@koine/next 1.2.3 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/{AnalyticsGoogle.d.ts → 12/AnalyticsGoogle.d.ts} +1 -1
  2. package/{AnalyticsGoogle.js → 12/AnalyticsGoogle.js} +2 -1
  3. package/{AnalyticsGoogle.mjs → 12/AnalyticsGoogle.mjs} +2 -2
  4. package/{DisableErrorOverlay.d.ts → 12/DisableErrorOverlay.d.ts} +1 -1
  5. package/{DynamicNamespaces.js → 12/DynamicNamespaces.js} +1 -0
  6. package/{DynamicNamespaces.mjs → 12/DynamicNamespaces.mjs} +1 -0
  7. package/{Favicon.d.ts → 12/Favicon.d.ts} +1 -1
  8. package/{Link.js → 12/Link.js} +1 -1
  9. package/{Link.mjs → 12/Link.mjs} +1 -1
  10. package/{NextProgress.d.ts → 12/NextProgress.d.ts} +1 -1
  11. package/{NextProgress.js → 12/NextProgress.js} +1 -0
  12. package/{NextProgress.mjs → 12/NextProgress.mjs} +1 -0
  13. package/{Seo.d.ts → 12/Seo.d.ts} +1 -1
  14. package/{SeoDefaults.d.ts → 12/SeoDefaults.d.ts} +1 -1
  15. package/{T.d.ts → 12/T.d.ts} +1 -0
  16. package/{T.js → 12/T.js} +1 -0
  17. package/{T.mjs → 12/T.mjs} +1 -0
  18. package/{ThemeProvider.d.ts → 12/ThemeProvider.d.ts} +1 -1
  19. package/{ThemeProvider.js → 12/ThemeProvider.js} +3 -14
  20. package/{ThemeProvider.mjs → 12/ThemeProvider.mjs} +4 -15
  21. package/{TransText.js → 12/TransText.js} +1 -0
  22. package/{TransText.mjs → 12/TransText.mjs} +1 -0
  23. package/12/app/AppHead.d.ts +3 -0
  24. package/{app → 12/app}/css/AppMain.d.ts +1 -1
  25. package/{app → 12/app}/css/AppTheme.d.ts +2 -2
  26. package/{app → 12/app}/css/AppTheme.js +1 -2
  27. package/{app → 12/app}/css/AppTheme.mjs +1 -2
  28. package/12/app/css/auth/index.d.ts +11 -0
  29. package/{app → 12/app}/css/auth/index.js +1 -1
  30. package/{app → 12/app}/css/auth/index.mjs +1 -1
  31. package/{app → 12/app}/css/index.d.ts +1 -1
  32. package/{app/em → 12/app/sc}/AppMain.d.ts +1 -1
  33. package/{app → 12/app}/sc/AppMain.js +1 -1
  34. package/{app → 12/app}/sc/AppMain.mjs +1 -1
  35. package/{app → 12/app}/sc/AppTheme.d.ts +2 -2
  36. package/{app → 12/app}/sc/AppTheme.js +1 -2
  37. package/{app → 12/app}/sc/AppTheme.mjs +1 -2
  38. package/12/app/sc/auth/index.d.ts +11 -0
  39. package/{app/em → 12/app/sc}/auth/index.js +1 -1
  40. package/{app/em → 12/app/sc}/auth/index.mjs +1 -1
  41. package/{app → 12/app}/sc/index.d.ts +4 -4
  42. package/{document → 12/document}/Document.d.ts +1 -2
  43. package/{document → 12/document}/Document.js +1 -1
  44. package/{document → 12/document}/Document.mjs +2 -2
  45. package/{document → 12/document}/css/index.d.ts +1 -2
  46. package/{document → 12/document}/css/index.js +1 -1
  47. package/{document → 12/document}/css/index.mjs +3 -3
  48. package/{document → 12/document}/sc/index.d.ts +2 -3
  49. package/{document → 12/document}/sc/index.js +1 -1
  50. package/{document → 12/document}/sc/index.mjs +1 -1
  51. package/{getT.js → 12/getT.js} +2 -1
  52. package/{getT.mjs → 12/getT.mjs} +1 -0
  53. package/12/index.d.ts +24 -0
  54. package/12/index.js +52 -0
  55. package/12/index.mjs +27 -0
  56. package/{types-i18n.d.ts → 12/types-i18n.d.ts} +1 -1
  57. package/{useBackUrl.js → 12/useBackUrl.js} +1 -0
  58. package/{useBackUrl.mjs → 12/useBackUrl.mjs} +1 -0
  59. package/{useDateFormat.js → 12/useDateFormat.js} +1 -0
  60. package/{useDateFormat.mjs → 12/useDateFormat.mjs} +1 -0
  61. package/{useForm.d.ts → 12/useForm.d.ts} +1 -1
  62. package/{useForm.js → 12/useForm.js} +1 -0
  63. package/{useForm.mjs → 12/useForm.mjs} +1 -0
  64. package/{useLocale.js → 12/useLocale.js} +1 -0
  65. package/{useLocale.mjs → 12/useLocale.mjs} +1 -0
  66. package/12/useT.d.ts +4 -0
  67. package/{useT.js → 12/useT.js} +21 -16
  68. package/12/useT.mjs +21 -0
  69. package/{useTheme.js → 12/useTheme.js} +1 -0
  70. package/{useTheme.mjs → 12/useTheme.mjs} +1 -0
  71. package/{useTo.js → 12/useTo.js} +1 -0
  72. package/{useTo.mjs → 12/useTo.mjs} +1 -0
  73. package/index.d.ts +2 -28
  74. package/index.js +5 -31
  75. package/index.mjs +2 -30
  76. package/package.json +13 -30
  77. package/typings.d.ts +0 -87
  78. package/Head.d.ts +0 -3
  79. package/Head.js +0 -7
  80. package/Head.mjs +0 -3
  81. package/app/AppHead.d.ts +0 -3
  82. package/app/css/auth/index.d.ts +0 -11
  83. package/app/em/AppMain.js +0 -29
  84. package/app/em/AppMain.mjs +0 -25
  85. package/app/em/AppTheme.d.ts +0 -16
  86. package/app/em/AppTheme.js +0 -23
  87. package/app/em/AppTheme.mjs +0 -19
  88. package/app/em/auth/index.d.ts +0 -11
  89. package/app/em/index.d.ts +0 -9
  90. package/app/em/index.js +0 -16
  91. package/app/em/index.mjs +0 -12
  92. package/app/sc/AppMain.d.ts +0 -11
  93. package/app/sc/auth/index.d.ts +0 -11
  94. package/app/sc/auth/index.js +0 -17
  95. package/app/sc/auth/index.mjs +0 -13
  96. package/auth/helpers.d.ts +0 -17
  97. package/auth/helpers.js +0 -28
  98. package/auth/helpers.mjs +0 -22
  99. package/auth/index.d.ts +0 -4
  100. package/auth/index.js +0 -7
  101. package/auth/index.mjs +0 -4
  102. package/auth/useLogin.d.ts +0 -8
  103. package/auth/useLogin.js +0 -54
  104. package/auth/useLogin.mjs +0 -50
  105. package/auth/useLoginUrl.d.ts +0 -2
  106. package/auth/useLoginUrl.js +0 -16
  107. package/auth/useLoginUrl.mjs +0 -12
  108. package/auth/useLogout.d.ts +0 -7
  109. package/auth/useLogout.js +0 -58
  110. package/auth/useLogout.mjs +0 -53
  111. package/createEmotionCache.d.ts +0 -6
  112. package/createEmotionCache.js +0 -14
  113. package/createEmotionCache.mjs +0 -9
  114. package/document/em/index.d.ts +0 -16
  115. package/document/em/index.js +0 -63
  116. package/document/em/index.mjs +0 -60
  117. package/document/em/package.json +0 -6
  118. package/document/package.json +0 -6
  119. package/document/sc/package.json +0 -6
  120. package/revalidate.d.ts +0 -5
  121. package/revalidate.js +0 -8
  122. package/revalidate.mjs +0 -5
  123. package/useT.d.ts +0 -17
  124. package/useT.mjs +0 -34
  125. /package/{DisableErrorOverlay.js → 12/DisableErrorOverlay.js} +0 -0
  126. /package/{DisableErrorOverlay.mjs → 12/DisableErrorOverlay.mjs} +0 -0
  127. /package/{DynamicNamespaces.d.ts → 12/DynamicNamespaces.d.ts} +0 -0
  128. /package/{Favicon.js → 12/Favicon.js} +0 -0
  129. /package/{Favicon.mjs → 12/Favicon.mjs} +0 -0
  130. /package/{Link.d.ts → 12/Link.d.ts} +0 -0
  131. /package/{Seo.js → 12/Seo.js} +0 -0
  132. /package/{Seo.mjs → 12/Seo.mjs} +0 -0
  133. /package/{SeoDefaults.js → 12/SeoDefaults.js} +0 -0
  134. /package/{SeoDefaults.mjs → 12/SeoDefaults.mjs} +0 -0
  135. /package/{ThemeContext.d.ts → 12/ThemeContext.d.ts} +0 -0
  136. /package/{ThemeContext.js → 12/ThemeContext.js} +0 -0
  137. /package/{ThemeContext.mjs → 12/ThemeContext.mjs} +0 -0
  138. /package/{TransText.d.ts → 12/TransText.d.ts} +0 -0
  139. /package/{app → 12/app}/AppHead.js +0 -0
  140. /package/{app → 12/app}/AppHead.mjs +0 -0
  141. /package/{app → 12/app}/AppMain.d.ts +0 -0
  142. /package/{app → 12/app}/AppMain.js +0 -0
  143. /package/{app → 12/app}/AppMain.mjs +0 -0
  144. /package/{app → 12/app}/css/AppMain.js +0 -0
  145. /package/{app → 12/app}/css/AppMain.mjs +0 -0
  146. /package/{app → 12/app}/css/auth/package.json +0 -0
  147. /package/{app → 12/app}/css/index.js +0 -0
  148. /package/{app → 12/app}/css/index.mjs +0 -0
  149. /package/{app → 12/app}/css/package.json +0 -0
  150. /package/{app → 12/app}/index.d.ts +0 -0
  151. /package/{app → 12/app}/index.js +0 -0
  152. /package/{app → 12/app}/index.mjs +0 -0
  153. /package/{app/em/auth → 12/app}/package.json +0 -0
  154. /package/{app/em → 12/app/sc/auth}/package.json +0 -0
  155. /package/{app → 12/app}/sc/index.js +0 -0
  156. /package/{app → 12/app}/sc/index.mjs +0 -0
  157. /package/{app → 12/app/sc}/package.json +0 -0
  158. /package/{app/sc/auth → 12/document/css}/package.json +0 -0
  159. /package/{document → 12/document}/index.d.ts +0 -0
  160. /package/{document → 12/document}/index.js +0 -0
  161. /package/{document → 12/document}/index.mjs +0 -0
  162. /package/{app/sc → 12/document}/package.json +0 -0
  163. /package/{auth → 12/document/sc}/package.json +0 -0
  164. /package/{getT.d.ts → 12/getT.d.ts} +0 -0
  165. /package/{document/css → 12}/package.json +0 -0
  166. /package/{seoBuildTags.d.ts → 12/seoBuildTags.d.ts} +0 -0
  167. /package/{seoBuildTags.js → 12/seoBuildTags.js} +0 -0
  168. /package/{seoBuildTags.mjs → 12/seoBuildTags.mjs} +0 -0
  169. /package/{to.d.ts → 12/to.d.ts} +0 -0
  170. /package/{to.js → 12/to.js} +0 -0
  171. /package/{to.mjs → 12/to.mjs} +0 -0
  172. /package/{translationAsOptions.d.ts → 12/translationAsOptions.d.ts} +0 -0
  173. /package/{translationAsOptions.js → 12/translationAsOptions.js} +0 -0
  174. /package/{translationAsOptions.mjs → 12/translationAsOptions.mjs} +0 -0
  175. /package/{types-i18n.js → 12/types-i18n.js} +0 -0
  176. /package/{types-i18n.mjs → 12/types-i18n.mjs} +0 -0
  177. /package/{types-seo.d.ts → 12/types-seo.d.ts} +0 -0
  178. /package/{types-seo.js → 12/types-seo.js} +0 -0
  179. /package/{types-seo.mjs → 12/types-seo.mjs} +0 -0
  180. /package/{useBackUrl.d.ts → 12/useBackUrl.d.ts} +0 -0
  181. /package/{useDateFormat.d.ts → 12/useDateFormat.d.ts} +0 -0
  182. /package/{useLocale.d.ts → 12/useLocale.d.ts} +0 -0
  183. /package/{useTheme.d.ts → 12/useTheme.d.ts} +0 -0
  184. /package/{useTo.d.ts → 12/useTo.d.ts} +0 -0
