calmlens 0.20.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 +1329 -664
- package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-CeSwiMo5.js} +1 -1
- package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
- package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-CYY6elxg.js} +183 -347
- package/cjs/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
- package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-nfu6_YEW.js} +288 -88
- package/cjs/{CalmLensTypes-COJbOuiv.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-2nIv7Zh3.js → ModerationContextLimits-BxOmeSqq.js} +669 -269
- package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-BK2O3dnK.js} +1 -1
- package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +342 -34
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{UploadController-MLVs97Zt.js → UploadController-DLyiLDTB.js} +34 -14
- package/cjs/{WebhookPayload-DkukERKE.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 +24 -14
- package/cjs/testing.js +1413 -402
- 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/esm/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-i9OhCzMJ.js} +1 -1
- package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
- package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BGZlIsT2.js} +182 -340
- package/esm/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
- package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-dAQUcDWb.js} +265 -89
- package/esm/{CalmLensTypes-COJbOuiv.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-Chw-AzgL.js → ModerationContextLimits-B6_RalCQ.js} +624 -254
- package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-DxwVqfX1.js} +1 -1
- package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +319 -35
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{UploadController-BJZghJpg.js → UploadController-D9Z-h00Q.js} +34 -14
- package/esm/{WebhookPayload-DkukERKE.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 +24 -14
- package/esm/testing.js +1409 -398
- 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-DxbJ_Xaa.d.ts +0 -253
- package/cjs/ui-BSqPGKrZ.d.ts +0 -539
- package/cjs/ui-CX1z2pD9.js +0 -586
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/esm/index-DxbJ_Xaa.d.ts +0 -253
- package/esm/svelte/CalmLensMedia.svelte +0 -134
- package/esm/ui-BSqPGKrZ.d.ts +0 -539
- package/esm/ui-CXH7xJpb.js +0 -461
package/cjs/react-native.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_UploadController = require("./UploadController-
|
|
2
|
+
const require_ModerationContextLimits = require("./ModerationContextLimits-BxOmeSqq.js");
|
|
3
|
+
const require_UploadController = require("./UploadController-DLyiLDTB.js");
|
|
4
|
+
const require_Core = require("./Core-Dc3cteU7.js");
|
|
4
5
|
const require_FileIcons = require("./FileIcons-Ob003MdS.js");
|
|
5
|
-
const require_ReactUpload = require("./ReactUpload-
|
|
6
|
+
const require_ReactUpload = require("./ReactUpload-BK2O3dnK.js");
|
|
6
7
|
let react = require("react");
|
|
7
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
9
|
let react_native = require("react-native");
|
|
@@ -270,9 +271,9 @@ function CalmLensUploader({ pick, disabled, messages: overrides, controller: ext
|
|
|
270
271
|
const own = require_ReactUpload.useOwnController(options, !external);
|
|
271
272
|
const upload = require_ReactUpload.useUploadSnapshot(external ?? own);
|
|
272
273
|
const { accept, multiple = false } = upload.controller.options;
|
|
273
|
-
const messages = (0, react.useMemo)(() =>
|
|
274
|
-
const styles = (0, react.useMemo)(() => createUploaderStyles(
|
|
275
|
-
const view =
|
|
274
|
+
const messages = (0, react.useMemo)(() => require_Core.resolveMessages(overrides), [overrides]);
|
|
275
|
+
const styles = (0, react.useMemo)(() => createUploaderStyles(require_Core.resolveTheme(themeOverrides)), [themeOverrides]);
|
|
276
|
+
const view = require_Core.describeUploader(upload, upload.controller.options, messages);
|
|
276
277
|
const openPicker = async () => {
|
|
277
278
|
if (disabled) return;
|
|
278
279
|
const files = await pick({
|
|
@@ -300,7 +301,7 @@ function CalmLensUploader({ pick, disabled, messages: overrides, controller: ext
|
|
|
300
301
|
style: styles.uploads,
|
|
301
302
|
children: upload.items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UploadRow, {
|
|
302
303
|
item,
|
|
303
|
-
view:
|
|
304
|
+
view: require_Core.describeUploadItem(item, messages),
|
|
304
305
|
messages,
|
|
305
306
|
styles,
|
|
306
307
|
showChooseAnother: !view.showDropzone,
|
|
@@ -312,8 +313,8 @@ function CalmLensUploader({ pick, disabled, messages: overrides, controller: ext
|
|
|
312
313
|
})]
|
|
313
314
|
});
|
|
314
315
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
316
|
+
const assetStyles = react_native.StyleSheet.create({
|
|
317
|
+
asset: {
|
|
317
318
|
position: "relative",
|
|
318
319
|
overflow: "hidden",
|
|
319
320
|
minHeight: 160
|
|
@@ -348,148 +349,279 @@ const mediaStyles = react_native.StyleSheet.create({
|
|
|
348
349
|
fontSize: 14,
|
|
349
350
|
fontWeight: "500",
|
|
350
351
|
color: "#111"
|
|
352
|
+
},
|
|
353
|
+
open: {
|
|
354
|
+
...react_native.StyleSheet.absoluteFill,
|
|
355
|
+
alignItems: "center",
|
|
356
|
+
justifyContent: "center"
|
|
357
|
+
},
|
|
358
|
+
file: {
|
|
359
|
+
...react_native.StyleSheet.absoluteFill,
|
|
360
|
+
alignItems: "center",
|
|
361
|
+
justifyContent: "center"
|
|
362
|
+
},
|
|
363
|
+
fileIcon: {
|
|
364
|
+
width: 48,
|
|
365
|
+
height: 60,
|
|
366
|
+
alignItems: "center",
|
|
367
|
+
justifyContent: "flex-end",
|
|
368
|
+
paddingBottom: 8,
|
|
369
|
+
borderWidth: 1.5,
|
|
370
|
+
borderRadius: 6
|
|
371
|
+
},
|
|
372
|
+
fileIconLabel: {
|
|
373
|
+
fontSize: 11,
|
|
374
|
+
fontWeight: "700",
|
|
375
|
+
fontFamily: "monospace"
|
|
351
376
|
}
|
|
352
377
|
});
|
|
353
378
|
/**
|
|
354
|
-
* Shows an asset from
|
|
355
|
-
*
|
|
356
|
-
*
|
|
379
|
+
* Shows an asset from its asset URL (public, or signed by your server) with React Native's own
|
|
380
|
+
* views: images at the width in `image.widths` that covers their measured size, over a blurred
|
|
381
|
+
* placeholder; video and audio in `renderPlayer`'s player; and for documents, text, spreadsheets
|
|
382
|
+
* and websites, their preview still with a button that opens them. It reads `{src}/info` once
|
|
383
|
+
* mounted, unless `info` is given. Age-restricted content stays behind its placeholder and a
|
|
384
|
+
* reveal button; content the CDN refuses shows the unavailable notice.
|
|
357
385
|
*/
|
|
358
|
-
function
|
|
359
|
-
const {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
placeholderHash,
|
|
376
|
-
placeholderUrl: customPlaceholderUrl,
|
|
377
|
-
cdnBaseUrl,
|
|
378
|
-
viewerClaims
|
|
379
|
-
});
|
|
386
|
+
function CalmLensAsset(props) {
|
|
387
|
+
const { src, display, viewerClaims, info, image, video, onExpired, alt = "", fit = "contain", aspectRatio, messages: overrides, theme: themeOverrides, onLoad, onError, onAvailabilityChange, onAgeConfirmRequest, onPlay, onEnded, onTimeUpdate, renderPlayer, renderUnavailable, renderAgeGate, style } = props;
|
|
388
|
+
const options = {
|
|
389
|
+
src,
|
|
390
|
+
display,
|
|
391
|
+
viewerClaims,
|
|
392
|
+
info,
|
|
393
|
+
image,
|
|
394
|
+
video,
|
|
395
|
+
onExpired
|
|
396
|
+
};
|
|
397
|
+
const messages = (0, react.useMemo)(() => require_Core.resolveMessages(overrides), [overrides]);
|
|
398
|
+
const theme = (0, react.useMemo)(() => require_Core.resolveTheme(themeOverrides), [themeOverrides]);
|
|
399
|
+
const [, setVersion] = (0, react.useState)(0);
|
|
400
|
+
const [session] = (0, react.useState)(() => new require_Core.AssetSession(() => setVersion((count) => count + 1)));
|
|
401
|
+
const state = session.update(options);
|
|
402
|
+
const view = require_Core.getAssetView(options, state);
|
|
380
403
|
const [layoutWidth, setLayoutWidth] = (0, react.useState)();
|
|
381
|
-
const
|
|
382
|
-
|
|
404
|
+
const callbacks = (0, react.useRef)({
|
|
405
|
+
onLoad,
|
|
406
|
+
onError,
|
|
407
|
+
onAvailabilityChange
|
|
408
|
+
});
|
|
409
|
+
callbacks.current = {
|
|
410
|
+
onLoad,
|
|
411
|
+
onError,
|
|
412
|
+
onAvailabilityChange
|
|
413
|
+
};
|
|
414
|
+
(0, react.useEffect)(() => session.load());
|
|
415
|
+
const base = state.src?.split("?", 1)[0];
|
|
416
|
+
const previewUrl = base && state.info?.content?.preview ? require_ModerationContextLimits.appendAssetLocation(base, {
|
|
417
|
+
resource: "preview",
|
|
418
|
+
viewerClaims
|
|
419
|
+
}) : void 0;
|
|
420
|
+
const playable = view.kind === "video" || view.kind === "audio";
|
|
421
|
+
const shownImage = view.kind === "image" || view.kind === "website" ? require_Core.pickAssetSource(view, layoutWidth) : void 0;
|
|
422
|
+
const still = view.kind === "video" && !renderPlayer ? view.poster : view.kind === "audio" && !renderPlayer ? view.waveformUrl : view.kind === "document" ? view.still : view.kind === "text" || view.kind === "spreadsheet" ? previewUrl : void 0;
|
|
423
|
+
const shown = shownImage ?? still;
|
|
424
|
+
const opens = view.kind === "document" ? view.src : view.kind === "website" ? view.link : (view.kind === "text" || view.kind === "spreadsheet") && base ? require_ModerationContextLimits.appendAssetLocation(base, {
|
|
425
|
+
resource: "original",
|
|
426
|
+
viewerClaims
|
|
427
|
+
}) : playable && !renderPlayer ? view.src : void 0;
|
|
428
|
+
const openLabel = playable ? messages.play : messages.open;
|
|
429
|
+
const loadKey = shown ?? require_Core.getAssetViewKey(view);
|
|
383
430
|
const [load, setLoad] = (0, react.useState)({
|
|
384
431
|
key: loadKey,
|
|
385
432
|
state: "loading"
|
|
386
433
|
});
|
|
387
434
|
const current = load.key === loadKey ? load.state : "loading";
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
435
|
+
const [resumeFrom, setResumeFrom] = (0, react.useState)();
|
|
436
|
+
const [failedStream, setFailedStream] = (0, react.useState)();
|
|
437
|
+
(0, react.useEffect)(() => {
|
|
438
|
+
if (current === "loaded") callbacks.current.onLoad?.();
|
|
439
|
+
if (current === "error") callbacks.current.onError?.();
|
|
440
|
+
}, [current]);
|
|
441
|
+
const availability = view.kind === "unavailable" ? "unavailable" : view.kind === "age-restricted" ? "age-restricted" : view.kind === "pending" ? void 0 : "available";
|
|
442
|
+
(0, react.useEffect)(() => {
|
|
443
|
+
if (availability) callbacks.current.onAvailabilityChange?.(availability);
|
|
444
|
+
}, [availability]);
|
|
445
|
+
const ratio = require_Core.getAssetAspectRatio(view, state.info, aspectRatio);
|
|
446
|
+
const placeholderUrl = "placeholderUrl" in view && (view.kind !== "image" || current !== "loaded") ? view.placeholderUrl : void 0;
|
|
447
|
+
const streaming = playable && Boolean(view.stream) && view.stream !== failedStream;
|
|
448
|
+
const player = playable && renderPlayer ? renderPlayer({
|
|
449
|
+
kind: view.kind,
|
|
450
|
+
src: streaming && view.stream ? view.stream : view.src,
|
|
451
|
+
streaming,
|
|
452
|
+
poster: view.kind === "video" ? view.poster : view.waveformUrl,
|
|
453
|
+
peaks: view.kind === "audio" ? view.peaks : void 0,
|
|
454
|
+
alt,
|
|
455
|
+
autoPlay: video?.autoPlay,
|
|
456
|
+
muted: video?.muted,
|
|
457
|
+
loop: video?.loop,
|
|
458
|
+
controls: video?.controls ?? true,
|
|
459
|
+
resumeFrom,
|
|
460
|
+
onError: (playback) => {
|
|
461
|
+
const from = playback ?? {
|
|
462
|
+
position: 0,
|
|
463
|
+
playing: false
|
|
464
|
+
};
|
|
465
|
+
setResumeFrom(from);
|
|
466
|
+
if (streaming) setFailedStream(view.stream);
|
|
467
|
+
else session.mediaFailed(from);
|
|
468
|
+
},
|
|
469
|
+
onLoad: () => {
|
|
470
|
+
session.loaded();
|
|
471
|
+
setLoad({
|
|
472
|
+
key: loadKey,
|
|
473
|
+
state: "loaded"
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
onPlay,
|
|
477
|
+
onEnded,
|
|
478
|
+
onTimeUpdate
|
|
400
479
|
}) : void 0;
|
|
401
480
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
402
481
|
onLayout: (event) => {
|
|
403
482
|
setLayoutWidth(react_native.PixelRatio.getPixelSizeForLayoutSize(event.nativeEvent.layout.width));
|
|
404
483
|
},
|
|
484
|
+
"aria-busy": view.kind === "pending" ? true : void 0,
|
|
405
485
|
style: [
|
|
406
|
-
|
|
407
|
-
ratio !== void 0 && [
|
|
408
|
-
{ backgroundColor: averageColor ?? theme.surface },
|
|
486
|
+
assetStyles.asset,
|
|
487
|
+
ratio !== void 0 && [assetStyles.sized, { aspectRatio: ratio }],
|
|
488
|
+
{ backgroundColor: state.info?.content?.preview?.averageColor ?? theme.surface },
|
|
409
489
|
style
|
|
410
490
|
],
|
|
411
491
|
children: [
|
|
412
|
-
|
|
492
|
+
placeholderUrl && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Image, {
|
|
413
493
|
source: { uri: placeholderUrl },
|
|
414
494
|
"aria-hidden": true,
|
|
415
495
|
blurRadius: 12,
|
|
416
496
|
resizeMode: fit,
|
|
417
|
-
style:
|
|
497
|
+
style: assetStyles.fill
|
|
418
498
|
}),
|
|
419
|
-
|
|
420
|
-
source: { uri:
|
|
499
|
+
shown && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Image, {
|
|
500
|
+
source: { uri: shown },
|
|
421
501
|
"aria-label": alt || void 0,
|
|
422
502
|
accessible: Boolean(alt),
|
|
423
|
-
resizeMode: fit,
|
|
424
|
-
onLoad: () =>
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
503
|
+
resizeMode: view.kind === "audio" ? "stretch" : fit,
|
|
504
|
+
onLoad: () => {
|
|
505
|
+
session.loaded();
|
|
506
|
+
setLoad({
|
|
507
|
+
key: loadKey,
|
|
508
|
+
state: "loaded"
|
|
509
|
+
});
|
|
510
|
+
},
|
|
511
|
+
onError: () => {
|
|
512
|
+
if (shownImage) session.failed();
|
|
513
|
+
else setLoad({
|
|
514
|
+
key: loadKey,
|
|
515
|
+
state: "error"
|
|
516
|
+
});
|
|
517
|
+
},
|
|
518
|
+
style: [assetStyles.fill, { opacity: current === "loaded" ? 1 : 0 }]
|
|
433
519
|
}, loadKey),
|
|
434
520
|
player,
|
|
435
|
-
|
|
436
|
-
style:
|
|
521
|
+
view.kind === "file" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
522
|
+
style: assetStyles.file,
|
|
523
|
+
"aria-label": alt || void 0,
|
|
524
|
+
role: alt ? "img" : void 0,
|
|
525
|
+
accessible: Boolean(alt),
|
|
526
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
527
|
+
"aria-hidden": true,
|
|
528
|
+
style: [assetStyles.fileIcon, { borderColor: require_FileIcons.FILE_ICON_COLORS[view.icon] }],
|
|
529
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
530
|
+
style: [assetStyles.fileIconLabel, { color: require_FileIcons.FILE_ICON_COLORS[view.icon] }],
|
|
531
|
+
children: require_FileIcons.getFileIconLabel("").text
|
|
532
|
+
})
|
|
533
|
+
})
|
|
534
|
+
}),
|
|
535
|
+
opens && view.kind !== "website" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
536
|
+
style: assetStyles.open,
|
|
537
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
538
|
+
role: "link",
|
|
539
|
+
"aria-label": openLabel,
|
|
540
|
+
onPress: () => void react_native.Linking.openURL(opens),
|
|
541
|
+
style: assetStyles.revealButton,
|
|
542
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
543
|
+
style: assetStyles.revealText,
|
|
544
|
+
children: openLabel
|
|
545
|
+
})
|
|
546
|
+
})
|
|
547
|
+
}),
|
|
548
|
+
view.kind === "website" && opens && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
549
|
+
role: "link",
|
|
550
|
+
"aria-label": require_Core.formatMessage(messages.openWebsite, { host: new URL(opens).host }),
|
|
551
|
+
onPress: () => void react_native.Linking.openURL(opens),
|
|
552
|
+
style: [assetStyles.revealButton, {
|
|
553
|
+
position: "absolute",
|
|
554
|
+
top: 8,
|
|
555
|
+
left: 8
|
|
556
|
+
}],
|
|
557
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
558
|
+
style: assetStyles.revealText,
|
|
559
|
+
children: require_Core.formatMessage(messages.openWebsite, { host: new URL(opens).host })
|
|
560
|
+
})
|
|
561
|
+
}),
|
|
562
|
+
view.kind === "age-restricted" && (renderAgeGate ? renderAgeGate({
|
|
563
|
+
placeholderUrl: view.placeholderUrl,
|
|
564
|
+
confirm: onAgeConfirmRequest
|
|
565
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
566
|
+
style: assetStyles.notice,
|
|
437
567
|
children: [
|
|
438
568
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
439
|
-
style:
|
|
569
|
+
style: assetStyles.noticeTitle,
|
|
440
570
|
children: messages.sensitiveTitle
|
|
441
571
|
}),
|
|
442
572
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
443
|
-
style:
|
|
573
|
+
style: assetStyles.noticeText,
|
|
444
574
|
children: messages.sensitiveBody
|
|
445
575
|
}),
|
|
446
|
-
|
|
576
|
+
onAgeConfirmRequest && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
447
577
|
role: "button",
|
|
448
578
|
"aria-label": messages.reveal,
|
|
449
|
-
onPress:
|
|
450
|
-
style:
|
|
579
|
+
onPress: onAgeConfirmRequest,
|
|
580
|
+
style: assetStyles.revealButton,
|
|
451
581
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
452
|
-
style:
|
|
582
|
+
style: assetStyles.revealText,
|
|
453
583
|
children: messages.reveal
|
|
454
584
|
})
|
|
455
585
|
})
|
|
456
586
|
]
|
|
457
|
-
}),
|
|
458
|
-
unavailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
459
|
-
style: [
|
|
587
|
+
})),
|
|
588
|
+
(view.kind === "unavailable" || current === "error") && (renderUnavailable ? renderUnavailable() : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
589
|
+
style: [assetStyles.notice, { backgroundColor: theme.surface }],
|
|
460
590
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
461
591
|
style: { color: theme.text },
|
|
462
|
-
children:
|
|
592
|
+
children: messages.unavailable
|
|
463
593
|
})
|
|
464
|
-
})
|
|
594
|
+
}))
|
|
465
595
|
]
|
|
466
596
|
});
|
|
467
597
|
}
|
|
468
|
-
exports.
|
|
469
|
-
exports.
|
|
598
|
+
exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
|
|
599
|
+
exports.AssetSession = require_Core.AssetSession;
|
|
600
|
+
exports.CALMLENS_STYLES = require_Core.CALMLENS_STYLES;
|
|
601
|
+
exports.CALMLENS_THEME = require_Core.CALMLENS_THEME;
|
|
470
602
|
exports.CHOOSE_TEST_ID = CHOOSE_TEST_ID;
|
|
471
|
-
exports.
|
|
603
|
+
exports.CalmLensAsset = CalmLensAsset;
|
|
472
604
|
exports.CalmLensUploader = CalmLensUploader;
|
|
473
|
-
exports.DEFAULT_MESSAGES =
|
|
474
|
-
exports.ICONS =
|
|
475
|
-
exports.ICON_ATTRIBUTES =
|
|
605
|
+
exports.DEFAULT_MESSAGES = require_Core.DEFAULT_MESSAGES;
|
|
606
|
+
exports.ICONS = require_Core.ICONS;
|
|
607
|
+
exports.ICON_ATTRIBUTES = require_Core.ICON_ATTRIBUTES;
|
|
476
608
|
exports.UploadController = require_UploadController.UploadController;
|
|
477
609
|
exports.createProgressFetch = require_UploadController.createProgressFetch;
|
|
478
610
|
exports.createUploadController = require_UploadController.createUploadController;
|
|
479
|
-
exports.describeUploadItem =
|
|
480
|
-
exports.describeUploader =
|
|
481
|
-
exports.formatBytes =
|
|
482
|
-
exports.formatMessage =
|
|
483
|
-
exports.
|
|
484
|
-
exports.
|
|
485
|
-
exports.
|
|
486
|
-
exports.
|
|
487
|
-
exports.
|
|
488
|
-
exports.
|
|
489
|
-
exports.
|
|
611
|
+
exports.describeUploadItem = require_Core.describeUploadItem;
|
|
612
|
+
exports.describeUploader = require_Core.describeUploader;
|
|
613
|
+
exports.formatBytes = require_Core.formatBytes;
|
|
614
|
+
exports.formatMessage = require_Core.formatMessage;
|
|
615
|
+
exports.getAssetAspectRatio = require_Core.getAssetAspectRatio;
|
|
616
|
+
exports.getAssetView = require_Core.getAssetView;
|
|
617
|
+
exports.getAssetViewKey = require_Core.getAssetViewKey;
|
|
618
|
+
exports.getDropzoneHint = require_Core.getDropzoneHint;
|
|
619
|
+
exports.getPeakHeights = require_Core.getPeakHeights;
|
|
620
|
+
exports.getPlayedPercent = require_Core.getPlayedPercent;
|
|
621
|
+
exports.getUploadItemMessage = require_Core.getUploadItemMessage;
|
|
622
|
+
exports.getUploadItemOutcome = require_Core.getUploadItemOutcome;
|
|
490
623
|
exports.isFileAccepted = require_UploadController.isFileAccepted;
|
|
491
|
-
exports.
|
|
492
|
-
exports.
|
|
493
|
-
exports.
|
|
494
|
-
exports.resolveTheme = require_ui.resolveTheme;
|
|
624
|
+
exports.pickAssetSource = require_Core.pickAssetSource;
|
|
625
|
+
exports.resolveMessages = require_Core.resolveMessages;
|
|
626
|
+
exports.resolveTheme = require_Core.resolveTheme;
|
|
495
627
|
exports.useCalmLensUpload = require_ReactUpload.useCalmLensUpload;
|
package/cjs/react.d.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
import { A as
|
|
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-
|
|
3
|
-
import {
|
|
1
|
+
import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, G as AssetSession, H as AssetImageOptions, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, P as UploadFile, Q as getAssetView, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-C82YmjjX.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-D-NnAN7g.js";
|
|
3
|
+
import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-CTBUxnVp.js";
|
|
4
|
+
import { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
5
|
+
type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
6
|
+
/** Leaves out the stylesheet the viewers render, so you can style the `calmlens-*` classes. */
|
|
7
|
+
unstyled?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
export type CalmLensImageViewerProps = ImageViewerOptions & ElementProps;
|
|
12
|
+
export type CalmLensWebsiteViewerProps = WebsiteViewerOptions & ElementProps;
|
|
13
|
+
export type CalmLensTextViewerProps = TextViewerOptions & ElementProps;
|
|
14
|
+
export type CalmLensDocumentViewerProps = DocumentViewerOptions & ElementProps;
|
|
15
|
+
export type CalmLensSpreadsheetViewerProps = SpreadsheetViewerOptions & ElementProps;
|
|
16
|
+
/** Shows an image asset's rendered file, fitted to the element, over its placeholder. */
|
|
17
|
+
export declare function CalmLensImageViewer(props: CalmLensImageViewerProps): import("react").JSX.Element;
|
|
18
|
+
/** Shows a website asset's screenshot with a link to the original page. */
|
|
19
|
+
export declare function CalmLensWebsiteViewer(props: CalmLensWebsiteViewerProps): import("react").JSX.Element;
|
|
20
|
+
/** Shows a text asset's text, escaped, in a scrolling region. */
|
|
21
|
+
export declare function CalmLensTextViewer(props: CalmLensTextViewerProps): import("react").JSX.Element;
|
|
22
|
+
/** Shows a PDF, or a document rendered as one, a page at a time with pdf.js (loaded lazily). */
|
|
23
|
+
export declare function CalmLensDocumentViewer(props: CalmLensDocumentViewerProps): import("react").JSX.Element;
|
|
24
|
+
/** Shows a spreadsheet's sheets as tabs and paged tables, from its extracted text. */
|
|
25
|
+
export declare function CalmLensSpreadsheetViewer(props: CalmLensSpreadsheetViewerProps): import("react").JSX.Element;
|
|
4
26
|
/**
|
|
5
27
|
* Uploads files through an upload preset and re-renders as each one uploads and is checked. Use
|
|
6
28
|
* it to build your own upload UI; `CalmLensUploader` is built on it. Uploads still running when
|
|
@@ -20,11 +42,22 @@ export type CalmLensUploaderProps = UploaderProps & StyleOptions & {
|
|
|
20
42
|
* and moderation decision, and reports finished uploads to `onUploaded`.
|
|
21
43
|
*/
|
|
22
44
|
export declare function CalmLensUploader({ disabled, capture, messages: overrides, unstyled, controller: external, className, style, ...options }: CalmLensUploaderProps): import("react").JSX.Element;
|
|
23
|
-
export type
|
|
45
|
+
export type CalmLensAssetProps = AssetProps & StyleOptions & Omit<HTMLAttributes<HTMLElement>, "children" | "placeholder" | "onLoad" | "onError" | "onPlay" | "onEnded" | "onTimeUpdate"> & {
|
|
46
|
+
/** Replaces the unavailable notice. */
|
|
47
|
+
renderUnavailable?: () => ReactNode;
|
|
48
|
+
/** Replaces the age notice; call `confirm` from your own reveal button. */
|
|
49
|
+
renderAgeGate?: (props: {
|
|
50
|
+
placeholderUrl?: string;
|
|
51
|
+
confirm?: () => void;
|
|
52
|
+
}) => ReactNode;
|
|
53
|
+
};
|
|
24
54
|
/**
|
|
25
|
-
* Shows
|
|
26
|
-
*
|
|
27
|
-
*
|
|
55
|
+
* Shows any asset from its asset URL (public, or signed by your server), natively in the page: an
|
|
56
|
+
* image with responsive widths, a website's screenshot and link, video and audio with their
|
|
57
|
+
* adaptive stream, a document, text or spreadsheet viewer, or a preview still or file icon. It
|
|
58
|
+
* reads `{src}/info` once mounted, unless `info` is given, in which case the first render, on the
|
|
59
|
+
* server too, is the real element. Age-restricted content stays behind its blurred placeholder
|
|
60
|
+
* and a reveal button; content the CDN refuses shows the unavailable notice.
|
|
28
61
|
*/
|
|
29
|
-
export declare function
|
|
30
|
-
export { CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, ICONS, ICON_ATTRIBUTES, type IconName, type
|
|
62
|
+
export declare function CalmLensAsset(props: CalmLensAssetProps): import("react").JSX.Element;
|
|
63
|
+
export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, type AssetDisplay, type AssetDisplayOptions, type AssetDocumentOptions, type AssetEventHandlers, type AssetImageOptions, type AssetImageSource, type AssetOptions, type AssetProps, AssetSession, type AssetSessionState, type AssetSpreadsheetOptions, type AssetVideoOptions, type AssetView, type AssetViewer, type AssetViewerKind, AssetViewerMount, AssetViewerName, AssetViewerOptionsByKind, CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, type IconName, type ImageViewerOptions, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, type UseCalmLensUploadResult, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, type WebsiteViewerOptions, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex };
|