sanity-plugin-mux-input 2.0.4 → 2.0.5

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.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "An input component that integrates Sanity Studio with Mux video encoding/hosting service.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -25,8 +25,8 @@
25
25
  ".": {
26
26
  "types": "./lib/index.d.ts",
27
27
  "source": "./src/index.ts",
28
- "import": "./lib/index.esm.js",
29
28
  "require": "./lib/index.js",
29
+ "import": "./lib/index.esm.js",
30
30
  "default": "./lib/index.esm.js"
31
31
  },
32
32
  "./package.json": "./package.json"
@@ -56,58 +56,58 @@
56
56
  "format": "prettier --write --cache --ignore-unknown ."
57
57
  },
58
58
  "dependencies": {
59
- "@mux/playback-core": "^0.11.0",
60
- "@mux/upchunk": "^3.0.0",
59
+ "@mux/mux-video-react": "^0.7",
60
+ "@mux/upchunk": "^3",
61
61
  "@sanity/icons": "^2",
62
62
  "@sanity/incompatible-plugin": "^1",
63
63
  "@sanity/ui": "^1",
64
64
  "@sanity/uuid": "^3",
65
65
  "classnames": "^2.3.2",
66
66
  "jsonwebtoken-esm": "^1.0.3",
67
- "media-chrome": "^0.16.0",
68
- "motion": "^10.14.3",
67
+ "media-chrome": "^0.17.0",
68
+ "motion": "^10",
69
69
  "rxjs": "^7",
70
- "scroll-into-view-if-needed": "^3.0.3",
71
- "suspend-react": "^0.0.8",
72
- "swr": "^1.3.0",
73
- "use-device-pixel-ratio": "^1.1.0",
70
+ "scroll-into-view-if-needed": "^3",
71
+ "suspend-react": "^0.0.9",
72
+ "swr": "^2.0.0",
73
+ "use-device-pixel-ratio": "^1.1.2",
74
74
  "use-error-boundary": "^2.0.6"
75
75
  },
76
76
  "devDependencies": {
77
- "@commitlint/cli": "^17.2.0",
78
- "@commitlint/config-conventional": "^17.2.0",
79
- "@sanity/pkg-utils": "^2.1.0",
80
- "@sanity/plugin-kit": "^3.1.1",
81
- "@sanity/semantic-release-preset": "^2.0.2",
82
- "@sanity/vision": "^3.0.0",
77
+ "@commitlint/cli": "^17.4.2",
78
+ "@commitlint/config-conventional": "^17.4.2",
79
+ "@sanity/pkg-utils": "^2.2.1",
80
+ "@sanity/plugin-kit": "^3.1.4",
81
+ "@sanity/semantic-release-preset": "^3.0.2",
82
+ "@sanity/vision": "^3.2.3",
83
83
  "@types/react": "^18.0.26",
84
84
  "@types/styled-components": "^5.1.26",
85
- "@typescript-eslint/eslint-plugin": "^5.48.0",
86
- "@typescript-eslint/parser": "^5.48.0",
85
+ "@typescript-eslint/eslint-plugin": "^5.48.1",
86
+ "@typescript-eslint/parser": "^5.48.1",
87
87
  "cz-conventional-changelog": "^3.3.0",
88
88
  "eslint": "^8.31.0",
89
89
  "eslint-config-prettier": "^8.6.0",
90
90
  "eslint-config-react-app": "^7.0.1",
91
91
  "eslint-config-sanity": "^6.0.0",
92
- "eslint-plugin-import": "^2.26.0",
92
+ "eslint-plugin-import": "^2.27.4",
93
93
  "eslint-plugin-prettier": "^4.2.1",
94
- "eslint-plugin-react": "^7.31.11",
94
+ "eslint-plugin-react": "^7.32.0",
95
95
  "eslint-plugin-react-hooks": "^4.6.0",
96
96
  "eslint-plugin-simple-import-sort": "^8.0.0",
97
- "husky": "^8.0.2",
98
- "lint-staged": "^13.0.3",
99
- "next": "^13.0.2",
100
- "next-sanity": "^1.0.9",
97
+ "husky": "^8.0.3",
98
+ "lint-staged": "^13.1.0",
99
+ "next": "^13.1.2",
100
+ "next-sanity": "^4.0.6",
101
101
  "npm-run-all": "^4.1.5",
102
- "prettier": "^2.8.1",
102
+ "prettier": "^2.8.3",
103
103
  "prettier-plugin-packagejson": "^2.3.0",
104
104
  "react": "^18.2.0",
105
105
  "react-dom": "^18.2.0",
106
106
  "react-is": "^18.2.0",
107
- "rimraf": "^3.0.2",
108
- "sanity": "^3.1.4",
107
+ "rimraf": "^4.0.4",
108
+ "sanity": "^3.2.3",
109
109
  "styled-components": "^5.3.6",
110
- "type-fest": "^3.2.0",
110
+ "type-fest": "^3.5.1",
111
111
  "typescript": "^4.9.4"
112
112
  },
