@buerokratt-ria/common-gui-components 0.0.33 → 0.0.34

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 (2) hide show
  1. package/package.json +1 -1
  2. package/services/file.ts +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
package/services/file.ts CHANGED
@@ -1,7 +1,18 @@
1
- import { Buffer } from 'buffer';
1
+ /**
2
+ * Converts a base64 string to a Uint8Array (browser-compatible alternative to Buffer)
3
+ */
4
+ const base64ToUint8Array = (base64: string): Uint8Array<ArrayBuffer> => {
5
+ const binaryString = atob(base64);
6
+ const bytes = new Uint8Array(binaryString.length);
7
+ for (let i = 0; i < binaryString.length; i++) {
8
+ bytes[i] = binaryString.charCodeAt(i);
9
+ }
10
+ return bytes;
11
+ };
2
12
 
3
13
  export const saveFile = async (base64String: string, fileName: `${string}.${string}`, type: string) => {
4
- const blob = new Blob([Buffer.from(base64String, 'base64')], {
14
+ const bytes = base64ToUint8Array(base64String);
15
+ const blob = new Blob([bytes], {
5
16
  type: type,
6
17
  });
7
18