@vtj/coder 0.11.16 → 0.12.0-alpha.1
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 +17 -17
- package/dist/index.mjs +29 -24
- package/package.json +4 -4
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@vtj/base"),T=require("prettier/standalone"),Z=require("prettier/plugins/html"),K=require("prettier/plugins/babel"),ee=require("prettier/plugins/postcss"),te=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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@vtj/base"),T=require("prettier/standalone"),Z=require("prettier/plugins/html"),K=require("prettier/plugins/babel"),ee=require("prettier/plugins/postcss"),te=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 r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ne=F(Z),D=F(K),L=F(ee),U=F(te);/**!
|
|
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.
|
|
5
|
+
* @version 0.12.0-alpha.1
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const
|
|
7
|
+
*/const re="0.12.0-alpha.1";/**!
|
|
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.
|
|
11
|
+
* @version 0.12.0-alpha.1
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
|
-
*/const
|
|
13
|
+
*/const se=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.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:[ne,D,U,L]})}async function M(t,e){if(e)return t;try{return(await T.format(t,{parser:"babel-ts",...B,plugins:[D,U]})).replace(/;\n$/gi,"")}catch(n){return console.warn(n),t}}async function I(t,e){return e?t:T.format(t,{parser:"scss",...B,plugins:[L]})}function S(t){return t&&t.type==="JSExpression"}function A(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function v(t){return S(t)||A(t)}function V(t){return t.replace(new RegExp("this.","g"),"")}function J(t){return t.replace(/this\.context\??\./g,"")}function m(t,e=!0,n=!0,r=[]){let s=v(t)?t.value.trim().replace(/\"/g,"'").replace(/;$/,""):e?JSON.stringify(t):t;return s=k(s,r),n?V(J(s)):J(s)}function k(t,e=[]){let n=t;for(const r of e)n=n.replace(new RegExp(`this.${r}.value`,"g"),`this.${r}`);return n}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 s=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,i=e.match(s);i&&i[2]&&(i[2].startsWith("{")||(e=e.replace(i[2],`{ return ${i[2]} }`))),e=e.replace("=>","")}return e}function ie(t={}){return Object.entries(t).map(([e,n])=>`"${e}": ${m(n)}`)}function Q(t={},e=!1){const n=Object.keys(t);return e?n.map(r=>"."+r):n}function oe(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];e+=n+": "+r+";"}return e}function ce(t=[],e=[]){return t.filter(n=>!e.includes(n))}class ae{constructor(e,n){this.dsl=e,this.dependencies=n,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const n=e.split(".");if(n.length===4){const r=n.pop(),s=n.join(".")+".",i=n.pop();if(r&&i){const c=this.dependencies.find(a=>a.library===i)?.package;c&&(this.imports[c]||(this.imports[c]=new Set)).add(r)}return{name:r,path:s,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let r=e.value;for(const s of n){const i=e.value?.match(s)||[];for(const c of i){const a=this.collectImport(c);if(a){const p=a.path.replace(/\$/g,"\\$");r=r.replace(new RegExp(p,"g"),"")}}}return r}walk(e){const n=r=>{if(!r||typeof r!="object")return;if(Array.isArray(r)){for(let i of r)n(i);return}const s=Object.values(r);for(const i of s)v(i)?i.value=this.replaceLibraryPath(i):n(i)};n(e)}getLibraryMember(e=[]){let n=[...e];const r={...this.imports};delete r["uni-h5"],delete r["@dcloudio/uni-h5"],delete r["uni-ui"],delete r["@dcloudio/uni-ui"];for(const s of Object.values(r))n=n.concat(Array.from(s));return f.dedupArray(n)}collectContext(e,n){const r=new Set(n?.id?this.context[n.id]:[]),s=(e.directives||[]).find(a=>a.name==="vFor");let i=new Set(Array.from(r));if(s){const{item:a="item",index:p="index"}=s.iterator||{};i=new Set([a,p,...Array.from(i)])}const c=e.slot;if(c){const a=typeof c=="string"?[]:c.params||[],p=a.length?a:[`scope_${n?.id}`];i=new Set([...p,...Array.from(i)])}this.context[e.id]=i}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!v(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=(r,s)=>{this.collectContext(r,s),this.collectStyle(r),this.collectUrlSchema(r),this.collectBlockPlugin(r),Array.isArray(r.children)&&r.children.forEach(i=>n(i,r))};Array.isArray(e.nodes)&&e.nodes.forEach(r=>n(r))}}function ue(t={}){return Object.entries(t).map(([e,n])=>{const r=m(n,!1);return`${e}:${r}`})}function le(t=[]){return t.map(e=>`${e.name}: {
|
|
14
14
|
from: '${e.from||e.name}',
|
|
15
15
|
default: ${m(e.default,!0,!1)}
|
|
16
16
|
}`)}function pe(t=[]){const e=n=>n?`[${f.toArray(n).map(i=>i.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(n=>typeof n=="string"?`${n}: {}`:(v(n.default)&&!n.default.value&&(n.default.value="undefined"),`${n.name}: {
|
|
17
17
|
type:${e(n.type)},
|
|
18
18
|
required: ${m(!!n.required,!0,!1)},
|
|
19
19
|
default: ${m(n.default,!0,!1)}
|
|
20
|
-
}`))}function fe(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function E(t={},e=[]){return Object.entries(t).map(([n,
|
|
20
|
+
}`))}function fe(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function E(t={},e=[]){return Object.entries(t).map(([n,r])=>{let s=H(m(r,!1,!1));return s=k(s,e),s.startsWith("async")?`async ${n}${s.replace(/^async/,"")}`:`${n}${s}`})}function me(t=[],e=[]){const n=t.reduce((i,c)=>(c.id&&A(c.source)&&(i[`watcher_${c.id}`]=c.source),i),{}),r=E(n,e),s=t.map(i=>`watcher_${i.id}: {
|
|
21
21
|
deep: ${i.deep},
|
|
22
22
|
immediate:${i.immediate},
|
|
23
23
|
handler${H(i.handler.value)}
|
|
24
|
-
}`);return{computed:
|
|
24
|
+
}`);return{computed:r,watches:s}}function he(t={}){return Object.values(t).map(e=>{if(e.type==="mock"){const n=A(e.mockTemplate)&&e.mockTemplate.value||"(params) => ({})";return`async ${e.name}(...args:any[]) {
|
|
25
25
|
const mock = this.provider.createMock(${n})
|
|
26
26
|
return await mock.apply(this, args);
|
|
27
27
|
}`}else{const n=A(e.transform)&&e.transform.value||"(res) => res";return`async ${e.name}(...args:any[]) {
|
|
28
28
|
return await this.provider.apis['${e.ref}'].apply(this, args).then(${n});
|
|
29
|
-
}`}})}const de=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],q=["vIf","vShow","vModel","vFor","vBind","vHtml"];function z(t,e,n=[],
|
|
29
|
+
}`}})}const de=["img","input","br","hr","area","base","col","embed","link","meta","param","source","track","wbr"],q=["vIf","vShow","vModel","vFor","vBind","vHtml"];function z(t,e,n=[],r={},s){const i=[];let c={},a=[];const p=[];let o=[];return ge(t).forEach(u=>{const h=[];for(const y of u.children){let{id:b,name:$,invisible:N,from:g}=y;if(N)continue;const w=$e($,e,g);w&&a.push(w),G(g)&&o.push({id:g.id,name:$});const{props:C,events:P,handlers:O}=ke(y,b,y.props,y.events,r,n),W=we(y.directives,n,p).join(" "),j=y.children?Pe(y.children,n,e,r,y):"";Object.assign(c,O);let _="";typeof j=="string"?_=j:(_=(j?.nodes||[]).join(`
|
|
30
30
|
`),Object.assign(c,j?.methods||{}),a=a.concat(j?.components||[]),o=o.concat(j?.importBlocks||[]));const x=["@dcloudio/uni-h5","@dcloudio/uni-ui"].includes(g)?f.kebabCase($):X(g)||Y(g)?"component":$;h.push(de.includes(x)?`<${x} ${W} ${C} ${P} />`:`<${x} ${W} ${C} ${P}>${_?`
|
|
31
31
|
`+_.trim():""}</${x}>`)}const d=Oe(u.slot,h.join(`
|
|
32
|
-
`),
|
|
32
|
+
`),s?.id);i.push(d)}),{nodes:i,methods:c,directives:ye(p),components:f.dedupArray(a),importBlocks:f.dedupArray(o,"id")}}function ye(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ge(t=[]){const e=new Map;for(const n of t){const r=typeof n.slot=="string"?n.slot:n.slot?.name,s=e.get(r);s?s.children.push(n):e.set(r,{slot:n.slot,children:[n]})}return e}function $e(t,e,n){if(se.includes(t))return null;const r=e.get(t);if(r&&r.alias){const s=r.parent?`${r.parent}.${r.alias}`:r.alias;return`${t}: ${s}`}return G(n)||r?t:null}function G(t){return!!t&&typeof t=="object"&&t.type==="Schema"}function X(t){return typeof t=="object"&&t.type==="UrlSchema"}function Y(t){return typeof t=="object"&&t.type==="Plugin"}function ve(t,e,n=[]){return t==="style"?v(e)?`:style="${m({...e,value:k(e.value,n)})}"`:"":t==="__class"&&v(e)?`:class="${m({...e,value:k(e.value,n)})}"`:typeof e=="string"?`${t}="${e}"`:v(e)?`:${t}="${m({...e,value:k(e.value,n)})}"`:f.isPlainObject(e)?`:${t}='{${ie(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function be(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,v(e.style)||delete e.style}const s=t.from;return(X(s)||Y(s))&&(e.is={type:"JSExpression",value:t.name}),Object.entries(e).map(([i,c])=>ve(i,c,n))}function je(t,e,n,r,s){const i=Q(e.modifiers,!0);return s?`@${t}${i.join("")}="${n}"`:r&&r.length>0?`@${t}${i.join("")}="(...args:any[]) => ${n}"`:`@${t}${i.join("")}="${n}"`}function Se(t,e={},n={}){const r={},s=Array.from(n[t]||new Set([])),i=s.length?`({${s.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,p])=>{const o=p.handler.value.startsWith("this."),l=o?V(p.handler.value):`${f.camelCase(a)}_${t}${i}`;return o||(r[l]=s.length?{type:"JSFunction",value:`{
|
|
33
33
|
return (${p.handler.value}).apply(this, args);
|
|
34
|
-
}`}:p.handler),je(a,p,l,
|
|
34
|
+
}`}:p.handler),je(a,p,l,s,o)}),handlers:r}}function ke(t,e,n={},r={},s={},i){const{binders:c,handlers:a}=Se(e,r,s);return{props:be(t,n,i).join(" "),handlers:a,binders:c,events:c.join(" ")}}function we(t=[],e=[],n=[]){const r=[],{vIf:s,vShow:i,vModels:c,vFor:a,vBind:p,vHtml:o,customDirectives:l}=Ce(t);if(s&&r.push(`v-if="${m(s.value,!0,!0,e)}"`),i&&r.push(`v-show="${m(i.value,!0,!0,e)}"`),p&&r.push(`v-bind="${m(p.value,!0,!0,e)}"`),c.forEach(u=>{const h=Q(u.modifiers,!0),d=u.arg?S(u.arg)?`:[${m(u.arg,!0,!0,e)}]`:`:${u.arg}`:"";r.push(`v-model${d}${h}="${m(u.value,!0,!0,e)}"`)}),a){const{item:u,index:h}={item:"item",index:"index",...a.iterator};r.push(`v-for="(${u}, ${h}) in ${m(a.value,!0,!0,e)}"`)}return o&&r.push(`v-html="${m(o.value,!0,!0,e)}"`),l&&l.length&&l.forEach(u=>{if(!u.name)return;let h="",d="";S(u.name)?(d=m(u.name,!0,!0,e),n.push(d)):d=u.name;const y=d?.startsWith("v")?f.kebabCase(d):f.kebabCase("v-"+d);if(h+=y,u.arg&&(S(u.arg)?h+=`:[${m(u.name,!0,!0,e)}]`:h+=`:${u.arg}`),u.modifiers){const b=Object.keys(u.modifiers);b.length&&(h+=b.map($=>"."+$))}u.value?r.push(`${h}="${m(u.value,!0,!0,e)}"`):r.push(h)}),r}function Ce(t=[]){const e=t.filter(o=>q.includes(o.name)),n=t.filter(o=>!q.includes(o.name)),r=e.find(o=>f.camelCase(o.name)==="vIf"),s=e.find(o=>f.camelCase(o.name)==="vFor"),i=e.find(o=>f.camelCase(o.name)==="vShow"),c=e.find(o=>f.camelCase(o.name)==="vBind"),a=e.find(o=>f.camelCase(o.name)==="vHtml"),p=e.filter(o=>f.camelCase(o.name)==="vModel");return{vIf:r,vFor:s,vShow:i,vModels:p,vBind:c,vHtml:a,customDirectives:n}}function Pe(t,e,n,r,s){return typeof t=="string"?t:S(t)?`{{ ${m(t,!1,!0,e)} }}`:Array.isArray(t)?z(t,n,e,r,s):""}function Oe(t,e,n){if(!t)return e;const r=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${r.name}="${r.params?.length>0?`{${r.params?.join(",")}}`:`scope_${n}`}"`}>
|
|
35
35
|
${e}
|
|
36
|
-
</template>`}function _e(t,e=[],n=[],
|
|
36
|
+
</template>`}function _e(t,e=[],n=[],r={},s="web"){const i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],c={vue:["defineComponent","reactive"]},a=[];for(const o of e){const l=t.get(o.split(":")[0]);if(l&&l.package){const u=c[l.package]??(c[l.package]=[]),h=l.parent||(l.alias||"").split(".")[0]||l.name;u.push(h),s==="uniapp"&&i.includes(l.package)&&a.push(h)}}for(const[o,l]of Object.entries(r))(c[o]??(c[o]=[])).push(...Array.from(l)),s==="uniapp"&&i.includes(o)&&a.push(...Array.from(l));return{imports:Object.entries(c).filter(([o,l])=>s==="uniapp"?!i.includes(o)&&!!l.length:!!l.length).map(([o,l])=>`import { ${f.dedupArray(l).join(",")}} from '${o}';`).concat(n),uniComponents:a}}function xe(t={}){const e=[];for(const[n,r]of Object.entries(t))e.push(`
|
|
37
37
|
${n} {
|
|
38
|
-
${oe(
|
|
38
|
+
${oe(r)}
|
|
39
39
|
}
|
|
40
40
|
`);return e.join(`
|
|
41
|
-
`)}function Ee(t={}){const e=[];return Object.entries(t).forEach(([n,
|
|
41
|
+
`)}function Ee(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${r.url}');`)}),e}function Ae(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(r)});`)}),e}function Fe(t,e,n="web"){const{dsl:r}=t,s=Object.keys(r.computed||{}),i=E(r.lifeCycles,s),c=E(r.computed,s),a=me(r.watch,s),p=he(r.dataSources),{methods:o,nodes:l,components:u,importBlocks:h,directives:d}=z(r.nodes||[],e,s,t.context),y=[...c,...a.computed],b=E({...o,...r.methods||{}},s),$=h.map(O=>`import ${O.name} from './${O.id}.vue';`);let{imports:N,uniComponents:g}=_e(e,u,$,t.imports,n);const w=Object.keys({...t.urlSchemas,...t.blockPlugins}),C=Ee(t.urlSchemas),P=Ae(t.blockPlugins);return{id:r.id,version:r.__VERSION__,name:r.name,state:ue(r.state).join(","),inject:le(r.inject).join(","),props:pe(r.props).join(","),emits:fe(r.emits).join(","),watch:a.watches.join(","),lifeCycles:i.join(","),computed:y.join(","),methods:[...p,...b].join(","),imports:`
|
|
42
42
|
`+N.join(`
|
|
43
43
|
`),components:ce(u,g).join(","),directives:d.join(","),returns:t.members.join(","),template:l.join(`
|
|
44
|
-
`),css:
|
|
44
|
+
`),css:r.css||"",style:xe(t.style),urlSchemas:C.join(`
|
|
45
45
|
`),blockPlugins:P.join(`
|
|
46
46
|
`),asyncComponents:w.join(","),uniComponents:g,renderer:n==="uniapp"?"@vtj/uni-app":"@vtj/renderer"}}const Ne=`
|
|
47
47
|
// @ts-nocheck
|
|
@@ -60,7 +60,7 @@ export default defineComponent({
|
|
|
60
60
|
id: '<%= id %>',
|
|
61
61
|
version: '<%= version %>'
|
|
62
62
|
});
|
|
63
|
-
const state = reactive
|
|
63
|
+
const state = reactive({ <%= state %> });
|
|
64
64
|
<%= urlSchemas %>
|
|
65
65
|
<%= blockPlugins %>
|
|
66
66
|
return {
|
|
@@ -86,7 +86,7 @@ export default defineComponent({
|
|
|
86
86
|
<%= css %>
|
|
87
87
|
<%= style %>
|
|
88
88
|
</style>
|
|
89
|
-
`,Te=f.template(Ne),Be=f.template(Ie);async function Re(t,e=new Map,n=[],
|
|
89
|
+
`,Te=f.template(Ne),Be=f.template(Ie);async function Re(t,e=new Map,n=[],r="web",s){const i=new ae(f.cloneDeep(t),n),c=Fe(i,e,r),a=Te(c),p=Be({template:c.template,css:await I(c.css,s),script:await M(a,s),style:await I(c.style,s)});return await R(p,s).catch(o=>(o.content=p,Promise.reject(o)))}async function We(t){const e=`
|
|
90
90
|
<template>
|
|
91
91
|
<div>
|
|
92
92
|
<h3>源码模式页面</h3>
|
|
@@ -97,4 +97,4 @@ export default defineComponent({
|
|
|
97
97
|
<\/script>
|
|
98
98
|
<style scoped lang="scss">
|
|
99
99
|
</style>
|
|
100
|
-
`;return await R(e)}exports.VTJ_CODER_VERSION=
|
|
100
|
+
`;return await R(e)}exports.VTJ_CODER_VERSION=re;exports.createEmptyPage=We;exports.cssFormatter=I;exports.generator=Re;exports.tsFormatter=M;exports.vueFormatter=R;
|
package/dist/index.mjs
CHANGED
|
@@ -8,15 +8,15 @@ import * as H from "prettier/plugins/estree";
|
|
|
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.
|
|
11
|
+
* @version 0.12.0-alpha.1
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const Le = "0.
|
|
14
|
+
const Le = "0.12.0-alpha.1";
|
|
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.
|
|
19
|
+
* @version 0.12.0-alpha.1
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
22
|
const re = [
|
|
@@ -33,7 +33,7 @@ const re = [
|
|
|
33
33
|
"a"
|
|
34
34
|
];
|
|
35
35
|
K();
|
|
36
|
-
const
|
|
36
|
+
const T = {
|
|
37
37
|
arrowParens: "always",
|
|
38
38
|
bracketSpacing: !0,
|
|
39
39
|
bracketSameLine: !0,
|
|
@@ -56,21 +56,26 @@ const R = {
|
|
|
56
56
|
async function M(t, e) {
|
|
57
57
|
return e ? t : await B(t, {
|
|
58
58
|
parser: "vue",
|
|
59
|
-
...
|
|
59
|
+
...T,
|
|
60
60
|
plugins: [se, D, H, V]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
async function ie(t, e) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
if (e) return t;
|
|
65
|
+
try {
|
|
66
|
+
return (await B(t, {
|
|
67
|
+
parser: "babel-ts",
|
|
68
|
+
...T,
|
|
69
|
+
plugins: [D, H]
|
|
70
|
+
})).replace(/;\n$/gi, "");
|
|
71
|
+
} catch (n) {
|
|
72
|
+
return console.warn(n), t;
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
async function W(t, e) {
|
|
71
76
|
return e ? t : B(t, {
|
|
72
77
|
parser: "scss",
|
|
73
|
-
...
|
|
78
|
+
...T,
|
|
74
79
|
plugins: [V]
|
|
75
80
|
});
|
|
76
81
|
}
|
|
@@ -90,7 +95,7 @@ function J(t) {
|
|
|
90
95
|
return t.replace(/this\.context\??\./g, "");
|
|
91
96
|
}
|
|
92
97
|
function f(t, e = !0, n = !0, s = []) {
|
|
93
|
-
let r = $(t) ? t.value : e ? JSON.stringify(t) : t;
|
|
98
|
+
let r = $(t) ? t.value.trim().replace(/\"/g, "'").replace(/;$/, "") : e ? JSON.stringify(t) : t;
|
|
94
99
|
return r = k(r, s), n ? q(J(r)) : J(r);
|
|
95
100
|
}
|
|
96
101
|
function k(t, e = []) {
|
|
@@ -103,7 +108,7 @@ function k(t, e = []) {
|
|
|
103
108
|
return n;
|
|
104
109
|
}
|
|
105
110
|
function Q(t) {
|
|
106
|
-
let e = t.trim();
|
|
111
|
+
let e = t.trim().replace(/;$/, "");
|
|
107
112
|
if (e = /^\((\(|async|function)/.test(e) ? e.substring(1, e.length - 1) : e, e.startsWith("{")) return e;
|
|
108
113
|
if (e.startsWith("async function"))
|
|
109
114
|
e = e.replace(/^async function/, "async");
|
|
@@ -324,7 +329,7 @@ const ye = [
|
|
|
324
329
|
"vBind",
|
|
325
330
|
"vHtml"
|
|
326
331
|
];
|
|
327
|
-
function
|
|
332
|
+
function X(t, e, n = [], s = {}, r) {
|
|
328
333
|
const i = [];
|
|
329
334
|
let c = {}, a = [];
|
|
330
335
|
const p = [];
|
|
@@ -336,7 +341,7 @@ function z(t, e, n = [], s = {}, r) {
|
|
|
336
341
|
if (F)
|
|
337
342
|
continue;
|
|
338
343
|
const C = ve(g, e, y);
|
|
339
|
-
C && a.push(C),
|
|
344
|
+
C && a.push(C), z(y) && o.push({ id: y.id, name: g });
|
|
340
345
|
const { props: P, events: O, handlers: x } = we(
|
|
341
346
|
d,
|
|
342
347
|
b,
|
|
@@ -344,7 +349,7 @@ function z(t, e, n = [], s = {}, r) {
|
|
|
344
349
|
d.events,
|
|
345
350
|
s,
|
|
346
351
|
n
|
|
347
|
-
),
|
|
352
|
+
), R = Ce(
|
|
348
353
|
d.directives,
|
|
349
354
|
n,
|
|
350
355
|
p
|
|
@@ -363,7 +368,7 @@ function z(t, e, n = [], s = {}, r) {
|
|
|
363
368
|
y
|
|
364
369
|
) ? I(g) : Y(y) || Z(y) ? "component" : g;
|
|
365
370
|
m.push(
|
|
366
|
-
ye.includes(_) ? `<${_} ${
|
|
371
|
+
ye.includes(_) ? `<${_} ${R} ${P} ${O} />` : `<${_} ${R} ${P} ${O}>${E ? `
|
|
367
372
|
` + E.trim() : ""}</${_}>`
|
|
368
373
|
);
|
|
369
374
|
}
|
|
@@ -396,9 +401,9 @@ function ve(t, e, n) {
|
|
|
396
401
|
const r = s.parent ? `${s.parent}.${s.alias}` : s.alias;
|
|
397
402
|
return `${t}: ${r}`;
|
|
398
403
|
}
|
|
399
|
-
return
|
|
404
|
+
return z(n) || s ? t : null;
|
|
400
405
|
}
|
|
401
|
-
function
|
|
406
|
+
function z(t) {
|
|
402
407
|
return !!t && typeof t == "object" && t.type === "Schema";
|
|
403
408
|
}
|
|
404
409
|
function Y(t) {
|
|
@@ -522,7 +527,7 @@ function Pe(t = []) {
|
|
|
522
527
|
};
|
|
523
528
|
}
|
|
524
529
|
function Oe(t, e, n, s, r) {
|
|
525
|
-
return typeof t == "string" ? t : S(t) ? `{{ ${f(t, !1, !0, e)} }}` : Array.isArray(t) ?
|
|
530
|
+
return typeof t == "string" ? t : S(t) ? `{{ ${f(t, !1, !0, e)} }}` : Array.isArray(t) ? X(t, n, e, s, r) : "";
|
|
526
531
|
}
|
|
527
532
|
function xe(t, e, n) {
|
|
528
533
|
if (!t) return e;
|
|
@@ -584,7 +589,7 @@ function Ne(t = {}) {
|
|
|
584
589
|
}), e;
|
|
585
590
|
}
|
|
586
591
|
function Fe(t, e, n = "web") {
|
|
587
|
-
const { dsl: s } = t, r = Object.keys(s.computed || {}), i = A(s.lifeCycles, r), c = A(s.computed, r), a = he(s.watch, r), p = de(s.dataSources), { methods: o, nodes: l, components: u, importBlocks: m, directives: h } =
|
|
592
|
+
const { dsl: s } = t, r = Object.keys(s.computed || {}), i = A(s.lifeCycles, r), c = A(s.computed, r), a = he(s.watch, r), p = de(s.dataSources), { methods: o, nodes: l, components: u, importBlocks: m, directives: h } = X(
|
|
588
593
|
s.nodes || [],
|
|
589
594
|
e,
|
|
590
595
|
r,
|
|
@@ -655,7 +660,7 @@ export default defineComponent({
|
|
|
655
660
|
id: '<%= id %>',
|
|
656
661
|
version: '<%= version %>'
|
|
657
662
|
});
|
|
658
|
-
const state = reactive
|
|
663
|
+
const state = reactive({ <%= state %> });
|
|
659
664
|
<%= urlSchemas %>
|
|
660
665
|
<%= blockPlugins %>
|
|
661
666
|
return {
|
|
@@ -681,9 +686,9 @@ export default defineComponent({
|
|
|
681
686
|
<%= css %>
|
|
682
687
|
<%= style %>
|
|
683
688
|
</style>
|
|
684
|
-
`,
|
|
689
|
+
`, Te = U(Ie), Re = U(Be);
|
|
685
690
|
async function Ue(t, e = /* @__PURE__ */ new Map(), n = [], s = "web", r) {
|
|
686
|
-
const i = new ue(ne(t), n), c = Fe(i, e, s), a =
|
|
691
|
+
const i = new ue(ne(t), n), c = Fe(i, e, s), a = Te(c), p = Re({
|
|
687
692
|
template: c.template,
|
|
688
693
|
css: await W(c.css, r),
|
|
689
694
|
script: await ie(a, r),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/coder",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0-alpha.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"prettier": "~3.5.0",
|
|
25
|
-
"@vtj/
|
|
26
|
-
"@vtj/
|
|
25
|
+
"@vtj/base": "~0.12.0-alpha.1",
|
|
26
|
+
"@vtj/core": "~0.12.0-alpha.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@vtj/cli": "~0.
|
|
29
|
+
"@vtj/cli": "~0.12.0-alpha.1"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
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.
|
|
5
|
+
* @version 0.12.0-alpha.0
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.
|
|
8
|
+
export declare const version = "0.12.0-alpha.0";
|