calmlens 0.27.4 → 0.27.6

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 (87) hide show
  1. package/README.md +2 -2
  2. package/bin/calmlens.js +26 -15
  3. package/cjs/{BrowserUpload-CFtjSpBI.d.ts → BrowserUpload-CdOfuIcV.d.ts} +2 -2
  4. package/cjs/{BrowserUpload-Ch9y2ZDx.js → BrowserUpload-GQtZti-D.js} +1 -1
  5. package/{esm/CalmLensAppClient-DzoSqUgG.d.ts → cjs/CalmLensAppClient-Btp8f-34.d.ts} +2 -2
  6. package/cjs/{CalmLensAppClient-DGtj1vUV.js → CalmLensAppClient-Bwt3gP0C.js} +3 -3
  7. package/cjs/{CalmLensOptionKeys-DbL03fZj.js → CalmLensOptionKeys--gTpTkwt.js} +1 -1
  8. package/cjs/{CalmLensServerClient-D62AeRAi.js → CalmLensServerClient-BYMzGkQK.js} +7 -7
  9. package/cjs/{CalmLensServerClient-D3K5HS9v.d.ts → CalmLensServerClient-C3kaPLUZ.d.ts} +2 -2
  10. package/cjs/{CalmLensTypes-OWZsGvBX.d.ts → CalmLensTypes-DxxyZt2L.d.ts} +73 -5
  11. package/cjs/{Core-Cv2zLAJ-.js → Core-52DVaX7d.js} +63 -21
  12. package/{esm/Core-BXeXyiNv.d.ts → cjs/Core-Dhijt6JU.d.ts} +13 -14
  13. package/cjs/{CryptoUtils-B_x8lMIx-YBW1-bvL.js → CryptoUtils-BLCa-oZe-leCkr1ko.js} +1 -2
  14. package/cjs/{ModerationContextLimits-DjacyIkw.js → ModerationContextLimits-DJyIjzIn.js} +21 -3
  15. package/cjs/{ReactUpload-C47UrgH2.d.ts → ReactUpload-BuqLPgNr.d.ts} +1 -1
  16. package/cjs/{ReactUpload-CytoQTh_.js → ReactUpload-DHuhGYsr.js} +1 -1
  17. package/cjs/{TestTriggers-Cvi7e2KA-DcT1pc_W.js → TestTriggers-DP4m92jg-C0HD-A4r.js} +14 -14
  18. package/cjs/{UploadController-fpTC5TUO.js → UploadController-ChzDPMmm.js} +2 -2
  19. package/{esm/WebhookPayload-CrMU6lg0.d.ts → cjs/WebhookPayload-D_yWJA9M.d.ts} +5 -1
  20. package/cjs/app.d.ts +4 -4
  21. package/cjs/app.js +2 -2
  22. package/cjs/elements.d.ts +8 -19
  23. package/cjs/elements.js +45 -53
  24. package/cjs/{index-BDxmVi-G.d.ts → index-CUA-HDNu.d.ts} +2 -2
  25. package/cjs/index.d.ts +3 -3
  26. package/cjs/index.js +1 -1
  27. package/cjs/react-native.d.ts +3 -3
  28. package/cjs/react-native.js +6 -4
  29. package/cjs/react.d.ts +5 -11
  30. package/cjs/react.js +29 -36
  31. package/cjs/server.d.ts +4 -4
  32. package/cjs/server.js +2 -2
  33. package/cjs/test-inputs.js +13 -13
  34. package/cjs/testing.d.ts +4 -4
  35. package/cjs/testing.js +54 -32
  36. package/cjs/{ui-5IdEYYpC.d.ts → ui-BSm_qphN.d.ts} +3 -9
  37. package/cjs/{ui-BvyDbJBb.js → ui-C1_SDSiq.js} +2 -201
  38. package/cjs/ui.d.ts +3 -3
  39. package/cjs/ui.js +5 -5
  40. package/cjs/vue.d.ts +6 -319
  41. package/cjs/vue.js +27 -17
  42. package/esm/{BrowserUpload-BE8OVeBC.js → BrowserUpload-BaKFKEBz.js} +1 -1
  43. package/esm/{BrowserUpload-CFtjSpBI.d.ts → BrowserUpload-CdOfuIcV.d.ts} +2 -2
  44. package/{cjs/CalmLensAppClient-DzoSqUgG.d.ts → esm/CalmLensAppClient-Btp8f-34.d.ts} +2 -2
  45. package/esm/{CalmLensAppClient-C1cpQEYR.js → CalmLensAppClient-DM6c3pGC.js} +3 -3
  46. package/esm/{CalmLensOptionKeys-DoCKKuLT.js → CalmLensOptionKeys-CKZs8i3_.js} +1 -1
  47. package/esm/{CalmLensServerClient-D3K5HS9v.d.ts → CalmLensServerClient-C3kaPLUZ.d.ts} +2 -2
  48. package/esm/{CalmLensServerClient-CSCrJ7wX.js → CalmLensServerClient-Da2UfUo4.js} +3 -3
  49. package/esm/{CalmLensTypes-OWZsGvBX.d.ts → CalmLensTypes-DxxyZt2L.d.ts} +73 -5
  50. package/{cjs/Core-BXeXyiNv.d.ts → esm/Core-Dhijt6JU.d.ts} +13 -14
  51. package/esm/{Core-Df2PSa1n.js → Core-kYMRW5C1.js} +52 -22
  52. package/esm/{CryptoUtils-B_x8lMIx-DhuWGzqn.js → CryptoUtils-BLCa-oZe-DKr3LmN6.js} +1 -2
  53. package/esm/{ModerationContextLimits-tu_PY4fn.js → ModerationContextLimits-ZIlK9n2X.js} +21 -3
  54. package/esm/{ReactUpload-C47UrgH2.d.ts → ReactUpload-BuqLPgNr.d.ts} +1 -1
  55. package/esm/{ReactUpload-BsbisXS6.js → ReactUpload-CipY3cmO.js} +1 -1
  56. package/esm/{TestTriggers-Cvi7e2KA-BA83CRJb.js → TestTriggers-DP4m92jg-DhOI4S1V.js} +11 -11
  57. package/esm/{UploadController-Dqjf23bS.js → UploadController-D-14HWII.js} +2 -2
  58. package/{cjs/WebhookPayload-CrMU6lg0.d.ts → esm/WebhookPayload-D_yWJA9M.d.ts} +5 -1
  59. package/esm/app.d.ts +4 -4
  60. package/esm/app.js +2 -2
  61. package/esm/elements.d.ts +8 -19
  62. package/esm/elements.js +44 -50
  63. package/esm/{index-BDxmVi-G.d.ts → index-CUA-HDNu.d.ts} +2 -2
  64. package/esm/index.d.ts +3 -3
  65. package/esm/index.js +1 -1
  66. package/esm/react-native.d.ts +3 -3
  67. package/esm/react-native.js +5 -5
  68. package/esm/react.d.ts +5 -11
  69. package/esm/react.js +29 -34
  70. package/esm/server.d.ts +4 -4
  71. package/esm/server.js +2 -2
  72. package/esm/styles.css +12 -16
  73. package/esm/svelte/CalmLensAsset.svelte +22 -4
  74. package/esm/svelte/index.d.ts +0 -6
  75. package/esm/svelte/index.js +0 -2
  76. package/esm/test-inputs.js +1 -1
  77. package/esm/testing.d.ts +4 -4
  78. package/esm/testing.js +45 -23
  79. package/esm/{ui-5IdEYYpC.d.ts → ui-BSm_qphN.d.ts} +3 -9
  80. package/esm/{ui-DF7-9mB3.js → ui-CgIG3knW.js} +3 -190
  81. package/esm/ui.d.ts +3 -3
  82. package/esm/ui.js +4 -4
  83. package/esm/vue.d.ts +6 -319
  84. package/esm/vue.js +26 -14
  85. package/package.json +1 -1
  86. package/esm/svelte/CalmLensImageViewer.svelte +0 -7
  87. package/esm/svelte/CalmLensWebsiteViewer.svelte +0 -7
