@jant/core 0.3.47 → 0.3.49
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/{app-3REcR-3U.js → app-C8bKBHtv.js} +72 -5
- package/dist/{app-B67XOEyo.js → app-DxnM9H8F.js} +1 -1
- package/dist/client/.vite/manifest.json +1 -1
- package/dist/client/_assets/{client-s71Js1Cu.css → client-BoUn7xBo.css} +1 -1
- package/dist/index.js +1 -1
- package/dist/node.js +2 -2
- package/package.json +1 -1
- package/src/app.tsx +2 -0
- package/src/lib/api-posts.ts +9 -7
- package/src/routes/api/public/__tests__/archive.test.ts +261 -0
- package/src/routes/api/public/archive.ts +116 -0
- package/src/routes/api/public/posts.ts +5 -5
- package/src/styles/ui.css +2 -2
|
@@ -3418,10 +3418,10 @@ function normalizeThemeColorForMeta(color) {
|
|
|
3418
3418
|
* internal paths (e.g. `/_assets/client-HASH.js`) embedded by the Worker build
|
|
3419
3419
|
* from the Vite client manifest. Used only in production (IS_VITE_DEV=false).
|
|
3420
3420
|
*/ var IS_VITE_DEV = typeof __JANT_DEV__ !== "undefined" && __JANT_DEV__ === true;
|
|
3421
|
-
var CORE_VERSION = "0.3.
|
|
3421
|
+
var CORE_VERSION = "0.3.49-c59b5d15c4832deb";
|
|
3422
3422
|
var CLIENT_JS_FILE = "/_assets/client-dSfWfMe9.js";
|
|
3423
3423
|
var CLIENT_AUTH_JS_FILE = "/_assets/client-auth-Ce5WEAVS.js";
|
|
3424
|
-
var CLIENT_CSS_FILE = "/_assets/client-
|
|
3424
|
+
var CLIENT_CSS_FILE = "/_assets/client-BoUn7xBo.css";
|
|
3425
3425
|
var CLIENT_CJK_CSS_FILE = "/_assets/client-cjk-B7Z0snDu.css";
|
|
3426
3426
|
var CLIENT_CJK_TC_CSS_FILE = "/_assets/client-cjk-tc-BesJYrb2.css";
|
|
3427
3427
|
var CLIENT_CJK_JP_CSS_FILE = "/_assets/client-cjk-jp-DZwrTzQC.css";
|
|
@@ -3739,7 +3739,7 @@ var IconSprite = () => {
|
|
|
3739
3739
|
const cjkSerifFont = appConfig?.cjkSerifFont ?? "off";
|
|
3740
3740
|
const cjkStylesheetPath = cjkSerifFont === "zh-Hans" ? IS_VITE_DEV ? assetPath("/src/style-cjk.css") : toPublicAssetPath(CLIENT_CJK_CSS_FILE, assetBasePath) : cjkSerifFont === "zh-Hant" ? IS_VITE_DEV ? assetPath("/src/style-cjk-tc.css") : toPublicAssetPath(CLIENT_CJK_TC_CSS_FILE, assetBasePath) : cjkSerifFont === "ja" ? IS_VITE_DEV ? assetPath("/src/style-cjk-jp.css") : toPublicAssetPath(CLIENT_CJK_JP_CSS_FILE, assetBasePath) : cjkSerifFont === "ko" ? IS_VITE_DEV ? assetPath("/src/style-cjk-kr.css") : toPublicAssetPath(CLIENT_CJK_KR_CSS_FILE, assetBasePath) : null;
|
|
3741
3741
|
const clientScriptPath = IS_VITE_DEV ? resolvedClientBundle === "full" ? assetPath("/src/client-auth.ts") : assetPath("/src/client.ts") : toPublicAssetPath(resolvedClientBundle === "full" ? CLIENT_AUTH_JS_FILE : CLIENT_JS_FILE, assetBasePath);
|
|
3742
|
-
const faviconAssetVersion = resolvedFaviconVersion || "0.3.
|
|
3742
|
+
const faviconAssetVersion = resolvedFaviconVersion || "0.3.49-c59b5d15c4832deb";
|
|
3743
3743
|
const resolvedFaviconHref = faviconHref ?? (faviconAssetVersion ? toPublicPath(`/favicon.ico?v=${faviconAssetVersion}`, sitePathPrefix) : toPublicPath("/favicon.ico", sitePathPrefix));
|
|
3744
3744
|
const resolvedAppleTouchHref = appleTouchHref ?? (faviconAssetVersion ? toPublicPath(`/apple-touch-icon.png?v=${faviconAssetVersion}`, sitePathPrefix) : toPublicPath("/apple-touch-icon.png", sitePathPrefix));
|
|
3745
3745
|
const socialImageHref = resolvedSocialImagePath && (isFullUrl(resolvedSocialImagePath) || resolvedSocialImagePath.startsWith("//") ? resolvedSocialImagePath : toAbsoluteSiteUrl(resolvedSocialImagePath, appConfig?.siteUrl || "", sitePathPrefix));
|
|
@@ -21952,13 +21952,13 @@ function toApiAttachment(media, r2PublicUrl, imageTransformUrl, s3PublicUrl, loc
|
|
|
21952
21952
|
summary: media.summary,
|
|
21953
21953
|
chars: media.chars
|
|
21954
21954
|
};
|
|
21955
|
-
const previewUrl = getImageUrl(url, imageTransformUrl, {
|
|
21955
|
+
const previewUrl = media.mimeType.startsWith("image/") ? getImageUrl(url, imageTransformUrl, {
|
|
21956
21956
|
width: 1200,
|
|
21957
21957
|
height: 768,
|
|
21958
21958
|
quality: 80,
|
|
21959
21959
|
format: "auto",
|
|
21960
21960
|
fit: "scale-down"
|
|
21961
|
-
});
|
|
21961
|
+
}) : url;
|
|
21962
21962
|
const posterUrl = media.posterKey ? getMediaUrl(media.posterKey, publicUrl, sitePathPrefix) : null;
|
|
21963
21963
|
return {
|
|
21964
21964
|
type: "media",
|
|
@@ -25344,6 +25344,72 @@ publicPostsApiRoutes.get("/:slug", async (c) => {
|
|
|
25344
25344
|
return c.json(toPublicPost(post, mediaList, postCollections, c.var.appConfig, { content }));
|
|
25345
25345
|
});
|
|
25346
25346
|
//#endregion
|
|
25347
|
+
//#region src/routes/api/public/archive.ts
|
|
25348
|
+
var publicArchiveApiRoutes = new Hono();
|
|
25349
|
+
var MediaKindSchema = z.enum(MEDIA_KINDS);
|
|
25350
|
+
var INVALID_MEDIA_KIND_MESSAGE = "Invalid media kind. Allowed: " + MEDIA_KINDS.join(", ");
|
|
25351
|
+
var BoolFlagSchema = z.enum(["0", "1"]).transform((value) => value === "1");
|
|
25352
|
+
var ListPublicArchiveQuerySchema = z.object({
|
|
25353
|
+
format: FormatSchema.optional(),
|
|
25354
|
+
collection: z.string().optional(),
|
|
25355
|
+
year: z.coerce.number().int().min(1971).optional(),
|
|
25356
|
+
media: z.string().optional().transform((value, ctx) => {
|
|
25357
|
+
if (!value) return void 0;
|
|
25358
|
+
const parts = value.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
25359
|
+
if (parts.length === 0) return void 0;
|
|
25360
|
+
const result = z.array(MediaKindSchema).safeParse(parts);
|
|
25361
|
+
if (!result.success) {
|
|
25362
|
+
ctx.addIssue({
|
|
25363
|
+
code: z.ZodIssueCode.custom,
|
|
25364
|
+
message: INVALID_MEDIA_KIND_MESSAGE
|
|
25365
|
+
});
|
|
25366
|
+
return z.NEVER;
|
|
25367
|
+
}
|
|
25368
|
+
return result.data;
|
|
25369
|
+
}),
|
|
25370
|
+
hasMedia: BoolFlagSchema.optional(),
|
|
25371
|
+
hasTitle: BoolFlagSchema.optional(),
|
|
25372
|
+
cursor: z.string().optional(),
|
|
25373
|
+
limit: z.coerce.number().int().min(1).max(100).optional().default(20),
|
|
25374
|
+
content: z.enum(["markdown"]).optional()
|
|
25375
|
+
});
|
|
25376
|
+
publicArchiveApiRoutes.get("/", async (c) => {
|
|
25377
|
+
const { format, collection, year, media, hasMedia, hasTitle, cursor, limit, content } = parseValidated(ListPublicArchiveQuerySchema, c.req.query());
|
|
25378
|
+
let collectionIds;
|
|
25379
|
+
if (collection) {
|
|
25380
|
+
const slugExpression = collection.replace(/,/g, "+");
|
|
25381
|
+
const selection = await c.var.services.collections.resolveSelection(slugExpression);
|
|
25382
|
+
if (!selection || selection.collections.length === 0) return c.json({
|
|
25383
|
+
posts: [],
|
|
25384
|
+
nextCursor: null
|
|
25385
|
+
});
|
|
25386
|
+
collectionIds = selection.collections.map((col) => col.id);
|
|
25387
|
+
}
|
|
25388
|
+
const publishedAfter = year !== void 0 ? Date.UTC(year, 0, 1) / 1e3 : void 0;
|
|
25389
|
+
const publishedBefore = year !== void 0 ? Date.UTC(year + 1, 0, 1) / 1e3 : void 0;
|
|
25390
|
+
const posts = await c.var.services.posts.list({
|
|
25391
|
+
format,
|
|
25392
|
+
collectionIds,
|
|
25393
|
+
status: "published",
|
|
25394
|
+
cursor: cursor ?? void 0,
|
|
25395
|
+
limit,
|
|
25396
|
+
excludePrivate: true,
|
|
25397
|
+
excludeLatestHidden: false,
|
|
25398
|
+
excludeReplies: true,
|
|
25399
|
+
publishedAfter,
|
|
25400
|
+
publishedBefore,
|
|
25401
|
+
mediaKinds: media,
|
|
25402
|
+
hasMedia,
|
|
25403
|
+
hasTitle
|
|
25404
|
+
});
|
|
25405
|
+
const postIds = posts.map((post) => post.id);
|
|
25406
|
+
const [mediaMap, collectionsMap] = await Promise.all([c.var.services.media.getByPostIds(postIds), c.var.services.collections.getCollectionsByPostIds(postIds)]);
|
|
25407
|
+
return c.json({
|
|
25408
|
+
posts: posts.map((post) => toPublicPost(post, mediaMap.get(post.id) ?? [], collectionsMap.get(post.id) ?? [], c.var.appConfig, { content })),
|
|
25409
|
+
nextCursor: posts.length === limit ? posts[posts.length - 1]?.id ?? null : null
|
|
25410
|
+
});
|
|
25411
|
+
});
|
|
25412
|
+
//#endregion
|
|
25347
25413
|
//#region src/routes/compose.tsx
|
|
25348
25414
|
/**
|
|
25349
25415
|
* Compose Route
|
|
@@ -31993,6 +32059,7 @@ async function servePublicStorage(c) {
|
|
|
31993
32059
|
app.use("*", withConfig());
|
|
31994
32060
|
app.use("*", i18nMiddleware());
|
|
31995
32061
|
app.route("/api/public/posts", publicPostsApiRoutes);
|
|
32062
|
+
app.route("/api/public/archive", publicArchiveApiRoutes);
|
|
31996
32063
|
app.route("/api/posts", postsApiRoutes);
|
|
31997
32064
|
app.route("/api/nav-items", navItemsApiRoutes);
|
|
31998
32065
|
app.route("/api/collections", collectionsApiRoutes);
|