calmlens 0.24.0 → 0.26.1

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 (84) hide show
  1. package/README.md +14 -14
  2. package/bin/calmlens.js +2202 -521
  3. package/cjs/{BrowserUpload-DB-G4tjH.js → BrowserUpload-DdkcoZLH.js} +1 -1
  4. package/{esm/BrowserUpload-nyagMGlJ.d.ts → cjs/BrowserUpload-zYWKtFSs.d.ts} +2 -2
  5. package/cjs/{CalmLensAppClient-CmikPp9x.js → CalmLensAppClient-Gu9mU_66.js} +22 -15
  6. package/{esm/CalmLensAppClient-8qOu4bIX.d.ts → cjs/CalmLensAppClient-mTTjqpRc.d.ts} +5 -11
  7. package/cjs/{CalmLensOptionKeys-BbMF4k44.js → CalmLensOptionKeys-BCITGsr9.js} +138 -90
  8. package/cjs/CalmLensServerClient-D5-njsNk.d.ts +357 -0
  9. package/cjs/{CalmLensServerClient-DJyULgDN.js → CalmLensServerClient-DHmAPT1u.js} +283 -303
  10. package/cjs/{CalmLensTypes-D3eKASff.d.ts → CalmLensTypes-Df8eBgWB.d.ts} +228 -59
  11. package/cjs/{Core-dsHfSHt3.d.ts → Core-CREGGR0L.d.ts} +10 -3
  12. package/cjs/{Core-DnXZJjWN.js → Core-DAf9lqe2.js} +30 -12
  13. package/{esm/ModerationContextLimits-BFILRYw_.js → cjs/ModerationContextLimits-D4iwqoN_.js} +858 -28
  14. package/cjs/{ReactUpload-DWnJElAd.js → ReactUpload-BNIbpxIH.js} +38 -2
  15. package/cjs/ReactUpload-D4htIz8X.d.ts +27 -0
  16. package/cjs/{UploadController-CEHCQar2.js → UploadController-B_lKxvpM.js} +16 -3
  17. package/cjs/{WebhookPayload-DiBh-W7_.d.ts → WebhookPayload-DMa6ihHr.d.ts} +152 -3
  18. package/cjs/app.d.ts +5 -5
  19. package/cjs/app.js +20 -2
  20. package/cjs/elements.d.ts +5 -5
  21. package/cjs/elements.js +102 -67
  22. package/{esm/index-L7S6-AX8.d.ts → cjs/index-CtpQldn_.d.ts} +2 -2
  23. package/cjs/index.d.ts +4 -4
  24. package/cjs/index.js +19 -1
  25. package/cjs/react-native.d.ts +3 -3
  26. package/cjs/react-native.js +6 -4
  27. package/cjs/react.d.ts +5 -4
  28. package/cjs/react.js +10 -14
  29. package/cjs/server.d.ts +5 -5
  30. package/cjs/server.js +20 -2
  31. package/cjs/testing.d.ts +11 -9
  32. package/cjs/testing.js +73 -41
  33. package/cjs/{ui-DJPSG8nD.d.ts → ui-BwFPFrno.d.ts} +2 -2
  34. package/cjs/{ui-DjX32iuB.js → ui-CvlJmRYM.js} +6 -4
  35. package/cjs/ui.d.ts +3 -3
  36. package/cjs/ui.js +4 -3
  37. package/cjs/vue.d.ts +15 -8
  38. package/cjs/vue.js +29 -16
  39. package/esm/{BrowserUpload-B9IJOAOn.js → BrowserUpload-BAWYEBd7.js} +1 -1
  40. package/{cjs/BrowserUpload-nyagMGlJ.d.ts → esm/BrowserUpload-zYWKtFSs.d.ts} +2 -2
  41. package/esm/{CalmLensAppClient-DKDX61Ip.js → CalmLensAppClient-DNkIZb6x.js} +22 -15
  42. package/{cjs/CalmLensAppClient-8qOu4bIX.d.ts → esm/CalmLensAppClient-mTTjqpRc.d.ts} +5 -11
  43. package/esm/{CalmLensOptionKeys-CEX6GvWi.js → CalmLensOptionKeys-CYHJo3nV.js} +133 -91
  44. package/esm/{CalmLensServerClient-DM147w2r.js → CalmLensServerClient-B1AiR4nv.js} +283 -303
  45. package/esm/CalmLensServerClient-D5-njsNk.d.ts +357 -0
  46. package/esm/{CalmLensTypes-D3eKASff.d.ts → CalmLensTypes-Df8eBgWB.d.ts} +228 -59
  47. package/esm/{Core-dsHfSHt3.d.ts → Core-CREGGR0L.d.ts} +10 -3
  48. package/esm/{Core-ix7mc07M.js → Core-xNBQxZWH.js} +30 -12
  49. package/{cjs/ModerationContextLimits-CPNFkp0P.js → esm/ModerationContextLimits-DxuPP4uM.js} +475 -285
  50. package/esm/{ReactUpload-CW1v2fmH.js → ReactUpload-BWifQdLv.js} +34 -4
  51. package/esm/ReactUpload-D4htIz8X.d.ts +27 -0
  52. package/esm/{UploadController-4wdF7tKa.js → UploadController-jlJdddyI.js} +11 -4
  53. package/esm/{WebhookPayload-DiBh-W7_.d.ts → WebhookPayload-DMa6ihHr.d.ts} +152 -3
  54. package/esm/app.d.ts +5 -5
  55. package/esm/app.js +3 -3
  56. package/esm/elements.d.ts +5 -5
  57. package/esm/elements.js +102 -68
  58. package/{cjs/index-L7S6-AX8.d.ts → esm/index-CtpQldn_.d.ts} +2 -2
  59. package/esm/index.d.ts +4 -4
  60. package/esm/index.js +1 -1
  61. package/esm/react-native.d.ts +3 -3
  62. package/esm/react-native.js +5 -5
  63. package/esm/react.d.ts +5 -4
  64. package/esm/react.js +9 -15
  65. package/esm/server.d.ts +5 -5
  66. package/esm/server.js +3 -3
  67. package/esm/styles.css +28 -10
  68. package/esm/svelte/CalmLensUploader.svelte +17 -17
  69. package/esm/svelte/context.js +21 -0
  70. package/esm/svelte/index.d.ts +12 -0
  71. package/esm/svelte/index.js +1 -0
  72. package/esm/testing.d.ts +11 -9
  73. package/esm/testing.js +73 -41
  74. package/esm/{ui-eVZ1gGuL.js → ui-BXzzqh7M.js} +6 -4
  75. package/esm/{ui-DJPSG8nD.d.ts → ui-BwFPFrno.d.ts} +2 -2
  76. package/esm/ui.d.ts +3 -3
  77. package/esm/ui.js +4 -4
  78. package/esm/vue.d.ts +15 -8
  79. package/esm/vue.js +29 -18
  80. package/package.json +16 -6
  81. package/cjs/CalmLensServerClient-CDhey01B.d.ts +0 -353
  82. package/cjs/ReactUpload-B_zmKB9X.d.ts +0 -17
  83. package/esm/CalmLensServerClient-CDhey01B.d.ts +0 -353
  84. package/esm/ReactUpload-B_zmKB9X.d.ts +0 -17
