ssqch 0.7.1 → 0.9.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.
Files changed (155) hide show
  1. package/README.md +8 -4
  2. package/bin/ssqch.js +14 -48
  3. package/bundled/README.md +1314 -0
  4. package/bundled/completions/bash +840 -0
  5. package/bundled/completions/elvish +286 -0
  6. package/bundled/completions/fish +182 -0
  7. package/bundled/completions/powershell +318 -0
  8. package/bundled/completions/zsh +510 -0
  9. package/bundled/ssqch.d.ts +540 -0
  10. package/bundled/starter/engines/index.edge +11 -0
  11. package/bundled/starter/engines/index.ejs +11 -0
  12. package/bundled/starter/engines/index.hbs +11 -0
  13. package/bundled/starter/engines/index.liquid +11 -0
  14. package/bundled/starter/engines/layout.edge +35 -0
  15. package/bundled/starter/engines/layout.ejs +35 -0
  16. package/bundled/starter/engines/layout.hbs +35 -0
  17. package/bundled/starter/engines/layout.liquid +35 -0
  18. package/bundled/starter/gitignore +3 -0
  19. package/bundled/starter/jsconfig.json +11 -0
  20. package/bundled/starter/src/404.md +8 -0
  21. package/bundled/starter/src/_blueprints/posts.md +5 -0
  22. package/bundled/starter/src/_data/site.json +4 -0
  23. package/bundled/starter/src/_includes/layout.jinja +35 -0
  24. package/bundled/starter/src/index.jinja +11 -0
  25. package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
  26. package/bundled/starter/src/posts/posts.json +4 -0
  27. package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
  28. package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
  29. package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
  30. package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
  31. package/bundled/starter/ssqch.config.js +29 -0
  32. package/bundled/starter-docs/engines/edge/base.edge +41 -0
  33. package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
  34. package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
  35. package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
  36. package/bundled/starter-docs/engines/edge/doc.edge +59 -0
  37. package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
  38. package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
  39. package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
  40. package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
  41. package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
  42. package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
  43. package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
  44. package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
  45. package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
  46. package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
  47. package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
  48. package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
  49. package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
  50. package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
  51. package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
  52. package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
  55. package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
  56. package/bundled/starter-docs/gitignore +4 -0
  57. package/bundled/starter-docs/src/404.md +12 -0
  58. package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
  59. package/bundled/starter-docs/src/_data/nav.yml +10 -0
  60. package/bundled/starter-docs/src/_data/site.json +5 -0
  61. package/bundled/starter-docs/src/_includes/base.jinja +41 -0
  62. package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
  63. package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
  64. package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
  65. package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
  66. package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
  67. package/bundled/starter-docs/src/assets/docs.css +257 -0
  68. package/bundled/starter-docs/src/assets/docs.js +67 -0
  69. package/bundled/starter-docs/src/docs/docs.json +1 -0
  70. package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
  71. package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
  72. package/bundled/starter-docs/src/docs/index.md +29 -0
  73. package/bundled/starter-docs/src/docs/install.md +42 -0
  74. package/bundled/starter-docs/src/index.md +13 -0
  75. package/bundled/starter-docs/ssqch.config.js +40 -0
  76. package/bundled/trailheads/from-component-frameworks.md +116 -0
  77. package/bundled/trailheads/from-docusaurus.md +55 -0
  78. package/bundled/trailheads/from-eleventy.md +140 -0
  79. package/bundled/trailheads/from-hexo.md +92 -0
  80. package/bundled/trailheads/from-jekyll.md +79 -0
  81. package/bundled/trailheads/from-mkdocs.md +45 -0
  82. package/bundled/trailheads/from-zola.md +71 -0
  83. package/lib/assets.js +235 -3
  84. package/lib/chunk-3A647I3N.js +384 -0
  85. package/lib/chunk-3GYLOC6Y.js +1017 -0
  86. package/lib/chunk-3K3ANWZ2.js +118 -0
  87. package/lib/chunk-3NYSSA2C.js +22 -0
  88. package/lib/chunk-47P4YREZ.js +1287 -0
  89. package/lib/chunk-4Q6WMTER.js +32 -0
  90. package/lib/chunk-76NTVE34.js +338 -0
  91. package/lib/chunk-7PWCYHTJ.js +1350 -0
  92. package/lib/chunk-7RDRZHJD.js +217 -0
  93. package/lib/chunk-7SD7K567.js +57 -0
  94. package/lib/chunk-7XLK2GEG.js +54 -0
  95. package/lib/chunk-AD3HAW3W.js +10 -0
  96. package/lib/chunk-BEGC7YP6.js +502 -0
  97. package/lib/chunk-CMUWRPSQ.js +113 -0
  98. package/lib/chunk-CZ4XQC56.js +999 -0
  99. package/lib/chunk-D2XE2GTY.js +71 -0
  100. package/lib/chunk-DDV6JEC2.js +46 -0
  101. package/lib/chunk-DELWRJAO.js +37409 -0
  102. package/lib/chunk-DELWRJAO.js.LEGAL.txt +27 -0
  103. package/lib/chunk-F65YUXZ7.js +334 -0
  104. package/lib/chunk-FVZ5JBRI.js +115 -0
  105. package/lib/chunk-GRWMGC7D.js +4435 -0
  106. package/lib/chunk-GRWMGC7D.js.LEGAL.txt +41 -0
  107. package/lib/chunk-GUKSZ2XM.js +207 -0
  108. package/lib/chunk-HPXAZ2HU.js +251 -0
  109. package/lib/chunk-HXCLCXRT.js +20 -0
  110. package/lib/chunk-I3PS26CI.js +48 -0
  111. package/lib/chunk-IAFM5ITE.js +11 -0
  112. package/lib/chunk-II5DEH3Q.js +209 -0
  113. package/lib/chunk-IJWHOFRP.js +44 -0
  114. package/lib/chunk-LPHNACE4.js +29 -0
  115. package/lib/chunk-MI6EJWA2.js +175 -0
  116. package/lib/chunk-NCWFYT74.js +1541 -0
  117. package/lib/chunk-NKXEPHRZ.js +136 -0
  118. package/lib/chunk-NNUKIGOO.js +160 -0
  119. package/lib/chunk-R7K3D5W5.js +3957 -0
  120. package/lib/chunk-RNJFPFXE.js +29 -0
  121. package/lib/chunk-SF4I6Z7S.js +25 -0
  122. package/lib/chunk-SURPOAW7.js +44 -0
  123. package/lib/chunk-SXMJ52IK.js +572 -0
  124. package/lib/chunk-TICWN55Z.js +20 -0
  125. package/lib/chunk-TVU3OPPK.js +146 -0
  126. package/lib/chunk-UU43WIZG.js +29 -0
  127. package/lib/chunk-VJWQSYEG.js +119 -0
  128. package/lib/chunk-XMXBHXZR.js +75 -0
  129. package/lib/chunk-YTHQBMDJ.js +211 -0
  130. package/lib/cli.js +547 -0
  131. package/lib/elements.js +180 -3
  132. package/lib/image.js +27 -3
  133. package/lib/links.js +464 -3
  134. package/lib/minify.js +69 -3
  135. package/lib/redirects.js +152 -3
  136. package/lib/rss.js +139 -3
  137. package/lib/sass.js +256 -3
  138. package/lib/sitemap.js +113 -3
  139. package/lib/ssqch.js +28 -0
  140. package/package.json +83 -80
  141. package/src/serve/live.js +174 -0
  142. package/src/serve/not-found.html +31 -0
  143. package/types/globals.d.ts +3 -2
  144. package/types/image.d.ts +7 -3
  145. package/types/index.d.ts +28 -9
  146. package/types/links.d.ts +1 -1
  147. package/types/minify.d.ts +1 -1
  148. package/types/rss.d.ts +1 -1
  149. package/types/sass.d.ts +1 -1
  150. package/types/sitemap.d.ts +2 -0
  151. package/wasm/markdown.wasm +0 -0
  152. package/wasm/minify.wasm +0 -0
  153. package/wasm/sass.wasm +0 -0
  154. package/lib/index.js +0 -3
  155. package/platforms.json +0 -6
