seemore 1.12.21 → 1.12.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +53 -16
- package/dist/cli/index.js.map +1 -1
- package/package.json +2 -1
- package/src/app/features/edit.tsx +77 -16
- package/src/app/styles/globals.css +4 -2
package/dist/cli/index.js
CHANGED
|
@@ -1159,11 +1159,11 @@ function humanise(slug) {
|
|
|
1159
1159
|
// src/node/content/source.ts
|
|
1160
1160
|
function createSource(options) {
|
|
1161
1161
|
let cached;
|
|
1162
|
-
const
|
|
1162
|
+
const read2 = () => cached ??= scan(options);
|
|
1163
1163
|
const loader = dynamicLoader(
|
|
1164
1164
|
{
|
|
1165
1165
|
cache: "custom",
|
|
1166
|
-
files: () =>
|
|
1166
|
+
files: () => read2().files,
|
|
1167
1167
|
invalidate: () => {
|
|
1168
1168
|
cached = void 0;
|
|
1169
1169
|
}
|
|
@@ -1172,11 +1172,11 @@ function createSource(options) {
|
|
|
1172
1172
|
);
|
|
1173
1173
|
return {
|
|
1174
1174
|
loader,
|
|
1175
|
-
current:
|
|
1176
|
-
pages: () =>
|
|
1175
|
+
current: read2,
|
|
1176
|
+
pages: () => read2().pages,
|
|
1177
1177
|
refresh() {
|
|
1178
1178
|
loader.invalidate();
|
|
1179
|
-
return
|
|
1179
|
+
return read2();
|
|
1180
1180
|
},
|
|
1181
1181
|
async getPageTree() {
|
|
1182
1182
|
const output = await loader.get();
|
|
@@ -1822,6 +1822,14 @@ function spliceSource(content, request) {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
return { ok: true, content: content.slice(0, start) + withEol(text, dominantEol(content)) + content.slice(end) };
|
|
1824
1824
|
}
|
|
1825
|
+
function appendSource(content, text) {
|
|
1826
|
+
const body = text.replace(/\r\n/g, "\n").replace(/\s+$/, "");
|
|
1827
|
+
if (body.trim() === "") return void 0;
|
|
1828
|
+
const lf = content.replace(/\r\n/g, "\n");
|
|
1829
|
+
const separator = lf === "" || lf.endsWith("\n\n") ? "" : lf.endsWith("\n") ? "\n" : "\n\n";
|
|
1830
|
+
return content + withEol(`${separator}${body}
|
|
1831
|
+
`, dominantEol(content));
|
|
1832
|
+
}
|
|
1825
1833
|
function dominantEol(content) {
|
|
1826
1834
|
const crlf = content.match(/\r\n/g)?.length ?? 0;
|
|
1827
1835
|
const lf = (content.match(/\n/g)?.length ?? 0) - crlf;
|
|
@@ -2018,7 +2026,8 @@ function handleSourceRead(ctx, req, res) {
|
|
|
2018
2026
|
if (page === void 0) return send(res, 404, { error: "That file is not part of this site." });
|
|
2019
2027
|
const start = Number(query.get("start"));
|
|
2020
2028
|
const end = Number(query.get("end"));
|
|
2021
|
-
const content =
|
|
2029
|
+
const content = read(res, page.absPath);
|
|
2030
|
+
if (content === void 0) return;
|
|
2022
2031
|
if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end < start || end > content.length) {
|
|
2023
2032
|
return send(res, 400, { error: "The requested range is not inside this file." });
|
|
2024
2033
|
}
|
|
@@ -2033,10 +2042,19 @@ async function handleSourceWrite(ctx, req, res) {
|
|
|
2033
2042
|
}
|
|
2034
2043
|
const page = resolvePage(ctx, body.file);
|
|
2035
2044
|
if (page === void 0) return send(res, 404, { error: "That file is not part of this site." });
|
|
2045
|
+
if (body.append === true) {
|
|
2046
|
+
if (typeof body.text !== "string") return send(res, 400, { error: "`text` is required." });
|
|
2047
|
+
const content2 = read(res, page.absPath);
|
|
2048
|
+
if (content2 === void 0) return;
|
|
2049
|
+
const appended = appendSource(content2, body.text);
|
|
2050
|
+
if (appended === void 0) return send(res, 200, { ok: true });
|
|
2051
|
+
return write(res, page.absPath, appended);
|
|
2052
|
+
}
|
|
2036
2053
|
if (typeof body.expected !== "string" || typeof body.text !== "string") {
|
|
2037
2054
|
return send(res, 400, { error: "Both `expected` and `text` are required." });
|
|
2038
2055
|
}
|
|
2039
|
-
const content =
|
|
2056
|
+
const content = read(res, page.absPath);
|
|
2057
|
+
if (content === void 0) return;
|
|
2040
2058
|
const result = spliceSource(content, {
|
|
2041
2059
|
start: body.start,
|
|
2042
2060
|
end: body.end,
|
|
@@ -2044,7 +2062,24 @@ async function handleSourceWrite(ctx, req, res) {
|
|
|
2044
2062
|
text: body.text
|
|
2045
2063
|
});
|
|
2046
2064
|
if (!result.ok) return send(res, result.status, { error: result.error });
|
|
2047
|
-
|
|
2065
|
+
return write(res, page.absPath, result.content);
|
|
2066
|
+
}
|
|
2067
|
+
function read(res, file) {
|
|
2068
|
+
try {
|
|
2069
|
+
return readFileSync6(file, "utf8");
|
|
2070
|
+
} catch (error) {
|
|
2071
|
+
const code = error.code;
|
|
2072
|
+
send(res, 500, { error: `The file could not be read${code === void 0 ? "" : ` (${code})`}. Is another program holding it open?` });
|
|
2073
|
+
return void 0;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
function write(res, file, content) {
|
|
2077
|
+
try {
|
|
2078
|
+
writeFileSync5(file, content, "utf8");
|
|
2079
|
+
} catch (error) {
|
|
2080
|
+
const code = error.code;
|
|
2081
|
+
return send(res, 500, { error: `The file could not be written${code === void 0 ? "" : ` (${code})`}. Is another program holding it open?` });
|
|
2082
|
+
}
|
|
2048
2083
|
return send(res, 200, { ok: true });
|
|
2049
2084
|
}
|
|
2050
2085
|
function resolvePage(ctx, file) {
|
|
@@ -2398,6 +2433,7 @@ async function loadPrerenderModule(ctx, ssrOutDir) {
|
|
|
2398
2433
|
// src/node/social/cards.ts
|
|
2399
2434
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
2400
2435
|
import { dirname as dirname9, join as join11 } from "path";
|
|
2436
|
+
import { createElement } from "react";
|
|
2401
2437
|
|
|
2402
2438
|
// src/shared/og.ts
|
|
2403
2439
|
function ogImagePath(url) {
|
|
@@ -2428,8 +2464,13 @@ async function generateSocialCards(ctx, outDir) {
|
|
|
2428
2464
|
return written;
|
|
2429
2465
|
}
|
|
2430
2466
|
async function renderCard(takumi, site, title, description) {
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2467
|
+
const children = [
|
|
2468
|
+
createElement("div", { style: { fontSize: 28, opacity: 0.6 } }, site),
|
|
2469
|
+
createElement("div", { style: { fontSize: 64, fontWeight: 700 } }, title),
|
|
2470
|
+
...typeof description === "string" ? [createElement("div", { style: { fontSize: 30, opacity: 0.8 } }, description)] : []
|
|
2471
|
+
];
|
|
2472
|
+
const node = createElement(
|
|
2473
|
+
"div",
|
|
2433
2474
|
{
|
|
2434
2475
|
style: {
|
|
2435
2476
|
width: 1200,
|
|
@@ -2443,13 +2484,9 @@ async function renderCard(takumi, site, title, description) {
|
|
|
2443
2484
|
gap: 24
|
|
2444
2485
|
}
|
|
2445
2486
|
},
|
|
2446
|
-
|
|
2447
|
-
takumi.text(site, { style: { fontSize: 28, opacity: 0.6 } }),
|
|
2448
|
-
takumi.text(title, { style: { fontSize: 64, fontWeight: 700 } }),
|
|
2449
|
-
...typeof description === "string" ? [takumi.text(description, { style: { fontSize: 30, opacity: 0.8 } })] : []
|
|
2450
|
-
]
|
|
2487
|
+
children
|
|
2451
2488
|
);
|
|
2452
|
-
return await
|
|
2489
|
+
return await takumi.render(node, { width: 1200, height: 630 });
|
|
2453
2490
|
}
|
|
2454
2491
|
async function importOptional(specifier) {
|
|
2455
2492
|
return await import(specifier);
|