@zaly/tui 0.0.4 → 0.0.5

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 (154) hide show
  1. package/dist/actions-CnVzKVID.d.mts +41 -0
  2. package/dist/actions-CnVzKVID.d.mts.map +1 -0
  3. package/dist/actions-DEIKF2ts.mjs +48 -0
  4. package/dist/actions-DEIKF2ts.mjs.map +1 -0
  5. package/dist/{box-DyaByEiG.mjs → box-DepqUtuo.mjs} +2 -2
  6. package/dist/{box-DyaByEiG.mjs.map → box-DepqUtuo.mjs.map} +1 -1
  7. package/dist/{builder-D49ECBEf.mjs → builder-T9oGIWFa.mjs} +2 -2
  8. package/dist/{builder-D49ECBEf.mjs.map → builder-T9oGIWFa.mjs.map} +1 -1
  9. package/dist/{callbacks-CNjGNxVw.mjs → callbacks-DcMBGQEO.mjs} +2 -2
  10. package/dist/{callbacks-CNjGNxVw.mjs.map → callbacks-DcMBGQEO.mjs.map} +1 -1
  11. package/dist/{client-D6C_uczF.mjs → client-BBdtbLp4.mjs} +5 -10
  12. package/dist/client-BBdtbLp4.mjs.map +1 -0
  13. package/dist/client-cIckDgAj.mjs +2 -0
  14. package/dist/clipboard-l_TWxxTf.mjs +404 -0
  15. package/dist/clipboard-l_TWxxTf.mjs.map +1 -0
  16. package/dist/clipboard.mjs +1 -403
  17. package/dist/ctx-Ctmvof1N.mjs +43 -0
  18. package/dist/ctx-Ctmvof1N.mjs.map +1 -0
  19. package/dist/ctx-DhJIKuOX.mjs +2 -0
  20. package/dist/divider-cclEAdPx.mjs +9 -0
  21. package/dist/divider-cclEAdPx.mjs.map +1 -0
  22. package/dist/files-Aw3iWpXD.d.mts +29 -0
  23. package/dist/files-Aw3iWpXD.d.mts.map +1 -0
  24. package/dist/files-BvThQpOf.mjs +42 -0
  25. package/dist/files-BvThQpOf.mjs.map +1 -0
  26. package/dist/github-Cy2hfWJ7.mjs +137 -0
  27. package/dist/github-Cy2hfWJ7.mjs.map +1 -0
  28. package/dist/github-DS00VoOj.d.mts +64 -0
  29. package/dist/github-DS00VoOj.d.mts.map +1 -0
  30. package/dist/image-BTxDPPiT.d.mts +37 -0
  31. package/dist/image-BTxDPPiT.d.mts.map +1 -0
  32. package/dist/index.mjs +6 -202
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/input-CRBuTrsL.mjs +497 -0
  35. package/dist/input-CRBuTrsL.mjs.map +1 -0
  36. package/dist/{inspect-D1d9t-ni.mjs → inspect-BaKG6cU_.mjs} +2 -2
  37. package/dist/{inspect-D1d9t-ni.mjs.map → inspect-BaKG6cU_.mjs.map} +1 -1
  38. package/dist/log-DYHEYX_z.mjs +130 -0
  39. package/dist/log-DYHEYX_z.mjs.map +1 -0
  40. package/dist/logger-Ch0LwSG_.mjs +71 -0
  41. package/dist/logger-Ch0LwSG_.mjs.map +1 -0
  42. package/dist/markdown-CYHHoYu0.mjs +124 -0
  43. package/dist/markdown-CYHHoYu0.mjs.map +1 -0
  44. package/dist/markdown.mjs +1 -1
  45. package/dist/overlay-9xNgsuuy.mjs +18 -0
  46. package/dist/overlay-9xNgsuuy.mjs.map +1 -0
  47. package/dist/{picker-ndVVt6qF.mjs → picker-cH-rc7-X.mjs} +5 -5
  48. package/dist/{picker-ndVVt6qF.mjs.map → picker-cH-rc7-X.mjs.map} +1 -1
  49. package/dist/queries-B_lOwEiE.mjs +200 -0
  50. package/dist/queries-B_lOwEiE.mjs.map +1 -0
  51. package/dist/{registry-U654j61Y.mjs → registry-CdeLjUo2.mjs} +2 -4
  52. package/dist/registry-CdeLjUo2.mjs.map +1 -0
  53. package/dist/render-CPUD4yaW.mjs +33 -0
  54. package/dist/render-CPUD4yaW.mjs.map +1 -0
  55. package/dist/{renderer-CxL4xbkl.mjs → renderer-DJ1pWXSL.mjs} +8 -7
  56. package/dist/{renderer-CxL4xbkl.mjs.map → renderer-DJ1pWXSL.mjs.map} +1 -1
  57. package/dist/renderer-Dgj_qEOA.mjs +2 -0
  58. package/dist/{renderer-CdLCkJB-.mjs → renderer-qSMVeNSV.mjs} +3 -5
  59. package/dist/{renderer-CdLCkJB-.mjs.map → renderer-qSMVeNSV.mjs.map} +1 -1
  60. package/dist/select-m7NE6Rwa.mjs +195 -0
  61. package/dist/select-m7NE6Rwa.mjs.map +1 -0
  62. package/dist/services/logger.mjs +1 -70
  63. package/dist/services/notifier.mjs +2 -2
  64. package/dist/services/picker.d.mts +1 -1
  65. package/dist/services/picker.mjs +6 -6
  66. package/dist/services/prompt.d.mts +1 -1
  67. package/dist/services/prompt.mjs +5 -5
  68. package/dist/shiki/server.d.mts +1 -0
  69. package/dist/shiki/server.mjs +129 -0
  70. package/dist/shiki/server.mjs.map +1 -0
  71. package/dist/{shiki-BrjVUkeh.mjs → shiki-B5NwIiot.mjs} +5 -10
  72. package/dist/shiki-B5NwIiot.mjs.map +1 -0
  73. package/dist/shiki-BK-v9CtF.mjs +12 -0
  74. package/dist/shiki-BK-v9CtF.mjs.map +1 -0
  75. package/dist/show-DR2x1YFc.mjs +85 -0
  76. package/dist/show-DR2x1YFc.mjs.map +1 -0
  77. package/dist/style.mjs +2 -2
  78. package/dist/text-9lwQeqYr.d.mts +33 -0
  79. package/dist/text-9lwQeqYr.d.mts.map +1 -0
  80. package/dist/text-DILrol9j.mjs +32 -0
  81. package/dist/text-DILrol9j.mjs.map +1 -0
  82. package/dist/text-q26V6_Sc.mjs +111 -0
  83. package/dist/text-q26V6_Sc.mjs.map +1 -0
  84. package/dist/text.d.mts +2 -33
  85. package/dist/text.mjs +1 -110
  86. package/dist/themes.mjs +1 -1
  87. package/dist/tree-Bo1afYhe.mjs +73 -0
  88. package/dist/tree-Bo1afYhe.mjs.map +1 -0
  89. package/dist/widget-BkMwhY2p.mjs +40 -0
  90. package/dist/widget-BkMwhY2p.mjs.map +1 -0
  91. package/dist/widget-M7jD8Rgg.d.mts +49 -0
  92. package/dist/widget-M7jD8Rgg.d.mts.map +1 -0
  93. package/dist/widgets/autocomplete.mjs +2 -2
  94. package/dist/widgets/box.mjs +1 -1
  95. package/dist/widgets/code.mjs +7 -7
  96. package/dist/widgets/completions/actions.d.mts +2 -41
  97. package/dist/widgets/completions/actions.mjs +1 -47
  98. package/dist/widgets/completions/files.d.mts +2 -29
  99. package/dist/widgets/completions/files.mjs +1 -41
  100. package/dist/widgets/completions/github.d.mts +2 -64
  101. package/dist/widgets/completions/github.mjs +1 -136
  102. package/dist/widgets/completions/index.d.mts +3 -3
  103. package/dist/widgets/completions/index.mjs +3 -3
  104. package/dist/widgets/diff.d.mts +1 -1
  105. package/dist/widgets/diff.mjs +3 -3
  106. package/dist/widgets/divider.mjs +1 -8
  107. package/dist/widgets/image.d.mts +2 -37
  108. package/dist/widgets/image.mjs +1 -1
  109. package/dist/widgets/input.mjs +1 -496
  110. package/dist/widgets/log.mjs +1 -129
  111. package/dist/widgets/markdown.d.mts +2 -2
  112. package/dist/widgets/markdown.mjs +1 -123
  113. package/dist/widgets/overlay.mjs +1 -17
  114. package/dist/widgets/picker.mjs +1 -1
  115. package/dist/widgets/select.mjs +1 -194
  116. package/dist/widgets/show.mjs +1 -84
  117. package/dist/widgets/text.mjs +1 -31
  118. package/dist/widgets/tree.mjs +1 -72
  119. package/dist/widgets/widget.d.mts +2 -49
  120. package/dist/widgets/widget.mjs +1 -39
  121. package/dist/worker-BvRm4OsW.mjs +2 -0
  122. package/dist/worker-T6SdPzUH.mjs +52 -0
  123. package/dist/worker-T6SdPzUH.mjs.map +1 -0
  124. package/package.json +5 -1
  125. package/dist/client-D6C_uczF.mjs.map +0 -1
  126. package/dist/clipboard.mjs.map +0 -1
  127. package/dist/registry-U654j61Y.mjs.map +0 -1
  128. package/dist/render-DxVLqqB9.mjs +0 -74
  129. package/dist/render-DxVLqqB9.mjs.map +0 -1
  130. package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
  131. package/dist/services/logger.mjs.map +0 -1
  132. package/dist/shiki-BrjVUkeh.mjs.map +0 -1
  133. package/dist/text.d.mts.map +0 -1
  134. package/dist/text.mjs.map +0 -1
  135. package/dist/widgets/completions/actions.d.mts.map +0 -1
  136. package/dist/widgets/completions/actions.mjs.map +0 -1
  137. package/dist/widgets/completions/files.d.mts.map +0 -1
  138. package/dist/widgets/completions/files.mjs.map +0 -1
  139. package/dist/widgets/completions/github.d.mts.map +0 -1
  140. package/dist/widgets/completions/github.mjs.map +0 -1
  141. package/dist/widgets/divider.mjs.map +0 -1
  142. package/dist/widgets/image.d.mts.map +0 -1
  143. package/dist/widgets/input.mjs.map +0 -1
  144. package/dist/widgets/log.mjs.map +0 -1
  145. package/dist/widgets/markdown.mjs.map +0 -1
  146. package/dist/widgets/overlay.mjs.map +0 -1
  147. package/dist/widgets/select.mjs.map +0 -1
  148. package/dist/widgets/show.mjs.map +0 -1
  149. package/dist/widgets/text.mjs.map +0 -1
  150. package/dist/widgets/tree.mjs.map +0 -1
  151. package/dist/widgets/widget.d.mts.map +0 -1
  152. package/dist/widgets/widget.mjs.map +0 -1
  153. package/dist/worker-DjHuQSbY.mjs +0 -27
  154. package/dist/worker-DjHuQSbY.mjs.map +0 -1
