@calmlens/sdk 0.16.3 → 0.17.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.
Files changed (112) hide show
  1. package/README.md +398 -163
  2. package/cjs/BrowserUpload-DZ0Vbmxi.js +10 -0
  3. package/cjs/BrowserUpload-uZjVFGfP.d.ts +11 -0
  4. package/cjs/CalmLensAppClient-CV_K26Ce.d.ts +40 -0
  5. package/cjs/CalmLensAppClient-DBGmaDlG.js +89 -0
  6. package/cjs/CalmLensConnection-K1TAD1Z-.js +659 -0
  7. package/cjs/CalmLensServerClient-C-pxiz0C.js +645 -0
  8. package/cjs/CalmLensServerClient-JtP687a3.d.ts +235 -0
  9. package/cjs/CalmLensTypes-9Vt16pc7.d.ts +40400 -0
  10. package/cjs/Classification-94kSYWZw-CMnQKW13.d.ts +5873 -0
  11. package/cjs/CryptoUtils-B_x8lMIx-YBW1-bvL.js +42 -0
  12. package/cjs/FileIcons-Ob003MdS.js +175 -0
  13. package/cjs/Jurisdiction-FusEXb4U-zVs21tDv.js +91 -0
  14. package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +67 -0
  15. package/cjs/ModerationContextLimits-Dj1YAl3G.js +1311 -0
  16. package/cjs/ReactUpload-DxtFMr06.js +54 -0
  17. package/cjs/ReactUpload-nZahpmyg.d.ts +17 -0
  18. package/cjs/TestTriggers-By07LR31-CmK0yTyR.d.ts +271 -0
  19. package/cjs/TestTriggers-DcArt0Nu-CvoaONUB.js +1326 -0
  20. package/cjs/UploadController-BBkN4Ni6.js +618 -0
  21. package/{esm/index-C9Xw1aid.d.ts → cjs/WebhookPayload-2aL31v0J.d.ts} +131 -155
  22. package/cjs/app.d.ts +7 -44
  23. package/cjs/app.js +11 -89
  24. package/cjs/elements.d.ts +88 -0
  25. package/cjs/elements.js +555 -0
  26. package/cjs/file-icons.d.ts +67 -0
  27. package/cjs/file-icons.js +10 -0
  28. package/cjs/index-CI4BzN4W.d.ts +252 -0
  29. package/cjs/index.d.ts +6 -4
  30. package/cjs/index.js +9 -4
  31. package/cjs/react-native.d.ts +56 -0
  32. package/cjs/react-native.js +495 -0
  33. package/cjs/react.d.ts +30 -0
  34. package/cjs/react.js +370 -0
  35. package/cjs/server.d.ts +12 -191
  36. package/cjs/server.js +18 -378
  37. package/cjs/test-inputs.d.ts +2 -2
  38. package/cjs/test-inputs.js +9 -264
  39. package/cjs/testing.d.ts +285 -190
  40. package/cjs/testing.js +2393 -1203
  41. package/cjs/ui-CgZpgpNo.d.ts +526 -0
  42. package/cjs/ui-KceuoVCM.js +583 -0
  43. package/cjs/ui.d.ts +2 -0
  44. package/cjs/ui.js +27 -0
  45. package/cjs/vue.d.ts +490 -0
  46. package/cjs/vue.js +419 -0
  47. package/esm/BrowserUpload-D7-zNmc0.js +5 -0
  48. package/esm/BrowserUpload-uZjVFGfP.d.ts +11 -0
  49. package/esm/CalmLensAppClient-CV_K26Ce.d.ts +40 -0
  50. package/esm/CalmLensAppClient-FVMwrHlH.js +84 -0
  51. package/esm/CalmLensConnection-iyNQHA8L.js +582 -0
  52. package/esm/CalmLensServerClient-JtP687a3.d.ts +235 -0
  53. package/esm/CalmLensServerClient-fQEYKLw4.js +586 -0
  54. package/esm/CalmLensTypes-9Vt16pc7.d.ts +40400 -0
  55. package/esm/Classification-94kSYWZw-CMnQKW13.d.ts +5873 -0
  56. package/esm/CryptoUtils-B_x8lMIx-DhuWGzqn.js +25 -0
  57. package/esm/FileIcons-M6dzjFxd.js +128 -0
  58. package/esm/Jurisdiction-FusEXb4U-1ov6m5yE.js +46 -0
  59. package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +67 -0
  60. package/esm/ModerationContextLimits-D1x_WAtP.js +1114 -0
  61. package/esm/ReactUpload-D6yBCkcw.js +37 -0
  62. package/esm/ReactUpload-nZahpmyg.d.ts +17 -0
  63. package/esm/TestTriggers-By07LR31-CmK0yTyR.d.ts +271 -0
  64. package/esm/TestTriggers-DcArt0Nu-s0AQZuWE.js +1266 -0
  65. package/esm/UploadController-txp5NuzH.js +589 -0
  66. package/{cjs/index-C9Xw1aid.d.ts → esm/WebhookPayload-2aL31v0J.d.ts} +131 -155
  67. package/esm/app.d.ts +7 -44
  68. package/esm/app.js +3 -86
  69. package/esm/elements.d.ts +88 -0
  70. package/esm/elements.js +528 -0
  71. package/esm/file-icons.d.ts +67 -0
  72. package/esm/file-icons.js +1 -0
  73. package/esm/index-CI4BzN4W.d.ts +252 -0
  74. package/esm/index.d.ts +6 -4
  75. package/esm/index.js +1 -1
  76. package/esm/react-native.d.ts +56 -0
  77. package/esm/react-native.js +467 -0
  78. package/esm/react.d.ts +30 -0
  79. package/esm/react.js +343 -0
  80. package/esm/server.d.ts +12 -191
  81. package/esm/server.js +3 -369
  82. package/esm/styles.css +147 -0
  83. package/esm/svelte/CalmLensMedia.svelte +134 -0
  84. package/esm/svelte/CalmLensUploader.svelte +175 -0
  85. package/esm/svelte/Icon.svelte +7 -0
  86. package/esm/svelte/index.d.ts +37 -0
  87. package/esm/svelte/index.js +6 -0
  88. package/esm/test-inputs.d.ts +2 -2
  89. package/esm/test-inputs.js +1 -256
  90. package/esm/testing.d.ts +285 -190
  91. package/esm/testing.js +2329 -1122
  92. package/esm/ui-Ca_SpJXf.js +458 -0
  93. package/esm/ui-CgZpgpNo.d.ts +526 -0
  94. package/esm/ui.d.ts +2 -0
  95. package/esm/ui.js +3 -0
  96. package/esm/vue.d.ts +490 -0
  97. package/esm/vue.js +392 -0
  98. package/package.json +110 -11
  99. package/cjs/CalmLensConnection-BNUHp_AQ.js +0 -234
  100. package/cjs/CalmLensUtils-o171ownK.js +0 -699
  101. package/cjs/CalmLensVersion-DwhgxQK5.js +0 -480
  102. package/cjs/CalmLensWebhooks-BKrq30Yp.js +0 -201
  103. package/cjs/Classification-BNhgwGEm-DmA9VEuE.d.ts +0 -4806
  104. package/cjs/TestTriggers-CRKtulyp-vrzEq2wm.d.ts +0 -44
  105. package/cjs/WebhookPayload-CJoIkGBD.d.ts +0 -11753
  106. package/esm/CalmLensConnection-XTqmlwzG.js +0 -193
  107. package/esm/CalmLensUtils-DsF8Aa_x.js +0 -574
  108. package/esm/CalmLensVersion-DcifRKsx.js +0 -415
  109. package/esm/CalmLensWebhooks-BvGyk5d3.js +0 -148
  110. package/esm/Classification-BNhgwGEm-DmA9VEuE.d.ts +0 -4806
  111. package/esm/TestTriggers-CRKtulyp-vrzEq2wm.d.ts +0 -44
  112. package/esm/WebhookPayload-CJoIkGBD.d.ts +0 -11753
