sanity-plugin-smart-asset-manager 1.0.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/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1356 -0
- package/dist/index.mjs +1336 -0
- package/package.json +72 -0
- package/src/assets/images/all-assets.png +0 -0
- package/src/assets/images/details-popup.png +0 -0
- package/src/assets/images/size-analyzer.png +0 -0
- package/src/assets/images/unused-assets.png +0 -0
- package/src/components/AssetCard.tsx +177 -0
- package/src/components/AssetDetailsDialog.tsx +423 -0
- package/src/components/SmartAssetManagerTool.tsx +284 -0
- package/src/components/TopToolbar.tsx +129 -0
- package/src/components/__tests__/AssetCard.test.tsx +64 -0
- package/src/components/common/Icons.tsx +239 -0
- package/src/components/tabs/SizeAnalyzer.tsx +142 -0
- package/src/components/tabs/UnusedAssets.tsx +129 -0
- package/src/components/tabs/__tests__/SizeAnalyzer.test.tsx +73 -0
- package/src/hooks/useAssets.ts +75 -0
- package/src/index.ts +17 -0
- package/src/setupTests.ts +1 -0
- package/src/types/index.ts +29 -0
- package/src/utils/__tests__/formatBytes.test.ts +25 -0
- package/src/utils/assetQueries.ts +59 -0
- package/src/utils/formatBytes.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Code Journey
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Sanity Plugin Smart Asset Manager
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/sanity-plugin-smart-asset-manager)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
An advanced, premium asset management dashboard for Sanity Studio. Stop guessing which assets are bloating your projectโtake full control of your media library with smart analysis, bulk cleanup tools, and deep usage tracking.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## โจ Features
|
|
11
|
+
|
|
12
|
+
### ๐ Advanced Filtering & Sorting
|
|
13
|
+
|
|
14
|
+
Easily navigate through your media library. Filter by **Images**, **Videos**, **Audio**, and other file types. Use the built-in size filters to find **Small (<100KB)**, **Medium (100KB-1MB)**, or **Large (>1MB)** files instantly.
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
### ๐ Image Size Analyzer
|
|
19
|
+
|
|
20
|
+
Identify performance bottlenecks. The Analyzer tab lists your assets by weight and dimensions. You can sort by file size (Weight) to quickly find unoptimized images that are slowing down your site.
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
### ๐งน Unused Asset Detector & Bulk Cleanup
|
|
25
|
+
|
|
26
|
+
Keep your dataset lean and save on storage costs.
|
|
27
|
+
|
|
28
|
+
- **Smart Detection**: Automatically finds assets not referenced by any document.
|
|
29
|
+
- **Multi-Select**: Use checkboxes to select specific assets for deletion.
|
|
30
|
+
- **Bulk Delete**: Delete all or selected unused assets with a single click after a safety confirmation.
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
### ๐ก๏ธ Duplicate Prevention
|
|
35
|
+
|
|
36
|
+
Stop uploading the same file twice. The plugin automatically checks for existing filenames during upload and warns you if a duplicate is detected, keeping your library clean and organized.
|
|
37
|
+
|
|
38
|
+
### ๐ Deep Usage Tracking
|
|
39
|
+
|
|
40
|
+
Never delete a critical asset by mistake. Click any asset to see exactly which documents are referencing it. You can even click a document in the usage list to jump straight to the editor.
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
### โก Batch Uploads
|
|
45
|
+
|
|
46
|
+
Upload multiple files at once. The plugin provides clear progress feedback and handles batch processing efficiently, with a smart 1-second delay after completion to ensure Sanity's backend has indexed your new files.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ๐ฆ Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install sanity-plugin-smart-asset-manager
|
|
54
|
+
# or
|
|
55
|
+
yarn add sanity-plugin-smart-asset-manager
|
|
56
|
+
# or
|
|
57
|
+
pnpm add sanity-plugin-smart-asset-manager
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ๐ Usage
|
|
63
|
+
|
|
64
|
+
1. Add the plugin to your `sanity.config.ts` (or `.js`):
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import {defineConfig} from 'sanity'
|
|
68
|
+
import {smartAssetManager} from 'sanity-plugin-smart-asset-manager'
|
|
69
|
+
|
|
70
|
+
export default defineConfig({
|
|
71
|
+
// ...
|
|
72
|
+
plugins: [
|
|
73
|
+
smartAssetManager(),
|
|
74
|
+
// ...
|
|
75
|
+
],
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. Open your Sanity Studio. You will see a new **Smart Asset Manager** tool in your navigation bar.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## ๐ Why This Plugin?
|
|
84
|
+
|
|
85
|
+
Sanity's default media library is great for selection, but maintenance can be challenging as libraries grow. **Smart Asset Manager** provides the power tools needed for:
|
|
86
|
+
|
|
87
|
+
- **Performance Optimization**: Find and replace heavy assets.
|
|
88
|
+
- **Cost Management**: Remove gigabytes of unused files.
|
|
89
|
+
- **Workflow Efficiency**: Batch upload and deep usage insights.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ๐ ๏ธ Development & Building
|
|
94
|
+
|
|
95
|
+
To build the plugin locally:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm run build
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The plugin uses `tsup` for lightning-fast ESM and CJS builds with declaration types.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## ๐ License
|
|
106
|
+
|
|
107
|
+
[MIT](LICENSE) ยฉ [Code Journey](https://github.com/Code-Journey-77)
|
|
108
|
+
|
|
109
|
+
---
|
package/dist/index.d.mts
ADDED