@elench/testkit 0.1.114 → 0.1.115

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 (184) hide show
  1. package/lib/cli/assistant/app.mjs +4 -2
  2. package/lib/cli/assistant/session.mjs +5 -1
  3. package/lib/cli/assistant/state.mjs +1 -2
  4. package/lib/cli/components/blocks/run-tree.mjs +7 -2
  5. package/lib/cli/components/hooks/use-element-layout.mjs +63 -0
  6. package/lib/cli/components/hooks/use-spinner-frame.mjs +26 -0
  7. package/node_modules/@alcalzone/ansi-tokenize/README.md +0 -5
  8. package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.d.ts +8 -0
  9. package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js +10 -8
  10. package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js.map +1 -1
  11. package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.d.ts +1 -5
  12. package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.js +9 -45
  13. package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.js.map +1 -1
  14. package/node_modules/@alcalzone/ansi-tokenize/package.json +1 -1
  15. package/node_modules/@elench/next-analysis/package.json +1 -1
  16. package/node_modules/@elench/testkit-bridge/package.json +2 -2
  17. package/node_modules/@elench/testkit-protocol/package.json +1 -1
  18. package/node_modules/@elench/ts-analysis/package.json +1 -1
  19. package/node_modules/cli-boxes/index.d.ts +95 -90
  20. package/node_modules/cli-boxes/index.js +5 -2
  21. package/node_modules/cli-boxes/package.json +6 -13
  22. package/node_modules/cli-boxes/readme.md +15 -3
  23. package/node_modules/cli-truncate/index.d.ts +1 -1
  24. package/node_modules/cli-truncate/package.json +4 -4
  25. package/node_modules/cli-truncate/readme.md +1 -0
  26. package/node_modules/ink/build/apply-styles.js +175 -0
  27. package/node_modules/ink/build/build-layout.js +77 -0
  28. package/node_modules/ink/build/calculate-wrapped-text.js +53 -0
  29. package/node_modules/ink/build/components/App.d.ts +1 -4
  30. package/node_modules/ink/build/components/App.js +22 -142
  31. package/node_modules/ink/build/components/App.js.map +1 -1
  32. package/node_modules/ink/build/components/AppContext.d.ts +3 -23
  33. package/node_modules/ink/build/components/AppContext.js +4 -7
  34. package/node_modules/ink/build/components/AppContext.js.map +1 -1
  35. package/node_modules/ink/build/components/Box.d.ts +3 -16
  36. package/node_modules/ink/build/components/Color.js +62 -0
  37. package/node_modules/ink/build/components/Cursor.d.ts +83 -0
  38. package/node_modules/ink/build/components/Cursor.js +53 -0
  39. package/node_modules/ink/build/components/Cursor.js.map +1 -0
  40. package/node_modules/ink/build/components/ErrorBoundary.d.ts +2 -2
  41. package/node_modules/ink/build/components/ErrorOverview.js +6 -6
  42. package/node_modules/ink/build/components/ErrorOverview.js.map +1 -1
  43. package/node_modules/ink/build/components/Static.js.map +1 -1
  44. package/node_modules/ink/build/components/StdinContext.d.ts +1 -7
  45. package/node_modules/ink/build/components/StdinContext.js +0 -1
  46. package/node_modules/ink/build/components/StdinContext.js.map +1 -1
  47. package/node_modules/ink/build/components/Text.d.ts +1 -1
  48. package/node_modules/ink/build/components/Text.js +1 -1
  49. package/node_modules/ink/build/components/Text.js.map +1 -1
  50. package/node_modules/ink/build/components/Transform.d.ts +1 -1
  51. package/node_modules/ink/build/devtools-window-polyfill.js +4 -7
  52. package/node_modules/ink/build/devtools-window-polyfill.js.map +1 -1
  53. package/node_modules/ink/build/devtools.js +6 -31
  54. package/node_modules/ink/build/devtools.js.map +1 -1
  55. package/node_modules/ink/build/dom.d.ts +1 -5
  56. package/node_modules/ink/build/dom.js +1 -20
  57. package/node_modules/ink/build/dom.js.map +1 -1
  58. package/node_modules/ink/build/experimental/apply-style.js +140 -0
  59. package/node_modules/ink/build/experimental/dom.js +123 -0
  60. package/node_modules/ink/build/experimental/output.js +91 -0
  61. package/node_modules/ink/build/experimental/reconciler.js +141 -0
  62. package/node_modules/ink/build/experimental/renderer.js +81 -0
  63. package/node_modules/ink/build/hooks/use-app.d.ts +1 -1
  64. package/node_modules/ink/build/hooks/use-app.js +1 -1
  65. package/node_modules/ink/build/hooks/use-cursor.d.ts +1 -1
  66. package/node_modules/ink/build/hooks/use-cursor.js +1 -1
  67. package/node_modules/ink/build/hooks/use-focus-manager.d.ts +2 -17
  68. package/node_modules/ink/build/hooks/use-focus-manager.js +1 -2
  69. package/node_modules/ink/build/hooks/use-focus-manager.js.map +1 -1
  70. package/node_modules/ink/build/hooks/use-focus.d.ts +1 -2
  71. package/node_modules/ink/build/hooks/use-focus.js +4 -5
  72. package/node_modules/ink/build/hooks/use-focus.js.map +1 -1
  73. package/node_modules/ink/build/hooks/use-input.d.ts +1 -2
  74. package/node_modules/ink/build/hooks/use-input.js +80 -82
  75. package/node_modules/ink/build/hooks/use-input.js.map +1 -1
  76. package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.d.ts +1 -2
  77. package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js +1 -2
  78. package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
  79. package/node_modules/ink/build/hooks/use-stderr.d.ts +1 -1
  80. package/node_modules/ink/build/hooks/use-stderr.js +1 -1
  81. package/node_modules/ink/build/hooks/use-stdin.d.ts +2 -4
  82. package/node_modules/ink/build/hooks/use-stdin.js +1 -2
  83. package/node_modules/ink/build/hooks/use-stdin.js.map +1 -1
  84. package/node_modules/ink/build/hooks/use-stdout.d.ts +1 -1
  85. package/node_modules/ink/build/hooks/use-stdout.js +1 -1
  86. package/node_modules/ink/build/hooks/useInput.js +38 -0
  87. package/node_modules/ink/build/index.d.ts +1 -8
  88. package/node_modules/ink/build/index.js +0 -4
  89. package/node_modules/ink/build/index.js.map +1 -1
  90. package/node_modules/ink/build/ink.d.ts +3 -48
  91. package/node_modules/ink/build/ink.js +155 -325
  92. package/node_modules/ink/build/ink.js.map +1 -1
  93. package/node_modules/ink/build/input-parser.d.ts +1 -4
  94. package/node_modules/ink/build/input-parser.js +30 -70
  95. package/node_modules/ink/build/input-parser.js.map +1 -1
  96. package/node_modules/ink/build/instance.js +205 -0
  97. package/node_modules/ink/build/layout.d.ts +7 -0
  98. package/node_modules/ink/build/layout.js +33 -0
  99. package/node_modules/ink/build/layout.js.map +1 -0
  100. package/node_modules/ink/build/log-update.d.ts +0 -1
  101. package/node_modules/ink/build/log-update.js +1 -13
  102. package/node_modules/ink/build/log-update.js.map +1 -1
  103. package/node_modules/ink/build/measure-element.d.ts +0 -4
  104. package/node_modules/ink/build/measure-element.js +0 -4
  105. package/node_modules/ink/build/measure-element.js.map +1 -1
  106. package/node_modules/ink/build/options.d.ts +52 -0
  107. package/node_modules/ink/build/options.js +2 -0
  108. package/node_modules/ink/build/options.js.map +1 -0
  109. package/node_modules/ink/build/output.js +0 -25
  110. package/node_modules/ink/build/output.js.map +1 -1
  111. package/node_modules/ink/build/parse-keypress.d.ts +3 -1
  112. package/node_modules/ink/build/parse-keypress.js +17 -19
  113. package/node_modules/ink/build/parse-keypress.js.map +1 -1
  114. package/node_modules/ink/build/reconciler.js +27 -46
  115. package/node_modules/ink/build/reconciler.js.map +1 -1
  116. package/node_modules/ink/build/render-border.js +18 -29
  117. package/node_modules/ink/build/render-border.js.map +1 -1
  118. package/node_modules/ink/build/render-to-string.js +1 -2
  119. package/node_modules/ink/build/render-to-string.js.map +1 -1
  120. package/node_modules/ink/build/render.d.ts +2 -57
  121. package/node_modules/ink/build/render.js +11 -18
  122. package/node_modules/ink/build/render.js.map +1 -1
  123. package/node_modules/ink/build/screen-reader-update.d.ts +13 -0
  124. package/node_modules/ink/build/screen-reader-update.js +38 -0
  125. package/node_modules/ink/build/screen-reader-update.js.map +1 -0
  126. package/node_modules/ink/build/styles.d.ts +16 -78
  127. package/node_modules/ink/build/styles.js +31 -102
  128. package/node_modules/ink/build/styles.js.map +1 -1
  129. package/node_modules/ink/build/utils.d.ts +2 -9
  130. package/node_modules/ink/build/utils.js +3 -18
  131. package/node_modules/ink/build/utils.js.map +1 -1
  132. package/node_modules/ink/build/wrap-text.js +0 -7
  133. package/node_modules/ink/build/wrap-text.js.map +1 -1
  134. package/node_modules/ink/build/write-synchronized.d.ts +1 -1
  135. package/node_modules/ink/build/write-synchronized.js +2 -4
  136. package/node_modules/ink/build/write-synchronized.js.map +1 -1
  137. package/node_modules/ink/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  138. package/node_modules/ink/node_modules/emoji-regex/README.md +107 -0
  139. package/node_modules/ink/node_modules/emoji-regex/index.d.ts +3 -0
  140. package/node_modules/ink/node_modules/emoji-regex/index.js +4 -0
  141. package/node_modules/ink/node_modules/emoji-regex/index.mjs +4 -0
  142. package/node_modules/ink/node_modules/emoji-regex/package.json +45 -0
  143. package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/index.d.ts +1 -1
  144. package/node_modules/ink/node_modules/wrap-ansi/index.js +222 -0
  145. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/index.d.ts +39 -0
  146. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/index.js +82 -0
  147. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/license +9 -0
  148. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/package.json +64 -0
  149. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/readme.md +66 -0
  150. package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/package.json +11 -11
  151. package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/readme.md +0 -2
  152. package/node_modules/ink/package.json +98 -34
  153. package/node_modules/ink/readme.md +48 -554
  154. package/node_modules/slice-ansi/index.d.ts +1 -1
  155. package/node_modules/slice-ansi/index.js +89 -146
  156. package/node_modules/slice-ansi/package.json +5 -5
  157. package/node_modules/slice-ansi/readme.md +0 -1
  158. package/node_modules/slice-ansi/tokenize-ansi.js +1 -1
  159. package/package.json +11 -10
  160. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.d.ts +188 -0
  161. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.d.ts.map +1 -0
  162. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.js +293 -0
  163. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.js.map +1 -0
  164. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/package.json +25 -0
  165. package/node_modules/@alcalzone/ansi-tokenize/build/consts.d.ts +0 -17
  166. package/node_modules/@alcalzone/ansi-tokenize/build/consts.js +0 -28
  167. package/node_modules/@alcalzone/ansi-tokenize/build/consts.js.map +0 -1
  168. package/node_modules/ink/build/components/AnimationContext.d.ts +0 -9
  169. package/node_modules/ink/build/components/AnimationContext.js +0 -13
  170. package/node_modules/ink/build/components/AnimationContext.js.map +0 -1
  171. package/node_modules/ink/build/hooks/use-animation.d.ts +0 -49
  172. package/node_modules/ink/build/hooks/use-animation.js +0 -87
  173. package/node_modules/ink/build/hooks/use-animation.js.map +0 -1
  174. package/node_modules/ink/build/hooks/use-box-metrics.d.ts +0 -59
  175. package/node_modules/ink/build/hooks/use-box-metrics.js +0 -88
  176. package/node_modules/ink/build/hooks/use-box-metrics.js.map +0 -1
  177. package/node_modules/ink/build/hooks/use-paste.d.ts +0 -35
  178. package/node_modules/ink/build/hooks/use-paste.js +0 -62
  179. package/node_modules/ink/build/hooks/use-paste.js.map +0 -1
  180. package/node_modules/ink/build/hooks/use-window-size.d.ts +0 -18
  181. package/node_modules/ink/build/hooks/use-window-size.js +0 -22
  182. package/node_modules/ink/build/hooks/use-window-size.js.map +0 -1
  183. package/node_modules/wrap-ansi/index.js +0 -468
  184. /package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/license +0 -0
