@fangzhongya/vue-archive 0.1.8 → 0.1.9

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.
@@ -1323,664 +1323,288 @@ function getRawValue(comRaw, key) {
1323
1323
  }
1324
1324
  }
1325
1325
 
1326
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/primitives.js
1327
- var Markers;
1328
- (function(Markers2) {
1329
- Markers2["start"] = "/**";
1330
- Markers2["nostart"] = "/***";
1331
- Markers2["delim"] = "*";
1332
- Markers2["end"] = "*/";
1333
- })(Markers = Markers || (Markers = {}));
1334
-
1335
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/util.js
1336
- function isSpace(source) {
1337
- return /^\s+$/.test(source);
1338
- }
1339
- function splitCR(source) {
1340
- const matches = source.match(/\r+$/);
1341
- return matches == null ? ["", source] : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];
1342
- }
1343
- function splitSpace(source) {
1344
- const matches = source.match(/^\s+/);
1345
- return matches == null ? ["", source] : [source.slice(0, matches[0].length), source.slice(matches[0].length)];
1346
- }
1347
- function splitLines(source) {
1348
- return source.split(/\n/);
1349
- }
1350
- function seedSpec(spec = {}) {
1351
- return Object.assign({ tag: "", name: "", type: "", optional: false, description: "", problems: [], source: [] }, spec);
1352
- }
1353
- function seedTokens(tokens = {}) {
1354
- return Object.assign({ start: "", delimiter: "", postDelimiter: "", tag: "", postTag: "", name: "", postName: "", type: "", postType: "", description: "", end: "", lineEnd: "" }, tokens);
1326
+ // node_modules/.pnpm/@fangzhongya+utils@0.0.73/node_modules/@fangzhongya/utils/dist/chunk-FS4JPT23.js
1327
+ function deComment(code) {
1328
+ let output = "";
1329
+ let state = "code";
1330
+ let escaping = false;
1331
+ let i = 0;
1332
+ const len = code.length;
1333
+ while (i < len) {
1334
+ const char = code[i];
1335
+ const nextChar = code[i + 1];
1336
+ switch (state) {
1337
+ case "code":
1338
+ if (char === "/" && nextChar === "/") {
1339
+ state = "singleLine";
1340
+ i += 2;
1341
+ } else if (char === "/" && nextChar === "*") {
1342
+ state = "multiLine";
1343
+ i += 2;
1344
+ } else if (char === "'") {
1345
+ state = "singleQuote";
1346
+ output += char;
1347
+ i++;
1348
+ } else if (char === '"') {
1349
+ state = "doubleQuote";
1350
+ output += char;
1351
+ i++;
1352
+ } else if (char === "`") {
1353
+ state = "template";
1354
+ output += char;
1355
+ i++;
1356
+ } else {
1357
+ output += char;
1358
+ i++;
1359
+ }
1360
+ break;
1361
+ case "singleLine":
1362
+ if (char === "\n" || char === "\r") {
1363
+ state = "code";
1364
+ output += char;
1365
+ i++;
1366
+ if (char === "\r" && nextChar === "\n") {
1367
+ output += nextChar;
1368
+ i++;
1369
+ }
1370
+ } else {
1371
+ i++;
1372
+ }
1373
+ break;
1374
+ case "multiLine":
1375
+ if (char === "*" && nextChar === "/") {
1376
+ state = "code";
1377
+ i += 2;
1378
+ if (output.length > 0 && /[a-zA-Z0-9_$]$/.test(output) && i < len && /[a-zA-Z0-9_$]/.test(code[i])) {
1379
+ output += " ";
1380
+ }
1381
+ } else {
1382
+ i++;
1383
+ }
1384
+ break;
1385
+ case "singleQuote":
1386
+ output += char;
1387
+ if (!escaping && char === "'") {
1388
+ state = "code";
1389
+ }
1390
+ escaping = !escaping && char === "\\";
1391
+ i++;
1392
+ break;
1393
+ case "doubleQuote":
1394
+ output += char;
1395
+ if (!escaping && char === '"') {
1396
+ state = "code";
1397
+ }
1398
+ escaping = !escaping && char === "\\";
1399
+ i++;
1400
+ break;
1401
+ case "template":
1402
+ output += char;
1403
+ if (!escaping && char === "`") {
1404
+ state = "code";
1405
+ } else if (!escaping && char === "$" && nextChar === "{") {
1406
+ output += nextChar;
1407
+ i += 2;
1408
+ continue;
1409
+ }
1410
+ escaping = !escaping && char === "\\";
1411
+ i++;
1412
+ break;
1413
+ }
1414
+ }
1415
+ return output;
1355
1416
  }
1356
1417
 
1357
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/block-parser.js
1358
- var reTag = /^@\S+/;
1359
- function getParser({ fence = "```" } = {}) {
1360
- const fencer = getFencer(fence);
1361
- const toggleFence = (source, isFenced) => fencer(source) ? !isFenced : isFenced;
1362
- return function parseBlock(source) {
1363
- const sections = [[]];
1364
- let isFenced = false;
1365
- for (const line of source) {
1366
- if (reTag.test(line.tokens.description) && !isFenced) {
1367
- sections.push([line]);
1368
- } else {
1369
- sections[sections.length - 1].push(line);
1418
+ // node_modules/.pnpm/@fangzhongya+utils@0.0.73/node_modules/@fangzhongya/utils/dist/chunk-N5Y3XGHX.js
1419
+ function getImports(code, includeType = false) {
1420
+ code = deComment(code);
1421
+ const imports = /* @__PURE__ */ new Set();
1422
+ const regex = /(?:import\s*(?:type\s+)?(?:(?:\w+|\*\s*as\s+\w+|\{[^}]*\})\s+from\s*)?['"]([^'"]+)['"]|import\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)|export\s*(?:type\s+)?(?:(?:\*|\*?\s*as\s+\w+|\{[^}]*\})\s+from\s*)?['"]([^'"]+)['"])/g;
1423
+ let match;
1424
+ while ((match = regex.exec(code)) !== null) {
1425
+ const path = match[1] || match[2] || match[3] || match[4];
1426
+ if (!path) continue;
1427
+ const fullMatch = match[0];
1428
+ if (!includeType) {
1429
+ if (fullMatch.includes("import") && isPureTypeImport(fullMatch) || fullMatch.includes("export") && isPureTypeExport(fullMatch)) {
1430
+ continue;
1370
1431
  }
1371
- isFenced = toggleFence(line.tokens.description, isFenced);
1372
1432
  }
1373
- return sections;
1374
- };
1433
+ imports.add(path);
1434
+ }
1435
+ return Array.from(imports);
1375
1436
  }
1376
- function getFencer(fence) {
1377
- if (typeof fence === "string")
1378
- return (source) => source.split(fence).length % 2 === 0;
1379
- return fence;
1437
+ function isPureTypeImport(importStatement) {
1438
+ const importTypeRegex = /^\s*import\s+type\b/;
1439
+ if (importTypeRegex.test(importStatement)) {
1440
+ return true;
1441
+ }
1442
+ if (importStatement.includes("{")) {
1443
+ const braceContent = importStatement.match(/\{([^}]*)\}/)?.[1] || "";
1444
+ const items = braceContent.split(",").map((item) => item.trim()).filter(Boolean);
1445
+ return items.length > 0 && items.every((item) => item.startsWith("type "));
1446
+ }
1447
+ return false;
1380
1448
  }
1381
-
1382
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/source-parser.js
1383
- function getParser2({ startLine = 0, markers = Markers } = {}) {
1384
- let block = null;
1385
- let num = startLine;
1386
- return function parseSource(source) {
1387
- let rest = source;
1388
- const tokens = seedTokens();
1389
- [tokens.lineEnd, rest] = splitCR(rest);
1390
- [tokens.start, rest] = splitSpace(rest);
1391
- if (block === null && rest.startsWith(markers.start) && !rest.startsWith(markers.nostart)) {
1392
- block = [];
1393
- tokens.delimiter = rest.slice(0, markers.start.length);
1394
- rest = rest.slice(markers.start.length);
1395
- [tokens.postDelimiter, rest] = splitSpace(rest);
1396
- }
1397
- if (block === null) {
1398
- num++;
1399
- return null;
1400
- }
1401
- const isClosed = rest.trimRight().endsWith(markers.end);
1402
- if (tokens.delimiter === "" && rest.startsWith(markers.delim) && !rest.startsWith(markers.end)) {
1403
- tokens.delimiter = markers.delim;
1404
- rest = rest.slice(markers.delim.length);
1405
- [tokens.postDelimiter, rest] = splitSpace(rest);
1406
- }
1407
- if (isClosed) {
1408
- const trimmed = rest.trimRight();
1409
- tokens.end = rest.slice(trimmed.length - markers.end.length);
1410
- rest = trimmed.slice(0, -markers.end.length);
1411
- }
1412
- tokens.description = rest;
1413
- block.push({ number: num, source, tokens });
1414
- num++;
1415
- if (isClosed) {
1416
- const result = block.slice();
1417
- block = null;
1418
- return result;
1419
- }
1420
- return null;
1421
- };
1449
+ function isPureTypeExport(exportStatement) {
1450
+ const exportTypeRegex = /^\s*export\s+type\b/;
1451
+ if (exportTypeRegex.test(exportStatement)) {
1452
+ return true;
1453
+ }
1454
+ if (exportStatement.includes("{")) {
1455
+ const braceContent = exportStatement.match(/\{([^}]*)\}/)?.[1] || "";
1456
+ const items = braceContent.split(",").map((item) => item.trim()).filter(Boolean);
1457
+ return items.length > 0 && items.every((item) => item.startsWith("type "));
1458
+ }
1459
+ return false;
1422
1460
  }
1423
1461
 
1424
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/spec-parser.js
1425
- function getParser3({ tokenizers }) {
1426
- return function parseSpec(source) {
1427
- var _a;
1428
- let spec = seedSpec({ source });
1429
- for (const tokenize of tokenizers) {
1430
- spec = tokenize(spec);
1431
- if ((_a = spec.problems[spec.problems.length - 1]) === null || _a === void 0 ? void 0 : _a.critical)
1432
- break;
1433
- }
1434
- return spec;
1435
- };
1462
+ // packages/utils/index.ts
1463
+ function getTextImport(jstext) {
1464
+ return new Promise(async (resolve2) => {
1465
+ const importss = getImports(jstext);
1466
+ resolve2(importss);
1467
+ });
1436
1468
  }
1437
1469
 
1438
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/tag.js
1439
- function tagTokenizer() {
1440
- return (spec) => {
1441
- const { tokens } = spec.source[0];
1442
- const match = tokens.description.match(/\s*(@(\S+))(\s*)/);
1443
- if (match === null) {
1444
- spec.problems.push({
1445
- code: "spec:tag:prefix",
1446
- message: 'tag should start with "@" symbol',
1447
- line: spec.source[0].number,
1448
- critical: true
1449
- });
1450
- return spec;
1451
- }
1452
- tokens.tag = match[1];
1453
- tokens.postTag = match[3];
1454
- tokens.description = tokens.description.slice(match[0].length);
1455
- spec.tag = match[2];
1456
- return spec;
1457
- };
1470
+ // packages/utils/glob.ts
1471
+ var componentsObj = {};
1472
+ var componentPropsObj = {};
1473
+ var componentNameKeys = [];
1474
+ var exampleObj = {};
1475
+ var examplesObj = {};
1476
+ var examplesRawObj = {};
1477
+ function getTests() {
1478
+ return getConfig("example");
1458
1479
  }
1459
-
1460
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/type.js
1461
- function typeTokenizer(spacing = "compact") {
1462
- const join5 = getJoiner(spacing);
1463
- return (spec) => {
1464
- let curlies = 0;
1465
- let lines = [];
1466
- for (const [i, { tokens }] of spec.source.entries()) {
1467
- let type = "";
1468
- if (i === 0 && tokens.description[0] !== "{")
1469
- return spec;
1470
- for (const ch of tokens.description) {
1471
- if (ch === "{")
1472
- curlies++;
1473
- if (ch === "}")
1474
- curlies--;
1475
- type += ch;
1476
- if (curlies === 0)
1477
- break;
1480
+ function setExampleObj(dir, example, vexample, comRaw) {
1481
+ const obj2 = mergeObject(example, vexample || {}, 3, true);
1482
+ obj2.exampless = obj2.exampless || [];
1483
+ obj2.examplessRaw = obj2.examplessRaw || [];
1484
+ const arr = [];
1485
+ const examples = obj2.examples;
1486
+ if (examples) {
1487
+ Object.keys(examples).forEach((key) => {
1488
+ arr.push(key);
1489
+ examplesObj[key] = examples[key];
1490
+ });
1491
+ }
1492
+ const examplesRaw = obj2.examplesRaw;
1493
+ const arrraw = [];
1494
+ if (obj2.urls && obj2.urls.length > 0) {
1495
+ obj2.exampless = obj2.urls;
1496
+ obj2.urls.forEach((key) => {
1497
+ arrraw.push(key);
1498
+ if (examplesRaw) {
1499
+ examplesRawObj[key] = getexamplesRawObj(examplesRaw, key);
1478
1500
  }
1479
- lines.push([tokens, type]);
1480
- if (curlies === 0)
1481
- break;
1482
- }
1483
- if (curlies !== 0) {
1484
- spec.problems.push({
1485
- code: "spec:type:unpaired-curlies",
1486
- message: "unpaired curlies",
1487
- line: spec.source[0].number,
1488
- critical: true
1501
+ });
1502
+ } else {
1503
+ obj2.exampless = arr;
1504
+ if (examplesRaw) {
1505
+ Object.keys(examplesRaw).forEach((key) => {
1506
+ arrraw.push(key);
1507
+ examplesRawObj[key] = getexamplesRawObj(examplesRaw, key);
1489
1508
  });
1490
- return spec;
1491
1509
  }
1492
- const parts = [];
1493
- const offset = lines[0][0].postDelimiter.length;
1494
- for (const [i, [tokens, type]] of lines.entries()) {
1495
- tokens.type = type;
1496
- if (i > 0) {
1497
- tokens.type = tokens.postDelimiter.slice(offset) + type;
1498
- tokens.postDelimiter = tokens.postDelimiter.slice(0, offset);
1499
- }
1500
- [tokens.postType, tokens.description] = splitSpace(tokens.description.slice(type.length));
1501
- parts.push(tokens.type);
1510
+ }
1511
+ obj2.examples = void 0;
1512
+ if (example.tests && comRaw) {
1513
+ const testsNanme = example.testsNanme || "/tests/";
1514
+ if (typeof testsNanme == "string") {
1515
+ Object.keys(comRaw).forEach((key) => {
1516
+ if (key.includes(testsNanme)) {
1517
+ obj2.exampless.push(key);
1518
+ arrraw.push(key);
1519
+ examplesRawObj[key] = getexamplesRawObj(comRaw, key);
1520
+ }
1521
+ });
1522
+ } else {
1523
+ Object.keys(comRaw).forEach((key) => {
1524
+ if (testsNanme.test(key)) {
1525
+ obj2.exampless.push(key);
1526
+ arrraw.push(key);
1527
+ examplesRawObj[key] = getexamplesRawObj(comRaw, key);
1528
+ }
1529
+ });
1502
1530
  }
1503
- parts[0] = parts[0].slice(1);
1504
- parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1);
1505
- spec.type = join5(parts);
1506
- return spec;
1507
- };
1531
+ }
1532
+ obj2.exampless = [...new Set(obj2.exampless)];
1533
+ obj2.examplessRaw = [...new Set(arrraw)];
1534
+ obj2.examplesRaw = void 0;
1535
+ exampleObj[dir] = obj2;
1508
1536
  }
1509
- var trim = (x) => x.trim();
1510
- function getJoiner(spacing) {
1511
- if (spacing === "compact")
1512
- return (t) => t.map(trim).join("");
1513
- else if (spacing === "preserve")
1514
- return (t) => t.join("\n");
1515
- else
1516
- return spacing;
1537
+ function getexamplesRawObj(comRaw, key) {
1538
+ if (typeof comRaw == "function") {
1539
+ return comRaw;
1540
+ } else if (comRaw) {
1541
+ return comRaw[key] || comRaw;
1542
+ } else {
1543
+ return comRaw;
1544
+ }
1517
1545
  }
1518
-
1519
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/name.js
1520
- var isQuoted = (s) => s && s.startsWith('"') && s.endsWith('"');
1521
- function nameTokenizer() {
1522
- const typeEnd = (num, { tokens }, i) => tokens.type === "" ? num : i;
1523
- return (spec) => {
1524
- const { tokens } = spec.source[spec.source.reduce(typeEnd, 0)];
1525
- const source = tokens.description.trimLeft();
1526
- const quotedGroups = source.split('"');
1527
- if (quotedGroups.length > 1 && quotedGroups[0] === "" && quotedGroups.length % 2 === 1) {
1528
- spec.name = quotedGroups[1];
1529
- tokens.name = `"${quotedGroups[1]}"`;
1530
- [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length));
1531
- return spec;
1532
- }
1533
- let brackets = 0;
1534
- let name = "";
1535
- let optional = false;
1536
- let defaultValue;
1537
- for (const ch of source) {
1538
- if (brackets === 0 && isSpace(ch))
1539
- break;
1540
- if (ch === "[")
1541
- brackets++;
1542
- if (ch === "]")
1543
- brackets--;
1544
- name += ch;
1546
+ var aliasObj = {};
1547
+ function getURLalias(value) {
1548
+ const alias = getConfig("resolve");
1549
+ if (aliasObj[value]) {
1550
+ return aliasObj[value];
1551
+ } else {
1552
+ for (let o of alias) {
1553
+ if (value.startsWith(o.find + "/")) {
1554
+ const t = o.replacement.replaceAll("\\", "/");
1555
+ const v = t + value.replace(o.find + "/", "/");
1556
+ aliasObj[value] = v;
1557
+ return v;
1558
+ }
1545
1559
  }
1546
- if (brackets !== 0) {
1547
- spec.problems.push({
1548
- code: "spec:name:unpaired-brackets",
1549
- message: "unpaired brackets",
1550
- line: spec.source[0].number,
1551
- critical: true
1560
+ }
1561
+ }
1562
+ async function getImport(text, type) {
1563
+ let jstext = "";
1564
+ if (type == "vue") {
1565
+ jstext = getVueTexts(text).script;
1566
+ } else if (type == "js" || type == "ts" || type == "") {
1567
+ jstext = text;
1568
+ }
1569
+ if (jstext) {
1570
+ const arr = await getTextImport(jstext);
1571
+ const yrs = [];
1572
+ if (arr && arr.length > 0) {
1573
+ arr.forEach((key) => {
1574
+ if (key) {
1575
+ if (key.startsWith("./") || key.startsWith("../")) {
1576
+ yrs.push(key);
1577
+ } else {
1578
+ const v = getURLalias(key);
1579
+ if (v) {
1580
+ yrs.push(v);
1581
+ }
1582
+ }
1583
+ }
1552
1584
  });
1553
- return spec;
1554
1585
  }
1555
- const nameToken = name;
1556
- if (name[0] === "[" && name[name.length - 1] === "]") {
1557
- optional = true;
1558
- name = name.slice(1, -1);
1559
- const parts = name.split("=");
1560
- name = parts[0].trim();
1561
- if (parts[1] !== void 0)
1562
- defaultValue = parts.slice(1).join("=").trim();
1563
- if (name === "") {
1564
- spec.problems.push({
1565
- code: "spec:name:empty-name",
1566
- message: "empty name",
1567
- line: spec.source[0].number,
1568
- critical: true
1569
- });
1570
- return spec;
1571
- }
1572
- if (defaultValue === "") {
1573
- spec.problems.push({
1574
- code: "spec:name:empty-default",
1575
- message: "empty default value",
1576
- line: spec.source[0].number,
1577
- critical: true
1578
- });
1579
- return spec;
1580
- }
1581
- if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) {
1582
- spec.problems.push({
1583
- code: "spec:name:invalid-default",
1584
- message: "invalid default value syntax",
1585
- line: spec.source[0].number,
1586
- critical: true
1586
+ return yrs;
1587
+ }
1588
+ }
1589
+ function getLocalTextTests(obj2) {
1590
+ return new Promise((resolve2) => {
1591
+ if (obj2) {
1592
+ if (obj2.raw) {
1593
+ resolve2(obj2.raw);
1594
+ } else if (obj2.getRaw) {
1595
+ obj2.getRaw(obj2).then((s) => {
1596
+ const m = getGetRawValue(s);
1597
+ obj2.raw = m;
1598
+ obj2.getRaw = null;
1599
+ resolve2(m);
1587
1600
  });
1588
- return spec;
1601
+ } else {
1602
+ resolve2("");
1589
1603
  }
1604
+ } else {
1605
+ resolve2("");
1590
1606
  }
1591
- spec.optional = optional;
1592
- spec.name = name;
1593
- tokens.name = nameToken;
1594
- if (defaultValue !== void 0)
1595
- spec.default = defaultValue;
1596
- [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length));
1597
- return spec;
1598
- };
1599
- }
1600
-
1601
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/description.js
1602
- function descriptionTokenizer(spacing = "compact", markers = Markers) {
1603
- const join5 = getJoiner2(spacing);
1604
- return (spec) => {
1605
- spec.description = join5(spec.source, markers);
1606
- return spec;
1607
- };
1608
- }
1609
- function getJoiner2(spacing) {
1610
- if (spacing === "compact")
1611
- return compactJoiner;
1612
- if (spacing === "preserve")
1613
- return preserveJoiner;
1614
- return spacing;
1615
- }
1616
- function compactJoiner(lines, markers = Markers) {
1617
- return lines.map(({ tokens: { description } }) => description.trim()).filter((description) => description !== "").join(" ");
1618
- }
1619
- var lineNo = (num, { tokens }, i) => tokens.type === "" ? num : i;
1620
- var getDescription = ({ tokens }) => (tokens.delimiter === "" ? tokens.start : tokens.postDelimiter.slice(1)) + tokens.description;
1621
- function preserveJoiner(lines, markers = Markers) {
1622
- if (lines.length === 0)
1623
- return "";
1624
- if (lines[0].tokens.description === "" && lines[0].tokens.delimiter === markers.start)
1625
- lines = lines.slice(1);
1626
- const lastLine = lines[lines.length - 1];
1627
- if (lastLine !== void 0 && lastLine.tokens.description === "" && lastLine.tokens.end.endsWith(markers.end))
1628
- lines = lines.slice(0, -1);
1629
- lines = lines.slice(lines.reduce(lineNo, 0));
1630
- return lines.map(getDescription).join("\n");
1631
- }
1632
-
1633
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/index.js
1634
- function getParser4({ startLine = 0, fence = "```", spacing = "compact", markers = Markers, tokenizers = [
1635
- tagTokenizer(),
1636
- typeTokenizer(spacing),
1637
- nameTokenizer(),
1638
- descriptionTokenizer(spacing)
1639
- ] } = {}) {
1640
- if (startLine < 0 || startLine % 1 > 0)
1641
- throw new Error("Invalid startLine");
1642
- const parseSource = getParser2({ startLine, markers });
1643
- const parseBlock = getParser({ fence });
1644
- const parseSpec = getParser3({ tokenizers });
1645
- const joinDescription = getJoiner2(spacing);
1646
- return function(source) {
1647
- const blocks = [];
1648
- for (const line of splitLines(source)) {
1649
- const lines = parseSource(line);
1650
- if (lines === null)
1651
- continue;
1652
- const sections = parseBlock(lines);
1653
- const specs = sections.slice(1).map(parseSpec);
1654
- blocks.push({
1655
- description: joinDescription(sections[0], markers),
1656
- tags: specs,
1657
- source: lines,
1658
- problems: specs.reduce((acc, spec) => acc.concat(spec.problems), [])
1659
- });
1660
- }
1661
- return blocks;
1662
- };
1663
- }
1664
-
1665
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/stringifier/index.js
1666
- function join3(tokens) {
1667
- return tokens.start + tokens.delimiter + tokens.postDelimiter + tokens.tag + tokens.postTag + tokens.type + tokens.postType + tokens.name + tokens.postName + tokens.description + tokens.end + tokens.lineEnd;
1668
- }
1669
- function getStringifier() {
1670
- return (block) => block.source.map(({ tokens }) => join3(tokens)).join("\n");
1671
- }
1672
-
1673
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/stringifier/inspect.js
1674
- var zeroWidth = {
1675
- line: 0,
1676
- start: 0,
1677
- delimiter: 0,
1678
- postDelimiter: 0,
1679
- tag: 0,
1680
- postTag: 0,
1681
- name: 0,
1682
- postName: 0,
1683
- type: 0,
1684
- postType: 0,
1685
- description: 0,
1686
- end: 0,
1687
- lineEnd: 0
1688
- };
1689
- var fields = Object.keys(zeroWidth);
1690
-
1691
- // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/index.js
1692
- function parse(source, options = {}) {
1693
- return getParser4(options)(source);
1694
- }
1695
- var stringify = getStringifier();
1696
-
1697
- // node_modules/.pnpm/@fangzhongya+utils@0.0.73/node_modules/@fangzhongya/utils/dist/chunk-FS4JPT23.js
1698
- function deComment(code) {
1699
- let output = "";
1700
- let state = "code";
1701
- let escaping = false;
1702
- let i = 0;
1703
- const len = code.length;
1704
- while (i < len) {
1705
- const char = code[i];
1706
- const nextChar = code[i + 1];
1707
- switch (state) {
1708
- case "code":
1709
- if (char === "/" && nextChar === "/") {
1710
- state = "singleLine";
1711
- i += 2;
1712
- } else if (char === "/" && nextChar === "*") {
1713
- state = "multiLine";
1714
- i += 2;
1715
- } else if (char === "'") {
1716
- state = "singleQuote";
1717
- output += char;
1718
- i++;
1719
- } else if (char === '"') {
1720
- state = "doubleQuote";
1721
- output += char;
1722
- i++;
1723
- } else if (char === "`") {
1724
- state = "template";
1725
- output += char;
1726
- i++;
1727
- } else {
1728
- output += char;
1729
- i++;
1730
- }
1731
- break;
1732
- case "singleLine":
1733
- if (char === "\n" || char === "\r") {
1734
- state = "code";
1735
- output += char;
1736
- i++;
1737
- if (char === "\r" && nextChar === "\n") {
1738
- output += nextChar;
1739
- i++;
1740
- }
1741
- } else {
1742
- i++;
1743
- }
1744
- break;
1745
- case "multiLine":
1746
- if (char === "*" && nextChar === "/") {
1747
- state = "code";
1748
- i += 2;
1749
- if (output.length > 0 && /[a-zA-Z0-9_$]$/.test(output) && i < len && /[a-zA-Z0-9_$]/.test(code[i])) {
1750
- output += " ";
1751
- }
1752
- } else {
1753
- i++;
1754
- }
1755
- break;
1756
- case "singleQuote":
1757
- output += char;
1758
- if (!escaping && char === "'") {
1759
- state = "code";
1760
- }
1761
- escaping = !escaping && char === "\\";
1762
- i++;
1763
- break;
1764
- case "doubleQuote":
1765
- output += char;
1766
- if (!escaping && char === '"') {
1767
- state = "code";
1768
- }
1769
- escaping = !escaping && char === "\\";
1770
- i++;
1771
- break;
1772
- case "template":
1773
- output += char;
1774
- if (!escaping && char === "`") {
1775
- state = "code";
1776
- } else if (!escaping && char === "$" && nextChar === "{") {
1777
- output += nextChar;
1778
- i += 2;
1779
- continue;
1780
- }
1781
- escaping = !escaping && char === "\\";
1782
- i++;
1783
- break;
1784
- }
1785
- }
1786
- return output;
1787
- }
1788
-
1789
- // node_modules/.pnpm/@fangzhongya+utils@0.0.73/node_modules/@fangzhongya/utils/dist/chunk-N5Y3XGHX.js
1790
- function getImports(code, includeType = false) {
1791
- code = deComment(code);
1792
- const imports = /* @__PURE__ */ new Set();
1793
- const regex = /(?:import\s*(?:type\s+)?(?:(?:\w+|\*\s*as\s+\w+|\{[^}]*\})\s+from\s*)?['"]([^'"]+)['"]|import\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)|export\s*(?:type\s+)?(?:(?:\*|\*?\s*as\s+\w+|\{[^}]*\})\s+from\s*)?['"]([^'"]+)['"])/g;
1794
- let match;
1795
- while ((match = regex.exec(code)) !== null) {
1796
- const path = match[1] || match[2] || match[3] || match[4];
1797
- if (!path) continue;
1798
- const fullMatch = match[0];
1799
- if (!includeType) {
1800
- if (fullMatch.includes("import") && isPureTypeImport(fullMatch) || fullMatch.includes("export") && isPureTypeExport(fullMatch)) {
1801
- continue;
1802
- }
1803
- }
1804
- imports.add(path);
1805
- }
1806
- return Array.from(imports);
1807
- }
1808
- function isPureTypeImport(importStatement) {
1809
- const importTypeRegex = /^\s*import\s+type\b/;
1810
- if (importTypeRegex.test(importStatement)) {
1811
- return true;
1812
- }
1813
- if (importStatement.includes("{")) {
1814
- const braceContent = importStatement.match(/\{([^}]*)\}/)?.[1] || "";
1815
- const items = braceContent.split(",").map((item) => item.trim()).filter(Boolean);
1816
- return items.length > 0 && items.every((item) => item.startsWith("type "));
1817
- }
1818
- return false;
1819
- }
1820
- function isPureTypeExport(exportStatement) {
1821
- const exportTypeRegex = /^\s*export\s+type\b/;
1822
- if (exportTypeRegex.test(exportStatement)) {
1823
- return true;
1824
- }
1825
- if (exportStatement.includes("{")) {
1826
- const braceContent = exportStatement.match(/\{([^}]*)\}/)?.[1] || "";
1827
- const items = braceContent.split(",").map((item) => item.trim()).filter(Boolean);
1828
- return items.length > 0 && items.every((item) => item.startsWith("type "));
1829
- }
1830
- return false;
1831
- }
1832
-
1833
- // packages/utils/index.ts
1834
- function getTextNotes(text) {
1835
- if (text) {
1836
- return parse(text);
1837
- }
1838
- }
1839
- function getTextImport(jstext) {
1840
- return new Promise(async (resolve2) => {
1841
- const importss = getImports(jstext);
1842
- resolve2(importss);
1843
- });
1844
- }
1845
-
1846
- // packages/utils/glob.ts
1847
- var componentsObj = {};
1848
- var componentPropsObj = {};
1849
- var componentNameKeys = [];
1850
- var exampleObj = {};
1851
- var examplesObj = {};
1852
- var examplesRawObj = {};
1853
- function getTests() {
1854
- return getConfig("example");
1855
- }
1856
- function setExampleObj(dir, example, vexample, comRaw) {
1857
- const obj2 = mergeObject(example, vexample || {}, 3, true);
1858
- obj2.exampless = obj2.exampless || [];
1859
- obj2.examplessRaw = obj2.examplessRaw || [];
1860
- const arr = [];
1861
- const examples = obj2.examples;
1862
- if (examples) {
1863
- Object.keys(examples).forEach((key) => {
1864
- arr.push(key);
1865
- examplesObj[key] = examples[key];
1866
- });
1867
- }
1868
- const examplesRaw = obj2.examplesRaw;
1869
- const arrraw = [];
1870
- if (obj2.urls && obj2.urls.length > 0) {
1871
- obj2.exampless = obj2.urls;
1872
- obj2.urls.forEach((key) => {
1873
- arrraw.push(key);
1874
- if (examplesRaw) {
1875
- examplesRawObj[key] = getexamplesRawObj(examplesRaw, key);
1876
- }
1877
- });
1878
- } else {
1879
- obj2.exampless = arr;
1880
- if (examplesRaw) {
1881
- Object.keys(examplesRaw).forEach((key) => {
1882
- arrraw.push(key);
1883
- examplesRawObj[key] = getexamplesRawObj(examplesRaw, key);
1884
- });
1885
- }
1886
- }
1887
- obj2.examples = void 0;
1888
- if (example.tests && comRaw) {
1889
- const testsNanme = example.testsNanme || "/tests/";
1890
- if (typeof testsNanme == "string") {
1891
- Object.keys(comRaw).forEach((key) => {
1892
- if (key.includes(testsNanme)) {
1893
- obj2.exampless.push(key);
1894
- arrraw.push(key);
1895
- examplesRawObj[key] = getexamplesRawObj(comRaw, key);
1896
- }
1897
- });
1898
- } else {
1899
- Object.keys(comRaw).forEach((key) => {
1900
- if (testsNanme.test(key)) {
1901
- obj2.exampless.push(key);
1902
- arrraw.push(key);
1903
- examplesRawObj[key] = getexamplesRawObj(comRaw, key);
1904
- }
1905
- });
1906
- }
1907
- }
1908
- obj2.exampless = [...new Set(obj2.exampless)];
1909
- obj2.examplessRaw = [...new Set(arrraw)];
1910
- obj2.examplesRaw = void 0;
1911
- exampleObj[dir] = obj2;
1912
- }
1913
- function getexamplesRawObj(comRaw, key) {
1914
- if (typeof comRaw == "function") {
1915
- return comRaw;
1916
- } else if (comRaw) {
1917
- return comRaw[key] || comRaw;
1918
- } else {
1919
- return comRaw;
1920
- }
1921
- }
1922
- var aliasObj = {};
1923
- function getURLalias(value) {
1924
- const alias = getConfig("resolve");
1925
- if (aliasObj[value]) {
1926
- return aliasObj[value];
1927
- } else {
1928
- for (let o of alias) {
1929
- if (value.startsWith(o.find + "/")) {
1930
- const t = o.replacement.replaceAll("\\", "/");
1931
- const v = t + value.replace(o.find + "/", "/");
1932
- aliasObj[value] = v;
1933
- return v;
1934
- }
1935
- }
1936
- }
1937
- }
1938
- async function getImport(text, type) {
1939
- let jstext = "";
1940
- if (type == "vue") {
1941
- jstext = getVueTexts(text).script;
1942
- } else if (type == "js" || type == "ts" || type == "") {
1943
- jstext = text;
1944
- }
1945
- if (jstext) {
1946
- const arr = await getTextImport(jstext);
1947
- const yrs = [];
1948
- if (arr && arr.length > 0) {
1949
- arr.forEach((key) => {
1950
- if (key) {
1951
- if (key.startsWith("./") || key.startsWith("../")) {
1952
- yrs.push(key);
1953
- } else {
1954
- const v = getURLalias(key);
1955
- if (v) {
1956
- yrs.push(v);
1957
- }
1958
- }
1959
- }
1960
- });
1961
- }
1962
- return yrs;
1963
- }
1964
- }
1965
- function getLocalTextTests(obj2) {
1966
- return new Promise((resolve2) => {
1967
- if (obj2) {
1968
- if (obj2.raw) {
1969
- resolve2(obj2.raw);
1970
- } else if (obj2.getRaw) {
1971
- obj2.getRaw(obj2).then((s) => {
1972
- const m = getGetRawValue(s);
1973
- obj2.raw = m;
1974
- obj2.getRaw = null;
1975
- resolve2(m);
1976
- });
1977
- } else {
1978
- resolve2("");
1979
- }
1980
- } else {
1981
- resolve2("");
1982
- }
1983
- });
1607
+ });
1984
1608
  }
1985
1609
  function getLevelUrl(key, obj2) {
1986
1610
  key = (key || "") + "";
@@ -2528,12 +2152,19 @@ var props = {
2528
2152
  },
2529
2153
  required(obj2) {
2530
2154
  if (obj2.required) {
2531
- return obj2.required.name + obj2.required.description;
2155
+ return obj2.required.name + obj2.required.description || "true";
2532
2156
  } else if (obj2.props) {
2533
2157
  return obj2.props.required;
2534
2158
  } else {
2535
2159
  return "";
2536
2160
  }
2161
+ },
2162
+ model(obj2) {
2163
+ if (obj2.model) {
2164
+ return obj2.model.name + obj2.model.description || "true";
2165
+ } else {
2166
+ return "";
2167
+ }
2537
2168
  }
2538
2169
  };
2539
2170
  var emits = {
@@ -2688,646 +2319,702 @@ function getSlotValue(arr) {
2688
2319
  });
2689
2320
  }
2690
2321
 
2691
- // packages/components/test/index.ts
2692
- function getObj(v) {
2693
- delete v.problems;
2694
- delete v.source;
2695
- return v;
2696
- }
2697
- function getFilter(obj2, keyArr) {
2698
- const _objs = {
2699
- descriptions: obj2?.description || ""
2700
- };
2701
- const arr = [];
2702
- if (obj2?.tags) {
2703
- obj2?.tags?.forEach((v, index) => {
2704
- let tag = v.tag;
2705
- let ov = getObj(v);
2706
- if (!_objs.hasOwnProperty(tag) && keyArr.includes(tag)) {
2707
- _objs[tag] = ov;
2708
- } else {
2709
- let ao = {};
2710
- ao[tag] = ov;
2711
- arr.push({
2712
- key: tag,
2713
- value: ao
2714
- });
2715
- }
2716
- });
2717
- }
2718
- return {
2719
- arr,
2720
- obj: _objs
2721
- };
2722
- }
2723
- var titles = [];
2724
- function setTitle(obj2) {
2725
- const arr = ["title", "author", "date"];
2726
- const fobj = getFilter(obj2, arr);
2727
- const value = {};
2728
- arr.forEach((key) => {
2729
- value[key] = fobj.obj[key];
2730
- });
2731
- addTitle(value);
2732
- fobj.arr.forEach((o) => {
2733
- addTags(o.key, o.value);
2734
- });
2322
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/primitives.js
2323
+ var Markers;
2324
+ (function(Markers2) {
2325
+ Markers2["start"] = "/**";
2326
+ Markers2["nostart"] = "/***";
2327
+ Markers2["delim"] = "*";
2328
+ Markers2["end"] = "*/";
2329
+ })(Markers = Markers || (Markers = {}));
2330
+
2331
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/util.js
2332
+ function isSpace(source) {
2333
+ return /^\s+$/.test(source);
2735
2334
  }
2736
- var states = [];
2737
- function setState(obj2) {
2738
- const arr = ["state", "type"];
2739
- const fobj = getFilter(obj2, arr);
2740
- const value = {};
2741
- arr.forEach((key) => {
2742
- value[key] = fobj.obj[key];
2743
- });
2744
- addState(value);
2745
- fobj.arr.forEach((o) => {
2746
- addTags(o.key, o.value);
2747
- });
2335
+ function splitCR(source) {
2336
+ const matches = source.match(/\r+$/);
2337
+ return matches == null ? ["", source] : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];
2748
2338
  }
2749
- function addTitle(value) {
2750
- titles.push(value);
2339
+ function splitSpace(source) {
2340
+ const matches = source.match(/^\s+/);
2341
+ return matches == null ? ["", source] : [source.slice(0, matches[0].length), source.slice(matches[0].length)];
2751
2342
  }
2752
- function addProposal(value) {
2753
- titles.push(value);
2343
+ function splitLines(source) {
2344
+ return source.split(/\n/);
2754
2345
  }
2755
- function addError(value) {
2756
- titles.push(value);
2346
+ function seedSpec(spec = {}) {
2347
+ return Object.assign({ tag: "", name: "", type: "", optional: false, description: "", problems: [], source: [] }, spec);
2757
2348
  }
2758
- function addState(value) {
2759
- states.push(value);
2349
+ function seedTokens(tokens = {}) {
2350
+ return Object.assign({ start: "", delimiter: "", postDelimiter: "", tag: "", postTag: "", name: "", postName: "", type: "", postType: "", description: "", end: "", lineEnd: "" }, tokens);
2760
2351
  }
2761
- function addTags(tag, obj2) {
2762
- switch (tag) {
2763
- case "title":
2764
- addTitle(obj2);
2765
- return true;
2766
- case "proposal":
2767
- addProposal(obj2);
2768
- return true;
2769
- case "error":
2770
- addError(obj2);
2771
- return true;
2772
- case "state":
2773
- addState(obj2);
2774
- return true;
2775
- case "text":
2776
- addTitle(obj2);
2777
- return true;
2778
- case "html":
2779
- addTitle(obj2);
2780
- return true;
2781
- default:
2782
- return false;
2783
- }
2352
+
2353
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/block-parser.js
2354
+ var reTag = /^@\S+/;
2355
+ function getParser({ fence = "```" } = {}) {
2356
+ const fencer = getFencer(fence);
2357
+ const toggleFence = (source, isFenced) => fencer(source) ? !isFenced : isFenced;
2358
+ return function parseBlock(source) {
2359
+ const sections = [[]];
2360
+ let isFenced = false;
2361
+ for (const line of source) {
2362
+ if (reTag.test(line.tokens.description) && !isFenced) {
2363
+ sections.push([line]);
2364
+ } else {
2365
+ sections[sections.length - 1].push(line);
2366
+ }
2367
+ isFenced = toggleFence(line.tokens.description, isFenced);
2368
+ }
2369
+ return sections;
2370
+ };
2784
2371
  }
2785
- function setTags(tag, obj2) {
2786
- switch (tag) {
2787
- case "title":
2788
- setTitle(obj2);
2789
- return true;
2790
- // case 'proposal':
2791
- // setProposal(obj);
2792
- // return true;
2793
- // case 'error':
2794
- // setError(obj);
2795
- // return true;
2796
- case "state":
2797
- setState(obj2);
2798
- return true;
2799
- default:
2800
- return false;
2801
- }
2372
+ function getFencer(fence) {
2373
+ if (typeof fence === "string")
2374
+ return (source) => source.split(fence).length % 2 === 0;
2375
+ return fence;
2802
2376
  }
2803
- function getNotes(text) {
2804
- titles = [];
2805
- states = [];
2806
- const notes = getTextNotes(text);
2807
- notes?.forEach((obj2) => {
2808
- let tags = obj2?.tags || [];
2809
- let lg = tags?.length || 0;
2810
- if (lg > 0) {
2811
- for (let i = 0; i < lg; i++) {
2812
- const v = tags[i] || {};
2813
- let is = setTags(v.tag, obj2);
2814
- if (is) {
2815
- break;
2816
- }
2817
- }
2377
+
2378
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/source-parser.js
2379
+ function getParser2({ startLine = 0, markers = Markers } = {}) {
2380
+ let block = null;
2381
+ let num = startLine;
2382
+ return function parseSource(source) {
2383
+ let rest = source;
2384
+ const tokens = seedTokens();
2385
+ [tokens.lineEnd, rest] = splitCR(rest);
2386
+ [tokens.start, rest] = splitSpace(rest);
2387
+ if (block === null && rest.startsWith(markers.start) && !rest.startsWith(markers.nostart)) {
2388
+ block = [];
2389
+ tokens.delimiter = rest.slice(0, markers.start.length);
2390
+ rest = rest.slice(markers.start.length);
2391
+ [tokens.postDelimiter, rest] = splitSpace(rest);
2392
+ }
2393
+ if (block === null) {
2394
+ num++;
2395
+ return null;
2396
+ }
2397
+ const isClosed = rest.trimRight().endsWith(markers.end);
2398
+ if (tokens.delimiter === "" && rest.startsWith(markers.delim) && !rest.startsWith(markers.end)) {
2399
+ tokens.delimiter = markers.delim;
2400
+ rest = rest.slice(markers.delim.length);
2401
+ [tokens.postDelimiter, rest] = splitSpace(rest);
2402
+ }
2403
+ if (isClosed) {
2404
+ const trimmed = rest.trimRight();
2405
+ tokens.end = rest.slice(trimmed.length - markers.end.length);
2406
+ rest = trimmed.slice(0, -markers.end.length);
2818
2407
  }
2819
- });
2820
- return {
2821
- titles,
2822
- states
2408
+ tokens.description = rest;
2409
+ block.push({ number: num, source, tokens });
2410
+ num++;
2411
+ if (isClosed) {
2412
+ const result = block.slice();
2413
+ block = null;
2414
+ return result;
2415
+ }
2416
+ return null;
2823
2417
  };
2824
2418
  }
2825
2419
 
2826
- // packages/components/compo/top.ts
2827
- import { defineComponent, h } from "vue";
2828
- function getTopDom(props2, h4, isZy) {
2829
- let doms = [];
2830
- let domss = [];
2831
- let list = [];
2832
- const getValue = (v) => {
2833
- if (isZy) {
2834
- return htmlEscape(v);
2835
- } else {
2836
- return v;
2837
- }
2838
- };
2839
- const setTitle3 = () => {
2840
- if (list.length > 0) {
2841
- doms.push(
2842
- h4(
2843
- "div",
2844
- {
2845
- class: "compo-top-list"
2846
- },
2847
- list
2848
- )
2849
- );
2850
- list = [];
2420
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/spec-parser.js
2421
+ function getParser3({ tokenizers }) {
2422
+ return function parseSpec(source) {
2423
+ var _a;
2424
+ let spec = seedSpec({ source });
2425
+ for (const tokenize of tokenizers) {
2426
+ spec = tokenize(spec);
2427
+ if ((_a = spec.problems[spec.problems.length - 1]) === null || _a === void 0 ? void 0 : _a.critical)
2428
+ break;
2851
2429
  }
2430
+ return spec;
2852
2431
  };
2853
- const setDivision = () => {
2854
- if (doms.length > 0) {
2855
- domss.push(
2856
- h4(
2857
- "div",
2858
- {
2859
- class: "compo-top-division"
2860
- },
2861
- doms
2862
- )
2863
- );
2864
- doms = [];
2432
+ }
2433
+
2434
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/tag.js
2435
+ function tagTokenizer() {
2436
+ return (spec) => {
2437
+ const { tokens } = spec.source[0];
2438
+ const match = tokens.description.match(/\s*(@(\S+))(\s*)/);
2439
+ if (match === null) {
2440
+ spec.problems.push({
2441
+ code: "spec:tag:prefix",
2442
+ message: 'tag should start with "@" symbol',
2443
+ line: spec.source[0].number,
2444
+ critical: true
2445
+ });
2446
+ return spec;
2865
2447
  }
2448
+ tokens.tag = match[1];
2449
+ tokens.postTag = match[3];
2450
+ tokens.description = tokens.description.slice(match[0].length);
2451
+ spec.tag = match[2];
2452
+ return spec;
2866
2453
  };
2867
- props2?.forEach((obj2) => {
2868
- const info = [];
2869
- let is = false;
2870
- if (obj2.date) {
2871
- is = true;
2872
- info.push(
2873
- h4(
2874
- "div",
2875
- {
2876
- class: "compo-top-date"
2877
- },
2878
- [
2879
- h4("span", {}, "\u66F4\u65B0\u65F6\u95F4\uFF1A"),
2880
- h4("span", {}, [
2881
- getValue(
2882
- obj2.date.name + " " + obj2.date.description
2883
- )
2884
- ])
2885
- ]
2886
- )
2887
- );
2888
- }
2889
- if (obj2.author) {
2890
- is = true;
2891
- info.push(
2892
- h4(
2893
- "div",
2894
- {
2895
- class: "compo-top-author"
2896
- },
2897
- [
2898
- h4("span", {}, "\u4F5C\u8005\uFF1A"),
2899
- h4("span", {}, [
2900
- getValue(
2901
- obj2.author.name + " " + obj2.author.description
2902
- )
2903
- ])
2904
- ]
2905
- )
2906
- );
2907
- }
2908
- if (obj2.title && (obj2.title.type || obj2.title.name || obj2.title.description)) {
2909
- setTitle3();
2910
- if (is) {
2911
- setDivision();
2912
- }
2913
- let type = (obj2.title.type || "div").split(".");
2914
- let c = type[1] || "";
2915
- if (type[0] == "html") {
2916
- doms.push(
2917
- h4("div", {
2918
- class: "compo-top-title " + c,
2919
- innerHTML: obj2.title.name + " " + obj2.title.description
2920
- })
2921
- );
2922
- } else {
2923
- doms.push(
2924
- h4(
2925
- type[0],
2926
- {
2927
- class: "compo-top-title " + c
2928
- },
2929
- [
2930
- h4("span", {}, [
2931
- getValue(
2932
- obj2.title.name + " " + obj2.title.description
2933
- )
2934
- ])
2935
- ]
2936
- )
2937
- );
2938
- }
2939
- }
2940
- if (is) {
2941
- if (list.length > 0) {
2942
- setTitle3();
2943
- setDivision();
2944
- }
2945
- doms.push(
2946
- h4(
2947
- "div",
2948
- {
2949
- class: "compo-top-info"
2950
- },
2951
- info
2952
- )
2953
- );
2954
- }
2955
- if (obj2.html) {
2956
- let type = (obj2.html.type || "div").split(".");
2957
- let c = type[1] || "";
2958
- list.push(
2959
- h4(type[0], {
2960
- class: "compo-top-html " + c,
2961
- innerHTML: obj2.html.name + " " + obj2.html.description
2962
- })
2963
- );
2964
- }
2965
- ["text"].forEach((v) => {
2966
- if (obj2[v]) {
2967
- let type = (obj2[v].type || "div").split(".");
2968
- let c = type[1] || "";
2969
- if (type[0] == "html") {
2970
- list.push(
2971
- h4("div", {
2972
- class: "compo-top-" + v + " " + c,
2973
- innerHTML: obj2[v].name + " " + obj2[v].description
2974
- })
2975
- );
2976
- } else {
2977
- list.push(
2978
- h4(
2979
- type[0],
2980
- {
2981
- class: "compo-top-" + v + " " + c
2982
- },
2983
- [
2984
- h4("span", {}, [
2985
- getValue(
2986
- obj2[v].name + " " + obj2[v].description
2987
- )
2988
- ])
2989
- ]
2990
- )
2991
- );
2992
- }
2993
- }
2994
- });
2995
- });
2996
- setTitle3();
2997
- setDivision();
2998
- return domss;
2999
2454
  }
3000
- var top_default = defineComponent({
3001
- /**
3002
- * @props {Stinrg} value 插入数据
3003
- */
3004
- props: {
3005
- value: Array
3006
- },
3007
- render(propss, a, props2) {
3008
- const domss = getTopDom(props2.value, h);
3009
- return h(
3010
- "div",
3011
- {
3012
- class: "compo-top"
3013
- },
3014
- domss
3015
- );
3016
- }
3017
- });
3018
2455
 
3019
- // packages/components/test/top.ts
3020
- import { defineComponent as defineComponent2, h as h2 } from "vue";
3021
- function getTestTopDom(props2, h4, isZy) {
3022
- let doms = [];
3023
- let domss = [];
3024
- let list = [];
3025
- const getValue = (v) => {
3026
- if (isZy) {
3027
- return htmlEscape(v);
3028
- } else {
3029
- return v;
2456
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/type.js
2457
+ function typeTokenizer(spacing = "compact") {
2458
+ const join5 = getJoiner(spacing);
2459
+ return (spec) => {
2460
+ let curlies = 0;
2461
+ let lines = [];
2462
+ for (const [i, { tokens }] of spec.source.entries()) {
2463
+ let type = "";
2464
+ if (i === 0 && tokens.description[0] !== "{")
2465
+ return spec;
2466
+ for (const ch of tokens.description) {
2467
+ if (ch === "{")
2468
+ curlies++;
2469
+ if (ch === "}")
2470
+ curlies--;
2471
+ type += ch;
2472
+ if (curlies === 0)
2473
+ break;
2474
+ }
2475
+ lines.push([tokens, type]);
2476
+ if (curlies === 0)
2477
+ break;
3030
2478
  }
3031
- };
3032
- const setTitle3 = () => {
3033
- if (list.length > 0) {
3034
- doms.push(
3035
- h4(
3036
- "div",
3037
- {
3038
- class: "test-top-list"
3039
- },
3040
- list
3041
- )
3042
- );
3043
- list = [];
2479
+ if (curlies !== 0) {
2480
+ spec.problems.push({
2481
+ code: "spec:type:unpaired-curlies",
2482
+ message: "unpaired curlies",
2483
+ line: spec.source[0].number,
2484
+ critical: true
2485
+ });
2486
+ return spec;
3044
2487
  }
3045
- };
3046
- const setDivision = () => {
3047
- if (doms.length > 0) {
3048
- domss.push(
3049
- h4(
3050
- "div",
3051
- {
3052
- class: "test-top-division"
3053
- },
3054
- doms
3055
- )
3056
- );
3057
- doms = [];
2488
+ const parts = [];
2489
+ const offset = lines[0][0].postDelimiter.length;
2490
+ for (const [i, [tokens, type]] of lines.entries()) {
2491
+ tokens.type = type;
2492
+ if (i > 0) {
2493
+ tokens.type = tokens.postDelimiter.slice(offset) + type;
2494
+ tokens.postDelimiter = tokens.postDelimiter.slice(0, offset);
2495
+ }
2496
+ [tokens.postType, tokens.description] = splitSpace(tokens.description.slice(type.length));
2497
+ parts.push(tokens.type);
3058
2498
  }
2499
+ parts[0] = parts[0].slice(1);
2500
+ parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1);
2501
+ spec.type = join5(parts);
2502
+ return spec;
3059
2503
  };
3060
- props2.forEach((obj2) => {
3061
- const info = [];
3062
- let is = false;
3063
- if (obj2.date) {
3064
- is = true;
3065
- info.push(
3066
- h4(
3067
- "div",
3068
- {
3069
- class: "test-top-date"
3070
- },
3071
- [
3072
- h4("span", {}, "\u66F4\u65B0\u65F6\u95F4\uFF1A"),
3073
- h4("span", {}, [
3074
- getValue(
3075
- obj2.date.name + " " + obj2.date.description
3076
- )
3077
- ])
3078
- ]
3079
- )
3080
- );
2504
+ }
2505
+ var trim = (x) => x.trim();
2506
+ function getJoiner(spacing) {
2507
+ if (spacing === "compact")
2508
+ return (t) => t.map(trim).join("");
2509
+ else if (spacing === "preserve")
2510
+ return (t) => t.join("\n");
2511
+ else
2512
+ return spacing;
2513
+ }
2514
+
2515
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/name.js
2516
+ var isQuoted = (s) => s && s.startsWith('"') && s.endsWith('"');
2517
+ function nameTokenizer() {
2518
+ const typeEnd = (num, { tokens }, i) => tokens.type === "" ? num : i;
2519
+ return (spec) => {
2520
+ const { tokens } = spec.source[spec.source.reduce(typeEnd, 0)];
2521
+ const source = tokens.description.trimLeft();
2522
+ const quotedGroups = source.split('"');
2523
+ if (quotedGroups.length > 1 && quotedGroups[0] === "" && quotedGroups.length % 2 === 1) {
2524
+ spec.name = quotedGroups[1];
2525
+ tokens.name = `"${quotedGroups[1]}"`;
2526
+ [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length));
2527
+ return spec;
3081
2528
  }
3082
- if (obj2.author) {
3083
- is = true;
3084
- info.push(
3085
- h4(
3086
- "div",
3087
- {
3088
- class: "test-top-author"
3089
- },
3090
- [
3091
- h4("span", {}, "\u4F5C\u8005\uFF1A"),
3092
- h4("span", {}, [
3093
- getValue(
3094
- obj2.author.name + " " + obj2.author.description
3095
- )
3096
- ])
3097
- ]
3098
- )
3099
- );
2529
+ let brackets = 0;
2530
+ let name = "";
2531
+ let optional = false;
2532
+ let defaultValue;
2533
+ for (const ch of source) {
2534
+ if (brackets === 0 && isSpace(ch))
2535
+ break;
2536
+ if (ch === "[")
2537
+ brackets++;
2538
+ if (ch === "]")
2539
+ brackets--;
2540
+ name += ch;
3100
2541
  }
3101
- if (obj2.title && (obj2.title.type || obj2.title.name || obj2.title.description)) {
3102
- setTitle3();
3103
- if (is) {
3104
- setDivision();
2542
+ if (brackets !== 0) {
2543
+ spec.problems.push({
2544
+ code: "spec:name:unpaired-brackets",
2545
+ message: "unpaired brackets",
2546
+ line: spec.source[0].number,
2547
+ critical: true
2548
+ });
2549
+ return spec;
2550
+ }
2551
+ const nameToken = name;
2552
+ if (name[0] === "[" && name[name.length - 1] === "]") {
2553
+ optional = true;
2554
+ name = name.slice(1, -1);
2555
+ const parts = name.split("=");
2556
+ name = parts[0].trim();
2557
+ if (parts[1] !== void 0)
2558
+ defaultValue = parts.slice(1).join("=").trim();
2559
+ if (name === "") {
2560
+ spec.problems.push({
2561
+ code: "spec:name:empty-name",
2562
+ message: "empty name",
2563
+ line: spec.source[0].number,
2564
+ critical: true
2565
+ });
2566
+ return spec;
3105
2567
  }
3106
- let type = (obj2.title.type || "div").split(".");
3107
- let c = type[1] || "";
3108
- if (type[0] == "html") {
3109
- doms.push(
3110
- h4("div", {
3111
- class: "test-top-title " + c,
3112
- innerHTML: obj2.title.name + " " + obj2.title.description
3113
- })
3114
- );
2568
+ if (defaultValue === "") {
2569
+ spec.problems.push({
2570
+ code: "spec:name:empty-default",
2571
+ message: "empty default value",
2572
+ line: spec.source[0].number,
2573
+ critical: true
2574
+ });
2575
+ return spec;
2576
+ }
2577
+ if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) {
2578
+ spec.problems.push({
2579
+ code: "spec:name:invalid-default",
2580
+ message: "invalid default value syntax",
2581
+ line: spec.source[0].number,
2582
+ critical: true
2583
+ });
2584
+ return spec;
2585
+ }
2586
+ }
2587
+ spec.optional = optional;
2588
+ spec.name = name;
2589
+ tokens.name = nameToken;
2590
+ if (defaultValue !== void 0)
2591
+ spec.default = defaultValue;
2592
+ [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length));
2593
+ return spec;
2594
+ };
2595
+ }
2596
+
2597
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/tokenizers/description.js
2598
+ function descriptionTokenizer(spacing = "compact", markers = Markers) {
2599
+ const join5 = getJoiner2(spacing);
2600
+ return (spec) => {
2601
+ spec.description = join5(spec.source, markers);
2602
+ return spec;
2603
+ };
2604
+ }
2605
+ function getJoiner2(spacing) {
2606
+ if (spacing === "compact")
2607
+ return compactJoiner;
2608
+ if (spacing === "preserve")
2609
+ return preserveJoiner;
2610
+ return spacing;
2611
+ }
2612
+ function compactJoiner(lines, markers = Markers) {
2613
+ return lines.map(({ tokens: { description } }) => description.trim()).filter((description) => description !== "").join(" ");
2614
+ }
2615
+ var lineNo = (num, { tokens }, i) => tokens.type === "" ? num : i;
2616
+ var getDescription = ({ tokens }) => (tokens.delimiter === "" ? tokens.start : tokens.postDelimiter.slice(1)) + tokens.description;
2617
+ function preserveJoiner(lines, markers = Markers) {
2618
+ if (lines.length === 0)
2619
+ return "";
2620
+ if (lines[0].tokens.description === "" && lines[0].tokens.delimiter === markers.start)
2621
+ lines = lines.slice(1);
2622
+ const lastLine = lines[lines.length - 1];
2623
+ if (lastLine !== void 0 && lastLine.tokens.description === "" && lastLine.tokens.end.endsWith(markers.end))
2624
+ lines = lines.slice(0, -1);
2625
+ lines = lines.slice(lines.reduce(lineNo, 0));
2626
+ return lines.map(getDescription).join("\n");
2627
+ }
2628
+
2629
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/parser/index.js
2630
+ function getParser4({ startLine = 0, fence = "```", spacing = "compact", markers = Markers, tokenizers = [
2631
+ tagTokenizer(),
2632
+ typeTokenizer(spacing),
2633
+ nameTokenizer(),
2634
+ descriptionTokenizer(spacing)
2635
+ ] } = {}) {
2636
+ if (startLine < 0 || startLine % 1 > 0)
2637
+ throw new Error("Invalid startLine");
2638
+ const parseSource = getParser2({ startLine, markers });
2639
+ const parseBlock = getParser({ fence });
2640
+ const parseSpec = getParser3({ tokenizers });
2641
+ const joinDescription = getJoiner2(spacing);
2642
+ return function(source) {
2643
+ const blocks = [];
2644
+ for (const line of splitLines(source)) {
2645
+ const lines = parseSource(line);
2646
+ if (lines === null)
2647
+ continue;
2648
+ const sections = parseBlock(lines);
2649
+ const specs = sections.slice(1).map(parseSpec);
2650
+ blocks.push({
2651
+ description: joinDescription(sections[0], markers),
2652
+ tags: specs,
2653
+ source: lines,
2654
+ problems: specs.reduce((acc, spec) => acc.concat(spec.problems), [])
2655
+ });
2656
+ }
2657
+ return blocks;
2658
+ };
2659
+ }
2660
+
2661
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/stringifier/index.js
2662
+ function join3(tokens) {
2663
+ return tokens.start + tokens.delimiter + tokens.postDelimiter + tokens.tag + tokens.postTag + tokens.type + tokens.postType + tokens.name + tokens.postName + tokens.description + tokens.end + tokens.lineEnd;
2664
+ }
2665
+ function getStringifier() {
2666
+ return (block) => block.source.map(({ tokens }) => join3(tokens)).join("\n");
2667
+ }
2668
+
2669
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/stringifier/inspect.js
2670
+ var zeroWidth = {
2671
+ line: 0,
2672
+ start: 0,
2673
+ delimiter: 0,
2674
+ postDelimiter: 0,
2675
+ tag: 0,
2676
+ postTag: 0,
2677
+ name: 0,
2678
+ postName: 0,
2679
+ type: 0,
2680
+ postType: 0,
2681
+ description: 0,
2682
+ end: 0,
2683
+ lineEnd: 0
2684
+ };
2685
+ var fields = Object.keys(zeroWidth);
2686
+
2687
+ // node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/index.js
2688
+ function parse(source, options = {}) {
2689
+ return getParser4(options)(source);
2690
+ }
2691
+ var stringify = getStringifier();
2692
+
2693
+ // packages/utils/annotat.ts
2694
+ var notesObj = {
2695
+ titles: [],
2696
+ propss: [],
2697
+ slots: [],
2698
+ emitss: [],
2699
+ exposes: []
2700
+ };
2701
+ function init() {
2702
+ Object.keys(notesObj).forEach((key) => {
2703
+ notesObj[key] = [];
2704
+ });
2705
+ }
2706
+ function getDefault(ss, iss) {
2707
+ let char = ss.charAt(0);
2708
+ let css2 = [
2709
+ ['"', '"'],
2710
+ ["'", "'"],
2711
+ ["`", "`"],
2712
+ ["(", ")"],
2713
+ ["{", "}"],
2714
+ ["[", "]"]
2715
+ ];
2716
+ const cs = css2.map((o) => o[0]);
2717
+ let ci = cs.indexOf(char);
2718
+ if (ci != -1) {
2719
+ let bracketStack = [char];
2720
+ for (let i = 1; i < ss.length; i++) {
2721
+ char = ss[i];
2722
+ ci = cs.indexOf(char);
2723
+ if (ci != -1) {
2724
+ if (ci > 2) {
2725
+ bracketStack.push(char);
2726
+ } else {
2727
+ if (bracketStack[bracketStack.length - 1] === char) {
2728
+ bracketStack.pop();
2729
+ } else {
2730
+ bracketStack.push(char);
2731
+ }
2732
+ }
3115
2733
  } else {
3116
- doms.push(
3117
- h4(
3118
- type[0],
3119
- {
3120
- class: "test-top-title " + c
3121
- },
3122
- [
3123
- h4("span", {}, [
3124
- getValue(
3125
- obj2.title.name + " " + obj2.title.description
3126
- )
3127
- ])
3128
- ]
3129
- )
3130
- );
2734
+ let is = false;
2735
+ for (let v of css2) {
2736
+ if (char === v[1] && bracketStack[bracketStack.length - 1] === v[0]) {
2737
+ is = true;
2738
+ break;
2739
+ }
2740
+ }
2741
+ if (is) {
2742
+ bracketStack.pop();
2743
+ }
3131
2744
  }
3132
- }
3133
- if (is) {
3134
- if (list.length > 0) {
3135
- setTitle3();
3136
- setDivision();
2745
+ if (bracketStack.length === 0) {
2746
+ if (iss && ss[i + 1] === " ") {
2747
+ return ss.substring(0, i + 1);
2748
+ } else {
2749
+ return ss.substring(0, i + 1);
2750
+ }
3137
2751
  }
3138
- doms.push(
3139
- h4(
3140
- "div",
3141
- {
3142
- class: "test-top-info"
3143
- },
3144
- info
3145
- )
3146
- );
3147
2752
  }
3148
- if (obj2.html) {
3149
- let type = (obj2.html.type || "div").split(".");
3150
- let c = type[1] || "";
3151
- list.push(
3152
- h4(type[0], {
3153
- class: "test-top-html " + c,
3154
- innerHTML: obj2.html.name + " " + obj2.html.description
3155
- })
3156
- );
2753
+ } else {
2754
+ if (iss) {
2755
+ return ss.substring(0, ss.indexOf(" "));
2756
+ } else {
2757
+ return ss;
3157
2758
  }
3158
- ["text", "proposal", "error"].forEach((v) => {
3159
- if (obj2[v]) {
3160
- let type = (obj2[v].type || "div").split(".");
3161
- let c = type[1] || "";
3162
- if (type[0] == "html") {
3163
- list.push(
3164
- h4("div", {
3165
- class: "test-top-" + v + " " + c,
3166
- innerHTML: obj2[v].name + " " + obj2[v].description
3167
- })
3168
- );
3169
- } else {
3170
- list.push(
3171
- h4(
3172
- type[0],
3173
- {
3174
- class: "test-top-" + v + " " + c
3175
- },
3176
- [
3177
- h4("span", {}, [
3178
- getValue(
3179
- obj2[v].name + " " + obj2[v].description
3180
- )
3181
- ])
3182
- ]
3183
- )
3184
- );
3185
- }
2759
+ }
2760
+ }
2761
+ function getObj(v) {
2762
+ delete v.problems;
2763
+ delete v.source;
2764
+ let tag = v.tag;
2765
+ let name = v.name;
2766
+ let description = v.description;
2767
+ let defaults = v.default;
2768
+ let selectable = "";
2769
+ let required = "";
2770
+ if (tag == "default") {
2771
+ name = name.trim();
2772
+ name = getDefault(name) || name;
2773
+ } else if (tag == "selectable") {
2774
+ name = name.trim();
2775
+ } else {
2776
+ if (name.includes("=")) {
2777
+ const ms = name.split("=");
2778
+ name = ms[0];
2779
+ const ss = ms[1] + " " + description;
2780
+ const dvz = getDefault(ss, true);
2781
+ if (dvz) {
2782
+ defaults = dvz;
2783
+ description = ss.replace(dvz, "");
2784
+ } else {
2785
+ defaults = v.default || ms[1] || "";
3186
2786
  }
3187
- });
2787
+ }
2788
+ const regExp = /\s*\((.*)\)\s*/gi;
2789
+ const rtr = regExp.exec(description);
2790
+ if (rtr && rtr.length > 0) {
2791
+ selectable = rtr[1];
2792
+ description = description.replace(rtr[0], "");
2793
+ }
2794
+ }
2795
+ if (name.endsWith("*")) {
2796
+ required = "*";
2797
+ name = name.substring(0, name.length - 1);
2798
+ }
2799
+ v.name = name;
2800
+ v.required = required;
2801
+ v.default = defaults || "";
2802
+ v.description = description;
2803
+ v.selectable = selectable;
2804
+ return v;
2805
+ }
2806
+ function setTitle(obj2) {
2807
+ let title = "";
2808
+ let name = "";
2809
+ let author = "";
2810
+ let description = "";
2811
+ let date = "";
2812
+ let arr = [
2813
+ "title",
2814
+ // 'name',
2815
+ "text",
2816
+ "author",
2817
+ "date"
2818
+ // 'description',
2819
+ // 'descriptions',
2820
+ ];
2821
+ let fobj = getFilter(obj2, arr);
2822
+ let value = {};
2823
+ arr.forEach((key) => {
2824
+ value[key] = fobj.obj[key];
2825
+ });
2826
+ addTitles(value);
2827
+ fobj.arr.forEach((o) => {
2828
+ addTags(o.key, o.value);
2829
+ });
2830
+ }
2831
+ function addTitles(value) {
2832
+ notesObj.titles.push(value);
2833
+ }
2834
+ function setProps(obj2) {
2835
+ let name = "";
2836
+ let type = "";
2837
+ let defaults = "";
2838
+ let description = "";
2839
+ let selectable = "";
2840
+ let arr = [
2841
+ "props",
2842
+ "name",
2843
+ "type",
2844
+ "default",
2845
+ "required",
2846
+ "selectable",
2847
+ "description",
2848
+ "descriptions",
2849
+ "model",
2850
+ "return"
2851
+ ];
2852
+ let fobj = getFilter(obj2, arr);
2853
+ let value = {};
2854
+ arr.forEach((key) => {
2855
+ value[key] = fobj.obj[key];
2856
+ });
2857
+ addObj(value, "props");
2858
+ fobj.arr.forEach((o) => {
2859
+ addTags(o.key, o.value);
3188
2860
  });
3189
- setTitle3();
3190
- setDivision();
3191
- return domss;
3192
2861
  }
3193
- var top_default2 = defineComponent2({
3194
- /**
3195
- * @props {Stinrg} value 插入数据
3196
- */
3197
- props: {
3198
- value: Array
3199
- },
3200
- render(propss, a, props2) {
3201
- const domss = getTestTopDom(props2.value, h2);
3202
- if (domss && domss.length > 0) {
3203
- return h2(
3204
- "div",
3205
- {
3206
- class: "test-top-top"
3207
- },
3208
- domss
3209
- );
3210
- }
3211
- return "";
3212
- }
3213
- });
3214
-
3215
- // node_modules/.pnpm/@fangzhongya+utils@0.0.73/node_modules/@fangzhongya/utils/dist/chunk-Q6BNW3MO.js
3216
- var FUNCTION_REGEX = /^\s*(?:(async)\s+)?(?:function\s*(\*?)\s*(\w*)\s*\(([\s\S]*?)\)|(\*?\s*)\b(\w+)\s*\(([\s\S]*?)\)|\(([\s\S]*?)\)|([^=>,\(\)]+?))\s*(?:=>)?\s*(?:\{([\s\S]*?)\}|([\s\S]*))$/;
3217
- function getFunctionFormat(v) {
3218
- if (!v) return;
3219
- const str = typeof v === "function" ? v.toString() : v;
3220
- const trimmed = str.trim();
3221
- const match = trimmed.match(FUNCTION_REGEX);
3222
- if (!match) {
3223
- console.warn("Unsupported function format:", trimmed.slice(0, 100));
3224
- return;
3225
- }
3226
- const [
3227
- _,
3228
- // 完整匹配
3229
- asyncFlag,
3230
- // 异步标志
3231
- funcGenerator,
3232
- // 函数生成器标志
3233
- funcName,
3234
- // 函数名称
3235
- funcParams,
3236
- // 函数参数
3237
- methodGenerator,
3238
- // 方法生成器标志
3239
- methodName,
3240
- // 方法名称
3241
- methodParams,
3242
- // 方法参数
3243
- arrowParenParams,
3244
- // 箭头函数括号参数
3245
- arrowSingleParam,
3246
- // 箭头函数单参数
3247
- blockBody,
3248
- // 块级函数体
3249
- exprBody
3250
- // 表达式函数体
3251
- ] = match;
3252
- let isAsync = !!asyncFlag;
3253
- let isGenerator = false;
2862
+ function setSlot(obj2) {
3254
2863
  let name = "";
3255
- let param = "";
3256
- let body = "";
3257
- let isArrow = false;
3258
- let arrowBody = "";
3259
- if (funcParams !== void 0) {
3260
- isGenerator = funcGenerator === "*";
3261
- name = funcName || "";
3262
- param = funcParams;
3263
- body = blockBody || exprBody || "";
3264
- } else if (methodParams !== void 0) {
3265
- isGenerator = methodGenerator?.includes("*") || false;
3266
- name = methodName || "";
3267
- param = methodParams;
3268
- body = blockBody || exprBody || "";
3269
- } else if (arrowParenParams !== void 0 || arrowSingleParam !== void 0) {
3270
- isArrow = true;
3271
- param = arrowParenParams || arrowSingleParam || "";
3272
- body = blockBody || exprBody || "";
3273
- arrowBody = body.trim();
3274
- if (!blockBody && !/^\s*return\b/.test(body)) {
3275
- body = `return ${body}`;
3276
- }
2864
+ let description = "";
2865
+ let selectable = "";
2866
+ let arr = ["slot", "name", "selectable", "description", "descriptions"];
2867
+ let fobj = getFilter(obj2, arr);
2868
+ let value = {};
2869
+ arr.forEach((key) => {
2870
+ value[key] = fobj.obj[key];
2871
+ });
2872
+ addObj(value, "slot");
2873
+ fobj.arr.forEach((o) => {
2874
+ addTags(o.key, o.value);
2875
+ });
2876
+ }
2877
+ function setEmits(obj2) {
2878
+ let arr = ["emits", "name", "selectable", "description", "descriptions"];
2879
+ let fobj = getFilter(obj2, arr);
2880
+ let value = {};
2881
+ arr.forEach((key) => {
2882
+ value[key] = fobj.obj[key];
2883
+ });
2884
+ addObj(value, "emits");
2885
+ fobj.arr.forEach((o) => {
2886
+ addTags(o.key, o.value);
2887
+ });
2888
+ }
2889
+ function setExpose(obj2) {
2890
+ let arr = [
2891
+ "expose",
2892
+ "name",
2893
+ "type",
2894
+ "return",
2895
+ "selectable",
2896
+ "description",
2897
+ "descriptions"
2898
+ ];
2899
+ let fobj = getFilter(obj2, arr);
2900
+ let value = {};
2901
+ arr.forEach((key) => {
2902
+ value[key] = fobj.obj[key];
2903
+ });
2904
+ addObj(value, "expose");
2905
+ fobj.arr.forEach((o) => {
2906
+ addTags(o.key, o.value);
2907
+ });
2908
+ }
2909
+ function addObj(value, type) {
2910
+ const ms = notesObj[type + "name"] || [];
2911
+ const name = value.name ?? value[type]?.name;
2912
+ const nis = ms.indexOf(name);
2913
+ if (nis >= 0) {
2914
+ notesObj[type + "s"].splice(nis, 1);
2915
+ ms.splice(nis, 1);
2916
+ }
2917
+ notesObj[type + "s"].push(value);
2918
+ ms.push(name);
2919
+ notesObj[type + "name"] = ms;
2920
+ }
2921
+ function getFilter(obj2, arrs) {
2922
+ const _objs = {
2923
+ descriptions: obj2?.description || ""
2924
+ };
2925
+ const arr = [];
2926
+ if (obj2?.tags) {
2927
+ obj2.tags?.forEach((v) => {
2928
+ let tag = v.tag;
2929
+ let ov = getObj(v);
2930
+ if (!_objs.hasOwnProperty(tag)) {
2931
+ _objs[tag] = ov;
2932
+ } else {
2933
+ const ao = {};
2934
+ ao[tag] = ov;
2935
+ arr.push({
2936
+ key: tag,
2937
+ value: ao
2938
+ });
2939
+ }
2940
+ });
3277
2941
  }
3278
2942
  return {
3279
- isArrow,
3280
- isAsync,
3281
- isGenerator,
3282
- ...name && { name },
3283
- param: param.trim(),
3284
- body: body.trim(),
3285
- arrowBody
2943
+ arr,
2944
+ obj: _objs
3286
2945
  };
3287
2946
  }
3288
-
3289
- // packages/components/use/util.ts
3290
- var getFormat2 = (r) => {
3291
- return r;
3292
- };
3293
- var isp = getConfig("prettier");
3294
- if (isp) {
3295
- Promise.resolve().then(() => (init_prettier(), prettier_exports)).then((d) => {
3296
- getFormat2 = d.getFormat;
3297
- });
3298
- }
3299
- function prettierHtml(st) {
3300
- if (isp) {
3301
- const v = getFormat2(st, "html");
3302
- return v;
2947
+ function addTags(tag, obj2) {
2948
+ switch (tag) {
2949
+ case "title":
2950
+ addTitles(obj2);
2951
+ return true;
2952
+ case "text":
2953
+ addTitles(obj2);
2954
+ return true;
2955
+ case "props":
2956
+ addObj(obj2, "props");
2957
+ return true;
2958
+ case "slot":
2959
+ addObj(obj2, "slot");
2960
+ return true;
2961
+ case "emits":
2962
+ addObj(obj2, "emits");
2963
+ return true;
2964
+ case "expose":
2965
+ addObj(obj2, "expose");
2966
+ return true;
2967
+ default:
2968
+ return false;
3303
2969
  }
3304
- return st;
3305
2970
  }
3306
- function prettierTs(st) {
3307
- if (isp) {
3308
- const v = getFormat2(st, "ts");
3309
- return v;
2971
+ function setTags(tag, obj2) {
2972
+ switch (tag) {
2973
+ case "title":
2974
+ setTitle(obj2);
2975
+ return true;
2976
+ case "props":
2977
+ setProps(obj2);
2978
+ return true;
2979
+ case "slot":
2980
+ setSlot(obj2);
2981
+ return true;
2982
+ case "emits":
2983
+ setEmits(obj2);
2984
+ return true;
2985
+ case "expose":
2986
+ setExpose(obj2);
2987
+ return true;
2988
+ default:
2989
+ return false;
3310
2990
  }
3311
- return st;
3312
2991
  }
3313
- function vueFormat(st, kg = "") {
3314
- let arr = (st + "").trim().split(/\n/);
3315
- arr = arr.map((v) => {
3316
- return kg + v;
2992
+ function notesFilter(notes) {
2993
+ init();
2994
+ notes?.forEach((obj2) => {
2995
+ let tags = obj2?.tags || [];
2996
+ let lg = tags?.length || 0;
2997
+ if (lg > 0) {
2998
+ for (let i = 0; i < lg; i++) {
2999
+ const v = tags[i] || {};
3000
+ let is = setTags(v.tag, obj2);
3001
+ if (is) {
3002
+ break;
3003
+ }
3004
+ }
3005
+ }
3317
3006
  });
3318
- return arr.join("\n");
3007
+ return JSON.parse(JSON.stringify(notesObj));
3319
3008
  }
3320
- function getFunBody(sr = "") {
3321
- sr = sr.trim();
3322
- let body = "[\\s|\\n|\\r]*\\{((.|\n|\r)+?)\\}[\\s|\\n|\\r]*";
3323
- let reg = new RegExp("^" + body + "$");
3324
- let vts = reg.exec(sr);
3325
- if (vts && vts.length > 0) {
3326
- return getFunBody(vts[1]);
3327
- } else {
3328
- return sr;
3009
+ function getTextNotes(text) {
3010
+ if (text) {
3011
+ return parse(text);
3329
3012
  }
3330
3013
  }
3014
+ function getNotesText(text) {
3015
+ let notes = getTextNotes(text);
3016
+ return notesFilter(notes);
3017
+ }
3331
3018
  var jctypes = [
3332
3019
  "Boolean",
3333
3020
  "Any",
@@ -3344,30 +3031,6 @@ function conversionType(type) {
3344
3031
  return type;
3345
3032
  }
3346
3033
  }
3347
- var splitIgnoringNesting = (str, delimiter) => {
3348
- let bracketStack = [];
3349
- let parts = [];
3350
- let current = "";
3351
- for (let i = 0; i < str.length; i++) {
3352
- const char = str[i];
3353
- if (char === "[" || char === "<" || char === "(") {
3354
- bracketStack.push(char);
3355
- current += char;
3356
- } 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] === "(") {
3357
- bracketStack.pop();
3358
- current += char;
3359
- } else if (char === delimiter && bracketStack.length === 0) {
3360
- parts.push(current.trim());
3361
- current = "";
3362
- } else {
3363
- current += char;
3364
- }
3365
- }
3366
- if (current.trim() !== "") {
3367
- parts.push(current.trim());
3368
- }
3369
- return parts;
3370
- };
3371
3034
  var splitIgnoring = (str) => {
3372
3035
  let bracketStack = [];
3373
3036
  let isArr = false;
@@ -3402,878 +3065,1359 @@ var splitIgnoring = (str) => {
3402
3065
  };
3403
3066
  }
3404
3067
  }
3405
- return {
3406
- top: str,
3407
- type: ""
3408
- };
3409
- };
3410
- var parseTypeDefinition = (typeDef) => {
3411
- if (!typeDef) {
3412
- return ["any"];
3413
- } else if (typeDef.startsWith("[") && typeDef.endsWith("]") || typeDef.startsWith("(") && typeDef.endsWith(")")) {
3414
- const inner = typeDef.slice(1, -1).trim();
3415
- if (!inner) return ["any"];
3416
- const types = splitIgnoringNesting(inner, ",");
3417
- return types;
3418
- } else if (typeDef.startsWith("{") && typeDef.endsWith("}")) {
3419
- return ["Object"];
3420
- } else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
3421
- const inner = typeDef.slice(1, -1).trim();
3422
- if (!inner) return ["any"];
3423
- const types = splitIgnoringNesting(inner, "|");
3424
- return types;
3425
- } else {
3426
- const types = splitIgnoringNesting(typeDef, ",");
3427
- return types;
3068
+ return {
3069
+ top: str,
3070
+ type: ""
3071
+ };
3072
+ };
3073
+ var splitIgnoringNesting = (str, delimiter) => {
3074
+ let bracketStack = [];
3075
+ let parts = [];
3076
+ let current = "";
3077
+ for (let i = 0; i < str.length; i++) {
3078
+ const char = str[i];
3079
+ if (char === "[" || char === "<" || char === "(") {
3080
+ bracketStack.push(char);
3081
+ current += char;
3082
+ } 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] === "(") {
3083
+ bracketStack.pop();
3084
+ current += char;
3085
+ } else if (char === delimiter && bracketStack.length === 0) {
3086
+ parts.push(current.trim());
3087
+ current = "";
3088
+ } else {
3089
+ current += char;
3090
+ }
3091
+ }
3092
+ if (current.trim() !== "") {
3093
+ parts.push(current.trim());
3094
+ }
3095
+ return parts;
3096
+ };
3097
+ function getTypeName(type) {
3098
+ let t = "";
3099
+ if (typeof type == "string") {
3100
+ t = type;
3101
+ } else {
3102
+ t = type.value;
3103
+ }
3104
+ return conversionType(t || "any");
3105
+ }
3106
+ function getDataTypeType(dataType) {
3107
+ const type = dataType[0] || "any";
3108
+ return getTypeName(type);
3109
+ }
3110
+ var parseTypeDefinition = (typeDef) => {
3111
+ if (!typeDef) {
3112
+ return ["any"];
3113
+ } else if (typeDef.startsWith("[") && typeDef.endsWith("]") || typeDef.startsWith("(") && typeDef.endsWith(")")) {
3114
+ const inner = typeDef.slice(1, -1).trim();
3115
+ if (!inner) return ["any"];
3116
+ const types = splitIgnoringNesting(inner, ",");
3117
+ return types;
3118
+ } else if (typeDef.startsWith("{") && typeDef.endsWith("}")) {
3119
+ return ["Object"];
3120
+ } else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
3121
+ const inner = typeDef.slice(1, -1).trim();
3122
+ if (!inner) return ["any"];
3123
+ const types = splitIgnoringNesting(inner, "|");
3124
+ return types;
3125
+ } else {
3126
+ const types = splitIgnoringNesting(typeDef, ",");
3127
+ return types;
3128
+ }
3129
+ };
3130
+ function getDataType(arr) {
3131
+ const value = [];
3132
+ arr.forEach((v) => {
3133
+ const ss = splitIgnoring(v);
3134
+ if (ss.type) {
3135
+ const dataType = parseTypeDefinition(ss.type);
3136
+ const children = getDataType(dataType);
3137
+ value.push({
3138
+ label: v,
3139
+ value: ss.top,
3140
+ children
3141
+ });
3142
+ } else {
3143
+ value.push(ss.top);
3144
+ }
3145
+ });
3146
+ return value;
3147
+ }
3148
+ function parseParamString(input) {
3149
+ const parts = splitIgnoringNesting(input, ",");
3150
+ return parts.map((trimmedPart) => {
3151
+ const label = trimmedPart.trim();
3152
+ const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
3153
+ if (!nameMatch) return null;
3154
+ const name = nameMatch[1].trim();
3155
+ const must = !nameMatch[2];
3156
+ const typeDefStart = nameMatch[0].length;
3157
+ const typeDef = trimmedPart.substring(typeDefStart).trim();
3158
+ let bracketStack = [];
3159
+ let t = "";
3160
+ let description = "";
3161
+ for (let i = 0; i < typeDef.length; i++) {
3162
+ const char = typeDef[i];
3163
+ if (char === "[" || char === "<" || char === "(" || char === "{") {
3164
+ bracketStack.push(char);
3165
+ } else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === "}" && bracketStack[bracketStack.length - 1] === "{" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
3166
+ bracketStack.pop();
3167
+ }
3168
+ if (bracketStack.length === 0 && i > 0) {
3169
+ if (i == 1 && char !== "]" && char !== ">" && char !== "}" && char !== ")") {
3170
+ t = "";
3171
+ description = typeDef.substring(0);
3172
+ } else {
3173
+ t = typeDef.substring(0, i + 1).trim();
3174
+ description = typeDef.substring(i + 1);
3175
+ }
3176
+ break;
3177
+ }
3178
+ }
3179
+ const dataType = parseTypeDefinition(t);
3180
+ const tarr = getDataType(dataType);
3181
+ return {
3182
+ name,
3183
+ prop: name,
3184
+ type: getDataTypeType(tarr),
3185
+ dataType: tarr,
3186
+ must,
3187
+ label,
3188
+ description
3189
+ };
3190
+ }).filter(Boolean);
3191
+ }
3192
+
3193
+ // packages/components/test/index.ts
3194
+ function getObj2(v) {
3195
+ delete v.problems;
3196
+ delete v.source;
3197
+ return v;
3198
+ }
3199
+ function getFilter2(obj2, keyArr) {
3200
+ const _objs = {
3201
+ descriptions: obj2?.description || ""
3202
+ };
3203
+ const arr = [];
3204
+ if (obj2?.tags) {
3205
+ obj2?.tags?.forEach((v, index) => {
3206
+ let tag = v.tag;
3207
+ let ov = getObj2(v);
3208
+ if (!_objs.hasOwnProperty(tag) && keyArr.includes(tag)) {
3209
+ _objs[tag] = ov;
3210
+ } else {
3211
+ let ao = {};
3212
+ ao[tag] = ov;
3213
+ arr.push({
3214
+ key: tag,
3215
+ value: ao
3216
+ });
3217
+ }
3218
+ });
3219
+ }
3220
+ return {
3221
+ arr,
3222
+ obj: _objs
3223
+ };
3224
+ }
3225
+ var titles = [];
3226
+ function setTitle2(obj2) {
3227
+ const arr = ["title", "author", "date"];
3228
+ const fobj = getFilter2(obj2, arr);
3229
+ const value = {};
3230
+ arr.forEach((key) => {
3231
+ value[key] = fobj.obj[key];
3232
+ });
3233
+ addTitle(value);
3234
+ fobj.arr.forEach((o) => {
3235
+ addTags2(o.key, o.value);
3236
+ });
3237
+ }
3238
+ var states = [];
3239
+ function setState(obj2) {
3240
+ const arr = ["state", "type"];
3241
+ const fobj = getFilter2(obj2, arr);
3242
+ const value = {};
3243
+ arr.forEach((key) => {
3244
+ value[key] = fobj.obj[key];
3245
+ });
3246
+ addState(value);
3247
+ fobj.arr.forEach((o) => {
3248
+ addTags2(o.key, o.value);
3249
+ });
3250
+ }
3251
+ function addTitle(value) {
3252
+ titles.push(value);
3253
+ }
3254
+ function addProposal(value) {
3255
+ titles.push(value);
3256
+ }
3257
+ function addError(value) {
3258
+ titles.push(value);
3259
+ }
3260
+ function addState(value) {
3261
+ states.push(value);
3262
+ }
3263
+ function addTags2(tag, obj2) {
3264
+ switch (tag) {
3265
+ case "title":
3266
+ addTitle(obj2);
3267
+ return true;
3268
+ case "proposal":
3269
+ addProposal(obj2);
3270
+ return true;
3271
+ case "error":
3272
+ addError(obj2);
3273
+ return true;
3274
+ case "state":
3275
+ addState(obj2);
3276
+ return true;
3277
+ case "text":
3278
+ addTitle(obj2);
3279
+ return true;
3280
+ case "html":
3281
+ addTitle(obj2);
3282
+ return true;
3283
+ default:
3284
+ return false;
3285
+ }
3286
+ }
3287
+ function setTags2(tag, obj2) {
3288
+ switch (tag) {
3289
+ case "title":
3290
+ setTitle2(obj2);
3291
+ return true;
3292
+ // case 'proposal':
3293
+ // setProposal(obj);
3294
+ // return true;
3295
+ // case 'error':
3296
+ // setError(obj);
3297
+ // return true;
3298
+ case "state":
3299
+ setState(obj2);
3300
+ return true;
3301
+ default:
3302
+ return false;
3428
3303
  }
3429
- };
3430
- function parseParamString(input) {
3431
- const parts = splitIgnoringNesting(input, ",");
3432
- return parts.map((trimmedPart) => {
3433
- const label = trimmedPart.trim();
3434
- const nameMatch = trimmedPart.match(/^([^:?]+)(\??):/);
3435
- if (!nameMatch) return null;
3436
- const name = nameMatch[1].trim();
3437
- const must = !nameMatch[2];
3438
- const typeDefStart = nameMatch[0].length;
3439
- const typeDef = trimmedPart.substring(typeDefStart).trim();
3440
- let bracketStack = [];
3441
- let t = "";
3442
- let description = "";
3443
- for (let i = 0; i < typeDef.length; i++) {
3444
- const char = typeDef[i];
3445
- if (char === "[" || char === "<" || char === "(" || char === "{") {
3446
- bracketStack.push(char);
3447
- } else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === "}" && bracketStack[bracketStack.length - 1] === "{" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
3448
- bracketStack.pop();
3449
- }
3450
- if (bracketStack.length === 0 && i > 0) {
3451
- if (i == 1 && char !== "]" && char !== ">" && char !== "}" && char !== ")") {
3452
- t = "";
3453
- description = typeDef.substring(0);
3454
- } else {
3455
- t = typeDef.substring(0, i + 1).trim();
3456
- description = typeDef.substring(i + 1);
3457
- }
3458
- break;
3459
- }
3460
- }
3461
- const dataType = parseTypeDefinition(t);
3462
- const tarr = getDataType(dataType);
3463
- return {
3464
- name,
3465
- prop: name,
3466
- type: getDataTypeType(tarr),
3467
- dataType: tarr,
3468
- must,
3469
- label,
3470
- description
3471
- };
3472
- }).filter(Boolean);
3473
3304
  }
3474
- function setDataType(arr) {
3475
- const v = arr.map((v2) => {
3476
- if (typeof v2 == "string") {
3477
- if (v2.toLowerCase() === "array") {
3478
- return "Array<any>";
3479
- }
3480
- return v2;
3481
- } else {
3482
- if (v2.children && v2.children.length > 0) {
3483
- const vz = setDataType(v2.children);
3484
- return v2.value + "<" + vz + ">";
3485
- } else {
3486
- const z = v2.value;
3487
- if (z.toLowerCase() === "array") {
3488
- return "Array<any>";
3305
+ function getNotes(text) {
3306
+ titles = [];
3307
+ states = [];
3308
+ const notes = getTextNotes(text);
3309
+ notes?.forEach((obj2) => {
3310
+ let tags = obj2?.tags || [];
3311
+ let lg = tags?.length || 0;
3312
+ if (lg > 0) {
3313
+ for (let i = 0; i < lg; i++) {
3314
+ const v = tags[i] || {};
3315
+ let is = setTags2(v.tag, obj2);
3316
+ if (is) {
3317
+ break;
3489
3318
  }
3490
- return z;
3491
3319
  }
3492
3320
  }
3493
- }).join(" | ");
3494
- return v || "any";
3321
+ });
3322
+ return {
3323
+ titles,
3324
+ states
3325
+ };
3495
3326
  }
3496
- function getDataType(arr) {
3497
- const value = [];
3498
- arr.forEach((v) => {
3499
- const ss = splitIgnoring(v);
3500
- if (ss.type) {
3501
- const dataType = parseTypeDefinition(ss.type);
3502
- const children = getDataType(dataType);
3503
- value.push({
3504
- label: v,
3505
- value: ss.top,
3506
- children
3507
- });
3327
+
3328
+ // packages/components/compo/top.ts
3329
+ import { defineComponent, h } from "vue";
3330
+ function getTopDom(props2, h4, isZy) {
3331
+ let doms = [];
3332
+ let domss = [];
3333
+ let list = [];
3334
+ const getValue = (v) => {
3335
+ if (isZy) {
3336
+ return htmlEscape(v);
3508
3337
  } else {
3509
- value.push(ss.top);
3338
+ return v;
3510
3339
  }
3511
- });
3512
- return value;
3513
- }
3514
- function getTypeName(type) {
3515
- let t = "";
3516
- if (typeof type == "string") {
3517
- t = type;
3518
- } else {
3519
- t = type.value;
3520
- }
3521
- return conversionType(t || "any");
3522
- }
3523
- function getDataTypeType(dataType) {
3524
- const type = dataType[0] || "any";
3525
- return getTypeName(type);
3526
- }
3527
- function getTypeValue(arr) {
3528
- const dataType = arr[0];
3529
- let type = getDataTypeType(arr);
3530
- switch (type) {
3531
- case "string":
3532
- return '""';
3533
- case "boolean":
3534
- return "false";
3535
- case "number":
3536
- return "0";
3537
- case "array":
3538
- if (typeof dataType === "string") {
3539
- return `[]`;
3340
+ };
3341
+ const setTitle3 = () => {
3342
+ if (list.length > 0) {
3343
+ doms.push(
3344
+ h4(
3345
+ "div",
3346
+ {
3347
+ class: "compo-top-list"
3348
+ },
3349
+ list
3350
+ )
3351
+ );
3352
+ list = [];
3353
+ }
3354
+ };
3355
+ const setDivision = () => {
3356
+ if (doms.length > 0) {
3357
+ domss.push(
3358
+ h4(
3359
+ "div",
3360
+ {
3361
+ class: "compo-top-division"
3362
+ },
3363
+ doms
3364
+ )
3365
+ );
3366
+ doms = [];
3367
+ }
3368
+ };
3369
+ props2?.forEach((obj2) => {
3370
+ const info = [];
3371
+ let is = false;
3372
+ if (obj2.date) {
3373
+ is = true;
3374
+ info.push(
3375
+ h4(
3376
+ "div",
3377
+ {
3378
+ class: "compo-top-date"
3379
+ },
3380
+ [
3381
+ h4("span", {}, "\u66F4\u65B0\u65F6\u95F4\uFF1A"),
3382
+ h4("span", {}, [
3383
+ getValue(
3384
+ obj2.date.name + " " + obj2.date.description
3385
+ )
3386
+ ])
3387
+ ]
3388
+ )
3389
+ );
3390
+ }
3391
+ if (obj2.author) {
3392
+ is = true;
3393
+ info.push(
3394
+ h4(
3395
+ "div",
3396
+ {
3397
+ class: "compo-top-author"
3398
+ },
3399
+ [
3400
+ h4("span", {}, "\u4F5C\u8005\uFF1A"),
3401
+ h4("span", {}, [
3402
+ getValue(
3403
+ obj2.author.name + " " + obj2.author.description
3404
+ )
3405
+ ])
3406
+ ]
3407
+ )
3408
+ );
3409
+ }
3410
+ if (obj2.title && (obj2.title.type || obj2.title.name || obj2.title.description)) {
3411
+ setTitle3();
3412
+ if (is) {
3413
+ setDivision();
3414
+ }
3415
+ let type = (obj2.title.type || "div").split(".");
3416
+ let c = type[1] || "";
3417
+ if (type[0] == "html") {
3418
+ doms.push(
3419
+ h4("div", {
3420
+ class: "compo-top-title " + c,
3421
+ innerHTML: obj2.title.name + " " + obj2.title.description
3422
+ })
3423
+ );
3540
3424
  } else {
3541
- let st = dataType.children;
3542
- if (st && st.length > 0) {
3543
- let v = getTypeValue([st[0]]);
3544
- v = v == "undefined" ? "" : v;
3545
- return `[${v}]`;
3425
+ doms.push(
3426
+ h4(
3427
+ type[0],
3428
+ {
3429
+ class: "compo-top-title " + c
3430
+ },
3431
+ [
3432
+ h4("span", {}, [
3433
+ getValue(
3434
+ obj2.title.name + " " + obj2.title.description
3435
+ )
3436
+ ])
3437
+ ]
3438
+ )
3439
+ );
3440
+ }
3441
+ }
3442
+ if (is) {
3443
+ if (list.length > 0) {
3444
+ setTitle3();
3445
+ setDivision();
3446
+ }
3447
+ doms.push(
3448
+ h4(
3449
+ "div",
3450
+ {
3451
+ class: "compo-top-info"
3452
+ },
3453
+ info
3454
+ )
3455
+ );
3456
+ }
3457
+ if (obj2.html) {
3458
+ let type = (obj2.html.type || "div").split(".");
3459
+ let c = type[1] || "";
3460
+ list.push(
3461
+ h4(type[0], {
3462
+ class: "compo-top-html " + c,
3463
+ innerHTML: obj2.html.name + " " + obj2.html.description
3464
+ })
3465
+ );
3466
+ }
3467
+ ["text"].forEach((v) => {
3468
+ if (obj2[v]) {
3469
+ let type = (obj2[v].type || "div").split(".");
3470
+ let c = type[1] || "";
3471
+ if (type[0] == "html") {
3472
+ list.push(
3473
+ h4("div", {
3474
+ class: "compo-top-" + v + " " + c,
3475
+ innerHTML: obj2[v].name + " " + obj2[v].description
3476
+ })
3477
+ );
3546
3478
  } else {
3547
- return `[]`;
3479
+ list.push(
3480
+ h4(
3481
+ type[0],
3482
+ {
3483
+ class: "compo-top-" + v + " " + c
3484
+ },
3485
+ [
3486
+ h4("span", {}, [
3487
+ getValue(
3488
+ obj2[v].name + " " + obj2[v].description
3489
+ )
3490
+ ])
3491
+ ]
3492
+ )
3493
+ );
3548
3494
  }
3549
3495
  }
3550
- case "object":
3551
- return "{}";
3552
- case "function":
3553
- return "()=>{}";
3554
- case "any":
3555
- return '""';
3556
- default:
3557
- return "undefined";
3558
- }
3496
+ });
3497
+ });
3498
+ setTitle3();
3499
+ setDivision();
3500
+ return domss;
3559
3501
  }
3560
- var allReservedWords = [
3561
- // JavaScript 基本关键字
3562
- "break",
3563
- "case",
3564
- "catch",
3565
- "class",
3566
- "const",
3567
- "continue",
3568
- "debugger",
3569
- "default",
3570
- "delete",
3571
- "do",
3572
- "else",
3573
- "export",
3574
- "extends",
3575
- "finally",
3576
- "for",
3577
- "function",
3578
- "if",
3579
- "import",
3580
- "in",
3581
- "instanceof",
3582
- "new",
3583
- "return",
3584
- "super",
3585
- "switch",
3586
- "this",
3587
- "throw",
3588
- "try",
3589
- "typeof",
3590
- "var",
3591
- "void",
3592
- "while",
3593
- "with",
3594
- "yield",
3595
- // 严格模式下的保留字
3596
- "implements",
3597
- "interface",
3598
- "let",
3599
- "package",
3600
- "private",
3601
- "protected",
3602
- "public",
3603
- "static",
3604
- // 字面量值
3605
- "true",
3606
- "false",
3607
- "null",
3608
- "undefined",
3609
- // TypeScript 特有类型关键字
3610
- "any",
3611
- "boolean",
3612
- "number",
3613
- "string",
3614
- "object",
3615
- "symbol",
3616
- "unknown",
3617
- "never",
3618
- "void",
3619
- "undefined",
3620
- "null",
3621
- // TypeScript 类型操作与定义
3622
- "type",
3623
- "interface",
3624
- "enum",
3625
- "as",
3626
- "is",
3627
- "infer",
3628
- "unique",
3629
- // TypeScript 类修饰符
3630
- "abstract",
3631
- "readonly",
3632
- // TypeScript 模块与声明
3633
- "namespace",
3634
- "module",
3635
- "declare",
3636
- "require",
3637
- // 其他(访问器、未来保留字等)
3638
- "get",
3639
- "set",
3640
- "async",
3641
- "await",
3642
- "from",
3643
- "of",
3644
- "package"
3645
- ];
3502
+ var top_default = defineComponent({
3503
+ /**
3504
+ * @props {Stinrg} value 插入数据
3505
+ */
3506
+ props: {
3507
+ value: Array
3508
+ },
3509
+ render(propss, a, props2) {
3510
+ const domss = getTopDom(props2.value, h);
3511
+ return h(
3512
+ "div",
3513
+ {
3514
+ class: "compo-top"
3515
+ },
3516
+ domss
3517
+ );
3518
+ }
3519
+ });
3646
3520
 
3647
- // packages/components/use/code.ts
3648
- function getSpecObjs(specs, name) {
3649
- return specs.filter((o) => o.name == name)[0];
3650
- }
3651
- function getParameStr(css2) {
3652
- return css2.map((o) => {
3653
- const name = o.prop || "...arr";
3654
- return name + ":" + setDataType(o.dataType);
3655
- }).join(",");
3656
- }
3657
- async function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
3658
- const tarr = [];
3659
- const sarr = [];
3660
- let is = true;
3661
- const ps = getPropsValue2(param.propss || []);
3662
- const es2 = getEmitsValue(param.emitss || []);
3663
- const res = getExposeValue(param.exposes || []);
3664
- const ss = getSlotValue(param.slots || []);
3665
- Object.keys(value).forEach(async (key) => {
3666
- let val = value[key];
3667
- if (/^on[A-Z]/.test(key) && typeof val == "function") {
3668
- let name = key.substring(2);
3669
- const knam = key.split(":");
3670
- let strs;
3671
- if (knam.length > 1) {
3672
- strs = knam[0] + knam.slice(1).map((o) => firstUpper(o)).join("");
3673
- name = firstLower(name);
3674
- } else {
3675
- strs = knam[0];
3676
- name = humpToLine(name);
3677
- }
3678
- if (knam.includes("-")) {
3679
- let arr = strs.split("-");
3680
- arr = arr.map((vs, i) => {
3681
- if (i != 0) {
3682
- return firstUpper(vs);
3683
- } else {
3684
- return vs;
3685
- }
3686
- });
3687
- strs = arr.join("");
3688
- }
3689
- tarr.push(" @" + name + '="' + strs + '"');
3690
- const sp = getSpecObjs(es2, name) || {};
3691
- const s = sp.selectable || "";
3692
- const css2 = parseParamString(s);
3693
- const cs = getParameStr(css2);
3694
- sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
3695
- sarr.push("function " + strs + "(" + cs + ") {");
3696
- css2.forEach((o) => {
3697
- const name2 = o.name || "arr";
3698
- sarr.push(" console.log('" + o.label + "', " + name2 + ")");
3699
- });
3700
- sarr.push("}");
3521
+ // packages/components/test/top.ts
3522
+ import { defineComponent as defineComponent2, h as h2 } from "vue";
3523
+ function getTestTopDom(props2, h4, isZy) {
3524
+ let doms = [];
3525
+ let domss = [];
3526
+ let list = [];
3527
+ const getValue = (v) => {
3528
+ if (isZy) {
3529
+ return htmlEscape(v);
3701
3530
  } else {
3702
- let z = key;
3703
- if (allReservedWords.includes(key)) {
3704
- z = key + "1";
3705
- }
3706
- tarr.push(" :" + key + '="' + z + '"');
3707
- const sp = getSpecObjs(ps, key) || {};
3708
- const t = getSpecType(sp);
3709
- sarr.push(
3710
- `// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
3531
+ return v;
3532
+ }
3533
+ };
3534
+ const setTitle3 = () => {
3535
+ if (list.length > 0) {
3536
+ doms.push(
3537
+ h4(
3538
+ "div",
3539
+ {
3540
+ class: "test-top-list"
3541
+ },
3542
+ list
3543
+ )
3711
3544
  );
3712
- if (typeof val == "function" || t.dataType.length == 1 && t.type == "function" && val) {
3713
- sarr.push(
3714
- "const " + key + " = " + await getFunctionBody(
3715
- val,
3716
- key,
3717
- propsText
3718
- )
3545
+ list = [];
3546
+ }
3547
+ };
3548
+ const setDivision = () => {
3549
+ if (doms.length > 0) {
3550
+ domss.push(
3551
+ h4(
3552
+ "div",
3553
+ {
3554
+ class: "test-top-division"
3555
+ },
3556
+ doms
3557
+ )
3558
+ );
3559
+ doms = [];
3560
+ }
3561
+ };
3562
+ props2.forEach((obj2) => {
3563
+ const info = [];
3564
+ let is = false;
3565
+ if (obj2.date) {
3566
+ is = true;
3567
+ info.push(
3568
+ h4(
3569
+ "div",
3570
+ {
3571
+ class: "test-top-date"
3572
+ },
3573
+ [
3574
+ h4("span", {}, "\u66F4\u65B0\u65F6\u95F4\uFF1A"),
3575
+ h4("span", {}, [
3576
+ getValue(
3577
+ obj2.date.name + " " + obj2.date.description
3578
+ )
3579
+ ])
3580
+ ]
3581
+ )
3582
+ );
3583
+ }
3584
+ if (obj2.author) {
3585
+ is = true;
3586
+ info.push(
3587
+ h4(
3588
+ "div",
3589
+ {
3590
+ class: "test-top-author"
3591
+ },
3592
+ [
3593
+ h4("span", {}, "\u4F5C\u8005\uFF1A"),
3594
+ h4("span", {}, [
3595
+ getValue(
3596
+ obj2.author.name + " " + obj2.author.description
3597
+ )
3598
+ ])
3599
+ ]
3600
+ )
3601
+ );
3602
+ }
3603
+ if (obj2.title && (obj2.title.type || obj2.title.name || obj2.title.description)) {
3604
+ setTitle3();
3605
+ if (is) {
3606
+ setDivision();
3607
+ }
3608
+ let type = (obj2.title.type || "div").split(".");
3609
+ let c = type[1] || "";
3610
+ if (type[0] == "html") {
3611
+ doms.push(
3612
+ h4("div", {
3613
+ class: "test-top-title " + c,
3614
+ innerHTML: obj2.title.name + " " + obj2.title.description
3615
+ })
3719
3616
  );
3720
3617
  } else {
3721
- if (is) {
3722
- is = false;
3723
- sarr.unshift("import { ref } from 'vue';");
3724
- }
3725
- if (typeof val == "undefined") {
3726
- if (t.type == "function") {
3727
- const tv = getTypeValueFunction(sp);
3728
- sarr.push("const " + z + " = " + tv + ";");
3729
- } else {
3730
- const tv = getTypeValue(t.dataType);
3731
- sarr.push(
3732
- "const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
3733
- );
3734
- }
3735
- } else {
3736
- let st2 = setValStringify(val, key, propsText);
3737
- sarr.push("const " + z + " = ref(" + st2 + ");");
3738
- }
3618
+ doms.push(
3619
+ h4(
3620
+ type[0],
3621
+ {
3622
+ class: "test-top-title " + c
3623
+ },
3624
+ [
3625
+ h4("span", {}, [
3626
+ getValue(
3627
+ obj2.title.name + " " + obj2.title.description
3628
+ )
3629
+ ])
3630
+ ]
3631
+ )
3632
+ );
3739
3633
  }
3740
3634
  }
3741
- });
3742
- const ev = Object.values(exposeText || {});
3743
- if (ev.length > 0) {
3744
3635
  if (is) {
3745
- is = false;
3746
- sarr.unshift("import { ref } from 'vue';");
3636
+ if (list.length > 0) {
3637
+ setTitle3();
3638
+ setDivision();
3639
+ }
3640
+ doms.push(
3641
+ h4(
3642
+ "div",
3643
+ {
3644
+ class: "test-top-info"
3645
+ },
3646
+ info
3647
+ )
3648
+ );
3747
3649
  }
3748
- tarr.unshift(' ref="refDom"');
3749
- sarr.push("const refDom = ref()");
3750
- ev.forEach((v) => {
3751
- const s = getSpecObjs(res, v.name) || {};
3752
- sarr.push(
3753
- `// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
3650
+ if (obj2.html) {
3651
+ let type = (obj2.html.type || "div").split(".");
3652
+ let c = type[1] || "";
3653
+ list.push(
3654
+ h4(type[0], {
3655
+ class: "test-top-html " + c,
3656
+ innerHTML: obj2.html.name + " " + obj2.html.description
3657
+ })
3754
3658
  );
3755
- const m = v.name + "Value";
3756
- const css2 = parseParamString(s?.selectable || "");
3757
- const cs = [];
3758
- const ps2 = v.params || [];
3759
- css2.forEach((c, index) => {
3760
- const prop = c.name;
3761
- if (prop) {
3762
- const key = prop + v.name;
3763
- const val = ps2[index];
3764
- sarr.push(`// ${c.label}`);
3765
- if (typeof val == "function") {
3766
- sarr.push(
3767
- "const " + key + " = " + getFunctionBody(val, prop, v.text)
3768
- );
3769
- } else {
3770
- if (typeof val == "undefined") {
3771
- sarr.push(
3772
- "const " + key + " = " + getTypeValue(c.dataType) + ";"
3773
- );
3774
- } else {
3775
- let st2 = setValStringify(val, prop, v.text);
3776
- sarr.push("const " + key + " = " + st2 + ";");
3777
- }
3778
- }
3779
- cs.push(key);
3780
- }
3781
- });
3782
- if (v.type === "function") {
3783
- if (s.return) {
3784
- sarr.push(
3785
- `const ${m} = refDom.value?.${v.name}(${cs.join(
3786
- ", "
3787
- )})`
3659
+ }
3660
+ ["text", "proposal", "error"].forEach((v) => {
3661
+ if (obj2[v]) {
3662
+ let type = (obj2[v].type || "div").split(".");
3663
+ let c = type[1] || "";
3664
+ if (type[0] == "html") {
3665
+ list.push(
3666
+ h4("div", {
3667
+ class: "test-top-" + v + " " + c,
3668
+ innerHTML: obj2[v].name + " " + obj2[v].description
3669
+ })
3788
3670
  );
3789
3671
  } else {
3790
- sarr.push(`refDom.value?.${v.name}(${cs.join(", ")})`);
3791
- }
3792
- if (s.return) {
3793
- sarr.push(`console.log('${s.return}', ${m})`);
3672
+ list.push(
3673
+ h4(
3674
+ type[0],
3675
+ {
3676
+ class: "test-top-" + v + " " + c
3677
+ },
3678
+ [
3679
+ h4("span", {}, [
3680
+ getValue(
3681
+ obj2[v].name + " " + obj2[v].description
3682
+ )
3683
+ ])
3684
+ ]
3685
+ )
3686
+ );
3794
3687
  }
3795
- } else {
3796
- sarr.push(`const ${m} = refDom.value?.${v.name}`);
3797
- sarr.push(`console.log('${s.type || s.name}', ${m})`);
3798
3688
  }
3799
3689
  });
3690
+ });
3691
+ setTitle3();
3692
+ setDivision();
3693
+ return domss;
3694
+ }
3695
+ var top_default2 = defineComponent2({
3696
+ /**
3697
+ * @props {Stinrg} value 插入数据
3698
+ */
3699
+ props: {
3700
+ value: Array
3701
+ },
3702
+ render(propss, a, props2) {
3703
+ const domss = getTestTopDom(props2.value, h2);
3704
+ if (domss && domss.length > 0) {
3705
+ return h2(
3706
+ "div",
3707
+ {
3708
+ class: "test-top-top"
3709
+ },
3710
+ domss
3711
+ );
3712
+ }
3713
+ return "";
3714
+ }
3715
+ });
3716
+
3717
+ // node_modules/.pnpm/@fangzhongya+utils@0.0.73/node_modules/@fangzhongya/utils/dist/chunk-Q6BNW3MO.js
3718
+ var FUNCTION_REGEX = /^\s*(?:(async)\s+)?(?:function\s*(\*?)\s*(\w*)\s*\(([\s\S]*?)\)|(\*?\s*)\b(\w+)\s*\(([\s\S]*?)\)|\(([\s\S]*?)\)|([^=>,\(\)]+?))\s*(?:=>)?\s*(?:\{([\s\S]*?)\}|([\s\S]*))$/;
3719
+ function getFunctionFormat(v) {
3720
+ if (!v) return;
3721
+ const str = typeof v === "function" ? v.toString() : v;
3722
+ const trimmed = str.trim();
3723
+ const match = trimmed.match(FUNCTION_REGEX);
3724
+ if (!match) {
3725
+ console.warn("Unsupported function format:", trimmed.slice(0, 100));
3726
+ return;
3800
3727
  }
3801
- if (tarr.length > 0) {
3802
- tarr.unshift("");
3728
+ const [
3729
+ _,
3730
+ // 完整匹配
3731
+ asyncFlag,
3732
+ // 异步标志
3733
+ funcGenerator,
3734
+ // 函数生成器标志
3735
+ funcName,
3736
+ // 函数名称
3737
+ funcParams,
3738
+ // 函数参数
3739
+ methodGenerator,
3740
+ // 方法生成器标志
3741
+ methodName,
3742
+ // 方法名称
3743
+ methodParams,
3744
+ // 方法参数
3745
+ arrowParenParams,
3746
+ // 箭头函数括号参数
3747
+ arrowSingleParam,
3748
+ // 箭头函数单参数
3749
+ blockBody,
3750
+ // 块级函数体
3751
+ exprBody
3752
+ // 表达式函数体
3753
+ ] = match;
3754
+ let isAsync = !!asyncFlag;
3755
+ let isGenerator = false;
3756
+ let name = "";
3757
+ let param = "";
3758
+ let body = "";
3759
+ let isArrow = false;
3760
+ let arrowBody = "";
3761
+ if (funcParams !== void 0) {
3762
+ isGenerator = funcGenerator === "*";
3763
+ name = funcName || "";
3764
+ param = funcParams;
3765
+ body = blockBody || exprBody || "";
3766
+ } else if (methodParams !== void 0) {
3767
+ isGenerator = methodGenerator?.includes("*") || false;
3768
+ name = methodName || "";
3769
+ param = methodParams;
3770
+ body = blockBody || exprBody || "";
3771
+ } else if (arrowParenParams !== void 0 || arrowSingleParam !== void 0) {
3772
+ isArrow = true;
3773
+ param = arrowParenParams || arrowSingleParam || "";
3774
+ body = blockBody || exprBody || "";
3775
+ arrowBody = body.trim();
3776
+ if (!blockBody && !/^\s*return\b/.test(body)) {
3777
+ body = `return ${body}`;
3778
+ }
3803
3779
  }
3804
- const slots = getSlots(slotValue, ss);
3805
- let template = `<template>
3806
- <div>
3807
- <${propsname}${tarr.join("\n")}>${slots.join("\n")}
3808
- </${propsname}>
3809
- </div>
3810
- </template>`;
3811
- template = await prettierHtml(template);
3812
- let js2 = sarr.join("\n");
3813
- js2 = await prettierTs(js2);
3814
- const st = `<!--${propsname}-->
3815
- ${template}
3816
- <script lang="ts" setup>
3817
- ${js2}
3818
- </script>`;
3819
- return st;
3780
+ return {
3781
+ isArrow,
3782
+ isAsync,
3783
+ isGenerator,
3784
+ ...name && { name },
3785
+ param: param.trim(),
3786
+ body: body.trim(),
3787
+ arrowBody
3788
+ };
3820
3789
  }
3821
- function getSlots(obj2 = {}, ss) {
3822
- const arr = [];
3823
- Object.keys(obj2).forEach((key) => {
3824
- const sp = getSpecObjs(ss, key) || {};
3825
- const v = obj2[key];
3826
- if (v) {
3827
- const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
3828
- <template #${key}="scope">
3829
- ${vueFormat(v, " ")}
3830
- </template>`;
3831
- arr.push(st);
3832
- }
3790
+
3791
+ // packages/components/use/util.ts
3792
+ var getFormat2 = (r) => {
3793
+ return r;
3794
+ };
3795
+ var isp = getConfig("prettier");
3796
+ if (isp) {
3797
+ Promise.resolve().then(() => (init_prettier(), prettier_exports)).then((d) => {
3798
+ getFormat2 = d.getFormat;
3833
3799
  });
3834
- if (arr && arr.length > 0) {
3835
- arr.unshift("");
3836
- }
3837
- return arr;
3838
3800
  }
3839
- function getFunctionBody(v, key, propsText) {
3840
- const text = propsText ? propsText[key] : "";
3841
- if (text) {
3842
- if (text.includes("=>")) {
3843
- return text;
3844
- } else if (text.includes("function")) {
3845
- return text;
3846
- } else {
3847
- return funstr(v.toString());
3848
- }
3849
- } else {
3850
- return funstr(v.toString());
3801
+ function prettierHtml(st) {
3802
+ if (isp) {
3803
+ const v = getFormat2(st, "html");
3804
+ return v;
3851
3805
  }
3806
+ return st;
3852
3807
  }
3853
- async function funstr(v) {
3854
- const st = getFunctionFormat(v);
3855
- if (st) {
3856
- let body = `{
3857
- ${vueFormat(getFunBody(st.body), " ")}
3858
- }`;
3859
- return `function (${st.param.split(",").map((v2) => v2 + ":any").join(",")}) ${body}`;
3860
- } else {
3861
- return "undefined";
3808
+ function prettierTs(st) {
3809
+ if (isp) {
3810
+ const v = getFormat2(st, "ts");
3811
+ return v;
3862
3812
  }
3813
+ return st;
3863
3814
  }
3864
- function getTypeValueFunction(sp) {
3865
- const css2 = parseParamString(sp.selectable);
3866
- const cs = getParameStr(css2);
3867
- let rs = "";
3868
- if (sp.return) {
3869
- rs = "return ";
3870
- }
3871
- let body = `{
3872
- ${vueFormat(getFunBody(rs), " ")}
3873
- }`;
3874
- return `function (${cs}) ${body}`;
3815
+ function vueFormat(st, kg = "") {
3816
+ let arr = (st + "").trim().split(/\n/);
3817
+ arr = arr.map((v) => {
3818
+ return kg + v;
3819
+ });
3820
+ return arr.join("\n");
3875
3821
  }
3876
- function getChange(str) {
3877
- const tr = str.trim();
3878
- if (/^\(/.test(tr)) {
3879
- return funstr(tr);
3822
+ function getFunBody(sr = "") {
3823
+ sr = sr.trim();
3824
+ let body = "[\\s|\\n|\\r]*\\{((.|\n|\r)+?)\\}[\\s|\\n|\\r]*";
3825
+ let reg = new RegExp("^" + body + "$");
3826
+ let vts = reg.exec(sr);
3827
+ if (vts && vts.length > 0) {
3828
+ return getFunBody(vts[1]);
3880
3829
  } else {
3881
- return JSON.stringify(str);
3830
+ return sr;
3882
3831
  }
3883
3832
  }
3884
- function setValStringify(v, key, propsText) {
3885
- const text = propsText ? propsText[key] : "";
3886
- if (text) {
3887
- return text;
3833
+ var jctypes2 = [
3834
+ "Boolean",
3835
+ "Any",
3836
+ "String",
3837
+ "Number",
3838
+ "Array",
3839
+ "Object",
3840
+ "Function"
3841
+ ];
3842
+ function conversionType2(type) {
3843
+ if (jctypes2.includes(type)) {
3844
+ return firstLower(type);
3888
3845
  } else {
3889
- if (typeof v == "string") {
3890
- return getChange(v + "");
3846
+ return type;
3847
+ }
3848
+ }
3849
+ var splitIgnoringNesting2 = (str, delimiter) => {
3850
+ let bracketStack = [];
3851
+ let parts = [];
3852
+ let current = "";
3853
+ for (let i = 0; i < str.length; i++) {
3854
+ const char = str[i];
3855
+ if (char === "[" || char === "<" || char === "(") {
3856
+ bracketStack.push(char);
3857
+ current += char;
3858
+ } 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] === "(") {
3859
+ bracketStack.pop();
3860
+ current += char;
3861
+ } else if (char === delimiter && bracketStack.length === 0) {
3862
+ parts.push(current.trim());
3863
+ current = "";
3891
3864
  } else {
3892
- return JSON.stringify(v);
3865
+ current += char;
3893
3866
  }
3894
3867
  }
3895
- }
3896
- function getSpecType(val) {
3897
- let tarr = getDataType(parseTypeDefinition(val?.type));
3898
- let type = getDataTypeType(tarr);
3899
- if (tarr.length > 1) {
3900
- type = "any";
3868
+ if (current.trim() !== "") {
3869
+ parts.push(current.trim());
3901
3870
  }
3902
- let selectable = (val?.selectable || "").trim();
3903
- let arr = [];
3904
- if (selectable && type != "boolean") {
3905
- if (selectable.includes("|")) {
3906
- selectable.split("|").forEach((v) => {
3907
- if (v) {
3908
- let z = v.split(":");
3909
- arr.push({
3910
- label: v,
3911
- prop: getObjValue(z[0].trim())
3912
- });
3913
- }
3914
- });
3915
- } else {
3916
- arr = parseParamString(selectable);
3871
+ return parts;
3872
+ };
3873
+ var splitIgnoring2 = (str) => {
3874
+ let bracketStack = [];
3875
+ let isArr = false;
3876
+ let is = false;
3877
+ let top = 0;
3878
+ for (let i = 0; i < str.length; i++) {
3879
+ const char = str[i];
3880
+ if (char === "[" || char === "<" || char === "(") {
3881
+ is = true;
3882
+ bracketStack.push(char);
3883
+ if (char == "[") {
3884
+ isArr = true;
3885
+ }
3886
+ if (top == 0) {
3887
+ top = i;
3888
+ }
3889
+ } else if (char === "]" && bracketStack[bracketStack.length - 1] === "[" || char === ">" && bracketStack[bracketStack.length - 1] === "<" || char === ")" && bracketStack[bracketStack.length - 1] === "(") {
3890
+ bracketStack.pop();
3917
3891
  }
3918
- if (type == "array") {
3919
- type = "choice";
3920
- } else {
3921
- if (type != "function" && arr.length > 1) {
3922
- type = "select";
3892
+ if (is && bracketStack.length === 0) {
3893
+ if (isArr) {
3894
+ if (top + 1 == i) {
3895
+ return {
3896
+ top: "Array",
3897
+ type: str.substring(0, top)
3898
+ };
3899
+ }
3923
3900
  }
3901
+ return {
3902
+ top: str.substring(0, top),
3903
+ type: str.substring(top + 1, i)
3904
+ };
3924
3905
  }
3925
3906
  }
3926
3907
  return {
3927
- arr,
3928
- type,
3929
- dataType: tarr
3908
+ top: str,
3909
+ type: ""
3930
3910
  };
3931
- }
3932
- function getObjValue(d, type) {
3933
- try {
3934
- if (type == "function") {
3935
- if (typeof d === "string") {
3936
- if (/^\((.|\n|\r)*\)$/.test(d)) {
3937
- d = d.substring(1, d.length - 1);
3938
- return new Function(`{ return ${d} }`)();
3939
- }
3911
+ };
3912
+ var parseTypeDefinition2 = (typeDef) => {
3913
+ if (!typeDef) {
3914
+ return ["any"];
3915
+ } else if (typeDef.startsWith("[") && typeDef.endsWith("]") || typeDef.startsWith("(") && typeDef.endsWith(")")) {
3916
+ const inner = typeDef.slice(1, -1).trim();
3917
+ if (!inner) return ["any"];
3918
+ const types = splitIgnoringNesting2(inner, ",");
3919
+ return types;
3920
+ } else if (typeDef.startsWith("{") && typeDef.endsWith("}")) {
3921
+ return ["Object"];
3922
+ } else if (typeDef.startsWith("<") && typeDef.endsWith(">")) {
3923
+ const inner = typeDef.slice(1, -1).trim();
3924
+ if (!inner) return ["any"];
3925
+ const types = splitIgnoringNesting2(inner, "|");
3926
+ return types;
3927
+ } else {
3928
+ const types = splitIgnoringNesting2(typeDef, ",");
3929
+ return types;
3930
+ }
3931
+ };
3932
+ function setDataType(arr) {
3933
+ const v = arr.map((v2) => {
3934
+ if (typeof v2 == "string") {
3935
+ if (v2.toLowerCase() === "array") {
3936
+ return "Array<any>";
3937
+ }
3938
+ return v2;
3939
+ } else {
3940
+ if (v2.children && v2.children.length > 0) {
3941
+ const vz = setDataType(v2.children);
3942
+ return v2.value + "<" + vz + ">";
3940
3943
  } else {
3941
- return d;
3944
+ const z = v2.value;
3945
+ if (z.toLowerCase() === "array") {
3946
+ return "Array<any>";
3947
+ }
3948
+ return z;
3942
3949
  }
3950
+ }
3951
+ }).join(" | ");
3952
+ return v || "any";
3953
+ }
3954
+ function getDataType2(arr) {
3955
+ const value = [];
3956
+ arr.forEach((v) => {
3957
+ const ss = splitIgnoring2(v);
3958
+ if (ss.type) {
3959
+ const dataType = parseTypeDefinition2(ss.type);
3960
+ const children = getDataType2(dataType);
3961
+ value.push({
3962
+ label: v,
3963
+ value: ss.top,
3964
+ children
3965
+ });
3943
3966
  } else {
3944
- return new Function(`{ return ${d} }`)();
3967
+ value.push(ss.top);
3945
3968
  }
3946
- } catch (error) {
3947
- return "" + d;
3948
- }
3969
+ });
3970
+ return value;
3949
3971
  }
3950
- function getDefaultValue(obj2, is = true) {
3951
- const vo = getSpecType(obj2);
3952
- const v = getTypeValue(vo.dataType);
3953
- if (is) {
3954
- const d = (obj2.default || "").trim();
3955
- return getObjValue(d || v, getDataTypeType(vo.dataType));
3972
+ function getTypeName2(type) {
3973
+ let t = "";
3974
+ if (typeof type == "string") {
3975
+ t = type;
3956
3976
  } else {
3957
- const d = (obj2.default || "").trim();
3958
- return getObjValue(d, getDataTypeType(vo.dataType));
3977
+ t = type.value;
3959
3978
  }
3979
+ return conversionType2(t || "any");
3960
3980
  }
3961
-
3962
- // packages/components/compo/index.ts
3963
- var notesObj = {
3964
- titles: [],
3965
- propss: [],
3966
- slots: [],
3967
- emitss: [],
3968
- exposes: []
3969
- };
3970
- function getDefault(ss, iss) {
3971
- let char = ss.charAt(0);
3972
- let css2 = [
3973
- ['"', '"'],
3974
- ["'", "'"],
3975
- ["`", "`"],
3976
- ["(", ")"],
3977
- ["{", "}"],
3978
- ["[", "]"]
3979
- ];
3980
- const cs = css2.map((o) => o[0]);
3981
- let ci = cs.indexOf(char);
3982
- if (ci != -1) {
3983
- let bracketStack = [char];
3984
- for (let i = 1; i < ss.length; i++) {
3985
- char = ss[i];
3986
- ci = cs.indexOf(char);
3987
- if (ci != -1) {
3988
- if (ci > 2) {
3989
- bracketStack.push(char);
3981
+ function getDataTypeType2(dataType) {
3982
+ const type = dataType[0] || "any";
3983
+ return getTypeName2(type);
3984
+ }
3985
+ function getTypeValue(arr) {
3986
+ const dataType = arr[0];
3987
+ let type = getDataTypeType2(arr);
3988
+ switch (type) {
3989
+ case "string":
3990
+ return '""';
3991
+ case "boolean":
3992
+ return "false";
3993
+ case "number":
3994
+ return "0";
3995
+ case "array":
3996
+ if (typeof dataType === "string") {
3997
+ return `[]`;
3998
+ } else {
3999
+ let st = dataType.children;
4000
+ if (st && st.length > 0) {
4001
+ let v = getTypeValue([st[0]]);
4002
+ v = v == "undefined" ? "" : v;
4003
+ return `[${v}]`;
3990
4004
  } else {
3991
- if (bracketStack[bracketStack.length - 1] === char) {
3992
- bracketStack.pop();
4005
+ return `[]`;
4006
+ }
4007
+ }
4008
+ case "object":
4009
+ return "{}";
4010
+ case "function":
4011
+ return "()=>{}";
4012
+ case "any":
4013
+ return '""';
4014
+ default:
4015
+ return "undefined";
4016
+ }
4017
+ }
4018
+ var allReservedWords = [
4019
+ // JavaScript 基本关键字
4020
+ "break",
4021
+ "case",
4022
+ "catch",
4023
+ "class",
4024
+ "const",
4025
+ "continue",
4026
+ "debugger",
4027
+ "default",
4028
+ "delete",
4029
+ "do",
4030
+ "else",
4031
+ "export",
4032
+ "extends",
4033
+ "finally",
4034
+ "for",
4035
+ "function",
4036
+ "if",
4037
+ "import",
4038
+ "in",
4039
+ "instanceof",
4040
+ "new",
4041
+ "return",
4042
+ "super",
4043
+ "switch",
4044
+ "this",
4045
+ "throw",
4046
+ "try",
4047
+ "typeof",
4048
+ "var",
4049
+ "void",
4050
+ "while",
4051
+ "with",
4052
+ "yield",
4053
+ // 严格模式下的保留字
4054
+ "implements",
4055
+ "interface",
4056
+ "let",
4057
+ "package",
4058
+ "private",
4059
+ "protected",
4060
+ "public",
4061
+ "static",
4062
+ // 字面量值
4063
+ "true",
4064
+ "false",
4065
+ "null",
4066
+ "undefined",
4067
+ // TypeScript 特有类型关键字
4068
+ "any",
4069
+ "boolean",
4070
+ "number",
4071
+ "string",
4072
+ "object",
4073
+ "symbol",
4074
+ "unknown",
4075
+ "never",
4076
+ "void",
4077
+ "undefined",
4078
+ "null",
4079
+ // TypeScript 类型操作与定义
4080
+ "type",
4081
+ "interface",
4082
+ "enum",
4083
+ "as",
4084
+ "is",
4085
+ "infer",
4086
+ "unique",
4087
+ // TypeScript 类修饰符
4088
+ "abstract",
4089
+ "readonly",
4090
+ // TypeScript 模块与声明
4091
+ "namespace",
4092
+ "module",
4093
+ "declare",
4094
+ "require",
4095
+ // 其他(访问器、未来保留字等)
4096
+ "get",
4097
+ "set",
4098
+ "async",
4099
+ "await",
4100
+ "from",
4101
+ "of",
4102
+ "package"
4103
+ ];
4104
+
4105
+ // packages/components/use/code.ts
4106
+ function getSpecObjs(specs, name) {
4107
+ return specs.filter((o) => o.name == name)[0];
4108
+ }
4109
+ function getParameStr(css2) {
4110
+ return css2.map((o) => {
4111
+ const name = o.prop || "...arr";
4112
+ return name + ":" + setDataType(o.dataType);
4113
+ }).join(",");
4114
+ }
4115
+ async function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
4116
+ const tarr = [];
4117
+ const sarr = [];
4118
+ let is = true;
4119
+ const ps = getPropsValue2(param.propss || []);
4120
+ const es2 = getEmitsValue(param.emitss || []);
4121
+ const res = getExposeValue(param.exposes || []);
4122
+ const ss = getSlotValue(param.slots || []);
4123
+ Object.keys(value).forEach(async (key) => {
4124
+ let val = value[key];
4125
+ if (/^on[A-Z]/.test(key) && typeof val == "function") {
4126
+ let name = key.substring(2);
4127
+ const knam = key.split(":");
4128
+ let strs;
4129
+ if (knam.length > 1) {
4130
+ strs = knam[0] + knam.slice(1).map((o) => firstUpper(o)).join("");
4131
+ name = firstLower(name);
4132
+ } else {
4133
+ strs = knam[0];
4134
+ name = humpToLine(name);
4135
+ }
4136
+ if (knam.includes("-")) {
4137
+ let arr = strs.split("-");
4138
+ arr = arr.map((vs, i) => {
4139
+ if (i != 0) {
4140
+ return firstUpper(vs);
3993
4141
  } else {
3994
- bracketStack.push(char);
4142
+ return vs;
3995
4143
  }
3996
- }
4144
+ });
4145
+ strs = arr.join("");
4146
+ }
4147
+ tarr.push(" @" + name + '="' + strs + '"');
4148
+ const sp = getSpecObjs(es2, name) || {};
4149
+ const s = sp.selectable || "";
4150
+ const css2 = parseParamString(s);
4151
+ const cs = getParameStr(css2);
4152
+ sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
4153
+ sarr.push("function " + strs + "(" + cs + ") {");
4154
+ css2.forEach((o) => {
4155
+ const name2 = o.name || "arr";
4156
+ sarr.push(" console.log('" + o.label + "', " + name2 + ")");
4157
+ });
4158
+ sarr.push("}");
4159
+ } else {
4160
+ let z = key;
4161
+ if (allReservedWords.includes(key)) {
4162
+ z = key + "1";
4163
+ }
4164
+ tarr.push(" :" + key + '="' + z + '"');
4165
+ const sp = getSpecObjs(ps, key) || {};
4166
+ const t = getSpecType(sp);
4167
+ sarr.push(
4168
+ `// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
4169
+ );
4170
+ if (typeof val == "function" || t.dataType.length == 1 && t.type == "function" && val) {
4171
+ sarr.push(
4172
+ "const " + key + " = " + await getFunctionBody(
4173
+ val,
4174
+ key,
4175
+ propsText
4176
+ )
4177
+ );
3997
4178
  } else {
3998
- let is = false;
3999
- for (let v of css2) {
4000
- if (char === v[1] && bracketStack[bracketStack.length - 1] === v[0]) {
4001
- is = true;
4002
- break;
4003
- }
4004
- }
4005
4179
  if (is) {
4006
- bracketStack.pop();
4180
+ is = false;
4181
+ sarr.unshift("import { ref } from 'vue';");
4007
4182
  }
4008
- }
4009
- if (bracketStack.length === 0) {
4010
- if (iss && ss[i + 1] === " ") {
4011
- return ss.substring(0, i + 1);
4183
+ if (typeof val == "undefined") {
4184
+ if (t.type == "function") {
4185
+ const tv = getTypeValueFunction(sp);
4186
+ sarr.push("const " + z + " = " + tv + ";");
4187
+ } else {
4188
+ const tv = getTypeValue(t.dataType);
4189
+ sarr.push(
4190
+ "const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
4191
+ );
4192
+ }
4012
4193
  } else {
4013
- return ss.substring(0, i + 1);
4194
+ let st2 = setValStringify(val, key, propsText);
4195
+ sarr.push("const " + z + " = ref(" + st2 + ");");
4014
4196
  }
4015
4197
  }
4016
4198
  }
4017
- } else {
4018
- if (iss) {
4019
- return ss.substring(0, ss.indexOf(" "));
4020
- } else {
4021
- return ss;
4199
+ });
4200
+ const ev = Object.values(exposeText || {});
4201
+ if (ev.length > 0) {
4202
+ if (is) {
4203
+ is = false;
4204
+ sarr.unshift("import { ref } from 'vue';");
4022
4205
  }
4023
- }
4024
- }
4025
- function getObj2(v) {
4026
- delete v.problems;
4027
- delete v.source;
4028
- let tag = v.tag;
4029
- let name = v.name;
4030
- let description = v.description;
4031
- let defaults = v.default;
4032
- let selectable = "";
4033
- let required = "";
4034
- if (tag == "default") {
4035
- name = name.trim();
4036
- name = getDefault(name) || name;
4037
- } else if (tag == "selectable") {
4038
- name = name.trim();
4039
- } else {
4040
- if (name.includes("=")) {
4041
- const ms = name.split("=");
4042
- name = ms[0];
4043
- const ss = ms[1] + " " + description;
4044
- const dvz = getDefault(ss, true);
4045
- if (dvz) {
4046
- defaults = dvz;
4047
- description = ss.replace(dvz, "");
4206
+ tarr.unshift(' ref="refDom"');
4207
+ sarr.push("const refDom = ref()");
4208
+ ev.forEach((v) => {
4209
+ const s = getSpecObjs(res, v.name) || {};
4210
+ sarr.push(
4211
+ `// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
4212
+ );
4213
+ const m = v.name + "Value";
4214
+ const css2 = parseParamString(s?.selectable || "");
4215
+ const cs = [];
4216
+ const ps2 = v.params || [];
4217
+ css2.forEach((c, index) => {
4218
+ const prop = c.name;
4219
+ if (prop) {
4220
+ const key = prop + v.name;
4221
+ const val = ps2[index];
4222
+ sarr.push(`// ${c.label}`);
4223
+ if (typeof val == "function") {
4224
+ sarr.push(
4225
+ "const " + key + " = " + getFunctionBody(val, prop, v.text)
4226
+ );
4227
+ } else {
4228
+ if (typeof val == "undefined") {
4229
+ sarr.push(
4230
+ "const " + key + " = " + getTypeValue(c.dataType) + ";"
4231
+ );
4232
+ } else {
4233
+ let st2 = setValStringify(val, prop, v.text);
4234
+ sarr.push("const " + key + " = " + st2 + ";");
4235
+ }
4236
+ }
4237
+ cs.push(key);
4238
+ }
4239
+ });
4240
+ if (v.type === "function") {
4241
+ if (s.return) {
4242
+ sarr.push(
4243
+ `const ${m} = refDom.value?.${v.name}(${cs.join(
4244
+ ", "
4245
+ )})`
4246
+ );
4247
+ } else {
4248
+ sarr.push(`refDom.value?.${v.name}(${cs.join(", ")})`);
4249
+ }
4250
+ if (s.return) {
4251
+ sarr.push(`console.log('${s.return}', ${m})`);
4252
+ }
4048
4253
  } else {
4049
- defaults = v.default || ms[1] || "";
4254
+ sarr.push(`const ${m} = refDom.value?.${v.name}`);
4255
+ sarr.push(`console.log('${s.type || s.name}', ${m})`);
4050
4256
  }
4051
- }
4052
- const regExp = /\s*\((.*)\)\s/gi;
4053
- const rtr = regExp.exec(description);
4054
- if (rtr && rtr.length > 0) {
4055
- selectable = rtr[1];
4056
- description = description.replace(rtr[0], "");
4057
- }
4257
+ });
4058
4258
  }
4059
- if (name.endsWith("*")) {
4060
- required = "*";
4061
- name = name.substring(0, name.length - 1);
4259
+ if (tarr.length > 0) {
4260
+ tarr.unshift("");
4062
4261
  }
4063
- v.name = name;
4064
- v.required = required;
4065
- v.default = defaults || "";
4066
- v.description = description;
4067
- v.selectable = selectable;
4068
- return v;
4069
- }
4070
- function setTitle2(obj2) {
4071
- let title = "";
4072
- let name = "";
4073
- let author = "";
4074
- let description = "";
4075
- let date = "";
4076
- let arr = [
4077
- "title",
4078
- // 'name',
4079
- "text",
4080
- "author",
4081
- "date"
4082
- // 'description',
4083
- // 'descriptions',
4084
- ];
4085
- let fobj = getFilter2(obj2, arr);
4086
- let value = {};
4087
- arr.forEach((key) => {
4088
- value[key] = fobj.obj[key];
4089
- });
4090
- addTitles(value);
4091
- fobj.arr.forEach((o) => {
4092
- addTags2(o.key, o.value);
4093
- });
4094
- }
4095
- function addTitles(value) {
4096
- notesObj.titles.push(value);
4262
+ const slots = getSlots(slotValue, ss);
4263
+ let template = `<template>
4264
+ <div>
4265
+ <${propsname}${tarr.join("\n")}>${slots.join("\n")}
4266
+ </${propsname}>
4267
+ </div>
4268
+ </template>`;
4269
+ template = await prettierHtml(template);
4270
+ let js2 = sarr.join("\n");
4271
+ js2 = await prettierTs(js2);
4272
+ const st = `<!--${propsname}-->
4273
+ ${template}
4274
+ <script lang="ts" setup>
4275
+ ${js2}
4276
+ </script>`;
4277
+ return st;
4097
4278
  }
4098
- function setProps(obj2) {
4099
- let name = "";
4100
- let type = "";
4101
- let defaults = "";
4102
- let description = "";
4103
- let selectable = "";
4104
- let arr = [
4105
- "props",
4106
- "name",
4107
- "type",
4108
- "default",
4109
- "required",
4110
- "selectable",
4111
- "description",
4112
- "descriptions",
4113
- "return"
4114
- ];
4115
- let fobj = getFilter2(obj2, arr);
4116
- let value = {};
4117
- arr.forEach((key) => {
4118
- value[key] = fobj.obj[key];
4119
- });
4120
- addObj(value, "props");
4121
- fobj.arr.forEach((o) => {
4122
- addTags2(o.key, o.value);
4279
+ function getSlots(obj2 = {}, ss) {
4280
+ const arr = [];
4281
+ Object.keys(obj2).forEach((key) => {
4282
+ const sp = getSpecObjs(ss, key) || {};
4283
+ const v = obj2[key];
4284
+ if (v) {
4285
+ const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
4286
+ <template #${key}="scope">
4287
+ ${vueFormat(v, " ")}
4288
+ </template>`;
4289
+ arr.push(st);
4290
+ }
4123
4291
  });
4292
+ if (arr && arr.length > 0) {
4293
+ arr.unshift("");
4294
+ }
4295
+ return arr;
4124
4296
  }
4125
- function setSlot(obj2) {
4126
- let name = "";
4127
- let description = "";
4128
- let selectable = "";
4129
- let arr = ["slot", "name", "selectable", "description", "descriptions"];
4130
- let fobj = getFilter2(obj2, arr);
4131
- let value = {};
4132
- arr.forEach((key) => {
4133
- value[key] = fobj.obj[key];
4134
- });
4135
- addObj(value, "slot");
4136
- fobj.arr.forEach((o) => {
4137
- addTags2(o.key, o.value);
4138
- });
4297
+ function getFunctionBody(v, key, propsText) {
4298
+ const text = propsText ? propsText[key] : "";
4299
+ if (text) {
4300
+ if (text.includes("=>")) {
4301
+ return text;
4302
+ } else if (text.includes("function")) {
4303
+ return text;
4304
+ } else {
4305
+ return funstr(v.toString());
4306
+ }
4307
+ } else {
4308
+ return funstr(v.toString());
4309
+ }
4139
4310
  }
4140
- function setEmits(obj2) {
4141
- let arr = ["emits", "name", "selectable", "description", "descriptions"];
4142
- let fobj = getFilter2(obj2, arr);
4143
- let value = {};
4144
- arr.forEach((key) => {
4145
- value[key] = fobj.obj[key];
4146
- });
4147
- addObj(value, "emits");
4148
- fobj.arr.forEach((o) => {
4149
- addTags2(o.key, o.value);
4150
- });
4311
+ async function funstr(v) {
4312
+ const st = getFunctionFormat(v);
4313
+ if (st) {
4314
+ let body = `{
4315
+ ${vueFormat(getFunBody(st.body), " ")}
4316
+ }`;
4317
+ return `function (${st.param.split(",").map((v2) => v2 + ":any").join(",")}) ${body}`;
4318
+ } else {
4319
+ return "undefined";
4320
+ }
4151
4321
  }
4152
- function setExpose(obj2) {
4153
- let arr = [
4154
- "expose",
4155
- "name",
4156
- "type",
4157
- "return",
4158
- "selectable",
4159
- "description",
4160
- "descriptions"
4161
- ];
4162
- let fobj = getFilter2(obj2, arr);
4163
- let value = {};
4164
- arr.forEach((key) => {
4165
- value[key] = fobj.obj[key];
4166
- });
4167
- addObj(value, "expose");
4168
- fobj.arr.forEach((o) => {
4169
- addTags2(o.key, o.value);
4170
- });
4322
+ function getTypeValueFunction(sp) {
4323
+ const css2 = parseParamString(sp.selectable);
4324
+ const cs = getParameStr(css2);
4325
+ let rs = "";
4326
+ if (sp.return) {
4327
+ rs = "return ";
4328
+ }
4329
+ let body = `{
4330
+ ${vueFormat(getFunBody(rs), " ")}
4331
+ }`;
4332
+ return `function (${cs}) ${body}`;
4171
4333
  }
4172
- function addObj(value, type) {
4173
- const ms = notesObj[type + "name"] || [];
4174
- const name = value.name ?? value[type]?.name;
4175
- const nis = ms.indexOf(name);
4176
- if (nis >= 0) {
4177
- notesObj[type + "s"].splice(nis, 1);
4178
- ms.splice(nis, 1);
4334
+ function getChange(str) {
4335
+ const tr = str.trim();
4336
+ if (/^\(/.test(tr)) {
4337
+ return funstr(tr);
4338
+ } else {
4339
+ return JSON.stringify(str);
4179
4340
  }
4180
- notesObj[type + "s"].push(value);
4181
- ms.push(name);
4182
- notesObj[type + "name"] = ms;
4183
4341
  }
4184
- function init() {
4185
- Object.keys(notesObj).forEach((key) => {
4186
- notesObj[key] = [];
4187
- });
4342
+ function setValStringify(v, key, propsText) {
4343
+ const text = propsText ? propsText[key] : "";
4344
+ if (text) {
4345
+ return text;
4346
+ } else {
4347
+ if (typeof v == "string") {
4348
+ return getChange(v + "");
4349
+ } else {
4350
+ return JSON.stringify(v);
4351
+ }
4352
+ }
4188
4353
  }
4189
- function getFilter2(obj2, arrs) {
4190
- const _objs = {
4191
- descriptions: obj2?.description || ""
4192
- };
4193
- const arr = [];
4194
- if (obj2?.tags) {
4195
- obj2.tags?.forEach((v) => {
4196
- let tag = v.tag;
4197
- let ov = getObj2(v);
4198
- if (!_objs.hasOwnProperty(tag)) {
4199
- _objs[tag] = ov;
4200
- } else {
4201
- const ao = {};
4202
- ao[tag] = ov;
4203
- arr.push({
4204
- key: tag,
4205
- value: ao
4206
- });
4354
+ function getSpecType(val) {
4355
+ let tarr = getDataType2(parseTypeDefinition2(val?.type));
4356
+ let type = getDataTypeType2(tarr);
4357
+ if (tarr.length > 1) {
4358
+ type = "any";
4359
+ }
4360
+ let selectable = (val?.selectable || "").trim();
4361
+ let arr = [];
4362
+ if (selectable && type != "boolean") {
4363
+ if (selectable.includes("|")) {
4364
+ selectable.split("|").forEach((v) => {
4365
+ if (v) {
4366
+ let z = v.split(":");
4367
+ arr.push({
4368
+ label: v,
4369
+ prop: getObjValue(z[0].trim())
4370
+ });
4371
+ }
4372
+ });
4373
+ } else {
4374
+ arr = parseParamString(selectable);
4375
+ }
4376
+ if (type == "array") {
4377
+ type = "choice";
4378
+ } else {
4379
+ if (type != "function" && arr.length > 1) {
4380
+ type = "select";
4207
4381
  }
4208
- });
4382
+ }
4209
4383
  }
4210
4384
  return {
4211
4385
  arr,
4212
- obj: _objs
4386
+ type,
4387
+ dataType: tarr
4213
4388
  };
4214
4389
  }
4215
- function addTags2(tag, obj2) {
4216
- switch (tag) {
4217
- case "title":
4218
- addTitles(obj2);
4219
- return true;
4220
- case "text":
4221
- addTitles(obj2);
4222
- return true;
4223
- case "props":
4224
- addObj(obj2, "props");
4225
- return true;
4226
- case "slot":
4227
- addObj(obj2, "slot");
4228
- return true;
4229
- case "emits":
4230
- addObj(obj2, "emits");
4231
- return true;
4232
- case "expose":
4233
- addObj(obj2, "expose");
4234
- return true;
4235
- default:
4236
- return false;
4237
- }
4238
- }
4239
- function setTags2(tag, obj2) {
4240
- switch (tag) {
4241
- case "title":
4242
- setTitle2(obj2);
4243
- return true;
4244
- case "props":
4245
- setProps(obj2);
4246
- return true;
4247
- case "slot":
4248
- setSlot(obj2);
4249
- return true;
4250
- case "emits":
4251
- setEmits(obj2);
4252
- return true;
4253
- case "expose":
4254
- setExpose(obj2);
4255
- return true;
4256
- default:
4257
- return false;
4258
- }
4259
- }
4260
- function notesFilter(notes) {
4261
- init();
4262
- notes?.forEach((obj2) => {
4263
- let tags = obj2?.tags || [];
4264
- let lg = tags?.length || 0;
4265
- if (lg > 0) {
4266
- for (let i = 0; i < lg; i++) {
4267
- const v = tags[i] || {};
4268
- let is = setTags2(v.tag, obj2);
4269
- if (is) {
4270
- break;
4390
+ function getObjValue(d, type) {
4391
+ try {
4392
+ if (type == "function") {
4393
+ if (typeof d === "string") {
4394
+ if (/^\((.|\n|\r)*\)$/.test(d)) {
4395
+ d = d.substring(1, d.length - 1);
4396
+ return new Function(`{ return ${d} }`)();
4271
4397
  }
4398
+ } else {
4399
+ return d;
4272
4400
  }
4401
+ } else {
4402
+ return new Function(`{ return ${d} }`)();
4273
4403
  }
4274
- });
4275
- return JSON.parse(JSON.stringify(notesObj));
4404
+ } catch (error) {
4405
+ return "" + d;
4406
+ }
4407
+ }
4408
+ function getDefaultValue(obj2, is = true) {
4409
+ const vo = getSpecType(obj2);
4410
+ const v = getTypeValue(vo.dataType);
4411
+ if (is) {
4412
+ const d = (obj2.default || "").trim();
4413
+ return getObjValue(d || v, getDataTypeType2(vo.dataType));
4414
+ } else {
4415
+ const d = (obj2.default || "").trim();
4416
+ return getObjValue(d, getDataTypeType2(vo.dataType));
4417
+ }
4276
4418
  }
4419
+
4420
+ // packages/components/compo/index.ts
4277
4421
  function getNotes2(key) {
4278
4422
  return new Promise((resolve2) => {
4279
4423
  getLocalTextComponents(key).then((text) => {
@@ -4281,16 +4425,17 @@ function getNotes2(key) {
4281
4425
  });
4282
4426
  });
4283
4427
  }
4284
- function getNotesText(text) {
4285
- let notes = getTextNotes(text);
4286
- return notesFilter(notes);
4287
- }
4288
4428
  var tprops = [
4289
4429
  {
4290
4430
  label: "\u5C5E\u6027\u540D",
4291
4431
  prop: "name",
4292
4432
  formatter: props.name
4293
4433
  },
4434
+ {
4435
+ label: "\u53CC\u5411",
4436
+ prop: "model",
4437
+ formatter: props.model
4438
+ },
4294
4439
  {
4295
4440
  label: "\u8BF4\u660E",
4296
4441
  prop: "description",