@koine/next 2.0.0-alpha.1 → 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 (306) hide show
  1. package/{AnalyticsGoogle.d.ts → 12/AnalyticsGoogle.d.ts} +1 -1
  2. package/{AnalyticsGoogle.js → 12/AnalyticsGoogle.js} +1 -1
  3. package/{legacy → 12}/AnalyticsGoogle.mjs +1 -2
  4. package/{legacy → 12}/DisableErrorOverlay.d.ts +1 -1
  5. package/{Favicon.d.ts → 12/Favicon.d.ts} +1 -1
  6. package/{legacy → 12}/Link.js +1 -1
  7. package/{legacy → 12}/Link.mjs +1 -1
  8. package/{NextProgress.d.ts → 12/NextProgress.d.ts} +1 -1
  9. package/{legacy → 12}/Seo.d.ts +1 -1
  10. package/{SeoDefaults.d.ts → 12/SeoDefaults.d.ts} +1 -1
  11. package/{T.d.ts → 12/T.d.ts} +1 -0
  12. package/{legacy → 12}/ThemeProvider.d.ts +1 -1
  13. package/{ThemeProvider.js → 12/ThemeProvider.js} +2 -14
  14. package/{ThemeProvider.mjs → 12/ThemeProvider.mjs} +3 -15
  15. package/12/app/AppHead.d.ts +3 -0
  16. package/{legacy → 12}/app/css/AppMain.d.ts +1 -1
  17. package/{legacy → 12}/app/css/AppTheme.d.ts +1 -1
  18. package/{app → 12/app}/css/AppTheme.js +1 -2
  19. package/{app → 12/app}/css/AppTheme.mjs +1 -2
  20. package/{legacy/app/sc → 12/app/css}/auth/index.d.ts +1 -1
  21. package/{app → 12/app}/css/auth/index.js +1 -1
  22. package/{app → 12/app}/css/auth/index.mjs +1 -1
  23. package/{app → 12/app}/css/index.d.ts +1 -1
  24. package/{legacy → 12}/app/sc/AppMain.d.ts +1 -1
  25. package/{legacy → 12}/app/sc/AppMain.js +1 -1
  26. package/{app → 12/app}/sc/AppMain.mjs +1 -1
  27. package/{legacy → 12}/app/sc/AppTheme.d.ts +1 -1
  28. package/{app → 12/app}/sc/AppTheme.js +1 -2
  29. package/{app → 12/app}/sc/AppTheme.mjs +1 -2
  30. package/{legacy/app/css → 12/app/sc}/auth/index.d.ts +1 -1
  31. package/{app/em → 12/app/sc}/auth/index.js +1 -1
  32. package/{legacy/app/css → 12/app/sc}/auth/index.mjs +1 -1
  33. package/{legacy → 12}/app/sc/index.d.ts +1 -1
  34. package/{document → 12/document}/Document.d.ts +1 -2
  35. package/{legacy → 12}/document/Document.js +1 -1
  36. package/{legacy → 12}/document/Document.mjs +2 -2
  37. package/{legacy → 12}/document/css/index.d.ts +1 -2
  38. package/{document → 12/document}/css/index.js +1 -1
  39. package/{legacy → 12}/document/css/index.mjs +2 -2
  40. package/{legacy → 12}/document/sc/index.d.ts +1 -2
  41. package/{legacy → 12}/document/sc/index.js +1 -1
  42. package/{legacy → 12}/document/sc/index.mjs +1 -1
  43. package/{legacy → 12}/types-i18n.d.ts +1 -1
  44. package/{legacy → 12}/useForm.d.ts +1 -1
  45. package/12/useT.d.ts +4 -0
  46. package/{useT.js → 12/useT.js} +20 -16
  47. package/{legacy → 12}/useT.mjs +7 -5
  48. package/package.json +13 -24
  49. package/AnalyticsGoogle.mjs +0 -35
  50. package/DisableErrorOverlay.d.ts +0 -7
  51. package/Head.d.ts +0 -3
  52. package/Head.js +0 -7
  53. package/Head.mjs +0 -3
  54. package/Link.js +0 -15
  55. package/Link.mjs +0 -12
  56. package/Seo.d.ts +0 -41
  57. package/ThemeProvider.d.ts +0 -35
  58. package/app/AppHead.d.ts +0 -3
  59. package/app/css/AppMain.d.ts +0 -9
  60. package/app/css/AppTheme.d.ts +0 -11
  61. package/app/css/auth/index.d.ts +0 -11
  62. package/app/em/AppMain.d.ts +0 -11
  63. package/app/em/AppMain.js +0 -29
  64. package/app/em/AppMain.mjs +0 -25
  65. package/app/em/AppTheme.d.ts +0 -16
  66. package/app/em/AppTheme.js +0 -23
  67. package/app/em/AppTheme.mjs +0 -19
  68. package/app/em/auth/index.d.ts +0 -11
  69. package/app/em/auth/index.mjs +0 -13
  70. package/app/em/index.d.ts +0 -9
  71. package/app/em/index.js +0 -16
  72. package/app/em/index.mjs +0 -12
  73. package/app/sc/AppMain.d.ts +0 -11
  74. package/app/sc/AppMain.js +0 -29
  75. package/app/sc/AppTheme.d.ts +0 -14
  76. package/app/sc/auth/index.d.ts +0 -11
  77. package/app/sc/auth/index.js +0 -17
  78. package/app/sc/auth/index.mjs +0 -13
  79. package/app/sc/index.d.ts +0 -56
  80. package/auth/helpers.d.ts +0 -17
  81. package/auth/helpers.js +0 -28
  82. package/auth/helpers.mjs +0 -22
  83. package/auth/index.d.ts +0 -4
  84. package/auth/index.js +0 -7
  85. package/auth/index.mjs +0 -4
  86. package/auth/useLogin.d.ts +0 -8
  87. package/auth/useLogin.js +0 -54
  88. package/auth/useLogin.mjs +0 -50
  89. package/auth/useLoginUrl.d.ts +0 -2
  90. package/auth/useLoginUrl.js +0 -17
  91. package/auth/useLoginUrl.mjs +0 -13
  92. package/auth/useLogout.d.ts +0 -7
  93. package/auth/useLogout.js +0 -59
  94. package/auth/useLogout.mjs +0 -54
  95. package/createEmotionCache.d.ts +0 -6
  96. package/createEmotionCache.js +0 -14
  97. package/createEmotionCache.mjs +0 -9
  98. package/document/Document.js +0 -31
  99. package/document/Document.mjs +0 -28
  100. package/document/css/index.d.ts +0 -18
  101. package/document/css/index.mjs +0 -45
  102. package/document/em/index.d.ts +0 -16
  103. package/document/em/index.js +0 -63
  104. package/document/em/index.mjs +0 -60
  105. package/document/em/package.json +0 -6
  106. package/document/package.json +0 -6
  107. package/document/sc/index.d.ts +0 -20
  108. package/document/sc/index.js +0 -67
  109. package/document/sc/index.mjs +0 -64
  110. package/document/sc/package.json +0 -6
  111. package/legacy/AnalyticsGoogle.d.ts +0 -6
  112. package/legacy/AnalyticsGoogle.js +0 -39
  113. package/legacy/DisableErrorOverlay.js +0 -18
  114. package/legacy/DisableErrorOverlay.mjs +0 -13
  115. package/legacy/DynamicNamespaces.d.ts +0 -13
  116. package/legacy/DynamicNamespaces.js +0 -13
  117. package/legacy/DynamicNamespaces.mjs +0 -9
  118. package/legacy/Favicon.d.ts +0 -4
  119. package/legacy/Favicon.js +0 -10
  120. package/legacy/Favicon.mjs +0 -6
  121. package/legacy/Link.d.ts +0 -10
  122. package/legacy/NextProgress.d.ts +0 -25
  123. package/legacy/NextProgress.js +0 -46
  124. package/legacy/NextProgress.mjs +0 -42
  125. package/legacy/Seo.js +0 -34
  126. package/legacy/Seo.mjs +0 -29
  127. package/legacy/SeoDefaults.d.ts +0 -11
  128. package/legacy/SeoDefaults.js +0 -17
  129. package/legacy/SeoDefaults.mjs +0 -12
  130. package/legacy/T.d.ts +0 -15
  131. package/legacy/T.js +0 -17
  132. package/legacy/T.mjs +0 -13
  133. package/legacy/ThemeContext.d.ts +0 -17
  134. package/legacy/ThemeContext.js +0 -10
  135. package/legacy/ThemeContext.mjs +0 -7
  136. package/legacy/ThemeProvider.js +0 -251
  137. package/legacy/ThemeProvider.mjs +0 -247
  138. package/legacy/TransText.d.ts +0 -3
  139. package/legacy/TransText.js +0 -8
  140. package/legacy/TransText.mjs +0 -4
  141. package/legacy/app/AppHead.d.ts +0 -3
  142. package/legacy/app/AppHead.js +0 -11
  143. package/legacy/app/AppHead.mjs +0 -6
  144. package/legacy/app/AppMain.d.ts +0 -35
  145. package/legacy/app/AppMain.js +0 -2
  146. package/legacy/app/AppMain.mjs +0 -1
  147. package/legacy/app/css/AppMain.js +0 -18
  148. package/legacy/app/css/AppMain.mjs +0 -14
  149. package/legacy/app/css/AppTheme.js +0 -19
  150. package/legacy/app/css/AppTheme.mjs +0 -15
  151. package/legacy/app/css/auth/index.js +0 -17
  152. package/legacy/app/css/auth/package.json +0 -6
  153. package/legacy/app/css/index.d.ts +0 -54
  154. package/legacy/app/css/index.js +0 -61
  155. package/legacy/app/css/index.mjs +0 -57
  156. package/legacy/app/css/package.json +0 -6
  157. package/legacy/app/index.d.ts +0 -2
  158. package/legacy/app/index.js +0 -5
  159. package/legacy/app/index.mjs +0 -2
  160. package/legacy/app/package.json +0 -6
  161. package/legacy/app/sc/AppMain.mjs +0 -25
  162. package/legacy/app/sc/AppTheme.js +0 -16
  163. package/legacy/app/sc/AppTheme.mjs +0 -12
  164. package/legacy/app/sc/auth/index.js +0 -17
  165. package/legacy/app/sc/auth/index.mjs +0 -13
  166. package/legacy/app/sc/auth/package.json +0 -6
  167. package/legacy/app/sc/index.js +0 -63
  168. package/legacy/app/sc/index.mjs +0 -59
  169. package/legacy/app/sc/package.json +0 -6
  170. package/legacy/document/Document.d.ts +0 -16
  171. package/legacy/document/css/index.js +0 -45
  172. package/legacy/document/css/package.json +0 -6
  173. package/legacy/document/index.d.ts +0 -2
  174. package/legacy/document/index.js +0 -7
  175. package/legacy/document/index.mjs +0 -2
  176. package/legacy/document/package.json +0 -6
  177. package/legacy/document/sc/package.json +0 -6
  178. package/legacy/getT.d.ts +0 -9
  179. package/legacy/getT.js +0 -14
  180. package/legacy/getT.mjs +0 -10
  181. package/legacy/package.json +0 -6
  182. package/legacy/useT.d.ts +0 -17
  183. package/legacy/useT.js +0 -40
  184. package/revalidate.d.ts +0 -5
  185. package/revalidate.js +0 -8
  186. package/revalidate.mjs +0 -5
  187. package/seoBuildTags.d.ts +0 -23
  188. package/seoBuildTags.js +0 -121
  189. package/seoBuildTags.mjs +0 -117
  190. package/to.d.ts +0 -24
  191. package/to.js +0 -29
  192. package/to.mjs +0 -25
  193. package/translationAsOptions.d.ts +0 -3
  194. package/translationAsOptions.js +0 -13
  195. package/translationAsOptions.mjs +0 -9
  196. package/types-i18n.d.ts +0 -118
  197. package/types-i18n.js +0 -14
  198. package/types-i18n.mjs +0 -13
  199. package/types-seo.d.ts +0 -7
  200. package/types-seo.js +0 -2
  201. package/types-seo.mjs +0 -1
  202. package/useBackUrl.d.ts +0 -2
  203. package/useBackUrl.js +0 -33
  204. package/useBackUrl.mjs +0 -28
  205. package/useDateFormat.d.ts +0 -7
  206. package/useDateFormat.js +0 -43
  207. package/useDateFormat.mjs +0 -39
  208. package/useForm.d.ts +0 -27
  209. package/useForm.js +0 -39
  210. package/useForm.mjs +0 -35
  211. package/useLocale.d.ts +0 -2
  212. package/useLocale.js +0 -11
  213. package/useLocale.mjs +0 -6
  214. package/useT.d.ts +0 -17
  215. package/useT.mjs +0 -19
  216. package/useTheme.d.ts +0 -7
  217. package/useTheme.js +0 -12
  218. package/useTheme.mjs +0 -8
  219. package/useTo.d.ts +0 -3
  220. package/useTo.js +0 -19
  221. package/useTo.mjs +0 -15
  222. /package/{DisableErrorOverlay.js → 12/DisableErrorOverlay.js} +0 -0
  223. /package/{DisableErrorOverlay.mjs → 12/DisableErrorOverlay.mjs} +0 -0
  224. /package/{DynamicNamespaces.d.ts → 12/DynamicNamespaces.d.ts} +0 -0
  225. /package/{DynamicNamespaces.js → 12/DynamicNamespaces.js} +0 -0
  226. /package/{DynamicNamespaces.mjs → 12/DynamicNamespaces.mjs} +0 -0
  227. /package/{Favicon.js → 12/Favicon.js} +0 -0
  228. /package/{Favicon.mjs → 12/Favicon.mjs} +0 -0
  229. /package/{Link.d.ts → 12/Link.d.ts} +0 -0
  230. /package/{NextProgress.js → 12/NextProgress.js} +0 -0
  231. /package/{NextProgress.mjs → 12/NextProgress.mjs} +0 -0
  232. /package/{Seo.js → 12/Seo.js} +0 -0
  233. /package/{Seo.mjs → 12/Seo.mjs} +0 -0
  234. /package/{SeoDefaults.js → 12/SeoDefaults.js} +0 -0
  235. /package/{SeoDefaults.mjs → 12/SeoDefaults.mjs} +0 -0
  236. /package/{T.js → 12/T.js} +0 -0
  237. /package/{T.mjs → 12/T.mjs} +0 -0
  238. /package/{ThemeContext.d.ts → 12/ThemeContext.d.ts} +0 -0
  239. /package/{ThemeContext.js → 12/ThemeContext.js} +0 -0
  240. /package/{ThemeContext.mjs → 12/ThemeContext.mjs} +0 -0
  241. /package/{TransText.d.ts → 12/TransText.d.ts} +0 -0
  242. /package/{TransText.js → 12/TransText.js} +0 -0
  243. /package/{TransText.mjs → 12/TransText.mjs} +0 -0
  244. /package/{app → 12/app}/AppHead.js +0 -0
  245. /package/{app → 12/app}/AppHead.mjs +0 -0
  246. /package/{app → 12/app}/AppMain.d.ts +0 -0
  247. /package/{app → 12/app}/AppMain.js +0 -0
  248. /package/{app → 12/app}/AppMain.mjs +0 -0
  249. /package/{app → 12/app}/css/AppMain.js +0 -0
  250. /package/{app → 12/app}/css/AppMain.mjs +0 -0
  251. /package/{app → 12/app}/css/auth/package.json +0 -0
  252. /package/{app → 12/app}/css/index.js +0 -0
  253. /package/{app → 12/app}/css/index.mjs +0 -0
  254. /package/{app → 12/app}/css/package.json +0 -0
  255. /package/{app → 12/app}/index.d.ts +0 -0
  256. /package/{app → 12/app}/index.js +0 -0
  257. /package/{app → 12/app}/index.mjs +0 -0
  258. /package/{app/em/auth → 12/app}/package.json +0 -0
  259. /package/{app/em → 12/app/sc/auth}/package.json +0 -0
  260. /package/{app → 12/app}/sc/index.js +0 -0
  261. /package/{app → 12/app}/sc/index.mjs +0 -0
  262. /package/{app → 12/app/sc}/package.json +0 -0
  263. /package/{app/sc/auth → 12/document/css}/package.json +0 -0
  264. /package/{document → 12/document}/index.d.ts +0 -0
  265. /package/{document → 12/document}/index.js +0 -0
  266. /package/{document → 12/document}/index.mjs +0 -0
  267. /package/{app/sc → 12/document}/package.json +0 -0
  268. /package/{auth → 12/document/sc}/package.json +0 -0
  269. /package/{getT.d.ts → 12/getT.d.ts} +0 -0
  270. /package/{getT.js → 12/getT.js} +0 -0
  271. /package/{getT.mjs → 12/getT.mjs} +0 -0
  272. /package/{legacy → 12}/index.d.ts +0 -0
  273. /package/{legacy → 12}/index.js +0 -0
  274. /package/{legacy → 12}/index.mjs +0 -0
  275. /package/{document/css → 12}/package.json +0 -0
  276. /package/{legacy → 12}/seoBuildTags.d.ts +0 -0
  277. /package/{legacy → 12}/seoBuildTags.js +0 -0
  278. /package/{legacy → 12}/seoBuildTags.mjs +0 -0
  279. /package/{legacy → 12}/to.d.ts +0 -0
  280. /package/{legacy → 12}/to.js +0 -0
  281. /package/{legacy → 12}/to.mjs +0 -0
  282. /package/{legacy → 12}/translationAsOptions.d.ts +0 -0
  283. /package/{legacy → 12}/translationAsOptions.js +0 -0
  284. /package/{legacy → 12}/translationAsOptions.mjs +0 -0
  285. /package/{legacy → 12}/types-i18n.js +0 -0
  286. /package/{legacy → 12}/types-i18n.mjs +0 -0
  287. /package/{legacy → 12}/types-seo.d.ts +0 -0
  288. /package/{legacy → 12}/types-seo.js +0 -0
  289. /package/{legacy → 12}/types-seo.mjs +0 -0
  290. /package/{legacy → 12}/useBackUrl.d.ts +0 -0
  291. /package/{legacy → 12}/useBackUrl.js +0 -0
  292. /package/{legacy → 12}/useBackUrl.mjs +0 -0
  293. /package/{legacy → 12}/useDateFormat.d.ts +0 -0
  294. /package/{legacy → 12}/useDateFormat.js +0 -0
  295. /package/{legacy → 12}/useDateFormat.mjs +0 -0
  296. /package/{legacy → 12}/useForm.js +0 -0
  297. /package/{legacy → 12}/useForm.mjs +0 -0
  298. /package/{legacy → 12}/useLocale.d.ts +0 -0
  299. /package/{legacy → 12}/useLocale.js +0 -0
  300. /package/{legacy → 12}/useLocale.mjs +0 -0
  301. /package/{legacy → 12}/useTheme.d.ts +0 -0
  302. /package/{legacy → 12}/useTheme.js +0 -0
  303. /package/{legacy → 12}/useTheme.mjs +0 -0
  304. /package/{legacy → 12}/useTo.d.ts +0 -0
  305. /package/{legacy → 12}/useTo.js +0 -0
  306. /package/{legacy → 12}/useTo.mjs +0 -0
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,17 +0,0 @@
1
- "use strict";
2
- "use client";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useLoginUrl = void 0;
5
- var react_1 = require("react");
6
- var useT_1 = require("../useT");
7
- var helpers_1 = require("./helpers");
8
- function useLoginUrl() {
9
- var _a = (0, react_1.useState)(""), currentUrl = _a[0], setCurrentUrl = _a[1];
10
- var t = (0, useT_1.useT)();
11
- (0, react_1.useEffect)(function () {
12
- setCurrentUrl("?callbackUrl=".concat(window.location.href));
13
- }, []);
14
- return "".concat((0, helpers_1.getAuthRoutes)(t).login).concat(currentUrl);
15
- }
16
- exports.useLoginUrl = useLoginUrl;
17
- exports.default = useLoginUrl;
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { useEffect, useState } from "react";
3
- import { useT } from "../useT";
4
- import { getAuthRoutes } from "./helpers";
5
- export function useLoginUrl() {
6
- var _a = useState(""), currentUrl = _a[0], setCurrentUrl = _a[1];
7
- var t = useT();
8
- useEffect(function () {
9
- setCurrentUrl("?callbackUrl=".concat(window.location.href));
10
- }, []);
11
- return "".concat(getAuthRoutes(t).login).concat(currentUrl);
12
- }
13
- 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,59 +0,0 @@
1
- "use strict";
2
- "use client";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useLogout = void 0;
5
- var tslib_1 = require("tslib");
6
- var react_1 = require("react");
7
- var router_1 = require("next/router");
8
- var react_2 = require("next-auth/react");
9
- var parseURL_1 = tslib_1.__importDefault(require("@koine/utils/parseURL"));
10
- var useT_1 = require("../useT");
11
- var helpers_1 = require("./helpers");
12
- function useLogout() {
13
- var t = (0, useT_1.useT)();
14
- var push = (0, router_1.useRouter)().push;
15
- var _a = (0, react_1.useState)(false), loading = _a[0], setLoading = _a[1];
16
- var _b = (0, react_1.useState)(false), ok = _b[0], setOk = _b[1];
17
- var fail = (0, react_1.useState)(false)[0];
18
- var submit = (0, react_1.useCallback)(function (event) {
19
- event.preventDefault();
20
- event.stopPropagation();
21
- setLoading(true);
22
- (0, react_2.signOut)({ redirect: false }).then(function () {
23
- setLoading(false);
24
- setOk(true);
25
- var redirectUrl = (0, parseURL_1.default)((0, helpers_1.getCallbackUrl)());
26
- var currentUrl = (0, parseURL_1.default)(window.location.href);
27
- var secured = (0, helpers_1.getAuthRoutes)(t).secured;
28
- var signin = t("~:/signin");
29
- var profile = t("~:/profile");
30
- var targetUrl = redirectUrl || currentUrl;
31
- var redirect = "";
32
- if (targetUrl) {
33
- if (targetUrl.pathname === profile) {
34
- redirect = signin;
35
- }
36
- else if (secured) {
37
- for (var i = 0; i < secured.length; i++) {
38
- if (targetUrl.pathname.match(secured[i])) {
39
- redirect = signin;
40
- break;
41
- }
42
- }
43
- }
44
- }
45
- if (redirect) {
46
- push(redirect);
47
- }
48
- });
49
- }, [t, push]);
50
- // TODO: useMemo ?
51
- return {
52
- submit: submit,
53
- loading: loading,
54
- ok: ok,
55
- fail: fail,
56
- };
57
- }
58
- exports.useLogout = useLogout;
59
- exports.default = useLogout;
@@ -1,54 +0,0 @@
1
- "use client";
2
- import { useState, useCallback } from "react";
3
- import { useRouter } from "next/router";
4
- import { signOut } 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 useLogout() {
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 fail = useState(false)[0];
14
- var submit = useCallback(function (event) {
15
- event.preventDefault();
16
- event.stopPropagation();
17
- setLoading(true);
18
- signOut({ redirect: false }).then(function () {
19
- setLoading(false);
20
- setOk(true);
21
- var redirectUrl = parseURL(getCallbackUrl());
22
- var currentUrl = parseURL(window.location.href);
23
- var secured = getAuthRoutes(t).secured;
24
- var signin = t("~:/signin");
25
- var profile = t("~:/profile");
26
- var targetUrl = redirectUrl || currentUrl;
27
- var redirect = "";
28
- if (targetUrl) {
29
- if (targetUrl.pathname === profile) {
30
- redirect = signin;
31
- }
32
- else if (secured) {
33
- for (var i = 0; i < secured.length; i++) {
34
- if (targetUrl.pathname.match(secured[i])) {
35
- redirect = signin;
36
- break;
37
- }
38
- }
39
- }
40
- }
41
- if (redirect) {
42
- push(redirect);
43
- }
44
- });
45
- }, [t, push]);
46
- // TODO: useMemo ?
47
- return {
48
- submit: submit,
49
- loading: loading,
50
- ok: ok,
51
- fail: fail,
52
- };
53
- }
54
- 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,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var document_1 = tslib_1.__importStar(require("next/document"));
7
- var Meta_1 = tslib_1.__importDefault(require("@koine/react/Meta"));
8
- var NoJs_1 = tslib_1.__importDefault(require("@koine/react/NoJs"));
9
- /**
10
- * Next Document wrapper for bare projects
11
- *
12
- * @example
13
- *
14
- * in your `myapp/pages/_document.tsx`:
15
- * ```tsx
16
- * export { Document as default } from "@koine/next/document";
17
- * ```
18
- */
19
- var Document = /** @class */ (function (_super) {
20
- tslib_1.__extends(Document, _super);
21
- function Document() {
22
- return _super !== null && _super.apply(this, arguments) || this;
23
- }
24
- Document.prototype.render = function () {
25
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
26
- return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(Meta_1.default, {}), (0, jsx_runtime_1.jsx)(NoJs_1.default, {})] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
27
- };
28
- return Document;
29
- }(document_1.default));
30
- exports.Document = Document;
31
- exports.default = Document;
@@ -1,28 +0,0 @@
1
- import { __assign, __extends } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import NextDocument, { Html, Head, Main, NextScript } from "next/document";
4
- import Meta from "@koine/react/Meta";
5
- import NoJs from "@koine/react/NoJs";
6
- /**
7
- * Next Document wrapper for bare projects
8
- *
9
- * @example
10
- *
11
- * in your `myapp/pages/_document.tsx`:
12
- * ```tsx
13
- * export { Document as default } from "@koine/next/document";
14
- * ```
15
- */
16
- var Document = /** @class */ (function (_super) {
17
- __extends(Document, _super);
18
- function Document() {
19
- return _super !== null && _super.apply(this, arguments) || this;
20
- }
21
- Document.prototype.render = function () {
22
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
23
- return (_jsxs(Html, __assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] })));
24
- };
25
- return Document;
26
- }(NextDocument));
27
- export { Document };
28
- export default Document;
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- import NextDocument from "next/document";
3
- /**
4
- * Next Document wrapper for `css/tailwind` based projects
5
- *
6
- * Uses cookie to manage the current theme
7
- *
8
- * @example
9
- *
10
- * in your `myapp/pages/_document.tsx`:
11
- * ```tsx
12
- * export { Document as default } from "@koine/next/document/css";
13
- * ```
14
- */
15
- export declare class Document extends NextDocument {
16
- render(): JSX.Element;
17
- }
18
- export default Document;
@@ -1,45 +0,0 @@
1
- import { __assign, __extends } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import NextDocument, {
4
- // DocumentContext,
5
- // DocumentInitialProps,
6
- Html, Head, Main, NextScript, } from "next/document";
7
- import Meta from "@koine/react/Meta";
8
- import NoJs from "@koine/react/NoJs";
9
- // import { getInitialThemeFromRequest, ThemeVanillaValue } from "@koine/react/sc"; // FIXME: this should be imported from another entrypoint
10
- /**
11
- * Next Document wrapper for `css/tailwind` based projects
12
- *
13
- * Uses cookie to manage the current theme
14
- *
15
- * @example
16
- *
17
- * in your `myapp/pages/_document.tsx`:
18
- * ```tsx
19
- * export { Document as default } from "@koine/next/document/css";
20
- * ```
21
- */
22
- var Document = /** @class */ (function (_super) {
23
- __extends(Document, _super);
24
- function Document() {
25
- return _super !== null && _super.apply(this, arguments) || this;
26
- }
27
- // static override async getInitialProps(
28
- // ctx: DocumentContext
29
- // ): Promise<DocumentInitialProps & { theme: ThemeVanillaValue }> {
30
- // const initialProps = await NextDocument.getInitialProps(ctx);
31
- // return {
32
- // ...initialProps,
33
- // theme: getInitialThemeFromRequest(
34
- // ctx.req?.headers.cookie /* || document?.cookie */ || ""
35
- // ),
36
- // };
37
- // }
38
- Document.prototype.render = function () {
39
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
40
- return (_jsxs(Html, __assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] })));
41
- };
42
- return Document;
43
- }(NextDocument));
44
- export { Document };
45
- export default Document;
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import NextDocument from "next/document";
3
- /**
4
- * Next Document wrapper for `emotion` based projects
5
- *
6
- * @example
7
- *
8
- * in your `myapp/pages/_document.tsx`:
9
- * ```tsx
10
- * export { Document as default } from "@koine/next/document/em";
11
- * ```
12
- */
13
- export declare class Document extends NextDocument {
14
- render(): JSX.Element;
15
- }
16
- export default Document;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var document_1 = tslib_1.__importStar(require("next/document"));
7
- var Meta_1 = tslib_1.__importDefault(require("@koine/react/Meta"));
8
- var NoJs_1 = tslib_1.__importDefault(require("@koine/react/NoJs"));
9
- var create_instance_1 = tslib_1.__importDefault(require("@emotion/server/create-instance"));
10
- var createEmotionCache_1 = require("../../createEmotionCache");
11
- /**
12
- * Next Document wrapper for `emotion` based projects
13
- *
14
- * @example
15
- *
16
- * in your `myapp/pages/_document.tsx`:
17
- * ```tsx
18
- * export { Document as default } from "@koine/next/document/em";
19
- * ```
20
- */
21
- var Document = /** @class */ (function (_super) {
22
- tslib_1.__extends(Document, _super);
23
- function Document() {
24
- return _super !== null && _super.apply(this, arguments) || this;
25
- }
26
- Document.prototype.render = function () {
27
- var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
28
- return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(Meta_1.default, {}), (0, jsx_runtime_1.jsx)(NoJs_1.default, {}), this.props.emotionStyleTags] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
29
- };
30
- return Document;
31
- }(document_1.default));
32
- exports.Document = Document;
33
- // `getInitialProps` belongs to `_document` (instead of `_app`),
34
- // it's compatible with static-site generation (SSG).
35
- Document.getInitialProps = function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
36
- var originalRenderPage, cache, extractCriticalToChunks, initialProps, emotionStyles, emotionStyleTags;
37
- return tslib_1.__generator(this, function (_a) {
38
- switch (_a.label) {
39
- case 0:
40
- originalRenderPage = ctx.renderPage;
41
- cache = (0, createEmotionCache_1.createEmotionCache)();
42
- extractCriticalToChunks = (0, create_instance_1.default)(cache).extractCriticalToChunks;
43
- ctx.renderPage = function () {
44
- return originalRenderPage({
45
- enhanceApp: function (App) {
46
- return function EnhanceApp(props) {
47
- return (0, jsx_runtime_1.jsx)(App, tslib_1.__assign({ emotionCache: cache }, props));
48
- };
49
- },
50
- });
51
- };
52
- return [4 /*yield*/, Document.getInitialProps(ctx)];
53
- case 1:
54
- initialProps = _a.sent();
55
- emotionStyles = extractCriticalToChunks(initialProps.html);
56
- emotionStyleTags = emotionStyles.styles.map(function (style) { return ((0, jsx_runtime_1.jsx)("style", { "data-emotion": "".concat(style.key, " ").concat(style.ids.join(" ")),
57
- // eslint-disable-next-line react/no-danger
58
- dangerouslySetInnerHTML: { __html: style.css } }, style.key)); });
59
- return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), { emotionStyleTags: emotionStyleTags })];
60
- }
61
- });
62
- }); };
63
- exports.default = Document;