dsh-tui-theme 0.2.1 → 0.2.2

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.
@@ -6,9 +6,9 @@
6
6
  * ride it. This module gives pink-day/pink-night the same behavior from the
7
7
  * plugin side:
8
8
  *
9
- * - at apply() (which runs before the React tree mounts and reads
10
- * ~/.dsh-tui/theme.json), the cached detection writes the resolved theme
11
- * name into the pref synchronously always in time for this boot;
9
+ * - the caller wires this from the settings inject callback (see index.ts):
10
+ * that fires before the React tree mounts and reads ~/.dsh-tui/theme.json,
11
+ * so the cached detection still decides this boot;
12
12
  * - a fresh OSC 11 query then refreshes the cache for the next boot. The
13
13
  * very first enabling (or a system flip between boots) lands one boot
14
14
  * late — the same cadence as the host's own "re-select auto or restart".
@@ -1 +1 @@
1
- {"version":3,"file":"autoTheme.d.ts","sourceRoot":"","sources":["../../src/autoTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAgBH,UAAU,WAAW;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;CACX;AAgCD,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGxE;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQrE;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,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EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAC7B,IAAI,CAYN"}
@@ -6,9 +6,9 @@
6
6
  * ride it. This module gives pink-day/pink-night the same behavior from the
7
7
  * plugin side:
8
8
  *
9
- * - at apply() (which runs before the React tree mounts and reads
10
- * ~/.dsh-tui/theme.json), the cached detection writes the resolved theme
11
- * name into the pref synchronously always in time for this boot;
9
+ * - the caller wires this from the settings inject callback (see index.ts):
10
+ * that fires before the React tree mounts and reads ~/.dsh-tui/theme.json,
11
+ * so the cached detection still decides this boot;
12
12
  * - a fresh OSC 11 query then refreshes the cache for the next boot. The
13
13
  * very first enabling (or a system flip between boots) lands one boot
14
14
  * late — the same cadence as the host's own "re-select auto or restart".
@@ -19,7 +19,6 @@
19
19
  * @module dsh-tui-theme/autoTheme
20
20
  */
21
21
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
22
- import { homedir } from 'node:os';
23
22
  import { join } from 'node:path';
24
23
  /** The pair this feature switches between (light terminal → day). */
25
24
  const LIGHT_THEME = 'pink-day';
@@ -29,9 +28,6 @@ const QUERY = '\x1b]11;?\x07';
29
28
  // ST terminated.
30
29
  const REPLY = /\x1b\]11;rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})(?:\x07|\x1b\\)/;
31
30
  const DETECT_TIMEOUT_MS = 400;
