New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/audio

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/audio - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

8

dist/index.d.ts

@@ -12,2 +12,6 @@ import { Accessor } from 'solid-js';

}
declare type AudioSource = string | undefined | HTMLAudioElement | MediaSource | (string & MediaSource);
declare type AudioEventHandlers = {
[K in keyof HTMLMediaElementEventMap]?: (event: HTMLMediaElementEventMap[K]) => void;
};
/**

@@ -55,3 +59,3 @@ * Generates a basic audio instance with limited functionality.

* @return store.currentTime - Current time of the playhead
* @return store.duration - Duratio of the audio player
* @return store.duration - Duration of the audio player
*

@@ -79,2 +83,2 @@ * @example

export { AudioState, createAudio, makeAudio, makeAudioPlayer };
export { AudioEventHandlers, AudioSource, AudioState, createAudio, makeAudio, makeAudioPlayer };

@@ -1,12 +0,99 @@

import {
AudioState,
createAudio,
makeAudio,
makeAudioPlayer
} from "./chunk-T5LONJJD.js";
export {
AudioState,
createAudio,
makeAudio,
makeAudioPlayer
import { onMount, onCleanup, createEffect } from 'solid-js';
import { access, createStaticStore } from '@solid-primitives/utils';
// src/index.ts
var AudioState = /* @__PURE__ */ ((AudioState2) => {
AudioState2["LOADING"] = "loading";
AudioState2["PLAYING"] = "playing";
AudioState2["PAUSED"] = "paused";
AudioState2["COMPLETE"] = "complete";
AudioState2["STOPPED"] = "stopped";
AudioState2["READY"] = "ready";
AudioState2["ERROR"] = "error";
return AudioState2;
})(AudioState || {});
var unwrapSource = (src) => {
let player;
if (src instanceof HTMLAudioElement) {
player = src;
} else {
player = new Audio();
player[typeof src === "string" ? "src" : "srcObject"] = src;
}
return player;
};
var makeAudio = (src, handlers = {}) => {
const player = unwrapSource(src);
const listeners = (enabled) => {
Object.entries(handlers).forEach(
([evt, handler]) => player[enabled ? "addEventListener" : "removeEventListener"](
evt,
handler
)
);
};
onMount(() => listeners(true));
onCleanup(() => {
player.pause();
listeners(false);
});
return player;
};
var makeAudioPlayer = (src, handlers = {}) => {
const player = makeAudio(src, handlers);
const play = () => player.play();
const pause = () => player.pause();
const seek = (time) => player.fastSeek ? player.fastSeek(time) : player.currentTime = time;
const setVolume = (volume) => player.volume = volume;
return { play, pause, seek, setVolume, player };
};
var createAudio = (src, playing, volume) => {
const player = unwrapSource(access(src));
const [store, setStore] = createStaticStore({
state: "loading" /* LOADING */,
player,
currentTime: 0,
get duration() {
return this.player.duration;
},
get volume() {
return this.player.volume;
}
});
const { play, pause, setVolume, seek } = makeAudioPlayer(store.player, {
loadeddata: () => {
setStore({
state: "ready" /* READY */,
duration: player.duration
});
if (playing && playing() == true)
play();
},
timeupdate: () => setStore("currentTime", player.currentTime),
loadstart: () => setStore("state", "loading" /* LOADING */),
playing: () => setStore("state", "playing" /* PLAYING */),
pause: () => setStore("state", "paused" /* PAUSED */),
error: () => setStore("state", "error" /* ERROR */)
});
if (src instanceof Function) {
createEffect(() => {
const newSrc = access(src);
if (newSrc instanceof HTMLAudioElement) {
setStore("player", () => newSrc);
} else {
store.player[typeof newSrc === "string" ? "src" : "srcObject"] = newSrc;
}
seek(0);
});
}
if (playing) {
createEffect(() => playing() === true ? play() : pause());
}
if (volume) {
createEffect(() => setVolume(volume()));
setVolume(volume());
}
return [store, { seek, play, pause, setVolume }];
};
export { AudioState, createAudio, makeAudio, makeAudioPlayer };

