sanity-plugin-mux-input 2.3.5 → 2.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-plugin-mux-input",
3
- "version": "2.3.5",
3
+ "version": "2.4.0",
4
4
  "description": "An input component that integrates Sanity Studio with Mux video encoding/hosting service.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -55,14 +55,14 @@
55
55
  "dependencies": {
56
56
  "@mux/mux-player-react": "^2.6.0",
57
57
  "@mux/upchunk": "^3.4.0",
58
- "@sanity/icons": "^2.11.8",
58
+ "@sanity/icons": "^3.0.0",
59
59
  "@sanity/incompatible-plugin": "^1.0.4",
60
60
  "@sanity/ui": "^2.1.11",
61
61
  "@sanity/uuid": "^3.0.2",
62
62
  "iso-639-1": "^3.1.2",
63
63
  "jsonwebtoken-esm": "^1.0.5",
64
64
  "lodash": "^4.17.21",
65
- "react-rx": "^2.1.3",
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,40 +71,38 @@
71
71
  "use-error-boundary": "^2.0.6"
72
72
  },
73
73
  "devDependencies": {
74
- "@commitlint/cli": "^19.3.0",
75
- "@commitlint/config-conventional": "^19.2.2",
76
- "@sanity/client": "^6.18.2",
77
- "@sanity/pkg-utils": "^6.8.16",
78
- "@sanity/plugin-kit": "4.0.12",
79
- "@sanity/semantic-release-preset": "^4.1.7",
80
- "@sanity/vision": "^3.42.1",
81
- "@types/lodash": "^4.17.4",
82
- "@types/react": "^18.3.2",
74
+ "@sanity/client": "^6.22.4",
75
+ "@sanity/pkg-utils": "^6.11.11",
76
+ "@sanity/plugin-kit": "4.0.18",
77
+ "@sanity/semantic-release-preset": "^5.0.0",
78
+ "@sanity/vision": "^3.64.1",
79
+ "@types/lodash": "^4.17.13",
80
+ "@types/react": "^18.3.12",
83
81
  "@types/react-is": "^18.3.0",
84
82
  "@types/styled-components": "^5.1.34",
85
- "@typescript-eslint/eslint-plugin": "^7.0.2",
86
- "@typescript-eslint/parser": "^7.0.2",
87
- "cz-conventional-changelog": "^3.3.0",
88
- "eslint": "^8.57.0",
83
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
84
+ "@typescript-eslint/parser": "^7.18.0",
85
+ "eslint": "^8.57.1",
89
86
  "eslint-config-prettier": "^9.1.0",
90
87
  "eslint-config-react-app": "^7.0.1",
91
- "eslint-config-sanity": "^7.1.2",
92
- "eslint-plugin-import": "^2.29.1",
93
- "eslint-plugin-prettier": "^5.1.3",
94
- "eslint-plugin-react-hooks": "^4.6.2",
95
- "eslint-plugin-simple-import-sort": "^12.1.0",
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.0.0",
92
+ "eslint-plugin-simple-import-sort": "^12.1.1",
96
93
  "husky": "^9.0.11",
97
94
  "lint-staged": "^15.2.2",
98
- "npm-run-all2": "^5.0.0",
99
- "prettier": "^3.2.5",
100
- "prettier-plugin-packagejson": "^2.5.0",
95
+ "npm-run-all2": "^5.0.2",
96
+ "prettier": "^3.3.3",
97
+ "prettier-plugin-packagejson": "^2.5.3",
101
98
  "react": "^18.3.1",
102
99
  "react-dom": "^18.3.1",
103
100
  "react-is": "^18.3.1",
104
101
  "rimraf": "^5.0.7",
105
- "sanity": "^3.42.1",
106
- "styled-components": "^6.1.11",
107
- "typescript": "^5.4.5",
102
+ "sanity": "^3.64.1",
103
+ "semantic-release": "^24.2.0",
104
+ "styled-components": "^6.1.13",
105
+ "typescript": "^5.6.3",
108
106
  "yalc": "1.0.0-pre.53"
109
107
  },
