@quintype/framework 7.17.0 → 7.18.0-test-ga.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/client/start.js +36 -34
- package/package.json +1 -1
package/client/start.js
CHANGED
|
@@ -55,20 +55,20 @@ function getRouteData(path, { location = global.location, existingFetch, mountAt
|
|
|
55
55
|
const [routeDataPath, relativePath] = getRouteDataAndPath(path, mountAt);
|
|
56
56
|
const url = new URL(relativePath, location.origin);
|
|
57
57
|
return (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
existingFetch ||
|
|
59
|
+
fetch(`${routeDataPath}?path=${encodeURIComponent(url.pathname)}${url.search ? `&${url.search.slice(1)}` : ""}`, {
|
|
60
|
+
credentials: "same-origin",
|
|
61
|
+
})
|
|
62
62
|
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
.then((response) => {
|
|
64
|
+
if (response.status == 404) {
|
|
65
|
+
// There is a chance this might abort
|
|
66
|
+
maybeBypassServiceWorker();
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
return response.json();
|
|
70
|
+
})
|
|
71
|
+
.then(maybeRedirect);
|
|
72
72
|
|
|
73
73
|
function maybeRedirect(page) {
|
|
74
74
|
// This next line aborts the entire load
|
|
@@ -123,7 +123,7 @@ export function navigateToPage(dispatch, path, doNotPushPath) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
Promise.resolve(
|
|
126
|
-
|
|
126
|
+
pickComponentWrapper && pickComponentWrapper.preloadComponent(page.pageType, page.subPageType)
|
|
127
127
|
).then(() => {
|
|
128
128
|
dispatch({
|
|
129
129
|
type: NAVIGATE_TO_PAGE,
|
|
@@ -165,8 +165,10 @@ export function maybeNavigateTo(path, store) {
|
|
|
165
165
|
*/
|
|
166
166
|
export function maybeSetUrl(path, title) {
|
|
167
167
|
if (global.location.pathname === path) return;
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
if (global.history.pushState) {
|
|
169
|
+
global.document.title = title;
|
|
170
|
+
global.history.pushState(null, title, path);
|
|
171
|
+
}
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
/**
|
|
@@ -183,7 +185,7 @@ export function renderComponent(clazz, container, store, props = {}, callback) {
|
|
|
183
185
|
|
|
184
186
|
const containerEle = document.getElementById(container);
|
|
185
187
|
|
|
186
|
-
if(!containerEle){
|
|
188
|
+
if (!containerEle) {
|
|
187
189
|
console && console.log(`Rendering component on DOM id ${container} FAILED, node not available`);
|
|
188
190
|
return null;
|
|
189
191
|
}
|
|
@@ -206,16 +208,16 @@ export function renderIsomorphicComponent(container, store, pickComponent, props
|
|
|
206
208
|
if (!store.getState().qt.disableIsomorphicComponent) {
|
|
207
209
|
pickComponentWrapper = makePickComponentSync(pickComponent);
|
|
208
210
|
return pickComponentWrapper
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
.preloadComponent(store.getState().qt.pageType, store.getState().qt.subPageType)
|
|
212
|
+
.then(() =>
|
|
213
|
+
renderComponent(
|
|
214
|
+
IsomorphicComponent,
|
|
215
|
+
container,
|
|
216
|
+
store,
|
|
217
|
+
Object.assign({ pickComponent: pickComponentWrapper }, props),
|
|
218
|
+
() => store.dispatch({ type: CLIENT_SIDE_RENDERED })
|
|
219
|
+
)
|
|
220
|
+
);
|
|
219
221
|
}
|
|
220
222
|
console && console.log("IsomorphicComponent is disabled");
|
|
221
223
|
}
|
|
@@ -264,15 +266,15 @@ export function startApp(renderApplication, reducers, opts) {
|
|
|
264
266
|
const path = `${location.pathname}${location.search || ""}`;
|
|
265
267
|
const staticData = global.staticPageStoreContent || getJsonContent("static-page");
|
|
266
268
|
const dataPromise = staticData
|
|
267
|
-
|
|
268
|
-
|
|
269
|
+
? Promise.resolve(staticData.qt)
|
|
270
|
+
: getRouteData(path, { existingFetch: global.initialFetch });
|
|
269
271
|
|
|
270
272
|
startAnalytics();
|
|
271
273
|
|
|
272
274
|
const store = createQtStore(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
reducers,
|
|
276
|
+
(staticData && staticData.qt) || global.initialPage || getJsonContent("initial-page") || {},
|
|
277
|
+
{}
|
|
276
278
|
);
|
|
277
279
|
|
|
278
280
|
if (opts.preRenderApplication) {
|
|
@@ -314,9 +316,9 @@ export function startApp(renderApplication, reducers, opts) {
|
|
|
314
316
|
|
|
315
317
|
if (page.title) {
|
|
316
318
|
global.document.title = get(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
319
|
+
page,
|
|
320
|
+
["data", "customSeo", "title"],
|
|
321
|
+
get(page, ["data", "story", "seo", "meta-title"], page.title)
|
|
320
322
|
);
|
|
321
323
|
}
|
|
322
324
|
return store;
|