@vtj/coder 0.8.158 → 0.8.160
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 +6 -4
- package/dist/index.mjs +6 -4
- 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) 2024, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/coder
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.8.
|
|
5
|
+
* @version 0.8.160
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const ee="0.8.
|
|
7
|
+
*/const ee="0.8.160";/**!
|
|
8
8
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
9
9
|
* @name @vtj/core
|
|
10
10
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
11
|
-
* @version 0.8.
|
|
11
|
+
* @version 0.8.160
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/const te=["slot","template","component","img","div","p","h1","h2","h3","span","a"];l.mitt();const _={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 q(t,e){return e?t:await x.format(t,{parser:"vue",..._,plugins:[K,I,T,J]})}async function ne(t,e){return e?t:await x.format(t,{parser:"babel-ts",..._,plugins:[I,T]})}async function R(t,e){return e?t:x.format(t,{parser:"scss",..._,plugins:[J]})}function E(t){return t&&t.type==="JSExpression"}function A(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function $(t){return E(t)||A(t)}function L(t){return t.replace(new RegExp("this.","g"),"")}function W(t){return t.replace(/this\.context\??\./g,"")}function u(t,e=!0,n=!0,r=[]){let i=$(t)?t.value:e?JSON.stringify(t):t;return i=w(i,r),n?L(W(i)):W(i)}function w(t,e=[]){let n=t;for(const r of e)n=n.replace(new RegExp(`this.${r}.value`,"g"),`this.${r}`);return n}function U(t){let e=t.trim();if(e=/^\((\(|async|function)/.test(e)?e.substring(1,e.length-1):e,e.startsWith("{"))return e;if(e.startsWith("async function"))e=e.replace(/^async function/,"async");else if(e.startsWith("function"))e=e.replace(/^function/,"");else{const i=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,s=e.match(i);s&&s[2]&&(s[2].startsWith("{")||(e=e.replace(s[2],`{ return ${s[2]} }`))),e=e.replace("=>","")}return e}function re(t={}){return Object.entries(t).map(([e,n])=>`"${e}": ${u(n)}`)}function V(t={},e=!1){const n=Object.keys(t);return e?n.map(r=>"."+r):n}function se(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];e+=n+": "+r+";"}return e}class ie{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(),i=n.join(".")+".",s=n.pop();if(r&&s){const o=this.dependencies.find(a=>a.library===s)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(r)}return{name:r,path:i,library:s}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let r=e.value;for(const i of n){const s=e.value.match(i)||[];for(const o of s){const a=this.collectImport(o);if(a){const c=a.path.replace(/\$/g,"\\$");r=r.replace(new RegExp(c,"g"),"")}}}return r}walk(e){const n=r=>{if(!r||typeof r!="object")return;if(Array.isArray(r)){for(let s of r)n(s);return}const i=Object.values(r);for(const s of i)$(s)?s.value=this.replaceLibraryPath(s):n(s)};n(e)}getLibraryMember(e=[]){let n=[...e];for(const r of Object.values(this.imports))n=n.concat(Array.from(r));return l.dedupArray(n)}collectContext(e,n){const r=new Set(n?.id?this.context[n.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let s=new Set(Array.from(r));if(i){const{item:a="item",index:c="index"}=i.iterator||{};s=new Set([a,c,...Array.from(s)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],c=a.length?a:[`scope_${n?.id}`];s=new Set([...c,...Array.from(s)])}this.context[e.id]=s}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&(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,i)=>{this.collectContext(r,i),this.collectStyle(r),this.collectUrlSchema(r),this.collectBlockPlugin(r),Array.isArray(r.children)&&r.children.forEach(s=>n(s,r))};Array.isArray(e.nodes)&&e.nodes.forEach(r=>n(r))}}function oe(t={}){return Object.entries(t).map(([e,n])=>{const r=u(n,!1);return`${e}:${r}`})}function ae(t=[]){return t.map(e=>`${e.name}: {
|
|
14
14
|
from: '${e.from||e.name}',
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
${se(r)}
|
|
36
36
|
}
|
|
37
37
|
`);return e.join(`
|
|
38
|
-
`)}function Pe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${r.url}');`)}),e}function Oe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(r)});`)}),e}function Ce(t,e){const{dsl:n}=t,r=Object.keys(n.computed||{}),i=S(n.lifeCycles,r),s=S(n.computed,r),o=ue(n.watch,r),a=pe(n.dataSources),{methods:c,nodes:p,components:f,importBlocks:b}=M(n.nodes||[],e,r,t.context),P=[...s,...o.computed],m=S({...c,...n.methods||{}},r),O=b.map(g=>`import ${g.name} from './${g.id}.vue';`),h=we(e,f,O,t.imports),C=Object.keys({...t.urlSchemas,...t.blockPlugins}),d=Pe(t.urlSchemas),v=Oe(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:oe(n.state).join(","),inject:ae(n.inject).join(","),props:ce(n.props).join(","),emits:le(n.emits).join(","),watch:o.watches.join(","),lifeCycles:i.join(","),computed:P.join(","),methods:[...a,...m].join(","),imports
|
|
38
|
+
`)}function Pe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.defineUrlSchemaComponent('${r.url}');`)}),e}function Oe(t={}){const e=[];return Object.entries(t).forEach(([n,r])=>{e.push(`const ${n} = provider.definePluginComponent(${JSON.stringify(r)});`)}),e}function Ce(t,e){const{dsl:n}=t,r=Object.keys(n.computed||{}),i=S(n.lifeCycles,r),s=S(n.computed,r),o=ue(n.watch,r),a=pe(n.dataSources),{methods:c,nodes:p,components:f,importBlocks:b}=M(n.nodes||[],e,r,t.context),P=[...s,...o.computed],m=S({...c,...n.methods||{}},r),O=b.map(g=>`import ${g.name} from './${g.id}.vue';`),h=we(e,f,O,t.imports),C=Object.keys({...t.urlSchemas,...t.blockPlugins}),d=Pe(t.urlSchemas),v=Oe(t.blockPlugins);return{id:n.id,version:n.__VERSION__,name:n.name,state:oe(n.state).join(","),inject:ae(n.inject).join(","),props:ce(n.props).join(","),emits:le(n.emits).join(","),watch:o.watches.join(","),lifeCycles:i.join(","),computed:P.join(","),methods:[...a,...m].join(","),imports:`
|
|
39
|
+
`+h.join(`
|
|
39
40
|
`),components:f.join(","),returns:t.members.join(","),template:p.join(`
|
|
40
41
|
`),css:n.css||"",style:ke(t.style),urlSchemas:d.join(`
|
|
41
42
|
`),blockPlugins:v.join(`
|
|
42
43
|
`),asyncComponents:C.join(",")}}const xe=`
|
|
43
44
|
// @ts-nocheck
|
|
45
|
+
|
|
44
46
|
<%= imports %>
|
|
45
47
|
import { useProvider } from '@vtj/renderer';
|
|
46
48
|
export default defineComponent({
|
package/dist/index.mjs
CHANGED
|
@@ -8,15 +8,15 @@ import * as T from "prettier/plugins/estree";
|
|
|
8
8
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
9
9
|
* @name @vtj/coder
|
|
10
10
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
11
|
-
* @version 0.8.
|
|
11
|
+
* @version 0.8.160
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const Bt = "0.8.
|
|
14
|
+
const Bt = "0.8.160";
|
|
15
15
|
/**!
|
|
16
16
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
17
17
|
* @name @vtj/core
|
|
18
18
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
19
|
-
* @version 0.8.
|
|
19
|
+
* @version 0.8.160
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
22
|
const et = [
|
|
@@ -524,7 +524,8 @@ function Ot(e, t) {
|
|
|
524
524
|
lifeCycles: i.join(","),
|
|
525
525
|
computed: P.join(","),
|
|
526
526
|
methods: [...c, ...f].join(","),
|
|
527
|
-
imports:
|
|
527
|
+
imports: `
|
|
528
|
+
` + m.join(`
|
|
528
529
|
`),
|
|
529
530
|
components: p.join(","),
|
|
530
531
|
returns: e.members.join(","),
|
|
@@ -541,6 +542,7 @@ function Ot(e, t) {
|
|
|
541
542
|
}
|
|
542
543
|
const Ct = `
|
|
543
544
|
// @ts-nocheck
|
|
545
|
+
|
|
544
546
|
<%= imports %>
|
|
545
547
|
import { useProvider } from '@vtj/renderer';
|
|
546
548
|
export default defineComponent({
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/coder",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.160",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"prettier": "~3.3.0",
|
|
8
8
|
"@vtj/base": "~0.8.12",
|
|
9
|
-
"@vtj/core": "~0.8.
|
|
9
|
+
"@vtj/core": "~0.8.160"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@vtj/cli": "~0.8.38"
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/coder
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.8.
|
|
5
|
+
* @version 0.8.160
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.8.
|
|
8
|
+
export declare const version = "0.8.160";
|