@@ -0,0 +1,293 @@
1
+ export const TESTKIT_BROWSER_PROTOCOL_VERSION = 1;
2
+ export const TESTKIT_COVERAGE_GRAPH_VERSION = 1;
3
+ const TARGET_KINDS = new Set(["testId", "role", "text", "css", "xpath", "component"]);
4
+ const CONFIDENCE_LEVELS = new Set(["low", "medium", "high"]);
5
+ const FAILURE_STATES = new Set(["failing", "healthy", "unavailable"]);
6
+ const COVERAGE_STATES = new Set(["covered", "missing", "unavailable"]);
7
+ const NODE_KINDS = new Set([
8
+ "page_view",
9
+ "ui_surface",
10
+ "ui_action",
11
+ "client_request",
12
+ "api_route",
13
+ "server_action",
14
+ "server_capability",
15
+ "data_capability",
16
+ "test_file",
17
+ ]);
18
+ const EDGE_KINDS = new Set([
19
+ "contains",
20
+ "renders",
21
+ "triggers",
22
+ "requests",
23
+ "handles",
24
+ "delegates_to",
25
+ "covers",
26
+ ]);
27
+ const EVIDENCE_SOURCES = new Set(["convention", "static", "runtime"]);
28
+ const DIAGNOSTIC_LEVELS = new Set(["info", "warn"]);
29
+ export function normalizeBrowserTarget(value) {
30
+ if (!value || typeof value !== "object" || Array.isArray(value))
31
+ return null;
32
+ const record = value;
33
+ const kind = normalizeOptionalString(record.kind);
34
+ const targetValue = normalizeOptionalString(record.value);
35
+ if (!kind || !isSetValue(TARGET_KINDS, kind) || !targetValue)
36
+ return null;
37
+ const label = normalizeOptionalString(record.label);
38
+ const confidence = normalizeOptionalString(record.confidence);
39
+ return {
40
+ kind,
41
+ value: targetValue,
42
+ ...(label ? { label } : {}),
43
+ ...(confidence && isSetValue(CONFIDENCE_LEVELS, confidence) ? { confidence } : {}),
44
+ };
45
+ }
46
+ export function normalizeBrowserMetadata(value) {
47
+ if (!value || typeof value !== "object" || Array.isArray(value))
48
+ return null;
49
+ const record = value;
50
+ const label = normalizeOptionalString(record.label);
51
+ const origins = normalizeStringArray(record.origins);
52
+ const routes = normalizeStringArray(record.routes);
53
+ const targets = Array.isArray(record.targets)
54
+ ? record.targets.map((entry) => normalizeBrowserTarget(entry)).filter((entry) => Boolean(entry))
55
+ : [];
56
+ if (!label && origins.length === 0 && routes.length === 0 && targets.length === 0) {
57
+ return null;
58
+ }
59
+ return {
60
+ ...(label ? { label } : {}),
61
+ ...(origins.length > 0 ? { origins } : {}),
62
+ ...(routes.length > 0 ? { routes } : {}),
63
+ ...(targets.length > 0 ? { targets } : {}),
64
+ };
65
+ }
66
+ export function normalizeBrowserMetadataDocument(value) {
67
+ if (!value || typeof value !== "object" || Array.isArray(value))
68
+ return null;
69
+ const record = value;
70
+ const schemaVersion = Number.isInteger(record.schemaVersion) && Number(record.schemaVersion) > 0
71
+ ? Number(record.schemaVersion)
72
+ : TESTKIT_BROWSER_PROTOCOL_VERSION;
73
+ const browser = normalizeBrowserMetadata(record.browser);
74
+ if (!browser)
75
+ return null;
76
+ return {
77
+ schemaVersion,
78
+ browser,
79
+ };
80
+ }
81
+ export function normalizeCoverageGraphNode(value) {
82
+ if (!value || typeof value !== "object" || Array.isArray(value))
83
+ return null;
84
+ const record = value;
85
+ const id = normalizeOptionalString(record.id);
86
+ const kind = normalizeOptionalString(record.kind);
87
+ const service = normalizeOptionalString(record.service);
88
+ const label = normalizeOptionalString(record.label);
89
+ if (!id || !kind || !isSetValue(NODE_KINDS, kind) || !service || !label)
90
+ return null;
91
+ const filePath = normalizeOptionalString(record.filePath);
92
+ const route = normalizeOptionalString(record.route);
93
+ const method = normalizeOptionalString(record.method);
94
+ const path = normalizeOptionalString(record.path);
95
+ const target = normalizeBrowserTarget(record.target);
96
+ const metadata = normalizeMetadataRecord(record.metadata);
97
+ return {
98
+ id,
99
+ kind,
100
+ service,
101
+ label,
102
+ ...(filePath ? { filePath } : {}),
103
+ ...(route ? { route } : {}),
104
+ ...(method ? { method } : {}),
105
+ ...(path ? { path } : {}),
106
+ ...(target ? { target } : {}),
107
+ ...(metadata ? { metadata } : {}),
108
+ };
109
+ }
110
+ export function normalizeCoverageGraphEdge(value) {
111
+ if (!value || typeof value !== "object" || Array.isArray(value))
112
+ return null;
113
+ const record = value;
114
+ const id = normalizeOptionalString(record.id);
115
+ const kind = normalizeOptionalString(record.kind);
116
+ const from = normalizeOptionalString(record.from);
117
+ const to = normalizeOptionalString(record.to);
118
+ if (!id || !kind || !isSetValue(EDGE_KINDS, kind) || !from || !to)
119
+ return null;
120
+ const confidence = normalizeOptionalString(record.confidence);
121
+ const metadata = normalizeMetadataRecord(record.metadata);
122
+ return {
123
+ id,
124
+ kind,
125
+ from,
126
+ to,
127
+ ...(confidence && isSetValue(CONFIDENCE_LEVELS, confidence) ? { confidence } : {}),
128
+ ...(metadata ? { metadata } : {}),
129
+ };
130
+ }
131
+ export function normalizeCoverageEvidence(value) {
132
+ if (!value || typeof value !== "object" || Array.isArray(value))
133
+ return null;
134
+ const record = value;
135
+ const id = normalizeOptionalString(record.id);
136
+ const source = normalizeOptionalString(record.source);
137
+ const service = normalizeOptionalString(record.service);
138
+ const suiteName = normalizeOptionalString(record.suiteName);
139
+ const type = normalizeOptionalString(record.type) || normalizeOptionalString(record.selectionType);
140
+ const testFilePath = normalizeOptionalString(record.testFilePath);
141
+ const coveredNodeIds = normalizeStringArray(record.coveredNodeIds);
142
+ if (!id ||
143
+ !source ||
144
+ !isSetValue(EVIDENCE_SOURCES, source) ||
145
+ !service ||
146
+ !suiteName ||
147
+ !type ||
148
+ !testFilePath ||
149
+ coveredNodeIds.length === 0) {
150
+ return null;
151
+ }
152
+ const confidence = normalizeOptionalString(record.confidence);
153
+ const details = normalizeEvidenceDetails(record.details);
154
+ return {
155
+ id,
156
+ source,
157
+ service,
158
+ suiteName,
159
+ type,
160
+ testFilePath,
161
+ coveredNodeIds,
162
+ ...(confidence && isSetValue(CONFIDENCE_LEVELS, confidence) ? { confidence } : {}),
163
+ ...(details ? { details } : {}),
164
+ };
165
+ }
166
+ export function normalizeCoverageGraphDiagnostic(value) {
167
+ if (!value || typeof value !== "object" || Array.isArray(value))
168
+ return null;
169
+ const record = value;
170
+ const level = normalizeOptionalString(record.level);
171
+ const code = normalizeOptionalString(record.code);
172
+ const filePath = normalizeOptionalString(record.filePath);
173
+ const service = normalizeOptionalString(record.service);
174
+ const message = normalizeOptionalString(record.message);
175
+ if (!level || !code || !filePath || !service || !message)
176
+ return null;
177
+ if (!isSetValue(DIAGNOSTIC_LEVELS, level))
178
+ return null;
179
+ return { level, code, filePath, service, message };
180
+ }
181
+ export function normalizeCoverageGraph(value) {
182
+ if (!value || typeof value !== "object" || Array.isArray(value))
183
+ return null;
184
+ const record = value;
185
+ const schemaVersion = Number.isInteger(record.schemaVersion) && Number(record.schemaVersion) > 0
186
+ ? Number(record.schemaVersion)
187
+ : TESTKIT_COVERAGE_GRAPH_VERSION;
188
+ const nodes = Array.isArray(record.nodes)
189
+ ? record.nodes.map((entry) => normalizeCoverageGraphNode(entry)).filter((entry) => Boolean(entry))
190
+ : [];
191
+ const edges = Array.isArray(record.edges)
192
+ ? record.edges.map((entry) => normalizeCoverageGraphEdge(entry)).filter((entry) => Boolean(entry))
193
+ : [];
194
+ const evidence = Array.isArray(record.evidence)
195
+ ? record.evidence.map((entry) => normalizeCoverageEvidence(entry)).filter((entry) => Boolean(entry))
196
+ : [];
197
+ const diagnostics = Array.isArray(record.diagnostics)
198
+ ? record.diagnostics
199
+ .map((entry) => normalizeCoverageGraphDiagnostic(entry))
200
+ .filter((entry) => Boolean(entry))
201
+ : [];
202
+ if (nodes.length === 0)
203
+ return null;
204
+ return {
205
+ schemaVersion,
206
+ nodes,
207
+ edges,
208
+ evidence,
209
+ diagnostics,
210
+ };
211
+ }
212
+ export function isPageOverlayResponse(value) {
213
+ return Boolean(normalizePageOverlayResponse(value));
214
+ }
215
+ export function normalizePageOverlayResponse(value) {
216
+ if (!value || typeof value !== "object" || Array.isArray(value))
217
+ return null;
218
+ const record = value;
219
+ if (record.protocolVersion !== TESTKIT_BROWSER_PROTOCOL_VERSION)
220
+ return null;
221
+ if (!record.page || typeof record.page !== "object")
222
+ return null;
223
+ if (!record.match || typeof record.match !== "object")
224
+ return null;
225
+ if (!record.summary || typeof record.summary !== "object")
226
+ return null;
227
+ if (!Array.isArray(record.coverage) || !Array.isArray(record.failures))
228
+ return null;
229
+ const summary = record.summary;
230
+ if (!isSetValue(FAILURE_STATES, summary.failureState))
231
+ return null;
232
+ if (!isSetValue(COVERAGE_STATES, summary.coverageState))
233
+ return null;
234
+ return record;
235
+ }
236
+ export function createBridgeErrorResponse(code, message) {
237
+ return {
238
+ protocolVersion: TESTKIT_BROWSER_PROTOCOL_VERSION,
239
+ error: {
240
+ code,
241
+ message,
242
+ },
243
+ };
244
+ }
245
+ function normalizeEvidenceDetails(value) {
246
+ if (!value || typeof value !== "object" || Array.isArray(value))
247
+ return null;
248
+ const record = value;
249
+ const requestPaths = normalizeStringArray(record.requestPaths);
250
+ const route = normalizeOptionalString(record.route);
251
+ const targets = Array.isArray(record.targets)
252
+ ? record.targets.map((entry) => normalizeBrowserTarget(entry)).filter((entry) => Boolean(entry))
253
+ : [];
254
+ if (requestPaths.length === 0 && !route && targets.length === 0)
255
+ return null;
256
+ return {
257
+ ...(requestPaths.length > 0 ? { requestPaths } : {}),
258
+ ...(route ? { route } : {}),
259
+ ...(targets.length > 0 ? { targets } : {}),
260
+ };
261
+ }
262
+ function normalizeMetadataRecord(value) {
263
+ if (!value || typeof value !== "object" || Array.isArray(value))
264
+ return null;
265
+ const normalized = {};
266
+ for (const [key, entry] of Object.entries(value)) {
267
+ const normalizedKey = normalizeOptionalString(key);
268
+ if (!normalizedKey)
269
+ continue;
270
+ if (entry === null ||
271
+ typeof entry === "string" ||
272
+ typeof entry === "number" ||
273
+ typeof entry === "boolean") {
274
+ normalized[normalizedKey] = entry;
275
+ }
276
+ }
277
+ return Object.keys(normalized).length > 0 ? normalized : null;
278
+ }
279
+ function normalizeStringArray(value) {
280
+ if (!Array.isArray(value))
281
+ return [];
282
+ return value.map((entry) => normalizeOptionalString(entry)).filter((entry) => Boolean(entry));
283
+ }
284
+ function normalizeOptionalString(value) {
285
+ if (typeof value !== "string")
286
+ return null;
287
+ const normalized = value.trim();
288
+ return normalized.length > 0 ? normalized : null;
289
+ }
290
+ function isSetValue(set, value) {
291
+ return typeof value === "string" && set.has(value);
292
+ }
293
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/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AAK,SAAS,EAC1B,CAAC;YACD,UAAU,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACjH,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED,SAAS,UAAU,CAAmB,GAAmB,EAAE,KAAc;IACvE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,GAAG,CAAC,KAAU,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@elench/testkit-protocol",
3
+ "version": "0.1.114",
4
+ "description": "Shared browser protocol for testkit bridge and extension consumers",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "dist/",
17
+ "package.json"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.build.json",
21
+ "clean": "rm -rf dist",
22
+ "typecheck": "tsc -p tsconfig.json --noEmit"
23
+ },
24
+ "private": false
25
+ }
@@ -1,17 +0,0 @@
1
- export declare const CC_BEL: number;
2
- export declare const CC_ESC: number;
3
- export declare const CC_BACKSLASH: number;
4
- export declare const CC_CSI: number;
5
- export declare const CC_OSC: number;
6
- export declare const CC_C1_ST: number;
7
- export declare const CC_0: number;
8
- export declare const CC_9: number;
9
- export declare const CC_SEMI: number;
10
- export declare const CC_M: number;
11
- export declare const ESCAPES: Set<number>;
12
- export declare const linkCodePrefix: string;
13
- export declare const linkCodePrefixCharCodes: number[];
14
- export declare const linkCodeSuffix = "\u0007";
15
- export declare const linkEndCode: string;
16
- export declare const linkEndCodeST: string;
17
- export declare const linkEndCodeC1ST: string;
@@ -1,28 +0,0 @@
1
- // Named ANSI control characters
2
- const BEL = "\x07";
3
- const ESC = "\x1b";
4
- const BACKSLASH = "\\";
5
- const CSI = "[";
6
- const OSC = "]";
7
- const C1_ST = "\x9c";
8
- // Char codes (derived from named characters)
9
- export const CC_BEL = BEL.charCodeAt(0);
10
- export const CC_ESC = ESC.charCodeAt(0);
11
- export const CC_BACKSLASH = BACKSLASH.charCodeAt(0);
12
- export const CC_CSI = CSI.charCodeAt(0);
13
- export const CC_OSC = OSC.charCodeAt(0);
14
- export const CC_C1_ST = C1_ST.charCodeAt(0);
15
- export const CC_0 = "0".charCodeAt(0);
16
- export const CC_9 = "9".charCodeAt(0);
17
- export const CC_SEMI = ";".charCodeAt(0);
18
- export const CC_M = "m".charCodeAt(0);
19
- // Escape code points
20
- export const ESCAPES = new Set([CC_ESC, 0x9b]); // \x1b and \x9b
21
- // OSC 8 hyperlink constants
22
- export const linkCodePrefix = `${ESC}${OSC}8;`;
23
- export const linkCodePrefixCharCodes = linkCodePrefix.split("").map((char) => char.charCodeAt(0));
24
- export const linkCodeSuffix = BEL;
25
- export const linkEndCode = `${ESC}${OSC}8;;${BEL}`;
26
- export const linkEndCodeST = `${ESC}${OSC}8;;${ESC}${BACKSLASH}`;
27
- export const linkEndCodeC1ST = `${ESC}${OSC}8;;${C1_ST}`;
28
- //# sourceMappingURL=consts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,GAAG,GAAG,GAAG,CAAC;AAChB,MAAM,GAAG,GAAG,GAAG,CAAC;AAChB,MAAM,KAAK,GAAG,MAAM,CAAC;AAErB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAEtC,qBAAqB;AACrB,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB;AAEhE,4BAA4B;AAC5B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAClG,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,EAAE,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,KAAK,EAAE,CAAC"}
@@ -1,9 +0,0 @@
1
- type AnimationContextValue = {
2
- readonly renderThrottleMs: number;
3
- readonly subscribe: (callback: (currentTime: number) => void, interval: number) => {
4
- readonly startTime: number;
5
- readonly unsubscribe: () => void;
6
- };
7
- };
8
- declare const animationContext: import("react").Context<AnimationContextValue>;
9
- export default animationContext;
@@ -1,13 +0,0 @@
1
- import { createContext } from 'react';
2
- const animationContext = createContext({
3
- renderThrottleMs: 0,
4
- subscribe() {
5
- return {
6
- startTime: 0,
7
- unsubscribe() { },
8
- };
9
- },
10
- });
11
- animationContext.displayName = 'InternalAnimationContext';
12
- export default animationContext;
13
- //# sourceMappingURL=AnimationContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AnimationContext.js","sourceRoot":"","sources":["../../src/components/AnimationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAapC,MAAM,gBAAgB,GAAG,aAAa,CAAwB;IAC7D,gBAAgB,EAAE,CAAC;IACnB,SAAS;QACR,OAAO;YACN,SAAS,EAAE,CAAC;YACZ,WAAW,KAAI,CAAC;SAChB,CAAC;IACH,CAAC;CACD,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,0BAA0B,CAAC;AAE1D,eAAe,gBAAgB,CAAC"}
@@ -1,49 +0,0 @@
1
- type Options = {
2
- /**
3
- Time between ticks in milliseconds.
4
-
5
- @default 100
6
- */
7
- readonly interval?: number;
8
- /**
9
- Whether the animation is running. When set to `false`, the animation stops. When toggled back to `true`, all values reset to `0`.
10
-
11
- @default true
12
- */
13
- readonly isActive?: boolean;
14
- };
15
- export type AnimationResult = {
16
- /**
17
- Discrete counter that increments by 1 each interval. Useful for indexed sequences like spinner frames.
18
- */
19
- readonly frame: number;
20
- /**
21
- Total elapsed time in milliseconds since the animation started or was last reset. Useful for continuous math-based animations like sine waves: `Math.sin(time / 1000 * Math.PI * 2)`.
22
- */
23
- readonly time: number;
24
- /**
25
- Time in milliseconds since the previous rendered tick. Accounts for throttled renders. Useful for physics-based or velocity-driven motion: `position += speed * delta`.
26
- */
27
- readonly delta: number;
28
- /**
29
- Resets `frame`, `time`, and `delta` to `0` and restarts timing from the current moment. Useful for one-shot animations triggered by events.
30
- */
31
- readonly reset: () => void;
32
- };
33
- /**
34
- A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function. All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
35
-
36
- @example
37
- ```
38
- import {Text, useAnimation} from 'ink';
39
-
40
- const Spinner = () => {
41
- const {frame} = useAnimation({interval: 80});
42
- const characters = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
43
-
44
- return <Text>{characters[frame % characters.length]}</Text>;
45
- };
46
- ```
47
- */
48
- export default function useAnimation(options?: Options): AnimationResult;
49
- export {};
@@ -1,87 +0,0 @@
1
- import { useState, useLayoutEffect, useRef, useCallback, useContext, } from 'react';
2
- import AnimationContext from '../components/AnimationContext.js';
3
- const defaultAnimationInterval = 100;
4
- const maximumTimerInterval = 2_147_483_647;
5
- const zeroAnimState = { frame: 0, time: 0, delta: 0 };
6
- /**
7
- A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function. All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
8
-
9
- @example
10
- ```
11
- import {Text, useAnimation} from 'ink';
12
-
13
- const Spinner = () => {
14
- const {frame} = useAnimation({interval: 80});
15
- const characters = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
16
-
17
- return <Text>{characters[frame % characters.length]}</Text>;
18
- };
19
- ```
20
- */
21
- export default function useAnimation(options) {
22
- const { interval = defaultAnimationInterval, isActive = true } = options ?? {};
23
- const safeInterval = normalizeAnimationInterval(interval);
24
- const { subscribe, renderThrottleMs } = useContext(AnimationContext);
25
- const [resetKey, setResetKey] = useState(0);
26
- const [animState, setAnimState] = useState(zeroAnimState);
27
- const nextRenderTimeRef = useRef(0);
28
- const lastRenderTimeRef = useRef(0);
29
- const previousOptionsRef = useRef({ isActive, safeInterval, resetKey });
30
- const previousOptions = previousOptionsRef.current;
31
- const shouldReset = isActive &&
32
- (safeInterval !== previousOptions.safeInterval ||
33
- !previousOptions.isActive ||
34
- resetKey !== previousOptions.resetKey);
35
- const reset = useCallback(() => {
36
- setResetKey(k => k + 1);
37
- }, []);
38
- useLayoutEffect(() => {
39
- if (!isActive) {
40
- return;
41
- }
42
- // Reset to zero immediately so any render that occurs between this
43
- // effect commit and the first tick shows zeros, not stale values.
44
- // On initial mount this is a no-op: Object.is bails out because the
45
- // state was initialized with the same zeroAnimState reference.
46
- setAnimState(zeroAnimState);
47
- let startTime = 0;
48
- const { startTime: subscriberStartTime, unsubscribe } = subscribe(currentTime => {
49
- const isThrottled = renderThrottleMs > 0 && currentTime < nextRenderTimeRef.current;
50
- if (isThrottled) {
51
- // Coalesce intermediate ticks while Ink is inside the current
52
- // render-throttle window; the next allowed render will jump
53
- // straight to the latest elapsed values.
54
- return;
55
- }
56
- const elapsed = currentTime - startTime;
57
- const nextDelta = currentTime - lastRenderTimeRef.current;
58
- lastRenderTimeRef.current = currentTime;
59
- nextRenderTimeRef.current = currentTime + renderThrottleMs;
60
- setAnimState({
61
- frame: Math.floor(elapsed / safeInterval),
62
- time: elapsed,
63
- delta: nextDelta,
64
- });
65
- }, safeInterval);
66
- // Use the scheduler's start time instead of sampling our own clock so the
67
- // first delivered tick cannot start one frame late.
68
- startTime = subscriberStartTime;
69
- lastRenderTimeRef.current = subscriberStartTime;
70
- nextRenderTimeRef.current = startTime + renderThrottleMs;
71
- return unsubscribe;
72
- }, [safeInterval, isActive, subscribe, renderThrottleMs, resetKey]);
73
- useLayoutEffect(() => {
74
- previousOptionsRef.current = { isActive, safeInterval, resetKey };
75
- }, [isActive, safeInterval, resetKey]);
76
- if (shouldReset) {
77
- return { ...zeroAnimState, reset };
78
- }
79
- return { ...animState, reset };
80
- }
81
- function normalizeAnimationInterval(interval) {
82
- if (!Number.isFinite(interval)) {
83
- return defaultAnimationInterval;
84
- }
85
- return Math.min(maximumTimerInterval, Math.max(1, interval));
86
- }
87
- //# sourceMappingURL=use-animation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-animation.js","sourceRoot":"","sources":["../../src/hooks/use-animation.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,eAAe,EACf,MAAM,EACN,WAAW,EACX,UAAU,GACV,MAAM,OAAO,CAAC;AACf,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AAEjE,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAC3C,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,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E,QAAQ,CAAC,CAAC,CAAC;IAEvC,IAAI,WAAW,EAAE,CAAC;QACjB,OAAO,EAAC,GAAG,aAAa,EAAE,KAAK,EAAC,CAAC;IAClC,CAAC;IAED,OAAO,EAAC,GAAG,SAAS,EAAE,KAAK,EAAC,CAAC;AAC9B,CAAC;AAED,SAAS,0BAA0B,CAAC,QAAgB;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChC,OAAO,wBAAwB,CAAC;IACjC,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9D,CAAC"}
@@ -1,59 +0,0 @@
1
- import { type RefObject } from 'react';
2
- import { type DOMElement } from '../dom.js';
3
- /**
4
- Metrics of a box element.
5
-
6
- All positions are relative to the element's parent.
7
- */
8
- export type BoxMetrics = {
9
- /**
10
- Element width.
11
- */
12
- readonly width: number;
13
- /**
14
- Element height.
15
- */
16
- readonly height: number;
17
- /**
18
- Distance from the left edge of the parent.
19
- */
20
- readonly left: number;
21
- /**
22
- Distance from the top edge of the parent.
23
- */
24
- readonly top: number;
25
- };
26
- export type UseBoxMetricsResult = BoxMetrics & {
27
- /**
28
- Whether the currently tracked element has been measured in the latest layout pass.
29
- */
30
- readonly hasMeasured: boolean;
31
- };
32
- /**
33
- A React hook that returns the current layout metrics for a tracked box element.
34
- It updates when layout changes (for example terminal resize, sibling/content changes, or position changes).
35
-
36
- The hook returns `{width: 0, height: 0, left: 0, top: 0}` until the first layout pass completes. It also returns zeros when the tracked ref is detached.
37
-
38
- Use `hasMeasured` to detect when the currently tracked element has been measured.
39
-
40
- @example
41
- ```tsx
42
- import {useRef} from 'react';
43
- import {Box, Text, useBoxMetrics} from 'ink';
44
-
45
- const Example = () => {
46
- const ref = useRef(null);
47
- const {width, height, left, top, hasMeasured} = useBoxMetrics(ref);
48
- return (
49
- <Box ref={ref}>
50
- <Text>
51
- {hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}
52
- </Text>
53
- </Box>
54
- );
55
- };
56
- ```
57
- */
58
- declare const useBoxMetrics: (ref: RefObject<DOMElement>) => UseBoxMetricsResult;
59
- export default useBoxMetrics;