sanity-plugin-mux-input 3.0.4 → 4.0.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.
Files changed (130) hide show
  1. package/README.md +0 -2
  2. package/dist/index.d.ts +134 -193
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2893 -4417
  5. package/dist/index.js.map +1 -1
  6. package/package.json +33 -43
  7. package/dist/index.cjs +0 -7270
  8. package/dist/index.cjs.map +0 -1
  9. package/dist/index.d.cts +0 -347
  10. package/sanity.json +0 -8
  11. package/src/_exports/index.ts +0 -73
  12. package/src/actions/assets.ts +0 -152
  13. package/src/actions/secrets.ts +0 -111
  14. package/src/actions/upload.ts +0 -310
  15. package/src/clients/upChunkObservable.ts +0 -54
  16. package/src/components/AddCaptionDialog.tsx +0 -440
  17. package/src/components/CaptionsDialog.tsx +0 -23
  18. package/src/components/ConfigureApi.styled.tsx +0 -19
  19. package/src/components/ConfigureApi.tsx +0 -296
  20. package/src/components/DraggableWatermark.tsx +0 -877
  21. package/src/components/EditCaptionDialog.tsx +0 -510
  22. package/src/components/EditThumbnailDialog.tsx +0 -122
  23. package/src/components/ErrorBoundaryCard.tsx +0 -96
  24. package/src/components/FileInputButton.tsx +0 -54
  25. package/src/components/FileInputMenuItem.styled.tsx +0 -36
  26. package/src/components/FileInputMenuItem.tsx +0 -85
  27. package/src/components/FormField.tsx +0 -38
  28. package/src/components/IconInfo.tsx +0 -22
  29. package/src/components/ImportVideosFromMux.tsx +0 -342
  30. package/src/components/Input.styled.tsx +0 -22
  31. package/src/components/Input.tsx +0 -78
  32. package/src/components/InputBrowser.tsx +0 -41
  33. package/src/components/InputError.tsx +0 -17
  34. package/src/components/MuxLogo.tsx +0 -42
  35. package/src/components/Onboard.tsx +0 -65
  36. package/src/components/PageSelector.tsx +0 -54
  37. package/src/components/Player.styled.tsx +0 -55
  38. package/src/components/Player.tsx +0 -117
  39. package/src/components/PlayerActionsMenu.tsx +0 -190
  40. package/src/components/ResyncMetadata.tsx +0 -280
  41. package/src/components/SelectAsset.tsx +0 -39
  42. package/src/components/SelectSortOptions.tsx +0 -45
  43. package/src/components/SpinnerBox.tsx +0 -16
  44. package/src/components/StudioTool.tsx +0 -24
  45. package/src/components/TextTracksEditor.tsx +0 -117
  46. package/src/components/TextTracksManager.tsx +0 -737
  47. package/src/components/UploadConfiguration.tsx +0 -694
  48. package/src/components/UploadPlaceholder.tsx +0 -88
  49. package/src/components/UploadProgress.tsx +0 -80
  50. package/src/components/Uploader.styled.tsx +0 -66
  51. package/src/components/Uploader.tsx +0 -498
  52. package/src/components/VideoDetails/DeleteDialog.tsx +0 -147
  53. package/src/components/VideoDetails/VideoDetails.tsx +0 -358
  54. package/src/components/VideoDetails/VideoReferences.tsx +0 -63
  55. package/src/components/VideoDetails/useVideoDetails.ts +0 -103
  56. package/src/components/VideoInBrowser.tsx +0 -245
  57. package/src/components/VideoMetadata.tsx +0 -45
  58. package/src/components/VideoPlayer.tsx +0 -235
  59. package/src/components/VideoThumbnail.tsx +0 -138
  60. package/src/components/VideosBrowser.tsx +0 -100
  61. package/src/components/documentPreview/DocumentPreview.tsx +0 -83
  62. package/src/components/documentPreview/DraftStatus.tsx +0 -34
  63. package/src/components/documentPreview/MissingSchemaType.tsx +0 -32
  64. package/src/components/documentPreview/PaneItemPreview.tsx +0 -74
  65. package/src/components/documentPreview/PublishedStatus.tsx +0 -35
  66. package/src/components/documentPreview/TimeAgo.tsx +0 -12
  67. package/src/components/documentPreview/paneItemTypes.ts +0 -7
  68. package/src/components/icons/Audio.tsx +0 -13
  69. package/src/components/icons/Resolution.tsx +0 -12
  70. package/src/components/icons/StopWatch.tsx +0 -20
  71. package/src/components/icons/ToolIcon.tsx +0 -19
  72. package/src/components/uploadConfiguration/PlaybackPolicy.tsx +0 -133
  73. package/src/components/uploadConfiguration/PlaybackPolicyOption.tsx +0 -76
  74. package/src/components/uploadConfiguration/PlaybackPolicyWarning.tsx +0 -29
  75. package/src/components/uploadConfiguration/ResolutionTierSelector.tsx +0 -72
  76. package/src/components/uploadConfiguration/StaticRenditionSelector.tsx +0 -180
  77. package/src/components/withFocusRing/helpers.ts +0 -24
  78. package/src/components/withFocusRing/index.ts +0 -1
  79. package/src/components/withFocusRing/withFocusRing.ts +0 -30
  80. package/src/context/DialogStateContext.tsx +0 -36
  81. package/src/context/DrmPlaybackWarningContext.tsx +0 -93
  82. package/src/hooks/useAccessControl.ts +0 -13
  83. package/src/hooks/useAssetDocumentValues.ts +0 -11
  84. package/src/hooks/useAssets.ts +0 -68
  85. package/src/hooks/useCancelUpload.ts +0 -22
  86. package/src/hooks/useClient.ts +0 -8
  87. package/src/hooks/useDialogState.ts +0 -11
  88. package/src/hooks/useDocReferences.ts +0 -21
  89. package/src/hooks/useFetchFileSize.ts +0 -54
  90. package/src/hooks/useImportMuxAssets.ts +0 -132
  91. package/src/hooks/useInView.ts +0 -42
  92. package/src/hooks/useMediaMetadata.ts +0 -103
  93. package/src/hooks/useMuxAssets.ts +0 -179
  94. package/src/hooks/useMuxPolling.ts +0 -49
  95. package/src/hooks/useResyncAsset.ts +0 -110
  96. package/src/hooks/useResyncMuxMetadata.ts +0 -176
  97. package/src/hooks/useSaveSecrets.ts +0 -78
  98. package/src/hooks/useSecretsDocumentValues.ts +0 -38
  99. package/src/hooks/useSecretsFormState.ts +0 -47
  100. package/src/plugin.tsx +0 -31
  101. package/src/sanity-ui.d.ts +0 -5
  102. package/src/schema.ts +0 -196
  103. package/src/util/addKeysToMuxData.ts +0 -30
  104. package/src/util/areSecretsSignable.ts +0 -5
  105. package/src/util/asserters.ts +0 -36
  106. package/src/util/assetTitlePlaceholder.ts +0 -31
  107. package/src/util/constants.ts +0 -15
  108. package/src/util/convertWatermarkToMux.ts +0 -160
  109. package/src/util/createSearchFilter.ts +0 -76
  110. package/src/util/createUrlParamsObject.ts +0 -29
  111. package/src/util/extractFiles.ts +0 -67
  112. package/src/util/formatBytes.ts +0 -32
  113. package/src/util/formatDriveShareLink.ts +0 -64
  114. package/src/util/formatSeconds.ts +0 -49
  115. package/src/util/generateJwt.ts +0 -57
  116. package/src/util/getAnimatedPosterSrc.ts +0 -26
  117. package/src/util/getPlaybackPolicy.ts +0 -69
  118. package/src/util/getPosterSrc.ts +0 -28
  119. package/src/util/getStoryboardSrc.ts +0 -27
  120. package/src/util/getVideoMetadata.ts +0 -23
  121. package/src/util/getVideoSrc.ts +0 -23
  122. package/src/util/isSigned.ts +0 -20
  123. package/src/util/parsers.ts +0 -5
  124. package/src/util/pluginVersion.ts +0 -1
  125. package/src/util/readSecrets.ts +0 -38
  126. package/src/util/roundPxString.ts +0 -16
  127. package/src/util/textTracks.ts +0 -222
  128. package/src/util/tryWithSuspend.ts +0 -22
  129. package/src/util/types.ts +0 -596
  130. package/v2-incompatible.js +0 -11
