what-compiler 0.8.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel-plugin.js +314 -48
- package/dist/babel-plugin.js.map +2 -2
- package/dist/babel-plugin.min.js +1 -1
- package/dist/babel-plugin.min.js.map +3 -3
- package/dist/file-router.js +78 -2
- package/dist/file-router.js.map +2 -2
- package/dist/file-router.min.js +3 -2
- package/dist/file-router.min.js.map +3 -3
- package/dist/index.js +354 -52
- package/dist/index.js.map +2 -2
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +3 -3
- package/dist/vite-plugin.js +354 -52
- package/dist/vite-plugin.js.map +2 -2
- package/dist/vite-plugin.min.js +6 -6
- package/dist/vite-plugin.min.js.map +3 -3
- package/package.json +2 -2
- package/src/babel-plugin.js +514 -65
- package/src/file-router.js +104 -2
- package/src/vite-plugin.js +28 -2
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var xe=new Set(["preventDefault","stopPropagation","once","capture","passive","self"]),Ee=new Set(["once","capture","passive"]),be=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Se=new Set(["click","input","change","keydown","keyup","submit","focusin","focusout","mousedown","mouseup"]),R=new Set(["Math","Number","String","Boolean","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","JSON","Date","Array","Object","console","RegExp"]),te=new Set(["useSignal","signal","computed","useComputed","useState","useReducer","createResource","useSWR","useQuery","useInfiniteQuery"]);function W({types:e}){function f(n){let i=n.split("|"),r=i[0],t=i.slice(1).filter(a=>xe.has(a));return{eventName:r,modifiers:t}}function b(n){return n.startsWith("bind:")}function I(n){return n.slice(5)}function _(n){return/^[A-Z]/.test(n)}function P(n){return be.has(String(n).toLowerCase())}function v(n){return n?e.isJSXExpressionContainer(n)?n.expression:e.isStringLiteral(n)?n:e.stringLiteral(n.value||""):e.booleanLiteral(!0)}function C(n){return n==="className"?"class":n==="htmlFor"?"for":n}function k(n){return e.isJSXNamespacedName(n.name)?`${n.name.namespace.name}:${n.name.name.name}`:typeof n.name.name=="string"?n.name.name:String(n.name.name)}function $(n,i){if(i.length===0)return n;let r=n;for(let t of i)switch(t){case"preventDefault":r=e.arrowFunctionExpression([e.identifier("e")],e.blockStatement([e.expressionStatement(e.callExpression(e.memberExpression(e.identifier("e"),e.identifier("preventDefault")),[])),e.expressionStatement(e.callExpression(r,[e.identifier("e")]))]));break;case"stopPropagation":r=e.arrowFunctionExpression([e.identifier("e")],e.blockStatement([e.expressionStatement(e.callExpression(e.memberExpression(e.identifier("e"),e.identifier("stopPropagation")),[])),e.expressionStatement(e.callExpression(r,[e.identifier("e")]))]));break;case"self":r=e.arrowFunctionExpression([e.identifier("e")],e.blockStatement([e.ifStatement(e.binaryExpression("===",e.memberExpression(e.identifier("e"),e.identifier("target")),e.memberExpression(e.identifier("e"),e.identifier("currentTarget"))),e.expressionStatement(e.callExpression(r,[e.identifier("e")])))]));break;case"once":case"capture":case"passive":break}return r}function d(n,i){return i.has(n)}function m(n){let i=new Set;function r(a){let s=a.init;if(!s||!e.isCallExpression(s))return;let o=s.callee,c="";if(e.isIdentifier(o)?c=o.name:e.isMemberExpression(o)&&e.isIdentifier(o.property)&&(c=o.property.name),te.has(c)){let u=a.id;if(e.isIdentifier(u))i.add(u.name);else if(e.isArrayPattern(u))for(let S of u.elements)e.isIdentifier(S)&&i.add(S.name);else if(e.isObjectPattern(u))for(let S of u.properties)e.isObjectProperty(S)&&e.isIdentifier(S.value)&&i.add(S.value.name)}}let t=n.scope;for(;t;){for(let[a,s]of Object.entries(t.bindings))if(s.path.isVariableDeclarator()&&r(s.path.node),s.path.isIdentifier()||s.kind==="param"){let o=s.scope.path;if(o&&o.node&&o.node.params){for(let c of o.node.params)if(e.isObjectPattern(c))for(let u of c.properties)e.isObjectProperty(u)&&e.isIdentifier(u.value)?i.add(u.value.name):e.isRestElement(u)&&e.isIdentifier(u.argument)&&i.add(u.argument.name)}}t=t.parent}return i}function x(n){return m(n)}function g(n){if(!e.isCallExpression(n))return!1;let i=n.callee;return e.isMemberExpression(i)&&e.isIdentifier(i.object)?R.has(i.object.name):e.isIdentifier(i)?R.has(i.name):!1}function T(n,i,r){if(!i)return!1;if(e.isCallExpression(n)){if(e.isIdentifier(n.callee)&&d(n.callee.name,i)||r&&e.isIdentifier(n.callee)&&r.has(n.callee.name)&&!R.has(n.callee.name)||e.isMemberExpression(n.callee)&&e.isIdentifier(n.callee.object)&&d(n.callee.object.name,i)||g(n))return!1;if(n.arguments.some(t=>L(t,i,r)))return!0}return!1}function L(n,i,r){return i||(i=new Set),e.isCallExpression(n)?e.isIdentifier(n.callee)&&d(n.callee.name,i)||r&&e.isIdentifier(n.callee)&&r.has(n.callee.name)&&!R.has(n.callee.name)||e.isMemberExpression(n.callee)&&e.isIdentifier(n.callee.object)&&d(n.callee.object.name,i)?!0:g(n)?n.arguments.some(t=>L(t,i,r)):e.isIdentifier(n.callee)?n.arguments.some(t=>L(t,i,r)):L(n.callee,i,r)||n.arguments.some(t=>L(t,i,r)):e.isIdentifier(n)?d(n.name,i):e.isMemberExpression(n)?L(n.object,i,r):e.isConditionalExpression(n)?L(n.test,i,r)||L(n.consequent,i,r)||L(n.alternate,i,r):e.isBinaryExpression(n)||e.isLogicalExpression(n)?L(n.left,i,r)||L(n.right,i,r):e.isUnaryExpression(n)?L(n.argument,i,r):e.isTemplateLiteral(n)?n.expressions.some(t=>L(t,i,r)):e.isObjectExpression(n)?n.properties.some(t=>e.isObjectProperty(t)&&L(t.value,i,r)):e.isArrayExpression(n)?n.elements.some(t=>t&&L(t,i,r)):(e.isArrowFunctionExpression(n)||e.isFunctionExpression(n),!1)}function J(n){if(e.isJSXText(n))return!0;if(e.isJSXExpressionContainer(n))return!1;if(e.isJSXElement(n)){let i=n.openingElement,r=i.name.name;if(_(r))return!1;for(let t of i.attributes){if(e.isJSXSpreadAttribute(t))return!1;let a=t.value;if(e.isJSXExpressionContainer(a))return!1}return n.children.every(J)}return!1}function j(n){return e.isJSXSpreadAttribute(n)?!0:n.value?e.isJSXExpressionContainer(n.value):!1}function z(n){if(e.isJSXText(n)){let s=n.value.replace(/\n\s+/g," ").trim();return s?K(s):""}if(e.isJSXExpressionContainer(n))return e.isJSXEmptyExpression(n.expression)?"":"<!--$-->";if(!e.isJSXElement(n))return"";let i=n.openingElement,r=i.name.name;if(_(r))return"";let t=`<${r}`;for(let s of i.attributes){if(e.isJSXSpreadAttribute(s))continue;let o=k(s);if(o==="key"||o.startsWith("on")||o.startsWith("bind:")||o.includes("|"))continue;let c=o;if(o==="className"&&(c="class"),o==="htmlFor"&&(c="for"),!s.value)t+=` ${c}`;else if(e.isStringLiteral(s.value))t+=` ${c}="${ue(s.value.value)}"`;else if(e.isJSXExpressionContainer(s.value))continue}let a=n.openingElement.selfClosing;if(a&&P(r))return t+=">",t;if(a)return t+=`></${r}>`,t;t+=">";for(let s of n.children)if(e.isJSXText(s)){let o=s.value.replace(/\n\s+/g," ").trim();o&&(t+=K(o))}else e.isJSXExpressionContainer(s)?e.isJSXEmptyExpression(s.expression)||(t+="<!--$-->"):e.isJSXElement(s)&&(_(s.openingElement.name.name)?t+="<!--$-->":t+=z(s));return t+=`</${r}>`,t}function K(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ue(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function X(n,i){let{node:r}=n,t=r.openingElement,a=t.name.name;if(_(a))return ie(n,i);if(a==="For")return de(n,i);if(a==="Show")return me(n,i);let s=t.attributes,o=r.children,c=o.every(J),u=s.every(E=>!j(E)),S=s.every(E=>{if(e.isJSXSpreadAttribute(E))return!1;let p=k(E);return!p?.startsWith("on")&&!p?.startsWith("bind:")});if(c&&u&&S){let E=z(r);if(E){let p=re(i,E);return i.needsTemplate=!0,e.callExpression(e.identifier(p),[])}}let y=z(r);if(!y){let E=r.loc,p=i.filename||i.file?.opts?.filename||"<unknown>",w=E?`:${E.start.line}:${E.start.column}`:"";return console.warn(`[what-compiler] Could not extract template for <${a}> at ${p}${w}. Falling back to h() for this element. This element could not be statically analyzed. Consider simplifying the JSX.`),i.needsH=!0,U(n,i)}let M=re(i,y);i.needsTemplate=!0;let l=i.nextVarId(),h=[e.variableDeclaration("const",[e.variableDeclarator(e.identifier(l),e.callExpression(e.identifier(M),[]))])];return ee(h,l,s,i),ne(h,l,o,r,i),i._pendingSetup||(i._pendingSetup=[]),i._pendingSetup.push(...h),e.identifier(l)}function U(n,i){let{node:r}=n,t=r.openingElement,a=t.name.name,s=t.attributes,o=r.children,c=[];for(let y of s){if(e.isJSXSpreadAttribute(y))continue;let M=k(y),l=v(y.value),h=C(M);c.push(e.objectProperty(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(h)?e.identifier(h):e.stringLiteral(h),l))}let u=[];for(let y of o)if(e.isJSXText(y)){let M=y.value.replace(/\n\s+/g," ").trim();M&&u.push(e.stringLiteral(M))}else e.isJSXExpressionContainer(y)?e.isJSXEmptyExpression(y.expression)||u.push(y.expression):e.isJSXElement(y)?u.push(X({node:y},i)):e.isJSXFragment(y)&&u.push(H({node:y},i));let S=c.length>0?e.objectExpression(c):e.nullLiteral();return e.callExpression(e.identifier("h"),[e.stringLiteral(a),S,...u])}function ee(n,i,r,t){function a(s,o){return t.needsSetProp=!0,e.callExpression(e.identifier("_$setProp"),[e.identifier(i),e.stringLiteral(s),o])}for(let s of r){if(e.isJSXSpreadAttribute(s)){t.needsSpread=!0,n.push(e.expressionStatement(e.callExpression(e.identifier("_$spread"),[e.identifier(i),s.argument])));continue}let o=k(s);if(o!=="key"){if(o==="ref"){let c=v(s.value);n.push(e.expressionStatement(e.conditionalExpression(e.binaryExpression("===",e.unaryExpression("typeof",c),e.stringLiteral("function")),e.callExpression(e.cloneNode(c),[e.identifier(i)]),e.assignmentExpression("=",e.memberExpression(e.cloneNode(c),e.identifier("current")),e.identifier(i)))));continue}if(o.startsWith("on")&&!o.includes("|")){let c=o.slice(2).toLowerCase(),u=v(s.value);Se.has(c)?(t.needsDelegation=!0,t.delegatedEvents||(t.delegatedEvents=new Set),t.delegatedEvents.add(c),n.push(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(i),e.identifier(`__${c}`)),u)))):n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),[e.stringLiteral(c),u])));continue}if(o.startsWith("on")&&o.includes("|")){let{eventName:c,modifiers:u}=f(o),S=v(s.value),y=$(S,u),M=c.slice(2).toLowerCase(),l=u.filter(E=>Ee.has(E)),h=[e.stringLiteral(M),y];if(l.length>0){let E=l.map(p=>e.objectProperty(e.identifier(p),e.booleanLiteral(!0)));h.push(e.objectExpression(E))}n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),h)));continue}if(b(o)){let c=I(o),u=s.value.expression;t.needsEffect=!0,c==="value"?(n.push(e.expressionStatement(e.callExpression(e.identifier("_$effect"),[e.arrowFunctionExpression([],e.assignmentExpression("=",e.memberExpression(e.identifier(i),e.identifier("value")),e.callExpression(e.cloneNode(u),[])))]))),n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),[e.stringLiteral("input"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(u),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("value"))]))])))):c==="checked"&&(t.needsEffect=!0,n.push(e.expressionStatement(e.callExpression(e.identifier("_$effect"),[e.arrowFunctionExpression([],e.assignmentExpression("=",e.memberExpression(e.identifier(i),e.identifier("checked")),e.callExpression(e.cloneNode(u),[])))]))),n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),[e.stringLiteral("change"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(u),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("checked"))]))]))));continue}if(e.isJSXExpressionContainer(s.value)){let c=s.value.expression,u=C(o);if(L(c,t.signalNames,t.importedIdentifiers)){t.needsEffect=!0;let S=e.callExpression(e.identifier("_$effect"),[e.arrowFunctionExpression([],a(u,c))]);T(c,t.signalNames,t.importedIdentifiers)&&e.addComment(S,"leading"," @what-dev: effect wrapping may be unnecessary \u2014 expression contains a non-signal function call with reactive args ",!1),n.push(e.expressionStatement(S))}else n.push(e.expressionStatement(a(u,c)))}}}}function ne(n,i,r,t,a){let s=[],o=0;for(let l of r){if(e.isJSXText(l)){l.value.replace(/\n\s+/g," ").trim()&&o++;continue}if(e.isJSXExpressionContainer(l)){if(e.isJSXEmptyExpression(l.expression))continue;s.push({type:"expression",child:l,childIndex:o}),o++;continue}if(e.isJSXElement(l)){let h=l.openingElement.name.name;if(_(h)||h==="For"||h==="Show")s.push({type:"component",child:l,childIndex:o}),o++;else{let E=l.openingElement.attributes.some(j)||l.openingElement.attributes.some(p=>!e.isJSXSpreadAttribute(p)&&k(p)?.startsWith("on"))||!l.children.every(J);s.push({type:"static",child:l,childIndex:o,hasAnythingDynamic:E}),o++}continue}e.isJSXFragment(l)&&s.push({type:"fragment",child:l})}let c=s.filter(l=>l.type==="expression"||l.type==="component"||l.type==="static"&&l.hasAnythingDynamic),u=s.some(l=>l.type==="expression"||l.type==="component"),S=c.length>=2&&u,y=new Map;if(S)for(let l of c){let h=`_m$${l.childIndex}`,E=a.nextVarId();y.set(l.childIndex,E),n.push(e.variableDeclaration("const",[e.variableDeclarator(e.identifier(E),G(i,l.childIndex))]))}function M(l){return y.has(l)?e.identifier(y.get(l)):G(i,l)}for(let l of s){if(l.type==="expression"){let h=l.child.expression,E=M(l.childIndex);if(a.needsInsert=!0,L(h,a.signalNames,a.importedIdentifiers)){let p=e.callExpression(e.identifier("_$insert"),[e.identifier(i),e.arrowFunctionExpression([],h),E]);T(h,a.signalNames,a.importedIdentifiers)&&e.addComment(p,"leading"," @what-dev: reactive wrapping may be unnecessary \u2014 expression contains a non-signal function call with reactive args ",!1),n.push(e.expressionStatement(p))}else n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),h,E])));continue}if(l.type==="component"){let h=X({node:l.child},a),E=M(l.childIndex);a.needsInsert=!0,n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),h,E])));continue}if(l.type==="static"&&l.hasAnythingDynamic){let h;y.has(l.childIndex)?h=y.get(l.childIndex):(h=a.nextVarId(),n.push(e.variableDeclaration("const",[e.variableDeclarator(e.identifier(h),G(i,l.childIndex))]))),ee(n,h,l.child.openingElement.attributes,a),ne(n,h,l.child.children,l.child,a);continue}if(l.type==="fragment"){for(let h of l.child.children)if(e.isJSXExpressionContainer(h)&&!e.isJSXEmptyExpression(h.expression)){a.needsInsert=!0;let E=h.expression;L(E,a.signalNames,a.importedIdentifiers)?n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),e.arrowFunctionExpression([],E)]))):n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),E])))}}}}function G(n,i){if(i===0)return e.memberExpression(e.identifier(n),e.identifier("firstChild"));let r=e.memberExpression(e.identifier(n),e.identifier("firstChild"));for(let t=0;t<i;t++)r=e.memberExpression(r,e.identifier("nextSibling"));return r}function ie(n,i){let{node:r}=n,t=r.openingElement,a=t.name.name,s=t.attributes,o=r.children,c=null,u=[];for(let p of s){if(e.isJSXAttribute(p)){let w;if(e.isJSXNamespacedName(p.name)?w=`${p.name.namespace.name}:${p.name.name.name}`:w=p.name.name,w&&typeof w=="string"&&w.startsWith("client:")){let O=w.slice(7);p.value?c={type:O,value:p.value.value}:c={type:O};continue}}u.push(p)}if(c){i.needsCreateComponent=!0,i.needsIsland=!0;let p=[e.objectProperty(e.identifier("component"),e.identifier(a)),e.objectProperty(e.identifier("mode"),e.stringLiteral(c.type))];c.value&&p.push(e.objectProperty(e.identifier("mediaQuery"),e.stringLiteral(c.value)));for(let w of u){if(e.isJSXSpreadAttribute(w))continue;let O=k(w),A=v(w.value);p.push(e.objectProperty(e.identifier(O),A))}return e.callExpression(e.identifier("_$createComponent"),[e.identifier("Island"),e.objectExpression(p),e.arrayExpression([])])}i.needsCreateComponent=!0;let S=[],y=!1,M=null;for(let p of u){if(e.isJSXSpreadAttribute(p)){y=!0,M=p.argument;continue}let w=k(p);if(w==="key")continue;if(b(w)){let A=I(w),N=p.value.expression;A==="value"?(S.push(e.objectProperty(e.identifier("value"),e.callExpression(e.cloneNode(N),[]))),S.push(e.objectProperty(e.identifier("onInput"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(N),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("value"))]))))):A==="checked"&&(S.push(e.objectProperty(e.identifier("checked"),e.callExpression(e.cloneNode(N),[]))),S.push(e.objectProperty(e.identifier("onChange"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(N),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("checked"))])))));continue}if(w.startsWith("on")&&w.includes("|")){let{eventName:A,modifiers:N}=f(w),he=v(p.value),ge=$(he,N);S.push(e.objectProperty(e.identifier(A),ge));continue}let O=v(p.value);S.push(e.objectProperty(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(w)?e.identifier(w):e.stringLiteral(w),O))}let l=[];for(let p of o)if(e.isJSXText(p)){let w=p.value.replace(/\n\s+/g," ").trim();w&&l.push(e.stringLiteral(w))}else e.isJSXExpressionContainer(p)?e.isJSXEmptyExpression(p.expression)||l.push(p.expression):e.isJSXElement(p)?l.push(X({node:p},i)):e.isJSXFragment(p)&&l.push(H({node:p},i));let h;y?S.length>0?h=e.callExpression(e.memberExpression(e.identifier("Object"),e.identifier("assign")),[e.objectExpression([]),M,e.objectExpression(S)]):h=M:S.length>0?h=e.objectExpression(S):h=e.nullLiteral();let E=l.length>0?e.arrayExpression(l):e.arrayExpression([]);return e.callExpression(e.identifier("_$createComponent"),[e.identifier(a),h,E])}function de(n,i){let{node:r}=n,t=r.openingElement.attributes,a=r.children,s=null;for(let c of t)e.isJSXAttribute(c)&&k(c)==="each"&&(s=v(c.value));if(!s)return console.warn('[what-compiler] <For> element missing "each" attribute.'),i.needsH=!0,U(n,i);let o=null;for(let c of a)if(e.isJSXExpressionContainer(c)&&!e.isJSXEmptyExpression(c.expression)){o=c.expression;break}return o?(i.needsMapArray=!0,e.callExpression(e.identifier("_$mapArray"),[s,o])):(console.warn("[what-compiler] <For> element missing render function child."),i.needsH=!0,U(n,i))}function me(n,i){return i.needsCreateComponent=!0,ie(n,i)}function H(n,i){let{node:r}=n,t=r.children,a=[];for(let s of t)if(e.isJSXText(s)){let o=s.value.replace(/\n\s+/g," ").trim();o&&a.push(e.stringLiteral(o))}else e.isJSXExpressionContainer(s)?e.isJSXEmptyExpression(s.expression)||a.push(s.expression):e.isJSXElement(s)?a.push(X({node:s},i)):e.isJSXFragment(s)&&a.push(H({node:s},i));return a.length===1?a[0]:e.arrayExpression(a)}function re(n,i){if(n.templateMap.has(i))return n.templateMap.get(i);let r=`_tmpl$${n.templateCount++}`;return n.templateMap.set(i,r),n.templates.push({id:r,html:i}),r}return{name:"what-jsx-transform",visitor:{Program:{enter(n,i){i.needsTemplate=!1,i.needsInsert=!1,i.needsEffect=!1,i.needsMapArray=!1,i.needsSpread=!1,i.needsSetProp=!1,i.needsH=!1,i.needsCreateComponent=!1,i.needsFragment=!1,i.needsIsland=!1,i.needsDelegation=!1,i.delegatedEvents=new Set,i.templates=[],i.templateMap=new Map,i.templateCount=0,i._varCounter=0,i._pendingSetup=[],i.nextVarId=()=>`_el$${i._varCounter++}`,i.signalNames=new Set,i.importedIdentifiers=new Set;for(let r of n.node.body)if(e.isImportDeclaration(r)){let t=r.source.value,a=t==="what-framework"||t.startsWith("what-framework/")||t==="what-core"||t.startsWith("what-core/")||t.startsWith("./")||t.startsWith("../");for(let s of r.specifiers){let o=null;(e.isImportSpecifier(s)&&e.isIdentifier(s.local)||e.isImportDefaultSpecifier(s)&&e.isIdentifier(s.local)||e.isImportNamespaceSpecifier(s)&&e.isIdentifier(s.local))&&(o=s.local.name),o&&(a||/^(use|create)[A-Z]/.test(o))&&i.importedIdentifiers.add(o)}}n.traverse({VariableDeclarator(r){let t=r.node.init;if(!t||!e.isCallExpression(t))return;let a=t.callee,s="";if(e.isIdentifier(a)?s=a.name:e.isMemberExpression(a)&&e.isIdentifier(a.property)&&(s=a.property.name),te.has(s)){let o=r.node.id;if(e.isIdentifier(o))i.signalNames.add(o.name);else if(e.isArrayPattern(o))for(let c of o.elements)e.isIdentifier(c)&&i.signalNames.add(c.name);else if(e.isObjectPattern(o))for(let c of o.properties)e.isObjectProperty(c)&&e.isIdentifier(c.value)&&i.signalNames.add(c.value.name)}}})},exit(n,i){for(let a of i.templates.reverse())n.unshiftContainer("body",e.variableDeclaration("const",[e.variableDeclarator(e.identifier(a.id),e.callExpression(e.identifier("_$template"),[e.stringLiteral(a.html)]))]));let r=[];i.needsTemplate&&r.push(e.importSpecifier(e.identifier("_$template"),e.identifier("template"))),i.needsInsert&&r.push(e.importSpecifier(e.identifier("_$insert"),e.identifier("insert"))),i.needsEffect&&r.push(e.importSpecifier(e.identifier("_$effect"),e.identifier("effect"))),i.needsMapArray&&r.push(e.importSpecifier(e.identifier("_$mapArray"),e.identifier("mapArray"))),i.needsSpread&&r.push(e.importSpecifier(e.identifier("_$spread"),e.identifier("spread"))),i.needsSetProp&&r.push(e.importSpecifier(e.identifier("_$setProp"),e.identifier("setProp"))),i.needsCreateComponent&&r.push(e.importSpecifier(e.identifier("_$createComponent"),e.identifier("_$createComponent"))),i.needsDelegation&&r.push(e.importSpecifier(e.identifier("_$delegateEvents"),e.identifier("delegateEvents")));let t=[];if(i.needsH&&t.push(e.importSpecifier(e.identifier("h"),e.identifier("h"))),i.needsFragment&&t.push(e.importSpecifier(e.identifier("Fragment"),e.identifier("Fragment"))),i.needsIsland&&t.push(e.importSpecifier(e.identifier("Island"),e.identifier("Island"))),r.length>0){let a=null;for(let s of n.node.body)if(e.isImportDeclaration(s)&&(s.source.value==="what-framework/render"||s.source.value==="what-core/render")){a=s;break}if(a){let s=new Set(a.specifiers.filter(o=>e.isImportSpecifier(o)).map(o=>o.imported.name));for(let o of r)s.has(o.imported.name)||a.specifiers.push(o)}else n.unshiftContainer("body",e.importDeclaration(r,e.stringLiteral("what-framework/render")))}if(t.length>0&&ye(n,e,t),i.needsDelegation&&i.delegatedEvents&&i.delegatedEvents.size>0){let a=e.arrayExpression([...i.delegatedEvents].map(s=>e.stringLiteral(s)));n.pushContainer("body",e.expressionStatement(e.callExpression(e.identifier("_$delegateEvents"),[a])))}}},JSXElement(n,i){i.signalNames=m(n),i._pendingSetup=[];let r=X(n,i),t=i._pendingSetup;if(i._pendingSetup=[],t.length>0){let a=n;for(;a&&!a.isStatement();)a=a.parentPath;if(a&&a.isStatement()){for(let s of t)a.insertBefore(s);n.replaceWith(r)}else t.push(e.returnStatement(r)),n.replaceWith(e.callExpression(e.arrowFunctionExpression([],e.blockStatement(t)),[]))}else n.replaceWith(r)},JSXFragment(n,i){let r=H(n,i);n.replaceWith(r)}}}}function ye(e,f,b){let I=null;for(let _ of e.node.body)if(f.isImportDeclaration(_)&&(_.source.value==="what-core"||_.source.value==="what-framework")){I=_;break}if(I){let _=new Set(I.specifiers.filter(P=>f.isImportSpecifier(P)).map(P=>P.imported.name));for(let P of b)_.has(P.imported.name)||I.specifiers.push(P)}else{let _=f.importDeclaration(b,f.stringLiteral("what-framework"));e.unshiftContainer("body",_)}}import Y from"path";import{transformSync as Ce}from"@babel/core";import D from"fs";import F from"path";var se=new Set([".jsx",".tsx",".js",".ts"]),ve=new Set(["_layout","_error","_loading","_404"]);function le(e){let f=[],b=[],I=[];function _(v,C=""){if(!D.existsSync(v))return;let k=D.readdirSync(v,{withFileTypes:!0});for(let $ of k){let d=F.join(v,$.name);if($.isDirectory()){if($.name.match(/^\((.+)\)$/)){_(d,C);continue}if($.name==="api"&&C===""){P(d,"/api");continue}_(d,C+"/"+V($.name));continue}let m=F.extname($.name);if(!se.has(m))continue;let x=F.basename($.name,m);if(x==="_layout"){b.push({filePath:d,urlPrefix:C||"/"});continue}if(ve.has(x))continue;let g=V(x),T=x==="index"?C||"/":C+"/"+g;f.push({filePath:d,routePath:oe(T),isDynamic:T.includes(":")||T.includes("*")})}}function P(v,C){if(!D.existsSync(v))return;let k=D.readdirSync(v,{withFileTypes:!0});for(let $ of k){let d=F.join(v,$.name);if($.isDirectory()){P(d,C+"/"+V($.name));continue}let m=F.extname($.name);if(!se.has(m))continue;let x=F.basename($.name,m),g=V(x),T=x==="index"?C:C+"/"+g;I.push({filePath:d,routePath:oe(T)})}}return _(e),f.sort((v,C)=>{let k=ae(v.routePath),$=ae(C.routePath);return k-$}),{pages:f,layouts:b,apiRoutes:I}}function V(e){let f=e.match(/^\[\.\.\.(\w+)\]$/);if(f)return"*"+f[1];let b=e.match(/^\[(\w+)\]$/);return b?":"+b[1]:e.toLowerCase()}function oe(e){let f=e.replace(/\/+/g,"/");return f.length>1&&f.endsWith("/")&&(f=f.slice(0,-1)),f||"/"}function ae(e){return e.includes("*")?100:e.includes(":")?10:0}function ce(e){let f=e.match(/export\s+const\s+page\s*=\s*(\{[^}]*\})/s);if(!f)return{mode:"client"};try{let b=f[1].replace(/'/g,'"').replace(/(\w+)\s*:/g,'"$1":').replace(/,\s*}/g,"}").replace(/\/\/[^\n]*/g,"");return{mode:"client",...JSON.parse(b)}}catch{return{mode:"client"}}}function Z(e,f){let{pages:b,layouts:I,apiRoutes:_}=le(e),P=[],v=[],C=new Map;I.forEach((d,m)=>{let x=`_layout${m}`,g=q(d.filePath,f);P.push(`import ${x} from '${g}';`),C.set(d.urlPrefix,x)}),b.forEach((d,m)=>{let x=`_page${m}`,g=q(d.filePath,f);P.push(`import ${x} from '${g}';`);let T={mode:"client"};try{let j=D.readFileSync(d.filePath,"utf-8");T=ce(j)}catch{}let L=we(d.routePath,C),J={path:d.routePath,component:x,mode:T.mode||"client",layout:L||null};v.push(J)});let k=[];return _.forEach((d,m)=>{let x=`_api${m}`,g=q(d.filePath,f);P.push(`import * as ${x} from '${g}';`),k.push({path:d.routePath,handlers:x})}),["// Auto-generated by What Framework file router","// Do not edit \u2014 changes will be overwritten","",...P,"","export const routes = [",...v.map(d=>` { path: '${d.path}', component: ${d.component}, mode: '${d.mode}'${d.layout?`, layout: ${d.layout}`:""} },`),"];","","export const apiRoutes = [",...k.map(d=>` { path: '${d.path}', handlers: ${d.handlers} },`),"];","","export const pageModes = {",...v.map(d=>` '${d.path}': '${d.mode}',`),"};"].join(`
|
|
2
|
-
`)}function
|
|
1
|
+
var ve=new Set(["preventDefault","stopPropagation","once","capture","passive","self"]),_e=new Set(["once","capture","passive"]),ke=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e=new Set(["click","input","change","keydown","keyup","submit","focusin","focusout","mousedown","mouseup"]),B=new Set(["Math","Number","String","Boolean","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","JSON","Date","Array","Object","console","RegExp"]),le=new Set(["useSignal","signal","computed","useComputed","useState","useReducer","createResource","useSWR","useQuery","useInfiniteQuery"]);function O(e){if(!/[\r\n]/.test(e))return e.replace(/\t/g," ");let p=e.split(/\r\n|\n|\r/),_=-1;for(let v=0;v<p.length;v++)/[^ \t]/.test(p[v])&&(_=v);if(_===-1)return"";let L="";for(let v=0;v<p.length;v++){let $=p[v].replace(/\t/g," "),P=v===0,C=v===p.length-1;P||($=$.replace(/^ +/,"")),C||($=$.replace(/ +$/,"")),$&&(v!==_&&($+=" "),L+=$)}return L}function z({types:e}){let p=new Set,_=new Set;function L(n,i){return!(!n.includes("__")||!n.startsWith("on")||n.split("__").slice(1).filter(a=>a!=="").length===0)}function v(n){let i=n.includes("|")?"|":"__",r=n.split(i),s=r[0],a=r.slice(1).filter(t=>ve.has(t));return{eventName:s,modifiers:a}}function $(n){return n.startsWith("bind:")}function P(n){return n.slice(5)}function C(n){return/^[A-Z]/.test(n)}function F(n){return ke.has(String(n).toLowerCase())}function k(n){return n?e.isJSXExpressionContainer(n)?n.expression:e.isStringLiteral(n)?n:e.stringLiteral(n.value||""):e.booleanLiteral(!0)}function E(n){return n==="className"?"class":n==="htmlFor"?"for":n}function u(n){return e.isJSXNamespacedName(n.name)?`${n.name.namespace.name}:${n.name.name.name}`:typeof n.name.name=="string"?n.name.name:String(n.name.name)}function S(n,i){if(i.length===0)return n;let r=n;for(let s of i)switch(s){case"preventDefault":r=e.arrowFunctionExpression([e.identifier("e")],e.blockStatement([e.expressionStatement(e.callExpression(e.memberExpression(e.identifier("e"),e.identifier("preventDefault")),[])),e.expressionStatement(e.callExpression(r,[e.identifier("e")]))]));break;case"stopPropagation":r=e.arrowFunctionExpression([e.identifier("e")],e.blockStatement([e.expressionStatement(e.callExpression(e.memberExpression(e.identifier("e"),e.identifier("stopPropagation")),[])),e.expressionStatement(e.callExpression(r,[e.identifier("e")]))]));break;case"self":r=e.arrowFunctionExpression([e.identifier("e")],e.blockStatement([e.ifStatement(e.binaryExpression("===",e.memberExpression(e.identifier("e"),e.identifier("target")),e.memberExpression(e.identifier("e"),e.identifier("currentTarget"))),e.expressionStatement(e.callExpression(r,[e.identifier("e")])))]));break;case"once":case"capture":case"passive":break}return r}function g(n,i){return i.has(n)}function M(n){let i=new Set;function r(a){let t=a.init;if(!t||!e.isCallExpression(t))return;let o=t.callee,l="";if(e.isIdentifier(o)?l=o.name:e.isMemberExpression(o)&&e.isIdentifier(o.property)&&(l=o.property.name),le.has(l)){let d=a.id;if(e.isIdentifier(d))i.add(d.name);else if(e.isArrayPattern(d))for(let m of d.elements)e.isIdentifier(m)&&i.add(m.name);else if(e.isObjectPattern(d))for(let m of d.properties)e.isObjectProperty(m)&&e.isIdentifier(m.value)&&i.add(m.value.name)}}let s=n.scope;for(;s;){for(let t of Object.values(s.bindings))t.path.isVariableDeclarator()&&r(t.path.node);let a=s.path&&s.path.node;if(a&&a.params){for(let t of a.params)if(e.isObjectPattern(t))for(let o of t.properties)e.isObjectProperty(o)&&e.isIdentifier(o.value)?i.add(o.value.name):e.isRestElement(o)&&e.isIdentifier(o.argument)&&i.add(o.argument.name)}s=s.parent}return i}function j(n){return M(n)}function R(n){if(!e.isCallExpression(n))return!1;let i=n.callee;return e.isMemberExpression(i)&&e.isIdentifier(i.object)?B.has(i.object.name):e.isIdentifier(i)?B.has(i.name):!1}function W(n,i,r){if(!i)return!1;if(e.isCallExpression(n)){if(e.isIdentifier(n.callee)&&g(n.callee.name,i)||r&&e.isIdentifier(n.callee)&&r.has(n.callee.name)&&!B.has(n.callee.name)||e.isMemberExpression(n.callee)&&e.isIdentifier(n.callee.object)&&g(n.callee.object.name,i)||R(n))return!1;if(n.arguments.some(s=>A(s,i,r)))return!0}return!1}function A(n,i,r){return i||(i=new Set),e.isCallExpression(n)?e.isIdentifier(n.callee)&&g(n.callee.name,i)||r&&e.isIdentifier(n.callee)&&r.has(n.callee.name)&&!B.has(n.callee.name)||e.isMemberExpression(n.callee)&&e.isIdentifier(n.callee.object)&&g(n.callee.object.name,i)?!0:R(n)?n.arguments.some(s=>A(s,i,r)):e.isIdentifier(n.callee)?n.arguments.some(s=>A(s,i,r)):A(n.callee,i,r)||n.arguments.some(s=>A(s,i,r)):e.isIdentifier(n)?g(n.name,i)||r&&r.has(n.name):e.isMemberExpression(n)?A(n.object,i,r):e.isConditionalExpression(n)?A(n.test,i,r)||A(n.consequent,i,r)||A(n.alternate,i,r):e.isBinaryExpression(n)||e.isLogicalExpression(n)?A(n.left,i,r)||A(n.right,i,r):e.isUnaryExpression(n)?A(n.argument,i,r):e.isTemplateLiteral(n)?n.expressions.some(s=>A(s,i,r)):e.isObjectExpression(n)?n.properties.some(s=>e.isObjectProperty(s)&&A(s.value,i,r)):e.isArrayExpression(n)?n.elements.some(s=>s&&A(s,i,r)):(e.isArrowFunctionExpression(n)||e.isFunctionExpression(n),!1)}function ge(n,i){let r=n,s=!1;if(e.isArrowFunctionExpression(n)&&n.params.length===0&&(r=n.body,s=!0),e.isConditionalExpression(r)){let t=H(r.consequent,i),o=H(r.alternate,i);if(t||o){let l=e.conditionalExpression(r.test,t||r.consequent,o||r.alternate);return s?e.arrowFunctionExpression([],l):l}return null}if(e.isLogicalExpression(r)&&(r.operator==="&&"||r.operator==="||")){let t=H(r.right,i);if(t){let o=e.logicalExpression(r.operator,r.left,t);return s?e.arrowFunctionExpression([],o):o}return null}return H(r,i)}function H(n,i){if(!e.isCallExpression(n)||!e.isMemberExpression(n.callee)||!e.isIdentifier(n.callee.property,{name:"map"})||n.arguments.length<1)return null;let r=n.arguments[0];if(!e.isArrowFunctionExpression(r)&&!e.isFunctionExpression(r))return null;let s=null;if(e.isArrowFunctionExpression(r)){if(e.isExpression(r.body))s=r.body;else if(e.isBlockStatement(r.body)){let c=r.body.body.find(f=>e.isReturnStatement(f));c&&(s=c.argument)}}else if(e.isFunctionExpression(r)){let c=r.body.body.find(f=>e.isReturnStatement(f));c&&(s=c.argument)}if(!s||!e.isJSXElement(s))return null;let a=s.openingElement.attributes,t=null;for(let c of a)if(e.isJSXAttribute(c)&&u(c)==="key"){t=c;break}if(!t)return null;let o=k(t.value);if(!o)return null;s.openingElement.attributes=a.filter(c=>c!==t);let l=n.callee.object,d=e.arrowFunctionExpression([],l),m=r.params[0]?e.cloneNode(r.params[0],!0):e.identifier("_item"),w=e.arrowFunctionExpression([m],e.cloneNode(o,!0));return e.callExpression(e.identifier("_$mapArray"),[d,r,e.objectExpression([e.objectProperty(e.identifier("key"),w),e.objectProperty(e.identifier("raw"),e.booleanLiteral(!0))])])}function q(n){if(e.isJSXText(n))return!0;if(e.isJSXExpressionContainer(n))return!1;if(e.isJSXElement(n)){let i=n.openingElement,r=i.name.name;if(C(r))return!1;for(let s of i.attributes){if(e.isJSXSpreadAttribute(s))return!1;let a=s.value;if(e.isJSXExpressionContainer(a))return!1}return n.children.every(q)}return!1}function re(n){return e.isJSXSpreadAttribute(n)?!0:n.value?e.isJSXExpressionContainer(n.value):!1}function Z(n){if(e.isJSXText(n)){let t=O(n.value);return t?te(t):""}if(e.isJSXExpressionContainer(n))return e.isJSXEmptyExpression(n.expression)?"":"<!--$-->";if(!e.isJSXElement(n))return"";let i=n.openingElement,r=i.name.name;if(C(r))return"";let s=`<${r}`;for(let t of i.attributes){if(e.isJSXSpreadAttribute(t))continue;let o=u(t);if(o==="key"||o.startsWith("on")||o.startsWith("bind:")||o.includes("|"))continue;let l=o;if(o==="className"&&(l="class"),o==="htmlFor"&&(l="for"),!t.value)s+=` ${l}`;else if(e.isStringLiteral(t.value))s+=` ${l}="${xe(t.value.value)}"`;else if(e.isJSXExpressionContainer(t.value))continue}let a=n.openingElement.selfClosing;if(a&&F(r))return s+=">",s;if(a)return s+=`></${r}>`,s;s+=">";for(let t of n.children)if(e.isJSXText(t)){let o=O(t.value);o&&(s+=te(o))}else e.isJSXExpressionContainer(t)?e.isJSXEmptyExpression(t.expression)||(s+="<!--$-->"):e.isJSXElement(t)&&(C(t.openingElement.name.name)?s+="<!--$-->":s+=Z(t));return s+=`</${r}>`,s}function te(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function xe(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function J(n,i){let{node:r}=n,s=r.openingElement,a=s.name.name;if(a==="For")return be(n,i);if(a==="Show")return ye(n,i);if(C(a))return Ee(n,i);let t=s.attributes,o=r.children,l=o.every(q),d=t.every(b=>!re(b)),m=t.every(b=>{if(e.isJSXSpreadAttribute(b))return!1;let h=u(b);return!h?.startsWith("on")&&!h?.startsWith("bind:")});if(l&&d&&m){let b=Z(r);if(b){let h=ae(i,b);return i.needsTemplate=!0,e.callExpression(e.identifier(h),[])}}let w=Z(r);if(!w){let b=r.loc,h=i.filename||i.file?.opts?.filename||"<unknown>",y=b?`:${b.start.line}:${b.start.column}`:"";return console.warn(`[what-compiler] Could not extract template for <${a}> at ${h}${y}. Falling back to h() for this element. This element could not be statically analyzed. Consider simplifying the JSX.`),i.needsH=!0,K(n,i)}let c=ae(i,w);i.needsTemplate=!0;let f=i.nextVarId(),x=[e.variableDeclaration("const",[e.variableDeclarator(e.identifier(f),e.callExpression(e.identifier(c),[]))])];return se(x,f,t,i),oe(x,f,o,r,i),i._pendingSetup||(i._pendingSetup=[]),i._pendingSetup.push(...x),e.identifier(f)}function K(n,i){let{node:r}=n,s=r.openingElement,a=s.name.name,t=s.attributes,o=r.children,l=[];for(let w of t){if(e.isJSXSpreadAttribute(w))continue;let c=u(w),f=k(w.value),x=E(c);l.push(e.objectProperty(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(x)?e.identifier(x):e.stringLiteral(x),f))}let d=[];for(let w of o)if(e.isJSXText(w)){let c=O(w.value);c&&d.push(e.stringLiteral(c))}else e.isJSXExpressionContainer(w)?e.isJSXEmptyExpression(w.expression)||d.push(w.expression):e.isJSXElement(w)?d.push(J({node:w},i)):e.isJSXFragment(w)&&d.push(V({node:w},i));let m=l.length>0?e.objectExpression(l):e.nullLiteral();return e.callExpression(e.identifier("h"),[e.stringLiteral(a),m,...d])}function se(n,i,r,s){function a(t,o){return s.needsSetProp=!0,e.callExpression(e.identifier("_$setProp"),[e.identifier(i),e.stringLiteral(t),o])}for(let t of r){if(e.isJSXSpreadAttribute(t)){s.needsSpread=!0,n.push(e.expressionStatement(e.callExpression(e.identifier("_$spread"),[e.identifier(i),t.argument])));continue}let o=u(t);if(o!=="key"){if(o==="ref"){let l=k(t.value);n.push(e.expressionStatement(e.conditionalExpression(e.binaryExpression("===",e.unaryExpression("typeof",l),e.stringLiteral("function")),e.callExpression(e.cloneNode(l),[e.identifier(i)]),e.assignmentExpression("=",e.memberExpression(e.cloneNode(l),e.identifier("current")),e.identifier(i)))));continue}if(o.startsWith("on")&&!o.includes("|")&&!L(o,s)){let l=o.slice(2).toLowerCase(),d=k(t.value);$e.has(l)?(s.needsDelegation=!0,s.delegatedEvents||(s.delegatedEvents=new Set),s.delegatedEvents.add(l),n.push(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(i),e.identifier(`$$${l}`)),d)))):n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),[e.stringLiteral(l),d])));continue}if(o.startsWith("on")&&(o.includes("|")||L(o,s))){let{eventName:l,modifiers:d}=v(o),m=k(t.value),w=S(m,d),c=l.slice(2).toLowerCase(),f=d.filter(b=>_e.has(b)),x=[e.stringLiteral(c),w];if(f.length>0){let b=f.map(h=>e.objectProperty(e.identifier(h),e.booleanLiteral(!0)));x.push(e.objectExpression(b))}n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),x)));continue}if($(o)){let l=P(o),d=t.value.expression;s.needsEffect=!0,l==="value"?(n.push(e.expressionStatement(e.callExpression(e.identifier("_$effect"),[e.arrowFunctionExpression([],e.assignmentExpression("=",e.memberExpression(e.identifier(i),e.identifier("value")),e.callExpression(e.cloneNode(d),[])))]))),n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),[e.stringLiteral("input"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(d),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("value"))]))])))):l==="checked"&&(s.needsEffect=!0,n.push(e.expressionStatement(e.callExpression(e.identifier("_$effect"),[e.arrowFunctionExpression([],e.assignmentExpression("=",e.memberExpression(e.identifier(i),e.identifier("checked")),e.callExpression(e.cloneNode(d),[])))]))),n.push(e.expressionStatement(e.callExpression(e.memberExpression(e.identifier(i),e.identifier("addEventListener")),[e.stringLiteral("change"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(d),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("checked"))]))]))));continue}if(e.isJSXExpressionContainer(t.value)){let l=t.value.expression,d=E(o);if(A(l,s.signalNames,s.importedIdentifiers)){s.needsEffect=!0;let m=e.isIdentifier(l)&&(g(l.name,s.signalNames)||s.importedIdentifiers&&s.importedIdentifiers.has(l.name))?e.callExpression(l,[]):l,w=e.callExpression(e.identifier("_$effect"),[e.arrowFunctionExpression([],a(d,m))]);W(l,s.signalNames,s.importedIdentifiers)&&e.addComment(w,"leading"," @what-dev: effect wrapping may be unnecessary \u2014 expression contains a non-signal function call with reactive args ",!1),n.push(e.expressionStatement(w))}else n.push(e.expressionStatement(a(d,l)))}}}}function oe(n,i,r,s,a){let t=[],o=0;for(let c of r){if(e.isJSXText(c)){O(c.value)&&o++;continue}if(e.isJSXExpressionContainer(c)){if(e.isJSXEmptyExpression(c.expression))continue;t.push({type:"expression",child:c,childIndex:o}),o++;continue}if(e.isJSXElement(c)){let f=c.openingElement.name.name;if(C(f)||f==="For"||f==="Show")t.push({type:"component",child:c,childIndex:o}),o++;else{let x=c.openingElement.attributes.some(re)||c.openingElement.attributes.some(b=>!e.isJSXSpreadAttribute(b)&&u(b)?.startsWith("on"))||!c.children.every(q);t.push({type:"static",child:c,childIndex:o,hasAnythingDynamic:x}),o++}continue}e.isJSXFragment(c)&&t.push({type:"fragment",child:c})}let l=t.filter(c=>c.type==="expression"||c.type==="component"||c.type==="static"&&c.hasAnythingDynamic),d=l.length>=2,m=new Map;if(d){let c=null,f=0;for(let x of l){let b=x.childIndex,h=a.nextVarId();m.set(b,h);let y;if(c===null)y=Y(i,b);else{y=e.identifier(c);for(let N=f;N<b;N++)y=e.memberExpression(y,e.identifier("nextSibling"))}n.push(e.variableDeclaration("const",[e.variableDeclarator(e.identifier(h),y)])),c=h,f=b}}function w(c){return m.has(c)?e.identifier(m.get(c)):Y(i,c)}for(let c of t){if(c.type==="expression"){let f=c.child.expression,x=w(c.childIndex);a.needsInsert=!0;let b=ge(f,a);if(b){a.needsMapArray=!0;let y=e.isCallExpression(b)&&e.isIdentifier(b.callee)&&(b.callee.name==="_$mapArray"||b.callee.name==="mapArray"),N=e.isArrowFunctionExpression(b),I=y||N?b:e.arrowFunctionExpression([],b);n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),I,x])));continue}if(e.isCallExpression(f)&&e.isIdentifier(f.callee)&&(f.callee.name==="mapArray"||f.callee.name==="_$mapArray")){a.needsMapArray=!0,f.callee.name==="mapArray"&&(f.callee.name="_$mapArray"),n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),f,x])));continue}if(A(f,a.signalNames,a.importedIdentifiers)){let y=e.callExpression(e.identifier("_$insert"),[e.identifier(i),e.arrowFunctionExpression([],f),x]);W(f,a.signalNames,a.importedIdentifiers)&&e.addComment(y,"leading"," @what-dev: reactive wrapping may be unnecessary \u2014 expression contains a non-signal function call with reactive args ",!1),n.push(e.expressionStatement(y))}else n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),f,x])));continue}if(c.type==="component"){let f=J({node:c.child},a),x=w(c.childIndex);a.needsInsert=!0,n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),f,x])));continue}if(c.type==="static"&&c.hasAnythingDynamic){let f;m.has(c.childIndex)?f=m.get(c.childIndex):(f=a.nextVarId(),n.push(e.variableDeclaration("const",[e.variableDeclarator(e.identifier(f),Y(i,c.childIndex))]))),se(n,f,c.child.openingElement.attributes,a),oe(n,f,c.child.children,c.child,a);continue}if(c.type==="fragment"){for(let f of c.child.children)if(e.isJSXExpressionContainer(f)&&!e.isJSXEmptyExpression(f.expression)){a.needsInsert=!0;let x=f.expression;A(x,a.signalNames,a.importedIdentifiers)?n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),e.arrowFunctionExpression([],x)]))):n.push(e.expressionStatement(e.callExpression(e.identifier("_$insert"),[e.identifier(i),x])))}}}}function Y(n,i){if(i===0)return e.memberExpression(e.identifier(n),e.identifier("firstChild"));let r=e.memberExpression(e.identifier(n),e.identifier("firstChild"));for(let s=0;s<i;s++)r=e.memberExpression(r,e.identifier("nextSibling"));return r}function Ee(n,i){let{node:r}=n,s=r.openingElement,a=s.name.name,t=s.attributes,o=r.children,l=null,d=[];for(let h of t){if(e.isJSXAttribute(h)){let y;if(e.isJSXNamespacedName(h.name)?y=`${h.name.namespace.name}:${h.name.name.name}`:y=h.name.name,y&&typeof y=="string"&&y.startsWith("client:")){let N=y.slice(7);h.value?l={type:N,value:h.value.value}:l={type:N};continue}}d.push(h)}if(l){i.needsCreateComponent=!0,i.needsIsland=!0;let h=[e.objectProperty(e.identifier("component"),e.identifier(a)),e.objectProperty(e.identifier("mode"),e.stringLiteral(l.type))];l.value&&h.push(e.objectProperty(e.identifier("mediaQuery"),e.stringLiteral(l.value)));for(let y of d){if(e.isJSXSpreadAttribute(y))continue;let N=u(y),I=k(y.value);h.push(e.objectProperty(e.identifier(N),I))}return e.callExpression(e.identifier("_$createComponent"),[e.identifier("Island"),e.objectExpression(h),e.arrayExpression([])])}i.needsCreateComponent=!0;let m=[],w=!1,c=null;for(let h of d){if(e.isJSXSpreadAttribute(h)){w=!0,c=h.argument;continue}let y=u(h);if(y==="key")continue;if($(y)){let I=P(y),X=h.value.expression;I==="value"?(m.push(e.objectProperty(e.identifier("value"),e.callExpression(e.cloneNode(X),[]))),m.push(e.objectProperty(e.identifier("onInput"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(X),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("value"))]))))):I==="checked"&&(m.push(e.objectProperty(e.identifier("checked"),e.callExpression(e.cloneNode(X),[]))),m.push(e.objectProperty(e.identifier("onChange"),e.arrowFunctionExpression([e.identifier("e")],e.callExpression(e.memberExpression(e.cloneNode(X),e.identifier("set")),[e.memberExpression(e.memberExpression(e.identifier("e"),e.identifier("target")),e.identifier("checked"))])))));continue}if(y.startsWith("on")&&(y.includes("|")||L(y,i))){let{eventName:I,modifiers:X}=v(y),Se=k(h.value),we=S(Se,X);m.push(e.objectProperty(e.identifier(I),we));continue}let N=k(h.value);m.push(e.objectProperty(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(y)?e.identifier(y):e.stringLiteral(y),N))}let f=[];for(let h of o)if(e.isJSXText(h)){let y=O(h.value);y&&f.push(e.stringLiteral(y))}else e.isJSXExpressionContainer(h)?e.isJSXEmptyExpression(h.expression)||f.push(h.expression):e.isJSXElement(h)?f.push(J({node:h},i)):e.isJSXFragment(h)&&f.push(V({node:h},i));let x;w?m.length>0?x=e.callExpression(e.memberExpression(e.identifier("Object"),e.identifier("assign")),[e.objectExpression([]),c,e.objectExpression(m)]):x=c:m.length>0?x=e.objectExpression(m):x=e.nullLiteral();let b=f.length>0?e.arrayExpression(f):e.arrayExpression([]);return e.callExpression(e.identifier("_$createComponent"),[e.identifier(a),x,b])}function be(n,i){let{node:r}=n,s=r.openingElement.attributes,a=r.children,t=null,o=null;for(let m of s)if(e.isJSXAttribute(m)){let w=u(m);w==="each"?t=k(m.value):w==="key"&&(o=k(m.value))}if(!t)return console.warn('[what-compiler] <For> element missing "each" attribute.'),i.needsH=!0,K(n,i);let l=null;for(let m of a)if(e.isJSXExpressionContainer(m)&&!e.isJSXEmptyExpression(m.expression)){l=m.expression;break}if(!l)return console.warn("[what-compiler] <For> element missing render function child."),i.needsH=!0,K(n,i);i.needsMapArray=!0;let d=[t,l];return o&&d.push(e.objectExpression([e.objectProperty(e.identifier("key"),o)])),e.callExpression(e.identifier("_$mapArray"),d)}function ye(n,i){let{node:r}=n,s=r.openingElement.attributes,a=r.children,t=null,o=null;for(let f of s)if(e.isJSXAttribute(f)){let x=u(f);x==="when"?t=k(f.value):x==="fallback"&&(o=k(f.value))}if(!t)throw n.buildCodeFrameError('<Show> requires a "when" prop. Example: <Show when={isOpen} fallback={null}>...</Show>');let l=null;for(let f of a)if(e.isJSXExpressionContainer(f)&&!e.isJSXEmptyExpression(f.expression)){l=f.expression;break}if(!l){let f=[];for(let x of a)if(e.isJSXText(x)){let b=O(x.value);b&&f.push(e.stringLiteral(b))}else e.isJSXElement(x)&&f.push(J({node:x},i));f.length===1?l=f[0]:f.length>1?l=e.arrayExpression(f):l=e.nullLiteral()}let d;e.isCallExpression(t)?d=t:e.isArrowFunctionExpression(t)&&e.isExpression(t.body)?d=t.body:e.isIdentifier(t)&&(i.signalNames&&g(t.name,i.signalNames)||i.importedIdentifiers&&i.importedIdentifiers.has(t.name))?d=e.callExpression(t,[]):d=t;let m=n.scope?n.scope.generateUidIdentifier("v"):e.identifier("_v"),w=e.isFunction(l)?e.callExpression(l,[e.cloneNode(m)]):l,c=o||e.nullLiteral();return e.arrowFunctionExpression([],e.blockStatement([e.variableDeclaration("const",[e.variableDeclarator(m,d)]),e.returnStatement(e.conditionalExpression(e.cloneNode(m),w,c))]))}function V(n,i){let{node:r}=n,s=r.children,a=[];for(let t of s)if(e.isJSXText(t)){let o=O(t.value);o&&a.push(e.stringLiteral(o))}else e.isJSXExpressionContainer(t)?e.isJSXEmptyExpression(t.expression)||a.push(t.expression):e.isJSXElement(t)?a.push(J({node:t},i)):e.isJSXFragment(t)&&a.push(V({node:t},i));return a.length===1?a[0]:e.arrayExpression(a)}function ae(n,i){if(n.templateMap.has(i))return n.templateMap.get(i);let r=`_tmpl$${n.templateCount++}`;return n.templateMap.set(i,r),n.templates.push({id:r,html:i}),r}return{name:"what-jsx-transform",visitor:{Program:{enter(n,i){i.needsTemplate=!1,i.needsInsert=!1,i.needsEffect=!1,i.needsMapArray=!1,i.needsSpread=!1,i.needsSetProp=!1,i.needsH=!1,i.needsCreateComponent=!1,i.needsFragment=!1,i.needsIsland=!1,i.needsDelegation=!1,i.delegatedEvents=new Set,i.templates=[],i.templateMap=new Map,i.templateCount=0,i._varCounter=0,i._pendingSetup=[],i.nextVarId=()=>`_el$${i._varCounter++}`,i.signalNames=new Set,i.importedIdentifiers=new Set;for(let r of n.node.body)if(e.isImportDeclaration(r)){let s=r.source.value,a=s==="what-framework"||s.startsWith("what-framework/")||s==="what-core"||s.startsWith("what-core/")||s.startsWith("./")||s.startsWith("../");for(let t of r.specifiers){let o=null;(e.isImportSpecifier(t)&&e.isIdentifier(t.local)||e.isImportDefaultSpecifier(t)&&e.isIdentifier(t.local)||e.isImportNamespaceSpecifier(t)&&e.isIdentifier(t.local))&&(o=t.local.name),o&&(a||/^(use|create)[A-Z]/.test(o))&&i.importedIdentifiers.add(o)}}n.traverse({VariableDeclarator(r){let s=r.node.init;if(!s||!e.isCallExpression(s))return;let a=s.callee,t="";if(e.isIdentifier(a)?t=a.name:e.isMemberExpression(a)&&e.isIdentifier(a.property)&&(t=a.property.name),le.has(t)){let o=r.node.id;if(e.isIdentifier(o))i.signalNames.add(o.name);else if(e.isArrayPattern(o))for(let l of o.elements)e.isIdentifier(l)&&i.signalNames.add(l.name);else if(e.isObjectPattern(o))for(let l of o.properties)e.isObjectProperty(l)&&e.isIdentifier(l.value)&&i.signalNames.add(l.value.name)}}})},exit(n,i){for(let a of i.templates.reverse())n.unshiftContainer("body",e.variableDeclaration("const",[e.variableDeclarator(e.identifier(a.id),e.callExpression(e.identifier("_$template"),[e.stringLiteral(a.html)]))]));let r=[];i.needsTemplate&&r.push(e.importSpecifier(e.identifier("_$template"),e.identifier("template"))),i.needsInsert&&r.push(e.importSpecifier(e.identifier("_$insert"),e.identifier("insert"))),i.needsEffect&&r.push(e.importSpecifier(e.identifier("_$effect"),e.identifier("effect"))),i.needsMapArray&&r.push(e.importSpecifier(e.identifier("_$mapArray"),e.identifier("mapArray"))),i.needsSpread&&r.push(e.importSpecifier(e.identifier("_$spread"),e.identifier("spread"))),i.needsSetProp&&r.push(e.importSpecifier(e.identifier("_$setProp"),e.identifier("setProp"))),i.needsCreateComponent&&r.push(e.importSpecifier(e.identifier("_$createComponent"),e.identifier("_$createComponent"))),i.needsDelegation&&r.push(e.importSpecifier(e.identifier("_$delegateEvents"),e.identifier("delegateEvents")));let s=[];if(i.needsH&&s.push(e.importSpecifier(e.identifier("h"),e.identifier("h"))),i.needsFragment&&s.push(e.importSpecifier(e.identifier("Fragment"),e.identifier("Fragment"))),i.needsIsland&&s.push(e.importSpecifier(e.identifier("Island"),e.identifier("Island"))),r.length>0){let a=null;for(let t of n.node.body)if(e.isImportDeclaration(t)&&(t.source.value==="what-framework/render"||t.source.value==="what-core/render")){a=t;break}if(a){let t=new Set(a.specifiers.filter(o=>e.isImportSpecifier(o)).map(o=>o.imported.name));for(let o of r)t.has(o.imported.name)||a.specifiers.push(o)}else n.unshiftContainer("body",e.importDeclaration(r,e.stringLiteral("what-framework/render")))}if(s.length>0&&Ce(n,e,s),i.needsDelegation&&i.delegatedEvents&&i.delegatedEvents.size>0){let a=e.arrayExpression([...i.delegatedEvents].map(t=>e.stringLiteral(t)));n.pushContainer("body",e.expressionStatement(e.callExpression(e.identifier("_$delegateEvents"),[a])))}}},JSXElement(n,i){let r=n.scope,s=i._signalNamesCache;s||(s=i._signalNamesCache=new WeakMap);let a=s.get(r);a||(a=M(n),s.set(r,a)),i.signalNames=a,i._pendingSetup=[];let t=J(n,i),o=i._pendingSetup;if(i._pendingSetup=[],o.length>0){let l=n,d=!1;for(;l&&!l.isStatement();)(l.isArrowFunctionExpression()||l.isFunctionExpression())&&(d=!0),l=l.parentPath;l&&l.isStatement()&&(l.listKey==="body"||l.listKey==="consequent")&&Array.isArray(l.container)&&!d?(l.insertBefore(o),n.replaceWith(t)):(o.push(e.returnStatement(t)),n.replaceWith(e.callExpression(e.arrowFunctionExpression([],e.blockStatement(o)),[])))}else n.replaceWith(t)},JSXFragment(n,i){let r=V(n,i);n.replaceWith(r)}}}}function Ce(e,p,_){let L=null;for(let v of e.node.body)if(p.isImportDeclaration(v)&&(v.source.value==="what-core"||v.source.value==="what-framework")){L=v;break}if(L){let v=new Set(L.specifiers.filter($=>p.isImportSpecifier($)).map($=>$.imported.name));for(let $ of _)v.has($.imported.name)||L.specifiers.push($)}else{let v=p.importDeclaration(_,p.stringLiteral("what-framework"));e.unshiftContainer("body",v)}}import ne from"path";import{transformSync as Me}from"@babel/core";import D from"fs";import T from"path";var ce=new Set([".jsx",".tsx",".js",".ts"]),Le=new Set(["_layout","_error","_loading","_404"]);function ue(e){let p=[],_=[],L=[];function v(P,C=""){if(!D.existsSync(P))return;let F=D.readdirSync(P,{withFileTypes:!0});for(let k of F){let E=T.join(P,k.name);if(k.isDirectory()){if(k.name.match(/^\((.+)\)$/)){v(E,C);continue}if(k.name==="api"&&C===""){$(E,"/api");continue}v(E,C+"/"+G(k.name));continue}let u=T.extname(k.name);if(!ce.has(u))continue;let S=T.basename(k.name,u);if(S==="_layout"){_.push({filePath:E,urlPrefix:C||"/"});continue}if(Le.has(S))continue;let g=G(S),M=S==="index"?C||"/":C+"/"+g;p.push({filePath:E,routePath:fe(M),isDynamic:M.includes(":")||M.includes("*")})}}function $(P,C){if(!D.existsSync(P))return;let F=D.readdirSync(P,{withFileTypes:!0});for(let k of F){let E=T.join(P,k.name);if(k.isDirectory()){$(E,C+"/"+G(k.name));continue}let u=T.extname(k.name);if(!ce.has(u))continue;let S=T.basename(k.name,u),g=G(S),M=S==="index"?C:C+"/"+g;L.push({filePath:E,routePath:fe(M)})}}return v(e),p.sort((P,C)=>{let F=pe(P.routePath),k=pe(C.routePath);return F-k}),{pages:p,layouts:_,apiRoutes:L}}function G(e){let p=e.match(/^\[\.\.\.(\w+)\]$/);if(p)return"*"+p[1];let _=e.match(/^\[(\w+)\]$/);return _?":"+_[1]:e.toLowerCase()}function fe(e){let p=e.replace(/\/+/g,"/");return p.length>1&&p.endsWith("/")&&(p=p.slice(0,-1)),p||"/"}function pe(e){return e.includes("*")?100:e.includes(":")?10:0}function de(e){let p=e.match(/export\s+const\s+page\s*=\s*(\{[^}]*\})/s);if(!p)return{mode:"client"};try{let _=p[1].replace(/'/g,'"').replace(/(\w+)\s*:/g,'"$1":').replace(/,\s*}/g,"}").replace(/\/\/[^\n]*/g,"");return{mode:"client",...JSON.parse(_)}}catch{return{mode:"client"}}}function Pe(e){return{hasLoader:/export\s+(?:async\s+)?(?:const|let|var|function)\s+loader\b/.test(e),hasGetStaticPaths:/export\s+(?:async\s+)?(?:const|let|var|function)\s+getStaticPaths\b/.test(e),hasPageConfig:/export\s+const\s+page\b/.test(e)}}function ee(e,p){let{pages:_,layouts:L,apiRoutes:v}=ue(e),$=[],P=[],C=new Map;L.forEach((E,u)=>{let S=`_layout${u}`,g=Q(E.filePath,p);$.push(`import ${S} from '${g}';`),C.set(E.urlPrefix,S)}),_.forEach((E,u)=>{let S=`_page${u}`,g=Q(E.filePath,p);$.push(`import ${S} from '${g}';`);let M={mode:"client"},j={hasLoader:!1,hasGetStaticPaths:!1,hasPageConfig:!1};try{let A=D.readFileSync(E.filePath,"utf-8");M=de(A),j=Pe(A)}catch{}let R=Ae(E.routePath,C),W={path:E.routePath,component:S,mode:M.mode||"client",layout:R||null,hasLoader:j.hasLoader};P.push(W)});let F=[];return v.forEach((E,u)=>{let S=`_api${u}`,g=Q(E.filePath,p);$.push(`import * as ${S} from '${g}';`),F.push({path:E.routePath,handlers:S})}),["// Auto-generated by What Framework file router","// Do not edit \u2014 changes will be overwritten","",...$,"","export const routes = [",...P.map(E=>` { path: '${E.path}', component: ${E.component}, mode: '${E.mode}'${E.layout?`, layout: ${E.layout}`:""}${E.hasLoader?", hasLoader: true":""} },`),"];","","export const apiRoutes = [",...F.map(E=>` { path: '${E.path}', handlers: ${E.handlers} },`),"];","","export const pageModes = {",...P.map(E=>` '${E.path}': '${E.mode}',`),"};"].join(`
|
|
2
|
+
`)}function Q(e,p){return"/"+T.relative(p,e).split(T.sep).join("/")}function Ae(e,p){let _=e.split("/").filter(Boolean);for(;_.length>0;){let L="/"+_.join("/");if(p.has(L))return p.get(L);_.pop()}return p.has("/")?p.get("/"):null}var Fe=`
|
|
3
3
|
:host {
|
|
4
4
|
position: fixed;
|
|
5
5
|
inset: 0;
|
|
@@ -185,12 +185,12 @@ var xe=new Set(["preventDefault","stopPropagation","once","capture","passive","s
|
|
|
185
185
|
white-space: pre-wrap;
|
|
186
186
|
line-height: 1.5;
|
|
187
187
|
}
|
|
188
|
-
`,
|
|
188
|
+
`,We=`
|
|
189
189
|
class WhatErrorOverlay extends HTMLElement {
|
|
190
190
|
constructor(err) {
|
|
191
191
|
super();
|
|
192
192
|
this.root = this.attachShadow({ mode: 'open' });
|
|
193
|
-
this.root.innerHTML = '<style>${
|
|
193
|
+
this.root.innerHTML = '<style>${Fe}</style>';
|
|
194
194
|
this._err = err;
|
|
195
195
|
this.show(err);
|
|
196
196
|
}
|
|
@@ -380,7 +380,7 @@ class WhatErrorOverlay extends HTMLElement {
|
|
|
380
380
|
if (!customElements.get('what-error-overlay')) {
|
|
381
381
|
customElements.define('what-error-overlay', WhatErrorOverlay);
|
|
382
382
|
}
|
|
383
|
-
`;function
|
|
383
|
+
`;function me(e){let p=e.ws.send.bind(e.ws);e.ws.send=function(_){return _?.type==="error"&&_.err?.plugin==="vite-plugin-what"&&(_.err._isCompilerError=!0),p(_)}}var he="virtual:what-routes",U="\0"+he,Ne=/export\s+(?:default\s+)?function\s+([A-Z]\w*)/,Ie=/(?:store|signal|state|context|util|helper|lib|config)\b/i;function ie(e={}){let{include:p=/\.[jt]sx$/,exclude:_=/node_modules/,sourceMaps:L=!0,production:v=!0,pages:$="src/pages",hot:P=!v}=e,C="",F="",k=null,E=!1;return{name:"vite-plugin-what",configResolved(u){C=u.root,F=ne.resolve(C,$),E=u.command==="serve"},configureServer(u){k=u,me(u),u.watcher.on("add",S=>{if(S.startsWith(F)){let g=u.moduleGraph.getModuleById(U);g&&(u.moduleGraph.invalidateModule(g),u.ws.send({type:"full-reload"}))}}),u.watcher.on("unlink",S=>{if(S.startsWith(F)){let g=u.moduleGraph.getModuleById(U);g&&(u.moduleGraph.invalidateModule(g),u.ws.send({type:"full-reload"}))}})},resolveId(u){if(u===he)return U},load(u){if(u===U)return ee(F,C)},transform(u,S){if(!p.test(S)||_&&_.test(S))return null;try{let g=Me(u,{filename:S,sourceMaps:L,plugins:[[z,{production:v}]],parserOpts:{plugins:["jsx","typescript"]}});if(!g||!g.code)return null;let M=g.code;return P&&E&&!v&&Te(u,S)&&(M+=Je(S)),{code:M,map:g.map}}catch(g){throw g.plugin="vite-plugin-what",g.id||(g.id=S),g.loc===void 0&&g._loc&&(g.loc={file:S,line:g._loc.line,column:g._loc.column}),console.error(`[what] Error transforming ${S}:`,g.message),g}},handleHotUpdate({file:u,server:S,modules:g}){if(P&&p.test(u)&&!(_&&_.test(u))&&Oe(u))return S.ws.send({type:"full-reload"}),[]},config(u,{mode:S}){return{esbuild:{jsx:"preserve"},optimizeDeps:{exclude:["what-framework","what-core","what-compiler","what-router"]}}}}}function Te(e,p){return!!(Ne.test(e)||p.includes("/pages/")||p.includes("\\pages\\"))}function Oe(e){let p=ne.basename(e,ne.extname(e));return Ie.test(p)}function Je(e){return`
|
|
384
384
|
|
|
385
385
|
// --- What Framework HMR Boundary ---
|
|
386
386
|
if (import.meta.hot) {
|
|
@@ -393,5 +393,5 @@ if (import.meta.hot) {
|
|
|
393
393
|
}
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
|
-
`}import{h as
|
|
396
|
+
`}import{h as Qe,Fragment as en,mount as nn,Island as rn}from"what-core";export{en as Fragment,rn as Island,z as babelPlugin,de as extractPageConfig,ee as generateRoutesModule,Qe as h,nn as mount,ue as scanPages,ie as vitePlugin,ie as what};
|
|
397
397
|
//# sourceMappingURL=index.min.js.map
|