@rip-lang/ui 0.3.18 → 0.3.19

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.
@@ -517,8 +517,8 @@ if (typeof globalThis !== 'undefined') {
517
517
  `:"",$=U.slice(0,u).join(`
518
518
  `)}let Y=new p().tokenize($);if(this.options.showTokens)Y.forEach((X)=>console.log(`${X[0].padEnd(12)} ${JSON.stringify(X[1])}`)),console.log();let F=null,Z=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)Z=[...Y];Y=Y.filter((X)=>X[0]!=="TYPE_DECL");while(Y.length>0&&Y[0][0]==="TERMINATOR")Y.shift();if(Y.every((X)=>X[0]==="TERMINATOR")){if(Z)F=N1(Z,["program"]);return{tokens:Y,sexpr:["program"],code:"",dts:F,data:A,reactiveVars:{}}}s.lexer={tokens:Y,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let X=this.tokens[this.pos++],z=X[1];if(X.data)z=new String(z),Object.assign(z,X.data);return this.text=z,this.loc=X.loc,X[0]}};let Q;try{Q=s.parse($)}catch(X){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test($)||/\?\s+\w+\s+\?\s+/.test($))throw Error("Nested ternary operators are not supported. Use if/else statements instead.");throw X}if(this.options.showSExpr)console.log(x(Q,0,!0)),console.log();let R=null;if(this.options.sourceMap){let X=(this.options.filename||"output")+".js",z=this.options.filename||"input.rip";R=new h1(X,z,$)}let w=new y({dataSection:A,skipPreamble:this.options.skipPreamble,reactiveVars:this.options.reactiveVars,sourceMap:R}),K=w.compile(Q),_=R?R.toJSON():null,J=R?R.toReverseMap():null;if(_&&this.options.sourceMap==="inline"){let X=typeof Buffer<"u"?Buffer.from(_).toString("base64"):btoa(_);K+=`
519
519
  //# sourceMappingURL=data:application/json;base64,${X}`}else if(_&&this.options.filename)K+=`
520
- //# sourceMappingURL=${this.options.filename}.js.map`;if(Z)F=N1(Z,Q);return{tokens:Y,sexpr:Q,code:K,dts:F,map:_,reverseMap:J,data:A,reactiveVars:w.reactiveVars}}compileToJS($){return this.compile($).code}compileToSExpr($){return this.compile($).sexpr}}D2(y,p);y.prototype.generateEnum=t1;function C1($,W={}){return new w1(W).compile($)}function r($,W={}){return new w1(W).compileToJS($)}function z1(){return new y({}).getReactiveRuntime()}function y1(){return new y({}).getComponentRuntime()}var V3="3.10.9",j3="2026-02-20@07:22:34GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(z1())();var h3=($)=>{let W=$.match(/^[ \t]*(?=\S)/gm),A=Math.min(...(W||[]).map((U)=>U.length));return $.replace(RegExp(`^[ ]{${A}}`,"gm"),"").trim()};async function C3(){let $=document.querySelectorAll('script[type="text/rip"]');for(let W of $){if(W.hasAttribute("data-rip-processed"))continue;if(W.hasAttribute("data-name"))continue;try{let A;if(W.src){let u=await fetch(W.src);if(!u.ok){console.error(`Rip: failed to fetch ${W.src} (${u.status})`);continue}A=await u.text()}else A=h3(W.textContent);let U;try{U=r(A)}catch(u){console.error("Rip compile error:",u.message),console.error("Source:",A);continue}await(0,eval)(`(async()=>{
520
+ //# sourceMappingURL=${this.options.filename}.js.map`;if(Z)F=N1(Z,Q);return{tokens:Y,sexpr:Q,code:K,dts:F,map:_,reverseMap:J,data:A,reactiveVars:w.reactiveVars}}compileToJS($){return this.compile($).code}compileToSExpr($){return this.compile($).sexpr}}D2(y,p);y.prototype.generateEnum=t1;function C1($,W={}){return new w1(W).compile($)}function r($,W={}){return new w1(W).compileToJS($)}function z1(){return new y({}).getReactiveRuntime()}function y1(){return new y({}).getComponentRuntime()}var V3="3.10.10",j3="2026-02-20@07:26:03GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(z1())();var h3=($)=>{let W=$.match(/^[ \t]*(?=\S)/gm),A=Math.min(...(W||[]).map((U)=>U.length));return $.replace(RegExp(`^[ ]{${A}}`,"gm"),"").trim()};async function C3(){let $=document.querySelectorAll('script[type="text/rip"]');for(let W of $){if(W.hasAttribute("data-rip-processed"))continue;if(W.hasAttribute("data-name"))continue;try{let A;if(W.src){let u=await fetch(W.src);if(!u.ok){console.error(`Rip: failed to fetch ${W.src} (${u.status})`);continue}A=await u.text()}else A=h3(W.textContent);let U;try{U=r(A)}catch(u){console.error("Rip compile error:",u.message),console.error("Source:",A);continue}await(0,eval)(`(async()=>{
521
521
  ${U}
522
522
  })()`),W.setAttribute("data-rip-processed","true")}catch(A){console.error("Rip runtime error:",A)}}}async function e($){for(let[f,Y]of Object.entries(e.modules))if($.includes(f))return Y;let W=await fetch($).then((f)=>{if(!f.ok)throw Error(`importRip: ${$} (${f.status})`);return f.text()}),A=r(W),U=new Blob([A],{type:"application/javascript"}),u=URL.createObjectURL(U);try{return await import(u)}finally{URL.revokeObjectURL(u)}}e.modules={};function y3($){try{let W=$.replace(/^/gm," "),U=r(`do ->