@@ -0,0 +1,495 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_ui = require("./ui-KceuoVCM.js");
3
+ const require_UploadController = require("./UploadController-BBkN4Ni6.js");
4
+ const require_FileIcons = require("./FileIcons-Ob003MdS.js");
5
+ const require_ReactUpload = require("./ReactUpload-DxtFMr06.js");
6
+ let react = require("react");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+ let react_native = require("react-native");
9
+ // src/react-native.tsx
10
+ const createUploaderStyles = (theme) => react_native.StyleSheet.create({
11
+ uploader: { gap: 12 },
12
+ picker: {
13
+ alignItems: "center",
14
+ gap: 12,
15
+ paddingVertical: 28,
16
+ paddingHorizontal: 20,
17
+ borderWidth: 1.5,
18
+ borderStyle: "dashed",
19
+ borderColor: theme.border,
20
+ borderRadius: theme.radius,
21
+ backgroundColor: theme.surface
22
+ },
23
+ hint: {
24
+ fontSize: 13,
25
+ color: theme.muted
26
+ },
27
+ button: {
28
+ paddingVertical: 8,
29
+ paddingHorizontal: 14,
30
+ borderRadius: 8,
31
+ borderWidth: 1,
32
+ borderColor: theme.accent,
33
+ backgroundColor: theme.accent
34
+ },
35
+ buttonText: {
36
+ fontSize: 14,
37
+ fontWeight: "500",
38
+ color: theme.accentText
39
+ },
40
+ outlineButton: {
41
+ backgroundColor: "transparent",
42
+ borderColor: theme.border
43
+ },
44
+ outlineButtonText: { color: theme.text },
45
+ smallButton: {
46
+ paddingVertical: 4,
47
+ paddingHorizontal: 10
48
+ },
49
+ disabledButton: {
50
+ backgroundColor: "transparent",
51
+ borderStyle: "dashed",
52
+ borderColor: theme.border
53
+ },
54
+ disabledButtonText: { color: theme.muted },
55
+ uploads: { gap: 8 },
56
+ upload: {
57
+ flexDirection: "row",
58
+ alignItems: "center",
59
+ gap: 12,
60
+ padding: 12,
61
+ borderWidth: 1,
62
+ borderColor: theme.border,
63
+ borderRadius: theme.radius,
64
+ backgroundColor: theme.background
65
+ },
66
+ messageRow: {
67
+ flexDirection: "row",
68
+ alignItems: "center",
69
+ gap: 8
70
+ },
71
+ outcomeDot: {
72
+ width: 8,
73
+ height: 8,
74
+ borderRadius: 4
75
+ },
76
+ accepted: { backgroundColor: theme.success },
77
+ restricted: { backgroundColor: theme.warning },
78
+ rejected: { backgroundColor: theme.danger },
79
+ thumb: {
80
+ width: 40,
81
+ height: 40,
82
+ borderRadius: 8,
83
+ overflow: "hidden"
84
+ },
85
+ fileIcon: {
86
+ alignItems: "center",
87
+ justifyContent: "center",
88
+ borderWidth: 1.5
89
+ },
90
+ fileIconLabel: {
91
+ fontSize: 9,
92
+ fontWeight: "700",
93
+ fontFamily: "monospace"
94
+ },
95
+ body: {
96
+ flex: 1,
97
+ minWidth: 0,
98
+ gap: 4
99
+ },
100
+ name: {
101
+ fontWeight: "500",
102
+ color: theme.text
103
+ },
104
+ size: {
105
+ fontSize: 13,
106
+ color: theme.muted
107
+ },
108
+ message: {
109
+ fontSize: 13,
110
+ color: theme.text
111
+ },
112
+ progress: {
113
+ height: 4,
114
+ borderRadius: 2,
115
+ overflow: "hidden",
116
+ backgroundColor: theme.border
117
+ },
118
+ progressBar: {
119
+ height: "100%",
120
+ borderRadius: 2,
121
+ backgroundColor: theme.accent
122
+ },
123
+ actions: {
124
+ flexDirection: "row",
125
+ alignItems: "center",
126
+ gap: 8
127
+ },
128
+ iconButton: {
129
+ width: 30,
130
+ height: 30,
131
+ alignItems: "center",
132
+ justifyContent: "center",
133
+ borderRadius: 8
134
+ },
135
+ iconButtonText: {
136
+ fontSize: 16,
137
+ color: theme.text
138
+ }
139
+ });
140
+ /** The `testID` of the uploader's pick buttons, for end-to-end tests such as Detox or Maestro. */
141
+ const CHOOSE_TEST_ID = "calmlens-choose";
142
+ const Button = ({ label, onPress, disabled, variant, size, styles, testID }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
143
+ role: "button",
144
+ "aria-label": label,
145
+ testID,
146
+ disabled,
147
+ onPress,
148
+ style: [
149
+ styles.button,
150
+ variant === "outline" && styles.outlineButton,
151
+ size === "small" && styles.smallButton,
152
+ disabled && styles.disabledButton
153
+ ],
154
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
155
+ style: [
156
+ styles.buttonText,
157
+ variant === "outline" && styles.outlineButtonText,
158
+ disabled && styles.disabledButtonText
159
+ ],
160
+ children: label
161
+ })
162
+ });
163
+ /** The file-type tile shown for files without an image preview, in the family's colour. */
164
+ const FileIcon = ({ file, styles }) => {
165
+ const { family, extension } = require_FileIcons.getFileIcon(file);
166
+ const tint = require_FileIcons.FILE_ICON_COLORS[family];
167
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
168
+ "aria-hidden": true,
169
+ style: [
170
+ styles.thumb,
171
+ styles.fileIcon,
172
+ { borderColor: tint }
173
+ ],
174
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
175
+ style: [styles.fileIconLabel, { color: tint }],
176
+ children: require_FileIcons.getFileIconLabel(extension).text
177
+ })
178
+ });
179
+ };
180
+ const UploadRow = ({ item, view, messages, styles, showChooseAnother, disabled, onChooseAnother, onRetry, onRemove }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
181
+ style: styles.upload,
182
+ children: [
183
+ item.previewUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Image, {
184
+ source: { uri: item.previewUrl },
185
+ "aria-hidden": true,
186
+ blurRadius: view.outcome === "rejected" ? 6 : void 0,
187
+ style: styles.thumb
188
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FileIcon, {
189
+ file: item.file,
190
+ styles
191
+ }),
192
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
193
+ style: styles.body,
194
+ children: [
195
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
196
+ style: styles.name,
197
+ numberOfLines: 1,
198
+ children: item.file.name
199
+ }),
200
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
201
+ style: styles.size,
202
+ children: view.size
203
+ }),
204
+ view.busy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
205
+ role: "progressbar",
206
+ "aria-label": view.message,
207
+ "aria-valuemin": 0,
208
+ "aria-valuemax": 100,
209
+ "aria-valuenow": view.progressPercent,
210
+ style: styles.progress,
211
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [styles.progressBar, { width: `${view.progressPercent ?? 100}%` }] })
212
+ }),
213
+ view.message ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
214
+ style: styles.messageRow,
215
+ children: [view.outcome && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
216
+ "aria-hidden": true,
217
+ style: [styles.outcomeDot, styles[view.outcome]]
218
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
219
+ role: "status",
220
+ style: styles.message,
221
+ children: view.message
222
+ })]
223
+ }) : null
224
+ ]
225
+ }),
226
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
227
+ style: styles.actions,
228
+ children: [
229
+ showChooseAnother && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
230
+ label: messages.chooseAnother,
231
+ testID: "calmlens-choose",
232
+ variant: "outline",
233
+ size: "small",
234
+ disabled,
235
+ onPress: onChooseAnother,
236
+ styles
237
+ }),
238
+ view.canRetry && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
239
+ role: "button",
240
+ "aria-label": messages.retry,
241
+ onPress: onRetry,
242
+ style: styles.iconButton,
243
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
244
+ "aria-hidden": true,
245
+ style: styles.iconButtonText,
246
+ children: "↻"
247
+ })
248
+ }),
249
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
250
+ role: "button",
251
+ "aria-label": view.removeLabel,
252
+ onPress: onRemove,
253
+ style: styles.iconButton,
254
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
255
+ "aria-hidden": true,
256
+ style: styles.iconButtonText,
257
+ children: "✕"
258
+ })
259
+ })
260
+ ]
261
+ })
262
+ ]
263
+ });
264
+ /**
265
+ * A pick button and file list that uploads through an upload preset, shows each file's progress
266
+ * and moderation decision, and reports finished uploads to `onUploaded`. `pick` opens your app's
267
+ * picker, such as `expo-image-picker`.
268
+ */
269
+ function CalmLensUploader({ pick, disabled, messages: overrides, controller: external, theme: themeOverrides, style, ...options }) {
270
+ const own = require_ReactUpload.useOwnController(options, !external);
271
+ const upload = require_ReactUpload.useUploadSnapshot(external ?? own);
272
+ const { accept, multiple = false } = upload.controller.options;
273
+ const messages = (0, react.useMemo)(() => require_ui.resolveMessages(overrides), [overrides]);
274
+ const styles = (0, react.useMemo)(() => createUploaderStyles(require_ui.resolveTheme(themeOverrides)), [themeOverrides]);
275
+ const view = require_ui.describeUploader(upload, upload.controller.options, messages);
276
+ const openPicker = async () => {
277
+ if (disabled) return;
278
+ const files = await pick({
279
+ multiple,
280
+ accept
281
+ });
282
+ if (files?.length) upload.addFiles(files);
283
+ };
284
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
285
+ style: [styles.uploader, style],
286
+ children: [view.showDropzone && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
287
+ style: styles.picker,
288
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
289
+ label: view.chooseLabel,
290
+ testID: "calmlens-choose",
291
+ variant: "outline",
292
+ disabled,
293
+ onPress: () => void openPicker(),
294
+ styles
295
+ }), view.hint && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
296
+ style: styles.hint,
297
+ children: view.hint
298
+ })]
299
+ }), upload.items.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
300
+ style: styles.uploads,
301
+ children: upload.items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UploadRow, {
302
+ item,
303
+ view: require_ui.describeUploadItem(item, messages),
304
+ messages,
305
+ styles,
306
+ showChooseAnother: !view.showDropzone,
307
+ disabled,
308
+ onChooseAnother: () => void openPicker(),
309
+ onRetry: () => upload.retry(item.key),
310
+ onRemove: () => upload.remove(item.key)
311
+ }, item.key))
312
+ })]
313
+ });
314
+ }
315
+ const mediaStyles = react_native.StyleSheet.create({
316
+ media: {
317
+ position: "relative",
318
+ overflow: "hidden",
319
+ minHeight: 160
320
+ },
321
+ sized: { minHeight: 0 },
322
+ fill: { ...react_native.StyleSheet.absoluteFill },
323
+ notice: {
324
+ ...react_native.StyleSheet.absoluteFill,
325
+ alignItems: "center",
326
+ justifyContent: "center",
327
+ gap: 6,
328
+ padding: 12,
329
+ backgroundColor: "rgba(0, 0, 0, 0.45)"
330
+ },
331
+ noticeTitle: {
332
+ fontWeight: "600",
333
+ color: "#fff",
334
+ textAlign: "center"
335
+ },
336
+ noticeText: {
337
+ color: "#fff",
338
+ textAlign: "center"
339
+ },
340
+ revealButton: {
341
+ marginTop: 4,
342
+ paddingVertical: 7,
343
+ paddingHorizontal: 14,
344
+ borderRadius: 8,
345
+ backgroundColor: "#fff"
346
+ },
347
+ revealText: {
348
+ fontSize: 14,
349
+ fontWeight: "500",
350
+ color: "#111"
351
+ }
352
+ });
353
+ /**
354
+ * Shows an asset from the CalmLens CDN, at the width in `widths` that covers its measured size,
355
+ * with a blurred placeholder while it loads. Age-restricted assets stay behind the placeholder and
356
+ * a reveal button until `ageConfirmed` is set; blocked and purged assets show an unavailable notice.
357
+ */
358
+ function CalmLensMedia(input) {
359
+ const { asset: _asset, projectId, assetId, status, contentRemoved, type, resource, lens, transform, widths, url, placeholder, placeholderHash, placeholderUrl: customPlaceholderUrl, cdnBaseUrl, viewerClaims, alt = "", aspectRatio, width, height, averageColor, fit = "cover", messages: overrides, theme: themeOverrides, onReveal, renderPlayer, style } = require_ui.resolveMediaProps(input);
360
+ const messages = (0, react.useMemo)(() => require_ui.resolveMessages(overrides), [overrides]);
361
+ const theme = (0, react.useMemo)(() => require_ui.resolveTheme(themeOverrides), [themeOverrides]);
362
+ const state = require_ui.getMediaState({
363
+ asset: _asset,
364
+ projectId,
365
+ assetId,
366
+ status,
367
+ contentRemoved,
368
+ type,
369
+ resource,
370
+ lens,
371
+ transform,
372
+ widths,
373
+ url,
374
+ placeholder,
375
+ placeholderHash,
376
+ placeholderUrl: customPlaceholderUrl,
377
+ cdnBaseUrl,
378
+ viewerClaims
379
+ });
380
+ const [layoutWidth, setLayoutWidth] = (0, react.useState)();
381
+ const src = state.kind === "image" ? require_ui.pickMediaSource(state, layoutWidth) : void 0;
382
+ const loadKey = src ?? require_ui.getMediaLoadKey(state);
383
+ const [load, setLoad] = (0, react.useState)({
384
+ key: loadKey,
385
+ state: "loading"
386
+ });
387
+ const current = load.key === loadKey ? load.state : "loading";
388
+ const ratio = require_ui.getMediaAspectRatio({
389
+ aspectRatio,
390
+ width,
391
+ height
392
+ });
393
+ const unavailable = state.kind === "unavailable" || current === "error";
394
+ const placeholderUrl = state.kind === "audio" || state.kind === "unavailable" ? void 0 : state.placeholderUrl;
395
+ const showPlaceholder = placeholderUrl && !unavailable && (state.kind !== "image" || current !== "loaded") && !(state.kind === "video" && renderPlayer);
396
+ const player = (state.kind === "video" || state.kind === "audio") && !unavailable ? renderPlayer?.({
397
+ kind: state.kind,
398
+ src: state.src,
399
+ alt
400
+ }) : void 0;
401
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
402
+ onLayout: (event) => {
403
+ setLayoutWidth(react_native.PixelRatio.getPixelSizeForLayoutSize(event.nativeEvent.layout.width));
404
+ },
405
+ style: [
406
+ mediaStyles.media,
407
+ ratio !== void 0 && [mediaStyles.sized, { aspectRatio: ratio }],
408
+ { backgroundColor: averageColor ?? theme.surface },
409
+ style
410
+ ],
411
+ children: [
412
+ showPlaceholder && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Image, {
413
+ source: { uri: placeholderUrl },
414
+ "aria-hidden": true,
415
+ blurRadius: 12,
416
+ resizeMode: fit,
417
+ style: mediaStyles.fill
418
+ }),
419
+ src && !unavailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Image, {
420
+ source: { uri: src },
421
+ "aria-label": alt || void 0,
422
+ accessible: Boolean(alt),
423
+ resizeMode: fit,
424
+ onLoad: () => setLoad({
425
+ key: loadKey,
426
+ state: "loaded"
427
+ }),
428
+ onError: () => setLoad({
429
+ key: loadKey,
430
+ state: "error"
431
+ }),
432
+ style: [mediaStyles.fill, { opacity: current === "loaded" ? 1 : 0 }]
433
+ }, loadKey),
434
+ player,
435
+ state.kind === "gated" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
436
+ style: mediaStyles.notice,
437
+ children: [
438
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
439
+ style: mediaStyles.noticeTitle,
440
+ children: messages.sensitiveTitle
441
+ }),
442
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
443
+ style: mediaStyles.noticeText,
444
+ children: messages.sensitiveBody
445
+ }),
446
+ onReveal && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
447
+ role: "button",
448
+ "aria-label": messages.reveal,
449
+ onPress: onReveal,
450
+ style: mediaStyles.revealButton,
451
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
452
+ style: mediaStyles.revealText,
453
+ children: messages.reveal
454
+ })
455
+ })
456
+ ]
457
+ }),
458
+ unavailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
459
+ style: [mediaStyles.notice, { backgroundColor: theme.surface }],
460
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
461
+ style: { color: theme.text },
462
+ children: require_ui.getMediaUnavailableMessage(state, messages)
463
+ })
464
+ })
465
+ ]
466
+ });
467
+ }
468
+ exports.CALMLENS_STYLES = require_ui.CALMLENS_STYLES;
469
+ exports.CALMLENS_THEME = require_ui.CALMLENS_THEME;
470
+ exports.CHOOSE_TEST_ID = CHOOSE_TEST_ID;
471
+ exports.CalmLensMedia = CalmLensMedia;
472
+ exports.CalmLensUploader = CalmLensUploader;
473
+ exports.DEFAULT_MESSAGES = require_ui.DEFAULT_MESSAGES;
474
+ exports.ICONS = require_ui.ICONS;
475
+ exports.ICON_ATTRIBUTES = require_ui.ICON_ATTRIBUTES;
476
+ exports.UploadController = require_UploadController.UploadController;
477
+ exports.createProgressFetch = require_UploadController.createProgressFetch;
478
+ exports.createUploadController = require_UploadController.createUploadController;
479
+ exports.describeUploadItem = require_ui.describeUploadItem;
480
+ exports.describeUploader = require_ui.describeUploader;
481
+ exports.formatBytes = require_ui.formatBytes;
482
+ exports.formatMessage = require_ui.formatMessage;
483
+ exports.getDropzoneHint = require_ui.getDropzoneHint;
484
+ exports.getMediaAspectRatio = require_ui.getMediaAspectRatio;
485
+ exports.getMediaLoadKey = require_ui.getMediaLoadKey;
486
+ exports.getMediaState = require_ui.getMediaState;
487
+ exports.getMediaUnavailableMessage = require_ui.getMediaUnavailableMessage;
488
+ exports.getUploadItemMessage = require_ui.getUploadItemMessage;
489
+ exports.getUploadItemOutcome = require_ui.getUploadItemOutcome;
490
+ exports.isFileAccepted = require_UploadController.isFileAccepted;
491
+ exports.pickMediaSource = require_ui.pickMediaSource;
492
+ exports.resolveMediaProps = require_ui.resolveMediaProps;
493
+ exports.resolveMessages = require_ui.resolveMessages;
494
+ exports.resolveTheme = require_ui.resolveTheme;
495
+ exports.useCalmLensUpload = require_ReactUpload.useCalmLensUpload;
package/cjs/react.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { A as CustomUploadResult, B as MediaAsset, C as getDropzoneHint, D as resolveMessages, E as getUploadItemOutcome, G as MediaState, H as MediaOptions, J as resolveMediaProps, K as getMediaState, L as UploadStage, M as UploadController, P as UploadFile, S as formatMessage, T as getUploadItemMessage, U as MediaSettings, V as MediaImageSource, W as MediaSource, _ as UploadItemView, a as createProgressFetch, b as describeUploader, c as IconName, d as UploaderDisplayOptions, g as DEFAULT_MESSAGES, h as CalmLensMessages, i as CALMLENS_STYLES, j as UploadClient, k as CustomUploadContext, l as MediaDisplayOptions, m as getMediaLoadKey, n as CalmLensTheme, o as ICONS, p as getMediaAspectRatio, q as pickMediaSource, r as resolveTheme, s as ICON_ATTRIBUTES, t as CALMLENS_THEME, u as MediaProps, v as UploaderView, w as getMediaUnavailableMessage, x as formatBytes, y as describeUploadItem, z as isFileAccepted } from "./ui-CgZpgpNo.js";
2
+ import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, o as UseCalmLensUploadResult, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-uZjVFGfP.js";
3
+ import { CSSProperties, HTMLAttributes } from "react";
4
+ /**
5
+ * Uploads files through an upload preset and re-renders as each one uploads and is checked. Use
6
+ * it to build your own upload UI; `CalmLensUploader` is built on it. Uploads still running when
7
+ * the component unmounts are cancelled.
8
+ */
9
+ export declare const useCalmLensUpload: <F extends UploadFile = File>(options: UploadControllerOptions<F>) => UseCalmLensUploadResult<F>;
10
+ /** Leaves out the stylesheet the components render, so you can style the `calmlens-*` classes. */
11
+ type StyleOptions = {
12
+ unstyled?: boolean;
13
+ };
14
+ export type CalmLensUploaderProps = UploaderProps & StyleOptions & {
15
+ className?: string;
16
+ style?: CSSProperties;
17
+ };
18
+ /**
19
+ * A drop zone and file list that uploads through an upload preset, shows each file's progress
20
+ * and moderation decision, and reports finished uploads to `onUploaded`.
21
+ */
22
+ export declare function CalmLensUploader({ disabled, capture, messages: overrides, unstyled, controller: external, className, style, ...options }: CalmLensUploaderProps): import("react").JSX.Element;
23
+ export type CalmLensMediaProps = MediaProps & StyleOptions & Omit<HTMLAttributes<HTMLElement>, "children" | "placeholder">;
24
+ /**
25
+ * Shows an asset from the CalmLens CDN with responsive widths and a blurred placeholder while
26
+ * it loads. Age-restricted assets stay behind the placeholder and a reveal button until
27
+ * `ageConfirmed` is set; blocked and purged assets show an unavailable notice.
28
+ */
29
+ export declare function CalmLensMedia(input: CalmLensMediaProps): import("react").JSX.Element;
30
+ export { CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, ICONS, ICON_ATTRIBUTES, type IconName, type MediaAsset, type MediaDisplayOptions, type MediaImageSource, type MediaOptions, type MediaProps, type MediaSettings, type MediaSource, type MediaState, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, type UseCalmLensUploadResult, createProgressFetch, createUploadController, describeUploadItem, describeUploader, formatBytes, formatMessage, getDropzoneHint, getMediaAspectRatio, getMediaLoadKey, getMediaState, getMediaUnavailableMessage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, pickMediaSource, resolveMediaProps, resolveMessages, resolveTheme };