babel-preset-dlight
Advanced tools
Comparing version 1.0.0-alpha.22 to 1.0.0-alpha.23
@@ -29,2 +29,12 @@ import { ConfigAPI, TransformOptions } from '@babel/core'; | ||
htmlTags?: HTMLTags; | ||
/** | ||
* Allowed HTML tags from attributes | ||
* e.g. { alt: ["area", "img", "input"] } | ||
*/ | ||
attributeMap?: Record<string, string[]>; | ||
/** | ||
* HTML attribute name map, from CamelCase to kebab-case | ||
* e.g. { acceptCharset: "accept-charset" } | ||
*/ | ||
alteredAttrMap?: Record<string, string>; | ||
} | ||
@@ -31,0 +41,0 @@ |
@@ -1,2 +0,2 @@ | ||
var I=Object.defineProperty;var k=(h,e,t)=>e in h?I(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var m=(h,e,t)=>(k(h,typeof e!="symbol"?e+"":e,t),t);import B from"babel-plugin-syntax-typescript-new";import M from"@babel/plugin-syntax-decorators";import{minimatch as x}from"minimatch";import{parseView as N}from"@dlightjs/view-parser";import{parseReactivity as v}from"@dlightjs/reactivity-parser";import{generateSubView as S,generateView as A}from"@dlightjs/view-generator";var C=process.env.NODE_ENV==="development",p=class{dlightPackageName=p.dlightDefaultPackageName;babelApi;t;traverse;enableDevTools;includes;excludes;htmlTags;constructor(e,t,i,s,r,n){this.babelApi=e,this.t=t,this.traverse=e.traverse,this.includes=i,this.excludes=s,this.enableDevTools=C&&r,this.htmlTags=typeof n=="function"?n(p.defaultHTMLTags):n.includes("*")?[...new Set([...p.defaultHTMLTags,...n])].filter(a=>a!=="*"):n}classDeclarationNode;classBodyNode;propertiesContainer={};dependencyMap={};enter=!0;enterClassNode=!1;className;programNode;allImports=[];didAlterImports=!1;clearNode(){this.classDeclarationNode=void 0,this.classBodyNode=void 0,this.propertiesContainer={},this.dependencyMap={},this.enter=!0,this.enterClassNode=!1,this.className=void 0}get availableProperties(){return Object.entries(this.propertiesContainer).filter(([e,{isWatcher:t,isStatic:i,isChildren:s}])=>e!=="_$compName"&&!t&&!i&&!s).map(([e])=>e)}initNode(e){let t=e.node;if(this.classDeclarationNode=t,this.classBodyNode=t.body,this.propertiesContainer={},t.id?.name||(t.id=this.t.identifier(`Anonymous_${p.uid()}`)),this.className=t.id?.name,this.handleClassCustomDecorators(),this.enableDevTools&&this.classBodyNode.body.unshift(this.t.classProperty(this.t.identifier("_$compName"),this.t.stringLiteral(this.className))),!this.didAlterImports){let i=this.allImports.filter(s=>s.source.value===p.dlightDefaultPackageName);this.dlightPackageName!==p.dlightDefaultPackageName&&i.forEach(s=>{s.source.value=this.dlightPackageName}),this.programNode.body.unshift(this.t.importDeclaration(Object.entries(p.importMap).map(([s,r])=>this.t.importSpecifier(this.t.identifier(r),this.t.identifier(s))),this.t.stringLiteral(this.dlightPackageName))),this.didAlterImports=!0}}enterProgram(e){}programEnterVisitor(e,t){if(this.enter=this.fileAllowed(t),!this.enter)return;if(this.allImports=e.node.body.filter(s=>this.t.isImportDeclaration(s)),this.allImports.filter(s=>s.source.value===p.dlightDefaultPackageName).length===0){this.enter=!1;return}this.programNode=e.node,this.enterProgram(e)}exitProgram(e){}programExitVisitor(e){this.enter&&(this.didAlterImports=!1,this.allImports=[],this.programNode=void 0,this.exitProgram(e))}enterClass(e){}classEnter(e){this.enter&&(this.enterClassNode=this.isDLightView(e),this.enterClass&&(this.initNode(e),this.enterClass(e)))}exitClass(e){}classExit(e){this.enter&&this.enterClassNode&&(this.transformDLightClass(),this.exitClass(e),this.clearNode(),this.enterClassNode=!1)}visitClassMethod(e){}classMethodVisitor(e){if(!this.enterClassNode||!this.t.isIdentifier(e.node.key))return;let t=e.node.key.name;if(t==="View"||this.findDecoratorByName(e.node.decorators,"View"))return;let s=e.node,r=this.findDecoratorByName(s.decorators,"Watch");if(!r){if(this.t.isIdentifier(s.key)&&["constructor","willMount","didMount","willUnmount","didUnmount"].includes(s.key.name))return;this.autoBindMethods(s);return}let n=[];if(this.t.isIdentifier(r))n=this.getDependencies(e);else{let a=r.arguments[0];this.t.isArrayExpression(a)&&(n=a.elements.filter(o=>this.t.isStringLiteral(o)).map(o=>o.value),n=[...new Set(n)])}this.propertiesContainer[t]={node:s,deps:n,isWatcher:!0},s.decorators=this.removeDecorators(s.decorators,["Watch"]),this.visitClassMethod(e)}visitClassProperty(e){}classPropertyVisitor(e){if(!this.enterClassNode)return;let t=e.node;if(!this.t.isIdentifier(t.key))return;let i=t.key.name;if(i==="View")return;let s=t.decorators;if(this.findDecoratorByName(s,"View"))return;let n=!!this.findDecoratorByName(s,"Prop"),a=!!this.findDecoratorByName(s,"Env"),o=!!this.findDecoratorByName(t.decorators,"Children"),d=o?[]:this.getDependencies(e);this.propertiesContainer[i]={node:t,deps:d,isStatic:!!this.findDecoratorByName(s,"Static"),isContent:!!this.findDecoratorByName(s,"Content"),isChildren:o,isPropOrEnv:n?"Prop":a?"Env":void 0},t.decorators=this.removeDecorators(s,p.availableDecoNames),this.visitClassProperty(e)}resolveWatcherDecorator(e){if(!this.t.isIdentifier(e.key))return;let t=e.key.name,i=this.classBodyNode.body.indexOf(e),s=this.t.classProperty(this.t.identifier(`$w$${t}`));this.classBodyNode.body.splice(i,0,s)}resolveChildrenDecorator(e){if(!this.classBodyNode||!this.t.isIdentifier(e.key))return;let t=e.key.name,i=this.classBodyNode.body.indexOf(e),s=this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$children")),r=this.t.classMethod("get",this.t.identifier(t),[],this.t.blockStatement([this.t.returnStatement(s)]));this.classBodyNode.body.splice(i,1,r)}resolveContentDecorator(e){if(!this.classBodyNode||!this.t.isIdentifier(e.key)||this.classBodyNode.body.some(r=>this.t.isClassProperty(r)&&r.key.name==="_$contentKey"))return;let t=e.key.name,i=this.classBodyNode.body.indexOf(e),s=this.t.classProperty(this.t.identifier("_$contentKey"),this.t.stringLiteral(t));this.classBodyNode.body.splice(i,0,s)}resolvePropDecorator(e,t){if(!this.classBodyNode||!this.t.isIdentifier(e.key))return;let i=e.key.name,s=this.classBodyNode.body.indexOf(e),r=t.toLowerCase()==="prop"?"p":"e",n=this.t.classProperty(this.t.identifier(`$${r}$${i}`));this.classBodyNode.body.splice(s,0,n)}resolveStateDecorator(e,t,i){if(!this.classBodyNode||!this.t.isIdentifier(e.key))return;let s=e.key.name;e.key.name=`$${s}`;let r=this.classBodyNode.body.indexOf(e),n=this.t.classProperty(this.t.identifier(`$$${s}`),this.t.numericLiteral(1<<t)),a=i?[this.t.classProperty(this.t.identifier(`$s$${s}`),this.t.arrayExpression([...i].map(c=>this.t.stringLiteral(c))))]:[],o=this.t.classMethod("get",this.t.identifier(s),[],this.t.blockStatement([this.t.returnStatement(this.t.memberExpression(this.t.thisExpression(),this.t.identifier(`$${s}`)))])),d=this.t.classMethod("set",this.t.identifier(s),[this.t.identifier("value")],this.t.blockStatement([this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$updateProp")),[this.t.stringLiteral(s),this.t.identifier("value")]))]));this.classBodyNode.body.splice(r+1,0,n,...a,o,d)}handleClassCustomDecorators(){if(!this.classBodyNode)return;let e=this.classDeclarationNode?.decorators;if(!e)return;this.findDecoratorByName(e,"ForwardProps")&&(this.classBodyNode.body.unshift(this.t.classProperty(this.t.identifier("_$forwardProps")),this.t.classProperty(this.t.identifier("_$forwardPropsSet"),this.t.newExpression(this.t.identifier("Set"),[])),this.t.classProperty(this.t.identifier("_$forwardPropsId"),this.t.arrayExpression([]))),this.classDeclarationNode.decorators=this.removeDecorators(e,["ForwardProps"]))}transformDLightClass(){let e=this.handleView(),t=Object.entries(this.propertiesContainer).reverse(),i=this.dependencyMapReversed();for(let[s,{node:r,deps:n,isStatic:a,isChildren:o,isPropOrEnv:d,isWatcher:c,isContent:l}]of t){if(o){this.resolveChildrenDecorator(r);continue}n.length>0&&(e.push(...n),c?this.resolveWatcherDecorator(r):this.handleDerivedProperty(r)),d&&this.resolvePropDecorator(r,d),l&&(this.resolvePropDecorator(r,"Prop"),this.resolveContentDecorator(r)),!a&&e.includes(s)&&this.resolveStateDecorator(r,this.availableProperties.indexOf(s),i[s])}}handleView(){if(!this.classBodyNode)return[];let e=new Set,t,i=[];for(let o of this.classBodyNode.body){if(!this.t.isClassProperty(o)&&!this.t.isClassMethod(o)||!this.t.isIdentifier(o.key))continue;let d=this.findDecoratorByName(o.decorators,"View"),c=o.key.name==="View";if(!(!d&&!c)){if(this.t.isClassProperty(o)){let l=o.value;for(;this.t.isTSAsExpression(l);)l=l.expression;if(!this.t.isArrowFunctionExpression(l))continue;o.value=l;let f=this.arrowFunctionPropertyToMethod(o);if(!f)continue;o=f}d?(o.decorators=null,i.push(o)):t=o}}let s=i.map(o=>o.key.name),r=Object.fromEntries(i.map(o=>{let d=o.params[0];if(!d||!this.t.isObjectPattern(d))return["-",null];let c=Object.fromEntries(d.properties.map(l=>{if(!this.t.isObjectProperty(l))return["-",null];let f=l.key.name,y=this.getIdentifiers(this.t.assignmentExpression("=",this.t.objectPattern([this.t.objectProperty(this.t.numericLiteral(0),l.value)]),this.t.numericLiteral(0))).filter(b=>b!==f);return[f,y]}).filter(([l,f])=>f));return[o.key.name,c]}).filter(([o,d])=>d)),n=-1;if(t){let o;[o,n]=this.alterMainView(t,s,r),o.forEach(e.add.bind(e))}i.forEach(o=>{let d;[d,n]=this.alterSubView(o,s,r,n),d.forEach(e.add.bind(e))});let a=[];return this.availableProperties.forEach(o=>{e.has(o)&&a.push(o)}),a}alterMainView(e,t,i){let s=N(e.body,{babelApi:this.babelApi,subviewNames:t,htmlTags:this.htmlTags}),[r,n]=v(s,{babelApi:this.babelApi,availableProperties:this.availableProperties,dependencyMap:this.dependencyMap}),[a,o,d]=A(r,{babelApi:this.babelApi,className:this.className,importMap:p.importMap,subViewPropMap:Object.fromEntries(Object.entries(i).map(([c,l])=>[c,Object.keys(l)])),templateIdx:-1});return e.body=a,this.classBodyNode?.body.push(...o),[n,d]}alterSubView(e,t,i,s){e.params.length===0?e.params.push(this.t.identifier("_$"),this.t.identifier("$subviewNode")):e.params.length===1?e.params.push(this.t.identifier("$subviewNode")):(e.params[1]=this.t.identifier("$subviewNode"),e.params.length=2);let r=N(e.body,{babelApi:this.babelApi,subviewNames:t,htmlTags:this.htmlTags}),[n,a]=v(r,{babelApi:this.babelApi,availableProperties:this.availableProperties,dependencyMap:this.dependencyMap}),o=i[e.key.name]??[],d={};Object.entries(o).forEach(([g,P])=>{P.forEach(w=>{d[w]=[g]})});let[c]=v(r,{babelApi:this.babelApi,availableProperties:Object.keys(o),dependencyMap:this.dependencyMap,dependencyParseType:"identifier",identifierDepMap:d}),l=Object.fromEntries(Object.entries(i).map(([g,P])=>[g,Object.keys(P)])),[f,y,b]=S(n,c,e.params[0],{babelApi:this.babelApi,className:this.className,importMap:p.importMap,subViewPropMap:l,templateIdx:s});return e.body=f,this.classBodyNode?.body.push(...y),[a,b]}fileAllowed(e){return this.includes.includes("*")?!0:!(!e||this.excludes.some(t=>x(e,t))||!this.includes.some(t=>x(e,t)))}isDLightView(e){let t=e.node;return(t.decorators??[]).find(r=>this.t.isIdentifier(r.expression,{name:"View"}))&&(t.superClass=this.t.identifier("View"),t.decorators=t.decorators?.filter(r=>!this.t.isIdentifier(r.expression,{name:"View"}))),this.t.isIdentifier(t.superClass,{name:"View"})}removeDecorators(e,t){return e?e.filter(i=>!(this.t.isIdentifier(i.expression)&&t.includes(i.expression.name)||this.t.isCallExpression(i.expression)&&this.t.isIdentifier(i.expression.callee)&&t.includes(i.expression.callee.name))):[]}findDecoratorByName(e,t){if(e)return e.find(i=>this.t.isIdentifier(i.expression,{name:t})||this.t.isCallExpression(i.expression)&&this.t.isIdentifier(i.expression.callee,{name:t}))?.expression}addConstructor(){let e=this.classBodyNode.body.find(t=>this.t.isClassMethod(t,{kind:"constructor"}));return e||(e=this.t.classMethod("constructor",this.t.identifier("constructor"),[],this.t.blockStatement([this.t.expressionStatement(this.t.callExpression(this.t.super(),[]))])),this.classBodyNode.body.unshift(e),e)}autoBindMethods(e){this.addConstructor().body.body.push(this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.thisExpression(),e.key),this.t.callExpression(this.t.memberExpression(this.t.memberExpression(this.t.thisExpression(),e.key),this.t.identifier("bind")),[this.t.thisExpression()]))))}handleDerivedProperty(e){if(!this.t.isIdentifier(e.key))return;let t=e.key.name,i=e.value,s=this.classBodyNode.body.indexOf(e),r=this.t.classMethod("get",this.t.identifier(`$f$${t}`),[],this.t.blockStatement([this.t.returnStatement(i)]));this.classBodyNode.body.splice(s+1,0,r),e.value=null}getDependencies(e){let t=e.node;if(!this.t.isIdentifier(t.key))return[];let i=new Set,s=new Set;e.scope.traverse(t,{MemberExpression:a=>{if(!this.t.isIdentifier(a.node.property))return;let o=a.node.property.name;this.isAssignmentExpressionLeft(a)?s.add(o):this.availableProperties.includes(o)&&this.t.isThisExpression(a.node.object)&&!this.isMemberInEscapeFunction(a,this.classDeclarationNode)&&!this.isMemberInManualFunction(a,this.classDeclarationNode)&&!this.isAssignmentExpressionRight(a,this.classDeclarationNode)&&(i.add(o),this.dependencyMap[o]?.forEach(i.add.bind(i)))}}),s.forEach(i.delete.bind(i));let r=t.key.name,n=[...i];return i.size>0&&(this.dependencyMap[r]=n),n}dependencyMapReversed(){let e={};return Object.entries(this.dependencyMap).forEach(([t,i])=>{i.forEach(s=>{e[s]||(e[s]=new Set),e[s].add(t)})}),e}arrowFunctionPropertyToMethod(e){if(!this.t.isArrowFunctionExpression(e.value))return;let t=e.value;if(!this.t.isBlockStatement(t.body))return;let i=this.classBodyNode.body.indexOf(e),s=this.t.classMethod("method",e.key,t.params,t.body);return this.classBodyNode.body.splice(i,1,s),s}isMemberExpressionProperty(e,t){return this.t.isMemberExpression(e)&&!e.computed&&e.property===t}isObjectKey(e,t){return this.t.isObjectProperty(e)&&e.key===t}valueWithArrowFunc(e){e.value||(e.value=this.t.identifier("undefined")),e.value=this.t.arrowFunctionExpression([],e.value)}valueWrapper(e){return this.t.file(this.t.program([this.t.isStatement(e)?e:this.t.expressionStatement(e)]))}isAttrFromFunction(e,t){let i=e.parentPath,s=r=>this.t.isIdentifier(r)?r.name===t:this.t.isAssignmentPattern(r)?s(r.left):this.t.isArrayPattern(r)?r.elements.filter(Boolean).map(n=>s(n)).includes(!0):this.t.isObjectPattern(r)?r.properties.filter(n=>this.t.isObjectProperty(n)&&this.t.isIdentifier(n.key)).map(n=>n.key.name).includes(t):this.t.isRestElement(r)?s(r.argument):!1;for(;i;){let r=i.node;if(this.t.isArrowFunctionExpression(r)||this.t.isFunctionDeclaration(r)){for(let n of r.params)if(s(n))return!0}i=i.parentPath}return!1}isStandAloneIdentifier(e){let t=e.node,i=e.parentPath?.node;if(this.t.isMemberExpression(i)&&i.property===t||this.isAttrFromFunction(e,t.name))return!1;for(;e.parentPath;){if(this.t.isVariableDeclarator(e.parentPath.node)||this.t.isObjectProperty(e.parentPath.node)&&e.parentPath.node.key===e.node&&!e.parentPath.node.computed)return!1;e=e.parentPath}return!0}getIdentifiers(e){if(this.t.isIdentifier(e))return[e.name];let t=new Set;return this.traverse(this.valueWrapper(e),{Identifier:i=>{this.isStandAloneIdentifier(i)&&t.add(i.node.name)}}),[...t]}isAssignmentExpressionLeft(e){let t=e.parentPath?.node;return this.t.isAssignmentExpression(t)&&t.left===e.node||this.t.isUpdateExpression(t)}isAssignmentExpressionRight(e,t){let i=e.node,s=!1,r=e.parentPath;for(;r&&r.node!==t;){if(this.t.isAssignmentExpression(r.node)){let n=r.node.left,a=i.type===n.type,o=i.property.name===n.property.name;s=a&&o}r=r.parentPath}return s}isMemberInEscapeFunction(e,t){let i=!1,s=e.parentPath;for(;s&&s.node!==t;){let r=s.node;if(this.t.isCallExpression(r)&&this.t.isIdentifier(r.callee)&&p.escapeNamings.includes(r.callee.name)){i=!0;break}s=s.parentPath}return i}isMemberInManualFunction(e,t){let i=!1,s=e.parentPath;for(;s&&s.node!==t;){let r=s.node,n=s.parentPath?.node,a=this.t.isFunctionExpression(r)||this.t.isArrowFunctionExpression(r),o=this.t.isCallExpression(n)&&this.t.isIdentifier(n.callee)&&n.callee.name==="manual";if(a&&o){i=!0;break}s=s.parentPath}return i}static uid(e=4){return Math.random().toString(32).slice(2,e+2)}},u=p;m(u,"defaultHTMLTags",["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","acronym","applet","basefont","bgsound","big","blink","center","dir","font","frame","frameset","isindex","keygen","listing","marquee","menuitem","multicol","nextid","nobr","noembed","noframes","param","plaintext","rb","rtc","spacer","strike","tt","xmp","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tspan","use","view"]),m(u,"availableDecoNames",["Static","Prop","Env","Content","Children"]),m(u,"dlightDefaultPackageName","@dlightjs/dlight"),m(u,"importMap",Object.fromEntries(["createTemplate","setStyle","setDataset","setEvent","setHTMLProp","setHTMLAttr","setHTMLProps","setHTMLAttrs","insertNode","createElement","ForNode","CondNode","EnvNode","createTextNode","updateText","ExpNode","PropView","SubViewNode"].map((e,t)=>C?[e,e]:[e,`$${t}$`]))),m(u,"escapeNamings",["escape","$"]);var E=u;function D(h,e){let{types:t}=h,{files:i="**/*.{js,jsx,ts,tsx}",excludeFiles:s="**/{dist,node_modules,lib}/*.{js,ts}",enableDevTools:r=!1,htmlTags:n=o=>o}=e,a=new E(h,t,Array.isArray(i)?i:[i],Array.isArray(s)?s:[s],r,n);return{visitor:{Program:{enter(o,{filename:d}){return a.programEnterVisitor(o,d)},exit:a.programExitVisitor.bind(a)},ClassDeclaration:{enter:a.classEnter.bind(a),exit:a.classExit.bind(a)},ClassExpression:{enter:a.classEnter.bind(a),exit:a.classExit.bind(a)},ClassMethod:a.classMethodVisitor.bind(a),ClassProperty:a.classPropertyVisitor.bind(a)}}}function q(h,e){return{plugins:[B,[M.default??M,{legacy:!0}],[D,e]]}}export{q as default}; | ||
var O=Object.defineProperty;var L=(c,e,t)=>e in c?O(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var M=(c,e,t)=>(L(c,typeof e!="symbol"?e+"":e,t),t);import $ from"babel-plugin-syntax-typescript-new";import V from"@babel/plugin-syntax-decorators";import{minimatch as k}from"minimatch";import{parseView as I}from"@dlightjs/view-parser";import{parseReactivity as N}from"@dlightjs/reactivity-parser";import{generateSubView as j,generateView as T}from"@dlightjs/view-generator";var P=process.env.NODE_ENV==="development",C=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","acronym","applet","basefont","bgsound","big","blink","center","dir","font","frame","frameset","isindex","keygen","listing","marquee","menuitem","multicol","nextid","nobr","noembed","noframes","param","plaintext","rb","rtc","spacer","strike","tt","xmp","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tspan","use","view"],E=["Static","Prop","Env","Content","Children"],u="@dlightjs/dlight",f=Object.fromEntries(["createTemplate","setStyle","setDataset","setEvent","setHTMLProp","setHTMLAttr","setHTMLProps","setHTMLAttrs","insertNode","createElement","ForNode","CondNode","EnvNode","createTextNode","updateText","ExpNode","PropView","SubViewNode"].map((c,e)=>P?[c,c]:[c,`$${e}$`])),w={acceptCharset:"accept-charset",colSpan:"colspan",contentEditable:"contenteditable",formAction:"formaction",formEnctype:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",httpEquiv:"http-equiv",intrinsicSize:"intrinsicsize",inputMode:"inputmode",itemProp:"itemprop",maxLength:"maxlength",minLength:"minlength",noValidate:"novalidate",playsInline:"playsinline",referrerPolicy:"referrerpolicy",rowSpan:"rowspan",tabIndex:"tabindex",ariaAutocomplete:"aria-autocomplete",ariaChecked:"aria-checked",ariaDisabled:"aria-disabled",ariaErrorMessage:"aria-errormessage",ariaExpanded:"aria-expanded",ariaHasPopup:"aria-haspopup",ariaHidden:"aria-hidden",ariaInvalid:"aria-invalid",ariaLabel:"aria-label",ariaLevel:"aria-level",ariaModal:"aria-modal",ariaMultiline:"aria-multiline",ariaMultiSelectable:"aria-multiselectable",ariaOrientation:"aria-orientation",ariaPlaceholder:"aria-placeholder",ariaPressed:"aria-pressed",ariaReadonly:"aria-readonly",ariaRequired:"aria-required",ariaSelected:"aria-selected",ariaSort:"aria-sort",ariaValuemax:"aria-valuemax",ariaValuemin:"aria-valuemin",ariaValueNow:"aria-valuenow",ariaValueText:"aria-valuetext",ariaBusy:"aria-busy",ariaLive:"aria-live",ariaRelevant:"aria-relevant",ariaAtomic:"aria-atomic",ariaDropEffect:"aria-dropeffect",ariaGrabbed:"aria-grabbed",ariaActiveDescendant:"aria-activedescendant",ariaColCount:"aria-colcount",ariaColIndex:"aria-colindex",ariaColSpan:"aria-colspan",ariaControls:"aria-controls",ariaDescribedBy:"aria-describedby",ariaDescription:"aria-description",ariaDetails:"aria-details",ariaFlowTo:"aria-flowto",ariaLabelLedBy:"aria-labelledby",ariaOwns:"aria-owns",ariaPosInset:"aria-posinset",ariaRowCount:"aria-rowcount",ariaRowIndex:"aria-rowindex",ariaRowSpan:"aria-rowspan",ariaSetSize:"aria-setsize"},D={textContent:["*"],innerHTML:["*"],accept:["form","input"],acceptCharset:["form"],accesskey:["*"],action:["form"],align:["caption","col","colgroup","hr","iframe","img","table","tbody","td","tfoot","th","thead","tr"],allow:["iframe"],alt:["area","img","input"],async:["script"],autocapitalize:["*"],autocomplete:["form","input","select","textarea"],autofocus:["button","input","select","textarea"],autoplay:["audio","video"],background:["body","table","td","th"],bgColor:["body","col","colgroup","marquee","table","tbody","tfoot","td","th","tr"],border:["img","object","table"],buffered:["audio","video"],capture:["input"],charset:["meta"],checked:["input"],cite:["blockquote","del","ins","q"],class:["*"],color:["font","hr"],cols:["textarea"],colSpan:["td","th"],content:["meta"],contentEditable:["*"],contextmenu:["*"],controls:["audio","video"],coords:["area"],crossOrigin:["audio","img","link","script","video"],csp:["iframe"],data:["object"],dateTime:["del","ins","time"],decoding:["img"],default:["track"],defer:["script"],dir:["*"],dirname:["input","textarea"],disabled:["button","fieldset","input","optgroup","option","select","textarea"],download:["a","area"],draggable:["*"],enctype:["form"],enterKeyHint:["textarea","contenteditable"],for:["label","output"],form:["button","fieldset","input","label","meter","object","output","progress","select","textarea"],formAction:["input","button"],formEnctype:["button","input"],formMethod:["button","input"],formNoValidate:["button","input"],formTarget:["button","input"],headers:["td","th"],height:["canvas","embed","iframe","img","input","object","video"],hidden:["*"],high:["meter"],href:["a","area","base","link"],hreflang:["a","link"],httpEquiv:["meta"],id:["*"],integrity:["link","script"],intrinsicSize:["img"],inputMode:["textarea","contenteditable"],ismap:["img"],itemProp:["*"],kind:["track"],label:["optgroup","option","track"],lang:["*"],language:["script"],loading:["img","iframe"],list:["input"],loop:["audio","marquee","video"],low:["meter"],manifest:["html"],max:["input","meter","progress"],maxLength:["input","textarea"],minLength:["input","textarea"],media:["a","area","link","source","style"],method:["form"],min:["input","meter"],multiple:["input","select"],muted:["audio","video"],name:["button","form","fieldset","iframe","input","object","output","select","textarea","map","meta","param"],noValidate:["form"],open:["details","dialog"],optimum:["meter"],pattern:["input"],ping:["a","area"],placeholder:["input","textarea"],playsInline:["video"],poster:["video"],preload:["audio","video"],readonly:["input","textarea"],referrerPolicy:["a","area","iframe","img","link","script"],rel:["a","area","link"],required:["input","select","textarea"],reversed:["ol"],role:["*"],rows:["textarea"],rowSpan:["td","th"],sandbox:["iframe"],scope:["th"],scoped:["style"],selected:["option"],shape:["a","area"],size:["input","select"],sizes:["link","img","source"],slot:["*"],span:["col","colgroup"],spellcheck:["*"],src:["audio","embed","iframe","img","input","script","source","track","video"],srcdoc:["iframe"],srclang:["track"],srcset:["img","source"],start:["ol"],step:["input"],style:["*"],summary:["table"],tabIndex:["*"],target:["a","area","base","form"],title:["*"],translate:["*"],type:["button","input","embed","object","ol","script","source","style","menu","link"],usemap:["img","input","object"],value:["button","data","input","li","meter","option","progress","param","text"],width:["canvas","embed","iframe","img","input","object","video"],wrap:["textarea"],ariaAutocomplete:["*"],ariaChecked:["*"],ariaDisabled:["*"],ariaErrorMessage:["*"],ariaExpanded:["*"],ariaHasPopup:["*"],ariaHidden:["*"],ariaInvalid:["*"],ariaLabel:["*"],ariaLevel:["*"],ariaModal:["*"],ariaMultiline:["*"],ariaMultiSelectable:["*"],ariaOrientation:["*"],ariaPlaceholder:["*"],ariaPressed:["*"],ariaReadonly:["*"],ariaRequired:["*"],ariaSelected:["*"],ariaSort:["*"],ariaValuemax:["*"],ariaValuemin:["*"],ariaValueNow:["*"],ariaValueText:["*"],ariaBusy:["*"],ariaLive:["*"],ariaRelevant:["*"],ariaAtomic:["*"],ariaDropEffect:["*"],ariaGrabbed:["*"],ariaActiveDescendant:["*"],ariaColCount:["*"],ariaColIndex:["*"],ariaColSpan:["*"],ariaControls:["*"],ariaDescribedBy:["*"],ariaDescription:["*"],ariaDetails:["*"],ariaFlowTo:["*"],ariaLabelledBy:["*"],ariaOwns:["*"],ariaPosInset:["*"],ariaRowCount:["*"],ariaRowIndex:["*"],ariaRowSpan:["*"],ariaSetSize:["*"]};var b=class{dlightPackageName=u;babelApi;t;traverse;enableDevTools;includes;excludes;htmlTags;attributeMap;alteredAttrMap;constructor(e,t,r,i,s,o,l,a){this.babelApi=e,this.t=t,this.traverse=e.traverse,this.includes=r,this.excludes=i,this.enableDevTools=P&&s,this.htmlTags=typeof o=="function"?o(C):o.includes("*")?[...new Set([...C,...o])].filter(n=>n!=="*"):o,this.attributeMap=l,this.alteredAttrMap=a}classDeclarationNode;classBodyNode;propertiesContainer={};dependencyMap={};enter=!0;enterClassNode=!1;className;programNode;allImports=[];didAlterImports=!1;clearNode(){this.classDeclarationNode=void 0,this.classBodyNode=void 0,this.propertiesContainer={},this.dependencyMap={},this.enter=!0,this.enterClassNode=!1,this.className=void 0}get availableProperties(){return Object.entries(this.propertiesContainer).filter(([e,{isWatcher:t,isStatic:r,isChildren:i}])=>e!=="_$compName"&&!t&&!r&&!i).map(([e])=>e)}initNode(e){let t=e.node;if(this.classDeclarationNode=t,this.classBodyNode=t.body,this.propertiesContainer={},t.id?.name||(t.id=this.t.identifier(`Anonymous_${b.uid()}`)),this.className=t.id?.name,this.handleClassCustomDecorators(),this.enableDevTools&&this.classBodyNode.body.unshift(this.t.classProperty(this.t.identifier("_$compName"),this.t.stringLiteral(this.className))),!this.didAlterImports){let r=this.allImports.filter(i=>i.source.value===u);this.dlightPackageName!==u&&r.forEach(i=>{i.source.value=this.dlightPackageName}),this.programNode.body.unshift(this.t.importDeclaration(Object.entries(f).map(([i,s])=>this.t.importSpecifier(this.t.identifier(s),this.t.identifier(i))),this.t.stringLiteral(this.dlightPackageName))),this.didAlterImports=!0}}enterProgram(e){}programEnterVisitor(e,t){if(this.enter=this.fileAllowed(t),!this.enter)return;if(this.allImports=e.node.body.filter(i=>this.t.isImportDeclaration(i)),this.allImports.filter(i=>i.source.value===u).length===0){this.enter=!1;return}this.programNode=e.node,this.enterProgram(e)}exitProgram(e){}programExitVisitor(e){this.enter&&(this.didAlterImports=!1,this.allImports=[],this.programNode=void 0,this.exitProgram(e))}enterClass(e){}classEnter(e){this.enter&&(this.enterClassNode=this.isDLightView(e),this.enterClass&&(this.initNode(e),this.enterClass(e)))}exitClass(e){}classExit(e){this.enter&&this.enterClassNode&&(this.transformDLightClass(),this.exitClass(e),this.clearNode(),this.enterClassNode=!1)}visitClassMethod(e){}classMethodVisitor(e){if(!this.enterClassNode||!this.t.isIdentifier(e.node.key))return;let t=e.node.key.name;if(t==="View"||this.findDecoratorByName(e.node.decorators,"View"))return;let i=e.node,s=this.findDecoratorByName(i.decorators,"Watch");if(!s){if(this.t.isIdentifier(i.key)&&["constructor","willMount","didMount","willUnmount","didUnmount"].includes(i.key.name))return;this.autoBindMethods(i);return}let o=[];if(this.t.isIdentifier(s))o=this.getDependencies(e);else{let l=s.arguments[0];this.t.isArrayExpression(l)&&(o=l.elements.filter(a=>this.t.isStringLiteral(a)).map(a=>a.value),o=[...new Set(o)])}this.propertiesContainer[t]={node:i,deps:o,isWatcher:!0},i.decorators=this.removeDecorators(i.decorators,["Watch"]),this.visitClassMethod(e)}visitClassProperty(e){}classPropertyVisitor(e){if(!this.enterClassNode)return;let t=e.node;if(!this.t.isIdentifier(t.key))return;let r=t.key.name;if(r==="View")return;let i=t.decorators;if(this.findDecoratorByName(i,"View"))return;let o=!!this.findDecoratorByName(i,"Prop"),l=!!this.findDecoratorByName(i,"Env"),a=!!this.findDecoratorByName(t.decorators,"Children"),n=a?[]:this.getDependencies(e);this.propertiesContainer[r]={node:t,deps:n,isStatic:!!this.findDecoratorByName(i,"Static"),isContent:!!this.findDecoratorByName(i,"Content"),isChildren:a,isPropOrEnv:o?"Prop":l?"Env":void 0},t.decorators=this.removeDecorators(i,E),this.visitClassProperty(e)}resolveWatcherDecorator(e){if(!this.t.isIdentifier(e.key))return;let t=e.key.name,r=this.classBodyNode.body.indexOf(e),i=this.t.classProperty(this.t.identifier(`$w$${t}`));this.classBodyNode.body.splice(r,0,i)}resolveChildrenDecorator(e){if(!this.classBodyNode||!this.t.isIdentifier(e.key))return;let t=e.key.name,r=this.classBodyNode.body.indexOf(e),i=this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$children")),s=this.t.classMethod("get",this.t.identifier(t),[],this.t.blockStatement([this.t.returnStatement(i)]));this.classBodyNode.body.splice(r,1,s)}resolveContentDecorator(e){if(!this.classBodyNode||!this.t.isIdentifier(e.key)||this.classBodyNode.body.some(s=>this.t.isClassProperty(s)&&s.key.name==="_$contentKey"))return;let t=e.key.name,r=this.classBodyNode.body.indexOf(e),i=this.t.classProperty(this.t.identifier("_$contentKey"),this.t.stringLiteral(t));this.classBodyNode.body.splice(r,0,i)}resolvePropDecorator(e,t){if(!this.classBodyNode||!this.t.isIdentifier(e.key))return;let r=e.key.name,i=this.classBodyNode.body.indexOf(e),s=t.toLowerCase()==="prop"?"p":"e",o=this.t.classProperty(this.t.identifier(`$${s}$${r}`));this.classBodyNode.body.splice(i,0,o)}resolveStateDecorator(e,t,r){if(!this.classBodyNode||!this.t.isIdentifier(e.key))return;let i=e.key.name;e.key.name=`$${i}`;let s=this.classBodyNode.body.indexOf(e),o=this.t.classProperty(this.t.identifier(`$$${i}`),this.t.numericLiteral(1<<t)),l=r?[this.t.classProperty(this.t.identifier(`$s$${i}`),this.t.arrayExpression([...r].map(p=>this.t.stringLiteral(p))))]:[],a=this.t.classMethod("get",this.t.identifier(i),[],this.t.blockStatement([this.t.returnStatement(this.t.memberExpression(this.t.thisExpression(),this.t.identifier(`$${i}`)))])),n=this.t.classMethod("set",this.t.identifier(i),[this.t.identifier("value")],this.t.blockStatement([this.t.expressionStatement(this.t.callExpression(this.t.memberExpression(this.t.thisExpression(),this.t.identifier("_$updateProp")),[this.t.stringLiteral(i),this.t.identifier("value")]))]));this.classBodyNode.body.splice(s+1,0,o,...l,a,n)}handleClassCustomDecorators(){if(!this.classBodyNode)return;let e=this.classDeclarationNode?.decorators;if(!e)return;this.findDecoratorByName(e,"ForwardProps")&&(this.classBodyNode.body.unshift(this.t.classProperty(this.t.identifier("_$forwardProps")),this.t.classProperty(this.t.identifier("_$forwardPropsSet"),this.t.newExpression(this.t.identifier("Set"),[])),this.t.classProperty(this.t.identifier("_$forwardPropsId"),this.t.arrayExpression([]))),this.classDeclarationNode.decorators=this.removeDecorators(e,["ForwardProps"]))}transformDLightClass(){let e=this.handleView(),t=Object.entries(this.propertiesContainer).reverse(),r=this.dependencyMapReversed();for(let[i,{node:s,deps:o,isStatic:l,isChildren:a,isPropOrEnv:n,isWatcher:p,isContent:d}]of t){if(a){this.resolveChildrenDecorator(s);continue}o.length>0&&(e.push(...o),p?this.resolveWatcherDecorator(s):this.handleDerivedProperty(s)),n&&this.resolvePropDecorator(s,n),d&&(this.resolvePropDecorator(s,"Prop"),this.resolveContentDecorator(s)),!l&&e.includes(i)&&this.resolveStateDecorator(s,this.availableProperties.indexOf(i),r[i])}}handleView(){if(!this.classBodyNode)return[];let e=new Set,t,r=[];for(let a of this.classBodyNode.body){if(!this.t.isClassProperty(a)&&!this.t.isClassMethod(a)||!this.t.isIdentifier(a.key))continue;let n=this.findDecoratorByName(a.decorators,"View"),p=a.key.name==="View";if(!(!n&&!p)){if(this.t.isClassProperty(a)){let d=a.value;for(;this.t.isTSAsExpression(d);)d=d.expression;if(!this.t.isArrowFunctionExpression(d))continue;a.value=d;let h=this.arrowFunctionPropertyToMethod(a);if(!h)continue;a=h}n?(a.decorators=null,r.push(a)):t=a}}let i=r.map(a=>a.key.name),s=Object.fromEntries(r.map(a=>{let n=a.params[0];if(!n||!this.t.isObjectPattern(n))return["-",null];let p=Object.fromEntries(n.properties.map(d=>{if(!this.t.isObjectProperty(d))return["-",null];let h=d.key.name,y=this.getIdentifiers(this.t.assignmentExpression("=",this.t.objectPattern([this.t.objectProperty(this.t.numericLiteral(0),d.value)]),this.t.numericLiteral(0))).filter(g=>g!==h);return[h,y]}).filter(([d,h])=>h));return[a.key.name,p]}).filter(([a,n])=>n)),o=-1;if(t){let a;[a,o]=this.alterMainView(t,i,s),a.forEach(e.add.bind(e))}r.forEach(a=>{let n;[n,o]=this.alterSubView(a,i,s,o),n.forEach(e.add.bind(e))});let l=[];return this.availableProperties.forEach(a=>{e.has(a)&&l.push(a)}),l}alterMainView(e,t,r){let i=I(e.body,{babelApi:this.babelApi,subviewNames:t,htmlTags:this.htmlTags}),[s,o]=N(i,{babelApi:this.babelApi,availableProperties:this.availableProperties,dependencyMap:this.dependencyMap,alteredAttrMap:this.alteredAttrMap}),[l,a,n]=T(s,{babelApi:this.babelApi,className:this.className,importMap:f,subViewPropMap:Object.fromEntries(Object.entries(r).map(([p,d])=>[p,Object.keys(d)])),templateIdx:-1,attributeMap:this.attributeMap});return e.body=l,this.classBodyNode?.body.push(...a),[o,n]}alterSubView(e,t,r,i){e.params.length===0?e.params.push(this.t.identifier("_$"),this.t.identifier("$subviewNode")):e.params.length===1?e.params.push(this.t.identifier("$subviewNode")):(e.params[1]=this.t.identifier("$subviewNode"),e.params.length=2);let s=I(e.body,{babelApi:this.babelApi,subviewNames:t,htmlTags:this.htmlTags}),[o,l]=N(s,{babelApi:this.babelApi,availableProperties:this.availableProperties,dependencyMap:this.dependencyMap,alteredAttrMap:this.alteredAttrMap}),a=r[e.key.name]??[],n={};Object.entries(a).forEach(([v,x])=>{x.forEach(B=>{n[B]=[v]})});let[p]=N(s,{babelApi:this.babelApi,availableProperties:Object.keys(a),dependencyMap:this.dependencyMap,dependencyParseType:"identifier",identifierDepMap:n,alteredAttrMap:this.alteredAttrMap}),d=Object.fromEntries(Object.entries(r).map(([v,x])=>[v,Object.keys(x)])),[h,y,g]=j(o,p,e.params[0],{babelApi:this.babelApi,className:this.className,importMap:f,subViewPropMap:d,templateIdx:i,attributeMap:this.attributeMap});return e.body=h,this.classBodyNode?.body.push(...y),[l,g]}fileAllowed(e){return this.includes.includes("*")?!0:!(!e||this.excludes.some(t=>k(e,t))||!this.includes.some(t=>k(e,t)))}isDLightView(e){let t=e.node;return(t.decorators??[]).find(s=>this.t.isIdentifier(s.expression,{name:"View"}))&&(t.superClass=this.t.identifier("View"),t.decorators=t.decorators?.filter(s=>!this.t.isIdentifier(s.expression,{name:"View"}))),this.t.isIdentifier(t.superClass,{name:"View"})}removeDecorators(e,t){return e?e.filter(r=>!(this.t.isIdentifier(r.expression)&&t.includes(r.expression.name)||this.t.isCallExpression(r.expression)&&this.t.isIdentifier(r.expression.callee)&&t.includes(r.expression.callee.name))):[]}findDecoratorByName(e,t){if(e)return e.find(r=>this.t.isIdentifier(r.expression,{name:t})||this.t.isCallExpression(r.expression)&&this.t.isIdentifier(r.expression.callee,{name:t}))?.expression}addConstructor(){let e=this.classBodyNode.body.find(t=>this.t.isClassMethod(t,{kind:"constructor"}));return e||(e=this.t.classMethod("constructor",this.t.identifier("constructor"),[],this.t.blockStatement([this.t.expressionStatement(this.t.callExpression(this.t.super(),[]))])),this.classBodyNode.body.unshift(e),e)}autoBindMethods(e){this.addConstructor().body.body.push(this.t.expressionStatement(this.t.assignmentExpression("=",this.t.memberExpression(this.t.thisExpression(),e.key),this.t.callExpression(this.t.memberExpression(this.t.memberExpression(this.t.thisExpression(),e.key),this.t.identifier("bind")),[this.t.thisExpression()]))))}handleDerivedProperty(e){if(!this.t.isIdentifier(e.key))return;let t=e.key.name,r=e.value,i=this.classBodyNode.body.indexOf(e),s=this.t.classMethod("get",this.t.identifier(`$f$${t}`),[],this.t.blockStatement([this.t.returnStatement(r)]));this.classBodyNode.body.splice(i+1,0,s),e.value=null}getDependencies(e){let t=e.node;if(!this.t.isIdentifier(t.key))return[];let r=new Set,i=new Set;e.scope.traverse(t,{MemberExpression:l=>{if(!this.t.isIdentifier(l.node.property))return;let a=l.node.property.name;this.isAssignmentExpressionLeft(l)?i.add(a):this.availableProperties.includes(a)&&this.t.isThisExpression(l.node.object)&&!this.isMemberInEscapeFunction(l,this.classDeclarationNode)&&!this.isMemberInManualFunction(l,this.classDeclarationNode)&&!this.isAssignmentExpressionRight(l,this.classDeclarationNode)&&(r.add(a),this.dependencyMap[a]?.forEach(r.add.bind(r)))}}),i.forEach(r.delete.bind(r));let s=t.key.name,o=[...r];return r.size>0&&(this.dependencyMap[s]=o),o}dependencyMapReversed(){let e={};return Object.entries(this.dependencyMap).forEach(([t,r])=>{r.forEach(i=>{e[i]||(e[i]=new Set),e[i].add(t)})}),e}arrowFunctionPropertyToMethod(e){if(!this.t.isArrowFunctionExpression(e.value))return;let t=e.value;if(!this.t.isBlockStatement(t.body))return;let r=this.classBodyNode.body.indexOf(e),i=this.t.classMethod("method",e.key,t.params,t.body);return this.classBodyNode.body.splice(r,1,i),i}isMemberExpressionProperty(e,t){return this.t.isMemberExpression(e)&&!e.computed&&e.property===t}isObjectKey(e,t){return this.t.isObjectProperty(e)&&e.key===t}valueWithArrowFunc(e){e.value||(e.value=this.t.identifier("undefined")),e.value=this.t.arrowFunctionExpression([],e.value)}valueWrapper(e){return this.t.file(this.t.program([this.t.isStatement(e)?e:this.t.expressionStatement(e)]))}isAttrFromFunction(e,t){let r=e.parentPath,i=s=>this.t.isIdentifier(s)?s.name===t:this.t.isAssignmentPattern(s)?i(s.left):this.t.isArrayPattern(s)?s.elements.filter(Boolean).map(o=>i(o)).includes(!0):this.t.isObjectPattern(s)?s.properties.filter(o=>this.t.isObjectProperty(o)&&this.t.isIdentifier(o.key)).map(o=>o.key.name).includes(t):this.t.isRestElement(s)?i(s.argument):!1;for(;r;){let s=r.node;if(this.t.isArrowFunctionExpression(s)||this.t.isFunctionDeclaration(s)){for(let o of s.params)if(i(o))return!0}r=r.parentPath}return!1}isStandAloneIdentifier(e){let t=e.node,r=e.parentPath?.node;if(this.t.isMemberExpression(r)&&r.property===t||this.isAttrFromFunction(e,t.name))return!1;for(;e.parentPath;){if(this.t.isVariableDeclarator(e.parentPath.node)||this.t.isObjectProperty(e.parentPath.node)&&e.parentPath.node.key===e.node&&!e.parentPath.node.computed)return!1;e=e.parentPath}return!0}getIdentifiers(e){if(this.t.isIdentifier(e))return[e.name];let t=new Set;return this.traverse(this.valueWrapper(e),{Identifier:r=>{this.isStandAloneIdentifier(r)&&t.add(r.node.name)}}),[...t]}isAssignmentExpressionLeft(e){let t=e.parentPath?.node;return this.t.isAssignmentExpression(t)&&t.left===e.node||this.t.isUpdateExpression(t)}isAssignmentExpressionRight(e,t){let r=e.node,i=!1,s=e.parentPath;for(;s&&s.node!==t;){if(this.t.isAssignmentExpression(s.node)){let o=s.node.left,l=r.type===o.type,a=r.property.name===o.property.name;i=l&&a}s=s.parentPath}return i}isMemberInEscapeFunction(e,t){let r=!1,i=e.parentPath;for(;i&&i.node!==t;){let s=i.node;if(this.t.isCallExpression(s)&&this.t.isIdentifier(s.callee)&&b.escapeNamings.includes(s.callee.name)){r=!0;break}i=i.parentPath}return r}isMemberInManualFunction(e,t){let r=!1,i=e.parentPath;for(;i&&i.node!==t;){let s=i.node,o=i.parentPath?.node,l=this.t.isFunctionExpression(s)||this.t.isArrowFunctionExpression(s),a=this.t.isCallExpression(o)&&this.t.isIdentifier(o.callee)&&o.callee.name==="manual";if(l&&a){r=!0;break}i=i.parentPath}return r}static uid(e=4){return Math.random().toString(32).slice(2,e+2)}},m=b;M(m,"escapeNamings",["escape","$"]);var S=m;function A(c,e){let{types:t}=c,{files:r="**/*.{js,jsx,ts,tsx}",excludeFiles:i="**/{dist,node_modules,lib}/*.{js,ts}",enableDevTools:s=!1,htmlTags:o=p=>p,alteredAttrMap:l=w,attributeMap:a=D}=e,n=new S(c,t,Array.isArray(r)?r:[r],Array.isArray(i)?i:[i],s,o,a,l);return{visitor:{Program:{enter(p,{filename:d}){return n.programEnterVisitor(p,d)},exit:n.programExitVisitor.bind(n)},ClassDeclaration:{enter:n.classEnter.bind(n),exit:n.classExit.bind(n)},ClassExpression:{enter:n.classEnter.bind(n),exit:n.classExit.bind(n)},ClassMethod:n.classMethodVisitor.bind(n),ClassProperty:n.classPropertyVisitor.bind(n)}}}function ee(c,e){return{plugins:[$,[V.default??V,{legacy:!0}],[A,e]]}}export{ee as default}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "babel-preset-dlight", | ||
"version": "1.0.0-alpha.22", | ||
"version": "1.0.0-alpha.23", | ||
"description": "DLight transpiler babel preset", | ||
@@ -30,6 +30,6 @@ "author": { | ||
"minimatch": "^9.0.3", | ||
"@dlightjs/reactivity-parser": "1.0.0-alpha.4", | ||
"@dlightjs/view-generator": "1.0.0-alpha.20", | ||
"@dlightjs/view-parser": "1.0.0-alpha.1", | ||
"babel-plugin-syntax-typescript-new": "1.0.0" | ||
"@dlightjs/reactivity-parser": "1.0.0-alpha.5", | ||
"@dlightjs/view-parser": "1.0.0-alpha.2", | ||
"babel-plugin-syntax-typescript-new": "1.0.0", | ||
"@dlightjs/view-generator": "1.0.0-alpha.21" | ||
}, | ||
@@ -36,0 +36,0 @@ "tsup": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
220597
236
1
+ Added@dlightjs/reactivity-parser@1.0.0-alpha.5(transitive)
+ Added@dlightjs/view-generator@1.0.0-alpha.21(transitive)
+ Added@dlightjs/view-parser@1.0.0-alpha.2(transitive)
- Removed@dlightjs/reactivity-parser@1.0.0-alpha.4(transitive)
- Removed@dlightjs/view-generator@1.0.0-alpha.20(transitive)
- Removed@dlightjs/view-parser@1.0.0-alpha.1(transitive)