@vtj/coder 0.8.37 → 0.8.39

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,32 +1,32 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@vtj/base"),x=require("prettier/standalone"),H=require("prettier/plugins/html"),X=require("prettier/plugins/babel"),Y=require("prettier/plugins/postcss"),Z=require("prettier/plugins/estree");function k(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const K=k(H),I=k(X),J=k(Y),T=k(Z);/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@vtj/base"),x=require("prettier/standalone"),H=require("prettier/plugins/html"),X=require("prettier/plugins/babel"),Y=require("prettier/plugins/postcss"),Z=require("prettier/plugins/estree");function k(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const K=k(H),J=k(X),T=k(Y),q=k(Z);/**!
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.37
5
+ * @version 0.8.39
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const ee="0.8.37";/**!
7
+ */const ee="0.8.39";/**!
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.37
11
+ * @version 0.8.39
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
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,I,T,J]})}async function ne(t,e){return e?t:await x.format(t,{parser:"babel-ts",..._,plugins:[I,T]})}async function W(t,e){return e?t:x.format(t,{parser:"scss",..._,plugins:[J]})}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 q(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(q(i)):q(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}: {
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}',
15
15
  default: ${u(e.default,!0,!1)}
16
16
  }`)}function ce(t=[]){const e=n=>n?`[${l.toArray(n).map(s=>s.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(n=>typeof n=="string"?`${n}: {}`:($(n.default)&&!n.default.value&&(n.default.value="undefined"),`${n.name}: {
17
17
  type:${e(n.type)},
18
18
  required: ${u(!!n.required,!0,!1)},
19
19
  default: ${u(n.default,!0,!1)}
20
- }`))}function le(t=[]){return t.map(e=>`'${e}'`)}function w(t={},e=[]){return Object.entries(t).map(([n,r])=>{let i=U(u(r,!1,!1));return i=b(i,e),i.startsWith("async")?`async ${n}${i.replace(/^async/,"")}`:`${n}${i}`})}function ue(t=[],e=[]){const n=t.reduce((s,o)=>(o.id&&A(o.source)&&(s[`watcher_${o.id}`]=o.source),s),{}),r=w(n,e),i=t.map(s=>`watcher_${s.id}: {
20
+ }`))}function le(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function w(t={},e=[]){return Object.entries(t).map(([n,r])=>{let i=U(u(r,!1,!1));return i=b(i,e),i.startsWith("async")?`async ${n}${i.replace(/^async/,"")}`:`${n}${i}`})}function ue(t=[],e=[]){const n=t.reduce((s,o)=>(o.id&&A(o.source)&&(s[`watcher_${o.id}`]=o.source),s),{}),r=w(n,e),i=t.map(s=>`watcher_${s.id}: {
21
21
  deep: ${s.deep},
22
22
  immediate:${s.immediate},
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
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(`
27
- `),Object.assign(o,y?.methods||{}),a=a.concat(y?.components||[]),c=c.concat(y?.importBlocks||[]));const R=Q(d)||z(d)?"component":h;j.push(h==="img"?`<${h} ${B} ${g} ${N} />`:`<${R} ${B} ${g} ${N}>${S?`
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
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 Q(t){return typeof t=="object"&&t.type==="UrlSchema"}function z(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(Q(i)||z(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:`{
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:`{
30
30
  return (${c.handler.value}).apply(this, args);
31
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}`}"`}>
32
32
  ${e}
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.37
11
+ * @version 0.8.39
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Bt = "0.8.37";
14
+ const Bt = "0.8.39";
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.37
19
+ * @version 0.8.39
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
22
  const et = [
@@ -160,7 +160,7 @@ class it {
160
160
  const s = n.pop(), i = n.join(".") + ".", r = n.pop();
161
161
  if (s && r) {
162
162
  const o = this.dependencies.find(
163
- (c) => c.library === r
163
+ (a) => a.library === r
164
164
  )?.package;
165
165
  o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(s);
166
166
  }
@@ -179,10 +179,10 @@ class it {
179
179
  for (const i of n) {
180
180
  const r = t.value.match(i) || [];
181
181
  for (const o of r) {
182
- const c = this.collectImport(o);
183
- if (c) {
184
- const a = c.path.replace(/\$/g, "\\$");
185
- s = s.replace(new RegExp(a, "g"), "");
182
+ const a = this.collectImport(o);
183
+ if (a) {
184
+ const c = a.path.replace(/\$/g, "\\$");
185
+ s = s.replace(new RegExp(c, "g"), "");
186
186
  }
187
187
  }
188
188
  }
@@ -210,16 +210,16 @@ class it {
210
210
  return k(n);
211
211
  }
212
212
  collectContext(t, n) {
213
- const s = new Set(n?.id ? this.context[n.id] : []), i = (t.directives || []).find((c) => c.name === "vFor");
213
+ const s = new Set(n?.id ? this.context[n.id] : []), i = (t.directives || []).find((a) => a.name === "vFor");
214
214
  let r = new Set(Array.from(s));
215
215
  if (i) {
216
- const { item: c = "item", index: a = "index" } = i.iterator || {};
217
- r = /* @__PURE__ */ new Set([c, a, ...Array.from(r)]);
216
+ const { item: a = "item", index: c = "index" } = i.iterator || {};
217
+ r = /* @__PURE__ */ new Set([a, c, ...Array.from(r)]);
218
218
  }
