@vtj/coder 0.16.26 → 0.16.28

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,51 +1,49 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@vtj/base"),D=require("prettier/standalone"),K=require("prettier/plugins/html"),ee=require("prettier/plugins/babel"),te=require("prettier/plugins/postcss"),se=require("prettier/plugins/estree");function N(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const ne=N(K),q=N(ee),M=N(te),U=N(se);/**!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@vtj/base"),T=require("prettier/standalone"),Y=require("prettier/plugins/html"),K=require("prettier/plugins/babel"),ee=require("prettier/plugins/postcss"),te=require("prettier/plugins/estree");function N(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const se=N(Y),J=N(K),q=N(ee),M=N(te);/**!
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.16.26
5
+ * @version 0.16.28
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const re="0.16.26";/**!
7
+ */const ne="0.16.28";/**!
8
8
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
9
9
  * @name @vtj/core
10
10
  * @author CHC chenhuachun1549@dingtalk.com
11
- * @version 0.16.26
11
+ * @version 0.16.28
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
- */const ie=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const T={arrowParens:"always",bracketSpacing:!0,bracketSameLine:!0,endOfLine:"lf",htmlWhitespaceSensitivity:"css",insertPragma:!1,jsxBracketSameLine:!0,jsxSingleQuote:!0,printWidth:80,proseWrap:"preserve",quoteProps:"as-needed",requirePragma:!1,semi:!0,singleQuote:!0,tabWidth:2,trailingComma:"none",useTabs:!1,vueIndentScriptAndStyle:!0};async function B(t,e){return e?t:await D.format(t,{parser:"vue",...T,plugins:[ne,q,U,M]})}async function V(t,e){if(e)return t;try{return(await D.format(t,{parser:"babel-ts",...T,plugins:[q,U]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function F(t,e){return e?t:D.format(t,{parser:"scss",...T,plugins:[M]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function L(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[],i=!0){let r=t;return j(t)?(r=t.value.trim().replace(/;$/,""),i&&(r=r.replace(/\"/g,"'"))):r=e?JSON.stringify(r):t,r=w(r,n),s?H(L(r)):L(r)}function w(t="",e=[]){let s=t;for(const n of e)s=s.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return s}function Q(t){let e=t.trim().replace(/;$/,"");if(e=/^\((\(|async|function)/.test(e)?e.substring(1,e.length-1):e,e.startsWith("{"))return e;if(e.startsWith("async function"))e=e.replace(/^async function/,"async");else if(e.startsWith("function"))e=e.replace(/^function/,"");else{const i=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,r=e.match(i);r&&r[2]&&(r[2].startsWith("{")||(e=e.replace(r[2],`{ return ${r[2]} }`))),e=e.replace("=>","")}return e}function oe(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${d(s)}`)}function z(t={},e=!1){const s=Object.keys(t);return e?s.map(n=>"."+n):s}function ae(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];e+=s+": "+n+";"}return e}function ce(t=[],e=[]){return t.filter(s=>!e.includes(s))}function R(t){return f.base64(JSON.stringify(t))}class le{constructor(e,s){this.dsl=e,this.dependencies=s,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const s=e.split(".");if(s.length===4){const n=s.pop(),i=s.join(".")+".",r=s.pop();if(n&&r){const o=this.dependencies.find(a=>a.library===r)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:i,library:r}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let n=e.value;for(const i of s){const r=e.value?.match(i)||[];for(const o of r){const a=this.collectImport(o);if(a){const m=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(m,"g"),"")}}}return n}walk(e){const s=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let r of n)s(r);return}const i=Object.values(n);for(const r of i)j(r)?r.value=this.replaceLibraryPath(r):s(r)};s(e)}getLibraryMember(e=[]){let s=[...e];const n={...this.imports};delete n["uni-h5"],delete n["@dcloudio/uni-h5"],delete n["uni-ui"],delete n["@dcloudio/uni-ui"];for(const i of Object.values(n))s=s.concat(Array.from(i));return f.dedupArray(s)}collectContext(e,s){const n=new Set(s?.id?this.context[s.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let r=new Set(Array.from(n));if(i){const{item:a="item",index:m="index"}=i.iterator||{};r=new Set([a,m,...Array.from(r)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],m=a.length?a:[`scope_${s?.id}`];r=new Set([...m,...Array.from(r)])}this.context[e.id]=r}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!j(e.props.style)&&(this.style[`.${e.name}_${e.id}`]=e.props.style)}collectUrlSchema(e){typeof e.from=="object"&&e.from.type==="UrlSchema"&&(this.urlSchemas[e.name]=e.from)}collectBlockPlugin(e){typeof e.from=="object"&&e.from.type==="Plugin"&&(this.blockPlugins[e.name]=e.from)}walkNodes(e){const s=(n,i)=>{this.collectContext(n,i),this.collectStyle(n),this.collectUrlSchema(n),this.collectBlockPlugin(n),Array.isArray(n.children)&&n.children.forEach(r=>s(r,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>s(n))}}function ue(t={}){return Object.entries(t).map(([e,s])=>{const n=d(s,!1,!0,[],!1);return`${e}:${n}`})}function pe(t=[]){return t.map(e=>`${e.name}: {
13
+ */const re=["slot","template","component","img","div","p","h1","h2","h3","span","a"];m.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 W(t,e){return e?t:await T.format(t,{parser:"vue",...B,plugins:[se,J,M,q]})}async function U(t,e){if(e)return t;try{return(await T.format(t,{parser:"babel-ts",...B,plugins:[J,M]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function F(t,e){return e?t:T.format(t,{parser:"scss",...B,plugins:[q]})}function w(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return w(t)||I(t)}function V(t){return t.replace(new RegExp("this.","g"),"")}function D(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[],i=!0){let r=t;return j(t)?(r=t.value.trim().replace(/;$/,""),i&&(r=r.replace(/\"/g,"'"))):r=e?JSON.stringify(r):t,r=C(r,n),s?V(D(r)):D(r)}function C(t="",e=[]){let s=t;for(const n of e)s=s.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return s}function H(t){let e=t.trim().replace(/;$/,"");if(e=/^\((\(|async|function)/.test(e)?e.substring(1,e.length-1):e,e.startsWith("{"))return e;if(e.startsWith("async function"))e=e.replace(/^async function/,"async");else if(e.startsWith("function"))e=e.replace(/^function/,"");else{const i=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,r=e.match(i);r&&r[2]&&(r[2].startsWith("{")||(e=e.replace(r[2],`{ return ${r[2]} }`))),e=e.replace("=>","")}return e}function ie(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${d(s)}`)}function Q(t={},e=!1){const s=Object.keys(t);return e?s.map(n=>"."+n):s}function oe(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];e+=s+": "+n+";"}return e}function ae(t=[],e=[]){return t.filter(s=>!e.includes(s))}function L(t){return m.base64(JSON.stringify(t))}class ce{constructor(e,s){this.dsl=e,this.dependencies=s,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const s=e.split(".");if(s.length===4){const n=s.pop(),i=s.join(".")+".",r=s.pop();if(n&&r){const o=this.dependencies.find(c=>c.library===r)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:i,library:r}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let n=e.value;for(const i of s){const r=e.value?.match(i)||[];for(const o of r){const c=this.collectImport(o);if(c){const h=c.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(h,"g"),"")}}}return n}walk(e){const s=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let r of n)s(r);return}const i=Object.values(n);for(const r of i)j(r)?r.value=this.replaceLibraryPath(r):s(r)};s(e)}getLibraryMember(e=[]){let s=[...e];const n={...this.imports};delete n["uni-h5"],delete n["@dcloudio/uni-h5"],delete n["uni-ui"],delete n["@dcloudio/uni-ui"];for(const i of Object.values(n))s=s.concat(Array.from(i));return m.dedupArray(s)}collectContext(e,s){const n=new Set(s?.id?this.context[s.id]:[]),i=(e.directives||[]).find(c=>c.name==="vFor");let r=new Set(Array.from(n));if(i){const{item:c="item",index:h="index"}=i.iterator||{};r=new Set([c,h,...Array.from(r)])}const o=e.slot;if(o){const c=typeof o=="string"?[]:o.params||[],h=c.length?c:[`scope_${s?.id}`];r=new Set([...h,...Array.from(r)])}this.context[e.id]=r}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!j(e.props.style)&&(this.style[`.${e.name}_${e.id}`]=e.props.style)}collectUrlSchema(e){typeof e.from=="object"&&e.from.type==="UrlSchema"&&(this.urlSchemas[e.name]=e.from)}collectBlockPlugin(e){typeof e.from=="object"&&e.from.type==="Plugin"&&(this.blockPlugins[e.name]=e.from)}walkNodes(e){const s=(n,i)=>{this.collectContext(n,i),this.collectStyle(n),this.collectUrlSchema(n),this.collectBlockPlugin(n),Array.isArray(n.children)&&n.children.forEach(r=>s(r,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>s(n))}}function le(t={}){return Object.entries(t).map(([e,s])=>{const n=d(s,!1,!0,[],!1);return`${e}:${n}`})}function ue(t=[]){return t.map(e=>`${e.name}: {
14
14
  from: '${e.from||e.name}',
15
15
  default: ${d(e.default,!0,!1,[],!1)}
16
- }`)}function fe(t=[]){const e=s=>s?`[${f.toArray(s).map(r=>r.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(s=>typeof s=="string"?`${s}: {}`:(j(s.default)&&!s.default.value&&(s.default.value="undefined"),`${s.name}: {
16
+ }`)}function pe(t=[]){const e=s=>s?`[${m.toArray(s).map(r=>r.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(s=>typeof s=="string"?`${s}: {}`:(j(s.default)&&!s.default.value&&(s.default.value="undefined"),`${s.name}: {
17
17
  type:${e(s.type)},
18
18
  required: ${d(!!s.required,!0,!1,[],!1)},
19
19
  default: ${s.default?d(s.default,!0,!1,[],!1):"undefined"}
20
- }`))}function me(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([s,n])=>{let i=Q(d(n,!1,!1,[],!1));return i=w(i,e)?.trim(),i.startsWith("async")?`async ${s}${i.replace(/^async/,"")}`:i.startsWith("(")||i.startsWith("{")?`${s}${i}`:null}).filter(s=>!!s)}function he(t=[],e=[]){const s=t.reduce((r,o)=>(o.id&&I(o.source)&&(r[`watcher_${o.id}`]=o.source),r),{}),n=A(s,e),i=t.map(r=>r.handler&&r.handler.value?`watcher_${r.id}: {
20
+ }`))}function fe(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([s,n])=>{let i=H(d(n,!1,!1,[],!1));return i=C(i,e)?.trim(),i.startsWith("async")?`async ${s}${i.replace(/^async/,"")}`:i.startsWith("(")||i.startsWith("{")?`${s}${i}`:null}).filter(s=>!!s)}function me(t=[],e=[]){const s=t.reduce((r,o)=>(o.id&&I(o.source)&&(r[`watcher_${o.id}`]=o.source),r),{}),n=A(s,e),i=t.map(r=>r.handler&&r.handler.value?`watcher_${r.id}: {
21
21
  deep: ${r.deep},
22
22
  immediate:${r.immediate},
23
- handler${Q(r.handler.value)}
23
+ handler${H(r.handler.value)}
24
24
  }`:null).filter(r=>!!r);return{computed:n,watches:i}}function de(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const s=I(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args) {
25
- // DataSource: ${R(e)}
25
+ // DataSource: ${L(e)}
26
26
  const mock = this.provider.createMock(${s});
27
27
  return await mock.apply(this, args);
28
28
  }`}else{const s=I(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args) {
29
- // DataSource: ${R(e)}
29
+ // DataSource: ${L(e)}
30
30
  return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
31
- }`}})}const ge=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],J=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"];function G(t,e,s=[],n={},i){const r=[];let o={},a=[];const m=[];let u=[];return ve(t).forEach(c=>{const v=[];for(const h of c.children){let{id:g,name:$,invisible:b,from:y}=h;if(b)continue;const C=$e($,e,y);C&&a.push(C),Z(y)&&u.push({id:y.id,name:$});const{props:O,events:P,handlers:x}=we(h,g,h.props,h.events,n,s),W=Ce(h.directives,s,m).join(" "),S=h.children?Pe(h.children,s,e,n,h):"";Object.assign(o,x);let E="";typeof S=="string"?E=S:(E=(S?.nodes||[]).join(`
32
- `),Object.assign(o,S?.methods||{}),a=a.concat(S?.components||[]),u=u.concat(S?.importBlocks||[]));const _=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes(y||e.get($)?.package)?f.kebabCase($):X(y)||Y(y)?"component":$;v.push(ge.includes(_)?`<${_} ${W} ${O} ${P} />`:`<${_} ${W} ${O} ${P}>${E?`
33
- `+E.trim():""}</${_}>`)}const p=xe(c.slot,v.join(`
34
- `),i?.id);r.push(p)}),{nodes:r,methods:o,directives:ye(m),components:f.dedupArray(a),importBlocks:f.dedupArray(u,"id")}}function ye(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ve(t=[]){const e=new Map;for(const s of t){const n=typeof s.slot=="string"?s.slot:s.slot?.name,i=e.get(n);i?i.children.push(s):e.set(n,{slot:s.slot,children:[s]})}return e}function $e(t,e,s){if(ie.includes(t))return null;const n=e.get(t);if(n&&n.alias){const i=n.parent?`${n.parent}.${n.alias}`:n.alias;return`${t}: ${i}`}return Z(s)||n?t:null}function Z(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 be(t,e,s=[]){return t==="style"?j(e)?`:style="${d({...e,value:w(e.value,s)})}"`:"":t==="__class"&&j(e)?`:class="${d({...e,value:w(e.value,s)})}"`:typeof e=="string"?`${t}="${e}"`:j(e)?`:${t}="${d({...e,value:w(e.value,s)})}"`:f.isPlainObject(e)?`:${t}='{${oe(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function je(t,e={},s=[]){if(!!Object.keys(e.style||{}).length){const r=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,r].join(" "):(e.__class=e.class,e.class=r):e.class=r,j(e.style)||delete e.style}const i=t.from;return(X(i)||Y(i))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([r,o])=>be(r,o,s))}function Se(t,e,s,n,i){const r=z(e.modifiers,!0);return i?`@${t}${r.join("")}="${s}"`:n&&n.length>0?`@${t}${r.join("")}="(...args:any[]) => ${s}"`:`@${t}${r.join("")}="${s}"`}function ke(t,e={},s={}){const n={},i=Array.from(s[t]||new Set([])),r=i.length?`({${i.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,m])=>{const u=m.handler.value.startsWith("this."),l=u?H(m.handler.value):`${f.camelCase(a)}_${t}${r}`;return u||(n[l]=i.length?{type:"JSFunction",value:`{
35
- return (${m.handler.value}).apply(this, args);
36
- }`}:m.handler),Se(a,m,l,i,u)}),handlers:n}}function we(t,e,s={},n={},i={},r){const{binders:o,handlers:a}=ke(e,n,i);return{props:je(t,s,r).join(" "),handlers:a,binders:o,events:o.join(" ")}}function Ce(t=[],e=[],s=[]){const n=[],{vIf:i,vElse:r,vElseIf:o,vShow:a,vModels:m,vFor:u,vBind:l,vHtml:c,customDirectives:v}=Oe(t);if(i&&n.push(`v-if="${d(i.value,!0,!0,e)}"`),o&&n.push(`v-else-if="${d(o.value,!0,!0,e)}"`),r&&n.push("v-else"),a&&n.push(`v-show="${d(a.value,!0,!0,e)}"`),l&&n.push(`v-bind="${d(l.value,!0,!0,e)}"`),m.forEach(p=>{const h=z(p.modifiers,!0),g=p.arg?k(p.arg)?`:[${d(p.arg,!0,!0,e)}]`:`:${p.arg}`:"";n.push(`v-model${g}${h}="${d(p.value,!0,!0,e)}"`)}),u){const{item:p,index:h}={item:"item",index:"index",...u.iterator};n.push(`v-for="(${p}, ${h}) in ${d(u.value,!0,!0,e)}"`)}return c&&n.push(`v-html="${d(c.value,!0,!0,e)}"`),v&&v.length&&v.forEach(p=>{if(!p.name)return;let h="",g="";k(p.name)?(g=d(p.name,!0,!0,e),s.push(g)):g=p.name;const $=g?.startsWith("v")?f.kebabCase(g):f.kebabCase("v-"+g);if(h+=$,p.arg&&(k(p.arg)?h+=`:[${d(p.name,!0,!0,e)}]`:h+=`:${p.arg}`),p.modifiers){const b=Object.keys(p.modifiers);b.length&&(h+=b.map(y=>"."+y))}p.value?n.push(`${h}="${d(p.value,!0,!0,e)}"`):n.push(h)}),n}function Oe(t=[]){const e=t.filter(c=>J.includes(c.name)),s=t.filter(c=>!J.includes(c.name)),n=e.find(c=>f.camelCase(c.name)==="vIf"),i=e.find(c=>f.camelCase(c.name)==="vElseIf"),r=e.find(c=>f.camelCase(c.name)==="vElse"),o=e.find(c=>f.camelCase(c.name)==="vFor"),a=e.find(c=>f.camelCase(c.name)==="vShow"),m=e.find(c=>f.camelCase(c.name)==="vBind"),u=e.find(c=>f.camelCase(c.name)==="vHtml"),l=e.filter(c=>f.camelCase(c.name)==="vModel");return{vIf:n,vElseIf:i,vElse:r,vFor:o,vShow:a,vModels:l,vBind:m,vHtml:u,customDirectives:s}}function Pe(t,e,s,n,i){return typeof t=="string"?t:k(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?G(t,s,e,n,i):""}function xe(t,e,s){if(!t)return e;const n=typeof t=="string"?{name:t,params:[],scope:""}:{params:[],scope:"",...t};return`<template ${`#${n.name}="${n.scope?n.scope:n.params?.length>0?`{${n.params?.join(",")}}`:`scope_${s}`}"`}>
31
+ }`}})}const he=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],R=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"];function z(t,e,s=[],n={},i){const r=[];let o={},c=[];const h=[];let p=[];return ge(t).forEach(a=>{const v=[];for(const f of a.children){let{id:y,name:b,invisible:$,from:g}=f;if($)continue;const O=ve(b,e,g);O&&c.push(O),G(g)&&p.push({id:g.id,name:b});const{props:P,events:x}=ke(f,y,f.props,f.events,n,s),k=we(f.directives,s,h).join(" "),S=f.children?Oe(f.children,s,e,n,f):"";let E="";typeof S=="string"?E=S:(E=(S?.nodes||[]).join(`
32
+ `),Object.assign(o,S?.methods||{}),c=c.concat(S?.components||[]),p=p.concat(S?.importBlocks||[]));const _=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes(g||e.get(b)?.package)?m.kebabCase(b):Z(g)||X(g)?"component":b;v.push(he.includes(_)?`<${_} ${k} ${P} ${x} />`:`<${_} ${k} ${P} ${x}>${E?`
33
+ `+E.trim():""}</${_}>`)}const l=Pe(a.slot,v.join(`
34
+ `),i?.id);r.push(l)}),{nodes:r,methods:o,directives:ye(h),components:m.dedupArray(c),importBlocks:m.dedupArray(p,"id")}}function ye(t){return m.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ge(t=[]){const e=new Map;for(const s of t){const n=typeof s.slot=="string"?s.slot:s.slot?.name,i=e.get(n);i?i.children.push(s):e.set(n,{slot:s.slot,children:[s]})}return e}function ve(t,e,s){if(re.includes(t))return null;const n=e.get(t);if(n&&n.alias){const i=n.parent?`${n.parent}.${n.alias}`:n.alias;return`${t}: ${i}`}return G(s)||n?t:null}function G(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function Z(t){return typeof t=="object"&&t.type==="UrlSchema"}function X(t){return typeof t=="object"&&t.type==="Plugin"}function be(t,e,s=[]){return t==="style"?j(e)?`:style="${d({...e,value:C(e.value,s)})}"`:"":t==="__class"&&j(e)?`:class="${d({...e,value:C(e.value,s)})}"`:typeof e=="string"?`${t}="${e}"`:j(e)?`:${t}="${d({...e,value:C(e.value,s)})}"`:m.isPlainObject(e)?`:${t}='{${ie(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function $e(t,e={},s=[]){if(!!Object.keys(e.style||{}).length){const r=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,r].join(" "):(e.__class=e.class,e.class=r):e.class=r,j(e.style)||delete e.style}const i=t.from;return(Z(i)||X(i))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([r,o])=>be(r,o,s))}function je(t,e,s){const n=Q(e.modifiers,!0);return`@${t}${n.join("")}="${s}"`}function Se(t,e={},s={}){const n={};return{binders:Object.entries(e).map(([r,o])=>{const c=V(D(o.handler.value)).replace(/\"/g,"'");return je(r,o,c)}),handlers:n}}function ke(t,e,s={},n={},i={},r){const{binders:o,handlers:c}=Se(e,n,i);return{props:$e(t,s,r).join(" "),handlers:c,binders:o,events:o.join(" ")}}function we(t=[],e=[],s=[]){const n=[],{vIf:i,vElse:r,vElseIf:o,vShow:c,vModels:h,vFor:p,vBind:u,vHtml:a,customDirectives:v}=Ce(t);if(i&&n.push(`v-if="${d(i.value,!0,!0,e)}"`),o&&n.push(`v-else-if="${d(o.value,!0,!0,e)}"`),r&&n.push("v-else"),c&&n.push(`v-show="${d(c.value,!0,!0,e)}"`),u&&n.push(`v-bind="${d(u.value,!0,!0,e)}"`),h.forEach(l=>{const f=Q(l.modifiers,!0),y=l.arg?w(l.arg)?`:[${d(l.arg,!0,!0,e)}]`:`:${l.arg}`:"";n.push(`v-model${y}${f}="${d(l.value,!0,!0,e)}"`)}),p){const{item:l,index:f}={item:"item",index:"index",...p.iterator};n.push(`v-for="(${l}, ${f}) in ${d(p.value,!0,!0,e)}"`)}return a&&n.push(`v-html="${d(a.value,!0,!0,e)}"`),v&&v.length&&v.forEach(l=>{if(!l.name)return;let f="",y="";w(l.name)?(y=d(l.name,!0,!0,e),s.push(y)):y=l.name;const b=y?.startsWith("v")?m.kebabCase(y):m.kebabCase("v-"+y);if(f+=b,l.arg&&(w(l.arg)?f+=`:[${d(l.name,!0,!0,e)}]`:f+=`:${l.arg}`),l.modifiers){const $=Object.keys(l.modifiers);$.length&&(f+=$.map(g=>"."+g))}l.value?n.push(`${f}="${d(l.value,!0,!0,e)}"`):n.push(f)}),n}function Ce(t=[]){const e=t.filter(a=>R.includes(a.name)),s=t.filter(a=>!R.includes(a.name)),n=e.find(a=>m.camelCase(a.name)==="vIf"),i=e.find(a=>m.camelCase(a.name)==="vElseIf"),r=e.find(a=>m.camelCase(a.name)==="vElse"),o=e.find(a=>m.camelCase(a.name)==="vFor"),c=e.find(a=>m.camelCase(a.name)==="vShow"),h=e.find(a=>m.camelCase(a.name)==="vBind"),p=e.find(a=>m.camelCase(a.name)==="vHtml"),u=e.filter(a=>m.camelCase(a.name)==="vModel");return{vIf:n,vElseIf:i,vElse:r,vFor:o,vShow:c,vModels:u,vBind:h,vHtml:p,customDirectives:s}}function Oe(t,e,s,n,i){return typeof t=="string"?t:w(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?z(t,s,e,n,i):""}function Pe(t,e,s){if(!t)return e;const n=typeof t=="string"?{name:t,params:[],scope:""}:{params:[],scope:"",...t};return`<template ${`#${n.name}="${n.scope?n.scope:n.params?.length>0?`{${n.params?.join(",")}}`:`scope_${s}`}"`}>
37
35
  ${e}
38
- </template>`}function Ee(t,e=[],s=[],n={},i="web"){const r=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],o={vue:["defineComponent","reactive"]},a=[];for(const u of e){const l=t.get(u.split(":")[0]);if(l&&l.package){const c=o[l.package]??(o[l.package]=[]),v=l.parent||(l.alias||"").split(".")[0]||l.name;c.push(v),i==="uniapp"&&r.includes(l.package)&&a.push(v)}}for(const[u,l]of Object.entries(n))(o[u]??(o[u]=[])).push(...Array.from(l)),i==="uniapp"&&r.includes(u)&&a.push(...Array.from(l));return{imports:Object.entries(o).filter(([u,l])=>i==="uniapp"?!r.includes(u)&&!!l.length:!!l.length).map(([u,l])=>`import { ${f.dedupArray(l).join(",")}} from '${u}';`).concat(s),uniComponents:a}}function _e(t={}){const e=[];for(const[s,n]of Object.entries(t))e.push(`
36
+ </template>`}function xe(t,e=[],s=[],n={},i="web"){const r=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],o={vue:["defineComponent","reactive"]},c=[];for(const p of e){const u=t.get(p.split(":")[0]);if(u&&u.package){const a=o[u.package]??(o[u.package]=[]),v=u.parent||(u.alias||"").split(".")[0]||u.name;a.push(v),i==="uniapp"&&r.includes(u.package)&&c.push(v)}}for(const[p,u]of Object.entries(n))(o[p]??(o[p]=[])).push(...Array.from(u)),i==="uniapp"&&r.includes(p)&&c.push(...Array.from(u));return{imports:Object.entries(o).filter(([p,u])=>i==="uniapp"?!r.includes(p)&&!!u.length:!!u.length).map(([p,u])=>`import { ${m.dedupArray(u).join(",")}} from '${p}';`).concat(s),uniComponents:c}}function Ee(t={}){const e=[];for(const[s,n]of Object.entries(t))e.push(`
39
37
  ${s} {
40
- ${ae(n)}
38
+ ${oe(n)}
41
39
  }
42
40
  `);return e.join(`
43
- `)}function Ae(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.defineUrlSchemaComponent('${n.url}');`)}),e}function Ie(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.definePluginComponent(${JSON.stringify(n)});`)}),e}function Ne(t,e,s="web"){const{dsl:n}=t,i=Object.keys(n.computed||{}),r=A(n.lifeCycles,i),o=A(n.computed,i),a=he(n.watch,i),m=de(n.dataSources),{methods:u,nodes:l,components:c,importBlocks:v,directives:p}=G(n.nodes||[],e,i,t.context),h=[...o,...a.computed],g=A({...u,...n.methods||{}},i),$=v.map(x=>`import ${x.name} from './${x.id}.vue';`);let{imports:b,uniComponents:y}=Ee(e,c,$,t.imports,s);const C=Object.keys({...t.urlSchemas,...t.blockPlugins}),O=Ae(t.urlSchemas),P=Ie(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:ue(n.state).join(","),inject:pe(n.inject).join(","),props:fe(n.props).join(","),emits:me(n.emits).join(","),expose:n.expose&&n.expose.length?JSON.stringify(n.expose||[]):"",watch:a.watches.join(","),lifeCycles:r.join(","),computed:h.join(","),methods:[...m,...g].join(","),imports:`
44
- `+b.join(`
45
- `),components:ce(c,y).join(","),directives:p.join(","),returns:t.members.join(","),template:l.join(`
46
- `),css:n.css||"",style:_e(t.style),urlSchemas:O.join(`
47
- `),blockPlugins:P.join(`
48
- `),asyncComponents:C.join(","),uniComponents:y,renderer:s==="uniapp"?"@vtj/uni-app":"@vtj/renderer"}}const Fe=`
41
+ `)}function _e(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.defineUrlSchemaComponent('${n.url}');`)}),e}function Ae(t={}){const e=[];return Object.entries(t).forEach(([s,n])=>{e.push(`const ${s} = provider.definePluginComponent(${JSON.stringify(n)});`)}),e}function Ie(t,e,s="web"){const{dsl:n}=t,i=Object.keys(n.computed||{}),r=A(n.lifeCycles,i),o=A(n.computed,i),c=me(n.watch,i),h=de(n.dataSources),{methods:p,nodes:u,components:a,importBlocks:v,directives:l}=z(n.nodes||[],e,i,t.context),f=[...o,...c.computed],y=A({...p,...n.methods||{}},i),b=v.map(k=>`import ${k.name} from './${k.id}.vue';`);let{imports:$,uniComponents:g}=xe(e,a,b,t.imports,s);const O=Object.keys({...t.urlSchemas,...t.blockPlugins}),P=_e(t.urlSchemas),x=Ae(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:le(n.state).join(","),inject:ue(n.inject).join(","),props:pe(n.props).join(","),emits:fe(n.emits).join(","),expose:n.expose&&n.expose.length?JSON.stringify(n.expose||[]):"",watch:c.watches.join(","),lifeCycles:r.join(","),computed:f.join(","),methods:[...h,...y].join(","),imports:`
42
+ `+$.join(`
43
+ `),components:ae(a,g).join(","),directives:l.join(","),returns:t.members.join(","),template:u.join(`
44
+ `),css:n.css||"",style:Ee(t.style),urlSchemas:P.join(`
45
+ `),blockPlugins:x.join(`
46
+ `),asyncComponents:O.join(","),uniComponents:g,renderer:s==="uniapp"?"@vtj/uni-app":"@vtj/renderer"}}const Ne=`
49
47
  // @ts-nocheck
50
48
 
51
49
  <%= imports %>
@@ -78,7 +76,7 @@ export default defineComponent({
78
76
  <% if(methods) { %> methods: { <%= methods %> }, <% } %>
79
77
  <% if(watch) { %> watch: { <%= watch %> }, <% } %> <%= lifeCycles %>
80
78
  });
81
- `.replace(/(\n|\r|\t)/g,""),De=`
79
+ `.replace(/(\n|\r|\t)/g,""),Fe=`
82
80
  <template>
83
81
  <%= template %>
84
82
  </template>
@@ -89,11 +87,11 @@ export default defineComponent({
89
87
  <%= css %>
90
88
  <%= style %>
91
89
  </style>
92
- `,Te=f.template(Fe),Be=f.template(De);async function We(t,e=new Map,s=[],n="web",i){const r=t,o=typeof r.dsl=="object"&&arguments.length===1?r:{dsl:t,componentMap:e,dependencies:s,platform:n,formatterDisabled:i},{dsl:a,componentMap:m=new Map,dependencies:u=[],platform:l="web",formatterDisabled:c=!1,ts:v=!0,scss:p=!1}=o,h=new le(f.cloneDeep(a),u),g=Ne(h,m,l),$=Te(g),b=Be({template:g.template||`
90
+ `,De=m.template(Ne),Te=m.template(Fe);async function Be(t,e=new Map,s=[],n="web",i){const r=t,o=typeof r.dsl=="object"&&arguments.length===1?r:{dsl:t,componentMap:e,dependencies:s,platform:n,formatterDisabled:i},{dsl:c,componentMap:h=new Map,dependencies:p=[],platform:u="web",formatterDisabled:a=!1,ts:v=!0,scss:l=!1}=o,f=new ce(m.cloneDeep(c),p),y=Ie(f,h,u),b=De(y),$=Te({template:y.template||`
93
91
  <!--组件模版内容-->
94
- `,css:await F(g.css,c)||`
92
+ `,css:await F(y.css,a)||`
95
93
  /* 组件样式内容 */
96
- `,script:await V($,c),style:await F(g.style,c),scriptLang:v?"ts":"js",styleLang:p?"scss":"css"});return await B(b,c).catch(y=>(y.content=b,Promise.reject(y)))}async function Le(t){const e=`
94
+ `,script:await U(b,a),style:await F(y.style,a),scriptLang:v?"ts":"js",styleLang:l?"scss":"css"});return await W($,a).catch(g=>(g.content=$,Promise.reject(g)))}async function We(t){const e=`
97
95
  <template>
98
96
  <div>
99
97
  <h3>源码模式页面</h3>
@@ -104,4 +102,4 @@ export default defineComponent({
104
102
  <\/script>
105
103
  <style scoped lang="scss">
106
104
  </style>
107
- `;return await B(e)}exports.VTJ_CODER_VERSION=re;exports.createEmptyPage=Le;exports.cssFormatter=F;exports.generator=We;exports.tsFormatter=V;exports.vueFormatter=B;
105
+ `;return await W(e)}exports.VTJ_CODER_VERSION=ne;exports.createEmptyPage=We;exports.cssFormatter=F;exports.generator=Be;exports.tsFormatter=U;exports.vueFormatter=W;
package/dist/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
- import { mitt as ee, base64 as te, dedupArray as x, toArray as se, kebabCase as F, camelCase as b, isPlainObject as ne, template as U, cloneDeep as re } from "@vtj/base";
2
- import { format as B } from "prettier/standalone";
3
- import * as ie from "prettier/plugins/html";
4
- import * as M from "prettier/plugins/babel";
5
- import * as V from "prettier/plugins/postcss";
6
- import * as H from "prettier/plugins/estree";
1
+ import { mitt as K, base64 as ee, dedupArray as C, toArray as te, kebabCase as B, camelCase as b, isPlainObject as se, template as J, cloneDeep as ne } from "@vtj/base";
2
+ import { format as F } from "prettier/standalone";
3
+ import * as re from "prettier/plugins/html";
4
+ import * as U from "prettier/plugins/babel";
5
+ import * as M from "prettier/plugins/postcss";
6
+ import * as V from "prettier/plugins/estree";
7
7
  /**!
8
8
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
9
9
  * @name @vtj/coder
10
10
  * @author CHC chenhuachun1549@dingtalk.com
11
- * @version 0.16.26
11
+ * @version 0.16.28
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Ue = "0.16.26";
14
+ const Je = "0.16.28";
15
15
  /**!
16
16
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
17
17
  * @name @vtj/core
18
18
  * @author CHC chenhuachun1549@dingtalk.com
19
- * @version 0.16.26
19
+ * @version 0.16.28
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
- const oe = [
22
+ const ie = [
23
23
  "slot",
24
24
  "template",
25
25
  "component",
@@ -32,8 +32,8 @@ const oe = [
32
32
  "span",
33
33
  "a"
34
34
  ];
35
- ee();
36
- const D = {
35
+ K();
36
+ const T = {
37
37
  arrowParens: "always",
38
38
  bracketSpacing: !0,
39
39
  bracketSameLine: !0,
@@ -53,61 +53,61 @@ const D = {
53
53
  useTabs: !1,
54
54
  vueIndentScriptAndStyle: !0
55
55
  };
56
- async function q(t, e) {
57
- return e ? t : await B(t, {
56
+ async function H(t, e) {
57
+ return e ? t : await F(t, {
58
58
  parser: "vue",
59
- ...D,
60
- plugins: [ie, M, H, V]
59
+ ...T,
60
+ plugins: [re, U, V, M]
61
61
  });
62
62
  }
63
- async function ae(t, e) {
63
+ async function oe(t, e) {
64
64
  if (e) return t;
65
65
  try {
66
- return (await B(t, {
66
+ return (await F(t, {
67
67
  parser: "babel-ts",
68
- ...D,
69
- plugins: [M, H]
68
+ ...T,
69
+ plugins: [U, V]
70
70
  })).replace(/;\n$/gi, "");
71
- } catch (s) {
72
- return console.warn(s), t;
71
+ } catch (n) {
72
+ return console.warn(n), t;
73
73
  }
74
74
  }
75
- async function T(t, e) {
76
- return e ? t : B(t, {
75
+ async function W(t, e) {
76
+ return e ? t : F(t, {
77
77
  parser: "scss",
78
- ...D,
79
- plugins: [V]
78
+ ...T,
79
+ plugins: [M]
80
80
  });
81
81
  }
82
- function k(t) {
82
+ function w(t) {
83
83
  return t && t.type === "JSExpression";
84
84
  }
85
- function N(t) {
85
+ function A(t) {
86
86
  return typeof t == "object" && t && t.type === "JSFunction";
87
87
  }
88
88
  function j(t) {
89
- return k(t) || N(t);
89
+ return w(t) || A(t);
90
90
  }
91
- function Q(t) {
91
+ function q(t) {
92
92
  return t.replace(new RegExp("this.", "g"), "");
93
93
  }
94
- function L(t) {
94
+ function D(t) {
95
95
  return t.replace(/this\.context\??\./g, "");
96
96
  }
97
- function h(t, e = !0, s = !0, n = [], i = !0) {
97
+ function m(t, e = !0, n = !0, s = [], i = !0) {
98
98
  let r = t;
99
- return j(t) ? (r = t.value.trim().replace(/;$/, ""), i && (r = r.replace(/\"/g, "'"))) : r = e ? JSON.stringify(r) : t, r = w(r, n), s ? Q(L(r)) : L(r);
100
- }
101
- function w(t = "", e = []) {
102
- let s = t;
103
- for (const n of e)
104
- s = s.replace(
105
- new RegExp(`this.${n}.value`, "g"),
106
- `this.${n}`
99
+ return j(t) ? (r = t.value.trim().replace(/;$/, ""), i && (r = r.replace(/\"/g, "'"))) : r = e ? JSON.stringify(r) : t, r = x(r, s), n ? q(D(r)) : D(r);
100
+ }
101
+ function x(t = "", e = []) {
102
+ let n = t;
103
+ for (const s of e)
104
+ n = n.replace(
105
+ new RegExp(`this.${s}.value`, "g"),
106
+ `this.${s}`
107
107
  );
108
- return s;
108
+ return n;
109
109
  }
110
- function G(t) {
110
+ function Q(t) {
111
111
  let e = t.trim().replace(/;$/, "");
112
112
  if (e = /^\((\(|async|function)/.test(e) ? e.substring(1, e.length - 1) : e, e.startsWith("{")) return e;
113
113
  if (e.startsWith("async function"))
@@ -121,30 +121,30 @@ function G(t) {
121
121
  return e;
122
122
  }
123
123
  function ce(t = {}) {
124
- return Object.entries(t).map(([e, s]) => `"${e}": ${h(s)}`);
124
+ return Object.entries(t).map(([e, n]) => `"${e}": ${m(n)}`);
125
125
  }
126
- function Z(t = {}, e = !1) {
127
- const s = Object.keys(t);
128
- return e ? s.map((n) => "." + n) : s;
126
+ function G(t = {}, e = !1) {
127
+ const n = Object.keys(t);
128
+ return e ? n.map((s) => "." + s) : n;
129
129
  }
130
- function le(t) {
130
+ function ae(t) {
131
131
  let e = "";
132
- for (var s in t)
133
- if (t.hasOwnProperty(s)) {
134
- var n = t[s];
135
- e += s + ": " + n + ";";
132
+ for (var n in t)
133
+ if (t.hasOwnProperty(n)) {
134
+ var s = t[n];
135
+ e += n + ": " + s + ";";
136
136
  }
137
137
  return e;
138
138
  }
139
- function ue(t = [], e = []) {
140
- return t.filter((s) => !e.includes(s));
139
+ function le(t = [], e = []) {
140
+ return t.filter((n) => !e.includes(n));
141
141
  }
142
- function R(t) {
143
- return te(JSON.stringify(t));
142
+ function L(t) {
143
+ return ee(JSON.stringify(t));
144
144
  }
145
- class pe {
146
- constructor(e, s) {
147
- this.dsl = e, this.dependencies = s, this.libraryRegex = this.collectLibrary(), this.walk(e), this.walkNodes(e), this.members = this.getLibraryMember();
145
+ class ue {
146
+ constructor(e, n) {
147
+ this.dsl = e, this.dependencies = n, this.libraryRegex = this.collectLibrary(), this.walk(e), this.walkNodes(e), this.members = this.getLibraryMember();
148
148
  }
149
149
  /**
150
150
  * { 'element-plus': ['ElButton', 'ElInput' ...] }
@@ -165,17 +165,17 @@ class pe {
165
165
  * @returns ex: { name: 'ElButton', path: 'this.$libs.ElementPlus.', library: 'ElementPlus' }
166
166
  */
167
167
  collectImport(e) {
168
- const s = e.split(".");
169
- if (s.length === 4) {
170
- const n = s.pop(), i = s.join(".") + ".", r = s.pop();
171
- if (n && r) {
168
+ const n = e.split(".");
169
+ if (n.length === 4) {
170
+ const s = n.pop(), i = n.join(".") + ".", r = n.pop();
171
+ if (s && r) {
172
172
  const o = this.dependencies.find(
173
173
  (a) => a.library === r
174
174
  )?.package;
175
- o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(n);
175
+ o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(s);
176
176
  }
177
177
  return {
178
- name: n,
178
+ name: s,
179
179
  path: i,
180
180
  library: r
181
181
  };
@@ -184,53 +184,53 @@ class pe {
184
184
  }
185
185
  // 代码中包含依赖库的引用,需要从代码中移除
186
186
  replaceLibraryPath(e) {
187
- const { libraryRegex: s } = this;
188
- let n = e.value;
189
- for (const i of s) {
187
+ const { libraryRegex: n } = this;
188
+ let s = e.value;
189
+ for (const i of n) {
190
190
  const r = e.value?.match(i) || [];
191
191
  for (const o of r) {
192
192
  const a = this.collectImport(o);
193
193
  if (a) {
194
- const f = a.path.replace(/\$/g, "\\$");
195
- n = n.replace(new RegExp(f, "g"), "");
194
+ const h = a.path.replace(/\$/g, "\\$");
195
+ s = s.replace(new RegExp(h, "g"), "");
196
196
  }
197
197
  }
198
198
  }
199
- return n;
199
+ return s;
200
200
  }
201
201
  walk(e) {
202
- const s = (n) => {
203
- if (!n || typeof n != "object") return;
204
- if (Array.isArray(n)) {
205
- for (let r of n)
206
- s(r);
202
+ const n = (s) => {
203
+ if (!s || typeof s != "object") return;
204
+ if (Array.isArray(s)) {
205
+ for (let r of s)
206
+ n(r);
207
207
  return;
208
208
  }
209
- const i = Object.values(n);
209
+ const i = Object.values(s);
210
210
  for (const r of i)
211
- j(r) ? r.value = this.replaceLibraryPath(r) : s(r);
211
+ j(r) ? r.value = this.replaceLibraryPath(r) : n(r);
212
212
  };
213
- s(e);
213
+ n(e);
214
214
  }
215
215
  getLibraryMember(e = []) {
216
- let s = [...e];
217
- const n = { ...this.imports };
218
- delete n["uni-h5"], delete n["@dcloudio/uni-h5"], delete n["uni-ui"], delete n["@dcloudio/uni-ui"];
219
- for (const i of Object.values(n))
220
- s = s.concat(Array.from(i));
221
- return x(s);
216
+ let n = [...e];
217
+ const s = { ...this.imports };
218
+ delete s["uni-h5"], delete s["@dcloudio/uni-h5"], delete s["uni-ui"], delete s["@dcloudio/uni-ui"];
219
+ for (const i of Object.values(s))
220
+ n = n.concat(Array.from(i));
221
+ return C(n);
222
222
  }
223
- collectContext(e, s) {
224
- const n = new Set(s?.id ? this.context[s.id] : []), i = (e.directives || []).find((a) => a.name === "vFor");
225
- let r = new Set(Array.from(n));
223
+ collectContext(e, n) {
224
+ const s = new Set(n?.id ? this.context[n.id] : []), i = (e.directives || []).find((a) => a.name === "vFor");
225
+ let r = new Set(Array.from(s));
226
226
  if (i) {
227
- const { item: a = "item", index: f = "index" } = i.iterator || {};
228
- r = /* @__PURE__ */ new Set([a, f, ...Array.from(r)]);
227
+ const { item: a = "item", index: h = "index" } = i.iterator || {};
228
+ r = /* @__PURE__ */ new Set([a, h, ...Array.from(r)]);
229
229
  }
230
230
  const o = e.slot;
231
231
  if (o) {
232
- const a = typeof o == "string" ? [] : o.params || [], f = a.length ? a : [`scope_${s?.id}`];
233
- r = /* @__PURE__ */ new Set([...f, ...Array.from(r)]);
232
+ const a = typeof o == "string" ? [] : o.params || [], h = a.length ? a : [`scope_${n?.id}`];
233
+ r = /* @__PURE__ */ new Set([...h, ...Array.from(r)]);
234
234
  }
235
235
  this.context[e.id] = r;
236
236
  }
@@ -244,76 +244,76 @@ class pe {
244
244
  typeof e.from == "object" && e.from.type === "Plugin" && (this.blockPlugins[e.name] = e.from);
245
245
  }
246
246
  walkNodes(e) {
247
- const s = (n, i) => {
248
- this.collectContext(n, i), this.collectStyle(n), this.collectUrlSchema(n), this.collectBlockPlugin(n), Array.isArray(n.children) && n.children.forEach((r) => s(r, n));
247
+ const n = (s, i) => {
248
+ this.collectContext(s, i), this.collectStyle(s), this.collectUrlSchema(s), this.collectBlockPlugin(s), Array.isArray(s.children) && s.children.forEach((r) => n(r, s));
249
249
  };
250
- Array.isArray(e.nodes) && e.nodes.forEach((n) => s(n));
250
+ Array.isArray(e.nodes) && e.nodes.forEach((s) => n(s));
251
251
  }
252
252
  }
253
- function fe(t = {}) {
254
- return Object.entries(t).map(([e, s]) => {
255
- const n = h(s, !1, !0, [], !1);
256
- return `${e}:${n}`;
253
+ function pe(t = {}) {
254
+ return Object.entries(t).map(([e, n]) => {
255
+ const s = m(n, !1, !0, [], !1);
256
+ return `${e}:${s}`;
257
257
  });
258
258
  }
259
- function me(t = []) {
259
+ function fe(t = []) {
260
260
  return t.map((e) => `${e.name}: {
261
261
  from: '${e.from || e.name}',
262
- default: ${h(e.default, !0, !1, [], !1)}
262
+ default: ${m(e.default, !0, !1, [], !1)}
263
263
  }`);
264
264
  }
265
- function he(t = []) {
266
- const e = (s) => s ? `[${se(s).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
267
- return t.map((s) => typeof s == "string" ? `${s}: {}` : (j(s.default) && !s.default.value && (s.default.value = "undefined"), `${s.name}: {
268
- type:${e(s.type)},
269
- required: ${h(!!s.required, !0, !1, [], !1)},
270
- default: ${s.default ? h(s.default, !0, !1, [], !1) : "undefined"}
265
+ function me(t = []) {
266
+ const e = (n) => n ? `[${te(n).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
267
+ return t.map((n) => typeof n == "string" ? `${n}: {}` : (j(n.default) && !n.default.value && (n.default.value = "undefined"), `${n.name}: {
268
+ type:${e(n.type)},
269
+ required: ${m(!!n.required, !0, !1, [], !1)},
270
+ default: ${n.default ? m(n.default, !0, !1, [], !1) : "undefined"}
271
271
  }`));
272
272
  }
273
- function de(t = []) {
273
+ function he(t = []) {
274
274
  return t.map((e) => `'${typeof e == "string" ? e : e.name}'`);
275
275
  }
276
- function A(t = {}, e = []) {
277
- return Object.entries(t).map(([s, n]) => {
278
- let i = G(
279
- h(n, !1, !1, [], !1)
276
+ function N(t = {}, e = []) {
277
+ return Object.entries(t).map(([n, s]) => {
278
+ let i = Q(
279
+ m(s, !1, !1, [], !1)
280
280
  );
281
- return i = w(i, e)?.trim(), i.startsWith("async") ? `async ${s}${i.replace(/^async/, "")}` : i.startsWith("(") || i.startsWith("{") ? `${s}${i}` : null;
282
- }).filter((s) => !!s);
281
+ return i = x(i, e)?.trim(), i.startsWith("async") ? `async ${n}${i.replace(/^async/, "")}` : i.startsWith("(") || i.startsWith("{") ? `${n}${i}` : null;
282
+ }).filter((n) => !!n);
283
283
  }
284
- function ge(t = [], e = []) {
285
- const s = t.reduce(
286
- (r, o) => (o.id && N(o.source) && (r[`watcher_${o.id}`] = o.source), r),
284
+ function de(t = [], e = []) {
285
+ const n = t.reduce(
286
+ (r, o) => (o.id && A(o.source) && (r[`watcher_${o.id}`] = o.source), r),
287
287
  {}
288
- ), n = A(s, e), i = t.map((r) => r.handler && r.handler.value ? `watcher_${r.id}: {
288
+ ), s = N(n, e), i = t.map((r) => r.handler && r.handler.value ? `watcher_${r.id}: {
289
289
  deep: ${r.deep},
290
290
  immediate:${r.immediate},
291
- handler${G(r.handler.value)}
291
+ handler${Q(r.handler.value)}
292
292
  }` : null).filter((r) => !!r);
293
293
  return {
294
- computed: n,
294
+ computed: s,
295
295
  watches: i
296
296
  };
297
297
  }
298
- function ye(t = {}) {
298
+ function ge(t = {}) {
299
299
  return Object.values(t).map((e) => {
300
300
  if (e.type === "mock") {
301
- const s = N(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
301
+ const n = A(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
302
302
  return `async ${e.name}(...args) {
303
- // DataSource: ${R(e)}
304
- const mock = this.provider.createMock(${s});
303
+ // DataSource: ${L(e)}
304
+ const mock = this.provider.createMock(${n});
305
305
  return await mock.apply(this, args);
306
306
  }`;
307
307
  } else {
308
- const s = N(e.transform) && e.transform.value || "(res) => res";
308
+ const n = A(e.transform) && e.transform.value || "(res) => res";
309
309
  return `async ${e.name}(...args) {
310
- // DataSource: ${R(e)}
311
- return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
310
+ // DataSource: ${L(e)}
311
+ return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
312
312
  }`;
313
313
  }
314
314
  });
315
315
  }
316
- const $e = [
316
+ const ye = [
317
317
  "img",
318
318
  "input",
319
319
  "br",
@@ -328,7 +328,7 @@ const $e = [
328
328
  "source",
329
329
  "track",
330
330
  "wbr"
331
- ], J = [
331
+ ], R = [
332
332
  "vIf",
333
333
  "vElseIf",
334
334
  "vElse",
@@ -338,193 +338,190 @@ const $e = [
338
338
  "vBind",
339
339
  "vHtml"
340
340
  ];
341
- function z(t, e, s = [], n = {}, i) {
341
+ function Z(t, e, n = [], s = {}, i) {
342
342
  const r = [];
343
343
  let o = {}, a = [];
344
- const f = [];
345
- let u = [];
346
- return be(t).forEach((c) => {
344
+ const h = [];
345
+ let p = [];
346
+ return $e(t).forEach((c) => {
347
347
  const y = [];
348
- for (const m of c.children) {
349
- let { id: d, name: $, invisible: v, from: g } = m;
350
- if (v)
348
+ for (const f of c.children) {
349
+ let { id: d, name: v, invisible: $, from: g } = f;
350
+ if ($)
351
351
  continue;
352
- const O = je($, e, g);
353
- O && a.push(O), X(g) && u.push({ id: g.id, name: $ });
354
- const { props: C, events: E, handlers: P } = Oe(
355
- m,
352
+ const O = be(v, e, g);
353
+ O && a.push(O), z(g) && p.push({ id: g.id, name: v });
354
+ const { props: E, events: P } = xe(
355
+ f,
356
356
  d,
357
- m.props,
358
- m.events,
357
+ f.props,
358
+ f.events,
359
+ s,
360
+ n
361
+ ), k = Ce(
362
+ f.directives,
359
363
  n,
360
- s
361
- ), W = Ce(
362
- m.directives,
364
+ h
365
+ ).join(" "), S = f.children ? Ee(
366
+ f.children,
367
+ n,
368
+ e,
363
369
  s,
364
370
  f
365
- ).join(" "), S = m.children ? Pe(
366
- m.children,
367
- s,
368
- e,
369
- n,
370
- m
371
371
  ) : "";
372
- Object.assign(o, P);
373
372
  let _ = "";
374
373
  typeof S == "string" ? _ = S : (_ = (S?.nodes || []).join(`
375
- `), Object.assign(o, S?.methods || {}), a = a.concat(S?.components || []), u = u.concat(S?.importBlocks || []));
374
+ `), Object.assign(o, S?.methods || {}), a = a.concat(S?.components || []), p = p.concat(S?.importBlocks || []));
376
375
  const I = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
377
- g || e.get($)?.package
378
- ) ? F($) : Y(g) || K(g) ? "component" : $;
376
+ g || e.get(v)?.package
377
+ ) ? B(v) : X(g) || Y(g) ? "component" : v;
379
378
  y.push(
380
- $e.includes(I) ? `<${I} ${W} ${C} ${E} />` : `<${I} ${W} ${C} ${E}>${_ ? `
379
+ ye.includes(I) ? `<${I} ${k} ${E} ${P} />` : `<${I} ${k} ${E} ${P}>${_ ? `
381
380
  ` + _.trim() : ""}</${I}>`
382
381
  );
383
382
  }
384
- const p = _e(c.slot, y.join(`
383
+ const l = Pe(c.slot, y.join(`
385
384
  `), i?.id);
386
- r.push(p);
385
+ r.push(l);
387
386
  }), {
388
387
  nodes: r,
389
388
  methods: o,
390
- directives: ve(f),
391
- components: x(a),
392
- importBlocks: x(u, "id")
389
+ directives: ve(h),
390
+ components: C(a),
391
+ importBlocks: C(p, "id")
393
392
  };
394
393
  }
395
394
  function ve(t) {
396
- return x(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
395
+ return C(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
397
396
  }
398
- function be(t = []) {
397
+ function $e(t = []) {
399
398
  const e = /* @__PURE__ */ new Map();
400
- for (const s of t) {
401
- const n = typeof s.slot == "string" ? s.slot : s.slot?.name, i = e.get(n);
402
- i ? i.children.push(s) : e.set(n, { slot: s.slot, children: [s] });
399
+ for (const n of t) {
400
+ const s = typeof n.slot == "string" ? n.slot : n.slot?.name, i = e.get(s);
401
+ i ? i.children.push(n) : e.set(s, { slot: n.slot, children: [n] });
403
402
  }
404
403
  return e;
405
404
  }
406
- function je(t, e, s) {
407
- if (oe.includes(t)) return null;
408
- const n = e.get(t);
409
- if (n && n.alias) {
410
- const i = n.parent ? `${n.parent}.${n.alias}` : n.alias;
405
+ function be(t, e, n) {
406
+ if (ie.includes(t)) return null;
407
+ const s = e.get(t);
408
+ if (s && s.alias) {
409
+ const i = s.parent ? `${s.parent}.${s.alias}` : s.alias;
411
410
  return `${t}: ${i}`;
412
411
  }
413
- return X(s) || n ? t : null;
412
+ return z(n) || s ? t : null;
414
413
  }
415
- function X(t) {
414
+ function z(t) {
416
415
  return !!t && typeof t == "object" && t.type === "Schema";
417
416
  }
418
- function Y(t) {
417
+ function X(t) {
419
418
  return typeof t == "object" && t.type === "UrlSchema";
420
419
  }
421
- function K(t) {
420
+ function Y(t) {
422
421
  return typeof t == "object" && t.type === "Plugin";
423
422
  }
424
- function Se(t, e, s = []) {
425
- return t === "style" ? j(e) ? `:style="${h({
423
+ function je(t, e, n = []) {
424
+ return t === "style" ? j(e) ? `:style="${m({
426
425
  ...e,
427
- value: w(e.value, s)
428
- })}"` : "" : t === "__class" && j(e) ? `:class="${h({
426
+ value: x(e.value, n)
427
+ })}"` : "" : t === "__class" && j(e) ? `:class="${m({
429
428
  ...e,
430
- value: w(e.value, s)
431
- })}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${h({
429
+ value: x(e.value, n)
430
+ })}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${m({
432
431
  ...e,
433
- value: w(e.value, s)
434
- })}"` : ne(e) ? `:${t}='{${ce(
432
+ value: x(e.value, n)
433
+ })}"` : se(e) ? `:${t}='{${ce(
435
434
  e
436
435
  ).join(", ")}}'` : `:${t}='${JSON.stringify(e)}'`;
437
436
  }
438
- function ke(t, e = {}, s = []) {
437
+ function Se(t, e = {}, n = []) {
439
438
  if (!!Object.keys(e.style || {}).length) {
440
439
  const r = `${t.name}_${t.id}`;
441
440
  e.class ? typeof e.class == "string" ? e.class = [e.class, r].join(" ") : (e.__class = e.class, e.class = r) : e.class = r, j(e.style) || delete e.style;
442
441
  }
443
442
  const i = t.from;
444
- return (Y(i) || K(i)) && (e.is = {
443
+ return (X(i) || Y(i)) && (e.is = {
445
444
  type: "JSExpression",
446
445
  value: t.name
447
- }), Object.entries(e).map(([r, o]) => Se(r, o, s));
446
+ }), Object.entries(e).map(([r, o]) => je(r, o, n));
448
447
  }
449
- function we(t, e, s, n, i) {
450
- const r = Z(e.modifiers, !0);
451
- return i ? `@${t}${r.join("")}="${s}"` : n && n.length > 0 ? `@${t}${r.join("")}="(...args:any[]) => ${s}"` : `@${t}${r.join("")}="${s}"`;
448
+ function ke(t, e, n) {
449
+ const s = G(e.modifiers, !0);
450
+ return `@${t}${s.join("")}="${n}"`;
452
451
  }
453
- function xe(t, e = {}, s = {}) {
454
- const n = {}, i = Array.from(s[t] || /* @__PURE__ */ new Set([])), r = i.length ? `({${i.join(", ")}}, args)` : "";
452
+ function we(t, e = {}, n = {}) {
453
+ const s = {};
455
454
  return {
456
- binders: Object.entries(e).map(([a, f]) => {
457
- const u = f.handler.value.startsWith("this."), l = u ? Q(f.handler.value) : `${b(a)}_${t}${r}`;
458
- return u || (n[l] = i.length ? {
459
- type: "JSFunction",
460
- value: `{
461
- return (${f.handler.value}).apply(this, args);
462
- }`
463
- } : f.handler), we(a, f, l, i, u);
455
+ binders: Object.entries(e).map(([r, o]) => {
456
+ const a = q(D(o.handler.value)).replace(
457
+ /\"/g,
458
+ "'"
459
+ );
460
+ return ke(r, o, a);
464
461
  }),
465
- handlers: n
462
+ handlers: s
466
463
  };
467
464
  }
468
- function Oe(t, e, s = {}, n = {}, i = {}, r) {
469
- const { binders: o, handlers: a } = xe(e, n, i);
465
+ function xe(t, e, n = {}, s = {}, i = {}, r) {
466
+ const { binders: o, handlers: a } = we(e, s, i);
470
467
  return {
471
- props: ke(t, s, r).join(" "),
468
+ props: Se(t, n, r).join(" "),
472
469
  handlers: a,
473
470
  binders: o,
474
471
  events: o.join(" ")
475
472
  };
476
473
  }
477
- function Ce(t = [], e = [], s = []) {
478
- const n = [], {
474
+ function Ce(t = [], e = [], n = []) {
475
+ const s = [], {
479
476
  vIf: i,
480
477
  vElse: r,
481
478
  vElseIf: o,
482
479
  vShow: a,
483
- vModels: f,
484
- vFor: u,
485
- vBind: l,
480
+ vModels: h,
481
+ vFor: p,
482
+ vBind: u,
486
483
  vHtml: c,
487
484
  customDirectives: y
488
- } = Ee(t);
489
- if (i && n.push(`v-if="${h(i.value, !0, !0, e)}"`), o && n.push(
490
- `v-else-if="${h(o.value, !0, !0, e)}"`
491
- ), r && n.push("v-else"), a && n.push(
492
- `v-show="${h(a.value, !0, !0, e)}"`
493
- ), l && n.push(
494
- `v-bind="${h(l.value, !0, !0, e)}"`
495
- ), f.forEach((p) => {
496
- const m = Z(p.modifiers, !0), d = p.arg ? k(p.arg) ? `:[${h(p.arg, !0, !0, e)}]` : `:${p.arg}` : "";
497
- n.push(
498
- `v-model${d}${m}="${h(p.value, !0, !0, e)}"`
485
+ } = Oe(t);
486
+ if (i && s.push(`v-if="${m(i.value, !0, !0, e)}"`), o && s.push(
487
+ `v-else-if="${m(o.value, !0, !0, e)}"`
488
+ ), r && s.push("v-else"), a && s.push(
489
+ `v-show="${m(a.value, !0, !0, e)}"`
490
+ ), u && s.push(
491
+ `v-bind="${m(u.value, !0, !0, e)}"`
492
+ ), h.forEach((l) => {
493
+ const f = G(l.modifiers, !0), d = l.arg ? w(l.arg) ? `:[${m(l.arg, !0, !0, e)}]` : `:${l.arg}` : "";
494
+ s.push(
495
+ `v-model${d}${f}="${m(l.value, !0, !0, e)}"`
499
496
  );
500
- }), u) {
501
- const { item: p, index: m } = { item: "item", index: "index", ...u.iterator };
502
- n.push(
503
- `v-for="(${p}, ${m}) in ${h(u.value, !0, !0, e)}"`
497
+ }), p) {
498
+ const { item: l, index: f } = { item: "item", index: "index", ...p.iterator };
499
+ s.push(
500
+ `v-for="(${l}, ${f}) in ${m(p.value, !0, !0, e)}"`
504
501
  );
505
502
  }
506
- return c && n.push(
507
- `v-html="${h(c.value, !0, !0, e)}"`
508
- ), y && y.length && y.forEach((p) => {
509
- if (!p.name) return;
510
- let m = "", d = "";
511
- k(p.name) ? (d = h(p.name, !0, !0, e), s.push(d)) : d = p.name;
512
- const $ = d?.startsWith("v") ? F(d) : F("v-" + d);
513
- if (m += $, p.arg && (k(p.arg) ? m += `:[${h(p.name, !0, !0, e)}]` : m += `:${p.arg}`), p.modifiers) {
514
- const v = Object.keys(p.modifiers);
515
- v.length && (m += v.map((g) => "." + g));
503
+ return c && s.push(
504
+ `v-html="${m(c.value, !0, !0, e)}"`
505
+ ), y && y.length && y.forEach((l) => {
506
+ if (!l.name) return;
507
+ let f = "", d = "";
508
+ w(l.name) ? (d = m(l.name, !0, !0, e), n.push(d)) : d = l.name;
509
+ const v = d?.startsWith("v") ? B(d) : B("v-" + d);
510
+ if (f += v, l.arg && (w(l.arg) ? f += `:[${m(l.name, !0, !0, e)}]` : f += `:${l.arg}`), l.modifiers) {
511
+ const $ = Object.keys(l.modifiers);
512
+ $.length && (f += $.map((g) => "." + g));
516
513
  }
517
- p.value ? n.push(
518
- `${m}="${h(p.value, !0, !0, e)}"`
519
- ) : n.push(m);
520
- }), n;
514
+ l.value ? s.push(
515
+ `${f}="${m(l.value, !0, !0, e)}"`
516
+ ) : s.push(f);
517
+ }), s;
521
518
  }
522
- function Ee(t = []) {
519
+ function Oe(t = []) {
523
520
  const e = t.filter(
524
- (c) => J.includes(c.name)
525
- ), s = t.filter(
526
- (c) => !J.includes(c.name)
527
- ), n = e.find(
521
+ (c) => R.includes(c.name)
522
+ ), n = t.filter(
523
+ (c) => !R.includes(c.name)
524
+ ), s = e.find(
528
525
  (c) => b(c.name) === "vIf"
529
526
  ), i = e.find(
530
527
  (c) => b(c.name) === "vElseIf"
@@ -534,36 +531,36 @@ function Ee(t = []) {
534
531
  (c) => b(c.name) === "vFor"
535
532
  ), a = e.find(
536
533
  (c) => b(c.name) === "vShow"
537
- ), f = e.find(
534
+ ), h = e.find(
538
535
  (c) => b(c.name) === "vBind"
539
- ), u = e.find(
536
+ ), p = e.find(
540
537
  (c) => b(c.name) === "vHtml"
541
- ), l = e.filter(
538
+ ), u = e.filter(
542
539
  (c) => b(c.name) === "vModel"
543
540
  );
544
541
  return {
545
- vIf: n,
542
+ vIf: s,
546
543
  vElseIf: i,
547
544
  vElse: r,
548
545
  vFor: o,
549
546
  vShow: a,
550
- vModels: l,
551
- vBind: f,
552
- vHtml: u,
553
- customDirectives: s
547
+ vModels: u,
548
+ vBind: h,
549
+ vHtml: p,
550
+ customDirectives: n
554
551
  };
555
552
  }
556
- function Pe(t, e, s, n, i) {
557
- return typeof t == "string" ? t : k(t) ? `{{ ${h(t, !1, !0, e)} }}` : Array.isArray(t) ? z(t, s, e, n, i) : "";
553
+ function Ee(t, e, n, s, i) {
554
+ return typeof t == "string" ? t : w(t) ? `{{ ${m(t, !1, !0, e)} }}` : Array.isArray(t) ? Z(t, n, e, s, i) : "";
558
555
  }
559
- function _e(t, e, s) {
556
+ function Pe(t, e, n) {
560
557
  if (!t) return e;
561
- const n = typeof t == "string" ? { name: t, params: [], scope: "" } : { params: [], scope: "", ...t };
562
- return `<template ${`#${n.name}="${n.scope ? n.scope : n.params?.length > 0 ? `{${n.params?.join(",")}}` : `scope_${s}`}"`}>
558
+ const s = typeof t == "string" ? { name: t, params: [], scope: "" } : { params: [], scope: "", ...t };
559
+ return `<template ${`#${s.name}="${s.scope ? s.scope : s.params?.length > 0 ? `{${s.params?.join(",")}}` : `scope_${n}`}"`}>
563
560
  ${e}
564
561
  </template>`;
565
562
  }
566
- function Ie(t, e = [], s = [], n = {}, i = "web") {
563
+ function _e(t, e = [], n = [], s = {}, i = "web") {
567
564
  const r = [
568
565
  "@dcloudio/uni-h5",
569
566
  "uni-h5",
@@ -572,28 +569,28 @@ function Ie(t, e = [], s = [], n = {}, i = "web") {
572
569
  ], o = {
573
570
  vue: ["defineComponent", "reactive"]
574
571
  }, a = [];
575
- for (const u of e) {
576
- const l = t.get(u.split(":")[0]);
577
- if (l && l.package) {
578
- const c = o[l.package] ?? (o[l.package] = []), y = l.parent || (l.alias || "").split(".")[0] || l.name;
579
- c.push(y), i === "uniapp" && r.includes(l.package) && a.push(y);
572
+ for (const p of e) {
573
+ const u = t.get(p.split(":")[0]);
574
+ if (u && u.package) {
575
+ const c = o[u.package] ?? (o[u.package] = []), y = u.parent || (u.alias || "").split(".")[0] || u.name;
576
+ c.push(y), i === "uniapp" && r.includes(u.package) && a.push(y);
580
577
  }
581
578
  }
582
- for (const [u, l] of Object.entries(n))
583
- (o[u] ?? (o[u] = [])).push(...Array.from(l)), i === "uniapp" && r.includes(u) && a.push(...Array.from(l));
579
+ for (const [p, u] of Object.entries(s))
580
+ (o[p] ?? (o[p] = [])).push(...Array.from(u)), i === "uniapp" && r.includes(p) && a.push(...Array.from(u));
584
581
  return {
585
- imports: Object.entries(o).filter(([u, l]) => i === "uniapp" ? !r.includes(u) && !!l.length : !!l.length).map(([u, l]) => `import { ${x(l).join(
582
+ imports: Object.entries(o).filter(([p, u]) => i === "uniapp" ? !r.includes(p) && !!u.length : !!u.length).map(([p, u]) => `import { ${C(u).join(
586
583
  ","
587
- )}} from '${u}';`).concat(s),
584
+ )}} from '${p}';`).concat(n),
588
585
  uniComponents: a
589
586
  };
590
587
  }
591
- function Ae(t = {}) {
588
+ function Ie(t = {}) {
592
589
  const e = [];
593
- for (const [s, n] of Object.entries(t))
590
+ for (const [n, s] of Object.entries(t))
594
591
  e.push(`
595
- ${s} {
596
- ${le(n)}
592
+ ${n} {
593
+ ${ae(s)}
597
594
  }
598
595
  `);
599
596
  return e.join(`
@@ -601,74 +598,74 @@ function Ae(t = {}) {
601
598
  }
602
599
  function Ne(t = {}) {
603
600
  const e = [];
604
- return Object.entries(t).forEach(([s, n]) => {
601
+ return Object.entries(t).forEach(([n, s]) => {
605
602
  e.push(
606
- `const ${s} = provider.defineUrlSchemaComponent('${n.url}');`
603
+ `const ${n} = provider.defineUrlSchemaComponent('${s.url}');`
607
604
  );
608
605
  }), e;
609
606
  }
610
- function Fe(t = {}) {
607
+ function Ae(t = {}) {
611
608
  const e = [];
612
- return Object.entries(t).forEach(([s, n]) => {
609
+ return Object.entries(t).forEach(([n, s]) => {
613
610
  e.push(
614
- `const ${s} = provider.definePluginComponent(${JSON.stringify(n)});`
611
+ `const ${n} = provider.definePluginComponent(${JSON.stringify(s)});`
615
612
  );
616
613
  }), e;
617
614
  }
618
- function Be(t, e, s = "web") {
619
- const { dsl: n } = t, i = Object.keys(n.computed || {}), r = A(n.lifeCycles, i), o = A(n.computed, i), a = ge(n.watch, i), f = ye(n.dataSources), { methods: u, nodes: l, components: c, importBlocks: y, directives: p } = z(
620
- n.nodes || [],
615
+ function Be(t, e, n = "web") {
616
+ const { dsl: s } = t, i = Object.keys(s.computed || {}), r = N(s.lifeCycles, i), o = N(s.computed, i), a = de(s.watch, i), h = ge(s.dataSources), { methods: p, nodes: u, components: c, importBlocks: y, directives: l } = Z(
617
+ s.nodes || [],
621
618
  e,
622
619
  i,
623
620
  t.context
624
- ), m = [...o, ...a.computed], d = A(
621
+ ), f = [...o, ...a.computed], d = N(
625
622
  {
626
- ...u,
627
- ...n.methods || {}
623
+ ...p,
624
+ ...s.methods || {}
628
625
  },
629
626
  i
630
- ), $ = y.map((P) => `import ${P.name} from './${P.id}.vue';`);
631
- let { imports: v, uniComponents: g } = Ie(
627
+ ), v = y.map((k) => `import ${k.name} from './${k.id}.vue';`);
628
+ let { imports: $, uniComponents: g } = _e(
632
629
  e,
633
630
  c,
634
- $,
631
+ v,
635
632
  t.imports,
636
- s
633
+ n
637
634
  );
638
635
  const O = Object.keys({
639
636
  ...t.urlSchemas,
640
637
  ...t.blockPlugins
641
- }), C = Ne(t.urlSchemas), E = Fe(t.blockPlugins);
638
+ }), E = Ne(t.urlSchemas), P = Ae(t.blockPlugins);
642
639
  return {
643
- id: n.id,
644
- version: n.__VERSION__,
645
- name: n.name,
646
- state: fe(n.state).join(","),
647
- inject: me(n.inject).join(","),
648
- props: he(n.props).join(","),
649
- emits: de(n.emits).join(","),
650
- expose: n.expose && n.expose.length ? JSON.stringify(n.expose || []) : "",
640
+ id: s.id,
641
+ version: s.__VERSION__,
642
+ name: s.name,
643
+ state: pe(s.state).join(","),
644
+ inject: fe(s.inject).join(","),
645
+ props: me(s.props).join(","),
646
+ emits: he(s.emits).join(","),
647
+ expose: s.expose && s.expose.length ? JSON.stringify(s.expose || []) : "",
651
648
  watch: a.watches.join(","),
652
649
  lifeCycles: r.join(","),
653
- computed: m.join(","),
654
- methods: [...f, ...d].join(","),
650
+ computed: f.join(","),
651
+ methods: [...h, ...d].join(","),
655
652
  imports: `
656
- ` + v.join(`
653
+ ` + $.join(`
657
654
  `),
658
- components: ue(c, g).join(","),
659
- directives: p.join(","),
655
+ components: le(c, g).join(","),
656
+ directives: l.join(","),
660
657
  returns: t.members.join(","),
661
- template: l.join(`
658
+ template: u.join(`
662
659
  `),
663
- css: n.css || "",
664
- style: Ae(t.style),
665
- urlSchemas: C.join(`
660
+ css: s.css || "",
661
+ style: Ie(t.style),
662
+ urlSchemas: E.join(`
666
663
  `),
667
- blockPlugins: E.join(`
664
+ blockPlugins: P.join(`
668
665
  `),
669
666
  asyncComponents: O.join(","),
670
667
  uniComponents: g,
671
- renderer: s === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
668
+ renderer: n === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
672
669
  };
673
670
  }
674
671
  const De = `
@@ -704,7 +701,7 @@ export default defineComponent({
704
701
  <% if(methods) { %> methods: { <%= methods %> }, <% } %>
705
702
  <% if(watch) { %> watch: { <%= watch %> }, <% } %> <%= lifeCycles %>
706
703
  });
707
- `.replace(/(\n|\r|\t)/g, ""), We = `
704
+ `.replace(/(\n|\r|\t)/g, ""), Fe = `
708
705
  <template>
709
706
  <%= template %>
710
707
  </template>
@@ -715,37 +712,37 @@ export default defineComponent({
715
712
  <%= css %>
716
713
  <%= style %>
717
714
  </style>
718
- `, Te = U(De), Le = U(We);
719
- async function Me(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", i) {
715
+ `, Te = J(De), We = J(Fe);
716
+ async function Ue(t, e = /* @__PURE__ */ new Map(), n = [], s = "web", i) {
720
717
  const r = t, o = typeof r.dsl == "object" && arguments.length === 1 ? r : {
721
718
  dsl: t,
722
719
  componentMap: e,
723
- dependencies: s,
724
- platform: n,
720
+ dependencies: n,
721
+ platform: s,
725
722
  formatterDisabled: i
726
723
  }, {
727
724
  dsl: a,
728
- componentMap: f = /* @__PURE__ */ new Map(),
729
- dependencies: u = [],
730
- platform: l = "web",
725
+ componentMap: h = /* @__PURE__ */ new Map(),
726
+ dependencies: p = [],
727
+ platform: u = "web",
731
728
  formatterDisabled: c = !1,
732
729
  ts: y = !0,
733
- scss: p = !1
734
- } = o, m = new pe(re(a), u), d = Be(m, f, l), $ = Te(d), v = Le({
730
+ scss: l = !1
731
+ } = o, f = new ue(ne(a), p), d = Be(f, h, u), v = Te(d), $ = We({
735
732
  template: d.template || `
736
733
  <!--组件模版内容-->
737
734
  `,
738
- css: await T(d.css, c) || `
735
+ css: await W(d.css, c) || `
739
736
  /* 组件样式内容 */
740
737
  `,
741
- script: await ae($, c),
742
- style: await T(d.style, c),
738
+ script: await oe(v, c),
739
+ style: await W(d.style, c),
743
740
  scriptLang: y ? "ts" : "js",
744
- styleLang: p ? "scss" : "css"
741
+ styleLang: l ? "scss" : "css"
745
742
  });
746
- return await q(v, c).catch((g) => (g.content = v, Promise.reject(g)));
743
+ return await H($, c).catch((g) => (g.content = $, Promise.reject(g)));
747
744
  }
748
- async function Ve(t) {
745
+ async function Me(t) {
749
746
  const e = `
750
747
  <template>
751
748
  <div>
@@ -758,13 +755,13 @@ async function Ve(t) {
758
755
  <style scoped lang="scss">
759
756
  </style>
760
757
  `;
761
- return await q(e);
758
+ return await H(e);
762
759
  }
763
760
  export {
764
- Ue as VTJ_CODER_VERSION,
765
- Ve as createEmptyPage,
766
- T as cssFormatter,
767
- Me as generator,
768
- ae as tsFormatter,
769
- q as vueFormatter
761
+ Je as VTJ_CODER_VERSION,
762
+ Me as createEmptyPage,
763
+ W as cssFormatter,
764
+ Ue as generator,
765
+ oe as tsFormatter,
766
+ H as vueFormatter
770
767
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.16.26",
4
+ "version": "0.16.28",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -22,8 +22,8 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "prettier": "~3.7.0",
25
- "@vtj/core": "~0.16.26",
26
- "@vtj/base": "~0.12.4"
25
+ "@vtj/base": "~0.12.4",
26
+ "@vtj/core": "~0.16.28"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@vtj/cli": "~0.12.19"
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.16.25
5
+ * @version 0.16.27
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.16.25";
8
+ export declare const version = "0.16.27";