Skip to content

Commit e04dfa3

Browse files
committed
fixes and sdk update
1 parent 520c491 commit e04dfa3

File tree

4 files changed

+51
-52
lines changed

4 files changed

+51
-52
lines changed

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@ai-sdk/svelte": "^1.1.24",
23-
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@e264dec",
23+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@2f43d8c",
2424
"@appwrite.io/pink-icons": "0.25.0",
2525
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@df765cc",
2626
"@appwrite.io/pink-legacy": "^1.0.3",

src/lib/helpers/fingerprint.ts

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -69,52 +69,46 @@ function getWebGLFingerprint(): string {
6969
}
7070
}
7171

72-
function getAudioFingerprint(): Promise<string> {
73-
return new Promise((resolve) => {
74-
try {
75-
const AudioContext =
76-
window.AudioContext ||
77-
(window as unknown as { webkitAudioContext: typeof window.AudioContext })
78-
.webkitAudioContext;
79-
if (!AudioContext) {
80-
resolve('');
81-
return;
82-
}
83-
84-
const context = new AudioContext();
85-
const oscillator = context.createOscillator();
86-
const analyser = context.createAnalyser();
87-
const gain = context.createGain();
88-
const processor = context.createScriptProcessor(4096, 1, 1);
89-
90-
gain.gain.value = 0;
91-
oscillator.type = 'triangle';
92-
oscillator.frequency.value = 10000;
93-
94-
oscillator.connect(analyser);
95-
analyser.connect(processor);
96-
processor.connect(gain);
97-
gain.connect(context.destination);
98-
99-
oscillator.start(0);
100-
101-
const dataArray = new Float32Array(analyser.frequencyBinCount);
102-
analyser.getFloatFrequencyData(dataArray);
103-
104-
let sum = 0;
105-
for (let i = 0; i < dataArray.length; i++) {
106-
sum += Math.abs(dataArray[i]);
107-
}
108-
109-
oscillator.stop();
110-
processor.disconnect();
111-
context.close();
112-
113-
resolve(sum.toString());
114-
} catch {
115-
resolve('');
72+
async function getAudioFingerprint(): Promise<string> {
73+
try {
74+
const OfflineCtx =
75+
window.OfflineAudioContext ||
76+
(window as unknown as { webkitOfflineAudioContext: typeof OfflineAudioContext })
77+
.webkitOfflineAudioContext;
78+
if (!OfflineCtx) return '';
79+
80+
const sampleRate = 44100;
81+
const length = 4096;
82+
const context = new OfflineCtx(1, length, sampleRate);
83+
84+
const oscillator = context.createOscillator();
85+
oscillator.type = 'triangle';
86+
oscillator.frequency.value = 10000;
87+
88+
const compressor = context.createDynamicsCompressor();
89+
compressor.threshold.value = -50;
90+
compressor.knee.value = 40;
91+
compressor.ratio.value = 12;
92+
compressor.attack.value = 0;
93+
compressor.release.value = 0.25;
94+
95+
oscillator.connect(compressor);
96+
compressor.connect(context.destination);
97+
98+
oscillator.start(0);
99+
100+
const buffer = await context.startRendering();
101+
const samples = buffer.getChannelData(0);
102+
103+
let sum = 0;
104+
for (let i = 0; i < samples.length; i++) {
105+
sum += Math.abs(samples[i]);
116106
}
117-
});
107+
108+
return sum.toString();
109+
} catch {
110+
return '';
111+
}
118112
}
119113

120114
interface StaticSignals {

src/routes/(console)/project-[region]-[project]/pausedProjectModal.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
import { generateFingerprintToken } from '$lib/helpers/fingerprint';
99
import { Alert, Layout, Modal, Typography } from '@appwrite.io/pink-svelte';
1010
11-
export let show = false;
12-
export let projectId: string;
11+
let {
12+
show = $bindable(false),
13+
projectId
14+
}: {
15+
show: boolean;
16+
projectId: string;
17+
} = $props();
1318
14-
let loading = false;
15-
let error: string | null = null;
19+
let loading = $state(false);
20+
let error: string | null = $state(null);
1621
1722
async function handleResume() {
1823
loading = true;

0 commit comments

Comments
 (0)