@h-ai/ui 0.1.0-alpha.70 → 0.1.0-alpha.71
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 +16 -6
- package/README.ja.md +16 -6
- package/README.md +16 -6
- 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 +85 -20
- package/dist/components/scenes/app/FeedbackForm.svelte.d.ts +14 -3
- package/dist/components/scenes/app/FeedbackList.svelte +3 -2
- package/dist/components/scenes/app/FeedbackModal.svelte +49 -1
- 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 +27 -9
- package/dist/messages/ja-JP.json +27 -9
- package/dist/messages/zh-CN.json +27 -9
- package/dist/toast.svelte.d.ts +9 -0
- package/dist/toast.svelte.js +25 -4
- package/package.json +3 -2
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<!-- 浏览器原生短录屏;用户主动授权,无声音,停止后交给宿主准备附件。 -->
|
|
2
|
+
<script lang='ts'>
|
|
3
|
+
import { onMount } from 'svelte'
|
|
4
|
+
import { uiM } from '../../../messages.js'
|
|
5
|
+
import { errorMessage } from '../../../toast.svelte.js'
|
|
6
|
+
import { portal } from '../../../utils.js'
|
|
7
|
+
import Button from '../../primitives/Button.svelte'
|
|
8
|
+
|
|
9
|
+
const { disabled = false, maxBytes = 5 * 1024 * 1024, onrecord, onactive }: {
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
maxBytes?: number
|
|
12
|
+
onrecord: (file: File) => Promise<void>
|
|
13
|
+
onactive: (active: boolean) => void
|
|
14
|
+
} = $props()
|
|
15
|
+
let supported = $state(false)
|
|
16
|
+
let expanded = $state(false)
|
|
17
|
+
let active = $state(false)
|
|
18
|
+
let busy = $state(false)
|
|
19
|
+
let seconds = $state(0)
|
|
20
|
+
let error = $state('')
|
|
21
|
+
let recorder: MediaRecorder | undefined
|
|
22
|
+
let stream: MediaStream | undefined
|
|
23
|
+
let timer: ReturnType<typeof setInterval> | undefined
|
|
24
|
+
let mounted = true
|
|
25
|
+
let cancelled = false
|
|
26
|
+
|
|
27
|
+
function release() {
|
|
28
|
+
clearInterval(timer)
|
|
29
|
+
timer = undefined
|
|
30
|
+
for (const track of stream?.getTracks() ?? [])
|
|
31
|
+
track.stop()
|
|
32
|
+
stream = undefined
|
|
33
|
+
}
|
|
34
|
+
function stop(discard = false) {
|
|
35
|
+
cancelled ||= discard
|
|
36
|
+
if (recorder?.state === 'recording') {
|
|
37
|
+
recorder.stop()
|
|
38
|
+
// 正常停止先让编码器发送最终数据;取消/卸载立即释放,正常路径由 onstop 释放。
|
|
39
|
+
if (!discard)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
release()
|
|
43
|
+
}
|
|
44
|
+
async function start() {
|
|
45
|
+
if (busy || active || disabled)
|
|
46
|
+
return
|
|
47
|
+
busy = true
|
|
48
|
+
error = ''
|
|
49
|
+
cancelled = false
|
|
50
|
+
try {
|
|
51
|
+
// 必须直接来自点击事件,保留浏览器的用户激活授权。
|
|
52
|
+
const selected = await navigator.mediaDevices.getDisplayMedia({ video: { width: 1280, height: 720, frameRate: 10 }, audio: false })
|
|
53
|
+
if (!mounted) {
|
|
54
|
+
selected.getTracks().forEach(track => track.stop())
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
stream = selected
|
|
58
|
+
const mimeType = ['video/webm;codecs=vp8', 'video/webm', 'video/mp4'].find(type => MediaRecorder.isTypeSupported(type))
|
|
59
|
+
if (!mimeType)
|
|
60
|
+
throw new Error('No supported recording format')
|
|
61
|
+
const current = new MediaRecorder(stream, { mimeType, videoBitsPerSecond: 500_000 })
|
|
62
|
+
recorder = current
|
|
63
|
+
const chunks: Blob[] = []
|
|
64
|
+
let size = 0
|
|
65
|
+
current.ondataavailable = (event) => {
|
|
66
|
+
if (event.data.size) {
|
|
67
|
+
chunks.push(event.data)
|
|
68
|
+
size += event.data.size
|
|
69
|
+
if (size >= maxBytes * 0.9)
|
|
70
|
+
stop()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
current.onerror = (event) => {
|
|
74
|
+
cancelled = true
|
|
75
|
+
error = errorMessage('error' in event ? event.error : new Error('MediaRecorder failed'), uiM('feedback_record_failed'))
|
|
76
|
+
stop(true)
|
|
77
|
+
}
|
|
78
|
+
current.onstart = () => {
|
|
79
|
+
// 原生编码器可能延迟启动;录制时长必须从实际开始采集时计算。
|
|
80
|
+
if (!mounted || cancelled || current.state !== 'recording')
|
|
81
|
+
return
|
|
82
|
+
const started = Date.now()
|
|
83
|
+
timer = setInterval(() => {
|
|
84
|
+
seconds = Math.floor((Date.now() - started) / 1000)
|
|
85
|
+
if (seconds >= 60)
|
|
86
|
+
stop()
|
|
87
|
+
}, 250)
|
|
88
|
+
}
|
|
89
|
+
current.onstop = async () => {
|
|
90
|
+
release()
|
|
91
|
+
active = false
|
|
92
|
+
busy = true
|
|
93
|
+
try {
|
|
94
|
+
if (!mounted || cancelled)
|
|
95
|
+
return
|
|
96
|
+
if (!size || size > maxBytes) {
|
|
97
|
+
error = errorMessage(new Error('Recording output was empty or exceeded budget', { cause: { size, maxBytes, seconds, mimeType } }), uiM('feedback_record_empty'))
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
const type = mimeType.split(';')[0]!
|
|
101
|
+
await onrecord(new File(chunks, `recording-${Date.now()}.${type === 'video/mp4' ? 'mp4' : 'webm'}`, { type }))
|
|
102
|
+
expanded = false
|
|
103
|
+
}
|
|
104
|
+
catch (cause) {
|
|
105
|
+
error = errorMessage(cause, uiM('feedback_record_failed'))
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
busy = false
|
|
109
|
+
if (mounted)
|
|
110
|
+
onactive(false)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const track of stream.getVideoTracks())
|
|
114
|
+
track.addEventListener('ended', () => stop(), { once: true })
|
|
115
|
+
current.start(1000)
|
|
116
|
+
seconds = 0
|
|
117
|
+
active = true
|
|
118
|
+
onactive(true)
|
|
119
|
+
}
|
|
120
|
+
catch (cause) {
|
|
121
|
+
release()
|
|
122
|
+
error = errorMessage(cause, uiM('feedback_record_failed'))
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
busy = false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
onMount(() => {
|
|
130
|
+
supported = typeof MediaRecorder !== 'undefined' && typeof navigator.mediaDevices?.getDisplayMedia === 'function'
|
|
131
|
+
return () => {
|
|
132
|
+
mounted = false
|
|
133
|
+
stop(true)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<div class='space-y-2 min-w-0'>
|
|
139
|
+
<Button size='sm' variant='ghost' disabled={disabled || active || busy} onclick={() => expanded = !expanded}>{uiM('feedback_record')}</Button>
|
|
140
|
+
{#if expanded}
|
|
141
|
+
<p class='text-xs text-base-content/65'>{supported ? uiM('feedback_record_hint', { size: (maxBytes / 1048576).toFixed(1) }) : uiM('feedback_record_unsupported')}</p>
|
|
142
|
+
{#if supported}<Button size='sm' loading={busy} disabled={disabled || active} onclick={start}>{uiM('feedback_record_start')}</Button>{/if}
|
|
143
|
+
{/if}
|
|
144
|
+
{#if error}<p class='text-error text-sm break-words' role='alert'>{error}</p>{/if}
|
|
145
|
+
</div>
|
|
146
|
+
{#if active}
|
|
147
|
+
<div use:portal class='fixed bottom-4 inset-x-4 z-[1200] mx-auto flex max-w-xl flex-wrap items-center justify-between gap-3 rounded-xl border border-error/25 bg-base-100 p-4 shadow-xl' data-feedback-ignore='true'>
|
|
148
|
+
<p class='text-sm' role='status'>{uiM('feedback_recording', { seconds })}</p>
|
|
149
|
+
<div class='flex gap-2'>
|
|
150
|
+
<Button size='sm' variant='ghost' onclick={() => stop(true)}>{uiM('feedback_record_cancel')}</Button>
|
|
151
|
+
<Button size='sm' variant='error' onclick={() => stop()}>{uiM('feedback_record_stop')}</Button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
maxBytes?: number;
|
|
4
|
+
onrecord: (file: File) => Promise<void>;
|
|
5
|
+
onactive: (active: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
declare const FeedbackRecorder: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type FeedbackRecorder = ReturnType<typeof FeedbackRecorder>;
|
|
9
|
+
export default FeedbackRecorder;
|
|
@@ -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,35 @@
|
|
|
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}"
|
|
462
480
|
}
|
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,35 @@
|
|
|
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} 件"
|
|
462
480
|
}
|