@wordpress/media-utils 5.40.0 → 5.40.1-next.v.202602200903.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ function uploadMedia({
48
48
  const validFiles = [];
49
49
  const filesSet = [];
50
50
  const setAndUpdateFiles = (index, value) => {
51
- if (!window.__experimentalMediaProcessing) {
51
+ if (!window.__clientSideMediaProcessing) {
52
52
  if (filesSet[index]?.url) {
53
53
  (0, import_blob.revokeBlobURL)(filesSet[index].url);
54
54
  }
@@ -78,7 +78,7 @@ function uploadMedia({
78
78
  continue;
79
79
  }
80
80
  validFiles.push(mediaFile);
81
- if (!window.__experimentalMediaProcessing) {
81
+ if (!window.__clientSideMediaProcessing) {
82
82
  filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
83
83
  onFileChange?.(filesSet);
84
84
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/upload-media.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { createBlobURL, revokeBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAdditionalData,\n\tAttachment,\n\tOnChangeHandler,\n\tOnErrorHandler,\n} from './types';\nimport { uploadToServer } from './upload-to-server';\nimport { validateMimeType } from './validate-mime-type';\nimport { validateMimeTypeForUser } from './validate-mime-type-for-user';\nimport { validateFileSize } from './validate-file-size';\nimport { UploadError } from './upload-error';\n\ndeclare global {\n\tinterface Window {\n\t\t__experimentalMediaProcessing?: boolean;\n\t}\n}\n\ninterface UploadMediaArgs {\n\t// Additional data to include in the request.\n\tadditionalData?: AdditionalData;\n\t// Array with the types of media that can be uploaded, if unset all types are allowed.\n\tallowedTypes?: string[];\n\t// List of files.\n\tfilesList: File[];\n\t// Maximum upload size in bytes allowed for the site.\n\tmaxUploadFileSize?: number;\n\t// Function called when an error happens.\n\tonError?: OnErrorHandler;\n\t// Function called each time a file or a temporary representation of the file is available.\n\tonFileChange?: OnChangeHandler;\n\t// List of allowed mime types and file extensions.\n\twpAllowedMimeTypes?: Record< string, string > | null;\n\t// Abort signal.\n\tsignal?: AbortSignal;\n\t// Whether to allow multiple files to be uploaded.\n\tmultiple?: boolean;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param $0 Parameters object passed to the function.\n * @param $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param $0.additionalData Additional data to include in the request.\n * @param $0.filesList List of files.\n * @param $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.\n * @param $0.onError Function called when an error happens.\n * @param $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param $0.wpAllowedMimeTypes List of allowed mime types and file extensions.\n * @param $0.signal Abort signal.\n * @param $0.multiple Whether to allow multiple files to be uploaded.\n */\nexport function uploadMedia( {\n\twpAllowedMimeTypes,\n\tallowedTypes,\n\tadditionalData = {},\n\tfilesList,\n\tmaxUploadFileSize,\n\tonError,\n\tonFileChange,\n\tsignal,\n\tmultiple = true,\n}: UploadMediaArgs ) {\n\tif ( ! multiple && filesList.length > 1 ) {\n\t\tonError?.( new Error( __( 'Only one file can be used here.' ) ) );\n\t\treturn;\n\t}\n\n\tconst validFiles = [];\n\n\tconst filesSet: Array< Partial< Attachment > | null > = [];\n\tconst setAndUpdateFiles = ( index: number, value: Attachment | null ) => {\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__experimentalMediaProcessing ) {\n\t\t\tif ( filesSet[ index ]?.url ) {\n\t\t\t\trevokeBlobURL( filesSet[ index ].url );\n\t\t\t}\n\t\t}\n\t\tfilesSet[ index ] = value;\n\t\tonFileChange?.(\n\t\t\tfilesSet.filter( ( attachment ) => attachment !== null )\n\t\t);\n\t};\n\n\tfor ( const mediaFile of filesList ) {\n\t\t// Verify if user is allowed to upload this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeTypeForUser( mediaFile, wpAllowedMimeTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if the caller (e.g. a block) supports this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeType( mediaFile, allowedTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Verify if file is greater than the maximum file upload size allowed for the site.\n\t\ttry {\n\t\t\tvalidateFileSize( mediaFile, maxUploadFileSize );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalidFiles.push( mediaFile );\n\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__experimentalMediaProcessing ) {\n\t\t\t// Set temporary URL to create placeholder media file, this is replaced\n\t\t\t// with final file from media gallery when upload is `done` below.\n\t\t\tfilesSet.push( { url: createBlobURL( mediaFile ) } );\n\t\t\tonFileChange?.( filesSet as Array< Partial< Attachment > > );\n\t\t}\n\t}\n\n\tvalidFiles.map( async ( file, index ) => {\n\t\ttry {\n\t\t\tconst attachment = await uploadToServer(\n\t\t\t\tfile,\n\t\t\t\tadditionalData,\n\t\t\t\tsignal\n\t\t\t);\n\t\t\tsetAndUpdateFiles( index, attachment );\n\t\t} catch ( error ) {\n\t\t\t// Reset to empty on failure.\n\t\t\tsetAndUpdateFiles( index, null );\n\n\t\t\t// @wordpress/api-fetch throws any response that isn't in the 200 range as-is.\n\t\t\tlet message: string;\n\t\t\tif (\n\t\t\t\ttypeof error === 'object' &&\n\t\t\t\terror !== null &&\n\t\t\t\t'message' in error\n\t\t\t) {\n\t\t\t\tmessage =\n\t\t\t\t\ttypeof error.message === 'string'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: String( error.message );\n\t\t\t} else {\n\t\t\t\tmessage = sprintf(\n\t\t\t\t\t// translators: %s: file name\n\t\t\t\t\t__( 'Error while uploading file %s to the media library.' ),\n\t\t\t\t\tfile.name\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tonError?.(\n\t\t\t\tnew UploadError( {\n\t\t\t\t\tcode: 'GENERAL',\n\t\t\t\t\tmessage,\n\t\t\t\t\tfile,\n\t\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,kBAA6C;AAW7C,8BAA+B;AAC/B,gCAAiC;AACjC,yCAAwC;AACxC,gCAAiC;AACjC,0BAA4B;AA4CrB,SAAS,YAAa;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,iBAAiB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAAqB;AACpB,MAAK,CAAE,YAAY,UAAU,SAAS,GAAI;AACzC,cAAW,IAAI,UAAO,gBAAI,iCAAkC,CAAE,CAAE;AAChE;AAAA,EACD;AAEA,QAAM,aAAa,CAAC;AAEpB,QAAM,WAAkD,CAAC;AACzD,QAAM,oBAAoB,CAAE,OAAe,UAA8B;AAExE,QAAK,CAAE,OAAO,+BAAgC;AAC7C,UAAK,SAAU,KAAM,GAAG,KAAM;AAC7B,uCAAe,SAAU,KAAM,EAAE,GAAI;AAAA,MACtC;AAAA,IACD;AACA,aAAU,KAAM,IAAI;AACpB;AAAA,MACC,SAAS,OAAQ,CAAE,eAAgB,eAAe,IAAK;AAAA,IACxD;AAAA,EACD;AAEA,aAAY,aAAa,WAAY;AAGpC,QAAI;AACH,sEAAyB,WAAW,kBAAmB;AAAA,IACxD,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAIA,QAAI;AACH,sDAAkB,WAAW,YAAa;AAAA,IAC3C,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAGA,QAAI;AACH,sDAAkB,WAAW,iBAAkB;AAAA,IAChD,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAEA,eAAW,KAAM,SAAU;AAG3B,QAAK,CAAE,OAAO,+BAAgC;AAG7C,eAAS,KAAM,EAAE,SAAK,2BAAe,SAAU,EAAE,CAAE;AACnD,qBAAgB,QAA2C;AAAA,IAC5D;AAAA,EACD;AAEA,aAAW,IAAK,OAAQ,MAAM,UAAW;AACxC,QAAI;AACH,YAAM,aAAa,UAAM;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,wBAAmB,OAAO,UAAW;AAAA,IACtC,SAAU,OAAQ;AAEjB,wBAAmB,OAAO,IAAK;AAG/B,UAAI;AACJ,UACC,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,OACZ;AACD,kBACC,OAAO,MAAM,YAAY,WACtB,MAAM,UACN,OAAQ,MAAM,OAAQ;AAAA,MAC3B,OAAO;AACN,sBAAU;AAAA;AAAA,cAET,gBAAI,qDAAsD;AAAA,UAC1D,KAAK;AAAA,QACN;AAAA,MACD;AAEA;AAAA,QACC,IAAI,gCAAa;AAAA,UAChB,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,OAAO,iBAAiB,QAAQ,QAAQ;AAAA,QACzC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { createBlobURL, revokeBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAdditionalData,\n\tAttachment,\n\tOnChangeHandler,\n\tOnErrorHandler,\n} from './types';\nimport { uploadToServer } from './upload-to-server';\nimport { validateMimeType } from './validate-mime-type';\nimport { validateMimeTypeForUser } from './validate-mime-type-for-user';\nimport { validateFileSize } from './validate-file-size';\nimport { UploadError } from './upload-error';\n\ndeclare global {\n\tinterface Window {\n\t\t__clientSideMediaProcessing?: boolean;\n\t}\n}\n\ninterface UploadMediaArgs {\n\t// Additional data to include in the request.\n\tadditionalData?: AdditionalData;\n\t// Array with the types of media that can be uploaded, if unset all types are allowed.\n\tallowedTypes?: string[];\n\t// List of files.\n\tfilesList: File[];\n\t// Maximum upload size in bytes allowed for the site.\n\tmaxUploadFileSize?: number;\n\t// Function called when an error happens.\n\tonError?: OnErrorHandler;\n\t// Function called each time a file or a temporary representation of the file is available.\n\tonFileChange?: OnChangeHandler;\n\t// List of allowed mime types and file extensions.\n\twpAllowedMimeTypes?: Record< string, string > | null;\n\t// Abort signal.\n\tsignal?: AbortSignal;\n\t// Whether to allow multiple files to be uploaded.\n\tmultiple?: boolean;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param $0 Parameters object passed to the function.\n * @param $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param $0.additionalData Additional data to include in the request.\n * @param $0.filesList List of files.\n * @param $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.\n * @param $0.onError Function called when an error happens.\n * @param $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param $0.wpAllowedMimeTypes List of allowed mime types and file extensions.\n * @param $0.signal Abort signal.\n * @param $0.multiple Whether to allow multiple files to be uploaded.\n */\nexport function uploadMedia( {\n\twpAllowedMimeTypes,\n\tallowedTypes,\n\tadditionalData = {},\n\tfilesList,\n\tmaxUploadFileSize,\n\tonError,\n\tonFileChange,\n\tsignal,\n\tmultiple = true,\n}: UploadMediaArgs ) {\n\tif ( ! multiple && filesList.length > 1 ) {\n\t\tonError?.( new Error( __( 'Only one file can be used here.' ) ) );\n\t\treturn;\n\t}\n\n\tconst validFiles = [];\n\n\tconst filesSet: Array< Partial< Attachment > | null > = [];\n\tconst setAndUpdateFiles = ( index: number, value: Attachment | null ) => {\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__clientSideMediaProcessing ) {\n\t\t\tif ( filesSet[ index ]?.url ) {\n\t\t\t\trevokeBlobURL( filesSet[ index ].url );\n\t\t\t}\n\t\t}\n\t\tfilesSet[ index ] = value;\n\t\tonFileChange?.(\n\t\t\tfilesSet.filter( ( attachment ) => attachment !== null )\n\t\t);\n\t};\n\n\tfor ( const mediaFile of filesList ) {\n\t\t// Verify if user is allowed to upload this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeTypeForUser( mediaFile, wpAllowedMimeTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if the caller (e.g. a block) supports this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeType( mediaFile, allowedTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Verify if file is greater than the maximum file upload size allowed for the site.\n\t\ttry {\n\t\t\tvalidateFileSize( mediaFile, maxUploadFileSize );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalidFiles.push( mediaFile );\n\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__clientSideMediaProcessing ) {\n\t\t\t// Set temporary URL to create placeholder media file, this is replaced\n\t\t\t// with final file from media gallery when upload is `done` below.\n\t\t\tfilesSet.push( { url: createBlobURL( mediaFile ) } );\n\t\t\tonFileChange?.( filesSet as Array< Partial< Attachment > > );\n\t\t}\n\t}\n\n\tvalidFiles.map( async ( file, index ) => {\n\t\ttry {\n\t\t\tconst attachment = await uploadToServer(\n\t\t\t\tfile,\n\t\t\t\tadditionalData,\n\t\t\t\tsignal\n\t\t\t);\n\t\t\tsetAndUpdateFiles( index, attachment );\n\t\t} catch ( error ) {\n\t\t\t// Reset to empty on failure.\n\t\t\tsetAndUpdateFiles( index, null );\n\n\t\t\t// @wordpress/api-fetch throws any response that isn't in the 200 range as-is.\n\t\t\tlet message: string;\n\t\t\tif (\n\t\t\t\ttypeof error === 'object' &&\n\t\t\t\terror !== null &&\n\t\t\t\t'message' in error\n\t\t\t) {\n\t\t\t\tmessage =\n\t\t\t\t\ttypeof error.message === 'string'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: String( error.message );\n\t\t\t} else {\n\t\t\t\tmessage = sprintf(\n\t\t\t\t\t// translators: %s: file name\n\t\t\t\t\t__( 'Error while uploading file %s to the media library.' ),\n\t\t\t\t\tfile.name\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tonError?.(\n\t\t\t\tnew UploadError( {\n\t\t\t\t\tcode: 'GENERAL',\n\t\t\t\t\tmessage,\n\t\t\t\t\tfile,\n\t\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,kBAA6C;AAW7C,8BAA+B;AAC/B,gCAAiC;AACjC,yCAAwC;AACxC,gCAAiC;AACjC,0BAA4B;AA4CrB,SAAS,YAAa;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,iBAAiB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAAqB;AACpB,MAAK,CAAE,YAAY,UAAU,SAAS,GAAI;AACzC,cAAW,IAAI,UAAO,gBAAI,iCAAkC,CAAE,CAAE;AAChE;AAAA,EACD;AAEA,QAAM,aAAa,CAAC;AAEpB,QAAM,WAAkD,CAAC;AACzD,QAAM,oBAAoB,CAAE,OAAe,UAA8B;AAExE,QAAK,CAAE,OAAO,6BAA8B;AAC3C,UAAK,SAAU,KAAM,GAAG,KAAM;AAC7B,u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A,EACD,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -24,7 +24,7 @@ function uploadMedia({
24
24
  const validFiles = [];
25
25
  const filesSet = [];
26
26
  const setAndUpdateFiles = (index, value) => {
27
- if (!window.__experimentalMediaProcessing) {
27
+ if (!window.__clientSideMediaProcessing) {
28
28
  if (filesSet[index]?.url) {
29
29
  revokeBlobURL(filesSet[index].url);
30
30
  }
@@ -54,7 +54,7 @@ function uploadMedia({
54
54
  continue;
55
55
  }
56
56
  validFiles.push(mediaFile);
57
- if (!window.__experimentalMediaProcessing) {
57
+ if (!window.__clientSideMediaProcessing) {
58
58
  filesSet.push({ url: createBlobURL(mediaFile) });
59
59
  onFileChange?.(filesSet);
60
60
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/upload-media.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { createBlobURL, revokeBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAdditionalData,\n\tAttachment,\n\tOnChangeHandler,\n\tOnErrorHandler,\n} from './types';\nimport { uploadToServer } from './upload-to-server';\nimport { validateMimeType } from './validate-mime-type';\nimport { validateMimeTypeForUser } from './validate-mime-type-for-user';\nimport { validateFileSize } from './validate-file-size';\nimport { UploadError } from './upload-error';\n\ndeclare global {\n\tinterface Window {\n\t\t__experimentalMediaProcessing?: boolean;\n\t}\n}\n\ninterface UploadMediaArgs {\n\t// Additional data to include in the request.\n\tadditionalData?: AdditionalData;\n\t// Array with the types of media that can be uploaded, if unset all types are allowed.\n\tallowedTypes?: string[];\n\t// List of files.\n\tfilesList: File[];\n\t// Maximum upload size in bytes allowed for the site.\n\tmaxUploadFileSize?: number;\n\t// Function called when an error happens.\n\tonError?: OnErrorHandler;\n\t// Function called each time a file or a temporary representation of the file is available.\n\tonFileChange?: OnChangeHandler;\n\t// List of allowed mime types and file extensions.\n\twpAllowedMimeTypes?: Record< string, string > | null;\n\t// Abort signal.\n\tsignal?: AbortSignal;\n\t// Whether to allow multiple files to be uploaded.\n\tmultiple?: boolean;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param $0 Parameters object passed to the function.\n * @param $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param $0.additionalData Additional data to include in the request.\n * @param $0.filesList List of files.\n * @param $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.\n * @param $0.onError Function called when an error happens.\n * @param $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param $0.wpAllowedMimeTypes List of allowed mime types and file extensions.\n * @param $0.signal Abort signal.\n * @param $0.multiple Whether to allow multiple files to be uploaded.\n */\nexport function uploadMedia( {\n\twpAllowedMimeTypes,\n\tallowedTypes,\n\tadditionalData = {},\n\tfilesList,\n\tmaxUploadFileSize,\n\tonError,\n\tonFileChange,\n\tsignal,\n\tmultiple = true,\n}: UploadMediaArgs ) {\n\tif ( ! multiple && filesList.length > 1 ) {\n\t\tonError?.( new Error( __( 'Only one file can be used here.' ) ) );\n\t\treturn;\n\t}\n\n\tconst validFiles = [];\n\n\tconst filesSet: Array< Partial< Attachment > | null > = [];\n\tconst setAndUpdateFiles = ( index: number, value: Attachment | null ) => {\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__experimentalMediaProcessing ) {\n\t\t\tif ( filesSet[ index ]?.url ) {\n\t\t\t\trevokeBlobURL( filesSet[ index ].url );\n\t\t\t}\n\t\t}\n\t\tfilesSet[ index ] = value;\n\t\tonFileChange?.(\n\t\t\tfilesSet.filter( ( attachment ) => attachment !== null )\n\t\t);\n\t};\n\n\tfor ( const mediaFile of filesList ) {\n\t\t// Verify if user is allowed to upload this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeTypeForUser( mediaFile, wpAllowedMimeTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if the caller (e.g. a block) supports this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeType( mediaFile, allowedTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Verify if file is greater than the maximum file upload size allowed for the site.\n\t\ttry {\n\t\t\tvalidateFileSize( mediaFile, maxUploadFileSize );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalidFiles.push( mediaFile );\n\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__experimentalMediaProcessing ) {\n\t\t\t// Set temporary URL to create placeholder media file, this is replaced\n\t\t\t// with final file from media gallery when upload is `done` below.\n\t\t\tfilesSet.push( { url: createBlobURL( mediaFile ) } );\n\t\t\tonFileChange?.( filesSet as Array< Partial< Attachment > > );\n\t\t}\n\t}\n\n\tvalidFiles.map( async ( file, index ) => {\n\t\ttry {\n\t\t\tconst attachment = await uploadToServer(\n\t\t\t\tfile,\n\t\t\t\tadditionalData,\n\t\t\t\tsignal\n\t\t\t);\n\t\t\tsetAndUpdateFiles( index, attachment );\n\t\t} catch ( error ) {\n\t\t\t// Reset to empty on failure.\n\t\t\tsetAndUpdateFiles( index, null );\n\n\t\t\t// @wordpress/api-fetch throws any response that isn't in the 200 range as-is.\n\t\t\tlet message: string;\n\t\t\tif (\n\t\t\t\ttypeof error === 'object' &&\n\t\t\t\terror !== null &&\n\t\t\t\t'message' in error\n\t\t\t) {\n\t\t\t\tmessage =\n\t\t\t\t\ttypeof error.message === 'string'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: String( error.message );\n\t\t\t} else {\n\t\t\t\tmessage = sprintf(\n\t\t\t\t\t// translators: %s: file name\n\t\t\t\t\t__( 'Error while uploading file %s to the media library.' ),\n\t\t\t\t\tfile.name\n\t\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kB;AAAA,IAChD,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAEA,eAAW,KAAM,SAAU;AAG3B,QAAK,CAAE,OAAO,+BAAgC;AAG7C,eAAS,KAAM,EAAE,KAAK,cAAe,SAAU,EAAE,CAAE;AACnD,qBAAgB,QAA2C;AAAA,IAC5D;AAAA,EACD;AAEA,aAAW,IAAK,OAAQ,MAAM,UAAW;AACxC,QAAI;AACH,YAAM,aAAa,MAAM;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,wBAAmB,OAAO,UAAW;AAAA,IACtC,SAAU,OAAQ;AAEjB,wBAAmB,OAAO,IAAK;AAG/B,UAAI;AACJ,UACC,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,OACZ;AACD,kBACC,OAAO,MAAM,YAAY,WACtB,MAAM,UACN,OAAQ,MAAM,OAAQ;AAAA,MAC3B,OAAO;AACN,kBAAU;AAAA;AAAA,UAET,GAAI,qDAAsD;AAAA,UAC1D,KAAK;AAAA,QACN;AAAA,MACD;AAEA;AAAA,QACC,IAAI,YAAa;AAAA,UAChB,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,OAAO,iBAAiB,QAAQ,QAAQ;AAAA,QACzC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { createBlobURL, revokeBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAdditionalData,\n\tAttachment,\n\tOnChangeHandler,\n\tOnErrorHandler,\n} from './types';\nimport { uploadToServer } from './upload-to-server';\nimport { validateMimeType } from './validate-mime-type';\nimport { validateMimeTypeForUser } from './validate-mime-type-for-user';\nimport { validateFileSize } from './validate-file-size';\nimport { UploadError } from './upload-error';\n\ndeclare global {\n\tinterface Window {\n\t\t__clientSideMediaProcessing?: boolean;\n\t}\n}\n\ninterface UploadMediaArgs {\n\t// Additional data to include in the request.\n\tadditionalData?: AdditionalData;\n\t// Array with the types of media that can be uploaded, if unset all types are allowed.\n\tallowedTypes?: string[];\n\t// List of files.\n\tfilesList: File[];\n\t// Maximum upload size in bytes allowed for the site.\n\tmaxUploadFileSize?: number;\n\t// Function called when an error happens.\n\tonError?: OnErrorHandler;\n\t// Function called each time a file or a temporary representation of the file is available.\n\tonFileChange?: OnChangeHandler;\n\t// List of allowed mime types and file extensions.\n\twpAllowedMimeTypes?: Record< string, string > | null;\n\t// Abort signal.\n\tsignal?: AbortSignal;\n\t// Whether to allow multiple files to be uploaded.\n\tmultiple?: boolean;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param $0 Parameters object passed to the function.\n * @param $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param $0.additionalData Additional data to include in the request.\n * @param $0.filesList List of files.\n * @param $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.\n * @param $0.onError Function called when an error happens.\n * @param $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param $0.wpAllowedMimeTypes List of allowed mime types and file extensions.\n * @param $0.signal Abort signal.\n * @param $0.multiple Whether to allow multiple files to be uploaded.\n */\nexport function uploadMedia( {\n\twpAllowedMimeTypes,\n\tallowedTypes,\n\tadditionalData = {},\n\tfilesList,\n\tmaxUploadFileSize,\n\tonError,\n\tonFileChange,\n\tsignal,\n\tmultiple = true,\n}: UploadMediaArgs ) {\n\tif ( ! multiple && filesList.length > 1 ) {\n\t\tonError?.( new Error( __( 'Only one file can be used here.' ) ) );\n\t\treturn;\n\t}\n\n\tconst validFiles = [];\n\n\tconst filesSet: Array< Partial< Attachment > | null > = [];\n\tconst setAndUpdateFiles = ( index: number, value: Attachment | null ) => {\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__clientSideMediaProcessing ) {\n\t\t\tif ( filesSet[ index ]?.url ) {\n\t\t\t\trevokeBlobURL( filesSet[ index ].url );\n\t\t\t}\n\t\t}\n\t\tfilesSet[ index ] = value;\n\t\tonFileChange?.(\n\t\t\tfilesSet.filter( ( attachment ) => attachment !== null )\n\t\t);\n\t};\n\n\tfor ( const mediaFile of filesList ) {\n\t\t// Verify if user is allowed to upload this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeTypeForUser( mediaFile, wpAllowedMimeTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if the caller (e.g. a block) supports this mime type.\n\t\t// Defer to the server when type not detected.\n\t\ttry {\n\t\t\tvalidateMimeType( mediaFile, allowedTypes );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Verify if file is greater than the maximum file upload size allowed for the site.\n\t\ttry {\n\t\t\tvalidateFileSize( mediaFile, maxUploadFileSize );\n\t\t} catch ( error: unknown ) {\n\t\t\tonError?.( error as Error );\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalidFiles.push( mediaFile );\n\n\t\t// For client-side media processing, this is handled by the upload-media package.\n\t\tif ( ! window.__clientSideMediaProcessing ) {\n\t\t\t// Set temporary URL to create placeholder media file, this is replaced\n\t\t\t// with final file from media gallery when upload is `done` below.\n\t\t\tfilesSet.push( { url: createBlobURL( mediaFile ) } );\n\t\t\tonFileChange?.( filesSet as Array< Partial< Attachment > > );\n\t\t}\n\t}\n\n\tvalidFiles.map( async ( file, index ) => {\n\t\ttry {\n\t\t\tconst attachment = await uploadToServer(\n\t\t\t\tfile,\n\t\t\t\tadditionalData,\n\t\t\t\tsignal\n\t\t\t);\n\t\t\tsetAndUpdateFiles( index, attachment );\n\t\t} catch ( error ) {\n\t\t\t// Reset to empty on failure.\n\t\t\tsetAndUpdateFiles( index, null );\n\n\t\t\t// @wordpress/api-fetch throws any response that isn't in the 200 range as-is.\n\t\t\tlet message: string;\n\t\t\tif (\n\t\t\t\ttypeof error === 'object' &&\n\t\t\t\terror !== null &&\n\t\t\t\t'message' in error\n\t\t\t) {\n\t\t\t\tmessage =\n\t\t\t\t\ttypeof error.message === 'string'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: String( error.message );\n\t\t\t} else {\n\t\t\t\tmessage = sprintf(\n\t\t\t\t\t// translators: %s: file name\n\t\t\t\t\t__( 'Error while uploading file %s to the media library.' ),\n\t\t\t\t\tfile.name\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tonError?.(\n\t\t\t\tnew UploadError( {\n\t\t\t\t\tcode: 'GENERAL',\n\t\t\t\t\tmessage,\n\t\t\t\t\tfile,\n\t\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,eAAe,qBAAqB;AAW7C,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AA4CrB,SAAS,YAAa;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,iBAAiB,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAAqB;AACpB,MAAK,CAAE,YAAY,UAAU,SAAS,GAAI;AACzC,cAAW,IAAI,MAAO,GAAI,iCAAkC,CAAE,CAAE;AAChE;AAAA,EACD;AAEA,QAAM,aAAa,CAAC;AAEpB,QAAM,WAAkD,CAAC;AACzD,QAAM,oBAAoB,CAAE,OAAe,UAA8B;AAExE,QAAK,CAAE,OAAO,6BAA8B;AAC3C,UAAK,SAAU,KAAM,GAAG,KAAM;AAC7B,sBAAe,SAAU,KAAM,EAAE,GAAI;AAAA,MACtC;AAAA,IACD;AACA,aAAU,KAAM,IAAI;AACpB;AAAA,MACC,SAAS,OAAQ,CAAE,eAAgB,eAAe,IAAK;AAAA,IACxD;AAAA,EACD;AAEA,aAAY,aAAa,WAAY;AAGpC,QAAI;AACH,8BAAyB,WAAW,kBAAmB;AAAA,IACxD,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAIA,QAAI;AACH,uBAAkB,WAAW,YAAa;AAAA,IAC3C,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAGA,QAAI;AACH,uBAAkB,WAAW,iBAAkB;AAAA,IAChD,SAAU,OAAiB;AAC1B,gBAAW,KAAe;AAC1B;AAAA,IACD;AAEA,eAAW,KAAM,SAAU;AAG3B,QAAK,CAAE,OAAO,6BAA8B;AAG3C,eAAS,KAAM,EAAE,KAAK,cAAe,SAAU,EAAE,CAAE;AACnD,qBAAgB,QAA2C;AAAA,IAC5D;AAAA,EACD;AAEA,aAAW,IAAK,OAAQ,MAAM,UAAW;AACxC,QAAI;AACH,YAAM,aAAa,MAAM;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,wBAAmB,OAAO,UAAW;AAAA,IACtC,SAAU,OAAQ;AAEjB,wBAAmB,OAAO,IAAK;AAG/B,UAAI;AACJ,UACC,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,OACZ;AACD,kBACC,OAAO,MAAM,YAAY,WACtB,MAAM,UACN,OAAQ,MAAM,OAAQ;AAAA,MAC3B,OAAO;AACN,kBAAU;AAAA;AAAA,UAET,GAAI,qDAAsD;AAAA,UAC1D,KAAK;AAAA,QACN;AAAA,MACD;AAEA;AAAA,QACC,IAAI,YAAa;AAAA,UAChB,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,OAAO,iBAAiB,QAAQ,QAAQ;AAAA,QACzC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -289,13 +289,14 @@
289
289
  .media-upload-modal .media-upload-modal__snackbar {
290
290
  position: fixed;
291
291
  bottom: 24px;
292
- right: 50%;
293
- left: auto;
294
- transform: translateX(50%);
295
- width: max-content;
296
- max-width: calc(100vw - 32px);
292
+ right: 0;
293
+ left: 0;
294
+ padding-inline: 16px;
297
295
  box-sizing: border-box;
298
296
  display: flex;
299
297
  flex-direction: column;
300
- align-items: center;
298
+ pointer-events: none;
299
+ }
300
+ .media-upload-modal .media-upload-modal__snackbar .components-snackbar {
301
+ margin-inline: auto;
301
302
  }
@@ -289,13 +289,14 @@
289
289
  .media-upload-modal .media-upload-modal__snackbar {
290
290
  position: fixed;
291
291
  bottom: 24px;
292
- left: 50%;
293
- right: auto;
294
- transform: translateX(-50%);
295
- width: max-content;
296
- max-width: calc(100vw - 32px);
292
+ left: 0;
293
+ right: 0;
294
+ padding-inline: 16px;
297
295
  box-sizing: border-box;
298
296
  display: flex;
299
297
  flex-direction: column;
300
- align-items: center;
298
+ pointer-events: none;
299
+ }
300
+ .media-upload-modal .media-upload-modal__snackbar .components-snackbar {
301
+ margin-inline: auto;
301
302
  }
@@ -4,7 +4,7 @@
4
4
  import type { AdditionalData, OnChangeHandler, OnErrorHandler } from './types';
5
5
  declare global {
6
6
  interface Window {
7
- __experimentalMediaProcessing?: boolean;
7
+ __clientSideMediaProcessing?: boolean;
8
8
  }
9
9
  }
10
10
  interface UploadMediaArgs {
@@ -1 +1 @@
1
- {"version":3,"file":"upload-media.d.ts","sourceRoot":"","sources":["../../src/utils/upload-media.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EACX,cAAc,EAEd,eAAe,EACf,cAAc,EACd,MAAM,SAAS,CAAC;AAOjB,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,6BAA6B,CAAC,EAAE,OAAO,CAAC;KACxC;CACD;AAED,UAAU,eAAe;IAExB,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,SAAS,EAAE,IAAI,EAAE,CAAC;IAElB,iBAAiB,CAA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EACjB,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAe,GACf,EAAE,eAAe,QAqGjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-utils",
3
- "version": "5.40.0",
3
+ "version": "5.40.1-next.v.202602200903.0+06edfb869",
4
4
  "description": "WordPress Media Upload Utils.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -47,19 +47,19 @@
47
47
  "build-style/**"
48
48
  ],
49
49
  "dependencies": {
50
- "@wordpress/api-fetch": "^7.40.0",
51
- "@wordpress/base-styles": "^6.16.0",
52
- "@wordpress/blob": "^4.40.0",
53
- "@wordpress/components": "^32.2.0",
54
- "@wordpress/core-data": "^7.40.0",
55
- "@wordpress/data": "^10.40.0",
56
- "@wordpress/dataviews": "^12.0.0",
57
- "@wordpress/element": "^6.40.0",
58
- "@wordpress/i18n": "^6.13.0",
59
- "@wordpress/icons": "^11.7.0",
60
- "@wordpress/media-fields": "^0.5.0",
61
- "@wordpress/notices": "^5.40.0",
62
- "@wordpress/private-apis": "^1.40.0"
50
+ "@wordpress/api-fetch": "^7.40.1-next.v.202602200903.0+06edfb869",
51
+ "@wordpress/base-styles": "^6.16.1-next.v.202602200903.0+06edfb869",
52
+ "@wordpress/blob": "^4.40.1-next.v.202602200903.0+06edfb869",
53
+ "@wordpress/components": "^32.2.2-next.v.202602200903.0+06edfb869",
54
+ "@wordpress/core-data": "^7.40.1-next.v.202602200903.0+06edfb869",
55
+ "@wordpress/data": "^10.40.1-next.v.202602200903.0+06edfb869",
56
+ "@wordpress/dataviews": "^12.1.1-next.v.202602200903.0+06edfb869",
57
+ "@wordpress/element": "^6.40.1-next.v.202602200903.0+06edfb869",
58
+ "@wordpress/i18n": "^6.13.1-next.v.202602200903.0+06edfb869",
59
+ "@wordpress/icons": "^11.7.1-next.v.202602200903.0+06edfb869",
60
+ "@wordpress/media-fields": "^0.5.1-next.v.202602200903.0+06edfb869",
61
+ "@wordpress/notices": "^5.40.1-next.v.202602200903.0+06edfb869",
62
+ "@wordpress/private-apis": "^1.40.1-next.v.202602200903.0+06edfb869"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": "^18.0.0"
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "376124aa10dbc2cc0c81c964ec00b99fcfee5382"
70
+ "gitHead": "6e225a6505fdc8e407305851c7a68b781dee8118"
71
71
  }
@@ -21,7 +21,7 @@ import { UploadError } from './upload-error';
21
21
 
22
22
  declare global {
23
23
  interface Window {
24
- __experimentalMediaProcessing?: boolean;
24
+ __clientSideMediaProcessing?: boolean;
25
25
  }
26
26
  }
27
27
 
@@ -82,7 +82,7 @@ export function uploadMedia( {
82
82
  const filesSet: Array< Partial< Attachment > | null > = [];
83
83
  const setAndUpdateFiles = ( index: number, value: Attachment | null ) => {
84
84
  // For client-side media processing, this is handled by the upload-media package.
85
- if ( ! window.__experimentalMediaProcessing ) {
85
+ if ( ! window.__clientSideMediaProcessing ) {
86
86
  if ( filesSet[ index ]?.url ) {
87
87
  revokeBlobURL( filesSet[ index ].url );
88
88
  }
@@ -123,7 +123,7 @@ export function uploadMedia( {
123
123
  validFiles.push( mediaFile );
124
124
 
125
125
  // For client-side media processing, this is handled by the upload-media package.
126
- if ( ! window.__experimentalMediaProcessing ) {
126
+ if ( ! window.__clientSideMediaProcessing ) {
127
127
  // Set temporary URL to create placeholder media file, this is replaced
128
128
  // with final file from media gallery when upload is `done` below.
129
129
  filesSet.push( { url: createBlobURL( mediaFile ) } );