| 129 | * @since 5.11.0 |
| 130 | */ |
| 131 | export const devicePixelRatio = /* @__PURE__ */ new (class DevicePixelRatio { |
| 132 | #dpr = source(BROWSER ? window.devicePixelRatio : undefined); |
| 133 | |
| 134 | #update() { |
| 135 | const off = on( |
| 136 | window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`), |
| 137 | 'change', |
| 138 | () => { |
| 139 | set(this.#dpr, window.devicePixelRatio); |
| 140 | |
| 141 | off(); |
| 142 | this.#update(); |
| 143 | } |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | constructor() { |
| 148 | if (BROWSER) { |
| 149 | this.#update(); |
| 150 | } |
| 151 | |
| 152 | if (DEV) { |
| 153 | tag(this.#dpr, 'window.devicePixelRatio'); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | get current() { |
| 158 | get(this.#dpr); |
| 159 | return BROWSER ? window.devicePixelRatio : undefined; |
| 160 | } |
| 161 | })(); |