@openrails/contentkit-ui 0.0.0-stage → 0.68.1
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/README.md +470 -2
- package/dist/appearance.d.ts +38 -0
- package/dist/appearance.js +15 -0
- package/dist/appearance.js.map +1 -0
- package/dist/assets/hash.worker-BYfo-7MQ.js.map +1 -0
- package/dist/client/aspect.d.ts +6 -0
- package/dist/client/aspect.js +17 -0
- package/dist/client/aspect.js.map +1 -0
- package/dist/client/client.d.ts +53 -0
- package/dist/client/client.js +36 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/codes.d.ts +12 -0
- package/dist/client/codes.js +19 -0
- package/dist/client/codes.js.map +1 -0
- package/dist/client/content/bans.d.ts +15 -0
- package/dist/client/content/bans.js +40 -0
- package/dist/client/content/bans.js.map +1 -0
- package/dist/client/content/comments.d.ts +36 -0
- package/dist/client/content/comments.js +95 -0
- package/dist/client/content/comments.js.map +1 -0
- package/dist/client/content/favorites.d.ts +14 -0
- package/dist/client/content/favorites.js +42 -0
- package/dist/client/content/favorites.js.map +1 -0
- package/dist/client/content/moderation.d.ts +18 -0
- package/dist/client/content/moderation.js +37 -0
- package/dist/client/content/moderation.js.map +1 -0
- package/dist/client/content/polls.d.ts +47 -0
- package/dist/client/content/polls.js +151 -0
- package/dist/client/content/polls.js.map +1 -0
- package/dist/client/content/posts.d.ts +44 -0
- package/dist/client/content/posts.js +92 -0
- package/dist/client/content/posts.js.map +1 -0
- package/dist/client/content/reactions.d.ts +12 -0
- package/dist/client/content/reactions.js +36 -0
- package/dist/client/content/reactions.js.map +1 -0
- package/dist/client/content/types.d.ts +91 -0
- package/dist/client/content/types.js +8 -0
- package/dist/client/content/types.js.map +1 -0
- package/dist/client/crop.d.ts +32 -0
- package/dist/client/crop.js +103 -0
- package/dist/client/crop.js.map +1 -0
- package/dist/client/errors.d.ts +54 -0
- package/dist/client/errors.js +80 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/gallery.d.ts +43 -0
- package/dist/client/gallery.js +86 -0
- package/dist/client/gallery.js.map +1 -0
- package/dist/client/generated/error-codes.d.ts +5 -0
- package/dist/client/generated/error-codes.js +131 -0
- package/dist/client/generated/error-codes.js.map +1 -0
- package/dist/client/generated/routes.d.ts +1086 -0
- package/dist/client/generated/routes.js +1400 -0
- package/dist/client/generated/routes.js.map +1 -0
- package/dist/client/generated/wire.d.ts +630 -0
- package/dist/client/generated/wire.js +6 -0
- package/dist/client/generated/wire.js.map +1 -0
- package/dist/client/http.d.ts +83 -0
- package/dist/client/http.js +82 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/image.d.ts +24 -0
- package/dist/client/image.js +65 -0
- package/dist/client/image.js.map +1 -0
- package/dist/client/index.d.ts +33 -0
- package/dist/client/media/api.d.ts +36 -0
- package/dist/client/media/api.js +61 -0
- package/dist/client/media/api.js.map +1 -0
- package/dist/client/media/client.d.ts +247 -0
- package/dist/client/media/client.js +407 -0
- package/dist/client/media/client.js.map +1 -0
- package/dist/client/media/encode.d.ts +3 -0
- package/dist/client/media/encode.js +8 -0
- package/dist/client/media/encode.js.map +1 -0
- package/dist/client/media/hash-stream.d.ts +6 -0
- package/dist/client/media/hash-stream.js +16 -0
- package/dist/client/media/hash-stream.js.map +1 -0
- package/dist/client/media/hash.d.ts +12 -0
- package/dist/client/media/hash.js +48 -0
- package/dist/client/media/hash.js.map +1 -0
- package/dist/client/media/hash.worker-inline.js +18 -0
- package/dist/client/media/hash.worker-inline.js.map +1 -0
- package/dist/client/media/pacer.d.ts +21 -0
- package/dist/client/media/pacer.js +25 -0
- package/dist/client/media/pacer.js.map +1 -0
- package/dist/client/media/queue.d.ts +112 -0
- package/dist/client/media/queue.js +274 -0
- package/dist/client/media/queue.js.map +1 -0
- package/dist/client/media/ref.d.ts +6 -0
- package/dist/client/media/ref.js +10 -0
- package/dist/client/media/ref.js.map +1 -0
- package/dist/client/media/rules.d.ts +54 -0
- package/dist/client/media/rules.js +143 -0
- package/dist/client/media/rules.js.map +1 -0
- package/dist/client/media/transport.d.ts +13 -0
- package/dist/client/media/transport.js +33 -0
- package/dist/client/media/transport.js.map +1 -0
- package/dist/client/media/windows.d.ts +15 -0
- package/dist/client/media/windows.js +39 -0
- package/dist/client/media/windows.js.map +1 -0
- package/dist/client/playback.d.ts +200 -0
- package/dist/client/playback.js +142 -0
- package/dist/client/playback.js.map +1 -0
- package/dist/client/player.d.ts +102 -0
- package/dist/client/player.js +155 -0
- package/dist/client/player.js.map +1 -0
- package/dist/client/public.d.ts +25 -0
- package/dist/client/public.js +18 -0
- package/dist/client/public.js.map +1 -0
- package/dist/client/rendition.d.ts +19 -0
- package/dist/client/rendition.js +16 -0
- package/dist/client/rendition.js.map +1 -0
- package/dist/client/route.d.ts +39 -0
- package/dist/client/route.js +31 -0
- package/dist/client/route.js.map +1 -0
- package/dist/client/taxonomy.d.ts +30 -0
- package/dist/client/taxonomy.js +77 -0
- package/dist/client/taxonomy.js.map +1 -0
- package/dist/client.js +33 -0
- package/dist/components/encode-progress.d.ts +15 -0
- package/dist/components/encode-progress.js +49 -0
- package/dist/components/encode-progress.js.map +1 -0
- package/dist/components/hover-preview.d.ts +29 -0
- package/dist/components/hover-preview.js +49 -0
- package/dist/components/hover-preview.js.map +1 -0
- package/dist/components/image-crop-dialog.d.ts +48 -0
- package/dist/components/image-crop-dialog.js +359 -0
- package/dist/components/image-crop-dialog.js.map +1 -0
- package/dist/components/lazy-mount.d.ts +10 -0
- package/dist/components/lazy-mount.js +22 -0
- package/dist/components/lazy-mount.js.map +1 -0
- package/dist/components/media-folder-editor.d.ts +59 -0
- package/dist/components/media-folder-editor.js +611 -0
- package/dist/components/media-folder-editor.js.map +1 -0
- package/dist/components/media-gallery.d.ts +54 -0
- package/dist/components/media-gallery.js +597 -0
- package/dist/components/media-gallery.js.map +1 -0
- package/dist/components/media-readiness-notice.d.ts +24 -0
- package/dist/components/media-readiness-notice.js +61 -0
- package/dist/components/media-readiness-notice.js.map +1 -0
- package/dist/components/player-controls.d.ts +71 -0
- package/dist/components/player-controls.js +264 -0
- package/dist/components/player-controls.js.map +1 -0
- package/dist/components/progress.d.ts +5 -0
- package/dist/components/progress.js +14 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/rendition-img.d.ts +34 -0
- package/dist/components/rendition-img.js +78 -0
- package/dist/components/rendition-img.js.map +1 -0
- package/dist/components/slot-editor.d.ts +95 -0
- package/dist/components/slot-editor.js +182 -0
- package/dist/components/slot-editor.js.map +1 -0
- package/dist/components/slot-image.d.ts +23 -0
- package/dist/components/slot-image.js +48 -0
- package/dist/components/slot-image.js.map +1 -0
- package/dist/components/slot-upload.d.ts +41 -0
- package/dist/components/slot-upload.js +215 -0
- package/dist/components/slot-upload.js.map +1 -0
- package/dist/components/social/bans.d.ts +42 -0
- package/dist/components/social/bans.js +300 -0
- package/dist/components/social/bans.js.map +1 -0
- package/dist/components/social/comments.d.ts +42 -0
- package/dist/components/social/comments.js +517 -0
- package/dist/components/social/comments.js.map +1 -0
- package/dist/components/social/engagement.d.ts +45 -0
- package/dist/components/social/engagement.js +129 -0
- package/dist/components/social/engagement.js.map +1 -0
- package/dist/components/social/index.d.ts +6 -0
- package/dist/components/social/moderation.d.ts +32 -0
- package/dist/components/social/moderation.js +383 -0
- package/dist/components/social/moderation.js.map +1 -0
- package/dist/components/social/parts.d.ts +50 -0
- package/dist/components/social/parts.js +106 -0
- package/dist/components/social/parts.js.map +1 -0
- package/dist/components/social/poll-editor.d.ts +34 -0
- package/dist/components/social/poll-editor.js +567 -0
- package/dist/components/social/poll-editor.js.map +1 -0
- package/dist/components/social/poll.d.ts +30 -0
- package/dist/components/social/poll.js +252 -0
- package/dist/components/social/poll.js.map +1 -0
- package/dist/components/sortable-list.d.ts +29 -0
- package/dist/components/sortable-list.js +121 -0
- package/dist/components/sortable-list.js.map +1 -0
- package/dist/components/video-mini-player.d.ts +35 -0
- package/dist/components/video-mini-player.js +236 -0
- package/dist/components/video-mini-player.js.map +1 -0
- package/dist/components/video-player.d.ts +146 -0
- package/dist/components/video-player.js +630 -0
- package/dist/components/video-player.js.map +1 -0
- package/dist/components/video-poster-picker.d.ts +59 -0
- package/dist/components/video-poster-picker.js +335 -0
- package/dist/components/video-poster-picker.js.map +1 -0
- package/dist/components/video-poster.d.ts +24 -0
- package/dist/components/video-poster.js +46 -0
- package/dist/components/video-poster.js.map +1 -0
- package/dist/i18n/context.d.ts +4 -0
- package/dist/i18n/context.js +11 -0
- package/dist/i18n/context.js.map +1 -0
- package/dist/i18n/messages.d.ts +40 -0
- package/dist/i18n/messages.js +94 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +41 -0
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/de.js +271 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/en.d.ts +457 -0
- package/dist/locales/en.js +271 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es.d.ts +2 -0
- package/dist/locales/es.js +271 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/ja.d.ts +2 -0
- package/dist/locales/ja.js +271 -0
- package/dist/locales/ja.js.map +1 -0
- package/dist/locales/ko.d.ts +2 -0
- package/dist/locales/ko.js +271 -0
- package/dist/locales/ko.js.map +1 -0
- package/dist/locales/social/de.d.ts +2 -0
- package/dist/locales/social/de.js +198 -0
- package/dist/locales/social/de.js.map +1 -0
- package/dist/locales/social/en.d.ts +195 -0
- package/dist/locales/social/en.js +198 -0
- package/dist/locales/social/en.js.map +1 -0
- package/dist/locales/social/es.d.ts +2 -0
- package/dist/locales/social/es.js +198 -0
- package/dist/locales/social/es.js.map +1 -0
- package/dist/locales/social/ja.d.ts +2 -0
- package/dist/locales/social/ja.js +198 -0
- package/dist/locales/social/ja.js.map +1 -0
- package/dist/locales/social/ko.d.ts +2 -0
- package/dist/locales/social/ko.js +198 -0
- package/dist/locales/social/ko.js.map +1 -0
- package/dist/locales/social/zh.d.ts +2 -0
- package/dist/locales/social/zh.js +198 -0
- package/dist/locales/social/zh.js.map +1 -0
- package/dist/locales/zh.d.ts +2 -0
- package/dist/locales/zh.js +271 -0
- package/dist/locales/zh.js.map +1 -0
- package/dist/provider.d.ts +22 -0
- package/dist/provider.js +59 -0
- package/dist/provider.js.map +1 -0
- package/dist/react/canonical.d.ts +33 -0
- package/dist/react/canonical.js +78 -0
- package/dist/react/canonical.js.map +1 -0
- package/dist/react/comments.d.ts +82 -0
- package/dist/react/comments.js +155 -0
- package/dist/react/comments.js.map +1 -0
- package/dist/react/config.d.ts +13 -0
- package/dist/react/config.js +14 -0
- package/dist/react/config.js.map +1 -0
- package/dist/react/context.d.ts +55 -0
- package/dist/react/context.js +42 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/crop.d.ts +49 -0
- package/dist/react/crop.js +107 -0
- package/dist/react/crop.js.map +1 -0
- package/dist/react/engagement.d.ts +38 -0
- package/dist/react/engagement.js +88 -0
- package/dist/react/engagement.js.map +1 -0
- package/dist/react/folder.d.ts +103 -0
- package/dist/react/folder.js +240 -0
- package/dist/react/folder.js.map +1 -0
- package/dist/react/gallery.d.ts +140 -0
- package/dist/react/gallery.js +477 -0
- package/dist/react/gallery.js.map +1 -0
- package/dist/react/index.d.ts +21 -0
- package/dist/react/inline-preview.d.ts +24 -0
- package/dist/react/inline-preview.js +76 -0
- package/dist/react/inline-preview.js.map +1 -0
- package/dist/react/player.d.ts +70 -0
- package/dist/react/player.js +214 -0
- package/dist/react/player.js.map +1 -0
- package/dist/react/polls.d.ts +74 -0
- package/dist/react/polls.js +176 -0
- package/dist/react/polls.js.map +1 -0
- package/dist/react/posts.d.ts +59 -0
- package/dist/react/posts.js +149 -0
- package/dist/react/posts.js.map +1 -0
- package/dist/react/provider.d.ts +27 -0
- package/dist/react/provider.js +49 -0
- package/dist/react/provider.js.map +1 -0
- package/dist/react/public.d.ts +39 -0
- package/dist/react/public.js +70 -0
- package/dist/react/public.js.map +1 -0
- package/dist/react/read.d.ts +52 -0
- package/dist/react/read.js +144 -0
- package/dist/react/read.js.map +1 -0
- package/dist/react/resources.d.ts +73 -0
- package/dist/react/resources.js +247 -0
- package/dist/react/resources.js.map +1 -0
- package/dist/react/slot.d.ts +104 -0
- package/dist/react/slot.js +185 -0
- package/dist/react/slot.js.map +1 -0
- package/dist/react/store.d.ts +51 -0
- package/dist/react/store.js +165 -0
- package/dist/react/store.js.map +1 -0
- package/dist/react/upload.d.ts +86 -0
- package/dist/react/upload.js +155 -0
- package/dist/react/upload.js.map +1 -0
- package/dist/react/use-resource.d.ts +44 -0
- package/dist/react/use-resource.js +74 -0
- package/dist/react/use-resource.js.map +1 -0
- package/dist/react/video.d.ts +118 -0
- package/dist/react/video.js +184 -0
- package/dist/react/video.js.map +1 -0
- package/dist/react/viewport.d.ts +19 -0
- package/dist/react/viewport.js +30 -0
- package/dist/react/viewport.js.map +1 -0
- package/dist/react.js +21 -0
- package/dist/scope.d.ts +14 -0
- package/dist/scope.js +30 -0
- package/dist/scope.js.map +1 -0
- package/dist/styles.css +3 -0
- package/dist/ui/alert-dialog.d.ts +18 -0
- package/dist/ui/alert-dialog.js +86 -0
- package/dist/ui/alert-dialog.js.map +1 -0
- package/dist/ui/alert.d.ts +10 -0
- package/dist/ui/alert.js +38 -0
- package/dist/ui/alert.js.map +1 -0
- package/dist/ui/avatar.d.ts +11 -0
- package/dist/ui/avatar.js +31 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/badge.d.ts +7 -0
- package/dist/ui/badge.js +31 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/button.d.ts +8 -0
- package/dist/ui/button.js +46 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/dialog.d.ts +17 -0
- package/dist/ui/dialog.js +91 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/dropdown-menu.d.ts +15 -0
- package/dist/ui/dropdown-menu.js +105 -0
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +17 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/label.d.ts +3 -0
- package/dist/ui/label.js +15 -0
- package/dist/ui/label.js.map +1 -0
- package/dist/ui/progress.d.ts +7 -0
- package/dist/ui/progress.js +31 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/select.d.ts +15 -0
- package/dist/ui/select.js +98 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/skeleton.d.ts +2 -0
- package/dist/ui/skeleton.js +14 -0
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/ui/slider.d.ts +3 -0
- package/dist/ui/slider.js +35 -0
- package/dist/ui/slider.js.map +1 -0
- package/dist/ui/switch.d.ts +5 -0
- package/dist/ui/switch.js +20 -0
- package/dist/ui/switch.js.map +1 -0
- package/dist/ui/tabs.d.ts +10 -0
- package/dist/ui/tabs.js +47 -0
- package/dist/ui/tabs.js.map +1 -0
- package/dist/ui/textarea.d.ts +3 -0
- package/dist/ui/textarea.js +15 -0
- package/dist/ui/textarea.js.map +1 -0
- package/dist/ui/toggle-group.d.ts +5 -0
- package/dist/ui/toggle-group.js +23 -0
- package/dist/ui/toggle-group.js.map +1 -0
- package/dist/urls/index.d.ts +100 -0
- package/dist/urls.js +118 -0
- package/dist/urls.js.map +1 -0
- package/package.json +120 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/client/crop.ts
|
|
2
|
+
function e(e, t, n, r = 0) {
|
|
3
|
+
let i = Math.max(1, Math.round(t.width)), a = Math.max(1, Math.round(t.height)), o = l(Math.round(e.w), 1, i), s = l(Math.round(e.h), 1, a);
|
|
4
|
+
if (n && n > 0) {
|
|
5
|
+
let e = r === 90 || r === 270 ? 1 / n : n;
|
|
6
|
+
for (s = Math.round(o / e), s > a && (o = Math.round(a * e)), o = l(o, 1, i), s = Math.round(o / e); s > a && o > 1;) s = Math.round(--o / e);
|
|
7
|
+
for (; s < 1 && o < i;) s = Math.round(++o / e);
|
|
8
|
+
s = Math.max(1, s);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
x: l(Math.round(e.x), 0, i - o),
|
|
12
|
+
y: l(Math.round(e.y), 0, a - s),
|
|
13
|
+
w: o,
|
|
14
|
+
h: s
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function t(e, t, r, a = 0) {
|
|
18
|
+
let o = n(r, a), s = o.width / t.width, c = o.height / t.height;
|
|
19
|
+
return i({
|
|
20
|
+
x: e.x * s,
|
|
21
|
+
y: e.y * c,
|
|
22
|
+
w: e.w * s,
|
|
23
|
+
h: e.h * c
|
|
24
|
+
}, r, a);
|
|
25
|
+
}
|
|
26
|
+
function n(e, t = 0) {
|
|
27
|
+
return t === 90 || t === 270 ? {
|
|
28
|
+
width: e.height,
|
|
29
|
+
height: e.width
|
|
30
|
+
} : e;
|
|
31
|
+
}
|
|
32
|
+
function r(e, t, n) {
|
|
33
|
+
let { width: r, height: i } = t;
|
|
34
|
+
return n === 90 ? {
|
|
35
|
+
x: i - (e.y + e.h),
|
|
36
|
+
y: e.x,
|
|
37
|
+
w: e.h,
|
|
38
|
+
h: e.w
|
|
39
|
+
} : n === 180 ? {
|
|
40
|
+
x: r - (e.x + e.w),
|
|
41
|
+
y: i - (e.y + e.h),
|
|
42
|
+
w: e.w,
|
|
43
|
+
h: e.h
|
|
44
|
+
} : n === 270 ? {
|
|
45
|
+
x: e.y,
|
|
46
|
+
y: r - (e.x + e.w),
|
|
47
|
+
w: e.h,
|
|
48
|
+
h: e.w
|
|
49
|
+
} : e;
|
|
50
|
+
}
|
|
51
|
+
function i(e, t, n) {
|
|
52
|
+
let { width: r, height: i } = t;
|
|
53
|
+
return n === 90 ? {
|
|
54
|
+
x: e.y,
|
|
55
|
+
y: i - (e.x + e.w),
|
|
56
|
+
w: e.h,
|
|
57
|
+
h: e.w
|
|
58
|
+
} : n === 180 ? {
|
|
59
|
+
x: r - (e.x + e.w),
|
|
60
|
+
y: i - (e.y + e.h),
|
|
61
|
+
w: e.w,
|
|
62
|
+
h: e.h
|
|
63
|
+
} : n === 270 ? {
|
|
64
|
+
x: r - (e.y + e.h),
|
|
65
|
+
y: e.x,
|
|
66
|
+
w: e.h,
|
|
67
|
+
h: e.w
|
|
68
|
+
} : e;
|
|
69
|
+
}
|
|
70
|
+
function a(t, n, r = 0) {
|
|
71
|
+
let i = e({
|
|
72
|
+
x: 0,
|
|
73
|
+
y: 0,
|
|
74
|
+
w: t.width,
|
|
75
|
+
h: t.height
|
|
76
|
+
}, t, n, r);
|
|
77
|
+
return {
|
|
78
|
+
...i,
|
|
79
|
+
x: Math.floor((t.width - i.w) / 2),
|
|
80
|
+
y: Math.floor((t.height - i.h) / 2)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function o(e, t, n = 0) {
|
|
84
|
+
let r = !e || e.x === 0 && e.y === 0 && e.w === t.width && e.h === t.height;
|
|
85
|
+
return r && n === 0 ? null : {
|
|
86
|
+
...r ? {} : { crop: e },
|
|
87
|
+
...n ? { rotate: n } : {}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function s(e, t) {
|
|
91
|
+
let n = e?.crop, r = t?.crop;
|
|
92
|
+
return (e?.rotate ?? 0) === (t?.rotate ?? 0) && (n === r || !!n && !!r && n.x === r.x && n.y === r.y && n.w === r.w && n.h === r.h);
|
|
93
|
+
}
|
|
94
|
+
function c(e) {
|
|
95
|
+
return (Math.round(e / 90) * 90 % 360 + 360) % 360;
|
|
96
|
+
}
|
|
97
|
+
function l(e, t, n) {
|
|
98
|
+
return Math.min(Math.max(e, t), n);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { a as centeredCrop, e as constrainCrop, o as editOf, n as editedSize, i as fromRotated, c as rotation, s as sameEdit, t as toOriginal, r as toRotated };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=crop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop.js","names":[],"sources":["../../src/client/crop.ts"],"sourcesContent":["import type { Crop, Edit } from \"./generated/wire.js\";\n\n/** Clockwise degrees. */\nexport type Rotation = 0 | 90 | 180 | 270;\n\nexport interface Size {\n width: number;\n height: number;\n}\n\n/**\n * Fits rect (original pixels) inside source as whole pixels. With aspect (the\n * edited image's width/height; with a 90/270 rotation the crop is its\n * transpose) the height follows the width exactly as the server derives it.\n */\nexport function constrainCrop(rect: Crop, source: Size, aspect?: number, rotate: Rotation = 0): Crop {\n const W = Math.max(1, Math.round(source.width));\n const H = Math.max(1, Math.round(source.height));\n let w = clamp(Math.round(rect.w), 1, W);\n let h = clamp(Math.round(rect.h), 1, H);\n if (aspect && aspect > 0) {\n const r = rotate === 90 || rotate === 270 ? 1 / aspect : aspect; // crop width / height\n h = Math.round(w / r);\n if (h > H) w = Math.round(H * r);\n w = clamp(w, 1, W);\n h = Math.round(w / r);\n while (h > H && w > 1) h = Math.round(--w / r);\n while (h < 1 && w < W) h = Math.round(++w / r);\n h = Math.max(1, h);\n }\n return { x: clamp(Math.round(rect.x), 0, W - w), y: clamp(Math.round(rect.y), 0, H - h), w, h };\n}\n\n/**\n * Maps a rect on the image shown at display size to original pixels. With a\n * rotation, display is the rotated image (as a cropper shows it) and the rect\n * is mapped back through the rotation.\n */\nexport function toOriginal(rect: Crop, display: Size, source: Size, rotate: Rotation = 0): Crop {\n const shown = editedSize(source, rotate);\n const sx = shown.width / display.width;\n const sy = shown.height / display.height;\n return fromRotated({ x: rect.x * sx, y: rect.y * sy, w: rect.w * sx, h: rect.h * sy }, source, rotate);\n}\n\n/** The image's size after a clockwise rotation. */\nexport function editedSize(source: Size, rotate: Rotation = 0): Size {\n return rotate === 90 || rotate === 270 ? { width: source.height, height: source.width } : source;\n}\n\n/** A rect in original pixels as it lies on the image turned clockwise by rotate. */\nexport function toRotated(r: Crop, source: Size, rotate: Rotation): Crop {\n const { width: W, height: H } = source;\n if (rotate === 90) return { x: H - (r.y + r.h), y: r.x, w: r.h, h: r.w };\n if (rotate === 180) return { x: W - (r.x + r.w), y: H - (r.y + r.h), w: r.w, h: r.h };\n if (rotate === 270) return { x: r.y, y: W - (r.x + r.w), w: r.h, h: r.w };\n return r;\n}\n\n/** Inverse of toRotated: a rect on the rotated image back in original pixels. */\nexport function fromRotated(r: Crop, source: Size, rotate: Rotation): Crop {\n const { width: W, height: H } = source;\n if (rotate === 90) return { x: r.y, y: H - (r.x + r.w), w: r.h, h: r.w };\n if (rotate === 180) return { x: W - (r.x + r.w), y: H - (r.y + r.h), w: r.w, h: r.h };\n if (rotate === 270) return { x: W - (r.y + r.h), y: r.x, w: r.h, h: r.w };\n return r;\n}\n\n/** The largest centred crop (at aspect, if any). */\nexport function centeredCrop(source: Size, aspect?: number, rotate: Rotation = 0): Crop {\n const c = constrainCrop({ x: 0, y: 0, w: source.width, h: source.height }, source, aspect, rotate);\n return { ...c, x: Math.floor((source.width - c.w) / 2), y: Math.floor((source.height - c.h) / 2) };\n}\n\n/** The edit for a crop and rotation; null when it changes nothing. */\nexport function editOf(crop: Crop | null, source: Size, rotate: Rotation = 0): Edit | null {\n const full = !crop || (crop.x === 0 && crop.y === 0 && crop.w === source.width && crop.h === source.height);\n if (full && rotate === 0) return null;\n return { ...(full ? {} : { crop }), ...(rotate ? { rotate } : {}) };\n}\n\n/** Whether two edits are the same value (null and an empty edit are). */\nexport function sameEdit(a: Edit | null | undefined, b: Edit | null | undefined): boolean {\n const x = a?.crop, y = b?.crop;\n return (a?.rotate ?? 0) === (b?.rotate ?? 0) && (x === y || (!!x && !!y && x.x === y.x && x.y === y.y && x.w === y.w && x.h === y.h));\n}\n\nexport function rotation(deg: number): Rotation {\n return ((((Math.round(deg / 90) * 90) % 360) + 360) % 360) as Rotation;\n}\n\nfunction clamp(v: number, lo: number, hi: number) {\n return Math.min(Math.max(v, lo), hi);\n}\n"],"mappings":";AAeA,SAAgB,EAAc,GAAY,GAAc,GAAiB,IAAmB,GAAS;CACnG,IAAM,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,EA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SAAgB,EAAO,GAAmB,GAAc,IAAmB,GAAgB;CACzF,IAAM,IAAO,CAAC,KAAS,EAAK,MAAM,KAAK,EAAK,MAAM,KAAK,EAAK,MAAM,EAAO,SAAS,EAAK,MAAM,EAAO;CAEpG,OADI,KAAQ,MAAW,IAAU,OAC1B;EAAE,GAAI,IAAO,CAAC,IAAI,EAAE,QAAK;EAAI,GAAI,IAAS,EAAE,UAAO,IAAI,CAAC;CAAG;AACpE;AAGA,SAAgB,EAAS,GAA4B,GAAqC;CACxF,IAAM,IAAI,GAAG,MAAM,IAAI,GAAG;CAC1B,QAAQ,GAAG,UAAU,QAAQ,GAAG,UAAU,OAAO,MAAM,KAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;AACpI;AAEA,SAAgB,EAAS,GAAuB;CAC9C,QAAW,KAAK,MAAM,IAAM,EAAE,IAAI,KAAM,MAAO,OAAO;AACxD;AAEA,SAAS,EAAM,GAAW,GAAY,GAAY;CAChD,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,CAAE,GAAG,CAAE;AACrC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ErrorCode } from './generated/error-codes.js';
|
|
2
|
+
import { BanNotice, ErrorDetails, Failure } from './generated/wire.js';
|
|
3
|
+
/**
|
|
4
|
+
* Codes raised in the browser: network (no response), storage (the bucket
|
|
5
|
+
* refused a PUT), aborted (the caller's signal), resume_mismatch (saved state
|
|
6
|
+
* is not for this file), decode (not readable as an image) and render_timeout
|
|
7
|
+
* (still processing after the wait).
|
|
8
|
+
*/
|
|
9
|
+
export declare const CLIENT_ERROR_CODES: readonly ["network", "storage", "aborted", "resume_mismatch", "decode", "render_timeout"];
|
|
10
|
+
export type ContentKitErrorCode = ErrorCode | (typeof CLIENT_ERROR_CODES)[number];
|
|
11
|
+
/** Every code a ContentKitError can carry: the server's registry, then the client's. */
|
|
12
|
+
export declare const ERROR_CODES: readonly ContentKitErrorCode[];
|
|
13
|
+
export interface ContentKitErrorInit extends ErrorOptions {
|
|
14
|
+
status?: number;
|
|
15
|
+
retryAfter?: number;
|
|
16
|
+
details?: ErrorDetails;
|
|
17
|
+
blobs?: string[];
|
|
18
|
+
ban?: BanNotice;
|
|
19
|
+
action?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class ContentKitError extends Error {
|
|
22
|
+
readonly code: ContentKitErrorCode;
|
|
23
|
+
readonly name = "ContentKitError";
|
|
24
|
+
/** HTTP status; 0 for client-side codes. */
|
|
25
|
+
readonly status: number;
|
|
26
|
+
readonly retryAfter?: number;
|
|
27
|
+
readonly details?: ErrorDetails;
|
|
28
|
+
readonly blobs?: string[];
|
|
29
|
+
readonly ban?: BanNotice;
|
|
30
|
+
readonly action?: string;
|
|
31
|
+
constructor(code: ContentKitErrorCode, message: string, init?: ContentKitErrorInit);
|
|
32
|
+
/**
|
|
33
|
+
* The request broke a rule the message states (a 4xx or a typed refusal),
|
|
34
|
+
* as opposed to a fault on the server or the network: show it as is.
|
|
35
|
+
*/
|
|
36
|
+
get refusal(): boolean;
|
|
37
|
+
/** Rate or quota refusals: stop starting new requests until the limit frees. */
|
|
38
|
+
get isLimit(): boolean;
|
|
39
|
+
/** The commit would exceed the kind's file caps (too_many_files, 409): remove files first. */
|
|
40
|
+
get isCeiling(): boolean;
|
|
41
|
+
/** Refusals that apply to every upload of this caller, not just this file. */
|
|
42
|
+
get blocksQueue(): boolean;
|
|
43
|
+
/** Worth retrying the same request. */
|
|
44
|
+
get transient(): boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare const isContentKitError: (e: unknown) => e is ContentKitError;
|
|
47
|
+
/** Anything a call can throw, as a ContentKitError (network when it is not one). */
|
|
48
|
+
export declare function toContentKitError(e: unknown): ContentKitError;
|
|
49
|
+
export declare function aborted(signal?: AbortSignal): ContentKitError;
|
|
50
|
+
export declare function throwIfAborted(signal?: AbortSignal): void;
|
|
51
|
+
/** Reads a response that is not 2xx. */
|
|
52
|
+
export declare function readContentKitError(res: Response): Promise<ContentKitError>;
|
|
53
|
+
/** An upload's recorded processing failure: its typed refusal, else a processing fault. */
|
|
54
|
+
export declare function failureError(f: Failure): ContentKitError;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { CONTENTKIT_ERROR_CODES as e } from "./generated/error-codes.js";
|
|
2
|
+
//#region src/client/errors.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"network",
|
|
5
|
+
"storage",
|
|
6
|
+
"aborted",
|
|
7
|
+
"resume_mismatch",
|
|
8
|
+
"decode",
|
|
9
|
+
"render_timeout"
|
|
10
|
+
], n = [...Object.keys(e), ...t], r = class extends Error {
|
|
11
|
+
code;
|
|
12
|
+
name = "ContentKitError";
|
|
13
|
+
status;
|
|
14
|
+
retryAfter;
|
|
15
|
+
details;
|
|
16
|
+
blobs;
|
|
17
|
+
ban;
|
|
18
|
+
action;
|
|
19
|
+
constructor(e, t, n = {}) {
|
|
20
|
+
super(t, n.cause === void 0 ? void 0 : { cause: n.cause }), this.code = e, this.status = n.status ?? 0, this.retryAfter = n.retryAfter, this.details = n.details, this.blobs = n.blobs, this.ban = n.ban, this.action = n.action;
|
|
21
|
+
}
|
|
22
|
+
get refusal() {
|
|
23
|
+
return this.status >= 400 && this.status < 500 && this.code !== "storage" || this.code.startsWith("image_") || this.code === "decode";
|
|
24
|
+
}
|
|
25
|
+
get isLimit() {
|
|
26
|
+
return this.code === "rate_limited" || this.code === "quota_exceeded";
|
|
27
|
+
}
|
|
28
|
+
get isCeiling() {
|
|
29
|
+
return this.code === "too_many_files";
|
|
30
|
+
}
|
|
31
|
+
get blocksQueue() {
|
|
32
|
+
return this.isLimit || this.code === "unauthorized" || this.code === "forbidden";
|
|
33
|
+
}
|
|
34
|
+
get transient() {
|
|
35
|
+
return this.code === "network" || this.code === "internal_error" || this.code === "unavailable" || this.code === "storage" && (this.status >= 500 || this.status === 403 || this.status === 408 || this.status === 429);
|
|
36
|
+
}
|
|
37
|
+
}, i = (e) => e instanceof r;
|
|
38
|
+
function a(e) {
|
|
39
|
+
return e instanceof r ? e : new r("network", e instanceof Error ? e.message : String(e), { cause: e });
|
|
40
|
+
}
|
|
41
|
+
function o(e) {
|
|
42
|
+
return new r("aborted", "request canceled", { cause: e?.reason });
|
|
43
|
+
}
|
|
44
|
+
function s(e) {
|
|
45
|
+
if (e?.aborted) throw o(e);
|
|
46
|
+
}
|
|
47
|
+
var c = {
|
|
48
|
+
401: "unauthorized",
|
|
49
|
+
403: "forbidden",
|
|
50
|
+
404: "not_found",
|
|
51
|
+
409: "conflict",
|
|
52
|
+
410: "gone",
|
|
53
|
+
413: "too_large",
|
|
54
|
+
415: "type_not_allowed",
|
|
55
|
+
429: "rate_limited",
|
|
56
|
+
501: "not_configured",
|
|
57
|
+
503: "unavailable"
|
|
58
|
+
}, l = new Set(n);
|
|
59
|
+
async function u(e) {
|
|
60
|
+
let t = {};
|
|
61
|
+
try {
|
|
62
|
+
t = await e.json();
|
|
63
|
+
} catch {}
|
|
64
|
+
let n = Number(e.headers.get("Retry-After")), i = t.retry_after ?? (Number.isFinite(n) && n > 0 ? n : void 0);
|
|
65
|
+
return new r(t.code && l.has(t.code) ? t.code : c[e.status] ?? (e.status >= 500 ? "internal_error" : "invalid_request"), t.error ?? `HTTP ${e.status}`, {
|
|
66
|
+
status: e.status,
|
|
67
|
+
retryAfter: i,
|
|
68
|
+
blobs: t.blobs,
|
|
69
|
+
details: t.details,
|
|
70
|
+
ban: t.ban,
|
|
71
|
+
action: t.action
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function d(e) {
|
|
75
|
+
return new r(e.code && l.has(e.code) ? e.code : "internal_error", e.message, { details: e.details });
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { t as CLIENT_ERROR_CODES, r as ContentKitError, n as ERROR_CODES, o as aborted, d as failureError, i as isContentKitError, u as readContentKitError, s as throwIfAborted, a as toContentKitError };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../../src/client/errors.ts"],"sourcesContent":["import { CONTENTKIT_ERROR_CODES, type ErrorCode } from \"./generated/error-codes.js\";\nimport type { BanNotice, ErrorDetails, ErrorReply, Failure } from \"./generated/wire.js\";\n\n/**\n * Codes raised in the browser: network (no response), storage (the bucket\n * refused a PUT), aborted (the caller's signal), resume_mismatch (saved state\n * is not for this file), decode (not readable as an image) and render_timeout\n * (still processing after the wait).\n */\nexport const CLIENT_ERROR_CODES = [\"network\", \"storage\", \"aborted\", \"resume_mismatch\", \"decode\", \"render_timeout\"] as const;\n\nexport type ContentKitErrorCode = ErrorCode | (typeof CLIENT_ERROR_CODES)[number];\n\n/** Every code a ContentKitError can carry: the server's registry, then the client's. */\nexport const ERROR_CODES: readonly ContentKitErrorCode[] = [...(Object.keys(CONTENTKIT_ERROR_CODES) as ErrorCode[]), ...CLIENT_ERROR_CODES];\n\nexport interface ContentKitErrorInit extends ErrorOptions {\n status?: number;\n retryAfter?: number;\n details?: ErrorDetails;\n blobs?: string[];\n ban?: BanNotice;\n action?: string;\n}\n\nexport class ContentKitError extends Error {\n override readonly name = \"ContentKitError\";\n /** HTTP status; 0 for client-side codes. */\n readonly status: number;\n readonly retryAfter?: number;\n readonly details?: ErrorDetails;\n readonly blobs?: string[];\n readonly ban?: BanNotice;\n readonly action?: string;\n\n constructor(\n readonly code: ContentKitErrorCode,\n message: string,\n init: ContentKitErrorInit = {},\n ) {\n super(message, init.cause === undefined ? undefined : { cause: init.cause });\n this.status = init.status ?? 0;\n this.retryAfter = init.retryAfter;\n this.details = init.details;\n this.blobs = init.blobs;\n this.ban = init.ban;\n this.action = init.action;\n }\n\n /**\n * The request broke a rule the message states (a 4xx or a typed refusal),\n * as opposed to a fault on the server or the network: show it as is.\n */\n get refusal(): boolean {\n return (this.status >= 400 && this.status < 500 && this.code !== \"storage\") || this.code.startsWith(\"image_\") || this.code === \"decode\";\n }\n\n /** Rate or quota refusals: stop starting new requests until the limit frees. */\n get isLimit(): boolean {\n return this.code === \"rate_limited\" || this.code === \"quota_exceeded\";\n }\n\n /** The commit would exceed the kind's file caps (too_many_files, 409): remove files first. */\n get isCeiling(): boolean {\n return this.code === \"too_many_files\";\n }\n\n /** Refusals that apply to every upload of this caller, not just this file. */\n get blocksQueue(): boolean {\n return this.isLimit || this.code === \"unauthorized\" || this.code === \"forbidden\";\n }\n\n /** Worth retrying the same request. */\n get transient(): boolean {\n return (\n this.code === \"network\" ||\n this.code === \"internal_error\" ||\n this.code === \"unavailable\" ||\n (this.code === \"storage\" && (this.status >= 500 || this.status === 403 || this.status === 408 || this.status === 429))\n );\n }\n}\n\nexport const isContentKitError = (e: unknown): e is ContentKitError => e instanceof ContentKitError;\n\n/** Anything a call can throw, as a ContentKitError (network when it is not one). */\nexport function toContentKitError(e: unknown): ContentKitError {\n if (e instanceof ContentKitError) return e;\n return new ContentKitError(\"network\", e instanceof Error ? e.message : String(e), { cause: e });\n}\n\nexport function aborted(signal?: AbortSignal): ContentKitError {\n return new ContentKitError(\"aborted\", \"request canceled\", { cause: signal?.reason });\n}\n\nexport function throwIfAborted(signal?: AbortSignal): void {\n if (signal?.aborted) throw aborted(signal);\n}\n\nconst byStatus: Record<number, ContentKitErrorCode> = {\n 401: \"unauthorized\",\n 403: \"forbidden\",\n 404: \"not_found\",\n 409: \"conflict\",\n 410: \"gone\",\n 413: \"too_large\",\n 415: \"type_not_allowed\",\n 429: \"rate_limited\",\n 501: \"not_configured\",\n 503: \"unavailable\",\n};\n\nconst known = new Set<string>(ERROR_CODES);\n\n/** Reads a response that is not 2xx. */\nexport async function readContentKitError(res: Response): Promise<ContentKitError> {\n let body: Partial<ErrorReply> = {};\n try {\n body = (await res.json()) as Partial<ErrorReply>;\n } catch {\n // not JSON (a proxy error page)\n }\n const header = Number(res.headers.get(\"Retry-After\"));\n const retryAfter = body.retry_after ?? (Number.isFinite(header) && header > 0 ? header : undefined);\n const code = body.code && known.has(body.code) ? (body.code as ContentKitErrorCode) : (byStatus[res.status] ?? (res.status >= 500 ? \"internal_error\" : \"invalid_request\"));\n return new ContentKitError(code, body.error ?? `HTTP ${res.status}`, {\n status: res.status,\n retryAfter,\n blobs: body.blobs,\n details: body.details,\n ban: body.ban,\n action: body.action,\n });\n}\n\n/** An upload's recorded processing failure: its typed refusal, else a processing fault. */\nexport function failureError(f: Failure): ContentKitError {\n const code = f.code && known.has(f.code) ? (f.code as ContentKitErrorCode) : \"internal_error\";\n return new ContentKitError(code, f.message, { details: f.details });\n}\n"],"mappings":";;AASA,IAAa,IAAqB;CAAC;CAAW;CAAW;CAAW;CAAmB;CAAU;AAAgB,GAKpG,IAA8C,CAAC,GAAI,OAAO,KAAK,CAAsB,GAAmB,GAAG,CAAkB,GAW7H,IAAb,cAAqC,MAAM;CAW9B;CAVX,OAAyB;CAEzB;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,GACA,GACA,IAA4B,CAAC,GAC7B;EAOA,AANA,MAAM,GAAS,EAAK,UAAU,KAAA,IAAY,KAAA,IAAY,EAAE,OAAO,EAAK,MAAM,CAAC,GAJlE,KAAA,OAAA,GAKT,KAAK,SAAS,EAAK,UAAU,GAC7B,KAAK,aAAa,EAAK,YACvB,KAAK,UAAU,EAAK,SACpB,KAAK,QAAQ,EAAK,OAClB,KAAK,MAAM,EAAK,KAChB,KAAK,SAAS,EAAK;CACrB;CAMA,IAAI,UAAmB;EACrB,OAAQ,KAAK,UAAU,OAAO,KAAK,SAAS,OAAO,KAAK,SAAS,aAAc,KAAK,KAAK,WAAW,QAAQ,KAAK,KAAK,SAAS;CACjI;CAGA,IAAI,UAAmB;EACrB,OAAO,KAAK,SAAS,kBAAkB,KAAK,SAAS;CACvD;CAGA,IAAI,YAAqB;EACvB,OAAO,KAAK,SAAS;CACvB;CAGA,IAAI,cAAuB;EACzB,OA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,KAAK,EAAK;EACV,QAAQ,EAAK;CACf,CAAC;AACH;AAGA,SAAgB,EAAa,GAA6B;CAExD,OAAO,IAAI,EADE,EAAE,QAAQ,EAAM,IAAI,EAAE,IAAI,IAAK,EAAE,OAA+B,kBAC5C,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;AACpE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FileInfo, ReadResult } from './generated/wire.js';
|
|
2
|
+
export type GalleryView = "carousel" | "grid";
|
|
3
|
+
export interface GalleryMediaItem {
|
|
4
|
+
kind: "image" | "video" | "audio";
|
|
5
|
+
key: string;
|
|
6
|
+
/** An image; a ladder's widest video track (its size and duration) or its audio file. */
|
|
7
|
+
file: FileInfo;
|
|
8
|
+
/** A video or audio ladder's HLS folder from the read's `hls`, e.g. "hls/". */
|
|
9
|
+
dir?: string;
|
|
10
|
+
/** Width / height from the read API; a default when unknown. */
|
|
11
|
+
aspect: number;
|
|
12
|
+
}
|
|
13
|
+
/** What a viewer without access is missing; `backdrop` is the public preview drawn behind it. */
|
|
14
|
+
export interface GalleryLockedItem {
|
|
15
|
+
kind: "locked";
|
|
16
|
+
key: string;
|
|
17
|
+
count: number;
|
|
18
|
+
videos: number;
|
|
19
|
+
backdrop?: string;
|
|
20
|
+
aspect: number;
|
|
21
|
+
}
|
|
22
|
+
export type GalleryItem = GalleryMediaItem | GalleryLockedItem;
|
|
23
|
+
export declare const isVideoType: (type?: string) => boolean;
|
|
24
|
+
export declare const isAudioType: (type?: string) => boolean;
|
|
25
|
+
export declare const isImageType: (type?: string) => boolean;
|
|
26
|
+
/** The stage aspect of an audio slide. */
|
|
27
|
+
export declare const AUDIO_ASPECT = 3;
|
|
28
|
+
/** Subtitle files are a video's text tracks, not gallery items. */
|
|
29
|
+
export declare const isSubtitleType: (type?: string) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The read result as gallery items in manifest order. With access: each
|
|
32
|
+
* image, each playable HLS ladder (a folder in `hls`: a video, or an
|
|
33
|
+
* audio-only one) and each other audio file. Without: the item's public
|
|
34
|
+
* previews (the read's `previews`), then one locked item for the rest; an
|
|
35
|
+
* item's private files are all or nothing, so locked files never carry URLs.
|
|
36
|
+
* Other files (plain videos, subtitles, zips) are not items; scope the read
|
|
37
|
+
* with a prefix to choose.
|
|
38
|
+
*/
|
|
39
|
+
export declare function galleryItems(read: ReadResult | null | undefined): GalleryItem[];
|
|
40
|
+
/** The carousel stage's width / height: the current item's native aspect. */
|
|
41
|
+
export declare function stageAspect(items: readonly GalleryItem[], index?: number): number;
|
|
42
|
+
/** "0:42", "12:05", "1:02:09". */
|
|
43
|
+
export declare function formatDuration(seconds: number): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region src/client/gallery.ts
|
|
2
|
+
var e = (e) => !!e?.startsWith("video/"), t = (e) => !!e?.startsWith("audio/"), n = (e) => !!e?.startsWith("image/"), r = (e) => [
|
|
3
|
+
"text/vtt",
|
|
4
|
+
"application/x-subrip",
|
|
5
|
+
"text/x-ssa",
|
|
6
|
+
"text/x-ass"
|
|
7
|
+
].includes(e ?? "");
|
|
8
|
+
function i(e, t) {
|
|
9
|
+
return e?.w && e.h ? e.w / e.h : t;
|
|
10
|
+
}
|
|
11
|
+
var a = (e) => e.slice(0, e.lastIndexOf("/") + 1);
|
|
12
|
+
function o(r) {
|
|
13
|
+
if (!r) return [];
|
|
14
|
+
let o = r.access === "full", s = r.hls ?? [], c = (e) => s.find((t) => e.path.startsWith(t)), l = (e) => a(e.path) || e.path, u = r.files.filter((n) => n.locked && (e(n.type) || t(n.type))), d = new Set(u.map(l)), f = r.files.filter((e) => e.locked && n(e.type) && !d.has(a(e.path))), p = new Set(u.filter((t) => e(t.type)).map(l)).size, m = o ? [] : r.previews ?? [], h = Math.max(f.length - m.length, 0) + d.size, g = m.map((e, t) => ({
|
|
15
|
+
kind: "image",
|
|
16
|
+
key: `preview/${t + 1}`,
|
|
17
|
+
file: {
|
|
18
|
+
path: `preview/${t + 1}`,
|
|
19
|
+
type: "image/webp",
|
|
20
|
+
url: e
|
|
21
|
+
},
|
|
22
|
+
aspect: 1
|
|
23
|
+
})), _ = /* @__PURE__ */ new Set();
|
|
24
|
+
for (let a of r.files) {
|
|
25
|
+
if (a.locked) continue;
|
|
26
|
+
let o = c(a);
|
|
27
|
+
if (o) {
|
|
28
|
+
if (_.has(o)) continue;
|
|
29
|
+
_.add(o);
|
|
30
|
+
let n = r.files.filter((e) => e.path.startsWith(o)), a = n.filter((t) => e(t.type)).reduce((e, t) => (t.w ?? 0) > (e?.w ?? -1) ? t : e, void 0);
|
|
31
|
+
if (a) {
|
|
32
|
+
let e = a.dur ?? n.find((e) => e.dur)?.dur;
|
|
33
|
+
g.push({
|
|
34
|
+
kind: "video",
|
|
35
|
+
key: o,
|
|
36
|
+
dir: o,
|
|
37
|
+
file: {
|
|
38
|
+
...a,
|
|
39
|
+
dur: e
|
|
40
|
+
},
|
|
41
|
+
aspect: i(a, 16 / 9)
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
let e = n.find((e) => e.path.endsWith(".m4a")) ?? n.find((e) => t(e.type));
|
|
45
|
+
e && g.push({
|
|
46
|
+
kind: "audio",
|
|
47
|
+
key: o,
|
|
48
|
+
dir: o,
|
|
49
|
+
file: e,
|
|
50
|
+
aspect: 3
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
n(a.type) ? g.push({
|
|
56
|
+
kind: "image",
|
|
57
|
+
key: a.path,
|
|
58
|
+
file: a,
|
|
59
|
+
aspect: i(a, 1)
|
|
60
|
+
}) : t(a.type) && g.push({
|
|
61
|
+
kind: "audio",
|
|
62
|
+
key: a.path,
|
|
63
|
+
file: a,
|
|
64
|
+
aspect: 3
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return h > 0 && g.push({
|
|
68
|
+
kind: "locked",
|
|
69
|
+
key: "locked",
|
|
70
|
+
count: h,
|
|
71
|
+
videos: p,
|
|
72
|
+
backdrop: m.at(-1),
|
|
73
|
+
aspect: 1
|
|
74
|
+
}), g;
|
|
75
|
+
}
|
|
76
|
+
function s(e, t = 0) {
|
|
77
|
+
return e[t]?.aspect ?? 1;
|
|
78
|
+
}
|
|
79
|
+
function c(e) {
|
|
80
|
+
let t = Math.max(0, Math.round(e)), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = String(t % 60).padStart(2, "0");
|
|
81
|
+
return n ? `${n}:${String(r).padStart(2, "0")}:${i}` : `${r}:${i}`;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { c as formatDuration, o as galleryItems, t as isAudioType, n as isImageType, r as isSubtitleType, e as isVideoType, s as stageAspect };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=gallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gallery.js","names":[],"sources":["../../src/client/gallery.ts"],"sourcesContent":["import type { FileInfo, ReadResult } from \"./generated/wire.js\";\n\nexport type GalleryView = \"carousel\" | \"grid\";\n\nexport interface GalleryMediaItem {\n kind: \"image\" | \"video\" | \"audio\";\n key: string;\n /** An image; a ladder's widest video track (its size and duration) or its audio file. */\n file: FileInfo;\n /** A video or audio ladder's HLS folder from the read's `hls`, e.g. \"hls/\". */\n dir?: string;\n /** Width / height from the read API; a default when unknown. */\n aspect: number;\n}\n\n/** What a viewer without access is missing; `backdrop` is the public preview drawn behind it. */\nexport interface GalleryLockedItem {\n kind: \"locked\";\n key: string;\n count: number;\n videos: number;\n backdrop?: string;\n aspect: number;\n}\n\nexport type GalleryItem = GalleryMediaItem | GalleryLockedItem;\n\nexport const isVideoType = (type?: string) => !!type?.startsWith(\"video/\");\nexport const isAudioType = (type?: string) => !!type?.startsWith(\"audio/\");\nexport const isImageType = (type?: string) => !!type?.startsWith(\"image/\");\n\n/** The stage aspect of an audio slide. */\nexport const AUDIO_ASPECT = 3;\n\n/** Subtitle files are a video's text tracks, not gallery items. */\nexport const isSubtitleType = (type?: string) =>\n [\"text/vtt\", \"application/x-subrip\", \"text/x-ssa\", \"text/x-ass\"].includes(type ?? \"\");\n\nfunction aspectOf(f: FileInfo | undefined, fallback: number) {\n return f?.w && f.h ? f.w / f.h : fallback;\n}\n\nconst parent = (path: string) => path.slice(0, path.lastIndexOf(\"/\") + 1);\n\n/**\n * The read result as gallery items in manifest order. With access: each\n * image, each playable HLS ladder (a folder in `hls`: a video, or an\n * audio-only one) and each other audio file. Without: the item's public\n * previews (the read's `previews`), then one locked item for the rest; an\n * item's private files are all or nothing, so locked files never carry URLs.\n * Other files (plain videos, subtitles, zips) are not items; scope the read\n * with a prefix to choose.\n */\nexport function galleryItems(read: ReadResult | null | undefined): GalleryItem[] {\n if (!read) return [];\n const full = read.access === \"full\";\n const dirs = read.hls ?? [];\n const dirOf = (f: FileInfo) => dirs.find((d) => f.path.startsWith(d));\n // A locked ladder lists its tracks (and sprite): count each folder once.\n const unit = (f: FileInfo) => parent(f.path) || f.path;\n const lockedMedia = read.files.filter((f) => f.locked && (isVideoType(f.type) || isAudioType(f.type)));\n const units = new Set(lockedMedia.map(unit));\n const lockedImages = read.files.filter((f) => f.locked && isImageType(f.type) && !units.has(parent(f.path)));\n const lockedVideos = new Set(lockedMedia.filter((f) => isVideoType(f.type)).map(unit)).size;\n const previews = full ? [] : (read.previews ?? []);\n // Each preview shows one of the locked images.\n const lockedCount = Math.max(lockedImages.length - previews.length, 0) + units.size;\n const items: GalleryItem[] = previews.map((url, i) => ({ kind: \"image\", key: `preview/${i + 1}`, file: { path: `preview/${i + 1}`, type: \"image/webp\", url }, aspect: 1 }));\n const seen = new Set<string>();\n for (const f of read.files) {\n if (f.locked) continue;\n const dir = dirOf(f);\n if (dir) {\n if (seen.has(dir)) continue;\n seen.add(dir);\n const files = read.files.filter((x) => x.path.startsWith(dir));\n const video = files.filter((x) => isVideoType(x.type)).reduce<FileInfo | undefined>((a, x) => ((x.w ?? 0) > (a?.w ?? -1) ? x : a), undefined);\n if (video) {\n const dur = video.dur ?? files.find((x) => x.dur)?.dur;\n items.push({ kind: \"video\", key: dir, dir, file: { ...video, dur }, aspect: aspectOf(video, 16 / 9) });\n } else {\n const audio = files.find((x) => x.path.endsWith(\".m4a\")) ?? files.find((x) => isAudioType(x.type));\n if (audio) items.push({ kind: \"audio\", key: dir, dir, file: audio, aspect: AUDIO_ASPECT });\n }\n continue;\n }\n if (isImageType(f.type)) items.push({ kind: \"image\", key: f.path, file: f, aspect: aspectOf(f, 1) });\n else if (isAudioType(f.type)) items.push({ kind: \"audio\", key: f.path, file: f, aspect: AUDIO_ASPECT });\n }\n if (lockedCount > 0)\n items.push({ kind: \"locked\", key: \"locked\", count: lockedCount, videos: lockedVideos, backdrop: previews.at(-1), aspect: 1 });\n return items;\n}\n\n/** The carousel stage's width / height: the current item's native aspect. */\nexport function stageAspect(items: readonly GalleryItem[], index = 0): number {\n return items[index]?.aspect ?? 1;\n}\n\n/** \"0:42\", \"12:05\", \"1:02:09\". */\nexport function formatDuration(seconds: number): string {\n const s = Math.max(0, Math.round(seconds));\n const h = Math.floor(s / 3600);\n const m = Math.floor((s % 3600) / 60);\n const ss = String(s % 60).padStart(2, \"0\");\n return h ? `${h}:${String(m).padStart(2, \"0\")}:${ss}` : `${m}:${ss}`;\n}\n"],"mappings":";AA2BA,IAAa,KAAe,MAAkB,CAAC,CAAC,GAAM,WAAW,QAAQ,GAC5D,KAAe,MAAkB,CAAC,CAAC,GAAM,WAAW,QAAQ,GAC5D,KAAe,MAAkB,CAAC,CAAC,GAAM,WAAW,QAAQ,GAM5D,KAAkB,MAC7B;CAAC;CAAY;CAAwB;CAAc;AAAY,CAAC,CAAC,SAAS,KAAQ,EAAE;AAEtF,SAAS,EAAS,GAAyB,GAAkB;CAC3D,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;AACnC;AAEA,IAAM,KAAU,MAAiB,EAAK,MAAM,GAAG,EAAK,YAAY,GAAG,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IAAI,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;CACzC,OAAO,IAAI,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,MAAO,GAAG,EAAE,GAAG;AAClE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type ErrorCode = "animation_not_allowed" | "animation_too_long" | "animation_unsupported" | "checksum_mismatch" | "comment_banned" | "comment_too_long" | "conflict" | "forbidden" | "gone" | "image_too_large" | "image_too_small" | "image_unreadable" | "incomplete" | "internal_error" | "invalid_request" | "moderation_rejected" | "not_configured" | "not_found" | "not_uploaded" | "quota_exceeded" | "rate_limited" | "tenant_mismatch" | "too_large" | "too_many_files" | "type_not_allowed" | "unauthorized" | "unavailable" | "video_aspect_unsupported" | "video_over_budget" | "video_too_large" | "video_too_long";
|
|
2
|
+
export declare const CONTENTKIT_ERROR_CODES: Readonly<Record<ErrorCode, {
|
|
3
|
+
status: number;
|
|
4
|
+
meaning: string;
|
|
5
|
+
}>>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//#region src/client/generated/error-codes.ts
|
|
2
|
+
var e = {
|
|
3
|
+
animation_not_allowed: {
|
|
4
|
+
status: 422,
|
|
5
|
+
meaning: "An animated image where the upload path refuses animation."
|
|
6
|
+
},
|
|
7
|
+
animation_too_long: {
|
|
8
|
+
status: 422,
|
|
9
|
+
meaning: "The animation has more frames or seconds than the processor allows."
|
|
10
|
+
},
|
|
11
|
+
animation_unsupported: {
|
|
12
|
+
status: 415,
|
|
13
|
+
meaning: "An AVIF or HEIF image sequence, which is decoded as one frame."
|
|
14
|
+
},
|
|
15
|
+
checksum_mismatch: {
|
|
16
|
+
status: 422,
|
|
17
|
+
meaning: "The stored bytes differ from the declared SHA-256."
|
|
18
|
+
},
|
|
19
|
+
comment_banned: {
|
|
20
|
+
status: 403,
|
|
21
|
+
meaning: "The actor is banned from commenting on this target; `ban` says the scope, the reason and when it ends."
|
|
22
|
+
},
|
|
23
|
+
comment_too_long: {
|
|
24
|
+
status: 422,
|
|
25
|
+
meaning: "The comment is longer than the site allows; `details.max` is the limit in characters."
|
|
26
|
+
},
|
|
27
|
+
conflict: {
|
|
28
|
+
status: 409,
|
|
29
|
+
meaning: "A concurrent change, a path or slug already taken, or an operation id already used for another commit."
|
|
30
|
+
},
|
|
31
|
+
forbidden: {
|
|
32
|
+
status: 403,
|
|
33
|
+
meaning: "The actor may not do this."
|
|
34
|
+
},
|
|
35
|
+
gone: {
|
|
36
|
+
status: 410,
|
|
37
|
+
meaning: "The content was removed."
|
|
38
|
+
},
|
|
39
|
+
image_too_large: {
|
|
40
|
+
status: 413,
|
|
41
|
+
meaning: "The image has more pixels or frames than the processor decodes."
|
|
42
|
+
},
|
|
43
|
+
image_too_small: {
|
|
44
|
+
status: 422,
|
|
45
|
+
meaning: "The edited image is narrower than its public preset's minimum width."
|
|
46
|
+
},
|
|
47
|
+
image_unreadable: {
|
|
48
|
+
status: 422,
|
|
49
|
+
meaning: "The file is not a decodable image of its declared type."
|
|
50
|
+
},
|
|
51
|
+
incomplete: {
|
|
52
|
+
status: 409,
|
|
53
|
+
meaning: "A multipart upload is missing parts."
|
|
54
|
+
},
|
|
55
|
+
internal_error: {
|
|
56
|
+
status: 500,
|
|
57
|
+
meaning: "A server fault; the cause is in the server log."
|
|
58
|
+
},
|
|
59
|
+
invalid_request: {
|
|
60
|
+
status: 400,
|
|
61
|
+
meaning: "The request is malformed: its body, a query parameter or a path value."
|
|
62
|
+
},
|
|
63
|
+
moderation_rejected: {
|
|
64
|
+
status: 422,
|
|
65
|
+
meaning: "The moderator refused the text; `error` says why."
|
|
66
|
+
},
|
|
67
|
+
not_configured: {
|
|
68
|
+
status: 501,
|
|
69
|
+
meaning: "The capability needs a port the host did not configure; retrying does not help."
|
|
70
|
+
},
|
|
71
|
+
not_found: {
|
|
72
|
+
status: 404,
|
|
73
|
+
meaning: "Nothing by that name, or nothing the actor may see."
|
|
74
|
+
},
|
|
75
|
+
not_uploaded: {
|
|
76
|
+
status: 409,
|
|
77
|
+
meaning: "A commit names an upload that has not landed; `blobs` lists the ones to upload again."
|
|
78
|
+
},
|
|
79
|
+
quota_exceeded: {
|
|
80
|
+
status: 413,
|
|
81
|
+
meaning: "The uploader's storage quota is used up."
|
|
82
|
+
},
|
|
83
|
+
rate_limited: {
|
|
84
|
+
status: 429,
|
|
85
|
+
meaning: "Too many requests; retry after `retry_after` seconds (also the Retry-After header)."
|
|
86
|
+
},
|
|
87
|
+
tenant_mismatch: {
|
|
88
|
+
status: 500,
|
|
89
|
+
meaning: "A host port answered with another tenant's data: a configuration fault."
|
|
90
|
+
},
|
|
91
|
+
too_large: {
|
|
92
|
+
status: 413,
|
|
93
|
+
meaning: "The file is larger than its upload path allows; `details` has `size` and `max_bytes`."
|
|
94
|
+
},
|
|
95
|
+
too_many_files: {
|
|
96
|
+
status: 409,
|
|
97
|
+
meaning: "The commit would put more files in an upload path, or the item, than allowed; `details.max` is the limit."
|
|
98
|
+
},
|
|
99
|
+
type_not_allowed: {
|
|
100
|
+
status: 415,
|
|
101
|
+
meaning: "The file type is not allowed in the upload path; `details.allowed` lists the types."
|
|
102
|
+
},
|
|
103
|
+
unauthorized: {
|
|
104
|
+
status: 401,
|
|
105
|
+
meaning: "The route needs a signed-in actor."
|
|
106
|
+
},
|
|
107
|
+
unavailable: {
|
|
108
|
+
status: 503,
|
|
109
|
+
meaning: "Media storage cannot be reached, or a commit's recovery is pending; retry."
|
|
110
|
+
},
|
|
111
|
+
video_aspect_unsupported: {
|
|
112
|
+
status: 422,
|
|
113
|
+
meaning: "The video's display aspect is outside what its upload path accepts; `details` has `min_aspect` and `max_aspect` (width/height)."
|
|
114
|
+
},
|
|
115
|
+
video_over_budget: {
|
|
116
|
+
status: 422,
|
|
117
|
+
meaning: "The planned encode costs more than its upload path allows, or the source averages under a frame a second."
|
|
118
|
+
},
|
|
119
|
+
video_too_large: {
|
|
120
|
+
status: 422,
|
|
121
|
+
meaning: "The video's frames are larger than its upload path allows."
|
|
122
|
+
},
|
|
123
|
+
video_too_long: {
|
|
124
|
+
status: 422,
|
|
125
|
+
meaning: "The video or audio runs longer than its upload path allows."
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
export { e as CONTENTKIT_ERROR_CODES };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.js","names":[],"sources":["../../../src/client/generated/error-codes.ts"],"sourcesContent":["// Generated by `go generate ./internal/contract` from ContentKit's error-code registry. Do not edit.\n\nexport type ErrorCode =\n | \"animation_not_allowed\"\n | \"animation_too_long\"\n | \"animation_unsupported\"\n | \"checksum_mismatch\"\n | \"comment_banned\"\n | \"comment_too_long\"\n | \"conflict\"\n | \"forbidden\"\n | \"gone\"\n | \"image_too_large\"\n | \"image_too_small\"\n | \"image_unreadable\"\n | \"incomplete\"\n | \"internal_error\"\n | \"invalid_request\"\n | \"moderation_rejected\"\n | \"not_configured\"\n | \"not_found\"\n | \"not_uploaded\"\n | \"quota_exceeded\"\n | \"rate_limited\"\n | \"tenant_mismatch\"\n | \"too_large\"\n | \"too_many_files\"\n | \"type_not_allowed\"\n | \"unauthorized\"\n | \"unavailable\"\n | \"video_aspect_unsupported\"\n | \"video_over_budget\"\n | \"video_too_large\"\n | \"video_too_long\"\n;\n\n// Each code's HTTP status and meaning. A message on the wire is for people;\n// classify by code.\nexport const CONTENTKIT_ERROR_CODES: Readonly<Record<ErrorCode, { status: number; meaning: string }>> = {\n animation_not_allowed: { status: 422, meaning: \"An animated image where the upload path refuses animation.\" },\n animation_too_long: { status: 422, meaning: \"The animation has more frames or seconds than the processor allows.\" },\n animation_unsupported: { status: 415, meaning: \"An AVIF or HEIF image sequence, which is decoded as one frame.\" },\n checksum_mismatch: { status: 422, meaning: \"The stored bytes differ from the declared SHA-256.\" },\n comment_banned: { status: 403, meaning: \"The actor is banned from commenting on this target; `ban` says the scope, the reason and when it ends.\" },\n comment_too_long: { status: 422, meaning: \"The comment is longer than the site allows; `details.max` is the limit in characters.\" },\n conflict: { status: 409, meaning: \"A concurrent change, a path or slug already taken, or an operation id already used for another commit.\" },\n forbidden: { status: 403, meaning: \"The actor may not do this.\" },\n gone: { status: 410, meaning: \"The content was removed.\" },\n image_too_large: { status: 413, meaning: \"The image has more pixels or frames than the processor decodes.\" },\n image_too_small: { status: 422, meaning: \"The edited image is narrower than its public preset's minimum width.\" },\n image_unreadable: { status: 422, meaning: \"The file is not a decodable image of its declared type.\" },\n incomplete: { status: 409, meaning: \"A multipart upload is missing parts.\" },\n internal_error: { status: 500, meaning: \"A server fault; the cause is in the server log.\" },\n invalid_request: { status: 400, meaning: \"The request is malformed: its body, a query parameter or a path value.\" },\n moderation_rejected: { status: 422, meaning: \"The moderator refused the text; `error` says why.\" },\n not_configured: { status: 501, meaning: \"The capability needs a port the host did not configure; retrying does not help.\" },\n not_found: { status: 404, meaning: \"Nothing by that name, or nothing the actor may see.\" },\n not_uploaded: { status: 409, meaning: \"A commit names an upload that has not landed; `blobs` lists the ones to upload again.\" },\n quota_exceeded: { status: 413, meaning: \"The uploader's storage quota is used up.\" },\n rate_limited: { status: 429, meaning: \"Too many requests; retry after `retry_after` seconds (also the Retry-After header).\" },\n tenant_mismatch: { status: 500, meaning: \"A host port answered with another tenant's data: a configuration fault.\" },\n too_large: { status: 413, meaning: \"The file is larger than its upload path allows; `details` has `size` and `max_bytes`.\" },\n too_many_files: { status: 409, meaning: \"The commit would put more files in an upload path, or the item, than allowed; `details.max` is the limit.\" },\n type_not_allowed: { status: 415, meaning: \"The file type is not allowed in the upload path; `details.allowed` lists the types.\" },\n unauthorized: { status: 401, meaning: \"The route needs a signed-in actor.\" },\n unavailable: { status: 503, meaning: \"Media storage cannot be reached, or a commit's recovery is pending; retry.\" },\n video_aspect_unsupported: { status: 422, meaning: \"The video's display aspect is outside what its upload path accepts; `details` has `min_aspect` and `max_aspect` (width/height).\" },\n video_over_budget: { status: 422, meaning: \"The planned encode costs more than its upload path allows, or the source averages under a frame a second.\" },\n video_too_large: { status: 422, meaning: \"The video's frames are larger than its upload path allows.\" },\n video_too_long: { status: 422, meaning: \"The video or audio runs longer than its upload path allows.\" },\n};\n"],"mappings":";AAsCA,IAAa,IAA2F;CACtG,uBAAuB;EAAE,QAAQ;EAAK,SAAS;CAA6D;CAC5G,oBAAoB;EAAE,QAAQ;EAAK,SAAS;CAAsE;CAClH,uBAAuB;EAAE,QAAQ;EAAK,SAAS;CAAiE;CAChH,mBAAmB;EAAE,QAAQ;EAAK,SAAS;CAAqD;CAChG,gBAAgB;EAAE,QAAQ;EAAK,SAAS;CAAyG;CACjJ,kBAAkB;EAAE,QAAQ;EAAK,SAAS;CAAwF;CAClI,UAAU;EAAE,QAAQ;EAAK,SAAS;CAAyG;CAC3I,WAAW;EAAE,QAAQ;EAAK,SAAS;CAA6B;CAChE,MAAM;EAAE,QAAQ;EAAK,SAAS;CAA2B;CACzD,iBAAiB;EAAE,QAAQ;EAAK,SAAS;CAAkE;CAC3G,iBAAiB;EAAE,QAAQ;EAAK,SAAS;CAAuE;CAChH,kBAAkB;EAAE,QAAQ;EAAK,SAAS;CAA0D;CACpG,YAAY;EAAE,QAAQ;EAAK,SAAS;CAAuC;CAC3E,gBAAgB;EAAE,QAAQ;EAAK,SAAS;CAAkD;CAC1F,iBAAiB;EAAE,QAAQ;EAAK,SAAS;CAAyE;CAClH,qBAAqB;EAAE,QAAQ;EAAK,SAAS;CAAoD;CACjG,gBAAgB;EAAE,QAAQ;EAAK,SAAS;CAAkF;CAC1H,WAAW;EAAE,QAAQ;EAAK,SAAS;CAAsD;CACzF,cAAc;EAAE,QAAQ;EAAK,SAAS;CAAwF;CAC9H,gBAAgB;EAAE,QAAQ;EAAK,SAAS;CAA2C;CACnF,cAAc;EAAE,QAAQ;EAAK,SAAS;CAAsF;CAC5H,iBAAiB;EAAE,QAAQ;EAAK,SAAS;C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