@ctrl-ui/react 0.8.19 → 0.8.21

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.
Files changed (84) hide show
  1. package/README.md +7 -0
  2. package/dist/action-bar.js +2 -2
  3. package/dist/audio-device-select.js +5 -2
  4. package/dist/blocks/coding-agent.js +22 -12
  5. package/dist/blocks/design-canvas-inspector.js +6 -3
  6. package/dist/blocks/design-canvas.js +17 -11
  7. package/dist/blocks/discussion-markdown-input.d.ts +3 -1
  8. package/dist/blocks/discussion-markdown-input.js +3 -1
  9. package/dist/blocks/discussion.d.ts +3 -1
  10. package/dist/blocks/discussion.js +9 -4
  11. package/dist/blocks/file-explorer.js +47 -25
  12. package/dist/blocks/settings.js +8 -6
  13. package/dist/chat-composer-editor/extensions/mention.d.ts +1 -1
  14. package/dist/chat-message.d.ts +13 -0
  15. package/dist/chat-message.js +198 -3
  16. package/dist/filter-bar/editor.js +5 -2
  17. package/dist/knob-contracts/flow-knobs.d.ts +4 -0
  18. package/dist/knob-contracts/flow-knobs.js +32 -0
  19. package/dist/knob-contracts/item-knobs.d.ts +1 -1
  20. package/dist/knob-contracts/item-knobs.js +4 -1
  21. package/dist/knob-contracts/markdown-editor-knobs.d.ts +1 -1
  22. package/dist/knob-contracts/markdown-editor-knobs.js +1 -0
  23. package/dist/knob-contracts/morphing-panel-knobs.d.ts +1 -1
  24. package/dist/knob-contracts/morphing-panel-knobs.js +2 -1
  25. package/dist/knob-contracts/resize-handle-knobs.d.ts +4 -0
  26. package/dist/knob-contracts/resize-handle-knobs.js +12 -0
  27. package/dist/knob-contracts/sidebar-knobs.d.ts +1 -1
  28. package/dist/knob-contracts/sidebar-knobs.js +10 -0
  29. package/dist/lib/canvas-grid.d.ts +4 -0
  30. package/dist/lib/canvas-grid.js +5 -0
  31. package/dist/markdown-editor/drag-handle.d.ts +6 -0
  32. package/dist/markdown-editor/drag-handle.js +126 -0
  33. package/dist/markdown-editor/suggestions.d.ts +12 -0
  34. package/dist/markdown-editor/suggestions.js +235 -0
  35. package/dist/markdown-editor/toolbar.js +6 -3
  36. package/dist/markdown-editor.js +14 -4
  37. package/dist/styles/index.css +6 -3
  38. package/dist/styles/recipes/chat-message-edit.css +105 -0
  39. package/dist/styles/recipes/flow.css +306 -0
  40. package/dist/styles/recipes/infinite-canvas.css +1 -1
  41. package/dist/styles/recipes/item.css +39 -2
  42. package/dist/styles/recipes/markdown-editor.css +44 -6
  43. package/dist/styles/recipes/morphing-panel.css +53 -12
  44. package/dist/styles/recipes/page-layout.css +11 -1
  45. package/dist/styles/recipes/resize-handle.css +126 -0
  46. package/dist/styles/recipes/sidebar-mobile.css +171 -0
  47. package/dist/styles/recipes/toolbar.css +8 -1
  48. package/dist/styles/theme.css +1 -0
  49. package/dist/ui/app-shell.js +1 -1
  50. package/dist/ui/color-picker.js +1 -1
  51. package/dist/ui/combobox.d.ts +1 -1
  52. package/dist/ui/command.js +1 -1
  53. package/dist/ui/dockable-panel.js +1 -1
  54. package/dist/ui/flow.d.ts +51 -0
  55. package/dist/ui/flow.js +153 -0
  56. package/dist/ui/infinite-canvas.js +3 -3
  57. package/dist/ui/item.d.ts +5 -3
  58. package/dist/ui/item.js +2 -1
  59. package/dist/ui/morphing-panel.d.ts +21 -4
  60. package/dist/ui/morphing-panel.js +152 -36
  61. package/dist/ui/resize-handle.d.ts +11 -0
  62. package/dist/ui/resize-handle.js +26 -0
  63. package/dist/ui/responsive-dialog.js +1 -1
  64. package/dist/ui/sidebar-menu.js +1 -1
  65. package/dist/ui/sidebar-mobile.d.ts +17 -0
  66. package/dist/ui/sidebar-mobile.js +70 -0
  67. package/dist/ui/sidebar-provider.d.ts +1 -0
  68. package/dist/ui/sidebar-provider.js +3 -0
  69. package/dist/ui/sidebar.d.ts +3 -1
  70. package/dist/ui/sidebar.js +100 -48
  71. package/dist/ui/toolbar.d.ts +3 -1
  72. package/dist/ui/toolbar.js +2 -1
  73. package/dist/ui/typography.d.ts +5 -2
  74. package/dist/ui/typography.js +5 -3
  75. package/package.json +5 -1
  76. package/dist/environment-variables.d.ts +0 -125
  77. package/dist/environment-variables.js +0 -512
  78. package/dist/hooks/use-environment-variables.d.ts +0 -50
  79. package/dist/hooks/use-environment-variables.js +0 -188
  80. package/dist/knob-contracts/environment-variables-knobs.d.ts +0 -4
  81. package/dist/knob-contracts/environment-variables-knobs.js +0 -12
  82. package/dist/lib/env-file.d.ts +0 -27
  83. package/dist/lib/env-file.js +0 -218
  84. package/dist/styles/recipes/environment-variables.css +0 -170
