@jant/core 1.0.1 → 1.2.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/lib/site-snapshot.js +10 -0
- package/dist/{app-Gt7_skt6.js → app-CbOZ2Irh.js} +8704 -5180
- package/dist/client/.vite/manifest.json +125 -85
- package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-hWapNE40.js} +26 -26
- package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +2 -0
- package/dist/client/_assets/chunks/{jant-locale-picker-DL6mIOT5.js → jant-locale-picker-2L4rkDaz.js} +1 -1
- package/dist/client/_assets/chunks/lit-Bw_voPoW.js +2 -0
- package/dist/client/_assets/chunks/preload-helper-Czpn1I53.js +1 -0
- package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +1 -0
- package/dist/client/_assets/chunks/{settings-paths-h6RjIe3C.js → settings-paths-BBVT8zKj.js} +1 -1
- package/dist/client/_assets/chunks/slug-format-BuCPjSrB.js +1 -0
- package/dist/client/_assets/chunks/sortable-list-DJXwkaOv.js +2 -0
- package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
- package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +1 -0
- package/dist/client/_assets/client-BO8GOFfT.js +354 -0
- package/dist/client/_assets/client-D8Rrsd73.css +2 -0
- package/dist/client/_assets/client-auth-CsUGM718.js +859 -0
- package/dist/client/_assets/client-author-QPm1whbO.css +2 -0
- package/dist/client/_assets/client-compose-BB4U7Wz0.js +2004 -0
- package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-CI9-eh-8.js} +176 -176
- package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-BnGPuqwc.js} +166 -166
- package/dist/client/_assets/client-share-0DICJjAc.css +1 -0
- package/dist/client/_assets/client-share-C59mOLJ1.js +149 -0
- package/dist/index.js +1 -1
- package/dist/node.js +3 -2
- package/package.json +2 -1
- package/src/app.tsx +9 -0
- package/src/client/components/compose-types.ts +1 -0
- package/src/client/components/jant-compose-dialog.ts +1 -0
- package/src/client/components/jant-compose-editor.ts +30 -0
- package/src/client/components/jant-compose-fullscreen.ts +1 -0
- package/src/client/components/jant-post-menu.ts +80 -13
- package/src/client/components/jant-share-dialog.ts +422 -0
- package/src/client/components/jant-share-menu.ts +188 -0
- package/src/client/compose-bridge.ts +61 -1
- package/src/client/feed-video-player.ts +6 -0
- package/src/client/lazy-entries.ts +21 -1
- package/src/client/post-menu-shared.ts +100 -0
- package/src/client/share-capture.ts +443 -0
- package/src/client/share-launch.ts +133 -0
- package/src/client/tiptap/bubble-menu.ts +25 -2
- package/src/client/tiptap/create-editor.ts +2 -0
- package/src/client/tiptap/extensions.ts +4 -0
- package/src/client/video-processor.ts +106 -52
- package/src/client/view-confirm.ts +108 -0
- package/src/client-share.ts +8 -0
- package/src/client.ts +2 -0
- package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
- package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
- package/src/db/migrations/meta/0035_snapshot.json +2877 -0
- package/src/db/migrations/meta/0036_snapshot.json +2924 -0
- package/src/db/migrations/meta/_journal.json +14 -0
- package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
- package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
- package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
- package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/_journal.json +14 -0
- package/src/db/pg/schema.ts +40 -0
- package/src/db/schema.ts +61 -0
- package/src/i18n/locales/public/en.po +5 -0
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +5 -0
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +5 -0
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +149 -0
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +149 -0
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +149 -0
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/discover.ts +31 -0
- package/src/lib/env.ts +20 -0
- package/src/lib/github-app-state.ts +1 -1
- package/src/lib/github-app.ts +183 -1
- package/src/lib/markdown-manager.ts +129 -1
- package/src/lib/post-meta.ts +13 -3
- package/src/lib/referrer-aliases.ts +311 -0
- package/src/lib/render.tsx +10 -0
- package/src/lib/resolve-config.ts +14 -0
- package/src/lib/share-card.ts +653 -0
- package/src/lib/summary.ts +152 -54
- package/src/lib/tiptap-render.ts +1 -0
- package/src/lib/upload.ts +21 -1
- package/src/lib/version.ts +2 -0
- package/src/lib/video-playback.ts +55 -0
- package/src/lib/view-buffer.ts +201 -0
- package/src/lib/view-counting.ts +539 -0
- package/src/lib/view-token.ts +177 -0
- package/src/lib/view.ts +13 -1
- package/src/middleware/view-counter.ts +140 -0
- package/src/node/runtime.ts +4 -0
- package/src/preset.css +31 -14
- package/src/routes/api/media.ts +21 -3
- package/src/routes/auth/setup.tsx +37 -1
- package/src/routes/dash/settings.tsx +433 -168
- package/src/routes/pages/archive.tsx +1 -0
- package/src/routes/pages/collection.tsx +6 -0
- package/src/routes/pages/collections.tsx +1 -0
- package/src/routes/pages/featured.tsx +1 -0
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/page.tsx +3 -0
- package/src/routes/pages/partials.tsx +23 -0
- package/src/routes/pages/smart-collection.tsx +2 -0
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/view-confirm.ts +63 -0
- package/src/services/export-theme/assets/client-site.js +1 -1
- package/src/services/export-theme/styles/main.css +39 -21
- package/src/services/export.ts +2 -0
- package/src/services/index.ts +17 -0
- package/src/services/mcp.ts +31 -1
- package/src/services/media.ts +63 -0
- package/src/services/stats.ts +1130 -0
- package/src/style-share.css +16 -0
- package/src/styles/components-author.css +177 -0
- package/src/styles/components.css +25 -3
- package/src/styles/share.css +1103 -0
- package/src/styles/tokens.css +65 -30
- package/src/styles/ui.css +62 -13
- package/src/types/app-context.ts +9 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/config.ts +54 -0
- package/src/types/views.ts +6 -0
- package/src/ui/compose/ComposeDialog.tsx +6 -0
- package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
- package/src/ui/dash/settings/StatsContent.tsx +855 -0
- package/src/ui/font-themes.ts +39 -6
- package/src/ui/layouts/BaseLayout.tsx +11 -2
- package/src/ui/layouts/SiteLayout.tsx +9 -3
- package/src/ui/share/ShareCard.tsx +298 -0
- package/src/ui/shared/Icon.tsx +23 -3
- package/src/ui/shared/MediaGallery.tsx +31 -4
- package/src/ui/shared/PostFooter.tsx +20 -4
- package/src/ui/shared/icon-collector.ts +28 -0
- package/src/ui/shared/post-article-attributes.ts +3 -0
- package/dist/client/_assets/chunks/footnote-rail-BJwswtVQ.js +0 -1
- package/dist/client/_assets/chunks/lit-DW8VmJAT.js +0 -2
- package/dist/client/_assets/chunks/slug-format-Dsi0e9Xn.js +0 -1
- package/dist/client/_assets/chunks/sortable-list-DWNKv782.js +0 -2
- package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
- package/dist/client/_assets/chunks/unsafe-svg-DTZZEvLU.js +0 -2
- package/dist/client/_assets/client-BaqmpPQ-.css +0 -2
- package/dist/client/_assets/client-C6melOtG.js +0 -296
- package/dist/client/_assets/client-auth-Ccq8kSqq.js +0 -828
- package/dist/client/_assets/client-author-CGVvrNZ8.css +0 -2
- package/dist/client/_assets/client-compose-oxzPb3SS.js +0 -2004
package/src/services/media.ts
CHANGED
|
@@ -25,8 +25,12 @@ import { markdownToTiptapJson } from "../lib/markdown-to-tiptap.js";
|
|
|
25
25
|
import { extractBodyText } from "../lib/summary.js";
|
|
26
26
|
import { now } from "../lib/time.js";
|
|
27
27
|
import { supportsCopy, type StorageDriver } from "../lib/storage.js";
|
|
28
|
+
import { generateRandomId } from "../lib/nanoid.js";
|
|
28
29
|
import {
|
|
30
|
+
detectPosterMimeType,
|
|
29
31
|
generateStorageKey,
|
|
32
|
+
getPosterExtension,
|
|
33
|
+
getPosterStorageKey,
|
|
30
34
|
imageExtensionForMimeType,
|
|
31
35
|
isAllowedSideloadImageType,
|
|
32
36
|
SITE_ASSET_STORAGE_KEY_LIKE_PATTERN,
|
|
@@ -314,6 +318,24 @@ export interface MediaService {
|
|
|
314
318
|
attachToPost(postId: string, mediaIds: string[]): Promise<void>;
|
|
315
319
|
detachFromPost(postId: string): Promise<void>;
|
|
316
320
|
updateAlt(id: string, alt: string): Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Give a video its poster, or replace the one it has: the still that stands
|
|
323
|
+
* in for the clip in the timeline, share cards, and feeds. A replacement
|
|
324
|
+
* goes to a new key and the old object is deleted, since posters are served
|
|
325
|
+
* `immutable` and one rewritten in place would stay stale in caches.
|
|
326
|
+
*
|
|
327
|
+
* @param id - Media record ID
|
|
328
|
+
* @param bytes - The poster, as WebP or PNG bytes
|
|
329
|
+
* @param deps.storage - Storage driver the poster is written to
|
|
330
|
+
* @returns The updated record, or null when there is no such media
|
|
331
|
+
* @throws ValidationError when the media is not a video, or the bytes are
|
|
332
|
+
* neither WebP nor PNG
|
|
333
|
+
*/
|
|
334
|
+
setPoster(
|
|
335
|
+
id: string,
|
|
336
|
+
bytes: Uint8Array,
|
|
337
|
+
deps: { storage: StorageDriver },
|
|
338
|
+
): Promise<Media | null>;
|
|
317
339
|
}
|
|
318
340
|
|
|
319
341
|
export interface CreateMediaData {
|
|
@@ -954,6 +976,47 @@ export function createMediaService(
|
|
|
954
976
|
.where(and(eq(media.siteId, siteId), eq(media.id, id)));
|
|
955
977
|
},
|
|
956
978
|
|
|
979
|
+
async setPoster(id, bytes, { storage }) {
|
|
980
|
+
const record = await this.getById(id);
|
|
981
|
+
if (!record) return null;
|
|
982
|
+
|
|
983
|
+
if (!record.mimeType.startsWith("video/")) {
|
|
984
|
+
throw new ValidationError(
|
|
985
|
+
`Only a video takes a poster. This media is ${record.mimeType}.`,
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
const contentType = detectPosterMimeType(bytes);
|
|
989
|
+
if (!contentType) {
|
|
990
|
+
throw new ValidationError(
|
|
991
|
+
"Unsupported poster format. Only WebP and PNG are accepted.",
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
const previousKey = record.posterKey;
|
|
996
|
+
const posterKey = getPosterStorageKey(
|
|
997
|
+
siteId,
|
|
998
|
+
id,
|
|
999
|
+
getPosterExtension(contentType),
|
|
1000
|
+
previousKey ? generateRandomId(8) : undefined,
|
|
1001
|
+
);
|
|
1002
|
+
await storage.put(posterKey, bytes, { contentType });
|
|
1003
|
+
await db
|
|
1004
|
+
.update(media)
|
|
1005
|
+
.set({ posterKey, updatedAt: now() })
|
|
1006
|
+
.where(and(eq(media.siteId, siteId), eq(media.id, id)));
|
|
1007
|
+
|
|
1008
|
+
if (previousKey && previousKey !== posterKey) {
|
|
1009
|
+
// The poster is derived from the clip, so the one it replaces goes
|
|
1010
|
+
// straight away rather than through the recycle window.
|
|
1011
|
+
await storage.delete(previousKey).catch((err) => {
|
|
1012
|
+
// eslint-disable-next-line no-console -- Error logging is intentional
|
|
1013
|
+
console.error("Storage delete error:", err);
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
return this.getById(id);
|
|
1018
|
+
},
|
|
1019
|
+
|
|
957
1020
|
async delete(id, storage) {
|
|
958
1021
|
const record = await this.getById(id);
|
|
959
1022
|
if (!record) return false;
|