calmlens 0.20.0 → 0.22.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 +15 -10
- package/bin/calmlens.js +1848 -679
- package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-BWjZ9ntu.d.ts} +2 -2
- package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-Bwlib4Zc.js} +1 -1
- package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-BaW3ddUR.d.ts} +13 -3
- package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-DUYMo9PZ.js} +30 -10
- package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-YvgV995V.js} +318 -374
- package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-3N-gdsxC.js} +346 -89
- package/cjs/CalmLensServerClient-BKzn8zmp.d.ts +353 -0
- package/cjs/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-BDKwThbO.d.ts} +26993 -27187
- package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/cjs/Core-C33pkBmf.d.ts +826 -0
- package/cjs/Core-Cm5Z1oJ9.js +1001 -0
- package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
- package/cjs/{ModerationContextLimits-2nIv7Zh3.js → ModerationContextLimits-ud1xpZRK.js} +727 -268
- package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-DQ0BYISX.js} +1 -1
- package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-D29T_R0M-D6Bu-Mln.js} +355 -47
- package/cjs/{UploadController-MLVs97Zt.js → UploadController-l8fZM2qT.js} +34 -14
- package/{esm/WebhookPayload-DkukERKE.d.ts → cjs/WebhookPayload-Dt6DttS0.d.ts} +120 -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-Bde1wjiw.d.ts +16 -0
- package/cjs/index.d.ts +5 -6
- package/cjs/index.js +3 -2
- package/cjs/react-native.d.ts +52 -11
- package/cjs/react-native.js +231 -99
- package/cjs/react.d.ts +42 -9
- package/cjs/react.js +381 -118
- package/cjs/server.d.ts +48 -7
- package/cjs/server.js +7 -3
- package/cjs/test-inputs.d.ts +2 -2
- package/cjs/test-inputs.js +13 -9
- package/cjs/testing.d.ts +29 -15
- package/cjs/testing.js +1722 -433
- package/cjs/ui-BRA4HQ8r.js +1359 -0
- package/cjs/ui-YQuvbidU.d.ts +139 -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-BWjZ9ntu.d.ts} +2 -2
- package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-GRZVB0G_.js} +1 -1
- package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-B5QIJ6KS.js} +30 -10
- package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-BaW3ddUR.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BG7Qrh8-.js} +317 -367
- package/esm/CalmLensServerClient-BKzn8zmp.d.ts +353 -0
- package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-bRUAebi-.js} +323 -90
- package/esm/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-BDKwThbO.d.ts} +26993 -27187
- package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/esm/Core-BvQe4moS.js +846 -0
- package/esm/Core-C33pkBmf.d.ts +826 -0
- package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
- package/esm/{ModerationContextLimits-Chw-AzgL.js → ModerationContextLimits-CrxSnVZ3.js} +682 -253
- package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-BMO8saxT.js} +1 -1
- package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-D29T_R0M-Ztc74ucs.js} +332 -48
- package/esm/{UploadController-BJZghJpg.js → UploadController-DnJrWiE4.js} +34 -14
- package/{cjs/WebhookPayload-DkukERKE.d.ts → esm/WebhookPayload-Dt6DttS0.d.ts} +120 -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-Bde1wjiw.d.ts +16 -0
- package/esm/index.d.ts +5 -6
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +52 -11
- package/esm/react-native.js +205 -75
- package/esm/react.d.ts +42 -9
- package/esm/react.js +327 -91
- package/esm/server.d.ts +48 -7
- package/esm/server.js +3 -3
- package/esm/styles.css +142 -22
- package/esm/svelte/AssetViewer.svelte +25 -0
- package/esm/svelte/CalmLensAsset.svelte +318 -0
- package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
- package/esm/svelte/CalmLensImageViewer.svelte +7 -0
- package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
- package/esm/svelte/CalmLensTextViewer.svelte +7 -0
- package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
- package/esm/svelte/index.d.ts +29 -6
- package/esm/svelte/index.js +7 -2
- package/esm/test-inputs.d.ts +2 -2
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +29 -15
- package/esm/testing.js +1718 -429
- package/esm/ui-YQuvbidU.d.ts +139 -0
- package/esm/ui-heryDd6g.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 +4 -2
- package/cjs/CalmLensServerClient-C-jsjn8m.d.ts +0 -259
- 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/CalmLensServerClient-C-jsjn8m.d.ts +0 -259
- 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/vue.js
CHANGED
|
@@ -1,10 +1,78 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ui = require("./ui-
|
|
3
|
-
const require_UploadController = require("./UploadController-
|
|
4
|
-
const
|
|
2
|
+
const require_ui = require("./ui-BRA4HQ8r.js");
|
|
3
|
+
const require_UploadController = require("./UploadController-l8fZM2qT.js");
|
|
4
|
+
const require_Core = require("./Core-Cm5Z1oJ9.js");
|
|
5
|
+
const require_FileIcons = require("./FileIcons-Ob003MdS.js");
|
|
6
|
+
const require_BrowserUpload = require("./BrowserUpload-Bwlib4Zc.js");
|
|
5
7
|
let vue = require("vue");
|
|
8
|
+
// src/viewers/Vue.ts
|
|
9
|
+
const optional$1 = (type) => ({
|
|
10
|
+
type,
|
|
11
|
+
default: void 0
|
|
12
|
+
});
|
|
13
|
+
const viewer = (name, kind) => (0, vue.defineComponent)({
|
|
14
|
+
name,
|
|
15
|
+
props: {
|
|
16
|
+
/** The asset URL, public or signed. */
|
|
17
|
+
src: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
/** The asset's display info (`getAssetInfo`), or the asset from the API. */
|
|
22
|
+
asset: {
|
|
23
|
+
type: Object,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
/** Returns a fresh asset URL once a signed one expires. */
|
|
27
|
+
onExpired: optional$1(Function),
|
|
28
|
+
onUnavailable: optional$1(Function),
|
|
29
|
+
viewerClaims: optional$1(Object),
|
|
30
|
+
label: optional$1(String),
|
|
31
|
+
messages: optional$1(Object),
|
|
32
|
+
/** Images: the `sizes` of a public image's responsive widths. */
|
|
33
|
+
sizes: optional$1(String),
|
|
34
|
+
/** Text and spreadsheets: text your app already has. */
|
|
35
|
+
text: optional$1(String),
|
|
36
|
+
/** Text and spreadsheets: reads the text yourself. */
|
|
37
|
+
getText: optional$1(Function),
|
|
38
|
+
/** Spreadsheets: rows shown at a time. */
|
|
39
|
+
pageSize: optional$1(Number),
|
|
40
|
+
/** Documents: where pdf.js loads its worker, fonts and decoders from. */
|
|
41
|
+
pdf: optional$1(Object),
|
|
42
|
+
/** Documents: the page shown first. */
|
|
43
|
+
initialPage: optional$1(Number)
|
|
44
|
+
},
|
|
45
|
+
setup(props) {
|
|
46
|
+
const root = (0, vue.ref)();
|
|
47
|
+
let mounted;
|
|
48
|
+
const options = () => ({ ...props });
|
|
49
|
+
(0, vue.onMounted)(() => {
|
|
50
|
+
mounted = require_ui.ASSET_VIEWERS[kind](root.value, options());
|
|
51
|
+
});
|
|
52
|
+
(0, vue.watch)(options, (next) => mounted?.update(next));
|
|
53
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
54
|
+
mounted?.destroy();
|
|
55
|
+
mounted = void 0;
|
|
56
|
+
});
|
|
57
|
+
return () => (0, vue.h)("div", {
|
|
58
|
+
ref: root,
|
|
59
|
+
class: "calmlens-viewer",
|
|
60
|
+
"data-kind": kind
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
/** Shows an image asset's rendered file, fitted to the element, over its placeholder. */
|
|
65
|
+
const CalmLensImageViewer = viewer("CalmLensImageViewer", "image");
|
|
66
|
+
/** Shows a website asset's screenshot with a link to the original page. */
|
|
67
|
+
const CalmLensWebsiteViewer = viewer("CalmLensWebsiteViewer", "website");
|
|
68
|
+
/** Shows a text asset's text, escaped, in a scrolling region. */
|
|
69
|
+
const CalmLensTextViewer = viewer("CalmLensTextViewer", "text");
|
|
70
|
+
/** Shows a PDF, or a document rendered as one, a page at a time with pdf.js (loaded lazily). */
|
|
71
|
+
const CalmLensDocumentViewer = viewer("CalmLensDocumentViewer", "document");
|
|
72
|
+
/** Shows a spreadsheet's sheets as tabs and paged tables, from its extracted text. */
|
|
73
|
+
const CalmLensSpreadsheetViewer = viewer("CalmLensSpreadsheetViewer", "spreadsheet");
|
|
6
74
|
// src/vue.ts
|
|
7
|
-
const icon = (name) => (0, vue.h)("svg",
|
|
75
|
+
const icon = (name) => (0, vue.h)("svg", require_Core.ICON_ATTRIBUTES, [(0, vue.h)("path", { d: require_Core.ICONS[name] })]);
|
|
8
76
|
/** Keeps a ref to a controller's snapshot, following the controller if it changes. */
|
|
9
77
|
const subscribeSnapshot = (controller) => {
|
|
10
78
|
const snapshot = (0, vue.shallowRef)((0, vue.toValue)(controller).getSnapshot());
|
|
@@ -105,7 +173,7 @@ const CalmLensUploader = (0, vue.defineComponent)({
|
|
|
105
173
|
}));
|
|
106
174
|
const controller = (0, vue.computed)(() => props.controller ?? own.controller);
|
|
107
175
|
const snapshot = subscribeSnapshot(controller);
|
|
108
|
-
const messages = (0, vue.computed)(() =>
|
|
176
|
+
const messages = (0, vue.computed)(() => require_Core.resolveMessages(props.messages));
|
|
109
177
|
const dragging = (0, vue.ref)(false);
|
|
110
178
|
const input = (0, vue.ref)();
|
|
111
179
|
const openPicker = () => {
|
|
@@ -120,7 +188,7 @@ const CalmLensUploader = (0, vue.defineComponent)({
|
|
|
120
188
|
const queue = controller.value;
|
|
121
189
|
const { accept, multiple } = queue.options;
|
|
122
190
|
const items = snapshot.value.items;
|
|
123
|
-
const view =
|
|
191
|
+
const view = require_Core.describeUploader(snapshot.value, queue.options, text);
|
|
124
192
|
return (0, vue.h)("div", { class: "calmlens-uploader" }, [
|
|
125
193
|
view.showDropzone && (0, vue.h)("div", {
|
|
126
194
|
class: "calmlens-dropzone",
|
|
@@ -170,7 +238,7 @@ const CalmLensUploader = (0, vue.defineComponent)({
|
|
|
170
238
|
}
|
|
171
239
|
}),
|
|
172
240
|
items.length > 0 && (0, vue.h)("ul", { class: "calmlens-uploads" }, items.map((item) => {
|
|
173
|
-
const itemView =
|
|
241
|
+
const itemView = require_Core.describeUploadItem(item, text);
|
|
174
242
|
return (0, vue.h)("li", {
|
|
175
243
|
key: item.key,
|
|
176
244
|
class: "calmlens-upload",
|
|
@@ -236,184 +304,348 @@ const CalmLensUploader = (0, vue.defineComponent)({
|
|
|
236
304
|
};
|
|
237
305
|
}
|
|
238
306
|
});
|
|
307
|
+
/** Audio's waveform: the preview still, with the played part of its peaks drawn over it. */
|
|
308
|
+
const waveform = (url, peaks, played) => {
|
|
309
|
+
if (!url && !peaks) return void 0;
|
|
310
|
+
const bars = () => require_Core.getPeakHeights(peaks ?? []).map((height) => (0, vue.h)("span", { style: { height: `${height}%` } }));
|
|
311
|
+
return (0, vue.h)("div", { class: "calmlens-asset__waveform" }, [url && (0, vue.h)("img", {
|
|
312
|
+
class: "calmlens-asset__wave",
|
|
313
|
+
src: url,
|
|
314
|
+
alt: "",
|
|
315
|
+
"aria-hidden": "true"
|
|
316
|
+
}), peaks && (0, vue.h)("div", {
|
|
317
|
+
class: "calmlens-asset__progress",
|
|
318
|
+
role: "progressbar",
|
|
319
|
+
"aria-hidden": "true",
|
|
320
|
+
"aria-valuemin": 0,
|
|
321
|
+
"aria-valuemax": 100,
|
|
322
|
+
"aria-valuenow": played,
|
|
323
|
+
style: { "--calmlens-played": `${played}%` }
|
|
324
|
+
}, [(0, vue.h)("div", { class: "calmlens-asset__peaks" }, bars()), (0, vue.h)("div", {
|
|
325
|
+
class: "calmlens-asset__peaks",
|
|
326
|
+
"data-played": ""
|
|
327
|
+
}, bars())])]);
|
|
328
|
+
};
|
|
239
329
|
/**
|
|
240
|
-
* Shows
|
|
241
|
-
*
|
|
242
|
-
*
|
|
330
|
+
* Shows any asset from its asset URL (public, or signed by your server), natively in the page: an
|
|
331
|
+
* image with responsive widths, a website's screenshot and link, video and audio with their
|
|
332
|
+
* adaptive stream, a document, text or spreadsheet viewer, or a preview still or file icon. It
|
|
333
|
+
* reads `{src}/info` once mounted, unless `info` is given, in which case the first render, on the
|
|
334
|
+
* server too, is the real element. Emits `load`, `error`, `availability-change`, `play`, `ended`
|
|
335
|
+
* and `timeupdate`; listen for `age-confirm-request` to show the reveal button on age-restricted
|
|
336
|
+
* content. The `unavailable` and `age-gate` slots (`{ placeholderUrl, confirm }`) replace the
|
|
337
|
+
* notices.
|
|
243
338
|
*/
|
|
244
|
-
const
|
|
245
|
-
name: "
|
|
339
|
+
const CalmLensAsset = (0, vue.defineComponent)({
|
|
340
|
+
name: "CalmLensAsset",
|
|
246
341
|
props: {
|
|
247
|
-
/**
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
projectId: optional(String),
|
|
251
|
-
/** Required without `asset`. */
|
|
252
|
-
assetId: optional(String),
|
|
253
|
-
status: optional(String),
|
|
254
|
-
contentRemoved: optional(Boolean),
|
|
255
|
-
type: optional(String),
|
|
256
|
-
resource: optional(String),
|
|
257
|
-
lens: optional(String),
|
|
258
|
-
transform: optional([
|
|
259
|
-
String,
|
|
260
|
-
Object,
|
|
261
|
-
Array
|
|
262
|
-
]),
|
|
263
|
-
widths: optional(Array),
|
|
264
|
-
url: optional(String),
|
|
265
|
-
placeholder: {
|
|
266
|
-
type: Boolean,
|
|
267
|
-
default: true
|
|
268
|
-
},
|
|
269
|
-
placeholderHash: optional(String),
|
|
270
|
-
placeholderUrl: optional(String),
|
|
271
|
-
averageColor: optional(String),
|
|
272
|
-
cdnBaseUrl: optional(String),
|
|
342
|
+
/** The asset URL, public or signed. Nothing is requested until it is set. */
|
|
343
|
+
src: optional(String),
|
|
344
|
+
display: optional(String),
|
|
273
345
|
viewerClaims: optional(Object),
|
|
346
|
+
/** The asset's display info, prefetched with `getAssetInfo`. */
|
|
347
|
+
info: optional(Object),
|
|
274
348
|
alt: {
|
|
275
349
|
type: String,
|
|
276
350
|
default: ""
|
|
277
351
|
},
|
|
278
|
-
aspectRatio: optional(Number),
|
|
279
|
-
width: optional(Number),
|
|
280
|
-
height: optional(Number),
|
|
281
|
-
sizes: optional(String),
|
|
282
352
|
fit: optional(String),
|
|
283
|
-
|
|
353
|
+
aspectRatio: optional(Number),
|
|
284
354
|
lazy: {
|
|
285
355
|
type: Boolean,
|
|
286
356
|
default: true
|
|
287
357
|
},
|
|
288
358
|
fetchPriority: optional(String),
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
359
|
+
image: optional(Object),
|
|
360
|
+
video: optional(Object),
|
|
361
|
+
document: optional(Object),
|
|
362
|
+
spreadsheet: optional(Object),
|
|
363
|
+
/** Returns a fresh asset URL from your server once a signed one expires. */
|
|
364
|
+
onExpired: optional(Function),
|
|
293
365
|
messages: messagesProp,
|
|
294
|
-
/** Bound by `@
|
|
295
|
-
|
|
366
|
+
/** Bound by `@age-confirm-request`; a prop so the reveal button shows only when bound. */
|
|
367
|
+
onAgeConfirmRequest: optional(Function)
|
|
296
368
|
},
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
369
|
+
emits: {
|
|
370
|
+
load: () => true,
|
|
371
|
+
error: () => true,
|
|
372
|
+
"availability-change": (_availability) => true,
|
|
373
|
+
play: () => true,
|
|
374
|
+
ended: () => true,
|
|
375
|
+
timeupdate: (_currentTime) => true
|
|
376
|
+
},
|
|
377
|
+
setup(props, { emit, slots }) {
|
|
378
|
+
const messages = (0, vue.computed)(() => require_Core.resolveMessages(props.messages));
|
|
379
|
+
const version = (0, vue.ref)(0);
|
|
380
|
+
const session = new require_Core.AssetSession(() => {
|
|
381
|
+
version.value++;
|
|
382
|
+
});
|
|
383
|
+
const options = (0, vue.computed)(() => ({
|
|
384
|
+
src: props.src,
|
|
385
|
+
display: props.display,
|
|
386
|
+
viewerClaims: props.viewerClaims,
|
|
387
|
+
info: props.info,
|
|
388
|
+
image: props.image,
|
|
389
|
+
video: props.video,
|
|
390
|
+
document: props.document,
|
|
391
|
+
spreadsheet: props.spreadsheet,
|
|
392
|
+
onExpired: props.onExpired,
|
|
393
|
+
alt: props.alt
|
|
394
|
+
}));
|
|
395
|
+
const state = (0, vue.computed)(() => {
|
|
396
|
+
version.value;
|
|
397
|
+
return session.update(options.value);
|
|
398
|
+
});
|
|
399
|
+
const view = (0, vue.computed)(() => require_Core.getAssetView(options.value, state.value));
|
|
400
|
+
const loadKey = (0, vue.computed)(() => require_Core.getAssetViewKey(view.value));
|
|
302
401
|
const load = (0, vue.ref)("loading");
|
|
402
|
+
const played = (0, vue.ref)(0);
|
|
403
|
+
const mounted = (0, vue.ref)(false);
|
|
303
404
|
const image = (0, vue.ref)();
|
|
405
|
+
const media = (0, vue.ref)();
|
|
406
|
+
const viewerRoot = (0, vue.ref)();
|
|
407
|
+
const failedAt = (element) => ({
|
|
408
|
+
position: element.currentTime || 0,
|
|
409
|
+
playing: !element.paused && !element.ended
|
|
410
|
+
});
|
|
411
|
+
const streams = new require_ui.MediaStreamPlayer((element) => {
|
|
412
|
+
session.mediaFailed(failedAt(element));
|
|
413
|
+
return true;
|
|
414
|
+
});
|
|
415
|
+
const viewers = new require_ui.AssetViewerMount();
|
|
416
|
+
(0, vue.watchEffect)(() => {
|
|
417
|
+
state.value;
|
|
418
|
+
if (mounted.value) session.load();
|
|
419
|
+
});
|
|
420
|
+
(0, vue.watch)([media, view], () => streams.update(media.value, view.value), { flush: "post" });
|
|
421
|
+
(0, vue.watch)([
|
|
422
|
+
viewerRoot,
|
|
423
|
+
view,
|
|
424
|
+
options,
|
|
425
|
+
state
|
|
426
|
+
], () => {
|
|
427
|
+
const kind = view.value.kind;
|
|
428
|
+
viewers.update(viewerRoot.value, require_ui.isMountedViewerKind(kind) ? kind : void 0, require_ui.getMountedViewerOptions(options.value, session), (viewerState) => {
|
|
429
|
+
if (viewerState !== "loading") load.value = viewerState;
|
|
430
|
+
});
|
|
431
|
+
}, { flush: "post" });
|
|
432
|
+
(0, vue.onScopeDispose)(() => {
|
|
433
|
+
streams.stop();
|
|
434
|
+
viewers.destroy();
|
|
435
|
+
});
|
|
304
436
|
(0, vue.watch)(loadKey, () => {
|
|
305
437
|
load.value = "loading";
|
|
306
438
|
});
|
|
439
|
+
(0, vue.watch)(load, (value) => {
|
|
440
|
+
if (value === "loaded") emit("load");
|
|
441
|
+
if (value === "error") emit("error");
|
|
442
|
+
});
|
|
443
|
+
const availability = (0, vue.computed)(() => view.value.kind === "unavailable" ? "unavailable" : view.value.kind === "age-restricted" ? "age-restricted" : view.value.kind === "pending" ? void 0 : "available");
|
|
444
|
+
(0, vue.watch)(availability, (value) => {
|
|
445
|
+
if (value) emit("availability-change", value);
|
|
446
|
+
}, { immediate: true });
|
|
307
447
|
(0, vue.onMounted)(() => {
|
|
448
|
+
mounted.value = true;
|
|
308
449
|
if (image.value?.complete && image.value.naturalWidth > 0) load.value = "loaded";
|
|
309
450
|
});
|
|
310
|
-
const
|
|
311
|
-
|
|
451
|
+
const onMediaError = (event) => {
|
|
452
|
+
const element = event.target;
|
|
453
|
+
if (!streams.recover(element)) session.mediaFailed(failedAt(element));
|
|
454
|
+
};
|
|
455
|
+
const playerEvents = {
|
|
456
|
+
onLoadedmetadata: (event) => {
|
|
457
|
+
session.mediaLoaded(event.target);
|
|
458
|
+
load.value = "loaded";
|
|
459
|
+
},
|
|
460
|
+
onError: onMediaError,
|
|
461
|
+
onPlay: () => emit("play"),
|
|
462
|
+
onEnded: () => emit("ended"),
|
|
463
|
+
onTimeupdate: (event) => {
|
|
464
|
+
const element = event.target;
|
|
465
|
+
played.value = require_Core.getPlayedPercent(element);
|
|
466
|
+
emit("timeupdate", element.currentTime);
|
|
467
|
+
}
|
|
312
468
|
};
|
|
313
469
|
return () => {
|
|
314
|
-
const current =
|
|
470
|
+
const current = view.value;
|
|
315
471
|
const text = messages.value;
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
|
|
472
|
+
const ratio = require_Core.getAssetAspectRatio(current, state.value.info, props.aspectRatio);
|
|
473
|
+
const placeholderUrl = "placeholderUrl" in current && (current.kind === "age-restricted" || current.kind === "pending" || load.value !== "loaded") ? current.placeholderUrl : void 0;
|
|
474
|
+
const notice = (children) => (0, vue.h)("figcaption", { class: "calmlens-asset__notice" }, children);
|
|
475
|
+
const video = props.video ?? {};
|
|
476
|
+
const imageElement = (shown) => (0, vue.h)("img", {
|
|
477
|
+
key: loadKey.value,
|
|
478
|
+
ref: image,
|
|
479
|
+
class: "calmlens-asset__content",
|
|
480
|
+
src: shown.src,
|
|
481
|
+
srcset: shown.srcSet,
|
|
482
|
+
sizes: shown.srcSet ? props.image?.sizes : void 0,
|
|
483
|
+
alt: props.alt,
|
|
484
|
+
width: shown.width,
|
|
485
|
+
height: shown.height,
|
|
486
|
+
loading: props.lazy ? "lazy" : void 0,
|
|
487
|
+
decoding: "async",
|
|
488
|
+
fetchpriority: props.fetchPriority,
|
|
489
|
+
onLoad: () => {
|
|
490
|
+
session.loaded();
|
|
491
|
+
load.value = "loaded";
|
|
492
|
+
},
|
|
493
|
+
onError: () => session.failed()
|
|
494
|
+
});
|
|
495
|
+
const viewerShown = require_ui.isMountedViewerKind(current.kind) && mounted.value;
|
|
496
|
+
const confirm = props.onAgeConfirmRequest;
|
|
322
497
|
return (0, vue.h)("figure", {
|
|
323
|
-
class: "calmlens-
|
|
498
|
+
class: "calmlens-asset",
|
|
324
499
|
"data-kind": current.kind,
|
|
325
500
|
"data-state": load.value,
|
|
326
501
|
"data-sized": ratio ? "" : void 0,
|
|
502
|
+
"aria-busy": current.kind === "pending" ? "true" : void 0,
|
|
327
503
|
style: {
|
|
328
504
|
aspectRatio: ratio,
|
|
329
|
-
backgroundColor:
|
|
330
|
-
"--calmlens-fit": props.fit
|
|
331
|
-
"--calmlens-position": props.position
|
|
505
|
+
backgroundColor: state.value.info?.content?.preview?.averageColor ?? void 0,
|
|
506
|
+
"--calmlens-fit": props.fit
|
|
332
507
|
}
|
|
333
508
|
}, [
|
|
334
|
-
|
|
335
|
-
class: "calmlens-
|
|
509
|
+
placeholderUrl && (0, vue.h)("img", {
|
|
510
|
+
class: "calmlens-asset__placeholder",
|
|
336
511
|
src: placeholderUrl,
|
|
337
512
|
alt: "",
|
|
338
513
|
"aria-hidden": "true"
|
|
339
514
|
}),
|
|
340
|
-
current.kind === "image" &&
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
515
|
+
current.kind === "image" && imageElement(current),
|
|
516
|
+
current.kind === "website" && current.link && (0, vue.h)("div", { class: "calmlens-asset__bar" }, [(0, vue.h)("a", {
|
|
517
|
+
class: "calmlens-button",
|
|
518
|
+
href: current.link,
|
|
519
|
+
target: "_blank",
|
|
520
|
+
rel: "noopener noreferrer nofollow"
|
|
521
|
+
}, require_Core.formatMessage(text.openWebsite, { host: new URL(current.link).host }))]),
|
|
522
|
+
current.kind === "website" && (0, vue.h)("div", {
|
|
523
|
+
class: "calmlens-asset__scroll",
|
|
524
|
+
role: "region",
|
|
525
|
+
"aria-label": props.alt || void 0,
|
|
526
|
+
tabindex: 0
|
|
527
|
+
}, [imageElement(current)]),
|
|
528
|
+
current.kind === "video" && (0, vue.h)("video", {
|
|
529
|
+
ref: media,
|
|
530
|
+
class: "calmlens-asset__content",
|
|
531
|
+
...current.stream ? {} : { src: current.src },
|
|
532
|
+
poster: current.poster,
|
|
533
|
+
controls: video.controls ?? true,
|
|
534
|
+
autoplay: video.autoPlay,
|
|
535
|
+
muted: video.muted,
|
|
536
|
+
loop: video.loop,
|
|
362
537
|
playsinline: true,
|
|
363
538
|
preload: "metadata",
|
|
364
539
|
"aria-label": props.alt || void 0,
|
|
365
|
-
|
|
366
|
-
load.value = "error";
|
|
367
|
-
}
|
|
540
|
+
...playerEvents
|
|
368
541
|
}),
|
|
369
|
-
current.kind === "audio" &&
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
542
|
+
current.kind === "audio" && waveform(current.waveformUrl, current.peaks, played.value),
|
|
543
|
+
current.kind === "audio" && (0, vue.h)("audio", {
|
|
544
|
+
ref: media,
|
|
545
|
+
class: "calmlens-asset__content",
|
|
546
|
+
...current.stream ? {} : { src: current.src },
|
|
547
|
+
controls: video.controls ?? true,
|
|
548
|
+
autoplay: video.autoPlay,
|
|
549
|
+
muted: video.muted,
|
|
550
|
+
loop: video.loop,
|
|
373
551
|
preload: "metadata",
|
|
374
552
|
"aria-label": props.alt || void 0,
|
|
375
|
-
|
|
376
|
-
load.value = "error";
|
|
377
|
-
}
|
|
553
|
+
...playerEvents
|
|
378
554
|
}),
|
|
379
|
-
current.kind === "
|
|
555
|
+
current.kind === "document" && !viewerShown && current.still && (0, vue.h)("img", {
|
|
556
|
+
class: "calmlens-asset__content",
|
|
557
|
+
src: current.still,
|
|
558
|
+
alt: props.alt,
|
|
559
|
+
decoding: "async"
|
|
560
|
+
}),
|
|
561
|
+
current.kind === "document" && !viewerShown && (0, vue.h)("a", {
|
|
562
|
+
class: "calmlens-button calmlens-asset__open",
|
|
563
|
+
href: current.src,
|
|
564
|
+
target: "_blank",
|
|
565
|
+
rel: "noopener noreferrer"
|
|
566
|
+
}, text.openDocument),
|
|
567
|
+
viewerShown && (0, vue.h)("div", {
|
|
568
|
+
ref: viewerRoot,
|
|
569
|
+
class: "calmlens-asset__viewer"
|
|
570
|
+
}),
|
|
571
|
+
current.kind === "file" && (0, vue.h)("span", {
|
|
572
|
+
class: "calmlens-asset__file",
|
|
573
|
+
role: "img",
|
|
574
|
+
"aria-label": props.alt || void 0,
|
|
575
|
+
"aria-hidden": props.alt ? void 0 : "true",
|
|
576
|
+
innerHTML: require_FileIcons.renderFileIconSvg({
|
|
577
|
+
family: current.icon,
|
|
578
|
+
extension: ""
|
|
579
|
+
}, 64)
|
|
580
|
+
}),
|
|
581
|
+
current.kind === "age-restricted" && (slots["age-gate"]?.({
|
|
582
|
+
placeholderUrl: current.placeholderUrl,
|
|
583
|
+
confirm
|
|
584
|
+
}) ?? notice([
|
|
380
585
|
(0, vue.h)("strong", text.sensitiveTitle),
|
|
381
586
|
(0, vue.h)("p", text.sensitiveBody),
|
|
382
|
-
|
|
587
|
+
confirm && (0, vue.h)("button", {
|
|
383
588
|
type: "button",
|
|
384
589
|
class: "calmlens-button",
|
|
385
|
-
onClick:
|
|
590
|
+
onClick: confirm
|
|
386
591
|
}, text.reveal)
|
|
387
|
-
]),
|
|
388
|
-
|
|
592
|
+
])),
|
|
593
|
+
current.kind === "unavailable" && (slots.unavailable?.() ?? notice([(0, vue.h)("p", [icon("unavailable"), (0, vue.h)("span", { class: "calmlens-asset__label" }, text.unavailable)])]))
|
|
389
594
|
]);
|
|
390
595
|
};
|
|
391
596
|
}
|
|
392
597
|
});
|
|
393
|
-
exports.
|
|
394
|
-
exports.
|
|
395
|
-
exports.
|
|
598
|
+
exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
|
|
599
|
+
exports.ASSET_VIEWERS = require_ui.ASSET_VIEWERS;
|
|
600
|
+
exports.AssetSession = require_Core.AssetSession;
|
|
601
|
+
exports.AssetViewerMount = require_ui.AssetViewerMount;
|
|
602
|
+
exports.CALMLENS_STYLES = require_Core.CALMLENS_STYLES;
|
|
603
|
+
exports.CALMLENS_THEME = require_Core.CALMLENS_THEME;
|
|
604
|
+
exports.CalmLensAsset = CalmLensAsset;
|
|
605
|
+
exports.CalmLensDocumentViewer = CalmLensDocumentViewer;
|
|
606
|
+
exports.CalmLensImageViewer = CalmLensImageViewer;
|
|
607
|
+
exports.CalmLensSpreadsheetViewer = CalmLensSpreadsheetViewer;
|
|
608
|
+
exports.CalmLensTextViewer = CalmLensTextViewer;
|
|
396
609
|
exports.CalmLensUploader = CalmLensUploader;
|
|
397
|
-
exports.
|
|
398
|
-
exports.
|
|
399
|
-
exports.
|
|
610
|
+
exports.CalmLensWebsiteViewer = CalmLensWebsiteViewer;
|
|
611
|
+
exports.DEFAULT_MESSAGES = require_Core.DEFAULT_MESSAGES;
|
|
612
|
+
exports.DEFAULT_VIEWER_MESSAGES = require_ui.DEFAULT_VIEWER_MESSAGES;
|
|
613
|
+
exports.ICONS = require_Core.ICONS;
|
|
614
|
+
exports.ICON_ATTRIBUTES = require_Core.ICON_ATTRIBUTES;
|
|
615
|
+
exports.MediaStreamPlayer = require_ui.MediaStreamPlayer;
|
|
400
616
|
exports.UploadController = require_UploadController.UploadController;
|
|
617
|
+
exports.VIEWER_STYLES = require_Core.VIEWER_STYLES;
|
|
618
|
+
exports.createDocumentViewer = require_ui.createDocumentViewer;
|
|
619
|
+
exports.createImageViewer = require_ui.createImageViewer;
|
|
401
620
|
exports.createProgressFetch = require_UploadController.createProgressFetch;
|
|
621
|
+
exports.createSpreadsheetViewer = require_ui.createSpreadsheetViewer;
|
|
622
|
+
exports.createTextViewer = require_ui.createTextViewer;
|
|
402
623
|
exports.createUploadController = require_BrowserUpload.createUploadController;
|
|
403
|
-
exports.
|
|
404
|
-
exports.
|
|
405
|
-
exports.
|
|
406
|
-
exports.
|
|
407
|
-
exports.
|
|
408
|
-
exports.
|
|
409
|
-
exports.
|
|
410
|
-
exports.
|
|
411
|
-
exports.
|
|
412
|
-
exports.
|
|
413
|
-
exports.
|
|
624
|
+
exports.createWebsiteViewer = require_ui.createWebsiteViewer;
|
|
625
|
+
exports.describeUploadItem = require_Core.describeUploadItem;
|
|
626
|
+
exports.describeUploader = require_Core.describeUploader;
|
|
627
|
+
exports.formatBytes = require_Core.formatBytes;
|
|
628
|
+
exports.formatMessage = require_Core.formatMessage;
|
|
629
|
+
exports.formatViewerMessage = require_ui.formatViewerMessage;
|
|
630
|
+
exports.getAssetAspectRatio = require_Core.getAssetAspectRatio;
|
|
631
|
+
exports.getAssetView = require_Core.getAssetView;
|
|
632
|
+
exports.getAssetViewKey = require_Core.getAssetViewKey;
|
|
633
|
+
exports.getAssetViewerKind = require_Core.getAssetViewerKind;
|
|
634
|
+
exports.getDropzoneHint = require_Core.getDropzoneHint;
|
|
635
|
+
exports.getMountedViewerOptions = require_ui.getMountedViewerOptions;
|
|
636
|
+
exports.getPeakHeights = require_Core.getPeakHeights;
|
|
637
|
+
exports.getPlayedPercent = require_Core.getPlayedPercent;
|
|
638
|
+
exports.getSpreadsheetPage = require_ui.getSpreadsheetPage;
|
|
639
|
+
exports.getUploadItemMessage = require_Core.getUploadItemMessage;
|
|
640
|
+
exports.getUploadItemOutcome = require_Core.getUploadItemOutcome;
|
|
414
641
|
exports.isFileAccepted = require_UploadController.isFileAccepted;
|
|
415
|
-
exports.
|
|
416
|
-
exports.
|
|
417
|
-
exports.
|
|
418
|
-
exports.
|
|
642
|
+
exports.isMountedViewerKind = require_ui.isMountedViewerKind;
|
|
643
|
+
exports.isSpreadsheetFormat = require_Core.isSpreadsheetFormat;
|
|
644
|
+
exports.loadPdfJs = require_ui.loadPdfJs;
|
|
645
|
+
exports.parseSpreadsheetText = require_ui.parseSpreadsheetText;
|
|
646
|
+
exports.pickAssetSource = require_Core.pickAssetSource;
|
|
647
|
+
exports.resolveMessages = require_Core.resolveMessages;
|
|
648
|
+
exports.resolveTheme = require_Core.resolveTheme;
|
|
649
|
+
exports.resolveViewerMessages = require_ui.resolveViewerMessages;
|
|
650
|
+
exports.spreadsheetColumnIndex = require_ui.spreadsheetColumnIndex;
|
|
419
651
|
exports.useCalmLensUpload = useCalmLensUpload;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as
|
|
2
|
-
import { t as UseCalmLensUploadResult$1 } from "./ReactUpload-
|
|
1
|
+
import { F as UploadItem$1, I as UploadSnapshot$1, M as UploadController, N as UploadControllerOptions$1, O as CalmLensUpload$1, P as UploadFile, h as UploaderProps$1 } from "./Core-C33pkBmf.js";
|
|
2
|
+
import { t as UseCalmLensUploadResult$1 } from "./ReactUpload-DhF8mm51.js";
|
|
3
3
|
type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
|
|
4
4
|
type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
|
|
5
5
|
type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createUploadController$1 } from "./UploadController-
|
|
1
|
+
import { n as createUploadController$1 } from "./UploadController-DnJrWiE4.js";
|
|
2
2
|
// src/ui/BrowserUpload.ts
|
|
3
3
|
/** Creates an upload queue for the browser components, such as one a form starts on submit. */
|
|
4
4
|
const createUploadController = (options) => createUploadController$1(options);
|