ccstatusline-zh 2.2.34 → 2.2.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstatusline-zh",
3
- "version": "2.2.34",
3
+ "version": "2.2.36",
4
4
  "bugs": {
5
5
  "url": "https://github.com/huangguang1999/ccstatusline-zh/issues"
6
6
  },
@@ -58,9 +58,9 @@
58
58
  "ink-gradient": "^4.0.0",
59
59
  "ink-select-input": "^6.2.0",
60
60
  "pluralize": "^8.0.0",
61
- "react": "19.3.0",
61
+ "react": "19.3.1",
62
62
  "react-devtools-core": "^8.0.0",
63
- "react-dom": "19.3.0",
63
+ "react-dom": "19.3.1",
64
64
  "remotion": "^4.0.459",
65
65
  "strip-ansi": "^7.1.0",
66
66
  "tinyglobby": "^0.2.14",
@@ -1,103 +0,0 @@
1
- import {
2
- loadClaudeSettings,
3
- saveClaudeSettings,
4
- getExistingStatusLine,
5
- getWidget
6
- } from "./ccstatusline-jp52tswn.js";
7
-
8
- // src/utils/hooks.ts
9
- var HOOK_TAG = "ccstatusline-managed";
10
- var CCSTATUSLINE_HOOK_PATTERN = /ccstatusline.* --hook(?:\s|$)/;
11
- function hasWidgetHooks(widget) {
12
- return Boolean(widget && "getHooks" in widget && typeof widget.getHooks === "function");
13
- }
14
- function isCcstatuslineManagedEntry(entry) {
15
- return entry._tag === HOOK_TAG;
16
- }
17
- function isLegacyCcstatuslineHookCommand(hook) {
18
- return CCSTATUSLINE_HOOK_PATTERN.test(hook.command);
19
- }
20
- function stripManagedHookEntry(entry) {
21
- if (isCcstatuslineManagedEntry(entry)) {
22
- return null;
23
- }
24
- if (!entry.hooks) {
25
- return entry;
26
- }
27
- const remainingHooks = entry.hooks.filter((hook) => !isLegacyCcstatuslineHookCommand(hook));
28
- if (remainingHooks.length === entry.hooks.length) {
29
- return entry;
30
- }
31
- if (remainingHooks.length === 0) {
32
- return null;
33
- }
34
- return {
35
- ...entry,
36
- hooks: remainingHooks
37
- };
38
- }
39
- function stripManagedHooks(hooks) {
40
- for (const event of Object.keys(hooks)) {
41
- hooks[event] = (hooks[event] ?? []).map(stripManagedHookEntry).filter((entry) => entry !== null);
42
- if (hooks[event].length === 0) {
43
- Reflect.deleteProperty(hooks, event);
44
- }
45
- }
46
- }
47
- function getActiveHookDefs(settings) {
48
- const seen = new Set;
49
- const defs = [];
50
- for (const line of settings.lines) {
51
- for (const item of line) {
52
- const widget = getWidget(item.type);
53
- if (!hasWidgetHooks(widget)) {
54
- continue;
55
- }
56
- for (const hook of widget.getHooks()) {
57
- const key = `${hook.event}:${hook.matcher ?? ""}`;
58
- if (!seen.has(key)) {
59
- seen.add(key);
60
- defs.push(hook);
61
- }
62
- }
63
- }
64
- }
65
- return defs;
66
- }
67
- async function syncWidgetHooks(settings) {
68
- const needed = getActiveHookDefs(settings);
69
- const claudeSettings = await loadClaudeSettings({ logErrors: false });
70
- const hooks = claudeSettings.hooks ?? {};
71
- stripManagedHooks(hooks);
72
- const statusCommand = await getExistingStatusLine();
73
- if (!statusCommand?.includes("ccstatusline")) {
74
- claudeSettings.hooks = Object.keys(hooks).length > 0 ? hooks : undefined;
75
- await saveClaudeSettings(claudeSettings);
76
- return;
77
- }
78
- const hookCommand = `${statusCommand} --hook`;
79
- for (const def of needed) {
80
- const entry = {
81
- _tag: HOOK_TAG,
82
- hooks: [{ type: "command", command: hookCommand }]
83
- };
84
- if (def.matcher) {
85
- entry.matcher = def.matcher;
86
- }
87
- const list = hooks[def.event] ??= [];
88
- list.push(entry);
89
- }
90
- claudeSettings.hooks = Object.keys(hooks).length > 0 ? hooks : undefined;
91
- await saveClaudeSettings(claudeSettings);
92
- }
93
- async function removeManagedHooks() {
94
- const claudeSettings = await loadClaudeSettings({ logErrors: false });
95
- const hooks = claudeSettings.hooks ?? {};
96
- stripManagedHooks(hooks);
97
- claudeSettings.hooks = Object.keys(hooks).length > 0 ? hooks : undefined;
98
- await saveClaudeSettings(claudeSettings);
99
- }
100
- export {
101
- removeManagedHooks,
102
- syncWidgetHooks
103
- };