sanity-plugin-mux-input 2.5.0 → 2.7.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.
package/dist/index.mjs CHANGED
@@ -1,9 +1,8 @@
1
- import { useClient as useClient$1, useDocumentStore, collate, useDocumentValues, createHookFromObservableFactory, truncateString, useFormattedDuration, SanityDefaultPreview, useTimeAgo, TextWithTone, isRecord, getPreviewStateObservable, getPreviewValueWithFallback, DocumentPreviewPresence, useDocumentPreviewStore, useSchema, useDocumentPresence, PreviewCard, isReference, useProjectId, useDataset, PatchEvent, unset, setIfMissing, set, LinearProgress, FormField as FormField$2, definePlugin } from "sanity";
1
+ import { useClient as useClient$1, createHookFromObservableFactory, useDocumentStore, collate, useDocumentValues, truncateString, useFormattedDuration, SanityDefaultPreview, useTimeAgo, TextWithTone, isRecord, getPreviewStateObservable, getPreviewValueWithFallback, DocumentPreviewPresence, useDocumentPreviewStore, useSchema, useDocumentPresence, PreviewCard, isReference, useProjectId, useDataset, PatchEvent, unset, setIfMissing, set, LinearProgress, FormField as FormField$2, definePlugin } from "sanity";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
- import { ErrorOutlineIcon, RetryIcon, CheckmarkCircleIcon, RetrieveIcon, SortIcon, WarningOutlineIcon, EditIcon, PublishIcon, DocumentIcon, TrashIcon, RevertIcon, SearchIcon, ClockIcon, CropIcon, CalendarIcon, TagIcon, CheckmarkIcon, LockIcon, PlayIcon, PlugIcon, EllipsisHorizontalIcon, UploadIcon, ImageIcon, ResetIcon, TranslateIcon, DocumentVideoIcon } from "@sanity/icons";
4
- import { Card, Box, Spinner, Stack, Text, Checkbox, Button, Dialog, Flex, Heading, Code, MenuButton, Menu, MenuItem, TextInput, Tooltip, Inline, useToast, TabList, Tab, TabPanel, Label as Label$1, Grid, useClickOutsideEvent, Popover, MenuDivider, Autocomplete, Radio, rem } from "@sanity/ui";
3
+ import { ErrorOutlineIcon, RetryIcon, CheckmarkCircleIcon, RetrieveIcon, SortIcon, WarningOutlineIcon, EditIcon, PublishIcon, DocumentIcon, TrashIcon, RevertIcon, SearchIcon, ClockIcon, CropIcon, CalendarIcon, TagIcon, CheckmarkIcon, LockIcon, PlayIcon, PlugIcon, EllipsisHorizontalIcon, UploadIcon, ImageIcon, ResetIcon, TranslateIcon, WarningFilledIcon, DocumentVideoIcon } from "@sanity/icons";
4
+ import { Card, Box, Spinner, Stack, Text, Checkbox, Button, Dialog, Flex, Heading, Code, MenuButton, Menu, MenuItem, TextInput, Tooltip, Inline, useToast, TabList, Tab, TabPanel, Label as Label$1, Grid, useTheme_v2, useClickOutsideEvent, Popover, MenuDivider, Autocomplete, Radio, rem } from "@sanity/ui";
5
5
  import React, { useState, useMemo, useEffect, useRef, useId, memo, createContext, useContext, isValidElement, useCallback, useReducer, PureComponent, createElement, forwardRef, Suspense } from "react";
6
- import { useObservable } from "react-rx";
7
6
  import compact from "lodash/compact.js";
8
7
  import toLower from "lodash/toLower.js";
9
8
  import trim from "lodash/trim.js";
@@ -19,6 +18,7 @@ import { usePaneRouter } from "sanity/desk";
19
18
  import { IntentLink } from "sanity/router";
20
19
  import isNumber from "lodash/isNumber.js";
21
20
  import isString from "lodash/isString.js";
21
+ import { useObservable } from "react-rx";
22
22
  import useSWR from "swr";
23
23
  import scrollIntoView from "scroll-into-view-if-needed";
24
24
  import { UpChunk } from "@mux/upchunk";
