sanity-plugin-mux-input 2.0.2 → 2.0.3
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/lib/_chunks/Input-4ec3c050.js +2666 -0
- package/lib/_chunks/Input-4ec3c050.js.map +1 -0
- package/lib/_chunks/Input-aa6d929b.js +2636 -0
- package/lib/_chunks/Input-aa6d929b.js.map +1 -0
- package/lib/_chunks/Preview-1664b7d5.js +28 -0
- package/lib/_chunks/Preview-1664b7d5.js.map +1 -0
- package/lib/_chunks/Preview-43ce9c72.js +26 -0
- package/lib/_chunks/{Preview-3195237b.js.map → Preview-43ce9c72.js.map} +1 -1
- package/lib/_chunks/VideoSource.styled-24577ec8.js +318 -0
- package/lib/_chunks/VideoSource.styled-24577ec8.js.map +1 -0
- package/lib/_chunks/VideoSource.styled-99ffa712.js +336 -0
- package/lib/_chunks/VideoSource.styled-99ffa712.js.map +1 -0
- package/lib/_chunks/index-9933dea2.js +264 -0
- package/lib/_chunks/index-9933dea2.js.map +1 -0
- package/lib/_chunks/index-c54f5393.js +247 -0
- package/lib/_chunks/index-c54f5393.js.map +1 -0
- package/lib/{src/index.d.ts → index.d.ts} +0 -0
- package/lib/index.esm.js +2 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/package.json +23 -30
- package/lib/_chunks/Input-2ba004d3.js +0 -2
- package/lib/_chunks/Input-2ba004d3.js.map +0 -1
- package/lib/_chunks/Input-af5a0a66.esm.js +0 -2
- package/lib/_chunks/Input-af5a0a66.esm.js.map +0 -1
- package/lib/_chunks/Preview-3195237b.js +0 -2
- package/lib/_chunks/Preview-bb256342.esm.js +0 -2
- package/lib/_chunks/Preview-bb256342.esm.js.map +0 -1
- package/lib/_chunks/VideoSource.styled-1b994d90.js +0 -2
- package/lib/_chunks/VideoSource.styled-1b994d90.js.map +0 -1
- package/lib/_chunks/VideoSource.styled-f92259cd.esm.js +0 -2
- package/lib/_chunks/VideoSource.styled-f92259cd.esm.js.map +0 -1
- package/lib/_chunks/index-3d8d7583.esm.js +0 -2
- package/lib/_chunks/index-3d8d7583.esm.js.map +0 -1
- package/lib/_chunks/index-efe6ce48.js +0 -2
- package/lib/_chunks/index-efe6ce48.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-3d8d7583.esm.js","sources":["../../src/util/constants.ts","../../src/components/ErrorBoundaryCard.tsx","../../src/components/Input.styled.tsx","../../src/components/FormInput.tsx","../../src/util/asserters.ts","../../src/components/FormPreview.tsx","../../src/index.ts"],"sourcesContent":["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 {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","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":["cacheNs","muxSecretsDocumentId","ErrorBoundaryCard$1","memo","props","children","schemaType","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","AspectRatioCard","styled","_templateObject","InputFallback","sizing","aspectRatio","width","borderRadius","direction","Spinner","muted","Box","marginTop","size","Input","lazy","import","createFormInput","config","_a","isObjectInputProps","type","name","isMuxInputProps","ErrorBoundaryCard","Suspense","fallback","_objectSpread","renderDefault","Preview","FormPreview","_b","isMuxInputPreviewProps","defaultConfig","mp4_support","muxInput","definePlugin","userConfig","form","components","input","preview","schema","types","fields","weak","to"],"mappings":"+qCAAO,MAGMA,EAAU,0BAEVC,EAAuB,cC0FpC,IAAeC,EAAAC,GAlFf,SAA2BC,GACnB,MAAAC,SAACA,EAAUC,WAAAA,GAAcF,GACxBG,KAAMC,GAAaC,IACpBC,EAAWC,EAAO,OAClBC,cAACA,EAAeC,SAAAA,EAAAC,MAAUA,EAAO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,EAWE,MAAwC,eAAjC,OAAAA,EAAA,OAAMZ,EAAApF,EAAAE,iBAAY,EAAAkF,EAAAE,eAAMC,KACjC,CCHMU,CAAuBjG,GAEtB2B,EAAAsC,EAAA,CAEChE,SAAC0B,EAAAmE,OAAY9F,MAIZA,EAAM6F,cAAc7F,EAC7B,ICZO,MAAMkG,EAAwB,CACnCC,YAAa,QAGFC,EAAWC,GAAsCC,IAC5D,MAAMnB,EAAiBS,EAAAA,EAAA,CAAA,EAAIM,GAAkBI,GAEtC,MAAA,CACLf,KAAM,YACNgB,KAAM,CACJC,WAAY,CACVC,MALiBvB,EAAgBC,GAMjCuB,QAASX,IAGbY,OAAQ,CACNC,MAAO,CACL,CACErB,KAAM,YACND,KAAM,SACN7D,MAAO,wBACPoF,OAAQ,CACN,CACEpF,MAAO,QACP8D,KAAM,QACND,KAAM,YACNwB,MAAM,EACNC,GAAI,CAAC,CAACzB,KAAM,sBAIlB,CACEC,KAAM,iBACND,KAAM,SACN7D,MAAO,cACPoF,OAAQ,CACN,CACEvB,KAAM,SACNC,KAAM,UAER,CACED,KAAM,SACNC,KAAM,WAER,CACED,KAAM,SACNC,KAAM,cAER,CACED,KAAM,SACNC,KAAM,YAER,CACED,KAAM,SACNC,KAAM,iBAMlB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e;function r(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var o=require("sanity"),s=require("react/jsx-runtime"),i=require("react"),c=require("@sanity/ui"),l=require("scroll-into-view-if-needed"),a=require("suspend-react"),u=require("use-error-boundary"),d=require("styled-components");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=p(l),f=p(d);var h=i.memo((function(e){const{children:r,schemaType:n}=e,{push:t}=c.useToast(),o=i.useRef(null),{ErrorBoundary:l,didCatch:d,error:p,reset:f}=u.useErrorBoundary({onDidCatch:(e,r)=>{console.group(e.toString()),console.groupCollapsed("console.error"),console.error(e),console.groupEnd(),e.stack&&(console.groupCollapsed("error.stack"),console.log(e.stack),console.groupEnd()),(null==r?void 0:r.componentStack)&&(console.groupCollapsed("errorInfo.componentStack"),console.log(r.componentStack),console.groupEnd()),console.groupEnd(),t({status:"error",title:"Plugin crashed",description:s.jsx(c.Flex,{align:"center",children:s.jsxs(c.Inline,{space:1,children:["An error happened while rendering",s.jsx(c.Button,{padding:1,fontSize:1,style:{transform:"translateY(1px)"},mode:"ghost",text:n.title,onClick:()=>{o.current&&m.default(o.current,{behavior:"smooth",scrollMode:"if-needed",block:"center"})}})]})})})}}),h=i.useCallback((()=>{a.clear(["mux-input"]),f()}),[f]);return d?s.jsx(c.Card,{ref:o,paddingX:[2,3,4,4],height:"fill",shadow:1,overflow:"auto",children:s.jsx(c.Flex,{justify:"flex-start",align:"center",height:"fill",children:s.jsxs(c.Grid,{columns:1,gap:[2,3,4,4],children:[s.jsxs(c.Heading,{as:"h1",children:["The ",s.jsx("code",{children:"mux-input"})," plugin crashed"]}),(null==p?void 0:p.message)&&s.jsx(c.Card,{padding:3,tone:"critical",shadow:1,radius:2,children:s.jsx(c.Text,{children:p.message})}),s.jsx(c.Inline,{children:s.jsx(c.Button,{onClick:h,text:"Retry"})})]})})}):s.jsx(l,{children:r})}));const x=f.default(c.Card)(e||(j=["\n aspect-ratio: 16 / 9;\n position: relative;\n width: 100%;\n"],g||(g=j.slice(0)),e=Object.freeze(Object.defineProperties(j,{raw:{value:Object.freeze(g)}}))));var j,g;const y=()=>s.jsx("div",{style:{padding:1},children:s.jsx(c.Card,{shadow:1,sizing:"border",style:{aspectRatio:"16/9",width:"100%",borderRadius:"1px"},children:s.jsxs(c.Flex,{align:"center",direction:"column",height:"fill",justify:"center",children:[s.jsx(c.Spinner,{muted:!0}),s.jsx(c.Box,{marginTop:3,children:s.jsx(c.Text,{align:"center",muted:!0,size:1,children:"Loading…"})})]})})}),b=i.lazy((()=>Promise.resolve().then((function(){return require("./Input-2ba004d3.js")}))));var v=e=>i.memo((function(r){return function(e){var r;return o.isObjectInputProps(e)&&"mux.video"===(null==(r=e.schemaType.type)?void 0:r.name)}(r)?s.jsx(x,{children:s.jsx(h,{schemaType:r.schemaType,children:s.jsx(i.Suspense,{fallback:s.jsx(y,{}),children:s.jsx(b,n({config:e},r))})})}):r.renderDefault(r)}));const O=i.lazy((()=>Promise.resolve().then((function(){return require("./Preview-3195237b.js")}))));var w=i.memo((function(e){return function(e){var r,n;return"mux.video"===(null==(n=null==(r=e.schemaType)?void 0:r.type)?void 0:n.name)}(e)?s.jsx(x,{children:s.jsx(O,n({},e))}):e.renderDefault(e)}));const P={mp4_support:"none"},k=o.definePlugin((e=>{const r=n(n({},P),e);return{name:"mux-input",form:{components:{input:v(r),preview:w}},schema:{types:[{name:"mux.video",type:"object",title:"Video asset reference",fields:[{title:"Video",name:"asset",type:"reference",weak:!0,to:[{type:"mux.videoAsset"}]}]},{name:"mux.videoAsset",type:"object",title:"Video asset",fields:[{type:"string",name:"status"},{type:"string",name:"assetId"},{type:"string",name:"playbackId"},{type:"string",name:"filename"},{type:"number",name:"thumbTime"}]}]}}}));exports.InputFallback=y,exports.cacheNs="sanity-plugin-mux-input",exports.defaultConfig=P,exports.muxInput=k,exports.muxSecretsDocumentId="secrets.mux";
|
|
2
|
-
//# sourceMappingURL=index-efe6ce48.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-efe6ce48.js","sources":["../../src/components/ErrorBoundaryCard.tsx","../../src/util/constants.ts","../../src/components/Input.styled.tsx","../../src/components/FormInput.tsx","../../src/util/asserters.ts","../../src/components/FormPreview.tsx","../../src/index.ts"],"sourcesContent":["/* 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","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","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 {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","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":["memo","props","children","schemaType","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","AspectRatioCard","styled","_templateObject","InputFallback","sizing","aspectRatio","width","borderRadius","direction","Spinner","muted","Box","marginTop","size","Input","lazy","Promise","resolve","then","require","createFormInput","config","_a","isObjectInputProps","type","name","isMuxInputProps","ErrorBoundaryCard","Suspense","fallback","_objectSpread","renderDefault","Preview","FormPreview","_b","isMuxInputPreviewProps","defaultConfig","mp4_support","muxInput","definePlugin","userConfig","form","components","input","preview","schema","types","fields","weak","to"],"mappings":"wgCA+FA,IAAeA,EAAAA,EAAAA,MAlFf,SAA2BC,GACnB,MAAAC,SAACA,EAAUC,WAAAA,GAAcF,GACxBG,KAAMC,GAAaC,EAASA,WAC7BC,EAAWC,SAAO,OAClBC,cAACA,EAAeC,SAAAA,EAAAC,MAAUA,EAAOC,MAAAA,GAASC,EAAAA,iBAAiB,CAC/DC,WAAY,CAACC,EAAKC,KACRC,QAAAC,MAAMH,EAAII,YAClBF,QAAQG,eAAe,iBACvBH,QAAQN,MAAMI,GACdE,QAAQI,WACJN,EAAIO,QACNL,QAAQG,eAAe,eACfH,QAAAM,IAAIR,EAAIO,OAChBL,QAAQI,mBAENL,WAAWQ,kBACbP,QAAQG,eAAe,4BACfH,QAAAM,IAAIP,EAAUQ,gBACtBP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