calmlens 0.27.3 → 0.27.5

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 (80) hide show
  1. package/bin/calmlens.js +1 -1
  2. package/cjs/{BrowserUpload-Dt1zocK4.d.ts → BrowserUpload-DJZY1LSU.d.ts} +2 -2
  3. package/cjs/{BrowserUpload-ldUKNpff.js → BrowserUpload-DhruIgFN.js} +1 -1
  4. package/cjs/{CalmLensAppClient--O7TSwy3.js → CalmLensAppClient-BA_xaNHY.js} +2 -2
  5. package/{esm/CalmLensAppClient-CTMmq7Dx.d.ts → cjs/CalmLensAppClient-DzoSqUgG.d.ts} +1 -1
  6. package/cjs/{CalmLensOptionKeys-BHl-sxlg.js → CalmLensOptionKeys-BvLQghl-.js} +1 -1
  7. package/cjs/{CalmLensServerClient--9ScUitp.d.ts → CalmLensServerClient-D3K5HS9v.d.ts} +2 -2
  8. package/cjs/{CalmLensServerClient-BTN0LFs6.js → CalmLensServerClient-D55xDZm4.js} +2 -2
  9. package/cjs/{CalmLensTypes-CRAOkOV4.d.ts → CalmLensTypes-OWZsGvBX.d.ts} +7 -2
  10. package/{esm/Core-BIs7IQ84.d.ts → cjs/Core-CTO_Eh0l.d.ts} +13 -14
  11. package/cjs/{Core-BdyadK2Y.js → Core-kKGmyk5V.js} +63 -21
  12. package/cjs/{ModerationContextLimits-Cyg__fp3.js → ModerationContextLimits-Cxaob3tc.js} +1 -1
  13. package/{esm/ReactUpload-DsF4ahE6.d.ts → cjs/ReactUpload-BDXV4aHT.d.ts} +1 -1
  14. package/cjs/{ReactUpload-C7-EzsLW.js → ReactUpload-Cx3Hi7xt.js} +1 -1
  15. package/cjs/{UploadController-wKETVSZ8.js → UploadController-CC1afxmL.js} +2 -2
  16. package/{esm/WebhookPayload-Cth0Xvpz.d.ts → cjs/WebhookPayload-CrMU6lg0.d.ts} +1 -1
  17. package/cjs/app.d.ts +4 -4
  18. package/cjs/app.js +2 -2
  19. package/cjs/elements.d.ts +8 -19
  20. package/cjs/elements.js +45 -53
  21. package/cjs/{index-BsUWhlwp.d.ts → index-BDxmVi-G.d.ts} +2 -2
  22. package/cjs/index.d.ts +3 -3
  23. package/cjs/index.js +1 -1
  24. package/cjs/react-native.d.ts +3 -3
  25. package/cjs/react-native.js +6 -4
  26. package/cjs/react.d.ts +5 -11
  27. package/cjs/react.js +29 -36
  28. package/cjs/server.d.ts +4 -4
  29. package/cjs/server.js +2 -2
  30. package/cjs/testing.d.ts +4 -4
  31. package/cjs/testing.js +5 -5
  32. package/cjs/{ui-CmRjBpMv.d.ts → ui-DAbpyM2Z.d.ts} +3 -9
  33. package/cjs/{ui-DZHhU1_I.js → ui-I75EvP9r.js} +2 -201
  34. package/cjs/ui.d.ts +3 -3
  35. package/cjs/ui.js +5 -5
  36. package/cjs/vue.d.ts +6 -319
  37. package/cjs/vue.js +27 -17
  38. package/esm/{BrowserUpload-DI_N79Hf.js → BrowserUpload-CejeWw5r.js} +1 -1
  39. package/esm/{BrowserUpload-Dt1zocK4.d.ts → BrowserUpload-DJZY1LSU.d.ts} +2 -2
  40. package/esm/{CalmLensAppClient-hBV8phqu.js → CalmLensAppClient-BxkCVPCl.js} +2 -2
  41. package/{cjs/CalmLensAppClient-CTMmq7Dx.d.ts → esm/CalmLensAppClient-DzoSqUgG.d.ts} +1 -1
  42. package/esm/{CalmLensOptionKeys-Cx6zlZBW.js → CalmLensOptionKeys-DC9FUO43.js} +1 -1
  43. package/esm/{CalmLensServerClient-C-Y82hbC.js → CalmLensServerClient-D-TIIQp2.js} +2 -2
  44. package/esm/{CalmLensServerClient--9ScUitp.d.ts → CalmLensServerClient-D3K5HS9v.d.ts} +2 -2
  45. package/esm/{CalmLensTypes-CRAOkOV4.d.ts → CalmLensTypes-OWZsGvBX.d.ts} +7 -2
  46. package/esm/{Core-KP_nIj1_.js → Core-B85V5dxv.js} +52 -22
  47. package/{cjs/Core-BIs7IQ84.d.ts → esm/Core-CTO_Eh0l.d.ts} +13 -14
  48. package/esm/{ModerationContextLimits-BTzR81IP.js → ModerationContextLimits-Tev2lxE0.js} +1 -1
  49. package/esm/{ReactUpload-DHMtN7ap.js → ReactUpload-B7QXMSWJ.js} +1 -1
  50. package/{cjs/ReactUpload-DsF4ahE6.d.ts → esm/ReactUpload-BDXV4aHT.d.ts} +1 -1
  51. package/esm/{UploadController-BlQqCkhK.js → UploadController-D7XmzO-p.js} +2 -2
  52. package/{cjs/WebhookPayload-Cth0Xvpz.d.ts → esm/WebhookPayload-CrMU6lg0.d.ts} +1 -1
  53. package/esm/app.d.ts +4 -4
  54. package/esm/app.js +2 -2
  55. package/esm/elements.d.ts +8 -19
  56. package/esm/elements.js +44 -50
  57. package/esm/{index-BsUWhlwp.d.ts → index-BDxmVi-G.d.ts} +2 -2
  58. package/esm/index.d.ts +3 -3
  59. package/esm/index.js +1 -1
  60. package/esm/react-native.d.ts +3 -3
  61. package/esm/react-native.js +5 -5
  62. package/esm/react.d.ts +5 -11
  63. package/esm/react.js +29 -34
  64. package/esm/server.d.ts +4 -4
  65. package/esm/server.js +2 -2
  66. package/esm/styles.css +12 -16
  67. package/esm/svelte/CalmLensAsset.svelte +22 -4
  68. package/esm/svelte/index.d.ts +0 -6
  69. package/esm/svelte/index.js +0 -2
  70. package/esm/testing.d.ts +4 -4
  71. package/esm/testing.js +5 -5
  72. package/esm/{ui-CmRjBpMv.d.ts → ui-DAbpyM2Z.d.ts} +3 -9
  73. package/esm/{ui-SnbQ4vk1.js → ui-cE1lyljs.js} +3 -190
  74. package/esm/ui.d.ts +3 -3
  75. package/esm/ui.js +4 -4
  76. package/esm/vue.d.ts +6 -319
  77. package/esm/vue.js +26 -14
  78. package/package.json +1 -1
  79. package/esm/svelte/CalmLensImageViewer.svelte +0 -7
  80. package/esm/svelte/CalmLensWebsiteViewer.svelte +0 -7
