@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.
- package/{AnalyticsGoogle.d.ts → 12/AnalyticsGoogle.d.ts} +1 -1
- package/{AnalyticsGoogle.js → 12/AnalyticsGoogle.js} +1 -1
- package/{legacy → 12}/AnalyticsGoogle.mjs +1 -2
- package/{legacy → 12}/DisableErrorOverlay.d.ts +1 -1
- package/{Favicon.d.ts → 12/Favicon.d.ts} +1 -1
- package/{legacy → 12}/Link.js +1 -1
- package/{legacy → 12}/Link.mjs +1 -1
- package/{NextProgress.d.ts → 12/NextProgress.d.ts} +1 -1
- package/{legacy → 12}/Seo.d.ts +1 -1
- package/{SeoDefaults.d.ts → 12/SeoDefaults.d.ts} +1 -1
- package/{T.d.ts → 12/T.d.ts} +1 -0
- package/{legacy → 12}/ThemeProvider.d.ts +1 -1
- package/{ThemeProvider.js → 12/ThemeProvider.js} +2 -14
- package/{ThemeProvider.mjs → 12/ThemeProvider.mjs} +3 -15
- package/12/app/AppHead.d.ts +3 -0
- package/{legacy → 12}/app/css/AppMain.d.ts +1 -1
- package/{legacy → 12}/app/css/AppTheme.d.ts +1 -1
- package/{app → 12/app}/css/AppTheme.js +1 -2
- package/{app → 12/app}/css/AppTheme.mjs +1 -2
- package/{legacy/app/sc → 12/app/css}/auth/index.d.ts +1 -1
- package/{app → 12/app}/css/auth/index.js +1 -1
- package/{app → 12/app}/css/auth/index.mjs +1 -1
- package/{app → 12/app}/css/index.d.ts +1 -1
- package/{legacy → 12}/app/sc/AppMain.d.ts +1 -1
- package/{legacy → 12}/app/sc/AppMain.js +1 -1
- package/{app → 12/app}/sc/AppMain.mjs +1 -1
- package/{legacy → 12}/app/sc/AppTheme.d.ts +1 -1
- package/{app → 12/app}/sc/AppTheme.js +1 -2
- package/{app → 12/app}/sc/AppTheme.mjs +1 -2
- package/{legacy/app/css → 12/app/sc}/auth/index.d.ts +1 -1
- package/{app/em → 12/app/sc}/auth/index.js +1 -1
- package/{legacy/app/css → 12/app/sc}/auth/index.mjs +1 -1
- package/{legacy → 12}/app/sc/index.d.ts +1 -1
- package/{document → 12/document}/Document.d.ts +1 -2
- package/{legacy → 12}/document/Document.js +1 -1
- package/{legacy → 12}/document/Document.mjs +2 -2
- package/{legacy → 12}/document/css/index.d.ts +1 -2
- package/{document → 12/document}/css/index.js +1 -1
- package/{legacy → 12}/document/css/index.mjs +2 -2
- package/{legacy → 12}/document/sc/index.d.ts +1 -2
- package/{legacy → 12}/document/sc/index.js +1 -1
- package/{legacy → 12}/document/sc/index.mjs +1 -1
- package/{legacy → 12}/types-i18n.d.ts +1 -1
- package/{legacy → 12}/useForm.d.ts +1 -1
- package/12/useT.d.ts +4 -0
- package/{useT.js → 12/useT.js} +20 -16
- package/{legacy → 12}/useT.mjs +7 -5
- package/package.json +13 -24
- package/AnalyticsGoogle.mjs +0 -35
- package/DisableErrorOverlay.d.ts +0 -7
- package/Head.d.ts +0 -3
- package/Head.js +0 -7
- package/Head.mjs +0 -3
- package/Link.js +0 -15
- package/Link.mjs +0 -12
- package/Seo.d.ts +0 -41
- package/ThemeProvider.d.ts +0 -35
- package/app/AppHead.d.ts +0 -3
- package/app/css/AppMain.d.ts +0 -9
- package/app/css/AppTheme.d.ts +0 -11
- package/app/css/auth/index.d.ts +0 -11
- package/app/em/AppMain.d.ts +0 -11
- package/app/em/AppMain.js +0 -29
- package/app/em/AppMain.mjs +0 -25
- package/app/em/AppTheme.d.ts +0 -16
- package/app/em/AppTheme.js +0 -23
- package/app/em/AppTheme.mjs +0 -19
- package/app/em/auth/index.d.ts +0 -11
- package/app/em/auth/index.mjs +0 -13
- package/app/em/index.d.ts +0 -9
- package/app/em/index.js +0 -16
- package/app/em/index.mjs +0 -12
- package/app/sc/AppMain.d.ts +0 -11
- package/app/sc/AppMain.js +0 -29
- package/app/sc/AppTheme.d.ts +0 -14
- package/app/sc/auth/index.d.ts +0 -11
- package/app/sc/auth/index.js +0 -17
- package/app/sc/auth/index.mjs +0 -13
- package/app/sc/index.d.ts +0 -56
- package/auth/helpers.d.ts +0 -17
- package/auth/helpers.js +0 -28
- package/auth/helpers.mjs +0 -22
- package/auth/index.d.ts +0 -4
- package/auth/index.js +0 -7
- package/auth/index.mjs +0 -4
- package/auth/useLogin.d.ts +0 -8
- package/auth/useLogin.js +0 -54
- package/auth/useLogin.mjs +0 -50
- package/auth/useLoginUrl.d.ts +0 -2
- package/auth/useLoginUrl.js +0 -17
- package/auth/useLoginUrl.mjs +0 -13
- package/auth/useLogout.d.ts +0 -7
- package/auth/useLogout.js +0 -59
- package/auth/useLogout.mjs +0 -54
- package/createEmotionCache.d.ts +0 -6
- package/createEmotionCache.js +0 -14
- package/createEmotionCache.mjs +0 -9
- package/document/Document.js +0 -31
- package/document/Document.mjs +0 -28
- package/document/css/index.d.ts +0 -18
- package/document/css/index.mjs +0 -45
- package/document/em/index.d.ts +0 -16
- package/document/em/index.js +0 -63
- package/document/em/index.mjs +0 -60
- package/document/em/package.json +0 -6
- package/document/package.json +0 -6
- package/document/sc/index.d.ts +0 -20
- package/document/sc/index.js +0 -67
- package/document/sc/index.mjs +0 -64
- package/document/sc/package.json +0 -6
- package/legacy/AnalyticsGoogle.d.ts +0 -6
- package/legacy/AnalyticsGoogle.js +0 -39
- package/legacy/DisableErrorOverlay.js +0 -18
- package/legacy/DisableErrorOverlay.mjs +0 -13
- package/legacy/DynamicNamespaces.d.ts +0 -13
- package/legacy/DynamicNamespaces.js +0 -13
- package/legacy/DynamicNamespaces.mjs +0 -9
- package/legacy/Favicon.d.ts +0 -4
- package/legacy/Favicon.js +0 -10
- package/legacy/Favicon.mjs +0 -6
- package/legacy/Link.d.ts +0 -10
- package/legacy/NextProgress.d.ts +0 -25
- package/legacy/NextProgress.js +0 -46
- package/legacy/NextProgress.mjs +0 -42
- package/legacy/Seo.js +0 -34
- package/legacy/Seo.mjs +0 -29
- package/legacy/SeoDefaults.d.ts +0 -11
- package/legacy/SeoDefaults.js +0 -17
- package/legacy/SeoDefaults.mjs +0 -12
- package/legacy/T.d.ts +0 -15
- package/legacy/T.js +0 -17
- package/legacy/T.mjs +0 -13
- package/legacy/ThemeContext.d.ts +0 -17
- package/legacy/ThemeContext.js +0 -10
- package/legacy/ThemeContext.mjs +0 -7
- package/legacy/ThemeProvider.js +0 -251
- package/legacy/ThemeProvider.mjs +0 -247
- package/legacy/TransText.d.ts +0 -3
- package/legacy/TransText.js +0 -8
- package/legacy/TransText.mjs +0 -4
- package/legacy/app/AppHead.d.ts +0 -3
- package/legacy/app/AppHead.js +0 -11
- package/legacy/app/AppHead.mjs +0 -6
- package/legacy/app/AppMain.d.ts +0 -35
- package/legacy/app/AppMain.js +0 -2
- package/legacy/app/AppMain.mjs +0 -1
- package/legacy/app/css/AppMain.js +0 -18
- package/legacy/app/css/AppMain.mjs +0 -14
- package/legacy/app/css/AppTheme.js +0 -19
- package/legacy/app/css/AppTheme.mjs +0 -15
- package/legacy/app/css/auth/index.js +0 -17
- package/legacy/app/css/auth/package.json +0 -6
- package/legacy/app/css/index.d.ts +0 -54
- package/legacy/app/css/index.js +0 -61
- package/legacy/app/css/index.mjs +0 -57
- package/legacy/app/css/package.json +0 -6
- package/legacy/app/index.d.ts +0 -2
- package/legacy/app/index.js +0 -5
- package/legacy/app/index.mjs +0 -2
- package/legacy/app/package.json +0 -6
- package/legacy/app/sc/AppMain.mjs +0 -25
- package/legacy/app/sc/AppTheme.js +0 -16
- package/legacy/app/sc/AppTheme.mjs +0 -12
- package/legacy/app/sc/auth/index.js +0 -17
- package/legacy/app/sc/auth/index.mjs +0 -13
- package/legacy/app/sc/auth/package.json +0 -6
- package/legacy/app/sc/index.js +0 -63
- package/legacy/app/sc/index.mjs +0 -59
- package/legacy/app/sc/package.json +0 -6
- package/legacy/document/Document.d.ts +0 -16
- package/legacy/document/css/index.js +0 -45
- package/legacy/document/css/package.json +0 -6
- package/legacy/document/index.d.ts +0 -2
- package/legacy/document/index.js +0 -7
- package/legacy/document/index.mjs +0 -2
- package/legacy/document/package.json +0 -6
- package/legacy/document/sc/package.json +0 -6
- package/legacy/getT.d.ts +0 -9
- package/legacy/getT.js +0 -14
- package/legacy/getT.mjs +0 -10
- package/legacy/package.json +0 -6
- package/legacy/useT.d.ts +0 -17
- package/legacy/useT.js +0 -40
- package/revalidate.d.ts +0 -5
- package/revalidate.js +0 -8
- package/revalidate.mjs +0 -5
- package/seoBuildTags.d.ts +0 -23
- package/seoBuildTags.js +0 -121
- package/seoBuildTags.mjs +0 -117
- package/to.d.ts +0 -24
- package/to.js +0 -29
- package/to.mjs +0 -25
- package/translationAsOptions.d.ts +0 -3
- package/translationAsOptions.js +0 -13
- package/translationAsOptions.mjs +0 -9
- package/types-i18n.d.ts +0 -118
- package/types-i18n.js +0 -14
- package/types-i18n.mjs +0 -13
- package/types-seo.d.ts +0 -7
- package/types-seo.js +0 -2
- package/types-seo.mjs +0 -1
- package/useBackUrl.d.ts +0 -2
- package/useBackUrl.js +0 -33
- package/useBackUrl.mjs +0 -28
- package/useDateFormat.d.ts +0 -7
- package/useDateFormat.js +0 -43
- package/useDateFormat.mjs +0 -39
- package/useForm.d.ts +0 -27
- package/useForm.js +0 -39
- package/useForm.mjs +0 -35
- package/useLocale.d.ts +0 -2
- package/useLocale.js +0 -11
- package/useLocale.mjs +0 -6
- package/useT.d.ts +0 -17
- package/useT.mjs +0 -19
- package/useTheme.d.ts +0 -7
- package/useTheme.js +0 -12
- package/useTheme.mjs +0 -8
- package/useTo.d.ts +0 -3
- package/useTo.js +0 -19
- package/useTo.mjs +0 -15
- /package/{DisableErrorOverlay.js → 12/DisableErrorOverlay.js} +0 -0
- /package/{DisableErrorOverlay.mjs → 12/DisableErrorOverlay.mjs} +0 -0
- /package/{DynamicNamespaces.d.ts → 12/DynamicNamespaces.d.ts} +0 -0
- /package/{DynamicNamespaces.js → 12/DynamicNamespaces.js} +0 -0
- /package/{DynamicNamespaces.mjs → 12/DynamicNamespaces.mjs} +0 -0
- /package/{Favicon.js → 12/Favicon.js} +0 -0
- /package/{Favicon.mjs → 12/Favicon.mjs} +0 -0
- /package/{Link.d.ts → 12/Link.d.ts} +0 -0
- /package/{NextProgress.js → 12/NextProgress.js} +0 -0
- /package/{NextProgress.mjs → 12/NextProgress.mjs} +0 -0
- /package/{Seo.js → 12/Seo.js} +0 -0
- /package/{Seo.mjs → 12/Seo.mjs} +0 -0
- /package/{SeoDefaults.js → 12/SeoDefaults.js} +0 -0
- /package/{SeoDefaults.mjs → 12/SeoDefaults.mjs} +0 -0
- /package/{T.js → 12/T.js} +0 -0
- /package/{T.mjs → 12/T.mjs} +0 -0
- /package/{ThemeContext.d.ts → 12/ThemeContext.d.ts} +0 -0
- /package/{ThemeContext.js → 12/ThemeContext.js} +0 -0
- /package/{ThemeContext.mjs → 12/ThemeContext.mjs} +0 -0
- /package/{TransText.d.ts → 12/TransText.d.ts} +0 -0
- /package/{TransText.js → 12/TransText.js} +0 -0
- /package/{TransText.mjs → 12/TransText.mjs} +0 -0
- /package/{app → 12/app}/AppHead.js +0 -0
- /package/{app → 12/app}/AppHead.mjs +0 -0
- /package/{app → 12/app}/AppMain.d.ts +0 -0
- /package/{app → 12/app}/AppMain.js +0 -0
- /package/{app → 12/app}/AppMain.mjs +0 -0
- /package/{app → 12/app}/css/AppMain.js +0 -0
- /package/{app → 12/app}/css/AppMain.mjs +0 -0
- /package/{app → 12/app}/css/auth/package.json +0 -0
- /package/{app → 12/app}/css/index.js +0 -0
- /package/{app → 12/app}/css/index.mjs +0 -0
- /package/{app → 12/app}/css/package.json +0 -0
- /package/{app → 12/app}/index.d.ts +0 -0
- /package/{app → 12/app}/index.js +0 -0
- /package/{app → 12/app}/index.mjs +0 -0
- /package/{app/em/auth → 12/app}/package.json +0 -0
- /package/{app/em → 12/app/sc/auth}/package.json +0 -0
- /package/{app → 12/app}/sc/index.js +0 -0
- /package/{app → 12/app}/sc/index.mjs +0 -0
- /package/{app → 12/app/sc}/package.json +0 -0
- /package/{app/sc/auth → 12/document/css}/package.json +0 -0
- /package/{document → 12/document}/index.d.ts +0 -0
- /package/{document → 12/document}/index.js +0 -0
- /package/{document → 12/document}/index.mjs +0 -0
- /package/{app/sc → 12/document}/package.json +0 -0
- /package/{auth → 12/document/sc}/package.json +0 -0
- /package/{getT.d.ts → 12/getT.d.ts} +0 -0
- /package/{getT.js → 12/getT.js} +0 -0
- /package/{getT.mjs → 12/getT.mjs} +0 -0
- /package/{legacy → 12}/index.d.ts +0 -0
- /package/{legacy → 12}/index.js +0 -0
- /package/{legacy → 12}/index.mjs +0 -0
- /package/{document/css → 12}/package.json +0 -0
- /package/{legacy → 12}/seoBuildTags.d.ts +0 -0
- /package/{legacy → 12}/seoBuildTags.js +0 -0
- /package/{legacy → 12}/seoBuildTags.mjs +0 -0
- /package/{legacy → 12}/to.d.ts +0 -0
- /package/{legacy → 12}/to.js +0 -0
- /package/{legacy → 12}/to.mjs +0 -0
- /package/{legacy → 12}/translationAsOptions.d.ts +0 -0
- /package/{legacy → 12}/translationAsOptions.js +0 -0
- /package/{legacy → 12}/translationAsOptions.mjs +0 -0
- /package/{legacy → 12}/types-i18n.js +0 -0
- /package/{legacy → 12}/types-i18n.mjs +0 -0
- /package/{legacy → 12}/types-seo.d.ts +0 -0
- /package/{legacy → 12}/types-seo.js +0 -0
- /package/{legacy → 12}/types-seo.mjs +0 -0
- /package/{legacy → 12}/useBackUrl.d.ts +0 -0
- /package/{legacy → 12}/useBackUrl.js +0 -0
- /package/{legacy → 12}/useBackUrl.mjs +0 -0
- /package/{legacy → 12}/useDateFormat.d.ts +0 -0
- /package/{legacy → 12}/useDateFormat.js +0 -0
- /package/{legacy → 12}/useDateFormat.mjs +0 -0
- /package/{legacy → 12}/useForm.js +0 -0
- /package/{legacy → 12}/useForm.mjs +0 -0
- /package/{legacy → 12}/useLocale.d.ts +0 -0
- /package/{legacy → 12}/useLocale.js +0 -0
- /package/{legacy → 12}/useLocale.mjs +0 -0
- /package/{legacy → 12}/useTheme.d.ts +0 -0
- /package/{legacy → 12}/useTheme.js +0 -0
- /package/{legacy → 12}/useTheme.mjs +0 -0
- /package/{legacy → 12}/useTo.d.ts +0 -0
- /package/{legacy → 12}/useTo.js +0 -0
- /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
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
package/auth/useLogin.d.ts
DELETED
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;
|
package/auth/useLoginUrl.d.ts
DELETED
package/auth/useLoginUrl.js
DELETED
|
@@ -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;
|
package/auth/useLoginUrl.mjs
DELETED
|
@@ -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;
|
package/auth/useLogout.d.ts
DELETED
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;
|
package/auth/useLogout.mjs
DELETED
|
@@ -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;
|
package/createEmotionCache.d.ts
DELETED
|
@@ -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;
|
package/createEmotionCache.js
DELETED
|
@@ -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;
|
package/createEmotionCache.mjs
DELETED
|
@@ -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;
|
package/document/Document.js
DELETED
|
@@ -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;
|
package/document/Document.mjs
DELETED
|
@@ -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;
|
package/document/css/index.d.ts
DELETED
|
@@ -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;
|
package/document/css/index.mjs
DELETED
|
@@ -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;
|
package/document/em/index.d.ts
DELETED
|
@@ -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;
|
package/document/em/index.js
DELETED
|
@@ -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;
|