@vtj/coder 0.12.55 → 0.12.57
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 +32 -30
- package/dist/index.mjs +109 -104
- package/package.json +3 -3
- package/types/utils.d.ts +5 -1
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@vtj/base"),T=require("prettier/standalone"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@vtj/base"),T=require("prettier/standalone"),K=require("prettier/plugins/html"),ee=require("prettier/plugins/babel"),te=require("prettier/plugins/postcss"),ne=require("prettier/plugins/estree");function F(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const se=F(K),L=F(ee),U=F(te),V=F(ne);/**!
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/coder
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.12.
|
|
5
|
+
* @version 0.12.57
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const
|
|
7
|
+
*/const re="0.12.57";/**!
|
|
8
8
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
9
9
|
* @name @vtj/core
|
|
10
10
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
11
|
-
* @version 0.12.
|
|
11
|
+
* @version 0.12.57
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
|
-
*/const
|
|
13
|
+
*/const ie=["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 R(t,e){return e?t:await T.format(t,{parser:"vue",...B,plugins:[se,L,V,U]})}async function M(t,e){if(e)return t;try{return(await T.format(t,{parser:"babel-ts",...B,plugins:[L,V]})).replace(/;\n$/gi,"")}catch(n){return console.warn(n),t}}async function N(t,e){return e?t:T.format(t,{parser:"scss",...B,plugins:[U]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function b(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function D(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,n=!0,s=[]){let r=b(t)?t.value.trim().replace(/\"/g,"'").replace(/;$/,""):e?JSON.stringify(t):t;return r=w(r,s),n?H(D(r)):D(r)}function w(t,e=[]){let n=t;for(const s of e)n=n.replace(new RegExp(`this.${s}.value`,"g"),`this.${s}`);return n}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 r=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,i=e.match(r);i&&i[2]&&(i[2].startsWith("{")||(e=e.replace(i[2],`{ return ${i[2]} }`))),e=e.replace("=>","")}return e}function oe(t={}){return Object.entries(t).map(([e,n])=>`"${e}": ${d(n)}`)}function z(t={},e=!1){const n=Object.keys(t);return e?n.map(s=>"."+s):n}function ce(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var s=t[n];e+=n+": "+s+";"}return e}function ae(t=[],e=[]){return t.filter(n=>!e.includes(n))}function J(t){return m.base64(JSON.stringify(t))}class le{constructor(e,n){this.dsl=e,this.dependencies=n,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const n=e.split(".");if(n.length===4){const s=n.pop(),r=n.join(".")+".",i=n.pop();if(s&&i){const o=this.dependencies.find(c=>c.library===i)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(s)}return{name:s,path:r,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let s=e.value;for(const r of n){const i=e.value?.match(r)||[];for(const o of i){const c=this.collectImport(o);if(c){const f=c.path.replace(/\$/g,"\\$");s=s.replace(new RegExp(f,"g"),"")}}}return s}walk(e){const n=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){for(let i of s)n(i);return}const r=Object.values(s);for(const i of r)b(i)?i.value=this.replaceLibraryPath(i):n(i)};n(e)}getLibraryMember(e=[]){let n=[...e];const s={...this.imports};delete s["uni-h5"],delete s["@dcloudio/uni-h5"],delete s["uni-ui"],delete s["@dcloudio/uni-ui"];for(const r of Object.values(s))n=n.concat(Array.from(r));return m.dedupArray(n)}collectContext(e,n){const s=new Set(n?.id?this.context[n.id]:[]),r=(e.directives||[]).find(c=>c.name==="vFor");let i=new Set(Array.from(s));if(r){const{item:c="item",index:f="index"}=r.iterator||{};i=new Set([c,f,...Array.from(i)])}const o=e.slot;if(o){const c=typeof o=="string"?[]:o.params||[],f=c.length?c:[`scope_${n?.id}`];i=new Set([...f,...Array.from(i)])}this.context[e.id]=i}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!b(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 n=(s,r)=>{this.collectContext(s,r),this.collectStyle(s),this.collectUrlSchema(s),this.collectBlockPlugin(s),Array.isArray(s.children)&&s.children.forEach(i=>n(i,s))};Array.isArray(e.nodes)&&e.nodes.forEach(s=>n(s))}}function ue(t={}){return Object.entries(t).map(([e,n])=>{const s=d(n,!1);return`${e}:${s}`})}function pe(t=[]){return t.map(e=>`${e.name}: {
|
|
14
14
|
from: '${e.from||e.name}',
|
|
15
15
|
default: ${d(e.default,!0,!1)}
|
|
16
|
-
}`)}function
|
|
17
|
-
type:${e(
|
|
18
|
-
required: ${d(!!
|
|
19
|
-
default: ${d(
|
|
20
|
-
}`))}function
|
|
16
|
+
}`)}function fe(t=[]){const e=n=>n?`[${m.toArray(n).map(i=>i.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(n=>typeof n=="string"?`${n}: {}`:(b(n.default)&&!n.default.value&&(n.default.value="undefined"),`${n.name}: {
|
|
17
|
+
type:${e(n.type)},
|
|
18
|
+
required: ${d(!!n.required,!0,!1)},
|
|
19
|
+
default: ${d(n.default,!0,!1)}
|
|
20
|
+
}`))}function me(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([n,s])=>{let r=Q(d(s,!1,!1));return r=w(r,e),r.startsWith("async")?`async ${n}${r.replace(/^async/,"")}`:`${n}${r}`})}function he(t=[],e=[]){const n=t.reduce((i,o)=>(o.id&&I(o.source)&&(i[`watcher_${o.id}`]=o.source),i),{}),s=A(n,e),r=t.map(i=>`watcher_${i.id}: {
|
|
21
21
|
deep: ${i.deep},
|
|
22
22
|
immediate:${i.immediate},
|
|
23
|
-
handler${
|
|
24
|
-
}`);return{computed:
|
|
25
|
-
|
|
23
|
+
handler${Q(i.handler.value)}
|
|
24
|
+
}`);return{computed:s,watches:r}}function de(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const n=I(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args) {
|
|
25
|
+
// DataSource: ${J(e)}
|
|
26
|
+
const mock = this.provider.createMock(${n});
|
|
26
27
|
return await mock.apply(this, args);
|
|
27
|
-
}`}else{const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`),
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
}`}else{const n=I(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args) {
|
|
29
|
+
// DataSource: ${J(e)}
|
|
30
|
+
return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
|
|
31
|
+
}`}})}const ye=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],q=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"];function G(t,e,n=[],s={},r){const i=[];let o={},c=[];const f=[];let l=[];return ve(t).forEach(a=>{const g=[];for(const h of a.children){let{id:y,name:$,invisible:j,from:v}=h;if(j)continue;const C=$e($,e,v);C&&c.push(C),X(v)&&l.push({id:v.id,name:$});const{props:P,events:O,handlers:E}=we(h,y,h.props,h.events,s,n),W=Ce(h.directives,n,f).join(" "),S=h.children?Oe(h.children,n,e,s,h):"";Object.assign(o,E);let _="";typeof S=="string"?_=S:(_=(S?.nodes||[]).join(`
|
|
32
|
+
`),Object.assign(o,S?.methods||{}),c=c.concat(S?.components||[]),l=l.concat(S?.importBlocks||[]));const x=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes(v||e.get($)?.package)?m.kebabCase($):Y(v)||Z(v)?"component":$;g.push(ye.includes(x)?`<${x} ${W} ${P} ${O} />`:`<${x} ${W} ${P} ${O}>${_?`
|
|
33
|
+
`+_.trim():""}</${x}>`)}const p=Ee(a.slot,g.join(`
|
|
34
|
+
`),r?.id);i.push(p)}),{nodes:i,methods:o,directives:ge(f),components:m.dedupArray(c),importBlocks:m.dedupArray(l,"id")}}function ge(t){return m.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ve(t=[]){const e=new Map;for(const n of t){const s=typeof n.slot=="string"?n.slot:n.slot?.name,r=e.get(s);r?r.children.push(n):e.set(s,{slot:n.slot,children:[n]})}return e}function $e(t,e,n){if(ie.includes(t))return null;const s=e.get(t);if(s&&s.alias){const r=s.parent?`${s.parent}.${s.alias}`:s.alias;return`${t}: ${r}`}return X(n)||s?t:null}function X(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function Y(t){return typeof t=="object"&&t.type==="UrlSchema"}function Z(t){return typeof t=="object"&&t.type==="Plugin"}function be(t,e,n=[]){return t==="style"?b(e)?`:style="${d({...e,value:w(e.value,n)})}"`:"":t==="__class"&&b(e)?`:class="${d({...e,value:w(e.value,n)})}"`:typeof e=="string"?`${t}="${e}"`:b(e)?`:${t}="${d({...e,value:w(e.value,n)})}"`:m.isPlainObject(e)?`:${t}='{${oe(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function je(t,e={},n=[]){if(!!Object.keys(e.style||{}).length){const i=`${t.name}_${t.id}`;e.class?typeof e.class=="string"?e.class=[e.class,i].join(" "):(e.__class=e.class,e.class=i):e.class=i,b(e.style)||delete e.style}const r=t.from;return(Y(r)||Z(r))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([i,o])=>be(i,o,n))}function Se(t,e,n,s,r){const i=z(e.modifiers,!0);return r?`@${t}${i.join("")}="${n}"`:s&&s.length>0?`@${t}${i.join("")}="(...args:any[]) => ${n}"`:`@${t}${i.join("")}="${n}"`}function ke(t,e={},n={}){const s={},r=Array.from(n[t]||new Set([])),i=r.length?`({${r.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([c,f])=>{const l=f.handler.value.startsWith("this."),u=l?H(f.handler.value):`${m.camelCase(c)}_${t}${i}`;return l||(s[u]=r.length?{type:"JSFunction",value:`{
|
|
33
35
|
return (${f.handler.value}).apply(this, args);
|
|
34
|
-
}`}:f.handler),
|
|
36
|
+
}`}:f.handler),Se(c,f,u,r,l)}),handlers:s}}function we(t,e,n={},s={},r={},i){const{binders:o,handlers:c}=ke(e,s,r);return{props:je(t,n,i).join(" "),handlers:c,binders:o,events:o.join(" ")}}function Ce(t=[],e=[],n=[]){const s=[],{vIf:r,vElse:i,vElseIf:o,vShow:c,vModels:f,vFor:l,vBind:u,vHtml:a,customDirectives:g}=Pe(t);if(r&&s.push(`v-if="${d(r.value,!0,!0,e)}"`),o&&s.push(`v-else-if="${d(o.value,!0,!0,e)}"`),i&&s.push("v-else"),c&&s.push(`v-show="${d(c.value,!0,!0,e)}"`),u&&s.push(`v-bind="${d(u.value,!0,!0,e)}"`),f.forEach(p=>{const h=z(p.modifiers,!0),y=p.arg?k(p.arg)?`:[${d(p.arg,!0,!0,e)}]`:`:${p.arg}`:"";s.push(`v-model${y}${h}="${d(p.value,!0,!0,e)}"`)}),l){const{item:p,index:h}={item:"item",index:"index",...l.iterator};s.push(`v-for="(${p}, ${h}) in ${d(l.value,!0,!0,e)}"`)}return a&&s.push(`v-html="${d(a.value,!0,!0,e)}"`),g&&g.length&&g.forEach(p=>{if(!p.name)return;let h="",y="";k(p.name)?(y=d(p.name,!0,!0,e),n.push(y)):y=p.name;const $=y?.startsWith("v")?m.kebabCase(y):m.kebabCase("v-"+y);if(h+=$,p.arg&&(k(p.arg)?h+=`:[${d(p.name,!0,!0,e)}]`:h+=`:${p.arg}`),p.modifiers){const j=Object.keys(p.modifiers);j.length&&(h+=j.map(v=>"."+v))}p.value?s.push(`${h}="${d(p.value,!0,!0,e)}"`):s.push(h)}),s}function Pe(t=[]){const e=t.filter(a=>q.includes(a.name)),n=t.filter(a=>!q.includes(a.name)),s=e.find(a=>m.camelCase(a.name)==="vIf"),r=e.find(a=>m.camelCase(a.name)==="vElseIf"),i=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"),f=e.find(a=>m.camelCase(a.name)==="vBind"),l=e.find(a=>m.camelCase(a.name)==="vHtml"),u=e.filter(a=>m.camelCase(a.name)==="vModel");return{vIf:s,vElseIf:r,vElse:i,vFor:o,vShow:c,vModels:u,vBind:f,vHtml:l,customDirectives:n}}function Oe(t,e,n,s,r){return typeof t=="string"?t:k(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?G(t,n,e,s,r):""}function Ee(t,e,n){if(!t)return e;const s=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${s.name}="${s.params?.length>0?`{${s.params?.join(",")}}`:`scope_${n}`}"`}>
|
|
35
37
|
${e}
|
|
36
|
-
</template>`}function
|
|
37
|
-
${
|
|
38
|
-
${
|
|
38
|
+
</template>`}function _e(t,e=[],n=[],s={},r="web"){const i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],o={vue:["defineComponent","reactive"]},c=[];for(const l of e){const u=t.get(l.split(":")[0]);if(u&&u.package){const a=o[u.package]??(o[u.package]=[]),g=u.parent||(u.alias||"").split(".")[0]||u.name;a.push(g),r==="uniapp"&&i.includes(u.package)&&c.push(g)}}for(const[l,u]of Object.entries(s))(o[l]??(o[l]=[])).push(...Array.from(u)),r==="uniapp"&&i.includes(l)&&c.push(...Array.from(u));return{imports:Object.entries(o).filter(([l,u])=>r==="uniapp"?!i.includes(l)&&!!u.length:!!u.length).map(([l,u])=>`import { ${m.dedupArray(u).join(",")}} from '${l}';`).concat(n),uniComponents:c}}function xe(t={}){const e=[];for(const[n,s]of Object.entries(t))e.push(`
|
|
39
|
+
${n} {
|
|
40
|
+
${ce(s)}
|
|
39
41
|
}
|
|
40
42
|
`);return e.join(`
|
|
41
|
-
`)}function
|
|
43
|
+
`)}function Ae(t={}){const e=[];return Object.entries(t).forEach(([n,s])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${s.url}');`)}),e}function Ie(t={}){const e=[];return Object.entries(t).forEach(([n,s])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(s)});`)}),e}function Fe(t,e,n="web"){const{dsl:s}=t,r=Object.keys(s.computed||{}),i=A(s.lifeCycles,r),o=A(s.computed,r),c=he(s.watch,r),f=de(s.dataSources),{methods:l,nodes:u,components:a,importBlocks:g,directives:p}=G(s.nodes||[],e,r,t.context),h=[...o,...c.computed],y=A({...l,...s.methods||{}},r),$=g.map(E=>`import ${E.name} from './${E.id}.vue';`);let{imports:j,uniComponents:v}=_e(e,a,$,t.imports,n);const C=Object.keys({...t.urlSchemas,...t.blockPlugins}),P=Ae(t.urlSchemas),O=Ie(t.blockPlugins);return{id:s.id,version:s.__VERSION__,name:s.name,state:ue(s.state).join(","),inject:pe(s.inject).join(","),props:fe(s.props).join(","),emits:me(s.emits).join(","),watch:c.watches.join(","),lifeCycles:i.join(","),computed:h.join(","),methods:[...f,...y].join(","),imports:`
|
|
42
44
|
`+j.join(`
|
|
43
|
-
`),components:
|
|
44
|
-
`),css:
|
|
45
|
+
`),components:ae(a,v).join(","),directives:p.join(","),returns:t.members.join(","),template:u.join(`
|
|
46
|
+
`),css:s.css||"",style:xe(t.style),urlSchemas:P.join(`
|
|
45
47
|
`),blockPlugins:O.join(`
|
|
46
|
-
`),asyncComponents:C.join(","),uniComponents:v,renderer:
|
|
48
|
+
`),asyncComponents:C.join(","),uniComponents:v,renderer:n==="uniapp"?"@vtj/uni-app":"@vtj/renderer"}}const Ne=`
|
|
47
49
|
// @ts-nocheck
|
|
48
50
|
|
|
49
51
|
<%= imports %>
|
|
@@ -75,7 +77,7 @@ export default defineComponent({
|
|
|
75
77
|
<% if(methods) { %> methods: { <%= methods %> }, <% } %>
|
|
76
78
|
<% if(watch) { %> watch: { <%= watch %> }, <% } %> <%= lifeCycles %>
|
|
77
79
|
});
|
|
78
|
-
`.replace(/(\n|\r|\t)/g,""),
|
|
80
|
+
`.replace(/(\n|\r|\t)/g,""),Te=`
|
|
79
81
|
<template>
|
|
80
82
|
<%= template %>
|
|
81
83
|
</template>
|
|
@@ -86,7 +88,7 @@ export default defineComponent({
|
|
|
86
88
|
<%= css %>
|
|
87
89
|
<%= style %>
|
|
88
90
|
</style>
|
|
89
|
-
`,
|
|
91
|
+
`,Be=m.template(Ne),Re=m.template(Te);async function We(t,e=new Map,n=[],s="web",r){const i=new le(m.cloneDeep(t),n),o=Fe(i,e,s),c=Be(o),f=Re({template:o.template,css:await N(o.css,r),script:await M(c,r),style:await N(o.style,r)});return await R(f,r).catch(l=>(l.content=f,Promise.reject(l)))}async function De(t){const e=`
|
|
90
92
|
<template>
|
|
91
93
|
<div>
|
|
92
94
|
<h3>源码模式页面</h3>
|
|
@@ -97,4 +99,4 @@ export default defineComponent({
|
|
|
97
99
|
<\/script>
|
|
98
100
|
<style scoped lang="scss">
|
|
99
101
|
</style>
|
|
100
|
-
`;return await R(e)}exports.VTJ_CODER_VERSION=
|
|
102
|
+
`;return await R(e)}exports.VTJ_CODER_VERSION=re;exports.createEmptyPage=De;exports.cssFormatter=N;exports.generator=We;exports.tsFormatter=M;exports.vueFormatter=R;
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { mitt as
|
|
1
|
+
import { mitt as ee, base64 as te, dedupArray as C, toArray as ne, kebabCase as F, camelCase as v, isPlainObject as se, template as U, cloneDeep as re } from "@vtj/base";
|
|
2
2
|
import { format as B } from "prettier/standalone";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
3
|
+
import * as ie from "prettier/plugins/html";
|
|
4
|
+
import * as V from "prettier/plugins/babel";
|
|
5
|
+
import * as H from "prettier/plugins/postcss";
|
|
6
|
+
import * as q from "prettier/plugins/estree";
|
|
7
7
|
/**!
|
|
8
8
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
9
9
|
* @name @vtj/coder
|
|
10
10
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
11
|
-
* @version 0.12.
|
|
11
|
+
* @version 0.12.57
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const
|
|
14
|
+
const Ue = "0.12.57";
|
|
15
15
|
/**!
|
|
16
16
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
17
17
|
* @name @vtj/core
|
|
18
18
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
19
|
-
* @version 0.12.
|
|
19
|
+
* @version 0.12.57
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
22
|
+
const oe = [
|
|
23
23
|
"slot",
|
|
24
24
|
"template",
|
|
25
25
|
"component",
|
|
@@ -32,7 +32,7 @@ const re = [
|
|
|
32
32
|
"span",
|
|
33
33
|
"a"
|
|
34
34
|
];
|
|
35
|
-
|
|
35
|
+
ee();
|
|
36
36
|
const T = {
|
|
37
37
|
arrowParens: "always",
|
|
38
38
|
bracketSpacing: !0,
|
|
@@ -53,20 +53,20 @@ const T = {
|
|
|
53
53
|
useTabs: !1,
|
|
54
54
|
vueIndentScriptAndStyle: !0
|
|
55
55
|
};
|
|
56
|
-
async function
|
|
56
|
+
async function M(t, e) {
|
|
57
57
|
return e ? t : await B(t, {
|
|
58
58
|
parser: "vue",
|
|
59
59
|
...T,
|
|
60
|
-
plugins: [
|
|
60
|
+
plugins: [ie, V, q, H]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
async function
|
|
63
|
+
async function ce(t, e) {
|
|
64
64
|
if (e) return t;
|
|
65
65
|
try {
|
|
66
66
|
return (await B(t, {
|
|
67
67
|
parser: "babel-ts",
|
|
68
68
|
...T,
|
|
69
|
-
plugins: [
|
|
69
|
+
plugins: [V, q]
|
|
70
70
|
})).replace(/;\n$/gi, "");
|
|
71
71
|
} catch (n) {
|
|
72
72
|
return console.warn(n), t;
|
|
@@ -76,7 +76,7 @@ async function W(t, e) {
|
|
|
76
76
|
return e ? t : B(t, {
|
|
77
77
|
parser: "scss",
|
|
78
78
|
...T,
|
|
79
|
-
plugins: [
|
|
79
|
+
plugins: [H]
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
function k(t) {
|
|
@@ -88,7 +88,7 @@ function N(t) {
|
|
|
88
88
|
function b(t) {
|
|
89
89
|
return k(t) || N(t);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function Q(t) {
|
|
92
92
|
return t.replace(new RegExp("this.", "g"), "");
|
|
93
93
|
}
|
|
94
94
|
function J(t) {
|
|
@@ -96,7 +96,7 @@ function J(t) {
|
|
|
96
96
|
}
|
|
97
97
|
function h(t, e = !0, n = !0, s = []) {
|
|
98
98
|
let r = b(t) ? t.value.trim().replace(/\"/g, "'").replace(/;$/, "") : e ? JSON.stringify(t) : t;
|
|
99
|
-
return r = w(r, s), n ?
|
|
99
|
+
return r = w(r, s), n ? Q(J(r)) : J(r);
|
|
100
100
|
}
|
|
101
101
|
function w(t, e = []) {
|
|
102
102
|
let n = t;
|
|
@@ -107,7 +107,7 @@ function w(t, e = []) {
|
|
|
107
107
|
);
|
|
108
108
|
return n;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function G(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"))
|
|
@@ -120,14 +120,14 @@ function Q(t) {
|
|
|
120
120
|
}
|
|
121
121
|
return e;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function ae(t = {}) {
|
|
124
124
|
return Object.entries(t).map(([e, n]) => `"${e}": ${h(n)}`);
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function X(t = {}, e = !1) {
|
|
127
127
|
const n = Object.keys(t);
|
|
128
128
|
return e ? n.map((s) => "." + s) : n;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function le(t) {
|
|
131
131
|
let e = "";
|
|
132
132
|
for (var n in t)
|
|
133
133
|
if (t.hasOwnProperty(n)) {
|
|
@@ -136,10 +136,13 @@ function ce(t) {
|
|
|
136
136
|
}
|
|
137
137
|
return e;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function ue(t = [], e = []) {
|
|
140
140
|
return t.filter((n) => !e.includes(n));
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
function D(t) {
|
|
143
|
+
return te(JSON.stringify(t));
|
|
144
|
+
}
|
|
145
|
+
class pe {
|
|
143
146
|
constructor(e, n) {
|
|
144
147
|
this.dsl = e, this.dependencies = n, this.libraryRegex = this.collectLibrary(), this.walk(e), this.walkNodes(e), this.members = this.getLibraryMember();
|
|
145
148
|
}
|
|
@@ -247,66 +250,68 @@ class le {
|
|
|
247
250
|
Array.isArray(e.nodes) && e.nodes.forEach((s) => n(s));
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
|
-
function
|
|
253
|
+
function fe(t = {}) {
|
|
251
254
|
return Object.entries(t).map(([e, n]) => {
|
|
252
255
|
const s = h(n, !1);
|
|
253
256
|
return `${e}:${s}`;
|
|
254
257
|
});
|
|
255
258
|
}
|
|
256
|
-
function
|
|
259
|
+
function me(t = []) {
|
|
257
260
|
return t.map((e) => `${e.name}: {
|
|
258
261
|
from: '${e.from || e.name}',
|
|
259
262
|
default: ${h(e.default, !0, !1)}
|
|
260
263
|
}`);
|
|
261
264
|
}
|
|
262
|
-
function
|
|
263
|
-
const e = (n) => n ? `[${
|
|
265
|
+
function he(t = []) {
|
|
266
|
+
const e = (n) => n ? `[${ne(n).map((i) => i.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
|
|
264
267
|
return t.map((n) => typeof n == "string" ? `${n}: {}` : (b(n.default) && !n.default.value && (n.default.value = "undefined"), `${n.name}: {
|
|
265
268
|
type:${e(n.type)},
|
|
266
269
|
required: ${h(!!n.required, !0, !1)},
|
|
267
270
|
default: ${h(n.default, !0, !1)}
|
|
268
271
|
}`));
|
|
269
272
|
}
|
|
270
|
-
function
|
|
273
|
+
function de(t = []) {
|
|
271
274
|
return t.map((e) => `'${typeof e == "string" ? e : e.name}'`);
|
|
272
275
|
}
|
|
273
276
|
function A(t = {}, e = []) {
|
|
274
277
|
return Object.entries(t).map(([n, s]) => {
|
|
275
|
-
let r =
|
|
278
|
+
let r = G(h(s, !1, !1));
|
|
276
279
|
return r = w(r, e), r.startsWith("async") ? `async ${n}${r.replace(/^async/, "")}` : `${n}${r}`;
|
|
277
280
|
});
|
|
278
281
|
}
|
|
279
|
-
function
|
|
282
|
+
function ye(t = [], e = []) {
|
|
280
283
|
const n = t.reduce(
|
|
281
284
|
(i, o) => (o.id && N(o.source) && (i[`watcher_${o.id}`] = o.source), i),
|
|
282
285
|
{}
|
|
283
286
|
), s = A(n, e), r = t.map((i) => `watcher_${i.id}: {
|
|
284
287
|
deep: ${i.deep},
|
|
285
288
|
immediate:${i.immediate},
|
|
286
|
-
handler${
|
|
289
|
+
handler${G(i.handler.value)}
|
|
287
290
|
}`);
|
|
288
291
|
return {
|
|
289
292
|
computed: s,
|
|
290
293
|
watches: r
|
|
291
294
|
};
|
|
292
295
|
}
|
|
293
|
-
function
|
|
296
|
+
function ge(t = {}) {
|
|
294
297
|
return Object.values(t).map((e) => {
|
|
295
298
|
if (e.type === "mock") {
|
|
296
299
|
const n = N(e.mockTemplate) && e.mockTemplate.value || "(params) => ({})";
|
|
297
|
-
return `async ${e.name}(...args
|
|
298
|
-
|
|
300
|
+
return `async ${e.name}(...args) {
|
|
301
|
+
// DataSource: ${D(e)}
|
|
302
|
+
const mock = this.provider.createMock(${n});
|
|
299
303
|
return await mock.apply(this, args);
|
|
300
304
|
}`;
|
|
301
305
|
} else {
|
|
302
306
|
const n = N(e.transform) && e.transform.value || "(res) => res";
|
|
303
|
-
return `async ${e.name}(...args
|
|
307
|
+
return `async ${e.name}(...args) {
|
|
308
|
+
// DataSource: ${D(e)}
|
|
304
309
|
return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
|
|
305
310
|
}`;
|
|
306
311
|
}
|
|
307
312
|
});
|
|
308
313
|
}
|
|
309
|
-
const
|
|
314
|
+
const $e = [
|
|
310
315
|
"img",
|
|
311
316
|
"input",
|
|
312
317
|
"br",
|
|
@@ -331,31 +336,31 @@ const ye = [
|
|
|
331
336
|
"vBind",
|
|
332
337
|
"vHtml"
|
|
333
338
|
];
|
|
334
|
-
function
|
|
339
|
+
function z(t, e, n = [], s = {}, r) {
|
|
335
340
|
const i = [];
|
|
336
341
|
let o = {}, c = [];
|
|
337
342
|
const f = [];
|
|
338
343
|
let l = [];
|
|
339
|
-
return
|
|
344
|
+
return be(t).forEach((a) => {
|
|
340
345
|
const y = [];
|
|
341
346
|
for (const m of a.children) {
|
|
342
347
|
let { id: d, name: $, invisible: j, from: g } = m;
|
|
343
348
|
if (j)
|
|
344
349
|
continue;
|
|
345
|
-
const E =
|
|
346
|
-
E && c.push(E),
|
|
347
|
-
const { props: P, events: O, handlers: x } =
|
|
350
|
+
const E = je($, e, g);
|
|
351
|
+
E && c.push(E), Y(g) && l.push({ id: g.id, name: $ });
|
|
352
|
+
const { props: P, events: O, handlers: x } = Ee(
|
|
348
353
|
m,
|
|
349
354
|
d,
|
|
350
355
|
m.props,
|
|
351
356
|
m.events,
|
|
352
357
|
s,
|
|
353
358
|
n
|
|
354
|
-
), R =
|
|
359
|
+
), R = Pe(
|
|
355
360
|
m.directives,
|
|
356
361
|
n,
|
|
357
362
|
f
|
|
358
|
-
).join(" "), S = m.children ?
|
|
363
|
+
).join(" "), S = m.children ? xe(
|
|
359
364
|
m.children,
|
|
360
365
|
n,
|
|
361
366
|
e,
|
|
@@ -368,27 +373,27 @@ function X(t, e, n = [], s = {}, r) {
|
|
|
368
373
|
`), Object.assign(o, S?.methods || {}), c = c.concat(S?.components || []), l = l.concat(S?.importBlocks || []));
|
|
369
374
|
const I = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
|
|
370
375
|
g || e.get($)?.package
|
|
371
|
-
) ? F($) :
|
|
376
|
+
) ? F($) : Z(g) || K(g) ? "component" : $;
|
|
372
377
|
y.push(
|
|
373
|
-
|
|
378
|
+
$e.includes(I) ? `<${I} ${R} ${P} ${O} />` : `<${I} ${R} ${P} ${O}>${_ ? `
|
|
374
379
|
` + _.trim() : ""}</${I}>`
|
|
375
380
|
);
|
|
376
381
|
}
|
|
377
|
-
const p =
|
|
382
|
+
const p = _e(a.slot, y.join(`
|
|
378
383
|
`), r?.id);
|
|
379
384
|
i.push(p);
|
|
380
385
|
}), {
|
|
381
386
|
nodes: i,
|
|
382
387
|
methods: o,
|
|
383
|
-
directives:
|
|
388
|
+
directives: ve(f),
|
|
384
389
|
components: C(c),
|
|
385
390
|
importBlocks: C(l, "id")
|
|
386
391
|
};
|
|
387
392
|
}
|
|
388
|
-
function
|
|
393
|
+
function ve(t) {
|
|
389
394
|
return C(t).map((e) => `${e.startsWith("v") ? e.substring(1) : e}:${e}`);
|
|
390
395
|
}
|
|
391
|
-
function
|
|
396
|
+
function be(t = []) {
|
|
392
397
|
const e = /* @__PURE__ */ new Map();
|
|
393
398
|
for (const n of t) {
|
|
394
399
|
const s = typeof n.slot == "string" ? n.slot : n.slot?.name, r = e.get(s);
|
|
@@ -396,25 +401,25 @@ function $e(t = []) {
|
|
|
396
401
|
}
|
|
397
402
|
return e;
|
|
398
403
|
}
|
|
399
|
-
function
|
|
400
|
-
if (
|
|
404
|
+
function je(t, e, n) {
|
|
405
|
+
if (oe.includes(t)) return null;
|
|
401
406
|
const s = e.get(t);
|
|
402
407
|
if (s && s.alias) {
|
|
403
408
|
const r = s.parent ? `${s.parent}.${s.alias}` : s.alias;
|
|
404
409
|
return `${t}: ${r}`;
|
|
405
410
|
}
|
|
406
|
-
return
|
|
411
|
+
return Y(n) || s ? t : null;
|
|
407
412
|
}
|
|
408
|
-
function
|
|
413
|
+
function Y(t) {
|
|
409
414
|
return !!t && typeof t == "object" && t.type === "Schema";
|
|
410
415
|
}
|
|
411
|
-
function
|
|
416
|
+
function Z(t) {
|
|
412
417
|
return typeof t == "object" && t.type === "UrlSchema";
|
|
413
418
|
}
|
|
414
|
-
function
|
|
419
|
+
function K(t) {
|
|
415
420
|
return typeof t == "object" && t.type === "Plugin";
|
|
416
421
|
}
|
|
417
|
-
function
|
|
422
|
+
function Se(t, e, n = []) {
|
|
418
423
|
return t === "style" ? b(e) ? `:style="${h({
|
|
419
424
|
...e,
|
|
420
425
|
value: w(e.value, n)
|
|
@@ -424,50 +429,50 @@ function be(t, e, n = []) {
|
|
|
424
429
|
})}"` : typeof e == "string" ? `${t}="${e}"` : b(e) ? `:${t}="${h({
|
|
425
430
|
...e,
|
|
426
431
|
value: w(e.value, n)
|
|
427
|
-
})}"` :
|
|
432
|
+
})}"` : se(e) ? `:${t}='{${ae(
|
|
428
433
|
e
|
|
429
434
|
).join(", ")}}'` : `:${t}='${JSON.stringify(e)}'`;
|
|
430
435
|
}
|
|
431
|
-
function
|
|
436
|
+
function ke(t, e = {}, n = []) {
|
|
432
437
|
if (!!Object.keys(e.style || {}).length) {
|
|
433
438
|
const i = `${t.name}_${t.id}`;
|
|
434
439
|
e.class ? typeof e.class == "string" ? e.class = [e.class, i].join(" ") : (e.__class = e.class, e.class = i) : e.class = i, b(e.style) || delete e.style;
|
|
435
440
|
}
|
|
436
441
|
const r = t.from;
|
|
437
|
-
return (
|
|
442
|
+
return (Z(r) || K(r)) && (e.is = {
|
|
438
443
|
type: "JSExpression",
|
|
439
444
|
value: t.name
|
|
440
|
-
}), Object.entries(e).map(([i, o]) =>
|
|
445
|
+
}), Object.entries(e).map(([i, o]) => Se(i, o, n));
|
|
441
446
|
}
|
|
442
|
-
function
|
|
443
|
-
const i =
|
|
447
|
+
function we(t, e, n, s, r) {
|
|
448
|
+
const i = X(e.modifiers, !0);
|
|
444
449
|
return r ? `@${t}${i.join("")}="${n}"` : s && s.length > 0 ? `@${t}${i.join("")}="(...args:any[]) => ${n}"` : `@${t}${i.join("")}="${n}"`;
|
|
445
450
|
}
|
|
446
|
-
function
|
|
451
|
+
function Ce(t, e = {}, n = {}) {
|
|
447
452
|
const s = {}, r = Array.from(n[t] || /* @__PURE__ */ new Set([])), i = r.length ? `({${r.join(", ")}}, args)` : "";
|
|
448
453
|
return {
|
|
449
454
|
binders: Object.entries(e).map(([c, f]) => {
|
|
450
|
-
const l = f.handler.value.startsWith("this."), u = l ?
|
|
455
|
+
const l = f.handler.value.startsWith("this."), u = l ? Q(f.handler.value) : `${v(c)}_${t}${i}`;
|
|
451
456
|
return l || (s[u] = r.length ? {
|
|
452
457
|
type: "JSFunction",
|
|
453
458
|
value: `{
|
|
454
459
|
return (${f.handler.value}).apply(this, args);
|
|
455
460
|
}`
|
|
456
|
-
} : f.handler),
|
|
461
|
+
} : f.handler), we(c, f, u, r, l);
|
|
457
462
|
}),
|
|
458
463
|
handlers: s
|
|
459
464
|
};
|
|
460
465
|
}
|
|
461
|
-
function
|
|
462
|
-
const { binders: o, handlers: c } =
|
|
466
|
+
function Ee(t, e, n = {}, s = {}, r = {}, i) {
|
|
467
|
+
const { binders: o, handlers: c } = Ce(e, s, r);
|
|
463
468
|
return {
|
|
464
|
-
props:
|
|
469
|
+
props: ke(t, n, i).join(" "),
|
|
465
470
|
handlers: c,
|
|
466
471
|
binders: o,
|
|
467
472
|
events: o.join(" ")
|
|
468
473
|
};
|
|
469
474
|
}
|
|
470
|
-
function
|
|
475
|
+
function Pe(t = [], e = [], n = []) {
|
|
471
476
|
const s = [], {
|
|
472
477
|
vIf: r,
|
|
473
478
|
vElse: i,
|
|
@@ -478,7 +483,7 @@ function Ce(t = [], e = [], n = []) {
|
|
|
478
483
|
vBind: u,
|
|
479
484
|
vHtml: a,
|
|
480
485
|
customDirectives: y
|
|
481
|
-
} =
|
|
486
|
+
} = Oe(t);
|
|
482
487
|
if (r && s.push(`v-if="${h(r.value, !0, !0, e)}"`), o && s.push(
|
|
483
488
|
`v-else-if="${h(o.value, !0, !0, e)}"`
|
|
484
489
|
), i && s.push("v-else"), c && s.push(
|
|
@@ -486,7 +491,7 @@ function Ce(t = [], e = [], n = []) {
|
|
|
486
491
|
), u && s.push(
|
|
487
492
|
`v-bind="${h(u.value, !0, !0, e)}"`
|
|
488
493
|
), f.forEach((p) => {
|
|
489
|
-
const m =
|
|
494
|
+
const m = X(p.modifiers, !0), d = p.arg ? k(p.arg) ? `:[${h(p.arg, !0, !0, e)}]` : `:${p.arg}` : "";
|
|
490
495
|
s.push(
|
|
491
496
|
`v-model${d}${m}="${h(p.value, !0, !0, e)}"`
|
|
492
497
|
);
|
|
@@ -512,7 +517,7 @@ function Ce(t = [], e = [], n = []) {
|
|
|
512
517
|
) : s.push(m);
|
|
513
518
|
}), s;
|
|
514
519
|
}
|
|
515
|
-
function
|
|
520
|
+
function Oe(t = []) {
|
|
516
521
|
const e = t.filter(
|
|
517
522
|
(a) => L.includes(a.name)
|
|
518
523
|
), n = t.filter(
|
|
@@ -546,17 +551,17 @@ function Ee(t = []) {
|
|
|
546
551
|
customDirectives: n
|
|
547
552
|
};
|
|
548
553
|
}
|
|
549
|
-
function
|
|
550
|
-
return typeof t == "string" ? t : k(t) ? `{{ ${h(t, !1, !0, e)} }}` : Array.isArray(t) ?
|
|
554
|
+
function xe(t, e, n, s, r) {
|
|
555
|
+
return typeof t == "string" ? t : k(t) ? `{{ ${h(t, !1, !0, e)} }}` : Array.isArray(t) ? z(t, n, e, s, r) : "";
|
|
551
556
|
}
|
|
552
|
-
function
|
|
557
|
+
function _e(t, e, n) {
|
|
553
558
|
if (!t) return e;
|
|
554
559
|
const s = typeof t == "string" ? { name: t, params: [] } : { params: [], ...t };
|
|
555
560
|
return `<template ${`#${s.name}="${s.params?.length > 0 ? `{${s.params?.join(",")}}` : `scope_${n}`}"`}>
|
|
556
561
|
${e}
|
|
557
562
|
</template>`;
|
|
558
563
|
}
|
|
559
|
-
function
|
|
564
|
+
function Ie(t, e = [], n = [], s = {}, r = "web") {
|
|
560
565
|
const i = [
|
|
561
566
|
"@dcloudio/uni-h5",
|
|
562
567
|
"uni-h5",
|
|
@@ -581,18 +586,18 @@ function xe(t, e = [], n = [], s = {}, r = "web") {
|
|
|
581
586
|
uniComponents: c
|
|
582
587
|
};
|
|
583
588
|
}
|
|
584
|
-
function
|
|
589
|
+
function Ae(t = {}) {
|
|
585
590
|
const e = [];
|
|
586
591
|
for (const [n, s] of Object.entries(t))
|
|
587
592
|
e.push(`
|
|
588
593
|
${n} {
|
|
589
|
-
${
|
|
594
|
+
${le(s)}
|
|
590
595
|
}
|
|
591
596
|
`);
|
|
592
597
|
return e.join(`
|
|
593
598
|
`);
|
|
594
599
|
}
|
|
595
|
-
function
|
|
600
|
+
function Ne(t = {}) {
|
|
596
601
|
const e = [];
|
|
597
602
|
return Object.entries(t).forEach(([n, s]) => {
|
|
598
603
|
e.push(
|
|
@@ -600,7 +605,7 @@ function Ie(t = {}) {
|
|
|
600
605
|
);
|
|
601
606
|
}), e;
|
|
602
607
|
}
|
|
603
|
-
function
|
|
608
|
+
function Fe(t = {}) {
|
|
604
609
|
const e = [];
|
|
605
610
|
return Object.entries(t).forEach(([n, s]) => {
|
|
606
611
|
e.push(
|
|
@@ -608,8 +613,8 @@ function Ae(t = {}) {
|
|
|
608
613
|
);
|
|
609
614
|
}), e;
|
|
610
615
|
}
|
|
611
|
-
function
|
|
612
|
-
const { dsl: s } = t, r = Object.keys(s.computed || {}), i = A(s.lifeCycles, r), o = A(s.computed, r), c =
|
|
616
|
+
function Be(t, e, n = "web") {
|
|
617
|
+
const { dsl: s } = t, r = Object.keys(s.computed || {}), i = A(s.lifeCycles, r), o = A(s.computed, r), c = ye(s.watch, r), f = ge(s.dataSources), { methods: l, nodes: u, components: a, importBlocks: y, directives: p } = z(
|
|
613
618
|
s.nodes || [],
|
|
614
619
|
e,
|
|
615
620
|
r,
|
|
@@ -621,7 +626,7 @@ function Ne(t, e, n = "web") {
|
|
|
621
626
|
},
|
|
622
627
|
r
|
|
623
628
|
), $ = y.map((x) => `import ${x.name} from './${x.id}.vue';`);
|
|
624
|
-
let { imports: j, uniComponents: g } =
|
|
629
|
+
let { imports: j, uniComponents: g } = Ie(
|
|
625
630
|
e,
|
|
626
631
|
a,
|
|
627
632
|
$,
|
|
@@ -631,15 +636,15 @@ function Ne(t, e, n = "web") {
|
|
|
631
636
|
const E = Object.keys({
|
|
632
637
|
...t.urlSchemas,
|
|
633
638
|
...t.blockPlugins
|
|
634
|
-
}), P =
|
|
639
|
+
}), P = Ne(t.urlSchemas), O = Fe(t.blockPlugins);
|
|
635
640
|
return {
|
|
636
641
|
id: s.id,
|
|
637
642
|
version: s.__VERSION__,
|
|
638
643
|
name: s.name,
|
|
639
|
-
state:
|
|
640
|
-
inject:
|
|
641
|
-
props:
|
|
642
|
-
emits:
|
|
644
|
+
state: fe(s.state).join(","),
|
|
645
|
+
inject: me(s.inject).join(","),
|
|
646
|
+
props: he(s.props).join(","),
|
|
647
|
+
emits: de(s.emits).join(","),
|
|
643
648
|
watch: c.watches.join(","),
|
|
644
649
|
lifeCycles: i.join(","),
|
|
645
650
|
computed: m.join(","),
|
|
@@ -647,13 +652,13 @@ function Ne(t, e, n = "web") {
|
|
|
647
652
|
imports: `
|
|
648
653
|
` + j.join(`
|
|
649
654
|
`),
|
|
650
|
-
components:
|
|
655
|
+
components: ue(a, g).join(","),
|
|
651
656
|
directives: p.join(","),
|
|
652
657
|
returns: t.members.join(","),
|
|
653
658
|
template: u.join(`
|
|
654
659
|
`),
|
|
655
660
|
css: s.css || "",
|
|
656
|
-
style:
|
|
661
|
+
style: Ae(t.style),
|
|
657
662
|
urlSchemas: P.join(`
|
|
658
663
|
`),
|
|
659
664
|
blockPlugins: O.join(`
|
|
@@ -663,7 +668,7 @@ function Ne(t, e, n = "web") {
|
|
|
663
668
|
renderer: n === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
|
|
664
669
|
};
|
|
665
670
|
}
|
|
666
|
-
const
|
|
671
|
+
const Te = `
|
|
667
672
|
// @ts-nocheck
|
|
668
673
|
|
|
669
674
|
<%= imports %>
|
|
@@ -695,7 +700,7 @@ export default defineComponent({
|
|
|
695
700
|
<% if(methods) { %> methods: { <%= methods %> }, <% } %>
|
|
696
701
|
<% if(watch) { %> watch: { <%= watch %> }, <% } %> <%= lifeCycles %>
|
|
697
702
|
});
|
|
698
|
-
`.replace(/(\n|\r|\t)/g, ""),
|
|
703
|
+
`.replace(/(\n|\r|\t)/g, ""), Re = `
|
|
699
704
|
<template>
|
|
700
705
|
<%= template %>
|
|
701
706
|
</template>
|
|
@@ -706,17 +711,17 @@ export default defineComponent({
|
|
|
706
711
|
<%= css %>
|
|
707
712
|
<%= style %>
|
|
708
713
|
</style>
|
|
709
|
-
`,
|
|
710
|
-
async function
|
|
711
|
-
const i = new
|
|
714
|
+
`, We = U(Te), Je = U(Re);
|
|
715
|
+
async function Ve(t, e = /* @__PURE__ */ new Map(), n = [], s = "web", r) {
|
|
716
|
+
const i = new pe(re(t), n), o = Be(i, e, s), c = We(o), f = Je({
|
|
712
717
|
template: o.template,
|
|
713
718
|
css: await W(o.css, r),
|
|
714
|
-
script: await
|
|
719
|
+
script: await ce(c, r),
|
|
715
720
|
style: await W(o.style, r)
|
|
716
721
|
});
|
|
717
|
-
return await
|
|
722
|
+
return await M(f, r).catch((l) => (l.content = f, Promise.reject(l)));
|
|
718
723
|
}
|
|
719
|
-
async function
|
|
724
|
+
async function He(t) {
|
|
720
725
|
const e = `
|
|
721
726
|
<template>
|
|
722
727
|
<div>
|
|
@@ -729,13 +734,13 @@ async function De(t) {
|
|
|
729
734
|
<style scoped lang="scss">
|
|
730
735
|
</style>
|
|
731
736
|
`;
|
|
732
|
-
return await
|
|
737
|
+
return await M(e);
|
|
733
738
|
}
|
|
734
739
|
export {
|
|
735
|
-
|
|
736
|
-
|
|
740
|
+
Ue as VTJ_CODER_VERSION,
|
|
741
|
+
He as createEmptyPage,
|
|
737
742
|
W as cssFormatter,
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
743
|
+
Ve as generator,
|
|
744
|
+
ce as tsFormatter,
|
|
745
|
+
M as vueFormatter
|
|
741
746
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/coder",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.57",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"prettier": "~3.6.0",
|
|
25
|
-
"@vtj/
|
|
26
|
-
"@vtj/
|
|
25
|
+
"@vtj/core": "~0.12.57",
|
|
26
|
+
"@vtj/base": "~0.12.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@vtj/cli": "~0.12.8"
|
package/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { JSExpression, JSFunction } from '@vtj/core';
|
|
1
|
+
import { JSExpression, JSFunction, DataSourceSchema } from '@vtj/core';
|
|
2
|
+
import { base64, unBase64 } from '@vtj/base';
|
|
3
|
+
export { base64, unBase64 };
|
|
2
4
|
export declare function isJSExpression(data: any): data is JSExpression;
|
|
3
5
|
export declare function isJSFunction(x: any): x is JSFunction;
|
|
4
6
|
export declare function isJSCode(data: unknown): data is JSExpression | JSFunction;
|
|
@@ -12,3 +14,5 @@ export declare function parsePlainObjectValue(obj?: Record<string, any>): string
|
|
|
12
14
|
export declare function getModifiers(modifiers?: Record<string, boolean>, isToString?: boolean): string[];
|
|
13
15
|
export declare function jsonToStyle(json: Record<string, any>): string;
|
|
14
16
|
export declare function skipUniComponents(components?: string[], uniComponents?: string[]): string[];
|
|
17
|
+
export declare function encodeDataSource(schema: DataSourceSchema): string;
|
|
18
|
+
export declare function decodeDataSource(code: string): DataSourceSchema | null;
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/coder
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.12.
|
|
5
|
+
* @version 0.12.56
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.12.
|
|
8
|
+
export declare const version = "0.12.56";
|