diff --git a/index.html b/index.html
index 18aa529..9b5a517 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,6 @@
Brightness Tray
-
diff --git a/package-lock.json b/package-lock.json
index 63b82d6..514be56 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,6 @@
"version": "0.1.0",
"dependencies": {
"@tauri-apps/api": "1.5.x",
- "core-js": "^3.34.0",
"lodash-es": "4.x",
"vue": "3.x"
},
@@ -1282,16 +1281,6 @@
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true
},
- "node_modules/core-js": {
- "version": "3.34.0",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.34.0.tgz",
- "integrity": "sha512-aDdvlDder8QmY91H88GzNi9EtQi2TjvQhpCX6B1v/dAZHU1AuLgHvRh54RiOerpEhEW46Tkf+vgAViB/CWC0ag==",
- "hasInstallScript": true,
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/core-js"
- }
- },
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
diff --git a/package.json b/package.json
index d25d97c..10526bc 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,6 @@
},
"dependencies": {
"@tauri-apps/api": "1.5.x",
- "core-js": "^3.34.0",
"lodash-es": "4.x",
"vue": "3.x"
},
diff --git a/src/polyfill.d.ts b/src/polyfill.d.ts
deleted file mode 100644
index 9c6604c..0000000
--- a/src/polyfill.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-interface Uint8Array {
- toBase64(options?: { alphabet?: "base64" | "base64url" }): string;
-}
diff --git a/src/polyfill.js b/src/polyfill.js
deleted file mode 100644
index 755eb80..0000000
--- a/src/polyfill.js
+++ /dev/null
@@ -1 +0,0 @@
-import "core-js/full/typed-array/to-base64";
diff --git a/src/polyfill.ts b/src/polyfill.ts
new file mode 100644
index 0000000..729c27f
--- /dev/null
+++ b/src/polyfill.ts
@@ -0,0 +1,28 @@
+export function toBase64(array: Uint8Array | Uint8ClampedArray): string {
+ let base64 = "";
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const padding = array.length % 3;
+
+ for (let i = 0; i < array.length - padding; i += 3) {
+ const combined = (array[i] << 16) | (array[i + 1] << 8) | array[i + 2];
+ base64 +=
+ characters[(combined >> 18) & 63] +
+ characters[(combined >> 12) & 63] +
+ characters[(combined >> 6) & 63] +
+ characters[combined & 63];
+ }
+
+ if (padding === 2) {
+ const combined = (array[array.length - 2] << 8) | array[array.length - 1];
+ base64 +=
+ characters[(combined >> 10) & 63] +
+ characters[(combined >> 4) & 63] +
+ characters[(combined << 2) & 63] +
+ "=";
+ } else if (padding === 1) {
+ const combined = array[array.length - 1];
+ base64 += characters[(combined >> 2) & 63] + characters[(combined << 4) & 63] + "==";
+ }
+
+ return base64;
+}
diff --git a/src/wm.ts b/src/wm.ts
index efb75aa..4e748ec 100644
--- a/src/wm.ts
+++ b/src/wm.ts
@@ -3,6 +3,7 @@ import { listen, Event } from "@tauri-apps/api/event";
import { LogicalPosition, LogicalSize, PhysicalPosition, appWindow } from "@tauri-apps/api/window";
import { reactive, watch, watchEffect, ref, computed } from "vue";
import { watchDelayed, watchThrottled } from "./watchers";
+import { toBase64 } from "./polyfill";
import settings from "./settings";
const panelState = reactive({
@@ -222,7 +223,7 @@ watchEffect(() => {
const imageData = ctx.getImageData(0, 0, scaledSize, scaledSize);
invoke("set_tray_icon", {
icon: {
- rgba: new Uint8Array(imageData.data.buffer).toBase64(),
+ rgba: toBase64(imageData.data),
width: imageData.width,
height: imageData.height,
},