@payloadcms/plugin-cloud-storage 1.0.13 → 1.0.15

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 (210) hide show
  1. package/.editorconfig +10 -0
  2. package/.eslintrc.js +14 -14
  3. package/.gitignore +248 -0
  4. package/.idea/.gitignore +5 -0
  5. package/.idea/httpRequests/2023-04-07T152957.206.png +0 -0
  6. package/.idea/httpRequests/2023-04-07T153025.403.html +10 -0
  7. package/.idea/httpRequests/2023-04-07T153146.200.png +0 -0
  8. package/.idea/httpRequests/http-client.cookies +1 -0
  9. package/.idea/httpRequests/http-requests-log.http +74 -0
  10. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  11. package/.idea/jsLinters/eslint.xml +6 -0
  12. package/.idea/modules.xml +8 -0
  13. package/.idea/plugin-cloud-storage.iml +12 -0
  14. package/.idea/vcs.xml +6 -0
  15. package/.idea/workspace.xml +269 -0
  16. package/.prettierignore +1 -0
  17. package/.prettierrc.js +8 -0
  18. package/.vscode/launch.json +28 -0
  19. package/.vscode/settings.json +9 -0
  20. package/LICENSE.md +22 -22
  21. package/README.md +178 -174
  22. package/azure.d.ts +1 -1
  23. package/azure.js +1 -1
  24. package/dev/.env +25 -0
  25. package/dev/.env.example +21 -0
  26. package/dev/build/127.d2c2ffcfff69fabfdd1b.js +1 -0
  27. package/dev/build/16.17dbe03b1d0a96f3e564.js +2 -0
  28. package/dev/build/16.17dbe03b1d0a96f3e564.js.LICENSE.txt +8 -0
  29. package/dev/build/171.bbcbae3ea90468ad0cad.js +2 -0
  30. package/dev/build/171.bbcbae3ea90468ad0cad.js.LICENSE.txt +8 -0
  31. package/dev/build/18.e50c27edff6716f930d9.js +1 -0
  32. package/dev/build/205.33c7a29683ba98de93e0.js +1 -0
  33. package/dev/build/2211c49456cd07331ea9.woff +0 -0
  34. package/dev/build/234.79395f82c18207c13766.js +1 -0
  35. package/dev/build/266.9d4a240b3e0985bd7dd5.js +1 -0
  36. package/dev/build/296.4c5d646257b42c915834.js +1 -0
  37. package/dev/build/304.40dbe690de322c8f7c0d.js +2 -0
  38. package/dev/build/304.40dbe690de322c8f7c0d.js.LICENSE.txt +37 -0
  39. package/dev/build/349.446c12bffd3905085fdb.js +1 -0
  40. package/dev/build/354.5acd04b85b96a9839125.js +1 -0
  41. package/dev/build/40ad7515b8674bb854a1.woff2 +0 -0
  42. package/dev/build/422.086542466cdc9f6a2437.js +2 -0
  43. package/dev/build/422.086542466cdc9f6a2437.js.LICENSE.txt +6 -0
  44. package/dev/build/491.0bfe1bb0ecfe383179aa.js +1 -0
  45. package/dev/build/4d8845b830f4e8e2affb.png +0 -0
  46. package/dev/build/51922ceb71da289688d3.woff2 +0 -0
  47. package/dev/build/522443364fda49e9e0ed.woff2 +0 -0
  48. package/dev/build/531.1c6f53f3b44a3c45b444.js +2 -0
  49. package/dev/build/531.1c6f53f3b44a3c45b444.js.LICENSE.txt +6 -0
  50. package/dev/build/570.f2d9b99706765fbf0225.js +1 -0
  51. package/dev/build/599.570a04990d5806004f61.js +1 -0
  52. package/dev/build/5b718d9772de251a8c0a.woff2 +0 -0
  53. package/dev/build/778.41ae26bcd617861ad586.js +1 -0
  54. package/dev/build/783.0117995f2ff6036d6746.js +1 -0
  55. package/dev/build/787999a6af6a17efbc7c.woff +0 -0
  56. package/dev/build/78b8935fb481e11c92ce.woff +0 -0
  57. package/dev/build/860.7688681d3269f3f16e9a.js +1 -0
  58. package/dev/build/892.1a4ca5ac67d81038ceec.js +1 -0
  59. package/dev/build/896.d8cb1160388dc29d6364.js +1 -0
  60. package/dev/build/8b4ddd0d08500553efde.woff +0 -0
  61. package/dev/build/8f612153248094525d9d.woff +0 -0
  62. package/dev/build/995.cc11e738ff81a85821b4.js +1 -0
  63. package/dev/build/9c7dfd0036f7bd24b053.woff2 +0 -0
  64. package/dev/build/a1cfdc5b5250b7c4b481.woff2 +0 -0
  65. package/dev/build/d7aeda9e48ce098e7b48.woff +0 -0
  66. package/dev/build/e009f21405b4d7e89367.woff2 +0 -0
  67. package/dev/build/e7caa9e17af6ac87d182.woff +0 -0
  68. package/dev/build/ebcc1430049fddb274f8.svg +15 -0
  69. package/dev/build/efe8f6a3b46446cc9135.woff +0 -0
  70. package/dev/build/f53bb8d4b29adc903703.woff2 +0 -0
  71. package/dev/build/index.html +1 -0
  72. package/dev/build/main.a2003d502fbb9aaa3e8d.js +2 -0
  73. package/dev/build/main.a2003d502fbb9aaa3e8d.js.LICENSE.txt +57 -0
  74. package/dev/build/styles.css +1 -0
  75. package/dev/build/styles.fa29d16b0baf5b98a1cf.js +1 -0
  76. package/dev/nodemon.json +8 -0
  77. package/dev/package.json +32 -0
  78. package/dev/src/collections/Media.ts +56 -0
  79. package/dev/src/collections/Users.ts +23 -0
  80. package/dev/src/mocks/fsMock.js +1 -0
  81. package/dev/src/mocks/promisifyMock.js +1 -0
  82. package/dev/src/payload.config.ts +111 -0
  83. package/dev/src/server.ts +26 -0
  84. package/dev/tsconfig.json +20 -0
  85. package/dist/adapters/azure/fileStub.d.ts +2 -0
  86. package/dist/adapters/azure/fileStub.js +4 -0
  87. package/dist/adapters/azure/fileStub.js.map +1 -0
  88. package/dist/adapters/azure/generateURL.d.ts +7 -7
  89. package/dist/adapters/azure/generateURL.js +15 -15
  90. package/dist/adapters/azure/handleDelete.d.ts +9 -9
  91. package/dist/adapters/azure/handleDelete.js +63 -63
  92. package/dist/adapters/azure/handleUpload.d.ts +10 -10
  93. package/dist/adapters/azure/handleUpload.js +80 -65
  94. package/dist/adapters/azure/handleUpload.js.map +1 -1
  95. package/dist/adapters/azure/index.d.ts +8 -8
  96. package/dist/adapters/azure/index.js +42 -42
  97. package/dist/adapters/azure/mock.d.ts +13 -7
  98. package/dist/adapters/azure/mock.js +12 -8
  99. package/dist/adapters/azure/mock.js.map +1 -1
  100. package/dist/adapters/azure/staticHandler.d.ts +9 -9
  101. package/dist/adapters/azure/staticHandler.js +81 -77
  102. package/dist/adapters/azure/staticHandler.js.map +1 -1
  103. package/dist/adapters/azure/webpack.d.ts +2 -2
  104. package/dist/adapters/azure/webpack.js +24 -24
  105. package/dist/adapters/azure/webpack.js.map +1 -1
  106. package/dist/adapters/gcs/generateURL.d.ts +8 -8
  107. package/dist/adapters/gcs/generateURL.js +15 -15
  108. package/dist/adapters/gcs/handleDelete.d.ts +8 -8
  109. package/dist/adapters/gcs/handleDelete.js +62 -62
  110. package/dist/adapters/gcs/handleUpload.d.ts +12 -12
  111. package/dist/adapters/gcs/handleUpload.js +72 -72
  112. package/dist/adapters/gcs/index.d.ts +8 -8
  113. package/dist/adapters/gcs/index.js +35 -35
  114. package/dist/adapters/gcs/mock.d.ts +1 -1
  115. package/dist/adapters/gcs/mock.js +4 -4
  116. package/dist/adapters/gcs/staticHandler.d.ts +10 -10
  117. package/dist/adapters/gcs/staticHandler.js +76 -76
  118. package/dist/adapters/gcs/webpack.d.ts +2 -2
  119. package/dist/adapters/gcs/webpack.js +24 -24
  120. package/dist/adapters/s3/fileStub.d.ts +2 -0
  121. package/dist/adapters/s3/fileStub.js +4 -0
  122. package/dist/adapters/s3/fileStub.js.map +1 -0
  123. package/dist/adapters/s3/generateURL.d.ts +8 -8
  124. package/dist/adapters/s3/generateURL.js +15 -15
  125. package/dist/adapters/s3/handleDelete.d.ts +8 -8
  126. package/dist/adapters/s3/handleDelete.js +63 -63
  127. package/dist/adapters/s3/handleUpload.d.ts +12 -12
  128. package/dist/adapters/s3/handleUpload.js +93 -93
  129. package/dist/adapters/s3/index.d.ts +8 -8
  130. package/dist/adapters/s3/index.js +59 -59
  131. package/dist/adapters/s3/mock.d.ts +8 -8
  132. package/dist/adapters/s3/mock.js +9 -9
  133. package/dist/adapters/s3/staticHandler.d.ts +10 -10
  134. package/dist/adapters/s3/staticHandler.js +80 -80
  135. package/dist/adapters/s3/webpack.d.ts +2 -2
  136. package/dist/adapters/s3/webpack.js +24 -24
  137. package/dist/adapters/s3/webpack.js.map +1 -1
  138. package/dist/fields/getFields.d.ts +11 -11
  139. package/dist/fields/getFields.js +118 -118
  140. package/dist/hooks/afterDelete.d.ts +10 -10
  141. package/dist/hooks/afterDelete.js +88 -88
  142. package/dist/hooks/afterRead.d.ts +12 -12
  143. package/dist/hooks/afterRead.js +79 -79
  144. package/dist/hooks/beforeChange.d.ts +10 -10
  145. package/dist/hooks/beforeChange.js +77 -77
  146. package/dist/index.d.ts +1 -1
  147. package/dist/index.js +5 -5
  148. package/dist/plugin.d.ts +3 -3
  149. package/dist/plugin.js +124 -124
  150. package/dist/types.d.ts +62 -62
  151. package/dist/types.js +2 -2
  152. package/dist/utilities/getFilePrefix.d.ts +5 -5
  153. package/dist/utilities/getFilePrefix.js +80 -80
  154. package/dist/utilities/getIncomingFiles.d.ts +7 -7
  155. package/dist/utilities/getIncomingFiles.js +37 -37
  156. package/dist/utilities/getRangeFromHeader.d.ts +6 -0
  157. package/dist/utilities/getRangeFromHeader.js +67 -0
  158. package/dist/utilities/getRangeFromHeader.js.map +1 -0
  159. package/dist/webpack.d.ts +9 -9
  160. package/dist/webpack.js +39 -39
  161. package/docs/local-dev.md +47 -0
  162. package/eslint-config/index.js +15 -0
  163. package/eslint-config/rules/import.js +38 -0
  164. package/eslint-config/rules/prettier.js +7 -0
  165. package/eslint-config/rules/style.js +21 -0
  166. package/eslint-config/rules/typescript.js +628 -0
  167. package/gcs.d.ts +1 -1
  168. package/gcs.js +1 -1
  169. package/package.json +67 -64
  170. package/s3.d.ts +1 -1
  171. package/s3.js +1 -1
  172. package/src/adapters/azure/emulator/docker-compose.yml +16 -0
  173. package/src/adapters/azure/fileStub.js +1 -0
  174. package/src/adapters/azure/generateURL.ts +13 -0
  175. package/src/adapters/azure/handleDelete.ts +16 -0
  176. package/src/adapters/azure/handleUpload.ts +41 -0
  177. package/src/adapters/azure/index.ts +47 -0
  178. package/src/adapters/azure/mock.js +13 -0
  179. package/src/adapters/azure/staticHandler.ts +38 -0
  180. package/src/adapters/azure/webpack.ts +20 -0
  181. package/src/adapters/gcs/emulator/docker-compose.yml +15 -0
  182. package/src/adapters/gcs/generateURL.ts +16 -0
  183. package/src/adapters/gcs/handleDelete.ts +16 -0
  184. package/src/adapters/gcs/handleUpload.ts +34 -0
  185. package/src/adapters/gcs/index.ts +37 -0
  186. package/src/adapters/gcs/mock.js +3 -0
  187. package/src/adapters/gcs/staticHandler.ts +34 -0
  188. package/src/adapters/gcs/webpack.ts +17 -0
  189. package/src/adapters/s3/emulator/docker-compose.yml +15 -0
  190. package/src/adapters/s3/fileStub.js +1 -0
  191. package/src/adapters/s3/generateURL.ts +14 -0
  192. package/src/adapters/s3/handleDelete.ts +17 -0
  193. package/src/adapters/s3/handleUpload.ts +62 -0
  194. package/src/adapters/s3/index.ts +38 -0
  195. package/src/adapters/s3/mock.js +9 -0
  196. package/src/adapters/s3/staticHandler.ts +40 -0
  197. package/src/adapters/s3/webpack.ts +19 -0
  198. package/src/fields/getFields.ts +155 -0
  199. package/src/hooks/afterDelete.ts +35 -0
  200. package/src/hooks/afterRead.ts +38 -0
  201. package/src/hooks/beforeChange.ts +30 -0
  202. package/src/index.ts +1 -0
  203. package/src/plugin.ts +94 -0
  204. package/src/types.ts +73 -0
  205. package/src/utilities/getFilePrefix.ts +26 -0
  206. package/src/utilities/getIncomingFiles.ts +44 -0
  207. package/src/utilities/getRangeFromHeader.ts +27 -0
  208. package/src/webpack.ts +46 -0
  209. package/tsconfig.json +23 -0
  210. package/yarn.lock +8155 -0