package/esm/server.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as ClassificationNotEvaluatedReason, c as ModerationQualifier, d as HashListEntry, f as ModerationContext, g as selectModerationContextItems, h as ModerationContextItem, i as ClassificationCategoryReport, l as PolicyAction, m as MODERATION_CONTEXT_USED_ITEMS, n as ClassificationCategories, o as ClassificationQualifierResults, p as MODERATION_CONTEXT_USED_CHARACTERS, r as ClassificationCategory, s as Likelihood, u as HashList } from "./Classification-CMM2tZpJ-IdIh63n0.js";
2
- import { $ as FolderPage, $t as VerifyWebhookSignatureOptions, A as CdnAssetLocation, An as Policy, At as RetrieveAssetOptions, B as CreateHashListOptions, Bn as AssetRendered, Bt as UpdateAssetOptions, C as AssetUploadStatus, Cn as BoundingBox, Ct as MultipartUploadPartOptions, D as BatchAssetsResponse, Dn as ProcessingFeatureResults, Dt as RequestAttempt, E as BatchAssetsOptions, En as ProcessingFeatureId, Et as RemoveAssetContentOptions, F as CdnTransform, Ft as SignUploadTokenOptions, G as DeleteAssetOptions, Gn as FileMetadata, Gt as UpdateProjectSettingsOptions, H as CreateMultipartUploadPartOptions, Hn as AssetSafetyHold, Ht as UpdateHashListOptions, I as ClassifyTextOptions, In as AssetInfo, It as SignedAssetUrl, J as EnsureLensesOptions, Jt as UploadPresetDefinition, K as DeleteMetadataFieldOptions, Kn as MetadataItem, Kt as UpgradePolicyOptions, L as ClientRequestDefaults, Ln as AssetHls, Lt as SignedUploadToken, M as CdnAssetUrlOptions, Mn as LensType, Mt as SearchAssetsOptions, N as CdnResource, Nn as AssetSearchMatchField, Nt as SetPolicyAutomaticUpdatesOptions, O as CalmLensAppClientOptions, On as ProcessingFeatureStage, Ot as RequestOptions, P as CdnServeOptions, Pn as AssetSearchQuery, Pt as SignAssetUrlOptions, Q as FolderIdOptions, Qt as UploadedAsset, R as ConnectionOptions, Rn as AssetHlsRendition, Rt as StreamingFeatureOptions, S as AssetUpload, Sn as AgeRange, St as MultipartUploadOptions, T as AssignPolicyOptions, Tn as DetectedPerson, Tt as PolicyPage, U as CreatePolicyOptions, Un as AssetSafetyHoldReason, Ut as UpdateLensOptions, V as CreateLensOptions, Vn as AssetRenderedKind, Vt as UpdateFolderOptions, W as DecideAssetOptions, Wn as ExtractedText, Wt as UpdatePolicyOptions, X as EnsureUploadPresetsOptions, Xt as UploadPresetPage, Y as EnsureMetadataFieldsOptions, Yt as UploadPresetIdOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetSubmitAssetOptions, _ as AssetPage, _n as Folder, _t as ListLensesOptions, a as AssetChecksums, an as AssetTimelineSegment, at as IdempotencyOptions, b as AssetTimelinePage, bn as PublicProjectSettings, bt as MoveAssetOptions, c as AssetClassificationFailureReason, cn as EventAsset, ct as LensIdOptions, d as AssetContentOptions, dn as EventFact, dt as ListAssetTimelineOptions, en as ViewerClaims, et as GetAssetInfoOptions, f as AssetContentRemovalReason, fn as EventFactValues, ft as ListAssetsOptions, g as AssetModerationStatus, gt as ListHashListsOptions, h as AssetModerationDecision, hn as EventType, ht as ListHashListEntriesOptions, i as AssetAvailability, in as AssetBatchOperation, it as HashListPage, j as CdnAssetReference, jn as CursorPage, jt as RetryAssetOptions, k as CalmLensServerClientOptions, kn as ProcessingFeatures, kt as ResetPolicyOptions, l as AssetClassificationStatus, ln as TypedEvent, lt as LensPage, m as AssetModeration, mn as EventSeverity, mt as ListFoldersOptions, n as AppInfo, nn as WebhookHeadersInput, nt as HashListEntryPage, o as AssetChildrenPage, on as GetEventsResponse, ot as ImageTransformOptions, p as AssetContentStatus, pn as EventFacts, pt as ListEventsOptions, q as EnsureLensOptions, qn as ProcessingOptions, qt as UploadAssetPartOptions, r as Asset, rn as WebhookPayloadInput, rt as HashListIdOptions, s as AssetClassification, st as Lens, t as AddHashListEntryOptions, tn as WaitForAssetDecisionOptions, tt as HashListEntryIdOptions, u as AssetContent, un as EventCategory, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vn as MetadataFieldsResource, vt as ListPoliciesOptions, w as AssetVisibility, wn as DetectedFace, wt as PolicyIdOptions, x as AssetType, xn as UploadPreset, xt as MoveFolderOptions, y as AssetSearchResult, yn as ProjectSettingsResource, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zn as AssetPreview, zt as SubmitAssetOptions } from "./CalmLensTypes-OWZsGvBX.js";
3
- import { i as getAssetInfo, n as DEFAULT_CDN_BASE_URL, r as CDN_RESOURCES, t as SDK_VERSION } from "./index-BDxmVi-G.js";
4
- import { A as CalmLensRateLimitError, C as CalmLensErrorKind, D as CalmLensNotFoundError, E as CalmLensInvalidResponseError, F as SdkErrorCode, I as ApiErrorCode, M as CalmLensTimeoutError, N as CalmLensUnprocessableEntityError, O as CalmLensPayloadTooLargeError, P as CalmLensWebhookVerificationError, S as CalmLensErrorDetails, T as CalmLensInvalidArgumentError, _ as CalmLensConfigurationError, a as AUTO_PAGING_TO_ARRAY_MAX, b as CalmLensError, c as CalmLensLastResponse, d as ListPromise, f as CALMLENS_ERROR_CODES, g as CalmLensCancelledError, h as CalmLensBadRequestError, i as ServedAssetInfo, j as CalmLensServerError, k as CalmLensPermissionDeniedError, l as CalmLensResponse, m as CalmLensAuthenticationError, o as AutoPaging, p as CalmLensApiError, r as CdnResponse, s as AutoPagingToArrayOptions, t as ReceivedWebhookEventPayload, u as ListPage, v as CalmLensConflictError, w as CalmLensErrorOptions, x as CalmLensErrorCode, y as CalmLensConnectionError } from "./WebhookPayload-CrMU6lg0.js";
5
- import { t as CalmLensServerClient } from "./CalmLensServerClient-D3K5HS9v.js";
2
+ import { $ as FolderPage, $t as VerifyWebhookSignatureOptions, A as CdnAssetLocation, An as Policy, At as RetrieveAssetOptions, B as CreateHashListOptions, Bn as AssetRendered, Bt as UpdateAssetOptions, C as AssetUploadStatus, Cn as BoundingBox, Ct as MultipartUploadPartOptions, D as BatchAssetsResponse, Dn as ProcessingFeatureResults, Dt as RequestAttempt, E as BatchAssetsOptions, En as ProcessingFeatureId, Et as RemoveAssetContentOptions, F as CdnTransform, Ft as SignUploadTokenOptions, G as DeleteAssetOptions, Gn as FileMetadata, Gt as UpdateProjectSettingsOptions, H as CreateMultipartUploadPartOptions, Hn as AssetSafetyHold, Ht as UpdateHashListOptions, I as ClassifyTextOptions, In as AssetInfo, It as SignedAssetUrl, J as EnsureLensesOptions, Jt as UploadPresetDefinition, K as DeleteMetadataFieldOptions, Kn as MetadataItem, Kt as UpgradePolicyOptions, L as ClientRequestDefaults, Ln as AssetHls, Lt as SignedUploadToken, M as CdnAssetUrlOptions, Mn as LensType, Mt as SearchAssetsOptions, N as CdnResource, Nn as AssetSearchMatchField, Nt as SetPolicyAutomaticUpdatesOptions, O as CalmLensAppClientOptions, On as ProcessingFeatureStage, Ot as RequestOptions, P as CdnServeOptions, Pn as AssetSearchQuery, Pt as SignAssetUrlOptions, Q as FolderIdOptions, Qt as UploadedAsset, R as ConnectionOptions, Rn as AssetHlsRendition, Rt as StreamingFeatureOptions, S as AssetUpload, Sn as AgeRange, St as MultipartUploadOptions, T as AssignPolicyOptions, Tn as DetectedPerson, Tt as PolicyPage, U as CreatePolicyOptions, Un as AssetSafetyHoldReason, Ut as UpdateLensOptions, V as CreateLensOptions, Vn as AssetRenderedKind, Vt as UpdateFolderOptions, W as DecideAssetOptions, Wn as ExtractedText, Wt as UpdatePolicyOptions, X as EnsureUploadPresetsOptions, Xt as UploadPresetPage, Y as EnsureMetadataFieldsOptions, Yt as UploadPresetIdOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetSubmitAssetOptions, _ as AssetPage, _n as Folder, _t as ListLensesOptions, a as AssetChecksums, an as AssetTimelineSegment, at as IdempotencyOptions, b as AssetTimelinePage, bn as PublicProjectSettings, bt as MoveAssetOptions, c as AssetClassificationFailureReason, cn as EventAsset, ct as LensIdOptions, d as AssetContentOptions, dn as EventFact, dt as ListAssetTimelineOptions, en as ViewerClaims, et as GetAssetInfoOptions, f as AssetContentRemovalReason, fn as EventFactValues, ft as ListAssetsOptions, g as AssetModerationStatus, gt as ListHashListsOptions, h as AssetModerationDecision, hn as EventType, ht as ListHashListEntriesOptions, i as AssetAvailability, in as AssetBatchOperation, it as HashListPage, j as CdnAssetReference, jn as CursorPage, jt as RetryAssetOptions, k as CalmLensServerClientOptions, kn as ProcessingFeatures, kt as ResetPolicyOptions, l as AssetClassificationStatus, ln as TypedEvent, lt as LensPage, m as AssetModeration, mn as EventSeverity, mt as ListFoldersOptions, n as AppInfo, nn as WebhookHeadersInput, nt as HashListEntryPage, o as AssetChildrenPage, on as GetEventsResponse, ot as ImageTransformOptions, p as AssetContentStatus, pn as EventFacts, pt as ListEventsOptions, q as EnsureLensOptions, qn as ProcessingOptions, qt as UploadAssetPartOptions, r as Asset, rn as WebhookPayloadInput, rt as HashListIdOptions, s as AssetClassification, st as Lens, t as AddHashListEntryOptions, tn as WaitForAssetDecisionOptions, tt as HashListEntryIdOptions, u as AssetContent, un as EventCategory, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vn as MetadataFieldsResource, vt as ListPoliciesOptions, w as AssetVisibility, wn as DetectedFace, wt as PolicyIdOptions, x as AssetType, xn as UploadPreset, xt as MoveFolderOptions, y as AssetSearchResult, yn as ProjectSettingsResource, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zn as AssetPreview, zt as SubmitAssetOptions } from "./CalmLensTypes-DxxyZt2L.js";
3
+ import { i as getAssetInfo, n as DEFAULT_CDN_BASE_URL, r as CDN_RESOURCES, t as SDK_VERSION } from "./index-CUA-HDNu.js";
4
+ import { A as CalmLensRateLimitError, C as CalmLensErrorKind, D as CalmLensNotFoundError, E as CalmLensInvalidResponseError, F as SdkErrorCode, I as ApiErrorCode, M as CalmLensTimeoutError, N as CalmLensUnprocessableEntityError, O as CalmLensPayloadTooLargeError, P as CalmLensWebhookVerificationError, S as CalmLensErrorDetails, T as CalmLensInvalidArgumentError, _ as CalmLensConfigurationError, a as AUTO_PAGING_TO_ARRAY_MAX, b as CalmLensError, c as CalmLensLastResponse, d as ListPromise, f as CALMLENS_ERROR_CODES, g as CalmLensCancelledError, h as CalmLensBadRequestError, i as ServedAssetInfo, j as CalmLensServerError, k as CalmLensPermissionDeniedError, l as CalmLensResponse, m as CalmLensAuthenticationError, o as AutoPaging, p as CalmLensApiError, r as CdnResponse, s as AutoPagingToArrayOptions, t as ReceivedWebhookEventPayload, u as ListPage, v as CalmLensConflictError, w as CalmLensErrorOptions, x as CalmLensErrorCode, y as CalmLensConnectionError } from "./WebhookPayload-D_yWJA9M.js";
5
+ import { t as CalmLensServerClient } from "./CalmLensServerClient-C3kaPLUZ.js";
6
6
  export declare const WEBHOOK_DELIVERY_HEADER = "x-calmlens-delivery";
