UNPKG

@knapsack/app

Version:

Build Design Systems with Knapsack

84 lines 2.73 kB
import { type LazyExoticComponent, type FC } from 'react'; import type { KsAppClientData, PluginMeta } from '@knapsack/types'; import { type KnapsackBrain } from './brain'; export type { MetaState, PluginMeta } from '@knapsack/types'; export type KsPluginPageProps<T> = { content?: T; }; export type KsPluginPage<T> = FC<KsPluginPageProps<T>>; export interface KsPluginPageConfig<T = any> { path: string; title?: string; section?: string; navItem?: { nav: 'primarySub'; title: string; }; /** * A lazy loaded React component * @example const Page = React.lazy(() => import('./pages')) */ Page: LazyExoticComponent<KsPluginPage<T>> | FC<KsPluginPageProps<T>>; } export interface KsClientPlugin<ServerPluginContent = any> { id: string; title?: string; description?: string; /** * @link {https://developers.google.com/gtagjs/reference/event} * @link {https://developers.google.com/gtagjs/reference/aw-events} * @link {https://support.google.com/firebase/answer/6317498?hl=en&ref_topic=6317484} */ addPages?: () => KsPluginPageConfig<ServerPluginContent>[]; } export interface KsClientPluginContext { pluginMeta: PluginMeta; } export type KsPluginLoadFunc<ServerPluginContent = any> = (context: KsClientPluginContext) => Promise<KsClientPlugin<ServerPluginContent>>; export interface KsServerPlugin<T = any> { id: string; title?: string; description?: string; /** * An absolute path to a directory that will be the public directory for the plugin, accessible at: `/plugins/ID` */ publicDir?: string; /** * Subpath for a browser `import()` to get a default export that is a function that returns a `KsClientPlugin`. * Must be inside `publicDir` * Passing `'client/index.js'` in a plugin with id "hi" would be retrieved via `import('/plugins/hi/client.js')` * @example `'client/index.js'` */ clientPluginPath?: string; /** @deprecated */ cssPath?: string; /** * Plugins receive brain after core brain and template renderers have fired `init()` */ init?( /** * The Knapsack Brain */ brain: KnapsackBrain): Promise<void>; loadContent?(): Promise<T>; /** * Ran after new data saved (i.e. POST /api/v1)data-store */ onDataUpdated?(opt: { /** * The Knapsack Brain */ brain: KnapsackBrain; state?: KsAppClientData; }): Promise<void>; /** * Ran when a full build is running ks build */ onBuild?(opt: { /** * The Knapsack Brain */ brain: KnapsackBrain; }): Promise<void>; } //# sourceMappingURL=plugins.d.ts.map