@vtj/coder 0.10.11 → 0.10.12

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,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.10.11
5
+ * @version 0.10.12
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const se="0.10.11";/**!
7
+ */const se="0.10.12";/**!
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.10.11
11
+ * @version 0.10.12
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */const re=["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){return e?t:await T.format(t,{parser:"babel-ts",...B,plugins:[D,U]})}async function I(t,e){return e?t:T.format(t,{parser:"scss",...B,plugins:[L]})}function j(t){return t&&t.type==="JSExpression"}function E(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function S(t){return j(t)||E(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,s=[]){let r=S(t)?t.value:e?JSON.stringify(t):t;return r=A(r,s),n?V(J(r)):J(r)}function A(t,e=[]){let n=t;for(const s of e)n=n.replace(new RegExp(`this.${s}.value`,"g"),`this.${s}`);return n}function H(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 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 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(s=>"."+s):n}function oe(t){let e="";for(var n in t)if(t.hasOwnProperty(n)){var s=t[n];e+=n+": "+s+";"}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 s=n.pop(),r=n.join(".")+".",i=n.pop();if(s&&i){const c=this.dependencies.find(a=>a.library===i)?.package;c&&(this.imports[c]||(this.imports[c]=new Set)).add(s)}return{name:s,path:r,library:i}}return null}replaceLibraryPath(e){const{libraryRegex:n}=this;let s=e.value;for(const r of n){const i=e.value?.match(r)||[];for(const c of i){const a=this.collectImport(c);if(a){const p=a.path.replace(/\$/g,"\\$");s=s.replace(new RegExp(p,"g"),"")}}}return s}walk(e){const n=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){for(let i of s)n(i);return}const r=Object.values(s);for(const i of r)S(i)?i.value=this.replaceLibraryPath(i):n(i)};n(e)}getLibraryMember(e=[]){let n=[...e];const s={...this.imports};delete s["uni-h5"],delete s["@dcloudio/uni-h5"],delete s["uni-ui"],delete s["@dcloudio/uni-ui"];for(const r of Object.values(s))n=n.concat(Array.from(r));return f.dedupArray(n)}collectContext(e,n){const s=new Set(n?.id?this.context[n.id]:[]),r=(e.directives||[]).find(a=>a.name==="vFor");let i=new Set(Array.from(s));if(r){const{item:a="item",index:p="index"}=r.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&&(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=(s,r)=>{this.collectContext(s,r),this.collectStyle(s),this.collectUrlSchema(s),this.collectBlockPlugin(s),Array.isArray(s.children)&&s.children.forEach(i=>n(i,s))};Array.isArray(e.nodes)&&e.nodes.forEach(s=>n(s))}}function ue(t={}){return Object.entries(t).map(([e,n])=>{const s=m(n,!1);return`${e}:${s}`})}function le(t=[]){return t.map(e=>`${e.name}: {
14
14
  from: '${e.from||e.name}',
@@ -43,7 +43,7 @@
43
43
  `),components:ce(u,g).join(","),directives:d.join(","),returns:t.members.join(","),template:l.join(`
44
44
  `),css:s.css||"",style:xe(t.style),urlSchemas:w.join(`
45
45
  `),blockPlugins:C.join(`
46
- `),asyncComponents:k.join(","),uniComponents:g,renderer:n==="uniapp"?"@vtj/uniapp":"@vtj/renderer"}}const Ne=`
46
+ `),asyncComponents:k.join(","),uniComponents:g,renderer:n==="uniapp"?"@vtj/uni-app":"@vtj/renderer"}}const Ne=`
47
47
  // @ts-nocheck
48
48
 
49
49
  <%= imports %>
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.10.11
11
+ * @version 0.10.12
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Le = "0.10.11";
14
+ const Le = "0.10.12";
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.10.11
19
+ * @version 0.10.12
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
22
  const re = [
@@ -632,7 +632,7 @@ function Fe(t, e, n = "web") {
632
632
  `),
633
633
  asyncComponents: w.join(","),
634
634
  uniComponents: y,
635
- renderer: n === "uniapp" ? "@vtj/uniapp" : "@vtj/renderer"
635
+ renderer: n === "uniapp" ? "@vtj/uni-app" : "@vtj/renderer"
636
636
  };
637
637
  }
638
638
  const Ie = `
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.10.11",
4
+ "version": "0.10.12",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "prettier": "~3.5.0",
8
- "@vtj/base": "~0.10.1",
9
- "@vtj/core": "~0.10.11"
8
+ "@vtj/core": "~0.10.12",
9
+ "@vtj/base": "~0.10.1"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@vtj/cli": "~0.10.2"
@@ -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.10.10
5
+ * @version 0.10.11
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.10.10";
8
+ export declare const version = "0.10.11";