package/esm/vue.js CHANGED
@@ -1,8 +1,8 @@
1
- import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-SnbQ4vk1.js";
2
- import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController$1, r as isFileAccepted, t as UploadController } from "./UploadController-BlQqCkhK.js";
3
- import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-KP_nIj1_.js";
1
+ import { a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createDocumentViewer, f as DEFAULT_VIEWER_MESSAGES, h as loadPdfJs, i as isMountedViewerKind, l as parseSpreadsheetText, m as resolveViewerMessages, n as AssetViewerMount, o as createSpreadsheetViewer, p as formatViewerMessage, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-cE1lyljs.js";
2
+ import { C as pickAssetSource, D as getAssetViewerKind, E as resolveTheme, O as isSpreadsheetFormat, S as isImageReady, T as CALMLENS_THEME, _ as getAssetAspectRatio, a as describeUploadItem, b as getPeakHeights, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as INSTANT_LOAD_MS, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetView, w as VIEWER_STYLES, x as getPlayedPercent, y as getAssetViewKey } from "./Core-B85V5dxv.js";
3
+ import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController$1, r as isFileAccepted, t as UploadController } from "./UploadController-D7XmzO-p.js";
4
4
  import { c as renderFileIconSvg } from "./FileIcons-M6dzjFxd.js";
