@fangzhongya/vue-archive 0.0.31 → 0.0.33

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.
@@ -3138,53 +3138,99 @@ function getTypeValue(arr) {
3138
3138
  return "undefined";
3139
3139
  }
3140
3140
  }
3141
- function getType(str) {
3142
- let arr = [];
3143
- if (str) {
3144
- str = (str + "").trim();
3145
- if (str.startsWith("[")) {
3146
- str = str.substring(1, str.lastIndexOf("]"));
3147
- arr = str.split(",");
3141
+ function setDataType(arr) {
3142
+ return arr.join("|") || "any";
3143
+ }
3144
+ var splitIgnoringNesting = (str, delimiter) => {
3145
+ let bracketStack = [];
3146
+ let parts = [];
3147
+ let current = "";
3148
+ for (let i = 0; i < str.length; i++) {
3149
+ const char = str[i];
3150
+ if (char === "[" || char === "<" || char === "(") {
3151
+ bracketStack.push(char);
3152
+ current += char;
3153
+ } else if (char === "]" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "(") {
3154
+ bracketStack.pop();
3155
+ current += char;
3156
+ } else if (char === delimiter && bracketStack.length === 0) {
3157
+ parts.push(current.trim());
3158
+ current = "";
3148
3159
  } else {
3149
- const reg = /^\<([a-z|\<|\>|\|]+)\>/;
3150
- let rts = reg.exec(str);
3151
- if (rts && rts.length > 0) {
3152
- let ass = rts[1];
3153
- arr = ass.split("|");
3154
- } else {
3155
- arr = ["any"];
3156
- }
3160
+ current += char;
3157
3161
  }
3162
+ }
3163
+ if (current.trim() !== "") {
3164
+ parts.push(current.trim());
3165
+ }
3166
+ return parts;
3167
+ };
3168
+ var parseTypeDefinition = (typeDef) => {
3169
+ if (!typeDef || typeDef === "[]") {
3170
+ return { type: "any", dataType: ["any"] };
3171
+ } else if (typeDef.startsWith("[") && typeDef.endsWith("]")) {
3172
+ const inner = typeDef.slice(1, -1).trim();
3173
+ if (!inner) return { type: "any", dataType: ["any"] };
3174
+ const types = splitIgnoringNesting(inner, ",");
3175
+ return {
3176
+ type: types[0] || "any",
3177
+ dataType: types
3178
+ };
3179
+ } else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
3180
+ const inner = typeDef.slice(1, -1).trim();
3181
+ if (!inner) return { type: "any", dataType: ["any"] };
3182
+ const types = splitIgnoringNesting(inner, "|");
3183
+ return {
3184
+ type: types[0] || "any",
3185
+ dataType: types
3186
+ };
3158
3187
  } else {
3159
- arr = ["any"];
3188
+ return {
3189
+ type: typeDef,
3190
+ dataType: [typeDef]
3191
+ };
3160
3192
  }
3161
- return arr.map((o) => conversionType(o));
3162
- }
3163
- function setDataType(arr) {
3164
- return arr.join("|") || "any";
3165
- }
3166
- function getParametersObj(cs) {
3167
- let arrs = cs.split(",");
3168
- return arrs.map((key) => {
3169
- key = key.trim();
3170
- let must = true;
3171
- let vs = key.split(":");
3172
- let name = vs[0].trim();
3173
- if (name.endsWith("?")) {
3174
- must = false;
3175
- name = name.substring(0, name.length - 1);
3193
+ };
3194
+ function parseParamString(input) {
3195
+ const parts = splitIgnoringNesting(input, ",");
3196
+ return parts.map((trimmedPart) => {
3197
+ const label = trimmedPart.trim();
3198
+ const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
3199
+ if (!nameMatch) return null;
3200
+ const name = nameMatch[1].trim();
3201
+ const must = !nameMatch[2];
3202
+ const typeDefStart = nameMatch[0].length;
3203
+ const typeDef = trimmedPart.substring(typeDefStart).trim();
3204
+ let bracketStack = [];
3205
+ let endIndex = -1;
3206
+ let t = "";
3207
+ let description = "";
3208
+ for (let i = 0; i < typeDef.length; i++) {
3209
+ const char = typeDef[i];
3210
+ if (char === "[" || char === "<" || char === "(") {
3211
+ bracketStack.push(char);
3212
+ } else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
3213
+ bracketStack.pop();
3214
+ }
3215
+ if (bracketStack.length === 0 && i > 0) {
3216
+ endIndex = i == 1 ? 0 : i;
3217
+ t = typeDef.substring(0, endIndex + 1).trim();
3218
+ description = typeDef.substring(endIndex + 1);
3219
+ break;
3220
+ }
3176
3221
  }
3177
- let t = vs[1] || "";
3178
- let tarr = getSonType(getType(t));
3222
+ const { type, dataType } = parseTypeDefinition(t);
3223
+ const tarr = getSonType(dataType);
3179
3224
  return {
3180
- label: key,
3225
+ name,
3181
3226
  prop: name,
3182
- must,
3183
3227
  type: tarr[0],
3184
- dataType: tarr,
3185
- description: t.substring(t.lastIndexOf("]") + 1).trim()
3228
+ dataType,
3229
+ must,
3230
+ label,
3231
+ description
3186
3232
  };
3187
- });
3233
+ }).filter(Boolean);
3188
3234
  }
3189
3235
 
3190
3236
  // packages/components/use/code.ts
@@ -3233,12 +3279,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3233
3279
  tarr.push(" @" + name + '="' + strs + '"');
3234
3280
  const sp = getSpecObjs(es, name) || {};
3235
3281
  const s = sp.selectable || "";
3236
- const css = getParametersObj(s);
3282
+ const css = parseParamString(s);
3283
+ console.log(css);
3237
3284
  const cs = getParameStr(css);
3238
3285
  sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
3239
3286
  sarr.push("function " + strs + "(" + cs + ") {");
3240
3287
  css.forEach((o) => {
3241
- const name2 = o.prop || "arr";
3288
+ const name2 = o.name || "arr";
3242
3289
  sarr.push(" console.log('" + o.label + "', " + name2 + ")");
3243
3290
  });
3244
3291
  sarr.push("}");
@@ -3292,11 +3339,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3292
3339
  `// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
3293
3340
  );
3294
3341
  const m = v.name + "Value";
3295
- const css = getParametersObj(s?.selectable || "");
3342
+ const css = parseParamString(s?.selectable || "");
3296
3343
  const cs = [];
3297
3344
  const ps2 = v.params || [];
3298
3345
  css.forEach((c, index) => {
3299
- const prop = c.prop;
3346
+ const prop = c.name;
3300
3347
  if (prop) {
3301
3348
  const key = prop + v.name;
3302
3349
  const val = ps2[index];
@@ -3403,7 +3450,7 @@ function setValStringify(v, key, propsText) {
3403
3450
  }
3404
3451
  }
3405
3452
  function getSpecType(val) {
3406
- let tarr = getType2(val?.type);
3453
+ let tarr = getType(val?.type);
3407
3454
  let type = "any";
3408
3455
  if (tarr.length == 1) {
3409
3456
  type = tarr[0].split("<")[0];
@@ -3436,7 +3483,7 @@ function getSpecType(val) {
3436
3483
  dataType: tarr
3437
3484
  };
3438
3485
  }
3439
- function getType2(value) {
3486
+ function getType(value) {
3440
3487
  let arr = [];
3441
3488
  let str = (value || "").trim().toLowerCase();
3442
3489
  str.split(",").forEach((v) => {
@@ -3123,53 +3123,99 @@ function getTypeValue(arr) {
3123
3123
  return "undefined";
3124
3124
  }
3125
3125
  }
3126
- function getType(str) {
3127
- let arr = [];
3128
- if (str) {
3129
- str = (str + "").trim();
3130
- if (str.startsWith("[")) {
3131
- str = str.substring(1, str.lastIndexOf("]"));
3132
- arr = str.split(",");
3126
+ function setDataType(arr) {
3127
+ return arr.join("|") || "any";
3128
+ }
3129
+ var splitIgnoringNesting = (str, delimiter) => {
3130
+ let bracketStack = [];
3131
+ let parts = [];
3132
+ let current = "";
3133
+ for (let i = 0; i < str.length; i++) {
3134
+ const char = str[i];
3135
+ if (char === "[" || char === "<" || char === "(") {
3136
+ bracketStack.push(char);
3137
+ current += char;
3138
+ } else if (char === "]" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack.length > 0 && bracketStack[bracketStack.length - 1] === "(") {
3139
+ bracketStack.pop();
3140
+ current += char;
3141
+ } else if (char === delimiter && bracketStack.length === 0) {
3142
+ parts.push(current.trim());
3143
+ current = "";
3133
3144
  } else {
3134
- const reg = /^\<([a-z|\<|\>|\|]+)\>/;
3135
- let rts = reg.exec(str);
3136
- if (rts && rts.length > 0) {
3137
- let ass = rts[1];
3138
- arr = ass.split("|");
3139
- } else {
3140
- arr = ["any"];
3141
- }
3145
+ current += char;
3142
3146
  }
3147
+ }
3148
+ if (current.trim() !== "") {
3149
+ parts.push(current.trim());
3150
+ }
3151
+ return parts;
3152
+ };
3153
+ var parseTypeDefinition = (typeDef) => {
3154
+ if (!typeDef || typeDef === "[]") {
3155
+ return { type: "any", dataType: ["any"] };
3156
+ } else if (typeDef.startsWith("[") && typeDef.endsWith("]")) {
3157
+ const inner = typeDef.slice(1, -1).trim();
3158
+ if (!inner) return { type: "any", dataType: ["any"] };
3159
+ const types = splitIgnoringNesting(inner, ",");
3160
+ return {
3161
+ type: types[0] || "any",
3162
+ dataType: types
3163
+ };
3164
+ } else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
3165
+ const inner = typeDef.slice(1, -1).trim();
3166
+ if (!inner) return { type: "any", dataType: ["any"] };
3167
+ const types = splitIgnoringNesting(inner, "|");
3168
+ return {
3169
+ type: types[0] || "any",
3170
+ dataType: types
3171
+ };
3143
3172
  } else {
3144
- arr = ["any"];
3173
+ return {
3174
+ type: typeDef,
3175
+ dataType: [typeDef]
3176
+ };
3145
3177
  }
3146
- return arr.map((o) => conversionType(o));
3147
- }
3148
- function setDataType(arr) {
3149
- return arr.join("|") || "any";
3150
- }
3151
- function getParametersObj(cs) {
3152
- let arrs = cs.split(",");
3153
- return arrs.map((key) => {
3154
- key = key.trim();
3155
- let must = true;
3156
- let vs = key.split(":");
3157
- let name = vs[0].trim();
3158
- if (name.endsWith("?")) {
3159
- must = false;
3160
- name = name.substring(0, name.length - 1);
3178
+ };
3179
+ function parseParamString(input) {
3180
+ const parts = splitIgnoringNesting(input, ",");
3181
+ return parts.map((trimmedPart) => {
3182
+ const label = trimmedPart.trim();
3183
+ const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
3184
+ if (!nameMatch) return null;
3185
+ const name = nameMatch[1].trim();
3186
+ const must = !nameMatch[2];
3187
+ const typeDefStart = nameMatch[0].length;
3188
+ const typeDef = trimmedPart.substring(typeDefStart).trim();
3189
+ let bracketStack = [];
3190
+ let endIndex = -1;
3191
+ let t = "";
3192
+ let description = "";
3193
+ for (let i = 0; i < typeDef.length; i++) {
3194
+ const char = typeDef[i];
3195
+ if (char === "[" || char === "<" || char === "(") {
3196
+ bracketStack.push(char);
3197
+ } else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
3198
+ bracketStack.pop();
3199
+ }
3200
+ if (bracketStack.length === 0 && i > 0) {
3201
+ endIndex = i == 1 ? 0 : i;
3202
+ t = typeDef.substring(0, endIndex + 1).trim();
3203
+ description = typeDef.substring(endIndex + 1);
3204
+ break;
3205
+ }
3161
3206
  }
3162
- let t = vs[1] || "";
3163
- let tarr = getSonType(getType(t));
3207
+ const { type, dataType } = parseTypeDefinition(t);
3208
+ const tarr = getSonType(dataType);
3164
3209
  return {
3165
- label: key,
3210
+ name,
3166
3211
  prop: name,
3167
- must,
3168
3212
  type: tarr[0],
3169
- dataType: tarr,
3170
- description: t.substring(t.lastIndexOf("]") + 1).trim()
3213
+ dataType,
3214
+ must,
3215
+ label,
3216
+ description
3171
3217
  };
3172
- });
3218
+ }).filter(Boolean);
3173
3219
  }
3174
3220
 
3175
3221
  // packages/components/use/code.ts
@@ -3218,12 +3264,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3218
3264
  tarr.push(" @" + name + '="' + strs + '"');
3219
3265
  const sp = getSpecObjs(es, name) || {};
3220
3266
  const s = sp.selectable || "";
3221
- const css = getParametersObj(s);
3267
+ const css = parseParamString(s);
3268
+ console.log(css);
3222
3269
  const cs = getParameStr(css);
3223
3270
  sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
3224
3271
  sarr.push("function " + strs + "(" + cs + ") {");
3225
3272
  css.forEach((o) => {
3226
- const name2 = o.prop || "arr";
3273
+ const name2 = o.name || "arr";
3227
3274
  sarr.push(" console.log('" + o.label + "', " + name2 + ")");
3228
3275
  });
3229
3276
  sarr.push("}");
@@ -3277,11 +3324,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3277
3324
  `// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
3278
3325
  );
3279
3326
  const m = v.name + "Value";
3280
- const css = getParametersObj(s?.selectable || "");
3327
+ const css = parseParamString(s?.selectable || "");
3281
3328
  const cs = [];
3282
3329
  const ps2 = v.params || [];
3283
3330
  css.forEach((c, index) => {
3284
- const prop = c.prop;
3331
+ const prop = c.name;
3285
3332
  if (prop) {
3286
3333
  const key = prop + v.name;
3287
3334
  const val = ps2[index];
@@ -3388,7 +3435,7 @@ function setValStringify(v, key, propsText) {
3388
3435
  }
3389
3436
  }
3390
3437
  function getSpecType(val) {
3391
- let tarr = getType2(val?.type);
3438
+ let tarr = getType(val?.type);
3392
3439
  let type = "any";
3393
3440
  if (tarr.length == 1) {
3394
3441
  type = tarr[0].split("<")[0];
@@ -3421,7 +3468,7 @@ function getSpecType(val) {
3421
3468
  dataType: tarr
3422
3469
  };
3423
3470
  }
3424
- function getType2(value) {
3471
+ function getType(value) {
3425
3472
  let arr = [];
3426
3473
  let str = (value || "").trim().toLowerCase();
3427
3474
  str.split(",").forEach((v) => {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const B=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const C=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const V=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const g=require("./util.cjs"),S=require("../../utils/props.cjs"),H=require("@fangzhongya/utils/basic/string/toFunction"),J=["class"];function j(s,t){return s.filter(e=>e.name==t)[0]}function N(s){return s.map(t=>(t.prop||"...arr")+":"+g.setDataType(t.dataType)).join(",")}function A(s,t,e,o,m,$){const f=[],n=[];let b=!0;const L=S.getPropsValue(t.propss||[]),P=S.getEmitsValue(t.emitss||[]),x=S.getExposeValue(t.exposes||[]),z=S.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let p=e[r];if(/^on[A-Z]/.test(r)&&typeof p=="function"){let i=r.substring(2);const c=r.split(":");let a;if(c.length>1?(a=c[0]+c.slice(1).map(l=>V.firstUpper(l)).join(""),i=C.firstLower(i)):(a=c[0],i=B.humpToLine(i)),c.includes("-")){let l=a.split("-");l=l.map((h,T)=>T!=0?V.firstUpper(h):h),a=l.join("")}f.push(" @"+i+'="'+a+'"');const u=j(P,i)||{},y=u.selectable||"",q=g.getParametersObj(y),d=N(q);n.push(`// ${u.description} ${u.name}: (${u.selectable})`),n.push("function "+a+"("+d+") {"),q.forEach(l=>{const h=l.prop||"arr";n.push(" console.log('"+l.label+"', "+h+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),f.push(" :"+r+'="'+i+'"');const c=j(L,r)||{},a=D(c);if(n.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof p=="function")n.push("const "+r+" = "+F(p,r,m));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof p>"u"){const u=g.getTypeValue(a.dataType);u=="()=>{}"?n.push("const "+i+" = "+u+";"):n.push("const "+i+" = ref("+(u==="undefined"?"":u)+");")}else{let u=E(p,r,m);n.push("const "+i+" = ref("+u+");")}}});const O=Object.values($||{});O.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),f.unshift(' ref="refDom"'),n.push("const refDom = ref()"),O.forEach(r=>{const p=j(x,r.name)||{};n.push(`// ${p.description} ${p.name}:(${p.selectable}) ${p.type}`);const i=r.name+"Value",c=g.getParametersObj(p?.selectable||""),a=[],u=r.params||[];c.forEach((y,q)=>{const d=y.prop;if(d){const l=d+r.name,h=u[q];if(n.push(`// ${y.label}`),typeof h=="function")n.push("const "+l+" = "+F(h,d,r.text));else if(typeof h>"u")n.push("const "+l+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(h,d,r.text);n.push("const "+l+" = "+T+";")}a.push(l)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${a.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${p.type}"', ${i})`)})),f.length>0&&f.unshift("");const U=M(o,z);return`<!--${s}-->
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const B=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const C=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const F=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const g=require("./util.cjs"),q=require("../../utils/props.cjs"),H=require("@fangzhongya/utils/basic/string/toFunction"),J=["class"];function j(s,t){return s.filter(e=>e.name==t)[0]}function N(s){return s.map(t=>(t.prop||"...arr")+":"+g.setDataType(t.dataType)).join(",")}function A(s,t,e,o,m,$){const f=[],n=[];let S=!0;const L=q.getPropsValue(t.propss||[]),P=q.getEmitsValue(t.emitss||[]),x=q.getExposeValue(t.exposes||[]),z=q.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let a=e[r];if(/^on[A-Z]/.test(r)&&typeof a=="function"){let i=r.substring(2);const c=r.split(":");let p;if(c.length>1?(p=c[0]+c.slice(1).map(l=>F.firstUpper(l)).join(""),i=C.firstLower(i)):(p=c[0],i=B.humpToLine(i)),c.includes("-")){let l=p.split("-");l=l.map((h,T)=>T!=0?F.firstUpper(h):h),p=l.join("")}f.push(" @"+i+'="'+p+'"');const u=j(P,i)||{},y=u.selectable||"",b=g.parseParamString(y);console.log(b);const d=N(b);n.push(`// ${u.description} ${u.name}: (${u.selectable})`),n.push("function "+p+"("+d+") {"),b.forEach(l=>{const h=l.name||"arr";n.push(" console.log('"+l.label+"', "+h+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),f.push(" :"+r+'="'+i+'"');const c=j(L,r)||{},p=D(c);if(n.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof a=="function")n.push("const "+r+" = "+O(a,r,m));else if(S&&(S=!1,n.unshift("import { ref } from 'vue';")),typeof a>"u"){const u=g.getTypeValue(p.dataType);u=="()=>{}"?n.push("const "+i+" = "+u+";"):n.push("const "+i+" = ref("+(u==="undefined"?"":u)+");")}else{let u=E(a,r,m);n.push("const "+i+" = ref("+u+");")}}});const V=Object.values($||{});V.length>0&&(S&&(S=!1,n.unshift("import { ref } from 'vue';")),f.unshift(' ref="refDom"'),n.push("const refDom = ref()"),V.forEach(r=>{const a=j(x,r.name)||{};n.push(`// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`);const i=r.name+"Value",c=g.parseParamString(a?.selectable||""),p=[],u=r.params||[];c.forEach((y,b)=>{const d=y.name;if(d){const l=d+r.name,h=u[b];if(n.push(`// ${y.label}`),typeof h=="function")n.push("const "+l+" = "+O(h,d,r.text));else if(typeof h>"u")n.push("const "+l+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(h,d,r.text);n.push("const "+l+" = "+T+";")}p.push(l)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${p.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${a.type}"', ${i})`)})),f.length>0&&f.unshift("");const U=M(o,z);return`<!--${s}-->
2
2
  <template>
3
3
  <div>
4
4
  <${s}${f.join(`
@@ -14,6 +14,6 @@ ${n.join(`
14
14
  `}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const m=j(t,o)||{},$=s[o];if($){const f=` <!-- ${m.description} ${m.name}:(${m.selectable}) -->
15
15
  <template #${o}="scope">
16
16
  ${g.vueFormat($," ")}
17
- </template>`;e.push(f)}}),e&&e.length>0&&e.unshift(""),e}function F(s,t,e){const o=e?e[t]:"";return o||w(s.toString())}function w(s){const t=H.getFunctionFormat(g.prettierFormat(s));if(t){let e=`{
17
+ </template>`;e.push(f)}}),e&&e.length>0&&e.unshift(""),e}function O(s,t,e){const o=e?e[t]:"";return o||w(s.toString())}function w(s){const t=H.getFunctionFormat(g.prettierFormat(s));if(t){let e=`{
18
18
  ${g.vueFormat(g.getFunBody(t.body)," ")}
19
19
  }`;return`function (${t.param}) ${e}`}else return"undefined"}function Z(s){const t=s.trim();return/^\(/.test(t)?w(t):JSON.stringify(s)}function E(s,t,e){const o=e?e[t]:"";return o||(typeof s=="string"?Z(s+""):JSON.stringify(s))}function D(s){let t=G(s?.type),e="any";t.length==1&&(e=t[0].split("<")[0]);const o=e;let m=(s?.selectable||"").trim(),$=[];return m&&e!="boolean"&&(m.split(",").forEach(f=>{if(f){let n=f.split(":");$.push({label:f,prop:n[0].trim()})}}),e=="function"?e="function":e=="array"?e="choice":e="select"),{arr:$,zdtype:o,type:e,dataType:t}}function G(s){let t=[];return(s||"").trim().toLowerCase().split(",").forEach(o=>{o=o.trim(),o&&t.push(o)}),[...new Set(t)].sort()}exports.getHmtl=A;exports.getSpecType=D;exports.setValStringify=E;
@@ -6,22 +6,22 @@ import "@fangzhongya/utils/basic/string/appearNum";
6
6
  import { firstLower as N } from "@fangzhongya/utils/basic/string/firstLower";
7
7
  import "@fangzhongya/utils/basic/array/duplicateRemoval";
8
8
  import "@fangzhongya/utils/basic/array/asyncMergeArray";
9
- import { firstUpper as O } from "@fangzhongya/utils/basic/string/firstUpper";
9
+ import { firstUpper as V } from "@fangzhongya/utils/basic/string/firstUpper";
10
10
  import "@fangzhongya/utils/urls/getSuffix";
11
11
  import "@fangzhongya/utils/basic/array/replaceAfter";
12
- import { getParametersObj as V, getTypeValue as F, setDataType as A, vueFormat as w, prettierFormat as H, getFunBody as U } from "./util.js";
12
+ import { parseParamString as F, getTypeValue as O, setDataType as A, vueFormat as w, prettierFormat as H, getFunBody as U } from "./util.js";
13
13
  import { getPropsValue as Z, getEmitsValue as q, getExposeValue as G, getSlotValue as I } from "../../utils/props.js";
14
14
  import { getFunctionFormat as K } from "@fangzhongya/utils/basic/string/toFunction";
15
15
  const M = ["class"];
16
- function j(s, e) {
16
+ function S(s, e) {
17
17
  return s.filter((t) => t.name == e)[0];
18
18
  }
19
19
  function Q(s) {
20
20
  return s.map((e) => (e.prop || "...arr") + ":" + A(e.dataType)).join(",");
21
21
  }
22
22
  function at(s, e, t, r, m, $) {
23
- const f = [], n = [];
24
- let y = !0;
23
+ const p = [], n = [];
24
+ let b = !0;
25
25
  const z = Z(e.propss || []), L = q(e.emitss || []), P = G(e.exposes || []), B = I(e.slots || []);
26
26
  Object.keys(t).forEach((o) => {
27
27
  let u = t[o];
@@ -29,28 +29,30 @@ function at(s, e, t, r, m, $) {
29
29
  let i = o.substring(2);
30
30
  const c = o.split(":");
31
31
  let a;
32
- if (c.length > 1 ? (a = c[0] + c.slice(1).map((p) => O(p)).join(""), i = N(i)) : (a = c[0], i = J(i)), c.includes("-")) {
33
- let p = a.split("-");
34
- p = p.map((h, S) => S != 0 ? O(h) : h), a = p.join("");
32
+ if (c.length > 1 ? (a = c[0] + c.slice(1).map((f) => V(f)).join(""), i = N(i)) : (a = c[0], i = J(i)), c.includes("-")) {
33
+ let f = a.split("-");
34
+ f = f.map((h, j) => j != 0 ? V(h) : h), a = f.join("");
35
35
  }
36
- f.push(" @" + i + '="' + a + '"');
37
- const l = j(L, i) || {}, d = l.selectable || "", b = V(d), g = Q(b);
38
- n.push(`// ${l.description} ${l.name}: (${l.selectable})`), n.push("function " + a + "(" + g + ") {"), b.forEach((p) => {
39
- const h = p.prop || "arr";
40
- n.push(" console.log('" + p.label + "', " + h + ")");
36
+ p.push(" @" + i + '="' + a + '"');
37
+ const l = S(L, i) || {}, d = l.selectable || "", y = F(d);
38
+ console.log(y);
39
+ const g = Q(y);
40
+ n.push(`// ${l.description} ${l.name}: (${l.selectable})`), n.push("function " + a + "(" + g + ") {"), y.forEach((f) => {
41
+ const h = f.name || "arr";
42
+ n.push(" console.log('" + f.label + "', " + h + ")");
41
43
  }), n.push("}");
42
44
  } else {
43
45
  let i = o;
44
- M.includes(o) && (i = o + "1"), f.push(" :" + o + '="' + i + '"');
45
- const c = j(z, o) || {}, a = X(c);
46
+ M.includes(o) && (i = o + "1"), p.push(" :" + o + '="' + i + '"');
47
+ const c = S(z, o) || {}, a = X(c);
46
48
  if (n.push(
47
49
  `// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`
48
50
  ), typeof u == "function")
49
51
  n.push(
50
52
  "const " + o + " = " + T(u, o, m)
51
53
  );
52
- else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof u > "u") {
53
- const l = F(a.dataType);
54
+ else if (b && (b = !1, n.unshift("import { ref } from 'vue';")), typeof u > "u") {
55
+ const l = O(a.dataType);
54
56
  l == "()=>{}" ? n.push("const " + i + " = " + l + ";") : n.push(
55
57
  "const " + i + " = ref(" + (l === "undefined" ? "" : l) + ");"
56
58
  );
@@ -61,39 +63,39 @@ function at(s, e, t, r, m, $) {
61
63
  }
62
64
  });
63
65
  const E = Object.values($ || {});
64
- E.length > 0 && (y && (y = !1, n.unshift("import { ref } from 'vue';")), f.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
65
- const u = j(P, o.name) || {};
66
+ E.length > 0 && (b && (b = !1, n.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
67
+ const u = S(P, o.name) || {};
66
68
  n.push(
67
69
  `// ${u.description} ${u.name}:(${u.selectable}) ${u.type}`
68
70
  );
69
- const i = o.name + "Value", c = V(u?.selectable || ""), a = [], l = o.params || [];
70
- c.forEach((d, b) => {
71
- const g = d.prop;
71
+ const i = o.name + "Value", c = F(u?.selectable || ""), a = [], l = o.params || [];
72
+ c.forEach((d, y) => {
73
+ const g = d.name;
72
74
  if (g) {
73
- const p = g + o.name, h = l[b];
75
+ const f = g + o.name, h = l[y];
74
76
  if (n.push(`// ${d.label}`), typeof h == "function")
75
77
  n.push(
76
- "const " + p + " = " + T(h, g, o.text)
78
+ "const " + f + " = " + T(h, g, o.text)
77
79
  );
78
80
  else if (typeof h > "u")
79
81
  n.push(
80
- "const " + p + " = " + F(d.dataType) + ";"
82
+ "const " + f + " = " + O(d.dataType) + ";"
81
83
  );
82
84
  else {
83
- let S = D(h, g, o.text);
84
- n.push("const " + p + " = " + S + ";");
85
+ let j = D(h, g, o.text);
86
+ n.push("const " + f + " = " + j + ";");
85
87
  }
86
- a.push(p);
88
+ a.push(f);
87
89
  }
88
90
  }), o.type === "function" ? n.push(
89
91
  `const ${i} = refDom.value?.${o.name}(${a.join(", ")})`
90
92
  ) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${u.type}"', ${i})`);
91
- })), f.length > 0 && f.unshift("");
93
+ })), p.length > 0 && p.unshift("");
92
94
  const C = R(r, B);
93
95
  return `<!--${s}-->
94
96
  <template>
95
97
  <div>
96
- <${s}${f.join(`
98
+ <${s}${p.join(`
97
99
  `)}>${C.join(`
98
100
  `)}
99
101
  </${s}>
@@ -108,13 +110,13 @@ ${n.join(`
108
110
  function R(s = {}, e) {
109
111
  const t = [];
110
112
  return Object.keys(s).forEach((r) => {
111
- const m = j(e, r) || {}, $ = s[r];
113
+ const m = S(e, r) || {}, $ = s[r];
112
114
  if ($) {
113
- const f = ` <!-- ${m.description} ${m.name}:(${m.selectable}) -->
115
+ const p = ` <!-- ${m.description} ${m.name}:(${m.selectable}) -->
114
116
  <template #${r}="scope">
115
117
  ${w($, " ")}
116
118
  </template>`;
117
- t.push(f);
119
+ t.push(p);
118
120
  }
119
121
  }), t && t.length > 0 && t.unshift(""), t;
120
122
  }
@@ -145,11 +147,11 @@ function X(s) {
145
147
  e.length == 1 && (t = e[0].split("<")[0]);
146
148
  const r = t;
147
149
  let m = (s?.selectable || "").trim(), $ = [];
148
- return m && t != "boolean" && (m.split(",").forEach((f) => {
149
- if (f) {
150
- let n = f.split(":");
150
+ return m && t != "boolean" && (m.split(",").forEach((p) => {
151
+ if (p) {
152
+ let n = p.split(":");
151
153
  $.push({
152
- label: f,
154
+ label: p,
153
155
  prop: n[0].trim()
154
156
  });
155
157
  }
@@ -1 +1 @@
1
- "use strict";const e=require("vue"),d=require("../../util.cjs"),g=require("../index.vue.cjs");;/* empty css */const y={class:"expose"},h={class:"expose-label"},x={class:"expose-return"},b=e.defineComponent({__name:"index",props:{getRef:{type:Function},name:String,value:{type:Object}},emits:["change"],setup(p,{emit:v}){const a=p,m=v,c=e.ref(""),o=e.ref(""),i=e.ref([]),f=e.computed(()=>{i.value=[];const t=a.value;if(t&&t.name){let l=(t.selectable+"").trim();if(c.value=t.name+": "+t.description+" 入参=("+l+") 返回值: "+t.type,l){let n=d.getParametersObj(l);return n.forEach(r=>{i.value.push(r.prop)}),n}}return[]});function _(t,l){let n=a.getRef?a.getRef():void 0,r=a.value?.name;if(r){let u=i.value.map(s=>t[s]);if(n&&n[r]){if(typeof n[r]=="function"){let s=n[r](...u);o.value=JSON.stringify(s)}else{let s=n[r];s instanceof HTMLDivElement?o.value=s.outerHTML:o.value=JSON.stringify(s)}m("change",r,u,typeof n[r],l)}}else console.log("请选择方法")}return(t,l)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",h,e.toDisplayString(c.value||"请选择方法"),1),e.createVNode(g,{list:f.value,name:a.name,queryName:"调用",onQuery:_},null,8,["list","name"]),e.createElementVNode("div",x,e.toDisplayString(a.value?.type)+"返回值:"+e.toDisplayString(o.value),1)]))}});module.exports=b;
1
+ "use strict";const e=require("vue"),d=require("../../util.cjs"),g=require("../index.vue.cjs");;/* empty css */const y={class:"expose"},h={class:"expose-label"},x={class:"expose-return"},S=e.defineComponent({__name:"index",props:{getRef:{type:Function},name:String,value:{type:Object}},emits:["change"],setup(p,{emit:m}){const s=p,v=m,c=e.ref(""),i=e.ref(""),o=e.ref([]),f=e.computed(()=>{o.value=[];const n=s.value;if(n&&n.name){let l=(n.selectable+"").trim();if(c.value=n.name+": "+n.description+" 入参=("+l+") 返回值: "+n.type,l){let r=d.parseParamString(l);return r.forEach(t=>{t.prop=t.name,o.value.push(t.name)}),r}}return[]});function _(n,l){let r=s.getRef?s.getRef():void 0,t=s.value?.name;if(t){let u=o.value.map(a=>n[a]);if(r&&r[t]){if(typeof r[t]=="function"){let a=r[t](...u);i.value=JSON.stringify(a)}else{let a=r[t];a instanceof HTMLDivElement?i.value=a.outerHTML:i.value=JSON.stringify(a)}v("change",t,u,typeof r[t],l)}}else console.log("请选择方法")}return(n,l)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",h,e.toDisplayString(c.value||"请选择方法"),1),e.createVNode(g,{list:f.value,name:s.name,queryName:"调用",onQuery:_},null,8,["list","name"]),e.createElementVNode("div",x,e.toDisplayString(s.value?.type)+"返回值:"+e.toDisplayString(i.value),1)]))}});module.exports=S;
@@ -1,8 +1,8 @@
1
- import { defineComponent as y, ref as i, computed as h, createElementBlock as b, openBlock as x, createElementVNode as p, createVNode as N, toDisplayString as c } from "vue";
2
- import { getParametersObj as E } from "../../util.js";
3
- import O from "../index.vue.js";
1
+ import { defineComponent as y, ref as i, computed as h, createElementBlock as x, openBlock as b, createElementVNode as p, createVNode as N, toDisplayString as c } from "vue";
2
+ import { parseParamString as S } from "../../util.js";
3
+ import E from "../index.vue.js";
4
4
  /* empty css */
5
- const S = { class: "expose" }, j = { class: "expose-label" }, R = { class: "expose-return" }, J = /* @__PURE__ */ y({
5
+ const O = { class: "expose" }, R = { class: "expose-label" }, j = { class: "expose-return" }, J = /* @__PURE__ */ y({
6
6
  __name: "index",
7
7
  props: {
8
8
  getRef: {
@@ -15,46 +15,46 @@ const S = { class: "expose" }, j = { class: "expose-label" }, R = { class: "expo
15
15
  },
16
16
  emits: ["change"],
17
17
  setup(f, { emit: v }) {
18
- const a = f, d = v, u = i(""), r = i(""), s = i([]), _ = h(() => {
18
+ const o = f, d = v, m = i(""), r = i(""), s = i([]), _ = h(() => {
19
19
  s.value = [];
20
- const e = a.value;
21
- if (e && e.name) {
22
- let l = (e.selectable + "").trim();
23
- if (u.value = e.name + ": " + e.description + " 入参=(" + l + ") 返回值: " + e.type, l) {
24
- let t = E(l);
25
- return t.forEach((n) => {
26
- s.value.push(n.prop);
27
- }), t;
20
+ const t = o.value;
21
+ if (t && t.name) {
22
+ let l = (t.selectable + "").trim();
23
+ if (m.value = t.name + ": " + t.description + " 入参=(" + l + ") 返回值: " + t.type, l) {
24
+ let n = S(l);
25
+ return n.forEach((e) => {
26
+ e.prop = e.name, s.value.push(e.name);
27
+ }), n;
28
28
  }
29
29
  }
30
30
  return [];
31
31
  });
32
- function g(e, l) {
33
- let t = a.getRef ? a.getRef() : void 0, n = a.value?.name;
34
- if (n) {
35
- let m = s.value.map((o) => e[o]);
36
- if (t && t[n]) {
37
- if (typeof t[n] == "function") {
38
- let o = t[n](...m);
39
- r.value = JSON.stringify(o);
32
+ function g(t, l) {
33
+ let n = o.getRef ? o.getRef() : void 0, e = o.value?.name;
34
+ if (e) {
35
+ let u = s.value.map((a) => t[a]);
36
+ if (n && n[e]) {
37
+ if (typeof n[e] == "function") {
38
+ let a = n[e](...u);
39
+ r.value = JSON.stringify(a);
40
40
  } else {
41
- let o = t[n];
42
- o instanceof HTMLDivElement ? r.value = o.outerHTML : r.value = JSON.stringify(o);
41
+ let a = n[e];
42
+ a instanceof HTMLDivElement ? r.value = a.outerHTML : r.value = JSON.stringify(a);
43
43
  }
44
- d("change", n, m, typeof t[n], l);
44
+ d("change", e, u, typeof n[e], l);
45
45
  }
46
46
  } else
47
47
  console.log("请选择方法");
48
48
  }
49
- return (e, l) => (x(), b("div", S, [
50
- p("div", j, c(u.value || "请选择方法"), 1),
51
- N(O, {
49
+ return (t, l) => (b(), x("div", O, [
50
+ p("div", R, c(m.value || "请选择方法"), 1),
51
+ N(E, {
52
52
  list: _.value,
53
- name: a.name,
53
+ name: o.name,
54
54
  queryName: "调用",
55
55
  onQuery: g
56
56
  }, null, 8, ["list", "name"]),
57
- p("div", R, c(a.value?.type) + "返回值:" + c(r.value), 1)
57
+ p("div", j, c(o.value?.type) + "返回值:" + c(r.value), 1)
58
58
  ]));
59
59
  }
60
60
  });
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@fangzhongya/utils/basic/string/toFunction"),m=require("@fangzhongya/utils/basic/string/firstLower");function l(e){return e.replace(/\;(\s|\n\r)*$/,"")}function d(e){return e="let a = "+e,l(e).replace(/^let a = /,"")}function j(e){return l(e)}function T(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 F=["Boolean","Any","String","Number","Array","Object","Function"];function c(e){return F.includes(e)?m.firstLower(e):e}function $(e){let r=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(r&&r.length>0)return{own:c(r[1]),son:r[2]}}function p(e,t){let r=$(e);r?(t.push(r.own),r.son&&p(r.son,t)):t.push(e)}function s(e){e instanceof Array&&(e=e[0]);const t=[];return e&&p(e,t),t}function g(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 O(e,t){const r=g(e),n=s(t)[0];return n&&n!="any"?r==n:!0}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 v(e){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let t="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?t="string":/^\[(.|\n|\r)*\]$/.test(e)?t="array":/^\{(.|\n|\r)*\}$/.test(e)?t="object":/^[0-9]*$/.test(e)?t="number":e==="true"||e==="false"?t="boolean":e=="undefined"?t="undefined":e=="null"?t="null":e&&(t="string"),t}function y(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let r=y(e.splice(1));return r=r=="undefined"?"":r,`[${r}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function w(e){let t=[];if(e)if(e=(e+"").trim(),e.startsWith("["))e=e.substring(1,e.lastIndexOf("]")),t=e.split(",");else{let n=/^\<([a-z|\<|\>|\|]+)\>/.exec(e);n&&n.length>0?t=n[1].split("|"):t=["any"]}else t=["any"];return t.map(r=>c(r))}function S(e){return e.join("|")||"any"}function x(e){return e.split(",").map(r=>{r=r.trim();let n=!0,i=r.split(":"),u=i[0].trim();u.endsWith("?")&&(n=!1,u=u.substring(0,u.length-1));let o=i[1]||"",a=s(w(o));return{label:r,prop:u,must:n,type:a[0],dataType:a,description:o.substring(o.lastIndexOf("]")+1).trim()}})}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>b.getFunctionFormat});exports.getFunBody=f;exports.getObjType=g;exports.getParametersObj=x;exports.getSonType=s;exports.getString=h;exports.getTypeValue=y;exports.isDefaultType=v;exports.isTypeEqual=O;exports.prettierArrFormat=j;exports.prettierFormat=l;exports.prettierObjFormat=d;exports.setDataType=S;exports.vueFormat=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@fangzhongya/utils/basic/string/toFunction"),w=require("@fangzhongya/utils/basic/string/firstLower");function g(e){return e.replace(/\;(\s|\n\r)*$/,"")}function O(e){return e="let a = "+e,g(e).replace(/^let a = /,"")}function x(e){return g(e)}function A(e,n=""){let t=(e+"").trim().split(/\n/);return t=t.map(r=>n+r),t.join(`
2
+ `)}function d(e=""){e=e.trim();let n=`[\\s|\\n|\\r]*\\{((.|
3
+ |\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?d(r[1]):e}const k=["Boolean","Any","String","Number","Array","Object","Function"];function q(e){return k.includes(e)?w.firstLower(e):e}function B(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:q(t[1]),son:t[2]}}function T(e,n){let t=B(e);t?(n.push(t.own),t.son&&T(t.son,n)):n.push(e)}function y(e){e instanceof Array&&(e=e[0]);const n=[];return e&&T(e,n),n}function j(e){const n=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(n),i=typeof e;return r&&r.length>0&&(i=r[1].toLowerCase()),i}function E(e,n){const t=j(e),r=y(n)[0];return r&&r!="any"?t==r:!0}function L(e){if(typeof e=="string"){let n=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(n=!0),n&&(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 W(e){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let n="";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}function F(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let t=F(e.splice(1));return t=t=="undefined"?"":t,`[${t}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function C(e){return e.join("|")||"any"}const p=(e,n)=>{let t=[],r=[],i="";for(let a=0;a<e.length;a++){const o=e[a];o==="["||o==="<"||o==="("?(t.push(o),i+=o):o==="]"&&t.length>0&&t[t.length-1]==="["||o===">"&&t.length>0&&t[t.length-1]==="<"||o===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),i+=o):o===n&&t.length===0?(r.push(i.trim()),i=""):i+=o}return i.trim()!==""&&r.push(i.trim()),r},I=e=>{if(!e||e==="[]")return{type:"any",dataType:["any"]};if(e.startsWith("[")&&e.endsWith("]")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=p(n,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=p(n,"|");return{type:t[0]||"any",dataType:t}}else return{type:e,dataType:[e]}};function M(e){return p(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const a=i[1].trim(),o=!i[2],$=i[0].length,c=t.substring($).trim();let s=[],f=-1,h="",m="";for(let u=0;u<c.length;u++){const l=c[u];if(l==="["||l==="<"||l==="("?s.push(l):(l==="]"&&s[s.length-1]==="["||l===">"&&s[s.length-1]==="<"||l===")"&&s[s.length-1]==="(")&&s.pop(),s.length===0&&u>0){f=u==1?0:u,h=c.substring(0,f+1).trim(),m=c.substring(f+1);break}}const{type:N,dataType:b}=I(h),S=y(b);return{name:a,prop:a,type:S[0],dataType:b,must:o,label:r,description:m}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>v.getFunctionFormat});exports.getFunBody=d;exports.getObjType=j;exports.getSonType=y;exports.getString=L;exports.getTypeValue=F;exports.isDefaultType=W;exports.isTypeEqual=E;exports.parseParamString=M;exports.prettierArrFormat=x;exports.prettierFormat=g;exports.prettierObjFormat=O;exports.setDataType=C;exports.vueFormat=A;
@@ -45,3 +45,12 @@ export declare function getParametersObj(cs: string): {
45
45
  dataType: string[];
46
46
  description: string;
47
47
  }[];
48
+ export declare function parseParamString(input: string): Array<{
49
+ name: string;
50
+ prop: string;
51
+ type: string;
52
+ dataType: string[];
53
+ must: boolean;
54
+ label: string;
55
+ description: string;
56
+ }>;
@@ -1,26 +1,26 @@
1
- import { getFunctionFormat as L } from "@fangzhongya/utils/basic/string/toFunction";
2
- import { firstLower as p } from "@fangzhongya/utils/basic/string/firstLower";
3
- function s(e) {
1
+ import { getFunctionFormat as V } from "@fangzhongya/utils/basic/string/toFunction";
2
+ import { firstLower as j } from "@fangzhongya/utils/basic/string/firstLower";
3
+ function m(e) {
4
4
  return e.replace(/\;(\s|\n\r)*$/, "");
5
5
  }
6
- function h(e) {
7
- return e = "let a = " + e, s(e).replace(/^let a = /, "");
6
+ function B(e) {
7
+ return e = "let a = " + e, m(e).replace(/^let a = /, "");
8
8
  }
9
- function T(e) {
10
- return s(e);
9
+ function E(e) {
10
+ return m(e);
11
11
  }
12
- function x(e, t = "") {
13
- let n = (e + "").trim().split(/\n/);
14
- return n = n.map((r) => t + r), n.join(`
12
+ function L(e, n = "") {
13
+ let t = (e + "").trim().split(/\n/);
14
+ return t = t.map((r) => n + r), t.join(`
15
15
  `);
16
16
  }
17
- function g(e = "") {
17
+ function S(e = "") {
18
18
  e = e.trim();
19
- let t = `[\\s|\\n|\\r]*\\{((.|
20
- |\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + t + "$").exec(e);
21
- return r && r.length > 0 ? g(r[1]) : e;
19
+ let n = `[\\s|\\n|\\r]*\\{((.|
20
+ |\r)+?)\\}[\\s|\\n|\\r]*`, r = new RegExp("^" + n + "$").exec(e);
21
+ return r && r.length > 0 ? S(r[1]) : e;
22
22
  }
23
- const y = [
23
+ const w = [
24
24
  "Boolean",
25
25
  "Any",
26
26
  "String",
@@ -29,47 +29,47 @@ const y = [
29
29
  "Object",
30
30
  "Function"
31
31
  ];
32
- function f(e) {
33
- return y.includes(e) ? p(e) : e;
32
+ function x(e) {
33
+ return w.includes(e) ? j(e) : e;
34
34
  }
35
- function m(e) {
36
- let n = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
37
- if (n && n.length > 0)
35
+ function F(e) {
36
+ let t = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
37
+ if (t && t.length > 0)
38
38
  return {
39
- own: f(n[1]),
40
- son: n[2]
39
+ own: x(t[1]),
40
+ son: t[2]
41
41
  };
42
42
  }
43
- function a(e, t) {
44
- let n = m(e);
45
- n ? (t.push(n.own), n.son && a(n.son, t)) : t.push(e);
43
+ function d(e, n) {
44
+ let t = F(e);
45
+ t ? (n.push(t.own), t.son && d(t.son, n)) : n.push(e);
46
46
  }
47
- function c(e) {
47
+ function b(e) {
48
48
  e instanceof Array && (e = e[0]);
49
- const t = [];
50
- return e && a(e, t), t;
49
+ const n = [];
50
+ return e && d(e, n), n;
51
51
  }
52
- function b(e) {
53
- const t = Object.prototype.toString.call(e);
54
- let r = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
52
+ function v(e) {
53
+ const n = Object.prototype.toString.call(e);
54
+ let r = /^\[[O|o]bject (.*)\]$/.exec(n), i = typeof e;
55
55
  return r && r.length > 0 && (i = r[1].toLowerCase()), i;
56
56
  }
57
- function v(e, t) {
58
- const n = b(e), r = c(t)[0];
59
- return r && r != "any" ? n == r : !0;
57
+ function C(e, n) {
58
+ const t = v(e), r = b(n)[0];
59
+ return r && r != "any" ? t == r : !0;
60
60
  }
61
- function w(e) {
61
+ function I(e) {
62
62
  if (typeof e == "string") {
63
- let t = !1;
64
- return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (t = !0), t && (e = e.substring(1, e.length - 1)), e + "";
63
+ let n = !1;
64
+ return (/^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e)) && (n = !0), n && (e = e.substring(1, e.length - 1)), e + "";
65
65
  } else return typeof e == "object" && e ? e.toString() : typeof e > "u" || typeof e == "object" && !e ? "" : e + "";
66
66
  }
67
- function F(e) {
67
+ function N(e) {
68
68
  e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
69
- let t = "";
70
- return /^\'(.|\n|\r)*\'$/.test(e) || /^\"(.|\n|\r)*\"$/.test(e) || /^\`(.|\n|\r)*\`$/.test(e) ? t = "string" : /^\[(.|\n|\r)*\]$/.test(e) ? t = "array" : /^\{(.|\n|\r)*\}$/.test(e) ? t = "object" : /^[0-9]*$/.test(e) ? t = "number" : e === "true" || e === "false" ? t = "boolean" : e == "undefined" ? t = "undefined" : e == "null" ? t = "null" : e && (t = "string"), t;
69
+ let n = "";
70
+ 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;
71
71
  }
72
- function d(e) {
72
+ function k(e) {
73
73
  switch ((e[0] || "any").toLowerCase()) {
74
74
  case "string":
75
75
  return '""';
@@ -78,8 +78,8 @@ function d(e) {
78
78
  case "number":
79
79
  return "0";
80
80
  case "array":
81
- let n = d(e.splice(1));
82
- return n = n == "undefined" ? "" : n, `[${n}]`;
81
+ let t = k(e.splice(1));
82
+ return t = t == "undefined" ? "" : t, `[${t}]`;
83
83
  case "object":
84
84
  return "{}";
85
85
  case "function":
@@ -90,51 +90,79 @@ function d(e) {
90
90
  return "undefined";
91
91
  }
92
92
  }
93
- function $(e) {
94
- let t = [];
95
- if (e)
96
- if (e = (e + "").trim(), e.startsWith("["))
97
- e = e.substring(1, e.lastIndexOf("]")), t = e.split(",");
98
- else {
99
- let r = /^\<([a-z|\<|\>|\|]+)\>/.exec(e);
100
- r && r.length > 0 ? t = r[1].split("|") : t = ["any"];
101
- }
102
- else
103
- t = ["any"];
104
- return t.map((n) => f(n));
105
- }
106
- function O(e) {
93
+ function R(e) {
107
94
  return e.join("|") || "any";
108
95
  }
109
- function A(e) {
110
- return e.split(",").map((n) => {
111
- n = n.trim();
112
- let r = !0, i = n.split(":"), l = i[0].trim();
113
- l.endsWith("?") && (r = !1, l = l.substring(0, l.length - 1));
114
- let u = i[1] || "", o = c($(u));
96
+ const p = (e, n) => {
97
+ let t = [], r = [], i = "";
98
+ for (let u = 0; u < e.length; u++) {
99
+ const s = e[u];
100
+ s === "[" || s === "<" || s === "(" ? (t.push(s), i += s) : s === "]" && t.length > 0 && t[t.length - 1] === "[" || s === ">" && t.length > 0 && t[t.length - 1] === "<" || s === ")" && t.length > 0 && t[t.length - 1] === "(" ? (t.pop(), i += s) : s === n && t.length === 0 ? (r.push(i.trim()), i = "") : i += s;
101
+ }
102
+ return i.trim() !== "" && r.push(i.trim()), r;
103
+ }, A = (e) => {
104
+ if (!e || e === "[]")
105
+ return { type: "any", dataType: ["any"] };
106
+ if (e.startsWith("[") && e.endsWith("]")) {
107
+ const n = e.slice(1, -1).trim();
108
+ if (!n) return { type: "any", dataType: ["any"] };
109
+ const t = p(n, ",");
110
+ return {
111
+ type: t[0] || "any",
112
+ dataType: t
113
+ };
114
+ } else if (e.startsWith("<") && e.endsWith(">")) {
115
+ const n = e.slice(1, -1).trim();
116
+ if (!n) return { type: "any", dataType: ["any"] };
117
+ const t = p(n, "|");
118
+ return {
119
+ type: t[0] || "any",
120
+ dataType: t
121
+ };
122
+ } else
123
+ return {
124
+ type: e,
125
+ dataType: [e]
126
+ };
127
+ };
128
+ function q(e) {
129
+ return p(e, ",").map((t) => {
130
+ const r = t.trim(), i = t.match(/^([^:?]+)(\??):/);
131
+ if (!i) return null;
132
+ const u = i[1].trim(), s = !i[2], T = i[0].length, c = t.substring(T).trim();
133
+ let o = [], f = -1, g = "", y = "";
134
+ for (let a = 0; a < c.length; a++) {
135
+ const l = c[a];
136
+ if (l === "[" || l === "<" || l === "(" ? o.push(l) : (l === "]" && o[o.length - 1] === "[" || l === ">" && o[o.length - 1] === "<" || l === ")" && o[o.length - 1] === "(") && o.pop(), o.length === 0 && a > 0) {
137
+ f = a == 1 ? 0 : a, g = c.substring(0, f + 1).trim(), y = c.substring(f + 1);
138
+ break;
139
+ }
140
+ }
141
+ const { type: O, dataType: h } = A(g), $ = b(h);
115
142
  return {
116
- label: n,
117
- prop: l,
118
- must: r,
119
- type: o[0],
120
- dataType: o,
121
- description: u.substring(u.lastIndexOf("]") + 1).trim()
143
+ name: u,
144
+ prop: u,
145
+ type: $[0],
146
+ dataType: h,
147
+ must: s,
148
+ label: r,
149
+ description: y
122
150
  };
123
- });
151
+ }).filter(Boolean);
124
152
  }
125
153
  export {
126
- g as getFunBody,
127
- L as getFunctionFormat,
128
- b as getObjType,
129
- A as getParametersObj,
130
- c as getSonType,
131
- w as getString,
132
- d as getTypeValue,
133
- F as isDefaultType,
134
- v as isTypeEqual,
135
- T as prettierArrFormat,
136
- s as prettierFormat,
137
- h as prettierObjFormat,
138
- O as setDataType,
139
- x as vueFormat
154
+ S as getFunBody,
155
+ V as getFunctionFormat,
156
+ v as getObjType,
157
+ b as getSonType,
158
+ I as getString,
159
+ k as getTypeValue,
160
+ N as isDefaultType,
161
+ C as isTypeEqual,
162
+ q as parseParamString,
163
+ E as prettierArrFormat,
164
+ m as prettierFormat,
165
+ B as prettierObjFormat,
166
+ R as setDataType,
167
+ L as vueFormat
140
168
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.31",
4
+ "version": "0.0.33",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",