@vtj/coder 0.7.29 → 0.7.31

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) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/coder
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.7.29
5
+ * @version 0.7.31
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const X="0.7.29";/**!
7
+ */const X="0.7.31";/**!
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.7.29
11
+ * @version 0.7.31
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */const Y=["slot","template","component","img","div","p","h1","h2","h3","span","a"];l.mitt();const x={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 J(t,e){return e?t:await _.format(t,{parser:"vue",...x,plugins:[U,T,B,q]})}async function Z(t,e){return e?t:await _.format(t,{parser:"babel-ts",...x,plugins:[T,B]})}async function W(t,e){return e?t:_.format(t,{parser:"scss",...x,plugins:[q]})}function C(t){return t&&t.type==="JSExpression"}function P(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function v(t){return C(t)||P(t)}function A(t){return t.replace(new RegExp("this.","g"),"")}function I(t){return t.replace(/this\.context\??\./g,"")}function u(t,e=!0,s=!0){const r=v(t)?t.value:e?JSON.stringify(t):t;return s?A(I(r)):I(r)}function j(t,e=[]){let s=t;for(const r of e)s=s.replace(new RegExp(`this.${r}.value`,"g"),`this.${r}`);return s}function L(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]+)/,n=e.match(i);n&&n[2]&&(n[2].startsWith("{")||(e=e.replace(n[2],`{ return ${n[2]} }`))),e=e.replace("=>","")}return e}function K(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${u(s)}`)}function M(t={},e=!1){const s=Object.keys(t);return e?s.map(r=>"."+r):s}function ee(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var r=t[s];e+=s+": "+r+";"}return e}class te{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=[];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 r=s.pop(),i=s.join(".")+".",n=s.pop();if(r&&n){const o=this.dependencies.find(a=>a.library===n)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(r)}return{name:r,path:i,library:n}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let r=e.value;for(const i of s){const n=e.value.match(i)||[];for(const o of n){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 s=r=>{if(!r||typeof r!="object")return;if(Array.isArray(r)){for(let n of r)s(n);return}const i=Object.values(r);for(const n of i)v(n)?n.value=this.replaceLibraryPath(n):s(n)};s(e)}getLibraryMember(e=[]){let s=[...e];for(const r of Object.values(this.imports))s=s.concat(Array.from(r));return l.dedupArray(s)}collectContext(e,s){const r=new Set(s?.id?this.context[s.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let n=new Set(Array.from(r));if(i){const{item:a="item",index:c="index"}=i.iterator||{};n=new Set([a,c,...Array.from(n)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],c=a.length?a:[`scope_${s?.id}`];n=new Set([...c,...Array.from(n)])}this.context[e.id]=n}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&(this.style[`.${e.name}_${e.id}`]=e.props.style)}walkNodes(e){const s=(r,i)=>{this.collectContext(r,i),this.collectStyle(r),Array.isArray(r.children)&&r.children.forEach(n=>s(n,r))};Array.isArray(e.nodes)&&e.nodes.forEach(r=>s(r))}}function se(t={}){return Object.entries(t).map(([e,s])=>{const r=u(s,!1);return`${e}:${r}`})}function re(t=[]){return t.map(e=>`${e.name}: {
14
14
  from: '${e.from||e.name}',
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.7.29
11
+ * @version 0.7.31
12
12
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
13
13
  */
14
- const Pt = "0.7.29";
14
+ const Pt = "0.7.31";
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.7.29
19
+ * @version 0.7.31
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
22
  const Y = [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/coder",
3
3
  "private": false,
4
- "version": "0.7.29",
4
+ "version": "0.7.31",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "vue-tsc && vite build",
@@ -10,12 +10,12 @@
10
10
  "coverage": "vitest run --coverage"
11
11
  },
12
12
  "dependencies": {
13
- "@vtj/base": "^0.7.7",
14
- "@vtj/core": "^0.7.29",
13
+ "@vtj/base": "^0.7.8",
14
+ "@vtj/core": "^0.7.31",
15
15
  "prettier": "~3.2.1"
16
16
  },
17
17
  "devDependencies": {
18
- "@vtj/cli": "^0.7.19"
18
+ "@vtj/cli": "^0.7.21"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
@@ -31,7 +31,7 @@
31
31
  "dist",
32
32
  "types"
33
33
  ],
34
- "gitHead": "051c91898082b0e954af310f9cfcd794a2cb84c2",
34
+ "gitHead": "eec8b5817a66b57a3d068eae6a9912a9b199346e",
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  }
@@ -1,4 +1,5 @@
1
- import { type BlockSchema, type Dependencie } from '@vtj/core';
1
+ import { BlockSchema, Dependencie } from '@vtj/core';
2
+
2
3
  export declare class Collecter {
3
4
  dsl: BlockSchema;
4
5
  dependencies: Dependencie[];
@@ -1,4 +1,5 @@
1
- import { type BlockSchema, type MaterialDescription, type Dependencie, type PageFile } from '@vtj/core';
1
+ import { BlockSchema, MaterialDescription, Dependencie, PageFile } from '@vtj/core';
2
+
2
3
  /**
3
4
  * 代码生成器 处理过程:
4
5
  * 1. Generator 读取 dsl、componentMap、dependencies
@@ -1,2 +1,3 @@
1
- import { type DataSourceSchema } from '@vtj/core';
1
+ import { DataSourceSchema } from '@vtj/core';
2
+
2
3
  export declare function parseDataSources(dataSources?: Record<string, DataSourceSchema>): string[];
@@ -1,2 +1,3 @@
1
- import { type JSFunction } from '@vtj/core';
1
+ import { JSFunction } from '@vtj/core';
2
+
2
3
  export declare function parseFunctionMap(map?: Record<string, JSFunction>, computedKeys?: string[]): string[];
@@ -1,2 +1,3 @@
1
- import { type MaterialDescription } from '@vtj/core';
1
+ import { MaterialDescription } from '@vtj/core';
2
+
2
3
  export declare function parseImports(componentMap: Map<string, MaterialDescription>, components?: string[], importBlocks?: string[], collectImports?: Record<string, Set<string>>): string[];
@@ -1,5 +1,6 @@
1
- import { type MaterialDescription } from '@vtj/core';
2
1
  import { Collecter } from '../collecter';
2
+ import { MaterialDescription } from '@vtj/core';
3
+
3
4
  export interface Token {
4
5
  id: string;
5
6
  version: string;
@@ -1,2 +1,3 @@
1
- import { type BlockInject } from '@vtj/core';
1
+ import { BlockInject } from '@vtj/core';
2
+
2
3
  export declare function parseInject(inject?: BlockInject[]): string[];
@@ -1,2 +1,3 @@
1
- import { type BlockProp } from '@vtj/core';
1
+ import { BlockProp } from '@vtj/core';
2
+
2
3
  export declare function parseProps(props?: Array<string | BlockProp>): string[];
@@ -1,2 +1,3 @@
1
- import { type BlockState } from '@vtj/core';
1
+ import { BlockState } from '@vtj/core';
2
+
2
3
  export declare function parseState(state?: BlockState): string[];
@@ -1,4 +1,5 @@
1
- import { type NodeSchema, type MaterialDescription, type JSFunction } from '@vtj/core';
1
+ import { NodeSchema, MaterialDescription, JSFunction } from '@vtj/core';
2
+
2
3
  export declare function parseTemplate(children: NodeSchema[], componentMap: Map<string, MaterialDescription>, computedKeys?: string[], context?: Record<string, Set<string>>, parent?: NodeSchema): {
3
4
  nodes: string[];
4
5
  methods: Record<string, JSFunction>;
@@ -1,4 +1,5 @@
1
- import { type BlockWatch } from '@vtj/core';
1
+ import { BlockWatch } from '@vtj/core';
2
+
2
3
  export declare function parseWatch(watch?: BlockWatch[], computedKeys?: string[]): {
3
4
  computed: string[];
4
5
  watches: string[];
package/types/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type JSExpression, type JSFunction } from '@vtj/core';
1
+ import { JSExpression, JSFunction } from '@vtj/core';
2
+
2
3
  export declare function isJSExpression(data: any): data is JSExpression;
3
4
  export declare function isJSFunction(x: any): x is JSFunction;
4
5
  export declare function isJSCode(data: unknown): data is JSExpression | JSFunction;
@@ -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.28
5
+ * @version 0.7.30
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.7.28";
8
+ export declare const version = "0.7.30";