mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 11:00:47 +02:00
# Description of Changes Move frontend code into `core` folder and add infrastructure for `proprietary` folder to include premium, non-OSS features
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { useMemo } from 'react';
|
|
|
|
import type { ToolId } from '@app/types/toolId';
|
|
import type { ToolRegistry } from '@app/data/toolsTaxonomy';
|
|
import ToolRegistryContext, { ToolRegistryCatalog } from '@app/contexts/ToolRegistryContext';
|
|
import { useTranslatedToolCatalog } from '@app/data/useTranslatedToolRegistry';
|
|
|
|
interface ToolRegistryProviderProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export const ToolRegistryProvider: React.FC<ToolRegistryProviderProps> = ({ children }) => {
|
|
const catalog = useTranslatedToolCatalog();
|
|
|
|
const contextValue = useMemo<ToolRegistryCatalog>(() => {
|
|
const { regularTools, superTools, linkTools } = catalog;
|
|
const allTools: ToolRegistry = {
|
|
...regularTools,
|
|
...superTools,
|
|
...linkTools,
|
|
};
|
|
|
|
const getToolById = (toolId: ToolId | null) => {
|
|
if (!toolId) {
|
|
return null;
|
|
}
|
|
return allTools[toolId] ?? null;
|
|
};
|
|
|
|
return {
|
|
regularTools,
|
|
superTools,
|
|
linkTools,
|
|
allTools,
|
|
getToolById,
|
|
};
|
|
}, [catalog]);
|
|
|
|
return (
|
|
<ToolRegistryContext.Provider value={contextValue}>
|
|
{children}
|
|
</ToolRegistryContext.Provider>
|
|
);
|
|
};
|