@vtj/coder 0.8.67 → 0.8.68

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,13 +2,13 @@
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.8.67
5
+ * @version 0.8.68
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const ee="0.8.67";/**!
7
+ */const ee="0.8.68";/**!
8
8
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
9
9
  * @name @vtj/core
10
10
  * @author CHC chenhuachun1549@dingtalk.com
11
- * @version 0.8.67
11
+ * @version 0.8.68
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */const te=["slot","template","component","img","div","p","h1","h2","h3","span","a"];l.mitt();const _={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 L(t,e){return e?t:await x.format(t,{parser:"vue",..._,plugins:[K,J,q,T]})}async function ne(t,e){return e?t:await x.format(t,{parser:"babel-ts",..._,plugins:[J,q]})}async function W(t,e){return e?t:x.format(t,{parser:"scss",..._,plugins:[T]})}function E(t){return t&&t.type==="JSExpression"}function A(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function $(t){return E(t)||A(t)}function F(t){return t.replace(new RegExp("this.","g"),"")}function I(t){return t.replace(/this\.context\??\./g,"")}function u(t,e=!0,n=!0,r=[]){let i=$(t)?t.value:e?JSON.stringify(t):t;return i=b(i,r),n?F(I(i)):I(i)}function b(t,e=[]){let n=t;for(const r of e)n=n.replace(new RegExp(`this.${r}.value`,"g"),`this.${r}`);return n}function U(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 i=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,s=e.match(i);s&&s[2]&&(s[2].startsWith("{")||(e=e.replace(s[2],`{ return ${s[2]} }`))),e=e.replace("=>","")}return e}function re(t={}){return Object.entries(t).map(([e,n])=>`"${e}": ${u(n)}`)}function V(t={},e=!1){const n=Object.keys(t);return e?n.map(r=>"."+r):n}function se(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];e+=n+": "+r+";"}return e}class ie{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 r=n.pop(),i=n.join(".")+".",s=n.pop();if(r&&s){const o=this.dependencies.find(a=>a.library===s)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(r)}return{name:r,path:i,library:s}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let r=e.value;for(const i of n){const s=e.value.match(i)||[];for(const o of s){const a=this.collectImport(o);if(a){const c=a.path.replace(/\$/g,"\\$");r=r.replace(new RegExp(c,"g"),"")}}}return r}walk(e){const n=r=>{if(!r||typeof r!="object")return;if(Array.isArray(r)){for(let s of r)n(s);return}const i=Object.values(r);for(const s of i)$(s)?s.value=this.replaceLibraryPath(s):n(s)};n(e)}getLibraryMember(e=[]){let n=[...e];for(const r of Object.values(this.imports))n=n.concat(Array.from(r));return l.dedupArray(n)}collectContext(e,n){const r=new Set(n?.id?this.context[n.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let s=new Set(Array.from(r));if(i){const{item:a="item",index:c="index"}=i.iterator||{};s=new Set([a,c,...Array.from(s)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],c=a.length?a:[`scope_${n?.id}`];s=new Set([...c,...Array.from(s)])}this.context[e.id]=s}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=(r,i)=>{this.collectContext(r,i),this.collectStyle(r),this.collectUrlSchema(r),this.collectBlockPlugin(r),Array.isArray(r.children)&&r.children.forEach(s=>n(s,r))};Array.isArray(e.nodes)&&e.nodes.forEach(r=>n(r))}}function oe(t={}){return Object.entries(t).map(([e,n])=>{const r=u(n,!1);return`${e}:${r}`})}function ae(t=[]){return t.map(e=>`${e.name}: {
14
14
  from: '${e.from||e.name}',
@@ -23,20 +23,20 @@
23
23
  handler${U(s.handler.value)}
24
24
  }`);return{computed:r,watches:i}}function pe(t={}){return Object.values(t).map(e=>{const n=A(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args:any[]) {
25
25
  return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
26
- }`})}function M(t,e,n=[],r={},i){const s=[];let o={},a=[],c=[];return fe(t).forEach(f=>{const j=[];for(const p of f.children){let{id:O,name:h,invisible:C,from:d}=p;if(C)continue;const v=me(h,e,d);v&&a.push(v),D(d)&&c.push({id:d.id,name:h});const{props:g,events:N,handlers:G}=$e(p,O,p.props,p.events,r,n),B=be(p.directives,n).join(" "),y=p.children?ve(p.children,n,e,r,p):"";Object.assign(o,G);let S="";typeof y=="string"?S=y:(S=(y?.nodes||[]).join(`
26
+ }`})}function M(t,e,n=[],r={},i){const s=[];let o={},a=[],c=[];return fe(t).forEach(m=>{const j=[];for(const p of m.children){let{id:O,name:h,invisible:C,from:d}=p;if(C)continue;const v=me(h,e,d);v&&a.push(v),D(d)&&c.push({id:d.id,name:h});const{props:g,events:N,handlers:G}=$e(p,O,p.props,p.events,r,n),B=be(p.directives,n).join(" "),y=p.children?ve(p.children,n,e,r,p):"";Object.assign(o,G);let S="";typeof y=="string"?S=y:(S=(y?.nodes||[]).join(`
27
27
  `),Object.assign(o,y?.methods||{}),a=a.concat(y?.components||[]),c=c.concat(y?.importBlocks||[]));const R=z(d)||Q(d)?"component":h;j.push(h==="img"?`<${h} ${B} ${g} ${N} />`:`<${R} ${B} ${g} ${N}>${S?`
28
- `+S.trim():""}</${R}>`)}const P=Se(f.slot,j.join(`
29
- `),i?.id);s.push(P)}),{nodes:s,methods:o,components:l.dedupArray(a),importBlocks:l.dedupArray(c,"id")}}function fe(t=[]){const e=new Map;for(const n of t){const r=typeof n.slot=="string"?n.slot:n.slot?.name,i=e.get(r);i?i.children.push(n):e.set(r,{slot:n.slot,children:[n]})}return e}function me(t,e,n){if(te.includes(t))return null;const r=e.get(t);if(r&&r.alias){const i=r.parent?`${r.parent}.${r.alias}`:r.alias;return`${t}: ${i}`}return D(n)||r?t:null}function D(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function z(t){return typeof t=="object"&&t.type==="UrlSchema"}function Q(t){return typeof t=="object"&&t.type==="Plugin"}function he(t,e,n=[]){return t==="style"?"":t==="__class"&&$(e)?`:class="${u({...e,value:b(e.value,n)})}"`:typeof e=="string"?`${t}="${e}"`:$(e)?`:${t}="${u({...e,value:b(e.value,n)})}"`:l.isPlainObject(e)?`:${t}='{${re(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function de(t,e={},n=[]){if(!!Object.keys(e.style||{}).length){const s=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,s].join(" "):(e.__class=e.class,e.class=s):(e.class=s,delete e.style)}const i=t.from;return(z(i)||Q(i))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([s,o])=>he(s,o,n))}function ye(t,e,n,r){const i=V(e.modifiers,!0);return r&&r.length>0?`@${t}${i.join("")}="(...args:any[]) => ${n}"`:`@${t}${i.join("")}="${n}"`}function ge(t,e={},n={}){const r={},i=Array.from(n[t]||new Set([])),s=i.length?`({${i.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,c])=>{const m=c.handler.value.startsWith("this."),f=m?F(c.handler.value):`${l.camelCase(a)}_${t}${s}`;return m||(r[f]=i.length?{type:"JSFunction",value:`{
28
+ `+S.trim():""}</${R}>`)}const P=Se(m.slot,j.join(`
29
+ `),i?.id);s.push(P)}),{nodes:s,methods:o,components:l.dedupArray(a),importBlocks:l.dedupArray(c,"id")}}function fe(t=[]){const e=new Map;for(const n of t){const r=typeof n.slot=="string"?n.slot:n.slot?.name,i=e.get(r);i?i.children.push(n):e.set(r,{slot:n.slot,children:[n]})}return e}function me(t,e,n){if(te.includes(t))return null;const r=e.get(t);if(r&&r.alias){const i=r.parent?`${r.parent}.${r.alias}`:r.alias;return`${t}: ${i}`}return D(n)||r?t:null}function D(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function z(t){return typeof t=="object"&&t.type==="UrlSchema"}function Q(t){return typeof t=="object"&&t.type==="Plugin"}function he(t,e,n=[]){return t==="style"?"":t==="__class"&&$(e)?`:class="${u({...e,value:b(e.value,n)})}"`:typeof e=="string"?`${t}="${e}"`:$(e)?`:${t}="${u({...e,value:b(e.value,n)})}"`:l.isPlainObject(e)?`:${t}='{${re(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function de(t,e={},n=[]){if(!!Object.keys(e.style||{}).length){const s=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,s].join(" "):(e.__class=e.class,e.class=s):(e.class=s,delete e.style)}const i=t.from;return(z(i)||Q(i))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([s,o])=>he(s,o,n))}function ye(t,e,n,r,i){const s=V(e.modifiers,!0);return i?`@${t}${s.join("")}="${n}"`:r&&r.length>0?`@${t}${s.join("")}="(...args:any[]) => ${n}"`:`@${t}${s.join("")}="${n}"`}function ge(t,e={},n={}){const r={},i=Array.from(n[t]||new Set([])),s=i.length?`({${i.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,c])=>{const f=c.handler.value.startsWith("this."),m=f?F(c.handler.value):`${l.camelCase(a)}_${t}${s}`;return f||(r[m]=i.length?{type:"JSFunction",value:`{
30
30
  return (${c.handler.value}).apply(this, args);
31
- }`}:c.handler),ye(a,c,f,i)}),handlers:r}}function $e(t,e,n={},r={},i={},s){const{binders:o,handlers:a}=ge(e,r,i);return{props:de(t,n,s).join(" "),handlers:a,binders:o,events:o.join(" ")}}function be(t=[],e=[]){const n=[],{vIf:r,vShow:i,vModels:s,vFor:o}=je(t);if(r&&n.push(`v-if="${u(r.value,!0,!0,e)}"`),i&&n.push(`v-show="${u(i.value,!0,!0,e)}"`),s.forEach(a=>{const c=V(a.modifiers,!0),m=a.arg?E(a.arg)?`:[${u(a.arg,!0,!0,e)}]`:`:${a.arg}`:"";n.push(`v-model${m}${c}="${u(a.value,!0,!0,e)}"`)}),o){const{item:a,index:c}={item:"item",index:"index",...o.iterator};n.push(`v-for="(${a}, ${c}) in ${u(o.value,!0,!0,e)}"`)}return n}function je(t=[]){const e=t.find(o=>l.camelCase(o.name)==="vIf"),n=t.find(o=>l.camelCase(o.name)==="vFor"),r=t.find(o=>l.camelCase(o.name)==="vShow"),i=t.find(o=>l.camelCase(o.name)==="vBind"),s=t.filter(o=>l.camelCase(o.name)==="vModel");return{vIf:e,vFor:n,vShow:r,vModels:s,vBind:i}}function ve(t,e,n,r,i){if(typeof t=="string")return t;if(E(t)){let s=u(t,!1);return s=b(s,e),s=F(s),`{{ ${s} }}`}return Array.isArray(t)?M(t,n,e,r,i):""}function Se(t,e,n){if(!t)return e;const r=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${r.name}="${r.params?.length>0?`{${r.params?.join(",")}}`:`scope_${n}`}"`}>
31
+ }`}:c.handler),ye(a,c,m,i,f)}),handlers:r}}function $e(t,e,n={},r={},i={},s){const{binders:o,handlers:a}=ge(e,r,i);return{props:de(t,n,s).join(" "),handlers:a,binders:o,events:o.join(" ")}}function be(t=[],e=[]){const n=[],{vIf:r,vShow:i,vModels:s,vFor:o}=je(t);if(r&&n.push(`v-if="${u(r.value,!0,!0,e)}"`),i&&n.push(`v-show="${u(i.value,!0,!0,e)}"`),s.forEach(a=>{const c=V(a.modifiers,!0),f=a.arg?E(a.arg)?`:[${u(a.arg,!0,!0,e)}]`:`:${a.arg}`:"";n.push(`v-model${f}${c}="${u(a.value,!0,!0,e)}"`)}),o){const{item:a,index:c}={item:"item",index:"index",...o.iterator};n.push(`v-for="(${a}, ${c}) in ${u(o.value,!0,!0,e)}"`)}return n}function je(t=[]){const e=t.find(o=>l.camelCase(o.name)==="vIf"),n=t.find(o=>l.camelCase(o.name)==="vFor"),r=t.find(o=>l.camelCase(o.name)==="vShow"),i=t.find(o=>l.camelCase(o.name)==="vBind"),s=t.filter(o=>l.camelCase(o.name)==="vModel");return{vIf:e,vFor:n,vShow:r,vModels:s,vBind:i}}function ve(t,e,n,r,i){if(typeof t=="string")return t;if(E(t)){let s=u(t,!1);return s=b(s,e),s=F(s),`{{ ${s} }}`}return Array.isArray(t)?M(t,n,e,r,i):""}function Se(t,e,n){if(!t)return e;const r=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${r.name}="${r.params?.length>0?`{${r.params?.join(",")}}`:`scope_${n}`}"`}>
32
32
  ${e}
33
33
  </template>`}function we(t,e=[],n=[],r={}){const i={vue:["defineComponent","reactive"]};for(const s of e){const o=t.get(s.split(":")[0]);o&&o.package&&(i[o.package]??(i[o.package]=[])).push(o.parent||(o.alias||"").split(".")[0]||o.name)}for(const[s,o]of Object.entries(r))(i[s]??(i[s]=[])).push(...Array.from(o));return Object.entries(i).filter(([s,o])=>!!o.length).map(([s,o])=>`import { ${l.dedupArray(o).join(",")}} from '${s}';`).concat(n)}function ke(t={}){const e=[];for(const[n,r]of Object.entries(t))e.push(`
34
34
  ${n} {
35
35
  ${se(r)}
36
36
  }
37
37
  `);return e.join(`
38
- `)}function Pe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${r.url}');`)}),e}function Oe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(r)});`)}),e}function Ce(t,e){const{dsl:n}=t,r=Object.keys(n.computed||{}),i=w(n.lifeCycles,r),s=w(n.computed,r),o=ue(n.watch,r),a=pe(n.dataSources),{methods:c,nodes:m,components:f,importBlocks:j}=M(n.nodes||[],e,r,t.context),P=[...s,...o.computed],p=w({...c,...n.methods||{}},r),O=j.map(g=>`import ${g.name} from './${g.id}.vue';`),h=we(e,f,O,t.imports),C=Object.keys({...t.urlSchemas,...t.blockPlugins}),d=Pe(t.urlSchemas),v=Oe(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:oe(n.state).join(","),inject:ae(n.inject).join(","),props:ce(n.props).join(","),emits:le(n.emits).join(","),watch:o.watches.join(","),lifeCycles:i.join(","),computed:P.join(","),methods:[...a,...p].join(","),imports:h.join(`
39
- `),components:f.join(","),returns:t.members.join(","),template:m.join(`
38
+ `)}function Pe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${r.url}');`)}),e}function Oe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(r)});`)}),e}function Ce(t,e){const{dsl:n}=t,r=Object.keys(n.computed||{}),i=w(n.lifeCycles,r),s=w(n.computed,r),o=ue(n.watch,r),a=pe(n.dataSources),{methods:c,nodes:f,components:m,importBlocks:j}=M(n.nodes||[],e,r,t.context),P=[...s,...o.computed],p=w({...c,...n.methods||{}},r),O=j.map(g=>`import ${g.name} from './${g.id}.vue';`),h=we(e,m,O,t.imports),C=Object.keys({...t.urlSchemas,...t.blockPlugins}),d=Pe(t.urlSchemas),v=Oe(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:oe(n.state).join(","),inject:ae(n.inject).join(","),props:ce(n.props).join(","),emits:le(n.emits).join(","),watch:o.watches.join(","),lifeCycles:i.join(","),computed:P.join(","),methods:[...a,...p].join(","),imports:h.join(`
39
+ `),components:m.join(","),returns:t.members.join(","),template:f.join(`
40
40
  `),css:n.css||"",style:ke(t.style),urlSchemas:d.join(`
