@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 +27 -29
- package/dist/index.mjs +323 -326
- package/package.json +3 -3
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,51 +1,49 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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.
|
|
5
|
+
* @version 0.16.28
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const
|
|
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.
|
|
11
|
+
* @version 0.16.28
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
|
-
*/const
|
|
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
|
|
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
|
|
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${
|
|
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: ${
|
|
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: ${
|
|
29
|
+
// DataSource: ${L(e)}
|
|
30
30
|
return await this.provider.apis['${e.ref}'].apply(this, args).then(${s});
|
|
31
|
-
}`}})}const
|
|
32
|
-
`),Object.assign(o,S?.methods||{}),
|
|
33
|
-
`+E.trim():""}</${_}>`)}const
|
|
34
|
-
`),i?.id);r.push(
|
|
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
|
|
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
|
-
${
|
|
38
|
+
${oe(n)}
|
|
41
39
|
}
|
|
42
40
|
`);return e.join(`
|
|
43
|
-
`)}function
|
|
44
|
-
|
|
45
|
-
`),components:
|
|
46
|
-
`),css:n.css||"",style:
|
|
47
|
-
`),blockPlugins:
|
|
48
|
-
`),asyncComponents:
|
|
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,""),
|
|
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
|
-
`,
|
|
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(
|
|
92
|
+
`,css:await F(y.css,a)||`
|
|
95
93
|
/* 组件样式内容 */
|
|
96
|
-
`,script:await
|
|
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
|
|
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
|
|
2
|
-
import { format as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
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.
|
|
11
|
+
* @version 0.16.28
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const
|
|
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.
|
|
19
|
+
* @version 0.16.28
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
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
|
-
|
|
36
|
-
const
|
|
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
|
|
57
|
-
return e ? t : await
|
|
56
|
+
async function H(t, e) {
|
|
57
|
+
return e ? t : await F(t, {
|
|
58
58
|
parser: "vue",
|
|
59
|
-
...
|
|
60
|
-
plugins: [
|
|
59
|
+
...T,
|
|
60
|
+
plugins: [re, U, V, M]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
async function
|
|
63
|
+
async function oe(t, e) {
|
|
64
64
|
if (e) return t;
|
|
65
65
|
try {
|
|
66
|
-
return (await
|
|
66
|
+
return (await F(t, {
|
|
67
67
|
parser: "babel-ts",
|
|
68
|
-
...
|
|
69
|
-
plugins: [
|
|
68
|
+
...T,
|
|
69
|
+
plugins: [U, V]
|
|
70
70
|
})).replace(/;\n$/gi, "");
|
|
71
|
-
} catch (
|
|
72
|
-
return console.warn(
|
|
71
|
+
} catch (n) {
|
|
72
|
+
return console.warn(n), t;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
async function
|
|
76
|
-
return e ? t :
|
|
75
|
+
async function W(t, e) {
|
|
76
|
+
return e ? t : F(t, {
|
|
77
77
|
parser: "scss",
|
|
78
|
-
...
|
|
79
|
-
plugins: [
|
|
78
|
+
...T,
|
|
79
|
+
plugins: [M]
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function w(t) {
|
|
83
83
|
return t && t.type === "JSExpression";
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function A(t) {
|
|
86
86
|
return typeof t == "object" && t && t.type === "JSFunction";
|
|
87
87
|
}
|
|
88
88
|
function j(t) {
|
|
89
|
-
return
|
|
89
|
+
return w(t) || A(t);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function q(t) {
|
|
92
92
|
return t.replace(new RegExp("this.", "g"), "");
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function D(t) {
|
|
95
95
|
return t.replace(/this\.context\??\./g, "");
|
|
96
96
|
}
|
|
97
|
-
function
|
|
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 =
|
|
100
|
-
}
|
|
101
|
-
function
|
|
102
|
-
let
|
|
103
|
-
for (const
|
|
104
|
-
|
|
105
|
-
new RegExp(`this.${
|
|
106
|
-
`this.${
|
|
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
|
|
108
|
+
return n;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
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,
|
|
124
|
+
return Object.entries(t).map(([e, n]) => `"${e}": ${m(n)}`);
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
return e ?
|
|
126
|
+
function G(t = {}, e = !1) {
|
|
127
|
+
const n = Object.keys(t);
|
|
128
|
+
return e ? n.map((s) => "." + s) : n;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function ae(t) {
|
|
131
131
|
let e = "";
|
|
132
|
-
for (var
|
|
133
|
-
if (t.hasOwnProperty(
|
|
134
|
-
var
|
|
135
|
-
e +=
|
|
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
|
|
140
|
-
return t.filter((
|
|
139
|
+
function le(t = [], e = []) {
|
|
140
|
+
return t.filter((n) => !e.includes(n));
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
return
|
|
142
|
+
function L(t) {
|
|
143
|
+
return ee(JSON.stringify(t));
|
|
144
144
|
}
|
|
145
|
-
class
|
|
146
|
-
constructor(e,
|
|
147
|
-
this.dsl = e, this.dependencies =
|
|
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
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
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(
|
|
175
|
+
o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(s);
|
|
176
176
|
}
|
|
177
177
|
return {
|
|
178
|
-
name:
|
|
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:
|
|
188
|
-
let
|
|
189
|
-
for (const i of
|
|
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
|
|
195
|
-
|
|
194
|
+
const h = a.path.replace(/\$/g, "\\$");
|
|
195
|
+
s = s.replace(new RegExp(h, "g"), "");
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
return
|
|
199
|
+
return s;
|
|
200
200
|
}
|
|
201
201
|
walk(e) {
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
204
|
-
if (Array.isArray(
|
|
205
|
-
for (let r of
|
|
206
|
-
|
|
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(
|
|
209
|
+
const i = Object.values(s);
|
|
210
210
|
for (const r of i)
|
|
211
|
-
j(r) ? r.value = this.replaceLibraryPath(r) :
|
|
211
|
+
j(r) ? r.value = this.replaceLibraryPath(r) : n(r);
|
|
212
212
|
};
|
|
213
|
-
|
|
213
|
+
n(e);
|
|
214
214
|
}
|
|
215
215
|
getLibraryMember(e = []) {
|
|
216
|
-
let
|
|
217
|
-
const
|
|
218
|
-
delete
|
|
219
|
-
for (const i of Object.values(
|
|
220
|
-
|
|
221
|
-
return
|
|
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,
|
|
224
|
-
const
|
|
225
|
-
let r = new Set(Array.from(
|
|
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:
|
|
228
|
-
r = /* @__PURE__ */ new Set([a,
|
|
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 || [],
|
|
233
|
-
r = /* @__PURE__ */ new Set([...
|
|
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
|
|
248
|
-
this.collectContext(
|
|
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((
|
|
250
|
+
Array.isArray(e.nodes) && e.nodes.forEach((s) => n(s));
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
return Object.entries(t).map(([e,
|
|
255
|
-
const
|
|
256
|
-
return `${e}:${
|
|
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
|
|
259
|
+
function fe(t = []) {
|
|
260
260
|
return t.map((e) => `${e.name}: {
|
|
261
261
|
from: '${e.from || e.name}',
|
|
262
|
-
default: ${
|
|
262
|
+
default: ${m(e.default, !0, !1, [], !1)}
|
|
263
263
|
}`);
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
const e = (
|
|
267
|
-
return t.map((
|
|
268
|
-
type:${e(
|
|
269
|
-
required: ${
|
|
270
|
-
default: ${
|
|
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
|
|
273
|
+
function he(t = []) {
|
|
274
274
|
return t.map((e) => `'${typeof e == "string" ? e : e.name}'`);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
return Object.entries(t).map(([
|
|
278
|
-
let i =
|
|
279
|
-
|
|
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 =
|
|
282
|
-
}).filter((
|
|
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
|
|
285
|
-
const
|
|
286
|
-
(r, o) => (o.id &&
|
|
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
|
-
),
|
|
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${
|
|
291
|
+
handler${Q(r.handler.value)}
|
|
292
292
|
}` : null).filter((r) => !!r);
|
|
293
293
|
return {
|
|
294
|
-
computed:
|
|
294
|
+
computed: s,
|
|
295
295
|
watches: i
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function ge(t = {}) {
|
|
299
299
|
return Object.values(t).map((e) => {
|
|
300
300
|
if (e.type === "mock") {
|
|
301
|
-
const
|
|
301
|
+
const n = A(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
|
|
302
302
|
return `async ${e.name}(...args) {
|
|
303
|
-
// DataSource: ${
|
|
304
|
-
const mock = this.provider.createMock(${
|
|
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
|
|
308
|
+
const n = A(e.transform) && e.transform.value || "(res) => res";
|
|
309
309
|
return `async ${e.name}(...args) {
|
|
310
|
-
// DataSource: ${
|
|
311
|
-
return await this.provider.apis['${e.ref}'].apply(this, args).then(${
|
|
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
|
|
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
|
-
],
|
|
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
|
|
341
|
+
function Z(t, e, n = [], s = {}, i) {
|
|
342
342
|
const r = [];
|
|
343
343
|
let o = {}, a = [];
|
|
344
|
-
const
|
|
345
|
-
let
|
|
346
|
-
return
|
|
344
|
+
const h = [];
|
|
345
|
+
let p = [];
|
|
346
|
+
return $e(t).forEach((c) => {
|
|
347
347
|
const y = [];
|
|
348
|
-
for (const
|
|
349
|
-
let { id: d, name:
|
|
350
|
-
if (
|
|
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 =
|
|
353
|
-
O && a.push(O),
|
|
354
|
-
const { props:
|
|
355
|
-
|
|
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
|
-
|
|
358
|
-
|
|
357
|
+
f.props,
|
|
358
|
+
f.events,
|
|
359
|
+
s,
|
|
360
|
+
n
|
|
361
|
+
), k = Ce(
|
|
362
|
+
f.directives,
|
|
359
363
|
n,
|
|
360
|
-
|
|
361
|
-
),
|
|
362
|
-
|
|
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 || []),
|
|
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(
|
|
378
|
-
) ?
|
|
376
|
+
g || e.get(v)?.package
|
|
377
|
+
) ? B(v) : X(g) || Y(g) ? "component" : v;
|
|
379
378
|
y.push(
|
|
380
|
-
|
|
379
|
+
ye.includes(I) ? `<${I} ${k} ${E} ${P} />` : `<${I} ${k} ${E} ${P}>${_ ? `
|
|
381
380
|
` + _.trim() : ""}</${I}>`
|
|
382
381
|
);
|
|
383
382
|
}
|
|
384
|
-
const
|
|
383
|
+
const l = Pe(c.slot, y.join(`
|
|
385
384
|
`), i?.id);
|
|
386
|
-
r.push(
|
|
385
|
+
r.push(l);
|
|
387
386
|
}), {
|
|
388
387
|
nodes: r,
|
|
389
388
|
methods: o,
|
|
390
|
-
directives: ve(
|
|
391
|
-
components:
|
|
392
|
-
importBlocks:
|
|
389
|
+
directives: ve(h),
|
|
390
|
+
components: C(a),
|
|
391
|
+
importBlocks: C(p, "id")
|
|
393
392
|
};
|
|
394
393
|
}
|
|
395
394
|
function ve(t) {
|
|
396
|
-
return
|
|
395
|
+
return C(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
|
|
397
396
|
}
|
|
398
|
-
function
|
|
397
|
+
function $e(t = []) {
|
|
399
398
|
const e = /* @__PURE__ */ new Map();
|
|
400
|
-
for (const
|
|
401
|
-
const
|
|
402
|
-
i ? i.children.push(
|
|
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
|
|
407
|
-
if (
|
|
408
|
-
const
|
|
409
|
-
if (
|
|
410
|
-
const i =
|
|
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
|
|
412
|
+
return z(n) || s ? t : null;
|
|
414
413
|
}
|
|
415
|
-
function
|
|
414
|
+
function z(t) {
|
|
416
415
|
return !!t && typeof t == "object" && t.type === "Schema";
|
|
417
416
|
}
|
|
418
|
-
function
|
|
417
|
+
function X(t) {
|
|
419
418
|
return typeof t == "object" && t.type === "UrlSchema";
|
|
420
419
|
}
|
|
421
|
-
function
|
|
420
|
+
function Y(t) {
|
|
422
421
|
return typeof t == "object" && t.type === "Plugin";
|
|
423
422
|
}
|
|
424
|
-
function
|
|
425
|
-
return t === "style" ? j(e) ? `:style="${
|
|
423
|
+
function je(t, e, n = []) {
|
|
424
|
+
return t === "style" ? j(e) ? `:style="${m({
|
|
426
425
|
...e,
|
|
427
|
-
value:
|
|
428
|
-
})}"` : "" : t === "__class" && j(e) ? `:class="${
|
|
426
|
+
value: x(e.value, n)
|
|
427
|
+
})}"` : "" : t === "__class" && j(e) ? `:class="${m({
|
|
429
428
|
...e,
|
|
430
|
-
value:
|
|
431
|
-
})}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${
|
|
429
|
+
value: x(e.value, n)
|
|
430
|
+
})}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${m({
|
|
432
431
|
...e,
|
|
433
|
-
value:
|
|
434
|
-
})}"` :
|
|
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
|
|
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 (
|
|
443
|
+
return (X(i) || Y(i)) && (e.is = {
|
|
445
444
|
type: "JSExpression",
|
|
446
445
|
value: t.name
|
|
447
|
-
}), Object.entries(e).map(([r, o]) =>
|
|
446
|
+
}), Object.entries(e).map(([r, o]) => je(r, o, n));
|
|
448
447
|
}
|
|
449
|
-
function
|
|
450
|
-
const
|
|
451
|
-
return
|
|
448
|
+
function ke(t, e, n) {
|
|
449
|
+
const s = G(e.modifiers, !0);
|
|
450
|
+
return `@${t}${s.join("")}="${n}"`;
|
|
452
451
|
}
|
|
453
|
-
function
|
|
454
|
-
const
|
|
452
|
+
function we(t, e = {}, n = {}) {
|
|
453
|
+
const s = {};
|
|
455
454
|
return {
|
|
456
|
-
binders: Object.entries(e).map(([
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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:
|
|
462
|
+
handlers: s
|
|
466
463
|
};
|
|
467
464
|
}
|
|
468
|
-
function
|
|
469
|
-
const { binders: o, handlers: a } =
|
|
465
|
+
function xe(t, e, n = {}, s = {}, i = {}, r) {
|
|
466
|
+
const { binders: o, handlers: a } = we(e, s, i);
|
|
470
467
|
return {
|
|
471
|
-
props:
|
|
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 = [],
|
|
478
|
-
const
|
|
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:
|
|
484
|
-
vFor:
|
|
485
|
-
vBind:
|
|
480
|
+
vModels: h,
|
|
481
|
+
vFor: p,
|
|
482
|
+
vBind: u,
|
|
486
483
|
vHtml: c,
|
|
487
484
|
customDirectives: y
|
|
488
|
-
} =
|
|
489
|
-
if (i &&
|
|
490
|
-
`v-else-if="${
|
|
491
|
-
), r &&
|
|
492
|
-
`v-show="${
|
|
493
|
-
),
|
|
494
|
-
`v-bind="${
|
|
495
|
-
),
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
`v-model${d}${
|
|
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
|
-
}),
|
|
501
|
-
const { item:
|
|
502
|
-
|
|
503
|
-
`v-for="(${
|
|
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 &&
|
|
507
|
-
`v-html="${
|
|
508
|
-
), y && y.length && y.forEach((
|
|
509
|
-
if (!
|
|
510
|
-
let
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
const
|
|
515
|
-
|
|
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
|
-
|
|
518
|
-
`${
|
|
519
|
-
) :
|
|
520
|
-
}),
|
|
514
|
+
l.value ? s.push(
|
|
515
|
+
`${f}="${m(l.value, !0, !0, e)}"`
|
|
516
|
+
) : s.push(f);
|
|
517
|
+
}), s;
|
|
521
518
|
}
|
|
522
|
-
function
|
|
519
|
+
function Oe(t = []) {
|
|
523
520
|
const e = t.filter(
|
|
524
|
-
(c) =>
|
|
525
|
-
),
|
|
526
|
-
(c) => !
|
|
527
|
-
),
|
|
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
|
-
),
|
|
534
|
+
), h = e.find(
|
|
538
535
|
(c) => b(c.name) === "vBind"
|
|
539
|
-
),
|
|
536
|
+
), p = e.find(
|
|
540
537
|
(c) => b(c.name) === "vHtml"
|
|
541
|
-
),
|
|
538
|
+
), u = e.filter(
|
|
542
539
|
(c) => b(c.name) === "vModel"
|
|
543
540
|
);
|
|
544
541
|
return {
|
|
545
|
-
vIf:
|
|
542
|
+
vIf: s,
|
|
546
543
|
vElseIf: i,
|
|
547
544
|
vElse: r,
|
|
548
545
|
vFor: o,
|
|
549
546
|
vShow: a,
|
|
550
|
-
vModels:
|
|
551
|
-
vBind:
|
|
552
|
-
vHtml:
|
|
553
|
-
customDirectives:
|
|
547
|
+
vModels: u,
|
|
548
|
+
vBind: h,
|
|
549
|
+
vHtml: p,
|
|
550
|
+
customDirectives: n
|
|
554
551
|
};
|
|
555
552
|
}
|
|
556
|
-
function
|
|
557
|
-
return typeof t == "string" ? t :
|
|
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
|
|
556
|
+
function Pe(t, e, n) {
|
|
560
557
|
if (!t) return e;
|
|
561
|
-
const
|
|
562
|
-
return `<template ${`#${
|
|
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
|
|
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
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
578
|
-
const c = o[
|
|
579
|
-
c.push(y), i === "uniapp" && r.includes(
|
|
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 [
|
|
583
|
-
(o[
|
|
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(([
|
|
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 '${
|
|
584
|
+
)}} from '${p}';`).concat(n),
|
|
588
585
|
uniComponents: a
|
|
589
586
|
};
|
|
590
587
|
}
|
|
591
|
-
function
|
|
588
|
+
function Ie(t = {}) {
|
|
592
589
|
const e = [];
|
|
593
|
-
for (const [
|
|
590
|
+
for (const [n, s] of Object.entries(t))
|
|
594
591
|
e.push(`
|
|
595
|
-
${
|
|
596
|
-
${
|
|
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(([
|
|
601
|
+
return Object.entries(t).forEach(([n, s]) => {
|
|
605
602
|
e.push(
|
|
606
|
-
`const ${
|
|
603
|
+
`const ${n} = provider.defineUrlSchemaComponent('${s.url}');`
|
|
607
604
|
);
|
|
608
605
|
}), e;
|
|
609
606
|
}
|
|
610
|
-
function
|
|
607
|
+
function Ae(t = {}) {
|
|
611
608
|
const e = [];
|
|
612
|
-
return Object.entries(t).forEach(([
|
|
609
|
+
return Object.entries(t).forEach(([n, s]) => {
|
|
613
610
|
e.push(
|
|
614
|
-
`const ${
|
|
611
|
+
`const ${n} = provider.definePluginComponent(${JSON.stringify(s)});`
|
|
615
612
|
);
|
|
616
613
|
}), e;
|
|
617
614
|
}
|
|
618
|
-
function Be(t, e,
|
|
619
|
-
const { dsl:
|
|
620
|
-
|
|
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
|
-
),
|
|
621
|
+
), f = [...o, ...a.computed], d = N(
|
|
625
622
|
{
|
|
626
|
-
...
|
|
627
|
-
...
|
|
623
|
+
...p,
|
|
624
|
+
...s.methods || {}
|
|
628
625
|
},
|
|
629
626
|
i
|
|
630
|
-
),
|
|
631
|
-
let { imports:
|
|
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
|
-
|
|
633
|
+
n
|
|
637
634
|
);
|
|
638
635
|
const O = Object.keys({
|
|
639
636
|
...t.urlSchemas,
|
|
640
637
|
...t.blockPlugins
|
|
641
|
-
}),
|
|
638
|
+
}), E = Ne(t.urlSchemas), P = Ae(t.blockPlugins);
|
|
642
639
|
return {
|
|
643
|
-
id:
|
|
644
|
-
version:
|
|
645
|
-
name:
|
|
646
|
-
state:
|
|
647
|
-
inject:
|
|
648
|
-
props:
|
|
649
|
-
emits:
|
|
650
|
-
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:
|
|
654
|
-
methods: [...
|
|
650
|
+
computed: f.join(","),
|
|
651
|
+
methods: [...h, ...d].join(","),
|
|
655
652
|
imports: `
|
|
656
|
-
` +
|
|
653
|
+
` + $.join(`
|
|
657
654
|
`),
|
|
658
|
-
components:
|
|
659
|
-
directives:
|
|
655
|
+
components: le(c, g).join(","),
|
|
656
|
+
directives: l.join(","),
|
|
660
657
|
returns: t.members.join(","),
|
|
661
|
-
template:
|
|
658
|
+
template: u.join(`
|
|
662
659
|
`),
|
|
663
|
-
css:
|
|
664
|
-
style:
|
|
665
|
-
urlSchemas:
|
|
660
|
+
css: s.css || "",
|
|
661
|
+
style: Ie(t.style),
|
|
662
|
+
urlSchemas: E.join(`
|
|
666
663
|
`),
|
|
667
|
-
blockPlugins:
|
|
664
|
+
blockPlugins: P.join(`
|
|
668
665
|
`),
|
|
669
666
|
asyncComponents: O.join(","),
|
|
670
667
|
uniComponents: g,
|
|
671
|
-
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, ""),
|
|
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 =
|
|
719
|
-
async function
|
|
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:
|
|
724
|
-
platform:
|
|
720
|
+
dependencies: n,
|
|
721
|
+
platform: s,
|
|
725
722
|
formatterDisabled: i
|
|
726
723
|
}, {
|
|
727
724
|
dsl: a,
|
|
728
|
-
componentMap:
|
|
729
|
-
dependencies:
|
|
730
|
-
platform:
|
|
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:
|
|
734
|
-
} = o,
|
|
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
|
|
735
|
+
css: await W(d.css, c) || `
|
|
739
736
|
/* 组件样式内容 */
|
|
740
737
|
`,
|
|
741
|
-
script: await
|
|
742
|
-
style: await
|
|
738
|
+
script: await oe(v, c),
|
|
739
|
+
style: await W(d.style, c),
|
|
743
740
|
scriptLang: y ? "ts" : "js",
|
|
744
|
-
styleLang:
|
|
741
|
+
styleLang: l ? "scss" : "css"
|
|
745
742
|
});
|
|
746
|
-
return await
|
|
743
|
+
return await H($, c).catch((g) => (g.content = $, Promise.reject(g)));
|
|
747
744
|
}
|
|
748
|
-
async function
|
|
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
|
|
758
|
+
return await H(e);
|
|
762
759
|
}
|
|
763
760
|
export {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
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.
|
|
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/
|
|
26
|
-
"@vtj/
|
|
25
|
+
"@vtj/base": "~0.12.4",
|
|
26
|
+
"@vtj/core": "~0.16.28"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@vtj/cli": "~0.12.19"
|
package/types/version.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
8
|
+
export declare const version = "0.16.27";
|