@@ -1,296 +0,0 @@
1
- import {
2
- Box,
3
- Button,
4
- Card,
5
- Checkbox,
6
- Code,
7
- Dialog,
8
- Flex,
9
- Inline,
10
- Stack,
11
- Text,
12
- TextInput,
13
- } from '@sanity/ui'
14
- import {useCallback, useEffect, useId, useMemo, useRef} from 'react'
15
- import {clear, preload} from 'suspend-react'
16
-
17
- import {useClient} from '../hooks/useClient'
18
- import type {SetDialogState} from '../hooks/useDialogState'
19
- import {useDialogState} from '../hooks/useDialogState'
20
- import {useSaveSecrets} from '../hooks/useSaveSecrets'
21
- import {useSecretsDocumentValues} from '../hooks/useSecretsDocumentValues'
22
- import {useSecretsFormState} from '../hooks/useSecretsFormState'
23
- import {cacheNs, DIALOGS_Z_INDEX} from '../util/constants'
24
- import {_id as secretsId} from '../util/readSecrets'
25
- import type {Secrets} from '../util/types'
26
- import {Header} from './ConfigureApi.styled'
27
- import FormField from './FormField'
28
-
29
- // Props for the dialog component when used with external state management
30
- export interface ConfigureApiDialogProps {
31
- setDialogState: SetDialogState
32
- secrets: Secrets
33
- }
34
-
35
- const fieldNames = ['token', 'secretKey', 'enableSignedUrls', 'drmConfigId'] as const
36
-
37
- // Internal dialog component that can be used with external state
38
- export function ConfigureApiDialog({secrets, setDialogState}: ConfigureApiDialogProps) {
39
- const client = useClient()
40
- const [state, dispatch] = useSecretsFormState(secrets)
41
- const hasSecretsInitially = useMemo(() => secrets.token && secrets.secretKey, [secrets])
42
- const handleClose = useCallback(() => setDialogState(false), [setDialogState])
43
- const dirty = useMemo(
44
- () =>
45
- secrets.token !== state.token ||
46
- secrets.secretKey !== state.secretKey ||
47
- secrets.enableSignedUrls !== state.enableSignedUrls ||
48
- secrets.drmConfigId !== state.drmConfigId,
49
- [secrets, state]
50
- )
51
- const id = `ConfigureApi${useId()}`
52
- const [tokenId, secretKeyId, enableSignedUrlsId, drmConfigIdId] = useMemo<typeof fieldNames>(
53
- () => fieldNames.map((field) => `${id}-${field}`) as unknown as typeof fieldNames,
54
- [id]
55
- )
56
- const firstField = useRef<HTMLInputElement>(null)
57
- const handleSaveSecrets = useSaveSecrets(client, secrets)
58
- const saving = useRef(false)
59
-
60
- const handleSubmit = useCallback(
61
- (event: React.FormEvent<HTMLFormElement>) => {
62
- event.preventDefault()
63
-
64
- if (!saving.current && event.currentTarget.reportValidity()) {
65
- saving.current = true
66
- dispatch({type: 'submit'})
67
- const {token, secretKey, enableSignedUrls, drmConfigId} = state
68
- handleSaveSecrets({token, secretKey, enableSignedUrls, drmConfigId})
69
- .then((savedSecrets) => {
70
- const {projectId, dataset} = client.config()
71
- clear([cacheNs, secretsId, projectId, dataset])
72
- preload(() => Promise.resolve(savedSecrets), [cacheNs, secretsId, projectId, dataset])
73
- setDialogState(false)
74
- })
75
- .catch((err) => dispatch({type: 'error', payload: err.message}))
76
- .finally(() => {
77
- saving.current = false
78
- })
79
- }
80
- },
81
- [client, dispatch, handleSaveSecrets, setDialogState, state]
82
- )
83
- const handleChangeToken = useCallback(
84
- (event: React.FormEvent<HTMLInputElement>) => {
85
- dispatch({
86
- type: 'change',
87
- payload: {name: 'token', value: event.currentTarget.value},
88
- })
89
- },
90
- [dispatch]
91
- )
92
- const handleChangeSecretKey = useCallback(
93
- (event: React.FormEvent<HTMLInputElement>) => {
94
- dispatch({
95
- type: 'change',
96
- payload: {name: 'secretKey', value: event.currentTarget.value},
97
- })
98
- },
99
- [dispatch]
100
- )
101
- const handleChangeEnableSignedUrls = useCallback(
102
- (event: React.FormEvent<HTMLInputElement>) => {
103
- dispatch({
104
- type: 'change',
105
- payload: {name: 'enableSignedUrls', value: event.currentTarget.checked},
106
- })
107
- },
108
- [dispatch]
109
- )
110
- const handleChangeDrmConfigId = useCallback(
111
- (event: React.FormEvent<HTMLInputElement>) => {
112
- dispatch({
113
- type: 'change',
114
- payload: {name: 'drmConfigId', value: event.currentTarget.value},
115
- })
116
- },
117
- [dispatch]
118
- )
119
-
120
- useEffect(() => {
121
- if (firstField.current) {
122
- firstField.current.focus()
123
- }
124
- }, [firstField])
125
-
126
- return (
127
- <Dialog
128
- animate
129
- id={id}
130
- onClose={handleClose}
131
- onClickOutside={handleClose}
132
- header={<Header />}
133
- zOffset={DIALOGS_Z_INDEX}
134
- position="fixed"
135
- width={1}
136
- >
137
- <Box padding={3}>
138
- <form onSubmit={handleSubmit} noValidate>
139
- <Stack space={4}>
140
- {!hasSecretsInitially && (
141
- <Card padding={[3, 3, 3]} radius={2} shadow={1} tone="primary">
142
- <Stack space={3}>
143
- <Text size={1}>
144
- To set up a new access token, go to your{' '}
145
- <a
146
- href="https://dashboard.mux.com/settings/access-tokens"
147
- target="_blank"
148
- rel="noreferrer noopener"
149
- >
150
- account on mux.com
151
- </a>
152
- .
153
- </Text>
154
- <Text size={1}>
155
- The access token needs permissions: <strong>Mux Video </strong>
156
- (Full Access) and <strong>Mux Data</strong> (Read)
157
- <br />
158
- To use Signed URLs, the token must also have System permissions.
159
- <br />
160
- The credentials will be stored safely in a hidden document only available to
161
- editors.
162
- </Text>
163
- </Stack>
164
- </Card>
165
- )}
166
- <FormField title="Access Token" inputId={tokenId}>
167
- <TextInput
168
- id={tokenId}
169
- ref={firstField}
170
- onChange={handleChangeToken}
171
- type="text"
172
- value={state.token ?? ''}
173
- required={!!state.secretKey || state.enableSignedUrls}
174
- />
175
- </FormField>
176
- <FormField title="Secret Key" inputId={secretKeyId}>
177
- <TextInput
178
- id={secretKeyId}
179
- onChange={handleChangeSecretKey}
180
- type="text"
181
- value={state.secretKey ?? ''}
182
- required={!!state.token || state.enableSignedUrls}
183
- />
184
- </FormField>
185
-
186
- <Stack space={4}>
187
- <Flex align="center">
188
- <Checkbox
189
- id={enableSignedUrlsId}
190
- onChange={handleChangeEnableSignedUrls}
191
- checked={state.enableSignedUrls}
192
- style={{display: 'block'}}
193
- />
194
- <Box flex={1} paddingLeft={3}>
195
- <Text>
196
- <label htmlFor={enableSignedUrlsId}>Enable Signed Urls</label>
197
- </Text>
198
- </Box>
199
- </Flex>
200
- {secrets.signingKeyId && state.enableSignedUrls ? (
201
- <Card padding={[3, 3, 3]} radius={2} shadow={1} tone="caution">
202
- <Stack space={3}>
203
- <Text size={1}>The signing key ID that Sanity will use is:</Text>
204
- <Code size={1}>{secrets.signingKeyId}</Code>
205
- <Text size={1}>
206
- This key is only used for previewing content in the Sanity UI.
207
- <br />
208
- You should generate a different key to use in your application server.
209
- </Text>
210
- </Stack>
211
- </Card>
212
- ) : null}
213
- </Stack>
214
-
215
- <FormField title="DRM Configuration ID" inputId={drmConfigIdId}>
216
- <TextInput
217
- id={drmConfigIdId}
218
- onChange={handleChangeDrmConfigId}
219
- type="text"
220
- value={state.drmConfigId ?? ''}
221
- required={false}
222
- />
223
- </FormField>
224
- <Card padding={[3, 3, 3]} radius={2} shadow={1} tone="neutral">
225
- <Stack space={3}>
226
- <Text size={1}>
227
- DRM (Digital Rights Management) provides an extra layer of content security for
228
- video content streamed from Mux. For additional information check out our{' '}
229
- <a
230
- href="https://www.mux.com/docs/guides/protect-videos-with-drm#play-drm-protected-videos"
231
- target="_blank"
232
- rel="noopener noreferrer"
233
- >
234
- DRM Guide
235
- </a>
236
- .
237
- </Text>
238
- <Text size={1}>
239
- <a
240
- href="https://www.mux.com/support/human"
241
- target="_blank"
242
- rel="noopener noreferrer"
243
- >
244
- Contact us
245
- </a>{' '}
246
- to get started using DRM.
247
- </Text>
248
- </Stack>
249
- </Card>
250
-
251
- <Inline space={2}>
252
- <Button
253
- text="Save"
254
- disabled={!dirty}
255
- loading={state.submitting}
256
- tone="primary"
257
- mode="default"
258
- type="submit"
259
- />
260
- <Button
261
- disabled={state.submitting}
262
- text="Cancel"
263
- mode="bleed"
264
- onClick={handleClose}
265
- />
266
- </Inline>
267
- {state.error && (
268
- <Card padding={[3, 3, 3]} radius={2} shadow={1} tone="critical">
269
- <Text>{state.error}</Text>
270
- </Card>
271
- )}
272
- </Stack>
273
- </form>
274
- </Box>
275
- </Dialog>
276
- )
277
- }
278
-
279
- // Wrapper component that manages its own dialog state (used in VideosBrowser)
280
- export default function ConfigureApi() {
281
- const [dialogOpen, setDialogOpen] = useDialogState()
282
- const secretDocumentValues = useSecretsDocumentValues()
283
-
284
- const openDialog = useCallback(() => setDialogOpen('secrets'), [setDialogOpen])
285
-
286
- if (dialogOpen === 'secrets') {
287
- return (
288
- <ConfigureApiDialog
289
- secrets={secretDocumentValues.value.secrets}
290
- setDialogState={setDialogOpen}
291
- />
292
- )
293
- }
294
-
295
- return <Button mode="bleed" text="Configure plugin" onClick={openDialog} />
296
- }