@fluixi/compiler 1.0.0-alpha.81 → 1.0.0-alpha.83
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/dist/analyze/static-graph.cjs +1 -0
- package/dist/analyze/static-graph.d.ts +103 -0
- package/dist/analyze/static-graph.d.ts.map +1 -0
- package/dist/analyze/static-graph.js +869 -0
- package/dist/analyze/static-graph.mjs +1 -0
- package/dist/{babel-4JUDAR2G.mjs → babel-VXKH6MRQ.mjs} +1 -1
- package/dist/chunk-5KMMN5QP.mjs +1 -0
- package/dist/chunk-YKZ54NVE.mjs +1 -0
- package/dist/codegen/backends/imperative.cjs +1 -1
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +62 -11
- package/dist/codegen/backends/imperative.mjs +1 -1
- package/dist/codegen/partial-template.cjs +1 -1
- package/dist/codegen/partial-template.mjs +1 -1
- package/dist/codegen/serialize-static.cjs +1 -1
- package/dist/codegen/serialize-static.d.ts +16 -0
- package/dist/codegen/serialize-static.d.ts.map +1 -1
- package/dist/codegen/serialize-static.js +25 -0
- package/dist/codegen/serialize-static.mjs +1 -1
- package/dist/frontend/babel/build-ir-lit.cjs +1 -1
- package/dist/frontend/babel/build-ir-lit.mjs +1 -1
- package/dist/frontend/babel/build-ir.cjs +1 -1
- package/dist/frontend/babel/build-ir.mjs +1 -1
- package/dist/frontend/babel/index.cjs +1 -1
- package/dist/frontend/babel/index.mjs +1 -1
- package/dist/frontend/babel/lower-template.cjs +1 -1
- package/dist/frontend/babel/lower-template.mjs +1 -1
- package/dist/frontend/babel/plugin.cjs +1 -1
- package/dist/frontend/babel/plugin.mjs +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.mjs +8 -8
- package/dist/integrations.cjs +18 -18
- package/dist/integrations.d.ts +16 -0
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +21 -2
- package/dist/integrations.mjs +5 -5
- package/dist/ir/nodes.cjs +1 -1
- package/dist/ir/nodes.d.ts +46 -0
- package/dist/ir/nodes.d.ts.map +1 -1
- package/dist/lower/compile-template.cjs +1 -1
- package/dist/lower/compile-template.d.ts +12 -0
- package/dist/lower/compile-template.d.ts.map +1 -1
- package/dist/lower/compile-template.js +5 -1
- package/dist/lower/compile-template.mjs +1 -1
- package/dist/lower/jsx.cjs +1 -1
- package/dist/lower/jsx.d.ts +2 -0
- package/dist/lower/jsx.d.ts.map +1 -1
- package/dist/lower/jsx.js +25 -3
- package/dist/lower/jsx.mjs +1 -1
- package/dist/lower/template.cjs +1 -1
- package/dist/lower/template.d.ts +14 -1
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +101 -15
- package/dist/lower/template.mjs +1 -1
- package/dist/transform/index.cjs +5 -5
- package/dist/transform/index.mjs +12 -12
- package/dist/transform/source-locations.cjs +1 -0
- package/dist/transform/source-locations.d.ts +44 -0
- package/dist/transform/source-locations.d.ts.map +1 -0
- package/dist/transform/source-locations.js +238 -0
- package/dist/transform/source-locations.mjs +1 -0
- package/dist/transform/templates.cjs +4 -4
- package/dist/transform/templates.d.ts +12 -4
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +72 -7
- package/dist/transform/templates.mjs +11 -11
- package/dist/transform-C4ZXRVGP.mjs +8 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/chunk-PVR2SN3B.mjs +0 -1
- package/dist/chunk-QUIYULS2.mjs +0 -1
- package/dist/chunk-YR3SAEO7.mjs +0 -1
- package/dist/transform-5WC4FWJE.mjs +0 -8
package/dist/transform/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{parse as
|
|
2
|
-
`),t=e.filter(s=>/^\t+/.test(s)),r=e.filter(s=>/^ {2,}/.test(s));if(t.length===0&&r.length===0)return null;if(t.length>=r.length)return" ";let i=r.reduce((s,o)=>{let a=/^ +/.exec(o)[0].length;return Math.min(a,s)},1/0);return new Array(i+1).join(" ")}function
|
|
3
|
-
`),t=[];for(let r=0,i=0;r<e.length;r++)t.push(i),i+=e[r].length+1;return function(i){let s=0,o=t.length;for(;s<o;){let c=s+o>>1;i<t[c]?o=c:s=c+1}let a=s-1,l=i-t[a];return{line:a,column:l}}}var
|
|
1
|
+
import{parse as Yn}from"@babel/parser";var _t=44,Jt=59,Xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",We=new Uint8Array(64),Bt=new Uint8Array(128);for(let n=0;n<Xe.length;n++){let e=Xe.charCodeAt(n);We[n]=e,Bt[e]=n}function q(n,e,t){let r=e-t;r=r<0?-r<<1|1:r<<1;do{let i=r&31;r>>>=5,r>0&&(i|=32),n.write(We[i])}while(r>0);return e}var Ve=1024*16,ze=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(n){return Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString()}}:{decode(n){let e="";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e}},Ft=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(Ve)}write(n){let{buffer:e}=this;e[this.pos++]=n,this.pos===Ve&&(this.out+=ze.decode(e),this.pos=0)}flush(){let{buffer:n,out:e,pos:t}=this;return t>0?e+ze.decode(n.subarray(0,t)):e}};function Ke(n){let e=new Ft,t=0,r=0,i=0,s=0;for(let o=0;o<n.length;o++){let a=n[o];if(o>0&&e.write(Jt),a.length===0)continue;let l=0;for(let c=0;c<a.length;c++){let u=a[c];c>0&&e.write(_t),l=q(e,u[0],l),u.length!==1&&(t=q(e,u[1],t),r=q(e,u[2],r),i=q(e,u[3],i),u.length!==4&&(s=q(e,u[4],s)))}}return e.flush()}var ae=class n{constructor(e){this.bits=e instanceof n?e.bits.slice():[]}add(e){this.bits[e>>5]|=1<<(e&31)}has(e){return!!(this.bits[e>>5]&1<<(e&31))}},le=class n{constructor(e,t,r){this.start=e,this.end=t,this.original=r,this.intro="",this.outro="",this.content=r,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(e){this.outro+=e}appendRight(e){this.intro=this.intro+e}clone(){let e=new n(this.start,this.end,this.original);return e.intro=this.intro,e.outro=this.outro,e.content=this.content,e.storeName=this.storeName,e.edited=this.edited,e}contains(e){return this.start<e&&e<this.end}eachNext(e){let t=this;for(;t;)e(t),t=t.next}eachPrevious(e){let t=this;for(;t;)e(t),t=t.previous}edit(e,t,r){return this.content=e,r||(this.intro="",this.outro=""),this.storeName=t,this.edited=!0,this}prependLeft(e){this.outro=e+this.outro}prependRight(e){this.intro=e+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(e){let t=e-this.start,r=this.original.slice(0,t),i=this.original.slice(t);this.original=r;let s=new n(e,this.end,i);return s.outro=this.outro,this.outro="",this.end=e,this.edited?(s.edit("",!1),this.content=""):this.content=r,s.next=this.next,s.next&&(s.next.previous=s),s.previous=this,this.next=s,s}toString(){return this.intro+this.content+this.outro}trimEnd(e){if(this.outro=this.outro.replace(e,""),this.outro.length)return!0;let t=this.content.replace(e,"");if(t.length)return t!==this.content&&(this.split(this.start+t.length).edit("",void 0,!0),this.edited&&this.edit(t,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(e,""),this.intro.length)return!0}trimStart(e){if(this.intro=this.intro.replace(e,""),this.intro.length)return!0;let t=this.content.replace(e,"");if(t.length){if(t!==this.content){let r=this.split(this.end-t.length);this.edited&&r.edit(t,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(e,""),this.outro.length)return!0}};function Ht(){return typeof globalThis<"u"&&typeof globalThis.btoa=="function"?n=>globalThis.btoa(unescape(encodeURIComponent(n))):typeof Buffer=="function"?n=>Buffer.from(n,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}var Ut=Ht(),we=class{constructor(e){this.version=3,this.file=e.file,this.sources=e.sources,this.sourcesContent=e.sourcesContent,this.names=e.names,this.mappings=Ke(e.mappings),typeof e.x_google_ignoreList<"u"&&(this.x_google_ignoreList=e.x_google_ignoreList),typeof e.debugId<"u"&&(this.debugId=e.debugId)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+Ut(this.toString())}};function qt(n){let e=n.split(`
|
|
2
|
+
`),t=e.filter(s=>/^\t+/.test(s)),r=e.filter(s=>/^ {2,}/.test(s));if(t.length===0&&r.length===0)return null;if(t.length>=r.length)return" ";let i=r.reduce((s,o)=>{let a=/^ +/.exec(o)[0].length;return Math.min(a,s)},1/0);return new Array(i+1).join(" ")}function Xt(n,e){let t=n.split(/[/\\]/),r=e.split(/[/\\]/);for(t.pop();t[0]===r[0];)t.shift(),r.shift();if(t.length){let i=t.length;for(;i--;)t[i]=".."}return t.concat(r).join("/")}var Vt=Object.prototype.toString;function zt(n){return Vt.call(n)==="[object Object]"}function Ge(n){let e=n.split(`
|
|
3
|
+
`),t=[];for(let r=0,i=0;r<e.length;r++)t.push(i),i+=e[r].length+1;return function(i){let s=0,o=t.length;for(;s<o;){let c=s+o>>1;i<t[c]?o=c:s=c+1}let a=s-1,l=i-t[a];return{line:a,column:l}}}var Wt=/\w/,Re=class{constructor(e){this.hires=e,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(e,t,r,i){if(t.length){let s=t.length-1,o=t.indexOf(`
|
|
4
4
|
`,0),a=-1;for(;o>=0&&s>o;){let c=[this.generatedCodeColumn,e,r.line,r.column];i>=0&&c.push(i),this.rawSegments.push(c),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=o,o=t.indexOf(`
|
|
5
5
|
`,o+1)}let l=[this.generatedCodeColumn,e,r.line,r.column];i>=0&&l.push(i),this.rawSegments.push(l),this.advance(t.slice(a+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(t));this.pending=null}addUneditedChunk(e,t,r,i,s){let o=t.start,a=!0,l=!1;for(;o<t.end;){if(r[o]===`
|
|
6
|
-
`)i.line+=1,i.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0,l=!1;else{if(this.hires||a||s.has(o)){let c=[this.generatedCodeColumn,e,i.line,i.column];this.hires==="boundary"?
|
|
7
|
-
`);if(t.length>1){for(let r=0;r<t.length-1;r++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=t[t.length-1].length}},
|
|
8
|
-
`,
|
|
6
|
+
`)i.line+=1,i.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0,l=!1;else{if(this.hires||a||s.has(o)){let c=[this.generatedCodeColumn,e,i.line,i.column];this.hires==="boundary"?Wt.test(r[o])?l||(this.rawSegments.push(c),l=!0):(this.rawSegments.push(c),l=!1):this.rawSegments.push(c)}i.column+=1,this.generatedCodeColumn+=1,a=!1}o+=1}this.pending=null}advance(e){if(!e)return;let t=e.split(`
|
|
7
|
+
`);if(t.length>1){for(let r=0;r<t.length-1;r++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=t[t.length-1].length}},X=`
|
|
8
|
+
`,_={insertLeft:!1,insertRight:!1,storeName:!1},J=class n{constructor(e,t={}){let r=new le(0,e.length,e);Object.defineProperties(this,{original:{writable:!0,value:e},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:r},lastChunk:{writable:!0,value:r},lastSearchedChunk:{writable:!0,value:r},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:t.filename},indentExclusionRanges:{writable:!0,value:t.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new ae},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:t.ignoreList},offset:{writable:!0,value:t.offset||0}}),this.byStart[0]=r,this.byEnd[e.length]=r}addSourcemapLocation(e){this.sourcemapLocations.add(e)}append(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.outro+=e,this}appendLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byEnd[e];return r?r.appendLeft(t):this.intro+=t,this}appendRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byStart[e];return r?r.appendRight(t):this.outro+=t,this}clone(){let e=new n(this.original,{filename:this.filename,offset:this.offset}),t=this.firstChunk,r=e.firstChunk=e.lastSearchedChunk=t.clone();for(;t;){e.byStart[r.start]=r,e.byEnd[r.end]=r;let i=t.next,s=i&&i.clone();s&&(r.next=s,s.previous=r,r=s),t=i}return e.lastChunk=r,this.indentExclusionRanges&&(e.indentExclusionRanges=this.indentExclusionRanges.slice()),e.sourcemapLocations=new ae(this.sourcemapLocations),e.intro=this.intro,e.outro=this.outro,e}generateDecodedMap(e){e=e||{};let t=0,r=Object.keys(this.storedNames),i=new Re(e.hires),s=Ge(this.original);return this.intro&&i.advance(this.intro),this.firstChunk.eachNext(o=>{let a=s(o.start);o.intro.length&&i.advance(o.intro),o.edited?i.addEdit(t,o.content,a,o.storeName?r.indexOf(o.original):-1):i.addUneditedChunk(t,o,this.original,a,this.sourcemapLocations),o.outro.length&&i.advance(o.outro)}),this.outro&&i.advance(this.outro),{file:e.file?e.file.split(/[/\\]/).pop():void 0,sources:[e.source?Xt(e.file||"",e.source):e.file||""],sourcesContent:e.includeContent?[this.original]:void 0,names:r,mappings:i.raw,x_google_ignoreList:this.ignoreList?[t]:void 0}}generateMap(e){return new we(this.generateDecodedMap(e))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=qt(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(e,t){let r=/^[^\r\n]/gm;if(zt(e)&&(t=e,e=void 0),e===void 0&&(this._ensureindentStr(),e=this.indentStr||" "),e==="")return this;t=t||{};let i={};t.exclude&&(typeof t.exclude[0]=="number"?[t.exclude]:t.exclude).forEach(u=>{for(let f=u[0];f<u[1];f+=1)i[f]=!0});let s=t.indentStart!==!1,o=c=>s?`${e}${c}`:(s=!0,c);this.intro=this.intro.replace(r,o);let a=0,l=this.firstChunk;for(;l;){let c=l.end;if(l.edited)i[a]||(l.content=l.content.replace(r,o),l.content.length&&(s=l.content[l.content.length-1]===`
|
|
9
9
|
`));else for(a=l.start;a<c;){if(!i[a]){let u=this.original[a];u===`
|
|
10
|
-
`?s=!0:u!=="\r"&&s&&(s=!1,a===l.start||(this._splitChunk(l,a),l=l.next),l.prependRight(e))}a+=1}a=l.end,l=l.next}return this.outro=this.outro.replace(r,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(e,t){return P.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),P.insertLeft=!0),this.appendLeft(e,t)}insertRight(e,t){return P.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),P.insertRight=!0),this.prependRight(e,t)}move(e,t,r){if(e=e+this.offset,t=t+this.offset,r=r+this.offset,r>=e&&r<=t)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(t),this._split(r);let i=this.byStart[e],s=this.byEnd[t],o=i.previous,a=s.next,l=this.byStart[r];if(!l&&s===this.lastChunk)return this;let c=l?l.previous:this.lastChunk;return o&&(o.next=a),a&&(a.previous=o),c&&(c.next=i),l&&(l.previous=s),i.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=c,s.next=l||null,c||(this.firstChunk=i),l||(this.lastChunk=s),this}overwrite(e,t,r,i){return i=i||{},this.update(e,t,r,{...i,overwrite:!i.contentOnly})}update(e,t,r,i){if(e=e+this.offset,t=t+this.offset,typeof r!="string")throw new TypeError("replacement content must be a string");if(this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(t>this.original.length)throw new Error("end is out of bounds");if(e===t)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this._split(e),this._split(t),i===!0&&(P.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),P.storeName=!0),i={storeName:!0});let s=i!==void 0?i.storeName:!1,o=i!==void 0?i.overwrite:!1;if(s){let c=this.original.slice(e,t);Object.defineProperty(this.storedNames,c,{writable:!0,value:!0,enumerable:!0})}let a=this.byStart[e],l=this.byEnd[t];if(a){let c=a;for(;c!==l;){if(c.next!==this.byStart[c.end])throw new Error("Cannot overwrite across a split point");c=c.next,c.edit("",!1)}a.edit(r,s,!o)}else{let c=new te(e,t,"").edit(r,s);l.next=c,c.previous=l}return this}prepend(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this}prependLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byEnd[e];return r?r.prependLeft(t):this.intro=t+this.intro,this}prependRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byStart[e];return r?r.prependRight(t):this.outro=t+this.outro,this}remove(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.intro="",r.outro="",r.edit(""),r=t>r.end?this.byStart[r.end]:null;return this}reset(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.reset(),r=t>r.end?this.byStart[r.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let e=this.lastChunk;do{if(e.outro.length)return e.outro[e.outro.length-1];if(e.content.length)return e.content[e.content.length-1];if(e.intro.length)return e.intro[e.intro.length-1]}while(e=e.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let e=this.outro.lastIndexOf(B);if(e!==-1)return this.outro.substr(e+1);let t=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(e=r.outro.lastIndexOf(B),e!==-1)return r.outro.substr(e+1)+t;t=r.outro+t}if(r.content.length>0){if(e=r.content.lastIndexOf(B),e!==-1)return r.content.substr(e+1)+t;t=r.content+t}if(r.intro.length>0){if(e=r.intro.lastIndexOf(B),e!==-1)return r.intro.substr(e+1)+t;t=r.intro+t}}while(r=r.previous);return e=this.intro.lastIndexOf(B),e!==-1?this.intro.substr(e+1)+t:this.intro+t}slice(e=0,t=this.original.length-this.offset){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}let r="",i=this.firstChunk;for(;i&&(i.start>e||i.end<=e);){if(i.start<t&&i.end>=t)return r;i=i.next}if(i&&i.edited&&i.start!==e)throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);let s=i;for(;i;){i.intro&&(s!==i||i.start===e)&&(r+=i.intro);let o=i.start<t&&i.end>=t;if(o&&i.edited&&i.end!==t)throw new Error(`Cannot use replaced character ${t} as slice end anchor.`);let a=s===i?e-i.start:0,l=o?i.content.length+t-i.end:i.content.length;if(r+=i.content.slice(a,l),i.outro&&(!o||i.end===t)&&(r+=i.outro),o)break;i=i.next}return r}snip(e,t){let r=this.clone();return r.remove(0,e),r.remove(t,r.original.length),r}_split(e){if(this.byStart[e]||this.byEnd[e])return;let t=this.lastSearchedChunk,r=t,i=e>t.end;for(;t;){if(t.contains(e))return this._splitChunk(t,e);if(t=i?this.byStart[t.end]:this.byEnd[t.start],t===r)return;r=t}}_splitChunk(e,t){if(e.edited&&e.content.length){let i=Je(this.original)(t);throw new Error(`Cannot split a chunk that has already been edited (${i.line}:${i.column} – "${e.original}")`)}let r=e.split(t);return this.byEnd[t]=e,this.byStart[t]=r,this.byEnd[r.end]=r,e===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=e,!0}toString(){let e=this.intro,t=this.firstChunk;for(;t;)e+=t.toString(),t=t.next;return e+this.outro}isEmpty(){let e=this.firstChunk;do if(e.intro.length&&e.intro.trim()||e.content.length&&e.content.trim()||e.outro.length&&e.outro.trim())return!1;while(e=e.next);return!0}length(){let e=this.firstChunk,t=0;do t+=e.intro.length+e.content.length+e.outro.length;while(e=e.next);return t}trimLines(){return this.trim("[\\r\\n]")}trim(e){return this.trimStart(e).trimEnd(e)}trimEndAborted(e){let t=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;let r=this.lastChunk;do{let i=r.end,s=r.trimEnd(t);if(r.end!==i&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.previous}while(r);return!1}trimEnd(e){return this.trimEndAborted(e),this}trimStartAborted(e){let t=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;let r=this.firstChunk;do{let i=r.end,s=r.trimStart(t);if(r.end!==i&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.next}while(r);return!1}trimStart(e){return this.trimStartAborted(e),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(e,t){function r(s,o){return typeof t=="string"?t.replace(/\$(\$|&|\d+)/g,(a,l)=>l==="$"?"$":l==="&"?s[0]:+l<s.length?s[+l]:`$${l}`):t(...s,s.index,o,s.groups)}function i(s,o){let a,l=[];for(;a=s.exec(o);)l.push(a);return l}if(e.global)i(e,this.original).forEach(o=>{if(o.index!=null){let a=r(o,this.original);a!==o[0]&&this.overwrite(o.index,o.index+o[0].length,a)}});else{let s=this.original.match(e);if(s&&s.index!=null){let o=r(s,this.original);o!==s[0]&&this.overwrite(s.index,s.index+s[0].length,o)}}return this}_replaceString(e,t){let{original:r}=this,i=r.indexOf(e);return i!==-1&&(typeof t=="function"&&(t=t(e,i,r)),e!==t&&this.overwrite(i,i+e.length,t)),this}replace(e,t){return typeof e=="string"?this._replaceString(e,t):this._replaceRegexp(e,t)}_replaceAllString(e,t){let{original:r}=this,i=e.length;for(let s=r.indexOf(e);s!==-1;s=r.indexOf(e,s+i)){let o=r.slice(s,s+i),a=t;typeof t=="function"&&(a=t(o,s,r)),o!==a&&this.overwrite(s,s+i,a)}return this}replaceAll(e,t){if(typeof e=="string")return this._replaceAllString(e,t);if(!e.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(e,t)}};function Dt(n){switch(n.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return n.reactive?"reactive-prop":n.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function M(n){let e=[],t=new Map,r=i=>{switch(i.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of i.children)r(s);return!1;case"fragment":for(let s of i.children)r(s);return!1;case"element":{let s=!0;for(let a of i.children)r(a)||(s=!1);let o;for(let a of i.props)if(o=Dt(a),o)break;return!o&&!s&&(o=At(i)),i.static=!o,o?t.set(i,o):e.push(i),i.static}default:return!1}};for(let i of Array.isArray(n)?n:[n])r(i);return{staticElements:e,reasons:t}}function At(n){for(let e of n.children){if(e.kind==="expr")return"expression-child";if(e.kind==="component")return"component-child";if(e.kind==="control")return"control-child";if(e.kind==="element"&&!e.static||e.kind==="fragment")return"expression-child"}return"expression-child"}var ne={kind:"eager"},jt=["pointerdown","focusin","keydown"],Fe=new Set(["eager","idle","visible","interaction","media","never"]),E=class extends Error{};function ge(n){return n.startsWith("load:")}function re(n,e){let t=n.slice(5);if(!Fe.has(t))throw new E(`Unknown load strategy 'load:${t}'. Expected one of ${[...Fe].join(", ")}.`);switch(t){case"eager":return ne;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?_t(e):[...jt]};case"media":if(!e)throw new E(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new E(`Unhandled load strategy '${t}'.`)}}function _t(n){let e=n.split(/[\s,]+/).map(t=>t.trim()).filter(Boolean);if(e.length===0)throw new E("'load:interaction' was given no event names.");return e}function J(n){return n.kind!=="eager"&&n.kind!=="never"}var F=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],H=["Suspense","SuspenseList","Await"],D=["Router","Outlet","Redirect","Link"],Yn=[...F,...H,...D],ye=new Set([...F,...H]);function He(n={}){let{controlFlowModule:e="@fluixi/dom",coreModule:t="@fluixi/core",routerModule:r="@fluixi/core/router"}=n,i={};for(let s of F)i[s]=e;for(let s of H)i[s]=t;for(let s of D)i[s]=r;return i}function ie(n,e={}){let{resolver:t,isBound:r,modules:i,strategyFor:s}=e,o=He(i),a=new Map,l=new Set,c=d=>{let{name:p}=d;if(!p||p.includes(".")||r?.(p))return;let m=u(p);if(!m){l.add(p);return}let h=m.origin==="builtin"&&ye.has(p)?ne:s?.(d)??ne;d.source={...m,loading:h},a.set(p,d.source)},u=d=>{if(ye.has(d))return{module:o[d],export:d,origin:"builtin"};let p=t?.resolve(d);if(p)return{module:p.module,export:p.export,origin:"rule"};if(D.includes(d))return{module:o[d],export:d,origin:"builtin"}};return se(n,d=>{d.kind==="component"&&c(d)}),{resolved:a,unresolved:[...l]}}function se(n,e){let t=Array.isArray(n)?n:[n];for(let r of t){e(r);let i=r.children;i&&se(i,e)}}function oe(n){let e=[];se(n,s=>{s.kind==="component"&&s.source&&e.push(s)});let t=new Set,r=new Set;for(let s of e){let{module:o,loading:a}=s.source;a.kind==="eager"&&t.add(o),a.kind==="never"&&r.add(o)}let i=new Map;for(let s of e){let o=s.source;J(o.loading)&&t.has(o.module)&&(o.loading={kind:"eager"},i.set(o.module,(i.get(o.module)??0)+1))}return{collapsed:i,conflicted:[...r].filter(s=>t.has(s))}}var Bt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ue={className:"class",htmlFor:"for"},Jt=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ft=new Set(["script","style","textarea","title"]);function ve(n){return Ft.has(n)}function qe(n){return Ue[n]??n}function U(n){return n.kind!=="attr"||n.expr!==void 0||n.name.includes(":")?!1:!Jt.has(n.name)}function xe(n){if(!n.static||ve(n.tag))return!1;for(let e of n.props)if(!U(e))return!1;for(let e of n.children)if(e.kind!=="text"&&!(e.kind==="element"&&xe(e)))return!1;return!0}function q(n){let e=n.props.map(Ut).filter(Boolean).join(""),t=`<${n.tag}${e}>`;return Bt.has(n.tag)?t:`${t}${n.children.map(Ht).join("")}</${n.tag}>`}function Ht(n){if(n.kind==="text")return Xt(n.value);if(n.kind!=="element")throw new Error(`serializeStatic: unexpected ${n.kind}`);return q(n)}function Ut(n){let e=Ue[n.name]??n.name,t=n.literal;return t===!0||t===void 0?` ${e}`:t===!1||t===null?"":` ${e}="${qt(String(t))}"`}function qt(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Xt(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var zt="<!--fx-->",Vt="<!--fx/-->";function le(n){return n.kind==="expr"||n.kind==="component"||n.kind==="control"}function Wt(n){return n.kind==="text"||n.kind==="element"&&Xe(n)}function Xe(n){return n.svg||ve(n.tag)||!n.props.every(e=>U(e))?!1:n.children.every(e=>Wt(e)||le(e))}function ae(n){if(le(n))return!0;let e=n.children;return e?e.some(ae):!1}function ze(n){for(let e=0;e<n.children.length;e++){let t=n.children[e];if(t.kind==="text"&&(t.value===""||n.children[e+1]?.kind==="text"))return!1}return n.children.every(e=>e.kind!=="element"||ze(e))}function Ve(n){if(!Xe(n)||!ze(n)||!n.children.some(ae))return null;let e=[],t=[],r=0,i=o=>{let a=`_n$${r++}`;return e.push({ref:a,expr:o}),a};return s(n,"_el$"),{html:Kt(n),tag:n.tag,steps:e,holes:t};function s(o,a){let l=-1;o.children.forEach((u,d)=>{ae(u)&&(l=d)});let c=null;for(let u=0;u<=l;u++){let d=o.children[u],p=c?`${c}.nextSibling`:`${a}.firstChild`;if(le(d)){let h=i(p),g=i(`holeEnd(${h})`);t.push({parentRef:a,startRef:h,endRef:g,node:d}),c=g;continue}let m=i(p);d.kind==="element"&&ae(d)&&s(d,m),c=m}}}function Kt(n){return q(We(n)).split(Ke).join(zt+Vt)}function We(n){return{...n,children:n.children.map(e=>le(e)?{kind:"text",value:Ke}:e.kind==="element"?We(e):e)}}var Ke="\0fx-hole\0";var Ne={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},lr={version:2,module:"@fluixi/dom",symbols:[...Ne.symbols,"template","cloneTemplate","walk"]};var Gt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Yt(n){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n)}function Ye(n){return Yt(n)?n:JSON.stringify(n)}function Zt(n){return n.expr!==void 0?n.reactive?`() => (${n.expr})`:`(${n.expr})`:JSON.stringify(n.literal??!0)}function Qt(n){return n.expr!==void 0?`(${n.expr})`:JSON.stringify(n.literal??!0)}function en(n,e,t){let r=n.filter(a=>a.kind==="spread"),s=n.filter(a=>a.kind!=="spread").map(a=>`${Ye(a.name)}: ${Zt(a)}`);e!=null&&s.push(`children: ${e}`);let o=`{ ${s.join(", ")} }`;return r.length>0?(t.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${o})`):o}function Ze(n,e,t){return n.length===1?X(n[0],e,t):`[${n.map(r=>X(r,e,t)).join(", ")}]`}function Ge(n,e,t,r,i){r.add("createMemo"),r.add("createComponent");let s=e.filter(c=>c.kind==="spread"),a=e.filter(c=>c.kind!=="spread").map(c=>`get ${Ye(c.name)}() { return ${Qt(c)}; }`);t.length>0&&a.push(`get children() { return ${Ze(t,r,i)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${n}, ${l}))`}function tn(n,e){let t=qe(e.name),r=e.literal;return r===!0||r===void 0?`${n}.setAttribute(${JSON.stringify(t)}, "");`:r===!1||r===null?"":`${n}.setAttribute(${JSON.stringify(t)}, ${JSON.stringify(String(r))});`}var Qe=!1;function X(n,e,t){switch(n.kind){case"text":return JSON.stringify(n.value);case"expr":return n.reactive?`() => (${n.code})`:`(${n.code})`;case"fragment":return n.children.length===0?"null":Ze(n.children,e,t);case"component":return Ge(n.name,n.props,n.children,e,t);case"control":{let r=Gt[n.control]??n.control;return e.add(r),Ge(r,n.props,n.children,e,t)}case"element":{if(t&&n.static&&!n.svg&&xe(n)){e.add("templateNode");let a=`_tmpl$${t.length}`;return t.push({id:a,html:q(n),tag:n.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(n.tag)})`}if(t&&Qe){let a=Ve(n);if(a){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let l=`_tmpl$${t.length}`;t.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let u of a.steps)c.push(`const ${u.ref} = ${u.expr};`);for(let u of a.holes)c.push(`insert(${u.parentRef}, holeScope(${u.startRef}, () => (${X(u.node,e,t)})), ${u.endRef}, holeContent(${u.startRef}, ${u.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let r=JSON.stringify(n.tag),i="_el$",s=[],o=n.svg?`${r}, true`:r;if(s.push(`const ${i} = createNativeElement(${o});`),n.props.length>0)if(!n.svg&&n.props.every(U))for(let a of n.props)s.push(tn(i,a));else{e.add("spread");let a=n.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${en(n.props,null,e)}${a} });`)}for(let a of n.children){e.add("insert");let l=X(a,e,t),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${i}, ${l}, null);`:`insert(${i}, ${l});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}function ce(n,e){if(!e||e.length===0)return n;let t=new Map(e.map(r=>[r.id,JSON.stringify(r.html)]));return n.replace(/_tmpl\$\d+/g,r=>t.get(r)??r)}var A={name:"imperative",contract:Ne,emit(n,e){let t=new Set,r=e?.templateClone!==!1?[]:void 0;return Qe=e?.partialTemplates===!0,{code:X(n,t,r),imports:Array.from(t),templates:r}}};var nn=n=>"components"in n;function et(n,e){return n.replace(/\$(\d+)/g,(t,r)=>e[Number(r)]??t)}function rn(n,e){return typeof e=="string"?{module:e,export:n}:e}function ue(n=[]){let e=new Map,t=[],r=[];for(let o of n){if(!nn(o)){r.push(o);continue}for(let[a,l]of Object.entries(o.components)){let c=rn(a,l),u=e.get(a);if(u&&u.module!==c.module){let d=t.find(p=>p.name===a);d?d.modules.push(c.module):t.push({name:a,modules:[u.module,c.module]});continue}e.set(a,c)}}let i=new Map;return{resolve:o=>{if(i.has(o))return i.get(o);let a=e.get(o);if(!a)for(let l of r){let c=o.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:et(l.module,c),export:l.export?et(l.export,c):o};break}}return i.set(o,a),a},names:()=>[...e.keys()],conflicts:()=>t}}import{parseTemplate as sn}from"@fluixi/template-parser";function z(n){let e=n.split(/\r\n|\n|\r/),t=0;for(let i=0;i<e.length;i++)/[^ \t]/.test(e[i])&&(t=i);let r="";for(let i=0;i<e.length;i++){let s=e[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==e.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==t&&(s+=" "),r+=s)}return r}var tt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function on(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function nt(n){return n.charAt(0).toUpperCase()+n.slice(1)}var be=class{constructor(e,t){this.holes=e;this.used=t}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:t,imports:r,templates:i}=A.emit(e,{});for(let s of r)this.used.add(s);return ce(t,i)}lowerRoot(e){let t=this.lowerChildren(e);return t.length===1?t[0]:{kind:"fragment",children:t}}lowerChildren(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.kind==="Element"||i.kind==="Component"){let o=i.attributes.find(a=>a.kind==="IfDirective");if(o&&o.kind==="IfDirective"){let a=r+1;a<e.length&&this.isBlankText(e[a])&&a++;let l=e[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(u=>u.kind==="ElseDirective");t.push(this.lowerIf(i,o.hole,c?l:null)),c&&(r=a);continue}if(i.attributes.some(a=>a.kind==="EachDirective")){t.push(this.lowerEach(i));continue}}let s=this.lowerNode(i);s&&t.push(s)}return t}isBlankText(e){return e.kind==="Text"&&!e.raw&&z(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let t=z(e.value);return t?{kind:"text",value:t}:null}case"Comment":return null;case"Expression":{let t=this.hole(e.hole);return{kind:"expr",code:t.code,reactive:t.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let t=e.attributes.find(r=>r.kind==="Attribute"&&r.name==="is");if(e.tag==="component"&&t&&t.value&&t.value.kind==="hole"){let r=e.attributes.filter(s=>s!==t),i=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:r});return i.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(t.value.hole).code})`}),i}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let t=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,r=this.lowerAttributes(e.attributes),{slots:i,rest:s}=this.partitionSlots(e.children);for(let[l,c]of i){let u=c.length===1?c[0]:{kind:"fragment",children:c},d={name:l,kind:"attr",expr:this.emit(u),jsxElement:!0},p=r.findIndex(m=>m.name===l);p>=0?r[p]=d:r.push(d)}let o=e.attributes.find(l=>l.kind==="LoadDirective"),a=o?re(`load:${o.strategy}`,o.modifier):void 0;return{kind:"component",name:t,props:r,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(e){let t=new Map,r=[];for(let i of e){if(i.kind==="Element"||i.kind==="Component"){let s=i.attributes.find(o=>o.kind==="Attribute"&&o.name==="slot");if(s&&s.value&&s.value.kind==="static"){let o={...i,attributes:i.attributes.filter(c=>c!==s)},a=o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o),l=t.get(s.value.value)??[];l.push(a),t.set(s.value.value,l);continue}}r.push(i)}return{slots:t,rest:r}}lowerIf(e,t,r){let i=this.hole(t),s=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive}];if(r){let a=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let o=this.stripAndLower(e,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[o]}}lowerEach(e){let t=e.attributes.find(l=>l.kind==="EachDirective");if(!t||t.kind!=="EachDirective")return this.lowerNode(e);let r=this.hole(t.hole),i=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive}];if(t.key){let l="static"in t.key?`(item) => item[${JSON.stringify(t.key.static)}]`:this.hole(t.key.hole).code;i.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(e),o;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(e,[l]);o=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(e,c=>c.kind==="EachDirective");o=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:i,children:[{kind:"expr",code:o,reactive:!1}]}}itemArrow(e){let t=e.children.filter(r=>!this.isBlankText(r));return t.length!==1||t[0].kind!=="Expression"?null:this.hole(t[0].hole).arrow??null}stripAndLower(e,t){let r={...e,attributes:e.attributes.filter(i=>!t(i))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(e,t){let r=this.lowerAttributes(e.attributes.filter(i=>i.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:r,children:t,static:!1}:{kind:"component",name:e.tag,props:r,children:t}}lowerAttributes(e){let t=[],r=[],i=!1,s=[],o=!1,a=[];for(let l of e)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":t.push(this.plainAttr(l));break;case"PropertyBinding":t.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":t.push(this.eventProp(l));break;case"RefBinding":t.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":t.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);r.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),o=o||c.reactive;break}case"BindDirective":t.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return r.length>0&&t.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:i}),s.length>0&&t.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:o}),a.length>0&&t.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),t}eventProp(e){let t=e.name.toLowerCase(),r=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+nt(e.name),kind:"event",event:{name:t,delegated:tt.has(t)},expr:r};let s=this.wrapHandler(r,e.modifiers),o=this.eventOptions(e.modifiers),a=o?`[${s}, ${o}]`:s;return{name:"on:"+t,kind:"attr",expr:a}}wrapHandler(e,t){let r=t.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return t.includes("prevent")&&i.push("e.preventDefault();"),t.includes("stop")&&i.push("e.stopPropagation();"),!r&&i.length===0?e:`(e) => { ${r}${i.join(" ")} return (${e})(e); }`}eventOptions(e){let t=[];return e.includes("capture")&&t.push("capture: true"),e.includes("once")&&t.push("once: true"),e.includes("passive")&&t.push("passive: true"),t.length?`{ ${t.join(", ")} }`:null}bindProps(e,t){let r=e==="checked",i=r?"change":"input",s=r?"checked":"value";this.used.add("bindPair");let o=`bindPair(${t})`;return[{name:e,kind:"attr",expr:`${o}[0]()`,reactive:!0},{name:"on"+nt(i),kind:"event",event:{name:i,delegated:tt.has(i)},expr:`(e) => ${o}[1](e.target.${s})`}]}plainAttr(e){let t=e.value,r=e.name;e.name==="class"?r=t&&t.kind==="hole"&&this.hole(t.hole).object?"classList":"className":e.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(t==null)return s.literal=!0,s;if(t.kind==="static")return s.literal=t.value,s;if(t.kind==="hole"){let l=this.hole(t.hole);return s.expr=l.code,s.reactive=l.reactive,s}let o=!1,a=t.parts.map(l=>{if("text"in l)return on(l.text);let c=this.hole(l.hole);return o=o||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=o,s}};function rt(n,e,t,r={}){let{root:i}=sn(n,{svg:r.svg});return new be(e,t).lowerRoot(i.children)}function it(n,e,t={}){let r=new Set,i=rt(n,[...e],r,{svg:t.svg});M(i),ie(i,{resolver:ue(t.resolve??[]),modules:{controlFlowModule:t.controlFlowModule??"@fluixi/dom",coreModule:t.coreModule??"@fluixi/core",routerModule:t.routerModule??"@fluixi/core/router"},strategyFor:l=>l.load}),oe(i);let{code:s,imports:o,templates:a}=A.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let l of o)r.add(l);return t.hoistTemplates?{code:s,imports:[...r],ir:i,templates:a}:{code:ce(s,a),imports:[...r],ir:i}}var an="children";function j(n){switch(n.kind){case"call":return!0;case"member":return n.property!==an;case"compound":return n.parts.some(j);case"opaque":return!1}}var ln=new Set(["CallExpression","OptionalCallExpression"]),cn=new Set(["MemberExpression","OptionalMemberExpression"]);function $(n){if(!n)return{kind:"opaque"};if(ln.has(n.type))return{kind:"call"};if(cn.has(n.type)){let e=n.property;return{kind:"member",property:!(n.computed===!0)&&e?.type==="Identifier"?e.name:null}}return n.type==="ConditionalExpression"?{kind:"compound",parts:[n.test,n.consequent,n.alternate].map(V)}:n.type==="LogicalExpression"||n.type==="BinaryExpression"?{kind:"compound",parts:[n.left,n.right].map(V)}:n.type==="TemplateLiteral"?{kind:"compound",parts:n.expressions.map(V)}:n.type==="ObjectExpression"?{kind:"compound",parts:n.properties.filter(t=>(t.type==="ObjectProperty"||t.type==="Property")&&t.computed!==!0).map(t=>V(t.value))}:n.type==="ArrayExpression"?{kind:"compound",parts:n.elements.filter(t=>t!=null&&t.type!=="SpreadElement").map(V)}:{kind:"opaque"}}var V=n=>$(n);var un=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),dn=/^on[A-Z]/,pn=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),at=n=>j($(n));function W(n){if(n.type==="StringLiteral"||n.type==="NumericLiteral"||n.type==="BooleanLiteral"||n.type==="Literal"&&(typeof n.value=="string"||typeof n.value=="number"||typeof n.value=="boolean"))return n.value}var we=n=>!!n&&typeof W(n)=="string";function fn(n,e){return n.type==="JSXIdentifier"?{tag:n.name,component:n.name[0]!==n.name[0].toLowerCase()}:n.type==="JSXMemberExpression"?{tag:e.code(n),component:!0}:n.type==="JSXNamespacedName"?{tag:`${n.namespace.name}:${n.name.name}`,component:!1}:{tag:"div",component:!1}}function Re(n){return n.type==="JSXIdentifier"?n.name==="class"?"className":n.name:n.type==="JSXNamespacedName"?`${n.namespace.name}:${n.name.name}`:"unknown"}function hn(n,e){let t=Re(n.name),r=dn.test(t),i=r||t.startsWith("on:")||t==="ref",o={name:t,kind:r?"event":"attr"};if(r){let l=t.slice(2).toLowerCase();o.event={name:l,delegated:pn.has(l)}}let a=n.value;if(a==null)return o.literal=!0,o;if(we(a))return o.literal=W(a),o;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=W(l);return c!==void 0?(o.literal=c,o):(o.expr=e.code(l),o.reactive=i?!1:at(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(o.jsxElement=!0),o)}return o.literal=!0,o}function st(n,e){let t=n.value;return t==null?null:we(t)?JSON.stringify(W(t)):t.type==="JSXExpressionContainer"&&t.expression?.type!=="JSXEmptyExpression"?e.code(t.expression):null}function mn(n,e){let t=[],r=[];for(let i of n){if(i.type==="JSXSpreadAttribute"){t.push({name:"",kind:"spread",expr:e.code(i.argument)});continue}if(i.type!=="JSXAttribute"||ge(Re(i.name)))continue;let s=i.name.type==="JSXNamespacedName"?i.name.namespace.name:null;if(s==="use"){let o=i.name.name.name;e.used.add(o);let a=st(i,e);r.push(a!=null?`[${o}, () => (${a})]`:`[${o}]`);continue}if(s==="oncapture"){let o=i.name.name.name.toLowerCase(),a=st(i,e)??"undefined";t.push({name:"on:"+o,kind:"attr",expr:`[${a}, { capture: true }]`});continue}t.push(hn(i,e))}return r.length>0&&t.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),t}function ot(n,e){let t=[];for(let r of n)if(r.type==="JSXText"){let i=z(r.value);i&&t.push({kind:"text",value:i})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let i=r.expression;t.push({kind:"expr",code:e.code(i),reactive:at(i)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?t.push(lt(r,e)):r.type==="JSXSpreadChild"&&t.push({kind:"expr",code:e.code(r.expression),reactive:!1});return t}function gn(n){for(let e of n){if(e.type!=="JSXAttribute")continue;let t=Re(e.name);if(ge(t)){if(e.value&&!we(e.value))throw new E(`'${t}' needs a literal value, not an expression — the strategy is compile-time.`);return re(t,e.value?W(e.value):null)}}}function lt(n,e){if(n.type==="JSXFragment")return{kind:"fragment",children:ot(n.children,e)};let{tag:t,component:r}=fn(n.openingElement.name,e),i=mn(n.openingElement.attributes,e),s=ot(n.children,e);if(r){let o=gn(n.openingElement.attributes);return{kind:"component",name:t,props:i,children:s,...o?{load:o}:{}}}return{kind:"element",tag:t,svg:un.has(t),props:i,children:s,static:!1}}function ct(n,e){let t=lt(n,e);return M(t),t}function C(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?C(t.argument,e):C(t.value,e);return;case"ArrayPattern":for(let t of n.elements)C(t,e);return;case"AssignmentPattern":C(n.left,e);return;case"RestElement":C(n.argument,e);return}}function ut(n,e){switch(n.type){case"ImportDeclaration":for(let t of n.specifiers)C(t.local,e);return;case"VariableDeclaration":for(let t of n.declarations)C(t.id,e);return;case"FunctionDeclaration":case"ClassDeclaration":C(n.id,e);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":n.declaration&&ut(n.declaration,e);return}}function K(n){let e=new Set;for(let t of n.body)ut(t,e);return e}import{parse as xn}from"@babel/parser";function w(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?w(t.argument,e):w(t.value,e);return;case"ArrayPattern":for(let t of n.elements)w(t,e);return;case"AssignmentPattern":w(n.left,e);return;case"RestElement":w(n.argument,e);return}}function Se(n){switch(n.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return n.expressions.every(Se);case"UnaryExpression":return Se(n.argument);case"MemberExpression":return!1;default:return!1}}function de(n,e){if(!(!n||typeof n!="object")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="range"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&de(i,e);else r&&typeof r=="object"&&typeof r.type=="string"&&de(r,e)}}}function yn(n){let e=new Set;return de(n,t=>{if(t.type==="AssignmentExpression")w(t.left,e);else if(t.type==="UpdateExpression"){let r=t.argument;r?.type==="Identifier"&&e.add(r.name)}}),e}function vn(n,e){let t=new Set,r=i=>{let s=new Set;w(i,s);for(let o of s)e.has(o)&&t.add(o)};return de(n,i=>{switch(i.type){case"VariableDeclarator":r(i.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(i.id);for(let s of i.params??[])r(s);return;case"CatchClause":r(i.param);return;case"ClassDeclaration":case"ClassExpression":r(i.id);return}}),t}function dt(n,e,t){for(let r of n.properties??[]){if(r.type==="RestElement"){let u=r.argument;if(u?.type!=="Identifier"||e.length>0){let d=new Set;w(u,d);for(let p of d)t.bails.push({name:p,reason:"rest"});continue}t.rest={name:u.name,keys:[]};continue}if(r.computed){let u=new Set;w(r.value,u);for(let d of u)t.bails.push({name:d,reason:"computed"});continue}let i=r.key,s=i.type==="Identifier"?i.name:i.value,o=r.value,a;o.type==="AssignmentPattern"&&(a=o.right,o=o.left);let l=[...e,s];if(o.type==="Identifier"){if(a&&!Se(a)){t.bails.push({name:o.name,reason:"unsafe-default"});continue}t.reads.push({name:o.name,path:l,...a?{fallback:a}:{}});continue}if(o.type==="ObjectPattern"){if(a){let u=new Set;w(o,u);for(let d of u)t.bails.push({name:d,reason:"unsafe-default"});continue}dt(o,l,t);continue}let c=new Set;w(o,c);for(let u of c)t.bails.push({name:u,reason:"computed"})}}function ke(n,e){let t={reads:[],bails:[]};if(n?.type!=="ObjectPattern"||(dt(n,[],t),t.rest&&(e?.type!=="BlockStatement"?(t.bails.push({name:t.rest.name,reason:"rest"}),delete t.rest):t.rest.keys=(n.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),t.reads.length===0&&!t.rest))return t;let r=new Set(t.reads.map(a=>a.name));t.rest&&r.add(t.rest.name);let i=yn(e),s=vn(e,r),o=[];for(let a of t.reads)i.has(a.name)?t.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?t.bails.push({name:a.name,reason:"shadowed"}):o.push(a);return t.reads=o,t.rest&&i.has(t.rest.name)?(t.bails.push({name:t.rest.name,reason:"reassigned"}),delete t.rest):t.rest&&s.has(t.rest.name)&&(t.bails.push({name:t.rest.name,reason:"shadowed"}),delete t.rest),t}function Ee(n){switch(n){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function G(n,e,t=null){if(!(!n||typeof n!="object"||typeof n.type!="string")&&!n.type.startsWith("TS")&&e(n,t)!==!1)for(let r of Object.keys(n)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let i=n[r];if(Array.isArray(i))for(let s of i)G(s,e,n);else i&&typeof i=="object"&&G(i,e,n)}}function pt(n){return!!n&&n[0]>="A"&&n[0]<="Z"}function Nn(n){let e=[];return G(n,t=>{if(t.type==="FunctionDeclaration"&&pt(t.id?.name)){e.push(t);return}if(t.type==="VariableDeclarator"&&pt(t.id?.name)){let r=t.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&e.push(r)}}),e}function bn(n){let e=new Set;return G(n,t=>{t.type==="Identifier"&&e.add(t.name)}),e}function wn(n,e){if(!e)return!0;switch(e.type){case"MemberExpression":case"OptionalMemberExpression":return!(e.property===n&&!e.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(e.key===n&&!e.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return e.label!==n;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function Ce(n,e,t={}){let r=[],i=[],s=new Set;for(let o of Nn(n)){let a=o.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=ke(a,o.body);for(let h of l.bails)i.push({name:h.name,reason:h.reason,message:Ee(h.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=bn(o),u=t.parameterName??"props";for(;c.has(u);)u=`_${u}`;let d=new Map;for(let h of l.reads){let g=`${u}.${h.path.join(".")}`,x=h.fallback;d.set(h.name,x?`(${g} === undefined ? ${e.slice(x.start,x.end)} : ${g})`:g)}let p=a.typeAnnotation;if(r.push({start:a.start,end:p?.start??a.end,code:u}),l.rest){let h=l.rest.keys.map(x=>JSON.stringify(x)).join(", "),g=o.body;r.push({start:g.start+1,end:g.start+1,code:`
|
|
11
|
-
const [, ${l.rest.name}] = splitProps(${u}, [${
|
|
12
|
-
`),{code:a.toString(),map:a.generateMap({source:e,includeContent:!0,hires:!0}),diagnostics:s,rewritten:i.filter(l=>l.code!==(t.parameterName??"props")).length}}
|
|
10
|
+
`?s=!0:u!=="\r"&&s&&(s=!1,a===l.start||(this._splitChunk(l,a),l=l.next),l.prependRight(e))}a+=1}a=l.end,l=l.next}return this.outro=this.outro.replace(r,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(e,t){return _.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),_.insertLeft=!0),this.appendLeft(e,t)}insertRight(e,t){return _.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),_.insertRight=!0),this.prependRight(e,t)}move(e,t,r){if(e=e+this.offset,t=t+this.offset,r=r+this.offset,r>=e&&r<=t)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(t),this._split(r);let i=this.byStart[e],s=this.byEnd[t],o=i.previous,a=s.next,l=this.byStart[r];if(!l&&s===this.lastChunk)return this;let c=l?l.previous:this.lastChunk;return o&&(o.next=a),a&&(a.previous=o),c&&(c.next=i),l&&(l.previous=s),i.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=c,s.next=l||null,c||(this.firstChunk=i),l||(this.lastChunk=s),this}overwrite(e,t,r,i){return i=i||{},this.update(e,t,r,{...i,overwrite:!i.contentOnly})}update(e,t,r,i){if(e=e+this.offset,t=t+this.offset,typeof r!="string")throw new TypeError("replacement content must be a string");if(this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(t>this.original.length)throw new Error("end is out of bounds");if(e===t)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this._split(e),this._split(t),i===!0&&(_.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),_.storeName=!0),i={storeName:!0});let s=i!==void 0?i.storeName:!1,o=i!==void 0?i.overwrite:!1;if(s){let c=this.original.slice(e,t);Object.defineProperty(this.storedNames,c,{writable:!0,value:!0,enumerable:!0})}let a=this.byStart[e],l=this.byEnd[t];if(a){let c=a;for(;c!==l;){if(c.next!==this.byStart[c.end])throw new Error("Cannot overwrite across a split point");c=c.next,c.edit("",!1)}a.edit(r,s,!o)}else{let c=new le(e,t,"").edit(r,s);l.next=c,c.previous=l}return this}prepend(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this}prependLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byEnd[e];return r?r.prependLeft(t):this.intro=t+this.intro,this}prependRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byStart[e];return r?r.prependRight(t):this.outro=t+this.outro,this}remove(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.intro="",r.outro="",r.edit(""),r=t>r.end?this.byStart[r.end]:null;return this}reset(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.reset(),r=t>r.end?this.byStart[r.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let e=this.lastChunk;do{if(e.outro.length)return e.outro[e.outro.length-1];if(e.content.length)return e.content[e.content.length-1];if(e.intro.length)return e.intro[e.intro.length-1]}while(e=e.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let e=this.outro.lastIndexOf(X);if(e!==-1)return this.outro.substr(e+1);let t=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(e=r.outro.lastIndexOf(X),e!==-1)return r.outro.substr(e+1)+t;t=r.outro+t}if(r.content.length>0){if(e=r.content.lastIndexOf(X),e!==-1)return r.content.substr(e+1)+t;t=r.content+t}if(r.intro.length>0){if(e=r.intro.lastIndexOf(X),e!==-1)return r.intro.substr(e+1)+t;t=r.intro+t}}while(r=r.previous);return e=this.intro.lastIndexOf(X),e!==-1?this.intro.substr(e+1)+t:this.intro+t}slice(e=0,t=this.original.length-this.offset){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}let r="",i=this.firstChunk;for(;i&&(i.start>e||i.end<=e);){if(i.start<t&&i.end>=t)return r;i=i.next}if(i&&i.edited&&i.start!==e)throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);let s=i;for(;i;){i.intro&&(s!==i||i.start===e)&&(r+=i.intro);let o=i.start<t&&i.end>=t;if(o&&i.edited&&i.end!==t)throw new Error(`Cannot use replaced character ${t} as slice end anchor.`);let a=s===i?e-i.start:0,l=o?i.content.length+t-i.end:i.content.length;if(r+=i.content.slice(a,l),i.outro&&(!o||i.end===t)&&(r+=i.outro),o)break;i=i.next}return r}snip(e,t){let r=this.clone();return r.remove(0,e),r.remove(t,r.original.length),r}_split(e){if(this.byStart[e]||this.byEnd[e])return;let t=this.lastSearchedChunk,r=t,i=e>t.end;for(;t;){if(t.contains(e))return this._splitChunk(t,e);if(t=i?this.byStart[t.end]:this.byEnd[t.start],t===r)return;r=t}}_splitChunk(e,t){if(e.edited&&e.content.length){let i=Ge(this.original)(t);throw new Error(`Cannot split a chunk that has already been edited (${i.line}:${i.column} – "${e.original}")`)}let r=e.split(t);return this.byEnd[t]=e,this.byStart[t]=r,this.byEnd[r.end]=r,e===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=e,!0}toString(){let e=this.intro,t=this.firstChunk;for(;t;)e+=t.toString(),t=t.next;return e+this.outro}isEmpty(){let e=this.firstChunk;do if(e.intro.length&&e.intro.trim()||e.content.length&&e.content.trim()||e.outro.length&&e.outro.trim())return!1;while(e=e.next);return!0}length(){let e=this.firstChunk,t=0;do t+=e.intro.length+e.content.length+e.outro.length;while(e=e.next);return t}trimLines(){return this.trim("[\\r\\n]")}trim(e){return this.trimStart(e).trimEnd(e)}trimEndAborted(e){let t=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;let r=this.lastChunk;do{let i=r.end,s=r.trimEnd(t);if(r.end!==i&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.previous}while(r);return!1}trimEnd(e){return this.trimEndAborted(e),this}trimStartAborted(e){let t=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;let r=this.firstChunk;do{let i=r.end,s=r.trimStart(t);if(r.end!==i&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.next}while(r);return!1}trimStart(e){return this.trimStartAborted(e),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(e,t){function r(s,o){return typeof t=="string"?t.replace(/\$(\$|&|\d+)/g,(a,l)=>l==="$"?"$":l==="&"?s[0]:+l<s.length?s[+l]:`$${l}`):t(...s,s.index,o,s.groups)}function i(s,o){let a,l=[];for(;a=s.exec(o);)l.push(a);return l}if(e.global)i(e,this.original).forEach(o=>{if(o.index!=null){let a=r(o,this.original);a!==o[0]&&this.overwrite(o.index,o.index+o[0].length,a)}});else{let s=this.original.match(e);if(s&&s.index!=null){let o=r(s,this.original);o!==s[0]&&this.overwrite(s.index,s.index+s[0].length,o)}}return this}_replaceString(e,t){let{original:r}=this,i=r.indexOf(e);return i!==-1&&(typeof t=="function"&&(t=t(e,i,r)),e!==t&&this.overwrite(i,i+e.length,t)),this}replace(e,t){return typeof e=="string"?this._replaceString(e,t):this._replaceRegexp(e,t)}_replaceAllString(e,t){let{original:r}=this,i=e.length;for(let s=r.indexOf(e);s!==-1;s=r.indexOf(e,s+i)){let o=r.slice(s,s+i),a=t;typeof t=="function"&&(a=t(o,s,r)),o!==a&&this.overwrite(s,s+i,a)}return this}replaceAll(e,t){if(typeof e=="string")return this._replaceAllString(e,t);if(!e.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(e,t)}};function Kt(n){switch(n.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return n.reactive?"reactive-prop":n.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function B(n){let e=[],t=new Map,r=i=>{switch(i.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of i.children)r(s);return!1;case"fragment":for(let s of i.children)r(s);return!1;case"element":{let s=!0;for(let a of i.children)r(a)||(s=!1);let o;for(let a of i.props)if(o=Kt(a),o)break;return!o&&!s&&(o=Gt(i)),i.static=!o,o?t.set(i,o):e.push(i),i.static}default:return!1}};for(let i of Array.isArray(n)?n:[n])r(i);return{staticElements:e,reasons:t}}function Gt(n){for(let e of n.children){if(e.kind==="expr")return"expression-child";if(e.kind==="component")return"component-child";if(e.kind==="control")return"control-child";if(e.kind==="element"&&!e.static||e.kind==="fragment")return"expression-child"}return"expression-child"}var ce={kind:"eager"},Yt=["pointerdown","focusin","keydown"],Ye=new Set(["eager","idle","visible","interaction","media","never"]),O=class extends Error{};function Ee(n){return n.startsWith("load:")}function ue(n,e){let t=n.slice(5);if(!Ye.has(t))throw new O(`Unknown load strategy 'load:${t}'. Expected one of ${[...Ye].join(", ")}.`);switch(t){case"eager":return ce;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?Zt(e):[...Yt]};case"media":if(!e)throw new O(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new O(`Unhandled load strategy '${t}'.`)}}function Zt(n){let e=n.split(/[\s,]+/).map(t=>t.trim()).filter(Boolean);if(e.length===0)throw new O("'load:interaction' was given no event names.");return e}function V(n){return n.kind!=="eager"&&n.kind!=="never"}var z=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],W=["Suspense","SuspenseList","Await"],F=["Router","Outlet","Redirect","Link"],xr=[...z,...W,...F],ke=new Set([...z,...W]);function Ze(n={}){let{controlFlowModule:e="@fluixi/dom",coreModule:t="@fluixi/core",routerModule:r="@fluixi/core/router"}=n,i={};for(let s of z)i[s]=e;for(let s of W)i[s]=t;for(let s of F)i[s]=r;return i}function de(n,e={}){let{resolver:t,isBound:r,modules:i,strategyFor:s}=e,o=Ze(i),a=new Map,l=new Set,c=f=>{let{name:d}=f;if(!d||d.includes(".")||r?.(d))return;let h=u(d);if(!h){l.add(d);return}let m=h.origin==="builtin"&&ke.has(d)?ce:s?.(f)??ce;f.source={...h,loading:m},a.set(d,f.source)},u=f=>{if(ke.has(f))return{module:o[f],export:f,origin:"builtin"};let d=t?.resolve(f);if(d)return{module:d.module,export:d.export,origin:"rule"};if(F.includes(f))return{module:o[f],export:f,origin:"builtin"}};return fe(n,f=>{f.kind==="component"&&c(f)}),{resolved:a,unresolved:[...l]}}function fe(n,e){let t=Array.isArray(n)?n:[n];for(let r of t){e(r);let i=r.children;i&&fe(i,e)}}function pe(n){let e=[];fe(n,s=>{s.kind==="component"&&s.source&&e.push(s)});let t=new Set,r=new Set;for(let s of e){let{module:o,loading:a}=s.source;a.kind==="eager"&&t.add(o),a.kind==="never"&&r.add(o)}let i=new Map;for(let s of e){let o=s.source;V(o.loading)&&t.has(o.module)&&(o.loading={kind:"eager"},i.set(o.module,(i.get(o.module)??0)+1))}return{collapsed:i,conflicted:[...r].filter(s=>t.has(s))}}var Qt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Qe={className:"class",htmlFor:"for"},en=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),tn=new Set(["script","style","textarea","title"]);function Ce(n){return tn.has(n)}function et(n){return Qe[n]??n}function K(n){return n.kind!=="attr"||n.expr!==void 0||n.name.includes(":")?!1:!en.has(n.name)}function Ie(n){if(!n.static||Ce(n.tag))return!1;for(let e of n.props)if(!K(e))return!1;for(let e of n.children)if(e.kind!=="text"&&!(e.kind==="element"&&Ie(e)))return!1;return!0}function G(n){let e=n.props.map(rn).filter(Boolean).join(""),t=`<${n.tag}${e}>`;return Qt.has(n.tag)?t:`${t}${n.children.map(nn).join("")}</${n.tag}>`}function nn(n){if(n.kind==="text")return on(n.value);if(n.kind!=="element")throw new Error(`serializeStatic: unexpected ${n.kind}`);return G(n)}function rn(n){let e=Qe[n.name]??n.name,t=n.literal;return t===!0||t===void 0?` ${e}`:t===!1||t===null?"":` ${e}="${sn(String(t))}"`}function sn(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function on(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function $e(n){let e=[],t,r=i=>{t??=i.at?.file,e.push(i.at?.line??0,i.at?.column??0);for(let s of i.children)s.kind==="element"&&r(s)};return r(n),t&&e.some(i=>i!==0)?{file:t,pos:e}:void 0}var an="<!--fx-->",ln="<!--fx/-->";function he(n){return n.kind==="expr"||n.kind==="component"||n.kind==="control"}function cn(n){return n.kind==="text"||n.kind==="element"&&tt(n)}function tt(n){return n.svg||Ce(n.tag)||!n.props.every(e=>K(e))?!1:n.children.every(e=>cn(e)||he(e))}function me(n){if(he(n))return!0;let e=n.children;return e?e.some(me):!1}function nt(n){for(let e=0;e<n.children.length;e++){let t=n.children[e];if(t.kind==="text"&&(t.value===""||n.children[e+1]?.kind==="text"))return!1}return n.children.every(e=>e.kind!=="element"||nt(e))}function rt(n){if(!tt(n)||!nt(n)||!n.children.some(me))return null;let e=[],t=[],r=0,i=o=>{let a=`_n$${r++}`;return e.push({ref:a,expr:o}),a};return s(n,"_el$"),{html:un(n),tag:n.tag,steps:e,holes:t};function s(o,a){let l=-1;o.children.forEach((u,f)=>{me(u)&&(l=f)});let c=null;for(let u=0;u<=l;u++){let f=o.children[u],d=c?`${c}.nextSibling`:`${a}.firstChild`;if(he(f)){let m=i(d),y=i(`holeEnd(${m})`);t.push({parentRef:a,startRef:m,endRef:y,node:f}),c=y;continue}let h=i(d);f.kind==="element"&&me(f)&&s(f,h),c=h}}}function un(n){return G(it(n)).split(st).join(an+ln)}function it(n){return{...n,children:n.children.map(e=>he(e)?{kind:"text",value:st}:e.kind==="element"?it(e):e)}}var st="\0fx-hole\0";var Te={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Pr={version:2,module:"@fluixi/dom",symbols:[...Te.symbols,"template","cloneTemplate","walk"]};var A="@fluixi/reactive/signal",C={$signal:{export:"signal",module:A,returns:"signal-handle"},$memo:{export:"memo",module:A,returns:"memo-handle"},$effect:{export:"effect",module:A,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:A,returns:"resource-handle"},$selector:{export:"createSelector",module:A,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:A,returns:"memo-accessor"},$untrack:{export:"untrack",module:A,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},ot={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},dn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core"],fn=new RegExp(`\\$(?:${Object.keys(C).map(n=>n.slice(1)).join("|")})\\s*\\(`);function at(n){return fn.test(n)}function ge(n){return Object.prototype.hasOwnProperty.call(C,n)}function lt(n){return dn.includes(n)}function b(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties??[])t.type==="RestElement"?b(t.argument,e):b(t.value,e);return;case"ArrayPattern":for(let t of n.elements??[])b(t,e);return;case"AssignmentPattern":b(n.left,e);return;case"RestElement":b(n.argument,e);return}}function Y(n,e){if(!(!n||typeof n!="object"||typeof n.type!="string")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)Y(i,e);else r&&typeof r=="object"&&Y(r,e)}}}function pn(n,e){if(n.type!=="CallExpression")return;let t=n.callee;if(t?.type!=="Identifier")return;let r=t.name,i=e.primitives.get(r);if(i)return i;let s=C[r];if(s&&!e.shadowed.has(r))return s.returns}function mn(n,e,t){if(Array.isArray(e)){n.type==="ArrayPattern"&&n.elements.forEach((r,i)=>{let s=e[i];r?.type==="Identifier"&&s&&t.set(r.name,s)});return}n.type==="Identifier"&&t.set(n.name,e)}function ct(n){let e=new Set;return Y(n,t=>{switch(t.type){case"VariableDeclarator":b(t.id,e);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":b(t.id,e);for(let r of t.params??[])b(r,e);return;case"ClassDeclaration":case"ClassExpression":b(t.id,e);return;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":b(t.local,e);return;case"CatchClause":b(t.param,e);return}}),e}function ye(n){let e={kinds:new Map,primitives:new Map,shadowed:new Set},t=n;Y(t,r=>{let i=new Set;if(r.type==="VariableDeclarator")b(r.id,i);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")b(r.id,i);else if(r.type==="ImportDefaultSpecifier"||r.type==="ImportNamespaceSpecifier")b(r.local,i);else if(r.type==="ImportSpecifier")b(r.local,i);else if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="FunctionDeclaration")for(let s of r.params??[])b(s,i);for(let s of i)C[s]&&e.shadowed.add(s)});for(let r of t.body??[])if(r.type==="ImportDeclaration"&<(r.source?.value))for(let i of r.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,o=s.type==="Identifier"?s.name:s.value,a=ot[o];a&&e.primitives.set(i.local.name,a)}return Y(t,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let i=pn(r.init,e);i&&mn(r.id,i,e.kinds)}),e}var Pe="__fx_source",hn="__fx_component",gn="__fx_hole",Z=(n,e,t,r)=>`(globalThis.${gn} ?? ((f) => f))(${n},${e},${t}${r===void 0?"":`,${JSON.stringify(r)}`})`,yn="__fx_props",dt=(n,e)=>`(globalThis.${yn} ?? ((p) => p))(${n},${JSON.stringify(e)})`,ft=new Set(["signal","memo","effect","store","resource","watch","createSignal","createMemo","createEffect","createStore","createResource"]);function pt(n){for(let e of ft)if(n.includes(e))return!0;return n.includes("$signal")||n.includes("$memo")||n.includes("$effect")||n.includes("$store")}var vn=new Set(["IfStatement","ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement","LabeledStatement","WithStatement"]);function bn(n,e){return!e||n.type==="BlockStatement"?!1:vn.has(e.type)}function ut(n){return n.type==="ExportNamedDeclaration"||n.type==="ExportDefaultDeclaration"}function Nn(n){return n.type.endsWith("Statement")||n.type==="VariableDeclaration"}function Oe(n,e,t=[]){if(!(!n||typeof n.type!="string")){e(n,t),t.push(n);for(let r of Object.keys(n)){if(r==="loc"||r==="parent")continue;let i=n[r];if(Array.isArray(i))for(let s of i)Oe(s,e,t);else i&&typeof i.type=="string"&&Oe(i,e,t)}t.pop()}}function xn(n){let e=n[n.length-1];if(e?.type!=="VariableDeclarator")return;let t=e.id;if(t?.type==="Identifier")return t.name;if(t?.type==="ArrayPattern"){let r=t.elements?.[0];if(r?.type==="Identifier")return r.name}}function Sn(n){if(n.type==="FunctionDeclaration"){let e=n.id?.name;return e&&e[0]===e[0]?.toUpperCase()?e:void 0}if(n.type==="VariableDeclarator"){let e=n.id,t=n.init;if(e?.type!=="Identifier"||!t||t.type!=="ArrowFunctionExpression"&&t.type!=="FunctionExpression")return;let r=e.name;return r[0]===r[0]?.toUpperCase()?r:void 0}}function mt(n,e){let t=[],r=new Set,{primitives:i,shadowed:s}=ye(n);return Oe(n,(o,a)=>{let l=Sn(o);if(l){let g=o.loc?.start,$=o.end;for(let j=a.length-1;j>=0;j--){let M=a[j];if(M.type!=="VariableDeclaration"&&M.type!=="ExportNamedDeclaration"&&M.type!=="ExportDefaultDeclaration")break;$=M.end}g&&t.push({start:$,end:$,code:`;globalThis.${hn}?.(${JSON.stringify(l)},${JSON.stringify(e)},${g.line},${g.column});`})}if(o.type!=="CallExpression")return;let c=o.callee;if(c?.type!=="Identifier")return;let u=c.name,f=ge(u)&&!s.has(u)?C[u]:void 0,d=i.has(u)||ft.has(u);if(!f&&!d)return;let h=o.loc?.start;if(!h)return;let m,y,S=-1;for(let g=a.length-1;g>=0;g--)if(Nn(a[g])||ut(a[g])){m=a[g],y=a[g-1],S=g;break}if(!m)return;let x=m.start,v=m.end;for(let g=S-1;g>=0&&ut(a[g]);g--)x=a[g].start,v=a[g].end,y=a[g-1];if(r.has(x))return;r.add(x);let I=xn(a),L=[JSON.stringify(e),String(h.line),String(h.column),I?JSON.stringify(I):void 0].filter(g=>g!==void 0).join(","),k=`globalThis.${Pe}?.(${L});`;if(bn(m,y)){t.push({start:x,end:x,code:`{${k}`}),t.push({start:v,end:v,code:"}"});return}t.push({start:x,end:x,code:k})}),{edits:t,marked:t.length}}var wn={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Rn(n){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n)}function yt(n){return Rn(n)?n:JSON.stringify(n)}function En(n){if(n.expr!==void 0){if(n.name==="ref"&&n.at)return Z(`(${n.expr})`,n.at.line,n.at.column,n.expr);if(!n.reactive)return`(${n.expr})`;let e=`() => (${n.expr})`;return n.at?Z(e,n.at.line,n.at.column,n.directive):e}return JSON.stringify(n.literal??!0)}function kn(n){return n.expr!==void 0?`(${n.expr})`:JSON.stringify(n.literal??!0)}function Cn(n,e,t){let r=n.filter(a=>a.kind==="spread"),s=n.filter(a=>a.kind!=="spread").map(a=>`${yt(a.name)}: ${En(a)}`);e!=null&&s.push(`children: ${e}`);let o=`{ ${s.join(", ")} }`;return r.length>0?(t.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${o})`):o}function ht(n,e){return e?Z(n,e.line,e.column):n}function vt(n,e,t){return n.length===1?Q(n[0],e,t):`[${n.map(r=>Q(r,e,t)).join(", ")}]`}function gt(n,e,t,r,i,s){r.add("createMemo"),r.add("createComponent");let o=e.filter(d=>d.kind==="spread"),a=e.filter(d=>d.kind!=="spread"),l=a.map(d=>`get ${yt(d.name)}() { return ${kn(d)}; }`);t.length>0&&l.push(`get children() { return ${vt(t,r,i)}; }`);let c=`{ ${l.join(", ")} }`;o.length>0&&(r.add("mergeProps"),c=`mergeProps(${o.map(d=>d.expr).join(", ")}, ${c})`);let u={};for(let d of a)d.at&&(u[d.name]=[d.at.line,d.at.column]);return Object.keys(u).length&&(c=dt(c,u)),`createMemo((${s?`globalThis.${Pe}?.(${JSON.stringify(s.file)},${s.line},${s.column},${JSON.stringify(n)}), `:""}() => createComponent(${n}, ${c})))`}function In(n,e){let t=et(e.name),r=e.literal;return r===!0||r===void 0?`${n}.setAttribute(${JSON.stringify(t)}, "");`:r===!1||r===null?"":`${n}.setAttribute(${JSON.stringify(t)}, ${JSON.stringify(String(r))});`}var bt=!1;function Q(n,e,t){switch(n.kind){case"text":return JSON.stringify(n.value);case"expr":{if(!n.reactive)return`(${n.code})`;let r=`() => (${n.code})`;return n.at?Z(r,n.at.line,n.at.column):r}case"fragment":return n.children.length===0?"null":vt(n.children,e,t);case"component":return ht(gt(n.name,n.props,n.children,e,t,n.at),n.bindAt??n.at);case"control":{let r=wn[n.control]??n.control;return e.add(r),ht(gt(r,n.props,n.children,e,t),n.bindAt)}case"element":{if(t&&n.static&&!n.svg&&Ie(n)){e.add("templateNode");let a=`_tmpl$${t.length}`;t.push({id:a,html:G(n),tag:n.tag,svg:!1});let l=$e(n);return l?`templateNode(${a}, ${JSON.stringify(n.tag)}, false, false, ${JSON.stringify(l)})`:`templateNode(${a}, ${JSON.stringify(n.tag)})`}if(t&&bt){let a=rt(n);if(a){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let l=`_tmpl$${t.length}`;t.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=$e(n),u=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true${c?`, false, ${JSON.stringify(c)}`:""});`];for(let f of a.steps)u.push(`const ${f.ref} = ${f.expr};`);for(let f of a.holes)u.push(`insert(${f.parentRef}, holeScope(${f.startRef}, () => (${Q(f.node,e,t)})), ${f.endRef}, holeContent(${f.startRef}, ${f.endRef}));`);return u.push("return _el$;"),`(() => { ${u.join(" ")} })()`}}e.add("createNativeElement");let r=JSON.stringify(n.tag),i="_el$",s=[],o=n.at?`${r}, ${n.svg}, ${JSON.stringify(n.at)}`:n.svg?`${r}, true`:r;if(s.push(`const ${i} = createNativeElement(${o});`),n.props.length>0)if(!n.svg&&n.props.every(K))for(let a of n.props)s.push(In(i,a));else{e.add("spread");let a=n.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${Cn(n.props,null,e)}${a} });`)}for(let a of n.children){e.add("insert");let l=Q(a,e,t),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${i}, ${l}, null);`:`insert(${i}, ${l});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}function ve(n,e){if(!e||e.length===0)return n;let t=new Map(e.map(r=>[r.id,JSON.stringify(r.html)]));return n.replace(/_tmpl\$\d+/g,r=>t.get(r)??r)}var H={name:"imperative",contract:Te,emit(n,e){let t=new Set,r=e?.templateClone!==!1?[]:void 0;return bt=e?.partialTemplates===!0,{code:Q(n,t,r),imports:Array.from(t),templates:r}}};var $n=n=>"components"in n;function Nt(n,e){return n.replace(/\$(\d+)/g,(t,r)=>e[Number(r)]??t)}function Tn(n,e){return typeof e=="string"?{module:e,export:n}:e}function be(n=[]){let e=new Map,t=[],r=[];for(let o of n){if(!$n(o)){r.push(o);continue}for(let[a,l]of Object.entries(o.components)){let c=Tn(a,l),u=e.get(a);if(u&&u.module!==c.module){let f=t.find(d=>d.name===a);f?f.modules.push(c.module):t.push({name:a,modules:[u.module,c.module]});continue}e.set(a,c)}}let i=new Map;return{resolve:o=>{if(i.has(o))return i.get(o);let a=e.get(o);if(!a)for(let l of r){let c=o.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:Nt(l.module,c),export:l.export?Nt(l.export,c):o};break}}return i.set(o,a),a},names:()=>[...e.keys()],conflicts:()=>t}}import{parseTemplate as On}from"@fluixi/template-parser";function ee(n){let e=n.split(/\r\n|\n|\r/),t=0;for(let i=0;i<e.length;i++)/[^ \t]/.test(e[i])&&(t=i);let r="";for(let i=0;i<e.length;i++){let s=e[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==e.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==t&&(s+=" "),r+=s)}return r}var xt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Pn(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function St(n){return n.charAt(0).toUpperCase()+n.slice(1)}var Le=class{constructor(e,t,r,i){this.holes=e;this.used=t;this.sourceFile=r;this.positionAt=i}tagAt(e){let t=e.loc?.start;if(!this.sourceFile||!this.positionAt||t==null)return;let{line:r,column:i}=this.positionAt(t);return{file:this.sourceFile,line:r,column:i}}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:t,imports:r,templates:i}=H.emit(e,{});for(let s of r)this.used.add(s);return ve(t,i)}lowerRoot(e){let t=this.lowerChildren(e);return t.length===1?t[0]:{kind:"fragment",children:t}}lowerChildren(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.kind==="Element"||i.kind==="Component"){let o=i.attributes.find(a=>a.kind==="IfDirective");if(o&&o.kind==="IfDirective"){let a=r+1;a<e.length&&this.isBlankText(e[a])&&a++;let l=e[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(u=>u.kind==="ElseDirective");t.push(this.lowerIf(i,o.hole,c?l:null)),c&&(r=a);continue}if(i.attributes.some(a=>a.kind==="EachDirective")){t.push(this.lowerEach(i));continue}}let s=this.lowerNode(i);s&&t.push(s)}return t}isBlankText(e){return e.kind==="Text"&&!e.raw&&ee(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let t=ee(e.value);return t?{kind:"text",value:t}:null}case"Comment":return null;case"Expression":{let t=this.hole(e.hole);return{kind:"expr",code:t.code,reactive:t.reactive,...t.at?{at:t.at}:{}}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let t=e.attributes.find(i=>i.kind==="Attribute"&&i.name==="is");if(e.tag==="component"&&t&&t.value&&t.value.kind==="hole"){let i=e.attributes.filter(o=>o!==t),s=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:i});return s.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(t.value.hole).code})`}),s}let r=this.tagAt(e);return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1,...r?{at:r}:{}}}lowerComponent(e){let t=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,r=this.lowerAttributes(e.attributes),{slots:i,rest:s}=this.partitionSlots(e.children);for(let[u,f]of i){let d=f.length===1?f[0]:{kind:"fragment",children:f},h={name:u,kind:"attr",expr:this.emit(d),jsxElement:!0},m=r.findIndex(y=>y.name===u);m>=0?r[m]=h:r.push(h)}let o=e.attributes.find(u=>u.kind==="LoadDirective"),a=o?ue(`load:${o.strategy}`,o.modifier):void 0,l=r.find(u=>u.at&&u.reactive)?.at,c=this.tagAt(e);return{kind:"component",name:t,props:r,children:this.lowerChildren(s),...c?{at:c}:{},...l?{bindAt:l}:{},...a?{load:a}:{}}}partitionSlots(e){let t=new Map,r=[];for(let i of e){if(i.kind==="Element"||i.kind==="Component"){let s=i.attributes.find(o=>o.kind==="Attribute"&&o.name==="slot");if(s&&s.value&&s.value.kind==="static"){let o={...i,attributes:i.attributes.filter(c=>c!==s)},a=o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o),l=t.get(s.value.value)??[];l.push(a),t.set(s.value.value,l);continue}}r.push(i)}return{slots:t,rest:r}}lowerIf(e,t,r){let i=this.hole(t),s=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive,...i.at?{at:i.at}:{}}];if(r){let l=this.stripAndLower(r,c=>c.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(l),jsxElement:!0})}let o=this.stripAndLower(e,l=>l.kind==="IfDirective"),a=this.tagAt(e);return{kind:"component",name:"Show",props:s,children:[o],...a?{at:a}:{},...i.at?{bindAt:i.at}:{}}}lowerEach(e){let t=e.attributes.find(c=>c.kind==="EachDirective");if(!t||t.kind!=="EachDirective")return this.lowerNode(e);let r=this.hole(t.hole),i=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive,...r.at?{at:r.at}:{}}];if(t.key){let c="static"in t.key?`(item) => item[${JSON.stringify(t.key.static)}]`:this.hole(t.key.hole).code;i.push({name:"by",kind:"attr",expr:c})}let s=this.itemArrow(e),o;if(s){let c={kind:"expr",code:s.body,reactive:s.bodyReactive},u=this.rebuildWithChildren(e,[c]);o=`(${s.params.join(", ")}) => (${this.emit(u)})`}else{let c=this.stripAndLower(e,u=>u.kind==="EachDirective");o=`() => (${this.emit(c)})`}let a=[{kind:"expr",code:o,reactive:!1}],l=this.tagAt(e);return{kind:"component",name:"For",props:i,children:a,...l?{at:l}:{},...r.at?{bindAt:r.at}:{}}}itemArrow(e){let t=e.children.filter(r=>!this.isBlankText(r));return t.length!==1||t[0].kind!=="Expression"?null:this.hole(t[0].hole).arrow??null}stripAndLower(e,t){let r={...e,attributes:e.attributes.filter(i=>!t(i))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(e,t){let r=this.lowerAttributes(e.attributes.filter(i=>i.kind!=="EachDirective"));if(e.kind==="Element"){let i=this.tagAt(e);return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:r,children:t,static:!1,...i?{at:i}:{}}}return{kind:"component",name:e.tag,props:r,children:t}}lowerAttributes(e){let t=[],r=[],i=!1,s,o=[],a=!1,l,c=[];for(let u of e)switch(u.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":t.push(this.plainAttr(u));break;case"PropertyBinding":t.push({name:u.name,kind:"prop",expr:this.hole(u.hole).code,reactive:this.hole(u.hole).reactive,...this.hole(u.hole).at?{at:this.hole(u.hole).at}:{}});break;case"EventBinding":t.push(this.eventProp(u));break;case"RefBinding":t.push({name:"ref",kind:"ref",expr:this.hole(u.hole).code,reactive:this.hole(u.hole).reactive,...this.hole(u.hole).at?{at:this.hole(u.hole).at}:{}});break;case"Spread":t.push({name:"",kind:"spread",expr:this.hole(u.hole).code});break;case"ClassDirective":{let f=this.hole(u.hole);r.push(`${JSON.stringify(u.name)}: ${f.code}`),i=i||f.reactive,s??=f.at;break}case"StyleDirective":{let f=this.hole(u.hole);o.push(`${JSON.stringify(u.name)}: ${f.code}`),a=a||f.reactive,l??=f.at;break}case"BindDirective":t.push(...this.bindProps(u.name,this.hole(u.hole)));break;case"UseDirective":{let f=u.name??(u.hole!=null?this.hole(u.hole).code:null);if(!f)break;c.push(u.name!=null&&u.hole!=null?`[${f}, () => (${this.hole(u.hole).code})]`:`[${f}]`);break}}return r.length>0&&t.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:i,...s?{at:s}:{}}),o.length>0&&t.push({name:"style",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:a,...l?{at:l}:{}}),c.length>0&&t.push({name:"use",kind:"attr",expr:`[${c.join(", ")}]`}),t}eventProp(e){let t=e.name.toLowerCase(),r=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+St(e.name),kind:"event",event:{name:t,delegated:xt.has(t)},expr:r};let s=this.wrapHandler(r,e.modifiers),o=this.eventOptions(e.modifiers),a=o?`[${s}, ${o}]`:s;return{name:"on:"+t,kind:"attr",expr:a}}wrapHandler(e,t){let r=t.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return t.includes("prevent")&&i.push("e.preventDefault();"),t.includes("stop")&&i.push("e.stopPropagation();"),!r&&i.length===0?e:`(e) => { ${r}${i.join(" ")} return (${e})(e); }`}eventOptions(e){let t=[];return e.includes("capture")&&t.push("capture: true"),e.includes("once")&&t.push("once: true"),e.includes("passive")&&t.push("passive: true"),t.length?`{ ${t.join(", ")} }`:null}bindProps(e,t){let r=t.code,i=e==="checked",s=i?"change":"input",o=i?"checked":"value";this.used.add("bindPair");let a=`bindPair(${r})`;return[{name:e,kind:"attr",expr:`${a}[0]()`,reactive:!0,directive:`bind:${e}`,...t.at?{at:t.at}:{}},{name:"on"+St(s),kind:"event",event:{name:s,delegated:xt.has(s)},expr:`(e) => ${a}[1](e.target.${o})`}]}plainAttr(e){let t=e.value,r=e.name;e.name==="class"?r=t&&t.kind==="hole"&&this.hole(t.hole).object?"classList":"className":e.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(t==null)return s.literal=!0,s;if(t.kind==="static")return s.literal=t.value,s;if(t.kind==="hole"){let c=this.hole(t.hole);return s.expr=c.code,s.reactive=c.reactive,c.at&&(s.at=c.at),s}let o=!1,a,l=t.parts.map(c=>{if("text"in c)return Pn(c.text);let u=this.hole(c.hole);return o=o||u.reactive,a??=u.at,"${"+u.code+"}"}).join("");return s.expr="`"+l+"`",s.reactive=o,a&&(s.at=a),s}};function wt(n,e,t,r={}){let{root:i}=On(n,{svg:r.svg});return new Le(e,t,r.sourceFile,r.positionAt).lowerRoot(i.children)}function Rt(n,e,t={}){let r=new Set,i=wt(n,[...e],r,{svg:t.svg,...t.sourceFile?{sourceFile:t.sourceFile}:{},...t.positionAt?{positionAt:t.positionAt}:{}});B(i),de(i,{resolver:be(t.resolve??[]),modules:{controlFlowModule:t.controlFlowModule??"@fluixi/dom",coreModule:t.coreModule??"@fluixi/core",routerModule:t.routerModule??"@fluixi/core/router"},strategyFor:l=>l.load}),pe(i);let{code:s,imports:o,templates:a}=H.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let l of o)r.add(l);return t.hoistTemplates?{code:s,imports:[...r],ir:i,templates:a}:{code:ve(s,a),imports:[...r],ir:i}}var Ln="children";function U(n){switch(n.kind){case"call":return!0;case"member":return n.property!==Ln;case"compound":return n.parts.some(U);case"opaque":return!1}}var Mn=new Set(["CallExpression","OptionalCallExpression"]),An=new Set(["MemberExpression","OptionalMemberExpression"]);function D(n){if(!n)return{kind:"opaque"};if(Mn.has(n.type))return{kind:"call"};if(An.has(n.type)){let e=n.property;return{kind:"member",property:!(n.computed===!0)&&e?.type==="Identifier"?e.name:null}}return n.type==="ConditionalExpression"?{kind:"compound",parts:[n.test,n.consequent,n.alternate].map(te)}:n.type==="LogicalExpression"||n.type==="BinaryExpression"?{kind:"compound",parts:[n.left,n.right].map(te)}:n.type==="TemplateLiteral"?{kind:"compound",parts:n.expressions.map(te)}:n.type==="ObjectExpression"?{kind:"compound",parts:n.properties.filter(t=>(t.type==="ObjectProperty"||t.type==="Property")&&t.computed!==!0).map(t=>te(t.value))}:n.type==="ArrayExpression"?{kind:"compound",parts:n.elements.filter(t=>t!=null&&t.type!=="SpreadElement").map(te)}:{kind:"opaque"}}var te=n=>D(n);var Dn=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),jn=/^on[A-Z]/,_n=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),Ct=n=>U(D(n)),ne=(n,e)=>{if(!e.sourceFile)return;let t=n.loc?.start;return t?{line:t.line,column:t.column}:void 0};function re(n){if(n.type==="StringLiteral"||n.type==="NumericLiteral"||n.type==="BooleanLiteral"||n.type==="Literal"&&(typeof n.value=="string"||typeof n.value=="number"||typeof n.value=="boolean"))return n.value}var Me=n=>!!n&&typeof re(n)=="string";function Jn(n,e){return n.type==="JSXIdentifier"?{tag:n.name,component:n.name[0]!==n.name[0].toLowerCase()}:n.type==="JSXMemberExpression"?{tag:e.code(n),component:!0}:n.type==="JSXNamespacedName"?{tag:`${n.namespace.name}:${n.name.name}`,component:!1}:{tag:"div",component:!1}}function Ae(n){return n.type==="JSXIdentifier"?n.name==="class"?"className":n.name:n.type==="JSXNamespacedName"?`${n.namespace.name}:${n.name.name}`:"unknown"}function Bn(n,e){let t=Ae(n.name),r=jn.test(t),i=r||t.startsWith("on:")||t==="ref",o={name:t,kind:r?"event":"attr"};if(r){let l=t.slice(2).toLowerCase();o.event={name:l,delegated:_n.has(l)}}let a=n.value;if(a==null)return o.literal=!0,o.at=ne(n,e),o;if(Me(a))return o.literal=re(a),o.at=ne(a,e),o;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=re(l);return c!==void 0?(o.literal=c,o.at=ne(l,e),o):(o.expr=e.code(l),o.reactive=i?!1:Ct(l),o.at=ne(l,e),(l.type==="JSXElement"||l.type==="JSXFragment")&&(o.jsxElement=!0),o)}return o.literal=!0,o}function Et(n,e){let t=n.value;return t==null?null:Me(t)?JSON.stringify(re(t)):t.type==="JSXExpressionContainer"&&t.expression?.type!=="JSXEmptyExpression"?e.code(t.expression):null}function Fn(n,e){let t=[],r=[];for(let i of n){if(i.type==="JSXSpreadAttribute"){t.push({name:"",kind:"spread",expr:e.code(i.argument)});continue}if(i.type!=="JSXAttribute"||Ee(Ae(i.name)))continue;let s=i.name.type==="JSXNamespacedName"?i.name.namespace.name:null;if(s==="use"){let o=i.name.name.name;e.used.add(o);let a=Et(i,e);r.push(a!=null?`[${o}, () => (${a})]`:`[${o}]`);continue}if(s==="oncapture"){let o=i.name.name.name.toLowerCase(),a=Et(i,e)??"undefined";t.push({name:"on:"+o,kind:"attr",expr:`[${a}, { capture: true }]`});continue}t.push(Bn(i,e))}return r.length>0&&t.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),t}function kt(n,e){let t=[];for(let r of n)if(r.type==="JSXText"){let i=ee(r.value);i&&t.push({kind:"text",value:i})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let i=r.expression,s=Ct(i);t.push({kind:"expr",code:e.code(i),reactive:s,...s?{at:ne(i,e)}:{}})}}else r.type==="JSXElement"||r.type==="JSXFragment"?t.push(It(r,e)):r.type==="JSXSpreadChild"&&t.push({kind:"expr",code:e.code(r.expression),reactive:!1});return t}function Hn(n){for(let e of n){if(e.type!=="JSXAttribute")continue;let t=Ae(e.name);if(Ee(t)){if(e.value&&!Me(e.value))throw new O(`'${t}' needs a literal value, not an expression — the strategy is compile-time.`);return ue(t,e.value?re(e.value):null)}}}function It(n,e){if(n.type==="JSXFragment")return{kind:"fragment",children:kt(n.children,e)};let{tag:t,component:r}=Jn(n.openingElement.name,e),i=Fn(n.openingElement.attributes,e),s=kt(n.children,e),o=e.sourceFile&&n.loc?.start?{file:e.sourceFile,line:n.loc.start.line,column:n.loc.start.column}:void 0;if(r){let a=Hn(n.openingElement.attributes);return{kind:"component",name:t,props:i,children:s,...a?{load:a}:{},...o?{at:o}:{}}}return{kind:"element",tag:t,svg:Dn.has(t),props:i,children:s,static:!1,...o?{at:o}:{}}}function $t(n,e){let t=It(n,e);return B(t),t}function P(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?P(t.argument,e):P(t.value,e);return;case"ArrayPattern":for(let t of n.elements)P(t,e);return;case"AssignmentPattern":P(n.left,e);return;case"RestElement":P(n.argument,e);return}}function Tt(n,e){switch(n.type){case"ImportDeclaration":for(let t of n.specifiers)P(t.local,e);return;case"VariableDeclaration":for(let t of n.declarations)P(t.id,e);return;case"FunctionDeclaration":case"ClassDeclaration":P(n.id,e);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":n.declaration&&Tt(n.declaration,e);return}}function ie(n){let e=new Set;for(let t of n.body)Tt(t,e);return e}import{parse as Xn}from"@babel/parser";function E(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?E(t.argument,e):E(t.value,e);return;case"ArrayPattern":for(let t of n.elements)E(t,e);return;case"AssignmentPattern":E(n.left,e);return;case"RestElement":E(n.argument,e);return}}function De(n){switch(n.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return n.expressions.every(De);case"UnaryExpression":return De(n.argument);case"MemberExpression":return!1;default:return!1}}function Ne(n,e){if(!(!n||typeof n!="object")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="range"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&Ne(i,e);else r&&typeof r=="object"&&typeof r.type=="string"&&Ne(r,e)}}}function Un(n){let e=new Set;return Ne(n,t=>{if(t.type==="AssignmentExpression")E(t.left,e);else if(t.type==="UpdateExpression"){let r=t.argument;r?.type==="Identifier"&&e.add(r.name)}}),e}function qn(n,e){let t=new Set,r=i=>{let s=new Set;E(i,s);for(let o of s)e.has(o)&&t.add(o)};return Ne(n,i=>{switch(i.type){case"VariableDeclarator":r(i.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(i.id);for(let s of i.params??[])r(s);return;case"CatchClause":r(i.param);return;case"ClassDeclaration":case"ClassExpression":r(i.id);return}}),t}function Ot(n,e,t){for(let r of n.properties??[]){if(r.type==="RestElement"){let u=r.argument;if(u?.type!=="Identifier"||e.length>0){let f=new Set;E(u,f);for(let d of f)t.bails.push({name:d,reason:"rest"});continue}t.rest={name:u.name,keys:[]};continue}if(r.computed){let u=new Set;E(r.value,u);for(let f of u)t.bails.push({name:f,reason:"computed"});continue}let i=r.key,s=i.type==="Identifier"?i.name:i.value,o=r.value,a;o.type==="AssignmentPattern"&&(a=o.right,o=o.left);let l=[...e,s];if(o.type==="Identifier"){if(a&&!De(a)){t.bails.push({name:o.name,reason:"unsafe-default"});continue}t.reads.push({name:o.name,path:l,...a?{fallback:a}:{}});continue}if(o.type==="ObjectPattern"){if(a){let u=new Set;E(o,u);for(let f of u)t.bails.push({name:f,reason:"unsafe-default"});continue}Ot(o,l,t);continue}let c=new Set;E(o,c);for(let u of c)t.bails.push({name:u,reason:"computed"})}}function je(n,e){let t={reads:[],bails:[]};if(n?.type!=="ObjectPattern"||(Ot(n,[],t),t.rest&&(e?.type!=="BlockStatement"?(t.bails.push({name:t.rest.name,reason:"rest"}),delete t.rest):t.rest.keys=(n.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),t.reads.length===0&&!t.rest))return t;let r=new Set(t.reads.map(a=>a.name));t.rest&&r.add(t.rest.name);let i=Un(e),s=qn(e,r),o=[];for(let a of t.reads)i.has(a.name)?t.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?t.bails.push({name:a.name,reason:"shadowed"}):o.push(a);return t.reads=o,t.rest&&i.has(t.rest.name)?(t.bails.push({name:t.rest.name,reason:"reassigned"}),delete t.rest):t.rest&&s.has(t.rest.name)&&(t.bails.push({name:t.rest.name,reason:"shadowed"}),delete t.rest),t}function _e(n){switch(n){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function se(n,e,t=null){if(!(!n||typeof n!="object"||typeof n.type!="string")&&!n.type.startsWith("TS")&&e(n,t)!==!1)for(let r of Object.keys(n)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let i=n[r];if(Array.isArray(i))for(let s of i)se(s,e,n);else i&&typeof i=="object"&&se(i,e,n)}}function Pt(n){return!!n&&n[0]>="A"&&n[0]<="Z"}function Vn(n){let e=[];return se(n,t=>{if(t.type==="FunctionDeclaration"&&Pt(t.id?.name)){e.push(t);return}if(t.type==="VariableDeclarator"&&Pt(t.id?.name)){let r=t.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&e.push(r)}}),e}function zn(n){let e=new Set;return se(n,t=>{t.type==="Identifier"&&e.add(t.name)}),e}function Wn(n,e){if(!e)return!0;switch(e.type){case"MemberExpression":case"OptionalMemberExpression":return!(e.property===n&&!e.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(e.key===n&&!e.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return e.label!==n;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function Je(n,e,t={}){let r=[],i=[],s=new Set;for(let o of Vn(n)){let a=o.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=je(a,o.body);for(let m of l.bails)i.push({name:m.name,reason:m.reason,message:_e(m.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=zn(o),u=t.parameterName??"props";for(;c.has(u);)u=`_${u}`;let f=new Map;for(let m of l.reads){let y=`${u}.${m.path.join(".")}`,S=m.fallback;f.set(m.name,S?`(${y} === undefined ? ${e.slice(S.start,S.end)} : ${y})`:y)}let d=a.typeAnnotation;if(r.push({start:a.start,end:d?.start??a.end,code:u}),l.rest){let m=l.rest.keys.map(S=>JSON.stringify(S)).join(", "),y=o.body;r.push({start:y.start+1,end:y.start+1,code:`
|
|
11
|
+
const [, ${l.rest.name}] = splitProps(${u}, [${m}]);`}),s.add("splitProps")}let h=[];se(o.body,(m,y)=>{if(m.type!=="Identifier")return;let S=f.get(m.name);if(!S)return;let x=y?.type==="ObjectProperty"&&y.shorthand&&y.value===m;if(!x&&!Wn(m,y))return;let v=l.reads.find(I=>I.name===m.name).path;h.push({node:m,parent:x?y:null,text:S,property:v[v.length-1]})});for(let m of h)m.parent?r.push({start:m.parent.start,end:m.parent.end,code:`${m.node.name}: ${m.text}`}):r.push({start:m.node.start,end:m.node.end,code:m.text}),Kn(m.node,u,m.property)}return{edits:r,diagnostics:i,used:s}}function Kn(n,e,t){n.type="MemberExpression",n.computed=!1,n.optional=!1,n.object={type:"Identifier",name:e,start:n.start,end:n.start},n.property={type:"Identifier",name:t,start:n.end,end:n.end},delete n.name}function Gn(n,e="module.tsx",t={}){let r=Xn(n,{sourceType:"module",plugins:["typescript","jsx"],errorRecovery:!0}),{edits:i,diagnostics:s,used:o}=Je(r.program,n,t),a=new J(n);for(let l of i)l.start===l.end?a.appendLeft(l.start,l.code):a.overwrite(l.start,l.end,l.code);return o.has("splitProps")&&!ie(r.program).has("splitProps")&&a.prepend(`import { splitProps } from ${JSON.stringify(t.runtimeModule??"@fluixi/dom")};
|
|
12
|
+
`),{code:a.toString(),map:a.generateMap({source:e,includeContent:!0,hires:!0}),diagnostics:s,rewritten:i.filter(l=>l.code!==(t.parameterName??"props")).length}}function Be(n,e){if(!(!n||typeof n!="object"||typeof n.type!="string")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)Be(i,e);else r&&typeof r=="object"&&Be(r,e)}}}function Lt(n){let e=[],t=[],r=new Map,i=new Set,{shadowed:s}=ye(n);return Be(n,o=>{if(o.type!=="CallExpression")return;let a=o.callee;if(a?.type!=="Identifier")return;let l=a.name;if(!ge(l))return;if(s.has(l)){i.has(l)||(i.add(l),t.push({name:l,message:`${l} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,start:a.start}));return}let c=C[l];e.push({start:a.start,end:a.end,code:c.export});let u=r.get(c.module)??new Set;u.add(c.export),r.set(c.module,u)}),{edits:e,diagnostics:t,imports:r}}function Mt(n,e){let t=[];for(let[r,i]of[...n.imports].sort(([s],[o])=>s.localeCompare(o))){let s=[...i].filter(o=>!e.has(o)).sort();s.length&&t.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return t.length?`${t.join(`
|
|
13
13
|
`)}
|
|
14
|
-
`:""}var
|
|
15
|
-
`?
|
|
14
|
+
`:""}var Zn=new Set(z),Qn=new Set(W),er=new Set(F),tr=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function Se(n,e,t=null,r=""){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(let i of n)Se(i,e,t,r);return}typeof n.type=="string"&&e(n,t,r);for(let i of Object.keys(n))i==="loc"||i==="leadingComments"||i==="trailingComments"||Se(n[i],e,typeof n.type=="string"?n:t,i)}}var Fe=n=>n.type==="JSXElement"||n.type==="JSXFragment";function nr(n,e,t){return Fe(n)?!(e&&Fe(e)&&t==="children"):!1}function rr(n,e){return n.type==="TaggedTemplateExpression"&&n.tag?.type==="Identifier"&&(n.tag.name===e||n.tag.name==="svg")}function At(n){return n.filter(e=>!n.some(t=>t!==e&&t.start<=e.start&&t.end>=e.end&&t.end-t.start>e.end-e.start&&!(e.start===e.end&&(e.start===t.start||e.start===t.end))))}function xe(n,e,t,r){let i=At(r.filter(o=>o.start>=e&&o.end<=t)).sort((o,a)=>a.start-o.start),s=n.slice(e,t);for(let o of i)s=s.slice(0,o.start-e)+o.code+s.slice(o.end-e);return s}function ir(n,e,t,r=!1){let i=r?e.loc?.start:void 0,s={code:xe(n,e.start,e.end,t),reactive:U(D(e)),...i?{at:{line:i.line,column:i.column}}:{}};return e.type==="ArrowFunctionExpression"&&e.body?.type!=="BlockStatement"&&(s.arrow={params:e.params.map(o=>xe(n,o.start,o.end,t)),body:xe(n,e.body.start,e.body.end,t),bodyReactive:U(D(e.body))}),e.type==="ObjectExpression"&&(s.object=!0),s}function Dt(n,e,t){if(!e||e.length===0)return n;let r=new Map;for(let i of e){let s=`${i.svg?"svg:":""}${i.html}`,o=t.get(s);o||(o=`_fxTmpl$${t.size}`,t.set(s,o)),r.set(i.id,o)}return n.replace(/_tmpl\$\d+/g,i=>r.get(i)??i)}function He(n,e){if(n.kind==="component"&&n.load&&!n.source&&V(n.load)&&(e.ignoredLoad.has(n.name)||e.ignoredLoad.set(n.name,n.load)),n.kind==="component"&&n.source){let t=n.source;t.origin==="builtin"?e.builtins.add(n.name):V(t.loading)&&!e.resolved.has(n.name)?e.deferred.set(n.name,t):(e.deferred.delete(n.name),e.resolved.set(n.name,t))}if("props"in n&&n.props)for(let t of n.props)t.kind==="event"&&t.event?.delegated&&e.delegatedEvents.add(t.event.name);if("children"in n&&n.children)for(let t of n.children)He(t,e)}function sr(n,e){for(let t of n.body??[])if(t.type==="ImportDeclaration")for(let r of t.specifiers??[]){if(r.local?.name!==e)continue;if(r.type==="ImportNamespaceSpecifier")return;let i=r.type==="ImportDefaultSpecifier"?"default":r.imported?.name??r.imported?.value;return{module:t.source.value,export:i,declaration:t,specifier:r}}}function or(n,e){for(let t of n.body??[])if(t.type==="ImportDeclaration"){for(let r of t.specifiers??[])if(r.type==="ImportNamespaceSpecifier"&&r.local?.name===e)return!0}return!1}function ar(n,e,t){let r=!1;return Se(n,i=>{r||i.type!=="Identifier"||i.name!==e||i.start===t.local?.start&&i.end===t.local?.end||(r=!0)}),r}function lr(n){let e=[`kind: ${JSON.stringify(n.kind)}`];return n.kind==="visible"&&n.rootMargin&&e.push(`rootMargin: ${JSON.stringify(n.rootMargin)}`),n.kind==="interaction"&&e.push(`events: ${JSON.stringify(n.events)}`),n.kind==="media"&&e.push(`query: ${JSON.stringify(n.query)}`),`{ ${e.join(", ")} }`}function cr(n){let e=[0];for(let t=0;t<n.length;t++)n.charCodeAt(t)===10&&e.push(t+1);return t=>{let r=0,i=e.length-1;for(;r<i;){let s=r+i+1>>1;e[s]<=t?r=s:i=s-1}return{line:r+1,column:t-e[r]}}}function ur(n){let e=[];return n.quasi.quasis.forEach((t,r)=>{if(e.push({kind:"static",text:t.value.cooked??t.value.raw,start:t.start}),r<n.quasi.expressions.length){let i=n.quasi.expressions[r];e.push({kind:"hole",index:r,start:i.start,end:i.end})}}),e}function dr(n,e){if(!e)return n;let t=e.endsWith("/")?e:`${e}/`;return n.startsWith(t)?n.slice(t.length):n}function fr(n,e,t={}){let r=t.litTag??"html",i=t.format??"both",s=i!=="jsx",o=i!=="lit",a=s&&(n.includes(`${r}\``)||n.includes("svg`")),l=t.intrinsics!==!1&&at(n),c=t.sourceLocations===!0&&pt(n),u=dr(e,t.sourceRoot);if(!a&&!(o&&n.includes("<"))&&!l&&!c)return null;let f=Yn(n,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),d=[];Se(f.program,(p,w,N)=>{(s&&rr(p,r)||o&&nr(p,w,N))&&d.push(p)});let h=t.propsDestructure===!1?{edits:[],diagnostics:[],used:new Set}:Je(f.program,n,{runtimeModule:t.runtimeModule}),m=t.intrinsics===!1?{edits:[],diagnostics:[],imports:new Map}:Lt(f.program),y=t.sourceLocations===!0?mt(f.program,u):{edits:[],marked:0};if(d.length===0&&h.edits.length===0&&y.edits.length===0&&m.edits.length===0&&m.diagnostics.length===0&&h.diagnostics.length===0)return null;d.sort((p,w)=>w.start-p.start||p.end-w.end);let x=new Set(h.used),v={builtins:new Set,resolved:new Map,deferred:new Map,delegatedEvents:new Set,ignoredLoad:new Map,unresolved:new Set,declared:ct(f.program)},I=new Map,L=[...h.edits,...m.edits,...y.edits];for(let p of d){let w=d.some(R=>R!==p&&R.start<=p.start&&R.end>=p.end&&R.end-R.start>p.end-p.start);if(Fe(p)){L.push({start:p.start,end:p.end,code:pr(n,p,L,w,x,v,I,t,u)});continue}let N=p.quasi.expressions.map(R=>ir(n,R,L,t.sourceLocations===!0)),T=Rt(ur(p),N,{...t,hoistTemplates:!0,...t.sourceLocations===!0?{sourceFile:u,positionAt:cr(n)}:{},templateClone:t.templateClone??!0,partialTemplates:w?!1:t.partialTemplates??!0,svg:p.tag.name==="svg"});for(let R of T.imports)x.add(R);He(T.ir,v),L.push({start:p.start,end:p.end,code:Dt(T.code,T.templates,I)})}let k=new J(n);for(let p of At(L))p.start===p.end?k.appendLeft(p.start,p.code):k.overwrite(p.start,p.end,p.code);let g=ie(f.program),$=new Map;for(let[p]of v.ignoredLoad)g.has(p)||$.set(p,"unsupplied");for(let[p,w]of[...v.ignoredLoad]){if(!g.has(p))continue;let N=sr(f.program,p);if(!N){$.set(p,or(f.program,p)?"namespace":"local");continue}if(ar(f.program,p,N.specifier)){$.set(p,"value");continue}let T=N.declaration.specifiers.filter(oe=>oe!==N.specifier),R=T.length===0&&n[N.declaration.end]===`
|
|
15
|
+
`?N.declaration.end+1:N.declaration.end;k.overwrite(N.declaration.start,R,T.length===0?"":`import { ${T.map(oe=>n.slice(oe.start,oe.end)).join(", ")} } from ${JSON.stringify(N.declaration.source.value)};`),v.deferred.set(p,{module:N.module,export:N.export,origin:"rule",loading:w}),g.delete(p),v.ignoredLoad.delete(p)}let j=mr(x,v,I,g,t);j&&k.prepend(j);let M=Mt(m,g);M&&k.prepend(M);let jt={value:p=>`${p} is used as a value here, not only as a tag, so its import has to stay — deferring would hand those references a lazy wrapper instead of the component. Defer it at the point it is rendered, or keep it eager.`,namespace:p=>`${p} came in through a namespace import, which has no single export to defer. Import ${p} by name.`,local:p=>`${p} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:p=>`nothing supplies ${p}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},Ue=[...v.ignoredLoad].map(([p,w])=>({name:p,strategy:w,message:`load:${w.kind} has no effect on <${p}>: ${jt[$.get(p)??"unsupplied"](p)}`})),qe=[...v.unresolved].map(p=>({name:p,message:`<${p}> is not defined: nothing imports it and no \`resolve\` rule supplies it. This compiles to a reference to a name that does not exist, so the component renders nothing. Import ${p}, or add a \`resolve\` rule for it.`}));return{code:k.toString(),map:k.generateMap({source:e,includeContent:!0,hires:!0}),...Ue.length?{loadDiagnostics:Ue}:{},...qe.length?{unresolvedDiagnostics:qe}:{},...h.diagnostics.length?{propsDiagnostics:h.diagnostics}:{},...m.diagnostics.length?{intrinsicDiagnostics:m.diagnostics}:{}}}function pr(n,e,t,r,i,s,o,a,l){let c=$t(e,{code:d=>xe(n,d.start,d.end,t),used:i,...a.sourceLocations===!0&&l?{sourceFile:l}:{}});B(c);let u=de(c,{resolver:be(a.resolve??[]),isBound:d=>s.declared.has(d),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"@fluixi/core",routerModule:a.routerModule??"@fluixi/core/router"},strategyFor:d=>d.load});for(let d of u.unresolved)s.unresolved.add(d);pe(c);let f=H.emit(c,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let d of f.imports)i.add(d);return He(c,s),Dt(f.code,f.templates,o)}function mr(n,e,t,r,i){let s=i.runtimeModule??"@fluixi/dom",o=i.coreModule??"@fluixi/core",a=new Map,l=(d,h)=>a.set(d,[...a.get(d)??[],h]),c=new Set(n);for(let d of e.builtins)c.add(d);e.delegatedEvents.size>0&&c.add("delegateEvents");for(let d of[...c].sort())r.has(d)||(tr.has(d)?l(i.reactiveModule??"@fluixi/reactive/signal",d):er.has(d)?l(i.routerModule??"@fluixi/core/router",d):Qn.has(d)?l(o,d):Zn.has(d)?l(i.controlFlowModule??s,d):l(s,d));for(let[d,h]of e.resolved)r.has(d)||l(h.module,h.export==="default"?`default as ${d}`:d===h.export?d:`${h.export} as ${d}`);let u=[];for(let[d,h]of a)u.push(`import { ${h.join(", ")} } from ${JSON.stringify(d)};`);let f=[...e.deferred].filter(([d])=>!r.has(d));if(f.length>0){r.has("deferred")||u.push(`import { deferred } from ${JSON.stringify(o)};`);for(let[d,h]of f)u.push(`const ${d} = deferred(() => import(${JSON.stringify(h.module)}), { strategy: ${lr(h.loading)}, export: ${JSON.stringify(h.export)} });`)}for(let[d,h]of t)u.push(`const ${h} = ${JSON.stringify(d.startsWith("svg:")?d.slice(4):d)};`);return e.delegatedEvents.size>0&&u.push(`delegateEvents(${JSON.stringify([...e.delegatedEvents])});`),u.length>0?u.join(`
|
|
16
16
|
`)+`
|
|
17
|
-
`:null}export{
|
|
17
|
+
`:null}export{_e as explainBail,ie as moduleBindings,je as planPropsDestructure,D as shapeOf,Gn as transformProps,fr as transformTemplates};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of U(t))!J.call(e,i)&&i!==r&&h(e,i,{get:()=>t[i],enumerable:!(n=B(t,i))||n.enumerable});return e};var G=e=>W(h({},"__esModule",{value:!0}),e);var oe={};H(oe,{COMPONENT_MARKER:()=>P,HOLE_MARKER:()=>k,PROPS_MARKER:()=>F,SOURCE_MARKER:()=>O,collectSourceEdits:()=>se,markHole:()=>X,markProps:()=>Y,mayHaveReactiveCall:()=>Z});module.exports=G(oe);var u="@fluixi/reactive/signal",d={$signal:{export:"signal",module:u,returns:"signal-handle"},$memo:{export:"memo",module:u,returns:"memo-handle"},$effect:{export:"effect",module:u,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:u,returns:"resource-handle"},$selector:{export:"createSelector",module:u,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:u,returns:"memo-accessor"},$untrack:{export:"untrack",module:u,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},M={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},q=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core"],ce=new RegExp(`\\$(?:${Object.keys(d).map(e=>e.slice(1)).join("|")})\\s*\\(`);function _(e){return Object.prototype.hasOwnProperty.call(d,e)}function A(e){return q.includes(e)}function c(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let r of e.properties??[])r.type==="RestElement"?c(r.argument,t):c(r.value,t);return;case"ArrayPattern":for(let r of e.elements??[])c(r,t);return;case"AssignmentPattern":c(e.left,t);return;case"RestElement":c(e.argument,t);return}}function N(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let r of Object.keys(e)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let n=e[r];if(Array.isArray(n))for(let i of n)N(i,t);else n&&typeof n=="object"&&N(n,t)}}}function z(e,t){if(e.type!=="CallExpression")return;let r=e.callee;if(r?.type!=="Identifier")return;let n=r.name,i=t.primitives.get(n);if(i)return i;let o=d[n];if(o&&!t.shadowed.has(n))return o.returns}function Q(e,t,r){if(Array.isArray(t)){e.type==="ArrayPattern"&&e.elements.forEach((n,i)=>{let o=t[i];n?.type==="Identifier"&&o&&r.set(n.name,o)});return}e.type==="Identifier"&&r.set(e.name,t)}function T(e){let t={kinds:new Map,primitives:new Map,shadowed:new Set},r=e;N(r,n=>{let i=new Set;if(n.type==="VariableDeclarator")c(n.id,i);else if(n.type==="FunctionDeclaration"||n.type==="ClassDeclaration")c(n.id,i);else if(n.type==="ImportDefaultSpecifier"||n.type==="ImportNamespaceSpecifier")c(n.local,i);else if(n.type==="ImportSpecifier")c(n.local,i);else if(n.type==="FunctionExpression"||n.type==="ArrowFunctionExpression"||n.type==="FunctionDeclaration")for(let o of n.params??[])c(o,i);for(let o of i)d[o]&&t.shadowed.add(o)});for(let n of r.body??[])if(n.type==="ImportDeclaration"&&A(n.source?.value))for(let i of n.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let o=i.imported,l=o.type==="Identifier"?o.name:o.value,a=M[l];a&&t.primitives.set(i.local.name,a)}return N(r,n=>{if(n.type!=="VariableDeclarator"||!n.init)return;let i=z(n.init,t);i&&Q(n.id,i,t.kinds)}),t}var O="__fx_source",P="__fx_component",k="__fx_hole",X=(e,t,r,n)=>`(globalThis.${k} ?? ((f) => f))(${e},${t},${r}${n===void 0?"":`,${JSON.stringify(n)}`})`,F="__fx_props",Y=(e,t)=>`(globalThis.${F} ?? ((p) => p))(${e},${JSON.stringify(t)})`,j=new Set(["signal","memo","effect","store","resource","watch","createSignal","createMemo","createEffect","createStore","createResource"]);function Z(e){for(let t of j)if(e.includes(t))return!0;return e.includes("$signal")||e.includes("$memo")||e.includes("$effect")||e.includes("$store")}var ee=new Set(["IfStatement","ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement","LabeledStatement","WithStatement"]);function te(e,t){return!t||e.type==="BlockStatement"?!1:ee.has(t.type)}function C(e){return e.type==="ExportNamedDeclaration"||e.type==="ExportDefaultDeclaration"}function ne(e){return e.type.endsWith("Statement")||e.type==="VariableDeclaration"}function E(e,t,r=[]){if(!(!e||typeof e.type!="string")){t(e,r),r.push(e);for(let n of Object.keys(e)){if(n==="loc"||n==="parent")continue;let i=e[n];if(Array.isArray(i))for(let o of i)E(o,t,r);else i&&typeof i.type=="string"&&E(i,t,r)}r.pop()}}function re(e){let t=e[e.length-1];if(t?.type!=="VariableDeclarator")return;let r=t.id;if(r?.type==="Identifier")return r.name;if(r?.type==="ArrayPattern"){let n=r.elements?.[0];if(n?.type==="Identifier")return n.name}}function ie(e){if(e.type==="FunctionDeclaration"){let t=e.id?.name;return t&&t[0]===t[0]?.toUpperCase()?t:void 0}if(e.type==="VariableDeclarator"){let t=e.id,r=e.init;if(t?.type!=="Identifier"||!r||r.type!=="ArrowFunctionExpression"&&r.type!=="FunctionExpression")return;let n=t.name;return n[0]===n[0]?.toUpperCase()?n:void 0}}function se(e,t){let r=[],n=new Set,{primitives:i,shadowed:o}=T(e);return E(e,(l,a)=>{let b=ie(l);if(b){let s=l.loc?.start,I=l.end;for(let R=a.length-1;R>=0;R--){let g=a[R];if(g.type!=="VariableDeclaration"&&g.type!=="ExportNamedDeclaration"&&g.type!=="ExportDefaultDeclaration")break;I=g.end}s&&r.push({start:I,end:I,code:`;globalThis.${P}?.(${JSON.stringify(b)},${JSON.stringify(t)},${s.line},${s.column});`})}if(l.type!=="CallExpression")return;let v=l.callee;if(v?.type!=="Identifier")return;let p=v.name,V=_(p)&&!o.has(p)?d[p]:void 0,K=i.has(p)||j.has(p);if(!V&&!K)return;let y=l.loc?.start;if(!y)return;let m,S,$=-1;for(let s=a.length-1;s>=0;s--)if(ne(a[s])||C(a[s])){m=a[s],S=a[s-1],$=s;break}if(!m)return;let f=m.start,x=m.end;for(let s=$-1;s>=0&&C(a[s]);s--)f=a[s].start,x=a[s].end,S=a[s-1];if(n.has(f))return;n.add(f);let w=re(a),L=[JSON.stringify(t),String(y.line),String(y.column),w?JSON.stringify(w):void 0].filter(s=>s!==void 0).join(","),D=`globalThis.${O}?.(${L});`;if(te(m,S)){r.push({start:f,end:f,code:`{${D}`}),r.push({start:x,end:x,code:"}"});return}r.push({start:f,end:f,code:D})}),{edits:r,marked:r.length}}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface SourceEdit {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SourceLocationsResult {
|
|
7
|
+
edits: SourceEdit[];
|
|
8
|
+
/** How many creation sites were marked. */
|
|
9
|
+
marked: number;
|
|
10
|
+
}
|
|
11
|
+
/** Installed by @fluixi/devtools; undefined everywhere else. */
|
|
12
|
+
export declare const SOURCE_MARKER = "__fx_source";
|
|
13
|
+
/** Where a component was declared. Keyed by name, since that is all the runtime carries. */
|
|
14
|
+
export declare const COMPONENT_MARKER = "__fx_component";
|
|
15
|
+
/**
|
|
16
|
+
* Where one reactive hole was written. This one wraps: the position has to travel with the
|
|
17
|
+
* accessor to wherever the dom wires it up. A template is emitted as one overwrite, so the
|
|
18
|
+
* source map has a single entry for the root and every hole traces back to it.
|
|
19
|
+
*
|
|
20
|
+
* `?? (f => f)` and not `?.()`: the value is the accessor, and returning undefined would
|
|
21
|
+
* delete the binding.
|
|
22
|
+
*/
|
|
23
|
+
export declare const HOLE_MARKER = "__fx_hole";
|
|
24
|
+
/**
|
|
25
|
+
* `_(() => x(), 9, 25)`, or the accessor untouched when nothing is watching.
|
|
26
|
+
*
|
|
27
|
+
* `name` is the source text the value came from, for a `ref` where knowing which variable
|
|
28
|
+
* holds the element is the whole question.
|
|
29
|
+
*/
|
|
30
|
+
export declare const markHole: (accessor: string, line: number, column: number, name?: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Where each prop of a component tag was written.
|
|
33
|
+
*
|
|
34
|
+
* The props object is built as getters, so nothing in it can carry a position of its own.
|
|
35
|
+
* The marker takes the object and a name-to-position map, and hands the object straight
|
|
36
|
+
* back — devtools keeps the map, and a build without it passes the object through.
|
|
37
|
+
*/
|
|
38
|
+
export declare const PROPS_MARKER = "__fx_props";
|
|
39
|
+
/** `_({ get a() {…} }, {"a":[9,25]})`, or the object untouched when nothing is watching. */
|
|
40
|
+
export declare const markProps: (object: string, at: Record<string, [number, number]>) => string;
|
|
41
|
+
/** Cheap enough to run before parsing. */
|
|
42
|
+
export declare function mayHaveReactiveCall(code: string): boolean;
|
|
43
|
+
export declare function collectSourceEdits(program: unknown, filename: string): SourceLocationsResult;
|
|
44
|
+
//# sourceMappingURL=source-locations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-locations.d.ts","sourceRoot":"","sources":["../../src/transform/source-locations.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gEAAgE;AAChE,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAE3C,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ,MAGE,CAAC;AAEN;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC,4FAA4F;AAC5F,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAG,MACF,CAAC;AAQhF,0CAA0C;AAC1C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKzD;AAuED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CA+G5F"}
|