svelte-tweakpane-ui 1.0.0
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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/control/ButtonGrid.svelte +49 -0
- package/dist/control/ButtonGrid.svelte.d.ts +190 -0
- package/dist/control/Checkbox.svelte +6 -0
- package/dist/control/Checkbox.svelte.d.ts +113 -0
- package/dist/control/Color.svelte +79 -0
- package/dist/control/Color.svelte.d.ts +177 -0
- package/dist/control/CubicBezier.svelte +74 -0
- package/dist/control/CubicBezier.svelte.d.ts +204 -0
- package/dist/control/Image.svelte +23 -0
- package/dist/control/Image.svelte.d.ts +177 -0
- package/dist/control/IntervalSlider.svelte +37 -0
- package/dist/control/IntervalSlider.svelte.d.ts +196 -0
- package/dist/control/List.svelte +69 -0
- package/dist/control/List.svelte.d.ts +122 -0
- package/dist/control/Point.svelte +100 -0
- package/dist/control/Point.svelte.d.ts +374 -0
- package/dist/control/RadioGrid.svelte +42 -0
- package/dist/control/RadioGrid.svelte.d.ts +231 -0
- package/dist/control/Ring.svelte +19 -0
- package/dist/control/Ring.svelte.d.ts +220 -0
- package/dist/control/RotationEuler.svelte +67 -0
- package/dist/control/RotationEuler.svelte.d.ts +273 -0
- package/dist/control/RotationQuaternion.svelte +65 -0
- package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
- package/dist/control/Slider.svelte +6 -0
- package/dist/control/Slider.svelte.d.ts +165 -0
- package/dist/control/Text.svelte +25 -0
- package/dist/control/Text.svelte.d.ts +129 -0
- package/dist/control/Textarea.svelte +47 -0
- package/dist/control/Textarea.svelte.d.ts +149 -0
- package/dist/control/Wheel.svelte +15 -0
- package/dist/control/Wheel.svelte.d.ts +186 -0
- package/dist/core/Binding.svelte +68 -0
- package/dist/core/Binding.svelte.d.ts +116 -0
- package/dist/core/Blade.svelte +61 -0
- package/dist/core/Blade.svelte.d.ts +90 -0
- package/dist/core/Button.svelte +59 -0
- package/dist/core/Button.svelte.d.ts +65 -0
- package/dist/core/Folder.svelte +69 -0
- package/dist/core/Folder.svelte.d.ts +78 -0
- package/dist/core/Pane.svelte +51 -0
- package/dist/core/Pane.svelte.d.ts +500 -0
- package/dist/core/Separator.svelte +14 -0
- package/dist/core/Separator.svelte.d.ts +85 -0
- package/dist/core/TabGroup.svelte +64 -0
- package/dist/core/TabGroup.svelte.d.ts +72 -0
- package/dist/core/TabPage.svelte +85 -0
- package/dist/core/TabPage.svelte.d.ts +82 -0
- package/dist/extra/AutoObject.svelte +46 -0
- package/dist/extra/AutoObject.svelte.d.ts +108 -0
- package/dist/extra/AutoValue.svelte +11 -0
- package/dist/extra/AutoValue.svelte.d.ts +123 -0
- package/dist/extra/Element.svelte +53 -0
- package/dist/extra/Element.svelte.d.ts +170 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +39 -0
- package/dist/internal/ClsPad.svelte +34 -0
- package/dist/internal/ClsPad.svelte.d.ts +95 -0
- package/dist/internal/GenericBinding.svelte +22 -0
- package/dist/internal/GenericBinding.svelte.d.ts +116 -0
- package/dist/internal/GenericBladeFolding.svelte +38 -0
- package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
- package/dist/internal/GenericInput.svelte +19 -0
- package/dist/internal/GenericInput.svelte.d.ts +116 -0
- package/dist/internal/GenericInputFolding.svelte +40 -0
- package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
- package/dist/internal/GenericMonitor.svelte +24 -0
- package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
- package/dist/internal/GenericPane.svelte +100 -0
- package/dist/internal/GenericPane.svelte.d.ts +84 -0
- package/dist/internal/GenericSlider.svelte +27 -0
- package/dist/internal/GenericSlider.svelte.d.ts +146 -0
- package/dist/internal/InternalMonitorBoolean.svelte +17 -0
- package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
- package/dist/internal/InternalMonitorNumber.svelte +31 -0
- package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
- package/dist/internal/InternalMonitorString.svelte +23 -0
- package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
- package/dist/internal/InternalPaneDraggable.svelte +368 -0
- package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
- package/dist/internal/InternalPaneFixed.svelte +28 -0
- package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
- package/dist/internal/InternalPaneInline.svelte +29 -0
- package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
- package/dist/monitor/FpsGraph.svelte +86 -0
- package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
- package/dist/monitor/Monitor.svelte +14 -0
- package/dist/monitor/Monitor.svelte.d.ts +526 -0
- package/dist/monitor/Profiler.svelte +72 -0
- package/dist/monitor/Profiler.svelte.d.ts +265 -0
- package/dist/monitor/WaveformMonitor.svelte +26 -0
- package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
- package/dist/theme.d.ts +91 -0
- package/dist/theme.js +332 -0
- package/dist/utils.d.ts +157 -0
- package/dist/utils.js +238 -0
- package/package.json +280 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { ProfilerBladeMeasureHandler } from '@0b5vr/tweakpane-plugin-profiler';
|
|
3
|
+
import type { Simplify } from '../utils';
|
|
4
|
+
export type ProfilerCalcMode = 'frame' | 'mean' | 'median';
|
|
5
|
+
export type ProfilerChangeEvent = CustomEvent<number>;
|
|
6
|
+
export type ProfilerMeasure = (name: string, fn: () => void) => void;
|
|
7
|
+
export type ProfilerMeasureAsync = (name: string, fn: () => Promise<void>) => Promise<void>;
|
|
8
|
+
export type ProfilerMeasureHandler = Simplify<ProfilerBladeMeasureHandler>;
|
|
9
|
+
import type { ProfilerBladeApi as ProfilerRef } from '@0b5vr/tweakpane-plugin-profiler/dist/types/ProfilerBladeApi.js';
|
|
10
|
+
import type { ProfilerBladePluginParams as ProfilerOptions } from '@0b5vr/tweakpane-plugin-profiler/dist/types/ProfilerBladePluginParams.js';
|
|
11
|
+
declare const __propDef: {
|
|
12
|
+
props: {
|
|
13
|
+
/**
|
|
14
|
+
* Function handle that wraps another function to measure its execution duration.
|
|
15
|
+
*
|
|
16
|
+
* If you want to measure something other than execution duration, customize
|
|
17
|
+
* `ProfilerBladeDefaultMeasureHandler`.
|
|
18
|
+
*
|
|
19
|
+
* @example `measure('Hard Work', () => { ... })`;
|
|
20
|
+
* @bindable
|
|
21
|
+
* @readonly
|
|
22
|
+
* @default `undefined`
|
|
23
|
+
*/
|
|
24
|
+
measure?: ProfilerMeasure | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Async variation of function handle that wraps another function to measure its execution
|
|
27
|
+
* duration.
|
|
28
|
+
*
|
|
29
|
+
* @example `measureAsync('Hard Work', async () => { ... })`;
|
|
30
|
+
* @bindable
|
|
31
|
+
* @async
|
|
32
|
+
* @readonly
|
|
33
|
+
* @default `undefined`
|
|
34
|
+
*/
|
|
35
|
+
measureAsync?: ProfilerMeasureAsync | undefined;
|
|
36
|
+
} & Omit<
|
|
37
|
+
{
|
|
38
|
+
/**
|
|
39
|
+
* Blade configuration exposing Tweakpane's internal
|
|
40
|
+
* [`BladeParams`](https://tweakpane.github.io/docs/api/interfaces/BaseBladeParams.html).
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
options: ProfilerOptions;
|
|
44
|
+
/**
|
|
45
|
+
* Prevent interactivity and gray out the control.
|
|
46
|
+
* @default `false`
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Custom color scheme.
|
|
51
|
+
* @default `undefined` \
|
|
52
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
53
|
+
* set with `setGlobalDefaultTheme()`.
|
|
54
|
+
*/
|
|
55
|
+
theme?: import('..').Theme | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Reference to internal Tweakpane
|
|
58
|
+
* [`BladeApi`](https://tweakpane.github.io/docs/api/classes/BladeApi.html) for this blade.
|
|
59
|
+
*
|
|
60
|
+
* This is primarily for internal use, when implementing convenience components wrapping Blade's
|
|
61
|
+
* functionality.
|
|
62
|
+
* @bindable
|
|
63
|
+
* @readonly
|
|
64
|
+
*/
|
|
65
|
+
ref?: ProfilerRef | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Imported Tweakpane `TpPluginBundle` (Aliased as `Plugin`) module to register before creating
|
|
68
|
+
* the blade.
|
|
69
|
+
*
|
|
70
|
+
* This is primarily for internal use, when implementing convenience components wrapping Blade's
|
|
71
|
+
* functionality in combination with a Tweakpane plugin.
|
|
72
|
+
* @default `undefined`
|
|
73
|
+
*/
|
|
74
|
+
plugin?: import('tweakpane').TpPluginBundle | undefined;
|
|
75
|
+
},
|
|
76
|
+
'options' | 'ref' | 'plugin'
|
|
77
|
+
> & {
|
|
78
|
+
/**
|
|
79
|
+
* Number of duration samples from which to calculate the delta value when `calcMode` is
|
|
80
|
+
* `'mean'` or `'median'`.
|
|
81
|
+
* @default `30`
|
|
82
|
+
*/
|
|
83
|
+
bufferSize?: number | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* How to calculate the delta value.
|
|
86
|
+
*
|
|
87
|
+
* `'frame'` takes only the latest sample into account, while `'mean'` and `'median'` are
|
|
88
|
+
* calculated from the samples in the buffer.
|
|
89
|
+
* @default `'mean'`
|
|
90
|
+
*/
|
|
91
|
+
calcMode?: ProfilerCalcMode | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Label suffix for the delta values shown in the control.
|
|
94
|
+
*
|
|
95
|
+
* Possibly useful if you're using a custom `ProfilerBladeDefaultMeasureHandler` and are
|
|
96
|
+
* measuring something other than time.
|
|
97
|
+
* @default `'ms'`
|
|
98
|
+
* */
|
|
99
|
+
deltaUnit?: string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Precision of the delta values shown in the control.
|
|
102
|
+
* @default `2`
|
|
103
|
+
*/
|
|
104
|
+
fractionDigits?: number | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Milliseconds between updates to the profiler visualization and delta label text.
|
|
107
|
+
*
|
|
108
|
+
* Note that this does not affect the internal sampling rate of the profiler itself, which
|
|
109
|
+
* is determined by your calls to the bound `measure` function.
|
|
110
|
+
* @default `500`
|
|
111
|
+
*/
|
|
112
|
+
interval?: number | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Text displayed next to the profiler visualization.
|
|
115
|
+
* @default `undefined`
|
|
116
|
+
* */
|
|
117
|
+
label?: string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Function handle that wraps another function to measure its execution duration.
|
|
120
|
+
*
|
|
121
|
+
* If you want to measure something other than execution duration, customize
|
|
122
|
+
* `ProfilerBladeDefaultMeasureHandler`.
|
|
123
|
+
*
|
|
124
|
+
* @example `measure('Hard Work', () => { ... })`;
|
|
125
|
+
*
|
|
126
|
+
* @bindable
|
|
127
|
+
* @readonly
|
|
128
|
+
* @default `undefined`
|
|
129
|
+
*/
|
|
130
|
+
measure?: ProfilerMeasure | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Async variation of function handle that wraps another function to measure its execution
|
|
133
|
+
* duration.
|
|
134
|
+
*
|
|
135
|
+
* @example `measureAsync('Hard Work', async () => { ... })`;
|
|
136
|
+
*
|
|
137
|
+
* @bindable
|
|
138
|
+
* @async
|
|
139
|
+
* @readonly
|
|
140
|
+
* @default `undefined`
|
|
141
|
+
*/
|
|
142
|
+
measureAsync?: ProfilerMeasureAsync | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Function wrapping the `measure` function.
|
|
145
|
+
*
|
|
146
|
+
* The default is fine for most cases when you want to measure a temporal duration.
|
|
147
|
+
* @default [`new
|
|
148
|
+
* ProfilerBladeDefaultMeasureHandler()`](https://github.com/0b5vr/tweakpane-plugin-profiler/blob/dev/src/ProfilerBladeDefaultMeasureHandler.ts)
|
|
149
|
+
*/
|
|
150
|
+
measureHandler?:
|
|
151
|
+
| {
|
|
152
|
+
measureStart: () => () => number | Promise<number>;
|
|
153
|
+
}
|
|
154
|
+
| undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Determines the horizontal scale and color mapping of the profiler visualization bars.
|
|
157
|
+
* @default `16.67` \
|
|
158
|
+
* 60fps.
|
|
159
|
+
*/
|
|
160
|
+
targetDelta?: number | undefined;
|
|
161
|
+
};
|
|
162
|
+
slots: {};
|
|
163
|
+
events: {
|
|
164
|
+
/**
|
|
165
|
+
* Fires when the overall delta value changes, passing the latest measurement.
|
|
166
|
+
*
|
|
167
|
+
* Note that the values described in the `ProfilerChangeEvent` type are available on the
|
|
168
|
+
* `event.detail` parameter.
|
|
169
|
+
* @event
|
|
170
|
+
* */
|
|
171
|
+
change: ProfilerChangeEvent;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
export type ProfilerProps = typeof __propDef.props;
|
|
175
|
+
export type ProfilerEvents = typeof __propDef.events;
|
|
176
|
+
export type ProfilerSlots = typeof __propDef.slots;
|
|
177
|
+
/**
|
|
178
|
+
* Measure and visualize multiple quantities over time.
|
|
179
|
+
*
|
|
180
|
+
* Configured to measure a function's execution duration by default, but can be customized to measure
|
|
181
|
+
* anything.
|
|
182
|
+
*
|
|
183
|
+
* Integrates [0b5vr's](https://0b5vr.com)
|
|
184
|
+
* [tweakpane-plugin-profiler](https://github.com/0b5vr/tweakpane-plugin-profiler).
|
|
185
|
+
*
|
|
186
|
+
* See `<FpsGraph>` for a simpler alternative optimized for framerate visualization.
|
|
187
|
+
*
|
|
188
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the profiler in `<Pane
|
|
189
|
+
* position='inline'>`.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```svelte
|
|
193
|
+
* <script lang="ts">
|
|
194
|
+
* import { onMount } from 'svelte';
|
|
195
|
+
* import { Profiler, type ProfilerMeasure, Slider } from 'svelte-tweakpane-ui';
|
|
196
|
+
*
|
|
197
|
+
* // this is a readonly function handle assigned by Profiler component
|
|
198
|
+
* // first used in onMount since it is not bound until then
|
|
199
|
+
* let measure: ProfilerMeasure;
|
|
200
|
+
*
|
|
201
|
+
* let loopExponent = 1;
|
|
202
|
+
*
|
|
203
|
+
* // helper to test Math functions
|
|
204
|
+
* function hardWork(fn: (n: number) => number, exponent: number): void {
|
|
205
|
+
* measure(fn.name, () => {
|
|
206
|
+
* for (let sum = 0; sum < Number('1e' + exponent); sum++) {
|
|
207
|
+
* fn(sum);
|
|
208
|
+
* }
|
|
209
|
+
* });
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* onMount(() => {
|
|
213
|
+
* (function tick() {
|
|
214
|
+
* // Nesting measurements creates a hierarchy
|
|
215
|
+
* // in the Profile visualization
|
|
216
|
+
* measure('Tick', () => {
|
|
217
|
+
* measure('Trigonometry', () => {
|
|
218
|
+
* hardWork(Math.sin, loopExponent);
|
|
219
|
+
* hardWork(Math.cos, loopExponent);
|
|
220
|
+
* hardWork(Math.tan, loopExponent);
|
|
221
|
+
* hardWork(Math.atan, loopExponent);
|
|
222
|
+
* hardWork(Math.acos, loopExponent);
|
|
223
|
+
* hardWork(Math.acosh, loopExponent);
|
|
224
|
+
* });
|
|
225
|
+
* measure('Logarithms', () => {
|
|
226
|
+
* hardWork(Math.log, loopExponent);
|
|
227
|
+
* hardWork(Math.log10, loopExponent);
|
|
228
|
+
* hardWork(Math.log1p, loopExponent);
|
|
229
|
+
* hardWork(Math.log2, loopExponent);
|
|
230
|
+
* });
|
|
231
|
+
* measure('Rounding', () => {
|
|
232
|
+
* hardWork(Math.round, loopExponent);
|
|
233
|
+
* hardWork(Math.floor, loopExponent);
|
|
234
|
+
* hardWork(Math.ceil, loopExponent);
|
|
235
|
+
* hardWork(Math.fround, loopExponent);
|
|
236
|
+
* });
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* requestAnimationFrame(tick);
|
|
240
|
+
* })();
|
|
241
|
+
* });
|
|
242
|
+
* </script>
|
|
243
|
+
*
|
|
244
|
+
* <Profiler bind:measure label="Profiler" />
|
|
245
|
+
* <Slider
|
|
246
|
+
* bind:value={loopExponent}
|
|
247
|
+
* min={1}
|
|
248
|
+
* max={5}
|
|
249
|
+
* label="Loop Exponent (Careful)"
|
|
250
|
+
* step={1}
|
|
251
|
+
* />
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @sourceLink
|
|
255
|
+
* [Profiler.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/monitor/Profiler.svelte)
|
|
256
|
+
*/
|
|
257
|
+
export default class Profiler extends SvelteComponent<
|
|
258
|
+
ProfilerProps,
|
|
259
|
+
ProfilerEvents,
|
|
260
|
+
ProfilerSlots
|
|
261
|
+
> {
|
|
262
|
+
get measure(): ProfilerMeasure;
|
|
263
|
+
get measureAsync(): ProfilerMeasureAsync;
|
|
264
|
+
}
|
|
265
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import ClsPad from '../internal/ClsPad.svelte';
|
|
5
|
+
import GenericMonitor from '../internal/GenericMonitor.svelte';
|
|
6
|
+
import { fillWith } from '../utils';
|
|
7
|
+
import { BROWSER } from 'esm-env';
|
|
8
|
+
import * as pluginModule from 'tweakpane-plugin-waveform';
|
|
9
|
+
export let value;
|
|
10
|
+
export let max = void 0;
|
|
11
|
+
export let min = void 0;
|
|
12
|
+
export let lineStyle = void 0;
|
|
13
|
+
let options;
|
|
14
|
+
$: options = {
|
|
15
|
+
min,
|
|
16
|
+
max,
|
|
17
|
+
lineStyle,
|
|
18
|
+
readonly: true,
|
|
19
|
+
view: 'waveform'
|
|
20
|
+
};
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<GenericMonitor {value} {options} plugin={pluginModule} {...$$restProps} />
|
|
24
|
+
{#if !BROWSER}
|
|
25
|
+
<ClsPad keysAdd={fillWith('containerUnitSize', 2)} theme={$$props.theme} />
|
|
26
|
+
{/if}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
export type WaveformMonitorValue = Uint8Array | Uint16Array | Uint32Array | number[];
|
|
3
|
+
import type { WaveformStyles as WaveformMonitorLineStyle } from 'tweakpane-plugin-waveform/dist/types/view/waveform.js';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: Omit<
|
|
6
|
+
Omit<
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* The binding's target object with values to manipulate.
|
|
10
|
+
* @bindable
|
|
11
|
+
*/
|
|
12
|
+
object: import('@tweakpane/core').Bindable & {
|
|
13
|
+
[x: string]: WaveformMonitorValue;
|
|
14
|
+
};
|
|
15
|
+
/** The key for the value in the target `object` that the control should manipulate. */
|
|
16
|
+
key: string | number;
|
|
17
|
+
/**
|
|
18
|
+
* Prevent interactivity and gray out the control.
|
|
19
|
+
* @default `false`
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Text displayed next to control.
|
|
24
|
+
* @default `undefined`
|
|
25
|
+
*/
|
|
26
|
+
label?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Tweakpane's internal options object.
|
|
29
|
+
*
|
|
30
|
+
* See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
|
|
31
|
+
*
|
|
32
|
+
* Valid types are contingent on the type of the value `key` points to in `object`.
|
|
33
|
+
*
|
|
34
|
+
* This is intended internal use, when implementing convenience components wrapping Binding's
|
|
35
|
+
* functionality. Options of interest are instead exposed as top-level props in _Svelte
|
|
36
|
+
* Tweakpane UI_.
|
|
37
|
+
* @default `undefined`
|
|
38
|
+
*/
|
|
39
|
+
options?:
|
|
40
|
+
| (import('@tweakpane/core').BaseMonitorParams & {
|
|
41
|
+
min?: number | undefined;
|
|
42
|
+
max?: number | undefined;
|
|
43
|
+
lineStyle?: WaveformMonitorLineStyle | undefined;
|
|
44
|
+
})
|
|
45
|
+
| undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Custom color scheme.
|
|
48
|
+
*
|
|
49
|
+
* @default `undefined` \
|
|
50
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
51
|
+
* set with `setGlobalDefaultTheme()`.
|
|
52
|
+
*/
|
|
53
|
+
theme?: import('..').Theme | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Reference to internal Tweakpane
|
|
56
|
+
* [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
|
|
57
|
+
* this control.
|
|
58
|
+
*
|
|
59
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
60
|
+
* Binding's functionality.
|
|
61
|
+
* @bindable
|
|
62
|
+
* @readonly
|
|
63
|
+
*/
|
|
64
|
+
ref?: import('../internal/GenericMonitor.svelte').GenericMonitorRef | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
|
|
67
|
+
* the binding's containing `<Pane>`.
|
|
68
|
+
*
|
|
69
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
70
|
+
* Binding's functionality in combination with a Tweakpane plugin.
|
|
71
|
+
* @default `undefined`
|
|
72
|
+
*/
|
|
73
|
+
plugin?: import('tweakpane').TpPluginBundle | undefined;
|
|
74
|
+
},
|
|
75
|
+
'object' | 'key'
|
|
76
|
+
> & {
|
|
77
|
+
/**
|
|
78
|
+
* Waveform values.
|
|
79
|
+
* @bindable
|
|
80
|
+
*/
|
|
81
|
+
value: WaveformMonitorValue;
|
|
82
|
+
} & {
|
|
83
|
+
/**
|
|
84
|
+
* Number of past states to retain.
|
|
85
|
+
* @default `1` \
|
|
86
|
+
* Or `64` if value is `number` and `graph` is `true`.
|
|
87
|
+
*/
|
|
88
|
+
bufferSize?: number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Time between value samples in milliseconds.
|
|
91
|
+
*
|
|
92
|
+
* Useful when `graph` is true. Defaults to reactive value updates only (`interval={0}`).
|
|
93
|
+
* @default `0`
|
|
94
|
+
*/
|
|
95
|
+
interval?: number | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Number of visible rows of state history.
|
|
98
|
+
*
|
|
99
|
+
* If `bufferSize` is larger, then the value window will scroll once state history exceeds
|
|
100
|
+
* row count.
|
|
101
|
+
* @default `1` \
|
|
102
|
+
* Or `3` if value is `string` and `multiline` is `true`.
|
|
103
|
+
*/
|
|
104
|
+
rows?: number | undefined /**
|
|
105
|
+
* Waveform values.
|
|
106
|
+
* @bindable
|
|
107
|
+
* */;
|
|
108
|
+
},
|
|
109
|
+
'options' | 'ref' | 'plugin'
|
|
110
|
+
> & {
|
|
111
|
+
/**
|
|
112
|
+
* Waveform values.
|
|
113
|
+
* @bindable
|
|
114
|
+
* */
|
|
115
|
+
value: WaveformMonitorValue;
|
|
116
|
+
/**
|
|
117
|
+
* Minimum graph bound.
|
|
118
|
+
* @default `0`
|
|
119
|
+
* */
|
|
120
|
+
min?: number | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Maximum graph bound.
|
|
123
|
+
* @default `100`
|
|
124
|
+
* */
|
|
125
|
+
max?: number | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Line style.
|
|
128
|
+
* @default `'linear''`
|
|
129
|
+
* */
|
|
130
|
+
lineStyle?: 'linear' | 'bezier' | undefined;
|
|
131
|
+
};
|
|
132
|
+
events: {
|
|
133
|
+
[evt: string]: CustomEvent<any>;
|
|
134
|
+
};
|
|
135
|
+
slots: {};
|
|
136
|
+
};
|
|
137
|
+
export type WaveformMonitorProps = typeof __propDef.props;
|
|
138
|
+
export type WaveformMonitorEvents = typeof __propDef.events;
|
|
139
|
+
export type WaveformMonitorSlots = typeof __propDef.slots;
|
|
140
|
+
/**
|
|
141
|
+
* Visualize multiple numeric values as a waveform.
|
|
142
|
+
*
|
|
143
|
+
* Integrates [Simon Schödler's](https://shoedler.github.io)
|
|
144
|
+
* [tweakpane-plugin-waveform](https://github.com/shoedler/tweakpane-plugin-waveform).
|
|
145
|
+
*
|
|
146
|
+
* See `<Monitor>` component if you want to graph a single value's change over time.
|
|
147
|
+
*
|
|
148
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the waveform monitor in `<Pane
|
|
149
|
+
* position='inline'>`.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```svelte
|
|
153
|
+
* <script lang="ts">
|
|
154
|
+
* import { WaveformMonitor } from 'svelte-tweakpane-ui';
|
|
155
|
+
*
|
|
156
|
+
* let waveData = [5, 6, 7, 8, 9, 3, 9, 8, 7, 6, 5];
|
|
157
|
+
*
|
|
158
|
+
* setInterval(() => {
|
|
159
|
+
* waveData = waveData.map((v) =>
|
|
160
|
+
* Math.max(0, Math.min(10, v + (Math.random() * 2 - 1) * 0.5))
|
|
161
|
+
* );
|
|
162
|
+
* }, 10);
|
|
163
|
+
* </script>
|
|
164
|
+
*
|
|
165
|
+
* <WaveformMonitor value={waveData} min={-1} max={11} lineStyle={'bezier'} />
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @sourceLink
|
|
169
|
+
* [WaveformMonitor.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/monitor/WaveformMonitor.svelte)
|
|
170
|
+
*/
|
|
171
|
+
export default class WaveformMonitor extends SvelteComponent<
|
|
172
|
+
WaveformMonitorProps,
|
|
173
|
+
WaveformMonitorEvents,
|
|
174
|
+
WaveformMonitorSlots
|
|
175
|
+
> {}
|
|
176
|
+
export {};
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type RgbColorObject, type RgbaColorObject } from '@tweakpane/core';
|
|
2
|
+
import type { Simplify } from './utils';
|
|
3
|
+
export type ThemeColorValue = Simplify<RgbColorObject | RgbaColorObject | string>;
|
|
4
|
+
export type Theme = ThemeKeys & CustomThemeKeys;
|
|
5
|
+
type ThemeKeys = {
|
|
6
|
+
baseBackgroundColor?: ThemeColorValue;
|
|
7
|
+
baseBorderRadius?: string;
|
|
8
|
+
baseFontFamily?: string;
|
|
9
|
+
baseShadowColor?: ThemeColorValue;
|
|
10
|
+
bladeBorderRadius?: string;
|
|
11
|
+
bladeHorizontalPadding?: string;
|
|
12
|
+
bladeValueWidth?: string;
|
|
13
|
+
buttonBackgroundColor?: ThemeColorValue;
|
|
14
|
+
buttonBackgroundColorActive?: ThemeColorValue;
|
|
15
|
+
buttonBackgroundColorFocus?: ThemeColorValue;
|
|
16
|
+
buttonBackgroundColorHover?: ThemeColorValue;
|
|
17
|
+
buttonForegroundColor?: ThemeColorValue;
|
|
18
|
+
containerBackgroundColor?: ThemeColorValue;
|
|
19
|
+
containerBackgroundColorActive?: ThemeColorValue;
|
|
20
|
+
containerBackgroundColorFocus?: ThemeColorValue;
|
|
21
|
+
containerBackgroundColorHover?: ThemeColorValue;
|
|
22
|
+
containerForegroundColor?: ThemeColorValue;
|
|
23
|
+
containerHorizontalPadding?: string;
|
|
24
|
+
containerUnitSize?: string;
|
|
25
|
+
containerUnitSpacing?: string;
|
|
26
|
+
containerVerticalPadding?: string;
|
|
27
|
+
grooveForegroundColor?: ThemeColorValue;
|
|
28
|
+
inputBackgroundColor?: ThemeColorValue;
|
|
29
|
+
inputBackgroundColorActive?: ThemeColorValue;
|
|
30
|
+
inputBackgroundColorFocus?: ThemeColorValue;
|
|
31
|
+
inputBackgroundColorHover?: ThemeColorValue;
|
|
32
|
+
inputForegroundColor?: ThemeColorValue;
|
|
33
|
+
labelForegroundColor?: ThemeColorValue;
|
|
34
|
+
monitorBackgroundColor?: ThemeColorValue;
|
|
35
|
+
monitorForegroundColor?: ThemeColorValue;
|
|
36
|
+
pluginImageDraggingColor?: ThemeColorValue;
|
|
37
|
+
};
|
|
38
|
+
type CustomThemeKeys = {
|
|
39
|
+
[key: string]: ThemeColorValue;
|
|
40
|
+
};
|
|
41
|
+
export declare const keys: Record<string, string>;
|
|
42
|
+
export declare const presets: {
|
|
43
|
+
/** Dark blue theme. */
|
|
44
|
+
iceberg: Theme;
|
|
45
|
+
/** Extra dark theme. */
|
|
46
|
+
jetblack: Theme;
|
|
47
|
+
/** Standard Tweakpane light theme. */
|
|
48
|
+
light: Theme;
|
|
49
|
+
/** Light theme with CRT vibes. */
|
|
50
|
+
retro: Theme;
|
|
51
|
+
/** Standard Tweakpane dark theme. This is the default theme. */
|
|
52
|
+
standard: Theme;
|
|
53
|
+
/** Dark translucent theme. */
|
|
54
|
+
translucent: Theme;
|
|
55
|
+
/** Red theme. */
|
|
56
|
+
vivid: Theme;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Used during SSR to calculate metrics Returns CSS string.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getValueOrFallback(theme: Theme | undefined, key: keyof ThemeKeys): string;
|
|
62
|
+
export declare function applyTheme(element: HTMLElement, theme: Theme | undefined): void;
|
|
63
|
+
/**
|
|
64
|
+
* Sets a default theme for all Tweakpane components on the page. Useful if you have a light / dark
|
|
65
|
+
* mode toggle.
|
|
66
|
+
*/
|
|
67
|
+
export declare function setGlobalDefaultTheme(theme: Theme | undefined): void;
|
|
68
|
+
declare const _default: {
|
|
69
|
+
/**
|
|
70
|
+
* A collection of default theme color schemes, matching those provided in the Tweakpane
|
|
71
|
+
* [Panebuilder presets](https://tweakpane.github.io/docs/theming/#builder).
|
|
72
|
+
* */
|
|
73
|
+
presets: {
|
|
74
|
+
/** Dark blue theme. */
|
|
75
|
+
iceberg: Theme;
|
|
76
|
+
/** Extra dark theme. */
|
|
77
|
+
jetblack: Theme;
|
|
78
|
+
/** Standard Tweakpane light theme. */
|
|
79
|
+
light: Theme;
|
|
80
|
+
/** Light theme with CRT vibes. */
|
|
81
|
+
retro: Theme;
|
|
82
|
+
/** Standard Tweakpane dark theme. This is the default theme. */
|
|
83
|
+
standard: Theme;
|
|
84
|
+
/** Dark translucent theme. */
|
|
85
|
+
translucent: Theme;
|
|
86
|
+
/** Red theme. */
|
|
87
|
+
vivid: Theme;
|
|
88
|
+
};
|
|
89
|
+
setGlobalDefaultTheme: typeof setGlobalDefaultTheme;
|
|
90
|
+
};
|
|
91
|
+
export default _default;
|