@calmdown/rollup-plugin-pyxis 1.0.0-rc.1
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/index.d.ts +6009 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
- package/readme.md +21 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import*as e from"node:path";function t(e){let t=n(e?.cssModules);return{pyxisModule:e?.pyxisModule??`@calmdown/pyxis`,include:r(e?.include,/\.[cm]?[jt]sx?$/i),exclude:r(e?.exclude),hmr:e?.hmr??!1,cssModules:t&&{include:r(t.include,/\.css$/i),exclude:r(t.exclude),modules:r(t.modules,/\.module\.css$/i),cssExtensionPrefix:t.cssExtensionPrefix??`cl`,lightningcss:t.lightningcss??{}}}}function n(e){switch(typeof e){case`boolean`:return e?{}:null;case`object`:return e;default:return null}}function r(e,t){return e===void 0?t===void 0?[]:[t]:Array.isArray(e)?e:[e]}function i(t){return e.posix.normalize(t.replace(/\\/g,`/`))}function a(e){return e.replace(/\?.*$/,``)}var o=class t{plugin;rootDir=process.cwd();isVite=!1;isDevServer=!1;isHotReload=!1;resolverCache=new Map;pyxisModuleIds=new Set;filters=[];viteCacheDir;context;constructor(n){let r=this;this.plugin={name:t.name,enforce:`pre`,options(t){if(r.isVite)return t;t.cwd&&(r.rootDir=e.resolve(t.cwd));let i=t.transform?.jsx;return i!==void 0&&typeof i!=`object`?t:{...t,transform:{...t.transform,jsx:{...i,importSource:n.pyxisModule}}}},config(e){r.isVite=!0;let t=e.oxc;if(t===!1)return e;let i=t?.jsx;return i!==void 0&&typeof i!=`object`?e:{...e,oxc:{...t,jsx:{...i,importSource:n.pyxisModule}}}},configResolved(e){r.rootDir=e.root,r.isDevServer=!e.isProduction,r.isHotReload=!!e.server.hmr,r.viteCacheDir=e.cacheDir},async buildStart(e){r.rootDir??=e.cwd??process.cwd(),r.context=this;let t=[n.pyxisModule,`${n.pyxisModule}/core`,`${n.pyxisModule}/core-dev`,`${n.pyxisModule}/jsx-runtime`,`${n.pyxisModule}/jsx-dev-runtime`];await Promise.all(t.map(async e=>{r.pyxisModuleIds.add(e);let t=await r.resolveId({source:e});t&&r.pyxisModuleIds.add(t)}))},resolveId:{order:`pre`,async handler(t,n,o){if(n!==void 0){let e=r.resolverCache.get(a(n));e&&(n=e.originalPath)}let s=await this.resolve(t,n,{...o,skipSelf:!0});if(!s)return null;let c=a(s.id),l=r.resolverCache.get(c);if(l)return l.resolved;if(r.isVite&&c.startsWith(r.viteCacheDir))return s;let u=e.relative(r.rootDir,c);if(!(u&&!u.startsWith(`..`)&&!u.startsWith(`.vite`)&&!e.isAbsolute(u)))return s;let d=e=>e.test(c),f=r.filters.filter(e=>e.include.some(d)&&!e.exclude.some(d));if(f.length===0)return s;let p=i(u),m=f.reduce((e,t)=>t.virtualExt??e,``),h=r.isVite?i(e.join(r.rootDir,`@pyxis/${p}${m}`)):p,g={...s,id:h},_={resolved:g,tags:f.reduce((e,t)=>(e.add(t.tag),e),new WeakSet),originalPath:c,relativePath:p,virtualPath:h};return r.resolverCache.set(h,_),r.resolverCache.set(c,_),g}},load:{order:`pre`,handler(e){let t=r.resolverCache.get(a(e));return t?(r.isHotReload&&this.addWatchFile(t.originalPath),this.fs.readFile(t.originalPath,{encoding:`utf8`})):null}},handleHotUpdate({file:e,server:t,modules:n}){let i=r.resolverCache.get(a(e));if(i){let e=t.moduleGraph.getModuleById(i.virtualPath);if(e)return[e]}return n}}}addFilter(e){let t={};return this.filters.push({...e,tag:t}),t}async resolve(e){let{source:t}=e,n=this.resolverCache.get(a(t));if(n)return Promise.resolve(n.resolved);let r=e.importer;if(r!==void 0){let e=this.resolverCache.get(a(r));e&&(r=e.originalPath)}return this.context.resolve(t,r,{...e.options,skipSelf:!1})}async resolveId(e){return(await this.resolve(e))?.id??null}async isPyxisModule(e){if(this.pyxisModuleIds.has(e.source))return!0;let t=await this.resolveId(e);return t!==null&&this.pyxisModuleIds.has(t)}peek(e){return this.resolverCache.get(a(e))??null}load(e){return this.context.load(e)}static name=`@calmdown/rollup-plugin-pyxis:loader`};function s(e,t,n=null){e.parent??=n,t.enter?.(e);let r,i,a,o;for(r in e)if(r!==`parent`)if(i=e[r],Array.isArray(i)){if((o=i.length)>0&&l(i[0]))for(a=0;a<o;a+=1)s(i[a],t,e)}else l(i)&&s(i,t,e);t.leave?.(e)}function c(e,t){let n=e,r;for(;n;){if((r=t(n))!==null)return r;n=n.parent}}function l(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}const u=/\r?\n/g;function d(e){return{code:e,at:0,line:0,column:0}}function f(e,t,n=!1){let{at:r,code:i}=e,{length:a}=i,{at:o,line:s,column:c}=e,l;for(;o<t&&o<a;)if(u.lastIndex=o,l=u.exec(i))if(l.index<t)if(n){c+=l.index-o,o=l.index;break}else s+=1,c=0,o=l.index+l[0].length;else{c+=t-o,o=t;break}else{let e=Math.min(t,a);c+=e-o,o=e}return e.at=o,e.line=s,e.column=c,o-r}function p(e){let{at:t,code:n}=e;switch(n[t]){case`
|
|
2
|
+
`:e.at+=1;break;case`\r`:if(n[t+1]===`
|
|
3
|
+
`){e.at+=2;break}default:throw Error(`invalid state: not at a newline`)}e.line+=1,e.column=0}const m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,h=Array.prototype.reduce.call(m,(e,t,n)=>(e[t]=n,e),{}),g={at:1/0,delta:0};function _(e){let t=e<0?-e<<1|1:e<<1,n,r=``;do n=t&31,t>>>=5,t>0&&(n|=32),r+=m[n];while(t>0);return r}function v(e,t,n,r=0){let i=n.filter(e=>e.delta!==0).sort((e,t)=>e.at-t.at),a=d(e),o=d(t),s=``,c=!1,l=_(r),u=(e,t,n)=>{s+=`${c?`,`:``}${_(e)}${l}${_(t)}${_(n)}`,c=!0},m=()=>{s+=`;`,c=!1},h=0,v=0,y=0,b=0,x=0;for(;o.at<t.length;){u(o.column-y,a.line-h,a.column-v),h=a.line,v=a.column,y=o.column;let e=i[b]??g,t=f(o,e.at+x,!0);if(t>0&&(f(a,a.at+t),u(o.column-y,a.line-h,a.column-v),h=a.line,v=a.column,y=o.column),a.at===e.at){if(e.delta>0){let t=o.at+e.delta;for(;f(o,t,!0),o.at<t;)m(),p(o),y=0;o.column>y&&(u(o.column-y,0,0),y=o.column)}else f(a,e.at-e.delta),u(0,a.line-h,a.column-v),h=a.line,v=a.column;x+=e.delta,b+=1}else m(),p(a),p(o),y=0}return s}function y(e,t){let n=_(t),{length:r}=e,i=``,a=0,o=()=>{let t=e[a];return t!==`,`&&t!==`;`?!1:(i+=t,a+=1,!0)},s=()=>{let t=a;for(;a<r&&((h[e[a++]]??0)&32)>0;);return e.slice(t,a)};for(;a<r;)o()||(i+=s(),!o()&&(s(),i+=n,i+=s(),i+=s(),!o()&&(i+=s(),o())));return i}var b=class{transforms=[];hasTransforms(){return this.transforms.length>0}addTransform(e,t){this.transforms.push({start:e.start,end:e.end,block:t})}transpile(e){let t=this.transforms.toSorted((e,t)=>e.start-t.start||t.end-e.end),n=t.map(e=>({kind:`start`,position:e.start,transform:e})),r=t.map(e=>({kind:`end`,position:e.end,transform:e})).reverse(),i=n.concat(r).sort((e,t)=>e.position-t.position),{length:a}=i,o=[],s=[],c=e,l=0,u=1,d=i[0];for(;u<a;u+=1){let e=i[u];if(e.transform===d.transform){let t=d.position+l,n=e.position+l,r=c.slice(t,n),a=e.transform.block(r,e.transform.start,e.transform.end);a&&(c=c.slice(0,t)+a.newCode+c.slice(n),l+=a.newCode.length-r.length,s.push(...a.edits));let f=i[u+1];switch(f?.kind){case`start`:d=f,u+=1;break;case`end`:if(o.length===0)throw Error(`invalid state: no skipped nodes found`);d=o.pop(),d.position-=l;break}}else{if(d.kind!==`start`)throw Error(`invalid state: disordered nodes`);o.push(d),d.position+=l,d=e}}return{transpiledCode:c,sourcemap:v(e,c,s)}}};function x({loader:t,tag:n,transpile:r}){return{name:`@calmdown/rollup-plugin-pyxis:transpile-tsx`,enforce:`pre`,transform:{order:`pre`,async handler(o,s){let c=t.peek(s);if(c?.tags.has(n)!==!0)return null;let l=S(a(s));if(!l)return null;let u=this.parse(o,{astType:`js`,lang:l}),d=new b;await r.call(this,{code:o,transpiler:d,moduleId:s,relativeId:c.relativePath,ast:u});let f=t.isVite?i(e.relative(c.virtualPath,c.originalPath)):c.relativePath;if(!d.hasTransforms())return{code:o,map:{version:3,sources:[f],sourcesContent:[o],names:[],mappings:v(o,o,[])}};let p=d.transpile(o);return{code:p.transpiledCode,map:{version:3,sources:[f],sourcesContent:[o],names:[],mappings:p.sourcemap}}}}}}function S(t){let n=e.extname(t);return/^\.[cm]?tsx?$/i.test(n)?n.endsWith(`x`)?`tsx`:`ts`:/^\.[cm]?jsx?$/i.test(n)?n.endsWith(`x`)?`jsx`:`js`:null}function C({loader:e,options:t}){let n=`${t.pyxisModule}/core`,r=`${t.pyxisModule}/core-dev`,i=null,a=!1;return{name:`@calmdown/rollup-plugin-pyxis:dev`,enforce:`pre`,apply:`serve`,config(){return a=!0,{resolve:{alias:{[n]:r}}}},resolveId:{order:`pre`,filter:{id:/\/core$/},async handler(t,r,o){return a||t!==n?null:i??=await e.resolve({source:t,importer:r,options:o})}}}}const w=`__HMR_`;async function T({ast:e,transpiler:t}){let n={},r=new Map,i=new Set,a=new Map,o=(e,t)=>{let i;switch(e.type){case`VariableDeclaration`:n[t]=i={kind:`variable`,node:e};break;case`ClassDeclaration`:n[t]=i={kind:`class`,node:e};break;case`FunctionDeclaration`:i=n[t],(!i||i.kind!==`function`)&&(n[t]=i={kind:`function`}),i.node=e;break;case`TSDeclareFunction`:i=n[t],(!i||i.kind!==`function`)&&(n[t]=i={kind:`function`}),(i.overloads??=[]).push(e);break;default:return}r.set(e,i)};for(let s of e.body)switch(s.type){case`VariableDeclaration`:case`FunctionDeclaration`:case`ClassDeclaration`:E(s,e=>{o(s,e.name)});break;case`ExportNamedDeclaration`:{let e=s.declaration;if(e&&(e.type===`TSDeclareFunction`||!A(e))&&(i.add(e),E(e,t=>{o(e,t.name),a.set(t.name,{shouldExport:!0,localName:t.name,exportName:t.name})}),t.addTransform(s,P)),s.exportKind===`type`)break;for(let e of s.specifiers){if(e.local.type!==`Identifier`||e.exported.type!==`Identifier`)continue;let t=e.local.name,r=n[t]?.node;if(r){let n=e.exported.name;i.add(r),a.set(n,{shouldExport:!1,localName:t,exportName:n})}}break}case`ExportDefaultDeclaration`:if(s.declaration.type===`Identifier`){let e=n[s.declaration.name]?.node;e&&(i.add(e),t.addTransform(s,F))}else A(s.declaration)||(r.set(s.declaration,{kind:`default-expression`,node:s.declaration}),i.add(s.declaration),a.set(`default`,{shouldExport:!0,localName:`${w}default`,exportName:`default`}),t.addTransform(s,P));break}if(i.size===0)return;let s=new WeakSet;for(let e of i){let n=r.get(e);if(!(!n||s.has(n)))switch(s.add(n),n.kind){case`variable`:n.node.kind===`const`&&t.addTransform(e,j);break;case`class`:n.node.id&&t.addTransform(e,M(n.node.id.name));break;case`function`:if(!n.node||!n.node.id)break;if(n.overloads){let e=n.node.id.name,r=`${w}${e}`;[...n.overloads,n.node].forEach(e=>{t.addTransform(e,N(r))}),t.addTransform(n.node,I(`\n\nlet ${e} = ${r};`))}else t.addTransform(e,M(n.node.id.name));break;case`default-expression`:t.addTransform(e,M(`${w}default`));break}}let c=`
|
|
4
|
+
`,l=``;for(let e of a.values())c+=`\t\t${JSON.stringify(e.exportName)}: value => { ${e.localName} = value; },\n`,e.shouldExport&&(e.localName===e.exportName?l+=`${e.localName}, `:l+=`${e.localName} as ${e.exportName}, `);let u=`
|
|
5
|
+
|
|
6
|
+
if (import.meta.hot) {
|
|
7
|
+
const setter = {${c}\t};
|
|
8
|
+
import.meta.hot.accept(hmrExports => {
|
|
9
|
+
hmrExports && Object.keys(hmrExports).forEach(key => {
|
|
10
|
+
setter[key]?.(hmrExports[key]);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
`;l&&(u+=`\nexport { ${l.slice(0,-2)} };\n`),t.addTransform(e,I(u))}function E(e,t){switch(e.type){case`VariableDeclaration`:D(e,t);break;case`FunctionDeclaration`:case`TSDeclareFunction`:case`ClassDeclaration`:if(!e.id)break;t(e.id);break}}function D(e,t){for(let n of e.declarations)if(n.init)if(k(n.id))O(n.id,t);else{if(n.id.type!==`Identifier`)continue;t(n.id)}else{if(n.id.type!==`Identifier`)continue;t(n.id)}}function O(e,t){switch(e?.type){case`Identifier`:t(e);break;case`AssignmentPattern`:O(e.left,t);break;case`ObjectPattern`:for(let n of e.properties)O(n.value,t);break;case`ArrayPattern`:for(let n of e.elements)O(n?.type===`RestElement`?n.argument:n,t);break}}function k(e){let{type:t}=e;return t===`ObjectPattern`||t===`ArrayPattern`}function A(e){return e.type.startsWith(`TS`)}const j=(e,t)=>{let n=/^\s*const\s+/.exec(e);if(!n)return null;let r=n[0].length;return{newCode:`let `+e.slice(r),edits:[{at:t,delta:-r},{at:t+r,delta:4}]}},M=e=>(t,n,r)=>({newCode:`let ${e} = (${t});`,edits:[{at:n,delta:e.length+8},{at:r,delta:2}]}),N=e=>(t,n)=>{let r=/^(\s*function\s+)([a-zA-Z_$][a-zA-Z0-9_$]*)(?=[(<\s])/.exec(t);if(!r)return null;let i=r[1].length,a=r[2].length;return{newCode:r[1]+e+t.slice(i+a),edits:[{at:n+i,delta:-a},{at:n+i+a,delta:e.length}]}},P=(e,t)=>{let n=/^\s*export(\s+default)?\s+/.exec(e);if(!n)return null;let r=n[0].length;return{newCode:e.slice(r),edits:[{at:t,delta:-r}]}},F=(e,t)=>({newCode:``,edits:[{at:t,delta:-e.length}]}),I=e=>(t,n,r)=>({newCode:t+e,edits:[{at:r,delta:e.length}]}),L={atomOf:`atom`,component:`component`,createContext:`context`,listOf:`list`,host:`host`},R={atom:2,component:1,context:0,list:2,host:2};async function z({ast:e,moduleId:t,relativeId:n,transpiler:r,loader:i}){let a={},o=!1;for(let n of e.body)if(n.type===`ImportDeclaration`&&n.importKind!==`type`&&await i.isPyxisModule({source:n.source.value,importer:t}))for(let e of n.specifiers){let t;switch(e.type){case`ImportSpecifier`:e.importKind!==`type`&&e.imported.type===`Identifier`&&(t=L[e.imported.name])&&(o=!0,a[e.local.name]={name:e.imported.name,kind:t});break;case`ImportNamespaceSpecifier`:o=!0,a[e.local.name]={name:e.local.name,kind:`namespace`};break}}if(!o)return;let c={},l=new WeakSet,u=(e,t)=>{if(t===`component`)l.add(e);else if(!B(l,e))return;let i=V(e),a=R[t]-e.arguments.length;if(i&&a>=0){let t=`${i}@${n}`,o=(c[t]??0)+1;c[t]=o;let s=o>1?`${t} ${o}`:t;r.addTransform(e,H(s,a))}};s(e,{enter:e=>{if(e.type!==`CallExpression`)return;let t,n;switch(e.callee.type){case`Identifier`:(t=a[e.callee.name])&&t.kind!==`namespace`&&u(e,t.kind);break;case`MemberExpression`:e.callee.property.type===`Identifier`&&(n=L[e.callee.property.name])&&e.callee.object.type===`Identifier`&&(t=a[e.callee.object.name])&&t.kind===`namespace`&&u(e,n);break}}})}function B(e,t){let n=c(t,e=>e.type===`FunctionDeclaration`||e.type===`ArrowFunctionExpression`?e:null);return n&&n.parent?.type===`CallExpression`&&e.has(n.parent)}function V(e){return c(e.parent,e=>{switch(e.type){case`VariableDeclarator`:return e.id.type===`Identifier`?e.id.name:void 0;case`Property`:switch(e.key.type){case`Identifier`:return e.key.name;case`PrivateIdentifier`:return e.key.name;case`Literal`:return typeof e.key.value==`string`?e.key.value:void 0;default:return}case`ExportDefaultDeclaration`:return`default`;default:return null}})}function H(e,t){return(n,r,i)=>{let a=/\s*\)$/.exec(n);if(!a)return null;let o=n.slice(0,a.index),s=``;return/[(,]$/.test(o)||(s+=`, `),s+=`undefined, `.repeat(t),s+=JSON.stringify(e),{newCode:`${o}${s})`,edits:[{at:i-1,delta:s.length}]}}}function U({loader:t,registry:n,options:r,tag:a}){let o=new Map,s;return{name:`@calmdown/rollup-plugin-pyxis:transpile-css`,enforce:`pre`,async buildStart(){try{s??=await import(`lightningcss`)}catch(e){this.error({cause:e,code:`E_DEPENDENCY`,message:`When using the cssModules feature, the LightningCss package must be installed.`})}},transform:{order:`pre`,async handler(c,l){let u=t.peek(l);if(u?.tags.has(a)!==!0)return null;let{originalPath:d,virtualPath:f}=u,p=r.cssModules.modules.some(e=>e.test(d)),m=s.transform({...r.cssModules.lightningcss,code:Buffer.from(c,`utf8`),filename:d,projectRoot:t.rootDir,sourceMap:!0,cssModules:p&&(typeof r.cssModules.lightningcss?.cssModules!=`object`||{...r.cssModules.lightningcss?.cssModules})});for(let e of m.warnings)this.warn({code:e.type,message:e.message,loc:{column:e.loc.column,line:e.loc.line,file:e.loc.filename}});let h={};p&&Object.keys(m.exports).reduce((e,t)=>(e[t]=m.exports[t].name,e),h),n.upsertExports(f,h);let g;try{let e=JSON.parse(m.map.toString(`utf8`));if(e?.version!==3)throw Error(`expected sourcemap version 3`);g=e.mappings??``}catch(e){this.warn({code:`E_SOURCEMAP`,message:`failed to parse sourcemap, ${e.message}`})}let _=m.code.toString(`utf8`);if(t.isVite){let t=i(e.relative(u.virtualPath,u.originalPath));return{moduleType:`js`,moduleSideEffects:`no-treeshake`,code:G(h,l,_),map:{version:3,sources:[t],sourcesContent:[c],names:[],mappings:g}}}return o.set(l,{originalPath:d,mappings:g,originalCode:c,transformedCode:_}),{moduleType:`js`,moduleSideEffects:`no-treeshake`,code:W(h),map:{version:3,sources:[u.relativePath],sourcesContent:[c],names:[],mappings:``}}}},generateBundle(n,r){if(t.isVite)return;let a=n.sourcemap??!1,s=e.resolve(t.rootDir,n.dir??`./dist`),c=n.sourcemapBaseUrl?new URL(n.sourcemapBaseUrl):null,l=Object.values(r).filter(e=>e.type===`chunk`);for(let t of l){let n=`${e.parse(t.fileName).name}.css`,r=t.moduleIds.map(e=>o.get(e)).filter(Boolean);if(r.length===0)continue;let l=r.map(e=>e.transformedCode).join(`
|
|
15
|
+
`);if(a){let t={version:3,sources:r.map(t=>i(e.relative(s,t.originalPath))),sourcesContent:r.map(e=>e.originalCode),names:[],mappings:r.map((e,t)=>y(e.mappings,t)).join(`;`)},a=`${n}.map`;this.emitFile({type:`prebuilt-chunk`,fileName:a,code:JSON.stringify(t)}),l+=`\n/*# sourceMappingURL=${c?new URL(a,c):a} */`}this.emitFile({type:`prebuilt-chunk`,fileName:n,code:l})}}}}function W(e){return`
|
|
16
|
+
export default ${JSON.stringify(e,null,` `)};
|
|
17
|
+
`}function G(e,t,n){return`
|
|
18
|
+
import { removeStyle, updateStyle } from "/@vite/client";
|
|
19
|
+
|
|
20
|
+
const moduleId = ${JSON.stringify(t)};
|
|
21
|
+
const cssCode = ${JSON.stringify(n)};
|
|
22
|
+
|
|
23
|
+
updateStyle(moduleId, cssCode);
|
|
24
|
+
import.meta.hot.accept();
|
|
25
|
+
import.meta.hot.prune(() => removeStyle(moduleId));
|
|
26
|
+
${W(e)}
|
|
27
|
+
`}var K=class{loader;mappings=new Map;constructor(e){this.loader=e}upsertExports(e,t){this.mappings.set(e,t)}async getExports(e,t){let n=e,r;return(r=this.mappings.get(n))?r:(n=await this.loader.resolveId({source:e,importer:t}),n?(r=this.mappings.get(n))?r:(await this.loader.load({id:n,resolveDependencies:!1}),this.mappings.get(n)??null):null)}};const q={jsx:!0,jsxs:!0,jsxDEV:!0};async function J({ast:e,transpiler:t,moduleId:n,loader:r,registry:i,options:o}){let c={},l={},u=!1,d,f;for(d of e.body){if(d.type!==`ImportDeclaration`||d.importKind===`type`)continue;let e=a(d.source.value);if(Y(o,e)){let t=await i.getExports(e,n);t&&(Object.assign(l,t),u=!0);continue}if(await r.isPyxisModule({source:e,importer:n}))for(f of d.specifiers)switch(f.type){case`ImportSpecifier`:f.importKind!==`type`&&f.imported.type===`Identifier`&&q[f.imported.name]&&(c[f.local.name]={name:f.imported.name,kind:`jsx`});break;case`ImportNamespaceSpecifier`:c[f.local.name]={name:f.local.name,kind:`namespace`};break}}if(!u)return;let p=o.cssModules.cssExtensionPrefix,m=e=>{let n;e.name.type===`JSXNamespacedName`&&e.name.namespace.name===p&&(n=l[e.name.name.name])&&t.addTransform(e.name.name,X(n))},h=e=>{if(e.arguments.length<2)return;let n=e.arguments[1];if(n.type!==`ObjectExpression`)return;let r,i;for(let e of n.properties)e.type===`Property`&&e.key.type===`Literal`&&typeof(r=e.key.value)==`string`&&r.startsWith(`${p}:`)&&(i=l[r.slice(p.length+1)])&&t.addTransform(e.key,Z(`${p}:${i}`))};s(e,{enter:e=>{if(e.type===`JSXAttribute`)m(e);else if(e.type===`CallExpression`){let t;switch(e.callee.type){case`Identifier`:(t=c[e.callee.name])&&t.kind===`jsx`&&h(e);break;case`MemberExpression`:e.callee.property.type===`Identifier`&&q[e.callee.property.name]&&e.callee.object.type===`Identifier`&&(t=c[e.callee.object.name])&&t.kind===`namespace`&&h(e);break}}}})}function Y(e,t){let n=/\.js$/.test(t)?t.slice(0,-3):t;return e.cssModules.modules.some(e=>e.test(n))}function X(e){return(t,n)=>{let r=t.length;return{newCode:e,edits:[{at:n,delta:-r},{at:n+r,delta:e.length}]}}}function Z(e){return(t,n)=>{if(t[0]!==t[t.length-1]||!/["'`]/.test(t[0]))return null;let r=JSON.stringify(e),i=t.length;return{newCode:r,edits:[{at:n,delta:-i},{at:n+i,delta:r.length}]}}}function Q(e){let n=t(e),r=new o(n),i=new K(r),a=[r.plugin],s=r.addFilter({include:n.include,exclude:n.exclude});if(n.hmr&&a.push(C({loader:r,options:n})),n.cssModules){let e=r.addFilter({include:n.cssModules.include,exclude:n.cssModules.exclude,virtualExt:`.js`});a.push(U({loader:r,registry:i,options:n,tag:e}))}return(n.hmr||n.cssModules)&&a.push(x({loader:r,tag:s,async transpile(e){n.hmr&&(await T(e),await z({...e,loader:r})),n.cssModules&&await J({...e,loader:r,registry:i,options:n})}})),a}export{Q as default};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/options.ts","../src/utils.ts","../src/PyxisLoader.ts","../src/transpiler/ast.ts","../src/transpiler/position.ts","../src/transpiler/sourcemap.ts","../src/transpiler/Transpiler.ts","../src/transpiler/pyxisTranspileTsx.ts","../src/hmr/pyxisDev.ts","../src/hmr/transpileExportedSymbols.ts","../src/hmr/transpileFactoryCalls.ts","../src/cssModules/pyxisTranspileCss.ts","../src/cssModules/CssExportsRegistry.ts","../src/cssModules/transpileClassNames.ts","../src/index.ts"],"sourcesContent":["import type { CSSModulesConfig, TransformOptions } from \"lightningcss\";\n\nexport interface PyxisPluginOptions {\n\t/**\n\t * The name of the Pyxis module.\n\t * @default \"@calmdown/pyxis\"\n\t */\n\tpyxisModule?: string;\n\n\t/**\n\t * Regular expression(s) matching file paths of source files to process.\n\t * @default /\\.[cm]?[jt]sx?$/i\n\t */\n\tinclude?: RegExp | RegExp[];\n\n\t/**\n\t * Regular expression(s) matching file paths to exclude from processing.\n\t * @default undefined\n\t */\n\texclude?: RegExp | RegExp[];\n\n\t/**\n\t * Whether to apply transformations to enable hot module replacement (HMR) with Vite dev server.\n\t * @default false\n\t */\n\thmr?: boolean;\n\n\t/**\n\t * Whether to enable transformations for CSS modules. A string may be passed to specify a glob\n\t * to match CSS module files.\n\t *\n\t * Note that to use this feature, the optional `lightningcss` dependency **must be installed**.\n\t * @default false\n\t */\n\tcssModules?: PyxisCssModulesOptions | null | boolean;\n}\n\nexport interface PyxisCssModulesOptions {\n\t/**\n\t * Regular expression(s) matching file paths to consider as CSS sources.\n\t * @default /\\.css$/i\n\t */\n\tinclude?: RegExp | RegExp[];\n\n\t/**\n\t * Regular expression(s) matching file paths NOT to consider as CSS sources.\n\t * @default undefined\n\t */\n\texclude?: RegExp | RegExp[];\n\n\t/**\n\t * Regular expression(s) matching CSS sources to consider as CSS modules.\n\t * @default /\\.module\\.css$/i\n\t */\n\tmodules?: RegExp | RegExp[];\n\n\t/**\n\t * The prefix of the `ClassListExtension` to rewrite class names for.\n\t * @default \"cl\"\n\t */\n\tcssExtensionPrefix?: string;\n\n\t/**\n\t * Custom Lightning CSS option overrides.\n\t * @default {}\n\t */\n\tlightningcss?: Omit<TransformOptions<any>, \"code\" | \"cssModules\" | \"filename\" | \"projectRoot\" | \"sourceMap\"> & {\n\t\tcssModules?: CSSModulesConfig | true;\n\t};\n}\n\n/** @internal */\nexport type ResolvedPyxisPluginOptions = ReturnType<typeof resolveOptions>;\n\n/** @internal */\nexport function resolveOptions(options?: PyxisPluginOptions) {\n\tconst cssModules = toObject(options?.cssModules);\n\treturn {\n\t\tpyxisModule: options?.pyxisModule ?? \"@calmdown/pyxis\",\n\t\tinclude: toArray(options?.include, /\\.[cm]?[jt]sx?$/i),\n\t\texclude: toArray(options?.exclude),\n\t\thmr: options?.hmr ?? false,\n\t\tcssModules: cssModules && {\n\t\t\tinclude: toArray(cssModules.include, /\\.css$/i),\n\t\t\texclude: toArray(cssModules.exclude),\n\t\t\tmodules: toArray(cssModules.modules, /\\.module\\.css$/i),\n\t\t\tcssExtensionPrefix: cssModules.cssExtensionPrefix ?? \"cl\",\n\t\t\tlightningcss: cssModules.lightningcss ?? {},\n\t\t},\n\t} satisfies PyxisPluginOptions;\n}\n\nfunction toObject<T>(value: T | boolean | undefined) {\n\tswitch (typeof value) {\n\t\tcase \"boolean\":\n\t\t\treturn value ? {} as T : null;\n\n\t\tcase \"object\":\n\t\t\treturn value;\n\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction toArray<T>(value: T | T[] | undefined, defaultValue?: T) {\n\treturn value === undefined\n\t\t? defaultValue === undefined\n\t\t\t? []\n\t\t\t: [ defaultValue ]\n\t\t: Array.isArray(value)\n\t\t\t? value\n\t\t\t: [ value ];\n}\n","import * as Path from \"node:path\";\n\nexport function normalizePath(moduleId: string) {\n\treturn Path.posix.normalize(moduleId.replace(/\\\\/g, '/'));\n}\n\nexport function trimQuery(url: string) {\n\treturn url.replace(/\\?.*$/, \"\");\n}\n","import * as Path from \"node:path\";\n\nimport type { PluginContext, PluginContextResolveOptions, ResolvedId } from \"rolldown\";\nimport type { Plugin } from \"vite\";\n\nimport type { ResolvedPyxisPluginOptions } from \"./options\";\nimport { normalizePath, trimQuery } from \"./utils\";\n\nexport interface ResolverCall {\n\tsource: string;\n\timporter?: string;\n\toptions?: PluginContextResolveOptions;\n}\n\nexport interface PyxisModuleFilter {\n\tinclude: RegExp[];\n\texclude: RegExp[];\n\tvirtualExt?: string;\n}\n\nexport interface PyxisModuleEntry {\n\treadonly resolved: ResolvedId;\n\treadonly originalPath: string;\n\treadonly relativePath: string;\n\treadonly virtualPath: string;\n\treadonly tags: WeakSet<WeakKey>;\n}\n\nexport class PyxisLoader {\n\tpublic readonly plugin: Plugin;\n\tpublic rootDir: string = process.cwd();\n\tpublic isVite: boolean = false;\n\tpublic isDevServer: boolean = false;\n\tpublic isHotReload: boolean = false;\n\n\tprivate readonly resolverCache = new Map<string, PyxisModuleEntry>();\n\tprivate readonly pyxisModuleIds = new Set<string>();\n\tprivate readonly filters: (PyxisModuleFilter & { tag: WeakKey })[] = [];\n\tprivate viteCacheDir?: string;\n\tprivate context!: PluginContext;\n\n\tpublic constructor(options: ResolvedPyxisPluginOptions) {\n\t\tconst self = this;\n\n\t\tthis.plugin = {\n\t\t\tname: PyxisLoader.name,\n\t\t\tenforce: \"pre\",\n\t\t\toptions(config) {\n\t\t\t\t// Rollup, Rolldown, Vite hook\n\t\t\t\tif (self.isVite) {\n\t\t\t\t\treturn config;\n\t\t\t\t}\n\n\t\t\t\tif (config.cwd) {\n\t\t\t\t\tself.rootDir = Path.resolve(config.cwd);\n\t\t\t\t}\n\n\t\t\t\tconst jsx = config.transform?.jsx;\n\t\t\t\tif (jsx !== undefined && typeof jsx !== \"object\") {\n\t\t\t\t\treturn config;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...config,\n\t\t\t\t\ttransform: {\n\t\t\t\t\t\t...config.transform,\n\t\t\t\t\t\tjsx: {\n\t\t\t\t\t\t\t...jsx,\n\t\t\t\t\t\t\timportSource: options.pyxisModule,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tconfig(config) {\n\t\t\t\t// Vite-only hook\n\t\t\t\tself.isVite = true;\n\n\t\t\t\tconst oxc = config.oxc;\n\t\t\t\tif (oxc === false) {\n\t\t\t\t\treturn config;\n\t\t\t\t}\n\n\t\t\t\tconst jsx = oxc?.jsx;\n\t\t\t\tif (jsx !== undefined && typeof jsx !== \"object\") {\n\t\t\t\t\treturn config;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...config,\n\t\t\t\t\toxc: {\n\t\t\t\t\t\t...oxc,\n\t\t\t\t\t\tjsx: {\n\t\t\t\t\t\t\t...jsx,\n\t\t\t\t\t\t\timportSource: options.pyxisModule,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tconfigResolved(viteConfig) {\n\t\t\t\t// Vite-only hook\n\t\t\t\tself.rootDir = viteConfig.root;\n\t\t\t\tself.isDevServer = !viteConfig.isProduction;\n\t\t\t\tself.isHotReload = !!viteConfig.server.hmr;\n\t\t\t\tself.viteCacheDir = viteConfig.cacheDir;\n\t\t\t},\n\t\t\tasync buildStart(inputOptions) {\n\t\t\t\t// Rollup, Rolldown, Vite hook\n\t\t\t\tself.rootDir ??= inputOptions.cwd ?? process.cwd();\n\t\t\t\tself.context = this;\n\n\t\t\t\t// pre-resolve Pyxis imports\n\t\t\t\tconst moduleIds = [\n\t\t\t\t\toptions.pyxisModule,\n\t\t\t\t\t`${options.pyxisModule}/core`,\n\t\t\t\t\t`${options.pyxisModule}/core-dev`,\n\t\t\t\t\t`${options.pyxisModule}/jsx-runtime`,\n\t\t\t\t\t`${options.pyxisModule}/jsx-dev-runtime`,\n\t\t\t\t];\n\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tmoduleIds.map(async source => {\n\t\t\t\t\t\tself.pyxisModuleIds.add(source);\n\n\t\t\t\t\t\tconst id = await self.resolveId({ source });\n\t\t\t\t\t\tid && self.pyxisModuleIds.add(id);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\tresolveId: {\n\t\t\t\torder: \"pre\",\n\t\t\t\tasync handler(source, importer, options) {\n\t\t\t\t\tif (importer !== undefined) {\n\t\t\t\t\t\t// importer should be a previously resolved path, so it should be cached\n\t\t\t\t\t\tconst importerHit = self.resolverCache.get(trimQuery(importer));\n\t\t\t\t\t\tif (importerHit) {\n\t\t\t\t\t\t\timporter = importerHit.originalPath;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// let the bundler resolve it\n\t\t\t\t\tconst result = await this.resolve(source, importer, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tskipSelf: true,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!result) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// check cache\n\t\t\t\t\tconst originalPath = trimQuery(result.id);\n\t\t\t\t\tconst sourceHit = self.resolverCache.get(originalPath);\n\t\t\t\t\tif (sourceHit) {\n\t\t\t\t\t\treturn sourceHit.resolved;\n\t\t\t\t\t}\n\n\t\t\t\t\t// match filters\n\t\t\t\t\tif (self.isVite && originalPath.startsWith(self.viteCacheDir!)) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relativePathRaw = Path.relative(self.rootDir, originalPath);\n\t\t\t\t\tconst isWithinRoot = (\n\t\t\t\t\t\trelativePathRaw &&\n\t\t\t\t\t\t!relativePathRaw.startsWith(\"..\") &&\n\t\t\t\t\t\t!relativePathRaw.startsWith(\".vite\") &&\n\t\t\t\t\t\t!Path.isAbsolute(relativePathRaw)\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!isWithinRoot) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst matchesRegExp = (pattern: RegExp) => pattern.test(originalPath);\n\t\t\t\t\tconst matchesFilter = (filter: PyxisModuleFilter) => filter.include.some(matchesRegExp) && !filter.exclude.some(matchesRegExp);\n\t\t\t\t\tconst matchingFilters = self.filters.filter(matchesFilter);\n\t\t\t\t\tif (matchingFilters.length === 0) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\n\t\t\t\t\t// build virtual override\n\t\t\t\t\tconst relativePath = normalizePath(relativePathRaw);\n\t\t\t\t\tconst virtualExt = matchingFilters.reduce((ext, filter) => filter.virtualExt ?? ext, \"\");\n\t\t\t\t\tconst virtualPath = self.isVite\n\t\t\t\t\t\t? normalizePath(Path.join(self.rootDir, `${__VIRTUAL_DIR__}/${relativePath}${virtualExt}`))\n\t\t\t\t\t\t: relativePath;\n\n\t\t\t\t\tconst override: ResolvedId = {\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\tid: virtualPath,\n\t\t\t\t\t};\n\n\t\t\t\t\tconst entry: PyxisModuleEntry = {\n\t\t\t\t\t\tresolved: override,\n\t\t\t\t\t\ttags: matchingFilters.reduce((tags, filter) => (tags.add(filter.tag), tags), new WeakSet()),\n\t\t\t\t\t\toriginalPath,\n\t\t\t\t\t\trelativePath,\n\t\t\t\t\t\tvirtualPath,\n\t\t\t\t\t};\n\n\t\t\t\t\tself.resolverCache.set(virtualPath, entry);\n\t\t\t\t\tself.resolverCache.set(originalPath, entry);\n\t\t\t\t\treturn override;\n\t\t\t\t},\n\t\t\t},\n\t\t\tload: {\n\t\t\t\torder: \"pre\",\n\t\t\t\thandler(moduleId) {\n\t\t\t\t\tconst entry = self.resolverCache.get(trimQuery(moduleId));\n\t\t\t\t\tif (!entry) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (self.isHotReload) {\n\t\t\t\t\t\tthis.addWatchFile(entry.originalPath);\n\t\t\t\t\t}\n\n\t\t\t\t\t// FUTURE: detect encoding first?\n\t\t\t\t\treturn this.fs.readFile(entry.originalPath, { encoding: \"utf8\" });\n\t\t\t\t},\n\t\t\t},\n\t\t\thandleHotUpdate({ file, server, modules }) {\n\t\t\t\tconst entry = self.resolverCache.get(trimQuery(file));\n\t\t\t\tif (entry) {\n\t\t\t\t\tconst virtualModule = server.moduleGraph.getModuleById(entry.virtualPath);\n\t\t\t\t\tif (virtualModule) {\n\t\t\t\t\t\treturn [ virtualModule ];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn modules;\n\t\t\t},\n\t\t};\n\t}\n\n\n\tpublic addFilter(filter: PyxisModuleFilter): WeakKey {\n\t\tconst tag: WeakKey = {};\n\t\tthis.filters.push({ ...filter, tag });\n\n\t\treturn tag;\n\t}\n\n\tpublic async resolve(call: ResolverCall) {\n\t\tconst { source } = call;\n\n\t\tconst hit = this.resolverCache.get(trimQuery(source));\n\t\tif (hit) {\n\t\t\treturn Promise.resolve(hit.resolved);\n\t\t}\n\n\t\tlet importer = call.importer;\n\t\tif (importer !== undefined) {\n\t\t\t// importer should be a previously resolved path, so it should be cached\n\t\t\tconst importerHit = this.resolverCache.get(trimQuery(importer));\n\t\t\tif (importerHit) {\n\t\t\t\timporter = importerHit.originalPath;\n\t\t\t}\n\t\t}\n\n\t\treturn this.context.resolve(source, importer, {\n\t\t\t...call.options,\n\t\t\tskipSelf: false,\n\t\t});\n\t}\n\n\tpublic async resolveId(call: ResolverCall) {\n\t\tconst result = await this.resolve(call);\n\t\treturn result?.id ?? null;\n\t}\n\n\tpublic async isPyxisModule(call: ResolverCall) {\n\t\tif (this.pyxisModuleIds.has(call.source)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst id = await this.resolveId(call);\n\t\treturn id === null\n\t\t\t? false\n\t\t\t: this.pyxisModuleIds.has(id);\n\t}\n\n\tpublic peek(moduleId: string) {\n\t\treturn this.resolverCache.get(trimQuery(moduleId)) ?? null;\n\t}\n\n\tpublic load(options: Parameters<PluginContext[\"load\"]>[0]) {\n\t\treturn this.context.load(options);\n\t}\n\n\n\tpublic static readonly name = `${__THIS_PLUGIN__}:loader`;\n}\n","import type * as AST from \"@oxc-project/types\";\n\nexport type { AST };\n\nexport interface WalkCallbacks {\n\tenter?: (node: AST.Node) => void;\n\tleave?: (node: AST.Node) => void;\n}\n\nexport function walkDown(node: AST.Node, callbacks: WalkCallbacks, parent: AST.Node | null = null) {\n\tnode.parent ??= parent;\n\tcallbacks.enter?.(node);\n\n\tlet prop;\n\tlet children: any;\n\tlet index;\n\tlet length;\n\tfor (prop in node) {\n\t\tif (prop === \"parent\") {\n\t\t\tcontinue;\n\t\t}\n\n\t\tchildren = node[prop as keyof AST.Node];\n\t\tif (Array.isArray(children)) {\n\t\t\tif ((length = children.length) > 0 && isNode(children[0])) {\n\t\t\t\tfor (index = 0; index < length; index += 1) {\n\t\t\t\t\twalkDown(children[index], callbacks, node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (isNode(children)) {\n\t\t\twalkDown(children, callbacks, node);\n\t\t}\n\t}\n\n\tcallbacks.leave?.(node);\n}\n\nexport function walkUp<T>(node: AST.Node | null | undefined, callback: (node: AST.Node) => T | null) {\n\tlet current = node;\n\tlet rval;\n\twhile (current) {\n\t\tif ((rval = callback(current)) !== null) {\n\t\t\treturn rval;\n\t\t}\n\n\t\tcurrent = current.parent;\n\t}\n}\n\nfunction isNode(value: any): value is AST.Node {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof value.type === \"string\"\n\t);\n}\n","interface CodePosition {\n\treadonly code: string;\n\tat: number;\n\tline: number;\n\tcolumn: number;\n}\n\nconst RE_NEWLINE = /\\r?\\n/g;\n\nexport function createPosition(code: string): CodePosition {\n\treturn {\n\t\tcode,\n\t\tat: 0,\n\t\tline: 0,\n\t\tcolumn: 0,\n\t};\n}\n\nexport function positionAt(code: string, at: number) {\n\tconst pos = createPosition(code);\n\tadvanceTo(pos, at);\n\treturn pos;\n}\n\nexport function advanceTo(pos: CodePosition, to: number, stopAtEol = false) {\n\tconst { at: startAt, code } = pos;\n\tconst { length } = code;\n\tlet { at, line, column } = pos;\n\tlet match;\n\n\twhile (at < to && at < length) {\n\t\tRE_NEWLINE.lastIndex = at;\n\t\tif (match = RE_NEWLINE.exec(code)) {\n\t\t\tif (match.index < to) {\n\t\t\t\tif (stopAtEol) {\n\t\t\t\t\tcolumn += match.index - at;\n\t\t\t\t\tat = match.index;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tline += 1;\n\t\t\t\t\tcolumn = 0;\n\t\t\t\t\tat = match.index + match[0].length;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcolumn += to - at;\n\t\t\t\tat = to;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tconst stop = Math.min(to, length);\n\t\t\tcolumn += stop - at;\n\t\t\tat = stop;\n\t\t}\n\t}\n\n\tpos.at = at;\n\tpos.line = line;\n\tpos.column = column;\n\treturn at - startAt;\n}\n\nexport function advanceNewLine(pos: CodePosition) {\n\tconst { at, code } = pos;\n\tswitch (code[at]) {\n\t\tcase \"\\n\":\n\t\t\tpos.at += 1;\n\t\t\tbreak;\n\n\t\tcase \"\\r\":\n\t\t\tif (code[at + 1] === \"\\n\") {\n\t\t\t\tpos.at += 2;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// fall through\n\n\t\tdefault:\n\t\t\tthrow new Error(\"invalid state: not at a newline\");\n\t}\n\n\tpos.line += 1;\n\tpos.column = 0;\n}\n","import { advanceNewLine, advanceTo, createPosition } from \"./position\";\n\nexport interface Edit {\n\treadonly at: number;\n\treadonly delta: number;\n}\n\nconst VLQ_ENCODE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst VLQ_DECODE = (Array.prototype.reduce<Record<string, number>>).call(\n\tVLQ_ENCODE,\n\t(map, char, id) => (map[char] = id, map),\n\t{},\n);\n\nconst NO_EDIT: Edit = {\n\tat: Infinity,\n\tdelta: 0,\n};\n\nfunction encodeVLQ(value: number): string {\n\tlet remainder = value < 0 ? ((-value << 1) | 1) : (value << 1); // zig-zag\n\tlet digit;\n\tlet vlq = \"\";\n\n\tdo {\n\t\tdigit = remainder & 0b11111;\n\t\tremainder >>>= 5;\n\t\tif (remainder > 0) {\n\t\t\tdigit |= 0b100000;\n\t\t}\n\n\t\tvlq += VLQ_ENCODE[digit];\n\t}\n\twhile (remainder > 0);\n\n\treturn vlq;\n}\n\nexport function buildSourcemap(\n\toriginalCode: string,\n\ttranspiledCode: string,\n\tedits: readonly Edit[],\n\tsourceIndex = 0,\n) {\n\tconst sortedEdits = edits\n\t\t.filter(it => it.delta !== 0)\n\t\t.sort((a, b) => a.at - b.at);\n\n\tconst original = createPosition(originalCode);\n\tconst transpiled = createPosition(transpiledCode);\n\n\tlet mapping = \"\";\n\tlet needsSeparator = false;\n\n\tconst sourceIndexVLQ = encodeVLQ(sourceIndex);\n\tconst addSegment = (tColDelta: number, oLineDelta: number, oColDelta: number) => {\n\t\tmapping += `${needsSeparator ? \",\" : \"\"}${encodeVLQ(tColDelta)}${sourceIndexVLQ}${encodeVLQ(oLineDelta)}${encodeVLQ(oColDelta)}`;\n\t\tneedsSeparator = true;\n\t};\n\n\tconst addLine = () => {\n\t\tmapping += \";\";\n\t\tneedsSeparator = false;\n\t};\n\n\tlet oPrevLine = 0;\n\tlet oPrevCol = 0;\n\tlet tPrevCol = 0;\n\tlet editIndex = 0;\n\tlet offset = 0;\n\n\twhile (transpiled.at < transpiledCode.length) {\n\n\t\taddSegment(transpiled.column - tPrevCol, original.line - oPrevLine, original.column - oPrevCol);\n\t\toPrevLine = original.line;\n\t\toPrevCol = original.column;\n\t\ttPrevCol = transpiled.column;\n\n\t\tconst edit = sortedEdits[editIndex] ?? NO_EDIT;\n\t\tconst skip = advanceTo(transpiled, edit.at + offset, true);\n\n\t\t// advance past unchanged code\n\t\tif (skip > 0) {\n\t\t\tadvanceTo(original, original.at + skip);\n\t\t\taddSegment(transpiled.column - tPrevCol, original.line - oPrevLine, original.column - oPrevCol);\n\t\t\toPrevLine = original.line;\n\t\t\toPrevCol = original.column;\n\t\t\ttPrevCol = transpiled.column;\n\t\t}\n\n\t\t// reached the next edit\n\t\tif (original.at === edit.at) {\n\t\t\tif (edit.delta > 0) {\n\t\t\t\t// transpiled code inserted\n\t\t\t\tconst limit = transpiled.at + edit.delta;\n\t\t\t\twhile (true) {\n\t\t\t\t\tadvanceTo(transpiled, limit, true);\n\t\t\t\t\tif (transpiled.at < limit) {\n\t\t\t\t\t\taddLine();\n\t\t\t\t\t\tadvanceNewLine(transpiled);\n\t\t\t\t\t\ttPrevCol = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (transpiled.column > tPrevCol) {\n\t\t\t\t\taddSegment(transpiled.column - tPrevCol, 0, 0);\n\t\t\t\t\ttPrevCol = transpiled.column;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// original code deleted\n\t\t\t\tadvanceTo(original, edit.at - edit.delta);\n\t\t\t\taddSegment(0, original.line - oPrevLine, original.column - oPrevCol);\n\t\t\t\toPrevLine = original.line;\n\t\t\t\toPrevCol = original.column;\n\t\t\t}\n\n\t\t\toffset += edit.delta;\n\t\t\teditIndex += 1;\n\t\t}\n\t\telse {\n\t\t\taddLine();\n\t\t\tadvanceNewLine(original);\n\t\t\tadvanceNewLine(transpiled);\n\t\t\ttPrevCol = 0;\n\t\t}\n\t}\n\n\treturn mapping;\n}\n\nexport function replaceSourceIndex(mapping: string, newSourceIndex: number) {\n\tconst newSourceIndexVLQ = encodeVLQ(newSourceIndex);\n\tconst { length } = mapping;\n\tlet result = \"\";\n\tlet index = 0;\n\n\tconst endOfSegmentOrLine = () => {\n\t\tconst char = mapping[index];\n\t\tif (char !== \",\" && char !== \";\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tresult += char;\n\t\tindex += 1;\n\t\treturn true;\n\t};\n\n\tconst nextValue = () => {\n\t\tconst anchor = index;\n\t\twhile (index < length && ((VLQ_DECODE[mapping[index++]] ?? 0) & 0b100000) > 0) ;\n\n\t\treturn mapping.slice(anchor, index);\n\t};\n\n\twhile (index < length) {\n\t\tif (endOfSegmentOrLine()) {\n\t\t\tcontinue; // empty line\n\t\t}\n\n\t\tresult += nextValue(); // transpiled column\n\t\tif (endOfSegmentOrLine()) {\n\t\t\tcontinue; // single field segment\n\t\t}\n\n\t\tnextValue();\n\t\tresult += newSourceIndexVLQ; // replaced source index\n\t\tresult += nextValue(); // original line\n\t\tresult += nextValue(); // original column\n\n\t\tif (endOfSegmentOrLine()) {\n\t\t\tcontinue; // four fields segment\n\t\t}\n\n\t\tresult += nextValue(); // name index\n\t\tendOfSegmentOrLine();\n\t}\n\n\treturn result;\n}\n","import type { AST } from \"./ast\";\nimport { buildSourcemap, type Edit } from \"./sourcemap\";\n\nexport interface Transform {\n\treadonly start: number;\n\treadonly end: number;\n\treadonly block: TransformBlock;\n}\n\nexport interface TransformBlock {\n\t(\n\t\toriginalCode: string,\n\t\tstart: number,\n\t\tend: number,\n\t): TransformResult | null;\n}\n\nexport interface TransformResult {\n\treadonly newCode: string;\n\treadonly edits: Edit[];\n}\n\ninterface Boundary {\n\treadonly kind: \"start\" | \"end\";\n\treadonly transform: Transform;\n\tposition: number;\n}\n\nexport class Transpiler {\n\tprivate readonly transforms: Transform[] = [];\n\n\tpublic hasTransforms() {\n\t\treturn this.transforms.length > 0;\n\t}\n\n\tpublic addTransform(node: AST.Node, block: TransformBlock) {\n\t\tthis.transforms.push({\n\t\t\tstart: node.start,\n\t\t\tend: node.end,\n\t\t\tblock,\n\t\t});\n\t}\n\n\tpublic transpile(originalCode: string) {\n\t\t// pre-sort transforms\n\t\tconst sortedTransforms = this.transforms.toSorted((a, b) => (a.start - b.start) || (b.end - a.end));\n\n\t\t// generate start and end boundaries separately, with end bounds in reverse order\n\t\tconst startBoundaries = sortedTransforms\n\t\t\t.map<Boundary>(transform => ({\n\t\t\t\tkind: \"start\",\n\t\t\t\tposition: transform.start,\n\t\t\t\ttransform,\n\t\t\t}));\n\n\t\tconst endBoundaries = sortedTransforms\n\t\t\t.map<Boundary>(transform => ({\n\t\t\t\tkind: \"end\",\n\t\t\t\tposition: transform.end,\n\t\t\t\ttransform,\n\t\t\t}))\n\t\t\t.reverse();\n\n\t\t// concat and re-sort - relying on stable sort\n\t\t// this way nested boundaries will be in the correct order\n\t\tconst boundaries = startBoundaries\n\t\t\t.concat(endBoundaries)\n\t\t\t.sort((a, b) => a.position - b.position); // stable sort\n\n\t\t// run transformations, gathering edits made to the code\n\t\t// transforms apply deep-first, and in order when at the same depth\n\t\tconst { length } = boundaries;\n\t\tconst skipped: Boundary[] = [];\n\t\tconst edits: Edit[] = [];\n\n\t\tlet transpiledCode = originalCode;\n\t\tlet offset = 0;\n\t\tlet index = 1;\n\t\tlet prev = boundaries[0];\n\n\t\tfor (; index < length; index += 1) {\n\t\t\tlet next = boundaries[index];\n\n\t\t\tif (next.transform === prev.transform) {\n\t\t\t\tconst start = prev.position + offset;\n\t\t\t\tconst end = next.position + offset;\n\n\t\t\t\tconst originalCode = transpiledCode.slice(start, end);\n\t\t\t\tconst result = next.transform.block(originalCode, next.transform.start, next.transform.end);\n\t\t\t\tif (result) {\n\t\t\t\t\ttranspiledCode = (\n\t\t\t\t\t\ttranspiledCode.slice(0, start) +\n\t\t\t\t\t\tresult.newCode +\n\t\t\t\t\t\ttranspiledCode.slice(end)\n\t\t\t\t\t);\n\n\t\t\t\t\toffset += result.newCode.length - originalCode.length;\n\t\t\t\t\tedits.push(...result.edits);\n\t\t\t\t}\n\n\t\t\t\tconst peek = boundaries[index + 1];\n\t\t\t\tswitch (peek?.kind) {\n\t\t\t\t\tcase \"start\":\n\t\t\t\t\t\tprev = peek;\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"end\":\n\t\t\t\t\t\tif (skipped.length === 0) {\n\t\t\t\t\t\t\tthrow new Error(\"invalid state: no skipped nodes found\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tprev = skipped.pop()!;\n\t\t\t\t\t\tprev.position -= offset;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (prev.kind !== \"start\") {\n\t\t\t\t\tthrow new Error(\"invalid state: disordered nodes\");\n\t\t\t\t}\n\n\t\t\t\tskipped.push(prev);\n\t\t\t\tprev.position += offset;\n\t\t\t\tprev = next;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\ttranspiledCode,\n\t\t\tsourcemap: buildSourcemap(originalCode, transpiledCode, edits),\n\t\t};\n\t}\n}\n","import * as Path from \"node:path\";\n\nimport type { TransformPluginContext } from \"rolldown\";\nimport type { Plugin } from \"vite\";\n\nimport { PyxisLoader } from \"~/PyxisLoader\";\nimport { normalizePath, trimQuery } from \"~/utils\";\n\nimport type { AST } from \"./ast\";\nimport { Transpiler } from \"./Transpiler\";\nimport { buildSourcemap } from \"./sourcemap\";\n\nexport interface PyxisTranspileTsxInit {\n\tloader: PyxisLoader;\n\ttag: WeakKey;\n\ttranspile(this: TransformPluginContext, call: TranspileTsxCall): Promise<void>;\n}\n\nexport interface TranspileTsxCall {\n\treadonly code: string;\n\treadonly ast: AST.Program;\n\treadonly transpiler: Transpiler;\n\treadonly moduleId: string;\n\treadonly relativeId: string;\n}\n\nexport function pyxisTranspileTsx({ loader, tag, transpile }: PyxisTranspileTsxInit): Plugin {\n\treturn {\n\t\tname: `${__THIS_PLUGIN__}:transpile-tsx`,\n\t\tenforce: \"pre\",\n\t\ttransform: {\n\t\t\torder: \"pre\",\n\t\t\tasync handler(originalCode, moduleId) {\n\t\t\t\tconst module = loader.peek(moduleId);\n\t\t\t\tif (module?.tags.has(tag) !== true) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst trimmedId = trimQuery(moduleId);\n\t\t\t\tconst lang = detectLang(trimmedId);\n\t\t\t\tif (!lang) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst ast = this.parse(originalCode, {\n\t\t\t\t\tastType: \"js\",\n\t\t\t\t\tlang,\n\t\t\t\t});\n\n\t\t\t\tconst transpiler = new Transpiler();\n\t\t\t\tawait transpile.call(this, {\n\t\t\t\t\tcode: originalCode,\n\t\t\t\t\ttranspiler,\n\t\t\t\t\tmoduleId,\n\t\t\t\t\trelativeId: module.relativePath,\n\t\t\t\t\tast,\n\t\t\t\t});\n\n\t\t\t\tconst sourcePath = loader.isVite\n\t\t\t\t\t? normalizePath(Path.relative(module.virtualPath, module.originalPath))\n\t\t\t\t\t: module.relativePath;\n\n\t\t\t\tif (!transpiler.hasTransforms()) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcode: originalCode,\n\t\t\t\t\t\tmap: {\n\t\t\t\t\t\t\tversion: 3,\n\t\t\t\t\t\t\tsources: [ sourcePath ],\n\t\t\t\t\t\t\tsourcesContent: [ originalCode ],\n\t\t\t\t\t\t\tnames: [],\n\t\t\t\t\t\t\tmappings: buildSourcemap(originalCode, originalCode, []),\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst result = transpiler.transpile(originalCode);\n\t\t\t\treturn {\n\t\t\t\t\tcode: result.transpiledCode,\n\t\t\t\t\tmap: {\n\t\t\t\t\t\tversion: 3,\n\t\t\t\t\t\tsources: [ sourcePath ],\n\t\t\t\t\t\tsourcesContent: [ originalCode ],\n\t\t\t\t\t\tnames: [],\n\t\t\t\t\t\tmappings: result.sourcemap,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction detectLang(moduleId: string) {\n\tconst ext = Path.extname(moduleId);\n\tif (/^\\.[cm]?tsx?$/i.test(ext)) {\n\t\treturn ext.endsWith('x') ? \"tsx\" : \"ts\";\n\t}\n\telse if (/^\\.[cm]?jsx?$/i.test(ext)) {\n\t\treturn ext.endsWith('x') ? \"jsx\" : \"js\";\n\t}\n\n\treturn null;\n}\n","import type { ResolvedId } from \"rolldown\";\nimport type { Plugin } from \"vite\";\n\nimport type { ResolvedPyxisPluginOptions } from \"~/options\";\nimport type { PyxisLoader } from \"~/PyxisLoader\";\n\nexport interface PyxisDevInit {\n\tloader: PyxisLoader;\n\toptions: ResolvedPyxisPluginOptions;\n}\n\nexport function pyxisDev({ loader, options }: PyxisDevInit): Plugin {\n\tconst coreProd = `${options.pyxisModule}/core`;\n\tconst coreDev = `${options.pyxisModule}/core-dev`;\n\n\tlet resolvedCoreDev: ResolvedId | null = null;\n\tlet isVite = false;\n\n\treturn {\n\t\tname: `${__THIS_PLUGIN__}:dev`,\n\t\tenforce: \"pre\",\n\t\tapply: \"serve\",\n\t\tconfig() {\n\t\t\t// Vite: configure resolution alias\n\t\t\tisVite = true;\n\t\t\treturn {\n\t\t\t\tresolve: {\n\t\t\t\t\talias: {\n\t\t\t\t\t\t[coreProd]: coreDev,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tresolveId: {\n\t\t\torder: \"pre\",\n\t\t\tfilter: {\n\t\t\t\tid: /\\/core$/,\n\t\t\t},\n\t\t\tasync handler(source, importer, extraOptions) {\n\t\t\t\tif (isVite || source !== coreProd) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn resolvedCoreDev ??= await loader.resolve({\n\t\t\t\t\tsource,\n\t\t\t\t\timporter,\n\t\t\t\t\toptions: extraOptions,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n}\n","import type { AST, TransformBlock, TranspileTsxCall } from \"~/transpiler\";\n\ntype NodeInfo =\n\t| VariableNodeInfo\n\t| ClassNodeInfo\n\t| FunctionNodeInfo\n\t| DefaultExpressionNodeInfo;\n\ninterface VariableNodeInfo {\n\treadonly kind: \"variable\";\n\treadonly node: AST.VariableDeclaration;\n}\n\ninterface ClassNodeInfo {\n\treadonly kind: \"class\";\n\treadonly node: AST.Class;\n}\n\ninterface FunctionNodeInfo {\n\treadonly kind: \"function\";\n\tnode?: AST.Function;\n\toverloads?: AST.Function[];\n}\n\ninterface DefaultExpressionNodeInfo {\n\treadonly kind: \"default-expression\";\n\treadonly node: AST.Expression;\n}\n\ninterface ExportedNameInfo {\n\treadonly shouldExport: boolean;\n\treadonly localName: string;\n\treadonly exportName: string;\n}\n\nconst HMR_PREFIX = \"__HMR_\";\n\n/**\n * applies transforms to exports:\n * - all exports are removed\n * - originally exported consts are converted to mutable variables\n * - originally exported function and class declarations are stored to mutable variables\n * - HMR logic is appended\n * - finally a common export is added re-exporting all the original symbols\n */\nexport async function transpileExportedSymbols({ ast, transpiler }: TranspileTsxCall) {\n\tconst topScopeNodesByName: { [N in string]?: NodeInfo } = {};\n\tconst topScopeNodes = new Map<AST.Node, NodeInfo>();\n\tconst exportedNodes = new Set<AST.Node>();\n\tconst exportedNames = new Map<string, ExportedNameInfo>();\n\n\tconst visitTopScopeNode = (node: AST.VariableDeclaration | AST.Class | AST.Function, name: string) => {\n\t\tlet info: NodeInfo | undefined;\n\t\tswitch (node.type) {\n\t\t\tcase \"VariableDeclaration\":\n\t\t\t\ttopScopeNodesByName[name] = (info = { kind: \"variable\", node });\n\t\t\t\tbreak;\n\n\t\t\tcase \"ClassDeclaration\":\n\t\t\t\ttopScopeNodesByName[name] = (info = { kind: \"class\", node });\n\t\t\t\tbreak;\n\n\t\t\tcase \"FunctionDeclaration\":\n\t\t\t\tinfo = topScopeNodesByName[name];\n\t\t\t\tif (!info || info.kind !== \"function\") {\n\t\t\t\t\ttopScopeNodesByName[name] = (info = { kind: \"function\" });\n\t\t\t\t}\n\n\t\t\t\tinfo.node = node;\n\t\t\t\tbreak;\n\n\t\t\tcase \"TSDeclareFunction\":\n\t\t\t\tinfo = topScopeNodesByName[name];\n\t\t\t\tif (!info || info.kind !== \"function\") {\n\t\t\t\t\ttopScopeNodesByName[name] = (info = { kind: \"function\" });\n\t\t\t\t}\n\n\t\t\t\t(info.overloads ??= []).push(node);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\ttopScopeNodes.set(node, info);\n\t};\n\n\tfor (const node of ast.body) {\n\t\tswitch (node.type) {\n\t\t\tcase \"VariableDeclaration\":\n\t\t\tcase \"FunctionDeclaration\":\n\t\t\tcase \"ClassDeclaration\":\n\t\t\t\tfindDeclaredSymbols(node, it => {\n\t\t\t\t\tvisitTopScopeNode(node, it.name);\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\n\t\t\tcase \"ExportNamedDeclaration\": {\n\t\t\t\t// may be a direct named export, e.g.:\n\t\t\t\t// export const a = 123;\n\t\t\t\tconst declaration = node.declaration;\n\t\t\t\tif (declaration && (declaration.type === \"TSDeclareFunction\" || !isTypeScriptNode(declaration))) {\n\t\t\t\t\texportedNodes.add(declaration);\n\t\t\t\t\tfindDeclaredSymbols(declaration, it => {\n\t\t\t\t\t\tvisitTopScopeNode(declaration, it.name);\n\t\t\t\t\t\texportedNames.set(it.name, {\n\t\t\t\t\t\t\tshouldExport: true,\n\t\t\t\t\t\t\tlocalName: it.name,\n\t\t\t\t\t\t\texportName: it.name,\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\ttranspiler.addTransform(node, removeExport);\n\t\t\t\t}\n\n\t\t\t\tif (node.exportKind === \"type\") {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// or a named reference export:\n\t\t\t\t// export { a, b, c };\n\t\t\t\tfor (const ref of node.specifiers) {\n\t\t\t\t\tif (ref.local.type !== \"Identifier\" || ref.exported.type !== \"Identifier\") {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst localName = ref.local.name;\n\t\t\t\t\tconst exportedNode = topScopeNodesByName[localName]?.node;\n\t\t\t\t\tif (exportedNode) {\n\t\t\t\t\t\tconst exportName = ref.exported.name;\n\t\t\t\t\t\texportedNodes.add(exportedNode);\n\t\t\t\t\t\texportedNames.set(exportName, {\n\t\t\t\t\t\t\tshouldExport: false,\n\t\t\t\t\t\t\tlocalName,\n\t\t\t\t\t\t\texportName,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"ExportDefaultDeclaration\": {\n\n\t\t\t\t// default export can be any expression -> detect references, otherwise use directly\n\t\t\t\tif (node.declaration.type === \"Identifier\") {\n\t\t\t\t\tconst localName = node.declaration.name;\n\t\t\t\t\tconst exportedNode = topScopeNodesByName[localName]?.node;\n\t\t\t\t\tif (exportedNode) {\n\t\t\t\t\t\texportedNodes.add(exportedNode);\n\t\t\t\t\t\ttranspiler.addTransform(node, removeNode);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (!isTypeScriptNode(node.declaration)) {\n\t\t\t\t\ttopScopeNodes.set(node.declaration, {\n\t\t\t\t\t\tkind: \"default-expression\",\n\t\t\t\t\t\tnode: node.declaration,\n\t\t\t\t\t});\n\n\t\t\t\t\texportedNodes.add(node.declaration);\n\t\t\t\t\texportedNames.set(\"default\", {\n\t\t\t\t\t\tshouldExport: true,\n\t\t\t\t\t\tlocalName: `${HMR_PREFIX}default`,\n\t\t\t\t\t\texportName: \"default\",\n\t\t\t\t\t});\n\n\t\t\t\t\ttranspiler.addTransform(node, removeExport);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// exit early if no exports were transformed\n\tif (exportedNodes.size === 0) {\n\t\treturn;\n\t}\n\n\tconst handled = new WeakSet<NodeInfo>();\n\tfor (const node of exportedNodes) {\n\t\tconst info = topScopeNodes.get(node);\n\t\tif (!info || handled.has(info)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\thandled.add(info);\n\t\tswitch (info.kind) {\n\t\t\tcase \"variable\":\n\t\t\t\tif (info.node.kind === \"const\") {\n\t\t\t\t\ttranspiler.addTransform(node, convertToMutableVariable);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase \"class\":\n\t\t\t\tif (info.node.id) {\n\t\t\t\t\ttranspiler.addTransform(node, assignToMutableVariable(info.node.id.name));\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase \"function\":\n\t\t\t\tif (!info.node || !info.node.id) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (info.overloads) {\n\t\t\t\t\tconst oldName = info.node.id.name;\n\t\t\t\t\tconst newName = `${HMR_PREFIX}${oldName}`;\n\t\t\t\t\t[ ...info.overloads, info.node ].forEach(it => {\n\t\t\t\t\t\ttranspiler.addTransform(it, renameOverloadedFunction(newName));\n\t\t\t\t\t});\n\n\t\t\t\t\ttranspiler.addTransform(info.node, appendCode(`\\n\\nlet ${oldName} = ${newName};`));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttranspiler.addTransform(node, assignToMutableVariable(info.node.id.name));\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase \"default-expression\":\n\t\t\t\ttranspiler.addTransform(node, assignToMutableVariable(`${HMR_PREFIX}default`));\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// generate HMR replacer code\n\tlet setters = \"\\n\";\n\tlet exports = \"\";\n\n\tfor (const it of exportedNames.values()) {\n\t\tsetters += `\\t\\t${JSON.stringify(it.exportName)}: value => { ${it.localName} = value; },\\n`;\n\t\tif (it.shouldExport) {\n\t\t\tif (it.localName !== it.exportName) {\n\t\t\t\texports += `${it.localName} as ${it.exportName}, `;\n\t\t\t}\n\t\t\telse {\n\t\t\t\texports += `${it.localName}, `;\n\t\t\t}\n\t\t}\n\t}\n\n\tlet hmrCode = `\n\nif (import.meta.hot) {\n\tconst setter = {${setters}\\t};\n\timport.meta.hot.accept(hmrExports => {\n\t\thmrExports && Object.keys(hmrExports).forEach(key => {\n\t\t\tsetter[key]?.(hmrExports[key]);\n\t\t});\n\t});\n}\n`;\n\n\tif (exports) {\n\t\thmrCode += `\\nexport { ${exports.slice(0, -2)} };\\n`;\n\t}\n\n\ttranspiler.addTransform(ast, appendCode(hmrCode));\n}\n\nfunction findDeclaredSymbols(\n\tdeclaration: AST.Declaration,\n\tblock: (node: AST.Node & { type: \"Identifier\" }) => void,\n) {\n\tswitch (declaration.type) {\n\t\tcase \"VariableDeclaration\":\n\t\t\tfindDeclaredVariables(declaration, block);\n\t\t\tbreak;\n\n\t\tcase \"FunctionDeclaration\":\n\t\tcase \"TSDeclareFunction\":\n\t\tcase \"ClassDeclaration\": {\n\t\t\tif (!declaration.id) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tblock(declaration.id);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction findDeclaredVariables(\n\tdeclaration: AST.VariableDeclaration,\n\tblock: (node: AST.Node & { type: \"Identifier\" }) => void,\n) {\n\tfor (const decl of declaration.declarations) {\n\t\tif (decl.init) {\n\t\t\tif (isBindingPattern(decl.id)) {\n\t\t\t\t// variable declarations via a binding pattern, e.g.:\n\t\t\t\t// const { a, b } = obj;\n\t\t\t\t// const [ x, y ] = arr;\n\t\t\t\t//\n\t\t\t\t// here id points to `obj` or `arr` -> we don't care about it\n\n\t\t\t\tfindDestructuredVariables(decl.id, block);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// variable initialized to an expression, e.g.:\n\t\t\t\t// const x = 123;\n\n\t\t\t\tif (decl.id.type !== \"Identifier\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblock(decl.id);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t// variable declaration without an init, e.g.:\n\t\t\t// let x;\n\n\t\t\tif (decl.id.type !== \"Identifier\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tblock(decl.id);\n\t\t}\n\t}\n}\n\nfunction findDestructuredVariables(\n\tnode: AST.BindingPattern | AST.BindingRestElement | null | undefined,\n\tblock: (node: AST.Node & { type: \"Identifier\" }) => void,\n) {\n\tswitch (node?.type) {\n\t\tcase \"Identifier\":\n\t\t\t// we don't make any effort to understand where values come from when using object or\n\t\t\t// array destructuring patterns - it's enough to know the exported names\n\t\t\tblock(node);\n\t\t\tbreak;\n\n\t\tcase \"AssignmentPattern\":\n\t\t\tfindDestructuredVariables(node.left, block);\n\t\t\tbreak;\n\n\t\tcase \"ObjectPattern\":\n\t\t\tfor (const prop of node.properties) {\n\t\t\t\tfindDestructuredVariables(prop.value, block);\n\t\t\t}\n\n\t\t\tbreak;\n\n\t\tcase \"ArrayPattern\":\n\t\t\tfor (const elem of node.elements) {\n\t\t\t\tconst arg = elem?.type === \"RestElement\" ? elem.argument : elem;\n\t\t\t\tfindDestructuredVariables(arg, block);\n\t\t\t}\n\n\t\t\tbreak;\n\t}\n}\n\nfunction isBindingPattern(node: AST.Node): node is AST.ObjectPattern | AST.ArrayPattern {\n\tconst { type } = node;\n\treturn (\n\t\ttype === \"ObjectPattern\" ||\n\t\ttype === \"ArrayPattern\"\n\t);\n}\n\nfunction isTypeScriptNode(node: AST.Node): node is AST.Node & { type: `TS${string}` } {\n\treturn node.type.startsWith(\"TS\");\n}\n\nconst convertToMutableVariable: TransformBlock = (originalCode, start) => {\n\tconst match = /^\\s*const\\s+/.exec(originalCode);\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\tconst removed = match[0].length;\n\treturn {\n\t\tnewCode: \"let \" + originalCode.slice(removed),\n\t\tedits: [\n\t\t\t{\n\t\t\t\tat: start,\n\t\t\t\tdelta: -removed,\n\t\t\t},\n\t\t\t{\n\t\t\t\tat: start + removed,\n\t\t\t\tdelta: 4,\n\t\t\t},\n\t\t],\n\t};\n};\n\nconst assignToMutableVariable = (name: string): TransformBlock => (originalCode, start, end) => {\n\treturn {\n\t\tnewCode: `let ${name} = (${originalCode});`,\n\t\tedits: [\n\t\t\t{\n\t\t\t\tat: start,\n\t\t\t\tdelta: name.length + 8,\n\t\t\t},\n\t\t\t{\n\t\t\t\tat: end,\n\t\t\t\tdelta: 2,\n\t\t\t},\n\t\t],\n\t};\n};\n\nconst renameOverloadedFunction = (newName: string): TransformBlock => (originalCode, start) => {\n\tconst match = /^(\\s*function\\s+)([a-zA-Z_$][a-zA-Z0-9_$]*)(?=[(<\\s])/.exec(originalCode);\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\tconst offset = match[1].length;\n\tconst removed = match[2].length;\n\treturn {\n\t\tnewCode: match[1] + newName + originalCode.slice(offset + removed),\n\t\tedits: [\n\t\t\t{\n\t\t\t\tat: start + offset,\n\t\t\t\tdelta: -removed,\n\t\t\t},\n\t\t\t{\n\t\t\t\tat: start + offset + removed,\n\t\t\t\tdelta: newName.length,\n\t\t\t},\n\t\t],\n\t};\n};\n\nconst removeExport: TransformBlock = (originalCode, start) => {\n\tconst match = /^\\s*export(\\s+default)?\\s+/.exec(originalCode);\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\tconst removed = match[0].length;\n\treturn {\n\t\tnewCode: originalCode.slice(removed),\n\t\tedits: [\n\t\t\t{\n\t\t\t\tat: start,\n\t\t\t\tdelta: -removed,\n\t\t\t},\n\t\t],\n\t};\n};\n\nconst removeNode: TransformBlock = (originalCode, start) => ({\n\tnewCode: \"\",\n\tedits: [\n\t\t{\n\t\t\tat: start,\n\t\t\tdelta: -originalCode.length,\n\t\t},\n\t],\n});\n\nconst appendCode = (code: string): TransformBlock => (originalCode, _start, end) => {\n\treturn {\n\t\tnewCode: originalCode + code,\n\t\tedits: [\n\t\t\t{\n\t\t\t\tat: end,\n\t\t\t\tdelta: code.length,\n\t\t\t},\n\t\t],\n\t};\n};\n","import type { PyxisLoader } from \"~/PyxisLoader\";\nimport { walkDown, walkUp, type AST, type TransformBlock, type TranspileTsxCall } from \"~/transpiler\";\n\ninterface SymbolInfo {\n\treadonly kind: FactoryKind | \"namespace\";\n\treadonly name: string;\n}\n\ntype FactoryKind =\n\t| \"atom\"\n\t| \"component\"\n\t| \"context\"\n\t| \"list\"\n\t| \"host\";\n\nconst factoryKindMap: { [N in string]?: FactoryKind } = {\n\tatomOf: \"atom\",\n\tcomponent: \"component\",\n\tcreateContext: \"context\",\n\tlistOf: \"list\",\n\thost: \"host\",\n};\n\nconst factoryArgCount: { [K in FactoryKind]: number } = {\n\tatom: 2,\n\tcomponent: 1,\n\tcontext: 0,\n\tlist: 2,\n\thost: 2,\n};\n\nexport interface TranspileFactoryCallsCall extends TranspileTsxCall {\n\tloader: PyxisLoader;\n}\n\nexport async function transpileFactoryCalls({\n\tast,\n\tmoduleId,\n\trelativeId,\n\ttranspiler,\n\tloader,\n}: TranspileFactoryCallsCall) {\n\t// find pyxis imports within the program\n\tconst imported: { [N in string]?: SymbolInfo } = {};\n\tlet hasPyxisImports = false;\n\n\tfor (const node of ast.body) {\n\t\tif (node.type !== \"ImportDeclaration\" || node.importKind === \"type\") {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isPyxisModule = await loader.isPyxisModule({\n\t\t\tsource: node.source.value,\n\t\t\timporter: moduleId,\n\t\t});\n\n\t\tif (!isPyxisModule) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const spec of node.specifiers) {\n\t\t\tlet kind;\n\t\t\tswitch (spec.type) {\n\t\t\t\tcase \"ImportSpecifier\":\n\t\t\t\t\tif (spec.importKind !== \"type\" &&\n\t\t\t\t\t\tspec.imported.type === \"Identifier\" &&\n\t\t\t\t\t\t(kind = factoryKindMap[spec.imported.name])\n\t\t\t\t\t) {\n\t\t\t\t\t\thasPyxisImports = true;\n\t\t\t\t\t\timported[spec.local.name] = {\n\t\t\t\t\t\t\tname: spec.imported.name,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ImportNamespaceSpecifier\":\n\t\t\t\t\thasPyxisImports = true;\n\t\t\t\t\timported[spec.local.name] = {\n\t\t\t\t\t\tname: spec.local.name,\n\t\t\t\t\t\tkind: \"namespace\",\n\t\t\t\t\t};\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t// pyxis doesn't have default exports\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!hasPyxisImports) {\n\t\treturn;\n\t}\n\n\t// identify and transpile factory calls within the program, passing unique devId's\n\t// uniqueness is not guaranteed from names alone, so we append counters when necessary (an order-sensitive fallback)\n\tconst assignedIds: { [K in string]?: number } = {};\n\n\t// track component nodes - devId must only be assigned to factories within a component scope, not e.g. within event handlers.\n\tconst componentNodes = new WeakSet<AST.Node>();\n\n\tconst transpileCall = (factory: AST.CallExpression, kind: FactoryKind) => {\n\t\tif (kind === \"component\") {\n\t\t\tcomponentNodes.add(factory);\n\t\t}\n\t\telse if (!isComponentScope(componentNodes, factory)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst name = findNameFor(factory);\n\t\tconst extraArgCount = factoryArgCount[kind] - factory.arguments.length;\n\t\tif (name && extraArgCount >= 0) {\n\t\t\tconst baseId = `${name}@${relativeId}`;\n\t\t\tconst counter = (assignedIds[baseId] ?? 0) + 1;\n\t\t\tassignedIds[baseId] = counter;\n\n\t\t\tconst devId = counter > 1 ? `${baseId} ${counter}` : baseId;\n\t\t\ttranspiler.addTransform(factory, appendDevIdArgument(devId, extraArgCount));\n\t\t}\n\t};\n\n\twalkDown(ast, {\n\t\tenter: node => {\n\t\t\tif (node.type !== \"CallExpression\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet tmp;\n\t\t\tlet kind;\n\t\t\tswitch (node.callee.type) {\n\t\t\t\tcase \"Identifier\":\n\t\t\t\t\tif ((tmp = imported[node.callee.name]) && tmp.kind !== \"namespace\") {\n\t\t\t\t\t\ttranspileCall(node, tmp.kind);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"MemberExpression\":\n\t\t\t\t\tif (node.callee.property.type === \"Identifier\" &&\n\t\t\t\t\t\t(kind = factoryKindMap[node.callee.property.name]) &&\n\t\t\t\t\t\tnode.callee.object.type === \"Identifier\" &&\n\t\t\t\t\t\t(tmp = imported[node.callee.object.name]) &&\n\t\t\t\t\t\ttmp.kind === \"namespace\"\n\t\t\t\t\t) {\n\t\t\t\t\t\ttranspileCall(node, kind);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t},\n\t});\n}\n\nfunction isComponentScope(componentNodes: WeakSet<AST.Node>, node: AST.Node) {\n\tconst nearestFn = walkUp(node, it => (\n\t\tit.type === \"FunctionDeclaration\" || it.type === \"ArrowFunctionExpression\"\n\t\t\t? it\n\t\t\t: null\n\t));\n\n\treturn (\n\t\tnearestFn &&\n\t\tnearestFn.parent?.type === \"CallExpression\" &&\n\t\tcomponentNodes.has(nearestFn.parent)\n\t);\n}\n\nfunction findNameFor(node: AST.Node) {\n\treturn walkUp(node.parent, parent => {\n\t\tswitch (parent.type) {\n\t\t\tcase \"VariableDeclarator\":\n\t\t\t\treturn parent.id.type === \"Identifier\"\n\t\t\t\t\t? parent.id.name\n\t\t\t\t\t: undefined;\n\n\t\t\tcase \"Property\":\n\t\t\t\tswitch (parent.key.type) {\n\t\t\t\t\tcase \"Identifier\":\n\t\t\t\t\t\treturn parent.key.name;\n\n\t\t\t\t\tcase \"PrivateIdentifier\":\n\t\t\t\t\t\treturn parent.key.name;\n\n\t\t\t\t\tcase \"Literal\":\n\t\t\t\t\t\treturn typeof parent.key.value === \"string\"\n\t\t\t\t\t\t\t? parent.key.value\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\tcase \"ExportDefaultDeclaration\":\n\t\t\t\treturn \"default\";\n\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t});\n}\n\nfunction appendDevIdArgument(devId: string, extraArgCount: number): TransformBlock {\n\treturn (originalCode, _start, end) => {\n\t\tconst match = /\\s*\\)$/.exec(originalCode);\n\t\tif (!match) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst slicedStart = originalCode.slice(0, match.index);\n\t\tlet addedCode = \"\";\n\t\tif (!/[(,]$/.test(slicedStart)) {\n\t\t\taddedCode += \", \";\n\t\t}\n\n\t\taddedCode += \"undefined, \".repeat(extraArgCount);\n\t\taddedCode += JSON.stringify(devId);\n\n\t\treturn {\n\t\t\tnewCode: `${slicedStart}${addedCode})`,\n\t\t\tedits: [\n\t\t\t\t{\n\t\t\t\t\tat: end - 1,\n\t\t\t\t\tdelta: addedCode.length,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t};\n}\n","import * as Path from \"node:path\";\n\nimport type { Plugin } from \"vite\";\n\nimport type { ResolvedPyxisPluginOptions } from \"~/options\";\nimport { PyxisLoader } from \"~/PyxisLoader\";\nimport { replaceSourceIndex } from \"~/transpiler\";\nimport { normalizePath } from \"~/utils\";\n\nimport type { CssExportsMap, CssExportsRegistry } from \"./CssExportsRegistry\";\n\nexport interface PyxisTranspileTsxInit {\n\tloader: PyxisLoader;\n\tregistry: CssExportsRegistry;\n\toptions: ResolvedPyxisPluginOptions;\n\ttag: WeakKey;\n}\n\ninterface CssChunk {\n\treadonly originalPath: string;\n\treadonly mappings: string;\n\treadonly originalCode: string;\n\treadonly transformedCode: string;\n}\n\nexport function pyxisTranspileCss({ loader, registry, options, tag }: PyxisTranspileTsxInit): Plugin {\n\tconst bundleCssChunks = new Map<string, CssChunk>();\n\n\tlet LightningCss!: typeof import(\"lightningcss\");\n\n\treturn {\n\t\tname: `${__THIS_PLUGIN__}:transpile-css`,\n\t\tenforce: \"pre\",\n\t\tasync buildStart() {\n\t\t\ttry {\n\t\t\t\tLightningCss ??= await import(\"lightningcss\");\n\t\t\t}\n\t\t\tcatch (ex) {\n\t\t\t\tthis.error({\n\t\t\t\t\tcause: ex,\n\t\t\t\t\tcode: \"E_DEPENDENCY\",\n\t\t\t\t\tmessage: \"When using the cssModules feature, the LightningCss package must be installed.\",\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\ttransform: {\n\t\t\torder: \"pre\",\n\t\t\tasync handler(originalCode, moduleId) {\n\t\t\t\tconst module = loader.peek(moduleId);\n\t\t\t\tif (module?.tags.has(tag) !== true) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t// transform CSS module with Lightning CSS\n\t\t\t\tconst { originalPath, virtualPath } = module;\n\t\t\t\tconst isModule = options.cssModules!.modules.some(pattern => pattern.test(originalPath));\n\t\t\t\tconst result = LightningCss.transform({\n\t\t\t\t\t...options.cssModules!.lightningcss,\n\t\t\t\t\tcode: Buffer.from(originalCode, \"utf8\"),\n\t\t\t\t\tfilename: originalPath,\n\t\t\t\t\tprojectRoot: loader.rootDir,\n\t\t\t\t\tsourceMap: true,\n\t\t\t\t\tcssModules: isModule && (\n\t\t\t\t\t\ttypeof options.cssModules!.lightningcss?.cssModules === \"object\"\n\t\t\t\t\t\t\t? { ...options.cssModules!.lightningcss?.cssModules }\n\t\t\t\t\t\t\t: true\n\t\t\t\t\t),\n\t\t\t\t});\n\n\t\t\t\t// forward warnings\n\t\t\t\tfor (const warning of result.warnings) {\n\t\t\t\t\tthis.warn({\n\t\t\t\t\t\tcode: warning.type,\n\t\t\t\t\t\tmessage: warning.message,\n\t\t\t\t\t\tloc: {\n\t\t\t\t\t\t\tcolumn: warning.loc.column,\n\t\t\t\t\t\t\tline: warning.loc.line,\n\t\t\t\t\t\t\tfile: warning.loc.filename,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// build and register CSS class name map\n\t\t\t\tconst classNameMap: CssExportsMap = {};\n\t\t\t\tif (isModule) {\n\t\t\t\t\tObject\n\t\t\t\t\t\t.keys(result.exports!)\n\t\t\t\t\t\t.reduce((map, key) => (map[key] = result.exports![key].name, map), classNameMap);\n\t\t\t\t}\n\n\t\t\t\tregistry.upsertExports(virtualPath, classNameMap);\n\n\t\t\t\t// get source mappings\n\t\t\t\tlet mappings;\n\t\t\t\ttry {\n\t\t\t\t\tconst sourcemap = JSON.parse((result.map as Buffer).toString(\"utf8\"));\n\t\t\t\t\tif (sourcemap?.version !== 3) {\n\t\t\t\t\t\tthrow new Error(\"expected sourcemap version 3\");\n\t\t\t\t\t}\n\n\t\t\t\t\tmappings = sourcemap.mappings ?? \"\";\n\t\t\t\t}\n\t\t\t\tcatch (ex) {\n\t\t\t\t\tthis.warn({\n\t\t\t\t\t\tcode: \"E_SOURCEMAP\",\n\t\t\t\t\t\tmessage: `failed to parse sourcemap, ${(ex as Error).message}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Vite handles the bundling, return CSS directly, no caching\n\t\t\t\tconst transformedCode = (result.code as Buffer).toString(\"utf8\");\n\t\t\t\tif (loader.isVite) {\n\t\t\t\t\tconst sourcePath = normalizePath(Path.relative(module.virtualPath, module.originalPath));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmoduleType: \"js\",\n\t\t\t\t\t\tmoduleSideEffects: \"no-treeshake\",\n\t\t\t\t\t\tcode: getViteHMRLoaderSource(classNameMap, moduleId, transformedCode),\n\t\t\t\t\t\tmap: {\n\t\t\t\t\t\t\tversion: 3,\n\t\t\t\t\t\t\tsources: [ sourcePath ],\n\t\t\t\t\t\t\tsourcesContent: [ originalCode ],\n\t\t\t\t\t\t\tnames: [],\n\t\t\t\t\t\t\tmappings,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// for raw Rollup/Rolldown builds, cache CSS and instead return a JS chunk with mappings\n\t\t\t\tbundleCssChunks.set(moduleId, {\n\t\t\t\t\toriginalPath,\n\t\t\t\t\tmappings,\n\t\t\t\t\toriginalCode,\n\t\t\t\t\ttransformedCode,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tmoduleType: \"js\",\n\t\t\t\t\tmoduleSideEffects: \"no-treeshake\",\n\t\t\t\t\tcode: getMappingsSource(classNameMap),\n\t\t\t\t\tmap: {\n\t\t\t\t\t\tversion: 3,\n\t\t\t\t\t\tsources: [ module.relativePath ],\n\t\t\t\t\t\tsourcesContent: [ originalCode ],\n\t\t\t\t\t\tnames: [],\n\t\t\t\t\t\tmappings: \"\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\tgenerateBundle(outputOptions, bundle) {\n\t\t\t// do nothing when used with Vite\n\t\t\tif (loader.isVite) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst sourcemapEnabled = outputOptions.sourcemap ?? false;\n\t\t\tconst baseDir = Path.resolve(loader.rootDir, outputOptions.dir ?? \"./dist\");\n\t\t\tconst baseUrl = outputOptions.sourcemapBaseUrl ? new URL(outputOptions.sourcemapBaseUrl) : null;\n\t\t\tconst bundles = Object\n\t\t\t\t.values(bundle)\n\t\t\t\t.filter(it => it.type === \"chunk\");\n\n\t\t\tfor (const it of bundles) {\n\t\t\t\tconst fileName = `${Path.parse(it.fileName).name}.css`;\n\t\t\t\tconst chunks = it.moduleIds\n\t\t\t\t\t.map(moduleId => bundleCssChunks.get(moduleId)!)\n\t\t\t\t\t.filter(Boolean);\n\n\t\t\t\tif (chunks.length === 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// merge CSS code\n\t\t\t\tlet code = chunks.map(chunk => chunk.transformedCode).join(\"\\n\");\n\n\t\t\t\t// generate bundled sourcemap if enabled\n\t\t\t\tif (sourcemapEnabled) {\n\t\t\t\t\tconst sourcemap = {\n\t\t\t\t\t\tversion: 3,\n\t\t\t\t\t\tsources: chunks.map(chunk => normalizePath(Path.relative(baseDir, chunk.originalPath))),\n\t\t\t\t\t\tsourcesContent: chunks.map(chunk => chunk.originalCode),\n\t\t\t\t\t\tnames: [],\n\t\t\t\t\t\tmappings: chunks\n\t\t\t\t\t\t\t.map((chunk, sourceIndex) => replaceSourceIndex(chunk.mappings, sourceIndex))\n\t\t\t\t\t\t\t.join(\";\"),\n\t\t\t\t\t};\n\n\t\t\t\t\t// emit sourcemap chunk\n\t\t\t\t\tconst sourcemapFileName = `${fileName}.map`;\n\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\ttype: \"prebuilt-chunk\",\n\t\t\t\t\t\tfileName: sourcemapFileName,\n\t\t\t\t\t\tcode: JSON.stringify(sourcemap),\n\t\t\t\t\t});\n\n\t\t\t\t\tcode += `\\n/*# sourceMappingURL=${baseUrl ? new URL(sourcemapFileName, baseUrl) : sourcemapFileName} */`;\n\t\t\t\t}\n\n\t\t\t\t// emit CSS chunk\n\t\t\t\tthis.emitFile({\n\t\t\t\t\ttype: \"prebuilt-chunk\",\n\t\t\t\t\tfileName,\n\t\t\t\t\tcode,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction getMappingsSource(classNameMap: CssExportsMap) {\n\treturn `\nexport default ${JSON.stringify(classNameMap, null, \"\\t\")};\n`;\n}\n\nfunction getViteHMRLoaderSource(\n\tclassNameMap: CssExportsMap,\n\tmoduleId: string,\n\tcssCode: string,\n) {\n\t// Vite populates `import.meta.hot` automatically\n\t// we just need to add the raw CSS loader\n\treturn `\nimport { removeStyle, updateStyle } from \"/@vite/client\";\n\nconst moduleId = ${JSON.stringify(moduleId)};\nconst cssCode = ${JSON.stringify(cssCode)};\n\nupdateStyle(moduleId, cssCode);\nimport.meta.hot.accept();\nimport.meta.hot.prune(() => removeStyle(moduleId));\n${getMappingsSource(classNameMap)}\n`;\n}\n","import type { PyxisLoader } from \"~/PyxisLoader\";\n\nexport type CssExportsMap = { [CN in string]?: string };\n\nexport class CssExportsRegistry {\n\tprivate readonly mappings = new Map<string, CssExportsMap>();\n\n\tpublic constructor(\n\t\tprivate readonly loader: PyxisLoader,\n\t) {}\n\n\tpublic upsertExports(moduleId: string, exportsMap: CssExportsMap) {\n\t\tthis.mappings.set(moduleId, exportsMap);\n\t}\n\n\tpublic async getExports(moduleId: string, importer?: string) {\n\t\tlet id: string | null = moduleId;\n\t\tlet map;\n\n\t\tif (map = this.mappings.get(id)) {\n\t\t\treturn map;\n\t\t}\n\n\t\tid = await this.loader.resolveId({\n\t\t\tsource: moduleId,\n\t\t\timporter,\n\t\t});\n\n\t\tif (!id) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (map = this.mappings.get(id)) {\n\t\t\treturn map;\n\t\t}\n\n\t\tawait this.loader.load({\n\t\t\tid: id,\n\t\t\tresolveDependencies: false,\n\t\t});\n\n\t\treturn this.mappings.get(id) ?? null;\n\t}\n}\n","import type { ResolvedPyxisPluginOptions } from \"~/options\";\nimport type { PyxisLoader } from \"~/PyxisLoader\";\nimport { walkDown, type AST, type TransformBlock, type TranspileTsxCall } from \"~/transpiler\";\nimport { trimQuery } from \"~/utils\";\n\nimport type { CssExportsMap, CssExportsRegistry } from \"./CssExportsRegistry\";\n\ninterface SymbolInfo {\n\treadonly name: string;\n\treadonly kind: \"jsx\" | \"namespace\";\n}\n\nconst isJsxFactory: { [K in string]?: true } = {\n\tjsx: true,\n\tjsxs: true,\n\tjsxDEV: true,\n};\n\nexport interface TranspileClassNamesCall extends TranspileTsxCall {\n\tloader: PyxisLoader;\n\tregistry: CssExportsRegistry;\n\toptions: ResolvedPyxisPluginOptions;\n}\n\nexport async function transpileClassNames({\n\tast,\n\ttranspiler,\n\tmoduleId,\n\tloader,\n\tregistry,\n\toptions,\n}: TranspileClassNamesCall) {\n\t// find CSS and pyxis imports of JSX factories within the program\n\tconst imported: { [N in string]?: SymbolInfo } = {};\n\tconst cssExportsMap: CssExportsMap = {};\n\n\tlet hasCssImports = false;\n\tlet node;\n\tlet spec;\n\n\tfor (node of ast.body) {\n\t\tif (node.type !== \"ImportDeclaration\" || node.importKind === \"type\") {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst importSource = trimQuery(node.source.value);\n\t\tif (isPotentialCssModule(options, importSource)) {\n\t\t\tconst map = await registry.getExports(importSource, moduleId);\n\t\t\tif (map) {\n\t\t\t\tObject.assign(cssExportsMap, map);\n\t\t\t\thasCssImports = true;\n\t\t\t}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isPyxisModule = await loader.isPyxisModule({\n\t\t\tsource: importSource,\n\t\t\timporter: moduleId,\n\t\t});\n\n\t\tif (!isPyxisModule) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (spec of node.specifiers) {\n\t\t\tswitch (spec.type) {\n\t\t\t\tcase \"ImportSpecifier\":\n\t\t\t\t\tif (spec.importKind !== \"type\" &&\n\t\t\t\t\t\tspec.imported.type === \"Identifier\" &&\n\t\t\t\t\t\tisJsxFactory[spec.imported.name]\n\t\t\t\t\t) {\n\t\t\t\t\t\timported[spec.local.name] = {\n\t\t\t\t\t\t\tname: spec.imported.name,\n\t\t\t\t\t\t\tkind: \"jsx\",\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ImportNamespaceSpecifier\":\n\t\t\t\t\timported[spec.local.name] = {\n\t\t\t\t\t\tname: spec.local.name,\n\t\t\t\t\t\tkind: \"namespace\",\n\t\t\t\t\t};\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t// pyxis doesn't have default exports\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!hasCssImports) {\n\t\treturn;\n\t}\n\n\t// identify and transpile relevant CSS class names within the program\n\tconst extPrefix = options.cssModules!.cssExtensionPrefix;\n\tconst transpileJsxAttribute = (attribute: AST.JSXAttribute) => {\n\t\tlet newClassName;\n\t\tif (attribute.name.type === \"JSXNamespacedName\" &&\n\t\t\tattribute.name.namespace.name === extPrefix &&\n\t\t\t(newClassName = cssExportsMap[attribute.name.name.name])\n\t\t) {\n\t\t\ttranspiler.addTransform(attribute.name.name, rewriteAttributeName(newClassName));\n\t\t}\n\t};\n\n\tconst transpileJsxFactoryCall = (factory: AST.CallExpression) => {\n\t\tif (factory.arguments.length < 2) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst propsArg = factory.arguments[1];\n\t\tif (propsArg.type !== \"ObjectExpression\") {\n\t\t\treturn;\n\t\t}\n\n\t\tlet key;\n\t\tlet newClassName;\n\t\tfor (const prop of propsArg.properties) {\n\t\t\tif (prop.type === \"Property\" &&\n\t\t\t\tprop.key.type === \"Literal\" &&\n\t\t\t\ttypeof (key = prop.key.value) === \"string\" &&\n\t\t\t\tkey.startsWith(`${extPrefix}:`) &&\n\t\t\t\t(newClassName = cssExportsMap[key.slice(extPrefix.length + 1)])\n\t\t\t) {\n\t\t\t\ttranspiler.addTransform(prop.key, rewritePropKeyLiteral(`${extPrefix}:${newClassName}`));\n\t\t\t}\n\t\t}\n\t};\n\n\twalkDown(ast, {\n\t\tenter: node => {\n\t\t\tif (node.type === \"JSXAttribute\") {\n\t\t\t\ttranspileJsxAttribute(node);\n\t\t\t}\n\t\t\telse if (node.type === \"CallExpression\") {\n\t\t\t\tlet tmp;\n\t\t\t\tswitch (node.callee.type) {\n\t\t\t\t\tcase \"Identifier\":\n\t\t\t\t\t\tif ((tmp = imported[node.callee.name]) && tmp.kind === \"jsx\") {\n\t\t\t\t\t\t\ttranspileJsxFactoryCall(node);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"MemberExpression\":\n\t\t\t\t\t\tif (node.callee.property.type === \"Identifier\" &&\n\t\t\t\t\t\t\tisJsxFactory[node.callee.property.name] &&\n\t\t\t\t\t\t\tnode.callee.object.type === \"Identifier\" &&\n\t\t\t\t\t\t\t(tmp = imported[node.callee.object.name]) &&\n\t\t\t\t\t\t\ttmp.kind === \"namespace\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ttranspileJsxFactoryCall(node);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n}\n\nfunction isPotentialCssModule(options: ResolvedPyxisPluginOptions, source: string) {\n\t// under Vite CSS modules are suffixed as `.css.js` which breaks pattern matching -> trim it\n\tconst trimmedSource = /\\.js$/.test(source) ? source.slice(0, -3) : source;\n\treturn options.cssModules!.modules.some(pattern => pattern.test(trimmedSource));\n}\n\nfunction rewriteAttributeName(newName: string): TransformBlock {\n\treturn (originalCode, start) => {\n\t\tconst removed = originalCode.length;\n\t\treturn {\n\t\t\tnewCode: newName,\n\t\t\tedits: [\n\t\t\t\t{\n\t\t\t\t\tat: start,\n\t\t\t\t\tdelta: -removed,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tat: start + removed,\n\t\t\t\t\tdelta: newName.length,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t};\n}\n\nfunction rewritePropKeyLiteral(newName: string): TransformBlock {\n\treturn (originalCode, start) => {\n\t\t// verify it's a quoted string literal\n\t\tif (originalCode[0] !== originalCode[originalCode.length - 1] || !/[\"'`]/.test(originalCode[0])) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst newCode = JSON.stringify(newName);\n\t\tconst removed = originalCode.length;\n\t\treturn {\n\t\t\tnewCode,\n\t\t\tedits: [\n\t\t\t\t{\n\t\t\t\t\tat: start,\n\t\t\t\t\tdelta: -removed,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tat: start + removed,\n\t\t\t\t\tdelta: newCode.length,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t};\n}\n","import type { Plugin as RolldownPlugin } from \"rolldown\";\nimport type { Plugin as VitePlugin } from \"vite\";\n\nimport { resolveOptions, type PyxisPluginOptions } from \"./options\";\nimport { PyxisLoader } from \"./PyxisLoader\";\nimport { pyxisTranspileTsx } from \"./transpiler\";\n\nimport { pyxisDev } from \"./hmr/pyxisDev\";\nimport { transpileExportedSymbols } from \"./hmr/transpileExportedSymbols\";\nimport { transpileFactoryCalls } from \"./hmr/transpileFactoryCalls\";\n\nimport { pyxisTranspileCss } from \"./cssModules/pyxisTranspileCss\";\nimport { CssExportsRegistry } from \"./cssModules/CssExportsRegistry\";\nimport { transpileClassNames } from \"./cssModules/transpileClassNames\";\n\nexport type * from \"./options\";\n\nexport default function pyxis(pluginOptions?: PyxisPluginOptions) {\n\tconst options = resolveOptions(pluginOptions);\n\tconst loader = new PyxisLoader(options);\n\tconst registry = new CssExportsRegistry(loader);\n\tconst plugins: VitePlugin[] = [ loader.plugin ];\n\n\tconst tsxTag = loader.addFilter({\n\t\tinclude: options.include,\n\t\texclude: options.exclude,\n\t});\n\n\n\tif (options.hmr) {\n\t\tplugins.push(pyxisDev({ loader, options }));\n\t}\n\n\tif (options.cssModules) {\n\t\tconst cssTag = loader.addFilter({\n\t\t\tinclude: options.cssModules.include,\n\t\t\texclude: options.cssModules.exclude,\n\t\t\tvirtualExt: \".js\",\n\t\t});\n\n\t\tplugins.push(pyxisTranspileCss({\n\t\t\tloader,\n\t\t\tregistry,\n\t\t\toptions,\n\t\t\ttag: cssTag,\n\t\t}));\n\t}\n\n\tif (options.hmr || options.cssModules) {\n\t\tplugins.push(pyxisTranspileTsx({\n\t\t\tloader,\n\t\t\ttag: tsxTag,\n\t\t\tasync transpile(call) {\n\t\t\t\tif (options.hmr) {\n\t\t\t\t\tawait transpileExportedSymbols(call);\n\t\t\t\t\tawait transpileFactoryCalls({ ...call, loader });\n\t\t\t\t}\n\n\t\t\t\tif (options.cssModules) {\n\t\t\t\t\tawait transpileClassNames({ ...call, loader, registry, options });\n\t\t\t\t}\n\t\t\t},\n\t\t}));\n\t}\n\n\treturn plugins as RolldownPlugin[];\n}\n"],"mappings":"4BA2EA,SAAgB,EAAe,EAA8B,CAC5D,IAAM,EAAa,EAAS,GAAS,UAAU,EAC/C,MAAO,CACN,YAAa,GAAS,aAAe,kBACrC,QAAS,EAAQ,GAAS,QAAS,kBAAkB,EACrD,QAAS,EAAQ,GAAS,OAAO,EACjC,IAAK,GAAS,KAAO,GACrB,WAAY,GAAc,CACzB,QAAS,EAAQ,EAAW,QAAS,SAAS,EAC9C,QAAS,EAAQ,EAAW,OAAO,EACnC,QAAS,EAAQ,EAAW,QAAS,iBAAiB,EACtD,mBAAoB,EAAW,oBAAsB,KACrD,aAAc,EAAW,cAAgB,CAAC,CAC3C,CACD,CACD,CAEA,SAAS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 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@calmdown/rollup-plugin-pyxis",
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"license": "ISC",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"lightningcss": "1.33.0"
|
|
14
|
+
},
|
|
15
|
+
"peerDependenciesMeta": {
|
|
16
|
+
"lightningcss": {
|
|
17
|
+
"optional": true
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@oxc-project/types": "0.140.0",
|
|
22
|
+
"@types/node": "26.1.1",
|
|
23
|
+
"lightningcss": "1.33.0",
|
|
24
|
+
"rolldown": "1.2.0",
|
|
25
|
+
"typescript": "6.0.3",
|
|
26
|
+
"vite": "8.1.4",
|
|
27
|
+
"build-logic": "0.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Pyxis HMR Plugin for Vite
|
|
2
|
+
|
|
3
|
+
This plugin enables hot module reload (HMR) functionality in Pyxis apps served
|
|
4
|
+
with Vite dev server.
|
|
5
|
+
|
|
6
|
+
## Constraints
|
|
7
|
+
|
|
8
|
+
For speed and simplicity, the plugin assumes your code follows certain patterns.
|
|
9
|
+
When the plugin fails to detect familiar code, the HMR functionality will be
|
|
10
|
+
disabled for the offending module.
|
|
11
|
+
|
|
12
|
+
- A component is any function or arrow function wrapped in the `component`
|
|
13
|
+
factory imported from `@calmdown/pyxis`.
|
|
14
|
+
- Components must be exported.
|
|
15
|
+
- Modules without any components will not hot reload.
|
|
16
|
+
- Only components are hot reloaded, other symbols exported from a module remain
|
|
17
|
+
static.
|
|
18
|
+
|
|
19
|
+
Furthermore, the plugin does *not* detect side effects. Such code will re-run
|
|
20
|
+
with each hot reload. Ideally, your components should each reside in their own
|
|
21
|
+
module without any side effects.
|