@vtj/coder 0.16.10 → 0.16.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 +8 -8
- package/dist/index.mjs +72 -70
- package/package.json +2 -2
- package/types/utils.d.ts +1 -1
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
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.16.
|
|
5
|
+
* @version 0.16.12
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const re="0.16.
|
|
7
|
+
*/const re="0.16.12";/**!
|
|
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.16.
|
|
11
|
+
* @version 0.16.12
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
|
-
*/const ie=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const T={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 B(t,e){return e?t:await D.format(t,{parser:"vue",...T,plugins:[ne,q,U,M]})}async function V(t,e){if(e)return t;try{return(await D.format(t,{parser:"babel-ts",...T,plugins:[q,U]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function F(t,e){return e?t:D.format(t,{parser:"scss",...T,plugins:[M]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function L(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[]){let
|
|
13
|
+
*/const ie=["slot","template","component","img","div","p","h1","h2","h3","span","a"];f.mitt();const T={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 B(t,e){return e?t:await D.format(t,{parser:"vue",...T,plugins:[ne,q,U,M]})}async function V(t,e){if(e)return t;try{return(await D.format(t,{parser:"babel-ts",...T,plugins:[q,U]})).replace(/;\n$/gi,"")}catch(s){return console.warn(s),t}}async function F(t,e){return e?t:D.format(t,{parser:"scss",...T,plugins:[M]})}function k(t){return t&&t.type==="JSExpression"}function I(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function j(t){return k(t)||I(t)}function H(t){return t.replace(new RegExp("this.","g"),"")}function L(t){return t.replace(/this\.context\??\./g,"")}function d(t,e=!0,s=!0,n=[],i=!0){let r=t;return j(t)?(r=t.value.trim().replace(/;$/,""),i&&(r=r.replace(/\"/g,"'"))):r=e?JSON.stringify(r):t,r=w(r,n),s?H(L(r)):L(r)}function w(t="",e=[]){let s=t;for(const n of e)s=s.replace(new RegExp(`this.${n}.value`,"g"),`this.${n}`);return s}function Q(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 i=/^(async\s)?\([\w]*\)\s+\=\>\s([\w\W]+)/,r=e.match(i);r&&r[2]&&(r[2].startsWith("{")||(e=e.replace(r[2],`{ return ${r[2]} }`))),e=e.replace("=>","")}return e}function oe(t={}){return Object.entries(t).map(([e,s])=>`"${e}": ${d(s)}`)}function z(t={},e=!1){const s=Object.keys(t);return e?s.map(n=>"."+n):s}function ae(t){let e="";for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];e+=s+": "+n+";"}return e}function ce(t=[],e=[]){return t.filter(s=>!e.includes(s))}function R(t){return f.base64(JSON.stringify(t))}class le{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=[];urlSchemas={};blockPlugins={};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 n=s.pop(),i=s.join(".")+".",r=s.pop();if(n&&r){const o=this.dependencies.find(a=>a.library===r)?.package;o&&(this.imports[o]||(this.imports[o]=new Set)).add(n)}return{name:n,path:i,library:r}}return null}replaceLibraryPath(e){const{libraryRegex:s}=this;let n=e.value;for(const i of s){const r=e.value?.match(i)||[];for(const o of r){const a=this.collectImport(o);if(a){const m=a.path.replace(/\$/g,"\\$");n=n.replace(new RegExp(m,"g"),"")}}}return n}walk(e){const s=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(let r of n)s(r);return}const i=Object.values(n);for(const r of i)j(r)?r.value=this.replaceLibraryPath(r):s(r)};s(e)}getLibraryMember(e=[]){let s=[...e];const n={...this.imports};delete n["uni-h5"],delete n["@dcloudio/uni-h5"],delete n["uni-ui"],delete n["@dcloudio/uni-ui"];for(const i of Object.values(n))s=s.concat(Array.from(i));return f.dedupArray(s)}collectContext(e,s){const n=new Set(s?.id?this.context[s.id]:[]),i=(e.directives||[]).find(a=>a.name==="vFor");let r=new Set(Array.from(n));if(i){const{item:a="item",index:m="index"}=i.iterator||{};r=new Set([a,m,...Array.from(r)])}const o=e.slot;if(o){const a=typeof o=="string"?[]:o.params||[],m=a.length?a:[`scope_${s?.id}`];r=new Set([...m,...Array.from(r)])}this.context[e.id]=r}collectStyle(e){e.id&&e.props?.style&&Object.keys(e.props.style).length&&!j(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=(n,i)=>{this.collectContext(n,i),this.collectStyle(n),this.collectUrlSchema(n),this.collectBlockPlugin(n),Array.isArray(n.children)&&n.children.forEach(r=>s(r,n))};Array.isArray(e.nodes)&&e.nodes.forEach(n=>s(n))}}function ue(t={}){return Object.entries(t).map(([e,s])=>{const n=d(s,!1,!0,[],!1);return`${e}:${n}`})}function pe(t=[]){return t.map(e=>`${e.name}: {
|
|
14
14
|
from: '${e.from||e.name}',
|
|
15
|
-
default: ${d(e.default,!0,!1)}
|
|
15
|
+
default: ${d(e.default,!0,!1,[],!1)}
|
|
16
16
|
}`)}function fe(t=[]){const e=s=>s?`[${f.toArray(s).map(r=>r.replace(/\'|\"/gi,"")).join(",")}]`:void 0;return t.map(s=>typeof s=="string"?`${s}: {}`:(j(s.default)&&!s.default.value&&(s.default.value="undefined"),`${s.name}: {
|
|
17
17
|
type:${e(s.type)},
|
|
18
|
-
required: ${d(!!s.required,!0,!1)},
|
|
19
|
-
default: ${s.default?d(s.default,!0,!1):"undefined"}
|
|
20
|
-
}`))}function me(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([s,n])=>{let i=Q(d(n,!1,!1));return i=w(i,e)?.trim(),i.startsWith("async")?`async ${s}${i.replace(/^async/,"")}`:i.startsWith("(")||i.startsWith("{")?`${s}${i}`:null}).filter(s=>!!s)}function he(t=[],e=[]){const s=t.reduce((r,o)=>(o.id&&I(o.source)&&(r[`watcher_${o.id}`]=o.source),r),{}),n=A(s,e),i=t.map(r=>r.handler&&r.handler.value?`watcher_${r.id}: {
|
|
18
|
+
required: ${d(!!s.required,!0,!1,[],!1)},
|
|
19
|
+
default: ${s.default?d(s.default,!0,!1,[],!1):"undefined"}
|
|
20
|
+
}`))}function me(t=[]){return t.map(e=>`'${typeof e=="string"?e:e.name}'`)}function A(t={},e=[]){return Object.entries(t).map(([s,n])=>{let i=Q(d(n,!1,!1,[],!1));return i=w(i,e)?.trim(),i.startsWith("async")?`async ${s}${i.replace(/^async/,"")}`:i.startsWith("(")||i.startsWith("{")?`${s}${i}`:null}).filter(s=>!!s)}function he(t=[],e=[]){const s=t.reduce((r,o)=>(o.id&&I(o.source)&&(r[`watcher_${o.id}`]=o.source),r),{}),n=A(s,e),i=t.map(r=>r.handler&&r.handler.value?`watcher_${r.id}: {
|
|
21
21
|
deep: ${r.deep},
|
|
22
22
|
immediate:${r.immediate},
|
|
23
23
|
handler${Q(r.handler.value)}
|
package/dist/index.mjs
CHANGED
|
@@ -8,15 +8,15 @@ import * as H 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.16.
|
|
11
|
+
* @version 0.16.12
|
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
13
13
|
*/
|
|
14
|
-
const Ue = "0.16.
|
|
14
|
+
const Ue = "0.16.12";
|
|
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.16.
|
|
19
|
+
* @version 0.16.12
|
|
20
20
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
21
21
|
*/
|
|
22
22
|
const oe = [
|
|
@@ -60,7 +60,7 @@ async function q(t, e) {
|
|
|
60
60
|
plugins: [ie, M, H, V]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
async function
|
|
63
|
+
async function ae(t, e) {
|
|
64
64
|
if (e) return t;
|
|
65
65
|
try {
|
|
66
66
|
return (await B(t, {
|
|
@@ -94,9 +94,9 @@ function Q(t) {
|
|
|
94
94
|
function L(t) {
|
|
95
95
|
return t.replace(/this\.context\??\./g, "");
|
|
96
96
|
}
|
|
97
|
-
function h(t, e = !0, s = !0, n = []) {
|
|
98
|
-
let
|
|
99
|
-
return i = w(
|
|
97
|
+
function h(t, e = !0, s = !0, n = [], i = !0) {
|
|
98
|
+
let r = t;
|
|
99
|
+
return j(t) ? (r = t.value.trim().replace(/;$/, ""), i && (r = r.replace(/\"/g, "'"))) : r = e ? JSON.stringify(r) : t, r = w(r, n), s ? Q(L(r)) : L(r);
|
|
100
100
|
}
|
|
101
101
|
function w(t = "", e = []) {
|
|
102
102
|
let s = t;
|
|
@@ -120,7 +120,7 @@ function G(t) {
|
|
|
120
120
|
}
|
|
121
121
|
return e;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function ce(t = {}) {
|
|
124
124
|
return Object.entries(t).map(([e, s]) => `"${e}": ${h(s)}`);
|
|
125
125
|
}
|
|
126
126
|
function Z(t = {}, e = !1) {
|
|
@@ -170,7 +170,7 @@ class pe {
|
|
|
170
170
|
const n = s.pop(), i = s.join(".") + ".", r = s.pop();
|
|
171
171
|
if (n && r) {
|
|
172
172
|
const o = this.dependencies.find(
|
|
173
|
-
(
|
|
173
|
+
(a) => a.library === r
|
|
174
174
|
)?.package;
|
|
175
175
|
o && (this.imports[o] || (this.imports[o] = /* @__PURE__ */ new Set())).add(n);
|
|
176
176
|
}
|
|
@@ -189,9 +189,9 @@ class pe {
|
|
|
189
189
|
for (const i of s) {
|
|
190
190
|
const r = e.value?.match(i) || [];
|
|
191
191
|
for (const o of r) {
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
const f =
|
|
192
|
+
const a = this.collectImport(o);
|
|
193
|
+
if (a) {
|
|
194
|
+
const f = a.path.replace(/\$/g, "\\$");
|
|
195
195
|
n = n.replace(new RegExp(f, "g"), "");
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -221,15 +221,15 @@ class pe {
|
|
|
221
221
|
return x(s);
|
|
222
222
|
}
|
|
223
223
|
collectContext(e, s) {
|
|
224
|
-
const n = new Set(s?.id ? this.context[s.id] : []), i = (e.directives || []).find((
|
|
224
|
+
const n = new Set(s?.id ? this.context[s.id] : []), i = (e.directives || []).find((a) => a.name === "vFor");
|
|
225
225
|
let r = new Set(Array.from(n));
|
|
226
226
|
if (i) {
|
|
227
|
-
const { item:
|
|
228
|
-
r = /* @__PURE__ */ new Set([
|
|
227
|
+
const { item: a = "item", index: f = "index" } = i.iterator || {};
|
|
228
|
+
r = /* @__PURE__ */ new Set([a, f, ...Array.from(r)]);
|
|
229
229
|
}
|
|
230
230
|
const o = e.slot;
|
|
231
231
|
if (o) {
|
|
232
|
-
const
|
|
232
|
+
const a = typeof o == "string" ? [] : o.params || [], f = a.length ? a : [`scope_${s?.id}`];
|
|
233
233
|
r = /* @__PURE__ */ new Set([...f, ...Array.from(r)]);
|
|
234
234
|
}
|
|
235
235
|
this.context[e.id] = r;
|
|
@@ -252,22 +252,22 @@ class pe {
|
|
|
252
252
|
}
|
|
253
253
|
function fe(t = {}) {
|
|
254
254
|
return Object.entries(t).map(([e, s]) => {
|
|
255
|
-
const n = h(s, !1);
|
|
255
|
+
const n = h(s, !1, !0, [], !1);
|
|
256
256
|
return `${e}:${n}`;
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
function me(t = []) {
|
|
260
260
|
return t.map((e) => `${e.name}: {
|
|
261
261
|
from: '${e.from || e.name}',
|
|
262
|
-
default: ${h(e.default, !0, !1)}
|
|
262
|
+
default: ${h(e.default, !0, !1, [], !1)}
|
|
263
263
|
}`);
|
|
264
264
|
}
|
|
265
265
|
function he(t = []) {
|
|
266
266
|
const e = (s) => s ? `[${se(s).map((r) => r.replace(/\'|\"/gi, "")).join(",")}]` : void 0;
|
|
267
267
|
return t.map((s) => typeof s == "string" ? `${s}: {}` : (j(s.default) && !s.default.value && (s.default.value = "undefined"), `${s.name}: {
|
|
268
268
|
type:${e(s.type)},
|
|
269
|
-
required: ${h(!!s.required, !0, !1)},
|
|
270
|
-
default: ${s.default ? h(s.default, !0, !1) : "undefined"}
|
|
269
|
+
required: ${h(!!s.required, !0, !1, [], !1)},
|
|
270
|
+
default: ${s.default ? h(s.default, !0, !1, [], !1) : "undefined"}
|
|
271
271
|
}`));
|
|
272
272
|
}
|
|
273
273
|
function de(t = []) {
|
|
@@ -275,7 +275,9 @@ function de(t = []) {
|
|
|
275
275
|
}
|
|
276
276
|
function A(t = {}, e = []) {
|
|
277
277
|
return Object.entries(t).map(([s, n]) => {
|
|
278
|
-
let i = G(
|
|
278
|
+
let i = G(
|
|
279
|
+
h(n, !1, !1, [], !1)
|
|
280
|
+
);
|
|
279
281
|
return i = w(i, e)?.trim(), i.startsWith("async") ? `async ${s}${i.replace(/^async/, "")}` : i.startsWith("(") || i.startsWith("{") ? `${s}${i}` : null;
|
|
280
282
|
}).filter((s) => !!s);
|
|
281
283
|
}
|
|
@@ -338,17 +340,17 @@ const $e = [
|
|
|
338
340
|
];
|
|
339
341
|
function z(t, e, s = [], n = {}, i) {
|
|
340
342
|
const r = [];
|
|
341
|
-
let o = {},
|
|
343
|
+
let o = {}, a = [];
|
|
342
344
|
const f = [];
|
|
343
345
|
let u = [];
|
|
344
|
-
return be(t).forEach((
|
|
346
|
+
return be(t).forEach((c) => {
|
|
345
347
|
const y = [];
|
|
346
|
-
for (const m of
|
|
348
|
+
for (const m of c.children) {
|
|
347
349
|
let { id: d, name: $, invisible: v, from: g } = m;
|
|
348
350
|
if (v)
|
|
349
351
|
continue;
|
|
350
352
|
const O = je($, e, g);
|
|
351
|
-
O &&
|
|
353
|
+
O && a.push(O), X(g) && u.push({ id: g.id, name: $ });
|
|
352
354
|
const { props: C, events: E, handlers: P } = Oe(
|
|
353
355
|
m,
|
|
354
356
|
d,
|
|
@@ -370,7 +372,7 @@ function z(t, e, s = [], n = {}, i) {
|
|
|
370
372
|
Object.assign(o, P);
|
|
371
373
|
let _ = "";
|
|
372
374
|
typeof S == "string" ? _ = S : (_ = (S?.nodes || []).join(`
|
|
373
|
-
`), Object.assign(o, S?.methods || {}),
|
|
375
|
+
`), Object.assign(o, S?.methods || {}), a = a.concat(S?.components || []), u = u.concat(S?.importBlocks || []));
|
|
374
376
|
const I = ["@dcloudio/uni-h5", "@dcloudio/uni-ui"].includes(
|
|
375
377
|
g || e.get($)?.package
|
|
376
378
|
) ? F($) : Y(g) || K(g) ? "component" : $;
|
|
@@ -379,14 +381,14 @@ function z(t, e, s = [], n = {}, i) {
|
|
|
379
381
|
` + _.trim() : ""}</${I}>`
|
|
380
382
|
);
|
|
381
383
|
}
|
|
382
|
-
const p = _e(
|
|
384
|
+
const p = _e(c.slot, y.join(`
|
|
383
385
|
`), i?.id);
|
|
384
386
|
r.push(p);
|
|
385
387
|
}), {
|
|
386
388
|
nodes: r,
|
|
387
389
|
methods: o,
|
|
388
390
|
directives: ve(f),
|
|
389
|
-
components: x(
|
|
391
|
+
components: x(a),
|
|
390
392
|
importBlocks: x(u, "id")
|
|
391
393
|
};
|
|
392
394
|
}
|
|
@@ -429,7 +431,7 @@ function Se(t, e, s = []) {
|
|
|
429
431
|
})}"` : typeof e == "string" ? `${t}="${e}"` : j(e) ? `:${t}="${h({
|
|
430
432
|
...e,
|
|
431
433
|
value: w(e.value, s)
|
|
432
|
-
})}"` : ne(e) ? `:${t}='{${
|
|
434
|
+
})}"` : ne(e) ? `:${t}='{${ce(
|
|
433
435
|
e
|
|
434
436
|
).join(", ")}}'` : `:${t}='${JSON.stringify(e)}'`;
|
|
435
437
|
}
|
|
@@ -451,23 +453,23 @@ function we(t, e, s, n, i) {
|
|
|
451
453
|
function xe(t, e = {}, s = {}) {
|
|
452
454
|
const n = {}, i = Array.from(s[t] || /* @__PURE__ */ new Set([])), r = i.length ? `({${i.join(", ")}}, args)` : "";
|
|
453
455
|
return {
|
|
454
|
-
binders: Object.entries(e).map(([
|
|
455
|
-
const u = f.handler.value.startsWith("this."), l = u ? Q(f.handler.value) : `${b(
|
|
456
|
+
binders: Object.entries(e).map(([a, f]) => {
|
|
457
|
+
const u = f.handler.value.startsWith("this."), l = u ? Q(f.handler.value) : `${b(a)}_${t}${r}`;
|
|
456
458
|
return u || (n[l] = i.length ? {
|
|
457
459
|
type: "JSFunction",
|
|
458
460
|
value: `{
|
|
459
461
|
return (${f.handler.value}).apply(this, args);
|
|
460
462
|
}`
|
|
461
|
-
} : f.handler), we(
|
|
463
|
+
} : f.handler), we(a, f, l, i, u);
|
|
462
464
|
}),
|
|
463
465
|
handlers: n
|
|
464
466
|
};
|
|
465
467
|
}
|
|
466
468
|
function Oe(t, e, s = {}, n = {}, i = {}, r) {
|
|
467
|
-
const { binders: o, handlers:
|
|
469
|
+
const { binders: o, handlers: a } = xe(e, n, i);
|
|
468
470
|
return {
|
|
469
471
|
props: ke(t, s, r).join(" "),
|
|
470
|
-
handlers:
|
|
472
|
+
handlers: a,
|
|
471
473
|
binders: o,
|
|
472
474
|
events: o.join(" ")
|
|
473
475
|
};
|
|
@@ -477,17 +479,17 @@ function Ce(t = [], e = [], s = []) {
|
|
|
477
479
|
vIf: i,
|
|
478
480
|
vElse: r,
|
|
479
481
|
vElseIf: o,
|
|
480
|
-
vShow:
|
|
482
|
+
vShow: a,
|
|
481
483
|
vModels: f,
|
|
482
484
|
vFor: u,
|
|
483
485
|
vBind: l,
|
|
484
|
-
vHtml:
|
|
486
|
+
vHtml: c,
|
|
485
487
|
customDirectives: y
|
|
486
488
|
} = Ee(t);
|
|
487
489
|
if (i && n.push(`v-if="${h(i.value, !0, !0, e)}"`), o && n.push(
|
|
488
490
|
`v-else-if="${h(o.value, !0, !0, e)}"`
|
|
489
|
-
), r && n.push("v-else"),
|
|
490
|
-
`v-show="${h(
|
|
491
|
+
), r && n.push("v-else"), a && n.push(
|
|
492
|
+
`v-show="${h(a.value, !0, !0, e)}"`
|
|
491
493
|
), l && n.push(
|
|
492
494
|
`v-bind="${h(l.value, !0, !0, e)}"`
|
|
493
495
|
), f.forEach((p) => {
|
|
@@ -501,8 +503,8 @@ function Ce(t = [], e = [], s = []) {
|
|
|
501
503
|
`v-for="(${p}, ${m}) in ${h(u.value, !0, !0, e)}"`
|
|
502
504
|
);
|
|
503
505
|
}
|
|
504
|
-
return
|
|
505
|
-
`v-html="${h(
|
|
506
|
+
return c && n.push(
|
|
507
|
+
`v-html="${h(c.value, !0, !0, e)}"`
|
|
506
508
|
), y && y.length && y.forEach((p) => {
|
|
507
509
|
if (!p.name) return;
|
|
508
510
|
let m = "", d = "";
|
|
@@ -519,32 +521,32 @@ function Ce(t = [], e = [], s = []) {
|
|
|
519
521
|
}
|
|
520
522
|
function Ee(t = []) {
|
|
521
523
|
const e = t.filter(
|
|
522
|
-
(
|
|
524
|
+
(c) => J.includes(c.name)
|
|
523
525
|
), s = t.filter(
|
|
524
|
-
(
|
|
526
|
+
(c) => !J.includes(c.name)
|
|
525
527
|
), n = e.find(
|
|
526
|
-
(
|
|
528
|
+
(c) => b(c.name) === "vIf"
|
|
527
529
|
), i = e.find(
|
|
528
|
-
(
|
|
530
|
+
(c) => b(c.name) === "vElseIf"
|
|
529
531
|
), r = e.find(
|
|
530
|
-
(
|
|
532
|
+
(c) => b(c.name) === "vElse"
|
|
531
533
|
), o = e.find(
|
|
532
|
-
(
|
|
533
|
-
),
|
|
534
|
-
(
|
|
534
|
+
(c) => b(c.name) === "vFor"
|
|
535
|
+
), a = e.find(
|
|
536
|
+
(c) => b(c.name) === "vShow"
|
|
535
537
|
), f = e.find(
|
|
536
|
-
(
|
|
538
|
+
(c) => b(c.name) === "vBind"
|
|
537
539
|
), u = e.find(
|
|
538
|
-
(
|
|
540
|
+
(c) => b(c.name) === "vHtml"
|
|
539
541
|
), l = e.filter(
|
|
540
|
-
(
|
|
542
|
+
(c) => b(c.name) === "vModel"
|
|
541
543
|
);
|
|
542
544
|
return {
|
|
543
545
|
vIf: n,
|
|
544
546
|
vElseIf: i,
|
|
545
547
|
vElse: r,
|
|
546
548
|
vFor: o,
|
|
547
|
-
vShow:
|
|
549
|
+
vShow: a,
|
|
548
550
|
vModels: l,
|
|
549
551
|
vBind: f,
|
|
550
552
|
vHtml: u,
|
|
@@ -569,21 +571,21 @@ function Ie(t, e = [], s = [], n = {}, i = "web") {
|
|
|
569
571
|
"uni-ui"
|
|
570
572
|
], o = {
|
|
571
573
|
vue: ["defineComponent", "reactive"]
|
|
572
|
-
},
|
|
574
|
+
}, a = [];
|
|
573
575
|
for (const u of e) {
|
|
574
576
|
const l = t.get(u.split(":")[0]);
|
|
575
577
|
if (l && l.package) {
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
+
const c = o[l.package] ?? (o[l.package] = []), y = l.parent || (l.alias || "").split(".")[0] || l.name;
|
|
579
|
+
c.push(y), i === "uniapp" && r.includes(l.package) && a.push(y);
|
|
578
580
|
}
|
|
579
581
|
}
|
|
580
582
|
for (const [u, l] of Object.entries(n))
|
|
581
|
-
(o[u] ?? (o[u] = [])).push(...Array.from(l)), i === "uniapp" && r.includes(u) &&
|
|
583
|
+
(o[u] ?? (o[u] = [])).push(...Array.from(l)), i === "uniapp" && r.includes(u) && a.push(...Array.from(l));
|
|
582
584
|
return {
|
|
583
585
|
imports: Object.entries(o).filter(([u, l]) => i === "uniapp" ? !r.includes(u) && !!l.length : !!l.length).map(([u, l]) => `import { ${x(l).join(
|
|
584
586
|
","
|
|
585
587
|
)}} from '${u}';`).concat(s),
|
|
586
|
-
uniComponents:
|
|
588
|
+
uniComponents: a
|
|
587
589
|
};
|
|
588
590
|
}
|
|
589
591
|
function Ae(t = {}) {
|
|
@@ -614,12 +616,12 @@ function Fe(t = {}) {
|
|
|
614
616
|
}), e;
|
|
615
617
|
}
|
|
616
618
|
function Be(t, e, s = "web") {
|
|
617
|
-
const { dsl: n } = t, i = Object.keys(n.computed || {}), r = A(n.lifeCycles, i), o = A(n.computed, i),
|
|
619
|
+
const { dsl: n } = t, i = Object.keys(n.computed || {}), r = A(n.lifeCycles, i), o = A(n.computed, i), a = ge(n.watch, i), f = ye(n.dataSources), { methods: u, nodes: l, components: c, importBlocks: y, directives: p } = z(
|
|
618
620
|
n.nodes || [],
|
|
619
621
|
e,
|
|
620
622
|
i,
|
|
621
623
|
t.context
|
|
622
|
-
), m = [...o, ...
|
|
624
|
+
), m = [...o, ...a.computed], d = A(
|
|
623
625
|
{
|
|
624
626
|
...u,
|
|
625
627
|
...n.methods || {}
|
|
@@ -628,7 +630,7 @@ function Be(t, e, s = "web") {
|
|
|
628
630
|
), $ = y.map((P) => `import ${P.name} from './${P.id}.vue';`);
|
|
629
631
|
let { imports: v, uniComponents: g } = Ie(
|
|
630
632
|
e,
|
|
631
|
-
|
|
633
|
+
c,
|
|
632
634
|
$,
|
|
633
635
|
t.imports,
|
|
634
636
|
s
|
|
@@ -646,14 +648,14 @@ function Be(t, e, s = "web") {
|
|
|
646
648
|
props: he(n.props).join(","),
|
|
647
649
|
emits: de(n.emits).join(","),
|
|
648
650
|
expose: n.expose && n.expose.length ? JSON.stringify(n.expose || []) : "",
|
|
649
|
-
watch:
|
|
651
|
+
watch: a.watches.join(","),
|
|
650
652
|
lifeCycles: r.join(","),
|
|
651
653
|
computed: m.join(","),
|
|
652
654
|
methods: [...f, ...d].join(","),
|
|
653
655
|
imports: `
|
|
654
656
|
` + v.join(`
|
|
655
657
|
`),
|
|
656
|
-
components: ue(
|
|
658
|
+
components: ue(c, g).join(","),
|
|
657
659
|
directives: p.join(","),
|
|
658
660
|
returns: t.members.join(","),
|
|
659
661
|
template: l.join(`
|
|
@@ -722,26 +724,26 @@ async function Me(t, e = /* @__PURE__ */ new Map(), s = [], n = "web", i) {
|
|
|
722
724
|
platform: n,
|
|
723
725
|
formatterDisabled: i
|
|
724
726
|
}, {
|
|
725
|
-
dsl:
|
|
727
|
+
dsl: a,
|
|
726
728
|
componentMap: f = /* @__PURE__ */ new Map(),
|
|
727
729
|
dependencies: u = [],
|
|
728
730
|
platform: l = "web",
|
|
729
|
-
formatterDisabled:
|
|
731
|
+
formatterDisabled: c = !1,
|
|
730
732
|
ts: y = !0,
|
|
731
733
|
scss: p = !1
|
|
732
|
-
} = o, m = new pe(re(
|
|
734
|
+
} = o, m = new pe(re(a), u), d = Be(m, f, l), $ = Te(d), v = Le({
|
|
733
735
|
template: d.template || `
|
|
734
736
|
<!--组件模版内容-->
|
|
735
737
|
`,
|
|
736
|
-
css: await T(d.css,
|
|
738
|
+
css: await T(d.css, c) || `
|
|
737
739
|
/* 组件样式内容 */
|
|
738
740
|
`,
|
|
739
|
-
script: await
|
|
740
|
-
style: await T(d.style,
|
|
741
|
+
script: await ae($, c),
|
|
742
|
+
style: await T(d.style, c),
|
|
741
743
|
scriptLang: y ? "ts" : "js",
|
|
742
744
|
styleLang: p ? "scss" : "css"
|
|
743
745
|
});
|
|
744
|
-
return await q(v,
|
|
746
|
+
return await q(v, c).catch((g) => (g.content = v, Promise.reject(g)));
|
|
745
747
|
}
|
|
746
748
|
async function Ve(t) {
|
|
747
749
|
const e = `
|
|
@@ -763,6 +765,6 @@ export {
|
|
|
763
765
|
Ve as createEmptyPage,
|
|
764
766
|
T as cssFormatter,
|
|
765
767
|
Me as generator,
|
|
766
|
-
|
|
768
|
+
ae as tsFormatter,
|
|
767
769
|
q as vueFormatter
|
|
768
770
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/coder",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.12",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"prettier": "~3.7.0",
|
|
25
25
|
"@vtj/base": "~0.12.4",
|
|
26
|
-
"@vtj/core": "~0.16.
|
|
26
|
+
"@vtj/core": "~0.16.12"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@vtj/cli": "~0.12.18"
|
package/types/utils.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function isJSCode(data: unknown): data is JSExpression | JSFuncti
|
|
|
7
7
|
export declare function JSCodeToString(data: unknown): string;
|
|
8
8
|
export declare function replaceThis(content: string): string;
|
|
9
9
|
export declare function replaceContext(content: string): string;
|
|
10
|
-
export declare function parseValue(val: unknown, stringify?: boolean, noThis?: boolean, computedKeys?: string[]): string;
|
|
10
|
+
export declare function parseValue(val: unknown, stringify?: boolean, noThis?: boolean, computedKeys?: string[], quote?: boolean): string;
|
|
11
11
|
export declare function replaceComputedValue(content?: string, keys?: string[]): string;
|
|
12
12
|
export declare function replaceFunctionTag(content: string): string;
|
|
13
13
|
export declare function parsePlainObjectValue(obj?: Record<string, any>): 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.16.
|
|
5
|
+
* @version 0.16.11
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.16.
|
|
8
|
+
export declare const version = "0.16.11";
|