@weasel-js/labkit 1.4.2 → 1.4.3

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 (105) hide show
  1. package/README.md +20 -2
  2. package/dist/_dts/{CanvasStackContext-kjILVnPj.d.ts → CanvasStackContext-Dde8_1my.d.ts} +1 -1
  3. package/dist/_dts/{PrefsForm.d-CgxUequc.d.ts → PrefsForm.d-DDHFANkc.d.ts} +1 -1
  4. package/dist/_dts/{frac-A4R6v4ld.d.ts → frac-B5mB8LsJ.d.ts} +7 -4
  5. package/dist/_dts/{index-CsU9WhjM.d.ts → index-DelFfeV0.d.ts} +15 -7
  6. package/dist/_dts/types-B9_zrHmb.d.ts +166 -0
  7. package/dist/_dts/{types-BbXpvQa8.d.ts → types-BP2OCcpg.d.ts} +21 -3
  8. package/dist/_dts/types-x92Kfeme.d.ts +62 -0
  9. package/dist/_dts/{useTrialState-DKjqpv20.d.ts → useTrialState-D6Vb3T-g.d.ts} +7 -7
  10. package/dist/canvas/index.d.ts +9 -8
  11. package/dist/canvas/index.js +1 -2
  12. package/dist/chrome/index.d.ts +7 -6
  13. package/dist/chrome/index.js +5 -5
  14. package/dist/{chunk-UTOEDPNU.js → chunk-2RQPGOQF.js} +7 -6
  15. package/dist/chunk-2RQPGOQF.js.map +1 -0
  16. package/dist/{chunk-ULDW42CR.js → chunk-5TROQVQ2.js} +25 -21
  17. package/dist/chunk-5TROQVQ2.js.map +1 -0
  18. package/dist/{chunk-XKENZTNE.js → chunk-ASWKLRKJ.js} +65 -49
  19. package/dist/chunk-ASWKLRKJ.js.map +1 -0
  20. package/dist/{chunk-W2FJR5FF.js → chunk-C42T6DJT.js} +74 -76
  21. package/dist/chunk-C42T6DJT.js.map +1 -0
  22. package/dist/chunk-E44SU6XS.js +50 -0
  23. package/dist/chunk-E44SU6XS.js.map +1 -0
  24. package/dist/{chunk-WS6ZRV75.js → chunk-FQMJUVHJ.js} +3 -3
  25. package/dist/{chunk-WS6ZRV75.js.map → chunk-FQMJUVHJ.js.map} +1 -1
  26. package/dist/{chunk-FJG4PHTL.js → chunk-I6JCVE24.js} +3 -3
  27. package/dist/chunk-I6JCVE24.js.map +1 -0
  28. package/dist/{chunk-NSOVI3AZ.js → chunk-ISCOFAUO.js} +6 -6
  29. package/dist/{chunk-NSOVI3AZ.js.map → chunk-ISCOFAUO.js.map} +1 -1
  30. package/dist/chunk-MHAGC6VD.js +7320 -0
  31. package/dist/chunk-MHAGC6VD.js.map +1 -0
  32. package/dist/{chunk-UDXOYZEC.js → chunk-QAGAHJKZ.js} +4 -4
  33. package/dist/{chunk-UDXOYZEC.js.map → chunk-QAGAHJKZ.js.map} +1 -1
  34. package/dist/{chunk-TN7YSJVU.js → chunk-RS3HRQWU.js} +3 -3
  35. package/dist/{chunk-TN7YSJVU.js.map → chunk-RS3HRQWU.js.map} +1 -1
  36. package/dist/{chunk-D5KQ5OY6.js → chunk-TJ7QY3OC.js} +3 -3
  37. package/dist/{chunk-D5KQ5OY6.js.map → chunk-TJ7QY3OC.js.map} +1 -1
  38. package/dist/controls/index.d.ts +5 -4
  39. package/dist/controls/index.js +3 -3
  40. package/dist/dragdrop/index.d.ts +6 -5
  41. package/dist/dragdrop/index.js +1 -2
  42. package/dist/index.d.ts +90 -23
  43. package/dist/index.js +199 -117
  44. package/dist/index.js.map +1 -1
  45. package/dist/layers/index.d.ts +7 -6
  46. package/dist/layers/index.js +2 -3
  47. package/dist/loupe/index.d.ts +8 -7
  48. package/dist/loupe/index.js +1 -2
  49. package/dist/passthrough/weasel-canvas.d.ts +1 -3
  50. package/dist/passthrough/weasel-canvas.js +1 -1
  51. package/dist/passthrough/weasel-canvas.js.map +1 -1
  52. package/dist/passthrough/weasel-ui.d.ts +88 -20
  53. package/dist/passthrough/weasel-ui.js +1 -2
  54. package/dist/primitives/index.js +3 -4
  55. package/dist/state/index.d.ts +6 -3
  56. package/dist/state/index.js +3 -2
  57. package/dist/state/index.js.map +1 -1
  58. package/dist/styles.css +2 -2
  59. package/dist/surface/index.js +1 -2
  60. package/dist/ui/layers/index.js +1 -2
  61. package/dist/undo/index.d.ts +6 -6
  62. package/package.json +7 -7
  63. package/src/annotations/ExportMenu.test.tsx +16 -0
  64. package/src/annotations/ExportMenu.tsx +0 -5
  65. package/src/config/builder.test.ts +56 -2
  66. package/src/config/builder.ts +73 -13
  67. package/src/config/index.ts +16 -1
  68. package/src/config/path.test.ts +109 -0
  69. package/src/config/path.ts +76 -0
  70. package/src/config/resolve.test.ts +93 -2
  71. package/src/config/resolve.ts +72 -29
  72. package/src/config/types.ts +99 -9
  73. package/src/config/visible.ts +6 -4
  74. package/src/controls/ControlPanel.stories.tsx +38 -4
  75. package/src/controls/ControlPanel.test.tsx +114 -0
  76. package/src/controls/ControlPanel.tsx +99 -50
  77. package/src/index.ts +16 -1
  78. package/src/instrument/serializers.ts +36 -0
  79. package/src/instrument/types.ts +4 -2
  80. package/src/lab/Lab.test.tsx +29 -1
  81. package/src/lab/Lab.tsx +10 -1
  82. package/src/lab/LabShell.test.tsx +8 -0
  83. package/src/lab/LabShell.tsx +3 -1
  84. package/src/primitives/ZoomControl.less +6 -2
  85. package/src/primitives/ZoomControl.tsx +1 -0
  86. package/src/state/helpers.ts +1 -1
  87. package/src/state/store.test.ts +155 -1
  88. package/src/state/store.ts +30 -24
  89. package/src/state/types.ts +24 -3
  90. package/src/state/useTrialState.ts +1 -1
  91. package/src/trial/Trial.config.test.tsx +44 -0
  92. package/src/trial/Trial.tsx +3 -3
  93. package/src/trial/TrialChrome.tsx +10 -5
  94. package/src/trial/trialOps.ts +4 -8
  95. package/dist/_dts/types-lg4TSCb2.d.ts +0 -164
  96. package/dist/_dts/weasel-canvas-FJTFi3ZZ.d.ts +0 -5041
  97. package/dist/chunk-54ZWZ5FQ.js +0 -29997
  98. package/dist/chunk-54ZWZ5FQ.js.map +0 -1
  99. package/dist/chunk-FJG4PHTL.js.map +0 -1
  100. package/dist/chunk-ISSVF5PT.js +0 -7263
  101. package/dist/chunk-ISSVF5PT.js.map +0 -1
  102. package/dist/chunk-ULDW42CR.js.map +0 -1
  103. package/dist/chunk-UTOEDPNU.js.map +0 -1
  104. package/dist/chunk-W2FJR5FF.js.map +0 -1
  105. package/dist/chunk-XKENZTNE.js.map +0 -1