@@ -0,0 +1,49 @@
1
+ import { p as Node } from "./queries-DH3bj74K.mjs";
2
+ //#region src/widgets/widget.d.ts
3
+ type Props = Record<string, unknown>;
4
+ /**
5
+ * A widget factory: takes some args, returns a `Node`.
6
+ *
7
+ * The default `A = never[]` makes the *bare* `Widget` the universal
8
+ * "any widget" type — the `(...args: never[]) => Node` idiom. Every
9
+ * concrete factory (zero-arg, `state + ...children`, single-props) is
10
+ * assignable to it, so it works both as the `widget()` constraint and
11
+ * as a stored value type (`details?: Widget`, invoked zero-arg). Supply
12
+ * `A` explicitly for a precise signature: `Widget<[State<LogState>]>`.
13
+ */
14
+ type Widget<A extends unknown[] = never[], N extends Node = Node> = (...args: A) => N;
15
+ /**
16
+ * Type helper for declaring widgets — runtime identity, just `return fn`.
17
+ *
18
+ * Three things it earns:
19
+ * 1. Inference at the declaration site: TS infers `S` from the function
20
+ * parameter and enforces it on every call site.
21
+ * 2. A consistent grep target: every component reads as
22
+ * `export const foo = widget((props) => …)`.
23
+ * 3. A future seam for instrumentation, lifecycle wrappers, devtools.
24
+ *
25
+ * The factory body runs **once** at construction. Reactive content lives
26
+ * in leaf thunks (`text(({ style }) => …)`), not by re-running the body
27
+ * — this is the Solid model, not React's. `ctx` is therefore unavailable
28
+ * inside the factory; reach for it inside leaf thunks where it belongs.
29
+ *
30
+ * ```ts
31
+ * const status = widget((props: { level: "ok" | "warn"; msg: string }) =>
32
+ * text(({ style }) => `${style.bold[props.level]("●")} ${style.dim(props.msg)}`),
33
+ * )
34
+ *
35
+ * status({ level: "ok", msg: "all systems nominal" })
36
+ * ```
37
+ */
38
+ /**
39
+ * Call-site args derived from `S`:
40
+ * - If `S` declares `children`, `children` is injected from rest args;
41
+ * state at the call site has `children` omitted, then `...children`.
42
+ * - Otherwise, no rest is allowed.
43
+ * - Either way, the state arg is optional when every field of the
44
+ * resolved state is optional (so bare `widget()` works).
45
+ */
46
+ declare function widget<T extends Widget>(fn: T): T;
47
+ //#endregion
48
+ export { Widget as n, widget as r, Props as t };
49
+ //# sourceMappingURL=widget-M7jD8Rgg.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-M7jD8Rgg.d.mts","names":[],"sources":["../src/widgets/widget.ts"],"mappings":";;KAIY,QAAQ;;;;;;;;;;;KAYR,OAAO,+BAA+B,UAAU,OAAO,YAAY,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkC3E,OAAO,UAAU,QAAQ,IAAI,IAAI"}
@@ -1,7 +1,7 @@
1
1
  import { S as unwrap, f as effect, h as memo, y as signal } from "../reactive-f7NpAi69.mjs";
