rip-lang 3.13.30 → 3.13.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/dist/rip.js +8 -3
- package/docs/dist/rip.min.js +7 -2
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/components.js +6 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.
|
|
12
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.31-blue.svg" alt="Version"></a>
|
|
13
13
|
<a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
|
|
14
14
|
<a href="#"><img src="https://img.shields.io/badge/tests-1%2C300%2F1%2C300-brightgreen.svg" alt="Tests"></a>
|
|
15
15
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
|
package/docs/dist/rip.js
CHANGED
|
@@ -4664,7 +4664,7 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4664
4664
|
const { propsCode, reactiveProps, childrenSetupLines } = this.buildComponentProps(args);
|
|
4665
4665
|
const s = this._self;
|
|
4666
4666
|
this._createLines.push(`${instVar} = new ${componentName}(${propsCode});`);
|
|
4667
|
-
this._createLines.push(`${elVar} = ${instVar}._create();`);
|
|
4667
|
+
this._createLines.push(`${elVar} = ${instVar}._root = ${instVar}._create();`);
|
|
4668
4668
|
this._createLines.push(`(${s}._children || (${s}._children = [])).push(${instVar});`);
|
|
4669
4669
|
this._setupLines.push(`try { if (${instVar}._setup) ${instVar}._setup(); if (${instVar}.mounted) ${instVar}.mounted(); } catch (__e) { __handleComponentError(__e, ${instVar}); }`);
|
|
4670
4670
|
for (const { key, valueCode } of reactiveProps) {
|
|
@@ -5044,6 +5044,11 @@ class __Component {
|
|
|
5044
5044
|
this._root.parentNode.removeChild(this._root);
|
|
5045
5045
|
}
|
|
5046
5046
|
}
|
|
5047
|
+
emit(name, detail) {
|
|
5048
|
+
if (this._root) {
|
|
5049
|
+
this._root.dispatchEvent(new CustomEvent(name, { detail, bubbles: true }));
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5047
5052
|
static mount(target = 'body') {
|
|
5048
5053
|
return new this().mount(target);
|
|
5049
5054
|
}
|
|
@@ -8570,8 +8575,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
8570
8575
|
return new CodeGenerator({}).getComponentRuntime();
|
|
8571
8576
|
}
|
|
8572
8577
|
// src/browser.js
|
|
8573
|
-
var VERSION = "3.13.
|
|
8574
|
-
var BUILD_DATE = "2026-02-26@
|
|
8578
|
+
var VERSION = "3.13.31";
|
|
8579
|
+
var BUILD_DATE = "2026-02-26@09:14:06GMT";
|
|
8575
8580
|
if (typeof globalThis !== "undefined") {
|
|
8576
8581
|
if (!globalThis.__rip)
|
|
8577
8582
|
new Function(getReactiveRuntime())();
|
package/docs/dist/rip.min.js
CHANGED
|
@@ -21,7 +21,7 @@ ${D}return ${I.join(`
|
|
|
21
21
|
`)},F.generateInComponent=function(U,u){if(typeof U==="string"&&this.reactiveMembers&&this.reactiveMembers.has(U))return`${this._self}.${U}.value`;if(typeof U==="string"&&this.componentMembers&&this.componentMembers.has(U))return`${this._self}.${U}`;if(Array.isArray(U)&&this.reactiveMembers){let f=this.transformComponentMembers(U);return this.generate(f,u)}return this.generate(U,u)},F.generateRender=function(U,u,f,Y){throw Error("render blocks can only be used inside a component")},F.buildRender=function(U){this._elementCount=0,this._textCount=0,this._blockCount=0,this._createLines=[],this._setupLines=[],this._blockFactories=[],this._loopVarStack=[],this._factoryMode=!1,this._factoryVars=null,this._fragChildren=new Map,this._pendingAutoWire=!1,this._autoWireEl=null,this._autoWireExplicit=null;let u=this.is(U,"block")?U.slice(1):[U],f;if(u.length===0)f="null";else if(u.length===1)this._pendingAutoWire=!!this._autoEventHandlers,f=this.generateNode(u[0]),this._pendingAutoWire=!1;else{f=this.newElementVar("frag"),this._createLines.push(`${f} = document.createDocumentFragment();`);let Y=[];for(let _ of u){let A=this.generateNode(_);this._createLines.push(`${f}.appendChild(${A});`),Y.push(A)}this._fragChildren.set(f,Y)}return{createLines:this._createLines,setupLines:this._setupLines,blockFactories:this._blockFactories,rootVar:f}},F.newBlockVar=function(){return`create_block_${this._blockCount++}`},F.newElementVar=function(U="el"){let u=`_${U}${this._elementCount++}`;if(this._factoryVars)this._factoryVars.add(u);return this._factoryMode?u:`this.${u}`},F.newTextVar=function(){let U=`_t${this._textCount++}`;if(this._factoryVars)this._factoryVars.add(U);return this._factoryMode?U:`this.${U}`},Object.defineProperty(F,"_self",{get(){return this._factoryMode?"ctx":"this"}}),F._pushEffect=function(U){if(this._factoryMode)this._setupLines.push(`disposers.push(__effect(() => { ${U} }));`);else this._setupLines.push(`__effect(() => { ${U} });`)},F.generateNode=function(U){if(typeof U==="string"||U instanceof String){let J=U.valueOf();if(J.startsWith('"')||J.startsWith("'")||J.startsWith("`")){let K=this.newTextVar();return this._createLines.push(`${K} = document.createTextNode(${J});`),K}if(this.reactiveMembers&&this.reactiveMembers.has(J)){let K=this.newTextVar();return this._createLines.push(`${K} = document.createTextNode('');`),this._pushEffect(`${K}.data = ${this._self}.${J}.value;`),K}let[R,X]=J.split("#"),z=this.newElementVar(),Z=R||"div";if(Y1.has(Z)||this._svgDepth>0)this._createLines.push(`${z} = document.createElementNS('http://www.w3.org/2000/svg', '${Z}');`);else this._createLines.push(`${z} = document.createElement('${Z}');`);if(X)this._createLines.push(`${z}.id = '${X}';`);return z}if(!Array.isArray(U)){let J=this.newElementVar("c");return this._createLines.push(`${J} = document.createComment('unknown');`),J}let[u,...f]=U,Y=typeof u==="string"?u:u instanceof String?u.valueOf():null;if(Y&&this.isComponent(Y))return this.generateChildComponent(Y,f);if(Y&&this.isHtmlTag(Y)){let[J,R]=Y.split("#");return this.generateTag(J||"div",[],f,R)}if(Y==="."){let[,J,R]=U;if(J==="this"&&typeof R==="string"){let Q=this._self;if(this.reactiveMembers&&this.reactiveMembers.has(R)){let H=this.newTextVar();return this._createLines.push(`${H} = document.createTextNode('');`),this._pushEffect(`${H}.data = ${Q}.${R}.value;`),H}let M=this.newElementVar("slot");return this._createLines.push(`${M} = ${Q}.${R} instanceof Node ? ${Q}.${R} : (${Q}.${R} != null ? document.createTextNode(String(${Q}.${R})) : document.createComment(''));`),M}let{tag:X,classes:z,id:Z}=this.collectTemplateClasses(U);if(X&&this.isHtmlTag(X))return this.generateTag(X,z,[],Z);let K=this.newTextVar(),w=this.generateInComponent(U,"value");return this._createLines.push(`${K} = document.createTextNode(String(${w}));`),K}if(Array.isArray(u)){if(Array.isArray(u[0])&&u[0][0]==="."&&(u[0][2]==="__clsx"||u[0][2]instanceof String&&u[0][2].valueOf()==="__clsx")){let z=typeof u[0][1]==="string"?u[0][1]:u[0][1].valueOf(),Z=u.slice(1);return this.generateDynamicTag(z,Z,f)}let{tag:J,classes:R,id:X}=this.collectTemplateClasses(u);if(J&&this.isHtmlTag(J)){if(R.length===1&&R[0]==="__clsx")return this.generateDynamicTag(J,f,[]);return this.generateTag(J,R,f,X)}}if(Y==="->"||Y==="=>")return this.generateTemplateBlock(f[1]);if(Y==="if")return this.generateConditional(U);if(Y==="for"||Y==="for-in"||Y==="for-of"||Y==="for-as")return this.generateTemplateLoop(U);let _=this.newTextVar(),A=this.generateInComponent(U,"value");if(this.hasReactiveDeps(U))this._createLines.push(`${_} = document.createTextNode('');`),this._pushEffect(`${_}.data = ${A};`);else this._createLines.push(`${_} = document.createTextNode(String(${A}));`);return _},F.appendChildren=function(U,u){for(let f of u)if(this.is(f,"->")||this.is(f,"=>")){let Y=f[2];if(this.is(Y,"block"))for(let _ of Y.slice(1))if(this.is(_,"object"))this.generateAttributes(U,_);else{let A=this.generateNode(_);this._createLines.push(`${U}.appendChild(${A});`)}else if(Y){let _=this.generateNode(Y);this._createLines.push(`${U}.appendChild(${_});`)}}else if(this.is(f,"object"))this.generateAttributes(U,f);else if(typeof f==="string"||f instanceof String){let Y=f.valueOf(),_=Y.split(/[#.]/)[0];if(this.isHtmlTag(_||"div")||this.isComponent(_)){let A=this.generateNode(f);this._createLines.push(`${U}.appendChild(${A});`)}else{let A=this.newTextVar();if(Y.startsWith('"')||Y.startsWith("'")||Y.startsWith("`"))this._createLines.push(`${A} = document.createTextNode(${Y});`);else if(this.reactiveMembers&&this.reactiveMembers.has(Y))this._createLines.push(`${A} = document.createTextNode('');`),this._pushEffect(`${A}.data = ${this._self}.${Y}.value;`);else if(this.componentMembers&&this.componentMembers.has(Y))this._createLines.push(`${A} = document.createTextNode(String(${this._self}.${Y}));`);else this._createLines.push(`${A} = document.createTextNode(${this.generateInComponent(f,"value")});`);this._createLines.push(`${U}.appendChild(${A});`)}}else if(f){let Y=this.generateNode(f);this._createLines.push(`${U}.appendChild(${Y});`)}},F._claimAutoWire=function(U){if(!this._pendingAutoWire||!this._autoEventHandlers?.size)return!1;return this._pendingAutoWire=!1,this._autoWireEl=U,this._autoWireExplicit=new Set,!0},F._emitAutoWire=function(U,u){if(!u)return;for(let[f,Y]of this._autoEventHandlers)if(!this._autoWireExplicit.has(f))this._createLines.push(`${U}.addEventListener('${f}', (e) => __batch(() => ${this._self}.${Y}(e)));`);this._autoWireEl=null,this._autoWireExplicit=null},F.generateTag=function(U,u,f,Y){let _=this.newElementVar(),A=Y1.has(U)||this._svgDepth>0;if(A)this._createLines.push(`${_} = document.createElementNS('http://www.w3.org/2000/svg', '${U}');`);else this._createLines.push(`${_} = document.createElement('${U}');`);if(Y)this._createLines.push(`${_}.id = '${Y}';`);let J=this._claimAutoWire(_),R=this._pendingClassArgs,X=this._pendingClassEl;if(u.length>0)this._pendingClassArgs=[`'${u.join(" ")}'`],this._pendingClassEl=_;if(U==="svg")this._svgDepth=(this._svgDepth||0)+1;if(this.appendChildren(_,f),U==="svg")this._svgDepth--;if(u.length>0){if(this._pendingClassArgs.length===1)if(A)this._createLines.push(`${_}.setAttribute('class', '${u.join(" ")}');`);else this._createLines.push(`${_}.className = '${u.join(" ")}';`);else{let z=this._pendingClassArgs.join(", ");if(A)this._pushEffect(`${_}.setAttribute('class', __clsx(${z}));`);else this._pushEffect(`${_}.className = __clsx(${z});`)}this._pendingClassArgs=R,this._pendingClassEl=X}return this._emitAutoWire(_,J),_},F.generateDynamicTag=function(U,u,f){let Y=this.newElementVar();if(Y1.has(U)||this._svgDepth>0)this._createLines.push(`${Y} = document.createElementNS('http://www.w3.org/2000/svg', '${U}');`);else this._createLines.push(`${Y} = document.createElement('${U}');`);let _=this._claimAutoWire(Y),A=u.map((X)=>this.generateInComponent(X,"value")),J=this._pendingClassArgs,R=this._pendingClassEl;if(this._pendingClassArgs=A,this._pendingClassEl=Y,U==="svg")this._svgDepth=(this._svgDepth||0)+1;if(this.appendChildren(Y,f),U==="svg")this._svgDepth--;if(this._pendingClassArgs.length>0){let X=this._pendingClassArgs.join(", ");if(Y1.has(U)||this._svgDepth>0)this._pushEffect(`${Y}.setAttribute('class', __clsx(${X}));`);else this._pushEffect(`${Y}.className = __clsx(${X});`)}return this._pendingClassArgs=J,this._pendingClassEl=R,this._emitAutoWire(Y,_),Y},F.generateAttributes=function(U,u){let f=b3(u.slice(1));for(let Y=1;Y<u.length;Y++){let[_,A]=u[Y];if(this.is(_,".")&&_[1]==="this"){let J=_[2];if(this._autoWireExplicit&&this._autoWireEl===U)this._autoWireExplicit.add(J);if(typeof A==="string"&&this.componentMembers?.has(A))this._createLines.push(`${U}.addEventListener('${J}', (e) => __batch(() => ${this._self}.${A}(e)));`);else{let R=this.generateInComponent(A,"value");this._createLines.push(`${U}.addEventListener('${J}', (e) => __batch(() => (${R})(e)));`)}continue}if(typeof _==="string"){if(_.startsWith('"')&&_.endsWith('"'))_=_.slice(1,-1);if(_==="class"||_==="className"){let R=this.generateInComponent(A,"value");if(this._pendingClassArgs&&this._pendingClassEl===U)this._pendingClassArgs.push(R);else if(this.hasReactiveDeps(A))if(this._svgDepth>0)this._pushEffect(`${U}.setAttribute('class', __clsx(${R}));`);else this._pushEffect(`${U}.className = __clsx(${R});`);else if(this._svgDepth>0)this._createLines.push(`${U}.setAttribute('class', ${R});`);else this._createLines.push(`${U}.className = ${R};`);continue}if(_==="__transition__"){let R=String(A).replace(/^["']|["']$/g,"");this._createLines.push(`this._t = "${R}";`);continue}if(_==="ref"){let R=String(A).replace(/^["']|["']$/g,"");this._createLines.push(`${this._self}.${R} = ${U};`);continue}if(_.startsWith("__bind_")&&_.endsWith("__")){let R=_.slice(7,-2),X=this.generateInComponent(A,"value"),z,Z;if(R==="checked")z="change",Z="e.target.checked";else z="input",Z=f==="number"||f==="range"?"e.target.valueAsNumber":"e.target.value";this._pushEffect(`${U}.${R} = ${X};`);let K=`${X} = ${Z}`,w=!this.isSimpleAssignable(A)&&this.findRootReactiveMember(A);if(w)K+=`; ${this._self}.${w}.touch?.()`;this._createLines.push(`${U}.addEventListener('${z}', (e) => { ${K}; });`);continue}let J=this.generateInComponent(A,"value");if((_==="value"||_==="checked")&&this.hasReactiveDeps(A)){this._pushEffect(`${U}.${_} = ${J};`);let R=!this.isSimpleAssignable(A)&&this.findRootReactiveMember(A);if(this.isSimpleAssignable(A)||R){let X=_==="checked"?"change":"input",Z=`${J} = ${_==="checked"?"e.target.checked":f==="number"||f==="range"?"e.target.valueAsNumber":"e.target.value"}`;if(R)Z+=`; ${this._self}.${R}.touch?.()`;this._createLines.push(`${U}.addEventListener('${X}', (e) => { ${Z}; });`)}continue}if(_==="innerHTML"||_==="textContent"||_==="innerText")if(this.hasReactiveDeps(A))this._pushEffect(`${U}.${_} = ${J};`);else this._createLines.push(`${U}.${_} = ${J};`);else if(y3.has(_))if(this.hasReactiveDeps(A))this._pushEffect(`${U}.toggleAttribute('${_}', !!${J});`);else this._createLines.push(`if (${J}) ${U}.setAttribute('${_}', '');`);else if(this.hasReactiveDeps(A))this._pushEffect(`${U}.setAttribute('${_}', ${J});`);else this._createLines.push(`${U}.setAttribute('${_}', ${J});`)}}},F.generateTemplateBlock=function(U){if(!Array.isArray(U)||U[0]!=="block")return this.generateNode(U);let u=U.slice(1);if(u.length===0){let _=this.newElementVar("empty");return this._createLines.push(`${_} = document.createComment('');`),_}if(u.length===1)return this.generateNode(u[0]);let f=this.newElementVar("frag");this._createLines.push(`${f} = document.createDocumentFragment();`);let Y=[];for(let _ of u){let A=this.generateNode(_);this._createLines.push(`${f}.appendChild(${A});`),Y.push(A)}return this._fragChildren.set(f,Y),f},F.generateConditional=function(U){this._pendingAutoWire=!1;let[,u,f,Y]=U,_=this.newElementVar("anchor");this._createLines.push(`${_} = document.createComment('if');`);let A=this.generateInComponent(u,"value"),J=this._loopVarStack.map((Q)=>`${Q.itemVar}, ${Q.indexVar}`).join(", "),R=J?`, ${J}`:"",X=this.newBlockVar();this.generateConditionBranch(X,f);let z=null;if(Y)z=this.newBlockVar(),this.generateConditionBranch(z,Y);let Z=[];Z.push(`// Conditional: ${X}${z?" / "+z:""}`),Z.push("{"),Z.push(` const anchor = ${_};`),Z.push(" let currentBlock = null;"),Z.push(" let showing = null;");let K=this._factoryMode?"disposers.push(__effect(() => {":"__effect(() => {",w=this._factoryMode?"}));":"});";if(Z.push(` ${K}`),Z.push(` const show = !!(${A});`),Z.push(` const want = show ? 'then' : ${Y?"'else'":"null"};`),Z.push(" if (want === showing) return;"),Z.push(""),Z.push(" if (currentBlock) {"),Z.push(" const leaving = currentBlock;"),Z.push(" if (leaving._t) { __transition(leaving._first, leaving._t, 'leave', () => leaving.d(true)); }"),Z.push(" else { leaving.d(true); }"),Z.push(" currentBlock = null;"),Z.push(" }"),Z.push(" showing = want;"),Z.push(""),Z.push(" if (want === 'then') {"),Z.push(` currentBlock = ${X}(${this._self}${R});`),Z.push(" currentBlock.c();"),Z.push(" if (anchor.parentNode) currentBlock.m(anchor.parentNode, anchor.nextSibling);"),Z.push(` currentBlock.p(${this._self}${R});`),Z.push(" if (currentBlock._t) __transition(currentBlock._first, currentBlock._t, 'enter');"),Z.push(" }"),Y)Z.push(" if (want === 'else') {"),Z.push(` currentBlock = ${z}(${this._self}${R});`),Z.push(" currentBlock.c();"),Z.push(" if (anchor.parentNode) currentBlock.m(anchor.parentNode, anchor.nextSibling);"),Z.push(` currentBlock.p(${this._self}${R});`),Z.push(" if (currentBlock._t) __transition(currentBlock._first, currentBlock._t, 'enter');"),Z.push(" }");return Z.push(` ${w}`),Z.push("}"),this._setupLines.push(Z.join(`
|
|
22
22
|
`)),_},F.generateConditionBranch=function(U,u){let f=[this._createLines,this._setupLines,this._factoryMode,this._factoryVars];this._createLines=[],this._setupLines=[],this._factoryMode=!0,this._factoryVars=new Set;let Y=this.generateTemplateBlock(u),_=this._createLines,A=this._setupLines,J=this._factoryVars;[this._createLines,this._setupLines,this._factoryMode,this._factoryVars]=f;let R=this._loopVarStack.map((z)=>`${z.itemVar}, ${z.indexVar}`).join(", "),X=R?`, ${R}`:"";this.emitBlockFactory(U,`ctx${X}`,Y,_,A,J)},F.emitBlockFactory=function(U,u,f,Y,_,A,J){let R=[];if(R.push(`function ${U}(${u}) {`),A.size>0)R.push(` let ${[...A].join(", ")};`);let X=_.length>0;if(X)R.push(" let disposers = [];");if(R.push(" return {"),J)R.push(" _s: true,");let z=this._fragChildren.get(f),Z=z?z[0]:f;R.push(" c() {");for(let K of Y)R.push(` ${K}`);if(R.push(` this._first = ${Z};`),R.push(" },"),R.push(" m(target, anchor) {"),z)for(let K of z)R.push(` if (target) target.insertBefore(${K}, anchor);`);else R.push(` if (target) target.insertBefore(${f}, anchor);`);if(R.push(" },"),R.push(` p(${u}) {`),X){R.push(" disposers.forEach(d => d());"),R.push(" disposers = [];");for(let K of _)R.push(` ${K}`)}if(R.push(" },"),R.push(" d(detaching) {"),X)R.push(" disposers.forEach(d => d());");if(z)for(let K of z)R.push(` if (detaching && ${K}) ${K}.remove();`);else R.push(` if (detaching && ${f}) ${f}.remove();`);R.push(" }"),R.push(" };"),R.push("}"),this._blockFactories.push(R.join(`
|
|
23
23
|
`))},F.generateTemplateLoop=function(U){this._pendingAutoWire=!1;let[u,f,Y,_,A,J]=U,R=this.newBlockVar(),X=this.newElementVar("anchor");this._createLines.push(`${X} = document.createComment('for');`);let z=Array.isArray(f)?f:[f],Z=z[0],K=z[1]||"i",w=this.generateInComponent(Y,"value"),Q=Z;if(this.is(J,"block")&&J.length>1){let c=J[1];if(Array.isArray(c))for(let o of c){if(this.is(o,"object"))for(let k=1;k<o.length;k++){let[z1,m]=o[k];if(z1==="key"){Q=this.generate(m,"value");break}}if(Q!==Z)break}}let M=[this._createLines,this._setupLines,this._factoryMode,this._factoryVars];this._createLines=[],this._setupLines=[],this._factoryMode=!0,this._factoryVars=new Set;let H=this._loopVarStack.map((c)=>`${c.itemVar}, ${c.indexVar}`).join(", "),O=H?`, ${H}`:"";this._loopVarStack.push({itemVar:Z,indexVar:K});let q=this.generateTemplateBlock(J);this._loopVarStack.pop();let E=this._createLines,I=this._setupLines,D=this._factoryVars;[this._createLines,this._setupLines,this._factoryMode,this._factoryVars]=M;let G=I.length===0,P=`ctx, ${Z}, ${K}${O}`;this.emitBlockFactory(R,P,q,E,I,D,G);let N=Q!==Z?`(${Z}, ${K}) => ${Q}`:"null",T=H?`, ${H}`:"",S=[];S.push(`// Loop: ${R}`),S.push("{"),S.push(" const __s = { blocks: [], keys: [] };");let j=this._factoryMode?"disposers.push(__effect(() => {":"__effect(() => {",C=this._factoryMode?"}));":"});";return S.push(` ${j}`),S.push(` __reconcile(${X}, __s, ${w}, ${this._self}, ${R}, ${N}${T});`),S.push(` ${C}`),S.push("}"),this._setupLines.push(S.join(`
|
|
24
|
-
`)),X},F.generateChildComponent=function(U,u){this._pendingAutoWire=!1;let f=this.newElementVar("inst"),Y=this.newElementVar("el"),{propsCode:_,reactiveProps:A,childrenSetupLines:J}=this.buildComponentProps(u),R=this._self;this._createLines.push(`${f} = new ${U}(${_});`),this._createLines.push(`${Y} = ${f}._create();`),this._createLines.push(`(${R}._children || (${R}._children = [])).push(${f});`),this._setupLines.push(`try { if (${f}._setup) ${f}._setup(); if (${f}.mounted) ${f}.mounted(); } catch (__e) { __handleComponentError(__e, ${f}); }`);for(let{key:X,valueCode:z}of A)this._pushEffect(`if (${f}.${X}) ${f}.${X}.value = ${z};`);for(let X of J)this._setupLines.push(X);return Y},F.buildComponentProps=function(U){let u=[],f=[],Y=null,_=[],A=(X,z)=>{if(this.reactiveMembers&&(typeof z==="string"&&this.reactiveMembers.has(z)||Array.isArray(z)&&z[0]==="."&&z[1]==="this"&&typeof z[2]==="string"&&this.reactiveMembers.has(z[2]))){let K=typeof z==="string"?z:z[2];u.push(`${X}: ${this._self}.${K}`)}else{let K=this.generateInComponent(z,"value");if(u.push(`${X}: ${K}`),this.hasReactiveDeps(z))f.push({key:X,valueCode:K})}},J=(X)=>{for(let z=1;z<X.length;z++){let[Z,K]=X[z];if(typeof Z==="string")A(Z,K)}};for(let X of U)if(this.is(X,"object"))J(X);else if(Array.isArray(X)&&(X[0]==="->"||X[0]==="=>")){let z=X[2];if(z){if(this.is(z,"block")){let Z=[];for(let K of z.slice(1))if(this.is(K,"object"))J(K);else Z.push(K);z=Z.length>0?["block",...Z]:null}if(z){let Z=this._createLines,K=this._setupLines;this._createLines=[],this._setupLines=[],Y=this.generateTemplateBlock(z);let w=this._createLines,Q=this._setupLines;this._createLines=Z,this._setupLines=K;for(let M of w)this._createLines.push(M);_.push(...Q),u.push(`children: ${Y}`)}}}return{propsCode:u.length>0?`{ ${u.join(", ")} }`:"{}",reactiveProps:f,childrenSetupLines:_}},F.hasReactiveDeps=function(U){if(typeof U==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U));if(!Array.isArray(U))return!1;if(U[0]==="."&&U[1]==="this"&&typeof U[2]==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U[2]));if(U[0]==="."&&this._rootsAtThis(U[1]))return!0;for(let u of U)if(this.hasReactiveDeps(u))return!0;return!1},F.isSimpleAssignable=function(U){if(typeof U==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U));if(Array.isArray(U)&&U[0]==="."&&U[1]==="this"&&typeof U[2]==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U[2]));return!1},F.findRootReactiveMember=function(U){if(typeof U==="string")return this.reactiveMembers?.has(U)?U:null;if(!Array.isArray(U))return null;if(U[0]==="."&&U[1]==="this"&&typeof U[2]==="string")return this.reactiveMembers?.has(U[2])?U[2]:null;if(U[0]==="."||U[0]==="[]")return this.findRootReactiveMember(U[1]);return null},F._rootsAtThis=function(U){if(typeof U==="string")return U==="this";if(!Array.isArray(U)||U[0]!==".")return!1;return this._rootsAtThis(U[1])},F.getComponentRuntime=function(){return`
|
|
24
|
+
`)),X},F.generateChildComponent=function(U,u){this._pendingAutoWire=!1;let f=this.newElementVar("inst"),Y=this.newElementVar("el"),{propsCode:_,reactiveProps:A,childrenSetupLines:J}=this.buildComponentProps(u),R=this._self;this._createLines.push(`${f} = new ${U}(${_});`),this._createLines.push(`${Y} = ${f}._root = ${f}._create();`),this._createLines.push(`(${R}._children || (${R}._children = [])).push(${f});`),this._setupLines.push(`try { if (${f}._setup) ${f}._setup(); if (${f}.mounted) ${f}.mounted(); } catch (__e) { __handleComponentError(__e, ${f}); }`);for(let{key:X,valueCode:z}of A)this._pushEffect(`if (${f}.${X}) ${f}.${X}.value = ${z};`);for(let X of J)this._setupLines.push(X);return Y},F.buildComponentProps=function(U){let u=[],f=[],Y=null,_=[],A=(X,z)=>{if(this.reactiveMembers&&(typeof z==="string"&&this.reactiveMembers.has(z)||Array.isArray(z)&&z[0]==="."&&z[1]==="this"&&typeof z[2]==="string"&&this.reactiveMembers.has(z[2]))){let K=typeof z==="string"?z:z[2];u.push(`${X}: ${this._self}.${K}`)}else{let K=this.generateInComponent(z,"value");if(u.push(`${X}: ${K}`),this.hasReactiveDeps(z))f.push({key:X,valueCode:K})}},J=(X)=>{for(let z=1;z<X.length;z++){let[Z,K]=X[z];if(typeof Z==="string")A(Z,K)}};for(let X of U)if(this.is(X,"object"))J(X);else if(Array.isArray(X)&&(X[0]==="->"||X[0]==="=>")){let z=X[2];if(z){if(this.is(z,"block")){let Z=[];for(let K of z.slice(1))if(this.is(K,"object"))J(K);else Z.push(K);z=Z.length>0?["block",...Z]:null}if(z){let Z=this._createLines,K=this._setupLines;this._createLines=[],this._setupLines=[],Y=this.generateTemplateBlock(z);let w=this._createLines,Q=this._setupLines;this._createLines=Z,this._setupLines=K;for(let M of w)this._createLines.push(M);_.push(...Q),u.push(`children: ${Y}`)}}}return{propsCode:u.length>0?`{ ${u.join(", ")} }`:"{}",reactiveProps:f,childrenSetupLines:_}},F.hasReactiveDeps=function(U){if(typeof U==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U));if(!Array.isArray(U))return!1;if(U[0]==="."&&U[1]==="this"&&typeof U[2]==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U[2]));if(U[0]==="."&&this._rootsAtThis(U[1]))return!0;for(let u of U)if(this.hasReactiveDeps(u))return!0;return!1},F.isSimpleAssignable=function(U){if(typeof U==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U));if(Array.isArray(U)&&U[0]==="."&&U[1]==="this"&&typeof U[2]==="string")return!!(this.reactiveMembers&&this.reactiveMembers.has(U[2]));return!1},F.findRootReactiveMember=function(U){if(typeof U==="string")return this.reactiveMembers?.has(U)?U:null;if(!Array.isArray(U))return null;if(U[0]==="."&&U[1]==="this"&&typeof U[2]==="string")return this.reactiveMembers?.has(U[2])?U[2]:null;if(U[0]==="."||U[0]==="[]")return this.findRootReactiveMember(U[1]);return null},F._rootsAtThis=function(U){if(typeof U==="string")return U==="this";if(!Array.isArray(U)||U[0]!==".")return!1;return this._rootsAtThis(U[1])},F.getComponentRuntime=function(){return`
|
|
25
25
|
// ============================================================================
|
|
26
26
|
// Rip Component Runtime
|
|
27
27
|
// ============================================================================
|
|
@@ -277,6 +277,11 @@ class __Component {
|
|
|
277
277
|
this._root.parentNode.removeChild(this._root);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
+
emit(name, detail) {
|
|
281
|
+
if (this._root) {
|
|
282
|
+
this._root.dispatchEvent(new CustomEvent(name, { detail, bubbles: true }));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
280
285
|
static mount(target = 'body') {
|
|
281
286
|
return new this().mount(target);
|
|
282
287
|
}
|
|
@@ -715,7 +720,7 @@ globalThis.sleep ??= (ms) => new Promise(r => setTimeout(r, ms));
|
|
|
715
720
|
globalThis.todo ??= (msg) => { throw new Error(msg || "Not implemented"); };
|
|
716
721
|
globalThis.warn ??= console.warn;
|
|
717
722
|
globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
718
|
-
`}function R1(){return new y({}).getReactiveRuntime()}function w1(){return new y({}).getComponentRuntime()}var M2="3.13.
|
|
723
|
+
`}function R1(){return new y({}).getReactiveRuntime()}function w1(){return new y({}).getComponentRuntime()}var M2="3.13.31",D2="2026-02-26@09:14:06GMT";if(typeof globalThis<"u"){if(!globalThis.__rip)Function(R1())();if(!globalThis.__ripComponent)Function(w1())()}var v3=($)=>{let W=$.match(/^[ \t]*(?=\S)/gm),F=Math.min(...(W||[]).map((U)=>U.length));return $.replace(RegExp(`^[ ]{${F}}`,"gm"),"").trim()};async function H2(){let $=[],W=document.querySelector('script[src$="rip.min.js"], script[src$="rip.js"]'),F=W?.getAttribute("data-src");if(F){for(let u of F.trim().split(/\s+/))if(u)$.push({url:u})}for(let u of document.querySelectorAll('script[type="text/rip"]'))if(u.src)$.push({url:u.src});else{let f=v3(u.textContent);if(f)$.push({code:f})}if($.length>0){await Promise.all($.map(async(Y)=>{if(!Y.url)return;try{let _=await fetch(Y.url);if(!_.ok){console.error(`Rip: failed to fetch ${Y.url} (${_.status})`);return}Y.code=await _.text()}catch(_){console.error(`Rip: failed to fetch ${Y.url}:`,_.message)}}));let u={skipRuntimes:!0,skipExports:!0},f=[];for(let Y of $){if(!Y.code)continue;try{f.push(d(Y.code,u))}catch(_){console.error("Rip compile error:",_.message)}}if(f.length>0){let Y=f.join(`
|
|
719
724
|
`),_=W?.getAttribute("data-mount");if(_){let A=W.getAttribute("data-target")||"body";Y+=`
|
|
720
725
|
${_}.mount(${JSON.stringify(A)});`}try{await(0,eval)(`(async()=>{
|
|
721
726
|
${Y}
|
package/docs/dist/rip.min.js.br
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/components.js
CHANGED
|
@@ -1640,7 +1640,7 @@ export function installComponentSupport(CodeGenerator, Lexer) {
|
|
|
1640
1640
|
|
|
1641
1641
|
const s = this._self;
|
|
1642
1642
|
this._createLines.push(`${instVar} = new ${componentName}(${propsCode});`);
|
|
1643
|
-
this._createLines.push(`${elVar} = ${instVar}._create();`);
|
|
1643
|
+
this._createLines.push(`${elVar} = ${instVar}._root = ${instVar}._create();`);
|
|
1644
1644
|
this._createLines.push(`(${s}._children || (${s}._children = [])).push(${instVar});`);
|
|
1645
1645
|
|
|
1646
1646
|
this._setupLines.push(`try { if (${instVar}._setup) ${instVar}._setup(); if (${instVar}.mounted) ${instVar}.mounted(); } catch (__e) { __handleComponentError(__e, ${instVar}); }`);
|
|
@@ -2075,6 +2075,11 @@ class __Component {
|
|
|
2075
2075
|
this._root.parentNode.removeChild(this._root);
|
|
2076
2076
|
}
|
|
2077
2077
|
}
|
|
2078
|
+
emit(name, detail) {
|
|
2079
|
+
if (this._root) {
|
|
2080
|
+
this._root.dispatchEvent(new CustomEvent(name, { detail, bubbles: true }));
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2078
2083
|
static mount(target = 'body') {
|
|
2079
2084
|
return new this().mount(target);
|
|
2080
2085
|
}
|