@fangzhongya/vue-archive 0.1.3 → 0.1.5

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.
@@ -1,48 +1,47 @@
1
1
  import "@fangzhongya/utils/basic/object/mergeObject";
2
2
  import "@fangzhongya/utils/basic/array/toggleArray";
3
- import { humpToLine as v } from "@fangzhongya/utils/name/humpToLine";
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 G } from "@fangzhongya/utils/basic/string/firstLower";
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 I, prettierTs as K, getDataType as M, parseTypeDefinition as Q, setDataType as R, vueFormat as x, getFunBody as J } from "./util.js";
13
- import { getPropsValue as W, getEmitsValue as X, getExposeValue as Y, getSlotValue as _ } from "../../utils/props.js";
14
- import { getFunctionFormat as k } from "@fangzhongya/utils/basic/string/toFunction";
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") + ":" + R(n.dataType)).join(",");
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 A = W(n.propss || []), C = X(n.emitss || []), U = Y(n.exposes || []), Z = _(n.slots || []);
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 = G(u)) : (l = a[0], u = v(u)), a.includes("-")) {
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(C, u) || {}, y = f.selectable || "", b = j(y), g = L(b);
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
- tt.includes(o) && (u = o + "1"), m.push(" :" + o + '="' + u + '"');
45
- const a = T(A, o) || {}, l = N(a);
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(U, o.name) || {};
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 q = et(s, Z);
102
+ const U = et(s, R);
104
103
  let S = `<template>
105
104
  <div>
106
105
  <${t}${m.join(`
107
- `)}>${q.join(`
106
+ `)}>${U.join(`
108
107
  `)}
109
108
  </${t}>
110
109
  </div>
111
110
  </template>`;
112
- S = await I(S);
111
+ S = await q(S);
113
112
  let D = r.join(`
114
113
  `);
115
- return D = await K(D), `<!--${t}-->
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 : w(t.toString());
135
+ return s && (s.includes("=>") || s.includes("function")) ? s : O(t.toString());
137
136
  }
138
- async function w(t) {
139
- const n = k(t);
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) ? w(n) : JSON.stringify(t);
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 = M(Q(t?.type)), e = F(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: O(m[0].trim())
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 O(t, n) {
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 O(i || s, F(e.dataType));
200
+ return w(i || s, F(e.dataType));
202
201
  } else {
203
202
  const i = (t.default || "").trim();
204
- return O(i, F(e.dataType));
203
+ return w(i, F(e.dataType));
205
204
  }
206
205
  }
207
206
  export {
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../../config.cjs"),W=require("@fangzhongya/utils/basic/string/toFunction"),k=require("@fangzhongya/utils/basic/string/firstLower");let c=e=>e;const f=A.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 L(e){return!/^\s*function/.test(e)&&!/^\s*\([^\)]*\)\s*\=\>/.test(e)?(e="function a"+e,(await g(e)).replace(/^function a/,"")):await g(e)}function B(e){return f?c(e,"html"):e}function E(e){return f?c(e,"ts"):e}function x(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 v(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?v(n[1]):e}const z=["Boolean","Any","String","Number","Array","Object","Function"];function H(e){return z.includes(e)?k.firstLower(e):e}function I(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 J(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 u=0;u<e.length;u++){const s=e[u];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},M=e=>{let t=[],r=!1,n=!1,i=0;for(let u=0;u<e.length;u++){const s=e[u];if(s==="["||s==="<"||s==="("?(n=!0,t.push(s),s=="["&&(r=!0),i==0&&(i=u)):(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==u?{top:"Array",type:e.substring(0,i)}:{top:e.substring(0,i),type:e.substring(i+1,u)}}return{top:e,type:""}},d=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 V(e){return y(e,",").map(r=>{const n=r.trim(),i=r.match(/^([^:?]+)(\??):/);if(!i)return null;const u=i[1].trim(),s=!i[2],w=i[0].length,p=r.substring(w).trim();let l=[],m="",b="";for(let a=0;a<p.length;a++){const o=p[a];if(o==="["||o==="<"||o==="("||o==="{"?l.push(o):(o==="]"&&l[l.length-1]==="["||o===">"&&l[l.length-1]==="<"||o==="}"&&l[l.length-1]==="{"||o===")"&&l[l.length-1]==="(")&&l.pop(),l.length===0&&a>0){a==1&&o!=="]"&&o!==">"&&o!=="}"&&o!==")"?(m="",b=p.substring(0)):(m=p.substring(0,a+1).trim(),b=p.substring(a+1));break}}const O=d(m),F=T(O);return{name:u,prop:u,type:h(F),dataType:F,must:s,label:n,description:b}}).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 T(e){const t=[];return e.forEach(r=>{const n=M(r);if(n.type){const i=d(n.type),u=T(i);t.push({label:r,value:n.top,children:u})}else t.push(n.top)}),t}function D(e){let t="";return typeof e=="string"?t=e:t=e.value,H(t||"any")}function h(e){const t=e[0]||"any";return D(t)}function $(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=$([n[0]]);return i=i=="undefined"?"":i,`[${i}]`}else return"[]"}case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function S(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 R(e,t){const r=S(e),n=h(t);return n&&n!="any"?r==n:!0}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>W.getFunctionFormat});exports.getDataType=T;exports.getDataTypeType=h;exports.getFunBody=v;exports.getObjType=S;exports.getString=I;exports.getTypeValue=$;exports.isDefaultType=J;exports.isTypeEqual=R;exports.parseParamString=V;exports.parseTypeDefinition=d;exports.prettierArrFormat=C;exports.prettierCss=N;exports.prettierFormat=g;exports.prettierFunFormat=L;exports.prettierHtml=B;exports.prettierJs=x;exports.prettierObjFormat=q;exports.prettierTs=E;exports.setDataType=j;exports.vueFormat=P;
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;
@@ -53,3 +53,4 @@ export declare function getObjType(obj: unknown): string;
53
53
  * @returns
54
54
  */
55
55
  export declare function isTypeEqual(obj: unknown, dataType: DataType[]): boolean;
56
+ export declare const allReservedWords: string[];
@@ -1,47 +1,47 @@
1
- import { getConfig as F } from "../../config.js";
2
- import { getFunctionFormat as Y } from "@fangzhongya/utils/basic/string/toFunction";
3
- import { firstLower as w } from "@fangzhongya/utils/basic/string/firstLower";
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 = F("prettier");
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 N(e) {
12
+ async function E(e) {
13
13
  return e = "let a = " + e, (await y(e)).replace(/^let a = /, "");
14
14
  }
15
- function z(e) {
15
+ function N(e) {
16
16
  return y(e);
17
17
  }
18
- async function I(e) {
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 q(e) {
21
+ function I(e) {
22
22
  return f ? c(e, "html") : e;
23
23
  }
24
- function H(e) {
24
+ function R(e) {
25
25
  return f ? c(e, "ts") : e;
26
26
  }
27
- function J(e) {
27
+ function H(e) {
28
28
  return f ? c(e, "js") : e;
29
29
  }
30
- function M(e) {
30
+ function J(e) {
31
31
  return f ? c(e, "css") : e;
32
32
  }
33
- function R(e, t = "") {
34
- let r = (e + "").trim().split(/\n/);
35
- return r = r.map((n) => t + n), r.join(`
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 S(e = "") {
38
+ function k(e = "") {
39
39
  e = e.trim();
40
40
  let t = `[\\s|\\n|\\r]*\\{((.|
41
- |\r)+?)\\}[\\s|\\n|\\r]*`, n = new RegExp("^" + t + "$").exec(e);
42
- return n && n.length > 0 ? S(n[1]) : e;
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 A = [
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 A.includes(e) ? w(e) : e;
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 r = "";
67
- 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;
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 r = [], n = [], i = "";
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 === "(" ? (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;
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() !== "" && n.push(i.trim()), n;
78
- }, k = (e) => {
79
- let t = [], r = !1, n = !1, i = 0;
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 === "(" ? (n = !0, t.push(s), s == "[" && (r = !0), i == 0 && (i = l)) : (s === "]" && t[t.length - 1] === "[" || s === ">" && t[t.length - 1] === "<" || s === ")" && t[t.length - 1] === "(") && t.pop(), n && t.length === 0)
83
- return r && i + 1 == l ? {
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((r) => {
113
- const n = r.trim(), i = r.match(/^([^:?]+)(\??):/);
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], j = i[0].length, p = r.substring(j).trim();
116
- let u = [], h = "", m = "";
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 = "", m = p.substring(0)) : (h = p.substring(0, a + 1).trim(), m = p.substring(a + 1));
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 $ = v(h), d = T($);
124
+ const T = v(h), b = j(T);
125
125
  return {
126
126
  name: l,
127
127
  prop: l,
128
- type: b(d),
129
- dataType: d,
128
+ type: m(b),
129
+ dataType: b,
130
130
  must: s,
131
- label: n,
132
- description: m
131
+ label: r,
132
+ description: d
133
133
  };
134
134
  }).filter(Boolean);
135
135
  }
136
- function O(e) {
137
- return e.map((r) => {
138
- if (typeof r == "string")
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 T(e) {
149
+ function j(e) {
150
150
  const t = [];
151
- return e.forEach((r) => {
152
- const n = k(r);
153
- if (n.type) {
154
- const i = v(n.type), l = T(i);
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: r,
157
- value: n.top,
156
+ label: n,
157
+ value: r.top,
158
158
  children: l
159
159
  });
160
160
  } else
161
- t.push(n.top);
161
+ t.push(r.top);
162
162
  }), t;
163
163
  }
164
- function x(e) {
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 b(e) {
168
+ function m(e) {
169
169
  const t = e[0] || "any";
170
- return x(t);
170
+ return O(t);
171
171
  }
172
172
  function C(e) {
173
173
  const t = e[0];
174
- switch (b(e)) {
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 n = t.children;
186
- if (n && n.length > 0) {
187
- let i = C([n[0]]);
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 n = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
205
- return n && n.length > 0 && (i = n[1].toLowerCase()), i;
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 r = L(e), n = b(t);
209
- return n && n != "any" ? r == n : !0;
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
- T as getDataType,
213
- b as getDataTypeType,
214
- S as getFunBody,
215
- Y as getFunctionFormat,
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
- z as prettierArrFormat,
224
- M as prettierCss,
310
+ N as prettierArrFormat,
311
+ J as prettierCss,
225
312
  y as prettierFormat,
226
- I as prettierFunFormat,
227
- q as prettierHtml,
228
- J as prettierJs,
229
- N as prettierObjFormat,
230
- H as prettierTs,
231
- O as setDataType,
232
- R as vueFormat
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
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../config.cjs"),l=require("../utils/storage.cjs");require("@fangzhongya/utils/basic/string/firstUpper");const p=require("./file.cjs"),f=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"})),i=[{path:"/__document",name:"__document",component:()=>Promise.resolve().then(()=>f(require("../index/index.vue.cjs"))),redirect:{name:"__documentIndex"},meta:{title:"文档"},children:[]}];let m=0;document.addEventListener("keydown",g);function g(e){e=e||window.event,(e.ctrlKey&&e.location==82||e.location==116)&&l.setSession("-keydown-F5",2)}let o="__document";function y(e){o=d.getConfig("router")||"__document";let t="/"+o;if(i[0].path=t,i[0].name=o,i[0].redirect={name:o+"Index"},i[0].children?.unshift({path:t+"/:chapters+",redirect:{name:o+"Index"}}),p.getFileName().forEach(n=>{i[0].children?.push({path:n.value,name:o+n.name,component:n.component})}),i.forEach(n=>{e.addRoute(n)}),e.beforeEach((n,r)=>{if(r.fullPath=="/"){let c=l.getSession("-keydown-F5");document.referrer||c==2?(console.log("刷新"),m=2):(console.log("地址栏输入 或者 刷新"),m=3)}else console.log("跳转"),m=1;l.setSession("-keydown-F5",0)}),d.getConfig("redirect")){const n=e.getRoutes().filter(r=>r.path=="/")[0]||{path:"/"};n.redirect=t,n.name?e.addRoute(n.name,n):e.addRoute(n)}}const u={};function h(e){let t=e.path,a=e.params;if(a&&Object.keys(a).length)return a;{let n=u[t];return n&&Object.keys(n).length?n:m==3?{}:l.getSession("router.toPage."+t)}}function s(e,t,a="push"){let n=t.path||"";const r=t.name,c=t.params||{};delete t.params,e[a](t),r&&(n=e.resolve({name:r}).path),u[n]=c,l.setSession("router.toPage."+n,c)}function k(e,t){s(e,{name:o+"Single",query:{id:t?.name+"/"+t?.value},params:{key:t?.key,comkey:t?.comkey}})}function v(e,t){s(e,{name:o+"Develop",query:{id:t?.value},params:{key:t?.key}})}function _(e,t){s(e,{name:o+"Edit",query:{id:t?.value},params:{key:t?.key}})}function P(e,t){s(e,{name:o+"Tests",query:{id:t?.value},params:{key:t?.key}})}function S(e,t){s(e,{name:o+"Compon",query:{id:t?.value},params:{key:t?.key}})}exports.getPageParams=h;exports.init=y;exports.toCompon=S;exports.toDevelop=v;exports.toEdit=_;exports.toPage=s;exports.toSingle=k;exports.toTests=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../config.cjs"),l=require("../utils/storage.cjs");require("@fangzhongya/utils/basic/string/firstUpper");const f=require("./file.cjs"),g=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"})),i=[{path:"/__document",name:"__document",component:()=>Promise.resolve().then(()=>g(require("../index/index.vue.cjs"))),redirect:{name:"__documentIndex"},meta:{title:"文档"},children:[]}];let m=0;document.addEventListener("keydown",y);function y(e){e=e||window.event,(e.ctrlKey&&e.location==82||e.location==116)&&l.setSession("-keydown-F5",2)}let o="__document";function h(e){o=d.getConfig("router")||"__document";let t="/"+o;if(i[0].path=t,i[0].name=o,i[0].redirect={name:o+"Index"},i[0].children?.unshift({path:t+"/:chapters+",redirect:{name:o+"Index"}}),f.getFileName().forEach(n=>{i[0].children?.push({path:n.value,name:o+n.name,component:n.component})}),i.forEach(n=>{e.addRoute(n)}),e.beforeEach((n,r,c)=>{if(r.fullPath=="/"){let p=l.getSession("-keydown-F5");document.referrer||p==2?(console.log("刷新"),m=2):(console.log("地址栏输入 或者 刷新"),m=3)}else console.log("跳转"),m=1;l.setSession("-keydown-F5",0),c()}),d.getConfig("redirect")){const n=e.getRoutes().filter(r=>r.path=="/")[0]||{path:"/"};n.redirect=t,n.name?e.addRoute(n.name,n):e.addRoute(n)}}const u={};function k(e){let t=e.path,a=e.params;if(a&&Object.keys(a).length)return a;{let n=u[t];return n&&Object.keys(n).length?n:m==3?{}:l.getSession("router.toPage."+t)}}function s(e,t,a="push"){let n=t.path||"";const r=t.name,c=t.params||{};delete t.params,e[a](t),r&&(n=e.resolve({name:r}).path),u[n]=c,l.setSession("router.toPage."+n,c)}function v(e,t){s(e,{name:o+"Single",query:{id:t?.name+"/"+t?.value},params:{key:t?.key,comkey:t?.comkey}})}function _(e,t){s(e,{name:o+"Develop",query:{id:t?.value},params:{key:t?.key}})}function P(e,t){s(e,{name:o+"Edit",query:{id:t?.value},params:{key:t?.key}})}function S(e,t){s(e,{name:o+"Tests",query:{id:t?.value},params:{key:t?.key}})}function q(e,t){s(e,{name:o+"Compon",query:{id:t?.value},params:{key:t?.key}})}exports.getPageParams=k;exports.init=h;exports.toCompon=q;exports.toDevelop=_;exports.toEdit=P;exports.toPage=s;exports.toSingle=v;exports.toTests=S;