2
2
  import { t as Node } from "../node-BZ7f6HzU.mjs";
3
- import { t as picker } from "../picker-ndVVt6qF.mjs";
4
- import { Input } from "./input.mjs";
3
+ import { t as picker } from "../picker-cH-rc7-X.mjs";
4
+ import { t as Input } from "../input-CRBuTrsL.mjs";
5
5
  //#region src/widgets/autocomplete.ts
6
6
  /**
7
7
  * Autocomplete popup bound to an `Input`. Watches the input's value and
@@ -1,2 +1,2 @@
1
- import { n as box, t as Box } from "../box-DyaByEiG.mjs";
1
+ import { n as box, t as Box } from "../box-DepqUtuo.mjs";
2
2
  export { Box, box };
@@ -1,11 +1,11 @@
1
1
  import { S as unwrap, h as memo, r as createAsync, w as useContext } from "../reactive-f7NpAi69.mjs";
2
- import { n as box } from "../box-DyaByEiG.mjs";
3
- import { formatLines } from "../text.mjs";
4
- import { text } from "./text.mjs";
5
- import { t as RenderContext } from "../render-DxVLqqB9.mjs";
6
- import { t as codeToAnsi } from "../shiki-BrjVUkeh.mjs";
7
- import { widget } from "./widget.mjs";
8
- import { show } from "./show.mjs";
2
+ import { n as box } from "../box-DepqUtuo.mjs";
3
+ import { a as formatLines } from "../text-q26V6_Sc.mjs";
4
+ import { n as text } from "../text-DILrol9j.mjs";
5
+ import { t as RenderContext } from "../render-CPUD4yaW.mjs";
6
+ import { t as codeToAnsi } from "../shiki-BK-v9CtF.mjs";
7
+ import { t as widget } from "../widget-BkMwhY2p.mjs";
8
+ import { t as show } from "../show-DR2x1YFc.mjs";
9
9
  import { extname } from "pathe";
10
10
  //#region src/widgets/code.ts
11
11
  /**
@@ -1,41 +1,2 @@
1
- import { Bt as Actions, It as ActionDef } from "../../queries-DH3bj74K.mjs";
2
- import { n as PickerItem } from "../../picker-D8OLb6kZ.mjs";
3
- import { o as CompletionSource } from "../../autocomplete-Dfw-yQDa.mjs";
4
- //#region src/widgets/completions/actions.d.ts
5
- /** Completion item produced by `actionsSource`. Carries the full
6
- * `ActionInfo` plus the action `id` so the source's `accept` can
7
- * dispatch without a secondary lookup. Items match the `MenuItem`
8
- * contract loosely via the overlapping `name`/... shape. */
9
- type ActionCompletionItem = ActionDef & PickerItem & {
10
- id: string;
11
- score: number;
12
- };
13
- interface ActionsSourceOptions {
14
- /** Registry to read from. Usually `renderer.actions`. */
15
- actions: Actions;
16
- /** Trigger regex. Default: `/^\s*\//` (slash at start of line). */
17
- trigger?: RegExp;
18
- /** Keep predicate. Default skips `info.hidden`. Return `false` to
19
- * drop the entry from the completion list. */
20
- filter?: (id: string, info: ActionDef) => boolean;
21
- }
22
- /**
23
- * Completion source backed by the `Actions` registry — typical slash
24
- * command ergonomics. Items are raw `ActionInfo` objects augmented
25
- * with their `id`; `accept` dispatches the action through the registry
26
- * and clears the trigger+query range, so the user's typed `/foo` is
27
- * removed once the action fires (no stale text left in the input).
28
- *
29
- * ```ts
30
- * autocomplete({
31
- * input: "chat-input",
32
- * sources: {
33
- * slash: actionsSource({ actions: renderer.actions }),
34
- * },
35
- * })
36
- * ```
37
- */
38
- declare function actionsSource(opts: ActionsSourceOptions): CompletionSource<ActionCompletionItem>;
39
- //#endregion
40
- export { ActionCompletionItem, ActionsSourceOptions, actionsSource };
41
- //# sourceMappingURL=actions.d.mts.map
1
+ import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions-CnVzKVID.mjs";
2
+ export { ActionCompletionItem, ActionsSourceOptions, actionsSource };
@@ -1,48 +1,2 @@
1
- //#region src/widgets/completions/actions.ts
2
- /**
3
- * Completion source backed by the `Actions` registry — typical slash
4
- * command ergonomics. Items are raw `ActionInfo` objects augmented
5
- * with their `id`; `accept` dispatches the action through the registry
6
- * and clears the trigger+query range, so the user's typed `/foo` is
7
- * removed once the action fires (no stale text left in the input).
8
- *
9
- * ```ts
10
- * autocomplete({
11
- * input: "chat-input",
12
- * sources: {
13
- * slash: actionsSource({ actions: renderer.actions }),
14
- * },
15
- * })
16
- * ```
17
- */
18
- function actionsSource(opts) {
19
- const trigger = opts.trigger ?? /^\//;
20
- const filter = opts.filter ?? ((_id, info) => !info.hidden && !!info.cmd);
21
- return {
22
- accept(item) {
23
- opts.actions.dispatch(item.id, { source: "autocomplete" });
24
- },
25
- complete(_query, match) {
26
- const out = [];
27
- for (const info of opts.actions.list()) {
28
- if (!filter(info.id, info)) continue;
29
- const name = info.cmd ?? info.id;
30
- const score = match(name);
31
- if (!score) continue;
32
- out.push({
33
- ...info,
34
- id: info.id,
35
- name,
36
- score,
37
- text: name
38
- });
39
- }
40
- return out;
41
- },
42
- triggers: [trigger]
43
- };
44
- }
45
- //#endregion
1
+ import { t as actionsSource } from "../../actions-DEIKF2ts.mjs";
46
2
  export { actionsSource };
