@openviking/react 0.1.8-beta.11.1.gc6def608a25e → 0.1.8-beta.12.1.g83d24ca4fc6f

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/dist/3c~0.js CHANGED
@@ -621,8 +621,8 @@ function useTuiComposerKeyboard({ inputRef, value, history, completion, inline,
621
621
  handleKeyDown
622
622
  };
623
623
  }
624
- const TUI_URI_PATTERN = /viking:\/\/[^\s"'<>`]+/g;
625
- const TUI_PROSE_URI_PATTERN = /viking:\/\/[^\s,,。;;、"'<>()[\]]+/g;
624
+ const TUI_URI_PATTERN = /(?:viking|https?):\/\/[^\s"'<>`]+/g;
625
+ const TUI_PROSE_URI_PATTERN = /(?:viking|https?):\/\/[^\s,,。;;、"'<>()[\]]+/g;
626
626
  function getTuiSafeHref(uri) {
627
627
  const href = uri?.trim();
628
628
  return href && /^(?:viking|https?):\/\/[^\s]+$/i.test(href) ? href : void 0;
@@ -921,14 +921,24 @@ function TuiComposer({ anchorRef, assistId, onFocus, onDismiss, onRequestPalette
921
921
  ]
922
922
  });
923
923
  }
924
- function pickTuiCommands(names = [], commands) {
924
+ function pickTuiCommands(shortcuts = [], commands) {
925
925
  const byName = new Map(commands.map((command)=>[
926
926
  command.name,
927
927
  command
928
928
  ]));
929
+ const firstByName = new Map();
930
+ for (const shortcut of shortcuts)if (!firstByName.has(shortcut.name)) firstByName.set(shortcut.name, shortcut);
929
931
  return [
930
- ...new Set(names)
931
- ].flatMap((name)=>byName.get(name) ?? []);
932
+ ...firstByName.values()
933
+ ].flatMap((shortcut)=>{
934
+ const command = byName.get(shortcut.name);
935
+ return command ? [
936
+ {
937
+ ...command,
938
+ value: shortcut.value
939
+ }
940
+ ] : [];
941
+ });
932
942
  }
933
943
  function TuiEmptyRegion({ emptyState, commands, labels, disabled, onPick }) {
934
944
  if (void 0 !== emptyState) return null === emptyState ? null : /*#__PURE__*/ jsx("div", {
@@ -959,7 +969,7 @@ function TuiEmptyRegion({ emptyState, commands, labels, disabled, onPick }) {
959
969
  type: "button",
960
970
  className: "ov-tui__empty-action",
961
971
  disabled: disabled,
962
- onClick: ()=>onPick(command),
972
+ onClick: ()=>onPick(command.value),
963
973
  children: [
964
974
  /*#__PURE__*/ jsx(ArrowRightIcon, {
965
975
  width: 14,
@@ -2117,13 +2127,14 @@ function Tui({ records, value, disabled = false, emptyState, quickCommands, loca
2117
2127
  onValueChange?.(next);
2118
2128
  };
2119
2129
  const readOnly = !onValueChange;
2120
- const fillCommand = (next)=>{
2130
+ const fillInput = (next)=>{
2121
2131
  if (disabled || readOnly) return;
2122
- updateValue(formatTuiCommandInput(next, commands));
2132
+ updateValue(next);
2123
2133
  composerRef.current?.querySelector('textarea')?.focus({
2124
2134
  preventScroll: true
2125
2135
  });
2126
2136
  };
2137
+ const fillCommand = (next)=>fillInput(formatTuiCommandInput(next, commands));
2127
2138
  const completion = useTuiCompletion(value, !disabled && !readOnly && dismissedValue !== value, commands, commandGroups, paletteScope);
2128
2139
  const queryKey = value;
2129
2140
  const activeIndex = selection.queryKey === queryKey && selection.index < completion.options.length ? selection.index : -1;
@@ -2171,7 +2182,7 @@ function Tui({ records, value, disabled = false, emptyState, quickCommands, loca
2171
2182
  commands: pickTuiCommands(quickCommands, commands),
2172
2183
  labels: text,
2173
2184
  disabled: disabled || readOnly,
2174
- onPick: (command)=>fillCommand(`${command.name} `)
2185
+ onPick: fillInput
2175
2186
  })
2176
2187
  }),
2177
2188
  /*#__PURE__*/ jsx(TuiAssist, {
package/dist/a~0.js CHANGED
@@ -1211,7 +1211,10 @@ const DEFAULT_QUICK_COMMANDS = [
1211
1211
  'find',
1212
1212
  'read',
1213
1213
  'status'
1214
- ];
1214
+ ].map((name)=>({
1215
+ name,
1216
+ value: `ov ${name} `
1217
+ }));
1215
1218
  function Console({ mode, defaultMode, locale: localeProp, quickCommands = DEFAULT_QUICK_COMMANDS, scopeKey, requestOptions, onModeChange, onOpenUri, conversation, slots, labels: overrides, className, ...rest }) {
1216
1219
  const locale = useLocale(localeProp);
1217
1220
  const state = useConsole({
@@ -1 +1,2 @@
1
1
  export * from './tui.js';
2
+ export type { TuiQuickCommand } from './types.js';
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { TuiCommandDefinition } from './command-catalog.js';
3
+ import type { TuiQuickCommand } from './types.js';
3
4
  import type { ResolvedTuiLabels } from './tui-labels.js';
4
5
  /**
5
6
  * 按名称从宿主目录中取快捷命令,保持传入顺序,未命中的名称直接跳过。
@@ -8,7 +9,7 @@ import type { ResolvedTuiLabels } from './tui-labels.js';
8
9
  * names the catalogue does not contain. Repeated names keep their first
9
10
  * occurrence so one command never renders as sibling nodes with the same key.
10
11
  */
11
- export declare function pickTuiCommands(names: readonly string[] | undefined, commands: readonly TuiCommandDefinition[]): readonly TuiCommandDefinition[];
12
+ export declare function pickTuiCommands(shortcuts: readonly TuiQuickCommand[] | undefined, commands: readonly TuiCommandDefinition[]): readonly (TuiCommandDefinition & TuiQuickCommand)[];
12
13
  /**
13
14
  * 无记录时的空态区域。宿主节点优先;否则展示内置空态,没有可用快捷命令时
14
15
  * 不渲染任何内容。
@@ -18,8 +19,8 @@ export declare function pickTuiCommands(names: readonly string[] | undefined, co
18
19
  */
19
20
  export declare function TuiEmptyRegion({ emptyState, commands, labels, disabled, onPick, }: {
20
21
  emptyState?: ReactNode;
21
- commands: readonly TuiCommandDefinition[];
22
+ commands: readonly (TuiCommandDefinition & TuiQuickCommand)[];
22
23
  labels: ResolvedTuiLabels;
23
24
  disabled?: boolean;
24
- onPick: (command: TuiCommandDefinition) => void;
25
+ onPick: (value: string) => void;
25
26
  }): import("react").JSX.Element | null;
@@ -465,6 +465,13 @@ export interface TuiLabels {
465
465
  /** 格式化已过去的整小时。Formats elapsed whole hours. */
466
466
  formatHoursAgo?: (hours: number) => string;
467
467
  }
468
+ /** 空态快捷入口。One empty-state shortcut. */
469
+ export interface TuiQuickCommand {
470
+ /** 匹配 commands 的名称,复用其说明。Name matched in commands to reuse its copy. */
471
+ name: string;
472
+ /** 原样填入的完整命令;空字符串清空输入,不回退到命令前缀。Full input text; an empty string clears the input without a prefix fallback. */
473
+ value: string;
474
+ }
468
475
  /**
469
476
  * 当前命令记录、结果与输入区的公开接口;会话、历史面板和外层工具栏由宿主组合。
470
477
  * 提供命令补全、参数提示与帮助。
@@ -504,15 +511,15 @@ export interface TuiProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onCopy'
504
511
  */
505
512
  emptyState?: ReactNode;
506
513
  /**
507
- * 内置空态展示的快捷命令名称,按数组顺序取自 `commands`,未命中的名称跳过,
508
- * 重复名称只保留首次出现。
509
- * 点击后填入输入框并聚焦,不提交命令。
510
- * Quick command names rendered by the built-in empty state, resolved from
511
- * `commands` in array order; unknown names are skipped and repeats keep their
512
- * first occurrence. Selecting one fills
513
- * and focuses the input without submitting.
514
+ * 内置空态快捷入口;name 按顺序匹配 commands 并复用 summary/description,
515
+ * 未命中的名称跳过,重复名称只保留首次出现。
516
+ * 点击后原样填入 value 并聚焦,不添加前缀、不提交;空字符串清空输入。
517
+ * Built-in empty-state shortcuts. Names resolve copy from commands in order;
518
+ * unknown names are skipped and repeats keep their first occurrence.
519
+ * Selection fills value verbatim and focuses without adding a prefix or
520
+ * submitting. An empty value clears the input.
514
521
  */
515
- quickCommands?: readonly string[];
522
+ quickCommands?: readonly TuiQuickCommand[];
516
523
  /** 宿主提供的命令目录;省略时无候选和参数帮助,仍可提交文本。 */
517
524
  commands?: readonly TuiCommandDefinition[];
518
525
  /** 宿主提供的分组名称与顺序;未声明的组按目录顺序追加。 */
@@ -1,7 +1,7 @@
1
1
  import type { Locale } from '../../shared/locale.js';
2
2
  import type { HTMLAttributes, ReactNode } from 'react';
3
3
  import type { OvRequestOptions } from '../../client/types.js';
4
- import type { TuiCommandDefinition, TuiLabels, TuiRecord } from '../../components/tui/index.js';
4
+ import type { TuiCommandDefinition, TuiLabels, TuiQuickCommand, TuiRecord } from '../../components/tui/index.js';
5
5
  import type { VikingBotLabels, VikingBotProps } from '../../components/viking-bot/index.js';
6
6
  export type ConsoleMode = 'conversation' | 'command';
7
7
  export interface ConsoleSlots {
@@ -42,14 +42,16 @@ export interface ConsoleProps extends ConsoleOptions, Omit<HTMLAttributes<HTMLDi
42
42
  /** 可选文案语言;继承上层,最终默认英文。Optional locale; inherits or defaults to en-US. */
43
43
  locale?: Locale;
44
44
  /**
45
- * 终端空态展示的快捷命令名称,按数组顺序取自命令目录,未命中的名称跳过,
45
+ * 终端空态快捷入口,按 name 从命令目录复用说明,点击原样填入 value 并聚焦,不提交。
46
+ * 未命中的名称跳过,
46
47
  * 重复名称只保留首次出现。
47
- * 省略时使用默认集合;传空数组不展示内置空态。
48
- * Quick command names shown in the terminal empty state, resolved from the
49
- * command catalogue in array order with unknown names skipped. Omitted uses
50
- * the default set; an empty array shows no built-in empty state.
48
+ * 省略时使用包含 ov 命令前缀的默认集合;传空数组不展示内置空态。
49
+ * Terminal shortcuts resolve copy by name from the command catalogue;
50
+ * selection fills value verbatim and focuses without submitting. Unknown
51
+ * names are skipped. Omitted uses the default set with ov command prefixes;
52
+ * an empty array shows no built-in empty state.
51
53
  */
52
- quickCommands?: readonly string[];
54
+ quickCommands?: readonly TuiQuickCommand[];
53
55
  /** Host-owned conversation state/capabilities. Omit draft callbacks to use Console's local draft. */
54
56
  conversation?: Partial<VikingBotProps>;
55
57
  /** Reports navigation intent; the host opens the resource. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openviking/react",
3
- "version": "0.1.8-beta.11.1.gc6def608a25e",
3
+ "version": "0.1.8-beta.12.1.g83d24ca4fc6f",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },