sanity-plugin-mux-input 2.0.3 → 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/lib/_chunks/{Input-aa6d929b.js → Input-235cb658.js} +77 -66
- package/lib/_chunks/Input-235cb658.js.map +1 -0
- package/lib/_chunks/{Input-4ec3c050.js → Input-b9334416.js} +78 -66
- package/lib/_chunks/Input-b9334416.js.map +1 -0
- package/lib/_chunks/{Preview-1664b7d5.js → Preview-85174edf.js} +2 -2
- package/lib/_chunks/{Preview-1664b7d5.js.map → Preview-85174edf.js.map} +1 -1
- package/lib/_chunks/{Preview-43ce9c72.js → Preview-ced24517.js} +2 -2
- package/lib/_chunks/{Preview-43ce9c72.js.map → Preview-ced24517.js.map} +1 -1
- package/lib/_chunks/{VideoSource.styled-99ffa712.js → VideoSource.styled-11786b3a.js} +3 -3
- package/lib/_chunks/VideoSource.styled-11786b3a.js.map +1 -0
- package/lib/_chunks/{VideoSource.styled-24577ec8.js → VideoSource.styled-f1b98975.js} +3 -3
- package/lib/_chunks/VideoSource.styled-f1b98975.js.map +1 -0
- package/lib/_chunks/{index-9933dea2.js → index-5a70abdc.js} +14 -13
- package/lib/_chunks/{index-9933dea2.js.map → index-5a70abdc.js.map} +1 -1
- package/lib/_chunks/{index-c54f5393.js → index-7260e0df.js} +14 -13
- package/lib/_chunks/{index-c54f5393.js.map → index-7260e0df.js.map} +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +33 -33
- package/src/actions/assets.ts +1 -1
- package/src/actions/secrets.ts +12 -3
- package/src/actions/upload.ts +1 -1
- package/src/components/Player.tsx +15 -24
- package/src/components/__legacy__Uploader.tsx +1 -1
- package/src/hooks/useSaveSecrets.ts +1 -1
- package/src/util/generateJwt.ts +1 -1
- package/src/util/getAnimatedPosterSrc.ts +1 -1
- package/src/util/getPosterSrc.ts +1 -1
- package/src/util/getStoryboardSrc.ts +1 -1
- package/src/util/getVideoSrc.ts +1 -1
- package/src/util/readSecrets.ts +1 -1
- package/lib/_chunks/Input-4ec3c050.js.map +0 -1
- package/lib/_chunks/Input-aa6d929b.js.map +0 -1
- package/lib/_chunks/VideoSource.styled-24577ec8.js.map +0 -1
- package/lib/_chunks/VideoSource.styled-99ffa712.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoSource.styled-11786b3a.js","sources":["../../src/hooks/useAssetDocumentValues.ts","../../src/hooks/useClient.ts","../../src/util/readSecrets.ts","../../src/util/generateJwt.ts","../../src/util/getPlaybackId.ts","../../src/util/getPlaybackPolicy.ts","../../src/util/getAnimatedPosterSrc.ts","../../src/util/getPosterSrc.ts","../../src/components/VideoSource.styled.tsx"],"sourcesContent":["import {isReference} from 'sanity'\nimport {useDocumentValues} from 'sanity'\n\nimport type {Reference, VideoAssetDocument} from '../util/types'\n\nconst path = ['assetId', 'data', 'playbackId', 'status', 'thumbTime', 'filename']\nexport const useAssetDocumentValues = (asset: Reference | null | undefined) =>\n useDocumentValues<VideoAssetDocument | null | undefined>(\n isReference(asset) ? asset._ref! : '',\n path\n )\n","// As it's required to specify the API Version this custom hook ensures it's all using the same version\nimport {useClient as useSanityClient} from 'sanity'\n\nexport function useClient() {\n return useSanityClient({apiVersion: '2022-09-14'})\n}\n","// Utils with a readName prefix are suspendable and should only be called in the render body\n// Not inside event callbacks or a useEffect.\n// They may be called dynamically, unlike useEffect\n\n// @TODO rename to readSigningPair\n\nimport type {SanityClient} from 'sanity'\nimport {suspend} from 'suspend-react'\n\nimport {cacheNs} from '../util/constants'\nimport {type Secrets} from '../util/types'\n\nexport const _id = 'secrets.mux' as const\n\nexport function readSecrets(client: SanityClient): Secrets {\n const {projectId, dataset} = client.config()\n return suspend(async () => {\n const data = await client.fetch(\n /* groq */ `*[_id == $_id][0]{\n token,\n secretKey,\n enableSignedUrls,\n signingKeyId,\n signingKeyPrivate\n }`,\n {_id}\n )\n return {\n token: data?.token || null,\n secretKey: data?.secretKey || null,\n enableSignedUrls: Boolean(data?.enableSignedUrls) || false,\n signingKeyId: data?.signingKeyId || null,\n signingKeyPrivate: data?.signingKeyPrivate || null,\n }\n }, [cacheNs, _id, projectId, dataset])\n}\n","import type {SanityClient} from 'sanity'\nimport {suspend} from 'suspend-react'\n\nimport {readSecrets} from './readSecrets'\nimport type {AnimatedThumbnailOptions, ThumbnailOptions} from './types'\n\nexport type Audience = 'g' | 's' | 't' | 'v'\n\nexport type Payload<T extends Audience> = T extends 'g'\n ? AnimatedThumbnailOptions\n : T extends 's'\n ? never\n : T extends 't'\n ? ThumbnailOptions\n : T extends 'v'\n ? never\n : never\n\nexport function generateJwt<T extends Audience>(\n client: SanityClient,\n playbackId: string,\n aud: T,\n payload?: Payload<T>\n): string {\n const {signingKeyId, signingKeyPrivate} = readSecrets(client)\n if (!signingKeyId) {\n throw new TypeError('Missing signingKeyId')\n }\n if (!signingKeyPrivate) {\n throw new TypeError('Missing signingKeyPrivate')\n }\n\n const {default: sign} = suspend(() => import('jsonwebtoken-esm/sign'), ['jsonwebtoken-esm/sign'])\n\n return sign(\n payload ? JSON.parse(JSON.stringify(payload, (_, v) => v ?? undefined)) : {},\n atob(signingKeyPrivate),\n {\n algorithm: 'RS256',\n keyid: signingKeyId,\n audience: aud,\n subject: playbackId,\n noTimestamp: true,\n expiresIn: '12h',\n }\n )\n}\n","import type {VideoAssetDocument} from './types'\n\nexport function getPlaybackId(asset: VideoAssetDocument): string {\n if (!asset?.playbackId) {\n console.error('Asset is missing a playbackId', {asset})\n throw new TypeError(`Missing playbackId`)\n }\n return asset.playbackId\n}\n","import type {PlaybackPolicy, VideoAssetDocument} from './types'\n\nexport function getPlaybackPolicy(asset: VideoAssetDocument): PlaybackPolicy {\n return asset.data?.playback_ids?.[0]?.policy ?? 'public'\n}\n","import type {SanityClient} from 'sanity'\n\nimport {generateJwt} from './generateJwt'\nimport {getPlaybackId} from './getPlaybackId'\nimport {getPlaybackPolicy} from './getPlaybackPolicy'\nimport type {AnimatedThumbnailOptions, MuxAnimatedThumbnailUrl, VideoAssetDocument} from './types'\n\nexport interface AnimatedPosterSrcOptions extends AnimatedThumbnailOptions {\n asset: VideoAssetDocument\n client: SanityClient\n}\n\nexport function getAnimatedPosterSrc({\n asset,\n client,\n height,\n width,\n start = asset.thumbTime ? Math.max(0, asset.thumbTime - 2.5) : 0,\n end = start + 5,\n fps = 15,\n}: AnimatedPosterSrcOptions): MuxAnimatedThumbnailUrl {\n const params = {height, width, start, end, fps}\n const playbackId = getPlaybackId(asset)\n\n let searchParams = new URLSearchParams(\n JSON.parse(JSON.stringify(params, (_, v) => v ?? undefined))\n )\n if (getPlaybackPolicy(asset) === 'signed') {\n const token = generateJwt(client, playbackId, 'g', params)\n searchParams = new URLSearchParams({token})\n }\n\n return `https://image.mux.com/${playbackId}/animated.gif?${searchParams}`\n}\n","import type {SanityClient} from 'sanity'\n\nimport {generateJwt} from './generateJwt'\nimport {getPlaybackId} from './getPlaybackId'\nimport {getPlaybackPolicy} from './getPlaybackPolicy'\nimport type {MuxThumbnailUrl, ThumbnailOptions, VideoAssetDocument} from './types'\n\nexport interface PosterSrcOptions extends ThumbnailOptions {\n asset: VideoAssetDocument\n client: SanityClient\n}\n\nexport function getPosterSrc({\n asset,\n client,\n fit_mode,\n height,\n time = asset.thumbTime,\n width,\n}: PosterSrcOptions): MuxThumbnailUrl {\n const params = {fit_mode, height, time, width}\n const playbackId = getPlaybackId(asset)\n\n let searchParams = new URLSearchParams(\n JSON.parse(JSON.stringify(params, (_, v) => v ?? undefined))\n )\n if (getPlaybackPolicy(asset) === 'signed') {\n const token = generateJwt(client, playbackId, 't', params)\n searchParams = new URLSearchParams({token})\n }\n\n return `https://image.mux.com/${playbackId}/thumbnail.png?${searchParams}`\n}\n","import {LockIcon, UnknownIcon} from '@sanity/icons'\nimport {Box, Card, Grid, Inline, Spinner} from '@sanity/ui'\nimport React, {memo, Suspense, useMemo} from 'react'\nimport {MediaPreview} from 'sanity'\nimport styled from 'styled-components'\nimport {suspend} from 'suspend-react'\nimport {useErrorBoundary} from 'use-error-boundary'\n\nimport {useClient} from '../hooks/useClient'\nimport {getAnimatedPosterSrc} from '../util/getAnimatedPosterSrc'\nimport {getPlaybackPolicy} from '../util/getPlaybackPolicy'\nimport {getPosterSrc} from '../util/getPosterSrc'\nimport type {VideoAssetDocument} from '../util/types'\n\nconst mediaDimensions = {aspect: 16 / 9}\n\ninterface ImageLoaderProps {\n alt: string\n src: string\n height?: number\n width: number\n aspectRatio?: string\n}\nconst ImageLoader = memo(function ImageLoader({\n alt,\n src,\n height,\n width,\n aspectRatio,\n}: ImageLoaderProps) {\n suspend(async () => {\n const img = new Image(width, height)\n img.decoding = 'async'\n img.src = src\n await img.decode()\n }, ['sanity-plugin-mux-input', 'image', src])\n\n return <img alt={alt} src={src} height={height} width={width} style={{aspectRatio}} />\n})\n\n// @TODO fix typings errors due to props.renderDefault\nconst VideoMediaPreview = styled<any>(MediaPreview)`\n img {\n object-fit: cover;\n }\n`\n\ninterface VideoMediaPreviewSignedSubtitleProps {\n solo?: boolean\n}\nconst VideoMediaPreviewSignedSubtitle = ({solo}: VideoMediaPreviewSignedSubtitleProps) => {\n return (\n <Inline\n space={1}\n style={{\n marginTop: solo ? '-1.35em' : undefined,\n marginBottom: solo ? undefined : '0.35rem',\n }}\n >\n <LockIcon />\n Signed playback policy\n </Inline>\n )\n}\n\ninterface PosterImageProps extends Omit<ImageLoaderProps, 'src' | 'alt'> {\n asset: VideoAssetDocument\n showTip?: boolean\n}\nconst PosterImage = ({asset, height, width, showTip}: PosterImageProps) => {\n const client = useClient()\n const src = getPosterSrc({\n asset,\n client,\n height,\n width,\n fit_mode: 'smartcrop',\n })\n const subtitle = useMemo(\n () =>\n showTip && getPlaybackPolicy(asset) === 'signed' ? (\n <VideoMediaPreviewSignedSubtitle solo />\n ) : undefined,\n [asset, showTip]\n )\n\n // eslint-disable-next-line no-warning-comments\n // @TODO support setting the alt text in the schema, like how we deal with images\n return (\n <VideoMediaPreview\n mediaDimensions={mediaDimensions}\n subtitle={subtitle}\n title={<>{null}</>}\n media={<ImageLoader alt=\"\" src={src} height={height} width={width} />}\n />\n )\n}\n\nexport interface VideoThumbnailProps extends Omit<PosterImageProps, 'height'> {\n width: number\n}\nexport const VideoThumbnail = memo(function VideoThumbnail({\n asset,\n width,\n showTip,\n}: VideoThumbnailProps) {\n const {ErrorBoundary, didCatch, error} = useErrorBoundary()\n const height = Math.round((width * 9) / 16)\n const subtitle = useMemo(\n () =>\n showTip && getPlaybackPolicy(asset) === 'signed' ? (\n <VideoMediaPreviewSignedSubtitle />\n ) : undefined,\n [showTip, asset]\n )\n\n if (didCatch) {\n return (\n <VideoMediaPreview\n subtitle={error.message}\n mediaDimensions={mediaDimensions}\n title=\"Error when loading thumbnail\"\n media={\n <Card radius={2} height=\"fill\" style={{position: 'relative', width: '100%'}}>\n <Box\n style={{\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n >\n <UnknownIcon />\n </Box>\n </Card>\n }\n />\n )\n }\n\n return (\n <ErrorBoundary>\n <Suspense\n fallback={\n <VideoMediaPreview\n isPlaceholder\n title=\"Loading thumbnail...\"\n subtitle={subtitle}\n mediaDimensions={mediaDimensions}\n />\n }\n >\n <PosterImage showTip={showTip} asset={asset} height={height} width={width} />\n </Suspense>\n </ErrorBoundary>\n )\n})\n\n// @TODO fix typings errors due to props.renderDefault\nconst AnimatedVideoMediaPreview = styled<any>(MediaPreview)`\n img {\n object-fit: contain;\n }\n`\n\ninterface AnimatedPosterImageProps extends Omit<ImageLoaderProps, 'src' | 'alt' | 'height'> {\n asset: VideoAssetDocument\n}\nconst AnimatedPosterImage = ({asset, width}: AnimatedPosterImageProps) => {\n const client = useClient()\n const src = getAnimatedPosterSrc({asset, client, width})\n\n // eslint-disable-next-line no-warning-comments\n // @TODO support setting the alt text in the schema, like how we deal with images\n return (\n <AnimatedVideoMediaPreview\n withBorder={false}\n mediaDimensions={mediaDimensions}\n media={<ImageLoader alt=\"\" src={src} width={width} aspectRatio=\"16:9\" />}\n />\n )\n}\n\nexport interface AnimatedVideoThumbnailProps extends Omit<PosterImageProps, 'height'> {\n width: number\n}\nexport const AnimatedVideoThumbnail = memo(function AnimatedVideoThumbnail({\n asset,\n width,\n}: AnimatedVideoThumbnailProps) {\n const {ErrorBoundary, didCatch} = useErrorBoundary()\n\n if (didCatch) {\n return null\n }\n\n return (\n <ErrorBoundary>\n <Suspense\n fallback={\n <FancyBackdrop>\n <VideoMediaPreview\n mediaDimensions={mediaDimensions}\n withBorder={false}\n media={<Spinner muted />}\n />\n </FancyBackdrop>\n }\n >\n <Card height=\"fill\" tone=\"transparent\">\n <AnimatedPosterImage asset={asset} width={width} />\n </Card>\n </Suspense>\n </ErrorBoundary>\n )\n})\nconst FancyBackdrop = styled(Box)`\n backdrop-filter: blur(8px) brightness(0.5) saturate(2);\n mix-blend-mode: color-dodge;\n`\n\nexport const ThumbGrid = styled(Grid)`\n grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));\n`\n\nexport const CardLoadMore = styled(Card)`\n border-top: 1px solid var(--card-border-color);\n position: sticky;\n bottom: 0;\n z-index: 200;\n`\n"],"names":["path","useAssetDocumentValues","asset","useDocumentValues","isReference","_ref","useClient","useSanityClient","apiVersion","_id","readSecrets","client","projectId","dataset","config","suspend","data","fetch","token","secretKey","enableSignedUrls","Boolean","signingKeyId","signingKeyPrivate","cacheNs","generateJwt","playbackId","aud","payload","TypeError","default","sign","JSON","parse","stringify","_","v","atob","algorithm","keyid","audience","subject","noTimestamp","expiresIn","getPlaybackId","console","error","getPlaybackPolicy","_a","_b","_c","_d","playback_ids","policy","getAnimatedPosterSrc","height","width","start","thumbTime","Math","max","end","fps","params","searchParams","URLSearchParams","getPosterSrc","fit_mode","time","mediaDimensions","aspect","ImageLoader","memo","alt","src","aspectRatio","img","Image","decoding","decode","jsx","style","VideoMediaPreview","styled","MediaPreview","VideoMediaPreviewSignedSubtitle","solo","jsxs","Inline","space","marginTop","marginBottom","children","LockIcon","PosterImage","showTip","subtitle","useMemo","title","media","VideoThumbnail","ErrorBoundary","didCatch","useErrorBoundary","round","message","Card","radius","position","Box","display","justifyContent","alignItems","top","left","right","bottom","UnknownIcon","Suspense","fallback","isPlaceholder","AnimatedVideoMediaPreview","AnimatedPosterImage","withBorder","AnimatedVideoThumbnail","FancyBackdrop","Spinner","muted","tone","ThumbGrid","Grid","CardLoadMore"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,MAAMA,OAAO,CAAC,SAAA,EAAW,QAAQ,YAAc,EAAA,QAAA,EAAU,aAAa,UAAU,CAAA;AACnE,MAAAC,sBAAA,GAA0BC,KACrC,IAAAC,MAAA,CAAAA,iBAAA,CACEC,MAAAA,CAAAA,WAAY,CAAAF,KAAK,CAAI,GAAAA,KAAA,CAAMG,IAAQ,GAAA,EAAA,EACnCL,IAAA,CACF;ACPK,SAASM,SAAY,GAAA;EAC1B,OAAOC,gBAAgB,CAAA;IAACC,UAAY,EAAA;EAAa,CAAA,CAAA;AACnD;ACOO,MAAMC,GAAM,GAAA,aAAA;AAEZ,SAASC,YAAYC,MAA+B,EAAA;EACzD,MAAM;IAACC,SAAA;IAAWC;EAAO,CAAA,GAAIF,OAAOG,MAAO,EAAA;EAC3C,OAAOC,qBAAQ,YAAY;IACnB,MAAAC,IAAA,GAAO,MAAML,MAAO,CAAAM,KAAA,EAAA,0JAQxB;MAACR;IAAG,CAAA,CACN;IACO,OAAA;MACLS,KAAA,EAAA,CAAOF,6BAAME,KAAS,KAAA,IAAA;MACtBC,SAAA,EAAA,CAAWH,6BAAMG,SAAa,KAAA,IAAA;MAC9BC,gBAAkB,EAAAC,OAAA,CAAQL,IAAM,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,IAAA,CAAAI,gBAAgB,CAAK,IAAA,KAAA;MACrDE,YAAA,EAAA,CAAcN,6BAAMM,YAAgB,KAAA,IA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AA;;;;;;;;;;;"}
|
|
@@ -8,7 +8,7 @@ import { memo, useMemo, Suspense } from 'react';
|
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
import { suspend } from 'suspend-react';
|
|
10
10
|
import { useErrorBoundary } from 'use-error-boundary';
|
|
11
|
-
import { cacheNs } from './index-
|
|
11
|
+
import { cacheNs } from './index-7260e0df.js';
|
|
12
12
|
const path = ["assetId", "data", "playbackId", "status", "thumbTime", "filename"];
|
|
13
13
|
const useAssetDocumentValues = asset => useDocumentValues(isReference(asset) ? asset._ref : "", path);
|
|
14
14
|
function useClient() {
|
|
@@ -23,7 +23,7 @@ function readSecrets(client) {
|
|
|
23
23
|
dataset
|
|
24
24
|
} = client.config();
|
|
25
25
|
return suspend(async () => {
|
|
26
|
-
const data = await client.fetch("*[_id == $_id][0]{\n token,\n secretKey,\n enableSignedUrls,\n signingKeyId,\n signingKeyPrivate\n }", {
|
|
26
|
+
const data = await client.fetch( /* groq */"*[_id == $_id][0]{\n token,\n secretKey,\n enableSignedUrls,\n signingKeyId,\n signingKeyPrivate\n }", {
|
|
27
27
|
_id
|
|
28
28
|
});
|
|
29
29
|
return {
|
|
@@ -315,4 +315,4 @@ const FancyBackdrop = styled(Box)(_templateObject3 || (_templateObject3 = _tagge
|
|
|
315
315
|
const ThumbGrid = styled(Grid)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));\n"])));
|
|
316
316
|
const CardLoadMore = styled(Card)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-top: 1px solid var(--card-border-color);\n position: sticky;\n bottom: 0;\n z-index: 200;\n"])));
|
|
317
317
|
export { AnimatedVideoThumbnail, CardLoadMore, ThumbGrid, VideoThumbnail, _id, generateJwt, getPlaybackId, getPlaybackPolicy, getPosterSrc, useAssetDocumentValues, useClient };
|
|
318
|
-
//# sourceMappingURL=VideoSource.styled-
|
|
318
|
+
//# sourceMappingURL=VideoSource.styled-f1b98975.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoSource.styled-f1b98975.js","sources":["../../src/hooks/useAssetDocumentValues.ts","../../src/hooks/useClient.ts","../../src/util/readSecrets.ts","../../src/util/generateJwt.ts","../../src/util/getPlaybackId.ts","../../src/util/getPlaybackPolicy.ts","../../src/util/getAnimatedPosterSrc.ts","../../src/util/getPosterSrc.ts","../../src/components/VideoSource.styled.tsx"],"sourcesContent":["import {isReference} from 'sanity'\nimport {useDocumentValues} from 'sanity'\n\nimport type {Reference, VideoAssetDocument} from '../util/types'\n\nconst path = ['assetId', 'data', 'playbackId', 'status', 'thumbTime', 'filename']\nexport const useAssetDocumentValues = (asset: Reference | null | undefined) =>\n useDocumentValues<VideoAssetDocument | null | undefined>(\n isReference(asset) ? asset._ref! : '',\n path\n )\n","// As it's required to specify the API Version this custom hook ensures it's all using the same version\nimport {useClient as useSanityClient} from 'sanity'\n\nexport function useClient() {\n return useSanityClient({apiVersion: '2022-09-14'})\n}\n","// Utils with a readName prefix are suspendable and should only be called in the render body\n// Not inside event callbacks or a useEffect.\n// They may be called dynamically, unlike useEffect\n\n// @TODO rename to readSigningPair\n\nimport type {SanityClient} from 'sanity'\nimport {suspend} from 'suspend-react'\n\nimport {cacheNs} from '../util/constants'\nimport {type Secrets} from '../util/types'\n\nexport const _id = 'secrets.mux' as const\n\nexport function readSecrets(client: SanityClient): Secrets {\n const {projectId, dataset} = client.config()\n return suspend(async () => {\n const data = await client.fetch(\n /* groq */ `*[_id == $_id][0]{\n token,\n secretKey,\n enableSignedUrls,\n signingKeyId,\n signingKeyPrivate\n }`,\n {_id}\n )\n return {\n token: data?.token || null,\n secretKey: data?.secretKey || null,\n enableSignedUrls: Boolean(data?.enableSignedUrls) || false,\n signingKeyId: data?.signingKeyId || null,\n signingKeyPrivate: data?.signingKeyPrivate || null,\n }\n }, [cacheNs, _id, projectId, dataset])\n}\n","import type {SanityClient} from 'sanity'\nimport {suspend} from 'suspend-react'\n\nimport {readSecrets} from './readSecrets'\nimport type {AnimatedThumbnailOptions, ThumbnailOptions} from './types'\n\nexport type Audience = 'g' | 's' | 't' | 'v'\n\nexport type Payload<T extends Audience> = T extends 'g'\n ? AnimatedThumbnailOptions\n : T extends 's'\n ? never\n : T extends 't'\n ? ThumbnailOptions\n : T extends 'v'\n ? never\n : never\n\nexport function generateJwt<T extends Audience>(\n client: SanityClient,\n playbackId: string,\n aud: T,\n payload?: Payload<T>\n): string {\n const {signingKeyId, signingKeyPrivate} = readSecrets(client)\n if (!signingKeyId) {\n throw new TypeError('Missing signingKeyId')\n }\n if (!signingKeyPrivate) {\n throw new TypeError('Missing signingKeyPrivate')\n }\n\n const {default: sign} = suspend(() => import('jsonwebtoken-esm/sign'), ['jsonwebtoken-esm/sign'])\n\n return sign(\n payload ? JSON.parse(JSON.stringify(payload, (_, v) => v ?? undefined)) : {},\n atob(signingKeyPrivate),\n {\n algorithm: 'RS256',\n keyid: signingKeyId,\n audience: aud,\n subject: playbackId,\n noTimestamp: true,\n expiresIn: '12h',\n }\n )\n}\n","import type {VideoAssetDocument} from './types'\n\nexport function getPlaybackId(asset: VideoAssetDocument): string {\n if (!asset?.playbackId) {\n console.error('Asset is missing a playbackId', {asset})\n throw new TypeError(`Missing playbackId`)\n }\n return asset.playbackId\n}\n","import type {PlaybackPolicy, VideoAssetDocument} from './types'\n\nexport function getPlaybackPolicy(asset: VideoAssetDocument): PlaybackPolicy {\n return asset.data?.playback_ids?.[0]?.policy ?? 'public'\n}\n","import type {SanityClient} from 'sanity'\n\nimport {generateJwt} from './generateJwt'\nimport {getPlaybackId} from './getPlaybackId'\nimport {getPlaybackPolicy} from './getPlaybackPolicy'\nimport type {AnimatedThumbnailOptions, MuxAnimatedThumbnailUrl, VideoAssetDocument} from './types'\n\nexport interface AnimatedPosterSrcOptions extends AnimatedThumbnailOptions {\n asset: VideoAssetDocument\n client: SanityClient\n}\n\nexport function getAnimatedPosterSrc({\n asset,\n client,\n height,\n width,\n start = asset.thumbTime ? Math.max(0, asset.thumbTime - 2.5) : 0,\n end = start + 5,\n fps = 15,\n}: AnimatedPosterSrcOptions): MuxAnimatedThumbnailUrl {\n const params = {height, width, start, end, fps}\n const playbackId = getPlaybackId(asset)\n\n let searchParams = new URLSearchParams(\n JSON.parse(JSON.stringify(params, (_, v) => v ?? undefined))\n )\n if (getPlaybackPolicy(asset) === 'signed') {\n const token = generateJwt(client, playbackId, 'g', params)\n searchParams = new URLSearchParams({token})\n }\n\n return `https://image.mux.com/${playbackId}/animated.gif?${searchParams}`\n}\n","import type {SanityClient} from 'sanity'\n\nimport {generateJwt} from './generateJwt'\nimport {getPlaybackId} from './getPlaybackId'\nimport {getPlaybackPolicy} from './getPlaybackPolicy'\nimport type {MuxThumbnailUrl, ThumbnailOptions, VideoAssetDocument} from './types'\n\nexport interface PosterSrcOptions extends ThumbnailOptions {\n asset: VideoAssetDocument\n client: SanityClient\n}\n\nexport function getPosterSrc({\n asset,\n client,\n fit_mode,\n height,\n time = asset.thumbTime,\n width,\n}: PosterSrcOptions): MuxThumbnailUrl {\n const params = {fit_mode, height, time, width}\n const playbackId = getPlaybackId(asset)\n\n let searchParams = new URLSearchParams(\n JSON.parse(JSON.stringify(params, (_, v) => v ?? undefined))\n )\n if (getPlaybackPolicy(asset) === 'signed') {\n const token = generateJwt(client, playbackId, 't', params)\n searchParams = new URLSearchParams({token})\n }\n\n return `https://image.mux.com/${playbackId}/thumbnail.png?${searchParams}`\n}\n","import {LockIcon, UnknownIcon} from '@sanity/icons'\nimport {Box, Card, Grid, Inline, Spinner} from '@sanity/ui'\nimport React, {memo, Suspense, useMemo} from 'react'\nimport {MediaPreview} from 'sanity'\nimport styled from 'styled-components'\nimport {suspend} from 'suspend-react'\nimport {useErrorBoundary} from 'use-error-boundary'\n\nimport {useClient} from '../hooks/useClient'\nimport {getAnimatedPosterSrc} from '../util/getAnimatedPosterSrc'\nimport {getPlaybackPolicy} from '../util/getPlaybackPolicy'\nimport {getPosterSrc} from '../util/getPosterSrc'\nimport type {VideoAssetDocument} from '../util/types'\n\nconst mediaDimensions = {aspect: 16 / 9}\n\ninterface ImageLoaderProps {\n alt: string\n src: string\n height?: number\n width: number\n aspectRatio?: string\n}\nconst ImageLoader = memo(function ImageLoader({\n alt,\n src,\n height,\n width,\n aspectRatio,\n}: ImageLoaderProps) {\n suspend(async () => {\n const img = new Image(width, height)\n img.decoding = 'async'\n img.src = src\n await img.decode()\n }, ['sanity-plugin-mux-input', 'image', src])\n\n return <img alt={alt} src={src} height={height} width={width} style={{aspectRatio}} />\n})\n\n// @TODO fix typings errors due to props.renderDefault\nconst VideoMediaPreview = styled<any>(MediaPreview)`\n img {\n object-fit: cover;\n }\n`\n\ninterface VideoMediaPreviewSignedSubtitleProps {\n solo?: boolean\n}\nconst VideoMediaPreviewSignedSubtitle = ({solo}: VideoMediaPreviewSignedSubtitleProps) => {\n return (\n <Inline\n space={1}\n style={{\n marginTop: solo ? '-1.35em' : undefined,\n marginBottom: solo ? undefined : '0.35rem',\n }}\n >\n <LockIcon />\n Signed playback policy\n </Inline>\n )\n}\n\ninterface PosterImageProps extends Omit<ImageLoaderProps, 'src' | 'alt'> {\n asset: VideoAssetDocument\n showTip?: boolean\n}\nconst PosterImage = ({asset, height, width, showTip}: PosterImageProps) => {\n const client = useClient()\n const src = getPosterSrc({\n asset,\n client,\n height,\n width,\n fit_mode: 'smartcrop',\n })\n const subtitle = useMemo(\n () =>\n showTip && getPlaybackPolicy(asset) === 'signed' ? (\n <VideoMediaPreviewSignedSubtitle solo />\n ) : undefined,\n [asset, showTip]\n )\n\n // eslint-disable-next-line no-warning-comments\n // @TODO support setting the alt text in the schema, like how we deal with images\n return (\n <VideoMediaPreview\n mediaDimensions={mediaDimensions}\n subtitle={subtitle}\n title={<>{null}</>}\n media={<ImageLoader alt=\"\" src={src} height={height} width={width} />}\n />\n )\n}\n\nexport interface VideoThumbnailProps extends Omit<PosterImageProps, 'height'> {\n width: number\n}\nexport const VideoThumbnail = memo(function VideoThumbnail({\n asset,\n width,\n showTip,\n}: VideoThumbnailProps) {\n const {ErrorBoundary, didCatch, error} = useErrorBoundary()\n const height = Math.round((width * 9) / 16)\n const subtitle = useMemo(\n () =>\n showTip && getPlaybackPolicy(asset) === 'signed' ? (\n <VideoMediaPreviewSignedSubtitle />\n ) : undefined,\n [showTip, asset]\n )\n\n if (didCatch) {\n return (\n <VideoMediaPreview\n subtitle={error.message}\n mediaDimensions={mediaDimensions}\n title=\"Error when loading thumbnail\"\n media={\n <Card radius={2} height=\"fill\" style={{position: 'relative', width: '100%'}}>\n <Box\n style={{\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n >\n <UnknownIcon />\n </Box>\n </Card>\n }\n />\n )\n }\n\n return (\n <ErrorBoundary>\n <Suspense\n fallback={\n <VideoMediaPreview\n isPlaceholder\n title=\"Loading thumbnail...\"\n subtitle={subtitle}\n mediaDimensions={mediaDimensions}\n />\n }\n >\n <PosterImage showTip={showTip} asset={asset} height={height} width={width} />\n </Suspense>\n </ErrorBoundary>\n )\n})\n\n// @TODO fix typings errors due to props.renderDefault\nconst AnimatedVideoMediaPreview = styled<any>(MediaPreview)`\n img {\n object-fit: contain;\n }\n`\n\ninterface AnimatedPosterImageProps extends Omit<ImageLoaderProps, 'src' | 'alt' | 'height'> {\n asset: VideoAssetDocument\n}\nconst AnimatedPosterImage = ({asset, width}: AnimatedPosterImageProps) => {\n const client = useClient()\n const src = getAnimatedPosterSrc({asset, client, width})\n\n // eslint-disable-next-line no-warning-comments\n // @TODO support setting the alt text in the schema, like how we deal with images\n return (\n <AnimatedVideoMediaPreview\n withBorder={false}\n mediaDimensions={mediaDimensions}\n media={<ImageLoader alt=\"\" src={src} width={width} aspectRatio=\"16:9\" />}\n />\n )\n}\n\nexport interface AnimatedVideoThumbnailProps extends Omit<PosterImageProps, 'height'> {\n width: number\n}\nexport const AnimatedVideoThumbnail = memo(function AnimatedVideoThumbnail({\n asset,\n width,\n}: AnimatedVideoThumbnailProps) {\n const {ErrorBoundary, didCatch} = useErrorBoundary()\n\n if (didCatch) {\n return null\n }\n\n return (\n <ErrorBoundary>\n <Suspense\n fallback={\n <FancyBackdrop>\n <VideoMediaPreview\n mediaDimensions={mediaDimensions}\n withBorder={false}\n media={<Spinner muted />}\n />\n </FancyBackdrop>\n }\n >\n <Card height=\"fill\" tone=\"transparent\">\n <AnimatedPosterImage asset={asset} width={width} />\n </Card>\n </Suspense>\n </ErrorBoundary>\n )\n})\nconst FancyBackdrop = styled(Box)`\n backdrop-filter: blur(8px) brightness(0.5) saturate(2);\n mix-blend-mode: color-dodge;\n`\n\nexport const ThumbGrid = styled(Grid)`\n grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));\n`\n\nexport const CardLoadMore = styled(Card)`\n border-top: 1px solid var(--card-border-color);\n position: sticky;\n bottom: 0;\n z-index: 200;\n`\n"],"names":["path","useAssetDocumentValues","asset","useDocumentValues","isReference","_ref","useClient","useSanityClient","apiVersion","_id","readSecrets","client","projectId","dataset","config","suspend","data","fetch","token","secretKey","enableSignedUrls","Boolean","signingKeyId","signingKeyPrivate","cacheNs","generateJwt","playbackId","aud","payload","TypeError","default","sign","JSON","parse","stringify","_","v","atob","algorithm","keyid","audience","subject","noTimestamp","expiresIn","getPlaybackId","console","error","getPlaybackPolicy","_a","_b","_c","_d","playback_ids","policy","getAnimatedPosterSrc","height","width","start","thumbTime","Math","max","end","fps","params","searchParams","URLSearchParams","getPosterSrc","fit_mode","time","mediaDimensions","aspect","ImageLoader","memo","alt","src","aspectRatio","img","Image","decoding","decode","jsx","style","VideoMediaPreview","styled","MediaPreview","VideoMediaPreviewSignedSubtitle","solo","jsxs","Inline","space","marginTop","marginBottom","children","LockIcon","PosterImage","showTip","subtitle","useMemo","title","media","VideoThumbnail","ErrorBoundary","didCatch","useErrorBoundary","round","message","Card","radius","position","Box","display","justifyContent","alignItems","top","left","right","bottom","UnknownIcon","Suspense","fallback","isPlaceholder","AnimatedVideoMediaPreview","AnimatedPosterImage","withBorder","AnimatedVideoThumbnail","FancyBackdrop","Spinner","muted","tone","ThumbGrid","Grid","CardLoadMore"],"mappings":";;;;;;;;;;;AAKA,MAAMA,OAAO,CAAC,SAAA,EAAW,QAAQ,YAAc,EAAA,QAAA,EAAU,aAAa,UAAU,CAAA;AACnE,MAAAC,sBAAA,GAA0BC,KACrC,IAAAC,iBAAA,CACEC,WAAY,CAAAF,KAAK,CAAI,GAAAA,KAAA,CAAMG,IAAQ,GAAA,EAAA,EACnCL,IAAA,CACF;ACPK,SAASM,SAAY,GAAA;EAC1B,OAAOC,WAAgB,CAAA;IAACC,UAAY,EAAA;EAAa,CAAA,CAAA;AACnD;ACOO,MAAMC,GAAM,GAAA,aAAA;AAEZ,SAASC,YAAYC,MAA+B,EAAA;EACzD,MAAM;IAACC,SAAA;IAAWC;EAAO,CAAA,GAAIF,OAAOG,MAAO,EAAA;EAC3C,OAAOC,QAAQ,YAAY;IACnB,MAAAC,IAAA,GAAO,MAAML,MAAO,CAAAM,KAAA,EAAA,0JAQxB;MAACR;IAAG,CAAA,CACN;IACO,OAAA;MACLS,KAAA,EAAA,CAAOF,6BAAME,KAAS,KAAA,IAAA;MACtBC,SAAA,EAAA,CAAWH,6BAAMG,SAAa,KAAA,IAAA;MAC9BC,gBAAkB,EAAAC,OAAA,CAAQL,IAAM,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,IAAA,CAAAI,gBAAgB,CAAK,IAAA,KAAA;MACrDE,YAAA,EAAA,CAAcN,6BAAMM,YAAgB,KAAA,IAAA;MACpCC,iBAAA,EAAA,CAAmBP,6BAAMO,iBAAqB,KAAA;IAAA,CAChD;KACC,CAACC,OAAA,EAASf,GAAK,EAAAG,SAAA,EAAWC,OAAO,CAAC,CAAA;AACvC;ACjBO,SAASY,WACd,CAAAd,MAAA,EACAe,UACA,EAAAC,GAAA,EACAC,OACQ,EAAA;EACR,MA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A,EAAO,MAAO;QAAAyE,IAAA,EAAK;QACvBpC,QAAC,EAAA,eAAAZ,GAAA,CAAA0C,mBAAA,EAAA;UAAoBxH,KAAc;UAAAsD;QAAA,CAAc;MACnD,CAAA;IAAA,CAAA;EAEJ,CAAA,CAAA;AAEJ,CAAC,CAAA;AACD,MAAMqE,aAAA,GAAgB1C,OAAO0B,GAAG,CAAA,oKAAA;AAKnB,MAAAoB,SAAA,GAAY9C,OAAO+C,IAAI,CAAA,0IAAA;AAIvB,MAAAC,YAAA,GAAehD,OAAOuB,IAAI,CAAA,gLAAA;"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _templateObject;
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
8
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
4
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
10
5
|
var sanity = require('sanity');
|
|
11
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -175,7 +170,7 @@ const InputFallback = () => {
|
|
|
175
170
|
});
|
|
176
171
|
};
|
|
177
172
|
const Input = React.lazy(() => Promise.resolve().then(function () {
|
|
178
|
-
return require('./Input-
|
|
173
|
+
return require('./Input-b9334416.js');
|
|
179
174
|
}));
|
|
180
175
|
var createFormInput = config => React.memo(function FormInput(props) {
|
|
181
176
|
if (isMuxInputProps(props)) {
|
|
@@ -184,9 +179,10 @@ var createFormInput = config => React.memo(function FormInput(props) {
|
|
|
184
179
|
schemaType: props.schemaType,
|
|
185
180
|
children: /* @__PURE__ */jsxRuntime.jsx(React.Suspense, {
|
|
186
181
|
fallback: /* @__PURE__ */jsxRuntime.jsx(InputFallback, {}),
|
|
187
|
-
children: /* @__PURE__ */jsxRuntime.jsx(Input,
|
|
188
|
-
config
|
|
189
|
-
|
|
182
|
+
children: /* @__PURE__ */jsxRuntime.jsx(Input, {
|
|
183
|
+
config,
|
|
184
|
+
...props
|
|
185
|
+
})
|
|
190
186
|
})
|
|
191
187
|
})
|
|
192
188
|
});
|
|
@@ -194,12 +190,14 @@ var createFormInput = config => React.memo(function FormInput(props) {
|
|
|
194
190
|
return props.renderDefault(props);
|
|
195
191
|
});
|
|
196
192
|
const Preview = React.lazy(() => Promise.resolve().then(function () {
|
|
197
|
-
return require('./Preview-
|
|
193
|
+
return require('./Preview-85174edf.js');
|
|
198
194
|
}));
|
|
199
195
|
var FormPreview = React.memo(function FormPreview(props) {
|
|
200
196
|
if (isMuxInputPreviewProps(props)) {
|
|
201
197
|
return /* @__PURE__ */jsxRuntime.jsx(AspectRatioCard, {
|
|
202
|
-
children: /* @__PURE__ */jsxRuntime.jsx(Preview,
|
|
198
|
+
children: /* @__PURE__ */jsxRuntime.jsx(Preview, {
|
|
199
|
+
...props
|
|
200
|
+
})
|
|
203
201
|
});
|
|
204
202
|
}
|
|
205
203
|
return props.renderDefault(props);
|
|
@@ -208,7 +206,10 @@ const defaultConfig = {
|
|
|
208
206
|
mp4_support: "none"
|
|
209
207
|
};
|
|
210
208
|
const muxInput = sanity.definePlugin(userConfig => {
|
|
211
|
-
const config =
|
|
209
|
+
const config = {
|
|
210
|
+
...defaultConfig,
|
|
211
|
+
...userConfig
|
|
212
|
+
};
|
|
212
213
|
const InputComponent = createFormInput(config);
|
|
213
214
|
return {
|
|
214
215
|
name: "mux-input",
|
|
@@ -261,4 +262,4 @@ exports.cacheNs = cacheNs;
|
|
|
261
262
|
exports.defaultConfig = defaultConfig;
|
|
262
263
|
exports.muxInput = muxInput;
|
|
263
264
|
exports.muxSecretsDocumentId = muxSecretsDocumentId;
|
|
264
|
-
//# sourceMappingURL=index-
|
|
265
|
+
//# sourceMappingURL=index-5a70abdc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-9933dea2.js","sources":["../../src/util/asserters.ts","../../src/util/constants.ts","../../src/components/ErrorBoundaryCard.tsx","../../src/components/Input.styled.tsx","../../src/components/FormInput.tsx","../../src/components/FormPreview.tsx","../../src/index.ts"],"sourcesContent":["import {type InputProps, type PreviewLayoutKey, type PreviewProps, isObjectInputProps} from 'sanity'\n\nimport type {MuxInputPreviewProps, MuxInputProps} from './types'\n\nexport function isMuxInputProps(props: InputProps): props is MuxInputProps {\n return isObjectInputProps(props) && props.schemaType.type?.name === 'mux.video'\n}\n\nexport function isMuxInputPreviewProps(\n props: PreviewProps<PreviewLayoutKey>\n): props is MuxInputPreviewProps {\n return props.schemaType?.type?.name === 'mux.video'\n}\n","export const name = 'mux-input' as const\n\n// Caching namespace, as suspend-react might be in use by other components on the page we must ensure we don't collide\nexport const cacheNs = 'sanity-plugin-mux-input' as const\n\nexport const muxSecretsDocumentId = 'secrets.mux' as const\n","/* eslint-disable no-console */\nimport {Button, Card, Flex, Grid, Heading, Inline, Text, useToast} from '@sanity/ui'\nimport React, {memo, useCallback, useRef} from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport {clear} from 'suspend-react'\nimport {useErrorBoundary} from 'use-error-boundary'\n\nimport {name} from '../util/constants'\nimport {type MuxInputProps} from '../util/types'\n\nexport interface Props extends Pick<MuxInputProps, 'schemaType'> {\n children: React.ReactNode\n}\nfunction ErrorBoundaryCard(props: Props) {\n const {children, schemaType} = props\n const {push: pushToast} = useToast()\n const errorRef = useRef(null)\n const {ErrorBoundary, didCatch, error, reset} = useErrorBoundary({\n onDidCatch: (err, errorInfo) => {\n console.group(err.toString())\n console.groupCollapsed('console.error')\n console.error(err)\n console.groupEnd()\n if (err.stack) {\n console.groupCollapsed('error.stack')\n console.log(err.stack)\n console.groupEnd()\n }\n if (errorInfo?.componentStack) {\n console.groupCollapsed('errorInfo.componentStack')\n console.log(errorInfo.componentStack)\n console.groupEnd()\n }\n console.groupEnd()\n pushToast({\n status: 'error',\n title: 'Plugin crashed',\n description: (\n <Flex align=\"center\">\n <Inline space={1}>\n An error happened while rendering\n <Button\n padding={1}\n fontSize={1}\n style={{transform: 'translateY(1px)'}}\n mode=\"ghost\"\n text={schemaType.title}\n onClick={() => {\n if (errorRef.current) {\n scrollIntoView(errorRef.current, {\n behavior: 'smooth',\n scrollMode: 'if-needed',\n block: 'center',\n })\n }\n }}\n />\n </Inline>\n </Flex>\n ),\n })\n },\n })\n const handleRetry = useCallback(() => {\n // Purge request cache before retrying, otherwise the cached errors will rethrow\n clear([name])\n\n reset()\n }, [reset])\n\n if (didCatch) {\n return (\n <Card ref={errorRef} paddingX={[2, 3, 4, 4]} height=\"fill\" shadow={1} overflow=\"auto\">\n <Flex justify=\"flex-start\" align=\"center\" height=\"fill\">\n <Grid columns={1} gap={[2, 3, 4, 4]}>\n <Heading as=\"h1\">\n The <code>{name}</code> plugin crashed\n </Heading>\n {error?.message && (\n <Card padding={3} tone=\"critical\" shadow={1} radius={2}>\n <Text>{error.message}</Text>\n </Card>\n )}\n <Inline>\n <Button onClick={handleRetry} text=\"Retry\" />\n </Inline>\n </Grid>\n </Flex>\n </Card>\n )\n }\n\n return <ErrorBoundary>{children}</ErrorBoundary>\n}\n\nexport default memo(ErrorBoundaryCard)\n","import {Box, Card, Flex, Spinner, Text} from '@sanity/ui'\nimport React from 'react'\nimport styled from 'styled-components'\n\n// This container base container ensures everything uses the same aspect ratio, avoids layout shifts and stuff jumping around\nexport const AspectRatioCard = styled(Card)`\n aspect-ratio: 16 / 9;\n position: relative;\n width: 100%;\n`\n\nexport const InputFallback = () => {\n return (\n <div style={{padding: 1}}>\n <Card\n shadow={1}\n sizing=\"border\"\n style={{aspectRatio: '16/9', width: '100%', borderRadius: '1px'}}\n >\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\">\n <Spinner muted />\n <Box marginTop={3}>\n <Text align=\"center\" muted size={1}>\n Loading…\n </Text>\n </Box>\n </Flex>\n </Card>\n </div>\n )\n}\n","import React, {lazy, memo, Suspense} from 'react'\nimport {type InputProps} from 'sanity'\n\nimport {isMuxInputProps} from '../util/asserters'\nimport {type Config} from '../util/types'\nimport ErrorBoundaryCard from './ErrorBoundaryCard'\nimport {AspectRatioCard, InputFallback} from './Input.styled'\n\nconst Input = lazy(() => import('./Input'))\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default (config: Config) =>\n memo(function FormInput(props: InputProps) {\n if (isMuxInputProps(props)) {\n return (\n <AspectRatioCard>\n <ErrorBoundaryCard schemaType={props.schemaType}>\n <Suspense fallback={<InputFallback />}>\n <Input config={config} {...props} />\n </Suspense>\n </ErrorBoundaryCard>\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n })\n","import React, {lazy, memo} from 'react'\nimport {PreviewLayoutKey, PreviewProps} from 'sanity'\n\nimport {isMuxInputPreviewProps} from '../util/asserters'\nimport {AspectRatioCard} from './Input.styled'\n\nconst Preview = lazy(() => import('./Preview'))\n\nexport default memo(function FormPreview(props: PreviewProps<PreviewLayoutKey>) {\n if (isMuxInputPreviewProps(props)) {\n return (\n <AspectRatioCard>\n {/* @ts-expect-error */}\n <Preview {...props} />\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n})\n","import {definePlugin} from 'sanity'\n\nimport createFormInput from './components/FormInput'\nimport FormPreview from './components/FormPreview'\nimport {type Config} from './util/types'\n\nexport const defaultConfig: Config = {\n mp4_support: 'none',\n}\n\nexport const muxInput = definePlugin<Partial<Config> | void>((userConfig) => {\n const config: Config = {...defaultConfig, ...userConfig}\n const InputComponent = createFormInput(config)\n return {\n name: 'mux-input',\n form: {\n components: {\n input: InputComponent,\n preview: FormPreview,\n },\n },\n schema: {\n types: [\n {\n name: 'mux.video',\n type: 'object',\n title: 'Video asset reference',\n fields: [\n {\n title: 'Video',\n name: 'asset',\n type: 'reference',\n weak: true,\n to: [{type: 'mux.videoAsset'}],\n },\n ],\n },\n {\n name: 'mux.videoAsset',\n type: 'object',\n title: 'Video asset',\n fields: [\n {\n type: 'string',\n name: 'status',\n },\n {\n type: 'string',\n name: 'assetId',\n },\n {\n type: 'string',\n name: 'playbackId',\n },\n {\n type: 'string',\n name: 'filename',\n },\n {\n type: 'number',\n name: 'thumbTime',\n },\n ],\n },\n ],\n },\n }\n})\n"],"names":["isMuxInputProps","props","_a","isObjectInputProps","schemaType","type","name","isMuxInputPreviewProps","_b","cacheNs","muxSecretsDocumentId","ErrorBoundaryCard","children","push","pushToast","useToast","errorRef","useRef","ErrorBoundary","didCatch","error","reset","useErrorBoundary","onDidCatch","err","errorInfo","console","group","toString","groupCollapsed","groupEnd","stack","log","componentStack","status","title","description","jsx","Flex","align","jsxs","Inline","space","Button","padding","fontSize","style","transform","mode","text","onClick","current","scrollIntoView","default","behavior","scrollMode","block","handleRetry","useCallback","clear","Card","ref","paddingX","height","shadow","overflow","justify","Grid","columns","gap","Heading","as","message","tone","radius","Text","memo","AspectRatioCard","styled","InputFallback","sizing","aspectRatio","width","borderRadius","direction","Spinner","muted","Box","marginTop","size","Input","lazy","Promise","resolve","then","require","createFormInput","config","FormInput","Suspense","fallback","renderDefault","Preview","FormPreview","defaultConfig","mp4_support","muxInput","definePlugin","userConfig","InputComponent","form","components","input","preview","schema","types","fields","weak","to"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAASA,gBAAgBC,KAA2C,EAAA;EAJ3E,IAAAC,EAAA;EAKE,OAAOC,0BAAmBF,KAAK,CAAA,IAAA,CAAA,CAAKC,WAAME,UAAW,CAAAC,IAAA,KAAjB,mBAAuBC,IAAS,MAAA,WAAA;AACtE;AAEO,SAASC,uBACdN,KAC+B,EAAA;EAVjC,IAAAC,EAAA,EAAAM,EAAA;EAWE,OAAA,CAAA,CAAOA,EAAM,GAAA,CAAAN,EAAA,GAAAD,KAAA,CAAAG,UAAA,KAAN,IAAkB,GAAA,KAAA,CAAA,GAAAF,EAAA,CAAAG,IAAA,KAAlB,mBAAwBC,IAAS,MAAA,WAAA;AAC1C;ACZO,MAAMA,IAAO,GAAA,WAAA;AAGb,MAAMG,OAAU,GAAA,yBAAA;AAEhB,MAAMC,oBAAuB,GAAA,aAAA;ACQpC,SAASC,kBAAkBV,KAAc,EAAA;EACjC,MAAA;IAACW,QAAU;IAAAR;EAAc,CAAA,GAAAH,KAAA;EAC/B,MAAM;IAACY,IAAA,EAAMC;EAAS,CAAA,GAAIC,EAAS,CAAAA,QAAA,EAAA;EAC7B,MAAAC,QAAA,GAAWC,aAAO,IAAI,CAAA;EAC5B,MAAM;IAACC,aAAe;IAAAC,QAAA;IAAUC,KAAO;IAAAC;EAAA,IAASC,gBAAAA,CAAAA,gBAAiB,CAAA;IAC/DC,UAAA,EAAY,CAACC,GAAA,EAAKC,SAAc,KAAA;MACtBC,OAAA,CAAAC,KAAA,CAAMH,GAAI,CAAAI,QAAA,EAAU,CAA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AM,EAAA,gBAAA;QACND,IAAM,EAAA,QAAA;QACN8B,KAAO,EAAA,aAAA;QACPiF,MAAQ,EAAA,CACN;UACE/G,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA;MAEJ,CAAA;IAEJ;EAAA,CACF;AACF,CAAC,CAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"index-5a70abdc.js","sources":["../../src/util/asserters.ts","../../src/util/constants.ts","../../src/components/ErrorBoundaryCard.tsx","../../src/components/Input.styled.tsx","../../src/components/FormInput.tsx","../../src/components/FormPreview.tsx","../../src/index.ts"],"sourcesContent":["import {type InputProps, type PreviewLayoutKey, type PreviewProps, isObjectInputProps} from 'sanity'\n\nimport type {MuxInputPreviewProps, MuxInputProps} from './types'\n\nexport function isMuxInputProps(props: InputProps): props is MuxInputProps {\n return isObjectInputProps(props) && props.schemaType.type?.name === 'mux.video'\n}\n\nexport function isMuxInputPreviewProps(\n props: PreviewProps<PreviewLayoutKey>\n): props is MuxInputPreviewProps {\n return props.schemaType?.type?.name === 'mux.video'\n}\n","export const name = 'mux-input' as const\n\n// Caching namespace, as suspend-react might be in use by other components on the page we must ensure we don't collide\nexport const cacheNs = 'sanity-plugin-mux-input' as const\n\nexport const muxSecretsDocumentId = 'secrets.mux' as const\n","/* eslint-disable no-console */\nimport {Button, Card, Flex, Grid, Heading, Inline, Text, useToast} from '@sanity/ui'\nimport React, {memo, useCallback, useRef} from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport {clear} from 'suspend-react'\nimport {useErrorBoundary} from 'use-error-boundary'\n\nimport {name} from '../util/constants'\nimport {type MuxInputProps} from '../util/types'\n\nexport interface Props extends Pick<MuxInputProps, 'schemaType'> {\n children: React.ReactNode\n}\nfunction ErrorBoundaryCard(props: Props) {\n const {children, schemaType} = props\n const {push: pushToast} = useToast()\n const errorRef = useRef(null)\n const {ErrorBoundary, didCatch, error, reset} = useErrorBoundary({\n onDidCatch: (err, errorInfo) => {\n console.group(err.toString())\n console.groupCollapsed('console.error')\n console.error(err)\n console.groupEnd()\n if (err.stack) {\n console.groupCollapsed('error.stack')\n console.log(err.stack)\n console.groupEnd()\n }\n if (errorInfo?.componentStack) {\n console.groupCollapsed('errorInfo.componentStack')\n console.log(errorInfo.componentStack)\n console.groupEnd()\n }\n console.groupEnd()\n pushToast({\n status: 'error',\n title: 'Plugin crashed',\n description: (\n <Flex align=\"center\">\n <Inline space={1}>\n An error happened while rendering\n <Button\n padding={1}\n fontSize={1}\n style={{transform: 'translateY(1px)'}}\n mode=\"ghost\"\n text={schemaType.title}\n onClick={() => {\n if (errorRef.current) {\n scrollIntoView(errorRef.current, {\n behavior: 'smooth',\n scrollMode: 'if-needed',\n block: 'center',\n })\n }\n }}\n />\n </Inline>\n </Flex>\n ),\n })\n },\n })\n const handleRetry = useCallback(() => {\n // Purge request cache before retrying, otherwise the cached errors will rethrow\n clear([name])\n\n reset()\n }, [reset])\n\n if (didCatch) {\n return (\n <Card ref={errorRef} paddingX={[2, 3, 4, 4]} height=\"fill\" shadow={1} overflow=\"auto\">\n <Flex justify=\"flex-start\" align=\"center\" height=\"fill\">\n <Grid columns={1} gap={[2, 3, 4, 4]}>\n <Heading as=\"h1\">\n The <code>{name}</code> plugin crashed\n </Heading>\n {error?.message && (\n <Card padding={3} tone=\"critical\" shadow={1} radius={2}>\n <Text>{error.message}</Text>\n </Card>\n )}\n <Inline>\n <Button onClick={handleRetry} text=\"Retry\" />\n </Inline>\n </Grid>\n </Flex>\n </Card>\n )\n }\n\n return <ErrorBoundary>{children}</ErrorBoundary>\n}\n\nexport default memo(ErrorBoundaryCard)\n","import {Box, Card, Flex, Spinner, Text} from '@sanity/ui'\nimport React from 'react'\nimport styled from 'styled-components'\n\n// This container base container ensures everything uses the same aspect ratio, avoids layout shifts and stuff jumping around\nexport const AspectRatioCard = styled(Card)`\n aspect-ratio: 16 / 9;\n position: relative;\n width: 100%;\n`\n\nexport const InputFallback = () => {\n return (\n <div style={{padding: 1}}>\n <Card\n shadow={1}\n sizing=\"border\"\n style={{aspectRatio: '16/9', width: '100%', borderRadius: '1px'}}\n >\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\">\n <Spinner muted />\n <Box marginTop={3}>\n <Text align=\"center\" muted size={1}>\n Loading…\n </Text>\n </Box>\n </Flex>\n </Card>\n </div>\n )\n}\n","import React, {lazy, memo, Suspense} from 'react'\nimport {type InputProps} from 'sanity'\n\nimport {isMuxInputProps} from '../util/asserters'\nimport {type Config} from '../util/types'\nimport ErrorBoundaryCard from './ErrorBoundaryCard'\nimport {AspectRatioCard, InputFallback} from './Input.styled'\n\nconst Input = lazy(() => import('./Input'))\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default (config: Config) =>\n memo(function FormInput(props: InputProps) {\n if (isMuxInputProps(props)) {\n return (\n <AspectRatioCard>\n <ErrorBoundaryCard schemaType={props.schemaType}>\n <Suspense fallback={<InputFallback />}>\n <Input config={config} {...props} />\n </Suspense>\n </ErrorBoundaryCard>\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n })\n","import React, {lazy, memo} from 'react'\nimport {PreviewLayoutKey, PreviewProps} from 'sanity'\n\nimport {isMuxInputPreviewProps} from '../util/asserters'\nimport {AspectRatioCard} from './Input.styled'\n\nconst Preview = lazy(() => import('./Preview'))\n\nexport default memo(function FormPreview(props: PreviewProps<PreviewLayoutKey>) {\n if (isMuxInputPreviewProps(props)) {\n return (\n <AspectRatioCard>\n {/* @ts-expect-error */}\n <Preview {...props} />\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n})\n","import {definePlugin} from 'sanity'\n\nimport createFormInput from './components/FormInput'\nimport FormPreview from './components/FormPreview'\nimport {type Config} from './util/types'\n\nexport const defaultConfig: Config = {\n mp4_support: 'none',\n}\n\nexport const muxInput = definePlugin<Partial<Config> | void>((userConfig) => {\n const config: Config = {...defaultConfig, ...userConfig}\n const InputComponent = createFormInput(config)\n return {\n name: 'mux-input',\n form: {\n components: {\n input: InputComponent,\n preview: FormPreview,\n },\n },\n schema: {\n types: [\n {\n name: 'mux.video',\n type: 'object',\n title: 'Video asset reference',\n fields: [\n {\n title: 'Video',\n name: 'asset',\n type: 'reference',\n weak: true,\n to: [{type: 'mux.videoAsset'}],\n },\n ],\n },\n {\n name: 'mux.videoAsset',\n type: 'object',\n title: 'Video asset',\n fields: [\n {\n type: 'string',\n name: 'status',\n },\n {\n type: 'string',\n name: 'assetId',\n },\n {\n type: 'string',\n name: 'playbackId',\n },\n {\n type: 'string',\n name: 'filename',\n },\n {\n type: 'number',\n name: 'thumbTime',\n },\n ],\n },\n ],\n },\n }\n})\n"],"names":["isMuxInputProps","props","_a","isObjectInputProps","schemaType","type","name","isMuxInputPreviewProps","_b","cacheNs","muxSecretsDocumentId","ErrorBoundaryCard","children","push","pushToast","useToast","errorRef","useRef","ErrorBoundary","didCatch","error","reset","useErrorBoundary","onDidCatch","err","errorInfo","console","group","toString","groupCollapsed","groupEnd","stack","log","componentStack","status","title","description","Flex","align","jsxs","Inline","space","jsx","Button","padding","fontSize","style","transform","mode","text","onClick","current","scrollIntoView","default","behavior","scrollMode","block","handleRetry","useCallback","clear","Card","ref","paddingX","height","shadow","overflow","justify","Grid","columns","gap","Heading","as","message","tone","radius","Text","memo","AspectRatioCard","styled","InputFallback","sizing","aspectRatio","width","borderRadius","direction","Spinner","muted","Box","marginTop","size","Input","lazy","Promise","resolve","then","require","createFormInput","config","FormInput","Suspense","fallback","renderDefault","Preview","FormPreview","defaultConfig","mp4_support","muxInput","definePlugin","userConfig","InputComponent","form","components","input","preview","schema","types","fields","weak","to"],"mappings":";;;;;;;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f,CAAA;AAEa,MAAAC,QAAA,GAAWC,MAAAA,CAAAA,YAAqC,CAACC,UAAe,IAAA;EAC3E,MAAMX,MAAiB,GAAA;IAAC,GAAGO,aAAA;IAAe,GAAGI;EAAU,CAAA;EACjD,MAAAC,cAAA,GAAiBb,gBAAgBC,MAAM,CAAA;EACtC,OAAA;IACL3F,IAAM,EAAA,WAAA;IACNwG,IAAM,EAAA;MACJC,UAAY,EAAA;QACVC,KAAO,EAAAH,cAAA;QACPI,OAAS,EAAAV;MACX;IACF,CAAA;IACAW,MAAQ,EAAA;MACNC,KAAO,EAAA,CACL;QACE7G,IAAM,EAAA,WAAA;QACND,IAAM,EAAA,QAAA;QACN8B,KAAO,EAAA,uBAAA;QACPiF,MAAQ,EAAA,CACN;UACEjF,KAAO,EAAA,OAAA;UACP7B,IAAM,EAAA,OAAA;UACND,IAAM,EAAA,WAAA;UACNgH,IAAM,EAAA,IAAA;UACNC,EAAI,EAAA,CAAC;YAACjH,IAAA,EAAM;WAAiB;QAC/B,CAAA;MAEJ,CAAA,EACA;QACEC,IAAM,EAAA,gBAAA;QACND,IAAM,EAAA,QAAA;QACN8B,KAAO,EAAA,aAAA;QACPiF,MAAQ,EAAA,CACN;UACE/G,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA;MAEJ,CAAA;IAEJ;EAAA,CACF;AACF,CAAC,CAAA;;;;;"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
8
3
|
import { isObjectInputProps, definePlugin } from 'sanity';
|
|
9
4
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -165,7 +160,7 @@ const InputFallback = () => {
|
|
|
165
160
|
})
|
|
166
161
|
});
|
|
167
162
|
};
|
|
168
|
-
const Input = lazy(() => import('./Input-
|
|
163
|
+
const Input = lazy(() => import('./Input-235cb658.js'));
|
|
169
164
|
var createFormInput = config => memo(function FormInput(props) {
|
|
170
165
|
if (isMuxInputProps(props)) {
|
|
171
166
|
return /* @__PURE__ */jsx(AspectRatioCard, {
|
|
@@ -173,20 +168,23 @@ var createFormInput = config => memo(function FormInput(props) {
|
|
|
173
168
|
schemaType: props.schemaType,
|
|
174
169
|
children: /* @__PURE__ */jsx(Suspense, {
|
|
175
170
|
fallback: /* @__PURE__ */jsx(InputFallback, {}),
|
|
176
|
-
children: /* @__PURE__ */jsx(Input,
|
|
177
|
-
config
|
|
178
|
-
|
|
171
|
+
children: /* @__PURE__ */jsx(Input, {
|
|
172
|
+
config,
|
|
173
|
+
...props
|
|
174
|
+
})
|
|
179
175
|
})
|
|
180
176
|
})
|
|
181
177
|
});
|
|
182
178
|
}
|
|
183
179
|
return props.renderDefault(props);
|
|
184
180
|
});
|
|
185
|
-
const Preview = lazy(() => import('./Preview-
|
|
181
|
+
const Preview = lazy(() => import('./Preview-ced24517.js'));
|
|
186
182
|
var FormPreview = memo(function FormPreview(props) {
|
|
187
183
|
if (isMuxInputPreviewProps(props)) {
|
|
188
184
|
return /* @__PURE__ */jsx(AspectRatioCard, {
|
|
189
|
-
children: /* @__PURE__ */jsx(Preview,
|
|
185
|
+
children: /* @__PURE__ */jsx(Preview, {
|
|
186
|
+
...props
|
|
187
|
+
})
|
|
190
188
|
});
|
|
191
189
|
}
|
|
192
190
|
return props.renderDefault(props);
|
|
@@ -195,7 +193,10 @@ const defaultConfig = {
|
|
|
195
193
|
mp4_support: "none"
|
|
196
194
|
};
|
|
197
195
|
const muxInput = definePlugin(userConfig => {
|
|
198
|
-
const config =
|
|
196
|
+
const config = {
|
|
197
|
+
...defaultConfig,
|
|
198
|
+
...userConfig
|
|
199
|
+
};
|
|
199
200
|
const InputComponent = createFormInput(config);
|
|
200
201
|
return {
|
|
201
202
|
name: "mux-input",
|
|
@@ -244,4 +245,4 @@ const muxInput = definePlugin(userConfig => {
|
|
|
244
245
|
};
|
|
245
246
|
});
|
|
246
247
|
export { InputFallback, cacheNs, defaultConfig, muxInput, muxSecretsDocumentId };
|
|
247
|
-
//# sourceMappingURL=index-
|
|
248
|
+
//# sourceMappingURL=index-7260e0df.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-c54f5393.js","sources":["../../src/util/asserters.ts","../../src/util/constants.ts","../../src/components/ErrorBoundaryCard.tsx","../../src/components/Input.styled.tsx","../../src/components/FormInput.tsx","../../src/components/FormPreview.tsx","../../src/index.ts"],"sourcesContent":["import {type InputProps, type PreviewLayoutKey, type PreviewProps, isObjectInputProps} from 'sanity'\n\nimport type {MuxInputPreviewProps, MuxInputProps} from './types'\n\nexport function isMuxInputProps(props: InputProps): props is MuxInputProps {\n return isObjectInputProps(props) && props.schemaType.type?.name === 'mux.video'\n}\n\nexport function isMuxInputPreviewProps(\n props: PreviewProps<PreviewLayoutKey>\n): props is MuxInputPreviewProps {\n return props.schemaType?.type?.name === 'mux.video'\n}\n","export const name = 'mux-input' as const\n\n// Caching namespace, as suspend-react might be in use by other components on the page we must ensure we don't collide\nexport const cacheNs = 'sanity-plugin-mux-input' as const\n\nexport const muxSecretsDocumentId = 'secrets.mux' as const\n","/* eslint-disable no-console */\nimport {Button, Card, Flex, Grid, Heading, Inline, Text, useToast} from '@sanity/ui'\nimport React, {memo, useCallback, useRef} from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport {clear} from 'suspend-react'\nimport {useErrorBoundary} from 'use-error-boundary'\n\nimport {name} from '../util/constants'\nimport {type MuxInputProps} from '../util/types'\n\nexport interface Props extends Pick<MuxInputProps, 'schemaType'> {\n children: React.ReactNode\n}\nfunction ErrorBoundaryCard(props: Props) {\n const {children, schemaType} = props\n const {push: pushToast} = useToast()\n const errorRef = useRef(null)\n const {ErrorBoundary, didCatch, error, reset} = useErrorBoundary({\n onDidCatch: (err, errorInfo) => {\n console.group(err.toString())\n console.groupCollapsed('console.error')\n console.error(err)\n console.groupEnd()\n if (err.stack) {\n console.groupCollapsed('error.stack')\n console.log(err.stack)\n console.groupEnd()\n }\n if (errorInfo?.componentStack) {\n console.groupCollapsed('errorInfo.componentStack')\n console.log(errorInfo.componentStack)\n console.groupEnd()\n }\n console.groupEnd()\n pushToast({\n status: 'error',\n title: 'Plugin crashed',\n description: (\n <Flex align=\"center\">\n <Inline space={1}>\n An error happened while rendering\n <Button\n padding={1}\n fontSize={1}\n style={{transform: 'translateY(1px)'}}\n mode=\"ghost\"\n text={schemaType.title}\n onClick={() => {\n if (errorRef.current) {\n scrollIntoView(errorRef.current, {\n behavior: 'smooth',\n scrollMode: 'if-needed',\n block: 'center',\n })\n }\n }}\n />\n </Inline>\n </Flex>\n ),\n })\n },\n })\n const handleRetry = useCallback(() => {\n // Purge request cache before retrying, otherwise the cached errors will rethrow\n clear([name])\n\n reset()\n }, [reset])\n\n if (didCatch) {\n return (\n <Card ref={errorRef} paddingX={[2, 3, 4, 4]} height=\"fill\" shadow={1} overflow=\"auto\">\n <Flex justify=\"flex-start\" align=\"center\" height=\"fill\">\n <Grid columns={1} gap={[2, 3, 4, 4]}>\n <Heading as=\"h1\">\n The <code>{name}</code> plugin crashed\n </Heading>\n {error?.message && (\n <Card padding={3} tone=\"critical\" shadow={1} radius={2}>\n <Text>{error.message}</Text>\n </Card>\n )}\n <Inline>\n <Button onClick={handleRetry} text=\"Retry\" />\n </Inline>\n </Grid>\n </Flex>\n </Card>\n )\n }\n\n return <ErrorBoundary>{children}</ErrorBoundary>\n}\n\nexport default memo(ErrorBoundaryCard)\n","import {Box, Card, Flex, Spinner, Text} from '@sanity/ui'\nimport React from 'react'\nimport styled from 'styled-components'\n\n// This container base container ensures everything uses the same aspect ratio, avoids layout shifts and stuff jumping around\nexport const AspectRatioCard = styled(Card)`\n aspect-ratio: 16 / 9;\n position: relative;\n width: 100%;\n`\n\nexport const InputFallback = () => {\n return (\n <div style={{padding: 1}}>\n <Card\n shadow={1}\n sizing=\"border\"\n style={{aspectRatio: '16/9', width: '100%', borderRadius: '1px'}}\n >\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\">\n <Spinner muted />\n <Box marginTop={3}>\n <Text align=\"center\" muted size={1}>\n Loading…\n </Text>\n </Box>\n </Flex>\n </Card>\n </div>\n )\n}\n","import React, {lazy, memo, Suspense} from 'react'\nimport {type InputProps} from 'sanity'\n\nimport {isMuxInputProps} from '../util/asserters'\nimport {type Config} from '../util/types'\nimport ErrorBoundaryCard from './ErrorBoundaryCard'\nimport {AspectRatioCard, InputFallback} from './Input.styled'\n\nconst Input = lazy(() => import('./Input'))\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default (config: Config) =>\n memo(function FormInput(props: InputProps) {\n if (isMuxInputProps(props)) {\n return (\n <AspectRatioCard>\n <ErrorBoundaryCard schemaType={props.schemaType}>\n <Suspense fallback={<InputFallback />}>\n <Input config={config} {...props} />\n </Suspense>\n </ErrorBoundaryCard>\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n })\n","import React, {lazy, memo} from 'react'\nimport {PreviewLayoutKey, PreviewProps} from 'sanity'\n\nimport {isMuxInputPreviewProps} from '../util/asserters'\nimport {AspectRatioCard} from './Input.styled'\n\nconst Preview = lazy(() => import('./Preview'))\n\nexport default memo(function FormPreview(props: PreviewProps<PreviewLayoutKey>) {\n if (isMuxInputPreviewProps(props)) {\n return (\n <AspectRatioCard>\n {/* @ts-expect-error */}\n <Preview {...props} />\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n})\n","import {definePlugin} from 'sanity'\n\nimport createFormInput from './components/FormInput'\nimport FormPreview from './components/FormPreview'\nimport {type Config} from './util/types'\n\nexport const defaultConfig: Config = {\n mp4_support: 'none',\n}\n\nexport const muxInput = definePlugin<Partial<Config> | void>((userConfig) => {\n const config: Config = {...defaultConfig, ...userConfig}\n const InputComponent = createFormInput(config)\n return {\n name: 'mux-input',\n form: {\n components: {\n input: InputComponent,\n preview: FormPreview,\n },\n },\n schema: {\n types: [\n {\n name: 'mux.video',\n type: 'object',\n title: 'Video asset reference',\n fields: [\n {\n title: 'Video',\n name: 'asset',\n type: 'reference',\n weak: true,\n to: [{type: 'mux.videoAsset'}],\n },\n ],\n },\n {\n name: 'mux.videoAsset',\n type: 'object',\n title: 'Video asset',\n fields: [\n {\n type: 'string',\n name: 'status',\n },\n {\n type: 'string',\n name: 'assetId',\n },\n {\n type: 'string',\n name: 'playbackId',\n },\n {\n type: 'string',\n name: 'filename',\n },\n {\n type: 'number',\n name: 'thumbTime',\n },\n ],\n },\n ],\n },\n }\n})\n"],"names":["isMuxInputProps","props","_a","isObjectInputProps","schemaType","type","name","isMuxInputPreviewProps","_b","cacheNs","muxSecretsDocumentId","ErrorBoundaryCard","children","push","pushToast","useToast","errorRef","useRef","ErrorBoundary","didCatch","error","reset","useErrorBoundary","onDidCatch","err","errorInfo","console","group","toString","groupCollapsed","groupEnd","stack","log","componentStack","status","title","description","jsx","Flex","align","jsxs","Inline","space","Button","padding","fontSize","style","transform","mode","text","onClick","current","scrollIntoView","behavior","scrollMode","block","handleRetry","useCallback","clear","Card","ref","paddingX","height","shadow","overflow","justify","Grid","columns","gap","Heading","as","message","tone","radius","Text","ErrorBoundaryCard$1","memo","AspectRatioCard","styled","InputFallback","sizing","aspectRatio","width","borderRadius","direction","Spinner","muted","Box","marginTop","size","Input","lazy","createFormInput","config","FormInput","Suspense","fallback","renderDefault","Preview","FormPreview","defaultConfig","mp4_support","muxInput","definePlugin","userConfig","InputComponent","form","components","input","preview","schema","types","fields","weak","to"],"mappings":";;;;;;;;;;;;;;;AAIO,SAASA,gBAAgBC,KAA2C,EAAA;EAJ3E,IAAAC,EAAA;EAKE,OAAOC,mBAAmBF,KAAK,CAAA,IAAA,CAAA,CAAKC,WAAME,UAAW,CAAAC,IAAA,KAAjB,mBAAuBC,IAAS,MAAA,WAAA;AACtE;AAEO,SAASC,uBACdN,KAC+B,EAAA;EAVjC,IAAAC,EAAA,EAAAM,EAAA;EAWE,OAAA,CAAA,CAAOA,EAAM,GAAA,CAAAN,EAAA,GAAAD,KAAA,CAAAG,UAAA,KAAN,IAAkB,GAAA,KAAA,CAAA,GAAAF,EAAA,CAAAG,IAAA,KAAlB,mBAAwBC,IAAS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QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA;MAEJ,CAAA;IAEJ;EAAA,CACF;AACF,CAAC,CAAA;"}
|
|
1
|
+
{"version":3,"file":"index-7260e0df.js","sources":["../../src/util/asserters.ts","../../src/util/constants.ts","../../src/components/ErrorBoundaryCard.tsx","../../src/components/Input.styled.tsx","../../src/components/FormInput.tsx","../../src/components/FormPreview.tsx","../../src/index.ts"],"sourcesContent":["import {type InputProps, type PreviewLayoutKey, type PreviewProps, isObjectInputProps} from 'sanity'\n\nimport type {MuxInputPreviewProps, MuxInputProps} from './types'\n\nexport function isMuxInputProps(props: InputProps): props is MuxInputProps {\n return isObjectInputProps(props) && props.schemaType.type?.name === 'mux.video'\n}\n\nexport function isMuxInputPreviewProps(\n props: PreviewProps<PreviewLayoutKey>\n): props is MuxInputPreviewProps {\n return props.schemaType?.type?.name === 'mux.video'\n}\n","export const name = 'mux-input' as const\n\n// Caching namespace, as suspend-react might be in use by other components on the page we must ensure we don't collide\nexport const cacheNs = 'sanity-plugin-mux-input' as const\n\nexport const muxSecretsDocumentId = 'secrets.mux' as const\n","/* eslint-disable no-console */\nimport {Button, Card, Flex, Grid, Heading, Inline, Text, useToast} from '@sanity/ui'\nimport React, {memo, useCallback, useRef} from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport {clear} from 'suspend-react'\nimport {useErrorBoundary} from 'use-error-boundary'\n\nimport {name} from '../util/constants'\nimport {type MuxInputProps} from '../util/types'\n\nexport interface Props extends Pick<MuxInputProps, 'schemaType'> {\n children: React.ReactNode\n}\nfunction ErrorBoundaryCard(props: Props) {\n const {children, schemaType} = props\n const {push: pushToast} = useToast()\n const errorRef = useRef(null)\n const {ErrorBoundary, didCatch, error, reset} = useErrorBoundary({\n onDidCatch: (err, errorInfo) => {\n console.group(err.toString())\n console.groupCollapsed('console.error')\n console.error(err)\n console.groupEnd()\n if (err.stack) {\n console.groupCollapsed('error.stack')\n console.log(err.stack)\n console.groupEnd()\n }\n if (errorInfo?.componentStack) {\n console.groupCollapsed('errorInfo.componentStack')\n console.log(errorInfo.componentStack)\n console.groupEnd()\n }\n console.groupEnd()\n pushToast({\n status: 'error',\n title: 'Plugin crashed',\n description: (\n <Flex align=\"center\">\n <Inline space={1}>\n An error happened while rendering\n <Button\n padding={1}\n fontSize={1}\n style={{transform: 'translateY(1px)'}}\n mode=\"ghost\"\n text={schemaType.title}\n onClick={() => {\n if (errorRef.current) {\n scrollIntoView(errorRef.current, {\n behavior: 'smooth',\n scrollMode: 'if-needed',\n block: 'center',\n })\n }\n }}\n />\n </Inline>\n </Flex>\n ),\n })\n },\n })\n const handleRetry = useCallback(() => {\n // Purge request cache before retrying, otherwise the cached errors will rethrow\n clear([name])\n\n reset()\n }, [reset])\n\n if (didCatch) {\n return (\n <Card ref={errorRef} paddingX={[2, 3, 4, 4]} height=\"fill\" shadow={1} overflow=\"auto\">\n <Flex justify=\"flex-start\" align=\"center\" height=\"fill\">\n <Grid columns={1} gap={[2, 3, 4, 4]}>\n <Heading as=\"h1\">\n The <code>{name}</code> plugin crashed\n </Heading>\n {error?.message && (\n <Card padding={3} tone=\"critical\" shadow={1} radius={2}>\n <Text>{error.message}</Text>\n </Card>\n )}\n <Inline>\n <Button onClick={handleRetry} text=\"Retry\" />\n </Inline>\n </Grid>\n </Flex>\n </Card>\n )\n }\n\n return <ErrorBoundary>{children}</ErrorBoundary>\n}\n\nexport default memo(ErrorBoundaryCard)\n","import {Box, Card, Flex, Spinner, Text} from '@sanity/ui'\nimport React from 'react'\nimport styled from 'styled-components'\n\n// This container base container ensures everything uses the same aspect ratio, avoids layout shifts and stuff jumping around\nexport const AspectRatioCard = styled(Card)`\n aspect-ratio: 16 / 9;\n position: relative;\n width: 100%;\n`\n\nexport const InputFallback = () => {\n return (\n <div style={{padding: 1}}>\n <Card\n shadow={1}\n sizing=\"border\"\n style={{aspectRatio: '16/9', width: '100%', borderRadius: '1px'}}\n >\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\">\n <Spinner muted />\n <Box marginTop={3}>\n <Text align=\"center\" muted size={1}>\n Loading…\n </Text>\n </Box>\n </Flex>\n </Card>\n </div>\n )\n}\n","import React, {lazy, memo, Suspense} from 'react'\nimport {type InputProps} from 'sanity'\n\nimport {isMuxInputProps} from '../util/asserters'\nimport {type Config} from '../util/types'\nimport ErrorBoundaryCard from './ErrorBoundaryCard'\nimport {AspectRatioCard, InputFallback} from './Input.styled'\n\nconst Input = lazy(() => import('./Input'))\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default (config: Config) =>\n memo(function FormInput(props: InputProps) {\n if (isMuxInputProps(props)) {\n return (\n <AspectRatioCard>\n <ErrorBoundaryCard schemaType={props.schemaType}>\n <Suspense fallback={<InputFallback />}>\n <Input config={config} {...props} />\n </Suspense>\n </ErrorBoundaryCard>\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n })\n","import React, {lazy, memo} from 'react'\nimport {PreviewLayoutKey, PreviewProps} from 'sanity'\n\nimport {isMuxInputPreviewProps} from '../util/asserters'\nimport {AspectRatioCard} from './Input.styled'\n\nconst Preview = lazy(() => import('./Preview'))\n\nexport default memo(function FormPreview(props: PreviewProps<PreviewLayoutKey>) {\n if (isMuxInputPreviewProps(props)) {\n return (\n <AspectRatioCard>\n {/* @ts-expect-error */}\n <Preview {...props} />\n </AspectRatioCard>\n )\n }\n return props.renderDefault(props)\n})\n","import {definePlugin} from 'sanity'\n\nimport createFormInput from './components/FormInput'\nimport FormPreview from './components/FormPreview'\nimport {type Config} from './util/types'\n\nexport const defaultConfig: Config = {\n mp4_support: 'none',\n}\n\nexport const muxInput = definePlugin<Partial<Config> | void>((userConfig) => {\n const config: Config = {...defaultConfig, ...userConfig}\n const InputComponent = createFormInput(config)\n return {\n name: 'mux-input',\n form: {\n components: {\n input: InputComponent,\n preview: FormPreview,\n },\n },\n schema: {\n types: [\n {\n name: 'mux.video',\n type: 'object',\n title: 'Video asset reference',\n fields: [\n {\n title: 'Video',\n name: 'asset',\n type: 'reference',\n weak: true,\n to: [{type: 'mux.videoAsset'}],\n },\n ],\n },\n {\n name: 'mux.videoAsset',\n type: 'object',\n title: 'Video asset',\n fields: [\n {\n type: 'string',\n name: 'status',\n },\n {\n type: 'string',\n name: 'assetId',\n },\n {\n type: 'string',\n name: 'playbackId',\n },\n {\n type: 'string',\n name: 'filename',\n },\n {\n type: 'number',\n name: 'thumbTime',\n },\n ],\n },\n ],\n },\n }\n})\n"],"names":["isMuxInputProps","props","_a","isObjectInputProps","schemaType","type","name","isMuxInputPreviewProps","_b","cacheNs","muxSecretsDocumentId","ErrorBoundaryCard","children","push","pushToast","useToast","errorRef","useRef","ErrorBoundary","didCatch","error","reset","useErrorBoundary","onDidCatch","err","errorInfo","console","group","toString","groupCollapsed","groupEnd","stack","log","componentStack","status","title","description","Flex","align","jsxs","Inline","space","jsx","Button","padding","fontSize","style","transform","mode","text","onClick","current","scrollIntoView","behavior","scrollMode","block","handleRetry","useCallback","clear","Card","ref","paddingX","height","shadow","overflow","justify","Grid","columns","gap","Heading","as","message","tone","radius","Text","ErrorBoundaryCard$1","memo","AspectRatioCard","styled","InputFallback","sizing","aspectRatio","width","borderRadius","direction","Spinner","muted","Box","marginTop","size","Input","lazy","createFormInput","config","FormInput","Suspense","fallback","renderDefault","Preview","FormPreview","defaultConfig","mp4_support","muxInput","definePlugin","userConfig","InputComponent","form","components","input","preview","schema","types","fields","weak","to"],"mappings":";;;;;;;;;;AAIO,SAASA,gBAAgBC,KAA2C,EAAA;EAJ3E,IAAAC,EAAA;EAKE,OAAOC,mBAAmBF,KAAK,CAAA,IAAA,CAAA,CAAKC,WAAME,UAAW,CAAAC,IAAA,KAAjB,mBAAuBC,IAAS,MAAA,WAAA;AACtE;AAEO,SAASC,uBACdN,KAC+B,EAAA;EAVjC,IAAAC,E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ACNC,IAAM,EAAA;QACR,CAAA;MAEJ,CAAA;IAEJ;EAAA,CACF;AACF,CAAC,CAAA;"}
|
package/lib/index.esm.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
require('sanity');
|
|
7
|
-
var index = require('./_chunks/index-
|
|
7
|
+
var index = require('./_chunks/index-5a70abdc.js');
|
|
8
8
|
exports.defaultConfig = index.defaultConfig;
|
|
9
9
|
exports.muxInput = index.muxInput;
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-mux-input",
|
|
3
|
-
"version": "2.0.
|
|
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/
|
|
60
|
-
"@mux/upchunk": "^3
|
|
61
|
-
"@sanity/icons": "^2
|
|
62
|
-
"@sanity/incompatible-plugin": "^1
|
|
63
|
-
"@sanity/ui": "^1
|
|
64
|
-
"@sanity/uuid": "^3
|
|
59
|
+
"@mux/mux-video-react": "^0.7",
|
|
60
|
+
"@mux/upchunk": "^3",
|
|
61
|
+
"@sanity/icons": "^2",
|
|
62
|
+
"@sanity/incompatible-plugin": "^1",
|
|
63
|
+
"@sanity/ui": "^1",
|
|
64
|
+
"@sanity/uuid": "^3",
|
|
65
65
|
"classnames": "^2.3.2",
|
|
66
66
|
"jsonwebtoken-esm": "^1.0.3",
|
|
67
|
-
"media-chrome": "^0.
|
|
68
|
-
"motion": "^10
|
|
69
|
-
"rxjs": "^
|
|
70
|
-
"scroll-into-view-if-needed": "^3
|
|
71
|
-
"suspend-react": "^0.0.
|
|
72
|
-
"swr": "^
|
|
73
|
-
"use-device-pixel-ratio": "^1.1.
|
|
67
|
+
"media-chrome": "^0.17.0",
|
|
68
|
+
"motion": "^10",
|
|
69
|
+
"rxjs": "^7",
|
|
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
|
|
78
|
-
"@commitlint/config-conventional": "^17.2
|
|
79
|
-
"@sanity/pkg-utils": "^2.1
|
|
80
|
-
"@sanity/plugin-kit": "^3.1.
|
|
81
|
-
"@sanity/semantic-release-preset": "^
|
|
82
|
-
"@sanity/vision": "^3.
|
|
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.
|
|
86
|
-
"@typescript-eslint/parser": "^5.48.
|
|
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.
|
|
92
|
+
"eslint-plugin-import": "^2.27.4",
|
|
93
93
|
"eslint-plugin-prettier": "^4.2.1",
|
|
94
|
-
"eslint-plugin-react": "^7.
|
|
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.
|
|
98
|
-
"lint-staged": "^13.0
|
|
99
|
-
"next": "^13.
|
|
100
|
-
"next-sanity": "^
|
|
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.
|
|
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": "^
|
|
108
|
-
"sanity": "^3.
|
|
107
|
+
"rimraf": "^4.0.4",
|
|
108
|
+
"sanity": "^3.2.3",
|
|
109
109
|
"styled-components": "^5.3.6",
|
|
110
|
-
"type-fest": "^3.
|
|
110
|
+
"type-fest": "^3.5.1",
|
|
111
111
|
"typescript": "^4.9.4"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|
package/src/actions/assets.ts
CHANGED
package/src/actions/secrets.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import type {SanityClient} from '
|
|
1
|
+
import type {SanityClient} from 'sanity'
|
|
2
2
|
import {defer} from 'rxjs'
|
|
3
3
|
|
|
4
|
+
interface SecretsDocument {
|
|
5
|
+
_id: 'secrets.mux'
|
|
6
|
+
_type: 'mux.apiKey'
|
|
7
|
+
token: string
|
|
8
|
+
secretKey: string
|
|
9
|
+
enableSignedUrls: boolean
|
|
10
|
+
signingKeyId: string
|
|
11
|
+
signingKeyPrivate: string
|
|
12
|
+
}
|
|
4
13
|
// eslint-disable-next-line max-params
|
|
5
14
|
export function saveSecrets(
|
|
6
15
|
client: SanityClient,
|
|
@@ -9,8 +18,8 @@ export function saveSecrets(
|
|
|
9
18
|
enableSignedUrls: boolean,
|
|
10
19
|
signingKeyId: string,
|
|
11
20
|
signingKeyPrivate: string
|
|
12
|
-
) {
|
|
13
|
-
const doc = {
|
|
21
|
+
): Promise<SecretsDocument> {
|
|
22
|
+
const doc: SecretsDocument = {
|
|
14
23
|
_id: 'secrets.mux',
|
|
15
24
|
_type: 'mux.apiKey',
|
|
16
25
|
token,
|