Skip to main content

euv_example/app/
const.rs

1/// Default window title for the native showcase binary.
2pub const SHOWCASE_WINDOW_TITLE: &str = "Euv Studio";
3/// Default logical window width in pixels.
4pub const SHOWCASE_WINDOW_WIDTH: u32 = 1200;
5/// Default logical window height in pixels.
6pub const SHOWCASE_WINDOW_HEIGHT: u32 = 800;
7/// Command-line flag enabling deterministic headless execution.
8pub const FLAG_HEADLESS: &str = "--headless";
9/// Command-line flag selecting the software rasterizer.
10pub const FLAG_SOFTWARE: &str = "--software";
11/// Command-line flag selecting the hardware GPU pipeline.
12pub const FLAG_HARDWARE: &str = "--hardware";
13/// Command-line flag selecting the hybrid compositor pipeline.
14pub const FLAG_HYBRID: &str = "--hybrid";
15/// Command-line flag keeping the native window open in an interactive event loop.
16pub const FLAG_INTERACTIVE: &str = "--interactive";
17/// Command-line flag capturing raw RGBA screenshots of all showcase routes into the following directory.
18pub const FLAG_CAPTURE_DIR: &str = "--capture-dir";
19/// Dev-only CLI flag printing the live AI Schema v1 runtime & layout snapshot JSON.
20#[cfg(all(debug_assertions, not(target_arch = "wasm32")))]
21pub const FLAG_AI_SCHEMA: &str = "--ai-schema";
22/// Dev-only CLI flag executing a single AI Schema v1 JSON request against the headless showcase.
23#[cfg(all(debug_assertions, not(target_arch = "wasm32")))]
24pub const FLAG_AI_QUERY: &str = "--ai-query";
25/// Dev-only CLI flag executing a single `euv://automation/...` protocol URI against the headless showcase.
26#[cfg(all(debug_assertions, not(target_arch = "wasm32")))]
27pub const FLAG_AI_URI: &str = "--ai-uri";
28/// Environment variable overriding the dev automation bridge bind address (defaults to `127.0.0.1:4174`).
29#[cfg(all(debug_assertions, not(target_arch = "wasm32")))]
30pub const ENV_AI_INSPECTOR_ADDR: &str = "EUV_AI_INSPECTOR_ADDR";
31/// Browser `window` property exposing the dev-only JSON automation protocol entrypoint on Web/WebView.
32#[cfg(all(debug_assertions, target_arch = "wasm32"))]
33pub(crate) const WEB_PROP_EUV_AUTOMATION: &str = "__euv_automation";
34/// Browser `window` property exposing the dev-only `euv://automation/...` URI dispatcher on Web/WebView.
35#[cfg(all(debug_assertions, target_arch = "wasm32"))]
36pub(crate) const WEB_PROP_EUV_AUTOMATION_URI: &str = "__euv_automation_uri";
37/// DOM KeyboardEvent key name for Enter.
38#[cfg(target_arch = "wasm32")]
39pub(crate) const WEB_KEY_ENTER: &str = "Enter";
40/// DOM KeyboardEvent key name for Backspace.
41#[cfg(target_arch = "wasm32")]
42pub(crate) const WEB_KEY_BACKSPACE: &str = "Backspace";
43/// DOM KeyboardEvent key name for Delete.
44#[cfg(target_arch = "wasm32")]
45pub(crate) const WEB_KEY_DELETE: &str = "Delete";
46/// DOM KeyboardEvent key name for Escape.
47#[cfg(target_arch = "wasm32")]
48pub(crate) const WEB_KEY_ESCAPE: &str = "Escape";
49/// DOM KeyboardEvent key name for Tab.
50#[cfg(target_arch = "wasm32")]
51pub(crate) const WEB_KEY_TAB: &str = "Tab";
52/// DOM KeyboardEvent key name for Spacebar.
53#[cfg(target_arch = "wasm32")]
54pub(crate) const WEB_KEY_SPACE: &str = " ";
55/// DOM KeyboardEvent key name for ArrowLeft.
56#[cfg(target_arch = "wasm32")]
57pub(crate) const WEB_KEY_ARROW_LEFT: &str = "ArrowLeft";
58/// DOM KeyboardEvent key name for ArrowRight.
59#[cfg(target_arch = "wasm32")]
60pub(crate) const WEB_KEY_ARROW_RIGHT: &str = "ArrowRight";
61/// DOM KeyboardEvent key name for ArrowUp.
62#[cfg(target_arch = "wasm32")]
63pub(crate) const WEB_KEY_ARROW_UP: &str = "ArrowUp";
64/// DOM KeyboardEvent key name for ArrowDown.
65#[cfg(target_arch = "wasm32")]
66pub(crate) const WEB_KEY_ARROW_DOWN: &str = "ArrowDown";
67/// DOM KeyboardEvent key name for Home.
68#[cfg(target_arch = "wasm32")]
69pub(crate) const WEB_KEY_HOME: &str = "Home";
70/// DOM KeyboardEvent key name for End.
71#[cfg(target_arch = "wasm32")]
72pub(crate) const WEB_KEY_END: &str = "End";
73/// DOM KeyboardEvent key name for PageUp.
74#[cfg(target_arch = "wasm32")]
75pub(crate) const WEB_KEY_PAGE_UP: &str = "PageUp";
76/// DOM KeyboardEvent key name for PageDown.
77#[cfg(target_arch = "wasm32")]
78pub(crate) const WEB_KEY_PAGE_DOWN: &str = "PageDown";
79/// DOM physical KeyboardEvent code for `W`.
80#[cfg(target_arch = "wasm32")]
81pub(crate) const WEB_CODE_KEY_W: &str = "KeyW";
82/// DOM physical KeyboardEvent code for `A`.
83#[cfg(target_arch = "wasm32")]
84pub(crate) const WEB_CODE_KEY_A: &str = "KeyA";
85/// DOM physical KeyboardEvent code for `S`.
86#[cfg(target_arch = "wasm32")]
87pub(crate) const WEB_CODE_KEY_S: &str = "KeyS";
88/// DOM physical KeyboardEvent code for `D`.
89#[cfg(target_arch = "wasm32")]
90pub(crate) const WEB_CODE_KEY_D: &str = "KeyD";
91/// DOM physical KeyboardEvent code for `E`.
92#[cfg(target_arch = "wasm32")]
93pub(crate) const WEB_CODE_KEY_E: &str = "KeyE";
94/// DOM physical KeyboardEvent code for `R`.
95#[cfg(target_arch = "wasm32")]
96pub(crate) const WEB_CODE_KEY_R: &str = "KeyR";
97/// DOM physical KeyboardEvent code for `P`.
98#[cfg(target_arch = "wasm32")]
99pub(crate) const WEB_CODE_KEY_P: &str = "KeyP";
100/// DOM physical KeyboardEvent code for `J`.
101#[cfg(target_arch = "wasm32")]
102pub(crate) const WEB_CODE_KEY_J: &str = "KeyJ";
103/// DOM physical KeyboardEvent code for `C`.
104#[cfg(target_arch = "wasm32")]
105pub(crate) const WEB_CODE_KEY_C: &str = "KeyC";
106/// DOM physical KeyboardEvent code for `V`.
107#[cfg(target_arch = "wasm32")]
108pub(crate) const WEB_CODE_KEY_V: &str = "KeyV";
109/// DOM physical KeyboardEvent code for `X`.
110#[cfg(target_arch = "wasm32")]
111pub(crate) const WEB_CODE_KEY_X: &str = "KeyX";
112/// DOM physical KeyboardEvent code for `Z`.
113#[cfg(target_arch = "wasm32")]
114pub(crate) const WEB_CODE_KEY_Z: &str = "KeyZ";
115/// DOM physical KeyboardEvent code for `K`.
116#[cfg(target_arch = "wasm32")]
117pub(crate) const WEB_CODE_KEY_K: &str = "KeyK";
118/// DOM physical KeyboardEvent code for Space.
119#[cfg(target_arch = "wasm32")]
120pub(crate) const WEB_CODE_SPACE: &str = "Space";
121/// DOM event name for pointer movement.
122#[cfg(target_arch = "wasm32")]
123pub(crate) const WEB_EVENT_POINTER_MOVE: &str = "pointermove";
124/// DOM event name for pointer press.
125#[cfg(target_arch = "wasm32")]
126pub(crate) const WEB_EVENT_POINTER_DOWN: &str = "pointerdown";
127/// DOM event name for pointer release.
128#[cfg(target_arch = "wasm32")]
129pub(crate) const WEB_EVENT_POINTER_UP: &str = "pointerup";
130/// DOM event name for pointer cancel.
131#[cfg(target_arch = "wasm32")]
132pub(crate) const WEB_EVENT_POINTER_CANCEL: &str = "pointercancel";
133/// DOM event name for lost pointer capture.
134#[cfg(target_arch = "wasm32")]
135pub(crate) const WEB_EVENT_LOST_POINTER_CAPTURE: &str = "lostpointercapture";
136/// DOM event name for window blur.
137#[cfg(target_arch = "wasm32")]
138pub(crate) const WEB_EVENT_BLUR: &str = "blur";
139/// DOM event name for mouse/trackpad wheel scroll.
140#[cfg(target_arch = "wasm32")]
141pub(crate) const WEB_EVENT_WHEEL: &str = "wheel";
142/// DOM event name for key down.
143#[cfg(target_arch = "wasm32")]
144pub(crate) const WEB_EVENT_KEY_DOWN: &str = "keydown";
145/// DOM event name for key up.
146#[cfg(target_arch = "wasm32")]
147pub(crate) const WEB_EVENT_KEY_UP: &str = "keyup";
148/// DOM event name for window resize.
149#[cfg(target_arch = "wasm32")]
150pub(crate) const WEB_EVENT_RESIZE: &str = "resize";
151/// DOM `PointerEvent.pointerType` value for touch contacts.
152#[cfg(target_arch = "wasm32")]
153pub(crate) const WEB_PTR_TYPE_TOUCH: &str = "touch";
154/// DOM `PointerEvent.pointerType` value for pen/stylus contacts.
155#[cfg(target_arch = "wasm32")]
156pub(crate) const WEB_PTR_TYPE_PEN: &str = "pen";
157/// DOM CSS selector for the mounted canvas element.
158#[cfg(target_arch = "wasm32")]
159pub(crate) const WEB_SELECTOR_CANVAS: &str = "canvas";
160/// DOM tag name for the hidden browser IME proxy input element.
161#[cfg(target_arch = "wasm32")]
162pub(crate) const WEB_IME_INPUT_TAG: &str = "input";
163/// DOM id attribute for the hidden browser IME proxy input element.
164#[cfg(target_arch = "wasm32")]
165pub(crate) const WEB_IME_INPUT_ID: &str = "euv-ime-proxy";
166/// DOM attribute name for `id`.
167#[cfg(target_arch = "wasm32")]
168pub(crate) const WEB_IME_ATTR_ID: &str = "id";
169/// DOM attribute name for `type`.
170#[cfg(target_arch = "wasm32")]
171pub(crate) const WEB_IME_ATTR_TYPE: &str = "type";
172/// DOM `<input type="text">` attribute value.
173#[cfg(target_arch = "wasm32")]
174pub(crate) const WEB_IME_ATTR_TEXT: &str = "text";
175/// DOM attribute name for `autocomplete`.
176#[cfg(target_arch = "wasm32")]
177pub(crate) const WEB_IME_ATTR_AUTOCOMPLETE: &str = "autocomplete";
178/// DOM attribute value disabling autocomplete/autocorrect/autocapitalize.
179#[cfg(target_arch = "wasm32")]
180pub(crate) const WEB_IME_ATTR_OFF: &str = "off";
181/// DOM attribute name for `autocorrect`.
182#[cfg(target_arch = "wasm32")]
183pub(crate) const WEB_IME_ATTR_AUTOCORRECT: &str = "autocorrect";
184/// DOM attribute name for `autocapitalize`.
185#[cfg(target_arch = "wasm32")]
186pub(crate) const WEB_IME_ATTR_AUTOCAPITALIZE: &str = "autocapitalize";
187/// DOM attribute name for `spellcheck`.
188#[cfg(target_arch = "wasm32")]
189pub(crate) const WEB_IME_ATTR_SPELLCHECK: &str = "spellcheck";
190/// DOM attribute value `"false"`.
191#[cfg(target_arch = "wasm32")]
192pub(crate) const WEB_IME_ATTR_FALSE: &str = "false";
193/// DOM attribute name for `aria-label`.
194#[cfg(target_arch = "wasm32")]
195pub(crate) const WEB_IME_ATTR_ARIA_LABEL: &str = "aria-label";
196/// Accessible label applied to the hidden IME proxy input.
197#[cfg(target_arch = "wasm32")]
198pub(crate) const WEB_IME_ARIA_LABEL: &str = "euv text input";
199/// DOM attribute name for inline CSS `style`.
200#[cfg(target_arch = "wasm32")]
201pub(crate) const WEB_IME_ATTR_STYLE: &str = "style";
202/// Inline CSS keeping the IME proxy input visually hidden without triggering iOS Safari auto-zoom or tap highlights.
203#[cfg(target_arch = "wasm32")]
204pub(crate) const WEB_IME_STYLE: &str = "position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none;border:0;padding:0;margin:0;z-index:-1;font-size:16px;outline:none;-webkit-tap-highlight-color:transparent;";
205/// DOM event name for text input changes.
206#[cfg(target_arch = "wasm32")]
207pub(crate) const WEB_EVENT_INPUT: &str = "input";
208/// DOM event name for IME composition start.
209#[cfg(target_arch = "wasm32")]
210pub(crate) const WEB_EVENT_COMPOSITION_START: &str = "compositionstart";
211/// DOM event name for IME composition update.
212#[cfg(target_arch = "wasm32")]
213pub(crate) const WEB_EVENT_COMPOSITION_UPDATE: &str = "compositionupdate";
214/// DOM event name for IME composition end.
215#[cfg(target_arch = "wasm32")]
216pub(crate) const WEB_EVENT_COMPOSITION_END: &str = "compositionend";
217/// DOM JS property name for an input element's string value.
218#[cfg(target_arch = "wasm32")]
219pub(crate) const WEB_PROP_VALUE: &str = "value";
220/// DOM JS property name for `CompositionEvent.data` / `InputEvent.data`.
221#[cfg(target_arch = "wasm32")]
222pub(crate) const WEB_PROP_DATA: &str = "data";
223/// DOM JS property name for `InputEvent.isComposing`.
224#[cfg(target_arch = "wasm32")]
225pub(crate) const WEB_PROP_IS_COMPOSING: &str = "isComposing";
226/// DOM `KeyboardEvent.key` value emitted by browsers while an IME is processing a keystroke.
227pub(crate) const WEB_KEY_PROCESS: &str = "Process";
228/// Legacy DOM `KeyboardEvent.keyCode` value (`229`) emitted while an IME is processing a keystroke.
229pub(crate) const WEB_KEY_CODE_IME_PROCESS: u32 = 229;
230/// Native action subcommand showing the browser soft keyboard / IME proxy.
231#[cfg(target_arch = "wasm32")]
232pub(crate) const WEB_IME_ACTION_SHOW: &str = "show";
233/// Native action subcommand hiding the browser soft keyboard / IME proxy.
234#[cfg(target_arch = "wasm32")]
235pub(crate) const WEB_IME_ACTION_HIDE: &str = "hide";
236/// Native action subcommand requesting browser fullscreen entry.
237#[cfg(target_arch = "wasm32")]
238pub(crate) const WEB_FS_ACTION_ON: &str = "on";
239/// Native action subcommand requesting browser fullscreen exit.
240#[cfg(target_arch = "wasm32")]
241pub(crate) const WEB_FS_ACTION_OFF: &str = "off";
242/// DOM event name for page visibility changes.
243#[cfg(target_arch = "wasm32")]
244pub(crate) const WEB_EVENT_VISIBILITY_CHANGE: &str = "visibilitychange";
245/// DOM event name for window focus gain.
246#[cfg(target_arch = "wasm32")]
247pub(crate) const WEB_EVENT_FOCUS: &str = "focus";
248/// DOM event name for page show lifecycle notifications.
249#[cfg(target_arch = "wasm32")]
250pub(crate) const WEB_EVENT_PAGE_SHOW: &str = "pageshow";
251/// DOM event name for page hide lifecycle notifications.
252#[cfg(target_arch = "wasm32")]
253pub(crate) const WEB_EVENT_PAGE_HIDE: &str = "pagehide";
254/// DOM event name for page unload termination warnings.
255#[cfg(target_arch = "wasm32")]
256pub(crate) const WEB_EVENT_BEFORE_UNLOAD: &str = "beforeunload";
257/// DOM event name for network online transitions.
258#[cfg(target_arch = "wasm32")]
259pub(crate) const WEB_EVENT_ONLINE: &str = "online";
260/// DOM event name for network offline transitions.
261#[cfg(target_arch = "wasm32")]
262pub(crate) const WEB_EVENT_OFFLINE: &str = "offline";
263/// DOM event name for media-query preference changes.
264#[cfg(target_arch = "wasm32")]
265pub(crate) const WEB_EVENT_CHANGE: &str = "change";
266/// DOM event name for URL fragment hash navigation changes.
267#[cfg(target_arch = "wasm32")]
268pub(crate) const WEB_EVENT_HASH_CHANGE: &str = "hashchange";
269/// DOM event name for browser history back/forward traversal.
270#[cfg(target_arch = "wasm32")]
271pub(crate) const WEB_EVENT_POP_STATE: &str = "popstate";
272/// DOM event name for standard fullscreen state transitions.
273#[cfg(target_arch = "wasm32")]
274pub(crate) const WEB_EVENT_FULLSCREEN_CHANGE: &str = "fullscreenchange";
275/// DOM event name for WebKit-prefixed Safari fullscreen state transitions.
276#[cfg(target_arch = "wasm32")]
277pub(crate) const WEB_EVENT_WEBKIT_FULLSCREEN_CHANGE: &str = "webkitfullscreenchange";
278/// DOM event name for mobile screen orientation changes.
279#[cfg(target_arch = "wasm32")]
280pub(crate) const WEB_EVENT_ORIENTATION_CHANGE: &str = "orientationchange";
281/// DOM event name for clipboard paste delivery.
282#[cfg(target_arch = "wasm32")]
283pub(crate) const WEB_EVENT_PASTE: &str = "paste";
284/// DOM event name for clipboard copy delivery of selected canvas text.
285#[cfg(target_arch = "wasm32")]
286pub(crate) const WEB_EVENT_COPY: &str = "copy";
287/// HTML attribute marking `euv-core`'s offscreen copy proxy `<textarea>` so native `copy` events pass through.
288#[cfg(target_arch = "wasm32")]
289pub(crate) const WEB_ATTR_COPY_PROXY: &str = "data-euv-copy-proxy";
290/// Attribute value identifying the offscreen copy proxy `<textarea>`.
291#[cfg(target_arch = "wasm32")]
292pub(crate) const WEB_COPY_PROXY_FLAG: &str = "1";
293/// DOM `DataTransfer.setData` method name for writing plain text on `copy` events.
294#[cfg(target_arch = "wasm32")]
295pub(crate) const WEB_PROP_SET_DATA: &str = "setData";
296/// DOM event name for legacy touch cancellation.
297#[cfg(target_arch = "wasm32")]
298pub(crate) const WEB_EVENT_TOUCH_CANCEL: &str = "touchcancel";
299/// DOM `ClipboardEvent.clipboardData` property key.
300#[cfg(target_arch = "wasm32")]
301pub(crate) const WEB_PROP_CLIPBOARD_DATA: &str = "clipboardData";
302/// DOM `DataTransfer.getData` method name.
303#[cfg(target_arch = "wasm32")]
304pub(crate) const WEB_PROP_GET_DATA: &str = "getData";
305/// Plain-text MIME type passed to `DataTransfer.getData`.
306#[cfg(target_arch = "wasm32")]
307pub(crate) const WEB_MIME_TEXT_PLAIN: &str = "text/plain";
308/// WebKit-prefixed `document.webkitFullscreenElement` property key.
309#[cfg(target_arch = "wasm32")]
310pub(crate) const WEB_PROP_WEBKIT_FULLSCREEN_ELEMENT: &str = "webkitFullscreenElement";
311/// DOM `window.screen` property key.
312#[cfg(target_arch = "wasm32")]
313pub(crate) const WEB_PROP_SCREEN: &str = "screen";
314/// DOM `screen.orientation` property key.
315#[cfg(target_arch = "wasm32")]
316pub(crate) const WEB_PROP_ORIENTATION: &str = "orientation";
317/// CSS media query detecting browser dark color scheme preference.
318#[cfg(target_arch = "wasm32")]
319pub(crate) const WEB_MEDIA_PREFERS_DARK: &str = "(prefers-color-scheme: dark)";
320/// DOM window property exposing the mobile soft-keyboard `VisualViewport`.
321#[cfg(target_arch = "wasm32")]
322pub(crate) const WEB_PROP_VISUAL_VIEWPORT: &str = "visualViewport";
323/// DOM `VisualViewport.width` property key.
324#[cfg(target_arch = "wasm32")]
325pub(crate) const WEB_PROP_WIDTH: &str = "width";
326/// DOM `VisualViewport.height` property key.
327#[cfg(target_arch = "wasm32")]
328pub(crate) const WEB_PROP_HEIGHT: &str = "height";
329/// DOM `VisualViewport.scale` property key guarding pinch-zoom from shrinking the layout canvas.
330#[cfg(target_arch = "wasm32")]
331pub(crate) const WEB_PROP_SCALE: &str = "scale";
332/// Minimum supported Web `devicePixelRatio` multiplier.
333#[cfg(target_arch = "wasm32")]
334pub(crate) const WEB_DPR_MIN: f32 = 1.0;
335/// Maximum supported Web `devicePixelRatio` multiplier covering 3x Retina displays at up to 200% zoom.
336#[cfg(target_arch = "wasm32")]
337pub(crate) const WEB_DPR_MAX: f32 = 6.0;
338/// Maximum safe physical Web `<canvas>` dimension per axis preventing GPU allocation failures.
339#[cfg(target_arch = "wasm32")]
340pub(crate) const WEB_CANVAS_MAX_PHYS_DIM: f64 = 8192.0;
341/// Threshold above `1.0` indicating browser pinch-zoom is active on `window.visualViewport`.
342#[cfg(target_arch = "wasm32")]
343pub(crate) const WEB_PINCH_ZOOM_THRESHOLD: f64 = 1.01;
344/// `window.open` target opening external URLs in a new tab.
345#[cfg(target_arch = "wasm32")]
346pub(crate) const WEB_OPEN_TARGET_BLANK: &str = "_blank";
347/// `window.open` security feature string preventing reverse tabnabbing.
348#[cfg(target_arch = "wasm32")]
349pub(crate) const WEB_OPEN_FEATURES_SAFE: &str = "noopener,noreferrer";
350/// DOM `EventTarget.addEventListener` method name for attaching non-passive listeners.
351#[cfg(target_arch = "wasm32")]
352pub(crate) const WEB_METHOD_ADD_EVENT_LISTENER: &str = "addEventListener";
353/// DOM `AddEventListenerOptions.passive` option key.
354#[cfg(target_arch = "wasm32")]
355pub(crate) const WEB_OPT_PASSIVE: &str = "passive";
356/// Minimum logical pixel viewport contraction treated as an active browser soft keyboard.
357#[cfg(target_arch = "wasm32")]
358pub(crate) const WEB_KEYBOARD_MIN_DELTA_PX: f32 = 80.0;
359/// JS parameter list for attaching a `ResizeObserver` onto the showcase `<canvas>`.
360#[cfg(target_arch = "wasm32")]
361pub(crate) const WEB_JS_ATTACH_RESIZE_ARGS: &str = "el,cb";
362/// JS body attaching a retained `ResizeObserver` preferring `device-pixel-content-box` for exact 1:1 physical canvas pixels across zoom and monitor switches.
363#[cfg(target_arch = "wasm32")]
364pub(crate) const WEB_JS_ATTACH_RESIZE_OBSERVER: &str = "if(typeof ResizeObserver!=='undefined'){var ro=new ResizeObserver(function(entries){var pw=0,ph=0;if(entries&&entries.length>0){var e=entries[entries.length-1];var d=e.devicePixelContentBoxSize;if(d&&d.length>0){pw=Math.round(d[0].inlineSize||0);ph=Math.round(d[0].blockSize||0);}}cb(pw,ph);});el.__euvRo=ro;try{ro.observe(el,{box:'device-pixel-content-box'});}catch(_){ro.observe(el);}}";
365/// JS parameter list for installing a self-rearming `devicePixelRatio` media-query watcher.
366#[cfg(target_arch = "wasm32")]
367pub(crate) const WEB_JS_WATCH_DPR_ARGS: &str = "cb";
368/// JS body listening for `devicePixelRatio` transitions via a retained `matchMedia` watcher plus a zero-reflow fallback poll catching silent Chromium/Safari DPR transitions on idle pages.
369#[cfg(target_arch = "wasm32")]
370pub(crate) const WEB_JS_WATCH_DPR_BODY: &str = "var lastDpr=window.devicePixelRatio||1;var rearm=function(){if(typeof matchMedia!=='function'){return;}var dpr=window.devicePixelRatio||1;var m=matchMedia('(resolution: '+dpr+'dppx)');window.__euvDprMql=m;var on=function(){if(window.__euvDprMql===m){window.__euvDprMql=null;}lastDpr=window.devicePixelRatio||1;cb();rearm();};if(m.addEventListener){m.addEventListener('change',on,{once:true});}else if(m.addListener){m.addListener(on);}};rearm();if(typeof setInterval==='function'){window.__euvDprTimer=setInterval(function(){var cur=window.devicePixelRatio||1;if(Math.abs(cur-lastDpr)>0.005){lastDpr=cur;cb();rearm();}},250);}";