svelte-tweakpane-ui 1.0.0 → 1.0.2
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/dist/control/ButtonGrid.svelte +6 -7
- package/dist/control/ButtonGrid.svelte.d.ts +6 -4
- package/dist/control/Checkbox.svelte.d.ts +2 -4
- package/dist/control/Color.svelte.d.ts +2 -4
- package/dist/control/CubicBezier.svelte +13 -21
- package/dist/control/CubicBezier.svelte.d.ts +5 -2
- package/dist/control/Image.svelte.d.ts +7 -9
- package/dist/control/IntervalSlider.svelte.d.ts +2 -4
- package/dist/control/List.svelte +14 -20
- package/dist/control/List.svelte.d.ts +3 -5
- package/dist/control/Point.svelte.d.ts +29 -31
- package/dist/control/RadioGrid.svelte.d.ts +2 -4
- package/dist/control/Ring.svelte.d.ts +2 -4
- package/dist/control/RotationEuler.svelte.d.ts +66 -4
- package/dist/control/RotationQuaternion.svelte.d.ts +2 -4
- package/dist/control/Slider.svelte.d.ts +2 -4
- package/dist/control/Text.svelte +1 -1
- package/dist/control/Text.svelte.d.ts +2 -4
- package/dist/control/Textarea.svelte +1 -1
- package/dist/control/Textarea.svelte.d.ts +2 -4
- package/dist/control/Wheel.svelte.d.ts +2 -4
- package/dist/core/Blade.svelte +1 -1
- package/dist/core/TabGroup.svelte +3 -5
- package/dist/core/TabPage.svelte +2 -2
- package/dist/extra/AutoObject.svelte +7 -7
- package/dist/extra/AutoValue.svelte.d.ts +6 -4
- package/dist/extra/Element.svelte +2 -4
- package/dist/extra/Element.svelte.d.ts +30 -23
- package/dist/index.js +5 -5
- package/dist/internal/ClsPad.svelte +3 -7
- package/dist/internal/ClsPad.svelte.d.ts +10 -0
- package/dist/internal/GenericBinding.svelte.d.ts +2 -4
- package/dist/internal/GenericBladeFolding.svelte +5 -5
- package/dist/internal/GenericInput.svelte.d.ts +2 -4
- package/dist/internal/GenericInputFolding.svelte +5 -5
- package/dist/internal/GenericInputFolding.svelte.d.ts +2 -4
- package/dist/internal/GenericMonitor.svelte +1 -1
- package/dist/internal/GenericMonitor.svelte.d.ts +2 -4
- package/dist/internal/GenericPane.svelte +4 -7
- package/dist/internal/GenericSlider.svelte.d.ts +2 -4
- package/dist/internal/InternalMonitorBoolean.svelte.d.ts +2 -4
- package/dist/internal/InternalMonitorNumber.svelte.d.ts +2 -4
- package/dist/internal/InternalMonitorString.svelte.d.ts +2 -4
- package/dist/internal/InternalPaneDraggable.svelte +72 -64
- package/dist/internal/InternalPaneFixed.svelte +1 -3
- package/dist/internal/InternalPaneInline.svelte +3 -3
- package/dist/monitor/FpsGraph.svelte +6 -3
- package/dist/monitor/FpsGraph.svelte.d.ts +2 -2
- package/dist/monitor/Monitor.svelte.d.ts +24 -32
- package/dist/monitor/Profiler.svelte +10 -7
- package/dist/monitor/Profiler.svelte.d.ts +8 -5
- package/dist/monitor/WaveformMonitor.svelte.d.ts +2 -4
- package/dist/theme.d.ts +1 -3
- package/dist/theme.js +30 -39
- package/dist/utils.d.ts +10 -7
- package/dist/utils.js +53 -46
- package/package.json +26 -43
- package/{README.md → readme.md} +10 -3
- /package/{LICENSE → license.txt} +0 -0
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { clamp, getSwatchButton, pickerIsOpen, removeKeys } from '../utils.js';
|
|
11
11
|
import { onDestroy, onMount } from 'svelte';
|
|
12
12
|
import { persisted } from 'svelte-local-storage-store';
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const titlebarWindowShadeSingleClick = true;
|
|
14
|
+
const titlebarWindowShadeDoubleClick = false;
|
|
15
15
|
export let storePositionLocally = true;
|
|
16
16
|
export let localStoreId = localStoreDefaultId;
|
|
17
17
|
let positionStore;
|
|
@@ -88,96 +88,103 @@
|
|
|
88
88
|
const dy = documentHeight - documentHeightPrevious;
|
|
89
89
|
const centerPercentX = (x + width / 2) / documentWidth;
|
|
90
90
|
const centerPercentY = (y + containerHeightScaled / 2) / documentHeight;
|
|
91
|
-
if (!isNaN(dx) && centerPercentX >= 0.5) {
|
|
91
|
+
if (!Number.isNaN(dx) && centerPercentX >= 0.5) {
|
|
92
92
|
x += dx;
|
|
93
93
|
}
|
|
94
|
-
if (!isNaN(dy) && centerPercentY >= 0.5) {
|
|
94
|
+
if (!Number.isNaN(dy) && centerPercentY >= 0.5) {
|
|
95
95
|
y += dy;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const clickBlocker = (
|
|
100
|
-
|
|
99
|
+
const clickBlocker = (event) => {
|
|
100
|
+
event.stopPropagation();
|
|
101
101
|
};
|
|
102
102
|
let startWidth = 0;
|
|
103
103
|
let startOffsetX = 0;
|
|
104
104
|
let startOffsetY = 0;
|
|
105
105
|
let moveDistance = 0;
|
|
106
|
-
const doubleClickListener = (
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
if (width !== void 0 &&
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} else {
|
|
113
|
-
width = minWidth;
|
|
114
|
-
}
|
|
115
|
-
} else if (TITLEBAR_WINDOW_SHADE_DOUBLE_CLICK && e.target === dragBarElement) {
|
|
106
|
+
const doubleClickListener = (event) => {
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
if (event.target) {
|
|
109
|
+
if (width !== void 0 && event.target === widthHandleElement) {
|
|
110
|
+
width = width < maxAvailablePanelWidth ? maxAvailablePanelWidth : minWidth;
|
|
111
|
+
} else if (titlebarWindowShadeDoubleClick && event.target === dragBarElement) {
|
|
116
112
|
paneRef.expanded = !paneRef.expanded;
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
115
|
};
|
|
120
|
-
const downListener = (
|
|
121
|
-
if (x !== void 0 && y !== void 0 &&
|
|
116
|
+
const downListener = (event) => {
|
|
117
|
+
if (x !== void 0 && y !== void 0 && event.button === 0 && event.target instanceof HTMLElement) {
|
|
122
118
|
moveDistance = 0;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
event.target.setPointerCapture(event.pointerId);
|
|
120
|
+
event.target.addEventListener('pointermove', moveListener);
|
|
121
|
+
event.target.addEventListener('pointerup', upListener);
|
|
126
122
|
startWidth = width ?? 0;
|
|
127
|
-
startOffsetX = x -
|
|
128
|
-
startOffsetY = y -
|
|
123
|
+
startOffsetX = x - event.pageX;
|
|
124
|
+
startOffsetY = y - event.pageY;
|
|
129
125
|
}
|
|
130
126
|
};
|
|
131
|
-
const moveListener = (
|
|
127
|
+
const moveListener = (event) => {
|
|
132
128
|
if (
|
|
133
|
-
|
|
129
|
+
event.target instanceof HTMLElement &&
|
|
134
130
|
width !== void 0 &&
|
|
135
131
|
minWidth !== void 0 &&
|
|
136
132
|
x !== void 0 &&
|
|
137
133
|
y !== void 0
|
|
138
134
|
) {
|
|
139
|
-
if (
|
|
140
|
-
moveDistance += Math.
|
|
141
|
-
x =
|
|
142
|
-
y =
|
|
143
|
-
} else if (
|
|
144
|
-
width = clamp(
|
|
135
|
+
if (event.target === dragBarElement) {
|
|
136
|
+
moveDistance += Math.hypot(event.movementX, event.movementY);
|
|
137
|
+
x = event.pageX + startOffsetX;
|
|
138
|
+
y = event.pageY + startOffsetY;
|
|
139
|
+
} else if (event.target === widthHandleElement) {
|
|
140
|
+
width = clamp(
|
|
141
|
+
event.pageX + startOffsetX + startWidth - x,
|
|
142
|
+
minWidth,
|
|
143
|
+
maxAvailablePanelWidth
|
|
144
|
+
);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
const upListener = (
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
const upListener = (event) => {
|
|
149
|
+
event.stopImmediatePropagation();
|
|
150
|
+
if (event.target instanceof HTMLElement) {
|
|
151
|
+
event.target.releasePointerCapture(event.pointerId);
|
|
152
|
+
event.target.removeEventListener('pointermove', moveListener);
|
|
153
|
+
event.target.removeEventListener('pointerup', upListener);
|
|
154
|
+
if (
|
|
155
|
+
titlebarWindowShadeSingleClick &&
|
|
156
|
+
event.target === dragBarElement &&
|
|
157
|
+
moveDistance < 3 &&
|
|
158
|
+
userExpandable
|
|
159
|
+
)
|
|
160
|
+
paneRef.expanded = !paneRef.expanded;
|
|
157
161
|
}
|
|
158
162
|
};
|
|
159
|
-
const touchScrollBlocker = (
|
|
160
|
-
|
|
163
|
+
const touchScrollBlocker = (event) => {
|
|
164
|
+
event.preventDefault();
|
|
161
165
|
};
|
|
162
166
|
onMount(() => {
|
|
163
167
|
setDocumentSize();
|
|
164
168
|
if (paneRef) {
|
|
165
|
-
containerElement.
|
|
169
|
+
containerElement.append(paneRef.element);
|
|
166
170
|
} else {
|
|
167
171
|
console.warn('no pane ref in draggable');
|
|
168
172
|
}
|
|
169
173
|
containerElement.addEventListener('touchmove', touchScrollBlocker, { passive: false });
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
widthHandleElement
|
|
177
|
-
widthHandleElement
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
const dragBarElementCheck = containerElement.querySelector('.tp-rotv_t');
|
|
175
|
+
if (dragBarElementCheck) {
|
|
176
|
+
dragBarElement = dragBarElementCheck;
|
|
177
|
+
dragBarElement.addEventListener('click', clickBlocker);
|
|
178
|
+
dragBarElement.addEventListener('dblclick', doubleClickListener);
|
|
179
|
+
dragBarElement.addEventListener('pointerdown', downListener);
|
|
180
|
+
widthHandleElement = dragBarElement.parentElement?.appendChild(document.createElement('div'));
|
|
181
|
+
if (widthHandleElement) {
|
|
182
|
+
widthHandleElement.className = 'tp-custom-width-handle';
|
|
183
|
+
widthHandleElement.textContent = '\u2194';
|
|
184
|
+
widthHandleElement.addEventListener('click', clickBlocker);
|
|
185
|
+
widthHandleElement.addEventListener('dblclick', doubleClickListener);
|
|
186
|
+
widthHandleElement.addEventListener('pointerdown', downListener);
|
|
187
|
+
}
|
|
181
188
|
}
|
|
182
189
|
});
|
|
183
190
|
onDestroy(() => {
|
|
@@ -204,18 +211,13 @@
|
|
|
204
211
|
});
|
|
205
212
|
function updateResizability(isResizable) {
|
|
206
213
|
if (widthHandleElement) {
|
|
207
|
-
|
|
208
|
-
widthHandleElement.style.display = 'block';
|
|
209
|
-
} else {
|
|
210
|
-
widthHandleElement.style.display = 'none';
|
|
211
|
-
}
|
|
214
|
+
widthHandleElement.style.display = isResizable ? 'block' : 'none';
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
217
|
$: paneRef && resizable && updateResizability(resizable);
|
|
215
218
|
function recursiveCollapse(children, maxToCollapse = Number.MAX_SAFE_INTEGER) {
|
|
216
|
-
console.log(maxToCollapse);
|
|
217
219
|
if (maxToCollapse > 0) {
|
|
218
|
-
|
|
220
|
+
for (const child of children) {
|
|
219
221
|
if ('expanded' in child) {
|
|
220
222
|
if (child.expanded) {
|
|
221
223
|
maxToCollapse--;
|
|
@@ -231,7 +233,7 @@
|
|
|
231
233
|
swatchButton.click();
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
|
-
}
|
|
236
|
+
}
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
239
|
$: if (
|
|
@@ -270,7 +272,8 @@
|
|
|
270
272
|
containerHeightScaled = containerHeight;
|
|
271
273
|
} else {
|
|
272
274
|
const style = window.getComputedStyle(containerElement);
|
|
273
|
-
const vPadding =
|
|
275
|
+
const vPadding =
|
|
276
|
+
Number.parseFloat(style.paddingTop) + Number.parseFloat(style.paddingBottom);
|
|
274
277
|
containerHeightScaled = (containerHeight - vPadding) * scale + vPadding;
|
|
275
278
|
}
|
|
276
279
|
}
|
|
@@ -280,9 +283,9 @@
|
|
|
280
283
|
<svelte:window on:resize={setDocumentSize} />
|
|
281
284
|
|
|
282
285
|
<div
|
|
283
|
-
bind:this={containerElement}
|
|
284
286
|
bind:clientHeight={containerHeight}
|
|
285
287
|
bind:clientWidth={containerWidth}
|
|
288
|
+
bind:this={containerElement}
|
|
286
289
|
on:focus|capture={() => {
|
|
287
290
|
zIndexLocal = ++zIndexGlobal;
|
|
288
291
|
}}
|
|
@@ -323,6 +326,11 @@ draggable-container"
|
|
|
323
326
|
/* stylelint-disable-next-line selector-class-pattern */
|
|
324
327
|
div.draggable-container :global(div.tp-rotv_t) {
|
|
325
328
|
cursor: grab;
|
|
329
|
+
overflow: hidden;
|
|
330
|
+
/* Ensure draggable hit zone does not collapse if title is missing */
|
|
331
|
+
/* Fixes #1 */
|
|
332
|
+
height: 100%;
|
|
333
|
+
text-overflow: ellipsis;
|
|
326
334
|
}
|
|
327
335
|
|
|
328
336
|
div.draggable-container.not-collapsable :global(div.tp-rotv_t) {
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
export let title = 'Tweakpane';
|
|
9
9
|
let paneRef;
|
|
10
10
|
let paneContainer;
|
|
11
|
-
$: paneRef
|
|
12
|
-
paneRef.element.parentElement &&
|
|
13
|
-
(paneContainer = paneRef.element.parentElement);
|
|
11
|
+
$: paneRef?.element.parentElement && (paneContainer = paneRef.element.parentElement);
|
|
14
12
|
$: paneContainer !== void 0 &&
|
|
15
13
|
x !== void 0 &&
|
|
16
14
|
(paneContainer.style.setProperty('right', 'unset'),
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
export let theme = {
|
|
8
8
|
baseBorderRadius: '0px',
|
|
9
9
|
baseShadowColor: 'hsla(0, 0%, 0%, 0)'
|
|
10
|
-
//
|
|
10
|
+
// BladeBorderRadius: '0px'
|
|
11
11
|
};
|
|
12
12
|
let paneRef;
|
|
13
13
|
let containerElement;
|
|
14
14
|
onMount(() => {
|
|
15
15
|
if (paneRef) {
|
|
16
16
|
const fixedContainer = paneRef.element.parentElement;
|
|
17
|
-
containerElement.
|
|
17
|
+
containerElement.append(paneRef.element);
|
|
18
18
|
fixedContainer?.remove();
|
|
19
19
|
} else {
|
|
20
20
|
console.warn('paneRef is undefined');
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
});
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
|
-
<div bind:this={containerElement} style:width={width
|
|
25
|
+
<div bind:this={containerElement} style:width={width === undefined ? null : `${width}px`}>
|
|
26
26
|
<GenericPane bind:expanded bind:paneRef {theme} {...removeKeys($$restProps, 'position')}>
|
|
27
27
|
<slot />
|
|
28
28
|
</GenericPane>
|
|
@@ -46,12 +46,15 @@
|
|
|
46
46
|
function startObservingMeasuredFpsValue() {
|
|
47
47
|
stopObservingMeasuredFpsValue();
|
|
48
48
|
const targetNode = fpsBlade.controller.valueController.view.valueElement;
|
|
49
|
-
if (!targetNode
|
|
49
|
+
if (!targetNode?.innerHTML) return;
|
|
50
50
|
observer = new MutationObserver((mutations) => {
|
|
51
51
|
for (const mutation of mutations) {
|
|
52
52
|
if (mutation.type === 'characterData' || mutation.type === 'childList') {
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const fpsText = mutation.target.textContent;
|
|
54
|
+
if (fpsText !== null) {
|
|
55
|
+
const fps = Number.parseInt(fpsText, 10);
|
|
56
|
+
!Number.isNaN(fps) && dispatch('change', fps);
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
});
|
|
@@ -181,8 +181,8 @@ export type FpsGraphSlots = typeof __propDef.slots;
|
|
|
181
181
|
* <Slider bind:value={rotationSpeed} label="Rotation Speed" />
|
|
182
182
|
*
|
|
183
183
|
* <div class="demo">
|
|
184
|
-
* {#each Array.from({ length: gridSize }, (_,
|
|
185
|
-
* {#each Array.from({ length: gridSize }, (_,
|
|
184
|
+
* {#each Array.from({ length: gridSize }, (_, index) => index) as x}
|
|
185
|
+
* {#each Array.from({ length: gridSize }, (_, index) => index) as y}
|
|
186
186
|
* <div
|
|
187
187
|
* class="box"
|
|
188
188
|
* style:left="{(x / gridSize) * 100}%"
|
|
@@ -7,11 +7,9 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
7
7
|
* The binding's target object with values to manipulate.
|
|
8
8
|
* @bindable
|
|
9
9
|
*/
|
|
10
|
-
object: import('@tweakpane/core').Bindable &
|
|
11
|
-
[x: string]: W;
|
|
12
|
-
};
|
|
10
|
+
object: import('@tweakpane/core').Bindable & Record<string, W>;
|
|
13
11
|
/** The key for the value in the target `object` that the control should manipulate. */
|
|
14
|
-
key: string
|
|
12
|
+
key: string;
|
|
15
13
|
/**
|
|
16
14
|
* Prevent interactivity and gray out the control.
|
|
17
15
|
* @default `false`
|
|
@@ -38,10 +36,10 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
38
36
|
| (W extends string
|
|
39
37
|
? import('tweakpane').StringMonitorParams
|
|
40
38
|
: W extends boolean
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
? import('tweakpane').BooleanMonitorParams
|
|
40
|
+
: W extends number
|
|
41
|
+
? import('tweakpane').NumberMonitorParams
|
|
42
|
+
: import('@tweakpane/core').BaseMonitorParams)
|
|
45
43
|
| undefined;
|
|
46
44
|
/**
|
|
47
45
|
* Custom color scheme.
|
|
@@ -113,11 +111,9 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
113
111
|
* The binding's target object with values to manipulate.
|
|
114
112
|
* @bindable
|
|
115
113
|
*/
|
|
116
|
-
object: import('@tweakpane/core').Bindable &
|
|
117
|
-
[x: string]: string;
|
|
118
|
-
};
|
|
114
|
+
object: import('@tweakpane/core').Bindable & Record<string, string>;
|
|
119
115
|
/** The key for the value in the target `object` that the control should manipulate. */
|
|
120
|
-
key: string
|
|
116
|
+
key: string;
|
|
121
117
|
/**
|
|
122
118
|
* Prevent interactivity and gray out the control.
|
|
123
119
|
* @default `false`
|
|
@@ -202,7 +198,7 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
202
198
|
rows?: number | undefined;
|
|
203
199
|
},
|
|
204
200
|
'options' | 'ref' | 'plugin' | 'interval'
|
|
205
|
-
|
|
201
|
+
> & {
|
|
206
202
|
/**
|
|
207
203
|
* A value to monitor.
|
|
208
204
|
* @bindable
|
|
@@ -213,20 +209,18 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
213
209
|
* @default `false`
|
|
214
210
|
*/
|
|
215
211
|
multiline?: boolean | undefined;
|
|
216
|
-
|
|
212
|
+
}
|
|
217
213
|
: W extends boolean
|
|
218
|
-
|
|
214
|
+
? Omit<
|
|
219
215
|
Omit<
|
|
220
216
|
{
|
|
221
217
|
/**
|
|
222
218
|
* The binding's target object with values to manipulate.
|
|
223
219
|
* @bindable
|
|
224
220
|
*/
|
|
225
|
-
object: import('@tweakpane/core').Bindable &
|
|
226
|
-
[x: string]: boolean;
|
|
227
|
-
};
|
|
221
|
+
object: import('@tweakpane/core').Bindable & Record<string, boolean>;
|
|
228
222
|
/** The key for the value in the target `object` that the control should manipulate. */
|
|
229
|
-
key: string
|
|
223
|
+
key: string;
|
|
230
224
|
/**
|
|
231
225
|
* Prevent interactivity and gray out the control.
|
|
232
226
|
* @default `false`
|
|
@@ -311,26 +305,24 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
311
305
|
rows?: number | undefined;
|
|
312
306
|
},
|
|
313
307
|
'options' | 'ref' | 'plugin' | 'interval'
|
|
314
|
-
|
|
308
|
+
> & {
|
|
315
309
|
/**
|
|
316
310
|
* A value to monitor.
|
|
317
311
|
* @bindable
|
|
318
312
|
*/
|
|
319
313
|
value: boolean;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
}
|
|
315
|
+
: W extends number
|
|
316
|
+
? Omit<
|
|
323
317
|
Omit<
|
|
324
318
|
{
|
|
325
319
|
/**
|
|
326
320
|
* The binding's target object with values to manipulate.
|
|
327
321
|
* @bindable
|
|
328
322
|
*/
|
|
329
|
-
object: import('@tweakpane/core').Bindable &
|
|
330
|
-
[x: string]: number;
|
|
331
|
-
};
|
|
323
|
+
object: import('@tweakpane/core').Bindable & Record<string, number>;
|
|
332
324
|
/** The key for the value in the target `object` that the control should manipulate. */
|
|
333
|
-
key: string
|
|
325
|
+
key: string;
|
|
334
326
|
/**
|
|
335
327
|
* Prevent interactivity and gray out the control.
|
|
336
328
|
* @default `false`
|
|
@@ -415,7 +407,7 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
415
407
|
rows?: number | undefined;
|
|
416
408
|
},
|
|
417
409
|
'options' | 'ref' | 'plugin'
|
|
418
|
-
|
|
410
|
+
> & {
|
|
419
411
|
/**
|
|
420
412
|
* A value to monitor.
|
|
421
413
|
* @bindable
|
|
@@ -442,14 +434,14 @@ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
|
|
|
442
434
|
* @default `false`
|
|
443
435
|
*/
|
|
444
436
|
graph?: boolean | undefined;
|
|
445
|
-
|
|
446
|
-
|
|
437
|
+
}
|
|
438
|
+
: {
|
|
447
439
|
/**
|
|
448
440
|
* A value to monitor.
|
|
449
441
|
* @bindable
|
|
450
442
|
* */
|
|
451
443
|
value: string | number | boolean;
|
|
452
|
-
|
|
444
|
+
});
|
|
453
445
|
events(): {} & {
|
|
454
446
|
[evt: string]: CustomEvent<any>;
|
|
455
447
|
};
|
|
@@ -501,7 +493,7 @@ export type MonitorSlots<W extends number | string | boolean | unknown> = Return
|
|
|
501
493
|
*
|
|
502
494
|
* setInterval(() => {
|
|
503
495
|
* booleanToMonitor = !booleanToMonitor;
|
|
504
|
-
* stringToMonitor = stringToMonitor.
|
|
496
|
+
* stringToMonitor = [...stringToMonitor].reverse().join('');
|
|
505
497
|
* }, 1000);
|
|
506
498
|
* </script>
|
|
507
499
|
*
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
import { fillWith } from '../utils';
|
|
8
8
|
import { BROWSER } from 'esm-env';
|
|
9
9
|
import { createEventDispatcher, onDestroy } from 'svelte';
|
|
10
|
-
function _measure(name,
|
|
11
|
-
profilerBlade?.measure(name,
|
|
10
|
+
function _measure(name, functionToMeasure) {
|
|
11
|
+
profilerBlade?.measure(name, functionToMeasure);
|
|
12
12
|
}
|
|
13
|
-
async function _measureAsync(name,
|
|
14
|
-
profilerBlade?.measureAsync(name,
|
|
13
|
+
async function _measureAsync(name, functionToMeasure) {
|
|
14
|
+
await profilerBlade?.measureAsync(name, functionToMeasure);
|
|
15
15
|
}
|
|
16
16
|
export let label = void 0;
|
|
17
17
|
export let bufferSize = void 0;
|
|
@@ -33,12 +33,15 @@
|
|
|
33
33
|
function startObservingMeasuredValue() {
|
|
34
34
|
stopObservingMeasuredValue();
|
|
35
35
|
const targetNode = profilerBlade.controller.view.valueElement;
|
|
36
|
-
if (!targetNode
|
|
36
|
+
if (!targetNode?.innerHTML) return;
|
|
37
37
|
observer = new MutationObserver((mutations) => {
|
|
38
38
|
for (const mutation of mutations) {
|
|
39
39
|
if (mutation.type === 'characterData' || mutation.type === 'childList') {
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const fpsText = mutation.target.textContent;
|
|
41
|
+
if (fpsText !== null) {
|
|
42
|
+
const delta = Number.parseFloat(fpsText);
|
|
43
|
+
!Number.isNaN(delta) && dispatch('change', delta);
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
});
|
|
@@ -3,8 +3,11 @@ import type { ProfilerBladeMeasureHandler } from '@0b5vr/tweakpane-plugin-profil
|
|
|
3
3
|
import type { Simplify } from '../utils';
|
|
4
4
|
export type ProfilerCalcMode = 'frame' | 'mean' | 'median';
|
|
5
5
|
export type ProfilerChangeEvent = CustomEvent<number>;
|
|
6
|
-
export type ProfilerMeasure = (name: string,
|
|
7
|
-
export type ProfilerMeasureAsync = (
|
|
6
|
+
export type ProfilerMeasure = (name: string, functionToMeasure: () => void) => void;
|
|
7
|
+
export type ProfilerMeasureAsync = (
|
|
8
|
+
name: string,
|
|
9
|
+
functionToMeasure: () => Promise<void>
|
|
10
|
+
) => Promise<void>;
|
|
8
11
|
export type ProfilerMeasureHandler = Simplify<ProfilerBladeMeasureHandler>;
|
|
9
12
|
import type { ProfilerBladeApi as ProfilerRef } from '@0b5vr/tweakpane-plugin-profiler/dist/types/ProfilerBladeApi.js';
|
|
10
13
|
import type { ProfilerBladePluginParams as ProfilerOptions } from '@0b5vr/tweakpane-plugin-profiler/dist/types/ProfilerBladePluginParams.js';
|
|
@@ -201,10 +204,10 @@ export type ProfilerSlots = typeof __propDef.slots;
|
|
|
201
204
|
* let loopExponent = 1;
|
|
202
205
|
*
|
|
203
206
|
* // helper to test Math functions
|
|
204
|
-
* function hardWork(
|
|
205
|
-
* measure(
|
|
207
|
+
* function hardWork(function_: (n: number) => number, exponent: number): void {
|
|
208
|
+
* measure(function_.name, () => {
|
|
206
209
|
* for (let sum = 0; sum < Number('1e' + exponent); sum++) {
|
|
207
|
-
*
|
|
210
|
+
* function_(sum);
|
|
208
211
|
* }
|
|
209
212
|
* });
|
|
210
213
|
* }
|
|
@@ -9,11 +9,9 @@ declare const __propDef: {
|
|
|
9
9
|
* The binding's target object with values to manipulate.
|
|
10
10
|
* @bindable
|
|
11
11
|
*/
|
|
12
|
-
object: import('@tweakpane/core').Bindable &
|
|
13
|
-
[x: string]: WaveformMonitorValue;
|
|
14
|
-
};
|
|
12
|
+
object: import('@tweakpane/core').Bindable & Record<string, WaveformMonitorValue>;
|
|
15
13
|
/** The key for the value in the target `object` that the control should manipulate. */
|
|
16
|
-
key: string
|
|
14
|
+
key: string;
|
|
17
15
|
/**
|
|
18
16
|
* Prevent interactivity and gray out the control.
|
|
19
17
|
* @default `false`
|
package/dist/theme.d.ts
CHANGED
|
@@ -35,9 +35,7 @@ type ThemeKeys = {
|
|
|
35
35
|
monitorForegroundColor?: ThemeColorValue;
|
|
36
36
|
pluginImageDraggingColor?: ThemeColorValue;
|
|
37
37
|
};
|
|
38
|
-
type CustomThemeKeys =
|
|
39
|
-
[key: string]: ThemeColorValue;
|
|
40
|
-
};
|
|
38
|
+
type CustomThemeKeys = Record<string, ThemeColorValue>;
|
|
41
39
|
export declare const keys: Record<string, string>;
|
|
42
40
|
export declare const presets: {
|
|
43
41
|
/** Dark blue theme. */
|
package/dist/theme.js
CHANGED
|
@@ -33,7 +33,7 @@ const standard = {
|
|
|
33
33
|
monitorBackgroundColor: 'rgba(0, 0, 0, 0.2)',
|
|
34
34
|
monitorForegroundColor: 'rgba(187, 188, 196, 0.7)',
|
|
35
35
|
pluginImageDraggingColor: 'hsla(230, 100%, 66%, 1)'
|
|
36
|
-
//
|
|
36
|
+
// PluginThumbnailListHeight: '400px', pluginThumbnailListThumbSize: '20px',
|
|
37
37
|
// pluginThumbnailListWidth: '200px'
|
|
38
38
|
};
|
|
39
39
|
export const keys = Object.keys(standard).reduce((acc, key) => {
|
|
@@ -239,76 +239,67 @@ const keyToCssVariableMap = new Map([
|
|
|
239
239
|
function stringToCssValue(v) {
|
|
240
240
|
if (v === undefined) {
|
|
241
241
|
return undefined;
|
|
242
|
-
}
|
|
242
|
+
}
|
|
243
|
+
if (typeof v === 'string') {
|
|
243
244
|
return v;
|
|
244
|
-
}
|
|
245
|
+
}
|
|
246
|
+
if (isRgbaColorObject(v)) {
|
|
245
247
|
return `rgba(${v.r}, ${v.g}, ${v.b}, ${v.a})`;
|
|
246
|
-
}
|
|
248
|
+
}
|
|
249
|
+
if (isRgbColorObject(v)) {
|
|
247
250
|
return `rgb(${v.r}, ${v.g}, ${v.b})`;
|
|
248
|
-
} else {
|
|
249
|
-
throw new Error(`Unknown CSS theme value object: ${v}`);
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
function expandVariableKey(name) {
|
|
253
|
-
//
|
|
254
|
+
// Pass explicit variables through
|
|
254
255
|
if (name.startsWith('--tp-')) {
|
|
255
256
|
return name;
|
|
256
|
-
} else {
|
|
257
|
-
const varName = keyToCssVariableMap.get(name);
|
|
258
|
-
if (varName) {
|
|
259
|
-
return varName;
|
|
260
|
-
} else {
|
|
261
|
-
throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
|
|
262
|
-
}
|
|
263
257
|
}
|
|
258
|
+
const variableName = keyToCssVariableMap.get(name);
|
|
259
|
+
if (variableName) {
|
|
260
|
+
return variableName;
|
|
261
|
+
}
|
|
262
|
+
throw new Error(`Unknown Tweakpane CSS theme map variable key: "${name}"`);
|
|
264
263
|
}
|
|
265
264
|
/**
|
|
266
265
|
* Used during SSR to calculate metrics Returns CSS string.
|
|
267
266
|
*/
|
|
268
267
|
export function getValueOrFallback(theme, key) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return stringToCssValue(theme[key]);
|
|
273
|
-
}
|
|
268
|
+
return theme?.[key] === undefined
|
|
269
|
+
? stringToCssValue(standard[key])
|
|
270
|
+
: stringToCssValue(theme[key]);
|
|
274
271
|
}
|
|
275
272
|
export function applyTheme(element, theme) {
|
|
276
|
-
const
|
|
273
|
+
const rootDocument = getWindowDocument().documentElement;
|
|
277
274
|
if (theme === undefined) {
|
|
278
|
-
Object.keys(standard)
|
|
275
|
+
for (const k of Object.keys(standard)) {
|
|
279
276
|
const key = expandVariableKey(k);
|
|
280
277
|
if (element.style.getPropertyValue(key).length > 0) {
|
|
281
|
-
// console.log(`Unsetting via undefined theme ${key}`);
|
|
282
278
|
element.style.removeProperty(key);
|
|
283
279
|
}
|
|
284
|
-
}
|
|
280
|
+
}
|
|
285
281
|
} else {
|
|
286
|
-
|
|
282
|
+
for (const [k, v] of Object.entries(theme)) {
|
|
287
283
|
const key = expandVariableKey(k);
|
|
288
284
|
const value = stringToCssValue(v);
|
|
289
|
-
//
|
|
290
|
-
// only set the variable if it deviates from the standard theme or the root theme (set
|
|
285
|
+
// Only set the variable if it deviates from the standard theme or the root theme (set
|
|
291
286
|
// by setGlobalDefaultTheme).... but if theme is explicitly standard and not undefined,
|
|
292
287
|
// then apply it anyway so that any global theme is overridden TODO normalize color
|
|
293
288
|
// representation for comparison? TODO tests for this logic
|
|
294
289
|
const standardValue = standard[k] || undefined;
|
|
295
|
-
const rootValue =
|
|
296
|
-
const isDeviationFromRoot = (rootValue && value !== rootValue)
|
|
297
|
-
const isDeviationFromStandard = (standardValue && value !== standardValue)
|
|
290
|
+
const rootValue = rootDocument.style.getPropertyValue(key) || undefined;
|
|
291
|
+
const isDeviationFromRoot = (rootValue && value !== rootValue) ?? false;
|
|
292
|
+
const isDeviationFromStandard = (standardValue && value !== standardValue) ?? false;
|
|
298
293
|
if (
|
|
299
294
|
theme !== undefined &&
|
|
300
295
|
value !== undefined &&
|
|
301
296
|
(isDeviationFromRoot || (!rootValue && isDeviationFromStandard))
|
|
302
297
|
) {
|
|
303
|
-
// console.log(`Setting ${key} to ${value}`);
|
|
304
298
|
element.style.setProperty(key, value);
|
|
305
|
-
} else {
|
|
306
|
-
|
|
307
|
-
// console.log(`Unsetting ${key}`);
|
|
308
|
-
element.style.removeProperty(key);
|
|
309
|
-
}
|
|
299
|
+
} else if (element.style.getPropertyValue(key).length > 0) {
|
|
300
|
+
element.style.removeProperty(key);
|
|
310
301
|
}
|
|
311
|
-
}
|
|
302
|
+
}
|
|
312
303
|
}
|
|
313
304
|
}
|
|
314
305
|
/**
|
|
@@ -316,12 +307,12 @@ export function applyTheme(element, theme) {
|
|
|
316
307
|
* mode toggle.
|
|
317
308
|
*/
|
|
318
309
|
export function setGlobalDefaultTheme(theme) {
|
|
319
|
-
//
|
|
320
|
-
if (
|
|
310
|
+
// Wait for dom ready... better outside?
|
|
311
|
+
if (window?.document) {
|
|
321
312
|
applyTheme(getWindowDocument().documentElement, theme);
|
|
322
313
|
}
|
|
323
314
|
}
|
|
324
|
-
//
|
|
315
|
+
// Library exports
|
|
325
316
|
export default {
|
|
326
317
|
/**
|
|
327
318
|
* A collection of default theme color schemes, matching those provided in the Tweakpane
|