@@ -1,164 +0,0 @@
1
- import { T as ToolPrefLeaf, a as ToolPrefGroup } from './weasel-canvas-FJTFi3ZZ.js';
2
- import { P as PrefRenderer } from './PrefsForm.d-CgxUequc.js';
3
-
4
- /**
5
- * Renders the control cell for one config leaf. Identical to weasel-ui's
6
- * `PrefRenderer` on purpose — aliased rather than redeclared so the two
7
- * cannot drift.
8
- */
9
- type ControlRenderer = PrefRenderer;
10
- /** One labeled choice in an `enum` leaf. */
11
- interface ConfigOption {
12
- value: string;
13
- label: string;
14
- }
15
- /** Everything a leaf can carry beyond its kind and default. A flat union of
16
- * every `Pref*` leaf's extras, plus labkit's own `debounceMs`. */
17
- interface Annotations {
18
- name?: string;
19
- description?: string;
20
- hidden?: boolean;
21
- block?: boolean;
22
- pair?: string;
23
- min?: number;
24
- max?: number;
25
- step?: number;
26
- suffix?: string;
27
- control?: string;
28
- options?: readonly ConfigOption[];
29
- placeholder?: string;
30
- maxLength?: number;
31
- /** Milliseconds to debounce a string leaf's live writes. Default 150. */
32
- debounceMs?: number;
33
- }
34
- /** What a rule contributes. `kind` is honored only while it is still unset,
35
- * which is what makes `f.value` claimable and a kinded factory final. */
36
- type LeafPatch = Annotations & {
37
- kind?: string;
38
- };
39
- /** What a rule is given for the leaf it is deciding about. */
40
- interface ConfigRuleContext {
41
- /** The config key this leaf writes. */
42
- key: string;
43
- /** Dotted path within the schema. Equal to `key` while schemas are flat. */
44
- path: string;
45
- /** The leaf's default value. A rule may read it but never change it. */
46
- default: unknown;
47
- /** What earlier rules and the author's own annotations have settled. */
48
- leaf: Readonly<LeafPatch>;
49
- }
50
- /**
51
- * Decides part of how a leaf is presented. Returns a patch, or null to
52
- * abstain. Merging is gap-filling: a property already settled is never
53
- * overwritten, so the author's annotations beat every rule and a consumer's
54
- * rules beat labkit's built-ins.
55
- */
56
- type ConfigRule = (ctx: ConfigRuleContext) => LeafPatch | null;
57
- /** A presentational bucket of leaves, rendered under one heading. */
58
- interface SectionSpec {
59
- label: string;
60
- paths: readonly string[];
61
- }
62
- /** A schema resolved against a set of rules: the vocabulary weasel-ui renders,
63
- * plus the three things labkit keeps on the side because `PrefLeaf` has no
64
- * field for them. */
65
- interface ResolvedConfig {
66
- /** Flat: every leaf is a direct child, so a leaf's path is its config key. */
67
- group: ToolPrefGroup;
68
- sections: readonly SectionSpec[];
69
- showIf: ReadonlyMap<string, (config: Record<string, unknown>) => boolean>;
70
- /** Node-level `.render` overrides, keyed by path. */
71
- renderers: Readonly<Record<string, ControlRenderer>>;
72
- }
73
- /** Per-node extras that do not belong on a `PrefLeaf`. */
74
- interface NodeOptions {
75
- section?: string;
76
- showIf?: (config: Record<string, unknown>) => boolean;
77
- render?: ControlRenderer;
78
- validate?: (leaf: ToolPrefLeaf) => string[];
79
- }
80
- /** The builder's leaf: a kind (or null, to be decided by rules), a default,
81
- * an annotation bag, and the extras above. */
82
- interface ConfigNode<T = unknown> {
83
- readonly kind: string | null;
84
- readonly default: T;
85
- readonly annotations: Readonly<Annotations>;
86
- readonly options: Readonly<NodeOptions>;
87
- }
88
- /** The value type a node produces. */
89
- type NodeValue<N> = N extends ConfigNode<infer T> ? T : never;
90
- /** The config type a builder shape produces. */
91
- type InferConfig<S> = {
92
- [K in keyof S]: NodeValue<S[K]>;
93
- };
94
- /** An instrument's config, declared once. */
95
- interface ConfigSchema<TC> {
96
- readonly nodes: Readonly<Record<string, ConfigNode>>;
97
- /** The starting config — what `defaultConfig()` would have returned. */
98
- defaults(): TC;
99
- }
100
- /** The config type behind a schema: `ConfigOf<typeof sceneConfig>`. */
101
- type ConfigOf<S> = S extends ConfigSchema<infer TC> ? TC : never;
102
-
103
- /** Which control a config field is edited with. */
104
- type ConfigFieldType = 'slider' | 'checkbox' | 'select' | 'number' | 'text' | 'color';
105
- /** What every config field carries: the config key it writes, the label shown
106
- * beside it, and which control renders it. */
107
- interface ConfigFieldBase {
108
- key: string;
109
- label: string;
110
- type: ConfigFieldType;
111
- }
112
- /** A bounded number edited by dragging. */
113
- interface SliderField extends ConfigFieldBase {
114
- type: 'slider';
115
- default: number;
116
- min: number;
117
- max: number;
118
- step?: number;
119
- }
120
- /** A boolean. */
121
- interface CheckboxField extends ConfigFieldBase {
122
- type: 'checkbox';
123
- default: boolean;
124
- }
125
- /** One choice in a select field. */
126
- interface SelectOption {
127
- value: string;
128
- label: string;
129
- }
130
- /** A fixed set of labeled choices. */
131
- interface SelectField extends ConfigFieldBase {
132
- type: 'select';
133
- default: string;
134
- options: SelectOption[];
135
- }
136
- /** A number typed directly, optionally bounded. Use a slider field instead
137
- * when the range matters more than the exact value. */
138
- interface NumberField extends ConfigFieldBase {
139
- type: 'number';
140
- default: number;
141
- min?: number;
142
- max?: number;
143
- step?: number;
144
- }
145
- /** A free-text string. Writes are debounced so typing does not re-run the
146
- * instrument on every keystroke. */
147
- interface TextField extends ConfigFieldBase {
148
- type: 'text';
149
- default: string;
150
- placeholder?: string;
151
- maxLength?: number;
152
- /** Milliseconds to debounce live setConfig calls. Default 150 ms. Set to 0 to disable. */
153
- debounceMs?: number;
154
- }
155
- /** A color, as a CSS color string. */
156
- interface ColorField extends ConfigFieldBase {
157
- type: 'color';
158
- default: string;
159
- }
160
- /** One field of an instrument's config schema. The schema is what the control
161
- * panel renders, and what `validateConfigSchema` checks. */
162
- type ConfigField = SliderField | CheckboxField | SelectField | NumberField | TextField | ColorField;
163
-
164
- export type { Annotations as A, ConfigField as C, InferConfig as I, LeafPatch as L, NodeOptions as N, ResolvedConfig as R, SectionSpec as S, TextField as T, ConfigSchema as a, ConfigNode as b, ControlRenderer as c, ConfigOption as d, ConfigRule as e, ConfigRuleContext as f, CheckboxField as g, ColorField as h, ConfigFieldBase as i, ConfigFieldType as j, ConfigOf as k, NodeValue as l, NumberField as m, SelectField as n, SelectOption as o, SliderField as p };