ha-nitrous-personalization 0.0.0 → 0.0.1

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../../utils/api.cjs"),m=require("../../utils/etc.cjs"),i=require("react"),f=require("./PersonalizationWidgetItem.cjs"),z={"recommended-for-you":"user_personalization",trending:"trending_now",ymal:"similar_items"},P=({apiKey:o,brand:s,contentType:n="article",data:t,model:a})=>{const[r,l]=i.useState(void 0);return i.useEffect(()=>{(async()=>{var e;if(t)l(t);else if(n&&a&&o&&s){const d=z[a],c=(e=m.getNitrousCookie())==null?void 0:e.deviceId;if(console.log("fetching data",d,c),c){const u=await g.getPersonalizationData(o,{brand:s,type:n,useCase:d,userId:c});console.log("data",u),t&&l(u)}}})()},[o,t,n,a,s]),i.createElement("div",{"data-id":"personalization-widget"},r==null?void 0:r.data.recommendations.map(e=>i.createElement(f.PersonalizationWidgetItem,{item:e,key:e.id})))};exports.PersonalizationWidget=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../../utils/api.cjs"),m=require("../../utils/etc.cjs"),o=require("react"),f=require("./PersonalizationWidgetItem.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,32 +1,32 @@
1
1
  import { getPersonalizationData as f } from "../../utils/api.js";
2
2
  import { getNitrousCookie as g } from "../../utils/etc.js";
3
- import l, { useState as u, useEffect as p } from "react";
3
+ import d, { useState as u, useEffect as p } from "react";
4
4
  import { PersonalizationWidgetItem as z } from "./PersonalizationWidgetItem.js";
5
5
  const P = {
6
6
  "recommended-for-you": "user_personalization",
7
7
  trending: "trending_now",
8
8
  ymal: "similar_items"
9
- }, E = ({ apiKey: o, brand: i, contentType: s = "article", data: t, model: a }) => {
10
- const [r, c] = u(void 0);
9
+ }, E = ({ apiKey: i, brand: a, contentType: s = "article", data: o, model: n }) => {
10
+ const [t, c] = u(void 0);
11
11
  return p(() => {
12
12
  (async () => {
13
13
  var e;
14
- if (t)
15
- c(t);
16
- else if (s && a && o && i) {
17
- const m = P[a], n = (e = g()) == null ? void 0 : e.deviceId;
18
- if (console.log("fetching data", m, n), n) {
19
- const d = await f(o, {
20
- brand: i,
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
21
  type: s,
22
- useCase: m,
23
- userId: n
22
+ useCase: l,
23
+ userId: r
24
24
  });
25
- console.log("data", d), t && c(d);
25
+ console.log("data", m), o && c(m);
26
26
  }
27
27
  }
28
28
  })();
29
- }, [o, t, s, a, i]), /* @__PURE__ */ l.createElement("div", { "data-id": "personalization-widget" }, r == null ? void 0 : r.data.recommendations.map((e) => /* @__PURE__ */ l.createElement(z, { item: e, key: e.id })));
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
30
  };
31
31
  export {
32
32
  E 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/prettier-config-nitrous": "0.0.4",
18
- "@motortrend/eslint-plugin-nitrous": "0.0.12"
17
+ "@motortrend/eslint-plugin-nitrous": "0.0.12",
18
+ "@motortrend/prettier-config-nitrous": "0.0.4"
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.0",
44
+ "version": "0.0.1",
45
45
  "scripts": {
46
46
  "build": "tsc --noEmit && vite build",
47
47
  "build:analyze": "vite-bundle-visualizer",