react-ssr-web
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -1,1 +0,1 @@ | ||
import{renderToString as r}from"react-dom/server";import{StaticRouter as t}from"react-router-dom/server";import{Routes as e}from"react-router-dom";import{renderRoutes as o}from"react-router-layout";import{HelmetProvider as n}from"react-helmet-async";import i from"serialize-javascript";import{RootContextProvider as c,createServerStore as a}from"react-reducer-ssr";import{I18nextProvider as u}from"react-i18next";import{jsx as s}from"react/jsx-runtime";import{matchRoutes as f}from"react-router";import l from"parseurl";import p from"fs";var m=function(a,f,l,p,m){var d=function(r){var t,e=null===(t=r.i18n)||void 0===t||null===(t=t.languages)||void 0===t?void 0:t[0],o={},n=r.i18n.reportNamespaces.getUsedNamespaces();return r.i18n.languages.forEach((function(t){o[t]={},n.forEach((function(e){o[t][e]=r.i18n.services.resourceStore.data[t][e]}))})),{initialLanguage:e,initialI18nStore:o}}(p),v=d.initialLanguage,y=d.initialI18nStore,b={},h=s(u,{i18n:p.i18n,children:s(t,{location:p.url,children:s(n,{context:b,children:s(c,{reducer:a,initialState:null==m?void 0:m.root,children:s(e,{children:o(l)})})})})}),g=r(h),O="production"===process.env.NODE_ENV?'<script src="/static/js/service-worker.js" defer><\/script>':"",w=b.helmet,S=w&&w.title?w.title.toString():"",j=w&&w.meta?w.meta.toString():"";return f.replace('<div id="app"></div>','<div id="app">'.concat(g,"</div>\n <script>\n window.INITIAL_STATE = ").concat(i(m.root),";\n window.INITIAL_LANGUAGE = '").concat(v,"';\n window.INITIAL_I18N_STORE = ").concat(i(y),";\n <\/script>\n ").concat(O)).replace("\x3c!-- META --\x3e","".concat(S,"\n ").concat(j))};function d(r){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},d(r)}function v(r){var t=function(r,t){if("object"!=d(r)||!r)return r;var e=r[Symbol.toPrimitive];if(void 0!==e){var o=e.call(r,t||"default");if("object"!=d(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==d(t)?t:t+""}function y(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.push.apply(e,o)}return e}function b(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?y(Object(e),!0).forEach((function(t){var o,n,i;o=r,n=t,i=e[t],(n=v(n))in o?Object.defineProperty(o,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):o[n]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):y(Object(e)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))}))}return r}var h=function(r,t,e,o){return function(n,i,c){var u=l(n),s=u?u.search:"",d=u?u.pathname:"",v=b({},n.cookies),y=b({},n.cookies),h=o?{services:o(y)}:{},O=a(t,h,{}),w=p.readFileSync(r,"utf8"),S=f(e,d||"");if(!S)return i.statusCode=404,void c("Not found");var j=S.map((function(r){var t=r.route;return t.loadData?t.loadData(O.dispatch,y,s):null})).map((function(r){if(r)return new Promise((function(t){r.then(t).catch(t)}))}));Promise.all(j).then((function(){var r=m(t,w,e,n,O),o=function(r,t){var e={};for(var o in t)r[o]!==t[o]&&(e[o]=t[o]);return e}(v,y);for(var a in o)i.cookie(a,o[a]);g(i,r),c()})).catch((function(r){g(i,"Error happens: "+r),c()}))}};function g(r,t){r.statusCode=r.statusCode||200,r.setHeader("Content-Type","text/html; charset=UTF-8"),r.setHeader("X-Powered-By","react-ssr-web"),r.end(t)}export{h as reactSsr,m as renderHtml}; | ||
import{renderToString as r}from"react-dom/server";import{StaticRouter as t}from"react-router-dom/server";import{Routes as e}from"react-router-dom";import{renderRoutes as o}from"react-router-layout";import{HelmetProvider as n}from"react-helmet-async";import i from"serialize-javascript";import{RootContextProvider as c,createServerStore as a}from"react-reducer-ssr";import{I18nextProvider as u}from"react-i18next";import{jsx as s}from"react/jsx-runtime";import{matchRoutes as l}from"react-router";import f from"parseurl";import p from"fs";var m=function(a,l,f,p,m){var d=function(r){var t,e,o,n=null===(t=r.i18n)||void 0===t||null===(t=t.languages)||void 0===t?void 0:t[0],i={},c=null!==(e=r.i18n)&&void 0!==e&&e.reportNamespaces?null===(o=r.i18n)||void 0===o?void 0:o.reportNamespaces.getUsedNamespaces():[];return r.i18n.languages.forEach((function(t){i[t]={},c.forEach((function(e){i[t][e]=r.i18n.services.resourceStore.data[t][e]}))})),{initialLanguage:n,initialI18nStore:i}}(p),v=d.initialLanguage,y=d.initialI18nStore,b={},h=s(u,{i18n:p.i18n,children:s(t,{location:p.url,children:s(n,{context:b,children:s(c,{reducer:a,initialState:null==m?void 0:m.root,children:s(e,{children:o(f)})})})})}),g=r(h),O="production"===process.env.NODE_ENV?'<script src="/static/js/service-worker.js" defer><\/script>':"",w=b.helmet,S=w&&w.title?w.title.toString():"",j=w&&w.meta?w.meta.toString():"";return l.replace('<div id="app"></div>','<div id="app">'.concat(g,"</div>\n <script>\n window.INITIAL_STATE = ").concat(i(m.root),";\n window.INITIAL_LANGUAGE = '").concat(v,"';\n window.INITIAL_I18N_STORE = ").concat(i(y),";\n <\/script>\n ").concat(O)).replace("\x3c!-- META --\x3e","".concat(S,"\n ").concat(j))};function d(r){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},d(r)}function v(r){var t=function(r,t){if("object"!=d(r)||!r)return r;var e=r[Symbol.toPrimitive];if(void 0!==e){var o=e.call(r,t||"default");if("object"!=d(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==d(t)?t:t+""}function y(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.push.apply(e,o)}return e}function b(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?y(Object(e),!0).forEach((function(t){var o,n,i;o=r,n=t,i=e[t],(n=v(n))in o?Object.defineProperty(o,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):o[n]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):y(Object(e)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))}))}return r}var h=function(r,t,e,o){return function(n,i,c){var u=f(n),s=u?u.search:"",d=u?u.pathname:"",v=b({},n.cookies),y=b({},n.cookies),h=o?{services:o(y)}:{},O=a(t,h,{}),w=p.readFileSync(r,"utf8"),S=l(e,d||"");if(!S)return i.statusCode=404,void c("Not found");var j=S.map((function(r){var t=r.route;return t.loadData?t.loadData(O.dispatch,y,s):null})).map((function(r){if(r)return new Promise((function(t){r.then(t).catch(t)}))}));Promise.all(j).then((function(){var r=m(t,w,e,n,O),o=function(r,t){var e={};for(var o in t)r[o]!==t[o]&&(e[o]=t[o]);return e}(v,y);for(var a in o)i.cookie(a,o[a]);g(i,r),c()})).catch((function(r){g(i,"Error happens: "+r),c()}))}};function g(r,t){r.statusCode=r.statusCode||200,r.setHeader("Content-Type","text/html; charset=UTF-8"),r.setHeader("X-Powered-By","react-ssr-web"),r.end(t)}export{h as reactSsr,m as renderHtml}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("react-dom/server"),r=require("react-router-dom/server"),t=require("react-router-dom"),n=require("react-router-layout"),o=require("react-helmet-async"),i=require("serialize-javascript"),c=require("react-reducer-ssr"),a=require("react-i18next"),u=require("react/jsx-runtime"),s=require("react-router"),l=require("parseurl"),f=require("fs");var d=function(s,l,f,d,p){var v=function(e){var r,t=null===(r=e.i18n)||void 0===r||null===(r=r.languages)||void 0===r?void 0:r[0],n={},o=e.i18n.reportNamespaces.getUsedNamespaces();return e.i18n.languages.forEach((function(r){n[r]={},o.forEach((function(t){n[r][t]=e.i18n.services.resourceStore.data[r][t]}))})),{initialLanguage:t,initialI18nStore:n}}(d),m=v.initialLanguage,y=v.initialI18nStore,b={},h=u.jsx(a.I18nextProvider,{i18n:d.i18n,children:u.jsx(r.StaticRouter,{location:d.url,children:u.jsx(o.HelmetProvider,{context:b,children:u.jsx(c.RootContextProvider,{reducer:s,initialState:null==p?void 0:p.root,children:u.jsx(t.Routes,{children:n.renderRoutes(f)})})})})}),g=e.renderToString(h),j="production"===process.env.NODE_ENV?'<script src="/static/js/service-worker.js" defer><\/script>':"",S=b.helmet,O=S&&S.title?S.title.toString():"",w=S&&S.meta?S.meta.toString():"";return l.replace('<div id="app"></div>','<div id="app">'.concat(g,"</div>\n <script>\n window.INITIAL_STATE = ").concat(i(p.root),";\n window.INITIAL_LANGUAGE = '").concat(m,"';\n window.INITIAL_I18N_STORE = ").concat(i(y),";\n <\/script>\n ").concat(j)).replace("\x3c!-- META --\x3e","".concat(O,"\n ").concat(w))};function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function v(e){var r=function(e,r){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==p(r)?r:r+""}function m(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?m(Object(t),!0).forEach((function(r){var n,o,i;n=e,o=r,i=t[r],(o=v(o))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):m(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(e,r){e.statusCode=e.statusCode||200,e.setHeader("Content-Type","text/html; charset=UTF-8"),e.setHeader("X-Powered-By","react-ssr-web"),e.end(r)}exports.reactSsr=function(e,r,t,n){return function(o,i,a){var u=l(o),p=u?u.search:"",v=u?u.pathname:"",m=y({},o.cookies),h=y({},o.cookies),g=n?{services:n(h)}:{},j=c.createServerStore(r,g,{}),S=f.readFileSync(e,"utf8"),O=s.matchRoutes(t,v||"");if(!O)return i.statusCode=404,void a("Not found");var w=O.map((function(e){var r=e.route;return r.loadData?r.loadData(j.dispatch,h,p):null})).map((function(e){if(e)return new Promise((function(r){e.then(r).catch(r)}))}));Promise.all(w).then((function(){var e=d(r,S,t,o,j),n=function(e,r){var t={};for(var n in r)e[n]!==r[n]&&(t[n]=r[n]);return t}(m,h);for(var c in n)i.cookie(c,n[c]);b(i,e),a()})).catch((function(e){b(i,"Error happens: "+e),a()}))}},exports.renderHtml=d; | ||
"use strict";var e=require("react-dom/server"),r=require("react-router-dom/server"),t=require("react-router-dom"),n=require("react-router-layout"),o=require("react-helmet-async"),i=require("serialize-javascript"),c=require("react-reducer-ssr"),a=require("react-i18next"),u=require("react/jsx-runtime"),s=require("react-router"),l=require("parseurl"),d=require("fs");var f=function(s,l,d,f,p){var v=function(e){var r,t,n,o=null===(r=e.i18n)||void 0===r||null===(r=r.languages)||void 0===r?void 0:r[0],i={},c=null!==(t=e.i18n)&&void 0!==t&&t.reportNamespaces?null===(n=e.i18n)||void 0===n?void 0:n.reportNamespaces.getUsedNamespaces():[];return e.i18n.languages.forEach((function(r){i[r]={},c.forEach((function(t){i[r][t]=e.i18n.services.resourceStore.data[r][t]}))})),{initialLanguage:o,initialI18nStore:i}}(f),m=v.initialLanguage,y=v.initialI18nStore,b={},h=u.jsx(a.I18nextProvider,{i18n:f.i18n,children:u.jsx(r.StaticRouter,{location:f.url,children:u.jsx(o.HelmetProvider,{context:b,children:u.jsx(c.RootContextProvider,{reducer:s,initialState:null==p?void 0:p.root,children:u.jsx(t.Routes,{children:n.renderRoutes(d)})})})})}),g=e.renderToString(h),j="production"===process.env.NODE_ENV?'<script src="/static/js/service-worker.js" defer><\/script>':"",S=b.helmet,O=S&&S.title?S.title.toString():"",w=S&&S.meta?S.meta.toString():"";return l.replace('<div id="app"></div>','<div id="app">'.concat(g,"</div>\n <script>\n window.INITIAL_STATE = ").concat(i(p.root),";\n window.INITIAL_LANGUAGE = '").concat(m,"';\n window.INITIAL_I18N_STORE = ").concat(i(y),";\n <\/script>\n ").concat(j)).replace("\x3c!-- META --\x3e","".concat(O,"\n ").concat(w))};function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function v(e){var r=function(e,r){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==p(r)?r:r+""}function m(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?m(Object(t),!0).forEach((function(r){var n,o,i;n=e,o=r,i=t[r],(o=v(o))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):m(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(e,r){e.statusCode=e.statusCode||200,e.setHeader("Content-Type","text/html; charset=UTF-8"),e.setHeader("X-Powered-By","react-ssr-web"),e.end(r)}exports.reactSsr=function(e,r,t,n){return function(o,i,a){var u=l(o),p=u?u.search:"",v=u?u.pathname:"",m=y({},o.cookies),h=y({},o.cookies),g=n?{services:n(h)}:{},j=c.createServerStore(r,g,{}),S=d.readFileSync(e,"utf8"),O=s.matchRoutes(t,v||"");if(!O)return i.statusCode=404,void a("Not found");var w=O.map((function(e){var r=e.route;return r.loadData?r.loadData(j.dispatch,h,p):null})).map((function(e){if(e)return new Promise((function(r){e.then(r).catch(r)}))}));Promise.all(w).then((function(){var e=f(r,S,t,o,j),n=function(e,r){var t={};for(var n in r)e[n]!==r[n]&&(t[n]=r[n]);return t}(m,h);for(var c in n)i.cookie(c,n[c]);b(i,e),a()})).catch((function(e){b(i,"Error happens: "+e),a()}))}},exports.renderHtml=f; |
{ | ||
"name": "react-ssr-web", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "React SSR convenience functions.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32287
351