-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new private
upload-media
package
- Loading branch information
1 parent
119cacc
commit ad143dc
Showing
31 changed files
with
3,330 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
|
||
## Unreleased | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "@wordpress/upload-media", | ||
"version": "1.0.0-prerelease", | ||
"private": true, | ||
"description": "Core media upload logic.", | ||
"author": "The WordPress Contributors", | ||
"license": "GPL-2.0-or-later", | ||
"keywords": [ | ||
"wordpress", | ||
"media" | ||
], | ||
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/upload-media/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/WordPress/gutenberg.git", | ||
"directory": "packages/upload-media" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/WordPress/gutenberg/issues" | ||
}, | ||
"engines": { | ||
"node": ">=18.12.0", | ||
"npm": ">=8.19.2" | ||
}, | ||
"main": "build/index.js", | ||
"module": "build-module/index.js", | ||
"types": "build-types", | ||
"dependencies": { | ||
"@shopify/web-worker": "^6.4.0", | ||
"@wordpress/api-fetch": "file:../api-fetch", | ||
"@wordpress/blob": "file:../blob", | ||
"@wordpress/data": "file:../data", | ||
"@wordpress/i18n": "file:../i18n", | ||
"@wordpress/preferences": "file:../preferences", | ||
"@wordpress/private-apis": "file:../private-apis", | ||
"@wordpress/url": "file:../url", | ||
"@wordpress/vips": "file:../vips", | ||
"uuid": "^9.0.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const PREFERENCES_NAME = 'core/media'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* ImageFile class. | ||
* | ||
* Small wrapper around the `File` class to hold | ||
* information about current dimensions and original | ||
* dimensions, in case the image was resized. | ||
*/ | ||
export class ImageFile extends File { | ||
width = 0; | ||
height = 0; | ||
originalWidth? = 0; | ||
originalHeight? = 0; | ||
|
||
get wasResized() { | ||
return ( | ||
( this.originalWidth || 0 ) > this.width || | ||
( this.originalHeight || 0 ) > this.height | ||
); | ||
} | ||
|
||
constructor( | ||
file: File, | ||
width: number, | ||
height: number, | ||
originalWidth?: number, | ||
originalHeight?: number | ||
) { | ||
super( [ file ], file.name, { | ||
type: file.type, | ||
lastModified: file.lastModified, | ||
} ); | ||
|
||
this.width = width; | ||
this.height = height; | ||
this.originalWidth = originalWidth; | ||
this.originalHeight = originalHeight; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as uploadStore } from './store'; | ||
|
||
export { uploadStore as store }; | ||
|
||
export { UploadError } from './upload-error'; | ||
|
||
export type { | ||
ImageFormat, | ||
ImageLibrary, | ||
ImageSizeCrop, | ||
ThumbnailGeneration, | ||
VideoFormat, | ||
AudioFormat, | ||
} from './store/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; | ||
|
||
export const { lock, unlock } = | ||
__dangerousOptInToUnstableAPIsOnlyForCoreModules( | ||
'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', | ||
'@wordpress/upload-media' | ||
); |
Oops, something went wrong.