@lizardbyte/shared-web 2026.726.204939 → 2026.811.210538

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/crowdin.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{var t={714(t,e,i){const o=i(836);function n(t,e){e>=100||globalThis.setTimeout(function(){s(t,e+1)},50)}function s(t,e=0){const i=document.getElementById("crowdin-language-picker");if("sphinx"===t){const o=document.getElementsByClassName("cr-picker-button")[0],s=document.getElementsByClassName("sidebar-sticky")[0];return null===i||void 0===o||void 0===s?void n(t,e):(i.classList.remove("cr-position-bottom-left"),i.style.width=o.offsetWidth+10+"px",i.style.position="relative",i.style.left="10px",i.style.bottom="10px",void s.appendChild(i))}const o=document.querySelector(".sidebar .sidebar-elems")||document.querySelector(".sidebar");null!==i&&null!==o?(i.classList.remove("cr-position-bottom-left"),i.classList.add("rustdoc-crowdin-picker"),i.style.position="static",i.style.left="auto",i.style.bottom="auto",o.appendChild(i)):n(t,e)}function r(t="LizardByte",e=null){["LizardByte","LizardByte-docs"].includes(t)?["sphinx","rustdoc",null].includes(e)?(function(){if("function"!=typeof globalThis.fetch)return;if(globalThis._crowdinMirrorInstalled)return;globalThis._crowdinMirrorInstalled=!0;const t=globalThis.fetch.bind(globalThis);globalThis.fetch=function(e,i){if("string"==typeof e){let o;try{o=new URL(e)}catch{}if("https:"===o?.protocol&&"distributions.crowdin.net"===o.hostname){const e="https://cdn.jsdelivr.net/gh/LizardByte/i18n@dist"+o.pathname+o.search+o.hash;return t(e,i)}}return t(e,i)}}(),o("https://website-translator.app.crowdin.net/assets/proxy-translator.js",function(){let i={bg:"Български (Bulgarian)",cs:"Čeština (Czech)",de:"Deutsch (German)",en:"English","en-GB":"English, United Kingdom","en-US":"English, United States","es-ES":"Español (Spanish)",fr:"Français (French)",hu:"Magyar (Hungarian)",it:"Italiano (Italian)",ja:"日本語 (Japanese)",ko:"한국어 (Korean)",pl:"Polski (Polish)","pt-BR":"Português, Brasileiro (Portuguese, Brazilian)","pt-PT":"Português (Portuguese)",ru:"Русский (Russian)","sv-SE":"svenska (Swedish)",tr:"Türkçe (Turkish)",uk:"Українська (Ukranian)",vi:"Tiếng Việt (Vietnamese)","zh-CN":"简体中文 (Chinese Simplified)","zh-TW":"繁體中文 (Chinese Traditional)"};i=Object.fromEntries(Object.entries(i).sort((t,e)=>t[1].localeCompare(e[1])));let o=globalThis.location.origin;globalThis.proxyTranslator.init({baseUrl:o,distribution:{LizardByte:{baseUrl:"https://app.lizardbyte.dev",distribution:"458f881791aebba1d4dde491bw4"},"LizardByte-docs":{baseUrl:"https://docs.lizardbyte.dev",distribution:"d6c830ba4b41106fefe5d391bw4"}}[t].distribution,defaultLanguage:"en",languageTitles:i,showDefaultLanguageInUrl:!1,languageRoutingMethod:"query",position:"bottom-left",submenuPosition:"top-left",poweredBy:!1}),null!==e&&s(e)})):console.error('Invalid UI. Must be "sphinx", "rustdoc", or null'):console.error('Invalid project. Must be "LizardByte" or "LizardByte-docs"')}void 0!==globalThis.window&&(globalThis.initCrowdIn=r),t.exports=r},836(t){function e(t,e){const i=document.createElement("script");i.src=t,i.async=!0,i.onload=()=>{e&&e(null,i)},i.onerror=()=>{e&&e(new Error(`Failed to load script: ${t}`))},document.head.appendChild(i)}void 0!==globalThis.window&&(globalThis.loadScript=e),t.exports=e}};const e={};!function i(o){const n=e[o];if(void 0!==n)return n.exports;const s=e[o]={exports:{}};return t[o](s,s.exports,i),s.exports}(714)})();
1
+ (()=>{var e={714(e,t,n){const i=n(836),o=["a","abbr","b","cite","code","del","em","i","ins","kbd","mark","q","s","samp","small","span","strong","sub","sup","time","u","var"].join(",");function s(e){const t=new globalThis.MutationObserver(n);function n(){t.disconnect(),function(e){e.forEach(e=>{const t=function(e){if(e.node.isConnected)return e.node;const t=e.previousInline?.nextSibling;if(t instanceof globalThis.Text&&t.isConnected)return e.node=t,e.node;const n=e.nextInline?.previousSibling;if(n instanceof globalThis.Text&&n.isConnected)return e.node=n,e.node;if(!e.whitespaceOnly)return null;const i=document.createTextNode("");if(e.previousInline?.isConnected)e.previousInline.after(i);else{if(!e.nextInline?.isConnected)return null;e.nextInline.before(i)}return e.node=i,e.node}(e);null!==t&&(e.leading&&!/^\s/.test(t.data)&&(t.data=" "+t.data),e.trailing&&!/\s$/.test(t.data)&&(t.data+=" "))})}(e),t.observe(document.body,{characterData:!0,childList:!0,subtree:!0})}return n}function l(e,t){t>=100||globalThis.setTimeout(function(){r(e,t+1)},50)}function r(e,t=0){const n=document.getElementById("crowdin-language-picker");if("sphinx"===e){const i=document.getElementsByClassName("cr-picker-button")[0],o=document.getElementsByClassName("sidebar-sticky")[0];return null===n||void 0===i||void 0===o?void l(e,t):(n.classList.remove("cr-position-bottom-left"),n.style.width=i.offsetWidth+10+"px",n.style.position="relative",n.style.left="10px",n.style.bottom="10px",void o.appendChild(n))}const i=document.querySelector(".sidebar .sidebar-elems")||document.querySelector(".sidebar");null!==n&&null!==i?(n.classList.remove("cr-position-bottom-left"),n.classList.add("rustdoc-crowdin-picker"),n.style.position="static",n.style.left="auto",n.style.bottom="auto",i.appendChild(n)):l(e,t)}function a(e="LizardByte",t=null){["LizardByte","LizardByte-docs"].includes(e)?["sphinx","rustdoc",null].includes(t)?(function(){if("function"!=typeof globalThis.fetch)return;if(globalThis._crowdinMirrorInstalled)return;globalThis._crowdinMirrorInstalled=!0;const e=globalThis.fetch.bind(globalThis);globalThis.fetch=function(t,n){if("string"==typeof t){let i;try{i=new URL(t)}catch{}if("https:"===i?.protocol&&"distributions.crowdin.net"===i.hostname){const t="https://cdn.jsdelivr.net/gh/LizardByte/i18n@dist"+i.pathname+i.search+i.hash;return e(t,n)}}return e(t,n)}}(),i("https://website-translator.app.crowdin.net/assets/proxy-translator.js",function(){let n={bg:"Български (Bulgarian)",cs:"Čeština (Czech)",de:"Deutsch (German)",en:"English","en-GB":"English, United Kingdom","en-US":"English, United States","es-ES":"Español (Spanish)",fr:"Français (French)",hu:"Magyar (Hungarian)",it:"Italiano (Italian)",ja:"日本語 (Japanese)",ko:"한국어 (Korean)",pl:"Polski (Polish)","pt-BR":"Português, Brasileiro (Portuguese, Brazilian)","pt-PT":"Português (Portuguese)",ru:"Русский (Russian)","sv-SE":"svenska (Swedish)",tr:"Türkçe (Turkish)",uk:"Українська (Ukranian)",vi:"Tiếng Việt (Vietnamese)","zh-CN":"简体中文 (Chinese Simplified)","zh-TW":"繁體中文 (Chinese Traditional)"};n=Object.fromEntries(Object.entries(n).sort((e,t)=>e[1].localeCompare(t[1])));let i=globalThis.location.origin;const l=function(){const e=[],t=document.createTreeWalker(document.body,globalThis.NodeFilter.SHOW_TEXT);let n=t.nextNode();for(;null!==n;){const i=n.previousSibling instanceof globalThis.Element&&n.previousSibling.matches(o),s=n.nextSibling instanceof globalThis.Element&&n.nextSibling.matches(o),l=i&&/^\s/.test(n.data),r=s&&/\s$/.test(n.data);(l||r)&&e.push({node:n,leading:l,trailing:r,previousInline:i?n.previousSibling:null,nextInline:s?n.nextSibling:null,whitespaceOnly:/^\s*$/.test(n.data)}),n=t.nextNode()}return e}();globalThis.proxyTranslator.init({baseUrl:i,callback:s(l),distribution:{LizardByte:{baseUrl:"https://app.lizardbyte.dev",distribution:"458f881791aebba1d4dde491bw4"},"LizardByte-docs":{baseUrl:"https://docs.lizardbyte.dev",distribution:"d6c830ba4b41106fefe5d391bw4"}}[e].distribution,defaultLanguage:"en",languageTitles:n,showDefaultLanguageInUrl:!1,languageRoutingMethod:"query",position:"bottom-left",submenuPosition:"top-left",poweredBy:!1}),null!==t&&r(t)})):console.error('Invalid UI. Must be "sphinx", "rustdoc", or null'):console.error('Invalid project. Must be "LizardByte" or "LizardByte-docs"')}void 0!==globalThis.window&&(globalThis.initCrowdIn=a),e.exports=a},836(e){function t(e,t){const n=document.createElement("script");n.src=e,n.async=!0,n.onload=()=>{t&&t(null,n)},n.onerror=()=>{t&&t(new Error(`Failed to load script: ${e}`))},document.head.appendChild(n)}void 0!==globalThis.window&&(globalThis.loadScript=t),e.exports=t}};const t={};!function n(i){const o=t[i];if(void 0!==o)return o.exports;const s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}(714)})();
2
2
  //# sourceMappingURL=crowdin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crowdin.js","mappings":"wBAAA,MAAMA,EAAaC,EAAQ,KAuD3B,SAASC,EAA6BC,EAAUC,GACxCA,GA7CsC,KAiD1CC,WAAWC,WAAW,WAClBC,EAA6BJ,EAAUC,EAAU,EACrD,EAlD4C,GAmDhD,CAOA,SAASG,EAA6BJ,EAAUC,EAAU,GACtD,MAAMI,EAAYC,SAASC,eAAe,2BAE1C,GAAiB,WAAbP,EAAuB,CACvB,MAAMQ,EAASF,SAASG,uBAAuB,oBAAoB,GAC7DC,EAAUJ,SAASG,uBAAuB,kBAAkB,GAElE,OAAkB,OAAdJ,QAAiCM,IAAXH,QAAoCG,IAAZD,OAC9CX,EAA6BC,EAAUC,IAI3CI,EAAUO,UAAUC,OAAO,2BAC3BR,EAAUS,MAAMC,MAAQP,EAAOQ,YAAc,GAAK,KAClDX,EAAUS,MAAMG,SAAW,WAC3BZ,EAAUS,MAAMI,KAAO,OACvBb,EAAUS,MAAMK,OAAS,YAGzBT,EAAQU,YAAYf,GAExB,CAEA,MAAMK,EAAUJ,SAASe,cAAc,4BAA8Bf,SAASe,cAAc,YAE1E,OAAdhB,GAAkC,OAAZK,GAK1BL,EAAUO,UAAUC,OAAO,2BAC3BR,EAAUO,UAAUU,IAAI,0BACxBjB,EAAUS,MAAMG,SAAW,SAC3BZ,EAAUS,MAAMI,KAAO,OACvBb,EAAUS,MAAMK,OAAS,OAEzBT,EAAQU,YAAYf,IAVhBN,EAA6BC,EAAUC,EAW/C,CAOA,SAASsB,EAAYC,EAAU,aAAcxB,EAAW,MAE/C,CAAC,aAAc,mBAAmByB,SAASD,GAI3C,CAAC,SAAU,UAAW,MAAMC,SAASzB,IAjG9C,WACI,GAAgC,mBAArBE,WAAWwB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ACjC,IAtEI4E,QAAQC,MAAM,oDAJdD,QAAQC,MAAM,6DA2EtB,MAG0BlE,IAAtBT,WAAW4E,SACX5E,WAAWqB,YAAcA,GAG7BwD,EAAOC,QAAUzD,UClMjB,SAAS1B,EAAWiC,EAAKmD,GACrB,MAAMC,EAAS5E,SAAS6E,cAAc,UACtCD,EAAOE,IAAMtD,EACboD,EAAOG,OAAQ,EAEfH,EAAOI,OAAS,KACRL,GAAUA,EAAS,KAAMC,IAGjCA,EAAOK,QAAU,KACTN,GAAUA,EAAS,IAAIO,MAAM,0BAA0B1D,OAG/DxB,SAASmF,KAAKrE,YAAY8D,EAC9B,MAG0BvE,IAAtBT,WAAW4E,SACX5E,WAAWL,WAAaA,GAG5BkF,EAAOC,QAAUnF,ICzBjB,MAAA6F,EAAA,IAGA,SAAA5F,EAAA6F,GAEA,MAAAC,EAAAF,EAAAC,GACA,QAAAhF,IAAAiF,EACA,OAAAA,EAAAZ,QAGA,MAAAD,EAAAW,EAAAC,GAAA,CAGAX,QAAA,IAOA,OAHAa,EAAAF,GAAAZ,EAAAA,EAAAC,QAAAlF,GAGAiF,EAAAC,OACA,CCnBAlF,CAAA","sources":["webpack://@lizardbyte/shared-web/./src/js/crowdin.js","webpack://@lizardbyte/shared-web/./src/js/load-script.js","webpack://@lizardbyte/shared-web/webpack/bootstrap","webpack://@lizardbyte/shared-web/webpack/startup"],"sourcesContent":["const loadScript = require('./load-script');\n\n/**\n * jsDelivr CDN URL serving Crowdin distribution files from the crowdin-dist\n * git branch. jsDelivr unconditionally sets Access-Control-Allow-Origin: *,\n * so cross-origin fetch() calls succeed without any browser plugin.\n * The branch is refreshed daily by the \"Sync Crowdin Distribution\" workflow.\n * Structure mirrors https://distributions.crowdin.net/<hash>/… exactly.\n * @type {string}\n */\nconst CROWDIN_DIST_MIRROR = 'https://cdn.jsdelivr.net/gh/LizardByte/i18n@dist';\nconst CROWDIN_PLATFORM_STYLING_MAX_ATTEMPTS = 100;\nconst CROWDIN_PLATFORM_STYLING_RETRY_DELAY_MS = 50;\n\n/**\n * Monkey-patches globalThis.fetch to redirect Crowdin distribution requests to\n * the self-hosted GitHub Pages mirror.\n *\n * Must be called BEFORE proxy-translator.js is loaded so that every fetch()\n * the script makes is already intercepted.\n *\n * Idempotent – installs the interceptor at most once per page.\n */\nfunction _installCrowdinFetchInterceptor() {\n if (typeof globalThis.fetch !== 'function') return;\n if (globalThis._crowdinMirrorInstalled) return;\n globalThis._crowdinMirrorInstalled = true;\n\n const _origFetch = globalThis.fetch.bind(globalThis);\n\n globalThis.fetch = function crowdinMirrorFetch(url, options) {\n if (typeof url === 'string') {\n let parsed;\n try {\n parsed = new URL(url);\n } catch {\n // Not a valid absolute URL – pass through unchanged.\n }\n // Use exact hostname comparison to avoid prefix-match bypasses\n // (e.g. distributions.crowdin.net.evil.com) that would be flagged\n // by incomplete URL sanitisation checks.\n if (parsed?.protocol === 'https:' && parsed.hostname === 'distributions.crowdin.net') {\n const mirroredUrl = CROWDIN_DIST_MIRROR + parsed.pathname + parsed.search + parsed.hash;\n return _origFetch(mirroredUrl, options);\n }\n }\n return _origFetch(url, options);\n };\n}\n\n/**\n * Re-attempts platform styling while Crowdin inserts the language picker.\n * @param {string} platform - UI platform ('sphinx' or 'rustdoc').\n * @param {number} attempt - Current retry count.\n */\nfunction _retryCrowdinPlatformStyling(platform, attempt) {\n if (attempt >= CROWDIN_PLATFORM_STYLING_MAX_ATTEMPTS) {\n return;\n }\n\n globalThis.setTimeout(function() {\n _applyCrowdinPlatformStyling(platform, attempt + 1);\n }, CROWDIN_PLATFORM_STYLING_RETRY_DELAY_MS);\n}\n\n/**\n * Applies platform-specific placement after the Crowdin picker exists.\n * @param {string} platform - UI platform ('sphinx' or 'rustdoc').\n * @param {number} attempt - Current retry count.\n */\nfunction _applyCrowdinPlatformStyling(platform, attempt = 0) {\n const container = document.getElementById('crowdin-language-picker');\n\n if (platform === 'sphinx') {\n const button = document.getElementsByClassName('cr-picker-button')[0];\n const sidebar = document.getElementsByClassName('sidebar-sticky')[0];\n\n if (container === null || button === undefined || sidebar === undefined) {\n _retryCrowdinPlatformStyling(platform, attempt);\n return;\n }\n\n container.classList.remove('cr-position-bottom-left');\n container.style.width = button.offsetWidth + 10 + 'px';\n container.style.position = 'relative';\n container.style.left = '10px';\n container.style.bottom = '10px';\n\n // move button to related pages\n sidebar.appendChild(container);\n return;\n }\n\n const sidebar = document.querySelector('.sidebar .sidebar-elems') || document.querySelector('.sidebar');\n\n if (container === null || sidebar === null) {\n _retryCrowdinPlatformStyling(platform, attempt);\n return;\n }\n\n container.classList.remove('cr-position-bottom-left');\n container.classList.add('rustdoc-crowdin-picker');\n container.style.position = 'static';\n container.style.left = 'auto';\n container.style.bottom = 'auto';\n\n sidebar.appendChild(container);\n}\n\n/**\n * Initializes Crowdin translation widget based on project and UI platform.\n * @param {string} project - Project name ('LizardByte' or 'LizardByte-docs').\n * @param {string|null} platform - UI platform ('sphinx', 'rustdoc', or null).\n */\nfunction initCrowdIn(project = 'LizardByte', platform = null) {\n // Input validation\n if (!['LizardByte', 'LizardByte-docs'].includes(project)) {\n console.error('Invalid project. Must be \"LizardByte\" or \"LizardByte-docs\"');\n return;\n }\n if (!['sphinx', 'rustdoc', null].includes(platform)) {\n console.error('Invalid UI. Must be \"sphinx\", \"rustdoc\", or null');\n return;\n }\n\n // Redirect distribution CDN requests to our self-hosted GitHub Pages mirror\n // before the script is even loaded so every fetch() it makes is intercepted.\n _installCrowdinFetchInterceptor();\n\n loadScript('https://website-translator.app.crowdin.net/assets/proxy-translator.js', function() {\n // Configure base settings based on project\n const projectSettings = {\n 'LizardByte': {\n baseUrl: \"https://app.lizardbyte.dev\",\n distribution: \"458f881791aebba1d4dde491bw4\",\n },\n 'LizardByte-docs': {\n baseUrl: \"https://docs.lizardbyte.dev\",\n distribution: \"d6c830ba4b41106fefe5d391bw4\",\n }\n };\n\n let languageTitles = {\n \"bg\": \"Български (Bulgarian)\",\n \"cs\": \"Čeština (Czech)\",\n \"de\": \"Deutsch (German)\",\n \"en\": \"English\",\n \"en-GB\": \"English, United Kingdom\",\n \"en-US\": \"English, United States\",\n \"es-ES\": \"Español (Spanish)\",\n \"fr\": \"Français (French)\",\n \"hu\": \"Magyar (Hungarian)\",\n \"it\": \"Italiano (Italian)\",\n \"ja\": \"日本語 (Japanese)\",\n \"ko\": \"한국어 (Korean)\",\n \"pl\": \"Polski (Polish)\",\n \"pt-BR\": \"Português, Brasileiro (Portuguese, Brazilian)\",\n \"pt-PT\": \"Português (Portuguese)\",\n \"ru\": \"Русский (Russian)\",\n \"sv-SE\": \"svenska (Swedish)\",\n \"tr\": \"Türkçe (Turkish)\",\n \"uk\": \"Українська (Ukranian)\",\n \"vi\": \"Tiếng Việt (Vietnamese)\",\n \"zh-CN\": \"简体中文 (Chinese Simplified)\",\n \"zh-TW\": \"繁體中文 (Chinese Traditional)\",\n };\n // sort languages by name\n languageTitles = Object.fromEntries(Object.entries(languageTitles).sort((a, b) => a[1].localeCompare(b[1])));\n\n // use this to allow translations to work on PR preview builds\n let currentBaseUrl = globalThis.location.origin;\n\n // Initialize Crowdin translator\n globalThis.proxyTranslator.init({\n baseUrl: currentBaseUrl,\n distribution: projectSettings[project].distribution,\n defaultLanguage: \"en\",\n languageTitles: languageTitles,\n showDefaultLanguageInUrl: false,\n languageRoutingMethod: \"query\",\n position: \"bottom-left\",\n submenuPosition: \"top-left\",\n poweredBy: false,\n });\n\n // Apply styling based on UI framework\n if (platform === null) {\n return;\n }\n\n _applyCrowdinPlatformStyling(platform);\n });\n}\n\n// Expose to the global scope\nif (globalThis.window !== undefined) {\n globalThis.initCrowdIn = initCrowdIn;\n}\n\nmodule.exports = initCrowdIn;\n","/**\n * Load a script asynchronously, and add it to the DOM. Optionally, call a callback when the script has loaded.\n * @param {string} url The URL of the script to load.\n * @param {Function} callback An optional callback to call when the script has loaded.\n */\nfunction loadScript(url, callback) {\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n\n script.onload = () => {\n if (callback) callback(null, script);\n };\n\n script.onerror = () => {\n if (callback) callback(new Error(`Failed to load script: ${url}`));\n };\n\n document.head.appendChild(script);\n}\n\n// Expose to the global scope\nif (globalThis.window !== undefined) {\n globalThis.loadScript = loadScript;\n}\n\nmodule.exports = loadScript;\n","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nlet __webpack_exports__ = __webpack_require__(714);\n"],"names":["loadScript","__webpack_require__","_retryCrowdinPlatformStyling","platform","attempt","globalThis","setTimeout","_applyCrowdinPlatformStyling","container","document","getElementById","button","getElementsByClassName","sidebar","undefined","classList","remove","style","width","offsetWidth","position","left","bottom","appendChild","querySelector","add","initCrowdIn","project","includes","fetch","_crowdinMirrorInstalled","_origFetch","bind","url","options","parsed","URL","protocol","hostname","mirroredUrl","pathname","search","hash","_installCrowdinFetchInterceptor","languageTitles","bg","cs","de","en","fr","hu","it","ja","ko","pl","ru","tr","uk","vi","Object","fromEntries","entries","sort","a","b","localeCompare","currentBaseUrl","location","origin","proxyTranslator","init","baseUrl","distribution","LizardByte","defaultLanguage","showDefaultLanguageInUrl","languageRoutingMethod","submenuPosition","poweredBy","console","error","window","module","exports","callback","script","createElement","src","async","onload","onerror","Error","head","__webpack_module_cache__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
