@h-ai/ui 0.1.0-alpha.70 → 0.1.0-alpha.72
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/README.en.md +19 -6
- package/README.ja.md +19 -6
- package/README.md +19 -6
- package/auto-import.d.ts +1 -0
- package/auto-import.js +1 -0
- package/dist/components/compounds/JsonViewer.svelte +214 -0
- package/dist/components/compounds/JsonViewer.svelte.d.ts +26 -0
- package/dist/components/compounds/index.d.ts +1 -0
- package/dist/components/compounds/index.js +2 -0
- package/dist/components/scenes/ai/index.d.ts +1 -0
- package/dist/components/scenes/ai/index.js +2 -0
- package/dist/components/scenes/app/FeedbackDetail.svelte +14 -2
- package/dist/components/scenes/app/FeedbackDetail.svelte.d.ts +2 -0
- package/dist/components/scenes/app/FeedbackForm.svelte +128 -61
- package/dist/components/scenes/app/FeedbackForm.svelte.d.ts +14 -3
- package/dist/components/scenes/app/FeedbackList.svelte +3 -3
- package/dist/components/scenes/app/FeedbackModal.svelte +50 -2
- package/dist/components/scenes/app/FeedbackRecorder.svelte +154 -0
- package/dist/components/scenes/app/FeedbackRecorder.svelte.d.ts +9 -0
- package/dist/components/scenes/app/FeedbackReplay.svelte +142 -0
- package/dist/components/scenes/app/FeedbackReplay.svelte.d.ts +7 -0
- package/dist/components/scenes/app/FeedbackScreenshot.svelte +37 -23
- package/dist/components/scenes/app/feedback-functions.js +1 -0
- package/dist/components/scenes/app/feedback-types.d.ts +1 -1
- package/dist/components/scenes/iam/auth-error-message.d.ts +1 -1
- package/dist/components/scenes/iam/auth-error-message.js +2 -1
- package/dist/messages/en-US.json +29 -9
- package/dist/messages/ja-JP.json +29 -9
- package/dist/messages/zh-CN.json +29 -9
- package/dist/toast.svelte.d.ts +9 -0
- package/dist/toast.svelte.js +25 -4
- package/dist/types.d.ts +27 -0
- package/package.json +3 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<!-- 按需加载回放引擎;仅接受宿主已脱敏的页面事件,不执行原应用脚本。 -->
|
|
2
|
+
<script lang='ts'>
|
|
3
|
+
import type { Replayer } from '@rrweb/replay'
|
|
4
|
+
import type { FeedbackEvidenceView } from './feedback-types.js'
|
|
5
|
+
import { uiM } from '../../../messages.js'
|
|
6
|
+
import { errorMessage } from '../../../toast.svelte.js'
|
|
7
|
+
import Button from '../../primitives/Button.svelte'
|
|
8
|
+
|
|
9
|
+
const { load }: { load: () => Promise<FeedbackEvidenceView[]> } = $props()
|
|
10
|
+
/**
|
|
11
|
+
* 回放引擎自身的事件契约;不复制第三方格式。
|
|
12
|
+
* @example 模块内部上下文
|
|
13
|
+
* ```ts
|
|
14
|
+
* const records: ReplayEvent[] = []
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
type ReplayEvent = Exclude<ConstructorParameters<typeof Replayer>[0][number], string>
|
|
18
|
+
let viewport = $state<HTMLDivElement>()
|
|
19
|
+
let target = $state<HTMLDivElement>()
|
|
20
|
+
let player = $state.raw<Replayer>()
|
|
21
|
+
let loading = $state(true)
|
|
22
|
+
let error = $state('')
|
|
23
|
+
let playing = $state(false)
|
|
24
|
+
let position = $state(0)
|
|
25
|
+
let duration = $state(0)
|
|
26
|
+
let scale = $state(1)
|
|
27
|
+
let height = $state(400)
|
|
28
|
+
let frame = 0
|
|
29
|
+
let events: ReplayEvent[] = []
|
|
30
|
+
let snapshotOffset = 0
|
|
31
|
+
|
|
32
|
+
function isEvent(value: unknown): value is ReplayEvent {
|
|
33
|
+
return value !== null && typeof value === 'object' && 'timestamp' in value && typeof value.timestamp === 'number'
|
|
34
|
+
&& 'type' in value && typeof value.type === 'number' && Number.isInteger(value.type) && value.type >= 0 && value.type <= 6 && 'data' in value
|
|
35
|
+
}
|
|
36
|
+
function construct() {
|
|
37
|
+
if (!player || !target)
|
|
38
|
+
return
|
|
39
|
+
const Player = player.constructor as typeof Replayer
|
|
40
|
+
player.destroy()
|
|
41
|
+
player = new Player(events, { root: target, showWarning: false, showDebug: false, loadTimeout: 1000 })
|
|
42
|
+
}
|
|
43
|
+
function seek(value: number) {
|
|
44
|
+
playing = false
|
|
45
|
+
cancelAnimationFrame(frame)
|
|
46
|
+
construct()
|
|
47
|
+
position = Math.max(0, Math.min(duration, value))
|
|
48
|
+
player?.pause(Math.max(position, snapshotOffset) + 1)
|
|
49
|
+
}
|
|
50
|
+
function update() {
|
|
51
|
+
if (!playing || !player)
|
|
52
|
+
return
|
|
53
|
+
position = Math.min(duration, player.getCurrentTime())
|
|
54
|
+
if (position >= duration) {
|
|
55
|
+
player.pause()
|
|
56
|
+
playing = false
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
frame = requestAnimationFrame(update)
|
|
60
|
+
}
|
|
61
|
+
function play() {
|
|
62
|
+
if (!player)
|
|
63
|
+
return
|
|
64
|
+
if (position >= duration)
|
|
65
|
+
seek(0)
|
|
66
|
+
playing = true
|
|
67
|
+
player.play(Math.max(position, snapshotOffset))
|
|
68
|
+
cancelAnimationFrame(frame)
|
|
69
|
+
update()
|
|
70
|
+
}
|
|
71
|
+
function pause() {
|
|
72
|
+
player?.pause()
|
|
73
|
+
playing = false
|
|
74
|
+
cancelAnimationFrame(frame)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
$effect(() => {
|
|
78
|
+
const root = target
|
|
79
|
+
const container = viewport
|
|
80
|
+
if (!root || !container)
|
|
81
|
+
return
|
|
82
|
+
let active = true
|
|
83
|
+
const observer = new ResizeObserver(() => {
|
|
84
|
+
const width = Number(player?.iframe.width) || 1024
|
|
85
|
+
scale = Math.min(1, container.clientWidth / width)
|
|
86
|
+
height = (Number(player?.iframe.height) || 768) * scale
|
|
87
|
+
})
|
|
88
|
+
void (async () => {
|
|
89
|
+
try {
|
|
90
|
+
const records = await load()
|
|
91
|
+
if (!active)
|
|
92
|
+
return
|
|
93
|
+
events = records.map(item => item.data.event).filter(isEvent).sort((a, b) => a.timestamp - b.timestamp)
|
|
94
|
+
const snapshot = events.find(event => event.type === 2)
|
|
95
|
+
if (!snapshot || events.length < 2)
|
|
96
|
+
return
|
|
97
|
+
const { Replayer: Player } = await import('@rrweb/replay')
|
|
98
|
+
await import('@rrweb/replay/dist/style.css')
|
|
99
|
+
if (!active)
|
|
100
|
+
return
|
|
101
|
+
duration = Math.max(0, events.at(-1)!.timestamp - events[0]!.timestamp)
|
|
102
|
+
snapshotOffset = Math.max(0, snapshot.timestamp - events[0]!.timestamp)
|
|
103
|
+
player = new Player(events, { root, showWarning: false, showDebug: false, loadTimeout: 1000 })
|
|
104
|
+
player.pause(snapshotOffset + 1)
|
|
105
|
+
observer.observe(container)
|
|
106
|
+
}
|
|
107
|
+
catch (cause) {
|
|
108
|
+
if (active)
|
|
109
|
+
error = errorMessage(cause, uiM('feedback_action_failed'))
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
if (active)
|
|
113
|
+
loading = false
|
|
114
|
+
}
|
|
115
|
+
})()
|
|
116
|
+
return () => {
|
|
117
|
+
active = false
|
|
118
|
+
cancelAnimationFrame(frame)
|
|
119
|
+
observer.disconnect()
|
|
120
|
+
player?.destroy()
|
|
121
|
+
player = undefined
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<div class='space-y-3 min-w-0'>
|
|
127
|
+
<p class='text-sm text-base-content/65'>{uiM('feedback_replay_hint')}</p>
|
|
128
|
+
{#if error}<p class='text-error text-sm break-words' role='alert'>{error}</p>{/if}
|
|
129
|
+
{#if loading}<p role='status'>{uiM('feedback_loading')}</p>
|
|
130
|
+
{:else if !player}<p class='rounded bg-base-200 p-4 text-sm'>{uiM('feedback_replay_empty')}</p>{/if}
|
|
131
|
+
<div bind:this={viewport} class='relative w-full overflow-hidden rounded-lg bg-base-200' style:height={player ? `${height}px` : '0'}>
|
|
132
|
+
<div bind:this={target} class='origin-top-left' style:transform={`scale(${scale})`}></div>
|
|
133
|
+
</div>
|
|
134
|
+
{#if player}
|
|
135
|
+
<div class='flex flex-wrap items-center gap-2'>
|
|
136
|
+
<Button size='sm' disabled={playing} onclick={play}>{uiM('feedback_replay_play')}</Button>
|
|
137
|
+
<Button size='sm' variant='ghost' disabled={!playing} onclick={pause}>{uiM('feedback_replay_pause')}</Button>
|
|
138
|
+
<input type='range' min={0} max={Math.max(1, duration)} step={1} value={position} oninput={event => seek(Number(event.currentTarget.value))} aria-label={uiM('feedback_replay')} class='range range-xs min-w-24 flex-1' />
|
|
139
|
+
<span class='text-xs tabular-nums'>{Math.floor(position / 1000)} / {Math.ceil(duration / 1000)} s</span>
|
|
140
|
+
</div>
|
|
141
|
+
{/if}
|
|
142
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FeedbackEvidenceView } from './feedback-types.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
load: () => Promise<FeedbackEvidenceView[]>;
|
|
4
|
+
};
|
|
5
|
+
declare const FeedbackReplay: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type FeedbackReplay = ReturnType<typeof FeedbackReplay>;
|
|
7
|
+
export default FeedbackReplay;
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
<script lang='ts'>
|
|
3
3
|
import type { FeedbackAnnotation, FeedbackAttachmentView } from './feedback-types.js'
|
|
4
4
|
import { uiM } from '../../../messages.js'
|
|
5
|
-
import
|
|
6
|
-
import FormLayout from '../../compounds/FormLayout.svelte'
|
|
5
|
+
import { errorMessage } from '../../../toast.svelte.js'
|
|
7
6
|
import Button from '../../primitives/Button.svelte'
|
|
8
|
-
import Input from '../../primitives/Input.svelte'
|
|
9
7
|
import { imagePreviewUrl } from './feedback-functions.js'
|
|
10
8
|
|
|
11
9
|
const { attachment, onannotate }: {
|
|
@@ -14,27 +12,26 @@
|
|
|
14
12
|
} = $props()
|
|
15
13
|
|
|
16
14
|
let mode = $state<'mask' | 'outline'>('outline')
|
|
17
|
-
let
|
|
18
|
-
let top = $state('10')
|
|
19
|
-
let width = $state('20')
|
|
20
|
-
let height = $state('20')
|
|
15
|
+
let rect = $state({ x: 0.1, y: 0.1, width: 0.2, height: 0.2 })
|
|
21
16
|
let start = $state<{ x: number, y: number } | null>(null)
|
|
22
17
|
let selected = $state(false)
|
|
23
18
|
let loading = $state(false)
|
|
24
19
|
let error = $state('')
|
|
25
20
|
let imageFailed = $state(false)
|
|
26
21
|
const url = $derived(imagePreviewUrl(attachment.url))
|
|
27
|
-
const rect = $derived({ x: Math.max(0, Math.min(1, Number(left) / 100)), y: Math.max(0, Math.min(1, Number(top) / 100)), width: Math.max(0, Math.min(1, Number(width) / 100)), height: Math.max(0, Math.min(1, Number(height) / 100)) })
|
|
28
22
|
|
|
29
23
|
function point(event: PointerEvent & { currentTarget: HTMLDivElement }) {
|
|
30
|
-
const bounds = event.currentTarget.getBoundingClientRect()
|
|
31
|
-
|
|
24
|
+
const bounds = (event.currentTarget.querySelector('img') ?? event.currentTarget).getBoundingClientRect()
|
|
25
|
+
if (!bounds.width || !bounds.height)
|
|
26
|
+
return { x: 0, y: 0 }
|
|
27
|
+
return { x: Math.max(0, Math.min(1, (event.clientX - bounds.left) / bounds.width)), y: Math.max(0, Math.min(1, (event.clientY - bounds.top) / bounds.height)) }
|
|
32
28
|
}
|
|
33
29
|
function begin(event: PointerEvent & { currentTarget: HTMLDivElement }) {
|
|
34
30
|
if (!onannotate || loading)
|
|
35
31
|
return
|
|
36
32
|
event.preventDefault()
|
|
37
33
|
start = point(event)
|
|
34
|
+
rect = { ...start, width: 0, height: 0 }
|
|
38
35
|
selected = true
|
|
39
36
|
event.currentTarget.setPointerCapture?.(event.pointerId)
|
|
40
37
|
}
|
|
@@ -42,10 +39,33 @@
|
|
|
42
39
|
if (!start)
|
|
43
40
|
return
|
|
44
41
|
const end = point(event)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
rect = { x: Math.min(start.x, end.x), y: Math.min(start.y, end.y), width: Math.abs(end.x - start.x), height: Math.abs(end.y - start.y) }
|
|
43
|
+
}
|
|
44
|
+
function keydown(event: KeyboardEvent) {
|
|
45
|
+
if (!onannotate || loading)
|
|
46
|
+
return
|
|
47
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
48
|
+
event.preventDefault()
|
|
49
|
+
selected = true
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key))
|
|
53
|
+
return
|
|
54
|
+
event.preventDefault()
|
|
55
|
+
selected = true
|
|
56
|
+
const dx = event.key === 'ArrowLeft' ? -0.01 : event.key === 'ArrowRight' ? 0.01 : 0
|
|
57
|
+
const dy = event.key === 'ArrowUp' ? -0.01 : event.key === 'ArrowDown' ? 0.01 : 0
|
|
58
|
+
rect = event.shiftKey
|
|
59
|
+
? { ...rect, width: Math.max(0.01, Math.min(1 - rect.x, rect.width + dx)), height: Math.max(0.01, Math.min(1 - rect.y, rect.height + dy)) }
|
|
60
|
+
: { ...rect, x: Math.max(0, Math.min(1 - rect.width, rect.x + dx)), y: Math.max(0, Math.min(1 - rect.height, rect.y + dy)) }
|
|
61
|
+
}
|
|
62
|
+
function end(event: PointerEvent & { currentTarget: HTMLDivElement }) {
|
|
63
|
+
move(event)
|
|
64
|
+
start = null
|
|
65
|
+
}
|
|
66
|
+
function cancel() {
|
|
67
|
+
start = null
|
|
68
|
+
selected = false
|
|
49
69
|
}
|
|
50
70
|
async function apply() {
|
|
51
71
|
if (!onannotate || loading || !Object.values(rect).every(Number.isFinite) || rect.width <= 0 || rect.height <= 0)
|
|
@@ -57,7 +77,7 @@
|
|
|
57
77
|
selected = false
|
|
58
78
|
}
|
|
59
79
|
catch (cause) {
|
|
60
|
-
error = cause
|
|
80
|
+
error = errorMessage(cause, uiM('feedback_action_failed'))
|
|
61
81
|
}
|
|
62
82
|
finally {
|
|
63
83
|
loading = false
|
|
@@ -67,7 +87,7 @@
|
|
|
67
87
|
|
|
68
88
|
{#if url}
|
|
69
89
|
<div class='space-y-3 min-w-0'>
|
|
70
|
-
<div class='relative overflow-hidden rounded-lg border border-base-content/10 select-none' role='
|
|
90
|
+
<div class='relative w-fit max-w-full overflow-hidden rounded-lg border border-base-content/10 select-none' role='button' aria-label={attachment.name} aria-disabled={!onannotate} tabindex={onannotate ? 0 : -1} onkeydown={keydown} style:touch-action={onannotate ? 'none' : 'auto'} onpointerdown={begin} onpointermove={move} onpointerup={end} onpointercancel={cancel}>
|
|
71
91
|
<img src={url} alt={attachment.name} class='block max-w-full h-auto' draggable='false' referrerpolicy='no-referrer' onerror={() => imageFailed = true} onload={() => imageFailed = false} />
|
|
72
92
|
{#if selected}
|
|
73
93
|
<div class:mask-preview={mode === 'mask'} class='pointer-events-none absolute border-2 border-error' style:left={`${rect.x * 100}%`} style:top={`${rect.y * 100}%`} style:width={`${rect.width * 100}%`} style:height={`${rect.height * 100}%`}></div>
|
|
@@ -86,14 +106,8 @@
|
|
|
86
106
|
}}>{uiM('feedback_mark_mask')}</Button>
|
|
87
107
|
</div>
|
|
88
108
|
<p class='text-xs text-base-content/60'>{uiM('feedback_mark_hint')}</p>
|
|
89
|
-
<FormLayout columns={2}>
|
|
90
|
-
<FormField label={uiM('feedback_mark_x')}><Input type='number' min={0} max={100} bind:value={left} oninput={() => selected = true} /></FormField>
|
|
91
|
-
<FormField label={uiM('feedback_mark_y')}><Input type='number' min={0} max={100} bind:value={top} oninput={() => selected = true} /></FormField>
|
|
92
|
-
<FormField label={uiM('feedback_mark_width')}><Input type='number' min={1} max={100} bind:value={width} oninput={() => selected = true} /></FormField>
|
|
93
|
-
<FormField label={uiM('feedback_mark_height')}><Input type='number' min={1} max={100} bind:value={height} oninput={() => selected = true} /></FormField>
|
|
94
|
-
</FormLayout>
|
|
95
109
|
<div class='flex flex-wrap gap-2'>
|
|
96
|
-
<Button size='sm' {loading} disabled={!selected} onclick={apply}>{uiM('feedback_mark_apply')}</Button>
|
|
110
|
+
<Button size='sm' {loading} disabled={!selected || rect.width <= 0 || rect.height <= 0} onclick={apply}>{uiM('feedback_mark_apply')}</Button>
|
|
97
111
|
<Button size='sm' variant='ghost' onclick={() => selected = false}>{uiM('feedback_mark_clear')}</Button>
|
|
98
112
|
</div>
|
|
99
113
|
{/if}
|
|
@@ -33,7 +33,7 @@ export interface FeedbackReportView {
|
|
|
33
33
|
commit?: string;
|
|
34
34
|
status: FeedbackStatus;
|
|
35
35
|
collectionStatus: 'collecting' | 'complete' | 'partial' | 'failed';
|
|
36
|
-
notificationStatus: 'pending' | 'sending' | 'sent' | 'deferred' | 'failed';
|
|
36
|
+
notificationStatus: 'disabled' | 'pending' | 'sending' | 'sent' | 'deferred' | 'failed';
|
|
37
37
|
createdAt: number;
|
|
38
38
|
updatedAt: number;
|
|
39
39
|
version: number;
|
|
@@ -9,4 +9,4 @@ import type { HaiError } from '@h-ai/core';
|
|
|
9
9
|
* const message = authErrorMessage({ code: 'hai:iam:020', message: '登录失败' })
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
|
-
export declare function authErrorMessage(error: Pick<HaiError, 'code' | 'message'>): string;
|
|
12
|
+
export declare function authErrorMessage(error: Pick<HaiError, 'code' | 'message' | 'traceId'>): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { core } from '@h-ai/core';
|
|
1
2
|
import { uiM } from '../../../messages.js';
|
|
2
3
|
const messages = {
|
|
3
4
|
'hai:iam:001': 'auth_error_credentials',
|
|
@@ -39,5 +40,5 @@ const messages = {
|
|
|
39
40
|
*/
|
|
40
41
|
export function authErrorMessage(error) {
|
|
41
42
|
const key = messages[error.code];
|
|
42
|
-
return key ? uiM(key) : error.message;
|
|
43
|
+
return core.error.formatMessage({ message: key ? uiM(key) : error.message, traceId: error.traceId });
|
|
43
44
|
}
|
package/dist/messages/en-US.json
CHANGED
|
@@ -389,12 +389,12 @@
|
|
|
389
389
|
"feedback_optional_description": "A short description (optional)",
|
|
390
390
|
"feedback_quick_hint": "You can submit now. Allowed diagnostic materials will be included.",
|
|
391
391
|
"feedback_more": "More options",
|
|
392
|
-
"feedback_materials": "
|
|
392
|
+
"feedback_materials": "Collected materials",
|
|
393
393
|
"feedback_screenshots": "Screenshots and annotations",
|
|
394
394
|
"feedback_attachments": "Attachments",
|
|
395
395
|
"feedback_add_files": "Add screenshots or attachments",
|
|
396
396
|
"feedback_remove": "Remove",
|
|
397
|
-
"feedback_local_export": "Save
|
|
397
|
+
"feedback_local_export": "Save feedback locally",
|
|
398
398
|
"feedback_accepted": "Accepted: {number}",
|
|
399
399
|
"feedback_accepted_hint": "You can keep using the product while materials are collected in the background.",
|
|
400
400
|
"feedback_collecting": "Collecting materials",
|
|
@@ -423,7 +423,7 @@
|
|
|
423
423
|
"feedback_notification": "Notification status",
|
|
424
424
|
"feedback_notification_pending": "Notification pending",
|
|
425
425
|
"feedback_notification_sending": "Sending notification",
|
|
426
|
-
"feedback_notification_sent": "Accepted by
|
|
426
|
+
"feedback_notification_sent": "Accepted by notification channel",
|
|
427
427
|
"feedback_notification_deferred": "Notification deferred",
|
|
428
428
|
"feedback_notification_failed": "Notification failed",
|
|
429
429
|
"feedback_date_range": "Submission date range",
|
|
@@ -446,17 +446,37 @@
|
|
|
446
446
|
"feedback_revision": "Evidence revision",
|
|
447
447
|
"feedback_mark_outline": "Highlight problem area",
|
|
448
448
|
"feedback_mark_mask": "Mask sensitive area",
|
|
449
|
-
"feedback_mark_hint": "Drag over the image
|
|
449
|
+
"feedback_mark_hint": "Drag over the image, then apply. Arrow keys move the selection; Shift + arrow keys resize it.",
|
|
450
450
|
"feedback_mark_apply": "Apply annotation",
|
|
451
451
|
"feedback_mark_clear": "Clear selection",
|
|
452
|
-
"feedback_mark_x": "Left (%)",
|
|
453
|
-
"feedback_mark_y": "Top (%)",
|
|
454
|
-
"feedback_mark_width": "Width (%)",
|
|
455
|
-
"feedback_mark_height": "Height (%)",
|
|
456
452
|
"feedback_download": "View / download",
|
|
457
453
|
"feedback_close": "Close",
|
|
458
454
|
"feedback_apply_filters": "Query materials",
|
|
459
455
|
"feedback_preview_failed": "The image preview is unavailable. Other materials can still be viewed or submitted.",
|
|
460
456
|
"feedback_build_id": "Build identifier",
|
|
461
|
-
"feedback_commit": "Source commit"
|
|
457
|
+
"feedback_commit": "Source commit",
|
|
458
|
+
"feedback_capture_add": "Add page screenshot",
|
|
459
|
+
"feedback_capture_replace": "Retake screenshot",
|
|
460
|
+
"feedback_capture_now": "Capture this page",
|
|
461
|
+
"feedback_capture_return": "Back to feedback",
|
|
462
|
+
"feedback_capture_hint": "Navigate to the page you need, then choose “Capture this page”. Your feedback will be kept.",
|
|
463
|
+
"feedback_replay": "Page replay",
|
|
464
|
+
"feedback_replay_play": "Play",
|
|
465
|
+
"feedback_replay_pause": "Pause",
|
|
466
|
+
"feedback_replay_hint": "Replay captured pages and interactions. Input values are masked; external assets may be missing.",
|
|
467
|
+
"feedback_replay_empty": "No page replay is available. Recording starts only when replay is enabled. You can also review screenshots or screen recordings.",
|
|
468
|
+
"feedback_record": "Record screen",
|
|
469
|
+
"feedback_record_start": "Start recording",
|
|
470
|
+
"feedback_record_stop": "Stop recording",
|
|
471
|
+
"feedback_record_cancel": "Cancel recording",
|
|
472
|
+
"feedback_record_hint": "Choose a tab or window to record, up to 60 seconds / {size} MiB, without audio. Avoid sensitive content; preview or remove the video when finished.",
|
|
473
|
+
"feedback_recording": "Recording · {seconds}s",
|
|
474
|
+
"feedback_record_unsupported": "Screen recording is unavailable in this browser. Use a screenshot or attach a video.",
|
|
475
|
+
"feedback_record_failed": "Recording did not finish. Choose a screen again or attach a video.",
|
|
476
|
+
"feedback_record_empty": "No video was recorded. Please retry.",
|
|
477
|
+
"feedback_local_saved": "Your feedback download has started.",
|
|
478
|
+
"feedback_notification_disabled": "Notifications disabled",
|
|
479
|
+
"feedback_capacity_hint": "Attachments {used}/{total} MiB · {single} MiB each · up to {count}",
|
|
480
|
+
"json_viewer_copy": "Copy",
|
|
481
|
+
"json_viewer_copied": "Copied"
|
|
462
482
|
}
|
package/dist/messages/ja-JP.json
CHANGED
|
@@ -389,12 +389,12 @@
|
|
|
389
389
|
"feedback_optional_description": "簡単な説明(任意)",
|
|
390
390
|
"feedback_quick_hint": "そのまま送信できます。許可された診断資料が添付されます。",
|
|
391
391
|
"feedback_more": "その他のオプション",
|
|
392
|
-
"feedback_materials": "
|
|
392
|
+
"feedback_materials": "収集資料",
|
|
393
393
|
"feedback_screenshots": "スクリーンショットと注釈",
|
|
394
394
|
"feedback_attachments": "添付ファイル",
|
|
395
395
|
"feedback_add_files": "画像やファイルを追加",
|
|
396
396
|
"feedback_remove": "削除",
|
|
397
|
-
"feedback_local_export": "
|
|
397
|
+
"feedback_local_export": "フィードバックをローカル保存",
|
|
398
398
|
"feedback_accepted": "受理しました:{number}",
|
|
399
399
|
"feedback_accepted_hint": "資料はバックグラウンドで収集されます。引き続き製品をご利用いただけます。",
|
|
400
400
|
"feedback_collecting": "資料を収集中",
|
|
@@ -423,7 +423,7 @@
|
|
|
423
423
|
"feedback_notification": "通知状況",
|
|
424
424
|
"feedback_notification_pending": "通知待ち",
|
|
425
425
|
"feedback_notification_sending": "送信中",
|
|
426
|
-
"feedback_notification_sent": "
|
|
426
|
+
"feedback_notification_sent": "通知チャネルで受理済み",
|
|
427
427
|
"feedback_notification_deferred": "通知延期",
|
|
428
428
|
"feedback_notification_failed": "通知失敗",
|
|
429
429
|
"feedback_date_range": "投稿日時の範囲",
|
|
@@ -446,17 +446,37 @@
|
|
|
446
446
|
"feedback_revision": "資料リビジョン",
|
|
447
447
|
"feedback_mark_outline": "問題の範囲を指定",
|
|
448
448
|
"feedback_mark_mask": "機密情報を隠す",
|
|
449
|
-
"feedback_mark_hint": "
|
|
449
|
+
"feedback_mark_hint": "画像をドラッグして注釈を適用します。矢印キーで移動、Shift + 矢印キーでサイズを調整できます。",
|
|
450
450
|
"feedback_mark_apply": "注釈を適用",
|
|
451
451
|
"feedback_mark_clear": "選択を解除",
|
|
452
|
-
"feedback_mark_x": "左 (%)",
|
|
453
|
-
"feedback_mark_y": "上 (%)",
|
|
454
|
-
"feedback_mark_width": "幅 (%)",
|
|
455
|
-
"feedback_mark_height": "高さ (%)",
|
|
456
452
|
"feedback_download": "表示 / ダウンロード",
|
|
457
453
|
"feedback_close": "閉じる",
|
|
458
454
|
"feedback_apply_filters": "資料を検索",
|
|
459
455
|
"feedback_preview_failed": "画像を表示できません。他の資料は引き続き閲覧・送信できます。",
|
|
460
456
|
"feedback_build_id": "ビルド識別子",
|
|
461
|
-
"feedback_commit": "ソースコミット"
|
|
457
|
+
"feedback_commit": "ソースコミット",
|
|
458
|
+
"feedback_capture_add": "ページ画像を追加",
|
|
459
|
+
"feedback_capture_replace": "撮り直す",
|
|
460
|
+
"feedback_capture_now": "現在のページを撮影",
|
|
461
|
+
"feedback_capture_return": "フィードバックに戻る",
|
|
462
|
+
"feedback_capture_hint": "撮影するページに移動し、「現在のページを撮影」を押してください。入力内容は保持されます。",
|
|
463
|
+
"feedback_replay": "ページ再生",
|
|
464
|
+
"feedback_replay_play": "再生",
|
|
465
|
+
"feedback_replay_pause": "一時停止",
|
|
466
|
+
"feedback_replay_hint": "収集した画面と操作を再生します。入力内容は隠され、外部リソースは表示されない場合があります。",
|
|
467
|
+
"feedback_replay_empty": "再生できる操作記録がありません。有効化後の操作のみ記録されます。画像や録画も確認できます。",
|
|
468
|
+
"feedback_record": "画面録画",
|
|
469
|
+
"feedback_record_start": "録画を開始",
|
|
470
|
+
"feedback_record_stop": "録画を停止",
|
|
471
|
+
"feedback_record_cancel": "録画を取り消す",
|
|
472
|
+
"feedback_record_hint": "タブやウィンドウを選択して録画します。最大60秒 / {size} MiB、音声なし。機密情報に注意し、停止後に確認・削除できます。",
|
|
473
|
+
"feedback_recording": "録画中 · {seconds}秒",
|
|
474
|
+
"feedback_record_unsupported": "このブラウザーは画面録画に対応していません。画像や動画を添付してください。",
|
|
475
|
+
"feedback_record_failed": "録画が完了しませんでした。画面を再選択するか動画を添付してください。",
|
|
476
|
+
"feedback_record_empty": "映像がありません。再試行してください。",
|
|
477
|
+
"feedback_local_saved": "フィードバックのダウンロードを開始しました。",
|
|
478
|
+
"feedback_notification_disabled": "通知は無効です",
|
|
479
|
+
"feedback_capacity_hint": "添付 {used}/{total} MiB · 各 {single} MiB まで · 最大 {count} 件",
|
|
480
|
+
"json_viewer_copy": "コピー",
|
|
481
|
+
"json_viewer_copied": "コピーしました"
|
|
462
482
|
}
|
package/dist/messages/zh-CN.json
CHANGED
|
@@ -389,12 +389,12 @@
|
|
|
389
389
|
"feedback_optional_description": "一句话说明(可选)",
|
|
390
390
|
"feedback_quick_hint": "可以直接提交。系统会附上允许收集的现场材料。",
|
|
391
391
|
"feedback_more": "更多选项",
|
|
392
|
-
"feedback_materials": "
|
|
392
|
+
"feedback_materials": "收集材料",
|
|
393
393
|
"feedback_screenshots": "截图与标注",
|
|
394
394
|
"feedback_attachments": "附件",
|
|
395
395
|
"feedback_add_files": "添加截图或附件",
|
|
396
396
|
"feedback_remove": "删除",
|
|
397
|
-
"feedback_local_export": "
|
|
397
|
+
"feedback_local_export": "保存反馈到本地",
|
|
398
398
|
"feedback_accepted": "已受理:{number}",
|
|
399
399
|
"feedback_accepted_hint": "您可以继续使用产品,材料将在后台汇集。",
|
|
400
400
|
"feedback_collecting": "材料收集中",
|
|
@@ -423,7 +423,7 @@
|
|
|
423
423
|
"feedback_notification": "通知状态",
|
|
424
424
|
"feedback_notification_pending": "等待通知",
|
|
425
425
|
"feedback_notification_sending": "正在发送",
|
|
426
|
-
"feedback_notification_sent": "
|
|
426
|
+
"feedback_notification_sent": "通知通道已受理",
|
|
427
427
|
"feedback_notification_deferred": "通知已延迟",
|
|
428
428
|
"feedback_notification_failed": "通知失败",
|
|
429
429
|
"feedback_date_range": "提交时间范围",
|
|
@@ -446,17 +446,37 @@
|
|
|
446
446
|
"feedback_revision": "证据修订",
|
|
447
447
|
"feedback_mark_outline": "圈选问题位置",
|
|
448
448
|
"feedback_mark_mask": "遮挡敏感区域",
|
|
449
|
-
"feedback_mark_hint": "
|
|
449
|
+
"feedback_mark_hint": "在图片上拖动选择区域,再应用标注。也可用方向键移动选区,Shift + 方向键调整大小。",
|
|
450
450
|
"feedback_mark_apply": "应用标注",
|
|
451
451
|
"feedback_mark_clear": "清除选区",
|
|
452
|
-
"feedback_mark_x": "左侧 (%)",
|
|
453
|
-
"feedback_mark_y": "顶部 (%)",
|
|
454
|
-
"feedback_mark_width": "宽度 (%)",
|
|
455
|
-
"feedback_mark_height": "高度 (%)",
|
|
456
452
|
"feedback_download": "查看 / 下载",
|
|
457
453
|
"feedback_close": "关闭",
|
|
458
454
|
"feedback_apply_filters": "查询材料",
|
|
459
455
|
"feedback_preview_failed": "图片预览不可用,其他材料仍可查看或提交。",
|
|
460
456
|
"feedback_build_id": "构建标识",
|
|
461
|
-
"feedback_commit": "源码提交"
|
|
457
|
+
"feedback_commit": "源码提交",
|
|
458
|
+
"feedback_capture_add": "添加页面截图",
|
|
459
|
+
"feedback_capture_replace": "重新截图",
|
|
460
|
+
"feedback_capture_now": "截取当前页面",
|
|
461
|
+
"feedback_capture_return": "返回反馈",
|
|
462
|
+
"feedback_capture_hint": "切换到需要截图的页面,再点击“截取当前页面”。已填写的内容会保留。",
|
|
463
|
+
"feedback_replay": "页面回放",
|
|
464
|
+
"feedback_replay_play": "播放",
|
|
465
|
+
"feedback_replay_pause": "暂停",
|
|
466
|
+
"feedback_replay_hint": "回放已采集的页面与操作。输入内容已遮挡,外部资源可能缺失。",
|
|
467
|
+
"feedback_replay_empty": "没有可用的页面回放。仅在启用回放采集后记录操作;也可查看截图或录屏。",
|
|
468
|
+
"feedback_record": "录屏",
|
|
469
|
+
"feedback_record_start": "开始录屏",
|
|
470
|
+
"feedback_record_stop": "停止录屏",
|
|
471
|
+
"feedback_record_cancel": "取消录屏",
|
|
472
|
+
"feedback_record_hint": "选择页面或窗口后录制,最多 60 秒 / {size} MiB,不录制声音。请避开敏感内容;停止后可预览或删除。",
|
|
473
|
+
"feedback_recording": "正在录屏 · {seconds} 秒",
|
|
474
|
+
"feedback_record_unsupported": "当前浏览器不支持录屏,请使用截图或添加视频文件。",
|
|
475
|
+
"feedback_record_failed": "录屏未完成,请重新选择页面或添加视频文件。",
|
|
476
|
+
"feedback_record_empty": "未录制到画面,请重试。",
|
|
477
|
+
"feedback_local_saved": "已开始下载反馈文件。",
|
|
478
|
+
"feedback_notification_disabled": "未启用通知",
|
|
479
|
+
"feedback_capacity_hint": "附件 {used}/{total} MiB · 单个最多 {single} MiB · 最多 {count} 项",
|
|
480
|
+
"json_viewer_copy": "复制",
|
|
481
|
+
"json_viewer_copied": "已复制"
|
|
462
482
|
}
|
package/dist/toast.svelte.d.ts
CHANGED
|
@@ -168,6 +168,15 @@ export declare function notifySuccess(message: string, duration?: number): strin
|
|
|
168
168
|
* ```
|
|
169
169
|
*/
|
|
170
170
|
export declare function notifyError(error: unknown, fallback?: string, duration?: number): string;
|
|
171
|
+
/**
|
|
172
|
+
* 行内错误和 Toast 共用的安全提示;日志保留脱敏原因,提示末尾共用 traceId。
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* import { errorMessage } from '@h-ai/ui'
|
|
176
|
+
* const text = errorMessage(new Error('Internal detail'), '保存失败')
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare function errorMessage(error: unknown, fallback?: string): string;
|
|
171
180
|
/**
|
|
172
181
|
* 弹出信息提示(右上角)。
|
|
173
182
|
*
|
package/dist/toast.svelte.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Toast 通知的状态管理,使用 Svelte 5 Runes
|
|
5
5
|
* @module toast.svelte
|
|
6
6
|
*/
|
|
7
|
+
import { core } from '@h-ai/core';
|
|
7
8
|
/**
|
|
8
9
|
* Toast 状态
|
|
9
10
|
*/
|
|
@@ -201,10 +202,30 @@ export function notifySuccess(message, duration = SUCCESS_DURATION) {
|
|
|
201
202
|
* ```
|
|
202
203
|
*/
|
|
203
204
|
export function notifyError(error, fallback = '', duration = ERROR_DURATION) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
return toast.error(errorMessage(error, fallback), duration);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 行内错误和 Toast 共用的安全提示;日志保留脱敏原因,提示末尾共用 traceId。
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* import { errorMessage } from '@h-ai/ui'
|
|
212
|
+
* const text = errorMessage(new Error('Internal detail'), '保存失败')
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export function errorMessage(error, fallback = '') {
|
|
216
|
+
let known;
|
|
217
|
+
if (error && typeof error === 'object' && !(error instanceof Error) && Object.hasOwn(error, 'code') && Object.hasOwn(error, 'message') && 'message' in error && typeof error.message === 'string')
|
|
218
|
+
known = error;
|
|
219
|
+
const receivedMessage = error instanceof Error ? error.message : typeof error === 'string' ? error : '';
|
|
220
|
+
const embeddedTraceId = /\(traceId: ([\w.:-]{1,128})\)$/.exec(receivedMessage)?.[1];
|
|
221
|
+
const traceId = known?.traceId ?? embeddedTraceId ?? core.context.get().traceId ?? core.context.get().requestId ?? core.id.uuid();
|
|
222
|
+
core.logger.error('User operation failed', { traceId, error });
|
|
223
|
+
let message = fallback || core.i18n.coreM('core_errorInternal');
|
|
224
|
+
if (known)
|
|
225
|
+
message = core.error.toPublic(known, traceId).message;
|
|
226
|
+
else if (typeof error === 'string' || embeddedTraceId)
|
|
227
|
+
message = receivedMessage;
|
|
228
|
+
return core.error.formatMessage({ message, traceId: /\(traceId: [\w.:-]{1,128}\)$/.test(message) ? undefined : traceId });
|
|
208
229
|
}
|
|
209
230
|
/**
|
|
210
231
|
* 弹出信息提示(右上角)。
|
package/dist/types.d.ts
CHANGED
|
@@ -1299,6 +1299,33 @@ export interface EmptyProps extends DataAttributes {
|
|
|
1299
1299
|
/** 自定义图标插槽 */
|
|
1300
1300
|
children?: Snippet;
|
|
1301
1301
|
}
|
|
1302
|
+
/**
|
|
1303
|
+
* JSON 查看器属性
|
|
1304
|
+
*
|
|
1305
|
+
* @example
|
|
1306
|
+
* ```svelte
|
|
1307
|
+
* <script lang="ts">
|
|
1308
|
+
* import { JsonViewer } from '@h-ai/ui'
|
|
1309
|
+
* import type { JsonViewerProps } from '@h-ai/ui'
|
|
1310
|
+
* const props: JsonViewerProps = { value: { name: 'wf', nested: { list: [1, 2] } } }
|
|
1311
|
+
* </script>
|
|
1312
|
+
* <JsonViewer {...props} />
|
|
1313
|
+
* ```
|
|
1314
|
+
*/
|
|
1315
|
+
export interface JsonViewerProps extends DataAttributes {
|
|
1316
|
+
/** 要展示的 JSON 数据;循环引用自动替换为占位符 */
|
|
1317
|
+
value: unknown;
|
|
1318
|
+
/** 初始展开深度;0 表示全部折叠,1 展开顶层容器 */
|
|
1319
|
+
defaultExpandedDepth?: number;
|
|
1320
|
+
/** 标量文本截断长度;超出部分以省略号结尾 */
|
|
1321
|
+
maxScalarLength?: number;
|
|
1322
|
+
/** 是否显示复制按钮 */
|
|
1323
|
+
showCopy?: boolean;
|
|
1324
|
+
/** 自定义类名 */
|
|
1325
|
+
class?: string;
|
|
1326
|
+
/** 复制成功后的回调,参数为复制的格式化 JSON 文本 */
|
|
1327
|
+
onCopy?: (text: string) => void;
|
|
1328
|
+
}
|
|
1302
1329
|
/**
|
|
1303
1330
|
* 结果页属性
|
|
1304
1331
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.72",
|
|
5
5
|
"description": "Hai Framework UI component library for Svelte 5 Runes.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"svelte": "./dist/index.js",
|
|
@@ -119,8 +119,9 @@
|
|
|
119
119
|
"svelte": "^5.57.2"
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
122
|
+
"@h-ai/core": "0.1.0-alpha.72",
|
|
123
123
|
"@internationalized/date": "^3.12.4",
|
|
124
|
+
"@rrweb/replay": "^2.1.7",
|
|
124
125
|
"@shikijs/langs": "^4.5.0",
|
|
125
126
|
"bits-ui": "^2.19.5",
|
|
126
127
|
"driver.js": "1.9.0",
|