diff --git a/src/index.ts b/src/index.ts index f5d9641..1c4097f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,12 @@ import phantom from "./phantom"; import createPhantomStore from "./createPhantomStore"; // types -export { - PhantomElement, - PhantomDOMFunction, - PhantomDOM, -} from "./types/phantomDOM"; // phantomDOM +export { PhantomElement, PhantomComponent, PhantomDOM } from "./types/phantom"; export { PhantomAction, PhantomReducer, Subscription, -} from "./types/phantomStore"; // phantomStore +} from "./types/phantomStore"; export { createPhantomStore }; export default phantom; diff --git a/src/phantom.ts b/src/phantom.ts index 4e77e8c..6476c38 100644 --- a/src/phantom.ts +++ b/src/phantom.ts @@ -1,14 +1,17 @@ import { PhantomStore } from "./types/phantomStore"; -import { Phantom } from "./types/phantom"; - import { - PhantomDOMFunction, + Phantom, + PhantomComponent, PhantomDOM, PhantomElement, -} from "./types/phantomDOM"; +} from "./types/phantom"; + import phantomExorciser from "./phantomExorciser"; -function PHANTOM(phantomStore: PhantomStore, PhantomDOM: PhantomDOMFunction) { +function PHANTOM( + phantomStore: PhantomStore, + phantomComponent: PhantomComponent +) { let phantomDOM: PhantomDOM = { test: { tagName: "div", @@ -40,7 +43,7 @@ function PHANTOM(phantomStore: PhantomStore, PhantomDOM: PhantomDOMFunction) { function coalescePhantomDOM() { return `
- ${PhantomDOM()} + ${phantomComponent()}
`; } diff --git a/src/types/phantom.ts b/src/types/phantom.ts index 4cbafa6..1072e81 100644 --- a/src/types/phantom.ts +++ b/src/types/phantom.ts @@ -3,10 +3,25 @@ import { PhantomStore, FireFunction, } from "./phantomStore"; -import { PhantomDOMFunction } from "./phantomDOM"; + +export type PhantomElement = { + tagName: string; + attributes: { id?: string | number; class?: string | DOMTokenList }; + children: PhantomElement[] | []; + innerHTML: string; + dataset?: DOMTokenList | {}; +}; + +export type PhantomComponent = { + (): string; +}; + +export type PhantomDOM = { + [key: string]: PhantomElement; +}; export type Phantom = { - (phantomStore: PhantomStore, phantomElement: PhantomDOMFunction): { + (phantomStore: PhantomStore, phantomElement: PhantomComponent): { fire: FireFunction; data: () => any; appear: () => HTMLElement; diff --git a/src/types/phantomDOM.ts b/src/types/phantomDOM.ts deleted file mode 100644 index 3f47f42..0000000 --- a/src/types/phantomDOM.ts +++ /dev/null @@ -1,15 +0,0 @@ -export type PhantomElement = { - tagName: string; - attributes: { id?: string | number; class?: string | DOMTokenList }; - children: PhantomElement[] | []; - innerHTML: string; - dataset?: DOMTokenList | {}; -}; - -export type PhantomDOMFunction = { - (): string; -}; - -export type PhantomDOM = { - [key: string]: PhantomElement; -};