@anvilkit/plugin-asset-manager 0.1.8 → 0.1.10
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 +96 -3
- package/dist/adapters/data-url.d.cts +1 -0
- package/dist/adapters/data-url.d.cts.map +1 -1
- package/dist/adapters/data-url.d.ts +1 -0
- package/dist/adapters/data-url.d.ts.map +1 -1
- package/dist/adapters/s3-multipart.cjs +425 -0
- package/dist/adapters/s3-multipart.d.cts +43 -0
- package/dist/adapters/s3-multipart.d.cts.map +1 -0
- package/dist/adapters/s3-multipart.d.ts +43 -0
- package/dist/adapters/s3-multipart.d.ts.map +1 -0
- package/dist/adapters/s3-multipart.js +387 -0
- package/dist/adapters/s3-presigned.d.cts +2 -0
- package/dist/adapters/s3-presigned.d.cts.map +1 -1
- package/dist/adapters/s3-presigned.d.ts +2 -0
- package/dist/adapters/s3-presigned.d.ts.map +1 -1
- package/dist/i18n/provider.d.cts +1 -0
- package/dist/i18n/provider.d.cts.map +1 -1
- package/dist/i18n/provider.d.ts +1 -0
- package/dist/i18n/provider.d.ts.map +1 -1
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +9 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/plugin.cjs +152 -12
- package/dist/plugin.d.cts +49 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +49 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +147 -13
- package/dist/sources/composite-source.cjs +3 -0
- package/dist/sources/composite-source.d.cts.map +1 -1
- package/dist/sources/composite-source.d.ts.map +1 -1
- package/dist/sources/composite-source.js +3 -0
- package/dist/sources/federated-search.cjs +45 -7
- package/dist/sources/federated-search.d.cts.map +1 -1
- package/dist/sources/federated-search.d.ts.map +1 -1
- package/dist/sources/federated-search.js +45 -7
- package/dist/sources/provider.d.cts +5 -0
- package/dist/sources/provider.d.cts.map +1 -1
- package/dist/sources/provider.d.ts +5 -0
- package/dist/sources/provider.d.ts.map +1 -1
- package/dist/sources/unsplash/index.d.cts +1 -0
- package/dist/sources/unsplash/index.d.cts.map +1 -1
- package/dist/sources/unsplash/index.d.ts +1 -0
- package/dist/sources/unsplash/index.d.ts.map +1 -1
- package/dist/testing/index.d.cts +4 -0
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/types/categories.d.cts +3 -0
- package/dist/types/categories.d.cts.map +1 -1
- package/dist/types/categories.d.ts +3 -0
- package/dist/types/categories.d.ts.map +1 -1
- package/dist/types/data-source.d.cts +9 -0
- package/dist/types/data-source.d.cts.map +1 -1
- package/dist/types/data-source.d.ts +9 -0
- package/dist/types/data-source.d.ts.map +1 -1
- package/dist/types/filter.d.cts +11 -0
- package/dist/types/filter.d.cts.map +1 -1
- package/dist/types/filter.d.ts +11 -0
- package/dist/types/filter.d.ts.map +1 -1
- package/dist/types/folders.d.cts +2 -0
- package/dist/types/folders.d.cts.map +1 -1
- package/dist/types/folders.d.ts +2 -0
- package/dist/types/folders.d.ts.map +1 -1
- package/dist/types/options.d.cts +57 -1
- package/dist/types/options.d.cts.map +1 -1
- package/dist/types/options.d.ts +57 -1
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/resumable.cjs +42 -0
- package/dist/types/resumable.d.cts +204 -0
- package/dist/types/resumable.d.cts.map +1 -0
- package/dist/types/resumable.d.ts +204 -0
- package/dist/types/resumable.d.ts.map +1 -0
- package/dist/types/resumable.js +4 -0
- package/dist/types/transform.cjs +18 -0
- package/dist/types/transform.d.cts +45 -0
- package/dist/types/transform.d.cts.map +1 -0
- package/dist/types/transform.d.ts +45 -0
- package/dist/types/transform.d.ts.map +1 -0
- package/dist/types/transform.js +1 -0
- package/dist/types/types.d.cts +17 -0
- package/dist/types/types.d.cts.map +1 -1
- package/dist/types/types.d.ts +17 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/unsplash.d.cts +2 -0
- package/dist/types/unsplash.d.cts.map +1 -1
- package/dist/types/unsplash.d.ts +2 -0
- package/dist/types/unsplash.d.ts.map +1 -1
- package/dist/ui/AssetBrowser.d.cts +3 -1
- package/dist/ui/AssetBrowser.d.cts.map +1 -1
- package/dist/ui/AssetBrowser.d.ts +3 -1
- package/dist/ui/AssetBrowser.d.ts.map +1 -1
- package/dist/ui/AssetCommandPalette.d.cts +4 -1
- package/dist/ui/AssetCommandPalette.d.cts.map +1 -1
- package/dist/ui/AssetCommandPalette.d.ts +4 -1
- package/dist/ui/AssetCommandPalette.d.ts.map +1 -1
- package/dist/ui/AssetManagerUI.cjs +3 -1
- package/dist/ui/AssetManagerUI.d.cts +11 -2
- package/dist/ui/AssetManagerUI.d.cts.map +1 -1
- package/dist/ui/AssetManagerUI.d.ts +11 -2
- package/dist/ui/AssetManagerUI.d.ts.map +1 -1
- package/dist/ui/AssetManagerUI.js +3 -1
- package/dist/ui/DeleteAssetDialog.d.cts +4 -1
- package/dist/ui/DeleteAssetDialog.d.cts.map +1 -1
- package/dist/ui/DeleteAssetDialog.d.ts +4 -1
- package/dist/ui/DeleteAssetDialog.d.ts.map +1 -1
- package/dist/ui/DeleteFolderDialog.d.cts +4 -1
- package/dist/ui/DeleteFolderDialog.d.cts.map +1 -1
- package/dist/ui/DeleteFolderDialog.d.ts +4 -1
- package/dist/ui/DeleteFolderDialog.d.ts.map +1 -1
- package/dist/ui/EmptyFolderState.d.cts +4 -1
- package/dist/ui/EmptyFolderState.d.cts.map +1 -1
- package/dist/ui/EmptyFolderState.d.ts +4 -1
- package/dist/ui/EmptyFolderState.d.ts.map +1 -1
- package/dist/ui/FolderBreadcrumb.d.cts +4 -1
- package/dist/ui/FolderBreadcrumb.d.cts.map +1 -1
- package/dist/ui/FolderBreadcrumb.d.ts +4 -1
- package/dist/ui/FolderBreadcrumb.d.ts.map +1 -1
- package/dist/ui/FolderNameDialog.d.cts +3 -1
- package/dist/ui/FolderNameDialog.d.cts.map +1 -1
- package/dist/ui/FolderNameDialog.d.ts +3 -1
- package/dist/ui/FolderNameDialog.d.ts.map +1 -1
- package/dist/ui/FolderTree.d.cts +4 -1
- package/dist/ui/FolderTree.d.cts.map +1 -1
- package/dist/ui/FolderTree.d.ts +4 -1
- package/dist/ui/FolderTree.d.ts.map +1 -1
- package/dist/ui/MetadataPanel.d.cts +4 -1
- package/dist/ui/MetadataPanel.d.cts.map +1 -1
- package/dist/ui/MetadataPanel.d.ts +4 -1
- package/dist/ui/MetadataPanel.d.ts.map +1 -1
- package/dist/ui/MoveTargetPicker.d.cts +3 -1
- package/dist/ui/MoveTargetPicker.d.cts.map +1 -1
- package/dist/ui/MoveTargetPicker.d.ts +3 -1
- package/dist/ui/MoveTargetPicker.d.ts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.cjs +7 -2
- package/dist/ui/ReplaceAssetDialog.d.cts +5 -2
- package/dist/ui/ReplaceAssetDialog.d.cts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.d.ts +5 -2
- package/dist/ui/ReplaceAssetDialog.d.ts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.js +7 -2
- package/dist/ui/UnsplashPanel.d.cts +4 -1
- package/dist/ui/UnsplashPanel.d.cts.map +1 -1
- package/dist/ui/UnsplashPanel.d.ts +4 -1
- package/dist/ui/UnsplashPanel.d.ts.map +1 -1
- package/dist/ui/UploadButton.cjs +7 -2
- package/dist/ui/UploadButton.d.cts +6 -2
- package/dist/ui/UploadButton.d.cts.map +1 -1
- package/dist/ui/UploadButton.d.ts +6 -2
- package/dist/ui/UploadButton.d.ts.map +1 -1
- package/dist/ui/UploadButton.js +7 -2
- package/dist/utils/asset-reference.cjs +87 -4
- package/dist/utils/asset-reference.d.cts +30 -6
- package/dist/utils/asset-reference.d.cts.map +1 -1
- package/dist/utils/asset-reference.d.ts +30 -6
- package/dist/utils/asset-reference.d.ts.map +1 -1
- package/dist/utils/asset-reference.js +83 -3
- package/dist/utils/csp.cjs +16 -0
- package/dist/utils/csp.d.cts +23 -0
- package/dist/utils/csp.d.cts.map +1 -1
- package/dist/utils/csp.d.ts +23 -0
- package/dist/utils/csp.d.ts.map +1 -1
- package/dist/utils/csp.js +16 -0
- package/dist/utils/data-source.cjs +19 -5
- package/dist/utils/data-source.d.cts +5 -1
- package/dist/utils/data-source.d.cts.map +1 -1
- package/dist/utils/data-source.d.ts +5 -1
- package/dist/utils/data-source.d.ts.map +1 -1
- package/dist/utils/data-source.js +19 -5
- package/dist/utils/errors.d.cts +5 -0
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/query-param-transform.cjs +101 -0
- package/dist/utils/query-param-transform.d.cts +46 -0
- package/dist/utils/query-param-transform.d.cts.map +1 -0
- package/dist/utils/query-param-transform.d.ts +46 -0
- package/dist/utils/query-param-transform.d.ts.map +1 -0
- package/dist/utils/query-param-transform.js +60 -0
- package/dist/utils/registry.cjs +3 -0
- package/dist/utils/registry.d.cts +8 -0
- package/dist/utils/registry.d.cts.map +1 -1
- package/dist/utils/registry.d.ts +8 -0
- package/dist/utils/registry.d.ts.map +1 -1
- package/dist/utils/registry.js +3 -0
- package/dist/utils/resolver.cjs +19 -11
- package/dist/utils/resolver.d.cts +24 -0
- package/dist/utils/resolver.d.cts.map +1 -1
- package/dist/utils/resolver.d.ts +24 -0
- package/dist/utils/resolver.d.ts.map +1 -1
- package/dist/utils/resolver.js +19 -11
- package/dist/utils/retry.d.cts +2 -0
- package/dist/utils/retry.d.cts.map +1 -1
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/run-resumable-upload.cjs +160 -0
- package/dist/utils/run-resumable-upload.d.cts +56 -0
- package/dist/utils/run-resumable-upload.d.cts.map +1 -0
- package/dist/utils/run-resumable-upload.d.ts +56 -0
- package/dist/utils/run-resumable-upload.d.ts.map +1 -0
- package/dist/utils/run-resumable-upload.js +122 -0
- package/dist/utils/sniff-file-type.cjs +209 -0
- package/dist/utils/sniff-file-type.d.cts +25 -0
- package/dist/utils/sniff-file-type.d.cts.map +1 -0
- package/dist/utils/sniff-file-type.d.ts +25 -0
- package/dist/utils/sniff-file-type.d.ts.map +1 -0
- package/dist/utils/sniff-file-type.js +164 -0
- package/dist/utils/studio-asset-source.cjs +11 -6
- package/dist/utils/studio-asset-source.d.cts +5 -1
- package/dist/utils/studio-asset-source.d.cts.map +1 -1
- package/dist/utils/studio-asset-source.d.ts +5 -1
- package/dist/utils/studio-asset-source.d.ts.map +1 -1
- package/dist/utils/studio-asset-source.js +11 -6
- package/dist/utils/upload-session-store.cjs +125 -0
- package/dist/utils/upload-session-store.d.cts +55 -0
- package/dist/utils/upload-session-store.d.cts.map +1 -0
- package/dist/utils/upload-session-store.d.ts +55 -0
- package/dist/utils/upload-session-store.d.ts.map +1 -0
- package/dist/utils/upload-session-store.js +84 -0
- package/dist/utils/validate-upload-result.cjs +9 -1
- package/dist/utils/validate-upload-result.d.cts +1 -0
- package/dist/utils/validate-upload-result.d.cts.map +1 -1
- package/dist/utils/validate-upload-result.d.ts +1 -0
- package/dist/utils/validate-upload-result.d.ts.map +1 -1
- package/dist/utils/validate-upload-result.js +9 -1
- package/dist/version.cjs +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.cts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/meta/config.json +1 -1
- package/package.json +42 -12
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { UploadResult } from "../types/types.js";
|
|
3
|
+
/** Props for the asset metadata editing dialog. */
|
|
2
4
|
export interface MetadataPanelProps {
|
|
3
5
|
/**
|
|
4
6
|
* Asset whose metadata is being edited. When `null`, the panel is
|
|
@@ -17,5 +19,6 @@ export interface MetadataPanelProps {
|
|
|
17
19
|
}) => void | Promise<void>;
|
|
18
20
|
readonly onCancel: () => void;
|
|
19
21
|
}
|
|
20
|
-
|
|
22
|
+
/** Dialog panel for editing an asset name and tag metadata. */
|
|
23
|
+
export declare function MetadataPanel({ asset, onCancel, onConfirm, }: MetadataPanelProps): React.JSX.Element;
|
|
21
24
|
//# sourceMappingURL=MetadataPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataPanel.d.ts","sourceRoot":"","sources":["../../src/ui/MetadataPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetadataPanel.d.ts","sourceRoot":"","sources":["../../src/ui/MetadataPanel.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,mDAAmD;AACnD,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,CACnB,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,KAC7D,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,SAAS,GACT,EAAE,kBAAkB,qBA2JpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetFolder } from "../types/folders.js";
|
|
2
3
|
/**
|
|
3
4
|
* Keyboard-accessible move-target picker — the a11y fallback for drag-to-folder.
|
|
@@ -12,5 +13,6 @@ export interface MoveTargetPickerProps {
|
|
|
12
13
|
readonly onPick: (folderId: string | null) => void | Promise<void>;
|
|
13
14
|
readonly rootLabel?: string;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
/** Dialog for choosing the destination folder for an asset or folder move. */
|
|
17
|
+
export declare function MoveTargetPicker({ open, onOpenChange, folders, onPick, rootLabel, }: MoveTargetPickerProps): React.JSX.Element;
|
|
16
18
|
//# sourceMappingURL=MoveTargetPicker.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoveTargetPicker.d.cts","sourceRoot":"","sources":["../../src/ui/MoveTargetPicker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MoveTargetPicker.d.cts","sourceRoot":"","sources":["../../src/ui/MoveTargetPicker.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,EAChC,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,SAAS,GACT,EAAE,qBAAqB,qBAgEvB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetFolder } from "../types/folders.js";
|
|
2
3
|
/**
|
|
3
4
|
* Keyboard-accessible move-target picker — the a11y fallback for drag-to-folder.
|
|
@@ -12,5 +13,6 @@ export interface MoveTargetPickerProps {
|
|
|
12
13
|
readonly onPick: (folderId: string | null) => void | Promise<void>;
|
|
13
14
|
readonly rootLabel?: string;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
/** Dialog for choosing the destination folder for an asset or folder move. */
|
|
17
|
+
export declare function MoveTargetPicker({ open, onOpenChange, folders, onPick, rootLabel, }: MoveTargetPickerProps): React.JSX.Element;
|
|
16
18
|
//# sourceMappingURL=MoveTargetPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoveTargetPicker.d.ts","sourceRoot":"","sources":["../../src/ui/MoveTargetPicker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MoveTargetPicker.d.ts","sourceRoot":"","sources":["../../src/ui/MoveTargetPicker.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,EAChC,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,SAAS,GACT,EAAE,qBAAqB,qBAgEvB"}
|
|
@@ -36,13 +36,17 @@ const button_namespaceObject = require("@anvilkit/ui/button");
|
|
|
36
36
|
const dialog_namespaceObject = require("@anvilkit/ui/dialog");
|
|
37
37
|
const external_react_namespaceObject = require("react");
|
|
38
38
|
const external_plugin_cjs_namespaceObject = require("../plugin.cjs");
|
|
39
|
-
function ReplaceAssetDialog({ acceptedMimeTypes, asset, maxFileSize, onCancel, onConfirm }) {
|
|
39
|
+
function ReplaceAssetDialog({ acceptedFileExtensions, acceptedMimeTypes, asset, maxFileSize, onCancel, onConfirm }) {
|
|
40
40
|
const msg = (0, i18n_namespaceObject.useMsg)();
|
|
41
41
|
const inputRef = external_react_namespaceObject.useRef(null);
|
|
42
42
|
const [selectedFile, setSelectedFile] = external_react_namespaceObject.useState(null);
|
|
43
43
|
const [error, setError] = external_react_namespaceObject.useState(null);
|
|
44
44
|
const [busy, setBusy] = external_react_namespaceObject.useState(false);
|
|
45
|
-
const acceptAttr = external_react_namespaceObject.useMemo(()=>
|
|
45
|
+
const acceptAttr = external_react_namespaceObject.useMemo(()=>[
|
|
46
|
+
...acceptedMimeTypes ?? [],
|
|
47
|
+
...acceptedFileExtensions ?? []
|
|
48
|
+
].join(",") || void 0, [
|
|
49
|
+
acceptedFileExtensions,
|
|
46
50
|
acceptedMimeTypes
|
|
47
51
|
]);
|
|
48
52
|
function resetPicker() {
|
|
@@ -55,6 +59,7 @@ function ReplaceAssetDialog({ acceptedMimeTypes, asset, maxFileSize, onCancel, o
|
|
|
55
59
|
if (!file) return;
|
|
56
60
|
try {
|
|
57
61
|
(0, external_plugin_cjs_namespaceObject.validateSelectedFile)(file, {
|
|
62
|
+
acceptedFileExtensions,
|
|
58
63
|
acceptedMimeTypes,
|
|
59
64
|
maxFileSize
|
|
60
65
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetManagerOptions } from "../types/options.js";
|
|
2
3
|
import type { UploadResult } from "../types/types.js";
|
|
3
|
-
|
|
4
|
+
/** Props for the replace-asset file selection dialog. */
|
|
5
|
+
export interface ReplaceAssetDialogProps extends Pick<AssetManagerOptions, "acceptedFileExtensions" | "acceptedMimeTypes" | "maxFileSize"> {
|
|
4
6
|
/** Asset to replace. `null` closes the dialog. */
|
|
5
7
|
readonly asset: UploadResult | null;
|
|
6
8
|
/**
|
|
@@ -11,5 +13,6 @@ export interface ReplaceAssetDialogProps extends Pick<AssetManagerOptions, "acce
|
|
|
11
13
|
readonly onConfirm: (asset: UploadResult, file: File) => void | Promise<void>;
|
|
12
14
|
readonly onCancel: () => void;
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
/** Dialog that validates and confirms selecting a replacement file for an asset. */
|
|
17
|
+
export declare function ReplaceAssetDialog({ acceptedFileExtensions, acceptedMimeTypes, asset, maxFileSize, onCancel, onConfirm, }: ReplaceAssetDialogProps): React.JSX.Element;
|
|
15
18
|
//# sourceMappingURL=ReplaceAssetDialog.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaceAssetDialog.d.cts","sourceRoot":"","sources":["../../src/ui/ReplaceAssetDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReplaceAssetDialog.d.cts","sourceRoot":"","sources":["../../src/ui/ReplaceAssetDialog.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,yDAAyD;AACzD,MAAM,WAAW,uBAChB,SAAQ,IAAI,CACX,mBAAmB,EACnB,wBAAwB,GAAG,mBAAmB,GAAG,aAAa,CAC9D;IACD,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,EAClC,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,GACT,EAAE,uBAAuB,qBA8IzB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetManagerOptions } from "../types/options.js";
|
|
2
3
|
import type { UploadResult } from "../types/types.js";
|
|
3
|
-
|
|
4
|
+
/** Props for the replace-asset file selection dialog. */
|
|
5
|
+
export interface ReplaceAssetDialogProps extends Pick<AssetManagerOptions, "acceptedFileExtensions" | "acceptedMimeTypes" | "maxFileSize"> {
|
|
4
6
|
/** Asset to replace. `null` closes the dialog. */
|
|
5
7
|
readonly asset: UploadResult | null;
|
|
6
8
|
/**
|
|
@@ -11,5 +13,6 @@ export interface ReplaceAssetDialogProps extends Pick<AssetManagerOptions, "acce
|
|
|
11
13
|
readonly onConfirm: (asset: UploadResult, file: File) => void | Promise<void>;
|
|
12
14
|
readonly onCancel: () => void;
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
/** Dialog that validates and confirms selecting a replacement file for an asset. */
|
|
17
|
+
export declare function ReplaceAssetDialog({ acceptedFileExtensions, acceptedMimeTypes, asset, maxFileSize, onCancel, onConfirm, }: ReplaceAssetDialogProps): React.JSX.Element;
|
|
15
18
|
//# sourceMappingURL=ReplaceAssetDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaceAssetDialog.d.ts","sourceRoot":"","sources":["../../src/ui/ReplaceAssetDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReplaceAssetDialog.d.ts","sourceRoot":"","sources":["../../src/ui/ReplaceAssetDialog.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,yDAAyD;AACzD,MAAM,WAAW,uBAChB,SAAQ,IAAI,CACX,mBAAmB,EACnB,wBAAwB,GAAG,mBAAmB,GAAG,aAAa,CAC9D;IACD,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,EAClC,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,GACT,EAAE,uBAAuB,qBA8IzB"}
|
|
@@ -4,13 +4,17 @@ import { Button } from "@anvilkit/ui/button";
|
|
|
4
4
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@anvilkit/ui/dialog";
|
|
5
5
|
import { validateSelectedFile } from "../plugin.js";
|
|
6
6
|
import * as __rspack_external_react from "react";
|
|
7
|
-
function ReplaceAssetDialog({ acceptedMimeTypes, asset, maxFileSize, onCancel, onConfirm }) {
|
|
7
|
+
function ReplaceAssetDialog({ acceptedFileExtensions, acceptedMimeTypes, asset, maxFileSize, onCancel, onConfirm }) {
|
|
8
8
|
const msg = useMsg();
|
|
9
9
|
const inputRef = __rspack_external_react.useRef(null);
|
|
10
10
|
const [selectedFile, setSelectedFile] = __rspack_external_react.useState(null);
|
|
11
11
|
const [error, setError] = __rspack_external_react.useState(null);
|
|
12
12
|
const [busy, setBusy] = __rspack_external_react.useState(false);
|
|
13
|
-
const acceptAttr = __rspack_external_react.useMemo(()=>
|
|
13
|
+
const acceptAttr = __rspack_external_react.useMemo(()=>[
|
|
14
|
+
...acceptedMimeTypes ?? [],
|
|
15
|
+
...acceptedFileExtensions ?? []
|
|
16
|
+
].join(",") || void 0, [
|
|
17
|
+
acceptedFileExtensions,
|
|
14
18
|
acceptedMimeTypes
|
|
15
19
|
]);
|
|
16
20
|
function resetPicker() {
|
|
@@ -23,6 +27,7 @@ function ReplaceAssetDialog({ acceptedMimeTypes, asset, maxFileSize, onCancel, o
|
|
|
23
27
|
if (!file) return;
|
|
24
28
|
try {
|
|
25
29
|
validateSelectedFile(file, {
|
|
30
|
+
acceptedFileExtensions,
|
|
26
31
|
acceptedMimeTypes,
|
|
27
32
|
maxFileSize
|
|
28
33
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetTheme } from "../sources/provider.js";
|
|
2
3
|
/** A browsed Unsplash result + the attribution the tile must show. */
|
|
3
4
|
export interface UnsplashResult {
|
|
@@ -8,6 +9,7 @@ export interface UnsplashResult {
|
|
|
8
9
|
readonly unsplashUrl: string;
|
|
9
10
|
}
|
|
10
11
|
export type UnsplashPanelStatus = "idle" | "loading" | "rateLimited" | "error" | "disabled";
|
|
12
|
+
/** Props for the Unsplash browsing panel. */
|
|
11
13
|
export interface UnsplashPanelProps {
|
|
12
14
|
readonly themes: readonly AssetTheme[];
|
|
13
15
|
readonly activeThemeId?: string;
|
|
@@ -24,5 +26,6 @@ export interface UnsplashPanelProps {
|
|
|
24
26
|
/** Skeleton tile count while loading the first page. */
|
|
25
27
|
readonly skeletonCount?: number;
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
/** Browse, search, and pick assets from the configured Unsplash provider. */
|
|
30
|
+
export declare function UnsplashPanel({ themes, activeThemeId, onThemeChange, query, onQueryChange, results, status, onPick, onLoadMore, themeLabel, skeletonCount, }: UnsplashPanelProps): React.JSX.Element;
|
|
28
31
|
//# sourceMappingURL=UnsplashPanel.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsplashPanel.d.cts","sourceRoot":"","sources":["../../src/ui/UnsplashPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UnsplashPanel.d.cts","sourceRoot":"","sources":["../../src/ui/UnsplashPanel.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,GAC5B,MAAM,GACN,SAAS,GACT,aAAa,GACb,OAAO,GACP,UAAU,CAAC;AAEd,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,wDAAwD;IACxD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,EAC7B,MAAM,EACN,aAAa,EACb,aAAa,EACb,KAAK,EACL,aAAa,EACb,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,EACV,aAAkB,GAClB,EAAE,kBAAkB,qBA8JpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetTheme } from "../sources/provider.js";
|
|
2
3
|
/** A browsed Unsplash result + the attribution the tile must show. */
|
|
3
4
|
export interface UnsplashResult {
|
|
@@ -8,6 +9,7 @@ export interface UnsplashResult {
|
|
|
8
9
|
readonly unsplashUrl: string;
|
|
9
10
|
}
|
|
10
11
|
export type UnsplashPanelStatus = "idle" | "loading" | "rateLimited" | "error" | "disabled";
|
|
12
|
+
/** Props for the Unsplash browsing panel. */
|
|
11
13
|
export interface UnsplashPanelProps {
|
|
12
14
|
readonly themes: readonly AssetTheme[];
|
|
13
15
|
readonly activeThemeId?: string;
|
|
@@ -24,5 +26,6 @@ export interface UnsplashPanelProps {
|
|
|
24
26
|
/** Skeleton tile count while loading the first page. */
|
|
25
27
|
readonly skeletonCount?: number;
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
/** Browse, search, and pick assets from the configured Unsplash provider. */
|
|
30
|
+
export declare function UnsplashPanel({ themes, activeThemeId, onThemeChange, query, onQueryChange, results, status, onPick, onLoadMore, themeLabel, skeletonCount, }: UnsplashPanelProps): React.JSX.Element;
|
|
28
31
|
//# sourceMappingURL=UnsplashPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsplashPanel.d.ts","sourceRoot":"","sources":["../../src/ui/UnsplashPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UnsplashPanel.d.ts","sourceRoot":"","sources":["../../src/ui/UnsplashPanel.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,GAC5B,MAAM,GACN,SAAS,GACT,aAAa,GACb,OAAO,GACP,UAAU,CAAC;AAEd,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,wDAAwD;IACxD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,EAC7B,MAAM,EACN,aAAa,EACb,aAAa,EACb,KAAK,EACL,aAAa,EACb,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,EACV,aAAkB,GAClB,EAAE,kBAAkB,qBA8JpB"}
|
package/dist/ui/UploadButton.cjs
CHANGED
|
@@ -41,7 +41,7 @@ function handleDragOver(event) {
|
|
|
41
41
|
event.stopPropagation();
|
|
42
42
|
if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
|
|
43
43
|
}
|
|
44
|
-
function UploadButton({ acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAllowlistOptIn, maxFileSize, onError, onProgress, onUploaded, uploader }) {
|
|
44
|
+
function UploadButton({ acceptedFileExtensions, acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAllowlistOptIn, maxFileSize, onError, onProgress, onUploaded, uploader }) {
|
|
45
45
|
const msg = (0, i18n_namespaceObject.useMsg)();
|
|
46
46
|
const inputRef = external_react_namespaceObject.useRef(null);
|
|
47
47
|
const [errorMessage, setErrorMessage] = external_react_namespaceObject.useState(null);
|
|
@@ -50,7 +50,11 @@ function UploadButton({ acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAll
|
|
|
50
50
|
const isUploading = null !== batch;
|
|
51
51
|
const uploadAbortRef = external_react_namespaceObject.useRef(null);
|
|
52
52
|
external_react_namespaceObject.useEffect(()=>()=>uploadAbortRef.current?.abort(), []);
|
|
53
|
-
const acceptAttr = external_react_namespaceObject.useMemo(()=>
|
|
53
|
+
const acceptAttr = external_react_namespaceObject.useMemo(()=>[
|
|
54
|
+
...acceptedMimeTypes ?? [],
|
|
55
|
+
...acceptedFileExtensions ?? []
|
|
56
|
+
].join(",") || void 0, [
|
|
57
|
+
acceptedFileExtensions,
|
|
54
58
|
acceptedMimeTypes
|
|
55
59
|
]);
|
|
56
60
|
async function processFiles(files) {
|
|
@@ -73,6 +77,7 @@ function UploadButton({ acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAll
|
|
|
73
77
|
const file = files[index];
|
|
74
78
|
if (file) try {
|
|
75
79
|
(0, external_plugin_cjs_namespaceObject.validateSelectedFile)(file, {
|
|
80
|
+
acceptedFileExtensions,
|
|
76
81
|
acceptedMimeTypes,
|
|
77
82
|
maxFileSize
|
|
78
83
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetManagerOptions } from "../types/options.js";
|
|
2
3
|
import type { UploadAdapter, UploadResult } from "../types/types.js";
|
|
4
|
+
/** Aggregate progress snapshot for the active upload batch. */
|
|
3
5
|
export interface UploadProgressSnapshot {
|
|
4
6
|
readonly completed: number;
|
|
5
7
|
readonly total: number;
|
|
6
8
|
}
|
|
7
|
-
|
|
9
|
+
/** Props for the upload button and drop-zone component. */
|
|
10
|
+
export interface UploadButtonProps extends Pick<AssetManagerOptions, "acceptedFileExtensions" | "acceptedMimeTypes" | "maxFileSize" | "dataUrlAllowlistOptIn" | "allowMixedScriptHostnames"> {
|
|
8
11
|
/**
|
|
9
12
|
* Binary uploader. Required at the UI boundary even though
|
|
10
13
|
* `AssetManagerOptions.uploader` is optional — the plugin passes the
|
|
@@ -20,5 +23,6 @@ export interface UploadButtonProps extends Pick<AssetManagerOptions, "acceptedMi
|
|
|
20
23
|
*/
|
|
21
24
|
readonly onProgress?: (snapshot: UploadProgressSnapshot | null) => void;
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
/** Upload control with file picker, drag/drop, progress, and validation. */
|
|
27
|
+
export declare function UploadButton({ acceptedFileExtensions, acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAllowlistOptIn, maxFileSize, onError, onProgress, onUploaded, uploader, }: UploadButtonProps): React.JSX.Element;
|
|
24
28
|
//# sourceMappingURL=UploadButton.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadButton.d.cts","sourceRoot":"","sources":["../../src/ui/UploadButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UploadButton.d.cts","sourceRoot":"","sources":["../../src/ui/UploadButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGrE,+DAA+D;AAC/D,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAChB,SAAQ,IAAI,CACX,mBAAmB,EACjB,wBAAwB,GACxB,mBAAmB,GACnB,aAAa,GACb,uBAAuB,GACvB,2BAA2B,CAC7B;IACD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI,KAAK,IAAI,CAAC;CACxE;AAYD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,EAC5B,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,QAAQ,GACR,EAAE,iBAAiB,qBA0LnB"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { AssetManagerOptions } from "../types/options.js";
|
|
2
3
|
import type { UploadAdapter, UploadResult } from "../types/types.js";
|
|
4
|
+
/** Aggregate progress snapshot for the active upload batch. */
|
|
3
5
|
export interface UploadProgressSnapshot {
|
|
4
6
|
readonly completed: number;
|
|
5
7
|
readonly total: number;
|
|
6
8
|
}
|
|
7
|
-
|
|
9
|
+
/** Props for the upload button and drop-zone component. */
|
|
10
|
+
export interface UploadButtonProps extends Pick<AssetManagerOptions, "acceptedFileExtensions" | "acceptedMimeTypes" | "maxFileSize" | "dataUrlAllowlistOptIn" | "allowMixedScriptHostnames"> {
|
|
8
11
|
/**
|
|
9
12
|
* Binary uploader. Required at the UI boundary even though
|
|
10
13
|
* `AssetManagerOptions.uploader` is optional — the plugin passes the
|
|
@@ -20,5 +23,6 @@ export interface UploadButtonProps extends Pick<AssetManagerOptions, "acceptedMi
|
|
|
20
23
|
*/
|
|
21
24
|
readonly onProgress?: (snapshot: UploadProgressSnapshot | null) => void;
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
/** Upload control with file picker, drag/drop, progress, and validation. */
|
|
27
|
+
export declare function UploadButton({ acceptedFileExtensions, acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAllowlistOptIn, maxFileSize, onError, onProgress, onUploaded, uploader, }: UploadButtonProps): React.JSX.Element;
|
|
24
28
|
//# sourceMappingURL=UploadButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadButton.d.ts","sourceRoot":"","sources":["../../src/ui/UploadButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UploadButton.d.ts","sourceRoot":"","sources":["../../src/ui/UploadButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGrE,+DAA+D;AAC/D,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAChB,SAAQ,IAAI,CACX,mBAAmB,EACjB,wBAAwB,GACxB,mBAAmB,GACnB,aAAa,GACb,uBAAuB,GACvB,2BAA2B,CAC7B;IACD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI,KAAK,IAAI,CAAC;CACxE;AAYD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,EAC5B,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,QAAQ,GACR,EAAE,iBAAiB,qBA0LnB"}
|
package/dist/ui/UploadButton.js
CHANGED
|
@@ -9,7 +9,7 @@ function handleDragOver(event) {
|
|
|
9
9
|
event.stopPropagation();
|
|
10
10
|
if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
|
|
11
11
|
}
|
|
12
|
-
function UploadButton({ acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAllowlistOptIn, maxFileSize, onError, onProgress, onUploaded, uploader }) {
|
|
12
|
+
function UploadButton({ acceptedFileExtensions, acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAllowlistOptIn, maxFileSize, onError, onProgress, onUploaded, uploader }) {
|
|
13
13
|
const msg = useMsg();
|
|
14
14
|
const inputRef = __rspack_external_react.useRef(null);
|
|
15
15
|
const [errorMessage, setErrorMessage] = __rspack_external_react.useState(null);
|
|
@@ -18,7 +18,11 @@ function UploadButton({ acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAll
|
|
|
18
18
|
const isUploading = null !== batch;
|
|
19
19
|
const uploadAbortRef = __rspack_external_react.useRef(null);
|
|
20
20
|
__rspack_external_react.useEffect(()=>()=>uploadAbortRef.current?.abort(), []);
|
|
21
|
-
const acceptAttr = __rspack_external_react.useMemo(()=>
|
|
21
|
+
const acceptAttr = __rspack_external_react.useMemo(()=>[
|
|
22
|
+
...acceptedMimeTypes ?? [],
|
|
23
|
+
...acceptedFileExtensions ?? []
|
|
24
|
+
].join(",") || void 0, [
|
|
25
|
+
acceptedFileExtensions,
|
|
22
26
|
acceptedMimeTypes
|
|
23
27
|
]);
|
|
24
28
|
async function processFiles(files) {
|
|
@@ -41,6 +45,7 @@ function UploadButton({ acceptedMimeTypes, allowMixedScriptHostnames, dataUrlAll
|
|
|
41
45
|
const file = files[index];
|
|
42
46
|
if (file) try {
|
|
43
47
|
validateSelectedFile(file, {
|
|
48
|
+
acceptedFileExtensions,
|
|
44
49
|
acceptedMimeTypes,
|
|
45
50
|
maxFileSize
|
|
46
51
|
});
|
|
@@ -27,15 +27,98 @@ var __webpack_require__ = {};
|
|
|
27
27
|
})();
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const ASSET_REFERENCE_PREFIX = "asset://";
|
|
31
|
+
function createAssetReference(id, transform) {
|
|
32
|
+
const base = `${ASSET_REFERENCE_PREFIX}${encodeId(id)}`;
|
|
33
|
+
if (void 0 === transform) return base;
|
|
34
|
+
const query = encodeTransform(transform);
|
|
35
|
+
return "" === query ? base : `${base}?${query}`;
|
|
36
|
+
}
|
|
37
|
+
function parseAssetReference(url) {
|
|
38
|
+
if (!url.startsWith(ASSET_REFERENCE_PREFIX)) return null;
|
|
39
|
+
const rest = url.slice(ASSET_REFERENCE_PREFIX.length);
|
|
40
|
+
const queryIndex = rest.indexOf("?");
|
|
41
|
+
const id = decodeId((-1 === queryIndex ? rest : rest.slice(0, queryIndex)).trim());
|
|
42
|
+
if ("" === id) return null;
|
|
43
|
+
if (-1 === queryIndex) return {
|
|
44
|
+
id
|
|
45
|
+
};
|
|
46
|
+
const transform = decodeTransform(rest.slice(queryIndex + 1));
|
|
47
|
+
return void 0 === transform ? {
|
|
48
|
+
id
|
|
49
|
+
} : {
|
|
50
|
+
id,
|
|
51
|
+
transform
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function encodeId(id) {
|
|
55
|
+
return id.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23");
|
|
56
|
+
}
|
|
57
|
+
function decodeId(id) {
|
|
58
|
+
return id.replace(/%3F/gi, "?").replace(/%23/gi, "#").replace(/%25/g, "%");
|
|
59
|
+
}
|
|
60
|
+
const FITS = new Set([
|
|
61
|
+
"cover",
|
|
62
|
+
"contain",
|
|
63
|
+
"fill",
|
|
64
|
+
"inside",
|
|
65
|
+
"outside"
|
|
66
|
+
]);
|
|
67
|
+
const FORMATS = new Set([
|
|
68
|
+
"webp",
|
|
69
|
+
"avif",
|
|
70
|
+
"jpeg",
|
|
71
|
+
"png",
|
|
72
|
+
"auto"
|
|
73
|
+
]);
|
|
74
|
+
function encodeTransform(transform) {
|
|
75
|
+
const params = new URLSearchParams();
|
|
76
|
+
if (void 0 !== transform.width) params.set("w", String(transform.width));
|
|
77
|
+
if (void 0 !== transform.height) params.set("h", String(transform.height));
|
|
78
|
+
if (void 0 !== transform.fit) params.set("fit", transform.fit);
|
|
79
|
+
if (void 0 !== transform.format) params.set("fm", transform.format);
|
|
80
|
+
if (void 0 !== transform.quality) params.set("q", String(transform.quality));
|
|
81
|
+
if (void 0 !== transform.dpr) params.set("dpr", String(transform.dpr));
|
|
82
|
+
return params.toString();
|
|
83
|
+
}
|
|
84
|
+
function decodeTransform(query) {
|
|
85
|
+
const params = new URLSearchParams(query);
|
|
86
|
+
const out = {};
|
|
87
|
+
const width = toPositiveInteger(params.get("w"));
|
|
88
|
+
if (void 0 !== width) out.width = width;
|
|
89
|
+
const height = toPositiveInteger(params.get("h"));
|
|
90
|
+
if (void 0 !== height) out.height = height;
|
|
91
|
+
const fit = params.get("fit");
|
|
92
|
+
if (FITS.has(fit)) out.fit = fit;
|
|
93
|
+
const format = params.get("fm");
|
|
94
|
+
if (FORMATS.has(format)) out.format = format;
|
|
95
|
+
const quality = toPositiveInteger(params.get("q"));
|
|
96
|
+
if (void 0 !== quality && quality <= 100) out.quality = quality;
|
|
97
|
+
const dpr = toPositiveNumber(params.get("dpr"));
|
|
98
|
+
if (void 0 !== dpr) out.dpr = dpr;
|
|
99
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
100
|
+
}
|
|
101
|
+
const DECIMAL_INTEGER_RE = /^[0-9]+$/;
|
|
102
|
+
const DECIMAL_NUMBER_RE = /^[0-9]+(?:\.[0-9]+)?$/;
|
|
103
|
+
function toPositiveInteger(value) {
|
|
104
|
+
if (null === value || !DECIMAL_INTEGER_RE.test(value)) return;
|
|
105
|
+
const n = Number(value);
|
|
106
|
+
return Number.isSafeInteger(n) && n > 0 ? n : void 0;
|
|
107
|
+
}
|
|
108
|
+
function toPositiveNumber(value) {
|
|
109
|
+
if (null === value || !DECIMAL_NUMBER_RE.test(value)) return;
|
|
110
|
+
const n = Number(value);
|
|
111
|
+
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
32
112
|
}
|
|
33
113
|
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
-
createAssetReference: ()=>createAssetReference
|
|
114
|
+
createAssetReference: ()=>createAssetReference,
|
|
115
|
+
parseAssetReference: ()=>parseAssetReference
|
|
35
116
|
});
|
|
36
117
|
exports.createAssetReference = __webpack_exports__.createAssetReference;
|
|
118
|
+
exports.parseAssetReference = __webpack_exports__.parseAssetReference;
|
|
37
119
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
38
|
-
"createAssetReference"
|
|
120
|
+
"createAssetReference",
|
|
121
|
+
"parseAssetReference"
|
|
39
122
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
40
123
|
Object.defineProperty(exports, '__esModule', {
|
|
41
124
|
value: true
|
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Canonical `asset
|
|
2
|
+
* @file Canonical `asset://<id>` reference codec.
|
|
3
3
|
*
|
|
4
|
-
* Lives in its own file so both `plugin.ts` (which dispatches asset
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Lives in its own file so both `plugin.ts` (which dispatches asset references
|
|
5
|
+
* into Puck data) and `resolver.ts` / `studio-asset-source.ts` can reuse it
|
|
6
|
+
* without a circular import. A reference may carry an optional transform query
|
|
7
|
+
* (`asset://<id>?w=800&fm=webp`) requesting a derivative rendition; the IR
|
|
8
|
+
* resolver decodes it and maps it to a derivative URL via the host's
|
|
9
|
+
* `TransformResolver` (review finding #9).
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
import type { AssetTransform } from "../types/transform.js";
|
|
12
|
+
/**
|
|
13
|
+
* Build the opaque `asset://<id>` reference stored in page data for an asset.
|
|
14
|
+
* The IR resolver ({@link createIRAssetResolver}) turns it back into a validated
|
|
15
|
+
* URL at export / render time; it is never a directly-loadable URL itself.
|
|
16
|
+
*
|
|
17
|
+
* Pass a {@link AssetTransform} to request a derivative rendition — it is
|
|
18
|
+
* encoded as a stable query (`?w=&h=&fit=&fm=&q=&dpr=`) and applied by the
|
|
19
|
+
* resolver's configured `TransformResolver`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createAssetReference(id: string, transform?: AssetTransform): string;
|
|
22
|
+
/** Parsed components of an `asset://` reference. */
|
|
23
|
+
export interface ParsedAssetReference {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
/** Present only when the reference carried a (well-formed) transform query. */
|
|
26
|
+
readonly transform?: AssetTransform;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse an `asset://<id>[?transform]` reference. Returns `null` for any non-
|
|
30
|
+
* asset URL or an empty id. Malformed transform params are ignored rather than
|
|
31
|
+
* failing the parse (references can be host- or tamper-supplied).
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseAssetReference(url: string): ParsedAssetReference | null;
|
|
10
34
|
//# sourceMappingURL=asset-reference.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-reference.d.cts","sourceRoot":"","sources":["../../src/utils/asset-reference.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"asset-reference.d.cts","sourceRoot":"","sources":["../../src/utils/asset-reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,MAAM,EACV,SAAS,CAAC,EAAE,cAAc,GACxB,MAAM,CAKR;AAED,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAW5E"}
|
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Canonical `asset
|
|
2
|
+
* @file Canonical `asset://<id>` reference codec.
|
|
3
3
|
*
|
|
4
|
-
* Lives in its own file so both `plugin.ts` (which dispatches asset
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Lives in its own file so both `plugin.ts` (which dispatches asset references
|
|
5
|
+
* into Puck data) and `resolver.ts` / `studio-asset-source.ts` can reuse it
|
|
6
|
+
* without a circular import. A reference may carry an optional transform query
|
|
7
|
+
* (`asset://<id>?w=800&fm=webp`) requesting a derivative rendition; the IR
|
|
8
|
+
* resolver decodes it and maps it to a derivative URL via the host's
|
|
9
|
+
* `TransformResolver` (review finding #9).
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
import type { AssetTransform } from "../types/transform.js";
|
|
12
|
+
/**
|
|
13
|
+
* Build the opaque `asset://<id>` reference stored in page data for an asset.
|
|
14
|
+
* The IR resolver ({@link createIRAssetResolver}) turns it back into a validated
|
|
15
|
+
* URL at export / render time; it is never a directly-loadable URL itself.
|
|
16
|
+
*
|
|
17
|
+
* Pass a {@link AssetTransform} to request a derivative rendition — it is
|
|
18
|
+
* encoded as a stable query (`?w=&h=&fit=&fm=&q=&dpr=`) and applied by the
|
|
19
|
+
* resolver's configured `TransformResolver`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createAssetReference(id: string, transform?: AssetTransform): string;
|
|
22
|
+
/** Parsed components of an `asset://` reference. */
|
|
23
|
+
export interface ParsedAssetReference {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
/** Present only when the reference carried a (well-formed) transform query. */
|
|
26
|
+
readonly transform?: AssetTransform;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse an `asset://<id>[?transform]` reference. Returns `null` for any non-
|
|
30
|
+
* asset URL or an empty id. Malformed transform params are ignored rather than
|
|
31
|
+
* failing the parse (references can be host- or tamper-supplied).
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseAssetReference(url: string): ParsedAssetReference | null;
|
|
10
34
|
//# sourceMappingURL=asset-reference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-reference.d.ts","sourceRoot":"","sources":["../../src/utils/asset-reference.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"asset-reference.d.ts","sourceRoot":"","sources":["../../src/utils/asset-reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,MAAM,EACV,SAAS,CAAC,EAAE,cAAc,GACxB,MAAM,CAKR;AAED,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAW5E"}
|