@rakutenanalytics/rat-react 0.3.1 → 0.3.2
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 +27 -19
- package/dist/lib/VisibilityTracker.d.ts +1 -3
- package/dist/lib/constants.test.d.ts +1 -0
- package/dist/lib/createTracker.test.d.ts +1 -0
- package/dist/lib/index.test.d.ts +1 -0
- package/dist/lib/internal/contextGuards.d.ts +3 -0
- package/dist/lib/internal/contextGuards.test.d.ts +1 -0
- package/dist/lib/internal/trackerRegistry.d.ts +7 -0
- package/dist/lib/internal/trackerRegistry.test.d.ts +1 -0
- package/package.json +41 -1
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.
|
|
1794
|
+
const Ge = "0.3.2", je = "rat-react", Ye = Ge;
|
|
1795
1795
|
function M(n) {
|
|
1796
1796
|
return new We({
|
|
1797
1797
|
...n,
|
|
@@ -1799,29 +1799,37 @@ function M(n) {
|
|
|
1799
1799
|
sdkVersion: Ye
|
|
1800
1800
|
});
|
|
1801
1801
|
}
|
|
1802
|
-
const
|
|
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
|
-
},
|
|
1809
|
-
|
|
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(
|
|
1811
|
+
throw new Error(Qe);
|
|
1814
1812
|
return n;
|
|
1815
|
-
}
|
|
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
|
-
|
|
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);
|
|
@@ -1829,7 +1837,7 @@ const ze = (n) => {
|
|
|
1829
1837
|
}, r = (a) => s[a];
|
|
1830
1838
|
return /* @__PURE__ */ z(ae.Provider, { value: { getTracker: r, addTracker: t }, children: n });
|
|
1831
1839
|
};
|
|
1832
|
-
function
|
|
1840
|
+
function ze(n) {
|
|
1833
1841
|
const { onChange: e, once: s = !0 } = n, [_, t] = F(!1), r = K(null), a = K(null), i = _e(
|
|
1834
1842
|
(o) => {
|
|
1835
1843
|
o.forEach((c) => {
|
|
@@ -1852,7 +1860,7 @@ function Qe(n) {
|
|
|
1852
1860
|
};
|
|
1853
1861
|
}, [i]), { isVisible: _, containerRef: a };
|
|
1854
1862
|
}
|
|
1855
|
-
const
|
|
1863
|
+
const tt = ({
|
|
1856
1864
|
children: n,
|
|
1857
1865
|
tracker: e,
|
|
1858
1866
|
id: s,
|
|
@@ -1861,7 +1869,7 @@ const $e = ({
|
|
|
1861
1869
|
style: r,
|
|
1862
1870
|
...a
|
|
1863
1871
|
}) => {
|
|
1864
|
-
const { isVisible: i, containerRef: o } =
|
|
1872
|
+
const { isVisible: i, containerRef: o } = ze({
|
|
1865
1873
|
onChange: _,
|
|
1866
1874
|
once: t
|
|
1867
1875
|
});
|
|
@@ -1897,9 +1905,9 @@ export {
|
|
|
1897
1905
|
ke as PowerstatusEnum,
|
|
1898
1906
|
Ie as ReceiverEndpoint,
|
|
1899
1907
|
Me as SrtEnum,
|
|
1900
|
-
|
|
1908
|
+
et as TrackerProvider,
|
|
1901
1909
|
ne as TransportMethod,
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1910
|
+
tt as VisibilityTracker,
|
|
1911
|
+
$e as useTracker,
|
|
1912
|
+
Ze as useTrackerContext
|
|
1905
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 @@
|
|
|
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.
|
|
4
|
+
"version": "0.3.2",
|
|
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"
|