@koine/next 1.0.9 → 1.0.10

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.
Files changed (184) hide show
  1. package/package.json +30 -2
  2. package/Analytics/AnalyticsGoogle.d.ts +0 -5
  3. package/Analytics/AnalyticsGoogle.js +0 -37
  4. package/Analytics/index.d.ts +0 -1
  5. package/Analytics/index.js +0 -1
  6. package/Analytics/package.json +0 -6
  7. package/Auth/helpers.d.ts +0 -17
  8. package/Auth/helpers.js +0 -21
  9. package/Auth/index.d.ts +0 -4
  10. package/Auth/index.js +0 -4
  11. package/Auth/package.json +0 -6
  12. package/Auth/useLogin.d.ts +0 -7
  13. package/Auth/useLogin.js +0 -50
  14. package/Auth/useLoginUrl.d.ts +0 -1
  15. package/Auth/useLoginUrl.js +0 -11
  16. package/Auth/useLogout.d.ts +0 -6
  17. package/Auth/useLogout.js +0 -52
  18. package/Favicon/Favicon.d.ts +0 -3
  19. package/Favicon/Favicon.js +0 -4
  20. package/Favicon/index.d.ts +0 -1
  21. package/Favicon/index.js +0 -1
  22. package/Favicon/package.json +0 -6
  23. package/Forms/index.d.ts +0 -2
  24. package/Forms/index.js +0 -2
  25. package/Forms/package.json +0 -6
  26. package/Forms/useForm.d.ts +0 -32
  27. package/Forms/useForm.js +0 -37
  28. package/Forms/useSubmit.d.ts +0 -24
  29. package/Forms/useSubmit.js +0 -23
  30. package/Head/Head.d.ts +0 -1
  31. package/Head/Head.js +0 -1
  32. package/Head/index.d.ts +0 -1
  33. package/Head/index.js +0 -1
  34. package/Head/package.json +0 -6
  35. package/I18n/I18n.d.ts +0 -44
  36. package/I18n/I18n.js +0 -74
  37. package/I18n/index.d.ts +0 -1
  38. package/I18n/index.js +0 -1
  39. package/I18n/package.json +0 -6
  40. package/Img/Img.d.ts +0 -21
  41. package/Img/Img.js +0 -28
  42. package/Img/index.d.ts +0 -1
  43. package/Img/index.js +0 -1
  44. package/Img/package.json +0 -6
  45. package/Link/Link.d.ts +0 -9
  46. package/Link/Link.js +0 -9
  47. package/Link/index.d.ts +0 -1
  48. package/Link/index.js +0 -1
  49. package/Link/package.json +0 -6
  50. package/NextProgress/NextProgress.d.ts +0 -24
  51. package/NextProgress/NextProgress.js +0 -37
  52. package/NextProgress/index.d.ts +0 -2
  53. package/NextProgress/index.js +0 -1
  54. package/NextProgress/package.json +0 -6
  55. package/Seo/Seo.d.ts +0 -3
  56. package/Seo/Seo.js +0 -8
  57. package/Seo/SeoDefaults.d.ts +0 -3
  58. package/Seo/SeoDefaults.js +0 -12
  59. package/Seo/helpers.d.ts +0 -48
  60. package/Seo/helpers.js +0 -111
  61. package/Seo/index.d.ts +0 -12
  62. package/Seo/index.js +0 -12
  63. package/Seo/package.json +0 -6
  64. package/Theme/Theme.d.ts +0 -46
  65. package/Theme/Theme.js +0 -235
  66. package/Theme/index.d.ts +0 -1
  67. package/Theme/index.js +0 -1
  68. package/Theme/package.json +0 -6
  69. package/app/AppHead.d.ts +0 -2
  70. package/app/AppHead.js +0 -5
  71. package/app/AppMain.d.ts +0 -35
  72. package/app/AppMain.js +0 -1
  73. package/app/css/AppMain.d.ts +0 -8
  74. package/app/css/AppMain.js +0 -11
  75. package/app/css/AppTheme.d.ts +0 -10
  76. package/app/css/AppTheme.js +0 -12
  77. package/app/css/auth/index.d.ts +0 -9
  78. package/app/css/auth/index.js +0 -13
  79. package/app/css/auth/package.json +0 -6
  80. package/app/css/index.d.ts +0 -54
  81. package/app/css/index.js +0 -57
  82. package/app/css/package.json +0 -6
  83. package/app/em/AppMain.d.ts +0 -10
  84. package/app/em/AppMain.js +0 -22
  85. package/app/em/AppTheme.d.ts +0 -15
  86. package/app/em/AppTheme.js +0 -17
  87. package/app/em/auth/index.d.ts +0 -9
  88. package/app/em/auth/index.js +0 -13
  89. package/app/em/auth/package.json +0 -6
  90. package/app/em/index.d.ts +0 -9
  91. package/app/em/index.js +0 -12
  92. package/app/em/package.json +0 -6
  93. package/app/index.d.ts +0 -2
  94. package/app/index.js +0 -2
  95. package/app/package.json +0 -6
  96. package/app/sc/AppMain.d.ts +0 -10
  97. package/app/sc/AppMain.js +0 -22
  98. package/app/sc/AppTheme.d.ts +0 -13
  99. package/app/sc/AppTheme.js +0 -9
  100. package/app/sc/auth/index.d.ts +0 -9
  101. package/app/sc/auth/index.js +0 -13
  102. package/app/sc/auth/package.json +0 -6
  103. package/app/sc/index.d.ts +0 -56
  104. package/app/sc/index.js +0 -59
  105. package/app/sc/package.json +0 -6
  106. package/config/index.d.ts +0 -71
  107. package/config/index.js +0 -174
  108. package/config/package.json +0 -6
  109. package/document/Document.d.ts +0 -15
  110. package/document/Document.js +0 -19
  111. package/document/css/index.d.ts +0 -22
  112. package/document/css/index.js +0 -30
  113. package/document/css/package.json +0 -6
  114. package/document/em/index.d.ts +0 -16
  115. package/document/em/index.js +0 -68
  116. package/document/em/package.json +0 -6
  117. package/document/index.d.ts +0 -2
  118. package/document/index.js +0 -2
  119. package/document/package.json +0 -6
  120. package/document/sc/index.d.ts +0 -20
  121. package/document/sc/index.js +0 -44
  122. package/document/sc/package.json +0 -6
  123. package/index.d.ts +0 -12
  124. package/index.js +0 -12
  125. package/node/Analytics/AnalyticsGoogle.js +0 -42
  126. package/node/Analytics/index.js +0 -4
  127. package/node/Auth/helpers.js +0 -26
  128. package/node/Auth/index.js +0 -7
  129. package/node/Auth/useLogin.js +0 -54
  130. package/node/Auth/useLoginUrl.js +0 -15
  131. package/node/Auth/useLogout.js +0 -56
  132. package/node/Favicon/Favicon.js +0 -9
  133. package/node/Favicon/index.js +0 -4
  134. package/node/Forms/index.js +0 -5
  135. package/node/Forms/useForm.js +0 -41
  136. package/node/Forms/useSubmit.js +0 -27
  137. package/node/Head/Head.js +0 -8
  138. package/node/Head/index.js +0 -4
  139. package/node/I18n/I18n.js +0 -82
  140. package/node/I18n/index.js +0 -4
  141. package/node/Img/Img.js +0 -34
  142. package/node/Img/index.js +0 -4
  143. package/node/Link/Link.js +0 -13
  144. package/node/Link/index.js +0 -4
  145. package/node/NextProgress/NextProgress.js +0 -41
  146. package/node/NextProgress/index.js +0 -5
  147. package/node/Seo/Seo.js +0 -12
  148. package/node/Seo/SeoDefaults.js +0 -16
  149. package/node/Seo/helpers.js +0 -115
  150. package/node/Seo/index.js +0 -15
  151. package/node/Theme/Theme.js +0 -241
  152. package/node/Theme/index.js +0 -4
  153. package/node/app/AppHead.js +0 -10
  154. package/node/app/AppMain.js +0 -2
  155. package/node/app/css/AppMain.js +0 -16
  156. package/node/app/css/AppTheme.js +0 -16
  157. package/node/app/css/auth/index.js +0 -18
  158. package/node/app/css/index.js +0 -62
  159. package/node/app/em/AppMain.js +0 -26
  160. package/node/app/em/AppTheme.js +0 -22
  161. package/node/app/em/auth/index.js +0 -18
  162. package/node/app/em/index.js +0 -17
  163. package/node/app/index.js +0 -5
  164. package/node/app/sc/AppMain.js +0 -26
  165. package/node/app/sc/AppTheme.js +0 -13
  166. package/node/app/sc/auth/index.js +0 -18
  167. package/node/app/sc/index.js +0 -64
  168. package/node/config/index.js +0 -184
  169. package/node/document/Document.js +0 -24
  170. package/node/document/css/index.js +0 -35
  171. package/node/document/em/index.js +0 -73
  172. package/node/document/index.js +0 -7
  173. package/node/document/sc/index.js +0 -49
  174. package/node/index.js +0 -15
  175. package/node/utils/api.js +0 -38
  176. package/node/utils/emotion-cache.js +0 -13
  177. package/node/utils/index.js +0 -32
  178. package/utils/api.d.ts +0 -55
  179. package/utils/api.js +0 -35
  180. package/utils/emotion-cache.d.ts +0 -5
  181. package/utils/emotion-cache.js +0 -8
  182. package/utils/index.d.ts +0 -19
  183. package/utils/index.js +0 -26
  184. package/utils/package.json +0 -6
