ha-nitrous-personalization 0.0.2 → 0.0.4

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={"recommended-for-you":"user_personalization",trending:"trending_now",ymal:"similar_items"};exports.useCaseMap=e;
@@ -0,0 +1 @@
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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./CzA4yy-l.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./DUOWEPPk.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;
@@ -0,0 +1 @@
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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Cl5f7YcH.cjs"),t=require("./CzA4yy-l.cjs");exports.PersonalizationWidget=e.PersonalizationWidget;exports.getPersonalizationData=t.getPersonalizationData;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./DrtFMAn_.cjs"),t=require("./CzA4yy-l.cjs");exports.PersonalizationWidget=e.PersonalizationWidget;exports.getPersonalizationData=t.getPersonalizationData;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=e=>{var i;const o=`; ${document.cookie}`.split(`; ${e}=`);if(o.length===2)return(i=o.pop())==null?void 0:i.split(";").shift()},n=()=>{const e=r("nit");let t;try{e&&(t=JSON.parse(decodeURIComponent(e)))}catch{}return t},c=()=>{var e;return(e=n())==null?void 0:e.deviceId};exports.getDeviceId=c;exports.getNitrousCookie=n;
@@ -0,0 +1,23 @@
1
+ const n = (t) => {
2
+ var i;
3
+ const o = `; ${document.cookie}`.split(`; ${t}=`);
4
+ if (o.length === 2)
5
+ return (i = o.pop()) == null ? void 0 : i.split(";").shift();
6
+ }, r = () => {
7
+ const t = n("nit");
8
+ let e;
9
+ try {
10
+ t && (e = JSON.parse(
11
+ decodeURIComponent(t)
12
+ ));
13
+ } catch {
14
+ }
15
+ return e;
16
+ }, c = () => {
17
+ var t;
18
+ return (t = r()) == null ? void 0 : t.deviceId;
19
+ };
20
+ export {
21
+ c as getDeviceId,
22
+ r as getNitrousCookie
23
+ };
@@ -0,0 +1,14 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { usePersonalizationData as n } from "./DbRLS8rI.js";
3
+ import { PersonalizationGrid as e } from "./DYPQQ1rv.js";
4
+ const l = ({ brand: o, contentType: t, model: a }) => {
5
+ const r = n({
6
+ brand: o,
7
+ contentType: t,
8
+ model: a
9
+ });
10
+ return /* @__PURE__ */ i(e, { data: r });
11
+ };
12
+ export {
13
+ l as PersonalizationWidget
14
+ };
@@ -0,0 +1,19 @@
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
+ };
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1,33 @@
1
+ import { getPersonalizationData as f } from "./BUU6fvy1.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
+ };
@@ -0,0 +1,8 @@
1
+ const e = {
2
+ "recommended-for-you": "user_personalization",
3
+ trending: "trending_now",
4
+ ymal: "similar_items"
5
+ };
6
+ export {
7
+ e as useCaseMap
8
+ };
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PersonalizationWidget as a } from "./BOgMIZfR.js";
1
+ import { PersonalizationWidget as a } from "./CzNdIE9n.js";
2
2
  import { getPersonalizationData as r } from "./BUU6fvy1.js";
