@massalabs/gossip-sdk 0.0.2-dev.20260128160824 → 0.0.2-dev.20260128162527
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/config/protocol.js +18 -12
- package/package.json +1 -1
package/dist/config/protocol.js
CHANGED
|
@@ -9,23 +9,29 @@
|
|
|
9
9
|
const DEFAULT_API_URL = 'https://api.usegossip.com';
|
|
10
10
|
// Mutable config that can be updated at runtime
|
|
11
11
|
let currentBaseUrl = null;
|
|
12
|
+
/**
|
|
13
|
+
* Safely get Vite environment variable without causing parse-time errors.
|
|
14
|
+
* Uses dynamic Function evaluation to avoid import.meta syntax errors
|
|
15
|
+
* in environments that don't support ESM (like jiti).
|
|
16
|
+
*/
|
|
17
|
+
function getViteEnvUrl() {
|
|
18
|
+
try {
|
|
19
|
+
// Use Function constructor to evaluate import.meta at runtime
|
|
20
|
+
// This avoids parse-time syntax errors in non-ESM environments
|
|
21
|
+
const fn = new Function('return typeof import.meta !== "undefined" && import.meta.env && import.meta.env.VITE_GOSSIP_API_URL');
|
|
22
|
+
return fn() || undefined;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
12
28
|
function buildProtocolApiBaseUrl() {
|
|
13
29
|
// If runtime override is set, use it
|
|
14
30
|
if (currentBaseUrl !== null) {
|
|
15
31
|
return currentBaseUrl;
|
|
16
32
|
}
|
|
17
|
-
// Try to get from environment variable
|
|
18
|
-
let apiUrl;
|
|
19
|
-
try {
|
|
20
|
-
// Check if import.meta.env is available (Vite environment)
|
|
21
|
-
if (typeof import.meta !== 'undefined' &&
|
|
22
|
-
import.meta.env?.VITE_GOSSIP_API_URL) {
|
|
23
|
-
apiUrl = import.meta.env.VITE_GOSSIP_API_URL;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
// import.meta.env not available (Node.js without Vite)
|
|
28
|
-
}
|
|
33
|
+
// Try to get from Vite environment variable
|
|
34
|
+
let apiUrl = getViteEnvUrl();
|
|
29
35
|
// Check process.env for Node.js environment
|
|
30
36
|
if (!apiUrl &&
|
|
31
37
|
typeof process !== 'undefined' &&
|
package/package.json
CHANGED