calmlens 0.29.2 → 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.
- package/bin/calmlens.js +17 -45
- package/{esm/BrowserUpload-CeGsM9h1.d.ts → cjs/BrowserUpload-BAH54V1q.d.ts} +2 -2
- package/cjs/{BrowserUpload-CCXt4DAY.js → BrowserUpload-IiRDbL85.js} +1 -1
- package/cjs/{CalmLensAppClient-ea-qXkmD.js → CalmLensAppClient-BBcq6pJg.js} +10 -10
- package/cjs/{CalmLensAppClient-D-BD_Ny1.d.ts → CalmLensAppClient-CdlcDd5l.d.ts} +1 -1
- package/cjs/{ModerationContextLimits-1XP4ZTQk.js → CalmLensCdn-2VbArrj-.js} +2 -52
- package/cjs/{CalmLensConnection-BrySN2M3.js → CalmLensConnection-CpnDGa8W.js} +15 -22
- package/cjs/{CalmLensError-DPHJaVjX.js → CalmLensError-ifj5rLmk.js} +5 -0
- package/{esm/CalmLensServerClient-BYN_N0lt.d.ts → cjs/CalmLensServerClient-CtS66dCU.d.ts} +12 -8
- package/cjs/{CalmLensServerClient-FD7H7KvL.js → CalmLensServerClient-DbemlDXj.js} +38 -37
- package/cjs/{CalmLensTestInputArguments-BXDBAOg_.js → CalmLensTestInputArguments-PYuRmE0j.js} +1 -1
- package/cjs/{CalmLensTypes-C2blKgTu.d.ts → CalmLensTypes-87kiUg0H.d.ts} +208 -10
- package/cjs/{Classification-CMM2tZpJ-IdIh63n0.d.ts → Classification-C3pkrGYS-B7EygpJn.d.ts} +16 -50
- package/cjs/{Core-CNmoxDCW.d.ts → Core-Ccy4-_sN.d.ts} +2 -2
- package/cjs/{Core-DMFa3EUp.js → Core-xy9aV1ED.js} +8 -8
- package/cjs/{ReactUpload-gaeiPSeH.js → ReactUpload-BX3XOVfb.js} +1 -1
- package/{esm/ReactUpload-kqEe6gcN.d.ts → cjs/ReactUpload-DBhppuxM.d.ts} +1 -1
- package/cjs/{TestTriggers-CFnel6a9.d.ts → TestTriggers-Daxebd0V.d.ts} +1 -1
- package/cjs/{UploadController-CyPTBuZg.js → UploadController-CmTjpOfp.js} +2 -2
- package/{esm/WebhookPayload-DZWlnvcY.d.ts → cjs/WebhookPayload-B4rA_Dvm.d.ts} +13 -7
- package/cjs/app.d.ts +6 -6
- package/cjs/app.js +8 -11
- package/cjs/elements.d.ts +4 -4
- package/cjs/elements.js +4 -4
- package/cjs/{index-Dl2qwS8L.d.ts → index-CWUnLKoF.d.ts} +8 -4
- package/cjs/index.d.ts +5 -5
- package/cjs/index.js +7 -10
- package/cjs/react-native.d.ts +2 -2
- package/cjs/react-native.js +7 -7
- package/cjs/react.d.ts +4 -4
- package/cjs/react.js +5 -5
- package/cjs/server.d.ts +12 -12
- package/cjs/server.js +9 -12
- package/cjs/test-inputs.d.ts +1 -1
- package/cjs/test-inputs.js +1 -1
- package/cjs/testing.d.ts +12 -8
- package/cjs/testing.js +89 -37
- package/cjs/{ui-DNP1uWQy.js → ui-BJKh49aM.js} +3 -3
- package/cjs/{ui-BtmJC-f9.d.ts → ui-sjnJhloQ.d.ts} +2 -2
- package/cjs/ui.d.ts +2 -2
- package/cjs/ui.js +3 -3
- package/cjs/vue.d.ts +5 -5
- package/cjs/vue.js +4 -4
- package/{cjs/BrowserUpload-CeGsM9h1.d.ts → esm/BrowserUpload-BAH54V1q.d.ts} +2 -2
- package/esm/{BrowserUpload-Bu6eWqQS.js → BrowserUpload-C5aXj6QC.js} +1 -1
- package/esm/{CalmLensAppClient-D-BD_Ny1.d.ts → CalmLensAppClient-CdlcDd5l.d.ts} +1 -1
- package/esm/{CalmLensAppClient-xp-fH6Lz.js → CalmLensAppClient-gAd0C_Q_.js} +3 -3
- package/esm/{ModerationContextLimits-CtAyz60h.js → CalmLensCdn-CcxEY6wB.js} +3 -35
- package/esm/{CalmLensConnection-DwG5yBk2.js → CalmLensConnection-CfGVp95D.js} +2 -9
- package/esm/{CalmLensError-BDWThPCr.js → CalmLensError-C15tWu8W.js} +5 -0
- package/esm/{CalmLensServerClient-CKlNBBo3.js → CalmLensServerClient-CPWeRVWO.js} +18 -17
- package/{cjs/CalmLensServerClient-BYN_N0lt.d.ts → esm/CalmLensServerClient-CtS66dCU.d.ts} +12 -8
- package/esm/{CalmLensTestInputArguments-Xh4GIadS.js → CalmLensTestInputArguments-CqPADTkl.js} +1 -1
- package/esm/{CalmLensTypes-C2blKgTu.d.ts → CalmLensTypes-87kiUg0H.d.ts} +208 -10
- package/esm/{Classification-CMM2tZpJ-IdIh63n0.d.ts → Classification-C3pkrGYS-B7EygpJn.d.ts} +16 -50
- package/esm/{Core-CNmoxDCW.d.ts → Core-Ccy4-_sN.d.ts} +2 -2
- package/esm/{Core-DnCeTmvS.js → Core-DTcxpv3O.js} +3 -3
- package/{cjs/ReactUpload-kqEe6gcN.d.ts → esm/ReactUpload-DBhppuxM.d.ts} +1 -1
- package/esm/{ReactUpload-D30YlRui.js → ReactUpload-Dg7MtjbJ.js} +1 -1
- package/esm/{TestTriggers-CFnel6a9.d.ts → TestTriggers-Daxebd0V.d.ts} +1 -1
- package/esm/{UploadController-DENryQ8H.js → UploadController-DVsTVJVv.js} +2 -2
- package/{cjs/WebhookPayload-DZWlnvcY.d.ts → esm/WebhookPayload-B4rA_Dvm.d.ts} +13 -7
- package/esm/app.d.ts +6 -6
- package/esm/app.js +4 -4
- package/esm/elements.d.ts +4 -4
- package/esm/elements.js +4 -4
- package/esm/{index-Dl2qwS8L.d.ts → index-CWUnLKoF.d.ts} +8 -4
- package/esm/index.d.ts +5 -5
- package/esm/index.js +3 -3
- package/esm/react-native.d.ts +2 -2
- package/esm/react-native.js +4 -4
- package/esm/react.d.ts +4 -4
- package/esm/react.js +5 -5
- package/esm/server.d.ts +12 -12
- package/esm/server.js +4 -4
- package/esm/test-inputs.d.ts +1 -1
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +12 -8
- package/esm/testing.js +74 -22
- package/esm/{ui-DUEBbRJ0.js → ui-DUao8UY0.js} +2 -2
- package/esm/{ui-BtmJC-f9.d.ts → ui-sjnJhloQ.d.ts} +2 -2
- package/esm/ui.d.ts +2 -2
- package/esm/ui.js +3 -3
- package/esm/vue.d.ts +5 -5
- package/esm/vue.js +4 -4
- package/package.json +1 -1
package/cjs/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
3
|
-
const
|
|
2
|
+
const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
|
|
3
|
+
const require_CalmLensCdn = require("./CalmLensCdn-2VbArrj-.js");
|
|
4
4
|
require("./index.js");
|
|
5
|
-
const require_CalmLensServerClient = require("./CalmLensServerClient-
|
|
6
|
-
exports.AUTO_PAGING_TO_ARRAY_MAX =
|
|
5
|
+
const require_CalmLensServerClient = require("./CalmLensServerClient-DbemlDXj.js");
|
|
6
|
+
exports.AUTO_PAGING_TO_ARRAY_MAX = require_CalmLensCdn.AUTO_PAGING_TO_ARRAY_MAX;
|
|
7
7
|
exports.CALMLENS_ERROR_CODES = require_CalmLensError.CALMLENS_ERROR_CODES;
|
|
8
|
-
exports.CDN_RESOURCES =
|
|
8
|
+
exports.CDN_RESOURCES = require_CalmLensCdn.CDN_RESOURCES;
|
|
9
9
|
exports.CalmLensApiError = require_CalmLensError.CalmLensApiError;
|
|
10
10
|
exports.CalmLensAuthenticationError = require_CalmLensError.CalmLensAuthenticationError;
|
|
11
11
|
exports.CalmLensBadRequestError = require_CalmLensError.CalmLensBadRequestError;
|
|
@@ -25,19 +25,16 @@ exports.CalmLensServerError = require_CalmLensError.CalmLensServerError;
|
|
|
25
25
|
exports.CalmLensTimeoutError = require_CalmLensError.CalmLensTimeoutError;
|
|
26
26
|
exports.CalmLensUnprocessableEntityError = require_CalmLensError.CalmLensUnprocessableEntityError;
|
|
27
27
|
exports.CalmLensWebhookVerificationError = require_CalmLensError.CalmLensWebhookVerificationError;
|
|
28
|
-
exports.DEFAULT_CDN_BASE_URL =
|
|
29
|
-
exports.
|
|
30
|
-
exports.MODERATION_CONTEXT_USED_ITEMS = require_ModerationContextLimits.MODERATION_CONTEXT_USED_ITEMS;
|
|
31
|
-
exports.SDK_VERSION = require_ModerationContextLimits.SDK_VERSION;
|
|
28
|
+
exports.DEFAULT_CDN_BASE_URL = require_CalmLensCdn.DEFAULT_CDN_BASE_URL;
|
|
29
|
+
exports.SDK_VERSION = require_CalmLensCdn.SDK_VERSION;
|
|
32
30
|
exports.WEBHOOK_DELIVERY_HEADER = require_CalmLensServerClient.WEBHOOK_DELIVERY_HEADER;
|
|
33
31
|
exports.WEBHOOK_SIGNATURE_HEADER = require_CalmLensServerClient.WEBHOOK_SIGNATURE_HEADER;
|
|
34
32
|
exports.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = require_CalmLensServerClient.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS;
|
|
35
33
|
exports.WEBHOOK_TIMESTAMP_HEADER = require_CalmLensServerClient.WEBHOOK_TIMESTAMP_HEADER;
|
|
36
|
-
exports.getAssetInfo =
|
|
34
|
+
exports.getAssetInfo = require_CalmLensCdn.getAssetInfo;
|
|
37
35
|
exports.getEventFact = require_CalmLensServerClient.getEventFact;
|
|
38
36
|
exports.getEventFacts = require_CalmLensServerClient.getEventFacts;
|
|
39
|
-
exports.
|
|
37
|
+
exports.isNewerEvent = require_CalmLensServerClient.isNewerEvent;
|
|
40
38
|
exports.isTestWebhookEvent = require_CalmLensServerClient.isTestWebhookEvent;
|
|
41
39
|
exports.parseWebhookEvent = require_CalmLensServerClient.parseWebhookEvent;
|
|
42
|
-
exports.selectModerationContextItems = require_ModerationContextLimits.selectModerationContextItems;
|
|
43
40
|
exports.verifyWebhookSignature = require_CalmLensServerClient.verifyWebhookSignature;
|
package/cjs/test-inputs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as TEST_FACE_AGE_PRESETS, c as TestDetections, d as detectTestTrigger, f as getImageTestCategories, i as TEST_FACE_AGE_MAX, l as TestInput, m as testInputForSignal, n as TEST_DETECTIONS_MAX, o as TEST_INPUT_KEY_PATTERN, p as paintTestImage$1, r as TEST_DETECTION_BOX_MAX, s as TEST_INPUT_PRESETS, t as ClassificationTestSignal, u as detectTestImage } from "./TestTriggers-
|
|
1
|
+
import { a as TEST_FACE_AGE_PRESETS, c as TestDetections, d as detectTestTrigger, f as getImageTestCategories, i as TEST_FACE_AGE_MAX, l as TestInput, m as testInputForSignal, n as TEST_DETECTIONS_MAX, o as TEST_INPUT_KEY_PATTERN, p as paintTestImage$1, r as TEST_DETECTION_BOX_MAX, s as TEST_INPUT_PRESETS, t as ClassificationTestSignal, u as detectTestImage } from "./TestTriggers-Daxebd0V.js";
|
|
2
2
|
/** A text code for `scenario`, signed with the project's test input key. */
|
|
3
3
|
export declare const generateTestTextCode: (scenario: TestInput | ClassificationTestSignal, key: string) => Promise<string>;
|
|
4
4
|
/** An RGBA test image for `scenario`, signed with the project's test input key. */
|
package/cjs/test-inputs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-
|
|
2
|
+
const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-PYuRmE0j.js");
|
|
3
3
|
// src/test-inputs.ts
|
|
4
4
|
/**
|
|
5
5
|
* Portable test inputs: presets and custom instances share one authenticated format. CalmLens
|
package/cjs/testing.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
3
|
-
import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-
|
|
4
|
-
import { t as CalmLensServerClient } from "./CalmLensServerClient-
|
|
5
|
-
import { t as ClassificationTestSignal } from "./TestTriggers-
|
|
1
|
+
import { Lt as SignUploadTokenOptions, O as CalmLensAppClientOptions, Xt as UploadPresetDefinition, bn as PermissionGrant, fn as TypedEvent, k as CalmLensServerClientOptions, m as AssetModeration, r as Asset, xn as Folder, zn as AssetBinaryPayloadInput, zt as SignedUploadToken } from "./CalmLensTypes-87kiUg0H.js";
|
|
2
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-CdlcDd5l.js";
|
|
3
|
+
import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-B4rA_Dvm.js";
|
|
4
|
+
import { t as CalmLensServerClient } from "./CalmLensServerClient-CtS66dCU.js";
|
|
5
|
+
import { t as ClassificationTestSignal } from "./TestTriggers-Daxebd0V.js";
|
|
6
6
|
import "zod";
|
|
7
7
|
/**
|
|
8
8
|
* Signs a single-use upload token with `apiKey`, locally. `CalmLensServerClient` and
|
|
@@ -300,10 +300,14 @@ interface MockServedUrl {
|
|
|
300
300
|
/** The `Content-Type` the URL answers with, such as `image/png`. */
|
|
301
301
|
type: string;
|
|
302
302
|
}
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
/**
|
|
304
|
+
* An event to add to the mock feed; omitted fields get defaults. With `assetId` it is about that
|
|
305
|
+
* asset, and its `resource` takes the asset's next number like the API's; without, it is about no
|
|
306
|
+
* resource.
|
|
307
|
+
*/
|
|
308
|
+
type MockEventInput = Partial<Omit<TypedEvent, "type" | "resource">> & {
|
|
306
309
|
type: TypedEvent["type"];
|
|
310
|
+
assetId?: string | null;
|
|
307
311
|
};
|
|
308
312
|
/**
|
|
309
313
|
* The upload preset settings a `MockCalmLensAppClient` applies, as the API would, with the same
|
package/cjs/testing.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-
|
|
3
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
4
|
-
const
|
|
5
|
-
const require_CalmLensServerClient = require("./CalmLensServerClient-
|
|
6
|
-
const require_CalmLensConnection = require("./CalmLensConnection-
|
|
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-
|
|
9
|
-
const require_UploadController = require("./UploadController-
|
|
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(
|
|
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 =
|
|
9487
|
+
const mimeType = require_CalmLensCdn.normalizeUploadMimeType(format ?? "");
|
|
9460
9488
|
const browserSafe = isBrowserSafeMediaFormat(format);
|
|
9461
9489
|
const preview = (size) => ({
|
|
9462
9490
|
...size,
|
|
@@ -9845,7 +9873,7 @@ var MockCalmLensApi = class {
|
|
|
9845
9873
|
this.waitedMs = 0;
|
|
9846
9874
|
this.publishAssets = (_key, value) => isStoredAsset(value) ? {
|
|
9847
9875
|
...value,
|
|
9848
|
-
|
|
9876
|
+
sequence: this.eventSequenceOf(value.id)
|
|
9849
9877
|
} : value;
|
|
9850
9878
|
this.policies = /* @__PURE__ */ new Map();
|
|
9851
9879
|
this.hashLists = /* @__PURE__ */ new Map();
|
|
@@ -9915,32 +9943,35 @@ var MockCalmLensApi = class {
|
|
|
9915
9943
|
return this.pushEvent(input);
|
|
9916
9944
|
}
|
|
9917
9945
|
/** Adds an event to the feed, filling the fields the API always sets. */
|
|
9918
|
-
pushEvent(input) {
|
|
9946
|
+
pushEvent({ assetId, ...input }) {
|
|
9919
9947
|
const now = this.now();
|
|
9948
|
+
const sequence = assetId ? (this.assetEventSequences.get(assetId) ?? 0) + 1 : null;
|
|
9949
|
+
if (assetId && sequence !== null) this.assetEventSequences.set(assetId, sequence);
|
|
9920
9950
|
const event = {
|
|
9921
9951
|
id: this.createId("evt"),
|
|
9922
9952
|
projectId: this.projectId,
|
|
9923
9953
|
severity: "low",
|
|
9924
9954
|
title: input.type,
|
|
9925
9955
|
description: null,
|
|
9926
|
-
assetId: null,
|
|
9927
9956
|
actor: MOCK_API_KEY_ACTOR,
|
|
9928
9957
|
facts: [],
|
|
9929
9958
|
createdAt: now,
|
|
9930
|
-
...input
|
|
9959
|
+
...input,
|
|
9960
|
+
resource: assetId && sequence !== null ? {
|
|
9961
|
+
kind: "asset",
|
|
9962
|
+
id: assetId,
|
|
9963
|
+
sequence
|
|
9964
|
+
} : null
|
|
9931
9965
|
};
|
|
9932
|
-
const sequence = event.assetId ? (this.assetEventSequences.get(event.assetId) ?? 0) + 1 : null;
|
|
9933
|
-
if (event.assetId && sequence !== null) this.assetEventSequences.set(event.assetId, sequence);
|
|
9934
|
-
event.assetSequence = sequence;
|
|
9935
9966
|
this.eventFeed.push(event);
|
|
9936
9967
|
return event;
|
|
9937
9968
|
}
|
|
9938
|
-
/** The `
|
|
9969
|
+
/** The `resource.sequence` of the latest event about an asset, or 0 before its first. */
|
|
9939
9970
|
eventSequenceOf(assetId) {
|
|
9940
9971
|
return this.assetEventSequences.get(assetId) ?? 0;
|
|
9941
9972
|
}
|
|
9942
9973
|
/**
|
|
9943
|
-
* A copy of a stored asset as the API returns it, with its `
|
|
9974
|
+
* A copy of a stored asset as the API returns it, with its `sequence` as it is now. The
|
|
9944
9975
|
* mock keeps each asset's sequence itself rather than in `databaseStorage`, whose
|
|
9945
9976
|
* implementations needn't know about it, so every asset leaving the mock passes through here
|
|
9946
9977
|
* or `publishAssets`.
|
|
@@ -9948,7 +9979,7 @@ var MockCalmLensApi = class {
|
|
|
9948
9979
|
toPublished(asset) {
|
|
9949
9980
|
return {
|
|
9950
9981
|
...structuredClone(asset),
|
|
9951
|
-
|
|
9982
|
+
sequence: this.eventSequenceOf(asset.id)
|
|
9952
9983
|
};
|
|
9953
9984
|
}
|
|
9954
9985
|
/** Applies a reviewer's decision to a stored asset (see `MockCalmLensServerClient.decide`). */
|
|
@@ -10801,7 +10832,7 @@ var MockCalmLensApi = class {
|
|
|
10801
10832
|
if (expiresIn < 1) throw invalidField("validation/too-small", "expiresIn");
|
|
10802
10833
|
if (expiresIn > 86400) throw invalidField("validation/too-big", "expiresIn");
|
|
10803
10834
|
const { resource } = body;
|
|
10804
|
-
if (resource !== void 0 && (typeof resource !== "string" || !Object.hasOwn(
|
|
10835
|
+
if (resource !== void 0 && (typeof resource !== "string" || !Object.hasOwn(require_CalmLensCdn.ASSET_RESOURCE_PATHS, resource))) throw invalidField("validation/invalid-value", "resource");
|
|
10805
10836
|
let asset;
|
|
10806
10837
|
if (externalId !== void 0) {
|
|
10807
10838
|
asset = (await this.databaseStorage.listAssets(this.projectId)).find((candidate) => candidate.externalId === externalId);
|
|
@@ -10814,7 +10845,7 @@ var MockCalmLensApi = class {
|
|
|
10814
10845
|
original: resource === "original",
|
|
10815
10846
|
expiresAt
|
|
10816
10847
|
});
|
|
10817
|
-
const path = resource === void 0 ? "" : `/${
|
|
10848
|
+
const path = resource === void 0 ? "" : `/${require_CalmLensCdn.ASSET_RESOURCE_PATHS[resource]}`;
|
|
10818
10849
|
return {
|
|
10819
10850
|
url: `${this.cdnBaseUrl}/assets/${encodeURIComponent(this.projectId)}/${grant}${path}`,
|
|
10820
10851
|
expiresAt
|
|
@@ -11007,8 +11038,8 @@ var MockCalmLensApi = class {
|
|
|
11007
11038
|
const { part } = fields;
|
|
11008
11039
|
const contentType = fetched ? fetched.type : fields.contentType;
|
|
11009
11040
|
const bytes = fetched?.bytes ?? fields.bytes ?? /* @__PURE__ */ new Uint8Array(0);
|
|
11010
|
-
if (contentType !== void 0 && !
|
|
11011
|
-
message:
|
|
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),
|
|
11012
11043
|
details: {
|
|
11013
11044
|
mimeType: contentType,
|
|
11014
11045
|
source: "calmlens"
|
|
@@ -11045,7 +11076,7 @@ var MockCalmLensApi = class {
|
|
|
11045
11076
|
const keepContent = processingOptions.retainContent === true;
|
|
11046
11077
|
this.processingOptions.set(id, processingOptions);
|
|
11047
11078
|
const hasContent = fields.url === void 0 || fetched !== void 0;
|
|
11048
|
-
const contextItems =
|
|
11079
|
+
const contextItems = await this.selectContext(fields.context?.items ?? []);
|
|
11049
11080
|
const asset = {
|
|
11050
11081
|
id,
|
|
11051
11082
|
projectId: this.projectId,
|
|
@@ -11065,7 +11096,7 @@ var MockCalmLensApi = class {
|
|
|
11065
11096
|
context: contextItems.length ? { items: contextItems } : null,
|
|
11066
11097
|
tags: fields.tags ?? [],
|
|
11067
11098
|
visibility: fields.visibility ?? "private",
|
|
11068
|
-
|
|
11099
|
+
sequence: 0,
|
|
11069
11100
|
content: {
|
|
11070
11101
|
status: keepContent ? "stored" : "temporary",
|
|
11071
11102
|
removalReason: null,
|
|
@@ -11201,12 +11232,12 @@ var MockCalmLensApi = class {
|
|
|
11201
11232
|
/** Like the API: image uploads in parts total at most 20 MiB, at any size below that. */
|
|
11202
11233
|
multipartImageSizeError(type, sizeInBytes) {
|
|
11203
11234
|
if (type !== "image") return void 0;
|
|
11204
|
-
if (sizeInBytes >
|
|
11235
|
+
if (sizeInBytes > require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES) return require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE;
|
|
11205
11236
|
}
|
|
11206
11237
|
/** The failure for a size error code, with the limit `upload/too-large` carries. */
|
|
11207
11238
|
sizeFailure(code) {
|
|
11208
11239
|
return fail(code, code === require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE ? { details: {
|
|
11209
|
-
limitBytes:
|
|
11240
|
+
limitBytes: require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES,
|
|
11210
11241
|
source: "plan"
|
|
11211
11242
|
} } : {});
|
|
11212
11243
|
}
|
|
@@ -11233,6 +11264,28 @@ var MockCalmLensApi = class {
|
|
|
11233
11264
|
};
|
|
11234
11265
|
}
|
|
11235
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
|
+
}
|
|
11236
11289
|
async storedBytes(asset) {
|
|
11237
11290
|
if (asset.content.status === "removed") return null;
|
|
11238
11291
|
const stored = await this.imageStorage.getContent(asset.id);
|
|
@@ -11648,7 +11701,7 @@ var MockCalmLensApi = class {
|
|
|
11648
11701
|
const assetId = query.get("assetId");
|
|
11649
11702
|
if (assetId !== null && !isId(assetId, "asset")) throw invalidField("validation/invalid-format", "assetId");
|
|
11650
11703
|
const filter = btoa(JSON.stringify([[...new Set(types)].sort(), assetId]));
|
|
11651
|
-
const matches = (event) => (!types.length || types.includes(event.type)) && (assetId === null || event.
|
|
11704
|
+
const matches = (event) => (!types.length || types.includes(event.type)) && (assetId === null || event.resource?.id === assetId);
|
|
11652
11705
|
const cursor = query.get("cursor");
|
|
11653
11706
|
if (!cursor) return {
|
|
11654
11707
|
items: [],
|
|
@@ -12007,7 +12060,7 @@ var MockCalmLensApi = class {
|
|
|
12007
12060
|
const isHls = resource === "hls";
|
|
12008
12061
|
let selector;
|
|
12009
12062
|
try {
|
|
12010
|
-
selector =
|
|
12063
|
+
selector = require_CalmLensCdn.parseTransformSelector(isHls ? "" : selectorPath.join("/"));
|
|
12011
12064
|
} catch {
|
|
12012
12065
|
return invalidTransform();
|
|
12013
12066
|
}
|
|
@@ -12095,7 +12148,7 @@ var MockCalmLensApi = class {
|
|
|
12095
12148
|
const stillImage = resource === "preview" || resource === "rendered" && rendered?.kind === "image";
|
|
12096
12149
|
if (!stillImage && hasSelector) return invalidTransform();
|
|
12097
12150
|
if (selector.options) {
|
|
12098
|
-
const { unknownKeys, invalidKeys } =
|
|
12151
|
+
const { unknownKeys, invalidKeys } = require_CalmLensCdn.checkTransformOptions(selector.options);
|
|
12099
12152
|
if (unknownKeys.length || invalidKeys.length) return this.jsonResponse(400, {
|
|
12100
12153
|
code: "transform-options/invalid",
|
|
12101
12154
|
message: `Invalid transform options: ${[...unknownKeys, ...invalidKeys].join(", ")}`
|
|
@@ -12279,14 +12332,14 @@ const mockClientOptions = (api, endpoints, session) => {
|
|
|
12279
12332
|
const { useTimers } = api;
|
|
12280
12333
|
const fetch = api.createFetch(endpoints, session);
|
|
12281
12334
|
const hooks = {
|
|
12282
|
-
sleep: useTimers ?
|
|
12283
|
-
await
|
|
12335
|
+
sleep: useTimers ? require_CalmLensCdn.sleep : async (ms, signal) => {
|
|
12336
|
+
await require_CalmLensCdn.sleep(0, signal);
|
|
12284
12337
|
api.waitedMs += ms;
|
|
12285
12338
|
},
|
|
12286
12339
|
now: useTimers ? () => Date.now() : () => api.waitedMs,
|
|
12287
12340
|
uploadTokenTime: () => ({
|
|
12288
12341
|
now: api.now(),
|
|
12289
|
-
nonce:
|
|
12342
|
+
nonce: require_CalmLensCdn.randomUuid()
|
|
12290
12343
|
}),
|
|
12291
12344
|
deferUploadChecks: true,
|
|
12292
12345
|
defaultCdnBaseUrl: "mock://calmlens/v1"
|
|
@@ -12318,7 +12371,7 @@ var MockCalmLensServerClient = class extends require_CalmLensServerClient.CalmLe
|
|
|
12318
12371
|
...input,
|
|
12319
12372
|
projectId: input.projectId ?? "project-1"
|
|
12320
12373
|
};
|
|
12321
|
-
|
|
12374
|
+
require_CalmLensCdn.validateServerClientOptions(options);
|
|
12322
12375
|
const { mockOptions = {}, ...clientOptions } = options;
|
|
12323
12376
|
const api = new MockCalmLensApi({
|
|
12324
12377
|
projectId: options.projectId,
|
|
@@ -12464,7 +12517,7 @@ var MockCalmLensServerClient = class extends require_CalmLensServerClient.CalmLe
|
|
|
12464
12517
|
var MockCalmLensAppClient = class extends require_CalmLensAppClient.CalmLensAppClient {
|
|
12465
12518
|
#uploadPresetId;
|
|
12466
12519
|
constructor(options) {
|
|
12467
|
-
|
|
12520
|
+
require_CalmLensCdn.validateAppClientOptions(options);
|
|
12468
12521
|
const { mockOptions = {}, ...clientOptions } = options;
|
|
12469
12522
|
if (mockOptions.preset) checkMockUploadPreset(mockOptions.preset);
|
|
12470
12523
|
const server = mockOptions.server ?? new MockCalmLensServerClient({
|
|
@@ -12514,8 +12567,7 @@ const toWebhookEventPayload = (event) => ({
|
|
|
12514
12567
|
severity: event.severity,
|
|
12515
12568
|
title: event.title,
|
|
12516
12569
|
description: event.description ?? null,
|
|
12517
|
-
|
|
12518
|
-
assetSequence: event.assetSequence ?? null,
|
|
12570
|
+
resource: event.resource ?? null,
|
|
12519
12571
|
facts: event.facts,
|
|
12520
12572
|
createdAt: event.createdAt
|
|
12521
12573
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
require("./Core-
|
|
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
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
3
|
-
const require_Core = require("./Core-
|
|
4
|
-
const require_UploadController = require("./UploadController-
|
|
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-
|
|
2
|
-
import "./index-
|
|
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-
|
|
4
|
-
import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-
|
|
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-
|
|
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-
|
|
3
|
-
const require_Core = require("./Core-
|
|
4
|
-
const require_UploadController = require("./UploadController-
|
|
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-
|
|
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-
|
|
2
|
-
import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-
|
|
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-
|
|
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-
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-
|
|
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-
|
|
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.
|
|
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
|
-
|
|
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-
|
|
2
|
-
import {
|
|
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."
|