47
-
48
- //# sourceMappingURL=actions.mjs.map
@@ -1,29 +1,2 @@
1
- import { n as PickerItem } from "../../picker-D8OLb6kZ.mjs";
2
- import { o as CompletionSource } from "../../autocomplete-Dfw-yQDa.mjs";
3
- import { FindOptions } from "@zaly/shared/find";
4
- //#region src/widgets/completions/files.d.ts
5
- interface FilesSourceOptions extends FindOptions {
6
- /** Base directory relative queries resolve against. Default:
7
- * `process.cwd()`. */
8
- cwd?: string;
9
- /** Trigger regex. Default: `/(?<=^|\s)@/` — `@` preceded by start-of-
10
- * string or whitespace. Lookbehind keeps `match.start` on the `@`
11
- * itself so the leading space isn't eaten on insertion. */
12
- trigger?: RegExp;
13
- /** Prefix prepended to accepted values so the trigger character stays
14
- * in the input after a pick (letting users keep typing to drill into
15
- * subdirectories). Default: `"@"` — matches the default trigger.
16
- * When customizing `trigger`, set this to the character your trigger
17
- * represents. */
18
- prefix?: string;
19
- refreshInterval?: number;
20
- }
21
- type File = PickerItem & {
22
- file: string;
23
- };
24
- /** Completion source for files. Uses `@zaly/shared/find` under the hood, so
25
- * supports all the same options and respects .gitignore by default. */
26
- declare function filesSource(opts?: FilesSourceOptions): CompletionSource<File>;
27
- //#endregion
28
- export { FilesSourceOptions, filesSource };
29
- //# sourceMappingURL=files.d.mts.map
1
+ import { n as filesSource, t as FilesSourceOptions } from "../../files-Aw3iWpXD.mjs";
2
+ export { FilesSourceOptions, filesSource };
@@ -1,42 +1,2 @@
1
- import { a as createIterable, y as signal } from "../../reactive-f7NpAi69.mjs";
2
- import { normPath } from "@zaly/shared";
3
- //#region src/widgets/completions/files.ts
4
- /** Completion source for files. Uses `@zaly/shared/find` under the hood, so
5
- * supports all the same options and respects .gitignore by default. */
6
- function filesSource(opts = {}) {
7
- const cwd = normPath(opts.cwd);
8
- const trigger = opts.trigger ?? /(?<=^|\s)@/;
9
- const prefix = opts.prefix ?? "@";
10
- let results;
11
- const [gen, setGen] = signal(0);
12
- let lastRefresh = 0;
13
- return {
14
- accept: (item) => {
15
- const v = item.file;
16
- return `${prefix}${v}${v.endsWith("/") ? "" : " "}`;
17
- },
18
- get complete() {
19
- const now = performance.now();
20
- if (!results?.loading() && now - lastRefresh > (opts.refreshInterval ?? 1e4)) {
21
- setGen((g) => g + 1);
22
- lastRefresh = now;
23
- }
24
- return results ??= createIterable(async function* iterFiles() {
25
- gen();
26
- const { find } = await import("@zaly/shared/find");
27
- for await (const f of find({
28
- ...opts,
29
- cwd
30
- })) yield (Array.isArray(f) ? f : [f]).map((file) => ({
31
- file,
32
- text: file
33
- }));
34
- });
35
- },
36
- triggers: [trigger]
37
- };
38
- }
39
- //#endregion
1
+ import { t as filesSource } from "../../files-BvThQpOf.mjs";
40
2
  export { filesSource };
