calmlens 0.20.0 → 0.21.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/README.md +13 -9
- package/bin/calmlens.js +1329 -664
- package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-CeSwiMo5.js} +1 -1
- package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
- package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-CYY6elxg.js} +183 -347
- package/cjs/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
- package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-nfu6_YEW.js} +288 -88
- package/cjs/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/cjs/Core-C82YmjjX.d.ts +823 -0
- package/cjs/Core-Dc3cteU7.js +998 -0
- package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
- package/cjs/{ModerationContextLimits-2nIv7Zh3.js → ModerationContextLimits-BxOmeSqq.js} +669 -269
- package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-BK2O3dnK.js} +1 -1
- package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +342 -34
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{UploadController-MLVs97Zt.js → UploadController-DLyiLDTB.js} +34 -14
- package/cjs/{WebhookPayload-DkukERKE.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/cjs/app.d.ts +6 -7
- package/cjs/app.js +4 -3
- package/cjs/elements.d.ts +123 -22
- package/cjs/elements.js +553 -156
- package/cjs/file-icons.d.ts +2 -67
- package/cjs/index-CKRgjV16.d.ts +16 -0
- package/cjs/index.d.ts +5 -6
- package/cjs/index.js +3 -2
- package/cjs/react-native.d.ts +52 -11
- package/cjs/react-native.js +231 -99
- package/cjs/react.d.ts +42 -9
- package/cjs/react.js +381 -118
- package/cjs/server.d.ts +48 -7
- package/cjs/server.js +7 -3
- package/cjs/test-inputs.d.ts +2 -2
- package/cjs/test-inputs.js +13 -9
- package/cjs/testing.d.ts +24 -14
- package/cjs/testing.js +1413 -402
- package/cjs/ui-CTBUxnVp.d.ts +139 -0
- package/cjs/ui-CZ8exACq.js +1359 -0
- package/cjs/ui.d.ts +3 -2
- package/cjs/ui.js +45 -22
- package/cjs/vue.d.ts +802 -199
- package/cjs/vue.js +359 -127
- package/esm/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-i9OhCzMJ.js} +1 -1
- package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
- package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BGZlIsT2.js} +182 -340
- package/esm/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
- package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-dAQUcDWb.js} +265 -89
- package/esm/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/esm/Core-BxeIud_S.js +843 -0
- package/esm/Core-C82YmjjX.d.ts +823 -0
- package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
- package/esm/{ModerationContextLimits-Chw-AzgL.js → ModerationContextLimits-B6_RalCQ.js} +624 -254
- package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-DxwVqfX1.js} +1 -1
- package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +319 -35
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{UploadController-BJZghJpg.js → UploadController-D9Z-h00Q.js} +34 -14
- package/esm/{WebhookPayload-DkukERKE.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/esm/app.d.ts +6 -7
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +123 -22
- package/esm/elements.js +497 -128
- package/esm/file-icons.d.ts +2 -67
- package/esm/index-CKRgjV16.d.ts +16 -0
- package/esm/index.d.ts +5 -6
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +52 -11
- package/esm/react-native.js +205 -75
- package/esm/react.d.ts +42 -9
- package/esm/react.js +327 -91
- package/esm/server.d.ts +48 -7
- package/esm/server.js +3 -3
- package/esm/styles.css +142 -22
- package/esm/svelte/AssetViewer.svelte +25 -0
- package/esm/svelte/CalmLensAsset.svelte +318 -0
- package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
- package/esm/svelte/CalmLensImageViewer.svelte +7 -0
- package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
- package/esm/svelte/CalmLensTextViewer.svelte +7 -0
- package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
- package/esm/svelte/index.d.ts +29 -6
- package/esm/svelte/index.js +7 -2
- package/esm/test-inputs.d.ts +2 -2
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +24 -14
- package/esm/testing.js +1409 -398
- package/esm/ui-CTBUxnVp.d.ts +139 -0
- package/esm/ui-Cr7s6JHm.js +1258 -0
- package/esm/ui.d.ts +3 -2
- package/esm/ui.js +4 -3
- package/esm/vue.d.ts +802 -199
- package/esm/vue.js +308 -103
- package/package.json +3 -1
- package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/cjs/index-DxbJ_Xaa.d.ts +0 -253
- package/cjs/ui-BSqPGKrZ.d.ts +0 -539
- package/cjs/ui-CX1z2pD9.js +0 -586
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/esm/index-DxbJ_Xaa.d.ts +0 -253
- package/esm/svelte/CalmLensMedia.svelte +0 -134
- package/esm/ui-BSqPGKrZ.d.ts +0 -539
- package/esm/ui-CXH7xJpb.js +0 -461
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as ClassificationCategory } from "./Classification-Q5zGpR8l-CEWjnE39.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
interface RgbaImage {
|
|
4
4
|
width: number;
|
|
@@ -11,6 +11,41 @@ declare const TEST_INPUT_KEY_PATTERN: RegExp;
|
|
|
11
11
|
/** Category shortcuts are presets in the same instance-based format. */
|
|
12
12
|
declare function testInputForSignal(signal: ClassificationTestSignal, kind?: "image" | "text"): TestInput;
|
|
13
13
|
declare const getImageTestCategories: () => ClassificationTestSignal[];
|
|
14
|
+
/** Each detection list holds at most this many entries; 32 faces fit a test image. */
|
|
15
|
+
declare const TEST_DETECTIONS_MAX = 32;
|
|
16
|
+
/** Box values are integer basis points of the image width and height: 10000 is the full side. */
|
|
17
|
+
declare const TEST_DETECTION_BOX_MAX = 10000;
|
|
18
|
+
/** Age presets and the range a custom estimate may use. */
|
|
19
|
+
declare const TEST_FACE_AGE_PRESETS: {
|
|
20
|
+
readonly adult: {
|
|
21
|
+
readonly low: 25;
|
|
22
|
+
readonly high: 35;
|
|
23
|
+
};
|
|
24
|
+
readonly minor: {
|
|
25
|
+
readonly low: 12;
|
|
26
|
+
readonly high: 16;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
declare const TEST_FACE_AGE_MAX = 120;
|
|
30
|
+
/** Person and face detection results a test image reports instead of running detection. */
|
|
31
|
+
declare const TEST_DETECTIONS_SCHEMA: z.ZodObject<{
|
|
32
|
+
people: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
33
|
+
box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
34
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
}, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
|
|
36
|
+
faces: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
37
|
+
box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
38
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
age: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
40
|
+
adult: "adult";
|
|
41
|
+
minor: "minor";
|
|
42
|
+
}>, z.ZodObject<{
|
|
43
|
+
low: z.ZodNumber;
|
|
44
|
+
high: z.ZodNumber;
|
|
45
|
+
}, z.core.$strict>]>>;
|
|
46
|
+
}, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
type TestDetections = z.infer<typeof TEST_DETECTIONS_SCHEMA>;
|
|
14
49
|
/** Each row is one qualifying instance. Unselected qualifiers are explicitly absent. */
|
|
15
50
|
declare const TEST_INPUT_SCHEMA: z.ZodObject<{
|
|
16
51
|
regionalActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -157,6 +192,7 @@ declare const TEST_INPUT_SCHEMA: z.ZodObject<{
|
|
|
157
192
|
"sexual-extreme": "sexual-extreme";
|
|
158
193
|
"sexual-fictional": "sexual-fictional";
|
|
159
194
|
"sexual-historical": "sexual-historical";
|
|
195
|
+
"sexual-incest": "sexual-incest";
|
|
160
196
|
"sexual-intimate-image-abuse": "sexual-intimate-image-abuse";
|
|
161
197
|
"sexual-minors": "sexual-minors";
|
|
162
198
|
"sexual-non-consensual": "sexual-non-consensual";
|
|
@@ -166,6 +202,7 @@ declare const TEST_INPUT_SCHEMA: z.ZodObject<{
|
|
|
166
202
|
"sexual-pornographic-media": "sexual-pornographic-media";
|
|
167
203
|
"sexual-revealing-clothing": "sexual-revealing-clothing";
|
|
168
204
|
"sexual-solicitation": "sexual-solicitation";
|
|
205
|
+
"sexual-strangulation": "sexual-strangulation";
|
|
169
206
|
"sexual-suggestive": "sexual-suggestive";
|
|
170
207
|
"sexual-support-prevention": "sexual-support-prevention";
|
|
171
208
|
"sexual-text": "sexual-text";
|
|
@@ -195,6 +232,23 @@ declare const TEST_INPUT_SCHEMA: z.ZodObject<{
|
|
|
195
232
|
"violence-wish": "violence-wish";
|
|
196
233
|
}>>;
|
|
197
234
|
}, z.core.$strict>>;
|
|
235
|
+
detections: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
people: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
237
|
+
box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
238
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
}, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
|
|
240
|
+
faces: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
241
|
+
box: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
242
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
243
|
+
age: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
244
|
+
adult: "adult";
|
|
245
|
+
minor: "minor";
|
|
246
|
+
}>, z.ZodObject<{
|
|
247
|
+
low: z.ZodNumber;
|
|
248
|
+
high: z.ZodNumber;
|
|
249
|
+
}, z.core.$strict>]>>;
|
|
250
|
+
}, z.core.$strict>>, z.ZodLiteral<"unavailable">]>>;
|
|
251
|
+
}, z.core.$strict>>;
|
|
198
252
|
}, z.core.$strict>;
|
|
199
253
|
type TestInput = z.infer<typeof TEST_INPUT_SCHEMA>;
|
|
200
254
|
declare const TEST_INPUT_PRESETS: {
|
|
@@ -247,21 +301,91 @@ declare const TEST_INPUT_PRESETS: {
|
|
|
247
301
|
qualifiers: "harassment-threat"[];
|
|
248
302
|
})[];
|
|
249
303
|
};
|
|
304
|
+
oneFace: {
|
|
305
|
+
instances: never[];
|
|
306
|
+
detections: {
|
|
307
|
+
people: {
|
|
308
|
+
box: [number, number, number, number];
|
|
309
|
+
}[];
|
|
310
|
+
faces: {
|
|
311
|
+
box: [number, number, number, number];
|
|
312
|
+
}[];
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
noFace: {
|
|
316
|
+
instances: never[];
|
|
317
|
+
detections: {
|
|
318
|
+
people: never[];
|
|
319
|
+
faces: never[];
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
adultFace: {
|
|
323
|
+
instances: never[];
|
|
324
|
+
detections: {
|
|
325
|
+
people: {
|
|
326
|
+
box: [number, number, number, number];
|
|
327
|
+
}[];
|
|
328
|
+
faces: {
|
|
329
|
+
box: [number, number, number, number];
|
|
330
|
+
age: "adult";
|
|
331
|
+
}[];
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
minorFace: {
|
|
335
|
+
instances: never[];
|
|
336
|
+
detections: {
|
|
337
|
+
people: {
|
|
338
|
+
box: [number, number, number, number];
|
|
339
|
+
}[];
|
|
340
|
+
faces: {
|
|
341
|
+
box: [number, number, number, number];
|
|
342
|
+
age: "minor";
|
|
343
|
+
}[];
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
group: {
|
|
347
|
+
instances: never[];
|
|
348
|
+
detections: {
|
|
349
|
+
people: {
|
|
350
|
+
box: [number, number, number, number];
|
|
351
|
+
}[];
|
|
352
|
+
faces: {
|
|
353
|
+
box: [number, number, number, number];
|
|
354
|
+
}[];
|
|
355
|
+
};
|
|
356
|
+
};
|
|
250
357
|
};
|
|
251
358
|
declare function generateTestTextCode(scenario: TestInput | ClassificationTestSignal, key: string): Promise<string>;
|
|
359
|
+
/**
|
|
360
|
+
* The scenario a text declares when the whole text is one code signed with `key`; surrounding
|
|
361
|
+
* text, a second code or an altered code all return undefined, so the text is moderated as
|
|
362
|
+
* ordinary content.
|
|
363
|
+
*/
|
|
252
364
|
declare function detectTestTrigger(text: string, key: string): Promise<TestInput | undefined>;
|
|
253
365
|
/**
|
|
254
|
-
* The text code's signed bytes as a grid (TestImageGrid.ts): the
|
|
255
|
-
* bytes, big-endian), the 16-byte tag, then the JSON. The reader rebuilds
|
|
256
|
-
* and text share one verification.
|
|
366
|
+
* The text code's signed bytes as a grid (TestImageGrid.ts): the signed payload's length (two
|
|
367
|
+
* bytes, big-endian), the 16-byte tag, then the payload (the scenario JSON). The reader rebuilds
|
|
368
|
+
* the text code, so images and text share one verification.
|
|
257
369
|
*/
|
|
258
370
|
declare function paintTestImage(scenario: TestInput | ClassificationTestSignal, key: string): Promise<{
|
|
259
371
|
width: number;
|
|
260
372
|
height: number;
|
|
261
373
|
rgba: Uint8Array<ArrayBuffer>;
|
|
262
374
|
}>;
|
|
263
|
-
/**
|
|
264
|
-
|
|
375
|
+
/**
|
|
376
|
+
* The test input an image declares when the whole image is one of the project's test images,
|
|
377
|
+
* also after lossy formats and resizing: the grid, optionally on a uniform border. Every pixel
|
|
378
|
+
* must match the grid repainted from the bytes it carries (TestImageGrid.ts,
|
|
379
|
+
* `matchesTestImageGrid`), so nothing else can be drawn on or around it.
|
|
380
|
+
*/
|
|
381
|
+
declare function detectTestImage(image: RgbaImage, key: string,
|
|
382
|
+
/**
|
|
383
|
+
* `whole: false` only reads the grid, for a video frame: media moderation sees the frame anyway,
|
|
384
|
+
* so its findings can only add to that moderation.
|
|
385
|
+
*/
|
|
386
|
+
{ whole }?: {
|
|
387
|
+
whole?: boolean;
|
|
388
|
+
}): Promise<{
|
|
265
389
|
regionalActions?: {
|
|
266
390
|
region: "AT" | "AU" | "BR" | "DE" | "EU" | "FR" | "GB";
|
|
267
391
|
action: "age-restrict" | "block" | "limit";
|
|
@@ -271,7 +395,21 @@ declare function detectTestImage(image: RgbaImage, key: string): Promise<{
|
|
|
271
395
|
category: "criminal-activity" | "harassment" | "hate" | "personal-information" | "profanity" | "self-harm" | "sexual" | "violence";
|
|
272
396
|
score?: number | undefined;
|
|
273
397
|
action?: "age-restrict" | "allow" | "block" | "limit" | undefined;
|
|
274
|
-
qualifiers: ("criminal-activity-alcohol" | "criminal-activity-coded-incitement" | "criminal-activity-csam" | "criminal-activity-demonstration" | "criminal-activity-discussion" | "criminal-activity-documentary" | "criminal-activity-educational" | "criminal-activity-fictional" | "criminal-activity-fraud" | "criminal-activity-gambling" | "criminal-activity-graffiti" | "criminal-activity-grooming" | "criminal-activity-historical" | "criminal-activity-instructions" | "criminal-activity-preparation" | "criminal-activity-promotion" | "criminal-activity-request" | "criminal-activity-sexual-solicitation" | "criminal-activity-substances" | "criminal-activity-support-prevention" | "criminal-activity-tobacco" | "harassment-abuse" | "harassment-bullying" | "harassment-documentary" | "harassment-educational" | "harassment-encouragement" | "harassment-fictional" | "harassment-historical" | "harassment-mild" | "harassment-public-target" | "harassment-sexual" | "harassment-support-prevention" | "harassment-threat" | "hate-abuse" | "hate-adjudicated-nazi-crimes-denial" | "hate-counterspeech" | "hate-dehumanization" | "hate-documentary" | "hate-educational" | "hate-exclusion" | "hate-fictional" | "hate-historical" | "hate-hostility" | "hate-inferiority" | "hate-nazi-genocide-denial-or-approval" | "hate-nazi-genocide-public-peace" | "hate-nazi-insignia-public-display" | "hate-nazi-symbols-public-display" | "hate-personal" | "hate-slurs" | "hate-support-prevention" | "hate-symbol" | "hate-threat" | "personal-information-contact" | "personal-information-credentials" | "personal-information-documentary" | "personal-information-educational" | "personal-information-email" | "personal-information-fictional" | "personal-information-financial" | "personal-information-government-id" | "personal-information-historical" | "personal-information-identifiers" | "personal-information-location" | "personal-information-phone" | "personal-information-request" | "personal-information-self-disclosure" | "personal-information-support-prevention" | "personal-information-third-party" | "profanity-documentary" | "profanity-educational" | "profanity-fictional" | "profanity-historical" | "profanity-mild" | "profanity-obfuscated" | "profanity-slurs" | "profanity-strong" | "profanity-support-prevention" | "self-harm-act" | "self-harm-age-restricted" | "self-harm-documentary" | "self-harm-educational" | "self-harm-encouragement" | "self-harm-fictional" | "self-harm-historical" | "self-harm-methods" | "self-harm-preparation" | "self-harm-support-prevention" | "self-harm-thoughts" | "sexual-activity" | "sexual-adult-promotion" | "sexual-assault-media" | "sexual-discussion" | "sexual-documentary" | "sexual-educational" | "sexual-explicit-language" | "sexual-extreme" | "sexual-fictional" | "sexual-historical" | "sexual-intimate-image-abuse" | "sexual-minors" | "sexual-non-consensual" | "sexual-non-erotic-nudity" | "sexual-nudity" | "sexual-paid" | "sexual-pornographic-media" | "sexual-revealing-clothing" | "sexual-solicitation" | "sexual-suggestive" | "sexual-support-prevention" | "sexual-text" | "violence-attack" | "violence-coded-incitement" | "violence-decapitation-act" | "violence-discussion" | "violence-documentary" | "violence-educational" | "violence-encouragement" | "violence-extremism" | "violence-fantasy" | "violence-fictional" | "violence-gore" | "violence-graphic" | "violence-high-impact" | "violence-historical" | "violence-injury" | "violence-natural-death" | "violence-preparation" | "violence-sport" | "violence-support-prevention" | "violence-text" | "violence-threat" | "violence-violent-death" | "violence-weapon" | "violence-wish")[];
|
|
398
|
+
qualifiers: ("criminal-activity-alcohol" | "criminal-activity-coded-incitement" | "criminal-activity-csam" | "criminal-activity-demonstration" | "criminal-activity-discussion" | "criminal-activity-documentary" | "criminal-activity-educational" | "criminal-activity-fictional" | "criminal-activity-fraud" | "criminal-activity-gambling" | "criminal-activity-graffiti" | "criminal-activity-grooming" | "criminal-activity-historical" | "criminal-activity-instructions" | "criminal-activity-preparation" | "criminal-activity-promotion" | "criminal-activity-request" | "criminal-activity-sexual-solicitation" | "criminal-activity-substances" | "criminal-activity-support-prevention" | "criminal-activity-tobacco" | "harassment-abuse" | "harassment-bullying" | "harassment-documentary" | "harassment-educational" | "harassment-encouragement" | "harassment-fictional" | "harassment-historical" | "harassment-mild" | "harassment-public-target" | "harassment-sexual" | "harassment-support-prevention" | "harassment-threat" | "hate-abuse" | "hate-adjudicated-nazi-crimes-denial" | "hate-counterspeech" | "hate-dehumanization" | "hate-documentary" | "hate-educational" | "hate-exclusion" | "hate-fictional" | "hate-historical" | "hate-hostility" | "hate-inferiority" | "hate-nazi-genocide-denial-or-approval" | "hate-nazi-genocide-public-peace" | "hate-nazi-insignia-public-display" | "hate-nazi-symbols-public-display" | "hate-personal" | "hate-slurs" | "hate-support-prevention" | "hate-symbol" | "hate-threat" | "personal-information-contact" | "personal-information-credentials" | "personal-information-documentary" | "personal-information-educational" | "personal-information-email" | "personal-information-fictional" | "personal-information-financial" | "personal-information-government-id" | "personal-information-historical" | "personal-information-identifiers" | "personal-information-location" | "personal-information-phone" | "personal-information-request" | "personal-information-self-disclosure" | "personal-information-support-prevention" | "personal-information-third-party" | "profanity-documentary" | "profanity-educational" | "profanity-fictional" | "profanity-historical" | "profanity-mild" | "profanity-obfuscated" | "profanity-slurs" | "profanity-strong" | "profanity-support-prevention" | "self-harm-act" | "self-harm-age-restricted" | "self-harm-documentary" | "self-harm-educational" | "self-harm-encouragement" | "self-harm-fictional" | "self-harm-historical" | "self-harm-methods" | "self-harm-preparation" | "self-harm-support-prevention" | "self-harm-thoughts" | "sexual-activity" | "sexual-adult-promotion" | "sexual-assault-media" | "sexual-discussion" | "sexual-documentary" | "sexual-educational" | "sexual-explicit-language" | "sexual-extreme" | "sexual-fictional" | "sexual-historical" | "sexual-incest" | "sexual-intimate-image-abuse" | "sexual-minors" | "sexual-non-consensual" | "sexual-non-erotic-nudity" | "sexual-nudity" | "sexual-paid" | "sexual-pornographic-media" | "sexual-revealing-clothing" | "sexual-solicitation" | "sexual-strangulation" | "sexual-suggestive" | "sexual-support-prevention" | "sexual-text" | "violence-attack" | "violence-coded-incitement" | "violence-decapitation-act" | "violence-discussion" | "violence-documentary" | "violence-educational" | "violence-encouragement" | "violence-extremism" | "violence-fantasy" | "violence-fictional" | "violence-gore" | "violence-graphic" | "violence-high-impact" | "violence-historical" | "violence-injury" | "violence-natural-death" | "violence-preparation" | "violence-sport" | "violence-support-prevention" | "violence-text" | "violence-threat" | "violence-violent-death" | "violence-weapon" | "violence-wish")[];
|
|
275
399
|
}[];
|
|
400
|
+
detections?: {
|
|
401
|
+
people?: "unavailable" | {
|
|
402
|
+
box: [number, number, number, number];
|
|
403
|
+
confidence?: number | undefined;
|
|
404
|
+
}[] | undefined;
|
|
405
|
+
faces?: "unavailable" | {
|
|
406
|
+
box: [number, number, number, number];
|
|
407
|
+
confidence?: number | undefined;
|
|
408
|
+
age?: "adult" | "minor" | {
|
|
409
|
+
low: number;
|
|
410
|
+
high: number;
|
|
411
|
+
} | undefined;
|
|
412
|
+
}[] | undefined;
|
|
413
|
+
} | undefined;
|
|
276
414
|
} | undefined>;
|
|
277
|
-
export {
|
|
415
|
+
export { TEST_FACE_AGE_PRESETS as a, TestDetections as c, detectTestTrigger as d, generateTestTextCode as f, testInputForSignal as h, TEST_FACE_AGE_MAX as i, TestInput as l, paintTestImage as m, TEST_DETECTIONS_MAX as n, TEST_INPUT_KEY_PATTERN as o, getImageTestCategories as p, TEST_DETECTION_BOX_MAX as r, TEST_INPUT_PRESETS as s, ClassificationTestSignal as t, detectTestImage as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_ModerationContextLimits = require("./ModerationContextLimits-
|
|
2
|
-
const require_CalmLensAppClient = require("./CalmLensAppClient-
|
|
1
|
+
const require_ModerationContextLimits = require("./ModerationContextLimits-BxOmeSqq.js");
|
|
2
|
+
const require_CalmLensAppClient = require("./CalmLensAppClient-0UVCuNqW.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.
|
|
@@ -307,6 +307,22 @@ const sleep = (ms, signal) => new Promise((resolve) => {
|
|
|
307
307
|
resolve();
|
|
308
308
|
});
|
|
309
309
|
});
|
|
310
|
+
/** A custom upload is settled once it has a status other than `pending`, or reports none. */
|
|
311
|
+
const checkedCustomUpload = (id, status) => ({
|
|
312
|
+
id,
|
|
313
|
+
status,
|
|
314
|
+
settled: status !== "pending"
|
|
315
|
+
});
|
|
316
|
+
/**
|
|
317
|
+
* An upload preset's upload is settled once its processing is `completed` or `failed`; its
|
|
318
|
+
* moderation status is present only when the preset shows decisions.
|
|
319
|
+
*/
|
|
320
|
+
const checkedPresetUpload = ({ id, classification }) => ({
|
|
321
|
+
id,
|
|
322
|
+
status: classification.moderation?.status,
|
|
323
|
+
settled: classification.status === "completed" || classification.status === "failed",
|
|
324
|
+
failed: classification.status === "failed"
|
|
325
|
+
});
|
|
310
326
|
let nextKey = 0;
|
|
311
327
|
/**
|
|
312
328
|
* Uploads files through an upload preset and tracks each one until it has a moderation
|
|
@@ -498,12 +514,22 @@ var UploadController = class {
|
|
|
498
514
|
});
|
|
499
515
|
}
|
|
500
516
|
const deadline = Date.now() + (options.decisionTimeoutMs ?? DEFAULT_DECISION_TIMEOUT_MS);
|
|
501
|
-
for (let delay = 1e3; asset.
|
|
517
|
+
for (let delay = 1e3; !asset.settled && check && Date.now() < deadline; delay *= 2) {
|
|
502
518
|
await sleep(Math.min(delay, Math.max(0, deadline - Date.now())), abort.signal);
|
|
503
519
|
if (abort.signal.aborted) return;
|
|
504
520
|
asset = await check(asset.id);
|
|
505
521
|
}
|
|
506
522
|
if (abort.signal.aborted) return;
|
|
523
|
+
if (asset.failed) {
|
|
524
|
+
this.#checks.delete(key);
|
|
525
|
+
this.#update(key, {
|
|
526
|
+
stage: "failed",
|
|
527
|
+
progress: null
|
|
528
|
+
});
|
|
529
|
+
const item = this.#find(key);
|
|
530
|
+
if (item) options.onFailed?.(item);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
507
533
|
this.#update(key, {
|
|
508
534
|
stage: "complete",
|
|
509
535
|
status: asset.status
|
|
@@ -540,15 +566,9 @@ var UploadController = class {
|
|
|
540
566
|
signal,
|
|
541
567
|
onProgress
|
|
542
568
|
});
|
|
543
|
-
return
|
|
544
|
-
id: assetId,
|
|
545
|
-
status
|
|
546
|
-
};
|
|
569
|
+
return checkedCustomUpload(assetId, status);
|
|
547
570
|
},
|
|
548
|
-
retrieve: checkStatus ? async (assetId) => ({
|
|
549
|
-
id: assetId,
|
|
550
|
-
status: await checkStatus(assetId, { signal })
|
|
551
|
-
}) : void 0
|
|
571
|
+
retrieve: checkStatus ? async (assetId) => checkedCustomUpload(assetId, await checkStatus(assetId, { signal })) : void 0
|
|
552
572
|
};
|
|
553
573
|
if (!uploadPresetId) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.SDK_ERROR_CODES.INVALID_CONFIG, { message: "The uploader needs an uploadPresetId or an upload function" });
|
|
554
574
|
const options = {
|
|
@@ -562,7 +582,7 @@ var UploadController = class {
|
|
|
562
582
|
return {
|
|
563
583
|
create: async () => {
|
|
564
584
|
const type = file.type || "application/octet-stream";
|
|
565
|
-
return client.assets.create({
|
|
585
|
+
return checkedPresetUpload(await client.assets.create({
|
|
566
586
|
name: file.name,
|
|
567
587
|
content: isBlob(file) ? {
|
|
568
588
|
data: file,
|
|
@@ -571,9 +591,9 @@ var UploadController = class {
|
|
|
571
591
|
uint8Array: new Uint8Array(await file.arrayBuffer()),
|
|
572
592
|
type
|
|
573
593
|
}
|
|
574
|
-
});
|
|
594
|
+
}));
|
|
575
595
|
},
|
|
576
|
-
retrieve: (assetId) => client.assets.retrieve({ assetId })
|
|
596
|
+
retrieve: async (assetId) => checkedPresetUpload(await client.assets.retrieve({ assetId }))
|
|
577
597
|
};
|
|
578
598
|
}
|
|
579
599
|
async #tokenFor(file, signal) {
|