@nuskin/product-components 3.20.1 → 3.20.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/docs/CHANGELOG.md +1 -1
- package/package.json +1 -1
- package/services/NsProductAppService.js +86 -11
package/docs/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
## [3.20.
|
|
1
|
+
## [3.20.2](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.20.1...v3.20.2) (2026-04-27)
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ if (!NsProductAppService) {
|
|
|
25
25
|
return {
|
|
26
26
|
runConfig: {},
|
|
27
27
|
runConfigInterval: null,
|
|
28
|
-
runConfigTries:
|
|
28
|
+
runConfigTries: 10,
|
|
29
29
|
locale: "",
|
|
30
30
|
marketConfig: {},
|
|
31
31
|
awsUrl: "",
|
|
@@ -34,7 +34,10 @@ if (!NsProductAppService) {
|
|
|
34
34
|
showWholeSalePricing: false,
|
|
35
35
|
loadingConfig: true,
|
|
36
36
|
translations: {},
|
|
37
|
-
loadingTranslations: true
|
|
37
|
+
loadingTranslations: true,
|
|
38
|
+
configLoadedSuccessfully: false,
|
|
39
|
+
visibilityChangeTriggered: false,
|
|
40
|
+
pageShowTriggered: false
|
|
38
41
|
};
|
|
39
42
|
},
|
|
40
43
|
computed: {
|
|
@@ -44,20 +47,86 @@ if (!NsProductAppService) {
|
|
|
44
47
|
},
|
|
45
48
|
async mounted() {
|
|
46
49
|
await this.setConfig();
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
this.startConfigRetryInterval();
|
|
51
|
+
|
|
52
|
+
// Handle Instagram and other in-app browsers that load pages in hidden state
|
|
53
|
+
// Re-initialize when page becomes visible
|
|
54
|
+
this.handleVisibilityChange = async () => {
|
|
55
|
+
this.visibilityChangeTriggered = true;
|
|
56
|
+
|
|
57
|
+
const visibilityState =
|
|
58
|
+
typeof document !== "undefined" && document.visibilityState
|
|
59
|
+
? document.visibilityState
|
|
60
|
+
: "visible";
|
|
61
|
+
|
|
62
|
+
if (visibilityState === "visible" && !this.configLoadedSuccessfully) {
|
|
63
|
+
await this.setConfig();
|
|
64
|
+
if (!this.configLoadedSuccessfully) {
|
|
65
|
+
this.startConfigRetryInterval();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (typeof document !== "undefined") {
|
|
71
|
+
document.addEventListener(
|
|
72
|
+
"visibilitychange",
|
|
73
|
+
this.handleVisibilityChange
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Handle page restoration from bfcache (back/forward cache)
|
|
78
|
+
this.handlePageShow = async event => {
|
|
79
|
+
this.pageShowTriggered = true;
|
|
80
|
+
if (event.persisted && !this.configLoadedSuccessfully) {
|
|
81
|
+
await this.setConfig();
|
|
82
|
+
if (!this.configLoadedSuccessfully) {
|
|
83
|
+
this.startConfigRetryInterval();
|
|
84
|
+
}
|
|
54
85
|
}
|
|
55
|
-
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
if (typeof window !== "undefined") {
|
|
89
|
+
window.addEventListener("pageshow", this.handlePageShow);
|
|
90
|
+
}
|
|
56
91
|
},
|
|
57
92
|
beforeDestroy() {
|
|
58
|
-
|
|
93
|
+
this.clearConfigRetryInterval();
|
|
94
|
+
if (this.handleVisibilityChange && typeof document !== "undefined") {
|
|
95
|
+
document.removeEventListener(
|
|
96
|
+
"visibilitychange",
|
|
97
|
+
this.handleVisibilityChange
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (this.handlePageShow && typeof window !== "undefined") {
|
|
101
|
+
window.removeEventListener("pageshow", this.handlePageShow);
|
|
102
|
+
}
|
|
59
103
|
},
|
|
60
104
|
methods: {
|
|
105
|
+
/**
|
|
106
|
+
* Start the configuration retry interval
|
|
107
|
+
*/
|
|
108
|
+
startConfigRetryInterval() {
|
|
109
|
+
this.clearConfigRetryInterval();
|
|
110
|
+
this.runConfigInterval = setInterval(async () => {
|
|
111
|
+
if (this.runConfigTries <= 0 || this.configLoadedSuccessfully) {
|
|
112
|
+
this.clearConfigRetryInterval();
|
|
113
|
+
} else {
|
|
114
|
+
await this.checkConfig();
|
|
115
|
+
this.runConfigTries--;
|
|
116
|
+
}
|
|
117
|
+
}, 350);
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Clear the configuration retry interval
|
|
122
|
+
*/
|
|
123
|
+
clearConfigRetryInterval() {
|
|
124
|
+
if (this.runConfigInterval) {
|
|
125
|
+
clearInterval(this.runConfigInterval);
|
|
126
|
+
this.runConfigInterval = null;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
61
130
|
/**
|
|
62
131
|
* Gets the full content path for an image or content src
|
|
63
132
|
*/
|
|
@@ -89,6 +158,7 @@ if (!NsProductAppService) {
|
|
|
89
158
|
runConfig = runConfig || RunConfigService.getRunConfig() || {};
|
|
90
159
|
if (!runConfig.language || !runConfig.country) {
|
|
91
160
|
// the runconfig isn't ready yet
|
|
161
|
+
this.loadingConfig = false;
|
|
92
162
|
return;
|
|
93
163
|
}
|
|
94
164
|
|
|
@@ -115,6 +185,11 @@ if (!NsProductAppService) {
|
|
|
115
185
|
};
|
|
116
186
|
|
|
117
187
|
this.loadingConfig = false;
|
|
188
|
+
this.configLoadedSuccessfully = true;
|
|
189
|
+
|
|
190
|
+
// Stop retry interval once config is successfully loaded
|
|
191
|
+
this.clearConfigRetryInterval();
|
|
192
|
+
|
|
118
193
|
this.$emit("config-changed", configData);
|
|
119
194
|
},
|
|
120
195
|
|