41
-
42
- //# sourceMappingURL=files.mjs.map
@@ -1,64 +1,2 @@
1
- import { n as PickerItem } from "../../picker-D8OLb6kZ.mjs";
2
- import { o as CompletionSource } from "../../autocomplete-Dfw-yQDa.mjs";
3
- //#region src/widgets/completions/github.d.ts
4
- /** A GitHub issue or pull request returned by `githubSource`. Shape
5
- * mirrors the `gh` CLI's `--json number,title,state,author,url`
6
- * output, with `type` added to distinguish issues from PRs. */
7
- type GithubItem = PickerItem & {
8
- number: number;
9
- title: string;
10
- /** `"open"` / `"closed"` for issues; `"open"` / `"closed"` / `"merged"`
11
- * for PRs. Kept as a string so we don't trip if gh evolves. */
12
- state: string;
13
- type: "issue" | "pr";
14
- url: string;
15
- author?: {
16
- login?: string;
17
- };
18
- };
19
- type GithubState = "open" | "closed" | "all";
20
- type GithubFetcher = (cwd: string, state: GithubState) => Promise<GithubItem[]>;
21
- interface GithubSourceOptions {
22
- /** Working directory used to locate the repo. `gh` resolves the repo
23
- * from the git remote of this dir. Default: `process.cwd()`. */
24
- cwd?: string;
25
- /** Trigger regex. Default: `/(?<=^|\s)#/` — `#` preceded by start-of-
26
- * string or whitespace (same lookbehind trick as `filesSource`). */
27
- trigger?: RegExp;
28
- /** Prepended to the accepted value so the trigger character stays in
29
- * the input. Default: `"#"`. */
30
- prefix?: string;
31
- /** Which issues / PRs to include. Default: `"open"`. */
32
- state?: GithubState;
33
- /** Per-kind cap passed to `gh`. Default: `50`. */
34
- limit?: number;
35
- /** Override the fetch implementation. Mainly useful for tests — the
36
- * default shells out to `gh`. The fetcher is called at most once per
37
- * `githubSource` instance; results are cached thereafter. */
38
- fetcher?: GithubFetcher;
39
- }
40
- /**
41
- * Completion source for GitHub issues and pull requests from the repo
42
- * at `cwd`. Shells out to the `gh` CLI on first use, caches the result,
43
- * and fuzzy-filters locally on subsequent calls so typing stays snappy.
44
- *
45
- * Accepts insert `#123 ` into the input — ready for a markdown-style
46
- * reference in a chat message or commit subject.
47
- *
48
- * ```ts
49
- * autocomplete({
50
- * input: "chat-input",
51
- * sources: {
52
- * gh: githubSource(),
53
- * },
54
- * })
55
- * ```
56
- *
57
- * Silently returns no items when `gh` isn't installed, the user isn't
58
- * authenticated, or the directory isn't a GitHub repo — so it's safe
59
- * to wire up unconditionally.
60
- */
61
- declare function githubSource(opts?: GithubSourceOptions): CompletionSource<GithubItem>;
62
- //#endregion
63
- export { GithubFetcher, GithubItem, GithubSourceOptions, GithubState, githubSource };
64
- //# sourceMappingURL=github.d.mts.map
1
+ import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-DS00VoOj.mjs";
2
+ export { GithubFetcher, GithubItem, GithubSourceOptions, GithubState, githubSource };
@@ -1,137 +1,2 @@
1
- import { stringWidth } from "@zaly/shared/ansi";
2
- import { spawn } from "node:child_process";
3
- //#region src/widgets/completions/github.ts
4
- /**
5
- * Completion source for GitHub issues and pull requests from the repo
6
- * at `cwd`. Shells out to the `gh` CLI on first use, caches the result,
7
- * and fuzzy-filters locally on subsequent calls so typing stays snappy.
8
- *
9
- * Accepts insert `#123 ` into the input — ready for a markdown-style
10
- * reference in a chat message or commit subject.
11
- *
12
- * ```ts
13
- * autocomplete({
14
- * input: "chat-input",
15
- * sources: {
16
- * gh: githubSource(),
17
- * },
18
- * })
19
- * ```
20
- *
21
- * Silently returns no items when `gh` isn't installed, the user isn't
22
- * authenticated, or the directory isn't a GitHub repo — so it's safe
23
- * to wire up unconditionally.
24
- */
25
- function githubSource(opts = {}) {
26
- const cwd = opts.cwd ?? process.cwd();
27
- const trigger = opts.trigger ?? /(?<=^|\s)#/;
28
- const prefix = opts.prefix ?? "#";
29
- const state = opts.state ?? "open";
30
- const limit = opts.limit ?? 50;
31
- const fetcher = opts.fetcher ?? defaultFetcher(limit);
32
- let cache;
33
- return {
34
- accept: (item) => `${prefix}${item.number} `,
35
- async complete(_query, match) {
36
- cache ??= fetcher(cwd, state).catch(() => []);
37
- const items = await cache;
38
- const out = [];
39
- for (const item of items) {
40
- const score = match(`#${item.number} ${item.title}`);
41
- if (!score) continue;
42
- out.push({
43
- ...item,
44
- score
45
- });
46
- }
47
- return out;
48
- },
49
- render: defaultRender,
50
- triggers: [trigger]
51
- };
52
- }
53
- const defaultRender = (item, ctx) => {
54
- const { style } = ctx;
55
- const num = `#${item.number}`;
56
- const stateSlot = stateStyleSlot(item.state);
57
- const typeLabel = item.type === "pr" ? "pr" : "issue";
58
- const author = item.author?.login ? `@${item.author.login}` : "";
59
- const lead = `${style.add("optionName")(num)} ${style.add(stateSlot)(`${item.state}·${typeLabel}`)} ${item.title}`;
60
- if (author === "") return lead;
61
- const gap = 2;
62
- const leadW = stringWidth(lead);
63
- const hintW = stringWidth(author);
64
- const padded = ctx.width - leadW - hintW - gap;
65
- if (padded < 1) return lead;
66
- return lead + " ".repeat(padded + gap) + style.add("optionDesc")(author);
67
- };
68
- function stateStyleSlot(state) {
69
- if (state === "open") return "success";
70
- if (state === "merged") return "accent";
71
- return "muted";
72
- }
73
- /** Default fetcher — shells out to `gh issue list` + `gh pr list` in
74
- * parallel. Either failing is swallowed so a repo with only issues
75
- * (or only PRs) still works. */
76
- function defaultFetcher(limit) {
77
- const fields = "number,title,state,author,url";
78
- return async (cwd, state) => {
79
- const [issues, prs] = await Promise.all([runGh(cwd, [
80
- "issue",
81
- "list",
82
- "--state",
83
- state,
84
- "--json",
85
- fields,
86
- "--limit",
87
- String(limit)
88
- ]), runGh(cwd, [
89
- "pr",
90
- "list",
91
- "--state",
92
- state,
93
- "--json",
94
- fields,
95
- "--limit",
96
- String(limit)
97
- ])]);
98
- return [...parse(issues).map((x) => Object.assign(x, { type: "issue" })), ...parse(prs).map((x) => Object.assign(x, { type: "pr" }))].map((item) => Object.assign(item, { text: `#${item.number} ${item.title}` }));
99
- };
100
- }
101
- function parse(out) {
102
- try {
103
- return JSON.parse(out);
104
- } catch {
105
- return [];
106
- }
107
- }
108
- function runGh(cwd, args) {
109
- return new Promise((resolve) => {
110
- try {
111
- const child = spawn("gh", args, {
112
- cwd,
113
- stdio: [
114
- "ignore",
115
- "pipe",
116
- "ignore"
117
- ]
118
- });
119
- let stdout = "";
120
- child.stdout.on("data", (chunk) => {
121
- stdout += chunk.toString("utf8");
122
- });
123
- child.on("close", (code) => {
124
- resolve(code === 0 ? stdout : "");
125
- });
126
- child.on("error", () => {
127
- resolve("");
128
- });
129
- } catch {
130
- resolve("");
131
- }
132
- });
133
- }
134
- //#endregion
1
+ import { t as githubSource } from "../../github-Cy2hfWJ7.mjs";
135
2
  export { githubSource };
