sanity-plugin-mux-input 1.1.0 → 1.1.1
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 +21 -21
- package/README.md +86 -86
- package/build/actions/assets.js +0 -0
- package/build/actions/assets.js.map +1 -1
- package/build/actions/secrets.js +0 -0
- package/build/actions/secrets.js.map +1 -1
- package/build/actions/upload.js +0 -0
- package/build/actions/upload.js.map +1 -1
- package/build/clients/SanityClient.js +0 -0
- package/build/clients/SanityClient.js.map +1 -1
- package/build/clients/upChunkObservable.js +0 -0
- package/build/clients/upChunkObservable.js.map +1 -1
- package/build/components/FileInputButton.js +0 -0
- package/build/components/FileInputButton.js.map +1 -1
- package/build/components/Input.css +30 -30
- package/build/components/Input.js +0 -0
- package/build/components/Input.js.map +1 -1
- package/build/components/MuxLogo.js +0 -0
- package/build/components/MuxLogo.js.map +1 -1
- package/build/components/Preview.css +16 -16
- package/build/components/Preview.js +0 -0
- package/build/components/Preview.js.map +1 -1
- package/build/components/SelectAsset.css +56 -56
- package/build/components/SelectAsset.js +0 -0
- package/build/components/SelectAsset.js.map +1 -1
- package/build/components/Setup.css +7 -7
- package/build/components/Setup.js +0 -0
- package/build/components/Setup.js.map +1 -1
- package/build/components/UploadPlaceholder.css +81 -81
- package/build/components/UploadPlaceholder.js +0 -0
- package/build/components/UploadPlaceholder.js.map +1 -1
- package/build/components/Uploader.css +28 -28
- package/build/components/Uploader.js +0 -0
- package/build/components/Uploader.js.map +1 -1
- package/build/components/Video.css +21 -21
- package/build/components/Video.js +0 -0
- package/build/components/Video.js.map +1 -1
- package/build/config.js +0 -0
- package/build/config.js.map +1 -1
- package/build/index.js +0 -0
- package/build/index.js.map +1 -1
- package/build/schema/mux.video.js +0 -0
- package/build/schema/mux.video.js.map +1 -1
- package/build/schema/mux.videoAsset.js +0 -0
- package/build/schema/mux.videoAsset.js.map +1 -1
- package/build/util/extractFiles.js +4 -4
- package/build/util/extractFiles.js.map +1 -1
- package/build/util/formatTime.js +0 -0
- package/build/util/formatTime.js.map +1 -1
- package/build/util/generateJwt.js +0 -0
- package/build/util/generateJwt.js.map +1 -1
- package/build/util/getPosterSrc.js +0 -0
- package/build/util/getPosterSrc.js.map +1 -1
- package/build/util/getStoryboardSrc.js +0 -0
- package/build/util/getStoryboardSrc.js.map +1 -1
- package/build/util/getVideoSrc.js +0 -0
- package/build/util/getVideoSrc.js.map +1 -1
- package/config.dist.json +3 -3
- package/package.json +85 -85
- package/sanity.json +16 -16
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Sanity.io
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Sanity.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
# Mux Video Input Sanity Plugin
|
|
2
|
-
|
|
3
|
-
This is a plugin which let you use [Mux](https://www.mux.com) video assets in your Sanity studio.
|
|
4
|
-
|
|
5
|
-
The Mux plugin for Sanity gives you a way to upload and preview videos easily.
|
|
6
|
-
|
|
7
|
-
[Read our blog post](https://www.sanity.io/blog/first-class-responsive-video-support-with-the-new-mux-plugin) about this plugin.
|
|
8
|
-
|
|
9
|
-
Not familiar with Sanity? [Visit www.sanity.io](https://www.sanity.io/)
|
|
10
|
-
|
|
11
|
-
## Quick start
|
|
12
|
-
|
|
13
|
-
- While in your project folder, run `sanity install mux-input`.
|
|
14
|
-
Read more about [using plugins in Sanity here](https://www.sanity.io/docs/plugins).
|
|
15
|
-
|
|
16
|
-
* Make a schema type that uses the plugin's type `mux.video`, for example:
|
|
17
|
-
|
|
18
|
-
```js
|
|
19
|
-
{
|
|
20
|
-
title: "Video blog post",
|
|
21
|
-
name: "videoBlogPost",
|
|
22
|
-
type: "document",
|
|
23
|
-
fields: [
|
|
24
|
-
{ title: "Title", name: "title", type: "string" },
|
|
25
|
-
{
|
|
26
|
-
title: "Video file",
|
|
27
|
-
name: "video",
|
|
28
|
-
type: "mux.video"
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Read more about [schemas in Sanity here](https://www.sanity.io/docs/the-schema).
|
|
35
|
-
|
|
36
|
-
- Get an API Access Token and enter it into the setup screen
|
|
37
|
-
First time you use the plugin you will be asked to enter your Mux credentials.
|
|
38
|
-
|
|
39
|
-
The Mux Video API uses an Access Token and Secret Key for authentication.
|
|
40
|
-
|
|
41
|
-
If you haven't already, generate a new Access Token in the Access Token settings of your Mux account dashboard, and make sure it got permission to both read and write _video_ and read _data_.
|
|
42
|
-
|
|
43
|
-
The token is stored in the dataset as a document of the type `mux.apiKey` with the id `secrets.mux`.
|
|
44
|
-
Having the ID be non-root ensures that only editors are able to see it.
|
|
45
|
-
|
|
46
|
-
The Mux plugin will find it’s access tokens by fetching this document.
|
|
47
|
-
|
|
48
|
-
# Playing videos in the frontend
|
|
49
|
-
|
|
50
|
-
We have made an own player which supports poster images for the videos as set with this plugin, see [`sanity-mux-player`](https://github.com/sanity-io/sanity-mux-player)
|
|
51
|
-
|
|
52
|
-
You could use any player which supports HLS, just point the video source to:
|
|
53
|
-
|
|
54
|
-
`https://stream.mux.com/${assetDocument.playbackId}.m3u8`
|
|
55
|
-
|
|
56
|
-
# Enabling Signed Urls
|
|
57
|
-
|
|
58
|
-
To enable [signed urls](https://docs.mux.com/docs/security-signed-urls) with content uploaded to Mux, you will need to check the "Enable Signed Urls" option in the Mux Plugin configuration. Assuming that the API Access Token and Secret Key are set (as per the [Quick start](#quick-start) section).
|
|
59
|
-
|
|
60
|
-
More information for this feature of the plugin can be found on Mux's [documentation](https://docs.mux.com/docs/headless-cms-sanity#advanced-signed-urls)
|
|
61
|
-
|
|
62
|
-
# Enabling MP4 support
|
|
63
|
-
|
|
64
|
-
To enable [static MP4 renditions](https://docs.mux.com/guides/video/enable-static-mp4-renditions), create or open the config file found in `config/mux-input.json` in your studio folder. This file is automatically created the first time the studio starts after adding the plugin.
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
{
|
|
68
|
-
"mp4_support": "standard"
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Currently `mp4_support` is the only supported MUX option and this supports a value of either `standard` or `none` (the default).
|
|
73
|
-
|
|
74
|
-
# Contributing
|
|
75
|
-
|
|
76
|
-
Issues are actively monitored and PRs are welcome. When developing this plugin the easiest setup is:
|
|
77
|
-
|
|
78
|
-
1. Fork this repo.
|
|
79
|
-
1. Install the sanity cli and create a sanity project: `npm install -g @sanity/cli && sanity init`. Follow the prompts, starting out with the blog template is a good way to go.
|
|
80
|
-
1. `cd` into your project directory, run `npm install && npm start` - your sanity studio should be running on http://localhost:3333.
|
|
81
|
-
1. `cd` into the `plugins` director of your project.
|
|
82
|
-
1. Fork this repo and clone your fork into the `plugins` directory inside your project `git clone git@github.com:your-fork/sanity-plugin-mux-input.git`.
|
|
83
|
-
1. Open `sanity.json`, go to the `plugins` array and add `mux-input`.
|
|
84
|
-
1. Re-start the sanity studio server with `npm start`.
|
|
85
|
-
1. Edit `schemas/post.js` and add follow the plugin documentation to add a `mux.video` type field.
|
|
86
|
-
1. Your studio should reload, and now when you edit the plugin code it should reload the studio, when you're done create a branch, put in a PR and a maintainer will review it. Thank you!
|
|
1
|
+
# Mux Video Input Sanity Plugin
|
|
2
|
+
|
|
3
|
+
This is a plugin which let you use [Mux](https://www.mux.com) video assets in your Sanity studio.
|
|
4
|
+
|
|
5
|
+
The Mux plugin for Sanity gives you a way to upload and preview videos easily.
|
|
6
|
+
|
|
7
|
+
[Read our blog post](https://www.sanity.io/blog/first-class-responsive-video-support-with-the-new-mux-plugin) about this plugin.
|
|
8
|
+
|
|
9
|
+
Not familiar with Sanity? [Visit www.sanity.io](https://www.sanity.io/)
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
- While in your project folder, run `sanity install mux-input`.
|
|
14
|
+
Read more about [using plugins in Sanity here](https://www.sanity.io/docs/plugins).
|
|
15
|
+
|
|
16
|
+
* Make a schema type that uses the plugin's type `mux.video`, for example:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
{
|
|
20
|
+
title: "Video blog post",
|
|
21
|
+
name: "videoBlogPost",
|
|
22
|
+
type: "document",
|
|
23
|
+
fields: [
|
|
24
|
+
{ title: "Title", name: "title", type: "string" },
|
|
25
|
+
{
|
|
26
|
+
title: "Video file",
|
|
27
|
+
name: "video",
|
|
28
|
+
type: "mux.video"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Read more about [schemas in Sanity here](https://www.sanity.io/docs/the-schema).
|
|
35
|
+
|
|
36
|
+
- Get an API Access Token and enter it into the setup screen
|
|
37
|
+
First time you use the plugin you will be asked to enter your Mux credentials.
|
|
38
|
+
|
|
39
|
+
The Mux Video API uses an Access Token and Secret Key for authentication.
|
|
40
|
+
|
|
41
|
+
If you haven't already, generate a new Access Token in the Access Token settings of your Mux account dashboard, and make sure it got permission to both read and write _video_ and read _data_.
|
|
42
|
+
|
|
43
|
+
The token is stored in the dataset as a document of the type `mux.apiKey` with the id `secrets.mux`.
|
|
44
|
+
Having the ID be non-root ensures that only editors are able to see it.
|
|
45
|
+
|
|
46
|
+
The Mux plugin will find it’s access tokens by fetching this document.
|
|
47
|
+
|
|
48
|
+
# Playing videos in the frontend
|
|
49
|
+
|
|
50
|
+
We have made an own player which supports poster images for the videos as set with this plugin, see [`sanity-mux-player`](https://github.com/sanity-io/sanity-mux-player)
|
|
51
|
+
|
|
52
|
+
You could use any player which supports HLS, just point the video source to:
|
|
53
|
+
|
|
54
|
+
`https://stream.mux.com/${assetDocument.playbackId}.m3u8`
|
|
55
|
+
|
|
56
|
+
# Enabling Signed Urls
|
|
57
|
+
|
|
58
|
+
To enable [signed urls](https://docs.mux.com/docs/security-signed-urls) with content uploaded to Mux, you will need to check the "Enable Signed Urls" option in the Mux Plugin configuration. Assuming that the API Access Token and Secret Key are set (as per the [Quick start](#quick-start) section).
|
|
59
|
+
|
|
60
|
+
More information for this feature of the plugin can be found on Mux's [documentation](https://docs.mux.com/docs/headless-cms-sanity#advanced-signed-urls)
|
|
61
|
+
|
|
62
|
+
# Enabling MP4 support
|
|
63
|
+
|
|
64
|
+
To enable [static MP4 renditions](https://docs.mux.com/guides/video/enable-static-mp4-renditions), create or open the config file found in `config/mux-input.json` in your studio folder. This file is automatically created the first time the studio starts after adding the plugin.
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
{
|
|
68
|
+
"mp4_support": "standard"
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Currently `mp4_support` is the only supported MUX option and this supports a value of either `standard` or `none` (the default).
|
|
73
|
+
|
|
74
|
+
# Contributing
|
|
75
|
+
|
|
76
|
+
Issues are actively monitored and PRs are welcome. When developing this plugin the easiest setup is:
|
|
77
|
+
|
|
78
|
+
1. Fork this repo.
|
|
79
|
+
1. Install the sanity cli and create a sanity project: `npm install -g @sanity/cli && sanity init`. Follow the prompts, starting out with the blog template is a good way to go.
|
|
80
|
+
1. `cd` into your project directory, run `npm install && npm start` - your sanity studio should be running on http://localhost:3333.
|
|
81
|
+
1. `cd` into the `plugins` director of your project.
|
|
82
|
+
1. Fork this repo and clone your fork into the `plugins` directory inside your project `git clone git@github.com:your-fork/sanity-plugin-mux-input.git`.
|
|
83
|
+
1. Open `sanity.json`, go to the `plugins` array and add `mux-input`.
|
|
84
|
+
1. Re-start the sanity studio server with `npm start`.
|
|
85
|
+
1. Edit `schemas/post.js` and add follow the plugin documentation to add a `mux.video` type field.
|
|
86
|
+
1. Your studio should reload, and now when you edit the plugin code it should reload the studio, when you're done create a branch, put in a PR and a maintainer will review it. Thank you!
|
package/build/actions/assets.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/assets.js"],"names":["deleteAsset","assetId","dataset","client","clientConfig","request","url","withCredentials","method","getAsset"],"mappings":";;;;;;;;;AAAA;;;;AAEO,SAASA,WAAT,CAAqBC,OAArB,EAA8B;AACnC,MAAMC,OAAO,GAAGC,sBAAOC,YAAP,CAAoBF,OAApC;AACA,SAAOC,sBAAOE,OAAP,CAAe;AACpBC,IAAAA,GAAG,+BAAwBJ,OAAxB,cAAmCD,OAAnC,CADiB;AAEpBM,IAAAA,eAAe,EAAE,IAFG;AAGpBC,IAAAA,MAAM,EAAE;AAHY,GAAf,CAAP;AAKD;;AAEM,SAASC,QAAT,CAAkBR,OAAlB,EAA2B;AAChC,MAAMC,OAAO,GAAGC,sBAAOC,YAAP,CAAoBF,OAApC;AACA,SAAOC,sBAAOE,OAAP,CAAe;AACpBC,IAAAA,GAAG,+BAAwBJ,OAAxB,mBAAwCD,OAAxC,CADiB;AAEpBM,IAAAA,eAAe,EAAE,IAFG;AAGpBC,IAAAA,MAAM,EAAE;AAHY,GAAf,CAAP;AAKD;;eAEc;AAACC,EAAAA,QAAD;AAAWT,EAAAA;AAAX,C","sourcesContent":["import client from '../clients/SanityClient'\
|
|
1
|
+
{"version":3,"sources":["../../src/actions/assets.js"],"names":["deleteAsset","assetId","dataset","client","clientConfig","request","url","withCredentials","method","getAsset"],"mappings":";;;;;;;;;AAAA;;;;AAEO,SAASA,WAAT,CAAqBC,OAArB,EAA8B;AACnC,MAAMC,OAAO,GAAGC,sBAAOC,YAAP,CAAoBF,OAApC;AACA,SAAOC,sBAAOE,OAAP,CAAe;AACpBC,IAAAA,GAAG,+BAAwBJ,OAAxB,cAAmCD,OAAnC,CADiB;AAEpBM,IAAAA,eAAe,EAAE,IAFG;AAGpBC,IAAAA,MAAM,EAAE;AAHY,GAAf,CAAP;AAKD;;AAEM,SAASC,QAAT,CAAkBR,OAAlB,EAA2B;AAChC,MAAMC,OAAO,GAAGC,sBAAOC,YAAP,CAAoBF,OAApC;AACA,SAAOC,sBAAOE,OAAP,CAAe;AACpBC,IAAAA,GAAG,+BAAwBJ,OAAxB,mBAAwCD,OAAxC,CADiB;AAEpBM,IAAAA,eAAe,EAAE,IAFG;AAGpBC,IAAAA,MAAM,EAAE;AAHY,GAAf,CAAP;AAKD;;eAEc;AAACC,EAAAA,QAAD;AAAWT,EAAAA;AAAX,C","sourcesContent":["import client from '../clients/SanityClient'\n\nexport function deleteAsset(assetId) {\n const dataset = client.clientConfig.dataset\n return client.request({\n url: `/addons/mux/assets/${dataset}/${assetId}`,\n withCredentials: true,\n method: 'DELETE',\n })\n}\n\nexport function getAsset(assetId) {\n const dataset = client.clientConfig.dataset\n return client.request({\n url: `/addons/mux/assets/${dataset}/data/${assetId}`,\n withCredentials: true,\n method: 'GET',\n })\n}\n\nexport default {getAsset, deleteAsset}\n"],"file":"assets.js"}
|
package/build/actions/secrets.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/secrets.js"],"names":["cache","secrets","exists","fetchSecrets","Promise","resolve","client","fetch","then","Boolean","token","secretKey","enableSignedUrls","signingKeyId","signingKeyPrivate","saveSecrets","doc","_id","_type","createOrReplace","createSigningKeys","dataset","clientConfig","request","url","withCredentials","method","testSecrets","haveValidSigningKeys","res","data","id","e","console","error","testSecretsObservable","observable"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;;;;;;;AAEA,IAAMA,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uB,OAAf,CAAlB,CADE,CAMF;AACA;AACA;;AACA,aAAO,CAAC,EAAEG,GAAG,CAACC,IAAJ,IAAYD,GAAG,CAACC,IAAJ,CAASC,EAAvB,CAAR;AACD,KAVD,CAUE,OAAOC,CAAP,EAAU;AACVC,MAAAA,OAAO,CAACC,KAAR,CAAc,6BAAd,EAA6CrB,YAA7C,EAA2D,0BAA3D;AACA,aAAO,KAAP;AACD;AACF,G;;;;AAEM,SAASsB,qBAAT,GAAiC;AACtC,MAAMd,OAAO,GAAGf,sBAAOgB,YAAP,CAAoBD,OAApC;AACA,SAAO,iBAAM,MACXf,sBAAO8B,UAAP,CAAkBb,OAAlB,CAA0B;AACxBC,IAAAA,GAAG,gCAAyBH,OAAzB,UADqB;AAExBI,IAAAA,eAAe,EAAE,IAFO;AAGxBC,IAAAA,MAAM,EAAE;AAHgB,GAA1B,CADK,CAAP;AAOD","sourcesContent":["import {defer} from 'rxjs'\
|
|
1
|
+
{"version":3,"sources":["../../src/actions/secrets.js"],"names":["cache","secrets","exists","fetchSecrets","Promise","resolve","client","fetch","then","Boolean","token","secretKey","enableSignedUrls","signingKeyId","signingKeyPrivate","saveSecrets","doc","_id","_type","createOrReplace","createSigningKeys","dataset","clientConfig","request","url","withCredentials","method","testSecrets","haveValidSigningKeys","res","data","id","e","console","error","testSecretsObservable","observable"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;;;;;;;AAEA,IAAMA,KAAK,GAAG;AACZC,EAAAA,OAAO,EAAE,IADG;AAEZC,EAAAA,MAAM,EAAE;AAFI,CAAd;;AAKO,SAASC,YAAT,GAAwB;AAC7B,MAAIH,KAAK,CAACE,MAAV,EAAkB;AAChB,WAAOE,OAAO,CAACC,OAAR,CAAgBL,KAAhB,CAAP;AACD;;AAED,SAAOM,sBAAOC,KAAP,CAAa,4BAAb,EAA2CC,IAA3C,CAAiDP,OAAD,IAAa;AAClED,IAAAA,KAAK,CAACE,MAAN,GAAeO,OAAO,CAACR,OAAD,CAAtB;AAC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BD,OAApC;AACA,SAAO,iBAAM,MACXf,sBAAO8B,UAAP,CAAkBb,OAAlB,CAA0B;AACxBC,IAAAA,GAAG,gCAAyBH,OAAzB,UADqB;AAExBI,IAAAA,eAAe,EAAE,IAFO;AAGxBC,IAAAA,MAAM,EAAE;AAHgB,GAA1B,CADK,CAAP;AAOD","sourcesContent":["import {defer} from 'rxjs'\nimport client from '../clients/SanityClient'\n\nconst cache = {\n secrets: null,\n exists: false,\n}\n\nexport function fetchSecrets() {\n if (cache.exists) {\n return Promise.resolve(cache)\n }\n\n return client.fetch('*[_id == \"secrets.mux\"][0]').then((secrets) => {\n cache.exists = Boolean(secrets)\n cache.secrets = {\n token: secrets?.token || null,\n secretKey: secrets?.secretKey || null,\n enableSignedUrls: secrets?.enableSignedUrls || false,\n signingKeyId: secrets?.signingKeyId || null,\n signingKeyPrivate: secrets?.signingKeyPrivate || null,\n }\n return cache\n })\n}\n\nexport function saveSecrets(token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate) {\n const doc = {\n _id: 'secrets.mux',\n _type: 'mux.apiKey',\n token,\n secretKey,\n enableSignedUrls,\n signingKeyId,\n signingKeyPrivate,\n }\n\n return client.createOrReplace(doc).then(() => {\n cache.exists = true\n cache.secrets = {\n token,\n secretKey,\n enableSignedUrls,\n signingKeyId,\n signingKeyPrivate,\n }\n return cache.secrets\n })\n}\n\nexport function createSigningKeys() {\n const dataset = client.clientConfig.dataset\n return client.request({\n url: `/addons/mux/signing-keys/${dataset}`,\n withCredentials: true,\n method: 'POST',\n })\n}\n\nexport function testSecrets() {\n const dataset = client.clientConfig.dataset\n return client.request({\n url: `/addons/mux/secrets/${dataset}/test`,\n withCredentials: true,\n method: 'GET',\n })\n}\n\nexport async function haveValidSigningKeys(signingKeyId, signingKeyPrivate) {\n if (!(signingKeyId && signingKeyPrivate)) {\n return false\n }\n\n const dataset = client.clientConfig.dataset\n try {\n const res = await client.request({\n url: `/addons/mux/signing-keys/${dataset}/${signingKeyId}`,\n withCredentials: true,\n method: 'GET',\n })\n //\n // if this signing key is valid it will return { data: { id: 'xxxx' } }\n //\n return !!(res.data && res.data.id)\n } catch (e) {\n console.error('Error fetching signingKeyId', signingKeyId, 'assuming it is not valid')\n return false\n }\n}\n\nexport function testSecretsObservable() {\n const dataset = client.clientConfig.dataset\n return defer(() =>\n client.observable.request({\n url: `/addons/mux/secrets/${dataset}/test`,\n withCredentials: true,\n method: 'GET',\n })\n )\n}\n"],"file":"secrets.js"}
|
package/build/actions/upload.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/upload.js"],"names":["cancelUpload","uuid","client","observable","request","url","clientConfig","dataset","withCredentials","method","uploadUrl","options","testUrl","pipe","validUrl","type","json","status","Error","enableSignedUrls","muxBody","input","playback_policy","mp4_support","config","query","JSON","stringify","filename","split","slice","headers","result","asset","results","document","id","uploadFile","file","testFile","fileOptions","body","upload","event","updateAssetDocumentFromUpload","doc","err","getUpload","assetId","pollUpload","maxTries","pollInterval","tries","Promise","resolve","reject","setInterval","data","asset_id","clearInterval","_id","_type","playbackId","playback_ids","uploadId","createOrReplace","then","window","File","optionsFromFile","error","parsed","URL","protocol","match","opts","fileOpts","preserveFilename","undefined","name","contentType"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEO,SAASA,YAAT,CAAsBC,IAAtB,EAA4B;AACjC,SAAOC,sBAAOC,UAAP,CAAkBC,OAAlB,CAA0B;AAC/BC,IAAAA,GAAG,gCAAyBH,sBAAOI,YAAP,CAAoBC,OAA7C,cAAwDN,IAAxD,CAD4B;AAE/BO,IAAAA,eAAe,EAAE,IAFc;AAG/BC,IAAAA,MAAM,EAAE;AAHuB,GAA1B,CAAP;AAKD;;AAEM,SAASC,SAAT,CAAmBL,GAAnB,EAAsC;AAAA,MAAdM,OAAc,uEAAJ,EAAI;AAC3C,SAAOC,OAAO,CA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D,GAFD,CAEE,OAAOyC,GAAP,EAAY;AACZ,WAAO,sBAAWwB,KAAX,CAAP;AACD;;AACD,MAAIC,MAAM,IAAI,CAACA,MAAM,CAACE,QAAP,CAAgBC,KAAhB,CAAsB,cAAtB,CAAf,EAAsD;AACpD,WAAO,sBAAWJ,KAAX,CAAP;AACD;;AACD,SAAO,cAAGjE,GAAH,CAAP;AACD;;AAED,SAASgE,eAAT,CAAyBM,IAAzB,EAA+BrC,IAA/B,EAAqC;AACnC,MAAI,OAAO6B,MAAP,KAAkB,WAAlB,IAAiC,EAAE7B,IAAI,YAAY6B,MAAM,CAACC,IAAzB,CAArC,EAAqE;AACnE,WAAOO,IAAP;AACD;;AACD,MAAMC,QAAQ,GAAG;AACfhD,IAAAA,QAAQ,EAAE+C,IAAI,CAACE,gBAAL,KAA0B,KAA1B,GAAkCC,SAAlC,GAA8CxC,IAAI,CAACyC,IAD9C;AAEfC,IAAAA,WAAW,EAAE1C,IAAI,CAACvB;AAFH,GAAjB;AAKA,yCACK;AACDa,IAAAA,QAAQ,EAAE+C,IAAI,CAACE,gBAAL,KAA0B,KAA1B,GAAkCC,SAAlC,GAA8CxC,IAAI,CAACyC,IAD5D;AAEDC,IAAAA,WAAW,EAAE1C,IAAI,CAACvB;AAFjB,GADL;AAKE6D,IAAAA;AALF;AAOD","sourcesContent":["/* eslint-disable camelcase */\r\nimport {uuid as generateUuid} from '@sanity/uuid'\r\nimport config from '../config'\r\nimport {isString} from 'lodash'\r\nimport {concat, defer, from, of, throwError} from 'rxjs'\r\nimport {catchError, mergeMap, mergeMapTo, switchMap} from 'rxjs/operators'\r\nimport {getAsset} from '../actions/assets'\r\nimport {testSecretsObservable} from '../actions/secrets'\r\nimport client from '../clients/SanityClient'\r\nimport {createUpChunkObservable} from '../clients/upChunkObservable'\r\n\r\nexport function cancelUpload(uuid) {\r\n return client.observable.request({\r\n url: `/addons/mux/uploads/${client.clientConfig.dataset}/${uuid}`,\r\n withCredentials: true,\r\n method: 'DELETE',\r\n })\r\n}\r\n\r\nexport function uploadUrl(url, options = {}) {\r\n return testUrl(url).pipe(\r\n switchMap((validUrl) => {\r\n return concat(\r\n of({type: 'url', url: validUrl}),\r\n testSecretsObservable().pipe(\r\n switchMap((json) => {\r\n if (!json || !json.status) {\r\n return throwError(new Error('Invalid credentials'))\r\n }\r\n const uuid = generateUuid()\r\n const {enableSignedUrls} = options\r\n const muxBody = {\r\n input: validUrl,\r\n playback_policy: [enableSignedUrls ? 'signed' : 'public'],\r\n mp4_support: config.mp4_support,\r\n }\r\n const query = {\r\n muxBody: JSON.stringify(muxBody),\r\n filename: validUrl.split('/').slice(-1)[0],\r\n }\r\n\r\n const dataset = client.clientConfig.dataset\r\n return defer(() =>\r\n client.observable.request({\r\n url: `/addons/mux/assets/${dataset}`,\r\n withCredentials: true,\r\n method: 'POST',\r\n headers: {\r\n 'MUX-Proxy-UUID': uuid,\r\n 'Content-Type': 'application/json',\r\n },\r\n query,\r\n })\r\n ).pipe(\r\n mergeMap((result) => {\r\n const asset =\r\n (result && result.results && result.results[0] && result.results[0].document) ||\r\n null\r\n\r\n if (!asset) {\r\n return throwError(new Error('No asset document returned'))\r\n }\r\n return of({type: 'success', id: uuid, asset})\r\n })\r\n )\r\n })\r\n )\r\n )\r\n })\r\n )\r\n}\r\n\r\nexport function uploadFile(file, options = {}) {\r\n return testFile(file).pipe(\r\n switchMap((fileOptions) => {\r\n return concat(\r\n of({type: 'file', file: fileOptions}),\r\n testSecretsObservable().pipe(\r\n switchMap((json) => {\r\n if (!json || !json.status) {\r\n return throwError(new Error('Invalid credentials'))\r\n }\r\n const uuid = generateUuid()\r\n const {enableSignedUrls} = options\r\n const body = {\r\n mp4_support: config.mp4_support,\r\n playback_policy: [enableSignedUrls ? 'signed' : 'public'],\r\n }\r\n\r\n return concat(\r\n of({type: 'uuid', uuid}),\r\n defer(() =>\r\n client.observable.request({\r\n url: `/addons/mux/uploads/${client.clientConfig.dataset}`,\r\n withCredentials: true,\r\n method: 'POST',\r\n headers: {\r\n 'MUX-Proxy-UUID': uuid,\r\n 'Content-Type': 'application/json',\r\n },\r\n body,\r\n })\r\n ).pipe(\r\n mergeMap((result) => {\r\n return createUpChunkObservable(uuid, result.upload.url, file).pipe(\r\n // eslint-disable-next-line max-nested-callbacks\r\n mergeMap((event) => {\r\n if (event.type !== 'success') {\r\n return of(event)\r\n }\r\n return from(updateAssetDocumentFromUpload(uuid)).pipe(\r\n // eslint-disable-next-line max-nested-callbacks\r\n mergeMap((doc) => of({...event, asset: doc}))\r\n )\r\n }),\r\n // eslint-disable-next-line max-nested-callbacks\r\n catchError((err) => {\r\n // Delete asset document\r\n return cancelUpload(uuid).pipe(mergeMapTo(throwError(err)))\r\n })\r\n )\r\n })\r\n )\r\n )\r\n })\r\n )\r\n )\r\n })\r\n )\r\n}\r\n\r\nexport function getUpload(assetId) {\r\n return client.request({\r\n url: `/addons/mux/uploads/${client.clientConfig.dataset}/${assetId}`,\r\n withCredentials: true,\r\n method: 'GET',\r\n })\r\n}\r\n\r\nexport default {uploadUrl, uploadFile, getUpload}\r\n\r\nfunction pollUpload(uuid) {\r\n const maxTries = 10\r\n let pollInterval\r\n let tries = 0\r\n let assetId\r\n let upload\r\n return new Promise((resolve, reject) => {\r\n pollInterval = setInterval(async () => {\r\n try {\r\n upload = await getUpload(uuid)\r\n } catch (err) {\r\n reject(err)\r\n return\r\n }\r\n assetId = upload && upload.data && upload.data.asset_id\r\n if (assetId) {\r\n clearInterval(pollInterval)\r\n resolve(upload)\r\n }\r\n if (tries > maxTries) {\r\n clearInterval(pollInterval)\r\n reject(new Error('Upload did not finish'))\r\n }\r\n tries++\r\n }, 2000)\r\n })\r\n}\r\n\r\nasync function updateAssetDocumentFromUpload(uuid) {\r\n let upload\r\n let asset\r\n try {\r\n upload = await pollUpload(uuid)\r\n } catch (err) {\r\n return Promise.reject(err)\r\n }\r\n try {\r\n asset = await getAsset(upload.data.asset_id)\r\n } catch (err) {\r\n return Promise.reject(err)\r\n }\r\n\r\n const doc = {\r\n _id: uuid,\r\n _type: 'mux.videoAsset',\r\n status: asset.data.status,\r\n data: asset.data,\r\n assetId: asset.data.id,\r\n playbackId: asset.data.playback_ids[0].id,\r\n uploadId: upload.data.id,\r\n }\r\n return client.createOrReplace(doc).then(() => {\r\n return doc\r\n })\r\n}\r\n\r\nfunction testFile(file) {\r\n if (typeof window !== 'undefined' && file instanceof window.File) {\r\n const fileOptions = optionsFromFile(file)\r\n return of(fileOptions)\r\n }\r\n return throwError(new Error('Invalid file'))\r\n}\r\n\r\nfunction testUrl(url) {\r\n const error = new Error('Invalid URL')\r\n if (!isString(url)) {\r\n return throwError(error)\r\n }\r\n let parsed\r\n try {\r\n parsed = new URL(url)\r\n } catch (err) {\r\n return throwError(error)\r\n }\r\n if (parsed && !parsed.protocol.match(/http:|https:/)) {\r\n return throwError(error)\r\n }\r\n return of(url)\r\n}\r\n\r\nfunction optionsFromFile(opts, file) {\r\n if (typeof window === 'undefined' || !(file instanceof window.File)) {\r\n return opts\r\n }\r\n const fileOpts = {\r\n filename: opts.preserveFilename === false ? undefined : file.name,\r\n contentType: file.type,\r\n }\r\n\r\n return {\r\n ...{\r\n filename: opts.preserveFilename === false ? undefined : file.name,\r\n contentType: file.type,\r\n },\r\n fileOpts,\r\n }\r\n}\r\n"],"file":"upload.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/upload.js"],"names":["cancelUpload","uuid","client","observable","request","url","clientConfig","dataset","withCredentials","method","uploadUrl","options","testUrl","pipe","validUrl","type","json","status","Error","enableSignedUrls","muxBody","input","playback_policy","mp4_support","config","query","JSON","stringify","filename","split","slice","headers","result","asset","results","document","id","uploadFile","file","testFile","fileOptions","body","upload","event","updateAssetDocumentFromUpload","doc","err","getUpload","assetId","pollUpload","maxTries","pollInterval","tries","Promise","resolve","reject","setInterval","data","asset_id","clearInterval","_id","_type","playbackId","playback_ids","uploadId","createOrReplace","then","window","File","optionsFromFile","error","parsed","URL","protocol","match","opts","fileOpts","preserveF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1C,IAAI,CAACvB;AAFjB,GADL;AAKE6D,IAAAA;AALF;AAOD","sourcesContent":["/* eslint-disable camelcase */\nimport {uuid as generateUuid} from '@sanity/uuid'\nimport config from '../config'\nimport {isString} from 'lodash'\nimport {concat, defer, from, of, throwError} from 'rxjs'\nimport {catchError, mergeMap, mergeMapTo, switchMap} from 'rxjs/operators'\nimport {getAsset} from '../actions/assets'\nimport {testSecretsObservable} from '../actions/secrets'\nimport client from '../clients/SanityClient'\nimport {createUpChunkObservable} from '../clients/upChunkObservable'\n\nexport function cancelUpload(uuid) {\n return client.observable.request({\n url: `/addons/mux/uploads/${client.clientConfig.dataset}/${uuid}`,\n withCredentials: true,\n method: 'DELETE',\n })\n}\n\nexport function uploadUrl(url, options = {}) {\n return testUrl(url).pipe(\n switchMap((validUrl) => {\n return concat(\n of({type: 'url', url: validUrl}),\n testSecretsObservable().pipe(\n switchMap((json) => {\n if (!json || !json.status) {\n return throwError(new Error('Invalid credentials'))\n }\n const uuid = generateUuid()\n const {enableSignedUrls} = options\n const muxBody = {\n input: validUrl,\n playback_policy: [enableSignedUrls ? 'signed' : 'public'],\n mp4_support: config.mp4_support,\n }\n const query = {\n muxBody: JSON.stringify(muxBody),\n filename: validUrl.split('/').slice(-1)[0],\n }\n\n const dataset = client.clientConfig.dataset\n return defer(() =>\n client.observable.request({\n url: `/addons/mux/assets/${dataset}`,\n withCredentials: true,\n method: 'POST',\n headers: {\n 'MUX-Proxy-UUID': uuid,\n 'Content-Type': 'application/json',\n },\n query,\n })\n ).pipe(\n mergeMap((result) => {\n const asset =\n (result && result.results && result.results[0] && result.results[0].document) ||\n null\n\n if (!asset) {\n return throwError(new Error('No asset document returned'))\n }\n return of({type: 'success', id: uuid, asset})\n })\n )\n })\n )\n )\n })\n )\n}\n\nexport function uploadFile(file, options = {}) {\n return testFile(file).pipe(\n switchMap((fileOptions) => {\n return concat(\n of({type: 'file', file: fileOptions}),\n testSecretsObservable().pipe(\n switchMap((json) => {\n if (!json || !json.status) {\n return throwError(new Error('Invalid credentials'))\n }\n const uuid = generateUuid()\n const {enableSignedUrls} = options\n const body = {\n mp4_support: config.mp4_support,\n playback_policy: [enableSignedUrls ? 'signed' : 'public'],\n }\n\n return concat(\n of({type: 'uuid', uuid}),\n defer(() =>\n client.observable.request({\n url: `/addons/mux/uploads/${client.clientConfig.dataset}`,\n withCredentials: true,\n method: 'POST',\n headers: {\n 'MUX-Proxy-UUID': uuid,\n 'Content-Type': 'application/json',\n },\n body,\n })\n ).pipe(\n mergeMap((result) => {\n return createUpChunkObservable(uuid, result.upload.url, file).pipe(\n // eslint-disable-next-line max-nested-callbacks\n mergeMap((event) => {\n if (event.type !== 'success') {\n return of(event)\n }\n return from(updateAssetDocumentFromUpload(uuid)).pipe(\n // eslint-disable-next-line max-nested-callbacks\n mergeMap((doc) => of({...event, asset: doc}))\n )\n }),\n // eslint-disable-next-line max-nested-callbacks\n catchError((err) => {\n // Delete asset document\n return cancelUpload(uuid).pipe(mergeMapTo(throwError(err)))\n })\n )\n })\n )\n )\n })\n )\n )\n })\n )\n}\n\nexport function getUpload(assetId) {\n return client.request({\n url: `/addons/mux/uploads/${client.clientConfig.dataset}/${assetId}`,\n withCredentials: true,\n method: 'GET',\n })\n}\n\nexport default {uploadUrl, uploadFile, getUpload}\n\nfunction pollUpload(uuid) {\n const maxTries = 10\n let pollInterval\n let tries = 0\n let assetId\n let upload\n return new Promise((resolve, reject) => {\n pollInterval = setInterval(async () => {\n try {\n upload = await getUpload(uuid)\n } catch (err) {\n reject(err)\n return\n }\n assetId = upload && upload.data && upload.data.asset_id\n if (assetId) {\n clearInterval(pollInterval)\n resolve(upload)\n }\n if (tries > maxTries) {\n clearInterval(pollInterval)\n reject(new Error('Upload did not finish'))\n }\n tries++\n }, 2000)\n })\n}\n\nasync function updateAssetDocumentFromUpload(uuid) {\n let upload\n let asset\n try {\n upload = await pollUpload(uuid)\n } catch (err) {\n return Promise.reject(err)\n }\n try {\n asset = await getAsset(upload.data.asset_id)\n } catch (err) {\n return Promise.reject(err)\n }\n\n const doc = {\n _id: uuid,\n _type: 'mux.videoAsset',\n status: asset.data.status,\n data: asset.data,\n assetId: asset.data.id,\n playbackId: asset.data.playback_ids[0].id,\n uploadId: upload.data.id,\n }\n return client.createOrReplace(doc).then(() => {\n return doc\n })\n}\n\nfunction testFile(file) {\n if (typeof window !== 'undefined' && file instanceof window.File) {\n const fileOptions = optionsFromFile(file)\n return of(fileOptions)\n }\n return throwError(new Error('Invalid file'))\n}\n\nfunction testUrl(url) {\n const error = new Error('Invalid URL')\n if (!isString(url)) {\n return throwError(error)\n }\n let parsed\n try {\n parsed = new URL(url)\n } catch (err) {\n return throwError(error)\n }\n if (parsed && !parsed.protocol.match(/http:|https:/)) {\n return throwError(error)\n }\n return of(url)\n}\n\nfunction optionsFromFile(opts, file) {\n if (typeof window === 'undefined' || !(file instanceof window.File)) {\n return opts\n }\n const fileOpts = {\n filename: opts.preserveFilename === false ? undefined : file.name,\n contentType: file.type,\n }\n\n return {\n ...{\n filename: opts.preserveFilename === false ? undefined : file.name,\n contentType: file.type,\n },\n fileOpts,\n }\n}\n"],"file":"upload.js"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/clients/SanityClient.js"],"names":["isContentLakeSupported","sanityClient","withConfig","client","apiVersion"],"mappings":";;;;;;;AAAA;;;;AAEA,IAAMA,sBAAsB,GAAG,OAAOC,gBAAaC,UAApB,KAAmC,UAAlE;AAEO,IAAMC,MAAM,GAAGH,sBAAsB,GACxCC,gBAAaC,UAAb,CAAwB;AAACE,EAAAA,UAAU,EAAE;AAAb,CAAxB,CADwC,GAExCH,eAFG;;eAIQE,M","sourcesContent":["import sanityClient from 'part:@sanity/base/client'\
|
|
1
|
+
{"version":3,"sources":["../../src/clients/SanityClient.js"],"names":["isContentLakeSupported","sanityClient","withConfig","client","apiVersion"],"mappings":";;;;;;;AAAA;;;;AAEA,IAAMA,sBAAsB,GAAG,OAAOC,gBAAaC,UAApB,KAAmC,UAAlE;AAEO,IAAMC,MAAM,GAAGH,sBAAsB,GACxCC,gBAAaC,UAAb,CAAwB;AAACE,EAAAA,UAAU,EAAE;AAAb,CAAxB,CADwC,GAExCH,eAFG;;eAIQE,M","sourcesContent":["import sanityClient from 'part:@sanity/base/client'\n\nconst isContentLakeSupported = typeof sanityClient.withConfig === 'function'\n\nexport const client = isContentLakeSupported\n ? sanityClient.withConfig({apiVersion: '2021-05-17'})\n : sanityClient\n\nexport default client\n"],"file":"SanityClient.js"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/clients/upChunkObservable.js"],"names":["createUpChunkObservable","uuid","uploadUrl","source","Observable","subscriber","upchunk","UpChunk","createUpload","endpoint","file","chunkSize","successHandler","next","type","id","complete","errorHandler","data","error","Error","detail","message","progressHandler","percent","offlineHandler","pause","onlineHandler","resume","on","abort"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEO,SAASA,uBAAT,CAAiCC,IAAjC,EAAuCC,SAAvC,EAAkDC,MAAlD,EAA0D;AAC/D,SAAO,IAAIC,gBAAJ,CAAgBC,UAAD,IAAgB;AACpC,QAAMC,OAAO,GAAGC,OAAO,CAACC,YAAR,CAAqB;AACnCC,MAAAA,QAAQ,EAAEP,SADyB;AAEnCQ,MAAAA,IAAI,EAAEP,MAF6B;AAGnCQ,MAAAA,SAAS,EAAE,IAHwB,CAGlB;;AAHkB,KAArB,CAAhB;;AAMA,QAAMC,cAAc,GAAG,MAAM;AAC3BP,MAAAA,UAAU,CAACQ,IAAX,CAAgB;AACdC,QAAAA,IAAI,EAAE,SADQ;AAEdC,QAAAA,EAAE,EAAEd;AAFU,OAAhB;AAIAI,MAAAA,UAAU,CAACW,QAAX;AACD,KAND;;AAQA,QAAMC,YAAY,GAAIC,IAAD,IAAUb,UAAU,CAACc,KAAX,CAAiB,IAAIC,KAAJ,CAAUF,IAAI,CAACG,MAAL,CAAYC,OAAtB,CAAjB,CAA/B;;AAEA,QAAMC,eAAe,GAAIL,IAAD,IAAU;AAChC,aAAOb,UAAU,CAACQ,IAAX,CAAgB;AAACC,QAAAA,IAAI,EAAE,UAAP;AAAmBU,QAAAA,OAAO,EAAEN,IAAI,CAACG;AAAjC,OAAhB,CAAP;AACD,KAFD;;AAIA,QAAMI,cAAc,GAAIP,IAAD,IAAU;AAC/BZ,MAAAA,OAAO,CAACoB,KAAR;AACArB,MAAAA,UAAU,CAACQ,IAAX,CAAgB;AACdC,QAAAA,IAAI,EAAE,OADQ;AAEdC,QAAAA,EAAE,EAAEd;AAFU,OAAhB;AAID,KAND;;AAQA,QAAM0B,aAAa,GAAIT,IAAD,IAAU;AAC9BZ,MAAAA,OAAO,CAACsB,MAAR;AACAvB,MAAAA,UAAU,CAACQ,IAAX,CAAgB;AACdC,QAAAA,IAAI,EAAE,QADQ;AAEdC,QAAAA,EAAE,EAAEd;AAFU,OAAhB;AAID,KAND;;AAQAK,IAAAA,OAAO,CAACuB,EAAR,CAAW,SAAX,EAAsBjB,cAAtB;AACAN,IAAAA,OAAO,CAACuB,EAAR,CAAW,OAAX,EAAoBZ,YAApB;AACAX,IAAAA,OAAO,CAACuB,EAAR,CAAW,UAAX,EAAuBN,eAAvB;AACAjB,IAAAA,OAAO,CAACuB,EAAR,CAAW,SAAX,EAAsBJ,cAAtB;AACAnB,IAAAA,OAAO,CAACuB,EAAR,CAAW,QAAX,EAAqBF,aAArB;AAEA,WAAO,MAAMrB,OAAO,CAACwB,KAAR,EAAb;AACD,GA5CM,CAAP;AA6CD","sourcesContent":["import * as UpChunk from '@mux/upchunk'\
|
|
1
|
+
{"version":3,"sources":["../../src/clients/upChunkObservable.js"],"names":["createUpChunkObservable","uuid","uploadUrl","source","Observable","subscriber","upchunk","UpChunk","createUpload","endpoint","file","chunkSize","successHandler","next","type","id","complete","errorHandler","data","error","Error","detail","message","progressHandler","percent","offlineHandler","pause","onlineHandler","resume","on","abort"],"mappings":";;;;;;;AAAA;;AACA;;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AAA,OAAO,CAACuB,EAAR,CAAW,SAAX,EAAsBjB,cAAtB;AACAN,IAAAA,OAAO,CAACuB,EAAR,CAAW,OAAX,EAAoBZ,YAApB;AACAX,IAAAA,OAAO,CAACuB,EAAR,CAAW,UAAX,EAAuBN,eAAvB;AACAjB,IAAAA,OAAO,CAACuB,EAAR,CAAW,SAAX,EAAsBJ,cAAtB;AACAnB,IAAAA,OAAO,CAACuB,EAAR,CAAW,QAAX,EAAqBF,aAArB;AAEA,WAAO,MAAMrB,OAAO,CAACwB,KAAR,EAAb;AACD,GA5CM,CAAP;AA6CD","sourcesContent":["import * as UpChunk from '@mux/upchunk'\nimport {Observable} from 'rxjs'\n\nexport function createUpChunkObservable(uuid, uploadUrl, source) {\n return new Observable((subscriber) => {\n const upchunk = UpChunk.createUpload({\n endpoint: uploadUrl,\n file: source,\n chunkSize: 5120, // Uploads the file in ~5mb chunks\n })\n\n const successHandler = () => {\n subscriber.next({\n type: 'success',\n id: uuid,\n })\n subscriber.complete()\n }\n\n const errorHandler = (data) => subscriber.error(new Error(data.detail.message))\n\n const progressHandler = (data) => {\n return subscriber.next({type: 'progress', percent: data.detail})\n }\n\n const offlineHandler = (data) => {\n upchunk.pause()\n subscriber.next({\n type: 'pause',\n id: uuid,\n })\n }\n\n const onlineHandler = (data) => {\n upchunk.resume()\n subscriber.next({\n type: 'resume',\n id: uuid,\n })\n }\n\n upchunk.on('success', successHandler)\n upchunk.on('error', errorHandler)\n upchunk.on('progress', progressHandler)\n upchunk.on('offline', offlineHandler)\n upchunk.on('online', onlineHandler)\n\n return () => upchunk.abort()\n })\n}\n"],"file":"upChunkObservable.js"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/FileInputButton.js"],"names":["HiddenInput","styled","input","Label","label","handleSelect","event","onSelect","target","files","handleButtonClick","inputRef","current","click","FileInputButton","type","props","_inputId","React","useRef","width"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;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FP;AAGE,IAAA,IAAI,EAAC,SAHP;AAIE,IAAA,KAAK,EAAE;AAACS,MAAAA,KAAK,EAAE;AAAR;AAJT,KAKMJ,KALN,EATF,CADF;AAmBD,CAtBM;;;eAwBQF,e","sourcesContent":["import {Button} from '@sanity/ui'\
|
|
1
|
+
{"version":3,"sources":["../../src/components/FileInputButton.js"],"names":["HiddenInput","styled","input","Label","label","handleSelect","event","onSelect","target","files","handleButtonClick","inputRef","current","click","FileInputButton","type","props","_inputId","React","useRef","width"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA,IAAMA,WAAW,GAAGC,0BAAOC,KAAV,qLAAjB;;AASA,IAAMC,KAAK,GAAGF,0BAAOG,KAAV,gGAAX;;AAIA,IAAMC,YAAY,GAAG,QAAuB;AAAA,MAArBC,KAAqB,QAArBA,KAAqB;AAAA,MAAdC,QAAc,QAAdA,QAAc;;AAC1C,MAAIA,QAAJ,EAAc;AACZA,IAAAA,QAAQ,CAACD,KAAK,CAACE,MAAN,CAAaC,KAAd,CAAR;AACD;AACF,CAJD;;AAMA,IAAMC,iBAAiB,GAAIC,QAAD,IAAc;AACtC,MAAIA,QAAQ,IAAIA,QAAQ,CAACC,OAAzB,EAAkC;AAChCD,IAAAA,QAAQ,CAACC,OAAT,CAAiBC,KAAjB;AACD;AACF,CAJD;;AAMO,IAAMC,eAAe,GAAG,SAAyC;AAAA,MAAvCP,QAAuC,SAAvCA,QAAuC;AAAA,yBAA7BQ,IAA6B;AAAA,MAA7BA,IAA6B,2BAAtB,MAAsB;AAAA,MAAXC,KAAW;;AACtE,MAAMC,QAAQ,GAAGC,eAAMC,MAAN,CAAa,sBAAS,YAAT,CAAb,CAAjB;;AACA,MAAMR,QAAQ,GAAGO,eAAMC,MAAN,CAAa,IAAb,CAAjB;;AACA,sBACE,6BAAC,KAAD;AAAO,IAAA,OAAO,EAAEF,QAAQ,CAACL;AAAzB,kBACE,6BAAC,WAAD;AACE,IAAA,GAAG,EAAED,QADP;AAEE,IAAA,QAAQ,EAAC,GAFX;AAGE,IAAA,IAAI,EAAEI,IAHR;AAIE,IAAA,EAAE,EAAEE,QAAQ,CAACL,OAJf;AAKE,IAAA,QAAQ,EAAGN,KAAD,IAAWD,YAAY,CAAC;AAACC,MAAAA,KAAD;AAAQC,MAAAA;AAAR,KAAD,CALnC;AAME,IAAA,KAAK,EAAC;AANR,IADF,eASE,6BAAC,UAAD;AACE,IAAA,OAAO,EAAE,MAAMG,iBAAiB,CAACC,QAAD,CADlC;AAEE,IAAA,IAAI,EAAC,SAFP;AAGE,IAAA,IAAI,EAAC,SAHP;AAIE,IAAA,KAAK,EAAE;AAACS,MAAAA,KAAK,EAAE;AAAR;AAJT,KAKMJ,KALN,EATF,CADF;AAmBD,CAtBM;;;eAwBQF,e","sourcesContent":["import {Button} from '@sanity/ui'\nimport {uniqueId} from 'lodash'\nimport React from 'react'\nimport styled from 'styled-components'\n\nconst HiddenInput = styled.input`\n overflow: hidden;\n width: 0.1px;\n height: 0.1px;\n opacity: 0;\n position: absolute;\n z-index: -1;\n`\n\nconst Label = styled.label`\n position: relative;\n`\n\nconst handleSelect = ({event, onSelect}) => {\n if (onSelect) {\n onSelect(event.target.files)\n }\n}\n\nconst handleButtonClick = (inputRef) => {\n if (inputRef && inputRef.current) {\n inputRef.current.click()\n }\n}\n\nexport const FileInputButton = ({onSelect, type = 'file', ...props}) => {\n const _inputId = React.useRef(uniqueId('FileSelect'))\n const inputRef = React.useRef(null)\n return (\n <Label htmlFor={_inputId.current}>\n <HiddenInput\n ref={inputRef}\n tabindex=\"0\"\n type={type}\n id={_inputId.current}\n onChange={(event) => handleSelect({event, onSelect})}\n value=\"\"\n />\n <Button\n onClick={() => handleButtonClick(inputRef)}\n mode=\"default\"\n tone=\"primary\"\n style={{width: '100%'}}\n {...props}\n />\n </Label>\n )\n}\n\nexport default FileInputButton\n"],"file":"FileInputButton.js"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
@import 'part:@sanity/base/theme/variables-style';
|
|
2
|
-
|
|
3
|
-
.formField {
|
|
4
|
-
display: inline-block;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.setupButtonContainer {
|
|
8
|
-
position: relative;
|
|
9
|
-
display: block;
|
|
10
|
-
font-size: 0.8em;
|
|
11
|
-
transform: translate(0%, -10%);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.cancelRemoveVideoButton {
|
|
15
|
-
display: inline-block;
|
|
16
|
-
position: relative;
|
|
17
|
-
left: var(--small-padding);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.confirmDeletePopoverButtons {
|
|
21
|
-
margin-bottom: var(--medium-padding);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.thumbPreview {
|
|
25
|
-
border: 1px solid var(--gray);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.deleteCheckboxRow:not(:last-child) {
|
|
29
|
-
margin-bottom: 0.5rem;
|
|
30
|
-
}
|
|
1
|
+
@import 'part:@sanity/base/theme/variables-style';
|
|
2
|
+
|
|
3
|
+
.formField {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.setupButtonContainer {
|
|
8
|
+
position: relative;
|
|
9
|
+
display: block;
|
|
10
|
+
font-size: 0.8em;
|
|
11
|
+
transform: translate(0%, -10%);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.cancelRemoveVideoButton {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
position: relative;
|
|
17
|
+
left: var(--small-padding);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.confirmDeletePopoverButtons {
|
|
21
|
+
margin-bottom: var(--medium-padding);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.thumbPreview {
|
|
25
|
+
border: 1px solid var(--gray);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.deleteCheckboxRow:not(:last-child) {
|
|
29
|
+
margin-bottom: 0.5rem;
|
|
30
|
+
}
|
|
File without changes
|