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,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as prepareSubmitAssetOptions, f as resolveConnectionOptions, i as CalmLensConnection, p as splitsIntoParts, s as expectUploadedAsset, t as APP_OPTION_KEYS } from "./CalmLensOptionKeys-
|
|
1
|
+
import { B as invalidArgument, S as validateAppClientOptions, V as invalidConfig, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, u as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-B6_RalCQ.js";
|
|
2
|
+
import { d as prepareSubmitAssetOptions, f as resolveConnectionOptions, i as CalmLensConnection, p as splitsIntoParts, s as expectUploadedAsset, t as APP_OPTION_KEYS } from "./CalmLensOptionKeys-BGZlIsT2.js";
|
|
3
3
|
// src/client/CalmLensAppClient.ts
|
|
4
4
|
const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
5
5
|
/** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
|
|
@@ -19,11 +19,15 @@ var CalmLensAppClient = class {
|
|
|
19
19
|
/** The token each upload started with, for its parts and status checks. */
|
|
20
20
|
#uploadTokens = /* @__PURE__ */ new Map();
|
|
21
21
|
#connection;
|
|
22
|
+
#projectId;
|
|
23
|
+
#cdnBaseUrl;
|
|
22
24
|
constructor(options) {
|
|
23
25
|
validateAppClientOptions(options);
|
|
24
|
-
const { token, uploadPresetId, ...rest } = options;
|
|
26
|
+
const { token, uploadPresetId, projectId, cdnBaseUrl, ...rest } = options;
|
|
25
27
|
this.#uploadPresetId = uploadPresetId;
|
|
26
28
|
this.#token = token;
|
|
29
|
+
this.#projectId = projectId;
|
|
30
|
+
this.#cdnBaseUrl = (cdnBaseUrl ?? DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
|
|
27
31
|
this.#connection = new CalmLensConnection(resolveConnectionOptions(rest));
|
|
28
32
|
}
|
|
29
33
|
/** Keeps tokens out of `console.log`, `util.inspect` and `JSON.stringify`. */
|
|
@@ -51,7 +55,7 @@ var CalmLensAppClient = class {
|
|
|
51
55
|
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
52
56
|
}
|
|
53
57
|
/** Uploads with a new token, kept for the upload's parts and status checks. */
|
|
54
|
-
async submit(options,
|
|
58
|
+
async submit(options, wait) {
|
|
55
59
|
if (!options || typeof options !== "object") throw invalidArgument("Upload options are required");
|
|
56
60
|
if (!("content" in options) && !("part" in options)) throw invalidArgument("Uploads through an upload preset need content or a part");
|
|
57
61
|
prepareSubmitAssetOptions(options, {
|
|
@@ -60,7 +64,7 @@ var CalmLensAppClient = class {
|
|
|
60
64
|
});
|
|
61
65
|
const token = await this.newUploadToken();
|
|
62
66
|
if ("content" in options && splitsIntoParts(options.content, this.#connection.partSizeBytes)) {
|
|
63
|
-
const data = await this.#connection.submitInParts(this.uploadsPath, options,
|
|
67
|
+
const data = await this.#connection.submitInParts(this.uploadsPath, options, wait, {
|
|
64
68
|
authHeaders: token ? { Authorization: `Bearer ${token}` } : {},
|
|
65
69
|
partPath: (assetId) => `${this.uploadsPath}/${encodeURIComponent(assetId)}/part`,
|
|
66
70
|
onStarted: (assetId) => {
|
|
@@ -70,20 +74,36 @@ var CalmLensAppClient = class {
|
|
|
70
74
|
});
|
|
71
75
|
return expectUploadedAsset(data);
|
|
72
76
|
}
|
|
73
|
-
const data = await this.#connection.submitRawUpload(this.uploadsPath, options,
|
|
77
|
+
const data = await this.#connection.submitRawUpload(this.uploadsPath, options, wait, token ? { Authorization: `Bearer ${token}` } : {});
|
|
74
78
|
const uploaded = expectUploadedAsset(data);
|
|
75
79
|
if (token) this.#uploadTokens.set(uploaded.id, token);
|
|
76
80
|
return uploaded;
|
|
77
81
|
}
|
|
82
|
+
/** Public asset URLs, built without a request. */
|
|
83
|
+
get cdn() {
|
|
84
|
+
return {
|
|
85
|
+
/**
|
|
86
|
+
* Builds a public asset's CDN URL: the asset URL, or a resource URL when `resource` is
|
|
87
|
+
* given, with its lens or transform and the viewer claims. Private assets need a URL your
|
|
88
|
+
* server signs with `cdn.signAssetUrl`. The project is the client's `projectId` unless the
|
|
89
|
+
* call names one.
|
|
90
|
+
*/
|
|
91
|
+
getAssetUrl: (urlOptions) => {
|
|
92
|
+
const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
|
|
93
|
+
const project = projectId ?? this.#projectId;
|
|
94
|
+
if (project === void 0) throw invalidArgument("Pass projectId, here or in the client's options");
|
|
95
|
+
return buildAssetUrl(this.#cdnBaseUrl, project, options);
|
|
96
|
+
} };
|
|
97
|
+
}
|
|
78
98
|
/** Uploads through the client's upload preset and checks those uploads. */
|
|
79
99
|
get assets() {
|
|
80
100
|
return {
|
|
81
|
-
/** Uploads a file and
|
|
82
|
-
create: async (options) => this.submit(checked("assets.create", options),
|
|
101
|
+
/** Uploads a file and returns without waiting for its decision. */
|
|
102
|
+
create: async (options) => this.submit(checked("assets.create", options), false),
|
|
83
103
|
/** Uploads a file and waits for its moderation decision. */
|
|
84
|
-
classify: async (options) => this.submit(checked("assets.classify", options),
|
|
104
|
+
classify: async (options) => this.submit(checked("assets.classify", options), true),
|
|
85
105
|
/**
|
|
86
|
-
* Uploads the next part of a multipart upload this client started. The upload's
|
|
106
|
+
* Uploads the next part of a multipart upload this client started. The upload's wait
|
|
87
107
|
* mode, chosen when it started, applies when the final part arrives.
|
|
88
108
|
*/
|
|
89
109
|
uploadPart: async (partOptions) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as CalmLensAppClientOptions, Jt as UploadPresetSubmitAssetOptions, Yt as UploadedAsset, j as CdnAssetUrlOptions, jt as RetrieveAssetOptions, qt as UploadAssetPartOptions } from "./CalmLensTypes-CUB0YYVz.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,
|
|
@@ -22,14 +22,24 @@ declare class CalmLensAppClient {
|
|
|
22
22
|
private authHeaders;
|
|
23
23
|
/** Uploads with a new token, kept for the upload's parts and status checks. */
|
|
24
24
|
private submit;
|
|
25
|
+
/** Public asset URLs, built without a request. */
|
|
26
|
+
get cdn(): {
|
|
27
|
+
/**
|
|
28
|
+
* Builds a public asset's CDN URL: the asset URL, or a resource URL when `resource` is
|
|
29
|
+
* given, with its lens or transform and the viewer claims. Private assets need a URL your
|
|
30
|
+
* server signs with `cdn.signAssetUrl`. The project is the client's `projectId` unless the
|
|
31
|
+
* call names one.
|
|
32
|
+
*/
|
|
33
|
+
getAssetUrl: (urlOptions: CdnAssetUrlOptions) => string;
|
|
34
|
+
};
|
|
25
35
|
/** Uploads through the client's upload preset and checks those uploads. */
|
|
26
36
|
get assets(): {
|
|
27
|
-
/** Uploads a file and
|
|
37
|
+
/** Uploads a file and returns without waiting for its decision. */
|
|
28
38
|
create: (options: UploadPresetSubmitAssetOptions) => Promise<UploadedAsset>;
|
|
29
39
|
/** Uploads a file and waits for its moderation decision. */
|
|
30
40
|
classify: (options: UploadPresetSubmitAssetOptions) => Promise<UploadedAsset>;
|
|
31
41
|
/**
|
|
32
|
-
* Uploads the next part of a multipart upload this client started. The upload's
|
|
42
|
+
* Uploads the next part of a multipart upload this client started. The upload's wait
|
|
33
43
|
* mode, chosen when it started, applies when the final part arrives.
|
|
34
44
|
*/
|
|
35
45
|
uploadPart: (partOptions: UploadAssetPartOptions) => Promise<UploadedAsset>;
|