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
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
onUnmounted,
|
|
4
|
+
ref,
|
|
5
|
+
toValue,
|
|
6
|
+
watch
|
|
7
|
+
} from "vue";
|
|
8
|
+
import { $fetch } from "ofetch";
|
|
9
|
+
import { useMLProcessingStatus } from "./useMLProcessingStatus.js";
|
|
10
|
+
function formatStepName(name) {
|
|
11
|
+
return name.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
12
|
+
}
|
|
13
|
+
function getDefaults(schema) {
|
|
14
|
+
const defaults = {};
|
|
15
|
+
for (const [key, opt] of Object.entries(schema)) {
|
|
16
|
+
if (opt.default !== void 0) defaults[key] = opt.default;
|
|
17
|
+
}
|
|
18
|
+
return defaults;
|
|
19
|
+
}
|
|
20
|
+
export function useMLProcessingStepper(assetId) {
|
|
21
|
+
const steps = ref([]);
|
|
22
|
+
const loading = ref(false);
|
|
23
|
+
const currentStepIndex = ref(0);
|
|
24
|
+
const { track, closeAll } = useMLProcessingStatus();
|
|
25
|
+
let stream = null;
|
|
26
|
+
async function fetchAndHydrate() {
|
|
27
|
+
const id = toValue(assetId);
|
|
28
|
+
if (!id) return;
|
|
29
|
+
loading.value = true;
|
|
30
|
+
try {
|
|
31
|
+
const res = await $fetch(
|
|
32
|
+
`/api/media-library/manage/processing/assets/${encodeURIComponent(id)}/tasks`
|
|
33
|
+
);
|
|
34
|
+
console.log(res);
|
|
35
|
+
const pipeline = res.pipeline ?? [];
|
|
36
|
+
const schemas = res.pipeline_steps_schema ?? res.pipelineStepsSchema ?? {};
|
|
37
|
+
const existingTasks = res.items ?? [];
|
|
38
|
+
const taskByType = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const t of existingTasks) {
|
|
40
|
+
taskByType.set(t.task_type, t);
|
|
41
|
+
}
|
|
42
|
+
const built = pipeline.map((name, index) => {
|
|
43
|
+
const schema = schemas[name] ?? {};
|
|
44
|
+
const task = taskByType.get(name) ?? null;
|
|
45
|
+
const hasOptions = Object.keys(schema).length > 0;
|
|
46
|
+
let status = "pending";
|
|
47
|
+
let error = null;
|
|
48
|
+
if (task) {
|
|
49
|
+
const ts = task.status?.toLowerCase();
|
|
50
|
+
if (ts === "succeeded" || ts === "completed") status = "succeeded";
|
|
51
|
+
else if (ts === "failed") {
|
|
52
|
+
status = "failed";
|
|
53
|
+
error = task.last_error;
|
|
54
|
+
} else if (ts === "queued") status = "queued";
|
|
55
|
+
else if (ts === "running") status = "running";
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
name,
|
|
59
|
+
displayName: formatStepName(name),
|
|
60
|
+
index,
|
|
61
|
+
status,
|
|
62
|
+
task,
|
|
63
|
+
optionsSchema: schema,
|
|
64
|
+
userOptions: getDefaults(schema),
|
|
65
|
+
isLocked: false,
|
|
66
|
+
isActive: false,
|
|
67
|
+
hasOptions,
|
|
68
|
+
error
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
steps.value = built;
|
|
72
|
+
console.log(steps.value);
|
|
73
|
+
recomputeLocks();
|
|
74
|
+
if (built.some((s) => s.status === "queued" || s.status === "running")) {
|
|
75
|
+
openStream();
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
steps.value = [];
|
|
79
|
+
} finally {
|
|
80
|
+
loading.value = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function recomputeLocks() {
|
|
84
|
+
const list = steps.value;
|
|
85
|
+
let firstPending = -1;
|
|
86
|
+
for (let i = 0; i < list.length; i++) {
|
|
87
|
+
if (i === 0) {
|
|
88
|
+
list[i].isLocked = false;
|
|
89
|
+
} else {
|
|
90
|
+
const prev = list[i - 1].status;
|
|
91
|
+
list[i].isLocked = prev !== "succeeded" && prev !== "skipped";
|
|
92
|
+
}
|
|
93
|
+
list[i].isActive = false;
|
|
94
|
+
if (firstPending === -1 && list[i].status !== "succeeded" && list[i].status !== "skipped") {
|
|
95
|
+
firstPending = i;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (firstPending >= 0) {
|
|
99
|
+
currentStepIndex.value = firstPending;
|
|
100
|
+
const step = list[firstPending];
|
|
101
|
+
if (!step.isLocked && step.status !== "running") {
|
|
102
|
+
step.isActive = true;
|
|
103
|
+
step.status = step.status === "pending" ? "configuring" : step.status;
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
currentStepIndex.value = list.length;
|
|
107
|
+
}
|
|
108
|
+
steps.value = [...list];
|
|
109
|
+
}
|
|
110
|
+
function updateStepOptions(stepName, options) {
|
|
111
|
+
const step = steps.value.find((s) => s.name === stepName);
|
|
112
|
+
if (step) {
|
|
113
|
+
step.userOptions = { ...options };
|
|
114
|
+
steps.value = [...steps.value];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async function runStep(stepName) {
|
|
118
|
+
const id = toValue(assetId);
|
|
119
|
+
if (!id) return;
|
|
120
|
+
const step = steps.value.find((s) => s.name === stepName);
|
|
121
|
+
if (!step || step.isLocked) return;
|
|
122
|
+
step.status = "running";
|
|
123
|
+
step.isActive = false;
|
|
124
|
+
step.error = null;
|
|
125
|
+
steps.value = [...steps.value];
|
|
126
|
+
try {
|
|
127
|
+
await $fetch(
|
|
128
|
+
`/api/media-library/manage/processing/assets/${encodeURIComponent(id)}/process`,
|
|
129
|
+
{
|
|
130
|
+
method: "POST",
|
|
131
|
+
body: {
|
|
132
|
+
steps: [stepName],
|
|
133
|
+
stepOptions: Object.keys(step.userOptions).length > 0 ? { [stepName]: step.userOptions } : void 0
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
openStream();
|
|
138
|
+
} catch (err) {
|
|
139
|
+
step.status = "failed";
|
|
140
|
+
step.error = err?.data?.detail ?? err?.message ?? "Failed to trigger step";
|
|
141
|
+
steps.value = [...steps.value];
|
|
142
|
+
recomputeLocks();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function skipStep(stepName) {
|
|
146
|
+
const step = steps.value.find((s) => s.name === stepName);
|
|
147
|
+
if (!step || step.isLocked) return;
|
|
148
|
+
step.status = "skipped";
|
|
149
|
+
step.error = null;
|
|
150
|
+
recomputeLocks();
|
|
151
|
+
}
|
|
152
|
+
async function retryStep(stepName) {
|
|
153
|
+
const step = steps.value.find((s) => s.name === stepName);
|
|
154
|
+
if (!step) return;
|
|
155
|
+
step.status = "configuring";
|
|
156
|
+
step.error = null;
|
|
157
|
+
step.isActive = true;
|
|
158
|
+
steps.value = [...steps.value];
|
|
159
|
+
}
|
|
160
|
+
async function runRemaining() {
|
|
161
|
+
const pending = steps.value.filter(
|
|
162
|
+
(s) => s.status !== "succeeded" && s.status !== "skipped"
|
|
163
|
+
);
|
|
164
|
+
for (const step of pending) {
|
|
165
|
+
if (step.isLocked) continue;
|
|
166
|
+
await runStep(step.name);
|
|
167
|
+
await waitForStep(step.name);
|
|
168
|
+
if (step.status === "failed") break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function waitForStep(stepName) {
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
const check = setInterval(() => {
|
|
174
|
+
const step = steps.value.find((s) => s.name === stepName);
|
|
175
|
+
if (!step || step.status === "succeeded" || step.status === "failed" || step.status === "skipped") {
|
|
176
|
+
clearInterval(check);
|
|
177
|
+
resolve();
|
|
178
|
+
}
|
|
179
|
+
}, 500);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
let sseWatchStop = null;
|
|
183
|
+
function openStream() {
|
|
184
|
+
const id = toValue(assetId);
|
|
185
|
+
if (!id || stream) return;
|
|
186
|
+
stream = track(id);
|
|
187
|
+
let debounce = null;
|
|
188
|
+
sseWatchStop = watch(stream.taskEvents, () => {
|
|
189
|
+
if (debounce) clearTimeout(debounce);
|
|
190
|
+
debounce = setTimeout(() => refreshTasks(), 500);
|
|
191
|
+
}, { deep: true });
|
|
192
|
+
}
|
|
193
|
+
async function refreshTasks() {
|
|
194
|
+
const id = toValue(assetId);
|
|
195
|
+
if (!id) return;
|
|
196
|
+
try {
|
|
197
|
+
const res = await $fetch(
|
|
198
|
+
`/api/media-library/manage/processing/assets/${encodeURIComponent(id)}/tasks`
|
|
199
|
+
);
|
|
200
|
+
const existingTasks = res.items ?? [];
|
|
201
|
+
const taskByType = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const t of existingTasks) {
|
|
203
|
+
taskByType.set(t.task_type, t);
|
|
204
|
+
}
|
|
205
|
+
for (const step of steps.value) {
|
|
206
|
+
const task = taskByType.get(step.name);
|
|
207
|
+
if (!task) continue;
|
|
208
|
+
step.task = task;
|
|
209
|
+
const ts = task.status?.toLowerCase();
|
|
210
|
+
if (ts === "succeeded" || ts === "completed") {
|
|
211
|
+
step.status = "succeeded";
|
|
212
|
+
step.error = null;
|
|
213
|
+
} else if (ts === "failed") {
|
|
214
|
+
step.status = "failed";
|
|
215
|
+
step.error = task.last_error;
|
|
216
|
+
} else if (ts === "queued") {
|
|
217
|
+
step.status = "queued";
|
|
218
|
+
} else if (ts === "running") {
|
|
219
|
+
step.status = "running";
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
recomputeLocks();
|
|
223
|
+
} catch {
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const currentStep = computed(
|
|
227
|
+
() => currentStepIndex.value < steps.value.length ? steps.value[currentStepIndex.value] : null
|
|
228
|
+
);
|
|
229
|
+
const allComplete = computed(
|
|
230
|
+
() => steps.value.length > 0 && steps.value.every((s) => s.status === "succeeded" || s.status === "skipped")
|
|
231
|
+
);
|
|
232
|
+
const hasAnyFailed = computed(
|
|
233
|
+
() => steps.value.some((s) => s.status === "failed")
|
|
234
|
+
);
|
|
235
|
+
const progressPercent = computed(() => {
|
|
236
|
+
if (!steps.value.length) return 0;
|
|
237
|
+
const done = steps.value.filter((s) => s.status === "succeeded" || s.status === "skipped").length;
|
|
238
|
+
return Math.round(done / steps.value.length * 100);
|
|
239
|
+
});
|
|
240
|
+
watch(() => toValue(assetId), () => {
|
|
241
|
+
steps.value = [];
|
|
242
|
+
currentStepIndex.value = 0;
|
|
243
|
+
if (sseWatchStop) {
|
|
244
|
+
sseWatchStop();
|
|
245
|
+
sseWatchStop = null;
|
|
246
|
+
}
|
|
247
|
+
if (stream) {
|
|
248
|
+
stream.close();
|
|
249
|
+
stream = null;
|
|
250
|
+
}
|
|
251
|
+
void fetchAndHydrate();
|
|
252
|
+
}, { immediate: true });
|
|
253
|
+
function cleanup() {
|
|
254
|
+
if (sseWatchStop) {
|
|
255
|
+
sseWatchStop();
|
|
256
|
+
sseWatchStop = null;
|
|
257
|
+
}
|
|
258
|
+
if (stream) {
|
|
259
|
+
stream.close();
|
|
260
|
+
stream = null;
|
|
261
|
+
}
|
|
262
|
+
closeAll();
|
|
263
|
+
}
|
|
264
|
+
onUnmounted(cleanup);
|
|
265
|
+
return {
|
|
266
|
+
steps,
|
|
267
|
+
loading,
|
|
268
|
+
currentStepIndex,
|
|
269
|
+
currentStep,
|
|
270
|
+
allComplete,
|
|
271
|
+
hasAnyFailed,
|
|
272
|
+
progressPercent,
|
|
273
|
+
updateStepOptions,
|
|
274
|
+
runStep,
|
|
275
|
+
skipStep,
|
|
276
|
+
retryStep,
|
|
277
|
+
runRemaining,
|
|
278
|
+
cleanup
|
|
279
|
+
};
|
|
280
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AssetKind } from '../types/resourcePolicy.js';
|
|
2
|
+
export declare const RENDITION_PIPELINE: string[];
|
|
3
|
+
export declare const useMLProcessingStrategies: () => {
|
|
4
|
+
getPipeline: (kind: AssetKind) => string[];
|
|
5
|
+
isConfigurable: (stepName: string) => boolean;
|
|
6
|
+
getDefaultOptions: (stepName: string) => Record<string, any>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AssetKind } from "../types/resourcePolicy.js";
|
|
2
|
+
const PIPELINES = {
|
|
3
|
+
[AssetKind.Image]: ["virus_scan", "image_derive", "relocate_to_bucket"],
|
|
4
|
+
[AssetKind.ImageBatch]: ["virus_scan", "zip_image_extract"],
|
|
5
|
+
[AssetKind.Video]: ["virus_scan", "video_transcode", "video_adaptive_stream", "relocate_to_volume", "video_thumbnail", "backup"],
|
|
6
|
+
[AssetKind.Audio]: ["virus_scan", "relocate_to_volume", "backup"],
|
|
7
|
+
[AssetKind.Document]: ["virus_scan", "relocate_to_bucket"],
|
|
8
|
+
[AssetKind.Archive]: ["virus_scan", "relocate_to_bucket"],
|
|
9
|
+
[AssetKind.Font]: ["virus_scan", "relocate_to_bucket"],
|
|
10
|
+
[AssetKind.Model3D]: ["virus_scan", "relocate_to_bucket"],
|
|
11
|
+
[AssetKind.WebApp]: ["virus_scan", "deploy_web_app"],
|
|
12
|
+
[AssetKind.Other]: ["virus_scan", "backup"]
|
|
13
|
+
};
|
|
14
|
+
export const RENDITION_PIPELINE = ["virus_scan", "relocate_to_bucket", "backup"];
|
|
15
|
+
const CONFIGURABLE_STEPS = {
|
|
16
|
+
image_derive: {
|
|
17
|
+
defaultOptions: () => ({ formats: ["webp"], sizes: [640], quality: 80 })
|
|
18
|
+
},
|
|
19
|
+
video_transcode: {
|
|
20
|
+
defaultOptions: () => ({ codec: "h264", resolution: "1920x1080", bitrate: "5000k" })
|
|
21
|
+
},
|
|
22
|
+
video_thumbnail: {
|
|
23
|
+
defaultOptions: () => ({ timestamp: 1, sizes: [320], quality: 80 })
|
|
24
|
+
},
|
|
25
|
+
video_adaptive_stream: {
|
|
26
|
+
defaultOptions: () => ({ format: "hls", resolutions: ["1920x1080", "1280x720", "854x480"] })
|
|
27
|
+
},
|
|
28
|
+
backup: {
|
|
29
|
+
defaultOptions: () => ({ compression: 6, destination: "" })
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const useMLProcessingStrategies = () => {
|
|
33
|
+
const getPipeline = (kind) => {
|
|
34
|
+
return PIPELINES[kind] ?? PIPELINES[AssetKind.Other];
|
|
35
|
+
};
|
|
36
|
+
const isConfigurable = (stepName) => {
|
|
37
|
+
return stepName in CONFIGURABLE_STEPS;
|
|
38
|
+
};
|
|
39
|
+
const getDefaultOptions = (stepName) => {
|
|
40
|
+
return CONFIGURABLE_STEPS[stepName]?.defaultOptions() ?? {};
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
getPipeline,
|
|
44
|
+
isConfigurable,
|
|
45
|
+
getDefaultOptions
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function useMLRepeater(list) {
|
|
2
|
+
const add = (item) => list.push(item);
|
|
3
|
+
const removeAt = (idx) => list.splice(idx, 1);
|
|
4
|
+
const move = (from, to) => {
|
|
5
|
+
if (to < 0 || to >= list.length) return;
|
|
6
|
+
const removed = list.splice(from, 1);
|
|
7
|
+
if (removed.length === 0) return;
|
|
8
|
+
list.splice(to, 0, ...removed);
|
|
9
|
+
};
|
|
10
|
+
return { add, removeAt, move };
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@source "../components/**/*.{vue,js,ts}";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './composables/useMLChunkUploader.js';
|
|
2
|
+
export * from './composables/useMLProcessingStatus.js';
|
|
3
|
+
export * from './composables/useMLProcessingPipeline.js';
|
|
4
|
+
export * from './composables/useMLProcessingStepper.js';
|
|
5
|
+
export * from './composables/useMLAssetManager.js';
|
|
6
|
+
export * from './composables/useMLAssetLibrary.js';
|
|
7
|
+
export * from './composables/useMLAssetManagerPreview.js';
|
|
8
|
+
export * from './composables/useElapsedTimer.js';
|
|
9
|
+
export * from './composables/resourcePolicy/useMLResourcePolicy.js';
|
|
10
|
+
export * from './types/resourcePolicy.js';
|
|
11
|
+
export * from './types/uploader.js';
|
|
12
|
+
export * from './types/asset.js';
|
|
13
|
+
export * from './utils/uploader/uploader.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./composables/useMLChunkUploader.js";
|
|
2
|
+
export * from "./composables/useMLProcessingStatus.js";
|
|
3
|
+
export * from "./composables/useMLProcessingPipeline.js";
|
|
4
|
+
export * from "./composables/useMLProcessingStepper.js";
|
|
5
|
+
export * from "./composables/useMLAssetManager.js";
|
|
6
|
+
export * from "./composables/useMLAssetLibrary.js";
|
|
7
|
+
export * from "./composables/useMLAssetManagerPreview.js";
|
|
8
|
+
export * from "./composables/useElapsedTimer.js";
|
|
9
|
+
export * from "./composables/resourcePolicy/useMLResourcePolicy.js";
|
|
10
|
+
export * from "./types/resourcePolicy.js";
|
|
11
|
+
export * from "./types/uploader.js";
|
|
12
|
+
export * from "./types/asset.js";
|
|
13
|
+
export * from "./utils/uploader/uploader.js";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
|
2
|
+
import { watch } from "vue";
|
|
3
|
+
import { useMLAssetPreview } from "../composables/useMLAssetPreview.js";
|
|
4
|
+
function applyAssetToElement(el, asset, arg) {
|
|
5
|
+
if (!asset || !asset.url) return;
|
|
6
|
+
if (arg === "bg") {
|
|
7
|
+
el.style.backgroundImage = `url("${asset.url}")`;
|
|
8
|
+
if (!el.style.backgroundSize) el.style.backgroundSize = "cover";
|
|
9
|
+
if (!el.style.backgroundPosition) el.style.backgroundPosition = "center";
|
|
10
|
+
} else {
|
|
11
|
+
const imgEl = el;
|
|
12
|
+
imgEl.src = asset.url;
|
|
13
|
+
const altFromMeta = typeof asset.metadata?.alt === "string" ? asset.metadata.alt : void 0;
|
|
14
|
+
if (!imgEl.alt && altFromMeta) {
|
|
15
|
+
imgEl.alt = altFromMeta;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function setupWatcher(el, id, arg) {
|
|
20
|
+
if (el.__assetStopHandle__) {
|
|
21
|
+
el.__assetStopHandle__();
|
|
22
|
+
el.__assetStopHandle__ = void 0;
|
|
23
|
+
}
|
|
24
|
+
if (!id) return;
|
|
25
|
+
const store = useMLAssetPreview();
|
|
26
|
+
el.__assetStopHandle__ = watch(
|
|
27
|
+
() => store.getAsset(id),
|
|
28
|
+
(asset) => {
|
|
29
|
+
applyAssetToElement(el, asset, arg);
|
|
30
|
+
},
|
|
31
|
+
{ immediate: true }
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const assetDirective = {
|
|
35
|
+
mounted(el, binding) {
|
|
36
|
+
if (import.meta.server) return;
|
|
37
|
+
const id = binding.value || "";
|
|
38
|
+
const arg = binding.arg;
|
|
39
|
+
el.__assetId__ = id;
|
|
40
|
+
const store = useMLAssetPreview();
|
|
41
|
+
store.register(id);
|
|
42
|
+
setupWatcher(el, id, arg);
|
|
43
|
+
},
|
|
44
|
+
updated(el, binding) {
|
|
45
|
+
if (import.meta.server) return;
|
|
46
|
+
const newId = binding.value || "";
|
|
47
|
+
const oldId = binding.oldValue || "";
|
|
48
|
+
const arg = binding.arg;
|
|
49
|
+
if (newId === oldId) return;
|
|
50
|
+
el.__assetId__ = newId;
|
|
51
|
+
const store = useMLAssetPreview();
|
|
52
|
+
store.register(newId);
|
|
53
|
+
setupWatcher(el, newId, arg);
|
|
54
|
+
},
|
|
55
|
+
unmounted(el) {
|
|
56
|
+
if (el.__assetStopHandle__) {
|
|
57
|
+
el.__assetStopHandle__();
|
|
58
|
+
el.__assetStopHandle__ = void 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
63
|
+
nuxtApp.vueApp.directive("asset", assetDirective);
|
|
64
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChunkUploaderConfig } from '../types/uploader.js';
|
|
2
|
+
declare module '#app' {
|
|
3
|
+
interface NuxtApp {
|
|
4
|
+
$chunkUploader: ChunkUploaderConfig;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare module 'vue' {
|
|
8
|
+
interface ComponentCustomProperties {
|
|
9
|
+
$chunkUploader: ChunkUploaderConfig;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
3
|
+
const config = useRuntimeConfig();
|
|
4
|
+
const publicCfg = config.public?.mediaLibrary;
|
|
5
|
+
const routes = publicCfg?.routes;
|
|
6
|
+
if (!routes?.createSession || !routes?.getSession || !routes?.uploadPart || !routes?.finalize) {
|
|
7
|
+
throw new Error("ChunkUploader routes are required. Please provide createSession, getSession, uploadPart, and finalize.");
|
|
8
|
+
}
|
|
9
|
+
const cfg = {
|
|
10
|
+
baseURL: publicCfg?.baseURL ?? "",
|
|
11
|
+
routes,
|
|
12
|
+
proxyUploads: publicCfg?.proxyUploads ?? true,
|
|
13
|
+
partSize: publicCfg?.partSize ?? 8 * 1024 * 1024,
|
|
14
|
+
concurrency: publicCfg?.concurrency ?? 3,
|
|
15
|
+
checksum: {
|
|
16
|
+
algorithm: publicCfg?.checksum?.algorithm ?? "SHA-256",
|
|
17
|
+
perPart: publicCfg?.checksum?.perPart ?? true,
|
|
18
|
+
final: publicCfg?.checksum?.final ?? true
|
|
19
|
+
},
|
|
20
|
+
headers: publicCfg?.headers ?? {}
|
|
21
|
+
};
|
|
22
|
+
nuxtApp.provide("chunkUploader", cfg);
|
|
23
|
+
});
|