package/esm/testing.js CHANGED
@@ -1,9 +1,9 @@
1
- import { A as getRejectedUploadMimeTypeError, B as invalidArgument, H as API_ERROR_CODES, N as sleep, O as MAX_IMAGE_UPLOAD_BYTES, R as CalmLensError, S as validateAppClientOptions, T as validateServerClientOptions, U as API_ERROR_DEFINITIONS, V as invalidConfig, _ as randomUuid, f as checkTransformOptions, h as parseTransformSelector, j as normalizeUploadMimeType, m as isAcceptedUploadMimeType, r as selectModerationContextItems, z as SDK_ERROR_CODES } from "./ModerationContextLimits-BFILRYw_.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-DM147w2r.js";
3
- import { a as MOCK_HOOKS, g as validateAssetPayload, h as assetToData, m as assetDataToUint8Array } from "./CalmLensOptionKeys-CEX6GvWi.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-DxuPP4uM.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-B1AiR4nv.js";
3
+ import { _ as validateAssetPayload, a as MOCK_HOOKS, g as assetToData, h as assetDataToUint8Array } from "./CalmLensOptionKeys-CYHJo3nV.js";
4
4
  import { t as hmacSha256Hex } from "./CryptoUtils-B_x8lMIx-DhuWGzqn.js";
5
- import { t as CalmLensAppClient } from "./CalmLensAppClient-DKDX61Ip.js";
6
- import { a as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-4wdF7tKa.js";
5
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-DNkIZb6x.js";
6
+ import { o as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-jlJdddyI.js";
7
7
  import { d as getTestInputTag, m as CLASSIFICATION_CATEGORIES } from "./TestTriggers-CiFcTHX3-BK2-sgOC.js";
8
8
  import * as zod from "zod";
9
9
  // src/contract/MediaTestTriggers.js
@@ -31,7 +31,7 @@ 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-BESMSxGb.js
34
+ // src/contract/Ids-l0is4BI5.js
35
35
  var __defProp = Object.defineProperty;
36
36
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
37
37
  var __exportAll = (all, no_symbols) => {
@@ -7828,6 +7828,14 @@ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
7828
7828
  ...schemas_exports,
7829
7829
  ...checks_exports
7830
7830
  });
7831
+ const createMetaType = (type) => {
7832
+ return Object.assign((value) => {
7833
+ return {
7834
+ type,
7835
+ data: value ?? {}
7836
+ };
7837
+ }, type);
7838
+ };
7831
7839
  (/* @__PURE__ */ __commonJSMin(((exports, module) => {
7832
7840
  const CHARS_GLOBAL_BACKSLASH_SUPPORTED_RX = /[\0\b\t\n\r\x1a"'\\]/g;
7833
7841
  const CHARS_ESCAPE_BACKSLASH_SUPPORTED_MAP = {
@@ -7884,6 +7892,39 @@ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
7884
7892
  }
7885
7893
  module.exports = escapeString;
7886
7894
  })))();
7895
+ const isZodTypeExtends = (type, zodType) => {
7896
+ if (type instanceof zodType) return type;
7897
+ if (type.def.type === "union") {
7898
+ for (const option of type.def.options) if (isZodTypeExtends(option, zodType)) return option;
7899
+ return false;
7900
+ }
7901
+ const rootType = type.def.innerType ?? type.def.in;
7902
+ if (rootType) return isZodTypeExtends(rootType, zodType);
7903
+ return false;
7904
+ };
7905
+ createMetaType({
7906
+ id: "foreignKey",
7907
+ check: (type) => {
7908
+ if (isZodTypeExtends(type, zod.ZodString) || isZodTypeExtends(type, zod.ZodNumber)) return { success: true };
7909
+ return {
7910
+ success: false,
7911
+ message: "Foreign key must be a string or number"
7912
+ };
7913
+ }
7914
+ });
7915
+ createMetaType({
7916
+ id: "primaryKey",
7917
+ check: (type) => {
7918
+ if (isZodTypeExtends(type, zod.ZodString) || isZodTypeExtends(type, zod.ZodNumber)) return { success: true };
7919
+ return {
7920
+ success: false,
7921
+ message: "Primary key must be a string or number"
7922
+ };
7923
+ }
7924
+ });
7925
+ createMetaType({ id: "updatedAt" });
7926
+ createMetaType({ id: "monotonicTimestamp" });
7927
+ createMetaType({ id: "backfill" });
7887
7928
  /**
7888
7929
  * The prefix of every kind of object customers can see, so an ID says what it identifies:
7889
7930
  * `proj_8fK2mQx7Lp4NvB3tRz9Y` is a project. Rows that never leave the backend (usage meters, upload
@@ -7987,7 +8028,7 @@ const EXAMPLE_IDS = {
7987
8028
  * across the packages that build records from plain strings).
7988
8029
  */
7989
8030
  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]] });