219
219
  const o = t.slot;
220
220
  if (o) {
221
- const c = typeof o == "string" ? [] : o.params || [], a = c.length ? c : [`scope_${n?.id}`];
222
- r = /* @__PURE__ */ new Set([...a, ...Array.from(r)]);
221
+ const a = typeof o == "string" ? [] : o.params || [], c = a.length ? a : [`scope_${n?.id}`];
222
+ r = /* @__PURE__ */ new Set([...c, ...Array.from(r)]);
223
223
  }
224
224
  this.context[t.id] = r;
225
225
  }
@@ -245,13 +245,13 @@ function ot(e = {}) {
245
245
  return `${t}:${s}`;
246
246
  });
247
247
  }
248
- function ct(e = []) {
248
+ function at(e = []) {
249
249
  return e.map((t) => `${t.name}: {
250
250
  from: '${t.from || t.name}',
251
251
  default: ${l(t.default, !0, !1)}
252
252
  }`);
253
253
  }
254
- function at(e = []) {
254
+ function ct(e = []) {
255
255
  const t = (n) => n ? `[${Y(n).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
256
256
  return e.map((n) => typeof n == "string" ? `${n}: {}` : ($(n.default) && !n.default.value && (n.default.value = "undefined"), `${n.name}: {
257
257
  type:${t(n.type)},
@@ -260,7 +260,7 @@ function at(e = []) {
260
260
  }`));
261
261
  }
262
262
  function lt(e = []) {
263
- return e.map((t) => `'${t}'`);
263
+ return e.map((t) => `'${typeof t == "string" ? t : t.name}'`);
264
264
  }
265
265
  function w(e = {}, t = []) {
266
266
  return Object.entries(e).map(([n, s]) => {
@@ -292,7 +292,7 @@ function pt(e = {}) {
292
292
  }
293
293
  function D(e, t, n = [], s = {}, i) {
294
294
  const r = [];
295
- let o = {}, c = [], a = [];
295
+ let o = {}, a = [], c = [];
296
296
  return ft(e).forEach((p) => {
297
297
  const v = [];
298
298
  for (const u of p.children) {
@@ -300,7 +300,7 @@ function D(e, t, n = [], s = {}, i) {
300
300
  if (O)
301
301
  continue;
302
302
  const j = mt(m, t, h);
303
- j && c.push(j), Q(h) && a.push({ id: h.id, name: m });
303
+ j && a.push(j), Q(h) && c.push({ id: h.id, name: m });
304
304
  const { props: g, events: N, handlers: H } = $t(
305
305
  u,
306
306
  x,
@@ -320,7 +320,7 @@ function D(e, t, n = [], s = {}, i) {
320
320
  Object.assign(o, H);
321
321
  let S = "";
322
322
  typeof d == "string" ? S = d : (S = (d?.nodes || []).join(`
323
- `), Object.assign(o, d?.methods || {}), c = c.concat(d?.components || []), a = a.concat(d?.importBlocks || []));
323
+ `), Object.assign(o, d?.methods || {}), a = a.concat(d?.components || []), c = c.concat(d?.importBlocks || []));
324
324
  const R = z(h) || G(h) ? "component" : m;
325
325
  v.push(
326
326
  m === "img" ? `<${m} ${B} ${g} ${N} />` : `<${R} ${B} ${g} ${N}>${S ? `
@@ -333,8 +333,8 @@ function D(e, t, n = [], s = {}, i) {
333
333
  }), {
334
334
  nodes: r,
335
335
  methods: o,
336
- components: k(c),
337
- importBlocks: k(a, "id")
336
+ components: k(a),
337
+ importBlocks: k(c, "id")
338
338
  };
339
339
  }
340
340
  function ft(e = []) {
@@ -393,23 +393,23 @@ function yt(e, t, n, s) {
393
393
  function gt(e, t = {}, n = {}) {
394
394
  const s = {}, i = Array.from(n[e] || /* @__PURE__ */ new Set([])), r = i.length ? `({${i.join(", ")}}, args)` : "";
395
395
  return {
396
- binders: Object.entries(t).map(([c, a]) => {
397
- const f = a.handler.value.startsWith("this."), p = f ? F(a.handler.value) : `${y(c)}_${e}${r}`;
396
+ binders: Object.entries(t).map(([a, c]) => {
397
+ const f = c.handler.value.startsWith("this."), p = f ? F(c.handler.value) : `${y(a)}_${e}${r}`;
398
398
  return f || (s[p] = i.length ? {
399
399
  type: "JSFunction",
400
400
  value: `{
401
- return (${a.handler.value}).apply(this, args);
401
+ return (${c.handler.value}).apply(this, args);
402
402
  }`
403
- } : a.handler), yt(c, a, p, i);
403
+ } : c.handler), yt(a, c, p, i);
404
404
  }),
405
405
  handlers: s
406
406
  };
407
407
  }
408
408
  function $t(e, t, n = {}, s = {}, i = {}, r) {
409
- const { binders: o, handlers: c } = gt(t, s, i);
409
+ const { binders: o, handlers: a } = gt(t, s, i);
410
410
  return {
411
411
  props: dt(e, n, r).join(" "),
412
- handlers: c,
412
+ handlers: a,
413
413
  binders: o,
414
414
  events: o.join(" ")
415
415
  };
@@ -418,15 +418,15 @@ function bt(e = [], t = []) {
418
418
  const n = [], { vIf: s, vShow: i, vModels: r, vFor: o } = vt(e);
419
419
  if (s && n.push(`v-if="${l(s.value, !0, !0, t)}"`), i && n.push(
420
420
  `v-show="${l(i.value, !0, !0, t)}"`
421
- ), r.forEach((c) => {
422
- const a = M(c.modifiers, !0), f = c.arg ? _(c.arg) ? `:[${l(c.arg, !0, !0, t)}]` : `:${c.arg}` : "";
421
+ ), r.forEach((a) => {
422
+ const c = M(a.modifiers, !0), f = a.arg ? _(a.arg) ? `:[${l(a.arg, !0, !0, t)}]` : `:${a.arg}` : "";
423
423
  n.push(
424
- `v-model${f}${a}="${l(c.value, !0, !0, t)}"`
424
+ `v-model${f}${c}="${l(a.value, !0, !0, t)}"`
425
425
  );
426
426
  }), o) {
427
- const { item: c, index: a } = { item: "item", index: "index", ...o.iterator };
427
+ const { item: a, index: c } = { item: "item", index: "index", ...o.iterator };
428
428
  n.push(
429
- `v-for="(${c}, ${a}) in ${l(o.value, !0, !0, t)}"`
429
+ `v-for="(${a}, ${c}) in ${l(o.value, !0, !0, t)}"`
430
430
  );
431
431
  }
432
432
  return n;
@@ -500,14 +500,14 @@ function xt(e = {}) {
500
500
  }), t;
501
501
  }
502
502
  function Ot(e, t) {
503
- 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: f, components: p, importBlocks: v } = D(
503
+ 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(
504
504
  n.nodes || [],
505
505
  t,
506
506
  s,
507
507
  e.context
508
508
  ), P = [...r, ...o.computed], u = w(
509
509
  {
510
- ...a,
510
+ ...c,
511
511
  ...n.methods || {}
512
512
  },
513
513
  s
@@ -525,13 +525,13 @@ function Ot(e, t) {
525
525
  version: n.__VERSION__,
526
526
  name: n.name,
527
527
  state: ot(n.state).join(","),
528
- inject: ct(n.inject).join(","),
529
- props: at(n.props).join(","),
528
+ inject: at(n.inject).join(","),
529
+ props: ct(n.props).join(","),
530
530
  emits: lt(n.emits).join(","),
531
531
  watch: o.watches.join(","),
532
532
  lifeCycles: i.join(","),
533
533
  computed: P.join(","),
534
- methods: [...c, ...u].join(","),
534
+ methods: [...a, ...u].join(","),
535
535
  imports: m.join(`
536
536
  `),
537
537
  components: p.join(","),
@@ -589,13 +589,13 @@ export default defineComponent({
589
589
  </style>
590
590
  `, _t = J(Ct), At = J(Et);
591
591
  async function Rt(e, t = /* @__PURE__ */ new Map(), n = [], s) {
592
- const i = new it(K(e), n), r = Ot(i, t), o = _t(r), c = At({
592
+ const i = new it(K(e), n), r = Ot(i, t), o = _t(r), a = At({
593
593
  template: r.template,
594
594
  css: await W(r.css, s),
595
595
  script: await nt(o, s),
596
596
  style: await W(r.style, s)
597
597
  });
598
- return await V(c, s).catch((a) => (a.content = c, a));
598
+ return await V(a, s).catch((c) => (c.content = a, c));
599
599
  }
600
600
  async function Wt(e) {
601
601
  const t = `
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.8.37",
4
+ "version": "0.8.39",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "prettier": "~3.2.1",
8
- "@vtj/core": "~0.8.37",
8
+ "@vtj/core": "~0.8.39",
9
9
  "@vtj/base": "~0.8.4"
10
10
  },
11
11
  "devDependencies": {
@@ -1 +1,3 @@
1
- export declare function parseEmits(emits?: string[]): string[];
1
+ import { BlockEmit } from '@vtj/core';
2
+
3
+ export declare function parseEmits(emits?: Array<string | BlockEmit>): string[];
@@ -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.37
5
+ * @version 0.8.38
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.8.37";
8
+ export declare const version = "0.8.38";