@babylonjs/core 9.3.4 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2012,7 +2012,7 @@ interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> {
2012
2012
  * @param options If provided, sets the alphabet and padding behavior used.
2013
2013
  * @returns A base64-encoded string.
2014
2014
  */
2015
- toBase64?(options?: { alphabet?: "base64" | "base64url" | undefined; omitPadding?: boolean | undefined }): string;
2015
+ toBase64(options?: { alphabet?: "base64" | "base64url" | undefined; omitPadding?: boolean | undefined }): string;
2016
2016
  }
2017
2017
 
2018
2018
  interface Int8ArrayConstructor {
@@ -2030,7 +2030,7 @@ interface Uint8ArrayConstructor {
2030
2030
  * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last
2031
2031
  * chunk is inconsistent with the `lastChunkHandling` option.
2032
2032
  */
2033
- fromBase64?(
2033
+ fromBase64(
2034
2034
  string: string,
2035
2035
  options?: {
2036
2036
  alphabet?: "base64" | "base64url" | undefined;
@@ -76,7 +76,7 @@ function JsDecodeBase64ToBinary(base64Data) {
76
76
  */
77
77
  export const EncodeArrayBufferToBase64 = (buffer) => {
78
78
  const bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);
79
- return bytes.toBase64 ? bytes.toBase64() : JsEncodeArrayBufferToBase64(bytes);
79
+ return typeof bytes.toBase64 === "function" ? bytes.toBase64() : JsEncodeArrayBufferToBase64(bytes);
80
80
  };
81
81
  /**
82
82
  * Converts a given base64 string as an ASCII encoded stream of data
@@ -92,7 +92,7 @@ export const DecodeBase64ToString = (base64Data) => {
92
92
  * @returns ArrayBuffer of byte data
93
93
  */
94
94
  export const DecodeBase64ToBinary = (base64Data) => {
95
- return Uint8Array.fromBase64 ? Uint8Array.fromBase64(base64Data).buffer : JsDecodeBase64ToBinary(base64Data);
95
+ return typeof Uint8Array.fromBase64 === "function" ? Uint8Array.fromBase64(base64Data).buffer : JsDecodeBase64ToBinary(base64Data);
96
96
  };
97
97
  /**
98
98
  * Converts a number to string and pads with preceding zeroes until it is of specified length.
@@ -1 +1 @@
1
- {"version":3,"file":"stringTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/stringTools.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,MAAc,EAAW,EAAE;IAC7D,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,MAAc,EAAW,EAAE;IAC/D,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAgC,EAAU,EAAE;IAC/D,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,SAAS,2BAA2B,CAAC,KAAiB;IAClD,MAAM,MAAM,GAAG,mEAAmE,CAAC;IACnF,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,IA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CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC;AACjH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,MAAc,EAAU,EAAE;IAC7D,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACpB,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AACF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,QAAQ;IACR,UAAU;IACV,MAAM;IACN,yBAAyB;IACzB,oBAAoB;IACpB,oBAAoB;IACpB,SAAS;CACZ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/**\r\n * Checks for a matching suffix at the end of a string (for ES5 and lower)\r\n * @param str Source string\r\n * @param suffix Suffix to search for in the source string\r\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\r\n * @deprecated Please use native string function instead\r\n */\r\nexport const EndsWith = (str: string, suffix: string): boolean => {\r\n return str.endsWith(suffix);\r\n};\r\n\r\n/**\r\n * Checks for a matching suffix at the beginning of a string (for ES5 and lower)\r\n * @param str Source string\r\n * @param suffix Suffix to search for in the source string\r\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\r\n * @deprecated Please use native string function instead\r\n */\r\nexport const StartsWith = (str: string, suffix: string): boolean => {\r\n if (!str) {\r\n return false;\r\n }\r\n return str.startsWith(suffix);\r\n};\r\n\r\n/**\r\n * Decodes a buffer into a string\r\n * @param buffer The buffer to decode\r\n * @returns The decoded string\r\n */\r\nexport const Decode = (buffer: Uint8Array | Uint16Array): string => {\r\n if (typeof TextDecoder !== \"undefined\") {\r\n return new TextDecoder().decode(buffer);\r\n }\r\n\r\n let result = \"\";\r\n for (let i = 0; i < buffer.byteLength; i++) {\r\n result += String.fromCharCode(buffer[i]);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nfunction JsEncodeArrayBufferToBase64(bytes: Uint8Array): string {\r\n const keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\n let output = \"\";\r\n let chr1, chr2, chr3, enc1, enc2, enc3, enc4;\r\n let i = 0;\r\n\r\n while (i < bytes.length) {\r\n chr1 = bytes[i++];\r\n chr2 = i < bytes.length ? bytes[i++] : Number.NaN;\r\n chr3 = i < bytes.length ? bytes[i++] : Number.NaN;\r\n\r\n enc1 = chr1 >> 2;\r\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\r\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\r\n enc4 = chr3 & 63;\r\n\r\n if (isNaN(chr2)) {\r\n enc3 = enc4 = 64;\r\n } else if (isNaN(chr3)) {\r\n enc4 = 64;\r\n }\r\n output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);\r\n }\r\n\r\n return output;\r\n}\r\n\r\nfunction JsDecodeBase64ToBinary(base64Data: string): ArrayBuffer {\r\n const decodedString = DecodeBase64ToString(base64Data);\r\n const bufferLength = decodedString.length;\r\n const bufferView = new Uint8Array(new ArrayBuffer(bufferLength));\r\n\r\n for (let i = 0; i < bufferLength; i++) {\r\n bufferView[i] = decodedString.charCodeAt(i);\r\n }\r\n\r\n return bufferView.buffer;\r\n}\r\n\r\n/**\r\n * Encode a buffer to a base64 string\r\n * @param buffer defines the buffer to encode\r\n * @returns the encoded string\r\n */\r\nexport const EncodeArrayBufferToBase64 = (buffer: ArrayBuffer | ArrayBufferView): string => {\r\n const bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);\r\n\r\n return bytes.toBase64 ? bytes.toBase64() : JsEncodeArrayBufferToBase64(bytes);\r\n};\r\n\r\n/**\r\n * Converts a given base64 string as an ASCII encoded stream of data\r\n * @param base64Data The base64 encoded string to decode\r\n * @returns Decoded ASCII string\r\n */\r\nexport const DecodeBase64ToString = (base64Data: string): string => {\r\n return atob(base64Data);\r\n};\r\n\r\n/**\r\n * Converts a given base64 string into an ArrayBuffer of raw byte data\r\n * @param base64Data The base64 encoded string to decode\r\n * @returns ArrayBuffer of byte data\r\n */\r\nexport const DecodeBase64ToBinary = (base64Data: string): ArrayBuffer => {\r\n return Uint8Array.fromBase64 ? Uint8Array.fromBase64(base64Data).buffer : JsDecodeBase64ToBinary(base64Data);\r\n};\r\n\r\n/**\r\n * Converts a number to string and pads with preceding zeroes until it is of specified length.\r\n * @param num the number to convert and pad\r\n * @param length the expected length of the string\r\n * @returns the padded string\r\n */\r\nexport const PadNumber = (num: number, length: number): string => {\r\n let str = String(num);\r\n while (str.length < length) {\r\n str = \"0\" + str;\r\n }\r\n return str;\r\n};\r\n/**\r\n * Helper to manipulate strings\r\n */\r\nexport const StringTools = {\r\n EndsWith,\r\n StartsWith,\r\n Decode,\r\n EncodeArrayBufferToBase64,\r\n DecodeBase64ToString,\r\n DecodeBase64ToBinary,\r\n PadNumber,\r\n};\r\n"]}
1
+ {"version":3,"file":"stringTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/stringTools.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,MAAc,EAAW,EAAE;IAC7D,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,MAAc,EAAW,EAAE;IAC/D,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;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C,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAExI,OAAO,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;AACxG,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAU,EAAE;IAC/D,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAe,EAAE;IACpE,OAAO,OAAO,UAAU,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC;AACvI,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,MAAc,EAAU,EAAE;IAC7D,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACpB,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AACF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,QAAQ;IACR,UAAU;IACV,MAAM;IACN,yBAAyB;IACzB,oBAAoB;IACpB,oBAAoB;IACpB,SAAS;CACZ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/**\r\n * Checks for a matching suffix at the end of a string (for ES5 and lower)\r\n * @param str Source string\r\n * @param suffix Suffix to search for in the source string\r\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\r\n * @deprecated Please use native string function instead\r\n */\r\nexport const EndsWith = (str: string, suffix: string): boolean => {\r\n return str.endsWith(suffix);\r\n};\r\n\r\n/**\r\n * Checks for a matching suffix at the beginning of a string (for ES5 and lower)\r\n * @param str Source string\r\n * @param suffix Suffix to search for in the source string\r\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\r\n * @deprecated Please use native string function instead\r\n */\r\nexport const StartsWith = (str: string, suffix: string): boolean => {\r\n if (!str) {\r\n return false;\r\n }\r\n return str.startsWith(suffix);\r\n};\r\n\r\n/**\r\n * Decodes a buffer into a string\r\n * @param buffer The buffer to decode\r\n * @returns The decoded string\r\n */\r\nexport const Decode = (buffer: Uint8Array | Uint16Array): string => {\r\n if (typeof TextDecoder !== \"undefined\") {\r\n return new TextDecoder().decode(buffer);\r\n }\r\n\r\n let result = \"\";\r\n for (let i = 0; i < buffer.byteLength; i++) {\r\n result += String.fromCharCode(buffer[i]);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nfunction JsEncodeArrayBufferToBase64(bytes: Uint8Array): string {\r\n const keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\n let output = \"\";\r\n let chr1, chr2, chr3, enc1, enc2, enc3, enc4;\r\n let i = 0;\r\n\r\n while (i < bytes.length) {\r\n chr1 = bytes[i++];\r\n chr2 = i < bytes.length ? bytes[i++] : Number.NaN;\r\n chr3 = i < bytes.length ? bytes[i++] : Number.NaN;\r\n\r\n enc1 = chr1 >> 2;\r\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\r\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\r\n enc4 = chr3 & 63;\r\n\r\n if (isNaN(chr2)) {\r\n enc3 = enc4 = 64;\r\n } else if (isNaN(chr3)) {\r\n enc4 = 64;\r\n }\r\n output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);\r\n }\r\n\r\n return output;\r\n}\r\n\r\nfunction JsDecodeBase64ToBinary(base64Data: string): ArrayBuffer {\r\n const decodedString = DecodeBase64ToString(base64Data);\r\n const bufferLength = decodedString.length;\r\n const bufferView = new Uint8Array(new ArrayBuffer(bufferLength));\r\n\r\n for (let i = 0; i < bufferLength; i++) {\r\n bufferView[i] = decodedString.charCodeAt(i);\r\n }\r\n\r\n return bufferView.buffer;\r\n}\r\n\r\n/**\r\n * Encode a buffer to a base64 string\r\n * @param buffer defines the buffer to encode\r\n * @returns the encoded string\r\n */\r\nexport const EncodeArrayBufferToBase64 = (buffer: ArrayBuffer | ArrayBufferView): string => {\r\n const bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);\r\n\r\n return typeof bytes.toBase64 === \"function\" ? bytes.toBase64() : JsEncodeArrayBufferToBase64(bytes);\r\n};\r\n\r\n/**\r\n * Converts a given base64 string as an ASCII encoded stream of data\r\n * @param base64Data The base64 encoded string to decode\r\n * @returns Decoded ASCII string\r\n */\r\nexport const DecodeBase64ToString = (base64Data: string): string => {\r\n return atob(base64Data);\r\n};\r\n\r\n/**\r\n * Converts a given base64 string into an ArrayBuffer of raw byte data\r\n * @param base64Data The base64 encoded string to decode\r\n * @returns ArrayBuffer of byte data\r\n */\r\nexport const DecodeBase64ToBinary = (base64Data: string): ArrayBuffer => {\r\n return typeof Uint8Array.fromBase64 === \"function\" ? Uint8Array.fromBase64(base64Data).buffer : JsDecodeBase64ToBinary(base64Data);\r\n};\r\n\r\n/**\r\n * Converts a number to string and pads with preceding zeroes until it is of specified length.\r\n * @param num the number to convert and pad\r\n * @param length the expected length of the string\r\n * @returns the padded string\r\n */\r\nexport const PadNumber = (num: number, length: number): string => {\r\n let str = String(num);\r\n while (str.length < length) {\r\n str = \"0\" + str;\r\n }\r\n return str;\r\n};\r\n/**\r\n * Helper to manipulate strings\r\n */\r\nexport const StringTools = {\r\n EndsWith,\r\n StartsWith,\r\n Decode,\r\n EncodeArrayBufferToBase64,\r\n DecodeBase64ToString,\r\n DecodeBase64ToBinary,\r\n PadNumber,\r\n};\r\n"]}
package/Misc/tools.js CHANGED
@@ -1221,7 +1221,7 @@ Tools._DefaultCdnUrl = "https://cdn.babylonjs.com";
1221
1221
  * When set, unversioned CDN URLs will be rewritten to include this version prefix.
1222
1222
  * @internal
1223
1223
  */
1224
- Tools._CdnVersion = "9.3.4";
1224
+ Tools._CdnVersion = "9.4.0";
1225
1225
  /**
1226
1226
  * @internal
1227
1227
  */