type-on-strap 2.5.1 → 2.5.2

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.
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Simple-Jekyll-Search v2.1.3
2
+ * Simple-Jekyll-Search v2.1.4
3
3
  * Copyright 2015-2022, Christian Fei
4
4
  * Copyright 2025-2026, Sylhare
5
5
  * Licensed under the MIT License.
6
6
  */
7
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SimpleJekyllSearch={})}(this,function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=class{constructor(t){if(!this.validateParams(t))throw new Error("-- OptionsValidator: required options missing");this.requiredOptions=t.required}getRequiredOptions(){return this.requiredOptions}validate(t){const e=[];return this.requiredOptions.forEach(n=>{void 0===t[n]&&e.push(n)}),e}validateParams(t){return!!t&&void 0!==t.required&&Array.isArray(t.required)}};function n(t,e){const n=t.trim().toLowerCase(),r=e.endsWith(" ")?[e.toLowerCase()]:e.trim().toLowerCase().split(" ");if(r.filter(t=>n.indexOf(t)>=0).length!==r.length)return[];const i=[];for(const s of r){if(!s||0===s.length)continue;let e=0;for(;-1!==(e=n.indexOf(s,e));)i.push({start:e,end:e+s.length,text:t.substring(e,e+s.length),type:"exact"}),e+=s.length}return i}function r(t,e){if(0===(e=e.trimEnd()).length)return[];const n=t.toLowerCase(),r=e.toLowerCase();let i=0,s=0;const a=[];for(;i<t.length&&s<e.length;)n[i]===r[s]&&(a.push(i),s++),i++;if(s!==e.length)return[];const o=a[0],h=a[a.length-1]+1;return[{start:o,end:h,text:t.substring(o,h),type:"fuzzy"}]}function i(t,e,n={}){const r=e.replace(/\*/g,function(t){const e="number"!=typeof(n=t.maxSpaces)||Number.isNaN(n)||n<=0?0:Number.isFinite(n)?Math.floor(n):1/0;var n;return 0===e?"[^ ]*":e===1/0?"[^ ]*(?: [^ ]*)*":`[^ ]*(?: [^ ]*){0,${e}}`}(n)),i=new RegExp(r,"gi"),s=[];let a;for(;null!==(a=i.exec(t));)s.push({start:a.index,end:a.index+a[0].length,text:a[0],type:"wildcard"}),i.lastIndex===a.index&&i.lastIndex++;return s}var s=class{constructor(t){this.findMatchesFunction=t}matches(t,e){return!(null===t||""===t.trim()||!e)&&this.findMatchesFunction(t,e).length>0}findMatches(t,e){return null!==t&&""!==t.trim()&&e?this.findMatchesFunction(t,e):[]}},a=new s(n),o=new s((t,e)=>{const i=r(t,e);return i.length>0?i:n(t,e)}),h=class extends s{constructor(t={}){const e={...t};super((t,r)=>{const s=i(t,r,e);return s.length>0?s:n(t,r)}),this.config=e}getConfig(){return{...this.config}}};function l(t){return Boolean(t)&&"[object Object]"===Object.prototype.toString.call(t)}var c={searchInput:null,resultsContainer:null,json:[],success:function(){},searchResultTemplate:'<li><a href="{url}" title="{desc}">{title}</a></li>',templateMiddleware:(t,e,n)=>{},sortMiddleware:function(){return 0},noResultsText:"No results found",limit:10,strategy:"literal",debounceTime:null,exclude:[],onSearch:()=>{},onError:t=>console.error("SimpleJekyllSearch error:",t),fuzzy:!1},u=["searchInput","resultsContainer","json"],d=new Set(["Enter","Shift","CapsLock","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Meta"]),p=class{constructor(t={},e=()=>a){this.data=[],this.excludePatterns=[],this.strategyResolver=e,this.setOptions(t)}put(t){return l(t)?this.addObject(t):Array.isArray(t)?this.addArray(t):void 0}clear(){return this.data.length=0,this.data}search(t){return t?this.findMatches(this.data,t).sort(this.options.sortMiddleware).map(t=>({...t})):[]}setOptions(t){let e=this.normalizeStrategyOption(t?.strategy??c.strategy);t?.fuzzy&&!t?.strategy&&(console.warn('[Simple Jekyll Search] Warning: fuzzy option is deprecated. Use strategy: "fuzzy" instead.'),e={type:"fuzzy"});const n=t?.exclude||c.exclude;this.excludePatterns=n.map(t=>new RegExp(t)),this.options={limit:t?.limit||c.limit,searchStrategy:this.searchStrategy(e),sortMiddleware:t?.sortMiddleware||c.sortMiddleware,exclude:n,strategy:e}}addObject(t){return this.data.push(t),this.data}addArray(t){const e=[];this.clear();for(const n of t)l(n)&&e.push(this.addObject(n)[0]);return e}findMatches(t,e){const n=[];for(let r=0;r<t.length&&n.length<this.options.limit;r++){const i=this.findMatchesInObject(t[r],e);i&&n.push(i)}return n}findMatchesInObject(t,e){let n=!1;const r={...t};r._matchInfo={};for(const i in t)if(!this.isExcluded(t[i])&&this.options.searchStrategy.matches(t[i],e)&&(n=!0,this.options.searchStrategy.findMatches)){const n=this.options.searchStrategy.findMatches(t[i],e);n&&n.length>0&&(r._matchInfo[i]=n)}return n?r:void 0}isExcluded(t){const e=String(t);return this.excludePatterns.some(t=>t.test(e))}searchStrategy(t){return this.strategyResolver(t)}normalizeStrategyOption(t){return t?"string"==typeof t?{type:t}:t:this.getDefaultStrategyConfig()}getDefaultStrategyConfig(){const t=c.strategy;return"string"==typeof t?{type:t}:t}},g={pattern:/\{(.*?)\}/g,template:"",middleware:function(){}},f=class{constructor(t){this.debounceTimerHandle=null,this.eventHandler=null,this.pageShowHandler=null,this.pendingRequest=null,this.isInitialized=!1,this.STORAGE_KEY="sjs-search-state",this.options={...c},this.repository=new p({},t),this.optionsValidator=new e({required:u})}debounce(t,e){e?(this.debounceTimerHandle&&clearTimeout(this.debounceTimerHandle),this.debounceTimerHandle=setTimeout(t,e)):t()}throwError(t){throw new Error(`SimpleJekyllSearch --- ${t}`)}emptyResultsContainer(){this.options.resultsContainer.innerHTML=""}initWithJSON(t){this.repository.put(t),this.registerInput()}initWithURL(t){!function(t,e){const n=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");n.open("GET",t,!0),n.onreadystatechange=function(t,e){return function(){if(4===t.readyState&&200===t.status)try{e(null,JSON.parse(t.responseText))}catch(n){e(n instanceof Error?n:new Error(String(n)),null)}}}(n,e),n.send()}(t,(e,n)=>{e&&this.throwError(`Failed to load JSON from ${t}: ${e.message}`),this.initWithJSON(n)})}registerInput(){this.eventHandler=t=>{try{const e=t;d.has(e.key)||(this.emptyResultsContainer(),this.debounce(()=>{try{this.search(t.target.value)}catch(e){console.error("Search error:",e),this.options.onError?.(e)}},this.options.debounceTime??null))}catch(e){console.error("Input handler error:",e),this.options.onError?.(e)}},this.options.searchInput.addEventListener("input",this.eventHandler),this.pageShowHandler=()=>{this.restoreSearchState()},window.addEventListener("pageshow",this.pageShowHandler),this.restoreSearchState()}saveSearchState(t){if(t?.trim())try{const e={query:t.trim(),timestamp:Date.now(),path:window.location.pathname};sessionStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))}catch{}else this.clearSearchState()}getStoredSearchState(){try{const t=sessionStorage.getItem(this.STORAGE_KEY);if(!t)return null;const e=JSON.parse(t);return"string"!=typeof e?.query?null:Date.now()-e.timestamp>18e5||e.path&&e.path!==window.location.pathname?(this.clearSearchState(),null):e.query}catch{return this.clearSearchState(),null}}clearSearchState(){try{sessionStorage.removeItem(this.STORAGE_KEY)}catch{}}restoreSearchState(){if(this.options.resultsContainer.children.length>0)return;let t=this.options.searchInput.value?.trim();t||(t=this.getStoredSearchState()||""),t.length>0&&(this.options.searchInput.value=t,this.search(t))}search(t){if(t?.trim().length>0){this.saveSearchState(t),this.emptyResultsContainer();const e=this.repository.search(t);this.render(e,t),this.options.onSearch?.()}else this.clearSearchState()}render(t,e){if(0===t.length)return void this.options.resultsContainer.insertAdjacentHTML("beforeend",this.options.noResultsText);const n=document.createDocumentFragment();t.forEach(t=>{t.query=e;const r=document.createElement("div");r.innerHTML=function(t,e){return g.template.replace(g.pattern,function(n,r){const i=t._matchInfo?.[r];if(i&&i.length>0&&e){const n=g.middleware(r,t[r],g.template,e,i);if(void 0!==n)return n}if(e){const n=g.middleware(r,t[r],g.template,e);if(void 0!==n)return n}const s=g.middleware(r,t[r],g.template);return void 0!==s?s:t[r]||n})}(t,e),n.appendChild(r)}),this.options.resultsContainer.appendChild(n)}destroy(){this.eventHandler&&(this.options.searchInput.removeEventListener("input",this.eventHandler),this.eventHandler=null),this.pageShowHandler&&(window.removeEventListener("pageshow",this.pageShowHandler),this.pageShowHandler=null),this.debounceTimerHandle&&(clearTimeout(this.debounceTimerHandle),this.debounceTimerHandle=null),this.clearSearchState()}init(t){var e,n,r;this.optionsValidator.validate(t).length>0&&this.throwError(`Missing required options: ${u.join(", ")}`),this.options=(e=this.options,n=t,{...e,...n}),function(t){t.pattern&&(g.pattern=t.pattern),t.template&&(g.template=t.template),"function"==typeof t.middleware&&(g.middleware=t.middleware)}({template:this.options.searchResultTemplate,middleware:this.options.templateMiddleware}),this.repository.setOptions({limit:this.options.limit,sortMiddleware:this.options.sortMiddleware,strategy:this.options.strategy,exclude:this.options.exclude}),r=this.options.json,Array.isArray(r)||null!==r&&"object"==typeof r?this.initWithJSON(this.options.json):this.initWithURL(this.options.json);const i={search:this.search.bind(this),destroy:this.destroy.bind(this)};return this.options.success?.call(i),i}},m=class extends s{constructor(t={}){super((t,e)=>this.hybridFind(t,e)),this.config={...t,preferFuzzy:t.preferFuzzy??!1,wildcardPriority:t.wildcardPriority??!0,minFuzzyLength:t.minFuzzyLength??4,maxExtraFuzzyChars:t.maxExtraFuzzyChars??2,maxSpaces:t.maxSpaces??1}}hybridFind(t,e){if(this.config.wildcardPriority&&e.includes("*")){const n=i(t,e,this.config);if(n.length>0)return n}if(e.includes(" ")||e.length<this.config.minFuzzyLength){const r=n(t,e);if(r.length>0)return r}if(this.config.preferFuzzy||e.length>=this.config.minFuzzyLength){const n=r(t,e);if(n.length>0){const t=this.applyFuzzyConstraints(n,e);if(t.length>0)return t}}return n(t,e)}applyFuzzyConstraints(t,e){const n=this.config.maxExtraFuzzyChars;if(!Number.isFinite(n)||n<0)return t;const r=this.normalizeLength(e);return 0===r?t:t.filter(t=>{const e=this.normalizeLength(t.text);return Math.max(0,e-r)<=n})}normalizeLength(t){return t.replace(/\s+/g,"").length}},y=new m,S=class{static create(t={type:"literal"}){const{options:e}=t;switch(this.isValidStrategy(t.type)?t.type:"literal"){case"literal":default:return a;case"fuzzy":return o;case"wildcard":return new h(e);case"hybrid":return new m(e)}}static getAvailableStrategies(){return["literal","fuzzy","wildcard","hybrid"]}static isValidStrategy(t){return this.getAvailableStrategies().includes(t)}};function w(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.replace(/[&<>"']/g,t=>e[t])}function x(t){if(0===t.length)return[];const e=[...t].sort((t,e)=>t.start-e.start),n=[{...e[0]}];for(let r=1;r<e.length;r++){const t=e[r],i=n[n.length-1];t.start<=i.end?i.end=Math.max(i.end,t.end):n.push({...t})}return n}function b(t,e,n={}){if(!t||0===e.length)return w(t);const r=n.className||"search-highlight",i=n.maxLength,s=x(e);let a="",o=0;for(const h of s)a+=w(t.substring(o,h.start)),a+=`<span class="${r}">${w(t.substring(h.start,h.end))}</span>`,o=h.end;return a+=w(t.substring(o)),i&&a.length>i&&(a=function(t,e,n,r,i){if(0===e.length)return w(t.substring(0,n-3))+"...";const s=e[0],a=Math.max(0,s.start-r),o=Math.min(t.length,s.end+r);let h="";a>0&&(h+="...");const l=t.substring(a,o),c=e.filter(t=>t.start<o&&t.end>a).map(t=>({...t,start:Math.max(0,t.start-a),end:Math.min(l.length,t.end-a)}));let u=0;for(const d of c)h+=w(l.substring(u,d.start)),h+=`<span class="${i}">${w(l.substring(d.start,d.end))}</span>`,u=d.end;return h+=w(l.substring(u)),o<t.length&&(h+="..."),h}(t,s,i,n.contextLength||30,r)),a}var v=["content","desc","description"],z=["url","link","href","query"];function M(t={}){const e={className:t.className||"search-highlight",maxLength:t.maxLength,contextLength:t.contextLength||30},n=t.truncateFields||v,r=t.noHighlightFields||z;return function(t,i,s,a,o){if("string"!=typeof i)return;if(r.includes(t))return;const h=n.includes(t);if(o&&o.length>0&&a){const t=b(i,o,{...e,maxLength:h?e.maxLength:void 0});return t!==i?t:void 0}return h&&e.maxLength&&i.length>e.maxLength?w(i.substring(0,e.maxLength-3)+"..."):void 0}}function L(t){return new f(t=>S.create(t)).init(t)}"undefined"!=typeof window&&(window.SimpleJekyllSearch=L,window.createHighlightTemplateMiddleware=M),t.DefaultHybridSearchStrategy=y,t.HybridSearchStrategy=m,t.StrategyFactory=S,t.createHighlightTemplateMiddleware=M,t.default=L,t.defaultHighlightMiddleware=function(t,e,n,r,i){return M()(t,e,n,r,i)},t.escapeHtml=w,t.highlightWithMatchInfo=b,t.mergeOverlappingMatches=x});
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SimpleJekyllSearch={})}(this,function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=class{constructor(t){if(!this.validateParams(t))throw new Error("-- OptionsValidator: required options missing");this.requiredOptions=t.required}getRequiredOptions(){return this.requiredOptions}validate(t){const e=[];return this.requiredOptions.forEach(n=>{void 0===t[n]&&e.push(n)}),e}validateParams(t){return!!t&&void 0!==t.required&&Array.isArray(t.required)}};function n(t,e){const n=t.trim().toLowerCase(),r=e.endsWith(" ")?[e.toLowerCase()]:e.trim().toLowerCase().split(" ");if(r.filter(t=>n.indexOf(t)>=0).length!==r.length)return[];const i=[];for(const s of r){if(!s||0===s.length)continue;let e=0;for(;-1!==(e=n.indexOf(s,e));)i.push({start:e,end:e+s.length,text:t.substring(e,e+s.length),type:"exact"}),e+=s.length}return i}function r(t,e){if(0===(e=e.trimEnd()).length)return[];const n=t.toLowerCase(),r=e.toLowerCase();let i=0,s=0;const a=[];for(;i<t.length&&s<e.length;)n[i]===r[s]&&(a.push(i),s++),i++;if(s!==e.length)return[];const o=a[0],h=a[a.length-1]+1;return[{start:o,end:h,text:t.substring(o,h),type:"fuzzy"}]}function i(t,e,n={}){const r=e.replace(/\*/g,function(t){const e="number"!=typeof(n=t.maxSpaces)||Number.isNaN(n)||n<=0?0:Number.isFinite(n)?Math.floor(n):1/0;var n;return 0===e?"[^ ]*":e===1/0?"[^ ]*(?: [^ ]*)*":`[^ ]*(?: [^ ]*){0,${e}}`}(n)),i=new RegExp(r,"gi"),s=[];let a;for(;null!==(a=i.exec(t));)s.push({start:a.index,end:a.index+a[0].length,text:a[0],type:"wildcard"}),i.lastIndex===a.index&&i.lastIndex++;return s}var s=class{constructor(t){this.findMatchesFunction=t}matches(t,e){return!(null===t||""===t.trim()||!e)&&this.findMatchesFunction(t,e).length>0}findMatches(t,e){return null!==t&&""!==t.trim()&&e?this.findMatchesFunction(t,e):[]}},a=new s(n),o=new s((t,e)=>{const i=r(t,e);return i.length>0?i:n(t,e)}),h=class extends s{constructor(t={}){const e={...t};super((t,r)=>{const s=i(t,r,e);return s.length>0?s:n(t,r)}),this.config=e}getConfig(){return{...this.config}}},l={exact:100,fuzzy:50,wildcard:25};function c(t){return"title"===t?10:1}function u(t){if(t.length<2)return 0;const e=Math.min(...t.map(t=>t.start)),n=Math.max(...t.map(t=>t.end))-e-t.reduce((t,e)=>t+(e.end-e.start),0);return n<=0?80:Math.max(0,80-2*n)}function d(t){const e=t._matchInfo;if(!e||0===Object.keys(e).length)return 0;let n=0;for(const[r,i]of Object.entries(e)){const t=c(r);for(const e of i){let r=l[e.type]??0;r+=Math.max(0,50-2*e.start),n+=r*t}n+=u(i)*t}return n}function p(t,e){return d(e)-d(t)}function g(t){return Boolean(t)&&"[object Object]"===Object.prototype.toString.call(t)}var f={searchInput:null,resultsContainer:null,json:[],success:function(){},searchResultTemplate:'<li><a href="{url}" title="{desc}">{title}</a></li>',templateMiddleware:(t,e,n)=>{},sortMiddleware:function(){return 0},noResultsText:"No results found",limit:10,strategy:"literal",debounceTime:null,exclude:[],onSearch:()=>{},onError:t=>console.error("SimpleJekyllSearch error:",t),fuzzy:!1},m=["searchInput","resultsContainer","json"],y=new Set(["Enter","Shift","CapsLock","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Meta"]),S=class{constructor(t={},e=()=>a){this.data=[],this.excludePatterns=[],this.strategyResolver=e,this.setOptions(t)}put(t){return g(t)?this.addObject(t):Array.isArray(t)?this.addArray(t):void 0}clear(){return this.data.length=0,this.data}search(t){return t?this.findMatches(this.data,t).sort(this.options.sortMiddleware).map(t=>({...t})):[]}setOptions(t){let e=this.normalizeStrategyOption(t?.strategy??f.strategy);t?.fuzzy&&!t?.strategy&&(console.warn('[Simple Jekyll Search] Warning: fuzzy option is deprecated. Use strategy: "fuzzy" instead.'),e={type:"fuzzy"});const n=t?.exclude||f.exclude;this.excludePatterns=n.map(t=>new RegExp(t)),this.options={limit:t?.limit||f.limit,searchStrategy:this.searchStrategy(e),sortMiddleware:t?.sortMiddleware||f.sortMiddleware,exclude:n,strategy:e}}addObject(t){return this.data.push(t),this.data}addArray(t){const e=[];this.clear();for(const n of t)g(n)&&e.push(this.addObject(n)[0]);return e}findMatches(t,e){const n=[];for(let r=0;r<t.length&&n.length<this.options.limit;r++){const i=this.findMatchesInObject(t[r],e);i&&n.push(i)}return n}findMatchesInObject(t,e){let n=!1;const r={...t};r._matchInfo={};for(const i in t)if(!this.isExcluded(t[i])&&this.options.searchStrategy.matches(t[i],e)&&(n=!0,this.options.searchStrategy.findMatches)){const n=this.options.searchStrategy.findMatches(t[i],e);n&&n.length>0&&(r._matchInfo[i]=n)}return n?r:void 0}isExcluded(t){const e=String(t);return this.excludePatterns.some(t=>t.test(e))}searchStrategy(t){return this.strategyResolver(t)}normalizeStrategyOption(t){return t?"string"==typeof t?{type:t}:t:this.getDefaultStrategyConfig()}getDefaultStrategyConfig(){const t=f.strategy;return"string"==typeof t?{type:t}:t}},w={pattern:/\{(.*?)\}/g,template:"",middleware:function(){}},x=class{constructor(t){this.debounceTimerHandle=null,this.eventHandler=null,this.pageShowHandler=null,this.pendingRequest=null,this.isInitialized=!1,this.STORAGE_KEY="sjs-search-state",this.options={...f},this.repository=new S({},t),this.optionsValidator=new e({required:m})}debounce(t,e){e?(this.debounceTimerHandle&&clearTimeout(this.debounceTimerHandle),this.debounceTimerHandle=setTimeout(t,e)):t()}throwError(t){throw new Error(`SimpleJekyllSearch --- ${t}`)}emptyResultsContainer(){this.options.resultsContainer.innerHTML=""}initWithJSON(t){this.repository.put(t),this.registerInput()}initWithURL(t){!function(t,e){const n=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");n.open("GET",t,!0),n.onreadystatechange=function(t,e){return function(){if(4===t.readyState&&200===t.status)try{e(null,JSON.parse(t.responseText))}catch(n){e(n instanceof Error?n:new Error(String(n)),null)}}}(n,e),n.send()}(t,(e,n)=>{e&&this.throwError(`Failed to load JSON from ${t}: ${e.message}`),this.initWithJSON(n)})}registerInput(){this.eventHandler=t=>{try{const e=t;y.has(e.key)||(this.emptyResultsContainer(),this.debounce(()=>{try{this.search(t.target.value)}catch(e){console.error("Search error:",e),this.options.onError?.(e)}},this.options.debounceTime??null))}catch(e){console.error("Input handler error:",e),this.options.onError?.(e)}},this.options.searchInput.addEventListener("input",this.eventHandler),this.pageShowHandler=()=>{this.restoreSearchState()},window.addEventListener("pageshow",this.pageShowHandler),this.restoreSearchState()}saveSearchState(t){if(t?.trim())try{const e={query:t.trim(),timestamp:Date.now(),path:window.location.pathname};sessionStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))}catch{}else this.clearSearchState()}getStoredSearchState(){try{const t=sessionStorage.getItem(this.STORAGE_KEY);if(!t)return null;const e=JSON.parse(t);return"string"!=typeof e?.query?null:Date.now()-e.timestamp>18e5||e.path&&e.path!==window.location.pathname?(this.clearSearchState(),null):e.query}catch{return this.clearSearchState(),null}}clearSearchState(){try{sessionStorage.removeItem(this.STORAGE_KEY)}catch{}}restoreSearchState(){if(this.options.resultsContainer.children.length>0)return;let t=this.options.searchInput.value?.trim();t||(t=this.getStoredSearchState()||""),t.length>0&&(this.options.searchInput.value=t,this.search(t))}search(t){if(t?.trim().length>0){this.saveSearchState(t),this.emptyResultsContainer();const e=this.repository.search(t);this.render(e,t),this.options.onSearch?.()}else this.clearSearchState()}render(t,e){if(0===t.length)return void this.options.resultsContainer.insertAdjacentHTML("beforeend",this.options.noResultsText);const n=document.createDocumentFragment();t.forEach(t=>{t.query=e;const r=document.createElement("div");r.innerHTML=function(t,e){return w.template.replace(w.pattern,function(n,r){const i=t._matchInfo?.[r];if(i&&i.length>0&&e){const n=w.middleware(r,t[r],w.template,e,i);if(void 0!==n)return n}if(e){const n=w.middleware(r,t[r],w.template,e);if(void 0!==n)return n}const s=w.middleware(r,t[r],w.template);return void 0!==s?s:t[r]||n})}(t,e),n.appendChild(r)}),this.options.resultsContainer.appendChild(n)}destroy(){this.eventHandler&&(this.options.searchInput.removeEventListener("input",this.eventHandler),this.eventHandler=null),this.pageShowHandler&&(window.removeEventListener("pageshow",this.pageShowHandler),this.pageShowHandler=null),this.debounceTimerHandle&&(clearTimeout(this.debounceTimerHandle),this.debounceTimerHandle=null),this.clearSearchState()}init(t){var e,n,r;this.optionsValidator.validate(t).length>0&&this.throwError(`Missing required options: ${m.join(", ")}`),this.options=(e=this.options,n=t,{...e,...n}),function(t){t.pattern&&(w.pattern=t.pattern),t.template&&(w.template=t.template),"function"==typeof t.middleware&&(w.middleware=t.middleware)}({template:this.options.searchResultTemplate,middleware:this.options.templateMiddleware}),this.repository.setOptions({limit:this.options.limit,sortMiddleware:this.options.sortMiddleware,strategy:this.options.strategy,exclude:this.options.exclude}),r=this.options.json,Array.isArray(r)||null!==r&&"object"==typeof r?this.initWithJSON(this.options.json):this.initWithURL(this.options.json);const i={search:this.search.bind(this),destroy:this.destroy.bind(this)};return this.options.success?.call(i),i}},b=class extends s{constructor(t={}){super((t,e)=>this.hybridFind(t,e)),this.config={...t,preferFuzzy:t.preferFuzzy??!1,wildcardPriority:t.wildcardPriority??!0,minFuzzyLength:t.minFuzzyLength??4,maxExtraFuzzyChars:t.maxExtraFuzzyChars??2,maxSpaces:t.maxSpaces??1}}hybridFind(t,e){if(this.config.wildcardPriority&&e.includes("*")){const n=i(t,e,this.config);if(n.length>0)return n}if(e.includes(" ")||e.length<this.config.minFuzzyLength){const r=n(t,e);if(r.length>0)return r}if(this.config.preferFuzzy||e.length>=this.config.minFuzzyLength){const n=r(t,e);if(n.length>0){const t=this.applyFuzzyConstraints(n,e);if(t.length>0)return t}}return n(t,e)}applyFuzzyConstraints(t,e){const n=this.config.maxExtraFuzzyChars;if(!Number.isFinite(n)||n<0)return t;const r=this.normalizeLength(e);return 0===r?t:t.filter(t=>{const e=this.normalizeLength(t.text);return Math.max(0,e-r)<=n})}normalizeLength(t){return t.replace(/\s+/g,"").length}},v=new b,z=class{static create(t={type:"literal"}){const{options:e}=t;switch(this.isValidStrategy(t.type)?t.type:"literal"){case"literal":default:return a;case"fuzzy":return o;case"wildcard":return new h(e);case"hybrid":return new b(e)}}static getAvailableStrategies(){return["literal","fuzzy","wildcard","hybrid"]}static isValidStrategy(t){return this.getAvailableStrategies().includes(t)}};function M(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.replace(/[&<>"']/g,t=>e[t])}function L(t){if(0===t.length)return[];const e=[...t].sort((t,e)=>t.start-e.start),n=[{...e[0]}];for(let r=1;r<e.length;r++){const t=e[r],i=n[n.length-1];t.start<=i.end?i.end=Math.max(i.end,t.end):n.push({...t})}return n}function E(t,e,n={}){if(!t||0===e.length)return M(t);const r=n.className||"search-highlight",i=n.maxLength,s=L(e);let a="",o=0;for(const h of s)a+=M(t.substring(o,h.start)),a+=`<span class="${r}">${M(t.substring(h.start,h.end))}</span>`,o=h.end;return a+=M(t.substring(o)),i&&a.length>i&&(a=function(t,e,n,r,i){if(0===e.length)return M(t.substring(0,n-3))+"...";const s=e[0],a=Math.max(0,s.start-r),o=Math.min(t.length,s.end+r);let h="";a>0&&(h+="...");const l=t.substring(a,o),c=e.filter(t=>t.start<o&&t.end>a).map(t=>({...t,start:Math.max(0,t.start-a),end:Math.min(l.length,t.end-a)}));let u=0;for(const d of c)h+=M(l.substring(u,d.start)),h+=`<span class="${i}">${M(l.substring(d.start,d.end))}</span>`,u=d.end;return h+=M(l.substring(u)),o<t.length&&(h+="..."),h}(t,s,i,n.contextLength||30,r)),a}var O=["content","desc","description"],H=["url","link","href","query"];function T(t={}){const e={className:t.className||"search-highlight",maxLength:t.maxLength,contextLength:t.contextLength||30},n=t.truncateFields||O,r=t.noHighlightFields||H;return function(t,i,s,a,o){if("string"!=typeof i)return;if(r.includes(t))return;const h=n.includes(t);if(o&&o.length>0&&a){const t=E(i,o,{...e,maxLength:h?e.maxLength:void 0});return t!==i?t:void 0}return h&&e.maxLength&&i.length>e.maxLength?M(i.substring(0,e.maxLength-3)+"..."):void 0}}function C(t){return new x(t=>z.create(t)).init(t)}"undefined"!=typeof window&&(window.SimpleJekyllSearch=C,window.createHighlightTemplateMiddleware=T,window.RelevanceSort=p),t.DefaultHybridSearchStrategy=v,t.HybridSearchStrategy=b,t.RelevanceSort=p,t.StrategyFactory=z,t.createHighlightTemplateMiddleware=T,t.default=C,t.defaultHighlightMiddleware=function(t,e,n,r,i){return T()(t,e,n,r,i)},t.escapeHtml=M,t.highlightWithMatchInfo=E,t.mergeOverlappingMatches=L});
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type-on-strap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylhare
8
8
  - Rohan Chandra
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-01 00:00:00.000000000 Z
11
+ date: 2026-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -98,8 +98,10 @@ dependencies:
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
100
  version: 1.1.0
101
- description: A simple and responsive jekyll theme template based on type-theme. Great
102
- for blogs, easy to customize and responsive.
101
+ description: A free and open-source Jekyll theme for writers, developers, and creatives.
102
+ Includes portfolio and gallery pages, auto dark/light mode, full-text search, KaTeX
103
+ math rendering, Mermaid diagrams, multiple comment systems, and Bootstrap support.
104
+ Works as a Ruby gem or remote theme.
103
105
  email:
104
106
  - sylhare@outlook.com
105
107
  - hellorohan@outlook.com
@@ -272,5 +274,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
274
  requirements: []
273
275
  rubygems_version: 3.6.2
274
276
  specification_version: 4
275
- summary: A simple and responsive jekyll theme template
277
+ summary: Feature-rich Jekyll theme with portfolio, gallery, dark mode, search, KaTeX
278
+ and Mermaid
276
279
  test_files: []