@@ -1,25 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { createElement as _createElement } from "react";
3
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
- import { useRouter } from "next/router";
5
- import { AnimatePresence, m } from "framer-motion";
6
- import MotionProvider from "@koine/react/m/MotionProvider";
7
- import { SeoDefaults } from "../../SeoDefaults";
8
- import { NextProgress } from "../../NextProgress";
9
- /**
10
- * App main
11
- *
12
- * It implies a setup for `styled-components` and `framer-motion` libraries.
13
- *
14
- * About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
15
- */
16
- export var AppMain = function (_a) {
17
- 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 ? {
18
- initial: { opacity: 0 },
19
- animate: { opacity: 1 },
20
- exit: { opacity: 0 },
21
- } : _b, pre = _a.pre, post = _a.post;
22
- var pathname = useRouter().pathname;
23
- return (_jsxs(_Fragment, { children: [_jsx(SeoDefaults, __assign({}, seo)), pre, _jsxs(MotionProvider, __assign({ features: motion }, { children: [ProgressOverlay && _jsx(NextProgress, { Overlay: ProgressOverlay }), _jsx(Layout, { children: _jsx(AnimatePresence, __assign({ exitBeforeEnter: true, initial: false }, { children: _jsx(m.div, __assign({}, transition, { children: _createElement(Component, __assign({}, pageProps, { key: pathname })) }), pathname) })) })] })), post] }));
24
- };
25
- export default AppMain;
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- import { AppProps as NextAppProps } from "next/app";
3
- import { Theme } from "@mui/material/styles";
4
- import { EmotionCache } from "@emotion/react";
5
- export type AppThemeProps = React.PropsWithChildren<NextAppProps & {
6
- emotionCache?: EmotionCache;
7
- /**
8
- * A theme object
9
- */
10
- theme: Theme;
11
- }>;
12
- /**
13
- * App theme with `emotion` (good for `@mui`)s
14
- */
15
- export declare const AppTheme: ({ emotionCache, theme, children, }: AppThemeProps) => JSX.Element;
16
- export default AppTheme;
@@ -1,23 +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 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 createEmotionCache_1 = require("../../createEmotionCache");
12
- // client-side cache, shared for the whole session of the user in the browser.
13
- var clientSideEmotionCache = (0, createEmotionCache_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
- exports.default = exports.AppTheme;
23
- var templateObject_1;
@@ -1,19 +0,0 @@
1
- import { __assign, __makeTemplateObject } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { ThemeProvider } from "@mui/material/styles";
4
- import { CacheProvider } from "@emotion/react";
5
- import CssBaseline from "@mui/material/CssBaseline";
6
- import { Global, css } from "@emotion/react";
7
- import { stylesGlobal } from "@koine/react/sc";
8
- import { createEmotionCache } from "../../createEmotionCache";
9
- // client-side cache, shared for the whole session of the user in the browser.
10
- var clientSideEmotionCache = createEmotionCache();
11
- /**
12
- * App theme with `emotion` (good for `@mui`)s
13
- */
14
- export var AppTheme = function (_a) {
15
- var _b = _a.emotionCache, emotionCache = _b === void 0 ? clientSideEmotionCache : _b, theme = _a.theme, children = _a.children;
16
- return (_jsx(CacheProvider, __assign({ value: emotionCache }, { children: _jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(CssBaseline, {}), _jsx(Global, { styles: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), stylesGlobal) }), children] })) })));
17
- };
18
- export default AppTheme;
19
- var templateObject_1;
@@ -1,11 +0,0 @@
1
- import { AppProps } from "next/app";
2
- import { AppThemeProps } from "../AppTheme";
3
- import { AppMainProps } from "../AppMain";
4
- export type NextAppProps = AppProps<{
5
- session: any;
6
- }> & AppThemeProps & AppMainProps;
7
- /**
8
- * App with authentication provided by `next-auth`
9
- */
10
- export declare const NextApp: (props: NextAppProps) => JSX.Element;
11
- export default NextApp;
package/app/em/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { AppProps } from "next/app";
2
- import { AppThemeProps } from "./AppTheme";
3
- import { AppMainProps } from "./AppMain";
4
- export type NextAppProps = AppProps & AppThemeProps & AppMainProps;
5
- /**
6
- * App
7
- */
8
- export declare const NextApp: (props: NextAppProps) => JSX.Element;
9
- export default NextApp;
package/app/em/index.js DELETED
@@ -1,16 +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 AppHead_1 = require("../AppHead");
7
- var AppTheme_1 = require("./AppTheme");
8
- var AppMain_1 = require("./AppMain");
9
- /**
10
- * App
11
- */
12
- var NextApp = function (props) {
13
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { 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)) }))] }));
14
- };
15
- exports.NextApp = NextApp;
16
- exports.default = exports.NextApp;
package/app/em/index.mjs DELETED
@@ -1,12 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { AppHead } from "../AppHead";
4
- import { AppTheme } from "./AppTheme";
5
- import { AppMain } from "./AppMain";
6
- /**
7
- * App
8
- */
9
- export var NextApp = function (props) {
10
- return (_jsxs(_Fragment, { children: [_jsx(AppHead, {}), _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) }))] }));
11
- };
12
- export default NextApp;
@@ -1,11 +0,0 @@
1
- import type { AppMainBaseProps, AppMainFramerProps } from "../AppMain";
2
- export type AppMainProps = AppMainBaseProps & AppMainFramerProps;
3
- /**
4
- * App main
5
- *
6
- * It implies a setup for `styled-components` and `framer-motion` libraries.
7
- *
8
- * About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
9
- */
10
- export declare const AppMain: ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition, pre, post, }: AppMainProps) => JSX.Element;
11
- export default AppMain;
@@ -1,11 +0,0 @@
1
- import { AppProps } from "next/app";
2
- import { AppThemeProps } from "../AppTheme";
3
- import { AppMainProps } from "../AppMain";
4
- export type NextAppProps = AppProps<{
5
- session: any;
6
- }> & AppThemeProps & AppMainProps;
7
- /**
8
- * App with authentication provided by `next-auth`
9
- */
10
- export declare const NextApp: (props: NextAppProps) => JSX.Element;
11
- export default NextApp;
@@ -1,17 +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 = require("next-auth/react");
7
- var AppHead_1 = require("../../AppHead");
8
- var AppTheme_1 = require("../AppTheme");
9
- var AppMain_1 = require("../AppMain");
10
- /**
11
- * App with authentication provided by `next-auth`
12
- */
13
- var NextApp = function (props) {
14
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(react_1.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)) })) }))] }));
15
- };
16
- exports.NextApp = NextApp;
17
- exports.default = exports.NextApp;
@@ -1,13 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { SessionProvider } from "next-auth/react";
4
- import { AppHead } from "../../AppHead";
5
- import { AppTheme } from "../AppTheme";
6
- import { AppMain } from "../AppMain";
7
- /**
8
- * App with authentication provided by `next-auth`
9
- */
10
- export var NextApp = function (props) {
11
- return (_jsxs(_Fragment, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, __assign({ session: props.pageProps.session }, { children: _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) })) }))] }));
12
- };
13
- export default NextApp;
package/auth/helpers.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { TranslateLoose } from "../types-i18n";
2
- /**
3
- * @see next/auth `pages` mapping: https://next-auth.js.org/configuration/pages`
4
- */
5
- export type AuthRoutesMap = {
6
- login?: string;
7
- profile?: string;
8
- register?: string;
9
- /** Array of regexes to match pathnames of protected routes */
10
- secured?: RegExp[];
11
- };
12
- export declare const AUTH_ROUTES: AuthRoutesMap;
13
- export declare function getAuthRoutes(t: TranslateLoose): AuthRoutesMap;
14
- /**
15
- * @param url e.g. "http://localhost:3000/signin?callbackUrl=http://localhost:3000/profile"
16
- */
17
- export declare function getCallbackUrl(url?: string): string;
package/auth/helpers.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCallbackUrl = exports.getAuthRoutes = exports.AUTH_ROUTES = void 0;
4
- var tslib_1 = require("tslib");
5
- var isString_1 = tslib_1.__importDefault(require("@koine/utils/isString"));
6
- exports.AUTH_ROUTES = {
7
- login: process.env["AUTH_ROUTE_LOGIN"],
8
- profile: process.env["AUTH_ROUTE_PROFILE"],
9
- register: process.env["AUTH_ROUTE_REGISTER"],
10
- secured: JSON.parse(process.env["AUTH_ROUTES_SECURED"] || "[]"),
11
- };
12
- function getAuthRoutes(t) {
13
- return Object.keys(exports.AUTH_ROUTES).reduce(function (map, name) {
14
- var routePage = exports.AUTH_ROUTES[name];
15
- // @ts-expect-error cannot remember
16
- map[name] = (0, isString_1.default)(routePage) ? t("~:".concat(exports.AUTH_ROUTES[name])) : routePage;
17
- return map;
18
- }, {});
19
- }
20
- exports.getAuthRoutes = getAuthRoutes;
21
- /**
22
- * @param url e.g. "http://localhost:3000/signin?callbackUrl=http://localhost:3000/profile"
23
- */
24
- function getCallbackUrl(url) {
25
- if (url === void 0) { url = window.location.href; }
26
- return url.split("callbackUrl=")[1] || "";
27
- }
28
- exports.getCallbackUrl = getCallbackUrl;
package/auth/helpers.mjs DELETED
@@ -1,22 +0,0 @@
1
- import isString from "@koine/utils/isString";
2
- export var AUTH_ROUTES = {
3
- login: process.env["AUTH_ROUTE_LOGIN"],
4
- profile: process.env["AUTH_ROUTE_PROFILE"],
5
- register: process.env["AUTH_ROUTE_REGISTER"],
6
- secured: JSON.parse(process.env["AUTH_ROUTES_SECURED"] || "[]"),
7
- };
8
- export function getAuthRoutes(t) {
9
- return Object.keys(AUTH_ROUTES).reduce(function (map, name) {
10
- var routePage = AUTH_ROUTES[name];
11
- // @ts-expect-error cannot remember
12
- map[name] = isString(routePage) ? t("~:".concat(AUTH_ROUTES[name])) : routePage;
13
- return map;
14
- }, {});
15
- }
16
- /**
17
- * @param url e.g. "http://localhost:3000/signin?callbackUrl=http://localhost:3000/profile"
18
- */
19
- export function getCallbackUrl(url) {
20
- if (url === void 0) { url = window.location.href; }
21
- return url.split("callbackUrl=")[1] || "";
22
- }
package/auth/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./helpers";
2
- export * from "./useLogin";
3
- export * from "./useLoginUrl";
4
- export * from "./useLogout";
package/auth/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./helpers"), exports);
5
- tslib_1.__exportStar(require("./useLogin"), exports);
6
- tslib_1.__exportStar(require("./useLoginUrl"), exports);
7
- tslib_1.__exportStar(require("./useLogout"), exports);
package/auth/index.mjs DELETED
@@ -1,4 +0,0 @@
1
- export * from "./helpers";
2
- export * from "./useLogin";
3
- export * from "./useLoginUrl";
4
- export * from "./useLogout";
@@ -1,8 +0,0 @@
1
- import type { SubmitHandler } from "react-hook-form";
2
- export declare function useLogin<LoginForm extends {} = {}>(): {
3
- submit: SubmitHandler<LoginForm>;
4
- loading: boolean;
5
- ok: boolean;
6
- fail: boolean;
7
- };
8
- export default useLogin;
package/auth/useLogin.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useLogin = void 0;
4
- var tslib_1 = require("tslib");
5
- var react_1 = require("react");
6
- var router_1 = require("next/router");
7
- var react_2 = require("next-auth/react");
8
- var parseURL_1 = tslib_1.__importDefault(require("@koine/utils/parseURL"));
9
- var useT_1 = require("../useT");
10
- var helpers_1 = require("./helpers");
11
- function useLogin() {
12
- var t = (0, useT_1.useT)();
13
- var push = (0, router_1.useRouter)().push;
14
- var _a = (0, react_1.useState)(false), loading = _a[0], setLoading = _a[1];
15
- var _b = (0, react_1.useState)(false), ok = _b[0], setOk = _b[1];
16
- var _c = (0, react_1.useState)(false), fail = _c[0], setFail = _c[1];
17
- var submit = (0, react_1.useCallback)(function (data) {
18
- setLoading(true);
19
- (0, react_2.signIn)("credentials", tslib_1.__assign(tslib_1.__assign({}, data), { redirect: false }))
20
- // @ts-expect-error FIXME: at some point...
21
- .then(function (_a) {
22
- var ok = _a.ok;
23
- setLoading(false);
24
- setOk(ok);
25
- setFail(!ok);
26
- if (ok) {
27
- var redirectUrl = (0, parseURL_1.default)((0, helpers_1.getCallbackUrl)());
28
- var _b = (0, helpers_1.getAuthRoutes)(t), login = _b.login, register = _b.register, profile = _b.profile;
29
- if (redirectUrl) {
30
- var redirectPath = redirectUrl.pathname;
31
- if (profile &&
32
- (redirectPath === login || redirectPath === register)) {
33
- push(profile);
34
- }
35
- else {
36
- push(redirectPath + redirectUrl.search);
37
- }
38
- }
39
- else if (profile) {
40
- push(profile);
41
- }
42
- }
43
- });
44
- }, [t, push]);
45
- // TODO: useMemo ?
46
- return {
47
- submit: submit,
48
- loading: loading,
49
- ok: ok,
50
- fail: fail,
51
- };
52
- }
53
- exports.useLogin = useLogin;
54
- exports.default = useLogin;
package/auth/useLogin.mjs DELETED
@@ -1,50 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { useState, useCallback } from "react";
3
- import { useRouter } from "next/router";
4
- import { signIn } from "next-auth/react";
5
- import parseURL from "@koine/utils/parseURL";
6
- import { useT } from "../useT";
7
- import { getAuthRoutes, getCallbackUrl } from "./helpers";
8
- export function useLogin() {
9
- var t = useT();
10
- var push = useRouter().push;
11
- var _a = useState(false), loading = _a[0], setLoading = _a[1];
12
- var _b = useState(false), ok = _b[0], setOk = _b[1];
13
- var _c = useState(false), fail = _c[0], setFail = _c[1];
14
- var submit = useCallback(function (data) {
15
- setLoading(true);
16
- signIn("credentials", __assign(__assign({}, data), { redirect: false }))
17
- // @ts-expect-error FIXME: at some point...
18
- .then(function (_a) {
19
- var ok = _a.ok;
20
- setLoading(false);
21
- setOk(ok);
22
- setFail(!ok);
23
- if (ok) {
24
- var redirectUrl = parseURL(getCallbackUrl());
25
- var _b = getAuthRoutes(t), login = _b.login, register = _b.register, profile = _b.profile;
26
- if (redirectUrl) {
27
- var redirectPath = redirectUrl.pathname;
28
- if (profile &&
29
- (redirectPath === login || redirectPath === register)) {
30
- push(profile);
31
- }
32
- else {
33
- push(redirectPath + redirectUrl.search);
34
- }
35
- }
36
- else if (profile) {
37
- push(profile);
38
- }
39
- }
40
- });
41
- }, [t, push]);
42
- // TODO: useMemo ?
43
- return {
44
- submit: submit,
45
- loading: loading,
46
- ok: ok,
47
- fail: fail,
48
- };
49
- }
50
- export default useLogin;
@@ -1,2 +0,0 @@
1
- export declare function useLoginUrl(): string;
2
- export default useLoginUrl;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useLoginUrl = void 0;
4
- var react_1 = require("react");
5
- var useT_1 = require("../useT");
6
- var helpers_1 = require("./helpers");
7
- function useLoginUrl() {
8
- var _a = (0, react_1.useState)(""), currentUrl = _a[0], setCurrentUrl = _a[1];
9
- var t = (0, useT_1.useT)();
10
- (0, react_1.useEffect)(function () {
11
- setCurrentUrl("?callbackUrl=".concat(window.location.href));
12
- }, []);
13
- return "".concat((0, helpers_1.getAuthRoutes)(t).login).concat(currentUrl);
14
- }
15
- exports.useLoginUrl = useLoginUrl;
16
- exports.default = useLoginUrl;
@@ -1,12 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { useT } from "../useT";
3
- import { getAuthRoutes } from "./helpers";
4
- export function useLoginUrl() {
5
- var _a = useState(""), currentUrl = _a[0], setCurrentUrl = _a[1];
6
- var t = useT();
7
- useEffect(function () {
8
- setCurrentUrl("?callbackUrl=".concat(window.location.href));
9
- }, []);
10
- return "".concat(getAuthRoutes(t).login).concat(currentUrl);
11
- }
12
- export default useLoginUrl;
@@ -1,7 +0,0 @@
1
- export declare function useLogout(): {
2
- submit: (event: React.SyntheticEvent<HTMLFormElement>) => void;
3
- loading: boolean;
4
- ok: boolean;
5
- fail: boolean;
6
- };
7
- export default useLogout;
package/auth/useLogout.js DELETED
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useLogout = void 0;
4
- var tslib_1 = require("tslib");
5
- var react_1 = require("react");
6
- var router_1 = require("next/router");
7
- var react_2 = require("next-auth/react");
8
- var parseURL_1 = tslib_1.__importDefault(require("@koine/utils/parseURL"));
9
- var useT_1 = require("../useT");
10
- var helpers_1 = require("./helpers");
11
- function useLogout() {
12
- var t = (0, useT_1.useT)();
13
- var push = (0, router_1.useRouter)().push;
14
- var _a = (0, react_1.useState)(false), loading = _a[0], setLoading = _a[1];
15
- var _b = (0, react_1.useState)(false), ok = _b[0], setOk = _b[1];
16
- var fail = (0, react_1.useState)(false)[0];
17
- var submit = (0, react_1.useCallback)(function (event) {
18
- event.preventDefault();
19
- event.stopPropagation();
20
- setLoading(true);
21
- (0, react_2.signOut)({ redirect: false }).then(function () {
22
- setLoading(false);
23
- setOk(true);
24
- var redirectUrl = (0, parseURL_1.default)((0, helpers_1.getCallbackUrl)());
25
- var currentUrl = (0, parseURL_1.default)(window.location.href);
26
- var secured = (0, helpers_1.getAuthRoutes)(t).secured;
27
- var signin = t("~:/signin");
28
- var profile = t("~:/profile");
29
- var targetUrl = redirectUrl || currentUrl;
30
- var redirect = "";
31
- if (targetUrl) {
32
- if (targetUrl.pathname === profile) {
33
- redirect = signin;
34
- }
35
- else if (secured) {
36
- for (var i = 0; i < secured.length; i++) {
37
- if (targetUrl.pathname.match(secured[i])) {
38
- redirect = signin;
39
- break;
40
- }
41
- }
42
- }
43
- }
44
- if (redirect) {
45
- push(redirect);
46
- }
47
- });
48
- }, [t, push]);
49
- // TODO: useMemo ?
50
- return {
51
- submit: submit,
52
- loading: loading,
53
- ok: ok,
54
- fail: fail,
55
- };
56
- }
57
- exports.useLogout = useLogout;
58
- exports.default = useLogout;
@@ -1,53 +0,0 @@
1
- import { useState, useCallback } from "react";
2
- import { useRouter } from "next/router";
3
- import { signOut } from "next-auth/react";
4
- import parseURL from "@koine/utils/parseURL";
5
- import { useT } from "../useT";
6
- import { getAuthRoutes, getCallbackUrl } from "./helpers";
7
- export function useLogout() {
8
- var t = useT();
9
- var push = useRouter().push;
10
- var _a = useState(false), loading = _a[0], setLoading = _a[1];
11
- var _b = useState(false), ok = _b[0], setOk = _b[1];
12
- var fail = useState(false)[0];
13
- var submit = useCallback(function (event) {
14
- event.preventDefault();
15
- event.stopPropagation();
16
- setLoading(true);
17
- signOut({ redirect: false }).then(function () {
18
- setLoading(false);
19
- setOk(true);
20
- var redirectUrl = parseURL(getCallbackUrl());
21
- var currentUrl = parseURL(window.location.href);
22
- var secured = getAuthRoutes(t).secured;
23
- var signin = t("~:/signin");
24
- var profile = t("~:/profile");
25
- var targetUrl = redirectUrl || currentUrl;
26
- var redirect = "";
27
- if (targetUrl) {
28
- if (targetUrl.pathname === profile) {
29
- redirect = signin;
30
- }
31
- else if (secured) {
32
- for (var i = 0; i < secured.length; i++) {
33
- if (targetUrl.pathname.match(secured[i])) {
34
- redirect = signin;
35
- break;
36
- }
37
- }
38
- }
39
- }
40
- if (redirect) {
41
- push(redirect);
42
- }
43
- });
44
- }, [t, push]);
45
- // TODO: useMemo ?
46
- return {
47
- submit: submit,
48
- loading: loading,
49
- ok: ok,
50
- fail: fail,
51
- };
52
- }
53
- export default useLogout;
@@ -1,6 +0,0 @@
1
- /**
2
- * prepend: true moves MUI styles to the top of the <head> so they're loaded first.
3
- * It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
4
- */
5
- export declare function createEmotionCache(): import("@emotion/utils").EmotionCache;
6
- export default createEmotionCache;
@@ -1,14 +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;
14
- exports.default = createEmotionCache;
@@ -1,9 +0,0 @@
1
- import createCache from "@emotion/cache";
2
- /**
3
- * prepend: true moves MUI styles to the top of the <head> so they're loaded first.
4
- * It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
5
- */
6
- export function createEmotionCache() {
7
- return createCache({ key: "css", prepend: true });
8
- }
9
- export default createEmotionCache;
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import NextDocument from "next/document";
3
- /**
4
- * Next Document wrapper for `emotion` based projects
5
- *
6
- * @example
7
- *
8
- * in your `myapp/pages/_document.tsx`:
9
- * ```tsx
10
- * export { Document as default } from "@koine/next/document/em";
11
- * ```
12
- */
13
- export declare class Document extends NextDocument {
14
- render(): JSX.Element;
15
- }
16
- export default Document;