calmlens 0.30.0 → 0.31.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 (86) hide show
  1. package/bin/calmlens.js +2 -29
  2. package/{esm/BrowserUpload-DS6KT6o_.d.ts → cjs/BrowserUpload-BAH54V1q.d.ts} +2 -2
  3. package/cjs/{BrowserUpload-BNeTp6eF.js → BrowserUpload-IiRDbL85.js} +1 -1
  4. package/cjs/{CalmLensAppClient-ClqGwUbl.js → CalmLensAppClient-BBcq6pJg.js} +10 -10
  5. package/cjs/{CalmLensAppClient-B4vzxEzg.d.ts → CalmLensAppClient-CdlcDd5l.d.ts} +1 -1
  6. package/cjs/{ModerationContextLimits-BVBkcgSU.js → CalmLensCdn-2VbArrj-.js} +2 -52
  7. package/cjs/{CalmLensConnection-og0jh-Fw.js → CalmLensConnection-CpnDGa8W.js} +15 -22
  8. package/cjs/{CalmLensError-DPHJaVjX.js → CalmLensError-ifj5rLmk.js} +5 -0
  9. package/{esm/CalmLensServerClient-BJl2Hsxr.d.ts → cjs/CalmLensServerClient-CtS66dCU.d.ts} +3 -3
  10. package/cjs/{CalmLensServerClient-KsXM77rO.js → CalmLensServerClient-DbemlDXj.js} +22 -22
  11. package/cjs/{CalmLensTestInputArguments-BXDBAOg_.js → CalmLensTestInputArguments-PYuRmE0j.js} +1 -1
  12. package/cjs/{CalmLensTypes-fAgF0_lq.d.ts → CalmLensTypes-87kiUg0H.d.ts} +3 -5
  13. package/cjs/{Classification-DbXUPSvH-C0o2t4mg.d.ts → Classification-C3pkrGYS-B7EygpJn.d.ts} +2 -21
  14. package/cjs/{Core-DL531ZPG.d.ts → Core-Ccy4-_sN.d.ts} +2 -2
  15. package/cjs/{Core-eDiPpil9.js → Core-xy9aV1ED.js} +8 -8
  16. package/cjs/{ReactUpload-DAPAzAwY.js → ReactUpload-BX3XOVfb.js} +1 -1
  17. package/cjs/{ReactUpload-BoS0lr7U.d.ts → ReactUpload-DBhppuxM.d.ts} +1 -1
  18. package/{esm/TestTriggers-CLjF01NU.d.ts → cjs/TestTriggers-Daxebd0V.d.ts} +1 -1
  19. package/cjs/{UploadController-BElzwMic.js → UploadController-CmTjpOfp.js} +2 -2
  20. package/{esm/WebhookPayload-DlGoY_db.d.ts → cjs/WebhookPayload-B4rA_Dvm.d.ts} +3 -1
  21. package/cjs/app.d.ts +6 -6
  22. package/cjs/app.js +8 -11
  23. package/cjs/elements.d.ts +4 -4
  24. package/cjs/elements.js +4 -4
  25. package/cjs/{index-ChrzzIRt.d.ts → index-CWUnLKoF.d.ts} +8 -4
  26. package/cjs/index.d.ts +5 -5
  27. package/cjs/index.js +7 -10
  28. package/cjs/react-native.d.ts +2 -2
  29. package/cjs/react-native.js +7 -7
  30. package/cjs/react.d.ts +4 -4
  31. package/cjs/react.js +5 -5
  32. package/cjs/server.d.ts +6 -6
  33. package/cjs/server.js +8 -11
  34. package/cjs/test-inputs.d.ts +1 -1
  35. package/cjs/test-inputs.js +1 -1
  36. package/cjs/testing.d.ts +5 -5
  37. package/cjs/testing.js +73 -23
  38. package/cjs/{ui-COjb2Hx6.js → ui-BJKh49aM.js} +3 -3
  39. package/cjs/{ui-DpZOLeVs.d.ts → ui-sjnJhloQ.d.ts} +2 -2
  40. package/cjs/ui.d.ts +2 -2
  41. package/cjs/ui.js +3 -3
  42. package/cjs/vue.d.ts +5 -5
  43. package/cjs/vue.js +4 -4
  44. package/{cjs/BrowserUpload-DS6KT6o_.d.ts → esm/BrowserUpload-BAH54V1q.d.ts} +2 -2
  45. package/esm/{BrowserUpload-BCmj5eGu.js → BrowserUpload-C5aXj6QC.js} +1 -1
  46. package/esm/{CalmLensAppClient-B4vzxEzg.d.ts → CalmLensAppClient-CdlcDd5l.d.ts} +1 -1
  47. package/esm/{CalmLensAppClient-DcPVLn2y.js → CalmLensAppClient-gAd0C_Q_.js} +3 -3
  48. package/esm/{ModerationContextLimits-DmjWgTBa.js → CalmLensCdn-CcxEY6wB.js} +3 -35
  49. package/esm/{CalmLensConnection-Pm-g6a1l.js → CalmLensConnection-CfGVp95D.js} +2 -9
  50. package/esm/{CalmLensError-BDWThPCr.js → CalmLensError-C15tWu8W.js} +5 -0
  51. package/esm/{CalmLensServerClient-C2HGsjkT.js → CalmLensServerClient-CPWeRVWO.js} +3 -3
  52. package/{cjs/CalmLensServerClient-BJl2Hsxr.d.ts → esm/CalmLensServerClient-CtS66dCU.d.ts} +3 -3
  53. package/esm/{CalmLensTestInputArguments-Xh4GIadS.js → CalmLensTestInputArguments-CqPADTkl.js} +1 -1
  54. package/esm/{CalmLensTypes-fAgF0_lq.d.ts → CalmLensTypes-87kiUg0H.d.ts} +3 -5
  55. package/esm/{Classification-DbXUPSvH-C0o2t4mg.d.ts → Classification-C3pkrGYS-B7EygpJn.d.ts} +2 -21
  56. package/esm/{Core-DL531ZPG.d.ts → Core-Ccy4-_sN.d.ts} +2 -2
  57. package/esm/{Core-KYgLJ0eb.js → Core-DTcxpv3O.js} +3 -3
  58. package/esm/{ReactUpload-BoS0lr7U.d.ts → ReactUpload-DBhppuxM.d.ts} +1 -1
  59. package/esm/{ReactUpload-QW_RNxFp.js → ReactUpload-Dg7MtjbJ.js} +1 -1
  60. package/{cjs/TestTriggers-CLjF01NU.d.ts → esm/TestTriggers-Daxebd0V.d.ts} +1 -1
  61. package/esm/{UploadController-Civ7QPwT.js → UploadController-DVsTVJVv.js} +2 -2
  62. package/{cjs/WebhookPayload-DlGoY_db.d.ts → esm/WebhookPayload-B4rA_Dvm.d.ts} +3 -1
  63. package/esm/app.d.ts +6 -6
  64. package/esm/app.js +4 -4
  65. package/esm/elements.d.ts +4 -4
  66. package/esm/elements.js +4 -4
  67. package/esm/{index-ChrzzIRt.d.ts → index-CWUnLKoF.d.ts} +8 -4
  68. package/esm/index.d.ts +5 -5
  69. package/esm/index.js +3 -3
  70. package/esm/react-native.d.ts +2 -2
  71. package/esm/react-native.js +4 -4
  72. package/esm/react.d.ts +4 -4
  73. package/esm/react.js +5 -5
  74. package/esm/server.d.ts +6 -6
  75. package/esm/server.js +4 -4
  76. package/esm/test-inputs.d.ts +1 -1
  77. package/esm/test-inputs.js +1 -1
  78. package/esm/testing.d.ts +5 -5
  79. package/esm/testing.js +58 -8
  80. package/esm/{ui-BVXgDCO2.js → ui-DUao8UY0.js} +2 -2
  81. package/esm/{ui-DpZOLeVs.d.ts → ui-sjnJhloQ.d.ts} +2 -2
  82. package/esm/ui.d.ts +2 -2
  83. package/esm/ui.js +3 -3
  84. package/esm/vue.d.ts +5 -5
  85. package/esm/vue.js +4 -4
  86. package/package.json +1 -1
