Repository navigation
Tracking issue: WordPress Directives Plugin 🎨 #80
Description
This issue aims to list and keep track of the tasks related to the WordPress Directives Plugin experiment. The goal is to create an installable plugin that adds a set of basic directives and client-side navigations to any site.
For this experiment's stress-testing, please check the Tracking Issue: Performance and stress-testing vDOM Hydration 🧪
For the Custom Elements or Directives Hydration experiment, please check their corresponding Tracking Issues.
The main branch of this experiment is main-wp-directives-plugin. Make sure you select it when opening a pull request if it is related to this experiment.
Please proactively comment on this issue whenever you start working on a new task, get blocked, or finish a task, sharing as much detail and information as possible. Thanks!!
High-level overview
-
Directives
-
Finish the directives of the initial list - In progress 🚧
Work on the directives is still reactive as we only work on the ones that we need for our experiments, demos, etc. The work on the Movies demo and Woo blocks should bring some focus to this task.
-
Add SSR for the ones that need it - In progress 🚧\
This is led by @ockham and @dmsnell.
There's already initial support for the SSR of basic directive attributes and good progress on
wp-context. The next challenge to solve is to figure out the APIs to access the inner HTML with the HTML (Tag) Processor. -
Decide final names - In progress 🚧
We are keeping a list of the decisions that need to be made here in the Tracking Issue.
-
-
Components
There hasn't been any progress on this, mostly due to the lack of need for components (directive tags). @luisherranz opened an issue proposing their removal, as we couldn't find a single case where they add meaningful value and we might want to use them for other purposes in the future.
-
State Management
- Finish the Deep Signals implementation - Finished ✅
- Decide on the recommended shape - In progress 🚧
Same answer as in the "Directives - Decide final names". - TypeScript support - Not started ⏸
- Figure out if we want to expose some parts of the router and/or other configuration in the state (example) - Not started ⏸
-
Server-side rendering
- API to do SSRing - In progress 🚧
Same answer as in the "Directives - Add SSR for the ones that need it". - Serialize initial state - Finished ✅
- Sort directives by priority - Not started ⏸
- API to do SSRing - In progress 🚧
-
Client runtime
-
Bundling
- API to register directives/components - Not started ⏸
- Enqueue directives/components present in the HTML - Not started ⏸
- Ensure script execution order, deferring and prefetch - Not started ⏸
- Choose final package name and shape - In progress 🚧
Same answer as in the "Directives - Decide final names". - Choose and implement dependency management - In progress 🚧
Barely started, just preliminary conversations between @luisherranz, @gziolo, @dmsnell and @youknowriad.
-
Client-side navigation
- Manual (Finished ✅) and automatic opt-in (Not started ⏸)
- Router
- Fetch directives/components scripts - Not started ⏸
- Global state (
state.router.url) - Not started ⏸
- API to trigger virtual pageviews - Not started ⏸
- Prefetching strategy - Not started ⏸
Done
- 🎨 Add wp-link attribute to all links #81
- 🎨 Add basic functionality #82
- 🎨 Add basic router and wp link directive #83
- 🎨 Remove comments and preserve scripts #84
- 🎨 Support CSS in client-side navigations #85
- 🎨 Add meta tag to opt-in to client-side navigations #86
- 🎨 Admin for client side navigations #88
- 🎨 Add
prefetchto all links and prevent scroll in pagination #87 - 🎨 Fix context not updated on prop change #90
- 🎨 Preserve client components in the DOM #89
- 🎨 WP Directives plugin - Stress testing in real sites #91 (closed because it was finished)
- Handle CDATA nodes #115
- WP Directives Plugin: Require Gutenberg plugin to avoid a fatal error #119
- Treat
nodeType7 like comments #121 - Ignore
refattr while generating virtual nodes #122 - Limit the hydration to block when client-side navigations are deactivated #124
- Fix wp-class and introduce the evaluate function #127
- Switch to the deepsignal package #128
- Make
wp-contextinheritable and extensible #139 - Create constants file for
wp-prefixes #142 - Serialize store in PHP #147
- Handle missing class attribute inside
wp-class#149 - Add
wp-showdirective attribute #156 - Add client-side navigation support for
wp-ignoredirective #163 - wp-bind improvements and negation in runtime #213
- 🎨 Switch toVdom from array iteration to createTreeWalker #103
- Fetch scripts in the
<head>on client-side navigations #164 - Add server side negation operator #214
- Add a
useSignalEffectimplementation that behaves likeuseEffect#226
In progress
Next
- Merge new SSR state on client-side navigation #154
- Merge new SSR context on client-side navigation #155
- Automatically detect if a block is using directives #126
- Add lazy hydration techniques: idle and view #75
- Router: cancel navigation when another starts #192
- Remove directive tags (components) from the proposal #152
Decisions that need to be made
- Find a better name for
wpx()(needed for the announcement blog post) - Remove directive tags (components) from the proposal #152 (needed for the announcement blog post)
- Decide on whether to follow the HTML spec or not (needed for the announcement blog post)
- Decide the name of the client-side navigation meta tag.
- Find a way to use Preact's JSX pragma in the
view.jsfiles with backward compatibility. - Decide whether
"interactive: true"should be optional or not in theblock.json. - Decide how to use namespaces in the store #138 (needed for the announcement blog post)
- Decide the name of the npm package, like
@wordpress/interactivity. #146 -
Figure out how the store will work in static blocks: it won't. - Figure out how we can pass objects to wp-context instead of a stringified JSON (in PHP and JS).
- Decide if
wp-bind:valueshould be bidirectional in inputs. - Find names for the full/partial/isolated hydration types.
- Decide if we should use
client-side transitionsorclient-side navigation: we'll useclient-side navigationfrom now on -
Figure out how to use context inside the derived state: we'll use selectors - Decide on whether to use
componentsor not: we won't - Decide on the name of this repo. Something like
interactivity-api-proposal. (needed for the announcement blog post) - Is registering the
block.jsonin the server a requirement? - Is a single top-level node a requirement?
- What should be the HTML structure returned when
wp-showis false? #159 - Decide how to name the DOM element that is passed down to the references (right now it's called
ref) - Decide if we want to expose some parts of the router and/or other configuration in the store #160 (needed for the announcement blog post)
- Decide what pattern we should use for "multiple render path" directives like
wp-error-boundaryorwp-suspense - Decide if we need to name
wp-htmlwith a word the warns about its risks, likewp-dangerous-html
Experiments
- Experiment: Client-side navigation of the Query Loop block using directives gutenberg#44034
- Experiment: Client side navigations in the Product Query block woocommerce/woocommerce-blocks#7187
- Experiment: Replicate Navigation block using directives gutenberg#44509
- https://github.com/woocommerce/woocommerce-blocks/issues/8219
- Experiment: use the Interactivity API to do client-side form submissions gutenberg#49305
- Experiment: Add lightbox to Image block using directives gutenberg#49621
Activity
luisherranz commentedon Oct 14, 2022
I've opened the
main-wp-directives-pluginbranch with a basic skeleton of a plugin, including a basicwebpackconfiguration and enqueuing of the runtime/vendor scripts.luisherranz commentedon Oct 14, 2022
I've added some basic tasks to the OP to get the client-side navigations working, which is our first task.
These two experiments contain much of the required code:
We should rename
wp-client-transitiontowp-link.SantosGuillamot commentedon Oct 17, 2022
I have created a Pull Request to "Add the wp-link to all the relative links on the page". It is still a draft, but I opened it to keep the discussion about that specific task there.
luisherranz commentedon Oct 17, 2022
I've created a pull request to add the basic vdom + directives functionality.
I'll now create another one for the router +
wp-link.luisherranz commentedon Oct 17, 2022
I've created the pull request to add the router and the
wp-linkdirective.luisherranz commentedon Oct 17, 2022
I've created another pull request to change the
toVdomlogic to test removing the comment nodes and preserving the script's children:DAreRodz commentedon Oct 18, 2022
I'll be working on adding page transitions to the client-side navigations using the Shared Element Transition API. I'll share here a link to the PR soon.
luisherranz commentedon Oct 19, 2022
I've created a PR to add support for CSS loading during client-side navigations:
luisherranz commentedon Oct 19, 2022
I've opened a PR to add a basic opt-in mechanism based on a custom meta tag:
SantosGuillamot commentedon Oct 19, 2022
I've opened a PR to add
prefetchto all links and prevent scrolling in the pagination:prefetchto all links and prevent scroll in pagination #87While doing that, we realized that the HTML of the parent blocks contains the children, so we were parsing the HTML multiple times. For that, we change the filters to only trigger for the Query Loop and the Template Parts until we figure out a better solution.
luisherranz commentedon Oct 19, 2022
Another PR to add an admin page with a checkbox to toggle client-side navigations (for testing purposes only):
luisherranz commentedon Oct 21, 2022
I did a couple of bug fixes that we noticed while working on this demo:
luisherranz commentedon Oct 26, 2022
I've opened an issue to talk about limiting the hydration surface when the site doesn't support client-side navigations:
29 remaining items
luisherranz commentedon Mar 13, 2023
I've opened a couple of issues, one to make the hydration more resilient (and make it work with
template) and the other to see how we could integrate the new View Transitions API:luisherranz commentedon Mar 23, 2023
It's very preliminary yet, but @DAreRodz and I have started an experiment to do client-side form submissions on the Comments Form block:
luisherranz commentedon Mar 23, 2023
Added this to the list, mentioned by @tomjn here:
luisherranz commentedon Mar 27, 2023
Another issue related to the router:
michalczaplinski commentedon Mar 27, 2023
I've reopened
because it became clear that
wp_storeis not the right final name. It would be amazing if we could decide before publishing the blog post introducing the Interactivity API because having a bad name is easy for people to nitpick.Realistically, we might need more time, though 🙂
luisherranz commentedon Mar 28, 2023
We finished the basic functionality of the Comments Form submission experiment:
luisherranz commentedon Apr 12, 2023
@artemiomorales started this experiment of a lightbox for images, similar to the one in Medium:
luisherranz commentedon Apr 14, 2023
I've added support for the
!operator:"!state.boolean"I've also improved the logic of
data-wp-bindand added some e2e tests.luisherranz commentedon Apr 20, 2023
I finally merged the
createTreeWalkerversion:@DAreRodz and I have also started working on a branch to simplify the runtime so we can start testing it with core blocks:
DAreRodz commentedon May 8, 2023
I haven't opened a PR yet, but I just started working on sorting directives by priority. I'll update this comment with the PR link soon.
luisherranz commentedon May 15, 2023
We also merged this fix:
useSignalEffectimplementation that behaves likeuseEffect#226luisherranz commentedon Jul 28, 2023
I'm going to close this issue as part of the migration to the Gutenberg repository.
This is the current Tracking Issue on Gutenberg. Please refer to it from now on.