pi-kiosk-shared 1.0.3 → 1.0.5
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/api.js +2 -1
- package/dist/config/environments.js +43 -3
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -55,8 +55,9 @@ class APIClient {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
exports.APIClient = APIClient;
|
|
58
|
+
const environments_1 = require("./config/environments");
|
|
58
59
|
const createAPIClient = (baseUrl, kioskSecret) => {
|
|
59
|
-
const url = baseUrl ||
|
|
60
|
+
const url = baseUrl || (0, environments_1.getEnvironmentConfig)().apiUrl;
|
|
60
61
|
return new APIClient(url, kioskSecret);
|
|
61
62
|
};
|
|
62
63
|
exports.createAPIClient = createAPIClient;
|
|
@@ -4,10 +4,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.isProduction = exports.isDevelopment = exports.getEnvironmentConfig = exports.getCurrentEnvironment = void 0;
|
|
5
5
|
// Helper function to get environment variables dynamically
|
|
6
6
|
function getEnvVar(key, defaultValue) {
|
|
7
|
-
|
|
7
|
+
// Try to get from process.env (Node.js) or import.meta.env (Vite)
|
|
8
|
+
let value;
|
|
9
|
+
// Check for process.env (Node.js environment)
|
|
10
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
11
|
+
value = process.env[key];
|
|
12
|
+
}
|
|
13
|
+
// If not found and we're in a browser, try to access Vite's environment
|
|
14
|
+
if (!value && typeof window !== 'undefined') {
|
|
15
|
+
try {
|
|
16
|
+
// Use eval to access import.meta at runtime (not at parse time)
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const viteEnv = eval('typeof import !== "undefined" && import.meta && import.meta.env');
|
|
19
|
+
if (viteEnv && typeof viteEnv === 'object') {
|
|
20
|
+
value = viteEnv[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
// Ignore errors, fall back to default
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return value || defaultValue;
|
|
8
28
|
}
|
|
9
29
|
function getEnvBool(key, defaultValue) {
|
|
10
|
-
|
|
30
|
+
const value = getEnvVar(key, defaultValue.toString());
|
|
31
|
+
return value === 'true';
|
|
11
32
|
}
|
|
12
33
|
// Get environment configuration dynamically
|
|
13
34
|
function getConfigForEnvironment(env) {
|
|
@@ -32,7 +53,26 @@ function getConfigForEnvironment(env) {
|
|
|
32
53
|
}
|
|
33
54
|
// Simple environment detection
|
|
34
55
|
const getCurrentEnvironment = () => {
|
|
35
|
-
|
|
56
|
+
let nodeEnv;
|
|
57
|
+
// Check for process.env (Node.js environment)
|
|
58
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
59
|
+
nodeEnv = process.env.NODE_ENV;
|
|
60
|
+
}
|
|
61
|
+
// If not found and we're in a browser, try to access Vite's environment
|
|
62
|
+
if (!nodeEnv && typeof window !== 'undefined') {
|
|
63
|
+
try {
|
|
64
|
+
// Use eval to access import.meta at runtime (not at parse time)
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
const viteEnv = eval('typeof import !== "undefined" && import.meta && import.meta.env');
|
|
67
|
+
if (viteEnv && typeof viteEnv === 'object') {
|
|
68
|
+
nodeEnv = viteEnv.NODE_ENV;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
// Ignore errors, fall back to default
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return nodeEnv === 'production' ? 'production' : 'development';
|
|
36
76
|
};
|
|
37
77
|
exports.getCurrentEnvironment = getCurrentEnvironment;
|
|
38
78
|
// Get current environment configuration
|