-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed tests; split options type module
- Loading branch information
Showing
10 changed files
with
110 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { isObject } from "@/utils/isObject"; | ||
import { isFunction } from "@/utils/isFunction"; | ||
|
||
/** | ||
* The host store represents an interface to the state of | ||
* the application that is using Chartlets. | ||
*/ | ||
export interface HostStore { | ||
/** | ||
* Let Chartlets listen to changes in the host store that may | ||
* cause different values to be returned from the `get()` method. | ||
* | ||
* @param listener A listener that is called when the | ||
* host store changes | ||
*/ | ||
subscribe: (listener: () => void) => void; | ||
|
||
/** | ||
* Get a property value from the host state. | ||
* | ||
* @param property The property name. | ||
* @returns The property value. | ||
*/ | ||
get: (property: string) => unknown; | ||
|
||
/** | ||
* **UNSTABLE API** | ||
* | ||
* Set a property value in the host state. | ||
* | ||
* @param property The property name. | ||
* @param value The new property value. | ||
*/ | ||
set?: (property: string, value: unknown) => void; | ||
} | ||
|
||
/** | ||
* A mutable host store implements the `set()` method. | ||
*/ | ||
export interface MutableHostStore extends HostStore { | ||
/** | ||
* **UNSTABLE API** | ||
* | ||
* Set a property value in the host state. | ||
* | ||
* @param property The property name. | ||
* @param value The new property value. | ||
*/ | ||
set: (property: string, value: unknown) => void; | ||
} | ||
|
||
export function isHostStore(value: unknown): value is HostStore { | ||
return ( | ||
isObject(value) && isFunction(value.get) && isFunction(value.subscribe) | ||
); | ||
} | ||
|
||
export function isMutableHostStore(value: unknown): value is MutableHostStore { | ||
return isHostStore(value) && isFunction(value.set); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { ComponentType } from "react"; | ||
import type { ComponentProps } from "@/components/Component"; | ||
|
||
/** | ||
* A component registration - a pair comprising the component type name | ||
* and the React component. | ||
*/ | ||
export type ComponentRegistration = [string, ComponentType<ComponentProps>]; | ||
|
||
/** | ||
* A framework plugin. | ||
* Plugins are no-arg functions that are called | ||
* after the framework's initialisation. | ||
* Most typically, a plugin wants to return new components | ||
* in the `components` array: | ||
* `{ components: [["MyComponent", MyComponent]] }`. | ||
*/ | ||
export interface Plugin { | ||
components?: ComponentRegistration[]; | ||
} | ||
|
||
/** | ||
* An object of type `Plugin`, or a function that returns a | ||
* value that can be resolved to a `Plugin`, | ||
* or a promise that resolves to a value that can be | ||
* resolved to a `Plugin`. | ||
*/ | ||
export type PluginLike = Plugin | (() => PluginLike) | Promise<PluginLike>; |