@blaze-cms/nextjs-tools 0.127.0 → 0.128.0-admin-updates.0
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 +8 -0
- package/lib/application/query/index.js +4 -4
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/DebugSidebar/index.js.map +1 -1
- package/lib/helpers/check-url.js +143 -151
- package/lib/helpers/check-url.js.map +1 -1
- package/lib/helpers/get-entitys-actions.js +6 -6
- package/lib/helpers/get-entitys-actions.js.map +1 -1
- package/lib/helpers/get-page-data.js +34 -36
- package/lib/helpers/get-page-data.js.map +1 -1
- package/lib/helpers/handle-static-routes.js +1 -1
- package/lib/helpers/static-route-handlers/generic-file-handler.js +42 -46
- package/lib/helpers/static-route-handlers/generic-file-handler.js.map +1 -1
- package/lib/hoc/withBlaze.js +90 -94
- package/lib/hoc/withBlaze.js.map +1 -1
- package/lib/pages/Resolver.js +6 -8
- package/lib/pages/Resolver.js.map +1 -1
- package/lib/server/index.js +15 -17
- package/lib/server/index.js.map +1 -1
- package/lib-es/components/DebugSidebar/index.js.map +1 -1
- package/package.json +16 -16
- package/tests/unit/src/components/DebugSidebar/DebugSidebar.test.js +4 -1
- package/tests/unit/src/containers/ContentContainer.test.js +4 -1
- package/tests/unit/src/helpers/build-admin-href.test.js +1 -1
- package/tests/unit/src/helpers/check-for-gtm.test.js +1 -1
- package/tests/unit/src/helpers/check-parent.test.js +1 -1
- package/tests/unit/src/helpers/check-url.test.js +1 -1
- package/tests/unit/src/helpers/get-entitys-actions.test.js +1 -1
- package/tests/unit/src/helpers/get-error-message.test.js +1 -1
- package/tests/unit/src/helpers/get-page-data.test.js +1 -1
- package/tests/unit/src/helpers/get-search-filter.test.js +1 -1
- package/tests/unit/src/helpers/render-apple-tags.test.js +1 -1
- package/tests/unit/src/helpers/set-blaze-debug.test.js +4 -1
- package/tests/unit/src/hoc/withBlaze.test.js +4 -1
- package/tests/unit/src/pages/Resolver.test.js +4 -1
|
@@ -18,53 +18,49 @@ var _constants = require("../../constants");
|
|
|
18
18
|
var getHandler = function getHandler(fileQuery, getVariables) {
|
|
19
19
|
return /*#__PURE__*/function () {
|
|
20
20
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(props) {
|
|
21
|
-
var res, apolloClient, variables, _yield$apolloClient$q, _yield$apolloClient$q2, files, _files, _files$, mimetype, url, fileResponse;
|
|
21
|
+
var res, apolloClient, variables, _yield$apolloClient$q, _yield$apolloClient$q2, files, _files, _files$, _files$2, mimetype, url, fileResponse;
|
|
22
22
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
23
|
-
while (1) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
case 26:
|
|
65
|
-
case "end":
|
|
66
|
-
return _context.stop();
|
|
67
|
-
}
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
res = props.res, apolloClient = props.apolloClient;
|
|
26
|
+
variables = getVariables ? getVariables(props) : {};
|
|
27
|
+
_context.next = 4;
|
|
28
|
+
return apolloClient.query({
|
|
29
|
+
query: fileQuery,
|
|
30
|
+
variables: variables
|
|
31
|
+
});
|
|
32
|
+
case 4:
|
|
33
|
+
_yield$apolloClient$q = _context.sent;
|
|
34
|
+
_yield$apolloClient$q2 = _yield$apolloClient$q.data.files;
|
|
35
|
+
files = _yield$apolloClient$q2 === void 0 ? [] : _yield$apolloClient$q2;
|
|
36
|
+
_files = (0, _slicedToArray2["default"])(files, 1), _files$ = _files[0], _files$2 = _files$ === void 0 ? {} : _files$, mimetype = _files$2.mimetype, url = _files$2.url;
|
|
37
|
+
if (url) {
|
|
38
|
+
_context.next = 13;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
res.writeHead(404);
|
|
42
|
+
res.write(_constants.RESPONSE_404);
|
|
43
|
+
res.end();
|
|
44
|
+
return _context.abrupt("return");
|
|
45
|
+
case 13:
|
|
46
|
+
_context.next = 15;
|
|
47
|
+
return fetch(url);
|
|
48
|
+
case 15:
|
|
49
|
+
fileResponse = _context.sent;
|
|
50
|
+
setHeadersFromResponse(fileResponse.headers, res);
|
|
51
|
+
res.writeHead(200, {
|
|
52
|
+
'Content-Type': mimetype
|
|
53
|
+
});
|
|
54
|
+
_context.t0 = res;
|
|
55
|
+
_context.next = 21;
|
|
56
|
+
return fileResponse.text();
|
|
57
|
+
case 21:
|
|
58
|
+
_context.t1 = _context.sent;
|
|
59
|
+
_context.t0.write.call(_context.t0, _context.t1);
|
|
60
|
+
res.end();
|
|
61
|
+
case 24:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
68
64
|
}
|
|
69
65
|
}, _callee);
|
|
70
66
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-file-handler.js","names":["getHandler","fileQuery","getVariables","props","res","apolloClient","variables","query","data","files","mimetype","url","writeHead","write","RESPONSE_404","end","fetch","fileResponse","setHeadersFromResponse","headers","text","STATIC_FILE_FORWARD_HEADERS","forEach","headerKey","headerValue","get","setHeader"],"sources":["../../../src/helpers/static-route-handlers/generic-file-handler.js"],"sourcesContent":["import 'cross-fetch/polyfill';\nimport { RESPONSE_404, STATIC_FILE_FORWARD_HEADERS } from '../../constants';\n\nconst getHandler = (fileQuery, getVariables) => async props => {\n const { res, apolloClient } = props;\n const variables = getVariables ? getVariables(props) : {};\n const {\n data: { files = [] }\n } = await apolloClient.query({ query: fileQuery, variables });\n const [{ mimetype, url } = {}] = files;\n if (!url) {\n res.writeHead(404);\n res.write(RESPONSE_404);\n res.end();\n return;\n }\n\n const fileResponse = await fetch(url);\n\n setHeadersFromResponse(fileResponse.headers, res);\n res.writeHead(200, { 'Content-Type': mimetype });\n res.write(await fileResponse.text());\n res.end();\n};\n\nfunction setHeadersFromResponse(headers, res) {\n STATIC_FILE_FORWARD_HEADERS.forEach(headerKey => {\n const headerValue = headers.get(headerKey);\n if (!headerValue) return;\n\n res.setHeader(headerKey, headerValue);\n });\n}\n\nexport default getHandler;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAU,CAAIC,SAAS,EAAEC,YAAY;EAAA;IAAA,yFAAK,iBAAMC,KAAK;MAAA;MAAA;QAAA;UAAA;
|
|
1
|
+
{"version":3,"file":"generic-file-handler.js","names":["getHandler","fileQuery","getVariables","props","res","apolloClient","variables","query","data","files","mimetype","url","writeHead","write","RESPONSE_404","end","fetch","fileResponse","setHeadersFromResponse","headers","text","STATIC_FILE_FORWARD_HEADERS","forEach","headerKey","headerValue","get","setHeader"],"sources":["../../../src/helpers/static-route-handlers/generic-file-handler.js"],"sourcesContent":["import 'cross-fetch/polyfill';\nimport { RESPONSE_404, STATIC_FILE_FORWARD_HEADERS } from '../../constants';\n\nconst getHandler = (fileQuery, getVariables) => async props => {\n const { res, apolloClient } = props;\n const variables = getVariables ? getVariables(props) : {};\n const {\n data: { files = [] }\n } = await apolloClient.query({ query: fileQuery, variables });\n const [{ mimetype, url } = {}] = files;\n if (!url) {\n res.writeHead(404);\n res.write(RESPONSE_404);\n res.end();\n return;\n }\n\n const fileResponse = await fetch(url);\n\n setHeadersFromResponse(fileResponse.headers, res);\n res.writeHead(200, { 'Content-Type': mimetype });\n res.write(await fileResponse.text());\n res.end();\n};\n\nfunction setHeadersFromResponse(headers, res) {\n STATIC_FILE_FORWARD_HEADERS.forEach(headerKey => {\n const headerValue = headers.get(headerKey);\n if (!headerValue) return;\n\n res.setHeader(headerKey, headerValue);\n });\n}\n\nexport default getHandler;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAU,CAAIC,SAAS,EAAEC,YAAY;EAAA;IAAA,yFAAK,iBAAMC,KAAK;MAAA;MAAA;QAAA;UAAA;YACjDC,GAAG,GAAmBD,KAAK,CAA3BC,GAAG,EAAEC,YAAY,GAAKF,KAAK,CAAtBE,YAAY;YACnBC,SAAS,GAAGJ,YAAY,GAAGA,YAAY,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC;YAAA;YAAA,OAG/CE,YAAY,CAACE,KAAK,CAAC;cAAEA,KAAK,EAAEN,SAAS;cAAEK,SAAS,EAATA;YAAU,CAAC,CAAC;UAAA;YAAA;YAAA,+CAD3DE,IAAI,CAAIC,KAAK;YAALA,KAAK,uCAAG,EAAE;YAAA,yCAEaA,KAAK,2DAAX,CAAC,CAAC,YAApBC,QAAQ,YAARA,QAAQ,EAAEC,GAAG,YAAHA,GAAG;YAAA,IACjBA,GAAG;cAAA;cAAA;YAAA;YACNP,GAAG,CAACQ,SAAS,CAAC,GAAG,CAAC;YAClBR,GAAG,CAACS,KAAK,CAACC,uBAAY,CAAC;YACvBV,GAAG,CAACW,GAAG,EAAE;YAAC;UAAA;YAAA;YAAA,OAIeC,KAAK,CAACL,GAAG,CAAC;UAAA;YAA/BM,YAAY;YAElBC,sBAAsB,CAACD,YAAY,CAACE,OAAO,EAAEf,GAAG,CAAC;YACjDA,GAAG,CAACQ,SAAS,CAAC,GAAG,EAAE;cAAE,cAAc,EAAEF;YAAS,CAAC,CAAC;YAAC,cACjDN,GAAG;YAAA;YAAA,OAAaa,YAAY,CAACG,IAAI,EAAE;UAAA;YAAA;YAAA,YAA/BP,KAAK;YACTT,GAAG,CAACW,GAAG,EAAE;UAAC;UAAA;YAAA;QAAA;MAAA;IAAA,CACX;IAAA;MAAA;IAAA;EAAA;AAAA;AAED,SAASG,sBAAsB,CAACC,OAAO,EAAEf,GAAG,EAAE;EAC5CiB,sCAA2B,CAACC,OAAO,CAAC,UAAAC,SAAS,EAAI;IAC/C,IAAMC,WAAW,GAAGL,OAAO,CAACM,GAAG,CAACF,SAAS,CAAC;IAC1C,IAAI,CAACC,WAAW,EAAE;IAElBpB,GAAG,CAACsB,SAAS,CAACH,SAAS,EAAEC,WAAW,CAAC;EACvC,CAAC,CAAC;AACJ;AAAC,eAEcxB,UAAU;AAAA"}
|
package/lib/hoc/withBlaze.js
CHANGED
|
@@ -82,25 +82,23 @@ function getWrappedApp(isSsr, config, blazeApp, App) {
|
|
|
82
82
|
value: function () {
|
|
83
83
|
var _componentDidMount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
84
84
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
85
|
-
while (1) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return _context.stop();
|
|
103
|
-
}
|
|
85
|
+
while (1) switch (_context.prev = _context.next) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!blazeApp.initComplete()) {
|
|
88
|
+
_context.next = 2;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return _context.abrupt("return");
|
|
92
|
+
case 2:
|
|
93
|
+
_context.next = 4;
|
|
94
|
+
return blazeApp.init();
|
|
95
|
+
case 4:
|
|
96
|
+
this.setState({
|
|
97
|
+
appLoaded: blazeApp.initComplete()
|
|
98
|
+
});
|
|
99
|
+
case 5:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context.stop();
|
|
104
102
|
}
|
|
105
103
|
}, _callee, this);
|
|
106
104
|
}));
|
|
@@ -138,82 +136,80 @@ function getWrappedApp(isSsr, config, blazeApp, App) {
|
|
|
138
136
|
var _getInitialProps = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(context) {
|
|
139
137
|
var _Component, router, AppTree, ctx, appProps, errorProps, requestApp, apolloClient, _appProps, _appProps$pageProps, pageProps, mainProps, apolloState, sortedState;
|
|
140
138
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
141
|
-
while (1) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
_context2.next = 24;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
return _context2.abrupt("return", mainProps);
|
|
182
|
-
case 24:
|
|
183
|
-
_context2.prev = 24;
|
|
184
|
-
_context2.next = 27;
|
|
185
|
-
return (0, _ssr.getDataFromTree)( /*#__PURE__*/_react["default"].createElement(AppTree, (0, _extends2["default"])({}, appProps, {
|
|
186
|
-
Component: _Component,
|
|
187
|
-
router: router,
|
|
188
|
-
apolloClient: apolloClient
|
|
189
|
-
})));
|
|
190
|
-
case 27:
|
|
191
|
-
_context2.next = 35;
|
|
139
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
_Component = context.Component, router = context.router, AppTree = context.AppTree, ctx = context.ctx;
|
|
142
|
+
appProps = {};
|
|
143
|
+
errorProps = {};
|
|
144
|
+
requestApp = ctx.blazeApp;
|
|
145
|
+
requestApp = getRequestApp(requestApp);
|
|
146
|
+
requestApp.ctx.router = router;
|
|
147
|
+
requestApp.ctx.req = ctx.req;
|
|
148
|
+
requestApp.ctx.res = ctx.res;
|
|
149
|
+
_context2.next = 10;
|
|
150
|
+
return blazeApp.init();
|
|
151
|
+
case 10:
|
|
152
|
+
_context2.next = 12;
|
|
153
|
+
return requestApp.init();
|
|
154
|
+
case 12:
|
|
155
|
+
apolloClient = getApolloClient(ctx, requestApp);
|
|
156
|
+
ctx.apolloClient = apolloClient;
|
|
157
|
+
ctx.blazeApp = requestApp;
|
|
158
|
+
requestApp.events.emit('page-load:get-initial-props:before', {
|
|
159
|
+
ctx: ctx
|
|
160
|
+
});
|
|
161
|
+
if (!App.getInitialProps) {
|
|
162
|
+
_context2.next = 20;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
_context2.next = 19;
|
|
166
|
+
return App.getInitialProps(context);
|
|
167
|
+
case 19:
|
|
168
|
+
appProps = _context2.sent;
|
|
169
|
+
case 20:
|
|
170
|
+
_appProps = appProps, _appProps$pageProps = _appProps.pageProps, pageProps = _appProps$pageProps === void 0 ? {} : _appProps$pageProps;
|
|
171
|
+
mainProps = _objectSpread(_objectSpread({}, appProps), {}, {
|
|
172
|
+
pageProps: _objectSpread(_objectSpread({}, pageProps), errorProps)
|
|
173
|
+
});
|
|
174
|
+
if (isSsr) {
|
|
175
|
+
_context2.next = 24;
|
|
192
176
|
break;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
177
|
+
}
|
|
178
|
+
return _context2.abrupt("return", mainProps);
|
|
179
|
+
case 24:
|
|
180
|
+
_context2.prev = 24;
|
|
181
|
+
_context2.next = 27;
|
|
182
|
+
return (0, _ssr.getDataFromTree)( /*#__PURE__*/_react["default"].createElement(AppTree, (0, _extends2["default"])({}, appProps, {
|
|
183
|
+
Component: _Component,
|
|
184
|
+
router: router,
|
|
185
|
+
apolloClient: apolloClient
|
|
186
|
+
})));
|
|
187
|
+
case 27:
|
|
188
|
+
_context2.next = 35;
|
|
189
|
+
break;
|
|
190
|
+
case 29:
|
|
191
|
+
_context2.prev = 29;
|
|
192
|
+
_context2.t0 = _context2["catch"](24);
|
|
193
|
+
errorProps = (0, _helpers.getErrorMessage)(_context2.t0);
|
|
194
|
+
if (errorProps.errorCode) ctx.res.statusCode = errorProps.errorCode;
|
|
195
|
+
ctx.blazeApp.events.emit('monitor:log', {
|
|
196
|
+
error: _context2.t0
|
|
197
|
+
});
|
|
198
|
+
requestApp.log.error('Error while running `getDataFromTree`', _context2.t0);
|
|
199
|
+
case 35:
|
|
200
|
+
apolloState = apolloClient.cache.extract();
|
|
201
|
+
sortedState = Object.keys(apolloState).sort().reduce(function (acc, key) {
|
|
202
|
+
acc[key] = apolloState[key];
|
|
203
|
+
return acc;
|
|
204
|
+
}, {});
|
|
205
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, mainProps), {}, {
|
|
206
|
+
pageProps: _objectSpread(_objectSpread({}, mainProps.pageProps), errorProps),
|
|
207
|
+
apolloState: sortedState,
|
|
208
|
+
processedBlazeEntities: blazeApp.getProcessedEntities()
|
|
209
|
+
}));
|
|
210
|
+
case 38:
|
|
211
|
+
case "end":
|
|
212
|
+
return _context2.stop();
|
|
217
213
|
}
|
|
218
214
|
}, _callee2, null, [[24, 29]]);
|
|
219
215
|
}));
|
package/lib/hoc/withBlaze.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withBlaze.js","names":["ErrorBoundary","dynamic","APP_LOG_NAMESPACE_MAIN","getWrappedApp","isSsr","config","blazeApp","App","getApolloClient","ctx","requestApp","apolloClient","getClient","createClient","getRequestApp","getBlazeUi","props","state","appLoaded","initComplete","init","setState","apolloState","processedBlazeEntities","setupCheckAccessToken","setApolloClient","context","_Component","Component","router","AppTree","appProps","errorProps","req","res","events","emit","getInitialProps","pageProps","mainProps","getDataFromTree","getErrorMessage","errorCode","statusCode","error","log","cache","extract","sortedState","Object","keys","sort","reduce","acc","key","getProcessedEntities","PropTypes","object","undefined","withBlaze","buildConfig","forceSsr","window","blazeConfig","logNameSpace"],"sources":["../../src/hoc/withBlaze.js"],"sourcesContent":["// see: https://github.com/zeit/next.js/blob/canary/examples/with-apollo-auth/lib/withApollo.js\nimport React, { Component } from 'react';\nimport { getDataFromTree } from '@apollo/client/react/ssr';\nimport getBlazeUi from '@blaze-cms/core-ui';\nimport { setupCheckAccessToken } from '@blaze-cms/core-auth-ui';\nimport PropTypes from 'prop-types';\nimport dynamic from 'next/dynamic'; // Next.js dynamic\nimport blazeConfig from '../blaze.config';\nimport { getErrorMessage } from '../helpers';\n\nconst ErrorBoundary = dynamic(() => import('@blaze-cms/core-errors-ui'));\n\nconst APP_LOG_NAMESPACE_MAIN = 'main';\n\nfunction getWrappedApp(isSsr, config, blazeApp, App) {\n function getApolloClient(ctx, requestApp) {\n return ctx.apolloClient || requestApp.getClient() || requestApp.createClient();\n }\n\n function getRequestApp(requestApp) {\n return !requestApp && isSsr ? getBlazeUi({ config }) : blazeApp;\n }\n return class extends Component {\n static displayName = 'withBlaze(App)';\n\n static propTypes = {\n apolloState: PropTypes.object,\n apolloClient: PropTypes.object,\n processedBlazeEntities: PropTypes.object\n };\n\n static defaultProps = {\n apolloState: {},\n apolloClient: null,\n processedBlazeEntities: undefined\n };\n\n static async getInitialProps(context) {\n const { Component: _Component, router, AppTree, ctx } = context;\n let appProps = {};\n let errorProps = {};\n\n let requestApp = ctx.blazeApp;\n requestApp = getRequestApp(requestApp);\n\n requestApp.ctx.router = router;\n requestApp.ctx.req = ctx.req;\n requestApp.ctx.res = ctx.res;\n\n await blazeApp.init();\n await requestApp.init();\n\n const apolloClient = getApolloClient(ctx, requestApp);\n\n ctx.apolloClient = apolloClient;\n ctx.blazeApp = requestApp;\n\n requestApp.events.emit('page-load:get-initial-props:before', { ctx });\n\n if (App.getInitialProps) {\n appProps = await App.getInitialProps(context);\n }\n\n const { pageProps = {} } = appProps;\n const mainProps = {\n ...appProps,\n pageProps: { ...pageProps, ...errorProps }\n };\n\n if (!isSsr) return mainProps;\n\n try {\n await getDataFromTree(\n <AppTree\n {...appProps}\n Component={_Component}\n router={router}\n apolloClient={apolloClient}\n />\n );\n } catch (error) {\n errorProps = getErrorMessage(error);\n if (errorProps.errorCode) ctx.res.statusCode = errorProps.errorCode;\n ctx.blazeApp.events.emit('monitor:log', { error });\n requestApp.log.error('Error while running `getDataFromTree`', error);\n }\n\n const apolloState = apolloClient.cache.extract();\n const sortedState = Object.keys(apolloState)\n .sort()\n .reduce((acc, key) => {\n acc[key] = apolloState[key];\n return acc;\n }, {});\n\n return {\n ...mainProps,\n pageProps: { ...mainProps.pageProps, ...errorProps },\n apolloState: sortedState,\n processedBlazeEntities: blazeApp.getProcessedEntities()\n };\n }\n\n constructor(props) {\n super(props);\n this.apolloClient = props.apolloClient;\n this.state = {\n appLoaded: isSsr || blazeApp.initComplete()\n };\n this.blazeApp = blazeApp;\n }\n\n async componentDidMount() {\n if (blazeApp.initComplete()) return;\n\n await blazeApp.init();\n\n this.setState({\n appLoaded: blazeApp.initComplete()\n });\n }\n\n setApolloClient() {\n if (!this.apolloClient) {\n const { apolloState, processedBlazeEntities } = this.props;\n this.apolloClient = blazeApp.createClient(apolloState, processedBlazeEntities);\n setupCheckAccessToken(this.apolloClient);\n }\n }\n\n render() {\n const { appLoaded } = this.state;\n\n if (!appLoaded && !isSsr) return '...loading';\n\n this.setApolloClient();\n\n return (\n <ErrorBoundary app={this.blazeApp}>\n <App {...this.props} apolloClient={this.apolloClient} />\n </ErrorBoundary>\n );\n }\n };\n}\n\nconst withBlaze = (App, buildConfig, { forceSsr = false } = {}) => {\n const isSsr = forceSsr || typeof window === 'undefined';\n const config = buildConfig ? buildConfig(blazeConfig) : blazeConfig;\n const blazeApp = getBlazeUi({ config, logNameSpace: APP_LOG_NAMESPACE_MAIN });\n blazeApp.init();\n\n return getWrappedApp(isSsr, config, blazeApp, App);\n};\n\nexport default withBlaze;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAE7C,IAAMA,aAAa,GAAG,IAAAC,mBAAO,EAAC;EAAA;IAAA,uCAAa,2BAA2B;EAAA;AAAA,CAAC,CAAC;AAExE,IAAMC,sBAAsB,GAAG,MAAM;AAErC,SAASC,aAAa,CAACC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,GAAG,EAAE;EAAA;EACnD,SAASC,eAAe,CAACC,GAAG,EAAEC,UAAU,EAAE;IACxC,OAAOD,GAAG,CAACE,YAAY,IAAID,UAAU,CAACE,SAAS,EAAE,IAAIF,UAAU,CAACG,YAAY,EAAE;EAChF;EAEA,SAASC,aAAa,CAACJ,UAAU,EAAE;IACjC,OAAO,CAACA,UAAU,IAAIN,KAAK,GAAG,IAAAW,kBAAU,EAAC;MAAEV,MAAM,EAANA;IAAO,CAAC,CAAC,GAAGC,QAAQ;EACjE;EACA;IAAA;IAAA;IAiFE,gBAAYU,KAAK,EAAE;MAAA;MAAA;MACjB,0BAAMA,KAAK;MACX,MAAKL,YAAY,GAAGK,KAAK,CAACL,YAAY;MACtC,MAAK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S,CAACC,MAAM;IAC9BlC,sBAAsB,EAAEiC,qBAAS,CAACC;EACpC,CAAC,4DAEqB;IACpBnC,WAAW,EAAE,CAAC,CAAC;IACfX,YAAY,EAAE,IAAI;IAClBY,sBAAsB,EAAEmC;EAC1B,CAAC;AA6GL;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAS,CAAIpD,GAAG,EAAEqD,WAAW,EAAgC;EAAA,+EAAP,CAAC,CAAC;IAAA,qBAAvBC,QAAQ;IAARA,QAAQ,8BAAG,KAAK;EACrD,IAAMzD,KAAK,GAAGyD,QAAQ,IAAI,OAAOC,MAAM,KAAK,WAAW;EACvD,IAAMzD,MAAM,GAAGuD,WAAW,GAAGA,WAAW,CAACG,iBAAW,CAAC,GAAGA,iBAAW;EACnE,IAAMzD,QAAQ,GAAG,IAAAS,kBAAU,EAAC;IAAEV,MAAM,EAANA,MAAM;IAAE2D,YAAY,EAAE9D;EAAuB,CAAC,CAAC;EAC7EI,QAAQ,CAACc,IAAI,EAAE;EAEf,OAAOjB,aAAa,CAACC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,GAAG,CAAC;AACpD,CAAC;AAAC,eAEaoD,SAAS;AAAA"}
|
|
1
|
+
{"version":3,"file":"withBlaze.js","names":["ErrorBoundary","dynamic","APP_LOG_NAMESPACE_MAIN","getWrappedApp","isSsr","config","blazeApp","App","getApolloClient","ctx","requestApp","apolloClient","getClient","createClient","getRequestApp","getBlazeUi","props","state","appLoaded","initComplete","init","setState","apolloState","processedBlazeEntities","setupCheckAccessToken","setApolloClient","context","_Component","Component","router","AppTree","appProps","errorProps","req","res","events","emit","getInitialProps","pageProps","mainProps","getDataFromTree","getErrorMessage","errorCode","statusCode","error","log","cache","extract","sortedState","Object","keys","sort","reduce","acc","key","getProcessedEntities","PropTypes","object","undefined","withBlaze","buildConfig","forceSsr","window","blazeConfig","logNameSpace"],"sources":["../../src/hoc/withBlaze.js"],"sourcesContent":["// see: https://github.com/zeit/next.js/blob/canary/examples/with-apollo-auth/lib/withApollo.js\nimport React, { Component } from 'react';\nimport { getDataFromTree } from '@apollo/client/react/ssr';\nimport getBlazeUi from '@blaze-cms/core-ui';\nimport { setupCheckAccessToken } from '@blaze-cms/core-auth-ui';\nimport PropTypes from 'prop-types';\nimport dynamic from 'next/dynamic'; // Next.js dynamic\nimport blazeConfig from '../blaze.config';\nimport { getErrorMessage } from '../helpers';\n\nconst ErrorBoundary = dynamic(() => import('@blaze-cms/core-errors-ui'));\n\nconst APP_LOG_NAMESPACE_MAIN = 'main';\n\nfunction getWrappedApp(isSsr, config, blazeApp, App) {\n function getApolloClient(ctx, requestApp) {\n return ctx.apolloClient || requestApp.getClient() || requestApp.createClient();\n }\n\n function getRequestApp(requestApp) {\n return !requestApp && isSsr ? getBlazeUi({ config }) : blazeApp;\n }\n return class extends Component {\n static displayName = 'withBlaze(App)';\n\n static propTypes = {\n apolloState: PropTypes.object,\n apolloClient: PropTypes.object,\n processedBlazeEntities: PropTypes.object\n };\n\n static defaultProps = {\n apolloState: {},\n apolloClient: null,\n processedBlazeEntities: undefined\n };\n\n static async getInitialProps(context) {\n const { Component: _Component, router, AppTree, ctx } = context;\n let appProps = {};\n let errorProps = {};\n\n let requestApp = ctx.blazeApp;\n requestApp = getRequestApp(requestApp);\n\n requestApp.ctx.router = router;\n requestApp.ctx.req = ctx.req;\n requestApp.ctx.res = ctx.res;\n\n await blazeApp.init();\n await requestApp.init();\n\n const apolloClient = getApolloClient(ctx, requestApp);\n\n ctx.apolloClient = apolloClient;\n ctx.blazeApp = requestApp;\n\n requestApp.events.emit('page-load:get-initial-props:before', { ctx });\n\n if (App.getInitialProps) {\n appProps = await App.getInitialProps(context);\n }\n\n const { pageProps = {} } = appProps;\n const mainProps = {\n ...appProps,\n pageProps: { ...pageProps, ...errorProps }\n };\n\n if (!isSsr) return mainProps;\n\n try {\n await getDataFromTree(\n <AppTree\n {...appProps}\n Component={_Component}\n router={router}\n apolloClient={apolloClient}\n />\n );\n } catch (error) {\n errorProps = getErrorMessage(error);\n if (errorProps.errorCode) ctx.res.statusCode = errorProps.errorCode;\n ctx.blazeApp.events.emit('monitor:log', { error });\n requestApp.log.error('Error while running `getDataFromTree`', error);\n }\n\n const apolloState = apolloClient.cache.extract();\n const sortedState = Object.keys(apolloState)\n .sort()\n .reduce((acc, key) => {\n acc[key] = apolloState[key];\n return acc;\n }, {});\n\n return {\n ...mainProps,\n pageProps: { ...mainProps.pageProps, ...errorProps },\n apolloState: sortedState,\n processedBlazeEntities: blazeApp.getProcessedEntities()\n };\n }\n\n constructor(props) {\n super(props);\n this.apolloClient = props.apolloClient;\n this.state = {\n appLoaded: isSsr || blazeApp.initComplete()\n };\n this.blazeApp = blazeApp;\n }\n\n async componentDidMount() {\n if (blazeApp.initComplete()) return;\n\n await blazeApp.init();\n\n this.setState({\n appLoaded: blazeApp.initComplete()\n });\n }\n\n setApolloClient() {\n if (!this.apolloClient) {\n const { apolloState, processedBlazeEntities } = this.props;\n this.apolloClient = blazeApp.createClient(apolloState, processedBlazeEntities);\n setupCheckAccessToken(this.apolloClient);\n }\n }\n\n render() {\n const { appLoaded } = this.state;\n\n if (!appLoaded && !isSsr) return '...loading';\n\n this.setApolloClient();\n\n return (\n <ErrorBoundary app={this.blazeApp}>\n <App {...this.props} apolloClient={this.apolloClient} />\n </ErrorBoundary>\n );\n }\n };\n}\n\nconst withBlaze = (App, buildConfig, { forceSsr = false } = {}) => {\n const isSsr = forceSsr || typeof window === 'undefined';\n const config = buildConfig ? buildConfig(blazeConfig) : blazeConfig;\n const blazeApp = getBlazeUi({ config, logNameSpace: APP_LOG_NAMESPACE_MAIN });\n blazeApp.init();\n\n return getWrappedApp(isSsr, config, blazeApp, App);\n};\n\nexport default withBlaze;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAE7C,IAAMA,aAAa,GAAG,I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KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,GAAG,CAAC;AACpD,CAAC;AAAC,eAEaoD,SAAS;AAAA"}
|
package/lib/pages/Resolver.js
CHANGED
|
@@ -76,14 +76,12 @@ var Resolver = function Resolver(props) {
|
|
|
76
76
|
Resolver.getInitialProps = /*#__PURE__*/function () {
|
|
77
77
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(props) {
|
|
78
78
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
79
|
-
while (1) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return _context.stop();
|
|
86
|
-
}
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
return _context.abrupt("return", (0, _helpers.checkUrl)(props));
|
|
82
|
+
case 1:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context.stop();
|
|
87
85
|
}
|
|
88
86
|
}, _callee);
|
|
89
87
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resolver.js","names":["Resolver","props","pageData","itemId","itemEntity","isStatusPage","fullUrl","disableSsr","rootSelectorClasses","RESOLVER_CONTAINER_CLASS","isPreview","errorCode","NOT_FOUND_STATUS_CODE","errorMessage","router","useRouter","window","asPath","location","hash","url","URL","href","searchParams","set","Date","now","push","getInitialProps","checkUrl","propTypes","PropTypes","string","object","bool","number","defaultProps"],"sources":["../../src/pages/Resolver.js"],"sourcesContent":["import React from 'react';\nimport NextError from 'next/error';\nimport { useRouter } from 'next/router';\nimport PropTypes from 'prop-types';\nimport { DebugSidebar } from '../components';\nimport { checkUrl } from '../helpers';\nimport { ContentContainer } from '../containers';\nimport { NOT_FOUND_STATUS_CODE, RESOLVER_CONTAINER_CLASS } from '../constants';\n\nconst Resolver = props => {\n const {\n pageData,\n itemId,\n itemEntity,\n isStatusPage,\n fullUrl,\n disableSsr,\n rootSelectorClasses = RESOLVER_CONTAINER_CLASS,\n isPreview = false,\n errorCode = NOT_FOUND_STATUS_CODE,\n errorMessage = null\n } = props;\n const router = useRouter();\n\n if (disableSsr) {\n if (typeof window !== 'undefined') {\n let { asPath } = router;\n if (window.location.hash) {\n // handle nextjs issue not calling getInitialProps if pushing a url with a hash in it\n // we add a new query string param to force calling getInitialProps\n // this should only happen if disableSsr and window.location.hash\n const url = new URL(router.asPath, window.location.href);\n if (url.hash) url.searchParams.set('_h', Date.now());\n asPath = url;\n }\n router.push('/Resolver', asPath);\n }\n return '';\n }\n\n if (isStatusPage) return 'OK';\n\n if (!pageData || !itemId || !itemEntity)\n return <NextError statusCode={errorCode} title={errorMessage} />;\n\n return (\n <div className={rootSelectorClasses}>\n <ContentContainer\n pageData={pageData}\n itemId={itemId}\n itemEntity={itemEntity}\n isPreview={isPreview}\n fullUrl={fullUrl}\n />\n\n <DebugSidebar itemId={itemId} itemEntity={itemEntity} />\n </div>\n );\n};\n\nResolver.getInitialProps = async props => checkUrl(props);\n\nResolver.propTypes = {\n itemId: PropTypes.string,\n itemEntity: PropTypes.string,\n pageData: PropTypes.object,\n isStatusPage: PropTypes.bool,\n fullUrl: PropTypes.string,\n isPreview: PropTypes.bool,\n errorCode: PropTypes.number,\n disableSsr: PropTypes.bool,\n errorMessage: PropTypes.string,\n rootSelectorClasses: PropTypes.string\n};\n\nResolver.defaultProps = {\n itemId: null,\n itemEntity: null,\n pageData: null,\n isStatusPage: false,\n fullUrl: '',\n isPreview: false,\n errorCode: NOT_FOUND_STATUS_CODE,\n disableSsr: false,\n errorMessage: null,\n rootSelectorClasses: RESOLVER_CONTAINER_CLASS\n};\n\nexport default Resolver;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,CAAGC,KAAK,EAAI;EACxB,IACEC,QAAQ,GAUND,KAAK,CAVPC,QAAQ;IACRC,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AC,4BAAgB;IACf,QAAQ,EAAEN,QAAS;IACnB,MAAM,EAAEC,MAAO;IACf,UAAU,EAAEC,UAAW;IACvB,SAAS,EAAEM,SAAU;IACrB,OAAO,EAAEJ;EAAQ,EACjB,eAEF,gCAAC,wBAAY;IAAC,MAAM,EAAEH,MAAO;IAAC,UAAU,EAAEC;EAAW,EAAG,CACpD;AAEV,CAAC;AAEDJ,QAAQ,CAAC4B,eAAe;EAAA,yFAAG,iBAAM3B,KAAK;IAAA;MAAA;QAAA;UAAA
|
|
1
|
+
{"version":3,"file":"Resolver.js","names":["Resolver","props","pageData","itemId","itemEntity","isStatusPage","fullUrl","disableSsr","rootSelectorClasses","RESOLVER_CONTAINER_CLASS","isPreview","errorCode","NOT_FOUND_STATUS_CODE","errorMessage","router","useRouter","window","asPath","location","hash","url","URL","href","searchParams","set","Date","now","push","getInitialProps","checkUrl","propTypes","PropTypes","string","object","bool","number","defaultProps"],"sources":["../../src/pages/Resolver.js"],"sourcesContent":["import React from 'react';\nimport NextError from 'next/error';\nimport { useRouter } from 'next/router';\nimport PropTypes from 'prop-types';\nimport { DebugSidebar } from '../components';\nimport { checkUrl } from '../helpers';\nimport { ContentContainer } from '../containers';\nimport { NOT_FOUND_STATUS_CODE, RESOLVER_CONTAINER_CLASS } from '../constants';\n\nconst Resolver = props => {\n const {\n pageData,\n itemId,\n itemEntity,\n isStatusPage,\n fullUrl,\n disableSsr,\n rootSelectorClasses = RESOLVER_CONTAINER_CLASS,\n isPreview = false,\n errorCode = NOT_FOUND_STATUS_CODE,\n errorMessage = null\n } = props;\n const router = useRouter();\n\n if (disableSsr) {\n if (typeof window !== 'undefined') {\n let { asPath } = router;\n if (window.location.hash) {\n // handle nextjs issue not calling getInitialProps if pushing a url with a hash in it\n // we add a new query string param to force calling getInitialProps\n // this should only happen if disableSsr and window.location.hash\n const url = new URL(router.asPath, window.location.href);\n if (url.hash) url.searchParams.set('_h', Date.now());\n asPath = url;\n }\n router.push('/Resolver', asPath);\n }\n return '';\n }\n\n if (isStatusPage) return 'OK';\n\n if (!pageData || !itemId || !itemEntity)\n return <NextError statusCode={errorCode} title={errorMessage} />;\n\n return (\n <div className={rootSelectorClasses}>\n <ContentContainer\n pageData={pageData}\n itemId={itemId}\n itemEntity={itemEntity}\n isPreview={isPreview}\n fullUrl={fullUrl}\n />\n\n <DebugSidebar itemId={itemId} itemEntity={itemEntity} />\n </div>\n );\n};\n\nResolver.getInitialProps = async props => checkUrl(props);\n\nResolver.propTypes = {\n itemId: PropTypes.string,\n itemEntity: PropTypes.string,\n pageData: PropTypes.object,\n isStatusPage: PropTypes.bool,\n fullUrl: PropTypes.string,\n isPreview: PropTypes.bool,\n errorCode: PropTypes.number,\n disableSsr: PropTypes.bool,\n errorMessage: PropTypes.string,\n rootSelectorClasses: PropTypes.string\n};\n\nResolver.defaultProps = {\n itemId: null,\n itemEntity: null,\n pageData: null,\n isStatusPage: false,\n fullUrl: '',\n isPreview: false,\n errorCode: NOT_FOUND_STATUS_CODE,\n disableSsr: false,\n errorMessage: null,\n rootSelectorClasses: RESOLVER_CONTAINER_CLASS\n};\n\nexport default Resolver;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,CAAGC,KAAK,EAAI;EACxB,IACEC,QAAQ,GAUND,KAAK,CAVPC,QAAQ;IACRC,MAAM,GASJF,KAAK,CATPE,MAAM;IACNC,UAAU,GAQRH,KAAK,CARPG,UAAU;IACVC,YAAY,GAOVJ,KAAK,CAPPI,YAAY;IACZC,OAAO,GAMLL,KAAK,CANPK,OAAO;IACPC,UAAU,GAKRN,KAAK,CALPM,UAAU;IAAA,wBAKRN,KAAK,CAJPO,mBAAmB;IAAnBA,mBAAmB,sCAAGC,mCAAwB;IAAA,mBAI5CR,KAAK,CAHPS,SAAS;IAATA,SAAS,iCAAG,KAAK;IAAA,mBAGfT,KAAK,CAFPU,SAAS;IAATA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AC5B,KAAK,CAAC;QAAA;QAAA;UAAA;MAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAAA;AAEzDD,QAAQ,CAAC8B,SAAS,GAAG;EACnB3B,MAAM,EAAE4B,qBAAS,CAACC,MAAM;EACxB5B,UAAU,EAAE2B,qBAAS,CAACC,MAAM;EAC5B9B,QAAQ,EAAE6B,qBAAS,CAACE,MAAM;EAC1B5B,YAAY,EAAE0B,qBAAS,CAACG,IAAI;EAC5B5B,OAAO,EAAEyB,qBAAS,CAACC,MAAM;EACzBtB,SAAS,EAAEqB,qBAAS,CAACG,IAAI;EACzBvB,SAAS,EAAEoB,qBAAS,CAACI,MAAM;EAC3B5B,UAAU,EAAEwB,qBAAS,CAACG,IAAI;EAC1BrB,YAAY,EAAEkB,qBAAS,CAACC,MAAM;EAC9BxB,mBAAmB,EAAEuB,qBAAS,CAACC;AACjC,CAAC;AAEDhC,QAAQ,CAACoC,YAAY,GAAG;EACtBjC,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,IAAI;EAChBF,QAAQ,EAAE,IAAI;EACdG,YAAY,EAAE,KAAK;EACnBC,OAAO,EAAE,EAAE;EACXI,SAAS,EAAE,KAAK;EAChBC,SAAS,EAAEC,gCAAqB;EAChCL,UAAU,EAAE,KAAK;EACjBM,YAAY,EAAE,IAAI;EAClBL,mBAAmB,EAAEC;AACvB,CAAC;AAAC,eAEaT,QAAQ;AAAA"}
|
package/lib/server/index.js
CHANGED
|
@@ -15,23 +15,21 @@ function _prepareServer() {
|
|
|
15
15
|
_prepareServer = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(nextApp) {
|
|
16
16
|
var handler;
|
|
17
17
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
18
|
-
while (1) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return _context.stop();
|
|
34
|
-
}
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
handler = Router.getRequestHandler(nextApp);
|
|
21
|
+
_context.next = 3;
|
|
22
|
+
return nextApp.prepare();
|
|
23
|
+
case 3:
|
|
24
|
+
return _context.abrupt("return", {
|
|
25
|
+
run: function run() {
|
|
26
|
+
return createServer(handler).listen(port);
|
|
27
|
+
},
|
|
28
|
+
handler: handler
|
|
29
|
+
});
|
|
30
|
+
case 4:
|
|
31
|
+
case "end":
|
|
32
|
+
return _context.stop();
|
|
35
33
|
}
|
|
36
34
|
}, _callee);
|
|
37
35
|
}));
|
package/lib/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["require","createServer","Router","port","parseInt","process","env","PORT","prepareServer","nextApp","handler","getRequestHandler","prepare","run","listen","module","exports"],"sources":["../../src/server/index.js"],"sourcesContent":["const { createServer } = require('http');\nconst Router = require('./routes');\n\nconst port = parseInt(process.env.PORT, 10) || 3000;\n\nasync function prepareServer(nextApp) {\n const handler = Router.getRequestHandler(nextApp);\n\n await nextApp.prepare();\n\n return { run: () => createServer(handler).listen(port), handler };\n}\n\nmodule.exports = prepareServer;\n"],"mappings":";;;;;;AAAA,eAAyBA,OAAO,CAAC,MAAM,CAAC;EAAhCC,YAAY,YAAZA,YAAY;AACpB,IAAMC,MAAM,GAAGF,OAAO,CAAC,UAAU,CAAC;AAElC,IAAMG,IAAI,GAAGC,QAAQ,CAACC,OAAO,CAACC,GAAG,CAACC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI;AAAC,SAErCC,aAAa;EAAA;AAAA;AAAA;EAAA,+FAA5B,iBAA6BC,OAAO;IAAA;IAAA;MAAA;QAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["require","createServer","Router","port","parseInt","process","env","PORT","prepareServer","nextApp","handler","getRequestHandler","prepare","run","listen","module","exports"],"sources":["../../src/server/index.js"],"sourcesContent":["const { createServer } = require('http');\nconst Router = require('./routes');\n\nconst port = parseInt(process.env.PORT, 10) || 3000;\n\nasync function prepareServer(nextApp) {\n const handler = Router.getRequestHandler(nextApp);\n\n await nextApp.prepare();\n\n return { run: () => createServer(handler).listen(port), handler };\n}\n\nmodule.exports = prepareServer;\n"],"mappings":";;;;;;AAAA,eAAyBA,OAAO,CAAC,MAAM,CAAC;EAAhCC,YAAY,YAAZA,YAAY;AACpB,IAAMC,MAAM,GAAGF,OAAO,CAAC,UAAU,CAAC;AAElC,IAAMG,IAAI,GAAGC,QAAQ,CAACC,OAAO,CAACC,GAAG,CAACC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI;AAAC,SAErCC,aAAa;EAAA;AAAA;AAAA;EAAA,+FAA5B,iBAA6BC,OAAO;IAAA;IAAA;MAAA;QAAA;UAC5BC,OAAO,GAAGR,MAAM,CAACS,iBAAiB,CAACF,OAAO,CAAC;UAAA;UAAA,OAE3CA,OAAO,CAACG,OAAO,EAAE;QAAA;UAAA,iCAEhB;YAAEC,GAAG,EAAE;cAAA,OAAMZ,YAAY,CAACS,OAAO,CAAC,CAACI,MAAM,CAACX,IAAI,CAAC;YAAA;YAAEO,OAAO,EAAPA;UAAQ,CAAC;QAAA;QAAA;UAAA;MAAA;IAAA;EAAA,CAClE;EAAA;AAAA;AAEDK,MAAM,CAACC,OAAO,GAAGR,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useState","useEffect","PropTypes","classnames","Link","MdKeyboardArrowLeft","buildAdminHref","setBlazeDebug","DEBUG_LOGO","DebugSidebar","itemEntity","itemId","debugMode","isDebugMode","setIsDebugMode","isOpen","setIsOpen","divClass","href","SRC","ALT","propTypes","string","bool","defaultProps"],"sources":["../../../src/components/DebugSidebar/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport { Link } from '@blaze-cms/nextjs-components';\nimport { MdKeyboardArrowLeft } from 'react-icons/md';\nimport { buildAdminHref, setBlazeDebug } from '../../helpers';\nimport { DEBUG_LOGO } from '../../constants';\n\nconst DebugSidebar = ({ itemEntity, itemId, debugMode }) => {\n const [isDebugMode, setIsDebugMode] = useState(debugMode);\n const [isOpen, setIsOpen] = useState(true);\n\n useEffect(\n () => {\n if (debugMode === true) {\n setIsDebugMode(debugMode);\n } else setBlazeDebug(setIsDebugMode);\n },\n [debugMode]\n );\n\n const divClass = classnames('debug-sidebar', {\n 'debug-sidebar--open': isOpen,\n 'debug-sidebar--close': !isOpen\n });\n\n const href = buildAdminHref({ itemEntity, itemId });\n\n return (\n <>\n {isDebugMode ? (\n <div className={divClass} data-testid=\"debug-sidebar\">\n <Link href={href}>\n <img src={DEBUG_LOGO.SRC} alt={DEBUG_LOGO.ALT} />\n <span>Blaze admin</span>\n </Link>\n <div\n role=\"button\"\n className=\"debug-sidebar__button open\"\n data-testid=\"debug-sidebar-button\"\n id=\"debug-sidebar-button\"\n onClick={() => setIsOpen(!isOpen)}>\n <i>\n <MdKeyboardArrowLeft />\n </i>\n </div>\n </div>\n ) : null}\n </>\n );\n};\n\nDebugSidebar.propTypes = {\n itemEntity: PropTypes.string,\n itemId: PropTypes.string,\n debugMode: PropTypes.bool\n};\n\nDebugSidebar.defaultProps = {\n itemEntity: '',\n itemId: '',\n debugMode: false\n};\n\nexport default DebugSidebar;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,IAAI,QAAQ,8BAA8B;AACnD,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,cAAc,EAAEC,aAAa,QAAQ,eAAe;AAC7D,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,MAAMC,YAAY,GAAG,CAAC;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,KAAK;EAC1D,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGd,QAAQ,CAACY,SAAS,CAAC;EACzD,MAAM,CAACG,MAAM,EAAEC,SAAS,CAAC,GAAGhB,QAAQ,CAAC,IAAI,CAAC;EAE1CC,SAAS,CACP,MAAM;IACJ,IAAIW,SAAS,KAAK,IAAI,EAAE;MACtBE,cAAc,CAACF,SAAS,CAAC;IAC3B,CAAC,MAAML,aAAa,CAACO,cAAc,CAAC;EACtC,CAAC,EACD,CAACF,SAAS,CAAC,CACZ;EAED,MAAMK,QAAQ,GAAGd,UAAU,CAAC,eAAe,EAAE;IAC3C,qBAAqB,EAAEY,MAAM;IAC7B,sBAAsB,EAAE,CAACA;EAC3B,CAAC,CAAC;EAEF,MAAMG,IAAI,GAAGZ,cAAc,CAAC;IAAEI,UAAU;IAAEC;EAAO,CAAC,CAAC;EAEnD,oBACE,0CACGE,WAAW,gBACV;IAAK,SAAS,EAAEI,QAAS;IAAC,eAAY;EAAe,gBACnD,oBAAC,IAAI;IAAC,IAAI,EAAEC;EAAK,gBACf;IAAK,GAAG,EAAEV,UAAU,CAACW,GAAI;IAAC,GAAG,EAAEX,UAAU,CAACY;EAAI,EAAG,eACjD,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useState","useEffect","PropTypes","classnames","Link","MdKeyboardArrowLeft","buildAdminHref","setBlazeDebug","DEBUG_LOGO","DebugSidebar","itemEntity","itemId","debugMode","isDebugMode","setIsDebugMode","isOpen","setIsOpen","divClass","href","SRC","ALT","propTypes","string","bool","defaultProps"],"sources":["../../../src/components/DebugSidebar/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport { Link } from '@blaze-cms/nextjs-components';\nimport { MdKeyboardArrowLeft } from 'react-icons/md';\nimport { buildAdminHref, setBlazeDebug } from '../../helpers';\nimport { DEBUG_LOGO } from '../../constants';\n\nconst DebugSidebar = ({ itemEntity, itemId, debugMode }) => {\n const [isDebugMode, setIsDebugMode] = useState(debugMode);\n const [isOpen, setIsOpen] = useState(true);\n\n useEffect(\n () => {\n if (debugMode === true) {\n setIsDebugMode(debugMode);\n } else setBlazeDebug(setIsDebugMode);\n },\n [debugMode]\n );\n\n const divClass = classnames('debug-sidebar', {\n 'debug-sidebar--open': isOpen,\n 'debug-sidebar--close': !isOpen\n });\n\n const href = buildAdminHref({ itemEntity, itemId });\n\n return (\n <>\n {isDebugMode ? (\n <div className={divClass} data-testid=\"debug-sidebar\">\n <Link href={href}>\n <img src={DEBUG_LOGO.SRC} alt={DEBUG_LOGO.ALT} />\n <span>Blaze admin</span>\n </Link>\n <div\n role=\"button\"\n className=\"debug-sidebar__button open\"\n data-testid=\"debug-sidebar-button\"\n id=\"debug-sidebar-button\"\n onClick={() => setIsOpen(!isOpen)}>\n <i>\n <MdKeyboardArrowLeft />\n </i>\n </div>\n </div>\n ) : null}\n </>\n );\n};\n\nDebugSidebar.propTypes = {\n itemEntity: PropTypes.string,\n itemId: PropTypes.string,\n debugMode: PropTypes.bool\n};\n\nDebugSidebar.defaultProps = {\n itemEntity: '',\n itemId: '',\n debugMode: false\n};\n\nexport default DebugSidebar;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,IAAI,QAAQ,8BAA8B;AACnD,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,cAAc,EAAEC,aAAa,QAAQ,eAAe;AAC7D,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,MAAMC,YAAY,GAAG,CAAC;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,KAAK;EAC1D,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGd,QAAQ,CAACY,SAAS,CAA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.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/nextjs-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.128.0-admin-updates.0",
|
|
4
4
|
"description": "Blaze nextjs tools",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@apollo/client": "3.5.x",
|
|
31
|
-
"@blaze-cms/core-auth-ui": "
|
|
32
|
-
"@blaze-cms/core-errors": "
|
|
33
|
-
"@blaze-cms/core-errors-ui": "
|
|
34
|
-
"@blaze-cms/core-ui": "
|
|
35
|
-
"@blaze-cms/nextjs-components": "
|
|
36
|
-
"@blaze-cms/plugin-auth-fe": "
|
|
37
|
-
"@blaze-cms/plugin-auth-local-fe": "
|
|
38
|
-
"@blaze-cms/plugin-google-maps-fe": "
|
|
39
|
-
"@blaze-cms/plugin-gtm-fe": "
|
|
40
|
-
"@blaze-cms/plugin-page-builder-fe": "
|
|
41
|
-
"@blaze-cms/plugin-preview-fe": "
|
|
42
|
-
"@blaze-cms/plugin-search-ui": "
|
|
43
|
-
"@blaze-cms/react-page-builder": "
|
|
44
|
-
"@blaze-cms/setup-ui": "
|
|
31
|
+
"@blaze-cms/core-auth-ui": "0.128.0-admin-updates.0",
|
|
32
|
+
"@blaze-cms/core-errors": "0.128.0-admin-updates.0",
|
|
33
|
+
"@blaze-cms/core-errors-ui": "0.128.0-admin-updates.0",
|
|
34
|
+
"@blaze-cms/core-ui": "0.128.0-admin-updates.0",
|
|
35
|
+
"@blaze-cms/nextjs-components": "0.128.0-admin-updates.0",
|
|
36
|
+
"@blaze-cms/plugin-auth-fe": "0.128.0-admin-updates.0",
|
|
37
|
+
"@blaze-cms/plugin-auth-local-fe": "0.128.0-admin-updates.0",
|
|
38
|
+
"@blaze-cms/plugin-google-maps-fe": "0.128.0-admin-updates.0",
|
|
39
|
+
"@blaze-cms/plugin-gtm-fe": "0.128.0-admin-updates.0",
|
|
40
|
+
"@blaze-cms/plugin-page-builder-fe": "0.128.0-admin-updates.0",
|
|
41
|
+
"@blaze-cms/plugin-preview-fe": "0.128.0-admin-updates.0",
|
|
42
|
+
"@blaze-cms/plugin-search-ui": "0.128.0-admin-updates.0",
|
|
43
|
+
"@blaze-cms/react-page-builder": "0.128.0-admin-updates.0",
|
|
44
|
+
"@blaze-cms/setup-ui": "0.128.0-admin-updates.0",
|
|
45
45
|
"autoprefixer": "^10.2.3",
|
|
46
46
|
"core-js": "^3.2.1",
|
|
47
47
|
"cross-fetch": "^3.0.2",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"lib/*",
|
|
69
69
|
"lib-es/*"
|
|
70
70
|
],
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "ad3389e954fe463366655311efb1198191dbb625"
|
|
72
72
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
2
4
|
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
4
7
|
import { render, act, fireEvent } from '@testing-library/react';
|
|
5
8
|
import { DebugSidebar } from '../../../../../src/components';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
2
4
|
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
6
|
|
|
4
7
|
import { MockedProvider } from '@apollo/client/testing';
|
|
5
8
|
import { render } from '@testing-library/react';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import { setEnvs, deleteEnvs } from '@blaze-cms/tools/test-helpers/test-files/test-env';
|
|
3
|
-
import
|
|
3
|
+
import buildAdminHref from '../../../../src/helpers/build-admin-href';
|
|
4
4
|
|
|
5
5
|
describe('buildAdminHref function', () => {
|
|
6
6
|
const itemId = '0000-1111-2222-test';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import checkUrl from '../../../../src/helpers/check-url';
|
|
8
8
|
import { ROUTE_PATTERN_SITEMAP, NOT_FOUND_STATUS_CODE } from '../../../../src/constants';
|
|
9
9
|
import { checkUrlQuery } from '../../../../src/application/query';
|
|
10
10
|
|