sanity-plugin-mux-input 2.0.16 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/_chunks/Player-d8f163ed.cjs +474 -0
  2. package/lib/_chunks/Player-d8f163ed.cjs.map +1 -0
  3. package/lib/_chunks/Player-fb9712c0.js +465 -0
  4. package/lib/_chunks/Player-fb9712c0.js.map +1 -0
  5. package/lib/_chunks/index-0656ede8.js +3229 -0
  6. package/lib/_chunks/index-0656ede8.js.map +1 -0
  7. package/lib/_chunks/index-9cd542f1.cjs +3271 -0
  8. package/lib/_chunks/index-9cd542f1.cjs.map +1 -0
  9. package/lib/index.cjs +1 -1
  10. package/lib/index.d.ts +97 -0
  11. package/lib/index.js +1 -1
  12. package/package.json +16 -17
  13. package/src/components/Input.tsx +34 -29
  14. package/src/components/__legacy__Uploader.tsx +7 -2
  15. package/src/index.ts +8 -49
  16. package/src/plugin.tsx +31 -0
  17. package/src/schema.tsx +42 -0
  18. package/lib/_chunks/Input-509c8fa5.cjs +0 -189
  19. package/lib/_chunks/Input-509c8fa5.cjs.map +0 -1
  20. package/lib/_chunks/Input-9ddeac65.js +0 -189
  21. package/lib/_chunks/Input-9ddeac65.js.map +0 -1
  22. package/lib/_chunks/Preview-04fe7cde.js +0 -26
  23. package/lib/_chunks/Preview-04fe7cde.js.map +0 -1
  24. package/lib/_chunks/Preview-442a88cd.cjs +0 -28
  25. package/lib/_chunks/Preview-442a88cd.cjs.map +0 -1
  26. package/lib/_chunks/VideoSource.styled-45ab4b64.js +0 -318
  27. package/lib/_chunks/VideoSource.styled-45ab4b64.js.map +0 -1
  28. package/lib/_chunks/VideoSource.styled-cb41adac.cjs +0 -336
  29. package/lib/_chunks/VideoSource.styled-cb41adac.cjs.map +0 -1
  30. package/lib/_chunks/index-d360f7ae.cjs +0 -265
  31. package/lib/_chunks/index-d360f7ae.cjs.map +0 -1
  32. package/lib/_chunks/index-f8b48f62.js +0 -248
  33. package/lib/_chunks/index-f8b48f62.js.map +0 -1
  34. package/src/components/FormInput.tsx +0 -26
  35. package/src/components/FormPreview.tsx +0 -19
  36. package/src/components/Preview.tsx +0 -33
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-d360f7ae.cjs","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, isObjectInputProps, type PreviewLayoutKey, type PreviewProps} 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","_templateObject","_taggedTemplateLiteral","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;EA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ACL7F,IAAM,EAAA,WAAA;IACN0G,IAAM,EAAA;MACJC,UAAY,EAAA;QACVC,KAAO,EAAAH,cAAA;QACPI,OAAS,EAAAV;MACX;IACF,CAAA;IACAW,MAAQ,EAAA;MACNC,KAAO,EAAA,CACL;QACE/G,IAAM,EAAA,WAAA;QACND,IAAM,EAAA,QAAA;QACN8B,KAAO,EAAA,uBAAA;QACPmF,MAAQ,EAAA,CACN;UACEnF,KAAO,EAAA,OAAA;UACP7B,IAAM,EAAA,OAAA;UACND,IAAM,EAAA,WAAA;UACNkH,IAAM,EAAA,IAAA;UACNC,EAAI,EAAA,CAAC;YAACnH,IAAA,EAAM;WAAiB;QAC/B,CAAA;MAEJ,CAAA,EACA;QACEC,IAAM,EAAA,gBAAA;QACND,IAAM,EAAA,QAAA;QACN8B,KAAO,EAAA,aAAA;QACPmF,MAAQ,EAAA,CACN;UACEjH,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,248 +0,0 @@
1
- var _templateObject;
2
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
- import { isObjectInputProps, definePlugin } from 'sanity';
4
- import { jsx, jsxs } from 'react/jsx-runtime';
5
- import { memo, useRef, useCallback, lazy, Suspense } from 'react';
6
- import { useToast, Flex, Inline, Button, Card, Grid, Heading, Text, Spinner, Box } from '@sanity/ui';
7
- import scrollIntoView from 'scroll-into-view-if-needed';
8
- import { clear } from 'suspend-react';
9
- import { useErrorBoundary } from 'use-error-boundary';
10
- import styled from 'styled-components';
11
- function isMuxInputProps(props) {
12
- var _a;
13
- return isObjectInputProps(props) && ((_a = props.schemaType.type) == null ? void 0 : _a.name) === "mux.video";
14
- }
15
- function isMuxInputPreviewProps(props) {
16
- var _a, _b;
17
- return ((_b = (_a = props.schemaType) == null ? void 0 : _a.type) == null ? void 0 : _b.name) === "mux.video";
18
- }
19
- const name = "mux-input";
20
- const cacheNs = "sanity-plugin-mux-input";
21
- const muxSecretsDocumentId = "secrets.mux";
22
- function ErrorBoundaryCard(props) {
23
- const {
24
- children,
25
- schemaType
26
- } = props;
27
- const {
28
- push: pushToast
29
- } = useToast();
30
- const errorRef = useRef(null);
31
- const {
32
- ErrorBoundary,
33
- didCatch,
34
- error,
35
- reset
36
- } = useErrorBoundary({
37
- onDidCatch: (err, errorInfo) => {
38
- console.group(err.toString());
39
- console.groupCollapsed("console.error");
40
- console.error(err);
41
- console.groupEnd();
42
- if (err.stack) {
43
- console.groupCollapsed("error.stack");
44
- console.log(err.stack);
45
- console.groupEnd();
46
- }
47
- if (errorInfo == null ? void 0 : errorInfo.componentStack) {
48
- console.groupCollapsed("errorInfo.componentStack");
49
- console.log(errorInfo.componentStack);
50
- console.groupEnd();
51
- }
52
- console.groupEnd();
53
- pushToast({
54
- status: "error",
55
- title: "Plugin crashed",
56
- description: /* @__PURE__ */jsx(Flex, {
57
- align: "center",
58
- children: /* @__PURE__ */jsxs(Inline, {
59
- space: 1,
60
- children: ["An error happened while rendering", /* @__PURE__ */jsx(Button, {
61
- padding: 1,
62
- fontSize: 1,
63
- style: {
64
- transform: "translateY(1px)"
65
- },
66
- mode: "ghost",
67
- text: schemaType.title,
68
- onClick: () => {
69
- if (errorRef.current) {
70
- scrollIntoView(errorRef.current, {
71
- behavior: "smooth",
72
- scrollMode: "if-needed",
73
- block: "center"
74
- });
75
- }
76
- }
77
- })]
78
- })
79
- })
80
- });
81
- }
82
- });
83
- const handleRetry = useCallback(() => {
84
- clear([name]);
85
- reset();
86
- }, [reset]);
87
- if (didCatch) {
88
- return /* @__PURE__ */jsx(Card, {
89
- ref: errorRef,
90
- paddingX: [2, 3, 4, 4],
91
- height: "fill",
92
- shadow: 1,
93
- overflow: "auto",
94
- children: /* @__PURE__ */jsx(Flex, {
95
- justify: "flex-start",
96
- align: "center",
97
- height: "fill",
98
- children: /* @__PURE__ */jsxs(Grid, {
99
- columns: 1,
100
- gap: [2, 3, 4, 4],
101
- children: [/* @__PURE__ */jsxs(Heading, {
102
- as: "h1",
103
- children: ["The ", /* @__PURE__ */jsx("code", {
104
- children: name
105
- }), " plugin crashed"]
106
- }), (error == null ? void 0 : error.message) && /* @__PURE__ */jsx(Card, {
107
- padding: 3,
108
- tone: "critical",
109
- shadow: 1,
110
- radius: 2,
111
- children: /* @__PURE__ */jsx(Text, {
112
- children: error.message
113
- })
114
- }), /* @__PURE__ */jsx(Inline, {
115
- children: /* @__PURE__ */jsx(Button, {
116
- onClick: handleRetry,
117
- text: "Retry"
118
- })
119
- })]
120
- })
121
- })
122
- });
123
- }
124
- return /* @__PURE__ */jsx(ErrorBoundary, {
125
- children
126
- });
127
- }
128
- var ErrorBoundaryCard$1 = memo(ErrorBoundaryCard);
129
- const AspectRatioCard = styled(Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n aspect-ratio: 16 / 9;\n position: relative;\n width: 100%;\n"])));
130
- const InputFallback = () => {
131
- return /* @__PURE__ */jsx("div", {
132
- style: {
133
- padding: 1
134
- },
135
- children: /* @__PURE__ */jsx(Card, {
136
- shadow: 1,
137
- sizing: "border",
138
- style: {
139
- aspectRatio: "16/9",
140
- width: "100%",
141
- borderRadius: "1px"
142
- },
143
- children: /* @__PURE__ */jsxs(Flex, {
144
- align: "center",
145
- direction: "column",
146
- height: "fill",
147
- justify: "center",
148
- children: [/* @__PURE__ */jsx(Spinner, {
149
- muted: true
150
- }), /* @__PURE__ */jsx(Box, {
151
- marginTop: 3,
152
- children: /* @__PURE__ */jsx(Text, {
153
- align: "center",
154
- muted: true,
155
- size: 1,
156
- children: "Loading\u2026"
157
- })
158
- })]
159
- })
160
- })
161
- });
162
- };
163
- const Input = lazy(() => import('./Input-9ddeac65.js'));
164
- var createFormInput = config => memo(function FormInput(props) {
165
- if (isMuxInputProps(props)) {
166
- return /* @__PURE__ */jsx(AspectRatioCard, {
167
- children: /* @__PURE__ */jsx(ErrorBoundaryCard$1, {
168
- schemaType: props.schemaType,
169
- children: /* @__PURE__ */jsx(Suspense, {
170
- fallback: /* @__PURE__ */jsx(InputFallback, {}),
171
- children: /* @__PURE__ */jsx(Input, {
172
- config,
173
- ...props
174
- })
175
- })
176
- })
177
- });
178
- }
179
- return props.renderDefault(props);
180
- });
181
- const Preview = lazy(() => import('./Preview-04fe7cde.js'));
182
- var FormPreview = memo(function FormPreview(props) {
183
- if (isMuxInputPreviewProps(props)) {
184
- return /* @__PURE__ */jsx(AspectRatioCard, {
185
- children: /* @__PURE__ */jsx(Preview, {
186
- ...props
187
- })
188
- });
189
- }
190
- return props.renderDefault(props);
191
- });
192
- const defaultConfig = {
193
- mp4_support: "none"
194
- };
195
- const muxInput = definePlugin(userConfig => {
196
- const config = {
197
- ...defaultConfig,
198
- ...userConfig
199
- };
200
- const InputComponent = createFormInput(config);
201
- return {
202
- name: "mux-input",
203
- form: {
204
- components: {
205
- input: InputComponent,
206
- preview: FormPreview
207
- }
208
- },
209
- schema: {
210
- types: [{
211
- name: "mux.video",
212
- type: "object",
213
- title: "Video asset reference",
214
- fields: [{
215
- title: "Video",
216
- name: "asset",
217
- type: "reference",
218
- weak: true,
219
- to: [{
220
- type: "mux.videoAsset"
221
- }]
222
- }]
223
- }, {
224
- name: "mux.videoAsset",
225
- type: "object",
226
- title: "Video asset",
227
- fields: [{
228
- type: "string",
229
- name: "status"
230
- }, {
231
- type: "string",
232
- name: "assetId"
233
- }, {
234
- type: "string",
235
- name: "playbackId"
236
- }, {
237
- type: "string",
238
- name: "filename"
239
- }, {
240
- type: "number",
241
- name: "thumbTime"
242
- }]
243
- }]
244
- }
245
- };
246
- });
247
- export { InputFallback, cacheNs, defaultConfig, muxInput, muxSecretsDocumentId };
248
- //# sourceMappingURL=index-f8b48f62.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-f8b48f62.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, isObjectInputProps, type PreviewLayoutKey, type PreviewProps} 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","_templateObject","_taggedTemplateLiteral","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,O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,EACA;UACED,IAAM,EAAA,QAAA;UACNC,IAAM,EAAA;QACR,CAAA;MAEJ,CAAA;IAEJ;EAAA,CACF;AACF,CAAC,CAAA;"}
@@ -1,26 +0,0 @@
1
- import React, {lazy, memo, Suspense} from 'react'
2
- import {type InputProps} from 'sanity'
3
-
4
- import {isMuxInputProps} from '../util/asserters'
5
- import {type Config} from '../util/types'
6
- import ErrorBoundaryCard from './ErrorBoundaryCard'
7
- import {AspectRatioCard, InputFallback} from './Input.styled'
8
-
9
- const Input = lazy(() => import('./Input'))
10
-
11
- // eslint-disable-next-line import/no-anonymous-default-export
12
- export default (config: Config) =>
13
- memo(function FormInput(props: InputProps) {
14
- if (isMuxInputProps(props)) {
15
- return (
16
- <AspectRatioCard>
17
- <ErrorBoundaryCard schemaType={props.schemaType}>
18
- <Suspense fallback={<InputFallback />}>
19
- <Input config={config} {...props} />
20
- </Suspense>
21
- </ErrorBoundaryCard>
22
- </AspectRatioCard>
23
- )
24
- }
25
- return props.renderDefault(props)
26
- })
@@ -1,19 +0,0 @@
1
- import React, {lazy, memo} from 'react'
2
- import {PreviewLayoutKey, PreviewProps} from 'sanity'
3
-
4
- import {isMuxInputPreviewProps} from '../util/asserters'
5
- import {AspectRatioCard} from './Input.styled'
6
-
7
- const Preview = lazy(() => import('./Preview'))
8
-
9
- export default memo(function FormPreview(props: PreviewProps<PreviewLayoutKey>) {
10
- if (isMuxInputPreviewProps(props)) {
11
- return (
12
- <AspectRatioCard>
13
- {/* @ts-expect-error */}
14
- <Preview {...props} />
15
- </AspectRatioCard>
16
- )
17
- }
18
- return props.renderDefault(props)
19
- })
@@ -1,33 +0,0 @@
1
- import React from 'react'
2
- import {SanityDefaultPreview} from 'sanity'
3
-
4
- import {useAssetDocumentValues} from '../hooks/useAssetDocumentValues'
5
- import {VideoThumbnail} from './VideoSource.styled'
6
-
7
- export interface MuxVideoPreviewProps {
8
- value: {
9
- asset: {
10
- _type: 'reference'
11
- _ref: string
12
- }
13
- }
14
- }
15
- const MuxVideoPreview = ({value}: MuxVideoPreviewProps) => {
16
- const assetDocumentValues = useAssetDocumentValues(value?.asset!)
17
-
18
- if (assetDocumentValues.value) {
19
- return <VideoThumbnail asset={assetDocumentValues.value} width={640} />
20
- }
21
-
22
- // @ts-expect-error
23
- const {filename, playbackId, status} = value ?? {}
24
-
25
- return (
26
- <SanityDefaultPreview
27
- title={filename || playbackId || ''}
28
- subtitle={status ? `status: ${status}` : null}
29
- />
30
- )
31
- }
32
-
33
- export default MuxVideoPreview