Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 19 additions & 15 deletions packages/interactivity-router/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
parseServerData,
populateServerData,
batch,
initDone,
} = privateApis(
'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'
);
Expand Down Expand Up @@ -188,21 +189,24 @@ window.addEventListener( 'popstate', async () => {
}
} );

// Initialize the router and cache the initial page using the initial vDOM.
// Once this code is tested and more mature, the head should be updated for
// region based navigation as well.
window.document
.querySelectorAll< HTMLScriptElement >( 'script[type=module][src]' )
.forEach( ( { src } ) => markScriptModuleAsResolved( src ) );
pages.set(
getPagePath( window.location.href ),
Promise.resolve(
regionsToVdom( document, {
vdom: initialVdom,
url: getPagePath( window.location.href ),
} )
)
);
( async () => {
await initDone;
// Initialize the router and cache the initial page using the initial vDOM.
// Once this code is tested and more mature, the head should be updated for
// region based navigation as well.
window.document
.querySelectorAll< HTMLScriptElement >( 'script[type=module][src]' )
.forEach( ( { src } ) => markScriptModuleAsResolved( src ) );
pages.set(
getPagePath( window.location.href ),
Promise.resolve(
regionsToVdom( document, {
vdom: initialVdom,
url: getPagePath( window.location.href ),
} )
)
);
} )();

// Check if the link is valid for client-side navigation.
const isValidLink = ( ref: HTMLAnchorElement ) =>
Expand Down
3 changes: 2 additions & 1 deletion packages/interactivity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export const privateApis = ( lock ): any => {
parseServerData,
populateServerData,
batch,
initDone,
};
}

throw new Error( 'Forbidden access.' );
};

registerDirectives();
init();
const initDone = init();
Loading