@paroicms/content-loading-plugin 0.18.1 → 0.20.0

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,6 +1,6 @@
1
1
  import { isDef, strVal, strValOrUndef } from "@paroi/data-formatters-lib";
2
2
  import { parseNodelId } from "@paroicms/public-anywhere-lib";
3
- import { escapeHtml, resolveModuleDirectory, } from "@paroicms/public-server-lib";
3
+ import { escapeHtml, makeStylesheetLinkAsyncTag, resolveModuleDirectory, } from "@paroicms/public-server-lib";
4
4
  import { readFileSync } from "node:fs";
5
5
  import { dirname, join } from "node:path";
6
6
  import { getPartials, makeSearch } from "./controller.js";
@@ -12,8 +12,17 @@ const plugin = {
12
12
  version,
13
13
  slug: "content-loading",
14
14
  async siteInit(service) {
15
- service.setPublicAssetsDirectory(join(packageDir, "public-front", "dist"));
16
- service.addHeadTag(`<link rel="stylesheet" href="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.css`)}">`, `<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}"></script>`);
15
+ service.setPublicAssetsDirectory(join(packageDir, "frontend", "dist"));
16
+ service.registerHeadTags(({ html }) => {
17
+ if (html.includes(`data-effect="paSearchOpener"`) ||
18
+ html.includes(`data-effect="paSearchApp"`) ||
19
+ html.includes(`data-effect="paInfiniteLoading"`)) {
20
+ return [
21
+ makeStylesheetLinkAsyncTag(`${service.pluginAssetsUrl}/content-loading-plugin.css`),
22
+ `<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/content-loading-plugin.mjs`)}" async></script>`,
23
+ ];
24
+ }
25
+ });
17
26
  service.setPublicApiHandler(async (service, httpContext, relativePath) => {
18
27
  const { req, res } = httpContext;
19
28
  if (req.method === "GET" && relativePath === "/search") {
@@ -0,0 +1 @@
1
+ @charset "UTF-8";.PaSearchApp-form{display:flex;justify-content:center;margin-bottom:20px}.TinyModal{background:transparent;border:none;margin:auto;padding:0;position:fixed;overflow:visible;max-width:100vw;max-height:100vh}.TinyModal::backdrop{background-color:#222b}.TinyModal-body{overflow:scroll}.TinyModal-closeButton{align-items:center;background-color:#bbb;border-radius:50%;cursor:pointer;display:flex;font-size:30px;font-weight:700;height:40px;justify-content:center;line-height:1;position:absolute;right:-30px;top:-30px;width:40px;z-index:2}.TinyModal-closeButton:before{content:"×"}@media (max-width: 400px){.TinyModal-closeButton{right:-18px}}.TinyModalHidden{display:none!important}.PaSearchOpenerButton{cursor:pointer}.PaSearchOpenerButton-svg{fill:var(--paInteractiveColor, #000)}.PaSearchOpener{box-sizing:border-box;display:flex;gap:20px;justify-content:center;flex-direction:column;align-items:center;max-width:500px;padding:30px 5px;width:85vw}.PaSearchOpener-input{border:1px solid transparent;font-size:1.2rem;padding:10px;width:100%}.PaSearchOpener-button{cursor:pointer;padding:20px 25px}
@@ -1 +1 @@
1
- import{delegateEvents as re,template as E,insert as L,setAttribute as z,isServer as T,getRequestEvent as Y,createComponent as S,memo as Z,effect as K,render as pe}from"https://esm.sh/solid-js@1.9.7/web";import{createMemo as R,getOwner as me,runWithOwner as ge,useContext as we,createContext as ye,createSignal as A,createRenderEffect as We,on as j,startTransition as Ve,resetErrorBoundaries as He,batch as Ke,untrack as ve,createComponent as ze,children as be,mergeProps as Ge,Show as B,createRoot as Je,onCleanup as Se,sharedConfig as J,createEffect as $e}from"https://esm.sh/solid-js@1.9.7";function ee(e){return e.varName?` for '${e.varName}'`:""}function Qe(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function Xe(e,t={}){if(e==null||e===""&&!t.allowEmpty)throw new Error(`Missing string value${ee(t)}`);return typeof e=="string"?e:e.toString()}function k(e,t={}){return e==null||e===""&&!t.allowEmpty?void 0:Xe(e,t)}function Ye(e,t={}){if(typeof e=="number")return e;if(e==null)throw new Error(`Missing number value${ee(t)}`);if(typeof e=="string"&&Qe(e))return Number(e);throw new Error(`Cannot convert to number the value of type '${typeof e}'${ee(t)}`)}function V(e,t={}){return e==null?void 0:Ye(e,t)}function Ze(e){let t=e;const r=t.indexOf("?");r!==-1&&(t=t.substring(0,r));const o=t.indexOf("#");o!==-1&&(t=t.substring(0,o));const n=t.lastIndexOf("/");return n===-1?void 0:t.slice(0,n)}const Pe="/api/plugin/content-loading",Le=Ze(import.meta.url);async function et(e){const t=`${Pe}${e}`,r=await fetch(t);if(r.status!==200)throw new Error(`api error ${r.status}`);return await r.text()}function te(e){const t=document.createElement("div");return t.innerHTML=e,[...t.children]}const Ee=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function Re(e,t,r){for(const[o,n]of Object.entries(t)){const a=`${r}.${o}`;e[a]=n,Ee(n)&&Re(e,n,a)}}function tt(e){const t={...e};for(const[r,o]of Object.entries(e))Ee(o)&&Re(t,o,r);return t}const nt=(e,t)=>{if(t)for(const[r,o]of Object.entries(t))e=e.replace(new RegExp(`{{\\s*${r}\\s*}}`,"g"),o);return e},rt=e=>e;function ot(e,t=rt){return(r,...o)=>{r[0]==="."&&(r=r.slice(1));const n=e()?.[r];switch(typeof n){case"function":return n(...o);case"string":return t(n,o[0]);default:return n}}}const at={nothingMessage:"No results found for",search:"Search"},st={loadMore:"Load more"},it={searchApp:at,infiniteLoading:st},ct={nothingMessage:"Aucun résultat trouvé pour",search:"Rechercher"},lt={loadMore:"Charger la suite"},ut={searchApp:ct,infiniteLoading:lt},ue={en:it,fr:ut};function G(e){const t=R((()=>{const o=e in ue?e:"en";return tt(ue[o])}));return{t:ot(t,nt)}}var dt=E('<button class="PaInfiniteLoading-loadButton PaButton"type=button>'),ft=E("<div class=PaInfiniteLoading-loadMore>"),ht=E('<img class="PaInfiniteLoading-loading PaLoading"width=50 height=50 alt=…>');function pt(e,{language:t}){const r=V(e.dataset.start),o=V(e.dataset.total),n=V(e.dataset.limit),a=k(e.dataset.parentId),s=k(e.dataset.template),i=k(e.dataset.labeledById),c=k(e.dataset.labeledByField);if(!(r===void 0||o===void 0||a===void 0||n===void 0||s===void 0)){if(!t)throw new Error("Missing language");mt({language:t,limit:n,parentId:a,root:e,start:r,total:o,templateName:s,labeledBy:i!==void 0&&c?{termNodeId:i,fieldName:c}:void 0})}}function mt({language:e,limit:t,root:r,start:o,total:n,parentId:a,templateName:s,labeledBy:i}){const{t:c}=G(e);let l=o;if(l>=n)return;const f=(()=>{var m=dt();return m.$$click=p,L(m,(()=>c("infiniteLoading.loadMore"))),m})(),w=(()=>{var m=ft();return L(m,f),m})(),h=(()=>{var m=ht();return z(m,"src",`${Le}/spinner.svg`),m})();r.appendChild(w);async function p(){r.appendChild(h);const m=await gt({limit:t,newStart:l,parentId:a,templateName:s,labeledBy:i});for(const u of m)r.insertBefore(u,w);l+=t,l>=n&&w.remove(),h.remove()}}async function gt({limit:e,newStart:t,parentId:r,templateName:o,labeledBy:n}){let a="";if(n){const c=encodeURIComponent(n.termNodeId),l=encodeURIComponent(n.fieldName);a=`&labeled-t=${c}&labeled-f=${l}`}const s=`/partials?template=${encodeURIComponent(o)}&children-of=${encodeURIComponent(r)}&start=${encodeURIComponent(t)}&limit=${encodeURIComponent(e)}${a}`,i=await et(s);return te(i)}re(["click"]);function Ae(){let e=new Set;function t(n){return e.add(n),()=>e.delete(n)}let r=!1;function o(n,a){if(r)return!(r=!1);const s={to:n,options:a,defaultPrevented:!1,preventDefault:()=>s.defaultPrevented=!0};for(const i of e)i.listener({...s,from:i.location,retry:c=>{c&&(r=!0),i.navigate(n,{...a,resolve:!1})}});return!s.defaultPrevented}return{subscribe:t,confirm:o}}let ne;function oe(){(!window.history.state||window.history.state._depth==null)&&window.history.replaceState({...window.history.state,_depth:window.history.length-1},""),ne=window.history.state._depth}T||oe();function wt(e){return{...e,_depth:window.history.state&&window.history.state._depth}}function yt(e,t){let r=!1;return()=>{const o=ne;oe();const n=o==null?null:ne-o;if(r){r=!1;return}n&&t(n)?(r=!0,window.history.go(-n)):e()}}const vt=/^(?:[a-z0-9]+:)?\/\//i,bt=/^\/+|(\/)\/+$/g,Ce="http://sr";function N(e,t=!1){const r=e.replace(bt,"$1");return r?t||/^[?#]/.test(r)?r:"/"+r:""}function H(e,t,r){if(vt.test(t))return;const o=N(e),n=r&&N(r);let a="";return!n||t.startsWith("/")?a=o:n.toLowerCase().indexOf(o.toLowerCase())!==0?a=o+n:a=n,(a||"/")+N(t,!a)}function St(e,t){if(e==null)throw new Error(t);return e}function $t(e,t){return N(e).replace(/\/*(\*.*)?$/g,"")+N(t)}function Ie(e){const t={};return e.searchParams.forEach(((r,o)=>{o in t?Array.isArray(t[o])?t[o].push(r):t[o]=[t[o],r]:t[o]=r})),t}function Pt(e,t,r){const[o,n]=e.split("/*",2),a=o.split("/").filter(Boolean),s=a.length;return i=>{const c=i.split("/").filter(Boolean),l=c.length-s;if(l<0||l>0&&n===void 0&&!t)return null;const f={path:s?"":"/",params:{}},w=h=>r===void 0?void 0:r[h];for(let h=0;h<s;h++){const p=a[h],m=p[0]===":",u=m?c[h]:c[h].toLowerCase(),d=m?p.slice(1):p.toLowerCase();if(m&&Q(u,w(d)))f.params[d]=u;else if(m||!Q(u,d))return null;f.path+=`/${u}`}if(n){const h=l?c.slice(-l).join("/"):"";if(Q(h,w(n)))f.params[n]=h;else return null}return f}}function Q(e,t){const r=o=>o===e;return t===void 0?!0:typeof t=="string"?r(t):typeof t=="function"?t(e):Array.isArray(t)?t.some(r):t instanceof RegExp?t.test(e):!1}function Lt(e){const[t,r]=e.pattern.split("/*",2),o=t.split("/").filter(Boolean);return o.reduce(((n,a)=>n+(a.startsWith(":")?2:3)),o.length-(r===void 0?0:1))}function _e(e){const t=new Map,r=me();return new Proxy({},{get(o,n){return t.has(n)||ge(r,(()=>t.set(n,R((()=>e()[n]))))),t.get(n)()},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},ownKeys(){return Reflect.ownKeys(e())}})}function xe(e){let t=/(\/?\:[^\/]+)\?/.exec(e);if(!t)return[e];let r=e.slice(0,t.index),o=e.slice(t.index+t[0].length);const n=[r,r+=t[1]];for(;t=/^(\/\:[^\/]+)\?/.exec(o);)n.push(r+=t[1]),o=o.slice(t[0].length);return xe(o).reduce(((a,s)=>[...a,...n.map((i=>i+s))]),[])}const Et=100,Oe=ye(),Ue=ye(),ae=()=>St(we(Oe),"<A> and 'use' router primitives can be only used inside a Route."),Me=()=>ae().navigatorFactory(),Rt=()=>ae().location,At=()=>ae().params;function Ct(e,t=""){const{component:r,preload:o,load:n,children:a,info:s}=e,i=!a||Array.isArray(a)&&!a.length,c={key:e,component:r,preload:o||n,info:s};return Be(e.path).reduce(((l,f)=>{for(const w of xe(f)){const h=$t(t,w);let p=i?h:h.split("/*",1)[0];p=p.split("/").map((m=>m.startsWith(":")||m.startsWith("*")?m:encodeURIComponent(m))).join("/"),l.push({...c,originalPath:f,pattern:p,matcher:Pt(p,!i,e.matchFilters)})}return l}),[])}function It(e,t=0){return{routes:e,score:Lt(e[e.length-1])*1e4-t,matcher(r){const o=[];for(let n=e.length-1;n>=0;n--){const a=e[n],s=a.matcher(r);if(!s)return null;o.unshift({...s,route:a})}return o}}}function Be(e){return Array.isArray(e)?e:[e]}function Fe(e,t="",r=[],o=[]){const n=Be(e);for(let a=0,s=n.length;a<s;a++){const i=n[a];if(i&&typeof i=="object"){i.hasOwnProperty("path")||(i.path="");const c=Ct(i,t);for(const l of c){r.push(l);const f=Array.isArray(i.children)&&i.children.length===0;if(i.children&&!f)Fe(i.children,l.pattern,r,o);else{const w=It([...r],o.length);o.push(w)}r.pop()}}}return r.length?o:o.sort(((a,s)=>s.score-a.score))}function q(e,t){for(let r=0,o=e.length;r<o;r++){const n=e[r].matcher(t);if(n)return n}return[]}function _t(e,t,r){const o=new URL(Ce),n=R((f=>{const w=e();try{return new URL(w,o)}catch{return console.error(`Invalid path ${w}`),f}}),o,{equals:(f,w)=>f.href===w.href}),a=R((()=>n().pathname)),s=R((()=>n().search),!0),i=R((()=>n().hash)),c=()=>"",l=j(s,(()=>Ie(n())));return{get pathname(){return a()},get search(){return s()},get hash(){return i()},get state(){return t()},get key(){return c()},query:r?r(l):_e(l)}}let _;function xt(){return _}function Ot(e,t,r,o={}){const{signal:[n,a],utils:s={}}=e,i=s.parsePath||(g=>g),c=s.renderPath||(g=>g),l=s.beforeLeave||Ae(),f=H("",o.base||"");if(f===void 0)throw new Error(`${f} is not a valid base path`);f&&!n().value&&a({value:f,replace:!0,scroll:!1});const[w,h]=A(!1);let p;const m=(g,v)=>{v.value===u()&&v.state===y()||(p===void 0&&h(!0),_=g,p=v,Ve((()=>{p===v&&(d(p.value),b(p.state),He(),T||I[1]((P=>P.filter((x=>x.pending)))))})).finally((()=>{p===v&&Ke((()=>{_=void 0,g==="navigate"&&qe(p),h(!1),p=void 0}))})))},[u,d]=A(n().value),[y,b]=A(n().state),$=_t(u,y,s.queryWrapper),C=[],I=A(T?De():[]),F=R((()=>typeof o.transformUrl=="function"?q(t(),o.transformUrl($.pathname)):q(t(),$.pathname))),se=()=>{const g=F(),v={};for(let P=0;P<g.length;P++)Object.assign(v,g[P].params);return v},ke=s.paramsWrapper?s.paramsWrapper(se,t):_e(se),ie={pattern:f,path:()=>f,outlet:()=>null,resolvePath(g){return H(f,g)}};return We(j(n,(g=>m("native",g)),{defer:!0})),{base:ie,location:$,params:ke,isRouting:w,renderPath:c,parsePath:i,navigatorFactory:Ne,matches:F,beforeLeave:l,preloadRoute:je,singleFlight:o.singleFlight===void 0?!0:o.singleFlight,submissions:I};function Te(g,v,P){ve((()=>{if(typeof v=="number"){v&&(s.go?s.go(v):console.warn("Router integration does not support relative routing"));return}const x=!v||v[0]==="?",{replace:D,resolve:O,scroll:W,state:U}={replace:!1,resolve:!x,scroll:!0,...P},M=O?g.resolvePath(v):H(x&&$.pathname||"",v);if(M===void 0)throw new Error(`Path '${v}' is not a routable path`);if(C.length>=Et)throw new Error("Too many redirects");const ce=u();if(M!==ce||U!==y())if(T){const le=Y();le&&(le.response={status:302,headers:new Headers({Location:M})}),a({value:M,replace:D,scroll:W,state:U})}else l.confirm(M,P)&&(C.push({value:ce,replace:D,scroll:W,state:y()}),m("navigate",{value:M,state:U}))}))}function Ne(g){return g=g||we(Ue)||ie,(v,P)=>Te(g,v,P)}function qe(g){const v=C[0];v&&(a({...g,replace:v.replace,scroll:v.scroll}),C.length=0)}function je(g,v){const P=q(t(),g.pathname),x=_;_="preload";for(let D in P){const{route:O,params:W}=P[D];O.component&&O.component.preload&&O.component.preload();const{preload:U}=O;v&&U&&ge(r(),(()=>U({params:W,location:{pathname:g.pathname,search:g.search,hash:g.hash,query:Ie(g),state:null,key:""},intent:"preload"})))}_=x}function De(){const g=Y();return g&&g.router&&g.router.submission?[g.router.submission]:[]}}function Ut(e,t,r,o){const{base:n,location:a,params:s}=e,{pattern:i,component:c,preload:l}=o().route,f=R((()=>o().path));c&&c.preload&&c.preload();const w=l?l({params:s,location:a,intent:_||"initial"}):void 0;return{parent:t,pattern:i,path:f,outlet:()=>c?ze(c,{params:s,location:a,data:w,get children(){return r()}}):r(),resolvePath(p){return H(n.path(),p,f())}}}const Mt=e=>t=>{const{base:r}=t,o=be((()=>t.children)),n=R((()=>Fe(o(),t.base||"")));let a;const s=Ot(e,n,(()=>a),{base:r,singleFlight:t.singleFlight,transformUrl:t.transformUrl});return e.create&&e.create(s),S(Oe.Provider,{value:s,get children(){return S(Bt,{routerState:s,get root(){return t.root},get preload(){return t.rootPreload||t.rootLoad},get children(){return[Z((()=>(a=me())&&null)),S(Ft,{routerState:s,get branches(){return n()}})]}})}})};function Bt(e){const t=e.routerState.location,r=e.routerState.params,o=R((()=>e.preload&&ve((()=>{e.preload({params:r,location:t,intent:xt()||"initial"})}))));return S(B,{get when(){return e.root},keyed:!0,get fallback(){return e.children},children:n=>S(n,{params:r,location:t,get data(){return o()},get children(){return e.children}})})}function Ft(e){if(T){const n=Y();if(n&&n.router&&n.router.dataOnly){kt(n,e.routerState,e.branches);return}n&&((n.router||(n.router={})).matches||(n.router.matches=e.routerState.matches().map((({route:a,path:s,params:i})=>({path:a.originalPath,pattern:a.pattern,match:s,params:i,info:a.info})))))}const t=[];let r;const o=R(j(e.routerState.matches,((n,a,s)=>{let i=a&&n.length===a.length;const c=[];for(let l=0,f=n.length;l<f;l++){const w=a&&a[l],h=n[l];s&&w&&h.route.key===w.route.key?c[l]=s[l]:(i=!1,t[l]&&t[l](),Je((p=>{t[l]=p,c[l]=Ut(e.routerState,c[l-1]||e.routerState.base,de((()=>o()[l+1])),(()=>e.routerState.matches()[l]))})))}return t.splice(n.length).forEach((l=>l())),s&&i?s:(r=c[0],c)})));return de((()=>o()&&r))()}const de=e=>()=>S(B,{get when(){return e()},keyed:!0,children:t=>S(Ue.Provider,{value:t,get children(){return t.outlet()}})}),X=e=>{const t=be((()=>e.children));return Ge(e,{get children(){return t()}})};function kt(e,t,r){const o=new URL(e.request.url),n=q(r,new URL(e.router.previousUrl||e.request.url).pathname),a=q(r,o.pathname);for(let s=0;s<a.length;s++){(!n[s]||a[s].route!==n[s].route)&&(e.router.dataOnly=!0);const{route:i,params:c}=a[s];i.preload&&i.preload({params:c,location:t.location,intent:"preload"})}}function Tt([e,t],r,o){return[e,o?n=>t(o(n)):t]}function Nt(e){let t=!1;const r=n=>typeof n=="string"?{value:n}:n,o=Tt(A(r(e.get()),{equals:(n,a)=>n.value===a.value&&n.state===a.state}),void 0,(n=>(!t&&e.set(n),J.registry&&!J.done&&(J.done=!0),n)));return e.init&&Se(e.init(((n=e.get())=>{t=!0,o[1](r(n)),t=!1}))),Mt({signal:o,create:e.create,utils:e.utils})}function qt(e,t,r){return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}function jt(e,t){const r=e&&document.getElementById(e);r?r.scrollIntoView():t&&window.scrollTo(0,0)}const Dt=new Map;function Wt(e=!0,t=!1,r="/_server",o){return n=>{const a=n.base.path(),s=n.navigatorFactory(n.base);let i,c;function l(u){return u.namespaceURI==="http://www.w3.org/2000/svg"}function f(u){if(u.defaultPrevented||u.button!==0||u.metaKey||u.altKey||u.ctrlKey||u.shiftKey)return;const d=u.composedPath().find((F=>F instanceof Node&&F.nodeName.toUpperCase()==="A"));if(!d||t&&!d.hasAttribute("link"))return;const y=l(d),b=y?d.href.baseVal:d.href;if((y?d.target.baseVal:d.target)||!b&&!d.hasAttribute("state"))return;const C=(d.getAttribute("rel")||"").split(/\s+/);if(d.hasAttribute("download")||C&&C.includes("external"))return;const I=y?new URL(b,document.baseURI):new URL(b);if(!(I.origin!==window.location.origin||a&&I.pathname&&!I.pathname.toLowerCase().startsWith(a.toLowerCase())))return[d,I]}function w(u){const d=f(u);if(!d)return;const[y,b]=d,$=n.parsePath(b.pathname+b.search+b.hash),C=y.getAttribute("state");u.preventDefault(),s($,{resolve:!1,replace:y.hasAttribute("replace"),scroll:!y.hasAttribute("noscroll"),state:C?JSON.parse(C):void 0})}function h(u){const d=f(u);if(!d)return;const[y,b]=d;n.preloadRoute(b,y.getAttribute("preload")!=="false")}function p(u){clearTimeout(i);const d=f(u);if(!d)return c=null;const[y,b]=d;c!==y&&(i=setTimeout((()=>{n.preloadRoute(b,y.getAttribute("preload")!=="false"),c=y}),20))}function m(u){if(u.defaultPrevented)return;let d=u.submitter&&u.submitter.hasAttribute("formaction")?u.submitter.getAttribute("formaction"):u.target.getAttribute("action");if(!d)return;if(!d.startsWith("https://action/")){const b=new URL(d,Ce);if(d=n.parsePath(b.pathname+b.search),!d.startsWith(r))return}if(u.target.method.toUpperCase()!=="POST")throw new Error("Only POST forms are supported for Actions");const y=Dt.get(d);if(y){u.preventDefault();const b=new FormData(u.target,u.submitter);y.call({r:n,f:u.target},u.target.enctype==="multipart/form-data"?b:new URLSearchParams(b))}}re(["click","submit"]),document.addEventListener("click",w),e&&(document.addEventListener("mousemove",p,{passive:!0}),document.addEventListener("focusin",h,{passive:!0}),document.addEventListener("touchstart",h,{passive:!0})),document.addEventListener("submit",m),Se((()=>{document.removeEventListener("click",w),e&&(document.removeEventListener("mousemove",p),document.removeEventListener("focusin",h),document.removeEventListener("touchstart",h)),document.removeEventListener("submit",m)}))}}function Vt(e){const t=e.replace(/^.*?#/,"");if(!t.startsWith("/")){const[,r="/"]=window.location.hash.split("#",2);return`${r}#${t}`}return t}function Ht(e){const t=()=>window.location.hash.slice(1),r=Ae();return Nt({get:t,set({value:o,replace:n,scroll:a,state:s}){n?window.history.replaceState(wt(s),"","#"+o):window.history.pushState(s,"","#"+o);const i=o.indexOf("#"),c=i>=0?o.slice(i+1):"";jt(c,a),oe()},init:o=>qt(window,"hashchange",yt(o,(n=>!r.confirm(n&&n<0?n:t())))),create:Wt(e.preload,e.explicitLinks,e.actionBase),utils:{go:o=>window.history.go(o),renderPath:o=>`#${o}`,parsePath:Vt,beforeLeave:r}})(e)}function Kt(e){const t=Me(),r=Rt(),{href:o,state:n}=e,a=typeof o=="function"?o({navigate:t,location:r}):o;return t(a,{replace:!0,state:n}),null}async function fe({language:e,text:t,limit:r,start:o,templateName:n}){const a=`${Pe}/search?language=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}&limit=${encodeURIComponent(r)}&start=${encodeURIComponent(o)}&tpl=${encodeURIComponent(n)}`,s=await fetch(a,{method:"GET"});if(s.status!==200){const c=await s.text();throw new Error(`API error (${s.status}): ${c}`)}return await s.json()}var zt=E('<form class=PaSearchApp-form><input class="PaSearchApp-input PaInput"type=search><button class="PaSearchApp-searchButton PaButton"type=submit>');function Gt(e){const t=Me(),[r,o]=A(e.value??""),{t:n}=G(e.language);$e(j((()=>e.value),(()=>o(e.value??""))));const a=async s=>{s.preventDefault(),t(`/q/${encodeURIComponent(r())}`)};return(()=>{var s=zt(),i=s.firstChild,c=i.nextSibling;return s.addEventListener("submit",a),i.addEventListener("change",(l=>o(l.currentTarget.value))),L(c,(()=>n("searchApp.search"))),K((()=>z(i,"placeholder",n("searchApp.search")))),K((()=>i.value=r())),s})()}var Jt=E("<div class=PaSearchApp-loadMore>"),Qt=E("<div class=PaSearchApp-results>"),Xt=E("<div class=PaSearchApp>"),Yt=E("<div class=PaSearchApp-nothing> <span class=PaSearchApp-quote>"),Zt=E('<img class="PaSearchApp-loading PaLoading"width=80 height=80 alt=…>'),en=E('<button class="PaSearchApp-loadButton PaButton"type=button>');function he({language:e,limit:t,templateName:r}){const{t:o}=G(e),n=At(),[a,s]=A([]),[i,c]=A(-1),[l,f]=A(0),[w,h]=A(!1);$e(j((()=>n.searchString),p));async function p(){if(n.searchString){h(!0);try{s([]),f(0),c(-1);const u=await fe({language:e,text:decodeURIComponent(n.searchString),limit:t,start:l(),templateName:r});if(c(u.total),f(l()+t),!u.html)return;s(te(u.html))}finally{h(!1)}}}async function m(){if(!n.searchString)return;const u=i();if(!(u===-1||l()>=u)){h(!0);try{const d=await fe({language:e,text:decodeURIComponent(n.searchString),limit:t,start:l(),templateName:r});if(!d.html)return;s([...a(),...te(d.html)]),f(l()+t)}finally{h(!1)}}}return(()=>{var u=Xt();return L(u,S(Gt,{language:e,get value(){return Z((()=>!!n.searchString))()?decodeURIComponent(n.searchString):void 0}}),null),L(u,S(B,{get when(){return n.searchString},get children(){var d=Qt();return L(d,S(B,{get when(){return i()!==-1},get children(){return S(B,{get when(){return a().length>0},get fallback(){return(()=>{var y=Yt(),b=y.firstChild,$=b.nextSibling;return L(y,(()=>o("searchApp.nothingMessage")),b),L($,(()=>n.searchString)),y})()},get children(){return a()}})}}),null),L(d,S(B,{get when(){return i()===-1||w()||l()<i()},get children(){var y=Jt();return L(y,(()=>{var b=Z((()=>!!w()));return()=>b()?(()=>{var $=Zt();return z($,"src",`${Le}/spinner.svg`),$})():(()=>{var $=en();return $.$$click=m,L($,(()=>o("infiniteLoading.loadMore"))),$})()})()),y}}),null),d}}),null),u})()}re(["click"]);function tn(e,{language:t}){if(!t)throw new Error("Missing language");const r=V(e.dataset.limit),o=k(e.dataset.template);r===void 0||o===void 0||pe((()=>S(Ht,{explicitLinks:!0,get children(){return[S(X,{path:"/",component:()=>S(Kt,{href:"/q"})}),S(X,{path:"/q",component:()=>S(he,{language:t,templateName:o,limit:r})}),S(X,{path:"/q/:searchString",component:()=>S(he,{language:t,templateName:o,limit:r})})]}})),e)}function nn({openButton:e,dialogContent:t,modalClass:r}){const o=e?typeof e=="string"?document.querySelector(e):e:void 0,n=typeof t=="string"?document.querySelector(t):t;if(!n)return;n instanceof HTMLTemplateElement||n.classList.remove("TinyModalHidden");const a=document.createElement("dialog");a.classList.add("TinyModal"),a.classList.add(r);const s=document.createElement("button");s.classList.add("TinyModal-closeButton"),a.appendChild(s);const i=document.createElement("div");i.classList.add("TinyModal-body"),i.appendChild(n instanceof HTMLTemplateElement?n.content.cloneNode(!0):n),a.appendChild(i),document.body.appendChild(a);const c=new Map;function l(p,m){c.has(p)||c.set(p,[]),c.get(p)?.push(m)}function f(p){c.has(p)&&c.get(p)?.forEach((m=>m()))}function w(){a.showModal(),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",f("open")}function h(){a.close()}return o?.addEventListener("click",w),s.addEventListener("click",h),a.addEventListener("close",(()=>{document.body.style.removeProperty("overflow"),document.documentElement.style.removeProperty("overflow"),f("close")})),{open:w,close:h,on:l}}var rn=E('<input class="PaSearchOpener-input PaInput"type=search required>'),on=E('<form class=PaSearchOpener><button class="PaSearchOpener-button PaButton"type=submit>');function an({searchURL:e,language:t}){const[r,o]=A(""),{t:n}=G(t),a=(()=>{var i=rn();return i.addEventListener("change",(c=>o(c.currentTarget.value))),K((()=>z(i,"placeholder",n("searchApp.search")))),K((()=>i.value=r())),i})(),s=i=>{i.preventDefault(),window.location.href=`${e}#/q/${encodeURIComponent(r())}`};return(()=>{var i=on(),c=i.firstChild;return i.addEventListener("submit",s),L(i,a,c),L(c,(()=>n("searchApp.search"))),i})()}var sn=E('<button class="PaSearchOpenerButton PaIconButton"type=button><svg class=PaSearchOpenerButton-svg width=20 height=20 version=1.1 xmlns=http://www.w3.org/2000/svg viewBox="0 0 490.4 490.4"><title>Mignifier</title><g id=SVGRepo_bgCarrier stroke-width=0></g><g id=SVGRepo_tracerCarrier stroke-linecap=round stroke-linejoin=round></g><g id=SVGRepo_iconCarrier><g><path d="M484.1,454.796l-110.5-110.6c29.8-36.3,47.6-82.8,47.6-133.4c0-116.3-94.3-210.6-210.6-210.6S0,94.496,0,210.796 s94.3,210.6,210.6,210.6c50.8,0,97.4-18,133.8-48l110.5,110.5c12.9,11.8,25,4.2,29.2,0C492.5,475.596,492.5,463.096,484.1,454.796z M41.1,210.796c0-93.6,75.9-169.5,169.5-169.5s169.6,75.9,169.6,169.5s-75.9,169.5-169.5,169.5S41.1,304.396,41.1,210.796z"></path> ');function cn({searchIconColor:e,language:t,searchURL:r}){const o=(()=>{var s=sn(),i=s.firstChild;return e!=null?i.style.setProperty("fill",e):i.style.removeProperty("fill"),s})(),n=S(an,{searchURL:r,language:t});return nn({openButton:o,dialogContent:n,modalClass:"_paSearchOpener"}).on("open",(()=>{n.querySelector("input")?.focus()})),o}function ln(e,{language:t}){const r=e.dataset.searchUrl,o=e.dataset.iconColor;if(!t)throw new Error("Missing language");if(!r)throw new Error("Missing search url");pe((()=>S(cn,{language:t,searchURL:r,searchIconColor:o})),e)}document.addEventListener("DOMContentLoaded",(()=>{const e=document.documentElement.lang,t={paSearchOpener:ln,paSearchApp:tn,paInfiniteLoading:pt},r=document.querySelectorAll("[data-effect]");for(const o of r){const n=o.dataset.effect;if(!n)continue;const a=t[n];a&&a(o,{language:e})}}));
1
+ import{delegateEvents as re,template as E,insert as L,setAttribute as z,isServer as T,getRequestEvent as Y,createComponent as S,memo as Z,effect as K,render as me}from"https://esm.sh/solid-js@1.9.7/web";import{createMemo as R,getOwner as ge,runWithOwner as we,useContext as ye,createContext as ve,createSignal as A,createRenderEffect as Ve,on as j,startTransition as He,resetErrorBoundaries as Ke,batch as ze,untrack as be,createComponent as Ge,children as Se,mergeProps as Je,Show as B,createRoot as Qe,onCleanup as $e,sharedConfig as J,createEffect as Pe}from"https://esm.sh/solid-js@1.9.7";function ee(e){return e.varName?` for '${e.varName}'`:""}function Xe(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function Ye(e,t={}){if(e==null||e===""&&!t.allowEmpty)throw new Error(`Missing string value${ee(t)}`);return typeof e=="string"?e:e.toString()}function k(e,t={}){return e==null||e===""&&!t.allowEmpty?void 0:Ye(e,t)}function Ze(e,t={}){if(typeof e=="number")return e;if(e==null)throw new Error(`Missing number value${ee(t)}`);if(typeof e=="string"&&Xe(e))return Number(e);throw new Error(`Cannot convert to number the value of type '${typeof e}'${ee(t)}`)}function V(e,t={}){return e==null?void 0:Ze(e,t)}function et(e){let t=e;const r=t.indexOf("?");r!==-1&&(t=t.substring(0,r));const o=t.indexOf("#");o!==-1&&(t=t.substring(0,o));const n=t.lastIndexOf("/");return n===-1?void 0:t.slice(0,n)}const Le="/api/plugin/content-loading",Ee=et(import.meta.url);async function tt(e){const t=`${Le}${e}`,r=await fetch(t);if(r.status!==200)throw new Error(`api error ${r.status}`);return await r.text()}function te(e){const t=document.createElement("div");return t.innerHTML=e,[...t.children]}const Re=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function Ae(e,t,r){for(const[o,n]of Object.entries(t)){const a=`${r}.${o}`;e[a]=n,Re(n)&&Ae(e,n,a)}}function nt(e){const t={...e};for(const[r,o]of Object.entries(e))Re(o)&&Ae(t,o,r);return t}const rt=(e,t)=>{if(t)for(const[r,o]of Object.entries(t))e=e.replace(new RegExp(`{{\\s*${r}\\s*}}`,"g"),o);return e},ot=e=>e;function at(e,t=ot){return(r,...o)=>{r[0]==="."&&(r=r.slice(1));const n=e()?.[r];switch(typeof n){case"function":return n(...o);case"string":return t(n,o[0]);default:return n}}}const st={nothingMessage:"No results found for",search:"Search"},it={loadMore:"Load more"},ct={searchApp:st,infiniteLoading:it},lt={nothingMessage:"Aucun résultat trouvé pour",search:"Rechercher"},ut={loadMore:"Charger la suite"},dt={searchApp:lt,infiniteLoading:ut},ue={en:ct,fr:dt};function G(e){const t=R((()=>{const o=e in ue?e:"en";return nt(ue[o])}));return{t:at(t,rt)}}var ft=E('<button class="PaInfiniteLoading-loadButton PaButton"type=button>'),ht=E("<div class=PaInfiniteLoading-loadMore>"),pt=E('<img class="PaInfiniteLoading-loading PaLoading"width=50 height=50 alt=…>');function mt(e,{language:t}){const r=V(e.dataset.start),o=V(e.dataset.total),n=V(e.dataset.limit),a=k(e.dataset.parentId),s=k(e.dataset.template),i=k(e.dataset.labeledById),c=k(e.dataset.labeledByField);if(!(r===void 0||o===void 0||a===void 0||n===void 0||s===void 0)){if(!t)throw new Error("Missing language");gt({language:t,limit:n,parentId:a,root:e,start:r,total:o,templateName:s,labeledBy:i!==void 0&&c?{termNodeId:i,fieldName:c}:void 0})}}function gt({language:e,limit:t,root:r,start:o,total:n,parentId:a,templateName:s,labeledBy:i}){const{t:c}=G(e);let l=o;if(l>=n)return;const f=(()=>{var m=ft();return m.$$click=p,L(m,(()=>c("infiniteLoading.loadMore"))),m})(),w=(()=>{var m=ht();return L(m,f),m})(),h=(()=>{var m=pt();return z(m,"src",`${Ee}/spinner.svg`),m})();r.appendChild(w);async function p(){r.appendChild(h);const m=await wt({limit:t,newStart:l,parentId:a,templateName:s,labeledBy:i});for(const u of m)r.insertBefore(u,w);l+=t,l>=n&&w.remove(),h.remove()}}async function wt({limit:e,newStart:t,parentId:r,templateName:o,labeledBy:n}){let a="";if(n){const c=encodeURIComponent(n.termNodeId),l=encodeURIComponent(n.fieldName);a=`&labeled-t=${c}&labeled-f=${l}`}const s=`/partials?template=${encodeURIComponent(o)}&children-of=${encodeURIComponent(r)}&start=${encodeURIComponent(t)}&limit=${encodeURIComponent(e)}${a}`,i=await tt(s);return te(i)}re(["click"]);function Ce(){let e=new Set;function t(n){return e.add(n),()=>e.delete(n)}let r=!1;function o(n,a){if(r)return!(r=!1);const s={to:n,options:a,defaultPrevented:!1,preventDefault:()=>s.defaultPrevented=!0};for(const i of e)i.listener({...s,from:i.location,retry:c=>{c&&(r=!0),i.navigate(n,{...a,resolve:!1})}});return!s.defaultPrevented}return{subscribe:t,confirm:o}}let ne;function oe(){(!window.history.state||window.history.state._depth==null)&&window.history.replaceState({...window.history.state,_depth:window.history.length-1},""),ne=window.history.state._depth}T||oe();function yt(e){return{...e,_depth:window.history.state&&window.history.state._depth}}function vt(e,t){let r=!1;return()=>{const o=ne;oe();const n=o==null?null:ne-o;if(r){r=!1;return}n&&t(n)?(r=!0,window.history.go(-n)):e()}}const bt=/^(?:[a-z0-9]+:)?\/\//i,St=/^\/+|(\/)\/+$/g,Ie="http://sr";function N(e,t=!1){const r=e.replace(St,"$1");return r?t||/^[?#]/.test(r)?r:"/"+r:""}function H(e,t,r){if(bt.test(t))return;const o=N(e),n=r&&N(r);let a="";return!n||t.startsWith("/")?a=o:n.toLowerCase().indexOf(o.toLowerCase())!==0?a=o+n:a=n,(a||"/")+N(t,!a)}function $t(e,t){if(e==null)throw new Error(t);return e}function Pt(e,t){return N(e).replace(/\/*(\*.*)?$/g,"")+N(t)}function _e(e){const t={};return e.searchParams.forEach(((r,o)=>{o in t?Array.isArray(t[o])?t[o].push(r):t[o]=[t[o],r]:t[o]=r})),t}function Lt(e,t,r){const[o,n]=e.split("/*",2),a=o.split("/").filter(Boolean),s=a.length;return i=>{const c=i.split("/").filter(Boolean),l=c.length-s;if(l<0||l>0&&n===void 0&&!t)return null;const f={path:s?"":"/",params:{}},w=h=>r===void 0?void 0:r[h];for(let h=0;h<s;h++){const p=a[h],m=p[0]===":",u=m?c[h]:c[h].toLowerCase(),d=m?p.slice(1):p.toLowerCase();if(m&&Q(u,w(d)))f.params[d]=u;else if(m||!Q(u,d))return null;f.path+=`/${u}`}if(n){const h=l?c.slice(-l).join("/"):"";if(Q(h,w(n)))f.params[n]=h;else return null}return f}}function Q(e,t){const r=o=>o===e;return t===void 0?!0:typeof t=="string"?r(t):typeof t=="function"?t(e):Array.isArray(t)?t.some(r):t instanceof RegExp?t.test(e):!1}function Et(e){const[t,r]=e.pattern.split("/*",2),o=t.split("/").filter(Boolean);return o.reduce(((n,a)=>n+(a.startsWith(":")?2:3)),o.length-(r===void 0?0:1))}function xe(e){const t=new Map,r=ge();return new Proxy({},{get(o,n){return t.has(n)||we(r,(()=>t.set(n,R((()=>e()[n]))))),t.get(n)()},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},ownKeys(){return Reflect.ownKeys(e())}})}function Oe(e){let t=/(\/?\:[^\/]+)\?/.exec(e);if(!t)return[e];let r=e.slice(0,t.index),o=e.slice(t.index+t[0].length);const n=[r,r+=t[1]];for(;t=/^(\/\:[^\/]+)\?/.exec(o);)n.push(r+=t[1]),o=o.slice(t[0].length);return Oe(o).reduce(((a,s)=>[...a,...n.map((i=>i+s))]),[])}const Rt=100,Ue=ve(),Me=ve(),ae=()=>$t(ye(Ue),"<A> and 'use' router primitives can be only used inside a Route."),Be=()=>ae().navigatorFactory(),At=()=>ae().location,Ct=()=>ae().params;function It(e,t=""){const{component:r,preload:o,load:n,children:a,info:s}=e,i=!a||Array.isArray(a)&&!a.length,c={key:e,component:r,preload:o||n,info:s};return Fe(e.path).reduce(((l,f)=>{for(const w of Oe(f)){const h=Pt(t,w);let p=i?h:h.split("/*",1)[0];p=p.split("/").map((m=>m.startsWith(":")||m.startsWith("*")?m:encodeURIComponent(m))).join("/"),l.push({...c,originalPath:f,pattern:p,matcher:Lt(p,!i,e.matchFilters)})}return l}),[])}function _t(e,t=0){return{routes:e,score:Et(e[e.length-1])*1e4-t,matcher(r){const o=[];for(let n=e.length-1;n>=0;n--){const a=e[n],s=a.matcher(r);if(!s)return null;o.unshift({...s,route:a})}return o}}}function Fe(e){return Array.isArray(e)?e:[e]}function ke(e,t="",r=[],o=[]){const n=Fe(e);for(let a=0,s=n.length;a<s;a++){const i=n[a];if(i&&typeof i=="object"){i.hasOwnProperty("path")||(i.path="");const c=It(i,t);for(const l of c){r.push(l);const f=Array.isArray(i.children)&&i.children.length===0;if(i.children&&!f)ke(i.children,l.pattern,r,o);else{const w=_t([...r],o.length);o.push(w)}r.pop()}}}return r.length?o:o.sort(((a,s)=>s.score-a.score))}function q(e,t){for(let r=0,o=e.length;r<o;r++){const n=e[r].matcher(t);if(n)return n}return[]}function xt(e,t,r){const o=new URL(Ie),n=R((f=>{const w=e();try{return new URL(w,o)}catch{return console.error(`Invalid path ${w}`),f}}),o,{equals:(f,w)=>f.href===w.href}),a=R((()=>n().pathname)),s=R((()=>n().search),!0),i=R((()=>n().hash)),c=()=>"",l=j(s,(()=>_e(n())));return{get pathname(){return a()},get search(){return s()},get hash(){return i()},get state(){return t()},get key(){return c()},query:r?r(l):xe(l)}}let _;function Ot(){return _}function Ut(e,t,r,o={}){const{signal:[n,a],utils:s={}}=e,i=s.parsePath||(g=>g),c=s.renderPath||(g=>g),l=s.beforeLeave||Ce(),f=H("",o.base||"");if(f===void 0)throw new Error(`${f} is not a valid base path`);f&&!n().value&&a({value:f,replace:!0,scroll:!1});const[w,h]=A(!1);let p;const m=(g,v)=>{v.value===u()&&v.state===y()||(p===void 0&&h(!0),_=g,p=v,He((()=>{p===v&&(d(p.value),b(p.state),Ke(),T||I[1]((P=>P.filter((x=>x.pending)))))})).finally((()=>{p===v&&ze((()=>{_=void 0,g==="navigate"&&je(p),h(!1),p=void 0}))})))},[u,d]=A(n().value),[y,b]=A(n().state),$=xt(u,y,s.queryWrapper),C=[],I=A(T?We():[]),F=R((()=>typeof o.transformUrl=="function"?q(t(),o.transformUrl($.pathname)):q(t(),$.pathname))),se=()=>{const g=F(),v={};for(let P=0;P<g.length;P++)Object.assign(v,g[P].params);return v},Te=s.paramsWrapper?s.paramsWrapper(se,t):xe(se),ie={pattern:f,path:()=>f,outlet:()=>null,resolvePath(g){return H(f,g)}};return Ve(j(n,(g=>m("native",g)),{defer:!0})),{base:ie,location:$,params:Te,isRouting:w,renderPath:c,parsePath:i,navigatorFactory:qe,matches:F,beforeLeave:l,preloadRoute:De,singleFlight:o.singleFlight===void 0?!0:o.singleFlight,submissions:I};function Ne(g,v,P){be((()=>{if(typeof v=="number"){v&&(s.go?s.go(v):console.warn("Router integration does not support relative routing"));return}const x=!v||v[0]==="?",{replace:D,resolve:O,scroll:W,state:U}={replace:!1,resolve:!x,scroll:!0,...P},M=O?g.resolvePath(v):H(x&&$.pathname||"",v);if(M===void 0)throw new Error(`Path '${v}' is not a routable path`);if(C.length>=Rt)throw new Error("Too many redirects");const ce=u();if(M!==ce||U!==y())if(T){const le=Y();le&&(le.response={status:302,headers:new Headers({Location:M})}),a({value:M,replace:D,scroll:W,state:U})}else l.confirm(M,P)&&(C.push({value:ce,replace:D,scroll:W,state:y()}),m("navigate",{value:M,state:U}))}))}function qe(g){return g=g||ye(Me)||ie,(v,P)=>Ne(g,v,P)}function je(g){const v=C[0];v&&(a({...g,replace:v.replace,scroll:v.scroll}),C.length=0)}function De(g,v){const P=q(t(),g.pathname),x=_;_="preload";for(let D in P){const{route:O,params:W}=P[D];O.component&&O.component.preload&&O.component.preload();const{preload:U}=O;v&&U&&we(r(),(()=>U({params:W,location:{pathname:g.pathname,search:g.search,hash:g.hash,query:_e(g),state:null,key:""},intent:"preload"})))}_=x}function We(){const g=Y();return g&&g.router&&g.router.submission?[g.router.submission]:[]}}function Mt(e,t,r,o){const{base:n,location:a,params:s}=e,{pattern:i,component:c,preload:l}=o().route,f=R((()=>o().path));c&&c.preload&&c.preload();const w=l?l({params:s,location:a,intent:_||"initial"}):void 0;return{parent:t,pattern:i,path:f,outlet:()=>c?Ge(c,{params:s,location:a,data:w,get children(){return r()}}):r(),resolvePath(p){return H(n.path(),p,f())}}}const Bt=e=>t=>{const{base:r}=t,o=Se((()=>t.children)),n=R((()=>ke(o(),t.base||"")));let a;const s=Ut(e,n,(()=>a),{base:r,singleFlight:t.singleFlight,transformUrl:t.transformUrl});return e.create&&e.create(s),S(Ue.Provider,{value:s,get children(){return S(Ft,{routerState:s,get root(){return t.root},get preload(){return t.rootPreload||t.rootLoad},get children(){return[Z((()=>(a=ge())&&null)),S(kt,{routerState:s,get branches(){return n()}})]}})}})};function Ft(e){const t=e.routerState.location,r=e.routerState.params,o=R((()=>e.preload&&be((()=>{e.preload({params:r,location:t,intent:Ot()||"initial"})}))));return S(B,{get when(){return e.root},keyed:!0,get fallback(){return e.children},children:n=>S(n,{params:r,location:t,get data(){return o()},get children(){return e.children}})})}function kt(e){if(T){const n=Y();if(n&&n.router&&n.router.dataOnly){Tt(n,e.routerState,e.branches);return}n&&((n.router||(n.router={})).matches||(n.router.matches=e.routerState.matches().map((({route:a,path:s,params:i})=>({path:a.originalPath,pattern:a.pattern,match:s,params:i,info:a.info})))))}const t=[];let r;const o=R(j(e.routerState.matches,((n,a,s)=>{let i=a&&n.length===a.length;const c=[];for(let l=0,f=n.length;l<f;l++){const w=a&&a[l],h=n[l];s&&w&&h.route.key===w.route.key?c[l]=s[l]:(i=!1,t[l]&&t[l](),Qe((p=>{t[l]=p,c[l]=Mt(e.routerState,c[l-1]||e.routerState.base,de((()=>o()[l+1])),(()=>e.routerState.matches()[l]))})))}return t.splice(n.length).forEach((l=>l())),s&&i?s:(r=c[0],c)})));return de((()=>o()&&r))()}const de=e=>()=>S(B,{get when(){return e()},keyed:!0,children:t=>S(Me.Provider,{value:t,get children(){return t.outlet()}})}),X=e=>{const t=Se((()=>e.children));return Je(e,{get children(){return t()}})};function Tt(e,t,r){const o=new URL(e.request.url),n=q(r,new URL(e.router.previousUrl||e.request.url).pathname),a=q(r,o.pathname);for(let s=0;s<a.length;s++){(!n[s]||a[s].route!==n[s].route)&&(e.router.dataOnly=!0);const{route:i,params:c}=a[s];i.preload&&i.preload({params:c,location:t.location,intent:"preload"})}}function Nt([e,t],r,o){return[e,o?n=>t(o(n)):t]}function qt(e){let t=!1;const r=n=>typeof n=="string"?{value:n}:n,o=Nt(A(r(e.get()),{equals:(n,a)=>n.value===a.value&&n.state===a.state}),void 0,(n=>(!t&&e.set(n),J.registry&&!J.done&&(J.done=!0),n)));return e.init&&$e(e.init(((n=e.get())=>{t=!0,o[1](r(n)),t=!1}))),Bt({signal:o,create:e.create,utils:e.utils})}function jt(e,t,r){return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}function Dt(e,t){const r=e&&document.getElementById(e);r?r.scrollIntoView():t&&window.scrollTo(0,0)}const Wt=new Map;function Vt(e=!0,t=!1,r="/_server",o){return n=>{const a=n.base.path(),s=n.navigatorFactory(n.base);let i,c;function l(u){return u.namespaceURI==="http://www.w3.org/2000/svg"}function f(u){if(u.defaultPrevented||u.button!==0||u.metaKey||u.altKey||u.ctrlKey||u.shiftKey)return;const d=u.composedPath().find((F=>F instanceof Node&&F.nodeName.toUpperCase()==="A"));if(!d||t&&!d.hasAttribute("link"))return;const y=l(d),b=y?d.href.baseVal:d.href;if((y?d.target.baseVal:d.target)||!b&&!d.hasAttribute("state"))return;const C=(d.getAttribute("rel")||"").split(/\s+/);if(d.hasAttribute("download")||C&&C.includes("external"))return;const I=y?new URL(b,document.baseURI):new URL(b);if(!(I.origin!==window.location.origin||a&&I.pathname&&!I.pathname.toLowerCase().startsWith(a.toLowerCase())))return[d,I]}function w(u){const d=f(u);if(!d)return;const[y,b]=d,$=n.parsePath(b.pathname+b.search+b.hash),C=y.getAttribute("state");u.preventDefault(),s($,{resolve:!1,replace:y.hasAttribute("replace"),scroll:!y.hasAttribute("noscroll"),state:C?JSON.parse(C):void 0})}function h(u){const d=f(u);if(!d)return;const[y,b]=d;n.preloadRoute(b,y.getAttribute("preload")!=="false")}function p(u){clearTimeout(i);const d=f(u);if(!d)return c=null;const[y,b]=d;c!==y&&(i=setTimeout((()=>{n.preloadRoute(b,y.getAttribute("preload")!=="false"),c=y}),20))}function m(u){if(u.defaultPrevented)return;let d=u.submitter&&u.submitter.hasAttribute("formaction")?u.submitter.getAttribute("formaction"):u.target.getAttribute("action");if(!d)return;if(!d.startsWith("https://action/")){const b=new URL(d,Ie);if(d=n.parsePath(b.pathname+b.search),!d.startsWith(r))return}if(u.target.method.toUpperCase()!=="POST")throw new Error("Only POST forms are supported for Actions");const y=Wt.get(d);if(y){u.preventDefault();const b=new FormData(u.target,u.submitter);y.call({r:n,f:u.target},u.target.enctype==="multipart/form-data"?b:new URLSearchParams(b))}}re(["click","submit"]),document.addEventListener("click",w),e&&(document.addEventListener("mousemove",p,{passive:!0}),document.addEventListener("focusin",h,{passive:!0}),document.addEventListener("touchstart",h,{passive:!0})),document.addEventListener("submit",m),$e((()=>{document.removeEventListener("click",w),e&&(document.removeEventListener("mousemove",p),document.removeEventListener("focusin",h),document.removeEventListener("touchstart",h)),document.removeEventListener("submit",m)}))}}function Ht(e){const t=e.replace(/^.*?#/,"");if(!t.startsWith("/")){const[,r="/"]=window.location.hash.split("#",2);return`${r}#${t}`}return t}function Kt(e){const t=()=>window.location.hash.slice(1),r=Ce();return qt({get:t,set({value:o,replace:n,scroll:a,state:s}){n?window.history.replaceState(yt(s),"","#"+o):window.history.pushState(s,"","#"+o);const i=o.indexOf("#"),c=i>=0?o.slice(i+1):"";Dt(c,a),oe()},init:o=>jt(window,"hashchange",vt(o,(n=>!r.confirm(n&&n<0?n:t())))),create:Vt(e.preload,e.explicitLinks,e.actionBase),utils:{go:o=>window.history.go(o),renderPath:o=>`#${o}`,parsePath:Ht,beforeLeave:r}})(e)}function zt(e){const t=Be(),r=At(),{href:o,state:n}=e,a=typeof o=="function"?o({navigate:t,location:r}):o;return t(a,{replace:!0,state:n}),null}async function fe({language:e,text:t,limit:r,start:o,templateName:n}){const a=`${Le}/search?language=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}&limit=${encodeURIComponent(r)}&start=${encodeURIComponent(o)}&tpl=${encodeURIComponent(n)}`,s=await fetch(a,{method:"GET"});if(s.status!==200){const c=await s.text();throw new Error(`API error (${s.status}): ${c}`)}return await s.json()}var Gt=E('<form class=PaSearchApp-form><input class="PaSearchApp-input PaInput"type=search><button class="PaSearchApp-searchButton PaButton"type=submit>');function Jt(e){const t=Be(),[r,o]=A(e.value??""),{t:n}=G(e.language);Pe(j((()=>e.value),(()=>o(e.value??""))));const a=async s=>{s.preventDefault(),t(`/q/${encodeURIComponent(r())}`)};return(()=>{var s=Gt(),i=s.firstChild,c=i.nextSibling;return s.addEventListener("submit",a),i.addEventListener("change",(l=>o(l.currentTarget.value))),L(c,(()=>n("searchApp.search"))),K((()=>z(i,"placeholder",n("searchApp.search")))),K((()=>i.value=r())),s})()}var Qt=E("<div class=PaSearchApp-loadMore>"),Xt=E("<div class=PaSearchApp-results>"),Yt=E("<div class=PaSearchApp>"),Zt=E("<div class=PaSearchApp-nothing> <span class=PaSearchApp-quote>"),en=E('<img class="PaSearchApp-loading PaLoading"width=80 height=80 alt=…>'),tn=E('<button class="PaSearchApp-loadButton PaButton"type=button>');function he({language:e,limit:t,templateName:r}){const{t:o}=G(e),n=Ct(),[a,s]=A([]),[i,c]=A(-1),[l,f]=A(0),[w,h]=A(!1);Pe(j((()=>n.searchString),p));async function p(){if(n.searchString){h(!0);try{s([]),f(0),c(-1);const u=await fe({language:e,text:decodeURIComponent(n.searchString),limit:t,start:l(),templateName:r});if(c(u.total),f(l()+t),!u.html)return;s(te(u.html))}finally{h(!1)}}}async function m(){if(!n.searchString)return;const u=i();if(!(u===-1||l()>=u)){h(!0);try{const d=await fe({language:e,text:decodeURIComponent(n.searchString),limit:t,start:l(),templateName:r});if(!d.html)return;s([...a(),...te(d.html)]),f(l()+t)}finally{h(!1)}}}return(()=>{var u=Yt();return L(u,S(Jt,{language:e,get value(){return Z((()=>!!n.searchString))()?decodeURIComponent(n.searchString):void 0}}),null),L(u,S(B,{get when(){return n.searchString},get children(){var d=Xt();return L(d,S(B,{get when(){return i()!==-1},get children(){return S(B,{get when(){return a().length>0},get fallback(){return(()=>{var y=Zt(),b=y.firstChild,$=b.nextSibling;return L(y,(()=>o("searchApp.nothingMessage")),b),L($,(()=>n.searchString)),y})()},get children(){return a()}})}}),null),L(d,S(B,{get when(){return i()===-1||w()||l()<i()},get children(){var y=Qt();return L(y,(()=>{var b=Z((()=>!!w()));return()=>b()?(()=>{var $=en();return z($,"src",`${Ee}/spinner.svg`),$})():(()=>{var $=tn();return $.$$click=m,L($,(()=>o("infiniteLoading.loadMore"))),$})()})()),y}}),null),d}}),null),u})()}re(["click"]);function nn(e,{language:t}){if(!t)throw new Error("Missing language");const r=V(e.dataset.limit),o=k(e.dataset.template);r===void 0||o===void 0||me((()=>S(Kt,{explicitLinks:!0,get children(){return[S(X,{path:"/",component:()=>S(zt,{href:"/q"})}),S(X,{path:"/q",component:()=>S(he,{language:t,templateName:o,limit:r})}),S(X,{path:"/q/:searchString",component:()=>S(he,{language:t,templateName:o,limit:r})})]}})),e)}function rn({openButton:e,dialogContent:t,modalClass:r}){const o=e?typeof e=="string"?document.querySelector(e):e:void 0,n=typeof t=="string"?document.querySelector(t):t;if(!n)return;n instanceof HTMLTemplateElement||n.classList.remove("TinyModalHidden");const a=document.createElement("dialog");a.classList.add("TinyModal"),a.classList.add(r);const s=document.createElement("button");s.classList.add("TinyModal-closeButton"),a.appendChild(s);const i=document.createElement("div");i.classList.add("TinyModal-body"),i.appendChild(n instanceof HTMLTemplateElement?n.content.cloneNode(!0):n),a.appendChild(i),document.body.appendChild(a);const c=new Map;function l(p,m){c.has(p)||c.set(p,[]),c.get(p)?.push(m)}function f(p){c.has(p)&&c.get(p)?.forEach((m=>m()))}function w(){a.showModal(),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",f("open")}function h(){a.close()}return o?.addEventListener("click",w),s.addEventListener("click",h),a.addEventListener("close",(()=>{document.body.style.removeProperty("overflow"),document.documentElement.style.removeProperty("overflow"),f("close")})),{open:w,close:h,on:l}}var on=E('<input class="PaSearchOpener-input PaInput"type=search required>'),an=E('<form class=PaSearchOpener><button class="PaSearchOpener-button PaButton"type=submit>');function sn({searchURL:e,language:t}){const[r,o]=A(""),{t:n}=G(t),a=(()=>{var i=on();return i.addEventListener("change",(c=>o(c.currentTarget.value))),K((()=>z(i,"placeholder",n("searchApp.search")))),K((()=>i.value=r())),i})(),s=i=>{i.preventDefault(),window.location.href=`${e}#/q/${encodeURIComponent(r())}`};return(()=>{var i=an(),c=i.firstChild;return i.addEventListener("submit",s),L(i,a,c),L(c,(()=>n("searchApp.search"))),i})()}var cn=E('<button class="PaSearchOpenerButton PaIconButton"type=button><svg class=PaSearchOpenerButton-svg width=20 height=20 version=1.1 xmlns=http://www.w3.org/2000/svg viewBox="0 0 490.4 490.4"><title>Mignifier</title><g id=SVGRepo_bgCarrier stroke-width=0></g><g id=SVGRepo_tracerCarrier stroke-linecap=round stroke-linejoin=round></g><g id=SVGRepo_iconCarrier><g><path d="M484.1,454.796l-110.5-110.6c29.8-36.3,47.6-82.8,47.6-133.4c0-116.3-94.3-210.6-210.6-210.6S0,94.496,0,210.796 s94.3,210.6,210.6,210.6c50.8,0,97.4-18,133.8-48l110.5,110.5c12.9,11.8,25,4.2,29.2,0C492.5,475.596,492.5,463.096,484.1,454.796z M41.1,210.796c0-93.6,75.9-169.5,169.5-169.5s169.6,75.9,169.6,169.5s-75.9,169.5-169.5,169.5S41.1,304.396,41.1,210.796z"></path> ');function ln({searchIconColor:e,language:t,searchURL:r}){const o=(()=>{var s=cn(),i=s.firstChild;return e!=null?i.style.setProperty("fill",e):i.style.removeProperty("fill"),s})(),n=S(sn,{searchURL:r,language:t});return rn({openButton:o,dialogContent:n,modalClass:"_paSearchOpener"}).on("open",(()=>{n.querySelector("input")?.focus()})),o}function un(e,{language:t}){const r=e.dataset.searchUrl,o=e.dataset.iconColor;if(!t)throw new Error("Missing language");if(!r)throw new Error("Missing search url");me((()=>S(ln,{language:t,searchURL:r,searchIconColor:o})),e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",pe):pe();function pe(){const e=document.documentElement.lang,t={paSearchOpener:un,paSearchApp:nn,paInfiniteLoading:mt},r=document.querySelectorAll("[data-effect]");for(const o of r){const n=o.dataset.effect;if(!n)continue;const a=t[n];a&&a(o,{language:e})}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/content-loading-plugin",
3
- "version": "0.18.1",
3
+ "version": "0.20.0",
4
4
  "description": "Content loading plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
@@ -16,14 +16,14 @@
16
16
  "author": "Paroi Team",
17
17
  "license": "MIT",
18
18
  "scripts": {
19
- "dev:public": "(cd public-front && vite)",
19
+ "dev:public": "(cd frontend && vite)",
20
20
  "build": "npm run build:backend && npm run build:public",
21
21
  "build:backend": "(cd backend && tsc)",
22
22
  "build:backend:watch": "(cd backend && tsc --watch --preserveWatchOutput)",
23
- "build:public": "(cd public-front && tsc && vite build && npm run minify:public)",
24
- "minify:public": "terser public-front/dist/public-front-plugin.mjs --output public-front/dist/public-front-plugin.mjs",
25
- "build:public:watch": "(cd public-front && tsc && vite build --watch)",
26
- "clear": "rimraf backend/dist/* public-front/dist/*"
23
+ "build:public": "(cd frontend && tsc && vite build && npm run minify:public)",
24
+ "minify:public": "terser frontend/dist/content-loading-plugin.mjs --output frontend/dist/content-loading-plugin.mjs",
25
+ "build:public:watch": "(cd frontend && tsc && vite build --watch)",
26
+ "clear": "rimraf backend/dist/* frontend/dist/*"
27
27
  },
28
28
  "dependencies": {
29
29
  "@paroi/data-formatters-lib": "~0.4.0"
@@ -33,8 +33,8 @@
33
33
  "@paroicms/public-server-lib": "0"
34
34
  },
35
35
  "devDependencies": {
36
- "@paroicms/public-anywhere-lib": "0.23.1",
37
- "@paroicms/public-server-lib": "0.34.1",
36
+ "@paroicms/public-anywhere-lib": "0.24.0",
37
+ "@paroicms/public-server-lib": "0.36.0",
38
38
  "@paroicms/tiny-modal": "0.5.2",
39
39
  "@solid-primitives/i18n": "~2.2.1",
40
40
  "@solidjs/router": "~0.15.3",
@@ -52,6 +52,6 @@
52
52
  "main": "backend/dist/plugin.js",
53
53
  "files": [
54
54
  "backend/dist",
55
- "public-front/dist"
55
+ "frontend/dist"
56
56
  ]
57
57
  }
@@ -1 +0,0 @@
1
- @import"https://cdn.jsdelivr.net/npm/@paroicms/tiny-modal@0.4.1/dist/tiny-modal.css";.PaSearchApp-form{display:flex;justify-content:center;margin-bottom:20px}.PaSearchOpenerButton{cursor:pointer}.PaSearchOpenerButton-svg{fill:var(--paInteractiveColor, #000)}.PaSearchOpener{box-sizing:border-box;display:flex;gap:20px;justify-content:center;flex-direction:column;align-items:center;max-width:500px;padding:30px 5px;width:85vw}.PaSearchOpener-input{border:1px solid transparent;font-size:1.2rem;padding:10px;width:100%}.PaSearchOpener-button{cursor:pointer;padding:20px 25px}
File without changes