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