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,28 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import GenericPane from './GenericPane.svelte';
|
|
3
|
+
import { removeKeys } from '../utils.js';
|
|
4
|
+
export let expanded = void 0;
|
|
5
|
+
export let x = void 0;
|
|
6
|
+
export let y = void 0;
|
|
7
|
+
export let width = void 0;
|
|
8
|
+
export let title = 'Tweakpane';
|
|
9
|
+
let paneRef;
|
|
10
|
+
let paneContainer;
|
|
11
|
+
$: paneRef !== void 0 &&
|
|
12
|
+
paneRef.element.parentElement &&
|
|
13
|
+
(paneContainer = paneRef.element.parentElement);
|
|
14
|
+
$: paneContainer !== void 0 &&
|
|
15
|
+
x !== void 0 &&
|
|
16
|
+
(paneContainer.style.setProperty('right', 'unset'),
|
|
17
|
+
paneContainer.style.setProperty('left', `${x}px`));
|
|
18
|
+
$: paneContainer !== void 0 && y !== void 0 && paneContainer.style.setProperty('top', `${y}px`);
|
|
19
|
+
$: paneContainer !== void 0 &&
|
|
20
|
+
width !== void 0 &&
|
|
21
|
+
paneContainer.style.setProperty('width', `${width}px`);
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div style="display: none;">
|
|
25
|
+
<GenericPane bind:expanded bind:paneRef {title} {...removeKeys($$restProps, 'position')}>
|
|
26
|
+
<slot />
|
|
27
|
+
</GenericPane>
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { Pane as TpPane } from 'tweakpane';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: Omit<
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* Text in the pane's title bar.
|
|
8
|
+
* @default `Tweakpane` \
|
|
9
|
+
* Unless `position='inline'`, in which case the default is `undefined` and no title bar is
|
|
10
|
+
* shown.
|
|
11
|
+
*/
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Allow users to interactively expand / contract the pane by clicking its title bar.
|
|
15
|
+
*
|
|
16
|
+
* Hides the collapse button from the title bar when `false`.
|
|
17
|
+
* @default `true`
|
|
18
|
+
*/
|
|
19
|
+
userExpandable?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Expand or collapse the pane into its title bar.
|
|
22
|
+
* @default `true`
|
|
23
|
+
* @bindable
|
|
24
|
+
*/
|
|
25
|
+
expanded?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Custom color scheme.
|
|
28
|
+
*
|
|
29
|
+
* Applies to all child components, but note that setting a different `theme` on a child
|
|
30
|
+
* component's prop will **not** override the parent pane's theme.
|
|
31
|
+
*
|
|
32
|
+
* Note that `<Pane position="inline' ...>` squares off rounded corners by default to better
|
|
33
|
+
* integrate with surrounding content.
|
|
34
|
+
*
|
|
35
|
+
* Simply pass a custom or default theme like `ThemeUtils.presets.standard` if you want rounded
|
|
36
|
+
* corners on an `inline` pane.
|
|
37
|
+
*
|
|
38
|
+
* See also the `setGlobalDefaultTheme()` for a way to set a custom default theme for all panes
|
|
39
|
+
* on the page.
|
|
40
|
+
* @default `undefined` \
|
|
41
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
42
|
+
* set with `setGlobalDefaultTheme()`.
|
|
43
|
+
*/
|
|
44
|
+
theme?: import('..').Theme | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Scales the pane's elements by a factor of `scale` to make it easier to see.
|
|
47
|
+
*
|
|
48
|
+
* Holds the width of the pane constant, so the pane will grow taller as it is scaled and will
|
|
49
|
+
* continue to respect position- and size-related props. If you need more breathing room, set
|
|
50
|
+
* the `width` property on the pane.
|
|
51
|
+
*
|
|
52
|
+
* Note that the scaling prop is only available on `<Pane>`, not on stand-alone (implicitly
|
|
53
|
+
* wrapped) inline elements.
|
|
54
|
+
*
|
|
55
|
+
* Negative values are ignored.
|
|
56
|
+
* @default `1`
|
|
57
|
+
*/
|
|
58
|
+
scale?: number | undefined;
|
|
59
|
+
/** Internal use only. */
|
|
60
|
+
userCreatedPane?: boolean | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Internal use only.
|
|
63
|
+
* @readonly
|
|
64
|
+
*/
|
|
65
|
+
paneRef?: TpPane | undefined;
|
|
66
|
+
},
|
|
67
|
+
'userCreatedPane' | 'paneRef'
|
|
68
|
+
> & {
|
|
69
|
+
/**
|
|
70
|
+
* Horizontal position of the pane relative to the left edge of the window, in pixels.
|
|
71
|
+
*
|
|
72
|
+
* Not to be confused with the `position` prop which defines _how_, not _where_, the pane is
|
|
73
|
+
* positioned on the page. (So-named because of its similarity to CSS `position` property.)
|
|
74
|
+
* @default `undefined` \
|
|
75
|
+
* 8 pixels from the right edge of the window.
|
|
76
|
+
* */
|
|
77
|
+
x?: number | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Vertical position of the pane relative to the top of the window, in pixels.
|
|
80
|
+
*
|
|
81
|
+
* Not to be confused with the `position` prop which defines _how_, not _where_, the pane is
|
|
82
|
+
* positioned on the page. (So-named because of its similarity to CSS `position` property.)
|
|
83
|
+
* @default `undefined` \
|
|
84
|
+
* 8 pixels from the top edge of the window.
|
|
85
|
+
* */
|
|
86
|
+
y?: number | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Width of the pane, in pixels.
|
|
89
|
+
* @default `256`
|
|
90
|
+
* */
|
|
91
|
+
width?: number | undefined;
|
|
92
|
+
};
|
|
93
|
+
events: {
|
|
94
|
+
[evt: string]: CustomEvent<any>;
|
|
95
|
+
};
|
|
96
|
+
slots: {
|
|
97
|
+
/**
|
|
98
|
+
* Any Tweakpane component, except another `<Pane>`.
|
|
99
|
+
*/
|
|
100
|
+
default: {};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export type InternalPaneFixedProps = typeof __propDef.props;
|
|
104
|
+
export type InternalPaneFixedEvents = typeof __propDef.events;
|
|
105
|
+
export type InternalPaneFixedSlots = typeof __propDef.slots;
|
|
106
|
+
/**
|
|
107
|
+
* This component is for internal use only.
|
|
108
|
+
*
|
|
109
|
+
* Implements the default tweakpane behavior... opens in a fixed position.
|
|
110
|
+
*
|
|
111
|
+
* @sourceLink
|
|
112
|
+
* [InternalPaneFixed.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/internal/InternalPaneFixed.svelte)
|
|
113
|
+
*/
|
|
114
|
+
export default class InternalPaneFixed extends SvelteComponent<
|
|
115
|
+
InternalPaneFixedProps,
|
|
116
|
+
InternalPaneFixedEvents,
|
|
117
|
+
InternalPaneFixedSlots
|
|
118
|
+
> {}
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import GenericPane from './GenericPane.svelte';
|
|
3
|
+
import { removeKeys } from '../utils.js';
|
|
4
|
+
import { onMount } from 'svelte';
|
|
5
|
+
export let expanded = void 0;
|
|
6
|
+
export let width = void 0;
|
|
7
|
+
export let theme = {
|
|
8
|
+
baseBorderRadius: '0px',
|
|
9
|
+
baseShadowColor: 'hsla(0, 0%, 0%, 0)'
|
|
10
|
+
// bladeBorderRadius: '0px'
|
|
11
|
+
};
|
|
12
|
+
let paneRef;
|
|
13
|
+
let containerElement;
|
|
14
|
+
onMount(() => {
|
|
15
|
+
if (paneRef) {
|
|
16
|
+
const fixedContainer = paneRef.element.parentElement;
|
|
17
|
+
containerElement.appendChild(paneRef.element);
|
|
18
|
+
fixedContainer?.remove();
|
|
19
|
+
} else {
|
|
20
|
+
console.warn('paneRef is undefined');
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div bind:this={containerElement} style:width={width !== undefined ? `${width}px` : null}>
|
|
26
|
+
<GenericPane bind:expanded bind:paneRef {theme} {...removeKeys($$restProps, 'position')}>
|
|
27
|
+
<slot />
|
|
28
|
+
</GenericPane>
|
|
29
|
+
</div>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { Pane as TpPane } from 'tweakpane';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: Omit<
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* Text in the pane's title bar.
|
|
8
|
+
* @default `Tweakpane` \
|
|
9
|
+
* Unless `position='inline'`, in which case the default is `undefined` and no title bar is
|
|
10
|
+
* shown.
|
|
11
|
+
*/
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Allow users to interactively expand / contract the pane by clicking its title bar.
|
|
15
|
+
*
|
|
16
|
+
* Hides the collapse button from the title bar when `false`.
|
|
17
|
+
* @default `true`
|
|
18
|
+
*/
|
|
19
|
+
userExpandable?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Expand or collapse the pane into its title bar.
|
|
22
|
+
* @default `true`
|
|
23
|
+
* @bindable
|
|
24
|
+
*/
|
|
25
|
+
expanded?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Custom color scheme.
|
|
28
|
+
*
|
|
29
|
+
* Applies to all child components, but note that setting a different `theme` on a child
|
|
30
|
+
* component's prop will **not** override the parent pane's theme.
|
|
31
|
+
*
|
|
32
|
+
* Note that `<Pane position="inline' ...>` squares off rounded corners by default to better
|
|
33
|
+
* integrate with surrounding content.
|
|
34
|
+
*
|
|
35
|
+
* Simply pass a custom or default theme like `ThemeUtils.presets.standard` if you want rounded
|
|
36
|
+
* corners on an `inline` pane.
|
|
37
|
+
*
|
|
38
|
+
* See also the `setGlobalDefaultTheme()` for a way to set a custom default theme for all panes
|
|
39
|
+
* on the page.
|
|
40
|
+
* @default `undefined` \
|
|
41
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
42
|
+
* set with `setGlobalDefaultTheme()`.
|
|
43
|
+
*/
|
|
44
|
+
theme?: import('..').Theme | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Scales the pane's elements by a factor of `scale` to make it easier to see.
|
|
47
|
+
*
|
|
48
|
+
* Holds the width of the pane constant, so the pane will grow taller as it is scaled and will
|
|
49
|
+
* continue to respect position- and size-related props. If you need more breathing room, set
|
|
50
|
+
* the `width` property on the pane.
|
|
51
|
+
*
|
|
52
|
+
* Note that the scaling prop is only available on `<Pane>`, not on stand-alone (implicitly
|
|
53
|
+
* wrapped) inline elements.
|
|
54
|
+
*
|
|
55
|
+
* Negative values are ignored.
|
|
56
|
+
* @default `1`
|
|
57
|
+
*/
|
|
58
|
+
scale?: number | undefined;
|
|
59
|
+
/** Internal use only. */
|
|
60
|
+
userCreatedPane?: boolean | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Internal use only.
|
|
63
|
+
* @readonly
|
|
64
|
+
*/
|
|
65
|
+
paneRef?: TpPane | undefined;
|
|
66
|
+
},
|
|
67
|
+
'paneRef'
|
|
68
|
+
> & {
|
|
69
|
+
/**
|
|
70
|
+
* Width of the pane, in pixels.
|
|
71
|
+
*
|
|
72
|
+
* If undefined, the pane will fill the width of its container. (This behavior is unique to
|
|
73
|
+
* `position="inline"`.)
|
|
74
|
+
*
|
|
75
|
+
* This value is particularly important in combination with `scale`, since a scaled inline
|
|
76
|
+
* pane will grow indefinitely wider if an intrinsic width is not specified and a containing
|
|
77
|
+
* element is not provided.
|
|
78
|
+
* @default `undefined`
|
|
79
|
+
* */
|
|
80
|
+
width?: number | undefined;
|
|
81
|
+
};
|
|
82
|
+
events: {
|
|
83
|
+
[evt: string]: CustomEvent<any>;
|
|
84
|
+
};
|
|
85
|
+
slots: {
|
|
86
|
+
/**
|
|
87
|
+
* Any Tweakpane component, except another `<Pane>`.
|
|
88
|
+
*/
|
|
89
|
+
default: {};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export type InternalPaneInlineProps = typeof __propDef.props;
|
|
93
|
+
export type InternalPaneInlineEvents = typeof __propDef.events;
|
|
94
|
+
export type InternalPaneInlineSlots = typeof __propDef.slots;
|
|
95
|
+
/**
|
|
96
|
+
* This component is for internal use only.
|
|
97
|
+
*
|
|
98
|
+
* @sourceLink
|
|
99
|
+
* [InternalPaneInline.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/internal/InternalPaneInline.svelte)
|
|
100
|
+
*/
|
|
101
|
+
export default class InternalPaneInline extends SvelteComponent<
|
|
102
|
+
InternalPaneInlineProps,
|
|
103
|
+
InternalPaneInlineEvents,
|
|
104
|
+
InternalPaneInlineSlots
|
|
105
|
+
> {}
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import * as pluginModule from '@tweakpane/plugin-essentials';
|
|
5
|
+
import Blade from '../core/Blade.svelte';
|
|
6
|
+
import ClsPad from '../internal/ClsPad.svelte';
|
|
7
|
+
import { fillWith } from '../utils';
|
|
8
|
+
import { BROWSER } from 'esm-env';
|
|
9
|
+
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
10
|
+
export let rows = void 0;
|
|
11
|
+
export let interval = void 0;
|
|
12
|
+
export let max = void 0;
|
|
13
|
+
export let min = void 0;
|
|
14
|
+
export let label = void 0;
|
|
15
|
+
let implicitMode = true;
|
|
16
|
+
export function begin() {
|
|
17
|
+
implicitMode = false;
|
|
18
|
+
fpsBlade?.begin();
|
|
19
|
+
}
|
|
20
|
+
export function end() {
|
|
21
|
+
implicitMode = false;
|
|
22
|
+
fpsBlade?.end();
|
|
23
|
+
}
|
|
24
|
+
let fpsBlade;
|
|
25
|
+
let requestId;
|
|
26
|
+
const dispatch = createEventDispatcher();
|
|
27
|
+
onMount(() => {
|
|
28
|
+
startInternalLoop();
|
|
29
|
+
});
|
|
30
|
+
onDestroy(() => {
|
|
31
|
+
stopInternalLoop();
|
|
32
|
+
stopObservingMeasuredFpsValue();
|
|
33
|
+
});
|
|
34
|
+
function startInternalLoop() {
|
|
35
|
+
loop();
|
|
36
|
+
}
|
|
37
|
+
function loop() {
|
|
38
|
+
fpsBlade?.end();
|
|
39
|
+
fpsBlade?.begin();
|
|
40
|
+
requestId = requestAnimationFrame(loop);
|
|
41
|
+
}
|
|
42
|
+
function stopInternalLoop() {
|
|
43
|
+
requestId && cancelAnimationFrame(requestId);
|
|
44
|
+
}
|
|
45
|
+
let observer = void 0;
|
|
46
|
+
function startObservingMeasuredFpsValue() {
|
|
47
|
+
stopObservingMeasuredFpsValue();
|
|
48
|
+
const targetNode = fpsBlade.controller.valueController.view.valueElement;
|
|
49
|
+
if (!targetNode || !targetNode.innerHTML) return;
|
|
50
|
+
observer = new MutationObserver((mutations) => {
|
|
51
|
+
for (const mutation of mutations) {
|
|
52
|
+
if (mutation.type === 'characterData' || mutation.type === 'childList') {
|
|
53
|
+
const fps = parseInt(mutation.target.innerText);
|
|
54
|
+
!isNaN(fps) && dispatch('change', fps);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
observer.observe(targetNode, { characterData: true, childList: true, subtree: true });
|
|
59
|
+
}
|
|
60
|
+
function stopObservingMeasuredFpsValue() {
|
|
61
|
+
if (observer) {
|
|
62
|
+
observer.disconnect();
|
|
63
|
+
observer = void 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
$: fpsBlade && startObservingMeasuredFpsValue();
|
|
67
|
+
let options;
|
|
68
|
+
$: options = {
|
|
69
|
+
min,
|
|
70
|
+
max,
|
|
71
|
+
interval,
|
|
72
|
+
label,
|
|
73
|
+
rows,
|
|
74
|
+
view: 'fpsgraph'
|
|
75
|
+
};
|
|
76
|
+
$: !implicitMode && stopInternalLoop();
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<Blade bind:ref={fpsBlade} {options} plugin={pluginModule} {...$$restProps} />
|
|
80
|
+
{#if !BROWSER}
|
|
81
|
+
{#if rows}
|
|
82
|
+
<ClsPad keysAdd={fillWith('containerUnitSize', rows)} theme={$$props.theme} />
|
|
83
|
+
{:else}
|
|
84
|
+
<ClsPad keysAdd={fillWith('containerUnitSize', 2)} theme={$$props.theme} />
|
|
85
|
+
{/if}
|
|
86
|
+
{/if}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
export type FpsGraphChangeEvent = CustomEvent<number>;
|
|
3
|
+
import type { FpsGraphBladeApi as FpsGraphRef } from '@tweakpane/plugin-essentials';
|
|
4
|
+
import type { FpsGraphBladeParams as FpsGraphOptions } from '@tweakpane/plugin-essentials/dist/types/fps-graph/plugin.js';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* Function to start a single frame measurement sample.
|
|
9
|
+
*
|
|
10
|
+
* If undefined, a `requestAnimationFrame` is used to indicate the overall performance of
|
|
11
|
+
* the page.
|
|
12
|
+
* @default `undefined`
|
|
13
|
+
*/
|
|
14
|
+
begin?: (() => void) | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Function to end a single frame measurement sample.
|
|
17
|
+
*
|
|
18
|
+
* If undefined, a `requestAnimationFrame` is used to indicate the overall performance of
|
|
19
|
+
* the page.
|
|
20
|
+
* @default `undefined`
|
|
21
|
+
*/
|
|
22
|
+
end?: (() => void) | undefined;
|
|
23
|
+
} & Omit<
|
|
24
|
+
{
|
|
25
|
+
/**
|
|
26
|
+
* Blade configuration exposing Tweakpane's internal
|
|
27
|
+
* [`BladeParams`](https://tweakpane.github.io/docs/api/interfaces/BaseBladeParams.html).
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
options: FpsGraphOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Prevent interactivity and gray out the control.
|
|
33
|
+
* @default `false`
|
|
34
|
+
*/
|
|
35
|
+
disabled?: boolean | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Custom color scheme.
|
|
38
|
+
* @default `undefined` \
|
|
39
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
40
|
+
* set with `setGlobalDefaultTheme()`.
|
|
41
|
+
*/
|
|
42
|
+
theme?: import('..').Theme | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Reference to internal Tweakpane
|
|
45
|
+
* [`BladeApi`](https://tweakpane.github.io/docs/api/classes/BladeApi.html) for this blade.
|
|
46
|
+
*
|
|
47
|
+
* This is primarily for internal use, when implementing convenience components wrapping Blade's
|
|
48
|
+
* functionality.
|
|
49
|
+
* @bindable
|
|
50
|
+
* @readonly
|
|
51
|
+
*/
|
|
52
|
+
ref?: FpsGraphRef | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Imported Tweakpane `TpPluginBundle` (Aliased as `Plugin`) module to register before creating
|
|
55
|
+
* the blade.
|
|
56
|
+
*
|
|
57
|
+
* This is primarily for internal use, when implementing convenience components wrapping Blade's
|
|
58
|
+
* functionality in combination with a Tweakpane plugin.
|
|
59
|
+
* @default `undefined`
|
|
60
|
+
*/
|
|
61
|
+
plugin?: import('tweakpane').TpPluginBundle | undefined;
|
|
62
|
+
},
|
|
63
|
+
'options' | 'ref' | 'plugin'
|
|
64
|
+
> & {
|
|
65
|
+
/**
|
|
66
|
+
* Lower bound of the FPS graph.
|
|
67
|
+
* @default `0`
|
|
68
|
+
* */
|
|
69
|
+
min?: number | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Upper bound of the FPS graph.
|
|
72
|
+
* @default `90`
|
|
73
|
+
* */
|
|
74
|
+
max?: number | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Function to start a single frame measurement sample.
|
|
77
|
+
*
|
|
78
|
+
* If undefined, a `requestAnimationFrame` is used to indicate the overall performance of
|
|
79
|
+
* the page.
|
|
80
|
+
* @default `undefined`
|
|
81
|
+
* */
|
|
82
|
+
begin?: (() => void) | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Function to end a single frame measurement sample.
|
|
85
|
+
*
|
|
86
|
+
* If undefined, a `requestAnimationFrame` is used to indicate the overall performance of
|
|
87
|
+
* the page.
|
|
88
|
+
* @default `undefined`
|
|
89
|
+
* */
|
|
90
|
+
end?: (() => void) | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Time in milliseconds between updates to the graph.
|
|
93
|
+
* @default `1000`
|
|
94
|
+
* */
|
|
95
|
+
interval?: number | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Text displayed next to the FPS graph.
|
|
98
|
+
* @default `undefined`
|
|
99
|
+
* */
|
|
100
|
+
label?: string | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Height of the FPS graph, in rows.
|
|
103
|
+
* @default `2`
|
|
104
|
+
* */
|
|
105
|
+
rows?: number | undefined;
|
|
106
|
+
};
|
|
107
|
+
slots: {};
|
|
108
|
+
events: {
|
|
109
|
+
/**
|
|
110
|
+
* Fires when the FPS value changes, passing the latest FPS measurement.
|
|
111
|
+
*
|
|
112
|
+
* Note that the values described in the `FpsGraphChangeEvent` type are available on the
|
|
113
|
+
* `event.detail` parameter.
|
|
114
|
+
* @event
|
|
115
|
+
* */
|
|
116
|
+
change: FpsGraphChangeEvent;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export type FpsGraphProps = typeof __propDef.props;
|
|
120
|
+
export type FpsGraphEvents = typeof __propDef.events;
|
|
121
|
+
export type FpsGraphSlots = typeof __propDef.slots;
|
|
122
|
+
/**
|
|
123
|
+
* A control for monitoring and graphing frame rates over time.
|
|
124
|
+
*
|
|
125
|
+
* Integrates the [FPS Graph](https://github.com/tweakpane/plugin-essentials#fps-graph) control from
|
|
126
|
+
* Tweakpane-creator [Hiroki Kokubun's](https://cocopon.me) [Essentials
|
|
127
|
+
* plugin](https://github.com/tweakpane/plugin-essentials).
|
|
128
|
+
*
|
|
129
|
+
* By default, the component creates an internal `requestAnimationFrame` loop to measure the overall
|
|
130
|
+
* performance of the page. If you want to measure the performance of a specific block of code, you can
|
|
131
|
+
* bind the `begin` and `end` props for access to functions to fence the code of interest. (The default
|
|
132
|
+
* internal loop will be cleaned up automatically on the bound functions first use.)
|
|
133
|
+
*
|
|
134
|
+
* See the `<Profiler>` component for a more advanced measurement and visualization strategies.
|
|
135
|
+
*
|
|
136
|
+
* If you'd like to observe or visualize the frame rate data elsewhere, a `change` event is provided to
|
|
137
|
+
* notify when the FPS value changes.
|
|
138
|
+
*
|
|
139
|
+
* @emits {number} change - When the FPS value changes.
|
|
140
|
+
*
|
|
141
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the FPS graph in `<Pane
|
|
142
|
+
* position='inline'>`.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```svelte
|
|
146
|
+
* <script lang="ts">
|
|
147
|
+
* import { onMount } from 'svelte';
|
|
148
|
+
* import { FpsGraph, Monitor, Slider } from 'svelte-tweakpane-ui';
|
|
149
|
+
*
|
|
150
|
+
* let rotation = 0;
|
|
151
|
+
* let rotationSpeed = 3;
|
|
152
|
+
* let phase = 500;
|
|
153
|
+
* let scale = 1.25;
|
|
154
|
+
* let intensity = 4;
|
|
155
|
+
*
|
|
156
|
+
* onMount(() => {
|
|
157
|
+
* (function tick() {
|
|
158
|
+
* rotation += rotationSpeed;
|
|
159
|
+
* requestAnimationFrame(tick);
|
|
160
|
+
* })();
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* $: gridSize = intensity ** 2;
|
|
164
|
+
* </script>
|
|
165
|
+
*
|
|
166
|
+
* <FpsGraph interval={50} label="FPS" rows={5} />
|
|
167
|
+
* <Slider
|
|
168
|
+
* bind:value={intensity}
|
|
169
|
+
* min={1}
|
|
170
|
+
* max={10}
|
|
171
|
+
* label="Intensity (Careful)"
|
|
172
|
+
* step={1}
|
|
173
|
+
* />
|
|
174
|
+
* <Monitor
|
|
175
|
+
* value={gridSize ** 2}
|
|
176
|
+
* format={(v) => v.toFixed(0)}
|
|
177
|
+
* label="Boxes (Monitor)"
|
|
178
|
+
* />
|
|
179
|
+
* <Slider bind:value={scale} min={0.25} max={2} label="Scale" />
|
|
180
|
+
* <Slider bind:value={phase} min={0} max={2000} label="Phase" />
|
|
181
|
+
* <Slider bind:value={rotationSpeed} label="Rotation Speed" />
|
|
182
|
+
*
|
|
183
|
+
* <div class="demo">
|
|
184
|
+
* {#each Array.from({ length: gridSize }, (_, i) => i) as x}
|
|
185
|
+
* {#each Array.from({ length: gridSize }, (_, i) => i) as y}
|
|
186
|
+
* <div
|
|
187
|
+
* class="box"
|
|
188
|
+
* style:left="{(x / gridSize) * 100}%"
|
|
189
|
+
* style:scale
|
|
190
|
+
* style:top="{(y / gridSize) * 100}%"
|
|
191
|
+
* style:transform="rotateZ({rotation +
|
|
192
|
+
* (x / gridSize) * phase +
|
|
193
|
+
* (y / gridSize) * phase}deg)"
|
|
194
|
+
* style:width="{100 / gridSize}%"
|
|
195
|
+
* />
|
|
196
|
+
* {/each}
|
|
197
|
+
* {/each}
|
|
198
|
+
* </div>
|
|
199
|
+
*
|
|
200
|
+
* <style>
|
|
201
|
+
* .demo {
|
|
202
|
+
* position: relative;
|
|
203
|
+
* overflow: hidden;
|
|
204
|
+
* aspect-ratio: 1;
|
|
205
|
+
* width: 100%;
|
|
206
|
+
* background: linear-gradient(to top, gold, rebeccapurple);
|
|
207
|
+
* }
|
|
208
|
+
*
|
|
209
|
+
* .box {
|
|
210
|
+
* position: absolute;
|
|
211
|
+
* transform-origin: center;
|
|
212
|
+
* aspect-ratio: 1;
|
|
213
|
+
* opacity: 0.5;
|
|
214
|
+
* background: linear-gradient(to bottom, orange, magenta);
|
|
215
|
+
* }
|
|
216
|
+
* </style>
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @sourceLink
|
|
220
|
+
* [FpsGraph.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/monitor/FpsGraph.svelte)
|
|
221
|
+
*/
|
|
222
|
+
export default class FpsGraph extends SvelteComponent<
|
|
223
|
+
FpsGraphProps,
|
|
224
|
+
FpsGraphEvents,
|
|
225
|
+
FpsGraphSlots
|
|
226
|
+
> {
|
|
227
|
+
get begin(): (() => void) & (() => void);
|
|
228
|
+
get end(): (() => void) & (() => void);
|
|
229
|
+
}
|
|
230
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script generics="W extends number | string | boolean | unknown">
|
|
2
|
+
import InternalMonitorBoolean from '../internal/InternalMonitorBoolean.svelte';
|
|
3
|
+
import InternalMonitorNumber from '../internal/InternalMonitorNumber.svelte';
|
|
4
|
+
import InternalMonitorString from '../internal/InternalMonitorString.svelte';
|
|
5
|
+
export let value;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#if typeof value === 'number'}
|
|
9
|
+
<InternalMonitorNumber {value} {...$$restProps} />
|
|
10
|
+
{:else if typeof value === 'boolean'}
|
|
11
|
+
<InternalMonitorBoolean {value} {...$$restProps} />
|
|
12
|
+
{:else if typeof value === 'string'}
|
|
13
|
+
<InternalMonitorString {value} {...$$restProps} />
|
|
14
|
+
{/if}
|