@@ -1,36 +0,51 @@

import {
AudioState
} from "./chunk-T5LONJJD.js";
import 'solid-js';
import { noop } from '@solid-primitives/utils';
// src/server.ts
import { noop } from "@solid-primitives/utils";
var AudioState2 = AudioState;
var makeAudio = () => ({});
var makeAudioPlayer = () => ({
pause: noop,
play: noop,
player: {},
seek: noop,
setVolume: noop
});
var createAudio = () => [
// src/index.ts
var AudioState = /* @__PURE__ */ ((AudioState2) => {
AudioState2["LOADING"] = "loading";
AudioState2["PLAYING"] = "playing";
AudioState2["PAUSED"] = "paused";
AudioState2["COMPLETE"] = "complete";
AudioState2["STOPPED"] = "stopped";
AudioState2["READY"] = "ready";
AudioState2["ERROR"] = "error";
return AudioState2;
})(AudioState || {});
var makeAudio = (src, handlers = {}) => {
{
state: AudioState2.LOADING,
currentTime: 0,
duration: 0,
volume: 0,
player: {}
},
return {};
}
};
var makeAudioPlayer = (src, handlers = {}) => {
{
seek: noop,
setVolume: noop,
play: noop,
pause: noop
return {
pause: noop,
play: noop,
player: {},
seek: noop,
setVolume: noop
};
}
];
export {
AudioState2 as AudioState,
createAudio,
makeAudio,
makeAudioPlayer
};
var createAudio = (src, playing, volume) => {
{
return [
{
state: "loading" /* LOADING */,
currentTime: 0,
duration: 0,
volume: 0,
player: {}
},
{
seek: noop,
setVolume: noop,
play: noop,
pause: noop
}
];
}
};
export { AudioState, createAudio, makeAudio, makeAudioPlayer };
{
"name": "@solid-primitives/audio",
"version": "1.3.2",
"version": "1.3.3",
"description": "Primitives to manage audio and single sounds.",

@@ -29,5 +29,21 @@ "author": "David Di Biase <dave.dibiase@gmail.com>",

"main": "./dist/server.cjs",
"module": "./dist/index.js",
"module": "./dist/server.js",
"browser": {
"./dist/server.cjs": "./dist/index.cjs",
"./dist/server.js": "./dist/index.js"
},
"types": "./dist/index.d.ts",
"exports": {
"worker": {
"import": "./dist/server.js",
"require": "./dist/server.cjs"
},
"browser": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"deno": {
"import": "./dist/server.js",
"require": "./dist/server.cjs"
},
"node": {

@@ -45,30 +61,20 @@ "import": "./dist/server.js",

],
"testEnvironment": "jsdom",
"devDependencies": {
"jsdom": "^20.0.0",
"prettier": "^2.7.1",
"solid-heroicons": "^2.0.3",
"solid-js": "^1.5.1",
"solid-register": "^0.2.5",
"solid-testing-library": "^0.2.1",
"tslib": "^2.4.0",
"tsup": "^6.2.2",
"typescript": "^4.7.4",
"unocss": "^0.44.7",
"uvu": "^0.5.6",
"vite": "^3.0.7",
"vite-plugin-solid": "^2.3.0"
"solid-js": "^1.5.0",
"solid-testing-library": "^0.2.1"
},
"dependencies": {
"@solid-primitives/utils": "^3.1.0"
},
"peerDependencies": {
"solid-js": "^1.4.4"
"solid-js": "^1.5.0"
},
"dependencies": {
"@solid-primitives/utils": "^3.0.2"
},
"scripts": {
"start": "vite serve dev",
"dev": "vite serve dev",
"build": "tsup",
"test": "uvu -b -r solid-register"
"build": "jiti ../../scripts/build.ts --ssr",
"test": "vitest -c ../../configs/vitest.config.ts",
"test:ssr": "pnpm run test --mode ssr"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc