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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/control/ButtonGrid.svelte +49 -0
  4. package/dist/control/ButtonGrid.svelte.d.ts +190 -0
  5. package/dist/control/Checkbox.svelte +6 -0
  6. package/dist/control/Checkbox.svelte.d.ts +113 -0
  7. package/dist/control/Color.svelte +79 -0
  8. package/dist/control/Color.svelte.d.ts +177 -0
  9. package/dist/control/CubicBezier.svelte +74 -0
  10. package/dist/control/CubicBezier.svelte.d.ts +204 -0
  11. package/dist/control/Image.svelte +23 -0
  12. package/dist/control/Image.svelte.d.ts +177 -0
  13. package/dist/control/IntervalSlider.svelte +37 -0
  14. package/dist/control/IntervalSlider.svelte.d.ts +196 -0
  15. package/dist/control/List.svelte +69 -0
  16. package/dist/control/List.svelte.d.ts +122 -0
  17. package/dist/control/Point.svelte +100 -0
  18. package/dist/control/Point.svelte.d.ts +374 -0
  19. package/dist/control/RadioGrid.svelte +42 -0
  20. package/dist/control/RadioGrid.svelte.d.ts +231 -0
  21. package/dist/control/Ring.svelte +19 -0
  22. package/dist/control/Ring.svelte.d.ts +220 -0
  23. package/dist/control/RotationEuler.svelte +67 -0
  24. package/dist/control/RotationEuler.svelte.d.ts +273 -0
  25. package/dist/control/RotationQuaternion.svelte +65 -0
  26. package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
  27. package/dist/control/Slider.svelte +6 -0
  28. package/dist/control/Slider.svelte.d.ts +165 -0
  29. package/dist/control/Text.svelte +25 -0
  30. package/dist/control/Text.svelte.d.ts +129 -0
  31. package/dist/control/Textarea.svelte +47 -0
  32. package/dist/control/Textarea.svelte.d.ts +149 -0
  33. package/dist/control/Wheel.svelte +15 -0
  34. package/dist/control/Wheel.svelte.d.ts +186 -0
  35. package/dist/core/Binding.svelte +68 -0
  36. package/dist/core/Binding.svelte.d.ts +116 -0
  37. package/dist/core/Blade.svelte +61 -0
  38. package/dist/core/Blade.svelte.d.ts +90 -0
  39. package/dist/core/Button.svelte +59 -0
  40. package/dist/core/Button.svelte.d.ts +65 -0
  41. package/dist/core/Folder.svelte +69 -0
  42. package/dist/core/Folder.svelte.d.ts +78 -0
  43. package/dist/core/Pane.svelte +51 -0
  44. package/dist/core/Pane.svelte.d.ts +500 -0
  45. package/dist/core/Separator.svelte +14 -0
  46. package/dist/core/Separator.svelte.d.ts +85 -0
  47. package/dist/core/TabGroup.svelte +64 -0
  48. package/dist/core/TabGroup.svelte.d.ts +72 -0
  49. package/dist/core/TabPage.svelte +85 -0
  50. package/dist/core/TabPage.svelte.d.ts +82 -0
  51. package/dist/extra/AutoObject.svelte +46 -0
  52. package/dist/extra/AutoObject.svelte.d.ts +108 -0
  53. package/dist/extra/AutoValue.svelte +11 -0
  54. package/dist/extra/AutoValue.svelte.d.ts +123 -0
  55. package/dist/extra/Element.svelte +53 -0
  56. package/dist/extra/Element.svelte.d.ts +170 -0
  57. package/dist/index.d.ts +94 -0
  58. package/dist/index.js +39 -0
  59. package/dist/internal/ClsPad.svelte +34 -0
  60. package/dist/internal/ClsPad.svelte.d.ts +95 -0
  61. package/dist/internal/GenericBinding.svelte +22 -0
  62. package/dist/internal/GenericBinding.svelte.d.ts +116 -0
  63. package/dist/internal/GenericBladeFolding.svelte +38 -0
  64. package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
  65. package/dist/internal/GenericInput.svelte +19 -0
  66. package/dist/internal/GenericInput.svelte.d.ts +116 -0
  67. package/dist/internal/GenericInputFolding.svelte +40 -0
  68. package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
  69. package/dist/internal/GenericMonitor.svelte +24 -0
  70. package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
  71. package/dist/internal/GenericPane.svelte +100 -0
  72. package/dist/internal/GenericPane.svelte.d.ts +84 -0
  73. package/dist/internal/GenericSlider.svelte +27 -0
  74. package/dist/internal/GenericSlider.svelte.d.ts +146 -0
  75. package/dist/internal/InternalMonitorBoolean.svelte +17 -0
  76. package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
  77. package/dist/internal/InternalMonitorNumber.svelte +31 -0
  78. package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
  79. package/dist/internal/InternalMonitorString.svelte +23 -0
  80. package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
  81. package/dist/internal/InternalPaneDraggable.svelte +368 -0
  82. package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
  83. package/dist/internal/InternalPaneFixed.svelte +28 -0
  84. package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
  85. package/dist/internal/InternalPaneInline.svelte +29 -0
  86. package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
  87. package/dist/monitor/FpsGraph.svelte +86 -0
  88. package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
  89. package/dist/monitor/Monitor.svelte +14 -0
  90. package/dist/monitor/Monitor.svelte.d.ts +526 -0
  91. package/dist/monitor/Profiler.svelte +72 -0
  92. package/dist/monitor/Profiler.svelte.d.ts +265 -0
  93. package/dist/monitor/WaveformMonitor.svelte +26 -0
  94. package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
  95. package/dist/theme.d.ts +91 -0
  96. package/dist/theme.js +332 -0
  97. package/dist/utils.d.ts +157 -0
  98. package/dist/utils.js +238 -0
  99. package/package.json +280 -0
