@solid-primitives/media
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -0,3 +1,4 @@ | ||
import { isServer } from 'solid-js/web'; | ||
import { makeEventListener } from '@solid-primitives/event-listener'; | ||
import { createHydratableSignal, createHydratableStaticStore, entries } from '@solid-primitives/utils'; | ||
import { noop, createHydratableSignal, createHydratableStaticStore, entries } from '@solid-primitives/utils'; | ||
import { createHydratableSingletonRoot } from '@solid-primitives/rootless'; | ||
@@ -7,2 +8,5 @@ | ||
function makeMediaQueryListener(query, callback) { | ||
if (isServer) { | ||
return noop; | ||
} | ||
const mql = typeof query === "string" ? window.matchMedia(query) : query; | ||
@@ -12,2 +16,5 @@ return makeEventListener(mql, "change", callback); | ||
function createMediaQuery(query, serverFallback = false) { | ||
if (isServer) { | ||
return () => serverFallback; | ||
} | ||
const mql = window.matchMedia(query); | ||
@@ -32,3 +39,3 @@ const [state, setState] = createHydratableSignal(serverFallback, () => mql.matches); | ||
const fallback = options.fallbackState ?? getEmptyMatchesFromBreakpoints(breakpoints); | ||
if (!window.matchMedia) | ||
if (isServer || !window.matchMedia) | ||
return fallback; | ||
@@ -35,0 +42,0 @@ const { mediaFeature = "min-width", watchChange = true } = options; |
{ | ||
"name": "@solid-primitives/media", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Primitives for media query and device features", | ||
@@ -47,38 +47,7 @@ "author": "David Di Biase <dave.dibiase@gmail.com>", | ||
"type": "module", | ||
"main": "./dist/server.cjs", | ||
"module": "./dist/server.js", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"browser": { | ||
"./dist/server.js": "./dist/index.js", | ||
"./dist/server.cjs": "./dist/index.cjs" | ||
}, | ||
"browser": {}, | ||
"exports": { | ||
"worker": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"browser": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": "./dist/index.cjs" | ||
}, | ||
"deno": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"node": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"import": { | ||
@@ -91,8 +60,8 @@ "types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"@solid-primitives/event-listener": "^2.2.8", | ||
"@solid-primitives/rootless": "^1.3.0", | ||
"@solid-primitives/utils": "^5.5.0" | ||
"@solid-primitives/event-listener": "^2.2.9", | ||
"@solid-primitives/rootless": "^1.3.1", | ||
"@solid-primitives/utils": "^5.5.1" | ||
}, | ||
"peerDependencies": { | ||
"solid-js": "^1.6.0" | ||
"solid-js": "^1.6.12" | ||
}, | ||
@@ -103,3 +72,3 @@ "typesVersions": {}, | ||
"page": "vite build dev", | ||
"build": "jiti ../../scripts/build.ts --ssr", | ||
"build": "jiti ../../scripts/build.ts", | ||
"test": "vitest -c ../../configs/vitest.config.ts", | ||
@@ -106,0 +75,0 @@ "test:ssr": "pnpm run test --mode ssr" |
Sorry, the diff of this file is not supported yet
15915
6
192