calmlens 0.25.0 → 0.27.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 +15 -15
- package/bin/calmlens.js +2383 -677
- package/cjs/{BrowserUpload-AO2-2U5Z.js → BrowserUpload-CTqIjCV5.js} +1 -1
- package/{esm/BrowserUpload-D2lemMIU.d.ts → cjs/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{esm/CalmLensAppClient-Dt0t9Bk6.d.ts → cjs/CalmLensAppClient-CCeFnKX8.d.ts} +5 -11
- package/cjs/{CalmLensAppClient-nv6qwja0.js → CalmLensAppClient-CZm-9g22.js} +23 -16
- package/cjs/{CalmLensOptionKeys-BvCac9NO.js → CalmLensOptionKeys-C1w3SqmL.js} +165 -95
- package/cjs/CalmLensServerClient-B7PfocET.d.ts +346 -0
- package/cjs/{CalmLensServerClient-B60kCBCR.js → CalmLensServerClient-ucq3ITjd.js} +281 -315
- package/cjs/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-HUERg5hI.d.ts} +142 -155
- package/cjs/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/cjs/{Core-Cw4IxFUq.js → Core-D-1KCqT7.js} +39 -16
- package/cjs/{Core-DSMxC2GL.d.ts → Core-DXAs8mcx.d.ts} +10 -3
- package/{esm/ModerationContextLimits-Bqr0duav.js → cjs/ModerationContextLimits-BcYKgU2X.js} +859 -44
- package/cjs/ReactUpload-BTciTpwB.d.ts +27 -0
- package/cjs/{ReactUpload--oDFltw2.js → ReactUpload-BymgWiC8.js} +38 -2
- package/cjs/{TestTriggers-CiFcTHX3-BmfH4J3f.js → TestTriggers-Cvi7e2KA-DcT1pc_W.js} +91 -22
- package/{esm/TestTriggers-BJ4B-MXR-D1tGifPU.d.ts → cjs/TestTriggers-Dnukm-jm-DoEB7jJc.d.ts} +1 -1
- package/cjs/{UploadController-ObdgTaBl.js → UploadController-C8GPbDKI.js} +16 -3
- package/{esm/WebhookPayload-DLGGOGW6.d.ts → cjs/WebhookPayload-mUmOFH55.d.ts} +152 -9
- package/cjs/app.d.ts +6 -6
- package/cjs/app.js +20 -2
- package/cjs/elements.d.ts +5 -5
- package/cjs/elements.js +105 -68
- package/cjs/{index-AAWuerkU.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/cjs/index.d.ts +5 -5
- package/cjs/index.js +19 -1
- package/cjs/react-native.d.ts +3 -3
- package/cjs/react-native.js +7 -5
- package/cjs/react.d.ts +5 -4
- package/cjs/react.js +11 -15
- package/cjs/server.d.ts +6 -6
- package/cjs/server.js +20 -2
- package/cjs/test-inputs.d.ts +1 -1
- package/cjs/test-inputs.js +13 -13
- package/cjs/testing.d.ts +18 -21
- package/cjs/testing.js +99 -147
- package/cjs/{ui-CcuGKTcL.d.ts → ui-BfJNO3c6.d.ts} +2 -2
- package/cjs/{ui-CA16jyfZ.js → ui-CW8BqtZk.js} +7 -5
- package/cjs/ui.d.ts +3 -3
- package/cjs/ui.js +4 -3
- package/cjs/vue.d.ts +15 -8
- package/cjs/vue.js +30 -17
- package/esm/{BrowserUpload-Co4T6uGk.js → BrowserUpload-C01iLeOs.js} +1 -1
- package/{cjs/BrowserUpload-D2lemMIU.d.ts → esm/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{cjs/CalmLensAppClient-Dt0t9Bk6.d.ts → esm/CalmLensAppClient-CCeFnKX8.d.ts} +5 -11
- package/esm/{CalmLensAppClient-BRzy4dwn.js → CalmLensAppClient-CgDogQQC.js} +23 -16
- package/esm/{CalmLensOptionKeys-bE3rb5PN.js → CalmLensOptionKeys-CEwNbpEz.js} +160 -96
- package/esm/CalmLensServerClient-B7PfocET.d.ts +346 -0
- package/esm/{CalmLensServerClient-_PRi90wI.js → CalmLensServerClient-TT6zrAG5.js} +281 -315
- package/esm/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-HUERg5hI.d.ts} +142 -155
- package/esm/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/esm/{Core-CtbYmeXG.js → Core-CP6NaqJz.js} +39 -16
- package/esm/{Core-DSMxC2GL.d.ts → Core-DXAs8mcx.d.ts} +10 -3
- package/{cjs/ModerationContextLimits-Cn9RvnZH.js → esm/ModerationContextLimits-BmV8QD32.js} +476 -301
- package/esm/{ReactUpload-B5itHBSF.js → ReactUpload-B72Oq3qE.js} +34 -4
- package/esm/ReactUpload-BTciTpwB.d.ts +27 -0
- package/esm/{TestTriggers-CiFcTHX3-BK2-sgOC.js → TestTriggers-Cvi7e2KA-BA83CRJb.js} +87 -23
- package/{cjs/TestTriggers-BJ4B-MXR-D1tGifPU.d.ts → esm/TestTriggers-Dnukm-jm-DoEB7jJc.d.ts} +1 -1
- package/esm/{UploadController-C7fL3Iz9.js → UploadController-Q7xTqh5w.js} +11 -4
- package/{cjs/WebhookPayload-DLGGOGW6.d.ts → esm/WebhookPayload-mUmOFH55.d.ts} +152 -9
- package/esm/app.d.ts +6 -6
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +5 -5
- package/esm/elements.js +105 -69
- package/esm/{index-AAWuerkU.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/esm/index.d.ts +5 -5
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +3 -3
- package/esm/react-native.js +6 -6
- package/esm/react.d.ts +5 -4
- package/esm/react.js +10 -16
- package/esm/server.d.ts +6 -6
- package/esm/server.js +3 -3
- package/esm/styles.css +37 -14
- package/esm/svelte/CalmLensAsset.svelte +1 -1
- 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/test-inputs.d.ts +1 -1
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +18 -21
- package/esm/testing.js +93 -141
- package/esm/{ui-B98AucZA.js → ui-BBDJJkFL.js} +7 -5
- package/esm/{ui-CcuGKTcL.d.ts → ui-BfJNO3c6.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 +30 -19
- 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/cjs/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-DXAs8mcx.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-BfJNO3c6.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/cjs/ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ui = require("./ui-
|
|
3
|
-
const require_UploadController = require("./UploadController-
|
|
4
|
-
const require_Core = require("./Core-
|
|
2
|
+
const require_ui = require("./ui-CW8BqtZk.js");
|
|
3
|
+
const require_UploadController = require("./UploadController-C8GPbDKI.js");
|
|
4
|
+
const require_Core = require("./Core-D-1KCqT7.js");
|
|
5
5
|
exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
|
|
6
6
|
exports.ASSET_VIEWERS = require_ui.ASSET_VIEWERS;
|
|
7
7
|
exports.AssetSession = require_Core.AssetSession;
|
|
@@ -48,3 +48,4 @@ exports.resolveMessages = require_Core.resolveMessages;
|
|
|
48
48
|
exports.resolveTheme = require_Core.resolveTheme;
|
|
49
49
|
exports.resolveViewerMessages = require_ui.resolveViewerMessages;
|
|
50
50
|
exports.spreadsheetColumnIndex = require_ui.spreadsheetColumnIndex;
|
|
51
|
+
exports.withProvidedOptions = require_UploadController.withProvidedOptions;
|
package/cjs/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, en as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-HUERg5hI.js";
|
|
2
|
+
import "./index-Ck7x1YjM.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-DXAs8mcx.js";
|
|
4
|
+
import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-D4sEmd0X.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-BfJNO3c6.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/cjs/vue.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ui = require("./ui-
|
|
3
|
-
const require_UploadController = require("./UploadController-
|
|
4
|
-
const require_Core = require("./Core-
|
|
2
|
+
const require_ui = require("./ui-CW8BqtZk.js");
|
|
3
|
+
const require_UploadController = require("./UploadController-C8GPbDKI.js");
|
|
4
|
+
const require_Core = require("./Core-D-1KCqT7.js");
|
|
5
5
|
const require_FileIcons = require("./FileIcons-Ob003MdS.js");
|
|
6
|
-
const require_BrowserUpload = require("./BrowserUpload-
|
|
6
|
+
const require_BrowserUpload = require("./BrowserUpload-CTqIjCV5.js");
|
|
7
7
|
let vue = require("vue");
|
|
8
8
|
// src/viewers/Vue.ts
|
|
9
9
|
const optional$1 = (type) => ({
|
|
@@ -83,14 +83,30 @@ const subscribeSnapshot = (controller) => {
|
|
|
83
83
|
}, { immediate: true });
|
|
84
84
|
return snapshot;
|
|
85
85
|
};
|
|
86
|
+
const CALMLENS_PROVIDED_KEY = Symbol("calmlens");
|
|
87
|
+
/**
|
|
88
|
+
* Gives every `CalmLensUploader` and `useCalmLensUpload` in this component's descendants these
|
|
89
|
+
* upload options, such as `uploadPresetId` and `tokenUrl`, so they needn't be passed to each one.
|
|
90
|
+
* Call it in `setup`, or pass the app to provide them app-wide. An option a component sets itself
|
|
91
|
+
* wins, and a nested call adds to the outer one's options.
|
|
92
|
+
*/
|
|
93
|
+
const provideCalmLens = (options, app) => {
|
|
94
|
+
if (app) {
|
|
95
|
+
app.provide(CALMLENS_PROVIDED_KEY, options);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
(0, vue.provide)(CALMLENS_PROVIDED_KEY, require_UploadController.withProvidedOptions((0, vue.inject)(CALMLENS_PROVIDED_KEY, void 0), options));
|
|
99
|
+
};
|
|
86
100
|
/**
|
|
87
101
|
* Uploads files through an upload preset and keeps `snapshot` up to date as each one uploads and
|
|
88
102
|
* is checked. Use it to build your own upload UI; `CalmLensUploader` is built on it. Uploads
|
|
89
103
|
* still running when the component unmounts are cancelled.
|
|
90
104
|
*/
|
|
91
|
-
const useCalmLensUpload = (
|
|
92
|
-
const
|
|
93
|
-
|
|
105
|
+
const useCalmLensUpload = (own) => {
|
|
106
|
+
const provided = (0, vue.inject)(CALMLENS_PROVIDED_KEY, void 0);
|
|
107
|
+
const options = () => require_UploadController.withProvidedOptions(provided, (0, vue.toValue)(own));
|
|
108
|
+
const controller = require_UploadController.createUploadController(options());
|
|
109
|
+
(0, vue.watchEffect)(() => controller.setOptions(options()));
|
|
94
110
|
const snapshot = subscribeSnapshot(controller);
|
|
95
111
|
(0, vue.onScopeDispose)(() => controller.clear());
|
|
96
112
|
return {
|
|
@@ -258,17 +274,12 @@ const CalmLensUploader = (0, vue.defineComponent)({
|
|
|
258
274
|
(0, vue.h)("div", { class: "calmlens-upload__body" }, [
|
|
259
275
|
(0, vue.h)("span", { class: "calmlens-upload__name" }, item.file.name),
|
|
260
276
|
(0, vue.h)("span", { class: "calmlens-upload__size" }, itemView.size),
|
|
261
|
-
itemView.busy && (0, vue.h)("
|
|
277
|
+
itemView.busy && (0, vue.h)("progress", {
|
|
262
278
|
class: "calmlens-progress",
|
|
263
|
-
role: "progressbar",
|
|
264
279
|
"aria-label": itemView.message,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}, [(0, vue.h)("div", {
|
|
269
|
-
class: "calmlens-progress__bar",
|
|
270
|
-
style: itemView.progressPercent === void 0 ? void 0 : { width: `${itemView.progressPercent}%` }
|
|
271
|
-
})]),
|
|
280
|
+
max: 100,
|
|
281
|
+
value: itemView.progressPercent
|
|
282
|
+
}),
|
|
272
283
|
itemView.message && (0, vue.h)("p", {
|
|
273
284
|
class: "calmlens-upload__message",
|
|
274
285
|
role: "status"
|
|
@@ -502,7 +513,7 @@ const CalmLensAsset = (0, vue.defineComponent)({
|
|
|
502
513
|
"aria-busy": current.kind === "pending" ? "true" : void 0,
|
|
503
514
|
style: {
|
|
504
515
|
aspectRatio: ratio,
|
|
505
|
-
|
|
516
|
+
"--calmlens-average-color": state.value.info?.content?.preview?.averageColor ?? void 0,
|
|
506
517
|
"--calmlens-fit": props.fit
|
|
507
518
|
}
|
|
508
519
|
}, [
|
|
@@ -644,8 +655,10 @@ exports.isSpreadsheetFormat = require_Core.isSpreadsheetFormat;
|
|
|
644
655
|
exports.loadPdfJs = require_ui.loadPdfJs;
|
|
645
656
|
exports.parseSpreadsheetText = require_ui.parseSpreadsheetText;
|
|
646
657
|
exports.pickAssetSource = require_Core.pickAssetSource;
|
|
658
|
+
exports.provideCalmLens = provideCalmLens;
|
|
647
659
|
exports.resolveMessages = require_Core.resolveMessages;
|
|
648
660
|
exports.resolveTheme = require_Core.resolveTheme;
|
|
649
661
|
exports.resolveViewerMessages = require_ui.resolveViewerMessages;
|
|
650
662
|
exports.spreadsheetColumnIndex = require_ui.spreadsheetColumnIndex;
|
|
651
663
|
exports.useCalmLensUpload = useCalmLensUpload;
|
|
664
|
+
exports.withProvidedOptions = require_UploadController.withProvidedOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createUploadController$1 } from "./UploadController-
|
|
1
|
+
import { n as createUploadController$1 } from "./UploadController-Q7xTqh5w.js";
|
|
2
2
|
// src/ui/BrowserUpload.ts
|
|
3
3
|
/** Creates an upload queue for the browser components, such as one a form starts on submit. */
|
|
4
4
|
const createUploadController = (options) => createUploadController$1(options);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as UploadItem$1,
|
|
2
|
-
import {
|
|
1
|
+
import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-DXAs8mcx.js";
|
|
2
|
+
import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-BTciTpwB.js";
|
|
3
3
|
type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
|
|
4
4
|
type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
|
|
5
5
|
type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as RetrieveAssetOptions, M as CdnAssetUrlOptions, O as CalmLensAppClientOptions, Ot as RequestOptions, Qt as UploadedAsset, Zt as UploadPresetSubmitAssetOptions, qt as UploadAssetPartOptions } from "./CalmLensTypes-HUERg5hI.js";
|
|
2
2
|
declare const inspectSymbol: unique symbol;
|
|
3
|
-
/**
|
|
4
|
-
* The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
|
|
5
|
-
* with an upload token from your server when the preset requires one, and never holds an API
|
|
6
|
-
* key. It can upload (`assets.create`, `assets.classify`, `assets.uploadPart`) and check its own
|
|
7
|
-
* uploads (`assets.retrieve`). Every method throws `CalmLensError` on failure.
|
|
8
|
-
*/
|
|
9
3
|
declare class CalmLensAppClient {
|
|
10
4
|
#private;
|
|
11
5
|
constructor(options: CalmLensAppClientOptions);
|
|
@@ -35,16 +29,16 @@ declare class CalmLensAppClient {
|
|
|
35
29
|
/** Uploads through the client's upload preset and checks those uploads. */
|
|
36
30
|
get assets(): {
|
|
37
31
|
/** Uploads a file and returns without waiting for its decision. */
|
|
38
|
-
create: (options: UploadPresetSubmitAssetOptions) => Promise<UploadedAsset>;
|
|
32
|
+
create: (options: UploadPresetSubmitAssetOptions, requestOptions?: RequestOptions) => Promise<UploadedAsset>;
|
|
39
33
|
/** Uploads a file and waits for its moderation decision. */
|
|
40
|
-
classify: (options: UploadPresetSubmitAssetOptions) => Promise<UploadedAsset>;
|
|
34
|
+
classify: (options: UploadPresetSubmitAssetOptions, requestOptions?: RequestOptions) => Promise<UploadedAsset>;
|
|
41
35
|
/**
|
|
42
36
|
* Uploads the next part of a multipart upload this client started. The upload's wait
|
|
43
37
|
* mode, chosen when it started, applies when the final part arrives.
|
|
44
38
|
*/
|
|
45
|
-
uploadPart: (partOptions: UploadAssetPartOptions) => Promise<UploadedAsset>;
|
|
39
|
+
uploadPart: (partOptions: UploadAssetPartOptions, requestOptions?: RequestOptions) => Promise<UploadedAsset>;
|
|
46
40
|
/** Checks an upload this client made. `status` is present when the preset shows decisions. */
|
|
47
|
-
retrieve: (options: RetrieveAssetOptions) => Promise<UploadedAsset>;
|
|
41
|
+
retrieve: (options: RetrieveAssetOptions, requestOptions?: RequestOptions) => Promise<UploadedAsset>;
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
44
|
export { CalmLensAppClient as t };
|
|
@@ -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 { S as validateAppClientOptions, ct as invalidConfig, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, st as invalidArgument, u as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-BmV8QD32.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-CEwNbpEz.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. */
|
|
@@ -13,6 +13,12 @@ const checked = (operation, options) => {
|
|
|
13
13
|
* key. It can upload (`assets.create`, `assets.classify`, `assets.uploadPart`) and check its own
|
|
14
14
|
* uploads (`assets.retrieve`). Every method throws `CalmLensError` on failure.
|
|
15
15
|
*/
|
|
16
|
+
/** An upload's request options for reading it back: no key or body of the upload's own. */
|
|
17
|
+
const readOptions = (requestOptions) => {
|
|
18
|
+
if (!requestOptions) return void 0;
|
|
19
|
+
const { idempotencyKey: _key, extraBody: _body, ...read } = requestOptions;
|
|
20
|
+
return read;
|
|
21
|
+
};
|
|
16
22
|
var CalmLensAppClient = class {
|
|
17
23
|
#uploadPresetId;
|
|
18
24
|
#token;
|
|
@@ -55,26 +61,27 @@ var CalmLensAppClient = class {
|
|
|
55
61
|
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
56
62
|
}
|
|
57
63
|
/** Uploads with a new token, kept for the upload's parts and status checks. */
|
|
58
|
-
async submit(options, wait) {
|
|
64
|
+
async submit(operation, options, wait, requestOptions) {
|
|
65
|
+
const connection = this.#connection.forCall(operation, requestOptions);
|
|
59
66
|
if (!options || typeof options !== "object") throw invalidArgument("Upload options are required");
|
|
60
67
|
if (!("content" in options) && !("part" in options)) throw invalidArgument("Uploads through an upload preset need content or a part");
|
|
61
|
-
prepareSubmitAssetOptions(options, {
|
|
62
|
-
deferUploadChecks:
|
|
63
|
-
partSizeBytes:
|
|
68
|
+
const prepared = prepareSubmitAssetOptions(options, {
|
|
69
|
+
deferUploadChecks: connection.deferUploadChecks,
|
|
70
|
+
partSizeBytes: connection.partSizeBytes
|
|
64
71
|
});
|
|
65
72
|
const token = await this.newUploadToken();
|
|
66
|
-
if ("content" in
|
|
67
|
-
const data = await
|
|
73
|
+
if ("content" in prepared && splitsIntoParts(prepared.content, connection.partSizeBytes)) {
|
|
74
|
+
const data = await connection.submitInParts(this.uploadsPath, prepared, wait, {
|
|
68
75
|
authHeaders: token ? { Authorization: `Bearer ${token}` } : {},
|
|
69
76
|
partPath: (assetId) => `${this.uploadsPath}/${encodeURIComponent(assetId)}/part`,
|
|
70
77
|
onStarted: (assetId) => {
|
|
71
78
|
if (token) this.#uploadTokens.set(assetId, token);
|
|
72
79
|
},
|
|
73
|
-
retrieve: (assetId) => this.assets.retrieve({ assetId })
|
|
80
|
+
retrieve: (assetId) => this.assets.retrieve({ assetId }, readOptions(requestOptions))
|
|
74
81
|
});
|
|
75
82
|
return expectUploadedAsset(data);
|
|
76
83
|
}
|
|
77
|
-
const data = await
|
|
84
|
+
const data = await connection.submitUpload(this.uploadsPath, prepared, wait, token ? { Authorization: `Bearer ${token}` } : {});
|
|
78
85
|
const uploaded = expectUploadedAsset(data);
|
|
79
86
|
if (token) this.#uploadTokens.set(uploaded.id, token);
|
|
80
87
|
return uploaded;
|
|
@@ -99,24 +106,24 @@ getAssetUrl: (urlOptions) => {
|
|
|
99
106
|
get assets() {
|
|
100
107
|
return {
|
|
101
108
|
/** Uploads a file and returns without waiting for its decision. */
|
|
102
|
-
create: async (options) => this.submit(checked("assets.create", options), false),
|
|
109
|
+
create: async (options, requestOptions) => this.submit("assets.create", checked("assets.create", options), false, requestOptions),
|
|
103
110
|
/** Uploads a file and waits for its moderation decision. */
|
|
104
|
-
classify: async (options) => this.submit(checked("assets.classify", options), true),
|
|
111
|
+
classify: async (options, requestOptions) => this.submit("assets.classify", checked("assets.classify", options), true, requestOptions),
|
|
105
112
|
/**
|
|
106
113
|
* Uploads the next part of a multipart upload this client started. The upload's wait
|
|
107
114
|
* mode, chosen when it started, applies when the final part arrives.
|
|
108
115
|
*/
|
|
109
|
-
uploadPart: async (partOptions) => {
|
|
116
|
+
uploadPart: async (partOptions, requestOptions) => {
|
|
110
117
|
const { assetId, ...options } = checked("assets.uploadPart", partOptions);
|
|
111
118
|
const encodedAssetId = encodePathSegment(assetId, "Asset ID");
|
|
112
|
-
const data = await this.#connection.uploadPart(`${this.uploadsPath}/${encodedAssetId}/part`, options, this.authHeaders(assetId));
|
|
119
|
+
const data = await this.#connection.forCall("assets.uploadPart", requestOptions).uploadPart(`${this.uploadsPath}/${encodedAssetId}/part`, options, this.authHeaders(assetId));
|
|
113
120
|
return expectUploadedAsset(data);
|
|
114
121
|
},
|
|
115
122
|
/** Checks an upload this client made. `status` is present when the preset shows decisions. */
|
|
116
|
-
retrieve: async (options) => {
|
|
123
|
+
retrieve: async (options, requestOptions) => {
|
|
117
124
|
const { assetId } = checked("assets.retrieve", options);
|
|
118
125
|
const encodedAssetId = encodePathSegment(assetId, "Asset ID");
|
|
119
|
-
const data = await this.#connection.json("GET", `${this.uploadsPath}/${encodedAssetId}`, { headers: this.authHeaders(assetId) });
|
|
126
|
+
const data = await this.#connection.forCall("assets.retrieve", requestOptions).json("GET", `${this.uploadsPath}/${encodedAssetId}`, { headers: this.authHeaders(assetId) });
|
|
120
127
|
return expectUploadedAsset(data);
|
|
121
128
|
}
|
|
122
129
|
};
|