ha-nitrous-personalization 0.0.18 → 0.0.20
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/cjs/{B5NgqRQS.cjs → Bm3J2yTc.cjs} +1 -1
- package/dist/cjs/DHftg2Hg.cjs +1 -0
- package/dist/cjs/{BpfZC2Wc.cjs → Da-qHf6H.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/{CEeIi5_p.js → BM0A0N8-.js} +1 -1
- package/dist/esm/{LHxJC3pU.js → C0pAjWy-.js} +1 -1
- package/dist/esm/{DTVL7ZrY.js → DmWXT6Bq.js} +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/types/index.d.ts +66 -11
- package/package.json +3 -3
- package/dist/cjs/5ApNfbfp.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./DHftg2Hg.cjs"),l=require("./BwR_6yUe.cjs"),d=require("./jsr503aW.cjs"),r=require("react"),D=({brand:e,contentId:s,contentType:t="article",model:a="recommended-for-you"})=>{const[n,c]=r.useState(void 0);return r.useEffect(()=>{(async()=>{if(t&&a&&e){const u=l.useCaseMap[a],i=d.getDeviceId();if(i){const o=await f.getPersonalizationData({brand:e,itemId:s,type:t,useCase:u,userId:i});o&&c(o)}}})()},[e,s,t,a]),n};exports.usePersonalizationData=D;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=async e=>{var n;try{if(!e)return;const{brand:t,isProd:a,itemId:s,...o}=e,r=e.isProd?"https://personalize.motortrend.com":"https://personalize-stage.motortrend.com",d=e.isProd?"421efbf3760c201c62c2eddb51fbbe3b":"84556b8bceae7b56b299a199b8b1018d",c=`${t}-${e.type}-${e.itemId}`,m=new URLSearchParams({...o,brand:t,itemId:c}),i=await(await fetch(`${r}/recommendations?${m.toString()}`,{headers:{"api-key":d},method:"GET"})).json();return l((n=i==null?void 0:i.data)==null?void 0:n.recommendations)}catch{}},l=e=>{if(Array.isArray(e))return e.reduce((n,t)=>{var a,s,o,r;return t.__typename==="Content"&&(!((s=(a=t.media)==null?void 0:a[0])!=null&&s.url)||!((r=(o=t.metadata)==null?void 0:o.links)!=null&&r.frontend.url))?n:[...n,t]},[])};exports.getPersonalizationData=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./Bm3J2yTc.cjs"),r=require("./DzGaSnJW.cjs"),s=({brand:e,contentType:t,model:i})=>{const a=o.usePersonalizationData({brand:e,contentType:t,model:i});return n.jsx(r.PersonalizationGrid,{data:a})};exports.PersonalizationWidget=s;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./Da-qHf6H.cjs"),e=require("./Bm3J2yTc.cjs"),t=require("./DHftg2Hg.cjs");exports.PersonalizationWidget=a.PersonalizationWidget;exports.usePersonalizationData=e.usePersonalizationData;exports.getPersonalizationData=t.getPersonalizationData;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPersonalizationData as c } from "./
|
|
1
|
+
import { getPersonalizationData as c } from "./C0pAjWy-.js";
|
|
2
2
|
import { useCaseMap as n } from "./FkYTBHnm.js";
|
|
3
3
|
import { getDeviceId as u } from "./BTMNbCyp.js";
|
|
4
4
|
import { useState as p, useEffect as D } from "react";
|
|
@@ -5,7 +5,7 @@ const l = async (e) => {
|
|
|
5
5
|
return;
|
|
6
6
|
const { brand: t, isProd: s, itemId: a, ...o } = e, r = e.isProd ? "https://personalize.motortrend.com" : "https://personalize-stage.motortrend.com", d = e.isProd ? "421efbf3760c201c62c2eddb51fbbe3b" : "84556b8bceae7b56b299a199b8b1018d", c = `${t}-${e.type}-${e.itemId}`, m = new URLSearchParams({
|
|
7
7
|
...o,
|
|
8
|
-
|
|
8
|
+
brand: t,
|
|
9
9
|
itemId: c
|
|
10
10
|
}), i = await (await fetch(
|
|
11
11
|
`${r}/recommendations?${m.toString()}`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { usePersonalizationData as n } from "./
|
|
2
|
+
import { usePersonalizationData as n } from "./BM0A0N8-.js";
|
|
3
3
|
import { PersonalizationGrid as e } from "./DcA_qSqr.js";
|
|
4
4
|
const l = ({ brand: o, contentType: t, model: a }) => {
|
|
5
5
|
const r = n({
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PersonalizationWidget as t } from "./
|
|
2
|
-
import { usePersonalizationData as r } from "./
|
|
3
|
-
import { getPersonalizationData as n } from "./
|
|
1
|
+
import { PersonalizationWidget as t } from "./DmWXT6Bq.js";
|
|
2
|
+
import { usePersonalizationData as r } from "./BM0A0N8-.js";
|
|
3
|
+
import { getPersonalizationData as n } from "./C0pAjWy-.js";
|
|
4
4
|
export {
|
|
5
5
|
t as PersonalizationWidget,
|
|
6
6
|
n as getPersonalizationData,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
|
+
import { GetPersonalizationDataItem } from '../types/Api';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
declare type GetPersonalizationCarItem = {
|
|
5
|
+
vehicle_tags: Array<{
|
|
6
|
+
model: {
|
|
7
|
+
price: {
|
|
8
|
+
high: number;
|
|
9
|
+
low: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
} & GetPersonalizationContentItem;
|
|
4
14
|
|
|
5
|
-
declare
|
|
15
|
+
declare interface GetPersonalizationContentItem {
|
|
6
16
|
__typename: 'Content';
|
|
7
17
|
id: string;
|
|
8
|
-
media: {
|
|
18
|
+
media: Array<{
|
|
9
19
|
url: string;
|
|
10
|
-
}
|
|
11
|
-
metadata
|
|
20
|
+
}>;
|
|
21
|
+
metadata?: {
|
|
12
22
|
dek: string;
|
|
13
|
-
links
|
|
23
|
+
links?: {
|
|
14
24
|
frontend: {
|
|
15
25
|
url: string;
|
|
16
26
|
};
|
|
@@ -18,32 +28,77 @@ declare type GetPersonalizationDataItem = {
|
|
|
18
28
|
};
|
|
19
29
|
publish_from: string;
|
|
20
30
|
title: string;
|
|
21
|
-
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare const getPersonalizationData: (params: GetPersonalizationDataParams) => Promise<GetPersonalizationDataResponse["data"]["recommendations"] | undefined>;
|
|
34
|
+
|
|
35
|
+
declare type GetPersonalizationDataItem_2 = GetPersonalizationCarItem | GetPersonalizationContentItem | GetPersonalizationVideoItem;
|
|
22
36
|
|
|
23
37
|
declare type GetPersonalizationDataParams = {
|
|
24
38
|
brand: string;
|
|
39
|
+
isProd?: boolean;
|
|
40
|
+
itemId?: string;
|
|
25
41
|
type: 'article' | 'car' | 'video';
|
|
26
42
|
useCase: PersonalizationUseCase;
|
|
27
|
-
userId
|
|
43
|
+
userId?: string;
|
|
28
44
|
};
|
|
29
45
|
|
|
30
46
|
declare type GetPersonalizationDataResponse = {
|
|
31
47
|
data: {
|
|
32
|
-
recommendations:
|
|
48
|
+
recommendations: GetPersonalizationDataItem_2[];
|
|
33
49
|
};
|
|
34
50
|
error?: unknown;
|
|
35
51
|
};
|
|
36
52
|
|
|
53
|
+
declare interface GetPersonalizationVideoItem {
|
|
54
|
+
__typename: 'Video';
|
|
55
|
+
description: string;
|
|
56
|
+
duration: number;
|
|
57
|
+
id: string;
|
|
58
|
+
preview_image: string;
|
|
59
|
+
published_at: string;
|
|
60
|
+
slug: string;
|
|
61
|
+
title: string;
|
|
62
|
+
transcodings: VideoTranscoding[];
|
|
63
|
+
}
|
|
64
|
+
|
|
37
65
|
declare type PersonalizationUseCase = 'similar_items' | 'trending_now' | 'user_personalization';
|
|
38
66
|
|
|
39
67
|
export declare const PersonalizationWidget: FunctionComponent<PersonalizationWidgetProps>;
|
|
40
68
|
|
|
41
69
|
declare type PersonalizationWidgetProps = {
|
|
42
|
-
|
|
70
|
+
brand: string;
|
|
71
|
+
contentType?: GetPersonalizationDataParams['type'];
|
|
72
|
+
model?: 'recommended-for-you' | 'trending' | 'ymal';
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export declare const usePersonalizationData: ({ brand, contentId, contentType, model, }: UsePersonalizationDataProps) => GetPersonalizationDataItem[] | undefined;
|
|
76
|
+
|
|
77
|
+
declare type UsePersonalizationDataProps = {
|
|
43
78
|
brand?: string;
|
|
79
|
+
contentId?: string;
|
|
44
80
|
contentType?: GetPersonalizationDataParams['type'];
|
|
45
|
-
data?: GetPersonalizationDataResponse;
|
|
46
81
|
model?: 'recommended-for-you' | 'trending' | 'ymal';
|
|
47
82
|
};
|
|
48
83
|
|
|
84
|
+
declare type VideoTranscoding = {
|
|
85
|
+
bitrate?: string;
|
|
86
|
+
duration?: number;
|
|
87
|
+
duration_millis?: number;
|
|
88
|
+
file_size?: number;
|
|
89
|
+
frame_rate?: string;
|
|
90
|
+
full_url?: string;
|
|
91
|
+
height?: number;
|
|
92
|
+
id?: string;
|
|
93
|
+
key?: string;
|
|
94
|
+
mapped_preset_name?: string;
|
|
95
|
+
preset_id?: string;
|
|
96
|
+
preset_name?: string;
|
|
97
|
+
status?: string;
|
|
98
|
+
thumbnail_pattern?: string;
|
|
99
|
+
url?: string;
|
|
100
|
+
watermarks?: unknown[];
|
|
101
|
+
width?: number;
|
|
102
|
+
};
|
|
103
|
+
|
|
49
104
|
export { }
|
package/package.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"vite-bundle-visualizer": "~1.2.1",
|
|
15
15
|
"vite-plugin-dts": "~4.5.3",
|
|
16
16
|
"vite-tsconfig-paths": "^5.1.4",
|
|
17
|
-
"@motortrend/
|
|
18
|
-
"@motortrend/
|
|
17
|
+
"@motortrend/prettier-config-nitrous": "0.0.4",
|
|
18
|
+
"@motortrend/eslint-plugin-nitrous": "0.0.12"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=19",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"type": "module",
|
|
44
|
-
"version": "0.0.
|
|
44
|
+
"version": "0.0.20",
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc --noEmit && vite build",
|
|
47
47
|
"build:analyze": "vite-bundle-visualizer",
|
package/dist/cjs/5ApNfbfp.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=async e=>{var n;try{if(!e)return;const{brand:t,isProd:a,itemId:s,...o}=e,r=e.isProd?"https://personalize.motortrend.com":"https://personalize-stage.motortrend.com",d=e.isProd?"421efbf3760c201c62c2eddb51fbbe3b":"84556b8bceae7b56b299a199b8b1018d",c=`${t}-${e.type}-${e.itemId}`,b=new URLSearchParams({...o,brandid:t,itemId:c}),i=await(await fetch(`${r}/recommendations?${b.toString()}`,{headers:{"api-key":d},method:"GET"})).json();return l((n=i==null?void 0:i.data)==null?void 0:n.recommendations)}catch{}},l=e=>{if(Array.isArray(e))return e.reduce((n,t)=>{var a,s,o,r;return t.__typename==="Content"&&(!((s=(a=t.media)==null?void 0:a[0])!=null&&s.url)||!((r=(o=t.metadata)==null?void 0:o.links)!=null&&r.frontend.url))?n:[...n,t]},[])};exports.getPersonalizationData=m;
|