41
41
  `),blockPlugins:v.join(`
42
42
  `),asyncComponents:C.join(",")}}const xe=`
package/dist/index.mjs CHANGED
@@ -8,15 +8,15 @@ import * as U from "prettier/plugins/estree";
8
8
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
9
9
  * @name @vtj/coder
10
10
  * @author CHC chenhuachun1549@dingtalk.com
11
- * @version 0.8.67
11
+ * @version 0.8.68
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Bt = "0.8.67";
14
+ const Bt = "0.8.68";
15
15
  /**!
16
16
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
17
17
  * @name @vtj/core
18
18
  * @author CHC chenhuachun1549@dingtalk.com
19
- * @version 0.8.67
19
+ * @version 0.8.68
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
22
  const et = [
@@ -91,9 +91,9 @@ function I(e) {
91
91
  }
92
92
  function l(e, t = !0, n = !0, s = []) {
93
93
  let i = $(e) ? e.value : t ? JSON.stringify(e) : e;
94
- return i = b(i, s), n ? F(I(i)) : I(i);
94
+ return i = v(i, s), n ? F(I(i)) : I(i);
95
95
  }
96
- function b(e, t = []) {
96
+ function v(e, t = []) {
97
97
  let n = e;
98
98
  for (const s of t)
99
99
  n = n.replace(
@@ -159,7 +159,7 @@ class it {
159
159
  const s = n.pop(), i = n.join(".") + ".", r = n.pop();
160
160
  if (s && r) {
161
161
  const o = this.dependencies.find(
162
- (a) => a.library === r
162
+ (c) => c.library === r
163
163
  )?.package;
164
164
  o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(s);
165
165
  }
@@ -178,10 +178,10 @@ class it {
178
178
  for (const i of n) {
179
179
  const r = t.value.match(i) || [];
180
180
  for (const o of r) {
181
- const a = this.collectImport(o);
182
- if (a) {
183
- const c = a.path.replace(/\$/g, "\\$");
184
- s = s.replace(new RegExp(c, "g"), "");
181
+ const c = this.collectImport(o);
182
+ if (c) {
183
+ const a = c.path.replace(/\$/g, "\\$");
184
+ s = s.replace(new RegExp(a, "g"), "");
185
185
  }
186
186
  }
187
187
  }
@@ -208,16 +208,16 @@ class it {
208
208
  return k(n);
209
209
  }
210
210
  collectContext(t, n) {
211
- const s = new Set(n?.id ? this.context[n.id] : []), i = (t.directives || []).find((a) => a.name === "vFor");
211
+ const s = new Set(n?.id ? this.context[n.id] : []), i = (t.directives || []).find((c) => c.name === "vFor");
212
212
  let r = new Set(Array.from(s));
213
213
  if (i) {
214
- const { item: a = "item", index: c = "index" } = i.iterator || {};
215
- r = /* @__PURE__ */ new Set([a, c, ...Array.from(r)]);
214
+ const { item: c = "item", index: a = "index" } = i.iterator || {};
215
+ r = /* @__PURE__ */ new Set([c, a, ...Array.from(r)]);
216
216
  }
