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