7
7
  export declare const WEBHOOK_TIMESTAMP_HEADER = "x-calmlens-timestamp";
8
8
  export declare const WEBHOOK_SIGNATURE_HEADER = "x-calmlens-signature";
package/esm/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as CalmLensPayloadTooLargeError, G as CalmLensCancelledError, H as CalmLensApiError, I as AUTO_PAGING_TO_ARRAY_MAX, J as CalmLensConnectionError, K as CalmLensConfigurationError, N as SDK_VERSION, Q as CalmLensNotFoundError, U as CalmLensAuthenticationError, V as CALMLENS_ERROR_CODES, W as CalmLensBadRequestError, X as CalmLensInvalidArgumentError, Y as CalmLensError, Z as CalmLensInvalidResponseError, at as CalmLensWebhookVerificationError, et as CalmLensPermissionDeniedError, i as CDN_RESOURCES, it as CalmLensUnprocessableEntityError, n as MODERATION_CONTEXT_USED_ITEMS, nt as CalmLensServerError, q as CalmLensConflictError, r as selectModerationContextItems, rt as CalmLensTimeoutError, s as getAssetInfo, t as MODERATION_CONTEXT_USED_CHARACTERS, tt as CalmLensRateLimitError, u as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-tu_PY4fn.js";
1
+ import { $ as CalmLensPayloadTooLargeError, G as CalmLensCancelledError, H as CalmLensApiError, I as AUTO_PAGING_TO_ARRAY_MAX, J as CalmLensConnectionError, K as CalmLensConfigurationError, N as SDK_VERSION, Q as CalmLensNotFoundError, U as CalmLensAuthenticationError, V as CALMLENS_ERROR_CODES, W as CalmLensBadRequestError, X as CalmLensInvalidArgumentError, Y as CalmLensError, Z as CalmLensInvalidResponseError, at as CalmLensWebhookVerificationError, et as CalmLensPermissionDeniedError, i as CDN_RESOURCES, it as CalmLensUnprocessableEntityError, n as MODERATION_CONTEXT_USED_ITEMS, nt as CalmLensServerError, q as CalmLensConflictError, r as selectModerationContextItems, rt as CalmLensTimeoutError, s as getAssetInfo, t as MODERATION_CONTEXT_USED_CHARACTERS, tt as CalmLensRateLimitError, u as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-ZIlK9n2X.js";
2
2
  import "./index.js";
3
- import { a as WEBHOOK_TIMESTAMP_HEADER, c as isNewerAssetEvent, d as verifyWebhookSignature, i as WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, l as isTestWebhookEvent, n as WEBHOOK_DELIVERY_HEADER, o as getEventFact, r as WEBHOOK_SIGNATURE_HEADER, s as getEventFacts, t as CalmLensServerClient, u as parseWebhookEvent } from "./CalmLensServerClient-CSCrJ7wX.js";
3
+ import { a as WEBHOOK_TIMESTAMP_HEADER, c as isNewerAssetEvent, d as verifyWebhookSignature, i as WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, l as isTestWebhookEvent, n as WEBHOOK_DELIVERY_HEADER, o as getEventFact, r as WEBHOOK_SIGNATURE_HEADER, s as getEventFacts, t as CalmLensServerClient, u as parseWebhookEvent } from "./CalmLensServerClient-Da2UfUo4.js";
4
4
  export { AUTO_PAGING_TO_ARRAY_MAX, CALMLENS_ERROR_CODES, CDN_RESOURCES, CalmLensApiError, CalmLensAuthenticationError, CalmLensBadRequestError, CalmLensCancelledError, CalmLensConfigurationError, CalmLensConflictError, CalmLensConnectionError, CalmLensError, CalmLensInvalidArgumentError, CalmLensInvalidResponseError, CalmLensNotFoundError, CalmLensPayloadTooLargeError, CalmLensPermissionDeniedError, CalmLensRateLimitError, CalmLensServerClient, CalmLensServerError, CalmLensTimeoutError, CalmLensUnprocessableEntityError, CalmLensWebhookVerificationError, DEFAULT_CDN_BASE_URL, MODERATION_CONTEXT_USED_CHARACTERS, MODERATION_CONTEXT_USED_ITEMS, SDK_VERSION, WEBHOOK_DELIVERY_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, WEBHOOK_TIMESTAMP_HEADER, getAssetInfo, getEventFact, getEventFacts, isNewerAssetEvent, isTestWebhookEvent, parseWebhookEvent, selectModerationContextItems, verifyWebhookSignature };
package/esm/styles.css CHANGED
@@ -123,7 +123,7 @@
123
123
  }
