@conloca/content-api 0.2.2 → 0.2.4

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.
Files changed (118) hide show
  1. package/dist/.build-inputs.json +82 -0
  2. package/dist/address-site.d.ts +6 -0
  3. package/dist/address-site.d.ts.map +1 -0
  4. package/dist/address-site.js +15 -0
  5. package/dist/address-site.js.map +1 -0
  6. package/dist/asset-constraints.d.ts +9 -1
  7. package/dist/asset-constraints.d.ts.map +1 -1
  8. package/dist/asset-constraints.js +10 -2
  9. package/dist/asset-constraints.js.map +1 -1
  10. package/dist/asset-metadata-record.d.ts +18 -0
  11. package/dist/asset-metadata-record.d.ts.map +1 -0
  12. package/dist/asset-metadata-record.js +59 -0
  13. package/dist/asset-metadata-record.js.map +1 -0
  14. package/dist/asset-metadata-store.d.ts.map +1 -1
  15. package/dist/asset-metadata-store.js +7 -26
  16. package/dist/asset-metadata-store.js.map +1 -1
  17. package/dist/asset-naming.d.ts +39 -0
  18. package/dist/asset-naming.d.ts.map +1 -0
  19. package/dist/asset-naming.js +123 -0
  20. package/dist/asset-naming.js.map +1 -0
  21. package/dist/asset-operations.d.ts +15 -2
  22. package/dist/asset-operations.d.ts.map +1 -1
  23. package/dist/asset-operations.js +99 -90
  24. package/dist/asset-operations.js.map +1 -1
  25. package/dist/asset-types.d.ts +2 -0
  26. package/dist/asset-types.d.ts.map +1 -1
  27. package/dist/asset-usage.d.ts +8 -1
  28. package/dist/asset-usage.d.ts.map +1 -1
  29. package/dist/asset-usage.js +4 -1
  30. package/dist/asset-usage.js.map +1 -1
  31. package/dist/component-registry.d.ts +3 -0
  32. package/dist/component-registry.d.ts.map +1 -1
  33. package/dist/content-utils.d.ts +4 -1
  34. package/dist/content-utils.d.ts.map +1 -1
  35. package/dist/content-utils.js +14 -1
  36. package/dist/content-utils.js.map +1 -1
  37. package/dist/draft-media-ref.d.ts +9 -0
  38. package/dist/draft-media-ref.d.ts.map +1 -0
  39. package/dist/draft-media-ref.js +47 -0
  40. package/dist/draft-media-ref.js.map +1 -0
  41. package/dist/editor-host.d.ts +174 -0
  42. package/dist/editor-host.d.ts.map +1 -0
  43. package/dist/editor-host.js +304 -0
  44. package/dist/editor-host.js.map +1 -0
  45. package/dist/filesystem-content-api.d.ts +15 -0
  46. package/dist/filesystem-content-api.d.ts.map +1 -1
  47. package/dist/filesystem-content-api.js +3 -2
  48. package/dist/filesystem-content-api.js.map +1 -1
  49. package/dist/git-operations.d.ts +0 -5
  50. package/dist/git-operations.d.ts.map +1 -1
  51. package/dist/git-operations.js +1 -33
  52. package/dist/git-operations.js.map +1 -1
  53. package/dist/image-format.d.ts +9 -0
  54. package/dist/image-format.d.ts.map +1 -0
  55. package/dist/image-format.js +100 -0
  56. package/dist/image-format.js.map +1 -0
  57. package/dist/image-metadata.d.ts +11 -0
  58. package/dist/image-metadata.d.ts.map +1 -0
  59. package/dist/image-metadata.js +283 -0
  60. package/dist/image-metadata.js.map +1 -0
  61. package/dist/image-shrink.d.ts +15 -0
  62. package/dist/image-shrink.d.ts.map +1 -0
  63. package/dist/image-shrink.js +52 -0
  64. package/dist/image-shrink.js.map +1 -0
  65. package/dist/index.d.ts +8 -1
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +16 -3
  68. package/dist/index.js.map +1 -1
  69. package/dist/lfs-attributes.d.ts +26 -0
  70. package/dist/lfs-attributes.d.ts.map +1 -0
  71. package/dist/lfs-attributes.js +285 -0
  72. package/dist/lfs-attributes.js.map +1 -0
  73. package/dist/site.d.ts.map +1 -1
  74. package/dist/site.js +3 -1
  75. package/dist/site.js.map +1 -1
  76. package/dist/skill-stamp.d.ts +10 -0
  77. package/dist/skill-stamp.d.ts.map +1 -0
  78. package/dist/skill-stamp.js +42 -0
  79. package/dist/skill-stamp.js.map +1 -0
  80. package/dist/svg-sanitize.d.ts +8 -0
  81. package/dist/svg-sanitize.d.ts.map +1 -0
  82. package/dist/svg-sanitize.js +260 -0
  83. package/dist/svg-sanitize.js.map +1 -0
  84. package/dist/types.d.ts +9 -0
  85. package/dist/types.d.ts.map +1 -1
  86. package/dist/upload-bytes.d.ts +17 -0
  87. package/dist/upload-bytes.d.ts.map +1 -0
  88. package/dist/upload-bytes.js +43 -0
  89. package/dist/upload-bytes.js.map +1 -0
  90. package/dist/upload-refusals.d.ts +24 -0
  91. package/dist/upload-refusals.d.ts.map +1 -0
  92. package/dist/upload-refusals.js +49 -0
  93. package/dist/upload-refusals.js.map +1 -0
  94. package/package.json +49 -6
  95. package/src/address-site.ts +19 -0
  96. package/src/asset-constraints.ts +14 -2
  97. package/src/asset-metadata-record.ts +57 -0
  98. package/src/asset-metadata-store.ts +12 -21
  99. package/src/asset-naming.ts +120 -0
  100. package/src/asset-operations.ts +108 -91
  101. package/src/asset-types.ts +2 -0
  102. package/src/asset-usage.ts +16 -2
  103. package/src/content-utils.ts +18 -2
  104. package/src/draft-media-ref.ts +46 -0
  105. package/src/editor-host.ts +384 -0
  106. package/src/filesystem-content-api.ts +3 -2
  107. package/src/git-operations.ts +1 -38
  108. package/src/image-format.ts +87 -0
  109. package/src/image-metadata.ts +266 -0
  110. package/src/image-shrink.ts +57 -0
  111. package/src/index.ts +47 -3
  112. package/src/lfs-attributes.ts +291 -0
  113. package/src/site.ts +3 -1
  114. package/src/skill-stamp.ts +45 -0
  115. package/src/svg-sanitize.ts +260 -0
  116. package/src/types.ts +9 -0
  117. package/src/upload-bytes.ts +46 -0
  118. package/src/upload-refusals.ts +59 -0
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Lossless metadata stripping for uploads: EXIF, GPS, XMP, C2PA and anything appended after the image leave a JPEG, PNG
3
+ * or WebP before it is stored, while its pixels, colour profile and orientation stay. Each container is walked by an
4
+ * allowlist of the parts a picture needs; everything else is dropped. Pure and runtime-neutral.
5
+ */
6
+
7
+ /** A kept run of the input (`[start, end)`) or bytes written for the output. */
8
+ type Piece = [start: number, end: number] | Uint8Array;
9
+
10
+ /** Keep `[start, end)` of the input, joining it to the previous kept run when they touch. */
11
+ function keep(pieces: Piece[], start: number, end: number): void {
12
+ const last = pieces.at(-1);
13
+ if (last !== undefined && !(last instanceof Uint8Array) && last[1] === start) last[1] = end;
14
+ else pieces.push([start, end]);
15
+ }
16
+
17
+ /** The output, built once from the pieces; the input itself when nothing was dropped. */
18
+ function assemble(bytes: Uint8Array, pieces: readonly Piece[]): Uint8Array {
19
+ const only = pieces[0];
20
+ if (pieces.length === 1 && !(only instanceof Uint8Array) && only[0] === 0 && only[1] === bytes.length) return bytes;
21
+ let size = 0;
22
+ for (const piece of pieces) size += piece instanceof Uint8Array ? piece.length : piece[1] - piece[0];
23
+ const out = new Uint8Array(size);
24
+ let offset = 0;
25
+ for (const piece of pieces) {
26
+ const part = piece instanceof Uint8Array ? piece : bytes.subarray(piece[0], piece[1]);
27
+ out.set(part, offset);
28
+ offset += part.length;
29
+ }
30
+ return out;
31
+ }
32
+
33
+ function ascii(bytes: Uint8Array, start: number, text: string): boolean {
34
+ if (bytes.length < start + text.length) return false;
35
+ for (let i = 0; i < text.length; i += 1) if (bytes[start + i] !== text.charCodeAt(i)) return false;
36
+ return true;
37
+ }
38
+
39
+ function view(bytes: Uint8Array): DataView {
40
+ return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
41
+ }
42
+
43
+ /** The EXIF Orientation (tag 0x0112 in IFD0) of the TIFF structure at `[start, end)`, or 1 when it has none. */
44
+ function tiffOrientation(bytes: Uint8Array, start: number, end: number): number {
45
+ if (end - start < 8) return 1;
46
+ const little = ascii(bytes, start, 'II');
47
+ if (!little && !ascii(bytes, start, 'MM')) return 1;
48
+ const data = view(bytes);
49
+ const ifd = start + data.getUint32(start + 4, little);
50
+ if (ifd + 2 > end) return 1;
51
+ const count = data.getUint16(ifd, little);
52
+ for (let entry = ifd + 2; entry + 12 <= end && entry < ifd + 2 + count * 12; entry += 12) {
53
+ if (data.getUint16(entry, little) === 0x0112 && data.getUint16(entry + 2, little) === 3) {
54
+ const orientation = data.getUint16(entry + 8, little);
55
+ return orientation >= 1 && orientation <= 8 ? orientation : 1;
56
+ }
57
+ }
58
+ return 1;
59
+ }
60
+
61
+ /** A big-endian TIFF holding only IFD0 with one Orientation entry. */
62
+ function orientationTiff(orientation: number): Uint8Array {
63
+ // biome-ignore format: one TIFF field per row
64
+ return Uint8Array.from([
65
+ 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, // "MM", 42, IFD0 at 8
66
+ 0x00, 0x01, // one entry
67
+ 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, orientation, 0x00, 0x00, // Orientation, SHORT, 1 value
68
+ 0x00, 0x00, 0x00, 0x00, // no next IFD
69
+ ]);
70
+ }
71
+
72
+ /**
73
+ * JPEG APPn markers kept: APP0 only when it is JFIF (a JFXX one holds a thumbnail with its own EXIF), APP14 (Adobe
74
+ * colour transform), and APP2 only when it is an ICC profile.
75
+ */
76
+ const APP0 = 0xe0;
77
+ const APP1 = 0xe1;
78
+ const APP2 = 0xe2;
79
+ const APP14 = 0xee;
80
+ const COM = 0xfe;
81
+ const SOS = 0xda;
82
+ const EOI = 0xd9;
83
+
84
+ function isRst(marker: number): boolean {
85
+ return marker >= 0xd0 && marker <= 0xd7;
86
+ }
87
+
88
+ function stripJpeg(bytes: Uint8Array): Uint8Array | null {
89
+ if (bytes[0] !== 0xff || bytes[1] !== 0xd8) return null;
90
+ const pieces: Piece[] = [];
91
+ keep(pieces, 0, 2);
92
+ let orientation = 1;
93
+ let pos = 2;
94
+ while (pos < bytes.length) {
95
+ if (pos + 2 > bytes.length || bytes[pos] !== 0xff) return null;
96
+ const marker = bytes[pos + 1];
97
+ if (marker === 0xff) {
98
+ pos += 1; // fill byte
99
+ continue;
100
+ }
101
+ if (marker === EOI) {
102
+ keep(pieces, pos, pos + 2);
103
+ break; // everything after the primary image (MPF pictures, Ultra HDR gain maps, trailers) is dropped
104
+ }
105
+ if (marker === 0x01 || isRst(marker)) {
106
+ keep(pieces, pos, pos + 2);
107
+ pos += 2;
108
+ continue;
109
+ }
110
+ if (pos + 4 > bytes.length) return null;
111
+ const length = (bytes[pos + 2] << 8) | bytes[pos + 3];
112
+ const end = pos + 2 + length;
113
+ if (length < 2 || end > bytes.length) return null;
114
+ const dataStart = pos + 4;
115
+ if (marker === APP1) {
116
+ if (ascii(bytes, dataStart, 'Exif\0\0')) orientation = tiffOrientation(bytes, dataStart + 6, end);
117
+ } else if (
118
+ (marker === APP0 && ascii(bytes, dataStart, 'JFIF\0')) ||
119
+ marker === APP14 ||
120
+ (marker === APP2 && ascii(bytes, dataStart, 'ICC_PROFILE\0'))
121
+ ) {
122
+ keep(pieces, pos, end);
123
+ } else if (marker === COM || (marker & 0xf0) === 0xe0) {
124
+ // other APPn and comments: metadata
125
+ } else if (marker === SOS) {
126
+ // The entropy-coded scan runs to the next marker that is neither a stuffed 0xFF00 nor a restart marker.
127
+ let scan = end;
128
+ while (scan < bytes.length) {
129
+ if (bytes[scan] === 0xff && scan + 1 < bytes.length) {
130
+ const next = bytes[scan + 1];
131
+ if (next !== 0x00 && !isRst(next)) break;
132
+ scan += 2;
133
+ } else scan += 1;
134
+ }
135
+ keep(pieces, pos, scan);
136
+ pos = scan;
137
+ continue;
138
+ } else {
139
+ keep(pieces, pos, end); // tables, frame headers and every other structural segment
140
+ }
141
+ pos = end;
142
+ }
143
+ const first = pieces[0];
144
+ if (orientation !== 1 && !(first instanceof Uint8Array)) {
145
+ const tiff = orientationTiff(orientation);
146
+ const segment = new Uint8Array(4 + 6 + tiff.length);
147
+ segment.set([0xff, APP1, 0, 2 + 6 + tiff.length]);
148
+ segment.set([0x45, 0x78, 0x69, 0x66, 0, 0], 4); // "Exif\0\0"
149
+ segment.set(tiff, 10);
150
+ // Right after SOI, or after a kept JFIF APP0 that directly follows it: both always open the first kept run.
151
+ const cut = bytes[3] === APP0 && ascii(bytes, 6, 'JFIF\0') ? 4 + ((bytes[4] << 8) | bytes[5]) : 2;
152
+ const rest: Piece[] = first[1] > cut ? [[cut, first[1]]] : [];
153
+ pieces.splice(0, 1, [0, cut], segment, ...rest);
154
+ }
155
+ return assemble(bytes, pieces);
156
+ }
157
+
158
+ /**
159
+ * PNG chunks a picture needs, its HDR colour (cICP, mDCv, cLLi) included; everything else (eXIf, tEXt/zTXt/iTXt, tIME,
160
+ * caBX, private chunks) is dropped.
161
+ */
162
+ const PNG_KEPT = new Set([
163
+ 'IHDR',
164
+ 'PLTE',
165
+ 'IDAT',
166
+ 'IEND',
167
+ 'tRNS',
168
+ 'cHRM',
169
+ 'gAMA',
170
+ 'iCCP',
171
+ 'sBIT',
172
+ 'sRGB',
173
+ 'bKGD',
174
+ 'pHYs',
175
+ 'acTL',
176
+ 'cICP',
177
+ 'mDCv',
178
+ 'cLLi',
179
+ 'fcTL',
180
+ 'fdAT',
181
+ ]);
182
+
183
+ function chunkType(bytes: Uint8Array, start: number): string {
184
+ return String.fromCharCode(bytes[start], bytes[start + 1], bytes[start + 2], bytes[start + 3]);
185
+ }
186
+
187
+ function stripPng(bytes: Uint8Array): Uint8Array | null {
188
+ if (!ascii(bytes, 0, '\x89PNG\r\n\x1a\n')) return null;
189
+ const data = view(bytes);
190
+ const pieces: Piece[] = [];
191
+ keep(pieces, 0, 8);
192
+ let pos = 8;
193
+ while (pos + 12 <= bytes.length) {
194
+ const end = pos + 12 + data.getUint32(pos);
195
+ if (end > bytes.length) return null;
196
+ const type = chunkType(bytes, pos + 4);
197
+ if (PNG_KEPT.has(type)) keep(pieces, pos, end);
198
+ if (type === 'IEND') return assemble(bytes, pieces);
199
+ pos = end;
200
+ }
201
+ return null;
202
+ }
203
+
204
+ /** WebP chunks a picture needs; EXIF and XMP and anything unknown are dropped. */
205
+ const WEBP_KEPT = new Set(['VP8 ', 'VP8L', 'VP8X', 'ALPH', 'ANIM', 'ANMF', 'ICCP']);
206
+ const VP8X_EXIF = 0x08;
207
+ const VP8X_XMP = 0x04;
208
+
209
+ function stripWebp(bytes: Uint8Array): Uint8Array | null {
210
+ if (!ascii(bytes, 0, 'RIFF') || !ascii(bytes, 8, 'WEBP')) return null;
211
+ const data = view(bytes);
212
+ const riffEnd = 8 + data.getUint32(4, true);
213
+ if (riffEnd > bytes.length) return null;
214
+ const header = new Uint8Array(12);
215
+ const pieces: Piece[] = [header];
216
+ let vp8x: Uint8Array | null = null;
217
+ let orientation = 1;
218
+ let pos = 12;
219
+ while (pos < riffEnd) {
220
+ if (pos + 8 > riffEnd) return null;
221
+ const size = data.getUint32(pos + 4, true);
222
+ const end = pos + 8 + size + (size & 1);
223
+ if (end > riffEnd) return null;
224
+ const type = chunkType(bytes, pos);
225
+ if (type === 'VP8X') {
226
+ if (size < 10) return null;
227
+ // Copied, not kept: its flags change.
228
+ vp8x = bytes.slice(pos, end);
229
+ pieces.push(vp8x);
230
+ } else if (WEBP_KEPT.has(type)) {
231
+ keep(pieces, pos, end);
232
+ } else if (type === 'EXIF') {
233
+ const tiff = ascii(bytes, pos + 8, 'Exif\0\0') ? pos + 14 : pos + 8;
234
+ orientation = tiffOrientation(bytes, tiff, pos + 8 + size);
235
+ }
236
+ pos = end;
237
+ }
238
+ if (vp8x !== null) {
239
+ vp8x[8] &= ~(VP8X_XMP | VP8X_EXIF);
240
+ if (orientation !== 1) {
241
+ // A simple WebP (no VP8X) cannot carry EXIF, so only an extended one gets its orientation back.
242
+ vp8x[8] |= VP8X_EXIF;
243
+ const tiff = orientationTiff(orientation);
244
+ const chunk = new Uint8Array(8 + tiff.length);
245
+ chunk.set([0x45, 0x58, 0x49, 0x46, tiff.length]); // "EXIF", little-endian size
246
+ chunk.set(tiff, 8);
247
+ pieces.push(chunk);
248
+ }
249
+ }
250
+ let size = 0;
251
+ for (const piece of pieces) size += piece instanceof Uint8Array ? piece.length : piece[1] - piece[0];
252
+ header.set([0x52, 0x49, 0x46, 0x46]); // "RIFF"
253
+ new DataView(header.buffer).setUint32(4, size - 8, true);
254
+ header.set([0x57, 0x45, 0x42, 0x50], 8); // "WEBP"
255
+ return assemble(bytes, pieces);
256
+ }
257
+
258
+ /**
259
+ * `bytes` without their metadata, read as `format`: colour profile and orientation kept, pixels untouched. `null` when
260
+ * the container cannot be walked. The output is built once from slices of the input.
261
+ */
262
+ export function stripImageMetadata(bytes: Uint8Array, format: 'jpeg' | 'png' | 'webp'): Uint8Array | null {
263
+ if (format === 'jpeg') return stripJpeg(bytes);
264
+ if (format === 'png') return stripPng(bytes);
265
+ return stripWebp(bytes);
266
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Shrinking for the Node servers, the local editor and `conloca asset add`, the way the browser shrinks before it
3
+ * sends: a photo whose long edge is over {@link MAX_IMAGE_EDGE} is stood upright and resized to it. `sharp` is an
4
+ * optional dependency, loaded only when a photo needs it. Node only, not exported.
5
+ */
6
+ import { imageSize } from 'image-size';
7
+ import { JPEG_FALLBACK_QUALITY, MAX_IMAGE_EDGE, WEBP_QUALITY } from './asset-constraints.js';
8
+ import { sniffImageFormat } from './image-format.js';
9
+ import { shrinkUnavailableWarning, unreadableImageRefusal } from './upload-refusals.js';
10
+
11
+ /** The upload to store, with a warning when it needed shrinking but could not be, or the sentence it is refused with. */
12
+ export type ShrunkUpload = { bytes: Uint8Array; filename: string; warning?: string } | { refusal: string };
13
+
14
+ /**
15
+ * `bytes` resized so their long edge is at most {@link MAX_IMAGE_EDGE}, for JPEG, PNG, WebP and AVIF over it: PNG stays
16
+ * PNG; the others become WebP named `.webp` when `acceptedFormats` takes WebP, otherwise keep their format and name.
17
+ * Everything else is handed back unchanged, as is a large photo when `sharp` cannot be loaded (with a warning).
18
+ */
19
+ export async function shrinkImage(
20
+ bytes: Uint8Array,
21
+ filename: string,
22
+ acceptedFormats: readonly string[],
23
+ ): Promise<ShrunkUpload> {
24
+ const format = sniffImageFormat(bytes);
25
+ if (format !== 'jpeg' && format !== 'png' && format !== 'webp' && format !== 'avif') return { bytes, filename };
26
+ let longEdge: number;
27
+ try {
28
+ const { width, height } = imageSize(bytes);
29
+ longEdge = Math.max(width, height);
30
+ } catch {
31
+ // Not measurable: the upload's own checks refuse it as unreadable.
32
+ return { bytes, filename };
33
+ }
34
+ if (longEdge <= MAX_IMAGE_EDGE) return { bytes, filename };
35
+
36
+ // Dynamic: sharp is an optional dependency, and a native one that can fail to load even when installed.
37
+ const sharp = await import('sharp').then(
38
+ (module) => module.default,
39
+ () => null,
40
+ );
41
+ if (sharp === null) return { bytes, filename, warning: shrinkUnavailableWarning(filename) };
42
+ const target = format === 'png' || !acceptedFormats.includes('webp') ? format : 'webp';
43
+ const quality = Math.round((target === 'jpeg' ? JPEG_FALLBACK_QUALITY : WEBP_QUALITY) * 100);
44
+ let shrunk: Uint8Array;
45
+ try {
46
+ const resized = sharp(bytes)
47
+ .rotate()
48
+ .resize({ width: MAX_IMAGE_EDGE, height: MAX_IMAGE_EDGE, fit: 'inside', withoutEnlargement: true });
49
+ // PNG takes no quality: sharp reads one as a request for a reduced palette.
50
+ shrunk = await (target === 'png' ? resized.png() : resized.toFormat(target, { quality })).toBuffer();
51
+ } catch {
52
+ return { refusal: unreadableImageRefusal(filename) };
53
+ }
54
+ if (target !== 'webp' || format === 'webp') return { bytes: shrunk, filename };
55
+ const dot = filename.lastIndexOf('.');
56
+ return { bytes: shrunk, filename: `${dot > 0 ? filename.slice(0, dot) : filename}.webp` };
57
+ }
package/src/index.ts CHANGED
@@ -5,10 +5,36 @@
5
5
  * For Node.js-specific APIs (filesystem, in-memory, middleware, etc.), import from '@conloca/content-api/node'
6
6
  */
7
7
 
8
- // Upload ceiling + image allowlist. Pure data, no node deps — the source of
8
+ // The address site and its base path, shared by every host that reads a sites.json.
9
+ export { addressSiteName, isValidSiteBase } from './address-site.js';
10
+ // Upload ceiling, image allowlist and processing constants. Pure data, no node deps — the source of
9
11
  // truth other asset backends read through this entry.
10
- // DEFAULT_ACCEPTED_FORMATS deliberately stays off the barrel — it is just the map's keys.
11
- export { DEFAULT_MAX_FILE_SIZE, IMAGE_EXTENSION_MIME } from './asset-constraints.js';
12
+ export {
13
+ DEFAULT_ACCEPTED_FORMATS,
14
+ DEFAULT_MAX_FILE_SIZE,
15
+ IMAGE_EXTENSION_MIME,
16
+ JPEG_FALLBACK_QUALITY,
17
+ MAX_IMAGE_EDGE,
18
+ VIDEO_EXTENSIONS,
19
+ WEBP_QUALITY,
20
+ } from './asset-constraints.js';
21
+ // One asset's metadata record as committed: its path and exact bytes, shared by every writer.
22
+ export {
23
+ assetMetadataRecordPath,
24
+ parseAssetMetadata,
25
+ patchAssetMetadata,
26
+ sameAssetMetadata,
27
+ serializeAssetMetadata,
28
+ } from './asset-metadata-record.js';
29
+ // The one naming rule for uploads and media folders, shared by the browser and every server.
30
+ export {
31
+ fileNameFromUrl,
32
+ folderCaseClashError,
33
+ folderPathError,
34
+ safeAssetFilename,
35
+ uniqueAssetName,
36
+ withNumberSuffix,
37
+ } from './asset-naming.js';
12
38
  // Asset types (browser-safe, from asset-types.ts - no Node.js dependencies)
13
39
  export type {
14
40
  AssetEntry,
@@ -20,6 +46,8 @@ export type {
20
46
  FolderTreeNode,
21
47
  } from './asset-types.js';
22
48
  export { ASSET_METADATA_DIR } from './asset-types.js';
49
+ // Which pages link an asset, over any listing of the content.
50
+ export { type AssetUsageSource, findAssetUsage } from './asset-usage.js';
23
51
  // Browser-safe exports
24
52
  export * from './component-registry.types.js';
25
53
  export type { ContentAPI } from './content-api.interface.js';
@@ -28,11 +56,15 @@ export * from './content-operations.js';
28
56
  export type { PathnameValidationReason, PathnameValidationResult } from './content-utils.js';
29
57
  export * from './content-utils.js';
30
58
  export { normalizeAndValidatePathname } from './content-utils.js';
59
+ // The address an unpublished upload is linked by until it is published.
60
+ export { DRAFT_MEDIA_REF_BASE, draftMediaRef, draftMediaRefPath, mediaRefPath } from './draft-media-ref.js';
31
61
  // The one validator for a site's data bindings arriving from outside the editor.
32
62
  export { readEditorDataBindings } from './editor-data-bindings.js';
33
63
  export { Fragments } from './fragments.js';
34
64
  // Git types (browser-safe, pure interfaces - no Node.js dependencies)
35
65
  export type { GitCommitResult, GitPullResult, GitPushResult, GitStatus } from './git-operations.js';
66
+ // Git LFS rule matching for uploads, shared by the online editor's upload check and its Publish.
67
+ export { type GitAttributesFile, isAutoWrittenLfsAttributes, lfsRuleFor } from './lfs-attributes.js';
36
68
  // The page feed a data binding declares, shared by the published page and the editor.
37
69
  export { pageReferenceOf, pageTimestampsOf, selectPagesByPrefix } from './page-references.js';
38
70
  // Reader backend interface types (browser-safe; type-only re-export).
@@ -56,6 +88,18 @@ export type {
56
88
  } from './schemas/types.js';
57
89
  export { Site } from './site.js';
58
90
  export * from './types.js';
91
+ // Every sentence an upload is refused or warned with, shared by the browser and every server.
92
+ export {
93
+ importRefusal,
94
+ importTooLargeRefusal,
95
+ lfsRefusal,
96
+ repoNotReadyRefusal,
97
+ shrinkUnavailableWarning,
98
+ tooLargeRefusal,
99
+ unreadableImageRefusal,
100
+ unsupportedTypeRefusal,
101
+ videoRefusal,
102
+ } from './upload-refusals.js';
59
103
  // SSRF host predicate — pure string/number logic, so any host's import guards can share it.
60
104
  export { isPrivateFetchHost } from './url-validation.js';
61
105
  export { ContentUtils } from './utils.js';