@buildinternet/uploads 0.42.0 → 0.42.2

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.
@@ -0,0 +1,151 @@
1
+ /**
2
+ * GENERATED by packages/uploads/scripts/inline-shared.mjs — do not edit.
3
+ * Canonical source: packages/comment-render/src/index.ts
4
+ * The published CLI cannot import private @uploads/* packages, so this file
5
+ * is inlined into the tarball. Re-run the script after changing the source.
6
+ */
7
+ export type GhTargetKind = "pull" | "issues";
8
+ export interface GhTarget {
9
+ /** "owner/name" */
10
+ repo: string;
11
+ kind: GhTargetKind;
12
+ num: number;
13
+ }
14
+ /** Non-safe chars → `-` for a single R2 key segment (owner/name/branch/…).
15
+ * Exported for reuse by other GitHub-key builders (github-ingest.ts) that
16
+ * need the identical sanitization rule — github-promote.ts keeps its own
17
+ * byte-identical private copy rather than importing this one. */
18
+ export declare function sanitizeKeySegment(s: string): string;
19
+ export declare function ghKeyPrefix(target: GhTarget): string;
20
+ /** Literal root under which every private-repo attachment key lives. */
21
+ export declare const GH_PRIVATE_ROOT = "gh/private/";
22
+ /**
23
+ * Private-repo key prefix: `gh/private/<32-hex-id>/<kind>/<num>/`.
24
+ * Deliberately omits the repo (unlike `ghKeyPrefix`) — the id is a random,
25
+ * unguessable per-repo prefix rather than an owner/name path, so callers
26
+ * that need the repo back must read `gh.repo` metadata (see
27
+ * `parseGhPrivateKey`, which cannot recover it from the key alone).
28
+ */
29
+ export declare function ghPrivateKeyPrefix(prefixId: string, target: GhTarget): string;
30
+ /** Private-repo attachment key: `ghPrivateKeyPrefix` + the sanitized filename. */
31
+ export declare function ghPrivateAttachmentKey(prefixId: string, target: GhTarget, filename: string): string;
32
+ /**
33
+ * Private-repo branch-staged key prefix: `gh/private/<32-hex-id>/branch/`.
34
+ * Unlike `ghBranchKeyPrefix`, there is deliberately NO branch-name segment —
35
+ * the branch name itself is not embedded in a private-repo key.
36
+ */
37
+ export declare function ghPrivateBranchKeyPrefix(prefixId: string): string;
38
+ /** Private-repo branch-staged attachment key: `ghPrivateBranchKeyPrefix` + the sanitized filename. */
39
+ export declare function ghPrivateBranchAttachmentKey(prefixId: string, filename: string): string;
40
+ /**
41
+ * Inverse of `ghPrivateKeyPrefix`: parse the prefix id/kind/number back out
42
+ * of a private-repo attachment key, or undefined for any other key shape.
43
+ * Cannot recover the repo — callers that need it read `gh.repo` metadata.
44
+ */
45
+ export declare function parseGhPrivateKey(key: string): {
46
+ prefixId: string;
47
+ kind: GhTargetKind;
48
+ num: number;
49
+ } | undefined;
50
+ /** Hidden marker identifying the one comment this CLI manages. Never change it — existing comments are found by exact match. */
51
+ export declare const ATTACHMENTS_MARKER = "<!-- uploads.sh:attachments -->";
52
+ /**
53
+ * Per-workspace marker (`<!-- uploads.sh:attachments ws=<workspace> -->`) so
54
+ * two workspaces managing the same repo don't clobber each other's comment.
55
+ * Falls back to the shared legacy marker when `workspace` is missing or does
56
+ * not look like a safe slug — degrade, don't guess or risk breaking the
57
+ * comment's HTML.
58
+ */
59
+ export declare function attachmentsMarker(workspace?: string): string;
60
+ /** Max attachments embedded as inline `<img>` tags before the rest collapse
61
+ * into a `<details>` link list. Keeps very large threads from becoming a wall
62
+ * of images. */
63
+ export declare const MAX_INLINE_ATTACHMENT_IMAGES = 16;
64
+ /**
65
+ * Per-render knobs for the managed comment (issue #307), sourced from repo
66
+ * comment config. `imageWidth: "auto"` uses per-item filename heuristics plus
67
+ * density-aware sizing (solo/sparse/dense from the inlined count); `"full"`
68
+ * omits the `width` attribute entirely; a number overrides every width site.
69
+ */
70
+ export interface CommentRenderOptions {
71
+ imageWidth: "auto" | "full" | number;
72
+ maxInlineImages: number;
73
+ metaPath: boolean;
74
+ metaState: boolean;
75
+ note: string | null;
76
+ }
77
+ /** Today's behavior, expressed as options — the default for every caller that
78
+ * hasn't opted into repo comment config. */
79
+ export declare const AUTO_RENDER_OPTIONS: CommentRenderOptions;
80
+ export interface AttachmentItem {
81
+ key: string;
82
+ url: string | null;
83
+ /** Prefer for `<img src>` on GitHub (Camo-friendly host). Falls back to `url`. */
84
+ embedUrl?: string | null;
85
+ /** Canonical `/f/` file-page URL (server-computed). Preferred click-through target; falls back to `url`. */
86
+ pageUrl?: string | null;
87
+ /**
88
+ * The only canonical metadata the managed comment renders (issue #365).
89
+ * Deliberately two named fields rather than `Record<string, string>`: the
90
+ * comment is posted publicly, and keeping the set narrow at the type level
91
+ * mirrors the server-side query filter that never fetches EXIF-derived
92
+ * keys like `device`/`software` for this path.
93
+ */
94
+ meta?: {
95
+ path?: string;
96
+ state?: string;
97
+ };
98
+ /**
99
+ * Poster frame for a video (issue #299), server-computed like `embedUrl` —
100
+ * never taken from client-settable metadata. Absent means "no poster", and
101
+ * the renderer falls back to the bullet link.
102
+ */
103
+ posterUrl?: string | null;
104
+ /** Derived video facts used for the caption and display width. */
105
+ videoMeta?: {
106
+ durationSeconds?: number;
107
+ width?: number;
108
+ height?: number;
109
+ };
110
+ }
111
+ /** A public gallery linked to the PR or issue whose managed comment is syncing. */
112
+ export interface GalleryCommentItem {
113
+ title: string;
114
+ /** Canonical URL returned by the API; callers must not synthesize it. */
115
+ url: string;
116
+ /** A bounded set of available images; each links to its item page when known, else the gallery. */
117
+ previews?: {
118
+ url: string;
119
+ alt: string;
120
+ embedUrl?: string | null;
121
+ itemUrl?: string;
122
+ }[];
123
+ }
124
+ /**
125
+ * How crowded the managed comment is. Sparse comments (one shot, a single
126
+ * before/after) get larger embeds; dense comments keep compact historical sizes.
127
+ */
128
+ export type AttachmentDensity = "solo" | "sparse" | "dense";
129
+ /** Dense (historical) default max width for images in the managed comment. */
130
+ export declare const ATTACHMENT_IMAGE_WIDTH_DEFAULT = 400;
131
+ /** Portrait / device mockups — keep phones readable, not full-column. */
132
+ export declare const ATTACHMENT_IMAGE_WIDTH_PORTRAIT = 280;
133
+ /** Wide UI / browser chrome. */
134
+ export declare const ATTACHMENT_IMAGE_WIDTH_WIDE = 640;
135
+ /** Dense pair-cell cap (side-by-side before/after). */
136
+ export declare const ATTACHMENT_IMAGE_WIDTH_PAIR = 320;
137
+ /** Map an inlined-media count onto a density tier. */
138
+ export declare function attachmentDensityForCount(inlinedCount: number): AttachmentDensity;
139
+ /** Pair-cell cap for the given density. */
140
+ export declare function attachmentPairWidth(density?: AttachmentDensity): number;
141
+ /**
142
+ * Display width for a GitHub comment embed. Filenames are a weak but practical
143
+ * signal (we don't re-fetch dimensions when rebuilding the comment). `density`
144
+ * only affects managed-comment auto layout; other callers leave it `"dense"`.
145
+ */
146
+ export declare function attachmentImageWidth(filename: string, density?: AttachmentDensity): number;
147
+ /**
148
+ * Render the one marker-owned GitHub comment. When there are no galleries this
149
+ * intentionally preserves the legacy attachment-only body byte-for-byte.
150
+ */
151
+ export declare function attachmentsCommentBody(items: AttachmentItem[], galleries?: GalleryCommentItem[], marker?: string, options?: CommentRenderOptions): string;