From 8de7e88bd9adccde63a8f273e89db78a1b0c7cd6 Mon Sep 17 00:00:00 2001 From: eric-burel Date: Wed, 23 Sep 2020 15:50:43 +0200 Subject: [PATCH] reintroduce npm packages --- .../next-material-ui/components/Link.tsx | 88 ++++++++ .../dist/components/Link.d.ts | 9 + .../dist/getMuiDocumentInitialProps.d.ts | 2 + .../@vulcan/next-material-ui/dist/index.d.ts | 3 + .../@vulcan/next-material-ui/dist/index.js | 2 + .../next-material-ui/components/Link.d.ts | 9 + .../getMuiDocumentInitialProps.d.ts | 2 + .../dist/next-material-ui/index.d.ts | 3 + .../dist/next-material-ui/useMuiApp.d.ts | 2 + .../dist/next-style-collector/index.d.ts | 7 + .../next-material-ui/dist/useMuiApp.d.ts | 2 + .../getMuiDocumentInitialProps.tsx | 63 ++++++ packages/@vulcan/next-material-ui/index.ts | 5 + .../@vulcan/next-material-ui/package.json | 26 +++ .../@vulcan/next-material-ui/tsconfig.json | 8 + .../@vulcan/next-material-ui/useMuiApp.tsx | 13 ++ .../next-material-ui/webpack.config.js | 12 ++ .../next-style-collector/dist/index.d.ts | 7 + .../next-style-collector/dist/index.js | 2 + .../@vulcan/next-style-collector/index.ts | 13 ++ .../@vulcan/next-style-collector/package.json | 20 ++ .../next-style-collector/tsconfig.json | 7 + .../next-style-collector/webpack.config.js | 10 + .../dist/getSCDocumentInitialProps.d.ts | 2 + .../next-styled-components/dist/index.d.ts | 1 + .../next-styled-components/dist/index.js | 2 + .../dist/next-style-collector/index.d.ts | 7 + .../getSCDocumentInitialProps.d.ts | 2 + .../dist/next-styled-components/index.d.ts | 1 + .../getSCDocumentInitialProps.tsx | 45 +++++ .../@vulcan/next-styled-components/index.ts | 1 + .../next-styled-components/package.json | 24 +++ .../next-styled-components/tsconfig.json | 7 + .../next-styled-components/webpack.config.js | 10 + packages/@vulcan/next-utils/dist/index.d.ts | 2 + packages/@vulcan/next-utils/dist/index.js | 2 + packages/@vulcan/next-utils/dist/routing.d.ts | 23 +++ packages/@vulcan/next-utils/dist/ssr.d.ts | 4 + packages/@vulcan/next-utils/index.ts | 2 + packages/@vulcan/next-utils/package.json | 23 +++ packages/@vulcan/next-utils/routing.tsx | 190 ++++++++++++++++++ packages/@vulcan/next-utils/ssr.ts | 9 + packages/@vulcan/next-utils/tsconfig.json | 8 + packages/@vulcan/next-utils/webpack.config.js | 10 + scripts/link-vulcan.sh | 14 +- src/pages/docs/contributing.md | 13 ++ src/pages/docs/release-process.md | 3 +- src/pages/vns/debug/noApolloSsr.tsx | 2 +- 48 files changed, 712 insertions(+), 10 deletions(-) create mode 100644 packages/@vulcan/next-material-ui/components/Link.tsx create mode 100644 packages/@vulcan/next-material-ui/dist/components/Link.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/getMuiDocumentInitialProps.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/index.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/index.js create mode 100644 packages/@vulcan/next-material-ui/dist/next-material-ui/components/Link.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/next-material-ui/getMuiDocumentInitialProps.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/next-material-ui/index.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/next-material-ui/useMuiApp.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/next-style-collector/index.d.ts create mode 100644 packages/@vulcan/next-material-ui/dist/useMuiApp.d.ts create mode 100644 packages/@vulcan/next-material-ui/getMuiDocumentInitialProps.tsx create mode 100644 packages/@vulcan/next-material-ui/index.ts create mode 100644 packages/@vulcan/next-material-ui/package.json create mode 100644 packages/@vulcan/next-material-ui/tsconfig.json create mode 100644 packages/@vulcan/next-material-ui/useMuiApp.tsx create mode 100644 packages/@vulcan/next-material-ui/webpack.config.js create mode 100644 packages/@vulcan/next-style-collector/dist/index.d.ts create mode 100644 packages/@vulcan/next-style-collector/dist/index.js create mode 100644 packages/@vulcan/next-style-collector/index.ts create mode 100644 packages/@vulcan/next-style-collector/package.json create mode 100644 packages/@vulcan/next-style-collector/tsconfig.json create mode 100644 packages/@vulcan/next-style-collector/webpack.config.js create mode 100644 packages/@vulcan/next-styled-components/dist/getSCDocumentInitialProps.d.ts create mode 100644 packages/@vulcan/next-styled-components/dist/index.d.ts create mode 100644 packages/@vulcan/next-styled-components/dist/index.js create mode 100644 packages/@vulcan/next-styled-components/dist/next-style-collector/index.d.ts create mode 100644 packages/@vulcan/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts create mode 100644 packages/@vulcan/next-styled-components/dist/next-styled-components/index.d.ts create mode 100644 packages/@vulcan/next-styled-components/getSCDocumentInitialProps.tsx create mode 100644 packages/@vulcan/next-styled-components/index.ts create mode 100644 packages/@vulcan/next-styled-components/package.json create mode 100644 packages/@vulcan/next-styled-components/tsconfig.json create mode 100644 packages/@vulcan/next-styled-components/webpack.config.js create mode 100644 packages/@vulcan/next-utils/dist/index.d.ts create mode 100644 packages/@vulcan/next-utils/dist/index.js create mode 100644 packages/@vulcan/next-utils/dist/routing.d.ts create mode 100644 packages/@vulcan/next-utils/dist/ssr.d.ts create mode 100644 packages/@vulcan/next-utils/index.ts create mode 100644 packages/@vulcan/next-utils/package.json create mode 100644 packages/@vulcan/next-utils/routing.tsx create mode 100644 packages/@vulcan/next-utils/ssr.ts create mode 100644 packages/@vulcan/next-utils/tsconfig.json create mode 100644 packages/@vulcan/next-utils/webpack.config.js diff --git a/packages/@vulcan/next-material-ui/components/Link.tsx b/packages/@vulcan/next-material-ui/components/Link.tsx new file mode 100644 index 00000000..0b58e61d --- /dev/null +++ b/packages/@vulcan/next-material-ui/components/Link.tsx @@ -0,0 +1,88 @@ +// @see https://github.com/mui-org/material-ui/blob/master/examples/nextjs/src/Link.js +// /* eslint-disable jsx-a11y/anchor-has-content */ +import React, { Ref } from "react"; +import PropTypes from "prop-types"; +import clsx from "clsx"; +import { useRouter } from "next/router"; +import NextLink, { LinkProps as NextLinkProps } from "next/link"; +import MuiLink, { LinkProps as MuiLinkProps } from "@material-ui/core/Link"; + +type LinkProps = NextLinkProps & + MuiLinkProps & { + activeClassName?: string; + naked?: boolean; + }; + +const NextComposed = React.forwardRef(function NextComposed( + props: LinkProps, + ref: Ref +) { + const { as, href, ...other } = props; + + return ( + + + + ); +}); + +NextComposed.propTypes = { + as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), + // href: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), // FIXME: provokes a TS error + prefetch: PropTypes.bool, +}; + +// A styled version of the Next.js Link component: +// https://nextjs.org/docs/#with-link +function Link(props: LinkProps) { + const { + href, + activeClassName = "active", + className: classNameProps, + innerRef, + naked, + ...other + } = props; + + const router = useRouter(); + const pathname = typeof href === "string" ? href : href.pathname; + const className = clsx(classNameProps, { + [activeClassName]: router.pathname === pathname && activeClassName, + }); + + if (naked) { + return ( + + ); + } + + return ( + + ); +} + +Link.propTypes = { + activeClassName: PropTypes.string, + as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), + className: PropTypes.string, + href: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), + innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), + naked: PropTypes.bool, + onClick: PropTypes.func, + prefetch: PropTypes.bool, +}; + +export default React.forwardRef((props: LinkProps, ref) => ( + +)); diff --git a/packages/@vulcan/next-material-ui/dist/components/Link.d.ts b/packages/@vulcan/next-material-ui/dist/components/Link.d.ts new file mode 100644 index 00000000..71eaae5f --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/components/Link.d.ts @@ -0,0 +1,9 @@ +import React from "react"; +import { LinkProps as NextLinkProps } from "next/link"; +import { LinkProps as MuiLinkProps } from "@material-ui/core/Link"; +declare type LinkProps = NextLinkProps & MuiLinkProps & { + activeClassName?: string; + naked?: boolean; +}; +declare const _default: React.ForwardRefExoticComponent & React.RefAttributes>; +export default _default; diff --git a/packages/@vulcan/next-material-ui/dist/getMuiDocumentInitialProps.d.ts b/packages/@vulcan/next-material-ui/dist/getMuiDocumentInitialProps.d.ts new file mode 100644 index 00000000..8b2f7fa7 --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/getMuiDocumentInitialProps.d.ts @@ -0,0 +1,2 @@ +import { AppSheetsCollector } from "@vulcan/next-style-collector"; +export declare const getAppEnhancer: () => AppSheetsCollector; diff --git a/packages/@vulcan/next-material-ui/dist/index.d.ts b/packages/@vulcan/next-material-ui/dist/index.d.ts new file mode 100644 index 00000000..ccb93891 --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/index.d.ts @@ -0,0 +1,3 @@ +export { default as useMuiApp } from "./useMuiApp"; +export * from "./getMuiDocumentInitialProps"; +export { default as Link } from "./components/Link"; diff --git a/packages/@vulcan/next-material-ui/dist/index.js b/packages/@vulcan/next-material-ui/dist/index.js new file mode 100644 index 00000000..51af0cee --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/index.js @@ -0,0 +1,2 @@ +module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=require("react")},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),u=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});var o=r(2);Object.defineProperty(t,"useMuiApp",{enumerable:!0,get:function(){return o.default}}),u(r(3),t);var a=r(5);Object.defineProperty(t,"Link",{enumerable:!0,get:function(){return a.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.default=()=>{n.useEffect(()=>{const e=document.querySelector("#jss-server-side");e&&e.parentElement.removeChild(e)},[])}},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getAppEnhancer=void 0;const u=n(r(0)),o=r(4);t.getAppEnhancer=()=>{const e=new o.ServerStyleSheets;return{sheets:e,enhanceApp:t=>r=>e.collect(u.default.createElement(t,Object.assign({},r)))}}},function(e,t){e.exports=require("@material-ui/core/styles")},function(e,t,r){"use strict";var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var u=0;for(n=Object.getOwnPropertySymbols(e);uo.default.createElement(d,Object.assign({},e,{innerRef:t})))},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("clsx")},function(e,t){e.exports=require("next/router")},function(e,t){e.exports=require("next/link")},function(e,t){e.exports=require("@material-ui/core/Link")}]); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVhY3RcIiIsIndlYnBhY2s6Ly8vLi9pbmRleC50cyIsIndlYnBhY2s6Ly8vLi91c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sLXVpL2NvcmUvTGlua1wiKTsiXSwic291cmNlUm9vdCI6IiJ9 \ No newline at end of file diff --git a/packages/@vulcan/next-material-ui/dist/next-material-ui/components/Link.d.ts b/packages/@vulcan/next-material-ui/dist/next-material-ui/components/Link.d.ts new file mode 100644 index 00000000..71eaae5f --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/next-material-ui/components/Link.d.ts @@ -0,0 +1,9 @@ +import React from "react"; +import { LinkProps as NextLinkProps } from "next/link"; +import { LinkProps as MuiLinkProps } from "@material-ui/core/Link"; +declare type LinkProps = NextLinkProps & MuiLinkProps & { + activeClassName?: string; + naked?: boolean; +}; +declare const _default: React.ForwardRefExoticComponent & React.RefAttributes>; +export default _default; diff --git a/packages/@vulcan/next-material-ui/dist/next-material-ui/getMuiDocumentInitialProps.d.ts b/packages/@vulcan/next-material-ui/dist/next-material-ui/getMuiDocumentInitialProps.d.ts new file mode 100644 index 00000000..8b2f7fa7 --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/next-material-ui/getMuiDocumentInitialProps.d.ts @@ -0,0 +1,2 @@ +import { AppSheetsCollector } from "@vulcan/next-style-collector"; +export declare const getAppEnhancer: () => AppSheetsCollector; diff --git a/packages/@vulcan/next-material-ui/dist/next-material-ui/index.d.ts b/packages/@vulcan/next-material-ui/dist/next-material-ui/index.d.ts new file mode 100644 index 00000000..ccb93891 --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/next-material-ui/index.d.ts @@ -0,0 +1,3 @@ +export { default as useMuiApp } from "./useMuiApp"; +export * from "./getMuiDocumentInitialProps"; +export { default as Link } from "./components/Link"; diff --git a/packages/@vulcan/next-material-ui/dist/next-material-ui/useMuiApp.d.ts b/packages/@vulcan/next-material-ui/dist/next-material-ui/useMuiApp.d.ts new file mode 100644 index 00000000..e0568dcc --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/next-material-ui/useMuiApp.d.ts @@ -0,0 +1,2 @@ +declare const useMuiApp: () => void; +export default useMuiApp; diff --git a/packages/@vulcan/next-material-ui/dist/next-style-collector/index.d.ts b/packages/@vulcan/next-material-ui/dist/next-style-collector/index.d.ts new file mode 100644 index 00000000..2188ff84 --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/next-style-collector/index.d.ts @@ -0,0 +1,7 @@ +export interface AppSheetsCollector { + sheets: { + getStyleElement: Function; + }; + enhanceApp: Function; + finally?: Function; +} diff --git a/packages/@vulcan/next-material-ui/dist/useMuiApp.d.ts b/packages/@vulcan/next-material-ui/dist/useMuiApp.d.ts new file mode 100644 index 00000000..e0568dcc --- /dev/null +++ b/packages/@vulcan/next-material-ui/dist/useMuiApp.d.ts @@ -0,0 +1,2 @@ +declare const useMuiApp: () => void; +export default useMuiApp; diff --git a/packages/@vulcan/next-material-ui/getMuiDocumentInitialProps.tsx b/packages/@vulcan/next-material-ui/getMuiDocumentInitialProps.tsx new file mode 100644 index 00000000..aa01d4b7 --- /dev/null +++ b/packages/@vulcan/next-material-ui/getMuiDocumentInitialProps.tsx @@ -0,0 +1,63 @@ +import React from "react"; +import { ServerStyleSheets } from "@material-ui/core/styles"; +import { AppSheetsCollector } from "@vulcan/next-style-collector"; + +export const getAppEnhancer = (): AppSheetsCollector => { + const sheets = new ServerStyleSheets(); + const enhanceApp = (App) => (props) => sheets.collect(); + return { + sheets, + enhanceApp, + }; +}; + +// @see https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_document.js +// This function do not generalize when you have another lib collecting stylesheets (eg Styled Components) +/* +const getMuiDocumentInitialProps = async (ctx: DocumentContext) => { + // Resolution order + // + // On the server: + // 1. app.getInitialProps + // 2. page.getInitialProps + // 3. document.getInitialProps + // 4. app.render + // 5. page.render + // 6. document.render + // + // On the server with error: + // 1. document.getInitialProps + // 2. app.render + // 3. page.render + // 4. document.render + // + // On the client + // 1. app.getInitialProps + // 2. page.getInitialProps + // 3. app.render + // 4. page.render + + // Render app and page and get the context of the page with collected side effects. + const sheets = new ServerStyleSheets(); + const originalRenderPage = ctx.renderPage; + + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App) => (props) => sheets.collect(), + }); + + // get parent props + // NOTE: we need to have already enhanced ctx, so it has to be done here + const initialProps = await Document.getInitialProps(ctx); + + return { + // Styles fragment is rendered after the app and page rendering finish. + ...initialProps, + styles: [ + ...React.Children.toArray(initialProps.styles), + sheets.getStyleElement(), + ], + }; +}; +export default getMuiDocumentInitialProps; +*/ diff --git a/packages/@vulcan/next-material-ui/index.ts b/packages/@vulcan/next-material-ui/index.ts new file mode 100644 index 00000000..4e44e60c --- /dev/null +++ b/packages/@vulcan/next-material-ui/index.ts @@ -0,0 +1,5 @@ +export { default as useMuiApp } from "./useMuiApp"; + +export * from "./getMuiDocumentInitialProps"; + +export { default as Link } from "./components/Link"; diff --git a/packages/@vulcan/next-material-ui/package.json b/packages/@vulcan/next-material-ui/package.json new file mode 100644 index 00000000..5ed23951 --- /dev/null +++ b/packages/@vulcan/next-material-ui/package.json @@ -0,0 +1,26 @@ +{ + "name": "@vulcan/next-material-ui", + "version": "0.0.1", + "description": "Vulcan Next Material UI binding", + "main": "./dist/index.js", + "author": "eric-burel ", + "homepage": "https://github.com/VulcanJS/vulcan-npm#readme", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/VulcanJS/vulcan-npm.git" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "build": "webpack --config ./webpack.config.js" + }, + "bugs": { + "url": "https://github.com/VulcanJS/vulcan-npm/issues" + }, + "dependencies": { + "@material-ui/core": "^4.11.0", + "clsx": "^1.1.1", + "next": "^9.5.3", + "react-dom": "^16.13.1" + } +} diff --git a/packages/@vulcan/next-material-ui/tsconfig.json b/packages/@vulcan/next-material-ui/tsconfig.json new file mode 100644 index 00000000..40197ad0 --- /dev/null +++ b/packages/@vulcan/next-material-ui/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "lib": ["es6", "dom"] + }, + "include": ["*.ts"] +} diff --git a/packages/@vulcan/next-material-ui/useMuiApp.tsx b/packages/@vulcan/next-material-ui/useMuiApp.tsx new file mode 100644 index 00000000..63f9f36b --- /dev/null +++ b/packages/@vulcan/next-material-ui/useMuiApp.tsx @@ -0,0 +1,13 @@ +// @see https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_app.js +import { useEffect } from "react"; + +const useMuiApp = () => { + useEffect(() => { + // Remove the server-side injected CSS on each render + const jssStyles = document.querySelector("#jss-server-side"); + if (jssStyles) { + jssStyles.parentElement.removeChild(jssStyles); + } + }, []); +}; +export default useMuiApp; diff --git a/packages/@vulcan/next-material-ui/webpack.config.js b/packages/@vulcan/next-material-ui/webpack.config.js new file mode 100644 index 00000000..a43d22ff --- /dev/null +++ b/packages/@vulcan/next-material-ui/webpack.config.js @@ -0,0 +1,12 @@ +const merge = require("webpack-merge"); +const path = require("path"); +const baseConfig = require("../../webpack/webpack.config.base.common.prod"); +// @see https://stackoverflow.com/questions/46010926/how-to-use-webpack-with-a-monorepo-yarnpkg-workspaces + +//const merge = require('webpack-merge') +module.exports = merge(baseConfig, { + entry: path.resolve(__dirname, "./index.ts"), + output: { + path: path.resolve(__dirname, "dist"), + }, +}); diff --git a/packages/@vulcan/next-style-collector/dist/index.d.ts b/packages/@vulcan/next-style-collector/dist/index.d.ts new file mode 100644 index 00000000..2188ff84 --- /dev/null +++ b/packages/@vulcan/next-style-collector/dist/index.d.ts @@ -0,0 +1,7 @@ +export interface AppSheetsCollector { + sheets: { + getStyleElement: Function; + }; + enhanceApp: Function; + finally?: Function; +} diff --git a/packages/@vulcan/next-style-collector/dist/index.js b/packages/@vulcan/next-style-collector/dist/index.js new file mode 100644 index 00000000..61f85b12 --- /dev/null +++ b/packages/@vulcan/next-style-collector/dist/index.js @@ -0,0 +1,2 @@ +module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0})}]); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiXSwibmFtZXMiOlsiaW5zdGFsbGVkTW9kdWxlcyIsIl9fd2VicGFja19yZXF1aXJlX18iLCJtb2R1bGVJZCIsImV4cG9ydHMiLCJtb2R1bGUiLCJpIiwibCIsIm1vZHVsZXMiLCJjYWxsIiwibSIsImMiLCJkIiwibmFtZSIsImdldHRlciIsIm8iLCJPYmplY3QiLCJkZWZpbmVQcm9wZXJ0eSIsImVudW1lcmFibGUiLCJnZXQiLCJyIiwiU3ltYm9sIiwidG9TdHJpbmdUYWciLCJ2YWx1ZSIsInQiLCJtb2RlIiwiX19lc01vZHVsZSIsIm5zIiwiY3JlYXRlIiwia2V5IiwiYmluZCIsIm4iLCJvYmplY3QiLCJwcm9wZXJ0eSIsInByb3RvdHlwZSIsImhhc093blByb3BlcnR5IiwicCIsInMiXSwibWFwcGluZ3MiOiIyQkFDRSxJQUFJQSxFQUFtQixHQUd2QixTQUFTQyxFQUFvQkMsR0FHNUI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3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChvYmplY3QsIHByb3BlcnR5KTsgfTtcblxuIFx0Ly8gX193ZWJwYWNrX3B1YmxpY19wYXRoX19cbiBcdF9fd2VicGFja19yZXF1aXJlX18ucCA9IFwiXCI7XG5cblxuIFx0Ly8gTG9hZCBlbnRyeSBtb2R1bGUgYW5kIHJldHVybiBleHBvcnRzXG4gXHRyZXR1cm4gX193ZWJwYWNrX3JlcXVpcmVfXyhfX3dlYnBhY2tfcmVxdWlyZV9fLnMgPSAwKTtcbiJdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/packages/@vulcan/next-style-collector/index.ts b/packages/@vulcan/next-style-collector/index.ts new file mode 100644 index 00000000..b9151a86 --- /dev/null +++ b/packages/@vulcan/next-style-collector/index.ts @@ -0,0 +1,13 @@ +/** + * Generic helpers to build a lib that will collect styles in the Next application, + * such as Material UI, Styled Components... + * + * May become unnecessary when Next introduces packages? + */ + +// Generic interface to respect +export interface AppSheetsCollector { + sheets: { getStyleElement: Function }; // minimum spec to respect for a collector + enhanceApp: Function; // function used in ctx.renderPage, so the sheet can collect styles + finally?: Function; +} diff --git a/packages/@vulcan/next-style-collector/package.json b/packages/@vulcan/next-style-collector/package.json new file mode 100644 index 00000000..3cde20e0 --- /dev/null +++ b/packages/@vulcan/next-style-collector/package.json @@ -0,0 +1,20 @@ +{ + "name": "@vulcan/next-style-collector", + "version": "0.0.1", + "description": "Vulcan stylesheets collecting for SSR (Material UI, Styled Components)", + "main": "./dist/index.js", + "author": "eric-burel ", + "homepage": "https://github.com/VulcanJS/vulcan-npm#readme", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/VulcanJS/vulcan-npm.git" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "build": "webpack --config ./webpack.config.js" + }, + "bugs": { + "url": "https://github.com/VulcanJS/vulcan-npm/issues" + } +} diff --git a/packages/@vulcan/next-style-collector/tsconfig.json b/packages/@vulcan/next-style-collector/tsconfig.json new file mode 100644 index 00000000..e5a518ed --- /dev/null +++ b/packages/@vulcan/next-style-collector/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["*.ts"] +} diff --git a/packages/@vulcan/next-style-collector/webpack.config.js b/packages/@vulcan/next-style-collector/webpack.config.js new file mode 100644 index 00000000..af370835 --- /dev/null +++ b/packages/@vulcan/next-style-collector/webpack.config.js @@ -0,0 +1,10 @@ +const merge = require("webpack-merge"); +const path = require("path"); +const baseConfig = require("../../webpack/webpack.config.base.common.prod"); +//const merge = require('webpack-merge') +module.exports = merge(baseConfig, { + entry: path.resolve(__dirname, "./index.ts"), + output: { + path: path.resolve(__dirname, "dist"), + }, +}); diff --git a/packages/@vulcan/next-styled-components/dist/getSCDocumentInitialProps.d.ts b/packages/@vulcan/next-styled-components/dist/getSCDocumentInitialProps.d.ts new file mode 100644 index 00000000..8b2f7fa7 --- /dev/null +++ b/packages/@vulcan/next-styled-components/dist/getSCDocumentInitialProps.d.ts @@ -0,0 +1,2 @@ +import { AppSheetsCollector } from "@vulcan/next-style-collector"; +export declare const getAppEnhancer: () => AppSheetsCollector; diff --git a/packages/@vulcan/next-styled-components/dist/index.d.ts b/packages/@vulcan/next-styled-components/dist/index.d.ts new file mode 100644 index 00000000..a5ba2348 --- /dev/null +++ b/packages/@vulcan/next-styled-components/dist/index.d.ts @@ -0,0 +1 @@ +export * from "./getSCDocumentInitialProps"; diff --git a/packages/@vulcan/next-styled-components/dist/index.js b/packages/@vulcan/next-styled-components/dist/index.js new file mode 100644 index 00000000..b619c2da --- /dev/null +++ b/packages/@vulcan/next-styled-components/dist/index.js @@ -0,0 +1,2 @@ +module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(1),t)},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getAppEnhancer=void 0;const o=r(n(2)),u=n(3);t.getAppEnhancer=()=>{const e=new u.ServerStyleSheet;return{sheets:e,enhanceApp:t=>n=>e.collectStyles(o.default.createElement(t,Object.assign({},n))),finally:()=>e.seal()}}},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("styled-components")}]); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vaW5kZXgudHMiLCJ3ZWJwYWNrOi8vLy4vZ2V0U0NEb2N1bWVudEluaXRpYWxQcm9wcy50c3giLCJ3ZWJwYWNrOi8v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ZXQuZ2V0U3R5bGVFbGVtZW50KCl9XG4gICAgICAgIDwvPlxuICAgICAgKSxcbiAgICB9O1xuICB9IGZpbmFsbHkge1xuICAgIHNoZWV0LnNlYWwoKTtcbiAgfVxufTtcbmV4cG9ydCBkZWZhdWx0IGdldFNDRG9jdW1lbnRJbml0aWFsUHJvcHM7XG4qL1xuIiwibW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKFwicmVhY3RcIik7IiwibW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKFwic3R5bGVkLWNvbXBvbmVudHNcIik7Il0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/packages/@vulcan/next-styled-components/dist/next-style-collector/index.d.ts b/packages/@vulcan/next-styled-components/dist/next-style-collector/index.d.ts new file mode 100644 index 00000000..2188ff84 --- /dev/null +++ b/packages/@vulcan/next-styled-components/dist/next-style-collector/index.d.ts @@ -0,0 +1,7 @@ +export interface AppSheetsCollector { + sheets: { + getStyleElement: Function; + }; + enhanceApp: Function; + finally?: Function; +} diff --git a/packages/@vulcan/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts b/packages/@vulcan/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts new file mode 100644 index 00000000..8b2f7fa7 --- /dev/null +++ b/packages/@vulcan/next-styled-components/dist/next-styled-components/getSCDocumentInitialProps.d.ts @@ -0,0 +1,2 @@ +import { AppSheetsCollector } from "@vulcan/next-style-collector"; +export declare const getAppEnhancer: () => AppSheetsCollector; diff --git a/packages/@vulcan/next-styled-components/dist/next-styled-components/index.d.ts b/packages/@vulcan/next-styled-components/dist/next-styled-components/index.d.ts new file mode 100644 index 00000000..a5ba2348 --- /dev/null +++ b/packages/@vulcan/next-styled-components/dist/next-styled-components/index.d.ts @@ -0,0 +1 @@ +export * from "./getSCDocumentInitialProps"; diff --git a/packages/@vulcan/next-styled-components/getSCDocumentInitialProps.tsx b/packages/@vulcan/next-styled-components/getSCDocumentInitialProps.tsx new file mode 100644 index 00000000..7d75cc81 --- /dev/null +++ b/packages/@vulcan/next-styled-components/getSCDocumentInitialProps.tsx @@ -0,0 +1,45 @@ +import React from "react"; +import { ServerStyleSheet } from "styled-components"; +import { AppSheetsCollector } from "@vulcan/next-style-collector"; + +export const getAppEnhancer = (): AppSheetsCollector => { + const sheet = new ServerStyleSheet(); + const enhanceApp = (App) => (props) => + (sheet as any).collectStyles(); + return { + sheets: sheet, // MUI and Styled components have non normalized types, so we renormalize the names + enhanceApp, + finally: () => sheet.seal(), + }; +}; +// @see https://github.com/vercel/next.js/blob/canary/examples/with-styled-components/pages/_document.js +// This function do not generalize when you have another lib collecting stylesheets (eg Material UI) +/* +const getSCDocumentInitialProps = async (ctx: DocumentContext) => { + const sheet = new ServerStyleSheet(); + const originalRenderPage = ctx.renderPage; + + try { + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App) => (props) => sheet.collectStyles(), + }); + + // get parent props + // NOTE: we need to have already enhanced ctx, so it has to be done here + const initialProps = await Document.getInitialProps(ctx); + return { + ...initialProps, + styles: ( + <> + {initialProps.styles} + {sheet.getStyleElement()} + + ), + }; + } finally { + sheet.seal(); + } +}; +export default getSCDocumentInitialProps; +*/ diff --git a/packages/@vulcan/next-styled-components/index.ts b/packages/@vulcan/next-styled-components/index.ts new file mode 100644 index 00000000..a5ba2348 --- /dev/null +++ b/packages/@vulcan/next-styled-components/index.ts @@ -0,0 +1 @@ +export * from "./getSCDocumentInitialProps"; diff --git a/packages/@vulcan/next-styled-components/package.json b/packages/@vulcan/next-styled-components/package.json new file mode 100644 index 00000000..4692dbd9 --- /dev/null +++ b/packages/@vulcan/next-styled-components/package.json @@ -0,0 +1,24 @@ +{ + "name": "@vulcan/next-styled-components", + "version": "0.0.1", + "description": "Vulcan Next Styled Components bindings", + "main": "./dist/index.js", + "author": "eric-burel ", + "homepage": "https://github.com/VulcanJS/vulcan-npm#readme", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/VulcanJS/vulcan-npm.git" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "build": "webpack --config ./webpack.config.js" + }, + "bugs": { + "url": "https://github.com/VulcanJS/vulcan-npm/issues" + }, + "dependencies": { + "react": "^16.13.1", + "styled-components": "^5.2.0" + } +} diff --git a/packages/@vulcan/next-styled-components/tsconfig.json b/packages/@vulcan/next-styled-components/tsconfig.json new file mode 100644 index 00000000..e5a518ed --- /dev/null +++ b/packages/@vulcan/next-styled-components/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["*.ts"] +} diff --git a/packages/@vulcan/next-styled-components/webpack.config.js b/packages/@vulcan/next-styled-components/webpack.config.js new file mode 100644 index 00000000..af370835 --- /dev/null +++ b/packages/@vulcan/next-styled-components/webpack.config.js @@ -0,0 +1,10 @@ +const merge = require("webpack-merge"); +const path = require("path"); +const baseConfig = require("../../webpack/webpack.config.base.common.prod"); +//const merge = require('webpack-merge') +module.exports = merge(baseConfig, { + entry: path.resolve(__dirname, "./index.ts"), + output: { + path: path.resolve(__dirname, "dist"), + }, +}); diff --git a/packages/@vulcan/next-utils/dist/index.d.ts b/packages/@vulcan/next-utils/dist/index.d.ts new file mode 100644 index 00000000..952d7b44 --- /dev/null +++ b/packages/@vulcan/next-utils/dist/index.d.ts @@ -0,0 +1,2 @@ +export * from "./ssr"; +export * from "./routing"; diff --git a/packages/@vulcan/next-utils/dist/index.js b/packages/@vulcan/next-utils/dist/index.js new file mode 100644 index 00000000..6eb918a8 --- /dev/null +++ b/packages/@vulcan/next-utils/dist/index.js @@ -0,0 +1,2 @@ +module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isClientRender=t.isStaticExportCtx=t.isServerRenderCtx=void 0,t.isServerRenderCtx=e=>!!(e&&e.res&&e.res.writeHead),t.isStaticExportCtx=e=>!(!e||!e.res||e.res.writeHead),t.isClientRender=()=>!0},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(0),t),i(r(3),t)},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function u(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,s)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withPrivateAccess=t.redirectServer=void 0;const c=s(r(1)),d=o(r(4)),a=r(0),l=s(r(5)),f=r(1),p=l.default("vns:next"),v=s(r(6));t.redirectServer=e=>t=>{e.res.writeHead(302,{Location:t}),e.res.end()};const g={defaultRedirection:"/",LoaderComponent:()=>c.default.createElement(c.default.Fragment,null),isAllowedClient:()=>u(void 0,void 0,void 0,(function*(){return{isAllowed:!1}})),isAllowedServer:()=>u(void 0,void 0,void 0,(function*(){return{isAllowed:!1}}))};t.withPrivateAccess=e=>(r,n)=>{const i=v.default({},g,e||{},n||{}),{isAllowedClient:o,isAllowedServer:s,defaultRedirection:l,LoaderComponent:b}=i,h=e=>{const t=d.useRouter(),[n,i]=f.useState(!1),{isAllowedDuringSSR:s}=e;f.useEffect(()=>{u(void 0,void 0,void 0,(function*(){const{isAllowed:r,redirection:n}=yield o(e);r?i(!0):(p("Redirecting client-side"),t.push(n||l))}))},[t,e]);const{isStaticExport:v}=e;return v&&!a.isClientRender()?(p("We render nothing during static export, server side this is a private page (only rendered client side)"),c.default.createElement(c.default.Fragment,null)):!a.isClientRender()||s||n?(p("Rendering private page"),c.default.createElement(c.default.Fragment,null,c.default.createElement(r,Object.assign({},e)))):(p("We render nothing if user is not allowed or a redirect is happening or we simply wait for the effect to run"),c.default.createElement(b,null))},y=h.getInitialProps;return h.getInitialProps=e=>u(void 0,void 0,void 0,(function*(){p("Running private page getInitialProps");const r=y?y(e):{};if(a.isServerRenderCtx(e)){p("Detected dynamic server-side rendering");const{redirection:n,isAllowed:i,authProps:o={}}=yield s(r,e);if(i)return Object.assign(Object.assign(Object.assign({},r),o),{redirection:n,isServerRender:!0,isStaticExport:!1});p("Redirecting (dynamic server render)"),t.redirectServer(e)(n||l)}else{if(a.isStaticExportCtx(e))return p("Detected static export"),Object.assign(Object.assign({},r),{isStaticExport:!0,isServerRender:!1});if(a.isClientRender()){p("Detected client render");const{isAllowed:t,redirection:n,authProps:i={}}=yield o(r,e);return t||(p("Redirecting (client-side, during getInitialProps call)"),d.default.push(n||l)),Object.assign(Object.assign({},r),i)}}return r})),h}},function(e,t){e.exports=require("next/router")},function(e,t){e.exports=require("debug")},function(e,t){e.exports=require("lodash/merge")}]); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vc3NyLnRzIiwid2VicGFjazovLy9leHRlcm5hbCBcInJlYWN0XCIiLCJ3ZWJwYWNrOi8vLy4vaW5kZXgudHMiLCJ3ZWJwYWNrOi8vLy4vcm91dGluZy50c3giLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwibmV4dC9yb3V0ZXJcIiIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwgXCJkZWJ1Z1wiIiwid2VicGFjazovLy9leHRlcm5hbCBcImxvZGFzaC9tZXJnZVwiIl0sIm5hbWVzIjpbImluc3RhbGxlZE1vZHVsZXMiLCJfX3dlYnBhY2tfcmVxdWlyZV9fIiwibW9kdWxlSWQiLCJleHBvcnRzIiwibW9kdWxlIiwiaSIsImwiLCJtb2R1bGVzIiwiY2FsbCIsIm0iLCJjIiwiZCIsIm5hbWUiLCJnZXR0ZXIiLCJvIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJlbnVtZXJhYmxlIiwiZ2V0IiwiciIsIlN5bWJvbCIsInRvU3RyaW5nVGFnIiwidmFsdWUiLCJ0IiwibW9kZSIsIl9fZXNNb2R1bGUiLCJucyIsImNyZWF0ZSIsIm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SByZXF1aXJlKFwiZGVidWdcIik7IiwibW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKFwibG9kYXNoL21lcmdlXCIpOyJdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/packages/@vulcan/next-utils/dist/routing.d.ts b/packages/@vulcan/next-utils/dist/routing.d.ts new file mode 100644 index 00000000..23554cd5 --- /dev/null +++ b/packages/@vulcan/next-utils/dist/routing.d.ts @@ -0,0 +1,23 @@ +import React from "react"; +import { NextPage, NextPageContext } from "next"; +export declare const redirectServer: (ctx: NextPageContext) => (pathname: string) => void; +interface RedirectResult { + authProps?: Object; + redirection?: string; + isAllowed: boolean; +} +interface PrivateAccessOptions { + defaultRedirection?: string; + isAllowedServer: (pageProps: any, ctx: NextPageContext) => Promise; + isAllowedClient: (props: any, ctx?: NextPageContext) => Promise; + LoaderComponent: React.ComponentType; +} +interface PrivatePageProps { + isStaticExport?: boolean; + isServerRender?: boolean; + isAllowedDuringSSR?: boolean; +} +export declare const withPrivateAccess: (hocOptions?: Partial) => (Page: NextPage, pageOptions?: Partial) => React.FunctionComponent & { + getInitialProps?(context: NextPageContext): PrivatePageProps | Promise; +}; +export {}; diff --git a/packages/@vulcan/next-utils/dist/ssr.d.ts b/packages/@vulcan/next-utils/dist/ssr.d.ts new file mode 100644 index 00000000..7e9d3776 --- /dev/null +++ b/packages/@vulcan/next-utils/dist/ssr.d.ts @@ -0,0 +1,4 @@ +import { NextPageContext } from "next"; +export declare const isServerRenderCtx: (ctx?: NextPageContext) => boolean; +export declare const isStaticExportCtx: (ctx?: NextPageContext) => boolean; +export declare const isClientRender: () => boolean; diff --git a/packages/@vulcan/next-utils/index.ts b/packages/@vulcan/next-utils/index.ts new file mode 100644 index 00000000..952d7b44 --- /dev/null +++ b/packages/@vulcan/next-utils/index.ts @@ -0,0 +1,2 @@ +export * from "./ssr"; +export * from "./routing"; diff --git a/packages/@vulcan/next-utils/package.json b/packages/@vulcan/next-utils/package.json new file mode 100644 index 00000000..55ed9376 --- /dev/null +++ b/packages/@vulcan/next-utils/package.json @@ -0,0 +1,23 @@ +{ + "name": "@vulcan/next-utils", + "version": "0.0.1", + "description": "Vulcan Next related helpers", + "main": "./dist/index.js", + "author": "eric-burel ", + "homepage": "https://github.com/VulcanJS/vulcan-npm#readme", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/VulcanJS/vulcan-npm.git" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "build": "webpack --config ./webpack.config.js" + }, + "bugs": { + "url": "https://github.com/VulcanJS/vulcan-npm/issues" + }, + "dependencies": { + "react": "^16.13.1" + } +} diff --git a/packages/@vulcan/next-utils/routing.tsx b/packages/@vulcan/next-utils/routing.tsx new file mode 100644 index 00000000..5ed03a61 --- /dev/null +++ b/packages/@vulcan/next-utils/routing.tsx @@ -0,0 +1,190 @@ +/** + * Demo a private page + * + * @see https://github.com/VulcanJS/vulcan-next-starter/issues/49 + * @see https://github.com/vercel/next.js/discussions/14531 + */ +import React from "react"; +import { NextPage, NextPageContext } from "next"; +import Router, { useRouter } from "next/router"; +import { isServerRenderCtx, isClientRender, isStaticExportCtx } from "./ssr"; +import debug from "debug"; +import { useEffect, useState } from "react"; +const debugNext = debug("vns:next"); +import _merge from "lodash/merge"; + +// @ssr-only +export const redirectServer = (ctx: NextPageContext) => (pathname: string) => { + ctx.res.writeHead(302, { Location: pathname }); + ctx.res.end(); +}; + +interface RedirectResult { + authProps?: Object; + redirection?: string; + isAllowed: boolean; +} +interface PrivateAccessOptions { + defaultRedirection?: string; + isAllowedServer: ( + pageProps: any, + ctx: NextPageContext + ) => Promise; // return false if the user is allowed + isAllowedClient: ( + props: any, + ctx?: NextPageContext + ) => Promise; // return false if the user is not allowed + LoaderComponent: React.ComponentType; // Will be rendered during the client check. It's advised not to use this, you risk to have some annoying flash +} + +// relevant defaults so you don't accidentally show a private page +const defaultOptions: PrivateAccessOptions = { + defaultRedirection: "/", + LoaderComponent: () => <>, + isAllowedClient: async () => ({ + isAllowed: false, + }), + isAllowedServer: async () => ({ + isAllowed: false, + }), +}; +interface PrivatePageProps { + isStaticExport?: boolean; + isServerRender?: boolean; + isAllowedDuringSSR?: boolean; +} +/** + * Makes a page private. + * + * You can pass default options or page options, they will be merged automatically. + * For example: + * const customWithPrivateAccess = withPrivateAccess(myDefaultOptions) // reuse for all your pages + * ... + * export default customWithPrivateAccess(MyPrivatePage, myPageSpecificOptions) + * + * or simply + * + * export default MyPrivatePage = withPrivateAccess()(MyPage, myPageSpecificOptions) + * + * TODO: update on Vulcan AccessControl component + */ +export const withPrivateAccess = ( + hocOptions?: Partial +) => (Page: NextPage, pageOptions?: Partial) => { + const options: PrivateAccessOptions = _merge( + {}, + defaultOptions, + hocOptions || {}, + pageOptions || {} + ); + const { + isAllowedClient, + isAllowedServer, + defaultRedirection, + LoaderComponent, + } = options; + + const PrivatePage: NextPage = (props) => { + // SCENARIO 1: handle redirection and rendering purely client-side, after static export or during a client-side redirect + const router = useRouter(); + const [isAllowedState, setAllowedState] = useState(false); // use state to avoid the flash + const { isAllowedDuringSSR } = props; + useEffect(() => { + const checkAccess = async () => { + const { isAllowed, redirection } = await isAllowedClient(props); + if (!isAllowed) { + debugNext("Redirecting client-side"); + router.push(redirection || defaultRedirection); + } else { + setAllowedState(true); + } + }; + checkAccess(); + }, [router, props]); + // SCENARIO 1.1: static export (rendering server side at build time) + const { isStaticExport } = props; + if (isStaticExport && !isClientRender()) { + debugNext( + "We render nothing during static export, server side this is a private page (only rendered client side)" + ); + return <>; + // SCNEARIO 1.2: client render + // SCENARIO 1.2.1 : client render after a server render (we know if user is allowed thanks to initialProps) + // and 1.2.2: client render after a client redirect (we must wait for the useEffect to run) + } else if (isClientRender() && !(isAllowedDuringSSR || isAllowedState)) { + debugNext( + "We render nothing if user is not allowed or a redirect is happening or we simply wait for the effect to run" + ); + // we render nothing when waiting for a redirect or to check that we are allowed or not being auth (avoids a flash) + return ; + } + debugNext("Rendering private page"); + + return ( + <> + + + ); + }; + + // Initial Props + + const pageGetInitialProps = PrivatePage.getInitialProps; + /** + * At the time of writing, using getServerSideProps would be cleaner, but would disable + * static export. + * Instead we use getInitialProps, and treat SSR as special case + * + */ + PrivatePage.getInitialProps = async (ctx?: NextPageContext) => { + debugNext("Running private page getInitialProps"); + const pageInitialProps = pageGetInitialProps + ? pageGetInitialProps(ctx) + : {}; // get the page initial props if any + + // SCENARIO 2: we are doing dynamic SSR + // We redirect using HTTP + if (isServerRenderCtx(ctx)) { + debugNext("Detected dynamic server-side rendering"); + const { redirection, isAllowed, authProps = {} } = await isAllowedServer( + pageInitialProps, + ctx + ); + if (!isAllowed) { + debugNext("Redirecting (dynamic server render)"); + redirectServer(ctx)(redirection || defaultRedirection); + } else { + return { + ...pageInitialProps, + ...authProps, + redirection, + isServerRender: true, + isStaticExport: false, + }; + } + } else if (isStaticExportCtx(ctx)) { + debugNext("Detected static export"); + return { + ...pageInitialProps, + isStaticExport: true, + isServerRender: false, + }; + // SCENARIO 3: getInitialProps is called by a page change client side, we redirect directly here to avoid page flash + } else if (isClientRender()) { + debugNext("Detected client render"); + const { isAllowed, redirection, authProps = {} } = await isAllowedClient( + pageInitialProps, + ctx + ); + if (!isAllowed) { + debugNext("Redirecting (client-side, during getInitialProps call)"); + Router.push(redirection || defaultRedirection); + } + return { ...pageInitialProps, ...authProps }; + } + + return pageInitialProps; + }; + + return PrivatePage; +}; diff --git a/packages/@vulcan/next-utils/ssr.ts b/packages/@vulcan/next-utils/ssr.ts new file mode 100644 index 00000000..24eb001d --- /dev/null +++ b/packages/@vulcan/next-utils/ssr.ts @@ -0,0 +1,9 @@ +import { NextPageContext } from "next"; + +export const isServerRenderCtx = (ctx?: NextPageContext) => + !!(ctx && ctx.res && ctx.res.writeHead); + +export const isStaticExportCtx = (ctx?: NextPageContext) => + !!(ctx && ctx.res && !ctx.res.writeHead); + +export const isClientRender = () => typeof window !== "undefined"; diff --git a/packages/@vulcan/next-utils/tsconfig.json b/packages/@vulcan/next-utils/tsconfig.json new file mode 100644 index 00000000..4772574e --- /dev/null +++ b/packages/@vulcan/next-utils/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "lib": ["es5", "dom"] + }, + "include": ["*.ts"] +} diff --git a/packages/@vulcan/next-utils/webpack.config.js b/packages/@vulcan/next-utils/webpack.config.js new file mode 100644 index 00000000..af370835 --- /dev/null +++ b/packages/@vulcan/next-utils/webpack.config.js @@ -0,0 +1,10 @@ +const merge = require("webpack-merge"); +const path = require("path"); +const baseConfig = require("../../webpack/webpack.config.base.common.prod"); +//const merge = require('webpack-merge') +module.exports = merge(baseConfig, { + entry: path.resolve(__dirname, "./index.ts"), + output: { + path: path.resolve(__dirname, "dist"), + }, +}); diff --git a/scripts/link-vulcan.sh b/scripts/link-vulcan.sh index 11e45856..70e91919 100755 --- a/scripts/link-vulcan.sh +++ b/scripts/link-vulcan.sh @@ -11,15 +11,15 @@ yarn link @vulcan/multi-env-demo # @see https://github.com/VulcanJS/vulcan-npm/issues/6 # yarn link @vulcan/next-apollo # yarn link @vulcan/next-config -yarn link @vulcan/next-material-ui -yarn link @vulcan/next-style-collector -yarn link @vulcan/next-styled-components -yarn link @vulcan/next-utils +# yarn link @vulcan/next-material-ui +# yarn link @vulcan/next-style-collector +# yarn link @vulcan/next-styled-components +# yarn link @vulcan/next-utils # yarn link @vulcan/next-webpack yarn link @vulcan/react-hooks yarn link @vulcan/schema yarn link @vulcan/utils -# Link other packages that we don't want to duplicate -yarn link react -yarn link react-dom \ No newline at end of file +# Link other packages that we don't want to duplicate when using Lerna +# yarn link react +# yarn link react-dom \ No newline at end of file diff --git a/src/pages/docs/contributing.md b/src/pages/docs/contributing.md index d0a8bb76..e9fdc2a3 100644 --- a/src/pages/docs/contributing.md +++ b/src/pages/docs/contributing.md @@ -18,3 +18,16 @@ We follow the Git Flow model. - `feature/*`: features branches should start from master. - `support/*x.x.x*`: is for bugfixes for a specific version. - Tags allow to easily find the commit corresponding to a deployed versions. + +## Vulcan NPM local installation + +If you want to use the bleeding edge version of Vulcan, you'll need to install the Vulcan NPM packages locally. +Vulcan NPM is relying on Lerna + +### Troubleshoot + +#### Issues with hooks due to multiple version of React + +This is an open issue with Yarn workspaces, it is difficult not to duplicate packages used both by your NPM packages and your local app. +Easiest solution is to force Vulcan Next to use the packages from Vulcan NPM. See relevant scripts in both Vulcan NPM (to activate the link) +and Vulcan Next (to use linked versions). diff --git a/src/pages/docs/release-process.md b/src/pages/docs/release-process.md index 9fbaf1b9..d7426ce2 100644 --- a/src/pages/docs/release-process.md +++ b/src/pages/docs/release-process.md @@ -39,8 +39,7 @@ yarn run test:vns # Test storybook yarn run storybook # Test storybook static build -# NOTE: currently broken (v0.0.5)... -# yarn run build:storybook && yarn run start:storybook-static # test storybook static export +yarn run build:storybook && yarn run start:storybook-static # test storybook static export # Optionnaly test Docker version (takes a lot of time + not very useful as they don't change often) # yarn run build:docker diff --git a/src/pages/vns/debug/noApolloSsr.tsx b/src/pages/vns/debug/noApolloSsr.tsx index 5ca994a9..99f5b860 100644 --- a/src/pages/vns/debug/noApolloSsr.tsx +++ b/src/pages/vns/debug/noApolloSsr.tsx @@ -1,4 +1,4 @@ -import { useQuery /*, useMutation*/ } from "@apollo/react-hooks"; +import { useQuery /*, useMutation*/ } from "@apollo/client"; import gql from "graphql-tag"; import { withApollo } from "@vulcan/next-apollo";