ssqch 0.10.1 → 0.11.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/bundled/completions/bash +61 -15
- package/bundled/completions/elvish +27 -12
- package/bundled/completions/fish +35 -23
- package/bundled/completions/powershell +29 -12
- package/bundled/completions/zsh +39 -19
- package/bundled/docs/agents.md +11 -0
- package/bundled/docs/comparing-builds.md +37 -5
- package/bundled/docs/configuring.md +30 -5
- package/bundled/docs/field-guide.md +1 -1
- package/bundled/docs/github-pages.md +1 -1
- package/bundled/docs/index.md +1 -1
- package/bundled/docs/known-gaps.md +1 -1
- package/bundled/docs/markdown.md +63 -5
- package/bundled/docs/multilingual.md +20 -3
- package/bundled/docs/nav.yml +1 -0
- package/bundled/docs/netlify.md +2 -2
- package/bundled/docs/plugins.md +4 -4
- package/bundled/docs/seo.md +39 -1
- package/bundled/docs/template-languages.md +6 -4
- package/bundled/docs/templates.md +3 -3
- package/bundled/docs/trailheads/from-eleventy.md +25 -13
- package/bundled/docs/trailheads/from-hugo.md +103 -0
- package/bundled/docs/trailheads/from-jekyll.md +49 -15
- package/bundled/docs/trailheads/from-mkdocs.md +54 -9
- package/bundled/docs/trailheads/from-zola.md +2 -2
- package/bundled/docs/trailheads.md +22 -5
- package/bundled/docs/where-values-come-from.md +1 -1
- package/bundled/mkdocs/404.jinja +6 -0
- package/bundled/ssqch.d.ts +71 -16
- package/lib/assets.js +10 -9
- package/lib/{chunk-MUYWL4ZX.js → chunk-2L3HR67O.js} +71 -18
- package/lib/{chunk-ERNVEZOK.js → chunk-2QTJTEBV.js} +1 -1
- package/lib/{chunk-CXRHH5P5.js → chunk-3HZZY3Y7.js} +5 -5
- package/lib/{chunk-G67W2FTJ.js → chunk-3K237XAX.js} +9 -8
- package/lib/{chunk-6RSZV5O2.js → chunk-443ZQLVX.js} +3 -3
- package/lib/{chunk-ZZBHBLDB.js → chunk-5ELAUHRL.js} +18 -16
- package/lib/{chunk-MDG5A4NI.js → chunk-A75EVUJX.js} +5 -5
- package/lib/{chunk-JFPLNHEQ.js → chunk-AIMEXBTK.js} +28 -5
- package/lib/{chunk-6OUT5VFK.js → chunk-B5E27PLU.js} +10 -39
- package/lib/{chunk-R2YGC3VE.js → chunk-CMJ7X5WW.js} +3 -2
- package/lib/{chunk-MDB3D3LP.js → chunk-ERAIEV3O.js} +2 -2
- package/lib/{chunk-DTSTCVRX.js → chunk-FCM3NYFR.js} +11 -8
- package/lib/{chunk-X7C6GFUM.js → chunk-GJNIQAIH.js} +8 -8
- package/lib/{chunk-FYRC2HBU.js → chunk-GLJQ4C76.js} +39 -18
- package/lib/{chunk-BXARVN5Z.js → chunk-GS5B3CBW.js} +1 -1
- package/lib/chunk-H5K2ZE7B.js +219 -0
- package/lib/{chunk-DNWA7WNO.js → chunk-HFSWUTXX.js} +1 -1
- package/lib/{chunk-7JGYYAKI.js → chunk-HWW5NCVJ.js} +1 -1
- package/lib/{chunk-BT3NVQOD.js → chunk-I3HYKEEW.js} +1 -1
- package/lib/{chunk-RFNLZM7W.js → chunk-IOBC665M.js} +1 -1
- package/lib/chunk-JC54PHIT.js +7992 -0
- package/lib/{chunk-3BQJY6GF.js → chunk-KCF2Z6N7.js} +1 -1
- package/lib/{chunk-HMVYNV6M.js → chunk-KZZS4W2V.js} +14 -12
- package/lib/{chunk-XR7GFL4B.js → chunk-LJOURBYT.js} +14 -12
- package/lib/chunk-OQGXZYZS.js +45 -0
- package/lib/chunk-OSBEH67S.js +6296 -0
- package/lib/{chunk-FYU22VDK.js → chunk-QJ5ZFTML.js} +14 -12
- package/lib/{chunk-LU73FTIR.js → chunk-QLUTNR37.js} +11 -10
- package/lib/{chunk-DUGGZ4EE.js → chunk-RBNPBTDP.js} +1 -1
- package/lib/{chunk-F65YUXZ7.js → chunk-RIAOXEXC.js} +10 -4
- package/lib/chunk-RVXGUMFI.js +21 -0
- package/lib/{chunk-FZGJUJAL.js → chunk-RYIWYWRQ.js} +3 -3
- package/lib/{chunk-LYPKL524.js → chunk-RZYAIX2R.js} +12 -10
- package/lib/{chunk-3NDFUMV2.js → chunk-V2FSMOFX.js} +3 -3
- package/lib/{chunk-26SHWRC6.js → chunk-X2GAVYV2.js} +524 -72
- package/lib/chunk-XS4EJSEK.js +279 -0
- package/lib/chunk-YCOTX2VM.js +37 -0
- package/lib/{chunk-P2TRR6XK.js → chunk-Z44IAMNG.js} +85 -16
- package/lib/chunk-Z5OP43HU.js +2945 -0
- package/lib/{chunk-3LODFCCH.js → chunk-ZINLHOX4.js} +2 -2
- package/lib/{chunk-HNG372DW.js → chunk-ZR3JYLFB.js} +814 -12347
- package/lib/cli.js +78 -37
- package/lib/elements.js +10 -9
- package/lib/image.js +11 -10
- package/lib/links.js +10 -9
- package/lib/minify.js +71 -12
- package/lib/redirects.js +10 -9
- package/lib/rss.js +13 -10
- package/lib/sass.js +13 -243
- package/lib/sitemap.js +18 -15
- package/lib/ssqch.js +6 -4
- package/package.json +1 -1
- package/types/index.d.ts +52 -11
- package/types/minify.d.ts +15 -3
- package/types/sass.d.ts +2 -0
- package/types/sitemap.d.ts +2 -2
- package/wasm/markdown.wasm +0 -0
- package/wasm/minify.wasm +0 -0
- package/wasm/sass.wasm +0 -0
- package/lib/chunk-II7ZRIAC.js +0 -1285
- package/lib/chunk-IOXCGMSF.js +0 -1539
- /package/lib/{chunk-JFPLNHEQ.js.LEGAL.txt → chunk-AIMEXBTK.js.LEGAL.txt} +0 -0
- /package/lib/{chunk-HNG372DW.js.LEGAL.txt → chunk-ZR3JYLFB.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
startReading
|
|
5
|
+
} from "./chunk-3NYSSA2C.js";
|
|
6
|
+
import {
|
|
7
|
+
Options
|
|
8
|
+
} from "./chunk-RBNPBTDP.js";
|
|
9
|
+
import {
|
|
10
|
+
BUILTINS,
|
|
11
|
+
cssWithBase,
|
|
12
|
+
debugString,
|
|
13
|
+
wasi
|
|
14
|
+
} from "./chunk-Z44IAMNG.js";
|
|
15
|
+
import {
|
|
16
|
+
WebAssembly
|
|
17
|
+
} from "./chunk-JC54PHIT.js";
|
|
18
|
+
import {
|
|
19
|
+
BuildError,
|
|
20
|
+
bail,
|
|
21
|
+
comparePaths,
|
|
22
|
+
displayPath,
|
|
23
|
+
isInside,
|
|
24
|
+
messageOf,
|
|
25
|
+
realPath,
|
|
26
|
+
slashes
|
|
27
|
+
} from "./chunk-AIMEXBTK.js";
|
|
28
|
+
|
|
29
|
+
// src/modules/sass.ts
|
|
30
|
+
import fs from "node:fs";
|
|
31
|
+
import path from "node:path";
|
|
32
|
+
import { fileURLToPath } from "node:url";
|
|
33
|
+
function sassPlugin(options = {}) {
|
|
34
|
+
return { name: "ssqch/sass", builtin: "ssqch/sass", options };
|
|
35
|
+
}
|
|
36
|
+
var isSass = (file) => file.endsWith(".scss") || file.endsWith(".sass");
|
|
37
|
+
function entries(root, from, to) {
|
|
38
|
+
const src = path.resolve(root, from);
|
|
39
|
+
const stat = fs.statSync(src, { throwIfNoEntry: false });
|
|
40
|
+
if (stat?.isFile()) {
|
|
41
|
+
if (!isSass(src)) bail(`files: ${from} isn't a .scss or .sass file`);
|
|
42
|
+
return [[src, to.endsWith("/") ? `${to}${path.basename(src).replace(/\.s[ac]ss$/, "")}.css` : to]];
|
|
43
|
+
}
|
|
44
|
+
if (!stat?.isDirectory()) bail(`files: ${from} doesn't exist`);
|
|
45
|
+
const out = [];
|
|
46
|
+
const walk = (dir) => {
|
|
47
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
48
|
+
const file = path.join(dir, entry.name);
|
|
49
|
+
if (entry.isDirectory()) walk(file);
|
|
50
|
+
else if (entry.isFile() && isSass(entry.name) && !entry.name.startsWith("_")) {
|
|
51
|
+
out.push([file, `${to.replace(/\/+$/, "")}/${slashes(path.relative(src, file)).replace(/\.s[ac]ss$/, "")}.css`]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
walk(src);
|
|
56
|
+
return out.sort((a, b) => comparePaths(a[0], b[0]) || (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0));
|
|
57
|
+
}
|
|
58
|
+
BUILTINS.set("ssqch/sass", (config, given) => {
|
|
59
|
+
const o = new Options(given, ["files", "style", "loadPaths", "charset"]);
|
|
60
|
+
const files = [];
|
|
61
|
+
const map = o.get("files");
|
|
62
|
+
if (map !== void 0) {
|
|
63
|
+
if (typeof map !== "object" || Array.isArray(map)) bail('files must be an object of { source: "/output" }');
|
|
64
|
+
for (const [from, to] of Object.entries(map)) {
|
|
65
|
+
if (typeof to !== "string") bail(`files.${from}: the output must be a URL path string`);
|
|
66
|
+
files.push([from, to]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const style = o.string("style");
|
|
70
|
+
if (style !== void 0 && style !== "compressed" && style !== "expanded") bail(`style must be "compressed" or "expanded", not ${debugString(style)}`);
|
|
71
|
+
const loadPaths = o.list("loadPaths") ?? [];
|
|
72
|
+
const charset = o.bool("charset") ?? true;
|
|
73
|
+
if (!files.length) bail('files is required: { "src/scss": "/css" } or { "src/app.scss": "/app.css" }');
|
|
74
|
+
for (const [from, to] of files) {
|
|
75
|
+
if (!to.startsWith("/") || to.includes("..")) bail(`files: ${debugString(to)} must be a URL path starting with / (like "/css/app.css" or "/css")`);
|
|
76
|
+
if (from === "") bail("files: a source path can't be empty");
|
|
77
|
+
}
|
|
78
|
+
for (const [from] of files) {
|
|
79
|
+
config.watch.push(from);
|
|
80
|
+
const slash = Math.max(from.lastIndexOf("/"), from.lastIndexOf(path.sep));
|
|
81
|
+
const dir = slash < 0 ? "" : slash === 0 ? from.slice(0, 1) : from.slice(0, slash);
|
|
82
|
+
if (isSass(from) && dir !== "") config.watch.push(dir);
|
|
83
|
+
}
|
|
84
|
+
for (const dir of loadPaths) config.watch.push(dir);
|
|
85
|
+
let count;
|
|
86
|
+
config.fileBuilders.push(["ssqch/sass", (config2) => {
|
|
87
|
+
const chosen = style ?? (config2.env === "production" && !config2.serving ? "compressed" : "expanded");
|
|
88
|
+
const used = startReading(config2, "ssqch/sass");
|
|
89
|
+
const compiler = new Compiler(config2.root, used, loadPaths.map((dir) => path.resolve(config2.root, dir)));
|
|
90
|
+
const options = JSON.stringify({ style: chosen, loadPaths: loadPaths.map((dir) => compiler.name(path.resolve(config2.root, dir))) });
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const [from, to] of files) {
|
|
93
|
+
for (const [src, url] of entries(config2.root, from, to)) {
|
|
94
|
+
const shown = displayPath(config2.root, src);
|
|
95
|
+
const compiled2 = compiler.compile(src, options, shown);
|
|
96
|
+
const css = charset ? compiled2 : compiled2.replace(/^\uFEFF|^@charset "UTF-8";\n?/, "");
|
|
97
|
+
out.push({ path: url, contents: cssWithBase(config2.base, css) });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
count = [out.length, chosen];
|
|
101
|
+
return out;
|
|
102
|
+
}]);
|
|
103
|
+
config.summaries.push(["Sass", () => count === void 0 ? void 0 : `${count[0]} file${count[0] === 1 ? "" : "s"} (${count[1]})`]);
|
|
104
|
+
});
|
|
105
|
+
var compressedCss = /* @__PURE__ */ new Map();
|
|
106
|
+
var KEPT_CSS = 256;
|
|
107
|
+
function compressCss(css, shown = "CSS") {
|
|
108
|
+
const kept = compressedCss.get(css);
|
|
109
|
+
if (kept !== void 0) return kept;
|
|
110
|
+
const name = "ssqch:inline.css";
|
|
111
|
+
const compiler = new Compiler(process.cwd(), /* @__PURE__ */ new Set());
|
|
112
|
+
compiler.inline.set(name, css);
|
|
113
|
+
let out;
|
|
114
|
+
try {
|
|
115
|
+
out = compiler.compile(name, JSON.stringify({ style: "compressed", loadPaths: [] }), shown);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
throw new BuildError(messageOf(e).replace(`compiling ${shown}: ${shown}: `, `${shown}: `).replaceAll(name, shown));
|
|
118
|
+
}
|
|
119
|
+
if (compressedCss.size >= KEPT_CSS) compressedCss.delete(compressedCss.keys().next().value);
|
|
120
|
+
compressedCss.set(css, out);
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
var WASM_FILE = fileURLToPath(new URL("../../wasm/sass.wasm", new URL("../src/modules/sass.ts", import.meta.url).href));
|
|
124
|
+
var compiled;
|
|
125
|
+
var current;
|
|
126
|
+
var active;
|
|
127
|
+
var Compiler = class {
|
|
128
|
+
root;
|
|
129
|
+
used;
|
|
130
|
+
loadPaths;
|
|
131
|
+
/** A stylesheet that's no file, by the name grass is given for it (`minifyCss`'s text). */
|
|
132
|
+
inline = /* @__PURE__ */ new Map();
|
|
133
|
+
constructor(root, used, loadPaths = []) {
|
|
134
|
+
this.root = root;
|
|
135
|
+
this.used = used;
|
|
136
|
+
this.loadPaths = loadPaths;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A stylesheet as grass should read it. Two things other compilers take that grass doesn't:
|
|
140
|
+
*
|
|
141
|
+
* - Front matter (Jekyll's `---` lines at the top of a site's main stylesheet) becomes blank
|
|
142
|
+
* lines, so error lines still match the file. Sass can't start with `---`, so nothing that
|
|
143
|
+
* compiled before reads differently.
|
|
144
|
+
* - An `@import`, `@use` or `@forward` that names its extension (`"primer-core/index.scss"`)
|
|
145
|
+
* is found in the load paths too: grass 0.13 looks for one only beside the importing file
|
|
146
|
+
* (`find_import`, "todo: consider load paths"), and Dart Sass and Ruby Sass look in both.
|
|
147
|
+
* Where the file isn't beside the importer but is in a load path, the import names it from
|
|
148
|
+
* the importer's folder. primer's packages all import this way (opensource.guide, osg #10).
|
|
149
|
+
*/
|
|
150
|
+
source(file, data) {
|
|
151
|
+
if (!isSass(file)) return data;
|
|
152
|
+
let text = data.toString("utf8");
|
|
153
|
+
const front = /^---[ \t]*\r?\n(?:[\s\S]*?\r?\n)?---[ \t]*(?:\r?\n|$)/.exec(text);
|
|
154
|
+
if (front) text = front[0].replace(/[^\n]/g, "") + text.slice(front[0].length);
|
|
155
|
+
const dir = path.dirname(file);
|
|
156
|
+
const exists = (base, name) => {
|
|
157
|
+
const full = path.resolve(base, name);
|
|
158
|
+
const partial = path.join(path.dirname(full), `_${path.basename(full)}`);
|
|
159
|
+
return fs.existsSync(full) ? full : fs.existsSync(partial) ? partial : void 0;
|
|
160
|
+
};
|
|
161
|
+
const dotted = (name) => {
|
|
162
|
+
if (!/\.[^/.]+$/.test(name) || /\.(?:s[ac]ss|css)$/.test(name) || /^[a-z]+:/i.test(name)) return name;
|
|
163
|
+
for (const base of [dir, ...this.loadPaths]) {
|
|
164
|
+
for (const ext of [".scss", ".sass"]) if (exists(base, `${name}${ext}`)) return `${name}${ext}`;
|
|
165
|
+
}
|
|
166
|
+
return name;
|
|
167
|
+
};
|
|
168
|
+
const changed = text.replace(/@(import|use|forward)(\s+)([^;{}]+)/g, (statement, rule, space, rest) => `@${rule}${space}${rest.replace(/(["'])([^"'\n]+)\1/g, (quoted, q, name) => `${q}${dotted(name)}${q}`).replace(/(["'])([^"'\n]+\.s[ac]ss)\1/g, (quoted, q, name) => {
|
|
169
|
+
if (path.isAbsolute(name) || /^[a-z]+:/i.test(name) || exists(dir, name)) return quoted;
|
|
170
|
+
for (const load of this.loadPaths) {
|
|
171
|
+
const found = exists(load, name);
|
|
172
|
+
if (found) return `${q}${slashes(path.relative(dir, path.join(path.dirname(found), path.basename(name))))}${q}`;
|
|
173
|
+
}
|
|
174
|
+
return quoted;
|
|
175
|
+
})}`);
|
|
176
|
+
return front || changed !== text ? Buffer.from(changed, "utf8") : data;
|
|
177
|
+
}
|
|
178
|
+
/** A path as grass sees it: from the root for the site's own files, else whole; with `/`. */
|
|
179
|
+
name(file) {
|
|
180
|
+
return isInside(this.root, file) && file !== this.root ? slashes(path.relative(this.root, file)) : slashes(file);
|
|
181
|
+
}
|
|
182
|
+
/** A path grass gave back, as a real one. */
|
|
183
|
+
file(name) {
|
|
184
|
+
return path.resolve(this.root, name);
|
|
185
|
+
}
|
|
186
|
+
compile(src, options, shown) {
|
|
187
|
+
const x = instance();
|
|
188
|
+
const parts = [this.name(src), options];
|
|
189
|
+
const lens = parts.map((p) => Buffer.byteLength(p, "utf8"));
|
|
190
|
+
const ptr = x.sass_alloc(lens[0] + lens[1]);
|
|
191
|
+
const bytes = Buffer.from(x.memory.buffer);
|
|
192
|
+
bytes.write(parts[0], ptr, lens[0], "utf8");
|
|
193
|
+
bytes.write(parts[1], ptr + lens[0], lens[1], "utf8");
|
|
194
|
+
active = this;
|
|
195
|
+
let status;
|
|
196
|
+
try {
|
|
197
|
+
status = x.sass_compile(ptr, lens[0], lens[1]);
|
|
198
|
+
} catch (e) {
|
|
199
|
+
current = void 0;
|
|
200
|
+
let message = messageOf(e);
|
|
201
|
+
if (e instanceof WebAssembly.RuntimeError) {
|
|
202
|
+
try {
|
|
203
|
+
x.sass_panic();
|
|
204
|
+
message = resultOf(x) || message;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
throw new BuildError(`compiling ${shown}: ssqch's Sass crashed (${message.replace(/\s*\n\s*/g, " ")})`);
|
|
209
|
+
} finally {
|
|
210
|
+
active = void 0;
|
|
211
|
+
}
|
|
212
|
+
const text = resultOf(x);
|
|
213
|
+
if (status !== 0) throw new BuildError(`compiling ${shown}: ${shown}: ${text}`);
|
|
214
|
+
return text;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
function resultOf(x) {
|
|
218
|
+
const ptr = x.sass_result_ptr();
|
|
219
|
+
return Buffer.from(x.memory.buffer).toString("utf8", ptr, ptr + x.sass_result_len());
|
|
220
|
+
}
|
|
221
|
+
function instance() {
|
|
222
|
+
if (current) return current;
|
|
223
|
+
if (!compiled) {
|
|
224
|
+
let bytes;
|
|
225
|
+
try {
|
|
226
|
+
bytes = fs.readFileSync(WASM_FILE);
|
|
227
|
+
} catch (e) {
|
|
228
|
+
throw new BuildError(`ssqch's Sass isn't there (${WASM_FILE}: ${messageOf(e)}); build it with node packages/ssqch/scripts/build-wasm.ts sass`);
|
|
229
|
+
}
|
|
230
|
+
compiled = new WebAssembly.Module(bytes);
|
|
231
|
+
}
|
|
232
|
+
let x;
|
|
233
|
+
const memory = () => x.memory;
|
|
234
|
+
const text = (ptr, len) => Buffer.from(x.memory.buffer).toString("utf8", ptr, ptr + len);
|
|
235
|
+
const reply = (out, status, answer) => {
|
|
236
|
+
const data = typeof answer === "string" ? Buffer.from(answer, "utf8") : answer;
|
|
237
|
+
const ptr = x.sass_alloc(data.length);
|
|
238
|
+
const bytes = Buffer.from(x.memory.buffer);
|
|
239
|
+
bytes.set(data, ptr);
|
|
240
|
+
bytes.writeUInt32LE(ptr, out);
|
|
241
|
+
bytes.writeUInt32LE(data.length, out + 4);
|
|
242
|
+
return status;
|
|
243
|
+
};
|
|
244
|
+
const stat = (ptr, len) => fs.statSync(active.file(text(ptr, len)), { throwIfNoEntry: false });
|
|
245
|
+
const inline = (ptr, len) => active.inline.get(text(ptr, len));
|
|
246
|
+
const host = {
|
|
247
|
+
is_file: (ptr, len) => inline(ptr, len) !== void 0 || stat(ptr, len)?.isFile() ? 1 : 0,
|
|
248
|
+
is_dir: (ptr, len) => inline(ptr, len) === void 0 && stat(ptr, len)?.isDirectory() ? 1 : 0,
|
|
249
|
+
read: (ptr, len, out) => {
|
|
250
|
+
const given = inline(ptr, len);
|
|
251
|
+
if (given !== void 0) return reply(out, 0, given);
|
|
252
|
+
const file = active.file(text(ptr, len));
|
|
253
|
+
try {
|
|
254
|
+
const data = active.source(file, fs.readFileSync(file));
|
|
255
|
+
active.used.add(realPath(file));
|
|
256
|
+
return reply(out, 0, data);
|
|
257
|
+
} catch (e) {
|
|
258
|
+
return reply(out, 1, messageOf(e));
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
// The same file under two names is one module (grass uses it to load each once).
|
|
262
|
+
canonicalize: (ptr, len, out) => {
|
|
263
|
+
if (inline(ptr, len) !== void 0) return reply(out, 0, text(ptr, len));
|
|
264
|
+
try {
|
|
265
|
+
return reply(out, 0, active.name(fs.realpathSync.native(active.file(text(ptr, len)))));
|
|
266
|
+
} catch (e) {
|
|
267
|
+
return reply(out, 1, messageOf(e));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
x = new WebAssembly.Instance(compiled, { wasi_snapshot_preview1: wasi(memory), ssqch: host }).exports;
|
|
272
|
+
x._initialize();
|
|
273
|
+
return current = x;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export {
|
|
277
|
+
sassPlugin,
|
|
278
|
+
compressCss
|
|
279
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/bundled.ts
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
var PACKAGE = path.dirname(path.dirname(fileURLToPath(new URL("../src/bundled.ts", import.meta.url).href)));
|
|
9
|
+
var BUNDLED = path.join(PACKAGE, "bundled");
|
|
10
|
+
var FROM_REPOSITORY = [
|
|
11
|
+
["docs", "site/src/docs"]
|
|
12
|
+
];
|
|
13
|
+
function bundledPath(rel) {
|
|
14
|
+
const inPackage = path.join(BUNDLED, rel);
|
|
15
|
+
if (fs.existsSync(inPackage)) return inPackage;
|
|
16
|
+
for (const [prefix, original] of FROM_REPOSITORY) {
|
|
17
|
+
if (rel === prefix || rel.startsWith(`${prefix}/`)) return path.join(PACKAGE, "../..", original + rel.slice(prefix.length));
|
|
18
|
+
}
|
|
19
|
+
return inPackage;
|
|
20
|
+
}
|
|
21
|
+
var cache = /* @__PURE__ */ new Map();
|
|
22
|
+
function bundled(rel) {
|
|
23
|
+
let text = cache.get(rel);
|
|
24
|
+
if (text === void 0) cache.set(rel, text = fs.readFileSync(bundledPath(rel), "utf8"));
|
|
25
|
+
return text;
|
|
26
|
+
}
|
|
27
|
+
function bundledNames(rel) {
|
|
28
|
+
return fs.readdirSync(bundledPath(rel)).sort();
|
|
29
|
+
}
|
|
30
|
+
var types = () => bundled("ssqch.d.ts");
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
bundledPath,
|
|
34
|
+
bundled,
|
|
35
|
+
bundledNames,
|
|
36
|
+
types
|
|
37
|
+
};
|
|
@@ -2,17 +2,20 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
budget
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2QTJTEBV.js";
|
|
6
6
|
import {
|
|
7
7
|
bytes,
|
|
8
8
|
count
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ERAIEV3O.js";
|
|
10
10
|
import {
|
|
11
11
|
VERSION
|
|
12
12
|
} from "./chunk-AD3HAW3W.js";
|
|
13
|
+
import {
|
|
14
|
+
bundledPath
|
|
15
|
+
} from "./chunk-YCOTX2VM.js";
|
|
13
16
|
import {
|
|
14
17
|
CONFIG_FILES
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-GS5B3CBW.js";
|
|
16
19
|
import {
|
|
17
20
|
WebAssembly,
|
|
18
21
|
applyMarkdownOptions,
|
|
@@ -21,15 +24,16 @@ import {
|
|
|
21
24
|
oriented,
|
|
22
25
|
probeFile,
|
|
23
26
|
site,
|
|
24
|
-
undecodable
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
closest
|
|
28
|
-
} from "./chunk-FVZ5JBRI.js";
|
|
27
|
+
undecodable,
|
|
28
|
+
withPage
|
|
29
|
+
} from "./chunk-JC54PHIT.js";
|
|
29
30
|
import {
|
|
30
31
|
globProblem,
|
|
31
32
|
globToRegExp
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-HFSWUTXX.js";
|
|
34
|
+
import {
|
|
35
|
+
closest
|
|
36
|
+
} from "./chunk-FVZ5JBRI.js";
|
|
33
37
|
import {
|
|
34
38
|
describeThrown,
|
|
35
39
|
hookModules,
|
|
@@ -37,7 +41,7 @@ import {
|
|
|
37
41
|
loadedFiles,
|
|
38
42
|
settle,
|
|
39
43
|
watchSettle
|
|
40
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-IOBC665M.js";
|
|
41
45
|
import {
|
|
42
46
|
charCount,
|
|
43
47
|
firstChars,
|
|
@@ -67,7 +71,7 @@ import {
|
|
|
67
71
|
tomlReason,
|
|
68
72
|
warn,
|
|
69
73
|
warning
|
|
70
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-AIMEXBTK.js";
|
|
71
75
|
import {
|
|
72
76
|
__require
|
|
73
77
|
} from "./chunk-I3PS26CI.js";
|
|
@@ -3351,9 +3355,14 @@ function emptyConfig(options) {
|
|
|
3351
3355
|
ignore: [],
|
|
3352
3356
|
bundles: false,
|
|
3353
3357
|
strict: false,
|
|
3358
|
+
trimAfterFrontMatter: false,
|
|
3359
|
+
jekyllTemplates: false,
|
|
3360
|
+
mkdocsTemplates: null,
|
|
3361
|
+
jinjaAutoescape: null,
|
|
3354
3362
|
lastModified: null,
|
|
3355
3363
|
dateFallback: "file",
|
|
3356
3364
|
timeZone: null,
|
|
3365
|
+
layoutAliases: /* @__PURE__ */ new Map(),
|
|
3357
3366
|
base: "",
|
|
3358
3367
|
serveRun: [],
|
|
3359
3368
|
budgets: [],
|
|
@@ -3369,6 +3378,7 @@ function emptyConfig(options) {
|
|
|
3369
3378
|
transforms: [],
|
|
3370
3379
|
htmlTransforms: [],
|
|
3371
3380
|
engines: /* @__PURE__ */ new Map(),
|
|
3381
|
+
engineCaches: [],
|
|
3372
3382
|
beforeBuild: [],
|
|
3373
3383
|
afterBuild: [],
|
|
3374
3384
|
watch: [],
|
|
@@ -3445,9 +3455,27 @@ async function loadJsData(file, root) {
|
|
|
3445
3455
|
throw new BuildError(`${name}: ${describeThrown(e, root)}`);
|
|
3446
3456
|
}
|
|
3447
3457
|
}
|
|
3448
|
-
var
|
|
3458
|
+
var EngineCache = class {
|
|
3459
|
+
now = /* @__PURE__ */ new Map();
|
|
3460
|
+
before = /* @__PURE__ */ new Map();
|
|
3461
|
+
startBuild() {
|
|
3462
|
+
this.before = this.now;
|
|
3463
|
+
this.now = /* @__PURE__ */ new Map();
|
|
3464
|
+
}
|
|
3465
|
+
get(source) {
|
|
3466
|
+
const kept = this.now.get(source);
|
|
3467
|
+
if (kept !== void 0) return kept;
|
|
3468
|
+
const earlier = this.before.get(source);
|
|
3469
|
+
if (earlier !== void 0) this.now.set(source, earlier);
|
|
3470
|
+
return earlier;
|
|
3471
|
+
}
|
|
3472
|
+
set(source, html) {
|
|
3473
|
+
this.now.set(source, html);
|
|
3474
|
+
}
|
|
3475
|
+
};
|
|
3476
|
+
var SETTINGS = ["dirs", "templateFormats", "markdownEngine", "htmlEngine", "markdown", "deepMerge", "leaveNoTrace", "clean", "ignore", "bundles", "strict", "trimAfterFrontMatter", "jekyllTemplates", "mkdocsTemplates", "jinja", "lastModified", "dateFallback", "timeZone", "layoutAliases", "base", "schemas", "theme", "serve", "budgets"];
|
|
3449
3477
|
var PARTS = ["data", "filters", "collections", "transforms", "engines", "passthrough", "watch", "beforeBuild", "afterBuild", "plugins"];
|
|
3450
|
-
var CORE_ENGINES = ["edge", "
|
|
3478
|
+
var CORE_ENGINES = ["edge", "html", "txt"];
|
|
3451
3479
|
var DIRS = ["input", "output", "includes", "layouts", "data"];
|
|
3452
3480
|
var configOptions = () => [...SETTINGS, ...PARTS];
|
|
3453
3481
|
var isObject2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
@@ -3664,7 +3692,7 @@ async function loadJs(config, file) {
|
|
|
3664
3692
|
}
|
|
3665
3693
|
}
|
|
3666
3694
|
functions("filters", "filter", part.filters, where, (key, fn) => ops.push(() => {
|
|
3667
|
-
config.filters.set(key, fn);
|
|
3695
|
+
config.filters.set(key, withPage(fn));
|
|
3668
3696
|
config.siteFilters.add(key);
|
|
3669
3697
|
}));
|
|
3670
3698
|
functions("collections", "collection", part.collections, where, (key, fn) => ops.push(() => {
|
|
@@ -3687,6 +3715,8 @@ async function loadJs(config, file) {
|
|
|
3687
3715
|
for (const [key, engine] of Object.entries(part.engines)) {
|
|
3688
3716
|
const render = typeof engine === "function" ? engine : engine?.render;
|
|
3689
3717
|
if (typeof render !== "function") fail(`${where}: engines.${key} must be a function (source, data) or an object with a render(source, data) method`);
|
|
3718
|
+
if (isPlainObject(engine) && engine.cache !== void 0 && typeof engine.cache !== "boolean") fail(`${where}: engines.${key}.cache must be true or false`);
|
|
3719
|
+
const cache = typeof engine === "object" && engine.cache === true ? new EngineCache() : void 0;
|
|
3690
3720
|
if (!/^[A-Za-z0-9_-]+$/.test(key)) fail(`${where}: engines.${key}: an engine's name is a file extension (letters, digits, - and _)`);
|
|
3691
3721
|
if (CORE_ENGINES.includes(key)) fail(`${where}: engines.${key}: "${key}" is built in and can't be replaced`);
|
|
3692
3722
|
claim("engines", "engine", key, where);
|
|
@@ -3699,7 +3729,21 @@ async function loadJs(config, file) {
|
|
|
3699
3729
|
return out instanceof Promise ? watchSettle(out).then((v) => checked(v, inputPath)) : checked(out, inputPath);
|
|
3700
3730
|
};
|
|
3701
3731
|
ops.push(() => {
|
|
3702
|
-
|
|
3732
|
+
if (!cache) {
|
|
3733
|
+
config.engines.set(key, run);
|
|
3734
|
+
return;
|
|
3735
|
+
}
|
|
3736
|
+
config.engineCaches.push(cache);
|
|
3737
|
+
config.engines.set(key, (source, data, inputPath, context2) => {
|
|
3738
|
+
if (context2.kind !== "body") return run(source, data, inputPath, context2);
|
|
3739
|
+
const kept = cache.get(source);
|
|
3740
|
+
if (kept !== void 0) return kept;
|
|
3741
|
+
const out = run(source, data, inputPath, context2);
|
|
3742
|
+
if (typeof out === "string") cache.set(source, out);
|
|
3743
|
+
else out.then((html) => cache.set(source, html), () => {
|
|
3744
|
+
});
|
|
3745
|
+
return out;
|
|
3746
|
+
});
|
|
3703
3747
|
});
|
|
3704
3748
|
}
|
|
3705
3749
|
}
|
|
@@ -3785,12 +3829,23 @@ function applySettings(config, settings) {
|
|
|
3785
3829
|
trace = value;
|
|
3786
3830
|
}
|
|
3787
3831
|
if (trace !== void 0) config.leaveNoTrace = trace;
|
|
3788
|
-
for (const key of ["bundles", "strict"]) {
|
|
3832
|
+
for (const key of ["bundles", "strict", "trimAfterFrontMatter", "jekyllTemplates"]) {
|
|
3789
3833
|
const value = settings[key];
|
|
3790
3834
|
if (value === void 0) continue;
|
|
3791
3835
|
if (typeof value !== "boolean") bail(`${key} must be true or false, not ${typeof value}`);
|
|
3792
3836
|
config[key] = value;
|
|
3793
3837
|
}
|
|
3838
|
+
const mkdocs = settings.mkdocsTemplates;
|
|
3839
|
+
if (mkdocs === true) config.mkdocsTemplates = "mkdocs.yml";
|
|
3840
|
+
else if (typeof mkdocs === "string" && mkdocs.trim() !== "") config.mkdocsTemplates = mkdocs;
|
|
3841
|
+
else if (mkdocs !== void 0 && mkdocs !== false && mkdocs !== null) bail(`mkdocsTemplates must be true, false or the path of an mkdocs.yml, not ${typeof mkdocs === "string" ? "an empty string" : typeof mkdocs}`);
|
|
3842
|
+
const jinja = settings.jinja;
|
|
3843
|
+
if (isObject2(jinja)) {
|
|
3844
|
+
const unknown = Object.keys(jinja).find((k) => k !== "autoescape");
|
|
3845
|
+
if (unknown !== void 0) bail(`jinja: "${unknown}" isn't an option${meant(unknown, ["autoescape"])} (options: autoescape)`);
|
|
3846
|
+
if (jinja.autoescape !== void 0 && typeof jinja.autoescape !== "boolean") bail(`jinja.autoescape must be true or false, not ${typeof jinja.autoescape}`);
|
|
3847
|
+
if (typeof jinja.autoescape === "boolean") config.jinjaAutoescape = jinja.autoescape;
|
|
3848
|
+
} else if (jinja !== void 0 && jinja !== null) bail(`jinja must be an object, like { autoescape: false }, not ${typeof jinja}`);
|
|
3794
3849
|
const modified = settings.lastModified;
|
|
3795
3850
|
if (modified === true) config.lastModified = "git";
|
|
3796
3851
|
else if (modified === "git" || modified === "file") config.lastModified = modified;
|
|
@@ -3800,11 +3855,20 @@ function applySettings(config, settings) {
|
|
|
3800
3855
|
if (fallback === "git" || fallback === "file") config.dateFallback = fallback;
|
|
3801
3856
|
else if (fallback !== void 0 && fallback !== null) bail(`dateFallback must be "git" or "file", not ${typeof fallback === "string" ? `"${fallback}"` : typeof fallback}`);
|
|
3802
3857
|
if (settings.timeZone !== void 0 && settings.timeZone !== null) config.timeZone = checkTimeZone(settings.timeZone);
|
|
3858
|
+
if (settings.layoutAliases !== void 0 && settings.layoutAliases !== null) {
|
|
3859
|
+
if (!isObject2(settings.layoutAliases)) bail(`layoutAliases must be an object of { name: layout }, like { post: "layouts/post.njk" }, not ${typeof settings.layoutAliases}`);
|
|
3860
|
+
for (const [name, target] of Object.entries(settings.layoutAliases)) {
|
|
3861
|
+
if (typeof target !== "string" || target === "") bail(`layoutAliases.${name} must be a layout's name, like "layouts/post.njk"`);
|
|
3862
|
+
if (target === name) bail(`layoutAliases.${name} names itself`);
|
|
3863
|
+
config.layoutAliases.set(name, target);
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3803
3866
|
if (typeof settings.base === "string") config.base = normalizeBase(settings.base);
|
|
3804
3867
|
else if (settings.base !== void 0 && settings.base !== null) bail(`base must be a URL path like "/docs/", not ${typeof settings.base}`);
|
|
3805
3868
|
const theme = settings.theme;
|
|
3806
3869
|
const themes = theme === void 0 || theme === null || theme === false ? [] : Array.isArray(theme) ? theme : [theme];
|
|
3807
3870
|
for (const one of themes) addTheme(config, one);
|
|
3871
|
+
if (config.mkdocsTemplates !== null) addMkdocsTheme(config);
|
|
3808
3872
|
if (isObject2(settings.schemas)) {
|
|
3809
3873
|
for (const [name, spec] of Object.entries(settings.schemas)) {
|
|
3810
3874
|
const schema = parseSchema(name, spec);
|
|
@@ -3830,6 +3894,10 @@ function applySettings(config, settings) {
|
|
|
3830
3894
|
else if (Array.isArray(ignore)) config.ignore = ignore.map((g) => typeof g === "string" ? g : bail(`ignore must be a glob or an array of globs, not an array with ${typeof g}`));
|
|
3831
3895
|
else if (ignore !== void 0) bail(`ignore must be a glob or an array of globs, not ${typeof ignore}`);
|
|
3832
3896
|
}
|
|
3897
|
+
function addMkdocsTheme(config) {
|
|
3898
|
+
const dir = bundledPath("mkdocs");
|
|
3899
|
+
if (!config.themes.includes(dir)) config.themes.push(dir);
|
|
3900
|
+
}
|
|
3833
3901
|
function addTheme(config, theme) {
|
|
3834
3902
|
let dir;
|
|
3835
3903
|
if (typeof theme === "string") dir = resolveTheme(config.root, theme, config.quiet);
|
|
@@ -4009,6 +4077,7 @@ export {
|
|
|
4009
4077
|
DEFAULTS2 as DEFAULTS,
|
|
4010
4078
|
findConfig,
|
|
4011
4079
|
loadConfig,
|
|
4080
|
+
EngineCache,
|
|
4012
4081
|
configOptions,
|
|
4013
4082
|
meant,
|
|
4014
4083
|
BUILTINS,
|