@buoy-gg/env 7.0.41 → 7.0.42
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/README.md +11 -87
- package/lib/commonjs/env/components/EnvStatsOverview.js +1 -159
- package/lib/commonjs/env/components/EnvVarRow.js +1 -189
- package/lib/commonjs/env/components/EnvVarSection.js +1 -84
- package/lib/commonjs/env/components/EnvVarsModal.js +1 -322
- package/lib/commonjs/env/hooks/useDynamicEnv.js +1 -92
- package/lib/commonjs/env/types/index.js +1 -27
- package/lib/commonjs/env/types/types.js +1 -1
- package/lib/commonjs/env/types/userTypes.js +1 -1
- package/lib/commonjs/env/utils/envTypeDetector.js +1 -59
- package/lib/commonjs/env/utils/helpers.js +1 -119
- package/lib/commonjs/env/utils/index.js +1 -38
- package/lib/commonjs/env/utils/remoteEnv.js +1 -24
- package/lib/commonjs/env/utils/utils.js +1 -121
- package/lib/commonjs/index.js +1 -77
- package/lib/commonjs/preset.js +1 -81
- package/lib/commonjs/sync/envSyncAdapter.js +1 -51
- package/lib/module/env/components/EnvStatsOverview.js +1 -155
- package/lib/module/env/components/EnvVarRow.js +1 -185
- package/lib/module/env/components/EnvVarSection.js +1 -80
- package/lib/module/env/components/EnvVarsModal.js +1 -317
- package/lib/module/env/hooks/useDynamicEnv.js +1 -88
- package/lib/module/env/types/index.js +1 -4
- package/lib/module/env/types/types.js +1 -1
- package/lib/module/env/types/userTypes.js +1 -1
- package/lib/module/env/utils/envTypeDetector.js +1 -55
- package/lib/module/env/utils/helpers.js +1 -114
- package/lib/module/env/utils/index.js +1 -5
- package/lib/module/env/utils/remoteEnv.js +1 -19
- package/lib/module/env/utils/utils.js +1 -116
- package/lib/module/index.js +1 -21
- package/lib/module/preset.js +1 -78
- package/lib/module/sync/envSyncAdapter.js +1 -46
- package/lib/web/index.mjs +1 -2
- package/package.json +3 -3
- package/lib/typescript/env/components/EnvStatsOverview.d.ts.map +0 -1
- package/lib/typescript/env/components/EnvVarRow.d.ts.map +0 -1
- package/lib/typescript/env/components/EnvVarSection.d.ts.map +0 -1
- package/lib/typescript/env/components/EnvVarsModal.d.ts.map +0 -1
- package/lib/typescript/env/hooks/useDynamicEnv.d.ts.map +0 -1
- package/lib/typescript/env/types/index.d.ts.map +0 -1
- package/lib/typescript/env/types/types.d.ts.map +0 -1
- package/lib/typescript/env/types/userTypes.d.ts.map +0 -1
- package/lib/typescript/env/utils/envTypeDetector.d.ts.map +0 -1
- package/lib/typescript/env/utils/helpers.d.ts.map +0 -1
- package/lib/typescript/env/utils/index.d.ts.map +0 -1
- package/lib/typescript/env/utils/remoteEnv.d.ts.map +0 -1
- package/lib/typescript/env/utils/utils.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/sync/envSyncAdapter.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
@@ -1,55 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Detects the type of an environment variable value
|
|
5
|
-
* First checks if useDynamicEnv already parsed it to the correct type,
|
|
6
|
-
* then analyzes string content to detect what type it represents
|
|
7
|
-
*
|
|
8
|
-
* @returns One of: "string", "number", "boolean", "array", "object"
|
|
9
|
-
*/
|
|
10
|
-
export function getEnvVarType(value) {
|
|
11
|
-
// Check the actual parsed value type from useDynamicEnv
|
|
12
|
-
const type = typeof value;
|
|
13
|
-
if (type === "boolean") return "boolean";
|
|
14
|
-
if (type === "number") return "number";
|
|
15
|
-
if (Array.isArray(value)) return "array";
|
|
16
|
-
if (type === "object" && value !== null) return "object";
|
|
17
|
-
|
|
18
|
-
// For strings, check if they look like other types
|
|
19
|
-
if (type === "string") {
|
|
20
|
-
const strValue = value;
|
|
21
|
-
|
|
22
|
-
// Check if it looks like JSON
|
|
23
|
-
if (strValue.startsWith("{") && strValue.endsWith("}") || strValue.startsWith("[") && strValue.endsWith("]")) {
|
|
24
|
-
try {
|
|
25
|
-
const parsed = JSON.parse(strValue);
|
|
26
|
-
return Array.isArray(parsed) ? "array" : "object";
|
|
27
|
-
} catch {
|
|
28
|
-
return "string";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Check if it's a boolean string
|
|
33
|
-
const lowerStr = strValue.toLowerCase();
|
|
34
|
-
if (lowerStr === "true" || lowerStr === "false" || lowerStr === "enabled" || lowerStr === "disabled" || lowerStr === "yes" || lowerStr === "no" || lowerStr === "on" || lowerStr === "off") {
|
|
35
|
-
return "boolean";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Check if it's a number string (including 1 and 0 as numbers, not booleans)
|
|
39
|
-
if (!isNaN(Number(strValue)) && strValue.trim() !== "") {
|
|
40
|
-
return "number";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Check if it's a URL
|
|
44
|
-
if (strValue.startsWith("http://") || strValue.startsWith("https://")) {
|
|
45
|
-
return "url";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Check if it's a comma-separated array
|
|
49
|
-
if (strValue.includes(",")) {
|
|
50
|
-
return "array";
|
|
51
|
-
}
|
|
52
|
-
return "string";
|
|
53
|
-
}
|
|
54
|
-
return "unknown";
|
|
55
|
-
}
|
|
1
|
+
"use strict";export function getEnvVarType(e){const n=typeof e;if(n==="boolean")return"boolean";if(n==="number")return"number";if(Array.isArray(e))return"array";if(n==="object"&&e!==null)return"object";if(n==="string"){const r=e;if(r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]")){try{const s=JSON.parse(r);return Array.isArray(s)?"array":"object"}catch{return"string"}}const t=r.toLowerCase();if(t==="true"||t==="false"||t==="enabled"||t==="disabled"||t==="yes"||t==="no"||t==="on"||t==="off"){return"boolean"}if(!isNaN(Number(r))&&r.trim()!==""){return"number"}if(r.startsWith("http://")||r.startsWith("https://")){return"url"}if(r.includes(",")){return"array"}return"string"}return"unknown"}
|
|
@@ -1,114 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Helper to create a required env var configuration with type checking
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* const config = envVar("EXPO_PUBLIC_API_URL")
|
|
8
|
-
* .withType("string")
|
|
9
|
-
* .withDescription("Backend API endpoint")
|
|
10
|
-
* .build();
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const config = envVar("EXPO_PUBLIC_DEBUG_MODE")
|
|
14
|
-
* .withDescription("Enable debug logging")
|
|
15
|
-
* .withType("boolean")
|
|
16
|
-
* .build();
|
|
17
|
-
*/
|
|
18
|
-
class EnvVarBuilder {
|
|
19
|
-
constructor(key) {
|
|
20
|
-
this.key = key;
|
|
21
|
-
}
|
|
22
|
-
/** Just check if the variable exists */
|
|
23
|
-
exists() {
|
|
24
|
-
return this.key;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Check for a specific value */
|
|
28
|
-
withValue(value) {
|
|
29
|
-
this.expectedValue = value;
|
|
30
|
-
delete this.expectedType; // Can't have both type and value
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Check for a specific type */
|
|
35
|
-
withType(type) {
|
|
36
|
-
this.expectedType = type;
|
|
37
|
-
delete this.expectedValue; // Can't have both type and value
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Add a description for documentation */
|
|
42
|
-
withDescription(desc) {
|
|
43
|
-
this.description = desc;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Build the final configuration */
|
|
48
|
-
build() {
|
|
49
|
-
if (this.expectedValue !== undefined) {
|
|
50
|
-
return this.description ? {
|
|
51
|
-
key: this.key,
|
|
52
|
-
expectedValue: this.expectedValue,
|
|
53
|
-
description: this.description
|
|
54
|
-
} : {
|
|
55
|
-
key: this.key,
|
|
56
|
-
expectedValue: this.expectedValue
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (this.expectedType !== undefined) {
|
|
60
|
-
return this.description ? {
|
|
61
|
-
key: this.key,
|
|
62
|
-
expectedType: this.expectedType,
|
|
63
|
-
description: this.description
|
|
64
|
-
} : {
|
|
65
|
-
key: this.key,
|
|
66
|
-
expectedType: this.expectedType
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// If neither type nor value is specified, just check existence
|
|
71
|
-
return this.key;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Fluent builder for defining expected environment variables. Helps teams author readable
|
|
77
|
-
* `requiredEnvVars` arrays by chaining type/value/description requirements while keeping the
|
|
78
|
-
* final shape compatible with `EnvVarsModal` and related helpers.
|
|
79
|
-
*
|
|
80
|
-
* @param key - Environment variable name to validate.
|
|
81
|
-
* @returns Builder with convenience methods like `.withType()` and `.withValue()`.
|
|
82
|
-
*/
|
|
83
|
-
export function envVar(key) {
|
|
84
|
-
return new EnvVarBuilder(key);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Normalizes `requiredEnvVars` definitions while documenting intent in code. The helper simply
|
|
89
|
-
* returns the provided array, but allows teams to co-locate examples and benefit from IDE hovers.
|
|
90
|
-
*
|
|
91
|
-
* @param vars - Collection of required environment variable definitions created manually or via `envVar()`.
|
|
92
|
-
* @returns The original array, unchanged, for ergonomic chaining and inference.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* const requiredEnvVars = createEnvVarConfig([
|
|
96
|
-
* // Simple existence check
|
|
97
|
-
* "EXPO_PUBLIC_API_URL",
|
|
98
|
-
*
|
|
99
|
-
* // Type checking
|
|
100
|
-
* { key: "EXPO_PUBLIC_DEBUG_MODE", expectedType: "boolean" },
|
|
101
|
-
*
|
|
102
|
-
* // Value checking
|
|
103
|
-
* { key: "EXPO_PUBLIC_ENVIRONMENT", expectedValue: "development" },
|
|
104
|
-
*
|
|
105
|
-
* // With descriptions
|
|
106
|
-
* envVar("EXPO_PUBLIC_MAX_RETRIES")
|
|
107
|
-
* .withType("number")
|
|
108
|
-
* .withDescription("Maximum number of API retry attempts")
|
|
109
|
-
* .build(),
|
|
110
|
-
* ]);
|
|
111
|
-
*/
|
|
112
|
-
export function createEnvVarConfig(vars) {
|
|
113
|
-
return vars;
|
|
114
|
-
}
|
|
1
|
+
"use strict";class i{constructor(e){this.key=e}exists(){return this.key}withValue(e){this.expectedValue=e;delete this.expectedType;return this}withType(e){this.expectedType=e;delete this.expectedValue;return this}withDescription(e){this.description=e;return this}build(){if(this.expectedValue!==void 0){return this.description?{key:this.key,expectedValue:this.expectedValue,description:this.description}:{key:this.key,expectedValue:this.expectedValue}}if(this.expectedType!==void 0){return this.description?{key:this.key,expectedType:this.expectedType,description:this.description}:{key:this.key,expectedType:this.expectedType}}return this.key}}export function envVar(t){return new i(t)}export function createEnvVarConfig(t){return t}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Remote env override for remote mirror mode (desktop dashboard).
|
|
5
|
-
*
|
|
6
|
-
* The dashboard has no meaningful process.env of its own — the env values it
|
|
7
|
-
* shows come from the synced device. When set, useDynamicEnv reads from this
|
|
8
|
-
* map instead of process.env.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
let remoteEnv = null;
|
|
12
|
-
|
|
13
|
-
/** Override the env source. Pass null to restore process.env. */
|
|
14
|
-
export function setRemoteEnv(env) {
|
|
15
|
-
remoteEnv = env;
|
|
16
|
-
}
|
|
17
|
-
export function getRemoteEnv() {
|
|
18
|
-
return remoteEnv;
|
|
19
|
-
}
|
|
1
|
+
"use strict";let e=null;export function setRemoteEnv(t){e=t}export function getRemoteEnv(){return e}
|
|
@@ -1,116 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { getEnvVarType } from "./envTypeDetector";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Combines the auto-detected runtime environment values with the declared `requiredEnvVars`
|
|
7
|
-
* configuration and produces categorized metadata for rendering in the UI.
|
|
8
|
-
*
|
|
9
|
-
* @param autoCollectedEnvVars - Values discovered via `useDynamicEnv` (key/value string map).
|
|
10
|
-
* @param requiredEnvVars - Optional list of required variables describing expectations to validate.
|
|
11
|
-
* @returns Required and optional variable collections annotated with validation status.
|
|
12
|
-
*/
|
|
13
|
-
export const processEnvVars = (autoCollectedEnvVars, requiredEnvVars) => {
|
|
14
|
-
const requiredVarInfos = [];
|
|
15
|
-
const optionalVarInfos = [];
|
|
16
|
-
const processedKeys = new Set();
|
|
17
|
-
|
|
18
|
-
// Process required variables
|
|
19
|
-
requiredEnvVars?.forEach(envVar => {
|
|
20
|
-
const key = typeof envVar === "string" ? envVar : envVar.key;
|
|
21
|
-
const expectedValue = typeof envVar === "object" && "expectedValue" in envVar ? envVar.expectedValue : undefined;
|
|
22
|
-
const expectedType = typeof envVar === "object" && "expectedType" in envVar ? envVar.expectedType : undefined;
|
|
23
|
-
const description = typeof envVar === "object" && "description" in envVar ? envVar.description : undefined;
|
|
24
|
-
processedKeys.add(key);
|
|
25
|
-
const actualValue = autoCollectedEnvVars[key];
|
|
26
|
-
const isPresent = actualValue !== undefined;
|
|
27
|
-
let status;
|
|
28
|
-
if (!isPresent) {
|
|
29
|
-
status = "required_missing";
|
|
30
|
-
} else if (expectedValue) {
|
|
31
|
-
// Handle different expectedValue patterns
|
|
32
|
-
let valueMatches = false;
|
|
33
|
-
if (expectedValue === "sk_*") {
|
|
34
|
-
valueMatches = actualValue.startsWith("sk_");
|
|
35
|
-
} else if (expectedValue === "production or development") {
|
|
36
|
-
valueMatches = actualValue === "production" || actualValue === "development";
|
|
37
|
-
} else {
|
|
38
|
-
valueMatches = actualValue === expectedValue;
|
|
39
|
-
}
|
|
40
|
-
status = valueMatches ? "required_present" : "required_wrong_value";
|
|
41
|
-
} else if (expectedType && getEnvVarType(actualValue).toLowerCase() !== expectedType.toLowerCase()) {
|
|
42
|
-
status = "required_wrong_type";
|
|
43
|
-
} else {
|
|
44
|
-
status = "required_present";
|
|
45
|
-
}
|
|
46
|
-
requiredVarInfos.push({
|
|
47
|
-
key,
|
|
48
|
-
value: actualValue,
|
|
49
|
-
expectedValue,
|
|
50
|
-
expectedType,
|
|
51
|
-
description,
|
|
52
|
-
status,
|
|
53
|
-
category: "required"
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Process optional variables (those that exist but aren't required)
|
|
58
|
-
Object.entries(autoCollectedEnvVars).forEach(([key, value]) => {
|
|
59
|
-
if (!processedKeys.has(key)) {
|
|
60
|
-
optionalVarInfos.push({
|
|
61
|
-
key,
|
|
62
|
-
value,
|
|
63
|
-
status: "optional_present",
|
|
64
|
-
category: "optional"
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Sort each category
|
|
70
|
-
requiredVarInfos.sort((a, b) => {
|
|
71
|
-
const statusOrder = {
|
|
72
|
-
required_missing: 0,
|
|
73
|
-
required_wrong_value: 1,
|
|
74
|
-
required_wrong_type: 2,
|
|
75
|
-
required_present: 3,
|
|
76
|
-
optional_present: 4
|
|
77
|
-
};
|
|
78
|
-
if (statusOrder[a.status] !== statusOrder[b.status]) {
|
|
79
|
-
return statusOrder[a.status] - statusOrder[b.status];
|
|
80
|
-
}
|
|
81
|
-
return a.key.localeCompare(b.key);
|
|
82
|
-
});
|
|
83
|
-
optionalVarInfos.sort((a, b) => a.key.localeCompare(b.key));
|
|
84
|
-
return {
|
|
85
|
-
requiredVars: requiredVarInfos,
|
|
86
|
-
optionalVars: optionalVarInfos
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Derives aggregate statistics from the processed environment variable lists for health badges
|
|
92
|
-
* and summary chips in the modal UI.
|
|
93
|
-
*
|
|
94
|
-
* @param requiredVars - Processed required variables with validation state.
|
|
95
|
-
* @param optionalVars - Processed optional variables discovered at runtime.
|
|
96
|
-
* @param totalEnvVars - Raw key/value map of every detected environment variable.
|
|
97
|
-
* @returns Counts related to overall env health for display purposes.
|
|
98
|
-
*/
|
|
99
|
-
export const calculateStats = (requiredVars, optionalVars, totalEnvVars) => {
|
|
100
|
-
const totalCount = Object.keys(totalEnvVars).length;
|
|
101
|
-
const requiredCount = requiredVars.length;
|
|
102
|
-
const missingCount = requiredVars.filter(v => v.status === "required_missing").length;
|
|
103
|
-
const wrongValueCount = requiredVars.filter(v => v.status === "required_wrong_value").length;
|
|
104
|
-
const wrongTypeCount = requiredVars.filter(v => v.status === "required_wrong_type").length;
|
|
105
|
-
const presentRequiredCount = requiredVars.filter(v => v.status === "required_present").length;
|
|
106
|
-
const optionalCount = optionalVars.length;
|
|
107
|
-
return {
|
|
108
|
-
totalCount,
|
|
109
|
-
requiredCount,
|
|
110
|
-
missingCount,
|
|
111
|
-
wrongValueCount,
|
|
112
|
-
wrongTypeCount,
|
|
113
|
-
presentRequiredCount,
|
|
114
|
-
optionalCount
|
|
115
|
-
};
|
|
116
|
-
};
|
|
1
|
+
"use strict";import{getEnvVarType as g}from"./envTypeDetector";export const processEnvVars=(n,d)=>{const r=[];const i=[];const p=new Set;d?.forEach(e=>{const s=typeof e==="string"?e:e.key;const o=typeof e==="object"&&"expectedValue"in e?e.expectedValue:void 0;const u=typeof e==="object"&&"expectedType"in e?e.expectedType:void 0;const a=typeof e==="object"&&"description"in e?e.description:void 0;p.add(s);const t=n[s];const f=t!==void 0;let c;if(!f){c="required_missing"}else if(o){let l=false;if(o==="sk_*"){l=t.startsWith("sk_")}else if(o==="production or development"){l=t==="production"||t==="development"}else{l=t===o}c=l?"required_present":"required_wrong_value"}else if(u&&g(t).toLowerCase()!==u.toLowerCase()){c="required_wrong_type"}else{c="required_present"}r.push({key:s,value:t,expectedValue:o,expectedType:u,description:a,status:c,category:"required"})});Object.entries(n).forEach(([e,s])=>{if(!p.has(e)){i.push({key:e,value:s,status:"optional_present",category:"optional"})}});r.sort((e,s)=>{const o={required_missing:0,required_wrong_value:1,required_wrong_type:2,required_present:3,optional_present:4};if(o[e.status]!==o[s.status]){return o[e.status]-o[s.status]}return e.key.localeCompare(s.key)});i.sort((e,s)=>e.key.localeCompare(s.key));return{requiredVars:r,optionalVars:i}};export const calculateStats=(n,d,r)=>{const i=Object.keys(r).length;const p=n.length;const e=n.filter(t=>t.status==="required_missing").length;const s=n.filter(t=>t.status==="required_wrong_value").length;const o=n.filter(t=>t.status==="required_wrong_type").length;const u=n.filter(t=>t.status==="required_present").length;const a=d.length;return{totalCount:i,requiredCount:p,missingCount:e,wrongValueCount:s,wrongTypeCount:o,presentRequiredCount:u,optionalCount:a}};
|
package/lib/module/index.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Export preset configuration (easiest way to add to FloatingDevTools!)
|
|
4
|
-
export { envToolPreset, createEnvTool } from "./preset";
|
|
5
|
-
|
|
6
|
-
// Export main modal component
|
|
7
|
-
// `EnvToolView` is the same tool rendered inline (header bar + body) instead
|
|
8
|
-
// of inside a JsModal — for hosts that show tools in a panel.
|
|
9
|
-
export { EnvVarsModal, EnvToolView } from "./env/components/EnvVarsModal";
|
|
10
|
-
|
|
11
|
-
// External sync (adapter for @buoy-gg/external-sync's useExternalSync)
|
|
12
|
-
export { createEnvSyncAdapter } from "./sync/envSyncAdapter";
|
|
13
|
-
|
|
14
|
-
/** @internal - Remote mirror mode only (desktop dashboard). */
|
|
15
|
-
export { setRemoteEnv } from "./env/utils/remoteEnv";
|
|
16
|
-
|
|
17
|
-
// Export types (Environment, UserRole, RequiredEnvVar, etc.)
|
|
18
|
-
export * from "./env/types";
|
|
19
|
-
|
|
20
|
-
// Export utilities (createEnvVarConfig, envVar, etc.)
|
|
21
|
-
export * from "./env/utils";
|
|
1
|
+
"use strict";export{envToolPreset,createEnvTool}from"./preset";export{EnvVarsModal,EnvToolView}from"./env/components/EnvVarsModal";export{createEnvSyncAdapter}from"./sync/envSyncAdapter";export{setRemoteEnv}from"./env/utils/remoteEnv";export*from"./env/types";export*from"./env/utils";
|
package/lib/module/preset.js
CHANGED
|
@@ -1,78 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Pre-configured environment variables tool for FloatingDevTools
|
|
5
|
-
*
|
|
6
|
-
* This preset provides a zero-config way to add env var inspection to your dev tools.
|
|
7
|
-
* Just import and add it to your apps array!
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* import { envToolPreset } from '@buoy-gg/env';
|
|
12
|
-
*
|
|
13
|
-
* const installedApps = [
|
|
14
|
-
* envToolPreset, // That's it!
|
|
15
|
-
* // ...other tools
|
|
16
|
-
* ];
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { EnvIcon } from "@buoy-gg/floating-tools-core";
|
|
21
|
-
import { EnvVarsModal } from "./env/components/EnvVarsModal";
|
|
22
|
-
import { setToolRequiredEnvVars } from "./sync/envSyncAdapter";
|
|
23
|
-
import { createToolFactory, defineToolPreset } from "@buoy-gg/shared-ui";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Pre-configured environment variables tool for FloatingDevTools.
|
|
27
|
-
* Includes:
|
|
28
|
-
* - Automatic env var discovery
|
|
29
|
-
* - Required variable validation
|
|
30
|
-
* - Search and filtering
|
|
31
|
-
* - Copy functionality
|
|
32
|
-
*/
|
|
33
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
-
export const envToolPreset = defineToolPreset({
|
|
35
|
-
id: "env",
|
|
36
|
-
name: "ENV",
|
|
37
|
-
description: "Environment variables debugger",
|
|
38
|
-
slot: "both",
|
|
39
|
-
icon: ({
|
|
40
|
-
size
|
|
41
|
-
}) => /*#__PURE__*/_jsx(EnvIcon, {
|
|
42
|
-
size: size
|
|
43
|
-
}),
|
|
44
|
-
component: EnvVarsModal,
|
|
45
|
-
props: {
|
|
46
|
-
requiredEnvVars: [],
|
|
47
|
-
enableSharedModalDimensions: true
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Create a custom environment variables tool configuration.
|
|
53
|
-
* Use this if you want to override default settings or provide required env vars.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```tsx
|
|
57
|
-
* import { createEnvTool, envVar, createEnvVarConfig } from '@buoy-gg/env';
|
|
58
|
-
*
|
|
59
|
-
* const requiredEnvVars = createEnvVarConfig([
|
|
60
|
-
* envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
61
|
-
* envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
62
|
-
* ]);
|
|
63
|
-
*
|
|
64
|
-
* const myEnvTool = createEnvTool({
|
|
65
|
-
* requiredEnvVars,
|
|
66
|
-
* colorPreset: "cyan",
|
|
67
|
-
* enableSharedModalDimensions: true,
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export const createEnvTool = createToolFactory(envToolPreset, options => {
|
|
72
|
-
// Shared with the sync adapter so the desktop panel checks the same list.
|
|
73
|
-
setToolRequiredEnvVars(options.requiredEnvVars || []);
|
|
74
|
-
return {
|
|
75
|
-
requiredEnvVars: options.requiredEnvVars || [],
|
|
76
|
-
enableSharedModalDimensions: options.enableSharedModalDimensions ?? true
|
|
77
|
-
};
|
|
78
|
-
});
|
|
1
|
+
"use strict";import{EnvIcon as r}from"@buoy-gg/floating-tools-core";import{EnvVarsModal as o}from"./env/components/EnvVarsModal";import{setToolRequiredEnvVars as n}from"./sync/envSyncAdapter";import{createToolFactory as s,defineToolPreset as a}from"@buoy-gg/shared-ui";import{jsx as i}from"react/jsx-runtime";export const envToolPreset=a({id:"env",name:"ENV",description:"Environment variables debugger",slot:"both",icon:({size:e})=>i(r,{size:e}),component:o,props:{requiredEnvVars:[],enableSharedModalDimensions:true}});export const createEnvTool=s(envToolPreset,e=>{n(e.requiredEnvVars||[]);return{requiredEnvVars:e.requiredEnvVars||[],enableSharedModalDimensions:e.enableSharedModalDimensions??true}});
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { getRemoteEnv } from "../env/utils/remoteEnv";
|
|
4
|
-
/** Collect the device's env vars (only EXPO_PUBLIC_-style vars exist in RN). */
|
|
5
|
-
function collectEnv() {
|
|
6
|
-
const env = {};
|
|
7
|
-
// @ts-ignore process.env does exist
|
|
8
|
-
for (const [key, value] of Object.entries(getRemoteEnv() ?? (typeof process === "undefined" ? {} : process.env))) {
|
|
9
|
-
if (typeof value === "string") {
|
|
10
|
-
env[key] = value;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return env;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Create a sync adapter for the env tool, consumed by @buoy-gg/external-sync's
|
|
18
|
-
* `useExternalSync` (structurally matches its ToolSyncAdapter interface so
|
|
19
|
-
* this package doesn't need a dependency on it).
|
|
20
|
-
*
|
|
21
|
-
* Env vars are baked into the bundle, so the snapshot is static — it's sent
|
|
22
|
-
* once when a dashboard starts watching. Pass the same `requiredEnvVars`
|
|
23
|
-
* config you give FloatingDevTools so the dashboard validates against it.
|
|
24
|
-
*/
|
|
25
|
-
let toolRequiredEnvVars = [];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Called by `createEnvTool`. An app that declares its variables on the tool
|
|
29
|
-
* (`apps={[createEnvTool({ requiredEnvVars })]}`) rather than on
|
|
30
|
-
* FloatingDevTools used to sync an empty list, so the desktop panel checked
|
|
31
|
-
* nothing and showed no required variables.
|
|
32
|
-
*/
|
|
33
|
-
export function setToolRequiredEnvVars(vars) {
|
|
34
|
-
toolRequiredEnvVars = vars;
|
|
35
|
-
}
|
|
36
|
-
export function createEnvSyncAdapter(requiredEnvVars = []) {
|
|
37
|
-
return {
|
|
38
|
-
version: 1,
|
|
39
|
-
getSnapshot: () => ({
|
|
40
|
-
env: collectEnv(),
|
|
41
|
-
requiredEnvVars: requiredEnvVars.length > 0 ? requiredEnvVars : toolRequiredEnvVars
|
|
42
|
-
}),
|
|
43
|
-
// Env never changes at runtime — nothing to subscribe to
|
|
44
|
-
subscribe: () => () => {}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
1
|
+
"use strict";import{getRemoteEnv as r}from"../env/utils/remoteEnv";function s(){const e={};for(const[o,t]of Object.entries(r()??(typeof process==="undefined"?{}:process.env))){if(typeof t==="string"){e[o]=t}}return e}let n=[];export function setToolRequiredEnvVars(e){n=e}export function createEnvSyncAdapter(e=[]){return{version:1,getSnapshot:()=>({env:s(),requiredEnvVars:e.length>0?e:n}),subscribe:()=>()=>{}}}
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var ye=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var o in t)ye(e,o,{get:t[o],enumerable:!0})},pe=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Le(t))!Ae.call(e,r)&&r!==o&&ye(e,r,{get:()=>t[r],enumerable:!(s=_e(t,r))||s.enumerable});return e},g=(e,t,o)=>(pe(e,t,"default"),o&&pe(o,t,"default"));typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{EnvIcon as rn}from"@buoy-gg/floating-tools-core/web";import{JsModal as Gt,devToolsStorageKeys as Ee,ModalHeader as z,HeaderSearchButton as Ut,displayValue as Jt,buoyColors as K,night as Z,windowDragProps as Xt,ToolEmptyState as Qt,resolveListEmptyState as Yt,monoFont as Ve}from"@buoy-gg/shared-ui/web";import{useCallback as Zt,useState as ae,useRef as en,useEffect as Se,useMemo as F}from"react";var c={};Me(c,{AccessibilityInfo:()=>Qe,ActivityIndicator:()=>je,Alert:()=>Ue,Animated:()=>Ye,AppRegistry:()=>et,AppState:()=>tt,Appearance:()=>Ze,BackHandler:()=>nt,Button:()=>Ke,CheckBox:()=>vt,Clipboard:()=>ot,DeviceEventEmitter:()=>Lt,Dimensions:()=>rt,Easing:()=>it,FlatList:()=>ht,I18nManager:()=>st,Image:()=>xt,ImageBackground:()=>wt,InteractionManager:()=>lt,Keyboard:()=>at,KeyboardAvoidingView:()=>Tt,LayoutAnimation:()=>ct,Linking:()=>ut,LogBox:()=>_t,Modal:()=>ze,NativeEventEmitter:()=>dt,NativeModules:()=>Xe,PanResponder:()=>pt,Picker:()=>Et,PixelRatio:()=>yt,Platform:()=>ft,Pressable:()=>$e,ProgressBar:()=>Vt,RefreshControl:()=>St,SafeAreaView:()=>Ct,ScrollView:()=>ne,SectionList:()=>It,Share:()=>bt,StatusBar:()=>Rt,StyleSheet:()=>C,Switch:()=>Fe,Text:()=>y,TextInput:()=>He,Touchable:()=>kt,TouchableHighlight:()=>Be,TouchableNativeFeedback:()=>qt,TouchableOpacity:()=>B,TouchableWithoutFeedback:()=>Ne,UIManager:()=>gt,Vibration:()=>mt,View:()=>p,VirtualizedList:()=>Dt,YellowBox:()=>Wt,findNodeHandle:()=>Ge,unstable_createElement:()=>Je,useColorScheme:()=>At,useLocaleContext:()=>Mt,useWindowDimensions:()=>Ot});g(c,fn);import*as fn from"react-native-web";import{unstable_createElement as Je,NativeModules as Xe,AccessibilityInfo as Qe,Animated as Ye,Appearance as Ze,AppRegistry as et,AppState as tt,BackHandler as nt,Clipboard as ot,Dimensions as rt,Easing as it,I18nManager as st,Keyboard as at,InteractionManager as lt,LayoutAnimation as ct,Linking as ut,NativeEventEmitter as dt,PanResponder as pt,PixelRatio as yt,Platform as ft,Share as bt,StyleSheet as C,UIManager as gt,Vibration as mt,CheckBox as vt,FlatList as ht,Image as xt,ImageBackground as wt,KeyboardAvoidingView as Tt,Picker as Et,ProgressBar as Vt,RefreshControl as St,SafeAreaView as Ct,SectionList as It,StatusBar as Rt,Touchable as kt,TouchableNativeFeedback as qt,VirtualizedList as Dt,YellowBox as Wt,LogBox as _t,DeviceEventEmitter as Lt,useColorScheme as At,useLocaleContext as Mt,useWindowDimensions as Ot}from"react-native-web";import*as l from"react-native-web";import{createElement as Oe,forwardRef as Pe}from"react";function T(e){let t=Pe((s,r)=>{let{accessibilityState:n,accessibilityValue:a,...i}=s;for(let f of["busy","checked","disabled","expanded","selected"])n?.[f]!==void 0&&i[`aria-${f}`]===void 0&&(i[`aria-${f}`]=n[f]);for(let[f,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[f]!==void 0&&i[`aria-${u}`]===void 0&&(i[`aria-${u}`]=a[f]);return Oe(e,{...i,ref:r})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var p=T(l.View),y=T(l.Text),He=T(l.TextInput),B=T(l.TouchableOpacity),Be=T(l.TouchableHighlight),Ne=T(l.TouchableWithoutFeedback),$e=T(l.Pressable),ne=T(l.ScrollView),ze=T(l.Modal),Fe=T(l.Switch),je=T(l.ActivityIndicator),Ke=T(l.Button),Ge=l.findNodeHandle,Ue={alert(e,t,o,s){if(typeof document>"u")return;let r=document.createElement("dialog");r.dataset.buoyRoot="",r.setAttribute("aria-label",e),r.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",r.appendChild(n),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",r.appendChild(u)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=o?.length?o:[{text:"OK"}],f=()=>{r.close?.(),r.remove()};for(let u of i){let d=document.createElement("button");d.type="button",d.textContent=u.text??"OK",d.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,d.onclick=()=>{f(),u.onPress?.()},a.appendChild(d)}r.addEventListener("cancel",u=>{u.preventDefault(),s?.cancelable!==!1&&(f(),s?.onDismiss?.())}),r.appendChild(a),document.body.appendChild(r),r.showModal?r.showModal():r.setAttribute("open","")}};import{CompactRow as Pt,night as R,monoFont as fe}from"@buoy-gg/shared-ui/web";import{jsx as k,jsxs as A}from"react/jsx-runtime";function be({stats:e,healthPercentage:t,healthStatus:o,healthColor:s,activeFilter:r="all",onFilterChange:n}){let a=e.wrongValueCount+e.wrongTypeCount;return A(p,{style:b.container,children:[k(Pt,{statusDotColor:s,statusLabel:"System",statusSublabel:o.toLowerCase(),primaryText:"Environment Configuration",secondaryText:`${t}% healthy`,testID:"buoy-env-health",statusSublabelTestID:"buoy-env-health-status",accessibilityLabel:`Environment configuration ${o.toLowerCase()}, ${t}% healthy`,customBadge:k(p,{style:[b.percentBadge,{borderColor:s+"40",backgroundColor:s+"10"}],children:A(y,{style:[b.percentText,{color:s}],testID:"buoy-env-health-percent",children:[t,"%"]})})}),A(p,{style:b.statsGrid,children:[A(B,{style:[b.statCard,r==="all"&&b.statCardActive],onPress:()=>n?.("all"),activeOpacity:.8,testID:"buoy-env-filter-all",accessibilityRole:"button",accessibilityLabel:"Show all variables",accessibilityState:{selected:r==="all"},children:[k(y,{style:[b.statValue,r==="all"&&b.statValueActive],testID:"buoy-env-filter-all-count",children:e.requiredCount+e.optionalCount}),k(y,{style:[b.statLabel,r==="all"&&b.statLabelActive],children:"ALL"})]}),A(B,{style:[b.statCard,r==="missing"&&b.statCardActive],onPress:()=>n?.("missing"),activeOpacity:.8,testID:"buoy-env-filter-missing",accessibilityRole:"button",accessibilityLabel:"Show missing variables",accessibilityState:{selected:r==="missing"},children:[k(y,{style:[b.statValue,r==="missing"&&b.statValueActive],testID:"buoy-env-filter-missing-count",children:e.missingCount}),k(y,{style:[b.statLabel,r==="missing"&&b.statLabelActive],children:"MISSING"})]}),A(B,{style:[b.statCard,r==="issues"&&b.statCardActive],onPress:()=>n?.("issues"),activeOpacity:.8,testID:"buoy-env-filter-issues",accessibilityRole:"button",accessibilityLabel:"Show variables with issues",accessibilityState:{selected:r==="issues"},children:[k(y,{style:[b.statValue,r==="issues"&&b.statValueActive],testID:"buoy-env-filter-issues-count",children:a}),k(y,{style:[b.statLabel,r==="issues"&&b.statLabelActive],children:"ISSUES"})]})]})]})}var b=C.create({container:{gap:8},statsGrid:{flexDirection:"row",gap:8,paddingHorizontal:4},statCard:{flex:1,backgroundColor:R.color.surface,borderRadius:10,borderWidth:1,borderColor:R.color.border,padding:12,alignItems:"center",justifyContent:"center",minHeight:64},statCardActive:{borderColor:R.color.accentBorderStrong,backgroundColor:R.color.accentSoft},statValue:{fontSize:22,fontWeight:"700",fontFamily:fe,lineHeight:26,color:R.color.text},statValueActive:{color:R.color.accent},statLabel:{fontSize:9,color:R.color.textTertiary,marginTop:4,textTransform:"uppercase",letterSpacing:.5,fontWeight:"600"},statLabelActive:{color:R.color.accent},percentBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:6,borderWidth:1},percentText:{fontSize:14,fontWeight:"700",fontFamily:fe}});import{useMemo as me}from"react";var ge=null;function Ht(e){ge=e}function X(){return ge}function ve({envFilter:e=()=>!0}={}){let t=X()??(typeof process>"u"?{}:process.env),o=me(()=>r=>{let n=t[r];if(n===void 0)return null;try{if(n.startsWith("{")||n.startsWith("["))return JSON.parse(n);if(n.toLowerCase()==="true")return!0;if(n.toLowerCase()==="false")return!1;if(/^\d+$/.test(n)){let a=parseInt(n,10);return isNaN(a)?n:a}if(/^\d*\.\d+$/.test(n)){let a=parseFloat(n);return isNaN(a)?n:a}return n}catch{return n}},[t]);return me(()=>Object.keys(t).filter(a=>{let i=t[a];return e(a,i)}).map(a=>({key:a,data:o(a)})),[e,o,t])}function Q(e){let t=typeof e;if(t==="boolean")return"boolean";if(t==="number")return"number";if(Array.isArray(e))return"array";if(t==="object"&&e!==null)return"object";if(t==="string"){let o=e;if(o.startsWith("{")&&o.endsWith("}")||o.startsWith("[")&&o.endsWith("]"))try{let r=JSON.parse(o);return Array.isArray(r)?"array":"object"}catch{return"string"}let s=o.toLowerCase();return s==="true"||s==="false"||s==="enabled"||s==="disabled"||s==="yes"||s==="no"||s==="on"||s==="off"?"boolean":!isNaN(Number(o))&&o.trim()!==""?"number":o.startsWith("http://")||o.startsWith("https://")?"url":o.includes(",")?"array":"string"}return"unknown"}var oe=class{constructor(t){this.key=t}exists(){return this.key}withValue(t){return this.expectedValue=t,delete this.expectedType,this}withType(t){return this.expectedType=t,delete this.expectedValue,this}withDescription(t){return this.description=t,this}build(){return this.expectedValue!==void 0?this.description?{key:this.key,expectedValue:this.expectedValue,description:this.description}:{key:this.key,expectedValue:this.expectedValue}:this.expectedType!==void 0?this.description?{key:this.key,expectedType:this.expectedType,description:this.description}:{key:this.key,expectedType:this.expectedType}:this.key}};function kn(e){return new oe(e)}function qn(e){return e}var he=(e,t)=>{let o=[],s=[],r=new Set;return t?.forEach(n=>{let a=typeof n=="string"?n:n.key,i=typeof n=="object"&&"expectedValue"in n?n.expectedValue:void 0,f=typeof n=="object"&&"expectedType"in n?n.expectedType:void 0,u=typeof n=="object"&&"description"in n?n.description:void 0;r.add(a);let d=e[a],D=d!==void 0,S;if(!D)S="required_missing";else if(i){let W=!1;i==="sk_*"?W=d.startsWith("sk_"):i==="production or development"?W=d==="production"||d==="development":W=d===i,S=W?"required_present":"required_wrong_value"}else f&&Q(d).toLowerCase()!==f.toLowerCase()?S="required_wrong_type":S="required_present";o.push({key:a,value:d,expectedValue:i,expectedType:f,description:u,status:S,category:"required"})}),Object.entries(e).forEach(([n,a])=>{r.has(n)||s.push({key:n,value:a,status:"optional_present",category:"optional"})}),o.sort((n,a)=>{let i={required_missing:0,required_wrong_value:1,required_wrong_type:2,required_present:3,optional_present:4};return i[n.status]!==i[a.status]?i[n.status]-i[a.status]:n.key.localeCompare(a.key)}),s.sort((n,a)=>n.key.localeCompare(a.key)),{requiredVars:o,optionalVars:s}},xe=(e,t,o)=>{let s=Object.keys(o).length,r=e.length,n=e.filter(d=>d.status==="required_missing").length,a=e.filter(d=>d.status==="required_wrong_value").length,i=e.filter(d=>d.status==="required_wrong_type").length,f=e.filter(d=>d.status==="required_present").length,u=t.length;return{totalCount:s,requiredCount:r,missingCount:n,wrongValueCount:a,wrongTypeCount:i,presentRequiredCount:f,optionalCount:u}};import{useCallback as Ft,useState as jt}from"react";import{CompactRow as Bt,TypeBadge as re,buoyColors as M,night as ie,monoFont as se}from"@buoy-gg/shared-ui/web";import{Fragment as zt,jsx as E,jsxs as L}from"react/jsx-runtime";var Nt=(e,t)=>{switch(e){case"required_present":return{label:"Valid",color:M.success,sublabel:"Required"};case"required_missing":return{label:"Missing",color:M.error,sublabel:"Required"};case"required_wrong_value":return{label:"Wrong",color:M.warning,sublabel:"Invalid value"};case"required_wrong_type":return{label:"Type Error",color:M.info,sublabel:"Wrong type"};case"optional_present":return{label:"Set",color:M.textSecondary,sublabel:"Optional"}}};var $t=e=>e==null?"undefined":typeof e=="string"?e:String(e);function we({envVar:e,isExpanded:t,onPress:o}){let s=Nt(e.status,e.expectedType),r=e.value!==void 0&&e.value!==null,a=e.key.split("_").map(u=>u.toLowerCase()).join(" \u203A "),i=`buoy-env-row-${e.key}`,f=L(p,{style:m.expandedContainer,children:[L(p,{style:m.expandedRow,children:[E(y,{style:m.expandedLabel,children:"Value:"}),E(y,{style:m.expandedValue,numberOfLines:3,testID:`${i}-value`,children:$t(e.value)||"undefined"})]}),e.status==="required_wrong_type"&&e.expectedType&&L(zt,{children:[L(p,{style:m.expandedRow,children:[E(y,{style:m.expandedLabel,children:"Type:"}),E(re,{type:Q(e.value),testID:`${i}-actual-type`})]}),L(p,{style:m.expandedRow,children:[E(y,{style:m.expandedLabel,children:"Expected:"}),E(re,{type:e.expectedType,testID:`${i}-expected-type`})]})]}),e.status==="required_wrong_value"&&e.expectedValue&&L(p,{style:m.expandedRow,children:[E(y,{style:m.expandedLabel,children:"Expected:"}),E(y,{style:m.expandedExpected,testID:`${i}-expected-value`,children:String(e.expectedValue)})]}),e.description&&L(p,{style:m.expandedRow,children:[E(y,{style:m.expandedLabel,children:"Info:"}),E(y,{style:m.expandedDescription,testID:`${i}-description`,children:e.description})]})]});return E(Bt,{statusDotColor:s.color,statusLabel:s.label,statusSublabel:s.sublabel,primaryText:a,secondaryText:void 0,expandedContent:f,isExpanded:t,expandedGlowColor:s.color,customBadge:e.expectedType?E(re,{type:e.expectedType,testID:`${i}-type-badge`}):void 0,showChevron:!0,onPress:o?()=>o(e):void 0,testID:i,statusTestID:`${i}-status`,statusSublabelTestID:`${i}-category`,accessibilityLabel:`${e.key}, ${s.label}, ${s.sublabel}`})}var m=C.create({expandedContainer:{gap:6},expandedRow:{flexDirection:"row",alignItems:"center",gap:8},expandedLabel:{fontSize:10,color:ie.color.textTertiary,fontWeight:"600",minWidth:60,fontFamily:se},expandedValue:{fontSize:11,color:ie.color.textSecondary,fontFamily:se,flex:1},expandedExpected:{fontSize:11,color:M.warning,fontFamily:se,flex:1},expandedDescription:{fontSize:11,color:ie.color.textSecondary,flex:1}});import{SectionHeader as O,night as $,monoFont as Kt}from"@buoy-gg/shared-ui/web";import{jsx as q,jsxs as Y}from"react/jsx-runtime";function Te({title:e,count:t,vars:o,emptyMessage:s}){let[r,n]=jt(null),a=Ft(i=>{n(f=>f===i.key?null:i.key)},[]);return o.length===0&&e==="Required Variables"?Y(p,{style:N.sectionContainer,children:[Y(O,{children:[q(O.Title,{children:e}),q(O.Badge,{count:0,color:$.color.accent})]}),q(p,{style:N.emptySection,children:q(y,{style:N.emptySectionText,children:s})})]}):o.length===0?null:Y(p,{style:N.sectionContainer,children:[e!==""&&Y(O,{children:[q(O.Title,{children:e}),q(O.Badge,{count:t,color:$.color.accent})]}),q(p,{style:N.sectionContent,children:o.map(i=>q(we,{envVar:i,isExpanded:r===i.key,onPress:a},i.key))})]})}var N=C.create({sectionContainer:{gap:8},sectionContent:{},emptySection:{padding:20,backgroundColor:$.color.accent+"08",borderRadius:8,borderWidth:1,borderColor:$.color.accent+"20",alignItems:"center"},emptySectionText:{color:$.color.accent,fontSize:11,textAlign:"center",fontFamily:Kt,opacity:.8,letterSpacing:.5}});import{jsx as v,jsxs as j}from"react/jsx-runtime";function ee({visible:e,onClose:t,requiredEnvVars:o,onBack:s,onMinimize:r,enableSharedModalDimensions:n=!1,inline:a=!1}){let[i,f]=ae("all"),[u,d]=ae(!1),[D,S]=ae(""),W=en(null),ke=Zt(V=>{},[]);Se(()=>{u&&W.current&&W.current.focus()},[u]),Se(()=>{S(""),d(!1)},[i]);let le=ve(),G=F(()=>{let V={};return le.forEach(({key:h,data:x})=>{x!=null&&(V[h]=typeof x=="string"?x:Jt(x))}),V},[le]),{requiredVars:U,optionalVars:P}=F(()=>he(G,o),[G,o]),J=F(()=>o===void 0?{totalCount:0,requiredCount:0,optionalCount:0,presentRequiredCount:0,missingCount:0,wrongValueCount:0,wrongTypeCount:0}:xe(U,P,G),[o,U,P,G]),H=F(()=>[...U,...P].sort((h,x)=>{let de={required_missing:1,required_wrong_type:2,required_wrong_value:3,required_present:4,optional_present:5};return(de[h.status]||999)-(de[x.status]||999)}),[U,P]),te=F(()=>{let V=[];switch(i){case"all":V=H;break;case"missing":V=H.filter(h=>h.status==="required_missing");break;case"issues":V=H.filter(h=>h.status==="required_wrong_type"||h.status==="required_wrong_value");break}if(D){let h=D.toLowerCase();V=V.filter(x=>x.key.toLowerCase().includes(h)||x.description?.toLowerCase().includes(h)||typeof x.value=="string"&&x.value.toLowerCase().includes(h))}return V},[H,P,i,D]),_=J.requiredCount>0?Math.round(J.presentRequiredCount/J.requiredCount*100):100,qe=_===100?"HEALTHY":_>=75?"WARNING":_>=50?"ERROR":"CRITICAL",De=_===100?K.success:_>=75?K.warning:_>=50?K.error:K.error;if(!e)return null;let We=n?Ee.modal.root():Ee.env.modal(),ce=j(z,{children:[s&&v(z.Navigation,{onBack:s}),v(z.Content,{title:u?"":"Environment Variables",noMargin:u,children:u&&v(z.Search,{value:D,onChangeText:S,onCancel:()=>{d(!1),S("")},placeholder:"Search env keys...",accessibilityLabel:"Search env keys",testID:"buoy-env-search",containerTestID:"buoy-env-search-field",clearTestID:"buoy-env-search-clear"})}),v(z.Actions,{children:!u&&v(Ut,{onPress:()=>d(!0),testID:"buoy-env-search-open",accessibilityLabel:"Search env keys"})})]}),ue=j(ne,{style:I.scrollContainer,contentContainerStyle:I.contentContainer,showsVerticalScrollIndicator:!1,testID:"buoy-env-scroll",children:[v(be,{stats:J,healthPercentage:_,healthStatus:qe,healthColor:De,activeFilter:i,onFilterChange:f}),te.length>0?j(p,{style:I.varsSection,children:[j(p,{style:I.sectionHeader,children:[v(y,{style:I.sectionTitle,testID:"buoy-env-section-title",children:i==="all"?"ALL VARIABLES":i==="missing"?"MISSING VARIABLES":"ISSUES TO FIX"}),v(p,{style:I.countBadge,children:v(y,{style:I.countText,testID:"buoy-env-section-count",children:te.length})})]}),v(Te,{title:"",count:0,vars:te,emptyMessage:""})]}):v(Qt,{testID:"buoy-env-empty",...Yt({subject:"variables",verb:"declared",search:D,total:H.length,waiting:{otto:"keys",title:"No variables",message:`No ${i==="all"?"":i} variables found`}})})]});return a?j(p,{style:I.inlineRoot,children:[v(p,{style:I.inlineHeader,...Xt,children:ce}),ue]}):v(Gt,{visible:e,onClose:t,onMinimize:r,persistenceKey:We,header:{customContent:ce,showToggleButton:!0},onModeChange:ke,enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,styles:{},children:ue})}function tn({requiredEnvVars:e}){return v(ee,{inline:!0,visible:!0,requiredEnvVars:e,onClose:()=>{}})}var I=C.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:K.border,backgroundColor:"transparent"},scrollContainer:{flex:1,backgroundColor:"transparent"},contentContainer:{padding:8,paddingBottom:24},varsSection:{marginTop:16},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8,paddingHorizontal:8},sectionTitle:{fontSize:10,fontWeight:"700",color:Z.color.textTertiary,letterSpacing:1.2,fontFamily:Ve},countBadge:{backgroundColor:Z.color.accent+"15",paddingHorizontal:8,paddingVertical:2,borderRadius:9999,borderWidth:1,borderColor:Z.color.accent+"40"},countText:{fontSize:10,fontWeight:"500",color:Z.color.accent,fontFamily:Ve}});function nn(){let e={};for(let[t,o]of Object.entries(X()??(typeof process>"u"?{}:process.env)))typeof o=="string"&&(e[t]=o);return e}var Ce=[];function Ie(e){Ce=e}function on(e=[]){return{version:1,getSnapshot:()=>({env:nn(),requiredEnvVars:e.length>0?e:Ce}),subscribe:()=>()=>{}}}import{createToolFactory as sn,defineToolPreset as an}from"@buoy-gg/shared-ui/web";import{jsx as cn}from"react/jsx-runtime";var Re=an({id:"env",name:"ENV",description:"Environment variables debugger",slot:"both",icon:({size:e})=>cn(rn,{size:e}),component:ee,props:{requiredEnvVars:[],enableSharedModalDimensions:!0}}),ln=sn(Re,e=>(Ie(e.requiredEnvVars||[]),{requiredEnvVars:e.requiredEnvVars||[],enableSharedModalDimensions:e.enableSharedModalDimensions??!0}));export{tn as EnvToolView,ee as EnvVarsModal,xe as calculateStats,on as createEnvSyncAdapter,ln as createEnvTool,qn as createEnvVarConfig,Re as envToolPreset,kn as envVar,Q as getEnvVarType,he as processEnvVars,Ht as setRemoteEnv};
|
|
1
|
+
"use client";var oe=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Ie=(e,a)=>{for(var r in a)oe(e,r,{get:a[r],enumerable:true})},ie=(e,a,r,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of Ve(a))!ke.call(e,t)&&t!==r&&oe(e,t,{get:()=>a[t],enumerable:!(n=Te(a,t))||n.enumerable});return e},Ee=(e,a,r)=>(ie(e,a,"default"),r&&ie(r,a,"default"));typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{EnvIcon as Le}from"@buoy-gg/floating-tools-core/web";import{JsModal as Ae,devToolsStorageKeys as se,ModalHeader as M,HeaderSearchButton as qe,displayValue as De,buoyColors as j,night as K,windowDragProps as _e,ToolEmptyState as Re,resolveListEmptyState as Be,monoFont as le}from"@buoy-gg/shared-ui/web";import{useCallback as Me,useState as Y,useRef as je,useEffect as ce,useMemo as P}from"react";var de={};Ie(de,{AccessibilityInfo:()=>Fe,ActivityIndicator:()=>Mt,Alert:()=>Wt,Animated:()=>Oe,AppRegistry:()=>He,AppState:()=>$e,Appearance:()=>ze,BackHandler:()=>Ke,Button:()=>jt,CheckBox:()=>lt,Clipboard:()=>Ge,DeviceEventEmitter:()=>Tt,Dimensions:()=>Ue,Easing:()=>Je,FlatList:()=>ct,I18nManager:()=>Ye,Image:()=>dt,ImageBackground:()=>ut,InteractionManager:()=>Qe,Keyboard:()=>Xe,KeyboardAvoidingView:()=>pt,LayoutAnimation:()=>Ze,Linking:()=>et,LogBox:()=>St,Modal:()=>Rt,NativeEventEmitter:()=>tt,NativeModules:()=>Ne,PanResponder:()=>rt,Picker:()=>yt,PixelRatio:()=>at,Platform:()=>nt,Pressable:()=>_t,ProgressBar:()=>ht,RefreshControl:()=>bt,SafeAreaView:()=>gt,ScrollView:()=>ue,SectionList:()=>ft,Share:()=>ot,StatusBar:()=>mt,StyleSheet:()=>W,Switch:()=>Bt,Text:()=>y,TextInput:()=>At,Touchable:()=>vt,TouchableHighlight:()=>qt,TouchableNativeFeedback:()=>xt,TouchableOpacity:()=>G,TouchableWithoutFeedback:()=>Dt,UIManager:()=>it,Vibration:()=>st,View:()=>p,VirtualizedList:()=>Ct,YellowBox:()=>wt,findNodeHandle:()=>Pt,unstable_createElement:()=>We,useColorScheme:()=>Vt,useLocaleContext:()=>kt,useWindowDimensions:()=>It});Ee(de,Pe);import*as Pe from"react-native-web";import{unstable_createElement as We,NativeModules as Ne,AccessibilityInfo as Fe,Animated as Oe,Appearance as ze,AppRegistry as He,AppState as $e,BackHandler as Ke,Clipboard as Ge,Dimensions as Ue,Easing as Je,I18nManager as Ye,Keyboard as Xe,InteractionManager as Qe,LayoutAnimation as Ze,Linking as et,NativeEventEmitter as tt,PanResponder as rt,PixelRatio as at,Platform as nt,Share as ot,StyleSheet as W,UIManager as it,Vibration as st,CheckBox as lt,FlatList as ct,Image as dt,ImageBackground as ut,KeyboardAvoidingView as pt,Picker as yt,ProgressBar as ht,RefreshControl as bt,SafeAreaView as gt,SectionList as ft,StatusBar as mt,Touchable as vt,TouchableNativeFeedback as xt,VirtualizedList as Ct,YellowBox as wt,LogBox as St,DeviceEventEmitter as Tt,useColorScheme as Vt,useLocaleContext as kt,useWindowDimensions as It}from"react-native-web";import*as g from"react-native-web";import{createElement as Et,forwardRef as Lt}from"react";function x(e){let a=Lt((n,t)=>{let{accessibilityState:o,accessibilityValue:s,...i}=n;for(let d of["busy","checked","disabled","expanded","selected"])o?.[d]!==void 0&&i[`aria-${d}`]===void 0&&(i[`aria-${d}`]=o[d]);for(let[d,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[d]!==void 0&&i[`aria-${c}`]===void 0&&(i[`aria-${c}`]=s[d]);return Et(e,{...i,ref:t})}),r=e.State;return r&&Object.assign(a,{State:r}),a.displayName=e.displayName??e.name??"NativeWebView",a}var p=x(g.View),y=x(g.Text),At=x(g.TextInput),G=x(g.TouchableOpacity),qt=x(g.TouchableHighlight),Dt=x(g.TouchableWithoutFeedback),_t=x(g.Pressable),ue=x(g.ScrollView),Rt=x(g.Modal),Bt=x(g.Switch),Mt=x(g.ActivityIndicator),jt=x(g.Button),Pt=g.findNodeHandle,Wt={alert(e,a,r,n){if(typeof document>"u")return;let t=document.createElement("dialog");t.dataset.buoyRoot="",t.setAttribute("aria-label",e),t.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let o=document.createElement("h2");if(o.textContent=e,o.style.cssText="font-size:18px;margin:0 0 12px",t.appendChild(o),a){let c=document.createElement("p");c.textContent=a,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",t.appendChild(c)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=r?.length?r:[{text:"OK"}],d=()=>{t.close?.(),t.remove()};for(let c of i){let l=document.createElement("button");l.type="button",l.textContent=c.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{d(),c.onPress?.()},s.appendChild(l)}t.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(d(),n?.onDismiss?.())}),t.appendChild(s),document.body.appendChild(t),t.showModal?t.showModal():t.setAttribute("open","")}};import{CompactRow as Nt,night as T,monoFont as pe}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as q}from"react/jsx-runtime";function Ft({stats:e,healthPercentage:a,healthStatus:r,healthColor:n,activeFilter:t="all",onFilterChange:o}){let s=e.wrongValueCount+e.wrongTypeCount;return q(p,{style:u.container,children:[V(Nt,{statusDotColor:n,statusLabel:"System",statusSublabel:r.toLowerCase(),primaryText:"Environment Configuration",secondaryText:`${a}% healthy`,testID:"buoy-env-health",statusSublabelTestID:"buoy-env-health-status",accessibilityLabel:`Environment configuration ${r.toLowerCase()}, ${a}% healthy`,customBadge:V(p,{style:[u.percentBadge,{borderColor:n+"40",backgroundColor:n+"10"}],children:q(y,{style:[u.percentText,{color:n}],testID:"buoy-env-health-percent",children:[a,"%"]})})}),q(p,{style:u.statsGrid,children:[q(G,{style:[u.statCard,t==="all"&&u.statCardActive],onPress:()=>o?.("all"),activeOpacity:.8,testID:"buoy-env-filter-all",accessibilityRole:"button",accessibilityLabel:"Show all variables",accessibilityState:{selected:t==="all"},children:[V(y,{style:[u.statValue,t==="all"&&u.statValueActive],testID:"buoy-env-filter-all-count",children:e.requiredCount+e.optionalCount}),V(y,{style:[u.statLabel,t==="all"&&u.statLabelActive],children:"ALL"})]}),q(G,{style:[u.statCard,t==="missing"&&u.statCardActive],onPress:()=>o?.("missing"),activeOpacity:.8,testID:"buoy-env-filter-missing",accessibilityRole:"button",accessibilityLabel:"Show missing variables",accessibilityState:{selected:t==="missing"},children:[V(y,{style:[u.statValue,t==="missing"&&u.statValueActive],testID:"buoy-env-filter-missing-count",children:e.missingCount}),V(y,{style:[u.statLabel,t==="missing"&&u.statLabelActive],children:"MISSING"})]}),q(G,{style:[u.statCard,t==="issues"&&u.statCardActive],onPress:()=>o?.("issues"),activeOpacity:.8,testID:"buoy-env-filter-issues",accessibilityRole:"button",accessibilityLabel:"Show variables with issues",accessibilityState:{selected:t==="issues"},children:[V(y,{style:[u.statValue,t==="issues"&&u.statValueActive],testID:"buoy-env-filter-issues-count",children:s}),V(y,{style:[u.statLabel,t==="issues"&&u.statLabelActive],children:"ISSUES"})]})]})]})}var u=W.create({container:{gap:8},statsGrid:{flexDirection:"row",gap:8,paddingHorizontal:4},statCard:{flex:1,backgroundColor:T.color.surface,borderRadius:10,borderWidth:1,borderColor:T.color.border,padding:12,alignItems:"center",justifyContent:"center",minHeight:64},statCardActive:{borderColor:T.color.accentBorderStrong,backgroundColor:T.color.accentSoft},statValue:{fontSize:22,fontWeight:"700",fontFamily:pe,lineHeight:26,color:T.color.text},statValueActive:{color:T.color.accent},statLabel:{fontSize:9,color:T.color.textTertiary,marginTop:4,textTransform:"uppercase",letterSpacing:.5,fontWeight:"600"},statLabelActive:{color:T.color.accent},percentBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:6,borderWidth:1},percentText:{fontSize:14,fontWeight:"700",fontFamily:pe}});import{useMemo as ye}from"react";var he=null;function Ot(e){he=e}function be(){return he}function zt({envFilter:e=()=>true}={}){let a=be()??(typeof process>"u"?{}:process.env),r=ye(()=>n=>{let t=a[n];if(t===void 0)return null;try{if(t.startsWith("{")||t.startsWith("["))return JSON.parse(t);if(t.toLowerCase()==="true")return true;if(t.toLowerCase()==="false")return false;if(/^\d+$/.test(t)){let o=parseInt(t,10);return isNaN(o)?t:o}if(/^\d*\.\d+$/.test(t)){let o=parseFloat(t);return isNaN(o)?t:o}return t}catch{return t}},[a]);return ye(()=>Object.keys(a).filter(n=>{let t=a[n];return e(n,t)}).map(n=>({key:n,data:r(n)})),[e,r,a])}function X(e){let a=typeof e;if(a==="boolean")return"boolean";if(a==="number")return"number";if(Array.isArray(e))return"array";if(a==="object"&&e!==null)return"object";if(a==="string"){let r=e;if(r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]"))try{let t=JSON.parse(r);return Array.isArray(t)?"array":"object"}catch{return"string"}let n=r.toLowerCase();return n==="true"||n==="false"||n==="enabled"||n==="disabled"||n==="yes"||n==="no"||n==="on"||n==="off"?"boolean":!isNaN(Number(r))&&r.trim()!==""?"number":r.startsWith("http://")||r.startsWith("https://")?"url":r.includes(",")?"array":"string"}return"unknown"}var Ht=class{constructor(e){this.key=e}exists(){return this.key}withValue(e){return this.expectedValue=e,delete this.expectedType,this}withType(e){return this.expectedType=e,delete this.expectedValue,this}withDescription(e){return this.description=e,this}build(){return this.expectedValue!==void 0?this.description?{key:this.key,expectedValue:this.expectedValue,description:this.description}:{key:this.key,expectedValue:this.expectedValue}:this.expectedType!==void 0?this.description?{key:this.key,expectedType:this.expectedType,description:this.description}:{key:this.key,expectedType:this.expectedType}:this.key}};function $t(e){return new Ht(e)}function Kt(e){return e}var ge=(e,a)=>{let r=[],n=[],t=new Set;return a?.forEach(o=>{let s=typeof o=="string"?o:o.key,i=typeof o=="object"&&"expectedValue"in o?o.expectedValue:void 0,d=typeof o=="object"&&"expectedType"in o?o.expectedType:void 0,c=typeof o=="object"&&"description"in o?o.description:void 0;t.add(s);let l=e[s],I=l!==void 0,w;if(!I)w="required_missing";else if(i){let E=false;i==="sk_*"?E=l.startsWith("sk_"):i==="production or development"?E=l==="production"||l==="development":E=l===i,w=E?"required_present":"required_wrong_value"}else d&&X(l).toLowerCase()!==d.toLowerCase()?w="required_wrong_type":w="required_present";r.push({key:s,value:l,expectedValue:i,expectedType:d,description:c,status:w,category:"required"})}),Object.entries(e).forEach(([o,s])=>{t.has(o)||n.push({key:o,value:s,status:"optional_present",category:"optional"})}),r.sort((o,s)=>{let i={required_missing:0,required_wrong_value:1,required_wrong_type:2,required_present:3,optional_present:4};return i[o.status]!==i[s.status]?i[o.status]-i[s.status]:o.key.localeCompare(s.key)}),n.sort((o,s)=>o.key.localeCompare(s.key)),{requiredVars:r,optionalVars:n}},fe=(e,a,r)=>{let n=Object.keys(r).length,t=e.length,o=e.filter(l=>l.status==="required_missing").length,s=e.filter(l=>l.status==="required_wrong_value").length,i=e.filter(l=>l.status==="required_wrong_type").length,d=e.filter(l=>l.status==="required_present").length,c=a.length;return{totalCount:n,requiredCount:t,missingCount:o,wrongValueCount:s,wrongTypeCount:i,presentRequiredCount:d,optionalCount:c}};import{useCallback as Gt,useState as Ut}from"react";import{CompactRow as Jt,TypeBadge as Q,buoyColors as D,night as Z,monoFont as ee}from"@buoy-gg/shared-ui/web";import{Fragment as Yt,jsx as C,jsxs as A}from"react/jsx-runtime";var Xt=(e,a)=>{switch(e){case"required_present":return{label:"Valid",color:D.success,sublabel:"Required"};case"required_missing":return{label:"Missing",color:D.error,sublabel:"Required"};case"required_wrong_value":return{label:"Wrong",color:D.warning,sublabel:"Invalid value"};case"required_wrong_type":return{label:"Type Error",color:D.info,sublabel:"Wrong type"};case"optional_present":return{label:"Set",color:D.textSecondary,sublabel:"Optional"}}};var Qt=e=>e==null?"undefined":typeof e=="string"?e:String(e);function Zt({envVar:e,isExpanded:a,onPress:r}){let n=Xt(e.status,e.expectedType),t=e.value!==void 0&&e.value!==null,o=e.key.split("_").map(d=>d.toLowerCase()).join(" \u203A "),s=`buoy-env-row-${e.key}`,i=A(p,{style:h.expandedContainer,children:[A(p,{style:h.expandedRow,children:[C(y,{style:h.expandedLabel,children:"Value:"}),C(y,{style:h.expandedValue,numberOfLines:3,testID:`${s}-value`,children:Qt(e.value)||"undefined"})]}),e.status==="required_wrong_type"&&e.expectedType&&A(Yt,{children:[A(p,{style:h.expandedRow,children:[C(y,{style:h.expandedLabel,children:"Type:"}),C(Q,{type:X(e.value),testID:`${s}-actual-type`})]}),A(p,{style:h.expandedRow,children:[C(y,{style:h.expandedLabel,children:"Expected:"}),C(Q,{type:e.expectedType,testID:`${s}-expected-type`})]})]}),e.status==="required_wrong_value"&&e.expectedValue&&A(p,{style:h.expandedRow,children:[C(y,{style:h.expandedLabel,children:"Expected:"}),C(y,{style:h.expandedExpected,testID:`${s}-expected-value`,children:String(e.expectedValue)})]}),e.description&&A(p,{style:h.expandedRow,children:[C(y,{style:h.expandedLabel,children:"Info:"}),C(y,{style:h.expandedDescription,testID:`${s}-description`,children:e.description})]})]});return C(Jt,{statusDotColor:n.color,statusLabel:n.label,statusSublabel:n.sublabel,primaryText:o,secondaryText:void 0,expandedContent:i,isExpanded:a,expandedGlowColor:n.color,customBadge:e.expectedType?C(Q,{type:e.expectedType,testID:`${s}-type-badge`}):void 0,showChevron:true,onPress:r?()=>r(e):void 0,testID:s,statusTestID:`${s}-status`,statusSublabelTestID:`${s}-category`,accessibilityLabel:`${e.key}, ${n.label}, ${n.sublabel}`})}var h=W.create({expandedContainer:{gap:6},expandedRow:{flexDirection:"row",alignItems:"center",gap:8},expandedLabel:{fontSize:10,color:Z.color.textTertiary,fontWeight:"600",minWidth:60,fontFamily:ee},expandedValue:{fontSize:11,color:Z.color.textSecondary,fontFamily:ee,flex:1},expandedExpected:{fontSize:11,color:D.warning,fontFamily:ee,flex:1},expandedDescription:{fontSize:11,color:Z.color.textSecondary,flex:1}});import{SectionHeader as _,night as N,monoFont as er}from"@buoy-gg/shared-ui/web";import{jsx as k,jsxs as U}from"react/jsx-runtime";function tr({title:e,count:a,vars:r,emptyMessage:n}){let[t,o]=Ut(null),s=Gt(i=>{o(d=>d===i.key?null:i.key)},[]);return r.length===0&&e==="Required Variables"?U(p,{style:F.sectionContainer,children:[U(_,{children:[k(_.Title,{children:e}),k(_.Badge,{count:0,color:N.color.accent})]}),k(p,{style:F.emptySection,children:k(y,{style:F.emptySectionText,children:n})})]}):r.length===0?null:U(p,{style:F.sectionContainer,children:[e!==""&&U(_,{children:[k(_.Title,{children:e}),k(_.Badge,{count:a,color:N.color.accent})]}),k(p,{style:F.sectionContent,children:r.map(i=>k(Zt,{envVar:i,isExpanded:t===i.key,onPress:s},i.key))})]})}var F=W.create({sectionContainer:{gap:8},sectionContent:{},emptySection:{padding:20,backgroundColor:N.color.accent+"08",borderRadius:8,borderWidth:1,borderColor:N.color.accent+"20",alignItems:"center"},emptySectionText:{color:N.color.accent,fontSize:11,textAlign:"center",fontFamily:er,opacity:.8,letterSpacing:.5}});import{jsx as b,jsxs as O}from"react/jsx-runtime";function te({visible:e,onClose:a,requiredEnvVars:r,onBack:n,onMinimize:t,enableSharedModalDimensions:o=false,inline:s=false}){let[i,d]=Y("all"),[c,l]=Y(false),[I,w]=Y(""),E=je(null),xe=Me(f=>{},[]);ce(()=>{c&&E.current&&E.current.focus()},[c]),ce(()=>{w(""),l(false)},[i]);let re=zt(),z=P(()=>{let f={};return re.forEach(({key:m,data:v})=>{v!=null&&(f[m]=typeof v=="string"?v:De(v))}),f},[re]),{requiredVars:H,optionalVars:R}=P(()=>ge(z,r),[z,r]),$=P(()=>r===void 0?{totalCount:0,requiredCount:0,optionalCount:0,presentRequiredCount:0,missingCount:0,wrongValueCount:0,wrongTypeCount:0}:fe(H,R,z),[r,H,R,z]),B=P(()=>[...H,...R].sort((f,m)=>{let v={required_missing:1,required_wrong_type:2,required_wrong_value:3,required_present:4,optional_present:5};return(v[f.status]||999)-(v[m.status]||999)}),[H,R]),J=P(()=>{let f=[];switch(i){case"all":f=B;break;case"missing":f=B.filter(m=>m.status==="required_missing");break;case"issues":f=B.filter(m=>m.status==="required_wrong_type"||m.status==="required_wrong_value");break}if(I){let m=I.toLowerCase();f=f.filter(v=>v.key.toLowerCase().includes(m)||v.description?.toLowerCase().includes(m)||typeof v.value=="string"&&v.value.toLowerCase().includes(m))}return f},[B,R,i,I]),L=$.requiredCount>0?Math.round($.presentRequiredCount/$.requiredCount*100):100,Ce=L===100?"HEALTHY":L>=75?"WARNING":L>=50?"ERROR":"CRITICAL",we=L===100?j.success:L>=75?j.warning:L>=50?j.error:j.error;if(!e)return null;let Se=o?se.modal.root():se.env.modal(),ae=O(M,{children:[n&&b(M.Navigation,{onBack:n}),b(M.Content,{title:c?"":"Environment Variables",noMargin:c,children:c&&b(M.Search,{value:I,onChangeText:w,onCancel:()=>{l(false),w("")},placeholder:"Search env keys...",accessibilityLabel:"Search env keys",testID:"buoy-env-search",containerTestID:"buoy-env-search-field",clearTestID:"buoy-env-search-clear"})}),b(M.Actions,{children:!c&&b(qe,{onPress:()=>l(true),testID:"buoy-env-search-open",accessibilityLabel:"Search env keys"})})]}),ne=O(ue,{style:S.scrollContainer,contentContainerStyle:S.contentContainer,showsVerticalScrollIndicator:false,testID:"buoy-env-scroll",children:[b(Ft,{stats:$,healthPercentage:L,healthStatus:Ce,healthColor:we,activeFilter:i,onFilterChange:d}),J.length>0?O(p,{style:S.varsSection,children:[O(p,{style:S.sectionHeader,children:[b(y,{style:S.sectionTitle,testID:"buoy-env-section-title",children:i==="all"?"ALL VARIABLES":i==="missing"?"MISSING VARIABLES":"ISSUES TO FIX"}),b(p,{style:S.countBadge,children:b(y,{style:S.countText,testID:"buoy-env-section-count",children:J.length})})]}),b(tr,{title:"",count:0,vars:J,emptyMessage:""})]}):b(Re,{testID:"buoy-env-empty",...Be({subject:"variables",verb:"declared",search:I,total:B.length,waiting:{otto:"keys",title:"No variables",message:`No ${i==="all"?"":i} variables found`}})})]});return s?O(p,{style:S.inlineRoot,children:[b(p,{style:S.inlineHeader,..._e,children:ae}),ne]}):b(Ae,{visible:e,onClose:a,onMinimize:t,persistenceKey:Se,header:{customContent:ae,showToggleButton:true},onModeChange:xe,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},children:ne})}function rr({requiredEnvVars:e}){return b(te,{inline:true,visible:true,requiredEnvVars:e,onClose:()=>{}})}var S=W.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.border,backgroundColor:"transparent"},scrollContainer:{flex:1,backgroundColor:"transparent"},contentContainer:{padding:8,paddingBottom:24},varsSection:{marginTop:16},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8,paddingHorizontal:8},sectionTitle:{fontSize:10,fontWeight:"700",color:K.color.textTertiary,letterSpacing:1.2,fontFamily:le},countBadge:{backgroundColor:K.color.accent+"15",paddingHorizontal:8,paddingVertical:2,borderRadius:9999,borderWidth:1,borderColor:K.color.accent+"40"},countText:{fontSize:10,fontWeight:"500",color:K.color.accent,fontFamily:le}});function ar(){let e={};for(let[a,r]of Object.entries(be()??(typeof process>"u"?{}:process.env)))typeof r=="string"&&(e[a]=r);return e}var me=[];function nr(e){me=e}function or(e=[]){return{version:1,getSnapshot:()=>({env:ar(),requiredEnvVars:e.length>0?e:me}),subscribe:()=>()=>{}}}import{createToolFactory as ir,defineToolPreset as sr}from"@buoy-gg/shared-ui/web";import{jsx as lr}from"react/jsx-runtime";var ve=sr({id:"env",name:"ENV",description:"Environment variables debugger",slot:"both",icon:({size:e})=>lr(Le,{size:e}),component:te,props:{requiredEnvVars:[],enableSharedModalDimensions:true}}),cr=ir(ve,e=>(nr(e.requiredEnvVars||[]),{requiredEnvVars:e.requiredEnvVars||[],enableSharedModalDimensions:e.enableSharedModalDimensions??true}));export{rr as EnvToolView,te as EnvVarsModal,fe as calculateStats,or as createEnvSyncAdapter,cr as createEnvTool,Kt as createEnvVarConfig,ve as envToolPreset,$t as envVar,X as getEnvVarType,ge as processEnvVars,Ot as setRemoteEnv};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/env",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.42",
|
|
4
4
|
"description": "Environment variable inspector for React Native with runtime-visible values, required-variable checks, and type validation.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@buoy-gg/
|
|
38
|
-
"@buoy-gg/
|
|
37
|
+
"@buoy-gg/floating-tools-core": "^7.0.42",
|
|
38
|
+
"@buoy-gg/shared-ui": "^7.0.42"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "*",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvStatsOverview.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvStatsOverview.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEzD,UAAU,qBAAqB;IAC7B,KAAK,EAAE;QACL,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAoB,EACpB,cAAc,GACf,EAAE,qBAAqB,+BAoIvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvVarRow.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvVarRow.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,UAAU,cAAc;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAkDD,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,cAAc,+BAmGxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvVarSection.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvVarSection.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,GACb,EAAE,kBAAkB,sCA2CpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvVarsModal.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvVarsModal.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAc,MAAM,UAAU,CAAC;AAUtD,UAAU,iBAAiB;IACzB,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qFAAqF;IACrF,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,OAAO,EACP,eAAe,EACf,MAAM,EACN,UAAU,EACV,2BAAmC,EACnC,MAAc,GACf,EAAE,iBAAiB,sCAyQnB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,eAAe,GAChB,EAAE;IACD,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,+BASA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDynamicEnv.d.ts","sourceRoot":"","sources":["../../../../src/env/hooks/useDynamicEnv.ts"],"names":[],"mappings":"AAGA,UAAU,oBAAoB;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;CACjE;AAED,UAAU,SAAS;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAsB,GACvB,GAAE,oBAAyB,GAAG,SAAS,EAAE,CA6DzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/env/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|