@@ -1,188 +0,0 @@
1
- "use client";
2
- import { collectEnvironmentVariables, createEmptyEnvironmentVariableEntry, getDuplicateEnvironmentVariableKeys, parseEnvFileText, readEnvFile, rowsToEnvFileText } from "../lib/env-file.js";
3
- import { useRef, useState } from "react";
4
- //#region src/hooks/use-environment-variables.ts
5
- function defaultCreateRow(entry) {
6
- return {
7
- key: entry.key,
8
- value: entry.value
9
- };
10
- }
11
- function defaultEditableRows(rows) {
12
- return rows;
13
- }
14
- function defaultPreservedRows() {
15
- return [];
16
- }
17
- function normalizeRows(rows, createDefaultRow) {
18
- return rows && rows.length > 0 ? rows.map((row) => ({ ...row })) : [createDefaultRow()];
19
- }
20
- function hasOnlyEmptyRow(rows) {
21
- if (rows.length !== 1) return false;
22
- const [firstRow] = rows;
23
- if (!firstRow) return false;
24
- return !firstRow.key.trim() && !firstRow.value;
25
- }
26
- function areRowsEqual(a, b) {
27
- if (a.length !== b.length) return false;
28
- for (let index = 0; index < a.length; index++) {
29
- const aRow = a[index];
30
- const bRow = b[index];
31
- if (!aRow || !bRow || aRow.key !== bRow.key || aRow.value !== bRow.value) return false;
32
- }
33
- return true;
34
- }
35
- function useEnvironmentVariables({ initialRows, rows: controlledRows, onRowsChange, createDefaultRow = createEmptyEnvironmentVariableEntry, createRow = defaultCreateRow, getEditableRows = defaultEditableRows, getPreservedRows = defaultPreservedRows, maxUploadSize } = {}) {
36
- const initialSourceRows = controlledRows ?? initialRows;
37
- const nextRowId = useRef(0);
38
- const fallbackRowIds = useRef({});
39
- const [uncontrolledRows, setUncontrolledRows] = useState(() => normalizeRows(initialSourceRows, createDefaultRow));
40
- const [baselineRows, setBaselineRows] = useState(() => normalizeRows(initialSourceRows, createDefaultRow));
41
- const [rowIds, setRowIds] = useState(() => normalizeRows(initialSourceRows, createDefaultRow).map(() => createRowId()));
42
- const [uploadError, setUploadError] = useState(null);
43
- const [revealedValues, setRevealedValues] = useState({});
44
- const rows = controlledRows ? normalizeRows(controlledRows, createDefaultRow) : uncontrolledRows;
45
- const editableRows = (sourceRows = rows) => getEditableRows(sourceRows);
46
- const preservedRows = (sourceRows = rows) => getPreservedRows(sourceRows);
47
- function createRowId() {
48
- const rowId = nextRowId.current;
49
- nextRowId.current += 1;
50
- return `environment-variable-row-${rowId}`;
51
- }
52
- function commitRows(nextRows, nextRowIds) {
53
- const normalizedRows = normalizeRows(nextRows, createDefaultRow);
54
- const normalizedRowIds = normalizedRows.map((_, index) => nextRowIds?.[index] ?? rowIds[index] ?? createRowId());
55
- if (!controlledRows) setUncontrolledRows(normalizedRows);
56
- setRowIds(normalizedRowIds);
57
- onRowsChange?.(normalizedRows);
58
- return normalizedRows;
59
- }
60
- function setRows(nextRows) {
61
- return commitRows(nextRows);
62
- }
63
- function resetRows(nextRows = baselineRows) {
64
- const normalizedRows = normalizeRows(nextRows, createDefaultRow);
65
- commitRows(normalizedRows, normalizedRows.map(() => createRowId()));
66
- setBaselineRows(normalizedRows);
67
- setRevealedValues({});
68
- setUploadError(null);
69
- return normalizedRows;
70
- }
71
- function getRowsForSubmit() {
72
- return [...rows];
73
- }
74
- function appendRow(row = createDefaultRow()) {
75
- return commitRows([...rows, row], [...rowIds, createRowId()]);
76
- }
77
- function updateRow(index, patch) {
78
- return commitRows(rows.map((row, rowIndex) => rowIndex === index ? {
79
- ...row,
80
- ...patch
81
- } : row), rowIds);
82
- }
83
- function removeRow(index) {
84
- const nextRows = rows.filter((_, rowIndex) => rowIndex !== index);
85
- const nextRowIds = rowIds.filter((_, rowIndex) => rowIndex !== index);
86
- setRevealedValues({});
87
- return commitRows(nextRows.length > 0 ? nextRows : [createDefaultRow()], nextRows.length > 0 ? nextRowIds : [createRowId()]);
88
- }
89
- function mergeParsedRows(parsedRows, targetIndex) {
90
- const newRows = parsedRows.map(createRow);
91
- const newRowIds = newRows.map(() => createRowId());
92
- if (hasOnlyEmptyRow(editableRows(rows))) {
93
- const preserved = preservedRows(rows);
94
- return commitRows([...preserved, ...newRows], [...rowIds.slice(0, preserved.length), ...newRowIds]);
95
- }
96
- if (typeof targetIndex !== "number") return commitRows([...rows, ...newRows], [...rowIds, ...newRowIds]);
97
- const targetRow = rows[targetIndex];
98
- if (!targetRow) return commitRows([...rows, ...newRows], [...rowIds, ...newRowIds]);
99
- const targetIsEmpty = !targetRow.key.trim() && !targetRow.value;
100
- const before = rows.slice(0, targetIndex + (targetIsEmpty ? 0 : 1));
101
- const after = rows.slice(targetIndex + 1);
102
- const beforeIds = rowIds.slice(0, targetIndex + (targetIsEmpty ? 0 : 1));
103
- const afterIds = rowIds.slice(targetIndex + 1);
104
- return commitRows([
105
- ...before,
106
- ...newRows,
107
- ...after
108
- ], [
109
- ...beforeIds,
110
- ...newRowIds,
111
- ...afterIds
112
- ]);
113
- }
114
- function importText(text, options = {}) {
115
- const entries = parseEnvironmentVariablesImportText(text, options.mode ?? "bulk");
116
- if (entries.length === 0) return false;
117
- mergeParsedRows(entries, options.targetIndex);
118
- setRevealedValues({});
119
- setUploadError(null);
120
- return true;
121
- }
122
- function handlePaste(index, text) {
123
- return importText(text, {
124
- targetIndex: index,
125
- mode: "auto"
126
- });
127
- }
128
- async function handleFileUpload(event) {
129
- setUploadError(null);
130
- const file = event.target.files?.[0];
131
- if (!file) return;
132
- const result = await readEnvFile(file, { maxSize: maxUploadSize });
133
- if (!result.ok) {
134
- setUploadError(result.error);
135
- event.target.value = "";
136
- return;
137
- }
138
- mergeParsedRows(result.entries);
139
- setRevealedValues({});
140
- event.target.value = "";
141
- }
142
- function getRowId(index) {
143
- const rowId = rowIds[index] ?? fallbackRowIds.current[index];
144
- if (rowId) return rowId;
145
- const fallbackRowId = createRowId();
146
- fallbackRowIds.current[index] = fallbackRowId;
147
- return fallbackRowId;
148
- }
149
- const duplicateKeys = getDuplicateEnvironmentVariableKeys(rows);
150
- const rowsDirty = !areRowsEqual(rows, baselineRows);
151
- return {
152
- rows,
153
- uploadError,
154
- duplicateKeys,
155
- hasDuplicateKeys: duplicateKeys.size > 0,
156
- isDirty: rowsDirty,
157
- setRows,
158
- resetRows,
159
- appendRow,
160
- updateRow,
161
- removeRow,
162
- getRowsForSubmit,
163
- getEnvironmentVariablesForSubmit: () => collectEnvironmentVariables(getRowsForSubmit()),
164
- getEnvFileTextForSubmit: () => rowsToEnvFileText(getRowsForSubmit()),
165
- importText,
166
- handleFileUpload,
167
- handlePaste,
168
- clearUploadError: () => setUploadError(null),
169
- getRowId,
170
- isValueRevealed: (index) => Boolean(revealedValues[index]),
171
- toggleValueVisibility: (index) => setRevealedValues((previous) => ({
172
- ...previous,
173
- [index]: !previous[index]
174
- })),
175
- rowHasDuplicateKey: (index) => duplicateKeys.has(rows[index]?.key.trim() ?? "")
176
- };
177
- }
178
- function parseEnvironmentVariablesImportText(text, mode = "bulk") {
179
- const trimmedText = text.trim();
180
- if (!trimmedText.includes("=")) return [];
181
- const entries = parseEnvFileText(trimmedText);
182
- if (entries.length === 0) return [];
183
- if (mode === "bulk") return entries;
184
- const firstAssignmentLooksLikeEnvVar = /^(?:export\s+)?[A-Z_][A-Z0-9_]*\s*=/.test(trimmedText);
185
- return entries.length > 1 || trimmedText.includes("\n") || firstAssignmentLooksLikeEnvVar ? entries : [];
186
- }
187
- //#endregion
188
- export { parseEnvironmentVariablesImportText, useEnvironmentVariables };
@@ -1,4 +0,0 @@
1
- //#region src/knob-contracts/environment-variables-knobs.d.ts
2
- export declare const environmentVariablesKnobs: readonly ["--cui-environment-variables-title-foreground", "--cui-environment-variables-meta-foreground", "--cui-environment-variables-error-foreground", "--cui-environment-variables-message-background", "--cui-environment-variables-message-foreground", "--cui-environment-variables-message-border-color", "--cui-environment-variables-message-border-width"];
3
- export type EnvironmentVariablesKnobStyle = Partial<Record<(typeof environmentVariablesKnobs)[number], string>>;
4
- //#endregion
@@ -1,12 +0,0 @@
1
- //#region src/knob-contracts/environment-variables-knobs.ts
2
- const environmentVariablesKnobs = [
3
- "--cui-environment-variables-title-foreground",
4
- "--cui-environment-variables-meta-foreground",
5
- "--cui-environment-variables-error-foreground",
6
- "--cui-environment-variables-message-background",
7
- "--cui-environment-variables-message-foreground",
8
- "--cui-environment-variables-message-border-color",
9
- "--cui-environment-variables-message-border-width"
10
- ];
11
- //#endregion
12
- export { environmentVariablesKnobs };
@@ -1,27 +0,0 @@
1
- //#region src/lib/env-file.d.ts
2
- export interface EnvironmentVariableEntry {
3
- key: string;
4
- value: string;
5
- }
6
- export declare const ENV_FILE_MAX_SIZE: number;
7
- export declare const DUPLICATE_ENVIRONMENT_VARIABLE_MESSAGE = "Rename or remove the duplicate key.";
8
- export declare class DuplicateEnvironmentVariableKeyError extends Error {
9
- readonly key: string;
10
- constructor(key: string);
11
- }
12
- export declare function createEmptyEnvironmentVariableEntry(): EnvironmentVariableEntry;
13
- export declare function rowsFromEnvironmentVariables(envVars: Record<string, unknown> | undefined): EnvironmentVariableEntry[];
14
- export declare function getDuplicateEnvironmentVariableKeys(rows: readonly EnvironmentVariableEntry[]): Set<string>;
15
- export declare function collectEnvironmentVariables(rows: readonly EnvironmentVariableEntry[]): Record<string, string>;
16
- export declare function parseEnvFileText(text: string): EnvironmentVariableEntry[];
17
- export declare function rowsToEnvFileText(rows: readonly EnvironmentVariableEntry[]): string;
18
- export declare function readEnvFile(file: File, options?: {
19
- maxSize?: number;
20
- }): Promise<{
21
- ok: true;
22
- entries: EnvironmentVariableEntry[];
23
- } | {
24
- ok: false;
25
- error: string;
26
- }>;
27
- //#endregion
@@ -1,218 +0,0 @@
1
- //#region src/lib/env-file.ts
2
- const ENV_FILE_MAX_SIZE = 65536;
3
- const DUPLICATE_ENVIRONMENT_VARIABLE_MESSAGE = "Rename or remove the duplicate key.";
4
- var DuplicateEnvironmentVariableKeyError = class extends Error {
5
- key;
6
- constructor(key) {
7
- super(DUPLICATE_ENVIRONMENT_VARIABLE_MESSAGE);
8
- this.key = key;
9
- this.name = "DuplicateEnvironmentVariableKeyError";
10
- }
11
- };
12
- function createEmptyEnvironmentVariableEntry() {
13
- return {
14
- key: "",
15
- value: ""
16
- };
17
- }
18
- function rowsFromEnvironmentVariables(envVars) {
19
- const entries = Object.entries(envVars ?? {});
20
- return entries.length > 0 ? entries.map(([key, value]) => ({
21
- key,
22
- value: String(value)
23
- })) : [createEmptyEnvironmentVariableEntry()];
24
- }
25
- function getDuplicateEnvironmentVariableKeys(rows) {
26
- const seen = /* @__PURE__ */ new Set();
27
- const duplicates = /* @__PURE__ */ new Set();
28
- for (const row of rows) {
29
- const key = row.key.trim();
30
- if (!key) continue;
31
- if (seen.has(key)) duplicates.add(key);
32
- else seen.add(key);
33
- }
34
- return duplicates;
35
- }
36
- function collectEnvironmentVariables(rows) {
37
- const envVars = {};
38
- const seen = /* @__PURE__ */ new Set();
39
- for (const row of rows) {
40
- const key = row.key.trim();
41
- if (!key) continue;
42
- if (seen.has(key)) throw new DuplicateEnvironmentVariableKeyError(key);
43
- seen.add(key);
44
- envVars[key] = row.value;
45
- }
46
- return envVars;
47
- }
48
- function parseEnvAssignment(line) {
49
- const normalizedLine = line.trim();
50
- if (!normalizedLine || normalizedLine.startsWith("#")) return void 0;
51
- const stripped = normalizedLine.replace(/^export\s+/, "");
52
- const equalsIndex = stripped.indexOf("=");
53
- if (equalsIndex === -1) return void 0;
54
- const key = stripped.slice(0, equalsIndex).trim();
55
- if (!key) return void 0;
56
- return {
57
- key,
58
- rawValue: stripped.slice(equalsIndex + 1)
59
- };
60
- }
61
- function openingQuote(value) {
62
- if (value.startsWith("\"")) return "\"";
63
- if (value.startsWith("'")) return "'";
64
- }
65
- function parseUnquotedEnvValue(rawValue) {
66
- const commentIndex = rawValue.indexOf(" #");
67
- return (commentIndex === -1 ? rawValue : rawValue.slice(0, commentIndex)).trim();
68
- }
69
- function parseQuotedEnvValue(lines, lineIndex, value, quote) {
70
- const closingIndex = findClosingQuoteIndex(value, quote, 1);
71
- if (closingIndex !== -1) return {
72
- value: unescapeQuotedValue(value.slice(1, closingIndex), quote),
73
- nextLineIndex: lineIndex + 1
74
- };
75
- const parts = [value.slice(1)];
76
- let nextLineIndex = lineIndex + 1;
77
- while (nextLineIndex < lines.length) {
78
- const nextLine = lines[nextLineIndex];
79
- if (nextLine === void 0) break;
80
- const endIndex = findClosingQuoteIndex(nextLine, quote);
81
- if (endIndex !== -1) {
82
- parts.push(nextLine.slice(0, endIndex));
83
- nextLineIndex += 1;
84
- break;
85
- }
86
- parts.push(nextLine);
87
- nextLineIndex += 1;
88
- }
89
- return {
90
- value: unescapeQuotedValue(parts.join("\n"), quote),
91
- nextLineIndex
92
- };
93
- }
94
- function parseEnvValue(lines, lineIndex, rawValue) {
95
- const value = rawValue.trimStart();
96
- const quote = openingQuote(value);
97
- if (quote) return parseQuotedEnvValue(lines, lineIndex, value, quote);
98
- return {
99
- value: parseUnquotedEnvValue(rawValue),
100
- nextLineIndex: lineIndex + 1
101
- };
102
- }
103
- function parseEnvFileText(text) {
104
- const results = [];
105
- const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
106
- let lineIndex = 0;
107
- while (lineIndex < lines.length) {
108
- const currentLine = lines[lineIndex];
109
- if (currentLine === void 0) break;
110
- const assignment = parseEnvAssignment(currentLine);
111
- if (!assignment) {
112
- lineIndex++;
113
- continue;
114
- }
115
- const parsedValue = parseEnvValue(lines, lineIndex, assignment.rawValue);
116
- results.push({
117
- key: assignment.key,
118
- value: parsedValue.value
119
- });
120
- lineIndex = parsedValue.nextLineIndex;
121
- }
122
- return results;
123
- }
124
- function findClosingQuoteIndex(value, quote, startIndex = 0) {
125
- for (let index = startIndex; index < value.length; index++) if (value[index] === quote && !isEscaped(value, index)) return index;
126
- return -1;
127
- }
128
- function isEscaped(value, index) {
129
- let slashCount = 0;
130
- for (let cursor = index - 1; cursor >= 0 && value[cursor] === "\\"; cursor--) slashCount++;
131
- return slashCount % 2 === 1;
132
- }
133
- const DOUBLE_QUOTED_CONTROL_ESCAPES = {
134
- n: "\n",
135
- r: "\r",
136
- t: " "
137
- };
138
- function escapedQuotedCharacter(next, quote) {
139
- if (next === quote || next === "\\") return next;
140
- if (quote === "'") return void 0;
141
- return DOUBLE_QUOTED_CONTROL_ESCAPES[next];
142
- }
143
- function unescapeQuotedValue(value, quote) {
144
- let result = "";
145
- for (let index = 0; index < value.length; index++) {
146
- const current = value[index];
147
- const next = value[index + 1];
148
- if (current !== "\\" || next === void 0) {
149
- result += current;
150
- continue;
151
- }
152
- const unescaped = escapedQuotedCharacter(next, quote);
153
- result += unescaped ?? current;
154
- if (unescaped !== void 0) index++;
155
- }
156
- return result;
157
- }
158
- function escapeDoubleQuotedValue(value) {
159
- return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
160
- }
161
- function shouldQuoteValue(value) {
162
- return value.includes("\n") || value.includes("\r") || value.includes(" #") || /^\s|\s$/.test(value);
163
- }
164
- function rowsToEnvFileText(rows) {
165
- const lines = [];
166
- for (const row of rows) {
167
- const key = row.key.trim();
168
- if (!key) continue;
169
- const value = row.value;
170
- lines.push(shouldQuoteValue(value) ? `${key}="${escapeDoubleQuotedValue(value)}"` : `${key}=${value}`);
171
- }
172
- return lines.join("\n");
173
- }
174
- async function readEnvFile(file, options = {}) {
175
- const maxSize = options.maxSize ?? 65536;
176
- if (file.size > maxSize) return {
177
- ok: false,
178
- error: `That file is over ${Math.ceil(maxSize / 1024)} KB. Choose a smaller .env file.`
179
- };
180
- let text;
181
- try {
182
- text = await readFileText(file);
183
- } catch {
184
- return {
185
- ok: false,
186
- error: "Couldn't read that file. Try selecting it again."
187
- };
188
- }
189
- if (text.includes("\0")) return {
190
- ok: false,
191
- error: "That file isn't plain text. Choose a .env text file."
192
- };
193
- const entries = parseEnvFileText(text);
194
- if (entries.length === 0) return {
195
- ok: false,
196
- error: "No variables found. Use one KEY=value per line."
197
- };
198
- return {
199
- ok: true,
200
- entries
201
- };
202
- }
203
- async function readFileText(file) {
204
- if (typeof file.text === "function") try {
205
- return await file.text();
206
- } catch {}
207
- return new Promise((resolve, reject) => {
208
- const reader = new FileReader();
209
- reader.onload = () => {
210
- if (typeof reader.result === "string") resolve(reader.result);
211
- else reject(/* @__PURE__ */ new Error("FileReader returned non-text content."));
212
- };
213
- reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("FileReader failed."));
214
- reader.readAsText(file);
215
- });
216
- }
217
- //#endregion
218
- export { DUPLICATE_ENVIRONMENT_VARIABLE_MESSAGE, DuplicateEnvironmentVariableKeyError, ENV_FILE_MAX_SIZE, collectEnvironmentVariables, createEmptyEnvironmentVariableEntry, getDuplicateEnvironmentVariableKeys, parseEnvFileText, readEnvFile, rowsFromEnvironmentVariables, rowsToEnvFileText };
@@ -1,170 +0,0 @@
1
- @layer components {
2
- :where([data-control-family="environment-variables"][data-slot="root"]) {
3
- --cui-environment-variables-error-foreground: var(--destructive-text);
4
- --cui-environment-variables-message-background: oklch(from var(--destructive) l c h / 0.05);
5
- --cui-environment-variables-message-border-color: oklch(from var(--destructive) l c h / 0.4);
6
- --cui-environment-variables-message-border-width: var(--control-rim-width);
7
- --cui-environment-variables-message-foreground: var(--destructive-text);
8
- --cui-environment-variables-meta-foreground: var(--muted-foreground);
9
- --cui-environment-variables-title-foreground: var(--foreground);
10
- gap: calc(var(--spacing) * 4);
11
- }
12
-
13
- :where([data-control-family="environment-variables"][data-slot="header"]) {
14
- gap: calc(var(--spacing) * 1);
15
- }
16
-
17
- :where([data-control-family="environment-variables"][data-slot="toolbar"]) {
18
- gap: calc(var(--spacing) * 2);
19
- }
20
-
21
- :where([data-control-family="environment-variables"][data-slot="row"]) {
22
- gap: calc(var(--spacing) * 3);
23
- padding-block: calc(var(--spacing) * 2);
24
- padding-inline: calc(var(--spacing) * 1) calc(var(--spacing) * 9);
25
- }
26
-
27
- :where([data-control-family="environment-variables"][data-slot="row"] > div) {
28
- gap: calc(var(--spacing) * 1.5);
29
- }
30
-
31
- @media (width >= 40rem) {
32
- :where([data-control-family="environment-variables"][data-slot="row"]) {
33
- gap: calc(var(--spacing) * 2);
34
- padding-inline: calc(var(--spacing) * 1);
35
- }
36
- }
37
-
38
- :where([data-control-family="environment-variables"][data-slot="actions"]),
39
- :where([data-control-family="environment-variables"][data-slot="actions"] > div) {
40
- gap: calc(var(--spacing) * 2);
41
- }
42
-
43
- :where([data-control-family="environment-variables"][data-slot="readonly-list"]) {
44
- gap: calc(var(--spacing) * 1);
45
- }
46
-
47
- :where([data-control-family="environment-variables"][data-slot="readonly-item"]) {
48
- gap: calc(var(--spacing) * 3);
49
- padding-inline: calc(var(--spacing) * 1);
50
- padding-block: calc(var(--spacing) * 2);
51
- }
52
- :where([data-control-family="environment-variables"][data-slot="title"]) {
53
- color: var(--cui-environment-variables-title-foreground);
54
- font-size: var(--text-label);
55
- font-weight: var(--font-weight-semibold);
56
- text-wrap: balance;
57
- }
58
-
59
- :where(
60
- [data-control-family="environment-variables"]:is(
61
- [data-slot="description"],
62
- [data-slot="hint"],
63
- [data-slot="column-labels"],
64
- [data-slot="field-label"],
65
- [data-slot="empty"],
66
- [data-slot="readonly-item"]
67
- )
68
- ) {
69
- color: var(--cui-environment-variables-meta-foreground);
70
- font-size: var(--text-caption);
71
- }
72
-
73
- :where([data-control-family="environment-variables"][data-slot="hint-code"]),
74
- :where([data-control-family="environment-variables"][data-slot="readonly-key"]) {
75
- color: var(--foreground);
76
- }
77
-
78
- :where([data-control-family="environment-variables"][data-slot="row"] [data-control-family="field"][data-control="true"]) {
79
- --cui-field-font-size: var(--text-caption);
80
- font-family: var(--font-mono);
81
- }
82
-
83
- :where([data-control-family="environment-variables"][data-slot="field-error"]) {
84
- color: var(--cui-environment-variables-error-foreground);
85
- font-size: var(--text-caption);
86
- }
87
-
88
- :where([data-control-family="environment-variables"][data-slot="message"]) {
89
- gap: calc(var(--spacing) * 2);
90
- padding-inline: calc(var(--spacing) * 3);
91
- padding-block: calc(var(--spacing) * 2);
92
- background: var(--cui-environment-variables-message-background);
93
- border-block: var(--cui-environment-variables-message-border-width) solid var(--cui-environment-variables-message-border-color);
94
- color: var(--cui-environment-variables-message-foreground);
95
- font-size: var(--text-caption);
96
- }
97
-
98
- :where([data-control-family="environment-variables"][data-slot="readonly-value"]) {
99
- color: var(--muted-foreground);
100
- font-family: var(--font-mono);
101
- }
102
-
103
- :where([data-control-family="environment-variables"][data-slot="readonly-key"]) {
104
- font-family: var(--font-mono);
105
- font-weight: var(--font-weight-medium);
106
- }
107
-
108
- :where([data-control-family="environment-variables"][data-slot="empty"]) {
109
- padding-inline: calc(var(--spacing) * 3);
110
- padding-block: calc(var(--spacing) * 4);
111
- text-align: center;
112
- }
113
-
114
- :where([data-control-family="environment-variables"][data-slot="field-label"]) {
115
- font-weight: var(--font-weight-medium);
116
- }
117
-
118
- :where([data-control-family="environment-variables"][data-slot="column-labels"]) {
119
- gap: calc(var(--spacing) * 2);
120
- padding-inline: calc(var(--spacing) * 1);
121
- padding-block-end: calc(var(--spacing) * 1);
122
- font-weight: var(--font-weight-medium);
123
- }
124
-
125
- :where([data-control-family="environment-variables"][data-slot="hint-code"]) {
126
- font-family: var(--font-mono);
127
- }
128
- }
129
-
130
- @property --cui-environment-variables-title-foreground {
131
- syntax: "<color>";
132
- inherits: true;
133
- initial-value: transparent;
134
- }
135
-
136
- @property --cui-environment-variables-meta-foreground {
137
- syntax: "<color>";
138
- inherits: true;
139
- initial-value: transparent;
140
- }
141
-
142
- @property --cui-environment-variables-error-foreground {
143
- syntax: "<color>";
144
- inherits: true;
145
- initial-value: transparent;
146
- }
147
-
148
- @property --cui-environment-variables-message-background {
149
- syntax: "<color>";
150
- inherits: true;
151
- initial-value: transparent;
152
- }
153
-
154
- @property --cui-environment-variables-message-foreground {
155
- syntax: "<color>";
156
- inherits: true;
157
- initial-value: transparent;
158
- }
159
-
160
- @property --cui-environment-variables-message-border-color {
161
- syntax: "<color>";
162
- inherits: true;
163
- initial-value: transparent;
164
- }
165
-
166
- @property --cui-environment-variables-message-border-width {
167
- syntax: "<length>";
168
- inherits: true;
169
- initial-value: 0px;
170
- }