@fangzhongya/vue-archive 0.1.2 → 0.1.4
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.css +1 -1
- package/dist/node/index.cjs +104 -19
- package/dist/node/index.js +104 -19
- package/dist/node_modules/.pnpm/highlight.js@11.11.1/node_modules/highlight.js/lib/core.js +1 -1
- package/dist/packages/components/use/code.cjs +5 -5
- package/dist/packages/components/use/code.d.ts +25 -18
- package/dist/packages/components/use/code.js +25 -26
- package/dist/packages/components/use/retrie/input/editor/editor.d.ts +0 -49
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.d.ts +1 -0
- package/dist/packages/components/use/util.js +166 -79
- package/package.json +11 -11
|
@@ -1,48 +1,47 @@
|
|
|
1
1
|
import "@fangzhongya/utils/basic/object/mergeObject";
|
|
2
2
|
import "@fangzhongya/utils/basic/array/toggleArray";
|
|
3
|
-
import { humpToLine as
|
|
3
|
+
import { humpToLine as W } from "@fangzhongya/utils/name/humpToLine";
|
|
4
4
|
import "@fangzhongya/utils/name/lineToLargeHump";
|
|
5
5
|
import "@fangzhongya/utils/basic/string/appearNum";
|
|
6
|
-
import { firstLower as
|
|
6
|
+
import { firstLower as Z } from "@fangzhongya/utils/basic/string/firstLower";
|
|
7
7
|
import "@fangzhongya/utils/basic/array/duplicateRemoval";
|
|
8
8
|
import "@fangzhongya/utils/basic/array/asyncMergeArray";
|
|
9
9
|
import { firstUpper as z } from "@fangzhongya/utils/basic/string/firstUpper";
|
|
10
10
|
import "@fangzhongya/utils/urls/getSuffix";
|
|
11
11
|
import "@fangzhongya/utils/basic/array/replaceAfter";
|
|
12
|
-
import { getTypeValue as E, getDataTypeType as F, parseParamString as j, prettierHtml as
|
|
13
|
-
import { getPropsValue as
|
|
14
|
-
import { getFunctionFormat as
|
|
15
|
-
const tt = ["class"];
|
|
12
|
+
import { getTypeValue as E, getDataTypeType as F, parseParamString as j, prettierHtml as q, prettierTs as G, getDataType as I, parseTypeDefinition as K, setDataType as M, vueFormat as x, getFunBody as J, allReservedWords as Q } from "./util.js";
|
|
13
|
+
import { getPropsValue as X, getEmitsValue as Y, getExposeValue as _, getSlotValue as k } from "../../utils/props.js";
|
|
14
|
+
import { getFunctionFormat as tt } from "@fangzhongya/utils/basic/string/toFunction";
|
|
16
15
|
function T(t, n) {
|
|
17
16
|
return t.filter((e) => e.name == n)[0];
|
|
18
17
|
}
|
|
19
18
|
function L(t) {
|
|
20
|
-
return t.map((n) => (n.prop || "...arr") + ":" +
|
|
19
|
+
return t.map((n) => (n.prop || "...arr") + ":" + M(n.dataType)).join(",");
|
|
21
20
|
}
|
|
22
21
|
async function bt(t, n, e, s, i, $) {
|
|
23
22
|
const m = [], r = [];
|
|
24
23
|
let d = !0;
|
|
25
|
-
const
|
|
24
|
+
const v = X(n.propss || []), A = Y(n.emitss || []), C = _(n.exposes || []), R = k(n.slots || []);
|
|
26
25
|
Object.keys(e).forEach(async (o) => {
|
|
27
26
|
let c = e[o];
|
|
28
27
|
if (/^on[A-Z]/.test(o) && typeof c == "function") {
|
|
29
28
|
let u = o.substring(2);
|
|
30
29
|
const a = o.split(":");
|
|
31
30
|
let l;
|
|
32
|
-
if (a.length > 1 ? (l = a[0] + a.slice(1).map((p) => z(p)).join(""), u =
|
|
31
|
+
if (a.length > 1 ? (l = a[0] + a.slice(1).map((p) => z(p)).join(""), u = Z(u)) : (l = a[0], u = W(u)), a.includes("-")) {
|
|
33
32
|
let p = l.split("-");
|
|
34
33
|
p = p.map((h, V) => V != 0 ? z(h) : h), l = p.join("");
|
|
35
34
|
}
|
|
36
35
|
m.push(" @" + u + '="' + l + '"');
|
|
37
|
-
const f = T(
|
|
36
|
+
const f = T(A, u) || {}, y = f.selectable || "", b = j(y), g = L(b);
|
|
38
37
|
r.push(`// ${f.description} ${f.name}: (${f.selectable})`), r.push("function " + l + "(" + g + ") {"), b.forEach((p) => {
|
|
39
38
|
const h = p.name || "arr";
|
|
40
39
|
r.push(" console.log('" + p.label + "', " + h + ")");
|
|
41
40
|
}), r.push("}");
|
|
42
41
|
} else {
|
|
43
42
|
let u = o;
|
|
44
|
-
|
|
45
|
-
const a = T(
|
|
43
|
+
Q.includes(o) && (u = o + "1"), m.push(" :" + o + '="' + u + '"');
|
|
44
|
+
const a = T(v, o) || {}, l = N(a);
|
|
46
45
|
if (r.push(
|
|
47
46
|
`// ${a.description} ${a.name}: {${a.type}} (${a.selectable})`
|
|
48
47
|
), typeof c == "function" || l.dataType.length == 1 && l.type == "function" && c)
|
|
@@ -71,7 +70,7 @@ async function bt(t, n, e, s, i, $) {
|
|
|
71
70
|
});
|
|
72
71
|
const P = Object.values($ || {});
|
|
73
72
|
P.length > 0 && (d && (d = !1, r.unshift("import { ref } from 'vue';")), m.unshift(' ref="refDom"'), r.push("const refDom = ref()"), P.forEach((o) => {
|
|
74
|
-
const c = T(
|
|
73
|
+
const c = T(C, o.name) || {};
|
|
75
74
|
r.push(
|
|
76
75
|
`// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`
|
|
77
76
|
);
|
|
@@ -100,19 +99,19 @@ async function bt(t, n, e, s, i, $) {
|
|
|
100
99
|
)})`
|
|
101
100
|
) : r.push(`refDom.value?.${o.name}(${l.join(", ")})`), c.return && r.push(`console.log('${c.return}', ${u})`)) : (r.push(`const ${u} = refDom.value?.${o.name}`), r.push(`console.log('${c.type || c.name}', ${u})`));
|
|
102
101
|
})), m.length > 0 && m.unshift("");
|
|
103
|
-
const
|
|
102
|
+
const U = et(s, R);
|
|
104
103
|
let S = `<template>
|
|
105
104
|
<div>
|
|
106
105
|
<${t}${m.join(`
|
|
107
|
-
`)}>${
|
|
106
|
+
`)}>${U.join(`
|
|
108
107
|
`)}
|
|
109
108
|
</${t}>
|
|
110
109
|
</div>
|
|
111
110
|
</template>`;
|
|
112
|
-
S = await
|
|
111
|
+
S = await q(S);
|
|
113
112
|
let D = r.join(`
|
|
114
113
|
`);
|
|
115
|
-
return D = await
|
|
114
|
+
return D = await G(D), `<!--${t}-->
|
|
116
115
|
${S}
|
|
117
116
|
<script lang="ts" setup>
|
|
118
117
|
${D}
|
|
@@ -133,10 +132,10 @@ ${x($, " ")}
|
|
|
133
132
|
}
|
|
134
133
|
function B(t, n, e) {
|
|
135
134
|
const s = e ? e[n] : "";
|
|
136
|
-
return s && (s.includes("=>") || s.includes("function")) ? s :
|
|
135
|
+
return s && (s.includes("=>") || s.includes("function")) ? s : O(t.toString());
|
|
137
136
|
}
|
|
138
|
-
async function
|
|
139
|
-
const n =
|
|
137
|
+
async function O(t) {
|
|
138
|
+
const n = tt(t);
|
|
140
139
|
if (n) {
|
|
141
140
|
let e = `{
|
|
142
141
|
${x(J(n.body), " ")}
|
|
@@ -156,14 +155,14 @@ ${x(J(s), " ")}
|
|
|
156
155
|
}
|
|
157
156
|
function st(t) {
|
|
158
157
|
const n = t.trim();
|
|
159
|
-
return /^\(/.test(n) ?
|
|
158
|
+
return /^\(/.test(n) ? O(n) : JSON.stringify(t);
|
|
160
159
|
}
|
|
161
160
|
function H(t, n, e) {
|
|
162
161
|
const s = e ? e[n] : "";
|
|
163
162
|
return s || (typeof t == "string" ? st(t + "") : JSON.stringify(t));
|
|
164
163
|
}
|
|
165
164
|
function N(t) {
|
|
166
|
-
let n =
|
|
165
|
+
let n = I(K(t?.type)), e = F(n);
|
|
167
166
|
n.length > 1 && (e = "any");
|
|
168
167
|
let s = (t?.selectable || "").trim(), i = [];
|
|
169
168
|
return s && e != "boolean" && (s.includes("|") ? s.split("|").forEach(($) => {
|
|
@@ -171,7 +170,7 @@ function N(t) {
|
|
|
171
170
|
let m = $.split(":");
|
|
172
171
|
i.push({
|
|
173
172
|
label: $,
|
|
174
|
-
prop:
|
|
173
|
+
prop: w(m[0].trim())
|
|
175
174
|
});
|
|
176
175
|
}
|
|
177
176
|
}) : i = j(s), e == "array" ? e = "choice" : e != "function" && i.length > 1 && (e = "select")), {
|
|
@@ -180,7 +179,7 @@ function N(t) {
|
|
|
180
179
|
dataType: n
|
|
181
180
|
};
|
|
182
181
|
}
|
|
183
|
-
function
|
|
182
|
+
function w(t, n) {
|
|
184
183
|
try {
|
|
185
184
|
if (n == "function")
|
|
186
185
|
if (typeof t == "string") {
|
|
@@ -198,10 +197,10 @@ function Tt(t, n = !0) {
|
|
|
198
197
|
const e = N(t), s = E(e.dataType);
|
|
199
198
|
if (n) {
|
|
200
199
|
const i = (t.default || "").trim();
|
|
201
|
-
return
|
|
200
|
+
return w(i || s, F(e.dataType));
|
|
202
201
|
} else {
|
|
203
202
|
const i = (t.default || "").trim();
|
|
204
|
-
return
|
|
203
|
+
return w(i, F(e.dataType));
|
|
205
204
|
}
|
|
206
205
|
}
|
|
207
206
|
export {
|
|
@@ -3,52 +3,3 @@ export declare function getJs(parent: HTMLElement, value: string, options?: stri
|
|
|
3
3
|
export declare function getHtml(parent: HTMLElement, value: string, options?: string[]): monaco.editor.IStandaloneCodeEditor;
|
|
4
4
|
export declare function getJson(parent: HTMLElement, value: string, options?: string[]): monaco.editor.IStandaloneCodeEditor;
|
|
5
5
|
export declare function getCss(parent: HTMLElement, value: string, options?: string[]): monaco.editor.IStandaloneCodeEditor;
|
|
6
|
-
...items: string[]): string[];
|
|
7
|
-
isArray(arg: any): arg is any[];
|
|
8
|
-
readonly prototype: any[];
|
|
9
|
-
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
10
|
-
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
11
|
-
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
12
|
-
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
13
|
-
of<T>(...items: T[]): T[];
|
|
14
|
-
fromAsync<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | PromiseLike<T>> | ArrayLike<T | PromiseLike<T>>): Promise<T[]>;
|
|
15
|
-
fromAsync<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>, index: number) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
|
16
|
-
readonly [Symbol.species]: ArrayConstructor;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
20
|
-
"update:modelValue": (...args: any[]) => void;
|
|
21
|
-
}, string, PublicProps, Readonly< ExtractPropTypes<{
|
|
22
|
-
modelValue: {
|
|
23
|
-
type: StringConstructor;
|
|
24
|
-
default: string;
|
|
25
|
-
};
|
|
26
|
-
format: {
|
|
27
|
-
type: StringConstructor;
|
|
28
|
-
};
|
|
29
|
-
options: {
|
|
30
|
-
type: {
|
|
31
|
-
(arrayLength: number): string[];
|
|
32
|
-
(...items: string[]): string[];
|
|
33
|
-
new (arrayLength: number): string[];
|
|
34
|
-
new (...items: string[]): string[];
|
|
35
|
-
isArray(arg: any): arg is any[];
|
|
36
|
-
readonly prototype: any[];
|
|
37
|
-
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
38
|
-
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
39
|
-
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
40
|
-
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
41
|
-
of<T>(...items: T[]): T[];
|
|
42
|
-
fromAsync<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | PromiseLike<T>> | ArrayLike<T | PromiseLike<T>>): Promise<T[]>;
|
|
43
|
-
fromAsync<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>, index: number) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
|
44
|
-
readonly [Symbol.species]: ArrayConstructor;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
}>> & Readonly<{
|
|
48
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
49
|
-
}>, {
|
|
50
|
-
modelValue: string;
|
|
51
|
-
}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
52
|
-
refText: HTMLDivElement;
|
|
53
|
-
}, HTMLDivElement>;
|
|
54
|
-
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)}function
|
|
3
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+t+"$").exec(e);return n&&n.length>0?
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("../../config.cjs"),W=require("@fangzhongya/utils/basic/string/toFunction"),A=require("@fangzhongya/utils/basic/string/firstLower");let c=e=>e;const f=O.getConfig("prettier");f&&Promise.resolve().then(()=>require("./prettier.cjs")).then(e=>{c=e.getFormat});function g(e){return f?c(e,"js"):e.replace(/\;(\s|\n\r)*$/,"")}async function q(e){return e="let a = "+e,(await g(e)).replace(/^let a = /,"")}function C(e){return g(e)}async function x(e){return!/^\s*function/.test(e)&&!/^\s*\([^\)]*\)\s*\=\>/.test(e)?(e="function a"+e,(await g(e)).replace(/^function a/,"")):await g(e)}function L(e){return f?c(e,"html"):e}function B(e){return f?c(e,"ts"):e}function E(e){return f?c(e,"js"):e}function N(e){return f?c(e,"css"):e}function P(e,t=""){let r=(e+"").trim().split(/\n/);return r=r.map(n=>t+n),r.join(`
|
|
2
|
+
`)}function F(e=""){e=e.trim();let t=`[\\s|\\n|\\r]*\\{((.|
|
|
3
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`,n=new RegExp("^"+t+"$").exec(e);return n&&n.length>0?F(n[1]):e}const R=["Boolean","Any","String","Number","Array","Object","Function"];function z(e){return R.includes(e)?A.firstLower(e):e}function H(e){if(typeof e=="string"){let t=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(t=!0),t&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function I(e){const t=typeof e;if(t=="string"){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let r="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?r="string":/^\[(.|\n|\r)*\]$/.test(e)?r="array":/^\{(.|\n|\r)*\}$/.test(e)?r="object":/^[0-9]*$/.test(e)?r="number":e==="true"||e==="false"?r="boolean":e=="undefined"?r="undefined":e=="null"?r="null":e&&(r="string"),r}else return t==="object"?e instanceof Array?"array":t===null?"null":t:t}const y=(e,t)=>{let r=[],n=[],i="";for(let o=0;o<e.length;o++){const s=e[o];s==="["||s==="<"||s==="("?(r.push(s),i+=s):s==="]"&&r.length>0&&r[r.length-1]==="["||s===">"&&r.length>0&&r[r.length-1]==="<"||s===")"&&r.length>0&&r[r.length-1]==="("?(r.pop(),i+=s):s===t&&r.length===0?(n.push(i.trim()),i=""):i+=s}return i.trim()!==""&&n.push(i.trim()),n},J=e=>{let t=[],r=!1,n=!1,i=0;for(let o=0;o<e.length;o++){const s=e[o];if(s==="["||s==="<"||s==="("?(n=!0,t.push(s),s=="["&&(r=!0),i==0&&(i=o)):(s==="]"&&t[t.length-1]==="["||s===">"&&t[t.length-1]==="<"||s===")"&&t[t.length-1]==="(")&&t.pop(),n&&t.length===0)return r&&i+1==o?{top:"Array",type:e.substring(0,i)}:{top:e.substring(0,i),type:e.substring(i+1,o)}}return{top:e,type:""}},b=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const t=e.slice(1,-1).trim();return t?y(t,","):["any"]}else{if(e.startsWith("{")&&e.endsWith("}"))return["Object"];if(e.startsWith("<")&&e.endsWith(">")){const t=e.slice(1,-1).trim();return t?y(t,"|"):["any"]}else return y(e,",")}else return["any"]};function M(e){return y(e,",").map(r=>{const n=r.trim(),i=r.match(/^([^:?]+)(\??):/);if(!i)return null;const o=i[1].trim(),s=!i[2],S=i[0].length,p=r.substring(S).trim();let a=[],d="",m="";for(let u=0;u<p.length;u++){const l=p[u];if(l==="["||l==="<"||l==="("||l==="{"?a.push(l):(l==="]"&&a[a.length-1]==="["||l===">"&&a[a.length-1]==="<"||l==="}"&&a[a.length-1]==="{"||l===")"&&a[a.length-1]==="(")&&a.pop(),a.length===0&&u>0){u==1&&l!=="]"&&l!==">"&&l!=="}"&&l!==")"?(d="",m=p.substring(0)):(d=p.substring(0,u+1).trim(),m=p.substring(u+1));break}}const k=b(d),T=v(k);return{name:o,prop:o,type:h(T),dataType:T,must:s,label:n,description:m}}).filter(Boolean)}function j(e){return e.map(r=>{if(typeof r=="string")return r.toLowerCase()==="array"?"Array<any>":r;if(r.children&&r.children.length>0){const n=j(r.children);return r.value+"<"+n+">"}else{const n=r.value;return n.toLowerCase()==="array"?"Array<any>":n}}).join(" | ")||"any"}function v(e){const t=[];return e.forEach(r=>{const n=J(r);if(n.type){const i=b(n.type),o=v(i);t.push({label:r,value:n.top,children:o})}else t.push(n.top)}),t}function V(e){let t="";return typeof e=="string"?t=e:t=e.value,z(t||"any")}function h(e){const t=e[0]||"any";return V(t)}function w(e){const t=e[0];switch(h(e)){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":if(typeof t=="string")return"[]";{let n=t.children;if(n&&n.length>0){let i=w([n[0]]);return i=i=="undefined"?"":i,`[${i}]`}else return"[]"}case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function $(e){const t=Object.prototype.toString.call(e);let n=/^\[[O|o]bject (.*)\]$/.exec(t),i=typeof e;return n&&n.length>0&&(i=n[1].toLowerCase()),i}function D(e,t){const r=$(e),n=h(t);return n&&n!="any"?r==n:!0}const G=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","implements","interface","let","package","private","protected","public","static","true","false","null","undefined","any","boolean","number","string","object","symbol","unknown","never","void","undefined","null","type","interface","enum","as","is","infer","unique","abstract","readonly","namespace","module","declare","require","get","set","async","await","from","of","package"];Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>W.getFunctionFormat});exports.allReservedWords=G;exports.getDataType=v;exports.getDataTypeType=h;exports.getFunBody=F;exports.getObjType=$;exports.getString=H;exports.getTypeValue=w;exports.isDefaultType=I;exports.isTypeEqual=D;exports.parseParamString=M;exports.parseTypeDefinition=b;exports.prettierArrFormat=C;exports.prettierCss=N;exports.prettierFormat=g;exports.prettierFunFormat=x;exports.prettierHtml=L;exports.prettierJs=E;exports.prettierObjFormat=q;exports.prettierTs=B;exports.setDataType=j;exports.vueFormat=P;
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { getConfig as
|
|
2
|
-
import { getFunctionFormat as
|
|
3
|
-
import { firstLower as
|
|
1
|
+
import { getConfig as $ } from "../../config.js";
|
|
2
|
+
import { getFunctionFormat as Z } from "@fangzhongya/utils/basic/string/toFunction";
|
|
3
|
+
import { firstLower as F } from "@fangzhongya/utils/basic/string/firstLower";
|
|
4
4
|
let c = (e) => e;
|
|
5
|
-
const f =
|
|
5
|
+
const f = $("prettier");
|
|
6
6
|
f && import("./prettier.js").then((e) => {
|
|
7
7
|
c = e.getFormat;
|
|
8
8
|
});
|
|
9
9
|
function y(e) {
|
|
10
10
|
return f ? c(e, "js") : e.replace(/\;(\s|\n\r)*$/, "");
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
12
|
+
async function E(e) {
|
|
13
13
|
return e = "let a = " + e, (await y(e)).replace(/^let a = /, "");
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function N(e) {
|
|
16
16
|
return y(e);
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
18
|
+
async function z(e) {
|
|
19
19
|
return !/^\s*function/.test(e) && !/^\s*\([^\)]*\)\s*\=\>/.test(e) ? (e = "function a" + e, (await y(e)).replace(/^function a/, "")) : await y(e);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function I(e) {
|
|
22
22
|
return f ? c(e, "html") : e;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function R(e) {
|
|
25
25
|
return f ? c(e, "ts") : e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function H(e) {
|
|
28
28
|
return f ? c(e, "js") : e;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function J(e) {
|
|
31
31
|
return f ? c(e, "css") : e;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
return
|
|
33
|
+
function M(e, t = "") {
|
|
34
|
+
let n = (e + "").trim().split(/\n/);
|
|
35
|
+
return n = n.map((r) => t + r), n.join(`
|
|
36
36
|
`);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function k(e = "") {
|
|
39
39
|
e = e.trim();
|
|
40
40
|
let t = `[\\s|\\n|\\r]*\\{((.|
|
|
41
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,
|
|
42
|
-
return
|
|
41
|
+
|\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + t + "$").exec(e);
|
|
42
|
+
return r && r.length > 0 ? k(r[1]) : e;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const S = [
|
|
45
45
|
"Boolean",
|
|
46
46
|
"Any",
|
|
47
47
|
"String",
|
|
@@ -51,7 +51,7 @@ const A = [
|
|
|
51
51
|
"Function"
|
|
52
52
|
];
|
|
53
53
|
function W(e) {
|
|
54
|
-
return
|
|
54
|
+
return S.includes(e) ? F(e) : e;
|
|
55
55
|
}
|
|
56
56
|
function V(e) {
|
|
57
57
|
if (typeof e == "string") {
|
|
@@ -63,24 +63,24 @@ function G(e) {
|
|
|
63
63
|
const t = typeof e;
|
|
64
64
|
if (t == "string") {
|
|
65
65
|
e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
|
|
66
|
-
let
|
|
67
|
-
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ?
|
|
66
|
+
let n = "";
|
|
67
|
+
return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ? n = "string" : /^\[(.|\n|\r)*\]$/.test(e) ? n = "array" : /^\{(.|\n|\r)*\}$/.test(e) ? n = "object" : /^[0-9]*$/.test(e) ? n = "number" : e === "true" || e === "false" ? n = "boolean" : e == "undefined" ? n = "undefined" : e == "null" ? n = "null" : e && (n = "string"), n;
|
|
68
68
|
} else
|
|
69
69
|
return t === "object" ? e instanceof Array ? "array" : t === null ? "null" : t : t;
|
|
70
70
|
}
|
|
71
71
|
const g = (e, t) => {
|
|
72
|
-
let
|
|
72
|
+
let n = [], r = [], i = "";
|
|
73
73
|
for (let l = 0; l < e.length; l++) {
|
|
74
74
|
const s = e[l];
|
|
75
|
-
s === "[" || s === "<" || s === "(" ? (
|
|
75
|
+
s === "[" || s === "<" || s === "(" ? (n.push(s), i += s) : s === "]" && n.length > 0 && n[n.length - 1] === "[" || s === ">" && n.length > 0 && n[n.length - 1] === "<" || s === ")" && n.length > 0 && n[n.length - 1] === "(" ? (n.pop(), i += s) : s === t && n.length === 0 ? (r.push(i.trim()), i = "") : i += s;
|
|
76
76
|
}
|
|
77
|
-
return i.trim() !== "" &&
|
|
78
|
-
},
|
|
79
|
-
let t = [],
|
|
77
|
+
return i.trim() !== "" && r.push(i.trim()), r;
|
|
78
|
+
}, A = (e) => {
|
|
79
|
+
let t = [], n = !1, r = !1, i = 0;
|
|
80
80
|
for (let l = 0; l < e.length; l++) {
|
|
81
81
|
const s = e[l];
|
|
82
|
-
if (s === "[" || s === "<" || s === "(" ? (
|
|
83
|
-
return
|
|
82
|
+
if (s === "[" || s === "<" || s === "(" ? (r = !0, t.push(s), s == "[" && (n = !0), i == 0 && (i = l)) : (s === "]" && t[t.length - 1] === "[" || s === ">" && t[t.length - 1] === "<" || s === ")" && t[t.length - 1] === "(") && t.pop(), r && t.length === 0)
|
|
83
|
+
return n && i + 1 == l ? {
|
|
84
84
|
top: "Array",
|
|
85
85
|
type: e.substring(0, i)
|
|
86
86
|
} : {
|
|
@@ -109,69 +109,69 @@ const g = (e, t) => {
|
|
|
109
109
|
else return ["any"];
|
|
110
110
|
};
|
|
111
111
|
function K(e) {
|
|
112
|
-
return g(e, ",").map((
|
|
113
|
-
const
|
|
112
|
+
return g(e, ",").map((n) => {
|
|
113
|
+
const r = n.trim(), i = n.match(/^([^:?]+)(\??):/);
|
|
114
114
|
if (!i) return null;
|
|
115
|
-
const l = i[1].trim(), s = !i[2],
|
|
116
|
-
let u = [], h = "",
|
|
115
|
+
const l = i[1].trim(), s = !i[2], w = i[0].length, p = n.substring(w).trim();
|
|
116
|
+
let u = [], h = "", d = "";
|
|
117
117
|
for (let a = 0; a < p.length; a++) {
|
|
118
118
|
const o = p[a];
|
|
119
119
|
if (o === "[" || o === "<" || o === "(" || o === "{" ? u.push(o) : (o === "]" && u[u.length - 1] === "[" || o === ">" && u[u.length - 1] === "<" || o === "}" && u[u.length - 1] === "{" || o === ")" && u[u.length - 1] === "(") && u.pop(), u.length === 0 && a > 0) {
|
|
120
|
-
a == 1 && o !== "]" && o !== ">" && o !== "}" && o !== ")" ? (h = "",
|
|
120
|
+
a == 1 && o !== "]" && o !== ">" && o !== "}" && o !== ")" ? (h = "", d = p.substring(0)) : (h = p.substring(0, a + 1).trim(), d = p.substring(a + 1));
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const
|
|
124
|
+
const T = v(h), b = j(T);
|
|
125
125
|
return {
|
|
126
126
|
name: l,
|
|
127
127
|
prop: l,
|
|
128
|
-
type: b
|
|
129
|
-
dataType:
|
|
128
|
+
type: m(b),
|
|
129
|
+
dataType: b,
|
|
130
130
|
must: s,
|
|
131
|
-
label:
|
|
132
|
-
description:
|
|
131
|
+
label: r,
|
|
132
|
+
description: d
|
|
133
133
|
};
|
|
134
134
|
}).filter(Boolean);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
return e.map((
|
|
138
|
-
if (typeof
|
|
139
|
-
return r.toLowerCase() === "array" ? "Array<any>" : r;
|
|
140
|
-
if (r.children && r.children.length > 0) {
|
|
141
|
-
const n = O(r.children);
|
|
142
|
-
return r.value + "<" + n + ">";
|
|
143
|
-
} else {
|
|
144
|
-
const n = r.value;
|
|
136
|
+
function x(e) {
|
|
137
|
+
return e.map((n) => {
|
|
138
|
+
if (typeof n == "string")
|
|
145
139
|
return n.toLowerCase() === "array" ? "Array<any>" : n;
|
|
140
|
+
if (n.children && n.children.length > 0) {
|
|
141
|
+
const r = x(n.children);
|
|
142
|
+
return n.value + "<" + r + ">";
|
|
143
|
+
} else {
|
|
144
|
+
const r = n.value;
|
|
145
|
+
return r.toLowerCase() === "array" ? "Array<any>" : r;
|
|
146
146
|
}
|
|
147
147
|
}).join(" | ") || "any";
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function j(e) {
|
|
150
150
|
const t = [];
|
|
151
|
-
return e.forEach((
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
const i = v(
|
|
151
|
+
return e.forEach((n) => {
|
|
152
|
+
const r = A(n);
|
|
153
|
+
if (r.type) {
|
|
154
|
+
const i = v(r.type), l = j(i);
|
|
155
155
|
t.push({
|
|
156
|
-
label:
|
|
157
|
-
value:
|
|
156
|
+
label: n,
|
|
157
|
+
value: r.top,
|
|
158
158
|
children: l
|
|
159
159
|
});
|
|
160
160
|
} else
|
|
161
|
-
t.push(
|
|
161
|
+
t.push(r.top);
|
|
162
162
|
}), t;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function O(e) {
|
|
165
165
|
let t = "";
|
|
166
166
|
return typeof e == "string" ? t = e : t = e.value, W(t || "any");
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function m(e) {
|
|
169
169
|
const t = e[0] || "any";
|
|
170
|
-
return
|
|
170
|
+
return O(t);
|
|
171
171
|
}
|
|
172
172
|
function C(e) {
|
|
173
173
|
const t = e[0];
|
|
174
|
-
switch (
|
|
174
|
+
switch (m(e)) {
|
|
175
175
|
case "string":
|
|
176
176
|
return '""';
|
|
177
177
|
case "boolean":
|
|
@@ -182,9 +182,9 @@ function C(e) {
|
|
|
182
182
|
if (typeof t == "string")
|
|
183
183
|
return "[]";
|
|
184
184
|
{
|
|
185
|
-
let
|
|
186
|
-
if (
|
|
187
|
-
let i = C([
|
|
185
|
+
let r = t.children;
|
|
186
|
+
if (r && r.length > 0) {
|
|
187
|
+
let i = C([r[0]]);
|
|
188
188
|
return i = i == "undefined" ? "" : i, `[${i}]`;
|
|
189
189
|
} else
|
|
190
190
|
return "[]";
|
|
@@ -201,18 +201,105 @@ function C(e) {
|
|
|
201
201
|
}
|
|
202
202
|
function L(e) {
|
|
203
203
|
const t = Object.prototype.toString.call(e);
|
|
204
|
-
let
|
|
205
|
-
return
|
|
204
|
+
let r = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
|
|
205
|
+
return r && r.length > 0 && (i = r[1].toLowerCase()), i;
|
|
206
206
|
}
|
|
207
207
|
function Q(e, t) {
|
|
208
|
-
const
|
|
209
|
-
return
|
|
208
|
+
const n = L(e), r = m(t);
|
|
209
|
+
return r && r != "any" ? n == r : !0;
|
|
210
210
|
}
|
|
211
|
+
const U = [
|
|
212
|
+
// JavaScript 基本关键字
|
|
213
|
+
"break",
|
|
214
|
+
"case",
|
|
215
|
+
"catch",
|
|
216
|
+
"class",
|
|
217
|
+
"const",
|
|
218
|
+
"continue",
|
|
219
|
+
"debugger",
|
|
220
|
+
"default",
|
|
221
|
+
"delete",
|
|
222
|
+
"do",
|
|
223
|
+
"else",
|
|
224
|
+
"export",
|
|
225
|
+
"extends",
|
|
226
|
+
"finally",
|
|
227
|
+
"for",
|
|
228
|
+
"function",
|
|
229
|
+
"if",
|
|
230
|
+
"import",
|
|
231
|
+
"in",
|
|
232
|
+
"instanceof",
|
|
233
|
+
"new",
|
|
234
|
+
"return",
|
|
235
|
+
"super",
|
|
236
|
+
"switch",
|
|
237
|
+
"this",
|
|
238
|
+
"throw",
|
|
239
|
+
"try",
|
|
240
|
+
"typeof",
|
|
241
|
+
"var",
|
|
242
|
+
"void",
|
|
243
|
+
"while",
|
|
244
|
+
"with",
|
|
245
|
+
"yield",
|
|
246
|
+
// 严格模式下的保留字
|
|
247
|
+
"implements",
|
|
248
|
+
"interface",
|
|
249
|
+
"let",
|
|
250
|
+
"package",
|
|
251
|
+
"private",
|
|
252
|
+
"protected",
|
|
253
|
+
"public",
|
|
254
|
+
"static",
|
|
255
|
+
// 字面量值
|
|
256
|
+
"true",
|
|
257
|
+
"false",
|
|
258
|
+
"null",
|
|
259
|
+
"undefined",
|
|
260
|
+
// TypeScript 特有类型关键字
|
|
261
|
+
"any",
|
|
262
|
+
"boolean",
|
|
263
|
+
"number",
|
|
264
|
+
"string",
|
|
265
|
+
"object",
|
|
266
|
+
"symbol",
|
|
267
|
+
"unknown",
|
|
268
|
+
"never",
|
|
269
|
+
"void",
|
|
270
|
+
"undefined",
|
|
271
|
+
"null",
|
|
272
|
+
// TypeScript 类型操作与定义
|
|
273
|
+
"type",
|
|
274
|
+
"interface",
|
|
275
|
+
"enum",
|
|
276
|
+
"as",
|
|
277
|
+
"is",
|
|
278
|
+
"infer",
|
|
279
|
+
"unique",
|
|
280
|
+
// TypeScript 类修饰符
|
|
281
|
+
"abstract",
|
|
282
|
+
"readonly",
|
|
283
|
+
// TypeScript 模块与声明
|
|
284
|
+
"namespace",
|
|
285
|
+
"module",
|
|
286
|
+
"declare",
|
|
287
|
+
"require",
|
|
288
|
+
// 其他(访问器、未来保留字等)
|
|
289
|
+
"get",
|
|
290
|
+
"set",
|
|
291
|
+
"async",
|
|
292
|
+
"await",
|
|
293
|
+
"from",
|
|
294
|
+
"of",
|
|
295
|
+
"package"
|
|
296
|
+
];
|
|
211
297
|
export {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
298
|
+
U as allReservedWords,
|
|
299
|
+
j as getDataType,
|
|
300
|
+
m as getDataTypeType,
|
|
301
|
+
k as getFunBody,
|
|
302
|
+
Z as getFunctionFormat,
|
|
216
303
|
L as getObjType,
|
|
217
304
|
V as getString,
|
|
218
305
|
C as getTypeValue,
|
|
@@ -220,14 +307,14 @@ export {
|
|
|
220
307
|
Q as isTypeEqual,
|
|
221
308
|
K as parseParamString,
|
|
222
309
|
v as parseTypeDefinition,
|
|
223
|
-
|
|
224
|
-
|
|
310
|
+
N as prettierArrFormat,
|
|
311
|
+
J as prettierCss,
|
|
225
312
|
y as prettierFormat,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
313
|
+
z as prettierFunFormat,
|
|
314
|
+
I as prettierHtml,
|
|
315
|
+
H as prettierJs,
|
|
316
|
+
E as prettierObjFormat,
|
|
317
|
+
R as prettierTs,
|
|
318
|
+
x as setDataType,
|
|
319
|
+
M as vueFormat
|
|
233
320
|
};
|