@utilix-tech/sdk 0.33.0 → 0.34.0
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/CHANGELOG.md +4 -0
- package/README.md +13 -4
- package/dist/{chunk-CSNTHZHF.js → chunk-3YUKLV5N.js} +81 -1
- package/dist/{chunk-6FIB72KX.js → chunk-YEXQDI3J.js} +63 -1
- package/dist/{data-C4lCByXw.d.cts → data-CFeS9kes.d.cts} +35 -2
- package/dist/{data-C4lCByXw.d.ts → data-CFeS9kes.d.ts} +35 -2
- package/dist/index.cjs +142 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{network-D7Epuerc.d.cts → network-DfY5Ikvr.d.cts} +34 -2
- package/dist/{network-D7Epuerc.d.ts → network-DfY5Ikvr.d.ts} +34 -2
- package/dist/tools/data.cjs +62 -0
- package/dist/tools/data.d.cts +1 -1
- package/dist/tools/data.d.ts +1 -1
- package/dist/tools/data.js +1 -1
- package/dist/tools/network.cjs +80 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.34.0
|
|
6
|
+
- Add `buildReferrerPolicy` (referrer-policy-builder): build a Referrer-Policy header value from one or more policy tokens with a plain-English explanation of each and warnings for risky choices like unsafe-url.
|
|
7
|
+
- Add `generateMarkdownToc` (markdown-toc-generator): scan a Markdown document's ATX headings and build a nested table of contents with GitHub-style anchor slugs, disambiguating duplicates.
|
|
8
|
+
|
|
5
9
|
## 0.33.0
|
|
6
10
|
- Add `lintConventionalCommit` (conventional-commit-linter): lint a git commit message against the Conventional Commits v1.0.0 spec, checking header format, blank-line separation, footer tokens, and BREAKING CHANGE casing.
|
|
7
11
|
- Add `calculateSavingsGoal` (savings-goal-calculator): solve for months to reach a savings goal at a fixed monthly contribution, or the monthly contribution required to hit a goal by a target month count.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**593 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -181,13 +181,14 @@ analyzeSentenceLengths("The cat sat on the mat. It was a sunny day, and the dog
|
|
|
181
181
|
|
|
182
182
|
---
|
|
183
183
|
|
|
184
|
-
### `/data`: CSV / YAML / TOML / XML / INI / NDJSON / .env diff / subtitles / Markdown front matter
|
|
184
|
+
### `/data`: CSV / YAML / TOML / XML / INI / NDJSON / .env diff / subtitles / Markdown front matter & TOC
|
|
185
185
|
|
|
186
186
|
```ts
|
|
187
187
|
import { parseCsv, csvToJson, validateYaml, tomlToJson, jsonToToml,
|
|
188
188
|
formatXml, xmlToJson, jsonToXml, parseIni,
|
|
189
189
|
validateNdjson, formatNdjson, ndjsonToJsonArray, diffEnvExample,
|
|
190
|
-
parseSubtitles, convertSubtitles, shiftSubtitles, parseFrontMatter
|
|
190
|
+
parseSubtitles, convertSubtitles, shiftSubtitles, parseFrontMatter,
|
|
191
|
+
generateMarkdownToc } from "@utilix-tech/sdk/data";
|
|
191
192
|
|
|
192
193
|
// CSV
|
|
193
194
|
const rows = parseCsv("name,age\nalice,30\nbob,25");
|
|
@@ -225,6 +226,10 @@ shiftSubtitles("1\n00:00:01,000 --> 00:00:04,000\nHi\n", -2.5);
|
|
|
225
226
|
// Markdown front matter: split a document into its YAML front matter and body
|
|
226
227
|
parseFrontMatter("---\ntitle: Hello World\ntags: [foo, bar]\n---\n# Body");
|
|
227
228
|
// { frontMatter: { title: "Hello World", tags: ["foo", "bar"] }, body: "# Body", hasFrontMatter: true, ... }
|
|
229
|
+
|
|
230
|
+
// Markdown table of contents: ATX headings -> nested links with GitHub-style slugs
|
|
231
|
+
generateMarkdownToc("# Title\n\n## Section One\n\n## Section Two\n");
|
|
232
|
+
// { toc: "- [Title](#title)\n - [Section One](#section-one)\n - [Section Two](#section-two)", entries: [...] }
|
|
228
233
|
```
|
|
229
234
|
|
|
230
235
|
---
|
|
@@ -390,7 +395,7 @@ calculateEmi(500000, 8.5, 5, "years");
|
|
|
390
395
|
import { getStatusCode, isValidIp, isValidIpv4, isValidIpv6,
|
|
391
396
|
searchStatusCodes, buildGeoUrl, countryCodeToFlag,
|
|
392
397
|
parseHar, validateSitemap, validateRobotsTxt,
|
|
393
|
-
parseUserAgent, buildCacheControl, parseIpv6Address } from "@utilix-tech/sdk/network";
|
|
398
|
+
parseUserAgent, buildCacheControl, buildReferrerPolicy, parseIpv6Address } from "@utilix-tech/sdk/network";
|
|
394
399
|
|
|
395
400
|
getStatusCode(404);
|
|
396
401
|
// { code: 404, text: "Not Found", description: "...", category: "Client Error" }
|
|
@@ -425,6 +430,10 @@ validateRobotsTxt("User-agent: *\nDisallow: /admin\nSitemap: https://example.com
|
|
|
425
430
|
buildCacheControl({ visibility: "public", maxAge: 3600, mustRevalidate: true });
|
|
426
431
|
// { header: "public, max-age=3600, must-revalidate", directives: [...], warnings: [] }
|
|
427
432
|
|
|
433
|
+
// Build and explain a Referrer-Policy header from one or more fallback-chain tokens
|
|
434
|
+
buildReferrerPolicy("strict-origin-when-cross-origin");
|
|
435
|
+
// { header: "strict-origin-when-cross-origin", metaTag: '<meta name="referrer" content="...">', policies: [...], warnings: [] }
|
|
436
|
+
|
|
428
437
|
// Expand/compress an IPv6 address (RFC 5952) and classify its address type
|
|
429
438
|
parseIpv6Address("2001:db8::ff00:42:8329");
|
|
430
439
|
// { expanded: "2001:0db8:0000:0000:0000:ff00:0042:8329", compressed: "2001:db8::ff00:42:8329",
|
|
@@ -5,11 +5,13 @@ var network_exports = {};
|
|
|
5
5
|
__export(network_exports, {
|
|
6
6
|
DNS_RECORD_TYPES: () => DNS_RECORD_TYPES,
|
|
7
7
|
HTTP_HEADERS: () => HTTP_HEADERS,
|
|
8
|
+
REFERRER_POLICY_VALUES: () => REFERRER_POLICY_VALUES,
|
|
8
9
|
STATUS_CODES: () => STATUS_CODES,
|
|
9
10
|
buildCacheControl: () => buildCacheControl,
|
|
10
11
|
buildDnsQueryUrl: () => buildDnsQueryUrl,
|
|
11
12
|
buildGeoUrl: () => buildGeoUrl,
|
|
12
13
|
buildMapUrl: () => buildMapUrl,
|
|
14
|
+
buildReferrerPolicy: () => buildReferrerPolicy,
|
|
13
15
|
countryCodeToFlag: () => countryCodeToFlag,
|
|
14
16
|
formatCoordinates: () => formatCoordinates,
|
|
15
17
|
formatTtl: () => formatTtl,
|
|
@@ -1815,6 +1817,84 @@ function buildCacheControl(options = {}) {
|
|
|
1815
1817
|
const snippet = `Cache-Control: ${header}`;
|
|
1816
1818
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
1817
1819
|
}
|
|
1820
|
+
var REFERRER_POLICY_VALUES = [
|
|
1821
|
+
"no-referrer",
|
|
1822
|
+
"no-referrer-when-downgrade",
|
|
1823
|
+
"origin",
|
|
1824
|
+
"origin-when-cross-origin",
|
|
1825
|
+
"same-origin",
|
|
1826
|
+
"strict-origin",
|
|
1827
|
+
"strict-origin-when-cross-origin",
|
|
1828
|
+
"unsafe-url"
|
|
1829
|
+
];
|
|
1830
|
+
var _REFERRER_POLICY_INFO = {
|
|
1831
|
+
"no-referrer": {
|
|
1832
|
+
explanation: "Never sends the Referer header, on any request. The strictest option; the destination learns nothing about where the request came from.",
|
|
1833
|
+
leaksPathAndQuery: false,
|
|
1834
|
+
sentOnDowngrade: false
|
|
1835
|
+
},
|
|
1836
|
+
"no-referrer-when-downgrade": {
|
|
1837
|
+
explanation: "Sends the full URL (origin, path, and query string) for same-security-level or upgrading requests, but omits the header entirely when navigating from HTTPS to HTTP. This was the legacy browser default before strict-origin-when-cross-origin.",
|
|
1838
|
+
leaksPathAndQuery: true,
|
|
1839
|
+
sentOnDowngrade: false
|
|
1840
|
+
},
|
|
1841
|
+
origin: {
|
|
1842
|
+
explanation: "Sends only the origin (scheme, host, and port) on every request, same-origin or cross-origin, including on a downgrade. The path and query string are always stripped.",
|
|
1843
|
+
leaksPathAndQuery: false,
|
|
1844
|
+
sentOnDowngrade: true
|
|
1845
|
+
},
|
|
1846
|
+
"origin-when-cross-origin": {
|
|
1847
|
+
explanation: "Sends the full URL for same-origin requests, but only the origin for cross-origin requests. Still sends the origin on a downgrade.",
|
|
1848
|
+
leaksPathAndQuery: true,
|
|
1849
|
+
sentOnDowngrade: true
|
|
1850
|
+
},
|
|
1851
|
+
"same-origin": {
|
|
1852
|
+
explanation: "Sends the full URL for same-origin requests, and no Referer header at all for cross-origin requests.",
|
|
1853
|
+
leaksPathAndQuery: true,
|
|
1854
|
+
sentOnDowngrade: false
|
|
1855
|
+
},
|
|
1856
|
+
"strict-origin": {
|
|
1857
|
+
explanation: "Sends only the origin, and only when the security level stays the same or improves (HTTPS to HTTPS, or HTTP to anything). Nothing is sent on a downgrade from HTTPS to HTTP.",
|
|
1858
|
+
leaksPathAndQuery: false,
|
|
1859
|
+
sentOnDowngrade: false
|
|
1860
|
+
},
|
|
1861
|
+
"strict-origin-when-cross-origin": {
|
|
1862
|
+
explanation: "Sends the full URL for same-origin requests, only the origin for cross-origin requests at the same or better security level, and nothing at all on a downgrade. This is the current browser default when no policy is set.",
|
|
1863
|
+
leaksPathAndQuery: true,
|
|
1864
|
+
sentOnDowngrade: false
|
|
1865
|
+
},
|
|
1866
|
+
"unsafe-url": {
|
|
1867
|
+
explanation: "Always sends the full URL, including path and query string, on every request, even on a downgrade from HTTPS to HTTP. Generally discouraged: query strings can carry session tokens or other sensitive data that then leaks to third-party destinations and to the network on an insecure connection.",
|
|
1868
|
+
leaksPathAndQuery: true,
|
|
1869
|
+
sentOnDowngrade: true
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
function buildReferrerPolicy(policies) {
|
|
1873
|
+
const list = Array.isArray(policies) ? policies : [policies];
|
|
1874
|
+
const trimmed = list.map((p) => typeof p === "string" ? p.trim() : "").filter((p) => p !== "");
|
|
1875
|
+
if (trimmed.length === 0) {
|
|
1876
|
+
return { error: "At least one policy value is required" };
|
|
1877
|
+
}
|
|
1878
|
+
const entries = [];
|
|
1879
|
+
for (const value of trimmed) {
|
|
1880
|
+
if (!REFERRER_POLICY_VALUES.includes(value)) {
|
|
1881
|
+
return { error: `'${value}' is not a valid Referrer-Policy value. Valid values: ${REFERRER_POLICY_VALUES.join(", ")}` };
|
|
1882
|
+
}
|
|
1883
|
+
entries.push({ value, ..._REFERRER_POLICY_INFO[value] });
|
|
1884
|
+
}
|
|
1885
|
+
const warnings = [];
|
|
1886
|
+
const last = entries[entries.length - 1];
|
|
1887
|
+
if (last.value === "unsafe-url") {
|
|
1888
|
+
warnings.push("unsafe-url sends the full URL, including query strings, on every request, even over an insecure downgrade. Prefer strict-origin-when-cross-origin unless you have a specific reason to leak full URLs.");
|
|
1889
|
+
}
|
|
1890
|
+
if (entries.length > 1 && entries.some((e, i) => i !== entries.length - 1 && e.value === last.value)) {
|
|
1891
|
+
warnings.push("The same policy value appears more than once in the fallback chain, which has no effect beyond the first occurrence.");
|
|
1892
|
+
}
|
|
1893
|
+
const header = entries.map((e) => e.value).join(", ");
|
|
1894
|
+
const snippet = `Referrer-Policy: ${header}`;
|
|
1895
|
+
const metaTag = `<meta name="referrer" content="${last.value}">`;
|
|
1896
|
+
return { header, headerName: "Referrer-Policy", snippet, metaTag, policies: entries, warnings };
|
|
1897
|
+
}
|
|
1818
1898
|
function isValidIpv6HexGroup(g) {
|
|
1819
1899
|
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
1820
1900
|
}
|
|
@@ -1904,4 +1984,4 @@ function parseIpv6Address(input) {
|
|
|
1904
1984
|
};
|
|
1905
1985
|
}
|
|
1906
1986
|
|
|
1907
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap };
|
|
1987
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, REFERRER_POLICY_VALUES, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, buildReferrerPolicy, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap };
|
|
@@ -16,6 +16,7 @@ __export(data_exports, {
|
|
|
16
16
|
formatSubtitleTimestamp: () => formatSubtitleTimestamp,
|
|
17
17
|
formatToml: () => formatToml,
|
|
18
18
|
formatXml: () => formatXml,
|
|
19
|
+
generateMarkdownToc: () => generateMarkdownToc,
|
|
19
20
|
getSection: () => getSection,
|
|
20
21
|
getSectionNames: () => getSectionNames,
|
|
21
22
|
getTomlStats: () => getTomlStats,
|
|
@@ -1399,5 +1400,66 @@ function parseFrontMatter(input) {
|
|
|
1399
1400
|
}
|
|
1400
1401
|
return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
|
|
1401
1402
|
}
|
|
1403
|
+
function stripInlineMarkdown(text) {
|
|
1404
|
+
return text.replace(/(\*\*\*|___)(.+?)\1/g, "$2").replace(/(\*\*|__)(.+?)\1/g, "$2").replace(/(\*|_)(.+?)\1/g, "$2").replace(/`([^`]+)`/g, "$1").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").trim();
|
|
1405
|
+
}
|
|
1406
|
+
function slugifyHeading(text, seen) {
|
|
1407
|
+
let slug = text.toLowerCase().trim().replace(/[^\p{L}\p{N}\s_-]/gu, "").replace(/\s/g, "-");
|
|
1408
|
+
const count = seen.get(slug) ?? 0;
|
|
1409
|
+
seen.set(slug, count + 1);
|
|
1410
|
+
if (count > 0) slug = `${slug}-${count}`;
|
|
1411
|
+
return slug;
|
|
1412
|
+
}
|
|
1413
|
+
function generateMarkdownToc(markdown, options = {}) {
|
|
1414
|
+
if (typeof markdown !== "string" || markdown.trim() === "") {
|
|
1415
|
+
return { error: "markdown is required" };
|
|
1416
|
+
}
|
|
1417
|
+
const minLevel = options.minLevel ?? 1;
|
|
1418
|
+
const maxLevel = options.maxLevel ?? 6;
|
|
1419
|
+
if (!Number.isInteger(minLevel) || !Number.isInteger(maxLevel) || minLevel < 1 || minLevel > 6 || maxLevel < 1 || maxLevel > 6 || minLevel > maxLevel) {
|
|
1420
|
+
return { error: "minLevel and maxLevel must be integers between 1 and 6, with minLevel <= maxLevel" };
|
|
1421
|
+
}
|
|
1422
|
+
const lines = markdown.replace(/\r\n/g, "\n").split("\n");
|
|
1423
|
+
const entries = [];
|
|
1424
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1425
|
+
let inFence = false;
|
|
1426
|
+
let fenceMarker = "";
|
|
1427
|
+
for (const line of lines) {
|
|
1428
|
+
const fenceMatch = line.match(/^\s*(```+|~~~+)/);
|
|
1429
|
+
if (fenceMatch) {
|
|
1430
|
+
if (!inFence) {
|
|
1431
|
+
inFence = true;
|
|
1432
|
+
fenceMarker = fenceMatch[1][0];
|
|
1433
|
+
} else if (fenceMatch[1][0] === fenceMarker) {
|
|
1434
|
+
inFence = false;
|
|
1435
|
+
}
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
if (inFence) continue;
|
|
1439
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
1440
|
+
if (!headingMatch) continue;
|
|
1441
|
+
const level = headingMatch[1].length;
|
|
1442
|
+
const text = stripInlineMarkdown(headingMatch[2]);
|
|
1443
|
+
if (text === "") continue;
|
|
1444
|
+
const slug = slugifyHeading(text, seen);
|
|
1445
|
+
if (level < minLevel || level > maxLevel) continue;
|
|
1446
|
+
entries.push({ level, text, slug });
|
|
1447
|
+
}
|
|
1448
|
+
if (entries.length === 0) {
|
|
1449
|
+
return { error: "No headings found in the given level range" };
|
|
1450
|
+
}
|
|
1451
|
+
const baseLevel = Math.min(...entries.map((e) => e.level));
|
|
1452
|
+
const counters = [0, 0, 0, 0, 0, 0, 0];
|
|
1453
|
+
const tocLines = entries.map((e) => {
|
|
1454
|
+
const indent = " ".repeat(e.level - baseLevel);
|
|
1455
|
+
if (options.ordered) {
|
|
1456
|
+
counters[e.level] = (counters[e.level] ?? 0) + 1;
|
|
1457
|
+
for (let l = e.level + 1; l < counters.length; l++) counters[l] = 0;
|
|
1458
|
+
return `${indent}${counters[e.level]}. [${e.text}](#${e.slug})`;
|
|
1459
|
+
}
|
|
1460
|
+
return `${indent}- [${e.text}](#${e.slug})`;
|
|
1461
|
+
});
|
|
1462
|
+
return { toc: tocLines.join("\n"), entries };
|
|
1463
|
+
}
|
|
1402
1464
|
|
|
1403
|
-
export { convertSubtitles, csvToJson, data_exports, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
|
|
1465
|
+
export { convertSubtitles, csvToJson, data_exports, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, generateMarkdownToc, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
|
|
15
15
|
* - subtitle-converter: parseSubtitleTimestamp, formatSubtitleTimestamp, detectSubtitleFormat, parseSubtitles, serializeSubtitles, convertSubtitles, shiftSubtitles
|
|
16
16
|
* - markdown-front-matter-parser: parseFrontMatter
|
|
17
|
+
* - markdown-toc-generator: generateMarkdownToc
|
|
17
18
|
*/
|
|
18
19
|
interface ValidationResult {
|
|
19
20
|
valid: boolean;
|
|
@@ -291,6 +292,34 @@ interface FrontMatterError {
|
|
|
291
292
|
* "---" delimiter is returned as-is with `hasFrontMatter: false`.
|
|
292
293
|
*/
|
|
293
294
|
declare function parseFrontMatter(input: string): FrontMatterResult | FrontMatterError;
|
|
295
|
+
interface MarkdownTocOptions {
|
|
296
|
+
/** Shallowest heading level to include (1-6). Default 1. */
|
|
297
|
+
minLevel?: number;
|
|
298
|
+
/** Deepest heading level to include (1-6). Default 6. */
|
|
299
|
+
maxLevel?: number;
|
|
300
|
+
/** Render as a numbered list instead of a bullet list. Default false. */
|
|
301
|
+
ordered?: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface MarkdownTocEntry {
|
|
304
|
+
level: number;
|
|
305
|
+
text: string;
|
|
306
|
+
slug: string;
|
|
307
|
+
}
|
|
308
|
+
interface MarkdownTocResult {
|
|
309
|
+
toc: string;
|
|
310
|
+
entries: MarkdownTocEntry[];
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Generate a Markdown table of contents from a document's ATX headings
|
|
314
|
+
* (`#` through `######`). Returns both the rendered TOC (a nested bullet or
|
|
315
|
+
* numbered list of links) and the parsed heading entries with GitHub-style
|
|
316
|
+
* anchor slugs, so duplicate headings get `-1`, `-2`, ... suffixes the same
|
|
317
|
+
* way GitHub's own renderer disambiguates them. Headings inside fenced code
|
|
318
|
+
* blocks (```` ``` ```` or `~~~`) are ignored.
|
|
319
|
+
*/
|
|
320
|
+
declare function generateMarkdownToc(markdown: string, options?: MarkdownTocOptions): MarkdownTocResult | {
|
|
321
|
+
error: string;
|
|
322
|
+
};
|
|
294
323
|
|
|
295
324
|
type data_ConvertedSubtitles = ConvertedSubtitles;
|
|
296
325
|
type data_CsvParseResult = CsvParseResult;
|
|
@@ -301,6 +330,9 @@ type data_EnvParseResult = EnvParseResult;
|
|
|
301
330
|
type data_FrontMatterError = FrontMatterError;
|
|
302
331
|
type data_FrontMatterResult = FrontMatterResult;
|
|
303
332
|
type data_IniSection = IniSection;
|
|
333
|
+
type data_MarkdownTocEntry = MarkdownTocEntry;
|
|
334
|
+
type data_MarkdownTocOptions = MarkdownTocOptions;
|
|
335
|
+
type data_MarkdownTocResult = MarkdownTocResult;
|
|
304
336
|
type data_NdjsonLineResult = NdjsonLineResult;
|
|
305
337
|
type data_NdjsonValidateResult = NdjsonValidateResult;
|
|
306
338
|
type data_ParseOptions = ParseOptions;
|
|
@@ -323,6 +355,7 @@ declare const data_formatNdjson: typeof formatNdjson;
|
|
|
323
355
|
declare const data_formatSubtitleTimestamp: typeof formatSubtitleTimestamp;
|
|
324
356
|
declare const data_formatToml: typeof formatToml;
|
|
325
357
|
declare const data_formatXml: typeof formatXml;
|
|
358
|
+
declare const data_generateMarkdownToc: typeof generateMarkdownToc;
|
|
326
359
|
declare const data_getSection: typeof getSection;
|
|
327
360
|
declare const data_getSectionNames: typeof getSectionNames;
|
|
328
361
|
declare const data_getTomlStats: typeof getTomlStats;
|
|
@@ -357,7 +390,7 @@ declare const data_validateXml: typeof validateXml;
|
|
|
357
390
|
declare const data_validateYaml: typeof validateYaml;
|
|
358
391
|
declare const data_xmlToJson: typeof xmlToJson;
|
|
359
392
|
declare namespace data {
|
|
360
|
-
export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
393
|
+
export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
361
394
|
}
|
|
362
395
|
|
|
363
|
-
export {
|
|
396
|
+
export { parseIni as $, getSectionNames as A, getTomlStats as B, type ConvertedSubtitles as C, getXmlStats as D, type EnvDiffError as E, type FrontMatterError as F, getYamlStats as G, iniToJson as H, type IniSection as I, jsonArrayToNdjson as J, jsonToIni as K, jsonToToml as L, type MarkdownTocEntry as M, type NdjsonLineResult as N, jsonToXml as O, type ParseOptions as P, minifyNdjson as Q, minifyToml as R, type SubtitleCue as S, type TomlFormatResult as T, minifyXml as U, type ValidationResult as V, ndjsonToJsonArray as W, type XmlFormatResult as X, parseCsv as Y, parseEnv as Z, parseFrontMatter as _, type CsvParseResult as a, parseSubtitleTimestamp as a0, parseSubtitles as a1, parseXmlToObject as a2, serializeSubtitles as a3, shiftSubtitles as a4, stringifyIni as a5, toCsvString as a6, tomlToJson as a7, validateEnvKey as a8, validateIni as a9, validateNdjson as aa, validateToml as ab, validateXml as ac, validateYaml as ad, xmlToJson as ae, type EnvDiffResult as b, type EnvEntry as c, data as d, type EnvParseResult as e, type FrontMatterResult as f, type MarkdownTocOptions as g, type MarkdownTocResult as h, type NdjsonValidateResult as i, type ParsedIni as j, type ParsedSubtitles as k, type SubtitleFormat as l, type XmlToJsonOptions as m, convertSubtitles as n, csvToJson as o, detectDelimiter as p, detectSubtitleFormat as q, diffEnvExample as r, envToExport as s, envToJson as t, formatNdjson as u, formatSubtitleTimestamp as v, formatToml as w, formatXml as x, generateMarkdownToc as y, getSection as z };
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
|
|
15
15
|
* - subtitle-converter: parseSubtitleTimestamp, formatSubtitleTimestamp, detectSubtitleFormat, parseSubtitles, serializeSubtitles, convertSubtitles, shiftSubtitles
|
|
16
16
|
* - markdown-front-matter-parser: parseFrontMatter
|
|
17
|
+
* - markdown-toc-generator: generateMarkdownToc
|
|
17
18
|
*/
|
|
18
19
|
interface ValidationResult {
|
|
19
20
|
valid: boolean;
|
|
@@ -291,6 +292,34 @@ interface FrontMatterError {
|
|
|
291
292
|
* "---" delimiter is returned as-is with `hasFrontMatter: false`.
|
|
292
293
|
*/
|
|
293
294
|
declare function parseFrontMatter(input: string): FrontMatterResult | FrontMatterError;
|
|
295
|
+
interface MarkdownTocOptions {
|
|
296
|
+
/** Shallowest heading level to include (1-6). Default 1. */
|
|
297
|
+
minLevel?: number;
|
|
298
|
+
/** Deepest heading level to include (1-6). Default 6. */
|
|
299
|
+
maxLevel?: number;
|
|
300
|
+
/** Render as a numbered list instead of a bullet list. Default false. */
|
|
301
|
+
ordered?: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface MarkdownTocEntry {
|
|
304
|
+
level: number;
|
|
305
|
+
text: string;
|
|
306
|
+
slug: string;
|
|
307
|
+
}
|
|
308
|
+
interface MarkdownTocResult {
|
|
309
|
+
toc: string;
|
|
310
|
+
entries: MarkdownTocEntry[];
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Generate a Markdown table of contents from a document's ATX headings
|
|
314
|
+
* (`#` through `######`). Returns both the rendered TOC (a nested bullet or
|
|
315
|
+
* numbered list of links) and the parsed heading entries with GitHub-style
|
|
316
|
+
* anchor slugs, so duplicate headings get `-1`, `-2`, ... suffixes the same
|
|
317
|
+
* way GitHub's own renderer disambiguates them. Headings inside fenced code
|
|
318
|
+
* blocks (```` ``` ```` or `~~~`) are ignored.
|
|
319
|
+
*/
|
|
320
|
+
declare function generateMarkdownToc(markdown: string, options?: MarkdownTocOptions): MarkdownTocResult | {
|
|
321
|
+
error: string;
|
|
322
|
+
};
|
|
294
323
|
|
|
295
324
|
type data_ConvertedSubtitles = ConvertedSubtitles;
|
|
296
325
|
type data_CsvParseResult = CsvParseResult;
|
|
@@ -301,6 +330,9 @@ type data_EnvParseResult = EnvParseResult;
|
|
|
301
330
|
type data_FrontMatterError = FrontMatterError;
|
|
302
331
|
type data_FrontMatterResult = FrontMatterResult;
|
|
303
332
|
type data_IniSection = IniSection;
|
|
333
|
+
type data_MarkdownTocEntry = MarkdownTocEntry;
|
|
334
|
+
type data_MarkdownTocOptions = MarkdownTocOptions;
|
|
335
|
+
type data_MarkdownTocResult = MarkdownTocResult;
|
|
304
336
|
type data_NdjsonLineResult = NdjsonLineResult;
|
|
305
337
|
type data_NdjsonValidateResult = NdjsonValidateResult;
|
|
306
338
|
type data_ParseOptions = ParseOptions;
|
|
@@ -323,6 +355,7 @@ declare const data_formatNdjson: typeof formatNdjson;
|
|
|
323
355
|
declare const data_formatSubtitleTimestamp: typeof formatSubtitleTimestamp;
|
|
324
356
|
declare const data_formatToml: typeof formatToml;
|
|
325
357
|
declare const data_formatXml: typeof formatXml;
|
|
358
|
+
declare const data_generateMarkdownToc: typeof generateMarkdownToc;
|
|
326
359
|
declare const data_getSection: typeof getSection;
|
|
327
360
|
declare const data_getSectionNames: typeof getSectionNames;
|
|
328
361
|
declare const data_getTomlStats: typeof getTomlStats;
|
|
@@ -357,7 +390,7 @@ declare const data_validateXml: typeof validateXml;
|
|
|
357
390
|
declare const data_validateYaml: typeof validateYaml;
|
|
358
391
|
declare const data_xmlToJson: typeof xmlToJson;
|
|
359
392
|
declare namespace data {
|
|
360
|
-
export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
393
|
+
export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
361
394
|
}
|
|
362
395
|
|
|
363
|
-
export {
|
|
396
|
+
export { parseIni as $, getSectionNames as A, getTomlStats as B, type ConvertedSubtitles as C, getXmlStats as D, type EnvDiffError as E, type FrontMatterError as F, getYamlStats as G, iniToJson as H, type IniSection as I, jsonArrayToNdjson as J, jsonToIni as K, jsonToToml as L, type MarkdownTocEntry as M, type NdjsonLineResult as N, jsonToXml as O, type ParseOptions as P, minifyNdjson as Q, minifyToml as R, type SubtitleCue as S, type TomlFormatResult as T, minifyXml as U, type ValidationResult as V, ndjsonToJsonArray as W, type XmlFormatResult as X, parseCsv as Y, parseEnv as Z, parseFrontMatter as _, type CsvParseResult as a, parseSubtitleTimestamp as a0, parseSubtitles as a1, parseXmlToObject as a2, serializeSubtitles as a3, shiftSubtitles as a4, stringifyIni as a5, toCsvString as a6, tomlToJson as a7, validateEnvKey as a8, validateIni as a9, validateNdjson as aa, validateToml as ab, validateXml as ac, validateYaml as ad, xmlToJson as ae, type EnvDiffResult as b, type EnvEntry as c, data as d, type EnvParseResult as e, type FrontMatterResult as f, type MarkdownTocOptions as g, type MarkdownTocResult as h, type NdjsonValidateResult as i, type ParsedIni as j, type ParsedSubtitles as k, type SubtitleFormat as l, type XmlToJsonOptions as m, convertSubtitles as n, csvToJson as o, detectDelimiter as p, detectSubtitleFormat as q, diffEnvExample as r, envToExport as s, envToJson as t, formatNdjson as u, formatSubtitleTimestamp as v, formatToml as w, formatXml as x, generateMarkdownToc as y, getSection as z };
|
package/dist/index.cjs
CHANGED
|
@@ -4686,6 +4686,7 @@ __export(data_exports, {
|
|
|
4686
4686
|
formatSubtitleTimestamp: () => formatSubtitleTimestamp,
|
|
4687
4687
|
formatToml: () => formatToml,
|
|
4688
4688
|
formatXml: () => formatXml,
|
|
4689
|
+
generateMarkdownToc: () => generateMarkdownToc,
|
|
4689
4690
|
getSection: () => getSection,
|
|
4690
4691
|
getSectionNames: () => getSectionNames,
|
|
4691
4692
|
getTomlStats: () => getTomlStats,
|
|
@@ -6069,6 +6070,67 @@ function parseFrontMatter(input) {
|
|
|
6069
6070
|
}
|
|
6070
6071
|
return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
|
|
6071
6072
|
}
|
|
6073
|
+
function stripInlineMarkdown(text) {
|
|
6074
|
+
return text.replace(/(\*\*\*|___)(.+?)\1/g, "$2").replace(/(\*\*|__)(.+?)\1/g, "$2").replace(/(\*|_)(.+?)\1/g, "$2").replace(/`([^`]+)`/g, "$1").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").trim();
|
|
6075
|
+
}
|
|
6076
|
+
function slugifyHeading(text, seen) {
|
|
6077
|
+
let slug = text.toLowerCase().trim().replace(/[^\p{L}\p{N}\s_-]/gu, "").replace(/\s/g, "-");
|
|
6078
|
+
const count = seen.get(slug) ?? 0;
|
|
6079
|
+
seen.set(slug, count + 1);
|
|
6080
|
+
if (count > 0) slug = `${slug}-${count}`;
|
|
6081
|
+
return slug;
|
|
6082
|
+
}
|
|
6083
|
+
function generateMarkdownToc(markdown, options = {}) {
|
|
6084
|
+
if (typeof markdown !== "string" || markdown.trim() === "") {
|
|
6085
|
+
return { error: "markdown is required" };
|
|
6086
|
+
}
|
|
6087
|
+
const minLevel = options.minLevel ?? 1;
|
|
6088
|
+
const maxLevel = options.maxLevel ?? 6;
|
|
6089
|
+
if (!Number.isInteger(minLevel) || !Number.isInteger(maxLevel) || minLevel < 1 || minLevel > 6 || maxLevel < 1 || maxLevel > 6 || minLevel > maxLevel) {
|
|
6090
|
+
return { error: "minLevel and maxLevel must be integers between 1 and 6, with minLevel <= maxLevel" };
|
|
6091
|
+
}
|
|
6092
|
+
const lines = markdown.replace(/\r\n/g, "\n").split("\n");
|
|
6093
|
+
const entries = [];
|
|
6094
|
+
const seen = /* @__PURE__ */ new Map();
|
|
6095
|
+
let inFence = false;
|
|
6096
|
+
let fenceMarker = "";
|
|
6097
|
+
for (const line of lines) {
|
|
6098
|
+
const fenceMatch = line.match(/^\s*(```+|~~~+)/);
|
|
6099
|
+
if (fenceMatch) {
|
|
6100
|
+
if (!inFence) {
|
|
6101
|
+
inFence = true;
|
|
6102
|
+
fenceMarker = fenceMatch[1][0];
|
|
6103
|
+
} else if (fenceMatch[1][0] === fenceMarker) {
|
|
6104
|
+
inFence = false;
|
|
6105
|
+
}
|
|
6106
|
+
continue;
|
|
6107
|
+
}
|
|
6108
|
+
if (inFence) continue;
|
|
6109
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
6110
|
+
if (!headingMatch) continue;
|
|
6111
|
+
const level = headingMatch[1].length;
|
|
6112
|
+
const text = stripInlineMarkdown(headingMatch[2]);
|
|
6113
|
+
if (text === "") continue;
|
|
6114
|
+
const slug = slugifyHeading(text, seen);
|
|
6115
|
+
if (level < minLevel || level > maxLevel) continue;
|
|
6116
|
+
entries.push({ level, text, slug });
|
|
6117
|
+
}
|
|
6118
|
+
if (entries.length === 0) {
|
|
6119
|
+
return { error: "No headings found in the given level range" };
|
|
6120
|
+
}
|
|
6121
|
+
const baseLevel = Math.min(...entries.map((e) => e.level));
|
|
6122
|
+
const counters = [0, 0, 0, 0, 0, 0, 0];
|
|
6123
|
+
const tocLines = entries.map((e) => {
|
|
6124
|
+
const indent = " ".repeat(e.level - baseLevel);
|
|
6125
|
+
if (options.ordered) {
|
|
6126
|
+
counters[e.level] = (counters[e.level] ?? 0) + 1;
|
|
6127
|
+
for (let l = e.level + 1; l < counters.length; l++) counters[l] = 0;
|
|
6128
|
+
return `${indent}${counters[e.level]}. [${e.text}](#${e.slug})`;
|
|
6129
|
+
}
|
|
6130
|
+
return `${indent}- [${e.text}](#${e.slug})`;
|
|
6131
|
+
});
|
|
6132
|
+
return { toc: tocLines.join("\n"), entries };
|
|
6133
|
+
}
|
|
6072
6134
|
|
|
6073
6135
|
// src/tools/generators.ts
|
|
6074
6136
|
var generators_exports = {};
|
|
@@ -9281,11 +9343,13 @@ var network_exports = {};
|
|
|
9281
9343
|
__export(network_exports, {
|
|
9282
9344
|
DNS_RECORD_TYPES: () => DNS_RECORD_TYPES,
|
|
9283
9345
|
HTTP_HEADERS: () => HTTP_HEADERS,
|
|
9346
|
+
REFERRER_POLICY_VALUES: () => REFERRER_POLICY_VALUES,
|
|
9284
9347
|
STATUS_CODES: () => STATUS_CODES,
|
|
9285
9348
|
buildCacheControl: () => buildCacheControl,
|
|
9286
9349
|
buildDnsQueryUrl: () => buildDnsQueryUrl,
|
|
9287
9350
|
buildGeoUrl: () => buildGeoUrl,
|
|
9288
9351
|
buildMapUrl: () => buildMapUrl,
|
|
9352
|
+
buildReferrerPolicy: () => buildReferrerPolicy,
|
|
9289
9353
|
countryCodeToFlag: () => countryCodeToFlag,
|
|
9290
9354
|
formatCoordinates: () => formatCoordinates,
|
|
9291
9355
|
formatTtl: () => formatTtl,
|
|
@@ -11091,6 +11155,84 @@ function buildCacheControl(options = {}) {
|
|
|
11091
11155
|
const snippet = `Cache-Control: ${header}`;
|
|
11092
11156
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
11093
11157
|
}
|
|
11158
|
+
var REFERRER_POLICY_VALUES = [
|
|
11159
|
+
"no-referrer",
|
|
11160
|
+
"no-referrer-when-downgrade",
|
|
11161
|
+
"origin",
|
|
11162
|
+
"origin-when-cross-origin",
|
|
11163
|
+
"same-origin",
|
|
11164
|
+
"strict-origin",
|
|
11165
|
+
"strict-origin-when-cross-origin",
|
|
11166
|
+
"unsafe-url"
|
|
11167
|
+
];
|
|
11168
|
+
var _REFERRER_POLICY_INFO = {
|
|
11169
|
+
"no-referrer": {
|
|
11170
|
+
explanation: "Never sends the Referer header, on any request. The strictest option; the destination learns nothing about where the request came from.",
|
|
11171
|
+
leaksPathAndQuery: false,
|
|
11172
|
+
sentOnDowngrade: false
|
|
11173
|
+
},
|
|
11174
|
+
"no-referrer-when-downgrade": {
|
|
11175
|
+
explanation: "Sends the full URL (origin, path, and query string) for same-security-level or upgrading requests, but omits the header entirely when navigating from HTTPS to HTTP. This was the legacy browser default before strict-origin-when-cross-origin.",
|
|
11176
|
+
leaksPathAndQuery: true,
|
|
11177
|
+
sentOnDowngrade: false
|
|
11178
|
+
},
|
|
11179
|
+
origin: {
|
|
11180
|
+
explanation: "Sends only the origin (scheme, host, and port) on every request, same-origin or cross-origin, including on a downgrade. The path and query string are always stripped.",
|
|
11181
|
+
leaksPathAndQuery: false,
|
|
11182
|
+
sentOnDowngrade: true
|
|
11183
|
+
},
|
|
11184
|
+
"origin-when-cross-origin": {
|
|
11185
|
+
explanation: "Sends the full URL for same-origin requests, but only the origin for cross-origin requests. Still sends the origin on a downgrade.",
|
|
11186
|
+
leaksPathAndQuery: true,
|
|
11187
|
+
sentOnDowngrade: true
|
|
11188
|
+
},
|
|
11189
|
+
"same-origin": {
|
|
11190
|
+
explanation: "Sends the full URL for same-origin requests, and no Referer header at all for cross-origin requests.",
|
|
11191
|
+
leaksPathAndQuery: true,
|
|
11192
|
+
sentOnDowngrade: false
|
|
11193
|
+
},
|
|
11194
|
+
"strict-origin": {
|
|
11195
|
+
explanation: "Sends only the origin, and only when the security level stays the same or improves (HTTPS to HTTPS, or HTTP to anything). Nothing is sent on a downgrade from HTTPS to HTTP.",
|
|
11196
|
+
leaksPathAndQuery: false,
|
|
11197
|
+
sentOnDowngrade: false
|
|
11198
|
+
},
|
|
11199
|
+
"strict-origin-when-cross-origin": {
|
|
11200
|
+
explanation: "Sends the full URL for same-origin requests, only the origin for cross-origin requests at the same or better security level, and nothing at all on a downgrade. This is the current browser default when no policy is set.",
|
|
11201
|
+
leaksPathAndQuery: true,
|
|
11202
|
+
sentOnDowngrade: false
|
|
11203
|
+
},
|
|
11204
|
+
"unsafe-url": {
|
|
11205
|
+
explanation: "Always sends the full URL, including path and query string, on every request, even on a downgrade from HTTPS to HTTP. Generally discouraged: query strings can carry session tokens or other sensitive data that then leaks to third-party destinations and to the network on an insecure connection.",
|
|
11206
|
+
leaksPathAndQuery: true,
|
|
11207
|
+
sentOnDowngrade: true
|
|
11208
|
+
}
|
|
11209
|
+
};
|
|
11210
|
+
function buildReferrerPolicy(policies) {
|
|
11211
|
+
const list = Array.isArray(policies) ? policies : [policies];
|
|
11212
|
+
const trimmed = list.map((p) => typeof p === "string" ? p.trim() : "").filter((p) => p !== "");
|
|
11213
|
+
if (trimmed.length === 0) {
|
|
11214
|
+
return { error: "At least one policy value is required" };
|
|
11215
|
+
}
|
|
11216
|
+
const entries = [];
|
|
11217
|
+
for (const value of trimmed) {
|
|
11218
|
+
if (!REFERRER_POLICY_VALUES.includes(value)) {
|
|
11219
|
+
return { error: `'${value}' is not a valid Referrer-Policy value. Valid values: ${REFERRER_POLICY_VALUES.join(", ")}` };
|
|
11220
|
+
}
|
|
11221
|
+
entries.push({ value, ..._REFERRER_POLICY_INFO[value] });
|
|
11222
|
+
}
|
|
11223
|
+
const warnings = [];
|
|
11224
|
+
const last = entries[entries.length - 1];
|
|
11225
|
+
if (last.value === "unsafe-url") {
|
|
11226
|
+
warnings.push("unsafe-url sends the full URL, including query strings, on every request, even over an insecure downgrade. Prefer strict-origin-when-cross-origin unless you have a specific reason to leak full URLs.");
|
|
11227
|
+
}
|
|
11228
|
+
if (entries.length > 1 && entries.some((e, i) => i !== entries.length - 1 && e.value === last.value)) {
|
|
11229
|
+
warnings.push("The same policy value appears more than once in the fallback chain, which has no effect beyond the first occurrence.");
|
|
11230
|
+
}
|
|
11231
|
+
const header = entries.map((e) => e.value).join(", ");
|
|
11232
|
+
const snippet = `Referrer-Policy: ${header}`;
|
|
11233
|
+
const metaTag = `<meta name="referrer" content="${last.value}">`;
|
|
11234
|
+
return { header, headerName: "Referrer-Policy", snippet, metaTag, policies: entries, warnings };
|
|
11235
|
+
}
|
|
11094
11236
|
function isValidIpv6HexGroup(g) {
|
|
11095
11237
|
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
11096
11238
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,11 +2,11 @@ export { j as json } from './json-Ta9JykSB.cjs';
|
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
4
4
|
export { t as text } from './text-CA-zuD0C.cjs';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-CFeS9kes.cjs';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
8
|
export { u as units } from './units-BhoxdHhs.cjs';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-DfY5Ikvr.cjs';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.cjs';
|
|
11
11
|
export { c as code } from './code-BK-x8hVx.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export { j as json } from './json-Ta9JykSB.js';
|
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.js';
|
|
4
4
|
export { t as text } from './text-CA-zuD0C.js';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-CFeS9kes.js';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
8
|
export { u as units } from './units-BhoxdHhs.js';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-DfY5Ikvr.js';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.js';
|
|
11
11
|
export { c as code } from './code-BK-x8hVx.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-L6V4W4SU.js';
|
|
2
2
|
export { units_exports as units } from './chunk-ZPQOE7KD.js';
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
3
|
+
export { network_exports as network } from './chunk-3YUKLV5N.js';
|
|
4
4
|
export { api_exports as api } from './chunk-52ZDKSIX.js';
|
|
5
5
|
export { code_exports as code } from './chunk-UUT5HNST.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
@@ -11,7 +11,7 @@ export { json_exports as json } from './chunk-WVEKRKGU.js';
|
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
13
13
|
export { text_exports as text } from './chunk-H2USEUHD.js';
|
|
14
|
-
export { data_exports as data } from './chunk-
|
|
14
|
+
export { data_exports as data } from './chunk-YEXQDI3J.js';
|
|
15
15
|
export { generators_exports as generators } from './chunk-3TYWIX3B.js';
|
|
16
16
|
export { time_exports as time } from './chunk-IEPWZERQ.js';
|
|
17
17
|
import './chunk-MLKGABMK.js';
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
13
|
* - user-agent-parser: parseUserAgent
|
|
14
14
|
* - cache-control-builder: buildCacheControl
|
|
15
|
+
* - referrer-policy-builder: buildReferrerPolicy
|
|
15
16
|
* - ipv6-compressor: parseIpv6Address
|
|
16
17
|
*/
|
|
17
18
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
@@ -292,6 +293,32 @@ interface CacheControlResult {
|
|
|
292
293
|
declare function buildCacheControl(options?: CacheControlOptions): CacheControlResult | {
|
|
293
294
|
error: string;
|
|
294
295
|
};
|
|
296
|
+
type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
297
|
+
interface ReferrerPolicyEntry {
|
|
298
|
+
value: ReferrerPolicyValue;
|
|
299
|
+
explanation: string;
|
|
300
|
+
leaksPathAndQuery: boolean;
|
|
301
|
+
sentOnDowngrade: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface ReferrerPolicyResult {
|
|
304
|
+
header: string;
|
|
305
|
+
headerName: 'Referrer-Policy';
|
|
306
|
+
snippet: string;
|
|
307
|
+
metaTag: string;
|
|
308
|
+
policies: ReferrerPolicyEntry[];
|
|
309
|
+
warnings: string[];
|
|
310
|
+
}
|
|
311
|
+
declare const REFERRER_POLICY_VALUES: ReferrerPolicyValue[];
|
|
312
|
+
/**
|
|
313
|
+
* Build a `Referrer-Policy` header value from one or more policy tokens
|
|
314
|
+
* (a fallback chain: a browser that doesn't recognize an earlier token
|
|
315
|
+
* falls through to the next one, per the Referrer Policy spec), with a
|
|
316
|
+
* plain-English explanation of each token and warnings for risky choices.
|
|
317
|
+
* Pure string assembly and lookup; it never inspects real request traffic.
|
|
318
|
+
*/
|
|
319
|
+
declare function buildReferrerPolicy(policies: string | string[]): ReferrerPolicyResult | {
|
|
320
|
+
error: string;
|
|
321
|
+
};
|
|
295
322
|
type Ipv6AddressType = 'unspecified' | 'loopback' | 'link-local' | 'unique-local' | 'multicast' | 'ipv4-mapped' | 'documentation' | 'global-unicast';
|
|
296
323
|
interface Ipv6ParseResult {
|
|
297
324
|
expanded: string;
|
|
@@ -328,6 +355,10 @@ type network_Ipv6AddressType = Ipv6AddressType;
|
|
|
328
355
|
type network_Ipv6ParseResult = Ipv6ParseResult;
|
|
329
356
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
330
357
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
358
|
+
declare const network_REFERRER_POLICY_VALUES: typeof REFERRER_POLICY_VALUES;
|
|
359
|
+
type network_ReferrerPolicyEntry = ReferrerPolicyEntry;
|
|
360
|
+
type network_ReferrerPolicyResult = ReferrerPolicyResult;
|
|
361
|
+
type network_ReferrerPolicyValue = ReferrerPolicyValue;
|
|
331
362
|
type network_RobotsGroup = RobotsGroup;
|
|
332
363
|
type network_RobotsIssue = RobotsIssue;
|
|
333
364
|
type network_RobotsRule = RobotsRule;
|
|
@@ -344,6 +375,7 @@ declare const network_buildCacheControl: typeof buildCacheControl;
|
|
|
344
375
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
345
376
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
346
377
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
378
|
+
declare const network_buildReferrerPolicy: typeof buildReferrerPolicy;
|
|
347
379
|
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
348
380
|
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
349
381
|
declare const network_formatTtl: typeof formatTtl;
|
|
@@ -373,7 +405,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
373
405
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
374
406
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
375
407
|
declare namespace network {
|
|
376
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
408
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, type network_ReferrerPolicyEntry as ReferrerPolicyEntry, type network_ReferrerPolicyResult as ReferrerPolicyResult, type network_ReferrerPolicyValue as ReferrerPolicyValue, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
377
409
|
}
|
|
378
410
|
|
|
379
|
-
export {
|
|
411
|
+
export { isValidIpv6 as $, buildCacheControl as A, buildDnsQueryUrl as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, buildGeoUrl as E, buildMapUrl as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, buildReferrerPolicy as J, countryCodeToFlag as K, formatCoordinates as L, formatTtl as M, getByCategory as N, getHeader as O, type ParsedDnsResult as P, getHeadersByCategory as Q, REFERRER_POLICY_VALUES as R, STATUS_CODES as S, getStatusByCategory as T, type UaDeviceType as U, getStatusCode as V, isClientError as W, isServerError as X, isSuccess as Y, isValidIp as Z, isValidIpv4 as _, type CacheControlOptions as a, parseDnsResponse as a0, parseGeoResponse as a1, parseHar as a2, parseIpv6Address as a3, parseUserAgent as a4, searchHeaders as a5, searchStatusCodes as a6, statusCodeToText as a7, typeNumberToLabel as a8, validateDomain as a9, validateHeaderName as aa, validateHeaderValue as ab, validateRobotsTxt as ac, validateSitemap as ad, type CacheControlResult as b, type DnsRecord as c, type DnsRecordType as d, type DnsResponse as e, type HarEntry as f, type HarParseResult as g, type HarSummary as h, type HeaderCategory as i, type HttpHeader as j, type Ipv6ParseResult as k, type ParsedGeoResult as l, type ReferrerPolicyEntry as m, network as n, type ReferrerPolicyResult as o, type ReferrerPolicyValue as p, type RobotsGroup as q, type RobotsIssue as r, type RobotsRule as s, type RobotsValidationResult as t, type SitemapIndexEntry as u, type SitemapIssue as v, type SitemapUrlEntry as w, type SitemapValidationResult as x, type StatusCode as y, type UserAgentInfo as z };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
13
|
* - user-agent-parser: parseUserAgent
|
|
14
14
|
* - cache-control-builder: buildCacheControl
|
|
15
|
+
* - referrer-policy-builder: buildReferrerPolicy
|
|
15
16
|
* - ipv6-compressor: parseIpv6Address
|
|
16
17
|
*/
|
|
17
18
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
@@ -292,6 +293,32 @@ interface CacheControlResult {
|
|
|
292
293
|
declare function buildCacheControl(options?: CacheControlOptions): CacheControlResult | {
|
|
293
294
|
error: string;
|
|
294
295
|
};
|
|
296
|
+
type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
297
|
+
interface ReferrerPolicyEntry {
|
|
298
|
+
value: ReferrerPolicyValue;
|
|
299
|
+
explanation: string;
|
|
300
|
+
leaksPathAndQuery: boolean;
|
|
301
|
+
sentOnDowngrade: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface ReferrerPolicyResult {
|
|
304
|
+
header: string;
|
|
305
|
+
headerName: 'Referrer-Policy';
|
|
306
|
+
snippet: string;
|
|
307
|
+
metaTag: string;
|
|
308
|
+
policies: ReferrerPolicyEntry[];
|
|
309
|
+
warnings: string[];
|
|
310
|
+
}
|
|
311
|
+
declare const REFERRER_POLICY_VALUES: ReferrerPolicyValue[];
|
|
312
|
+
/**
|
|
313
|
+
* Build a `Referrer-Policy` header value from one or more policy tokens
|
|
314
|
+
* (a fallback chain: a browser that doesn't recognize an earlier token
|
|
315
|
+
* falls through to the next one, per the Referrer Policy spec), with a
|
|
316
|
+
* plain-English explanation of each token and warnings for risky choices.
|
|
317
|
+
* Pure string assembly and lookup; it never inspects real request traffic.
|
|
318
|
+
*/
|
|
319
|
+
declare function buildReferrerPolicy(policies: string | string[]): ReferrerPolicyResult | {
|
|
320
|
+
error: string;
|
|
321
|
+
};
|
|
295
322
|
type Ipv6AddressType = 'unspecified' | 'loopback' | 'link-local' | 'unique-local' | 'multicast' | 'ipv4-mapped' | 'documentation' | 'global-unicast';
|
|
296
323
|
interface Ipv6ParseResult {
|
|
297
324
|
expanded: string;
|
|
@@ -328,6 +355,10 @@ type network_Ipv6AddressType = Ipv6AddressType;
|
|
|
328
355
|
type network_Ipv6ParseResult = Ipv6ParseResult;
|
|
329
356
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
330
357
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
358
|
+
declare const network_REFERRER_POLICY_VALUES: typeof REFERRER_POLICY_VALUES;
|
|
359
|
+
type network_ReferrerPolicyEntry = ReferrerPolicyEntry;
|
|
360
|
+
type network_ReferrerPolicyResult = ReferrerPolicyResult;
|
|
361
|
+
type network_ReferrerPolicyValue = ReferrerPolicyValue;
|
|
331
362
|
type network_RobotsGroup = RobotsGroup;
|
|
332
363
|
type network_RobotsIssue = RobotsIssue;
|
|
333
364
|
type network_RobotsRule = RobotsRule;
|
|
@@ -344,6 +375,7 @@ declare const network_buildCacheControl: typeof buildCacheControl;
|
|
|
344
375
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
345
376
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
346
377
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
378
|
+
declare const network_buildReferrerPolicy: typeof buildReferrerPolicy;
|
|
347
379
|
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
348
380
|
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
349
381
|
declare const network_formatTtl: typeof formatTtl;
|
|
@@ -373,7 +405,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
373
405
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
374
406
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
375
407
|
declare namespace network {
|
|
376
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
408
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, type network_ReferrerPolicyEntry as ReferrerPolicyEntry, type network_ReferrerPolicyResult as ReferrerPolicyResult, type network_ReferrerPolicyValue as ReferrerPolicyValue, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
377
409
|
}
|
|
378
410
|
|
|
379
|
-
export {
|
|
411
|
+
export { isValidIpv6 as $, buildCacheControl as A, buildDnsQueryUrl as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, buildGeoUrl as E, buildMapUrl as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, buildReferrerPolicy as J, countryCodeToFlag as K, formatCoordinates as L, formatTtl as M, getByCategory as N, getHeader as O, type ParsedDnsResult as P, getHeadersByCategory as Q, REFERRER_POLICY_VALUES as R, STATUS_CODES as S, getStatusByCategory as T, type UaDeviceType as U, getStatusCode as V, isClientError as W, isServerError as X, isSuccess as Y, isValidIp as Z, isValidIpv4 as _, type CacheControlOptions as a, parseDnsResponse as a0, parseGeoResponse as a1, parseHar as a2, parseIpv6Address as a3, parseUserAgent as a4, searchHeaders as a5, searchStatusCodes as a6, statusCodeToText as a7, typeNumberToLabel as a8, validateDomain as a9, validateHeaderName as aa, validateHeaderValue as ab, validateRobotsTxt as ac, validateSitemap as ad, type CacheControlResult as b, type DnsRecord as c, type DnsRecordType as d, type DnsResponse as e, type HarEntry as f, type HarParseResult as g, type HarSummary as h, type HeaderCategory as i, type HttpHeader as j, type Ipv6ParseResult as k, type ParsedGeoResult as l, type ReferrerPolicyEntry as m, network as n, type ReferrerPolicyResult as o, type ReferrerPolicyValue as p, type RobotsGroup as q, type RobotsIssue as r, type RobotsRule as s, type RobotsValidationResult as t, type SitemapIndexEntry as u, type SitemapIssue as v, type SitemapUrlEntry as w, type SitemapValidationResult as x, type StatusCode as y, type UserAgentInfo as z };
|
package/dist/tools/data.cjs
CHANGED
|
@@ -1373,6 +1373,67 @@ function parseFrontMatter(input) {
|
|
|
1373
1373
|
}
|
|
1374
1374
|
return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
|
|
1375
1375
|
}
|
|
1376
|
+
function stripInlineMarkdown(text) {
|
|
1377
|
+
return text.replace(/(\*\*\*|___)(.+?)\1/g, "$2").replace(/(\*\*|__)(.+?)\1/g, "$2").replace(/(\*|_)(.+?)\1/g, "$2").replace(/`([^`]+)`/g, "$1").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").trim();
|
|
1378
|
+
}
|
|
1379
|
+
function slugifyHeading(text, seen) {
|
|
1380
|
+
let slug = text.toLowerCase().trim().replace(/[^\p{L}\p{N}\s_-]/gu, "").replace(/\s/g, "-");
|
|
1381
|
+
const count = seen.get(slug) ?? 0;
|
|
1382
|
+
seen.set(slug, count + 1);
|
|
1383
|
+
if (count > 0) slug = `${slug}-${count}`;
|
|
1384
|
+
return slug;
|
|
1385
|
+
}
|
|
1386
|
+
function generateMarkdownToc(markdown, options = {}) {
|
|
1387
|
+
if (typeof markdown !== "string" || markdown.trim() === "") {
|
|
1388
|
+
return { error: "markdown is required" };
|
|
1389
|
+
}
|
|
1390
|
+
const minLevel = options.minLevel ?? 1;
|
|
1391
|
+
const maxLevel = options.maxLevel ?? 6;
|
|
1392
|
+
if (!Number.isInteger(minLevel) || !Number.isInteger(maxLevel) || minLevel < 1 || minLevel > 6 || maxLevel < 1 || maxLevel > 6 || minLevel > maxLevel) {
|
|
1393
|
+
return { error: "minLevel and maxLevel must be integers between 1 and 6, with minLevel <= maxLevel" };
|
|
1394
|
+
}
|
|
1395
|
+
const lines = markdown.replace(/\r\n/g, "\n").split("\n");
|
|
1396
|
+
const entries = [];
|
|
1397
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1398
|
+
let inFence = false;
|
|
1399
|
+
let fenceMarker = "";
|
|
1400
|
+
for (const line of lines) {
|
|
1401
|
+
const fenceMatch = line.match(/^\s*(```+|~~~+)/);
|
|
1402
|
+
if (fenceMatch) {
|
|
1403
|
+
if (!inFence) {
|
|
1404
|
+
inFence = true;
|
|
1405
|
+
fenceMarker = fenceMatch[1][0];
|
|
1406
|
+
} else if (fenceMatch[1][0] === fenceMarker) {
|
|
1407
|
+
inFence = false;
|
|
1408
|
+
}
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
if (inFence) continue;
|
|
1412
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
1413
|
+
if (!headingMatch) continue;
|
|
1414
|
+
const level = headingMatch[1].length;
|
|
1415
|
+
const text = stripInlineMarkdown(headingMatch[2]);
|
|
1416
|
+
if (text === "") continue;
|
|
1417
|
+
const slug = slugifyHeading(text, seen);
|
|
1418
|
+
if (level < minLevel || level > maxLevel) continue;
|
|
1419
|
+
entries.push({ level, text, slug });
|
|
1420
|
+
}
|
|
1421
|
+
if (entries.length === 0) {
|
|
1422
|
+
return { error: "No headings found in the given level range" };
|
|
1423
|
+
}
|
|
1424
|
+
const baseLevel = Math.min(...entries.map((e) => e.level));
|
|
1425
|
+
const counters = [0, 0, 0, 0, 0, 0, 0];
|
|
1426
|
+
const tocLines = entries.map((e) => {
|
|
1427
|
+
const indent = " ".repeat(e.level - baseLevel);
|
|
1428
|
+
if (options.ordered) {
|
|
1429
|
+
counters[e.level] = (counters[e.level] ?? 0) + 1;
|
|
1430
|
+
for (let l = e.level + 1; l < counters.length; l++) counters[l] = 0;
|
|
1431
|
+
return `${indent}${counters[e.level]}. [${e.text}](#${e.slug})`;
|
|
1432
|
+
}
|
|
1433
|
+
return `${indent}- [${e.text}](#${e.slug})`;
|
|
1434
|
+
});
|
|
1435
|
+
return { toc: tocLines.join("\n"), entries };
|
|
1436
|
+
}
|
|
1376
1437
|
|
|
1377
1438
|
exports.convertSubtitles = convertSubtitles;
|
|
1378
1439
|
exports.csvToJson = csvToJson;
|
|
@@ -1385,6 +1446,7 @@ exports.formatNdjson = formatNdjson;
|
|
|
1385
1446
|
exports.formatSubtitleTimestamp = formatSubtitleTimestamp;
|
|
1386
1447
|
exports.formatToml = formatToml;
|
|
1387
1448
|
exports.formatXml = formatXml;
|
|
1449
|
+
exports.generateMarkdownToc = generateMarkdownToc;
|
|
1388
1450
|
exports.getSection = getSection;
|
|
1389
1451
|
exports.getSectionNames = getSectionNames;
|
|
1390
1452
|
exports.getTomlStats = getTomlStats;
|
package/dist/tools/data.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, F as FrontMatterError, f as FrontMatterResult, I as IniSection, N as NdjsonLineResult,
|
|
1
|
+
export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, F as FrontMatterError, f as FrontMatterResult, I as IniSection, M as MarkdownTocEntry, g as MarkdownTocOptions, h as MarkdownTocResult, N as NdjsonLineResult, i as NdjsonValidateResult, P as ParseOptions, j as ParsedIni, k as ParsedSubtitles, S as SubtitleCue, l as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, m as XmlToJsonOptions, n as convertSubtitles, o as csvToJson, p as detectDelimiter, q as detectSubtitleFormat, r as diffEnvExample, s as envToExport, t as envToJson, u as formatNdjson, v as formatSubtitleTimestamp, w as formatToml, x as formatXml, y as generateMarkdownToc, z as getSection, A as getSectionNames, B as getTomlStats, D as getXmlStats, G as getYamlStats, H as iniToJson, J as jsonArrayToNdjson, K as jsonToIni, L as jsonToToml, O as jsonToXml, Q as minifyNdjson, R as minifyToml, U as minifyXml, W as ndjsonToJsonArray, Y as parseCsv, Z as parseEnv, _ as parseFrontMatter, $ as parseIni, a0 as parseSubtitleTimestamp, a1 as parseSubtitles, a2 as parseXmlToObject, a3 as serializeSubtitles, a4 as shiftSubtitles, a5 as stringifyIni, a6 as toCsvString, a7 as tomlToJson, a8 as validateEnvKey, a9 as validateIni, aa as validateNdjson, ab as validateToml, ac as validateXml, ad as validateYaml, ae as xmlToJson } from '../data-CFeS9kes.cjs';
|
package/dist/tools/data.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, F as FrontMatterError, f as FrontMatterResult, I as IniSection, N as NdjsonLineResult,
|
|
1
|
+
export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, F as FrontMatterError, f as FrontMatterResult, I as IniSection, M as MarkdownTocEntry, g as MarkdownTocOptions, h as MarkdownTocResult, N as NdjsonLineResult, i as NdjsonValidateResult, P as ParseOptions, j as ParsedIni, k as ParsedSubtitles, S as SubtitleCue, l as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, m as XmlToJsonOptions, n as convertSubtitles, o as csvToJson, p as detectDelimiter, q as detectSubtitleFormat, r as diffEnvExample, s as envToExport, t as envToJson, u as formatNdjson, v as formatSubtitleTimestamp, w as formatToml, x as formatXml, y as generateMarkdownToc, z as getSection, A as getSectionNames, B as getTomlStats, D as getXmlStats, G as getYamlStats, H as iniToJson, J as jsonArrayToNdjson, K as jsonToIni, L as jsonToToml, O as jsonToXml, Q as minifyNdjson, R as minifyToml, U as minifyXml, W as ndjsonToJsonArray, Y as parseCsv, Z as parseEnv, _ as parseFrontMatter, $ as parseIni, a0 as parseSubtitleTimestamp, a1 as parseSubtitles, a2 as parseXmlToObject, a3 as serializeSubtitles, a4 as shiftSubtitles, a5 as stringifyIni, a6 as toCsvString, a7 as tomlToJson, a8 as validateEnvKey, a9 as validateIni, aa as validateNdjson, ab as validateToml, ac as validateXml, ad as validateYaml, ae as xmlToJson } from '../data-CFeS9kes.js';
|
package/dist/tools/data.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { convertSubtitles, csvToJson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson } from '../chunk-
|
|
1
|
+
export { convertSubtitles, csvToJson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, generateMarkdownToc, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson } from '../chunk-YEXQDI3J.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/network.cjs
CHANGED
|
@@ -1777,6 +1777,84 @@ function buildCacheControl(options = {}) {
|
|
|
1777
1777
|
const snippet = `Cache-Control: ${header}`;
|
|
1778
1778
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
1779
1779
|
}
|
|
1780
|
+
var REFERRER_POLICY_VALUES = [
|
|
1781
|
+
"no-referrer",
|
|
1782
|
+
"no-referrer-when-downgrade",
|
|
1783
|
+
"origin",
|
|
1784
|
+
"origin-when-cross-origin",
|
|
1785
|
+
"same-origin",
|
|
1786
|
+
"strict-origin",
|
|
1787
|
+
"strict-origin-when-cross-origin",
|
|
1788
|
+
"unsafe-url"
|
|
1789
|
+
];
|
|
1790
|
+
var _REFERRER_POLICY_INFO = {
|
|
1791
|
+
"no-referrer": {
|
|
1792
|
+
explanation: "Never sends the Referer header, on any request. The strictest option; the destination learns nothing about where the request came from.",
|
|
1793
|
+
leaksPathAndQuery: false,
|
|
1794
|
+
sentOnDowngrade: false
|
|
1795
|
+
},
|
|
1796
|
+
"no-referrer-when-downgrade": {
|
|
1797
|
+
explanation: "Sends the full URL (origin, path, and query string) for same-security-level or upgrading requests, but omits the header entirely when navigating from HTTPS to HTTP. This was the legacy browser default before strict-origin-when-cross-origin.",
|
|
1798
|
+
leaksPathAndQuery: true,
|
|
1799
|
+
sentOnDowngrade: false
|
|
1800
|
+
},
|
|
1801
|
+
origin: {
|
|
1802
|
+
explanation: "Sends only the origin (scheme, host, and port) on every request, same-origin or cross-origin, including on a downgrade. The path and query string are always stripped.",
|
|
1803
|
+
leaksPathAndQuery: false,
|
|
1804
|
+
sentOnDowngrade: true
|
|
1805
|
+
},
|
|
1806
|
+
"origin-when-cross-origin": {
|
|
1807
|
+
explanation: "Sends the full URL for same-origin requests, but only the origin for cross-origin requests. Still sends the origin on a downgrade.",
|
|
1808
|
+
leaksPathAndQuery: true,
|
|
1809
|
+
sentOnDowngrade: true
|
|
1810
|
+
},
|
|
1811
|
+
"same-origin": {
|
|
1812
|
+
explanation: "Sends the full URL for same-origin requests, and no Referer header at all for cross-origin requests.",
|
|
1813
|
+
leaksPathAndQuery: true,
|
|
1814
|
+
sentOnDowngrade: false
|
|
1815
|
+
},
|
|
1816
|
+
"strict-origin": {
|
|
1817
|
+
explanation: "Sends only the origin, and only when the security level stays the same or improves (HTTPS to HTTPS, or HTTP to anything). Nothing is sent on a downgrade from HTTPS to HTTP.",
|
|
1818
|
+
leaksPathAndQuery: false,
|
|
1819
|
+
sentOnDowngrade: false
|
|
1820
|
+
},
|
|
1821
|
+
"strict-origin-when-cross-origin": {
|
|
1822
|
+
explanation: "Sends the full URL for same-origin requests, only the origin for cross-origin requests at the same or better security level, and nothing at all on a downgrade. This is the current browser default when no policy is set.",
|
|
1823
|
+
leaksPathAndQuery: true,
|
|
1824
|
+
sentOnDowngrade: false
|
|
1825
|
+
},
|
|
1826
|
+
"unsafe-url": {
|
|
1827
|
+
explanation: "Always sends the full URL, including path and query string, on every request, even on a downgrade from HTTPS to HTTP. Generally discouraged: query strings can carry session tokens or other sensitive data that then leaks to third-party destinations and to the network on an insecure connection.",
|
|
1828
|
+
leaksPathAndQuery: true,
|
|
1829
|
+
sentOnDowngrade: true
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
function buildReferrerPolicy(policies) {
|
|
1833
|
+
const list = Array.isArray(policies) ? policies : [policies];
|
|
1834
|
+
const trimmed = list.map((p) => typeof p === "string" ? p.trim() : "").filter((p) => p !== "");
|
|
1835
|
+
if (trimmed.length === 0) {
|
|
1836
|
+
return { error: "At least one policy value is required" };
|
|
1837
|
+
}
|
|
1838
|
+
const entries = [];
|
|
1839
|
+
for (const value of trimmed) {
|
|
1840
|
+
if (!REFERRER_POLICY_VALUES.includes(value)) {
|
|
1841
|
+
return { error: `'${value}' is not a valid Referrer-Policy value. Valid values: ${REFERRER_POLICY_VALUES.join(", ")}` };
|
|
1842
|
+
}
|
|
1843
|
+
entries.push({ value, ..._REFERRER_POLICY_INFO[value] });
|
|
1844
|
+
}
|
|
1845
|
+
const warnings = [];
|
|
1846
|
+
const last = entries[entries.length - 1];
|
|
1847
|
+
if (last.value === "unsafe-url") {
|
|
1848
|
+
warnings.push("unsafe-url sends the full URL, including query strings, on every request, even over an insecure downgrade. Prefer strict-origin-when-cross-origin unless you have a specific reason to leak full URLs.");
|
|
1849
|
+
}
|
|
1850
|
+
if (entries.length > 1 && entries.some((e, i) => i !== entries.length - 1 && e.value === last.value)) {
|
|
1851
|
+
warnings.push("The same policy value appears more than once in the fallback chain, which has no effect beyond the first occurrence.");
|
|
1852
|
+
}
|
|
1853
|
+
const header = entries.map((e) => e.value).join(", ");
|
|
1854
|
+
const snippet = `Referrer-Policy: ${header}`;
|
|
1855
|
+
const metaTag = `<meta name="referrer" content="${last.value}">`;
|
|
1856
|
+
return { header, headerName: "Referrer-Policy", snippet, metaTag, policies: entries, warnings };
|
|
1857
|
+
}
|
|
1780
1858
|
function isValidIpv6HexGroup(g) {
|
|
1781
1859
|
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
1782
1860
|
}
|
|
@@ -1868,11 +1946,13 @@ function parseIpv6Address(input) {
|
|
|
1868
1946
|
|
|
1869
1947
|
exports.DNS_RECORD_TYPES = DNS_RECORD_TYPES;
|
|
1870
1948
|
exports.HTTP_HEADERS = HTTP_HEADERS;
|
|
1949
|
+
exports.REFERRER_POLICY_VALUES = REFERRER_POLICY_VALUES;
|
|
1871
1950
|
exports.STATUS_CODES = STATUS_CODES;
|
|
1872
1951
|
exports.buildCacheControl = buildCacheControl;
|
|
1873
1952
|
exports.buildDnsQueryUrl = buildDnsQueryUrl;
|
|
1874
1953
|
exports.buildGeoUrl = buildGeoUrl;
|
|
1875
1954
|
exports.buildMapUrl = buildMapUrl;
|
|
1955
|
+
exports.buildReferrerPolicy = buildReferrerPolicy;
|
|
1876
1956
|
exports.countryCodeToFlag = countryCodeToFlag;
|
|
1877
1957
|
exports.formatCoordinates = formatCoordinates;
|
|
1878
1958
|
exports.formatTtl = formatTtl;
|
package/dist/tools/network.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as REFERRER_POLICY_VALUES, m as ReferrerPolicyEntry, o as ReferrerPolicyResult, p as ReferrerPolicyValue, q as RobotsGroup, r as RobotsIssue, s as RobotsRule, t as RobotsValidationResult, S as STATUS_CODES, u as SitemapIndexEntry, v as SitemapIssue, w as SitemapUrlEntry, x as SitemapValidationResult, y as StatusCode, U as UaDeviceType, z as UserAgentInfo, A as buildCacheControl, B as buildDnsQueryUrl, E as buildGeoUrl, F as buildMapUrl, J as buildReferrerPolicy, K as countryCodeToFlag, L as formatCoordinates, M as formatTtl, N as getByCategory, O as getHeader, Q as getHeadersByCategory, T as getStatusByCategory, V as getStatusCode, W as isClientError, X as isServerError, Y as isSuccess, Z as isValidIp, _ as isValidIpv4, $ as isValidIpv6, a0 as parseDnsResponse, a1 as parseGeoResponse, a2 as parseHar, a3 as parseIpv6Address, a4 as parseUserAgent, a5 as searchHeaders, a6 as searchStatusCodes, a7 as statusCodeToText, a8 as typeNumberToLabel, a9 as validateDomain, aa as validateHeaderName, ab as validateHeaderValue, ac as validateRobotsTxt, ad as validateSitemap } from '../network-DfY5Ikvr.cjs';
|
package/dist/tools/network.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as REFERRER_POLICY_VALUES, m as ReferrerPolicyEntry, o as ReferrerPolicyResult, p as ReferrerPolicyValue, q as RobotsGroup, r as RobotsIssue, s as RobotsRule, t as RobotsValidationResult, S as STATUS_CODES, u as SitemapIndexEntry, v as SitemapIssue, w as SitemapUrlEntry, x as SitemapValidationResult, y as StatusCode, U as UaDeviceType, z as UserAgentInfo, A as buildCacheControl, B as buildDnsQueryUrl, E as buildGeoUrl, F as buildMapUrl, J as buildReferrerPolicy, K as countryCodeToFlag, L as formatCoordinates, M as formatTtl, N as getByCategory, O as getHeader, Q as getHeadersByCategory, T as getStatusByCategory, V as getStatusCode, W as isClientError, X as isServerError, Y as isSuccess, Z as isValidIp, _ as isValidIpv4, $ as isValidIpv6, a0 as parseDnsResponse, a1 as parseGeoResponse, a2 as parseHar, a3 as parseIpv6Address, a4 as parseUserAgent, a5 as searchHeaders, a6 as searchStatusCodes, a7 as statusCodeToText, a8 as typeNumberToLabel, a9 as validateDomain, aa as validateHeaderName, ab as validateHeaderValue, ac as validateRobotsTxt, ad as validateSitemap } from '../network-DfY5Ikvr.js';
|
package/dist/tools/network.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-
|
|
1
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, REFERRER_POLICY_VALUES, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, buildReferrerPolicy, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-3YUKLV5N.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "154+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
|
|
5
5
|
"author": "Utilix <hello@utilix.tech>",
|
|
6
6
|
"license": "MIT",
|