217
217
  const o = t.slot;
218
218
  if (o) {
219
- const a = typeof o == "string" ? [] : o.params || [], c = a.length ? a : [`scope_${n?.id}`];
220
- r = /* @__PURE__ */ new Set([...c, ...Array.from(r)]);
219
+ const c = typeof o == "string" ? [] : o.params || [], a = c.length ? c : [`scope_${n?.id}`];
220
+ r = /* @__PURE__ */ new Set([...a, ...Array.from(r)]);
221
221
  }
222
222
  this.context[t.id] = r;
223
223
  }
@@ -243,13 +243,13 @@ function ot(e = {}) {
243
243
  return `${t}:${s}`;
244
244
  });
245
245
  }
246
- function at(e = []) {
246
+ function ct(e = []) {
247
247
  return e.map((t) => `${t.name}: {
248
248
  from: '${t.from || t.name}',
249
249
  default: ${l(t.default, !0, !1)}
250
250
  }`);
251
251
  }
252
- function ct(e = []) {
252
+ function at(e = []) {
253
253
  const t = (n) => n ? `[${Y(n).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
254
254
  return e.map((n) => typeof n == "string" ? `${n}: {}` : ($(n.default) && !n.default.value && (n.default.value = "undefined"), `${n.name}: {
255
255
  type:${t(n.type)},
@@ -263,7 +263,7 @@ function lt(e = []) {
263
263
  function w(e = {}, t = []) {
264
264
  return Object.entries(e).map(([n, s]) => {
265
265
  let i = q(l(s, !1, !1));
266
- return i = b(i, t), i.startsWith("async") ? `async ${n}${i.replace(/^async/, "")}` : `${n}${i}`;
266
+ return i = v(i, t), i.startsWith("async") ? `async ${n}${i.replace(/^async/, "")}` : `${n}${i}`;
267
267
  });
268
268
  }
269
269
  function ut(e = [], t = []) {
@@ -290,15 +290,15 @@ function pt(e = {}) {
290
290
  }
291
291
  function D(e, t, n = [], s = {}, i) {
292
292
  const r = [];
293
- let o = {}, a = [], c = [];
294
- return ft(e).forEach((p) => {
295
- const v = [];
296
- for (const u of p.children) {
293
+ let o = {}, c = [], a = [];
294
+ return ft(e).forEach((f) => {
295
+ const b = [];
296
+ for (const u of f.children) {
297
297
  let { id: x, name: m, invisible: O, from: h } = u;
298
298
  if (O)
299
299
  continue;
300
300
  const j = mt(m, t, h);
301
- j && a.push(j), Q(h) && c.push({ id: h.id, name: m });
301
+ j && c.push(j), Q(h) && a.push({ id: h.id, name: m });
302
302
  const { props: g, events: N, handlers: H } = $t(
303
303
  u,
304
304
  x,
@@ -306,7 +306,7 @@ function D(e, t, n = [], s = {}, i) {
306
306
  u.events,
307
307
  s,
308
308
  n
309
- ), B = bt(u.directives, n).join(
309
+ ), B = vt(u.directives, n).join(
310
310
  " "
311
311
  ), d = u.children ? jt(
312
312
  u.children,
@@ -318,21 +318,21 @@ function D(e, t, n = [], s = {}, i) {
318
318
  Object.assign(o, H);
319
319
  let S = "";
320
320
  typeof d == "string" ? S = d : (S = (d?.nodes || []).join(`
321
- `), Object.assign(o, d?.methods || {}), a = a.concat(d?.components || []), c = c.concat(d?.importBlocks || []));
321
+ `), Object.assign(o, d?.methods || {}), c = c.concat(d?.components || []), a = a.concat(d?.importBlocks || []));
322
322
  const R = z(h) || G(h) ? "component" : m;
323
- v.push(
323
+ b.push(
324
324
  m === "img" ? `<${m} ${B} ${g} ${N} />` : `<${R} ${B} ${g} ${N}>${S ? `
325
325
  ` + S.trim() : ""}</${R}>`
326
326
  );
327
327
  }
328
- const P = St(p.slot, v.join(`
328
+ const P = St(f.slot, b.join(`
329
329
  `), i?.id);
330
330
  r.push(P);
331
331
  }), {
332
332
  nodes: r,
333
333
  methods: o,
334
- components: k(a),
335
- importBlocks: k(c, "id")
334
+ components: k(c),
335
+ importBlocks: k(a, "id")
336
336
  };
337
337
  }
338
338
  function ft(e = []) {
@@ -364,10 +364,10 @@ function G(e) {
364
364
  function ht(e, t, n = []) {
365
365
  return e === "style" ? "" : e === "__class" && $(t) ? `:class="${l({
366
366
  ...t,
367
- value: b(t.value, n)
367
+ value: v(t.value, n)
368
368
  })}"` : typeof t == "string" ? `${e}="${t}"` : $(t) ? `:${e}="${l({
369
369
  ...t,
370
- value: b(t.value, n)
370
+ value: v(t.value, n)
371
371
  })}"` : Z(t) ? `:${e}='{${st(
372
372
  t
373
373
  ).join(", ")}}'` : `:${e}='${JSON.stringify(t)}'`;
@@ -383,52 +383,52 @@ function dt(e, t = {}, n = []) {
383
383
  value: e.name
384
384
  }), Object.entries(t).map(([r, o]) => ht(r, o, n));
385
385
  }
386
- function yt(e, t, n, s) {
387
- const i = M(t.modifiers, !0);
388
- return s && s.length > 0 ? `@${e}${i.join("")}="(...args:any[]) => ${n}"` : `@${e}${i.join("")}="${n}"`;
386
+ function yt(e, t, n, s, i) {
387
+ const r = M(t.modifiers, !0);
388
+ return i ? `@${e}${r.join("")}="${n}"` : s && s.length > 0 ? `@${e}${r.join("")}="(...args:any[]) => ${n}"` : `@${e}${r.join("")}="${n}"`;
389
389
  }
390
390
  function gt(e, t = {}, n = {}) {
391
391
  const s = {}, i = Array.from(n[e] || /* @__PURE__ */ new Set([])), r = i.length ? `({${i.join(", ")}}, args)` : "";
392
392
  return {
393
- binders: Object.entries(t).map(([a, c]) => {
394
- const f = c.handler.value.startsWith("this."), p = f ? F(c.handler.value) : `${y(a)}_${e}${r}`;
395
- return f || (s[p] = i.length ? {
393
+ binders: Object.entries(t).map(([c, a]) => {
394
+ const p = a.handler.value.startsWith("this."), f = p ? F(a.handler.value) : `${y(c)}_${e}${r}`;
395
+ return p || (s[f] = i.length ? {
396
396
  type: "JSFunction",
397
397
  value: `{
398
- return (${c.handler.value}).apply(this, args);
398
+ return (${a.handler.value}).apply(this, args);
399
399
  }`
400
- } : c.handler), yt(a, c, p, i);
400
+ } : a.handler), yt(c, a, f, i, p);
401
401
  }),
402
402
  handlers: s
403
403
  };
404
404
  }
405
405
  function $t(e, t, n = {}, s = {}, i = {}, r) {
406
- const { binders: o, handlers: a } = gt(t, s, i);
406
+ const { binders: o, handlers: c } = gt(t, s, i);
407
407
  return {
408
408
  props: dt(e, n, r).join(" "),
409
- handlers: a,
409
+ handlers: c,
410
410
  binders: o,
411
411
  events: o.join(" ")
412
412
  };
413
413
  }
414
- function bt(e = [], t = []) {
415
- const n = [], { vIf: s, vShow: i, vModels: r, vFor: o } = vt(e);
414
+ function vt(e = [], t = []) {
415
+ const n = [], { vIf: s, vShow: i, vModels: r, vFor: o } = bt(e);
416
416
  if (s && n.push(`v-if="${l(s.value, !0, !0, t)}"`), i && n.push(
417
417
  `v-show="${l(i.value, !0, !0, t)}"`
418
- ), r.forEach((a) => {
419
- const c = M(a.modifiers, !0), f = a.arg ? _(a.arg) ? `:[${l(a.arg, !0, !0, t)}]` : `:${a.arg}` : "";
418
+ ), r.forEach((c) => {
419
+ const a = M(c.modifiers, !0), p = c.arg ? _(c.arg) ? `:[${l(c.arg, !0, !0, t)}]` : `:${c.arg}` : "";
420
420
  n.push(
421
- `v-model${f}${c}="${l(a.value, !0, !0, t)}"`
421
+ `v-model${p}${a}="${l(c.value, !0, !0, t)}"`
422
422
  );
423
423
  }), o) {
424
- const { item: a, index: c } = { item: "item", index: "index", ...o.iterator };
424
+ const { item: c, index: a } = { item: "item", index: "index", ...o.iterator };
425
425
  n.push(
426
- `v-for="(${a}, ${c}) in ${l(o.value, !0, !0, t)}"`
426
+ `v-for="(${c}, ${a}) in ${l(o.value, !0, !0, t)}"`
427
427
  );
428
428
  }
429
429
  return n;
430
430
  }
431
- function vt(e = []) {
431
+ function bt(e = []) {
432
432
  const t = e.find((o) => y(o.name) === "vIf"), n = e.find((o) => y(o.name) === "vFor"), s = e.find((o) => y(o.name) === "vShow"), i = e.find((o) => y(o.name) === "vBind"), r = e.filter((o) => y(o.name) === "vModel");
433
433
  return {
434
434
  vIf: t,
@@ -443,7 +443,7 @@ function jt(e, t, n, s, i) {
443
443
  return e;
444
444
  if (_(e)) {
445
445
  let r = l(e, !1);
446
- return r = b(r, t), r = F(r), `{{ ${r} }}`;
446
+ return r = v(r, t), r = F(r), `{{ ${r} }}`;
447
447
  }
448
448
  return Array.isArray(e) ? D(e, n, t, s, i) : "";
449
449
  }
@@ -496,20 +496,20 @@ function xt(e = {}) {
496
496
  }), t;
497
497
  }
498
498
  function Ot(e, t) {
499
- const { dsl: n } = e, s = Object.keys(n.computed || {}), i = w(n.lifeCycles, s), r = w(n.computed, s), o = ut(n.watch, s), a = pt(n.dataSources), { methods: c, nodes: f, components: p, importBlocks: v } = D(
499
+ const { dsl: n } = e, s = Object.keys(n.computed || {}), i = w(n.lifeCycles, s), r = w(n.computed, s), o = ut(n.watch, s), c = pt(n.dataSources), { methods: a, nodes: p, components: f, importBlocks: b } = D(
500
500
  n.nodes || [],
501
501
  t,
502
502
  s,
503
503
  e.context
504
504
  ), P = [...r, ...o.computed], u = w(
505
505
  {
506
- ...c,
506
+ ...a,
507
507
  ...n.methods || {}
508
508
  },
509
509
  s
510
- ), x = v.map((g) => `import ${g.name} from './${g.id}.vue';`), m = wt(
510
+ ), x = b.map((g) => `import ${g.name} from './${g.id}.vue';`), m = wt(
511
511
  t,
512
- p,
512
+ f,
513
513
  x,
514
514
  e.imports
515
515
  ), O = Object.keys({
@@ -521,18 +521,18 @@ function Ot(e, t) {
521
521
  version: n.__VERSION__,
522
522
  name: n.name,
523
523
  state: ot(n.state).join(","),
524
- inject: at(n.inject).join(","),
525
- props: ct(n.props).join(","),
524
+ inject: ct(n.inject).join(","),
525
+ props: at(n.props).join(","),
526
526
  emits: lt(n.emits).join(","),
527
527
  watch: o.watches.join(","),
528
528
  lifeCycles: i.join(","),
529
529
  computed: P.join(","),
530
- methods: [...a, ...u].join(","),
530
+ methods: [...c, ...u].join(","),
531
531
  imports: m.join(`
532
532
  `),
533
- components: p.join(","),
533
+ components: f.join(","),
534
534
  returns: e.members.join(","),
535
- template: f.join(`
535
+ template: p.join(`
536
536
  `),
537
537
  css: n.css || "",
538
538
  style: kt(e.style),
@@ -585,13 +585,13 @@ export default defineComponent({
585
585
  </style>
586
586
  `, _t = J(Ct), At = J(Et);
587
587
  async function Rt(e, t = /* @__PURE__ */ new Map(), n = [], s) {
588
- const i = new it(K(e), n), r = Ot(i, t), o = _t(r), a = At({
588
+ const i = new it(K(e), n), r = Ot(i, t), o = _t(r), c = At({
589
589
  template: r.template,
590
590
  css: await W(r.css, s),
591
591
  script: await nt(o, s),
592
592
  style: await W(r.style, s)
593
593
  });
594
- return await V(a, s).catch((c) => (c.content = a, c));
594
+ return await V(c, s).catch((a) => (a.content = c, a));
595
595
  }
596
596
  async function Wt(e) {
597
597
  const t = `
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.8.67",
4
+ "version": "0.8.68",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "prettier": "~3.3.0",
8
- "@vtj/core": "~0.8.67",
9
- "@vtj/base": "~0.8.6"
8
+ "@vtj/base": "~0.8.6",
9
+ "@vtj/core": "~0.8.68"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@vtj/cli": "~0.8.17"
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.8.66
5
+ * @version 0.8.67
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.8.66";
8
+ export declare const version = "0.8.67";