sanity-plugin-mux-input 2.3.6 → 2.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/LICENSE +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +322 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +324 -118
- package/dist/index.mjs.map +1 -1
- package/package.json +24 -24
- package/src/actions/upload.ts +1 -1
- package/src/components/FileInputArea.tsx +1 -1
- package/src/components/Input.tsx +1 -1
- package/src/components/InputBrowser.tsx +1 -1
- package/src/components/InputError.tsx +1 -1
- package/src/components/MuxLogo.tsx +1 -1
- package/src/components/Onboard.tsx +1 -1
- package/src/components/PlayerActionsMenu.tsx +5 -6
- package/src/components/SelectAsset.tsx +1 -1
- package/src/components/SelectSortOptions.tsx +1 -1
- package/src/components/UploadPlaceholder.tsx +2 -3
- package/src/components/VideoDetails/VideoDetails.tsx +7 -0
- package/src/components/VideoThumbnail.tsx +2 -2
- package/src/hooks/useAssets.ts +29 -23
- package/src/util/getPlaybackPolicy.ts +7 -2
- package/src/util/getVideoMetadata.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-mux-input",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "An input component that integrates Sanity Studio with Mux video encoding/hosting service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"iso-639-1": "^3.1.2",
|
|
63
63
|
"jsonwebtoken-esm": "^1.0.5",
|
|
64
64
|
"lodash": "^4.17.21",
|
|
65
|
-
"react-rx": "^
|
|
65
|
+
"react-rx": "^4.1.5",
|
|
66
66
|
"rxjs": "^7.8.1",
|
|
67
67
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
68
68
|
"suspend-react": "^0.1.3",
|
|
@@ -71,38 +71,38 @@
|
|
|
71
71
|
"use-error-boundary": "^2.0.6"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@sanity/client": "^6.
|
|
75
|
-
"@sanity/pkg-utils": "^6.
|
|
76
|
-
"@sanity/plugin-kit": "4.0.
|
|
74
|
+
"@sanity/client": "^6.24.1",
|
|
75
|
+
"@sanity/pkg-utils": "^6.12.1",
|
|
76
|
+
"@sanity/plugin-kit": "4.0.19",
|
|
77
77
|
"@sanity/semantic-release-preset": "^5.0.0",
|
|
78
|
-
"@sanity/vision": "^3.
|
|
79
|
-
"@types/lodash": "^4.17.
|
|
80
|
-
"@types/react": "^18.3.
|
|
81
|
-
"@types/react-is": "^18.3.
|
|
78
|
+
"@sanity/vision": "^3.68.1",
|
|
79
|
+
"@types/lodash": "^4.17.13",
|
|
80
|
+
"@types/react": "^18.3.17",
|
|
81
|
+
"@types/react-is": "^18.3.1",
|
|
82
82
|
"@types/styled-components": "^5.1.34",
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^7.0
|
|
84
|
-
"@typescript-eslint/parser": "^7.0
|
|
85
|
-
"eslint": "^8.57.
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
84
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
85
|
+
"eslint": "^8.57.1",
|
|
86
86
|
"eslint-config-prettier": "^9.1.0",
|
|
87
87
|
"eslint-config-react-app": "^7.0.1",
|
|
88
|
-
"eslint-config-sanity": "^7.1.
|
|
89
|
-
"eslint-plugin-import": "^2.
|
|
90
|
-
"eslint-plugin-prettier": "^5.1
|
|
91
|
-
"eslint-plugin-react-hooks": "^
|
|
92
|
-
"eslint-plugin-simple-import-sort": "^12.1.
|
|
88
|
+
"eslint-config-sanity": "^7.1.3",
|
|
89
|
+
"eslint-plugin-import": "^2.31.0",
|
|
90
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
91
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
92
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
93
93
|
"husky": "^9.0.11",
|
|
94
94
|
"lint-staged": "^15.2.2",
|
|
95
|
-
"npm-run-all2": "^5.0.
|
|
96
|
-
"prettier": "^3.2
|
|
97
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
95
|
+
"npm-run-all2": "^5.0.2",
|
|
96
|
+
"prettier": "^3.4.2",
|
|
97
|
+
"prettier-plugin-packagejson": "^2.5.6",
|
|
98
98
|
"react": "^18.3.1",
|
|
99
99
|
"react-dom": "^18.3.1",
|
|
100
100
|
"react-is": "^18.3.1",
|
|
101
101
|
"rimraf": "^5.0.7",
|
|
102
|
-
"sanity": "^3.
|
|
103
|
-
"semantic-release": "^24.
|
|
104
|
-
"styled-components": "^6.1.
|
|
105
|
-
"typescript": "^5.
|
|
102
|
+
"sanity": "^3.68.1",
|
|
103
|
+
"semantic-release": "^24.2.0",
|
|
104
|
+
"styled-components": "^6.1.13",
|
|
105
|
+
"typescript": "^5.7.2",
|
|
106
106
|
"yalc": "1.0.0-pre.53"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
package/src/actions/upload.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {catchError, mergeMap, mergeMapTo, switchMap} from 'rxjs/operators'
|
|
|
4
4
|
import type {SanityClient} from 'sanity'
|
|
5
5
|
|
|
6
6
|
import {createUpChunkObservable} from '../clients/upChunkObservable'
|
|
7
|
-
import type {MuxAsset, MuxNewAssetSettings
|
|
7
|
+
import type {MuxAsset, MuxNewAssetSettings} from '../util/types'
|
|
8
8
|
import {getAsset} from './assets'
|
|
9
9
|
import {testSecretsObservable} from './secrets'
|
|
10
10
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {UploadIcon} from '@sanity/icons'
|
|
2
|
-
import {
|
|
2
|
+
import {Card, CardTone, Flex, Inline} from '@sanity/ui'
|
|
3
3
|
import {PropsWithChildren, useRef, useState} from 'react'
|
|
4
4
|
|
|
5
5
|
import {extractDroppedFiles} from '../util/extractFiles'
|
package/src/components/Input.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {PlugIcon} from '@sanity/icons'
|
|
2
2
|
import {Button, Card, Flex, Grid, Heading, Inline} from '@sanity/ui'
|
|
3
|
-
import
|
|
3
|
+
import {useCallback} from 'react'
|
|
4
4
|
|
|
5
5
|
import type {SetDialogState} from '../hooks/useDialogState'
|
|
6
6
|
import MuxLogo from './MuxLogo'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EllipsisHorizontalIcon,
|
|
3
|
-
EllipsisVerticalIcon,
|
|
4
3
|
LockIcon,
|
|
5
4
|
PlugIcon,
|
|
6
5
|
ResetIcon,
|
|
@@ -19,9 +18,9 @@ import {
|
|
|
19
18
|
Popover,
|
|
20
19
|
Text,
|
|
21
20
|
Tooltip,
|
|
22
|
-
|
|
21
|
+
useClickOutsideEvent,
|
|
23
22
|
} from '@sanity/ui'
|
|
24
|
-
import
|
|
23
|
+
import {memo, useCallback, useEffect, useMemo, useState} from 'react'
|
|
25
24
|
import {PatchEvent, unset} from 'sanity'
|
|
26
25
|
import {styled} from 'styled-components'
|
|
27
26
|
|
|
@@ -65,9 +64,9 @@ function PlayerActionsMenu(
|
|
|
65
64
|
}
|
|
66
65
|
}, [dialogState, open])
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
[menuElement]
|
|
67
|
+
useClickOutsideEvent(
|
|
68
|
+
() => setOpen(false),
|
|
69
|
+
() => [menuElement]
|
|
71
70
|
)
|
|
72
71
|
|
|
73
72
|
return (
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {PlugIcon, SearchIcon, UploadIcon} from '@sanity/icons'
|
|
2
2
|
import {DocumentVideoIcon} from '@sanity/icons'
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {styled} from 'styled-components'
|
|
3
|
+
import {Button, Card, Flex, Inline, Text} from '@sanity/ui'
|
|
4
|
+
import {useCallback} from 'react'
|
|
6
5
|
|
|
7
6
|
import type {SetDialogState} from '../hooks/useDialogState'
|
|
8
7
|
import {FileInputButton, type FileInputButtonProps} from './FileInputButton'
|
|
@@ -280,6 +280,13 @@ const VideoDetails: React.FC<VideoDetailsProps> = (props) => {
|
|
|
280
280
|
size={2}
|
|
281
281
|
/>
|
|
282
282
|
<IconInfo text={`Mux ID: \n${displayInfo.id}`} icon={TagIcon} size={2} />
|
|
283
|
+
{displayInfo?.playbackId && (
|
|
284
|
+
<IconInfo
|
|
285
|
+
text={`Playback ID: ${displayInfo.playbackId}`}
|
|
286
|
+
icon={TagIcon}
|
|
287
|
+
size={2}
|
|
288
|
+
/>
|
|
289
|
+
)}
|
|
283
290
|
</Stack>
|
|
284
291
|
</Stack>
|
|
285
292
|
</TabPanel>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ErrorOutlineIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Card, CardTone, Spinner, Stack, Text} from '@sanity/ui'
|
|
3
|
-
import
|
|
3
|
+
import {useMemo, useState} from 'react'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
import {useClient} from '../hooks/useClient'
|
|
@@ -46,7 +46,7 @@ export default function VideoThumbnail({
|
|
|
46
46
|
if (status !== 'error') setStatus('error')
|
|
47
47
|
return undefined
|
|
48
48
|
}
|
|
49
|
-
}, [asset, client,
|
|
49
|
+
}, [asset, client, posterWidth, status])
|
|
50
50
|
|
|
51
51
|
function handleLoad() {
|
|
52
52
|
setStatus('loaded')
|
package/src/hooks/useAssets.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {useMemo, useState} from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {useObservable} from 'react-rx'
|
|
3
|
+
import {collate, DocumentStore, useDocumentStore} from 'sanity'
|
|
3
4
|
|
|
4
5
|
import {SANITY_API_VERSION} from '../hooks/useClient'
|
|
5
6
|
import {createSearchFilter} from '../util/createSearchFilter'
|
|
@@ -14,44 +15,49 @@ export const ASSET_SORT_OPTIONS = {
|
|
|
14
15
|
|
|
15
16
|
export type SortOption = keyof typeof ASSET_SORT_OPTIONS
|
|
16
17
|
|
|
17
|
-
const useAssetDocuments =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
18
|
+
const useAssetDocuments = ({
|
|
19
|
+
documentStore,
|
|
20
|
+
sort,
|
|
21
|
+
searchQuery,
|
|
22
|
+
}: {
|
|
23
|
+
documentStore: DocumentStore
|
|
24
|
+
sort: SortOption
|
|
25
|
+
searchQuery: string
|
|
26
|
+
}): VideoAssetDocument[] | undefined => {
|
|
27
|
+
const memoizedObservable = useMemo(() => {
|
|
28
|
+
const search = createSearchFilter(searchQuery)
|
|
29
|
+
const filter = [`_type == "mux.videoAsset"`, ...search.filter].filter(Boolean).join(' && ')
|
|
30
|
+
const sortFragment = ASSET_SORT_OPTIONS[sort].groq
|
|
31
|
+
return documentStore.listenQuery(
|
|
32
|
+
/* groq */ `*[${filter}] | order(${sortFragment})`,
|
|
33
|
+
search.params,
|
|
34
|
+
{
|
|
35
|
+
apiVersion: SANITY_API_VERSION,
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}, [documentStore, sort, searchQuery])
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/* groq */ `*[${filter}] | order(${sortFragment})`,
|
|
31
|
-
search.params,
|
|
32
|
-
{
|
|
33
|
-
apiVersion: SANITY_API_VERSION,
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
-
})
|
|
40
|
+
return useObservable(memoizedObservable, undefined)
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
export default function useAssets() {
|
|
39
44
|
const documentStore = useDocumentStore()
|
|
40
45
|
const [sort, setSort] = useState<SortOption>('createdDesc')
|
|
41
46
|
const [searchQuery, setSearchQuery] = useState('')
|
|
42
47
|
|
|
43
|
-
const
|
|
48
|
+
const assetDocumentsObservable = useAssetDocuments({documentStore, sort, searchQuery})
|
|
49
|
+
const isLoading = assetDocumentsObservable === undefined
|
|
44
50
|
const assets = useMemo(
|
|
45
51
|
() =>
|
|
46
52
|
// Avoid displaying both drafts & published assets by collating them together and giving preference to drafts
|
|
47
|
-
collate<VideoAssetDocument>(
|
|
53
|
+
collate<VideoAssetDocument>(assetDocumentsObservable ?? []).map(
|
|
48
54
|
(collated) =>
|
|
49
55
|
({
|
|
50
56
|
...(collated.draft || collated.published || {}),
|
|
51
57
|
_id: collated.id,
|
|
52
58
|
}) as VideoAssetDocument
|
|
53
59
|
),
|
|
54
|
-
[
|
|
60
|
+
[assetDocumentsObservable]
|
|
55
61
|
)
|
|
56
62
|
|
|
57
63
|
return {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type {PlaybackPolicy, VideoAssetDocument} from './types'
|
|
2
2
|
|
|
3
|
-
export function getPlaybackPolicy(
|
|
4
|
-
|
|
3
|
+
export function getPlaybackPolicy(
|
|
4
|
+
asset: Pick<VideoAssetDocument, 'data' | 'playbackId'>
|
|
5
|
+
): PlaybackPolicy {
|
|
6
|
+
return (
|
|
7
|
+
asset.data?.playback_ids?.find((playbackId) => asset.playbackId === playbackId.id)?.policy ??
|
|
8
|
+
'public'
|
|
9
|
+
)
|
|
5
10
|
}
|
|
@@ -10,6 +10,7 @@ export default function getVideoMetadata(doc: VideoAssetDocument) {
|
|
|
10
10
|
return {
|
|
11
11
|
title: doc.filename || id.slice(0, 12),
|
|
12
12
|
id: id,
|
|
13
|
+
playbackId: doc.playbackId,
|
|
13
14
|
createdAt: date,
|
|
14
15
|
duration: doc.data?.duration ? formatSeconds(doc.data?.duration) : undefined,
|
|
15
16
|
aspect_ratio: doc.data?.aspect_ratio,
|