Skip to content

Commit

Permalink
prep build 09/13
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Sep 13, 2024
2 parents 134cd57 + 632d8d6 commit ddf8dbf
Show file tree
Hide file tree
Showing 135 changed files with 1,541 additions and 496 deletions.
17 changes: 3 additions & 14 deletions bin/build-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,15 @@ npm run build
php bin/generate-gutenberg-php.php > gutenberg.tmp.php
mv gutenberg.tmp.php gutenberg.php

build_files=$(
ls build/*/*.{js,js.map,css,asset.php} \
build/block-library/blocks/*.php \
build/block-library/blocks/*/block.json \
build/block-library/blocks/*/*.{js,js.map,css,asset.php} \
build/edit-widgets/blocks/*/block.json \
build/widgets/blocks/*.php \
build/widgets/blocks/*/block.json \
build/style-engine/*.php \
)


# Generate the plugin zip file.
status "Creating archive... 🎁"
zip -r gutenberg.zip \
zip --recurse-paths --no-dir-entries \
gutenberg.zip \
gutenberg.php \
lib \
packages/block-serialization-default-parser/*.php \
post-content.php \
$build_files \
build \
build-module \
readme.txt \
changelog.txt \
Expand Down
6 changes: 0 additions & 6 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1697,12 +1697,6 @@
"markdown_source": "../packages/eslint-plugin/README.md",
"parent": "packages"
},
{
"title": "@wordpress/fields",
"slug": "packages-fields",
"markdown_source": "../packages/fields/README.md",
"parent": "packages"
},
{
"title": "@wordpress/format-library",
"slug": "packages-format-library",
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/slotfills/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ import { __ } from '@wordpress/i18n';
*/
const SiteEditorDocumentSettingPanel = () => {
// Retrieve information about the current post type.
const { isViewable } = useSelect( ( select ) => {
const isViewable = useSelect( ( select ) => {
const postTypeName = select( editorStore ).getCurrentPostType();
const postTypeObject = select( coreStore ).getPostType( postTypeName );

Expand Down
27 changes: 27 additions & 0 deletions lib/experimental/script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,30 @@ function gutenberg_dequeue_module( $module_identifier ) {
_deprecated_function( __FUNCTION__, 'Gutenberg 17.6.0', 'wp_dequeue_script_module' );
wp_script_modules()->dequeue( $module_identifier );
}

/**
* Registers Gutenberg Script Modules.
*
* @since 19.3
*/
function gutenberg_register_script_modules() {
// When in production, use the plugin's version as the default asset version;
// else (for development or test) default to use the current time.
$default_version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();

wp_deregister_script_module( '@wordpress/a11y' );
wp_register_script_module(
'@wordpress/a11y',
gutenberg_url( 'build-module/a11y/index.min.js' ),
array(),
$default_version
);
add_filter(
'script_module_data_@wordpress/a11y',
function ( $data ) {
$data['i18n'] = array( 'Notifications' => __( 'Notifications', 'default' ) );
return $data;
}
);
}
add_action( 'init', 'gutenberg_register_script_modules' );
65 changes: 54 additions & 11 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@
"storybook-source-link": "2.0.9",
"strip-json-comments": "5.0.0",
"style-loader": "3.2.1",
"terser": "5.32.0",
"terser-webpack-plugin": "5.3.9",
"typescript": "5.5.3",
"uglify-js": "3.13.7",
"uuid": "9.0.1",
"webdriverio": "8.16.20",
"webpack": "5.88.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/a11y/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ speak( 'The message you want to send to the ARIA live region', 'assertive' );
_Parameters_

- _message_ `string`: The message to be announced by assistive technologies.
- _ariaLive_ `[string]`: The politeness level for aria-live; default: 'polite'.
- _ariaLive_ `['polite'|'assertive']`: The politeness level for aria-live; default: 'polite'.

<!-- END TOKEN(Autogenerated API docs) -->

Expand Down
1 change: 1 addition & 0 deletions packages/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"types": "build-types",
"wpScriptModuleExports": "./build-module/module/index.js",
"dependencies": {
"@babel/runtime": "^7.16.0",
"@wordpress/dom-ready": "file:../dom-ready",
Expand Down
75 changes: 4 additions & 71 deletions packages/a11y/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,20 @@
* WordPress dependencies
*/
import domReady from '@wordpress/dom-ready';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import addIntroText from './add-intro-text';
import addContainer from './add-container';
import clear from './clear';
import filterMessage from './filter-message';
import { makeSetupFunction } from './shared/index';
export { speak } from './shared/index';

/**
* Create the live regions.
*/
export function setup() {
const introText = document.getElementById( 'a11y-speak-intro-text' );
const containerAssertive = document.getElementById(
'a11y-speak-assertive'
);
const containerPolite = document.getElementById( 'a11y-speak-polite' );

if ( introText === null ) {
addIntroText();
}

if ( containerAssertive === null ) {
addContainer( 'assertive' );
}

if ( containerPolite === null ) {
addContainer( 'polite' );
}
}
export const setup = makeSetupFunction( __( 'Notifications' ) );

/**
* Run setup on domReady.
*/
domReady( setup );

/**
* Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
* This module is inspired by the `speak` function in `wp-a11y.js`.
*
* @param {string} message The message to be announced by assistive technologies.
* @param {string} [ariaLive] The politeness level for aria-live; default: 'polite'.
*
* @example
* ```js
* import { speak } from '@wordpress/a11y';
*
* // For polite messages that shouldn't interrupt what screen readers are currently announcing.
* speak( 'The message you want to send to the ARIA live region' );
*
* // For assertive messages that should interrupt what screen readers are currently announcing.
* speak( 'The message you want to send to the ARIA live region', 'assertive' );
* ```
*/
export function speak( message, ariaLive ) {
/*
* Clear previous messages to allow repeated strings being read out and hide
* the explanatory text from assistive technologies.
*/
clear();

message = filterMessage( message );

const introText = document.getElementById( 'a11y-speak-intro-text' );
const containerAssertive = document.getElementById(
'a11y-speak-assertive'
);
const containerPolite = document.getElementById( 'a11y-speak-polite' );

if ( containerAssertive && ariaLive === 'assertive' ) {
containerAssertive.textContent = message;
} else if ( containerPolite ) {
containerPolite.textContent = message;
}

/*
* Make the explanatory text available to assistive technologies by removing
* the 'hidden' HTML attribute.
*/
if ( introText ) {
introText.removeAttribute( 'hidden' );
}
}
2 changes: 1 addition & 1 deletion packages/a11y/src/index.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import filterMessage from './filter-message';
import filterMessage from './shared/filter-message';

/**
* Update the ARIA live notification area text node.
Expand Down
25 changes: 25 additions & 0 deletions packages/a11y/src/module/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Internal dependencies
*/
import { makeSetupFunction } from '../shared/index';
export { speak } from '../shared/index';

// Without an i18n Script Module, "Notifications" (the only localized text used in this module)
// will be translated on the server and provided as script-module data.
let notificationsText = 'Notifications';
try {
const textContent = document.getElementById(
'wp-script-module-data-@wordpress/a11y'
)?.textContent;
if ( textContent ) {
const parsed = JSON.parse( textContent );
notificationsText = parsed?.i18n?.Notifications ?? notificationsText;
}
} catch {}

/**
* Create the live regions.
*/
export const setup = makeSetupFunction( notificationsText );

setup();
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Build the explanatory text to be placed before the aria live regions.
*
* This text is initially hidden from assistive technologies by using a `hidden`
* HTML attribute which is then removed once a message fills the aria-live regions.
*
* @param {string} introTextContent The translated intro text content.
* @return {HTMLParagraphElement} The explanatory text HTML element.
*/
export default function addIntroText() {
export default function addIntroText( introTextContent: string ) {
const introText = document.createElement( 'p' );

introText.id = 'a11y-speak-intro-text';
introText.className = 'a11y-speak-intro-text';
introText.textContent = __( 'Notifications' );
introText.textContent = introTextContent;

introText.setAttribute(
'style',
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ddf8dbf

Please sign in to comment.