113
113
  "peerDependencies": {
@@ -1,4 +1,4 @@
1
- import {type PlaybackEngine, generatePlayerInitTime, initialize} from '@mux/playback-core'
1
+ import MuxVideo from '@mux/mux-video-react'
2
2
  import {Card, Text} from '@sanity/ui'
3
3
  import {
4
4
  MediaControlBar,
@@ -35,7 +35,7 @@ interface Props extends Pick<MuxInputProps, 'onChange' | 'readOnly'> {
35
35
  setDialogState: SetDialogState
36
36
  }
37
37
 
38
- const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogState}: Props) => {
38
+ const MuxVideoOld = ({asset, buttons, readOnly, onChange, dialogState, setDialogState}: Props) => {
39
39
  const client = useClient()
40
40
  const isLoading = useMemo<boolean | string>(() => {
41
41
  if (asset?.status === 'preparing') {
@@ -88,25 +88,6 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
88
88
  muteRef.current.shadowRoot.appendChild(style.cloneNode(true))
89
89
  }
90
90
  }, [])
91
- const [playerInitTime] = useState(() => generatePlayerInitTime())
92
- const playbackEngineRef = useRef<PlaybackEngine | undefined>(undefined)
93
-
94
- useEffect(() => {
95
- if (isLoading || !videoSrc) {
96
- return
97
- }
98
- const nextPlaybackEngineRef = initialize(
99
- {
100
- src: videoSrc,
101
- playerInitTime,
102
- playerSoftwareName: 'sanity-plugin-mux-input',
103
- playerSoftwareVersion: 'dev-preview',
104
- },
105
- video.current,
106
- playbackEngineRef.current
107
- )
108
- playbackEngineRef.current = nextPlaybackEngineRef
109
- }, [videoSrc, isLoading, playerInitTime])
110
91
 
111
92
  useEffect(() => {
112
93
  if (asset?.status === 'errored') {
@@ -117,6 +98,15 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
117
98
  }
118
99
  }, [asset.data?.errors?.messages, asset?.status, handleCancelUpload])
119
100
 
101
+ const signedToken = useMemo(() => {
102
+ try {
103
+ const url = new URL(videoSrc!)
104
+ return url.searchParams.get('token')
105
+ } catch {
106
+ return false
107
+ }
108
+ }, [videoSrc])
109
+
120
110
  if (error) {
121
111
  // @TODO better error handling
122
112
  throw error
@@ -141,16 +131,17 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
141
131
  <>
142
132
  <VideoContainer shadow={1} tone="transparent" scheme="dark">
143
133
  <MediaController>
144
- <video
134
+ <MuxVideo
145
135
  playsInline
146
136
  ref={video}
137
+ playbackId={`${asset.playbackId}${signedToken ? `?token=${signedToken}` : ''}`}
147
138
  onError={handleError}
148
139
  slot="media"
149
140
  preload="metadata"
150
141
  crossOrigin="anonomous"
151
142
  >
152
143
  <ThumbnailsMetadataTrack asset={asset} />
153
- </video>
144
+ </MuxVideo>
154
145
  <PosterImage asset={asset} />
155
146
  <MediaLoadingIndicator slot="centered-chrome" noAutoHide />
156
147
  <StyledCenterControls slot="centered-chrome">
@@ -193,4 +184,4 @@ const MuxVideo = ({asset, buttons, readOnly, onChange, dialogState, setDialogSta
193
184
  )
194
185
  }
195
186
 
196
- export default MuxVideo
187
+ export default MuxVideoOld