32
- function homeDir() {
33
- return homedir() || process.env.USERPROFILE || process.env.HOME || '';
34
- }
35
31
  function prefPath(dir) {
36
32
  return join(dir, 'theme.json');
37
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjF,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAEnC,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,eAAe,CAAA;AAUpC,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,MAAM,CAOrC,CAAA;AAiBF;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAsC7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjF,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAEnC,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,eAAe,CAAA;AAUpC,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,MAAM,CAOrC,CAAA;AAwBF;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAgE7D"}
@@ -44,6 +44,12 @@ const DEFAULTS = {
44
44
  showClock: true,
45
45
  showTurns: true,
46
46
  };
47
+ /**
48
+ * Backstop delay for the cordis-layer follow decision on hosts without a
49
+ * settings service (see apply). Stays under the host's own 300ms pre-mount
50
+ * settings gate so the pref write still lands before first paint.
51
+ */
52
+ const FOLLOW_FALLBACK_MS = 150;
47
53
  /**
48
54
  * Wire the pink theme plugin.
49
55
  * @param ctx - Cordis context (the plugin's own activation).
@@ -69,18 +75,45 @@ export function apply(ctx, config = {}) {
69
75
  ctx.logger.warn(`dsh-tui-theme: could not install bundled theme "${file}"`);
70
76
  }
71
77
  }
72
- // Background follow runs before the React tree mounts (which reads the
73
- // theme pref), so the cached detection decides this boot.
74
- if (cordis.followSystem) {
75
- runFollowSystem(join(homeDir(), '.dsh-tui'), message => {
76
- ctx.logger.info(`dsh-tui-theme: ${message}`);
77
- });
78
- }
79
78
  // The /settings user layer (settings.yaml) overrides the cordis layer and
80
79
  // lands live through scope.watch; both override the hardcoded defaults.
81
80
  let effective = cordis;
81
+ // Background follow honors the MERGED knob (cordis layer overlaid by the
82
+ // /settings user layer), so the decision cannot be taken synchronously at
83
+ // apply(): the user layer is only readable once the settings service
84
+ // answers. The settings callback still fires before the host's React tree
85
+ // mounts (the host gates its own mount on the same service, probed
86
+ // against 0.9.0), so the pref write decides this boot exactly like a sync
87
+ // write would, and toggling followSystem in /settings re-decides live.
88
+ let followActive;
89
+ const dataDir = join(homeDir(), '.dsh-tui');
90
+ const startFollow = () => {
91
+ runFollowSystem(dataDir, message => {
92
+ ctx.logger.info(`dsh-tui-theme: ${message}`);
93
+ });
94
+ };
82
95
  registerPinkSettings(ctx, cordis, doc => {
83
96
  effective = { ...cordis, ...doc };
97
+ if (effective.followSystem !== followActive) {
98
+ followActive = effective.followSystem;
99
+ if (followActive) {
100
+ startFollow();
101
+ }
102
+ else {
103
+ ctx.logger.info('dsh-tui-theme: follow: disabled, manual /theme choice preserved');
104
+ }
105
+ }
84
106
  });
107
+ // Degradation backstop for hosts that never provide a settings service:
108
+ // the inject callback never fires there, so the cordis-layer decision
109
+ // applies instead. The delay lets any pending service registration (and
110
+ // its callback) land first — it no-ops once followActive is settled, and
111
+ // stays inside the host's own 300ms pre-mount settings gate either way.
112
+ setTimeout(() => {
113
+ if (followActive === undefined && cordis.followSystem) {
114
+ followActive = true;
115
+ startFollow();
116
+ }
117
+ }, FOLLOW_FALLBACK_MS);
85
118
  startStatusLine(ctx, () => effective);
86
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"settingsSection.d.ts","sourceRoot":"","sources":["../../src/settingsSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GACpC,IAAI,CAuCN"}
1
+ {"version":3,"file":"settingsSection.d.ts","sourceRoot":"","sources":["../../src/settingsSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GACpC,IAAI,CA2CN"}
@@ -46,8 +46,12 @@ export function registerPinkSettings(ctx, cordis, onDoc) {
46
46
  }
47
47
  onDoc(clean);
48
48
  };
49
- emit(scope.get());
50
- scope.watch(emit);
49
+ // Own the watcher on the inject-scoped ledger so it survives exactly as
50
+ // long as this activation (scope.watch's disposer is otherwise leaked).
51
+ settingsCtx.effect(() => {
52
+ emit(scope.get());
53
+ return scope.watch(emit);
54
+ });
51
55
  });
52
56
  ctx.inject(['tuiSettingsSections'], sectionsCtx => {
53
57
  const sections = sectionsCtx
@@ -1 +1 @@
1
- {"version":3,"file":"statusLine.d.ts","sourceRoot":"","sources":["../../src/statusLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;AAoBrD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,GAAG,IAAI,CAoDvF"}
1
+ {"version":3,"file":"statusLine.d.ts","sourceRoot":"","sources":["../../src/statusLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;AAoBrD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,GAAG,IAAI,CAsDvF"}
@@ -38,12 +38,14 @@ export function startStatusLine(ctx, getEffective) {
38
38
  try {
39
39
  const eff = getEffective();
40
40
  const parts = [];
41
- if (eff.showGlyph)
42
- parts.push(GLYPH);
43
- if (eff.showClock)
44
- parts.push(clockText());
45
- if (eff.showTurns && current !== undefined) {
46
- parts.push(`${turns.get(current) ?? 0}✦`);
41
+ if (eff.statusEnabled) {
42
+ if (eff.showGlyph)
43
+ parts.push(GLYPH);
44
+ if (eff.showClock)
45
+ parts.push(clockText());
46
+ if (eff.showTurns && current !== undefined) {
47
+ parts.push(`${turns.get(current) ?? 0}✦`);
48
+ }
47
49
  }
48
50
  const text = parts.join(' · ');
49
51
  // The trailing identity must be the inject-scoped context (the same
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tui-theme",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Sakura-pink themes for dsh-TUI with terminal-background auto-follow (pink-day/pink-night), a blossom status line, and a /settings section. No shortcuts, no commands.",
5
5
  "type": "module",
6
6
  "main": "lib/types/index.js",