ha-nitrous-personalization 0.0.8 → 0.0.10

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=async t=>{try{if(!t)return;const a=new URLSearchParams(t);return await(await fetch(`https://motortrend.com/nwapi/personalized?${a.toString()}`,{method:"GET"})).json()}catch{}};exports.getPersonalizationData=e;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./fy0r-ppP.cjs"),r=require("./D8aAR90g.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./zR1WquhW.cjs"),r=require("./iLKu5V_2.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=({item:t})=>e.jsxs("a",{"data-id":"personalization-item",href:t.link,children:[e.jsx("img",{alt:t.title,src:t.thumbnailUrl}),e.jsx("h6",{children:t.title})]});exports.PersonalizationWidgetItem=i;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./L4QvdLMR.cjs"),r=({data:i})=>e.jsxs("div",{"data-id":"personalization-widget",children:[e.jsx("h3",{children:"You May Also Like"}),i==null?void 0:i.map(n=>e.jsx(o.PersonalizationWidgetItem,{item:n},n.id))]});exports.PersonalizationGrid=r;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./CS-I99k3.cjs"),e=require("./fy0r-ppP.cjs"),t=require("./Cpvude1L.cjs");exports.PersonalizationWidget=a.PersonalizationWidget;exports.usePersonalizationData=e.usePersonalizationData;exports.getPersonalizationData=t.getPersonalizationData;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./C-iRPpvv.cjs"),e=require("./zR1WquhW.cjs"),t=require("./BsDqoYyp.cjs");exports.PersonalizationWidget=a.PersonalizationWidget;exports.usePersonalizationData=e.usePersonalizationData;exports.getPersonalizationData=t.getPersonalizationData;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./BsDqoYyp.cjs"),l=require("./BwR_6yUe.cjs"),d=require("./jsr503aW.cjs"),n=require("react"),f=({brand:e,contentType:t="article",model:a="recommended-for-you"})=>{const[r,c]=n.useState(void 0);return n.useEffect(()=>{(async()=>{if(t&&a&&e){const i=l.useCaseMap[a],s=d.getDeviceId();if(console.log("fetching data",i,s),s){const o=await u.getPersonalizationData({brand:e,type:t,useCase:i,userId:s});console.log("data",o),o&&c(o)}}})()},[e,t,a]),r};exports.usePersonalizationData=f;
@@ -0,0 +1,9 @@
1
+ import { jsxs as e, jsx as r } from "react/jsx-runtime";
2
+ import { PersonalizationWidgetItem as n } from "./CZPx6t8C.js";
3
+ const l = ({ data: i }) => /* @__PURE__ */ e("div", { "data-id": "personalization-widget", children: [
4
+ /* @__PURE__ */ r("h3", { children: "You May Also Like" }),
5
+ i == null ? void 0 : i.map((o) => /* @__PURE__ */ r(n, { item: o }, o.id))
6
+ ] });
7
+ export {
8
+ l as PersonalizationGrid
9
+ };
@@ -1,6 +1,6 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { usePersonalizationData as n } from "./C80AuR1w.js";
3
- import { PersonalizationGrid as e } from "./DYPQQ1rv.js";
2
+ import { usePersonalizationData as n } from "./DxK9e8W7.js";
3
+ import { PersonalizationGrid as e } from "./0XdfH2np.js";
4
4
  const l = ({ brand: o, contentType: t, model: a }) => {
5
5
  const r = n({
6
6
  brand: o,
@@ -0,0 +1,8 @@
1
+ import { jsxs as r, jsx as i } from "react/jsx-runtime";
2
+ const n = ({ item: t }) => /* @__PURE__ */ r("a", { "data-id": "personalization-item", href: t.link, children: [
3
+ /* @__PURE__ */ i("img", { alt: t.title, src: t.thumbnailUrl }),
4
+ /* @__PURE__ */ i("h6", { children: t.title })
5
+ ] });
6
+ export {
7
+ n as PersonalizationWidgetItem
8
+ };
@@ -0,0 +1,30 @@
1
+ import { getPersonalizationData as c } from "./bmmRYB8q.js";
2
+ import { useCaseMap as f } from "./FkYTBHnm.js";
3
+ import { getDeviceId as m } from "./BTMNbCyp.js";
4
+ import { useState as u, useEffect as l } from "react";
5
+ const z = ({
6
+ brand: a,
7
+ contentType: o = "article",
8
+ model: t = "recommended-for-you"
9
+ }) => {
10
+ const [r, n] = u(void 0);
11
+ return l(() => {
12
+ (async () => {
13
+ if (o && t && a) {
14
+ const s = f[t], e = m();
15
+ if (console.log("fetching data", s, e), e) {
16
+ const i = await c({
17
+ brand: a,
18
+ type: o,
19
+ useCase: s,
20
+ userId: e
21
+ });
22
+ console.log("data", i), i && n(i);
23
+ }
24
+ }
25
+ })();
26
+ }, [a, o, t]), r;
27
+ };
28
+ export {
29
+ z as usePersonalizationData
30
+ };
@@ -0,0 +1,21 @@
1
+ const o = async (t) => {
2
+ try {
3
+ if (!t)
4
+ return;
5
+ const a = new URLSearchParams(t);
6
+ return await (await fetch(
7
+ `https://motortrend.com/nwapi/personalized?${a.toString()}`,
8
+ // `${import.meta.env.VITE_NITROUS_API_URL}/personalization?${queryParams.toString()}`,
9
+ {
10
+ // headers: {
11
+ // 'X-API-Key': import.meta.env.VITE_NITROUS_API_KEY,
12
+ // },
13
+ method: "GET"
14
+ }
15
+ )).json();
16
+ } catch {
17
+ }
18
+ };
19
+ export {
20
+ o as getPersonalizationData
21
+ };
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { PersonalizationWidget as t } from "./C6QPIeZz.js";
2
- import { usePersonalizationData as r } from "./C80AuR1w.js";
3
- import { getPersonalizationData as n } from "./Wumphm1E.js";
1
+ import { PersonalizationWidget as t } from "./BCt7LdUs.js";
2
+ import { usePersonalizationData as r } from "./DxK9e8W7.js";
3
+ import { getPersonalizationData as n } from "./bmmRYB8q.js";
4
4
  export {
5
5
  t as PersonalizationWidget,
6
6
  n as getPersonalizationData,
package/package.json CHANGED
@@ -41,7 +41,7 @@
41
41
  }
42
42
  },
43
43
  "type": "module",
44
- "version": "0.0.8",
44
+ "version": "0.0.10",
45
45
  "scripts": {
46
46
  "build": "tsc --noEmit && vite build",
47
47
  "build:analyze": "vite-bundle-visualizer",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=async(o,e)=>{try{if(!e)return;const a=new URLSearchParams(e),t=await(await fetch(`https://eq47czqy1l.execute-api.us-west-2.amazonaws.com/v1/personalization?${a.toString()}`,{method:"GET"})).json();if(t.error)throw new Error(`Failed to fetch personalization data: ${JSON.stringify(t.error)}`);return t}catch{}};exports.getPersonalizationData=r;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./aa5MVVyd.cjs"),r=({data:e})=>n.jsx("div",{"data-id":"personalization-widget",children:e==null?void 0:e.data.recommendations.map(i=>n.jsx(o.PersonalizationWidgetItem,{item:i},i.id))});exports.PersonalizationGrid=r;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=({item:e})=>{var t,n,i,l;return r.jsxs("a",{"data-id":"personalization-item",href:(i=(n=(t=e==null?void 0:e.metadata)==null?void 0:t.links)==null?void 0:n.frontend)==null?void 0:i.url,children:[r.jsx("img",{alt:e.title,src:(l=e.media)==null?void 0:l[0].url,style:{}}),r.jsx("h6",{children:e.title}),r.jsx("div",{children:e.publish_from})]})};exports.PersonalizationWidgetItem=s;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./Cpvude1L.cjs"),f=require("./BwR_6yUe.cjs"),l=require("./jsr503aW.cjs"),c=require("react"),d=({brand:e,contentType:t="article",model:a="recommended-for-you"})=>{const[n,r]=c.useState(void 0);return c.useEffect(()=>{(async()=>{if(t&&a&&e){const i=f.useCaseMap[a],s=l.getDeviceId();if(console.log("fetching data",i,s),s){const o=await u.getPersonalizationData("421efbf3760c201c62c2eddb51fbbe3b",{brand:e,type:t,useCase:i,userId:s});console.log("data",o),o&&r(o)}}})()},[e,t,a]),n};exports.usePersonalizationData=d;
@@ -1,33 +0,0 @@
1
- import { getPersonalizationData as f } from "./Wumphm1E.js";
2
- import { useCaseMap as n } from "./FkYTBHnm.js";
3
- import { getDeviceId as d } from "./BTMNbCyp.js";
4
- import { useState as m, useEffect as u } from "react";
5
- const z = ({
6
- brand: a,
7
- contentType: e = "article",
8
- model: o = "recommended-for-you"
9
- }) => {
10
- const [r, c] = m(void 0);
11
- return u(() => {
12
- (async () => {
13
- if (e && o && a) {
14
- const s = n[o], t = d();
15
- if (console.log("fetching data", s, t), t) {
16
- const i = await f(
17
- "421efbf3760c201c62c2eddb51fbbe3b",
18
- {
19
- brand: a,
20
- type: e,
21
- useCase: s,
22
- userId: t
23
- }
24
- );
25
- console.log("data", i), i && c(i);
26
- }
27
- }
28
- })();
29
- }, [a, e, o]), r;
30
- };
31
- export {
32
- z as usePersonalizationData
33
- };
@@ -1,19 +0,0 @@
1
- import { jsxs as i, jsx as l } from "react/jsx-runtime";
2
- const s = ({ item: r }) => {
3
- var a, n, t, d;
4
- return /* @__PURE__ */ i(
5
- "a",
6
- {
7
- "data-id": "personalization-item",
8
- href: (t = (n = (a = r == null ? void 0 : r.metadata) == null ? void 0 : a.links) == null ? void 0 : n.frontend) == null ? void 0 : t.url,
9
- children: [
10
- /* @__PURE__ */ l("img", { alt: r.title, src: (d = r.media) == null ? void 0 : d[0].url, style: {} }),
11
- /* @__PURE__ */ l("h6", { children: r.title }),
12
- /* @__PURE__ */ l("div", { children: r.publish_from })
13
- ]
14
- }
15
- );
16
- };
17
- export {
18
- s as PersonalizationWidgetItem
19
- };
@@ -1,6 +0,0 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { PersonalizationWidgetItem as n } from "./D5_A9eyN.js";
3
- const m = ({ data: i }) => /* @__PURE__ */ r("div", { "data-id": "personalization-widget", children: i == null ? void 0 : i.data.recommendations.map((o) => /* @__PURE__ */ r(n, { item: o }, o.id)) });
4
- export {
5
- m as PersonalizationGrid
6
- };
@@ -1,21 +0,0 @@
1
- const n = async (r, a) => {
2
- try {
3
- if (!a)
4
- return;
5
- const e = new URLSearchParams(a), t = await (await fetch(
6
- `https://eq47czqy1l.execute-api.us-west-2.amazonaws.com/v1/personalization?${e.toString()}`,
7
- {
8
- method: "GET"
9
- }
10
- )).json();
11
- if (t.error)
12
- throw new Error(
13
- `Failed to fetch personalization data: ${JSON.stringify(t.error)}`
14
- );
15
- return t;
16
- } catch {
17
- }
18
- };
19
- export {
20
- n as getPersonalizationData
21
- };