@jbrowse/core 5.0.0-beta.2 → 5.0.0-beta.4

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 (142) hide show
  1. package/README.md +70 -40
  2. package/esm/BaseFeatureWidget/BaseFeatureDetail/FeatureDetails.d.ts +2 -3
  3. package/esm/BaseFeatureWidget/BaseFeatureDetail/ParentFeatureLine.d.ts +4 -0
  4. package/esm/BaseFeatureWidget/BaseFeatureDetail/ParentFeatureLine.js +17 -0
  5. package/esm/BaseFeatureWidget/BaseFeatureDetail/index.js +4 -3
  6. package/esm/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeaturePanel.d.ts +2 -2
  7. package/esm/BaseFeatureWidget/index.d.ts +1 -1
  8. package/esm/BaseFeatureWidget/stateModelFactory.d.ts +8 -1
  9. package/esm/BaseFeatureWidget/stateModelFactory.js +6 -0
  10. package/esm/BaseFeatureWidget/types.d.ts +10 -2
  11. package/esm/PluginManager.d.ts +30 -1
  12. package/esm/PluginManager.js +107 -70
  13. package/esm/ReExports/BaseFeatureDetails.js +1 -1
  14. package/esm/ReExports/MuiDataGridReExports.d.ts +1 -0
  15. package/esm/ReExports/MuiDataGridReExports.js +2 -2
  16. package/esm/ReExports/barrelOnlyNames.d.ts +5 -0
  17. package/esm/ReExports/barrelOnlyNames.js +63 -0
  18. package/esm/ReExports/modules.js +28 -56
  19. package/esm/ReExports/publicTracks.d.ts +1 -0
  20. package/esm/ReExports/publicTracks.js +14 -0
  21. package/esm/ReExports/publicUi.d.ts +4 -0
  22. package/esm/ReExports/publicUi.js +33 -0
  23. package/esm/ReExports/publicUtil.d.ts +1 -1
  24. package/esm/ReExports/publicUtil.js +8 -4
  25. package/esm/ReExports/sharedModules.d.ts +1 -1
  26. package/esm/ReExports/sharedModules.js +8 -1
  27. package/esm/ReExports/uiStub.d.ts +1 -0
  28. package/esm/ReExports/uiStub.js +6 -8
  29. package/esm/ReExports/workerModules.js +9 -4
  30. package/esm/ReExports/workerNamespaceNames.d.ts +11 -0
  31. package/esm/ReExports/workerNamespaceNames.js +281 -0
  32. package/esm/configuration/configurationSchema.js +11 -0
  33. package/esm/configuration/index.d.ts +2 -2
  34. package/esm/configuration/index.js +1 -1
  35. package/esm/configuration/promotableDefaults.d.ts +54 -19
  36. package/esm/configuration/promotableDefaults.js +108 -45
  37. package/esm/configuration/promotablePin.d.ts +50 -40
  38. package/esm/configuration/promotableResolve.d.ts +1 -1
  39. package/esm/configuration/promotableResolve.js +1 -1
  40. package/esm/configuration/tabixIndexFields.d.ts +2 -2
  41. package/esm/configuration/tabixIndexFields.js +2 -2
  42. package/esm/data_adapters/BaseAdapter/BaseFeatureDataAdapter.js +4 -12
  43. package/esm/data_adapters/BaseAdapter/featureDensity.d.ts +12 -0
  44. package/esm/data_adapters/BaseAdapter/featureDensity.js +15 -0
  45. package/esm/data_adapters/BaseAdapter/index.d.ts +2 -2
  46. package/esm/data_adapters/BaseAdapter/index.js +1 -1
  47. package/esm/data_adapters/BaseAdapter/types.d.ts +2 -8
  48. package/esm/pluggableElementTypes/AdapterType.d.ts +2 -1
  49. package/esm/pluggableElementTypes/AdapterType.js +1 -1
  50. package/esm/pluggableElementTypes/DisplayType.d.ts +3 -10
  51. package/esm/pluggableElementTypes/DisplayType.js +3 -45
  52. package/esm/pluggableElementTypes/LazyStateModelElement.d.ts +27 -0
  53. package/esm/pluggableElementTypes/LazyStateModelElement.js +71 -0
  54. package/esm/pluggableElementTypes/ViewType.d.ts +3 -10
  55. package/esm/pluggableElementTypes/ViewType.js +6 -51
  56. package/esm/pluggableElementTypes/extendElementType.d.ts +1 -2
  57. package/esm/pluggableElementTypes/extendElementType.js +1 -2
  58. package/esm/pluggableElementTypes/models/BaseDisplayModel.d.ts +3 -3
  59. package/esm/pluggableElementTypes/models/BaseDisplayModel.js +1 -1
  60. package/esm/pluggableElementTypes/models/BaseTrackModel.js +1 -4
  61. package/esm/pluggableElementTypes/models/BaseViewModel.d.ts +34 -34
  62. package/esm/pluggableElementTypes/models/BaseViewModel.js +19 -30
  63. package/esm/pluggableElementTypes/models/assertDisplayContract.d.ts +4 -3
  64. package/esm/pluggableElementTypes/models/assertDisplayContract.js +2 -2
  65. package/esm/pluggableElementTypes/models/baseTrackConfig.js +7 -1
  66. package/esm/ui/BaseExportSvgDialog.d.ts +1 -1
  67. package/esm/ui/ErrorMessageStackTraceDialog.js +5 -6
  68. package/esm/ui/ExportSvgDialog.d.ts +1 -1
  69. package/esm/ui/MenuTypes.d.ts +3 -3
  70. package/esm/ui/PinAdornment.js +22 -40
  71. package/esm/ui/ScrollChrome.d.ts +16 -0
  72. package/esm/ui/ScrollChrome.js +12 -0
  73. package/esm/ui/ScrollZoomToggle.d.ts +4 -3
  74. package/esm/ui/ScrollZoomToggle.js +4 -3
  75. package/esm/ui/SizeSliderRow.js +1 -1
  76. package/esm/ui/index.d.ts +2 -2
  77. package/esm/ui/index.js +3 -3
  78. package/esm/ui/legendMenuItem.d.ts +9 -15
  79. package/esm/ui/legendMenuItem.js +8 -19
  80. package/esm/ui/menuItemAdornment.d.ts +2 -3
  81. package/esm/ui/menuItemAdornment.js +2 -3
  82. package/esm/ui/menuItems.d.ts +1 -2
  83. package/esm/ui/menuItems.js +0 -1
  84. package/esm/ui/palette.d.ts +11 -11
  85. package/esm/ui/palette.js +11 -11
  86. package/esm/ui/promotablePinCoverage.d.ts +16 -2
  87. package/esm/ui/promotablePinCoverage.js +38 -2
  88. package/esm/ui/theme.js +5 -0
  89. package/esm/ui/toggleMenuItems.d.ts +13 -6
  90. package/esm/ui/toggleMenuItems.js +32 -15
  91. package/esm/util/Base1DUtils.d.ts +4 -2
  92. package/esm/util/Base1DUtils.js +12 -4
  93. package/esm/util/SvgCanvas.js +4 -3
  94. package/esm/util/adapterConfigKey.d.ts +12 -0
  95. package/esm/util/adapterConfigKey.js +14 -0
  96. package/esm/util/adapterMetadata.js +2 -1
  97. package/esm/util/analytics.js +4 -5
  98. package/esm/util/clampToContig.d.ts +17 -0
  99. package/esm/util/clampToContig.js +19 -0
  100. package/esm/util/colorBits.d.ts +2 -1
  101. package/esm/util/colorBits.js +2 -5
  102. package/esm/util/createStopTokenRotation.d.ts +8 -7
  103. package/esm/util/featureTypes.d.ts +24 -0
  104. package/esm/util/featureTypes.js +35 -0
  105. package/esm/util/fetchPhases.d.ts +1 -1
  106. package/esm/util/index.d.ts +4 -2
  107. package/esm/util/index.js +3 -1
  108. package/esm/util/installFetch.d.ts +29 -18
  109. package/esm/util/installFetch.js +17 -17
  110. package/esm/util/installInitAutorun.d.ts +6 -5
  111. package/esm/util/installInitAutorun.js +2 -2
  112. package/esm/util/installPrerequisiteFetch.d.ts +86 -0
  113. package/esm/util/installPrerequisiteFetch.js +73 -0
  114. package/esm/util/openFeatureWidget.d.ts +5 -0
  115. package/esm/util/openFeatureWidget.js +1 -0
  116. package/esm/util/openViews.d.ts +16 -0
  117. package/esm/util/openViews.js +22 -0
  118. package/esm/util/parentWalk.d.ts +1 -1
  119. package/esm/util/parentWalk.js +1 -1
  120. package/esm/util/renderToStaticMarkup.js +10 -0
  121. package/esm/util/scheduleDetachedDestroy.d.ts +18 -0
  122. package/esm/util/scheduleDetachedDestroy.js +24 -0
  123. package/esm/util/scrollLatch.d.ts +1 -0
  124. package/esm/util/scrollLatch.js +8 -0
  125. package/esm/util/stopToken.d.ts +6 -5
  126. package/esm/util/trackConfigDelta.d.ts +6 -6
  127. package/esm/util/trackConfigDelta.js +3 -3
  128. package/esm/util/types/index.d.ts +25 -20
  129. package/esm/util/usePanelVirtualScroll.d.ts +6 -2
  130. package/esm/util/usePanelVirtualScroll.js +6 -2
  131. package/esm/util/useRowVirtualScroll.d.ts +1 -1
  132. package/esm/util/useRowVirtualScroll.js +1 -1
  133. package/esm/util/useVirtualScrollWheel.js +11 -1
  134. package/esm/util/wheelZoom.d.ts +3 -1
  135. package/esm/util/wheelZoom.js +39 -14
  136. package/esm/util/whenViewSettled.d.ts +31 -6
  137. package/esm/util/whenViewSettled.js +33 -5
  138. package/esm/util/withLaunchInput.d.ts +47 -2
  139. package/esm/util/withLaunchInput.js +56 -11
  140. package/package.json +10 -5
  141. package/esm/ui/promotableMenuItems.d.ts +0 -19
  142. package/esm/ui/promotableMenuItems.js +0 -91
