calmlens 0.31.1 → 0.33.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.
Files changed (80) hide show
  1. package/bin/calmlens.js +54 -42
  2. package/cjs/{BrowserUpload-BwBE37LM.js → BrowserUpload-Al3ER3ki.js} +1 -1
  3. package/cjs/{BrowserUpload-BAH54V1q.d.ts → BrowserUpload-CURmX-DR.d.ts} +2 -2
  4. package/cjs/{CalmLensAppClient-CdlcDd5l.d.ts → CalmLensAppClient-DII9cdTD.d.ts} +3 -3
  5. package/cjs/{CalmLensAppClient-D6Y7MgH_.js → CalmLensAppClient-DWIy2yPF.js} +4 -4
  6. package/cjs/{CalmLensCdn-Q68faCEE.js → CalmLensCdn-6ZqvG8-v.js} +56 -22
  7. package/cjs/{CalmLensConnection-j2aBsuNx.js → CalmLensConnection-Qp9ucGHO.js} +7 -16
  8. package/cjs/{CalmLensServerClient-CtS66dCU.d.ts → CalmLensServerClient-CPwGfFR-.d.ts} +10 -10
  9. package/cjs/{CalmLensServerClient-CjK691kq.js → CalmLensServerClient-DRLyvnA1.js} +19 -19
  10. package/cjs/{CalmLensTypes-87kiUg0H.d.ts → CalmLensTypes-DF7wh23M.d.ts} +16527 -16498
  11. package/cjs/{Core-Ccy4-_sN.d.ts → Core-Dnm9bJPB.d.ts} +2 -2
  12. package/cjs/{Core-Dsj4tRNP.js → Core-rYZedJhi.js} +2 -2
  13. package/cjs/{ReactUpload-DBhppuxM.d.ts → ReactUpload-B7wrDPk8.d.ts} +1 -1
  14. package/cjs/{ReactUpload-B7SdNAel.js → ReactUpload-Bj6-CciJ.js} +1 -1
  15. package/{esm/TestTriggers-Daxebd0V.d.ts → cjs/TestTriggers-CjDhhz78.d.ts} +1 -11
  16. package/cjs/{UploadController-DsIENVY1.js → UploadController-DCr7oN6L.js} +1 -1
  17. package/cjs/{WebhookPayload-B4rA_Dvm.d.ts → WebhookPayload-CUMsersa.d.ts} +1 -1
  18. package/cjs/app.d.ts +5 -5
  19. package/cjs/app.js +2 -2
  20. package/cjs/elements.d.ts +4 -4
  21. package/cjs/elements.js +4 -4
  22. package/cjs/{index-CWUnLKoF.d.ts → index-B511mjeS.d.ts} +2 -2
  23. package/cjs/index.d.ts +4 -4
  24. package/cjs/index.js +1 -1
  25. package/cjs/react-native.d.ts +2 -2
  26. package/cjs/react-native.js +4 -4
  27. package/cjs/react.d.ts +4 -4
  28. package/cjs/react.js +5 -5
  29. package/cjs/server.d.ts +5 -5
  30. package/cjs/server.js +2 -2
  31. package/cjs/test-inputs.d.ts +15 -3
  32. package/cjs/test-inputs.js +105 -2
  33. package/cjs/testing.d.ts +14 -6
  34. package/cjs/testing.js +122 -53
  35. package/cjs/{ui-sjnJhloQ.d.ts → ui-B83Pqjom.d.ts} +2 -2
  36. package/cjs/{ui-BC70R8KT.js → ui-BS9eFCI7.js} +8 -8
  37. package/cjs/ui.d.ts +2 -2
  38. package/cjs/ui.js +3 -3
  39. package/cjs/vue.d.ts +5 -5
  40. package/cjs/vue.js +4 -4
  41. package/esm/{BrowserUpload-BAH54V1q.d.ts → BrowserUpload-CURmX-DR.d.ts} +2 -2
  42. package/esm/{BrowserUpload-DSLCpWgz.js → BrowserUpload-DOcZaSWT.js} +1 -1
  43. package/esm/{CalmLensAppClient-BKanqwYL.js → CalmLensAppClient-B7IkEK2D.js} +4 -4
  44. package/esm/{CalmLensAppClient-CdlcDd5l.d.ts → CalmLensAppClient-DII9cdTD.d.ts} +3 -3
  45. package/esm/{CalmLensCdn-CL1P1v2t.js → CalmLensCdn-DpJ7kIqG.js} +39 -23
  46. package/esm/{CalmLensConnection-CHNNULpg.js → CalmLensConnection-BYUqUitO.js} +7 -16
  47. package/esm/{CalmLensServerClient-CtS66dCU.d.ts → CalmLensServerClient-CPwGfFR-.d.ts} +10 -10
  48. package/esm/{CalmLensServerClient-CBjSqROz.js → CalmLensServerClient-DpkreSH6.js} +19 -19
  49. package/esm/{CalmLensTypes-87kiUg0H.d.ts → CalmLensTypes-DF7wh23M.d.ts} +16527 -16498
  50. package/esm/{Core-WxPuobo_.js → Core-DGF84gwM.js} +2 -2
  51. package/esm/{Core-Ccy4-_sN.d.ts → Core-Dnm9bJPB.d.ts} +2 -2
  52. package/esm/{ReactUpload-DBhppuxM.d.ts → ReactUpload-B7wrDPk8.d.ts} +1 -1
  53. package/esm/{ReactUpload-U49veoZl.js → ReactUpload-rDvF5arL.js} +1 -1
  54. package/{cjs/TestTriggers-Daxebd0V.d.ts → esm/TestTriggers-CjDhhz78.d.ts} +1 -11
  55. package/esm/{UploadController-X2gEFMGy.js → UploadController-cXocXbjd.js} +1 -1
  56. package/esm/{WebhookPayload-B4rA_Dvm.d.ts → WebhookPayload-CUMsersa.d.ts} +1 -1
  57. package/esm/app.d.ts +5 -5
  58. package/esm/app.js +2 -2
  59. package/esm/elements.d.ts +4 -4
  60. package/esm/elements.js +4 -4
  61. package/esm/{index-CWUnLKoF.d.ts → index-B511mjeS.d.ts} +2 -2
  62. package/esm/index.d.ts +4 -4
  63. package/esm/index.js +1 -1
  64. package/esm/react-native.d.ts +2 -2
  65. package/esm/react-native.js +4 -4
  66. package/esm/react.d.ts +4 -4
  67. package/esm/react.js +5 -5
  68. package/esm/server.d.ts +5 -5
  69. package/esm/server.js +2 -2
  70. package/esm/test-inputs.d.ts +15 -3
  71. package/esm/test-inputs.js +105 -2
  72. package/esm/testing.d.ts +14 -6
  73. package/esm/testing.js +122 -53
  74. package/esm/{ui-sjnJhloQ.d.ts → ui-B83Pqjom.d.ts} +2 -2
  75. package/esm/{ui-DS85DGfi.js → ui-C0wgePYT.js} +8 -8
  76. package/esm/ui.d.ts +2 -2
  77. package/esm/ui.js +3 -3
  78. package/esm/vue.d.ts +5 -5
  79. package/esm/vue.js +4 -4
  80. package/package.json +1 -1