@@ -1,10 +0,0 @@
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;
package/app/sc/AppMain.js DELETED
@@ -1,22 +0,0 @@
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,13 +0,0 @@
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;
@@ -1,9 +0,0 @@
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
- };
@@ -1,9 +0,0 @@
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;
@@ -1,13 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "main": "../../../node/app/sc/auth/index.js",
5
- "types": "./index.d.ts"
6
- }
package/app/sc/index.d.ts DELETED
@@ -1,56 +0,0 @@
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 DELETED
@@ -1,59 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "main": "../../node/app/sc/index.js",
5
- "types": "./index.d.ts"
6
- }
package/config/index.d.ts DELETED
@@ -1,71 +0,0 @@
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;
package/config/index.js DELETED
@@ -1,174 +0,0 @@
1
- /**
2
- * Normalise pathname
3
- *
4
- * From a path like `/some//malformed/path///` it returns `some/malformed/path`
5
- *
6
- * - Removes subsequent slashes
7
- * - Removing initial and ending slashes
8
- */
9
- export function normaliseUrlPathname(pathname) {
10
- return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
11
- }
12
- /**
13
- * Clean a pathname and encode each part
14
- *
15
- * @see {@link normaliseUrlPathname}
16
- */
17
- export function encodePathname(pathname) {
18
- const parts = normaliseUrlPathname(pathname).split("/");
19
- return parts
20
- .filter((part) => !!part)
21
- .map((part) => encodeURIComponent(part))
22
- .join("/");
23
- }
24
- /**
25
- */
26
- export function getPathRedirect(locale, localisedPathname, templateName, dynamic, permanent) {
27
- const suffix = dynamic ? `/:slug*` : "";
28
- return {
29
- source: `/${locale}/${encodePathname(localisedPathname)}${suffix}`,
30
- destination: `/${encodePathname(templateName)}${suffix}`,
31
- permanent: Boolean(permanent),
32
- locale: false,
33
- };
34
- }
35
- /**
36
- */
37
- export function getPathRewrite(source, destination, dynamic) {
38
- const suffix = dynamic ? `/:path*` : "";
39
- return {
40
- source: `/${encodePathname(source)}${suffix}`,
41
- destination: `/${encodePathname(destination)}${suffix}`,
42
- };
43
- }
44
- /**
45
- */
46
- export async function getRedirects({ defaultLocale, routes, dynamicRoutes, permanent, }) {
47
- const redirects = [];
48
- Object.keys(routes).forEach((page) => {
49
- const dynamic = dynamicRoutes[page];
50
- if (routes[page] !== page) {
51
- if (dynamic) {
52
- redirects.push(getPathRedirect(defaultLocale, page, routes[page], true, permanent));
53
- }
54
- else {
55
- redirects.push(getPathRedirect(defaultLocale, page, routes[page], false, permanent));
56
- }
57
- }
58
- });
59
- // console.log("redirects", redirects);
60
- return redirects;
61
- }
62
- /**
63
- */
64
- export async function getRewrites({ routes, dynamicRoutes, }) {
65
- const rewrites = [];
66
- Object.keys(routes).forEach((page) => {
67
- const dynamic = dynamicRoutes[page];
68
- if (routes[page] !== page) {
69
- if (dynamic) {
70
- rewrites.push(getPathRewrite(routes[page], page, true));
71
- }
72
- else {
73
- rewrites.push(getPathRewrite(routes[page], page));
74
- }
75
- }
76
- });
77
- // console.log("rewrites", rewrites);
78
- return rewrites;
79
- }
80
- /**
81
- * Get Next.js config with some basic opinionated defaults
82
- *
83
- * @param {object} options
84
- * @property {boolean} [options.nx=false] Nx monorepo setup
85
- * @property {boolean} [options.svg=false] Svg to react components
86
- * @property {boolean} [options.sc=false] Styled components enabled
87
- * @property {boolean} [options.page=false] When `true` uses `*.page.ts` or `*.page.tsx`
88
- * 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)
89
- * and it enables the same for `next-translate`.
90
- */
91
- export function withKoine({ nx = true, svg = true, sc = true, page, ...nextConfig } = {}) {
92
- nextConfig = {
93
- // @see https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
94
- pageExtensions: page ? ["page.tsx", "page.ts"] : undefined,
95
- eslint: {
96
- ignoreDuringBuilds: true, // we have this strict check on each commit
97
- },
98
- typescript: {
99
- ignoreBuildErrors: true, // we have this strict check on each commit
100
- },
101
- poweredByHeader: false,
102
- swcMinify: true,
103
- experimental: {
104
- // @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
105
- // @see critters error https://github.com/vercel/next.js/issues/20742
106
- // optimizeCss: true,
107
- // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
108
- scrollRestoration: true,
109
- // concurrentFeatures: true,
110
- // serverComponents: true,
111
- // reactRoot: true,
112
- ...(nextConfig.experimental || {}),
113
- // @see https://nextjs.org/docs/advanced-features/compiler#modularize-imports
114
- modularizeImports: {
115
- ...(nextConfig?.experimental?.modularizeImports || {}),
116
- // FIXME: make these work with the right file/folder structure?
117
- // "@koine/next/?(((\\w*)?/?)*)": {
118
- // transform: "@koine/next/{{ matches.[1] }}/{{member}}",
119
- // },
120
- // "@koine/react/?(((\\w*)?/?)*)": {
121
- // transform: "@koine/react/{{ matches.[1] }}/{{member}}",
122
- // },
123
- // "@koine/utils/?(((\\w*)?/?)*)": {
124
- // transform: "@koine/utils/{{ matches.[1] }}/{{member}}",
125
- // },
126
- },
127
- },
128
- // @see https://github.com/vercel/next.js/issues/7322#issuecomment-887330111
129
- // reactStrictMode: false,
130
- ...nextConfig,
131
- };
132
- if (svg) {
133
- if (nx) {
134
- // @see https://github.com/gregberge/svgr
135
- nextConfig["nx"] = {
136
- svgr: true,
137
- };
138
- }
139
- else {
140
- nextConfig.webpack = (_config, options) => {
141
- const webpackConfig = typeof nextConfig.webpack === "function"
142
- ? nextConfig.webpack(_config, options)
143
- : _config;
144
- // @see https://dev.to/dolearning/importing-svgs-to-next-js-nna#svgr
145
- webpackConfig.module.rules.push({
146
- test: /\.svg$/,
147
- use: [
148
- {
149
- loader: "@svgr/webpack",
150
- options: {
151
- svgoConfig: {
152
- plugins: [
153
- {
154
- name: "removeViewBox",
155
- active: false,
156
- },
157
- ],
158
- },
159
- },
160
- },
161
- ],
162
- });
163
- return webpackConfig;
164
- };
165
- }
166
- }
167
- if (sc) {
168
- nextConfig.compiler = {
169
- styledComponents: true,
170
- };
171
- }
172
- return nextConfig;
173
- }
174
- export default withKoine;
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "main": "../node/config/index.js",
5
- "types": "./index.d.ts"
6
- }
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- import NextDocument from "next/document";
3
- /**
4
- * Next Document wrapper for bare projects
5
- *
6
- * @example
7
- *
8
- * in your `myapp/pages/_document.tsx`:
9
- * ```tsx
10
- * export { Document as default } from "@koine/next/document";
11
- * ```
12
- */
13
- export declare class Document extends NextDocument {
14
- render(): JSX.Element;
15
- }
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import NextDocument, { Html, Head, Main, NextScript } from "next/document";
3
- import { Meta, NoJs } from "@koine/react";
4
- /**
5
- * Next Document wrapper for bare projects
6
- *
7
- * @example
8
- *
9
- * in your `myapp/pages/_document.tsx`:
10
- * ```tsx
11
- * export { Document as default } from "@koine/next/document";
12
- * ```
13
- */
14
- export class Document extends NextDocument {
15
- render() {
16
- const { locale, defaultLocale } = this.props.__NEXT_DATA__;
17
- return (_jsxs(Html, { lang: locale || defaultLocale, className: "no-js", children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] }));
18
- }
19
- }
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- import NextDocument, { DocumentContext, DocumentInitialProps } from "next/document";
3
- import { ThemeVanillaValue } from "@koine/react/sc";
4
- /**
5
- * Next Document wrapper for `css/tailwind` based projects
6
- *
7
- * Uses cookie to manage the current theme
8
- *
9
- * @example
10
- *
11
- * in your `myapp/pages/_document.tsx`:
12
- * ```tsx
13
- * export { Document as default } from "@koine/next/document/css";
14
- * ```
15
- */
16
- export declare class Document extends NextDocument {
17
- static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps & {
18
- theme: ThemeVanillaValue;
19
- }>;
20
- render(): JSX.Element;
21
- }
22
- export default Document;
@@ -1,30 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import NextDocument, { Html, Head, Main, NextScript, } from "next/document";
3
- import { Meta, NoJs } from "@koine/react";
4
- import { getInitialThemeFromRequest } from "@koine/react/sc"; // FIXME: this should be imported from another entrypoint
5
- /**
6
- * Next Document wrapper for `css/tailwind` based projects
7
- *
8
- * Uses cookie to manage the current theme
9
- *
10
- * @example
11
- *
12
- * in your `myapp/pages/_document.tsx`:
13
- * ```tsx
14
- * export { Document as default } from "@koine/next/document/css";
15
- * ```
16
- */
17
- export class Document extends NextDocument {
18
- static async getInitialProps(ctx) {
19
- const initialProps = await NextDocument.getInitialProps(ctx);
20
- return {
21
- ...initialProps,
22
- theme: getInitialThemeFromRequest(ctx.req?.headers.cookie /* || document?.cookie */ || ""),
23
- };
24
- }
25
- render() {
26
- const { locale, defaultLocale } = this.props.__NEXT_DATA__;
27
- return (_jsxs(Html, { lang: locale || defaultLocale, className: "no-js", children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] }));
28
- }
29
- }
30
- export default Document;
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "main": "../../node/document/css/index.js",
5
- "types": "./index.d.ts"
6
- }
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import NextDocument from "next/document";
3
- /**
4
- * Next Document wrapper for `emotion` based projects
5
- *
6
- * @example
7
- *
8
- * in your `myapp/pages/_document.tsx`:
9
- * ```tsx
10
- * export { Document as default } from "@koine/next/document/em";
11
- * ```
12
- */
13
- export declare class Document extends NextDocument {
14
- render(): JSX.Element;
15
- }
16
- export default Document;
@@ -1,68 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import NextDocument, { Html, Head, Main, NextScript } from "next/document";
3
- import { Meta, NoJs } from "@koine/react";
4
- import createEmotionServer from "@emotion/server/create-instance";
5
- import { createEmotionCache } from "../../utils/emotion-cache";
6
- /**
7
- * Next Document wrapper for `emotion` based projects
8
- *
9
- * @example
10
- *
11
- * in your `myapp/pages/_document.tsx`:
12
- * ```tsx
13
- * export { Document as default } from "@koine/next/document/em";
14
- * ```
15
- */
16
- export class Document extends NextDocument {
17
- render() {
18
- const { locale, defaultLocale } = this.props.__NEXT_DATA__;
19
- return (_jsxs(Html, { lang: locale || defaultLocale, className: "no-js", children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {}), this.props.emotionStyleTags] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] }));
20
- }
21
- }
22
- // `getInitialProps` belongs to `_document` (instead of `_app`),
23
- // it's compatible with static-site generation (SSG).
24
- Document.getInitialProps = async (ctx) => {
25
- // Resolution order
26
- //
27
- // On the server:
28
- // 1. app.getInitialProps
29
- // 2. page.getInitialProps
30
- // 3. document.getInitialProps
31
- // 4. app.render
32
- // 5. page.render
33
- // 6. document.render
34
- //
35
- // On the server with error:
36
- // 1. document.getInitialProps
37
- // 2. app.render
38
- // 3. page.render
39
- // 4. document.render
40
- //
41
- // On the client
42
- // 1. app.getInitialProps
43
- // 2. page.getInitialProps
44
- // 3. app.render
45
- // 4. page.render
46
- const originalRenderPage = ctx.renderPage;
47
- // You can consider sharing the same emotion cache between all the SSR requests to speed up performance.
48
- // However, be aware that it can have global side effects.
49
- const cache = createEmotionCache();
50
- const { extractCriticalToChunks } = createEmotionServer(cache);
51
- ctx.renderPage = () => originalRenderPage({
52
- enhanceApp: (App) => function EnhanceApp(props) {
53
- return _jsx(App, { emotionCache: cache, ...props });
54
- },
55
- });
56
- const initialProps = await Document.getInitialProps(ctx);
57
- // This is important. It prevents emotion to render invalid HTML.
58
- // See https://github.com/mui-org/material-ui/issues/26561#issuecomment-855286153
59
- const emotionStyles = extractCriticalToChunks(initialProps.html);
60
- const emotionStyleTags = emotionStyles.styles.map((style) => (_jsx("style", { "data-emotion": `${style.key} ${style.ids.join(" ")}`,
61
- // eslint-disable-next-line react/no-danger
62
- dangerouslySetInnerHTML: { __html: style.css } }, style.key)));
63
- return {
64
- ...initialProps,
65
- emotionStyleTags,
66
- };
67
- };
68
- export default Document;
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "./index.js",
4
- "main": "../../node/document/em/index.js",
5
- "types": "./index.d.ts"
6
- }
@@ -1,2 +0,0 @@
1
- export { Document } from "./Document";
2
- export { Document as default } from "./Document";