Skip to main content

euv_docs/bundle/
const.rs

1/// CLI flag enabling release profile compilation for multi-locale WASM bundles.
2pub const DOCS_FLAG_RELEASE: &str = "--release";
3/// CLI flag enabling debug profile compilation for multi-locale WASM bundles.
4pub const DOCS_FLAG_DEBUG: &str = "--debug";
5/// CLI flag selecting a single locale to build (`--locale <dir|prefix|label>`).
6pub const DOCS_FLAG_LOCALE: &str = "--locale";
7/// CLI flag forcing legacy single-locale static HTML output even when `locales:` is declared.
8pub const DOCS_FLAG_STATIC_HTML: &str = "--static-html";
9
10pub(crate) const BUNDLE_PKG_DIR: &str = "pkg";
11pub(crate) const BUNDLE_INDEX_HTML: &str = "index.html";
12pub(crate) const BUNDLE_NOT_FOUND_HTML: &str = "404.html";
13pub(crate) const BUNDLE_PUBLIC_DIR: &str = "public";
14pub(crate) const BUNDLE_BUILDER_DIR: &str = "euv-docs-wasm-builder";
15pub(crate) const BUNDLE_TARGET_DIR: &str = "euv-docs-wasm-target";
16pub(crate) const BUNDLE_CRATE_NAME: &str = "euv_docs_site";
17pub(crate) const BUNDLE_SHELL_JSON_FILE: &str = "site_shell.json";
18pub(crate) const BUNDLE_BODIES_BIN_FILE: &str = "site_bodies.euvz";
19pub(crate) const BUNDLE_CARGO_TOML: &str = "Cargo.toml";
20pub(crate) const BUNDLE_SRC_DIR: &str = "src";
21pub(crate) const BUNDLE_LIB_RS: &str = "lib.rs";
22pub(crate) const BUNDLE_WASM_PACK_BIN: &str = "wasm-pack";
23pub(crate) const BUNDLE_ARG_BUILD: &str = "build";
24pub(crate) const BUNDLE_ARG_TARGET: &str = "--target";
25pub(crate) const BUNDLE_ARG_WEB: &str = "web";
26pub(crate) const BUNDLE_ARG_NO_TS: &str = "--no-typescript";
27pub(crate) const BUNDLE_ARG_OUT_DIR: &str = "--out-dir";
28pub(crate) const BUNDLE_ARG_OUT_NAME: &str = "--out-name";
29pub(crate) const BUNDLE_ARG_DEV: &str = "--dev";
30pub(crate) const BUNDLE_ENV_TARGET_DIR: &str = "CARGO_TARGET_DIR";
31pub(crate) const BUNDLE_ENV_RUSTC_WRAPPER: &str = "RUSTC_WRAPPER";
32pub(crate) const BUNDLE_NAME_PREFIX: &str = "euv_docs_";
33pub(crate) const BUNDLE_BG_WASM_SUFFIX: &str = "_bg.wasm";
34pub(crate) const BUNDLE_JS_EXT: &str = ".js";
35pub(crate) const BUNDLE_MJS_EXT: &str = ".mjs";
36pub(crate) const BUNDLE_CSS_EXT: &str = ".css";
37pub(crate) const BUNDLE_FORBIDDEN_DIRS: [&str; 2] = ["js", "webfonts"];
38pub(crate) const BUNDLE_SKIP_FILES: [&str; 1] = [".DS_Store"];
39pub(crate) const BUNDLE_EXPORT_PREFIX: &str = "export ";
40pub(crate) const BUNDLE_EXPORT_BRACE: &str = "export {";
41pub(crate) const BUNDLE_EXPORT_DEFAULT: &str = "export default ";
42pub(crate) const BUNDLE_WASM_BINDGEN_VER: &str = "0.2";
43pub(crate) const BUNDLE_DIR_CORE: &str = "core";
44pub(crate) const BUNDLE_DIR_MACROS: &str = "macros";
45pub(crate) const BUNDLE_DIR_UI: &str = "ui";
46pub(crate) const BUNDLE_DEFAULT_LOCALE_SUFFIX: &str = "default";
47pub(crate) const BUNDLE_ESC_AMP: &str = "&amp;";
48pub(crate) const BUNDLE_ESC_LT: &str = "&lt;";
49pub(crate) const BUNDLE_ESC_GT: &str = "&gt;";
50pub(crate) const BUNDLE_ESC_QUOT: &str = "&quot;";
51pub(crate) const BUNDLE_HTML_DOCTYPE_OPEN: &str = "<!DOCTYPE html>\n<html lang=\"";
52pub(crate) const BUNDLE_ERR_NO_LOCALES: &str =
53    "No locales declared in root README.md frontmatter for multi-locale WASM build";
54pub(crate) const BUNDLE_ERR_NO_MATCHING_LOCALE: &str =
55    "No locale matched the requested --locale filter";
56pub(crate) const BUNDLE_ERR_WASM_PACK: &str = "wasm-pack build failed";
57pub(crate) const BUNDLE_WRAPPER_LIB_RS: &str = r#"use wasm_bindgen::prelude::wasm_bindgen;
58
59const SITE_SHELL_JSON: &str = include_str!("site_shell.json");
60const SITE_BODIES_BIN: &[u8] = include_bytes!("site_bodies.euvz");
61
62#[wasm_bindgen]
63pub fn euv_docs_web_start() -> u64 {
64    euv_docs::boot_wasm_docs_compressed_bundle(SITE_SHELL_JSON, SITE_BODIES_BIN)
65}
66
67#[wasm_bindgen]
68pub fn euv_docs_render_route(route: &str) -> u64 {
69    euv_docs::wasm_docs_render_route(route)
70}
71
72#[wasm_bindgen]
73pub fn euv_docs_pointer_move(x: f32, y: f32) -> u64 {
74    euv_docs::wasm_docs_pointer_move(x, y)
75}
76
77#[wasm_bindgen]
78pub fn euv_docs_pointer_down(x: f32, y: f32) -> u64 {
79    euv_docs::wasm_docs_pointer_down(x, y)
80}
81
82#[wasm_bindgen]
83pub fn euv_docs_pointer_up(x: f32, y: f32) -> u64 {
84    euv_docs::wasm_docs_pointer_up(x, y)
85}
86
87#[wasm_bindgen]
88pub fn euv_docs_pointer_event(
89    kind: u8,
90    pointer_id: u32,
91    is_touch: bool,
92    x: f32,
93    y: f32,
94    pressure: f32,
95) -> u64 {
96    euv_docs::wasm_docs_pointer_event(kind, pointer_id, is_touch, x, y, pressure)
97}
98
99#[wasm_bindgen]
100pub fn euv_docs_scroll(dx: f32, dy: f32) -> u64 {
101    euv_docs::wasm_docs_scroll(dx, dy)
102}
103
104#[wasm_bindgen]
105pub fn euv_docs_scroll_at(x: f32, y: f32, dx: f32, dy: f32) -> u64 {
106    euv_docs::wasm_docs_scroll_at(x, y, dx, dy)
107}
108
109#[wasm_bindgen]
110pub fn euv_docs_key_down(key: &str) -> u64 {
111    euv_docs::wasm_docs_key_down(key)
112}
113
114#[wasm_bindgen]
115pub fn euv_docs_resize(width: u32, height: u32, dpr: f32) -> u64 {
116    euv_docs::wasm_docs_resize(width, height, dpr)
117}
118
119#[wasm_bindgen]
120pub fn euv_docs_sync_safe_area() -> u64 {
121    euv_docs::wasm_docs_sync_safe_area()
122}
123
124#[wasm_bindgen]
125pub fn euv_docs_tick(dt_secs: f32) -> u64 {
126    euv_docs::wasm_docs_tick(dt_secs)
127}
128"#;
129pub(crate) const BUNDLE_HTML_HEAD_MID: &str = "\">\n<head>\n<meta charset=\"utf-8\"/>\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,viewport-fit=cover\"/>\n<meta name=\"description\" content=\"";
130pub(crate) const BUNDLE_HTML_DESC_END: &str = "\"/>\n<link rel=\"icon\" type=\"image/png\" href=\"https://devhub.vip/pages/docs/img/euv.png\"/>\n<title>";
131pub(crate) const BUNDLE_HTML_STYLE_AND_BODY: &str = "</title>\n<style>:root{--euv-safe-top:env(safe-area-inset-top,0px);--euv-safe-right:env(safe-area-inset-right,0px);--euv-safe-bottom:env(safe-area-inset-bottom,0px);--euv-safe-left:env(safe-area-inset-left,0px);}html,body{margin:0;padding:0;width:100vw;height:100vh;height:100dvh;overflow:hidden;background:#09090b;touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;user-select:none;-webkit-user-select:none;outline:none;}canvas{display:block;width:100%;height:100%;touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;user-select:none;-webkit-user-select:none;outline:none;}canvas:focus,canvas:focus-visible{outline:none;}</style>\n</head>\n<body>\n<script type=\"module\">\n";
132pub(crate) const BUNDLE_HTML_BOOT_PREFIX: &str = "\nawait __wbg_init({ module_or_path: './pkg/";
133pub(crate) const BUNDLE_HTML_BOOT_SUFFIX: &str = r#"' });
134euv_docs_web_start();
135function syncSize(){const vv=window.visualViewport;const w=Math.max(320,Math.round((vv&&vv.width)||window.innerWidth||1200));const h=Math.max(320,Math.round((vv&&vv.height)||window.innerHeight||800));euv_docs_resize(w,h,window.devicePixelRatio||1);euv_docs_sync_safe_area();requestAnimationFrame(()=>{euv_docs_tick(0);});}
136syncSize();
137window.addEventListener('resize',syncSize);
138window.addEventListener('orientationchange',()=>{syncSize();setTimeout(syncSize,120);});
139document.addEventListener('fullscreenchange',()=>{syncSize();setTimeout(syncSize,60);});
140if(window.visualViewport){window.visualViewport.addEventListener('resize',syncSize);}
141if(typeof ResizeObserver==='function'){new ResizeObserver(syncSize).observe(document.documentElement);}
142window.addEventListener('hashchange',()=>{const h=(window.location.hash||'').replace(/^#/,'');if(h.startsWith('/'))euv_docs_render_route(h);});
143const cvs=document.querySelector('canvas');
144if(cvs){
145const pt=(ev)=>{const r=cvs.getBoundingClientRect();return [ev.clientX-r.left,ev.clientY-r.top];};
146const isTouch=(ev)=>ev.pointerType==='touch';
147const press=(ev)=>(typeof ev.pressure==='number'&&ev.pressure>0)?ev.pressure:(ev.buttons>0?1.0:0.0);
148cvs.addEventListener('pointerdown',(ev)=>{const [x,y]=pt(ev);if(isTouch(ev)){try{cvs.setPointerCapture(ev.pointerId);}catch(_){}}euv_docs_pointer_event(1,ev.pointerId>>>0,isTouch(ev),x,y,press(ev)||1.0);});
149cvs.addEventListener('pointermove',(ev)=>{const [x,y]=pt(ev);euv_docs_pointer_event(0,ev.pointerId>>>0,isTouch(ev),x,y,press(ev));});
150cvs.addEventListener('pointerup',(ev)=>{const [x,y]=pt(ev);try{cvs.releasePointerCapture(ev.pointerId);}catch(_){}euv_docs_pointer_event(2,ev.pointerId>>>0,isTouch(ev),x,y,0.0);});
151cvs.addEventListener('pointercancel',(ev)=>{const [x,y]=pt(ev);try{cvs.releasePointerCapture(ev.pointerId);}catch(_){}euv_docs_pointer_event(3,ev.pointerId>>>0,isTouch(ev),x,y,0.0);});
152cvs.addEventListener('wheel',(ev)=>{ev.preventDefault();const [x,y]=pt(ev);const mult=ev.deltaMode===1?24:(ev.deltaMode===2?(window.innerHeight||800):1);euv_docs_scroll_at(x,y,ev.deltaX*mult,ev.deltaY*mult);},{passive:false});
153}
154window.addEventListener('keydown',(ev)=>{if(ev.key==='PageDown'||ev.key==='PageUp'||ev.key==='Home'||ev.key==='End'||ev.key==='ArrowDown'||ev.key==='ArrowUp'){ev.preventDefault();}euv_docs_key_down(ev.key);});
155let prevTs=performance.now();
156function frame(ts){const dt=Math.min(0.1,Math.max(0,(ts-prevTs)/1000));prevTs=ts;euv_docs_tick(dt);requestAnimationFrame(frame);}
157requestAnimationFrame(frame);
158</script>
159</body>
160</html>
161"#;