@koine/next 1.0.4 → 1.0.9

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