@koine/next 1.0.12 → 1.0.13

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 (56) hide show
  1. package/config/index.d.ts +13 -0
  2. package/config/index.js +27 -1
  3. package/package.json +8 -8
  4. package/node/Analytics/AnalyticsGoogle.js +0 -37
  5. package/node/Analytics/index.js +0 -4
  6. package/node/Auth/helpers.js +0 -27
  7. package/node/Auth/index.js +0 -7
  8. package/node/Auth/useLogin.js +0 -53
  9. package/node/Auth/useLoginUrl.js +0 -15
  10. package/node/Auth/useLogout.js +0 -56
  11. package/node/Favicon/Favicon.js +0 -9
  12. package/node/Favicon/index.js +0 -4
  13. package/node/Forms/index.js +0 -5
  14. package/node/Forms/useForm.js +0 -39
  15. package/node/Forms/useSubmit.js +0 -32
  16. package/node/Head/Head.js +0 -8
  17. package/node/Head/index.js +0 -4
  18. package/node/I18n/I18n.js +0 -102
  19. package/node/I18n/index.js +0 -4
  20. package/node/Img/Img.js +0 -35
  21. package/node/Img/index.js +0 -4
  22. package/node/Link/Link.js +0 -14
  23. package/node/Link/index.js +0 -4
  24. package/node/NextProgress/NextProgress.js +0 -44
  25. package/node/NextProgress/index.js +0 -5
  26. package/node/Seo/Seo.js +0 -12
  27. package/node/Seo/SeoDefaults.js +0 -16
  28. package/node/Seo/helpers.js +0 -119
  29. package/node/Seo/index.js +0 -15
  30. package/node/Theme/Theme.js +0 -250
  31. package/node/Theme/index.js +0 -4
  32. package/node/app/AppHead.js +0 -10
  33. package/node/app/AppMain.js +0 -2
  34. package/node/app/css/AppMain.js +0 -17
  35. package/node/app/css/AppTheme.js +0 -18
  36. package/node/app/css/auth/index.js +0 -18
  37. package/node/app/css/index.js +0 -62
  38. package/node/app/em/AppMain.js +0 -28
  39. package/node/app/em/AppTheme.js +0 -22
  40. package/node/app/em/auth/index.js +0 -18
  41. package/node/app/em/index.js +0 -17
  42. package/node/app/index.js +0 -5
  43. package/node/app/sc/AppMain.js +0 -28
  44. package/node/app/sc/AppTheme.js +0 -15
  45. package/node/app/sc/auth/index.js +0 -18
  46. package/node/app/sc/index.js +0 -64
  47. package/node/config/index.js +0 -174
  48. package/node/document/Document.js +0 -29
  49. package/node/document/css/index.js +0 -47
  50. package/node/document/em/index.js +0 -62
  51. package/node/document/index.js +0 -7
  52. package/node/document/sc/index.js +0 -68
  53. package/node/index.js +0 -15
  54. package/node/utils/api.js +0 -47
  55. package/node/utils/emotion-cache.js +0 -13
  56. package/node/utils/index.js +0 -33
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppMain = void 0;
4
- var tslib_1 = require("tslib");
5
- var react_1 = require("react");
6
- var jsx_runtime_1 = require("react/jsx-runtime");
7
- var router_1 = require("next/router");
8
- var framer_motion_1 = require("framer-motion");
9
- var m_1 = require("@koine/react/m");
10
- var Seo_1 = require("../../Seo");
11
- var NextProgress_1 = require("../../NextProgress");
12
- /**
13
- * App main
14
- *
15
- * It implies a setup for `styled-components` and `framer-motion` libraries.
16
- *
17
- * About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
18
- */
19
- var AppMain = function (_a) {
20
- var Component = _a.Component, pageProps = _a.pageProps, Layout = _a.Layout, ProgressOverlay = _a.ProgressOverlay, seo = _a.seo, motion = _a.motion, _b = _a.transition, transition = _b === void 0 ? {
21
- initial: { opacity: 0 },
22
- animate: { opacity: 1 },
23
- exit: { opacity: 0 },
24
- } : _b, pre = _a.pre, post = _a.post;
25
- var pathname = (0, router_1.useRouter)().pathname;
26
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Seo_1.SeoDefaults, tslib_1.__assign({}, seo)), pre, (0, jsx_runtime_1.jsxs)(m_1.MotionProvider, tslib_1.__assign({ features: motion }, { children: [ProgressOverlay && (0, jsx_runtime_1.jsx)(NextProgress_1.NextProgress, { Overlay: ProgressOverlay }), (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, tslib_1.__assign({ exitBeforeEnter: true, initial: false }, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.m.div, tslib_1.__assign({}, transition, { children: (0, react_1.createElement)(Component, tslib_1.__assign({}, pageProps, { key: pathname })) }), pathname) })) })] })), post] }));
27
- };
28
- exports.AppMain = AppMain;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppTheme = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var styled_components_1 = require("styled-components");
7
- var sc_1 = require("@koine/react/sc");
8
- /**
9
- * App theme with `styled-components`
10
- */
11
- var AppTheme = function (_a) {
12
- var theme = _a.theme, children = _a.children;
13
- return ((0, jsx_runtime_1.jsxs)(styled_components_1.ThemeProvider, tslib_1.__assign({ theme: theme }, { children: [(0, jsx_runtime_1.jsx)(sc_1.StylesGlobal, {}), children] })));
14
- };
15
- exports.AppTheme = AppTheme;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NextApp = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var react_1 = tslib_1.__importDefault(require("react"));
7
- var react_2 = require("next-auth/react");
8
- var AppHead_1 = require("../../AppHead");
9
- var AppTheme_1 = require("../AppTheme");
10
- var AppMain_1 = require("../AppMain");
11
- /**
12
- * App with authentication provided by `next-auth`
13
- */
14
- var NextApp = function (props) {
15
- return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(react_2.SessionProvider, tslib_1.__assign({ session: props.pageProps.session }, { children: (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, tslib_1.__assign({}, props, { children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, tslib_1.__assign({}, props)) })) }))] }));
16
- };
17
- exports.NextApp = NextApp;
18
- exports.default = exports.NextApp;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NextApp = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var react_1 = tslib_1.__importDefault(require("react"));
7
- var AppHead_1 = require("../AppHead");
8
- var AppTheme_1 = require("./AppTheme");
9
- var AppMain_1 = require("./AppMain");
10
- /**
11
- * App
12
- *
13
- * @example
14
- *
15
- * ```tsx
16
- * import { NextApp, NextAppProps } from "@koine/next/app/sc/auth";
17
- * import { Favicon, AnalyticsGoogle } from "@koine/next";
18
- * import { theme } from "src/helpers/theme";
19
- * import { Layout, ProgressOverlay } from "src/components/Layout";
20
- * // import "@fontsource/myfont/800.css";
21
- * // import "src/helpers/theme.css";
22
- *
23
- * const motion = () => import("@koine/react/m/max").then((m) => m.default);
24
- *
25
- * export default function App(props: NextAppProps) {
26
- * return (
27
- * <NextApp
28
- * {...props}
29
- * Layout={Layout}
30
- * ProgressOverlay={ProgressOverlay}
31
- * theme={theme}
32
- * motion={motion}
33
- * seo={{
34
- * titleTemplate: "%s | MyApp",
35
- * defaultTitle: "MyApp",
36
- * openGraph: {
37
- * type: "website",
38
- * locale: "en_US",
39
- * url: "https://myapp.com/",
40
- * site_name: "MyApp",
41
- * },
42
- * twitter: {
43
- * handle: "@MklrNl",
44
- * site: "@MyApp",
45
- * cardType: "summary_large_image",
46
- * },
47
- * }}
48
- * pre={
49
- * <>
50
- * <AnalyticsGoogle id="UA-xxxxxxxx-x" />
51
- * <Favicon name="MyApp" color="#000000" />
52
- * </>
53
- * }
54
- * />
55
- * );
56
- * }
57
- *
58
- * ```
59
- */
60
- var NextApp = function (props) {
61
- return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, tslib_1.__assign({}, props, { children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, tslib_1.__assign({}, props)) }))] }));
62
- };
63
- exports.NextApp = NextApp;
64
- exports.default = exports.NextApp;
@@ -1,174 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withKoine = exports.getRewrites = exports.getRedirects = exports.getPathRewrite = exports.getPathRedirect = exports.encodePathname = exports.normaliseUrlPathname = void 0;
4
- var tslib_1 = require("tslib");
5
- /**
6
- * Normalise pathname
7
- *
8
- * From a path like `/some//malformed/path///` it returns `some/malformed/path`
9
- *
10
- * - Removes subsequent slashes
11
- * - Removing initial and ending slashes
12
- */
13
- function normaliseUrlPathname(pathname) {
14
- return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
15
- }
16
- exports.normaliseUrlPathname = normaliseUrlPathname;
17
- /**
18
- * Clean a pathname and encode each part
19
- *
20
- * @see {@link normaliseUrlPathname}
21
- */
22
- function encodePathname(pathname) {
23
- var parts = normaliseUrlPathname(pathname).split("/");
24
- return parts
25
- .filter(function (part) { return !!part; })
26
- .map(function (part) { return encodeURIComponent(part); })
27
- .join("/");
28
- }
29
- exports.encodePathname = encodePathname;
30
- /**
31
- */
32
- function getPathRedirect(locale, localisedPathname, templateName, dynamic, permanent) {
33
- var suffix = dynamic ? "/:slug*" : "";
34
- return {
35
- source: "/".concat(locale, "/").concat(encodePathname(localisedPathname)).concat(suffix),
36
- destination: "/".concat(encodePathname(templateName)).concat(suffix),
37
- permanent: Boolean(permanent),
38
- locale: false,
39
- };
40
- }
41
- exports.getPathRedirect = getPathRedirect;
42
- /**
43
- */
44
- function getPathRewrite(source, destination, dynamic) {
45
- var suffix = dynamic ? "/:path*" : "";
46
- return {
47
- source: "/".concat(encodePathname(source)).concat(suffix),
48
- destination: "/".concat(encodePathname(destination)).concat(suffix),
49
- };
50
- }
51
- exports.getPathRewrite = getPathRewrite;
52
- /**
53
- */
54
- function getRedirects(_a) {
55
- var defaultLocale = _a.defaultLocale, routes = _a.routes, dynamicRoutes = _a.dynamicRoutes, permanent = _a.permanent;
56
- return tslib_1.__awaiter(this, void 0, void 0, function () {
57
- var redirects;
58
- return tslib_1.__generator(this, function (_b) {
59
- redirects = [];
60
- Object.keys(routes).forEach(function (page) {
61
- var dynamic = dynamicRoutes[page];
62
- if (routes[page] !== page) {
63
- if (dynamic) {
64
- redirects.push(getPathRedirect(defaultLocale, page, routes[page], true, permanent));
65
- }
66
- else {
67
- redirects.push(getPathRedirect(defaultLocale, page, routes[page], false, permanent));
68
- }
69
- }
70
- });
71
- // console.log("redirects", redirects);
72
- return [2 /*return*/, redirects];
73
- });
74
- });
75
- }
76
- exports.getRedirects = getRedirects;
77
- /**
78
- */
79
- function getRewrites(_a) {
80
- var routes = _a.routes, dynamicRoutes = _a.dynamicRoutes;
81
- return tslib_1.__awaiter(this, void 0, void 0, function () {
82
- var rewrites;
83
- return tslib_1.__generator(this, function (_b) {
84
- rewrites = [];
85
- Object.keys(routes).forEach(function (page) {
86
- var dynamic = dynamicRoutes[page];
87
- if (routes[page] !== page) {
88
- if (dynamic) {
89
- rewrites.push(getPathRewrite(routes[page], page, true));
90
- }
91
- else {
92
- rewrites.push(getPathRewrite(routes[page], page));
93
- }
94
- }
95
- });
96
- // console.log("rewrites", rewrites);
97
- return [2 /*return*/, rewrites];
98
- });
99
- });
100
- }
101
- exports.getRewrites = getRewrites;
102
- /**
103
- * Get Next.js config with some basic opinionated defaults
104
- *
105
- * @param {object} options
106
- * @property {boolean} [options.nx=false] Nx monorepo setup
107
- * @property {boolean} [options.svg=false] Svg to react components
108
- * @property {boolean} [options.sc=false] Styled components enabled
109
- * @property {boolean} [options.page=false] When `true` uses `*.page.ts` or `*.page.tsx`
110
- * 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)
111
- * and it enables the same for `next-translate`.
112
- */
113
- function withKoine(_a) {
114
- var _b;
115
- if (_a === void 0) { _a = {}; }
116
- var _c = _a.nx, nx = _c === void 0 ? true : _c, _d = _a.svg, svg = _d === void 0 ? true : _d, _e = _a.sc, sc = _e === void 0 ? true : _e, page = _a.page, nextConfig = tslib_1.__rest(_a, ["nx", "svg", "sc", "page"]);
117
- nextConfig = tslib_1.__assign({
118
- // @see https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
119
- pageExtensions: page ? ["page.tsx", "page.ts"] : undefined, eslint: {
120
- ignoreDuringBuilds: true, // we have this strict check on each commit
121
- }, typescript: {
122
- ignoreBuildErrors: true, // we have this strict check on each commit
123
- }, poweredByHeader: false, swcMinify: true, experimental: tslib_1.__assign(tslib_1.__assign({
124
- // @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
125
- // @see critters error https://github.com/vercel/next.js/issues/20742
126
- // optimizeCss: true,
127
- // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
128
- scrollRestoration: true }, (nextConfig.experimental || {})), {
129
- // @see https://nextjs.org/docs/advanced-features/compiler#modularize-imports
130
- modularizeImports: tslib_1.__assign({}, (((_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental) === null || _b === void 0 ? void 0 : _b.modularizeImports) || {})) }) }, nextConfig);
131
- if (svg) {
132
- if (nx) {
133
- // @see https://github.com/gregberge/svgr
134
- nextConfig["nx"] = {
135
- svgr: true,
136
- };
137
- }
138
- else {
139
- nextConfig.webpack = function (_config, options) {
140
- var webpackConfig = typeof nextConfig.webpack === "function"
141
- ? nextConfig.webpack(_config, options)
142
- : _config;
143
- // @see https://dev.to/dolearning/importing-svgs-to-next-js-nna#svgr
144
- webpackConfig.module.rules.push({
145
- test: /\.svg$/,
146
- use: [
147
- {
148
- loader: "@svgr/webpack",
149
- options: {
150
- svgoConfig: {
151
- plugins: [
152
- {
153
- name: "removeViewBox",
154
- active: false,
155
- },
156
- ],
157
- },
158
- },
159
- },
160
- ],
161
- });
162
- return webpackConfig;
163
- };
164
- }
165
- }
166
- if (sc) {
167
- nextConfig.compiler = {
168
- styledComponents: true,
169
- };
170
- }
171
- return nextConfig;
172
- }
173
- exports.withKoine = withKoine;
174
- exports.default = withKoine;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var document_1 = tslib_1.__importStar(require("next/document"));
7
- var react_1 = require("@koine/react");
8
- /**
9
- * Next Document wrapper for bare projects
10
- *
11
- * @example
12
- *
13
- * in your `myapp/pages/_document.tsx`:
14
- * ```tsx
15
- * export { Document as default } from "@koine/next/document";
16
- * ```
17
- */
18
- var Document = /** @class */ (function (_super) {
19
- tslib_1.__extends(Document, _super);
20
- function Document() {
21
- return _super !== null && _super.apply(this, arguments) || this;
22
- }
23
- Document.prototype.render = function () {
24
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
25
- return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.NoJs, {})] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
26
- };
27
- return Document;
28
- }(document_1.default));
29
- exports.Document = Document;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var document_1 = tslib_1.__importStar(require("next/document"));
7
- var react_1 = require("@koine/react");
8
- var sc_1 = require("@koine/react/sc"); // FIXME: this should be imported from another entrypoint
9
- /**
10
- * Next Document wrapper for `css/tailwind` based projects
11
- *
12
- * Uses cookie to manage the current theme
13
- *
14
- * @example
15
- *
16
- * in your `myapp/pages/_document.tsx`:
17
- * ```tsx
18
- * export { Document as default } from "@koine/next/document/css";
19
- * ```
20
- */
21
- var Document = /** @class */ (function (_super) {
22
- tslib_1.__extends(Document, _super);
23
- function Document() {
24
- return _super !== null && _super.apply(this, arguments) || this;
25
- }
26
- Document.getInitialProps = function (ctx) {
27
- var _a;
28
- return tslib_1.__awaiter(this, void 0, void 0, function () {
29
- var initialProps;
30
- return tslib_1.__generator(this, function (_b) {
31
- switch (_b.label) {
32
- case 0: return [4 /*yield*/, document_1.default.getInitialProps(ctx)];
33
- case 1:
34
- initialProps = _b.sent();
35
- return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), { theme: (0, sc_1.getInitialThemeFromRequest)(((_a = ctx.req) === null || _a === void 0 ? void 0 : _a.headers.cookie /* || document?.cookie */) || "") })];
36
- }
37
- });
38
- });
39
- };
40
- Document.prototype.render = function () {
41
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
42
- return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.NoJs, {})] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
43
- };
44
- return Document;
45
- }(document_1.default));
46
- exports.Document = Document;
47
- exports.default = Document;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var document_1 = tslib_1.__importStar(require("next/document"));
7
- var react_1 = require("@koine/react");
8
- var create_instance_1 = tslib_1.__importDefault(require("@emotion/server/create-instance"));
9
- var emotion_cache_1 = require("../../utils/emotion-cache");
10
- /**
11
- * Next Document wrapper for `emotion` based projects
12
- *
13
- * @example
14
- *
15
- * in your `myapp/pages/_document.tsx`:
16
- * ```tsx
17
- * export { Document as default } from "@koine/next/document/em";
18
- * ```
19
- */
20
- var Document = /** @class */ (function (_super) {
21
- tslib_1.__extends(Document, _super);
22
- function Document() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- Document.prototype.render = function () {
26
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
27
- return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.NoJs, {}), this.props.emotionStyleTags] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
28
- };
29
- return Document;
30
- }(document_1.default));
31
- exports.Document = Document;
32
- // `getInitialProps` belongs to `_document` (instead of `_app`),
33
- // it's compatible with static-site generation (SSG).
34
- Document.getInitialProps = function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
35
- var originalRenderPage, cache, extractCriticalToChunks, initialProps, emotionStyles, emotionStyleTags;
36
- return tslib_1.__generator(this, function (_a) {
37
- switch (_a.label) {
38
- case 0:
39
- originalRenderPage = ctx.renderPage;
40
- cache = (0, emotion_cache_1.createEmotionCache)();
41
- extractCriticalToChunks = (0, create_instance_1.default)(cache).extractCriticalToChunks;
42
- ctx.renderPage = function () {
43
- return originalRenderPage({
44
- enhanceApp: function (App) {
45
- return function EnhanceApp(props) {
46
- return (0, jsx_runtime_1.jsx)(App, tslib_1.__assign({ emotionCache: cache }, props));
47
- };
48
- },
49
- });
50
- };
51
- return [4 /*yield*/, Document.getInitialProps(ctx)];
52
- case 1:
53
- initialProps = _a.sent();
54
- emotionStyles = extractCriticalToChunks(initialProps.html);
55
- emotionStyleTags = emotionStyles.styles.map(function (style) { return ((0, jsx_runtime_1.jsx)("style", { "data-emotion": "".concat(style.key, " ").concat(style.ids.join(" ")),
56
- // eslint-disable-next-line react/no-danger
57
- dangerouslySetInnerHTML: { __html: style.css } }, style.key)); });
58
- return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), { emotionStyleTags: emotionStyleTags })];
59
- }
60
- });
61
- }); };
62
- exports.default = Document;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = exports.Document = void 0;
4
- var Document_1 = require("./Document");
5
- Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return Document_1.Document; } });
6
- var Document_2 = require("./Document");
7
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return Document_2.Document; } });
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var react_1 = tslib_1.__importDefault(require("react"));
7
- /* ? eslint-disable @next/next/no-document-import-in-page */
8
- var document_1 = tslib_1.__importStar(require("next/document"));
9
- var react_2 = require("@koine/react");
10
- var styled_components_1 = require("styled-components");
11
- /**
12
- * Next Document wrapper for `styled-components` based projects
13
- *
14
- * For typescript safety of this component
15
- * @see https://bit.ly/3ceuF8m
16
- *
17
- * @example
18
- *
19
- * in your `myapp/pages/_document.tsx`:
20
- * ```tsx
21
- * export { Document as default } from "@koine/next/document/sc";
22
- * ```
23
- */
24
- var Document = /** @class */ (function (_super) {
25
- tslib_1.__extends(Document, _super);
26
- function Document() {
27
- return _super !== null && _super.apply(this, arguments) || this;
28
- }
29
- Document.getInitialProps = function (ctx) {
30
- return tslib_1.__awaiter(this, void 0, void 0, function () {
31
- var sheet, originalRenderPage, initialProps;
32
- return tslib_1.__generator(this, function (_a) {
33
- switch (_a.label) {
34
- case 0:
35
- sheet = new styled_components_1.ServerStyleSheet();
36
- originalRenderPage = ctx.renderPage;
37
- _a.label = 1;
38
- case 1:
39
- _a.trys.push([1, , 3, 4]);
40
- ctx.renderPage = function () {
41
- return originalRenderPage({
42
- enhanceApp: function (App) { return function (props) {
43
- return sheet.collectStyles((0, jsx_runtime_1.jsx)(App, tslib_1.__assign({}, props)));
44
- }; },
45
- });
46
- };
47
- return [4 /*yield*/, document_1.default.getInitialProps(ctx)];
48
- case 2:
49
- initialProps = _a.sent();
50
- return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), {
51
- // @ts-expect-error FIXME: have they changed type?
52
- styles: ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })) })];
53
- case 3:
54
- sheet.seal();
55
- return [7 /*endfinally*/];
56
- case 4: return [2 /*return*/];
57
- }
58
- });
59
- });
60
- };
61
- Document.prototype.render = function () {
62
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
63
- return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(react_2.Meta, {}), (0, jsx_runtime_1.jsx)(react_2.NoJs, {})] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
64
- };
65
- return Document;
66
- }(document_1.default));
67
- exports.Document = Document;
68
- exports.default = Document;
package/node/index.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./Analytics"), exports);
5
- tslib_1.__exportStar(require("./Auth"), exports);
6
- tslib_1.__exportStar(require("./Favicon"), exports);
7
- tslib_1.__exportStar(require("./Forms"), exports);
8
- tslib_1.__exportStar(require("./Head"), exports);
9
- tslib_1.__exportStar(require("./I18n"), exports);
10
- tslib_1.__exportStar(require("./Img"), exports);
11
- tslib_1.__exportStar(require("./Link"), exports);
12
- tslib_1.__exportStar(require("./NextProgress"), exports);
13
- tslib_1.__exportStar(require("./Seo"), exports);
14
- tslib_1.__exportStar(require("./Theme"), exports);
15
- tslib_1.__exportStar(require("./utils"), exports);
package/node/utils/api.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.api = void 0;
4
- var tslib_1 = require("tslib");
5
- var utils_1 = require("@koine/utils");
6
- exports.api = ["get", "post", "put", "patch", "delete"].reduce(function (api, method) {
7
- api[method] = function (endpoint, options) {
8
- if (options === void 0) { options = {}; }
9
- return tslib_1.__awaiter(void 0, void 0, void 0, function () {
10
- var _a, json, params, _b, headers, _c, timeout, requestInit, timeoutNumber, controller, timeoutId, url, response, result;
11
- return tslib_1.__generator(this, function (_d) {
12
- switch (_d.label) {
13
- case 0:
14
- _a = options.json, json = _a === void 0 ? {} : _a, params = options.params, _b = options.headers, headers = _b === void 0 ? {} : _b, _c = options.timeout, timeout = _c === void 0 ? 10000 : _c;
15
- requestInit = {
16
- method: method.toUpperCase(),
17
- headers: tslib_1.__assign({ "content-type": "application/json" }, headers),
18
- };
19
- timeoutNumber = Number(timeout);
20
- url = "/api/".concat(endpoint.replace(/^\/*/, ""));
21
- if (method !== "get") {
22
- requestInit.body = JSON.stringify(json);
23
- }
24
- if (timeoutNumber > 0) {
25
- controller = new AbortController();
26
- timeoutId = setTimeout(function () { return controller.abort(); }, timeoutNumber);
27
- requestInit.signal = controller.signal;
28
- }
29
- if (params) {
30
- url += (0, utils_1.buildUrlQueryString)(params);
31
- }
32
- return [4 /*yield*/, fetch(url, requestInit)];
33
- case 1:
34
- response = _d.sent();
35
- if (timeoutId) {
36
- clearTimeout(timeoutId);
37
- }
38
- return [4 /*yield*/, response.json()];
39
- case 2:
40
- result = (_d.sent());
41
- return [2 /*return*/, result];
42
- }
43
- });
44
- });
45
- };
46
- return api;
47
- }, {});
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createEmotionCache = void 0;
4
- var tslib_1 = require("tslib");
5
- var cache_1 = tslib_1.__importDefault(require("@emotion/cache"));
6
- /**
7
- * prepend: true moves MUI styles to the top of the <head> so they're loaded first.
8
- * It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
9
- */
10
- function createEmotionCache() {
11
- return (0, cache_1.default)({ key: "css", prepend: true });
12
- }
13
- exports.createEmotionCache = createEmotionCache;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.load = exports.getSiteUrl = exports.ONE_DAY = exports.ONE_HOUR = void 0;
4
- var tslib_1 = require("tslib");
5
- var utils_1 = require("@koine/utils");
6
- tslib_1.__exportStar(require("./api"), exports);
7
- exports.ONE_HOUR = 3600;
8
- exports.ONE_DAY = 84000;
9
- /**
10
- * Get site absolute url with the given path
11
- *
12
- * - It uses the `NEXT_PUBLIC_APP_URL` env variable
13
- * - It removes the trailing slashes
14
- */
15
- function getSiteUrl(path) {
16
- if (path === void 0) { path = ""; }
17
- return (0, utils_1.normaliseUrl)("".concat(process.env["NEXT_PUBLIC_APP_URL"], "/").concat(path));
18
- }
19
- exports.getSiteUrl = getSiteUrl;
20
- /**
21
- * Utility to load a component with an optional pre-determined delay.
22
- *
23
- * This was designed to improve anti spam wit async form loading.
24
- *
25
- * @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
26
- * @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
27
- */
28
- function load(component, milliseconds) {
29
- return new Promise(function (resolve) {
30
- setTimeout(function () { return resolve(component); }, milliseconds);
31
- });
32
- }
33
- exports.load = load;