124
124
  .calmlens-icon-button:hover { background: color-mix(in srgb, var(--calmlens-accent) 8%, transparent); border-color: var(--calmlens-border); }
125
125
  @media (prefers-reduced-motion: reduce) {
126
- .calmlens-dropzone, .calmlens-dropzone__icon, .calmlens-asset__content { transition: none; }
126
+ .calmlens-dropzone, .calmlens-dropzone__icon { transition: none; }
127
127
  .calmlens-progress:indeterminate {
128
128
  --calmlens-progress-animation: calmlens-indeterminate-still 1s both;
129
129
  }
@@ -142,9 +142,17 @@
142
142
  .calmlens-asset:not([data-sized]) .calmlens-asset__content { position: relative; height: auto; }
143
143
  .calmlens-asset:not([data-sized])[data-kind="age-restricted"], .calmlens-asset:not([data-sized])[data-kind="unavailable"],
144
144
  .calmlens-asset:not([data-sized])[data-state="error"] { min-height: 160px; }
145
- .calmlens-asset__placeholder { transform: scale(1.1); filter: blur(12px); }
146
- .calmlens-asset__content { opacity: 0; transition: opacity 250ms; }
145
+ .calmlens-asset__placeholder { transform: scale(1.1); filter: blur(12px); opacity: 1; pointer-events: none; }
146
+ .calmlens-asset__content { opacity: 0; }
147
147
  .calmlens-asset[data-state="loaded"] .calmlens-asset__content { opacity: 1; }
148
+ .calmlens-asset[data-state="loaded"]:not([data-kind="age-restricted"]) .calmlens-asset__placeholder { opacity: 0; visibility: hidden; }
149
+ @media (prefers-reduced-motion: no-preference) {
150
+ .calmlens-asset[data-state="loaded"]:not([data-instant]) { transition: background-color 250ms; }
151
+ .calmlens-asset[data-state="loaded"]:not([data-instant]) .calmlens-asset__content { transition: opacity 250ms; }
152
+ .calmlens-asset[data-state="loaded"]:not([data-kind="age-restricted"], [data-instant]) .calmlens-asset__placeholder {
153
+ transition: opacity 250ms, visibility 0s linear 250ms;
154
+ }
155
+ }
148
156
  .calmlens-asset[data-kind="video"] .calmlens-asset__content, .calmlens-asset[data-kind="audio"] .calmlens-asset__content { opacity: 1; }
149
157
  /* Documents, text and spreadsheets fill the box with their viewer; a document shows its first
150
158
  page's still and an open link until the viewer loads. */
@@ -215,7 +223,7 @@
215
223
  /* An opaque surface of its own, so sticky headers and the toolbar cover what scrolls under them. */
216
224
  background: var(--calmlens-viewer-background, Canvas); color: var(--calmlens-viewer-text, CanvasText);
217
225
  }
218
- .calmlens-viewer:is([data-kind="text"], [data-kind="document"], [data-kind="spreadsheet"], [data-kind="website"]) > .calmlens-viewer__frame { min-height: 320px; }
226
+ .calmlens-viewer:is([data-kind="text"], [data-kind="document"], [data-kind="spreadsheet"]) > .calmlens-viewer__frame { min-height: 320px; }
219
227
  .calmlens-viewer :focus-visible {
220
228
  outline: 2px solid var(--calmlens-focus-ring); outline-offset: -2px;
221
229
  }
@@ -236,18 +244,6 @@
236
244
  .calmlens-viewer__spacer { flex: 1; }
237
245
  .calmlens-viewer__link { text-decoration: none; overflow-wrap: anywhere; }
238
246
  .calmlens-viewer__scroll { flex: 1; min-height: 0; overflow: auto; position: relative; }
239
- /* Images fit inside the frame, keeping their shape; without a frame height, the box takes it. */
240
- .calmlens-viewer[data-kind="image"] > .calmlens-viewer__frame { aspect-ratio: var(--calmlens-viewer-ratio, auto); max-height: 100%; }
241
- .calmlens-viewer[data-kind="image"] > .calmlens-viewer__frame > img {
242
- position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
243
- }
244
- .calmlens-viewer:not([data-kind="image"]) .calmlens-viewer__placeholder {
245
- position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top;
246
- }
247
- .calmlens-viewer__placeholder { filter: blur(12px); transform: scale(1.05); }
248
- .calmlens-viewer__image { opacity: 0; transition: opacity 250ms; }
249
- .calmlens-viewer[data-state="loaded"] .calmlens-viewer__image { opacity: 1; }
250
- .calmlens-viewer[data-kind="website"] .calmlens-viewer__image { position: relative; display: block; width: 100%; height: auto; }
251
247
  .calmlens-viewer__text {
252
248
  margin: 0 auto; padding: 20px 24px; max-width: 75ch; white-space: pre-wrap; overflow-wrap: anywhere;
253
249
  font-family: inherit; font-size: 1rem; line-height: 1.6;
@@ -14,6 +14,8 @@
14
14
  getMountedViewerOptions,
15
15
  getPeakHeights,
16
16
  getPlayedPercent,
17
+ INSTANT_LOAD_MS,
18
+ isImageReady,
17
19
  isMountedViewerKind,
18
20
  MediaStreamPlayer,
19
21
  resolveMessages,
@@ -75,6 +77,8 @@
75
77
  const loadKey = $derived(getAssetViewKey(view));
76
78
  const ratio = $derived(getAssetAspectRatio(view, sessionState.info, aspectRatio));
77
79
  let load: "loading" | "loaded" | "error" = $state("loading");
80
+ let instant = $state(false);
81
+ let loadStartedAt = 0;
78
82
  let played = $state(0);
79
83
  let mounted = $state(false);
80
84
  let image: HTMLImageElement | undefined = $state();
@@ -109,8 +113,6 @@
109
113
  });
