Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new private upload-media package #66290

Open
wants to merge 32 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8a57140
Add new private `upload-media` package
swissspidy Oct 21, 2024
808700e
Add missing readme
swissspidy Oct 22, 2024
7a9a762
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Oct 22, 2024
6022cf0
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Oct 23, 2024
3f30935
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Oct 24, 2024
91f7687
Make `updateSettings` private
swissspidy Oct 24, 2024
b1b0cb5
Remove empty line
swissspidy Oct 24, 2024
5d00adb
Add back some of the missing utils
swissspidy Oct 24, 2024
72d474f
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Oct 24, 2024
07680ca
Update docs now
swissspidy Oct 24, 2024
38c3df6
Remove meetings (#66421)
ndiego Oct 24, 2024
06e345e
Site editor: remove "default" admin CSS (#66431)
ellatrix Oct 24, 2024
8f99999
Fix: JSON Schema Docgen doesn't work on Windows OS (#66414)
t-hamano Oct 25, 2024
a198bd2
Revise zoom layout shift fix (#66390)
stokesman Oct 25, 2024
4d4142c
Zoom out: Add keyboard shortcut in editor (#66400)
ntsekouras Oct 25, 2024
7f2549c
Compose: Fix React Complier error for 'useCopyToClipboard' (#66444)
Mamaduka Oct 25, 2024
f0b988c
Style Book: Fix React Compiler error (#66445)
Mamaduka Oct 25, 2024
0b066a9
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Oct 25, 2024
3cfa25a
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Oct 25, 2024
a1f044f
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Nov 4, 2024
57135d8
Add `ts-ignore`
swissspidy Nov 4, 2024
a76fcc7
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Nov 25, 2024
5b3c022
Block editor: Add `MediaUploadProvider` (#66380)
swissspidy Nov 25, 2024
1dc086d
Change order in `package.json`
swissspidy Nov 25, 2024
845cf78
Rip out most code
swissspidy Nov 25, 2024
8cd6177
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Nov 30, 2024
a1f0282
A bunch of fixes
swissspidy Dec 2, 2024
bae3e67
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Dec 2, 2024
93e9ec9
Fixes
swissspidy Dec 2, 2024
6176a66
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Dec 2, 2024
17dc47e
Move to folder for RN compat
swissspidy Dec 2, 2024
8b6f249
Merge branch 'trunk' into add/61447-upload-media-pkg
swissspidy Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@wordpress/sync": "file:packages/sync",
"@wordpress/token-list": "file:packages/token-list",
"@wordpress/undo-manager": "file:packages/undo-manager",
"@wordpress/upload-media": "file:packages/upload-media",
"@wordpress/url": "file:packages/url",
"@wordpress/viewport": "file:packages/viewport",
"@wordpress/vips": "file:packages/vips",
Expand Down Expand Up @@ -310,7 +311,7 @@
"lint:pkg-json": "wp-scripts lint-pkg-json . 'packages/*/package.json'",
"native": "npm run --prefix packages/react-native-editor",
"other:changelog": "node ./bin/plugin/cli.js changelog",
"other:check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2 --ignore=@react-native-community/cli,@react-native-community/cli-platform-ios,@ampproject/remapping,human-signals,fb-watchman,walker,chrome-launcher,lighthouse-logger,chromium-edge-launcher\" \"wp-scripts check-licenses --dev\"",
"other:check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2 --ignore=@react-native-community/cli,@react-native-community/cli-platform-ios,@ampproject/remapping,human-signals,fb-watchman,walker,chrome-launcher,lighthouse-logger,chromium-edge-launcher,webpack\" \"wp-scripts check-licenses --dev\"",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the Apache-licensed @webassemblyjs/leb128 and @xtuc/long packages, which are dependencies of webpack, were being flagged. No idea why this happened only when working on this PR.

"preother:check-local-changes": "npm run docs:build",
"other:check-local-changes": "node ./bin/check-local-changes.js",
"other:cherry-pick": "node ./bin/cherry-pick.mjs",
Expand Down
1 change: 1 addition & 0 deletions packages/private-apis/src/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const CORE_MODULES_USING_PRIVATE_APIS = [
'@wordpress/router',
'@wordpress/dataviews',
'@wordpress/fields',
'@wordpress/upload-media',
];

/**
Expand Down
1 change: 1 addition & 0 deletions packages/upload-media/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions packages/upload-media/CHANGELOG.md
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.
43 changes: 43 additions & 0 deletions packages/upload-media/package.json
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"
}
}
1 change: 1 addition & 0 deletions packages/upload-media/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PREFERENCES_NAME = 'core/media';
38 changes: 38 additions & 0 deletions packages/upload-media/src/image-file.ts
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 {
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}
16 changes: 16 additions & 0 deletions packages/upload-media/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Internal dependencies
*/
import { store as uploadStore } from './store';
swissspidy marked this conversation as resolved.
Show resolved Hide resolved

export { uploadStore as store };

export { UploadError } from './upload-error';

export type {
ImageFormat,
ImageSizeCrop,
ThumbnailGeneration,
VideoFormat,
AudioFormat,
} from './store/types';
10 changes: 10 additions & 0 deletions packages/upload-media/src/lock-unlock.ts
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'
);
Loading
Loading