package/esm/testing.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Lt as SignUploadTokenOptions, O as CalmLensAppClientOptions, Xt as UploadPresetDefinition, bn as PermissionGrant, fn as TypedEvent, k as CalmLensServerClientOptions, m as AssetModeration, r as Asset, xn as Folder, zn as AssetBinaryPayloadInput, zt as SignedUploadToken } from "./CalmLensTypes-87kiUg0H.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-CdlcDd5l.js";
3
- import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-B4rA_Dvm.js";
4
- import { t as CalmLensServerClient } from "./CalmLensServerClient-CtS66dCU.js";
5
- import { t as ClassificationTestSignal } from "./TestTriggers-Daxebd0V.js";
1
+ import { Kt as SignedUploadToken, Ln as PermissionGrant, Nn as TypedEvent, O as CalmLensAppClientOptions, Rn as Folder, Vn as AssetBinaryPayloadInput, Wt as SignUploadTokenOptions, in as UploadPresetDefinition, k as CalmLensServerClientOptions, m as AssetModeration, r as Asset } from "./CalmLensTypes-DF7wh23M.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-DII9cdTD.js";
3
+ import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-CUMsersa.js";
4
+ import { t as CalmLensServerClient } from "./CalmLensServerClient-CPwGfFR-.js";
5
+ import { t as ClassificationTestSignal } from "./TestTriggers-CjDhhz78.js";
6
6
  import "zod";
7
7
  /**
8
8
  * Signs a single-use upload token with `apiKey`, locally. `CalmLensServerClient` and
@@ -381,7 +381,7 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
381
381
  callsTo(operation: MockCalmLensOperation): MockCalmLensCall[];
382
382
  /**
383
383
  * Fetches a URL of the mock's CDN as a browser would, without the API key: a signed asset URL
384
- * from `cdn.signAssetUrl` (with a resource appended), or a public one from `cdn.getAssetUrl`.
384
+ * from `cdn.signAssetUrl`, or a public one from `cdn.getAssetUrl`.
385
385
  * The request is recorded like any other.
386
386
  */
387
387
  fetchCdn(url: string, init?: RequestInit): Promise<Response>;
@@ -410,6 +410,14 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
410
410
  * is typed by its path's extension, and has no content.
411
411
  */
