@20minutes/tyr 0.1.74 → 0.1.76
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/dist/assets/scripts/concern/headerMini.d.ts +1 -0
- package/dist/components/atoms/managerHelpers/react-container.d.ts +6 -0
- package/dist/css/articlePage-desktop-critical.css +1 -1
- package/dist/css/articlePage-desktop-no-critical.css +1 -1
- package/dist/css/articlePage-mobile-critical.css +1 -1
- package/dist/css/articlePage-mobile-no-critical.css +1 -1
- package/dist/css/errorPage-desktop-critical.css +1 -1
- package/dist/css/errorPage-desktop-no-critical.css +1 -1
- package/dist/css/horoscopePage-desktop-critical.css +1 -1
- package/dist/css/horoscopePage-desktop-no-critical.css +1 -1
- package/dist/css/horoscopehomePage-desktop-critical.css +1 -1
- package/dist/css/horoscopehomePage-desktop-no-critical.css +1 -1
- package/dist/css/searchPage-desktop-critical.css +1 -1
- package/dist/css/searchPage-desktop-no-critical.css +1 -1
- package/dist/css/tagPage-desktop-critical.css +1 -1
- package/dist/css/tagPage-desktop-no-critical.css +1 -1
- package/dist/index.es.js +25967 -25630
- package/dist/index.umd.js +151 -150
- package/dist/js/concern.min.js +4 -4
- package/dist/managers/PageManagerHelper.d.ts +14 -0
- package/dist/managers/article/ArticlePageManager.d.ts +21 -0
- package/dist/managers/helpers/AdsManager.d.ts +2 -0
- package/dist/templates/PageTemplate/PageTemplate.d.ts +1 -0
- package/dist/types/ComponentConfig.d.ts +1 -0
- package/dist/types/PageConfig.d.ts +1 -1
- package/dist/types/helpers.d.ts +1 -0
- package/package.json +7 -6
package/dist/js/concern.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function q(e){let n=e;const t="\xE3\xE0\xE1\xE4\xE2\u1EBD\xE8\xE9\xEB\xEA\xEC\xED\xEF\xEE\xF5\xF2\xF3\xF6\xF4\xF9\xFA\xFC\xFB\xF1\xE7\xB7/_,:;",o="aaaaaeeeeeiiiiooooouuuunc------";for(let a=0;a<t.length;a+=1)n=e.replace(new RegExp(t.charAt(a),"g"),o.charAt(a));return n}const j=e=>{let n=e.toLowerCase().replace(/[\s-]+/g,"_");return n=q(n),n.replace(/[^\w-]+/g,"")},w=(e,n,t,o="",a="",i="")=>{var s,r,c;if(!((c=(r=(s=window.ATInternet)==null?void 0:s.Tracker)==null?void 0:r.instances)!=null&&c.length))return;const l={elem:e,name:j(n),type:t,chapter1:o,chapter2:a,chapter3:i};Object.keys(l).forEach(u=>{l[u]===""&&delete l[u]}),window.ATInternet.Tracker.instances[0].click.send(l)},f=()=>{const e=document.getElementById("templates"),n={appBannerContainer:document.getElementById("c-app-banner"),breakingNewsContainer:document.getElementById("c-alert-info"),storageName:"20mnAppBanner",storageDelay:864e5},t=()=>{var a,i;const s=document.querySelector(".c-social");if(s&&(a=n.appBannerContainer)!=null&&a.firstElementChild){const r=n.appBannerContainer.firstElementChild,c=(i=s.offsetHeight)!=null?i:0;r.style.bottom=`${c}px`}},o=()=>{var a,i,s,r,c;if(!n.appBannerContainer||(a=n?.breakingNewsContainer)!=null&&a.innerHTML&&((s=(i=n?.breakingNewsContainer)==null?void 0:i.innerHTML)==null?void 0:s.length)>0)return;n.appBannerContainer.innerHTML+=e.dataset.templateSmartBanner;const l=(r=n.appBannerContainer)==null?void 0:r.querySelector(".c-btn--ghost"),u=(c=n.appBannerContainer)==null?void 0:c.querySelector(".c-smart-banner__btn"),h=()=>{n.appBannerContainer&&(localStorage.setItem(n.storageName,JSON.stringify({opened:!1,time:new Date().getTime()})),n.appBannerContainer.innerHTML="",l&&w(l,"close-app-banner","action"))},g=()=>{localStorage.setItem(n.storageName,JSON.stringify({opened:!1,time:new Date().getTime()})),n.appBannerContainer&&(n.appBannerContainer.innerHTML="");const v=navigator?.userAgent||navigator?.platform||"unknown";u&&w(u,"open-store-app-banner","action"),window.location.href=/iPhone|iPad|iPod/i.test(v)?"https://apps.apple.com/fr/app/20-minutes-news-en-continu/id308834491":"https://play.google.com/store/apps/details?id=com.backelite.vingtminutes&hl=fr"};l?.addEventListener("click",h),u?.addEventListener("click",g),t()};(()=>{const a=JSON.parse(localStorage.getItem(n.storageName)),i=JSON.parse(localStorage.getItem("20mnBreakingNews"));!(i!=null&&i.open)&&n.appBannerContainer&&(a===null||a.opened||a.time+n.storageDelay<Date.now())&&(localStorage.setItem(n.storageName,JSON.stringify({opened:!0})),o())})()},P=()=>{document.readyState!=="loading"?f():window.addEventListener("DOMContentLoaded",()=>{f()})};function R(e,n){const t=n||{};return t.headers=t.headers||new Headers,t.headers.append("Content-Type","application/json"),fetch(e,t).then(o=>{if(o.ok)return o;throw new Error(`Fetch error: ${o.statusText}`)}).then(o=>o.json())}const x=()=>{const e={breakingNewsContainer:document.getElementById("c-alert-info"),appBannerContainer:document.getElementById("c-app-banner"),storageName:"20mnBreakingNews",storageDelay:18e4},n=t=>{var o;const a=JSON.parse(localStorage.getItem(e.storageName));if(t.content.length===0||!e.breakingNewsContainer)return;(o=e?.appBannerContainer)!=null&&o.innerHTML&&e.appBannerContainer.innerHTML.length>0&&(e.appBannerContainer.innerHTML="");let i="";t.image&&(i=`
|
|
2
2
|
<a href="${t.link}" class="flex@xs c-info-banner__visual">
|
|
3
3
|
<img width="147" height="96" src="${t.image}" srcset="${t.image} 130w" sizes="8.125rem" alt="ALERTE INFO" class="c-img c-info-banner__cover">
|
|
4
|
-
</a>`),
|
|
4
|
+
</a>`),e.breakingNewsContainer.innerHTML+=`
|
|
5
5
|
<div class="p-s@xs bg-red@light color-white@light flex@xs items-center@xs justify-center@xs gap-s@xs c-info-banner c-info-banner--alert">
|
|
6
6
|
<div class="flex@xs items-start@xs gap-s@xs c-info-banner__container">
|
|
7
|
-
${
|
|
7
|
+
${i}
|
|
8
8
|
<div class="flex@xs direction-column@xs justify-between@xs c-info-banner__content" direction="column">
|
|
9
9
|
<p class="bg-white@light color-red@light px-xxs-2@xs mb-xxs-2@xs text-s@xs font-weight-bold@xs c-info-banner__title">ALERTE INFO</p>
|
|
10
10
|
<a class="c-link c-link--default" href="${t.link}" target="_self" rel="">
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
</button>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
|
-
</div>`;const s=
|
|
18
|
+
</div>`;const s=e.breakingNewsContainer.querySelector(".c-info-banner__close"),r=e.breakingNewsContainer.querySelector(".c-link--default"),c=e.breakingNewsContainer.querySelector(".c-info-banner__visual"),l=()=>{e.breakingNewsContainer&&(a.open=!1,localStorage.setItem(e.storageName,JSON.stringify(a)),e.breakingNewsContainer.innerHTML="")};s?.addEventListener("click",l),r?.addEventListener("click",l),c?.addEventListener("click",l)};(()=>{var t,o,a,i,s;if(!e.breakingNewsContainer)return;const r=JSON.parse(localStorage.getItem(e.storageName));if(r&&r.time+e.storageDelay>new Date().getTime()){r.open&&n(r.data);return}const c=new Headers;(t=window.envVariables)!=null&&t.apiAuthKey&&c.append("auth-key",window.envVariables.apiAuthKey);const l=(a=(o=e?.breakingNewsContainer)==null?void 0:o.closest("body"))==null?void 0:a.getAttribute("data-api-host"),u=(s=(i=e?.breakingNewsContainer)==null?void 0:i.closest("body"))==null?void 0:s.getAttribute("data-img-host");if(!l||!u)return;const h=`${l}/?id=getBreakingNews&variables=%7B%22brandId%22%3A%22QnJhbmQ6MjBtaW51dGVz%22%7D`;R(h,{headers:c}).then(g=>{var v,E,k,C,N,B,S,_,L,T,I,A,D,H,M,O,F,$;const p=(B=(N=(C=(k=(E=(v=g?.data)==null?void 0:v.brand)==null?void 0:E.node)==null?void 0:k.home)==null?void 0:C.node)==null?void 0:N.homeBreakingNews)==null?void 0:B.node,z=(_=(S=p?.content)==null?void 0:S.editorial_model)==null?void 0:_.toLowerCase(),d=(T=(L=p?.content)==null?void 0:L[z])==null?void 0:T.node;if(!(d!=null&&d.title)||!(d!=null&&d.url_current))throw new Error("No data found...");const m={content:d?.title,link:d?.url_current};if(p!=null&&p.with_photo&&(H=(D=(A=(I=d?.medias)==null?void 0:I[0])==null?void 0:A.photo)==null?void 0:D.node)!=null&&H.id){const K=atob(d.medias[0].photo.node.id).replace("Photo:","");m.image=`${u}/${K}/147x96_${($=(F=(O=(M=d?.medias)==null?void 0:M.photo)==null?void 0:O.node)==null?void 0:F.slug)!=null?$:"media"}`}const J=r?.data===m?r.open:m.content.length>0;localStorage.setItem(e.storageName,JSON.stringify({data:m,time:new Date().getTime(),open:J})),J&&n(m)}).catch(g=>{console.error("20mn> Error while loading the breaking news:",g)})})()},V=()=>{document.readyState!=="loading"?x():window.addEventListener("DOMContentLoaded",()=>{x()})},b=e=>{const n=document.documentElement.scrollTop,t=document.querySelector(".c-header"),o="transform .4s ease";t&&(n>t.offsetHeight?(e.style.transform="translateY(0)",e.style.transition=o):(e.style.transform="translateY(-100%)",e.style.transition=o)),window.removeEventListener("scroll",b.bind(!1,e))},y=()=>{const e=document.querySelector(".c-header-mini");e&&(e.style.transform="translateY(-100%)",window.addEventListener("scroll",b.bind(!1,e)))},Y=()=>{document.readyState!=="loading"?y():window.addEventListener("DOMContentLoaded",()=>{y()})};P(),V(),Y()})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LayoutType } from '@20minutes/hela';
|
|
2
|
+
import { Prefix } from '@/types/helpers';
|
|
3
|
+
export declare abstract class PageManagerHelper<PageProps = Record<string, unknown>, SelectedProps extends keyof PageProps = keyof PageProps, PageFeatures extends string = string, PageContent = string> {
|
|
4
|
+
protected data: Pick<PageProps, SelectedProps>;
|
|
5
|
+
protected layout: LayoutType;
|
|
6
|
+
protected templateActivators: Record<Prefix<'enable', PageFeatures>, boolean>;
|
|
7
|
+
constructor(data: Pick<PageProps, SelectedProps>, layout: LayoutType, templateActivators: Record<Prefix<'enable', PageFeatures>, boolean>);
|
|
8
|
+
abstract transformContent(): PageContent;
|
|
9
|
+
abstract resolveTemplating(): Record<Prefix<'enable', PageFeatures>, boolean>;
|
|
10
|
+
resolve(): {
|
|
11
|
+
content: PageContent;
|
|
12
|
+
features: Record<`enable${PageFeatures}`, boolean>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LayoutType } from '@20minutes/hela';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ArticlePageProps } from '../..';
|
|
4
|
+
import { PageManagerHelper } from '../PageManagerHelper';
|
|
5
|
+
type ArticlePageTemplatingActivators = 'HeaderAd';
|
|
6
|
+
type SelectedProps = 'articleContent' | 'articleCover';
|
|
7
|
+
export type ArticlePageFilteredProps = Pick<ArticlePageProps, SelectedProps>;
|
|
8
|
+
export type ArticleContent = {
|
|
9
|
+
articleContent: React.ReactNode;
|
|
10
|
+
articleCover: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare class ArticlePageManager extends PageManagerHelper<ArticlePageProps, SelectedProps, ArticlePageTemplatingActivators, ArticleContent> {
|
|
13
|
+
constructor(data: ArticlePageFilteredProps, layout: LayoutType);
|
|
14
|
+
transformContent(): ArticleContent;
|
|
15
|
+
resolveTemplating(): {
|
|
16
|
+
enableHeaderAd: boolean;
|
|
17
|
+
};
|
|
18
|
+
handleDesktopInArticleAds(): string;
|
|
19
|
+
handleMobileInArticleAds(): string;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export declare const enum ComponentNameCommon {
|
|
3
3
|
COMMON_HEADER = "common/header",
|
|
4
|
+
COMMON_HEADER_MINI = "common/header-mini",
|
|
4
5
|
COMMON_FOOTER = "common/footer",
|
|
5
6
|
COMMON_MENU = "common/menu",
|
|
6
7
|
COMMON_NEWSLETTER = "common/newsletter",
|
|
@@ -17,7 +17,7 @@ export type PageConfig<TPageName = string, TComponentPage = React.FC<any>, TComp
|
|
|
17
17
|
expiration: number;
|
|
18
18
|
components: PageComponentConfig<TComponentName, TPropName>[];
|
|
19
19
|
};
|
|
20
|
-
export type PageTemplateComponentConfigs = PageComponentConfig<ComponentNameCommon, keyof Pick<PageTemplateProps, 'header' | 'footer' | 'menu'>>[];
|
|
20
|
+
export type PageTemplateComponentConfigs = PageComponentConfig<ComponentNameCommon, keyof Pick<PageTemplateProps, 'header' | 'headerMini' | 'footer' | 'menu'>>[];
|
|
21
21
|
export type ArticlePageConfig = PageConfig<'article', typeof ArticlePage, ComponentNameCommon | ComponentNameRubric | ComponentNameArticle, keyof ArticlePageProps | 'meta'>;
|
|
22
22
|
export type HoroscopePageConfig = PageConfig<'horoscope', typeof HoroscopePage, ComponentNameCommon | ComponentNameRubric | ComponentNameHoroscope, keyof HoroscopePageProps | 'meta'>;
|
|
23
23
|
export type HoroscopeHomePageConfig = PageConfig<'horoscopeHome', typeof HoroscopeHomePage, ComponentNameCommon | ComponentNameRubric | ComponentNameHoroscope, keyof HoroscopeHomePageProps | 'meta'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Prefix<P extends string, S extends string> = `${P}${S}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@20minutes/tyr",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.76",
|
|
4
4
|
"repository": "git@github.com:20minutes/tyr.git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "20 Minutes",
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
"node": ">=16"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@20minutes/hela": "^0.1.
|
|
46
|
+
"@20minutes/hela": "^0.1.68",
|
|
47
47
|
"aws-rum-web": "^1.12.0",
|
|
48
|
+
"html-entities": "^2.3.3",
|
|
48
49
|
"node-html-parser": "^6.1.5",
|
|
49
50
|
"react": "^18.2.0",
|
|
50
51
|
"react-dom": "^18.2.0"
|
|
@@ -63,11 +64,11 @@
|
|
|
63
64
|
"@types/jest": "^29.4.0",
|
|
64
65
|
"@types/react": "^18.0.28",
|
|
65
66
|
"@types/react-dom": "^18.0.11",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
67
|
-
"@typescript-eslint/parser": "^5.
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
|
68
|
+
"@typescript-eslint/parser": "^5.54.0",
|
|
68
69
|
"@vitejs/plugin-react": "^3.1.0",
|
|
69
70
|
"babel-loader": "^9.1.2",
|
|
70
|
-
"eslint": "^8.
|
|
71
|
+
"eslint": "^8.35.0",
|
|
71
72
|
"eslint-config-airbnb": "^19.0.4",
|
|
72
73
|
"eslint-config-prettier": "^8.6.0",
|
|
73
74
|
"eslint-import-resolver-typescript": "^3.5.3",
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
"lint-staged": "^13.1.2",
|
|
83
84
|
"prettier": "^2.8.4",
|
|
84
85
|
"purgecss": "^5.0.0",
|
|
85
|
-
"rollup": "^3.17.
|
|
86
|
+
"rollup": "^3.17.3",
|
|
86
87
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
87
88
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
88
89
|
"rollup-plugin-visualizer": "^5.9.0",
|