110
108
  "peerDependencies": {
@@ -1,10 +1,10 @@
1
1
  import {uuid as generateUuid} from '@sanity/uuid'
2
- import {concat, defer, from, of, throwError, type Observable} from 'rxjs'
2
+ import {concat, defer, from, type Observable, of, throwError} from 'rxjs'
3
3
  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, PluginConfig, UploadConfig} from '../util/types'
7
+ import type {MuxAsset, MuxNewAssetSettings} from '../util/types'
8
8
  import {getAsset} from './assets'
9
9
  import {testSecretsObservable} from './secrets'
10
10
 
@@ -1,8 +1,9 @@
1
- import {PropsWithChildren, useRef, useState} from 'react'
2
- import {Box, Button, Card, CardTone, Flex, Inline, Text} from '@sanity/ui'
3
- import {FileInputButton} from './FileInputButton'
4
1
  import {UploadIcon} from '@sanity/icons'
2
+ import {Card, CardTone, Flex, Inline} from '@sanity/ui'
3
+ import {PropsWithChildren, useRef, useState} from 'react'
4
+
5
5
  import {extractDroppedFiles} from '../util/extractFiles'
6
+ import {FileInputButton} from './FileInputButton'
6
7
 
7
8
  interface FileInputAreaProps extends PropsWithChildren {
8
9
  accept?: string
@@ -1,5 +1,5 @@
1
1
  import {Card} from '@sanity/ui'
2
- import React, {memo, Suspense} from 'react'
2
+ import {memo, Suspense} from 'react'
3
3
 
4
4
  import {useAssetDocumentValues} from '../hooks/useAssetDocumentValues'
5
5
  import {useClient} from '../hooks/useClient'
@@ -1,5 +1,5 @@
1
1
  import {Dialog} from '@sanity/ui'
2
- import React, {useCallback, useId} from 'react'
2
+ import {useCallback, useId} from 'react'
3
3
  import {styled} from 'styled-components'
4
4
 
5
5
  import type {SetDialogState} from '../hooks/useDialogState'
@@ -1,5 +1,5 @@
1
1
  import {Box, Dialog, Text} from '@sanity/ui'
2
- import React, {useId} from 'react'
2
+ import {useId} from 'react'
3
3
 
4
4
  interface Props {
5
5
  error: Error
@@ -1,4 +1,4 @@
1
- import React, {useId, useMemo} from 'react'
1
+ import {useId, useMemo} from 'react'
2
2
 
3
3
  // Mapping ids to ensure filter refs are unique, otherwise all Logo instances are hidden if the first SVG is hidden, due to how SVGs deal with relative links and ids
4
4
  const ids = [
@@ -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 React, {useCallback} from 'react'
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
- useClickOutside,
21
+ useClickOutsideEvent,
23
22
  } from '@sanity/ui'
24
- import React, {memo, useCallback, useEffect, useMemo, useState} from 'react'
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
- useClickOutside(
69
- useCallback(() => setOpen(false), []),
70
- [menuElement]
67
+ useClickOutsideEvent(
68
+ () => setOpen(false),
69
+ () => [menuElement]
71
70
  )
72
71
 
73
72
  return (
@@ -1,4 +1,4 @@
1
- import React, {useCallback} from 'react'
1
+ import {useCallback} from 'react'
2
2
  import {PatchEvent, set, setIfMissing, unset} from 'sanity'
3
3
 
4
4
  import type {SetDialogState} from '../hooks/useDialogState'
@@ -1,6 +1,6 @@
1
1
  import {SortIcon} from '@sanity/icons'
2
2
  import {Button, Menu, MenuButton, MenuItem, PopoverProps} from '@sanity/ui'
3
- import React, {useId} from 'react'
3
+ import {useId} from 'react'
4
4
 
5
5
  import {ASSET_SORT_OPTIONS, SortOption} from '../hooks/useAssets'
6
6
 
@@ -1,8 +1,7 @@
1
1
  import {PlugIcon, SearchIcon, UploadIcon} from '@sanity/icons'
2
2
  import {DocumentVideoIcon} from '@sanity/icons'
3
- import {Box, Button, Card, Flex, Inline, Text} from '@sanity/ui'
4
- import React, {useCallback} from 'react'
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'
@@ -1,7 +1,7 @@
1
1
  import {ErrorOutlineIcon} from '@sanity/icons'
2
2
  import {Button, CardTone, Flex, Text, useToast} from '@sanity/ui'
3
3
  import React, {useEffect, useReducer, useRef, useState} from 'react'
4
- import {Subject, Subscription, type Observable} from 'rxjs'
4
+ import {type Observable, Subject, Subscription} from 'rxjs'
5
5
  import {takeUntil, tap} from 'rxjs/operators'
6
6
  import type {SanityClient} from 'sanity'
7
7
  import {PatchEvent, set, setIfMissing} from 'sanity'
@@ -7,8 +7,8 @@ import {
7
7
  ErrorOutlineIcon,
8
8
  RevertIcon,
9
9
  SearchIcon,
10
- TrashIcon,
11
10
  TagIcon,
11
+ TrashIcon,
12
12
  } from '@sanity/icons'
13
13
  import {
14
14
  Button,
@@ -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,12 +1,12 @@
1
1
  import {ErrorOutlineIcon} from '@sanity/icons'
2
2
  import {Box, Card, CardTone, Spinner, Stack, Text} from '@sanity/ui'
3
- import React, {useMemo, useState} from 'react'
3
+ import {useMemo, useState} from 'react'
4
4
  import {styled} from 'styled-components'
5
5
 
6
6
  import {useClient} from '../hooks/useClient'
7
7
  import useInView from '../hooks/useInView'
8
8
  import {THUMBNAIL_ASPECT_RATIO} from '../util/constants'
9
- import {getAnimatedPosterSrc, type AnimatedPosterSrcOptions} from '../util/getAnimatedPosterSrc'
9
+ import {type AnimatedPosterSrcOptions, getAnimatedPosterSrc} from '../util/getAnimatedPosterSrc'
10
10
  import {VideoAssetDocument} from '../util/types'
11
11
 
12
12
  const Image = styled.img`
@@ -46,7 +46,7 @@ export default function VideoThumbnail({
46
46
  if (status !== 'error') setStatus('error')
47
47
  return undefined
48
48
  }
49
- }, [asset, client, width, status, setStatus])
49
+ }, [asset, client, posterWidth, status])
50
50
 
51
51
  function handleLoad() {
52
52
  setStatus('loaded')
@@ -2,8 +2,8 @@
2
2
  // https://github.com/sanity-io/sanity/blob/next/packages/sanity/src/desk/components/paneItem/PaneItemPreview.tsx
3
3
  import {Inline} from '@sanity/ui'
4
4
  import {isNumber, isString} from 'lodash'
5
- import {isValidElement} from 'react'
6
- import {useMemoObservable} from 'react-rx'
5
+ import {isValidElement, useMemo} from 'react'
6
+ import {useObservable} from 'react-rx'
7
7
  import type {SanityDocument, SchemaType} from 'sanity'
8
8
  import type {PreviewValue} from 'sanity'
9
9
  import {
@@ -44,12 +44,15 @@ export function PaneItemPreview(props: PaneItemPreviewProps) {
44
44
  ? value.title
45
45
  : null
46
46
 
47
- // NOTE: this emits sync so can never be null
48
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
49
- const {draft, published, isLoading} = useMemoObservable<PaneItemPreviewState>(
47
+ const observable = useMemo(
50
48
  () => getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, title),
51
- [props.documentPreviewStore, schemaType, value._id, title]
52
- )!
49
+ [props.documentPreviewStore, schemaType, title, value._id]
50
+ )
51
+ const {draft, published, isLoading} = useObservable(observable, {
52
+ draft: null,
53
+ published: null,
54
+ isLoading: true,
55
+ })
53
56
 
54
57
  const status = isLoading ? null : (
55
58
  <Inline space={4}>
@@ -1,5 +1,10 @@
1
1
  import type {PlaybackPolicy, VideoAssetDocument} from './types'
2
2
 
3
- export function getPlaybackPolicy(asset: Pick<VideoAssetDocument, 'data'>): PlaybackPolicy {
4
- return asset.data?.playback_ids?.[0]?.policy ?? 'public'
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,