@abraca/nuxt 2.76.0 → 2.78.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/dist/module.json +1 -1
- package/dist/runtime/components/editor/AFileAudioPlayer.d.vue.ts +12 -1
- package/dist/runtime/components/editor/AFileAudioPlayer.vue +9 -1
- package/dist/runtime/components/editor/AFileAudioPlayer.vue.d.ts +12 -1
- package/dist/runtime/components/editor/AFileVideoPlayer.d.vue.ts +5 -1
- package/dist/runtime/components/editor/AFileVideoPlayer.vue +2 -0
- package/dist/runtime/components/editor/AFileVideoPlayer.vue.d.ts +5 -1
- package/dist/runtime/components/renderers/AMediaRenderer.vue +2 -1
- package/dist/runtime/composables/useFileBlobStore.d.ts +1 -0
- package/dist/runtime/composables/useFileBlobStore.js +9 -1
- package/dist/runtime/composables/useMediaPlayback.d.ts +7 -0
- package/dist/runtime/composables/useMediaPlayback.js +3 -1
- package/dist/runtime/extensions/file-block.d.ts +1 -0
- package/dist/runtime/extensions/file-block.js +6 -1
- package/dist/runtime/extensions/views/FileNodeView.vue +43 -5
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -4,7 +4,18 @@ type __VLS_Props = {
|
|
|
4
4
|
artist?: string;
|
|
5
5
|
album?: string;
|
|
6
6
|
duration?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Whether `src` may be fetched in full for the waveform decode. `false` when
|
|
9
|
+
* `src` is a range-streamed server URL — downloading the whole file to draw
|
|
10
|
+
* a waveform would undo the point of streaming it. Defaults to `true` (an
|
|
11
|
+
* object URL is already local).
|
|
12
|
+
*/
|
|
13
|
+
analyzable?: boolean;
|
|
7
14
|
};
|
|
8
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
error: () => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
onError?: (() => any) | undefined;
|
|
19
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
20
|
declare const _default: typeof __VLS_export;
|
|
10
21
|
export default _default;
|
|
@@ -5,8 +5,10 @@ const props = defineProps({
|
|
|
5
5
|
filename: { type: String, required: true },
|
|
6
6
|
artist: { type: String, required: false },
|
|
7
7
|
album: { type: String, required: false },
|
|
8
|
-
duration: { type: Number, required: false }
|
|
8
|
+
duration: { type: Number, required: false },
|
|
9
|
+
analyzable: { type: Boolean, required: false }
|
|
9
10
|
});
|
|
11
|
+
const emit = defineEmits(["error"]);
|
|
10
12
|
const canvasRef = ref(null);
|
|
11
13
|
const audioRef = ref(null);
|
|
12
14
|
const isPlaying = ref(false);
|
|
@@ -39,6 +41,11 @@ async function analyzeAudio(url) {
|
|
|
39
41
|
waveformReady.value = false;
|
|
40
42
|
waveformFailed.value = false;
|
|
41
43
|
waveformBars.value = [];
|
|
44
|
+
if (props.analyzable === false) {
|
|
45
|
+
waveformFailed.value = true;
|
|
46
|
+
renderCanvas();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
42
49
|
try {
|
|
43
50
|
const response = await fetch(url);
|
|
44
51
|
const arrayBuffer = await response.arrayBuffer();
|
|
@@ -344,6 +351,7 @@ watch(() => props.src, (newSrc) => {
|
|
|
344
351
|
preload="metadata"
|
|
345
352
|
@ended="onAudioEnded"
|
|
346
353
|
@loadedmetadata="onAudioLoadedMetadata"
|
|
354
|
+
@error="emit('error')"
|
|
347
355
|
/>
|
|
348
356
|
</div>
|
|
349
357
|
</template>
|
|
@@ -4,7 +4,18 @@ type __VLS_Props = {
|
|
|
4
4
|
artist?: string;
|
|
5
5
|
album?: string;
|
|
6
6
|
duration?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Whether `src` may be fetched in full for the waveform decode. `false` when
|
|
9
|
+
* `src` is a range-streamed server URL — downloading the whole file to draw
|
|
10
|
+
* a waveform would undo the point of streaming it. Defaults to `true` (an
|
|
11
|
+
* object URL is already local).
|
|
12
|
+
*/
|
|
13
|
+
analyzable?: boolean;
|
|
7
14
|
};
|
|
8
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
error: () => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
onError?: (() => any) | undefined;
|
|
19
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
20
|
declare const _default: typeof __VLS_export;
|
|
10
21
|
export default _default;
|
|
@@ -2,6 +2,10 @@ type __VLS_Props = {
|
|
|
2
2
|
src: string;
|
|
3
3
|
filename: string;
|
|
4
4
|
};
|
|
5
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
error: () => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
onError?: (() => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
10
|
declare const _default: typeof __VLS_export;
|
|
7
11
|
export default _default;
|
|
@@ -4,6 +4,7 @@ defineProps({
|
|
|
4
4
|
src: { type: String, required: true },
|
|
5
5
|
filename: { type: String, required: true }
|
|
6
6
|
});
|
|
7
|
+
const emit = defineEmits(["error"]);
|
|
7
8
|
const videoRef = ref(null);
|
|
8
9
|
function requestFullscreen() {
|
|
9
10
|
videoRef.value?.requestFullscreen();
|
|
@@ -53,6 +54,7 @@ function requestFullscreen() {
|
|
|
53
54
|
controls
|
|
54
55
|
class="fv-video"
|
|
55
56
|
:aria-label="filename"
|
|
57
|
+
@error="emit('error')"
|
|
56
58
|
/>
|
|
57
59
|
</div>
|
|
58
60
|
</template>
|
|
@@ -2,6 +2,10 @@ type __VLS_Props = {
|
|
|
2
2
|
src: string;
|
|
3
3
|
filename: string;
|
|
4
4
|
};
|
|
5
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
error: () => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
onError?: (() => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
10
|
declare const _default: typeof __VLS_export;
|
|
7
11
|
export default _default;
|
|
@@ -41,7 +41,7 @@ const { mediaItems, groupedMedia } = useMediaExtractor(
|
|
|
41
41
|
);
|
|
42
42
|
const mediaElementRef = shallowRef(null);
|
|
43
43
|
const myClientId = computed(() => props.childProvider?.awareness?.clientID ?? 0);
|
|
44
|
-
const { getBlobUrl } = useFileBlobStore();
|
|
44
|
+
const { getBlobUrl, getStreamUrl } = useFileBlobStore();
|
|
45
45
|
const savedDocMeta = computed(() => tree.treeMap.data?.[props.docId]?.meta);
|
|
46
46
|
const repeatMode = ref(savedDocMeta.value?.mediaRepeat ?? "off");
|
|
47
47
|
watch(() => savedDocMeta.value?.mediaRepeat, (v) => {
|
|
@@ -72,6 +72,7 @@ const playback = useMediaPlayback({
|
|
|
72
72
|
repeatMode,
|
|
73
73
|
shuffle: shuffleEnabled,
|
|
74
74
|
getBlobUrl,
|
|
75
|
+
getStreamUrl,
|
|
75
76
|
useSyncedMap,
|
|
76
77
|
onTrackChange: (track) => {
|
|
77
78
|
setLocalState({ "media:trackId": track.id });
|
|
@@ -38,6 +38,7 @@ export interface ThumbOptions {
|
|
|
38
38
|
export declare const THUMB_SIZES: readonly [64, 128, 256, 512, 1024];
|
|
39
39
|
export declare function useFileBlobStore(): {
|
|
40
40
|
getBlobUrl: (docId: string, uploadId: string) => Promise<string | null>;
|
|
41
|
+
getStreamUrl: (docId: string, uploadId: string) => Promise<string | null>;
|
|
41
42
|
getThumbUrl: (docId: string, uploadId: string, opts?: ThumbOptions) => Promise<string | null>;
|
|
42
43
|
invalidateThumbUrl: (docId: string, uploadId: string, opts?: ThumbOptions) => void;
|
|
43
44
|
putBlob: (docId: string, id: string, file: File, filename: string) => Promise<void>;
|
|
@@ -25,6 +25,14 @@ export function useFileBlobStore() {
|
|
|
25
25
|
if (!_store) return null;
|
|
26
26
|
return _store.getBlobUrl(docId, uploadId);
|
|
27
27
|
}
|
|
28
|
+
async function getStreamUrl(docId, uploadId) {
|
|
29
|
+
if (!_store) return null;
|
|
30
|
+
try {
|
|
31
|
+
return await _store.getStreamUrl?.(docId, uploadId) ?? null;
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
28
36
|
async function getThumbUrl(docId, uploadId, opts = {}) {
|
|
29
37
|
if (!_store) return null;
|
|
30
38
|
try {
|
|
@@ -40,5 +48,5 @@ export function useFileBlobStore() {
|
|
|
40
48
|
if (!_store) return;
|
|
41
49
|
return _store.putBlob(docId, id, file, filename);
|
|
42
50
|
}
|
|
43
|
-
return { getBlobUrl, getThumbUrl, invalidateThumbUrl, putBlob };
|
|
51
|
+
return { getBlobUrl, getStreamUrl, getThumbUrl, invalidateThumbUrl, putBlob };
|
|
44
52
|
}
|
|
@@ -8,6 +8,13 @@ export interface UseMediaPlaybackOptions {
|
|
|
8
8
|
repeatMode: Ref<string>;
|
|
9
9
|
shuffle: Ref<boolean>;
|
|
10
10
|
getBlobUrl: (docId: string, uploadId: string) => Promise<string | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Optional range-streamed URL resolver (`useFileBlobStore().getStreamUrl`).
|
|
13
|
+
* When supplied and it resolves, playback starts and scrubs immediately
|
|
14
|
+
* instead of waiting for the whole file to download; `getBlobUrl` remains
|
|
15
|
+
* the offline fallback.
|
|
16
|
+
*/
|
|
17
|
+
getStreamUrl?: (docId: string, uploadId: string) => Promise<string | null>;
|
|
11
18
|
useSyncedMap: <T = any>(doc: ShallowRef<Y.Doc | null>, mapName: string) => {
|
|
12
19
|
data: Record<string, T>;
|
|
13
20
|
yMap: Ref<Y.Map<T> | null>;
|
|
@@ -7,7 +7,7 @@ const DRIFT_RATE_FAST = 1.02;
|
|
|
7
7
|
const DRIFT_RATE_SLOW = 0.98;
|
|
8
8
|
const DRIFT_RATE_DURATION = 2e3;
|
|
9
9
|
export function useMediaPlayback(options) {
|
|
10
|
-
const { mediaElementRef, childDoc, playlist, repeatMode, shuffle, getBlobUrl, useSyncedMap, onTrackChange } = options;
|
|
10
|
+
const { mediaElementRef, childDoc, playlist, repeatMode, shuffle, getBlobUrl, getStreamUrl, useSyncedMap, onTrackChange } = options;
|
|
11
11
|
const currentTrack = shallowRef(null);
|
|
12
12
|
const currentTrackIndex = ref(-1);
|
|
13
13
|
const isPlaying = ref(false);
|
|
@@ -32,6 +32,8 @@ export function useMediaPlayback(options) {
|
|
|
32
32
|
async function loadTrackBlob(track) {
|
|
33
33
|
isLoading.value = true;
|
|
34
34
|
try {
|
|
35
|
+
const streamed = await getStreamUrl?.(track.docId, track.uploadId);
|
|
36
|
+
if (streamed) return streamed;
|
|
35
37
|
return await getBlobUrl(track.docId, track.uploadId);
|
|
36
38
|
} finally {
|
|
37
39
|
isLoading.value = false;
|
|
@@ -11,7 +11,12 @@ export const FileBlock = Node.create({
|
|
|
11
11
|
uploadId: { default: null },
|
|
12
12
|
docId: { default: null },
|
|
13
13
|
filename: { default: "" },
|
|
14
|
-
mimeType: { default: "" }
|
|
14
|
+
mimeType: { default: "" },
|
|
15
|
+
// Byte size as a string. `useDocImport` has always set this on the
|
|
16
|
+
// element; without the attribute declared, ProseMirror dropped it —
|
|
17
|
+
// so size-aware behaviour (the audio streaming gate) never fired.
|
|
18
|
+
// Mirrors cou-sh's file-block.
|
|
19
|
+
fileSize: { default: null }
|
|
15
20
|
};
|
|
16
21
|
},
|
|
17
22
|
parseHTML() {
|
|
@@ -20,13 +20,16 @@ const props = defineProps({
|
|
|
20
20
|
extension: { type: Object, required: true },
|
|
21
21
|
HTMLAttributes: { type: Object, required: true }
|
|
22
22
|
});
|
|
23
|
-
const { getBlobUrl, getThumbUrl } = useFileBlobStore();
|
|
23
|
+
const { getBlobUrl, getStreamUrl, getThumbUrl } = useFileBlobStore();
|
|
24
24
|
const { client } = useAbracadabra();
|
|
25
25
|
const uploadId = computed(() => props.node.attrs.uploadId);
|
|
26
26
|
const docId = computed(() => props.node.attrs.docId);
|
|
27
27
|
const filename = computed(() => props.node.attrs.filename);
|
|
28
28
|
const mimeType = computed(() => props.node.attrs.mimeType);
|
|
29
|
+
const fileSize = computed(() => props.node.attrs.fileSize);
|
|
29
30
|
const blobUrl = ref(null);
|
|
31
|
+
const streamUrl = ref(null);
|
|
32
|
+
const mediaUrl = computed(() => streamUrl.value || blobUrl.value);
|
|
30
33
|
const loading = ref(true);
|
|
31
34
|
const error = ref(null);
|
|
32
35
|
const fileCategory = computed(() => {
|
|
@@ -46,6 +49,33 @@ const fileIcon = computed(() => {
|
|
|
46
49
|
if (fn.endsWith(".zip") || fn.endsWith(".tar") || fn.endsWith(".gz") || fn.endsWith(".rar")) return "i-lucide-file-archive";
|
|
47
50
|
return "i-lucide-file";
|
|
48
51
|
});
|
|
52
|
+
const WAVEFORM_MAX_BYTES = 25 * 1024 * 1024;
|
|
53
|
+
const prefersStreaming = computed(() => {
|
|
54
|
+
if (fileCategory.value === "video") return true;
|
|
55
|
+
if (fileCategory.value !== "audio") return false;
|
|
56
|
+
return Number(fileSize.value ?? 0) > WAVEFORM_MAX_BYTES;
|
|
57
|
+
});
|
|
58
|
+
async function loadStream() {
|
|
59
|
+
try {
|
|
60
|
+
const url = await getStreamUrl(docId.value, uploadId.value);
|
|
61
|
+
if (url) {
|
|
62
|
+
streamUrl.value = url;
|
|
63
|
+
error.value = null;
|
|
64
|
+
loading.value = false;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error("[FileNodeView] stream URL failed, falling back to blob", uploadId.value, e);
|
|
69
|
+
}
|
|
70
|
+
return loadBlob();
|
|
71
|
+
}
|
|
72
|
+
let mediaErrorCount = 0;
|
|
73
|
+
function handleMediaError() {
|
|
74
|
+
if (!streamUrl.value || mediaErrorCount > 1) return;
|
|
75
|
+
mediaErrorCount++;
|
|
76
|
+
streamUrl.value = null;
|
|
77
|
+
loadBlob();
|
|
78
|
+
}
|
|
49
79
|
async function loadBlob() {
|
|
50
80
|
if (!docId.value || !uploadId.value) {
|
|
51
81
|
loading.value = false;
|
|
@@ -74,9 +104,14 @@ async function loadBlob() {
|
|
|
74
104
|
loading.value = false;
|
|
75
105
|
}
|
|
76
106
|
}
|
|
77
|
-
|
|
107
|
+
function load() {
|
|
108
|
+
if (!docId.value || !uploadId.value) return loadBlob();
|
|
109
|
+
if (prefersStreaming.value) return loadStream();
|
|
110
|
+
return loadBlob();
|
|
111
|
+
}
|
|
112
|
+
onMounted(load);
|
|
78
113
|
watch(client, (c) => {
|
|
79
|
-
if (c && !blobUrl.value)
|
|
114
|
+
if (c && !blobUrl.value && !streamUrl.value) load();
|
|
80
115
|
});
|
|
81
116
|
</script>
|
|
82
117
|
|
|
@@ -125,15 +160,18 @@ watch(client, (c) => {
|
|
|
125
160
|
<!-- Video -->
|
|
126
161
|
<AFileVideoPlayer
|
|
127
162
|
v-else-if="fileCategory === 'video'"
|
|
128
|
-
:src="
|
|
163
|
+
:src="mediaUrl"
|
|
129
164
|
:filename="filename"
|
|
165
|
+
@error="handleMediaError"
|
|
130
166
|
/>
|
|
131
167
|
|
|
132
168
|
<!-- Audio -->
|
|
133
169
|
<AFileAudioPlayer
|
|
134
170
|
v-else-if="fileCategory === 'audio'"
|
|
135
|
-
:src="
|
|
171
|
+
:src="mediaUrl"
|
|
172
|
+
:analyzable="!streamUrl"
|
|
136
173
|
:filename="filename"
|
|
174
|
+
@error="handleMediaError"
|
|
137
175
|
/>
|
|
138
176
|
|
|
139
177
|
<!-- GLB / glTF — three.js peer dep loaded async -->
|