1 | var __create = Object.create;
|
2 | var __defProp = Object.defineProperty;
|
3 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 | var __getProtoOf = Object.getPrototypeOf;
|
6 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7 | var __export = (target, all) => {
|
8 | for (var name in all)
|
9 | __defProp(target, name, { get: all[name], enumerable: true });
|
10 | };
|
11 | var __copyProps = (to, from, except, desc) => {
|
12 | if (from && typeof from === "object" || typeof from === "function") {
|
13 | for (let key of __getOwnPropNames(from))
|
14 | if (!__hasOwnProp.call(to, key) && key !== except)
|
15 | __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 | }
|
17 | return to;
|
18 | };
|
19 | var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25 | mod
|
26 | ));
|
27 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28 | var stdin_exports = {};
|
29 | __export(stdin_exports, {
|
30 | SVG_PATH_REGEX: () => SVG_PATH_REGEX,
|
31 | URL_REGEX: () => URL_REGEX,
|
32 | collator: () => collator,
|
33 | getDirnameFromImportMeta: () => getDirnameFromImportMeta,
|
34 | getIconDataPath: () => getIconDataPath,
|
35 | getIconSlug: () => getIconSlug,
|
36 | getIconsData: () => getIconsData,
|
37 | getIconsDataString: () => getIconsDataString,
|
38 | getThirdPartyExtensions: () => getThirdPartyExtensions,
|
39 | htmlFriendlyToTitle: () => htmlFriendlyToTitle,
|
40 | normalizeColor: () => normalizeColor,
|
41 | normalizeNewlines: () => normalizeNewlines,
|
42 | slugToVariableName: () => slugToVariableName,
|
43 | svgToPath: () => svgToPath,
|
44 | titleToHtmlFriendly: () => titleToHtmlFriendly,
|
45 | titleToSlug: () => titleToSlug
|
46 | });
|
47 | module.exports = __toCommonJS(stdin_exports);
|
48 | var import_promises = __toESM(require("node:fs/promises"));
|
49 | var import_node_path = __toESM(require("node:path"));
|
50 | var import_node_url = require("node:url");
|
51 | const import_meta = {};
|
52 | const TITLE_TO_SLUG_REPLACEMENTS = {
|
53 | "+": "plus",
|
54 | ".": "dot",
|
55 | "&": "and",
|
56 | \u0111: "d",
|
57 | \u0127: "h",
|
58 | \u0131: "i",
|
59 | \u0138: "k",
|
60 | \u0140: "l",
|
61 | \u0142: "l",
|
62 | \u00DF: "ss",
|
63 | \u0167: "t"
|
64 | };
|
65 | const TITLE_TO_SLUG_CHARS_REGEX = new RegExp(
|
66 | `[${Object.keys(TITLE_TO_SLUG_REPLACEMENTS).join("")}]`,
|
67 | "g"
|
68 | );
|
69 | const TITLE_TO_SLUG_RANGE_REGEX = /[^a-z\d]/g;
|
70 | const URL_REGEX = /^https:\/\/[^\s"']+$/;
|
71 | const SVG_PATH_REGEX = /^m[-mzlhvcsqtae\d,. ]+$/i;
|
72 | const getDirnameFromImportMeta = (importMetaUrl) => import_node_path.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
73 | const getIconSlug = (icon) => icon.slug || titleToSlug(icon.title);
|
74 | const svgToPath = (svg) => svg.split('"', 8)[7];
|
75 | const titleToSlug = (title) => title.toLowerCase().replaceAll(
|
76 | TITLE_TO_SLUG_CHARS_REGEX,
|
77 | (char) => TITLE_TO_SLUG_REPLACEMENTS[char]
|
78 | ).normalize("NFD").replaceAll(TITLE_TO_SLUG_RANGE_REGEX, "");
|
79 | const slugToVariableName = (slug) => {
|
80 | const slugFirstLetter = slug[0].toUpperCase();
|
81 | return `si${slugFirstLetter}${slug.slice(1)}`;
|
82 | };
|
83 | const titleToHtmlFriendly = (brandTitle) => brandTitle.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">").replaceAll(/./g, (char) => {
|
84 | const charCode = char.codePointAt(0);
|
85 | return charCode > 127 ? `&#${charCode};` : char;
|
86 | });
|
87 | const htmlFriendlyToTitle = (htmlFriendlyTitle) => htmlFriendlyTitle.replaceAll(
|
88 | /&#(\d+);/g,
|
89 | (_, number_) => String.fromCodePoint(Number.parseInt(number_, 10))
|
90 | ).replaceAll(
|
91 | /&(quot|amp|lt|gt);/g,
|
92 | (_, reference) => ({ quot: '"', amp: "&", lt: "<", gt: ">" })[reference]
|
93 | );
|
94 | const getIconDataPath = (rootDirectory = getDirnameFromImportMeta(import_meta.url)) => {
|
95 | return import_node_path.default.resolve(rootDirectory, "_data", "simple-icons.json");
|
96 | };
|
97 | const getIconsDataString = (rootDirectory = getDirnameFromImportMeta(import_meta.url)) => {
|
98 | return import_promises.default.readFile(getIconDataPath(rootDirectory), "utf8");
|
99 | };
|
100 | const getIconsData = async (rootDirectory = getDirnameFromImportMeta(import_meta.url)) => {
|
101 | const fileContents = await getIconsDataString(rootDirectory);
|
102 | return JSON.parse(fileContents).icons;
|
103 | };
|
104 | const normalizeNewlines = (text) => {
|
105 | return text.replaceAll("\r\n", "\n");
|
106 | };
|
107 | const normalizeColor = (text) => {
|
108 | let color = text.replace("#", "").toUpperCase();
|
109 | if (color.length < 6) {
|
110 | color = [...color.slice(0, 3)].map((x) => x.repeat(2)).join("");
|
111 | } else if (color.length > 6) {
|
112 | color = color.slice(0, 6);
|
113 | }
|
114 | return color;
|
115 | };
|
116 | const getThirdPartyExtensions = async (readmePath = import_node_path.default.join(
|
117 | getDirnameFromImportMeta(import_meta.url),
|
118 | "README.md"
|
119 | )) => normalizeNewlines(await import_promises.default.readFile(readmePath, "utf8")).split("## Third-Party Extensions\n\n")[1].split("\n\n", 1)[0].split("\n").slice(2).map((line) => {
|
120 | let [module2, author] = line.split(" | ");
|
121 | module2 = module2.split('<img src="')[0];
|
122 | return {
|
123 | module: {
|
124 | name: /\[(.+)]/.exec(module2)[1],
|
125 | url: /\((.+)\)/.exec(module2)[1]
|
126 | },
|
127 | author: {
|
128 | name: /\[(.+)]/.exec(author)[1],
|
129 | url: /\((.+)\)/.exec(author)[1]
|
130 | }
|
131 | };
|
132 | });
|
133 | const collator = new Intl.Collator("en", {
|
134 | usage: "search",
|
135 | caseFirst: "upper"
|
136 | });
|