UNPKG

@botonic/react

Version:

Build Chatbots using React

31 lines 1.3 kB
import { __awaiter } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { CoreBot } from '@botonic/core'; import { Text } from './components/text'; import { RequestContext } from './contexts'; export class ReactBot extends CoreBot { constructor(options) { super(Object.assign({ defaultRoutes: [ { path: '404', action: () => _jsx(Text, { children: "I don't understand you" }), // eslint-disable-line }, ], renderer: (args) => this.renderReactActions(args) }, options)); } renderReactActions({ request, actions }) { return __awaiter(this, void 0, void 0, function* () { const renderedActions = []; for (const Action of actions) { if (Action) { const props = Action.botonicInit ? yield Action.botonicInit(request) : {}; const renderedAction = (_jsx(RequestContext.Provider, Object.assign({ value: request }, { children: _jsx(Action, Object.assign({}, props)) }))); renderedActions.push(renderedAction); } } return renderedActions; }); } } //# sourceMappingURL=react-bot.js.map