523
- ${W}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let u=(0,eval)(U);if(u&&typeof u.then==="function")return u.then((f)=>{if(f!==void 0)globalThis._=f;return f});if(u!==void 0)globalThis._=u;return u}catch(W){console.error("Rip compilation error:",W.message);return}}if(typeof globalThis<"u")globalThis.rip=y3,globalThis.importRip=e,globalThis.compileToJS=r,globalThis.__ripExports={compile:C1,compileToJS:r,formatSExpr:x,VERSION:V3,BUILD_DATE:j3,getReactiveRuntime:z1,getComponentRuntime:y1};async function b3(){if(globalThis.__ripLaunched)return;let $=e.modules?.["ui.rip"];if(!$?.launch)return;let W=document.querySelector("script[data-hash], script[data-url]"),A=W?.getAttribute("data-url")||"";if(!(document.querySelectorAll('script[type="text/rip"][data-name]').length>0)&&!A)return;let u={};if(W?.hasAttribute("data-hash"))u.hash=W.getAttribute("data-hash")!=="false";await $.launch(A,u)}if(typeof document<"u")globalThis.__ripScriptsReady=new Promise(($)=>{let W=()=>C3().then(b3).then($);if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>queueMicrotask(W));else queueMicrotask(W)});var n1={};x2(n1,{throttle:()=>x3,stash:()=>j2,setContext:()=>T2,raw:()=>h2,launch:()=>k3,isStash:()=>c3,hold:()=>l3,hasContext:()=>I2,getContext:()=>G2,delay:()=>C2,debounce:()=>g3,createRouter:()=>b2,createResource:()=>v3,createRenderer:()=>c2,createComponents:()=>y2});var M2,g1,u1,k,O1,w2,o,j,b1,F1,Z1,x1,z2,H2,H1,q1,q2,O2,P2,c1,v1,G2,E2,l1,I2,Y1,k1,B2,N2,T2,S2,L2,m1,V2;({__state:j,__effect:o,__batch:w2}=globalThis.__rip);({setContext:T2,getContext:G2,hasContext:I2}=globalThis.__ripComponent||{});O1=Symbol("stash");k=Symbol("signals");u1=Symbol("raw");g1=new WeakMap;b1=0;x1=j(0);l1=function($,W){let A;if(!$[k])Object.defineProperty($,k,{value:new Map,enumerable:!1});if(A=$[k].get(W),!A)A=j($[W]),$[k].set(W,A);return A};Y1=function($){return l1($,Symbol.for("keys"))};V2=function($){let W;if(!($!=null&&typeof $==="object"))return $;if($[O1])return $;if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Promise)return $;if(W=g1.get($),W)return W;return k1($)};k1=function($){let W,A;return A=null,W={get:function(U,u){let f,Y;if(u===O1)return!0;if(u===u1)return U;if(typeof u==="symbol")return Reflect.get(U,u);if(u==="length"&&Array.isArray(U))return Y1(U).value,U.length;if(u==="get")return function(F){return S2(A,F)};if(u==="set")return function(F,Z){return L2(A,F,Z)};if(f=l1(U,u),Y=f.value,Y!=null&&typeof Y==="object")return V2(Y);return Y},set:function(U,u,f){let Y,F;if(Y=U[u],F=f?.[u1]?f[u1]:f,F===Y)return!0;if(U[u]=F,U[k]?.has(u))U[k].get(u).value=F;if(Y===void 0&&F!==void 0)Y1(U).value=++b1;return x1.value++,!0},deleteProperty:function(U,u){let f;if(delete U[u],f=U[k]?.get(u),f)f.value=void 0;return Y1(U).value=++b1,!0},ownKeys:function(U){return Y1(U).value,Reflect.ownKeys(U)}},A=new Proxy($,W),g1.set($,A),A};M2=/([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;m1=function($){let W,A,U,u,f;U=("."+$).split(M2),U.shift(),f=[],A=0;while(A<U.length){if(u=U[A],W=u[0],W==="."||W==="/")f.push(u.slice(1));else if(W==="[")if(u[1]==='"'||u[1]==="'")f.push(u.slice(2,-2));else f.push(+u.slice(1,-1));A+=2}return f};S2=function($,W){let A,U;U=m1(W),A=$;for(let u of U){if(A==null)return;A=A[u]}return A};L2=function($,W,A){let U,u;u=m1(W),U=$;for(let f=0;f<u.length;f++){let Y=u[f];if(f===u.length-1)U[Y]=A;else{if(U[Y]==null)U[Y]={};U=U[Y]}}return A};Z1=function($){return typeof $==="function"?$:function(){return $.value}};F1=function($,W){let A;return A={read:function(){return $.read()}},Object.defineProperty(A,"value",{get:function(){return $.value},set:function(U){return W.value=U}}),A};P2=function($){let W;if(W=$.replace(/\.rip$/,""),W=W.replace(/\[\.\.\.(\w+)\]/g,"*$1"),W=W.replace(/\[(\w+)\]/g,":$1"),W==="index")return"/";return W=W.replace(/\/index$/,""),"/"+W};N2=function($){let W,A;return W=[],A=$.replace(/\*(\w+)/g,function(U,u){return W.push(u),"(.+)"}).replace(/:(\w+)/g,function(U,u){return W.push(u),"([^/]+)"}),{regex:new RegExp("^"+A+"$"),names:W}};B2=function($,W){let A,U;for(let u of W)if(A=$.match(u.regex.regex),A){U={};for(let f=0;f<u.regex.names.length;f++){let Y=u.regex.names[f];U[Y]=decodeURIComponent(A[f+1])}return{route:u,params:U}}return null};H1=function($,W="components"){let A,U,u,f,Y,F,Z,Q,R;Z=[],u=new Map,A=$.listAll(W);for(let w of A){if(F=w.slice(W.length+1),!F.endsWith(".rip"))continue;if(f=F.split("/").pop(),f==="_layout.rip"){U=F==="_layout.rip"?"":F.slice(0,-12),u.set(U,w);continue}if(f.startsWith("_"))continue;if(Q=F.split("/"),Q.length>1&&Q.some(function(K,_){return _<Q.length-1&&K.startsWith("_")}))continue;R=P2(F),Y=N2(R),Z.push({pattern:R,regex:Y,file:w,rel:F})}return Z.sort(function(w,K){let _,J,X,z;if(J=(w.pattern.match(/:/g)||[]).length,z=(K.pattern.match(/:/g)||[]).length,_=w.pattern.includes("*")?1:0,X=K.pattern.includes("*")?1:0,_!==X)return _-X;if(J!==z)return J-z;return w.pattern.localeCompare(K.pattern)}),{routes:Z,layouts:u}};E2=function($,W,A){let U,u,f,Y;if(U=[],f=$.slice(W.length+1),Y=f.split("/"),u="",A.has(""))U.push(A.get(""));for(let F=0;F<Y.length;F++){let Z=Y[F];if(F===Y.length-1)break;if(u=u?u+"/"+Z:Z,A.has(u))U.push(A.get(u))}return U};z2=function($,W){if($.length!==W.length)return!1;for(let A=0;A<$.length;A++)if($[A]!==W[A])return!1;return!0};v1=function($){for(let W in $){let A=$[W];if(typeof A==="function"&&(A.prototype?.mount||A.prototype?._create))return A}return typeof $.default==="function"?$.default:void 0};c1=function($){let W;W={};for(let A in $){let U=$[A];if(typeof U==="function"&&(U.prototype?.mount||U.prototype?._create))W[A]=U}return W};O2=function($){let W;return W=$.split("/").pop().replace(/\.rip$/,""),W.replace(/(^|[-_])([a-z])/g,function(A,U,u){return u.toUpperCase()})};H2=function($,W="components"){let A,U,u;U={};for(let f of $.listAll(W)){if(!f.endsWith(".rip"))continue;if(A=f.split("/").pop(),A.startsWith("_"))continue;if(u=O2(f),U[u])console.warn(`[Rip] Component name collision: ${u} (${U[u]} vs ${f})`);U[u]=f}return U};q1=async function($,W,A=null,U=null,u=null){let f,Y,F,Z,Q,R,w,K,_,J,X;if(A&&U){if(Y=A.getCompiled(U),Y)return Y}if(R=W($),u){_={};for(let z in u.map){let M=u.map[z];if(M!==U&&R.includes(`new ${z}(`)){if(!u.classes[z]){if(Z=A.read(M),Z){F=await q1(Z,W,A,M,u),Q=c1(F);for(let O in Q){let P=Q[O];u.classes[O]=P}}}if(u.classes[z])_[z]=!0}}if(K=Object.keys(_),K.length>0)J=`const {${K.join(", ")}} = globalThis['${u.key}'];
523
+ ${W}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let u=(0,eval)(U);if(u&&typeof u.then==="function")return u.then((f)=>{if(f!==void 0)globalThis._=f;return f});if(u!==void 0)globalThis._=u;return u}catch(W){console.error("Rip compilation error:",W.message);return}}if(typeof globalThis<"u")globalThis.rip=y3,globalThis.importRip=e,globalThis.compileToJS=r,globalThis.__ripExports={compile:C1,compileToJS:r,formatSExpr:x,VERSION:V3,BUILD_DATE:j3,getReactiveRuntime:z1,getComponentRuntime:y1};async function b3(){if(globalThis.__ripLaunched)return;let $=e.modules?.["ui.rip"];if(!$?.launch)return;let W=document.querySelector("script[data-hash], script[data-url]"),A=W?.getAttribute("data-url")||"";if(!(document.querySelectorAll('script[type="text/rip"][data-name]').length>0)&&!A)return;let f={hash:W?.getAttribute("data-hash")!=="false"};await $.launch(A,f)}if(typeof document<"u")globalThis.__ripScriptsReady=new Promise(($)=>{let W=()=>C3().then(b3).then($);if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>queueMicrotask(W));else queueMicrotask(W)});var n1={};x2(n1,{throttle:()=>x3,stash:()=>j2,setContext:()=>T2,raw:()=>h2,launch:()=>k3,isStash:()=>c3,hold:()=>l3,hasContext:()=>I2,getContext:()=>G2,delay:()=>C2,debounce:()=>g3,createRouter:()=>b2,createResource:()=>v3,createRenderer:()=>c2,createComponents:()=>y2});var M2,g1,u1,k,O1,w2,o,j,b1,F1,Z1,x1,z2,H2,H1,q1,q2,O2,P2,c1,v1,G2,E2,l1,I2,Y1,k1,B2,N2,T2,S2,L2,m1,V2;({__state:j,__effect:o,__batch:w2}=globalThis.__rip);({setContext:T2,getContext:G2,hasContext:I2}=globalThis.__ripComponent||{});O1=Symbol("stash");k=Symbol("signals");u1=Symbol("raw");g1=new WeakMap;b1=0;x1=j(0);l1=function($,W){let A;if(!$[k])Object.defineProperty($,k,{value:new Map,enumerable:!1});if(A=$[k].get(W),!A)A=j($[W]),$[k].set(W,A);return A};Y1=function($){return l1($,Symbol.for("keys"))};V2=function($){let W;if(!($!=null&&typeof $==="object"))return $;if($[O1])return $;if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Promise)return $;if(W=g1.get($),W)return W;return k1($)};k1=function($){let W,A;return A=null,W={get:function(U,u){let f,Y;if(u===O1)return!0;if(u===u1)return U;if(typeof u==="symbol")return Reflect.get(U,u);if(u==="length"&&Array.isArray(U))return Y1(U).value,U.length;if(u==="get")return function(F){return S2(A,F)};if(u==="set")return function(F,Z){return L2(A,F,Z)};if(f=l1(U,u),Y=f.value,Y!=null&&typeof Y==="object")return V2(Y);return Y},set:function(U,u,f){let Y,F;if(Y=U[u],F=f?.[u1]?f[u1]:f,F===Y)return!0;if(U[u]=F,U[k]?.has(u))U[k].get(u).value=F;if(Y===void 0&&F!==void 0)Y1(U).value=++b1;return x1.value++,!0},deleteProperty:function(U,u){let f;if(delete U[u],f=U[k]?.get(u),f)f.value=void 0;return Y1(U).value=++b1,!0},ownKeys:function(U){return Y1(U).value,Reflect.ownKeys(U)}},A=new Proxy($,W),g1.set($,A),A};M2=/([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;m1=function($){let W,A,U,u,f;U=("."+$).split(M2),U.shift(),f=[],A=0;while(A<U.length){if(u=U[A],W=u[0],W==="."||W==="/")f.push(u.slice(1));else if(W==="[")if(u[1]==='"'||u[1]==="'")f.push(u.slice(2,-2));else f.push(+u.slice(1,-1));A+=2}return f};S2=function($,W){let A,U;U=m1(W),A=$;for(let u of U){if(A==null)return;A=A[u]}return A};L2=function($,W,A){let U,u;u=m1(W),U=$;for(let f=0;f<u.length;f++){let Y=u[f];if(f===u.length-1)U[Y]=A;else{if(U[Y]==null)U[Y]={};U=U[Y]}}return A};Z1=function($){return typeof $==="function"?$:function(){return $.value}};F1=function($,W){let A;return A={read:function(){return $.read()}},Object.defineProperty(A,"value",{get:function(){return $.value},set:function(U){return W.value=U}}),A};P2=function($){let W;if(W=$.replace(/\.rip$/,""),W=W.replace(/\[\.\.\.(\w+)\]/g,"*$1"),W=W.replace(/\[(\w+)\]/g,":$1"),W==="index")return"/";return W=W.replace(/\/index$/,""),"/"+W};N2=function($){let W,A;return W=[],A=$.replace(/\*(\w+)/g,function(U,u){return W.push(u),"(.+)"}).replace(/:(\w+)/g,function(U,u){return W.push(u),"([^/]+)"}),{regex:new RegExp("^"+A+"$"),names:W}};B2=function($,W){let A,U;for(let u of W)if(A=$.match(u.regex.regex),A){U={};for(let f=0;f<u.regex.names.length;f++){let Y=u.regex.names[f];U[Y]=decodeURIComponent(A[f+1])}return{route:u,params:U}}return null};H1=function($,W="components"){let A,U,u,f,Y,F,Z,Q,R;Z=[],u=new Map,A=$.listAll(W);for(let w of A){if(F=w.slice(W.length+1),!F.endsWith(".rip"))continue;if(f=F.split("/").pop(),f==="_layout.rip"){U=F==="_layout.rip"?"":F.slice(0,-12),u.set(U,w);continue}if(f.startsWith("_"))continue;if(Q=F.split("/"),Q.length>1&&Q.some(function(K,_){return _<Q.length-1&&K.startsWith("_")}))continue;R=P2(F),Y=N2(R),Z.push({pattern:R,regex:Y,file:w,rel:F})}return Z.sort(function(w,K){let _,J,X,z;if(J=(w.pattern.match(/:/g)||[]).length,z=(K.pattern.match(/:/g)||[]).length,_=w.pattern.includes("*")?1:0,X=K.pattern.includes("*")?1:0,_!==X)return _-X;if(J!==z)return J-z;return w.pattern.localeCompare(K.pattern)}),{routes:Z,layouts:u}};E2=function($,W,A){let U,u,f,Y;if(U=[],f=$.slice(W.length+1),Y=f.split("/"),u="",A.has(""))U.push(A.get(""));for(let F=0;F<Y.length;F++){let Z=Y[F];if(F===Y.length-1)break;if(u=u?u+"/"+Z:Z,A.has(u))U.push(A.get(u))}return U};z2=function($,W){if($.length!==W.length)return!1;for(let A=0;A<$.length;A++)if($[A]!==W[A])return!1;return!0};v1=function($){for(let W in $){let A=$[W];if(typeof A==="function"&&(A.prototype?.mount||A.prototype?._create))return A}return typeof $.default==="function"?$.default:void 0};c1=function($){let W;W={};for(let A in $){let U=$[A];if(typeof U==="function"&&(U.prototype?.mount||U.prototype?._create))W[A]=U}return W};O2=function($){let W;return W=$.split("/").pop().replace(/\.rip$/,""),W.replace(/(^|[-_])([a-z])/g,function(A,U,u){return u.toUpperCase()})};H2=function($,W="components"){let A,U,u;U={};for(let f of $.listAll(W)){if(!f.endsWith(".rip"))continue;if(A=f.split("/").pop(),A.startsWith("_"))continue;if(u=O2(f),U[u])console.warn(`[Rip] Component name collision: ${u} (${U[u]} vs ${f})`);U[u]=f}return U};q1=async function($,W,A=null,U=null,u=null){let f,Y,F,Z,Q,R,w,K,_,J,X;if(A&&U){if(Y=A.getCompiled(U),Y)return Y}if(R=W($),u){_={};for(let z in u.map){let M=u.map[z];if(M!==U&&R.includes(`new ${z}(`)){if(!u.classes[z]){if(Z=A.read(M),Z){F=await q1(Z,W,A,M,u),Q=c1(F);for(let O in Q){let P=Q[O];u.classes[O]=P}}}if(u.classes[z])_[z]=!0}}if(K=Object.keys(_),K.length>0)J=`const {${K.join(", ")}} = globalThis['${u.key}'];
524
524
  `,R=J+R}f=new Blob([R],{type:"application/javascript"}),X=URL.createObjectURL(f);try{w=await import(X)}finally{URL.revokeObjectURL(X)}if(u){Q=c1(w);for(let z in Q){let M=Q[z];u.classes[z]=M}}if(A&&U)A.setCompiled(U,w);return w};q2=function($){let W,A,U;return U=1000,A=30000,W=function(){let u;return u=new EventSource($),u.addEventListener("connected",function(){return U=1000,console.log("[Rip] Hot reload connected")}),u.addEventListener("reload",function(){return console.log("[Rip] Reloading..."),location.reload()}),u.onerror=function(){return u.close(),setTimeout(W,U),U=Math.min(U*2,A)}},W()};var j2=function($={}){return k1($)},h2=function($){return $?.[u1]?$[u1]:$},c3=function($){return $?.[O1]===!0},v3=function($,W={}){let A,U,u,f,Y;if(A=j(W.initial||null),u=j(!1),U=j(null),f=async function(){let F;return u.value=!0,U.value=null,(async()=>{try{return F=await $(),A.value=F}catch(Z){return U.value=Z}finally{u.value=!1}})()},Y={data:void 0,loading:void 0,error:void 0,refetch:f},Object.defineProperty(Y,"data",{get:function(){return A.value}}),Object.defineProperty(Y,"loading",{get:function(){return u.value}}),Object.defineProperty(Y,"error",{get:function(){return U.value}}),!W.lazy)f();return Y},C2=function($,W){let A,U;return A=Z1(W),U=j(!!A()),o(function(){let u;if(A())return u=setTimeout(function(){return U.value=!0},$),function(){return clearTimeout(u)};else return U.value=!1}),typeof W!=="function"?F1(U,W):U},g3=function($,W){let A,U;return A=Z1(W),U=j(A()),o(function(){let u,f;return f=A(),u=setTimeout(function(){return U.value=f},$),function(){return clearTimeout(u)}}),typeof W!=="function"?F1(U,W):U},x3=function($,W){let A,U,u;return A=Z1(W),u=j(A()),U=0,o(function(){let f,Y,F,Z;if(Z=A(),f=Date.now(),Y=$-(f-U),Y<=0)return u.value=Z,U=f;else return F=setTimeout(function(){return u.value=A(),U=Date.now()},Y),function(){return clearTimeout(F)}}),typeof W!=="function"?F1(u,W):u},l3=function($,W){let A,U;return A=Z1(W),U=j(!!A()),o(function(){let u;if(A())return U.value=!0;else return u=setTimeout(function(){return U.value=!1},$),function(){return clearTimeout(u)}}),typeof W!=="function"?F1(U,W):U},y2=function(){let $,W,A,U;return W=new Map,U=[],$=new Map,A=function(u,f){for(let Y of U)Y(u,f)},{read:function(u){return W.get(u)},write:function(u,f){let Y;return Y=!W.has(u),W.set(u,f),$.delete(u),A(Y?"create":"change",u)},del:function(u){return W.delete(u),$.delete(u),A("delete",u)},exists:function(u){return W.has(u)},size:function(){return W.size},list:function(u=""){let f,Y,F;F=[],f=u?u+"/":"";for(let[Z]of W)if(Z.startsWith(f)){if(Y=Z.slice(f.length),Y.includes("/"))continue;F.push(Z)}return F},listAll:function(u=""){let f,Y;Y=[],f=u?u+"/":"";for(let[F]of W)if(F.startsWith(f))Y.push(F);return Y},load:function(u){for(let f in u){let Y=u[f];W.set(f,Y)}},watch:function(u){return U.push(u),function(){return U.splice(U.indexOf(u),1)}},getCompiled:function(u){return $.get(u)},setCompiled:function(u,f){return $.set(u,f)}}},b2=function($,W={}){let A,U,u,f,Y,F,Z,Q,R,w,K,_,J,X,z,M,O,P,q,E,H;if(O=W.root||"components",R=W.base||"",w=W.hash||!1,J=W.onError||null,q=function(D){return R&&D.startsWith(R)?D.slice(R.length)||"/":D},Q=function(D){return R?R+D:D},z=function(){let D;if(w){if(D=location.hash.slice(1),!D)return"/";return D[0]==="/"?D:"/"+D}else return location.pathname+location.search+location.hash},H=function(D){return w?D==="/"?location.pathname:"#"+D.slice(1):Q(D)},Y=j(q(w?z():location.pathname)),f=j({}),Z=j(null),U=j([]),F=j({}),A=j(""),u=C2(100,j(!1)),E=H1($,O),K=new Set,$.watch(function(D,G){if(!G.startsWith(O+"/"))return;return E=H1($,O)}),M=function(D){let G,I,B,N,T;if(N=D.split("?")[0].split("#")[0],I=q(N),I=I[0]==="/"?I:"/"+I,B=D.split("?")[1]?.split("#")[0]||"",G=D.includes("#")?D.split("#")[1]:"",T=B2(I,E.routes),T){w2(function(){return Y.value=I,f.value=T.params,Z.value=T.route,U.value=E2(T.route.file,O,E.layouts),F.value=Object.fromEntries(new URLSearchParams(B)),A.value=G});for(let L of K)L(P.current);return!0}if(J)J({status:404,path:I});return!1},X=function(){return M(z())},typeof window<"u")window.addEventListener("popstate",X);if(_=function(D){let G,I,B;if(D.button!==0||D.metaKey||D.ctrlKey||D.shiftKey||D.altKey)return;I=D.target;while(I&&I.tagName!=="A")I=I.parentElement;if(!I?.href)return;if(B=new URL(I.href,location.origin),B.origin!==location.origin)return;if(I.target==="_blank"||I.hasAttribute("data-external"))return;return D.preventDefault(),G=w&&B.hash?B.hash.slice(1)||"/":B.pathname+B.search+B.hash,P.push(G)},typeof document<"u")document.addEventListener("click",_);return P={push:function(D){return M(D)?history.pushState(null,"",H(Y.read())):void 0},replace:function(D){return M(D)?history.replaceState(null,"",H(Y.read())):void 0},back:function(){return history.back()},forward:function(){return history.forward()},current:void 0,path:void 0,params:void 0,route:void 0,layouts:void 0,query:void 0,hash:void 0,navigating:void 0,onNavigate:function(D){return K.add(D),function(){return K.delete(D)}},rebuild:function(){return E=H1($,O)},routes:void 0,init:function(){return M(z()),P},destroy:function(){if(typeof window<"u")window.removeEventListener("popstate",X);if(typeof document<"u")document.removeEventListener("click",_);return K.clear()}},Object.defineProperty(P,"current",{get:function(){return{path:Y.value,params:f.value,route:Z.value,layouts:U.value,query:F.value,hash:A.value}}}),Object.defineProperty(P,"path",{get:function(){return Y.value}}),Object.defineProperty(P,"params",{get:function(){return f.value}}),Object.defineProperty(P,"route",{get:function(){return Z.value}}),Object.defineProperty(P,"layouts",{get:function(){return U.value}}),Object.defineProperty(P,"query",{get:function(){return F.value}}),Object.defineProperty(P,"hash",{get:function(){return A.value}}),Object.defineProperty(P,"navigating",{get:function(){return u.value},set:function(D){return u.value=D}}),Object.defineProperty(P,"routes",{get:function(){return E.routes}}),P},c2=function($={}){let W,A,U,u,f,Y,F,Z,Q,R,w,K,_,J,X,z,M,O,P,q,E;if({router:P,app:W,components:f,resolver:O,compile:U,target:q,onError:z}=$,Y=typeof q==="string"?document.querySelector(q):q||document.getElementById("app"),!Y)Y=document.createElement("div"),Y.id="app",document.body.appendChild(Y);return Y.style.opacity="0",F=null,Q=null,Z=[],K=[],J=Y,w=0,R=null,u=new Map,_=$.cacheSize||10,A=function(){let H,D;if(F&&Q){if(F.beforeUnmount)F.beforeUnmount();if(u.set(Q,F),u.size>_){if(D=u.keys().next().value,H=u.get(D),H.unmounted)H.unmounted();u.delete(D)}return F=null,Q=null}},E=function(){A();for(let H=K.length-1;H>=0;H--){let D=K[H];if(D.beforeUnmount)D.beforeUnmount();if(D.unmounted)D.unmounted();D._root?.remove()}return K=[],J=Y},f.watch(function(H,D){let G;if(u.has(D)){if(G=u.get(D),G.unmounted)G.unmounted();return u.delete(D)}}),X=async function(H){let D,G,I,B,N,T,L,h,m,f1,$1,i1,n,p1,_1,R1,Q1,P1,C,d1,G1,a;if({route:C,params:R1,layouts:h,query:P1}=H,!C)return;if(C.file===Q)return;return B=++w,P.navigating=!0,(async()=>{try{if(G1=f.read(C.file),!G1){if(z)z({status:404,message:`File not found: ${C.file}`});P.navigating=!1;return}if(i1=await q1(G1,U,f,C.file,O),B!==w){P.navigating=!1;return}if(D=v1(i1),!D){if(z)z({status:500,message:`No component found in ${C.file}`});P.navigating=!1;return}if($1=!z2(h,Z),p1=F?._root,$1)E();else A();if(n=$1?Y:J,$1&&h.length>0){Y.innerHTML="",n=Y;for(let c of h){if(f1=f.read(c),!f1)continue;if(m=await q1(f1,U,f,c,O),B!==w){P.navigating=!1;return}if(G=v1(m),!G)continue;if(T=new G({app:W,params:R1,router:P}),T.beforeMount)T.beforeMount();a=document.createElement("div"),a.setAttribute("data-layout",c),n.appendChild(a),T.mount(a),K.push(T),d1=a.querySelector("#content")||a,n=d1}Z=[...h],J=n}else if($1)Y.innerHTML="",Z=[],J=Y;if(I=u.get(C.file),I)u.delete(C.file),n.appendChild(I._root),F=I,Q=C.file;else{if(_1=document.createElement("div"),_1.setAttribute("data-component",C.file),n.appendChild(_1),L=new D({app:W,params:R1,query:P1,router:P}),L.beforeMount)L.beforeMount();if(L.mount(_1),F=L,Q=C.file,L.load)await L.load(R1,P1)}return p1?.remove(),P.navigating=!1,Y.style.opacity==="0"?document.fonts.ready.then(function(){return requestAnimationFrame(function(){return Y.style.transition="opacity 150ms ease-in",Y.style.opacity="1"})}):void 0}catch(c){if(P.navigating=!1,Y.style.opacity="1",console.error(`Renderer: error mounting ${C.file}:`,c),z)z({status:500,message:c.message,error:c});N=!1;for(let E1=K.length-1;E1>=0;E1--){let r1=K[E1];if(r1.onError)try{r1.onError(c),N=!0;break}catch(v2){console.error("Renderer: error boundary failed:",v2)}}return(()=>{if(!N)return Q1=document.createElement("pre"),Q1.style.cssText="color:red;padding:1em",Q1.textContent=c.stack||c.message,Y.innerHTML="",Y.appendChild(Q1)})()}})()},M={start:function(){return R=o(function(){let H;return H=P.current,H.route?X(H):void 0}),P.init(),M},stop:function(){if(E(),R)R(),R=null;return Y.innerHTML=""},remount:function(){let H;return H=P.current,H.route?X(H):void 0},cache:u},M},k3=async function($="",W={}){let A,U,u,f,Y,F,Z,Q,R,w,K,_,J,X,z,M,O,P,q,E,H;if(globalThis.__ripLaunched=!0,typeof $==="object")W=$,$="";if($=$.replace(/\/+$/,""),H=W.target||"#app",R=W.compile||null,X=W.persist||!1,_=W.hash||!1,!R)R=globalThis?.compileToJS||null;if(typeof document<"u"&&!document.querySelector(H))K=document.createElement("div"),K.id=H.replace(/^#/,""),document.body.prepend(K);if(W.bundle)F=W.bundle;else if(W.components&&Array.isArray(W.components)){w={};for(let D of W.components)if(M=await fetch(D),M.ok)J=D.split("/").pop(),w[`components/${J}`]=await M.text();F={components:w,data:{}}}else if(typeof document<"u"&&document.querySelectorAll('script[type="text/rip"][data-name]').length>0){w={};for(let D of document.querySelectorAll('script[type="text/rip"][data-name]'))J=D.getAttribute("data-name"),J+=!J.endsWith(".rip")?".rip":void 0,w[`components/${J}`]=D.textContent;F={components:w,data:{}}}else{if(Z=`${$}/bundle`,M=await fetch(Z),!M.ok)throw Error(`launch: ${Z} (${M.status})`);F=await M.json()}if(f=j2({components:{},routes:{},data:{}}),F.data)f.data=F.data;if(F.routes)f.routes=F.routes;if(X&&typeof sessionStorage<"u"){u=`__rip_${$}`,U=X==="local"?localStorage:sessionStorage;try{if(q=U.getItem(u),q){E=JSON.parse(q);for(let D in E){let G=E[D];f.data[D]=G}}}catch{}A=function(){return(()=>{try{return U.setItem(u,JSON.stringify(h2(f.data)))}catch{return null}})()},o(function(){let D;return x1.value,D=setTimeout(A,2000),function(){return clearTimeout(D)}}),window.addEventListener("beforeunload",A)}if(Y=y2(),F.components)Y.load(F.components);if(Q=`__rip_${$.replace(/\//g,"_")||"app"}`,O={map:H2(Y),classes:{},key:Q},typeof globalThis<"u")globalThis[Q]=O.classes;if(f.data.title&&typeof document<"u")document.title=f.data.title;if(P=b2(Y,{root:"components",base:$,hash:_,onError:function(D){return console.error(`[Rip] Error ${D.status}: ${D.message||D.path}`)}}),z=c2({router:P,app:f,components:Y,resolver:O,compile:R,target:H,onError:function(D){return console.error(`[Rip] ${D.message}`,D.error)}}),z.start(),F.data?.watch)q2(`${$}/watch`);if(typeof window<"u")window.app=f,window.__RIP__={app:f,components:Y,router:P,renderer:z,cache:z.cache,version:"0.3.0"};return{app:f,components:Y,router:P,renderer:z}};e.modules["ui.rip"]=n1;export{y3 as rip,C3 as processRipScripts,s as parser,e as importRip,z1 as getReactiveRuntime,y1 as getComponentRuntime,x as formatSExpr,r as compileToJS,C1 as compile,V3 as VERSION,p as Lexer,w1 as Compiler,y as CodeGenerator,j3 as BUILD_DATE};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/ui",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "description": "Zero-build reactive web framework — rip.js + ui.rip + launch(url)",
5
5
  "type": "module",
6
6
  "main": "ui.rip",