@@ -0,0 +1,526 @@
1
+ import { SvelteComponent } from 'svelte';
2
+ declare class __sveltets_Render<W extends number | string | boolean | unknown> {
3
+ props(): Omit<
4
+ Omit<
5
+ {
6
+ /**
7
+ * The binding's target object with values to manipulate.
8
+ * @bindable
9
+ */
10
+ object: import('@tweakpane/core').Bindable & {
11
+ [x: string]: W;
12
+ };
13
+ /** The key for the value in the target `object` that the control should manipulate. */
14
+ key: string | number;
15
+ /**
16
+ * Prevent interactivity and gray out the control.
17
+ * @default `false`
18
+ */
19
+ disabled?: boolean | undefined;
20
+ /**
21
+ * Text displayed next to control.
22
+ * @default `undefined`
23
+ */
24
+ label?: string | undefined;
25
+ /**
26
+ * Tweakpane's internal options object.
27
+ *
28
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
29
+ *
30
+ * Valid types are contingent on the type of the value `key` points to in `object`.
31
+ *
32
+ * This is intended internal use, when implementing convenience components wrapping Binding's
33
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
34
+ * Tweakpane UI_.
35
+ * @default `undefined`
36
+ */
37
+ options?:
38
+ | (W extends string
39
+ ? import('tweakpane').StringMonitorParams
40
+ : W extends boolean
41
+ ? import('tweakpane').BooleanMonitorParams
42
+ : W extends number
43
+ ? import('tweakpane').NumberMonitorParams
44
+ : import('@tweakpane/core').BaseMonitorParams)
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
+ * A value to monitor.
79
+ * @bindable
80
+ */
81
+ value: W;
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
+ },
106
+ 'options' | 'ref' | 'plugin'
107
+ > &
108
+ (W extends string
109
+ ? Omit<
110
+ Omit<
111
+ {
112
+ /**
113
+ * The binding's target object with values to manipulate.
114
+ * @bindable
115
+ */
116
+ object: import('@tweakpane/core').Bindable & {
117
+ [x: string]: string;
118
+ };
119
+ /** The key for the value in the target `object` that the control should manipulate. */
120
+ key: string | number;
121
+ /**
122
+ * Prevent interactivity and gray out the control.
123
+ * @default `false`
124
+ */
125
+ disabled?: boolean | undefined;
126
+ /**
127
+ * Text displayed next to control.
128
+ * @default `undefined`
129
+ */
130
+ label?: string | undefined;
131
+ /**
132
+ * Tweakpane's internal options object.
133
+ *
134
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
135
+ *
136
+ * Valid types are contingent on the type of the value `key` points to in `object`.
137
+ *
138
+ * This is intended internal use, when implementing convenience components wrapping Binding's
139
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
140
+ * Tweakpane UI_.
141
+ * @default `undefined`
142
+ */
143
+ options?: import('tweakpane').StringMonitorParams | undefined;
144
+ /**
145
+ * Custom color scheme.
146
+ *
147
+ * @default `undefined` \
148
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
149
+ * set with `setGlobalDefaultTheme()`.
150
+ */
151
+ theme?: import('..').Theme | undefined;
152
+ /**
153
+ * Reference to internal Tweakpane
154
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
155
+ * this control.
156
+ *
157
+ * This is primarily for internal use, when implementing convenience components wrapping
158
+ * Binding's functionality.
159
+ * @bindable
160
+ * @readonly
161
+ */
162
+ ref?: import('../internal/GenericMonitor.svelte').GenericMonitorRef | undefined;
163
+ /**
164
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
165
+ * the binding's containing `<Pane>`.
166
+ *
167
+ * This is primarily for internal use, when implementing convenience components wrapping
168
+ * Binding's functionality in combination with a Tweakpane plugin.
169
+ * @default `undefined`
170
+ */
171
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
172
+ },
173
+ 'object' | 'key'
174
+ > & {
175
+ /**
176
+ * A value to monitor.
177
+ * @bindable
178
+ */
179
+ value: string;
180
+ } & {
181
+ /**
182
+ * Number of past states to retain.
183
+ * @default `1` \
184
+ * Or `64` if value is `number` and `graph` is `true`.
185
+ */
186
+ bufferSize?: number | undefined;
187
+ /**
188
+ * Time between value samples in milliseconds.
189
+ *
190
+ * Useful when `graph` is true. Defaults to reactive value updates only (`interval={0}`).
191
+ * @default `0`
192
+ */
193
+ interval?: number | undefined;
194
+ /**
195
+ * Number of visible rows of state history.
196
+ *
197
+ * If `bufferSize` is larger, then the value window will scroll once state history exceeds
198
+ * row count.
199
+ * @default `1` \
200
+ * Or `3` if value is `string` and `multiline` is `true`.
201
+ */
202
+ rows?: number | undefined;
203
+ },
204
+ 'options' | 'ref' | 'plugin' | 'interval'
205
+ > & {
206
+ /**
207
+ * A value to monitor.
208
+ * @bindable
209
+ */
210
+ value: string;
211
+ /**
212
+ * Display multiline strings.
213
+ * @default `false`
214
+ */
215
+ multiline?: boolean | undefined;
216
+ }
217
+ : W extends boolean
218
+ ? Omit<
219
+ Omit<
220
+ {
221
+ /**
222
+ * The binding's target object with values to manipulate.
223
+ * @bindable
224
+ */
225
+ object: import('@tweakpane/core').Bindable & {
226
+ [x: string]: boolean;
227
+ };
228
+ /** The key for the value in the target `object` that the control should manipulate. */
229
+ key: string | number;
230
+ /**
231
+ * Prevent interactivity and gray out the control.
232
+ * @default `false`
233
+ */
234
+ disabled?: boolean | undefined;
235
+ /**
236
+ * Text displayed next to control.
237
+ * @default `undefined`
238
+ */
239
+ label?: string | undefined;
240
+ /**
241
+ * Tweakpane's internal options object.
242
+ *
243
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
244
+ *
245
+ * Valid types are contingent on the type of the value `key` points to in `object`.
246
+ *
247
+ * This is intended internal use, when implementing convenience components wrapping Binding's
248
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
249
+ * Tweakpane UI_.
250
+ * @default `undefined`
251
+ */
252
+ options?: import('tweakpane').BooleanMonitorParams | undefined;
253
+ /**
254
+ * Custom color scheme.
255
+ *
256
+ * @default `undefined` \
257
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
258
+ * set with `setGlobalDefaultTheme()`.
259
+ */
260
+ theme?: import('..').Theme | undefined;
261
+ /**
262
+ * Reference to internal Tweakpane
263
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
264
+ * this control.
265
+ *
266
+ * This is primarily for internal use, when implementing convenience components wrapping
267
+ * Binding's functionality.
268
+ * @bindable
269
+ * @readonly
270
+ */
271
+ ref?: import('../internal/GenericMonitor.svelte').GenericMonitorRef | undefined;
272
+ /**
273
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
274
+ * the binding's containing `<Pane>`.
275
+ *
276
+ * This is primarily for internal use, when implementing convenience components wrapping
277
+ * Binding's functionality in combination with a Tweakpane plugin.
278
+ * @default `undefined`
279
+ */
280
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
281
+ },
282
+ 'object' | 'key'
283
+ > & {
284
+ /**
285
+ * A value to monitor.
286
+ * @bindable
287
+ */
288
+ value: boolean;
289
+ } & {
290
+ /**
291
+ * Number of past states to retain.
292
+ * @default `1` \
293
+ * Or `64` if value is `number` and `graph` is `true`.
294
+ */
295
+ bufferSize?: number | undefined;
296
+ /**
297
+ * Time between value samples in milliseconds.
298
+ *
299
+ * Useful when `graph` is true. Defaults to reactive value updates only (`interval={0}`).
300
+ * @default `0`
301
+ */
302
+ interval?: number | undefined;
303
+ /**
304
+ * Number of visible rows of state history.
305
+ *
306
+ * If `bufferSize` is larger, then the value window will scroll once state history exceeds
307
+ * row count.
308
+ * @default `1` \
309
+ * Or `3` if value is `string` and `multiline` is `true`.
310
+ */
311
+ rows?: number | undefined;
312
+ },
313
+ 'options' | 'ref' | 'plugin' | 'interval'
314
+ > & {
315
+ /**
316
+ * A value to monitor.
317
+ * @bindable
318
+ */
319
+ value: boolean;
320
+ }
321
+ : W extends number
322
+ ? Omit<
323
+ Omit<
324
+ {
325
+ /**
326
+ * The binding's target object with values to manipulate.
327
+ * @bindable
328
+ */
329
+ object: import('@tweakpane/core').Bindable & {
330
+ [x: string]: number;
331
+ };
332
+ /** The key for the value in the target `object` that the control should manipulate. */
333
+ key: string | number;
334
+ /**
335
+ * Prevent interactivity and gray out the control.
336
+ * @default `false`
337
+ */
338
+ disabled?: boolean | undefined;
339
+ /**
340
+ * Text displayed next to control.
341
+ * @default `undefined`
342
+ */
343
+ label?: string | undefined;
344
+ /**
345
+ * Tweakpane's internal options object.
346
+ *
347
+ * See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
348
+ *
349
+ * Valid types are contingent on the type of the value `key` points to in `object`.
350
+ *
351
+ * This is intended internal use, when implementing convenience components wrapping Binding's
352
+ * functionality. Options of interest are instead exposed as top-level props in _Svelte
353
+ * Tweakpane UI_.
354
+ * @default `undefined`
355
+ */
356
+ options?: import('tweakpane').NumberMonitorParams | undefined;
357
+ /**
358
+ * Custom color scheme.
359
+ *
360
+ * @default `undefined` \
361
+ * Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
362
+ * set with `setGlobalDefaultTheme()`.
363
+ */
364
+ theme?: import('..').Theme | undefined;
365
+ /**
366
+ * Reference to internal Tweakpane
367
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
368
+ * this control.
369
+ *
370
+ * This is primarily for internal use, when implementing convenience components wrapping
371
+ * Binding's functionality.
372
+ * @bindable
373
+ * @readonly
374
+ */
375
+ ref?: import('../internal/GenericMonitor.svelte').GenericMonitorRef | undefined;
376
+ /**
377
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
378
+ * the binding's containing `<Pane>`.
379
+ *
380
+ * This is primarily for internal use, when implementing convenience components wrapping
381
+ * Binding's functionality in combination with a Tweakpane plugin.
382
+ * @default `undefined`
383
+ */
384
+ plugin?: import('tweakpane').TpPluginBundle | undefined;
385
+ },
386
+ 'object' | 'key'
387
+ > & {
388
+ /**
389
+ * A value to monitor.
390
+ * @bindable
391
+ */
392
+ value: number;
393
+ } & {
394
+ /**
395
+ * Number of past states to retain.
396
+ * @default `1` \
397
+ * Or `64` if value is `number` and `graph` is `true`.
398
+ */
399
+ bufferSize?: number | undefined;
400
+ /**
401
+ * Time between value samples in milliseconds.
402
+ *
403
+ * Useful when `graph` is true. Defaults to reactive value updates only (`interval={0}`).
404
+ * @default `0`
405
+ */
406
+ interval?: number | undefined;
407
+ /**
408
+ * Number of visible rows of state history.
409
+ *
410
+ * If `bufferSize` is larger, then the value window will scroll once state history exceeds
411
+ * row count.
412
+ * @default `1` \
413
+ * Or `3` if value is `string` and `multiline` is `true`.
414
+ */
415
+ rows?: number | undefined;
416
+ },
417
+ 'options' | 'ref' | 'plugin'
418
+ > & {
419
+ /**
420
+ * A value to monitor.
421
+ * @bindable
422
+ */
423
+ value: number;
424
+ /**
425
+ * Minimum bound when `graph` is true.
426
+ * @default `0`
427
+ */
428
+ min?: number | undefined;
429
+ /**
430
+ * Maximum bound when `graph` is true.
431
+ * @default `100`
432
+ */
433
+ max?: number | undefined;
434
+ /**
435
+ * A function to customize the number's formatting (e.g. rounding, etc.).
436
+ * @default `undefined` \
437
+ * Normal `.toString()` formatting.
438
+ */
439
+ format?: ((value: number) => string) | undefined;
440
+ /**
441
+ * Display a graph of the value's changes over time.
442
+ * @default `false`
443
+ */
444
+ graph?: boolean | undefined;
445
+ }
446
+ : {
447
+ /**
448
+ * A value to monitor.
449
+ * @bindable
450
+ * */
451
+ value: string | number | boolean;
452
+ });
453
+ events(): {} & {
454
+ [evt: string]: CustomEvent<any>;
455
+ };
456
+ slots(): {};
457
+ }
458
+ export type MonitorProps<W extends number | string | boolean | unknown> = ReturnType<
459
+ __sveltets_Render<W>['props']
460
+ >;
461
+ export type MonitorEvents<W extends number | string | boolean | unknown> = ReturnType<
462
+ __sveltets_Render<W>['events']
463
+ >;
464
+ export type MonitorSlots<W extends number | string | boolean | unknown> = ReturnType<
465
+ __sveltets_Render<W>['slots']
466
+ >;
467
+ /**
468
+ * Wraps the Tweakpane [monitor binding](https://tweakpane.github.io/docs/monitor-bindings/)
469
+ * functionality for `boolean`, `number`, and `string` values.
470
+ *
471
+ * Technically, any unbound value on a normal _Svelte Tweakpane UI_ component effectively acts as a
472
+ * monitor, but additional monitor-specific components are provided to expose additional view options
473
+ * (e.g. `rows`).
474
+ *
475
+ * `<Monitor>` is a dynamic component, and the availability of additional props will vary depending on
476
+ * the type of the defined `value`
477
+ *
478
+ * Note that `interval` is not exposed on `boolean` and `string` monitors because updates are driven by
479
+ * reactive changes in the `value`.
480
+ *
481
+ * However, `interval` _is_ exposed on `number` monitors Note to allow independent control over the
482
+ * reactive value's update rate and the graph's update rate.
483
+ *
484
+ * See also the `<Waveform>` component for a more advanced number visualization.
485
+ *
486
+ * Usage outside of a `<Pane>` component will implicitly wrap the monitor in a `<Pane
487
+ * position='inline'>` component.
488
+ *
489
+ * @example
490
+ * ```svelte
491
+ * <script lang="ts">
492
+ * import { Monitor } from 'svelte-tweakpane-ui';
493
+ *
494
+ * let booleanToMonitor = false;
495
+ * let stringToMonitor = 'Reticulating';
496
+ * let numberToMonitor = 85;
497
+ *
498
+ * setInterval(() => {
499
+ * numberToMonitor = Math.random() * 100;
500
+ * }, 100);
501
+ *
502
+ * setInterval(() => {
503
+ * booleanToMonitor = !booleanToMonitor;
504
+ * stringToMonitor = stringToMonitor.split('').reverse().join('');
505
+ * }, 1000);
506
+ * </script>
507
+ *
508
+ * <Monitor value={numberToMonitor} graph={true} />
509
+ * <Monitor value={booleanToMonitor} label="Boolean Monitor" />
510
+ * <Monitor
511
+ * value={stringToMonitor}
512
+ * bufferSize={5}
513
+ * label="String Monitor"
514
+ * multiline={true}
515
+ * />
516
+ * ```
517
+ *
518
+ * @sourceLink
519
+ * [Monitor.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/monitor/Monitor.svelte)
520
+ */
521
+ export default class Monitor<W extends number | string | boolean | unknown> extends SvelteComponent<
522
+ MonitorProps<W>,
523
+ MonitorEvents<W>,
524
+ MonitorSlots<W>
525
+ > {}
526
+ export {};
@@ -0,0 +1,72 @@
1
+ <script context="module"></script>
2
+
3
+ <script>
4
+ import * as pluginModule from '@0b5vr/tweakpane-plugin-profiler';
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 } from 'svelte';
10
+ function _measure(name, fn) {
11
+ profilerBlade?.measure(name, fn);
12
+ }
13
+ async function _measureAsync(name, fn) {
14
+ profilerBlade?.measureAsync(name, fn);
15
+ }
16
+ export let label = void 0;
17
+ export let bufferSize = void 0;
18
+ export let calcMode = void 0;
19
+ export let deltaUnit = void 0;
20
+ export let fractionDigits = void 0;
21
+ export let measureHandler = void 0;
22
+ export const measure = _measure;
23
+ export const measureAsync = _measureAsync;
24
+ export let interval = void 0;
25
+ export let targetDelta = void 0;
26
+ let profilerBlade;
27
+ let options;
28
+ let observer = void 0;
29
+ const dispatch = createEventDispatcher();
30
+ onDestroy(() => {
31
+ stopObservingMeasuredValue();
32
+ });
33
+ function startObservingMeasuredValue() {
34
+ stopObservingMeasuredValue();
35
+ const targetNode = profilerBlade.controller.view.valueElement;
36
+ if (!targetNode || !targetNode.innerHTML) return;
37
+ observer = new MutationObserver((mutations) => {
38
+ for (const mutation of mutations) {
39
+ if (mutation.type === 'characterData' || mutation.type === 'childList') {
40
+ const delta = parseFloat(mutation.target.innerText);
41
+ !isNaN(delta) && dispatch('change', delta);
42
+ }
43
+ }
44
+ });
45
+ observer.observe(targetNode, { characterData: true, childList: true, subtree: true });
46
+ }
47
+ function stopObservingMeasuredValue() {
48
+ if (observer) {
49
+ observer.disconnect();
50
+ observer = void 0;
51
+ }
52
+ }
53
+ $: profilerBlade && startObservingMeasuredValue();
54
+ $: options = {
55
+ bufferSize,
56
+ calcMode,
57
+ deltaUnit,
58
+ fractionDigits,
59
+ interval,
60
+ label,
61
+ measureHandler,
62
+ targetDelta,
63
+ view: 'profiler'
64
+ };
65
+ </script>
66
+
67
+ <Blade bind:ref={profilerBlade} {options} plugin={pluginModule} {...$$restProps} />
68
+ {#if !BROWSER}
69
+ <ClsPad keysAdd={fillWith('containerUnitSize', 2)} theme={$$props.theme} />
70
+ <!-- TODO Magic number for label... -->
71
+ <ClsPad extra={14.287} keysAdd={fillWith('containerVerticalPadding', 1)} theme={$$props.theme} />
72
+ {/if}