sanity-plugin-mux-input 2.2.2 → 2.2.4
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/README.md +7 -7
- package/lib/index.cjs +48 -34
- package/lib/index.cjs.js +0 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +49 -35
- package/lib/index.js.map +1 -1
- package/package.json +28 -28
- package/src/components/VideoDetails/VideoDetails.tsx +8 -1
- package/src/components/VideoMetadata.tsx +4 -1
- package/src/components/__legacy__Uploader.tsx +2 -2
- package/src/util/createSearchFilter.ts +5 -7
- package/src/util/generateJwt.ts +6 -6
- package/src/util/getVideoMetadata.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-mux-input",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "An input component that integrates Sanity Studio with Mux video encoding/hosting service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"source": "./src/index.ts",
|
|
30
30
|
"require": "./lib/index.cjs",
|
|
31
31
|
"node": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"module": "./lib/index.js",
|
|
33
|
+
"import": "./lib/index.cjs.js"
|
|
34
34
|
},
|
|
35
35
|
"import": "./lib/index.js",
|
|
36
36
|
"default": "./lib/index.js"
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"watch": "pkg-utils watch --strict"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@mux/mux-player-react": "
|
|
65
|
-
"@mux/upchunk": "^3",
|
|
64
|
+
"@mux/mux-player-react": "1.15.0",
|
|
65
|
+
"@mux/upchunk": "^3.2.0",
|
|
66
66
|
"@sanity/icons": "^2",
|
|
67
67
|
"@sanity/incompatible-plugin": "^1",
|
|
68
68
|
"@sanity/ui": "^1",
|
|
@@ -72,46 +72,46 @@
|
|
|
72
72
|
"react-rx": "^2.1.3",
|
|
73
73
|
"rxjs": "^7",
|
|
74
74
|
"scroll-into-view-if-needed": "^3",
|
|
75
|
-
"suspend-react": "^0.1.
|
|
76
|
-
"swr": "^2.1
|
|
77
|
-
"type-fest": "^4.
|
|
75
|
+
"suspend-react": "^0.1.3",
|
|
76
|
+
"swr": "^2.2.1",
|
|
77
|
+
"type-fest": "^4.2.0",
|
|
78
78
|
"use-error-boundary": "^2.0.6"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@commitlint/cli": "^17.
|
|
82
|
-
"@commitlint/config-conventional": "^17.
|
|
83
|
-
"@sanity/pkg-utils": "^2.
|
|
84
|
-
"@sanity/plugin-kit": "^3.1.
|
|
85
|
-
"@sanity/semantic-release-preset": "^4.1.
|
|
86
|
-
"@sanity/vision": "^3.
|
|
87
|
-
"@types/react": "^18.2.
|
|
88
|
-
"@types/styled-components": "^5.1.
|
|
81
|
+
"@commitlint/cli": "^17.8.1",
|
|
82
|
+
"@commitlint/config-conventional": "^17.8.1",
|
|
83
|
+
"@sanity/pkg-utils": "^2.4.10",
|
|
84
|
+
"@sanity/plugin-kit": "^3.1.10",
|
|
85
|
+
"@sanity/semantic-release-preset": "^4.1.6",
|
|
86
|
+
"@sanity/vision": "^3.19.2",
|
|
87
|
+
"@types/react": "^18.2.37",
|
|
88
|
+
"@types/styled-components": "^5.1.30",
|
|
89
89
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
90
90
|
"@typescript-eslint/parser": "^5.62.0",
|
|
91
91
|
"cz-conventional-changelog": "^3.3.0",
|
|
92
|
-
"eslint": "^8.
|
|
93
|
-
"eslint-config-prettier": "^
|
|
92
|
+
"eslint": "^8.53.0",
|
|
93
|
+
"eslint-config-prettier": "^9.0.0",
|
|
94
94
|
"eslint-config-react-app": "^7.0.1",
|
|
95
95
|
"eslint-config-sanity": "^6.0.0",
|
|
96
|
-
"eslint-plugin-import": "^2.
|
|
97
|
-
"eslint-plugin-prettier": "^5.0.
|
|
98
|
-
"eslint-plugin-react": "^7.33.
|
|
96
|
+
"eslint-plugin-import": "^2.29.0",
|
|
97
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
98
|
+
"eslint-plugin-react": "^7.33.2",
|
|
99
99
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
100
100
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
101
101
|
"husky": "^8.0.3",
|
|
102
|
-
"lint-staged": "^13.
|
|
103
|
-
"next": "^13.
|
|
104
|
-
"next-sanity": "^5.
|
|
102
|
+
"lint-staged": "^13.3.0",
|
|
103
|
+
"next": "^13.5.6",
|
|
104
|
+
"next-sanity": "^5.5.10",
|
|
105
105
|
"npm-run-all": "^4.1.5",
|
|
106
|
-
"prettier": "^3.0
|
|
107
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
106
|
+
"prettier": "^3.1.0",
|
|
107
|
+
"prettier-plugin-packagejson": "^2.4.6",
|
|
108
108
|
"react": "^18.2.0",
|
|
109
109
|
"react-dom": "^18.2.0",
|
|
110
110
|
"react-is": "^18.2.0",
|
|
111
111
|
"rimraf": "^5.0.0",
|
|
112
|
-
"sanity": "^3.
|
|
112
|
+
"sanity": "^3.19.2",
|
|
113
113
|
"styled-components": "^5.3.11",
|
|
114
|
-
"typescript": "^5.
|
|
114
|
+
"typescript": "^5.2.2"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
117
|
"react": "^18",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
RevertIcon,
|
|
9
9
|
SearchIcon,
|
|
10
10
|
TrashIcon,
|
|
11
|
+
TagIcon,
|
|
11
12
|
} from '@sanity/icons'
|
|
12
13
|
import {
|
|
13
14
|
Button,
|
|
@@ -221,7 +222,12 @@ const VideoDetails: React.FC<VideoDetailsProps> = (props) => {
|
|
|
221
222
|
selected={tab === 'references'}
|
|
222
223
|
/>
|
|
223
224
|
</TabList>
|
|
224
|
-
<TabPanel
|
|
225
|
+
<TabPanel
|
|
226
|
+
aria-labelledby="details-tab"
|
|
227
|
+
id="details-panel"
|
|
228
|
+
hidden={tab !== 'details'}
|
|
229
|
+
style={{wordBreak: 'break-word'}}
|
|
230
|
+
>
|
|
225
231
|
<Stack space={4}>
|
|
226
232
|
<AssetInput
|
|
227
233
|
label="Video title or file name"
|
|
@@ -271,6 +277,7 @@ const VideoDetails: React.FC<VideoDetailsProps> = (props) => {
|
|
|
271
277
|
icon={CalendarIcon}
|
|
272
278
|
size={2}
|
|
273
279
|
/>
|
|
280
|
+
<IconInfo text={`Mux ID: \n${displayInfo.id}`} icon={TagIcon} size={2} />
|
|
274
281
|
</Stack>
|
|
275
282
|
</Stack>
|
|
276
283
|
</TabPanel>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CalendarIcon, ClockIcon} from '@sanity/icons'
|
|
1
|
+
import {CalendarIcon, ClockIcon, TagIcon} from '@sanity/icons'
|
|
2
2
|
import {Inline, Stack, Text} from '@sanity/ui'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
|
|
@@ -35,6 +35,9 @@ const VideoMetadata = (props: {asset: VideoAssetDocument}) => {
|
|
|
35
35
|
size={1}
|
|
36
36
|
muted
|
|
37
37
|
/>
|
|
38
|
+
{displayInfo.title != displayInfo.id.slice(0, 12) && (
|
|
39
|
+
<IconInfo text={displayInfo.id.slice(0, 12)} icon={TagIcon} size={1} muted />
|
|
40
|
+
)}
|
|
38
41
|
</Inline>
|
|
39
42
|
</Stack>
|
|
40
43
|
)
|
|
@@ -229,8 +229,8 @@ class MuxVideoInputUploader extends Component<Props, State> {
|
|
|
229
229
|
this.state.isDraggingOver && (this.state.invalidPaste || this.state.invalidFile)
|
|
230
230
|
? 'critical'
|
|
231
231
|
: this.state.isDraggingOver
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
? 'positive'
|
|
233
|
+
: undefined
|
|
234
234
|
}
|
|
235
235
|
onDrop={this.handleDrop}
|
|
236
236
|
onDragOver={this.handleDragOver}
|
|
@@ -12,7 +12,7 @@ function tokenize(string: string): string[] {
|
|
|
12
12
|
function toGroqParams(terms: string[]): Record<string, string> {
|
|
13
13
|
const params: Record<string, string> = {}
|
|
14
14
|
return terms.reduce((acc, term, i) => {
|
|
15
|
-
acc[`t${i}`] =
|
|
15
|
+
acc[`t${i}`] = `*${term}*` // "t" is short for term
|
|
16
16
|
return acc
|
|
17
17
|
}, params)
|
|
18
18
|
}
|
|
@@ -51,16 +51,14 @@ function extractTermsFromQuery(query: string): string[] {
|
|
|
51
51
|
return [...quotedTerms, ...remainingTerms]
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/** Which properties of the video asset document should we match users' queries against */
|
|
55
|
-
const SEARCH_PATHS = ['filename']
|
|
56
|
-
|
|
57
54
|
/**
|
|
58
55
|
* Create GROQ constraints, given search terms and the full spec of available document types and fields.
|
|
59
56
|
* Essentially a large list of all possible fields (joined by logical OR) to match our search terms against.
|
|
60
57
|
*/
|
|
61
|
-
function createConstraints(terms: string[]) {
|
|
58
|
+
function createConstraints(terms: string[], includeAssetId: Boolean) {
|
|
59
|
+
const searchPaths = includeAssetId ? ['filename', 'assetId'] : ['filename']
|
|
62
60
|
const constraints = terms
|
|
63
|
-
.map((_term, i) =>
|
|
61
|
+
.map((_term, i) => searchPaths.map((joinedPath) => `${joinedPath} match $t${i}`))
|
|
64
62
|
.filter((constraint) => constraint.length > 0)
|
|
65
63
|
|
|
66
64
|
return constraints.map((constraint) => `(${constraint.join(' || ')})`)
|
|
@@ -70,7 +68,7 @@ export function createSearchFilter(query: string) {
|
|
|
70
68
|
const terms = extractTermsFromQuery(query)
|
|
71
69
|
|
|
72
70
|
return {
|
|
73
|
-
filter: createConstraints(terms),
|
|
71
|
+
filter: createConstraints(terms, query.length >= 8), // if the search is big enough, include the assetId (mux id) in the results
|
|
74
72
|
params: {
|
|
75
73
|
...toGroqParams(terms),
|
|
76
74
|
},
|
package/src/util/generateJwt.ts
CHANGED
|
@@ -9,12 +9,12 @@ export type Audience = 'g' | 's' | 't' | 'v'
|
|
|
9
9
|
export type Payload<T extends Audience> = T extends 'g'
|
|
10
10
|
? AnimatedThumbnailOptions
|
|
11
11
|
: T extends 's'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
? never
|
|
13
|
+
: T extends 't'
|
|
14
|
+
? ThumbnailOptions
|
|
15
|
+
: T extends 'v'
|
|
16
|
+
? never
|
|
17
|
+
: never
|
|
18
18
|
|
|
19
19
|
export function generateJwt<T extends Audience>(
|
|
20
20
|
client: SanityClient,
|
|
@@ -8,7 +8,8 @@ export default function getVideoMetadata(doc: VideoAssetDocument) {
|
|
|
8
8
|
: new Date(doc._createdAt || doc._updatedAt || Date.now())
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
|
-
title: doc.filename || id.slice(0,
|
|
11
|
+
title: doc.filename || id.slice(0, 12),
|
|
12
|
+
id: id,
|
|
12
13
|
createdAt: date,
|
|
13
14
|
duration: doc.data?.duration ? formatSeconds(doc.data?.duration) : undefined,
|
|
14
15
|
aspect_ratio: doc.data?.aspect_ratio,
|