package/README.md CHANGED
@@ -1,174 +1,178 @@
1
- # Payload Cloud Storage Plugin
2
-
3
- This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store all uploaded media in third-party permanent storage.
4
-
5
- #### Requirements
6
-
7
- - Payload version `1.0.19` or higher is required
8
-
9
- ## Installation
10
-
11
- `yarn add @payloadcms/plugin-cloud-storage` or `npm install @payloadcms/plugin-cloud-storage`
12
-
13
- ## Usage
14
-
15
- Install this plugin within your Payload as follows:
16
-
17
- ```ts
18
- import { buildConfig } from 'payload/config';
19
- import path from 'path';
20
- import { cloudStorage } from '@payloadcms/plugin-cloud-storage';
21
-
22
- export default buildConfig({
23
- plugins: [
24
- cloudStorage({
25
- collections: {
26
- 'my-collection-slug': {
27
- adapter: theAdapterToUse, // see docs for the adapter you want to use
28
- },
29
- },
30
- }),
31
- ],
32
- // The rest of your config goes here
33
- });
34
- ```
35
-
36
- ## Features
37
-
38
- **Adapter-based Implementation**
39
-
40
- This plugin supports the following adapters:
41
-
42
- - [Azure Blob Storage](#azure-blob-storage-adapter)
43
- - [AWS S3-style Storage](#s3-adapter)
44
- - [Google Cloud Storage](#gcs-adapter)
45
-
46
- However, you can create your own adapter for any third-party service you would like to use.
47
-
48
- All adapters are implemented `dev` directory's [Payload Config](https://github.com/payloadcms/plugin-cloud-storage/blob/master/dev/src/payload.config.ts). See this file for examples.
49
-
50
- ## Plugin options
51
-
52
- This plugin is configurable to work across many different Payload collections. A `*` denotes that the property is required.
53
-
54
- | Option | Type | Description |
55
- |-------------------------|-----------------------------------------| ----------- |
56
- | `collections` * | Record<string, [CollectionOptions](https://github.com/payloadcms/plugin-cloud-storage/blob/c4a492a62abc2f21b4cd6a7c97778acd8e831212/src/types.ts#L48)> | Object with keys set to the slug of collections you want to enable the plugin for, and values set to collection-specific options. |
57
-
58
- **Collection-specific options:**
59
-
60
- | Option | Type | Description |
61
- |-------------------------------|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
62
- | `adapter` * | [Adapter](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L51) | Pass in the adapter that you'd like to use for this collection. You can also set this field to `null` for local development if you'd like to bypass cloud storage in certain scenarios and use local storage. |
63
- | `disableLocalStorage` | `boolean` | Choose to disable local storage on this collection. Defaults to `true`. |
64
- | `disablePayloadAccessControl` | `true` | Set to `true` to disable Payload's access control. [More](#payload-access-control) |
65
- | `prefix` | `string` | Set to `media/images` to upload files inside `media/images` folder in the bucket. |
66
- | `generateFileURL` | [GenerateFileURL](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L53) | Override the generated file URL with one that you create. |
67
-
68
- ### Azure Blob Storage Adapter
69
-
70
- To use the Azure Blob Storage adapter, you need to have `@azure/storage-blob` installed in your project dependencies. To do so, run `yarn add @azure/storage-blob`.
71
-
72
- From there, create the adapter, passing in all of its required properties:
73
-
74
- ```js
75
- import { azureBlobStorageAdapter } from '@payloadcms/plugin-cloud-storage/azure';
76
-
77
- const adapter = azureBlobStorageAdapter({
78
- connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
79
- containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
80
- allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
81
- baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
82
- })
83
-
84
- // Now you can pass this adapter to the plugin
85
- ```
86
-
87
- ### S3 Adapter
88
-
89
- To use the S3 adapter, some peer dependencies need to be installed:
90
-
91
- `yarn add @aws-sdk/client-s3 @aws-sdk/lib-storage`.
92
-
93
- From there, create the adapter, passing in all of its required properties:
94
-
95
- ```js
96
- import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';
97
-
98
- const adapter = s3Adapter({
99
- config: {
100
- credentials: {
101
- accessKeyId: process.env.S3_ACCESS_KEY_ID,
102
- secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
103
- }
104
- // ... Other S3 configuration
105
- },
106
- bucket: process.env.S3_BUCKET,
107
- })
108
-
109
- // Now you can pass this adapter to the plugin
110
- ```
111
-
112
- Other S3 Client configuration is documented [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html).
113
-
114
- Any upload over 50MB will automatically be uploaded using S3's multi-part upload.
115
-
116
- #### Other S3-Compatible Storage
117
-
118
- If you're running an S3-compatible object storage such as MinIO or Digital Ocean Spaces, you'll have to set the `endpoint` appropriately for the provider.
119
-
120
- ```js
121
- import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';
122
-
123
- const adapter = s3Adapter({
124
- config: {
125
- endpoint: process.env.S3_ENDPOINT, // Configure for your provider
126
- // ...
127
- },
128
- // ...
129
- })
130
- ```
131
-
132
- ### GCS Adapter
133
-
134
- To use the GCS adapter, you need to have `@google-cloud/storage` installed in your project dependencies. To do so, run `yarn add @google-cloud/storage`.
135
-
136
- From there, create the adapter, passing in all of its required properties:
137
-
138
- ```js
139
- import { gcsAdapter } from '@payloadcms/plugin-cloud-storage/gcs';
140
-
141
- const adapter = gcsAdapter({
142
- options: {
143
- // you can choose any method for authentication, and authorization which is being provided by `@google-cloud/storage`
144
- keyFilename: './gcs-credentials.json',
145
- //OR
146
- credentials: JSON.parse(process.env.GCS_CREDENTIALS) // this env variable will have stringify version of your credentials.json file
147
- },
148
- bucket: process.env.GCS_BUCKET,
149
- })
150
-
151
- // Now you can pass this adapter to the plugin
152
- ```
153
-
154
- ### Payload Access Control
155
-
156
- Payload ships with access control that runs _even on statically served files_. The same `read` access control property on your `upload`-enabled collections is used, and it allows you to restrict who can request your uploaded files.
157
-
158
- To preserve this feature, by default, this plugin _keeps all file URLs exactly the same_. Your file URLs won't be updated to point directly to your cloud storage source, as in that case, Payload's access control will be completely bypassed and you would need public readability on your cloud-hosted files.
159
-
160
- Instead, all uploads will still be reached from the default `/collectionSlug/staticURL/filename` path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing access control in place.
161
-
162
- If this does not apply to you (your upload collection has `read: () => true` or similar) you can disable this functionality by setting `disablePayloadAccessControl` to `true`. When this setting is in place, this plugin will update your file URLs to point directly to your cloud host.
163
-
164
- ## Local development
165
-
166
- For instructions regarding how to develop with this plugin locally, [click here](https://github.com/payloadcms/plugin-cloud-storage/blob/master/docs/local-dev.md).
167
-
168
- ## Questions
169
-
170
- Please contact [Payload](dev@payloadcms.com) with any questions about using this plugin.
171
-
172
- ## Credit
173
-
174
- This plugin was created with significant help, and code, from [Alex Bechmann](https://github.com/alexbechmann) and [Richard VanBergen](https://github.com/richardvanbergen). Thank you!!
1
+ # Payload Cloud Storage Plugin
2
+
3
+ This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store all uploaded media in third-party permanent storage.
4
+
5
+ #### Requirements
6
+
7
+ - Payload version `1.0.19` or higher is required
8
+
9
+ ## Installation
10
+
11
+ `yarn add @payloadcms/plugin-cloud-storage` or `npm install @payloadcms/plugin-cloud-storage`
12
+
13
+ ## Usage
14
+
15
+ Add this package into your dependencies executing this code in your command line:
16
+
17
+ `yarn add @payloadcms/plugin-cloud-storage`
18
+
19
+ Now install this plugin within your Payload as follows:
20
+
21
+ ```ts
22
+ import { buildConfig } from 'payload/config';
23
+ import path from 'path';
24
+ import { cloudStorage } from '@payloadcms/plugin-cloud-storage';
25
+
26
+ export default buildConfig({
27
+ plugins: [
28
+ cloudStorage({
29
+ collections: {
30
+ 'my-collection-slug': {
31
+ adapter: theAdapterToUse, // see docs for the adapter you want to use
32
+ },
33
+ },
34
+ }),
35
+ ],
36
+ // The rest of your config goes here
37
+ });
38
+ ```
39
+
40
+ ## Features
41
+
42
+ **Adapter-based Implementation**
43
+
44
+ This plugin supports the following adapters:
45
+
46
+ - [Azure Blob Storage](#azure-blob-storage-adapter)
47
+ - [AWS S3-style Storage](#s3-adapter)
48
+ - [Google Cloud Storage](#gcs-adapter)
49
+
50
+ However, you can create your own adapter for any third-party service you would like to use.
51
+
52
+ All adapters are implemented `dev` directory's [Payload Config](https://github.com/payloadcms/plugin-cloud-storage/blob/master/dev/src/payload.config.ts). See this file for examples.
53
+
54
+ ## Plugin options
55
+
56
+ This plugin is configurable to work across many different Payload collections. A `*` denotes that the property is required.
57
+
58
+ | Option | Type | Description |
59
+ |-------------------------|-----------------------------------------| ----------- |
60
+ | `collections` * | Record<string, [CollectionOptions](https://github.com/payloadcms/plugin-cloud-storage/blob/c4a492a62abc2f21b4cd6a7c97778acd8e831212/src/types.ts#L48)> | Object with keys set to the slug of collections you want to enable the plugin for, and values set to collection-specific options. |
61
+
62
+ **Collection-specific options:**
63
+
64
+ | Option | Type | Description |
65
+ |-------------------------------|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
66
+ | `adapter` * | [Adapter](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L51) | Pass in the adapter that you'd like to use for this collection. You can also set this field to `null` for local development if you'd like to bypass cloud storage in certain scenarios and use local storage. |
67
+ | `disableLocalStorage` | `boolean` | Choose to disable local storage on this collection. Defaults to `true`. |
68
+ | `disablePayloadAccessControl` | `true` | Set to `true` to disable Payload's access control. [More](#payload-access-control) |
69
+ | `prefix` | `string` | Set to `media/images` to upload files inside `media/images` folder in the bucket. |
70
+ | `generateFileURL` | [GenerateFileURL](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L53) | Override the generated file URL with one that you create. |
71
+
72
+ ### Azure Blob Storage Adapter
73
+
74
+ To use the Azure Blob Storage adapter, you need to have `@azure/storage-blob` installed in your project dependencies. To do so, run `yarn add @azure/storage-blob`.
75
+
76
+ From there, create the adapter, passing in all of its required properties:
77
+
78
+ ```js
79
+ import { azureBlobStorageAdapter } from '@payloadcms/plugin-cloud-storage/azure';
80
+
81
+ const adapter = azureBlobStorageAdapter({
82
+ connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
83
+ containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
84
+ allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
85
+ baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
86
+ })
87
+
88
+ // Now you can pass this adapter to the plugin
89
+ ```
90
+
91
+ ### S3 Adapter
92
+
93
+ To use the S3 adapter, some peer dependencies need to be installed:
94
+
95
+ `yarn add @aws-sdk/client-s3 @aws-sdk/lib-storage`.
96
+
97
+ From there, create the adapter, passing in all of its required properties:
98
+
99
+ ```js
100
+ import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';
101
+
102
+ const adapter = s3Adapter({
103
+ config: {
104
+ credentials: {
105
+ accessKeyId: process.env.S3_ACCESS_KEY_ID,
106
+ secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
107
+ }
108
+ // ... Other S3 configuration
109
+ },
110
+ bucket: process.env.S3_BUCKET,
111
+ })
112
+
113
+ // Now you can pass this adapter to the plugin
114
+ ```
115
+
116
+ Other S3 Client configuration is documented [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html).
117
+
118
+ Any upload over 50MB will automatically be uploaded using S3's multi-part upload.
119
+
120
+ #### Other S3-Compatible Storage
121
+
122
+ If you're running an S3-compatible object storage such as MinIO or Digital Ocean Spaces, you'll have to set the `endpoint` appropriately for the provider.
123
+
124
+ ```js
125
+ import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';
126
+
127
+ const adapter = s3Adapter({
128
+ config: {
129
+ endpoint: process.env.S3_ENDPOINT, // Configure for your provider
130
+ // ...
131
+ },
132
+ // ...
133
+ })
134
+ ```
135
+
136
+ ### GCS Adapter
137
+
138
+ To use the GCS adapter, you need to have `@google-cloud/storage` installed in your project dependencies. To do so, run `yarn add @google-cloud/storage`.
139
+
140
+ From there, create the adapter, passing in all of its required properties:
141
+
142
+ ```js
143
+ import { gcsAdapter } from '@payloadcms/plugin-cloud-storage/gcs';
144
+
145
+ const adapter = gcsAdapter({
146
+ options: {
147
+ // you can choose any method for authentication, and authorization which is being provided by `@google-cloud/storage`
148
+ keyFilename: './gcs-credentials.json',
149
+ //OR
150
+ credentials: JSON.parse(process.env.GCS_CREDENTIALS) // this env variable will have stringify version of your credentials.json file
151
+ },
152
+ bucket: process.env.GCS_BUCKET,
153
+ })
154
+
155
+ // Now you can pass this adapter to the plugin
156
+ ```
157
+
158
+ ### Payload Access Control
159
+
160
+ Payload ships with access control that runs _even on statically served files_. The same `read` access control property on your `upload`-enabled collections is used, and it allows you to restrict who can request your uploaded files.
161
+
162
+ To preserve this feature, by default, this plugin _keeps all file URLs exactly the same_. Your file URLs won't be updated to point directly to your cloud storage source, as in that case, Payload's access control will be completely bypassed and you would need public readability on your cloud-hosted files.
163
+
164
+ Instead, all uploads will still be reached from the default `/collectionSlug/staticURL/filename` path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing access control in place.
165
+
166
+ If this does not apply to you (your upload collection has `read: () => true` or similar) you can disable this functionality by setting `disablePayloadAccessControl` to `true`. When this setting is in place, this plugin will update your file URLs to point directly to your cloud host.
167
+
168
+ ## Local development
169
+
170
+ For instructions regarding how to develop with this plugin locally, [click here](https://github.com/payloadcms/plugin-cloud-storage/blob/master/docs/local-dev.md).
171
+
172
+ ## Questions
173
+
174
+ Please contact [Payload](dev@payloadcms.com) with any questions about using this plugin.
175
+
176
+ ## Credit
177
+
178
+ This plugin was created with significant help, and code, from [Alex Bechmann](https://github.com/alexbechmann) and [Richard VanBergen](https://github.com/richardvanbergen). Thank you!!
package/azure.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './dist/adapters/azure'
1
+ export * from './dist/adapters/azure'
package/azure.js CHANGED
@@ -1 +1 @@
1
- exports.azureBlobStorageAdapter = require('./dist/adapters/azure').azureBlobStorageAdapter
1
+ exports.azureBlobStorageAdapter = require('./dist/adapters/azure').azureBlobStorageAdapter
package/dev/.env ADDED
@@ -0,0 +1,25 @@
1
+ MONGODB_URI=mongodb://127.0.0.1/payload-plugin-cloud-storage
2
+ PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000
3
+ PAYLOAD_SECRET=45ligj345ligj4wl5igj4lw5igj45ligj45wlijl
4
+ PAYLOAD_CONFIG_PATH=src/payload.config.ts
5
+
6
+ AZURE_STORAGE_CONNECTION_STRING=BlobEndpoint=https://testpayloadplugin999.blob.core.windows.net/;QueueEndpoint=https://testpayloadplugin999.queue.core.windows.net/;FileEndpoint=https://testpayloadplugin999.file.core.windows.net/;TableEndpoint=https://testpayloadplugin999.table.core.windows.net/;SharedAccessSignature=sv=2021-06-08&ss=bfqt&srt=co&sp=rwdlacupiytfx&se=2023-11-30T22:41:29Z&st=2022-08-08T13:41:29Z&spr=https&sig=rYvOxhnnKkHXkOK%2B16HfD5zOT2zj75GgQXvox16K%2B6Q%3D
7
+ AZURE_STORAGE_CONTAINER_NAME=media
8
+ AZURE_STORAGE_ALLOW_CONTAINER_CREATE=true
9
+ AZURE_STORAGE_ACCOUNT_BASEURL=https://testpayloadplugin999.blob.core.windows.net/
10
+
11
+
12
+ S3_ENDPOINT=https://s3.amazonaws.com
13
+
14
+ S3_ACCESS_KEY_ID=AKIAYSEO7NJYNX35SVGC
15
+ S3_SECRET_ACCESS_KEY=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
16
+ S3_BUCKET=plugin-cloud-storage-test
17
+ S3_FORCE_PATH_STYLE=true
18
+
19
+ # GCS_ENDPOINT=http://127.0.0.1:4443
20
+ GCS_ENDPOINT=https://storage.googleapis.com
21
+ GCS_PROJECT_ID=my-project-72803-360420
22
+ GCS_BUCKET=project-72803
23
+
24
+
25
+ PAYLOAD_DROP_DATABASE=true
@@ -0,0 +1,21 @@
1
+ MONGODB_URI=mongodb://localhost/payload-plugin-cloud-storage
2
+ PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000
3
+ PAYLOAD_SECRET=45ligj345ligj4wl5igj4lw5igj45ligj45wlijl
4
+ PAYLOAD_CONFIG_PATH=src/payload.config.ts
5
+
6
+ AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;QueueEndpoint=http://localhost:10001/devstoreaccount1;
7
+ AZURE_STORAGE_CONTAINER_NAME=az-media
8
+ AZURE_STORAGE_ALLOW_CONTAINER_CREATE=true
9
+ AZURE_STORAGE_ACCOUNT_BASEURL=http://localhost:10000/devstoreaccount1
10
+
11
+ S3_ENDPOINT=http://localhost:4566
12
+ S3_ACCESS_KEY_ID=payloadAccessKey
13
+ S3_SECRET_ACCESS_KEY=alwiejglaiwhewlihgawe
14
+ S3_BUCKET=payload-bucket
15
+ S3_FORCE_PATH_STYLE=true
16
+
17
+ GCS_ENDPOINT=http://localhost:4443
18
+ GCS_PROJECT_ID=test
19
+ GCS_BUCKET=payload-bucket
20
+
21
+ PAYLOAD_DROP_DATABASE=true
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkpayload_plugin_cloud_storage_demo=self.webpackChunkpayload_plugin_cloud_storage_demo||[]).push([[127],{89127:(e,a,l)=>{l.r(a),l.d(a,{default:()=>D});var t=l(67294),i=l(5977),s=l(9980),n=l(28630),d=l(75091),o=l(47489),r=l(40684),c=l(2143),m=l(49546),v=l(28584),u=l(93313),p=l(4983),b=l(46268),f=l(5590),E=l(55532),g=l(37276),_=l(25896),Z=l(50854),h=l(8742),N=l(28019),S=l(40829),w=l(45074),y=l(8792),$=l(11750),k=l(24531),L=l(17095),P=l(9684),U=l(69850);l(88446);const R="global-edit",A=e=>{var a,l,i,n,d,o,r,c,A,C,F,D,T,I,x,M;const{admin:{dateFormat:O}}=(0,s.Z)(),{publishedDoc:V}=(0,w.x5)(),{global:G,data:H,onSave:K,permissions:j,action:q,apiURL:z,initialState:B,isLoading:J}=e,{fields:Q,preview:W,versions:X,label:Y,admin:{description:ee,hideAPIURL:ae}={}}=G,le=null===(a=null==j?void 0:j.update)||void 0===a?void 0:a.permission;return t.createElement("div",{className:R},J&&t.createElement(S.Z,null),!J&&t.createElement(P.R.Provider,{value:"update"},t.createElement(u.Z,{className:"global-edit__form",method:"post",action:q,onSuccess:K,disabled:!le,initialState:B},t.createElement("div",{className:"global-edit__main"},t.createElement(g.Z,{title:Y,description:Y,keywords:`${Y}, Payload, CMS`}),t.createElement(v.Z,null),!((null===(l=G.versions)||void 0===l?void 0:l.drafts)&&(null===(n=null===(i=G.versions)||void 0===i?void 0:i.drafts)||void 0===n?void 0:n.autosave))&&t.createElement(Z.Z,null),t.createElement(U.T,{className:"global-edit__edit"},t.createElement("header",{className:"global-edit__header"},t.createElement("h1",null,"Edit"," ",Y),ee&&t.createElement("div",{className:"global-edit__sub-header"},t.createElement(N.Z,{description:ee}))),t.createElement(f.Z,{readOnly:!le,permissions:j.fields,filter:e=>!e.admin.position||e.admin.position&&"sidebar"!==e.admin.position,fieldTypes:_.Z,fieldSchema:Q}))),t.createElement("div",{className:"global-edit__sidebar-wrap"},t.createElement("div",{className:"global-edit__sidebar"},t.createElement("div",{className:"global-edit__sidebar-sticky-wrap"},t.createElement("div",{className:"global-edit__document-actions"+((null===(d=G.versions)||void 0===d?void 0:d.drafts)&&!(null===(r=null===(o=G.versions)||void 0===o?void 0:o.drafts)||void 0===r?void 0:r.autosave)||W?" global-edit__document-actions--has-2":"")},W&&(!(null===(c=G.versions)||void 0===c?void 0:c.drafts)||(null===(C=null===(A=G.versions)||void 0===A?void 0:A.drafts)||void 0===C?void 0:C.autosave))&&t.createElement(p.Z,{generatePreviewURL:W,data:H}),le&&t.createElement(t.Fragment,null,(null===(F=G.versions)||void 0===F?void 0:F.drafts)&&t.createElement(t.Fragment,null,!G.versions.drafts.autosave&&t.createElement(y.Z,null),t.createElement($.Z,null)),!(null===(D=G.versions)||void 0===D?void 0:D.drafts)&&t.createElement(b.Z,{buttonId:"action-save"},"Save"))),t.createElement("div",{className:"global-edit__sidebar-fields"},W&&(null===(T=G.versions)||void 0===T?void 0:T.drafts)&&!(null===(x=null===(I=G.versions)||void 0===I?void 0:I.drafts)||void 0===x?void 0:x.autosave)&&t.createElement(p.Z,{generatePreviewURL:W,data:H}),(null===(M=G.versions)||void 0===M?void 0:M.drafts)&&t.createElement(t.Fragment,null,t.createElement(k.Z,null),G.versions.drafts.autosave&&le&&t.createElement(L.Z,{publishedDocUpdatedAt:(null==V?void 0:V.updatedAt)||(null==H?void 0:H.createdAt),global:G})),t.createElement(f.Z,{readOnly:!le,permissions:j.fields,filter:e=>"sidebar"===e.admin.position,fieldTypes:_.Z,fieldSchema:Q})),t.createElement("ul",{className:"global-edit__meta"},X&&t.createElement("li",null,t.createElement("div",{className:"global-edit__label"},"Versions"),t.createElement(h.Z,{global:G})),H&&!ae&&t.createElement("li",{className:"global-edit__api-url"},t.createElement("span",{className:"global-edit__label"},"API URL"," ",t.createElement(E.Z,{value:z})),t.createElement("a",{href:z,target:"_blank",rel:"noopener noreferrer"},z)),H.updatedAt&&t.createElement("li",null,t.createElement("div",{className:"global-edit__label"},"Last Modified"),t.createElement("div",null,(0,m.default)(new Date(H.updatedAt),O))))))))))};var C=l(19826),F=l(91455);const D=e=>{var a,l;const{state:m}=(0,i.TH)(),v=(0,r.bU)(),{setStepNav:u}=(0,d.FP)(),{permissions:p,user:b}=(0,n.a)(),[f,E]=(0,t.useState)(),{getVersions:g,preferencesKey:_}=(0,w.x5)(),{getPreference:Z}=(0,F.G)(),{serverURL:h,routes:{api:N}}=(0,s.Z)(),{global:S}=e,{slug:y,label:$,fields:k,admin:{components:{views:{Edit:L}={}}={}}={}}=S,P=(0,t.useCallback)((async e=>{g();const a=await(0,C.Z)({fieldSchema:k,data:e.result,operation:"update",user:b,locale:v});E(a)}),[g,k,b,v]),[{data:U}]=(0,o.Z)(`${h}${N}/globals/${y}`,{initialParams:{"fallback-locale":"null",depth:0,draft:"true"}}),R=(null==m?void 0:m.data)||U;(0,t.useEffect)((()=>{u([{label:$}])}),[u,$]),(0,t.useEffect)((()=>{(async()=>{const e=await(0,C.Z)({fieldSchema:k,data:R,user:b,operation:"update",locale:v});await Z(_),E(e)})()}),[R,k,b,v,Z,_]);const D=null===(a=null==p?void 0:p.globals)||void 0===a?void 0:a[y];return t.createElement(c.Z,{DefaultComponent:A,CustomComponent:L,componentProps:{isLoading:!f,data:R,permissions:D,initialState:f,global:S,onSave:P,apiURL:`${h}${N}/globals/${y}${(null===(l=S.versions)||void 0===l?void 0:l.drafts)?"?draft=true":""}`,action:`${h}${N}/globals/${y}?locale=${v}&depth=0&fallback-locale=null`}})}}}]);
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 16.17dbe03b1d0a96f3e564.js.LICENSE.txt */
2
+ (self.webpackChunkpayload_plugin_cloud_storage_demo=self.webpackChunkpayload_plugin_cloud_storage_demo||[]).push([[16],{29016:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>f});var a=n(67294),r=n(40460),s=n.n(r),i=n(28325),o=(n(35433),n(15251),n(24335),n(39980),n(74277),n(62356),n(96836),n(21029),n(73358),n(48170)),l=n(90546),u=n.n(l),c=n(953),g=n(90666),p=n(77070),d=n(35193);n(27413);const f=u()((e=>{const{path:t,name:n,required:r,validate:l=d.code,admin:{readOnly:u,style:f,className:h,width:m,language:y,description:v,condition:b}={},label:x}=e,[k]=(0,a.useState)((()=>i.languages[y]?e=>(0,i.highlight)(e,i.languages[y]):e=>e)),F=t||n,_=(0,a.useCallback)(((e,t)=>l(e,{...t,required:r})),[l,r]),{value:w,showError:A,setValue:S,errorMessage:P}=(0,o.Z)({path:F,validate:_,enableDebouncedValue:!0,condition:b}),E=["field-type","code",h,A&&"error",u&&"read-only"].filter(Boolean).join(" ");return a.createElement("div",{className:E,style:{...f,width:m}},a.createElement(g.Z,{showError:A,message:P}),a.createElement(c.Z,{htmlFor:`field-${F}`,label:x,required:r}),a.createElement(s(),{id:`field-${F.replace(/\./gi,"__")}`,value:w||"",onValueChange:u?()=>null:S,highlight:k,padding:25,style:{backgroundColor:"var(--theme-base-850)",color:"var(--theme-base-0)",fontFamily:'"Consolas", "Monaco", monospace',fontSize:12,pointerEvents:u?"none":"auto"}}),a.createElement(p.Z,{value:w,description:v}))}))},35433:()=>{Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}},28325:(e,t,n)=>{var a=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,a={},r={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof s?new s(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++n}),e.__id},clone:function e(t,n){var a,s;switch(n=n||{},r.util.type(t)){case"Object":if(s=r.util.objId(t),n[s])return n[s];for(var i in a={},n[s]=a,t)t.hasOwnProperty(i)&&(a[i]=e(t[i],n));return a;case"Array":return s=r.util.objId(t),n[s]?n[s]:(a=[],n[s]=a,t.forEach((function(t,r){a[r]=e(t,n)})),a);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return"none"},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,"gi"),""),e.classList.add("language-"+n)},currentScript:function(){if("undefined"==typeof document)return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(a){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(a.stack)||[])[1];if(e){var t=document.getElementsByTagName("script");for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var a="no-"+t;e;){var r=e.classList;if(r.contains(t))return!0;if(r.contains(a))return!1;e=e.parentElement}return!!n}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(e,t){var n=r.util.clone(r.languages[e]);for(var a in t)n[a]=t[a];return n},insertBefore:function(e,t,n,a){var s=(a=a||r.languages)[e],i={};for(var o in s)if(s.hasOwnProperty(o)){if(o==t)for(var l in n)n.hasOwnProperty(l)&&(i[l]=n[l]);n.hasOwnProperty(o)||(i[o]=s[o])}var u=a[e];return a[e]=i,r.languages.DFS(r.languages,(function(t,n){n===u&&t!=e&&(this[t]=i)})),i},DFS:function e(t,n,a,s){s=s||{};var i=r.util.objId;for(var o in t)if(t.hasOwnProperty(o)){n.call(t,o,t[o],a||o);var l=t[o],u=r.util.type(l);"Object"!==u||s[i(l)]?"Array"!==u||s[i(l)]||(s[i(l)]=!0,e(l,n,o,s)):(s[i(l)]=!0,e(l,n,null,s))}}},plugins:{},highlightAll:function(e,t){r.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var a={callback:n,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",a),a.elements=Array.prototype.slice.apply(a.container.querySelectorAll(a.selector)),r.hooks.run("before-all-elements-highlight",a);for(var s,i=0;s=a.elements[i++];)r.highlightElement(s,!0===t,a.callback)},highlightElement:function(t,n,a){var s=r.util.getLanguage(t),i=r.languages[s];r.util.setLanguage(t,s);var o=t.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&r.util.setLanguage(o,s);var l={element:t,language:s,grammar:i,code:t.textContent};function u(e){l.highlightedCode=e,r.hooks.run("before-insert",l),l.element.innerHTML=l.highlightedCode,r.hooks.run("after-highlight",l),r.hooks.run("complete",l),a&&a.call(l.element)}if(r.hooks.run("before-sanity-check",l),(o=l.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!l.code)return r.hooks.run("complete",l),void(a&&a.call(l.element));if(r.hooks.run("before-highlight",l),l.grammar)if(n&&e.Worker){var c=new Worker(r.filename);c.onmessage=function(e){u(e.data)},c.postMessage(JSON.stringify({language:l.language,code:l.code,immediateClose:!0}))}else u(r.highlight(l.code,l.grammar,l.language));else u(r.util.encode(l.code))},highlight:function(e,t,n){var a={code:e,grammar:t,language:n};if(r.hooks.run("before-tokenize",a),!a.grammar)throw new Error('The language "'+a.language+'" has no grammar.');return a.tokens=r.tokenize(a.code,a.grammar),r.hooks.run("after-tokenize",a),s.stringify(r.util.encode(a.tokens),a.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var a in n)t[a]=n[a];delete t.rest}var r=new l;return u(r,r.head,e),o(e,r,t,r.head,0),function(e){var t=[],n=e.head.next;for(;n!==e.tail;)t.push(n.value),n=n.next;return t}(r)},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var a,s=0;a=n[s++];)a(t)}},Token:s};function s(e,t,n,a){this.type=e,this.content=t,this.alias=n,this.length=0|(a||"").length}function i(e,t,n,a){e.lastIndex=t;var r=e.exec(n);if(r&&a&&r[1]){var s=r[1].length;r.index+=s,r[0]=r[0].slice(s)}return r}function o(e,t,n,a,l,g){for(var p in n)if(n.hasOwnProperty(p)&&n[p]){var d=n[p];d=Array.isArray(d)?d:[d];for(var f=0;f<d.length;++f){if(g&&g.cause==p+","+f)return;var h=d[f],m=h.inside,y=!!h.lookbehind,v=!!h.greedy,b=h.alias;if(v&&!h.pattern.global){var x=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,x+"g")}for(var k=h.pattern||h,F=a.next,_=l;F!==t.tail&&!(g&&_>=g.reach);_+=F.value.length,F=F.next){var w=F.value;if(t.length>e.length)return;if(!(w instanceof s)){var A,S=1;if(v){if(!(A=i(k,_,e,y))||A.index>=e.length)break;var P=A.index,E=A.index+A[0].length,C=_;for(C+=F.value.length;P>=C;)C+=(F=F.next).value.length;if(_=C-=F.value.length,F.value instanceof s)continue;for(var $=F;$!==t.tail&&(C<E||"string"==typeof $.value);$=$.next)S++,C+=$.value.length;S--,w=e.slice(_,C),A.index-=_}else if(!(A=i(k,0,w,y)))continue;P=A.index;var j=A[0],O=w.slice(0,P),z=w.slice(P+j.length),L=_+w.length;g&&L>g.reach&&(g.reach=L);var D=F.prev;if(O&&(D=u(t,D,O),_+=O.length),c(t,D,S),F=u(t,D,new s(p,m?r.tokenize(j,m):j,b,j)),z&&u(t,F,z),S>1){var K={cause:p+","+f,reach:L};o(e,t,n,F.prev,_,K),g&&K.reach>g.reach&&(g.reach=K.reach)}}}}}}function l(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function u(e,t,n){var a=t.next,r={value:n,prev:t,next:a};return t.next=r,a.prev=r,e.length++,r}function c(e,t,n){for(var a=t.next,r=0;r<n&&a!==e.tail;r++)a=a.next;t.next=a,a.prev=t,e.length-=r}if(e.Prism=r,s.stringify=function e(t,n){if("string"==typeof t)return t;if(Array.isArray(t)){var a="";return t.forEach((function(t){a+=e(t,n)})),a}var s={type:t.type,content:e(t.content,n),tag:"span",classes:["token",t.type],attributes:{},language:n},i=t.alias;i&&(Array.isArray(i)?Array.prototype.push.apply(s.classes,i):s.classes.push(i)),r.hooks.run("wrap",s);var o="";for(var l in s.attributes)o+=" "+l+'="'+(s.attributes[l]||"").replace(/"/g,"&quot;")+'"';return"<"+s.tag+' class="'+s.classes.join(" ")+'"'+o+">"+s.content+"</"+s.tag+">"},!e.document)return e.addEventListener?(r.disableWorkerMessageHandler||e.addEventListener("message",(function(t){var n=JSON.parse(t.data),a=n.language,s=n.code,i=n.immediateClose;e.postMessage(r.highlight(s,r.languages[a],a)),i&&e.close()}),!1),r):r;var g=r.util.currentScript();function p(){r.manual||r.highlightAll()}if(g&&(r.filename=g.src,g.hasAttribute("data-manual")&&(r.manual=!0)),!r.manual){var d=document.readyState;"loading"===d||"interactive"===d&&g&&g.defer?document.addEventListener("DOMContentLoaded",p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return r}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{});e.exports&&(e.exports=a),void 0!==n.g&&(n.g.Prism=a)},15251:()=>{!function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(Prism)},39980:()=>{Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript},74277:()=>{Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json},62356:()=>{!function(e){var t=e.util.clone(e.languages.javascript),n=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,a=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,r=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function s(e,t){return e=e.replace(/<S>/g,(function(){return n})).replace(/<BRACES>/g,(function(){return a})).replace(/<SPREAD>/g,(function(){return r})),RegExp(e,t)}r=s(r).source,e.languages.jsx=e.languages.extend("markup",t),e.languages.jsx.tag.pattern=s(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore("inside","attr-name",{spread:{pattern:s(/<SPREAD>/.source),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore("inside","special-attr",{script:{pattern:s(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:e.languages.jsx}}},e.languages.jsx.tag);var i=function(e){return e?"string"==typeof e?e:"string"==typeof e.content?e.content:e.content.map(i).join(""):""},o=function(t){for(var n=[],a=0;a<t.length;a++){var r=t[a],s=!1;if("string"!=typeof r&&("tag"===r.type&&r.content[0]&&"tag"===r.content[0].type?"</"===r.content[0].content[0].content?n.length>0&&n[n.length-1].tagName===i(r.content[0].content[1])&&n.pop():"/>"===r.content[r.content.length-1].content||n.push({tagName:i(r.content[0].content[1]),openedBraces:0}):n.length>0&&"punctuation"===r.type&&"{"===r.content?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&"punctuation"===r.type&&"}"===r.content?n[n.length-1].openedBraces--:s=!0),(s||"string"==typeof r)&&n.length>0&&0===n[n.length-1].openedBraces){var l=i(r);a<t.length-1&&("string"==typeof t[a+1]||"plain-text"===t[a+1].type)&&(l+=i(t[a+1]),t.splice(a+1,1)),a>0&&("string"==typeof t[a-1]||"plain-text"===t[a-1].type)&&(l=i(t[a-1])+l,t.splice(a-1,1),a--),t[a]=new e.Token("plain-text",l,null,l)}r.content&&"string"!=typeof r.content&&o(r.content)}};e.hooks.add("after-tokenize",(function(e){"jsx"!==e.language&&"tsx"!==e.language||o(e.tokens)}))}(Prism)},24335:()=>{Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&amp;/,"&"))})),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(e,t){var n={};n["language-"+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};a["language-"+t]={pattern:/[\s\S]+/,inside:Prism.languages[t]};var r={};r[e]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:a},Prism.languages.insertBefore("markup","cdata",r)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(e,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml},21029:()=>{!function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend("jsx",t),delete e.languages.tsx.parameter,delete e.languages.tsx["literal-property"];var n=e.languages.tsx.tag;n.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+n.pattern.source+")",n.pattern.flags),n.lookbehind=!0}(Prism)},96836:()=>{!function(e){e.languages.typescript=e.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript["literal-property"];var t=e.languages.extend("typescript",{});delete t["class-name"],e.languages.typescript["class-name"].inside=t,e.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),e.languages.ts=e.languages.typescript}(Prism)},73358:()=>{!function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,a="(?:"+n.source+"(?:[ \t]+"+t.source+")?|"+t.source+"(?:[ \t]+"+n.source+")?)",r=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g,(function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source})),s=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function i(e,t){t=(t||"").replace(/m/g,"")+"m";var n=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,(function(){return a})).replace(/<<value>>/g,(function(){return e}));return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g,(function(){return a}))),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,(function(){return a})).replace(/<<key>>/g,(function(){return"(?:"+r+"|"+s+")"}))),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:i(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:i(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:i(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:i(s),lookbehind:!0,greedy:!0},number:{pattern:i(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml}(Prism)},40460:function(e,t,n){"use strict";var a,r=this&&this.__extends||(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),s=this&&this.__assign||function(){return s=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,r)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return o(t,e),t},u=this&&this.__rest||function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var c=l(n(67294)),g=90,p=219,d=222,f=192,h=100,m="navigator"in n.g&&/Win/i.test(navigator.platform),y="navigator"in n.g&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),v="npm__react-simple-code-editor__textarea",b="\n/**\n * Reset the text fill color so that placeholder is visible\n */\n.".concat(v,":empty {\n -webkit-text-fill-color: inherit !important;\n}\n\n/**\n * Hack to apply on some CSS on IE10 and IE11\n */\n@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {\n /**\n * IE doesn't support '-webkit-text-fill-color'\n * So we use 'color: transparent' to make the text transparent on IE\n * Unlike other browsers, it doesn't affect caret color in IE\n */\n .").concat(v," {\n color: transparent !important;\n }\n\n .").concat(v,"::selection {\n background-color: #accef7 !important;\n color: transparent !important;\n }\n}\n"),x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={capture:!0},t._recordCurrentState=function(){var e=t._input;if(e){var n=e.value,a=e.selectionStart,r=e.selectionEnd;t._recordChange({value:n,selectionStart:a,selectionEnd:r})}},t._getLines=function(e,t){return e.substring(0,t).split("\n")},t._recordChange=function(e,n){var a,r,i;void 0===n&&(n=!1);var o=t._history,l=o.stack,u=o.offset;if(l.length&&u>-1){t._history.stack=l.slice(0,u+1);var c=t._history.stack.length;if(c>h){var g=c-h;t._history.stack=l.slice(g,c),t._history.offset=Math.max(t._history.offset-g,0)}}var p=Date.now();if(n){var d=t._history.stack[t._history.offset];if(d&&p-d.timestamp<3e3){var f=/[^a-z0-9]([a-z0-9]+)$/i,m=null===(a=t._getLines(d.value,d.selectionStart).pop())||void 0===a?void 0:a.match(f),y=null===(r=t._getLines(e.value,e.selectionStart).pop())||void 0===r?void 0:r.match(f);if((null==m?void 0:m[1])&&(null===(i=null==y?void 0:y[1])||void 0===i?void 0:i.startsWith(m[1])))return void(t._history.stack[t._history.offset]=s(s({},e),{timestamp:p}))}}t._history.stack.push(s(s({},e),{timestamp:p})),t._history.offset++},t._updateInput=function(e){var n=t._input;n&&(n.value=e.value,n.selectionStart=e.selectionStart,n.selectionEnd=e.selectionEnd,t.props.onValueChange(e.value))},t._applyEdits=function(e){var n=t._input,a=t._history.stack[t._history.offset];a&&n&&(t._history.stack[t._history.offset]=s(s({},a),{selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})),t._recordChange(e),t._updateInput(e)},t._undoEdit=function(){var e=t._history,n=e.stack,a=e.offset,r=n[a-1];r&&(t._updateInput(r),t._history.offset=Math.max(a-1,0))},t._redoEdit=function(){var e=t._history,n=e.stack,a=e.offset,r=n[a+1];r&&(t._updateInput(r),t._history.offset=Math.min(a+1,n.length-1))},t._handleKeyDown=function(e){var n=t.props,a=n.tabSize,r=n.insertSpaces,s=n.ignoreTabKey,i=n.onKeyDown;if(!i||(i(e),!e.defaultPrevented)){27===e.keyCode&&e.currentTarget.blur();var o=e.currentTarget,l=o.value,u=o.selectionStart,c=o.selectionEnd,h=(r?" ":"\t").repeat(a);if(9===e.keyCode&&!s&&t.state.capture)if(e.preventDefault(),e.shiftKey){var v=(F=t._getLines(l,u)).length-1,b=t._getLines(l,c).length-1,x=l.split("\n").map((function(e,t){return t>=v&&t<=b&&e.startsWith(h)?e.substring(h.length):e})).join("\n");if(l!==x){var k=F[v];t._applyEdits({value:x,selectionStart:(null==k?void 0:k.startsWith(h))?u-h.length:u,selectionEnd:c-(l.length-x.length)})}}else if(u!==c){var F,_=(F=t._getLines(l,u)).length-1,w=t._getLines(l,c).length-1;k=F[_];t._applyEdits({value:l.split("\n").map((function(e,t){return t>=_&&t<=w?h+e:e})).join("\n"),selectionStart:k&&/\S/.test(k)?u+h.length:u,selectionEnd:c+h.length*(w-_+1)})}else{var A=u+h.length;t._applyEdits({value:l.substring(0,u)+h+l.substring(c),selectionStart:A,selectionEnd:A})}else if(8===e.keyCode){var S=u!==c;if(l.substring(0,u).endsWith(h)&&!S){e.preventDefault();A=u-h.length;t._applyEdits({value:l.substring(0,u-h.length)+l.substring(c),selectionStart:A,selectionEnd:A})}}else if(13===e.keyCode){if(u===c){var P=t._getLines(l,u).pop(),E=null==P?void 0:P.match(/^\s+/);if(null==E?void 0:E[0]){e.preventDefault();var C="\n"+E[0];A=u+C.length;t._applyEdits({value:l.substring(0,u)+C+l.substring(c),selectionStart:A,selectionEnd:A})}}}else if(57===e.keyCode||e.keyCode===p||e.keyCode===d||e.keyCode===f){var $=void 0;57===e.keyCode&&e.shiftKey?$=["(",")"]:e.keyCode===p?$=e.shiftKey?["{","}"]:["[","]"]:e.keyCode===d?$=e.shiftKey?['"','"']:["'","'"]:e.keyCode!==f||e.shiftKey||($=["`","`"]),u!==c&&$&&(e.preventDefault(),t._applyEdits({value:l.substring(0,u)+$[0]+l.substring(u,c)+$[1]+l.substring(c),selectionStart:u,selectionEnd:c+2}))}else!(y?e.metaKey&&e.keyCode===g:e.ctrlKey&&e.keyCode===g)||e.shiftKey||e.altKey?(y?e.metaKey&&e.keyCode===g&&e.shiftKey:m?e.ctrlKey&&89===e.keyCode:e.ctrlKey&&e.keyCode===g&&e.shiftKey)&&!e.altKey?(e.preventDefault(),t._redoEdit()):77!==e.keyCode||!e.ctrlKey||y&&!e.shiftKey||(e.preventDefault(),t.setState((function(e){return{capture:!e.capture}}))):(e.preventDefault(),t._undoEdit())}},t._handleChange=function(e){var n=e.currentTarget,a=n.value,r=n.selectionStart,s=n.selectionEnd;t._recordChange({value:a,selectionStart:r,selectionEnd:s},!0),t.props.onValueChange(a)},t._history={stack:[],offset:-1},t._input=null,t}return r(t,e),t.prototype.componentDidMount=function(){this._recordCurrentState()},Object.defineProperty(t.prototype,"session",{get:function(){return{history:this._history}},set:function(e){this._history=e.history},enumerable:!1,configurable:!0}),t.prototype.render=function(){var e=this,t=this.props,n=t.value,a=t.style,r=t.padding,i=t.highlight,o=t.textareaId,l=t.textareaClassName,g=t.autoFocus,p=t.disabled,d=t.form,f=t.maxLength,h=t.minLength,m=t.name,y=t.placeholder,x=t.readOnly,F=t.required,_=t.onClick,w=t.onFocus,A=t.onBlur,S=t.onKeyUp,P=(t.onKeyDown,t.onValueChange,t.tabSize,t.insertSpaces,t.ignoreTabKey,t.preClassName),E=u(t,["value","style","padding","highlight","textareaId","textareaClassName","autoFocus","disabled","form","maxLength","minLength","name","placeholder","readOnly","required","onClick","onFocus","onBlur","onKeyUp","onKeyDown","onValueChange","tabSize","insertSpaces","ignoreTabKey","preClassName"]),C={paddingTop:r,paddingRight:r,paddingBottom:r,paddingLeft:r},$=i(n);return c.createElement("div",s({},E,{style:s(s({},k.container),a)}),c.createElement("textarea",{ref:function(t){return e._input=t},style:s(s(s({},k.editor),k.textarea),C),className:v+(l?" ".concat(l):""),id:o,value:n,onChange:this._handleChange,onKeyDown:this._handleKeyDown,onClick:_,onKeyUp:S,onFocus:w,onBlur:A,disabled:p,form:d,maxLength:f,minLength:h,name:m,placeholder:y,readOnly:x,required:F,autoFocus:g,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),c.createElement("pre",s({className:P,"aria-hidden":"true",style:s(s(s({},k.editor),k.highlight),C)},"string"==typeof $?{dangerouslySetInnerHTML:{__html:$+"<br />"}}:{children:$})),c.createElement("style",{type:"text/css",dangerouslySetInnerHTML:{__html:b}}))},t.defaultProps={tabSize:2,insertSpaces:!0,ignoreTabKey:!1,padding:0},t}(c.Component);t.default=x;var k={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}}}}]);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Prism: Lightweight, robust, elegant syntax highlighting
3
+ *
4
+ * @license MIT <https://opensource.org/licenses/MIT>
5
+ * @author Lea Verou <https://lea.verou.me>
6
+ * @namespace
7
+ * @public
8
+ */