5
- import { t as createUploadController } from "./BrowserUpload-DI_N79Hf.js";
5
+ import { t as createUploadController } from "./BrowserUpload-CejeWw5r.js";
6
6
  import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, onScopeDispose, provide, ref, shallowRef, toValue, watch, watchEffect } from "vue";
7
7
  // src/viewers/Vue.ts
8
8
  const optional$1 = (type) => ({
@@ -28,8 +28,6 @@ const viewer = (name, kind) => defineComponent({
28
28
  viewerClaims: optional$1(Object),
29
29
  label: optional$1(String),
30
30
  messages: optional$1(Object),
31
- /** Images: the `sizes` of a public image's responsive widths. */
32
- sizes: optional$1(String),
33
31
  /** Text and spreadsheets: text your app already has. */
34
32
  text: optional$1(String),
35
33
  /** Text and spreadsheets: reads the text yourself. */
@@ -60,10 +58,6 @@ const viewer = (name, kind) => defineComponent({
60
58
  });
61
59
  }
62
60
  });
63
- /** Shows an image asset's rendered file, fitted to the element, over its placeholder. */
64
- const CalmLensImageViewer = viewer("CalmLensImageViewer", "image");
65
- /** Shows a website asset's screenshot with a link to the original page. */
66
- const CalmLensWebsiteViewer = viewer("CalmLensWebsiteViewer", "website");
67
61
  /** Shows a text asset's text, escaped, in a scrolling region. */
68
62
  const CalmLensTextViewer = viewer("CalmLensTextViewer", "text");
69
63
  /** Shows a PDF, or a document rendered as one, a page at a time with pdf.js (loaded lazily). */
@@ -409,6 +403,8 @@ const CalmLensAsset = defineComponent({
409
403
  const view = computed(() => getAssetView(options.value, state.value));
410
404
  const loadKey = computed(() => getAssetViewKey(view.value));
411
405
  const load = ref("loading");
406
+ const instant = ref(false);
407
+ let loadStartedAt = 0;
412
408
  const played = ref(0);
413
409
  const mounted = ref(false);
414
410
  const image = ref();
@@ -445,7 +441,16 @@ const CalmLensAsset = defineComponent({
445
441
  });
446
442
  watch(loadKey, () => {
447
443
  load.value = "loading";
444
+ instant.value = false;
448
445
  });
446
+ watch([loadKey, image], () => {
447
+ if (!image.value) return;
448
+ loadStartedAt = performance.now();
449
+ if (isImageReady(image.value)) {
450
+ instant.value = true;
451
+ load.value = "loaded";
452
+ }
453
+ }, { flush: "post" });
449
454
  watch(load, (value) => {
450
455
  if (value === "loaded") emit("load");
451
456
  if (value === "error") emit("error");
@@ -456,7 +461,11 @@ const CalmLensAsset = defineComponent({
456
461
  }, { immediate: true });
457
462
  onMounted(() => {
458
463
  mounted.value = true;
459
- if (image.value?.complete && image.value.naturalWidth > 0) load.value = "loaded";
464
+ loadStartedAt = performance.now();
465
+ if (isImageReady(image.value)) {
466
+ instant.value = true;
467
+ load.value = "loaded";
468
+ }
460
469
  });
461
470
  const onMediaError = (event) => {
462
471
  const element = event.target;
@@ -480,7 +489,7 @@ const CalmLensAsset = defineComponent({
480
489
  const current = view.value;
481
490
  const text = messages.value;
482
491
  const ratio = getAssetAspectRatio(current, state.value.info, props.aspectRatio);
483
- const placeholderUrl = "placeholderUrl" in current && (current.kind === "age-restricted" || current.kind === "pending" || load.value !== "loaded") ? current.placeholderUrl : void 0;
492
+ const placeholderUrl = "placeholderUrl" in current && (current.kind === "age-restricted" || current.kind === "pending" || load.value !== "error" && !(load.value === "loaded" && instant.value)) ? current.placeholderUrl : void 0;
484
493
  const notice = (children) => h("figcaption", { class: "calmlens-asset__notice" }, children);
485
494
  const video = props.video ?? {};
486
495
  const imageElement = (shown) => h("img", {
@@ -489,7 +498,7 @@ const CalmLensAsset = defineComponent({
489
498
  class: "calmlens-asset__content",
490
499
  src: shown.src,
491
500
  srcset: shown.srcSet,
492
- sizes: shown.srcSet ? props.image?.sizes : void 0,
501
+ sizes: shown.srcSet ? props.image?.sizes ?? (props.lazy ? "auto, 100vw" : "100vw") : void 0,
493
502
  alt: props.alt,
494
503
  width: shown.width,
495
504
  height: shown.height,
@@ -498,6 +507,8 @@ const CalmLensAsset = defineComponent({
498
507
  fetchpriority: props.fetchPriority,
499
508
  onLoad: () => {
500
509
  session.loaded();
510
+ if (load.value === "loaded") return;
511
+ instant.value = performance.now() - loadStartedAt < 50;
501
512
  load.value = "loaded";
502
513
  },
503
514
  onError: () => session.failed()
@@ -508,6 +519,7 @@ const CalmLensAsset = defineComponent({
508
519
  class: "calmlens-asset",
509
520
  "data-kind": current.kind,
510
521
  "data-state": load.value,
522
+ "data-instant": instant.value ? "" : void 0,
511
523
  "data-sized": ratio ? "" : void 0,
512
524
  "aria-busy": current.kind === "pending" ? "true" : void 0,
513
525
  style: {
@@ -605,4 +617,4 @@ const CalmLensAsset = defineComponent({
605
617
  };
606
618
  }
607
619
  });
608
- export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, CalmLensAsset, CalmLensDocumentViewer, CalmLensImageViewer, CalmLensSpreadsheetViewer, CalmLensTextViewer, CalmLensUploader, CalmLensWebsiteViewer, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, MediaStreamPlayer, UploadController, VIEWER_STYLES, 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, provideCalmLens, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, useCalmLensUpload, withProvidedOptions };
620
+ export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, CalmLensAsset, CalmLensDocumentViewer, CalmLensSpreadsheetViewer, CalmLensTextViewer, CalmLensUploader, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, INSTANT_LOAD_MS, MediaStreamPlayer, UploadController, VIEWER_STYLES, createDocumentViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isImageReady, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, provideCalmLens, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, useCalmLensUpload, withProvidedOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calmlens",
3
- "version": "0.27.3",
3
+ "version": "0.27.5",
4
4
  "description": "Official CalmLens SDK for JavaScript and TypeScript: content moderation, asset storage and CDN delivery.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://calmlens.com/docs/sdk/javascript",
@@ -1,7 +0,0 @@
1
- <script lang="ts">
2
- import AssetViewer from "./AssetViewer.svelte";
3
-
4
- let props = $props();
5
- </script>
6
-
7
- <AssetViewer kind="image" {...props} />
@@ -1,7 +0,0 @@
1
- <script lang="ts">
2
- import AssetViewer from "./AssetViewer.svelte";
3
-
4
- let props = $props();
5
- </script>
6
-
7
- <AssetViewer kind="website" {...props} />