nuxt-media-library 0.0.44
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 +243 -0
- package/dist/module.d.mts +31 -0
- package/dist/module.d.ts +31 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +118 -0
- package/dist/runtime/components/MLAssetManager/AssetActivity.d.vue.ts +6 -0
- package/dist/runtime/components/MLAssetManager/AssetActivity.vue +13 -0
- package/dist/runtime/components/MLAssetManager/AssetActivity.vue.d.ts +6 -0
- package/dist/runtime/components/MLAssetManager/AssetCard.d.vue.ts +14 -0
- package/dist/runtime/components/MLAssetManager/AssetCard.vue +100 -0
- package/dist/runtime/components/MLAssetManager/AssetCard.vue.d.ts +14 -0
- package/dist/runtime/components/MLAssetManager/AssetDetail.d.vue.ts +14 -0
- package/dist/runtime/components/MLAssetManager/AssetDetail.vue +156 -0
- package/dist/runtime/components/MLAssetManager/AssetDetail.vue.d.ts +14 -0
- package/dist/runtime/components/MLAssetManager/AssetList.d.vue.ts +15 -0
- package/dist/runtime/components/MLAssetManager/AssetList.vue +41 -0
- package/dist/runtime/components/MLAssetManager/AssetList.vue.d.ts +15 -0
- package/dist/runtime/components/MLAssetManager/AssetOverview.d.vue.ts +8 -0
- package/dist/runtime/components/MLAssetManager/AssetOverview.vue +321 -0
- package/dist/runtime/components/MLAssetManager/AssetOverview.vue.d.ts +8 -0
- package/dist/runtime/components/MLAssetManager/AssetPreview.d.vue.ts +10 -0
- package/dist/runtime/components/MLAssetManager/AssetPreview.vue +18 -0
- package/dist/runtime/components/MLAssetManager/AssetPreview.vue.d.ts +10 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewAudio.d.vue.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewAudio.vue +21 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewAudio.vue.d.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewDocument.d.vue.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewDocument.vue +39 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewDocument.vue.d.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewFallback.d.vue.ts +7 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewFallback.vue +41 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewFallback.vue.d.ts +7 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewImage.d.vue.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewImage.vue +30 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewImage.vue.d.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewSidebar.d.vue.ts +15 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewSidebar.vue +69 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewSidebar.vue.d.ts +15 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewVideo.d.vue.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewVideo.vue +148 -0
- package/dist/runtime/components/MLAssetManager/AssetPreviewVideo.vue.d.ts +9 -0
- package/dist/runtime/components/MLAssetManager/AssetRenditions.d.vue.ts +8 -0
- package/dist/runtime/components/MLAssetManager/AssetRenditions.vue +148 -0
- package/dist/runtime/components/MLAssetManager/AssetRenditions.vue.d.ts +8 -0
- package/dist/runtime/components/MLAssetManager/Processing.d.vue.ts +8 -0
- package/dist/runtime/components/MLAssetManager/Processing.vue +84 -0
- package/dist/runtime/components/MLAssetManager/Processing.vue.d.ts +8 -0
- package/dist/runtime/components/MLAssetManager/SlotCard.d.vue.ts +17 -0
- package/dist/runtime/components/MLAssetManager/SlotCard.vue +94 -0
- package/dist/runtime/components/MLAssetManager/SlotCard.vue.d.ts +17 -0
- package/dist/runtime/components/MLAssetManager/Widget.d.vue.ts +14 -0
- package/dist/runtime/components/MLAssetManager/Widget.vue +328 -0
- package/dist/runtime/components/MLAssetManager/Widget.vue.d.ts +14 -0
- package/dist/runtime/components/MLPreviewProvider.d.vue.ts +31 -0
- package/dist/runtime/components/MLPreviewProvider.vue +51 -0
- package/dist/runtime/components/MLPreviewProvider.vue.d.ts +31 -0
- package/dist/runtime/components/MLProcessing/Forms/ConfigureStepModal.d.vue.ts +13 -0
- package/dist/runtime/components/MLProcessing/Forms/ConfigureStepModal.vue +47 -0
- package/dist/runtime/components/MLProcessing/Forms/ConfigureStepModal.vue.d.ts +13 -0
- package/dist/runtime/components/MLProcessing/Forms/FramePicker.d.vue.ts +11 -0
- package/dist/runtime/components/MLProcessing/Forms/FramePicker.vue +162 -0
- package/dist/runtime/components/MLProcessing/Forms/FramePicker.vue.d.ts +11 -0
- package/dist/runtime/components/MLProcessing/Forms/StepOptionsForm.d.vue.ts +14 -0
- package/dist/runtime/components/MLProcessing/Forms/StepOptionsForm.vue +113 -0
- package/dist/runtime/components/MLProcessing/Forms/StepOptionsForm.vue.d.ts +14 -0
- package/dist/runtime/components/MLProcessing/Pipeline.d.vue.ts +15 -0
- package/dist/runtime/components/MLProcessing/Pipeline.vue +178 -0
- package/dist/runtime/components/MLProcessing/Pipeline.vue.d.ts +15 -0
- package/dist/runtime/components/MLProcessing/PipelineStepItem.d.vue.ts +20 -0
- package/dist/runtime/components/MLProcessing/PipelineStepItem.vue +309 -0
- package/dist/runtime/components/MLProcessing/PipelineStepItem.vue.d.ts +20 -0
- package/dist/runtime/components/MLProcessing/ProgressBar.d.vue.ts +9 -0
- package/dist/runtime/components/MLProcessing/ProgressBar.vue +27 -0
- package/dist/runtime/components/MLProcessing/ProgressBar.vue.d.ts +9 -0
- package/dist/runtime/components/MLProcessing/StepLayout.d.vue.ts +31 -0
- package/dist/runtime/components/MLProcessing/StepLayout.vue +36 -0
- package/dist/runtime/components/MLProcessing/StepLayout.vue.d.ts +31 -0
- package/dist/runtime/components/MLProcessing/Stepper.d.vue.ts +16 -0
- package/dist/runtime/components/MLProcessing/Stepper.vue +87 -0
- package/dist/runtime/components/MLProcessing/Stepper.vue.d.ts +16 -0
- package/dist/runtime/components/MLProcessing/StepperItem.d.vue.ts +16 -0
- package/dist/runtime/components/MLProcessing/StepperItem.vue +150 -0
- package/dist/runtime/components/MLProcessing/StepperItem.vue.d.ts +16 -0
- package/dist/runtime/components/MLProcessing/TopBar.d.vue.ts +21 -0
- package/dist/runtime/components/MLProcessing/TopBar.vue +46 -0
- package/dist/runtime/components/MLProcessing/TopBar.vue.d.ts +21 -0
- package/dist/runtime/components/MLUploader/ButtonUploader.d.vue.ts +55 -0
- package/dist/runtime/components/MLUploader/ButtonUploader.vue +211 -0
- package/dist/runtime/components/MLUploader/ButtonUploader.vue.d.ts +55 -0
- package/dist/runtime/components/MLUploader/Item.d.vue.ts +34 -0
- package/dist/runtime/components/MLUploader/Item.vue +242 -0
- package/dist/runtime/components/MLUploader/Item.vue.d.ts +34 -0
- package/dist/runtime/components/MLUploader/PolicyPopover.d.vue.ts +7 -0
- package/dist/runtime/components/MLUploader/PolicyPopover.vue +160 -0
- package/dist/runtime/components/MLUploader/PolicyPopover.vue.d.ts +7 -0
- package/dist/runtime/components/MLUploader/Widget.d.vue.ts +44 -0
- package/dist/runtime/components/MLUploader/Widget.vue +251 -0
- package/dist/runtime/components/MLUploader/Widget.vue.d.ts +44 -0
- package/dist/runtime/composables/resourcePolicy/mimeUtils.d.ts +4 -0
- package/dist/runtime/composables/resourcePolicy/mimeUtils.js +71 -0
- package/dist/runtime/composables/resourcePolicy/useMLResourcePolicy.d.ts +17 -0
- package/dist/runtime/composables/resourcePolicy/useMLResourcePolicy.js +150 -0
- package/dist/runtime/composables/useElapsedTimer.d.ts +13 -0
- package/dist/runtime/composables/useElapsedTimer.js +46 -0
- package/dist/runtime/composables/useMLAssetLibrary.d.ts +31 -0
- package/dist/runtime/composables/useMLAssetLibrary.js +53 -0
- package/dist/runtime/composables/useMLAssetManager.d.ts +30 -0
- package/dist/runtime/composables/useMLAssetManager.js +229 -0
- package/dist/runtime/composables/useMLAssetManagerPreview.d.ts +28 -0
- package/dist/runtime/composables/useMLAssetManagerPreview.js +232 -0
- package/dist/runtime/composables/useMLAssetPreview.d.ts +23 -0
- package/dist/runtime/composables/useMLAssetPreview.js +153 -0
- package/dist/runtime/composables/useMLChunkUploader.d.ts +9 -0
- package/dist/runtime/composables/useMLChunkUploader.js +22 -0
- package/dist/runtime/composables/useMLProcessingPipeline.d.ts +38 -0
- package/dist/runtime/composables/useMLProcessingPipeline.js +258 -0
- package/dist/runtime/composables/useMLProcessingStatus.d.ts +34 -0
- package/dist/runtime/composables/useMLProcessingStatus.js +100 -0
- package/dist/runtime/composables/useMLProcessingStepper.d.ts +32 -0
- package/dist/runtime/composables/useMLProcessingStepper.js +280 -0
- package/dist/runtime/composables/useMLProcessingStrategies.d.ts +7 -0
- package/dist/runtime/composables/useMLProcessingStrategies.js +47 -0
- package/dist/runtime/composables/useMLRepeater.d.ts +5 -0
- package/dist/runtime/composables/useMLRepeater.js +11 -0
- package/dist/runtime/css/index.css +1 -0
- package/dist/runtime/index.d.ts +13 -0
- package/dist/runtime/index.js +13 -0
- package/dist/runtime/plugins/asset-direcetive-client.d.ts +2 -0
- package/dist/runtime/plugins/asset-direcetive-client.js +64 -0
- package/dist/runtime/plugins/config.d.ts +13 -0
- package/dist/runtime/plugins/config.js +23 -0
- package/dist/runtime/schemas/resource-policy.schema.d.ts +607 -0
- package/dist/runtime/schemas/resource-policy.schema.js +117 -0
- package/dist/runtime/server/assets-proxy.d.ts +2 -0
- package/dist/runtime/server/assets-proxy.js +81 -0
- package/dist/runtime/server/create-ml-proxy.d.ts +47 -0
- package/dist/runtime/server/create-ml-proxy.js +232 -0
- package/dist/runtime/server/delivery-proxy.d.ts +2 -0
- package/dist/runtime/server/delivery-proxy.js +74 -0
- package/dist/runtime/server/index.d.ts +2 -0
- package/dist/runtime/server/index.js +1 -0
- package/dist/runtime/server/processing-proxy.d.ts +2 -0
- package/dist/runtime/server/processing-proxy.js +55 -0
- package/dist/runtime/server/resource-policy-proxy.d.ts +2 -0
- package/dist/runtime/server/resource-policy-proxy.js +80 -0
- package/dist/runtime/server/tsconfig.json +0 -0
- package/dist/runtime/server/uploads-proxy.d.ts +2 -0
- package/dist/runtime/server/uploads-proxy.js +99 -0
- package/dist/runtime/types/asset.d.ts +174 -0
- package/dist/runtime/types/asset.js +7 -0
- package/dist/runtime/types/preview.d.ts +20 -0
- package/dist/runtime/types/preview.js +0 -0
- package/dist/runtime/types/resourcePolicy.d.ts +77 -0
- package/dist/runtime/types/resourcePolicy.js +25 -0
- package/dist/runtime/types/uploader.d.ts +71 -0
- package/dist/runtime/types/uploader.js +0 -0
- package/dist/runtime/utils/uploader/checksum.d.ts +21 -0
- package/dist/runtime/utils/uploader/checksum.js +23 -0
- package/dist/runtime/utils/uploader/chunking.d.ts +8 -0
- package/dist/runtime/utils/uploader/chunking.js +21 -0
- package/dist/runtime/utils/uploader/uploader.d.ts +20 -0
- package/dist/runtime/utils/uploader/uploader.js +206 -0
- package/dist/types.d.mts +11 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Get your module up and running quickly.
|
|
3
|
+
|
|
4
|
+
Find and replace all on all files (CMD+SHIFT+F):
|
|
5
|
+
- Name: My Module
|
|
6
|
+
- Package name: my-module
|
|
7
|
+
- Description: My new Nuxt module
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Media Library
|
|
11
|
+
|
|
12
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
13
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
14
|
+
[![License][license-src]][license-href]
|
|
15
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
16
|
+
|
|
17
|
+
Media library components and upload utilities for Nuxt, Vue, and custom elements.
|
|
18
|
+
|
|
19
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
20
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
|
|
21
|
+
<!-- - [📖 Documentation](https://example.com) -->
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
<!-- Highlight some of the features your module provide here -->
|
|
26
|
+
- ⛰ Foo
|
|
27
|
+
- 🚠 Bar
|
|
28
|
+
- 🌲 Baz
|
|
29
|
+
|
|
30
|
+
## Quick Setup
|
|
31
|
+
|
|
32
|
+
Install the module to your Nuxt application with one command:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx nuxi module add media-library
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
That's it! You can now use Media Library in your Nuxt app ✨
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### Nuxt installation (Vue components only)
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
export default defineNuxtConfig({
|
|
46
|
+
modules: ['media-library'],
|
|
47
|
+
mediaLibrary: {
|
|
48
|
+
// Auto-register Vue components from src/runtime/components
|
|
49
|
+
components: true,
|
|
50
|
+
// Chunk uploader config (used by MlFileUpload)
|
|
51
|
+
baseURL: 'https://api.example.com',
|
|
52
|
+
// Uploads always go through Nuxt server (/api/media-library/uploads/*)
|
|
53
|
+
routes: {
|
|
54
|
+
createSession: '/uploads/sessions',
|
|
55
|
+
getSession: '/uploads/sessions/:id',
|
|
56
|
+
uploadPart: '/uploads/sessions/:id/parts/:part',
|
|
57
|
+
finalize: '/uploads/sessions/:id/finalize',
|
|
58
|
+
abort: '/uploads/sessions/:id/abort',
|
|
59
|
+
},
|
|
60
|
+
partSize: 8 * 1024 * 1024,
|
|
61
|
+
concurrency: 3,
|
|
62
|
+
checksum: { algorithm: 'SHA-256', perPart: true, final: true },
|
|
63
|
+
headers: {},
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Nuxt usage
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<template>
|
|
72
|
+
<MediaLibrary />
|
|
73
|
+
</template>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If you use the uploader component in Nuxt, provide config via the Nuxt plugin
|
|
77
|
+
(see your module/plugin setup) and use:
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<template>
|
|
81
|
+
<MlFileUpload />
|
|
82
|
+
</template>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Vue installation (non-Nuxt)
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm i media-library
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { createApp } from 'vue'
|
|
93
|
+
import MediaLibraryPlugin from 'media-library/vue'
|
|
94
|
+
|
|
95
|
+
const app = createApp(App)
|
|
96
|
+
app.use(MediaLibraryPlugin, {
|
|
97
|
+
chunkUploader: {
|
|
98
|
+
// Use a same-origin proxy (recommended) or set baseURL for direct calls
|
|
99
|
+
baseURL: '',
|
|
100
|
+
routes: {
|
|
101
|
+
createSession: '/api/media-library/uploads/sessions',
|
|
102
|
+
getSession: '/api/media-library/uploads/sessions/:id',
|
|
103
|
+
uploadPart: '/api/media-library/uploads/sessions/:id/parts/:part',
|
|
104
|
+
finalize: '/api/media-library/uploads/sessions/:id/finalize',
|
|
105
|
+
},
|
|
106
|
+
partSize: 8 * 1024 * 1024,
|
|
107
|
+
concurrency: 3,
|
|
108
|
+
checksum: { algorithm: 'SHA-256', perPart: true, final: true },
|
|
109
|
+
headers: {},
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<template>
|
|
116
|
+
<MediaLibrary />
|
|
117
|
+
<MlFileUpload />
|
|
118
|
+
</template>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Custom element via CDN
|
|
122
|
+
|
|
123
|
+
Load the prebuilt custom element bundle (IIFE):
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<script src="/dist-ce/media-library.custom-element.js"></script>
|
|
127
|
+
<media-library></media-library>
|
|
128
|
+
<ml-file-upload></ml-file-upload>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Global config:
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<script>
|
|
135
|
+
window.MediaLibraryConfig = {
|
|
136
|
+
chunkUploader: {
|
|
137
|
+
baseURL: '',
|
|
138
|
+
routes: {
|
|
139
|
+
createSession: '/api/media-library/uploads/sessions',
|
|
140
|
+
getSession: '/api/media-library/uploads/sessions/:id',
|
|
141
|
+
uploadPart: '/api/media-library/uploads/sessions/:id/parts/:part',
|
|
142
|
+
finalize: '/api/media-library/uploads/sessions/:id/finalize',
|
|
143
|
+
},
|
|
144
|
+
partSize: 8388608,
|
|
145
|
+
concurrency: 3,
|
|
146
|
+
checksum: { algorithm: 'SHA-256', perPart: true, final: true },
|
|
147
|
+
headers: {},
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</script>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Per element:
|
|
154
|
+
|
|
155
|
+
```html
|
|
156
|
+
<ml-file-upload
|
|
157
|
+
chunk-uploader='{"baseURL":"","routes":{"createSession":"/api/media-library/uploads/sessions","getSession":"/api/media-library/uploads/sessions/:id","uploadPart":"/api/media-library/uploads/sessions/:id/parts/:part","finalize":"/api/media-library/uploads/sessions/:id/finalize"},"partSize":8388608,"concurrency":3,"checksum":{"algorithm":"SHA-256","perPart":true,"final":true},"headers":{}}'
|
|
158
|
+
></ml-file-upload>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Developer Guide
|
|
162
|
+
|
|
163
|
+
### Nuxt development (module)
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Install dependencies
|
|
167
|
+
npm install
|
|
168
|
+
|
|
169
|
+
# Generate type stubs and prepare the playground
|
|
170
|
+
npm run dev:prepare
|
|
171
|
+
|
|
172
|
+
# Run the playground (Nuxt module usage)
|
|
173
|
+
npm run dev
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Use the playground to test module options and auto-registered components.
|
|
177
|
+
|
|
178
|
+
#### SSR notes (Nuxt)
|
|
179
|
+
|
|
180
|
+
If a component uses browser-only APIs, use one of these patterns:
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
if (process.client) {
|
|
184
|
+
// window/document usage
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import { onMounted } from 'vue'
|
|
190
|
+
|
|
191
|
+
onMounted(() => {
|
|
192
|
+
// safe to access window/document here
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```vue
|
|
197
|
+
<ClientOnly>
|
|
198
|
+
<MediaLibrary />
|
|
199
|
+
</ClientOnly>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Or make it client-only by naming the file `MyComponent.client.vue`.
|
|
203
|
+
|
|
204
|
+
### Vue development (library)
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Build the Vue entry and type declarations
|
|
208
|
+
npm run prepack
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Import from `media-library/vue` in a Vue app to verify component behavior.
|
|
212
|
+
|
|
213
|
+
### Custom element development (CE)
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Build the standalone custom element bundle
|
|
217
|
+
npm run build:custom-element
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Load `dist-ce/media-library.custom-element.js` in any HTML page and use
|
|
221
|
+
`<media-library></media-library>` to verify the output.
|
|
222
|
+
|
|
223
|
+
### Tests
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm run lint
|
|
227
|
+
npm run test
|
|
228
|
+
npm run test:watch
|
|
229
|
+
npm run test:types
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
<!-- Badges -->
|
|
233
|
+
[npm-version-src]: https://img.shields.io/npm/v/media-library/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
234
|
+
[npm-version-href]: https://npmjs.com/package/media-library
|
|
235
|
+
|
|
236
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/media-library.svg?style=flat&colorA=020420&colorB=00DC82
|
|
237
|
+
[npm-downloads-href]: https://npm.chart.dev/media-library
|
|
238
|
+
|
|
239
|
+
[license-src]: https://img.shields.io/npm/l/media-library.svg?style=flat&colorA=020420&colorB=00DC82
|
|
240
|
+
[license-href]: https://npmjs.com/package/media-library
|
|
241
|
+
|
|
242
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
|
|
243
|
+
[nuxt-href]: https://nuxt.com
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export * from '../dist/runtime/types/resourcePolicy.js';
|
|
3
|
+
export * from '../dist/runtime/types/uploader.js';
|
|
4
|
+
export * from '../dist/runtime/types/preview.js';
|
|
5
|
+
export * from '../dist/runtime/types/asset.js';
|
|
6
|
+
|
|
7
|
+
interface ChunkUploaderRoutesConfig {
|
|
8
|
+
createSession: string;
|
|
9
|
+
getSession: string;
|
|
10
|
+
uploadPart: string;
|
|
11
|
+
finalize: string;
|
|
12
|
+
abort?: string;
|
|
13
|
+
assets?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ModuleOptions {
|
|
16
|
+
components?: boolean;
|
|
17
|
+
baseURL?: string;
|
|
18
|
+
routes?: ChunkUploaderRoutesConfig;
|
|
19
|
+
partSize?: number;
|
|
20
|
+
concurrency?: number;
|
|
21
|
+
checksum?: {
|
|
22
|
+
algorithm?: 'SHA-256';
|
|
23
|
+
perPart?: boolean;
|
|
24
|
+
final?: boolean;
|
|
25
|
+
};
|
|
26
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
27
|
+
}
|
|
28
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
29
|
+
|
|
30
|
+
export { _default as default };
|
|
31
|
+
export type { ChunkUploaderRoutesConfig, ModuleOptions };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export * from '../dist/runtime/types/resourcePolicy.js';
|
|
3
|
+
export * from '../dist/runtime/types/uploader.js';
|
|
4
|
+
export * from '../dist/runtime/types/preview.js';
|
|
5
|
+
export * from '../dist/runtime/types/asset.js';
|
|
6
|
+
|
|
7
|
+
interface ChunkUploaderRoutesConfig {
|
|
8
|
+
createSession: string;
|
|
9
|
+
getSession: string;
|
|
10
|
+
uploadPart: string;
|
|
11
|
+
finalize: string;
|
|
12
|
+
abort?: string;
|
|
13
|
+
assets?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ModuleOptions {
|
|
16
|
+
components?: boolean;
|
|
17
|
+
baseURL?: string;
|
|
18
|
+
routes?: ChunkUploaderRoutesConfig;
|
|
19
|
+
partSize?: number;
|
|
20
|
+
concurrency?: number;
|
|
21
|
+
checksum?: {
|
|
22
|
+
algorithm?: 'SHA-256';
|
|
23
|
+
perPart?: boolean;
|
|
24
|
+
final?: boolean;
|
|
25
|
+
};
|
|
26
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
27
|
+
}
|
|
28
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
29
|
+
|
|
30
|
+
export { _default as default };
|
|
31
|
+
export type { ChunkUploaderRoutesConfig, ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addImportsDir, addComponentsDir, addServerHandler, addPlugin } from '@nuxt/kit';
|
|
2
|
+
export * from '../dist/runtime/types/resourcePolicy.js';
|
|
3
|
+
export * from '../dist/runtime/types/uploader.js';
|
|
4
|
+
export * from '../dist/runtime/types/preview.js';
|
|
5
|
+
export * from '../dist/runtime/types/asset.js';
|
|
6
|
+
|
|
7
|
+
const module$1 = defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "media-library",
|
|
10
|
+
configKey: "mediaLibrary"
|
|
11
|
+
},
|
|
12
|
+
// Default configuration options of the Nuxt module
|
|
13
|
+
defaults: {
|
|
14
|
+
components: true,
|
|
15
|
+
baseURL: "",
|
|
16
|
+
routes: {
|
|
17
|
+
createSession: "/manage/uploads/sessions",
|
|
18
|
+
getSession: "/manage/uploads/sessions/:id",
|
|
19
|
+
uploadPart: "/manage/uploads/sessions/:id/parts/:part",
|
|
20
|
+
finalize: "/manage/uploads/sessions/:id/finalize",
|
|
21
|
+
abort: "/manage/uploads/sessions/:id/abort"
|
|
22
|
+
},
|
|
23
|
+
partSize: 8 * 1024 * 1024,
|
|
24
|
+
concurrency: 3,
|
|
25
|
+
checksum: { algorithm: "SHA-256", perPart: true, final: true },
|
|
26
|
+
headers: {}
|
|
27
|
+
},
|
|
28
|
+
async setup(options, nuxt) {
|
|
29
|
+
const resolver = createResolver(import.meta.url);
|
|
30
|
+
const runtimeDir = resolver.resolve("./runtime");
|
|
31
|
+
addImportsDir(resolver.resolve("runtime/composables"));
|
|
32
|
+
nuxt.options.build.transpile ||= [];
|
|
33
|
+
nuxt.options.build.transpile.push(runtimeDir);
|
|
34
|
+
const existingPrivate = nuxt.options.runtimeConfig.mediaLibrary || {};
|
|
35
|
+
const existingPublic = nuxt.options.runtimeConfig.public?.mediaLibrary || {};
|
|
36
|
+
const envBaseURL = nuxt.options.runtimeConfig.mediaLibraryBaseUrl;
|
|
37
|
+
const envTenantHeader = process.env.NUXT_MEDIA_LIBRARY_HEADERS_X_TENANT;
|
|
38
|
+
const envHeaders = envTenantHeader ? { "X-tenant": envTenantHeader } : {};
|
|
39
|
+
const existingHeaders = typeof existingPrivate.headers === "object" ? existingPrivate.headers : {};
|
|
40
|
+
const resolvedHeaders = { ...existingHeaders };
|
|
41
|
+
for (const [key, value] of Object.entries(envHeaders)) {
|
|
42
|
+
if (!resolvedHeaders[key]) {
|
|
43
|
+
resolvedHeaders[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (options.components) {
|
|
47
|
+
addComponentsDir({
|
|
48
|
+
path: resolver.resolve("./runtime/components"),
|
|
49
|
+
global: true,
|
|
50
|
+
pathPrefix: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const routes = {
|
|
54
|
+
createSession: "/api/media-library/manage/uploads/sessions",
|
|
55
|
+
getSession: "/api/media-library/manage/uploads/sessions/:id",
|
|
56
|
+
uploadPart: "/api/media-library/manage/uploads/sessions/:id/parts/:part",
|
|
57
|
+
finalize: "/api/media-library/manage/uploads/sessions/:id/finalize",
|
|
58
|
+
abort: "/api/media-library/manage/uploads/sessions/:id/abort",
|
|
59
|
+
assets: "/api/media-library/manage/assets"
|
|
60
|
+
};
|
|
61
|
+
if (!routes) {
|
|
62
|
+
throw new Error("ChunkUploader routes are required in mediaLibrary module options.");
|
|
63
|
+
}
|
|
64
|
+
addServerHandler({
|
|
65
|
+
route: "/api/media-library/delivery/**",
|
|
66
|
+
handler: resolver.resolve("./runtime/server/delivery-proxy")
|
|
67
|
+
});
|
|
68
|
+
addServerHandler({
|
|
69
|
+
route: "/api/media-library/manage/uploads/**",
|
|
70
|
+
handler: resolver.resolve("./runtime/server/uploads-proxy")
|
|
71
|
+
});
|
|
72
|
+
addServerHandler({
|
|
73
|
+
route: "/api/media-library/manage/resource-policies/**",
|
|
74
|
+
handler: resolver.resolve("./runtime/server/resource-policy-proxy")
|
|
75
|
+
});
|
|
76
|
+
addServerHandler({
|
|
77
|
+
route: "/api/media-library/manage/resource-policies",
|
|
78
|
+
handler: resolver.resolve("./runtime/server/resource-policy-proxy")
|
|
79
|
+
});
|
|
80
|
+
addServerHandler({
|
|
81
|
+
route: "/api/media-library/manage/assets/**",
|
|
82
|
+
handler: resolver.resolve("./runtime/server/assets-proxy")
|
|
83
|
+
});
|
|
84
|
+
addServerHandler({
|
|
85
|
+
route: "/api/media-library/manage/assets",
|
|
86
|
+
handler: resolver.resolve("./runtime/server/assets-proxy")
|
|
87
|
+
});
|
|
88
|
+
addServerHandler({
|
|
89
|
+
route: "/api/media-library/manage/processing/**",
|
|
90
|
+
handler: resolver.resolve("./runtime/server/processing-proxy")
|
|
91
|
+
});
|
|
92
|
+
nuxt.options.runtimeConfig.mediaLibrary = {
|
|
93
|
+
...existingPrivate,
|
|
94
|
+
baseURL: existingPrivate.baseURL ?? envBaseURL ?? options.baseURL ?? "",
|
|
95
|
+
routes: existingPrivate.routes ?? options.routes ?? routes,
|
|
96
|
+
headers: resolvedHeaders
|
|
97
|
+
};
|
|
98
|
+
nuxt.options.runtimeConfig.public.mediaLibrary = {
|
|
99
|
+
...existingPublic,
|
|
100
|
+
baseURL: existingPublic.baseURL ?? options.baseURL ?? "",
|
|
101
|
+
routes: existingPublic.routes ?? routes,
|
|
102
|
+
proxyUploads: existingPublic.proxyUploads ?? true,
|
|
103
|
+
partSize: existingPublic.partSize ?? options.partSize ?? 8 * 1024 * 1024,
|
|
104
|
+
concurrency: existingPublic.concurrency ?? options.concurrency ?? 3,
|
|
105
|
+
checksum: {
|
|
106
|
+
algorithm: existingPublic.checksum?.algorithm ?? options.checksum?.algorithm ?? "SHA-256",
|
|
107
|
+
perPart: existingPublic.checksum?.perPart ?? options.checksum?.perPart ?? true,
|
|
108
|
+
final: existingPublic.checksum?.final ?? options.checksum?.final ?? true
|
|
109
|
+
},
|
|
110
|
+
headers: existingPublic.headers ?? options.headers ?? {}
|
|
111
|
+
};
|
|
112
|
+
addPlugin({
|
|
113
|
+
src: resolver.resolve("./runtime/plugins/config")
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
assetId: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineProps({
|
|
3
|
+
assetId: { type: String, required: true }
|
|
4
|
+
});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<UEmpty
|
|
9
|
+
icon="i-lucide-activity"
|
|
10
|
+
title="Audit log coming soon"
|
|
11
|
+
description="Activity tracking will be available in a future update."
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
assetId: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AssetDetail } from "../../index.js";
|
|
2
|
+
import type { ProcessingStream } from "../../composables/useMLProcessingStatus.js";
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
asset: AssetDetail;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
processingStream?: ProcessingStream;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
click: () => any;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
11
|
+
onClick?: (() => any) | undefined;
|
|
12
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
asset: { type: Object, required: true },
|
|
5
|
+
selected: { type: Boolean, required: true },
|
|
6
|
+
processingStream: { type: Object, required: false }
|
|
7
|
+
});
|
|
8
|
+
const emit = defineEmits(["click"]);
|
|
9
|
+
const kindColor = computed(() => {
|
|
10
|
+
const map = {
|
|
11
|
+
IMAGE: "info",
|
|
12
|
+
VIDEO: "secondary",
|
|
13
|
+
AUDIO: "warning",
|
|
14
|
+
DOCUMENT: "success",
|
|
15
|
+
ARCHIVE: "neutral",
|
|
16
|
+
FONT: "neutral"
|
|
17
|
+
};
|
|
18
|
+
return map[props.asset.kind?.toUpperCase()] ?? "neutral";
|
|
19
|
+
});
|
|
20
|
+
const statusColor = computed(() => {
|
|
21
|
+
const map = {
|
|
22
|
+
ready: "success",
|
|
23
|
+
processing: "warning",
|
|
24
|
+
failed: "error",
|
|
25
|
+
uploaded: "info",
|
|
26
|
+
pending: "neutral"
|
|
27
|
+
};
|
|
28
|
+
return map[props.asset.status] ?? "neutral";
|
|
29
|
+
});
|
|
30
|
+
const statusLabel = computed(() => {
|
|
31
|
+
const map = {
|
|
32
|
+
ready: "READY",
|
|
33
|
+
processing: "PROC",
|
|
34
|
+
failed: "FAIL",
|
|
35
|
+
uploaded: "UPLOADED",
|
|
36
|
+
pending: "PENDING"
|
|
37
|
+
};
|
|
38
|
+
return map[props.asset.status] ?? props.asset.status?.toUpperCase();
|
|
39
|
+
});
|
|
40
|
+
const formattedSize = computed(() => {
|
|
41
|
+
const bytes = props.asset.bytes;
|
|
42
|
+
if (!bytes) return "0 B";
|
|
43
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
44
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
45
|
+
return `${(bytes / Math.pow(1024, i)).toFixed(i > 0 ? 1 : 0)} ${units[i]}`;
|
|
46
|
+
});
|
|
47
|
+
const kindIcon = computed(() => {
|
|
48
|
+
const map = {
|
|
49
|
+
IMAGE: "i-lucide-image",
|
|
50
|
+
VIDEO: "i-lucide-film",
|
|
51
|
+
AUDIO: "i-lucide-music",
|
|
52
|
+
DOCUMENT: "i-lucide-file-text",
|
|
53
|
+
ARCHIVE: "i-lucide-archive",
|
|
54
|
+
FONT: "i-lucide-type",
|
|
55
|
+
MODEL_3D: "i-lucide-box",
|
|
56
|
+
WEB_APP: "i-lucide-globe"
|
|
57
|
+
};
|
|
58
|
+
return map[props.asset.kind?.toUpperCase()] ?? "i-lucide-file";
|
|
59
|
+
});
|
|
60
|
+
const isProcessing = computed(() => !!props.processingStream?.isProcessing.value);
|
|
61
|
+
const processingProgress = computed(() => props.processingStream?.progress.value ?? 0);
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<template>
|
|
65
|
+
<div
|
|
66
|
+
class="flex items-center px-3 gap-3 cursor-pointer transition-colors"
|
|
67
|
+
:class="[
|
|
68
|
+
selected ? 'bg-elevated/50 border-l-3 border-primary' : 'hover:bg-elevated/50 border-l-3 border-transparent',
|
|
69
|
+
isProcessing ? 'py-2' : 'h-16'
|
|
70
|
+
]"
|
|
71
|
+
@click="emit('click')"
|
|
72
|
+
>
|
|
73
|
+
<!-- Thumbnail -->
|
|
74
|
+
<div class="w-10 h-10 rounded-lg bg-muted shrink-0 flex items-center justify-center overflow-hidden relative">
|
|
75
|
+
<UIcon :name="kindIcon" class="text-muted text-lg" />
|
|
76
|
+
<!-- Pulsing dot for processing -->
|
|
77
|
+
<div v-if="isProcessing" class="absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-warning animate-pulse" />
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<!-- Info -->
|
|
81
|
+
<div class="flex flex-col min-w-0 flex-1">
|
|
82
|
+
<span class="text-sm font-bold truncate text-default">
|
|
83
|
+
{{ asset.original_filename || asset.title || asset.id.slice(0, 8) }}
|
|
84
|
+
</span>
|
|
85
|
+
<div class="flex items-center gap-1 mt-0.5">
|
|
86
|
+
<UBadge :color="kindColor" variant="subtle" size="sm">{{ asset.kind }}</UBadge>
|
|
87
|
+
<UBadge :color="statusColor" :variant="isProcessing ? 'solid' : 'subtle'" size="sm">{{ statusLabel }}</UBadge>
|
|
88
|
+
</div>
|
|
89
|
+
<!-- Processing progress bar -->
|
|
90
|
+
<UProgress
|
|
91
|
+
v-if="isProcessing"
|
|
92
|
+
:model-value="processingProgress"
|
|
93
|
+
size="2xs"
|
|
94
|
+
color="warning"
|
|
95
|
+
class="mt-1"
|
|
96
|
+
/>
|
|
97
|
+
<span v-else class="text-[10px] text-muted mt-0.5">{{ formattedSize }}</span>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AssetDetail } from "../../index.js";
|
|
2
|
+
import type { ProcessingStream } from "../../composables/useMLProcessingStatus.js";
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
asset: AssetDetail;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
processingStream?: ProcessingStream;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
click: () => any;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
11
|
+
onClick?: (() => any) | undefined;
|
|
12
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AssetDetail, UseMLAssetManagerReturn } from "../../index.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
asset: AssetDetail;
|
|
4
|
+
manager: UseMLAssetManagerReturn;
|
|
5
|
+
/** Show delete & reupload action (slot mode) */
|
|
6
|
+
allowReupload?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
deleted: (assetId: string) => any;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
11
|
+
onDeleted?: ((assetId: string) => any) | undefined;
|
|
12
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|