fix: export navigate and prefetch from @woocommerce/interactivity

This commit is contained in:
Tung Du 2024-09-03 09:52:38 +07:00
parent 90abc56862
commit 6efc9bee2b
2 changed files with 22 additions and 21 deletions

View File

@ -17,8 +17,8 @@ import { directive } from './hooks';
import { getNamespace } from './namespaces';
import { parseServerData, populateServerData } from './store';
import { proxifyState } from './proxies';
import { actions } from './router';
export { navigate } from './router';
export { store, getConfig } from './store';
export { getContext, getElement } from './scopes';
export {
@ -34,6 +34,8 @@ export {
export { useState, useRef } from 'preact/hooks';
export const { navigate, prefetch } = actions;
const requiredConsent =
'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.';

View File

@ -2,20 +2,14 @@
* Internal dependencies
*/
import { fetchHeadAssets, updateHead } from './head';
import { store, privateApis, getConfig } from './index';
const {
directivePrefix,
getRegionRootFragment,
initialVdom,
toVdom,
render,
parseServerData,
populateServerData,
batch,
} = privateApis(
'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'
);
import { render } from 'preact';
import { batch } from '@preact/signals';
import { getRegionRootFragment, initialVdom } from './init';
import { directivePrefix } from './constants';
import { toVdom } from './vdom';
import { parseServerData, populateServerData } from './store';
import { store, getConfig } from './store';
interface NavigateOptions {
force?: boolean;
@ -166,13 +160,18 @@ window.addEventListener( 'popstate', async () => {
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
if ( navigationMode === 'fullPage' ) {
// Cache the scripts. Has to be called before fetching the assets.
[].map.call( document.querySelectorAll( 'script[src]' ), ( script ) => {
headElements.set( script.getAttribute( 'src' ), {
tag: script,
text: script.textContent,
} );
document.addEventListener( 'DOMContentLoaded', async function () {
[].map.call(
document.querySelectorAll( 'script[src]' ),
( script ) => {
headElements.set( script.getAttribute( 'src' ), {
tag: script,
text: script.textContent,
} );
}
);
await fetchHeadAssets( document, headElements );
} );
await fetchHeadAssets( document, headElements );
}
}
pages.set(
@ -205,7 +204,7 @@ const isValidEvent = ( event: MouseEvent ) =>
// Variable to store the current navigation.
let navigatingTo = '';
export const { state, actions } = store( 'core/router', {
export const { state, actions } = store( 'woocommerce/router', {
state: {
url: window.location.href,
navigation: {