@jbrowse/core 2.13.1 → 2.14.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 (149) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.js +2 -2
  2. package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.js +1 -1
  3. package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.js +3 -1
  4. package/BaseFeatureWidget/BaseFeatureDetail/index.js +28 -25
  5. package/BaseFeatureWidget/BaseFeatureDetail/util.js +1 -1
  6. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.js +11 -5
  7. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeaturePanel.d.ts +1 -1
  8. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeaturePanel.js +11 -7
  9. package/BaseFeatureWidget/SequenceFeatureDetails/SequencePanel.js +1 -1
  10. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/HelpDialog.js +6 -2
  11. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceDialog.js +11 -5
  12. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceFeatureMenu.js +15 -5
  13. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceTypeSelector.js +4 -2
  14. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SettingsDialog.js +15 -5
  15. package/BaseFeatureWidget/SequenceFeatureDetails/hooks.js +2 -2
  16. package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDNASequence.js +2 -2
  17. package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/SequenceDisplay.js +5 -3
  18. package/BaseFeatureWidget/stateModelFactory.js +0 -2
  19. package/PluginLoader.d.ts +1 -2
  20. package/PluginLoader.js +16 -6
  21. package/PluginManager.d.ts +13 -13
  22. package/PluginManager.js +7 -2
  23. package/ReExports/modules.js +2 -11
  24. package/assemblyManager/assembly.d.ts +18 -12
  25. package/assemblyManager/assembly.js +75 -52
  26. package/assemblyManager/assemblyConfigSchema.d.ts +9 -7
  27. package/assemblyManager/assemblyConfigSchema.js +15 -16
  28. package/assemblyManager/assemblyManager.d.ts +109 -81
  29. package/assemblyManager/assemblyManager.js +3 -6
  30. package/configuration/configurationSchema.d.ts +1 -1
  31. package/configuration/configurationSchema.js +1 -2
  32. package/configuration/configurationSlot.js +7 -8
  33. package/configuration/util.js +0 -7
  34. package/data_adapters/BaseAdapter/BaseFeatureDataAdapter.d.ts +6 -6
  35. package/data_adapters/BaseAdapter/BaseFeatureDataAdapter.js +6 -6
  36. package/data_adapters/BaseAdapter/BaseRefNameAliasAdapter.d.ts +1 -0
  37. package/data_adapters/CytobandAdapter/CytobandAdapter.d.ts +0 -1
  38. package/data_adapters/CytobandAdapter/CytobandAdapter.js +4 -8
  39. package/data_adapters/dataAdapterCache.d.ts +9 -6
  40. package/data_adapters/dataAdapterCache.js +16 -22
  41. package/package.json +3 -3
  42. package/pluggableElementTypes/AddTrackWorkflowType.js +0 -6
  43. package/pluggableElementTypes/ConnectionType.js +0 -6
  44. package/pluggableElementTypes/DisplayType.js +0 -20
  45. package/pluggableElementTypes/InternetAccountType.js +0 -11
  46. package/pluggableElementTypes/RpcMethodType.d.ts +1 -1
  47. package/pluggableElementTypes/TextSearchAdapterType.js +0 -3
  48. package/pluggableElementTypes/TrackType.js +0 -11
  49. package/pluggableElementTypes/ViewType.js +0 -6
  50. package/pluggableElementTypes/WidgetType.js +0 -6
  51. package/pluggableElementTypes/models/BaseConnectionModelFactory.d.ts +4 -3
  52. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +1 -3
  53. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +4 -5
  54. package/pluggableElementTypes/models/BaseDisplayModel.js +6 -14
  55. package/pluggableElementTypes/models/BaseTrackModel.js +8 -5
  56. package/pluggableElementTypes/models/InternetAccountModel.d.ts +1 -1
  57. package/pluggableElementTypes/models/InternetAccountModel.js +19 -13
  58. package/pluggableElementTypes/models/baseTrackConfig.js +2 -5
  59. package/pluggableElementTypes/renderers/BoxRendererType.d.ts +10 -4
  60. package/pluggableElementTypes/renderers/BoxRendererType.js +10 -26
  61. package/pluggableElementTypes/renderers/CircularChordRendererType.d.ts +1 -1
  62. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.d.ts +9 -12
  63. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +12 -19
  64. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +5 -5
  65. package/pluggableElementTypes/renderers/FeatureRendererType.js +6 -13
  66. package/pluggableElementTypes/renderers/RendererType.js +0 -10
  67. package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.d.ts +1 -1
  68. package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.js +8 -9
  69. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +11 -14
  70. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +4 -4
  71. package/pluggableElementTypes/renderers/ServerSideRendererType.js +7 -5
  72. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +0 -1
  73. package/rpc/BaseRpcDriver.d.ts +1 -1
  74. package/rpc/BaseRpcDriver.js +12 -11
  75. package/rpc/MainThreadRpcDriver.d.ts +2 -2
  76. package/rpc/MainThreadRpcDriver.js +3 -0
  77. package/rpc/RpcManager.d.ts +1 -1
  78. package/rpc/RpcManager.js +11 -8
  79. package/rpc/configSchema.js +0 -1
  80. package/rpc/methods/CoreFreeResources.d.ts +2 -2
  81. package/rpc/methods/CoreGetFeatureDensityStats.d.ts +2 -2
  82. package/rpc/methods/CoreGetFeatureDetails.d.ts +1 -1
  83. package/rpc/methods/CoreGetFeatureDetails.js +3 -3
  84. package/rpc/methods/CoreGetFeatures.d.ts +1 -1
  85. package/rpc/methods/CoreGetFileInfo.d.ts +1 -1
  86. package/rpc/methods/CoreGetMetadata.d.ts +1 -1
  87. package/rpc/methods/CoreGetRefNames.d.ts +1 -1
  88. package/rpc/methods/util.d.ts +2 -2
  89. package/rpc/methods/util.js +0 -3
  90. package/tsconfig.build.tsbuildinfo +1 -1
  91. package/ui/AssemblySelector.js +3 -1
  92. package/ui/CascadingMenu.js +2 -1
  93. package/ui/CascadingMenuButton.js +3 -1
  94. package/ui/ColorPicker.js +14 -4
  95. package/ui/DropDownMenu.js +3 -1
  96. package/ui/EditableTypography.js +6 -2
  97. package/ui/ErrorMessage.d.ts +2 -2
  98. package/ui/ErrorMessage.js +37 -20
  99. package/ui/ErrorMessageStackTraceDialog.js +11 -9
  100. package/ui/FactoryResetDialog.d.ts +1 -1
  101. package/ui/FactoryResetDialog.js +9 -3
  102. package/ui/FatalErrorDialog.js +9 -3
  103. package/ui/FileSelector/FileSelector.js +8 -4
  104. package/ui/FileSelector/LocalFileChooser.js +7 -6
  105. package/ui/LoadingEllipses.js +1 -1
  106. package/ui/Menu.d.ts +4 -4
  107. package/ui/Menu.js +6 -9
  108. package/ui/MenuButton.js +6 -2
  109. package/ui/PrerenderedCanvas.js +8 -5
  110. package/ui/RedErrorMessageBox.js +13 -8
  111. package/ui/ResizeHandle.d.ts +1 -1
  112. package/ui/ReturnToImportFormDialog.js +3 -1
  113. package/ui/SanitizedHTML.js +1 -3
  114. package/ui/SnackbarModel.d.ts +12 -1
  115. package/ui/SnackbarModel.js +19 -3
  116. package/ui/theme.js +5 -5
  117. package/util/Base1DViewModel.js +3 -1
  118. package/util/QuickLRU.js +8 -8
  119. package/util/TimeTraveller.js +12 -4
  120. package/util/analytics.js +0 -1
  121. package/util/blockTypes.js +5 -9
  122. package/util/calculateStaticBlocks.d.ts +1 -1
  123. package/util/compositeMap.js +2 -2
  124. package/util/idMaker.js +0 -1
  125. package/util/index.d.ts +9 -8
  126. package/util/index.js +91 -51
  127. package/util/io/RemoteFileWithRangeCache.js +1 -3
  128. package/util/io/index.js +3 -5
  129. package/util/jexlStrings.js +5 -8
  130. package/util/layouts/GranularRectLayout.js +1 -4
  131. package/util/layouts/SceneGraph.d.ts +1 -1
  132. package/util/layouts/SceneGraph.js +2 -6
  133. package/util/map-obj.js +15 -7
  134. package/util/mst-reflection.js +1 -2
  135. package/util/nanoid.js +9 -8
  136. package/util/offscreenCanvasPonyfill.d.ts +1 -1
  137. package/util/offscreenCanvasPonyfill.js +7 -10
  138. package/util/offscreenCanvasUtils.d.ts +1 -1
  139. package/util/offscreenCanvasUtils.js +1 -3
  140. package/util/rxjs.js +4 -2
  141. package/util/simpleFeature.d.ts +2 -3
  142. package/util/simpleFeature.js +9 -12
  143. package/util/stats.js +3 -1
  144. package/util/tracks.d.ts +4 -2
  145. package/util/tracks.js +10 -11
  146. package/util/types/index.d.ts +5 -5
  147. package/util/types/index.js +8 -1
  148. package/util/types/mst.js +1 -0
  149. package/util/when.js +7 -2
