diff --git a/src/runtime/components.js b/src/runtime/components.js deleted file mode 100644 index 86d7581f..00000000 --- a/src/runtime/components.js +++ /dev/null @@ -1,22 +0,0 @@ -import { useMemo, useContext } from 'preact/hooks'; -import { deepSignal } from 'deepsignal'; -import { component } from './hooks'; - -export default () => { - // - const Context = ({ children, data, context: { Provider } }) => { - const signals = useMemo(() => deepSignal(JSON.parse(data)), [data]); - return {children}; - }; - component('context', Context); - - // - const Show = ({ children, when, evaluate, context }) => { - const contextValue = useContext(context); - if (evaluate(when, { context: contextValue })) { - return children; - } - return ; - }; - component('show', Show); -}; diff --git a/src/runtime/constants.js b/src/runtime/constants.js index 66aa7817..b6ec99e5 100644 --- a/src/runtime/constants.js +++ b/src/runtime/constants.js @@ -1,3 +1,2 @@ export const csnMetaTagItemprop = 'wp-client-side-navigation'; -export const componentPrefix = 'wp-'; export const directivePrefix = 'data-wp-'; diff --git a/src/runtime/hooks.js b/src/runtime/hooks.js index 3bd380bd..4f5aebea 100644 --- a/src/runtime/hooks.js +++ b/src/runtime/hooks.js @@ -1,7 +1,6 @@ import { h, options, createContext } from 'preact'; import { useRef } from 'preact/hooks'; import { rawStore as store } from './store'; -import { componentPrefix } from './constants'; // Main context. const context = createContext({}); @@ -12,12 +11,6 @@ export const directive = (name, cb) => { directiveMap[name] = cb; }; -// WordPress Components. -const componentMap = {}; -export const component = (name, Comp) => { - componentMap[name] = Comp; -}; - // Resolve the path to some property of the store object. const resolve = (path, ctx) => { // If path starts with !, remove it and save a flag. @@ -60,19 +53,9 @@ const Directive = ({ type, directives, props: originalProps }) => { // Preact Options Hook called each time a vnode is created. const old = options.vnode; options.vnode = (vnode) => { - const type = vnode.type; const { directives } = vnode.props; - if ( - typeof type === 'string' && - type.slice(0, componentPrefix.length) === componentPrefix - ) { - vnode.props.children = h( - componentMap[type.slice(componentPrefix.length)], - { ...vnode.props, context, evaluate: getEvaluate() }, - vnode.props.children - ); - } else if (directives) { + if (directives) { const props = vnode.props; delete props.directives; if (!props._wrapped) { diff --git a/src/runtime/index.js b/src/runtime/index.js index 93d4e455..f6fae3ac 100644 --- a/src/runtime/index.js +++ b/src/runtime/index.js @@ -1,5 +1,4 @@ import registerDirectives from './directives'; -import registerComponents from './components'; import { init } from './router'; export { store } from './store'; export { navigate } from './router'; @@ -9,7 +8,6 @@ export { navigate } from './router'; */ document.addEventListener('DOMContentLoaded', async () => { registerDirectives(); - registerComponents(); await init(); // eslint-disable-next-line no-console console.log('Interactivity API started');