@quintype/framework 7.34.2-image-srcset-lcp.2 → 7.34.2-refactor-dfns.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/framework",
|
|
3
|
-
"version": "7.34.2-
|
|
3
|
+
"version": "7.34.2-refactor-dfns.0",
|
|
4
4
|
"description": "Libraries to help build Quintype Node.js apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
34
34
|
"@grpc/grpc-js": "^1.12.5",
|
|
35
35
|
"@jsdoc/salty": "^0.2.9",
|
|
36
|
-
"@quintype/amp": "^2.21.
|
|
36
|
+
"@quintype/amp": "^2.21.1",
|
|
37
37
|
"@quintype/backend": "^2.7.0",
|
|
38
38
|
"@quintype/components": "^3.5.0",
|
|
39
39
|
"@quintype/prerender-node": "^3.2.26",
|
|
@@ -204,6 +204,7 @@ function createStoreFromResult(url, result, opts = {}) {
|
|
|
204
204
|
primaryHostUrl: result.primaryHostUrl,
|
|
205
205
|
isBotRequest: isBotRequest,
|
|
206
206
|
lazyLoadImageMargin: opts.lazyLoadImageMargin,
|
|
207
|
+
localeModule: _.get(opts, ['localeModule'])
|
|
207
208
|
};
|
|
208
209
|
return createBasicStore(result, qt, opts);
|
|
209
210
|
}
|
|
@@ -471,7 +472,7 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
|
|
|
471
472
|
) {
|
|
472
473
|
const url = urlLib.parse(req.url, true);
|
|
473
474
|
|
|
474
|
-
function writeResponse(result) {
|
|
475
|
+
function writeResponse(result, opts) {
|
|
475
476
|
const statusCode = result.httpStatusCode || 200;
|
|
476
477
|
|
|
477
478
|
if (statusCode == 301 && result.data && result.data.location) {
|
|
@@ -491,6 +492,7 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
|
|
|
491
492
|
const store = createStoreFromResult(url, result, {
|
|
492
493
|
disableIsomorphicComponent: statusCode != 200,
|
|
493
494
|
lazyLoadImageMargin,
|
|
495
|
+
localeModule: _.get(opts, ['localeModule'])
|
|
494
496
|
});
|
|
495
497
|
|
|
496
498
|
if (lightPages) {
|
|
@@ -553,20 +555,55 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
|
|
|
553
555
|
logError(e);
|
|
554
556
|
return { httpStatusCode: 500, pageType: "error" };
|
|
555
557
|
})
|
|
556
|
-
.then((result) => {
|
|
558
|
+
.then(async (result) => {
|
|
557
559
|
if (!result) {
|
|
558
560
|
return next();
|
|
559
561
|
}
|
|
560
|
-
return
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
562
|
+
return getStoreOpts(config).then((opts) => {
|
|
563
|
+
return new Promise((resolve) => resolve(writeResponse(result, opts)))
|
|
564
|
+
.catch((e) => {
|
|
565
|
+
logError(e);
|
|
566
|
+
res.status(500);
|
|
567
|
+
res.send(e.message);
|
|
568
|
+
})
|
|
569
|
+
.finally(() => res.end());
|
|
570
|
+
});
|
|
571
|
+
})
|
|
568
572
|
};
|
|
569
573
|
|
|
574
|
+
async function getStoreOpts(config) {
|
|
575
|
+
const opts = {};
|
|
576
|
+
const enableTimeTranslation = _.get(config, ['pbConfig', 'general', 'enableTimeTranslation'], false);
|
|
577
|
+
if (!enableTimeTranslation) {
|
|
578
|
+
return Promise.resolve(opts);
|
|
579
|
+
}
|
|
580
|
+
const languageCode = _.get(config, ['language', 'ietf-code']);
|
|
581
|
+
try {
|
|
582
|
+
let localeModule;
|
|
583
|
+
switch (languageCode) {
|
|
584
|
+
case 'hi':
|
|
585
|
+
localeModule = require('date-fns/locale/hi');
|
|
586
|
+
break;
|
|
587
|
+
case 'ta':
|
|
588
|
+
localeModule = require('date-fns/locale/ta');
|
|
589
|
+
break;
|
|
590
|
+
case 'de':
|
|
591
|
+
localeModule = require('date-fns/locale/de');
|
|
592
|
+
break;
|
|
593
|
+
default:
|
|
594
|
+
localeModule = require('date-fns/locale/en-US');
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
opts.localeModule = localeModule.default || localeModule;
|
|
598
|
+
return Promise.resolve(opts);
|
|
599
|
+
} catch (err) {
|
|
600
|
+
console.warn(`Falling back to en-US due to error loading locale: ${languageCode}`, err);
|
|
601
|
+
const fallbackLocale = require('date-fns/locale/en-US');
|
|
602
|
+
opts.localeModule = fallbackLocale.default || fallbackLocale;
|
|
603
|
+
return Promise.resolve(opts);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
570
607
|
exports.handleStaticRoute = function handleStaticRoute(
|
|
571
608
|
req,
|
|
572
609
|
res,
|