package/util/index.js CHANGED
@@ -87,7 +87,7 @@ exports.stripAlpha = stripAlpha;
87
87
  exports.getStrokeProps = getStrokeProps;
88
88
  exports.getFillProps = getFillProps;
89
89
  exports.renderToStaticMarkup = renderToStaticMarkup;
90
- /* eslint-disable @typescript-eslint/no-explicit-any */
90
+ exports.isGzip = isGzip;
91
91
  const react_1 = require("react");
92
92
  const is_object_1 = __importDefault(require("is-object"));
93
93
  const mobx_state_tree_1 = require("mobx-state-tree");
@@ -127,7 +127,9 @@ function useWidthSetter(view, padding) {
127
127
  // sets after a requestAnimationFrame
128
128
  // https://stackoverflow.com/a/58701523/2129219
129
129
  // avoids ResizeObserver loop error being shown during development
130
- requestAnimationFrame(() => view.setWidth(width - Number.parseInt(padding, 10) * 2));
130
+ requestAnimationFrame(() => {
131
+ view.setWidth(width - Number.parseInt(padding, 10) * 2);
132
+ });
131
133
  }
132
134
  }, [padding, view, width]);
133
135
  return ref;
@@ -137,19 +139,20 @@ function useDebouncedCallback(callback, wait = 400) {
137
139
  // track args & timeout handle between calls
138
140
  const argsRef = (0, react_1.useRef)();
139
141
  const timeout = (0, react_1.useRef)();
140
- function cleanup() {
142
+ // make sure our timeout gets cleared if our consuming component gets
143
+ // unmounted
144
+ (0, react_1.useEffect)(() => {
141
145
  if (timeout.current) {
142
146
  clearTimeout(timeout.current);
143
147
  }
144
- }
145
- // make sure our timeout gets cleared if our consuming component gets
146
- // unmounted
147
- (0, react_1.useEffect)(() => cleanup, []);
148
+ }, []);
148
149
  return function debouncedCallback(...args) {
149
150
  // capture latest args
150
151
  argsRef.current = args;
151
152
  // clear debounce timer
152
- cleanup();
153
+ if (timeout.current) {
154
+ clearTimeout(timeout.current);
155
+ }
153
156
  // start waiting again
154
157
  timeout.current = setTimeout(() => {
155
158
  if (argsRef.current) {
@@ -218,16 +221,22 @@ function springAnimate(fromValue, toValue, setValue, onFinish = () => { }, preci
218
221
  }
219
222
  else {
220
223
  setValue(position);
221
- animationFrameId = requestAnimationFrame(() => update({
222
- lastPosition: position,
223
- lastTime: time,
224
- lastVelocity: velocity,
225
- }));
224
+ animationFrameId = requestAnimationFrame(() => {
225
+ update({
226
+ lastPosition: position,
227
+ lastTime: time,
228
+ lastVelocity: velocity,
229
+ });
230
+ });
226
231
  }
227
232
  }
228
233
  return [
229
- () => update({ lastPosition: fromValue }),
230
- () => cancelAnimationFrame(animationFrameId),
234
+ () => {
235
+ update({ lastPosition: fromValue });
236
+ },
237
+ () => {
238
+ cancelAnimationFrame(animationFrameId);
239
+ },
231
240
  ];
232
241
  }
233
242
  /**
@@ -362,19 +371,26 @@ function parseLocStringOneBased(locString, isValidRefName) {
362
371
  }
363
372
  // remove any whitespace
364
373
  locString = locString.replace(/\s/, '');
365
- // refNames can have colons, ref https://samtools.github.io/hts-specs/SAMv1.pdf Appendix A
366
- const assemblyMatch = locString.match(/({(.+)})?(.+)/);
374
+ // refNames can have colons, refer to
375
+ // https://samtools.github.io/hts-specs/SAMv1.pdf Appendix A
376
+ const assemblyMatch = /({(.+)})?(.+)/.exec(locString);
367
377
  if (!assemblyMatch) {
368
378
  throw new Error(`invalid location string: "${locString}"`);
369
379
  }
370
- const [, , assemblyName, location] = assemblyMatch;
380
+ const [, , assemblyName2, location2] = assemblyMatch;
381
+ const assemblyName = assemblyName2;
382
+ const location = location2;
371
383
  if (!assemblyName && location.startsWith('{}')) {
372
384
  throw new Error(`no assembly name was provided in location "${location}"`);
373
385
  }
374
386
  const lastColonIdx = location.lastIndexOf(':');
375
387
  if (lastColonIdx === -1) {
376
388
  if (isValidRefName(location, assemblyName)) {
377
- return { assemblyName, refName: location, reversed };
389
+ return {
390
+ assemblyName,
391
+ refName: location,
392
+ reversed,
393
+ };
378
394
  }
379
395
  throw new Error(`Unknown reference sequence "${location}"`);
380
396
  }
@@ -387,9 +403,9 @@ function parseLocStringOneBased(locString, isValidRefName) {
387
403
  else if (isValidRefName(prefix, assemblyName)) {
388
404
  if (suffix) {
389
405
  // see if it's a range
390
- const rangeMatch = suffix.match(/^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)(-?(\d+|\d{1,3}(,\d{3})*))$/);
406
+ const rangeMatch = /^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)(-?(\d+|\d{1,3}(,\d{3})*))$/.exec(suffix);
391
407
  // see if it's a single point
392
- const singleMatch = suffix.match(/^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)?$/);
408
+ const singleMatch = /^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)?$/.exec(suffix);
393
409
  if (rangeMatch) {
394
410
  const [, start, , , , end] = rangeMatch;
395
411
  if (start !== undefined && end !== undefined) {
@@ -428,11 +444,19 @@ function parseLocStringOneBased(locString, isValidRefName) {
428
444
  }
429
445
  }
430
446
  else {
431
- return { assemblyName, refName: prefix, reversed };
447
+ return {
448
+ assemblyName,
449
+ refName: prefix,
450
+ reversed,
451
+ };
432
452
  }
433
453
  }
434
454
  else if (isValidRefName(location, assemblyName)) {
435
- return { assemblyName, refName: location, reversed };
455
+ return {
456
+ assemblyName,
457
+ refName: location,
458
+ reversed,
459
+ };
436
460
  }
437
461
  throw new Error(`unknown reference sequence name in location "${locString}"`);
438
462
  }
@@ -671,7 +695,7 @@ reactionOptions, startedFunction, successFunction, errorFunction) {
671
695
  }
672
696
  }
673
697
  catch (e) {
674
- if (thisInProgress && !thisInProgress.signal.aborted) {
698
+ if (!thisInProgress.signal.aborted) {
675
699
  thisInProgress.abort();
676
700
  }
677
701
  handleError(e);
@@ -687,7 +711,7 @@ function renameRegionIfNeeded(refNameMap, region) {
687
711
  if ((0, mobx_state_tree_1.isStateTreeNode)(region) && !(0, mobx_state_tree_1.isAlive)(region)) {
688
712
  return region;
689
713
  }
690
- if (region && (refNameMap === null || refNameMap === void 0 ? void 0 : refNameMap[region.refName])) {
714
+ if (refNameMap === null || refNameMap === void 0 ? void 0 : refNameMap[region.refName]) {
691
715
  // clone the region so we don't modify it
692
716
  region = (0, mobx_state_tree_1.isStateTreeNode)(region)
693
717
  ? { ...(0, mobx_state_tree_1.getSnapshot)(region) }
@@ -724,7 +748,7 @@ function minmax(a, b) {
724
748
  }
725
749
  function shorten(name, max = 70, short = 30) {
726
750
  return name.length > max
727
- ? name.slice(0, short) + '...' + name.slice(-short)
751
+ ? `${name.slice(0, short)}...${name.slice(-short)}`
728
752
  : name;
729
753
  }
730
754
  function stringify({ refName, coord, assemblyName, oob, }, useAssemblyName) {
@@ -795,10 +819,15 @@ exports.complement = (() => {
795
819
  // otherwise listens for prerendered_canvas but reads empty pixels, and doesn't
796
820
  // get the contents of the canvas
797
821
  exports.rIC = typeof jest === 'undefined'
798
- ? typeof window !== 'undefined' && window.requestIdleCallback
799
- ? window.requestIdleCallback
800
- : (cb) => setTimeout(() => cb(), 1)
801
- : (cb) => cb();
822
+ ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
823
+ typeof window !== 'undefined' && window.requestIdleCallback
824
+ ? window.requestIdleCallback
825
+ : (cb) => setTimeout(() => {
826
+ cb();
827
+ }, 1)
828
+ : (cb) => {
829
+ cb();
830
+ };
802
831
  // prettier-ignore
803
832
  const widths = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625];
804
833
  // xref https://gist.github.com/tophtucker/62f93a4658387bb61e4510c37e2e97cf
@@ -947,9 +976,9 @@ async function bytesForRegions(regions, index) {
947
976
  }))
948
977
  .reduce((a, b) => a + b.end - b.start, 0);
949
978
  }
950
- // supported adapter types by text indexer
951
- // ensure that this matches the method found in @jbrowse/text-indexing/util
952
- function isSupportedIndexingAdapter(type) {
979
+ // supported adapter types by text indexer ensure that this matches the method
980
+ // found in @jbrowse/text-indexing/util
981
+ function isSupportedIndexingAdapter(type = '') {
953
982
  return [
954
983
  'Gff3TabixAdapter',
955
984
  'VcfTabixAdapter',
@@ -958,17 +987,15 @@ function isSupportedIndexingAdapter(type) {
958
987
  ].includes(type);
959
988
  }
960
989
  function getBpDisplayStr(totalBp) {
961
- let str;
962
990
  if (Math.floor(totalBp / 1000000) > 0) {
963
- str = `${Number.parseFloat((totalBp / 1000000).toPrecision(3))}Mbp`;
991
+ return `${Number.parseFloat((totalBp / 1000000).toPrecision(3))}Mbp`;
964
992
  }
965
993
  else if (Math.floor(totalBp / 1000) > 0) {
966
- str = `${Number.parseFloat((totalBp / 1000).toPrecision(3))}Kbp`;
994
+ return `${Number.parseFloat((totalBp / 1000).toPrecision(3))}Kbp`;
967
995
  }
968
996
  else {
969
- str = `${toLocale(Math.floor(totalBp))}bp`;
997
+ return `${toLocale(Math.floor(totalBp))}bp`;
970
998
  }
971
- return str;
972
999
  }
973
1000
  function toLocale(n) {
974
1001
  return n.toLocaleString('en-US');
@@ -976,7 +1003,7 @@ function toLocale(n) {
976
1003
  function getTickDisplayStr(totalBp, bpPerPx) {
977
1004
  return Math.floor(bpPerPx / 1000) > 0
978
1005
  ? `${toLocale(Number.parseFloat((totalBp / 1000000).toFixed(2)))}M`
979
- : `${toLocale(Math.floor(totalBp))}`;
1006
+ : toLocale(Math.floor(totalBp));
980
1007
  }
981
1008
  function getViewParams(model, exportSVG) {
982
1009
  // @ts-expect-error
@@ -992,7 +1019,7 @@ function getViewParams(model, exportSVG) {
992
1019
  };
993
1020
  }
994
1021
  function getLayoutId({ sessionId, layoutId, }) {
995
- return sessionId + '-' + layoutId;
1022
+ return `${sessionId}-${layoutId}`;
996
1023
  }
997
1024
  // Hook from https://usehooks.com/useLocalStorage/
998
1025
  function useLocalStorage(key, initialValue) {
@@ -1046,11 +1073,13 @@ function coarseStripHTML(s) {
1046
1073
  return s.replaceAll(/(<([^>]+)>)/gi, '');
1047
1074
  }
1048
1075
  // based on autolink-js, license MIT
1076
+ // https://github.com/bryanwoods/autolink-js/blob/1418049970152c56ced73d43dcc62d80b320fb71/autolink.js#L9
1049
1077
  function linkify(s) {
1050
1078
  const pattern = /(^|[\s\n]|<[A-Za-z]*\/?>)((?:https?|ftp):\/\/[-A-Z0-9+\u0026\u2019@#/%?=()~_|!:,.;]*[-A-Z0-9+\u0026@#/%=~()_|])/gi;
1051
1079
  return s.replaceAll(pattern, '$1<a href=\'$2\' target="_blank">$2</a>');
1052
1080
  }
1053
- // heuristic measurement for a column of a @mui/x-data-grid, pass in values from a column
1081
+ // heuristic measurement for a column of a @mui/x-data-grid, pass in
1082
+ // values from a column
1054
1083
  function measureGridWidth(elements, args) {
1055
1084
  const { padding = 30, minWidth = 80, fontSize = 12, maxWidth = 1000, stripHTML = false, } = args || {};
1056
1085
  return max(elements
@@ -1068,18 +1097,18 @@ function localStorageGetItem(item) {
1068
1097
  : undefined;
1069
1098
  }
1070
1099
  function localStorageSetItem(str, item) {
1071
- return typeof localStorage !== 'undefined'
1072
- ? localStorage.setItem(str, item)
1073
- : undefined;
1100
+ if (typeof localStorage !== 'undefined') {
1101
+ localStorage.setItem(str, item);
1102
+ }
1074
1103
  }
1075
- function max(arr, init = -Infinity) {
1104
+ function max(arr, init = Number.NEGATIVE_INFINITY) {
1076
1105
  let max = init;
1077
1106
  for (const entry of arr) {
1078
1107
  max = entry > max ? entry : max;
1079
1108
  }
1080
1109
  return max;
1081
1110
  }
1082
- function min(arr, init = Infinity) {
1111
+ function min(arr, init = Number.POSITIVE_INFINITY) {
1083
1112
  let min = init;
1084
1113
  for (const entry of arr) {
1085
1114
  min = entry < min ? entry : min;
@@ -1097,11 +1126,13 @@ function avg(arr) {
1097
1126
  return sum(arr) / arr.length;
1098
1127
  }
1099
1128
  function groupBy(array, predicate) {
1100
- var _a;
1101
1129
  const result = {};
1102
1130
  for (const value of array) {
1103
- const entry = (result[_a = predicate(value)] || (result[_a] = []));
1104
- entry.push(value);
1131
+ const t = predicate(value);
1132
+ if (!result[t]) {
1133
+ result[t] = [];
1134
+ }
1135
+ result[t].push(value);
1105
1136
  }
1106
1137
  return result;
1107
1138
  }
@@ -1154,11 +1185,17 @@ function stripAlpha(str) {
1154
1185
  }
1155
1186
  function getStrokeProps(str) {
1156
1187
  const c = (0, colord_1.colord)(str);
1157
- return { strokeOpacity: c.alpha(), stroke: c.alpha(1).toHex() };
1188
+ return {
1189
+ strokeOpacity: c.alpha(),
1190
+ stroke: c.alpha(1).toHex(),
1191
+ };
1158
1192
  }
1159
1193
  function getFillProps(str) {
1160
1194
  const c = (0, colord_1.colord)(str);
1161
- return { fillOpacity: c.alpha(), fill: c.alpha(1).toHex() };
1195
+ return {
1196
+ fillOpacity: c.alpha(),
1197
+ fill: c.alpha(1).toHex(),
1198
+ };
1162
1199
  }
1163
1200
  // https://react.dev/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code
1164
1201
  function renderToStaticMarkup(node, createRootFn) {
@@ -1173,6 +1210,9 @@ function renderToStaticMarkup(node, createRootFn) {
1173
1210
  });
1174
1211
  return div.innerHTML.replaceAll(/\brgba\((.+?),[^,]+?\)/g, 'rgb($1)');
1175
1212
  }
1213
+ function isGzip(buf) {
1214
+ return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
1215
+ }
1176
1216
  var simpleFeature_1 = require("./simpleFeature");
1177
1217
  Object.defineProperty(exports, "SimpleFeature", { enumerable: true, get: function () { return __importDefault(simpleFeature_1).default; } });
1178
1218
  Object.defineProperty(exports, "isFeature", { enumerable: true, get: function () { return simpleFeature_1.isFeature; } });
@@ -25,13 +25,12 @@ function clearCache() {
25
25
  }
26
26
  class RemoteFileWithRangeCache extends generic_filehandle_1.RemoteFile {
27
27
  async fetch(url, init) {
28
- var _a;
29
28
  const str = String(url);
30
29
  if (!fetchers[str]) {
31
30
  fetchers[str] = this.fetchBinaryRange.bind(this);
32
31
  }
33
32
  // if it is a range request, route it through the range cache
34
- const range = (_a = new Headers(init === null || init === void 0 ? void 0 : init.headers)) === null || _a === void 0 ? void 0 : _a.get('range');
33
+ const range = new Headers(init === null || init === void 0 ? void 0 : init.headers).get('range');
35
34
  if (range) {
36
35
  const rangeParse = /bytes=(\d+)-(\d+)/.exec(range);
37
36
  if (rangeParse) {
@@ -62,7 +61,6 @@ class RemoteFileWithRangeCache extends generic_filehandle_1.RemoteFile {
62
61
  }
63
62
  // translate the Headers object into a regular key -> value object.
64
63
  // will miss duplicate headers of course
65
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
64
  const headers = {};
67
65
  for (const [k, v] of res.headers.entries()) {
68
66
  headers[k] = v;
package/util/io/index.js CHANGED
@@ -27,9 +27,6 @@ function resolveUriLocation(location) {
27
27
  : location;
28
28
  }
29
29
  function openLocation(location, pluginManager) {
30
- if (!location) {
31
- throw new Error('must provide a location to openLocation');
32
- }
33
30
  if (isLocalPathLocation(location)) {
34
31
  if (!location.localPath) {
35
32
  throw new Error('No local path provided');
@@ -95,8 +92,9 @@ function getInternetAccount(location, pluginManager) {
95
92
  if (!location.internetAccountPreAuthorization.authInfo.token) {
96
93
  throw new Error('Failed to obtain token from internet account. Try reloading the page');
97
94
  }
98
- const internetAccountType = pluginManager.getInternetAccountType(location.internetAccountPreAuthorization.internetAccountType);
99
- return internetAccountType.stateModel.create({
95
+ return pluginManager
96
+ .getInternetAccountType(location.internetAccountPreAuthorization.internetAccountType)
97
+ .stateModel.create({
100
98
  type: location.internetAccountPreAuthorization.internetAccountType,
101
99
  configuration: location.internetAccountPreAuthorization.authInfo.configuration,
102
100
  });
@@ -5,19 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.stringToJexlExpression = stringToJexlExpression;
7
7
  const jexl_1 = __importDefault(require("./jexl"));
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
8
  const compilationCache = {};
10
- // revert function strings back to main, create a different file for jexlStrings.ts
11
- // pass the jexl property of the pluginManager as a param
9
+ // revert function strings back to main, create a different file for
10
+ // jexlStrings.ts pass the jexl property of the pluginManager as a param
12
11
  /**
13
12
  * compile a jexlExpression to a string
14
13
  *
15
14
  * @param str - string of code like `jexl:...`
16
15
  * @param options -
17
16
  */
18
- function stringToJexlExpression(str,
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- jexl) {
17
+ function stringToJexlExpression(str, jexl) {
21
18
  const cacheKey = `nosig|${str}`;
22
19
  if (!compilationCache[cacheKey]) {
23
20
  const match = str.startsWith('jexl:');
@@ -26,8 +23,8 @@ jexl) {
26
23
  }
27
24
  const code = str.split('jexl:')[1];
28
25
  const compiled = jexl
29
- ? jexl.compile(`${code}`)
30
- : (0, jexl_1.default)().compile(`${code}`);
26
+ ? jexl.compile(code)
27
+ : (0, jexl_1.default)().compile(code);
31
28
  compilationCache[cacheKey] = compiled;
32
29
  }
33
30
  return compilationCache[cacheKey];
@@ -328,14 +328,11 @@ class GranularRectLayout {
328
328
  * the features.
329
329
  */
330
330
  discardRange(left, right) {
331
- // console.log( 'discard', left, right );
332
331
  const pLeft = Math.floor(left / this.pitchX);
333
332
  const pRight = Math.floor(right / this.pitchX);
334
333
  const { bitmap } = this;
335
334
  for (const row of bitmap) {
336
- if (row) {
337
- row.discardRange(pLeft, pRight);
338
- }
335
+ row.discardRange(pLeft, pRight);
339
336
  }
340
337
  }
341
338
  hasSeen(id) {
@@ -35,7 +35,7 @@ export default class SceneGraph {
35
35
  expand(newLeft: number, newRight: number, newTop: number, newBottom: number): void;
36
36
  get bottom(): number;
37
37
  get right(): number;
38
- walkParents(callback: Function): void;
38
+ walkParents(callback: (arg: SceneGraph) => void): void;
39
39
  walkChildren(callback: (c: SceneGraph) => void): void;
40
40
  get absolute(): AbsoluteCache;
41
41
  move(x: number, y: number): void;
@@ -4,9 +4,7 @@ class SceneGraph {
4
4
  /**
5
5
  * note: all coordinates are inter-base or inter-pixel coordinates
6
6
  */
7
- constructor(name, left, top, width, height,
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- data) {
7
+ constructor(name, left, top, width, height, data) {
10
8
  this.name = name;
11
9
  this.left = left;
12
10
  this.top = top;
@@ -16,9 +14,7 @@ class SceneGraph {
16
14
  this.children = new Map();
17
15
  this.absoluteCache = { dirty: true };
18
16
  }
19
- addChild(nameOrSceneGraph, left, top, width, height,
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- data) {
17
+ addChild(nameOrSceneGraph, left, top, width, height, data) {
22
18
  const child = nameOrSceneGraph instanceof SceneGraph
23
19
  ? nameOrSceneGraph
24
20
  : new SceneGraph(nameOrSceneGraph, left, top, width, height, data);
package/util/map-obj.js CHANGED
@@ -9,25 +9,33 @@ const isObjectCustom = (value) => isObject(value) &&
9
9
  !(value instanceof RegExp) &&
10
10
  !(value instanceof Error) &&
11
11
  !(value instanceof Date) &&
12
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
12
13
  !(globalThis.Blob && value instanceof globalThis.Blob);
13
14
  function map(object, mapper, isSeen = new WeakSet()) {
14
15
  if (isSeen.has(object)) {
15
16
  return;
16
17
  }
17
18
  isSeen.add(object);
18
- const mapArray = (array) => array.forEach(element => {
19
- mapper(element);
20
- if (isObject(element)) {
21
- map(element, mapper, isSeen);
22
- }
23
- });
19
+ const mapArray = (array) => {
20
+ array.forEach(element => {
21
+ mapper(element);
22
+ if (isObject(element)) {
23
+ map(element, mapper, isSeen);
24
+ }
25
+ });
26
+ };
24
27
  if (Array.isArray(object)) {
25
28
  mapArray(object);
26
29
  }
27
30
  for (const value of Object.values(object)) {
28
31
  mapper(value);
29
32
  if (isObjectCustom(value)) {
30
- Array.isArray(value) ? mapArray(value) : map(value, mapper, isSeen);
33
+ if (Array.isArray(value)) {
34
+ mapArray(value);
35
+ }
36
+ else {
37
+ map(value, mapper, isSeen);
38
+ }
31
39
  }
32
40
  }
33
41
  }
@@ -6,7 +6,6 @@ exports.getPropertyType = getPropertyType;
6
6
  exports.getDefaultValue = getDefaultValue;
7
7
  exports.getEnumerationValues = getEnumerationValues;
8
8
  exports.resolveLateType = resolveLateType;
9
- /* eslint-disable no-underscore-dangle */
10
9
  const mobx_state_tree_1 = require("mobx-state-tree");
11
10
  /**
12
11
  * get the inner type of an MST optional, array, or late type object
@@ -29,8 +28,8 @@ function getSubType(type) {
29
28
  else {
30
29
  throw new TypeError('unsupported mst type');
31
30
  }
31
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
32
32
  if (!t) {
33
- // debugger
34
33
  throw new Error('failed to get subtype');
35
34
  }
36
35
  return t;
package/util/nanoid.js CHANGED
@@ -7,15 +7,15 @@ exports.nanoid = exports.customAlphabet = exports.customRandom = exports.random
7
7
  // The order of characters is optimized for better gzip and brotli compression.
8
8
  // Same as in non-secure/index.js
9
9
  exports.urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
10
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes));
10
+ const random = bytes => crypto.getRandomValues(new Uint8Array(bytes));
11
11
  exports.random = random;
12
- let customRandom = (alphabet, defaultSize, getRandom) => {
12
+ const customRandom = (alphabet, defaultSize, getRandom) => {
13
13
  // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
14
14
  // values closer to the alphabet size. The bitmask calculates the closest
15
15
  // `2^31 - 1` number, which exceeds the alphabet size.
16
16
  // For example, the bitmask for the alphabet size 30 is 31 (00011111).
17
17
  // `Math.clz32` is not used, because it is not available in browsers.
18
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1;
18
+ const mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1;
19
19
  // Though, the bitmask solution is not perfect since the bytes exceeding
20
20
  // the alphabet size are refused. Therefore, to reliably generate the ID,
21
21
  // the random bytes redundancy has to be satisfied.
@@ -28,26 +28,27 @@ let customRandom = (alphabet, defaultSize, getRandom) => {
28
28
  // according to benchmarks).
29
29
  // `-~f => Math.ceil(f)` if f is a float
30
30
  // `-~i => i + 1` if i is an integer
31
- let step = -~((1.6 * mask * defaultSize) / alphabet.length);
31
+ const step = -~((1.6 * mask * defaultSize) / alphabet.length);
32
32
  return (size = defaultSize) => {
33
33
  let id = '';
34
34
  while (true) {
35
- let bytes = getRandom(step);
35
+ const bytes = getRandom(step);
36
36
  // A compact alternative for `for (var i = 0; i < step; i++)`.
37
37
  let j = step;
38
38
  while (j--) {
39
39
  // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
40
40
  id += alphabet[bytes[j] & mask] || '';
41
- if (id.length === size)
41
+ if (id.length === size) {
42
42
  return id;
43
+ }
43
44
  }
44
45
  }
45
46
  };
46
47
  };
47
48
  exports.customRandom = customRandom;
48
- let customAlphabet = (alphabet, size = 21) => (0, exports.customRandom)(alphabet, size, exports.random);
49
+ const customAlphabet = (alphabet, size = 21) => (0, exports.customRandom)(alphabet, size, exports.random);
49
50
  exports.customAlphabet = customAlphabet;
50
- let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
51
+ const nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
51
52
  // It is incorrect to use bytes exceeding the alphabet size.
52
53
  // The following mask reduces the random byte in the 0-255 value
53
54
  // range to the 0-63 value range. Therefore, adding hacks, such
@@ -3,6 +3,6 @@ type AbstractImageBitmap = any;
3
3
  export declare let createCanvas: (width: number, height: number) => AbstractCanvas;
4
4
  export declare let createImageBitmap: (canvas: AbstractCanvas) => Promise<AbstractImageBitmap>;
5
5
  /** the JS class (constructor) for offscreen-generated image bitmap data */
6
- export declare let ImageBitmapType: Function;
6
+ export declare let ImageBitmapType: unknown;
7
7
  export declare function drawImageOntoCanvasContext(imageData: any, context: CanvasRenderingContext2D): void;
8
8
  export {};
@@ -9,9 +9,7 @@ exports.ImageBitmapType = exports.createImageBitmap = exports.createCanvas = voi
9
9
  exports.drawImageOntoCanvasContext = drawImageOntoCanvasContext;
10
10
  const detect_node_1 = __importDefault(require("detect-node"));
11
11
  const canvas_sequencer_1 = require("canvas-sequencer");
12
- function drawImageOntoCanvasContext(
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- imageData, context) {
12
+ function drawImageOntoCanvasContext(imageData, context) {
15
13
  if (imageData.serializedCommands) {
16
14
  const seq = new canvas_sequencer_1.CanvasSequence(imageData.serializedCommands);
17
15
  seq.execute(context);
@@ -26,27 +24,26 @@ const weHave = {
26
24
  };
27
25
  if (weHave.realOffscreenCanvas) {
28
26
  exports.createCanvas = (width, height) => new OffscreenCanvas(width, height);
27
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
29
28
  exports.createImageBitmap = window.createImageBitmap || self.createImageBitmap;
29
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
30
30
  exports.ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
31
31
  }
32
32
  else if (weHave.node) {
33
33
  // use node-canvas if we are running in node (i.e. automated tests)
34
34
  exports.createCanvas = (...args) => {
35
35
  // @ts-expect-error
36
- // eslint-disable-next-line no-undef
37
36
  return nodeCreateCanvas(...args);
38
37
  };
39
- exports.createImageBitmap = async (canvas, ...otherargs) => {
40
- if (otherargs.length > 0) {
41
- throw new Error('only one-argument uses of createImageBitmap are supported by the node offscreencanvas ponyfill');
42
- }
38
+ exports.createImageBitmap = async (canvas) => {
43
39
  const dataUri = canvas.toDataURL();
44
40
  // @ts-expect-error
45
- // eslint-disable-next-line no-undef
46
41
  const img = new nodeImage();
47
42
  return new Promise((resolve, reject) => {
48
43
  // need onload for jest
49
- img.onload = () => resolve(img);
44
+ img.onload = () => {
45
+ resolve(img);
46
+ };
50
47
  img.onerror = reject;
51
48
  img.src = dataUri;
52
49
  });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export type RenderReturn = Record<string, unknown> | void;
2
+ export type RenderReturn = Record<string, unknown> | undefined;
3
3
  type RendererRet = Promise<RenderReturn> | RenderReturn;
4
4
  export declare function renderToAbstractCanvas(width: number, height: number, opts: {
5
5
  exportSVG?: {
@@ -91,7 +91,5 @@ async function getSerializedSvg(results) {
91
91
  return ctx.getSvg().innerHTML;
92
92
  }
93
93
  function ReactRendering({ rendering, }) {
94
- return react_1.default.isValidElement(rendering.reactElement) ? (rendering.reactElement) : (react_1.default.createElement("g", {
95
- /* eslint-disable-next-line react/no-danger */
96
- dangerouslySetInnerHTML: { __html: rendering.html || '' } }));
94
+ return react_1.default.isValidElement(rendering.reactElement) ? (rendering.reactElement) : (react_1.default.createElement("g", { dangerouslySetInnerHTML: { __html: rendering.html || '' } }));
97
95
  }
package/util/rxjs.js CHANGED
@@ -14,8 +14,10 @@ function ObservableCreate(func, signal) {
14
14
  try {
15
15
  const ret = func(observer);
16
16
  // catch async errors
17
- if (ret && ret.catch) {
18
- ret.catch(error => observer.error(error));
17
+ if (ret === null || ret === void 0 ? void 0 : ret.catch) {
18
+ ret.catch((error) => {
19
+ observer.error(error);
20
+ });
19
21
  }
20
22
  }
21
23
  catch (error) {