@koine/next 1.0.4 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Analytics/AnalyticsGoogle.d.ts +5 -6
- package/Analytics/AnalyticsGoogle.js +37 -0
- package/Analytics/index.d.ts +1 -1
- package/Analytics/index.js +1 -0
- package/Analytics/package.json +6 -0
- package/Auth/helpers.d.ts +17 -17
- package/Auth/helpers.js +21 -0
- package/Auth/index.d.ts +4 -4
- package/Auth/index.js +4 -0
- package/Auth/package.json +6 -0
- package/Auth/useLogin.d.ts +7 -7
- package/Auth/useLogin.js +50 -0
- package/Auth/useLoginUrl.d.ts +1 -1
- package/Auth/useLoginUrl.js +11 -0
- package/Auth/useLogout.d.ts +6 -6
- package/Auth/useLogout.js +52 -0
- package/Favicon/Favicon.d.ts +3 -4
- package/Favicon/Favicon.js +4 -0
- package/Favicon/index.d.ts +1 -1
- package/Favicon/index.js +1 -0
- package/Favicon/package.json +6 -0
- package/Forms/index.d.ts +2 -2
- package/Forms/index.js +2 -0
- package/Forms/package.json +6 -0
- package/Forms/useForm.d.ts +32 -32
- package/Forms/useForm.js +37 -0
- package/Forms/useSubmit.d.ts +24 -24
- package/Forms/useSubmit.js +23 -0
- package/Head/Head.d.ts +1 -1
- package/Head/Head.js +1 -0
- package/Head/index.d.ts +1 -1
- package/Head/index.js +1 -0
- package/Head/package.json +6 -0
- package/I18n/I18n.d.ts +44 -48
- package/I18n/I18n.js +74 -0
- package/I18n/index.d.ts +1 -1
- package/I18n/index.js +1 -0
- package/I18n/package.json +6 -0
- package/Img/Img.d.ts +21 -21
- package/Img/Img.js +28 -0
- package/Img/index.d.ts +1 -1
- package/Img/index.js +1 -0
- package/Img/package.json +6 -0
- package/Link/Link.d.ts +9 -8
- package/Link/Link.js +9 -0
- package/Link/index.d.ts +1 -1
- package/Link/index.js +1 -0
- package/Link/package.json +6 -0
- package/NextProgress/NextProgress.d.ts +24 -14
- package/NextProgress/NextProgress.js +37 -0
- package/NextProgress/index.d.ts +2 -1
- package/NextProgress/index.js +1 -0
- package/NextProgress/package.json +6 -0
- package/README.md +0 -0
- package/Seo/Seo.d.ts +3 -3
- package/Seo/Seo.js +8 -0
- package/Seo/SeoDefaults.d.ts +3 -3
- package/Seo/SeoDefaults.js +12 -0
- package/Seo/helpers.d.ts +48 -48
- package/Seo/helpers.js +111 -0
- package/Seo/index.d.ts +12 -12
- package/Seo/index.js +12 -0
- package/Seo/package.json +6 -0
- package/Theme/Theme.d.ts +46 -46
- package/Theme/Theme.js +235 -0
- package/Theme/index.d.ts +1 -1
- package/Theme/index.js +1 -0
- package/Theme/package.json +6 -0
- package/app/AppHead.d.ts +2 -3
- package/app/AppHead.js +5 -0
- package/app/AppMain.d.ts +35 -34
- package/app/AppMain.js +1 -0
- package/app/css/AppMain.d.ts +8 -0
- package/app/css/AppMain.js +11 -0
- package/app/css/AppTheme.d.ts +10 -0
- package/app/css/AppTheme.js +12 -0
- package/app/css/auth/index.d.ts +9 -0
- package/app/css/auth/index.js +13 -0
- package/app/css/auth/package.json +6 -0
- package/app/css/index.d.ts +54 -0
- package/app/css/index.js +57 -0
- package/app/css/package.json +6 -0
- package/app/em/AppMain.d.ts +10 -0
- package/app/em/AppMain.js +22 -0
- package/app/{AppTheme--emotion.d.ts → em/AppTheme.d.ts} +15 -15
- package/app/em/AppTheme.js +17 -0
- package/app/em/auth/index.d.ts +9 -0
- package/app/em/auth/index.js +13 -0
- package/app/em/auth/package.json +6 -0
- package/app/em/index.d.ts +9 -0
- package/app/em/index.js +12 -0
- package/app/em/package.json +6 -0
- package/app/index.d.ts +2 -11
- package/app/index.js +2 -0
- package/app/package.json +6 -0
- package/app/sc/AppMain.d.ts +10 -0
- package/app/sc/AppMain.js +22 -0
- package/app/sc/AppTheme.d.ts +13 -0
- package/app/sc/AppTheme.js +9 -0
- package/app/sc/auth/index.d.ts +9 -0
- package/app/sc/auth/index.js +13 -0
- package/app/sc/auth/package.json +6 -0
- package/app/sc/index.d.ts +56 -0
- package/app/sc/index.js +59 -0
- package/app/sc/package.json +6 -0
- package/config/index.d.ts +71 -58
- package/config/index.js +174 -0
- package/config/package.json +6 -0
- package/document/Document.d.ts +15 -10
- package/document/Document.js +19 -0
- package/document/css/index.d.ts +22 -0
- package/document/css/index.js +30 -0
- package/document/css/package.json +6 -0
- package/document/em/index.d.ts +16 -0
- package/document/em/index.js +68 -0
- package/document/em/package.json +6 -0
- package/document/index.d.ts +2 -4
- package/document/index.js +2 -0
- package/document/package.json +6 -0
- package/document/{Document--sc.d.ts → sc/index.d.ts} +20 -11
- package/document/sc/index.js +44 -0
- package/document/sc/package.json +6 -0
- package/index.d.ts +12 -12
- package/index.js +12 -743
- package/node/Analytics/AnalyticsGoogle.js +42 -0
- package/node/Analytics/index.js +4 -0
- package/node/Auth/helpers.js +26 -0
- package/node/Auth/index.js +7 -0
- package/node/Auth/useLogin.js +54 -0
- package/node/Auth/useLoginUrl.js +15 -0
- package/node/Auth/useLogout.js +56 -0
- package/node/Favicon/Favicon.js +9 -0
- package/node/Favicon/index.js +4 -0
- package/node/Forms/index.js +5 -0
- package/node/Forms/useForm.js +41 -0
- package/node/Forms/useSubmit.js +27 -0
- package/node/Head/Head.js +8 -0
- package/node/Head/index.js +4 -0
- package/node/I18n/I18n.js +82 -0
- package/node/I18n/index.js +4 -0
- package/node/Img/Img.js +34 -0
- package/node/Img/index.js +4 -0
- package/node/Link/Link.js +13 -0
- package/node/Link/index.js +4 -0
- package/node/NextProgress/NextProgress.js +41 -0
- package/node/NextProgress/index.js +5 -0
- package/node/Seo/Seo.js +12 -0
- package/node/Seo/SeoDefaults.js +16 -0
- package/node/Seo/helpers.js +115 -0
- package/node/Seo/index.js +15 -0
- package/node/Theme/Theme.js +241 -0
- package/node/Theme/index.js +4 -0
- package/node/app/AppHead.js +10 -0
- package/node/app/AppMain.js +2 -0
- package/node/app/css/AppMain.js +16 -0
- package/node/app/css/AppTheme.js +16 -0
- package/node/app/css/auth/index.js +18 -0
- package/node/app/css/index.js +62 -0
- package/node/app/em/AppMain.js +26 -0
- package/node/app/em/AppTheme.js +22 -0
- package/node/app/em/auth/index.js +18 -0
- package/node/app/em/index.js +17 -0
- package/node/app/index.js +5 -0
- package/node/app/sc/AppMain.js +26 -0
- package/node/app/sc/AppTheme.js +13 -0
- package/node/app/sc/auth/index.js +18 -0
- package/node/app/sc/index.js +64 -0
- package/node/config/index.js +184 -0
- package/node/document/Document.js +24 -0
- package/node/document/css/index.js +35 -0
- package/node/document/em/index.js +73 -0
- package/node/document/index.js +7 -0
- package/node/document/sc/index.js +49 -0
- package/node/index.js +15 -0
- package/node/utils/api.js +38 -0
- package/node/utils/emotion-cache.js +13 -0
- package/node/utils/index.js +32 -0
- package/package.json +3 -30
- package/{types.d.ts → typings.d.ts} +10 -7
- package/utils/api.d.ts +55 -55
- package/utils/api.js +35 -0
- package/{document/emotion.d.ts → utils/emotion-cache.d.ts} +5 -5
- package/utils/emotion-cache.js +8 -0
- package/utils/index.d.ts +19 -19
- package/utils/index.js +26 -0
- package/utils/package.json +6 -0
- package/Theme.js +0 -1905
- package/_tslib.js +0 -41
- package/app/App--emotion.d.ts +0 -10
- package/app/App--sc.d.ts +0 -10
- package/app/App--vanilla.d.ts +0 -10
- package/app/AppAuth--emotion.d.ts +0 -10
- package/app/AppAuth--sc.d.ts +0 -10
- package/app/AppMain--vanilla.d.ts +0 -27
- package/app/AppTheme--sc.d.ts +0 -13
- package/app/AppTheme--vanilla.d.ts +0 -10
- package/app/motion-features.d.ts +0 -2
- package/app.js +0 -250
- package/config.js +0 -183
- package/document/Document--emotion.d.ts +0 -5
- package/document/Document--vanilla.d.ts +0 -11
- package/document.js +0 -207
- package/emotion.js +0 -1329
- package/es.object.assign.js +0 -1074
- package/es.string.replace.js +0 -785
- package/es.string.split.js +0 -201
- package/index.esm.js +0 -4600
- package/index.umd.js +0 -4638
- package/motion-features.js +0 -10
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { AppThemeProps } from "./AppTheme";
|
|
3
|
+
import { AppMainProps } from "./AppMain";
|
|
4
|
+
export declare type NextAppProps = AppProps & AppThemeProps & AppMainProps;
|
|
5
|
+
/**
|
|
6
|
+
* App
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { NextApp, NextAppProps } from "@koine/next/app/css/auth";
|
|
12
|
+
* import { Favicon, AnalyticsGoogle } from "@koine/next";
|
|
13
|
+
* import { theme } from "src/helpers/theme";
|
|
14
|
+
* import { Layout } from "src/components/Layout";
|
|
15
|
+
* // import "@fontsource/myfont/800.css";
|
|
16
|
+
* // import "src/helpers/theme.css";
|
|
17
|
+
*
|
|
18
|
+
* const motion = () => import("@koine/react/m/max").then((m) => m.default);
|
|
19
|
+
*
|
|
20
|
+
* export default function App(props: NextAppProps) {
|
|
21
|
+
* return (
|
|
22
|
+
* <NextApp
|
|
23
|
+
* {...props}
|
|
24
|
+
* Layout={Layout}
|
|
25
|
+
* theme={theme}
|
|
26
|
+
* seo={{
|
|
27
|
+
* titleTemplate: "%s | MyApp",
|
|
28
|
+
* defaultTitle: "MyApp",
|
|
29
|
+
* openGraph: {
|
|
30
|
+
* type: "website",
|
|
31
|
+
* locale: "en_US",
|
|
32
|
+
* url: "https://myapp.com/",
|
|
33
|
+
* site_name: "MyApp",
|
|
34
|
+
* },
|
|
35
|
+
* twitter: {
|
|
36
|
+
* handle: "@MklrNl",
|
|
37
|
+
* site: "@MyApp",
|
|
38
|
+
* cardType: "summary_large_image",
|
|
39
|
+
* },
|
|
40
|
+
* }}
|
|
41
|
+
* pre={
|
|
42
|
+
* <>
|
|
43
|
+
* <AnalyticsGoogle id="UA-xxxxxxxx-x" />
|
|
44
|
+
* <Favicon name="MyApp" color="#000000" />
|
|
45
|
+
* </>
|
|
46
|
+
* }
|
|
47
|
+
* />
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const NextApp: (props: NextAppProps) => JSX.Element;
|
|
54
|
+
export default NextApp;
|
package/app/css/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { AppHead } from "../AppHead";
|
|
4
|
+
import { AppTheme } from "./AppTheme";
|
|
5
|
+
import { AppMain } from "./AppMain";
|
|
6
|
+
/**
|
|
7
|
+
* App
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { NextApp, NextAppProps } from "@koine/next/app/css/auth";
|
|
13
|
+
* import { Favicon, AnalyticsGoogle } from "@koine/next";
|
|
14
|
+
* import { theme } from "src/helpers/theme";
|
|
15
|
+
* import { Layout } from "src/components/Layout";
|
|
16
|
+
* // import "@fontsource/myfont/800.css";
|
|
17
|
+
* // import "src/helpers/theme.css";
|
|
18
|
+
*
|
|
19
|
+
* const motion = () => import("@koine/react/m/max").then((m) => m.default);
|
|
20
|
+
*
|
|
21
|
+
* export default function App(props: NextAppProps) {
|
|
22
|
+
* return (
|
|
23
|
+
* <NextApp
|
|
24
|
+
* {...props}
|
|
25
|
+
* Layout={Layout}
|
|
26
|
+
* theme={theme}
|
|
27
|
+
* seo={{
|
|
28
|
+
* titleTemplate: "%s | MyApp",
|
|
29
|
+
* defaultTitle: "MyApp",
|
|
30
|
+
* openGraph: {
|
|
31
|
+
* type: "website",
|
|
32
|
+
* locale: "en_US",
|
|
33
|
+
* url: "https://myapp.com/",
|
|
34
|
+
* site_name: "MyApp",
|
|
35
|
+
* },
|
|
36
|
+
* twitter: {
|
|
37
|
+
* handle: "@MklrNl",
|
|
38
|
+
* site: "@MyApp",
|
|
39
|
+
* cardType: "summary_large_image",
|
|
40
|
+
* },
|
|
41
|
+
* }}
|
|
42
|
+
* pre={
|
|
43
|
+
* <>
|
|
44
|
+
* <AnalyticsGoogle id="UA-xxxxxxxx-x" />
|
|
45
|
+
* <Favicon name="MyApp" color="#000000" />
|
|
46
|
+
* </>
|
|
47
|
+
* }
|
|
48
|
+
* />
|
|
49
|
+
* );
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export const NextApp = (props) => {
|
|
55
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, { ...props, children: _jsx(AppMain, { ...props }) })] }));
|
|
56
|
+
};
|
|
57
|
+
export default NextApp;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppMainBaseProps, AppMainFramerProps } from "../AppMain";
|
|
2
|
+
export declare type AppMainProps = AppMainBaseProps & AppMainFramerProps;
|
|
3
|
+
/**
|
|
4
|
+
* App main
|
|
5
|
+
*
|
|
6
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
7
|
+
*
|
|
8
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
9
|
+
*/
|
|
10
|
+
export declare const AppMain: ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition, pre, post, }: AppMainProps) => JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRouter } from "next/router";
|
|
4
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
5
|
+
import { MotionProvider } from "@koine/react/m";
|
|
6
|
+
import { SeoDefaults } from "../../Seo";
|
|
7
|
+
import { NextProgress } from "../../NextProgress";
|
|
8
|
+
/**
|
|
9
|
+
* App main
|
|
10
|
+
*
|
|
11
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
12
|
+
*
|
|
13
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
14
|
+
*/
|
|
15
|
+
export const AppMain = ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition = {
|
|
16
|
+
initial: { opacity: 0 },
|
|
17
|
+
animate: { opacity: 1 },
|
|
18
|
+
exit: { opacity: 0 },
|
|
19
|
+
}, pre, post, }) => {
|
|
20
|
+
const { pathname } = useRouter();
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx(SeoDefaults, { ...seo }), pre, _jsxs(MotionProvider, { features: motion, children: [ProgressOverlay && _jsx(NextProgress, { Overlay: ProgressOverlay }), _jsx(Layout, { children: _jsx(AnimatePresence, { exitBeforeEnter: true, initial: false, children: _jsx(m.div, { ...transition, children: _createElement(Component, { ...pageProps, key: pathname }) }, pathname) }) })] }), post] }));
|
|
22
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { AppProps as NextAppProps } from "next/app";
|
|
3
|
-
import { Theme } from "@mui/material/styles";
|
|
4
|
-
import { EmotionCache } from "@emotion/react";
|
|
5
|
-
export declare type
|
|
6
|
-
emotionCache?: EmotionCache;
|
|
7
|
-
/**
|
|
8
|
-
* A theme object
|
|
9
|
-
*/
|
|
10
|
-
theme: Theme;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* App theme with `emotion` (good for `@mui`)s
|
|
14
|
-
*/
|
|
15
|
-
export declare const
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AppProps as NextAppProps } from "next/app";
|
|
3
|
+
import { Theme } from "@mui/material/styles";
|
|
4
|
+
import { EmotionCache } from "@emotion/react";
|
|
5
|
+
export declare type AppThemeProps = React.PropsWithChildren<NextAppProps & {
|
|
6
|
+
emotionCache?: EmotionCache;
|
|
7
|
+
/**
|
|
8
|
+
* A theme object
|
|
9
|
+
*/
|
|
10
|
+
theme: Theme;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* App theme with `emotion` (good for `@mui`)s
|
|
14
|
+
*/
|
|
15
|
+
export declare const AppTheme: ({ emotionCache, theme, children, }: AppThemeProps) => JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider } from "@mui/material/styles";
|
|
3
|
+
import { CacheProvider } from "@emotion/react";
|
|
4
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
5
|
+
import { Global, css } from "@emotion/react";
|
|
6
|
+
import { stylesGlobal } from "@koine/react/sc";
|
|
7
|
+
import { createEmotionCache } from "../../utils/emotion-cache";
|
|
8
|
+
// client-side cache, shared for the whole session of the user in the browser.
|
|
9
|
+
const clientSideEmotionCache = createEmotionCache();
|
|
10
|
+
/**
|
|
11
|
+
* App theme with `emotion` (good for `@mui`)s
|
|
12
|
+
*/
|
|
13
|
+
export const AppTheme = ({ emotionCache = clientSideEmotionCache, theme, children, }) => {
|
|
14
|
+
return (_jsx(CacheProvider, { value: emotionCache, children: _jsxs(ThemeProvider, { theme: theme, children: [_jsx(CssBaseline, {}), _jsx(Global, { styles: css `
|
|
15
|
+
${stylesGlobal}
|
|
16
|
+
` }), children] }) }));
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { AppThemeProps } from "../AppTheme";
|
|
3
|
+
import { AppMainProps } from "../AppMain";
|
|
4
|
+
export declare type NextAppProps = AppProps & AppThemeProps & AppMainProps;
|
|
5
|
+
/**
|
|
6
|
+
* App with authentication provided by `next-auth`
|
|
7
|
+
*/
|
|
8
|
+
export declare const NextApp: (props: NextAppProps) => JSX.Element;
|
|
9
|
+
export default NextApp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { SessionProvider } from "next-auth/react";
|
|
4
|
+
import { AppHead } from "../../AppHead";
|
|
5
|
+
import { AppTheme } from "../AppTheme";
|
|
6
|
+
import { AppMain } from "../AppMain";
|
|
7
|
+
/**
|
|
8
|
+
* App with authentication provided by `next-auth`
|
|
9
|
+
*/
|
|
10
|
+
export const NextApp = (props) => {
|
|
11
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, { session: props.pageProps.session, children: _jsx(AppTheme, { ...props, children: _jsx(AppMain, { ...props }) }) })] }));
|
|
12
|
+
};
|
|
13
|
+
export default NextApp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { AppThemeProps } from "./AppTheme";
|
|
3
|
+
import { AppMainProps } from "./AppMain";
|
|
4
|
+
export declare type NextAppProps = AppProps & AppThemeProps & AppMainProps;
|
|
5
|
+
/**
|
|
6
|
+
* App
|
|
7
|
+
*/
|
|
8
|
+
export declare const NextApp: (props: NextAppProps) => JSX.Element;
|
|
9
|
+
export default NextApp;
|
package/app/em/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { AppHead } from "../AppHead";
|
|
4
|
+
import { AppTheme } from "./AppTheme";
|
|
5
|
+
import { AppMain } from "./AppMain";
|
|
6
|
+
/**
|
|
7
|
+
* App
|
|
8
|
+
*/
|
|
9
|
+
export const NextApp = (props) => {
|
|
10
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, { ...props, children: _jsx(AppMain, { ...props }) })] }));
|
|
11
|
+
};
|
|
12
|
+
export default NextApp;
|
package/app/index.d.ts
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./App--vanilla";
|
|
4
|
-
export * from "./AppAuth--emotion";
|
|
5
|
-
export * from "./AppAuth--sc";
|
|
6
|
-
export * from "./AppHead";
|
|
7
|
-
export * from "./AppMain";
|
|
8
|
-
export * from "./AppMain--vanilla";
|
|
9
|
-
export * from "./AppTheme--emotion";
|
|
10
|
-
export * from "./AppTheme--sc";
|
|
11
|
-
export * from "./AppTheme--vanilla";
|
|
1
|
+
export * from "./AppHead";
|
|
2
|
+
export * from "./AppMain";
|
package/app/index.js
ADDED
package/app/package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppMainBaseProps, AppMainFramerProps } from "../AppMain";
|
|
2
|
+
export declare type AppMainProps = AppMainBaseProps & AppMainFramerProps;
|
|
3
|
+
/**
|
|
4
|
+
* App main
|
|
5
|
+
*
|
|
6
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
7
|
+
*
|
|
8
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
9
|
+
*/
|
|
10
|
+
export declare const AppMain: ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition, pre, post, }: AppMainProps) => JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRouter } from "next/router";
|
|
4
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
5
|
+
import { MotionProvider } from "@koine/react/m";
|
|
6
|
+
import { SeoDefaults } from "../../Seo";
|
|
7
|
+
import { NextProgress } from "../../NextProgress";
|
|
8
|
+
/**
|
|
9
|
+
* App main
|
|
10
|
+
*
|
|
11
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
12
|
+
*
|
|
13
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
14
|
+
*/
|
|
15
|
+
export const AppMain = ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition = {
|
|
16
|
+
initial: { opacity: 0 },
|
|
17
|
+
animate: { opacity: 1 },
|
|
18
|
+
exit: { opacity: 0 },
|
|
19
|
+
}, pre, post, }) => {
|
|
20
|
+
const { pathname } = useRouter();
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx(SeoDefaults, { ...seo }), pre, _jsxs(MotionProvider, { features: motion, children: [ProgressOverlay && _jsx(NextProgress, { Overlay: ProgressOverlay }), _jsx(Layout, { children: _jsx(AnimatePresence, { exitBeforeEnter: true, initial: false, children: _jsx(m.div, { ...transition, children: _createElement(Component, { ...pageProps, key: pathname }) }, pathname) }) })] }), post] }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AppProps as NextAppProps } from "next/app";
|
|
3
|
+
import { Theme } from "@koine/react/sc";
|
|
4
|
+
export declare type AppThemeProps = React.PropsWithChildren<NextAppProps & {
|
|
5
|
+
/**
|
|
6
|
+
* A theme object
|
|
7
|
+
*/
|
|
8
|
+
theme: Theme;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* App theme with `styled-components`
|
|
12
|
+
*/
|
|
13
|
+
export declare const AppTheme: ({ theme, children }: AppThemeProps) => JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { StylesGlobal } from "@koine/react/sc";
|
|
4
|
+
/**
|
|
5
|
+
* App theme with `styled-components`
|
|
6
|
+
*/
|
|
7
|
+
export const AppTheme = ({ theme, children }) => {
|
|
8
|
+
return (_jsxs(ThemeProvider, { theme: theme, children: [_jsx(StylesGlobal, {}), children] }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { AppThemeProps } from "../AppTheme";
|
|
3
|
+
import { AppMainProps } from "../AppMain";
|
|
4
|
+
export declare type NextAppProps = AppProps & AppThemeProps & AppMainProps;
|
|
5
|
+
/**
|
|
6
|
+
* App with authentication provided by `next-auth`
|
|
7
|
+
*/
|
|
8
|
+
export declare const NextApp: (props: NextAppProps) => JSX.Element;
|
|
9
|
+
export default NextApp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { SessionProvider } from "next-auth/react";
|
|
4
|
+
import { AppHead } from "../../AppHead";
|
|
5
|
+
import { AppTheme } from "../AppTheme";
|
|
6
|
+
import { AppMain } from "../AppMain";
|
|
7
|
+
/**
|
|
8
|
+
* App with authentication provided by `next-auth`
|
|
9
|
+
*/
|
|
10
|
+
export const NextApp = (props) => {
|
|
11
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, { session: props.pageProps.session, children: _jsx(AppTheme, { ...props, children: _jsx(AppMain, { ...props }) }) })] }));
|
|
12
|
+
};
|
|
13
|
+
export default NextApp;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { AppThemeProps } from "./AppTheme";
|
|
3
|
+
import { AppMainProps } from "./AppMain";
|
|
4
|
+
export declare type NextAppProps = AppProps & AppThemeProps & AppMainProps;
|
|
5
|
+
/**
|
|
6
|
+
* App
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { NextApp, NextAppProps } from "@koine/next/app/sc/auth";
|
|
12
|
+
* import { Favicon, AnalyticsGoogle } from "@koine/next";
|
|
13
|
+
* import { theme } from "src/helpers/theme";
|
|
14
|
+
* import { Layout, ProgressOverlay } from "src/components/Layout";
|
|
15
|
+
* // import "@fontsource/myfont/800.css";
|
|
16
|
+
* // import "src/helpers/theme.css";
|
|
17
|
+
*
|
|
18
|
+
* const motion = () => import("@koine/react/m/max").then((m) => m.default);
|
|
19
|
+
*
|
|
20
|
+
* export default function App(props: NextAppProps) {
|
|
21
|
+
* return (
|
|
22
|
+
* <NextApp
|
|
23
|
+
* {...props}
|
|
24
|
+
* Layout={Layout}
|
|
25
|
+
* ProgressOverlay={ProgressOverlay}
|
|
26
|
+
* theme={theme}
|
|
27
|
+
* motion={motion}
|
|
28
|
+
* seo={{
|
|
29
|
+
* titleTemplate: "%s | MyApp",
|
|
30
|
+
* defaultTitle: "MyApp",
|
|
31
|
+
* openGraph: {
|
|
32
|
+
* type: "website",
|
|
33
|
+
* locale: "en_US",
|
|
34
|
+
* url: "https://myapp.com/",
|
|
35
|
+
* site_name: "MyApp",
|
|
36
|
+
* },
|
|
37
|
+
* twitter: {
|
|
38
|
+
* handle: "@MklrNl",
|
|
39
|
+
* site: "@MyApp",
|
|
40
|
+
* cardType: "summary_large_image",
|
|
41
|
+
* },
|
|
42
|
+
* }}
|
|
43
|
+
* pre={
|
|
44
|
+
* <>
|
|
45
|
+
* <AnalyticsGoogle id="UA-xxxxxxxx-x" />
|
|
46
|
+
* <Favicon name="MyApp" color="#000000" />
|
|
47
|
+
* </>
|
|
48
|
+
* }
|
|
49
|
+
* />
|
|
50
|
+
* );
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const NextApp: (props: NextAppProps) => JSX.Element;
|
|
56
|
+
export default NextApp;
|
package/app/sc/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { AppHead } from "../AppHead";
|
|
4
|
+
import { AppTheme } from "./AppTheme";
|
|
5
|
+
import { AppMain } from "./AppMain";
|
|
6
|
+
/**
|
|
7
|
+
* App
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { NextApp, NextAppProps } from "@koine/next/app/sc/auth";
|
|
13
|
+
* import { Favicon, AnalyticsGoogle } from "@koine/next";
|
|
14
|
+
* import { theme } from "src/helpers/theme";
|
|
15
|
+
* import { Layout, ProgressOverlay } from "src/components/Layout";
|
|
16
|
+
* // import "@fontsource/myfont/800.css";
|
|
17
|
+
* // import "src/helpers/theme.css";
|
|
18
|
+
*
|
|
19
|
+
* const motion = () => import("@koine/react/m/max").then((m) => m.default);
|
|
20
|
+
*
|
|
21
|
+
* export default function App(props: NextAppProps) {
|
|
22
|
+
* return (
|
|
23
|
+
* <NextApp
|
|
24
|
+
* {...props}
|
|
25
|
+
* Layout={Layout}
|
|
26
|
+
* ProgressOverlay={ProgressOverlay}
|
|
27
|
+
* theme={theme}
|
|
28
|
+
* motion={motion}
|
|
29
|
+
* seo={{
|
|
30
|
+
* titleTemplate: "%s | MyApp",
|
|
31
|
+
* defaultTitle: "MyApp",
|
|
32
|
+
* openGraph: {
|
|
33
|
+
* type: "website",
|
|
34
|
+
* locale: "en_US",
|
|
35
|
+
* url: "https://myapp.com/",
|
|
36
|
+
* site_name: "MyApp",
|
|
37
|
+
* },
|
|
38
|
+
* twitter: {
|
|
39
|
+
* handle: "@MklrNl",
|
|
40
|
+
* site: "@MyApp",
|
|
41
|
+
* cardType: "summary_large_image",
|
|
42
|
+
* },
|
|
43
|
+
* }}
|
|
44
|
+
* pre={
|
|
45
|
+
* <>
|
|
46
|
+
* <AnalyticsGoogle id="UA-xxxxxxxx-x" />
|
|
47
|
+
* <Favicon name="MyApp" color="#000000" />
|
|
48
|
+
* </>
|
|
49
|
+
* }
|
|
50
|
+
* />
|
|
51
|
+
* );
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const NextApp = (props) => {
|
|
57
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, { ...props, children: _jsx(AppMain, { ...props }) })] }));
|
|
58
|
+
};
|
|
59
|
+
export default NextApp;
|
package/config/index.d.ts
CHANGED
|
@@ -1,58 +1,71 @@
|
|
|
1
|
-
import type { NextConfig } from "next";
|
|
2
|
-
import type { Redirect, Rewrite } from "next/dist/lib/load-custom-routes";
|
|
3
|
-
/**
|
|
4
|
-
* Normalise pathname
|
|
5
|
-
*
|
|
6
|
-
* From a path like `/some//malformed/path///` it returns `some/malformed/path`
|
|
7
|
-
*
|
|
8
|
-
* - Removes subsequent slashes
|
|
9
|
-
* - Removing initial and ending slashes
|
|
10
|
-
*/
|
|
11
|
-
export declare function normaliseUrlPathname(pathname: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Clean a pathname and encode each part
|
|
14
|
-
*
|
|
15
|
-
* @see {@link normaliseUrlPathname}
|
|
16
|
-
*/
|
|
17
|
-
export declare function encodePathname(pathname: string): string;
|
|
18
|
-
/**
|
|
19
|
-
*/
|
|
20
|
-
export declare function getPathRedirect(locale: string, localisedPathname: string, templateName: string, dynamic?: boolean, permanent?: boolean): {
|
|
21
|
-
source: string;
|
|
22
|
-
destination: string;
|
|
23
|
-
permanent: boolean;
|
|
24
|
-
locale: false;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
*/
|
|
28
|
-
export declare function getPathRewrite(source: string, destination: string, dynamic?: boolean): {
|
|
29
|
-
source: string;
|
|
30
|
-
destination: string;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
*/
|
|
34
|
-
export declare function getRedirects({ defaultLocale, routes, dynamicRoutes, permanent, }: {
|
|
35
|
-
defaultLocale: string;
|
|
36
|
-
routes: Record<string, string>;
|
|
37
|
-
dynamicRoutes: Record<string, boolean>;
|
|
38
|
-
permanent?: boolean;
|
|
39
|
-
}): Promise<Redirect[]>;
|
|
40
|
-
/**
|
|
41
|
-
*/
|
|
42
|
-
export declare function getRewrites({ routes, dynamicRoutes, }: {
|
|
43
|
-
routes: Record<string, string>;
|
|
44
|
-
dynamicRoutes: Record<string, boolean>;
|
|
45
|
-
}): Promise<Rewrite[]>;
|
|
46
|
-
declare type KoineNextConfig = {
|
|
47
|
-
/** @default true Nx monorepo setup */
|
|
48
|
-
nx?: boolean;
|
|
49
|
-
/** @default true Svg to react components */
|
|
50
|
-
svg?: boolean;
|
|
51
|
-
/** @default true Styled components enabled */
|
|
52
|
-
sc?: boolean;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import type { NextConfig } from "next";
|
|
2
|
+
import type { Redirect, Rewrite } from "next/dist/lib/load-custom-routes";
|
|
3
|
+
/**
|
|
4
|
+
* Normalise pathname
|
|
5
|
+
*
|
|
6
|
+
* From a path like `/some//malformed/path///` it returns `some/malformed/path`
|
|
7
|
+
*
|
|
8
|
+
* - Removes subsequent slashes
|
|
9
|
+
* - Removing initial and ending slashes
|
|
10
|
+
*/
|
|
11
|
+
export declare function normaliseUrlPathname(pathname: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Clean a pathname and encode each part
|
|
14
|
+
*
|
|
15
|
+
* @see {@link normaliseUrlPathname}
|
|
16
|
+
*/
|
|
17
|
+
export declare function encodePathname(pathname: string): string;
|
|
18
|
+
/**
|
|
19
|
+
*/
|
|
20
|
+
export declare function getPathRedirect(locale: string, localisedPathname: string, templateName: string, dynamic?: boolean, permanent?: boolean): {
|
|
21
|
+
source: string;
|
|
22
|
+
destination: string;
|
|
23
|
+
permanent: boolean;
|
|
24
|
+
locale: false;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
*/
|
|
28
|
+
export declare function getPathRewrite(source: string, destination: string, dynamic?: boolean): {
|
|
29
|
+
source: string;
|
|
30
|
+
destination: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
*/
|
|
34
|
+
export declare function getRedirects({ defaultLocale, routes, dynamicRoutes, permanent, }: {
|
|
35
|
+
defaultLocale: string;
|
|
36
|
+
routes: Record<string, string>;
|
|
37
|
+
dynamicRoutes: Record<string, boolean>;
|
|
38
|
+
permanent?: boolean;
|
|
39
|
+
}): Promise<Redirect[]>;
|
|
40
|
+
/**
|
|
41
|
+
*/
|
|
42
|
+
export declare function getRewrites({ routes, dynamicRoutes, }: {
|
|
43
|
+
routes: Record<string, string>;
|
|
44
|
+
dynamicRoutes: Record<string, boolean>;
|
|
45
|
+
}): Promise<Rewrite[]>;
|
|
46
|
+
declare type KoineNextConfig = {
|
|
47
|
+
/** @default true Nx monorepo setup */
|
|
48
|
+
nx?: boolean;
|
|
49
|
+
/** @default true Svg to react components */
|
|
50
|
+
svg?: boolean;
|
|
51
|
+
/** @default true Styled components enabled */
|
|
52
|
+
sc?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* When true uses `*.page.ts` or `*.page.tsx` extension for next.js config option [`pageExtensions`](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory). When `true` it enables the same for `next-translate`
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
page?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Get Next.js config with some basic opinionated defaults
|
|
61
|
+
*
|
|
62
|
+
* @param {object} options
|
|
63
|
+
* @property {boolean} [options.nx=false] Nx monorepo setup
|
|
64
|
+
* @property {boolean} [options.svg=false] Svg to react components
|
|
65
|
+
* @property {boolean} [options.sc=false] Styled components enabled
|
|
66
|
+
* @property {boolean} [options.page=false] When `true` uses `*.page.ts` or `*.page.tsx`
|
|
67
|
+
* extension for next.js config option [`pageExtensions`](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory)
|
|
68
|
+
* and it enables the same for `next-translate`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function withKoine({ nx, svg, sc, page, ...nextConfig }?: NextConfig & KoineNextConfig): NextConfig;
|
|
71
|
+
export default withKoine;
|