1
+ {"version":3,"file":"crowdin.js","mappings":"wBAAA,MAAMA,EAAaC,EAAQ,KAarBC,EAAkC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O4F,EAAOI,UAClB,CAEA,OAAOxG,CACX,CAyOqC8G,GAE7B5G,WAAW6G,gBAAgBC,KAAK,CAC5BC,QAASjB,EACTkB,SAAUnH,EAAkCoG,GAC5CgB,aA/CoB,CACpBC,WAAc,CACVH,QAAS,6BACTE,aAAc,+BAElB,kBAAmB,CACfF,QAAS,8BACTE,aAAc,gCAwCY1D,GAAS0D,aACvCE,gBAAiB,KACjB3C,eAAgBA,EAChB4C,0BAA0B,EAC1BC,sBAAuB,QACvBrE,SAAU,cACVsE,gBAAiB,WACjBC,WAAW,IAIE,OAAbtF,GAIJG,EAA6BH,EACjC,IAzEIuF,QAAQC,MAAM,oDAJdD,QAAQC,MAAM,6DA8EtB,MAG0B/E,IAAtB1C,WAAW0H,SACX1H,WAAWsD,YAAcA,GAG7BqE,EAAOC,QAAUtE,UC9UjB,SAAS7D,EAAWoE,EAAKmD,GACrB,MAAMa,EAAS5G,SAAS6G,cAAc,UACtCD,EAAOE,IAAMlE,EACbgE,EAAOG,OAAQ,EAEfH,EAAOI,OAAS,KACRjB,GAAUA,EAAS,KAAMa,IAGjCA,EAAOK,QAAU,KACTlB,GAAUA,EAAS,IAAImB,MAAM,0BAA0BtE,OAG/D5C,SAASmH,KAAKjF,YAAY0E,EAC9B,MAG0BnF,IAAtB1C,WAAW0H,SACX1H,WAAWP,WAAaA,GAG5BkI,EAAOC,QAAUnI,ICzBjB,MAAA4I,EAAA,IAGA,SAAA3I,EAAA4I,GAEA,MAAAC,EAAAF,EAAAC,GACA,QAAA5F,IAAA6F,EACA,OAAAA,EAAAX,QAGA,MAAAD,EAAAU,EAAAC,GAAA,CAGAV,QAAA,IAOA,OAHAY,EAAAF,GAAAX,EAAAA,EAAAC,QAAAlI,GAGAiI,EAAAC,OACA,CCnBAlI,CAAA","sources":["webpack://@lizardbyte/shared-web/./src/js/crowdin.js","webpack://@lizardbyte/shared-web/./src/js/load-script.js","webpack://@lizardbyte/shared-web/webpack/bootstrap","webpack://@lizardbyte/shared-web/webpack/startup"],"sourcesContent":["const loadScript = require('./load-script');\n\n/**\n * jsDelivr CDN URL serving Crowdin distribution files from the crowdin-dist\n * git branch. jsDelivr unconditionally sets Access-Control-Allow-Origin: *,\n * so cross-origin fetch() calls succeed without any browser plugin.\n * The branch is refreshed daily by the \"Sync Crowdin Distribution\" workflow.\n * Structure mirrors https://distributions.crowdin.net/<hash>/… exactly.\n * @type {string}\n */\nconst CROWDIN_DIST_MIRROR = 'https://cdn.jsdelivr.net/gh/LizardByte/i18n@dist';\nconst CROWDIN_PLATFORM_STYLING_MAX_ATTEMPTS = 100;\nconst CROWDIN_PLATFORM_STYLING_RETRY_DELAY_MS = 50;\nconst CROWDIN_INLINE_ELEMENT_SELECTOR = [\n 'a',\n 'abbr',\n 'b',\n 'cite',\n 'code',\n 'del',\n 'em',\n 'i',\n 'ins',\n 'kbd',\n 'mark',\n 'q',\n 's',\n 'samp',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'sup',\n 'time',\n 'u',\n 'var',\n].join(',');\n\n/**\n * Records whitespace that separates text from inline elements before Crowdin translates the page.\n * @returns {Array<{\n * node: Text,\n * leading: boolean,\n * trailing: boolean,\n * previousInline: Element|null,\n * nextInline: Element|null,\n * whitespaceOnly: boolean\n * }>} Recorded text-node boundaries.\n */\nfunction _captureCrowdinWhitespaceBoundaries() {\n const boundaries = [];\n const walker = document.createTreeWalker(document.body, globalThis.NodeFilter.SHOW_TEXT);\n let node = walker.nextNode();\n\n while (node !== null) {\n const previousIsInline = node.previousSibling instanceof globalThis.Element &&\n node.previousSibling.matches(CROWDIN_INLINE_ELEMENT_SELECTOR);\n const nextIsInline = node.nextSibling instanceof globalThis.Element &&\n node.nextSibling.matches(CROWDIN_INLINE_ELEMENT_SELECTOR);\n const leading = previousIsInline && /^\\s/.test(node.data);\n const trailing = nextIsInline && /\\s$/.test(node.data);\n\n if (leading || trailing) {\n boundaries.push({\n node,\n leading,\n trailing,\n previousInline: previousIsInline ? node.previousSibling : null,\n nextInline: nextIsInline ? node.nextSibling : null,\n whitespaceOnly: /^\\s*$/.test(node.data),\n });\n }\n\n node = walker.nextNode();\n }\n\n return boundaries;\n}\n\n/**\n * Finds the current text node for a boundary after Crowdin changes the DOM.\n * @param {Object} boundary Recorded whitespace boundary.\n * @returns {Text|null} Current or recreated text node.\n */\nfunction _resolveCrowdinWhitespaceNode(boundary) {\n if (boundary.node.isConnected) return boundary.node;\n\n const previousReplacement = boundary.previousInline?.nextSibling;\n if (previousReplacement instanceof globalThis.Text && previousReplacement.isConnected) {\n boundary.node = previousReplacement;\n return boundary.node;\n }\n const nextReplacement = boundary.nextInline?.previousSibling;\n if (nextReplacement instanceof globalThis.Text && nextReplacement.isConnected) {\n boundary.node = nextReplacement;\n return boundary.node;\n }\n if (!boundary.whitespaceOnly) return null;\n\n const replacement = document.createTextNode('');\n if (boundary.previousInline?.isConnected) {\n boundary.previousInline.after(replacement);\n } else if (boundary.nextInline?.isConnected) {\n boundary.nextInline.before(replacement);\n } else {\n return null;\n }\n\n boundary.node = replacement;\n return boundary.node;\n}\n\n/**\n * Restores whitespace that Crowdin removed from translated text-node boundaries.\n * @param {Array<Object>} boundaries Recorded text-node boundaries.\n */\nfunction _restoreCrowdinWhitespaceBoundaries(boundaries) {\n boundaries.forEach((boundary) => {\n const node = _resolveCrowdinWhitespaceNode(boundary);\n if (node === null) return;\n\n if (boundary.leading && !/^\\s/.test(node.data)) {\n node.data = ' ' + node.data;\n }\n if (boundary.trailing && !/\\s$/.test(node.data)) {\n node.data += ' ';\n }\n });\n}\n\n/**\n * Creates the Website Translator callback and observes later translation mutations.\n * @param {Array<Object>} boundaries Recorded text-node boundaries.\n * @returns {Function} Website Translator callback.\n */\nfunction _createCrowdinTranslationCallback(boundaries) {\n const translationObserver = new globalThis.MutationObserver(restoreAndObserve);\n\n function restoreAndObserve() {\n translationObserver.disconnect();\n _restoreCrowdinWhitespaceBoundaries(boundaries);\n translationObserver.observe(document.body, {\n characterData: true,\n childList: true,\n subtree: true,\n });\n }\n\n return restoreAndObserve;\n}\n\n/**\n * Monkey-patches globalThis.fetch to redirect Crowdin distribution requests to\n * the self-hosted GitHub Pages mirror.\n *\n * Must be called BEFORE proxy-translator.js is loaded so that every fetch()\n * the script makes is already intercepted.\n *\n * Idempotent – installs the interceptor at most once per page.\n */\nfunction _installCrowdinFetchInterceptor() {\n if (typeof globalThis.fetch !== 'function') return;\n if (globalThis._crowdinMirrorInstalled) return;\n globalThis._crowdinMirrorInstalled = true;\n\n const _origFetch = globalThis.fetch.bind(globalThis);\n\n globalThis.fetch = function crowdinMirrorFetch(url, options) {\n if (typeof url === 'string') {\n let parsed;\n try {\n parsed = new URL(url);\n } catch {\n // Not a valid absolute URL – pass through unchanged.\n }\n // Use exact hostname comparison to avoid prefix-match bypasses\n // (e.g. distributions.crowdin.net.evil.com) that would be flagged\n // by incomplete URL sanitisation checks.\n if (parsed?.protocol === 'https:' && parsed.hostname === 'distributions.crowdin.net') {\n const mirroredUrl = CROWDIN_DIST_MIRROR + parsed.pathname + parsed.search + parsed.hash;\n return _origFetch(mirroredUrl, options);\n }\n }\n return _origFetch(url, options);\n };\n}\n\n/**\n * Re-attempts platform styling while Crowdin inserts the language picker.\n * @param {string} platform - UI platform ('sphinx' or 'rustdoc').\n * @param {number} attempt - Current retry count.\n */\nfunction _retryCrowdinPlatformStyling(platform, attempt) {\n if (attempt >= CROWDIN_PLATFORM_STYLING_MAX_ATTEMPTS) {\n return;\n }\n\n globalThis.setTimeout(function() {\n _applyCrowdinPlatformStyling(platform, attempt + 1);\n }, CROWDIN_PLATFORM_STYLING_RETRY_DELAY_MS);\n}\n\n/**\n * Applies platform-specific placement after the Crowdin picker exists.\n * @param {string} platform - UI platform ('sphinx' or 'rustdoc').\n * @param {number} attempt - Current retry count.\n */\nfunction _applyCrowdinPlatformStyling(platform, attempt = 0) {\n const container = document.getElementById('crowdin-language-picker');\n\n if (platform === 'sphinx') {\n const button = document.getElementsByClassName('cr-picker-button')[0];\n const sidebar = document.getElementsByClassName('sidebar-sticky')[0];\n\n if (container === null || button === undefined || sidebar === undefined) {\n _retryCrowdinPlatformStyling(platform, attempt);\n return;\n }\n\n container.classList.remove('cr-position-bottom-left');\n container.style.width = button.offsetWidth + 10 + 'px';\n container.style.position = 'relative';\n container.style.left = '10px';\n container.style.bottom = '10px';\n\n // move button to related pages\n sidebar.appendChild(container);\n return;\n }\n\n const sidebar = document.querySelector('.sidebar .sidebar-elems') || document.querySelector('.sidebar');\n\n if (container === null || sidebar === null) {\n _retryCrowdinPlatformStyling(platform, attempt);\n return;\n }\n\n container.classList.remove('cr-position-bottom-left');\n container.classList.add('rustdoc-crowdin-picker');\n container.style.position = 'static';\n container.style.left = 'auto';\n container.style.bottom = 'auto';\n\n sidebar.appendChild(container);\n}\n\n/**\n * Initializes Crowdin translation widget based on project and UI platform.\n * @param {string} project - Project name ('LizardByte' or 'LizardByte-docs').\n * @param {string|null} platform - UI platform ('sphinx', 'rustdoc', or null).\n */\nfunction initCrowdIn(project = 'LizardByte', platform = null) {\n // Input validation\n if (!['LizardByte', 'LizardByte-docs'].includes(project)) {\n console.error('Invalid project. Must be \"LizardByte\" or \"LizardByte-docs\"');\n return;\n }\n if (!['sphinx', 'rustdoc', null].includes(platform)) {\n console.error('Invalid UI. Must be \"sphinx\", \"rustdoc\", or null');\n return;\n }\n\n // Redirect distribution CDN requests to our self-hosted GitHub Pages mirror\n // before the script is even loaded so every fetch() it makes is intercepted.\n _installCrowdinFetchInterceptor();\n\n loadScript('https://website-translator.app.crowdin.net/assets/proxy-translator.js', function() {\n // Configure base settings based on project\n const projectSettings = {\n 'LizardByte': {\n baseUrl: \"https://app.lizardbyte.dev\",\n distribution: \"458f881791aebba1d4dde491bw4\",\n },\n 'LizardByte-docs': {\n baseUrl: \"https://docs.lizardbyte.dev\",\n distribution: \"d6c830ba4b41106fefe5d391bw4\",\n }\n };\n\n let languageTitles = {\n \"bg\": \"Български (Bulgarian)\",\n \"cs\": \"Čeština (Czech)\",\n \"de\": \"Deutsch (German)\",\n \"en\": \"English\",\n \"en-GB\": \"English, United Kingdom\",\n \"en-US\": \"English, United States\",\n \"es-ES\": \"Español (Spanish)\",\n \"fr\": \"Français (French)\",\n \"hu\": \"Magyar (Hungarian)\",\n \"it\": \"Italiano (Italian)\",\n \"ja\": \"日本語 (Japanese)\",\n \"ko\": \"한국어 (Korean)\",\n \"pl\": \"Polski (Polish)\",\n \"pt-BR\": \"Português, Brasileiro (Portuguese, Brazilian)\",\n \"pt-PT\": \"Português (Portuguese)\",\n \"ru\": \"Русский (Russian)\",\n \"sv-SE\": \"svenska (Swedish)\",\n \"tr\": \"Türkçe (Turkish)\",\n \"uk\": \"Українська (Ukranian)\",\n \"vi\": \"Tiếng Việt (Vietnamese)\",\n \"zh-CN\": \"简体中文 (Chinese Simplified)\",\n \"zh-TW\": \"繁體中文 (Chinese Traditional)\",\n };\n // sort languages by name\n languageTitles = Object.fromEntries(Object.entries(languageTitles).sort((a, b) => a[1].localeCompare(b[1])));\n\n // use this to allow translations to work on PR preview builds\n let currentBaseUrl = globalThis.location.origin;\n\n // Initialize Crowdin translator\n const whitespaceBoundaries = _captureCrowdinWhitespaceBoundaries();\n\n globalThis.proxyTranslator.init({\n baseUrl: currentBaseUrl,\n callback: _createCrowdinTranslationCallback(whitespaceBoundaries),\n distribution: projectSettings[project].distribution,\n defaultLanguage: \"en\",\n languageTitles: languageTitles,\n showDefaultLanguageInUrl: false,\n languageRoutingMethod: \"query\",\n position: \"bottom-left\",\n submenuPosition: \"top-left\",\n poweredBy: false,\n });\n\n // Apply styling based on UI framework\n if (platform === null) {\n return;\n }\n\n _applyCrowdinPlatformStyling(platform);\n });\n}\n\n// Expose to the global scope\nif (globalThis.window !== undefined) {\n globalThis.initCrowdIn = initCrowdIn;\n}\n\nmodule.exports = initCrowdIn;\n","/**\n * Load a script asynchronously, and add it to the DOM. Optionally, call a callback when the script has loaded.\n * @param {string} url The URL of the script to load.\n * @param {Function} callback An optional callback to call when the script has loaded.\n */\nfunction loadScript(url, callback) {\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n\n script.onload = () => {\n if (callback) callback(null, script);\n };\n\n script.onerror = () => {\n if (callback) callback(new Error(`Failed to load script: ${url}`));\n };\n\n document.head.appendChild(script);\n}\n\n// Expose to the global scope\nif (globalThis.window !== undefined) {\n globalThis.loadScript = loadScript;\n}\n\nmodule.exports = loadScript;\n","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nlet __webpack_exports__ = __webpack_require__(714);\n"],"names":["loadScript","__webpack_require__","CROWDIN_INLINE_ELEMENT_SELECTOR","join","_createCrowdinTranslationCallback","boundaries","translationObserver","globalThis","MutationObserver","restoreAndObserve","disconnect","forEach","boundary","node","isConnected","previousReplacement","previousInline","nextSibling","Text","nextReplacement","nextInline","previousSibling","whitespaceOnly","replacement","document","createTextNode","after","before","_resolveCrowdinWhitespaceNode","leading","test","data","trailing","_restoreCrowdinWhitespaceBoundaries","observe","body","characterData","childList","subtree","_retryCrowdinPlatformStyling","platform","attempt","setTimeout","_applyCrowdinPlatformStyling","container","getElementById","button","getElementsByClassName","sidebar","undefined","classList","remove","style","width","offsetWidth","position","left","bottom","appendChild","querySelector","add","initCrowdIn","project","includes","fetch","_crowdinMirrorInstalled","_origFetch","bind","url","options","parsed","URL","protocol","hostname","mirroredUrl","pathname","search","hash","_installCrowdinFetchInterceptor","languageTitles","bg","cs","de","en","fr","hu","it","ja","ko","pl","ru","tr","uk","vi","Object","fromEntries","entries","sort","a","b","localeCompare","currentBaseUrl","location","origin","whitespaceBoundaries","walker","createTreeWalker","NodeFilter","SHOW_TEXT","nextNode","previousIsInline","Element","matches","nextIsInline","push","_captureCrowdinWhitespaceBoundaries","proxyTranslator","init","baseUrl","callback","distribution","LizardByte","defaultLanguage","showDefaultLanguageInUrl","languageRoutingMethod","submenuPosition","poweredBy","console","error","window","module","exports","script","createElement","src","async","onload","onerror","Error","head","__webpack_module_cache__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/LizardByte/shared-web.git"
6
6
  },
7
- "version": "2026.726.204939",
7
+ "version": "2026.811.210538",
8
8
  "description": "Shared web assets for LizardByte projects",
9
9
  "license": "AGPL-3.0-only",
10
10
  "funding": "https://app.lizardbyte.dev",
@@ -29,26 +29,26 @@
29
29
  "@eslint/js": "10.0.1",
30
30
  "@jest/globals": "30.4.1",
31
31
  "babel-loader": "10.1.1",
32
- "clean-jsdoc-theme": "5.1.0",
32
+ "clean-jsdoc-theme": "5.1.1",
33
33
  "cross-env": "10.1.0",
34
34
  "css-loader": "7.1.4",
35
- "eslint": "10.8.0",
35
+ "eslint": "10.8.1",
36
36
  "eslint-plugin-jest": "29.16.0",
37
- "globals": "17.8.0",
37
+ "globals": "17.9.0",
38
38
  "jest": "30.4.2",
39
39
  "jest-environment-jsdom": "30.4.1",
40
40
  "jest-junit": "17.0.0",
41
41
  "jsdoc": "4.0.5",
42
42
  "mini-css-extract-plugin": "2.10.2",
43
43
  "node-fetch": "3.3.2",
44
- "npm-run-all2": "9.0.2",
45
- "postcss": "8.5.23",
44
+ "npm-run-all2": "9.0.3",
45
+ "postcss": "8.5.26",
46
46
  "postcss-loader": "8.2.1",
47
47
  "postcss-preset-env": "11.3.2",
48
48
  "sass": "1.102.0",
49
49
  "sass-loader": "17.0.0",
50
- "webpack": "5.109.0",
51
- "webpack-cli": "7.2.1",
50
+ "webpack": "5.109.2",
51
+ "webpack-cli": "7.2.2",
52
52
  "webpack-dev-server": "6.0.0"
53
53
  },
