Skip to content

Commit 9623d3c

Browse files
committed
add noises
1 parent e7d75ef commit 9623d3c

File tree

5 files changed

+83
-13
lines changed

5 files changed

+83
-13
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
"lodash": "^4.17.21",
1616
"masonry-layout": "^4.2.2",
1717
"nostr-fetch": "^0.15.0",
18-
"nostr-tools": "^1.5.0",
19-
"svelte": "^4.2.8"
18+
"nostr-tools": "2.1.5",
19+
"svelte": "^4.2.8",
20+
"svelte-sound": "^0.6.0"
2021
},
2122
"devDependencies": {
2223
"@sveltejs/vite-plugin-svelte": "^3.0.1",

src/App.svelte

+35
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
1616
import Masonry from "masonry-layout";
1717
18+
import { Sound } from "svelte-sound";
19+
import tone_file from "./assets/tone.mp3";
20+
21+
const tone = new Sound(tone_file);
22+
23+
1824
import { generateBackground } from "./utils";
1925
2026
const MONITOR =
@@ -100,6 +106,7 @@
100106
}
101107
if (!initialSyncComplete) return;
102108
processBatch();
109+
if(!isMuted) tone.play()
103110
// console.log(event.id)
104111
};
105112
@@ -291,6 +298,7 @@
291298
function processBatch() {
292299
if (!initialSyncComplete) initialSyncComplete = true;
293300
k30066.update((currentk30066) => [...currentk30066]);
301+
294302
}
295303
296304
function calculateDimensions(event) {
@@ -366,6 +374,14 @@
366374
return rtt ? `${letter}:${rtt}ms` : "";
367375
}
368376
377+
let isMuted = true; // Initial state of the sound, assuming it starts muted
378+
379+
// Function to toggle the muted state
380+
function toggleMute() {
381+
isMuted = !isMuted;
382+
// Here, you can also add logic to actually control the audio
383+
}
384+
369385
window.addEventListener("resize", () => {
370386
if (masonry) {
371387
masonry.layout();
@@ -374,6 +390,9 @@
374390
</script>
375391
376392
{#if initialSyncComplete}
393+
<button on:click={toggleMute} class="mute">
394+
{isMuted ? '🔇' : '🔈'}
395+
</button>
377396
<div id="header">
378397
<span class="sitetitle">nostrpul.se</span>
379398
<span class="credit">by nostr.watch</span>
@@ -665,6 +684,18 @@
665684
font-size: clamp(6rem, 12vw, 25em); /* Responsive font size */
666685
}
667686
687+
.mute {
688+
display:inline;
689+
background:none;
690+
border:none;
691+
position:absolute;
692+
top:10px;
693+
left:50%;
694+
transform: translateX(-50%);
695+
z-index: 100;
696+
font-size:3em;
697+
}
698+
668699
@media (max-width: 600px) {
669700
#stats {
670701
flex-direction: column;
@@ -721,5 +752,9 @@
721752
display: inline-block;
722753
font-weight: bolder;
723754
}
755+
756+
.mute {
757+
display:none;
758+
}
724759
}
725760
</style>

src/assets/tone.mp3

44.1 KB
Binary file not shown.

vite.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { svelte } from '@sveltejs/vite-plugin-svelte'
33

44
// https://vitejs.dev/config/
55
export default defineConfig({
6-
plugins: [svelte()]
6+
plugins: [svelte()],
7+
optimizeDeps: {
8+
exclude: ['svelte-sound']
9+
}
710
// base: '/nip66-dataviz-demo/'
811
})

yarn.lock

+41-10
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@
162162
resolved "https://registry.yarnpkg.com/@noble/ciphers/-/ciphers-0.2.0.tgz#a12cda60f3cf1ab5d7c77068c3711d2366649ed7"
163163
integrity sha512-6YBxJDAapHSdd3bLDv6x2wRPwq4QFMUaB3HvljNBUTThDd12eSm7/3F+2lnfzx2jvM+S6Nsy0jEt9QbPqSwqRw==
164164

165-
"@noble/curves@1.1.0", "@noble/curves@~1.1.0":
166-
version "1.1.0"
167-
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d"
168-
integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==
165+
"@noble/curves@1.2.0":
166+
version "1.2.0"
167+
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35"
168+
integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==
169169
dependencies:
170-
"@noble/hashes" "1.3.1"
170+
"@noble/hashes" "1.3.2"
171171

172172
"@noble/curves@^1.1.0":
173173
version "1.3.0"
@@ -176,11 +176,23 @@
176176
dependencies:
177177
"@noble/hashes" "1.3.3"
178178

179+
"@noble/curves@~1.1.0":
180+
version "1.1.0"
181+
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d"
182+
integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==
183+
dependencies:
184+
"@noble/hashes" "1.3.1"
185+
179186
180187
version "1.3.1"
181188
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9"
182189
integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==
183190

191+
192+
version "1.3.2"
193+
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39"
194+
integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==
195+
184196
"@noble/[email protected]", "@noble/hashes@^1.2.0", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1":
185197
version "1.3.3"
186198
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699"
@@ -685,6 +697,11 @@ get-size@^2.0.0, get-size@^2.0.2:
685697
resolved "https://registry.yarnpkg.com/get-size/-/get-size-2.0.3.tgz#54a1d0256b20ea7ac646516756202769941ad2ef"
686698
integrity sha512-lXNzT/h/dTjTxRbm9BXb+SGxxzkm97h/PCIKtlN/CBCxxmkkIVV21udumMS93MuVTDX583gqc94v3RjuHmI+2Q==
687699

700+
howler@^2.2.3:
701+
version "2.2.4"
702+
resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.4.tgz#bd3df4a4f68a0118a51e4bd84a2bfc2e93e6e5a1"
703+
integrity sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w==
704+
688705
689706
version "0.6.3"
690707
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
@@ -772,17 +789,24 @@ nostr-fetch@^0.15.0:
772789
dependencies:
773790
"@nostr-fetch/kernel" "^0.15.0"
774791

775-
nostr-tools@^1.5.0:
776-
version "1.17.0"
777-
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.17.0.tgz#b6f62e32fedfd9e68ec0a7ce57f74c44fc768e8c"
778-
integrity sha512-LZmR8GEWKZeElbFV5Xte75dOeE9EFUW/QLI1Ncn3JKn0kFddDKEfBbFN8Mu4TMs+L4HR/WTPha2l+PPuRnJcMw==
792+
nostr-tools@2.1.5:
793+
version "2.1.5"
794+
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-2.1.5.tgz#d38ac1139343cf13654841b8727bab8dd70563eb"
795+
integrity sha512-Gug/j54YGQ0ewB09dZW3mS9qfXWFlcOQMlyb1MmqQsuNO/95mfNOQSBi+jZ61O++Y+jG99SzAUPFLopUsKf0MA==
779796
dependencies:
780797
"@noble/ciphers" "0.2.0"
781-
"@noble/curves" "1.1.0"
798+
"@noble/curves" "1.2.0"
782799
"@noble/hashes" "1.3.1"
783800
"@scure/base" "1.1.1"
784801
"@scure/bip32" "1.3.1"
785802
"@scure/bip39" "1.2.1"
803+
optionalDependencies:
804+
nostr-wasm v0.1.0
805+
806+
807+
version "0.1.0"
808+
resolved "https://registry.yarnpkg.com/nostr-wasm/-/nostr-wasm-0.1.0.tgz#17af486745feb2b7dd29503fdd81613a24058d94"
809+
integrity sha512-78BTryCLcLYv96ONU8Ws3Q1JzjlAt+43pWQhIl86xZmWeegYCNLPml7yQ+gG3vR6V5h4XGj+TxO+SS5dsThQIA==
786810

787811
outlayer@^2.1.0:
788812
version "2.1.1"
@@ -863,6 +887,13 @@ svelte-hmr@^0.15.3:
863887
resolved "https://registry.yarnpkg.com/svelte-hmr/-/svelte-hmr-0.15.3.tgz#df54ccde9be3f091bf5f18fc4ef7b8eb6405fbe6"
864888
integrity sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==
865889

890+
svelte-sound@^0.6.0:
891+
version "0.6.0"
892+
resolved "https://registry.yarnpkg.com/svelte-sound/-/svelte-sound-0.6.0.tgz#a80390898850915aed11fe05ac3f478dd8bb4db4"
893+
integrity sha512-n0JJwWwNEmsGntSN9oe57yevHrIg8Lw3tW2XsfdrDhJXwrbAAmLvbBJQ0Z3TFqONUW7+OWb5Yx04CSCo7q56fA==
894+
dependencies:
895+
howler "^2.2.3"
896+
866897
svelte@^4.2.8:
867898
version "4.2.9"
868899
resolved "https://registry.yarnpkg.com/svelte/-/svelte-4.2.9.tgz#ece982ccc5b700c27e85cdf130c0e343c195fab5"

0 commit comments

Comments
 (0)