@jant/core 0.11.0 → 0.12.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/bin/commands/deploy.js +179 -0
- package/bin/lib/cloudflare-setup.js +499 -0
- package/bin/lib/d1-query.js +26 -1
- package/bin/lib/r2-query.js +2 -2
- package/dist/{app-jQI4OPRe.js → app-DSwsDBD0.js} +28623 -635
- package/dist/client/.vite/manifest.json +2 -2
- package/dist/client/_assets/{client-52vQhZAv.js → client-DPByjWoU.js} +1 -1
- package/dist/client/_assets/{client-auth-BDcCR6u1.js → client-auth-CPqPTX1B.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/node.js +2 -2
- package/package.json +31 -31
- package/src/__tests__/bin/deploy.test.ts +163 -0
- package/src/__tests__/export-hugo-build.test.ts +5 -5
- package/src/__tests__/export-import-roundtrip.test.ts +1 -1
- package/src/__tests__/export-service.test.ts +2 -2
- package/src/__tests__/fixtures/releases/0.11.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/297kg/_index.md +14 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/2u5e5/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/bought-too-many-lemons-again/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/city-walks/_index.md +14 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/evf9j/_index.md +129 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-draft/_index.md +17 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-quotes/_index.md +13 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-text-attachment/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/j4v0q/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +40 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +50 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/data/jant.toml +155 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/_redirects +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/3c46a9ea6fe0-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m50607a6e8h8gfpa8byqtt7h.md +3 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/snapshot/db.sql +339 -0
- package/src/__tests__/fixtures/releases/0.11.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/d1-round-trips.ts +213 -0
- package/src/__tests__/package-dependencies.test.ts +123 -0
- package/src/__tests__/public-page-round-trips.test.ts +203 -0
- package/src/__tests__/template-deploy-workflow.test.ts +33 -77
- package/src/__tests__/vite-config.test.ts +32 -0
- package/src/app.tsx +7 -1
- package/src/client/icons.ts +5 -6
- package/src/db/__tests__/d1-query.test.ts +29 -0
- package/src/db/__tests__/migration-rehearsal.test.ts +2 -2
- package/src/lib/__tests__/icons.test.ts +21 -10
- package/src/lib/api-posts.ts +4 -2
- package/src/lib/api-public-posts.ts +4 -2
- package/src/lib/constants.ts +20 -0
- package/src/lib/icons.ts +96 -34
- package/src/lib/post-display.ts +13 -9
- package/src/lib/timeline.ts +23 -21
- package/src/lib/view.ts +3 -2
- package/src/middleware/__tests__/onboarding.test.ts +5 -3
- package/src/middleware/__tests__/secure-headers.test.ts +40 -42
- package/src/middleware/config.ts +44 -2
- package/src/middleware/onboarding.ts +12 -3
- package/src/middleware/secure-headers.ts +25 -36
- package/src/node/__tests__/cli-deploy-setup.test.ts +373 -0
- package/src/node/__tests__/cli-deploy.test.ts +55 -0
- package/src/routes/feed/feed.ts +4 -2
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +10 -10
- package/src/routes/pages/archive.tsx +36 -17
- package/src/routes/pages/collection.tsx +72 -35
- package/src/routes/pages/page.tsx +46 -25
- package/src/routes/pages/search.tsx +3 -1
- package/src/services/__tests__/collection.test.ts +2 -4
- package/src/services/collection.ts +95 -71
- package/src/services/export.ts +2 -1
- package/src/services/post.ts +150 -205
- package/src/services/settings.ts +4 -8
- package/src/types/app-context.ts +5 -0
- package/src/ui/pages/ArchivePage.tsx +34 -34
- package/src/ui/pages/CollectionPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -2
- package/src/ui/pages/SubscribePage.tsx +2 -4
- package/src/ui/shared/CollectionDirectory.tsx +2 -2
- package/src/ui/shared/CollectionsManager.tsx +1 -1
- package/src/ui/shared/CopyField.tsx +1 -1
- package/src/ui/shared/Icon.tsx +5 -5
- package/src/ui/shared/IconSprite.tsx +10 -11
- package/src/ui/shared/custom-icons.ts +38 -7
- package/src/ui/shared/icon-collector.ts +7 -5
|
@@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { resolveWorkerDevProcessOptions } from "../../vite.config.js";
|
|
6
|
+
import { stripJsxImportSourcePragmas } from "../../vite.config.worker.js";
|
|
6
7
|
|
|
7
8
|
describe("worker Vite config", () => {
|
|
8
9
|
const tempDirs: string[] = [];
|
|
@@ -43,3 +44,34 @@ describe("worker Vite config", () => {
|
|
|
43
44
|
);
|
|
44
45
|
});
|
|
45
46
|
});
|
|
47
|
+
|
|
48
|
+
describe("library Vite config", () => {
|
|
49
|
+
it("drops the JSX pragma TipTap leaves in its compiled extensions", () => {
|
|
50
|
+
const chunk = [
|
|
51
|
+
"//#region src/blockquote.tsx",
|
|
52
|
+
"/** @jsxImportSource @tiptap/core */",
|
|
53
|
+
"/**",
|
|
54
|
+
"* Matches a blockquote to a `>` as input.",
|
|
55
|
+
"*/",
|
|
56
|
+
"const inputRegex = /^\\s*>\\s$/;",
|
|
57
|
+
"",
|
|
58
|
+
].join("\n");
|
|
59
|
+
|
|
60
|
+
expect(stripJsxImportSourcePragmas(chunk)).toBe(
|
|
61
|
+
[
|
|
62
|
+
"//#region src/blockquote.tsx",
|
|
63
|
+
"/**",
|
|
64
|
+
"* Matches a blockquote to a `>` as input.",
|
|
65
|
+
"*/",
|
|
66
|
+
"const inputRegex = /^\\s*>\\s$/;",
|
|
67
|
+
"",
|
|
68
|
+
].join("\n"),
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("leaves a chunk without the pragma unchanged", () => {
|
|
73
|
+
const chunk = "/** Renders a post. */\nexport function render() {}\n";
|
|
74
|
+
|
|
75
|
+
expect(stripJsxImportSourcePragmas(chunk)).toBe(chunk);
|
|
76
|
+
});
|
|
77
|
+
});
|
package/src/app.tsx
CHANGED
|
@@ -78,7 +78,7 @@ import { attachSession } from "./middleware/session.js";
|
|
|
78
78
|
import { defaultCacheControl, noStore } from "./middleware/cache-control.js";
|
|
79
79
|
import { requireOnboarding } from "./middleware/onboarding.js";
|
|
80
80
|
import { errorHandler, notFoundHandler } from "./middleware/error-handler.js";
|
|
81
|
-
import { withConfig } from "./middleware/config.js";
|
|
81
|
+
import { prefetchSettings, withConfig } from "./middleware/config.js";
|
|
82
82
|
import { secureHeadersMiddleware } from "./middleware/secure-headers.js";
|
|
83
83
|
import { apiCors } from "./middleware/cors.js";
|
|
84
84
|
import { rejectCrossOriginWrites } from "./middleware/cross-origin.js";
|
|
@@ -479,6 +479,12 @@ export function createApp(): HonoApp {
|
|
|
479
479
|
|
|
480
480
|
// --- Middleware for all remaining routes ---
|
|
481
481
|
|
|
482
|
+
// Every route below renders with the site's settings. Start reading them
|
|
483
|
+
// now, so the read shares a round trip with the stored-redirect lookup
|
|
484
|
+
// below rather than following it; the onboarding gate and `withConfig()`
|
|
485
|
+
// both take this one read.
|
|
486
|
+
app.use("*", prefetchSettings());
|
|
487
|
+
|
|
482
488
|
// Onboarding gate — redirect to /setup if not yet initialized
|
|
483
489
|
app.use("*", requireOnboarding());
|
|
484
490
|
|
package/src/client/icons.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inline SVG for the few Lucide icons client components render themselves.
|
|
3
3
|
*
|
|
4
|
-
* Server-rendered UI goes through `lib/icons.ts`, which
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* stroke class appended.
|
|
4
|
+
* Server-rendered UI goes through `lib/icons.ts`, which carries every icon
|
|
5
|
+
* the server draws. Client code must not import that module — one icon lookup
|
|
6
|
+
* would ship all of them to the browser — so the handful of icons a component
|
|
7
|
+
* needs at runtime live here as literal markup, copied from `lucide-static`
|
|
8
|
+
* with the project's `icon-fine` stroke class appended.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/** Lucide `funnel`, the marker for a smart collection. */
|
|
@@ -83,6 +83,35 @@ describe("d1-query Wrangler error parsing", () => {
|
|
|
83
83
|
expect(runLocalWranglerMock).toHaveBeenCalledTimes(1);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
it("surfaces the JSON error on stdout over a warning on stderr", () => {
|
|
87
|
+
// What Wrangler printed for a site whose wrangler.toml named the D1
|
|
88
|
+
// binding something other than `DB`, on a machine behind a proxy.
|
|
89
|
+
runLocalWranglerMock.mockImplementationOnce(() => {
|
|
90
|
+
throw Object.assign(new Error("Command failed"), {
|
|
91
|
+
stdout:
|
|
92
|
+
"\n" +
|
|
93
|
+
JSON.stringify(
|
|
94
|
+
{
|
|
95
|
+
error: {
|
|
96
|
+
text: "Couldn't find a D1 DB with name or binding 'DB' in your config or the API. Run 'wrangler d1 create DB' to create it.",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
null,
|
|
100
|
+
2,
|
|
101
|
+
) +
|
|
102
|
+
"\n",
|
|
103
|
+
stderr:
|
|
104
|
+
"\x1B[33m▲ \x1B[43;33m[\x1B[43;30mWARNING\x1B[43;33m]\x1B[0m \x1B[1mProxy environment variables detected. We'll use your proxy for fetch requests.\x1B[0m\n\n\n",
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(() =>
|
|
109
|
+
queryD1("SELECT 1", "d1-remote", { retryAttempts: 1 }),
|
|
110
|
+
).toThrow(
|
|
111
|
+
"Wrangler error: Couldn't find a D1 DB with name or binding 'DB' in your config or the API.",
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
86
115
|
it("allows tracked migrations to disable transient retries", () => {
|
|
87
116
|
runLocalWranglerMock.mockImplementationOnce(() => {
|
|
88
117
|
throw createWranglerError("fetch failed");
|
|
@@ -42,8 +42,8 @@ function queryLocalCount(persistDir: string, sql: string) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* `v0.3.39` is
|
|
46
|
-
*
|
|
45
|
+
* `v0.3.39` is a site written by that release itself, older than any site
|
|
46
|
+
* still running, so the rehearsal starts below every real upgrade. `pinned-reply-memberships` starts
|
|
47
47
|
* later, from data that release couldn't hold. The rehearsal command checks
|
|
48
48
|
* each manifest's assertions; this checks it ran to the end.
|
|
49
49
|
*/
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getIconSvg } from "../icons.js";
|
|
2
|
+
import { getIconInnerSvg, getIconSvg, LUCIDE_ICON_NAMES } from "../icons.js";
|
|
3
3
|
|
|
4
4
|
describe("getIconSvg", () => {
|
|
5
|
-
it("returns SVG for a
|
|
6
|
-
const svg = getIconSvg("
|
|
5
|
+
it("returns the Lucide SVG for a name", () => {
|
|
6
|
+
const svg = getIconSvg("rss");
|
|
7
7
|
expect(svg).toContain("<svg");
|
|
8
|
-
expect(svg).toContain("lucide-
|
|
8
|
+
expect(svg).toContain('class="lucide lucide-rss"');
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
it("
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
it("appends extra classes to Lucide's own", () => {
|
|
12
|
+
expect(getIconSvg("funnel", "icon-fine")).toContain(
|
|
13
|
+
'class="lucide lucide-funnel icon-fine"',
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// A name maps to an import by hand, so the type check can't see
|
|
18
|
+
// `"arrow-left": ArrowRight`. Lucide names its own class after the icon.
|
|
19
|
+
it.each(LUCIDE_ICON_NAMES)("lists %s under its Lucide name", (name) => {
|
|
20
|
+
expect(getIconSvg(name)).toContain(`class="lucide lucide-${name}"`);
|
|
15
21
|
});
|
|
22
|
+
});
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
describe("getIconInnerSvg", () => {
|
|
25
|
+
it("returns the children without the <svg> wrapper", () => {
|
|
26
|
+
const inner = getIconInnerSvg("pencil");
|
|
27
|
+
expect(inner).toContain("<path");
|
|
28
|
+
expect(inner).not.toContain("<svg");
|
|
29
|
+
expect(inner).not.toContain("</svg>");
|
|
19
30
|
});
|
|
20
31
|
});
|
package/src/lib/api-posts.ts
CHANGED
|
@@ -329,7 +329,9 @@ export async function loadApiPostResponses(
|
|
|
329
329
|
services.media.getByPostIds(postIds),
|
|
330
330
|
services.posts.countThreadPosts(posts.map((post) => post.threadId)),
|
|
331
331
|
options.collectionIds
|
|
332
|
-
? services.collections.
|
|
332
|
+
? services.collections.getCollectionsByThreadIds(
|
|
333
|
+
posts.map((post) => post.threadId),
|
|
334
|
+
)
|
|
333
335
|
: Promise.resolve(null),
|
|
334
336
|
]);
|
|
335
337
|
|
|
@@ -343,7 +345,7 @@ export async function loadApiPostResponses(
|
|
|
343
345
|
),
|
|
344
346
|
...(collectionsMap
|
|
345
347
|
? {
|
|
346
|
-
collectionIds: (collectionsMap.get(post.
|
|
348
|
+
collectionIds: (collectionsMap.get(post.threadId) ?? []).map(
|
|
347
349
|
(collection) => collection.id,
|
|
348
350
|
),
|
|
349
351
|
}
|
|
@@ -220,7 +220,9 @@ export async function loadPublicPostResponses(
|
|
|
220
220
|
const [mediaMap, collectionsMap, threadPostCounts, aliases] =
|
|
221
221
|
await Promise.all([
|
|
222
222
|
services.media.getByPostIds(postIds),
|
|
223
|
-
services.collections.
|
|
223
|
+
services.collections.getCollectionsByThreadIds(
|
|
224
|
+
posts.map((post) => post.threadId),
|
|
225
|
+
),
|
|
224
226
|
services.posts.countThreadPosts(posts.map((post) => post.threadId)),
|
|
225
227
|
services.paths.getPostAliases(postIds),
|
|
226
228
|
]);
|
|
@@ -230,7 +232,7 @@ export async function loadPublicPostResponses(
|
|
|
230
232
|
post,
|
|
231
233
|
{
|
|
232
234
|
media: mediaMap.get(post.id) ?? [],
|
|
233
|
-
collections: collectionsMap.get(post.
|
|
235
|
+
collections: collectionsMap.get(post.threadId) ?? [],
|
|
234
236
|
threadPostCount: threadPostCounts.get(post.threadId) ?? 0,
|
|
235
237
|
aliasPath: aliases.get(post.id)?.[0],
|
|
236
238
|
},
|
package/src/lib/constants.ts
CHANGED
|
@@ -123,3 +123,23 @@ export const ONBOARDING_STATUS = {
|
|
|
123
123
|
|
|
124
124
|
export type OnboardingStatus =
|
|
125
125
|
(typeof ONBOARDING_STATUS)[keyof typeof ONBOARDING_STATUS];
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Read the stored `ONBOARDING_STATUS` setting. Anything but a known later
|
|
129
|
+
* stage, including no value at all, is `pending`.
|
|
130
|
+
*
|
|
131
|
+
* @param value - The stored setting, if any
|
|
132
|
+
* @returns How far first-run setup has got
|
|
133
|
+
* @example
|
|
134
|
+
* parseOnboardingStatus("completed"); // "completed"
|
|
135
|
+
* parseOnboardingStatus(undefined); // "pending"
|
|
136
|
+
*/
|
|
137
|
+
export function parseOnboardingStatus(
|
|
138
|
+
value: string | null | undefined,
|
|
139
|
+
): OnboardingStatus {
|
|
140
|
+
if (value === ONBOARDING_STATUS.COMPLETED) return ONBOARDING_STATUS.COMPLETED;
|
|
141
|
+
if (value === ONBOARDING_STATUS.PROVISIONED) {
|
|
142
|
+
return ONBOARDING_STATUS.PROVISIONED;
|
|
143
|
+
}
|
|
144
|
+
return ONBOARDING_STATUS.PENDING;
|
|
145
|
+
}
|
package/src/lib/icons.ts
CHANGED
|
@@ -1,43 +1,109 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lucide icons for server-rendered UI.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Every icon the server draws is imported here by name and listed in
|
|
5
|
+
* `LUCIDE_ICONS`, so the build keeps these few and drops the rest of the
|
|
6
|
+
* 1,700-icon `lucide-static` set, and an unknown or misspelled name fails the
|
|
7
|
+
* type check instead of rendering nothing. To use another icon, import it and
|
|
8
|
+
* add it under its Lucide name (lucide.dev).
|
|
6
9
|
*/
|
|
7
10
|
|
|
8
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
ArrowLeft,
|
|
13
|
+
ArrowRight,
|
|
14
|
+
Calendar,
|
|
15
|
+
ChevronDown,
|
|
16
|
+
Clock,
|
|
17
|
+
ExternalLink,
|
|
18
|
+
EyeOff,
|
|
19
|
+
File as FileIcon,
|
|
20
|
+
FileText,
|
|
21
|
+
Funnel,
|
|
22
|
+
GitBranch,
|
|
23
|
+
GitCommitHorizontal,
|
|
24
|
+
Globe,
|
|
25
|
+
History as HistoryIcon,
|
|
26
|
+
Image as ImageIcon,
|
|
27
|
+
LayoutGrid,
|
|
28
|
+
List,
|
|
29
|
+
ListTree,
|
|
30
|
+
Lock as LockIcon,
|
|
31
|
+
Monitor,
|
|
32
|
+
Music,
|
|
33
|
+
NotepadText,
|
|
34
|
+
Pencil,
|
|
35
|
+
Play,
|
|
36
|
+
Plus,
|
|
37
|
+
Quote,
|
|
38
|
+
Rss,
|
|
39
|
+
ScanEye,
|
|
40
|
+
Shapes,
|
|
41
|
+
TextAlignStart,
|
|
42
|
+
Trash2,
|
|
43
|
+
Type,
|
|
44
|
+
Video,
|
|
45
|
+
X,
|
|
46
|
+
} from "lucide-static";
|
|
9
47
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
48
|
+
const LUCIDE_ICONS = {
|
|
49
|
+
"arrow-left": ArrowLeft,
|
|
50
|
+
"arrow-right": ArrowRight,
|
|
51
|
+
calendar: Calendar,
|
|
52
|
+
"chevron-down": ChevronDown,
|
|
53
|
+
clock: Clock,
|
|
54
|
+
"external-link": ExternalLink,
|
|
55
|
+
"eye-off": EyeOff,
|
|
56
|
+
file: FileIcon,
|
|
57
|
+
"file-text": FileText,
|
|
58
|
+
funnel: Funnel,
|
|
59
|
+
"git-branch": GitBranch,
|
|
60
|
+
"git-commit-horizontal": GitCommitHorizontal,
|
|
61
|
+
globe: Globe,
|
|
62
|
+
history: HistoryIcon,
|
|
63
|
+
image: ImageIcon,
|
|
64
|
+
"layout-grid": LayoutGrid,
|
|
65
|
+
list: List,
|
|
66
|
+
"list-tree": ListTree,
|
|
67
|
+
lock: LockIcon,
|
|
68
|
+
monitor: Monitor,
|
|
69
|
+
music: Music,
|
|
70
|
+
"notepad-text": NotepadText,
|
|
71
|
+
pencil: Pencil,
|
|
72
|
+
play: Play,
|
|
73
|
+
plus: Plus,
|
|
74
|
+
quote: Quote,
|
|
75
|
+
rss: Rss,
|
|
76
|
+
"scan-eye": ScanEye,
|
|
77
|
+
shapes: Shapes,
|
|
78
|
+
"text-align-start": TextAlignStart,
|
|
79
|
+
"trash-2": Trash2,
|
|
80
|
+
type: Type,
|
|
81
|
+
video: Video,
|
|
82
|
+
x: X,
|
|
83
|
+
} as const satisfies Record<string, string>;
|
|
84
|
+
|
|
85
|
+
/** Kebab-case name of a Lucide icon the server renders. */
|
|
86
|
+
export type LucideIconName = keyof typeof LUCIDE_ICONS;
|
|
87
|
+
|
|
88
|
+
/** Every name in `LUCIDE_ICONS`. */
|
|
89
|
+
export const LUCIDE_ICON_NAMES = Object.keys(LUCIDE_ICONS) as LucideIconName[];
|
|
22
90
|
|
|
23
91
|
/**
|
|
24
|
-
* Get SVG markup for a Lucide icon
|
|
92
|
+
* Get SVG markup for a Lucide icon.
|
|
25
93
|
*
|
|
26
|
-
* @param name - Kebab-case icon name
|
|
94
|
+
* @param name - Kebab-case Lucide icon name
|
|
27
95
|
* @param className - Extra classes for the `<svg>`, appended to Lucide's own.
|
|
28
96
|
* `icon-fine` is the project's lighter stroke.
|
|
29
|
-
* @returns
|
|
97
|
+
* @returns The `<svg>` element as a string
|
|
30
98
|
*
|
|
31
99
|
* @example
|
|
32
100
|
* ```ts
|
|
33
|
-
* getIconSvg("
|
|
101
|
+
* getIconSvg("rss");
|
|
34
102
|
* getIconSvg("funnel", "icon-fine");
|
|
35
103
|
* ```
|
|
36
104
|
*/
|
|
37
|
-
export function getIconSvg(name:
|
|
38
|
-
const
|
|
39
|
-
const svg = (lucideIcons as Record<string, string>)[pascalName];
|
|
40
|
-
if (typeof svg !== "string") return null;
|
|
105
|
+
export function getIconSvg(name: LucideIconName, className?: string): string {
|
|
106
|
+
const svg = LUCIDE_ICONS[name];
|
|
41
107
|
if (!className) return svg;
|
|
42
108
|
// Lucide always ships a `class="lucide lucide-…"`, so extend it rather than
|
|
43
109
|
// adding a second class attribute the parser would drop.
|
|
@@ -49,25 +115,21 @@ export function getIconSvg(name: string, className?: string): string | null {
|
|
|
49
115
|
* without the outer <svg> wrapper). Used by the icon sprite to build
|
|
50
116
|
* <symbol> definitions.
|
|
51
117
|
*
|
|
52
|
-
* @param name - Kebab-case icon name
|
|
53
|
-
* @returns Inner SVG markup (e.g. "<path ... />")
|
|
118
|
+
* @param name - Kebab-case Lucide icon name
|
|
119
|
+
* @returns Inner SVG markup (e.g. "<path ... />")
|
|
54
120
|
*
|
|
55
121
|
* @example
|
|
56
122
|
* ```ts
|
|
57
|
-
* getIconInnerSvg("
|
|
123
|
+
* getIconInnerSvg("pencil");
|
|
58
124
|
* // -> "<path d=\"...\"/><path d=\"...\"/>"
|
|
59
125
|
* ```
|
|
60
126
|
*/
|
|
61
|
-
export function getIconInnerSvg(name:
|
|
62
|
-
const svg =
|
|
63
|
-
if (!svg) return null;
|
|
127
|
+
export function getIconInnerSvg(name: LucideIconName): string {
|
|
128
|
+
const svg = LUCIDE_ICONS[name];
|
|
64
129
|
// lucide-static output looks like:
|
|
65
130
|
// <svg ... viewBox="0 0 24 24" ...><path .../>...<line .../></svg>
|
|
66
131
|
// Strip the outer <svg ...> and </svg>.
|
|
67
|
-
|
|
68
|
-
const closeTagStart = svg.lastIndexOf("</svg>");
|
|
69
|
-
if (openTagEnd < 0 || closeTagStart < 0) return null;
|
|
70
|
-
return svg.slice(openTagEnd + 1, closeTagStart);
|
|
132
|
+
return svg.slice(svg.indexOf(">") + 1, svg.lastIndexOf("</svg>"));
|
|
71
133
|
}
|
|
72
134
|
|
|
73
135
|
/**
|
package/src/lib/post-display.ts
CHANGED
|
@@ -128,7 +128,7 @@ export async function assemblePostCardView(
|
|
|
128
128
|
const [rawMediaMap, collectionsMap, lastPostMap, draftTailMap, aliasesMap] =
|
|
129
129
|
await Promise.all([
|
|
130
130
|
c.var.services.media.getByPostIds([post.id]),
|
|
131
|
-
c.var.services.collections.
|
|
131
|
+
c.var.services.collections.getCollectionsByThreadIds([post.threadId]),
|
|
132
132
|
c.var.services.posts.getThreadTailIds([post.threadId]),
|
|
133
133
|
c.var.isAuthenticated
|
|
134
134
|
? c.var.services.posts.getThreadTailIds([post.threadId], {
|
|
@@ -149,7 +149,7 @@ export async function assemblePostCardView(
|
|
|
149
149
|
const view = toPostView(
|
|
150
150
|
{ ...post, mediaAttachments: mediaMap.get(post.id) ?? [] },
|
|
151
151
|
mediaCtx,
|
|
152
|
-
collectionsMap.get(post.
|
|
152
|
+
collectionsMap.get(post.threadId),
|
|
153
153
|
lastPostMap.get(post.threadId) === post.id,
|
|
154
154
|
aliasesMap.get(post.id)?.[0],
|
|
155
155
|
);
|
|
@@ -194,19 +194,23 @@ export async function assemblePostPageDisplay(
|
|
|
194
194
|
const includeDrafts = Boolean(
|
|
195
195
|
options?.includeDraftThread || c.var.isAuthenticated,
|
|
196
196
|
);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
// Collections belong to the Thread, so they need nothing from its posts
|
|
198
|
+
// and load alongside them.
|
|
199
|
+
const [thread, collectionsByThread] = await Promise.all([
|
|
200
|
+
c.var.services.posts.getThread(post.threadId),
|
|
201
|
+
c.var.services.collections.getCollectionsByThreadIds([post.threadId]),
|
|
202
|
+
]);
|
|
203
|
+
const threadPosts = thread.filter(
|
|
200
204
|
(threadPost) =>
|
|
201
205
|
threadPost.status === "published" ||
|
|
202
206
|
(includeDrafts && threadPost.status === "draft"),
|
|
203
207
|
);
|
|
208
|
+
const threadCollections = collectionsByThread.get(post.threadId);
|
|
204
209
|
|
|
205
210
|
const allPostIds =
|
|
206
211
|
threadPosts.length > 1 ? threadPosts.map((p) => p.id) : [post.id];
|
|
207
|
-
const [rawMediaMap,
|
|
212
|
+
const [rawMediaMap, aliasesMap] = await Promise.all([
|
|
208
213
|
c.var.services.media.getByPostIds(allPostIds),
|
|
209
|
-
c.var.services.collections.getCollectionsByPostIds(allPostIds),
|
|
210
214
|
c.var.services.paths.getPostAliases(allPostIds),
|
|
211
215
|
]);
|
|
212
216
|
const mediaMap = buildMediaMap(
|
|
@@ -222,7 +226,7 @@ export async function assemblePostPageDisplay(
|
|
|
222
226
|
const postView = toPostView(
|
|
223
227
|
{ ...post, mediaAttachments: mediaMap.get(post.id) ?? [] },
|
|
224
228
|
mediaCtx,
|
|
225
|
-
|
|
229
|
+
threadCollections,
|
|
226
230
|
undefined,
|
|
227
231
|
firstAlias(post.id),
|
|
228
232
|
);
|
|
@@ -236,7 +240,7 @@ export async function assemblePostPageDisplay(
|
|
|
236
240
|
mediaAttachments: mediaMap.get(threadPost.id) ?? [],
|
|
237
241
|
},
|
|
238
242
|
mediaCtx,
|
|
239
|
-
|
|
243
|
+
threadCollections,
|
|
240
244
|
index === threadPosts.length - 1,
|
|
241
245
|
firstAlias(threadPost.id),
|
|
242
246
|
),
|
package/src/lib/timeline.ts
CHANGED
|
@@ -95,14 +95,14 @@ async function buildTimelineItems(
|
|
|
95
95
|
const threadIds = posts.map((p) => p.threadId);
|
|
96
96
|
const [
|
|
97
97
|
rawMediaMap,
|
|
98
|
-
|
|
98
|
+
collectionsByThread,
|
|
99
99
|
threadContexts,
|
|
100
100
|
aliasesMap,
|
|
101
101
|
publishedTails,
|
|
102
102
|
draftInclusiveTails,
|
|
103
103
|
] = await Promise.all([
|
|
104
104
|
c.var.services.media.getByPostIds(postIds),
|
|
105
|
-
c.var.services.collections.
|
|
105
|
+
c.var.services.collections.getCollectionsByThreadIds(threadIds),
|
|
106
106
|
c.var.services.posts.getThreadTimelineContext(postIds),
|
|
107
107
|
c.var.services.paths.getPostAliases(postIds),
|
|
108
108
|
// The feed never renders drafts — it would turn a reading surface into a
|
|
@@ -127,7 +127,8 @@ async function buildTimelineItems(
|
|
|
127
127
|
mediaCtx.sitePathPrefix,
|
|
128
128
|
);
|
|
129
129
|
|
|
130
|
-
// Batch load media for the bounded leading/trailing thread context.
|
|
130
|
+
// Batch load media for the bounded leading/trailing thread context. Its
|
|
131
|
+
// collections are its Thread's, already loaded with the roots.
|
|
131
132
|
const contextPostIds = new Set<string>();
|
|
132
133
|
const gapPostIds = new Set<string>();
|
|
133
134
|
for (const ctx of threadContexts.values()) {
|
|
@@ -139,7 +140,7 @@ async function buildTimelineItems(
|
|
|
139
140
|
// only the alias that decides its address.
|
|
140
141
|
if (ctx.firstHiddenReply) gapPostIds.add(ctx.firstHiddenReply.id);
|
|
141
142
|
}
|
|
142
|
-
const [contextMediaMap,
|
|
143
|
+
const [contextMediaMap, contextAliasesMap] =
|
|
143
144
|
contextPostIds.size > 0
|
|
144
145
|
? await Promise.all([
|
|
145
146
|
c.var.services.media
|
|
@@ -154,9 +155,6 @@ async function buildTimelineItems(
|
|
|
154
155
|
mediaCtx.sitePathPrefix,
|
|
155
156
|
),
|
|
156
157
|
),
|
|
157
|
-
c.var.services.collections.getCollectionsByPostIds([
|
|
158
|
-
...contextPostIds,
|
|
159
|
-
]),
|
|
160
158
|
// Gap targets ride along here and nowhere else: their address is
|
|
161
159
|
// all the gap link needs.
|
|
162
160
|
c.var.services.paths.getPostAliases([
|
|
@@ -164,7 +162,7 @@ async function buildTimelineItems(
|
|
|
164
162
|
...gapPostIds,
|
|
165
163
|
]),
|
|
166
164
|
])
|
|
167
|
-
: [new Map(), new Map
|
|
165
|
+
: [new Map(), new Map<string, string[]>()];
|
|
168
166
|
|
|
169
167
|
const firstAlias = (id: string) => aliasesMap.get(id)?.[0];
|
|
170
168
|
const firstContextAlias = (id: string) => contextAliasesMap.get(id)?.[0];
|
|
@@ -177,7 +175,7 @@ async function buildTimelineItems(
|
|
|
177
175
|
mediaAttachments: mediaMap.get(post.id) ?? [],
|
|
178
176
|
},
|
|
179
177
|
mediaCtx,
|
|
180
|
-
|
|
178
|
+
collectionsByThread.get(post.threadId),
|
|
181
179
|
undefined,
|
|
182
180
|
firstAlias(post.id),
|
|
183
181
|
);
|
|
@@ -201,7 +199,7 @@ async function buildTimelineItems(
|
|
|
201
199
|
mediaAttachments: contextMediaMap.get(reply.id) ?? [],
|
|
202
200
|
},
|
|
203
201
|
mediaCtx,
|
|
204
|
-
|
|
202
|
+
collectionsByThread.get(reply.threadId),
|
|
205
203
|
false,
|
|
206
204
|
firstContextAlias(reply.id),
|
|
207
205
|
);
|
|
@@ -216,7 +214,7 @@ async function buildTimelineItems(
|
|
|
216
214
|
mediaAttachments: contextMediaMap.get(threadCtx.latestReply.id) ?? [],
|
|
217
215
|
},
|
|
218
216
|
mediaCtx,
|
|
219
|
-
|
|
217
|
+
collectionsByThread.get(threadCtx.latestReply.threadId),
|
|
220
218
|
true, // latestReply is the last published post in the thread
|
|
221
219
|
firstContextAlias(threadCtx.latestReply.id),
|
|
222
220
|
);
|
|
@@ -280,19 +278,23 @@ async function buildCuratedThreadItems(
|
|
|
280
278
|
}
|
|
281
279
|
|
|
282
280
|
const mediaCtx = createMediaContext(c.var.appConfig);
|
|
283
|
-
const
|
|
284
|
-
thread.posts.map(({ post }) => post
|
|
281
|
+
const threadPosts = orderedThreads.flatMap((thread) =>
|
|
282
|
+
thread.posts.map(({ post }) => post),
|
|
285
283
|
);
|
|
284
|
+
const postIds = threadPosts.map((post) => post.id);
|
|
286
285
|
const gapPostIds = orderedThreads.flatMap((thread) =>
|
|
287
286
|
[...thread.gapTargets.values()].map((target) => target.id),
|
|
288
287
|
);
|
|
289
|
-
const [rawMediaMap,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
const [rawMediaMap, collectionsByThread, curatedAliasesMap] =
|
|
289
|
+
await Promise.all([
|
|
290
|
+
c.var.services.media.getByPostIds(postIds),
|
|
291
|
+
c.var.services.collections.getCollectionsByThreadIds(
|
|
292
|
+
threadPosts.map((post) => post.threadId),
|
|
293
|
+
),
|
|
294
|
+
// Gap targets are never rendered, so they need only the alias that
|
|
295
|
+
// decides their address.
|
|
296
|
+
c.var.services.paths.getPostAliases([...postIds, ...gapPostIds]),
|
|
297
|
+
]);
|
|
296
298
|
const mediaMap = buildMediaMap(
|
|
297
299
|
rawMediaMap,
|
|
298
300
|
mediaCtx.r2PublicUrl,
|
|
@@ -317,7 +319,7 @@ async function buildCuratedThreadItems(
|
|
|
317
319
|
mediaAttachments: mediaMap.get(post.id) ?? [],
|
|
318
320
|
},
|
|
319
321
|
mediaCtx,
|
|
320
|
-
|
|
322
|
+
collectionsByThread.get(post.threadId),
|
|
321
323
|
post.id === lastPostId,
|
|
322
324
|
curatedAliasesMap.get(post.id)?.[0],
|
|
323
325
|
post.id === post.threadId &&
|
package/src/lib/view.ts
CHANGED
|
@@ -707,7 +707,8 @@ export function toSearchResultViews(
|
|
|
707
707
|
ctx: MediaContext,
|
|
708
708
|
query?: string,
|
|
709
709
|
aliasMap?: Map<string, string>,
|
|
710
|
-
|
|
710
|
+
/** Collections by Thread id, `collections.getCollectionsByThreadIds()`'s */
|
|
711
|
+
collectionsByThread?: Map<string, Collection[]>,
|
|
711
712
|
): SearchResultView[] {
|
|
712
713
|
return results.map((r) =>
|
|
713
714
|
toSearchResultView(
|
|
@@ -715,7 +716,7 @@ export function toSearchResultViews(
|
|
|
715
716
|
ctx,
|
|
716
717
|
query,
|
|
717
718
|
aliasMap?.get(r.post.id),
|
|
718
|
-
|
|
719
|
+
collectionsByThread?.get(r.post.threadId),
|
|
719
720
|
),
|
|
720
721
|
);
|
|
721
722
|
}
|
|
@@ -15,12 +15,14 @@ function createMockServices(status: OnboardingStatus) {
|
|
|
15
15
|
let callCount = 0;
|
|
16
16
|
const services = {
|
|
17
17
|
settings: {
|
|
18
|
-
|
|
18
|
+
getAll: async () => {
|
|
19
19
|
callCount++;
|
|
20
|
-
return status
|
|
20
|
+
return status === ONBOARDING_STATUS.PENDING
|
|
21
|
+
? {}
|
|
22
|
+
: { ONBOARDING_STATUS: status };
|
|
21
23
|
},
|
|
22
24
|
},
|
|
23
|
-
} as AppVariables["services"];
|
|
25
|
+
} as unknown as AppVariables["services"];
|
|
24
26
|
return { services, getCallCount: () => callCount };
|
|
25
27
|
}
|
|
26
28
|
|