136
-
137
- //# sourceMappingURL=github.mjs.map
@@ -1,4 +1,4 @@
1
- import { ActionCompletionItem, ActionsSourceOptions, actionsSource } from "./actions.mjs";
2
- import { FilesSourceOptions, filesSource } from "./files.mjs";
3
- import { GithubFetcher, GithubItem, GithubSourceOptions, GithubState, githubSource } from "./github.mjs";
1
+ import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions-CnVzKVID.mjs";
2
+ import { n as filesSource, t as FilesSourceOptions } from "../../files-Aw3iWpXD.mjs";
3
+ import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-DS00VoOj.mjs";
4
4
  export { ActionCompletionItem, ActionsSourceOptions, FilesSourceOptions, GithubFetcher, GithubItem, GithubSourceOptions, GithubState, actionsSource, filesSource, githubSource };
@@ -1,4 +1,4 @@
1
- import { actionsSource } from "./actions.mjs";
2
- import { filesSource } from "./files.mjs";
3
- import { githubSource } from "./github.mjs";
1
+ import { t as actionsSource } from "../../actions-DEIKF2ts.mjs";
2
+ import { t as filesSource } from "../../files-BvThQpOf.mjs";
3
+ import { t as githubSource } from "../../github-Cy2hfWJ7.mjs";
4
4
  export { actionsSource, filesSource, githubSource };