package/cjs/testing.js CHANGED
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-BXDBAOg_.js");
3
- const require_CalmLensError = require("./CalmLensError-DPHJaVjX.js");
4
- const require_ModerationContextLimits = require("./ModerationContextLimits-BVBkcgSU.js");
5
- const require_CalmLensServerClient = require("./CalmLensServerClient-KsXM77rO.js");
6
- const require_CalmLensConnection = require("./CalmLensConnection-og0jh-Fw.js");
2
+ const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-PYuRmE0j.js");
3
+ const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
4
+ const require_CalmLensCdn = require("./CalmLensCdn-2VbArrj-.js");
5
+ const require_CalmLensServerClient = require("./CalmLensServerClient-DbemlDXj.js");
6
+ const require_CalmLensConnection = require("./CalmLensConnection-CpnDGa8W.js");
7
7
  const require_CryptoUtils_BLCa_oZe = require("./CryptoUtils-BLCa-oZe-leCkr1ko.js");
8
- const require_CalmLensAppClient = require("./CalmLensAppClient-ClqGwUbl.js");
9
- const require_UploadController = require("./UploadController-BElzwMic.js");
8
+ const require_CalmLensAppClient = require("./CalmLensAppClient-BBcq6pJg.js");
9
+ const require_UploadController = require("./UploadController-CmTjpOfp.js");
10
10
  let zod = require("zod");
11
11
  let zod$1 = require_CalmLensTestInputArguments.__toESM(zod, 1);
12
12
  zod = require_CalmLensTestInputArguments.__toESM(zod);
