@koine/next 1.0.13 → 1.0.16

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/Forms/index.d.ts +0 -1
  2. package/Forms/index.js +0 -1
  3. package/node/Analytics/AnalyticsGoogle.js +37 -0
  4. package/node/Analytics/index.js +4 -0
  5. package/node/Auth/helpers.js +27 -0
  6. package/node/Auth/index.js +7 -0
  7. package/node/Auth/useLogin.js +53 -0
  8. package/node/Auth/useLoginUrl.js +15 -0
  9. package/node/Auth/useLogout.js +56 -0
  10. package/node/Favicon/Favicon.js +9 -0
  11. package/node/Favicon/index.js +4 -0
  12. package/node/Forms/index.js +4 -0
  13. package/node/Forms/useForm.js +39 -0
  14. package/node/Head/Head.js +5 -0
  15. package/node/Head/index.js +4 -0
  16. package/node/I18n/I18n.js +102 -0
  17. package/node/I18n/index.js +4 -0
  18. package/node/Img/Img.js +35 -0
  19. package/node/Img/index.js +4 -0
  20. package/node/Link/Link.js +14 -0
  21. package/node/Link/index.js +4 -0
  22. package/node/NextProgress/NextProgress.js +44 -0
  23. package/node/NextProgress/index.js +5 -0
  24. package/node/Seo/Seo.js +12 -0
  25. package/node/Seo/SeoDefaults.js +16 -0
  26. package/node/Seo/helpers.js +119 -0
  27. package/node/Seo/index.js +15 -0
  28. package/node/Theme/Theme.js +250 -0
  29. package/node/Theme/index.js +4 -0
  30. package/node/app/AppHead.js +10 -0
  31. package/node/app/AppMain.js +2 -0
  32. package/node/app/css/AppMain.js +17 -0
  33. package/node/app/css/AppTheme.js +18 -0
  34. package/node/app/css/auth/index.js +18 -0
  35. package/node/app/css/index.js +62 -0
  36. package/node/app/em/AppMain.js +28 -0
  37. package/node/app/em/AppTheme.js +22 -0
  38. package/node/app/em/auth/index.js +18 -0
  39. package/node/app/em/index.js +17 -0
  40. package/node/app/index.js +5 -0
  41. package/node/app/sc/AppMain.js +28 -0
  42. package/node/app/sc/AppTheme.js +15 -0
  43. package/node/app/sc/auth/index.js +18 -0
  44. package/node/app/sc/index.js +64 -0
  45. package/node/config/index.js +201 -0
  46. package/node/document/Document.js +29 -0
  47. package/node/document/css/index.js +47 -0
  48. package/node/document/em/index.js +62 -0
  49. package/node/document/index.js +7 -0
  50. package/node/document/sc/index.js +68 -0
  51. package/node/index.js +15 -0
  52. package/node/utils/emotion-cache.js +13 -0
  53. package/node/utils/index.js +31 -0
  54. package/package.json +3 -2
  55. package/utils/index.d.ts +0 -1
  56. package/utils/index.js +0 -1
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildTags = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var utils_1 = require("@koine/utils");
7
+ var defaults = {
8
+ tplTitle: "",
9
+ };
10
+ /**
11
+ * We do a couple of things in addition while many other are removed.
12
+ *
13
+ * - Add `seo` meta object coming from a CMS probably
14
+ * - Add `ogimage` and `openGraph.image` as single image source
15
+ * - Add `og` alias to define `openGraph`
16
+ * - Add check for `title` equale to `templateTitle` to avoid meta titles like
17
+ * "My site | My site" often happening in homepages
18
+ * - Remove the open graph videos and images
19
+ *
20
+ * - Shorter code
21
+ *
22
+ * @returns
23
+ */
24
+ var buildTags = function (_a) {
25
+ var _b = _a === void 0 ? {} : _a, seo = _b.seo, hidden = _b.hidden, keywords = _b.keywords, _c = _b.title, title = _c === void 0 ? "" : _c, titleTemplate = _b.titleTemplate, defaultTitle = _b.defaultTitle, noindex = _b.noindex, nofollow = _b.nofollow, description = _b.description, _d = _b.languageAlternates, languageAlternates = _d === void 0 ? [] : _d, twitter = _b.twitter, facebook = _b.facebook, openGraph = _b.openGraph, ogAlias = _b.og, canonical = _b.canonical, metaTags = _b.metaTags, linkTags = _b.linkTags;
26
+ var render = [];
27
+ var $names = {};
28
+ var $properties = {};
29
+ if (titleTemplate) {
30
+ defaults.tplTitle = titleTemplate;
31
+ }
32
+ title = title || (seo === null || seo === void 0 ? void 0 : seo.title) || "";
33
+ if (title) {
34
+ if (defaults.tplTitle && defaults.tplTitle !== title) {
35
+ title = defaults.tplTitle.replace(/%s/g, title);
36
+ }
37
+ }
38
+ else if (defaultTitle) {
39
+ title = defaultTitle;
40
+ }
41
+ if (title) {
42
+ render.push((0, jsx_runtime_1.jsx)("title", { children: title }, "title"));
43
+ $properties["og:title"] = title; // overridden later...
44
+ }
45
+ $names["robots"] = "".concat(noindex || hidden ? "noindex" : "index", ",").concat(nofollow || hidden ? "nofollow" : "follow");
46
+ description = description || (seo === null || seo === void 0 ? void 0 : seo.description);
47
+ if (description) {
48
+ $names["description"] = description;
49
+ $properties["og:description"] = description; // overridden later...
50
+ }
51
+ keywords = keywords || (seo === null || seo === void 0 ? void 0 : seo.keywords);
52
+ if (keywords) {
53
+ $names["keywords"] = (0, utils_1.isArray)(keywords) ? keywords.join(", ") : keywords;
54
+ }
55
+ if ((languageAlternates === null || languageAlternates === void 0 ? void 0 : languageAlternates.length) > 0) {
56
+ languageAlternates.forEach(function (languageAlternate) {
57
+ render.push((0, jsx_runtime_1.jsx)("link", { rel: "alternate", hrefLang: languageAlternate.hrefLang, href: languageAlternate.href }, "languageAlternate-".concat(languageAlternate.hrefLang)));
58
+ });
59
+ }
60
+ if (canonical) {
61
+ render.push((0, jsx_runtime_1.jsx)("link", { rel: "canonical", href: canonical }, "canonical"));
62
+ $properties["og:url"] = canonical;
63
+ }
64
+ if (facebook === null || facebook === void 0 ? void 0 : facebook.appId)
65
+ $properties["fb:app_id"] = facebook.appId;
66
+ if (twitter) {
67
+ if (twitter.cardType)
68
+ $names["twitter:card"] = twitter.cardType;
69
+ if (twitter.site)
70
+ $names["twitter:site"] = twitter.site;
71
+ if (twitter.handle)
72
+ $names["twitter:creator"] = twitter.handle;
73
+ }
74
+ var og = ogAlias || openGraph;
75
+ if (og === null || og === void 0 ? void 0 : og.title)
76
+ $properties["og:title"] = og === null || og === void 0 ? void 0 : og.title;
77
+ if (og === null || og === void 0 ? void 0 : og.description)
78
+ $properties["og:description"] = og === null || og === void 0 ? void 0 : og.description;
79
+ if (og === null || og === void 0 ? void 0 : og.url)
80
+ $properties["og:url"] = og.url;
81
+ if (og === null || og === void 0 ? void 0 : og.type)
82
+ $properties["og:type"] = og.type.toLowerCase();
83
+ if (og === null || og === void 0 ? void 0 : og.locale)
84
+ $properties["og:locale"] = og.locale;
85
+ if (og === null || og === void 0 ? void 0 : og.site_name)
86
+ $properties["og:site_name"] = og.site_name;
87
+ var ogimage = (og === null || og === void 0 ? void 0 : og.image) || (seo === null || seo === void 0 ? void 0 : seo.ogimage);
88
+ if (ogimage)
89
+ $properties["og:image"] = ogimage;
90
+ Object.keys($names).forEach(function (key) {
91
+ render.push((0, jsx_runtime_1.jsx)("meta", { name: key, content: $names[key] }, key));
92
+ });
93
+ Object.keys($properties).forEach(function (key) {
94
+ render.push((0, jsx_runtime_1.jsx)("meta", { property: key, content: $properties[key] }, key));
95
+ });
96
+ if (metaTags && metaTags.length > 0) {
97
+ metaTags.forEach(function (tag) {
98
+ var _a, _b, _c;
99
+ render.push((0, jsx_runtime_1.jsx)("meta", tslib_1.__assign({}, tag), "meta:".concat((_c = (_b = (_a = tag.keyOverride) !== null && _a !== void 0 ? _a : tag.name) !== null && _b !== void 0 ? _b : tag.property) !== null && _c !== void 0 ? _c : tag.httpEquiv)));
100
+ });
101
+ }
102
+ if (linkTags === null || linkTags === void 0 ? void 0 : linkTags.length) {
103
+ linkTags.forEach(function (tag) {
104
+ var _a;
105
+ render.push((0, jsx_runtime_1.jsx)("link", tslib_1.__assign({}, tag), "link".concat((_a = tag.keyOverride) !== null && _a !== void 0 ? _a : tag.href).concat(tag.rel)));
106
+ });
107
+ }
108
+ // TODO: alternates and canonical
109
+ // canonical = 'https://www.domain.com/';
110
+ // languageAlternates={[{
111
+ // hrefLang: 'en',
112
+ // href: 'https://www.domain.com/en',
113
+ // }]}
114
+ // <link rel="alternate" hreflang="x-default" href="https://www.domain.com/nl/">
115
+ // <link rel="alternate" hreflang="nl" href="https://www.domain.com/nl/">
116
+ // <link rel="alternate" hreflang="en" href="https://www.domain.com/en/">
117
+ return render;
118
+ };
119
+ exports.buildTags = buildTags;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * @file
4
+ *
5
+ * Adapted from https://github.com/garmeeh/next-seo
6
+ *
7
+ * See also:
8
+ * - https://github.com/catnose99/next-head-seo
9
+ * - https://nextjs.org/docs/api-reference/next/head
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ var tslib_1 = require("tslib");
13
+ tslib_1.__exportStar(require("./helpers"), exports);
14
+ tslib_1.__exportStar(require("./Seo"), exports);
15
+ tslib_1.__exportStar(require("./SeoDefaults"), exports);
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThemeProvider = exports.useTheme = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ /**
7
+ * @file
8
+ *
9
+ * Adapted from [next-themes](https://github.com/pacocoursey/next-themes)
10
+ */
11
+ var react_1 = require("react");
12
+ var script_1 = tslib_1.__importDefault(require("next/script"));
13
+ var utils_1 = require("@koine/utils");
14
+ var THEME_STORAGE_KEY = "theme";
15
+ var colorSchemes = ["light", "dark"];
16
+ var MEDIA = "(prefers-color-scheme: dark)";
17
+ var ThemeContext = (0, react_1.createContext)({
18
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
19
+ setTheme: function (_) { },
20
+ themes: [],
21
+ });
22
+ var useTheme = function () { return (0, react_1.useContext)(ThemeContext); };
23
+ exports.useTheme = useTheme;
24
+ var ThemeProvider = function (_a) {
25
+ var forcedTheme = _a.forcedTheme, _b = _a.disableTransitionOnChange, disableTransitionOnChange = _b === void 0 ? false : _b, _c = _a.enableSystem, enableSystem = _c === void 0 ? true : _c, _d = _a.enableColorScheme, enableColorScheme = _d === void 0 ? true : _d, _e = _a.themes, themes = _e === void 0 ? ["light", "dark"] : _e, _f = _a.defaultTheme, defaultTheme = _f === void 0 ? enableSystem ? "system" : "light" : _f, _g = _a.attribute, attribute = _g === void 0 ? "data-theme" : _g, value = _a.value, children = _a.children, nonce = _a.nonce;
26
+ var _h = (0, react_1.useState)(function () {
27
+ return getTheme(THEME_STORAGE_KEY, defaultTheme);
28
+ }), theme = _h[0], setThemeState = _h[1];
29
+ var _j = (0, react_1.useState)(function () {
30
+ return getTheme(THEME_STORAGE_KEY);
31
+ }), resolvedTheme = _j[0], setResolvedTheme = _j[1];
32
+ var attrs = !value ? themes : Object.values(value);
33
+ var applyTheme = (0, react_1.useCallback)(function (theme) {
34
+ var _a;
35
+ var resolved = theme;
36
+ if (utils_1.isServer || !resolved)
37
+ return;
38
+ // If theme is system, resolve it before setting theme
39
+ if (theme === "system" && enableSystem) {
40
+ resolved = getSystemTheme();
41
+ }
42
+ var name = value ? value[resolved] : resolved;
43
+ var enable = disableTransitionOnChange ? disableAnimation() : null;
44
+ var d = document.documentElement;
45
+ if (attribute === "class") {
46
+ (_a = d.classList).remove.apply(_a, attrs);
47
+ if (name)
48
+ d.classList.add(name);
49
+ }
50
+ else {
51
+ if (name) {
52
+ d.setAttribute(attribute, name);
53
+ }
54
+ else {
55
+ d.removeAttribute(attribute);
56
+ }
57
+ }
58
+ if (enableColorScheme) {
59
+ var fallback = colorSchemes.includes(defaultTheme)
60
+ ? defaultTheme
61
+ : "";
62
+ var colorScheme = colorSchemes.includes(resolved)
63
+ ? resolved
64
+ : fallback;
65
+ d.style.colorScheme = colorScheme;
66
+ }
67
+ enable === null || enable === void 0 ? void 0 : enable();
68
+ }, [
69
+ attribute,
70
+ attrs,
71
+ defaultTheme,
72
+ disableTransitionOnChange,
73
+ enableColorScheme,
74
+ enableSystem,
75
+ value,
76
+ ]);
77
+ var setTheme = (0, react_1.useCallback)(function (theme) {
78
+ setThemeState(theme);
79
+ // Save to storage
80
+ try {
81
+ localStorage.setItem(THEME_STORAGE_KEY, theme);
82
+ }
83
+ catch (e) {
84
+ // Unsupported
85
+ }
86
+ }, []);
87
+ var handleMediaQuery = (0, react_1.useCallback)(function (e) {
88
+ var resolved = getSystemTheme(e);
89
+ setResolvedTheme(resolved);
90
+ if (theme === "system" && enableSystem && !forcedTheme) {
91
+ applyTheme("system");
92
+ }
93
+ }, [theme, enableSystem, forcedTheme, applyTheme]);
94
+ // Always listen to System preference
95
+ (0, react_1.useEffect)(function () {
96
+ var media = window.matchMedia(MEDIA);
97
+ // Intentionally use deprecated listener methods to support iOS & old browsers
98
+ media.addListener(handleMediaQuery);
99
+ handleMediaQuery(media);
100
+ return function () { return media.removeListener(handleMediaQuery); };
101
+ }, [handleMediaQuery]);
102
+ // localStorage event handling
103
+ (0, react_1.useEffect)(function () {
104
+ var handleStorage = function (e) {
105
+ if (e.key !== THEME_STORAGE_KEY) {
106
+ return;
107
+ }
108
+ // If default theme set, use it if localstorage === null (happens on local storage manual deletion)
109
+ var theme = e.newValue || defaultTheme;
110
+ setTheme(theme);
111
+ };
112
+ window.addEventListener("storage", handleStorage);
113
+ return function () { return window.removeEventListener("storage", handleStorage); };
114
+ }, [defaultTheme, setTheme]);
115
+ // Whenever theme or forcedTheme changes, apply it
116
+ (0, react_1.useEffect)(function () {
117
+ applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
118
+ }, [applyTheme, forcedTheme, theme]);
119
+ return ((0, jsx_runtime_1.jsxs)(ThemeContext.Provider, tslib_1.__assign({ value: {
120
+ theme: theme,
121
+ setTheme: setTheme,
122
+ forcedTheme: forcedTheme,
123
+ resolvedTheme: theme === "system" ? resolvedTheme : theme,
124
+ themes: enableSystem ? tslib_1.__spreadArray(tslib_1.__spreadArray([], themes, true), ["system"], false) : themes,
125
+ systemTheme: (enableSystem ? resolvedTheme : undefined),
126
+ } }, { children: [(0, jsx_runtime_1.jsx)(ThemeScript, tslib_1.__assign({}, {
127
+ forcedTheme: forcedTheme,
128
+ disableTransitionOnChange: disableTransitionOnChange,
129
+ enableSystem: enableSystem,
130
+ enableColorScheme: enableColorScheme,
131
+ themes: themes,
132
+ defaultTheme: defaultTheme,
133
+ attribute: attribute,
134
+ value: value,
135
+ children: children,
136
+ attrs: attrs,
137
+ nonce: nonce,
138
+ })), children] })));
139
+ };
140
+ exports.ThemeProvider = ThemeProvider;
141
+ var ThemeScript = (0, react_1.memo)(function (_a) {
142
+ var forcedTheme = _a.forcedTheme, attribute = _a.attribute, enableSystem = _a.enableSystem, enableColorScheme = _a.enableColorScheme, defaultTheme = _a.defaultTheme, value = _a.value, attrs = _a.attrs, nonce = _a.nonce;
143
+ var defaultSystem = defaultTheme === "system";
144
+ // Code-golfing the amount of characters in the script
145
+ var optimization = (function () {
146
+ var removeClasses = "d.remove(".concat(attrs
147
+ .map(function (t) { return "'".concat(t, "'"); })
148
+ .join(","), ")");
149
+ return "var d=document.documentElement.classList;".concat(removeClasses, ";");
150
+ })();
151
+ var fallbackColorScheme = (function () {
152
+ if (!enableColorScheme) {
153
+ return "";
154
+ }
155
+ var fallback = colorSchemes.includes(defaultTheme)
156
+ ? defaultTheme
157
+ : null;
158
+ if (fallback) {
159
+ return "if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'".concat(defaultTheme, "'");
160
+ }
161
+ else {
162
+ return "if(e==='light'||e==='dark')d.style.colorScheme=e";
163
+ }
164
+ })();
165
+ var updateDOM = function (name, literal, setColorScheme) {
166
+ if (literal === void 0) { literal = false; }
167
+ if (setColorScheme === void 0) { setColorScheme = true; }
168
+ var resolvedName = value ? value[name] : name;
169
+ var val = literal ? name + "|| ''" : "'".concat(resolvedName, "'");
170
+ var text = "";
171
+ // MUCH faster to set colorScheme alongside HTML attribute/class
172
+ // as it only incurs 1 style recalculation rather than 2
173
+ // This can save over 250ms of work for pages with big DOM
174
+ if (enableColorScheme &&
175
+ setColorScheme &&
176
+ !literal &&
177
+ colorSchemes.includes(name)) {
178
+ text += "d.style.colorScheme = '".concat(name, "';");
179
+ }
180
+ if (attribute === "class") {
181
+ if (literal || resolvedName) {
182
+ text += "d.add(".concat(val, ")");
183
+ }
184
+ else {
185
+ text += "null";
186
+ }
187
+ }
188
+ else {
189
+ if (resolvedName) {
190
+ text += "d[s](n, ".concat(val, ")");
191
+ }
192
+ }
193
+ return text;
194
+ };
195
+ var scriptSrc = (function () {
196
+ if (forcedTheme) {
197
+ return "!function(){".concat(optimization).concat(updateDOM(forcedTheme), "}()");
198
+ }
199
+ if (enableSystem) {
200
+ return "!function(){try {".concat(optimization, "var e=localStorage.getItem('").concat(THEME_STORAGE_KEY, "');if(\"system\"===e||(!e&&").concat(defaultSystem, ")){var t=\"").concat(MEDIA, "\",m=window.matchMedia(t);if(m.media!==t||m.matches){").concat(updateDOM("dark"), "}else{").concat(updateDOM("light"), "}}else if(e){").concat(value ? "var x=".concat(JSON.stringify(value), ";") : "").concat(updateDOM(value ? "x[e]" : "e", true), "}").concat(!defaultSystem
201
+ ? "else{" + updateDOM(defaultTheme, false, false) + "}"
202
+ : "").concat(fallbackColorScheme, "}catch(e){}}()");
203
+ }
204
+ return "!function(){try{".concat(optimization, "var e=localStorage.getItem(\"").concat(THEME_STORAGE_KEY, "\");if(e){").concat(value ? "var x=".concat(JSON.stringify(value), ";") : "").concat(updateDOM(value ? "x[e]" : "e", true), "}else{").concat(updateDOM(defaultTheme, false, false), ";}").concat(fallbackColorScheme, "}catch(t){}}();");
205
+ })();
206
+ // We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
207
+ // However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
208
+ // But our script cannot be external because it changes at runtime based on React props
209
+ // so we trick next/script by passing `src` as a base64 JS script
210
+ var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
211
+ return ((0, jsx_runtime_1.jsx)(script_1.default, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
212
+ },
213
+ // Never re-render this component
214
+ function () { return true; });
215
+ // Helpers
216
+ var getTheme = function (key, fallback) {
217
+ if (utils_1.isServer)
218
+ return undefined;
219
+ var theme;
220
+ try {
221
+ theme = localStorage.getItem(key) || undefined;
222
+ }
223
+ catch (e) {
224
+ // Unsupported
225
+ }
226
+ return theme || fallback;
227
+ };
228
+ var disableAnimation = function () {
229
+ var css = document.createElement("style");
230
+ css.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
231
+ document.head.appendChild(css);
232
+ return function () {
233
+ // Force restyle
234
+ (function () { return window.getComputedStyle(document.body); })();
235
+ // Wait for next tick before removing
236
+ setTimeout(function () {
237
+ document.head.removeChild(css);
238
+ }, 1);
239
+ };
240
+ };
241
+ var getSystemTheme = function (e) {
242
+ if (!e)
243
+ e = window.matchMedia(MEDIA);
244
+ var isDark = e.matches;
245
+ var systemTheme = isDark ? "dark" : "light";
246
+ return systemTheme;
247
+ };
248
+ var encodeBase64 = function (str) {
249
+ return utils_1.isServer ? Buffer.from(str).toString("base64") : btoa(str);
250
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Theme"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppHead = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var head_1 = tslib_1.__importDefault(require("next/head"));
7
+ var AppHead = function () {
8
+ return ((0, jsx_runtime_1.jsx)(head_1.default, { children: (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width" }) }));
9
+ };
10
+ exports.AppHead = AppHead;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppMain = 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 Seo_1 = require("../../Seo");
8
+ /**
9
+ * App main
10
+ *
11
+ * It does not imply any specific styling or animation solution
12
+ */
13
+ var AppMain = function (_a) {
14
+ var Component = _a.Component, pageProps = _a.pageProps, Layout = _a.Layout, seo = _a.seo, pre = _a.pre, post = _a.post;
15
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Seo_1.SeoDefaults, tslib_1.__assign({}, seo)), pre, (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(Component, tslib_1.__assign({}, pageProps)) }), post] }));
16
+ };
17
+ exports.AppMain = AppMain;
@@ -0,0 +1,18 @@
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
+ // import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react";
7
+ var Theme_1 = require("../../Theme");
8
+ /**
9
+ * App theme with vanilla class based theme (good for `tailwindcss`)
10
+ */
11
+ var AppTheme = function (_a) {
12
+ var theme = _a.theme, children = _a.children;
13
+ // return (
14
+ // <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
15
+ // );
16
+ return ((0, jsx_runtime_1.jsx)(Theme_1.ThemeProvider, tslib_1.__assign({ defaultTheme: theme, attribute: "class" }, { children: children })));
17
+ };
18
+ exports.AppTheme = AppTheme;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,62 @@
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/css/auth";
17
+ * import { Favicon, AnalyticsGoogle } from "@koine/next";
18
+ * import { theme } from "src/helpers/theme";
19
+ * import { Layout } 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
+ * theme={theme}
31
+ * seo={{
32
+ * titleTemplate: "%s | MyApp",
33
+ * defaultTitle: "MyApp",
34
+ * openGraph: {
35
+ * type: "website",
36
+ * locale: "en_US",
37
+ * url: "https://myapp.com/",
38
+ * site_name: "MyApp",
39
+ * },
40
+ * twitter: {
41
+ * handle: "@MklrNl",
42
+ * site: "@MyApp",
43
+ * cardType: "summary_large_image",
44
+ * },
45
+ * }}
46
+ * pre={
47
+ * <>
48
+ * <AnalyticsGoogle id="UA-xxxxxxxx-x" />
49
+ * <Favicon name="MyApp" color="#000000" />
50
+ * </>
51
+ * }
52
+ * />
53
+ * );
54
+ * }
55
+ *
56
+ * ```
57
+ */
58
+ var NextApp = function (props) {
59
+ 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)) }))] }));
60
+ };
61
+ exports.NextApp = NextApp;
62
+ exports.default = exports.NextApp;
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1,22 @@
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 styles_1 = require("@mui/material/styles");
7
+ var react_1 = require("@emotion/react");
8
+ var CssBaseline_1 = tslib_1.__importDefault(require("@mui/material/CssBaseline"));
9
+ var react_2 = require("@emotion/react");
10
+ var sc_1 = require("@koine/react/sc");
11
+ var emotion_cache_1 = require("../../utils/emotion-cache");
12
+ // client-side cache, shared for the whole session of the user in the browser.
13
+ var clientSideEmotionCache = (0, emotion_cache_1.createEmotionCache)();
14
+ /**
15
+ * App theme with `emotion` (good for `@mui`)s
16
+ */
17
+ var AppTheme = function (_a) {
18
+ var _b = _a.emotionCache, emotionCache = _b === void 0 ? clientSideEmotionCache : _b, theme = _a.theme, children = _a.children;
19
+ return ((0, jsx_runtime_1.jsx)(react_1.CacheProvider, tslib_1.__assign({ value: emotionCache }, { children: (0, jsx_runtime_1.jsxs)(styles_1.ThemeProvider, tslib_1.__assign({ theme: theme }, { children: [(0, jsx_runtime_1.jsx)(CssBaseline_1.default, {}), (0, jsx_runtime_1.jsx)(react_2.Global, { styles: (0, react_2.css)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), sc_1.stylesGlobal) }), children] })) })));
20
+ };
21
+ exports.AppTheme = AppTheme;
22
+ var templateObject_1;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,17 @@
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
+ var NextApp = function (props) {
14
+ 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)) }))] }));
15
+ };
16
+ exports.NextApp = NextApp;
17
+ exports.default = exports.NextApp;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./AppHead"), exports);
5
+ tslib_1.__exportStar(require("./AppMain"), exports);
@@ -0,0 +1,28 @@
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;