@@ -0,0 +1,217 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ inspectPages
5
+ } from "./chunk-DELWRJAO.js";
6
+ import "./chunk-4Q6WMTER.js";
7
+ import "./chunk-3A647I3N.js";
8
+ import "./chunk-II5DEH3Q.js";
9
+ import "./chunk-R7K3D5W5.js";
10
+ import "./chunk-7XLK2GEG.js";
11
+ import "./chunk-NKXEPHRZ.js";
12
+ import "./chunk-AD3HAW3W.js";
13
+ import "./chunk-DDV6JEC2.js";
14
+ import "./chunk-NCWFYT74.js";
15
+ import "./chunk-FVZ5JBRI.js";
16
+ import "./chunk-HPXAZ2HU.js";
17
+ import "./chunk-UU43WIZG.js";
18
+ import "./chunk-76NTVE34.js";
19
+ import {
20
+ charCount,
21
+ firstChars,
22
+ jsString,
23
+ padEnd,
24
+ prettyJson,
25
+ quoted,
26
+ toJsonValue
27
+ } from "./chunk-CMUWRPSQ.js";
28
+ import {
29
+ bail,
30
+ getPath
31
+ } from "./chunk-GRWMGC7D.js";
32
+ import {
33
+ comparePaths,
34
+ compareText,
35
+ realPath,
36
+ shown
37
+ } from "./chunk-VJWQSYEG.js";
38
+ import "./chunk-I3PS26CI.js";
39
+
40
+ // src/inspect.ts
41
+ import fs from "node:fs";
42
+ import path from "node:path";
43
+ var has = (data, key) => data !== null && typeof data === "object" && Object.prototype.hasOwnProperty.call(data, key);
44
+ var nullish = (v) => v === void 0 || v === null;
45
+ function globalOrigin(config, dirs, key) {
46
+ if (key === "ssqch") return "built in";
47
+ if (config.globalData.some((d) => d.name === key)) return "the config's `data`";
48
+ for (const dir of [dirs.data, ...config.themes.map((theme) => path.join(theme, "_data"))]) {
49
+ let names;
50
+ try {
51
+ names = fs.readdirSync(dir);
52
+ } catch {
53
+ continue;
54
+ }
55
+ const files = names.map((name) => path.join(dir, name)).sort(comparePaths);
56
+ const found = files.find((file) => {
57
+ const name = path.basename(file);
58
+ return name === key || name.slice(0, name.length - path.extname(name).length) === key;
59
+ });
60
+ if (found !== void 0) return shown(dirs.root, found);
61
+ }
62
+ return "global data";
63
+ }
64
+ function fieldsOf(config, dirs, global, page) {
65
+ const computed = page.data.computed !== null && typeof page.data.computed === "object" && !Array.isArray(page.data.computed) ? page.data.computed : {};
66
+ const pagination = page.data.pagination;
67
+ const alias = pagination === void 0 ? "" : jsString(nullish(pagination) ? void 0 : pagination.alias);
68
+ const out = [];
69
+ for (const [name, value] of Object.entries(page.data)) {
70
+ let setBy = [];
71
+ if (has(global, name)) setBy.push({ from: globalOrigin(config, dirs, name), value: global[name] });
72
+ for (const [from, layer] of page.layers) {
73
+ if (name === "layout" && from.startsWith("layout ")) continue;
74
+ if (has(layer, name)) setBy.push({ from, value: layer[name] });
75
+ }
76
+ if (name === "page") setBy = [{ from: "built in", value }];
77
+ else if (has(computed, name)) setBy.push({ from: "computed", value });
78
+ else if (name === alias) setBy.push({ from: "pagination (its `alias`)", value });
79
+ else if (name === "pagination") setBy.push({ from: "pagination (this page's items and links)", value });
80
+ out.push({ name, value, from: setBy.length ? setBy[setBy.length - 1].from : "the build", setBy });
81
+ }
82
+ return out;
83
+ }
84
+ async function inspect(config, target) {
85
+ const { dirs, global, pages } = await inspectPages(config);
86
+ const trim = (u) => {
87
+ const rest = u.endsWith("index.html") ? u.slice(0, -10) : void 0;
88
+ return (rest !== void 0 && rest.endsWith("/") ? rest : u).replace(/\/+$/, "");
89
+ };
90
+ const exact = pages.filter((p) => p.url === target);
91
+ const byUrl = exact.length ? exact : pages.filter((p) => p.url !== null && trim(p.url) === trim(target));
92
+ const wanted = [path.resolve(dirs.root, target), path.resolve(dirs.input, target)].map(realPath);
93
+ const names = new Set(wanted.map((w) => path.basename(w)));
94
+ const byFile = pages.filter((p) => names.has(path.basename(p.input)) && wanted.includes(realPath(p.input)));
95
+ let page;
96
+ if (target.startsWith("/") && byUrl.length) page = byUrl[0];
97
+ else if (byFile.length === 1) page = byFile[0];
98
+ else if (byFile.length === 0) {
99
+ const parts = target.replace(/\/+$/, "").split("/");
100
+ const last = asciiLower(parts[parts.length - 1].replace(/(\.md)+$/, ""));
101
+ const near = pages.flatMap((p) => p.url !== null && last !== "" && asciiLower(p.url).includes(last) ? [p.url] : []).slice(0, 5).sort(compareText);
102
+ bail(`no page at ${quoted(target)} (give a URL like /about/, or a template's path; the site has ${pages.length} pages).${near.length ? ` Close: ${near.join(", ")}` : ""}`);
103
+ } else {
104
+ const urls = byFile.flatMap((p) => p.url === null ? [] : [p.url]).slice(0, 8);
105
+ bail(`${target} makes ${byFile.length} pages; give the URL of one: ${urls.join(", ")}${byFile.length > 8 ? ", ..." : ""}`);
106
+ }
107
+ const setIn = (key) => [...page.layers].reverse().find(([, layer]) => has(layer, key) && !nullish(layer[key]))?.[0];
108
+ const computedDate = has(page.data, "computed") && !nullish(getPath(page.data.computed, "date"));
109
+ const dateFrom = computedDate ? "computed" : setIn("date") ?? (page.dateFromName ? "the file's name" : "the file's modification time");
110
+ const collections = [];
111
+ if (page.inCollections) {
112
+ collections.push("all");
113
+ if (Array.isArray(page.data.tags)) collections.push(...page.data.tags.map(jsString));
114
+ }
115
+ return {
116
+ url: page.url,
117
+ inputPath: shown(dirs.root, page.input),
118
+ outputPath: page.output === null ? null : shown(dirs.root, page.output),
119
+ engines: page.engines,
120
+ layouts: page.layouts,
121
+ date: page.date.toISOString().replace(/\.\d{3}Z$/, "Z"),
122
+ dateFrom,
123
+ collections,
124
+ fields: fieldsOf(config, dirs, global, page)
125
+ };
126
+ }
127
+ var asciiLower = (text) => text.replace(/[A-Z]/g, (c) => c.toLowerCase());
128
+ function brief(value) {
129
+ if (typeof value === "string") return `${quoted(firstChars(value, 48))}${charCount(value) > 48 ? "\u2026" : ""}`;
130
+ if (Array.isArray(value)) return `[${value.length} item${value.length === 1 ? "" : "s"}]`;
131
+ if (typeof value === "function") return "a function";
132
+ if (value === void 0) return "undefined";
133
+ if (value !== null && typeof value === "object" && !(value instanceof Date)) {
134
+ const all = Object.keys(value);
135
+ const keys = [];
136
+ for (const key of all.slice(0, 4)) {
137
+ if (keys.reduce((sum, k) => sum + charCount(k) + 2, 0) + charCount(key) > 44) break;
138
+ keys.push(key);
139
+ }
140
+ if (!keys.length) return `{${all.length} key${all.length === 1 ? "" : "s"}}`;
141
+ return `{${keys.join(", ")}${all.length > keys.length ? ", \u2026" : ""}}`;
142
+ }
143
+ return jsString(value);
144
+ }
145
+ function valueAt(value, key) {
146
+ const index = /^\+?\d+$/.test(key) ? Number(key) : void 0;
147
+ if (Array.isArray(value)) return key === "length" ? value.length : index === void 0 ? void 0 : value[index];
148
+ if (typeof value === "string") return key === "length" ? value.length : index === void 0 ? void 0 : [...value][index];
149
+ if (value instanceof Date || typeof value === "function") return void 0;
150
+ return has(value, key) ? value[key] : void 0;
151
+ }
152
+ function field(inspection, dotted) {
153
+ const at = dotted.indexOf(".");
154
+ const [top, rest] = at === -1 ? [dotted, ""] : [dotted.slice(0, at), dotted.slice(at + 1)];
155
+ const found = inspection.fields.find((f) => f.name === top);
156
+ if (!found || rest === "") return found;
157
+ const pathIn = (v) => rest.split(".").reduce(valueAt, v);
158
+ const setBy = found.setBy.filter((s) => !nullish(pathIn(s.value))).map((s) => ({ from: s.from, value: pathIn(s.value) }));
159
+ return { name: dotted, value: pathIn(found.value), from: setBy.length ? setBy[setBy.length - 1].from : found.from, setBy };
160
+ }
161
+ function inspectionText(inspection) {
162
+ let out = `${inspection.url ?? "(no URL: permalink is false)"}
163
+ `;
164
+ const row = (label, value) => {
165
+ out += ` ${padEnd(label, 12)}${value}
166
+ `;
167
+ };
168
+ row("From", `${inspection.inputPath} (${inspection.engines.length ? inspection.engines.join(", ") : "as it is"})`);
169
+ if (inspection.outputPath !== null) row("Writes", inspection.outputPath);
170
+ if (inspection.layouts.length) row("Layouts", inspection.layouts.join(" > "));
171
+ row("Date", `${inspection.date} (from ${inspection.dateFrom})`);
172
+ row("Collections", inspection.collections.length ? inspection.collections.join(", ") : "none");
173
+ out += "\n Data (name, value, and the level of the cascade that set it)\n";
174
+ const width = Math.min(24, Math.max(0, ...inspection.fields.map((f) => charCount(f.name))));
175
+ for (const f of inspection.fields) {
176
+ const overrides = f.setBy.length > 1 ? ` (over ${f.setBy.slice(0, -1).map((s) => s.from).join(", ")})` : "";
177
+ out += ` ${padEnd(f.name, width)} ${padEnd(brief(f.value), 52)} ${f.from}${overrides}
178
+ `;
179
+ }
180
+ return out;
181
+ }
182
+ var pretty = (v) => prettyJson(toJsonValue(v));
183
+ function fieldText(f) {
184
+ let out = `${f.name} = ${pretty(f.value)}
185
+ `;
186
+ if (!f.setBy.length) return `${out} Nothing in the cascade sets it.
187
+ `;
188
+ out += "\nSet by (the last one wins):\n";
189
+ f.setBy.forEach((set, i) => {
190
+ out += ` ${i + 1 === f.setBy.length ? ">" : " "} ${padEnd(set.from, 40)} ${brief(set.value)}
191
+ `;
192
+ });
193
+ return out;
194
+ }
195
+ var setByJson = (f) => f.setBy.map((s) => ({ from: s.from, value: toJsonValue(s.value) }));
196
+ function inspectionJson(inspection, one) {
197
+ const out = {
198
+ schemaVersion: 1,
199
+ url: inspection.url,
200
+ inputPath: inspection.inputPath,
201
+ outputPath: inspection.outputPath,
202
+ engines: inspection.engines,
203
+ layouts: inspection.layouts,
204
+ date: { value: inspection.date, from: inspection.dateFrom },
205
+ collections: inspection.collections
206
+ };
207
+ if (one) out.field = { name: one.name, value: toJsonValue(one.value), from: one.from, setBy: setByJson(one) };
208
+ else out.data = Object.fromEntries(inspection.fields.map((f) => [f.name, { value: toJsonValue(f.value), from: f.from, setBy: setByJson(f) }]));
209
+ return out;
210
+ }
211
+ export {
212
+ field,
213
+ fieldText,
214
+ inspect,
215
+ inspectionJson,
216
+ inspectionText
217
+ };
@@ -0,0 +1,57 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ closest
5
+ } from "./chunk-FVZ5JBRI.js";
6
+ import {
7
+ bail
8
+ } from "./chunk-GRWMGC7D.js";
9
+
10
+ // src/modules/options.ts
11
+ var Options = class {
12
+ map;
13
+ constructor(value, known) {
14
+ if (typeof value !== "object" || value === null || Array.isArray(value)) bail("options must be an object");
15
+ const map = Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0));
16
+ const key = Object.keys(map).find((k) => !known.includes(k));
17
+ if (key !== void 0) {
18
+ if (known.length === 0) bail(`this plugin takes no options (got "${key}")`);
19
+ const meant = closest(key, known);
20
+ bail(`unknown option "${key}"${meant ? ` (did you mean "${meant}"?)` : ""} (options: ${known.join(", ")})`);
21
+ }
22
+ this.map = map;
23
+ }
24
+ /** An option's value, or `undefined` when it's missing or `null`. */
25
+ get(key) {
26
+ const v = this.map[key];
27
+ return v === null ? void 0 : v;
28
+ }
29
+ string(key) {
30
+ const v = this.get(key);
31
+ if (v === void 0) return void 0;
32
+ if (typeof v !== "string") bail(`${key} must be a string`);
33
+ return v;
34
+ }
35
+ number(key) {
36
+ const v = this.get(key);
37
+ if (v === void 0) return void 0;
38
+ if (typeof v !== "number" || !Number.isFinite(v)) bail(`${key} must be a number`);
39
+ return v;
40
+ }
41
+ bool(key) {
42
+ const v = this.get(key);
43
+ if (v === void 0) return void 0;
44
+ if (typeof v !== "boolean") bail(`${key} must be true or false`);
45
+ return v;
46
+ }
47
+ list(key) {
48
+ const v = this.get(key);
49
+ if (v === void 0) return void 0;
50
+ if (!Array.isArray(v) || v.some((i) => typeof i !== "string")) bail(`${key} must be an array of strings`);
51
+ return v;
52
+ }
53
+ };
54
+
55
+ export {
56
+ Options
57
+ };
@@ -0,0 +1,54 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ closest
5
+ } from "./chunk-FVZ5JBRI.js";
6
+ import {
7
+ quoted
8
+ } from "./chunk-CMUWRPSQ.js";
9
+ import {
10
+ bail
11
+ } from "./chunk-GRWMGC7D.js";
12
+
13
+ // src/budgets.ts
14
+ var BUDGETS = [
15
+ ["pages", "Pages"],
16
+ ["images", "Images"],
17
+ ["css", "CSS"],
18
+ ["javascript", "JavaScript"],
19
+ ["fonts", "Fonts"],
20
+ ["media", "Media"],
21
+ ["documents", "Documents"],
22
+ ["data", "Data and feeds"],
23
+ ["other", "Other"],
24
+ ["total", ""]
25
+ ];
26
+ function parseSize(text) {
27
+ const trimmed = text.trim();
28
+ const split = trimmed.search(/[A-Za-z]/);
29
+ const digits = (split === -1 ? trimmed : trimmed.slice(0, split)).trim();
30
+ if (!/^[+-]?(\d+\.?\d*|\.\d+)$/.test(digits) || !(Number(digits) >= 0)) return void 0;
31
+ const unit = { "": 1, B: 1, KB: 1e3, K: 1e3, MB: 1e6, M: 1e6, GB: 1e9, G: 1e9 }[(split === -1 ? "" : trimmed.slice(split)).trim().toUpperCase()];
32
+ if (unit === void 0) return void 0;
33
+ return Math.round(Number(digits) * unit);
34
+ }
35
+ function budget(name, given) {
36
+ const size = typeof given === "bigint" ? Number(given) : given;
37
+ const names = BUDGETS.map(([key]) => key);
38
+ if (!names.includes(name)) {
39
+ const near = closest(name, names);
40
+ bail(`budgets.${name} isn't a kind of file${near ? ` (did you mean \`${near}\`?)` : ""} (use ${names.join(", ")})`);
41
+ }
42
+ if (typeof size === "number" && size >= 0) return [name, Math.trunc(size)];
43
+ if (typeof size === "string") {
44
+ const bytes = parseSize(size);
45
+ if (bytes === void 0) bail(`budgets.${name}: ${quoted(size)} isn't a size (write it like "150 KB" or "1.5 MB")`);
46
+ return [name, bytes];
47
+ }
48
+ return bail(`budgets.${name} must be a size like "150 KB", not ${typeof size}`);
49
+ }
50
+
51
+ export {
52
+ BUDGETS,
53
+ budget
54
+ };
@@ -0,0 +1,10 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+
4
+ // src/version.ts
5
+ import fs from "node:fs";
6
+ var VERSION = JSON.parse(fs.readFileSync(new URL("../package.json", new URL("../src/version.ts", import.meta.url).href), "utf8")).version;
7
+
8
+ export {
9
+ VERSION
10
+ };