@vtj/coder 0.13.4 → 0.13.6

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.cjs CHANGED
@@ -2,45 +2,45 @@
2
2
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.13.4
5
+ * @version 0.13.6
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const re="0.13.4";/**!
7
+ */const re="0.13.6";/**!
8
8
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
9
9
  * @name @vtj/core
10
10
  * @author CHC chenhuachun1549@dingtalk.com
11
- * @version 0.13.4
11
+ * @version 0.13.6
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
- */const ie=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const T={arrowParens:"always",bracketSpacing:!0,bracketSameLine:!0,endOfLine:"lf",htmlWhitespaceSensitivity:"css",insertPragma:!1,jsxBracketSameLine:!0,jsxSingleQuote:!0,printWidth:80,proseWrap:"preserve",quoteProps:"as-needed",requirePragma:!1,semi:!0,singleQuote:!0,tabWidth:2,trailingComma:"none",useTabs:!1,vueIndentScriptAndStyle:!0};async function B(t,e){return e?t:await D.format(t,{parser:"vue",...T,plugins:[ne,q,U,M]})}async function V(t,e){if(e)return t;try{return(await D.format(t,{parser:"babel-ts",...T,plugins:[q,U]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function N(t,e){return e?t:D.format(t,{parser:"scss",...T,plugins:[M]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function R(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[]){let r=j(t)?t.value.trim().replace(/;$/,""):e?JSON.stringify(t):t;return r=w(r,n),s?H(R(r)):R(r)}function w(t="",e=[]){let s=t;for(const n of e)s=s.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return s}function Q(t){let e=t.trim().replace(/;$/,"");if(e=/^\((\(|async|function)/.test(e)?e.substring(1,e.length-1):e,e.startsWith("{"))return e;if(e.startsWith("async function"))e=e.replace(/^async function/,"async");else if(e.startsWith("function"))e=e.replace(/^function/,"");else{const r=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,i=e.match(r);i&&i[2]&&(i[2].startsWith("{")||(e=e.replace(i[2],`{ return ${i[2]} }`))),e=e.replace("=>","")}return e}function oe(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${d(s)}`)}function z(t={},e=!1){const s=Object.keys(t);return e?s.map(n=>"."+n):s}function ae(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];e+=s+": "+n+";"}return e}function ce(t=[],e=[]){return t.filter(s=>!e.includes(s))}function W(t){return f.base64(JSON.stringify(t))}class le{constructor(e,s){this.dsl=e,this.dependencies=s,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const s=e.split(".");if(s.length===4){const n=s.pop(),r=s.join(".")+".",i=s.pop();if(n&&i){const o=this.dependencies.find(a=>a.library===i)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:r,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let n=e.value;for(const r of s){const i=e.value?.match(r)||[];for(const o of i){const a=this.collectImport(o);if(a){const m=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(m,"g"),"")}}}return n}walk(e){const s=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let i of n)s(i);return}const r=Object.values(n);for(const i of r)j(i)?i.value=this.replaceLibraryPath(i):s(i)};s(e)}getLibraryMember(e=[]){let s=[...e];const n={...this.imports};delete n["uni-h5"],delete n["@dcloudio/uni-h5"],delete n["uni-ui"],delete n["@dcloudio/uni-ui"];for(const r of Object.values(n))s=s.concat(Array.from(r));return f.dedupArray(s)}collectContext(e,s){const n=new Set(s?.id?this.context[s.id]:[]),r=(e.directives||[]).find(a=>a.name==="vFor");let i=new Set(Array.from(n));if(r){const{item:a="item",index:m="index"}=r.iterator||{};i=new Set([a,m,...Array.from(i)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],m=a.length?a:[`scope_${s?.id}`];i=new Set([...m,...Array.from(i)])}this.context[e.id]=i}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!j(e.props.style)&&(this.style[`.${e.name}_${e.id}`]=e.props.style)}collectUrlSchema(e){typeof e.from=="object"&&e.from.type==="UrlSchema"&&(this.urlSchemas[e.name]=e.from)}collectBlockPlugin(e){typeof e.from=="object"&&e.from.type==="Plugin"&&(this.blockPlugins[e.name]=e.from)}walkNodes(e){const s=(n,r)=>{this.collectContext(n,r),this.collectStyle(n),this.collectUrlSchema(n),this.collectBlockPlugin(n),Array.isArray(n.children)&&n.children.forEach(i=>s(i,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>s(n))}}function ue(t={}){return Object.entries(t).map(([e,s])=>{const n=d(s,!1);return`${e}:${n}`})}function pe(t=[]){return t.map(e=>`${e.name}: {
13
+ */const ie=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const T={arrowParens:"always",bracketSpacing:!0,bracketSameLine:!0,endOfLine:"lf",htmlWhitespaceSensitivity:"css",insertPragma:!1,jsxBracketSameLine:!0,jsxSingleQuote:!0,printWidth:80,proseWrap:"preserve",quoteProps:"as-needed",requirePragma:!1,semi:!0,singleQuote:!0,tabWidth:2,trailingComma:"none",useTabs:!1,vueIndentScriptAndStyle:!0};async function B(t,e){return e?t:await D.format(t,{parser:"vue",...T,plugins:[ne,q,U,M]})}async function V(t,e){if(e)return t;try{return(await D.format(t,{parser:"babel-ts",...T,plugins:[q,U]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function N(t,e){return e?t:D.format(t,{parser:"scss",...T,plugins:[M]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function R(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[]){let i=j(t)?t.value.trim().replace(/;$/,""):e?JSON.stringify(t):t;return i=w(i,n),s?H(R(i)):R(i)}function w(t="",e=[]){let s=t;for(const n of e)s=s.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return s}function Q(t){let e=t.trim().replace(/;$/,"");if(e=/^\((\(|async|function)/.test(e)?e.substring(1,e.length-1):e,e.startsWith("{"))return e;if(e.startsWith("async function"))e=e.replace(/^async function/,"async");else if(e.startsWith("function"))e=e.replace(/^function/,"");else{const i=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,r=e.match(i);r&&r[2]&&(r[2].startsWith("{")||(e=e.replace(r[2],`{ return ${r[2]} }`))),e=e.replace("=>","")}return e}function oe(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${d(s)}`)}function z(t={},e=!1){const s=Object.keys(t);return e?s.map(n=>"."+n):s}function ae(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];e+=s+": "+n+";"}return e}function ce(t=[],e=[]){return t.filter(s=>!e.includes(s))}function W(t){return f.base64(JSON.stringify(t))}class le{constructor(e,s){this.dsl=e,this.dependencies=s,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const s=e.split(".");if(s.length===4){const n=s.pop(),i=s.join(".")+".",r=s.pop();if(n&&r){const o=this.dependencies.find(a=>a.library===r)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:i,library:r}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let n=e.value;for(const i of s){const r=e.value?.match(i)||[];for(const o of r){const a=this.collectImport(o);if(a){const m=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(m,"g"),"")}}}return n}walk(e){const s=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let r of n)s(r);return}const i=Object.values(n);for(const r of i)j(r)?r.value=this.replaceLibraryPath(r):s(r)};s(e)}getLibraryMember(e=[]){let s=[...e];const n={...this.imports};delete n["uni-h5"],delete n["@dcloudio/uni-h5"],delete n["uni-ui"],delete n["@dcloudio/uni-ui"];for(const i of Object.values(n))s=s.concat(Array.from(i));return f.dedupArray(s)}collectContext(e,s){const n=new Set(s?.id?this.context[s.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let r=new Set(Array.from(n));if(i){const{item:a="item",index:m="index"}=i.iterator||{};r=new Set([a,m,...Array.from(r)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],m=a.length?a:[`scope_${s?.id}`];r=new Set([...m,...Array.from(r)])}this.context[e.id]=r}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!j(e.props.style)&&(this.style[`.${e.name}_${e.id}`]=e.props.style)}collectUrlSchema(e){typeof e.from=="object"&&e.from.type==="UrlSchema"&&(this.urlSchemas[e.name]=e.from)}collectBlockPlugin(e){typeof e.from=="object"&&e.from.type==="Plugin"&&(this.blockPlugins[e.name]=e.from)}walkNodes(e){const s=(n,i)=>{this.collectContext(n,i),this.collectStyle(n),this.collectUrlSchema(n),this.collectBlockPlugin(n),Array.isArray(n.children)&&n.children.forEach(r=>s(r,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>s(n))}}function ue(t={}){return Object.entries(t).map(([e,s])=>{const n=d(s,!1);return`${e}:${n}`})}function pe(t=[]){return t.map(e=>`${e.name}: {
14
14
  from: '${e.from||e.name}',
15
15
  default: ${d(e.default,!0,!1)}
16
- }`)}function fe(t=[]){const e=s=>s?`[${f.toArray(s).map(i=>i.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(s=>typeof s=="string"?`${s}: {}`:(j(s.default)&&!s.default.value&&(s.default.value="undefined"),`${s.name}: {
16
+ }`)}function fe(t=[]){const e=s=>s?`[${f.toArray(s).map(r=>r.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(s=>typeof s=="string"?`${s}: {}`:(j(s.default)&&!s.default.value&&(s.default.value="undefined"),`${s.name}: {
17
17
  type:${e(s.type)},
18
18
  required: ${d(!!s.required,!0,!1)},
19
19
  default: ${d(s.default,!0,!1)}
20
- }`))}function me(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([s,n])=>{let r=Q(d(n,!1,!1));return r=w(r,e),r.startsWith("async")?`async ${s}${r.replace(/^async/,"")}`:`${s}${r}`})}function he(t=[],e=[]){const s=t.reduce((i,o)=>(o.id&&I(o.source)&&(i[`watcher_${o.id}`]=o.source),i),{}),n=A(s,e),r=t.map(i=>`watcher_${i.id}: {
21
- deep: ${i.deep},
22
- immediate:${i.immediate},
23
- handler${Q(i.handler.value)}
24
- }`);return{computed:n,watches:r}}function de(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const s=I(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args) {
20
+ }`))}function me(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([s,n])=>{let i=Q(d(n,!1,!1));return i=w(i,e),i.startsWith("async")?`async ${s}${i.replace(/^async/,"")}`:`${s}${i}`})}function he(t=[],e=[]){const s=t.reduce((r,o)=>(o.id&&I(o.source)&&(r[`watcher_${o.id}`]=o.source),r),{}),n=A(s,e),i=t.map(r=>r.handler&&r.handler.value?`watcher_${r.id}: {
21
+ deep: ${r.deep},
22
+ immediate:${r.immediate},
23
+ handler${Q(r.handler.value)}
24
+ }`:null).filter(r=>!!r);return{computed:n,watches:i}}function de(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const s=I(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args) {
25
25
  // DataSource: ${W(e)}
26
26
  const mock = this.provider.createMock(${s});
27
27
  return await mock.apply(this, args);
28
28
  }`}else{const s=I(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args) {
29
29
  // DataSource: ${W(e)}
30
30
  return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
31
- }`}})}const ye=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],J=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"];function G(t,e,s=[],n={},r){const i=[];let o={},a=[];const m=[];let u=[];return ve(t).forEach(c=>{const v=[];for(const h of c.children){let{id:y,name:$,invisible:b,from:g}=h;if(b)continue;const C=$e($,e,g);C&&a.push(C),X(g)&&u.push({id:g.id,name:$});const{props:P,events:O,handlers:E}=we(h,y,h.props,h.events,n,s),L=Ce(h.directives,s,m).join(" "),S=h.children?Oe(h.children,s,e,n,h):"";Object.assign(o,E);let x="";typeof S=="string"?x=S:(x=(S?.nodes||[]).join(`
31
+ }`}})}const ye=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],J=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"];function G(t,e,s=[],n={},i){const r=[];let o={},a=[];const m=[];let u=[];return ve(t).forEach(c=>{const v=[];for(const h of c.children){let{id:y,name:$,invisible:b,from:g}=h;if(b)continue;const C=$e($,e,g);C&&a.push(C),X(g)&&u.push({id:g.id,name:$});const{props:P,events:O,handlers:E}=we(h,y,h.props,h.events,n,s),L=Ce(h.directives,s,m).join(" "),S=h.children?Oe(h.children,s,e,n,h):"";Object.assign(o,E);let x="";typeof S=="string"?x=S:(x=(S?.nodes||[]).join(`
32
32
  `),Object.assign(o,S?.methods||{}),a=a.concat(S?.components||[]),u=u.concat(S?.importBlocks||[]));const _=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes(g||e.get($)?.package)?f.kebabCase($):Y(g)||Z(g)?"component":$;v.push(ye.includes(_)?`<${_} ${L} ${P} ${O} />`:`<${_} ${L} ${P} ${O}>${x?`
33
33
  `+x.trim():""}</${_}>`)}const p=Ee(c.slot,v.join(`
34
- `),r?.id);i.push(p)}),{nodes:i,methods:o,directives:ge(m),components:f.dedupArray(a),importBlocks:f.dedupArray(u,"id")}}function ge(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ve(t=[]){const e=new Map;for(const s of t){const n=typeof s.slot=="string"?s.slot:s.slot?.name,r=e.get(n);r?r.children.push(s):e.set(n,{slot:s.slot,children:[s]})}return e}function $e(t,e,s){if(ie.includes(t))return null;const n=e.get(t);if(n&&n.alias){const r=n.parent?`${n.parent}.${n.alias}`:n.alias;return`${t}: ${r}`}return X(s)||n?t:null}function X(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function Y(t){return typeof t=="object"&&t.type==="UrlSchema"}function Z(t){return typeof t=="object"&&t.type==="Plugin"}function be(t,e,s=[]){return t==="style"?j(e)?`:style="${d({...e,value:w(e.value,s)})}"`:"":t==="__class"&&j(e)?`:class="${d({...e,value:w(e.value,s)})}"`:typeof e=="string"?`${t}="${e}"`:j(e)?`:${t}="${d({...e,value:w(e.value,s)})}"`:f.isPlainObject(e)?`:${t}='{${oe(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function je(t,e={},s=[]){if(!!Object.keys(e.style||{}).length){const i=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,i].join(" "):(e.__class=e.class,e.class=i):e.class=i,j(e.style)||delete e.style}const r=t.from;return(Y(r)||Z(r))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([i,o])=>be(i,o,s))}function Se(t,e,s,n,r){const i=z(e.modifiers,!0);return r?`@${t}${i.join("")}="${s}"`:n&&n.length>0?`@${t}${i.join("")}="(...args:any[]) => ${s}"`:`@${t}${i.join("")}="${s}"`}function ke(t,e={},s={}){const n={},r=Array.from(s[t]||new Set([])),i=r.length?`({${r.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,m])=>{const u=m.handler.value.startsWith("this."),l=u?H(m.handler.value):`${f.camelCase(a)}_${t}${i}`;return u||(n[l]=r.length?{type:"JSFunction",value:`{
34
+ `),i?.id);r.push(p)}),{nodes:r,methods:o,directives:ge(m),components:f.dedupArray(a),importBlocks:f.dedupArray(u,"id")}}function ge(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ve(t=[]){const e=new Map;for(const s of t){const n=typeof s.slot=="string"?s.slot:s.slot?.name,i=e.get(n);i?i.children.push(s):e.set(n,{slot:s.slot,children:[s]})}return e}function $e(t,e,s){if(ie.includes(t))return null;const n=e.get(t);if(n&&n.alias){const i=n.parent?`${n.parent}.${n.alias}`:n.alias;return`${t}: ${i}`}return X(s)||n?t:null}function X(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function Y(t){return typeof t=="object"&&t.type==="UrlSchema"}function Z(t){return typeof t=="object"&&t.type==="Plugin"}function be(t,e,s=[]){return t==="style"?j(e)?`:style="${d({...e,value:w(e.value,s)})}"`:"":t==="__class"&&j(e)?`:class="${d({...e,value:w(e.value,s)})}"`:typeof e=="string"?`${t}="${e}"`:j(e)?`:${t}="${d({...e,value:w(e.value,s)})}"`:f.isPlainObject(e)?`:${t}='{${oe(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function je(t,e={},s=[]){if(!!Object.keys(e.style||{}).length){const r=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,r].join(" "):(e.__class=e.class,e.class=r):e.class=r,j(e.style)||delete e.style}const i=t.from;return(Y(i)||Z(i))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([r,o])=>be(r,o,s))}function Se(t,e,s,n,i){const r=z(e.modifiers,!0);return i?`@${t}${r.join("")}="${s}"`:n&&n.length>0?`@${t}${r.join("")}="(...args:any[]) => ${s}"`:`@${t}${r.join("")}="${s}"`}function ke(t,e={},s={}){const n={},i=Array.from(s[t]||new Set([])),r=i.length?`({${i.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,m])=>{const u=m.handler.value.startsWith("this."),l=u?H(m.handler.value):`${f.camelCase(a)}_${t}${r}`;return u||(n[l]=i.length?{type:"JSFunction",value:`{
35
35
  return (${m.handler.value}).apply(this, args);
36
- }`}:m.handler),Se(a,m,l,r,u)}),handlers:n}}function we(t,e,s={},n={},r={},i){const{binders:o,handlers:a}=ke(e,n,r);return{props:je(t,s,i).join(" "),handlers:a,binders:o,events:o.join(" ")}}function Ce(t=[],e=[],s=[]){const n=[],{vIf:r,vElse:i,vElseIf:o,vShow:a,vModels:m,vFor:u,vBind:l,vHtml:c,customDirectives:v}=Pe(t);if(r&&n.push(`v-if="${d(r.value,!0,!0,e)}"`),o&&n.push(`v-else-if="${d(o.value,!0,!0,e)}"`),i&&n.push("v-else"),a&&n.push(`v-show="${d(a.value,!0,!0,e)}"`),l&&n.push(`v-bind="${d(l.value,!0,!0,e)}"`),m.forEach(p=>{const h=z(p.modifiers,!0),y=p.arg?k(p.arg)?`:[${d(p.arg,!0,!0,e)}]`:`:${p.arg}`:"";n.push(`v-model${y}${h}="${d(p.value,!0,!0,e)}"`)}),u){const{item:p,index:h}={item:"item",index:"index",...u.iterator};n.push(`v-for="(${p}, ${h}) in ${d(u.value,!0,!0,e)}"`)}return c&&n.push(`v-html="${d(c.value,!0,!0,e)}"`),v&&v.length&&v.forEach(p=>{if(!p.name)return;let h="",y="";k(p.name)?(y=d(p.name,!0,!0,e),s.push(y)):y=p.name;const $=y?.startsWith("v")?f.kebabCase(y):f.kebabCase("v-"+y);if(h+=$,p.arg&&(k(p.arg)?h+=`:[${d(p.name,!0,!0,e)}]`:h+=`:${p.arg}`),p.modifiers){const b=Object.keys(p.modifiers);b.length&&(h+=b.map(g=>"."+g))}p.value?n.push(`${h}="${d(p.value,!0,!0,e)}"`):n.push(h)}),n}function Pe(t=[]){const e=t.filter(c=>J.includes(c.name)),s=t.filter(c=>!J.includes(c.name)),n=e.find(c=>f.camelCase(c.name)==="vIf"),r=e.find(c=>f.camelCase(c.name)==="vElseIf"),i=e.find(c=>f.camelCase(c.name)==="vElse"),o=e.find(c=>f.camelCase(c.name)==="vFor"),a=e.find(c=>f.camelCase(c.name)==="vShow"),m=e.find(c=>f.camelCase(c.name)==="vBind"),u=e.find(c=>f.camelCase(c.name)==="vHtml"),l=e.filter(c=>f.camelCase(c.name)==="vModel");return{vIf:n,vElseIf:r,vElse:i,vFor:o,vShow:a,vModels:l,vBind:m,vHtml:u,customDirectives:s}}function Oe(t,e,s,n,r){return typeof t=="string"?t:k(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?G(t,s,e,n,r):""}function Ee(t,e,s){if(!t)return e;const n=typeof t=="string"?{name:t,params:[],scope:""}:{params:[],scope:"",...t};return`<template ${`#${n.name}="${n.scope?n.scope:n.params?.length>0?`{${n.params?.join(",")}}`:`scope_${s}`}"`}>
36
+ }`}:m.handler),Se(a,m,l,i,u)}),handlers:n}}function we(t,e,s={},n={},i={},r){const{binders:o,handlers:a}=ke(e,n,i);return{props:je(t,s,r).join(" "),handlers:a,binders:o,events:o.join(" ")}}function Ce(t=[],e=[],s=[]){const n=[],{vIf:i,vElse:r,vElseIf:o,vShow:a,vModels:m,vFor:u,vBind:l,vHtml:c,customDirectives:v}=Pe(t);if(i&&n.push(`v-if="${d(i.value,!0,!0,e)}"`),o&&n.push(`v-else-if="${d(o.value,!0,!0,e)}"`),r&&n.push("v-else"),a&&n.push(`v-show="${d(a.value,!0,!0,e)}"`),l&&n.push(`v-bind="${d(l.value,!0,!0,e)}"`),m.forEach(p=>{const h=z(p.modifiers,!0),y=p.arg?k(p.arg)?`:[${d(p.arg,!0,!0,e)}]`:`:${p.arg}`:"";n.push(`v-model${y}${h}="${d(p.value,!0,!0,e)}"`)}),u){const{item:p,index:h}={item:"item",index:"index",...u.iterator};n.push(`v-for="(${p}, ${h}) in ${d(u.value,!0,!0,e)}"`)}return c&&n.push(`v-html="${d(c.value,!0,!0,e)}"`),v&&v.length&&v.forEach(p=>{if(!p.name)return;let h="",y="";k(p.name)?(y=d(p.name,!0,!0,e),s.push(y)):y=p.name;const $=y?.startsWith("v")?f.kebabCase(y):f.kebabCase("v-"+y);if(h+=$,p.arg&&(k(p.arg)?h+=`:[${d(p.name,!0,!0,e)}]`:h+=`:${p.arg}`),p.modifiers){const b=Object.keys(p.modifiers);b.length&&(h+=b.map(g=>"."+g))}p.value?n.push(`${h}="${d(p.value,!0,!0,e)}"`):n.push(h)}),n}function Pe(t=[]){const e=t.filter(c=>J.includes(c.name)),s=t.filter(c=>!J.includes(c.name)),n=e.find(c=>f.camelCase(c.name)==="vIf"),i=e.find(c=>f.camelCase(c.name)==="vElseIf"),r=e.find(c=>f.camelCase(c.name)==="vElse"),o=e.find(c=>f.camelCase(c.name)==="vFor"),a=e.find(c=>f.camelCase(c.name)==="vShow"),m=e.find(c=>f.camelCase(c.name)==="vBind"),u=e.find(c=>f.camelCase(c.name)==="vHtml"),l=e.filter(c=>f.camelCase(c.name)==="vModel");return{vIf:n,vElseIf:i,vElse:r,vFor:o,vShow:a,vModels:l,vBind:m,vHtml:u,customDirectives:s}}function Oe(t,e,s,n,i){return typeof t=="string"?t:k(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?G(t,s,e,n,i):""}function Ee(t,e,s){if(!t)return e;const n=typeof t=="string"?{name:t,params:[],scope:""}:{params:[],scope:"",...t};return`<template ${`#${n.name}="${n.scope?n.scope:n.params?.length>0?`{${n.params?.join(",")}}`:`scope_${s}`}"`}>
37
37
  ${e}
38
- </template>`}function xe(t,e=[],s=[],n={},r="web"){const i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],o={vue:["defineComponent","reactive"]},a=[];for(const u of e){const l=t.get(u.split(":")[0]);if(l&&l.package){const c=o[l.package]??(o[l.package]=[]),v=l.parent||(l.alias||"").split(".")[0]||l.name;c.push(v),r==="uniapp"&&i.includes(l.package)&&a.push(v)}}for(const[u,l]of Object.entries(n))(o[u]??(o[u]=[])).push(...Array.from(l)),r==="uniapp"&&i.includes(u)&&a.push(...Array.from(l));return{imports:Object.entries(o).filter(([u,l])=>r==="uniapp"?!i.includes(u)&&!!l.length:!!l.length).map(([u,l])=>`import { ${f.dedupArray(l).join(",")}} from '${u}';`).concat(s),uniComponents:a}}function _e(t={}){const e=[];for(const[s,n]of Object.entries(t))e.push(`
38
+ </template>`}function xe(t,e=[],s=[],n={},i="web"){const r=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],o={vue:["defineComponent","reactive"]},a=[];for(const u of e){const l=t.get(u.split(":")[0]);if(l&&l.package){const c=o[l.package]??(o[l.package]=[]),v=l.parent||(l.alias||"").split(".")[0]||l.name;c.push(v),i==="uniapp"&&r.includes(l.package)&&a.push(v)}}for(const[u,l]of Object.entries(n))(o[u]??(o[u]=[])).push(...Array.from(l)),i==="uniapp"&&r.includes(u)&&a.push(...Array.from(l));return{imports:Object.entries(o).filter(([u,l])=>i==="uniapp"?!r.includes(u)&&!!l.length:!!l.length).map(([u,l])=>`import { ${f.dedupArray(l).join(",")}} from '${u}';`).concat(s),uniComponents:a}}function _e(t={}){const e=[];for(const[s,n]of Object.entries(t))e.push(`
39
39
  ${s} {
40
40
  ${ae(n)}
41
41
  }
42
42
  `);return e.join(`
43
- `)}function Ae(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.defineUrlSchemaComponent('${n.url}');`)}),e}function Ie(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.definePluginComponent(${JSON.stringify(n)});`)}),e}function Fe(t,e,s="web"){const{dsl:n}=t,r=Object.keys(n.computed||{}),i=A(n.lifeCycles,r),o=A(n.computed,r),a=he(n.watch,r),m=de(n.dataSources),{methods:u,nodes:l,components:c,importBlocks:v,directives:p}=G(n.nodes||[],e,r,t.context),h=[...o,...a.computed],y=A({...u,...n.methods||{}},r),$=v.map(E=>`import ${E.name} from './${E.id}.vue';`);let{imports:b,uniComponents:g}=xe(e,c,$,t.imports,s);const C=Object.keys({...t.urlSchemas,...t.blockPlugins}),P=Ae(t.urlSchemas),O=Ie(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:ue(n.state).join(","),inject:pe(n.inject).join(","),props:fe(n.props).join(","),emits:me(n.emits).join(","),watch:a.watches.join(","),lifeCycles:i.join(","),computed:h.join(","),methods:[...m,...y].join(","),imports:`
43
+ `)}function Ae(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.defineUrlSchemaComponent('${n.url}');`)}),e}function Ie(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.definePluginComponent(${JSON.stringify(n)});`)}),e}function Fe(t,e,s="web"){const{dsl:n}=t,i=Object.keys(n.computed||{}),r=A(n.lifeCycles,i),o=A(n.computed,i),a=he(n.watch,i),m=de(n.dataSources),{methods:u,nodes:l,components:c,importBlocks:v,directives:p}=G(n.nodes||[],e,i,t.context),h=[...o,...a.computed],y=A({...u,...n.methods||{}},i),$=v.map(E=>`import ${E.name} from './${E.id}.vue';`);let{imports:b,uniComponents:g}=xe(e,c,$,t.imports,s);const C=Object.keys({...t.urlSchemas,...t.blockPlugins}),P=Ae(t.urlSchemas),O=Ie(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:ue(n.state).join(","),inject:pe(n.inject).join(","),props:fe(n.props).join(","),emits:me(n.emits).join(","),watch:a.watches.join(","),lifeCycles:r.join(","),computed:h.join(","),methods:[...m,...y].join(","),imports:`
44
44
  `+b.join(`
45
45
  `),components:ce(c,g).join(","),directives:p.join(","),returns:t.members.join(","),template:l.join(`
46
46
  `),css:n.css||"",style:_e(t.style),urlSchemas:P.join(`
@@ -88,7 +88,7 @@ export default defineComponent({
88
88
  <%= css %>
89
89
  <%= style %>
90
90
  </style>
91
- `,Te=f.template(Ne),Be=f.template(De);async function Le(t,e=new Map,s=[],n="web",r){const i=t,o=typeof i.dsl=="object"&&arguments.length===1?i:{dsl:t,componentMap:e,dependencies:s,platform:n,formatterDisabled:r},{dsl:a,componentMap:m=new Map,dependencies:u=[],platform:l="web",formatterDisabled:c=!1,ts:v=!0,scss:p=!1}=o,h=new le(f.cloneDeep(a),u),y=Fe(h,m,l),$=Te(y),b=Be({template:y.template,css:await N(y.css,c),script:await V($,c),style:await N(y.style,c),scriptLang:v?"ts":"js",styleLang:p?"scss":"css"});return await B(b,c).catch(g=>(g.content=b,Promise.reject(g)))}async function Re(t){const e=`
91
+ `,Te=f.template(Ne),Be=f.template(De);async function Le(t,e=new Map,s=[],n="web",i){const r=t,o=typeof r.dsl=="object"&&arguments.length===1?r:{dsl:t,componentMap:e,dependencies:s,platform:n,formatterDisabled:i},{dsl:a,componentMap:m=new Map,dependencies:u=[],platform:l="web",formatterDisabled:c=!1,ts:v=!0,scss:p=!1}=o,h=new le(f.cloneDeep(a),u),y=Fe(h,m,l),$=Te(y),b=Be({template:y.template,css:await N(y.css,c),script:await V($,c),style:await N(y.style,c),scriptLang:v?"ts":"js",styleLang:p?"scss":"css"});return await B(b,c).catch(g=>(g.content=b,Promise.reject(g)))}async function Re(t){const e=`
92
92
  <template>
93
93
  <div>
94
94
  <h3>源码模式页面</h3>
package/dist/index.mjs CHANGED
@@ -8,15 +8,15 @@ import * as H from "prettier/plugins/estree";
8
8
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
9
9
  * @name @vtj/coder
10
10
  * @author CHC chenhuachun1549@dingtalk.com
11
- * @version 0.13.4
11
+ * @version 0.13.6
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Ue = "0.13.4";
14
+ const Ue = "0.13.6";
15
15
  /**!
16
16
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
17
17
  * @name @vtj/core
18
18
  * @author CHC chenhuachun1549@dingtalk.com
19
- * @version 0.13.4
19
+ * @version 0.13.6
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
22
  const oe = [
@@ -95,8 +95,8 @@ function R(t) {
95
95
  return t.replace(/this\.context\??\./g, "");
96
96
  }
97
97
  function h(t, e = !0, s = !0, n = []) {
98
- let r = j(t) ? t.value.trim().replace(/;$/, "") : e ? JSON.stringify(t) : t;
99
- return r = w(r, n), s ? Q(R(r)) : R(r);
98
+ let i = j(t) ? t.value.trim().replace(/;$/, "") : e ? JSON.stringify(t) : t;
99
+ return i = w(i, n), s ? Q(R(i)) : R(i);
100
100
  }
101
101
  function w(t = "", e = []) {
102
102
  let s = t;
@@ -115,8 +115,8 @@ function G(t) {
115
115
  else if (e.startsWith("function"))
116
116
  e = e.replace(/^function/, "");
117
117
  else {
118
- const r = /^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/, i = e.match(r);
119
- i && i[2] && (i[2].startsWith("{") || (e = e.replace(i[2], `{ return ${i[2]} }`))), e = e.replace("=>", "");
118
+ const i = /^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/, r = e.match(i);
119
+ r && r[2] && (r[2].startsWith("{") || (e = e.replace(r[2], `{ return ${r[2]} }`))), e = e.replace("=>", "");
120
120
  }
121
121
  return e;
122
122
  }
@@ -167,17 +167,17 @@ class pe {
167
167
  collectImport(e) {
168
168
  const s = e.split(".");
169
169
  if (s.length === 4) {
170
- const n = s.pop(), r = s.join(".") + ".", i = s.pop();
171
- if (n && i) {
170
+ const n = s.pop(), i = s.join(".") + ".", r = s.pop();
171
+ if (n && r) {
172
172
  const o = this.dependencies.find(
173
- (c) => c.library === i
173
+ (c) => c.library === r
174
174
  )?.package;
175
175
  o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(n);
176
176
  }
177
177
  return {
178
178
  name: n,
179
- path: r,
180
- library: i
179
+ path: i,
180
+ library: r
181
181
  };
182
182
  }
183
183
  return null;
@@ -186,9 +186,9 @@ class pe {
186
186
  replaceLibraryPath(e) {
187
187
  const { libraryRegex: s } = this;
188
188
  let n = e.value;
189
- for (const r of s) {
190
- const i = e.value?.match(r) || [];
191
- for (const o of i) {
189
+ for (const i of s) {
190
+ const r = e.value?.match(i) || [];
191
+ for (const o of r) {
192
192
  const c = this.collectImport(o);
193
193
  if (c) {
194
194
  const f = c.path.replace(/\$/g, "\\$");
@@ -202,13 +202,13 @@ class pe {
202
202
  const s = (n) => {
203
203
  if (!n || typeof n != "object") return;
204
204
  if (Array.isArray(n)) {
205
- for (let i of n)
206
- s(i);
205
+ for (let r of n)
206
+ s(r);
207
207
  return;
208
208
  }
209
- const r = Object.values(n);
210
- for (const i of r)
211
- j(i) ? i.value = this.replaceLibraryPath(i) : s(i);
209
+ const i = Object.values(n);
210
+ for (const r of i)
211
+ j(r) ? r.value = this.replaceLibraryPath(r) : s(r);
212
212
  };
213
213
  s(e);
214
214
  }
@@ -216,23 +216,23 @@ class pe {
216
216
  let s = [...e];
217
217
  const n = { ...this.imports };
218
218
  delete n["uni-h5"], delete n["@dcloudio/uni-h5"], delete n["uni-ui"], delete n["@dcloudio/uni-ui"];
219
- for (const r of Object.values(n))
220
- s = s.concat(Array.from(r));
219
+ for (const i of Object.values(n))
220
+ s = s.concat(Array.from(i));
221
221
  return C(s);
222
222
  }
223
223
  collectContext(e, s) {
224
- const n = new Set(s?.id ? this.context[s.id] : []), r = (e.directives || []).find((c) => c.name === "vFor");
225
- let i = new Set(Array.from(n));
226
- if (r) {
227
- const { item: c = "item", index: f = "index" } = r.iterator || {};
228
- i = /* @__PURE__ */ new Set([c, f, ...Array.from(i)]);
224
+ const n = new Set(s?.id ? this.context[s.id] : []), i = (e.directives || []).find((c) => c.name === "vFor");
225
+ let r = new Set(Array.from(n));
226
+ if (i) {
227
+ const { item: c = "item", index: f = "index" } = i.iterator || {};
228
+ r = /* @__PURE__ */ new Set([c, f, ...Array.from(r)]);
229
229
  }
230
230
  const o = e.slot;
231
231
  if (o) {
232
232
  const c = typeof o == "string" ? [] : o.params || [], f = c.length ? c : [`scope_${s?.id}`];
233
- i = /* @__PURE__ */ new Set([...f, ...Array.from(i)]);
233
+ r = /* @__PURE__ */ new Set([...f, ...Array.from(r)]);
234
234
  }
235
- this.context[e.id] = i;
235
+ this.context[e.id] = r;
236
236
  }
237
237
  collectStyle(e) {
238
238
  e.id && e.props?.style && Object.keys(e.props.style).length && !j(e.props.style) && (this.style[`.${e.name}_${e.id}`] = e.props.style);
@@ -244,8 +244,8 @@ class pe {
244
244
  typeof e.from == "object" && e.from.type === "Plugin" && (this.blockPlugins[e.name] = e.from);
245
245
  }
246
246
  walkNodes(e) {
247
- const s = (n, r) => {
248
- this.collectContext(n, r), this.collectStyle(n), this.collectUrlSchema(n), this.collectBlockPlugin(n), Array.isArray(n.children) && n.children.forEach((i) => s(i, n));
247
+ const s = (n, i) => {
248
+ this.collectContext(n, i), this.collectStyle(n), this.collectUrlSchema(n), this.collectBlockPlugin(n), Array.isArray(n.children) && n.children.forEach((r) => s(r, n));
249
249
  };
250
250
  Array.isArray(e.nodes) && e.nodes.forEach((n) => s(n));
251
251
  }
@@ -263,7 +263,7 @@ function me(t = []) {
263
263
  }`);
264
264
  }
265
265
  function he(t = []) {
266
- const e = (s) => s ? `[${se(s).map((i) => i.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
266
+ const e = (s) => s ? `[${se(s).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
267
267
  return t.map((s) => typeof s == "string" ? `${s}: {}` : (j(s.default) && !s.default.value && (s.default.value = "undefined"), `${s.name}: {
268
268
  type:${e(s.type)},
269
269
  required: ${h(!!s.required, !0, !1)},
@@ -275,22 +275,22 @@ function de(t = []) {
275
275
  }
276
276
  function A(t = {}, e = []) {
277
277
  return Object.entries(t).map(([s, n]) => {
278
- let r = G(h(n, !1, !1));
279
- return r = w(r, e), r.startsWith("async") ? `async ${s}${r.replace(/^async/, "")}` : `${s}${r}`;
278
+ let i = G(h(n, !1, !1));
279
+ return i = w(i, e), i.startsWith("async") ? `async ${s}${i.replace(/^async/, "")}` : `${s}${i}`;
280
280
  });
281
281
  }
282
282
  function ge(t = [], e = []) {
283
283
  const s = t.reduce(
284
- (i, o) => (o.id && N(o.source) && (i[`watcher_${o.id}`] = o.source), i),
284
+ (r, o) => (o.id && N(o.source) && (r[`watcher_${o.id}`] = o.source), r),
285
285
  {}
286
- ), n = A(s, e), r = t.map((i) => `watcher_${i.id}: {
287
- deep: ${i.deep},
288
- immediate:${i.immediate},
289
- handler${G(i.handler.value)}
290
- }`);
286
+ ), n = A(s, e), i = t.map((r) => r.handler && r.handler.value ? `watcher_${r.id}: {
287
+ deep: ${r.deep},
288
+ immediate:${r.immediate},
289
+ handler${G(r.handler.value)}
290
+ }` : null).filter((r) => !!r);
291
291
  return {
292
292
  computed: n,
293
- watches: r
293
+ watches: i
294
294
  };
295
295
  }
296
296
  function ye(t = {}) {
@@ -336,8 +336,8 @@ const $e = [
336
336
  "vBind",
337
337
  "vHtml"
338
338
  ];
339
- function z(t, e, s = [], n = {}, r) {
340
- const i = [];
339
+ function z(t, e, s = [], n = {}, i) {
340
+ const r = [];
341
341
  let o = {}, c = [];
342
342
  const f = [];
343
343
  let u = [];
@@ -380,10 +380,10 @@ function z(t, e, s = [], n = {}, r) {
380
380
  );
381
381
  }
382
382
  const p = _e(a.slot, y.join(`
383
- `), r?.id);
384
- i.push(p);
383
+ `), i?.id);
384
+ r.push(p);
385
385
  }), {
386
- nodes: i,
386
+ nodes: r,
387
387
  methods: o,
388
388
  directives: ve(f),
389
389
  components: C(c),
@@ -396,8 +396,8 @@ function ve(t) {
396
396
  function be(t = []) {
397
397
  const e = /* @__PURE__ */ new Map();
398
398
  for (const s of t) {
399
- const n = typeof s.slot == "string" ? s.slot : s.slot?.name, r = e.get(n);
400
- r ? r.children.push(s) : e.set(n, { slot: s.slot, children: [s] });
399
+ const n = typeof s.slot == "string" ? s.slot : s.slot?.name, i = e.get(n);
400
+ i ? i.children.push(s) : e.set(n, { slot: s.slot, children: [s] });
401
401
  }
402
402
  return e;
403
403
  }
@@ -405,8 +405,8 @@ function je(t, e, s) {
405
405
  if (oe.includes(t)) return null;
406
406
  const n = e.get(t);
407
407
  if (n && n.alias) {
408
- const r = n.parent ? `${n.parent}.${n.alias}` : n.alias;
409
- return `${t}: ${r}`;
408
+ const i = n.parent ? `${n.parent}.${n.alias}` : n.alias;
409
+ return `${t}: ${i}`;
410
410
  }
411
411
  return Y(s) || n ? t : null;
412
412
  }
@@ -435,38 +435,38 @@ function Se(t, e, s = []) {
435
435
  }
436
436
  function ke(t, e = {}, s = []) {
437
437
  if (!!Object.keys(e.style || {}).length) {
438
- const i = `${t.name}_${t.id}`;
439
- e.class ? typeof e.class == "string" ? e.class = [e.class, i].join(" ") : (e.__class = e.class, e.class = i) : e.class = i, j(e.style) || delete e.style;
438
+ const r = `${t.name}_${t.id}`;
439
+ e.class ? typeof e.class == "string" ? e.class = [e.class, r].join(" ") : (e.__class = e.class, e.class = r) : e.class = r, j(e.style) || delete e.style;
440
440
  }
441
- const r = t.from;
442
- return (Z(r) || K(r)) && (e.is = {
441
+ const i = t.from;
442
+ return (Z(i) || K(i)) && (e.is = {
443
443
  type: "JSExpression",
444
444
  value: t.name
445
- }), Object.entries(e).map(([i, o]) => Se(i, o, s));
445
+ }), Object.entries(e).map(([r, o]) => Se(r, o, s));
446
446
  }
447
- function we(t, e, s, n, r) {
448
- const i = X(e.modifiers, !0);
449
- return r ? `@${t}${i.join("")}="${s}"` : n && n.length > 0 ? `@${t}${i.join("")}="(...args:any[]) => ${s}"` : `@${t}${i.join("")}="${s}"`;
447
+ function we(t, e, s, n, i) {
448
+ const r = X(e.modifiers, !0);
449
+ return i ? `@${t}${r.join("")}="${s}"` : n && n.length > 0 ? `@${t}${r.join("")}="(...args:any[]) => ${s}"` : `@${t}${r.join("")}="${s}"`;
450
450
  }
451
451
  function Ce(t, e = {}, s = {}) {
452
- const n = {}, r = Array.from(s[t] || /* @__PURE__ */ new Set([])), i = r.length ? `({${r.join(", ")}}, args)` : "";
452
+ const n = {}, i = Array.from(s[t] || /* @__PURE__ */ new Set([])), r = i.length ? `({${i.join(", ")}}, args)` : "";
453
453
  return {
454
454
  binders: Object.entries(e).map(([c, f]) => {
455
- const u = f.handler.value.startsWith("this."), l = u ? Q(f.handler.value) : `${b(c)}_${t}${i}`;
456
- return u || (n[l] = r.length ? {
455
+ const u = f.handler.value.startsWith("this."), l = u ? Q(f.handler.value) : `${b(c)}_${t}${r}`;
456
+ return u || (n[l] = i.length ? {
457
457
  type: "JSFunction",
458
458
  value: `{
459
459
  return (${f.handler.value}).apply(this, args);
460
460
  }`
461
- } : f.handler), we(c, f, l, r, u);
461
+ } : f.handler), we(c, f, l, i, u);
462
462
  }),
463
463
  handlers: n
464
464
  };
465
465
  }
466
- function Ee(t, e, s = {}, n = {}, r = {}, i) {
467
- const { binders: o, handlers: c } = Ce(e, n, r);
466
+ function Ee(t, e, s = {}, n = {}, i = {}, r) {
467
+ const { binders: o, handlers: c } = Ce(e, n, i);
468
468
  return {
469
- props: ke(t, s, i).join(" "),
469
+ props: ke(t, s, r).join(" "),
470
470
  handlers: c,
471
471
  binders: o,
472
472
  events: o.join(" ")
@@ -474,8 +474,8 @@ function Ee(t, e, s = {}, n = {}, r = {}, i) {
474
474
  }
475
475
  function Oe(t = [], e = [], s = []) {
476
476
  const n = [], {
477
- vIf: r,
478
- vElse: i,
477
+ vIf: i,
478
+ vElse: r,
479
479
  vElseIf: o,
480
480
  vShow: c,
481
481
  vModels: f,
@@ -484,9 +484,9 @@ function Oe(t = [], e = [], s = []) {
484
484
  vHtml: a,
485
485
  customDirectives: y
486
486
  } = Pe(t);
487
- if (r && n.push(`v-if="${h(r.value, !0, !0, e)}"`), o && n.push(
487
+ if (i && n.push(`v-if="${h(i.value, !0, !0, e)}"`), o && n.push(
488
488
  `v-else-if="${h(o.value, !0, !0, e)}"`
489
- ), i && n.push("v-else"), c && n.push(
489
+ ), r && n.push("v-else"), c && n.push(
490
490
  `v-show="${h(c.value, !0, !0, e)}"`
491
491
  ), l && n.push(
492
492
  `v-bind="${h(l.value, !0, !0, e)}"`
@@ -524,9 +524,9 @@ function Pe(t = []) {
524
524
  (a) => !J.includes(a.name)
525
525
  ), n = e.find(
526
526
  (a) => b(a.name) === "vIf"
527
- ), r = e.find(
528
- (a) => b(a.name) === "vElseIf"
529
527
  ), i = e.find(
528
+ (a) => b(a.name) === "vElseIf"
529
+ ), r = e.find(
530
530
  (a) => b(a.name) === "vElse"
531
531
  ), o = e.find(
532
532
  (a) => b(a.name) === "vFor"
@@ -541,8 +541,8 @@ function Pe(t = []) {
541
541
  );
542
542
  return {
543
543
  vIf: n,
544
- vElseIf: r,
545
- vElse: i,
544
+ vElseIf: i,
545
+ vElse: r,
546
546
  vFor: o,
547
547
  vShow: c,
548
548
  vModels: l,
@@ -551,8 +551,8 @@ function Pe(t = []) {
551
551
  customDirectives: s
552
552
  };
553
553
  }
554
- function xe(t, e, s, n, r) {
555
- return typeof t == "string" ? t : k(t) ? `{{ ${h(t, !1, !0, e)} }}` : Array.isArray(t) ? z(t, s, e, n, r) : "";
554
+ function xe(t, e, s, n, i) {
555
+ return typeof t == "string" ? t : k(t) ? `{{ ${h(t, !1, !0, e)} }}` : Array.isArray(t) ? z(t, s, e, n, i) : "";
556
556
  }
557
557
  function _e(t, e, s) {
558
558
  if (!t) return e;
@@ -561,8 +561,8 @@ function _e(t, e, s) {
561
561
  ${e}
562
562
  </template>`;
563
563
  }
564
- function Ie(t, e = [], s = [], n = {}, r = "web") {
565
- const i = [
564
+ function Ie(t, e = [], s = [], n = {}, i = "web") {
565
+ const r = [
566
566
  "@dcloudio/uni-h5",
567
567
  "uni-h5",
568
568
  "@dcloudio/uni-ui",
@@ -574,13 +574,13 @@ function Ie(t, e = [], s = [], n = {}, r = "web") {
574
574
  const l = t.get(u.split(":")[0]);
575
575
  if (l && l.package) {
576
576
  const a = o[l.package] ?? (o[l.package] = []), y = l.parent || (l.alias || "").split(".")[0] || l.name;
577
- a.push(y), r === "uniapp" && i.includes(l.package) && c.push(y);
577
+ a.push(y), i === "uniapp" && r.includes(l.package) && c.push(y);
578
578
  }
579
579
  }
580
580
  for (const [u, l] of Object.entries(n))
581
- (o[u] ?? (o[u] = [])).push(...Array.from(l)), r === "uniapp" && i.includes(u) && c.push(...Array.from(l));
581
+ (o[u] ?? (o[u] = [])).push(...Array.from(l)), i === "uniapp" && r.includes(u) && c.push(...Array.from(l));
582
582
  return {
583
- imports: Object.entries(o).filter(([u, l]) => r === "uniapp" ? !i.includes(u) && !!l.length : !!l.length).map(([u, l]) => `import { ${C(l).join(
583
+ imports: Object.entries(o).filter(([u, l]) => i === "uniapp" ? !r.includes(u) && !!l.length : !!l.length).map(([u, l]) => `import { ${C(l).join(
584
584
  ","
585
585
  )}} from '${u}';`).concat(s),
586
586
  uniComponents: c
@@ -614,17 +614,17 @@ function Fe(t = {}) {
614
614
  }), e;
615
615
  }
616
616
  function Be(t, e, s = "web") {
617
- const { dsl: n } = t, r = Object.keys(n.computed || {}), i = A(n.lifeCycles, r), o = A(n.computed, r), c = ge(n.watch, r), f = ye(n.dataSources), { methods: u, nodes: l, components: a, importBlocks: y, directives: p } = z(
617
+ const { dsl: n } = t, i = Object.keys(n.computed || {}), r = A(n.lifeCycles, i), o = A(n.computed, i), c = ge(n.watch, i), f = ye(n.dataSources), { methods: u, nodes: l, components: a, importBlocks: y, directives: p } = z(
618
618
  n.nodes || [],
619
619
  e,
620
- r,
620
+ i,
621
621
  t.context
622
622
  ), m = [...o, ...c.computed], d = A(
623
623
  {
624
624
  ...u,
625
625
  ...n.methods || {}
626
626
  },
627
- r
627
+ i
628
628
  ), $ = y.map((x) => `import ${x.name} from './${x.id}.vue';`);
629
629
  let { imports: v, uniComponents: g } = Ie(
630
630
  e,
@@ -646,7 +646,7 @@ function Be(t, e, s = "web") {
646
646
  props: he(n.props).join(","),
647
647
  emits: de(n.emits).join(","),
648
648
  watch: c.watches.join(","),
649
- lifeCycles: i.join(","),
649
+ lifeCycles: r.join(","),
650
650
  computed: m.join(","),
651
651
  methods: [...f, ...d].join(","),
652
652
  imports: `
@@ -712,13 +712,13 @@ export default defineComponent({
712
712
  <%= style %>
713
713
  </style>
714
714
  `, Le = U(De), Re = U(Te);
715
- async function Me(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", r) {
716
- const i = t, o = typeof i.dsl == "object" && arguments.length === 1 ? i : {
715
+ async function Me(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", i) {
716
+ const r = t, o = typeof r.dsl == "object" && arguments.length === 1 ? r : {
717
717
  dsl: t,
718
718
  componentMap: e,
719
719
  dependencies: s,
720
720
  platform: n,
721
- formatterDisabled: r
721
+ formatterDisabled: i
722
722
  }, {
723
723
  dsl: c,
724
724
  componentMap: f = /* @__PURE__ */ new Map(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.13.4",
4
+ "version": "0.13.6",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "prettier": "~3.6.0",
25
25
  "@vtj/base": "~0.12.2",
26
- "@vtj/core": "~0.13.4"
26
+ "@vtj/core": "~0.13.6"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@vtj/cli": "~0.12.10"
@@ -1,5 +1,5 @@
1
1
  import { BlockWatch } from '@vtj/core';
2
2
  export declare function parseWatch(watch?: BlockWatch[], computedKeys?: string[]): {
3
3
  computed: string[];
4
- watches: string[];
4
+ watches: (string | null)[];
5
5
  };
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2025, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.13.3
5
+ * @version 0.13.5
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.13.3";
8
+ export declare const version = "0.13.5";