@@ -1,5 +1,5 @@
1
1
  import { J as Layout, P as RenderCtx, X as State, nt as Reactive, p as Node } from "../queries-DH3bj74K.mjs";
2
- import { WrapMode } from "../text.mjs";
2
+ import { t as WrapMode } from "../text-9lwQeqYr.mjs";
3
3
  //#region src/widgets/diff.d.ts
4
4
  interface DiffState {
5
5
  /** Pre-state file content. Plain string or reactive accessor —
@@ -1,8 +1,8 @@
1
1
  import { S as unwrap, h as memo, r as createAsync, w as useContext } from "../reactive-f7NpAi69.mjs";
2
2
  import { t as Node } from "../node-BZ7f6HzU.mjs";
3
- import { calcLayout, countLines } from "../text.mjs";
4
- import { t as RenderContext } from "../render-DxVLqqB9.mjs";
5
- import { t as codeToAnsi } from "../shiki-BrjVUkeh.mjs";
3
+ import { r as countLines, t as calcLayout } from "../text-q26V6_Sc.mjs";
4
+ import { t as RenderContext } from "../render-CPUD4yaW.mjs";
5
+ import { t as codeToAnsi } from "../shiki-BK-v9CtF.mjs";
6
6
  import { splitAnsi, stringWidth, wrapAnsi } from "@zaly/shared/ansi";
7
7
  import { basename, extname } from "pathe";
8
8
  //#region src/widgets/diff.ts
@@ -1,9 +1,2 @@
1
- import { text } from "./text.mjs";
2
- //#region src/widgets/divider.ts
3
- function divider(state = { style: "divider" }) {
4
- return text((ctx) => (state.char ?? "─").repeat(state.length ?? ctx.width), state);
5
- }
6
- //#endregion
1
+ import { t as divider } from "../divider-cclEAdPx.mjs";
7
2
  export { divider };
8
-
9
- //# sourceMappingURL=divider.mjs.map
@@ -1,37 +1,2 @@
1
- import { J as Layout, P as RenderCtx, p as Node } from "../queries-DH3bj74K.mjs";
2
- //#region src/widgets/image.d.ts
3
- interface ImageState {
4
- /**
5
- * Path to an image file. PNG passes through with zero decoding; other
6
- * formats (JPEG/WebP/GIF/AVIF/SVG) are read via image-meta for
7
- * dimensions and — for KGP terminals — converted once to a cached
8
- * temp PNG via sharp. iTerm2 accepts all formats natively.
9
- */
10
- src: string;
11
- /** Display width in terminal cells. Defaults to `ctx.width`. */
12
- width?: number;
13
- /**
14
- * Display height in terminal cells. When omitted, computed from the
15
- * source aspect ratio + `cellAspect`.
16
- */
17
- height?: number;
18
- /** Fallback text shown on terminals without an image protocol. */
19
- alt?: string;
20
- /**
21
- * Character cell aspect ratio (cellHeight / cellWidth). Most terminals
22
- * land around 2.0. Tweak if aspect-preserved images look stretched.
23
- */
24
- cellAspect?: number;
25
- }
26
- declare class Image extends Node<ImageState> {
27
- #private;
28
- constructor(state: ImageState);
29
- get fallback(): string[];
30
- layout(): Layout;
31
- protected _render(ctx: RenderCtx): Promise<string[]>;
32
- }
33
- declare function image(src: string, style?: Omit<ImageState, "src">): Image;
34
- declare function image(state: ImageState): Image;
35
- //#endregion
36
- export { Image, ImageState, image };
37
- //# sourceMappingURL=image.d.mts.map
1
+ import { n as ImageState, r as image, t as Image } from "../image-BTxDPPiT.mjs";
2
+ export { Image, ImageState, image };
@@ -1,6 +1,6 @@
1
1
  import { S as unwrap, w as useContext } from "../reactive-f7NpAi69.mjs";
2
2
  import { t as Node } from "../node-BZ7f6HzU.mjs";
3
- import { t as RenderContext } from "../render-DxVLqqB9.mjs";
3
+ import { t as RenderContext } from "../render-CPUD4yaW.mjs";
4
4
  import { s as loadKittyGraphics } from "../kitty-JbCJC0iQ.mjs";
5
5
  import { fileDetect } from "@zaly/shared/detect";
6
6
  import { imageInfo } from "@zaly/shared/image";