54
54
  "jest": {
package/src/js/crowdin.js CHANGED
@@ -11,6 +11,143 @@ const loadScript = require('./load-script');
11
11
  const CROWDIN_DIST_MIRROR = 'https://cdn.jsdelivr.net/gh/LizardByte/i18n@dist';
12
12
  const CROWDIN_PLATFORM_STYLING_MAX_ATTEMPTS = 100;
13
13
  const CROWDIN_PLATFORM_STYLING_RETRY_DELAY_MS = 50;
14
+ const CROWDIN_INLINE_ELEMENT_SELECTOR = [
15
+ 'a',
16
+ 'abbr',
17
+ 'b',
18
+ 'cite',
19
+ 'code',
20
+ 'del',
21
+ 'em',
22
+ 'i',
23
+ 'ins',
24
+ 'kbd',
25
+ 'mark',
26
+ 'q',
27
+ 's',
28
+ 'samp',
29
+ 'small',
30
+ 'span',
31
+ 'strong',
32
+ 'sub',
33
+ 'sup',
34
+ 'time',
35
+ 'u',
36
+ 'var',
37
+ ].join(',');
38
+
39
+ /**
40
+ * Records whitespace that separates text from inline elements before Crowdin translates the page.
41
+ * @returns {Array<{
42
+ * node: Text,
43
+ * leading: boolean,
44
+ * trailing: boolean,
45
+ * previousInline: Element|null,
46
+ * nextInline: Element|null,
47
+ * whitespaceOnly: boolean
48
+ * }>} Recorded text-node boundaries.
49
+ */
50
+ function _captureCrowdinWhitespaceBoundaries() {
51
+ const boundaries = [];
52
+ const walker = document.createTreeWalker(document.body, globalThis.NodeFilter.SHOW_TEXT);
53
+ let node = walker.nextNode();
54
+
55
+ while (node !== null) {
56
+ const previousIsInline = node.previousSibling instanceof globalThis.Element &&
57
+ node.previousSibling.matches(CROWDIN_INLINE_ELEMENT_SELECTOR);
58
+ const nextIsInline = node.nextSibling instanceof globalThis.Element &&
59
+ node.nextSibling.matches(CROWDIN_INLINE_ELEMENT_SELECTOR);
60
+ const leading = previousIsInline && /^\s/.test(node.data);
61
+ const trailing = nextIsInline && /\s$/.test(node.data);
62
+
63
+ if (leading || trailing) {
64
+ boundaries.push({
65
+ node,
66
+ leading,
67
+ trailing,
68
+ previousInline: previousIsInline ? node.previousSibling : null,
69
+ nextInline: nextIsInline ? node.nextSibling : null,
70
+ whitespaceOnly: /^\s*$/.test(node.data),
71
+ });
72
+ }
73
+
74
+ node = walker.nextNode();
75
+ }
76
+
77
+ return boundaries;
78
+ }
79
+
80
+ /**
81
+ * Finds the current text node for a boundary after Crowdin changes the DOM.
82
+ * @param {Object} boundary Recorded whitespace boundary.
83
+ * @returns {Text|null} Current or recreated text node.
84
+ */
85
+ function _resolveCrowdinWhitespaceNode(boundary) {
86
+ if (boundary.node.isConnected) return boundary.node;
87
+
88
+ const previousReplacement = boundary.previousInline?.nextSibling;
89
+ if (previousReplacement instanceof globalThis.Text && previousReplacement.isConnected) {
90
+ boundary.node = previousReplacement;
91
+ return boundary.node;
92
+ }
93
+ const nextReplacement = boundary.nextInline?.previousSibling;
94
+ if (nextReplacement instanceof globalThis.Text && nextReplacement.isConnected) {
95
+ boundary.node = nextReplacement;
96
+ return boundary.node;
97
+ }
98
+ if (!boundary.whitespaceOnly) return null;
99
+
100
+ const replacement = document.createTextNode('');
101
+ if (boundary.previousInline?.isConnected) {
102
+ boundary.previousInline.after(replacement);
103
+ } else if (boundary.nextInline?.isConnected) {
104
+ boundary.nextInline.before(replacement);
105
+ } else {
106
+ return null;
107
+ }
108
+
109
+ boundary.node = replacement;
110
+ return boundary.node;
111
+ }
112
+
113
+ /**
114
+ * Restores whitespace that Crowdin removed from translated text-node boundaries.
115
+ * @param {Array<Object>} boundaries Recorded text-node boundaries.
116
+ */
117
+ function _restoreCrowdinWhitespaceBoundaries(boundaries) {
118
+ boundaries.forEach((boundary) => {
119
+ const node = _resolveCrowdinWhitespaceNode(boundary);
120
+ if (node === null) return;
121
+
122
+ if (boundary.leading && !/^\s/.test(node.data)) {
123
+ node.data = ' ' + node.data;
124
+ }
125
+ if (boundary.trailing && !/\s$/.test(node.data)) {
126
+ node.data += ' ';
127
+ }
128
+ });
129
+ }
130
+
131
+ /**
132
+ * Creates the Website Translator callback and observes later translation mutations.
133
+ * @param {Array<Object>} boundaries Recorded text-node boundaries.
134
+ * @returns {Function} Website Translator callback.
135
+ */
136
+ function _createCrowdinTranslationCallback(boundaries) {
137
+ const translationObserver = new globalThis.MutationObserver(restoreAndObserve);
138
+
139
+ function restoreAndObserve() {
140
+ translationObserver.disconnect();
141
+ _restoreCrowdinWhitespaceBoundaries(boundaries);
142
+ translationObserver.observe(document.body, {
143
+ characterData: true,
144
+ childList: true,
145
+ subtree: true,
146
+ });
147
+ }
148
+
149
+ return restoreAndObserve;
150
+ }
14
151
 
15
152
  /**
16
153
  * Monkey-patches globalThis.fetch to redirect Crowdin distribution requests to
@@ -171,8 +308,11 @@ function initCrowdIn(project = 'LizardByte', platform = null) {
171
308
  let currentBaseUrl = globalThis.location.origin;
172
309
 
173
310
  // Initialize Crowdin translator
311
+ const whitespaceBoundaries = _captureCrowdinWhitespaceBoundaries();
312
+
174
313
  globalThis.proxyTranslator.init({
175
314
  baseUrl: currentBaseUrl,
315
+ callback: _createCrowdinTranslationCallback(whitespaceBoundaries),
176
316
  distribution: projectSettings[project].distribution,
177
317
  defaultLanguage: "en",
178
318
  languageTitles: languageTitles,
@@ -86,6 +86,7 @@ describe('initCrowdIn', () => {
86
86
  jest.clearAllMocks();
87
87
  jest.useRealTimers();
88
88
  delete globalThis.window.proxyTranslator;
89
+ delete globalThis.window.i18nextify;
89
90
  delete globalThis._crowdinMirrorInstalled;
90
91
  });
91
92
 
@@ -114,6 +115,89 @@ describe('initCrowdIn', () => {
114
115
  );
115
116
  });
116
117
 
118
+ it('should only pass supported Website Translator options', () => {
119
+ initCrowdIn();
120
+
121
+ // Simulate script loading
122
+ jest.runAllTimers();
123
+
124
+ const options = globalThis.proxyTranslator.init.mock.calls[0][0];
125
+ expect(Object.keys(options).sort()).toEqual([
126
+ 'baseUrl',
127
+ 'callback',
128
+ 'defaultLanguage',
129
+ 'distribution',
130
+ 'languageRoutingMethod',
131
+ 'languageTitles',
132
+ 'position',
133
+ 'poweredBy',
134
+ 'showDefaultLanguageInUrl',
135
+ 'submenuPosition',
136
+ ]);
137
+ });
138
+
139
+ it('should restore whitespace around translated inline elements', () => {
140
+ globalThis.document.body.innerHTML = `
141
+ <p id="translated">
142
+ GitHub <em>Discussions</em> are available. <strong>Yearly:</strong> <strong>$14.99</strong>, billed.
143
+ </p>
144
+ <p id="detached">Before <i>removed</i></p>
145
+ <p id="next-anchor"><i>gone</i> <strong>kept</strong></p>
146
+ <p id="no-anchor"><i>gone</i> <strong>also gone</strong></p>
147
+ `;
148
+
149
+ initCrowdIn();
150
+ jest.runAllTimers();
151
+
152
+ const options = globalThis.proxyTranslator.init.mock.calls[0][0];
153
+ const translated = globalThis.document.getElementById('translated');
154
+ const emphasis = translated.querySelector('em');
155
+ const strongElements = translated.querySelectorAll('strong');
156
+ const detachedBoundary = globalThis.document.querySelector('#detached i').previousSibling;
157
+ const nextAnchor = globalThis.document.getElementById('next-anchor');
158
+ const nextAnchorWhitespace = nextAnchor.querySelector('i').nextSibling;
159
+ const noAnchor = globalThis.document.getElementById('no-anchor');
160
+
161
+ emphasis.previousSibling.replaceWith(document.createTextNode('GitHub'));
162
+ emphasis.nextSibling.replaceWith(document.createTextNode('are available. '));
163
+ strongElements[0].nextSibling.remove();
164
+ detachedBoundary.remove();
165
+ nextAnchor.querySelector('i').remove();
166
+ nextAnchorWhitespace.remove();
167
+ noAnchor.remove();
168
+
169
+ options.callback();
170
+ options.callback();
171
+
172
+ expect(translated.textContent.trim()).toBe(
173
+ 'GitHub Discussions are available. Yearly: $14.99, billed.'
174
+ );
175
+ expect(nextAnchor.textContent).toBe(' kept');
176
+ });
177
+
178
+ it('should restore whitespace after later asynchronous DOM changes', async () => {
179
+ globalThis.document.body.innerHTML = '<p id="translated">Use <a href="#">this link</a> here.</p>';
180
+
181
+ initCrowdIn();
182
+ jest.runAllTimers();
183
+
184
+ const options = globalThis.proxyTranslator.init.mock.calls[0][0];
185
+ const translated = globalThis.document.getElementById('translated');
186
+ const link = translated.querySelector('a');
187
+
188
+ options.callback();
189
+ link.previousSibling.data = link.previousSibling.data.trimEnd();
190
+ await Promise.resolve();
191
+
192
+ expect(translated.textContent).toBe('Use this link here.');
193
+
194
+ jest.advanceTimersByTime(1000);
195
+ link.nextSibling.data = link.nextSibling.data.trimStart();
196
+ await Promise.resolve();
197
+
198
+ expect(translated.textContent).toBe('Use this link here.');
199
+ });
200
+
117
201
  it('should initialize proxyTranslator with LizardByte-docs settings', () => {
118
202
  initCrowdIn('LizardByte-docs');
119
203