judgeme-hydrogen-fixed 1.0.2 → 1.0.3
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.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +7 -2
- package/dist/index.mjs +7 -2
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
SHOP_DOMAIN?: string;
|
|
7
7
|
PLATFORM?: string;
|
|
8
8
|
PUBLIC_TOKEN?: string;
|
|
9
|
+
LOCALE?: string;
|
|
9
10
|
productData?: {
|
|
10
11
|
id: string;
|
|
11
12
|
title: string;
|
|
@@ -46,6 +47,14 @@ interface UseJudgemeConfig {
|
|
|
46
47
|
* @default 500
|
|
47
48
|
*/
|
|
48
49
|
delay?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Locale code for Judge.me widget translations.
|
|
52
|
+
* Can be a full locale (e.g., 'fr-FR', 'fr-eu') or a simple language code ('fr').
|
|
53
|
+
* The hook will automatically extract the language code (first 2 characters)
|
|
54
|
+
* since Judge.me only supports simple language codes.
|
|
55
|
+
* @example 'fr', 'de', 'es', 'it', 'fr-FR', 'de-EU'
|
|
56
|
+
*/
|
|
57
|
+
locale?: string;
|
|
49
58
|
}
|
|
50
59
|
interface JudgemePreviewBadgeProps {
|
|
51
60
|
/**
|
|
@@ -132,6 +141,7 @@ interface JudgemeMedalsProps {
|
|
|
132
141
|
* publicToken: 'your-public-token',
|
|
133
142
|
* cdnHost: 'https://cdn.judge.me',
|
|
134
143
|
* delay: 500, // optional, defaults to 500ms
|
|
144
|
+
* locale: 'fr-EU', // optional, supports full locale or simple code
|
|
135
145
|
* });
|
|
136
146
|
*
|
|
137
147
|
* return <Outlet />;
|
|
@@ -143,8 +153,9 @@ interface JudgemeMedalsProps {
|
|
|
143
153
|
* @param config.publicToken - Your Judge.me public token
|
|
144
154
|
* @param config.cdnHost - Judge.me CDN host (usually 'https://cdn.judge.me')
|
|
145
155
|
* @param config.delay - Delay before re-rendering widgets on route change (default: 500ms)
|
|
156
|
+
* @param config.locale - Locale for widget translations (e.g., 'fr', 'de', 'fr-EU'). Automatically extracts language code.
|
|
146
157
|
*/
|
|
147
|
-
declare function useJudgeme({ shopDomain, publicToken, cdnHost, delay, }: UseJudgemeConfig): void;
|
|
158
|
+
declare function useJudgeme({ shopDomain, publicToken, cdnHost, delay, locale, }: UseJudgemeConfig): void;
|
|
148
159
|
|
|
149
160
|
/**
|
|
150
161
|
* Preview badge showing star rating for a product
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
SHOP_DOMAIN?: string;
|
|
7
7
|
PLATFORM?: string;
|
|
8
8
|
PUBLIC_TOKEN?: string;
|
|
9
|
+
LOCALE?: string;
|
|
9
10
|
productData?: {
|
|
10
11
|
id: string;
|
|
11
12
|
title: string;
|
|
@@ -46,6 +47,14 @@ interface UseJudgemeConfig {
|
|
|
46
47
|
* @default 500
|
|
47
48
|
*/
|
|
48
49
|
delay?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Locale code for Judge.me widget translations.
|
|
52
|
+
* Can be a full locale (e.g., 'fr-FR', 'fr-eu') or a simple language code ('fr').
|
|
53
|
+
* The hook will automatically extract the language code (first 2 characters)
|
|
54
|
+
* since Judge.me only supports simple language codes.
|
|
55
|
+
* @example 'fr', 'de', 'es', 'it', 'fr-FR', 'de-EU'
|
|
56
|
+
*/
|
|
57
|
+
locale?: string;
|
|
49
58
|
}
|
|
50
59
|
interface JudgemePreviewBadgeProps {
|
|
51
60
|
/**
|
|
@@ -132,6 +141,7 @@ interface JudgemeMedalsProps {
|
|
|
132
141
|
* publicToken: 'your-public-token',
|
|
133
142
|
* cdnHost: 'https://cdn.judge.me',
|
|
134
143
|
* delay: 500, // optional, defaults to 500ms
|
|
144
|
+
* locale: 'fr-EU', // optional, supports full locale or simple code
|
|
135
145
|
* });
|
|
136
146
|
*
|
|
137
147
|
* return <Outlet />;
|
|
@@ -143,8 +153,9 @@ interface JudgemeMedalsProps {
|
|
|
143
153
|
* @param config.publicToken - Your Judge.me public token
|
|
144
154
|
* @param config.cdnHost - Judge.me CDN host (usually 'https://cdn.judge.me')
|
|
145
155
|
* @param config.delay - Delay before re-rendering widgets on route change (default: 500ms)
|
|
156
|
+
* @param config.locale - Locale for widget translations (e.g., 'fr', 'de', 'fr-EU'). Automatically extracts language code.
|
|
146
157
|
*/
|
|
147
|
-
declare function useJudgeme({ shopDomain, publicToken, cdnHost, delay, }: UseJudgemeConfig): void;
|
|
158
|
+
declare function useJudgeme({ shopDomain, publicToken, cdnHost, delay, locale, }: UseJudgemeConfig): void;
|
|
148
159
|
|
|
149
160
|
/**
|
|
150
161
|
* Preview badge showing star rating for a product
|
package/dist/index.js
CHANGED
|
@@ -40,8 +40,10 @@ function useJudgeme({
|
|
|
40
40
|
shopDomain,
|
|
41
41
|
publicToken,
|
|
42
42
|
cdnHost,
|
|
43
|
-
delay = 500
|
|
43
|
+
delay = 500,
|
|
44
|
+
locale
|
|
44
45
|
}) {
|
|
46
|
+
const languageCode = locale ? locale.split("-")[0].toLowerCase() : void 0;
|
|
45
47
|
const location = (0, import_react2.useLocation)();
|
|
46
48
|
const lastPathnameRef = (0, import_react.useRef)("");
|
|
47
49
|
const rerenderTimeoutRef = (0, import_react.useRef)(null);
|
|
@@ -82,6 +84,9 @@ function useJudgeme({
|
|
|
82
84
|
window.jdgm.SHOP_DOMAIN = shopDomain;
|
|
83
85
|
window.jdgm.PLATFORM = "shopify";
|
|
84
86
|
window.jdgm.PUBLIC_TOKEN = publicToken;
|
|
87
|
+
if (languageCode) {
|
|
88
|
+
window.jdgm.LOCALE = languageCode;
|
|
89
|
+
}
|
|
85
90
|
fetch(`${cdnHost}/widget_preloader.js`).then((res) => {
|
|
86
91
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
87
92
|
return res.text();
|
|
@@ -102,7 +107,7 @@ function useJudgeme({
|
|
|
102
107
|
clearTimeout(rerenderTimeoutRef.current);
|
|
103
108
|
}
|
|
104
109
|
};
|
|
105
|
-
}, [shopDomain, publicToken, cdnHost, refreshWidgets]);
|
|
110
|
+
}, [shopDomain, publicToken, cdnHost, languageCode, refreshWidgets]);
|
|
106
111
|
(0, import_react.useEffect)(() => {
|
|
107
112
|
if (typeof window === "undefined") return;
|
|
108
113
|
const normalizedPathname = location.pathname.replace(/\/$/, "") || "/";
|
package/dist/index.mjs
CHANGED
|
@@ -6,8 +6,10 @@ function useJudgeme({
|
|
|
6
6
|
shopDomain,
|
|
7
7
|
publicToken,
|
|
8
8
|
cdnHost,
|
|
9
|
-
delay = 500
|
|
9
|
+
delay = 500,
|
|
10
|
+
locale
|
|
10
11
|
}) {
|
|
12
|
+
const languageCode = locale ? locale.split("-")[0].toLowerCase() : void 0;
|
|
11
13
|
const location = useLocation();
|
|
12
14
|
const lastPathnameRef = useRef("");
|
|
13
15
|
const rerenderTimeoutRef = useRef(null);
|
|
@@ -48,6 +50,9 @@ function useJudgeme({
|
|
|
48
50
|
window.jdgm.SHOP_DOMAIN = shopDomain;
|
|
49
51
|
window.jdgm.PLATFORM = "shopify";
|
|
50
52
|
window.jdgm.PUBLIC_TOKEN = publicToken;
|
|
53
|
+
if (languageCode) {
|
|
54
|
+
window.jdgm.LOCALE = languageCode;
|
|
55
|
+
}
|
|
51
56
|
fetch(`${cdnHost}/widget_preloader.js`).then((res) => {
|
|
52
57
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
53
58
|
return res.text();
|
|
@@ -68,7 +73,7 @@ function useJudgeme({
|
|
|
68
73
|
clearTimeout(rerenderTimeoutRef.current);
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
}, [shopDomain, publicToken, cdnHost, refreshWidgets]);
|
|
76
|
+
}, [shopDomain, publicToken, cdnHost, languageCode, refreshWidgets]);
|
|
72
77
|
useEffect(() => {
|
|
73
78
|
if (typeof window === "undefined") return;
|
|
74
79
|
const normalizedPathname = location.pathname.replace(/\/$/, "") || "/";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "judgeme-hydrogen-fixed",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Fixed version of @judgeme/shopify-hydrogen for Hydrogen/Oxygen. Fixes infinite refresh loops caused by installed.js and improper React hooks.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,7 +33,10 @@
|
|
|
33
33
|
"reviews",
|
|
34
34
|
"remix",
|
|
35
35
|
"bug-fix",
|
|
36
|
-
"refresh-loop-fix"
|
|
36
|
+
"refresh-loop-fix",
|
|
37
|
+
"i18n",
|
|
38
|
+
"locale",
|
|
39
|
+
"translations"
|
|
37
40
|
],
|
|
38
41
|
"author": "Ben Goodman",
|
|
39
42
|
"license": "MIT",
|