@koine/next 1.0.10 → 1.0.13
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/Analytics/AnalyticsGoogle.d.ts +5 -0
- package/Analytics/AnalyticsGoogle.js +33 -0
- package/Analytics/index.d.ts +1 -0
- package/Analytics/index.js +1 -0
- package/Analytics/package.json +6 -0
- package/Auth/helpers.d.ts +17 -0
- package/Auth/helpers.js +22 -0
- package/Auth/index.d.ts +4 -0
- package/Auth/index.js +4 -0
- package/Auth/package.json +6 -0
- package/Auth/useLogin.d.ts +7 -0
- package/Auth/useLogin.js +49 -0
- package/Auth/useLoginUrl.d.ts +1 -0
- package/Auth/useLoginUrl.js +11 -0
- package/Auth/useLogout.d.ts +6 -0
- package/Auth/useLogout.js +52 -0
- package/Favicon/Favicon.d.ts +3 -0
- package/Favicon/Favicon.js +5 -0
- package/Favicon/index.d.ts +1 -0
- package/Favicon/index.js +1 -0
- package/Favicon/package.json +6 -0
- package/Forms/index.d.ts +2 -0
- package/Forms/index.js +2 -0
- package/Forms/package.json +6 -0
- package/Forms/useForm.d.ts +32 -0
- package/Forms/useForm.js +35 -0
- package/Forms/useSubmit.d.ts +24 -0
- package/Forms/useSubmit.js +28 -0
- package/Head/Head.d.ts +1 -0
- package/Head/Head.js +1 -0
- package/Head/index.d.ts +1 -0
- package/Head/index.js +1 -0
- package/Head/package.json +6 -0
- package/I18n/I18n.d.ts +44 -0
- package/I18n/I18n.js +95 -0
- package/I18n/index.d.ts +1 -0
- package/I18n/index.js +1 -0
- package/I18n/package.json +6 -0
- package/Img/Img.d.ts +21 -0
- package/Img/Img.js +30 -0
- package/Img/index.d.ts +1 -0
- package/Img/index.js +1 -0
- package/Img/package.json +6 -0
- package/Link/Link.d.ts +9 -0
- package/Link/Link.js +11 -0
- package/Link/index.d.ts +1 -0
- package/Link/index.js +1 -0
- package/Link/package.json +6 -0
- package/NextProgress/NextProgress.d.ts +24 -0
- package/NextProgress/NextProgress.js +40 -0
- package/NextProgress/index.d.ts +2 -0
- package/NextProgress/index.js +1 -0
- package/NextProgress/package.json +6 -0
- package/Seo/Seo.d.ts +3 -0
- package/Seo/Seo.js +8 -0
- package/Seo/SeoDefaults.d.ts +3 -0
- package/Seo/SeoDefaults.js +12 -0
- package/Seo/helpers.d.ts +48 -0
- package/Seo/helpers.js +115 -0
- package/Seo/index.d.ts +12 -0
- package/Seo/index.js +12 -0
- package/Seo/package.json +6 -0
- package/Theme/Theme.d.ts +46 -0
- package/Theme/Theme.js +245 -0
- package/Theme/index.d.ts +1 -0
- package/Theme/index.js +1 -0
- package/Theme/package.json +6 -0
- package/app/AppHead.d.ts +2 -0
- package/app/AppHead.js +5 -0
- package/app/AppMain.d.ts +35 -0
- package/app/AppMain.js +1 -0
- package/app/css/AppMain.d.ts +8 -0
- package/app/css/AppMain.js +13 -0
- package/app/css/AppTheme.d.ts +10 -0
- package/app/css/AppTheme.js +14 -0
- package/app/css/auth/index.d.ts +9 -0
- package/app/css/auth/index.js +14 -0
- package/app/css/auth/package.json +6 -0
- package/app/css/index.d.ts +54 -0
- package/app/css/index.js +58 -0
- package/app/css/package.json +6 -0
- package/app/em/AppMain.d.ts +10 -0
- package/app/em/AppMain.js +24 -0
- package/app/em/AppTheme.d.ts +15 -0
- package/app/em/AppTheme.js +18 -0
- package/app/em/auth/index.d.ts +9 -0
- package/app/em/auth/index.js +14 -0
- package/app/em/auth/package.json +6 -0
- package/app/em/index.d.ts +9 -0
- package/app/em/index.js +13 -0
- package/app/em/package.json +6 -0
- package/app/index.d.ts +2 -0
- package/app/index.js +2 -0
- package/app/package.json +6 -0
- package/app/sc/AppMain.d.ts +10 -0
- package/app/sc/AppMain.js +24 -0
- package/app/sc/AppTheme.d.ts +13 -0
- package/app/sc/AppTheme.js +11 -0
- package/app/sc/auth/index.d.ts +9 -0
- package/app/sc/auth/index.js +14 -0
- package/app/sc/auth/package.json +6 -0
- package/app/sc/index.d.ts +56 -0
- package/app/sc/index.js +60 -0
- package/app/sc/package.json +6 -0
- package/config/index.d.ts +84 -0
- package/config/index.js +190 -0
- package/config/package.json +6 -0
- package/document/Document.d.ts +15 -0
- package/document/Document.js +26 -0
- package/document/css/index.d.ts +22 -0
- package/document/css/index.js +44 -0
- package/document/css/package.json +6 -0
- package/document/em/index.d.ts +16 -0
- package/document/em/index.js +59 -0
- package/document/em/package.json +6 -0
- package/document/index.d.ts +2 -0
- package/document/index.js +2 -0
- package/document/package.json +6 -0
- package/document/sc/index.d.ts +20 -0
- package/document/sc/index.js +65 -0
- package/document/sc/package.json +6 -0
- package/index.d.ts +12 -0
- package/index.js +12 -0
- package/package.json +11 -13
- package/utils/api.d.ts +55 -0
- package/utils/api.js +44 -0
- package/utils/emotion-cache.d.ts +5 -0
- package/utils/emotion-cache.js +8 -0
- package/utils/index.d.ts +19 -0
- package/utils/index.js +27 -0
- package/utils/package.json +6 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } 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, NoJs } from "@koine/react";
|
|
5
|
+
import createEmotionServer from "@emotion/server/create-instance";
|
|
6
|
+
import { createEmotionCache } from "../../utils/emotion-cache";
|
|
7
|
+
/**
|
|
8
|
+
* Next Document wrapper for `emotion` based projects
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* in your `myapp/pages/_document.tsx`:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* export { Document as default } from "@koine/next/document/em";
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var Document = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Document, _super);
|
|
19
|
+
function Document() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
Document.prototype.render = function () {
|
|
23
|
+
var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
24
|
+
return (_jsxs(Html, __assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {}), this.props.emotionStyleTags] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] })));
|
|
25
|
+
};
|
|
26
|
+
return Document;
|
|
27
|
+
}(NextDocument));
|
|
28
|
+
export { Document };
|
|
29
|
+
// `getInitialProps` belongs to `_document` (instead of `_app`),
|
|
30
|
+
// it's compatible with static-site generation (SSG).
|
|
31
|
+
Document.getInitialProps = function (ctx) { return __awaiter(void 0, void 0, void 0, function () {
|
|
32
|
+
var originalRenderPage, cache, extractCriticalToChunks, initialProps, emotionStyles, emotionStyleTags;
|
|
33
|
+
return __generator(this, function (_a) {
|
|
34
|
+
switch (_a.label) {
|
|
35
|
+
case 0:
|
|
36
|
+
originalRenderPage = ctx.renderPage;
|
|
37
|
+
cache = createEmotionCache();
|
|
38
|
+
extractCriticalToChunks = createEmotionServer(cache).extractCriticalToChunks;
|
|
39
|
+
ctx.renderPage = function () {
|
|
40
|
+
return originalRenderPage({
|
|
41
|
+
enhanceApp: function (App) {
|
|
42
|
+
return function EnhanceApp(props) {
|
|
43
|
+
return _jsx(App, __assign({ emotionCache: cache }, props));
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return [4 /*yield*/, Document.getInitialProps(ctx)];
|
|
49
|
+
case 1:
|
|
50
|
+
initialProps = _a.sent();
|
|
51
|
+
emotionStyles = extractCriticalToChunks(initialProps.html);
|
|
52
|
+
emotionStyleTags = emotionStyles.styles.map(function (style) { return (_jsx("style", { "data-emotion": "".concat(style.key, " ").concat(style.ids.join(" ")),
|
|
53
|
+
// eslint-disable-next-line react/no-danger
|
|
54
|
+
dangerouslySetInnerHTML: { __html: style.css } }, style.key)); });
|
|
55
|
+
return [2 /*return*/, __assign(__assign({}, initialProps), { emotionStyleTags: emotionStyleTags })];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}); };
|
|
59
|
+
export default Document;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import NextDocument, { DocumentContext, DocumentInitialProps } from "next/document";
|
|
3
|
+
/**
|
|
4
|
+
* Next Document wrapper for `styled-components` based projects
|
|
5
|
+
*
|
|
6
|
+
* For typescript safety of this component
|
|
7
|
+
* @see https://bit.ly/3ceuF8m
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* in your `myapp/pages/_document.tsx`:
|
|
12
|
+
* ```tsx
|
|
13
|
+
* export { Document as default } from "@koine/next/document/sc";
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class Document extends NextDocument {
|
|
17
|
+
static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps>;
|
|
18
|
+
render(): JSX.Element;
|
|
19
|
+
}
|
|
20
|
+
export default Document;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
/* ? eslint-disable @next/next/no-document-import-in-page */
|
|
5
|
+
import NextDocument, { Html, Head, Main, NextScript, } from "next/document";
|
|
6
|
+
import { Meta, NoJs } from "@koine/react";
|
|
7
|
+
import { ServerStyleSheet } from "styled-components";
|
|
8
|
+
/**
|
|
9
|
+
* Next Document wrapper for `styled-components` based projects
|
|
10
|
+
*
|
|
11
|
+
* For typescript safety of this component
|
|
12
|
+
* @see https://bit.ly/3ceuF8m
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* in your `myapp/pages/_document.tsx`:
|
|
17
|
+
* ```tsx
|
|
18
|
+
* export { Document as default } from "@koine/next/document/sc";
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
var Document = /** @class */ (function (_super) {
|
|
22
|
+
__extends(Document, _super);
|
|
23
|
+
function Document() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
+
}
|
|
26
|
+
Document.getInitialProps = function (ctx) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
28
|
+
var sheet, originalRenderPage, initialProps;
|
|
29
|
+
return __generator(this, function (_a) {
|
|
30
|
+
switch (_a.label) {
|
|
31
|
+
case 0:
|
|
32
|
+
sheet = new ServerStyleSheet();
|
|
33
|
+
originalRenderPage = ctx.renderPage;
|
|
34
|
+
_a.label = 1;
|
|
35
|
+
case 1:
|
|
36
|
+
_a.trys.push([1, , 3, 4]);
|
|
37
|
+
ctx.renderPage = function () {
|
|
38
|
+
return originalRenderPage({
|
|
39
|
+
enhanceApp: function (App) { return function (props) {
|
|
40
|
+
return sheet.collectStyles(_jsx(App, __assign({}, props)));
|
|
41
|
+
}; },
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
return [4 /*yield*/, NextDocument.getInitialProps(ctx)];
|
|
45
|
+
case 2:
|
|
46
|
+
initialProps = _a.sent();
|
|
47
|
+
return [2 /*return*/, __assign(__assign({}, initialProps), {
|
|
48
|
+
// @ts-expect-error FIXME: have they changed type?
|
|
49
|
+
styles: (_jsxs(React.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })) })];
|
|
50
|
+
case 3:
|
|
51
|
+
sheet.seal();
|
|
52
|
+
return [7 /*endfinally*/];
|
|
53
|
+
case 4: return [2 /*return*/];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
Document.prototype.render = function () {
|
|
59
|
+
var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
60
|
+
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, {})] })] })));
|
|
61
|
+
};
|
|
62
|
+
return Document;
|
|
63
|
+
}(NextDocument));
|
|
64
|
+
export { Document };
|
|
65
|
+
export default Document;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./Analytics";
|
|
2
|
+
export * from "./Auth";
|
|
3
|
+
export * from "./Favicon";
|
|
4
|
+
export * from "./Forms";
|
|
5
|
+
export * from "./Head";
|
|
6
|
+
export * from "./I18n";
|
|
7
|
+
export * from "./Img";
|
|
8
|
+
export * from "./Link";
|
|
9
|
+
export * from "./NextProgress";
|
|
10
|
+
export * from "./Seo";
|
|
11
|
+
export * from "./Theme";
|
|
12
|
+
export * from "./utils";
|
package/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./Analytics";
|
|
2
|
+
export * from "./Auth";
|
|
3
|
+
export * from "./Favicon";
|
|
4
|
+
export * from "./Forms";
|
|
5
|
+
export * from "./Head";
|
|
6
|
+
export * from "./I18n";
|
|
7
|
+
export * from "./Img";
|
|
8
|
+
export * from "./Link";
|
|
9
|
+
export * from "./NextProgress";
|
|
10
|
+
export * from "./Seo";
|
|
11
|
+
export * from "./Theme";
|
|
12
|
+
export * from "./utils";
|
package/package.json
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koine/next",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "./node/index.js",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"react": "^16.8 || ^17 || ^18",
|
|
9
9
|
"next": "^12.1.6",
|
|
10
|
-
"
|
|
10
|
+
"@koine/utils": "1.0.13",
|
|
11
|
+
"framer-motion": "^6.3.4",
|
|
11
12
|
"styled-components": "^5.3.5",
|
|
12
|
-
"@mui/base": "^5.0.0-alpha.
|
|
13
|
+
"@mui/base": "^5.0.0-alpha.82",
|
|
13
14
|
"react-icons": "^4.3.1",
|
|
14
15
|
"date-fns": "^2.28.0",
|
|
15
16
|
"react-swipeable": "^7.0.0",
|
|
16
|
-
"@reach/disclosure": "^0.17.0",
|
|
17
17
|
"@tiptap/react": "^2.0.0-beta.109",
|
|
18
|
-
"@tiptap/starter-kit": "^2.0.0-beta.
|
|
18
|
+
"@tiptap/starter-kit": "^2.0.0-beta.185",
|
|
19
19
|
"yup": "^0.32.11",
|
|
20
|
-
"react-hook-form": "^7.
|
|
21
|
-
"type-fest": "^2.
|
|
22
|
-
"
|
|
23
|
-
"@reach/tabs": "^0.17.0",
|
|
20
|
+
"react-hook-form": "^7.31.2",
|
|
21
|
+
"type-fest": "^2.13.0",
|
|
22
|
+
"tslib": "^2.4.0",
|
|
24
23
|
"next-auth": "^4.3.4",
|
|
25
|
-
"@mui/material": "^5.
|
|
24
|
+
"@mui/material": "^5.8.1",
|
|
26
25
|
"@emotion/react": "^11.9.0",
|
|
27
26
|
"@emotion/server": "^11.4.0",
|
|
28
|
-
"@hookform/resolvers": "^2.8.
|
|
27
|
+
"@hookform/resolvers": "^2.8.10",
|
|
29
28
|
"next-translate": "^1.4.0",
|
|
30
|
-
"next-seo": "^5.4.0"
|
|
31
|
-
"tslib": "^2.4.0"
|
|
29
|
+
"next-seo": "^5.4.0"
|
|
32
30
|
},
|
|
33
31
|
"peerDependencies": {},
|
|
34
32
|
"module": "./index.js",
|
package/utils/api.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare type _Response = Response;
|
|
2
|
+
export declare namespace KoineApi {
|
|
3
|
+
type ResponseSuccesfull = unknown;
|
|
4
|
+
type ResponseFailed = unknown;
|
|
5
|
+
type ResponseShared<T extends Record<string, unknown> = {}> = T & {
|
|
6
|
+
status: _Response["status"];
|
|
7
|
+
msg: _Response["statusText"];
|
|
8
|
+
};
|
|
9
|
+
type Response<Succesfull extends ResponseSuccesfull = ResponseSuccesfull, Failed extends ResponseFailed = ResponseFailed> = {
|
|
10
|
+
status: _Response["status"];
|
|
11
|
+
msg: _Response["statusText"];
|
|
12
|
+
ok: true;
|
|
13
|
+
fail?: false;
|
|
14
|
+
data: Succesfull;
|
|
15
|
+
} | {
|
|
16
|
+
status: _Response["status"];
|
|
17
|
+
msg: _Response["statusText"];
|
|
18
|
+
ok?: false;
|
|
19
|
+
fail: true;
|
|
20
|
+
data: Failed;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Request options
|
|
24
|
+
*/
|
|
25
|
+
type RequestOptions<TJson = unknown> = {
|
|
26
|
+
/**
|
|
27
|
+
* JSON request body
|
|
28
|
+
*
|
|
29
|
+
* @default {}
|
|
30
|
+
*/
|
|
31
|
+
json?: TJson;
|
|
32
|
+
/**
|
|
33
|
+
* Params will be serialized into a string and appended to the URL
|
|
34
|
+
*/
|
|
35
|
+
params?: Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Headers will be merged with
|
|
38
|
+
* ```
|
|
39
|
+
* { "content-type": "application/json" }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
headers?: RequestInit["headers"];
|
|
43
|
+
/**
|
|
44
|
+
* Timeout in `ms`, if `falsy` there is no timeout
|
|
45
|
+
*
|
|
46
|
+
* @default 10000
|
|
47
|
+
*/
|
|
48
|
+
timeout?: number | false | null;
|
|
49
|
+
};
|
|
50
|
+
type RequestMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
51
|
+
type RequestFn = <Succesfull extends ResponseSuccesfull = unknown, Failed extends ResponseFailed = unknown>(endpoint: string, options?: RequestOptions) => Promise<Response<Succesfull, Failed>>;
|
|
52
|
+
type Client = Record<RequestMethod, RequestFn>;
|
|
53
|
+
}
|
|
54
|
+
export declare const api: KoineApi.Client;
|
|
55
|
+
export {};
|
package/utils/api.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
+
import { buildUrlQueryString } from "@koine/utils";
|
|
3
|
+
export var api = ["get", "post", "put", "patch", "delete"].reduce(function (api, method) {
|
|
4
|
+
api[method] = function (endpoint, options) {
|
|
5
|
+
if (options === void 0) { options = {}; }
|
|
6
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
7
|
+
var _a, json, params, _b, headers, _c, timeout, requestInit, timeoutNumber, controller, timeoutId, url, response, result;
|
|
8
|
+
return __generator(this, function (_d) {
|
|
9
|
+
switch (_d.label) {
|
|
10
|
+
case 0:
|
|
11
|
+
_a = options.json, json = _a === void 0 ? {} : _a, params = options.params, _b = options.headers, headers = _b === void 0 ? {} : _b, _c = options.timeout, timeout = _c === void 0 ? 10000 : _c;
|
|
12
|
+
requestInit = {
|
|
13
|
+
method: method.toUpperCase(),
|
|
14
|
+
headers: __assign({ "content-type": "application/json" }, headers),
|
|
15
|
+
};
|
|
16
|
+
timeoutNumber = Number(timeout);
|
|
17
|
+
url = "/api/".concat(endpoint.replace(/^\/*/, ""));
|
|
18
|
+
if (method !== "get") {
|
|
19
|
+
requestInit.body = JSON.stringify(json);
|
|
20
|
+
}
|
|
21
|
+
if (timeoutNumber > 0) {
|
|
22
|
+
controller = new AbortController();
|
|
23
|
+
timeoutId = setTimeout(function () { return controller.abort(); }, timeoutNumber);
|
|
24
|
+
requestInit.signal = controller.signal;
|
|
25
|
+
}
|
|
26
|
+
if (params) {
|
|
27
|
+
url += buildUrlQueryString(params);
|
|
28
|
+
}
|
|
29
|
+
return [4 /*yield*/, fetch(url, requestInit)];
|
|
30
|
+
case 1:
|
|
31
|
+
response = _d.sent();
|
|
32
|
+
if (timeoutId) {
|
|
33
|
+
clearTimeout(timeoutId);
|
|
34
|
+
}
|
|
35
|
+
return [4 /*yield*/, response.json()];
|
|
36
|
+
case 2:
|
|
37
|
+
result = (_d.sent());
|
|
38
|
+
return [2 /*return*/, result];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return api;
|
|
44
|
+
}, {});
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export declare const ONE_HOUR = 3600;
|
|
3
|
+
export declare const ONE_DAY = 84000;
|
|
4
|
+
/**
|
|
5
|
+
* Get site absolute url with the given path
|
|
6
|
+
*
|
|
7
|
+
* - It uses the `NEXT_PUBLIC_APP_URL` env variable
|
|
8
|
+
* - It removes the trailing slashes
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSiteUrl(path?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Utility to load a component with an optional pre-determined delay.
|
|
13
|
+
*
|
|
14
|
+
* This was designed to improve anti spam wit async form loading.
|
|
15
|
+
*
|
|
16
|
+
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
17
|
+
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
|
18
|
+
*/
|
|
19
|
+
export declare function load<T>(component: T, milliseconds: number): Promise<T>;
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { normaliseUrl } from "@koine/utils";
|
|
2
|
+
export * from "./api";
|
|
3
|
+
export var ONE_HOUR = 3600;
|
|
4
|
+
export var ONE_DAY = 84000;
|
|
5
|
+
/**
|
|
6
|
+
* Get site absolute url with the given path
|
|
7
|
+
*
|
|
8
|
+
* - It uses the `NEXT_PUBLIC_APP_URL` env variable
|
|
9
|
+
* - It removes the trailing slashes
|
|
10
|
+
*/
|
|
11
|
+
export function getSiteUrl(path) {
|
|
12
|
+
if (path === void 0) { path = ""; }
|
|
13
|
+
return normaliseUrl("".concat(process.env["NEXT_PUBLIC_APP_URL"], "/").concat(path));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Utility to load a component with an optional pre-determined delay.
|
|
17
|
+
*
|
|
18
|
+
* This was designed to improve anti spam wit async form loading.
|
|
19
|
+
*
|
|
20
|
+
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
21
|
+
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
|
22
|
+
*/
|
|
23
|
+
export function load(component, milliseconds) {
|
|
24
|
+
return new Promise(function (resolve) {
|
|
25
|
+
setTimeout(function () { return resolve(component); }, milliseconds);
|
|
26
|
+
});
|
|
27
|
+
}
|