@@ -8146,6 +8146,34 @@ const getMockApiKeyGrants = (apiKey) => {
8146
8146
  * where CalmLens gives your key's own ID.
8147
8147
  */
8148
8148
  const MOCK_API_KEY_ID = "key_mock0000000000000000";
8149
+ // src/contract/ModerationContextLimits-ooIiAjJB.js
8150
+ /** The most characters of one earlier post's text CalmLens reads. */
8151
+ const MODERATION_CONTEXT_MAX_ITEM_CHARACTERS = 2e3;
8152
+ /** Unicode code points, as every SDK counts characters. */
8153
+ const countModerationContextCharacters = (text) => {
8154
+ let count = 0;
8155
+ for (const _ of text) count++;
8156
+ return count;
8157
+ };
8158
+ /**
8159
+ * The earlier posts CalmLens uses: the most recent ones, newest first, while at most
8160
+ * `MODERATION_CONTEXT_USED_ITEMS` and `MODERATION_CONTEXT_USED_CHARACTERS` allow, returned oldest
8161
+ * first. `textOf` gives the text each post contributes, read from its asset. The newest post is
8162
+ * always kept.
8163
+ */
8164
+ const selectModerationContextItems = (items, textOf) => {
8165
+ const selected = [];
8166
+ let characters = 0;
8167
+ for (let index = items.length - 1; index >= 0; index--) {
8168
+ if (selected.length === 5) break;
8169
+ const item = items[index];
8170
+ const length = countModerationContextCharacters(textOf(item));
8171
+ if (selected.length && characters + length > 2e3) break;
8172
+ selected.unshift(item);
8173
+ characters += length;
8174
+ }
8175
+ return selected;
8176
+ };
8149
8177
  // src/testing/MockClassification.ts
8150
8178
  /** The parent categories, in the API's order. */
8151
8179
  const MOCK_CATEGORIES = [
@@ -9443,7 +9471,7 @@ const SPREADSHEET_MIME_TYPES = [
9443
9471
  "application/vnd.oasis.opendocument.spreadsheet"
9444
9472
  ];
9445
9473
  /** Whether browsers play an audio or video upload's format as it is, so it is served as stored. */
9446
- const isBrowserSafeMediaFormat = (format) => BROWSER_SAFE_MEDIA_FORMATS.includes(require_ModerationContextLimits.normalizeUploadMimeType(format ?? ""));
9474
+ const isBrowserSafeMediaFormat = (format) => BROWSER_SAFE_MEDIA_FORMATS.includes(require_CalmLensCdn.normalizeUploadMimeType(format ?? ""));
9447
9475
  /**
9448
9476
  * The rendered file and preview the API reports for an asset with its content held (Asset.ts,
9449
9477
  * getAssetRendered and getAssetPreview). Once uploaded, an image renders as itself with a preview
@@ -9456,7 +9484,7 @@ const isBrowserSafeMediaFormat = (format) => BROWSER_SAFE_MEDIA_FORMATS.includes
9456
9484
  */
9457
9485
  const mockRendering = (asset, processed) => {
9458
9486
  const format = asset.content.format;
9459
- const mimeType = require_ModerationContextLimits.normalizeUploadMimeType(format ?? "");
9487
+ const mimeType = require_CalmLensCdn.normalizeUploadMimeType(format ?? "");
9460
9488
  const browserSafe = isBrowserSafeMediaFormat(format);
9461
9489
  const preview = (size) => ({
9462
9490
  ...size,
@@ -10804,7 +10832,7 @@ var MockCalmLensApi = class {
10804
10832
  if (expiresIn < 1) throw invalidField("validation/too-small", "expiresIn");
10805
10833
  if (expiresIn > 86400) throw invalidField("validation/too-big", "expiresIn");
10806
10834
  const { resource } = body;
10807
- if (resource !== void 0 && (typeof resource !== "string" || !Object.hasOwn(require_ModerationContextLimits.ASSET_RESOURCE_PATHS, resource))) throw invalidField("validation/invalid-value", "resource");
10835
+ if (resource !== void 0 && (typeof resource !== "string" || !Object.hasOwn(require_CalmLensCdn.ASSET_RESOURCE_PATHS, resource))) throw invalidField("validation/invalid-value", "resource");
10808
10836
  let asset;
10809
10837
  if (externalId !== void 0) {
10810
10838
  asset = (await this.databaseStorage.listAssets(this.projectId)).find((candidate) => candidate.externalId === externalId);
@@ -10817,7 +10845,7 @@ var MockCalmLensApi = class {
10817
10845
  original: resource === "original",
10818
10846
  expiresAt
10819
10847
  });
10820
- const path = resource === void 0 ? "" : `/${require_ModerationContextLimits.ASSET_RESOURCE_PATHS[resource]}`;
10848
+ const path = resource === void 0 ? "" : `/${require_CalmLensCdn.ASSET_RESOURCE_PATHS[resource]}`;
10821
10849
  return {
10822
10850
  url: `${this.cdnBaseUrl}/assets/${encodeURIComponent(this.projectId)}/${grant}${path}`,
10823
10851
  expiresAt
@@ -11010,8 +11038,8 @@ var MockCalmLensApi = class {
11010
11038
  const { part } = fields;
11011
11039
  const contentType = fetched ? fetched.type : fields.contentType;
11012
11040
  const bytes = fetched?.bytes ?? fields.bytes ?? /* @__PURE__ */ new Uint8Array(0);
11013
- if (contentType !== void 0 && !require_ModerationContextLimits.isAcceptedUploadMimeType(contentType)) throw fail(require_CalmLensError.API_ERROR_CODES.UNSUPPORTED_UPLOAD_TYPE, {
11014
- message: require_ModerationContextLimits.getRejectedUploadMimeTypeError(contentType),
11041
+ if (contentType !== void 0 && !require_CalmLensCdn.isAcceptedUploadMimeType(contentType)) throw fail(require_CalmLensError.API_ERROR_CODES.UNSUPPORTED_UPLOAD_TYPE, {
11042
+ message: require_CalmLensCdn.getRejectedUploadMimeTypeError(contentType),
11015
11043
  details: {
11016
11044
  mimeType: contentType,
11017
11045
  source: "calmlens"
@@ -11048,7 +11076,7 @@ var MockCalmLensApi = class {
11048
11076
  const keepContent = processingOptions.retainContent === true;
11049
11077
  this.processingOptions.set(id, processingOptions);
11050
11078
  const hasContent = fields.url === void 0 || fetched !== void 0;
11051
- const contextItems = require_ModerationContextLimits.selectModerationContextItems(fields.context?.items ?? []);
11079
+ const contextItems = await this.selectContext(fields.context?.items ?? []);
11052
11080
  const asset = {
11053
11081
  id,
11054
11082
  projectId: this.projectId,
@@ -11204,12 +11232,12 @@ var MockCalmLensApi = class {
11204
11232
  /** Like the API: image uploads in parts total at most 20 MiB, at any size below that. */
11205
11233
  multipartImageSizeError(type, sizeInBytes) {
11206
11234
  if (type !== "image") return void 0;
11207
- if (sizeInBytes > require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES) return require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE;
11235
+ if (sizeInBytes > require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES) return require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE;
11208
11236
  }
11209
11237
  /** The failure for a size error code, with the limit `upload/too-large` carries. */
11210
11238
  sizeFailure(code) {
11211
11239
  return fail(code, code === require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE ? { details: {
11212
- limitBytes: require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES,
11240
+ limitBytes: require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES,
11213
11241
  source: "plan"
11214
11242
  } } : {});
11215
11243
  }
@@ -11236,6 +11264,28 @@ var MockCalmLensApi = class {
11236
11264
  };
11237
11265
  }
11238
11266
  /** An asset's stored content, its parts in order, or `null` once it is removed. */
11267
+ /**
11268
+ * Like the API, a reply's context references the project's own assets, each read for its text:
11269
+ * a text asset's own text or the text found in it. Only the references CalmLens uses are kept.
11270
+ */
11271
+ async selectContext(items) {
11272
+ const posts = await Promise.all(items.map(async (item) => {
11273
+ const asset = await this.databaseStorage.getAsset(item.assetId);
11274
+ if (!asset || asset.projectId !== this.projectId) throw fail(require_CalmLensError.API_ERROR_CODES.CONTEXT_ASSET_NOT_FOUND, { details: { assetId: item.assetId } });
11275
+ return {
11276
+ item,
11277
+ text: await this.contextText(asset)
11278
+ };
11279
+ }));
11280
+ return selectModerationContextItems(posts, (post) => post.text).map((post) => post.item);
11281
+ }
11282
+ /** An earlier post's text, to the most CalmLens reads of one post; empty once its content is gone. */
11283
+ async contextText(asset) {
11284
+ const extracted = asset.content.extractedText;
11285
+ const bytes = asset.type === "plaintext-document" && await this.storedBytes(asset);
11286
+ const text = (bytes ? new TextDecoder().decode(bytes) : extracted?.type === "string" ? extracted.content : "").trim();
11287
+ return Array.from(text).slice(0, MODERATION_CONTEXT_MAX_ITEM_CHARACTERS).join("");
11288
+ }
11239
11289
  async storedBytes(asset) {
11240
11290
  if (asset.content.status === "removed") return null;
11241
11291
  const stored = await this.imageStorage.getContent(asset.id);
@@ -12010,7 +12060,7 @@ var MockCalmLensApi = class {
12010
12060
  const isHls = resource === "hls";
12011
12061
  let selector;
12012
12062
  try {
12013
- selector = require_ModerationContextLimits.parseTransformSelector(isHls ? "" : selectorPath.join("/"));
12063
+ selector = require_CalmLensCdn.parseTransformSelector(isHls ? "" : selectorPath.join("/"));
12014
12064
  } catch {
12015
12065
  return invalidTransform();
12016
12066
  }
@@ -12098,7 +12148,7 @@ var MockCalmLensApi = class {
12098
12148
  const stillImage = resource === "preview" || resource === "rendered" && rendered?.kind === "image";
12099
12149
  if (!stillImage && hasSelector) return invalidTransform();
12100
12150
  if (selector.options) {
12101
- const { unknownKeys, invalidKeys } = require_ModerationContextLimits.checkTransformOptions(selector.options);
12151
+ const { unknownKeys, invalidKeys } = require_CalmLensCdn.checkTransformOptions(selector.options);
12102
12152
  if (unknownKeys.length || invalidKeys.length) return this.jsonResponse(400, {
12103
12153
  code: "transform-options/invalid",
12104
12154
  message: `Invalid transform options: ${[...unknownKeys, ...invalidKeys].join(", ")}`
@@ -12282,14 +12332,14 @@ const mockClientOptions = (api, endpoints, session) => {
12282
12332
  const { useTimers } = api;
12283
12333
  const fetch = api.createFetch(endpoints, session);
12284
12334
  const hooks = {
12285
- sleep: useTimers ? require_ModerationContextLimits.sleep : async (ms, signal) => {
12286
- await require_ModerationContextLimits.sleep(0, signal);
12335
+ sleep: useTimers ? require_CalmLensCdn.sleep : async (ms, signal) => {
12336
+ await require_CalmLensCdn.sleep(0, signal);
12287
12337
  api.waitedMs += ms;
12288
12338
  },
12289
12339
  now: useTimers ? () => Date.now() : () => api.waitedMs,
12290
12340
  uploadTokenTime: () => ({
12291
12341
  now: api.now(),
12292
- nonce: require_ModerationContextLimits.randomUuid()
12342
+ nonce: require_CalmLensCdn.randomUuid()
12293
12343
  }),
12294
12344
  deferUploadChecks: true,
12295
12345
  defaultCdnBaseUrl: "mock://calmlens/v1"
@@ -12321,7 +12371,7 @@ var MockCalmLensServerClient = class extends require_CalmLensServerClient.CalmLe
12321
12371
  ...input,
12322
12372
  projectId: input.projectId ?? "project-1"
12323
12373
  };
12324
- require_ModerationContextLimits.validateServerClientOptions(options);
12374
+ require_CalmLensCdn.validateServerClientOptions(options);
12325
12375
  const { mockOptions = {}, ...clientOptions } = options;
12326
12376
  const api = new MockCalmLensApi({
12327
12377
  projectId: options.projectId,
@@ -12467,7 +12517,7 @@ var MockCalmLensServerClient = class extends require_CalmLensServerClient.CalmLe
12467
12517
  var MockCalmLensAppClient = class extends require_CalmLensAppClient.CalmLensAppClient {
12468
12518
  #uploadPresetId;
12469
12519
  constructor(options) {
12470
- require_ModerationContextLimits.validateAppClientOptions(options);
12520
+ require_CalmLensCdn.validateAppClientOptions(options);
12471
12521
  const { mockOptions = {}, ...clientOptions } = options;
12472
12522
  if (mockOptions.preset) checkMockUploadPreset(mockOptions.preset);
12473
12523
  const server = mockOptions.server ?? new MockCalmLensServerClient({
@@ -1,5 +1,5 @@
1
- const require_ModerationContextLimits = require("./ModerationContextLimits-BVBkcgSU.js");
2
- require("./Core-eDiPpil9.js");
1
+ const require_CalmLensCdn = require("./CalmLensCdn-2VbArrj-.js");
2
+ require("./Core-xy9aV1ED.js");
3
3
  // src/ui/viewers/PdfLoader.ts
4
4
  let loading;
5
5
  /**
@@ -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 require_ModerationContextLimits.appendAssetLocation(this.#src, {
115
+ return require_CalmLensCdn.appendAssetLocation(this.#src, {
116
116
  resource,
117
117
  transform,
118
118
  viewerClaims: resource === "placeholder" && viewerClaims ? { region: viewerClaims.region } : viewerClaims
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-fAgF0_lq.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-DL531ZPG.js";
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";
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/cjs/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-DL531ZPG.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-DpZOLeVs.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-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";
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/cjs/ui.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ui = require("./ui-COjb2Hx6.js");
3
- const require_Core = require("./Core-eDiPpil9.js");
4
- const require_UploadController = require("./UploadController-BElzwMic.js");
2
+ const require_ui = require("./ui-BJKh49aM.js");
3
+ const require_Core = require("./Core-xy9aV1ED.js");
4
+ const require_UploadController = require("./UploadController-CmTjpOfp.js");
5
5
  exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
6
6
  exports.ASSET_VIEWERS = require_ui.ASSET_VIEWERS;
7
7
  exports.AssetSession = require_Core.AssetSession;
package/cjs/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-fAgF0_lq.js";
2
- import "./index-ChrzzIRt.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-DL531ZPG.js";
4
- import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-DS6KT6o_.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-DpZOLeVs.js";
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";
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/cjs/vue.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ui = require("./ui-COjb2Hx6.js");
3
- const require_Core = require("./Core-eDiPpil9.js");
4
- const require_UploadController = require("./UploadController-BElzwMic.js");
2
+ const require_ui = require("./ui-BJKh49aM.js");
3
+ const require_Core = require("./Core-xy9aV1ED.js");
4
+ const require_UploadController = require("./UploadController-CmTjpOfp.js");
5
5
  const require_FileIcons = require("./FileIcons-Ob003MdS.js");
6
- const require_BrowserUpload = require("./BrowserUpload-BNeTp6eF.js");
6
+ const require_BrowserUpload = require("./BrowserUpload-IiRDbL85.js");
7
7
  let vue = require("vue");
8
8
  // src/viewers/Vue.ts
9
9
  const optional$1 = (type) => ({
@@ -1,5 +1,5 @@
1
- import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-DL531ZPG.js";
2
- import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-BoS0lr7U.js";
1
+ import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-Ccy4-_sN.js";
2
+ import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-DBhppuxM.js";
3
3
  type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
4
4
  type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
5
5
  type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
@@ -1,4 +1,4 @@
1
- import { n as createUploadController$1 } from "./UploadController-Civ7QPwT.js";
1
+ import { n as createUploadController$1 } from "./UploadController-DVsTVJVv.js";
2
2
  // src/ui/BrowserUpload.ts
3
3
  /** Creates an upload queue for the browser components, such as one a form starts on submit. */
4
4
  const createUploadController = (options) => createUploadController$1(options);
@@ -1,4 +1,4 @@
1
- import { $t as UploadPresetSubmitAssetOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, O as CalmLensAppClientOptions, Yt as UploadAssetPartOptions, en as UploadedAsset, kt as RequestOptions } from "./CalmLensTypes-fAgF0_lq.js";
1
+ import { $t as UploadPresetSubmitAssetOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, O as CalmLensAppClientOptions, Yt as UploadAssetPartOptions, en as UploadedAsset, kt as RequestOptions } from "./CalmLensTypes-87kiUg0H.js";
2
2
  declare const inspectSymbol: unique symbol;
3
3
  /**
4
4
  * The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
@@ -1,6 +1,6 @@
1
- import { C as invalidConfig, S as invalidArgument } from "./CalmLensError-BDWThPCr.js";
2
- import { T as validateAppClientOptions, g as encodePathSegment, l as buildAssetUrl, m as checkOptionKeys, p as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-DmjWgTBa.js";
3
- import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-Pm-g6a1l.js";
1
+ import { C as invalidConfig, S as invalidArgument } from "./CalmLensError-C15tWu8W.js";
2
+ import { S as validateAppClientOptions, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, u as DEFAULT_CDN_BASE_URL } from "./CalmLensCdn-CcxEY6wB.js";
3
+ import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-CfGVp95D.js";
4
4
  // src/client/CalmLensAppClient.ts
5
5
  const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
6
6
  /** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
@@ -1,4 +1,4 @@
1
- import { C as invalidConfig, S as invalidArgument, b as MAX_ERROR_BODY_LENGTH, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-BDWThPCr.js";
1
+ import { C as invalidConfig, S as invalidArgument, b as MAX_ERROR_BODY_LENGTH, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
2
  // src/client/CalmLensLogging.ts
3
3
  const LOG_LEVELS = [
4
4
  "off",
@@ -152,7 +152,7 @@ const listPages = (fetchPage, { cursor, feed = false } = {}) => {
152
152
  };
153
153
  // src/client/CalmLensVersion.ts
154
154
  /** This SDK's version, from its package.json. */
155
- const SDK_VERSION = "0.30.0";
155
+ const SDK_VERSION = "0.31.0";
156
156
  const runtimeName = () => {
157
157
  const runtime = globalThis;
158
158
  if (isReactNativeRuntime()) return "react-native";
@@ -1483,36 +1483,4 @@ const getAssetInfo = async (url, options = {}) => {
1483
1483
  });
1484
1484
  return data;
1485
1485
  };
1486
- // src/contract/ModerationContextLimits-k930WU8i.js
1487
- /** The most recent earlier posts CalmLens uses. */
1488
- const MODERATION_CONTEXT_USED_ITEMS = 5;
1489
- /**
1490
- * The most characters of earlier posts CalmLens uses. The newest post always fits, since no post
1491
- * may be longer.
1492
- */
1493
- const MODERATION_CONTEXT_USED_CHARACTERS = 2e3;
1494
- /** Unicode code points, as every SDK counts characters. */
1495
- const countModerationContextCharacters = (text) => {
1496
- let count = 0;
1497
- for (const _ of text) count++;
1498
- return count;
1499
- };
1500
- /**
1501
- * The earlier posts CalmLens uses: the most recent ones, newest first, while at most
1502
- * `MODERATION_CONTEXT_USED_ITEMS` and `MODERATION_CONTEXT_USED_CHARACTERS` allow, returned oldest
1503
- * first. The newest post is always kept, so an over-long one is left for validation to reject.
1504
- */
1505
- const selectModerationContextItems = (items) => {
1506
- const selected = [];
1507
- let characters = 0;
1508
- for (let index = items.length - 1; index >= 0; index--) {
1509
- if (selected.length === 5) break;
1510
- const item = items[index];
1511
- const length = countModerationContextCharacters(item.text);
1512
- if (selected.length && characters + length > 2e3) break;
1513
- selected.unshift(item);
1514
- characters += length;
1515
- }
1516
- return selected;
1517
- };
1518
- export { MAX_IMAGE_UPLOAD_BYTES as A, copyLastResponse as B, toTextAssetOptions as C, validateServerClientOptions as D, validateBatchAssetsOptions as E, sleep as F, readEnv as H, SDK_VERSION as I, isBrowserRuntime as L, getRejectedUploadMimeTypeError as M, normalizeUploadMimeType as N, DOMAIN as O, CalmLensTransport as P, isReactNativeRuntime as R, stringifyQuery as S, validateAppClientOptions as T, resolveLogLevel as U, listPages as V, isAcceptedUploadMimeType as _, CDN_RESOURCES as a, randomUuid as b, assetUrlOf as c, toUrlViewerClaims as d, validateSignAssetUrlOptions as f, encodePathSegment as g, checkTransformOptions as h, ASSET_RESOURCE_PATHS as i, MAX_NON_IMAGE_UPLOAD_BYTES as j, MAX_DIRECT_IMAGE_UPLOAD_BYTES as k, buildAssetUrl as l, checkOptionKeys as m, MODERATION_CONTEXT_USED_ITEMS as n, appendAssetLocation as o, DEFAULT_CDN_BASE_URL as p, selectModerationContextItems as r, appendSignedLocation as s, MODERATION_CONTEXT_USED_CHARACTERS as t, getAssetInfo as u, parseTransformSelector as v, transformSelector as w, serializeTransform as x, pollForDecision as y, AUTO_PAGING_TO_ARRAY_MAX as z };
1486
+ export { normalizeUploadMimeType as A, resolveLogLevel as B, validateBatchAssetsOptions as C, MAX_IMAGE_UPLOAD_BYTES as D, MAX_DIRECT_IMAGE_UPLOAD_BYTES as E, isReactNativeRuntime as F, AUTO_PAGING_TO_ARRAY_MAX as I, copyLastResponse as L, sleep as M, SDK_VERSION as N, MAX_NON_IMAGE_UPLOAD_BYTES as O, isBrowserRuntime as P, listPages as R, validateAppClientOptions as S, DOMAIN as T, randomUuid as _, assetUrlOf as a, toTextAssetOptions as b, toUrlViewerClaims as c, checkOptionKeys as d, checkTransformOptions as f, pollForDecision as g, parseTransformSelector as h, appendSignedLocation as i, CalmLensTransport as j, getRejectedUploadMimeTypeError as k, validateSignAssetUrlOptions as l, isAcceptedUploadMimeType as m, CDN_RESOURCES as n, buildAssetUrl as o, encodePathSegment as p, appendAssetLocation as r, getAssetInfo as s, ASSET_RESOURCE_PATHS as t, DEFAULT_CDN_BASE_URL as u, serializeTransform as v, validateServerClientOptions as w, transformSelector as x, stringifyQuery as y, readEnv as z };
@@ -1,5 +1,5 @@
1
- import { S as invalidArgument, l as CalmLensError, w as API_ERROR_CODES, x as SDK_ERROR_CODES } from "./CalmLensError-BDWThPCr.js";
2
- import { A as MAX_IMAGE_UPLOAD_BYTES, F as sleep, M as getRejectedUploadMimeTypeError, P as CalmLensTransport, S as stringifyQuery, U as resolveLogLevel, _ as isAcceptedUploadMimeType, b as randomUuid, j as MAX_NON_IMAGE_UPLOAD_BYTES, k as MAX_DIRECT_IMAGE_UPLOAD_BYTES, r as selectModerationContextItems } from "./ModerationContextLimits-DmjWgTBa.js";
1
+ import { S as invalidArgument, l as CalmLensError, w as API_ERROR_CODES, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
+ import { B as resolveLogLevel, D as MAX_IMAGE_UPLOAD_BYTES, E as MAX_DIRECT_IMAGE_UPLOAD_BYTES, M as sleep, O as MAX_NON_IMAGE_UPLOAD_BYTES, _ as randomUuid, j as CalmLensTransport, k as getRejectedUploadMimeTypeError, m as isAcceptedUploadMimeType, y as stringifyQuery } from "./CalmLensCdn-CcxEY6wB.js";
3
3
  // src/contract/AssetPayload.js
4
4
  const bufferInputToBytes = (value) => {
5
5
  if (value instanceof ArrayBuffer) return new Uint8Array(value);
@@ -681,13 +681,6 @@ const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeB
681
681
  });
682
682
  if (!validation.ok) throw invalidPayload(validation.error);
683
683
  }
684
- if (options.context !== void 0) {
685
- if (!options.context || !Array.isArray(options.context.items)) throw invalidArgument("context.items must be an array of earlier posts");
686
- return {
687
- ...options,
688
- context: { items: selectModerationContextItems(options.context.items) }
689
- };
690
- }
691
684
  return options;
692
685
  };
693
686
  const newIdempotencyKey = () => randomUuid();
@@ -115,6 +115,7 @@ const API_ERROR_CODES = {
115
115
  REMOTE_URL_UNAVAILABLE: "remote-url/unavailable",
116
116
  APPEAL_NOT_FOUND: "appeal/not-found",
117
117
  APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found",
118
+ CONTEXT_ASSET_NOT_FOUND: "context/asset-not-found",
118
119
  APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found",
119
120
  APPEAL_PERMISSION_DENIED: "appeal/permission-denied",
120
121
  APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed",
@@ -580,6 +581,10 @@ const API_ERROR_DEFINITIONS = {
580
581
  status: 404,
581
582
  message: "The judgment event is unavailable, belongs to another project or cannot supply an asset decision. Supply explicit context instead."
582
583
  },
584
+ "context/asset-not-found": {
585
+ status: 400,
586
+ message: "A context item names an asset this project doesn't have. Reference an earlier post uploaded to the same project."
587
+ },
583
588
  "appeal/asset-not-found": {
584
589
  status: 404,
585
590
  message: "The linked asset does not exist in this project."
@@ -1,6 +1,6 @@
1
- import { C as invalidConfig, S as invalidArgument, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-BDWThPCr.js";
2
- import { B as copyLastResponse, C as toTextAssetOptions, D as validateServerClientOptions, E as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, R as isReactNativeRuntime, S as stringifyQuery, V as listPages, f as validateSignAssetUrlOptions, g as encodePathSegment, l as buildAssetUrl, m as checkOptionKeys, p as DEFAULT_CDN_BASE_URL, s as appendSignedLocation, u as getAssetInfo, y as pollForDecision } from "./ModerationContextLimits-DmjWgTBa.js";
3
- import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-Pm-g6a1l.js";
1
+ import { C as invalidConfig, S as invalidArgument, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
+ import { C as validateBatchAssetsOptions, F as isReactNativeRuntime, L as copyLastResponse, P as isBrowserRuntime, R as listPages, b as toTextAssetOptions, d as checkOptionKeys, g as pollForDecision, i as appendSignedLocation, l as validateSignAssetUrlOptions, o as buildAssetUrl, p as encodePathSegment, s as getAssetInfo, u as DEFAULT_CDN_BASE_URL, w as validateServerClientOptions, y as stringifyQuery, z as readEnv } from "./CalmLensCdn-CcxEY6wB.js";
3
+ import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-CfGVp95D.js";
4
4
  import { n as sha256Hex, r as timingSafeEqual, t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
5
5
  // src/contract/JsonUtils.js
6
6
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
@@ -1,6 +1,6 @@
1
- import { c as HashList, l as HashListEntry } from "./Classification-DbXUPSvH-C0o2t4mg.js";
2
- import { $ as FolderPage, At as ResetPolicyOptions, B as CreateHashListOptions, Bn as AssetInfo, Cn as ProjectSettingsResource, D as BatchAssetsResponse, Dt as RequestAssetReviewOptions, E as BatchAssetsOptions, Et as RemoveAssetContentOptions, Ft as SetPolicyAutomaticUpdatesOptions, G as DeleteAssetOptions, Gt as UpdateLensOptions, Ht as UpdateAssetOptions, I as ClassifyTextOptions, It as SignAssetUrlOptions, J as EnsureLensesOptions, Jt as UpgradePolicyOptions, K as DeleteMetadataFieldOptions, Kt as UpdatePolicyOptions, Lt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, Nt as RetryAssetOptions, P as CdnServeOptions, Pn as Policy, Q as FolderIdOptions, Qt as UploadPresetPage, Rn as AssetSearchQuery, Rt as SignedAssetUrl, Sn as MetadataFieldsResource, T as AssignPolicyOptions, Tt as PolicyPage, U as CreatePolicyOptions, Ut as UpdateFolderOptions, V as CreateLensOptions, Vt as SubmitAssetOptions, W as DecideAssetOptions, Wt as UpdateHashListOptions, X as EnsureUploadPresetsOptions, Y as EnsureMetadataFieldsOptions, Yt as UploadAssetPartOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetIdOptions, _ as AssetPage, _t as ListLensesOptions, b as AssetTimelinePage, bt as MoveAssetOptions, ct as LensIdOptions, dt as ListAssetTimelineOptions, et as GetAssetInfoOptions, ft as ListAssetsOptions, gt as ListHashListsOptions, ht as ListHashListEntriesOptions, it as HashListPage, jt as RetrieveAssetByExternalIdOptions, k as CalmLensServerClientOptions, kt as RequestOptions, ln as GetEventsResponse, lt as LensPage, mt as ListFoldersOptions, nt as HashListEntryPage, o as AssetChildrenPage, pt as ListEventsOptions, q as EnsureLensOptions, qt as UpdateProjectSettingsOptions, r as Asset, rn as WaitForAssetDecisionOptions, rt as HashListIdOptions, sn as AssetReviewRequest, st as Lens, t as AddHashListEntryOptions, tn as VerifyWebhookSignatureOptions, tt as HashListEntryIdOptions, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vt as ListPoliciesOptions, wt as PolicyIdOptions, xn as Folder, xt as MoveFolderOptions, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zt as SignedUploadToken } from "./CalmLensTypes-fAgF0_lq.js";
3
- import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-DlGoY_db.js";
1
+ import { c as HashList, l as HashListEntry } from "./Classification-C3pkrGYS-B7EygpJn.js";
2
+ import { $ as FolderPage, At as ResetPolicyOptions, B as CreateHashListOptions, Bn as AssetInfo, Cn as ProjectSettingsResource, D as BatchAssetsResponse, Dt as RequestAssetReviewOptions, E as BatchAssetsOptions, Et as RemoveAssetContentOptions, Ft as SetPolicyAutomaticUpdatesOptions, G as DeleteAssetOptions, Gt as UpdateLensOptions, Ht as UpdateAssetOptions, I as ClassifyTextOptions, It as SignAssetUrlOptions, J as EnsureLensesOptions, Jt as UpgradePolicyOptions, K as DeleteMetadataFieldOptions, Kt as UpdatePolicyOptions, Lt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, Nt as RetryAssetOptions, P as CdnServeOptions, Pn as Policy, Q as FolderIdOptions, Qt as UploadPresetPage, Rn as AssetSearchQuery, Rt as SignedAssetUrl, Sn as MetadataFieldsResource, T as AssignPolicyOptions, Tt as PolicyPage, U as CreatePolicyOptions, Ut as UpdateFolderOptions, V as CreateLensOptions, Vt as SubmitAssetOptions, W as DecideAssetOptions, Wt as UpdateHashListOptions, X as EnsureUploadPresetsOptions, Y as EnsureMetadataFieldsOptions, Yt as UploadAssetPartOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetIdOptions, _ as AssetPage, _t as ListLensesOptions, b as AssetTimelinePage, bt as MoveAssetOptions, ct as LensIdOptions, dt as ListAssetTimelineOptions, et as GetAssetInfoOptions, ft as ListAssetsOptions, gt as ListHashListsOptions, ht as ListHashListEntriesOptions, it as HashListPage, jt as RetrieveAssetByExternalIdOptions, k as CalmLensServerClientOptions, kt as RequestOptions, ln as GetEventsResponse, lt as LensPage, mt as ListFoldersOptions, nt as HashListEntryPage, o as AssetChildrenPage, pt as ListEventsOptions, q as EnsureLensOptions, qt as UpdateProjectSettingsOptions, r as Asset, rn as WaitForAssetDecisionOptions, rt as HashListIdOptions, sn as AssetReviewRequest, st as Lens, t as AddHashListEntryOptions, tn as VerifyWebhookSignatureOptions, tt as HashListEntryIdOptions, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vt as ListPoliciesOptions, wt as PolicyIdOptions, xn as Folder, xt as MoveFolderOptions, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zt as SignedUploadToken } from "./CalmLensTypes-87kiUg0H.js";
3
+ import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-B4rA_Dvm.js";
4
4
  interface TransportRequest {
5
5
  /** The client method sending the request, such as `assets.retrieve`, for hooks and logs. */
6
6
  operation?: string;
@@ -1,4 +1,4 @@
1
- import { S as invalidArgument } from "./CalmLensError-BDWThPCr.js";
1
+ import { S as invalidArgument } from "./CalmLensError-C15tWu8W.js";
2
2
  import { r as timingSafeEqual, t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
3
3
  import * as z from "zod";
4
4
  import { globalRegistry } from "zod";
@@ -1,4 +1,4 @@
1
- import { c as HashList, d as ModerationContext, l as HashListEntry } from "./Classification-DbXUPSvH-C0o2t4mg.js";
1
+ import { c as HashList, d as ModerationContext, l as HashListEntry } from "./Classification-C3pkrGYS-B7EygpJn.js";
2
2
  import * as zod from "zod";
3
3
  /**
4
4
  * Where the asset is in the pipeline: waiting for its content or its turn (`queued`), being
@@ -10095,8 +10095,7 @@ declare const ASSET_SCHEMA: zod.ZodObject<{
10095
10095
  authorId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
10096
10096
  context: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
10097
10097
  items: zod.ZodArray<zod.ZodObject<{
10098
- text: zod.ZodString;
10099
- authorId: zod.ZodOptional<zod.ZodString>;
10098
+ assetId: zod.ZodString;
10100
10099
  }, zod.core.$strict>>;
10101
10100
  }, zod.core.$strip>>>;
10102
10101
  type: zod.ZodEnum<{
@@ -15368,8 +15367,7 @@ declare const ASSET_SEARCH_RESULT_SCHEMA: zod.ZodObject<{
15368
15367
  authorId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
15369
15368
  context: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
15370
15369
  items: zod.ZodArray<zod.ZodObject<{
15371
- text: zod.ZodString;
15372
- authorId: zod.ZodOptional<zod.ZodString>;
15370
+ assetId: zod.ZodString;
15373
15371
  }, zod.core.$strict>>;
15374
15372
  }, zod.core.$strip>>>;
15375
15373
  type: zod.ZodEnum<{
@@ -1,27 +1,8 @@
1
1
  import * as zod from "zod";
2
- /** The most recent earlier posts CalmLens uses. */
3
- declare const MODERATION_CONTEXT_USED_ITEMS = 5;
4
- /**
5
- * The most characters of earlier posts CalmLens uses. The newest post always fits, since no post
6
- * may be longer.
7
- */
8
- declare const MODERATION_CONTEXT_USED_CHARACTERS = 2000;
9
- /** An earlier post in the conversation. */
10
- interface ModerationContextItem {
11
- text: string;
12
- authorId?: string;
13
- }
14
- /**
15
- * The earlier posts CalmLens uses: the most recent ones, newest first, while at most
16
- * `MODERATION_CONTEXT_USED_ITEMS` and `MODERATION_CONTEXT_USED_CHARACTERS` allow, returned oldest
17
- * first. The newest post is always kept, so an over-long one is left for validation to reject.
18
- */
19
- declare const selectModerationContextItems: <Item extends ModerationContextItem>(items: readonly Item[]) => Item[];
20
2
  /** The context a request may send: up to 20 earlier posts, oldest first. */
21
3
  declare const MODERATION_CONTEXT_SCHEMA: zod.ZodObject<{
22
4
  items: zod.ZodArray<zod.ZodObject<{
23
- text: zod.ZodString;
24
- authorId: zod.ZodOptional<zod.ZodString>;
5
+ assetId: zod.ZodString;
25
6
  }, zod.core.$strict>>;
26
7
  }, zod.core.$strict>;
27
8
  type ModerationContext = zod.infer<typeof MODERATION_CONTEXT_SCHEMA>;
@@ -6013,4 +5994,4 @@ declare const CATEGORIES_SCHEMA: zod.ZodObject<{
6013
5994
  }, zod.core.$strict>], "status">;
6014
5995
  }, zod.core.$strict>;
6015
5996
  type ClassificationCategories = zod.infer<typeof CATEGORIES_SCHEMA>;
6016
- export { ClassificationQualifierResults as a, HashList as c, ModerationContext as d, MODERATION_CONTEXT_USED_CHARACTERS as f, selectModerationContextItems as h, ClassificationNotEvaluatedReason as i, HashListEntry as l, ModerationContextItem as m, ClassificationCategory as n, Likelihood as o, MODERATION_CONTEXT_USED_ITEMS as p, ClassificationCategoryReport as r, ModerationQualifier as s, ClassificationCategories as t, PolicyAction as u };
5997
+ export { ClassificationQualifierResults as a, HashList as c, ModerationContext as d, ClassificationNotEvaluatedReason as i, HashListEntry as l, ClassificationCategory as n, Likelihood as o, ClassificationCategoryReport as r, ModerationQualifier as s, ClassificationCategories as t, PolicyAction as u };
@@ -1,5 +1,5 @@
1
- import { F as CdnTransform, O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-fAgF0_lq.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-B4vzxEzg.js";
1
+ import { F as CdnTransform, O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-87kiUg0H.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-CdlcDd5l.js";
3
3
  import { o as UploadFileIconFamily } from "./FileIcons-4qSX7DW2.js";
4
4
  /**
5
5
  * The text the asset viewers show, keyed by name. `{name}` placeholders are filled in when shown.
@@ -1,6 +1,6 @@
1
- import { l as CalmLensError } from "./CalmLensError-BDWThPCr.js";
2
- import { c as assetUrlOf, d as toUrlViewerClaims, o as appendAssetLocation, u as getAssetInfo, w as transformSelector, x as serializeTransform } from "./ModerationContextLimits-DmjWgTBa.js";
3
- import { o as placeholderHashToDataURL } from "./UploadController-Civ7QPwT.js";
1
+ import { l as CalmLensError } from "./CalmLensError-C15tWu8W.js";
2
+ import { a as assetUrlOf, c as toUrlViewerClaims, r as appendAssetLocation, s as getAssetInfo, v as serializeTransform, x as transformSelector } from "./CalmLensCdn-CcxEY6wB.js";
3
+ import { o as placeholderHashToDataURL } from "./UploadController-DVsTVJVv.js";
4
4
  import { a as getFileIcon, c as renderFileIconSvg } from "./FileIcons-M6dzjFxd.js";
5
5
  // src/ui/viewers/ViewerAsset.ts
6
6
  /** Spreadsheet MIME types, as `content.format` reports them (compared lower-cased). */
@@ -1,4 +1,4 @@
1
- import { F as UploadFile, L as UploadSnapshot, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions } from "./Core-DL531ZPG.js";
1
+ import { F as UploadFile, L as UploadSnapshot, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions } from "./Core-Ccy4-_sN.js";
2
2
  import { ReactNode } from "react";
3
3
  type CalmLensProviderProps<F extends UploadFile = File> = CalmLensProvidedOptions<F> & {
4
4
  children?: ReactNode;
@@ -1,4 +1,4 @@
1
- import { i as withProvidedOptions, n as createUploadController } from "./UploadController-Civ7QPwT.js";
1
+ import { i as withProvidedOptions, n as createUploadController } from "./UploadController-DVsTVJVv.js";
2
2
  import { createContext, createElement, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
3
  // src/ui/ReactUpload.ts
4
4
  const CalmLensContext = createContext(void 0);
@@ -1,4 +1,4 @@
1
- import { n as ClassificationCategory } from "./Classification-DbXUPSvH-C0o2t4mg.js";
1
+ import { n as ClassificationCategory } from "./Classification-C3pkrGYS-B7EygpJn.js";
2
2
  import * as z from "zod";
3
3
  interface RgbaImage {
4
4
  width: number;
@@ -1,5 +1,5 @@
1
- import { l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-BDWThPCr.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-DcPVLn2y.js";
1
+ import { l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-gAd0C_Q_.js";
3
3
  // src/contract/PlaceholderHashDecode.js
4
4
  /**
5
5
  * Decodes a ThumbHash to an RGBA image. RGB is not be premultiplied by A.