@@ -0,0 +1,281 @@
1
+ import { DATA_GRID_NAMES } from './MuiDataGridReExports.js';
2
+ import { MUI_COMPONENT_NAMES } from './muiComponentNames.js';
3
+ // Own-key names of each namespace-shaped UI module the RPC worker stubs.
4
+ // workerModules.test.ts pins them to modules.ts; agent-docs/reference/EAGER_BUNDLE.md
5
+ export const REACT_DOM_NAMES = [
6
+ '__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE',
7
+ 'createPortal',
8
+ 'default',
9
+ 'flushSync',
10
+ 'preconnect',
11
+ 'prefetchDNS',
12
+ 'preinit',
13
+ 'preinitModule',
14
+ 'preload',
15
+ 'preloadModule',
16
+ 'requestFormReset',
17
+ 'unstable_batchedUpdates',
18
+ 'useFormState',
19
+ 'useFormStatus',
20
+ 'version',
21
+ ];
22
+ export const REACT_DOM_CLIENT_NAMES = [
23
+ 'createRoot',
24
+ 'default',
25
+ 'hydrateRoot',
26
+ 'version',
27
+ ];
28
+ export const MOBX_REACT_NAMES = [
29
+ 'Observer',
30
+ '_observerFinalizationRegistry',
31
+ 'clearTimers',
32
+ 'enableStaticRendering',
33
+ 'isUsingStaticRendering',
34
+ 'observer',
35
+ 'useLocalObservable',
36
+ ];
37
+ export const MUI_UTILS_NAMES = [
38
+ 'capitalize',
39
+ 'createChainedFunction',
40
+ 'createSvgIcon',
41
+ 'debounce',
42
+ 'deprecatedPropType',
43
+ 'getActiveElement',
44
+ 'isMuiElement',
45
+ 'mergeSlotProps',
46
+ 'ownerDocument',
47
+ 'ownerWindow',
48
+ 'requirePropFactory',
49
+ 'setRef',
50
+ 'unstable_ClassNameGenerator',
51
+ 'unstable_memoTheme',
52
+ 'unstable_useEnhancedEffect',
53
+ 'unstable_useId',
54
+ 'unsupportedProp',
55
+ 'useControlled',
56
+ 'useEventCallback',
57
+ 'useForkRef',
58
+ ];
59
+ export const MUI_STYLES_NAMES = [
60
+ 'CssVarsProvider',
61
+ 'Experimental_CssVarsProvider',
62
+ 'StyledEngineProvider',
63
+ 'THEME_ID',
64
+ 'ThemeProvider',
65
+ 'adaptV4Theme',
66
+ 'alpha',
67
+ 'createColorScheme',
68
+ 'createStyles',
69
+ 'createTheme',
70
+ 'css',
71
+ 'darken',
72
+ 'decomposeColor',
73
+ 'duration',
74
+ 'easing',
75
+ 'emphasize',
76
+ 'enhanceHighContrast',
77
+ 'experimental_sx',
78
+ 'extendTheme',
79
+ 'getContrastRatio',
80
+ 'getInitColorSchemeScript',
81
+ 'getLuminance',
82
+ 'getOverlayAlpha',
83
+ 'hexToRgb',
84
+ 'hslToRgb',
85
+ 'keyframes',
86
+ 'makeStyles',
87
+ 'private_createTypography',
88
+ 'private_excludeVariablesFromRoot',
89
+ 'recomposeColor',
90
+ 'responsiveFontSizes',
91
+ 'rgbToHex',
92
+ 'shouldSkipGeneratingVar',
93
+ 'styled',
94
+ 'unstable_createBreakpoints',
95
+ 'unstable_createMuiStrictModeTheme',
96
+ 'unstable_getUnit',
97
+ 'unstable_toUnitless',
98
+ 'useColorScheme',
99
+ 'useTheme',
100
+ 'useThemeProps',
101
+ 'withStyles',
102
+ 'withTheme',
103
+ ];
104
+ export const TSS_REACT_NAMES = ['cx', 'keyframes', 'makeStyles'];
105
+ export const MATERIAL_UI_LAB_NAMES = [
106
+ 'Alert',
107
+ 'Autocomplete',
108
+ 'ToggleButton',
109
+ 'ToggleButtonGroup',
110
+ ];
111
+ export const MUI_MATERIAL_NAMES = [
112
+ ...MUI_COMPONENT_NAMES,
113
+ 'alpha',
114
+ 'createTheme',
115
+ 'useTheme',
116
+ ];
117
+ export const MATERIAL_UI_CORE_NAMES = [
118
+ ...MUI_COMPONENT_NAMES,
119
+ 'alpha',
120
+ 'makeStyles',
121
+ 'useTheme',
122
+ ];
123
+ export const CORE_UI_NAMES = [
124
+ 'ActionLink',
125
+ 'AssemblySelector',
126
+ 'BaseExportSvgDialog',
127
+ 'BaseTooltip',
128
+ 'CONTEXT_MENU_Z_INDEX',
129
+ 'CascadingMenu',
130
+ 'CascadingMenuButton',
131
+ 'ConfirmDialog',
132
+ 'ContextMenu',
133
+ 'CopyToClipboardButton',
134
+ 'Crosshairs',
135
+ 'Dialog',
136
+ 'EditableTypography',
137
+ 'ErrorBanner',
138
+ 'ErrorBar',
139
+ 'ErrorMessage',
140
+ 'ErrorOverlay',
141
+ 'ExportSvgDialog',
142
+ 'ExternalLink',
143
+ 'FatalErrorDialog',
144
+ 'FileDropZone',
145
+ 'FileSelector',
146
+ 'GRADIENT_LEGEND_HEIGHT',
147
+ 'GRADIENT_LEGEND_SVG_AREA_WIDTH',
148
+ 'GRADIENT_LEGEND_WIDTH',
149
+ 'GpuFallbackButton',
150
+ 'INLINE_MENU_ROW_WIDTH',
151
+ 'InfoDialog',
152
+ 'JexlFilterDialog',
153
+ 'LAUNCH_LABEL',
154
+ 'LEGEND_ROW_HEIGHT',
155
+ 'LEGEND_SWATCH',
156
+ 'LabeledCheckbox',
157
+ 'LegendSwatchGlyph',
158
+ 'LoadingEllipses',
159
+ 'LoadingOverlay',
160
+ 'LoadingProgress',
161
+ 'LogoFull',
162
+ 'Logomark',
163
+ 'MAX_LEGEND_ITEMS',
164
+ 'Menu',
165
+ 'MonospaceTextField',
166
+ 'NumberTextField',
167
+ 'PinAdornment',
168
+ 'PluggableComponent',
169
+ 'PluggableComponents',
170
+ 'PluggableElements',
171
+ 'PrerenderedCanvas',
172
+ 'ProgressChip',
173
+ 'RefNameAutocomplete',
174
+ 'RefNameAutocompleteEndAdornment',
175
+ 'ReplaceCurrentViewButton',
176
+ 'ResetToDefaultButton',
177
+ 'ResizeHandle',
178
+ 'SanitizedHTML',
179
+ 'ScrollChrome',
180
+ 'ScrollEdgeShadow',
181
+ 'SettingsChangesTable',
182
+ 'ShareLinkField',
183
+ 'SingleSlider',
184
+ 'SliderTooltip',
185
+ 'StatusProgressBar',
186
+ 'SubmitDialog',
187
+ 'SubmitForm',
188
+ 'SvgColorLegend',
189
+ 'SvgGradientLegend',
190
+ 'TOOLTIP_Z_INDEX',
191
+ 'TagTextField',
192
+ 'VIEW_HEADER_HEIGHT',
193
+ 'VerticalScrollbar',
194
+ 'ViewLoadingScreen',
195
+ 'addExtensionElement',
196
+ 'adornmentReservePx',
197
+ 'checkboxItem',
198
+ 'colorFwdStrand',
199
+ 'colorInterchrom',
200
+ 'colorLongInsert',
201
+ 'colorLongreadInv',
202
+ 'colorNeutralRead',
203
+ 'colorPairLL',
204
+ 'colorPairLR',
205
+ 'colorPairLRDark',
206
+ 'colorPairRL',
207
+ 'colorPairRR',
208
+ 'colorRevStrand',
209
+ 'colorShortInsert',
210
+ 'colorSplitReadInversion',
211
+ 'colorSupplementary',
212
+ 'colorUnmappedMate',
213
+ 'colorUnmappedMateDark',
214
+ 'createJBrowseBaseTheme',
215
+ 'createJBrowseTheme',
216
+ 'createJBrowseThemeFromArgs',
217
+ 'defaultThemes',
218
+ 'displayTypesWithPromotableSlots',
219
+ 'getInputWidth',
220
+ 'hoverBoxStyle',
221
+ 'launchTargetsMenuItem',
222
+ 'legendEntries',
223
+ 'legendIsReadable',
224
+ 'legendSwatches',
225
+ 'makePromotableSizeMenu',
226
+ 'makeSizeMenu',
227
+ 'makeSizeSubMenu',
228
+ 'matchesTrackSelector',
229
+ 'measureLegendText',
230
+ 'methylated5hmC',
231
+ 'methylated5mC',
232
+ 'misKindedPins',
233
+ 'nonEmptyLegendSections',
234
+ 'promotableSlotsWithoutPin',
235
+ 'pushIntoSubMenu',
236
+ 'pushLaunchViewMenuItem',
237
+ 'radioItems',
238
+ 'replaceViewAction',
239
+ 'resolveSubMenu',
240
+ 'sliderScale',
241
+ 'staysOpenOnClick',
242
+ 'tagColorPalette',
243
+ 'unmethylated5mC',
244
+ 'useAssemblySelection',
245
+ 'useCopyToClipboard',
246
+ 'useExportSvgPreference',
247
+ 'useMouseState',
248
+ 'useMouseTracking',
249
+ 'useRecentLocations',
250
+ 'wrapComponent',
251
+ ];
252
+ const BASE_FEATURE_DETAIL_NAMES = [
253
+ 'Attributes',
254
+ 'BaseAttributes',
255
+ 'BaseCard',
256
+ 'BaseCoreDetails',
257
+ 'FeatureDetails',
258
+ 'FeatureWash',
259
+ ];
260
+ export const WORKER_NAMESPACE_NAMES = {
261
+ 'react-dom': REACT_DOM_NAMES,
262
+ 'react-dom/client': REACT_DOM_CLIENT_NAMES,
263
+ 'mobx-react': MOBX_REACT_NAMES,
264
+ '@mui/material/utils': MUI_UTILS_NAMES,
265
+ '@material-ui/core/utils': MUI_UTILS_NAMES,
266
+ 'tss-react': TSS_REACT_NAMES,
267
+ 'tss-react/mui': TSS_REACT_NAMES,
268
+ '@mui/material': MUI_MATERIAL_NAMES,
269
+ '@material-ui/core': MATERIAL_UI_CORE_NAMES,
270
+ '@mui/material/styles': MUI_STYLES_NAMES,
271
+ '@material-ui/core/styles': MUI_STYLES_NAMES,
272
+ '@material-ui/lab': MATERIAL_UI_LAB_NAMES,
273
+ '@mui/x-data-grid': DATA_GRID_NAMES,
274
+ '@jbrowse/core/ui': CORE_UI_NAMES,
275
+ // @mui/icons-material is NOT re-exported, so a plugin that wants an icon
276
+ // bundles icons-material, which reads `createSvgIcon` off this module. The
277
+ // main thread serves it (modules.ts) and the worker has to as well, or the
278
+ // plugin throws at module scope building its icons.
279
+ '@mui/material/SvgIcon': ['createSvgIcon'],
280
+ '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail': BASE_FEATURE_DETAIL_NAMES,
281
+ };
@@ -198,6 +198,17 @@ function makeConfigurationSchemaModel(modelName, schemaDefinition, options) {
198
198
  .sort()
199
199
  .join(', ')}`);
200
200
  }
201
+ // MST skips its own type check in a production build, and a value the
202
+ // slot's union cannot take is then dropped with no throw: the write
203
+ // reported success and the slot kept its old value. `is` still runs
204
+ // there, so the guard holds in both builds.
205
+ if (!modelDefinition[slotName].is(value)) {
206
+ const declared = schemaDefinition[slotName];
207
+ const slotType = isSlotDefinitionEntry(declared)
208
+ ? declared.type
209
+ : 'value';
210
+ throw new Error(`${modelName}.${slotName} is a ${slotType} slot and cannot take ${JSON.stringify(value)}`);
211
+ }
201
212
  self[slotName] = value;
202
213
  },
203
214
  }));
@@ -15,5 +15,5 @@ export { toCallbackValue, toFixedValue } from './configurationSlot.ts';
15
15
  export { getSlotDefinition, isConfigurationSlot, makeSlotFacade, preProcessSlotValues, slotChoices, } from './slotFacade.ts';
16
16
  export type { SlotFacade } from './slotFacade.ts';
17
17
  export type { ResolvableDisplay } from './promotableResolve.ts';
18
- export { clearPromotedDefaults, getDisplayTypeDefaultChanges, isSlotCustomized, makePin, getConfigSnapshotWithPromotables, getTrackConfigWithPromotables, } from './promotableDefaults.ts';
19
- export type { Pin, ResolvedConfigSnapshot, TrackConfigWithPromotables, } from './promotableDefaults.ts';
18
+ export { clearPromotedDefaults, getDisplayTypeDefaultChanges, isSlotCustomized, makePin, makeTogglePin, getConfigSnapshotWithPromotables, getTrackConfigWithPromotables, } from './promotableDefaults.ts';
19
+ export type { Pin, ResolvedConfigSnapshot, TogglePin, TrackConfigWithPromotables, ValuePin, } from './promotableDefaults.ts';
@@ -16,4 +16,4 @@ export { tabixIndexFields } from './tabixIndexFields.js';
16
16
  export { evaluateJexl, isCallbackValue } from './slotValueUtils.js';
17
17
  export { toCallbackValue, toFixedValue } from './configurationSlot.js';
18
18
  export { getSlotDefinition, isConfigurationSlot, makeSlotFacade, preProcessSlotValues, slotChoices, } from './slotFacade.js';
19
- export { clearPromotedDefaults, getDisplayTypeDefaultChanges, isSlotCustomized, makePin, getConfigSnapshotWithPromotables, getTrackConfigWithPromotables, } from './promotableDefaults.js';
19
+ export { clearPromotedDefaults, getDisplayTypeDefaultChanges, isSlotCustomized, makePin, makeTogglePin, getConfigSnapshotWithPromotables, getTrackConfigWithPromotables, } from './promotableDefaults.js';
@@ -1,8 +1,8 @@
1
1
  import type { TrackConfigChange } from '../util/trackConfigDelta.ts';
2
- import type { Pin } from './promotablePin.ts';
2
+ import type { TogglePin, ValuePin } from './promotablePin.ts';
3
3
  import type { PromotedDefaultStore, ResolvableDisplay } from './promotableResolve.ts';
4
4
  import type { AnyConfigurationModel, ConfigurationSchemaForModel, ConfigurationSlotName, ConfigurationSlotValueResolved } from './types.ts';
5
- export type { Pin } from './promotablePin.ts';
5
+ export type { Pin, TogglePin, ValuePin } from './promotablePin.ts';
6
6
  /**
7
7
  * #api core/configuration
8
8
  * Whether this track has customized the slot (holds a non-default value of its
@@ -11,10 +11,10 @@ export type { Pin } from './promotablePin.ts';
11
11
  * base instead reads as at-default for a track merely *following* a non-base
12
12
  * promoted default, so the reset control lights up on a no-op.
13
13
  *
14
- * `SLOT` is constrained the way `getConf`'s is. A pin or a reset over a slot
15
- * name the schema does not declare is inert and silent — `resolveSlot` answers
16
- * about nothing, so the control draws outline forever — and a widened `self`
17
- * switches the check off (`HostChecksSlotNames`).
14
+ * `SLOT` is constrained the way `getConf`'s is, and a widened `self` switches
15
+ * the check off (`HostChecksSlotNames`). A slot name the schema does not
16
+ * declare throws at the first read (`getSlotDefinition`), and a declared but
17
+ * non-promotable one throws in `resolveSlotIn`.
18
18
  */
19
19
  export declare function isSlotCustomized<CONFMODEL extends AnyConfigurationModel, SLOT extends ConfigurationSlotName<ConfigurationSchemaForModel<CONFMODEL>>>(self: ResolvableDisplay<CONFMODEL>, slot: SLOT): boolean;
20
20
  declare const promotablesResolved: unique symbol;
@@ -149,20 +149,22 @@ export declare function isPromotableDefault(self: ResolvableDisplay, slot: strin
149
149
  export declare function applySlotToOpenTracks(displays: ResolvableDisplay[], slot: string, value: unknown): void;
150
150
  /**
151
151
  * #api core/configuration
152
- * The pin for one promotable slot: "apply this value to every open track of this
153
- * display type", and — via the snackbar it raises — "keep it as the default for
154
- * the ones opened later".
152
+ * The pin on a radio or slider row: "apply this value to every open track of
153
+ * this display type", and — via the snackbar it raises — "keep it as the
154
+ * default for the ones opened later".
155
155
  *
156
156
  * `value` chooses between the subsystem's two meanings, which are otherwise
157
157
  * identical:
158
158
  *
159
- * - **Give it** for a per-value pin — "make *arcs* the default" — independent of
160
- * what the track currently shows. Use on an always-visible pin so it can never
161
- * promote a meaningless value, and so two rows sharing one slot (arcs `'arc'`
162
- * vs read cloud `'cloud'`; sashimi `'down'` vs `'auto'`) stay independent.
159
+ * - **Give it** for a per-value pin — "make *compact* the default" —
160
+ * independent of what the track currently shows. Use on an always-visible pin
161
+ * so it can never promote a meaningless value, and so two rows sharing one
162
+ * slot (sashimi `'down'` vs `'auto'`) stay independent.
163
163
  * - **Omit it** for "whatever I'm showing", resolved through the cascade. Use for
164
- * a symmetric or continuous setting where no fixed on-value makes sense
165
- * (wiggle point size, arc line width, `mismatchAlpha`).
164
+ * a continuous setting where no fixed on-value makes sense (wiggle point size,
165
+ * arc line width).
166
+ *
167
+ * A checkbox row takes neither: {@link makeTogglePin}.
166
168
  *
167
169
  * One function with an optional argument, rather than the two exported builders
168
170
  * it replaces — a per-value one and a `…CurrentValue…` one, the second of which
@@ -172,7 +174,40 @@ export declare function applySlotToOpenTracks(displays: ResolvableDisplay[], slo
172
174
  */
173
175
  export declare function makePin<CONFMODEL extends AnyConfigurationModel, SLOT extends ConfigurationSlotName<ConfigurationSchemaForModel<CONFMODEL>>>(self: ResolvableDisplay<CONFMODEL>, slot: SLOT, ...value: [] | [
174
176
  ConfigurationSlotValueResolved<ConfigurationSchemaForModel<CONFMODEL>, SLOT>
175
- ]): Pin;
177
+ ]): ValuePin;
178
+ /**
179
+ * The two states a checkbox row moves a slot between. Omitted for a
180
+ * `maybeBoolean` slot, where they are `true` and `false`; required for a
181
+ * two-member enum (`linkedReads`: "View as pairs" toggles `'normal'`/`'off'`).
182
+ * A slot with three or more members is a radio group, not a checkbox per
183
+ * member — `readConnections` was two checkboxes over one slot, and the
184
+ * unticked one's pin wrote the whole slot under a label naming only itself.
185
+ */
186
+ export interface ToggleStates<T> {
187
+ on: T;
188
+ off: T;
189
+ }
190
+ /**
191
+ * #api core/configuration
192
+ * The pin on a checkbox row: the row's own checkbox, acting on every open track
193
+ * of the display type. `active` mirrors the row, so the pin draws filled
194
+ * exactly when the box is ticked; a click flips the row's state on every open
195
+ * track and offers the new state as the display type's default. It never
196
+ * clears a default the way {@link makePin}'s filled pin does — flipping back
197
+ * and taking the offer promotes the other value, and promoting the base value
198
+ * clears the default (`applyAndOfferDefault`).
199
+ *
200
+ * Replaces a symmetric `makePin(self, slot)` on these rows, which carried the
201
+ * row's current state: beside an unchecked box that applied *off* everywhere
202
+ * and visibly did nothing. It also replaces the per-value `makePin` a checkbox
203
+ * row over a shared enum slot used to carry, which gave two checkbox rows in
204
+ * one submenu two different pins: one filled when its value was promoted and
205
+ * clearing on a second click, the other filled when the box was ticked and
206
+ * flipping. With `states`, a checkbox row is always the toggle kind.
207
+ */
208
+ export declare function makeTogglePin<CONFMODEL extends AnyConfigurationModel, SLOT extends ConfigurationSlotName<ConfigurationSchemaForModel<CONFMODEL>>>(self: ResolvableDisplay<CONFMODEL>, slot: SLOT, ...states: ConfigurationSlotValueResolved<ConfigurationSchemaForModel<CONFMODEL>, SLOT> extends boolean ? [] | [ToggleStates<boolean>] : [
209
+ ToggleStates<ConfigurationSlotValueResolved<ConfigurationSchemaForModel<CONFMODEL>, SLOT>>
210
+ ]): TogglePin;
176
211
  /**
177
212
  * #api core/configuration
178
213
  * Effective differences a track following the default inherits from session-wide
@@ -189,9 +224,9 @@ export declare function getDisplayTypeDefaultChanges(self: ResolvableDisplay): T
189
224
  *
190
225
  * **`slots` is required, and an all-slots default is not the convenience it
191
226
  * looks like.** It reaches further than any list a dialog can have shown: a
192
- * promoted default the track *customized* over, or one promoted to a value
193
- * equal to `promotedBase`, is `inherited: false` and so appears in no row, yet
194
- * still governs sibling tracks — so clearing it from a dialog that never showed
227
+ * promoted default the track *customized* over is `inherited: false` and so
228
+ * appears in no row, yet still governs sibling tracks — so clearing it from a
229
+ * dialog that never showed
195
230
  * it moves tracks other than the one whose badge was clicked. Clearing every
196
231
  * promoted default at once is a preferences-scope action, and Preferences →
197
232
  * "Reset to defaults" is where it lives (`clearPreferenceOverrides`).
@@ -24,10 +24,10 @@ import { isConfigurationModel } from './schemaTypes.js';
24
24
  * base instead reads as at-default for a track merely *following* a non-base
25
25
  * promoted default, so the reset control lights up on a no-op.
26
26
  *
27
- * `SLOT` is constrained the way `getConf`'s is. A pin or a reset over a slot
28
- * name the schema does not declare is inert and silent — `resolveSlot` answers
29
- * about nothing, so the control draws outline forever — and a widened `self`
30
- * switches the check off (`HostChecksSlotNames`).
27
+ * `SLOT` is constrained the way `getConf`'s is, and a widened `self` switches
28
+ * the check off (`HostChecksSlotNames`). A slot name the schema does not
29
+ * declare throws at the first read (`getSlotDefinition`), and a declared but
30
+ * non-promotable one throws in `resolveSlotIn`.
31
31
  */
32
32
  export function isSlotCustomized(self, slot) {
33
33
  return resolveSlot(self, slot).customized;
@@ -178,17 +178,11 @@ export function applySlotToOpenTracks(displays, slot, value) {
178
178
  }
179
179
  }
180
180
  /**
181
- * The pin's click. Two branches, chosen by whether this value is *already* the
182
- * display type's promoted default:
183
- *
184
- * - **It isn't** — write `value` into every open track of the type, and offer
185
- * the promotion as a snackbar action. Applying to the tracks in front of the
186
- * user is the click they mean far more often, so it is the one that needs no
187
- * second click; a default outlives the tracks it was set for and governs every
188
- * track of the type opened later, so it is the escalation (ADR-048).
189
- * - **It is** — clear it, touching no track. The open tracks hold their values
190
- * because the user applied them, so reverting them here would make a toggle
191
- * into a bulk discard.
181
+ * The pin's click: write `value` into every open track of the type, and offer
182
+ * the promotion as a snackbar action. Applying to the tracks in front of the
183
+ * user is the click they mean far more often, so it is the one that needs no
184
+ * second click; a default outlives the tracks it was set for and governs every
185
+ * track of the type opened later, so it is the escalation (ADR-048).
192
186
  *
193
187
  * The apply is one operation over *every* open track, not a labeled pair over
194
188
  * the tracks that differ and the tracks that follow. Overwriting a customized
@@ -203,43 +197,60 @@ export function applySlotToOpenTracks(displays, slot, value) {
203
197
  * the offer got a silent no-op. What is still guarded is the session, which owns
204
198
  * the map the write lands in. ADR-048 has the decisions this does not change:
205
199
  * no track set and no apply/promote decision may be closed over.
200
+ *
201
+ * **Promoting the slot's base value clears the default instead of storing it.**
202
+ * The cascade resolves the two identically, but a stored base was a third
203
+ * state the rest of the subsystem could see: the Preferences inventory listed a
204
+ * row reading "from X to X", and the base option's radio pin drew filled. Now
205
+ * "Set as the default" on the base row is the per-value way to undo a promoted
206
+ * default, and a filled pin only ever means a non-base value is promoted. The
207
+ * base is read here rather than at click time because it is a schema literal
208
+ * and cannot change.
206
209
  */
207
- function applyPinClick(self, slot, value, isDefault) {
210
+ function applyAndOfferDefault(self, slot, value) {
208
211
  const session = getSession(self);
209
212
  const displayType = self.type;
210
- if (isDefault) {
211
- session.setDisplayTypeDefault(displayType, slot, undefined);
212
- session.notify('Cleared the default', 'info');
213
- }
214
- else {
215
- const open = openTracksOfType(self);
216
- applySlotToOpenTracks(open, slot, value);
217
- session.notify(`Applied to ${open.length} open ${pluralize(open.length, 'track')}`, 'info', {
218
- name: 'Set as the default',
219
- onClick: () => {
220
- if (isAlive(session)) {
221
- session.setDisplayTypeDefault(displayType, slot, value);
222
- }
223
- },
224
- });
225
- }
213
+ const { base } = resolveSlot(self, slot);
214
+ const promoted = deepEqual(value, base) ? undefined : value;
215
+ const open = openTracksOfType(self);
216
+ applySlotToOpenTracks(open, slot, value);
217
+ session.notify(`Applied to ${open.length} open ${pluralize(open.length, 'track')}`, 'info', {
218
+ name: 'Set as the default',
219
+ onClick: () => {
220
+ if (isAlive(session)) {
221
+ session.setDisplayTypeDefault(displayType, slot, promoted);
222
+ }
223
+ },
224
+ });
225
+ }
226
+ /**
227
+ * A value pin's click when its value is already the promoted default: clear
228
+ * it, touching no track. The open tracks hold their values because the user
229
+ * applied them, so reverting them here would make a toggle into a bulk discard.
230
+ */
231
+ function clearDefault(self, slot) {
232
+ const session = getSession(self);
233
+ session.setDisplayTypeDefault(self.type, slot, undefined);
234
+ session.notify('Cleared the default', 'info');
226
235
  }
227
236
  /**
228
237
  * #api core/configuration
229
- * The pin for one promotable slot: "apply this value to every open track of this
230
- * display type", and — via the snackbar it raises — "keep it as the default for
231
- * the ones opened later".
238
+ * The pin on a radio or slider row: "apply this value to every open track of
239
+ * this display type", and — via the snackbar it raises — "keep it as the
240
+ * default for the ones opened later".
232
241
  *
233
242
  * `value` chooses between the subsystem's two meanings, which are otherwise
234
243
  * identical:
235
244
  *
236
- * - **Give it** for a per-value pin — "make *arcs* the default" — independent of
237
- * what the track currently shows. Use on an always-visible pin so it can never
238
- * promote a meaningless value, and so two rows sharing one slot (arcs `'arc'`
239
- * vs read cloud `'cloud'`; sashimi `'down'` vs `'auto'`) stay independent.
245
+ * - **Give it** for a per-value pin — "make *compact* the default" —
246
+ * independent of what the track currently shows. Use on an always-visible pin
247
+ * so it can never promote a meaningless value, and so two rows sharing one
248
+ * slot (sashimi `'down'` vs `'auto'`) stay independent.
240
249
  * - **Omit it** for "whatever I'm showing", resolved through the cascade. Use for
241
- * a symmetric or continuous setting where no fixed on-value makes sense
242
- * (wiggle point size, arc line width, `mismatchAlpha`).
250
+ * a continuous setting where no fixed on-value makes sense (wiggle point size,
251
+ * arc line width).
252
+ *
253
+ * A checkbox row takes neither: {@link makeTogglePin}.
243
254
  *
244
255
  * One function with an optional argument, rather than the two exported builders
245
256
  * it replaces — a per-value one and a `…CurrentValue…` one, the second of which
@@ -277,11 +288,63 @@ export function makePin(self, slot, ...value) {
277
288
  // same `deepEqual`, no second walk.
278
289
  const active = deepEqual(res.promoted, onValue);
279
290
  return {
291
+ kind: 'value',
292
+ slot,
293
+ onValue,
294
+ active,
295
+ toggle: () => {
296
+ if (active) {
297
+ clearDefault(self, slot);
298
+ }
299
+ else {
300
+ applyAndOfferDefault(self, slot, onValue);
301
+ }
302
+ },
303
+ };
304
+ }
305
+ /**
306
+ * #api core/configuration
307
+ * The pin on a checkbox row: the row's own checkbox, acting on every open track
308
+ * of the display type. `active` mirrors the row, so the pin draws filled
309
+ * exactly when the box is ticked; a click flips the row's state on every open
310
+ * track and offers the new state as the display type's default. It never
311
+ * clears a default the way {@link makePin}'s filled pin does — flipping back
312
+ * and taking the offer promotes the other value, and promoting the base value
313
+ * clears the default (`applyAndOfferDefault`).
314
+ *
315
+ * Replaces a symmetric `makePin(self, slot)` on these rows, which carried the
316
+ * row's current state: beside an unchecked box that applied *off* everywhere
317
+ * and visibly did nothing. It also replaces the per-value `makePin` a checkbox
318
+ * row over a shared enum slot used to carry, which gave two checkbox rows in
319
+ * one submenu two different pins: one filled when its value was promoted and
320
+ * clearing on a second click, the other filled when the box was ticked and
321
+ * flipping. With `states`, a checkbox row is always the toggle kind.
322
+ */
323
+ export function makeTogglePin(self, slot,
324
+ // rest-tuple, like `makePin`'s value: a boolean slot may omit the states, and
325
+ // any other slot has to name them, so the type says which without a runtime
326
+ // check that could only fire on a schema widened to `any`
327
+ ...states) {
328
+ const current = resolveSlot(self, slot).value;
329
+ const [given] = states;
330
+ if (!given && typeof current !== 'boolean') {
331
+ throw new Error(`cannot build a toggle pin over config slot "${slot}" without naming its on/off states: it resolves to ${JSON.stringify(current)}, not a boolean`);
332
+ }
333
+ const { on, off } = given ?? { on: true, off: false };
334
+ for (const state of [on, off]) {
335
+ if (!isPromotableValue(self.configuration, slot, state)) {
336
+ throw new Error(`cannot toggle config slot "${slot}" to ${JSON.stringify(state)}: the cascade refuses it, so the pin could never apply it`);
337
+ }
338
+ }
339
+ const active = deepEqual(current, on);
340
+ const onValue = active ? off : on;
341
+ return {
342
+ kind: 'toggle',
280
343
  slot,
281
344
  onValue,
282
345
  active,
283
346
  toggle: () => {
284
- applyPinClick(self, slot, onValue, active);
347
+ applyAndOfferDefault(self, slot, onValue);
285
348
  },
286
349
  };
287
350
  }
@@ -317,9 +380,9 @@ export function getDisplayTypeDefaultChanges(self) {
317
380
  *
318
381
  * **`slots` is required, and an all-slots default is not the convenience it
319
382
  * looks like.** It reaches further than any list a dialog can have shown: a
320
- * promoted default the track *customized* over, or one promoted to a value
321
- * equal to `promotedBase`, is `inherited: false` and so appears in no row, yet
322
- * still governs sibling tracks — so clearing it from a dialog that never showed
383
+ * promoted default the track *customized* over is `inherited: false` and so
384
+ * appears in no row, yet still governs sibling tracks — so clearing it from a
385
+ * dialog that never showed
323
386
  * it moves tracks other than the one whose badge was clicked. Clearing every
324
387
  * promoted default at once is a preferences-scope action, and Preferences →
325
388
  * "Reset to defaults" is where it lives (`clearPreferenceOverrides`).