7990
- // src/contract/Permissions-DPNlE8m-.js
8031
+ // src/contract/Permissions-CJ9upU6w.js
7991
8032
  const ACTION_SCHEMA = zod.enum([
7992
8033
  "assets:read",
7993
8034
  "assets:download",
@@ -8664,9 +8705,9 @@ const MOCK_ASSET_FILTER_FIELDS = {
8664
8705
  "=out="
8665
8706
  ]
8666
8707
  },
8667
- "classification.moderation.status": {
8708
+ "classification.moderation.decision": {
8668
8709
  kind: "text",
8669
- nullable: false,
8710
+ nullable: true,
8670
8711
  operators: [
8671
8712
  "==",
8672
8713
  "!=",
@@ -9061,7 +9102,7 @@ const searchFieldValues = (asset) => [
9061
9102
  ["type", asset.type],
9062
9103
  ["content.format", asset.content?.format ?? ""],
9063
9104
  ["content.extension", asset.content?.extension ?? ""],
9064
- ["classification.moderation.status", asset.classification.moderation.status]
9105
+ ["classification.moderation.decision", asset.classification.moderation.decision ?? "pending"]
9065
9106
  ];
9066
9107
  /** The API's keyword score for the whole lowercased query. */
9067
9108
  const keywordScore = (values, query) => {
@@ -9116,15 +9157,12 @@ const REVIEW_DECISIONS = [
9116
9157
  */
9117
9158
  const MOCK_OPERATIONS = [
9118
9159
  "assets.list",
9119
- "assets.iterate",
9120
9160
  "assets.search",
9121
9161
  "assets.retrieve",
9122
9162
  "assets.waitForDecision",
9123
9163
  "assets.update",
9124
9164
  "assets.listChildren",
9125
- "assets.iterateChildren",
9126
9165
  "assets.listTimeline",
9127
- "assets.iterateTimeline",
9128
9166
  "assets.create",
9129
9167
  "assets.classify",
9130
9168
  "assets.uploadPart",
@@ -9140,26 +9178,21 @@ const MOCK_OPERATIONS = [
9140
9178
  "cdn.getAssetInfo",
9141
9179
  "cdn.signAssetUrl",
9142
9180
  "events.list",
9143
- "events.pages",
9144
9181
  "folders.list",
9145
- "folders.iterate",
9146
9182
  "folders.retrieve",
9147
9183
  "folders.create",
9148
9184
  "folders.update",
9149
9185
  "folders.delete",
9150
9186
  "folders.move",
9151
9187
  "hashLists.list",
9152
- "hashLists.iterate",
9153
9188
  "hashLists.retrieve",
9154
9189
  "hashLists.create",
9155
9190
  "hashLists.update",
9156
9191
  "hashLists.delete",
9157
9192
  "hashLists.listEntries",
9158
- "hashLists.iterateEntries",
9159
9193
  "hashLists.addEntry",
9160
9194
  "hashLists.removeEntry",
9161
9195
  "policies.list",
9162
- "policies.iterate",
9163
9196
  "policies.retrieve",
9164
9197
  "policies.create",
9165
9198
  "policies.update",
@@ -9170,7 +9203,6 @@ const MOCK_OPERATIONS = [
9170
9203
  "policies.retrieveAssigned",
9171
9204
  "policies.assign",
9172
9205
  "lenses.list",
9173
- "lenses.iterate",
9174
9206
  "lenses.create",
9175
9207
  "lenses.retrieve",
9176
9208
  "lenses.update",
@@ -9178,7 +9210,6 @@ const MOCK_OPERATIONS = [
9178
9210
  "ensureLens",
9179
9211
  "ensureLenses",
9180
9212
  "uploadPresets.list",
9181
- "uploadPresets.iterate",
9182
9213
  "uploadPresets.ensure",
9183
9214
  "uploadPresets.delete",
9184
9215
  "projectSettings.get",
@@ -9236,7 +9267,7 @@ const toEventAsset = (asset) => ({
9236
9267
  classification: {
9237
9268
  status: asset.classification.status,
9238
9269
  testInput: asset.classification.testInput,
9239
- moderation: { status: asset.classification.moderation.status }
9270
+ moderation: { decision: asset.classification.moderation.decision }
9240
9271
  },
9241
9272
  content: { status: asset.content.status }
9242
9273
  });
@@ -9544,29 +9575,29 @@ const operationsOf = (request) => {
9544
9575
  const [root] = segments;
9545
9576
  if (root === "projects") {
9546
9577
  switch (segments.slice(2).join("/")) {
9547
- case "events": return ["events.list", "events.pages"];
9548
- case "lenses": return method === "GET" ? ["lenses.list", "lenses.iterate"] : method === "POST" ? ["lenses.create"] : ["ensureLenses", "ensureLens"];
9549
- case "folders": return method === "GET" ? ["folders.list", "folders.iterate"] : ["folders.create"];
9550
- case "hash-lists": return method === "GET" ? ["hashLists.list", "hashLists.iterate"] : ["hashLists.create"];
9578
+ case "events": return ["events.list"];
9579
+ case "lenses": return method === "GET" ? ["lenses.list"] : method === "POST" ? ["lenses.create"] : ["ensureLenses", "ensureLens"];
9580
+ case "folders": return method === "GET" ? ["folders.list"] : ["folders.create"];
9581
+ case "hash-lists": return method === "GET" ? ["hashLists.list"] : ["hashLists.create"];
9551
9582
  case "policy": return method === "GET" ? ["policies.retrieveAssigned"] : ["policies.assign"];
9552
- case "upload-presets": return method === "GET" ? ["uploadPresets.list", "uploadPresets.iterate"] : ["uploadPresets.ensure"];
9583
+ case "upload-presets": return method === "GET" ? ["uploadPresets.list"] : ["uploadPresets.ensure"];
9553
9584
  case "settings": return method === "GET" ? ["projectSettings.get"] : ["projectSettings.update"];
9554
9585
  case "metadata-fields": return method === "GET" ? ["metadataFields.list"] : ["metadataFields.ensure"];
9555
9586
  case "assets/search": return ["assets.search"];
9556
9587
  case "assets/batch": return ["assets.batch"];
9557
9588
  case "signed-asset-urls": return ["cdn.signAssetUrl"];
9558
9589
  case "assets":
9559
- if (method === "GET") return ["assets.list", "assets.iterate"];
9590
+ if (method === "GET") return ["assets.list"];
9560
9591
  if (query.get("wait") === "false") return ["assets.create"];
9561
9592
  return isTextUpload(request) ? ["assets.classify", "text.classify"] : ["assets.classify"];
9562
9593
  }
9563
- if (segments[2] === "assets" && segments[4] === "timeline" && segments.length === 5) return ["assets.listTimeline", "assets.iterateTimeline"];
9594
+ if (segments[2] === "assets" && segments[4] === "timeline" && segments.length === 5) return ["assets.listTimeline"];
9564
9595
  if (segments[2] === "metadata-fields" && segments.length === 4) return ["metadataFields.delete"];
9565
9596
  return [];
9566
9597
  }
9567
9598
  if (root === "policies") {
9568
9599
  const [, policyId, policyAction] = segments;
9569
- if (policyId === void 0) return method === "GET" ? ["policies.list", "policies.iterate"] : ["policies.create"];
9600
+ if (policyId === void 0) return method === "GET" ? ["policies.list"] : ["policies.create"];
9570
9601
  if (policyAction === "reset") return ["policies.reset"];
9571
9602
  if (policyAction === "upgrade") return ["policies.upgrade"];
9572
9603
  if (policyAction === "automatic-updates") return ["policies.setAutomaticUpdates"];
@@ -9585,7 +9616,7 @@ const operationsOf = (request) => {
9585
9616
  return method === "GET" ? ["folders.retrieve"] : method === "PATCH" ? ["folders.update"] : ["folders.delete"];
9586
9617
  }
9587
9618
  if (root === "hash-lists" && id !== void 0) {
9588
- if (action === "entries") return method === "GET" ? ["hashLists.listEntries", "hashLists.iterateEntries"] : ["hashLists.addEntry"];
9619
+ if (action === "entries") return method === "GET" ? ["hashLists.listEntries"] : ["hashLists.addEntry"];
9589
9620
  return method === "GET" ? ["hashLists.retrieve"] : method === "PATCH" ? ["hashLists.update"] : ["hashLists.delete"];
9590
9621
  }
9591
9622
  if (root === "hash-list-entries" && id !== void 0) return ["hashLists.removeEntry"];
@@ -9593,7 +9624,7 @@ const operationsOf = (request) => {
9593
9624
  switch (action) {
9594
9625
  case void 0: return method === "GET" ? ["assets.retrieve", "assets.waitForDecision"] : method === "PATCH" ? ["assets.update"] : ["assets.delete"];
9595
9626
  case "content": return ["assets.removeContent"];
9596
- case "children": return ["assets.listChildren", "assets.iterateChildren"];
9627
+ case "children": return ["assets.listChildren"];
9597
9628
  case "part": return ["assets.uploadPart"];
9598
9629
  case "move": return ["assets.move"];
9599
9630
  case "retry": return ["assets.retry"];
@@ -9691,7 +9722,7 @@ var MockCalmLensApi = class {
9691
9722
  if (!asset) return this.pushEvent(input);
9692
9723
  const snapshot = toEventAsset(asset);
9693
9724
  const announced = ANNOUNCED_STATUS[input.type];
9694
- if (announced) snapshot.classification.moderation.status = announced;
9725
+ if (announced) snapshot.classification.moderation.decision = announced;
9695
9726
  return this.pushEvent({
9696
9727
  ...input,
9697
9728
  asset: snapshot
@@ -9765,8 +9796,8 @@ var MockCalmLensApi = class {
9765
9796
  if (note.length > MAX_DECISION_NOTE_LENGTH) throw invalidField("validation/too-big", "note");
9766
9797
  const asset = await this.findOwnAsset(assetId);
9767
9798
  if (asset.upload.status === "uploading" || asset.classification.status === "processing") throw fail(API_ERROR_CODES.ASSET_PROCESSING);
9768
- const status = asset.classification.moderation.status;
9769
- if (decision !== "purged" && decision !== "blocked" && status === "pending") throw fail(API_ERROR_CODES.ASSET_DECISION_NOT_ALLOWED);
9799
+ const status = asset.classification.moderation.decision;
9800
+ if (decision !== "purged" && decision !== "blocked" && status === null) throw fail(API_ERROR_CODES.ASSET_DECISION_NOT_ALLOWED);
9770
9801
  if (status === decision) throw fail(API_ERROR_CODES.ASSET_DECISION_UNCHANGED);
9771
9802
  if (decision !== "purged" && decision !== "blocked" && status === "purged") throw fail(API_ERROR_CODES.ASSET_CONTENT_PURGED);
9772
9803
  return this.recordDecision(asset, decision, { note });
@@ -10479,7 +10510,7 @@ var MockCalmLensApi = class {
10479
10510
  }
10480
10511
  async retryAsset(assetId) {
10481
10512
  const asset = await this.findOwnAsset(assetId);
10482
- if (asset.classification.status !== "failed" || asset.classification.moderation.status !== "pending") throw fail(API_ERROR_CODES.ASSET_NOT_RETRYABLE);
10513
+ if (asset.classification.status !== "failed" || asset.classification.moderation.decision !== null) throw fail(API_ERROR_CODES.ASSET_NOT_RETRYABLE);
10483
10514
  if (asset.content.status === "removed") throw fail(API_ERROR_CODES.ASSET_CONTENT_UNAVAILABLE);
10484
10515
  const retried = await this.databaseStorage.updateAsset(await this.applyOutcome(asset, "pending"));
10485
10516
  this.recordLifecycleEvent("asset.retried", retried);
@@ -10518,7 +10549,7 @@ var MockCalmLensApi = class {
10518
10549
  },
10519
10550
  {
10520
10551
  key: "moderation-status",
10521
- value: asset.classification.moderation.status
10552
+ value: asset.classification.moderation.decision
10522
10553
  }
10523
10554
  ]
10524
10555
  });
@@ -10791,7 +10822,7 @@ var MockCalmLensApi = class {
10791
10822
  progress: null,
10792
10823
  testInput: false,
10793
10824
  moderation: {
10794
- status: "pending",
10825
+ decision: null,
10795
10826
  manualReviews: [],
10796
10827
  automatedStatus: null,
10797
10828
  policy: null,
@@ -11124,7 +11155,7 @@ var MockCalmLensApi = class {
11124
11155
  completedAt: decided ? now : null,
11125
11156
  moderation: {
11126
11157
  ...asset.classification.moderation,
11127
- status: decided ? outcome : "pending",
11158
+ decision: decided ? outcome : null,
11128
11159
  ...report
11129
11160
  }
11130
11161
  }
@@ -11175,7 +11206,7 @@ var MockCalmLensApi = class {
11175
11206
  classification: {
11176
11207
  status: asset.classification.status,
11177
11208
  failureReason: asset.classification.failureReason,
11178
- ...preset.showDecisions !== false && { moderation: { status: asset.classification.moderation.status } }
11209
+ ...preset.showDecisions !== false && { moderation: { decision: asset.classification.moderation.decision } }
11179
11210
  }
11180
11211
  });
11181
11212
  const [assetId, action] = rest;
@@ -11451,6 +11482,7 @@ var MockCalmLensApi = class {
11451
11482
  storeSensitiveMetadata: false,
11452
11483
  streamingEnabled: false,
11453
11484
  aiMediaSearchEnabled: false,
11485
+ linkCheckingEnabled: false,
11454
11486
  remoteUrlRule: null,
11455
11487
  websiteSubmissionsPerMinute: null,
11456
11488
  ...this.projectSettingsValues,
@@ -11642,7 +11674,7 @@ var MockCalmLensApi = class {
11642
11674
  const grants = hasApiKey ? this.grants : [];
11643
11675
  const folders = await this.databaseStorage.listFolders?.(this.projectId) ?? [];
11644
11676
  const canDownload = () => permits(grants, "assets:download", asset.folderId ?? null, folders);
11645
- const status = asset.classification.moderation.status;
11677
+ const status = asset.classification.moderation.decision;
11646
11678
  const isHead = request.method === "HEAD";
11647
11679
  const { rendered, preview } = asset.content;
11648
11680
  if (asset.visibility !== "public" && !grant && !hasApiKey && resource !== "info") return notFound();
@@ -11740,7 +11772,7 @@ var MockCalmLensApi = class {
11740
11772
  } catch {
11741
11773
  return this.jsonResponse(400, { code: "viewer-claims/invalid" }, url);
11742
11774
  }
11743
- const status = asset.classification.moderation.status;
11775
+ const status = asset.classification.moderation.decision;
11744
11776
  const restrictedInfo = isPrivate || status === "blocked" || status === "purged";
11745
11777
  if (restrictedInfo && !authorised) return this.jsonResponse(403, { code: "asset/not-available" }, url);
11746
11778
  const availability = asset.content.safetyHold || asset.upload.status === "uploading" || status === "blocked" || status === "purged" || asset.classification.status === "failed" || asset.content.status === "removed" ? "unavailable" : status === "age-restricted" && claims.ageConfirmed !== true ? "age-restricted" : "available";
@@ -1,6 +1,6 @@
1
- import { a as appendAssetLocation } from "./ModerationContextLimits-BFILRYw_.js";
2
- import { a as placeholderHashToDataURL } from "./UploadController-4wdF7tKa.js";
3
- import "./Core-ix7mc07M.js";
1
+ import { a as appendAssetLocation } from "./ModerationContextLimits-DxuPP4uM.js";
2
+ import { o as placeholderHashToDataURL } from "./UploadController-jlJdddyI.js";
3
+ import "./Core-xNBQxZWH.js";
4
4
  // src/ui/viewers/PdfLoader.ts
5
5
  let loading;
6
6
  /**
@@ -398,7 +398,9 @@ var DocumentViewer = class extends ViewerBase {
398
398
  toolbar.insertBefore(next, count.nextSibling);
399
399
  page.addEventListener("change", () => this.#go(Number(page.value)));
400
400
  page.addEventListener("keydown", (event) => {
401
- if (event.key === "Enter") this.#go(Number(page.value));
401
+ if (event.key !== "Enter") return;
402
+ event.preventDefault();
403
+ if (!event.isComposing && event.keyCode !== 229) this.#go(Number(page.value));
402
404
  });
403
405
  zoomOut.addEventListener("click", () => this.#setZoom(this.#scale / ZOOM_STEP));
404
406
  zoomIn.addEventListener("click", () => this.#setZoom(this.#scale * ZOOM_STEP));
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-D3eKASff.js";
2
- import { G as AssetSession, W as AssetOptions, Y as AssetView, at as ImageViewerOptions, ct as TextViewerOptions, ft as WebsiteViewerOptions, it as DocumentViewerOptions, ot as PdfAssetOptions, st as SpreadsheetViewerOptions, ut as ViewerOptions } from "./Core-dsHfSHt3.js";
1
+ import "./CalmLensTypes-Df8eBgWB.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-CREGGR0L.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> {
package/esm/ui.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadItem, G as AssetSession, H as AssetImageOptions, I as UploadSnapshot, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, N as UploadControllerOptions, O as CalmLensUpload, P as UploadFile, Q as getAssetView, R as createUploadController, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, h as UploaderProps, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-dsHfSHt3.js";
2
- import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-DJPSG8nD.js";
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 CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, type IconName, type ImageViewerOptions, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, type WebsiteViewerOptions, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex };
1
+ import { $ as getAssetAspectRatio, 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 MediaPlayback, 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 AssetViewerKind, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as PdfAssetOptions, d as AssetDisplayOptions, dt as ViewerAsset, et as getAssetView, f as AssetEventHandlers, ft as ViewerOptions, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as pickAssetSource, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as SpreadsheetViewerOptions, m as UploaderDisplayOptions, mt as WebsiteViewerOptions, n as CalmLensTheme, nt as getPeakHeights, o as createProgressFetch, ot as DocumentViewerOptions, p as AssetProps, pt as ViewerTextOptions, q as AssetSession, r as resolveTheme, rt as getPlayedPercent, s as ICONS, st as ImageViewerOptions, t as CALMLENS_THEME, tt as getAssetViewKey, u as ASSET_FILE_ICON_SIZE, ut as TextViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-CREGGR0L.js";
2
+ import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-BwFPFrno.js";
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, type IconName, type ImageViewerOptions, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, type WebsiteViewerOptions, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/esm/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-eVZ1gGuL.js";
2
- import { i as createProgressFetch, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-4wdF7tKa.js";
3
- import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-ix7mc07M.js";
4
- export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, MediaStreamPlayer, UploadController, VIEWER_STYLES, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex };
1
+ import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-BXzzqh7M.js";
2
+ import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-jlJdddyI.js";
3
+ import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-xNBQxZWH.js";
4
+ export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, MediaStreamPlayer, UploadController, VIEWER_STYLES, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/esm/vue.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { D as CalmLensAppClientOptions, h as AssetModerationStatus, r as AssetAvailability, sn as ViewerClaims } from "./CalmLensTypes-D3eKASff.js";
2
- import "./index-L7S6-AX8.js";
3
- import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, G as AssetSession, H as AssetImageOptions, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, P as UploadFile, Q as getAssetView, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-dsHfSHt3.js";
4
- import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-nyagMGlJ.js";
5
- import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-DJPSG8nD.js";
6
- import { MaybeRefOrGetter, PropType, ShallowRef } from "vue";
1
+ import { O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, tn as ViewerClaims } from "./CalmLensTypes-Df8eBgWB.js";
2
+ import "./index-CtpQldn_.js";
3
+ import { $ as getAssetAspectRatio, 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 MediaPlayback, 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 AssetViewerKind, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as PdfAssetOptions, d as AssetDisplayOptions, dt as ViewerAsset, et as getAssetView, f as AssetEventHandlers, ft as ViewerOptions, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as pickAssetSource, j as CustomUploadResult, l as IconName, lt as SpreadsheetViewerOptions, m as UploaderDisplayOptions, mt as WebsiteViewerOptions, n as CalmLensTheme, nt as getPeakHeights, o as createProgressFetch, ot as DocumentViewerOptions, p as AssetProps, pt as ViewerTextOptions, q as AssetSession, r as resolveTheme, rt as getPlayedPercent, s as ICONS, st as ImageViewerOptions, t as CALMLENS_THEME, tt as getAssetViewKey, u as ASSET_FILE_ICON_SIZE, ut as TextViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-CREGGR0L.js";
4
+ import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-zYWKtFSs.js";
5
+ import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-BwFPFrno.js";
6
+ import { App, MaybeRefOrGetter, PropType, ShallowRef } from "vue";
7
7
  /** Shows an image asset's rendered file, fitted to the element, over its placeholder. */
8
8
  export declare const CalmLensImageViewer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
9
  /** The asset URL, public or signed. */
@@ -714,12 +714,19 @@ export interface UseCalmLensUploadResult<F extends UploadFile = File> {
714
714
  clear: UploadController<F>["clear"];
715
715
  start: UploadController<F>["start"];
716
716
  }
717
+ /**
718
+ * Gives every `CalmLensUploader` and `useCalmLensUpload` in this component's descendants these
719
+ * upload options, such as `uploadPresetId` and `tokenUrl`, so they needn't be passed to each one.
720
+ * Call it in `setup`, or pass the app to provide them app-wide. An option a component sets itself
721
+ * wins, and a nested call adds to the outer one's options.
722
+ */
723
+ export declare const provideCalmLens: <F extends UploadFile = File>(options: CalmLensProvidedOptions<F>, app?: App) => void;
717
724
  /**
718
725
  * Uploads files through an upload preset and keeps `snapshot` up to date as each one uploads and
719
726
  * is checked. Use it to build your own upload UI; `CalmLensUploader` is built on it. Uploads
720
727
  * still running when the component unmounts are cancelled.
721
728
  */
722
- export declare const useCalmLensUpload: <F extends UploadFile = File>(options: MaybeRefOrGetter<UploadControllerOptions<F>>) => UseCalmLensUploadResult<F>;
729
+ export declare const useCalmLensUpload: <F extends UploadFile = File>(own: MaybeRefOrGetter<UploadControllerOptions<F>>) => UseCalmLensUploadResult<F>;
723
730
  /**
724
731
  * A drop zone and file list that uploads through an upload preset, shows each file's progress
725
732
  * and moderation decision, and emits `uploaded` for finished uploads.
@@ -1090,4 +1097,4 @@ export declare const CalmLensAsset: import("vue").DefineComponent<import("vue").
1090
1097
  messages: Partial<CalmLensMessages>;
1091
1098
  onAgeConfirmRequest: () => void;
1092
1099
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1093
- export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, type AssetDisplay, type AssetDisplayOptions, type AssetDocumentOptions, type AssetEventHandlers, type AssetImageOptions, type AssetImageSource, type AssetOptions, type AssetProps, AssetSession, type AssetSessionState, type AssetSpreadsheetOptions, type AssetVideoOptions, type AssetView, type AssetViewer, type AssetViewerKind, AssetViewerMount, AssetViewerName, AssetViewerOptionsByKind, CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, type IconName, type ImageViewerOptions, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, type WebsiteViewerOptions, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex };
1100
+ 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, type IconName, type ImageViewerOptions, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, type WebsiteViewerOptions, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/esm/vue.js CHANGED
@@ -1,9 +1,9 @@
1
- import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-eVZ1gGuL.js";
2
- import { i as createProgressFetch, n as createUploadController$1, r as isFileAccepted, t as UploadController } from "./UploadController-4wdF7tKa.js";
3
- import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-ix7mc07M.js";
1
+ import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-BXzzqh7M.js";
2
+ import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController$1, r as isFileAccepted, t as UploadController } from "./UploadController-jlJdddyI.js";
3
+ import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-xNBQxZWH.js";
4
4
  import { c as renderFileIconSvg } from "./FileIcons-M6dzjFxd.js";
5
- import { t as createUploadController } from "./BrowserUpload-B9IJOAOn.js";
6
- import { computed, defineComponent, h, onBeforeUnmount, onMounted, onScopeDispose, ref, shallowRef, toValue, watch, watchEffect } from "vue";
5
+ import { t as createUploadController } from "./BrowserUpload-BAWYEBd7.js";
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) => ({
9
9
  type,
@@ -82,14 +82,30 @@ const subscribeSnapshot = (controller) => {
82
82
  }, { immediate: true });
83
83
  return snapshot;
84
84
  };
85
+ const CALMLENS_PROVIDED_KEY = Symbol("calmlens");
86
+ /**
87
+ * Gives every `CalmLensUploader` and `useCalmLensUpload` in this component's descendants these
88
+ * upload options, such as `uploadPresetId` and `tokenUrl`, so they needn't be passed to each one.
89
+ * Call it in `setup`, or pass the app to provide them app-wide. An option a component sets itself
90
+ * wins, and a nested call adds to the outer one's options.
91
+ */
92
+ const provideCalmLens = (options, app) => {
93
+ if (app) {
94
+ app.provide(CALMLENS_PROVIDED_KEY, options);
95
+ return;
96
+ }
97
+ provide(CALMLENS_PROVIDED_KEY, withProvidedOptions(inject(CALMLENS_PROVIDED_KEY, void 0), options));
98
+ };
85
99
  /**
86
100
  * Uploads files through an upload preset and keeps `snapshot` up to date as each one uploads and
87
101
  * is checked. Use it to build your own upload UI; `CalmLensUploader` is built on it. Uploads
88
102
  * still running when the component unmounts are cancelled.
89
103
  */
90
- const useCalmLensUpload = (options) => {
91
- const controller = createUploadController$1(toValue(options));
92
- watchEffect(() => controller.setOptions(toValue(options)));
104
+ const useCalmLensUpload = (own) => {
105
+ const provided = inject(CALMLENS_PROVIDED_KEY, void 0);
106
+ const options = () => withProvidedOptions(provided, toValue(own));
107
+ const controller = createUploadController$1(options());
108
+ watchEffect(() => controller.setOptions(options()));
93
109
  const snapshot = subscribeSnapshot(controller);
94
110
  onScopeDispose(() => controller.clear());
95
111
  return {
@@ -257,17 +273,12 @@ const CalmLensUploader = defineComponent({
257
273
  h("div", { class: "calmlens-upload__body" }, [
258
274
  h("span", { class: "calmlens-upload__name" }, item.file.name),
259
275
  h("span", { class: "calmlens-upload__size" }, itemView.size),
260
- itemView.busy && h("div", {
276
+ itemView.busy && h("progress", {
261
277
  class: "calmlens-progress",
262
- role: "progressbar",
263
278
  "aria-label": itemView.message,
264
- "aria-valuemin": 0,
265
- "aria-valuemax": 100,
266
- "aria-valuenow": itemView.progressPercent
267
- }, [h("div", {
268
- class: "calmlens-progress__bar",
269
- style: itemView.progressPercent === void 0 ? void 0 : { width: `${itemView.progressPercent}%` }
270
- })]),
279
+ max: 100,
280
+ value: itemView.progressPercent
281
+ }),
271
282
  itemView.message && h("p", {
272
283
  class: "calmlens-upload__message",
273
284
  role: "status"
@@ -594,4 +605,4 @@ const CalmLensAsset = defineComponent({
594
605
  };
595
606
  }
596
607
  });
597
- export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, CalmLensAsset, CalmLensDocumentViewer, CalmLensImageViewer, CalmLensSpreadsheetViewer, CalmLensTextViewer, CalmLensUploader, CalmLensWebsiteViewer, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, MediaStreamPlayer, UploadController, VIEWER_STYLES, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, useCalmLensUpload };
608
+ export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, CalmLensAsset, CalmLensDocumentViewer, CalmLensImageViewer, CalmLensSpreadsheetViewer, CalmLensTextViewer, CalmLensUploader, CalmLensWebsiteViewer, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, MediaStreamPlayer, UploadController, VIEWER_STYLES, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, provideCalmLens, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, useCalmLensUpload, withProvidedOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calmlens",
3
- "version": "0.24.0",
3
+ "version": "0.26.1",
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",
@@ -30,12 +30,13 @@
30
30
  "prepublishOnly": "npm run check && npm run test && npm run build",
31
31
  "test": "bun test --parallel=4 ./tests/",
32
32
  "check:fix": "tsc --noEmit --project tsconfig.json && npx @biomejs/biome check --write",
33
- "check": "tsc --noEmit --project tsconfig.json && npx @biomejs/biome check",
33
+ "check": "tsc --noEmit --project tsconfig.json && tsc --project tsconfig.contract.json && npx @biomejs/biome check",
34
34
  "cleanup": "rimraf esm && rimraf cjs && rimraf bin",
35
- "build": "npm run cleanup && rolldown -c rolldown.config.mjs && node scripts/post-build.js && npm run build:cli && npm run verify:package",
35
+ "build": "npm run cleanup && rolldown -c rolldown.config.mjs && node scripts/post-build.js && npm run build:cli && npm run verify:package && npm run verify:types",
36
36
  "build:cli": "bun scripts/build-cli.ts",
37
37
  "build:cli:binary": "bun scripts/build-cli.ts --binary",
38
- "verify:package": "node scripts/verify-package.mjs"
38
+ "verify:package": "node scripts/verify-package.mjs",
39
+ "verify:types": "node scripts/check-minimum-typescript.mjs"
39
40
  },
40
41
  "keywords": [
41
42
  "calmlens",
@@ -62,18 +63,19 @@
62
63
  "@types/bun": "^1.4.4",
63
64
  "@types/node": "26.6.5",
64
65
  "@types/react": "19.3.0",
66
+ "hls.js": "1.7.3",
65
67
  "json-schema-to-ts": "^3.1.1",
68
+ "pdfjs-dist": "6.4.299",
66
69
  "react-native": "0.86.3",
67
70
  "rimraf": "6.1.3",
68
71
  "rolldown": "1.2.15",
69
72
  "rolldown-plugin-dts": "0.28.8",
70
73
  "svelte": "5.57.2",
71
74
  "typescript": "7.0.2",
75
+ "typescript-minimum": "npm:typescript@5.9.3",
72
76
  "vue": "3.5.44"
73
77
  },
74
78
  "dependencies": {
75
- "hls.js": "1.7.3",
76
- "pdfjs-dist": "6.4.299",
77
79
  "zod": "^4.6.7"
78
80
  },
79
81
  "exports": {
@@ -210,12 +212,20 @@
210
212
  "url": "https://github.com/CalmLens/sdks/issues"
211
213
  },
212
214
  "peerDependencies": {
215
+ "hls.js": "^1.6.0",
216
+ "pdfjs-dist": ">=5",
213
217
  "react": ">=19",
214
218
  "react-native": ">=0.79",
215
219
  "svelte": ">=5",
216
220
  "vue": ">=3.3"
217
221
  },
218
222
  "peerDependenciesMeta": {
223
+ "hls.js": {
224
+ "optional": true
225
+ },
226
+ "pdfjs-dist": {
227
+ "optional": true
228
+ },
219
229
  "react": {
220
230
  "optional": true
221
231
  },