Liking cljdoc? Tell your friends :D

com.blockether.spel.devices

Device and viewport presets for browser context emulation.

Provides keyword-based device presets (e.g. :iphone-14, :pixel-7) and viewport presets (e.g. :desktop-hd, :tablet, :mobile) that can be used with with-testing-page and new-context options.

Each device preset includes: viewport dimensions, device-scale-factor, is-mobile, has-touch, and user-agent string.

Viewport presets are simpler — just :width and :height.

Device and viewport presets for browser context emulation.

Provides keyword-based device presets (e.g. `:iphone-14`, `:pixel-7`)
and viewport presets (e.g. `:desktop-hd`, `:tablet`, `:mobile`) that
can be used with `with-testing-page` and `new-context` options.

Each device preset includes: viewport dimensions, device-scale-factor,
is-mobile, has-touch, and user-agent string.

Viewport presets are simpler — just :width and :height.
raw docstring

available-device-namesclj

(available-device-names)

Returns sorted sequence of string device names accepted by resolve-device-by-name.

Returns sorted sequence of string device names accepted by `resolve-device-by-name`.
sourceraw docstring

device-presetsclj

Map of keyword → device descriptor map.

Each descriptor contains keys matching new-context options: :viewport - {:width N :height N} :device-scale-factor - Double :is-mobile - Boolean :has-touch - Boolean :user-agent - String

Usage: (get device-presets :iphone-14) ;; => {:viewport {:width 390 :height 844} :device-scale-factor 3 ...}

Map of keyword → device descriptor map.

Each descriptor contains keys matching `new-context` options:
  :viewport             - {:width N :height N}
  :device-scale-factor  - Double
  :is-mobile            - Boolean
  :has-touch            - Boolean
  :user-agent           - String

Usage:
  (get device-presets :iphone-14)
  ;; => {:viewport {:width 390 :height 844} :device-scale-factor 3 ...}
sourceraw docstring

resolve-deviceclj

(resolve-device device)

Resolves a device keyword to its descriptor map.

Params: device - Keyword (e.g. :iphone-14, :pixel-7).

Returns: Device descriptor map, or throws if not found.

Example: (resolve-device :iphone-14) ;; => {:viewport {:width 390 :height 844} :device-scale-factor 3 ...}

Resolves a device keyword to its descriptor map.

Params:
  `device` - Keyword (e.g. :iphone-14, :pixel-7).

Returns:
  Device descriptor map, or throws if not found.

Example:
  (resolve-device :iphone-14)
  ;; => {:viewport {:width 390 :height 844} :device-scale-factor 3 ...}
sourceraw docstring

resolve-device-by-nameclj

(resolve-device-by-name device-name)

Resolves a case-insensitive device name string to its descriptor.

Used by the daemon for CLI set_device commands.

Params: device-name - String (e.g. "iPhone 14", "pixel 7", "desktop chrome").

Returns: Device descriptor map (same shape as device-presets values), or nil if not found.

Resolves a case-insensitive device name string to its descriptor.

Used by the daemon for CLI `set_device` commands.

Params:
  `device-name` - String (e.g. "iPhone 14", "pixel 7", "desktop chrome").

Returns:
  Device descriptor map (same shape as `device-presets` values),
  or nil if not found.
sourceraw docstring

resolve-viewportclj

(resolve-viewport viewport)

Resolves a viewport keyword or map to {:width N :height N}.

Accepts:

  • A keyword (e.g. :mobile, :desktop-hd) → looks up viewport-presets
  • A map with :width/:height → returned as-is
  • nil → returns nil (use default)

Returns: {:width N :height N}, or nil.

Resolves a viewport keyword or map to {:width N :height N}.

Accepts:
  - A keyword (e.g. :mobile, :desktop-hd) → looks up viewport-presets
  - A map with :width/:height → returned as-is
  - nil → returns nil (use default)

Returns:
  {:width N :height N}, or nil.
sourceraw docstring

viewport-presetsclj

Map of keyword → viewport dimensions {:width N :height N}.

Simpler than device presets — just sets the viewport size without changing user-agent, device-scale-factor, etc.

Usage: (get viewport-presets :mobile) ;; => {:width 375 :height 667}

Map of keyword → viewport dimensions {:width N :height N}.

Simpler than device presets — just sets the viewport size without
changing user-agent, device-scale-factor, etc.

Usage:
  (get viewport-presets :mobile)
  ;; => {:width 375 :height 667}
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close