@vtj/coder 0.10.1-alpha.7 → 0.10.2

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
@@ -1,49 +1,49 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@vtj/base"),N=require("prettier/standalone"),Z=require("prettier/plugins/html"),K=require("prettier/plugins/babel"),ee=require("prettier/plugins/postcss"),te=require("prettier/plugins/estree");function A(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ne=A(Z),L=A(K),D=A(ee),U=A(te);/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@vtj/base"),T=require("prettier/standalone"),Z=require("prettier/plugins/html"),K=require("prettier/plugins/babel"),ee=require("prettier/plugins/postcss"),te=require("prettier/plugins/estree");function F(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ne=F(Z),D=F(K),L=F(ee),U=F(te);/**!
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.10.1-alpha.7
5
+ * @version 0.10.2
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const se="0.10.1-alpha.7";/**!
7
+ */const se="0.10.2";/**!
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.10.1-alpha.7
11
+ * @version 0.10.2
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
- */const re=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const B={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 T(t,e){return e?t:await N.format(t,{parser:"vue",...B,plugins:[ne,L,U,D]})}async function M(t,e){return e?t:await N.format(t,{parser:"babel-ts",...B,plugins:[L,U]})}async function I(t,e){return e?t:N.format(t,{parser:"scss",...B,plugins:[D]})}function j(t){return t&&t.type==="JSExpression"}function _(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function S(t){return j(t)||_(t)}function V(t){return t.replace(new RegExp("this.","g"),"")}function J(t){return t.replace(/this\.context\??\./g,"")}function m(t,e=!0,n=!0,s=[]){let r=S(t)?t.value:e?JSON.stringify(t):t;return r=E(r,s),n?V(J(r)):J(r)}function E(t,e=[]){let n=t;for(const s of e)n=n.replace(new RegExp(`this.${s}.value`,"g"),`this.${s}`);return n}function H(t){let e=t.trim();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 ie(t={}){return Object.entries(t).map(([e,n])=>`"${e}": ${m(n)}`)}function Q(t={},e=!1){const n=Object.keys(t);return e?n.map(s=>"."+s):n}function oe(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var s=t[n];e+=n+": "+s+";"}return e}function ce(t=[],e=[]){return t.filter(n=>!e.includes(n))}class ae{constructor(e,n){this.dsl=e,this.dependencies=n,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 n=e.split(".");if(n.length===4){const s=n.pop(),r=n.join(".")+".",i=n.pop();if(s&&i){const c=this.dependencies.find(a=>a.library===i)?.package;c&&(this.imports[c]||(this.imports[c]=new Set)).add(s)}return{name:s,path:r,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let s=e.value;for(const r of n){const i=e.value?.match(r)||[];for(const c of i){const a=this.collectImport(c);if(a){const p=a.path.replace(/\$/g,"\\$");s=s.replace(new RegExp(p,"g"),"")}}}return s}walk(e){const n=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){for(let i of s)n(i);return}const r=Object.values(s);for(const i of r)S(i)?i.value=this.replaceLibraryPath(i):n(i)};n(e)}getLibraryMember(e=[]){let n=[...e];const s={...this.imports};delete s["uni-h5"],delete s["@dcloudio/uni-h5"],delete s["uni-ui"],delete s["@dcloudio/uni-ui"];for(const r of Object.values(s))n=n.concat(Array.from(r));return f.dedupArray(n)}collectContext(e,n){const s=new Set(n?.id?this.context[n.id]:[]),r=(e.directives||[]).find(a=>a.name==="vFor");let i=new Set(Array.from(s));if(r){const{item:a="item",index:p="index"}=r.iterator||{};i=new Set([a,p,...Array.from(i)])}const c=e.slot;if(c){const a=typeof c=="string"?[]:c.params||[],p=a.length?a:[`scope_${n?.id}`];i=new Set([...p,...Array.from(i)])}this.context[e.id]=i}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&(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 n=(s,r)=>{this.collectContext(s,r),this.collectStyle(s),this.collectUrlSchema(s),this.collectBlockPlugin(s),Array.isArray(s.children)&&s.children.forEach(i=>n(i,s))};Array.isArray(e.nodes)&&e.nodes.forEach(s=>n(s))}}function ue(t={}){return Object.entries(t).map(([e,n])=>{const s=m(n,!1);return`${e}:${s}`})}function le(t=[]){return t.map(e=>`${e.name}: {
13
+ */const re=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const B={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 R(t,e){return e?t:await T.format(t,{parser:"vue",...B,plugins:[ne,D,U,L]})}async function M(t,e){return e?t:await T.format(t,{parser:"babel-ts",...B,plugins:[D,U]})}async function I(t,e){return e?t:T.format(t,{parser:"scss",...B,plugins:[L]})}function j(t){return t&&t.type==="JSExpression"}function E(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function S(t){return j(t)||E(t)}function V(t){return t.replace(new RegExp("this.","g"),"")}function J(t){return t.replace(/this\.context\??\./g,"")}function m(t,e=!0,n=!0,s=[]){let r=S(t)?t.value:e?JSON.stringify(t):t;return r=A(r,s),n?V(J(r)):J(r)}function A(t,e=[]){let n=t;for(const s of e)n=n.replace(new RegExp(`this.${s}.value`,"g"),`this.${s}`);return n}function H(t){let e=t.trim();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 ie(t={}){return Object.entries(t).map(([e,n])=>`"${e}": ${m(n)}`)}function Q(t={},e=!1){const n=Object.keys(t);return e?n.map(s=>"."+s):n}function oe(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var s=t[n];e+=n+": "+s+";"}return e}function ce(t=[],e=[]){return t.filter(n=>!e.includes(n))}class ae{constructor(e,n){this.dsl=e,this.dependencies=n,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 n=e.split(".");if(n.length===4){const s=n.pop(),r=n.join(".")+".",i=n.pop();if(s&&i){const c=this.dependencies.find(a=>a.library===i)?.package;c&&(this.imports[c]||(this.imports[c]=new Set)).add(s)}return{name:s,path:r,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let s=e.value;for(const r of n){const i=e.value?.match(r)||[];for(const c of i){const a=this.collectImport(c);if(a){const p=a.path.replace(/\$/g,"\\$");s=s.replace(new RegExp(p,"g"),"")}}}return s}walk(e){const n=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){for(let i of s)n(i);return}const r=Object.values(s);for(const i of r)S(i)?i.value=this.replaceLibraryPath(i):n(i)};n(e)}getLibraryMember(e=[]){let n=[...e];const s={...this.imports};delete s["uni-h5"],delete s["@dcloudio/uni-h5"],delete s["uni-ui"],delete s["@dcloudio/uni-ui"];for(const r of Object.values(s))n=n.concat(Array.from(r));return f.dedupArray(n)}collectContext(e,n){const s=new Set(n?.id?this.context[n.id]:[]),r=(e.directives||[]).find(a=>a.name==="vFor");let i=new Set(Array.from(s));if(r){const{item:a="item",index:p="index"}=r.iterator||{};i=new Set([a,p,...Array.from(i)])}const c=e.slot;if(c){const a=typeof c=="string"?[]:c.params||[],p=a.length?a:[`scope_${n?.id}`];i=new Set([...p,...Array.from(i)])}this.context[e.id]=i}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&(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 n=(s,r)=>{this.collectContext(s,r),this.collectStyle(s),this.collectUrlSchema(s),this.collectBlockPlugin(s),Array.isArray(s.children)&&s.children.forEach(i=>n(i,s))};Array.isArray(e.nodes)&&e.nodes.forEach(s=>n(s))}}function ue(t={}){return Object.entries(t).map(([e,n])=>{const s=m(n,!1);return`${e}:${s}`})}function le(t=[]){return t.map(e=>`${e.name}: {
14
14
  from: '${e.from||e.name}',
15
15
  default: ${m(e.default,!0,!1)}
16
16
  }`)}function pe(t=[]){const e=n=>n?`[${f.toArray(n).map(i=>i.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(n=>typeof n=="string"?`${n}: {}`:(S(n.default)&&!n.default.value&&(n.default.value="undefined"),`${n.name}: {
17
17
  type:${e(n.type)},
18
18
  required: ${m(!!n.required,!0,!1)},
19
19
  default: ${m(n.default,!0,!1)}
20
- }`))}function fe(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function x(t={},e=[]){return Object.entries(t).map(([n,s])=>{let r=H(m(s,!1,!1));return r=E(r,e),r.startsWith("async")?`async ${n}${r.replace(/^async/,"")}`:`${n}${r}`})}function me(t=[],e=[]){const n=t.reduce((i,c)=>(c.id&&_(c.source)&&(i[`watcher_${c.id}`]=c.source),i),{}),s=x(n,e),r=t.map(i=>`watcher_${i.id}: {
20
+ }`))}function fe(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function x(t={},e=[]){return Object.entries(t).map(([n,s])=>{let r=H(m(s,!1,!1));return r=A(r,e),r.startsWith("async")?`async ${n}${r.replace(/^async/,"")}`:`${n}${r}`})}function me(t=[],e=[]){const n=t.reduce((i,c)=>(c.id&&E(c.source)&&(i[`watcher_${c.id}`]=c.source),i),{}),s=x(n,e),r=t.map(i=>`watcher_${i.id}: {
21
21
  deep: ${i.deep},
22
22
  immediate:${i.immediate},
23
23
  handler${H(i.handler.value)}
24
- }`);return{computed:s,watches:r}}function he(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const n=_(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args:any[]) {
24
+ }`);return{computed:s,watches:r}}function he(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const n=E(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args:any[]) {
25
25
  const mock = this.provider.createMock(${n})
26
26
  return await mock.apply(this, args);
27
- }`}else{const n=_(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args:any[]) {
27
+ }`}else{const n=E(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args:any[]) {
28
28
  return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
29
- }`}})}const q=["vIf","vShow","vModel","vFor","vBind","vHtml"];function z(t,e,n=[],s={},r){const i=[];let c={},a=[];const p=[];let o=[];return ye(t).forEach(u=>{const h=[];for(const y of u.children){let{id:v,name:g,invisible:F,from:$}=y;if(F)continue;const k=ge(g,e,$);k&&a.push(k),G($)&&o.push({id:$.id,name:g});const{props:w,events:C,handlers:P}=Se(y,v,y.props,y.events,s,n),R=ke(y.directives,n,p).join(" "),b=y.children?Ce(y.children,n,e,s,y):"";Object.assign(c,P);let O="";typeof b=="string"?O=b:(O=(b?.nodes||[]).join(`
30
- `),Object.assign(c,b?.methods||{}),a=a.concat(b?.components||[]),o=o.concat(b?.importBlocks||[]));const W=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes($)?f.kebabCase(g):X($)||Y($)?"component":g;h.push(g==="img"?`<${g} ${R} ${w} ${C} />`:`<${W} ${R} ${w} ${C}>${O?`
31
- `+O.trim():""}</${W}>`)}const d=Pe(u.slot,h.join(`
32
- `),r?.id);i.push(d)}),{nodes:i,methods:c,directives:de(p),components:f.dedupArray(a),importBlocks:f.dedupArray(o,"id")}}function de(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ye(t=[]){const e=new Map;for(const n of t){const s=typeof n.slot=="string"?n.slot:n.slot?.name,r=e.get(s);r?r.children.push(n):e.set(s,{slot:n.slot,children:[n]})}return e}function ge(t,e,n){if(re.includes(t))return null;const s=e.get(t);if(s&&s.alias){const r=s.parent?`${s.parent}.${s.alias}`:s.alias;return`${t}: ${r}`}return G(n)||s?t:null}function G(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function X(t){return typeof t=="object"&&t.type==="UrlSchema"}function Y(t){return typeof t=="object"&&t.type==="Plugin"}function $e(t,e,n=[]){return t==="style"?"":t==="__class"&&S(e)?`:class="${m({...e,value:E(e.value,n)})}"`:typeof e=="string"?`${t}="${e}"`:S(e)?`:${t}="${m({...e,value:E(e.value,n)})}"`:f.isPlainObject(e)?`:${t}='{${ie(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function ve(t,e={},n=[]){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,delete e.style)}const r=t.from;return(X(r)||Y(r))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([i,c])=>$e(i,c,n))}function be(t,e,n,s,r){const i=Q(e.modifiers,!0);return r?`@${t}${i.join("")}="${n}"`:s&&s.length>0?`@${t}${i.join("")}="(...args:any[]) => ${n}"`:`@${t}${i.join("")}="${n}"`}function je(t,e={},n={}){const s={},r=Array.from(n[t]||new Set([])),i=r.length?`({${r.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,p])=>{const o=p.handler.value.startsWith("this."),l=o?V(p.handler.value):`${f.camelCase(a)}_${t}${i}`;return o||(s[l]=r.length?{type:"JSFunction",value:`{
29
+ }`}})}const de=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],q=["vIf","vShow","vModel","vFor","vBind","vHtml"];function z(t,e,n=[],s={},r){const i=[];let c={},a=[];const p=[];let o=[];return ge(t).forEach(u=>{const h=[];for(const y of u.children){let{id:v,name:$,invisible:N,from:g}=y;if(N)continue;const k=$e($,e,g);k&&a.push(k),G(g)&&o.push({id:g.id,name:$});const{props:w,events:C,handlers:P}=ke(y,v,y.props,y.events,s,n),W=we(y.directives,n,p).join(" "),b=y.children?Pe(y.children,n,e,s,y):"";Object.assign(c,P);let O="";typeof b=="string"?O=b:(O=(b?.nodes||[]).join(`
30
+ `),Object.assign(c,b?.methods||{}),a=a.concat(b?.components||[]),o=o.concat(b?.importBlocks||[]));const _=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes(g)?f.kebabCase($):X(g)||Y(g)?"component":$;h.push(de.includes(_)?`<${_} ${W} ${w} ${C} />`:`<${_} ${W} ${w} ${C}>${O?`
31
+ `+O.trim():""}</${_}>`)}const d=Oe(u.slot,h.join(`
32
+ `),r?.id);i.push(d)}),{nodes:i,methods:c,directives:ye(p),components:f.dedupArray(a),importBlocks:f.dedupArray(o,"id")}}function ye(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ge(t=[]){const e=new Map;for(const n of t){const s=typeof n.slot=="string"?n.slot:n.slot?.name,r=e.get(s);r?r.children.push(n):e.set(s,{slot:n.slot,children:[n]})}return e}function $e(t,e,n){if(re.includes(t))return null;const s=e.get(t);if(s&&s.alias){const r=s.parent?`${s.parent}.${s.alias}`:s.alias;return`${t}: ${r}`}return G(n)||s?t:null}function G(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function X(t){return typeof t=="object"&&t.type==="UrlSchema"}function Y(t){return typeof t=="object"&&t.type==="Plugin"}function ve(t,e,n=[]){return t==="style"?"":t==="__class"&&S(e)?`:class="${m({...e,value:A(e.value,n)})}"`:typeof e=="string"?`${t}="${e}"`:S(e)?`:${t}="${m({...e,value:A(e.value,n)})}"`:f.isPlainObject(e)?`:${t}='{${ie(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function be(t,e={},n=[]){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,delete e.style)}const r=t.from;return(X(r)||Y(r))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([i,c])=>ve(i,c,n))}function je(t,e,n,s,r){const i=Q(e.modifiers,!0);return r?`@${t}${i.join("")}="${n}"`:s&&s.length>0?`@${t}${i.join("")}="(...args:any[]) => ${n}"`:`@${t}${i.join("")}="${n}"`}function Se(t,e={},n={}){const s={},r=Array.from(n[t]||new Set([])),i=r.length?`({${r.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,p])=>{const o=p.handler.value.startsWith("this."),l=o?V(p.handler.value):`${f.camelCase(a)}_${t}${i}`;return o||(s[l]=r.length?{type:"JSFunction",value:`{
33
33
  return (${p.handler.value}).apply(this, args);
34
- }`}:p.handler),be(a,p,l,r,o)}),handlers:s}}function Se(t,e,n={},s={},r={},i){const{binders:c,handlers:a}=je(e,s,r);return{props:ve(t,n,i).join(" "),handlers:a,binders:c,events:c.join(" ")}}function ke(t=[],e=[],n=[]){const s=[],{vIf:r,vShow:i,vModels:c,vFor:a,vBind:p,vHtml:o,customDirectives:l}=we(t);if(r&&s.push(`v-if="${m(r.value,!0,!0,e)}"`),i&&s.push(`v-show="${m(i.value,!0,!0,e)}"`),p&&s.push(`v-bind="${m(p.value,!0,!0,e)}"`),c.forEach(u=>{const h=Q(u.modifiers,!0),d=u.arg?j(u.arg)?`:[${m(u.arg,!0,!0,e)}]`:`:${u.arg}`:"";s.push(`v-model${d}${h}="${m(u.value,!0,!0,e)}"`)}),a){const{item:u,index:h}={item:"item",index:"index",...a.iterator};s.push(`v-for="(${u}, ${h}) in ${m(a.value,!0,!0,e)}"`)}return o&&s.push(`v-html="${m(o.value,!0,!0,e)}"`),l&&l.length&&l.forEach(u=>{if(!u.name)return;let h="",d="";j(u.name)?(d=m(u.name,!0,!0,e),n.push(d)):d=u.name;const y=d?.startsWith("v")?f.kebabCase(d):f.kebabCase("v-"+d);if(h+=y,u.arg&&(j(u.arg)?h+=`:[${m(u.name,!0,!0,e)}]`:h+=`:${u.arg}`),u.modifiers){const v=Object.keys(u.modifiers);v.length&&(h+=v.map(g=>"."+g))}u.value?s.push(`${h}="${m(u.value,!0,!0,e)}"`):s.push(h)}),s}function we(t=[]){const e=t.filter(o=>q.includes(o.name)),n=t.filter(o=>!q.includes(o.name)),s=e.find(o=>f.camelCase(o.name)==="vIf"),r=e.find(o=>f.camelCase(o.name)==="vFor"),i=e.find(o=>f.camelCase(o.name)==="vShow"),c=e.find(o=>f.camelCase(o.name)==="vBind"),a=e.find(o=>f.camelCase(o.name)==="vHtml"),p=e.filter(o=>f.camelCase(o.name)==="vModel");return{vIf:s,vFor:r,vShow:i,vModels:p,vBind:c,vHtml:a,customDirectives:n}}function Ce(t,e,n,s,r){return typeof t=="string"?t:j(t)?`{{ ${m(t,!1,!0,e)} }}`:Array.isArray(t)?z(t,n,e,s,r):""}function Pe(t,e,n){if(!t)return e;const s=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${s.name}="${s.params?.length>0?`{${s.params?.join(",")}}`:`scope_${n}`}"`}>
34
+ }`}:p.handler),je(a,p,l,r,o)}),handlers:s}}function ke(t,e,n={},s={},r={},i){const{binders:c,handlers:a}=Se(e,s,r);return{props:be(t,n,i).join(" "),handlers:a,binders:c,events:c.join(" ")}}function we(t=[],e=[],n=[]){const s=[],{vIf:r,vShow:i,vModels:c,vFor:a,vBind:p,vHtml:o,customDirectives:l}=Ce(t);if(r&&s.push(`v-if="${m(r.value,!0,!0,e)}"`),i&&s.push(`v-show="${m(i.value,!0,!0,e)}"`),p&&s.push(`v-bind="${m(p.value,!0,!0,e)}"`),c.forEach(u=>{const h=Q(u.modifiers,!0),d=u.arg?j(u.arg)?`:[${m(u.arg,!0,!0,e)}]`:`:${u.arg}`:"";s.push(`v-model${d}${h}="${m(u.value,!0,!0,e)}"`)}),a){const{item:u,index:h}={item:"item",index:"index",...a.iterator};s.push(`v-for="(${u}, ${h}) in ${m(a.value,!0,!0,e)}"`)}return o&&s.push(`v-html="${m(o.value,!0,!0,e)}"`),l&&l.length&&l.forEach(u=>{if(!u.name)return;let h="",d="";j(u.name)?(d=m(u.name,!0,!0,e),n.push(d)):d=u.name;const y=d?.startsWith("v")?f.kebabCase(d):f.kebabCase("v-"+d);if(h+=y,u.arg&&(j(u.arg)?h+=`:[${m(u.name,!0,!0,e)}]`:h+=`:${u.arg}`),u.modifiers){const v=Object.keys(u.modifiers);v.length&&(h+=v.map($=>"."+$))}u.value?s.push(`${h}="${m(u.value,!0,!0,e)}"`):s.push(h)}),s}function Ce(t=[]){const e=t.filter(o=>q.includes(o.name)),n=t.filter(o=>!q.includes(o.name)),s=e.find(o=>f.camelCase(o.name)==="vIf"),r=e.find(o=>f.camelCase(o.name)==="vFor"),i=e.find(o=>f.camelCase(o.name)==="vShow"),c=e.find(o=>f.camelCase(o.name)==="vBind"),a=e.find(o=>f.camelCase(o.name)==="vHtml"),p=e.filter(o=>f.camelCase(o.name)==="vModel");return{vIf:s,vFor:r,vShow:i,vModels:p,vBind:c,vHtml:a,customDirectives:n}}function Pe(t,e,n,s,r){return typeof t=="string"?t:j(t)?`{{ ${m(t,!1,!0,e)} }}`:Array.isArray(t)?z(t,n,e,s,r):""}function Oe(t,e,n){if(!t)return e;const s=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${s.name}="${s.params?.length>0?`{${s.params?.join(",")}}`:`scope_${n}`}"`}>
35
35
  ${e}
36
- </template>`}function Oe(t,e=[],n=[],s={},r="web"){const i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],c={vue:["defineComponent","reactive"]},a=[];for(const o of e){const l=t.get(o.split(":")[0]);if(l&&l.package){const u=c[l.package]??(c[l.package]=[]),h=l.parent||(l.alias||"").split(".")[0]||l.name;u.push(h),r==="uniapp"&&i.includes(l.package)&&a.push(h)}}for(const[o,l]of Object.entries(s))(c[o]??(c[o]=[])).push(...Array.from(l)),r==="uniapp"&&i.includes(o)&&a.push(...Array.from(l));return{imports:Object.entries(c).filter(([o,l])=>r==="uniapp"?!i.includes(o)&&!!l.length:!!l.length).map(([o,l])=>`import { ${f.dedupArray(l).join(",")}} from '${o}';`).concat(n),uniComponents:a}}function xe(t={}){const e=[];for(const[n,s]of Object.entries(t))e.push(`
36
+ </template>`}function _e(t,e=[],n=[],s={},r="web"){const i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],c={vue:["defineComponent","reactive"]},a=[];for(const o of e){const l=t.get(o.split(":")[0]);if(l&&l.package){const u=c[l.package]??(c[l.package]=[]),h=l.parent||(l.alias||"").split(".")[0]||l.name;u.push(h),r==="uniapp"&&i.includes(l.package)&&a.push(h)}}for(const[o,l]of Object.entries(s))(c[o]??(c[o]=[])).push(...Array.from(l)),r==="uniapp"&&i.includes(o)&&a.push(...Array.from(l));return{imports:Object.entries(c).filter(([o,l])=>r==="uniapp"?!i.includes(o)&&!!l.length:!!l.length).map(([o,l])=>`import { ${f.dedupArray(l).join(",")}} from '${o}';`).concat(n),uniComponents:a}}function xe(t={}){const e=[];for(const[n,s]of Object.entries(t))e.push(`
37
37
  ${n} {
38
38
  ${oe(s)}
39
39
  }
40
40
  `);return e.join(`
41
- `)}function _e(t={}){const e=[];return Object.entries(t).forEach(([n,s])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${s.url}');`)}),e}function Ee(t={}){const e=[];return Object.entries(t).forEach(([n,s])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(s)});`)}),e}function Ae(t,e,n="web"){const{dsl:s}=t,r=Object.keys(s.computed||{}),i=x(s.lifeCycles,r),c=x(s.computed,r),a=me(s.watch,r),p=he(s.dataSources),{methods:o,nodes:l,components:u,importBlocks:h,directives:d}=z(s.nodes||[],e,r,t.context),y=[...c,...a.computed],v=x({...o,...s.methods||{}},r),g=h.map(P=>`import ${P.name} from './${P.id}.vue';`);let{imports:F,uniComponents:$}=Oe(e,u,g,t.imports,n);const k=Object.keys({...t.urlSchemas,...t.blockPlugins}),w=_e(t.urlSchemas),C=Ee(t.blockPlugins);return{id:s.id,version:s.__VERSION__,name:s.name,state:ue(s.state).join(","),inject:le(s.inject).join(","),props:pe(s.props).join(","),emits:fe(s.emits).join(","),watch:a.watches.join(","),lifeCycles:i.join(","),computed:y.join(","),methods:[...p,...v].join(","),imports:`
42
- `+F.join(`
43
- `),components:ce(u,$).join(","),directives:d.join(","),returns:t.members.join(","),template:l.join(`
41
+ `)}function Ee(t={}){const e=[];return Object.entries(t).forEach(([n,s])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${s.url}');`)}),e}function Ae(t={}){const e=[];return Object.entries(t).forEach(([n,s])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(s)});`)}),e}function Fe(t,e,n="web"){const{dsl:s}=t,r=Object.keys(s.computed||{}),i=x(s.lifeCycles,r),c=x(s.computed,r),a=me(s.watch,r),p=he(s.dataSources),{methods:o,nodes:l,components:u,importBlocks:h,directives:d}=z(s.nodes||[],e,r,t.context),y=[...c,...a.computed],v=x({...o,...s.methods||{}},r),$=h.map(P=>`import ${P.name} from './${P.id}.vue';`);let{imports:N,uniComponents:g}=_e(e,u,$,t.imports,n);const k=Object.keys({...t.urlSchemas,...t.blockPlugins}),w=Ee(t.urlSchemas),C=Ae(t.blockPlugins);return{id:s.id,version:s.__VERSION__,name:s.name,state:ue(s.state).join(","),inject:le(s.inject).join(","),props:pe(s.props).join(","),emits:fe(s.emits).join(","),watch:a.watches.join(","),lifeCycles:i.join(","),computed:y.join(","),methods:[...p,...v].join(","),imports:`
42
+ `+N.join(`
43
+ `),components:ce(u,g).join(","),directives:d.join(","),returns:t.members.join(","),template:l.join(`
44
44
  `),css:s.css||"",style:xe(t.style),urlSchemas:w.join(`