110
114
  onMount(() => {
111
115
  mounted = true;
112
- // An image that loaded before hydration fires no load event.
113
- if (image?.complete && image.naturalWidth > 0) load = "loaded";
114
116
  return () => {
115
117
  streams.stop();
116
118
  viewers.destroy();
@@ -119,6 +121,17 @@
119
121
  $effect.pre(() => {
120
122
  void loadKey;
121
123
  load = "loading";
124
+ instant = false;
125
+ });
126
+ $effect(() => {
127
+ void loadKey;
128
+ if (!image) return;
129
+ loadStartedAt = performance.now();
130
+ // An image that loaded before hydration or from the browser cache shows without fading.
131
+ if (isImageReady(image)) {
132
+ instant = true;
133
+ load = "loaded";
134
+ }
122
135
  });
123
136
  $effect(() => {
124
137
  if (load === "loaded") onLoad?.();
@@ -152,11 +165,15 @@
152
165
  };
153
166
  const onImageLoad = () => {
154
167
  session.loaded();
168
+ if (load === "loaded") return;
169
+ instant = performance.now() - loadStartedAt < INSTANT_LOAD_MS;
155
170
  load = "loaded";
156
171
  };
157
172
  const placeholderUrl = $derived(
158
173
  "placeholderUrl" in view &&
159
- (view.kind === "age-restricted" || view.kind === "pending" || load !== "loaded")
174
+ (view.kind === "age-restricted" ||
175
+ view.kind === "pending" ||
176
+ (load !== "error" && !(load === "loaded" && instant)))
160
177
  ? view.placeholderUrl
161
178
  : undefined,
162
179
  );
@@ -172,7 +189,7 @@
172
189
  class="calmlens-asset__content"
173
190
  src={shown.src}
174
191
  srcset={shown.srcSet}
175
- sizes={shown.srcSet ? imageOptions?.sizes : undefined}
192
+ sizes={shown.srcSet ? (imageOptions?.sizes ?? (lazy ? "auto, 100vw" : "100vw")) : undefined}
176
193
  {alt}
177
194
  width={shown.width}
178
195
  height={shown.height}
@@ -189,6 +206,7 @@
189
206
  class="calmlens-asset"
190
207
  data-kind={view.kind}
191
208
  data-state={load}
209
+ data-instant={instant ? "" : undefined}
192
210
  data-sized={ratio ? "" : undefined}
193
211
  aria-busy={view.kind === "pending" ? "true" : undefined}
194
212
  style:aspect-ratio={ratio}
@@ -8,12 +8,10 @@ import type {
8
8
  UploadItem as CoreUploadItem,
9
9
  UploadSnapshot as CoreUploadSnapshot,
10
10
  DocumentViewerOptions,
11
- ImageViewerOptions,
12
11
  SpreadsheetViewerOptions,
13
12
  TextViewerOptions,
14
13
  UploadController,
15
14
  UploadFile,
16
- WebsiteViewerOptions,
17
15
  } from "../ui.js";
18
16
 
19
17
  // The browser's files are `File`s, so the upload types default to `File` here.
@@ -58,10 +56,6 @@ export declare const CalmLensAsset: Component<
58
56
  }
59
57
  >;
60
58
 
61
- /** Shows an image asset's rendered file, fitted to the element, over its placeholder (preview). */
62
- export declare const CalmLensImageViewer: Component<ImageViewerOptions>;
63
- /** Shows a website asset's screenshot with a link to the original page (preview). */
64
- export declare const CalmLensWebsiteViewer: Component<WebsiteViewerOptions>;
65
59
  /** Shows a text asset's text, escaped, in a scrolling region (preview). */
66
60
  export declare const CalmLensTextViewer: Component<TextViewerOptions>;
67
61
  /** Shows a PDF, or a document rendered as one, a page at a time with pdf.js (preview). */
@@ -4,9 +4,7 @@
4
4
  export * from "../ui.js";
5
5
  export { default as CalmLensAsset } from "./CalmLensAsset.svelte";
6
6
  export { default as CalmLensDocumentViewer } from "./CalmLensDocumentViewer.svelte";
7
- export { default as CalmLensImageViewer } from "./CalmLensImageViewer.svelte";
8
7
  export { default as CalmLensSpreadsheetViewer } from "./CalmLensSpreadsheetViewer.svelte";
9
8
  export { default as CalmLensTextViewer } from "./CalmLensTextViewer.svelte";
10
9
  export { default as CalmLensUploader } from "./CalmLensUploader.svelte";
11
- export { default as CalmLensWebsiteViewer } from "./CalmLensWebsiteViewer.svelte";
12
10
  export { getCalmLensContext, setCalmLensContext } from "./context.js";
@@ -1 +1 @@
1
- export { t as TEST_DETECTIONS_MAX, n as TEST_DETECTION_BOX_MAX, r as TEST_FACE_AGE_MAX, i as TEST_FACE_AGE_PRESETS, a as TEST_INPUT_KEY_PATTERN, o as TEST_INPUT_PRESETS, s as detectTestImage, c as detectTestTrigger, l as generateTestTextCode, u as getImageTestCategories, f as paintTestImage, p as testInputForSignal } from "./TestTriggers-Cvi7e2KA-BA83CRJb.js";
1
+ export { t as TEST_DETECTIONS_MAX, n as TEST_DETECTION_BOX_MAX, r as TEST_FACE_AGE_MAX, i as TEST_FACE_AGE_PRESETS, a as TEST_INPUT_KEY_PATTERN, o as TEST_INPUT_PRESETS, s as detectTestImage, c as detectTestTrigger, l as generateTestTextCode, u as getImageTestCategories, f as paintTestImage, p as testInputForSignal } from "./TestTriggers-DP4m92jg-DhOI4S1V.js";
package/esm/testing.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Fn as AssetBinaryPayloadInput, Ft as SignUploadTokenOptions, Lt as SignedUploadToken, O as CalmLensAppClientOptions, _n as Folder, gn as PermissionGrant, k as CalmLensServerClientOptions, ln as TypedEvent, m as AssetModeration, r as Asset } from "./CalmLensTypes-OWZsGvBX.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-DzoSqUgG.js";
3
- import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-CrMU6lg0.js";
4
- import { t as CalmLensServerClient } from "./CalmLensServerClient-D3K5HS9v.js";
1
+ import { Fn as AssetBinaryPayloadInput, Ft as SignUploadTokenOptions, Lt as SignedUploadToken, O as CalmLensAppClientOptions, _n as Folder, gn as PermissionGrant, k as CalmLensServerClientOptions, ln as TypedEvent, m as AssetModeration, r as Asset } from "./CalmLensTypes-DxxyZt2L.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-Btp8f-34.js";
3
+ import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-D_yWJA9M.js";
4
+ import { t as CalmLensServerClient } from "./CalmLensServerClient-C3kaPLUZ.js";
5
5
  import { t as ClassificationTestSignal } from "./TestTriggers-Dnukm-jm-DoEB7jJc.js";
6
6
  import "zod";
7
7
  /**
package/esm/testing.js CHANGED
@@ -1,10 +1,10 @@
1
- import { A as normalizeUploadMimeType, D as MAX_IMAGE_UPLOAD_BYTES, M as sleep, S as validateAppClientOptions, Y as CalmLensError, _ as randomUuid, ct as invalidConfig, f as checkTransformOptions, h as parseTransformSelector, k as getRejectedUploadMimeTypeError, lt as API_ERROR_CODES, m as isAcceptedUploadMimeType, ot as SDK_ERROR_CODES, r as selectModerationContextItems, st as invalidArgument, ut as API_ERROR_DEFINITIONS, w as validateServerClientOptions } from "./ModerationContextLimits-tu_PY4fn.js";
2
- import { a as WEBHOOK_TIMESTAMP_HEADER, f as signUploadTokenWithApiKey, m as stringifyJsonCanonical, n as WEBHOOK_DELIVERY_HEADER, p as decodeUploadToken, r as WEBHOOK_SIGNATURE_HEADER, t as CalmLensServerClient } from "./CalmLensServerClient-CSCrJ7wX.js";
3
- import { _ as validateAssetPayload, a as MOCK_HOOKS, g as assetToData, h as assetDataToUint8Array } from "./CalmLensOptionKeys-DoCKKuLT.js";
4
- import { t as hmacSha256Hex } from "./CryptoUtils-B_x8lMIx-DhuWGzqn.js";
5
- import { t as CalmLensAppClient } from "./CalmLensAppClient-C1cpQEYR.js";
6
- import { o as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-Dqjf23bS.js";
7
- import { d as getTestInputTag, h as CLASSIFICATION_CATEGORIES, m as lazySchema } from "./TestTriggers-Cvi7e2KA-BA83CRJb.js";
1
+ import { A as normalizeUploadMimeType, D as MAX_IMAGE_UPLOAD_BYTES, M as sleep, S as validateAppClientOptions, Y as CalmLensError, _ as randomUuid, ct as invalidConfig, f as checkTransformOptions, h as parseTransformSelector, k as getRejectedUploadMimeTypeError, lt as API_ERROR_CODES, m as isAcceptedUploadMimeType, ot as SDK_ERROR_CODES, r as selectModerationContextItems, st as invalidArgument, ut as API_ERROR_DEFINITIONS, w as validateServerClientOptions } from "./ModerationContextLimits-ZIlK9n2X.js";
2
+ import { a as WEBHOOK_TIMESTAMP_HEADER, f as signUploadTokenWithApiKey, m as stringifyJsonCanonical, n as WEBHOOK_DELIVERY_HEADER, p as decodeUploadToken, r as WEBHOOK_SIGNATURE_HEADER, t as CalmLensServerClient } from "./CalmLensServerClient-Da2UfUo4.js";
3
+ import { _ as validateAssetPayload, a as MOCK_HOOKS, g as assetToData, h as assetDataToUint8Array } from "./CalmLensOptionKeys-CKZs8i3_.js";
4
+ import { t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
5
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-DM6c3pGC.js";
6
+ import { o as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-D-14HWII.js";
7
+ import { d as getTestInputTag, h as CLASSIFICATION_CATEGORIES, m as lazySchema } from "./TestTriggers-DP4m92jg-DhOI4S1V.js";
8
8
  import * as zod from "zod";
9
9
  // src/contract/MediaTestTriggers.js
10
10
  const MEDIA_TEST_SIGNALS = [...CLASSIFICATION_CATEGORIES, "violence.graphic"];
@@ -31,7 +31,19 @@ async function generateMediaTestCode(signal, testInputKey) {
31
31
  if (!MEDIA_TEST_SIGNALS.includes(signal)) throw new RangeError("Unsupported media test signal");
32
32
  return `Calm Lens test ${[...await getTestInputTag("media", signal, testInputKey)].map((character) => HEX_WORDS[Number.parseInt(character, 16)]).join(" ")} ${signal.replace(/[.-]/g, " ")} end test`;
33
33
  }
34
- // src/contract/Ids-C2cLdFM0.js
34
+ /**
35
+ * The character an asset ID starts with (after `asset_`) to say the region it lives in: the asset
36
+ * table computes each row's region from it (`AssetTable`), so an ID is only ever in one region and
37
+ * a lookup by ID goes straight there. A code is never reused for another region.
38
+ */
39
+ const ASSET_ID_REGION_CODES = {
40
+ "aws-ap-southeast-1": "a",
41
+ "aws-eu-west-2": "e",
42
+ "aws-eu-central-1": "f",
43
+ "aws-us-east-2": "u"
44
+ };
45
+ new Map(Object.entries(ASSET_ID_REGION_CODES).map(([region, code]) => [code, region]));
46
+ // src/contract/Ids-BBz_iuDy.js
35
47
  var __defProp = Object.defineProperty;
36
48
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
37
49
  var __exportAll = (all, no_symbols) => {
@@ -7925,6 +7937,7 @@ createMetaType({
7925
7937
  createMetaType({ id: "updatedAt" });
7926
7938
  createMetaType({ id: "monotonicTimestamp" });
7927
7939
  createMetaType({ id: "backfill" });
7940
+ createMetaType({ id: "computed" });
7928
7941
  /**
7929
7942
  * The prefix of every kind of object customers can see, so an ID says what it identifies:
7930
7943
  * `proj_8fK2mQx7Lp4NvB3tRz9Y` is a project. Rows that never leave the backend (usage meters, upload
@@ -7987,15 +8000,23 @@ const randomBase62 = (length) => {
7987
8000
  }
7988
8001
  return result;
7989
8002
  };
7990
- /** A new random ID, such as `newId("proj")` → `proj_8fK2mQx7Lp4NvB3tRz9Y`. */
8003
+ /**
8004
+ * A new random ID, such as `newId("proj")` → `proj_8fK2mQx7Lp4NvB3tRz9Y`. Assets take theirs from
8005
+ * `newAssetId`, which names their region.
8006
+ */
7991
8007
  const newId = (prefix) => `${prefix}_${randomBase62(20)}`;
8008
+ /**
8009
+ * A new asset ID for an asset that lives in `region`: its first character after `asset_` is the
8010
+ * region's code (`ASSET_ID_REGION_CODES`), then 19 random characters (about 113 bits).
8011
+ */
8012
+ const newAssetId = (region) => `asset_${ASSET_ID_REGION_CODES[region]}${randomBase62(19)}`;
7992
8013
  /** Whether `value` is an ID with `prefix` (or with any registered prefix). */
7993
8014
  const isId = (value, prefix) => typeof value === "string" && idPattern(prefix).test(value);
7994
8015
  /** Example IDs for docs, OpenAPI and SDK fixtures: fixed, so generated output stays stable. */
7995
8016
  const EXAMPLE_IDS = {
7996
8017
  org: "org_3hQ7tLk2Vb9XpR4mWc8N",
7997
8018
  proj: "proj_8fK2mQx7Lp4NvB3tRz9Y",
7998
- asset: "asset_5Gm2Rk8XqT3wLp9VbN4c",
8019
+ asset: "asset_e5Gm2Rk8XqT3wLp9VbN4",
7999
8020
  fldr: "fldr_7Nc4Wq2Lm8Xt5Rk9Bv3P",
8000
8021
  lens: "lens_2Xr9Lp4Vm7Qk3Tb8Nw5C",
8001
8022
  key: "key_9Pt3Wm6Rk2Lx8Qv4Nb7C",
@@ -8028,8 +8049,9 @@ const EXAMPLE_IDS = {
8028
8049
  * across the packages that build records from plain strings).
8029
8050
  */
8030
8051
  const idField = (prefix) => zod.string().regex(idPattern(prefix), { message: `Must be a valid ID: "${prefix}_" followed by 20 letters or digits` }).meta({ examples: [EXAMPLE_IDS[prefix]] });
8031
- // src/contract/Permissions-CzuRcPMS.js
8032
- const ACTION_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.enum([
8052
+ // src/contract/Permissions-Dwk78TtG.js
8053
+ /** Every permission action, in the order the docs and the portal list them. */
8054
+ const PERMISSION_ACTIONS = [
8033
8055
  "assets:read",
8034
8056
  "assets:download",
8035
8057
  "assets:create",
@@ -8061,7 +8083,8 @@ const ACTION_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.enum([
8061
8083
  "reviews:read",
8062
8084
  "reviews:write",
8063
8085
  "project:manage"
8064
- ]));
8086
+ ];
8087
+ const ACTION_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.enum(PERMISSION_ACTIONS));
8065
8088
  const PROJECT_ACTIONS = [...[
8066
8089
  "settings",
8067
8090
  "members",
@@ -8083,8 +8106,8 @@ const GRANT_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.object({
8083
8106
  includeSubfolders: zod.boolean()
8084
8107
  }).strict().refine((g) => g.folderId === null || !g.actions.some(isProjectAction), "Project configuration permissions require project scope"));
8085
8108
  const GRANTS_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.array(GRANT_SCHEMA).max(100));
8086
- [...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
8087
- [...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
8109
+ [...PERMISSION_ACTIONS.filter((a) => !isProjectAction(a))];
8110
+ [...PERMISSION_ACTIONS.filter((a) => !isProjectAction(a))];
8088
8111
  const permits = (grants, action, folderId, folders) => grants.some((grant) => {
8089
8112
  if (![action, ...actionsImplying(action)].some((held) => grant.actions.includes(held))) return false;
8090
8113
  if (grant.folderId === null) return true;
@@ -11631,7 +11654,7 @@ var MockCalmLensApi = class {
11631
11654
  }, url);
11632
11655
  if (resource === "embed") return this.cdnResponse(isHead, new TextEncoder().encode(MOCK_EMBED_HTML), url, {
11633
11656
  "Content-Type": "text/html; charset=utf-8",
11634
- "Cache-Control": Object.keys(claims).length ? "private, no-store" : `${isPrivate ? "private" : "public"}, max-age=3600`,
11657
+ "Cache-Control": "private, no-store",
11635
11658
  "Cache-Tag": `asset-${asset.id}`,
11636
11659
  "X-Content-Type-Options": "nosniff"
11637
11660
  });
@@ -11663,15 +11686,14 @@ var MockCalmLensApi = class {
11663
11686
  bytes = mockPlaceholderPng(preview?.thumbhash ?? MOCK_THUMBHASH);
11664
11687
  contentType = "image/png";
11665
11688
  }
11666
- const immutable = stillImage || resource === "original" && asset.type === "image";
11689
+ const imageResponse = stillImage || resource === "original" && asset.type === "image";
11690
+ const maxAge = grant ? Math.max(0, Math.min(86400, Math.floor((grant.expiresAt - this.now()) / 1e3))) : 86400;
11691
+ const cacheControl = query.has("viewerClaims") || request.headers.has("X-CalmLens-Viewer-Claims") ? "private, no-store" : isPrivate && !grant ? "private, no-cache" : `${isPrivate ? "private" : "public"}, max-age=${maxAge}, must-revalidate`;
11667
11692
  return this.cdnResponse(isHead, bytes, url, {
11668
11693
  "Content-Type": contentType,
11669
- "Cache-Control": Object.keys(claims).length ? "private, no-store" : `${isPrivate ? "private" : "public"}, ${immutable ? "max-age=31536000, immutable" : "max-age=3600"}`,
11694
+ "Cache-Control": cacheControl,
11670
11695
  "Cache-Tag": `asset-${asset.id}`,
11671
- ...immutable ? {
11672
- ETag: `"${asset.id}"`,
11673
- Expires: new Date(this.now() + 31536e6).toUTCString()
11674
- } : {},
11696
+ ...imageResponse ? { ETag: `"${asset.id}"` } : {},
11675
11697
  "X-Content-Type-Options": "nosniff",
11676
11698
  "Content-Security-Policy": "sandbox; default-src 'none'",
11677
11699
  ...isActiveContentType(contentType) ? { "Content-Disposition": "attachment" } : {}
@@ -11872,7 +11894,7 @@ var MockCalmLensServerClient = class extends CalmLensServerClient {
11872
11894
  grants: getMockApiKeyGrants(options.apiKey),
11873
11895
  databaseStorage: mockOptions.databaseStorage ?? new InMemoryMockDatabaseStorage(),
11874
11896
  imageStorage: mockOptions.imageStorage ?? new InMemoryMockImageStorage(),
11875
- createId: mockOptions.createId ?? newId,
11897
+ createId: mockOptions.createId ?? ((prefix) => prefix === "asset" ? newAssetId("aws-eu-west-2") : newId(prefix)),
11876
11898
  now: mockOptions.now ?? createMonotonicClock(),
11877
11899
  moderate: mockOptions.moderate ?? defaultModerate
11878
11900
  });
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-OWZsGvBX.js";
2
- import { K as AssetOptions, Z as AssetView, ct as PdfAssetOptions, ft as ViewerOptions, lt as SpreadsheetViewerOptions, mt as WebsiteViewerOptions, ot as DocumentViewerOptions, q as AssetSession, st as ImageViewerOptions, ut as TextViewerOptions } from "./Core-BXeXyiNv.js";
1
+ import "./CalmLensTypes-DxxyZt2L.js";
2
+ import { K as AssetOptions, Z as AssetView, ct as DocumentViewerOptions, dt as TextViewerOptions, lt as PdfAssetOptions, pt as ViewerOptions, q as AssetSession, ut as SpreadsheetViewerOptions } from "./Core-Dhijt6JU.js";
3
3
  import "pdfjs-dist";
4
4
  /** A viewer mounted into an element, which it owns the children of. */
5
5
  interface AssetViewer<O extends ViewerOptions = ViewerOptions> {
@@ -11,10 +11,6 @@ interface AssetViewer<O extends ViewerOptions = ViewerOptions> {
11
11
  type ViewerState = "loading" | "loaded" | "error";
12
12
  /** Shows a PDF, or a document rendered as one, in `root`. */
13
13
  declare const createDocumentViewer: (root: HTMLElement, options: DocumentViewerOptions) => AssetViewer<DocumentViewerOptions>;
14
- /** Shows an image asset's rendered file in `root`. */
15
- declare const createImageViewer: (root: HTMLElement, options: ImageViewerOptions) => AssetViewer<ImageViewerOptions>;
16
- /** Shows a website asset's screenshot and a link to the page in `root`. */
17
- declare const createWebsiteViewer: (root: HTMLElement, options: WebsiteViewerOptions) => AssetViewer<WebsiteViewerOptions>;
18
14
  type PdfJs = typeof import("pdfjs-dist");
19
15
  /**
20
16
  * Loads pdf.js, the first time a document viewer needs it: never at import, so pages without
@@ -83,8 +79,6 @@ declare const createSpreadsheetViewer: (root: HTMLElement, options: SpreadsheetV
83
79
  declare const VIEWER_STYLES: string;
84
80
  /** Each viewer's options, by the kind of viewer `getAssetViewerKind` names. */
85
81
  interface AssetViewerOptionsByKind {
86
- image: ImageViewerOptions;
87
- website: WebsiteViewerOptions;
88
82
  text: TextViewerOptions;
89
83
  document: DocumentViewerOptions;
90
84
  spreadsheet: SpreadsheetViewerOptions;
@@ -136,4 +130,4 @@ declare class MediaStreamPlayer {
136
130
  /** Stops the stream, when the component unmounts. */
137
131
  stop(): void;
138
132
  }
139
- export { ViewerState as C, AssetViewer as S, spreadsheetColumnIndex as _, isMountedViewerKind as a, createWebsiteViewer as b, AssetViewerOptionsByKind as c, createTextViewer as d, SpreadsheetCell as f, parseSpreadsheetText as g, getSpreadsheetPage as h, getMountedViewerOptions as i, VIEWER_STYLES as l, SpreadsheetSheet as m, AssetViewerMount as n, ASSET_VIEWERS as o, SpreadsheetRow as p, MountedViewerKind as r, AssetViewerName as s, MediaStreamPlayer as t, createSpreadsheetViewer as u, loadPdfJs as v, createDocumentViewer as x, createImageViewer as y };
133
+ export { spreadsheetColumnIndex as _, isMountedViewerKind as a, AssetViewer as b, AssetViewerOptionsByKind as c, createTextViewer as d, SpreadsheetCell as f, parseSpreadsheetText as g, getSpreadsheetPage as h, getMountedViewerOptions as i, VIEWER_STYLES as l, SpreadsheetSheet as m, AssetViewerMount as n, ASSET_VIEWERS as o, SpreadsheetRow as p, MountedViewerKind as r, AssetViewerName as s, MediaStreamPlayer as t, createSpreadsheetViewer as u, loadPdfJs as v, ViewerState as x, createDocumentViewer as y };
@@ -1,6 +1,5 @@
1
- import { a as appendAssetLocation } from "./ModerationContextLimits-tu_PY4fn.js";
2
- import { o as placeholderHashToDataURL } from "./UploadController-Dqjf23bS.js";
3
- import "./Core-Df2PSa1n.js";
1
+ import { a as appendAssetLocation } from "./ModerationContextLimits-ZIlK9n2X.js";
2
+ import "./Core-kYMRW5C1.js";
4
3
  // src/ui/viewers/PdfLoader.ts
5
4
  let loading;
6
5
  /**
@@ -38,9 +37,6 @@ const openPdfDocument = async (url, options = {}) => {
38
37
  // src/ui/viewers/ViewerMessages.ts
39
38
  const DEFAULT_VIEWER_MESSAGES = {
40
39
  loading: "Loading…",
41
- imageFailed: "This image can't be shown.",
42
- openWebsite: "Open {host}",
43
- websiteLabel: "Website screenshot",
44
40
  textLabel: "Text",
45
41
  textFailed: "This text can't be shown.",
46
42
  documentLabel: "Document",
@@ -576,187 +572,6 @@ const createDocumentViewer = (root, options) => {
576
572
  viewer.update(options);
577
573
  return viewer;
578
574
  };
579
- // src/ui/viewers/ImageViewers.ts
580
- /** Widths offered for a public image, so the browser fetches the smallest that fills the frame. */
581
- const IMAGE_WIDTHS = [
582
- 320,
583
- 640,
584
- 960,
585
- 1280,
586
- 1920,
587
- 2560
588
- ];
589
- /** The blurred placeholder shown while the image loads: the stored ThumbHash, or the CDN's. */
590
- const placeholderFor = (asset, urls) => {
591
- const hash = asset.content?.preview?.thumbhash;
592
- if (hash) try {
593
- return placeholderHashToDataURL(hash);
594
- } catch {}
595
- return asset.content?.rendered || asset.content?.preview ? urls.url("placeholder") : void 0;
596
- };
597
- /**
598
- * Loads the rendered image into `image` at responsive widths, asking once for a fresh asset URL
599
- * when it fails to load (as an expired signed one does).
600
- */
601
- const loadRenderedImage = async (urls, image, { sizes, width }, signal, done) => {
602
- const widths = IMAGE_WIDTHS.filter((candidate) => !width || candidate < width);
603
- const setSources = (src) => {
604
- if (widths.length) {
605
- image.srcset = [...widths, ...width ? [width] : []].map((candidate) => `${urls.url("rendered", { width: candidate })} ${candidate}w`).join(", ");
606
- image.sizes = sizes;
607
- }
608
- image.src = src;
609
- };
610
- image.addEventListener("load", () => {
611
- urls.loaded("rendered");
612
- done("loaded");
613
- });
614
- image.addEventListener("error", () => {
615
- const fresh = urls.refresh("rendered");
616
- if (!fresh) return done("error");
617
- fresh.then((url) => {
618
- if (!signal.aborted) setSources(url);
619
- }, () => done("error"));
620
- });
621
- const url = await urls.get("rendered");
622
- if (!signal.aborted) setSources(url);
623
- };
624
- /**
625
- * Shows an image asset's rendered file, fitted inside the element (the whole frame, for an embed
626
- * page), over its blurred placeholder until it loads.
627
- */
628
- var ImageViewer = class extends ViewerBase {
629
- constructor(root) {
630
- super(root, "image");
631
- }
632
- describe({ asset, sizes }) {
633
- return [
634
- asset.content?.rendered,
635
- asset.content?.preview?.thumbhash,
636
- sizes
637
- ];
638
- }
639
- async load(signal) {
640
- const { asset, label = "", sizes = "100vw" } = this.options;
641
- const rendered = asset.content?.rendered;
642
- if (rendered?.width && rendered.height) this.root.style.setProperty("--calmlens-viewer-ratio", `${rendered.width} / ${rendered.height}`);
643
- const placeholderUrl = placeholderFor(asset, this.urls);
644
- const placeholder = placeholderUrl && el("img", {
645
- class: "calmlens-viewer__placeholder",
646
- src: placeholderUrl,
647
- alt: "",
648
- "aria-hidden": "true"
649
- });
650
- const image = el("img", {
651
- class: "calmlens-viewer__image",
652
- alt: label,
653
- width: rendered?.width ?? void 0,
654
- height: rendered?.height ?? void 0,
655
- decoding: "async"
656
- });
657
- this.frame.replaceChildren(...[placeholder, image].filter((node) => !!node));
658
- await loadRenderedImage(this.urls, image, {
659
- sizes,
660
- width: rendered?.width
661
- }, signal, (outcome) => {
662
- if (signal.aborted) return;
663
- if (outcome === "error") return this.fail();
664
- this.state = "loaded";
665
- if (placeholder) placeholder.remove();
666
- });
667
- }
668
- fail() {
669
- this.state = "error";
670
- this.frame.replaceChildren(this.notice(this.messages.imageFailed));
671
- }
672
- };
673
- /** The page's address, if it is a web address the viewer may link to. */
674
- const websiteUrl = (asset) => {
675
- if (!asset.externalUrl) return void 0;
676
- try {
677
- const url = new URL(asset.externalUrl);
678
- return url.protocol === "https:" || url.protocol === "http:" ? url : void 0;
679
- } catch {
680
- return;
681
- }
682
- };
683
- /**
684
- * Shows a website asset: a link to the original page, then its screenshot at the element's width,
685
- * scrolling down the page.
686
- */
687
- var WebsiteViewer = class extends ViewerBase {
688
- constructor(root) {
689
- super(root, "website");
690
- }
691
- describe({ asset }) {
692
- return [
693
- asset.content?.rendered,
694
- asset.content?.preview?.thumbhash,
695
- asset.externalUrl
696
- ];
697
- }
698
- #link() {
699
- const url = websiteUrl(this.options.asset);
700
- return url ? el("div", { class: "calmlens-viewer__bar" }, [el("a", {
701
- class: "calmlens-button calmlens-viewer__link",
702
- href: url.href,
703
- target: "_blank",
704
- rel: "noopener noreferrer nofollow"
705
- }, [formatViewerMessage(this.messages.openWebsite, { host: url.host })])]) : void 0;
706
- }
707
- async load(signal) {
708
- const { asset, label } = this.options;
709
- const rendered = asset.content?.rendered;
710
- if (!rendered) return this.fail();
711
- const name = label || this.messages.websiteLabel;
712
- const placeholderUrl = placeholderFor(asset, this.urls);
713
- const placeholder = placeholderUrl && el("img", {
714
- class: "calmlens-viewer__placeholder",
715
- src: placeholderUrl,
716
- alt: "",
717
- "aria-hidden": "true"
718
- });
719
- const image = el("img", {
720
- class: "calmlens-viewer__image",
721
- alt: name,
722
- width: rendered.width ?? void 0,
723
- height: rendered.height ?? void 0,
724
- decoding: "async"
725
- });
726
- const page = el("div", {
727
- class: "calmlens-viewer__scroll",
728
- role: "region",
729
- "aria-label": name,
730
- tabindex: 0
731
- }, [placeholder, image]);
732
- this.frame.replaceChildren(...[this.#link(), page].filter((node) => !!node));
733
- await loadRenderedImage(this.urls, image, {
734
- sizes: "100vw",
735
- width: rendered.width
736
- }, signal, (outcome) => {
737
- if (signal.aborted) return;
738
- if (outcome === "error") return this.fail();
739
- this.state = "loaded";
740
- if (placeholder) placeholder.remove();
741
- });
742
- }
743
- fail() {
744
- this.state = "error";
745
- this.frame.replaceChildren(...[this.#link(), this.notice(this.messages.imageFailed)].filter((node) => !!node));
746
- }
747
- };
748
- /** Shows an image asset's rendered file in `root`. */
749
- const createImageViewer = (root, options) => {
750
- const viewer = new ImageViewer(root);
751
- viewer.update(options);
752
- return viewer;
753
- };
754
- /** Shows a website asset's screenshot and a link to the page in `root`. */
755
- const createWebsiteViewer = (root, options) => {
756
- const viewer = new WebsiteViewer(root);
757
- viewer.update(options);
758
- return viewer;
759
- };
760
575
  // src/ui/viewers/Spreadsheet.ts
761
576
  const SHEET_LINE = /^# Sheet "((?:[^"\\]|\\.)*)"( \(hidden\))?$/;
762
577
  const ROW_LINE = /^Row (\d+)( \(hidden\))?: (.*)$/;
@@ -1074,8 +889,6 @@ const createSpreadsheetViewer = (root, options) => {
1074
889
  // src/ui/viewers/index.ts
1075
890
  /** Mounts each viewer, by kind, for the bindings. */
1076
891
  const ASSET_VIEWERS = {
1077
- image: createImageViewer,
1078
- website: createWebsiteViewer,
1079
892
  text: createTextViewer,
1080
893
  document: createDocumentViewer,
1081
894
  spreadsheet: createSpreadsheetViewer
@@ -1257,4 +1070,4 @@ var MediaStreamPlayer = class {
1257
1070
  this.#key = void 0;
1258
1071
  }
1259
1072
  };
1260
- export { loadPdfJs as _, ASSET_VIEWERS as a, getSpreadsheetPage as c, createImageViewer as d, createWebsiteViewer as f, resolveViewerMessages as g, formatViewerMessage as h, isMountedViewerKind as i, parseSpreadsheetText as l, DEFAULT_VIEWER_MESSAGES as m, AssetViewerMount as n, createSpreadsheetViewer as o, createDocumentViewer as p, getMountedViewerOptions as r, createTextViewer as s, MediaStreamPlayer as t, spreadsheetColumnIndex as u };
1073
+ export { ASSET_VIEWERS as a, getSpreadsheetPage as c, createDocumentViewer as d, DEFAULT_VIEWER_MESSAGES as f, loadPdfJs as h, isMountedViewerKind as i, parseSpreadsheetText as l, resolveViewerMessages as m, AssetViewerMount as n, createSpreadsheetViewer as o, formatViewerMessage as p, getMountedViewerOptions as r, createTextViewer as s, MediaStreamPlayer as t, spreadsheetColumnIndex as u };