UNPKG

next-csrf

Version:

CSRF mitigation library for Next.js

44 lines (36 loc) 1.1 kB
"use strict"; exports.__esModule = true; exports["default"] = flushToReact; exports.flushToHTML = flushToHTML; var _react = _interopRequireDefault(require("react")); var _style = require("./style"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function flushToReact(options) { if (options === void 0) { options = {}; } return (0, _style.flush)().map(function (args) { var id = args[0]; var css = args[1]; return _react["default"].createElement('style', { id: "__" + id, // Avoid warnings upon render with a key key: "__" + id, nonce: options.nonce ? options.nonce : undefined, dangerouslySetInnerHTML: { __html: css } }); }); } function flushToHTML(options) { if (options === void 0) { options = {}; } return (0, _style.flush)().reduce(function (html, args) { var id = args[0]; var css = args[1]; html += "<style id=\"__" + id + "\"" + (options.nonce ? " nonce=\"" + options.nonce + "\"" : '') + ">" + css + "</style>"; return html; }, ''); }