diff --git a/client/simple/vite.config.ts b/client/simple/vite.config.ts index c37025c61..92148bb34 100644 --- a/client/simple/vite.config.ts +++ b/client/simple/vite.config.ts @@ -34,7 +34,7 @@ const svg2svg_favicon_opts: Config = { }; export default { - base: "/static/themes/simple/", + base: "./", publicDir: "static/", build: { diff --git a/searx/static/themes/simple/sxng-core.min.js b/searx/static/themes/simple/sxng-core.min.js index 4a009d09f..e64bd1188 100644 --- a/searx/static/themes/simple/sxng-core.min.js +++ b/searx/static/themes/simple/sxng-core.min.js @@ -1,3 +1,3 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunk/DBO1tjH7.min.js","chunk/13gvpunf.min.js","chunk/gZqIRpW1.min.js","chunk/DO33-10z.min.js","chunk/Cyk8UkF6.min.js","chunk/Q2W2fJLA.min.js","chunk/KPZlR0ib.min.js","chunk/Dzkb_VTO.min.js","chunk/u0MAGmsp.min.js"])))=>i.map(i=>d[i]); -var e=class{id;constructor(e){this.id=e,this.invoke()}async invoke(){try{console.debug(`[PLUGIN] ${this.id}: Running...`);let e=await this.run();if(!e)return;console.debug(`[PLUGIN] ${this.id}: Running post-exec...`),await this.post(e)}catch(e){console.error(`[PLUGIN] ${this.id}:`,e)}finally{console.debug(`[PLUGIN] ${this.id}: Done.`)}}};const t={index:`index`,results:`results`,preferences:`preferences`,unknown:`unknown`},n={closeDetail:void 0,scrollPageToSelected:void 0,selectImage:void 0,selectNext:void 0,selectPrevious:void 0};var r=()=>{let e=document.querySelector(`meta[name="endpoint"]`)?.getAttribute(`content`);return e&&e in t?e:t.unknown},i=()=>{let e=document.querySelector(`script[client_settings]`)?.getAttribute(`client_settings`);if(!e)return{};try{return JSON.parse(atob(e))}catch(e){return console.error(`Failed to load client_settings:`,e),{}}};const a=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),n?.timeout??3e4),a=await fetch(t,{body:n?.body,method:e,signal:r.signal}).finally(()=>clearTimeout(i));if(!a.ok)throw Error(a.statusText);return a},o=(e,t,n,r)=>{if(typeof t!=`string`){t.addEventListener(e,n,r);return}document.addEventListener(e,e=>{for(let r of e.composedPath())if(r instanceof HTMLElement&&r.matches(t)){try{n.call(r,e)}catch(e){console.error(e)}break}},r)},s=(e,t)=>{for(let e of t?.on??[])if(!e)return;document.readyState===`loading`?o(`DOMContentLoaded`,document,e,{once:!0}):e()},c=r(),l=i(),u=(e,t)=>{d(t)&&e()};var d=e=>{switch(e.on){case`global`:return!0;case`endpoint`:return!!e.where.includes(c)}},f=`modulepreload`,p=function(e){return`/static/themes/simple/`+e},m={};const h=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=p(t,n),t in m)return;m[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:f,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};s(()=>{document.documentElement.classList.remove(`no-js`),document.documentElement.classList.add(`js`),o(`click`,`.close`,function(){this.parentNode?.classList.add(`invisible`)}),o(`click`,`.searxng_init_map`,async function(e){e.preventDefault(),this.classList.remove(`searxng_init_map`),u(()=>h(async()=>{let{default:e}=await import(`./chunk/Dtr6y4WS.min.js`);return{default:e}},[]).then(({default:e})=>new e(this)),{on:`endpoint`,where:[t.results]})}),l.plugins?.includes(`infiniteScroll`)&&u(()=>h(async()=>{let{default:e}=await import(`./chunk/DBO1tjH7.min.js`);return{default:e}},__vite__mapDeps([0,1,2])).then(({default:e})=>new e),{on:`endpoint`,where:[t.results]}),l.plugins?.includes(`calculator`)&&u(()=>h(async()=>{let{default:e}=await import(`./chunk/DO33-10z.min.js`);return{default:e}},__vite__mapDeps([3,2,1])).then(({default:e})=>new e),{on:`endpoint`,where:[t.results]})}),s(()=>{h(()=>import(`./chunk/Cyk8UkF6.min.js`),__vite__mapDeps([4,1])),h(()=>import(`./chunk/Q2W2fJLA.min.js`),__vite__mapDeps([5,2,1])),l.autocomplete&&h(()=>import(`./chunk/KPZlR0ib.min.js`),__vite__mapDeps([6,1]))},{on:[c===t.index]}),s(()=>{h(()=>import(`./chunk/Cyk8UkF6.min.js`),__vite__mapDeps([4,1])),h(()=>import(`./chunk/Dzkb_VTO.min.js`),__vite__mapDeps([7,1])),h(()=>import(`./chunk/Q2W2fJLA.min.js`),__vite__mapDeps([5,2,1])),l.autocomplete&&h(()=>import(`./chunk/KPZlR0ib.min.js`),__vite__mapDeps([6,1]))},{on:[c===t.results]}),s(()=>{h(()=>import(`./chunk/u0MAGmsp.min.js`),__vite__mapDeps([8,1]))},{on:[c===t.preferences]});export{e as a,l as i,o as n,n as r,a as t}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./chunk/DBO1tjH7.min.js","./chunk/13gvpunf.min.js","./chunk/gZqIRpW1.min.js","./chunk/DO33-10z.min.js","./chunk/Cyk8UkF6.min.js","./chunk/Q2W2fJLA.min.js","./chunk/KPZlR0ib.min.js","./chunk/Dzkb_VTO.min.js","./chunk/u0MAGmsp.min.js"])))=>i.map(i=>d[i]); +var e=class{id;constructor(e){this.id=e,this.invoke()}async invoke(){try{console.debug(`[PLUGIN] ${this.id}: Running...`);let e=await this.run();if(!e)return;console.debug(`[PLUGIN] ${this.id}: Running post-exec...`),await this.post(e)}catch(e){console.error(`[PLUGIN] ${this.id}:`,e)}finally{console.debug(`[PLUGIN] ${this.id}: Done.`)}}};const t={index:`index`,results:`results`,preferences:`preferences`,unknown:`unknown`},n={closeDetail:void 0,scrollPageToSelected:void 0,selectImage:void 0,selectNext:void 0,selectPrevious:void 0};var r=()=>{let e=document.querySelector(`meta[name="endpoint"]`)?.getAttribute(`content`);return e&&e in t?e:t.unknown},i=()=>{let e=document.querySelector(`script[client_settings]`)?.getAttribute(`client_settings`);if(!e)return{};try{return JSON.parse(atob(e))}catch(e){return console.error(`Failed to load client_settings:`,e),{}}};const a=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),n?.timeout??3e4),a=await fetch(t,{body:n?.body,method:e,signal:r.signal}).finally(()=>clearTimeout(i));if(!a.ok)throw Error(a.statusText);return a},o=(e,t,n,r)=>{if(typeof t!=`string`){t.addEventListener(e,n,r);return}document.addEventListener(e,e=>{for(let r of e.composedPath())if(r instanceof HTMLElement&&r.matches(t)){try{n.call(r,e)}catch(e){console.error(e)}break}},r)},s=(e,t)=>{for(let e of t?.on??[])if(!e)return;document.readyState===`loading`?o(`DOMContentLoaded`,document,e,{once:!0}):e()},c=r(),l=i(),u=(e,t)=>{d(t)&&e()};var d=e=>{switch(e.on){case`global`:return!0;case`endpoint`:return!!e.where.includes(c)}},f=`modulepreload`,p=function(e,t){return new URL(e,t).href},m={};const h=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=p(t,n),t in m)return;m[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:f,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};s(()=>{document.documentElement.classList.remove(`no-js`),document.documentElement.classList.add(`js`),o(`click`,`.close`,function(){this.parentNode?.classList.add(`invisible`)}),o(`click`,`.searxng_init_map`,async function(e){e.preventDefault(),this.classList.remove(`searxng_init_map`),u(()=>h(async()=>{let{default:e}=await import(`./chunk/Dtr6y4WS.min.js`);return{default:e}},[],import.meta.url).then(({default:e})=>new e(this)),{on:`endpoint`,where:[t.results]})}),l.plugins?.includes(`infiniteScroll`)&&u(()=>h(async()=>{let{default:e}=await import(`./chunk/DBO1tjH7.min.js`);return{default:e}},__vite__mapDeps([0,1,2]),import.meta.url).then(({default:e})=>new e),{on:`endpoint`,where:[t.results]}),l.plugins?.includes(`calculator`)&&u(()=>h(async()=>{let{default:e}=await import(`./chunk/DO33-10z.min.js`);return{default:e}},__vite__mapDeps([3,2,1]),import.meta.url).then(({default:e})=>new e),{on:`endpoint`,where:[t.results]})}),s(()=>{h(()=>import(`./chunk/Cyk8UkF6.min.js`),__vite__mapDeps([4,1]),import.meta.url),h(()=>import(`./chunk/Q2W2fJLA.min.js`),__vite__mapDeps([5,2,1]),import.meta.url),l.autocomplete&&h(()=>import(`./chunk/KPZlR0ib.min.js`),__vite__mapDeps([6,1]),import.meta.url)},{on:[c===t.index]}),s(()=>{h(()=>import(`./chunk/Cyk8UkF6.min.js`),__vite__mapDeps([4,1]),import.meta.url),h(()=>import(`./chunk/Dzkb_VTO.min.js`),__vite__mapDeps([7,1]),import.meta.url),h(()=>import(`./chunk/Q2W2fJLA.min.js`),__vite__mapDeps([5,2,1]),import.meta.url),l.autocomplete&&h(()=>import(`./chunk/KPZlR0ib.min.js`),__vite__mapDeps([6,1]),import.meta.url)},{on:[c===t.results]}),s(()=>{h(()=>import(`./chunk/u0MAGmsp.min.js`),__vite__mapDeps([8,1]),import.meta.url)},{on:[c===t.preferences]});export{e as a,l as i,o as n,n as r,a as t}; //# sourceMappingURL=sxng-core.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/sxng-core.min.js.map b/searx/static/themes/simple/sxng-core.min.js.map index 67354d123..16298f77f 100644 --- a/searx/static/themes/simple/sxng-core.min.js.map +++ b/searx/static/themes/simple/sxng-core.min.js.map @@ -1 +1 @@ -{"version":3,"mappings":";AAYA,IAAsB,EAAtB,KAA6B,CAI3B,GAMA,YAAsB,EAAY,CAChC,KAAK,GAAK,EAEL,KAAK,QAAQ,CAGpB,MAAc,QAAwB,CACpC,GAAI,CACF,QAAQ,MAAM,YAAY,KAAK,GAAG,cAAc,CAChD,IAAM,EAAS,MAAM,KAAK,KAAK,CAC/B,GAAI,CAAC,EAAQ,OAEb,QAAQ,MAAM,YAAY,KAAK,GAAG,wBAAwB,CAEpD,MAAM,KAAK,KAAK,EAAwD,OACvE,EAAO,CACd,QAAQ,MAAM,YAAY,KAAK,GAAG,GAAI,EAAM,QACpC,CACR,QAAQ,MAAM,YAAY,KAAK,GAAG,SAAS,ICJjD,MAAa,EAAY,CACvB,MAAO,QACP,QAAS,UACT,YAAa,cACb,QAAS,UACV,CAEY,EAAU,CACrB,YAAa,OACb,qBAAsB,OACtB,YAAa,OACb,WAAY,OACZ,eAAgB,OACjB,CAED,IAAM,MAAmC,CACvC,IAAM,EAAe,SAAS,cAAc,wBAAwB,EAAE,aAAa,UAAU,CAM7F,OAJI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a,EAAU,YAAY,CAAE,CAC7C","names":[],"ignoreList":[],"sources":["../../../../client/simple/src/js/Plugin.ts","../../../../client/simple/src/js/toolkit.ts","../../../../client/simple/src/js/loader.ts","../../../../client/simple/src/js/router.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\n/**\n * Base class for client-side plugins.\n *\n * @remarks\n * Handle conditional loading of the plugin in:\n *\n * - client/simple/src/js/router.ts\n *\n * @abstract\n */\nexport abstract class Plugin {\n /**\n * Plugin name.\n */\n protected readonly id: string;\n\n /**\n * @remarks\n * Don't hold references of this instance outside the class.\n */\n protected constructor(id: string) {\n this.id = id;\n\n void this.invoke();\n }\n\n private async invoke(): Promise {\n try {\n console.debug(`[PLUGIN] ${this.id}: Running...`);\n const result = await this.run();\n if (!result) return;\n\n console.debug(`[PLUGIN] ${this.id}: Running post-exec...`);\n // @ts-expect-error\n void (await this.post(result as NonNullable>>));\n } catch (error) {\n console.error(`[PLUGIN] ${this.id}:`, error);\n } finally {\n console.debug(`[PLUGIN] ${this.id}: Done.`);\n }\n }\n\n /**\n * Plugin goes here.\n *\n * @remarks\n * The plugin is already loaded at this point. If you wish to execute\n * conditions to exit early, consider moving the logic to:\n *\n * - client/simple/src/js/router.ts\n *\n * ...to avoid unnecessarily loading this plugin on the client.\n */\n protected abstract run(): Promise;\n\n /**\n * Post-execution hook.\n *\n * @remarks\n * The hook is only executed if `#run()` returns a truthy value.\n */\n // @ts-expect-error\n protected abstract post(result: NonNullable>>): Promise;\n}\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport type { KeyBindingLayout } from \"./main/keyboard.ts\";\n\n// synced with searx/webapp.py get_client_settings\ntype Settings = {\n plugins?: string[];\n advanced_search?: boolean;\n autocomplete?: string;\n autocomplete_min?: number;\n doi_resolver?: string;\n favicon_resolver?: string;\n hotkeys?: KeyBindingLayout;\n method?: \"GET\" | \"POST\";\n query_in_title?: boolean;\n results_on_new_tab?: boolean;\n safesearch?: 0 | 1 | 2;\n search_on_category_select?: boolean;\n theme?: string;\n theme_static_path?: string;\n translations?: Record;\n url_formatting?: \"pretty\" | \"full\" | \"host\";\n};\n\ntype HTTPOptions = {\n body?: BodyInit;\n timeout?: number;\n};\n\ntype ReadyOptions = {\n // all values must be truthy for the callback to be executed\n on?: (boolean | undefined)[];\n};\n\nexport type EndpointsKeys = keyof typeof Endpoints;\n\nexport const Endpoints = {\n index: \"index\",\n results: \"results\",\n preferences: \"preferences\",\n unknown: \"unknown\"\n} as const;\n\nexport const mutable = {\n closeDetail: undefined as (() => void) | undefined,\n scrollPageToSelected: undefined as (() => void) | undefined,\n selectImage: undefined as ((resultElement: HTMLElement) => void) | undefined,\n selectNext: undefined as ((openDetailView?: boolean) => void) | undefined,\n selectPrevious: undefined as ((openDetailView?: boolean) => void) | undefined\n};\n\nconst getEndpoint = (): EndpointsKeys => {\n const metaEndpoint = document.querySelector('meta[name=\"endpoint\"]')?.getAttribute(\"content\");\n\n if (metaEndpoint && metaEndpoint in Endpoints) {\n return metaEndpoint as EndpointsKeys;\n }\n\n return Endpoints.unknown;\n};\n\nconst getSettings = (): Settings => {\n const settings = document.querySelector(\"script[client_settings]\")?.getAttribute(\"client_settings\");\n if (!settings) return {};\n\n try {\n return JSON.parse(atob(settings));\n } catch (error) {\n console.error(\"Failed to load client_settings:\", error);\n return {};\n }\n};\n\nexport const http = async (method: string, url: string | URL, options?: HTTPOptions): Promise => {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options?.timeout ?? 30_000);\n\n const res = await fetch(url, {\n body: options?.body,\n method: method,\n signal: controller.signal\n }).finally(() => clearTimeout(timeoutId));\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n\n return res;\n};\n\nexport const listen = (\n type: string | K,\n target: string | Document | E,\n listener: (this: E, event: DocumentEventMap[K]) => void | Promise,\n options?: AddEventListenerOptions\n): void => {\n if (typeof target !== \"string\") {\n target.addEventListener(type, listener as EventListener, options);\n return;\n }\n\n document.addEventListener(\n type,\n (event: Event) => {\n for (const node of event.composedPath()) {\n if (node instanceof HTMLElement && node.matches(target)) {\n try {\n listener.call(node as E, event as DocumentEventMap[K]);\n } catch (error) {\n console.error(error);\n }\n break;\n }\n }\n },\n options\n );\n};\n\nexport const ready = (callback: () => void, options?: ReadyOptions): void => {\n for (const condition of options?.on ?? []) {\n if (!condition) {\n return;\n }\n }\n\n if (document.readyState !== \"loading\") {\n callback();\n } else {\n listen(\"DOMContentLoaded\", document, callback, { once: true });\n }\n};\n\nexport const endpoint: EndpointsKeys = getEndpoint();\nexport const settings: Settings = getSettings();\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport type { Plugin } from \"./Plugin.ts\";\nimport { type EndpointsKeys, endpoint } from \"./toolkit.ts\";\n\ntype Options =\n | {\n on: \"global\";\n }\n | {\n on: \"endpoint\";\n where: EndpointsKeys[];\n };\n\nexport const load = (instance: () => Promise, options: Options): void => {\n if (!check(options)) return;\n\n void instance();\n};\n\nconst check = (options: Options): boolean => {\n // biome-ignore lint/style/useDefaultSwitchClause: options is typed\n switch (options.on) {\n case \"global\": {\n return true;\n }\n case \"endpoint\": {\n if (!options.where.includes(endpoint)) {\n // not on the expected endpoint\n return false;\n }\n\n return true;\n }\n }\n};\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { load } from \"./loader.ts\";\nimport { Endpoints, endpoint, listen, ready, settings } from \"./toolkit.ts\";\n\nready(() => {\n document.documentElement.classList.remove(\"no-js\");\n document.documentElement.classList.add(\"js\");\n\n listen(\"click\", \".close\", function (this: HTMLElement) {\n (this.parentNode as HTMLElement)?.classList.add(\"invisible\");\n });\n\n listen(\"click\", \".searxng_init_map\", async function (this: HTMLElement, event: Event) {\n event.preventDefault();\n this.classList.remove(\"searxng_init_map\");\n\n load(() => import(\"./plugin/MapView.ts\").then(({ default: Plugin }) => new Plugin(this)), {\n on: \"endpoint\",\n where: [Endpoints.results]\n });\n });\n\n if (settings.plugins?.includes(\"infiniteScroll\")) {\n load(() => import(\"./plugin/InfiniteScroll.ts\").then(({ default: Plugin }) => new Plugin()), {\n on: \"endpoint\",\n where: [Endpoints.results]\n });\n }\n\n if (settings.plugins?.includes(\"calculator\")) {\n load(() => import(\"./plugin/Calculator.ts\").then(({ default: Plugin }) => new Plugin()), {\n on: \"endpoint\",\n where: [Endpoints.results]\n });\n }\n});\n\nready(\n () => {\n void import(\"./main/keyboard.ts\");\n void import(\"./main/search.ts\");\n\n if (settings.autocomplete) {\n void import(\"./main/autocomplete.ts\");\n }\n },\n { on: [endpoint === Endpoints.index] }\n);\n\nready(\n () => {\n void import(\"./main/keyboard.ts\");\n void import(\"./main/results.ts\");\n void import(\"./main/search.ts\");\n\n if (settings.autocomplete) {\n void import(\"./main/autocomplete.ts\");\n }\n },\n { on: [endpoint === Endpoints.results] }\n);\n\nready(\n () => {\n void import(\"./main/preferences.ts\");\n },\n { on: [endpoint === Endpoints.preferences] }\n);\n"],"file":"sxng-core.min.js"} \ No newline at end of file +{"version":3,"mappings":";AAYA,IAAsB,EAAtB,KAA6B,CAI3B,GAMA,YAAsB,EAAY,CAChC,KAAK,GAAK,EAEL,KAAK,QAAQ,CAGpB,MAAc,QAAwB,CACpC,GAAI,CACF,QAAQ,MAAM,YAAY,KAAK,GAAG,cAAc,CAChD,IAAM,EAAS,MAAM,KAAK,KAAK,CAC/B,GAAI,CAAC,EAAQ,OAEb,QAAQ,MAAM,YAAY,KAAK,GAAG,wBAAwB,CAEpD,MAAM,KAAK,KAAK,EAAwD,OACvE,EAAO,CACd,QAAQ,MAAM,YAAY,KAAK,GAAG,GAAI,EAAM,QACpC,CACR,QAAQ,MAAM,YAAY,KAAK,GAAG,SAAS,ICJjD,MAAa,EAAY,CACvB,MAAO,QACP,QAAS,UACT,YAAa,cACb,QAAS,UACV,CAEY,EAAU,CACrB,YAAa,OACb,qBAAsB,OACtB,YAAa,OACb,WAAY,OACZ,eAAgB,OACjB,CAED,IAAM,MAAmC,CACvC,IAAM,EAAe,SAAS,cAAc,w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AK,OAAO,oEAEd,CAAE,GAAI,CAAC,IAAa,EAAU,YAAY,CAAE,CAC7C","names":[],"ignoreList":[],"sources":["../../../../client/simple/src/js/Plugin.ts","../../../../client/simple/src/js/toolkit.ts","../../../../client/simple/src/js/loader.ts","../../../../client/simple/src/js/router.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\n/**\n * Base class for client-side plugins.\n *\n * @remarks\n * Handle conditional loading of the plugin in:\n *\n * - client/simple/src/js/router.ts\n *\n * @abstract\n */\nexport abstract class Plugin {\n /**\n * Plugin name.\n */\n protected readonly id: string;\n\n /**\n * @remarks\n * Don't hold references of this instance outside the class.\n */\n protected constructor(id: string) {\n this.id = id;\n\n void this.invoke();\n }\n\n private async invoke(): Promise {\n try {\n console.debug(`[PLUGIN] ${this.id}: Running...`);\n const result = await this.run();\n if (!result) return;\n\n console.debug(`[PLUGIN] ${this.id}: Running post-exec...`);\n // @ts-expect-error\n void (await this.post(result as NonNullable>>));\n } catch (error) {\n console.error(`[PLUGIN] ${this.id}:`, error);\n } finally {\n console.debug(`[PLUGIN] ${this.id}: Done.`);\n }\n }\n\n /**\n * Plugin goes here.\n *\n * @remarks\n * The plugin is already loaded at this point. If you wish to execute\n * conditions to exit early, consider moving the logic to:\n *\n * - client/simple/src/js/router.ts\n *\n * ...to avoid unnecessarily loading this plugin on the client.\n */\n protected abstract run(): Promise;\n\n /**\n * Post-execution hook.\n *\n * @remarks\n * The hook is only executed if `#run()` returns a truthy value.\n */\n // @ts-expect-error\n protected abstract post(result: NonNullable>>): Promise;\n}\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport type { KeyBindingLayout } from \"./main/keyboard.ts\";\n\n// synced with searx/webapp.py get_client_settings\ntype Settings = {\n plugins?: string[];\n advanced_search?: boolean;\n autocomplete?: string;\n autocomplete_min?: number;\n doi_resolver?: string;\n favicon_resolver?: string;\n hotkeys?: KeyBindingLayout;\n method?: \"GET\" | \"POST\";\n query_in_title?: boolean;\n results_on_new_tab?: boolean;\n safesearch?: 0 | 1 | 2;\n search_on_category_select?: boolean;\n theme?: string;\n theme_static_path?: string;\n translations?: Record;\n url_formatting?: \"pretty\" | \"full\" | \"host\";\n};\n\ntype HTTPOptions = {\n body?: BodyInit;\n timeout?: number;\n};\n\ntype ReadyOptions = {\n // all values must be truthy for the callback to be executed\n on?: (boolean | undefined)[];\n};\n\nexport type EndpointsKeys = keyof typeof Endpoints;\n\nexport const Endpoints = {\n index: \"index\",\n results: \"results\",\n preferences: \"preferences\",\n unknown: \"unknown\"\n} as const;\n\nexport const mutable = {\n closeDetail: undefined as (() => void) | undefined,\n scrollPageToSelected: undefined as (() => void) | undefined,\n selectImage: undefined as ((resultElement: HTMLElement) => void) | undefined,\n selectNext: undefined as ((openDetailView?: boolean) => void) | undefined,\n selectPrevious: undefined as ((openDetailView?: boolean) => void) | undefined\n};\n\nconst getEndpoint = (): EndpointsKeys => {\n const metaEndpoint = document.querySelector('meta[name=\"endpoint\"]')?.getAttribute(\"content\");\n\n if (metaEndpoint && metaEndpoint in Endpoints) {\n return metaEndpoint as EndpointsKeys;\n }\n\n return Endpoints.unknown;\n};\n\nconst getSettings = (): Settings => {\n const settings = document.querySelector(\"script[client_settings]\")?.getAttribute(\"client_settings\");\n if (!settings) return {};\n\n try {\n return JSON.parse(atob(settings));\n } catch (error) {\n console.error(\"Failed to load client_settings:\", error);\n return {};\n }\n};\n\nexport const http = async (method: string, url: string | URL, options?: HTTPOptions): Promise => {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options?.timeout ?? 30_000);\n\n const res = await fetch(url, {\n body: options?.body,\n method: method,\n signal: controller.signal\n }).finally(() => clearTimeout(timeoutId));\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n\n return res;\n};\n\nexport const listen = (\n type: string | K,\n target: string | Document | E,\n listener: (this: E, event: DocumentEventMap[K]) => void | Promise,\n options?: AddEventListenerOptions\n): void => {\n if (typeof target !== \"string\") {\n target.addEventListener(type, listener as EventListener, options);\n return;\n }\n\n document.addEventListener(\n type,\n (event: Event) => {\n for (const node of event.composedPath()) {\n if (node instanceof HTMLElement && node.matches(target)) {\n try {\n listener.call(node as E, event as DocumentEventMap[K]);\n } catch (error) {\n console.error(error);\n }\n break;\n }\n }\n },\n options\n );\n};\n\nexport const ready = (callback: () => void, options?: ReadyOptions): void => {\n for (const condition of options?.on ?? []) {\n if (!condition) {\n return;\n }\n }\n\n if (document.readyState !== \"loading\") {\n callback();\n } else {\n listen(\"DOMContentLoaded\", document, callback, { once: true });\n }\n};\n\nexport const endpoint: EndpointsKeys = getEndpoint();\nexport const settings: Settings = getSettings();\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport type { Plugin } from \"./Plugin.ts\";\nimport { type EndpointsKeys, endpoint } from \"./toolkit.ts\";\n\ntype Options =\n | {\n on: \"global\";\n }\n | {\n on: \"endpoint\";\n where: EndpointsKeys[];\n };\n\nexport const load = (instance: () => Promise, options: Options): void => {\n if (!check(options)) return;\n\n void instance();\n};\n\nconst check = (options: Options): boolean => {\n // biome-ignore lint/style/useDefaultSwitchClause: options is typed\n switch (options.on) {\n case \"global\": {\n return true;\n }\n case \"endpoint\": {\n if (!options.where.includes(endpoint)) {\n // not on the expected endpoint\n return false;\n }\n\n return true;\n }\n }\n};\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { load } from \"./loader.ts\";\nimport { Endpoints, endpoint, listen, ready, settings } from \"./toolkit.ts\";\n\nready(() => {\n document.documentElement.classList.remove(\"no-js\");\n document.documentElement.classList.add(\"js\");\n\n listen(\"click\", \".close\", function (this: HTMLElement) {\n (this.parentNode as HTMLElement)?.classList.add(\"invisible\");\n });\n\n listen(\"click\", \".searxng_init_map\", async function (this: HTMLElement, event: Event) {\n event.preventDefault();\n this.classList.remove(\"searxng_init_map\");\n\n load(() => import(\"./plugin/MapView.ts\").then(({ default: Plugin }) => new Plugin(this)), {\n on: \"endpoint\",\n where: [Endpoints.results]\n });\n });\n\n if (settings.plugins?.includes(\"infiniteScroll\")) {\n load(() => import(\"./plugin/InfiniteScroll.ts\").then(({ default: Plugin }) => new Plugin()), {\n on: \"endpoint\",\n where: [Endpoints.results]\n });\n }\n\n if (settings.plugins?.includes(\"calculator\")) {\n load(() => import(\"./plugin/Calculator.ts\").then(({ default: Plugin }) => new Plugin()), {\n on: \"endpoint\",\n where: [Endpoints.results]\n });\n }\n});\n\nready(\n () => {\n void import(\"./main/keyboard.ts\");\n void import(\"./main/search.ts\");\n\n if (settings.autocomplete) {\n void import(\"./main/autocomplete.ts\");\n }\n },\n { on: [endpoint === Endpoints.index] }\n);\n\nready(\n () => {\n void import(\"./main/keyboard.ts\");\n void import(\"./main/results.ts\");\n void import(\"./main/search.ts\");\n\n if (settings.autocomplete) {\n void import(\"./main/autocomplete.ts\");\n }\n },\n { on: [endpoint === Endpoints.results] }\n);\n\nready(\n () => {\n void import(\"./main/preferences.ts\");\n },\n { on: [endpoint === Endpoints.preferences] }\n);\n"],"file":"sxng-core.min.js"} \ No newline at end of file