@vtj/coder 0.7.9 → 0.7.10

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 CHANGED
@@ -2,9 +2,9 @@
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.7.9
5
+ * @version 0.7.10
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const U="0.7.9",O={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 F(t,e){return e?t:await C.format(t,{parser:"html",...O,plugins:[Q]})}async function X(t,e){return e?t:await C.format(t,{parser:"babel-ts",...O,plugins:[z,H]})}async function Y(t,e){return e?t:C.format(t,{parser:"scss",...O,plugins:[G]})}function k(t){return t&&t.type==="JSExpression"}function x(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function P(t){return k(t)||x(t)}function N(t){return t.replace(new RegExp("this.","g"),"")}function E(t){return t.replace(new RegExp("this.context.","g"),"")}function u(t,e=!0,r=!0){const n=P(t)?t.value:e?JSON.stringify(t):t;return r?N(E(n)):E(n)}function _(t,e=[]){let r=t;for(const n of e)r=r.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return r}function I(t){let e=t.trim();return e.startsWith("{")||(e.startsWith("async function")?e=e.replace(/^async function/,"async"):e.startsWith("function")?e=e.replace(/^function/,""):e=e.replace("=>","")),e}function Z(t={}){return Object.entries(t).map(([e,r])=>`"${e}": ${u(r)}`)}function R(t={},e=!1){const r=Object.keys(t);return e?r.map(n=>"."+n):r}class K{constructor(e,r){this.dsl=e,this.dependencies=r,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};members=[];libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const r=e.split(".");if(r.length===4){const n=r.pop(),i=r.join(".")+".",s=r.pop();if(n&&s){const o=this.dependencies.find(a=>a.library===s)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:i,library:s}}return null}replaceLibraryPath(e){const{libraryRegex:r}=this;let n=e.value;for(const i of r){const s=e.value.match(i)||[];for(const o of s){const a=this.collectImport(o);if(a){const c=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(c,"g"),"")}}}return n}walk(e){const r=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let s of n)r(s);return}const i=Object.values(n);for(const s of i)P(s)?s.value=this.replaceLibraryPath(s):r(s)};r(e)}getLibraryMember(e=[]){let r=[...e];for(const n of Object.values(this.imports))r=r.concat(Array.from(n));return p.dedupArray(r)}collectContext(e,r){const n=new Set(r?.id?this.context[r.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let s=new Set(Array.from(n));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_${r?.id}`];s=new Set([...c,...Array.from(s)])}this.context[e.id]=s}walkNodes(e){const r=(n,i)=>{this.collectContext(n,i),Array.isArray(n.children)&&n.children.forEach(s=>r(s,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>r(n))}}function ee(t={}){return Object.entries(t).map(([e,r])=>{const n=u(r,!1);return`${e}:${n}`})}function te(t=[]){return t.map(e=>`${e.name}: {
7
+ */const U="0.7.10",O={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 F(t,e){return e?t:await C.format(t,{parser:"html",...O,plugins:[Q]})}async function X(t,e){return e?t:await C.format(t,{parser:"babel-ts",...O,plugins:[z,H]})}async function Y(t,e){return e?t:C.format(t,{parser:"scss",...O,plugins:[G]})}function k(t){return t&&t.type==="JSExpression"}function x(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function P(t){return k(t)||x(t)}function N(t){return t.replace(new RegExp("this.","g"),"")}function E(t){return t.replace(new RegExp("this.context.","g"),"")}function u(t,e=!0,r=!0){const n=P(t)?t.value:e?JSON.stringify(t):t;return r?N(E(n)):E(n)}function _(t,e=[]){let r=t;for(const n of e)r=r.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return r}function I(t){let e=t.trim();return e.startsWith("{")||(e.startsWith("async function")?e=e.replace(/^async function/,"async"):e.startsWith("function")?e=e.replace(/^function/,""):e=e.replace("=>","")),e}function Z(t={}){return Object.entries(t).map(([e,r])=>`"${e}": ${u(r)}`)}function R(t={},e=!1){const r=Object.keys(t);return e?r.map(n=>"."+n):r}class K{constructor(e,r){this.dsl=e,this.dependencies=r,this.libraryRegex=this.collectLibrary(),this.walk(e),this.walkNodes(e),this.members=this.getLibraryMember()}imports={};context={};members=[];libraryRegex=[];collectLibrary(){return this.dependencies.filter(e=>!!e.library).map(e=>new RegExp(`(this.\\$libs.${e.library}.([\\w]+))`,"g"))}collectImport(e){const r=e.split(".");if(r.length===4){const n=r.pop(),i=r.join(".")+".",s=r.pop();if(n&&s){const o=this.dependencies.find(a=>a.library===s)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:i,library:s}}return null}replaceLibraryPath(e){const{libraryRegex:r}=this;let n=e.value;for(const i of r){const s=e.value.match(i)||[];for(const o of s){const a=this.collectImport(o);if(a){const c=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(c,"g"),"")}}}return n}walk(e){const r=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let s of n)r(s);return}const i=Object.values(n);for(const s of i)P(s)?s.value=this.replaceLibraryPath(s):r(s)};r(e)}getLibraryMember(e=[]){let r=[...e];for(const n of Object.values(this.imports))r=r.concat(Array.from(n));return p.dedupArray(r)}collectContext(e,r){const n=new Set(r?.id?this.context[r.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let s=new Set(Array.from(n));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_${r?.id}`];s=new Set([...c,...Array.from(s)])}this.context[e.id]=s}walkNodes(e){const r=(n,i)=>{this.collectContext(n,i),Array.isArray(n.children)&&n.children.forEach(s=>r(s,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>r(n))}}function ee(t={}){return Object.entries(t).map(([e,r])=>{const n=u(r,!1);return`${e}:${n}`})}function te(t=[]){return t.map(e=>`${e.name}: {
8
8
  from: '${e.from||e.name}',
9
9
  default: ${u(e.default,!0,!1)}
10
10
  }`)}function re(t=[]){const e=r=>r?`[${p.toArray(r).map(s=>s.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(r=>typeof r=="string"?`${r}: {}`:`${r.name}: {
package/dist/index.mjs CHANGED
@@ -8,10 +8,10 @@ import * as H 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.7.9
11
+ * @version 0.7.10
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const ke = "0.7.9", k = {
14
+ const ke = "0.7.10", k = {
15
15
  arrowParens: "always",
16
16
  bracketSpacing: !0,
17
17
  bracketSameLine: !0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.7.9",
4
+ "version": "0.7.10",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "vue-tsc && vite build",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@vtj/base": "^0.7.3",
14
- "@vtj/core": "^0.7.9",
14
+ "@vtj/core": "^0.7.10",
15
15
  "prettier": "~3.2.1"
16
16
  },
17
17
  "devDependencies": {
@@ -31,7 +31,7 @@
31
31
  "dist",
32
32
  "types"
33
33
  ],
34
- "gitHead": "923aab791b5aacf1f0e75255ad7aa2b1b71e26bf",
34
+ "gitHead": "6c54f72d57ad363d1ed75a36f25aed10d6b6a262",
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  }
@@ -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.7.8
5
+ * @version 0.7.10
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.7.8";
8
+ export declare const version = "0.7.10";