calmlens 0.5.0 → 0.18.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/LICENSE +21 -0
- package/README.md +51 -518
- package/bin/calmlens.js +15991 -1298
- package/bin/package.json +1 -0
- package/cjs/BrowserUpload-BT091eOB.d.ts +11 -0
- package/cjs/BrowserUpload-DRdjobfF.js +10 -0
- package/cjs/CalmLensAppClient-CV_K26Ce.d.ts +40 -0
- package/cjs/CalmLensAppClient-CkyH_fXH.js +89 -0
- package/cjs/CalmLensConnection-CX1A0Q4N.js +659 -0
- package/cjs/CalmLensServerClient-C1djppvN.js +645 -0
- package/cjs/CalmLensServerClient-JtP687a3.d.ts +235 -0
- package/cjs/CalmLensTypes-9Vt16pc7.d.ts +40400 -0
- package/cjs/Classification-94kSYWZw-CMnQKW13.d.ts +5873 -0
- package/cjs/CryptoUtils-B_x8lMIx-YBW1-bvL.js +42 -0
- package/cjs/FileIcons-Ob003MdS.js +175 -0
- package/cjs/Jurisdiction-FusEXb4U-zVs21tDv.js +91 -0
- package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +67 -0
- package/cjs/ModerationContextLimits-nJtd4Tag.js +1311 -0
- package/cjs/ReactUpload-CAyCsyG6.d.ts +17 -0
- package/cjs/ReactUpload-DmBmtsbJ.js +54 -0
- package/cjs/TestTriggers-By07LR31-CmK0yTyR.d.ts +271 -0
- package/cjs/TestTriggers-DTc_iMJF-BjMPq4_3.js +1327 -0
- package/cjs/UploadController-0YTjjzXh.js +618 -0
- package/cjs/WebhookPayload-2aL31v0J.d.ts +352 -0
- package/cjs/app.d.ts +7 -0
- package/cjs/app.js +13 -0
- package/cjs/elements.d.ts +88 -0
- package/cjs/elements.js +555 -0
- package/cjs/file-icons.d.ts +67 -0
- package/cjs/file-icons.js +10 -0
- package/cjs/index-CI4BzN4W.d.ts +252 -0
- package/cjs/index.d.ts +6 -2741
- package/cjs/index.js +9 -1205
- package/cjs/react-native.d.ts +56 -0
- package/cjs/react-native.js +495 -0
- package/cjs/react.d.ts +30 -0
- package/cjs/react.js +370 -0
- package/cjs/server.d.ts +33 -0
- package/cjs/server.js +20 -0
- package/cjs/test-inputs.d.ts +2 -0
- package/cjs/test-inputs.js +10 -0
- package/cjs/testing.d.ts +309 -80
- package/cjs/testing.js +10443 -658
- package/cjs/ui-BG2kKWUq.js +583 -0
- package/cjs/ui-wIiMfqMB.d.ts +526 -0
- package/cjs/ui.d.ts +2 -0
- package/cjs/ui.js +27 -0
- package/cjs/vue.d.ts +490 -0
- package/cjs/vue.js +419 -0
- package/esm/BrowserUpload-BT091eOB.d.ts +11 -0
- package/esm/BrowserUpload-DRHcNM9a.js +5 -0
- package/esm/CalmLensAppClient-COK1Cxfp.js +84 -0
- package/esm/CalmLensAppClient-CV_K26Ce.d.ts +40 -0
- package/esm/CalmLensConnection-BLw8vC-6.js +582 -0
- package/esm/CalmLensServerClient-BwRJKhn7.js +586 -0
- package/esm/CalmLensServerClient-JtP687a3.d.ts +235 -0
- package/esm/CalmLensTypes-9Vt16pc7.d.ts +40400 -0
- package/esm/Classification-94kSYWZw-CMnQKW13.d.ts +5873 -0
- package/esm/CryptoUtils-B_x8lMIx-DhuWGzqn.js +25 -0
- package/esm/FileIcons-M6dzjFxd.js +128 -0
- package/esm/Jurisdiction-FusEXb4U-1ov6m5yE.js +46 -0
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +67 -0
- package/esm/ModerationContextLimits-Cv1qXWB9.js +1114 -0
- package/esm/ReactUpload-CAyCsyG6.d.ts +17 -0
- package/esm/ReactUpload-DooBhDOR.js +37 -0
- package/esm/TestTriggers-By07LR31-CmK0yTyR.d.ts +271 -0
- package/esm/TestTriggers-DTc_iMJF-HfB533Gx.js +1267 -0
- package/esm/UploadController-BDIL9GKO.js +589 -0
- package/esm/WebhookPayload-2aL31v0J.d.ts +352 -0
- package/esm/app.d.ts +7 -0
- package/esm/app.js +4 -0
- package/esm/elements.d.ts +88 -0
- package/esm/elements.js +528 -0
- package/esm/file-icons.d.ts +67 -0
- package/esm/file-icons.js +1 -0
- package/esm/index-CI4BzN4W.d.ts +252 -0
- package/esm/index.d.ts +6 -2741
- package/esm/index.js +1 -1196
- package/esm/react-native.d.ts +56 -0
- package/esm/react-native.js +467 -0
- package/esm/react.d.ts +30 -0
- package/esm/react.js +343 -0
- package/esm/server.d.ts +33 -0
- package/esm/server.js +4 -0
- package/esm/styles.css +147 -0
- package/esm/svelte/CalmLensMedia.svelte +134 -0
- package/esm/svelte/CalmLensUploader.svelte +175 -0
- package/esm/svelte/Icon.svelte +7 -0
- package/esm/svelte/index.d.ts +37 -0
- package/esm/svelte/index.js +6 -0
- package/esm/test-inputs.d.ts +2 -0
- package/esm/test-inputs.js +1 -0
- package/esm/testing.d.ts +309 -80
- package/esm/testing.js +10432 -657
- package/esm/ui-DdoweZQx.js +458 -0
- package/esm/ui-wIiMfqMB.d.ts +526 -0
- package/esm/ui.d.ts +2 -0
- package/esm/ui.js +3 -0
- package/esm/vue.d.ts +490 -0
- package/esm/vue.js +392 -0
- package/package.json +173 -34
- package/cjs/CalmLensTypes-DG_kHVqY.d.ts +0 -3521
- package/cjs/CalmLensUtils-0QaxbI3A.js +0 -551
- package/esm/CalmLensTypes-DG_kHVqY.d.ts +0 -3521
- package/esm/CalmLensUtils-BQEgxGWk.js +0 -410
package/cjs/react.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_ui = require("./ui-BG2kKWUq.js");
|
|
4
|
+
const require_UploadController = require("./UploadController-0YTjjzXh.js");
|
|
5
|
+
const require_ReactUpload = require("./ReactUpload-DmBmtsbJ.js");
|
|
6
|
+
const require_BrowserUpload = require("./BrowserUpload-DRdjobfF.js");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
// src/react.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Uploads files through an upload preset and re-renders as each one uploads and is checked. Use
|
|
12
|
+
* it to build your own upload UI; `CalmLensUploader` is built on it. Uploads still running when
|
|
13
|
+
* the component unmounts are cancelled.
|
|
14
|
+
*/
|
|
15
|
+
const useCalmLensUpload = (options) => require_ReactUpload.useCalmLensUpload(options);
|
|
16
|
+
const joinClassNames = (...names) => names.filter(Boolean).join(" ");
|
|
17
|
+
const Icon = ({ name }) => {
|
|
18
|
+
const { "stroke-width": strokeWidth, "stroke-linecap": strokeLinecap, "stroke-linejoin": strokeLinejoin, "aria-hidden": ariaHidden, ...rest } = require_ui.ICON_ATTRIBUTES;
|
|
19
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
20
|
+
...rest,
|
|
21
|
+
strokeWidth,
|
|
22
|
+
strokeLinecap,
|
|
23
|
+
strokeLinejoin,
|
|
24
|
+
"aria-hidden": ariaHidden,
|
|
25
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: require_ui.ICONS[name] })
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The components' stylesheet, rendered with them: React hoists it into the document head, on the
|
|
30
|
+
* server as well as in the browser, and adds it once however many components render.
|
|
31
|
+
*/
|
|
32
|
+
const CalmLensStyles = ({ unstyled }) => unstyled ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", {
|
|
33
|
+
href: require_ui.CALMLENS_STYLES_ID,
|
|
34
|
+
precedence: "calmlens",
|
|
35
|
+
children: require_ui.CALMLENS_STYLES
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* A drop zone and file list that uploads through an upload preset, shows each file's progress
|
|
39
|
+
* and moderation decision, and reports finished uploads to `onUploaded`.
|
|
40
|
+
*/
|
|
41
|
+
function CalmLensUploader({ disabled, capture, messages: overrides, unstyled, controller: external, className, style, ...options }) {
|
|
42
|
+
const own = require_ReactUpload.useOwnController(options, !external);
|
|
43
|
+
const upload = require_ReactUpload.useUploadSnapshot(external ?? own);
|
|
44
|
+
const { accept, multiple } = upload.controller.options;
|
|
45
|
+
const messages = (0, react.useMemo)(() => require_ui.resolveMessages(overrides), [overrides]);
|
|
46
|
+
const view = require_ui.describeUploader(upload, upload.controller.options, messages);
|
|
47
|
+
const [dragging, setDragging] = (0, react.useState)(false);
|
|
48
|
+
const input = (0, react.useRef)(null);
|
|
49
|
+
const openPicker = () => {
|
|
50
|
+
if (!disabled) input.current?.click();
|
|
51
|
+
};
|
|
52
|
+
const onDragOver = (event) => {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
if (!disabled) setDragging(true);
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
57
|
+
className: joinClassNames("calmlens-uploader", className),
|
|
58
|
+
style,
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalmLensStyles, { unstyled }),
|
|
61
|
+
view.showDropzone && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
62
|
+
className: "calmlens-dropzone",
|
|
63
|
+
"data-dragging": dragging || void 0,
|
|
64
|
+
"data-disabled": disabled || void 0,
|
|
65
|
+
onClick: openPicker,
|
|
66
|
+
onDragOver,
|
|
67
|
+
onDragEnter: onDragOver,
|
|
68
|
+
onDragLeave: (event) => {
|
|
69
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setDragging(false);
|
|
70
|
+
},
|
|
71
|
+
onDrop: (event) => {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
setDragging(false);
|
|
74
|
+
if (!disabled) upload.addFiles(event.dataTransfer.files);
|
|
75
|
+
},
|
|
76
|
+
onPaste: (event) => {
|
|
77
|
+
if (!disabled && event.clipboardData.files.length) upload.addFiles(event.clipboardData.files);
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
81
|
+
className: "calmlens-dropzone__icon",
|
|
82
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "upload" })
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
85
|
+
className: "calmlens-dropzone__text",
|
|
86
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
87
|
+
className: "calmlens-dropzone__title",
|
|
88
|
+
children: dragging ? messages.dropzoneTitleDragging : messages.dropzoneTitle
|
|
89
|
+
}), view.hint && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
90
|
+
className: "calmlens-dropzone__hint",
|
|
91
|
+
children: view.hint
|
|
92
|
+
})]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
95
|
+
type: "button",
|
|
96
|
+
className: "calmlens-button",
|
|
97
|
+
"data-variant": "outline",
|
|
98
|
+
disabled,
|
|
99
|
+
onClick: (event) => {
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
openPicker();
|
|
102
|
+
},
|
|
103
|
+
children: view.chooseLabel
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
108
|
+
ref: input,
|
|
109
|
+
type: "file",
|
|
110
|
+
hidden: true,
|
|
111
|
+
accept,
|
|
112
|
+
multiple,
|
|
113
|
+
capture,
|
|
114
|
+
disabled,
|
|
115
|
+
onChange: (event) => {
|
|
116
|
+
if (event.target.files) upload.addFiles(event.target.files);
|
|
117
|
+
event.target.value = "";
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
upload.items.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
121
|
+
className: "calmlens-uploads",
|
|
122
|
+
children: upload.items.map((item) => {
|
|
123
|
+
const itemView = require_ui.describeUploadItem(item, messages);
|
|
124
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
125
|
+
className: "calmlens-upload",
|
|
126
|
+
"data-stage": item.stage,
|
|
127
|
+
"data-outcome": itemView.outcome,
|
|
128
|
+
children: [
|
|
129
|
+
item.previewUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
130
|
+
className: "calmlens-upload__thumb",
|
|
131
|
+
src: item.previewUrl,
|
|
132
|
+
alt: ""
|
|
133
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
134
|
+
className: "calmlens-upload__thumb",
|
|
135
|
+
"data-kind": "file",
|
|
136
|
+
"aria-hidden": "true",
|
|
137
|
+
dangerouslySetInnerHTML: { __html: itemView.fileIcon }
|
|
138
|
+
}),
|
|
139
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
140
|
+
className: "calmlens-upload__body",
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
143
|
+
className: "calmlens-upload__name",
|
|
144
|
+
children: item.file.name
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
147
|
+
className: "calmlens-upload__size",
|
|
148
|
+
children: itemView.size
|
|
149
|
+
}),
|
|
150
|
+
itemView.busy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
151
|
+
className: "calmlens-progress",
|
|
152
|
+
role: "progressbar",
|
|
153
|
+
"aria-label": itemView.message,
|
|
154
|
+
"aria-valuemin": 0,
|
|
155
|
+
"aria-valuemax": 100,
|
|
156
|
+
"aria-valuenow": itemView.progressPercent,
|
|
157
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
158
|
+
className: "calmlens-progress__bar",
|
|
159
|
+
style: itemView.progressPercent === void 0 ? void 0 : { width: `${itemView.progressPercent}%` }
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
itemView.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
163
|
+
className: "calmlens-upload__message",
|
|
164
|
+
role: "status",
|
|
165
|
+
children: itemView.message
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
}),
|
|
169
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
170
|
+
className: "calmlens-upload__actions",
|
|
171
|
+
children: [
|
|
172
|
+
!view.showDropzone && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
173
|
+
type: "button",
|
|
174
|
+
className: "calmlens-button",
|
|
175
|
+
"data-variant": "outline",
|
|
176
|
+
"data-size": "small",
|
|
177
|
+
disabled,
|
|
178
|
+
onClick: openPicker,
|
|
179
|
+
children: messages.chooseAnother
|
|
180
|
+
}),
|
|
181
|
+
itemView.canRetry && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
182
|
+
type: "button",
|
|
183
|
+
className: "calmlens-icon-button",
|
|
184
|
+
"aria-label": messages.retry,
|
|
185
|
+
title: messages.retry,
|
|
186
|
+
onClick: () => upload.retry(item.key),
|
|
187
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "retry" })
|
|
188
|
+
}),
|
|
189
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
190
|
+
type: "button",
|
|
191
|
+
className: "calmlens-icon-button",
|
|
192
|
+
"aria-label": itemView.removeLabel,
|
|
193
|
+
title: itemView.removeLabel,
|
|
194
|
+
onClick: () => upload.remove(item.key),
|
|
195
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "remove" })
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
}, item.key);
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Shows an asset from the CalmLens CDN with responsive widths and a blurred placeholder while
|
|
208
|
+
* it loads. Age-restricted assets stay behind the placeholder and a reveal button until
|
|
209
|
+
* `ageConfirmed` is set; blocked and purged assets show an unavailable notice.
|
|
210
|
+
*/
|
|
211
|
+
function CalmLensMedia(input) {
|
|
212
|
+
const { asset: _asset, projectId, assetId, status, contentRemoved, type, resource, lens, transform, widths, url, placeholder, placeholderHash, placeholderUrl: customPlaceholderUrl, cdnBaseUrl, viewerClaims, alt = "", aspectRatio, width, height, sizes, averageColor, fit, position, lazy = true, fetchPriority, controls = true, messages: overrides, unstyled, onReveal, className, style, ...attributes } = require_ui.resolveMediaProps(input);
|
|
213
|
+
const messages = (0, react.useMemo)(() => require_ui.resolveMessages(overrides), [overrides]);
|
|
214
|
+
const state = require_ui.getMediaState({
|
|
215
|
+
asset: _asset,
|
|
216
|
+
projectId,
|
|
217
|
+
assetId,
|
|
218
|
+
status,
|
|
219
|
+
contentRemoved,
|
|
220
|
+
type,
|
|
221
|
+
resource,
|
|
222
|
+
lens,
|
|
223
|
+
transform,
|
|
224
|
+
widths,
|
|
225
|
+
url,
|
|
226
|
+
placeholder,
|
|
227
|
+
placeholderHash,
|
|
228
|
+
placeholderUrl: customPlaceholderUrl,
|
|
229
|
+
cdnBaseUrl,
|
|
230
|
+
viewerClaims
|
|
231
|
+
});
|
|
232
|
+
const loadKey = require_ui.getMediaLoadKey(state);
|
|
233
|
+
const [load, setLoad] = (0, react.useState)({
|
|
234
|
+
key: loadKey,
|
|
235
|
+
state: "loading"
|
|
236
|
+
});
|
|
237
|
+
const current = load.key === loadKey ? load : {
|
|
238
|
+
key: loadKey,
|
|
239
|
+
state: "loading"
|
|
240
|
+
};
|
|
241
|
+
const image = (0, react.useRef)(null);
|
|
242
|
+
(0, react.useEffect)(() => {
|
|
243
|
+
if (image.current?.complete && image.current.naturalWidth > 0) setLoad({
|
|
244
|
+
key: loadKey,
|
|
245
|
+
state: "loaded"
|
|
246
|
+
});
|
|
247
|
+
}, [loadKey]);
|
|
248
|
+
const ratio = require_ui.getMediaAspectRatio({
|
|
249
|
+
aspectRatio,
|
|
250
|
+
width,
|
|
251
|
+
height
|
|
252
|
+
});
|
|
253
|
+
const kind = current.state === "error" ? "unavailable" : state.kind;
|
|
254
|
+
const placeholderUrl = state.kind === "audio" || state.kind === "unavailable" ? void 0 : state.placeholderUrl;
|
|
255
|
+
const showPlaceholder = placeholderUrl && (state.kind === "gated" || state.kind === "image" && current.state !== "loaded");
|
|
256
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("figure", {
|
|
257
|
+
...attributes,
|
|
258
|
+
className: joinClassNames("calmlens-media", className),
|
|
259
|
+
"data-kind": state.kind,
|
|
260
|
+
"data-state": current.state,
|
|
261
|
+
"data-sized": ratio ? "" : void 0,
|
|
262
|
+
style: {
|
|
263
|
+
aspectRatio: ratio,
|
|
264
|
+
backgroundColor: averageColor,
|
|
265
|
+
"--calmlens-fit": fit,
|
|
266
|
+
"--calmlens-position": position,
|
|
267
|
+
...style
|
|
268
|
+
},
|
|
269
|
+
children: [
|
|
270
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalmLensStyles, { unstyled }),
|
|
271
|
+
showPlaceholder && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
272
|
+
className: "calmlens-media__placeholder",
|
|
273
|
+
src: placeholderUrl,
|
|
274
|
+
alt: "",
|
|
275
|
+
"aria-hidden": "true"
|
|
276
|
+
}),
|
|
277
|
+
state.kind === "image" && current.state !== "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
278
|
+
ref: image,
|
|
279
|
+
className: "calmlens-media__content",
|
|
280
|
+
src: state.src,
|
|
281
|
+
srcSet: state.srcSet,
|
|
282
|
+
sizes,
|
|
283
|
+
alt,
|
|
284
|
+
width,
|
|
285
|
+
height,
|
|
286
|
+
loading: lazy ? "lazy" : void 0,
|
|
287
|
+
decoding: "async",
|
|
288
|
+
fetchPriority,
|
|
289
|
+
onLoad: () => setLoad({
|
|
290
|
+
key: loadKey,
|
|
291
|
+
state: "loaded"
|
|
292
|
+
}),
|
|
293
|
+
onError: () => setLoad({
|
|
294
|
+
key: loadKey,
|
|
295
|
+
state: "error"
|
|
296
|
+
})
|
|
297
|
+
}, loadKey),
|
|
298
|
+
state.kind === "video" && current.state !== "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("video", {
|
|
299
|
+
className: "calmlens-media__content",
|
|
300
|
+
src: state.src,
|
|
301
|
+
controls,
|
|
302
|
+
playsInline: true,
|
|
303
|
+
preload: "metadata",
|
|
304
|
+
"aria-label": alt || void 0,
|
|
305
|
+
onError: () => setLoad({
|
|
306
|
+
key: loadKey,
|
|
307
|
+
state: "error"
|
|
308
|
+
})
|
|
309
|
+
}),
|
|
310
|
+
state.kind === "audio" && current.state !== "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
|
|
311
|
+
className: "calmlens-media__content",
|
|
312
|
+
src: state.src,
|
|
313
|
+
controls,
|
|
314
|
+
preload: "metadata",
|
|
315
|
+
"aria-label": alt || void 0,
|
|
316
|
+
onError: () => setLoad({
|
|
317
|
+
key: loadKey,
|
|
318
|
+
state: "error"
|
|
319
|
+
})
|
|
320
|
+
}),
|
|
321
|
+
state.kind === "gated" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("figcaption", {
|
|
322
|
+
className: "calmlens-media__notice",
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: messages.sensitiveTitle }),
|
|
325
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: messages.sensitiveBody }),
|
|
326
|
+
onReveal && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
327
|
+
type: "button",
|
|
328
|
+
className: "calmlens-button",
|
|
329
|
+
onClick: onReveal,
|
|
330
|
+
children: messages.reveal
|
|
331
|
+
})
|
|
332
|
+
]
|
|
333
|
+
}),
|
|
334
|
+
kind === "unavailable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("figcaption", {
|
|
335
|
+
className: "calmlens-media__notice",
|
|
336
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "unavailable" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
337
|
+
className: "calmlens-media__label",
|
|
338
|
+
children: require_ui.getMediaUnavailableMessage(state, messages)
|
|
339
|
+
})] })
|
|
340
|
+
})
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
exports.CALMLENS_STYLES = require_ui.CALMLENS_STYLES;
|
|
345
|
+
exports.CALMLENS_THEME = require_ui.CALMLENS_THEME;
|
|
346
|
+
exports.CalmLensMedia = CalmLensMedia;
|
|
347
|
+
exports.CalmLensUploader = CalmLensUploader;
|
|
348
|
+
exports.DEFAULT_MESSAGES = require_ui.DEFAULT_MESSAGES;
|
|
349
|
+
exports.ICONS = require_ui.ICONS;
|
|
350
|
+
exports.ICON_ATTRIBUTES = require_ui.ICON_ATTRIBUTES;
|
|
351
|
+
exports.UploadController = require_UploadController.UploadController;
|
|
352
|
+
exports.createProgressFetch = require_UploadController.createProgressFetch;
|
|
353
|
+
exports.createUploadController = require_BrowserUpload.createUploadController;
|
|
354
|
+
exports.describeUploadItem = require_ui.describeUploadItem;
|
|
355
|
+
exports.describeUploader = require_ui.describeUploader;
|
|
356
|
+
exports.formatBytes = require_ui.formatBytes;
|
|
357
|
+
exports.formatMessage = require_ui.formatMessage;
|
|
358
|
+
exports.getDropzoneHint = require_ui.getDropzoneHint;
|
|
359
|
+
exports.getMediaAspectRatio = require_ui.getMediaAspectRatio;
|
|
360
|
+
exports.getMediaLoadKey = require_ui.getMediaLoadKey;
|
|
361
|
+
exports.getMediaState = require_ui.getMediaState;
|
|
362
|
+
exports.getMediaUnavailableMessage = require_ui.getMediaUnavailableMessage;
|
|
363
|
+
exports.getUploadItemMessage = require_ui.getUploadItemMessage;
|
|
364
|
+
exports.getUploadItemOutcome = require_ui.getUploadItemOutcome;
|
|
365
|
+
exports.isFileAccepted = require_UploadController.isFileAccepted;
|
|
366
|
+
exports.pickMediaSource = require_ui.pickMediaSource;
|
|
367
|
+
exports.resolveMediaProps = require_ui.resolveMediaProps;
|
|
368
|
+
exports.resolveMessages = require_ui.resolveMessages;
|
|
369
|
+
exports.resolveTheme = require_ui.resolveTheme;
|
|
370
|
+
exports.useCalmLensUpload = useCalmLensUpload;
|
package/cjs/server.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { a as selectModerationContextItems, i as ModerationContextItem, n as MODERATION_CONTEXT_USED_CHARACTERS, o as HashList, r as MODERATION_CONTEXT_USED_ITEMS, s as HashListEntry, t as ModerationContext } from "./ModerationContext-9lGm-Mna-CcmbRnOy.js";
|
|
2
|
+
import { $ as IterateAssetsOptions, $t as ExtractedText, A as ClassifyTextOptions, At as WebhookPayloadInput, B as EnsureLensesOptions, Bt as EventSeverity, C as BatchAssetsResponse, Ct as UploadAssetPartOptions, D as CdnResource, Dt as ViewerClaims, E as CdnAssetUrlOptions, Et as VerifyWebhookSignatureOptions, F as CreateMultipartUploadPartOptions, Ft as TypedEvent, G as HashListEntryIdOptions, Gt as Order, H as FolderIdOptions, I as DecideAssetOptions, It as EventCategory, J as HashListPage, Jt as AssetSearchQuery, K as HashListEntryPage, Kt as LensType, L as DeleteAssetContentOptions, Lt as EventFact, M as CreateAssetSignedUrlOptions, Mt as GetEventsResponse, N as CreateFolderOptions, O as CdnServeOptions, Ot as WaitForAssetDecisionOptions, P as CreateHashListOptions, Pt as EventAsset, Q as IterateAssetChildrenOptions, Qt as AssetSafetyHoldReason, R as DeleteAssetOptions, Rt as EventFactValues, S as BatchAssetsOptions, St as UpdateHashListOptions, T as CalmLensServerClientOptions, Tt as UploadedAsset, Ut as Folder, V as ExplainAssetOptions, Vt as EventType, W as GetAssetUrlOptions, Wt as CursorPage, X as ImageTransform, Xt as AssetImage, Y as IdempotencyOptions, Z as ImageTransformOptions, Zt as AssetSafetyHold, _ as AssetSearchResult, _t as SignedUploadToken, a as AssetClassification, b as AssetUploadStatus, bt as UpdateAssetOptions, c as AssetContent, ct as MoveAssetOptions, d as AssetContentStatus, dt as MultipartUploadPartOptions, en as FileMetadata, et as Lens, f as AssetModeration, ft as RequestOptions, g as AssetSearchResponse, gt as SignUploadTokenOptions, h as AssetPage, ht as SearchAssetsOptions, i as AssetChildrenPage, it as ListEventsOptions, j as ConnectionOptions, jt as AssetBatchOperation, k as CdnTransform, kt as WebhookHeadersInput, l as AssetContentOptions, lt as MoveFolderOptions, m as AssetModerationStatus, mt as RetryAssetOptions, n as Asset, nn as ProcessingOptions, nt as ListAssetChildrenOptions, o as AssetClassificationFailureReason, ot as ListHashListEntriesOptions, p as AssetModerationDecision, pt as RetrieveAssetOptions, q as HashListIdOptions, qt as AssetSearchMatchField, r as AssetChecksums, rt as ListAssetsOptions, s as AssetClassificationStatus, st as ListHashListsOptions, t as AddHashListEntryOptions, tn as MetadataItem, tt as LensTransform, u as AssetContentRemovalReason, ut as MultipartUploadOptions, v as AssetType, vt as SignedUrl, w as CalmLensAppClientOptions, wt as UploadPresetSubmitAssetOptions, x as AssetVisibility, xt as UpdateFolderOptions, y as AssetUpload, yt as SubmitAssetOptions, z as EnsureLensOptions, zt as EventFacts } from "./CalmLensTypes-9Vt16pc7.js";
|
|
3
|
+
import { a as CalmLensErrorCode, c as SdkErrorCode, i as CalmLensError, l as ApiErrorCode, o as CalmLensErrorDetails, r as CALMLENS_ERROR_CODES, s as CalmLensErrorOptions, t as ReceivedWebhookEventPayload } from "./WebhookPayload-2aL31v0J.js";
|
|
4
|
+
import { a as ProcessingFeatureId, c as ProcessingFeatures, d as getAssetUrl, i as DetectedPerson, l as SDK_VERSION, n as BoundingBox, o as ProcessingFeatureResults, r as DetectedFace, s as ProcessingFeatureStage, t as AgeRange, u as DEFAULT_CDN_BASE_URL } from "./index-CI4BzN4W.js";
|
|
5
|
+
import { a as ClassificationNotEvaluatedReason, c as ModerationQualifier, i as ClassificationLabel, l as PolicyAction, n as ClassificationCategory, o as ClassificationQualifierResults, r as ClassificationCategoryReport, s as Likelihood, t as ClassificationCategories } from "./Classification-94kSYWZw-CMnQKW13.js";
|
|
6
|
+
import { t as CalmLensServerClient } from "./CalmLensServerClient-JtP687a3.js";
|
|
7
|
+
export declare const WEBHOOK_DELIVERY_HEADER = "x-calmlens-delivery";
|
|
8
|
+
export declare const WEBHOOK_TIMESTAMP_HEADER = "x-calmlens-timestamp";
|
|
9
|
+
export declare const WEBHOOK_SIGNATURE_HEADER = "x-calmlens-signature";
|
|
10
|
+
/** Deliveries whose timestamp is further than this from the receiver's clock are rejected. */
|
|
11
|
+
export declare const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
12
|
+
/**
|
|
13
|
+
* Verifies a webhook delivery: `x-calmlens-signature` must contain a `v1=` HMAC-SHA256 of
|
|
14
|
+
* `"<x-calmlens-timestamp>.<raw body>"`, and the timestamp must be within `toleranceSeconds`
|
|
15
|
+
* (default 300) of now. Returns `false` for anything missing, malformed or stale, and throws
|
|
16
|
+
* `sdk/invalid-argument` when `payload` is not a raw body (for example, parsed JSON).
|
|
17
|
+
*/
|
|
18
|
+
export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Verifies a webhook delivery and parses its body. Throws `sdk/invalid-webhook-signature`
|
|
21
|
+
* when the signature or timestamp does not verify, and `sdk/invalid-webhook-payload` when a
|
|
22
|
+
* verified body is not a webhook event. Unknown event types, fact values and fields remain available.
|
|
23
|
+
*
|
|
24
|
+
* Event types and fact keys added to CalmLens after this SDK version are returned as they are,
|
|
25
|
+
* so keep a default branch when you switch on `type`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<ReceivedWebhookEventPayload>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a webhook event is a test send from the portal or the CLI rather than a real event: it
|
|
30
|
+
* carries the registered `{ key: "test", value: true }` fact.
|
|
31
|
+
*/
|
|
32
|
+
export declare const isTestWebhookEvent: (event: Pick<ReceivedWebhookEventPayload, "facts">) => boolean;
|
|
33
|
+
export { type AddHashListEntryOptions, type AgeRange, type ApiErrorCode, type Asset, type AssetBatchOperation, type AssetChecksums, type AssetChildrenPage, type AssetClassification, type AssetClassificationFailureReason, type AssetClassificationStatus, type AssetContent, type AssetContentOptions, type AssetContentRemovalReason, type AssetContentStatus, type AssetImage, type AssetModeration, type AssetModerationDecision, type AssetModerationStatus, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetType, type AssetUpload, type AssetUploadStatus, type AssetVisibility, type BatchAssetsOptions, type BatchAssetsResponse, type BoundingBox, CALMLENS_ERROR_CODES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, CalmLensServerClient, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnResource, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassifyTextOptions, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateHashListOptions, type CreateMultipartUploadPartOptions, type CursorPage, DEFAULT_CDN_BASE_URL, type DecideAssetOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExplainAssetOptions, type ExtractedText, type FileMetadata, type Folder, type FolderIdOptions, type GetAssetUrlOptions, type HashList, type HashListEntry, type HashListEntryIdOptions, type HashListEntryPage, type HashListIdOptions, type HashListPage, type IdempotencyOptions, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type ListHashListEntriesOptions, type ListHashListsOptions, MODERATION_CONTEXT_USED_CHARACTERS, MODERATION_CONTEXT_USED_ITEMS, type MetadataItem, type ModerationContext, type ModerationContextItem, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type PolicyAction, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UpdateHashListOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type ViewerClaims, type WaitForAssetDecisionOptions, type ReceivedWebhookEventPayload as WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput, getAssetUrl, selectModerationContextItems };
|
package/cjs/server.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_ModerationContextLimits = require("./ModerationContextLimits-nJtd4Tag.js");
|
|
3
|
+
require("./index.js");
|
|
4
|
+
const require_CalmLensServerClient = require("./CalmLensServerClient-C1djppvN.js");
|
|
5
|
+
exports.CALMLENS_ERROR_CODES = require_ModerationContextLimits.CALMLENS_ERROR_CODES;
|
|
6
|
+
exports.CalmLensError = require_ModerationContextLimits.CalmLensError;
|
|
7
|
+
exports.CalmLensServerClient = require_CalmLensServerClient.CalmLensServerClient;
|
|
8
|
+
exports.DEFAULT_CDN_BASE_URL = require_ModerationContextLimits.DEFAULT_CDN_BASE_URL;
|
|
9
|
+
exports.MODERATION_CONTEXT_USED_CHARACTERS = require_ModerationContextLimits.MODERATION_CONTEXT_USED_CHARACTERS;
|
|
10
|
+
exports.MODERATION_CONTEXT_USED_ITEMS = require_ModerationContextLimits.MODERATION_CONTEXT_USED_ITEMS;
|
|
11
|
+
exports.SDK_VERSION = require_ModerationContextLimits.SDK_VERSION;
|
|
12
|
+
exports.WEBHOOK_DELIVERY_HEADER = require_CalmLensServerClient.WEBHOOK_DELIVERY_HEADER;
|
|
13
|
+
exports.WEBHOOK_SIGNATURE_HEADER = require_CalmLensServerClient.WEBHOOK_SIGNATURE_HEADER;
|
|
14
|
+
exports.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = require_CalmLensServerClient.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS;
|
|
15
|
+
exports.WEBHOOK_TIMESTAMP_HEADER = require_CalmLensServerClient.WEBHOOK_TIMESTAMP_HEADER;
|
|
16
|
+
exports.getAssetUrl = require_ModerationContextLimits.getAssetUrl;
|
|
17
|
+
exports.isTestWebhookEvent = require_CalmLensServerClient.isTestWebhookEvent;
|
|
18
|
+
exports.parseWebhookEvent = require_CalmLensServerClient.parseWebhookEvent;
|
|
19
|
+
exports.selectModerationContextItems = require_ModerationContextLimits.selectModerationContextItems;
|
|
20
|
+
exports.verifyWebhookSignature = require_CalmLensServerClient.verifyWebhookSignature;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as detectTestImage, c as getImageTestCategories, i as TestInput, l as paintTestImage, n as TEST_INPUT_KEY_PATTERN, o as detectTestTrigger, r as TEST_INPUT_PRESETS, s as generateTestTextCode, t as ClassificationTestSignal, u as testInputForSignal } from "./TestTriggers-By07LR31-CmK0yTyR.js";
|
|
2
|
+
export { type ClassificationTestSignal, TEST_INPUT_KEY_PATTERN, TEST_INPUT_PRESETS, type TestInput, detectTestImage, detectTestTrigger, generateTestTextCode, getImageTestCategories, paintTestImage, testInputForSignal };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_TestTriggers_DTc_iMJF = require("./TestTriggers-DTc_iMJF-BjMPq4_3.js");
|
|
3
|
+
exports.TEST_INPUT_KEY_PATTERN = require_TestTriggers_DTc_iMJF.TEST_INPUT_KEY_PATTERN;
|
|
4
|
+
exports.TEST_INPUT_PRESETS = require_TestTriggers_DTc_iMJF.TEST_INPUT_PRESETS;
|
|
5
|
+
exports.detectTestImage = require_TestTriggers_DTc_iMJF.detectTestImage;
|
|
6
|
+
exports.detectTestTrigger = require_TestTriggers_DTc_iMJF.detectTestTrigger;
|
|
7
|
+
exports.generateTestTextCode = require_TestTriggers_DTc_iMJF.generateTestTextCode;
|
|
8
|
+
exports.getImageTestCategories = require_TestTriggers_DTc_iMJF.getImageTestCategories;
|
|
9
|
+
exports.paintTestImage = require_TestTriggers_DTc_iMJF.paintTestImage;
|
|
10
|
+
exports.testInputForSignal = require_TestTriggers_DTc_iMJF.testInputForSignal;
|