@antelopejs/dms-media 0.3.1 → 0.4.1
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 +57 -180
- package/dist/db/models/mediaAssets.model.d.ts +1 -0
- package/dist/db/models/mediaEvents.model.d.ts +1 -0
- package/dist/db/models/mediaFavorites.model.d.ts +1 -0
- package/dist/db/models/mediaFolders.model.d.ts +1 -0
- package/dist/db/models/mediaUploads.model.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/test/antelope.test.js +5 -5
- package/dist/test/helpers/pages.js +3 -2
- package/dist/test/helpers/pages.js.map +1 -1
- package/dist/test/integration/frontend-module.test.d.ts +1 -0
- package/dist/test/integration/frontend-module.test.js +13 -0
- package/dist/test/integration/frontend-module.test.js.map +1 -0
- package/frontend-vue/app/components/FileProperties.vue +9 -3
- package/frontend-vue/app/components/FirstRun.vue +1 -1
- package/frontend-vue/app/components/ImageEditor.vue +43 -26
- package/frontend-vue/app/components/PresetCards.vue +3 -11
- package/frontend-vue/app/components/RecentFiles.vue +6 -14
- package/frontend-vue/app/components/UploadQueue.vue +1 -1
- package/frontend-vue/app/components/UploadStrip.vue +1 -1
- package/frontend-vue/app/components/dialogs/DestinationDialog.vue +1 -2
- package/frontend-vue/app/components/explorer/ExplorerInspector.vue +17 -16
- package/frontend-vue/app/components/explorer/ExplorerShell.vue +11 -3
- package/frontend-vue/app/components/explorer/ExplorerToolbar.vue +2 -1
- package/frontend-vue/app/components/field/AssetValue.vue +12 -13
- package/frontend-vue/app/components/file/FileViewer.vue +1 -14
- package/frontend-vue/app/composables/library/useLibraryListing.ts +180 -79
- package/frontend-vue/app/composables/library/useLibraryTree.ts +31 -15
- package/frontend-vue/app/composables/library/useMediaLibrary.ts +17 -7
- package/frontend-vue/app/composables/uploadLimits.ts +25 -0
- package/frontend-vue/app/composables/useAssetContent.ts +20 -0
- package/frontend-vue/app/composables/useCurrentFile.ts +10 -8
- package/frontend-vue/app/composables/useFieldFolders.ts +19 -18
- package/frontend-vue/app/composables/useFileDetails.ts +117 -90
- package/frontend-vue/app/composables/useMediaApi.ts +18 -24
- package/frontend-vue/package.json +2 -1
- package/frontend-vue/pnpm-lock.yaml +17 -2
- package/frontend-vue/tests/engines.test.ts +20 -0
- package/frontend-vue/tests/fixtures/inertia.ts +8 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +200 -0
- package/frontend-vue/tests/fixtures/unhead.ts +3 -0
- package/frontend-vue/tests/fixtures/vueI18n.ts +4 -0
- package/frontend-vue/tests/libraryListing.test.ts +120 -0
- package/frontend-vue/tests/serverRender.test.ts +215 -0
- package/frontend-vue/vitest.config.ts +21 -0
- package/package.json +40 -16
- package/skills/dms-media/SKILL.md +64 -0
- package/src/index.ts +19 -2
- package/src/test/antelope.test.ts +5 -5
- package/src/test/helpers/pages.ts +3 -2
- package/src/test/integration/frontend-module.test.ts +13 -0
- package/frontend-vue/app/composables/useSharedTree.ts +0 -73
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { MediaTree } from '../types/media'
|
|
2
|
-
import type { MediaApi } from './useMediaApi'
|
|
3
|
-
|
|
4
|
-
const DEFAULT_MAX_UPLOAD_BYTES = 500 * 1024 * 1024
|
|
5
|
-
|
|
6
|
-
/** What the library takes at all, from the module config: every upload is checked against it before it is sent. */
|
|
7
|
-
export interface UploadLimits {
|
|
8
|
-
maxUploadBytes: number
|
|
9
|
-
/** Mimetype patterns the library accepts; any type until the server says otherwise. */
|
|
10
|
-
allowedMimetypes: readonly string[] | null
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const sharedTree = ref<MediaTree | null>(null)
|
|
14
|
-
const limits = ref<UploadLimits>({
|
|
15
|
-
maxUploadBytes: DEFAULT_MAX_UPLOAD_BYTES,
|
|
16
|
-
allowedMimetypes: null,
|
|
17
|
-
})
|
|
18
|
-
let pendingLoad: Promise<void> | null = null
|
|
19
|
-
let consumers = 0
|
|
20
|
-
|
|
21
|
-
/** The upload limits the server last sent, shared by every screen that uploads. */
|
|
22
|
-
export const uploadLimits = readonly(limits)
|
|
23
|
-
|
|
24
|
-
/** Keeps the upload limits a server answer carries. */
|
|
25
|
-
export function rememberUploadLimits(answer: UploadLimits): void {
|
|
26
|
-
limits.value = {
|
|
27
|
-
maxUploadBytes: answer.maxUploadBytes,
|
|
28
|
-
allowedMimetypes: answer.allowedMimetypes,
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Reads the folder tree (counted over `scopeFolderId` when given) and keeps the upload limits it carries. */
|
|
33
|
-
export async function fetchTree(
|
|
34
|
-
api: MediaApi,
|
|
35
|
-
scopeFolderId?: string,
|
|
36
|
-
): Promise<MediaTree> {
|
|
37
|
-
const tree = await api.tree(scopeFolderId)
|
|
38
|
-
rememberUploadLimits(tree)
|
|
39
|
-
return tree
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The folder tree every block of a page shares: read once when the first block
|
|
44
|
-
* mounts, read again on each library change, and dropped when the last block
|
|
45
|
-
* leaves so the next page starts from fresh data.
|
|
46
|
-
*/
|
|
47
|
-
export function useSharedTree() {
|
|
48
|
-
const api = useMediaApi()
|
|
49
|
-
|
|
50
|
-
function reload(): Promise<void> {
|
|
51
|
-
pendingLoad ??= fetchTree(api)
|
|
52
|
-
.then((tree) => {
|
|
53
|
-
sharedTree.value = tree
|
|
54
|
-
})
|
|
55
|
-
.catch(() => undefined)
|
|
56
|
-
.finally(() => {
|
|
57
|
-
pendingLoad = null
|
|
58
|
-
})
|
|
59
|
-
return pendingLoad
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
consumers += 1
|
|
63
|
-
onScopeDispose(() => {
|
|
64
|
-
consumers -= 1
|
|
65
|
-
if (consumers === 0) sharedTree.value = null
|
|
66
|
-
})
|
|
67
|
-
onMounted(() => {
|
|
68
|
-
if (!sharedTree.value) void reload()
|
|
69
|
-
})
|
|
70
|
-
onLibraryChange(reload)
|
|
71
|
-
|
|
72
|
-
return { tree: computed(() => sharedTree.value), reload }
|
|
73
|
-
}
|