waveform-analysis 0.1.47 → 0.1.50
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.md +127 -5
- package/dist/assets/workerRuntime-Dt94jbqq.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2701 -1165
- package/dist/style.css +1 -1
- package/dist/types/components/WaveformChart.vue.d.ts +14 -0
- package/dist/types/components/annotation/WaveformAnnotationEditor.vue.d.ts +0 -1
- package/dist/types/components/annotation/markup.d.ts +5 -6
- package/dist/types/components/annotation/types.d.ts +2 -0
- package/dist/types/components/core/latestTaskScheduler.d.ts +19 -0
- package/dist/types/components/core/layout.d.ts +2 -2
- package/dist/types/components/core/trackLayoutBuilder.d.ts +4 -1
- package/dist/types/components/core/types.d.ts +2 -0
- package/dist/types/components/core/useWaveformChartController.d.ts +1 -0
- package/dist/types/components/core/useWaveformData.d.ts +2 -0
- package/dist/types/components/core/useWaveformLayout.d.ts +2 -0
- package/dist/types/components/core/useWaveformRenderSampling.d.ts +19 -0
- package/dist/types/components/core/waveformChartTypes.d.ts +8 -1
- package/dist/types/components/core/workerSamplingClient.d.ts +8 -0
- package/dist/types/components/data/types.d.ts +1 -1
- package/dist/types/components/interaction/zoomConstraints.d.ts +2 -0
- package/dist/types/components/waveform.d.ts +1 -1
- package/dist/types/core/compactSamplePointSource.d.ts +3 -0
- package/dist/types/core/data.d.ts +7 -1
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/rendering.d.ts +3 -1
- package/dist/types/core/renderingOptions.d.ts +11 -1
- package/dist/types/core/samplingReference.d.ts +36 -0
- package/dist/types/core/samplingReferenceValues.d.ts +4 -0
- package/dist/types/core/samplingReferenceVectors.d.ts +17 -0
- package/dist/types/core/wasmSampling.d.ts +48 -0
- package/dist/types/core/waveformPointSource.d.ts +53 -0
- package/dist/types/core/workerSampling/index.d.ts +5 -0
- package/dist/types/core/workerSampling/javascriptBackend.d.ts +3 -0
- package/dist/types/core/workerSampling/multiresolution.d.ts +29 -0
- package/dist/types/core/workerSampling/protocol.d.ts +153 -0
- package/dist/types/core/workerSampling/repository.d.ts +36 -0
- package/dist/types/core/workerSampling/repositoryDataset.d.ts +29 -0
- package/dist/types/core/workerSampling/repositorySupport.d.ts +27 -0
- package/dist/types/core/workerSampling/samplingCache.d.ts +24 -0
- package/dist/types/core/workerSampling/workerRuntime.d.ts +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types/chart.d.ts +58 -0
- package/dist/types/types/data.d.ts +20 -2
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/views/WasmSamplingDemo.vue.d.ts +3 -0
- package/package.json +5 -4
- package/src/App.test.ts +11 -7
- package/src/App.vue +2 -2
- package/src/DemoRouterApp.vue +1 -0
- package/src/components/WaveformChart.css +2 -0
- package/src/components/annotation/WaveformAnnotationEditor.css +2 -2
- package/src/components/annotation/WaveformAnnotationEditor.vue +8 -4
- package/src/components/annotation/markup.ts +45 -26
- package/src/components/annotation/types.ts +2 -0
- package/src/components/annotation/useWaveformChartAnnotations.ts +12 -15
- package/src/components/core/latestTaskScheduler.test.ts +51 -0
- package/src/components/core/latestTaskScheduler.ts +75 -0
- package/src/components/core/layout.ts +15 -6
- package/src/components/core/trackLayoutBuilder.ts +8 -2
- package/src/components/core/types.ts +2 -0
- package/src/components/core/useWaveformChartController.ts +14 -0
- package/src/components/core/useWaveformData.test.ts +95 -0
- package/src/components/core/useWaveformData.ts +23 -32
- package/src/components/core/useWaveformLayout.ts +16 -10
- package/src/components/core/useWaveformRenderSampling.test.ts +17 -0
- package/src/components/core/useWaveformRenderSampling.ts +394 -0
- package/src/components/core/waveformChartTypes.ts +13 -0
- package/src/components/core/workerSamplingClient.ts +148 -0
- package/src/components/core/yAxisNice.test.ts +174 -0
- package/src/components/data/types.ts +9 -0
- package/src/components/interaction/WaveformTooltip.test.ts +1 -3
- package/src/components/interaction/WaveformTooltip.vue +13 -12
- package/src/components/interaction/useWaveformHover.ts +7 -7
- package/src/components/interaction/zoomConstraints.ts +5 -1
- package/src/components/waveform.ts +9 -0
- package/src/components/waveformChartCases/compactAndSharedHover.test.ts +15 -4
- package/src/components/waveformChartCases/dataAndHoverPerformance.test.ts +11 -6
- package/src/components/waveformChartCases/dataLifecycle.test.ts +1 -3
- package/src/components/waveformChartCases/trackOrder.test.ts +130 -0
- package/src/components/waveformChartCases/workerSamplingIntegration.test.ts +117 -0
- package/src/components/waveformChartCases/xDomainStrategy.test.ts +14 -2
- package/src/core/compactSamplePointSource.ts +76 -0
- package/src/core/data.test.ts +114 -0
- package/src/core/data.ts +177 -75
- package/src/core/index.ts +11 -0
- package/src/core/rendering.test.ts +87 -12
- package/src/core/rendering.ts +35 -1
- package/src/core/renderingOptions.ts +124 -15
- package/src/core/samplingReference.test.ts +124 -0
- package/src/core/samplingReference.ts +243 -0
- package/src/core/samplingReferenceValues.ts +169 -0
- package/src/core/samplingReferenceVectors.ts +46 -0
- package/src/core/wasmSampling.test.ts +205 -0
- package/src/core/wasmSampling.ts +230 -0
- package/src/core/waveformPointSource.ts +395 -0
- package/src/core/workerSampling/index.ts +30 -0
- package/src/core/workerSampling/javascriptBackend.ts +15 -0
- package/src/core/workerSampling/multiresolution.test.ts +69 -0
- package/src/core/workerSampling/multiresolution.ts +300 -0
- package/src/core/workerSampling/protocol.test.ts +34 -0
- package/src/core/workerSampling/protocol.ts +207 -0
- package/src/core/workerSampling/repository.test.ts +400 -0
- package/src/core/workerSampling/repository.ts +400 -0
- package/src/core/workerSampling/repositoryCache.test.ts +163 -0
- package/src/core/workerSampling/repositoryDataset.ts +194 -0
- package/src/core/workerSampling/repositorySupport.ts +225 -0
- package/src/core/workerSampling/repositoryTypedDataset.test.ts +89 -0
- package/src/core/workerSampling/repositoryWasmDataset.test.ts +70 -0
- package/src/core/workerSampling/samplingCache.ts +94 -0
- package/src/core/workerSampling/workerRuntime.ts +40 -0
- package/src/data/simulatedWaveforms.test.ts +19 -0
- package/src/data/simulatedWaveforms.ts +11 -8
- package/src/demo/xAxisLabelControls.test.ts +1 -1
- package/src/demoRoutes.css +177 -0
- package/src/index.ts +18 -0
- package/src/router.ts +5 -0
- package/src/types/chart.ts +65 -0
- package/src/types/data.ts +24 -1
- package/src/types/index.ts +9 -0
- package/src/views/WasmSamplingDemo.test.ts +13 -0
- package/src/views/WasmSamplingDemo.vue +180 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, reactive, ref } from 'vue'
|
|
3
|
+
import { InputNumber, RadioButton, RadioGroup, Select } from 'ant-design-vue'
|
|
4
|
+
|
|
5
|
+
import { WaveformChart } from '../components'
|
|
6
|
+
import type {
|
|
7
|
+
WaveformData,
|
|
8
|
+
WaveformRenderingOptions,
|
|
9
|
+
WaveformSamplingDiagnostics,
|
|
10
|
+
WaveformSamplingMode,
|
|
11
|
+
WaveformSamplingStrategy,
|
|
12
|
+
} from '../types'
|
|
13
|
+
|
|
14
|
+
const SERIES_COUNT = 10
|
|
15
|
+
const POINTS_PER_SERIES = 100_000
|
|
16
|
+
|
|
17
|
+
const colors = [
|
|
18
|
+
'#1677ff',
|
|
19
|
+
'#d4380d',
|
|
20
|
+
'#389e0d',
|
|
21
|
+
'#d46b08',
|
|
22
|
+
'#08979c',
|
|
23
|
+
'#c41d7f',
|
|
24
|
+
'#531dab',
|
|
25
|
+
'#096dd9',
|
|
26
|
+
'#ad6800',
|
|
27
|
+
'#237804',
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
const strategyOptions: Array<{ label: string; value: WaveformSamplingStrategy }> = [
|
|
31
|
+
{ label: '自动(peak)', value: 'auto' },
|
|
32
|
+
{ label: 'Peak', value: 'peak' },
|
|
33
|
+
{ label: 'LTTB', value: 'lttb' },
|
|
34
|
+
{ label: 'MinMax', value: 'minmax' },
|
|
35
|
+
{ label: 'Min', value: 'min' },
|
|
36
|
+
{ label: 'Max', value: 'max' },
|
|
37
|
+
{ label: 'Average', value: 'average' },
|
|
38
|
+
{ label: 'Sum', value: 'sum' },
|
|
39
|
+
{ label: 'None', value: 'none' },
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
function createDenseData(): WaveformData {
|
|
43
|
+
return {
|
|
44
|
+
kind: 'series',
|
|
45
|
+
series: Array.from({ length: SERIES_COUNT }, (_, seriesIndex) => {
|
|
46
|
+
const values = new Float32Array(POINTS_PER_SERIES)
|
|
47
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
48
|
+
const t = index / 1_000
|
|
49
|
+
const pulse = index % (8_123 + seriesIndex * 113) < 3 ? 3.5 + seriesIndex / 4 : 0
|
|
50
|
+
values[index] =
|
|
51
|
+
Math.sin(t * (0.8 + seriesIndex / 14)) * (1.2 + seriesIndex / 10) +
|
|
52
|
+
Math.cos(t * (2.1 + seriesIndex / 20)) * 0.35 +
|
|
53
|
+
pulse
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
id: `dense-${seriesIndex + 1}`,
|
|
57
|
+
trackId: 'dense-overlay',
|
|
58
|
+
name: `通道 ${String(seriesIndex + 1).padStart(2, '0')}`,
|
|
59
|
+
color: colors[seriesIndex],
|
|
60
|
+
data: { kind: 'typed-samples' as const, values, sampleRate: 1_000 },
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const data = createDenseData()
|
|
67
|
+
const mode = ref<WaveformSamplingMode>('auto')
|
|
68
|
+
const strategy = ref<WaveformSamplingStrategy>('peak')
|
|
69
|
+
const autoThreshold = ref(1_000)
|
|
70
|
+
const maxPointsPerPixel = ref(3)
|
|
71
|
+
const diagnostics = reactive<Record<string, WaveformSamplingDiagnostics | undefined>>({})
|
|
72
|
+
|
|
73
|
+
const rendering = computed<WaveformRenderingOptions>(() => ({
|
|
74
|
+
sampling: {
|
|
75
|
+
mode: mode.value,
|
|
76
|
+
strategy: strategy.value,
|
|
77
|
+
autoThreshold: autoThreshold.value,
|
|
78
|
+
maxPointsPerPixel: maxPointsPerPixel.value,
|
|
79
|
+
rawPointLimit: 100_000,
|
|
80
|
+
wasmFailureFallback: 'javascript',
|
|
81
|
+
},
|
|
82
|
+
}))
|
|
83
|
+
const rows = computed(() =>
|
|
84
|
+
Array.from({ length: SERIES_COUNT }, (_, index) => {
|
|
85
|
+
const id = `dense-${index + 1}`
|
|
86
|
+
return { id, name: `通道 ${String(index + 1).padStart(2, '0')}`, diagnostic: diagnostics[id] }
|
|
87
|
+
}),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
function onSamplingComplete(diagnostic: WaveformSamplingDiagnostics) {
|
|
91
|
+
diagnostics[diagnostic.seriesId] = diagnostic
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function pointCount(value: number | undefined) {
|
|
95
|
+
return value === undefined ? '--' : value.toLocaleString('en-US')
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<template>
|
|
100
|
+
<main class="sampling-demo">
|
|
101
|
+
<header class="sampling-demo__toolbar">
|
|
102
|
+
<div>
|
|
103
|
+
<h1>WASM 多分辨率采样</h1>
|
|
104
|
+
<p>10 条 TypedArray 通道,每条 {{ POINTS_PER_SERIES.toLocaleString('en-US') }} 点</p>
|
|
105
|
+
</div>
|
|
106
|
+
<RadioGroup v-model:value="mode" button-style="solid" aria-label="采样执行模式">
|
|
107
|
+
<RadioButton value="auto">Auto</RadioButton>
|
|
108
|
+
<RadioButton value="wasm">WASM</RadioButton>
|
|
109
|
+
<RadioButton value="raw">Raw</RadioButton>
|
|
110
|
+
</RadioGroup>
|
|
111
|
+
</header>
|
|
112
|
+
|
|
113
|
+
<section class="sampling-demo__controls" aria-label="采样参数">
|
|
114
|
+
<label>
|
|
115
|
+
<span>策略</span>
|
|
116
|
+
<Select v-model:value="strategy" :options="strategyOptions" size="small" />
|
|
117
|
+
</label>
|
|
118
|
+
<label>
|
|
119
|
+
<span>阈值</span>
|
|
120
|
+
<InputNumber
|
|
121
|
+
v-model:value="autoThreshold"
|
|
122
|
+
:min="1"
|
|
123
|
+
:max="100000"
|
|
124
|
+
:step="100"
|
|
125
|
+
size="small"
|
|
126
|
+
/>
|
|
127
|
+
</label>
|
|
128
|
+
<label>
|
|
129
|
+
<span>每像素点数</span>
|
|
130
|
+
<InputNumber
|
|
131
|
+
v-model:value="maxPointsPerPixel"
|
|
132
|
+
:min="0.25"
|
|
133
|
+
:max="16"
|
|
134
|
+
:step="0.25"
|
|
135
|
+
size="small"
|
|
136
|
+
/>
|
|
137
|
+
</label>
|
|
138
|
+
</section>
|
|
139
|
+
|
|
140
|
+
<section class="sampling-demo__workspace">
|
|
141
|
+
<div class="sampling-demo__chart">
|
|
142
|
+
<WaveformChart
|
|
143
|
+
:data="data"
|
|
144
|
+
:rendering="rendering"
|
|
145
|
+
:grid="{ rowCount: 1, columnCount: 1, showPagination: false }"
|
|
146
|
+
:legend="{ position: 'top-right', orientation: 'vertical' }"
|
|
147
|
+
:title="{ visible: true, text: '多系列采样与缓存诊断', align: 'left' }"
|
|
148
|
+
x-label="时间(s)"
|
|
149
|
+
time-unit="s"
|
|
150
|
+
@sampling-complete="onSamplingComplete"
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<aside class="sampling-demo__diagnostics" aria-label="每系列采样诊断">
|
|
155
|
+
<div class="sampling-demo__diagnostic-header">
|
|
156
|
+
<span>系列</span>
|
|
157
|
+
<span>后端</span>
|
|
158
|
+
<span>源点</span>
|
|
159
|
+
<span>可见</span>
|
|
160
|
+
<span>渲染</span>
|
|
161
|
+
<span>耗时</span>
|
|
162
|
+
<span>缓存</span>
|
|
163
|
+
</div>
|
|
164
|
+
<div v-for="row in rows" :key="row.id" class="sampling-demo__diagnostic-row">
|
|
165
|
+
<span data-label="系列">{{ row.name }}</span>
|
|
166
|
+
<span data-label="后端">{{ row.diagnostic?.backend ?? '--' }}</span>
|
|
167
|
+
<span data-label="源点">{{ pointCount(row.diagnostic?.sourcePointCount) }}</span>
|
|
168
|
+
<span data-label="可见">{{ pointCount(row.diagnostic?.visiblePointCount) }}</span>
|
|
169
|
+
<span data-label="渲染">{{ pointCount(row.diagnostic?.renderedPointCount) }}</span>
|
|
170
|
+
<span data-label="耗时">{{
|
|
171
|
+
row.diagnostic ? `${row.diagnostic.durationMs.toFixed(2)} ms` : '--'
|
|
172
|
+
}}</span>
|
|
173
|
+
<span data-label="缓存" :class="{ 'is-hit': row.diagnostic?.cacheHit }">
|
|
174
|
+
{{ row.diagnostic ? (row.diagnostic.cacheHit ? '命中' : '未命中') : '--' }}
|
|
175
|
+
</span>
|
|
176
|
+
</div>
|
|
177
|
+
</aside>
|
|
178
|
+
</section>
|
|
179
|
+
</main>
|
|
180
|
+
</template>
|