412
412
  serveUrl(url: string, content: MockServedUrl): void;
413
+ /**
414
+ * Makes the mock hash an image upload of exactly `content` (bytes, or text as UTF-8) as `hash`, a
415
+ * PDQ hash of 64 hexadecimal characters, with `quality` (0 to 100, default 100), instead of the
416
+ * SHA-256 of its bytes. Hash list entries match hashes up to 31 bits away, as in CalmLens, so a
417
+ * test can make a resized or recompressed copy a near match of a listed image: declare the
418
+ * copy's hash a few bits from the entry's.
419
+ */
420
+ setPerceptualHash(content: Uint8Array | ArrayBuffer | string, hash: string, quality?: number): void;
413
421
  /**
414
422
  * Changes the grants of the mock's API key, as editing the key in the portal would: later
415
423
  * requests, such as `cdn.serve`, use them. The key itself stays the same, so idempotency keys
package/esm/testing.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { C as invalidConfig, S as invalidArgument, T as API_ERROR_DEFINITIONS, l as CalmLensError, w as API_ERROR_CODES, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
- import { A as normalizeUploadMimeType, D as MAX_IMAGE_UPLOAD_BYTES, M as sleep, S as validateAppClientOptions, _ as randomUuid, f as checkTransformOptions, h as parseTransformSelector, k as getRejectedUploadMimeTypeError, m as isAcceptedUploadMimeType, t as ASSET_RESOURCE_PATHS, w as validateServerClientOptions } from "./CalmLensCdn-CL1P1v2t.js";
3
- 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-CBjSqROz.js";
4
- import { _ as validateAssetPayload, g as assetToData, h as assetDataToUint8Array, n as MOCK_HOOKS } from "./CalmLensConnection-CHNNULpg.js";
2
+ import { F as sleep, M as getRejectedUploadMimeTypeError, N as normalizeUploadMimeType, O as MAX_IMAGE_UPLOAD_BYTES, S as validateAppClientOptions, _ as randomUuid, f as checkTransformOptions, h as parseTransformSelector, m as isAcceptedUploadMimeType, t as ASSET_RESOURCE_PATHS, w as validateServerClientOptions } from "./CalmLensCdn-DpJ7kIqG.js";
3
+ 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-DpkreSH6.js";
4
+ import { _ as validateAssetPayload, g as assetToData, h as assetDataToUint8Array, n as MOCK_HOOKS } from "./CalmLensConnection-BYUqUitO.js";
5
5
  import { t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
6
- import { t as CalmLensAppClient } from "./CalmLensAppClient-BKanqwYL.js";
7
- import { o as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-X2gEFMGy.js";
6
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-B7IkEK2D.js";
7
+ import { o as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-cXocXbjd.js";
8
8
  import { f as getTestInputTag, g as CLASSIFICATION_CATEGORIES, h as lazySchema, t as withValidTestInputArguments } from "./CalmLensTestInputArguments-CqPADTkl.js";
9
9
  import * as zod from "zod";
10
10
  // src/contract/MediaTestTriggers.js
@@ -8532,7 +8532,6 @@ var MockDecision = class {
8532
8532
  rule: null,
8533
8533
  automatedStatus: status,
8534
8534
  regions: [],
8535
- linkSafety: null,
8536
8535
  timeline: null,
8537
8536
  flaggedCategories: evaluated.filter(([, score]) => action(score) !== "allow").map(([category]) => category),
8538
8537
  raw: {
@@ -8700,20 +8699,6 @@ const MOCK_ASSET_FILTER_FIELDS = {
8700
8699
  "=out="
8701
8700
  ]
8702
8701
  },
8703
- description: {
8704
- kind: "text",
8705
- nullable: true,
8706
- operators: [
8707
- "==",
8708
- "!=",
8709
- ">",
8710
- ">=",
8711
- "<",
8712
- "<=",
8713
- "=in=",
8714
- "=out="
8715
- ]
8716
- },
8717
8702
  externalId: {
8718
8703
  kind: "text",
8719
8704
  nullable: true,
@@ -9232,17 +9217,20 @@ const filterAssets = (items, filter) => {
9232
9217
  return items.filter((item) => matchesNode(item, node));
9233
9218
  };
9234
9219
  const MAX_SEARCH_TOKENS = 8;
9235
- /** The keyword fields the API searches, in the order it reports matches. */
9236
- const searchFieldValues = (asset) => [
9220
+ /**
9221
+ * The keyword fields the API searches, in the order it reports matches. `extractedText` is the
9222
+ * asset's retained text: empty unless its content is stored.
9223
+ */
9224
+ const searchFieldValues = (asset, extractedText) => [
9237
9225
  ["name", asset.name],
9238
9226
  ["id", asset.id],
9239
9227
  ["externalId", asset.externalId ?? ""],
9240
- ["description", asset.description ?? ""],
9241
9228
  ["tags", asset.tags?.join(" ") ?? ""],
9242
9229
  ["type", asset.type],
9243
9230
  ["content.format", asset.content?.format ?? ""],
9244
9231
  ["content.extension", asset.content?.extension ?? ""],
9245
- ["classification.moderation.decision", asset.classification.moderation.decision ?? "pending"]
9232
+ ["classification.moderation.decision", asset.classification.moderation.decision ?? "pending"],
9233
+ ["content.extractedText", extractedText]
9246
9234
  ];
9247
9235
  /** The API's keyword score for the whole lowercased query. */
9248
9236
  const keywordScore = (values, query) => {
@@ -9261,15 +9249,15 @@ const keywordScore = (values, query) => {
9261
9249
  };
9262
9250
  /**
9263
9251
  * Keyword search as the API runs it: every whitespace-separated token (case-insensitive, at
9264
- * most 8) must appear in some searchable field. Results are ranked by the API's score, then
9265
- * newest first.
9252
+ * most 8) must appear in some searchable field, including the asset's retained text, which
9253
+ * `extractedTexts` maps by asset ID. Results are ranked by the API's score, then newest first.
9266
9254
  */
9267
- const searchAssets = (assets, query, limit) => {
9255
+ const searchAssets = (assets, extractedTexts, query, limit) => {
9268
9256
  const normalized = query.trim().toLowerCase();
9269
9257
  const tokens = [...new Set(normalized.split(/\s+/).filter(Boolean))].slice(0, MAX_SEARCH_TOKENS);
9270
9258
  if (tokens.length === 0) return [];
9271
9259
  return assets.map((asset) => {
9272
- const fields = searchFieldValues(asset).map(([field, value]) => [field, value.toLowerCase()]);
9260
+ const fields = searchFieldValues(asset, extractedTexts.get(asset.id) ?? "").map(([field, value]) => [field, value.toLowerCase()]);
9273
9261
  return {
9274
9262
  asset,
9275
9263
  matches: tokens.every((token) => fields.some(([, value]) => value.includes(token))),
@@ -9379,8 +9367,12 @@ const checkMockUploadPreset = (preset) => {
9379
9367
  if (unknown.length) throw invalidArgument(`Unknown mockOptions.preset key${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`, { options: unknown });
9380
9368
  };
9381
9369
  const MAX_PAGE_SIZE = 100;
9382
- /** Entries with a lower PDQ quality never match (HashList.ts, HASH_MATCH_MIN_QUALITY). */
9370
+ /** Hashes with a lower PDQ quality never match (HashList.ts, HASH_MATCH_MIN_QUALITY). */
9383
9371
  const HASH_MATCH_MIN_QUALITY = 50;
9372
+ /** Hashes this many bits apart or fewer match (HashList.ts, HASH_MATCH_MAX_DISTANCE). */
9373
+ const HASH_MATCH_MAX_DISTANCE = 31;
9374
+ /** A block list blocks only matches this close; looser ones are flagged (HASH_BLOCK_MAX_DISTANCE). */
9375
+ const HASH_BLOCK_MAX_DISTANCE = 16;
9384
9376
  /** The most hash matches an asset records (HashList.ts). */
9385
9377
  const MAX_RECORDED_HASH_MATCHES = 10;
9386
9378
  const MAX_DECISION_NOTE_LENGTH = 1499;
@@ -9625,7 +9617,6 @@ const invalidField = (code, path) => new ApiFailure(400, API_ERROR_CODES.INVALID
9625
9617
  /** The asset fields an upload carries in its body; the API refuses them in the query string. */
9626
9618
  const UPLOAD_OPTION_KEYS = [
9627
9619
  "name",
9628
- "description",
9629
9620
  "processingOptions",
9630
9621
  "visibility",
9631
9622
  "metadata",
@@ -9858,12 +9849,14 @@ var MockCalmLensApi = class {
9858
9849
  this.cdnBaseUrl = "";
9859
9850
  this.lenses = /* @__PURE__ */ new Map();
9860
9851
  this.eventFeed = [];
9852
+ this.usedUploadTokens = /* @__PURE__ */ new Set();
9861
9853
  this.assetEventSequences = /* @__PURE__ */ new Map();
9862
9854
  this.processingOptions = /* @__PURE__ */ new Map();
9863
9855
  this.openUploads = /* @__PURE__ */ new Map();
9864
9856
  this.idempotentResults = /* @__PURE__ */ new Map();
9865
9857
  this.pendingFailures = [];
9866
9858
  this.servedUrls = /* @__PURE__ */ new Map();
9859
+ this.perceptualHashes = [];
9867
9860
  this.pendingReviews = /* @__PURE__ */ new Map();
9868
9861
  this.requestCount = 0;
9869
9862
  this.useTimers = false;
@@ -9928,6 +9921,24 @@ var MockCalmLensApi = class {
9928
9921
  type: type.trim()
9929
9922
  });
9930
9923
  }
9924
+ /**
9925
+ * Makes an image upload of exactly `content` hash as `hash` (64 hexadecimal characters, a PDQ
9926
+ * hash) with `quality`, instead of the SHA-256 of its bytes.
9927
+ */
9928
+ setPerceptualHash(content, hash, quality = 100) {
9929
+ const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content instanceof ArrayBuffer ? new Uint8Array(content.slice(0)) : content instanceof Uint8Array ? new Uint8Array(content) : void 0;
9930
+ if (!bytes) throw invalidArgument("content must be bytes or a string");
9931
+ if (typeof hash !== "string" || !/^[0-9a-f]{64}$/i.test(hash.trim())) throw invalidArgument("hash must be a PDQ hash of 64 hexadecimal characters");
9932
+ if (typeof quality !== "number" || !Number.isInteger(quality) || quality < 0 || quality > 100) throw invalidArgument("quality must be a whole number from 0 to 100");
9933
+ const declared = {
9934
+ bytes,
9935
+ hash: hash.trim().toLowerCase(),
9936
+ quality
9937
+ };
9938
+ const index = this.perceptualHashes.findIndex((known) => sameBytes(known.bytes, bytes));
9939
+ if (index === -1) this.perceptualHashes.push(declared);
9940
+ else this.perceptualHashes[index] = declared;
9941
+ }
9931
9942
  /** A `fetch` that answers a client's requests from memory; app clients pass their session. */
9932
9943
  createFetch(endpoints, session) {
9933
9944
  return ((input, init) => this.handle(input, init, endpoints(), session));
@@ -10733,8 +10744,9 @@ var MockCalmLensApi = class {
10733
10744
  }
10734
10745
  /**
10735
10746
  * Keyword search like the API's: every whitespace-separated token must appear,
10736
- * case-insensitively, in the asset's name, ID, external ID, description, tags, type, content
10737
- * format or extension, or moderation status. There is no semantic search.
10747
+ * case-insensitively, in the asset's name, ID, external ID, tags, type, content format or
10748
+ * extension, moderation status, or retained text while its content is stored. There is no
10749
+ * semantic search.
10738
10750
  */
10739
10751
  async searchAssets(params) {
10740
10752
  const query = (params.get("query") ?? "").trim();
@@ -10743,9 +10755,11 @@ var MockCalmLensApi = class {
10743
10755
  const pageSize = this.integer(params, "pageSize", 10);
10744
10756
  if (pageSize < 1) throw invalidField("validation/too-small", "pageSize");
10745
10757
  if (pageSize > MAX_SEARCH_PAGE_SIZE) throw invalidField("validation/too-big", "pageSize");
10758
+ const assets = await this.databaseStorage.listAssets(this.projectId);
10759
+ const extractedTexts = new Map(await Promise.all(assets.map(async (asset) => [asset.id, await this.searchText(asset)])));
10746
10760
  return {
10747
10761
  query,
10748
- items: searchAssets(await this.databaseStorage.listAssets(this.projectId), query, pageSize),
10762
+ items: searchAssets(assets, extractedTexts, query, pageSize),
10749
10763
  semanticStatus: "disabled"
10750
10764
  };
10751
10765
  }
@@ -11088,7 +11102,6 @@ var MockCalmLensApi = class {
11088
11102
  createdAt: now,
11089
11103
  updatedAt: now,
11090
11104
  name: fields.name,
11091
- description: fields.description ?? null,
11092
11105
  externalId: fields.externalId ?? null,
11093
11106
  externalUrl: fields.url ?? fields.externalUrl ?? null,
11094
11107
  type,
@@ -11285,10 +11298,19 @@ var MockCalmLensApi = class {
11285
11298
  }
11286
11299
  /** An earlier post's text, to the most CalmLens reads of one post; empty once its content is gone. */
11287
11300
  async contextText(asset) {
11301
+ const text = (await this.retainedText(asset)).trim();
11302
+ return Array.from(text).slice(0, MODERATION_CONTEXT_MAX_ITEM_CHARACTERS).join("");
11303
+ }
11304
+ /** The text keyword search reads, like the API: the retained text, only while content is stored. */
11305
+ async searchText(asset) {
11306
+ return asset.content.status === "stored" ? this.retainedText(asset) : "";
11307
+ }
11308
+ /** A text upload's stored bytes, or the text extracted from its content (such as OCR). */
11309
+ async retainedText(asset) {
11288
11310
  const extracted = asset.content.extractedText;
11289
11311
  const bytes = asset.type === "plaintext-document" && await this.storedBytes(asset);
11290
- const text = (bytes ? new TextDecoder().decode(bytes) : extracted?.type === "string" ? extracted.content : "").trim();
11291
- return Array.from(text).slice(0, MODERATION_CONTEXT_MAX_ITEM_CHARACTERS).join("");
11312
+ if (bytes) return new TextDecoder().decode(bytes);
11313
+ return extracted?.type === "string" ? extracted.content : "";
11292
11314
  }
11293
11315
  async storedBytes(asset) {
11294
11316
  if (asset.content.status === "removed") return null;
@@ -11299,28 +11321,40 @@ var MockCalmLensApi = class {
11299
11321
  }
11300
11322
  /**
11301
11323
  * A decided image with its hash and the project's hash list matches, as the API records them
11302
- * (AssetClassification.ts, Project.ts and HashList.ts). The mock computes no PDQ hash: an
11324
+ * (AssetClassification.ts, HashMatching.ts and HashList.ts). The mock computes no PDQ hash: an
11303
11325
  * image's `content.perceptualHash` is the SHA-256 of its bytes in lowercase hex, with quality
11304
- * 100, so an entry matches an image whose bytes equal those it was taken from, at distance 0.
11305
- * Entries below quality 50 never match. Each match takes its list's action, blocking matches
11306
- * first; a block raises an allowed, limited or age-restricted decision to `blocked`, with
11307
- * `source: "hash-list"`, and a flag only records the match.
11326
+ * 100, unless `setPerceptualHash` declared one for those bytes. An entry matches a hash up to 31
11327
+ * bits away, so different images' SHA-256 stand-ins never match, and an entry taken from an
11328
+ * image matches the same bytes at distance 0. Hashes below quality 50 never match. A match takes
11329
+ * its list's action, except that a block list only flags matches more than 16 bits away;
11330
+ * blocking matches come first, then the closest. A block raises an allowed, limited or
11331
+ * age-restricted decision to `blocked`, with `source: "hash-list"`, and a flag only records the
11332
+ * match.
11308
11333
  */
11309
11334
  async withHashMatches(asset, bytes) {
11310
- const hash = [...new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))].map((byte) => byte.toString(16).padStart(2, "0")).join("");
11311
- const matches = [...this.hashListEntries.values()].filter((entry) => entry.hash === hash && (entry.quality === null || entry.quality >= HASH_MATCH_MIN_QUALITY) && this.hashLists.has(entry.hashListId)).map((entry) => ({
11312
- source: "hash-list",
11313
- hashListId: entry.hashListId,
11314
- hashListEntryId: entry.id,
11315
- distance: 0,
11316
- action: this.hashLists.get(entry.hashListId).action
11317
- })).sort((a, b) => Number(b.action === "block") - Number(a.action === "block")).slice(0, MAX_RECORDED_HASH_MATCHES);
11335
+ const { hash, quality } = this.perceptualHashes.find((known) => sameBytes(known.bytes, bytes)) ?? {
11336
+ hash: await sha256Hex(bytes),
11337
+ quality: 100
11338
+ };
11339
+ const matches = [...this.hashListEntries.values()].flatMap((entry) => {
11340
+ const list = this.hashLists.get(entry.hashListId);
11341
+ const distance = hashDistance(hash, entry.hash);
11342
+ if (!list || quality < HASH_MATCH_MIN_QUALITY || entry.quality !== null && entry.quality < HASH_MATCH_MIN_QUALITY || distance > HASH_MATCH_MAX_DISTANCE) return [];
11343
+ const action = list.action === "block" && distance <= HASH_BLOCK_MAX_DISTANCE ? "block" : "flag";
11344
+ return [{
11345
+ source: "hash-list",
11346
+ hashListId: entry.hashListId,
11347
+ hashListEntryId: entry.id,
11348
+ distance,
11349
+ action
11350
+ }];
11351
+ }).sort((a, b) => Number(b.action === "block") - Number(a.action === "block") || a.distance - b.distance).slice(0, MAX_RECORDED_HASH_MATCHES);
11318
11352
  const hashed = {
11319
11353
  ...asset,
11320
11354
  content: {
11321
11355
  ...asset.content,
11322
11356
  perceptualHash: hash,
11323
- perceptualHashQuality: 100
11357
+ perceptualHashQuality: quality
11324
11358
  }
11325
11359
  };
11326
11360
  if (!matches.length) return hashed;
@@ -11654,7 +11688,9 @@ var MockCalmLensApi = class {
11654
11688
  const fields = this.uploadFields(request);
11655
11689
  const token = request.headers.get("authorization");
11656
11690
  if (preset.access === "token" && !token) throw fail(API_ERROR_CODES.UPLOAD_PRESET_TOKEN_REQUIRED);
11657
- const tokenExternalId = token ? decodeUploadToken(token.replace(/^Bearer /, ""))?.claims.x : void 0;
11691
+ const claims = token ? decodeUploadToken(token.replace(/^Bearer /, ""))?.claims : void 0;
11692
+ if (claims && this.usedUploadTokens.has(claims.n)) throw fail(API_ERROR_CODES.UPLOAD_TOKEN_USED);
11693
+ const tokenExternalId = claims?.x;
11658
11694
  if (fields.externalId && fields.externalId !== tokenExternalId) throw fail(API_ERROR_CODES.UPLOAD_PRESET_FIELD_NOT_ALLOWED, { details: { field: "externalId" } });
11659
11695
  for (const field of [
11660
11696
  "metadata",
@@ -11676,6 +11712,7 @@ var MockCalmLensApi = class {
11676
11712
  limitBytes: preset.maxSizeInBytes,
11677
11713
  source: "preset"
11678
11714
  } });
11715
+ if (claims) this.usedUploadTokens.add(claims.n);
11679
11716
  const asset = await this.storeAsset({
11680
11717
  ...fields,
11681
11718
  externalId: tokenExternalId,
@@ -11686,7 +11723,10 @@ var MockCalmLensApi = class {
11686
11723
  ...preset.processingOptions?.features && { features: preset.processingOptions.features },
11687
11724
  retainContent: preset.processingOptions?.retainContent ?? true
11688
11725
  }
11689
- }, request.query.get("wait") === "false");
11726
+ }, request.query.get("wait") === "false").catch((error) => {
11727
+ if (claims) this.usedUploadTokens.delete(claims.n);
11728
+ throw error;
11729
+ });
11690
11730
  session.uploads.add(asset.id);
11691
11731
  return toUploaded(asset);
11692
11732
  }
@@ -12243,6 +12283,25 @@ var MockCalmLensApi = class {
12243
12283
  });
12244
12284
  }
12245
12285
  };
12286
+ /** The SHA-256 of `bytes` in lowercase hex. */
12287
+ async function sha256Hex(bytes) {
12288
+ return [...new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))].map((byte) => byte.toString(16).padStart(2, "0")).join("");
12289
+ }
12290
+ /** How many bits two 64-character hex hashes differ by. */
12291
+ function hashDistance(a, b) {
12292
+ let distance = 0;
12293
+ for (let i = 0; i < 64; i += 8) {
12294
+ let bits = (Number.parseInt(a.slice(i, i + 8), 16) ^ Number.parseInt(b.slice(i, i + 8), 16)) >>> 0;
12295
+ while (bits) {
12296
+ bits &= bits - 1;
12297
+ distance++;
12298
+ }
12299
+ }
12300
+ return distance;
12301
+ }
12302
+ function sameBytes(a, b) {
12303
+ return a.length === b.length && a.every((byte, i) => byte === b[i]);
12304
+ }
12246
12305
  // src/testing/MockStorage.ts
12247
12306
  var InMemoryMockImageStorage = class {
12248
12307
  constructor() {
@@ -12428,7 +12487,7 @@ var MockCalmLensServerClient = class extends CalmLensServerClient {
12428
12487
  }
12429
12488
  /**
12430
12489
  * Fetches a URL of the mock's CDN as a browser would, without the API key: a signed asset URL
12431
- * from `cdn.signAssetUrl` (with a resource appended), or a public one from `cdn.getAssetUrl`.
12490
+ * from `cdn.signAssetUrl`, or a public one from `cdn.getAssetUrl`.
12432
12491
  * The request is recorded like any other.
12433
12492
  */
12434
12493
  fetchCdn(url, init) {
@@ -12474,6 +12533,16 @@ var MockCalmLensServerClient = class extends CalmLensServerClient {
12474
12533
  this.#api.serveUrl(url, content);
12475
12534
  }
12476
12535
  /**
12536
+ * Makes the mock hash an image upload of exactly `content` (bytes, or text as UTF-8) as `hash`, a
12537
+ * PDQ hash of 64 hexadecimal characters, with `quality` (0 to 100, default 100), instead of the
12538
+ * SHA-256 of its bytes. Hash list entries match hashes up to 31 bits away, as in CalmLens, so a
12539
+ * test can make a resized or recompressed copy a near match of a listed image: declare the
12540
+ * copy's hash a few bits from the entry's.
12541
+ */
12542
+ setPerceptualHash(content, hash, quality = 100) {
12543
+ this.#api.setPerceptualHash(content, hash, quality);
12544
+ }
12545
+ /**
12477
12546
  * Changes the grants of the mock's API key, as editing the key in the portal would: later
12478
12547
  * requests, such as `cdn.serve`, use them. The key itself stays the same, so idempotency keys
12479
12548
  * it used still replay.
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-87kiUg0H.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-Ccy4-_sN.js";
1
+ import "./CalmLensTypes-DF7wh23M.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-Dnm9bJPB.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> {
@@ -1,5 +1,5 @@
1
- import { r as appendAssetLocation } from "./CalmLensCdn-CL1P1v2t.js";
2
- import "./Core-WxPuobo_.js";
1
+ import { a as assetUrlOf, r as appendAssetLocation } from "./CalmLensCdn-DpJ7kIqG.js";
2
+ import "./Core-DGF84gwM.js";
3
3
  // src/ui/viewers/PdfLoader.ts
4
4
  let loading;
5
5
  /**
@@ -81,11 +81,11 @@ const responseCode = async (response) => {
81
81
  }
82
82
  };
83
83
  /**
84
- * The CDN URLs a viewer loads: resource paths beneath the asset URL (`src`), public or signed,
85
- * with the viewer claims that say something. When a URL stops working (`refresh`), as an expired
86
- * signed one does, it asks `onExpired` once for a fresh asset URL, and again only after that one
87
- * has worked (`loaded`), so a URL that keeps failing ends in the viewer's fallback. Without
88
- * `onExpired` nothing is refreshed.
84
+ * The CDN URLs a viewer loads: resource paths beneath the asset URL of `src` (a public or signed
85
+ * asset URL, or a resource URL beneath one), with the viewer claims that say something. When a URL
86
+ * stops working (`refresh`), as an expired signed one does, it asks `onExpired` once for a fresh
87
+ * URL, and again only after that one has worked (`loaded`), so a URL that keeps failing ends in the
88
+ * viewer's fallback. Without `onExpired` nothing is refreshed.
89
89
  */
90
90
  var ViewerUrls = class {
91
91
  #options;
@@ -112,7 +112,7 @@ var ViewerUrls = class {
112
112
  /** A resource's URL beneath the asset URL. The placeholder is never age-gated, so it needs no age claim. */
113
113
  url(resource, transform) {
114
114
  const { viewerClaims } = this.#options;
115
- return appendAssetLocation(this.#src, {
115
+ return appendAssetLocation(assetUrlOf(this.#src), {
116
116
  resource,
117
117
  transform,
118
118
  viewerClaims: resource === "placeholder" && viewerClaims ? { region: viewerClaims.region } : viewerClaims
package/esm/ui.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-Ccy4-_sN.js";
2
- import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-sjnJhloQ.js";
1
+ import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-Dnm9bJPB.js";
2
+ import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-B83Pqjom.js";
3
3
  export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, type AssetDisplay, type AssetDisplayOptions, type AssetDocumentOptions, type AssetEventHandlers, type AssetImageOptions, type AssetImageSource, type AssetOptions, type AssetProps, AssetSession, type AssetSessionState, type AssetSpreadsheetOptions, type AssetVideoOptions, type AssetView, type AssetViewer, type AssetViewerKind, AssetViewerMount, AssetViewerName, AssetViewerOptionsByKind, CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensProvidedOptions, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, INSTANT_LOAD_MS, type IconName, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, 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, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/esm/ui.js CHANGED
@@ -1,4 +1,4 @@
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-DS85DGfi.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-WxPuobo_.js";
3
- import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-X2gEFMGy.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-C0wgePYT.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-DGF84gwM.js";
3
+ import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-cXocXbjd.js";
4
4
  export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, 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, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/esm/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-87kiUg0H.js";
2
- import "./index-CWUnLKoF.js";
3
- import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-Ccy4-_sN.js";
4
- import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-BAH54V1q.js";
5
- import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-sjnJhloQ.js";
1
+ import { O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, un as ViewerClaims } from "./CalmLensTypes-DF7wh23M.js";
2
+ import "./index-B511mjeS.js";
3
+ import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-Dnm9bJPB.js";
4
+ import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-CURmX-DR.js";
5
+ import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-B83Pqjom.js";
6
6
  import { App, MaybeRefOrGetter, PropType, ShallowRef } from "vue";
7
7
  /** Shows a text asset's text, escaped, in a scrolling region. */
8
8
  export declare const CalmLensTextViewer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
package/esm/vue.js CHANGED
@@ -1,8 +1,8 @@
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-DS85DGfi.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-WxPuobo_.js";
3
- import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController$1, r as isFileAccepted, t as UploadController } from "./UploadController-X2gEFMGy.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-C0wgePYT.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-DGF84gwM.js";
3
+ import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController$1, r as isFileAccepted, t as UploadController } from "./UploadController-cXocXbjd.js";
4
4
  import { c as renderFileIconSvg } from "./FileIcons-M6dzjFxd.js";
5
- import { t as createUploadController } from "./BrowserUpload-DSLCpWgz.js";
5
+ import { t as createUploadController } from "./BrowserUpload-DOcZaSWT.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) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calmlens",
3
- "version": "0.31.1",
3
+ "version": "0.33.0",
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",