@@ -71,38 +71,33 @@ const ASSET_SORT_OPTIONS = {
71
71
  createdAsc: { groq: "_createdAt asc", label: "First created (oldest)" },
72
72
  filenameAsc: { groq: "filename asc", label: "By filename (A-Z)" },
73
73
  filenameDesc: { groq: "filename desc", label: "By filename (Z-A)" }
74
- }, useAssetDocuments = ({
75
- documentStore,
76
- sort,
77
- searchQuery
78
- }) => {
79
- const memoizedObservable = useMemo(() => {
80
- const search = createSearchFilter(searchQuery), filter = ['_type == "mux.videoAsset"', ...search.filter].filter(Boolean).join(" && "), sortFragment = ASSET_SORT_OPTIONS[sort].groq;
81
- return documentStore.listenQuery(
82
- /* groq */
83
- `*[${filter}] | order(${sortFragment})`,
84
- search.params,
85
- {
86
- apiVersion: SANITY_API_VERSION
87
- }
88
- );
89
- }, [documentStore, sort, searchQuery]);
90
- return useObservable(memoizedObservable, void 0);
91
- };
74
+ }, useAssetDocuments = createHookFromObservableFactory(({ documentStore, sort, searchQuery }) => {
75
+ const search = createSearchFilter(searchQuery), filter = ['_type == "mux.videoAsset"', ...search.filter].filter(Boolean).join(" && "), sortFragment = ASSET_SORT_OPTIONS[sort].groq;
76
+ return documentStore.listenQuery(
77
+ /* groq */
78
+ `*[${filter}] | order(${sortFragment})`,
79
+ search.params,
80
+ {
81
+ apiVersion: SANITY_API_VERSION
82
+ }
83
+ );
84
+ });
92
85
  function useAssets() {
93
- const documentStore = useDocumentStore(), [sort, setSort] = useState("createdDesc"), [searchQuery, setSearchQuery] = useState(""), assetDocumentsObservable = useAssetDocuments({ documentStore, sort, searchQuery }), isLoading = assetDocumentsObservable === void 0;
86
+ const documentStore = useDocumentStore(), [sort, setSort] = useState("createdDesc"), [searchQuery, setSearchQuery] = useState(""), [assetDocuments = [], isLoading] = useAssetDocuments(
87
+ useMemo(() => ({ documentStore, sort, searchQuery }), [documentStore, sort, searchQuery])
88
+ );
94
89
  return {
95
90
  assets: useMemo(
96
91
  () => (
97
92
  // Avoid displaying both drafts & published assets by collating them together and giving preference to drafts
98
- collate(assetDocumentsObservable ?? []).map(
93
+ collate(assetDocuments).map(
99
94
  (collated) => ({
100
95
  ...collated.draft || collated.published || {},
101
96
  _id: collated.id
102
97
  })
103
98
  )
104
99
  ),
105
- [assetDocumentsObservable]
100
+ [assetDocuments]
106
101
  ),
107
102
  isLoading,
108
103
  sort,
@@ -285,8 +280,8 @@ function assetExistsInSanity(asset, existingAssets) {
285
280
  (existing) => existing.assetId === asset.id || existing.uploadId === asset.upload_id
286
281
  );
287
282
  }
288
- function useInView(options = {}) {
289
- const [inView, setInView] = useState(!1), ref = useRef(null);
283
+ function useInView(ref, options = {}) {
284
+ const [inView, setInView] = useState(!1);
290
285
  return useEffect(() => {
291
286
  if (!ref.current) return;
292
287
  const observer = new IntersectionObserver(([entry], obs) => {
@@ -296,7 +291,7 @@ function useInView(options = {}) {
296
291
  return observer.observe(toObserve), () => {
297
292
  toObserve && observer.unobserve(toObserve);
298
293
  };
299
- }, [options]), { inView, ref };
294
+ }, [options, ref]), inView;
300
295
  }
301
296
  const _id = "secrets.mux";
302
297
  function readSecrets(client) {
@@ -403,7 +398,7 @@ function VideoThumbnail({
403
398
  width,
404
399
  staticImage = !1
405
400
  }) {
406
- const { inView, ref } = useInView(), posterWidth = width || 250, [status, setStatus] = useState("loading"), client = useClient(), src = useMemo(() => {
401
+ const ref = useRef(null), inView = useInView(ref), posterWidth = width || 250, [status, setStatus] = useState("loading"), client = useClient(), src = useMemo(() => {
407
402
  try {
408
403
  let thumbnail;
409
404
  return staticImage ? thumbnail = getPosterSrc({ asset, client, width: posterWidth }) : thumbnail = getAnimatedPosterSrc({ asset, client, width: posterWidth }), thumbnail;
@@ -470,9 +465,7 @@ function VideoThumbnail({
470
465
  alt: `Preview for ${staticImage ? "image" : "video"} ${asset.filename || asset.assetId}`,
471
466
  onLoad: handleLoad,
472
467
  onError: handleError,
473
- style: {
474
- opacity: status === "loaded" ? 1 : 0
475
- }
468
+ style: { opacity: status === "loaded" ? 1 : 0 }
476
469
  }
477
470
  )
478
471
  ] }) : null
@@ -923,7 +916,7 @@ function VideoPlayer({
923
916
  crossOrigin: "anonymous",
924
917
  metadata: {
925
918
  player_name: "Sanity Admin Dashboard",
926
- player_version: "2.5.0",
919
+ player_version: "2.7.0",
927
920
  page_type: "Preview Player"
928
921
  },
929
922
  audio: isAudio,
@@ -1291,10 +1284,9 @@ function getVideoMetadata(doc) {
1291
1284
  };
1292
1285
  }
1293
1286
  function useVideoDetails(props) {
1294
- const documentStore = useDocumentStore(), toast = useToast(), client = useClient(), [references, referencesLoading] = useDocReferences({
1295
- documentStore,
1296
- id: props.asset._id
1297
- }), [originalAsset, setOriginalAsset] = useState(() => props.asset), [filename, setFilename] = useState(props.asset.filename), modified = filename !== originalAsset.filename, displayInfo = getVideoMetadata({ ...props.asset, filename }), [state, setState] = useState("idle");
1287
+ const documentStore = useDocumentStore(), toast = useToast(), client = useClient(), [references, referencesLoading] = useDocReferences(
1288
+ useMemo(() => ({ documentStore, id: props.asset._id }), [documentStore, props.asset._id])
1289
+ ), [originalAsset, setOriginalAsset] = useState(() => props.asset), [filename, setFilename] = useState(props.asset.filename), modified = filename !== originalAsset.filename, displayInfo = getVideoMetadata({ ...props.asset, filename }), [state, setState] = useState("idle");
1298
1290
  function handleClose() {
1299
1291
  if (state === "idle") {
1300
1292
  if (modified) {
@@ -1936,13 +1928,19 @@ function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, s
1936
1928
  };
1937
1929
  return client.createOrReplace(doc);
1938
1930
  }
1939
- function createSigningKeys(client) {
1940
- const { dataset } = client.config();
1941
- return client.request({
1942
- url: `/addons/mux/signing-keys/${dataset}`,
1943
- withCredentials: !0,
1944
- method: "POST"
1945
- });
1931
+ async function createSigningKeys(client) {
1932
+ try {
1933
+ const { dataset } = client.config();
1934
+ return await client.request({
1935
+ url: `/addons/mux/signing-keys/${dataset}`,
1936
+ withCredentials: !0,
1937
+ method: "POST"
1938
+ });
1939
+ } catch (error) {
1940
+ console.error("Error creating signing keys", error);
1941
+ const message = error.response?.statusCode === 401 ? 'Unauthorized - Failed to create the Signing Key. Please ensure that the token has "System" permissions' : error.message;
1942
+ throw new Error(message);
1943
+ }
1946
1944
  }
1947
1945
  function testSecrets(client) {
1948
1946
  const { dataset } = client.config();
@@ -2050,593 +2048,43 @@ function reducer(state, action) {
2050
2048
  throw new Error(`Unknown action type: ${action?.type}`);
2051
2049
  }
2052
2050
  }
2053
- const useSecretsFormState = (secrets) => useReducer(reducer, secrets, init), ids = [
2054
- "title",
2055
- "a",
2056
- "b",
2057
- "c",
2058
- "d",
2059
- "e",
2060
- "f",
2061
- "g",
2062
- "h",
2063
- "i",
2064
- "j",
2065
- "k",
2066
- "l",
2067
- "m",
2068
- "n",
2069
- "o",
2070
- "p",
2071
- "q",
2072
- "r"
2073
- ];
2051
+ const useSecretsFormState = (secrets) => useReducer(reducer, secrets, init);
2074
2052
  function MuxLogo({ height = 26 }) {
2075
- const id = useId(), [titleId, a2, b, c2, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = useMemo(
2076
- () => ids.map((field) => `${id}-${field}`),
2077
- [id]
2078
- );
2079
- return /* @__PURE__ */ jsxs(
2053
+ const id = useId(), fillColor = useTheme_v2().color._dark ? "white" : "black", titleId = useMemo(() => `${id}-title`, [id]), pathStyle = {
2054
+ fillRule: "nonzero"
2055
+ };
2056
+ return /* @__PURE__ */ jsx(
2080
2057
  "svg",
2081
2058
  {
2082
2059
  "aria-labelledby": titleId,
2083
- role: "img",
2060
+ style: { height: `${height}px` },
2061
+ viewBox: "0 0 1600 500",
2062
+ version: "1.1",
2084
2063
  xmlns: "http://www.w3.org/2000/svg",
2085
2064
  xmlSpace: "preserve",
2086
- viewBox: "92.08878326416016 102.66712188720703 692.76123046875 219.99948120117188",
2087
- style: { height: `${height}px` },
2088
- children: [
2089
- /* @__PURE__ */ jsx("title", { id: titleId, children: "Mux Logo" }),
2090
- /* @__PURE__ */ jsxs("defs", { children: [
2091
- /* @__PURE__ */ jsxs(
2092
- "linearGradient",
2093
- {
2094
- id: c2,
2095
- spreadMethod: "pad",
2096
- gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
2097
- gradientUnits: "userSpaceOnUse",
2098
- y2: 0,
2099
- x2: 1,
2100
- y1: 0,
2101
- x1: 0,
2102
- children: [
2103
- /* @__PURE__ */ jsx(
2104
- "stop",
2105
- {
2106
- offset: 0,
2107
- style: {
2108
- stopOpacity: 1,
2109
- stopColor: "#ff4e00"
2110
- }
2111
- }
2112
- ),
2113
- /* @__PURE__ */ jsx(
2114
- "stop",
2115
- {
2116
- offset: 1,
2117
- style: {
2118
- stopOpacity: 1,
2119
- stopColor: "#ff1791"
2120
- }
2121
- }
2122
- )
2123
- ]
2124
- }
2125
- ),
2126
- /* @__PURE__ */ jsxs(
2127
- "linearGradient",
2128
- {
2129
- id: d,
2130
- spreadMethod: "pad",
2131
- gradientTransform: "matrix(523.66766 0 0 -523.66766 67.897 159.5)",
2132
- gradientUnits: "userSpaceOnUse",
2133
- y2: 0,
2134
- x2: 1,
2135
- y1: 0,
2136
- x1: 0,
2137
- children: [
2138
- /* @__PURE__ */ jsx(
2139
- "stop",
2140
- {
2141
- offset: 0,
2142
- style: {
2143
- stopOpacity: 1,
2144
- stopColor: "#ff4e00"
2145
- }
2146
- }
2147
- ),
2148
- /* @__PURE__ */ jsx(
2149
- "stop",
2150
- {
2151
- offset: 1,
2152
- style: {
2153
- stopOpacity: 1,
2154
- stopColor: "#ff1791"
2155
- }
2156
- }
2157
- )
2158
- ]
2159
- }
2160
- ),
2161
- /* @__PURE__ */ jsxs(
2162
- "linearGradient",
2163
- {
2164
- id: g,
2165
- spreadMethod: "pad",
2166
- gradientTransform: "rotate(180 296.075 79.75) scale(524.84045)",
2167
- gradientUnits: "userSpaceOnUse",
2168
- y2: 0,
2169
- x2: 1,
2170
- y1: 0,
2171
- x1: 0,
2172
- children: [
2173
- /* @__PURE__ */ jsx(
2174
- "stop",
2175
- {
2176
- offset: 0,
2177
- style: {
2178
- stopOpacity: 1,
2179
- stopColor: "#ff4e00"
2180
- }
2181
- }
2182
- ),
2183
- /* @__PURE__ */ jsx(
2184
- "stop",
2185
- {
2186
- offset: 1,
2187
- style: {
2188
- stopOpacity: 1,
2189
- stopColor: "#ff1791"
2190
- }
2191
- }
2192
- )
2193
- ]
2194
- }
2195
- ),
2196
- /* @__PURE__ */ jsxs(
2197
- "linearGradient",
2198
- {
2199
- id: i,
2200
- spreadMethod: "pad",
2201
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2202
- gradientUnits: "userSpaceOnUse",
2203
- y2: 0,
2204
- x2: 1,
2205
- y1: 0,
2206
- x1: 0,
2207
- children: [
2208
- /* @__PURE__ */ jsx(
2209
- "stop",
2210
- {
2211
- offset: 0,
2212
- style: {
2213
- stopOpacity: 1,
2214
- stopColor: "#ff4e00"
2215
- }
2216
- }
2217
- ),
2218
- /* @__PURE__ */ jsx(
2219
- "stop",
2220
- {
2221
- offset: 1,
2222
- style: {
2223
- stopOpacity: 1,
2224
- stopColor: "#ff1791"
2225
- }
2226
- }
2227
- )
2228
- ]
2229
- }
2230
- ),
2231
- /* @__PURE__ */ jsxs(
2232
- "linearGradient",
2233
- {
2234
- id: j,
2235
- spreadMethod: "pad",
2236
- gradientTransform: "matrix(523.08514 0 0 -523.08514 67.897 224.446)",
2237
- gradientUnits: "userSpaceOnUse",
2238
- y2: 0,
2239
- x2: 1,
2240
- y1: 0,
2241
- x1: 0,
2242
- children: [
2243
- /* @__PURE__ */ jsx(
2244
- "stop",
2245
- {
2246
- offset: 0,
2247
- style: {
2248
- stopOpacity: 1,
2249
- stopColor: "#ff4e00"
2250
- }
2251
- }
2252
- ),
2253
- /* @__PURE__ */ jsx(
2254
- "stop",
2255
- {
2256
- offset: 1,
2257
- style: {
2258
- stopOpacity: 1,
2259
- stopColor: "#ff1791"
2260
- }
2261
- }
2262
- )
2263
- ]
2264
- }
2265
- ),
2266
- /* @__PURE__ */ jsxs(
2267
- "linearGradient",
2268
- {
2269
- id: k,
2270
- spreadMethod: "pad",
2271
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.553)",
2272
- gradientUnits: "userSpaceOnUse",
2273
- y2: 0,
2274
- x2: 1,
2275
- y1: 0,
2276
- x1: 0,
2277
- children: [
2278
- /* @__PURE__ */ jsx(
2279
- "stop",
2280
- {
2281
- offset: 0,
2282
- style: {
2283
- stopOpacity: 1,
2284
- stopColor: "#ff4e00"
2285
- }
2286
- }
2287
- ),
2288
- /* @__PURE__ */ jsx(
2289
- "stop",
2290
- {
2291
- offset: 1,
2292
- style: {
2293
- stopOpacity: 1,
2294
- stopColor: "#ff1791"
2295
- }
2296
- }
2297
- )
2298
- ]
2299
- }
2300
- ),
2301
- /* @__PURE__ */ jsxs(
2302
- "linearGradient",
2303
- {
2304
- id: l,
2305
- spreadMethod: "pad",
2306
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2307
- gradientUnits: "userSpaceOnUse",
2308
- y2: 0,
2309
- x2: 1,
2310
- y1: 0,
2311
- x1: 0,
2312
- children: [
2313
- /* @__PURE__ */ jsx(
2314
- "stop",
2315
- {
2316
- offset: 0,
2317
- style: {
2318
- stopOpacity: 1,
2319
- stopColor: "#ff4e00"
2320
- }
2321
- }
2322
- ),
2323
- /* @__PURE__ */ jsx(
2324
- "stop",
2325
- {
2326
- offset: 1,
2327
- style: {
2328
- stopOpacity: 1,
2329
- stopColor: "#ff1791"
2330
- }
2331
- }
2332
- )
2333
- ]
2334
- }
2335
- ),
2336
- /* @__PURE__ */ jsxs(
2337
- "linearGradient",
2338
- {
2339
- id: m,
2340
- spreadMethod: "pad",
2341
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.554)",
2342
- gradientUnits: "userSpaceOnUse",
2343
- y2: 0,
2344
- x2: 1,
2345
- y1: 0,
2346
- x1: 0,
2347
- children: [
2348
- /* @__PURE__ */ jsx(
2349
- "stop",
2350
- {
2351
- offset: 0,
2352
- style: {
2353
- stopOpacity: 1,
2354
- stopColor: "#ff4e00"
2355
- }
2356
- }
2357
- ),
2358
- /* @__PURE__ */ jsx(
2359
- "stop",
2360
- {
2361
- offset: 1,
2362
- style: {
2363
- stopOpacity: 1,
2364
- stopColor: "#ff1791"
2365
- }
2366
- }
2367
- )
2368
- ]
2369
- }
2370
- ),
2371
- /* @__PURE__ */ jsxs(
2372
- "linearGradient",
2373
- {
2374
- id: p,
2375
- spreadMethod: "pad",
2376
- gradientTransform: "matrix(521.97632 0 0 -521.97632 69.067 191.973)",
2377
- gradientUnits: "userSpaceOnUse",
2378
- y2: 0,
2379
- x2: 1,
2380
- y1: 0,
2381
- x1: 0,
2382
- children: [
2383
- /* @__PURE__ */ jsx(
2384
- "stop",
2385
- {
2386
- offset: 0,
2387
- style: {
2388
- stopOpacity: 1,
2389
- stopColor: "#ff4e00"
2390
- }
2391
- }
2392
- ),
2393
- /* @__PURE__ */ jsx(
2394
- "stop",
2395
- {
2396
- offset: 1,
2397
- style: {
2398
- stopOpacity: 1,
2399
- stopColor: "#ff1791"
2400
- }
2401
- }
2402
- )
2403
- ]
2404
- }
2405
- ),
2406
- /* @__PURE__ */ jsxs(
2407
- "linearGradient",
2408
- {
2409
- id: q,
2410
- spreadMethod: "pad",
2411
- gradientTransform: "matrix(523.09039 0 0 -523.09039 67.312 191.973)",
2412
- gradientUnits: "userSpaceOnUse",
2413
- y2: 0,
2414
- x2: 1,
2415
- y1: 0,
2416
- x1: 0,
2417
- children: [
2418
- /* @__PURE__ */ jsx(
2419
- "stop",
2420
- {
2421
- offset: 0,
2422
- style: {
2423
- stopOpacity: 1,
2424
- stopColor: "#ff4e00"
2425
- }
2426
- }
2427
- ),
2428
- /* @__PURE__ */ jsx(
2429
- "stop",
2430
- {
2431
- offset: 1,
2432
- style: {
2433
- stopOpacity: 1,
2434
- stopColor: "#ff1791"
2435
- }
2436
- }
2437
- )
2438
- ]
2439
- }
2440
- ),
2441
- /* @__PURE__ */ jsxs(
2442
- "linearGradient",
2443
- {
2444
- id: r,
2445
- spreadMethod: "pad",
2446
- gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
2447
- gradientUnits: "userSpaceOnUse",
2448
- y2: 0,
2449
- x2: 1,
2450
- y1: 0,
2451
- x1: 0,
2452
- children: [
2453
- /* @__PURE__ */ jsx(
2454
- "stop",
2455
- {
2456
- offset: 0,
2457
- style: {
2458
- stopOpacity: 1,
2459
- stopColor: "#ff4e00"
2460
- }
2461
- }
2462
- ),
2463
- /* @__PURE__ */ jsx(
2464
- "stop",
2465
- {
2466
- offset: 1,
2467
- style: {
2468
- stopOpacity: 1,
2469
- stopColor: "#ff1791"
2470
- }
2471
- }
2472
- )
2473
- ]
2474
- }
2475
- ),
2476
- /* @__PURE__ */ jsx("clipPath", { id: a2, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
2477
- /* @__PURE__ */ jsx("clipPath", { id: b, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M423.64 242h164.999V77H423.64Z" }) }),
2478
- /* @__PURE__ */ jsx("clipPath", { id: e, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
2479
- /* @__PURE__ */ jsx("clipPath", { id: f, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M311.3 242h93.031V77H311.3Z" }) }),
2480
- /* @__PURE__ */ jsx("clipPath", { id: h, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M198.96 242h35.106V77H198.96Z" }) }),
2481
- /* @__PURE__ */ jsx("clipPath", { id: n, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
2482
- /* @__PURE__ */ jsx("clipPath", { id: o, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M69.067 242H169.12V141.947H69.067Z" }) })
2483
- ] }),
2484
- /* @__PURE__ */ jsx("g", { clipPath: `url(#${a2})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsx(
2485
- "g",
2486
- {
2487
- style: {
2488
- opacity: 0.69999701
2489
- },
2490
- clipPath: `url(#${b})`,
2491
- children: /* @__PURE__ */ jsx(
2492
- "path",
2493
- {
2494
- style: {
2495
- fill: `url(#${c2})`,
2496
- stroke: "none"
2497
- },
2498
- d: "M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
2499
- }
2500
- )
2501
- }
2502
- ) }),
2065
+ children: /* @__PURE__ */ jsxs("g", { id: "Layer-1", fill: fillColor, children: [
2503
2066
  /* @__PURE__ */ jsx(
2504
2067
  "path",
2505
2068
  {
2506
- style: {
2507
- fill: `url(#${d})`,
2508
- stroke: "none"
2509
- },
2510
- d: "M558.674 236.858 428.781 106.966c-6.855-6.855-6.855-17.969 0-24.825 6.855-6.854 17.969-6.854 24.823 0l129.894 129.894c6.854 6.855 6.854 17.968 0 24.823A17.498 17.498 0 0 1 571.086 242a17.495 17.495 0 0 1-12.412-5.142",
2511
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2069
+ d: "M994.287,93.486c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m0,-93.486c-34.509,-0 -62.484,27.976 -62.484,62.486l0,187.511c0,68.943 -56.09,125.033 -125.032,125.033c-68.942,-0 -125.03,-56.09 -125.03,-125.033l0,-187.511c0,-34.51 -27.976,-62.486 -62.485,-62.486c-34.509,-0 -62.484,27.976 -62.484,62.486l0,187.511c0,137.853 112.149,250.003 249.999,250.003c137.851,-0 250.001,-112.15 250.001,-250.003l0,-187.511c0,-34.51 -27.976,-62.486 -62.485,-62.486",
2070
+ style: pathStyle
2512
2071
  }
2513
2072
  ),
2514
- /* @__PURE__ */ jsxs("g", { clipPath: `url(#${e})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: [
2515
- /* @__PURE__ */ jsx(
2516
- "g",
2517
- {
2518
- style: {
2519
- opacity: 0.69999701
2520
- },
2521
- clipPath: `url(#${f})`,
2522
- children: /* @__PURE__ */ jsx(
2523
- "path",
2524
- {
2525
- style: {
2526
- fill: `url(#${g})`,
2527
- stroke: "none"
2528
- },
2529
- d: "M328.853 112.107c22.297 0 40.372 18.075 40.372 40.372v71.315c0 10.054 7.505 18.206 17.554 18.206 10.048 0 17.552-8.152 17.552-18.206v-71.315c0-41.686-33.793-75.479-75.478-75.479-9.694 0-17.553 7.859-17.553 17.554 0 9.694 7.859 17.553 17.553 17.553"
2530
- }
2531
- )
2532
- }
2533
- ),
2534
- /* @__PURE__ */ jsx(
2535
- "g",
2536
- {
2537
- style: {
2538
- opacity: 0.69999701
2539
- },
2540
- clipPath: `url(#${h})`,
2541
- children: /* @__PURE__ */ jsx(
2542
- "path",
2543
- {
2544
- style: {
2545
- fill: `url(#${i})`,
2546
- stroke: "none"
2547
- },
2548
- d: "M216.513 242c-10.049 0-17.553-8.152-17.553-18.206V95.206c0-10.054 7.504-18.206 17.553-18.206 10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.054-7.505 18.206-17.553 18.206"
2549
- }
2550
- )
2551
- }
2552
- )
2553
- ] }),
2554
2073
  /* @__PURE__ */ jsx(
2555
2074
  "path",
2556
2075
  {
2557
- style: {
2558
- fill: `url(#${j})`,
2559
- stroke: "none"
2560
- },
2561
- d: "M369.225 224.447c0-9.694 7.859-17.553 17.553-17.553 9.695 0 17.553 7.859 17.553 17.553s-7.858 17.552-17.553 17.552c-9.694 0-17.553-7.858-17.553-17.552",
2562
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2563
- }
2564
- ),
2565
- /* @__PURE__ */ jsx(
2566
- "path",
2567
- {
2568
- style: {
2569
- fill: `url(#${k})`,
2570
- stroke: "none"
2571
- },
2572
- d: "M553.532 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.552-17.554 17.552-9.694 0-17.553-7.858-17.553-17.552",
2573
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2574
- }
2575
- ),
2576
- /* @__PURE__ */ jsx(
2577
- "path",
2578
- {
2579
- style: {
2580
- fill: `url(#${l})`,
2581
- stroke: "none"
2582
- },
2583
- d: "M69.067 223.794V95.206C69.067 85.152 76.571 77 86.62 77c10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.055-7.505 18.205-17.553 18.205-10.049 0-17.553-8.15-17.553-18.205",
2584
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2076
+ d: "M1537.51,468.511c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m-275.883,-218.509l-143.33,143.329c-24.402,24.402 -24.402,63.966 0,88.368c24.402,24.402 63.967,24.402 88.369,-0l143.33,-143.329l143.328,143.329c24.402,24.4 63.967,24.402 88.369,-0c24.403,-24.402 24.403,-63.966 0.001,-88.368l-143.33,-143.329l0.001,-0.004l143.329,-143.329c24.402,-24.402 24.402,-63.965 0,-88.367c-24.402,-24.402 -63.967,-24.402 -88.369,-0l-143.329,143.328l-143.329,-143.328c-24.402,-24.401 -63.967,-24.402 -88.369,-0c-24.402,24.402 -24.402,63.965 0,88.367l143.329,143.329l0,0.004Z",
2077
+ style: pathStyle
2585
2078
  }
2586
2079
  ),
2587
2080
  /* @__PURE__ */ jsx(
2588
2081
  "path",
2589
2082
  {
2590
- style: {
2591
- fill: `url(#${m})`,
2592
- stroke: "none"
2593
- },
2594
- d: "M198.96 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.553-17.554 17.553-9.694 0-17.553-7.859-17.553-17.553",
2595
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2596
- }
2597
- ),
2598
- /* @__PURE__ */ jsx("g", { clipPath: `url(#${n})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsx(
2599
- "g",
2600
- {
2601
- style: {
2602
- opacity: 0.69999701
2603
- },
2604
- clipPath: `url(#${o})`,
2605
- children: /* @__PURE__ */ jsx(
2606
- "path",
2607
- {
2608
- style: {
2609
- fill: `url(#${p})`,
2610
- stroke: "none"
2611
- },
2612
- d: "M139.155 147.088c6.855-6.855 17.969-6.855 24.824 0s6.855 17.969 0 24.824l-64.947 64.946c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
2613
- }
2614
- )
2615
- }
2616
- ) }),
2617
- /* @__PURE__ */ jsx(
2618
- "path",
2619
- {
2620
- style: {
2621
- fill: `url(#${q})`,
2622
- stroke: "none"
2623
- },
2624
- d: "m204.101 236.858-64.947-64.946c-6.854-6.855-6.854-17.969 0-24.824 6.856-6.855 17.97-6.855 24.824 0l64.947 64.947c6.855 6.855 6.855 17.968 0 24.823A17.495 17.495 0 0 1 216.513 242a17.498 17.498 0 0 1-12.412-5.142",
2625
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2626
- }
2627
- ),
2628
- /* @__PURE__ */ jsx(
2629
- "path",
2630
- {
2631
- style: {
2632
- fill: `url(#${r})`,
2633
- stroke: "none"
2634
- },
2635
- d: "M253.374 223.794v-71.315c0-41.685 33.793-75.479 75.479-75.479 9.695 0 17.553 7.859 17.553 17.554 0 9.694-7.858 17.553-17.553 17.553-22.297 0-40.372 18.075-40.372 40.372v71.315c0 10.055-7.505 18.205-17.554 18.205s-17.553-8.15-17.553-18.205",
2636
- transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
2083
+ d: "M437.511,468.521c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m23.915,-463.762c-23.348,-9.672 -50.226,-4.327 -68.096,13.544l-143.331,143.329l-143.33,-143.329c-17.871,-17.871 -44.747,-23.216 -68.096,-13.544c-23.349,9.671 -38.574,32.455 -38.574,57.729l0,375.026c0,34.51 27.977,62.486 62.487,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-224.173l80.843,80.844c24.404,24.402 63.965,24.402 88.369,-0l80.843,-80.844l0,224.173c0,34.51 27.976,62.486 62.486,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-375.026c0,-25.274 -15.224,-48.058 -38.573,-57.729",
2084
+ style: pathStyle
2637
2085
  }
2638
2086
  )
2639
- ]
2087
+ ] })
2640
2088
  }
2641
2089
  );
2642
2090
  }
@@ -2731,6 +2179,8 @@ function ConfigureApi({ secrets, setDialogState }) {
2731
2179
  /* @__PURE__ */ jsx("strong", { children: "Mux Data" }),
2732
2180
  " (Read)",
2733
2181
  /* @__PURE__ */ jsx("br", {}),
2182
+ "To use Signed URLs, the token must also have System permissions.",
2183
+ /* @__PURE__ */ jsx("br", {}),
2734
2184
  "The credentials will be stored safely in a hidden document only available to editors."
2735
2185
  ] })
2736
2186
  ] }) }),
@@ -3603,6 +3053,88 @@ function TextTracksEditor({
3603
3053
  )
3604
3054
  ] }) });
3605
3055
  }
3056
+ function PlaybackPolicyOption({
3057
+ id,
3058
+ checked,
3059
+ optionName,
3060
+ description,
3061
+ dispatch,
3062
+ action
3063
+ }) {
3064
+ const [scale, setScale] = useState(1), boxStyle = {
3065
+ outline: "0.01rem solid grey",
3066
+ transform: `scale(${scale})`,
3067
+ transition: "transform 0.1s ease-in-out",
3068
+ cursor: "pointer",
3069
+ borderRadius: "0.25rem"
3070
+ }, triggerAnimation = () => {
3071
+ setScale(0.98), setTimeout(() => {
3072
+ setScale(1);
3073
+ }, 100);
3074
+ };
3075
+ return /* @__PURE__ */ jsx("label", { children: /* @__PURE__ */ jsxs(Flex, { gap: 3, padding: 3, style: boxStyle, children: [
3076
+ /* @__PURE__ */ jsx(Checkbox, { id, required: !0, checked, onChange: () => {
3077
+ triggerAnimation(), dispatch({
3078
+ action,
3079
+ value: !checked
3080
+ });
3081
+ } }),
3082
+ /* @__PURE__ */ jsxs(Grid, { gap: 3, children: [
3083
+ /* @__PURE__ */ jsx(Text, { size: 3, weight: "bold", children: optionName }),
3084
+ /* @__PURE__ */ jsx(Text, { size: 2, muted: !0, children: description })
3085
+ ] })
3086
+ ] }) });
3087
+ }
3088
+ function PlaybackPolicyWarning() {
3089
+ return /* @__PURE__ */ jsx(Box, { padding: 2, style: {
3090
+ outline: "0.01rem solid grey",
3091
+ backgroundColor: "#979cb0",
3092
+ borderRadius: "0.5rem",
3093
+ width: "max-content",
3094
+ color: "#13141A"
3095
+ }, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
3096
+ /* @__PURE__ */ jsx(WarningFilledIcon, {}),
3097
+ /* @__PURE__ */ jsx(Text, { size: 1, style: {
3098
+ color: "#13141A",
3099
+ fontWeight: 500
3100
+ }, children: "Please select at least one Playback Policy" })
3101
+ ] }) });
3102
+ }
3103
+ function PlaybackPolicy({
3104
+ id,
3105
+ config,
3106
+ secrets,
3107
+ dispatch
3108
+ }) {
3109
+ const noPolicySelected = !(config.public_policy || config.signed_policy);
3110
+ return /* @__PURE__ */ jsxs(Grid, { gap: 3, children: [
3111
+ /* @__PURE__ */ jsx(Text, { weight: "bold", children: "Advanced Playback Policies" }),
3112
+ /* @__PURE__ */ jsx(
3113
+ PlaybackPolicyOption,
3114
+ {
3115
+ id: `${id}--public`,
3116
+ checked: config.public_policy,
3117
+ optionName: "Public",
3118
+ description: "Playback IDs are accessible by constructing an HLS URL like https://stream.mux.com/{PLAYBACK_ID}",
3119
+ dispatch,
3120
+ action: "public_policy"
3121
+ }
3122
+ ),
3123
+ secrets.enableSignedUrls && /* @__PURE__ */ jsx(
3124
+ PlaybackPolicyOption,
3125
+ {
3126
+ id: `${id}--signed`,
3127
+ checked: config.signed_policy,
3128
+ optionName: "Signed",
3129
+ description: `Playback IDs should be used with tokens https://stream.mux.com/{PLAYBACK_ID}?token={TOKEN}.
3130
+ // See Secure video playback for details about creating tokens.`,
3131
+ dispatch,
3132
+ action: "signed_policy"
3133
+ }
3134
+ ),
3135
+ noPolicySelected && /* @__PURE__ */ jsx(PlaybackPolicyWarning, {})
3136
+ ] });
3137
+ }
3606
3138
  const ENCODING_OPTIONS = [
3607
3139
  { value: "smart", label: "Smart" },
3608
3140
  { value: "baseline", label: "Baseline" }
@@ -3635,7 +3167,9 @@ function UploadConfiguration({
3635
3167
  encoding_tier: action.value,
3636
3168
  mp4_support: "none",
3637
3169
  max_resolution_tier: "1080p",
3638
- text_tracks: prev.text_tracks?.filter(({ type }) => type !== "autogenerated")
3170
+ text_tracks: prev.text_tracks?.filter(({ type }) => type !== "autogenerated"),
3171
+ public_policy: !0,
3172
+ signed_policy: !1
3639
3173
  }) : Object.assign({}, prev, {
3640
3174
  encoding_tier: action.value,
3641
3175
  mp4_support: pluginConfig.mp4_support,
@@ -3645,7 +3179,9 @@ function UploadConfiguration({
3645
3179
  case "mp4_support":
3646
3180
  case "max_resolution_tier":
3647
3181
  case "normalize_audio":
3648
- case "signed":
3182
+ case "signed_policy":
3183
+ return Object.assign({}, prev, { [action.action]: action.value });
3184
+ case "public_policy":
3649
3185
  return Object.assign({}, prev, { [action.action]: action.value });
3650
3186
  // Updating individual tracks
3651
3187
  case "track": {
@@ -3680,7 +3216,8 @@ function UploadConfiguration({
3680
3216
  encoding_tier: pluginConfig.encoding_tier,
3681
3217
  max_resolution_tier: pluginConfig.max_resolution_tier,
3682
3218
  mp4_support: pluginConfig.mp4_support,
3683
- signed: secrets.enableSignedUrls && pluginConfig.defaultSigned,
3219
+ signed_policy: secrets.enableSignedUrls && pluginConfig.defaultSigned,
3220
+ public_policy: !0,
3684
3221
  normalize_audio: pluginConfig.normalize_audio,
3685
3222
  text_tracks: autoTextTracks
3686
3223
  }
@@ -3799,25 +3336,9 @@ function UploadConfiguration({
3799
3336
  }) })
3800
3337
  }
3801
3338
  ),
3802
- (secrets.enableSignedUrls || config.encoding_tier === "smart") && /* @__PURE__ */ jsx(FormField$2, { title: "Additional Configuration", children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
3803
- secrets.enableSignedUrls && /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
3804
- /* @__PURE__ */ jsx(
3805
- Checkbox,
3806
- {
3807
- id: `${id}--signed`,
3808
- style: { display: "block" },
3809
- name: "signed",
3810
- required: !0,
3811
- checked: config.signed,
3812
- onChange: (e) => dispatch({
3813
- action: "signed",
3814
- value: e.currentTarget.checked
3815
- })
3816
- }
3817
- ),
3818
- /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx("label", { htmlFor: `${id}--signed`, children: "Signed playback URL" }) })
3819
- ] }),
3820
- config.encoding_tier === "smart" && /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
3339
+ config.encoding_tier === "smart" && /* @__PURE__ */ jsx(FormField$2, { title: "Additional Configuration", children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
3340
+ /* @__PURE__ */ jsx(PlaybackPolicy, { id, config, secrets, dispatch }),
3341
+ config.encoding_tier === "smart" && /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, padding: [0, 2], children: [
3821
3342
  /* @__PURE__ */ jsx(
3822
3343
  Checkbox,
3823
3344
  {
@@ -3847,6 +3368,7 @@ function UploadConfiguration({
3847
3368
  /* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsx(
3848
3369
  Button,
3849
3370
  {
3371
+ disabled: config.encoding_tier === "smart" && !config.public_policy && !config.signed_policy,
3850
3372
  icon: UploadIcon,
3851
3373
  text: "Upload",
3852
3374
  tone: "positive",
@@ -3857,6 +3379,10 @@ function UploadConfiguration({
3857
3379
  }
3858
3380
  );
3859
3381
  }
3382
+ function setPlaybackPolicy(config) {
3383
+ const playback_policy = [];
3384
+ return config.public_policy && playback_policy.push("public"), config.signed_policy && playback_policy.push("signed"), playback_policy;
3385
+ }
3860
3386
  function formatUploadConfig(config) {
3861
3387
  const generated_subtitles = config.text_tracks.filter(isAutogeneratedTrack).map((track) => ({
3862
3388
  name: track.name,
@@ -3881,7 +3407,7 @@ function formatUploadConfig(config) {
3881
3407
  )
3882
3408
  ],
3883
3409
  mp4_support: config.mp4_support,
3884
- playback_policy: config.signed ? ["public", "signed"] : ["public"],
3410
+ playback_policy: setPlaybackPolicy(config),
3885
3411
  max_resolution_tier: config.max_resolution_tier,
3886
3412
  encoding_tier: config.encoding_tier,
3887
3413
  normalize_audio: config.normalize_audio