@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 9.12 kB
JavaScript
import{copy as e}from"../i18n/copy.mjs";import t from"../../constants/constants.mjs";import n from"../../utils/helpers/get-dir-name.mjs";import r from"node:fs/promises";import{join as i}from"node:path";const a=n(import.meta.url),o=async n=>{try{let e=i(a,`../../../`,t.directories.viteBuild),o=i(e,`index.html`),s=i(n.outDir,`index.html`);try{await r.access(o)}catch{throw Error(`Lucid SPA build artifact is missing at ${o}. Build /admin before preparing Lucid assets, or ensure /core includes its spa directory.`)}await r.cp(e,n.outDir,{recursive:!0}),await r.mkdir(i(n.outDir,t.directories.plugins),{recursive:!0}),await r.writeFile(i(n.outDir,t.directories.plugins,`test-component.js`),`const M=(e,t)=>e===t,N={equals:M};let q=k;const y=1,w=2,G={};var p=null;let P=null,R=null,c=null,a=null,d=null,E=0;function F(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},N,t):N).equals||void 0};return[Q.bind(n),e=>("function"==typeof e&&(e=e(n.value)),L(n,e))]}function $(e,t,n){_(X(e,t,!1,y))}function H(e){if(null===c)return e();const t=c;c=null;try{return e()}finally{c=t}}function Q(){if(this.sources&&this.state)if(this.state===y)_(this);else{const e=a;a=null,m((()=>S(this))),a=e}if(c){const e=this.observers?this.observers.length:0;c.sources?(c.sources.push(this),c.sourceSlots.push(e)):(c.sources=[this],c.sourceSlots=[e]),this.observers?(this.observers.push(c),this.observerSlots.push(c.sources.length-1)):(this.observers=[c],this.observerSlots=[c.sources.length-1])}return this.value}function L(e,t,n){let r=e.value;return(!e.comparator||!e.comparator(r,t))&&(e.value=t,e.observers&&e.observers.length&&m((()=>{for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t],r=P&&P.running;r&&P.disposed.has(n),(r?!n.tState:!n.state)&&(n.pure?a.push(n):d.push(n),n.observers&&I(n)),r||(n.state=y)}if(a.length>1e6)throw a=[],new Error}))),t}function _(e){if(!e.fn)return;x(e);const t=E;W(e,e.value,t)}function W(e,t,n){let r;const o=p,s=c;c=p=e;try{r=e.fn(t)}catch(t){return e.pure&&(e.state=y,e.owned&&e.owned.forEach(x),e.owned=null),e.updatedAt=n+1,V(t)}finally{c=s,p=o}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?L(e,r):e.value=r,e.updatedAt=n)}function X(e,t,n,r=y,o){const s={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:p,context:p?p.context:null,pure:n};return null===p||p!==G&&(p.owned?p.owned.push(s):p.owned=[s]),s}function U(e){if(0===e.state)return;if(e.state===w)return S(e);if(e.suspense&&H(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<E);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if((e=t[n]).state===y)_(e);else if(e.state===w){const n=a;a=null,m((()=>S(e,t[0]))),a=n}}function m(e,t){if(a)return e();let n=!1;a=[],d?n=!0:d=[],E++;try{const t=e();return J(n),t}catch(e){n||(d=null),a=null,V(e)}}function J(e){if(a&&(k(a),a=null),e)return;const t=d;d=null,t.length&&m((()=>q(t)))}function k(e){for(let t=0;t<e.length;t++)U(e[t])}function S(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];if(r.sources){const e=r.state;e===y?r!==t&&(!r.updatedAt||r.updatedAt<E)&&U(r):e===w&&S(r,t)}}}function I(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=w,n.pure?a.push(n):d.push(n),n.observers&&I(n))}}function x(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)x(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)x(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function K(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}function V(e,t=p){throw K(e)}function Y(e,t,n){let r=n.length,o=t.length,s=r,l=0,i=0,u=t[o-1].nextSibling,c=null;for(;l<o||i<s;)if(t[l]!==n[i]){for(;t[o-1]===n[s-1];)o--,s--;if(o===l){const t=s<r?i?n[i-1].nextSibling:n[s-i]:u;for(;i<s;)e.insertBefore(n[i++],t)}else if(s===i)for(;l<o;)(!c||!c.has(t[l]))&&t[l].remove(),l++;else if(t[l]===n[s-1]&&n[i]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[i++],t[l++].nextSibling),e.insertBefore(n[--s],r),t[o]=n[s]}else{if(!c){c=new Map;let e=i;for(;e<s;)c.set(n[e],e++)}const r=c.get(t[l]);if(null!=r)if(i<r&&r<s){let u,a=l,f=1;for(;++a<o&&a<s&&null!=(u=c.get(t[a]))&&u===r+f;)f++;if(f>r-i){const o=t[l];for(;i<r;)e.insertBefore(n[i++],o)}else e.replaceChild(n[i++],t[l++])}else l++;else t[l++].remove()}}else l++,i++}const O="_$DX_DELEGATE";function Z(e,t,n,r){let o;const s=()=>(o||(o=(()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild})())).cloneNode(!0);return s.cloneNode=s,s}function z(e,t=window.document){const n=t[O]||(t[O]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,ee))}}function B(e,t,n,r){if(void 0!==n&&!r&&(r=[]),"function"!=typeof t)return A(e,t,r,n);$((r=>A(e,t(),r,n)),r)}function ee(e){let t=e.target;const n=e.type,r=e.target,o=e.currentTarget,s=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),l=()=>{const r=t[n];if(r&&!t.disabled){const o=t[n+"Data"];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&s(t.host),!0},i=()=>{for(;l()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();s(n[0]);for(let e=0;e<n.length-2&&(t=n[e],l());e++){if(t._$host){t=t._$host,i();break}if(t.parentNode===o)break}}else i();s(r)}function A(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const s=typeof t,l=void 0!==r;if(e=l&&n[0]&&n[0].parentNode||e,"string"===s||"number"===s){if("number"===s&&(t=t.toString())===n)return n;if(l){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=b(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===s)n=b(e,n,r);else{if("function"===s)return $((()=>{let o=t();for(;"function"==typeof o;)o=o();n=A(e,o,n,r)})),()=>n;if(Array.isArray(t)){const s=[],i=n&&Array.isArray(n);if(__solidSpreadInsert(undefined, s,t,n,o))return $((()=>n=A(e,s,n,r,!0))),()=>n;if(0===s.length){if(n=b(e,n,r),l)return n}else i?0===n.length?D(e,s,r):Y(e,n,s):(n&&b(e),D(e,s));n=s}else if(t.nodeType){if(Array.isArray(n)){if(l)return n=b(e,n,r,t);b(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function __solidSpreadInsert(undefined, e,t,n,r){let o=!1;for(let s=0,l=t.length;s<l;s++){let l,i=t[s],u=n&&n[e.length];if(null!=i&&!0!==i&&!1!==i)if("object"==(l=typeof i)&&i.nodeType)e.push(i);else if(Array.isArray(i))o=__solidSpreadInsert(undefined, e,i,u)||o;else if("function"===l)if(r){for(;"function"==typeof i;)i=i();o=__solidSpreadInsert(undefined, e,Array.isArray(i)?i:[i],Array.isArray(u)?u:[u])||o}else e.push(i),o=!0;else{const t=String(i);u&&3===u.nodeType&&u.data===t?e.push(u):e.push(document.createTextNode(t))}}return o}function D(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function b(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let s=t.length-1;s>=0;s--){const l=t[s];if(o!==l){const t=l.parentNode===e;r||s?t&&l.remove():t?e.replaceChild(o,l):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}var te=Z("<div><h3>Runtime Loaded Plugin</h3><p>This component was loaded dynamically at runtime!</p><p>Prop received: <strong></strong></p><button>Clicked <!> times");const se=e=>{const[t,n]=F(0);return r=te(),o=r.firstChild,s=o.nextSibling,l=s.nextSibling,i=l.firstChild.nextSibling,u=l.nextSibling,(c=u.firstChild.nextSibling).nextSibling,r.style.setProperty("padding","20px"),r.style.setProperty("border","2px solid #3b82f6"),r.style.setProperty("border-radius","8px"),r.style.setProperty("background-color","#eff6ff"),o.style.setProperty("margin","0 0 10px 0"),o.style.setProperty("color","#1e40af"),s.style.setProperty("margin","0 0 10px 0"),l.style.setProperty("margin","0 0 10px 0"),B(i,(()=>(null==e?void 0:e.message)||"No message")),u.$$click=()=>n(t()+1),u.style.setProperty("padding","8px 16px"),u.style.setProperty("background-color","#3b82f6"),u.style.setProperty("color","white"),u.style.setProperty("border","none"),u.style.setProperty("border-radius","4px"),u.style.setProperty("cursor","pointer"),B(u,t,c),r;var r,o,s,l,i,u,c};z(["click"]);export{se as default};`);try{await r.access(s)}catch{throw Error(`Lucid SPA index.html was not copied to ${s}.`)}return{data:void 0,error:void 0}}catch(t){return{data:void 0,error:{message:e(`server:core.build.vite.error.message`,t instanceof Error?{defaultMessage:t.message}:void 0)}}}};export{o as default};
//# sourceMappingURL=prepare-lucid-spa.mjs.map