@vtj/coder 0.20.2 → 0.20.3
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 +5 -5
- package/dist/index.mjs +19 -16
- package/package.json +2 -2
- package/types/parser/defines.d.ts +2 -2
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
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.20.
|
|
5
|
+
* @version 0.20.3
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const Be="0.20.
|
|
7
|
+
*/const Be="0.20.3";/**!
|
|
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.20.
|
|
11
|
+
* @version 0.20.3
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/const Me=["slot","template","component","img","div","p","h1","h2","h3","span","a"];b.mitt();function Ne(t){return(t||"").trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"").replace(/\.vue$/i,"")}function te(t){return Ne(t.filePath)||t.id}function J(t,e="web"){const s=te(t);return t.type==="block"?`src/components/${s}.vue`:e==="uniapp"?`src/pages/${s}.vue`:`src/views/${s}.vue`}function se(t){return`@/components/${te(t)}.vue`}function ne(t=[]){const e=[];for(const s of t)s.dir||e.push(s),s.children?.length&&e.push(...ne(s.children));return e}function Te(t){const e=new Map,s=new Map,r=new Map,n=new Map;for(const o of t.blocks||[]){const c=J(o,t.platform).toLowerCase();e.set(o.id,o),r.set(c,o.id),s.set(se(o).toLowerCase(),o.id)}for(const o of ne(t.pages))e.set(o.id,o),n.set(J(o,t.platform).toLowerCase(),o.id);return{byId:e,blockIdByImportPath:s,blockIdBySourcePath:r,pageIdBySourcePath:n}}const G={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,removeBlankLines:!0};async function V(t,e){return e?t:await H.format(t,{parser:"vue",...G,plugins:[Ee,Y,ee,K]})}async function re(t,e){if(e)return t;try{return(await H.format(t,{parser:"babel-ts",...G,plugins:[Y,ee]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function W(t,e){return e?t:H.format(t,{parser:"scss",...G,plugins:[K]})}function N(t){return t&&t.type==="JSExpression"}function R(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function k(t){return N(t)||R(t)}function oe(t){return t.replace(new RegExp("this.","g"),"")}function q(t){return t.replace(/this\.context\??\./g,"")}function y(t,e=!0,s=!0,r=[],n=!0){let o=t;return k(t)?(o=t.value.trim().replace(/;$/,""),n&&(o=o.replace(/\"/g,"'"))):o=e?JSON.stringify(o):t,o=T(o,r),s?oe(q(o)):q(o)}function T(t="",e=[]){let s=t;for(const r of e)s=s.replace(new RegExp(`this.${r}.value`,"g"),`this.${r}`);return s}function ce(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 n=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,o=e.match(n);o&&o[2]&&(o[2].startsWith("{")||(e=e.replace(o[2],`{ return ${o[2]} }`))),e=e.replace("=>","")}return e}function Re(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${y(s)}`)}function ae(t={},e=!1){const s=Object.keys(t);return e?s.map(r=>"."+r):s}function Le(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var r=t[s];e+=s+": "+r+";"}return e}function De(t=[],e=[]){return t.filter(s=>!e.includes(s))}function Q(t){return b.base64(JSON.stringify(t))}class Ue{constructor(e,s){this.dsl=e,this.dependencies=s,this.collectEasycom(),this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};style={};members=[];urlSchemas={};blockPlugins={};easycomPackages=new Set;libraryRegex=[];collectEasycom(){for(const e of this.dependencies)e.easycom?.key&&e.easycom?.value&&e.package&&this.easycomPackages.add(e.package)}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 r=s.pop(),n=s.join(".")+".",o=s.pop();if(r&&o){const c=this.dependencies.find(a=>a.library===o)?.package;c&&!this.easycomPackages.has(c)&&(this.imports[c]||(this.imports[c]=new Set)).add(r)}return{name:r,path:n,library:o}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let r=e.value;for(const n of s){const o=e.value?.match(n)||[];for(const c of o){const a=this.collectImport(c);if(a){const l=a.path.replace(/\$/g,"\\$");r=r.replace(new RegExp(l,"g"),"")}}}return r}walk(e){const s=r=>{if(!r||typeof r!="object")return;if(Array.isArray(r)){for(let o of r)s(o);return}const n=Object.values(r);for(const o of n)k(o)?o.value=this.replaceLibraryPath(o):s(o)};s(e)}getLibraryMember(e=[]){let s=[...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 n of Object.values(r))s=s.concat(Array.from(n));return b.dedupArray(s)}collectContext(e,s){const r=new Set(s?.id?this.context[s.id]:[]),n=(e.directives||[]).find(a=>a.name==="vFor");let o=new Set(Array.from(r));if(n){const{item:a="item",index:l="index"}=n.iterator||{};o=new Set([a,l,...Array.from(o)])}const c=e.slot;if(c){const a=typeof c=="string"?[]:c.params||[],l=a.length?a:[`scope_${s?.id}`];o=new Set([...l,...Array.from(o)])}this.context[e.id]=o}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!k(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=(r,n)=>{this.collectContext(r,n),this.collectStyle(r),this.collectUrlSchema(r),this.collectBlockPlugin(r),Array.isArray(r.children)&&r.children.forEach(o=>s(o,r))};Array.isArray(e.nodes)&&e.nodes.forEach(r=>s(r))}}function Fe(t={}){return Object.entries(t).map(([e,s])=>{const r=y(s,!1,!0,[],!1);return`${e}:${r}`})}function Je(t=[]){return t.map(e=>`${e.name}: {
|
|
14
14
|
from: '${e.from||e.name}',
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
${Le(r)}
|
|
39
39
|
}
|
|
40
40
|
`);return e.join(`
|
|
41
|
-
`)}function de(t={}){const
|
|
41
|
+
`)}function de(t={},e="provider"){const s=[];return Object.entries(t).forEach(([r,n])=>{s.push(`const ${r} = ${e}.defineUrlSchemaComponent('${n.url}');`)}),s}function he(t={},e="provider"){const s=[];return Object.entries(t).forEach(([r,n])=>{s.push(`const ${r} = ${e}.definePluginComponent(${JSON.stringify(n)});`)}),s}function ct(t,e,s="web",r){const{dsl:n}=t,o=Object.keys(n.computed||{}),c=U(n.lifeCycles,o),a=U(n.computed,o),l=We(n.watch,o),m=qe(n.dataSources),{methods:p,nodes:i,components:u,importBlocks:f,directives:_}=z(n.nodes||[],e,o,t.context,void 0,t.easycomPackages),g=[...a,...l.computed],O=U({...p,...n.methods||{}},o),h=f.map(C=>{const $=r?.(C.id)||`./${C.id}.vue`;return`import ${C.name} from '${$}';`});let{imports:v,uniComponents:d}=ot(e,u,h,t.imports,s,t.easycomPackages);const S=Object.keys({...t.urlSchemas,...t.blockPlugins}),j=de(t.urlSchemas),I=he(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:Fe(n.state).join(","),inject:Je(n.inject).join(","),props:ie(n.props).join(","),emits:le(n.emits).join(","),expose:n.expose&&n.expose.length?JSON.stringify(n.expose||[]):"",watch:l.watches.join(","),lifeCycles:c.join(","),computed:g.join(","),methods:[...m,...O].join(","),imports:`
|
|
42
42
|
`+v.join(`
|
|
43
43
|
`),components:De(u,d).join(","),directives:_.join(","),returns:t.members.join(","),template:i.join(`
|
|
44
44
|
`),css:n.css||"",style:me(t.style),urlSchemas:j.join(`
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
return await __provider.apis['${s.ref}'].apply(null, args).then(${n});
|
|
51
51
|
};`}}).filter(s=>!!s)}function bt(t=[],e){return t.map(s=>{if(!s||!s.handler||!s.handler.value)return null;const r=s.source&&s.source.value?w(s.source.value,e,"script"):"() => null",n=M(r),o=w(s.handler.value,e,"script"),c=M(o),a=[];s.deep&&a.push("deep: true"),s.immediate&&a.push("immediate: true"),s.flush&&a.push(`flush: '${s.flush}'`);const l=a.length>0?`, { ${a.join(", ")} }`:"";return`watch(${n}, ${c}${l});`}).filter(s=>!!s)}function _t(t={},e){return Object.entries(t).map(([s,r])=>{let n;if(R(r)){const o=w(r.value||"",e,"script");n=M(o)}else k(r)?n=w(r.value||"undefined",e,"script"):n=JSON.stringify(r);return`provide('${s}', ${n});`})}function be(t){let e=t.trim().replace(/;$/,"");/^\((\(|async|function)/.test(e)&&(e=e.substring(1,e.length-1).trim());const s=e.match(/^(?:async\s+)?\([^)]*\)\s*=>\s*([\s\S]+)$/);if(s){let n=s[1].trim();return n.startsWith("{")&&n.endsWith("}")?n=n.slice(1,-1).trim():n=n.replace(/;$/,"")+";",n}const r=e.match(/^(?:async\s+)?function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*)\}$/);return r?r[1].trim():e}function yt(t,e){if(!t||!t.value)return"";const s=w(t.value,e,"script");return be(s)}function St(t={},e){const s=[];for(const r of["beforeCreate","created"]){const n=t[r];if(n&&n.value){const o=w(n.value,e,"script"),c=be(o);c&&s.push(`// ${r}
|
|
52
52
|
${c}`)}}return s.join(`
|
|
53
|
-
`)}const jt={beforeMount:"onBeforeMount",mounted:"onMounted",beforeUpdate:"onBeforeUpdate",updated:"onUpdated",beforeUnmount:"onBeforeUnmount",unmounted:"onUnmounted",errorCaptured:"onErrorCaptured",renderTracked:"onRenderTracked",renderTriggered:"onRenderTriggered",activated:"onActivated",deactivated:"onDeactivated"},kt=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onErrorCaptured","onRenderTracked","onRenderTriggered","onActivated","onDeactivated"]),wt=new Set(["onLoad","onShow","onReady","onHide","onUnload","onResize","onPullDownRefresh","onReachBottom","onTabItemTap","onShareAppMessage","onPageScroll","onNavigationBarButtonTap","onBackPress","onNavigationBarSearchInputChanged","onNavigationBarSearchInputConfirmed","onNavigationBarSearchInputClicked","onShareTimeline","onAddToFavorites"]);function It(t={},e){const s=[],r=new Set,n=new Set;for(const[o,c]of Object.entries(t)){if(!c||!c.value||o==="created"||o==="beforeCreate")continue;const a=jt[o]||o;if(kt.has(a)){const l=w(c.value,e,"script"),m=M(l);s.push(`${a}(${m});`),r.add(a)}else if(wt.has(a)){const l=w(c.value,e,"script"),m=M(l);s.push(`${a}(${m});`),n.add(a)}}return{statements:s,usedHooks:r,usedUniHooks:n}}function Ct(t){const{componentMap:e,components:s,importBlocks:r,collectImports:n,platform:o,vueImports:c,composableImports:a,globalApiImports:l,uniHookImports:m,easycomPackages:p}=t,i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],u={vue:[...c]},f=[],_=[],g={};for(const h of s){const v=h.split(":")[0],d=e.get(v);if(!d||!d.package||d.parent||p.has(d.package))continue;const S=u[d.package]??(u[d.package]=[]),j=(d.alias||"").split(".")[0]||d.name,I=v,C=j!==I?`${j} as ${I}`:j;S.push(C),g[j]=I,o==="uniapp"&&i.includes(d.package)&&f.push(j)}for(const h of s){const v=h.split(":")[0],d=e.get(v);if(!d||!d.package||!d.parent||p.has(d.package))continue;const S=d.parent,j=g[S]??S,I=d.alias||"";_.push(`const ${v} = ${j}.${I};`),g[S]||((u[d.package]??(u[d.package]=[])).push(S),g[S]=S)}for(const[h,v]of Object.entries(n))(u[h]??(u[h]=[])).push(...Array.from(v)),o==="uniapp"&&i.includes(h)&&f.push(...Array.from(v));for(const[h,v]of Object.entries(a))(u[h]??(u[h]=[])).push(...v);for(const[h,v]of Object.entries(l))(u[h]??(u[h]=[])).push(...v);return o==="uniapp"&&m.length>0&&(u["@dcloudio/uni-app"]??(u["@dcloudio/uni-app"]=[])).push(...m),{imports:Object.entries(u).filter(([h,v])=>o==="uniapp"?!i.includes(h)&&!!v.length:!!v.length).map(([h,v])=>`import { ${b.dedupArray(v).join(",")}} from '${h}';`).concat(r),uniComponents:f,componentDeclarations:_}}function At(t,e=B,s=new Set,r=new Set){const n=Object.entries(e),o=c=>{if(c==null||typeof c!="object")return c;if(Array.isArray(c))return c.map(o);if(k(c)&&typeof c.value=="string"){let l=c.value;for(const[m,p]of n){const i=m.replace(/\$/g,"\\$"),u=new RegExp(`this\\.${i}\\b`,"g");l=l.replace(u,p.replace)}return l=l.replace(/this\.([A-Za-z_$][\w$]*)\.value\b/g,(m,p)=>s.has(p)||r.has(p)?p:m),{...c,value:l}}const a={};for(const[l,m]of Object.entries(c))a[l]=o(m);return a};return t.map(o)}function Ot(t,e,s=[],r={},n,o=B,c=new Set,a=new Set,l=new Set){const m=At(t,o,c,a);return z(m,e,s,r,n,l)}function Pt(t,e,s="web",r){const{dsl:n}=t,o=ve(e),c=$e(o),a=ut(n,c),l=at(n,c),m=it(l,c),p=lt(l,c),i=p.__renderer__||[];delete p.__renderer__;const u=Ot(n.nodes||[],e,Object.keys(n.computed||{}),t.context,void 0,c,a.refs,a.computed,t.easycomPackages),f=u.importBlocks.map(A=>`import ${A.name} from '${r?.(A.id)||`./${A.id}.vue`}';`),_=pt(n.refs||{},a),g=ft(n.reactives||{},a),O=mt(n.state||{},a),h=gt(n.computed||{},a),v={...u.methods||{},...n.methods||{}},d=vt(v,a),S=$t(n.dataSources||{},a),j=bt(n.watch||[],a),I=ht(n.inject||[],a),C=_t(n.provide||{},a),$=dt(n.composables||[],a),P=new Set;for(const A of n.composables||[])if(A.destructure&&A.destructure.length>0)for(const D of A.destructure)P.add(D);else A.name&&P.add(A.name);const L=m.filter(A=>{const D=A.match(/^const\s+(\w+)\s*=/);return!(D&&P.has(D[1]))}),x=It(n.lifeCycles||{},a),_e=St(n.lifeCycles||{},a),ye=yt(n.setup,a),E=new Set;_.length>0&&E.add("ref"),(g.length>0||O)&&E.add("reactive"),h.length>0&&E.add("computed"),j.length>0&&E.add("watch"),I.length>0&&E.add("inject"),C.length>0&&E.add("provide");for(const A of x.usedHooks)E.add(A);const Se=s==="uniapp"?Array.from(x.usedUniHooks):[],{imports:je,uniComponents:ke,componentDeclarations:we}=Ct({componentMap:e,components:u.components,importBlocks:f,collectImports:t.imports,platform:s,vueImports:Array.from(E),composableImports:$.imports,globalApiImports:p,uniHookImports:Se,easycomPackages:t.easycomPackages}),Ie=de(t.urlSchemas),Ce=he(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,imports:`
|
|
53
|
+
`)}const jt={beforeMount:"onBeforeMount",mounted:"onMounted",beforeUpdate:"onBeforeUpdate",updated:"onUpdated",beforeUnmount:"onBeforeUnmount",unmounted:"onUnmounted",errorCaptured:"onErrorCaptured",renderTracked:"onRenderTracked",renderTriggered:"onRenderTriggered",activated:"onActivated",deactivated:"onDeactivated"},kt=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onErrorCaptured","onRenderTracked","onRenderTriggered","onActivated","onDeactivated"]),wt=new Set(["onLoad","onShow","onReady","onHide","onUnload","onResize","onPullDownRefresh","onReachBottom","onTabItemTap","onShareAppMessage","onPageScroll","onNavigationBarButtonTap","onBackPress","onNavigationBarSearchInputChanged","onNavigationBarSearchInputConfirmed","onNavigationBarSearchInputClicked","onShareTimeline","onAddToFavorites"]);function It(t={},e){const s=[],r=new Set,n=new Set;for(const[o,c]of Object.entries(t)){if(!c||!c.value||o==="created"||o==="beforeCreate")continue;const a=jt[o]||o;if(kt.has(a)){const l=w(c.value,e,"script"),m=M(l);s.push(`${a}(${m});`),r.add(a)}else if(wt.has(a)){const l=w(c.value,e,"script"),m=M(l);s.push(`${a}(${m});`),n.add(a)}}return{statements:s,usedHooks:r,usedUniHooks:n}}function Ct(t){const{componentMap:e,components:s,importBlocks:r,collectImports:n,platform:o,vueImports:c,composableImports:a,globalApiImports:l,uniHookImports:m,easycomPackages:p}=t,i=["@dcloudio/uni-h5","uni-h5","@dcloudio/uni-ui","uni-ui"],u={vue:[...c]},f=[],_=[],g={};for(const h of s){const v=h.split(":")[0],d=e.get(v);if(!d||!d.package||d.parent||p.has(d.package))continue;const S=u[d.package]??(u[d.package]=[]),j=(d.alias||"").split(".")[0]||d.name,I=v,C=j!==I?`${j} as ${I}`:j;S.push(C),g[j]=I,o==="uniapp"&&i.includes(d.package)&&f.push(j)}for(const h of s){const v=h.split(":")[0],d=e.get(v);if(!d||!d.package||!d.parent||p.has(d.package))continue;const S=d.parent,j=g[S]??S,I=d.alias||"";_.push(`const ${v} = ${j}.${I};`),g[S]||((u[d.package]??(u[d.package]=[])).push(S),g[S]=S)}for(const[h,v]of Object.entries(n))(u[h]??(u[h]=[])).push(...Array.from(v)),o==="uniapp"&&i.includes(h)&&f.push(...Array.from(v));for(const[h,v]of Object.entries(a))(u[h]??(u[h]=[])).push(...v);for(const[h,v]of Object.entries(l))(u[h]??(u[h]=[])).push(...v);return o==="uniapp"&&m.length>0&&(u["@dcloudio/uni-app"]??(u["@dcloudio/uni-app"]=[])).push(...m),{imports:Object.entries(u).filter(([h,v])=>o==="uniapp"?!i.includes(h)&&!!v.length:!!v.length).map(([h,v])=>`import { ${b.dedupArray(v).join(",")}} from '${h}';`).concat(r),uniComponents:f,componentDeclarations:_}}function At(t,e=B,s=new Set,r=new Set){const n=Object.entries(e),o=c=>{if(c==null||typeof c!="object")return c;if(Array.isArray(c))return c.map(o);if(k(c)&&typeof c.value=="string"){let l=c.value;for(const[m,p]of n){const i=m.replace(/\$/g,"\\$"),u=new RegExp(`this\\.${i}\\b`,"g");l=l.replace(u,p.replace)}return l=l.replace(/this\.([A-Za-z_$][\w$]*)\.value\b/g,(m,p)=>s.has(p)||r.has(p)?p:m),{...c,value:l}}const a={};for(const[l,m]of Object.entries(c))a[l]=o(m);return a};return t.map(o)}function Ot(t,e,s=[],r={},n,o=B,c=new Set,a=new Set,l=new Set){const m=At(t,o,c,a);return z(m,e,s,r,n,l)}function Pt(t,e,s="web",r){const{dsl:n}=t,o=ve(e),c=$e(o),a=ut(n,c),l=at(n,c),m=it(l,c),p=lt(l,c),i=p.__renderer__||[];delete p.__renderer__;const u=Ot(n.nodes||[],e,Object.keys(n.computed||{}),t.context,void 0,c,a.refs,a.computed,t.easycomPackages),f=u.importBlocks.map(A=>`import ${A.name} from '${r?.(A.id)||`./${A.id}.vue`}';`),_=pt(n.refs||{},a),g=ft(n.reactives||{},a),O=mt(n.state||{},a),h=gt(n.computed||{},a),v={...u.methods||{},...n.methods||{}},d=vt(v,a),S=$t(n.dataSources||{},a),j=bt(n.watch||[],a),I=ht(n.inject||[],a),C=_t(n.provide||{},a),$=dt(n.composables||[],a),P=new Set;for(const A of n.composables||[])if(A.destructure&&A.destructure.length>0)for(const D of A.destructure)P.add(D);else A.name&&P.add(A.name);const L=m.filter(A=>{const D=A.match(/^const\s+(\w+)\s*=/);return!(D&&P.has(D[1]))}),x=It(n.lifeCycles||{},a),_e=St(n.lifeCycles||{},a),ye=yt(n.setup,a),E=new Set;_.length>0&&E.add("ref"),(g.length>0||O)&&E.add("reactive"),h.length>0&&E.add("computed"),j.length>0&&E.add("watch"),I.length>0&&E.add("inject"),C.length>0&&E.add("provide");for(const A of x.usedHooks)E.add(A);const Se=s==="uniapp"?Array.from(x.usedUniHooks):[],{imports:je,uniComponents:ke,componentDeclarations:we}=Ct({componentMap:e,components:u.components,importBlocks:f,collectImports:t.imports,platform:s,vueImports:Array.from(E),composableImports:$.imports,globalApiImports:p,uniHookImports:Se,easycomPackages:t.easycomPackages}),Ie=de(t.urlSchemas,"__provider"),Ce=he(t.blockPlugins,"__provider");return{id:n.id,version:n.__VERSION__,name:n.name,imports:`
|
|
54
54
|
`+je.join(`
|
|
55
55
|
`),props:ie(n.props).join(","),emits:le(n.emits).join(","),needsProps:l.has("$props"),needsEmit:l.has("$emit"),expose:n.expose&&n.expose.length?`{ ${n.expose.join(", ")} }`:"",globalApiDeclares:L.join(`
|
|
56
56
|
`),injects:I.join(`
|
package/dist/index.mjs
CHANGED
|
@@ -8,15 +8,15 @@ import * as ee from "prettier/plugins/estree";
|
|
|
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.20.
|
|
11
|
+
* @version 0.20.3
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const Jt = "0.20.
|
|
14
|
+
const Jt = "0.20.3";
|
|
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.20.
|
|
19
|
+
* @version 0.20.3
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
22
|
const Be = [
|
|
@@ -650,21 +650,21 @@ function me(t = {}) {
|
|
|
650
650
|
return e.join(`
|
|
651
651
|
`);
|
|
652
652
|
}
|
|
653
|
-
function de(t = {}) {
|
|
654
|
-
const
|
|
655
|
-
return Object.entries(t).forEach(([
|
|
656
|
-
|
|
657
|
-
`const ${
|
|
653
|
+
function de(t = {}, e = "provider") {
|
|
654
|
+
const s = [];
|
|
655
|
+
return Object.entries(t).forEach(([o, n]) => {
|
|
656
|
+
s.push(
|
|
657
|
+
`const ${o} = ${e}.defineUrlSchemaComponent('${n.url}');`
|
|
658
658
|
);
|
|
659
|
-
}),
|
|
659
|
+
}), s;
|
|
660
660
|
}
|
|
661
|
-
function he(t = {}) {
|
|
662
|
-
const
|
|
663
|
-
return Object.entries(t).forEach(([
|
|
664
|
-
|
|
665
|
-
`const ${
|
|
661
|
+
function he(t = {}, e = "provider") {
|
|
662
|
+
const s = [];
|
|
663
|
+
return Object.entries(t).forEach(([o, n]) => {
|
|
664
|
+
s.push(
|
|
665
|
+
`const ${o} = ${e}.definePluginComponent(${JSON.stringify(n)});`
|
|
666
666
|
);
|
|
667
|
-
}),
|
|
667
|
+
}), s;
|
|
668
668
|
}
|
|
669
669
|
function ct(t, e, s = "web", o) {
|
|
670
670
|
const { dsl: n } = t, r = Object.keys(n.computed || {}), c = F(n.lifeCycles, r), a = F(n.computed, r), l = We(n.watch, r), m = He(n.dataSources), { methods: p, nodes: i, components: u, importBlocks: f, directives: b } = z(
|
|
@@ -1431,7 +1431,10 @@ function Bt(t, e, s = "web", o) {
|
|
|
1431
1431
|
globalApiImports: p,
|
|
1432
1432
|
uniHookImports: _e,
|
|
1433
1433
|
easycomPackages: t.easycomPackages
|
|
1434
|
-
}), ke = de(t.urlSchemas), we = he(
|
|
1434
|
+
}), ke = de(t.urlSchemas, "__provider"), we = he(
|
|
1435
|
+
t.blockPlugins,
|
|
1436
|
+
"__provider"
|
|
1437
|
+
);
|
|
1435
1438
|
return {
|
|
1436
1439
|
id: n.id,
|
|
1437
1440
|
version: n.__VERSION__,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/coder",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.20.
|
|
4
|
+
"version": "0.20.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"AI低代码",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"prettier": "~3.7.0",
|
|
27
27
|
"@vtj/base": "~0.13.1",
|
|
28
|
-
"@vtj/core": "~0.20.
|
|
28
|
+
"@vtj/core": "~0.20.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@vtj/cli": "~0.14.2"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NodeFromUrlSchema, NodeFromPlugin } from '@vtj/core';
|
|
2
|
-
export declare function parseUrlSchemas(urlSchemas?: Record<string, NodeFromUrlSchema
|
|
3
|
-
export declare function parseBlockPlugins(plugins?: Record<string, NodeFromPlugin
|
|
2
|
+
export declare function parseUrlSchemas(urlSchemas?: Record<string, NodeFromUrlSchema>, provider?: string): string[];
|
|
3
|
+
export declare function parseBlockPlugins(plugins?: Record<string, NodeFromPlugin>, provider?: string): string[];
|
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.20.
|
|
5
|
+
* @version 0.20.2
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.20.
|
|
8
|
+
export declare const version = "0.20.2";
|