calmlens 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/bin/calmlens.js +1646 -706
- package/cjs/{BrowserUpload-CJ4Xc9bR.js → BrowserUpload-CeSwiMo5.js} +1 -1
- package/{esm/BrowserUpload-RkxV_Vv7.d.ts → cjs/BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-LHMEQ-UZ.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
- package/cjs/{CalmLensAppClient-B5gfOB6J.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/cjs/{CalmLensOptionKeys-BUj7v5AG.js → CalmLensOptionKeys-CYY6elxg.js} +242 -345
- package/cjs/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +107 -49
- package/cjs/{CalmLensServerClient-BVOEUT_v.js → CalmLensServerClient-nfu6_YEW.js} +297 -92
- package/cjs/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/cjs/Core-C82YmjjX.d.ts +823 -0
- package/cjs/Core-Dc3cteU7.js +998 -0
- package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
- package/cjs/{ModerationContextLimits-FDpQmw_T.js → ModerationContextLimits-BxOmeSqq.js} +970 -278
- package/cjs/{ReactUpload-BvpW4hJi.js → ReactUpload-BK2O3dnK.js} +1 -1
- package/cjs/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/cjs/{TestTriggers-CMwMrbjy-K0YBzu2a.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +343 -35
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{UploadController-D4qOZZc3.js → UploadController-DLyiLDTB.js} +34 -14
- package/cjs/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/cjs/app.d.ts +6 -7
- package/cjs/app.js +4 -3
- package/cjs/elements.d.ts +123 -22
- package/cjs/elements.js +553 -156
- package/cjs/file-icons.d.ts +2 -67
- package/cjs/index-CKRgjV16.d.ts +16 -0
- package/cjs/index.d.ts +5 -6
- package/cjs/index.js +3 -2
- package/cjs/react-native.d.ts +52 -11
- package/cjs/react-native.js +231 -99
- package/cjs/react.d.ts +42 -9
- package/cjs/react.js +381 -118
- package/cjs/server.d.ts +48 -7
- package/cjs/server.js +7 -3
- package/cjs/test-inputs.d.ts +2 -2
- package/cjs/test-inputs.js +13 -9
- package/cjs/testing.d.ts +29 -16
- package/cjs/testing.js +1511 -397
- package/cjs/ui-CTBUxnVp.d.ts +139 -0
- package/cjs/ui-CZ8exACq.js +1359 -0
- package/cjs/ui.d.ts +3 -2
- package/cjs/ui.js +45 -22
- package/cjs/vue.d.ts +802 -199
- package/cjs/vue.js +359 -127
- package/{cjs/BrowserUpload-RkxV_Vv7.d.ts → esm/BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/esm/{BrowserUpload-DpzS2bbj.js → BrowserUpload-i9OhCzMJ.js} +1 -1
- package/esm/{CalmLensAppClient-BjlvBweS.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
- package/esm/{CalmLensAppClient-B5gfOB6J.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-BKez0Wiw.js → CalmLensOptionKeys-BGZlIsT2.js} +235 -338
- package/esm/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +107 -49
- package/esm/{CalmLensServerClient-DemxbNMn.js → CalmLensServerClient-dAQUcDWb.js} +274 -93
- package/esm/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/esm/Core-BxeIud_S.js +843 -0
- package/esm/Core-C82YmjjX.d.ts +823 -0
- package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
- package/esm/{ModerationContextLimits-lLfmyLni.js → ModerationContextLimits-B6_RalCQ.js} +911 -261
- package/esm/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/esm/{ReactUpload-6klucehl.js → ReactUpload-DxwVqfX1.js} +1 -1
- package/esm/{TestTriggers-CMwMrbjy-bdowBBKw.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +320 -36
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{UploadController-UxP6gj7A.js → UploadController-D9Z-h00Q.js} +34 -14
- package/esm/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/esm/app.d.ts +6 -7
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +123 -22
- package/esm/elements.js +497 -128
- package/esm/file-icons.d.ts +2 -67
- package/esm/index-CKRgjV16.d.ts +16 -0
- package/esm/index.d.ts +5 -6
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +52 -11
- package/esm/react-native.js +205 -75
- package/esm/react.d.ts +42 -9
- package/esm/react.js +327 -91
- package/esm/server.d.ts +48 -7
- package/esm/server.js +3 -3
- package/esm/styles.css +142 -22
- package/esm/svelte/AssetViewer.svelte +25 -0
- package/esm/svelte/CalmLensAsset.svelte +318 -0
- package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
- package/esm/svelte/CalmLensImageViewer.svelte +7 -0
- package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
- package/esm/svelte/CalmLensTextViewer.svelte +7 -0
- package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
- package/esm/svelte/index.d.ts +29 -6
- package/esm/svelte/index.js +7 -2
- package/esm/test-inputs.d.ts +2 -2
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +29 -16
- package/esm/testing.js +1507 -393
- package/esm/ui-CTBUxnVp.d.ts +139 -0
- package/esm/ui-Cr7s6JHm.js +1258 -0
- package/esm/ui.d.ts +3 -2
- package/esm/ui.js +4 -3
- package/esm/vue.d.ts +802 -199
- package/esm/vue.js +308 -103
- package/package.json +3 -1
- package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/cjs/index-BcDDQJF2.d.ts +0 -253
- package/cjs/ui-B23r8BvW.d.ts +0 -539
- package/cjs/ui-Dq-cm6Rx.js +0 -586
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/esm/index-BcDDQJF2.d.ts +0 -253
- package/esm/svelte/CalmLensMedia.svelte +0 -134
- package/esm/ui-B23r8BvW.d.ts +0 -539
- package/esm/ui-Bn29rfAi.js +0 -461
package/cjs/ui-Dq-cm6Rx.js
DELETED
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
const require_ModerationContextLimits = require("./ModerationContextLimits-FDpQmw_T.js");
|
|
2
|
-
const require_UploadController = require("./UploadController-D4qOZZc3.js");
|
|
3
|
-
const require_FileIcons = require("./FileIcons-Ob003MdS.js");
|
|
4
|
-
// src/ui/Icons.ts
|
|
5
|
-
/** Path data for the components' 24×24 stroke icons, so every framework draws the same ones. */
|
|
6
|
-
const ICONS = {
|
|
7
|
-
upload: "M12 16V4m0 0L7 9m5-5 5 5M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",
|
|
8
|
-
remove: "M18 6 6 18M6 6l12 12",
|
|
9
|
-
retry: "M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7",
|
|
10
|
-
unavailable: "M3 3l18 18M10.6 10.6a2 2 0 0 0 2.8 2.8M9.9 5.1A9.8 9.8 0 0 1 12 5c5 0 9 5 10 7a17 17 0 0 1-3.3 4.2M6.6 6.6C4.4 8 2.8 10.4 2 12c1 2 5 7 10 7a9.6 9.6 0 0 0 5.4-1.6"
|
|
11
|
-
};
|
|
12
|
-
/** Attributes shared by every icon's `<svg>`. */
|
|
13
|
-
const ICON_ATTRIBUTES = {
|
|
14
|
-
width: "18",
|
|
15
|
-
height: "18",
|
|
16
|
-
viewBox: "0 0 24 24",
|
|
17
|
-
fill: "none",
|
|
18
|
-
stroke: "currentColor",
|
|
19
|
-
"stroke-width": "2",
|
|
20
|
-
"stroke-linecap": "round",
|
|
21
|
-
"stroke-linejoin": "round",
|
|
22
|
-
"aria-hidden": "true"
|
|
23
|
-
};
|
|
24
|
-
// src/ui/Media.ts
|
|
25
|
-
/**
|
|
26
|
-
* The image URL to load for a box `displayWidth` pixels wide: the smallest width that covers it,
|
|
27
|
-
* or the largest when none does. Without `widths`, or before the box is measured, the image's own
|
|
28
|
-
* `src`. React Native, which has no `srcset`, calls this with its measured size.
|
|
29
|
-
*/
|
|
30
|
-
const pickMediaSource = (state, displayWidth) => {
|
|
31
|
-
const { sources } = state;
|
|
32
|
-
if (!sources?.length || !displayWidth) return state.src;
|
|
33
|
-
return (sources.find((source) => source.width >= displayWidth) ?? sources.at(-1))?.src ?? state.src;
|
|
34
|
-
};
|
|
35
|
-
const decodedPlaceholders = /* @__PURE__ */ new Map();
|
|
36
|
-
/** Renders a ThumbHash as a PNG data URL, once per hash; `undefined` for an invalid hash. */
|
|
37
|
-
const decodePlaceholderHash = (hash) => {
|
|
38
|
-
if (!hash) return void 0;
|
|
39
|
-
if (!decodedPlaceholders.has(hash)) {
|
|
40
|
-
let decoded;
|
|
41
|
-
try {
|
|
42
|
-
decoded = require_UploadController.placeholderHashToDataURL(hash);
|
|
43
|
-
} catch {}
|
|
44
|
-
if (decodedPlaceholders.size > 500) decodedPlaceholders.clear();
|
|
45
|
-
decodedPlaceholders.set(hash, decoded);
|
|
46
|
-
}
|
|
47
|
-
return decodedPlaceholders.get(hash);
|
|
48
|
-
};
|
|
49
|
-
const withWidth = (base, width) => {
|
|
50
|
-
if (width === void 0) return base;
|
|
51
|
-
if (base === void 0 || typeof base !== "string") return {
|
|
52
|
-
...base,
|
|
53
|
-
width
|
|
54
|
-
};
|
|
55
|
-
return [require_ModerationContextLimits.transformSelector(base), require_ModerationContextLimits.serializeTransform({ width })].filter(Boolean).join(",");
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Fills the props left unset from `asset`, if there is one: the project and ID, its moderation
|
|
59
|
-
* status, `video` or `audio` for those asset types, and its stored preview's ThumbHash, average
|
|
60
|
-
* colour and size. Every framework's media component calls this before rendering.
|
|
61
|
-
*/
|
|
62
|
-
const resolveMediaProps = (props) => {
|
|
63
|
-
const { asset } = props;
|
|
64
|
-
if (!asset) return props;
|
|
65
|
-
const preview = asset.content?.image;
|
|
66
|
-
const regionEntries = asset.classification?.moderation?.regions ?? [];
|
|
67
|
-
const ranks = {
|
|
68
|
-
pending: 0,
|
|
69
|
-
allowed: 0,
|
|
70
|
-
limited: 1,
|
|
71
|
-
"age-restricted": 2,
|
|
72
|
-
blocked: 3,
|
|
73
|
-
purged: 4
|
|
74
|
-
};
|
|
75
|
-
const statuses = {
|
|
76
|
-
limit: "limited",
|
|
77
|
-
"age-restrict": "age-restricted",
|
|
78
|
-
block: "blocked",
|
|
79
|
-
purge: "purged"
|
|
80
|
-
};
|
|
81
|
-
let status = props.status ?? asset.classification?.moderation?.status ?? "allowed";
|
|
82
|
-
for (const entry of regionEntries) {
|
|
83
|
-
const region = props.viewerClaims?.region;
|
|
84
|
-
if (region && (entry.region === region || entry.region === "EU" && require_ModerationContextLimits.EU_COUNTRIES.has(region))) {
|
|
85
|
-
const regionalStatus = statuses[entry.action];
|
|
86
|
-
if (regionalStatus && ranks[regionalStatus] > ranks[status]) status = regionalStatus;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const kind = asset.type === "video" || asset.type === "audio" ? asset.type : void 0;
|
|
90
|
-
return {
|
|
91
|
-
...props,
|
|
92
|
-
projectId: props.projectId ?? asset.projectId,
|
|
93
|
-
assetId: props.assetId ?? asset.id,
|
|
94
|
-
status,
|
|
95
|
-
contentRemoved: props.contentRemoved ?? asset.content?.status === "removed",
|
|
96
|
-
type: props.type ?? kind,
|
|
97
|
-
placeholderHash: props.placeholderHash ?? preview?.thumbhash ?? void 0,
|
|
98
|
-
averageColor: props.averageColor ?? preview?.averageColor ?? void 0,
|
|
99
|
-
width: props.width ?? preview?.width ?? void 0,
|
|
100
|
-
height: props.height ?? preview?.height ?? void 0
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
const getMediaState = (options) => buildMediaState(resolveMediaProps(options));
|
|
104
|
-
const buildMediaState = ({ projectId, assetId, status = "allowed", contentRemoved = false, type = "image", resource = "rendered", lens, transform, widths, url, placeholder = true, placeholderHash, placeholderUrl: customPlaceholderUrl, cdnBaseUrl, viewerClaims }) => {
|
|
105
|
-
if (status === "blocked" || status === "purged" || contentRemoved) return { kind: "unavailable" };
|
|
106
|
-
const region = viewerClaims?.region;
|
|
107
|
-
const ageConfirmed = viewerClaims?.ageConfirmed === true;
|
|
108
|
-
const asset = {
|
|
109
|
-
projectId,
|
|
110
|
-
assetIdentifier: assetId,
|
|
111
|
-
cdnBaseUrl,
|
|
112
|
-
viewerClaims: region || ageConfirmed ? {
|
|
113
|
-
...region ? { region } : {},
|
|
114
|
-
...ageConfirmed ? { ageConfirmed } : {}
|
|
115
|
-
} : void 0
|
|
116
|
-
};
|
|
117
|
-
const placeholderUrl = placeholder ? decodePlaceholderHash(placeholderHash) ?? customPlaceholderUrl ?? (type !== "image" ? void 0 : require_ModerationContextLimits.getAssetUrl({
|
|
118
|
-
projectId,
|
|
119
|
-
assetIdentifier: assetId,
|
|
120
|
-
cdnBaseUrl,
|
|
121
|
-
resource: "placeholder",
|
|
122
|
-
viewerClaims: region ? { region } : void 0
|
|
123
|
-
})) : void 0;
|
|
124
|
-
if (status === "age-restricted" && !ageConfirmed) return {
|
|
125
|
-
kind: "gated",
|
|
126
|
-
placeholderUrl
|
|
127
|
-
};
|
|
128
|
-
const build = (options = {}) => {
|
|
129
|
-
const chosen = options.resource ?? resource;
|
|
130
|
-
const rendered = chosen === "rendered";
|
|
131
|
-
return require_ModerationContextLimits.getAssetUrl({
|
|
132
|
-
...asset,
|
|
133
|
-
resource: chosen,
|
|
134
|
-
lens: rendered ? lens : void 0,
|
|
135
|
-
transform: rendered ? withWidth(transform, options.width) : void 0
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
if (type === "audio") return {
|
|
139
|
-
kind: "audio",
|
|
140
|
-
src: url ?? build({ resource: "original" })
|
|
141
|
-
};
|
|
142
|
-
if (type === "video") return {
|
|
143
|
-
kind: "video",
|
|
144
|
-
src: url ?? build({ resource: "original" }),
|
|
145
|
-
placeholderUrl
|
|
146
|
-
};
|
|
147
|
-
if (url) return {
|
|
148
|
-
kind: "image",
|
|
149
|
-
src: url,
|
|
150
|
-
placeholderUrl
|
|
151
|
-
};
|
|
152
|
-
const sources = [...new Set(widths ?? [])].filter((width) => Number.isSafeInteger(width) && width > 0).sort((a, b) => a - b).map((width) => ({
|
|
153
|
-
src: build({ width }),
|
|
154
|
-
width
|
|
155
|
-
}));
|
|
156
|
-
return {
|
|
157
|
-
kind: "image",
|
|
158
|
-
src: sources.at(-1)?.src ?? build(),
|
|
159
|
-
srcSet: sources.length ? sources.map(({ src, width }) => `${src} ${width}w`).join(", ") : void 0,
|
|
160
|
-
sources: sources.length ? sources : void 0,
|
|
161
|
-
placeholderUrl
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
// src/ui/Messages.ts
|
|
165
|
-
/** The size of a row's file-type icon, the same as an image preview. */
|
|
166
|
-
const FILE_ICON_SIZE = 40;
|
|
167
|
-
const DEFAULT_MESSAGES = {
|
|
168
|
-
dropzoneTitle: "Click to upload or drag and drop",
|
|
169
|
-
dropzoneTitleDragging: "Drop to upload",
|
|
170
|
-
chooseFile: "Select file",
|
|
171
|
-
chooseFiles: "Select files",
|
|
172
|
-
chooseAnother: "Choose another",
|
|
173
|
-
maxFileSizeHint: "Up to {size}",
|
|
174
|
-
selected: "",
|
|
175
|
-
queued: "Waiting…",
|
|
176
|
-
uploading: "Uploading…",
|
|
177
|
-
checking: "Checking…",
|
|
178
|
-
submitted: "Uploaded.",
|
|
179
|
-
pending: "Uploaded. It will be shown once it has been checked.",
|
|
180
|
-
allowed: "Uploaded.",
|
|
181
|
-
limited: "Uploaded.",
|
|
182
|
-
"age-restricted": "Uploaded. It will only be shown to people who can see sensitive content.",
|
|
183
|
-
blocked: "This file can't be used because it may break our community guidelines.",
|
|
184
|
-
purged: "This file can't be used because it breaks our community guidelines.",
|
|
185
|
-
failed: "We couldn't upload this file. Please try again.",
|
|
186
|
-
"file/not-accepted": "This type of file isn't accepted.",
|
|
187
|
-
"file/too-large": "This file is too large.",
|
|
188
|
-
"upload-preset/too-large": "This file is too large.",
|
|
189
|
-
"upload-preset/content-type-not-allowed": "This type of file isn't accepted.",
|
|
190
|
-
"upload-preset/daily-limit-reached": "You've reached today's upload limit. Try again tomorrow.",
|
|
191
|
-
"upload-token/expired": "Your upload expired. Please try again.",
|
|
192
|
-
"sdk/cancelled": "Cancelled.",
|
|
193
|
-
retry: "Retry",
|
|
194
|
-
remove: "Remove {name}",
|
|
195
|
-
cancel: "Cancel {name}",
|
|
196
|
-
sensitiveTitle: "Sensitive content",
|
|
197
|
-
sensitiveBody: "This may not be suitable for everyone.",
|
|
198
|
-
reveal: "View",
|
|
199
|
-
unavailable: "Unavailable",
|
|
200
|
-
regionalUnavailable: "Unavailable in your region"
|
|
201
|
-
};
|
|
202
|
-
const resolveMessages = (overrides) => overrides ? {
|
|
203
|
-
...DEFAULT_MESSAGES,
|
|
204
|
-
...overrides
|
|
205
|
-
} : DEFAULT_MESSAGES;
|
|
206
|
-
/** The unavailable notice every media binding shows for the same resolved state. */
|
|
207
|
-
const getMediaUnavailableMessage = (state, messages) => state.kind === "unavailable" && state.reason === "regional" ? messages.regionalUnavailable : messages.unavailable;
|
|
208
|
-
/** Fills `{name}`-style placeholders. */
|
|
209
|
-
const formatMessage = (message, values) => message.replace(/\{(\w+)\}/g, (match, name) => values[name] ?? match);
|
|
210
|
-
/** The message for a file's current state. */
|
|
211
|
-
const getUploadItemMessage = (item, messages) => {
|
|
212
|
-
if (item.stage === "failed") return item.errorCode && messages[item.errorCode] || messages.failed;
|
|
213
|
-
if (item.stage === "complete") return messages[item.status ?? "submitted"] ?? messages.submitted;
|
|
214
|
-
return messages[item.stage];
|
|
215
|
-
};
|
|
216
|
-
/** How a finished file turned out, for styling: `accepted`, `restricted` or `rejected`. */
|
|
217
|
-
const getUploadItemOutcome = (item) => {
|
|
218
|
-
if (item.stage === "failed") return "rejected";
|
|
219
|
-
if (item.stage !== "complete") return void 0;
|
|
220
|
-
if (item.status === "blocked" || item.status === "purged") return "rejected";
|
|
221
|
-
return item.status === "age-restricted" ? "restricted" : "accepted";
|
|
222
|
-
};
|
|
223
|
-
/** A byte count for people, such as `1.2 MB`. */
|
|
224
|
-
const formatBytes = (bytes) => {
|
|
225
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
226
|
-
const units = [
|
|
227
|
-
"KB",
|
|
228
|
-
"MB",
|
|
229
|
-
"GB"
|
|
230
|
-
];
|
|
231
|
-
let value = bytes / 1024;
|
|
232
|
-
let unit = 0;
|
|
233
|
-
while (value >= 1024 && unit < units.length - 1) {
|
|
234
|
-
value /= 1024;
|
|
235
|
-
unit++;
|
|
236
|
-
}
|
|
237
|
-
return `${value >= 10 ? Math.round(value) : value.toFixed(1)} ${units[unit]}`;
|
|
238
|
-
};
|
|
239
|
-
const describeUploadItem = (item, messages) => {
|
|
240
|
-
const busy = item.stage === "queued" || item.stage === "uploading" || item.stage === "checking";
|
|
241
|
-
return {
|
|
242
|
-
message: getUploadItemMessage(item, messages),
|
|
243
|
-
outcome: getUploadItemOutcome(item),
|
|
244
|
-
busy,
|
|
245
|
-
progressPercent: item.stage === "uploading" && item.progress !== null ? Math.round(item.progress * 100) : void 0,
|
|
246
|
-
canRetry: item.stage === "failed" && !item.errorCode?.startsWith("file/"),
|
|
247
|
-
removeLabel: formatMessage(busy ? messages.cancel : messages.remove, { name: item.file.name }),
|
|
248
|
-
fileIcon: item.previewUrl ? "" : require_FileIcons.renderFileIconSvg(require_FileIcons.getFileIcon(item.file), FILE_ICON_SIZE),
|
|
249
|
-
size: formatBytes(item.file.size)
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
/** The hint under the drop zone's title, or `undefined` without a size limit. */
|
|
253
|
-
const getDropzoneHint = (messages, maxFileSize) => maxFileSize === void 0 ? void 0 : formatMessage(messages.maxFileSizeHint, { size: formatBytes(maxFileSize) });
|
|
254
|
-
const describeUploader = (snapshot, options, messages) => ({
|
|
255
|
-
showDropzone: Boolean(options.multiple) || snapshot.items.length === 0,
|
|
256
|
-
chooseLabel: options.multiple ? messages.chooseFiles : messages.chooseFile,
|
|
257
|
-
hint: getDropzoneHint(messages, options.maxFileSize)
|
|
258
|
-
});
|
|
259
|
-
// src/ui/Props.ts
|
|
260
|
-
/** The aspect ratio a media component's box keeps, if it knows one. */
|
|
261
|
-
const getMediaAspectRatio = ({ aspectRatio, width, height }) => aspectRatio ?? (width && height ? width / height : void 0);
|
|
262
|
-
/** A key that changes whenever a media component must load something new. */
|
|
263
|
-
const getMediaLoadKey = (state) => state.kind === "image" ? `${state.src} ${state.srcSet ?? ""}` : state.kind === "video" || state.kind === "audio" ? state.src : state.kind === "unavailable" && state.reason === "regional" ? "unavailable-regional" : state.kind;
|
|
264
|
-
// src/ui/Theme.ts
|
|
265
|
-
const CALMLENS_THEME = {
|
|
266
|
-
accent: "#635bff",
|
|
267
|
-
accentText: "#fff",
|
|
268
|
-
radius: 12,
|
|
269
|
-
text: "#1f2328",
|
|
270
|
-
background: "transparent",
|
|
271
|
-
success: "#12a26f",
|
|
272
|
-
warning: "#e8a317",
|
|
273
|
-
danger: "#e5484d"
|
|
274
|
-
};
|
|
275
|
-
/** `color` at `alpha` as `rgba()`, for a hex colour; other colours are returned as they are. */
|
|
276
|
-
const withAlpha = (color, alpha) => {
|
|
277
|
-
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color)?.[1];
|
|
278
|
-
if (!hex) return color;
|
|
279
|
-
const full = hex.length === 3 ? [...hex].map((digit) => digit + digit).join("") : hex;
|
|
280
|
-
const [red, green, blue] = [
|
|
281
|
-
0,
|
|
282
|
-
2,
|
|
283
|
-
4
|
|
284
|
-
].map((start) => Number.parseInt(full.slice(start, start + 2), 16));
|
|
285
|
-
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* The full theme from your overrides, mixing the muted, border and surface colours from `text`
|
|
289
|
-
* as the stylesheet mixes them from the page's text colour.
|
|
290
|
-
*/
|
|
291
|
-
const resolveTheme = (overrides = {}) => {
|
|
292
|
-
const text = overrides.text ?? CALMLENS_THEME.text;
|
|
293
|
-
return {
|
|
294
|
-
...CALMLENS_THEME,
|
|
295
|
-
muted: withAlpha(text, .72),
|
|
296
|
-
border: withAlpha(text, .18),
|
|
297
|
-
surface: withAlpha(text, .04),
|
|
298
|
-
...overrides,
|
|
299
|
-
text
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
// src/ui/Styles.ts
|
|
303
|
-
/**
|
|
304
|
-
* The components' stylesheet, also shipped as `calmlens/styles.css`. The React components
|
|
305
|
-
* render it themselves (React hoists it into the head, on the server too); with Vue, Svelte or
|
|
306
|
-
* the web components, import or link `calmlens/styles.css` once. Nothing is added to the page
|
|
307
|
-
* at runtime. Theme it with the `--calmlens-*` custom properties, or leave it out and style the
|
|
308
|
-
* `calmlens-*` classes yourself.
|
|
309
|
-
*/
|
|
310
|
-
const CALMLENS_STYLES = `
|
|
311
|
-
/* Zero specificity, so a page's own --calmlens-* values win even on the same element. */
|
|
312
|
-
:where(.calmlens-uploader, .calmlens-media) {
|
|
313
|
-
--calmlens-accent: ${CALMLENS_THEME.accent};
|
|
314
|
-
--calmlens-accent-text: ${CALMLENS_THEME.accentText};
|
|
315
|
-
--calmlens-radius: ${CALMLENS_THEME.radius}px;
|
|
316
|
-
--calmlens-border: color-mix(in srgb, currentColor 18%, transparent);
|
|
317
|
-
--calmlens-surface: color-mix(in srgb, currentColor 4%, transparent);
|
|
318
|
-
--calmlens-background: ${CALMLENS_THEME.background};
|
|
319
|
-
--calmlens-muted: color-mix(in srgb, currentColor 72%, transparent);
|
|
320
|
-
--calmlens-success: ${CALMLENS_THEME.success};
|
|
321
|
-
--calmlens-warning: ${CALMLENS_THEME.warning};
|
|
322
|
-
--calmlens-danger: ${CALMLENS_THEME.danger};
|
|
323
|
-
--calmlens-focus-ring: var(--calmlens-accent);
|
|
324
|
-
--calmlens-focus-width: 2px;
|
|
325
|
-
--calmlens-focus-offset: 2px;
|
|
326
|
-
box-sizing: border-box;
|
|
327
|
-
font: inherit;
|
|
328
|
-
}
|
|
329
|
-
.calmlens-uploader *, .calmlens-media * { box-sizing: border-box; }
|
|
330
|
-
.calmlens-uploader { display: grid; gap: 12px; }
|
|
331
|
-
.calmlens-uploader > [hidden] { display: none; }
|
|
332
|
-
.calmlens-dropzone {
|
|
333
|
-
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
|
|
334
|
-
padding: 40px 24px; text-align: center;
|
|
335
|
-
border: 1.5px dashed var(--calmlens-border); border-radius: var(--calmlens-radius);
|
|
336
|
-
background: var(--calmlens-surface); cursor: pointer;
|
|
337
|
-
transition: border-color 200ms ease-in-out, background-color 200ms ease-in-out;
|
|
338
|
-
}
|
|
339
|
-
.calmlens-dropzone:hover, .calmlens-dropzone:focus-within {
|
|
340
|
-
border-color: color-mix(in srgb, var(--calmlens-accent) 30%, transparent);
|
|
341
|
-
background: color-mix(in srgb, var(--calmlens-accent) 4%, transparent);
|
|
342
|
-
}
|
|
343
|
-
.calmlens-dropzone[data-dragging] {
|
|
344
|
-
border-color: var(--calmlens-accent);
|
|
345
|
-
background: color-mix(in srgb, var(--calmlens-accent) 9%, transparent);
|
|
346
|
-
}
|
|
347
|
-
.calmlens-dropzone[data-disabled] {
|
|
348
|
-
cursor: not-allowed; border-color: var(--calmlens-border); background: none; color: var(--calmlens-muted);
|
|
349
|
-
}
|
|
350
|
-
.calmlens-dropzone__icon {
|
|
351
|
-
display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
|
|
352
|
-
color: var(--calmlens-accent); background: color-mix(in srgb, var(--calmlens-accent) 10%, transparent);
|
|
353
|
-
transition: transform 200ms;
|
|
354
|
-
}
|
|
355
|
-
.calmlens-dropzone[data-disabled] .calmlens-dropzone__icon { color: inherit; background: var(--calmlens-surface); }
|
|
356
|
-
.calmlens-dropzone[data-dragging] .calmlens-dropzone__icon { transform: scale(1.1); }
|
|
357
|
-
.calmlens-dropzone__text { display: grid; gap: 4px; }
|
|
358
|
-
.calmlens-dropzone__title { font-weight: 500; margin: 0; }
|
|
359
|
-
.calmlens-dropzone__hint { font-size: 0.875em; margin: 0; color: var(--calmlens-muted); }
|
|
360
|
-
.calmlens-button, .calmlens-icon-button { margin: 0; width: auto; text-transform: none; letter-spacing: normal; }
|
|
361
|
-
.calmlens-button {
|
|
362
|
-
font: inherit; font-weight: 500; font-size: 0.875em; padding: 7px 14px; border-radius: 8px; cursor: pointer;
|
|
363
|
-
border: 1px solid var(--calmlens-accent); background: var(--calmlens-accent); color: var(--calmlens-accent-text);
|
|
364
|
-
white-space: nowrap; transition: background-color 150ms, border-color 150ms;
|
|
365
|
-
}
|
|
366
|
-
.calmlens-button:focus-visible, .calmlens-icon-button:focus-visible {
|
|
367
|
-
outline: var(--calmlens-focus-width) solid var(--calmlens-focus-ring); outline-offset: var(--calmlens-focus-offset);
|
|
368
|
-
}
|
|
369
|
-
.calmlens-button:hover:not(:disabled) { background: var(--calmlens-accent); filter: brightness(1.08); }
|
|
370
|
-
.calmlens-button[data-variant="outline"] { background: none; color: inherit; border-color: var(--calmlens-border); }
|
|
371
|
-
.calmlens-button[data-variant="outline"]:hover:not(:disabled) {
|
|
372
|
-
filter: none; background: color-mix(in srgb, var(--calmlens-accent) 8%, transparent); border-color: var(--calmlens-accent);
|
|
373
|
-
}
|
|
374
|
-
.calmlens-button[data-size="small"] { padding: 4px 10px; }
|
|
375
|
-
.calmlens-button:disabled {
|
|
376
|
-
cursor: not-allowed; border-style: dashed; background: none; color: var(--calmlens-muted); border-color: var(--calmlens-border);
|
|
377
|
-
}
|
|
378
|
-
.calmlens-uploads { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
|
379
|
-
.calmlens-upload {
|
|
380
|
-
display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px;
|
|
381
|
-
border: 1px solid var(--calmlens-border); border-radius: var(--calmlens-radius); background: var(--calmlens-background);
|
|
382
|
-
}
|
|
383
|
-
/* A finished file's outcome is a dot in its status colour before the message. */
|
|
384
|
-
.calmlens-upload[data-outcome] .calmlens-upload__message::before {
|
|
385
|
-
content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%;
|
|
386
|
-
vertical-align: 0.05em;
|
|
387
|
-
}
|
|
388
|
-
.calmlens-upload[data-outcome="accepted"] .calmlens-upload__message::before { background: var(--calmlens-success); }
|
|
389
|
-
.calmlens-upload[data-outcome="restricted"] .calmlens-upload__message::before { background: var(--calmlens-warning); }
|
|
390
|
-
.calmlens-upload[data-outcome="rejected"] .calmlens-upload__message::before { background: var(--calmlens-danger); }
|
|
391
|
-
.calmlens-upload__thumb {
|
|
392
|
-
width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: grid; place-items: center;
|
|
393
|
-
background: var(--calmlens-surface); border: 1px solid var(--calmlens-border);
|
|
394
|
-
font-size: 0.6875em; font-weight: 700; text-transform: uppercase; overflow: hidden;
|
|
395
|
-
}
|
|
396
|
-
.calmlens-upload__thumb[data-kind="file"] { background: none; border: none; }
|
|
397
|
-
.calmlens-upload[data-outcome="rejected"] img.calmlens-upload__thumb { filter: blur(6px); }
|
|
398
|
-
.calmlens-upload__body { min-width: 0; display: grid; gap: 4px; }
|
|
399
|
-
.calmlens-upload__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
400
|
-
.calmlens-upload__size { font-size: 0.875em; color: var(--calmlens-muted); }
|
|
401
|
-
.calmlens-upload__message { font-size: 0.875em; margin: 0; }
|
|
402
|
-
.calmlens-progress {
|
|
403
|
-
height: 4px; border-radius: 2px; overflow: hidden; background: var(--calmlens-border); position: relative;
|
|
404
|
-
}
|
|
405
|
-
.calmlens-progress__bar {
|
|
406
|
-
position: absolute; inset: 0 auto 0 0; background: var(--calmlens-accent); border-radius: inherit;
|
|
407
|
-
transition: width 150ms;
|
|
408
|
-
}
|
|
409
|
-
.calmlens-progress:not([aria-valuenow]) .calmlens-progress__bar {
|
|
410
|
-
width: 35%; animation: calmlens-indeterminate 1.1s ease-in-out infinite;
|
|
411
|
-
}
|
|
412
|
-
@keyframes calmlens-indeterminate { from { left: -35%; } to { left: 100%; } }
|
|
413
|
-
.calmlens-upload__actions { display: flex; gap: 8px; align-items: center; }
|
|
414
|
-
.calmlens-icon-button {
|
|
415
|
-
display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 8px; cursor: pointer;
|
|
416
|
-
border: 1px solid transparent; background: none; color: inherit;
|
|
417
|
-
}
|
|
418
|
-
.calmlens-icon-button:hover { background: color-mix(in srgb, var(--calmlens-accent) 8%, transparent); border-color: var(--calmlens-border); }
|
|
419
|
-
@media (prefers-reduced-motion: reduce) {
|
|
420
|
-
.calmlens-progress__bar, .calmlens-dropzone, .calmlens-dropzone__icon, .calmlens-media__content { transition: none; }
|
|
421
|
-
.calmlens-progress:not([aria-valuenow]) .calmlens-progress__bar { animation: none; left: 0; width: 100%; }
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
.calmlens-media {
|
|
425
|
-
position: relative; display: block; overflow: hidden; margin: 0; border-radius: var(--calmlens-media-radius, 0);
|
|
426
|
-
background: var(--calmlens-surface);
|
|
427
|
-
}
|
|
428
|
-
.calmlens-media__placeholder, .calmlens-media__content {
|
|
429
|
-
position: absolute; inset: 0; width: 100%; height: 100%; object-fit: var(--calmlens-fit, cover);
|
|
430
|
-
object-position: var(--calmlens-position, center);
|
|
431
|
-
}
|
|
432
|
-
.calmlens-media:not([data-sized]) .calmlens-media__content { position: relative; height: auto; }
|
|
433
|
-
.calmlens-media:not([data-sized])[data-kind="gated"], .calmlens-media:not([data-sized])[data-kind="unavailable"],
|
|
434
|
-
.calmlens-media:not([data-sized])[data-state="error"] { min-height: 160px; }
|
|
435
|
-
.calmlens-media__placeholder { transform: scale(1.1); filter: blur(12px); }
|
|
436
|
-
.calmlens-media__content { opacity: 0; transition: opacity 250ms; }
|
|
437
|
-
.calmlens-media[data-state="loaded"] .calmlens-media__content { opacity: 1; }
|
|
438
|
-
.calmlens-media[data-kind="video"] .calmlens-media__content, .calmlens-media[data-kind="audio"] .calmlens-media__content { opacity: 1; }
|
|
439
|
-
.calmlens-media[data-kind="audio"] { background: none; }
|
|
440
|
-
.calmlens-media[data-kind="audio"] .calmlens-media__content { position: static; height: auto; }
|
|
441
|
-
.calmlens-media__notice {
|
|
442
|
-
position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px;
|
|
443
|
-
padding: 12px; text-align: center; color: #fff; background: rgba(0, 0, 0, 0.45);
|
|
444
|
-
}
|
|
445
|
-
.calmlens-media__notice p { margin: 0; display: flex; gap: 6px; align-items: center; }
|
|
446
|
-
/* Thumbnails keep the notice's icon and leave its text to screen readers. */
|
|
447
|
-
.calmlens-media[data-sized] { container-type: inline-size; }
|
|
448
|
-
@container (max-width: 119px) {
|
|
449
|
-
.calmlens-media__label, .calmlens-media__notice > strong, .calmlens-media__notice > p:not(:has(svg)) {
|
|
450
|
-
position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
.calmlens-media__notice strong { font-weight: 600; }
|
|
454
|
-
.calmlens-media__notice .calmlens-button { margin-top: 4px; border-color: #fff; background: #fff; color: #111; }
|
|
455
|
-
.calmlens-media[data-state="error"] .calmlens-media__notice, .calmlens-media[data-kind="unavailable"] .calmlens-media__notice {
|
|
456
|
-
color: inherit; background: var(--calmlens-surface);
|
|
457
|
-
}
|
|
458
|
-
`;
|
|
459
|
-
/** Identifies the stylesheet, so React adds it once however many components render. */
|
|
460
|
-
const CALMLENS_STYLES_ID = "calmlens-styles";
|
|
461
|
-
Object.defineProperty(exports, "CALMLENS_STYLES", {
|
|
462
|
-
enumerable: true,
|
|
463
|
-
get: function() {
|
|
464
|
-
return CALMLENS_STYLES;
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
Object.defineProperty(exports, "CALMLENS_STYLES_ID", {
|
|
468
|
-
enumerable: true,
|
|
469
|
-
get: function() {
|
|
470
|
-
return CALMLENS_STYLES_ID;
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
Object.defineProperty(exports, "CALMLENS_THEME", {
|
|
474
|
-
enumerable: true,
|
|
475
|
-
get: function() {
|
|
476
|
-
return CALMLENS_THEME;
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
Object.defineProperty(exports, "DEFAULT_MESSAGES", {
|
|
480
|
-
enumerable: true,
|
|
481
|
-
get: function() {
|
|
482
|
-
return DEFAULT_MESSAGES;
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
Object.defineProperty(exports, "ICONS", {
|
|
486
|
-
enumerable: true,
|
|
487
|
-
get: function() {
|
|
488
|
-
return ICONS;
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
Object.defineProperty(exports, "ICON_ATTRIBUTES", {
|
|
492
|
-
enumerable: true,
|
|
493
|
-
get: function() {
|
|
494
|
-
return ICON_ATTRIBUTES;
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
Object.defineProperty(exports, "describeUploadItem", {
|
|
498
|
-
enumerable: true,
|
|
499
|
-
get: function() {
|
|
500
|
-
return describeUploadItem;
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
Object.defineProperty(exports, "describeUploader", {
|
|
504
|
-
enumerable: true,
|
|
505
|
-
get: function() {
|
|
506
|
-
return describeUploader;
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
Object.defineProperty(exports, "formatBytes", {
|
|
510
|
-
enumerable: true,
|
|
511
|
-
get: function() {
|
|
512
|
-
return formatBytes;
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
Object.defineProperty(exports, "formatMessage", {
|
|
516
|
-
enumerable: true,
|
|
517
|
-
get: function() {
|
|
518
|
-
return formatMessage;
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
Object.defineProperty(exports, "getDropzoneHint", {
|
|
522
|
-
enumerable: true,
|
|
523
|
-
get: function() {
|
|
524
|
-
return getDropzoneHint;
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
Object.defineProperty(exports, "getMediaAspectRatio", {
|
|
528
|
-
enumerable: true,
|
|
529
|
-
get: function() {
|
|
530
|
-
return getMediaAspectRatio;
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
Object.defineProperty(exports, "getMediaLoadKey", {
|
|
534
|
-
enumerable: true,
|
|
535
|
-
get: function() {
|
|
536
|
-
return getMediaLoadKey;
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
Object.defineProperty(exports, "getMediaState", {
|
|
540
|
-
enumerable: true,
|
|
541
|
-
get: function() {
|
|
542
|
-
return getMediaState;
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
Object.defineProperty(exports, "getMediaUnavailableMessage", {
|
|
546
|
-
enumerable: true,
|
|
547
|
-
get: function() {
|
|
548
|
-
return getMediaUnavailableMessage;
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
Object.defineProperty(exports, "getUploadItemMessage", {
|
|
552
|
-
enumerable: true,
|
|
553
|
-
get: function() {
|
|
554
|
-
return getUploadItemMessage;
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
Object.defineProperty(exports, "getUploadItemOutcome", {
|
|
558
|
-
enumerable: true,
|
|
559
|
-
get: function() {
|
|
560
|
-
return getUploadItemOutcome;
|
|
561
|
-
}
|
|
562
|
-
});
|
|
563
|
-
Object.defineProperty(exports, "pickMediaSource", {
|
|
564
|
-
enumerable: true,
|
|
565
|
-
get: function() {
|
|
566
|
-
return pickMediaSource;
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
Object.defineProperty(exports, "resolveMediaProps", {
|
|
570
|
-
enumerable: true,
|
|
571
|
-
get: function() {
|
|
572
|
-
return resolveMediaProps;
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
Object.defineProperty(exports, "resolveMessages", {
|
|
576
|
-
enumerable: true,
|
|
577
|
-
get: function() {
|
|
578
|
-
return resolveMessages;
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
Object.defineProperty(exports, "resolveTheme", {
|
|
582
|
-
enumerable: true,
|
|
583
|
-
get: function() {
|
|
584
|
-
return resolveTheme;
|
|
585
|
-
}
|
|
586
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as zod from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* What moderation decided for an asset, which also decides how it is delivered: served to anyone
|
|
4
|
-
* with access (`allowed`), served the same way but marked for reduced reach (`limited`), only to
|
|
5
|
-
* requests that confirm the viewer's age with `ageConfirmed`, signed URLs and server keys included
|
|
6
|
-
* (`age-restricted`), not served (`blocked`), or not served with its stored content deleted
|
|
7
|
-
* (`purged`).
|
|
8
|
-
*/
|
|
9
|
-
declare const ASSET_MODERATION_DECISION_SCHEMA: zod.ZodEnum<{
|
|
10
|
-
"age-restricted": "age-restricted";
|
|
11
|
-
allowed: "allowed";
|
|
12
|
-
blocked: "blocked";
|
|
13
|
-
limited: "limited";
|
|
14
|
-
purged: "purged";
|
|
15
|
-
}>;
|
|
16
|
-
type AssetModerationDecision = zod.infer<typeof ASSET_MODERATION_DECISION_SCHEMA>;
|
|
17
|
-
declare const HASH_LIST_SCHEMA: zod.ZodObject<{
|
|
18
|
-
id: zod.ZodString;
|
|
19
|
-
projectId: zod.ZodString;
|
|
20
|
-
name: zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
|
|
21
|
-
description: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
22
|
-
action: zod.ZodEnum<{
|
|
23
|
-
block: "block";
|
|
24
|
-
flag: "flag";
|
|
25
|
-
}>;
|
|
26
|
-
createdAt: zod.ZodNumber;
|
|
27
|
-
updatedAt: zod.ZodOptional<zod.ZodNumber>;
|
|
28
|
-
}, zod.core.$strip>;
|
|
29
|
-
type HashList = zod.infer<typeof HASH_LIST_SCHEMA>;
|
|
30
|
-
declare const HASH_LIST_ENTRY_SCHEMA: zod.ZodObject<{
|
|
31
|
-
id: zod.ZodString;
|
|
32
|
-
projectId: zod.ZodString;
|
|
33
|
-
hashListId: zod.ZodString;
|
|
34
|
-
hash: zod.ZodString;
|
|
35
|
-
quality: zod.ZodNullable<zod.ZodNumber>;
|
|
36
|
-
label: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
37
|
-
sourceAssetId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
38
|
-
createdAt: zod.ZodNumber;
|
|
39
|
-
}, zod.core.$strip>;
|
|
40
|
-
type HashListEntry = zod.infer<typeof HASH_LIST_ENTRY_SCHEMA>;
|
|
41
|
-
/** The most recent earlier posts CalmLens uses. */
|
|
42
|
-
declare const MODERATION_CONTEXT_USED_ITEMS = 5;
|
|
43
|
-
/**
|
|
44
|
-
* The most characters of earlier posts CalmLens uses. The newest post always fits, since no post
|
|
45
|
-
* may be longer.
|
|
46
|
-
*/
|
|
47
|
-
declare const MODERATION_CONTEXT_USED_CHARACTERS = 2000;
|
|
48
|
-
/** An earlier post in the conversation. */
|
|
49
|
-
interface ModerationContextItem {
|
|
50
|
-
text: string;
|
|
51
|
-
authorId?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* The earlier posts CalmLens uses: the most recent ones, newest first, while at most
|
|
55
|
-
* `MODERATION_CONTEXT_USED_ITEMS` and `MODERATION_CONTEXT_USED_CHARACTERS` allow, returned oldest
|
|
56
|
-
* first. The newest post is always kept, so an over-long one is left for validation to reject.
|
|
57
|
-
*/
|
|
58
|
-
declare const selectModerationContextItems: <Item extends ModerationContextItem>(items: readonly Item[]) => Item[];
|
|
59
|
-
/** The context a request may send: up to 20 earlier posts, oldest first. */
|
|
60
|
-
declare const MODERATION_CONTEXT_SCHEMA: zod.ZodObject<{
|
|
61
|
-
items: zod.ZodArray<zod.ZodObject<{
|
|
62
|
-
text: zod.ZodString;
|
|
63
|
-
authorId: zod.ZodOptional<zod.ZodString>;
|
|
64
|
-
}, zod.core.$strict>>;
|
|
65
|
-
}, zod.core.$strict>;
|
|
66
|
-
type ModerationContext = zod.infer<typeof MODERATION_CONTEXT_SCHEMA>;
|
|
67
|
-
export { selectModerationContextItems as a, AssetModerationDecision as c, ModerationContextItem as i, MODERATION_CONTEXT_USED_CHARACTERS as n, HashList as o, MODERATION_CONTEXT_USED_ITEMS as r, HashListEntry as s, ModerationContext as t };
|