3
3
  export {
4
4
  a as PersonalizationWidget,
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/eslint-plugin-nitrous": "0.0.12",
18
- "@motortrend/prettier-config-nitrous": "0.0.4"
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.2",
44
+ "version": "0.0.4",
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 n=t=>{var i;const e=`; ${document.cookie}`.split(`; ${t}=`);if(e.length===2)return(i=e.pop())==null?void 0:i.split(";").shift()},r=()=>{const t=n("nit");let o;try{t&&(o=JSON.parse(decodeURIComponent(t)))}catch{}return o};exports.getNitrousCookie=r;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./CzA4yy-l.cjs"),m=require("./BrLBNZCr.cjs"),o=require("react"),f=require("./DeikC2LX.cjs"),z={"recommended-for-you":"user_personalization",trending:"trending_now",ymal:"similar_items"},P=({apiKey:a,brand:n,contentType:s="article",data:t,model:r})=>{const[i,l]=o.useState(void 0);return o.useEffect(()=>{(async()=>{var e;if(t)l(t);else if(s&&r&&a&&n){const d=z[r],c=(e=m.getNitrousCookie())==null?void 0:e.deviceId;if(console.log("fetching data",d,c),c){const u=await g.getPersonalizationData(a,{brand:n,type:s,useCase:d,userId:c});console.log("data",u),t&&l(u)}}})()},[a,t,s,r,n]),console.log("personalization data",i),o.createElement("div",{"data-id":"personalization-widget"},i==null?void 0:i.data.recommendations.map(e=>o.createElement(f.PersonalizationWidgetItem,{item:e,key:e.id})))};exports.PersonalizationWidget=P;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),o=({item:e})=>{var r,a,n,l;return t.createElement("a",{"data-id":"personalization-item",href:(n=(a=(r=e==null?void 0:e.metadata)==null?void 0:r.links)==null?void 0:a.frontend)==null?void 0:n.url},t.createElement("img",{src:(l=e.media)==null?void 0:l[0].url}),t.createElement("h6",null,e.title),t.createElement("div",null,e.publish_from))};exports.PersonalizationWidgetItem=o;
@@ -1,33 +0,0 @@
1
- import { getPersonalizationData as f } from "./BUU6fvy1.js";
2
- import { getNitrousCookie as g } from "./DHe8M36R.js";
3
- import d, { useState as u, useEffect as p } from "react";
4
- import { PersonalizationWidgetItem as z } from "./CPEbR5_0.js";
5
- const P = {
6
- "recommended-for-you": "user_personalization",
7
- trending: "trending_now",
8
- ymal: "similar_items"
9
- }, E = ({ apiKey: i, brand: a, contentType: s = "article", data: o, model: n }) => {
10
- const [t, c] = u(void 0);
11
- return p(() => {
12
- (async () => {
13
- var e;
14
- if (o)
15
- c(o);
16
- else if (s && n && i && a) {
17
- const l = P[n], r = (e = g()) == null ? void 0 : e.deviceId;
18
- if (console.log("fetching data", l, r), r) {
19
- const m = await f(i, {
20
- brand: a,
21
- type: s,
22
- useCase: l,
23
- userId: r
24
- });
25
- console.log("data", m), o && c(m);
26
- }
27
- }
28
- })();
29
- }, [i, o, s, n, a]), console.log("personalization data", t), /* @__PURE__ */ d.createElement("div", { "data-id": "personalization-widget" }, t == null ? void 0 : t.data.recommendations.map((e) => /* @__PURE__ */ d.createElement(z, { item: e, key: e.id })));
30
- };
31
- export {
32
- E as PersonalizationWidget
33
- };
@@ -1,17 +0,0 @@
1
- import r from "react";
2
- const c = ({ item: e }) => {
3
- var t, a, l, n;
4
- return /* @__PURE__ */ r.createElement(
5
- "a",
6
- {
7
- "data-id": "personalization-item",
8
- href: (l = (a = (t = e == null ? void 0 : e.metadata) == null ? void 0 : t.links) == null ? void 0 : a.frontend) == null ? void 0 : l.url
9
- },
10
- /* @__PURE__ */ r.createElement("img", { src: (n = e.media) == null ? void 0 : n[0].url }),
11
- /* @__PURE__ */ r.createElement("h6", null, e.title),
12
- /* @__PURE__ */ r.createElement("div", null, e.publish_from)
13
- );
14
- };
15
- export {
16
- c as PersonalizationWidgetItem
17
- };
@@ -1,19 +0,0 @@
1
- const n = (t) => {
2
- var i;
3
- const e = `; ${document.cookie}`.split(`; ${t}=`);
4
- if (e.length === 2)
5
- return (i = e.pop()) == null ? void 0 : i.split(";").shift();
6
- }, r = () => {
7
- const t = n("nit");
8
- let o;
9
- try {
10
- t && (o = JSON.parse(
11
- decodeURIComponent(t)
12
- ));
13
- } catch {
14
- }
15
- return o;
16
- };
17
- export {
18
- r as getNitrousCookie
19
- };