@rakutenanalytics/rat-react 0.3.1-rc.716ed0a → 0.3.2-rel.0

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/index.js CHANGED
@@ -1791,7 +1791,7 @@ class We {
1791
1791
  this.ral.processImmediate();
1792
1792
  }
1793
1793
  }
1794
- const Ge = "0.3.1-rc.716ed0a", je = "rat-react", Ye = Ge;
1794
+ const Ge = "0.3.2-rel.0", je = "rat-react", Ye = Ge;
1795
1795
  function M(n) {
1796
1796
  return new We({
1797
1797
  ...n,
@@ -1799,46 +1799,45 @@ function M(n) {
1799
1799
  sdkVersion: Ye
1800
1800
  });
1801
1801
  }
1802
- const ze = (n) => {
1802
+ const $e = (n) => {
1803
1803
  const { accountId: e, serviceId: s } = n, [_, t] = F(null);
1804
1804
  return R(() => {
1805
1805
  const r = M(n);
1806
1806
  t(r);
1807
1807
  }, [e, s]), _;
1808
- }, ae = se(
1809
- void 0
1810
- ), Xe = () => {
1811
- const n = ce(ae);
1808
+ }, Qe = "useTrackerContext must be used within a TrackerProvider";
1809
+ function xe(n) {
1812
1810
  if (!n)
1813
- throw new Error("useTrackerContext must be used within a TrackerProvider");
1811
+ throw new Error(Qe);
1814
1812
  return n;
1815
- }, Je = ({
1813
+ }
1814
+ const ae = se(
1815
+ void 0
1816
+ ), Ze = () => {
1817
+ const n = ce(ae);
1818
+ return xe(n);
1819
+ };
1820
+ function qe(n, e) {
1821
+ const s = {};
1822
+ return n.forEach(({ key: _, options: t }) => {
1823
+ s[_] = e(t);
1824
+ }), s;
1825
+ }
1826
+ const et = ({
1816
1827
  children: n,
1817
1828
  defaultTrackers: e = []
1818
1829
  }) => {
1819
1830
  const [s, _] = F({});
1820
1831
  R(() => {
1821
- const a = {};
1822
- e.forEach(({ key: i, options: o }) => {
1823
- a[i] = M(o);
1824
- }), _(a);
1832
+ _(qe(e, M));
1825
1833
  }, [e]);
1826
1834
  const t = (a, i) => {
1827
1835
  const o = M(i);
1828
1836
  _((c) => ({ ...c, [a]: o }));
1829
- }, r = (a) => {
1830
- const i = s[a];
1831
- if (!i) {
1832
- const o = Object.keys(s);
1833
- console.warn(
1834
- `Tracker with key "${a}" not found. Available trackers: ${o.length > 0 ? o.join(", ") : "none"}`
1835
- );
1836
- }
1837
- return i;
1838
- };
1837
+ }, r = (a) => s[a];
1839
1838
  return /* @__PURE__ */ z(ae.Provider, { value: { getTracker: r, addTracker: t }, children: n });
1840
1839
  };
1841
- function Qe(n) {
1840
+ function ze(n) {
1842
1841
  const { onChange: e, once: s = !0 } = n, [_, t] = F(!1), r = K(null), a = K(null), i = _e(
1843
1842
  (o) => {
1844
1843
  o.forEach((c) => {
@@ -1861,7 +1860,7 @@ function Qe(n) {
1861
1860
  };
1862
1861
  }, [i]), { isVisible: _, containerRef: a };
1863
1862
  }
1864
- const $e = ({
1863
+ const tt = ({
1865
1864
  children: n,
1866
1865
  tracker: e,
1867
1866
  id: s,
@@ -1870,20 +1869,18 @@ const $e = ({
1870
1869
  style: r,
1871
1870
  ...a
1872
1871
  }) => {
1873
- const { isVisible: i, containerRef: o } = Qe({
1872
+ const { isVisible: i, containerRef: o } = ze({
1874
1873
  onChange: _,
1875
1874
  once: t
1876
1875
  });
1877
1876
  return R(() => {
1878
- i && (e && typeof e.sendEvent == "function" ? e.sendEvent({
1877
+ i && e && typeof e.sendEvent == "function" && e.sendEvent({
1879
1878
  type: "appear",
1880
1879
  params: {
1881
1880
  componentId: [s]
1882
1881
  }
1883
1882
  // Add any required params here
1884
- }) : console.warn(
1885
- `VisibilityTracker: No tracker available for component "${s}". Event not sent.`
1886
- ));
1883
+ });
1887
1884
  }, [i, e, s]), /* @__PURE__ */ z(
1888
1885
  "div",
1889
1886
  {
@@ -1908,9 +1905,9 @@ export {
1908
1905
  ke as PowerstatusEnum,
1909
1906
  Ie as ReceiverEndpoint,
1910
1907
  Me as SrtEnum,
1911
- Je as TrackerProvider,
1908
+ et as TrackerProvider,
1912
1909
  ne as TransportMethod,
1913
- $e as VisibilityTracker,
1914
- ze as useTracker,
1915
- Xe as useTrackerContext
1910
+ tt as VisibilityTracker,
1911
+ $e as useTracker,
1912
+ Ze as useTrackerContext
1916
1913
  };
@@ -4,7 +4,7 @@ import { Tracker } from '@rakutenanalytics/rat-ts';
4
4
  * Props for the VisibilityTracker component
5
5
  * @public
6
6
  */
7
- export interface VisibilityTrackerProps {
7
+ export interface VisibilityTrackerProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'id' | 'onChange'> {
8
8
  /** React children to be rendered inside the visibility tracker */
9
9
  children: React.ReactNode;
10
10
  /** Optional tracker instance to send visibility events */
@@ -15,8 +15,6 @@ export interface VisibilityTrackerProps {
15
15
  onChange?: (isVisible: boolean) => void;
16
16
  /** Whether to track visibility only once (default: true) */
17
17
  once?: boolean;
18
- /** Optional CSS styles to apply to the container */
19
- style?: React.CSSProperties;
20
18
  }
21
19
  /**
22
20
  * A React component that tracks when it becomes visible in the viewport
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { TrackerContextType } from '../useTrackerContext';
2
+ export declare const TRACKER_CONTEXT_ERROR = "useTrackerContext must be used within a TrackerProvider";
3
+ export declare function requireTrackerContext(context: TrackerContextType | undefined): TrackerContextType;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Tracker, TrackerOptions } from '@rakutenanalytics/rat-ts';
2
+ export interface TrackerProviderConfigCore {
3
+ key: string;
4
+ options: TrackerOptions;
5
+ }
6
+ export declare function buildInitialTrackers(configs: TrackerProviderConfigCore[], createTrackerFn: (options: TrackerOptions) => Tracker): Record<string, Tracker>;
7
+ export declare function buildTrackerNotFoundWarning(key: string, availableKeys: string[]): string;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rakutenanalytics/rat-react",
3
3
  "private": false,
4
- "version": "0.3.1-rc.716ed0a",
4
+ "version": "0.3.2-rel.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -18,11 +18,51 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "license": "MIT",
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "build": "tsc -b ./tsconfig.lib.json && vite build --mode staging",
24
+ "build:production": "tsc -b ./tsconfig.lib.json && vite build --mode production",
25
+ "docs": "typedoc",
26
+ "docs:watch": "typedoc --watch",
27
+ "docs:serve": "typedoc && npx http-server docs/api -p 3001 -c-1",
28
+ "docs:deploy": "npm run docs && touch docs/api/.nojekyll && gh-pages -d docs/api -m 'Deploy documentation [skip ci]'",
29
+ "build:all": "npm run build && npm run docs",
30
+ "lint": "eslint .",
31
+ "preview": "vite preview",
32
+ "prepublishOnly": "npm run build:production",
33
+ "compat:legacy": "npm --prefix compat-tests/legacy install && npm --prefix compat-tests/legacy run typecheck",
34
+ "compat:modern": "npm --prefix compat-tests/modern install && npm --prefix compat-tests/modern run typecheck",
35
+ "compat:all": "npm run build && npm run compat:legacy && npm run compat:modern",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "test:run": "vitest run"
39
+ },
21
40
  "repository": "https://github.com/rakutenanalytics/rat-react",
22
41
  "publishConfig": {
23
42
  "registry": "https://registry.npmjs.org",
24
43
  "access": "public"
25
44
  },
45
+ "devDependencies": {
46
+ "@eslint/js": "^9.13.0",
47
+ "@types/node": "^22.8.4",
48
+ "@types/react": "^18.3.11",
49
+ "@types/react-dom": "^18.3.1",
50
+ "@vitejs/plugin-react": "^4.3.3",
51
+ "eslint": "^9.13.0",
52
+ "eslint-plugin-react-hooks": "^5.0.0",
53
+ "eslint-plugin-react-refresh": "^0.4.13",
54
+ "gh-pages": "^6.3.0",
55
+ "globals": "^15.11.0",
56
+ "react": "^18.3.1",
57
+ "react-dom": "^18.3.1",
58
+ "react-router-dom": "^7.1.3",
59
+ "typedoc": "^0.28.13",
60
+ "typescript": "~5.6.2",
61
+ "typescript-eslint": "^8.10.0",
62
+ "vite": "^6.4.1",
63
+ "vite-plugin-dts": "^4.3.0",
64
+ "vitest": "^3.2.4"
65
+ },
26
66
  "peerDependencies": {
27
67
  "react": ">=18.3.1 <20.0.0",
28
68
  "react-dom": ">=18.3.1 <20.0.0"