@bitcobblers/wod-wiki-core 0.50.2189 → 0.50.2190
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.
- package/dist/index.cjs +192 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -7
- package/dist/index.d.ts +52 -7
- package/dist/index.mjs +182 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1151,6 +1151,18 @@ var isNotebookTag = (tag) => tag.startsWith(NOTEBOOK_TAG_PREFIX);
|
|
|
1151
1151
|
|
|
1152
1152
|
// src/sections/sectionParser.ts
|
|
1153
1153
|
var KNOWN_SECTION_WIDGETS = ["playground-run-tip", "attention", "code-example", "syntax-group"];
|
|
1154
|
+
var KNOWN_QUERY_WIDGET_TYPES = {
|
|
1155
|
+
table: true,
|
|
1156
|
+
list: true,
|
|
1157
|
+
value: true,
|
|
1158
|
+
timeseries: true,
|
|
1159
|
+
bar: true,
|
|
1160
|
+
donut: true,
|
|
1161
|
+
toplist: true,
|
|
1162
|
+
"stacked-bar": true,
|
|
1163
|
+
"goal-rings": true,
|
|
1164
|
+
"zone-distribution": true
|
|
1165
|
+
};
|
|
1154
1166
|
function matchDialectFence(trimmedLine) {
|
|
1155
1167
|
const match = trimmedLine.match(/^`{3,}(time|log)(?::([\w-]+))?\s*$/i);
|
|
1156
1168
|
if (!match) return null;
|
|
@@ -1223,9 +1235,11 @@ function parseDocumentSections(content, options = {}) {
|
|
|
1223
1235
|
const tag = fence[2].trim();
|
|
1224
1236
|
const dialect = marker[0] === "`" ? matchDialectFence(`\`\`\`${tag}`) : null;
|
|
1225
1237
|
const widget = marker[0] === "`" ? tag.match(/^widget:([\w-]+)$/) : null;
|
|
1226
|
-
const query = marker[0] === "`" ? tag.match(/^query(?:[:\s](.*))?$/i) : null;
|
|
1227
1238
|
const names = options.registeredWidgets ?? KNOWN_SECTION_WIDGETS;
|
|
1228
1239
|
const knownWidget = widget && ("has" in names ? names.has(widget[1]) : names.includes(widget[1]));
|
|
1240
|
+
const widgetChartMatch = marker[0] === "`" && !knownWidget ? tag.match(/^widget:([a-zA-Z-]+)(?:-(?:full|\d+))?(?:\s+.*)?$/i) : null;
|
|
1241
|
+
const isWidgetChart = Boolean(widgetChartMatch && KNOWN_QUERY_WIDGET_TYPES[widgetChartMatch[1].toLowerCase()]);
|
|
1242
|
+
const query = marker[0] === "`" ? tag.match(/^query(?:[:\s](.*))?$/i) ?? (isWidgetChart ? tag.match(/^widget:?(.*)$/i) : null) : null;
|
|
1229
1243
|
const type = closed && dialect ? dialect.dialect : closed && knownWidget ? "widget" : closed && query ? "query" : "code";
|
|
1230
1244
|
const section2 = make(type, line, end2);
|
|
1231
1245
|
section2.contentFrom = offsets[line] + lines[line].length + separators[line].length;
|
|
@@ -1548,15 +1562,175 @@ function patchFrontmatterProperty(raw, path, value) {
|
|
|
1548
1562
|
next.splice(spliceIndex, removeCount, ...replacement);
|
|
1549
1563
|
return `---${eol}${next.length ? next.join(eol) + eol : ""}---` + raw.slice(m[0].length);
|
|
1550
1564
|
}
|
|
1565
|
+
var FRONTMATTER_BODY_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
1566
|
+
function unquoteScalar(value) {
|
|
1567
|
+
return value.replace(
|
|
1568
|
+
/^(['"])(.*)\1$/,
|
|
1569
|
+
(_match, quote, inner) => quote === '"' ? inner.replace(
|
|
1570
|
+
/\\(["\\nrt])/g,
|
|
1571
|
+
(_all, c) => c === "n" ? "\n" : c === "r" ? "\r" : c === "t" ? " " : c
|
|
1572
|
+
) : inner
|
|
1573
|
+
);
|
|
1574
|
+
}
|
|
1575
|
+
function parseMetaLines(lines) {
|
|
1576
|
+
const meta = {};
|
|
1577
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1578
|
+
const keyMatch = lines[i].match(/^([A-Za-z][\w.-]*)\s*:(.*)$/);
|
|
1579
|
+
if (!keyMatch) continue;
|
|
1580
|
+
const key = keyMatch[1];
|
|
1581
|
+
const rawVal = keyMatch[2].trim();
|
|
1582
|
+
if (rawVal === "") {
|
|
1583
|
+
const items = [];
|
|
1584
|
+
while (i + 1 < lines.length) {
|
|
1585
|
+
const itemMatch = lines[i + 1].match(/^\s+-\s+(.+)$/);
|
|
1586
|
+
if (!itemMatch) break;
|
|
1587
|
+
items.push(unquoteScalar(itemMatch[1].trim()));
|
|
1588
|
+
i++;
|
|
1589
|
+
}
|
|
1590
|
+
if (items.length > 0) {
|
|
1591
|
+
meta[key] = items;
|
|
1592
|
+
} else if (key === "metrics" || key === "summaries" || key === "widgets") {
|
|
1593
|
+
while (i + 1 < lines.length) {
|
|
1594
|
+
const childLine = lines[i + 1];
|
|
1595
|
+
if (/^\s*(?:#.*)?$/.test(childLine)) {
|
|
1596
|
+
i++;
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
const childMatch = childLine.match(/^\s{2,}([A-Za-z][\w.-]*)\s*:(.*)$/);
|
|
1600
|
+
if (!childMatch) break;
|
|
1601
|
+
i++;
|
|
1602
|
+
const childKey = `${key}.${childMatch[1]}`;
|
|
1603
|
+
const childRaw = childMatch[2].trim();
|
|
1604
|
+
if (childRaw === "") {
|
|
1605
|
+
const childItems = [];
|
|
1606
|
+
while (i + 1 < lines.length) {
|
|
1607
|
+
const listMatch = lines[i + 1].match(/^\s{4,}-\s+(.+)$/);
|
|
1608
|
+
if (!listMatch) break;
|
|
1609
|
+
childItems.push(unquoteScalar(listMatch[1].trim()));
|
|
1610
|
+
i++;
|
|
1611
|
+
}
|
|
1612
|
+
meta[childKey] = childItems.length > 0 ? childItems : "";
|
|
1613
|
+
} else {
|
|
1614
|
+
const wasQuoted = /^(['"])(.*)\1$/.test(childRaw);
|
|
1615
|
+
const value = unquoteScalar(childRaw);
|
|
1616
|
+
const num = Number(value);
|
|
1617
|
+
meta[childKey] = !wasQuoted && value !== "" && !isNaN(num) ? num : value;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
meta[key] = "";
|
|
1622
|
+
}
|
|
1623
|
+
} else {
|
|
1624
|
+
const wasQuoted = /^(['"])(.*)\1$/.test(rawVal);
|
|
1625
|
+
const value = unquoteScalar(rawVal);
|
|
1626
|
+
const num = Number(value);
|
|
1627
|
+
meta[key] = !wasQuoted && value !== "" && !isNaN(num) ? num : value;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
return meta;
|
|
1631
|
+
}
|
|
1632
|
+
function parseFrontmatter(raw) {
|
|
1633
|
+
const match = raw.match(FRONTMATTER_BODY_RE);
|
|
1634
|
+
if (!match) return { meta: {}, body: raw };
|
|
1635
|
+
return { meta: parseMetaLines(match[1].split(/\r?\n/)), body: raw.slice(match[0].length) };
|
|
1636
|
+
}
|
|
1637
|
+
function parseFrontmatterBody(innerContent) {
|
|
1638
|
+
return parseMetaLines(innerContent.split(/\r?\n/));
|
|
1639
|
+
}
|
|
1640
|
+
function serializeFrontmatter(meta) {
|
|
1641
|
+
const lines = [];
|
|
1642
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
1643
|
+
if (Array.isArray(value)) {
|
|
1644
|
+
if (value.length === 0) {
|
|
1645
|
+
lines.push(`${key}: ""`);
|
|
1646
|
+
continue;
|
|
1647
|
+
}
|
|
1648
|
+
lines.push(`${key}:`);
|
|
1649
|
+
for (const item of value) {
|
|
1650
|
+
lines.push(` - ${quoteYamlScalar(item)}`);
|
|
1651
|
+
}
|
|
1652
|
+
} else if (typeof value === "number") {
|
|
1653
|
+
lines.push(`${key}: ${value}`);
|
|
1654
|
+
} else {
|
|
1655
|
+
lines.push(`${key}: ${quoteYamlScalar(value)}`);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
return lines.join("\n");
|
|
1659
|
+
}
|
|
1660
|
+
function stripFrontmatter(raw) {
|
|
1661
|
+
return parseFrontmatter(raw).body;
|
|
1662
|
+
}
|
|
1663
|
+
function getScalar(meta, key) {
|
|
1664
|
+
const value = meta[key];
|
|
1665
|
+
return typeof value === "string" || typeof value === "number" ? value : void 0;
|
|
1666
|
+
}
|
|
1667
|
+
function getList(meta, key) {
|
|
1668
|
+
const value = meta[key];
|
|
1669
|
+
return Array.isArray(value) ? value : [];
|
|
1670
|
+
}
|
|
1671
|
+
function parseFrontmatterCategories(raw) {
|
|
1672
|
+
return getList(parseFrontmatter(raw).meta, "category").map((c) => c.toLowerCase());
|
|
1673
|
+
}
|
|
1674
|
+
function extractFrontmatterTags(raw) {
|
|
1675
|
+
const meta = FRONTMATTER_BODY_RE.test(raw) ? parseFrontmatter(raw).meta : parseFrontmatterBody(raw);
|
|
1676
|
+
const tags = meta["tags"] ?? meta["category"];
|
|
1677
|
+
const list = Array.isArray(tags) ? tags : typeof tags === "string" && tags.trim() ? tags.trim().startsWith("[") && tags.trim().endsWith("]") ? tags.trim().slice(1, -1).split(",") : [tags] : [];
|
|
1678
|
+
return [...new Set(list.map((tag) => tag.trim()).filter(Boolean))];
|
|
1679
|
+
}
|
|
1680
|
+
function extractTypedFrontmatterTags(raw, knownTypeNames = []) {
|
|
1681
|
+
const meta = FRONTMATTER_BODY_RE.test(raw) ? parseFrontmatter(raw).meta : parseFrontmatterBody(raw);
|
|
1682
|
+
const results = [];
|
|
1683
|
+
for (const tag of extractFrontmatterTags(raw)) {
|
|
1684
|
+
results.push({ label: tag });
|
|
1685
|
+
}
|
|
1686
|
+
const metaKeys = Object.keys(meta);
|
|
1687
|
+
for (const typeName of knownTypeNames) {
|
|
1688
|
+
if (typeName === "tags" || typeName === "category") continue;
|
|
1689
|
+
const matchedKey = metaKeys.find((k) => k.toLowerCase() === typeName.toLowerCase());
|
|
1690
|
+
if (!matchedKey) continue;
|
|
1691
|
+
const val = meta[matchedKey];
|
|
1692
|
+
if (val === void 0 || val === null || val === "") continue;
|
|
1693
|
+
let items = [];
|
|
1694
|
+
if (Array.isArray(val)) {
|
|
1695
|
+
items = val.map(String);
|
|
1696
|
+
} else if (typeof val === "string" && val.trim()) {
|
|
1697
|
+
const trimmed = val.trim();
|
|
1698
|
+
items = trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1).split(",") : [trimmed];
|
|
1699
|
+
}
|
|
1700
|
+
for (const item of items) {
|
|
1701
|
+
const label = item.trim();
|
|
1702
|
+
if (label) results.push({ label, type: typeName });
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
const map = /* @__PURE__ */ new Map();
|
|
1706
|
+
for (const item of results) {
|
|
1707
|
+
const existing = map.get(item.label);
|
|
1708
|
+
if (!existing || !existing.type && item.type) {
|
|
1709
|
+
map.set(item.label, item);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
return Array.from(map.values());
|
|
1713
|
+
}
|
|
1714
|
+
function parseFlatProperties(innerContent) {
|
|
1715
|
+
return parseFrontmatterProps(innerContent.split(/\r?\n/));
|
|
1716
|
+
}
|
|
1717
|
+
function parseFrontmatterProps(lines) {
|
|
1718
|
+
const props = {};
|
|
1719
|
+
for (const line of lines) {
|
|
1720
|
+
const match = line.match(/^([^:]+):\s*(.*)$/);
|
|
1721
|
+
if (match) props[match[1].trim()] = match[2].trim();
|
|
1722
|
+
}
|
|
1723
|
+
return props;
|
|
1724
|
+
}
|
|
1551
1725
|
|
|
1552
1726
|
// src/version.ts
|
|
1553
|
-
var VERSION = "0.50.
|
|
1554
|
-
var GIT_SHA = "
|
|
1555
|
-
var BUILD_TIME = "2026-11-
|
|
1727
|
+
var VERSION = "0.50.2190";
|
|
1728
|
+
var GIT_SHA = "9ee7872";
|
|
1729
|
+
var BUILD_TIME = "2026-11-01T23:32:46.829Z";
|
|
1556
1730
|
var SEMVER = {
|
|
1557
|
-
version: "0.50.
|
|
1558
|
-
gitSha: "
|
|
1559
|
-
buildTime: "2026-11-
|
|
1731
|
+
version: "0.50.2190",
|
|
1732
|
+
gitSha: "9ee7872",
|
|
1733
|
+
buildTime: "2026-11-01T23:32:46.829Z"
|
|
1560
1734
|
};
|
|
1561
1735
|
|
|
1562
1736
|
exports.BUILD_TIME = BUILD_TIME;
|
|
@@ -1596,13 +1770,17 @@ exports.createTagIndex = createTagIndex;
|
|
|
1596
1770
|
exports.detectScriptBlocks = detectScriptBlocks;
|
|
1597
1771
|
exports.dimensionKeyOf = dimensionKeyOf;
|
|
1598
1772
|
exports.extractBlockContent = extractBlockContent;
|
|
1773
|
+
exports.extractFrontmatterTags = extractFrontmatterTags;
|
|
1774
|
+
exports.extractTypedFrontmatterTags = extractTypedFrontmatterTags;
|
|
1599
1775
|
exports.fieldRefFromKey = fieldRefFromKey;
|
|
1600
1776
|
exports.fieldRefKey = fieldRefKey;
|
|
1601
1777
|
exports.findBlockAtLine = findBlockAtLine;
|
|
1602
1778
|
exports.flattenFieldLeaves = flattenFieldLeaves;
|
|
1603
1779
|
exports.fromNotebookTag = fromNotebookTag;
|
|
1780
|
+
exports.getList = getList;
|
|
1604
1781
|
exports.getMetricOwnershipLayer = getMetricOwnershipLayer;
|
|
1605
1782
|
exports.getReferenceMetadata = getReferenceMetadata;
|
|
1783
|
+
exports.getScalar = getScalar;
|
|
1606
1784
|
exports.getTagReference = getTagReference;
|
|
1607
1785
|
exports.isNoteEditable = isNoteEditable;
|
|
1608
1786
|
exports.isNotebookTag = isNotebookTag;
|
|
@@ -1616,12 +1794,19 @@ exports.notebookSlugFromId = notebookSlugFromId;
|
|
|
1616
1794
|
exports.orderPlacements = orderPlacements;
|
|
1617
1795
|
exports.ownershipRank = ownershipRank;
|
|
1618
1796
|
exports.parseDocumentSections = parseDocumentSections;
|
|
1797
|
+
exports.parseFlatProperties = parseFlatProperties;
|
|
1798
|
+
exports.parseFrontmatter = parseFrontmatter;
|
|
1799
|
+
exports.parseFrontmatterBody = parseFrontmatterBody;
|
|
1800
|
+
exports.parseFrontmatterCategories = parseFrontmatterCategories;
|
|
1801
|
+
exports.parseFrontmatterProps = parseFrontmatterProps;
|
|
1619
1802
|
exports.patchFrontmatterProperty = patchFrontmatterProperty;
|
|
1620
1803
|
exports.projectPlacements = projectPlacements;
|
|
1621
1804
|
exports.reconcileNoteBlocks = reconcileNoteBlocks;
|
|
1622
1805
|
exports.resolveLayer = resolveLayer;
|
|
1623
1806
|
exports.resolvePlacements = resolvePlacements;
|
|
1624
1807
|
exports.runAffordance = runAffordance;
|
|
1808
|
+
exports.serializeFrontmatter = serializeFrontmatter;
|
|
1809
|
+
exports.stripFrontmatter = stripFrontmatter;
|
|
1625
1810
|
exports.systemDefaultUnit = systemDefaultUnit;
|
|
1626
1811
|
exports.toNotebookId = toNotebookId;
|
|
1627
1812
|
exports.toNotebookTag = toNotebookTag;
|