@spencer-kit/coder-studio 0.4.5 → 0.4.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#62](https://github.com/spencerkit/coder-studio/pull/62) [`535c3c0`](https://github.com/spencerkit/coder-studio/commit/535c3c09cc5895e3b3b949067633f8a6bb3644f8) Thanks [@pallyoung](https://github.com/pallyoung)! - Improve desktop workspace ergonomics by adding keyboard pane navigation,
8
+ supporting workspace path drops into terminal sessions, and launching themed
9
+ PTYs with terminal-aware background environment hints.
10
+
3
11
  ## 0.4.5
4
12
 
5
13
  ### Patch Changes
package/dist/esm/bin.mjs CHANGED
@@ -6892,7 +6892,8 @@ var init_manager3 = __esm({
6892
6892
  ...cmd.env,
6893
6893
  CODER_STUDIO_SESSION_ID: sessionId
6894
6894
  },
6895
- title: req.provider.displayName
6895
+ title: req.provider.displayName,
6896
+ themeBackground: req.themeBackground
6896
6897
  };
6897
6898
  const terminal = this.deps.terminalMgr.create(terminalSpec);
6898
6899
  const active = new ActiveSession({
@@ -12152,6 +12153,39 @@ var init_types2 = __esm({
12152
12153
  function isTerminalTraceEnabled() {
12153
12154
  return process.env.CODER_STUDIO_TERMINAL_TRACE === "1";
12154
12155
  }
12156
+ function parseHexColor(input2) {
12157
+ const trimmed = input2.trim();
12158
+ if (!trimmed.startsWith("#")) {
12159
+ return null;
12160
+ }
12161
+ const hex = trimmed.slice(1);
12162
+ let r;
12163
+ let g;
12164
+ let b;
12165
+ if (hex.length === 3) {
12166
+ r = Number.parseInt(hex[0] + hex[0], 16);
12167
+ g = Number.parseInt(hex[1] + hex[1], 16);
12168
+ b = Number.parseInt(hex[2] + hex[2], 16);
12169
+ } else if (hex.length === 6 || hex.length === 8) {
12170
+ r = Number.parseInt(hex.slice(0, 2), 16);
12171
+ g = Number.parseInt(hex.slice(2, 4), 16);
12172
+ b = Number.parseInt(hex.slice(4, 6), 16);
12173
+ } else {
12174
+ return null;
12175
+ }
12176
+ if ([r, g, b].some((v) => Number.isNaN(v))) {
12177
+ return null;
12178
+ }
12179
+ return { r, g, b };
12180
+ }
12181
+ function computeColorFgBg(background) {
12182
+ const rgb = parseHexColor(background);
12183
+ if (!rgb) {
12184
+ return void 0;
12185
+ }
12186
+ const luma = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
12187
+ return luma > 0.5 ? "0;15" : "15;0";
12188
+ }
12155
12189
  function countOccurrences(text, needle) {
12156
12190
  return text.split(needle).length - 1;
12157
12191
  }
@@ -12208,6 +12242,7 @@ var init_manager5 = __esm({
12208
12242
  */
12209
12243
  create(spec) {
12210
12244
  const id = generateId();
12245
+ const derivedColorFgBg = spec.themeBackground ? computeColorFgBg(spec.themeBackground) : void 0;
12211
12246
  const terminalEnv = {
12212
12247
  ...Object.fromEntries(
12213
12248
  Object.entries(process.env).filter((e) => e[1] != null)
@@ -12215,6 +12250,7 @@ var init_manager5 = __esm({
12215
12250
  TERM: "xterm-256color",
12216
12251
  COLORTERM: "truecolor",
12217
12252
  FORCE_COLOR: "3",
12253
+ ...derivedColorFgBg ? { COLORFGBG: derivedColorFgBg } : {},
12218
12254
  ...spec.env
12219
12255
  };
12220
12256
  let pty;
@@ -13759,7 +13795,8 @@ var init_terminal = __esm({
13759
13795
  workspaceId: z6.string(),
13760
13796
  cols: z6.number().int().positive().optional(),
13761
13797
  rows: z6.number().int().positive().optional(),
13762
- cwdPath: z6.string().optional()
13798
+ cwdPath: z6.string().optional(),
13799
+ themeBackground: z6.string().regex(/^#[0-9a-fA-F]{3,8}$/).optional()
13763
13800
  }),
13764
13801
  async (args, ctx) => {
13765
13802
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -13797,7 +13834,8 @@ var init_terminal = __esm({
13797
13834
  title: shell.title,
13798
13835
  cwd,
13799
13836
  cols: args.cols ?? 120,
13800
- rows: args.rows ?? 30
13837
+ rows: args.rows ?? 30,
13838
+ themeBackground: args.themeBackground
13801
13839
  });
13802
13840
  return terminal;
13803
13841
  }
@@ -15369,7 +15407,8 @@ var init_session2 = __esm({
15369
15407
  z12.object({
15370
15408
  workspaceId: z12.string(),
15371
15409
  providerId: z12.string(),
15372
- draft: z12.string().optional()
15410
+ draft: z12.string().optional(),
15411
+ themeBackground: z12.string().regex(/^#[0-9a-fA-F]{3,8}$/).optional()
15373
15412
  }),
15374
15413
  async (args, ctx) => {
15375
15414
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -15397,7 +15436,8 @@ var init_session2 = __esm({
15397
15436
  workspacePath: workspace.path,
15398
15437
  providerId: args.providerId,
15399
15438
  provider,
15400
- draft: args.draft
15439
+ draft: args.draft,
15440
+ themeBackground: args.themeBackground
15401
15441
  });
15402
15442
  }
15403
15443
  );