@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.
Files changed (2) hide show
  1. package/client/start.js +36 -34
  2. 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
- existingFetch ||
59
- fetch(`${routeDataPath}?path=${encodeURIComponent(url.pathname)}${url.search ? `&${url.search.slice(1)}` : ""}`, {
60
- credentials: "same-origin",
61
- })
58
+ existingFetch ||
59
+ fetch(`${routeDataPath}?path=${encodeURIComponent(url.pathname)}${url.search ? `&${url.search.slice(1)}` : ""}`, {
60
+ credentials: "same-origin",
61
+ })
62
62
  )
63
- .then((response) => {
64
- if (response.status == 404) {
65
- // There is a chance this might abort
66
- maybeBypassServiceWorker();
67
- }
63
+ .then((response) => {
64
+ if (response.status == 404) {
65
+ // There is a chance this might abort
66
+ maybeBypassServiceWorker();
67
+ }
68
68
 
69
- return response.json();
70
- })
71
- .then(maybeRedirect);
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
- pickComponentWrapper && pickComponentWrapper.preloadComponent(page.pageType, page.subPageType)
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
- global.history.pushState && global.history.pushState(null, title, path);
169
- global.document.title = title;
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
- .preloadComponent(store.getState().qt.pageType, store.getState().qt.subPageType)
210
- .then(() =>
211
- renderComponent(
212
- IsomorphicComponent,
213
- container,
214
- store,
215
- Object.assign({ pickComponent: pickComponentWrapper }, props),
216
- () => store.dispatch({ type: CLIENT_SIDE_RENDERED })
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
- ? Promise.resolve(staticData.qt)
268
- : getRouteData(path, { existingFetch: global.initialFetch });
269
+ ? Promise.resolve(staticData.qt)
270
+ : getRouteData(path, { existingFetch: global.initialFetch });
269
271
 
270
272
  startAnalytics();
271
273
 
272
274
  const store = createQtStore(
273
- reducers,
274
- (staticData && staticData.qt) || global.initialPage || getJsonContent("initial-page") || {},
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
- page,
318
- ["data", "customSeo", "title"],
319
- get(page, ["data", "story", "seo", "meta-title"], page.title)
319
+ page,
320
+ ["data", "customSeo", "title"],
321
+ get(page, ["data", "story", "seo", "meta-title"], page.title)
320
322
  );
321
323
  }
322
324
  return store;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.17.0",
3
+ "version": "7.18.0-test-ga.0",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {