@matterandmotion/emdash-comics 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +114 -2
- package/dist/batches.d.ts +84 -0
- package/dist/batches.d.ts.map +1 -0
- package/dist/batches.js +101 -0
- package/dist/batches.js.map +1 -0
- package/dist/blocks.d.ts +26 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +45 -0
- package/dist/blocks.js.map +1 -0
- package/dist/id.d.ts +3 -0
- package/dist/id.d.ts.map +1 -0
- package/dist/id.js +3 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy-redirects.d.ts +15 -0
- package/dist/legacy-redirects.d.ts.map +1 -0
- package/dist/legacy-redirects.js +58 -0
- package/dist/legacy-redirects.js.map +1 -0
- package/dist/media.d.ts +26 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +48 -0
- package/dist/media.js.map +1 -0
- package/dist/transcripts.d.ts +10 -0
- package/dist/transcripts.d.ts.map +1 -0
- package/dist/transcripts.js +22 -0
- package/dist/transcripts.js.map +1 -0
- package/package.json +67 -3
- package/profile/index.d.mts +46 -0
- package/profile/index.mjs +197 -0
- package/src/admin/BulkUploadPage.tsx +1004 -0
- package/src/admin/ComicPagesField.tsx +202 -0
- package/src/admin/bulk/api.ts +215 -0
- package/src/admin/bulk/config.ts +87 -0
- package/src/admin/bulk/files.ts +76 -0
- package/src/admin/bulk/history.ts +45 -0
- package/src/admin/bulk/plan.ts +446 -0
- package/src/admin/fingerprint.ts +26 -0
- package/src/admin/index.tsx +19 -0
- package/src/admin/media.ts +75 -0
- package/src/admin/pickers.tsx +132 -0
- package/src/admin/segments.ts +36 -0
- package/src/admin/slice.ts +46 -0
- package/src/admin/types.ts +47 -0
- package/src/astro/AgeGate.astro +85 -0
- package/src/astro/ArchiveGrid.astro +79 -0
- package/src/astro/CastGrid.astro +63 -0
- package/src/astro/ChapterList.astro +57 -0
- package/src/astro/CharacterCard.astro +54 -0
- package/src/astro/ComicEmbed.astro +55 -0
- package/src/astro/ComicNav.astro +131 -0
- package/src/astro/ComicReader.astro +193 -0
- package/src/astro/ContentWarnings.astro +61 -0
- package/src/astro/Transcript.astro +43 -0
- package/src/astro/astro-modules.d.ts +6 -0
- package/src/astro/blocks.ts +11 -0
- package/src/astro/index.ts +20 -0
- package/src/batches.ts +154 -0
- package/src/blocks.ts +46 -0
- package/src/id.ts +2 -0
- package/src/index.ts +152 -0
- package/src/legacy-redirects.ts +59 -0
- package/src/media.ts +60 -0
- package/src/transcripts.ts +20 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-redirects.d.ts","sourceRoot":"","sources":["../src/legacy-redirects.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2BH;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACpC,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAiB7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Old query-string addresses, such as WordPress's `/?p=123` and
|
|
3
|
+
* `/?comic=the-slug`. EmDash's redirects match paths only, so
|
|
4
|
+
* `emdash-webcomic import` writes these into a map (`{ "?p=123": "/series/slug" }`)
|
|
5
|
+
* and the site's middleware looks requests up with `legacyRedirects()`.
|
|
6
|
+
*/
|
|
7
|
+
/** WordPress serves query-string permalinks from its front page. */
|
|
8
|
+
const LEGACY_PATHS = new Set(["/", "/index.php"]);
|
|
9
|
+
/** `key=value` with both halves decoded, or null. `+` is a space, as in forms. */
|
|
10
|
+
function normalizePair(pair) {
|
|
11
|
+
const equals = pair.indexOf("=");
|
|
12
|
+
if (equals <= 0)
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
const decode = (text) => decodeURIComponent(text.replaceAll("+", " "));
|
|
16
|
+
return `${decode(pair.slice(0, equals))}=${decode(pair.slice(equals + 1))}`;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** A path on this site: no scheme, no host. */
|
|
23
|
+
function isSitePath(value) {
|
|
24
|
+
return (typeof value === "string" &&
|
|
25
|
+
value.startsWith("/") &&
|
|
26
|
+
!value.startsWith("//") &&
|
|
27
|
+
!value.startsWith("/\\"));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Builds a lookup from an address map. The lookup returns the new path for a
|
|
31
|
+
* request to an old address, or null. Each `key=value` pair in the query is
|
|
32
|
+
* tried on its own, so extra parameters (`&utm_source=…`) don't stop a match,
|
|
33
|
+
* and percent-encoding differences don't either. Entries that don't point at
|
|
34
|
+
* a path on this site are ignored.
|
|
35
|
+
*/
|
|
36
|
+
export function legacyRedirects(map) {
|
|
37
|
+
const lookup = new Map();
|
|
38
|
+
for (const [address, destination] of Object.entries(map)) {
|
|
39
|
+
if (!address.startsWith("?") || !isSitePath(destination))
|
|
40
|
+
continue;
|
|
41
|
+
const key = normalizePair(address.slice(1));
|
|
42
|
+
// Percent-encode the path the way a browser would, for the Location header.
|
|
43
|
+
if (key)
|
|
44
|
+
lookup.set(key, new URL(destination, "https://site.invalid").pathname);
|
|
45
|
+
}
|
|
46
|
+
return (url) => {
|
|
47
|
+
if (lookup.size === 0 || !url.search || !LEGACY_PATHS.has(url.pathname))
|
|
48
|
+
return null;
|
|
49
|
+
for (const pair of url.search.slice(1).split("&")) {
|
|
50
|
+
const key = normalizePair(pair);
|
|
51
|
+
const destination = key === null ? undefined : lookup.get(key);
|
|
52
|
+
if (destination)
|
|
53
|
+
return destination;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=legacy-redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-redirects.js","sourceRoot":"","sources":["../src/legacy-redirects.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oEAAoE;AACpE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;AAElD,kFAAkF;AAClF,SAAS,aAAa,CAAC,IAAY;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7B,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/E,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAED,+CAA+C;AAC/C,SAAS,UAAU,CAAC,KAAc;IACjC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACrB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QACvB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CACxB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC9B,GAAsC;IAEtC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;YAAE,SAAS;QACnE,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,4EAA4E;QAC5E,IAAI,GAAG;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE;QACd,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;QACrF,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACnD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YAChC,MAAM,WAAW,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/D,IAAI,WAAW;gBAAE,OAAO,WAAW,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC,CAAC;AACH,CAAC"}
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media helpers for comic pages. Cloudflare's image transforms flatten animated
|
|
3
|
+
* GIFs to a single frame (V3), so the reader serves GIF pages untouched, using
|
|
4
|
+
* the same original URL EmDash's own image component would build.
|
|
5
|
+
*/
|
|
6
|
+
export interface MediaLike {
|
|
7
|
+
id?: string;
|
|
8
|
+
provider?: string;
|
|
9
|
+
src?: string;
|
|
10
|
+
filename?: string;
|
|
11
|
+
mimeType?: string;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
alt?: string;
|
|
15
|
+
meta?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare function asMedia(value: unknown): MediaLike | null;
|
|
18
|
+
/** True for GIF images, judged by MIME type, then filename or URL. */
|
|
19
|
+
export declare function isAnimatedImage(value: unknown): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The original (untransformed) URL of a local media item. `resolve` is
|
|
22
|
+
* `Astro.locals.emdash?.getPublicMediaUrl`, which maps a storage key to its
|
|
23
|
+
* public URL (an R2 custom domain, for example).
|
|
24
|
+
*/
|
|
25
|
+
export declare function originalMediaUrl(value: unknown, resolve?: ((storageKey: string) => string) | undefined): string | null;
|
|
26
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,SAAS;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAKD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAIxD;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,GACpD,MAAM,GAAG,IAAI,CAef"}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media helpers for comic pages. Cloudflare's image transforms flatten animated
|
|
3
|
+
* GIFs to a single frame (V3), so the reader serves GIF pages untouched, using
|
|
4
|
+
* the same original URL EmDash's own image component would build.
|
|
5
|
+
*/
|
|
6
|
+
const INTERNAL_MEDIA_PREFIX = "/_emdash/api/media/file/";
|
|
7
|
+
const SAFE_STORAGE_KEY = /^[A-Za-z0-9._-]+$/;
|
|
8
|
+
export function asMedia(value) {
|
|
9
|
+
if (typeof value === "string")
|
|
10
|
+
return value ? { src: value } : null;
|
|
11
|
+
if (typeof value !== "object" || value === null)
|
|
12
|
+
return null;
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/** True for GIF images, judged by MIME type, then filename or URL. */
|
|
16
|
+
export function isAnimatedImage(value) {
|
|
17
|
+
const media = asMedia(value);
|
|
18
|
+
if (!media)
|
|
19
|
+
return false;
|
|
20
|
+
if (media.mimeType)
|
|
21
|
+
return media.mimeType.toLowerCase() === "image/gif";
|
|
22
|
+
const name = media.filename ?? media.src ?? "";
|
|
23
|
+
return /\.gif(?:$|[?#])/i.test(name);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The original (untransformed) URL of a local media item. `resolve` is
|
|
27
|
+
* `Astro.locals.emdash?.getPublicMediaUrl`, which maps a storage key to its
|
|
28
|
+
* public URL (an R2 custom domain, for example).
|
|
29
|
+
*/
|
|
30
|
+
export function originalMediaUrl(value, resolve) {
|
|
31
|
+
const media = asMedia(value);
|
|
32
|
+
if (!media)
|
|
33
|
+
return null;
|
|
34
|
+
const storageKey = media.meta?.storageKey;
|
|
35
|
+
if (typeof storageKey === "string" && SAFE_STORAGE_KEY.test(storageKey)) {
|
|
36
|
+
return resolve ? resolve(storageKey) : `${INTERNAL_MEDIA_PREFIX}${storageKey}`;
|
|
37
|
+
}
|
|
38
|
+
if (media.src) {
|
|
39
|
+
if (resolve && media.src.startsWith(INTERNAL_MEDIA_PREFIX)) {
|
|
40
|
+
const key = media.src.slice(INTERNAL_MEDIA_PREFIX.length);
|
|
41
|
+
if (SAFE_STORAGE_KEY.test(key))
|
|
42
|
+
return resolve(key);
|
|
43
|
+
}
|
|
44
|
+
return media.src;
|
|
45
|
+
}
|
|
46
|
+
return media.id ? `${INTERNAL_MEDIA_PREFIX}${media.id}` : null;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AACzD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,MAAM,UAAU,OAAO,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,KAAkB,CAAC;AAC3B,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,KAAK,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC;IACxE,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC;IAC/C,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAc,EACd,OAAsD;IAEtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACzE,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,qBAAqB,GAAG,UAAU,EAAE,CAAC;IAChF,CAAC;IACD,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACf,IAAI,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAC5D,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;YAC1D,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,qBAAqB,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comic transcripts. Each page in the `pages` repeater can carry a transcript;
|
|
3
|
+
* the plugin copies them into one plain-text field so search can index and
|
|
4
|
+
* show them (raw repeater JSON makes poor search snippets).
|
|
5
|
+
*/
|
|
6
|
+
/** EmDash's text fields hold plenty, but a transcript this long is a mistake. */
|
|
7
|
+
export declare const MAX_TRANSCRIPT_LENGTH = 50000;
|
|
8
|
+
/** Joins the pages' transcripts, in page order, separated by blank lines. */
|
|
9
|
+
export declare function transcriptText(pages: unknown): string;
|
|
10
|
+
//# sourceMappingURL=transcripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcripts.d.ts","sourceRoot":"","sources":["../src/transcripts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASrD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comic transcripts. Each page in the `pages` repeater can carry a transcript;
|
|
3
|
+
* the plugin copies them into one plain-text field so search can index and
|
|
4
|
+
* show them (raw repeater JSON makes poor search snippets).
|
|
5
|
+
*/
|
|
6
|
+
/** EmDash's text fields hold plenty, but a transcript this long is a mistake. */
|
|
7
|
+
export const MAX_TRANSCRIPT_LENGTH = 50_000;
|
|
8
|
+
/** Joins the pages' transcripts, in page order, separated by blank lines. */
|
|
9
|
+
export function transcriptText(pages) {
|
|
10
|
+
if (!Array.isArray(pages))
|
|
11
|
+
return "";
|
|
12
|
+
const parts = [];
|
|
13
|
+
for (const page of pages) {
|
|
14
|
+
if (typeof page !== "object" || page === null)
|
|
15
|
+
continue;
|
|
16
|
+
const transcript = page.transcript;
|
|
17
|
+
if (typeof transcript === "string" && transcript.trim())
|
|
18
|
+
parts.push(transcript.trim());
|
|
19
|
+
}
|
|
20
|
+
return parts.join("\n\n").slice(0, MAX_TRANSCRIPT_LENGTH);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=transcripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcripts.js","sourceRoot":"","sources":["../src/transcripts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iFAAiF;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;YAAE,SAAS;QACxD,MAAM,UAAU,GAAI,IAAiC,CAAC,UAAU,CAAC;QACjE,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAC3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterandmotion/emdash-comics",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Comic tools for EmDash CMS: reader components (paged, vertical, right-to-left), navigation, archives, cast, content warnings, Portable Text comic blocks and searchable transcripts.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./astro": "./src/astro/index.ts",
|
|
13
|
+
"./astro/*": "./src/astro/*",
|
|
14
|
+
"./blocks": "./src/astro/blocks.ts",
|
|
15
|
+
"./admin": "./src/admin/index.tsx",
|
|
16
|
+
"./profile": {
|
|
17
|
+
"types": "./profile/index.d.mts",
|
|
18
|
+
"default": "./profile/index.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"profile",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"emdash",
|
|
30
|
+
"emdash-plugin",
|
|
31
|
+
"astro-component",
|
|
32
|
+
"webcomic",
|
|
33
|
+
"comics",
|
|
34
|
+
"webtoon",
|
|
35
|
+
"manga"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/matterandmotion/emdash-webcomic-kit.git",
|
|
40
|
+
"directory": "packages/comics"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/matterandmotion/emdash-webcomic-kit/tree/main/packages/comics#readme",
|
|
43
|
+
"bugs": "https://github.com/matterandmotion/emdash-webcomic-kit/issues",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.16"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@cloudflare/kumo": "2.19.0",
|
|
52
|
+
"@emdash-cms/admin": "^1.6.0",
|
|
53
|
+
"astro": ">=6.0.0",
|
|
54
|
+
"emdash": "^1.6.0",
|
|
55
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@cloudflare/kumo": "2.19.0",
|
|
59
|
+
"@emdash-cms/admin": "1.6.0",
|
|
60
|
+
"@types/react": "^19",
|
|
61
|
+
"astro": "7.4.13",
|
|
62
|
+
"emdash": "1.6.0",
|
|
63
|
+
"react": "19.3.1"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsc -p tsconfig.build.json",
|
|
67
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
68
|
+
"test": "vitest run"
|
|
69
|
+
}
|
|
6
70
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Matches the body of `POST /_emdash/api/schema/collections/:slug/fields`. */
|
|
2
|
+
export interface FieldDefinition {
|
|
3
|
+
slug: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
indexed?: boolean;
|
|
8
|
+
searchable?: boolean;
|
|
9
|
+
widget?: string;
|
|
10
|
+
validation?: Record<string, unknown> | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Matches the body of `POST /_emdash/api/schema/collections`, plus the fields to create. */
|
|
14
|
+
export interface CollectionDefinition {
|
|
15
|
+
slug: string;
|
|
16
|
+
label: string;
|
|
17
|
+
labelSingular?: string;
|
|
18
|
+
fields: FieldDefinition[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Matches the body of `POST /_emdash/api/taxonomies`. */
|
|
22
|
+
export interface TaxonomyDefinition {
|
|
23
|
+
name: string;
|
|
24
|
+
label: string;
|
|
25
|
+
labelSingular: string;
|
|
26
|
+
hierarchical: boolean;
|
|
27
|
+
collections: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ComicProfileOptions {
|
|
31
|
+
/** Default "comics". */
|
|
32
|
+
collection?: string;
|
|
33
|
+
/** Default "series". */
|
|
34
|
+
seriesCollection?: string;
|
|
35
|
+
/** Default "chapters"; false leaves chapters out. */
|
|
36
|
+
chaptersCollection?: string | false;
|
|
37
|
+
/** Default "cast"; false leaves the cast out. */
|
|
38
|
+
castCollection?: string | false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare const PLUGIN_ID: "mm-comics";
|
|
42
|
+
export declare const PAGES_FIELD: Readonly<FieldDefinition>;
|
|
43
|
+
|
|
44
|
+
export declare function comicProfile(options?: ComicProfileOptions): CollectionDefinition[];
|
|
45
|
+
|
|
46
|
+
export declare function comicTaxonomies(options?: { collection?: string }): TaxonomyDefinition[];
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema emdash-comics expects, for setup tools (the webcomic CLI's doctor
|
|
3
|
+
* and migrate commands) and templates. Plain JavaScript so Node scripts can
|
|
4
|
+
* import it without a build step. Collection and field definitions match the
|
|
5
|
+
* body of EmDash's schema REST API and `CollectionDefinition` in
|
|
6
|
+
* `@matterandmotion/emdash-plugin-toolkit`.
|
|
7
|
+
*
|
|
8
|
+
* Numbering and navigation fields (`series`, `number`) come from the serial
|
|
9
|
+
* profile in `@matterandmotion/emdash-series/profile`; merge both with the
|
|
10
|
+
* toolkit's `mergeDefinitions`, this profile first so its editor widgets win.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const PLUGIN_ID = "mm-comics";
|
|
14
|
+
|
|
15
|
+
const SLUG = /^[a-z][a-z0-9_]*$/;
|
|
16
|
+
|
|
17
|
+
function assertSlug(value, what) {
|
|
18
|
+
if (typeof value !== "string" || !SLUG.test(value)) {
|
|
19
|
+
throw new TypeError(
|
|
20
|
+
`${what} must be a lowercase slug (a-z, 0-9, _), got ${JSON.stringify(value)}`,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function widget(name) {
|
|
27
|
+
return `${PLUGIN_ID}:${name}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function seriesPicker() {
|
|
31
|
+
return {
|
|
32
|
+
slug: "series",
|
|
33
|
+
label: "Series",
|
|
34
|
+
type: "string",
|
|
35
|
+
required: true,
|
|
36
|
+
indexed: true,
|
|
37
|
+
widget: widget("series"),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The `pages` repeater: one item per page, or per segment of a tall strip. */
|
|
42
|
+
export const PAGES_FIELD = Object.freeze({
|
|
43
|
+
slug: "pages",
|
|
44
|
+
label: "Pages",
|
|
45
|
+
type: "repeater",
|
|
46
|
+
widget: widget("comic-pages"),
|
|
47
|
+
validation: {
|
|
48
|
+
minItems: 1,
|
|
49
|
+
subFields: [
|
|
50
|
+
{ slug: "image", label: "Image", type: "image" },
|
|
51
|
+
{ slug: "alt", label: "Alt text", type: "string" },
|
|
52
|
+
{ slug: "transcript", label: "Transcript", type: "text" },
|
|
53
|
+
{ slug: "hovertext", label: "Hover text", type: "string" },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Collections and fields for comics.
|
|
60
|
+
*
|
|
61
|
+
* - The comic collection gets the pages repeater (edited with the comic pages
|
|
62
|
+
* widget), a searchable `transcript_text` that the plugin fills from the
|
|
63
|
+
* pages, a thumbnail, creator notes and print and original sale links, plus
|
|
64
|
+
* series and chapter pickers on the serial profile's fields.
|
|
65
|
+
* - The series collection gets a reading direction, a rating and credits.
|
|
66
|
+
* - The chapters collection gets the series picker.
|
|
67
|
+
* - The cast collection holds characters: a name, portrait, bio, series and
|
|
68
|
+
* first appearance.
|
|
69
|
+
*
|
|
70
|
+
* @param {import("./index.d.mts").ComicProfileOptions} [options]
|
|
71
|
+
* @returns {import("./index.d.mts").CollectionDefinition[]}
|
|
72
|
+
*/
|
|
73
|
+
export function comicProfile(options = {}) {
|
|
74
|
+
const collection = assertSlug(options.collection ?? "comics", "collection");
|
|
75
|
+
const seriesCollection = assertSlug(options.seriesCollection ?? "series", "seriesCollection");
|
|
76
|
+
const chaptersCollection =
|
|
77
|
+
options.chaptersCollection === false
|
|
78
|
+
? null
|
|
79
|
+
: assertSlug(options.chaptersCollection ?? "chapters", "chaptersCollection");
|
|
80
|
+
const castCollection =
|
|
81
|
+
options.castCollection === false
|
|
82
|
+
? null
|
|
83
|
+
: assertSlug(options.castCollection ?? "cast", "castCollection");
|
|
84
|
+
|
|
85
|
+
const definitions = [
|
|
86
|
+
{
|
|
87
|
+
slug: collection,
|
|
88
|
+
label: "Comics",
|
|
89
|
+
labelSingular: "Comic",
|
|
90
|
+
fields: [
|
|
91
|
+
seriesPicker(),
|
|
92
|
+
...(chaptersCollection
|
|
93
|
+
? [
|
|
94
|
+
{
|
|
95
|
+
slug: "chapter",
|
|
96
|
+
label: "Chapter",
|
|
97
|
+
type: "string",
|
|
98
|
+
indexed: true,
|
|
99
|
+
widget: widget("chapter"),
|
|
100
|
+
},
|
|
101
|
+
]
|
|
102
|
+
: []),
|
|
103
|
+
structuredClone(PAGES_FIELD),
|
|
104
|
+
{
|
|
105
|
+
slug: "transcript_text",
|
|
106
|
+
label: "Transcript (search)",
|
|
107
|
+
type: "text",
|
|
108
|
+
searchable: true,
|
|
109
|
+
},
|
|
110
|
+
{ slug: "thumbnail", label: "Thumbnail", type: "image" },
|
|
111
|
+
{ slug: "notes", label: "Creator notes", type: "portableText" },
|
|
112
|
+
{ slug: "buy_print_url", label: "Buy print URL", type: "url" },
|
|
113
|
+
{ slug: "buy_original_url", label: "Buy original URL", type: "url" },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
slug: seriesCollection,
|
|
118
|
+
label: "Series",
|
|
119
|
+
labelSingular: "Series",
|
|
120
|
+
fields: [
|
|
121
|
+
{
|
|
122
|
+
slug: "reading_direction",
|
|
123
|
+
label: "Reading direction",
|
|
124
|
+
type: "select",
|
|
125
|
+
validation: { options: ["ltr", "rtl", "vertical"] },
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
slug: "rating",
|
|
129
|
+
label: "Rating",
|
|
130
|
+
type: "select",
|
|
131
|
+
validation: { options: ["all-ages", "teen", "mature"] },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
slug: "credits",
|
|
135
|
+
label: "Credits",
|
|
136
|
+
type: "repeater",
|
|
137
|
+
validation: {
|
|
138
|
+
subFields: [
|
|
139
|
+
{ slug: "name", label: "Name", type: "string" },
|
|
140
|
+
{ slug: "role", label: "Role", type: "string" },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
if (chaptersCollection) {
|
|
149
|
+
definitions.push({
|
|
150
|
+
slug: chaptersCollection,
|
|
151
|
+
label: "Chapters",
|
|
152
|
+
labelSingular: "Chapter",
|
|
153
|
+
fields: [seriesPicker()],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (castCollection) {
|
|
158
|
+
definitions.push({
|
|
159
|
+
slug: castCollection,
|
|
160
|
+
label: "Cast",
|
|
161
|
+
labelSingular: "Character",
|
|
162
|
+
fields: [
|
|
163
|
+
{ slug: "title", label: "Name", type: "string", required: true, searchable: true },
|
|
164
|
+
{ slug: "portrait", label: "Portrait", type: "image" },
|
|
165
|
+
{ slug: "bio", label: "Bio", type: "portableText" },
|
|
166
|
+
{ ...seriesPicker(), required: false },
|
|
167
|
+
{ slug: "first_appearance", label: "First appearance (number)", type: "integer" },
|
|
168
|
+
],
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return definitions;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Flat taxonomies for comics: characters, locations, tags and content
|
|
177
|
+
* warnings. The reader components show content warnings before a comic.
|
|
178
|
+
*
|
|
179
|
+
* @param {{ collection?: string }} [options]
|
|
180
|
+
* @returns {import("./index.d.mts").TaxonomyDefinition[]}
|
|
181
|
+
*/
|
|
182
|
+
export function comicTaxonomies(options = {}) {
|
|
183
|
+
const collection = assertSlug(options.collection ?? "comics", "collection");
|
|
184
|
+
const taxonomy = (name, label, labelSingular) => ({
|
|
185
|
+
name,
|
|
186
|
+
label,
|
|
187
|
+
labelSingular,
|
|
188
|
+
hierarchical: false,
|
|
189
|
+
collections: [collection],
|
|
190
|
+
});
|
|
191
|
+
return [
|
|
192
|
+
taxonomy("characters", "Characters", "Character"),
|
|
193
|
+
taxonomy("locations", "Locations", "Location"),
|
|
194
|
+
taxonomy("comic_tags", "Comic tags", "Comic tag"),
|
|
195
|
+
taxonomy("content_warnings", "Content warnings", "Content warning"),
|
|
196
|
+
];
|
|
197
|
+
}
|