mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-06 00:22:58 +00:00
28 lines
819 B
TypeScript
28 lines
819 B
TypeScript
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
|
|
//
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
import { createElement as h, useContext, createContext, type FunctionComponent, type ReactNode } from "react";
|
|
|
|
export type DataExport = {
|
|
readonly itemNames: Record<string, string>,
|
|
readonly recipes: Record<string, Recipe>,
|
|
};
|
|
|
|
export type Recipe = {
|
|
readonly inputs: Array<Array<string>>,
|
|
readonly output: string,
|
|
readonly count: number,
|
|
};
|
|
|
|
const DataExport = createContext<DataExport>({
|
|
itemNames: {},
|
|
recipes: {},
|
|
});
|
|
|
|
export const useExport = () => useContext(DataExport);
|
|
export default useExport;
|
|
|
|
export const WithExport: FunctionComponent<{ data: DataExport, children: ReactNode }> =
|
|
({ data, children }) => <DataExport.Provider value={data}> {children}</DataExport.Provider >;
|