-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Create @wordpress/interactivity with the Interactivity API #50906
Conversation
Size Change: -16.2 kB (-1%) Total Size: 1.44 MB
ℹ️ View Unchanged
|
Flaky tests detected in 1ed1e34. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5353969402
|
I had some issues regarding the Webpack configuration. One is that I had to add aliases to TypeError: Cannot add property __, object is not extensible Another one is that the The last one is that the Webpack runtime is included in every @luisherranz, @gziolo, I'd like to know your thoughts on these issues. 🙂 Apart from that, it's currently working. If you want to do a quick test, you can rename diff --git a/lib/experimental/interactivity-api/blocks.php b/lib/experimental/interactivity-api/blocks.php
index c7af76da52..bcb4858a58 100644
--- a/lib/experimental/interactivity-api/blocks.php
+++ b/lib/experimental/interactivity-api/blocks.php
@@ -227,7 +227,7 @@ function gutenberg_block_update_interactive_view_script( $metadata ) {
in_array( $metadata['name'], array( 'core/file', 'core/navigation' ), true ) &&
str_contains( $metadata['file'], 'build/block-library/blocks' )
) {
- $metadata['viewScript'] = array( 'file:./interactivity.min.js' );
+ $metadata['viewScript'] = array( 'file:./view.min.js' );
}
return $metadata;
}
|
That's weird. Where is that code located?
Yeah, yeah. It's fine with only one file. I forgot to mention that.
Yes. We need to live with that unless/until we move to modules. |
It's part of |
I don't mind the aliases, but I'd like to understand where this is coming from. |
Ok, let's merge this. We'll add the README in a different PR tomorrow with the help of @juanmaguitar. |
The PR for the readme is here: |
I think this PR caused a problem with the link color of the block not being applied correctly on the front end. Please check the comment here. |
Thanks for the report. Let's talk about it in the other issue 👍 |
Question: I see that this PR removed the non-Interactivity API code for the File block and Navigation block. How will that code be maintained before the Interactivity API ships in core? For example, the code in
But neither of these seem guaranteed. I am, for example, looking into a perf issue with the old Navigation block's view code. But I'm blocked from doing so at present. |
You're totally right. I'll revert those changes. Also, is it ok to keep using the |
Mario added the old implementation back: |
Thank you!
Humm. You mean for code that gets backported to core? I can see that there are both But otherwise, if the experiment feature flag isn't used, there should be a filter in the plugin to be able to decide between whether to use the Interactivity API version or the old implementation. Otherwise it would be difficult to access the old implementation, right? Not sure if |
Sure, we can do that 🙂
Thanks for the heads up, Weston. I think those files were backported automatically. I see you already commented here. I'll monitor the answer and we'll make a PR to remove that code if necessary. |
I've opened #52579 to propose this. |
Haha, you beat me to it 🤦 |
…#50906) * Start with package.json and README * Add new package to docs/manifest.json * Copy-paste runtime files from block-library * Add .npmrc file * Add interactivity package to dependencies * Create a custom webpack config for interactivity * Expose interactivity runtime in `wp.interactivity` * Update package-lock * Add `@wordpress/interactivity` to block-library deps * Rename entry point to index * Remove vendors chunk * Add oddly required aliases * Add view prefix to interactivity.js files * Use view-interactivity files when enabled * Stop adding defer to Interactivity scripts * Remove webpack config for interactivity.js files * Remove interactivity runtime from block-library * Remove interactivity runtime from sideEffects * Undo temporary fix for Interactivity API in dependency-extraction-webpack-plugin * Remove script loader for Interactivity API runtime * Remove block-librar/interactivity from build_files * Add src/index.js to Interactivity API entry file * Remove unnecessary aliases * Restore data-wp-body directive * Interactivity API: add `wp_store` (WordPress#51191) * Add `wp_store` to the Interactivity API * Rename WP_Interactivity_Store and move filter to scripts file * Remove todos to change the store id * Rename syntax to -- and data-wp-interactive (WordPress#51241) * Interactivity API: initial support for SSR (WordPress#51229) * Initial version working with basic support for wp-bind * Add wp-context * Add wp-class * Add wp-style * Add wp-text * Add directive processing tests * Add WP_Directive_Processor class tests * Add wp-bind tests * Add wp-context tests * Add wp-class tests * Add wp-style tests * Add wp-text tests * Add evaluate tests * Fix PHP lint * Prevent errors with incorrect JSON objects * Add support for functions in the server * Remove require for missing script-loader.php * Remove missing PHP file * Rename view file and fix block.json * Add "interactivity" to supports and fix renaming * Code improvements for the SSR part of the Interactivity API (WordPress#51640) * Fix multi-line comments and add examples * Add parse_attribute_name static method to WP_Directive_Processor * Replace array functions with a foreach loop * Add explanatory comment for the negation operator check * Replace $array with $path_segments * Minor fix for the negation operator comment * Call only instances of Closure * Improve negation operator code style * Do not lower-case tags * Use static parse_attribute_name inside directive processors * Add basic error handling in wp-context * Fix hidden identation errors * Use the correct variable name * Fix test for evaluating functions * Remove references to "attribute" directives * Remove emtpy lines in multi-line function calls * Fix typo --------- Co-authored-by: Luis Herranz <luisherranz@gmail.com> * Add the full Interactivity API runtime (but removing the client-side navigation). (WordPress#51194) * Add show and text directives * Move directive bind tests * Move the rest of e2e tests (except csn-related) * Add interactive-blocks plugin for e2e tests * Move test plugins one folder up * Add plugin to .wp-env.json * Change directive-bind spec file to use new plugin * Move plugin to e2e-tests package * Move HTML for directive-bind to plugin * Update exposed properties from preact * Refactor directive-bind spec file * Create directive-effect block for e2e testing * Update directive-effect spec file * Remove unnecessary files * Fix e2e tests for bind and effect directives * Refactor fixtures and use them for bind and effect * Remove unnecessary editorScript * Fix e2e test for directive priorities * Remove unnecessary files * Fix negation operator * Refactor store-tag e2e tests * Refactor directive-class e2e tests * Remove extra spaces * Add util for removing all created posts * Add block for context directive * Add block for directive show testing * Remove unintentionally added artifact * Ignore artifacts generated inside /test/e2e * Remove unused html * Add block for directive text testing * Add blocks for tovdom testing * Update directives syntax in e2e tests * Add getLink to InteractivityUtils * Fix php lint errors * Add disable_directives_ssr param * Fix phpcs errors * Fix missing phpcs error and warnings * Remove `wp-interactivity` from `viewScript` --------- Co-authored-by: Luis Herranz <luisherranz@gmail.com> * Remove custom watchOptions in interactivity webpack config * Update version and description of interactivity package --------- Co-authored-by: Luis Herranz <luisherranz@gmail.com>
@@ -27,8 +27,7 @@ | |||
"sideEffects": [ | |||
"build-style/**", | |||
"src/**/*.scss", | |||
"{src,build,build-module}/*/init.js", | |||
"{src,build,build-module}/utils/interactivity/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same side effects weren't added to the new @wordpress/interactivity
package. I might cause issues in the long run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Greg. Added to the roadmap 🙂👍
await expect( el ).toBeVisible(); | ||
} ); | ||
|
||
test( 'directives inside islands should not be hydrated twice', async ( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test became flaky - #58332.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @DAreRodz was already working on a fix, weren't you David?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What?
Expose in
@wordpress/interactivity
the minimal version of the Interactivity API that Core blocks use privately.Tracking issue: #50866New Tracking issue: #51056
Why?
This would allow developers to start experimenting with the new Interactivity API. Note that this won't be part of
trunk
until the feature freeze of WordPress 6.3.How?
See tasks in the tracking issue.