@freestyle-sh/with-ttyd 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +18 -3
- package/package.json +2 -2
- package/src/index.ts +28 -2
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ type TtydConfig = {
|
|
|
24
24
|
readOnly?: boolean;
|
|
25
25
|
/** Xterm.js theme settings passed to ttyd client options */
|
|
26
26
|
theme?: Record<string, string | number | boolean>;
|
|
27
|
+
/** TTYD client options (xterm.js options, ttyd client flags) */
|
|
28
|
+
clientOptions?: Record<string, unknown>;
|
|
27
29
|
};
|
|
28
30
|
type ResolvedTerminalConfig = {
|
|
29
31
|
port: number;
|
|
@@ -37,6 +39,7 @@ type ResolvedTerminalConfig = {
|
|
|
37
39
|
title: string;
|
|
38
40
|
readOnly: boolean;
|
|
39
41
|
theme?: Record<string, string | number | boolean>;
|
|
42
|
+
clientOptions?: Record<string, unknown>;
|
|
40
43
|
};
|
|
41
44
|
declare class VmWebTerminal<T extends TtydConfig[] = TtydConfig[]> extends VmWith<VmWebTerminalInstance<T>> {
|
|
42
45
|
private resolvedTerminals;
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,8 @@ class VmWebTerminal extends VmWith {
|
|
|
24
24
|
credential: config.credential,
|
|
25
25
|
title: config.title ?? `terminal-${port}`,
|
|
26
26
|
readOnly: config.readOnly ?? false,
|
|
27
|
-
theme: config.theme
|
|
27
|
+
theme: config.theme,
|
|
28
|
+
clientOptions: config.clientOptions
|
|
28
29
|
};
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -67,9 +68,23 @@ class VmWebTerminal extends VmWith {
|
|
|
67
68
|
} else {
|
|
68
69
|
args.push(`--writable`);
|
|
69
70
|
}
|
|
71
|
+
if (t.theme && t.clientOptions && "theme" in t.clientOptions) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Client option conflict for terminal on port ${t.port}: theme is set in both theme and clientOptions`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const clientOptions = {
|
|
77
|
+
...t.clientOptions ?? {}
|
|
78
|
+
};
|
|
70
79
|
if (t.theme) {
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
clientOptions.theme = t.theme;
|
|
81
|
+
}
|
|
82
|
+
for (const [key, value] of Object.entries(clientOptions)) {
|
|
83
|
+
if (value === void 0) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const serialized = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
87
|
+
args.push(`-t '${key}=${serialized}'`);
|
|
73
88
|
}
|
|
74
89
|
args.push(t.command);
|
|
75
90
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freestyle-sh/with-ttyd",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Web terminal for freestyle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"freestyle-sandboxes": "^0.1.28",
|
|
28
|
-
"@freestyle-sh/with-pty": "^0.0.
|
|
28
|
+
"@freestyle-sh/with-pty": "^0.0.4"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "pkgroll"
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type TtydConfig = {
|
|
|
25
25
|
readOnly?: boolean;
|
|
26
26
|
/** Xterm.js theme settings passed to ttyd client options */
|
|
27
27
|
theme?: Record<string, string | number | boolean>;
|
|
28
|
+
/** TTYD client options (xterm.js options, ttyd client flags) */
|
|
29
|
+
clientOptions?: Record<string, unknown>;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export type ResolvedTerminalConfig = {
|
|
@@ -36,6 +38,7 @@ export type ResolvedTerminalConfig = {
|
|
|
36
38
|
title: string;
|
|
37
39
|
readOnly: boolean;
|
|
38
40
|
theme?: Record<string, string | number | boolean>;
|
|
41
|
+
clientOptions?: Record<string, unknown>;
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
// ============================================================================
|
|
@@ -77,6 +80,7 @@ export class VmWebTerminal<
|
|
|
77
80
|
title: config.title ?? `terminal-${port}`,
|
|
78
81
|
readOnly: config.readOnly ?? false,
|
|
79
82
|
theme: config.theme,
|
|
83
|
+
clientOptions: config.clientOptions,
|
|
80
84
|
};
|
|
81
85
|
});
|
|
82
86
|
}
|
|
@@ -133,9 +137,31 @@ export class VmWebTerminal<
|
|
|
133
137
|
args.push(`--writable`);
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
if (t.theme && t.clientOptions && "theme" in t.clientOptions) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`Client option conflict for terminal on port ${t.port}: theme is set in both theme and clientOptions`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const clientOptions: Record<string, unknown> = {
|
|
147
|
+
...(t.clientOptions ?? {}),
|
|
148
|
+
};
|
|
149
|
+
|
|
136
150
|
if (t.theme) {
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
clientOptions.theme = t.theme;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
for (const [key, value] of Object.entries(clientOptions)) {
|
|
155
|
+
if (value === undefined) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const serialized =
|
|
159
|
+
typeof value === "string" ||
|
|
160
|
+
typeof value === "number" ||
|
|
161
|
+
typeof value === "boolean"
|
|
162
|
+
? String(value)
|
|
163
|
+
: JSON.stringify(value);
|
|
164
|
+
args.push(`-t '${key}=${serialized}'`);
|
|
139
165
|
}
|
|
140
166
|
|
|
141
167
|
// Shell command at the end
|