@fangzhongya/vue-archive 0.0.20 → 0.0.21

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.
@@ -2475,6 +2475,15 @@ function getExposeValue(arr) {
2475
2475
  return v;
2476
2476
  });
2477
2477
  }
2478
+ function getSlotValue(arr) {
2479
+ return arr.map((obj) => {
2480
+ const v = {};
2481
+ Object.keys(slot).forEach((key) => {
2482
+ v[key] = slot[key](obj);
2483
+ });
2484
+ return v;
2485
+ });
2486
+ }
2478
2487
 
2479
2488
  // packages/components/test/index.ts
2480
2489
  function getObj(v) {
@@ -3106,6 +3115,29 @@ function getSonType(type) {
3106
3115
  }
3107
3116
  return arr;
3108
3117
  }
3118
+ function getTypeValue(arr) {
3119
+ const type = (arr[0] || "any").toLowerCase();
3120
+ switch (type) {
3121
+ case "string":
3122
+ return '""';
3123
+ case "boolean":
3124
+ return "false";
3125
+ case "number":
3126
+ return "0";
3127
+ case "array":
3128
+ let v = getTypeValue(arr.splice(1));
3129
+ v = v == "undefined" ? "" : v;
3130
+ return `[${v}]`;
3131
+ case "object":
3132
+ return "{}";
3133
+ case "function":
3134
+ return "()=>{}";
3135
+ case "any":
3136
+ return '""';
3137
+ default:
3138
+ return "undefined";
3139
+ }
3140
+ }
3109
3141
  function getType(str) {
3110
3142
  let arr = [];
3111
3143
  if (str) {
@@ -3135,7 +3167,7 @@ function getParametersObj(cs) {
3135
3167
  let arrs = cs.split(",");
3136
3168
  return arrs.map((key) => {
3137
3169
  let vs = key.split(":");
3138
- let name = vs[0];
3170
+ let name = vs[0].trim();
3139
3171
  let t = vs[1] || "";
3140
3172
  let tarr = getSonType(getType(t));
3141
3173
  return {
@@ -3163,8 +3195,10 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3163
3195
  const tarr = [];
3164
3196
  const sarr = [];
3165
3197
  let is = true;
3198
+ const ps = getPropsValue2(param.propss || []);
3166
3199
  const es = getEmitsValue(param.emitss || []);
3167
3200
  const res = getExposeValue(param.exposes || []);
3201
+ const ss = getSlotValue(param.slots || []);
3168
3202
  Object.keys(value).forEach((key) => {
3169
3203
  let val = value[key];
3170
3204
  if (/^on[A-Z]/.test(key) && typeof val == "function") {
@@ -3190,9 +3224,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3190
3224
  strs = arr.join("");
3191
3225
  }
3192
3226
  tarr.push(" @" + name + '="' + strs + '"');
3193
- const s = getSpecObjs(es, name)?.selectable || "";
3227
+ const sp = getSpecObjs(es, name);
3228
+ const s = sp.selectable || "";
3194
3229
  const css = getParametersObj(s);
3195
3230
  const cs = getParameStr(css);
3231
+ sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
3196
3232
  sarr.push("function " + strs + "(" + cs + ") {");
3197
3233
  css.forEach((o) => {
3198
3234
  const name2 = o.prop || "arr";
@@ -3207,6 +3243,12 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3207
3243
  z = key + "1";
3208
3244
  }
3209
3245
  tarr.push(" :" + key + '="' + z + '"');
3246
+ const sp = getSpecObjs(ps, key);
3247
+ const t = getSpecType(sp);
3248
+ sarr.push(
3249
+ `// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
3250
+ );
3251
+ console.log("val", val);
3210
3252
  if (typeof val == "function") {
3211
3253
  sarr.push(
3212
3254
  "const " + key + " = " + getFunctionBody(val, key, propsText)
@@ -3217,7 +3259,14 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3217
3259
  sarr.unshift("import { ref } from 'vue';");
3218
3260
  }
3219
3261
  if (typeof val == "undefined") {
3220
- sarr.push("const " + z + " = ref();");
3262
+ const tv = getTypeValue(t.dataType);
3263
+ if (tv == "()=>{}") {
3264
+ sarr.push("const " + z + " = " + tv + ";");
3265
+ } else {
3266
+ sarr.push(
3267
+ "const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
3268
+ );
3269
+ }
3221
3270
  } else {
3222
3271
  let st2 = setValStringify(val, key, propsText);
3223
3272
  sarr.push("const " + z + " = ref(" + st2 + ");");
@@ -3234,27 +3283,36 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3234
3283
  tarr.unshift(' ref="refDom"');
3235
3284
  sarr.push("const refDom = ref()");
3236
3285
  ev.forEach((v) => {
3237
- sarr.push(`-------${v.name}--------`);
3238
3286
  const s = getSpecObjs(res, v.name);
3287
+ sarr.push(
3288
+ `// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
3289
+ );
3239
3290
  const m = v.name + "Value";
3240
3291
  const css = getParametersObj(s?.selectable || "");
3241
3292
  const cs = [];
3242
- v.params?.forEach((val, index) => {
3243
- const prop = css[index].prop;
3244
- const key = prop + v.name;
3245
- if (typeof val == "function") {
3246
- sarr.push(
3247
- "const " + key + " = " + getFunctionBody(val, prop, v.text)
3248
- );
3249
- } else {
3250
- if (typeof val == "undefined") {
3251
- sarr.push("const " + key + " = undefined;");
3293
+ const ps2 = v.params || [];
3294
+ css.forEach((c, index) => {
3295
+ const prop = c.prop;
3296
+ if (prop) {
3297
+ const key = prop + v.name;
3298
+ const val = ps2[index];
3299
+ sarr.push(`// ${c.label}`);
3300
+ if (typeof val == "function") {
3301
+ sarr.push(
3302
+ "const " + key + " = " + getFunctionBody(val, prop, v.text)
3303
+ );
3252
3304
  } else {
3253
- let st2 = setValStringify(val, prop, v.text);
3254
- sarr.push("const " + key + " = " + st2 + ";");
3305
+ if (typeof val == "undefined") {
3306
+ sarr.push(
3307
+ "const " + key + " = " + getTypeValue(c.dataType) + ";"
3308
+ );
3309
+ } else {
3310
+ let st2 = setValStringify(val, prop, v.text);
3311
+ sarr.push("const " + key + " = " + st2 + ";");
3312
+ }
3255
3313
  }
3314
+ cs.push(key);
3256
3315
  }
3257
- cs.push(key);
3258
3316
  });
3259
3317
  if (v.type === "function") {
3260
3318
  sarr.push(
@@ -3263,13 +3321,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3263
3321
  } else {
3264
3322
  sarr.push(`const ${m} = refDom.value?.${v.name}`);
3265
3323
  }
3266
- sarr.push(`console.log('"${s.description}"', ${m})`);
3324
+ sarr.push(`console.log('"${s.type}"', ${m})`);
3267
3325
  });
3268
3326
  }
3269
3327
  if (tarr.length > 0) {
3270
3328
  tarr.unshift("");
3271
3329
  }
3272
- const slots = getSlots(slotValue);
3330
+ const slots = getSlots(slotValue, ss);
3273
3331
  const st = `<!--${propsname}-->
3274
3332
  <template>
3275
3333
  <div>
@@ -3283,12 +3341,14 @@ ${sarr.join("\n")}
3283
3341
  `;
3284
3342
  return st;
3285
3343
  }
3286
- function getSlots(obj = {}) {
3344
+ function getSlots(obj = {}, ss) {
3287
3345
  const arr = [];
3288
3346
  Object.keys(obj).forEach((key) => {
3347
+ const sp = getSpecObjs(ss, key);
3289
3348
  const v = obj[key];
3290
3349
  if (v) {
3291
- const st = ` <template #${key}="scope">
3350
+ const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
3351
+ <template #${key}="scope">
3292
3352
  ${vueFormat(v, " ")}
3293
3353
  </template>`;
3294
3354
  arr.push(st);
@@ -3313,7 +3373,7 @@ function funstr(v) {
3313
3373
  let body = `{
3314
3374
  ${vueFormat(getFunBody(st.body), " ")}
3315
3375
  }`;
3316
- return `function ${st.param} ${body}`;
3376
+ return `function (${st.param}) ${body}`;
3317
3377
  } else {
3318
3378
  return "undefined";
3319
3379
  }
@@ -3837,15 +3897,6 @@ function gettests(obj, arr, n) {
3837
3897
  }
3838
3898
  }
3839
3899
  }
3840
- function getFFParam(str) {
3841
- str = str.trim();
3842
- if (str && str.length > 2) {
3843
- return str.substring(1, str.length - 1).split(",").map((k) => {
3844
- return (k.split(":")[0] || "").trim();
3845
- });
3846
- }
3847
- return [];
3848
- }
3849
3900
  function getObjValue(d) {
3850
3901
  try {
3851
3902
  return new Function(`{ return ${d} }`)();
@@ -3854,29 +3905,16 @@ function getObjValue(d) {
3854
3905
  }
3855
3906
  }
3856
3907
  function getDefaultValue(obj) {
3857
- const vo = getSpecType(obj).zdtype;
3908
+ const vo = getSpecType(obj);
3909
+ const v = getTypeValue(vo.dataType);
3858
3910
  const d = (obj.default || "").trim();
3859
- if (vo == "function") {
3860
- let fb = getFunctionFormat(d);
3861
- if (fb) {
3862
- return new Function(...getFFParam(fb.param), fb.body);
3863
- }
3864
- return new Function("{}");
3865
- } else if (vo == "array") {
3866
- return getObjValue(d || "[]");
3867
- } else if (vo == "object") {
3868
- return getObjValue(d || "{}");
3869
- } else if (vo == "number") {
3870
- return getObjValue(d || "1");
3871
- } else if (vo == "boolean") {
3872
- return getObjValue(d || "true");
3873
- } else {
3874
- return d;
3875
- }
3911
+ return getObjValue(d || v);
3876
3912
  }
3877
3913
  function setVue(propsname, param, url) {
3878
3914
  const ps = getPropsValue2(param.propss || []);
3879
3915
  const es = getEmitsValue(param.emitss || []);
3916
+ const res = getExposeValue(param.exposes || []);
3917
+ const ss = getSlotValue(param.slots || []);
3880
3918
  const propsObj = {};
3881
3919
  ps.forEach((val) => {
3882
3920
  let name = val.name;
@@ -3884,7 +3922,8 @@ function setVue(propsname, param, url) {
3884
3922
  let arr = name.split("/");
3885
3923
  name = (arr[0] || "").trim();
3886
3924
  if (name) {
3887
- propsObj[name] = getDefaultValue(val);
3925
+ const dv = getDefaultValue(val);
3926
+ propsObj[name] = dv;
3888
3927
  if (arr && arr.length > 1) {
3889
3928
  es.push({
3890
3929
  name: "update:" + name,
@@ -3910,7 +3949,18 @@ function setVue(propsname, param, url) {
3910
3949
  propsObj[name] = () => {
3911
3950
  };
3912
3951
  });
3913
- const html = getHmtl(propsname, param, propsObj);
3952
+ const slotValue = {};
3953
+ ss.forEach((v) => {
3954
+ slotValue[v.name] = " ";
3955
+ });
3956
+ const exposeText = {};
3957
+ res.forEach((v) => {
3958
+ exposeText[v.name] = {
3959
+ name: v.name,
3960
+ type: "function"
3961
+ };
3962
+ });
3963
+ const html = getHmtl(propsname, param, propsObj, slotValue, {}, exposeText);
3914
3964
  Fang.fileOpen(url, html);
3915
3965
  }
3916
3966
  function getMdurl(obj) {
@@ -2460,6 +2460,15 @@ function getExposeValue(arr) {
2460
2460
  return v;
2461
2461
  });
2462
2462
  }
2463
+ function getSlotValue(arr) {
2464
+ return arr.map((obj) => {
2465
+ const v = {};
2466
+ Object.keys(slot).forEach((key) => {
2467
+ v[key] = slot[key](obj);
2468
+ });
2469
+ return v;
2470
+ });
2471
+ }
2463
2472
 
2464
2473
  // packages/components/test/index.ts
2465
2474
  function getObj(v) {
@@ -3091,6 +3100,29 @@ function getSonType(type) {
3091
3100
  }
3092
3101
  return arr;
3093
3102
  }
3103
+ function getTypeValue(arr) {
3104
+ const type = (arr[0] || "any").toLowerCase();
3105
+ switch (type) {
3106
+ case "string":
3107
+ return '""';
3108
+ case "boolean":
3109
+ return "false";
3110
+ case "number":
3111
+ return "0";
3112
+ case "array":
3113
+ let v = getTypeValue(arr.splice(1));
3114
+ v = v == "undefined" ? "" : v;
3115
+ return `[${v}]`;
3116
+ case "object":
3117
+ return "{}";
3118
+ case "function":
3119
+ return "()=>{}";
3120
+ case "any":
3121
+ return '""';
3122
+ default:
3123
+ return "undefined";
3124
+ }
3125
+ }
3094
3126
  function getType(str) {
3095
3127
  let arr = [];
3096
3128
  if (str) {
@@ -3120,7 +3152,7 @@ function getParametersObj(cs) {
3120
3152
  let arrs = cs.split(",");
3121
3153
  return arrs.map((key) => {
3122
3154
  let vs = key.split(":");
3123
- let name = vs[0];
3155
+ let name = vs[0].trim();
3124
3156
  let t = vs[1] || "";
3125
3157
  let tarr = getSonType(getType(t));
3126
3158
  return {
@@ -3148,8 +3180,10 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3148
3180
  const tarr = [];
3149
3181
  const sarr = [];
3150
3182
  let is = true;
3183
+ const ps = getPropsValue2(param.propss || []);
3151
3184
  const es = getEmitsValue(param.emitss || []);
3152
3185
  const res = getExposeValue(param.exposes || []);
3186
+ const ss = getSlotValue(param.slots || []);
3153
3187
  Object.keys(value).forEach((key) => {
3154
3188
  let val = value[key];
3155
3189
  if (/^on[A-Z]/.test(key) && typeof val == "function") {
@@ -3175,9 +3209,11 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3175
3209
  strs = arr.join("");
3176
3210
  }
3177
3211
  tarr.push(" @" + name + '="' + strs + '"');
3178
- const s = getSpecObjs(es, name)?.selectable || "";
3212
+ const sp = getSpecObjs(es, name);
3213
+ const s = sp.selectable || "";
3179
3214
  const css = getParametersObj(s);
3180
3215
  const cs = getParameStr(css);
3216
+ sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
3181
3217
  sarr.push("function " + strs + "(" + cs + ") {");
3182
3218
  css.forEach((o) => {
3183
3219
  const name2 = o.prop || "arr";
@@ -3192,6 +3228,12 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3192
3228
  z = key + "1";
3193
3229
  }
3194
3230
  tarr.push(" :" + key + '="' + z + '"');
3231
+ const sp = getSpecObjs(ps, key);
3232
+ const t = getSpecType(sp);
3233
+ sarr.push(
3234
+ `// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
3235
+ );
3236
+ console.log("val", val);
3195
3237
  if (typeof val == "function") {
3196
3238
  sarr.push(
3197
3239
  "const " + key + " = " + getFunctionBody(val, key, propsText)
@@ -3202,7 +3244,14 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3202
3244
  sarr.unshift("import { ref } from 'vue';");
3203
3245
  }
3204
3246
  if (typeof val == "undefined") {
3205
- sarr.push("const " + z + " = ref();");
3247
+ const tv = getTypeValue(t.dataType);
3248
+ if (tv == "()=>{}") {
3249
+ sarr.push("const " + z + " = " + tv + ";");
3250
+ } else {
3251
+ sarr.push(
3252
+ "const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
3253
+ );
3254
+ }
3206
3255
  } else {
3207
3256
  let st2 = setValStringify(val, key, propsText);
3208
3257
  sarr.push("const " + z + " = ref(" + st2 + ");");
@@ -3219,27 +3268,36 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3219
3268
  tarr.unshift(' ref="refDom"');
3220
3269
  sarr.push("const refDom = ref()");
3221
3270
  ev.forEach((v) => {
3222
- sarr.push(`-------${v.name}--------`);
3223
3271
  const s = getSpecObjs(res, v.name);
3272
+ sarr.push(
3273
+ `// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
3274
+ );
3224
3275
  const m = v.name + "Value";
3225
3276
  const css = getParametersObj(s?.selectable || "");
3226
3277
  const cs = [];
3227
- v.params?.forEach((val, index) => {
3228
- const prop = css[index].prop;
3229
- const key = prop + v.name;
3230
- if (typeof val == "function") {
3231
- sarr.push(
3232
- "const " + key + " = " + getFunctionBody(val, prop, v.text)
3233
- );
3234
- } else {
3235
- if (typeof val == "undefined") {
3236
- sarr.push("const " + key + " = undefined;");
3278
+ const ps2 = v.params || [];
3279
+ css.forEach((c, index) => {
3280
+ const prop = c.prop;
3281
+ if (prop) {
3282
+ const key = prop + v.name;
3283
+ const val = ps2[index];
3284
+ sarr.push(`// ${c.label}`);
3285
+ if (typeof val == "function") {
3286
+ sarr.push(
3287
+ "const " + key + " = " + getFunctionBody(val, prop, v.text)
3288
+ );
3237
3289
  } else {
3238
- let st2 = setValStringify(val, prop, v.text);
3239
- sarr.push("const " + key + " = " + st2 + ";");
3290
+ if (typeof val == "undefined") {
3291
+ sarr.push(
3292
+ "const " + key + " = " + getTypeValue(c.dataType) + ";"
3293
+ );
3294
+ } else {
3295
+ let st2 = setValStringify(val, prop, v.text);
3296
+ sarr.push("const " + key + " = " + st2 + ";");
3297
+ }
3240
3298
  }
3299
+ cs.push(key);
3241
3300
  }
3242
- cs.push(key);
3243
3301
  });
3244
3302
  if (v.type === "function") {
3245
3303
  sarr.push(
@@ -3248,13 +3306,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3248
3306
  } else {
3249
3307
  sarr.push(`const ${m} = refDom.value?.${v.name}`);
3250
3308
  }
3251
- sarr.push(`console.log('"${s.description}"', ${m})`);
3309
+ sarr.push(`console.log('"${s.type}"', ${m})`);
3252
3310
  });
3253
3311
  }
3254
3312
  if (tarr.length > 0) {
3255
3313
  tarr.unshift("");
3256
3314
  }
3257
- const slots = getSlots(slotValue);
3315
+ const slots = getSlots(slotValue, ss);
3258
3316
  const st = `<!--${propsname}-->
3259
3317
  <template>
3260
3318
  <div>
@@ -3268,12 +3326,14 @@ ${sarr.join("\n")}
3268
3326
  `;
3269
3327
  return st;
3270
3328
  }
3271
- function getSlots(obj = {}) {
3329
+ function getSlots(obj = {}, ss) {
3272
3330
  const arr = [];
3273
3331
  Object.keys(obj).forEach((key) => {
3332
+ const sp = getSpecObjs(ss, key);
3274
3333
  const v = obj[key];
3275
3334
  if (v) {
3276
- const st = ` <template #${key}="scope">
3335
+ const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
3336
+ <template #${key}="scope">
3277
3337
  ${vueFormat(v, " ")}
3278
3338
  </template>`;
3279
3339
  arr.push(st);
@@ -3298,7 +3358,7 @@ function funstr(v) {
3298
3358
  let body = `{
3299
3359
  ${vueFormat(getFunBody(st.body), " ")}
3300
3360
  }`;
3301
- return `function ${st.param} ${body}`;
3361
+ return `function (${st.param}) ${body}`;
3302
3362
  } else {
3303
3363
  return "undefined";
3304
3364
  }
@@ -3822,15 +3882,6 @@ function gettests(obj, arr, n) {
3822
3882
  }
3823
3883
  }
3824
3884
  }
3825
- function getFFParam(str) {
3826
- str = str.trim();
3827
- if (str && str.length > 2) {
3828
- return str.substring(1, str.length - 1).split(",").map((k) => {
3829
- return (k.split(":")[0] || "").trim();
3830
- });
3831
- }
3832
- return [];
3833
- }
3834
3885
  function getObjValue(d) {
3835
3886
  try {
3836
3887
  return new Function(`{ return ${d} }`)();
@@ -3839,29 +3890,16 @@ function getObjValue(d) {
3839
3890
  }
3840
3891
  }
3841
3892
  function getDefaultValue(obj) {
3842
- const vo = getSpecType(obj).zdtype;
3893
+ const vo = getSpecType(obj);
3894
+ const v = getTypeValue(vo.dataType);
3843
3895
  const d = (obj.default || "").trim();
3844
- if (vo == "function") {
3845
- let fb = getFunctionFormat(d);
3846
- if (fb) {
3847
- return new Function(...getFFParam(fb.param), fb.body);
3848
- }
3849
- return new Function("{}");
3850
- } else if (vo == "array") {
3851
- return getObjValue(d || "[]");
3852
- } else if (vo == "object") {
3853
- return getObjValue(d || "{}");
3854
- } else if (vo == "number") {
3855
- return getObjValue(d || "1");
3856
- } else if (vo == "boolean") {
3857
- return getObjValue(d || "true");
3858
- } else {
3859
- return d;
3860
- }
3896
+ return getObjValue(d || v);
3861
3897
  }
3862
3898
  function setVue(propsname, param, url) {
3863
3899
  const ps = getPropsValue2(param.propss || []);
3864
3900
  const es = getEmitsValue(param.emitss || []);
3901
+ const res = getExposeValue(param.exposes || []);
3902
+ const ss = getSlotValue(param.slots || []);
3865
3903
  const propsObj = {};
3866
3904
  ps.forEach((val) => {
3867
3905
  let name = val.name;
@@ -3869,7 +3907,8 @@ function setVue(propsname, param, url) {
3869
3907
  let arr = name.split("/");
3870
3908
  name = (arr[0] || "").trim();
3871
3909
  if (name) {
3872
- propsObj[name] = getDefaultValue(val);
3910
+ const dv = getDefaultValue(val);
3911
+ propsObj[name] = dv;
3873
3912
  if (arr && arr.length > 1) {
3874
3913
  es.push({
3875
3914
  name: "update:" + name,
@@ -3895,7 +3934,18 @@ function setVue(propsname, param, url) {
3895
3934
  propsObj[name] = () => {
3896
3935
  };
3897
3936
  });
3898
- const html = getHmtl(propsname, param, propsObj);
3937
+ const slotValue = {};
3938
+ ss.forEach((v) => {
3939
+ slotValue[v.name] = " ";
3940
+ });
3941
+ const exposeText = {};
3942
+ res.forEach((v) => {
3943
+ exposeText[v.name] = {
3944
+ name: v.name,
3945
+ type: "function"
3946
+ };
3947
+ });
3948
+ const html = getHmtl(propsname, param, propsObj, slotValue, {}, exposeText);
3899
3949
  Fang.fileOpen(url, html);
3900
3950
  }
3901
3951
  function getMdurl(obj) {
@@ -1,18 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const P=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const x=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const S=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const h=require("./util.cjs"),E=require("../../utils/props.cjs"),z=require("@fangzhongya/utils/basic/string/toFunction"),U=["class"];function O(n,e){return n.filter(t=>t.name==e)[0]}function B(n){return n.map(e=>(e.prop||"...arr")+":"+h.setDataType(e.dataType)).join(",")}function C(n,e,t,i,a,y){const c=[],r=[];let $=!0;const w=E.getEmitsValue(e.emitss||[]),D=E.getExposeValue(e.exposes||[]);Object.keys(t).forEach(s=>{let p=t[s];if(/^on[A-Z]/.test(s)&&typeof p=="function"){let o=s.substring(2);const f=s.split(":");let l;if(f.length>1?(l=f[0]+f.slice(1).map(u=>S.firstUpper(u)).join(""),o=x.firstLower(o)):(l=f[0],o=P.humpToLine(o)),f.includes("-")){let u=l.split("-");u=u.map((m,V)=>V!=0?S.firstUpper(m):m),l=u.join("")}c.push(" @"+o+'="'+l+'"');const g=O(w,o)?.selectable||"",b=h.getParametersObj(g),d=B(b);r.push("function "+l+"("+d+") {"),b.forEach(u=>{const m=u.prop||"arr";r.push(" console.log('"+u.description+m+"', "+m+")")}),r.push("}")}else{let o=s;if(U.includes(s)&&(o=s+"1"),c.push(" :"+s+'="'+o+'"'),typeof p=="function")r.push("const "+s+" = "+F(p,s,a));else if($&&($=!1,r.unshift("import { ref } from 'vue';")),typeof p>"u")r.push("const "+o+" = ref();");else{let f=q(p,s,a);r.push("const "+o+" = ref("+f+");")}}});const j=Object.values(y||{});j.length>0&&($&&($=!1,r.unshift("import { ref } from 'vue';")),c.unshift(' ref="refDom"'),r.push("const refDom = ref()"),j.forEach(s=>{r.push(`-------${s.name}--------`);const p=O(D,s.name),o=s.name+"Value",f=h.getParametersObj(p?.selectable||""),l=[];s.params?.forEach((g,b)=>{const d=f[b].prop,u=d+s.name;if(typeof g=="function")r.push("const "+u+" = "+F(g,d,s.text));else if(typeof g>"u")r.push("const "+u+" = undefined;");else{let m=q(g,d,s.text);r.push("const "+u+" = "+m+";")}l.push(u)}),s.type==="function"?r.push(`const ${o} = refDom.value?.${s.name}(${l.join(", ")})`):r.push(`const ${o} = refDom.value?.${s.name}`),r.push(`console.log('"${p.description}"', ${o})`)})),c.length>0&&c.unshift("");const L=H(i);return`<!--${n}-->
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,h,$){const p=[],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 c=e[r];if(/^on[A-Z]/.test(r)&&typeof c=="function"){let i=r.substring(2);const u=r.split(":");let a;if(u.length>1?(a=u[0]+u.slice(1).map(f=>V.firstUpper(f)).join(""),i=C.firstLower(i)):(a=u[0],i=B.humpToLine(i)),u.includes("-")){let f=a.split("-");f=f.map((m,T)=>T!=0?V.firstUpper(m):m),a=f.join("")}p.push(" @"+i+'="'+a+'"');const l=j(P,i),y=l.selectable||"",q=g.getParametersObj(y),d=N(q);n.push(`// ${l.description} ${l.name}: (${l.selectable})`),n.push("function "+a+"("+d+") {"),q.forEach(f=>{const m=f.prop||"arr";n.push(" console.log('"+f.description+m+"', "+m+")")}),n.push("}")}else{let i=r;J.includes(r)&&(i=r+"1"),p.push(" :"+r+'="'+i+'"');const u=j(L,r),a=D(u);if(n.push(`// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`),console.log("val",c),typeof c=="function")n.push("const "+r+" = "+F(c,r,h));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof c>"u"){const l=g.getTypeValue(a.dataType);l=="()=>{}"?n.push("const "+i+" = "+l+";"):n.push("const "+i+" = ref("+(l==="undefined"?"":l)+");")}else{let l=E(c,r,h);n.push("const "+i+" = ref("+l+");")}}});const O=Object.values($||{});O.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),n.push("const refDom = ref()"),O.forEach(r=>{const c=j(x,r.name);n.push(`// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`);const i=r.name+"Value",u=g.getParametersObj(c?.selectable||""),a=[],l=r.params||[];u.forEach((y,q)=>{const d=y.prop;if(d){const f=d+r.name,m=l[q];if(n.push(`// ${y.label}`),typeof m=="function")n.push("const "+f+" = "+F(m,d,r.text));else if(typeof m>"u")n.push("const "+f+" = "+g.getTypeValue(y.dataType)+";");else{let T=E(m,d,r.text);n.push("const "+f+" = "+T+";")}a.push(f)}}),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('"${c.type}"', ${i})`)})),p.length>0&&p.unshift("");const U=M(o,z);return`<!--${s}-->
2
2
  <template>
3
3
  <div>
4
- <${n}${c.join(`
5
- `)}>${L.join(`
4
+ <${s}${p.join(`
5
+ `)}>${U.join(`
6
6
  `)}
7
- </${n}>
7
+ </${s}>
8
8
  </div>
9
9
  </template>
10
10
  <script lang="ts" setup>
11
- ${r.join(`
11
+ ${n.join(`
12
12
  `)}
13
13
  <\/script>
14
- `}function H(n={}){const e=[];return Object.keys(n).forEach(t=>{const i=n[t];if(i){const a=` <template #${t}="scope">
15
- ${h.vueFormat(i," ")}
16
- </template>`;e.push(a)}}),e&&e.length>0&&e.unshift(""),e}function F(n,e,t){const i=t?t[e]:"";return i||T(n.toString())}function T(n){const e=z.getFunctionFormat(h.prettierFormat(n));if(e){let t=`{
17
- ${h.vueFormat(h.getFunBody(e.body)," ")}
18
- }`;return`function ${e.param} ${t}`}else return"undefined"}function J(n){const e=n.trim();return/^\(/.test(e)?T(e):JSON.stringify(n)}function q(n,e,t){const i=t?t[e]:"";return i||(typeof n=="string"?J(n+""):JSON.stringify(n))}function N(n){let e=A(n.type),t="any";e.length==1&&(t=e[0].split("<")[0]);const i=t;let a=(n.selectable||"").trim(),y=[];return a&&t!="boolean"&&(a.split(",").forEach(c=>{if(c){let r=c.split(":");y.push({label:c,prop:r[0].trim()})}}),t=="function"?t="function":t=="array"?t="choice":t="select"),{arr:y,zdtype:i,type:t,dataType:e}}function A(n){let e=[];return(n||"").trim().toLowerCase().split(",").forEach(i=>{i=i.trim(),i&&e.push(i)}),[...new Set(e)].sort()}exports.getHmtl=C;exports.getSpecType=N;exports.setValStringify=q;
14
+ `}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const h=j(t,o),$=s[o];if($){const p=` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
15
+ <template #${o}="scope">
16
+ ${g.vueFormat($," ")}
17
+ </template>`;e.push(p)}}),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=`{
18
+ ${g.vueFormat(g.getFunBody(t.body)," ")}
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 h=(s.selectable||"").trim(),$=[];return h&&e!="boolean"&&(h.split(",").forEach(p=>{if(p){let n=p.split(":");$.push({label:p,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;
@@ -1,159 +1,175 @@
1
1
  import "@fangzhongya/utils/basic/object/mergeObject";
2
2
  import "@fangzhongya/utils/basic/array/toggleArray";
3
- import { humpToLine as T } from "@fangzhongya/utils/name/humpToLine";
3
+ import { humpToLine as J } from "@fangzhongya/utils/name/humpToLine";
4
4
  import "@fangzhongya/utils/name/lineToLargeHump";
5
5
  import "@fangzhongya/utils/basic/string/appearNum";
6
- import { firstLower as B } from "@fangzhongya/utils/basic/string/firstLower";
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 j } from "@fangzhongya/utils/basic/string/firstUpper";
9
+ import { firstUpper as O } 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 E, setDataType as C, vueFormat as D, prettierFormat as J, getFunBody as N } from "./util.js";
13
- import { getEmitsValue as P, getExposeValue as A } from "../../utils/props.js";
14
- import { getFunctionFormat as H } from "@fangzhongya/utils/basic/string/toFunction";
15
- const U = ["class"];
16
- function S(n, t) {
17
- return n.filter((e) => e.name == t)[0];
12
+ import { getParametersObj as V, getTypeValue as F, setDataType as A, vueFormat as w, prettierFormat as H, getFunBody as U } from "./util.js";
13
+ import { getPropsValue as Z, getEmitsValue as q, getExposeValue as G, getSlotValue as I } from "../../utils/props.js";
14
+ import { getFunctionFormat as K } from "@fangzhongya/utils/basic/string/toFunction";
15
+ const M = ["class"];
16
+ function j(s, e) {
17
+ return s.filter((t) => t.name == e)[0];
18
18
  }
19
- function Z(n) {
20
- return n.map((t) => (t.prop || "...arr") + ":" + C(t.dataType)).join(",");
19
+ function Q(s) {
20
+ return s.map((e) => (e.prop || "...arr") + ":" + A(e.dataType)).join(",");
21
21
  }
22
- function ot(n, t, e, o, a, d) {
23
- const c = [], r = [];
24
- let $ = !0;
25
- const x = P(t.emitss || []), V = A(t.exposes || []);
26
- Object.keys(e).forEach((s) => {
27
- let l = e[s];
28
- if (/^on[A-Z]/.test(s) && typeof l == "function") {
29
- let i = s.substring(2);
30
- const u = s.split(":");
31
- let p;
32
- if (u.length > 1 ? (p = u[0] + u.slice(1).map((f) => j(f)).join(""), i = B(i)) : (p = u[0], i = T(i)), u.includes("-")) {
33
- let f = p.split("-");
34
- f = f.map((m, L) => L != 0 ? j(m) : m), p = f.join("");
22
+ function at(s, e, t, r, h, $) {
23
+ const u = [], n = [];
24
+ let y = !0;
25
+ const z = Z(e.propss || []), L = q(e.emitss || []), P = G(e.exposes || []), B = I(e.slots || []);
26
+ Object.keys(t).forEach((o) => {
27
+ let c = t[o];
28
+ if (/^on[A-Z]/.test(o) && typeof c == "function") {
29
+ let i = o.substring(2);
30
+ const l = o.split(":");
31
+ let a;
32
+ if (l.length > 1 ? (a = l[0] + l.slice(1).map((f) => O(f)).join(""), i = N(i)) : (a = l[0], i = J(i)), l.includes("-")) {
33
+ let f = a.split("-");
34
+ f = f.map((m, S) => S != 0 ? O(m) : m), a = f.join("");
35
35
  }
36
- c.push(" @" + i + '="' + p + '"');
37
- const h = S(x, i)?.selectable || "", y = E(h), g = Z(y);
38
- r.push("function " + p + "(" + g + ") {"), y.forEach((f) => {
36
+ u.push(" @" + i + '="' + a + '"');
37
+ const p = j(L, i), d = p.selectable || "", b = V(d), g = Q(b);
38
+ n.push(`// ${p.description} ${p.name}: (${p.selectable})`), n.push("function " + a + "(" + g + ") {"), b.forEach((f) => {
39
39
  const m = f.prop || "arr";
40
- r.push(
40
+ n.push(
41
41
  " console.log('" + f.description + m + "', " + m + ")"
42
42
  );
43
- }), r.push("}");
43
+ }), n.push("}");
44
44
  } else {
45
- let i = s;
46
- if (U.includes(s) && (i = s + "1"), c.push(" :" + s + '="' + i + '"'), typeof l == "function")
47
- r.push(
48
- "const " + s + " = " + O(l, s, a)
45
+ let i = o;
46
+ M.includes(o) && (i = o + "1"), u.push(" :" + o + '="' + i + '"');
47
+ const l = j(z, o), a = X(l);
48
+ if (n.push(
49
+ `// ${l.description} ${l.name}: {${l.type}} (${l.selectable})`
50
+ ), console.log("val", c), typeof c == "function")
51
+ n.push(
52
+ "const " + o + " = " + T(c, o, h)
49
53
  );
50
- else if ($ && ($ = !1, r.unshift("import { ref } from 'vue';")), typeof l > "u")
51
- r.push("const " + i + " = ref();");
52
- else {
53
- let u = F(l, s, a);
54
- r.push("const " + i + " = ref(" + u + ");");
54
+ else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof c > "u") {
55
+ const p = F(a.dataType);
56
+ p == "()=>{}" ? n.push("const " + i + " = " + p + ";") : n.push(
57
+ "const " + i + " = ref(" + (p === "undefined" ? "" : p) + ");"
58
+ );
59
+ } else {
60
+ let p = D(c, o, h);
61
+ n.push("const " + i + " = ref(" + p + ");");
55
62
  }
56
63
  }
57
64
  });
58
- const b = Object.values(d || {});
59
- b.length > 0 && ($ && ($ = !1, r.unshift("import { ref } from 'vue';")), c.unshift(' ref="refDom"'), r.push("const refDom = ref()"), b.forEach((s) => {
60
- r.push(`-------${s.name}--------`);
61
- const l = S(V, s.name), i = s.name + "Value", u = E(l?.selectable || ""), p = [];
62
- s.params?.forEach((h, y) => {
63
- const g = u[y].prop, f = g + s.name;
64
- if (typeof h == "function")
65
- r.push(
66
- "const " + f + " = " + O(h, g, s.text)
67
- );
68
- else if (typeof h > "u")
69
- r.push("const " + f + " = undefined;");
70
- else {
71
- let m = F(h, g, s.text);
72
- r.push("const " + f + " = " + m + ";");
65
+ const E = Object.values($ || {});
66
+ E.length > 0 && (y && (y = !1, n.unshift("import { ref } from 'vue';")), u.unshift(' ref="refDom"'), n.push("const refDom = ref()"), E.forEach((o) => {
67
+ const c = j(P, o.name);
68
+ n.push(
69
+ `// ${c.description} ${c.name}:(${c.selectable}) ${c.type}`
70
+ );
71
+ const i = o.name + "Value", l = V(c?.selectable || ""), a = [], p = o.params || [];
72
+ l.forEach((d, b) => {
73
+ const g = d.prop;
74
+ if (g) {
75
+ const f = g + o.name, m = p[b];
76
+ if (n.push(`// ${d.label}`), typeof m == "function")
77
+ n.push(
78
+ "const " + f + " = " + T(m, g, o.text)
79
+ );
80
+ else if (typeof m > "u")
81
+ n.push(
82
+ "const " + f + " = " + F(d.dataType) + ";"
83
+ );
84
+ else {
85
+ let S = D(m, g, o.text);
86
+ n.push("const " + f + " = " + S + ";");
87
+ }
88
+ a.push(f);
73
89
  }
74
- p.push(f);
75
- }), s.type === "function" ? r.push(
76
- `const ${i} = refDom.value?.${s.name}(${p.join(", ")})`
77
- ) : r.push(`const ${i} = refDom.value?.${s.name}`), r.push(`console.log('"${l.description}"', ${i})`);
78
- })), c.length > 0 && c.unshift("");
79
- const z = q(o);
80
- return `<!--${n}-->
90
+ }), o.type === "function" ? n.push(
91
+ `const ${i} = refDom.value?.${o.name}(${a.join(", ")})`
92
+ ) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${c.type}"', ${i})`);
93
+ })), u.length > 0 && u.unshift("");
94
+ const C = R(r, B);
95
+ return `<!--${s}-->
81
96
  <template>
82
97
  <div>
83
- <${n}${c.join(`
84
- `)}>${z.join(`
98
+ <${s}${u.join(`
99
+ `)}>${C.join(`
85
100
  `)}
86
- </${n}>
101
+ </${s}>
87
102
  </div>
88
103
  </template>
89
104
  <script lang="ts" setup>
90
- ${r.join(`
105
+ ${n.join(`
91
106
  `)}
92
107
  <\/script>
93
108
  `;
94
109
  }
95
- function q(n = {}) {
110
+ function R(s = {}, e) {
96
111
  const t = [];
97
- return Object.keys(n).forEach((e) => {
98
- const o = n[e];
99
- if (o) {
100
- const a = ` <template #${e}="scope">
101
- ${D(o, " ")}
112
+ return Object.keys(s).forEach((r) => {
113
+ const h = j(e, r), $ = s[r];
114
+ if ($) {
115
+ const u = ` <!-- ${h.description} ${h.name}:(${h.selectable}) -->
116
+ <template #${r}="scope">
117
+ ${w($, " ")}
102
118
  </template>`;
103
- t.push(a);
119
+ t.push(u);
104
120
  }
105
121
  }), t && t.length > 0 && t.unshift(""), t;
106
122
  }
107
- function O(n, t, e) {
108
- const o = e ? e[t] : "";
109
- return o || w(n.toString());
123
+ function T(s, e, t) {
124
+ const r = t ? t[e] : "";
125
+ return r || x(s.toString());
110
126
  }
111
- function w(n) {
112
- const t = H(J(n));
113
- if (t) {
114
- let e = `{
115
- ${D(N(t.body), " ")}
127
+ function x(s) {
128
+ const e = K(H(s));
129
+ if (e) {
130
+ let t = `{
131
+ ${w(U(e.body), " ")}
116
132
  }`;
117
- return `function ${t.param} ${e}`;
133
+ return `function (${e.param}) ${t}`;
118
134
  } else
119
135
  return "undefined";
120
136
  }
121
- function G(n) {
122
- const t = n.trim();
123
- return /^\(/.test(t) ? w(t) : JSON.stringify(n);
137
+ function W(s) {
138
+ const e = s.trim();
139
+ return /^\(/.test(e) ? x(e) : JSON.stringify(s);
124
140
  }
125
- function F(n, t, e) {
126
- const o = e ? e[t] : "";
127
- return o || (typeof n == "string" ? G(n + "") : JSON.stringify(n));
141
+ function D(s, e, t) {
142
+ const r = t ? t[e] : "";
143
+ return r || (typeof s == "string" ? W(s + "") : JSON.stringify(s));
128
144
  }
129
- function it(n) {
130
- let t = I(n.type), e = "any";
131
- t.length == 1 && (e = t[0].split("<")[0]);
132
- const o = e;
133
- let a = (n.selectable || "").trim(), d = [];
134
- return a && e != "boolean" && (a.split(",").forEach((c) => {
135
- if (c) {
136
- let r = c.split(":");
137
- d.push({
138
- label: c,
139
- prop: r[0].trim()
145
+ function X(s) {
146
+ let e = Y(s.type), t = "any";
147
+ e.length == 1 && (t = e[0].split("<")[0]);
148
+ const r = t;
149
+ let h = (s.selectable || "").trim(), $ = [];
150
+ return h && t != "boolean" && (h.split(",").forEach((u) => {
151
+ if (u) {
152
+ let n = u.split(":");
153
+ $.push({
154
+ label: u,
155
+ prop: n[0].trim()
140
156
  });
141
157
  }
142
- }), e == "function" ? e = "function" : e == "array" ? e = "choice" : e = "select"), {
143
- arr: d,
144
- zdtype: o,
145
- type: e,
146
- dataType: t
158
+ }), t == "function" ? t = "function" : t == "array" ? t = "choice" : t = "select"), {
159
+ arr: $,
160
+ zdtype: r,
161
+ type: t,
162
+ dataType: e
147
163
  };
148
164
  }
149
- function I(n) {
150
- let t = [];
151
- return (n || "").trim().toLowerCase().split(",").forEach((o) => {
152
- o = o.trim(), o && t.push(o);
153
- }), [...new Set(t)].sort();
165
+ function Y(s) {
166
+ let e = [];
167
+ return (s || "").trim().toLowerCase().split(",").forEach((r) => {
168
+ r = r.trim(), r && e.push(r);
169
+ }), [...new Set(e)].sort();
154
170
  }
155
171
  export {
156
- ot as getHmtl,
157
- it as getSpecType,
158
- F as setValStringify
172
+ at as getHmtl,
173
+ X as getSpecType,
174
+ D as setValStringify
159
175
  };
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@fangzhongya/utils/basic/string/toFunction"),y=require("@fangzhongya/utils/basic/string/firstLower");function l(e){return e.replace(/\;(\s|\n\r)*$/,"")}function b(e){return e="let a = "+e,l(e).replace(/^let a = /,"")}function m(e){return l(e)}function d(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 j=["Boolean","Any","String","Number","Array","Object","Function"];function a(e){return j.includes(e)?y.firstLower(e):e}function F(e){let r=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(r&&r.length>0)return{own:a(r[1]),son:r[2]}}function c(e,t){let r=F(e);r?(t.push(r.own),r.son&&c(r.son,t)):t.push(e)}function u(e){e instanceof Array&&(e=e[0]);const t=[];return e&&c(e,t),t}function p(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 T(e,t){const r=p(e),n=u(t)[0];return n&&n!="any"?r==n:!0}function $(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 O(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 v(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=>a(r))}function S(e){return e.join("|")}function h(e){return e.split(",").map(r=>{let n=r.split(":"),i=n[0],o=n[1]||"",s=u(v(o));return{label:r,prop:i,type:s[0],dataType:s,description:o.substring(o.lastIndexOf("]")+1)}})}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>g.getFunctionFormat});exports.getFunBody=f;exports.getObjType=p;exports.getParametersObj=h;exports.getSonType=u;exports.getString=$;exports.isDefaultType=O;exports.isTypeEqual=T;exports.prettierArrFormat=m;exports.prettierFormat=l;exports.prettierObjFormat=b;exports.setDataType=S;exports.vueFormat=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@fangzhongya/utils/basic/string/toFunction"),b=require("@fangzhongya/utils/basic/string/firstLower");function u(e){return e.replace(/\;(\s|\n\r)*$/,"")}function m(e){return e="let a = "+e,u(e).replace(/^let a = /,"")}function d(e){return u(e)}function j(e,t=""){let r=(e+"").trim().split(/\n/);return r=r.map(n=>t+n),r.join(`
2
+ `)}function a(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?a(n[1]):e}const T=["Boolean","Any","String","Number","Array","Object","Function"];function f(e){return T.includes(e)?b.firstLower(e):e}function F(e){let r=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(r&&r.length>0)return{own:f(r[1]),son:r[2]}}function c(e,t){let r=F(e);r?(t.push(r.own),r.son&&c(r.son,t)):t.push(e)}function l(e){e instanceof Array&&(e=e[0]);const t=[];return e&&c(e,t),t}function p(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 $(e,t){const r=p(e),n=l(t)[0];return n&&n!="any"?r==n:!0}function O(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 g(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let r=g(e.splice(1));return r=r=="undefined"?"":r,`[${r}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function h(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=>f(r))}function w(e){return e.join("|")}function S(e){return e.split(",").map(r=>{let n=r.split(":"),i=n[0].trim(),o=n[1]||"",s=l(h(o));return{label:r,prop:i,type:s[0],dataType:s,description:o.substring(o.lastIndexOf("]")+1)}})}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>y.getFunctionFormat});exports.getFunBody=a;exports.getObjType=p;exports.getParametersObj=S;exports.getSonType=l;exports.getString=O;exports.getTypeValue=g;exports.isDefaultType=v;exports.isTypeEqual=$;exports.prettierArrFormat=d;exports.prettierFormat=u;exports.prettierObjFormat=m;exports.setDataType=w;exports.vueFormat=j;
@@ -35,6 +35,7 @@ export declare function getString(st: unknown): string;
35
35
  * 配置字符串的类型
36
36
  */
37
37
  export declare function isDefaultType(st: string): string;
38
+ export declare function getTypeValue(arr: string[]): string;
38
39
  export declare function setDataType(arr: string[]): string;
39
40
  export declare function getParametersObj(cs: string): {
40
41
  label: string;
@@ -1,12 +1,12 @@
1
- import { getFunctionFormat as S } from "@fangzhongya/utils/basic/string/toFunction";
1
+ import { getFunctionFormat as E } from "@fangzhongya/utils/basic/string/toFunction";
2
2
  import { firstLower as c } from "@fangzhongya/utils/basic/string/firstLower";
3
3
  function u(e) {
4
4
  return e.replace(/\;(\s|\n\r)*$/, "");
5
5
  }
6
- function d(e) {
6
+ function j(e) {
7
7
  return e = "let a = " + e, u(e).replace(/^let a = /, "");
8
8
  }
9
- function j(e) {
9
+ function T(e) {
10
10
  return u(e);
11
11
  }
12
12
  function x(e, t = "") {
@@ -29,47 +29,68 @@ const g = [
29
29
  "Object",
30
30
  "Function"
31
31
  ];
32
- function f(e) {
32
+ function s(e) {
33
33
  return g.includes(e) ? c(e) : e;
34
34
  }
35
35
  function y(e) {
36
36
  let n = new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);
37
37
  if (n && n.length > 0)
38
38
  return {
39
- own: f(n[1]),
39
+ own: s(n[1]),
40
40
  son: n[2]
41
41
  };
42
42
  }
43
- function s(e, t) {
43
+ function f(e, t) {
44
44
  let n = y(e);
45
- n ? (t.push(n.own), n.son && s(n.son, t)) : t.push(e);
45
+ n ? (t.push(n.own), n.son && f(n.son, t)) : t.push(e);
46
46
  }
47
47
  function a(e) {
48
48
  e instanceof Array && (e = e[0]);
49
49
  const t = [];
50
- return e && s(e, t), t;
50
+ return e && f(e, t), t;
51
51
  }
52
- function m(e) {
52
+ function b(e) {
53
53
  const t = Object.prototype.toString.call(e);
54
54
  let r = /^\[[O|o]bject (.*)\]$/.exec(t), i = typeof e;
55
55
  return r && r.length > 0 && (i = r[1].toLowerCase()), i;
56
56
  }
57
- function T(e, t) {
58
- const n = m(e), r = a(t)[0];
57
+ function h(e, t) {
58
+ const n = b(e), r = a(t)[0];
59
59
  return r && r != "any" ? n == r : !0;
60
60
  }
61
- function h(e) {
61
+ function v(e) {
62
62
  if (typeof e == "string") {
63
63
  let t = !1;
64
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 + "";
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 w(e) {
68
68
  e = (e + "").replace(/^(\s|\n|r)*/, "").replace(/(\s|\n|r)*$/, "");
69
69
  let t = "";
70
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;
71
71
  }
72
- function b(e) {
72
+ function m(e) {
73
+ switch ((e[0] || "any").toLowerCase()) {
74
+ case "string":
75
+ return '""';
76
+ case "boolean":
77
+ return "false";
78
+ case "number":
79
+ return "0";
80
+ case "array":
81
+ let n = m(e.splice(1));
82
+ return n = n == "undefined" ? "" : n, `[${n}]`;
83
+ case "object":
84
+ return "{}";
85
+ case "function":
86
+ return "()=>{}";
87
+ case "any":
88
+ return '""';
89
+ default:
90
+ return "undefined";
91
+ }
92
+ }
93
+ function d(e) {
73
94
  let t = [];
74
95
  if (e)
75
96
  if (e = (e + "").trim(), e.startsWith("["))
@@ -80,14 +101,14 @@ function b(e) {
80
101
  }
81
102
  else
82
103
  t = ["any"];
83
- return t.map((n) => f(n));
104
+ return t.map((n) => s(n));
84
105
  }
85
- function O(e) {
106
+ function F(e) {
86
107
  return e.join("|");
87
108
  }
88
- function v(e) {
109
+ function O(e) {
89
110
  return e.split(",").map((n) => {
90
- let r = n.split(":"), i = r[0], l = r[1] || "", o = a(b(l));
111
+ let r = n.split(":"), i = r[0].trim(), l = r[1] || "", o = a(d(l));
91
112
  return {
92
113
  label: n,
93
114
  prop: i,
@@ -99,16 +120,17 @@ function v(e) {
99
120
  }
100
121
  export {
101
122
  p as getFunBody,
102
- S as getFunctionFormat,
103
- m as getObjType,
104
- v as getParametersObj,
123
+ E as getFunctionFormat,
124
+ b as getObjType,
125
+ O as getParametersObj,
105
126
  a as getSonType,
106
- h as getString,
107
- F as isDefaultType,
108
- T as isTypeEqual,
109
- j as prettierArrFormat,
127
+ v as getString,
128
+ m as getTypeValue,
129
+ w as isDefaultType,
130
+ h as isTypeEqual,
131
+ T as prettierArrFormat,
110
132
  u as prettierFormat,
111
- d as prettierObjFormat,
112
- O as setDataType,
133
+ j as prettierObjFormat,
134
+ F as setDataType,
113
135
  x as vueFormat
114
136
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.20",
4
+ "version": "0.0.21",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",