@vtj/coder 0.12.63 → 0.12.64
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 +4 -4
- package/dist/index.mjs +5 -5
- package/package.json +2 -2
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
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.64
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const re="0.12.
|
|
7
|
+
*/const re="0.12.64";/**!
|
|
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.64
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/const ie=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const T={arrowParens:"always",bracketSpacing:!0,bracketSameLine:!0,endOfLine:"lf",htmlWhitespaceSensitivity:"css",insertPragma:!1,jsxBracketSameLine:!0,jsxSingleQuote:!0,printWidth:80,proseWrap:"preserve",quoteProps:"as-needed",requirePragma:!1,semi:!0,singleQuote:!0,tabWidth:2,trailingComma:"none",useTabs:!1,vueIndentScriptAndStyle:!0};async function B(t,e){return e?t:await D.format(t,{parser:"vue",...T,plugins:[ne,q,U,M]})}async function V(t,e){if(e)return t;try{return(await D.format(t,{parser:"babel-ts",...T,plugins:[q,U]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function N(t,e){return e?t:D.format(t,{parser:"scss",...T,plugins:[M]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function R(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[]){let r=j(t)?t.value.trim().replace(/\"/g,'\\"').replace(/;$/,""):e?JSON.stringify(t):t;return r=w(r,n),s?H(R(r)):R(r)}function w(t,e=[]){let s=t;for(const n of e)s=s.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return s}function Q(t){let e=t.trim().replace(/;$/,"");if(e=/^\((\(|async|function)/.test(e)?e.substring(1,e.length-1):e,e.startsWith("{"))return e;if(e.startsWith("async function"))e=e.replace(/^async function/,"async");else if(e.startsWith("function"))e=e.replace(/^function/,"");else{const 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,s])=>`"${e}": ${d(s)}`)}function z(t={},e=!1){const s=Object.keys(t);return e?s.map(n=>"."+n):s}function ae(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];e+=s+": "+n+";"}return e}function ce(t=[],e=[]){return t.filter(s=>!e.includes(s))}function W(t){return f.base64(JSON.stringify(t))}class le{constructor(e,s){this.dsl=e,this.dependencies=s,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const s=e.split(".");if(s.length===4){const n=s.pop(),r=s.join(".")+".",i=s.pop();if(n&&i){const o=this.dependencies.find(a=>a.library===i)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:r,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let n=e.value;for(const r of s){const i=e.value?.match(r)||[];for(const o of i){const a=this.collectImport(o);if(a){const m=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(m,"g"),"")}}}return n}walk(e){const s=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let i of n)s(i);return}const r=Object.values(n);for(const i of r)j(i)?i.value=this.replaceLibraryPath(i):s(i)};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 r of Object.values(n))s=s.concat(Array.from(r));return f.dedupArray(s)}collectContext(e,s){const n=new Set(s?.id?this.context[s.id]:[]),r=(e.directives||[]).find(a=>a.name==="vFor");let i=new Set(Array.from(n));if(r){const{item:a="item",index:m="index"}=r.iterator||{};i=new Set([a,m,...Array.from(i)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],m=a.length?a:[`scope_${s?.id}`];i=new Set([...m,...Array.from(i)])}this.context[e.id]=i}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,r)=>{this.collectContext(n,r),this.collectStyle(n),this.collectUrlSchema(n),this.collectBlockPlugin(n),Array.isArray(n.children)&&n.children.forEach(i=>s(i,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>s(n))}}function ue(t={}){return Object.entries(t).map(([e,s])=>{const n=d(s,!1);return`${e}:${n}`})}function pe(t=[]){return t.map(e=>`${e.name}: {
|
|
14
14
|
from: '${e.from||e.name}',
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
`+x.trim():""}</${_}>`)}const p=Ee(c.slot,v.join(`
|
|
34
34
|
`),r?.id);i.push(p)}),{nodes:i,methods:o,directives:ye(m),components:f.dedupArray(a),importBlocks:f.dedupArray(u,"id")}}function ye(t){return f.dedupArray(t).map(e=>`${e.startsWith("v")?e.substring(1):e}:${e}`)}function ve(t=[]){const e=new Map;for(const s of t){const n=typeof s.slot=="string"?s.slot:s.slot?.name,r=e.get(n);r?r.children.push(s):e.set(n,{slot:s.slot,children:[s]})}return e}function $e(t,e,s){if(ie.includes(t))return null;const n=e.get(t);if(n&&n.alias){const r=n.parent?`${n.parent}.${n.alias}`:n.alias;return`${t}: ${r}`}return X(s)||n?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,s=[]){return t==="style"?j(e)?`:style="${d({...e,value:w(e.value,s)})}"`:"":t==="__class"&&j(e)?`:class="${d({...e,value:w(e.value,s)})}"`:typeof e=="string"?`${t}="${e}"`:j(e)?`:${t}="${d({...e,value:w(e.value,s)})}"`:f.isPlainObject(e)?`:${t}='{${oe(e).join(", ")}}'`:`:${t}='${JSON.stringify(e)}'`}function je(t,e={},s=[]){if(!!Object.keys(e.style||{}).length){const 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,j(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,s))}function Se(t,e,s,n,r){const i=z(e.modifiers,!0);return r?`@${t}${i.join("")}="${s}"`:n&&n.length>0?`@${t}${i.join("")}="(...args:any[]) => ${s}"`:`@${t}${i.join("")}="${s}"`}function ke(t,e={},s={}){const n={},r=Array.from(s[t]||new Set([])),i=r.length?`({${r.join(", ")}}, args)`:"";return{binders:Object.entries(e).map(([a,m])=>{const u=m.handler.value.startsWith("this."),l=u?H(m.handler.value):`${f.camelCase(a)}_${t}${i}`;return u||(n[l]=r.length?{type:"JSFunction",value:`{
|
|
35
35
|
return (${m.handler.value}).apply(this, args);
|
|
36
|
-
}`}:m.handler),Se(a,m,l,r,u)}),handlers:n}}function we(t,e,s={},n={},r={},i){const{binders:o,handlers:a}=ke(e,n,r);return{props:je(t,s,i).join(" "),handlers:a,binders:o,events:o.join(" ")}}function Ce(t=[],e=[],s=[]){const n=[],{vIf:r,vElse:i,vElseIf:o,vShow:a,vModels:m,vFor:u,vBind:l,vHtml:c,customDirectives:v}=Pe(t);if(r&&n.push(`v-if="${d(r.value,!0,!0,e)}"`),o&&n.push(`v-else-if="${d(o.value,!0,!0,e)}"`),i&&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 Pe(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"),r=e.find(c=>f.camelCase(c.name)==="vElseIf"),i=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:r,vElse:i,vFor:o,vShow:a,vModels:l,vBind:m,vHtml:u,customDirectives:s}}function Oe(t,e,s,n,r){return typeof t=="string"?t:k(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?G(t,s,e,n,r):""}function Ee(t,e,s){if(!t)return e;const n=typeof t=="string"?{name:t,params:[]}:{params:[],...t};return`<template ${`#${n.name}="${n.params?.length>0?`{${n.params?.join(",")}}`:`scope_${s}`}"`}>
|
|
36
|
+
}`}:m.handler),Se(a,m,l,r,u)}),handlers:n}}function we(t,e,s={},n={},r={},i){const{binders:o,handlers:a}=ke(e,n,r);return{props:je(t,s,i).join(" "),handlers:a,binders:o,events:o.join(" ")}}function Ce(t=[],e=[],s=[]){const n=[],{vIf:r,vElse:i,vElseIf:o,vShow:a,vModels:m,vFor:u,vBind:l,vHtml:c,customDirectives:v}=Pe(t);if(r&&n.push(`v-if="${d(r.value,!0,!0,e)}"`),o&&n.push(`v-else-if="${d(o.value,!0,!0,e)}"`),i&&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 Pe(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"),r=e.find(c=>f.camelCase(c.name)==="vElseIf"),i=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:r,vElse:i,vFor:o,vShow:a,vModels:l,vBind:m,vHtml:u,customDirectives:s}}function Oe(t,e,s,n,r){return typeof t=="string"?t:k(t)?`{{ ${d(t,!1,!0,e)} }}`:Array.isArray(t)?G(t,s,e,n,r):""}function Ee(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
37
|
${e}
|
|
38
38
|
</template>`}function xe(t,e=[],s=[],n={},r="web"){const i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],o={vue:["defineComponent","reactive"]},a=[];for(const u of e){const l=t.get(u.split(":")[0]);if(l&&l.package){const c=o[l.package]??(o[l.package]=[]),v=l.parent||(l.alias||"").split(".")[0]||l.name;c.push(v),r==="uniapp"&&i.includes(l.package)&&a.push(v)}}for(const[u,l]of Object.entries(n))(o[u]??(o[u]=[])).push(...Array.from(l)),r==="uniapp"&&i.includes(u)&&a.push(...Array.from(l));return{imports:Object.entries(o).filter(([u,l])=>r==="uniapp"?!i.includes(u)&&!!l.length:!!l.length).map(([u,l])=>`import { ${f.dedupArray(l).join(",")}} from '${u}';`).concat(s),uniComponents:a}}function _e(t={}){const e=[];for(const[s,n]of Object.entries(t))e.push(`
|
|
39
39
|
${s} {
|
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.12.
|
|
11
|
+
* @version 0.12.64
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const Ue = "0.12.
|
|
14
|
+
const Ue = "0.12.64";
|
|
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.64
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
22
|
const oe = [
|
|
@@ -556,8 +556,8 @@ function xe(t, e, s, n, r) {
|
|
|
556
556
|
}
|
|
557
557
|
function _e(t, e, s) {
|
|
558
558
|
if (!t) return e;
|
|
559
|
-
const n = typeof t == "string" ? { name: t, params: [] } : { params: [], ...t };
|
|
560
|
-
return `<template ${`#${n.name}="${n.params?.length > 0 ? `{${n.params?.join(",")}}` : `scope_${s}`}"`}>
|
|
559
|
+
const n = typeof t == "string" ? { name: t, params: [], scope: "" } : { params: [], scope: "", ...t };
|
|
560
|
+
return `<template ${`#${n.name}="${n.scope ? n.scope : n.params?.length > 0 ? `{${n.params?.join(",")}}` : `scope_${s}`}"`}>
|
|
561
561
|
${e}
|
|
562
562
|
</template>`;
|
|
563
563
|
}
|
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.64",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"prettier": "~3.6.0",
|
|
25
25
|
"@vtj/base": "~0.12.2",
|
|
26
|
-
"@vtj/core": "~0.12.
|
|
26
|
+
"@vtj/core": "~0.12.64"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@vtj/cli": "~0.12.8"
|
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.63
|
|
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.63";
|