@mui/material-nextjs 5.15.11 → 6.0.0-alpha.1
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/CHANGELOG.md +905 -169
- package/modern/v13-appRouter/appRouterV13.js +1 -2
- package/modern/v13-pagesRouter/pagesRouterV13Document.js +1 -2
- package/node/v13-appRouter/appRouterV13.js +1 -1
- package/node/v13-appRouter/index.js +1 -1
- package/node/v13-pagesRouter/pagesRouterV13App.js +1 -1
- package/node/v13-pagesRouter/pagesRouterV13Document.js +1 -1
- package/package.json +4 -4
- package/v13-appRouter/appRouterV13.js +5 -7
- package/v13-pagesRouter/createCache.js +1 -1
- package/v13-pagesRouter/pagesRouterV13Document.js +3 -5
- package/legacy/v13-appRouter/appRouterV13.js +0 -109
- package/legacy/v13-appRouter/index.js +0 -2
- package/legacy/v13-pagesRouter/createCache.js +0 -17
- package/legacy/v13-pagesRouter/index.js +0 -2
- package/legacy/v13-pagesRouter/pagesRouterV13App.js +0 -14
- package/legacy/v13-pagesRouter/pagesRouterV13Document.js +0 -165
- package/legacy/v14-appRouter/index.js +0 -1
- package/legacy/v14-pagesRouter/index.js +0 -1
|
@@ -5,8 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import createCache from '@emotion/cache';
|
|
6
6
|
import { CacheProvider as DefaultCacheProvider } from '@emotion/react';
|
|
7
7
|
import { useServerInsertedHTML } from 'next/navigation';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
9
|
/**
|
|
11
10
|
* Emotion works OK without this provider but it's recommended to use this provider to improve performance.
|
|
12
11
|
* Without it, Emotion will generate a new <style> tag during SSR for every component.
|
|
@@ -4,8 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import createEmotionServer from '@emotion/server/create-instance';
|
|
5
5
|
import Document from 'next/document';
|
|
6
6
|
import createEmotionCache from './createCache';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
8
|
/**
|
|
10
9
|
* A utility to compose multiple `getInitialProps` functions.
|
|
11
10
|
*/
|
|
@@ -13,7 +13,7 @@ var _react2 = require("@emotion/react");
|
|
|
13
13
|
var _navigation = require("next/navigation");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
/**
|
|
18
18
|
* Emotion works OK without this provider but it's recommended to use this provider to improve performance.
|
|
19
19
|
* Without it, Emotion will generate a new <style> tag during SSR for every component.
|
|
@@ -25,4 +25,4 @@ Object.keys(_appRouterV).forEach(function (key) {
|
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
28
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
28
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -10,7 +10,7 @@ var _react2 = require("@emotion/react");
|
|
|
10
10
|
var _createCache = _interopRequireDefault(require("./createCache"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
const defaultEmotionCache = (0, _createCache.default)();
|
|
15
15
|
function AppCacheProvider({
|
|
16
16
|
emotionCache = defaultEmotionCache,
|
|
@@ -15,7 +15,7 @@ var _createCache = _interopRequireDefault(require("./createCache"));
|
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
var _meta;
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
/**
|
|
20
20
|
* A utility to compose multiple `getInitialProps` functions.
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/material-nextjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "Collection of utilities for integration between Material UI and Next.js.",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"url": "https://opencollective.com/mui-org"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@babel/runtime": "^7.
|
|
27
|
+
"@babel/runtime": "^7.24.5"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@emotion/cache": "^11.11.0",
|
|
31
31
|
"@emotion/server": "^11.11.0",
|
|
32
|
-
"@mui/material": "^5.0.0",
|
|
33
32
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
34
33
|
"next": "^13.0.0 || ^14.0.0",
|
|
35
|
-
"react": "^17.0.0 || ^18.0.0"
|
|
34
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
35
|
+
"@mui/material": "^6.0.0-alpha.7"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@types/react": {
|
|
@@ -5,8 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import createCache from '@emotion/cache';
|
|
6
6
|
import { CacheProvider as DefaultCacheProvider } from '@emotion/react';
|
|
7
7
|
import { useServerInsertedHTML } from 'next/navigation';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
9
|
/**
|
|
11
10
|
* Emotion works OK without this provider but it's recommended to use this provider to improve performance.
|
|
12
11
|
* Without it, Emotion will generate a new <style> tag during SSR for every component.
|
|
@@ -19,16 +18,15 @@ export default function AppRouterCacheProvider(props) {
|
|
|
19
18
|
children
|
|
20
19
|
} = props;
|
|
21
20
|
const [registry] = React.useState(() => {
|
|
22
|
-
var _options$key;
|
|
23
21
|
const cache = createCache(_extends({}, options, {
|
|
24
|
-
key:
|
|
22
|
+
key: options?.key ?? 'mui'
|
|
25
23
|
}));
|
|
26
24
|
cache.compat = true;
|
|
27
25
|
const prevInsert = cache.insert;
|
|
28
26
|
let inserted = [];
|
|
29
27
|
// Override the insert method to support streaming SSR with flush().
|
|
30
28
|
cache.insert = (...args) => {
|
|
31
|
-
if (options
|
|
29
|
+
if (options?.enableCssLayer) {
|
|
32
30
|
args[1].styles = `@layer mui {${args[1].styles}}`;
|
|
33
31
|
}
|
|
34
32
|
const [selector, serialized] = args;
|
|
@@ -80,7 +78,7 @@ export default function AppRouterCacheProvider(props) {
|
|
|
80
78
|
name,
|
|
81
79
|
style
|
|
82
80
|
}) => /*#__PURE__*/_jsx("style", {
|
|
83
|
-
nonce: options
|
|
81
|
+
nonce: options?.nonce,
|
|
84
82
|
"data-emotion": `${registry.cache.key}-global ${name}`
|
|
85
83
|
// eslint-disable-next-line react/no-danger
|
|
86
84
|
,
|
|
@@ -88,7 +86,7 @@ export default function AppRouterCacheProvider(props) {
|
|
|
88
86
|
__html: style
|
|
89
87
|
}
|
|
90
88
|
}, name)), styles && /*#__PURE__*/_jsx("style", {
|
|
91
|
-
nonce: options
|
|
89
|
+
nonce: options?.nonce,
|
|
92
90
|
"data-emotion": dataEmotionAttribute
|
|
93
91
|
// eslint-disable-next-line react/no-danger
|
|
94
92
|
,
|
|
@@ -8,7 +8,7 @@ export default function createEmotionCache() {
|
|
|
8
8
|
let insertionPoint;
|
|
9
9
|
if (isBrowser) {
|
|
10
10
|
const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
|
|
11
|
-
insertionPoint = emotionInsertionPoint
|
|
11
|
+
insertionPoint = emotionInsertionPoint ?? undefined;
|
|
12
12
|
}
|
|
13
13
|
return createCache({
|
|
14
14
|
key: 'mui',
|
|
@@ -4,8 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import createEmotionServer from '@emotion/server/create-instance';
|
|
5
5
|
import Document from 'next/document';
|
|
6
6
|
import createEmotionCache from './createCache';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
8
|
/**
|
|
10
9
|
* A utility to compose multiple `getInitialProps` functions.
|
|
11
10
|
*/
|
|
@@ -32,7 +31,6 @@ export function DocumentHeadTags(props) {
|
|
|
32
31
|
// `getInitialProps` belongs to `_document` (instead of `_app`),
|
|
33
32
|
// it's compatible with static-site generation (SSG).
|
|
34
33
|
export async function documentGetInitialProps(ctx, options) {
|
|
35
|
-
var _options$emotionCache, _options$plugins;
|
|
36
34
|
// Resolution order
|
|
37
35
|
//
|
|
38
36
|
// On the server:
|
|
@@ -57,7 +55,7 @@ export async function documentGetInitialProps(ctx, options) {
|
|
|
57
55
|
|
|
58
56
|
// You can consider sharing the same Emotion cache between all the SSR requests to speed up performance.
|
|
59
57
|
// However, be aware that it can have global side effects.
|
|
60
|
-
const cache =
|
|
58
|
+
const cache = options?.emotionCache ?? createEmotionCache();
|
|
61
59
|
// The createEmotionServer has to be called directly after the cache creation due to the side effect of cache.compat = true,
|
|
62
60
|
// otherwise the <style> tag will not come with the HTML string from the server.
|
|
63
61
|
const {
|
|
@@ -83,5 +81,5 @@ export async function documentGetInitialProps(ctx, options) {
|
|
|
83
81
|
}, style.key))
|
|
84
82
|
});
|
|
85
83
|
}
|
|
86
|
-
}, ...(
|
|
84
|
+
}, ...(options?.plugins ?? [])])(ctx);
|
|
87
85
|
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import createCache from '@emotion/cache';
|
|
6
|
-
import { CacheProvider as DefaultCacheProvider } from '@emotion/react';
|
|
7
|
-
import { useServerInsertedHTML } from 'next/navigation';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
/**
|
|
11
|
-
* Emotion works OK without this provider but it's recommended to use this provider to improve performance.
|
|
12
|
-
* Without it, Emotion will generate a new <style> tag during SSR for every component.
|
|
13
|
-
* See https://github.com/mui/material-ui/issues/26561#issuecomment-855286153 for why it's a problem.
|
|
14
|
-
*/
|
|
15
|
-
export default function AppRouterCacheProvider(props) {
|
|
16
|
-
var options = props.options,
|
|
17
|
-
_props$CacheProvider = props.CacheProvider,
|
|
18
|
-
CacheProvider = _props$CacheProvider === void 0 ? DefaultCacheProvider : _props$CacheProvider,
|
|
19
|
-
children = props.children;
|
|
20
|
-
var _React$useState = React.useState(function () {
|
|
21
|
-
var _options$key;
|
|
22
|
-
var cache = createCache(_extends({}, options, {
|
|
23
|
-
key: (_options$key = options == null ? void 0 : options.key) != null ? _options$key : 'mui'
|
|
24
|
-
}));
|
|
25
|
-
cache.compat = true;
|
|
26
|
-
var prevInsert = cache.insert;
|
|
27
|
-
var inserted = [];
|
|
28
|
-
// Override the insert method to support streaming SSR with flush().
|
|
29
|
-
cache.insert = function () {
|
|
30
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
-
args[_key] = arguments[_key];
|
|
32
|
-
}
|
|
33
|
-
if (options != null && options.enableCssLayer) {
|
|
34
|
-
args[1].styles = "@layer mui {".concat(args[1].styles, "}");
|
|
35
|
-
}
|
|
36
|
-
var selector = args[0],
|
|
37
|
-
serialized = args[1];
|
|
38
|
-
if (cache.inserted[serialized.name] === undefined) {
|
|
39
|
-
inserted.push({
|
|
40
|
-
name: serialized.name,
|
|
41
|
-
isGlobal: !selector
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return prevInsert.apply(void 0, args);
|
|
45
|
-
};
|
|
46
|
-
var flush = function flush() {
|
|
47
|
-
var prevInserted = inserted;
|
|
48
|
-
inserted = [];
|
|
49
|
-
return prevInserted;
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
cache: cache,
|
|
53
|
-
flush: flush
|
|
54
|
-
};
|
|
55
|
-
}),
|
|
56
|
-
registry = _React$useState[0];
|
|
57
|
-
useServerInsertedHTML(function () {
|
|
58
|
-
var inserted = registry.flush();
|
|
59
|
-
if (inserted.length === 0) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
var styles = '';
|
|
63
|
-
var dataEmotionAttribute = registry.cache.key;
|
|
64
|
-
var globals = [];
|
|
65
|
-
inserted.forEach(function (_ref) {
|
|
66
|
-
var name = _ref.name,
|
|
67
|
-
isGlobal = _ref.isGlobal;
|
|
68
|
-
var style = registry.cache.inserted[name];
|
|
69
|
-
if (typeof style !== 'boolean') {
|
|
70
|
-
if (isGlobal) {
|
|
71
|
-
globals.push({
|
|
72
|
-
name: name,
|
|
73
|
-
style: style
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
styles += style;
|
|
77
|
-
dataEmotionAttribute += " ".concat(name);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
82
|
-
children: [globals.map(function (_ref2) {
|
|
83
|
-
var name = _ref2.name,
|
|
84
|
-
style = _ref2.style;
|
|
85
|
-
return /*#__PURE__*/_jsx("style", {
|
|
86
|
-
nonce: options == null ? void 0 : options.nonce,
|
|
87
|
-
"data-emotion": "".concat(registry.cache.key, "-global ").concat(name)
|
|
88
|
-
// eslint-disable-next-line react/no-danger
|
|
89
|
-
,
|
|
90
|
-
dangerouslySetInnerHTML: {
|
|
91
|
-
__html: style
|
|
92
|
-
}
|
|
93
|
-
}, name);
|
|
94
|
-
}), styles && /*#__PURE__*/_jsx("style", {
|
|
95
|
-
nonce: options == null ? void 0 : options.nonce,
|
|
96
|
-
"data-emotion": dataEmotionAttribute
|
|
97
|
-
// eslint-disable-next-line react/no-danger
|
|
98
|
-
,
|
|
99
|
-
dangerouslySetInnerHTML: {
|
|
100
|
-
__html: styles
|
|
101
|
-
}
|
|
102
|
-
})]
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
return /*#__PURE__*/_jsx(CacheProvider, {
|
|
106
|
-
value: registry.cache,
|
|
107
|
-
children: children
|
|
108
|
-
});
|
|
109
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import createCache from '@emotion/cache';
|
|
2
|
-
var isBrowser = typeof document !== 'undefined';
|
|
3
|
-
|
|
4
|
-
// On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint.
|
|
5
|
-
// This assures that MUI styles are loaded first.
|
|
6
|
-
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
|
|
7
|
-
export default function createEmotionCache() {
|
|
8
|
-
var insertionPoint;
|
|
9
|
-
if (isBrowser) {
|
|
10
|
-
var emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
|
|
11
|
-
insertionPoint = emotionInsertionPoint != null ? emotionInsertionPoint : undefined;
|
|
12
|
-
}
|
|
13
|
-
return createCache({
|
|
14
|
-
key: 'mui',
|
|
15
|
-
insertionPoint: insertionPoint
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { CacheProvider } from '@emotion/react';
|
|
3
|
-
import createEmotionCache from './createCache';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
var defaultEmotionCache = createEmotionCache();
|
|
6
|
-
export function AppCacheProvider(_ref) {
|
|
7
|
-
var _ref$emotionCache = _ref.emotionCache,
|
|
8
|
-
emotionCache = _ref$emotionCache === void 0 ? defaultEmotionCache : _ref$emotionCache,
|
|
9
|
-
children = _ref.children;
|
|
10
|
-
return /*#__PURE__*/_jsx(CacheProvider, {
|
|
11
|
-
value: emotionCache,
|
|
12
|
-
children: children
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
var _meta;
|
|
5
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
import createEmotionServer from '@emotion/server/create-instance';
|
|
8
|
-
import Document from 'next/document';
|
|
9
|
-
import createEmotionCache from './createCache';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
/**
|
|
13
|
-
* A utility to compose multiple `getInitialProps` functions.
|
|
14
|
-
*/
|
|
15
|
-
export function createGetInitialProps(plugins) {
|
|
16
|
-
return /*#__PURE__*/function () {
|
|
17
|
-
var _getInitialProps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ctx) {
|
|
18
|
-
var originalRenderPage, initialProps, finalProps;
|
|
19
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
20
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
21
|
-
case 0:
|
|
22
|
-
originalRenderPage = ctx.renderPage;
|
|
23
|
-
ctx.renderPage = function () {
|
|
24
|
-
return originalRenderPage({
|
|
25
|
-
enhanceApp: function enhanceApp(App) {
|
|
26
|
-
return plugins.reduce(function (result, plugin) {
|
|
27
|
-
return plugin.enhanceApp(result);
|
|
28
|
-
}, App);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
_context2.next = 4;
|
|
33
|
-
return Document.getInitialProps(ctx);
|
|
34
|
-
case 4:
|
|
35
|
-
initialProps = _context2.sent;
|
|
36
|
-
_context2.next = 7;
|
|
37
|
-
return plugins.reduce( /*#__PURE__*/function () {
|
|
38
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(result, plugin) {
|
|
39
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
40
|
-
while (1) switch (_context.prev = _context.next) {
|
|
41
|
-
case 0:
|
|
42
|
-
_context.t0 = plugin;
|
|
43
|
-
_context.next = 3;
|
|
44
|
-
return result;
|
|
45
|
-
case 3:
|
|
46
|
-
_context.t1 = _context.sent;
|
|
47
|
-
return _context.abrupt("return", _context.t0.resolveProps.call(_context.t0, _context.t1));
|
|
48
|
-
case 5:
|
|
49
|
-
case "end":
|
|
50
|
-
return _context.stop();
|
|
51
|
-
}
|
|
52
|
-
}, _callee);
|
|
53
|
-
}));
|
|
54
|
-
return function (_x2, _x3) {
|
|
55
|
-
return _ref.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
}(), Promise.resolve(initialProps));
|
|
58
|
-
case 7:
|
|
59
|
-
finalProps = _context2.sent;
|
|
60
|
-
return _context2.abrupt("return", finalProps);
|
|
61
|
-
case 9:
|
|
62
|
-
case "end":
|
|
63
|
-
return _context2.stop();
|
|
64
|
-
}
|
|
65
|
-
}, _callee2);
|
|
66
|
-
}));
|
|
67
|
-
function getInitialProps(_x) {
|
|
68
|
-
return _getInitialProps.apply(this, arguments);
|
|
69
|
-
}
|
|
70
|
-
return getInitialProps;
|
|
71
|
-
}();
|
|
72
|
-
}
|
|
73
|
-
export function DocumentHeadTags(props) {
|
|
74
|
-
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
75
|
-
children: [_meta || (_meta = /*#__PURE__*/_jsx("meta", {
|
|
76
|
-
name: "emotion-insertion-point",
|
|
77
|
-
content: ""
|
|
78
|
-
})), props.emotionStyleTags]
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// `getInitialProps` belongs to `_document` (instead of `_app`),
|
|
83
|
-
// it's compatible with static-site generation (SSG).
|
|
84
|
-
export function documentGetInitialProps(_x4, _x5) {
|
|
85
|
-
return _documentGetInitialProps.apply(this, arguments);
|
|
86
|
-
}
|
|
87
|
-
function _documentGetInitialProps() {
|
|
88
|
-
_documentGetInitialProps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(ctx, options) {
|
|
89
|
-
var _options$emotionCache, _options$plugins;
|
|
90
|
-
var cache, _createEmotionServer, extractCriticalToChunks;
|
|
91
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
92
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
// Resolution order
|
|
95
|
-
//
|
|
96
|
-
// On the server:
|
|
97
|
-
// 1. app.getInitialProps
|
|
98
|
-
// 2. page.getInitialProps
|
|
99
|
-
// 3. document.getInitialProps
|
|
100
|
-
// 4. app.render
|
|
101
|
-
// 5. page.render
|
|
102
|
-
// 6. document.render
|
|
103
|
-
//
|
|
104
|
-
// On the server with error:
|
|
105
|
-
// 1. document.getInitialProps
|
|
106
|
-
// 2. app.render
|
|
107
|
-
// 3. page.render
|
|
108
|
-
// 4. document.render
|
|
109
|
-
//
|
|
110
|
-
// On the client
|
|
111
|
-
// 1. app.getInitialProps
|
|
112
|
-
// 2. page.getInitialProps
|
|
113
|
-
// 3. app.render
|
|
114
|
-
// 4. page.render
|
|
115
|
-
// You can consider sharing the same Emotion cache between all the SSR requests to speed up performance.
|
|
116
|
-
// However, be aware that it can have global side effects.
|
|
117
|
-
cache = (_options$emotionCache = options == null ? void 0 : options.emotionCache) != null ? _options$emotionCache : createEmotionCache(); // The createEmotionServer has to be called directly after the cache creation due to the side effect of cache.compat = true,
|
|
118
|
-
// otherwise the <style> tag will not come with the HTML string from the server.
|
|
119
|
-
_createEmotionServer = createEmotionServer(cache), extractCriticalToChunks = _createEmotionServer.extractCriticalToChunks;
|
|
120
|
-
return _context4.abrupt("return", createGetInitialProps([{
|
|
121
|
-
enhanceApp: function enhanceApp(App) {
|
|
122
|
-
return function EnhanceApp(props) {
|
|
123
|
-
return /*#__PURE__*/_jsx(App, _extends({
|
|
124
|
-
emotionCache: cache
|
|
125
|
-
}, props));
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
resolveProps: function () {
|
|
129
|
-
var _resolveProps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(initialProps) {
|
|
130
|
-
var _extractCriticalToChu, styles;
|
|
131
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
132
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
_extractCriticalToChu = extractCriticalToChunks(initialProps.html), styles = _extractCriticalToChu.styles;
|
|
135
|
-
return _context3.abrupt("return", _extends({}, initialProps, {
|
|
136
|
-
emotionStyleTags: styles.map(function (style) {
|
|
137
|
-
return /*#__PURE__*/_jsx("style", {
|
|
138
|
-
"data-emotion": "".concat(style.key, " ").concat(style.ids.join(' ')),
|
|
139
|
-
// eslint-disable-next-line react/no-danger
|
|
140
|
-
dangerouslySetInnerHTML: {
|
|
141
|
-
__html: style.css
|
|
142
|
-
}
|
|
143
|
-
}, style.key);
|
|
144
|
-
})
|
|
145
|
-
}));
|
|
146
|
-
case 2:
|
|
147
|
-
case "end":
|
|
148
|
-
return _context3.stop();
|
|
149
|
-
}
|
|
150
|
-
}, _callee3);
|
|
151
|
-
}));
|
|
152
|
-
function resolveProps(_x6) {
|
|
153
|
-
return _resolveProps.apply(this, arguments);
|
|
154
|
-
}
|
|
155
|
-
return resolveProps;
|
|
156
|
-
}()
|
|
157
|
-
}].concat(_toConsumableArray((_options$plugins = options == null ? void 0 : options.plugins) != null ? _options$plugins : [])))(ctx));
|
|
158
|
-
case 3:
|
|
159
|
-
case "end":
|
|
160
|
-
return _context4.stop();
|
|
161
|
-
}
|
|
162
|
-
}, _callee4);
|
|
163
|
-
}));
|
|
164
|
-
return _documentGetInitialProps.apply(this, arguments);
|
|
165
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../v13-appRouter';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../v13-pagesRouter';
|