45
45
  `),blockPlugins:C.join(`
46
- `),asyncComponents:k.join(","),uniComponents:$}}const Fe=`
46
+ `),asyncComponents:k.join(","),uniComponents:g}}const Ne=`
47
47
  // @ts-nocheck
48
48
 
49
49
  <%= imports %>
@@ -86,7 +86,7 @@ export default defineComponent({
86
86
  <%= css %>
87
87
  <%= style %>
88
88
  </style>
89
- `,Ne=f.template(Fe),Be=f.template(Ie);async function Te(t,e=new Map,n=[],s="web",r){const i=new ae(f.cloneDeep(t),n),c=Ae(i,e,s),a=Ne(c),p=Be({template:c.template,css:await I(c.css,r),script:await M(a,r),style:await I(c.style,r)});return await T(p,r).catch(o=>(o.content=p,Promise.reject(o)))}async function Re(t){const e=`
89
+ `,Te=f.template(Ne),Be=f.template(Ie);async function Re(t,e=new Map,n=[],s="web",r){const i=new ae(f.cloneDeep(t),n),c=Fe(i,e,s),a=Te(c),p=Be({template:c.template,css:await I(c.css,r),script:await M(a,r),style:await I(c.style,r)});return await R(p,r).catch(o=>(o.content=p,Promise.reject(o)))}async function We(t){const e=`
90
90
  <template>
91
91
  <div>
92
92
  <h3>源码模式页面</h3>
@@ -97,4 +97,4 @@ export default defineComponent({
97
97
  <\/script>
98
98
  <style scoped lang="scss">
99
99
  </style>
100
- `;return await T(e)}exports.VTJ_CODER_VERSION=se;exports.createEmptyPage=Re;exports.cssFormatter=I;exports.generator=Te;exports.tsFormatter=M;exports.vueFormatter=T;
100
+ `;return await R(e)}exports.VTJ_CODER_VERSION=se;exports.createEmptyPage=We;exports.cssFormatter=I;exports.generator=Re;exports.tsFormatter=M;exports.vueFormatter=R;
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.10.1-alpha.7
11
+ * @version 0.10.2
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Je = "0.10.1-alpha.7";
14
+ const Le = "0.10.2";
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.10.1-alpha.7
19
+ * @version 0.10.2
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
22
  const re = [
@@ -33,7 +33,7 @@ const re = [
33
33
  "a"
34
34
  ];
35
35
  K();
36
- const N = {
36
+ const R = {
37
37
  arrowParens: "always",
38
38
  bracketSpacing: !0,
39
39
  bracketSameLine: !0,
@@ -56,32 +56,32 @@ const N = {
56
56
  async function M(t, e) {
57
57
  return e ? t : await B(t, {
58
58
  parser: "vue",
59
- ...N,
59
+ ...R,
60
60
  plugins: [se, D, H, V]
61
61
  });
62
62
  }
63
63
  async function ie(t, e) {
64
64
  return e ? t : await B(t, {
65
65
  parser: "babel-ts",
66
- ...N,
66
+ ...R,
67
67
  plugins: [D, H]
68
68
  });
69
69
  }
70
70
  async function W(t, e) {
71
71
  return e ? t : B(t, {
72
72
  parser: "scss",
73
- ...N,
73
+ ...R,
74
74
  plugins: [V]
75
75
  });
76
76
  }
77
77
  function j(t) {
78
78
  return t && t.type === "JSExpression";
79
79
  }
80
- function _(t) {
80
+ function A(t) {
81
81
  return typeof t == "object" && t && t.type === "JSFunction";
82
82
  }
83
83
  function k(t) {
84
- return j(t) || _(t);
84
+ return j(t) || A(t);
85
85
  }
86
86
  function q(t) {
87
87
  return t.replace(new RegExp("this.", "g"), "");
@@ -91,9 +91,9 @@ function J(t) {
91
91
  }
92
92
  function f(t, e = !0, s = !0, n = []) {
93
93
  let r = k(t) ? t.value : e ? JSON.stringify(t) : t;
94
- return r = A(r, n), s ? q(J(r)) : J(r);
94
+ return r = N(r, n), s ? q(J(r)) : J(r);
95
95
  }
96
- function A(t, e = []) {
96
+ function N(t, e = []) {
97
97
  let s = t;
98
98
  for (const n of e)
99
99
  s = s.replace(
@@ -118,7 +118,7 @@ function Q(t) {
118
118
  function oe(t = {}) {
119
119
  return Object.entries(t).map(([e, s]) => `"${e}": ${f(s)}`);
120
120
  }
121
- function z(t = {}, e = !1) {
121
+ function G(t = {}, e = !1) {
122
122
  const s = Object.keys(t);
123
123
  return e ? s.map((n) => "." + n) : s;
124
124
  }
@@ -265,17 +265,17 @@ function fe(t = []) {
265
265
  function me(t = []) {
266
266
  return t.map((e) => `'${typeof e == "string" ? e : e.name}'`);
267
267
  }
268
- function E(t = {}, e = []) {
268
+ function _(t = {}, e = []) {
269
269
  return Object.entries(t).map(([s, n]) => {
270
270
  let r = Q(f(n, !1, !1));
271
- return r = A(r, e), r.startsWith("async") ? `async ${s}${r.replace(/^async/, "")}` : `${s}${r}`;
271
+ return r = N(r, e), r.startsWith("async") ? `async ${s}${r.replace(/^async/, "")}` : `${s}${r}`;
272
272
  });
273
273
  }
274
274
  function he(t = [], e = []) {
275
275
  const s = t.reduce(
276
- (i, c) => (c.id && _(c.source) && (i[`watcher_${c.id}`] = c.source), i),
276
+ (i, c) => (c.id && A(c.source) && (i[`watcher_${c.id}`] = c.source), i),
277
277
  {}
278
- ), n = E(s, e), r = t.map((i) => `watcher_${i.id}: {
278
+ ), n = _(s, e), r = t.map((i) => `watcher_${i.id}: {
279
279
  deep: ${i.deep},
280
280
  immediate:${i.immediate},
281
281
  handler${Q(i.handler.value)}
@@ -288,20 +288,35 @@ function he(t = [], e = []) {
288
288
  function de(t = {}) {
289
289
  return Object.values(t).map((e) => {
290
290
  if (e.type === "mock") {
291
- const s = _(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
291
+ const s = A(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
292
292
  return `async ${e.name}(...args:any[]) {
293
293
  const mock = this.provider.createMock(${s})
294
294
  return await mock.apply(this, args);
295
295
  }`;
296
296
  } else {
297
- const s = _(e.transform) && e.transform.value || "(res) => res";
297
+ const s = A(e.transform) && e.transform.value || "(res) => res";
298
298
  return `async ${e.name}(...args:any[]) {
299
299
  return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
300
300
  }`;
301
301
  }
302
302
  });
303
303
  }
304
- const L = [
304
+ const ye = [
305
+ "img",
306
+ "input",
307
+ "br",
308
+ "hr",
309
+ "area",
310
+ "base",
311
+ "col",
312
+ "embed",
313
+ "link",
314
+ "meta",
315
+ "param",
316
+ "source",
317
+ "track",
318
+ "wbr"
319
+ ], L = [
305
320
  "vIf",
306
321
  "vShow",
307
322
  "vModel",
@@ -309,47 +324,47 @@ const L = [
309
324
  "vBind",
310
325
  "vHtml"
311
326
  ];
312
- function G(t, e, s = [], n = {}, r) {
327
+ function z(t, e, s = [], n = {}, r) {
313
328
  const i = [];
314
329
  let c = {}, a = [];
315
330
  const p = [];
316
331
  let o = [];
317
- return ge(t).forEach((u) => {
332
+ return $e(t).forEach((u) => {
318
333
  const m = [];
319
334
  for (const d of u.children) {
320
- let { id: v, name: y, invisible: F, from: g } = d;
335
+ let { id: v, name: g, invisible: F, from: y } = d;
321
336
  if (F)
322
337
  continue;
323
- const w = $e(y, e, g);
324
- w && a.push(w), X(g) && o.push({ id: g.id, name: y });
325
- const { props: C, events: P, handlers: x } = ke(
338
+ const w = ve(g, e, y);
339
+ w && a.push(w), X(y) && o.push({ id: y.id, name: g });
340
+ const { props: C, events: P, handlers: O } = we(
326
341
  d,
327
342
  v,
328
343
  d.props,
329
344
  d.events,
330
345
  n,
331
346
  s
332
- ), R = we(
347
+ ), T = Ce(
333
348
  d.directives,
334
349
  s,
335
350
  p
336
- ).join(" "), b = d.children ? Pe(
351
+ ).join(" "), b = d.children ? Oe(
337
352
  d.children,
338
353
  s,
339
354
  e,
340
355
  n,
341
356
  d
342
357
  ) : "";
343
- Object.assign(c, x);
344
- let O = "";
345
- typeof b == "string" ? O = b : (O = (b?.nodes || []).join(`
358
+ Object.assign(c, O);
359
+ let x = "";
360
+ typeof b == "string" ? x = b : (x = (b?.nodes || []).join(`
346
361
  `), Object.assign(c, b?.methods || {}), a = a.concat(b?.components || []), o = o.concat(b?.importBlocks || []));
347
- const T = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
348
- g
349
- ) ? I(y) : Y(g) || Z(g) ? "component" : y;
362
+ const E = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
363
+ y
364
+ ) ? I(g) : Y(y) || Z(y) ? "component" : g;
350
365
  m.push(
351
- y === "img" ? `<${y} ${R} ${C} ${P} />` : `<${T} ${R} ${C} ${P}>${O ? `
352
- ` + O.trim() : ""}</${T}>`
366
+ ye.includes(E) ? `<${E} ${T} ${C} ${P} />` : `<${E} ${T} ${C} ${P}>${x ? `
367
+ ` + x.trim() : ""}</${E}>`
353
368
  );
354
369
  }
355
370
  const h = xe(u.slot, m.join(`
@@ -358,15 +373,15 @@ function G(t, e, s = [], n = {}, r) {
358
373
  }), {
359
374
  nodes: i,
360
375
  methods: c,
361
- directives: ye(p),
376
+ directives: ge(p),
362
377
  components: S(a),
363
378
  importBlocks: S(o, "id")
364
379
  };
365
380
  }
366
- function ye(t) {
381
+ function ge(t) {
367
382
  return S(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
368
383
  }
369
- function ge(t = []) {
384
+ function $e(t = []) {
370
385
  const e = /* @__PURE__ */ new Map();
371
386
  for (const s of t) {
372
387
  const n = typeof s.slot == "string" ? s.slot : s.slot?.name, r = e.get(n);
@@ -374,7 +389,7 @@ function ge(t = []) {
374
389
  }
375
390
  return e;
376
391
  }
377
- function $e(t, e, s) {
392
+ function ve(t, e, s) {
378
393
  if (re.includes(t)) return null;
379
394
  const n = e.get(t);
380
395
  if (n && n.alias) {
@@ -392,18 +407,18 @@ function Y(t) {
392
407
  function Z(t) {
393
408
  return typeof t == "object" && t.type === "Plugin";
394
409
  }
395
- function ve(t, e, s = []) {
410
+ function be(t, e, s = []) {
396
411
  return t === "style" ? "" : t === "__class" && k(e) ? `:class="${f({
397
412
  ...e,
398
- value: A(e.value, s)
413
+ value: N(e.value, s)
399
414
  })}"` : typeof e == "string" ? `${t}="${e}"` : k(e) ? `:${t}="${f({
400
415
  ...e,
401
- value: A(e.value, s)
416
+ value: N(e.value, s)
402
417
  })}"` : te(e) ? `:${t}='{${oe(
403
418
  e
404
419
  ).join(", ")}}'` : `:${t}='${JSON.stringify(e)}'`;
405
420
  }
406
- function be(t, e = {}, s = []) {
421
+ function je(t, e = {}, s = []) {
407
422
  if (!!Object.keys(e.style || {}).length) {
408
423
  const i = `${t.name}_${t.id}`;
409
424
  e.class ? typeof e.class == "string" ? e.class = [e.class, i].join(" ") : (e.__class = e.class, e.class = i) : (e.class = i, delete e.style);
@@ -412,13 +427,13 @@ function be(t, e = {}, s = []) {
412
427
  return (Y(r) || Z(r)) && (e.is = {
413
428
  type: "JSExpression",
414
429
  value: t.name
415
- }), Object.entries(e).map(([i, c]) => ve(i, c, s));
430
+ }), Object.entries(e).map(([i, c]) => be(i, c, s));
416
431
  }
417
- function je(t, e, s, n, r) {
418
- const i = z(e.modifiers, !0);
432
+ function Se(t, e, s, n, r) {
433
+ const i = G(e.modifiers, !0);
419
434
  return r ? `@${t}${i.join("")}="${s}"` : n && n.length > 0 ? `@${t}${i.join("")}="(...args:any[]) => ${s}"` : `@${t}${i.join("")}="${s}"`;
420
435
  }
421
- function Se(t, e = {}, s = {}) {
436
+ function ke(t, e = {}, s = {}) {
422
437
  const n = {}, r = Array.from(s[t] || /* @__PURE__ */ new Set([])), i = r.length ? `({${r.join(", ")}}, args)` : "";
423
438
  return {
424
439
  binders: Object.entries(e).map(([a, p]) => {
@@ -428,28 +443,28 @@ function Se(t, e = {}, s = {}) {
428
443
  value: `{
429
444
  return (${p.handler.value}).apply(this, args);
430
445
  }`
431
- } : p.handler), je(a, p, l, r, o);
446
+ } : p.handler), Se(a, p, l, r, o);
432
447
  }),
433
448
  handlers: n
434
449
  };
435
450
  }
436
- function ke(t, e, s = {}, n = {}, r = {}, i) {
437
- const { binders: c, handlers: a } = Se(e, n, r);
451
+ function we(t, e, s = {}, n = {}, r = {}, i) {
452
+ const { binders: c, handlers: a } = ke(e, n, r);
438
453
  return {
439
- props: be(t, s, i).join(" "),
454
+ props: je(t, s, i).join(" "),
440
455
  handlers: a,
441
456
  binders: c,
442
457
  events: c.join(" ")
443
458
  };
444
459
  }
445
- function we(t = [], e = [], s = []) {
446
- const n = [], { vIf: r, vShow: i, vModels: c, vFor: a, vBind: p, vHtml: o, customDirectives: l } = Ce(t);
460
+ function Ce(t = [], e = [], s = []) {
461
+ const n = [], { vIf: r, vShow: i, vModels: c, vFor: a, vBind: p, vHtml: o, customDirectives: l } = Pe(t);
447
462
  if (r && n.push(`v-if="${f(r.value, !0, !0, e)}"`), i && n.push(
448
463
  `v-show="${f(i.value, !0, !0, e)}"`
449
464
  ), p && n.push(
450
465
  `v-bind="${f(p.value, !0, !0, e)}"`
451
466
  ), c.forEach((u) => {
452
- const m = z(u.modifiers, !0), h = u.arg ? j(u.arg) ? `:[${f(u.arg, !0, !0, e)}]` : `:${u.arg}` : "";
467
+ const m = G(u.modifiers, !0), h = u.arg ? j(u.arg) ? `:[${f(u.arg, !0, !0, e)}]` : `:${u.arg}` : "";
453
468
  n.push(
454
469
  `v-model${h}${m}="${f(u.value, !0, !0, e)}"`
455
470
  );
@@ -468,14 +483,14 @@ function we(t = [], e = [], s = []) {
468
483
  const d = h?.startsWith("v") ? I(h) : I("v-" + h);
469
484
  if (m += d, u.arg && (j(u.arg) ? m += `:[${f(u.name, !0, !0, e)}]` : m += `:${u.arg}`), u.modifiers) {
470
485
  const v = Object.keys(u.modifiers);
471
- v.length && (m += v.map((y) => "." + y));
486
+ v.length && (m += v.map((g) => "." + g));
472
487
  }
473
488
  u.value ? n.push(
474
489
  `${m}="${f(u.value, !0, !0, e)}"`
475
490
  ) : n.push(m);
476
491
  }), n;
477
492
  }
478
- function Ce(t = []) {
493
+ function Pe(t = []) {
479
494
  const e = t.filter(
480
495
  (o) => L.includes(o.name)
481
496
  ), s = t.filter(
@@ -503,8 +518,8 @@ function Ce(t = []) {
503
518
  customDirectives: s
504
519
  };
505
520
  }
506
- function Pe(t, e, s, n, r) {
507
- return typeof t == "string" ? t : j(t) ? `{{ ${f(t, !1, !0, e)} }}` : Array.isArray(t) ? G(t, s, e, n, r) : "";
521
+ function Oe(t, e, s, n, r) {
522
+ return typeof t == "string" ? t : j(t) ? `{{ ${f(t, !1, !0, e)} }}` : Array.isArray(t) ? z(t, s, e, n, r) : "";
508
523
  }
509
524
  function xe(t, e, s) {
510
525
  if (!t) return e;
@@ -513,7 +528,7 @@ function xe(t, e, s) {
513
528
  ${e}
514
529
  </template>`;
515
530
  }
516
- function Oe(t, e = [], s = [], n = {}, r = "web") {
531
+ function Ee(t, e = [], s = [], n = {}, r = "web") {
517
532
  const i = [
518
533
  "@dcloudio/uni-h5",
519
534
  "uni-h5",
@@ -538,7 +553,7 @@ function Oe(t, e = [], s = [], n = {}, r = "web") {
538
553
  uniComponents: a
539
554
  };
540
555
  }
541
- function Ee(t = {}) {
556
+ function _e(t = {}) {
542
557
  const e = [];
543
558
  for (const [s, n] of Object.entries(t))
544
559
  e.push(`
@@ -549,7 +564,7 @@ function Ee(t = {}) {
549
564
  return e.join(`
550
565
  `);
551
566
  }
552
- function _e(t = {}) {
567
+ function Ae(t = {}) {
553
568
  const e = [];
554
569
  return Object.entries(t).forEach(([s, n]) => {
555
570
  e.push(
@@ -557,7 +572,7 @@ function _e(t = {}) {
557
572
  );
558
573
  }), e;
559
574
  }
560
- function Ae(t = {}) {
575
+ function Ne(t = {}) {
561
576
  const e = [];
562
577
  return Object.entries(t).forEach(([s, n]) => {
563
578
  e.push(
@@ -566,29 +581,29 @@ function Ae(t = {}) {
566
581
  }), e;
567
582
  }
568
583
  function Fe(t, e, s = "web") {
569
- const { dsl: n } = t, r = Object.keys(n.computed || {}), i = E(n.lifeCycles, r), c = E(n.computed, r), a = he(n.watch, r), p = de(n.dataSources), { methods: o, nodes: l, components: u, importBlocks: m, directives: h } = G(
584
+ const { dsl: n } = t, r = Object.keys(n.computed || {}), i = _(n.lifeCycles, r), c = _(n.computed, r), a = he(n.watch, r), p = de(n.dataSources), { methods: o, nodes: l, components: u, importBlocks: m, directives: h } = z(
570
585
  n.nodes || [],
571
586
  e,
572
587
  r,
573
588
  t.context
574
- ), d = [...c, ...a.computed], v = E(
589
+ ), d = [...c, ...a.computed], v = _(
575
590
  {
576
591
  ...o,
577
592
  ...n.methods || {}
578
593
  },
579
594
  r
580
- ), y = m.map((x) => `import ${x.name} from './${x.id}.vue';`);
581
- let { imports: F, uniComponents: g } = Oe(
595
+ ), g = m.map((O) => `import ${O.name} from './${O.id}.vue';`);
596
+ let { imports: F, uniComponents: y } = Ee(
582
597
  e,
583
598
  u,
584
- y,
599
+ g,
585
600
  t.imports,
586
601
  s
587
602
  );
588
603
  const w = Object.keys({
589
604
  ...t.urlSchemas,
590
605
  ...t.blockPlugins
591
- }), C = _e(t.urlSchemas), P = Ae(t.blockPlugins);
606
+ }), C = Ae(t.urlSchemas), P = Ne(t.blockPlugins);
592
607
  return {
593
608
  id: n.id,
594
609
  version: n.__VERSION__,
@@ -604,19 +619,19 @@ function Fe(t, e, s = "web") {
604
619
  imports: `
605
620
  ` + F.join(`
606
621
  `),
607
- components: ae(u, g).join(","),
622
+ components: ae(u, y).join(","),
608
623
  directives: h.join(","),
609
624
  returns: t.members.join(","),
610
625
  template: l.join(`
611
626
  `),
612
627
  css: n.css || "",
613
- style: Ee(t.style),
628
+ style: _e(t.style),
614
629
  urlSchemas: C.join(`
615
630
  `),
616
631
  blockPlugins: P.join(`
617
632
  `),
618
633
  asyncComponents: w.join(","),
619
- uniComponents: g
634
+ uniComponents: y
620
635
  };
621
636
  }
622
637
  const Ie = `
@@ -662,9 +677,9 @@ export default defineComponent({
662
677
  <%= css %>
663
678
  <%= style %>
664
679
  </style>
665
- `, Ne = U(Ie), Re = U(Be);
666
- async function Le(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", r) {
667
- const i = new ue(ne(t), s), c = Fe(i, e, n), a = Ne(c), p = Re({
680
+ `, Re = U(Ie), Te = U(Be);
681
+ async function Ue(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", r) {
682
+ const i = new ue(ne(t), s), c = Fe(i, e, n), a = Re(c), p = Te({
668
683
  template: c.template,
669
684
  css: await W(c.css, r),
670
685
  script: await ie(a, r),
@@ -672,7 +687,7 @@ async function Le(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", r) {
672
687
  });
673
688
  return await M(p, r).catch((o) => (o.content = p, Promise.reject(o)));
674
689
  }
675
- async function Ue(t) {
690
+ async function De(t) {
676
691
  const e = `
677
692
  <template>
678
693
  <div>
@@ -688,10 +703,10 @@ async function Ue(t) {
688
703
  return await M(e);
689
704
  }
690
705
  export {
691
- Je as VTJ_CODER_VERSION,
692
- Ue as createEmptyPage,
706
+ Le as VTJ_CODER_VERSION,
707
+ De as createEmptyPage,
693
708
  W as cssFormatter,
694
- Le as generator,
709
+ Ue as generator,
695
710
  ie as tsFormatter,
696
711
  M as vueFormatter
697
712
  };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.10.1-alpha.7",
4
+ "version": "0.10.2",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "prettier": "~3.4.0",
8
- "@vtj/base": "~0.10.0",
9
- "@vtj/core": "~0.10.1-alpha.7"
8
+ "@vtj/base": "~0.10.1",
9
+ "@vtj/core": "~0.10.2"
10
10
  },
11
11
  "devDependencies": {
12
- "@vtj/cli": "~0.10.0"
12
+ "@vtj/cli": "~0.10.1"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
@@ -1,4 +1,5 @@
1
1
  import { NodeSchema, MaterialDescription, JSFunction } from '@vtj/core';
2
+ export declare const NO_END_TAGS: string[];
2
3
  /**
3
4
  * 内置指令
4
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.10.1-alpha.6
5
+ * @version 0.10.1
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.10.1-alpha.6";
8
+ export declare const version = "0.10.1";