@genome-spy/core 0.68.0 → 0.69.1

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 (163) hide show
  1. package/dist/bundle/index.es.js +12119 -10681
  2. package/dist/bundle/index.js +119 -119
  3. package/dist/schema.json +6224 -6319
  4. package/dist/src/data/dataFlow.d.ts.map +1 -1
  5. package/dist/src/data/dataFlow.js +10 -0
  6. package/dist/src/data/flowNode.d.ts +25 -10
  7. package/dist/src/data/flowNode.d.ts.map +1 -1
  8. package/dist/src/data/flowNode.js +66 -13
  9. package/dist/src/data/flowTestUtils.d.ts +2 -2
  10. package/dist/src/data/flowTestUtils.d.ts.map +1 -1
  11. package/dist/src/data/flowTestUtils.js +5 -4
  12. package/dist/src/data/sources/dataSource.js +2 -2
  13. package/dist/src/data/sources/lazy/bigBedSource.d.ts.map +1 -1
  14. package/dist/src/data/sources/lazy/bigBedSource.js +11 -10
  15. package/dist/src/data/sources/lazy/bigWigSource.d.ts.map +1 -1
  16. package/dist/src/data/sources/lazy/bigWigSource.js +11 -10
  17. package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +1 -1
  18. package/dist/src/data/sources/lazy/tabixSource.d.ts +0 -1
  19. package/dist/src/data/sources/lazy/tabixSource.d.ts.map +1 -1
  20. package/dist/src/data/sources/lazy/tabixSource.js +41 -11
  21. package/dist/src/data/sources/sequenceSource.d.ts.map +1 -1
  22. package/dist/src/data/sources/sequenceSource.js +5 -3
  23. package/dist/src/data/sources/urlSource.d.ts.map +1 -1
  24. package/dist/src/data/sources/urlSource.js +7 -3
  25. package/dist/src/data/transforms/filter.d.ts +4 -4
  26. package/dist/src/data/transforms/filter.d.ts.map +1 -1
  27. package/dist/src/data/transforms/filter.js +13 -7
  28. package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
  29. package/dist/src/data/transforms/filterScoredLabels.js +11 -6
  30. package/dist/src/data/transforms/filterScoredLabels.test.d.ts +2 -0
  31. package/dist/src/data/transforms/filterScoredLabels.test.d.ts.map +1 -0
  32. package/dist/src/data/transforms/formula.d.ts +4 -4
  33. package/dist/src/data/transforms/formula.d.ts.map +1 -1
  34. package/dist/src/data/transforms/formula.js +12 -6
  35. package/dist/src/data/transforms/measureText.d.ts +2 -2
  36. package/dist/src/data/transforms/measureText.d.ts.map +1 -1
  37. package/dist/src/data/transforms/measureText.js +16 -12
  38. package/dist/src/data/transforms/transform.d.ts +2 -2
  39. package/dist/src/data/transforms/transform.d.ts.map +1 -1
  40. package/dist/src/data/transforms/transform.js +3 -3
  41. package/dist/src/encoder/accessor.d.ts +8 -4
  42. package/dist/src/encoder/accessor.d.ts.map +1 -1
  43. package/dist/src/encoder/accessor.js +10 -10
  44. package/dist/src/encoder/encoder.js +5 -5
  45. package/dist/src/genome/genome.d.ts +8 -0
  46. package/dist/src/genome/genome.d.ts.map +1 -1
  47. package/dist/src/genome/genome.js +16 -1
  48. package/dist/src/genomeSpy/inputBindingManager.js +1 -1
  49. package/dist/src/genomeSpy/interactionController.d.ts.map +1 -1
  50. package/dist/src/genomeSpy/interactionController.js +7 -1
  51. package/dist/src/genomeSpy.js +1 -1
  52. package/dist/src/gl/glslScaleGenerator.js +1 -1
  53. package/dist/src/marks/mark.d.ts.map +1 -1
  54. package/dist/src/marks/mark.js +22 -30
  55. package/dist/src/marks/point.d.ts.map +1 -1
  56. package/dist/src/marks/point.js +4 -6
  57. package/dist/src/paramRuntime/expressionCompiler.d.ts +7 -0
  58. package/dist/src/paramRuntime/expressionCompiler.d.ts.map +1 -0
  59. package/dist/src/paramRuntime/expressionCompiler.js +10 -0
  60. package/dist/src/paramRuntime/expressionRef.d.ts +20 -0
  61. package/dist/src/paramRuntime/expressionRef.d.ts.map +1 -0
  62. package/dist/src/paramRuntime/expressionRef.js +95 -0
  63. package/dist/src/paramRuntime/expressionRef.test.d.ts +2 -0
  64. package/dist/src/paramRuntime/expressionRef.test.d.ts.map +1 -0
  65. package/dist/src/paramRuntime/graphRuntime.d.ts +176 -0
  66. package/dist/src/paramRuntime/graphRuntime.d.ts.map +1 -0
  67. package/dist/src/paramRuntime/graphRuntime.js +628 -0
  68. package/dist/src/paramRuntime/graphRuntime.test.d.ts +2 -0
  69. package/dist/src/paramRuntime/graphRuntime.test.d.ts.map +1 -0
  70. package/dist/src/paramRuntime/index.d.ts +9 -0
  71. package/dist/src/paramRuntime/index.d.ts.map +1 -0
  72. package/dist/src/paramRuntime/index.js +8 -0
  73. package/dist/src/paramRuntime/lifecycleRegistry.d.ts +27 -0
  74. package/dist/src/paramRuntime/lifecycleRegistry.d.ts.map +1 -0
  75. package/dist/src/paramRuntime/lifecycleRegistry.js +54 -0
  76. package/dist/src/paramRuntime/paramRuntime.d.ts +165 -0
  77. package/dist/src/paramRuntime/paramRuntime.d.ts.map +1 -0
  78. package/dist/src/paramRuntime/paramRuntime.js +222 -0
  79. package/dist/src/paramRuntime/paramRuntime.test.d.ts +2 -0
  80. package/dist/src/paramRuntime/paramRuntime.test.d.ts.map +1 -0
  81. package/dist/src/paramRuntime/paramStore.d.ts +68 -0
  82. package/dist/src/paramRuntime/paramStore.d.ts.map +1 -0
  83. package/dist/src/paramRuntime/paramStore.js +148 -0
  84. package/dist/src/paramRuntime/paramStore.test.d.ts +2 -0
  85. package/dist/src/paramRuntime/paramStore.test.d.ts.map +1 -0
  86. package/dist/src/paramRuntime/paramUtils.d.ts +86 -0
  87. package/dist/src/paramRuntime/paramUtils.d.ts.map +1 -0
  88. package/dist/src/paramRuntime/paramUtils.js +272 -0
  89. package/dist/src/paramRuntime/selectionStore.d.ts +6 -0
  90. package/dist/src/paramRuntime/selectionStore.d.ts.map +1 -0
  91. package/dist/src/paramRuntime/selectionStore.js +13 -0
  92. package/dist/src/paramRuntime/types.d.ts +16 -0
  93. package/dist/src/paramRuntime/types.d.ts.map +1 -0
  94. package/dist/src/paramRuntime/types.js +25 -0
  95. package/dist/src/paramRuntime/viewParamRuntime.d.ts +164 -0
  96. package/dist/src/paramRuntime/viewParamRuntime.d.ts.map +1 -0
  97. package/dist/src/paramRuntime/viewParamRuntime.js +443 -0
  98. package/dist/src/scales/scaleInstanceManager.d.ts +6 -3
  99. package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -1
  100. package/dist/src/scales/scaleInstanceManager.js +17 -11
  101. package/dist/src/scales/scaleResolution.d.ts +1 -0
  102. package/dist/src/scales/scaleResolution.d.ts.map +1 -1
  103. package/dist/src/scales/scaleResolution.js +7 -1
  104. package/dist/src/selection/selection.js +1 -1
  105. package/dist/src/spec/coreSchemaRoot.d.ts +53 -0
  106. package/dist/src/spec/root.d.ts +1 -1
  107. package/dist/src/spec/view.d.ts +114 -33
  108. package/dist/src/tooltip/dataTooltipHandler.d.ts +1 -1
  109. package/dist/src/tooltip/dataTooltipHandler.js +23 -32
  110. package/dist/src/tooltip/dataTooltipHandler.test.d.ts +2 -0
  111. package/dist/src/tooltip/dataTooltipHandler.test.d.ts.map +1 -0
  112. package/dist/src/tooltip/flattenDatumRows.d.ts +13 -0
  113. package/dist/src/tooltip/flattenDatumRows.d.ts.map +1 -0
  114. package/dist/src/tooltip/flattenDatumRows.js +47 -0
  115. package/dist/src/tooltip/flattenDatumRows.test.d.ts +2 -0
  116. package/dist/src/tooltip/flattenDatumRows.test.d.ts.map +1 -0
  117. package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +1 -1
  118. package/dist/src/tooltip/refseqGeneTooltipHandler.js +7 -1
  119. package/dist/src/tooltip/tooltipContext.d.ts +13 -0
  120. package/dist/src/tooltip/tooltipContext.d.ts.map +1 -0
  121. package/dist/src/tooltip/tooltipContext.js +543 -0
  122. package/dist/src/tooltip/tooltipContext.test.d.ts +2 -0
  123. package/dist/src/tooltip/tooltipContext.test.d.ts.map +1 -0
  124. package/dist/src/tooltip/tooltipHandler.d.ts +40 -1
  125. package/dist/src/tooltip/tooltipHandler.d.ts.map +1 -1
  126. package/dist/src/tooltip/tooltipHandler.ts +62 -1
  127. package/dist/src/types/encoder.d.ts +1 -1
  128. package/dist/src/utils/inputBinding.d.ts +10 -2
  129. package/dist/src/utils/inputBinding.d.ts.map +1 -1
  130. package/dist/src/utils/inputBinding.js +12 -3
  131. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  132. package/dist/src/view/flowBuilder.js +12 -3
  133. package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
  134. package/dist/src/view/gridView/gridChild.js +8 -3
  135. package/dist/src/view/gridView/selectionRect.d.ts +6 -10
  136. package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
  137. package/dist/src/view/gridView/selectionRect.js +3 -20
  138. package/dist/src/view/layerView.d.ts.map +1 -1
  139. package/dist/src/view/layerView.js +4 -2
  140. package/dist/src/view/multiscale.d.ts +35 -0
  141. package/dist/src/view/multiscale.d.ts.map +1 -0
  142. package/dist/src/view/multiscale.js +233 -0
  143. package/dist/src/view/multiscale.test.d.ts +2 -0
  144. package/dist/src/view/multiscale.test.d.ts.map +1 -0
  145. package/dist/src/view/unitView.d.ts.map +1 -1
  146. package/dist/src/view/unitView.js +10 -4
  147. package/dist/src/view/view.d.ts +5 -4
  148. package/dist/src/view/view.d.ts.map +1 -1
  149. package/dist/src/view/view.js +223 -28
  150. package/dist/src/view/viewFactory.d.ts +0 -12
  151. package/dist/src/view/viewFactory.d.ts.map +1 -1
  152. package/dist/src/view/viewFactory.js +35 -24
  153. package/dist/src/view/viewParamRuntime.test.d.ts +2 -0
  154. package/dist/src/view/viewParamRuntime.test.d.ts.map +1 -0
  155. package/dist/src/view/viewSelectors.d.ts.map +1 -1
  156. package/dist/src/view/viewSelectors.js +8 -5
  157. package/package.json +3 -3
  158. package/dist/src/spec/sampleView.d.ts +0 -197
  159. package/dist/src/view/paramMediator.d.ts +0 -168
  160. package/dist/src/view/paramMediator.d.ts.map +0 -1
  161. package/dist/src/view/paramMediator.js +0 -545
  162. package/dist/src/view/paramMediator.test.d.ts +0 -2
  163. package/dist/src/view/paramMediator.test.d.ts.map +0 -1
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @typedef {import("../utils/expression.js").ExpressionFunction & {
3
+ * subscribe: (listener: () => void) => () => void,
4
+ * invalidate: () => void,
5
+ * identifier: () => string
6
+ * }} ExprRefFunction
7
+ */
8
+ /**
9
+ * @param {any} x
10
+ * @returns {x is import("../spec/parameter.js").ExprRef}
11
+ */
12
+ export function isExprRef(x: any): x is import("../spec/parameter.js").ExprRef;
13
+ /**
14
+ * Removes ExprRef from the type and checks that the value is not an ExprRef.
15
+ * This is designed to be used with `activateExprRefProps`.
16
+ *
17
+ * @param {T | import("../spec/parameter.js").ExprRef} x
18
+ * @template T
19
+ * @returns {T}
20
+ */
21
+ export function withoutExprRef<T>(x: T | import("../spec/parameter.js").ExprRef): T;
22
+ /**
23
+ * @param {import("../spec/parameter.js").Parameter} param
24
+ * @returns {param is import("../spec/parameter.js").VariableParameter}
25
+ */
26
+ export function isVariableParameter(param: import("../spec/parameter.js").Parameter): param is import("../spec/parameter.js").VariableParameter;
27
+ /**
28
+ * @param {import("../spec/parameter.js").Parameter} param
29
+ * @returns {param is import("../spec/parameter.js").SelectionParameter}
30
+ */
31
+ export function isSelectionParameter(param: import("../spec/parameter.js").Parameter): param is import("../spec/parameter.js").SelectionParameter;
32
+ /**
33
+ * Validates a parameter name. If the name is invalid, throws an error.
34
+ * Otherwise, returns the name.
35
+ *
36
+ * @param {string} name
37
+ * @returns {string} the name
38
+ */
39
+ export function validateParameterName(name: string): string;
40
+ /**
41
+ * Computes the default value for a parameter specification.
42
+ *
43
+ * @param {import("../spec/parameter.js").Parameter} param
44
+ * @param {{ createExpression: (expr: string) => ExprRefFunction }} [paramRuntime]
45
+ * @param {ExprRefFunction} [exprFn]
46
+ * @returns {any}
47
+ */
48
+ export function getDefaultParamValue(param: import("../spec/parameter.js").Parameter, paramRuntime?: {
49
+ createExpression: (expr: string) => ExprRefFunction;
50
+ }, exprFn?: ExprRefFunction): any;
51
+ /**
52
+ * Takes a record of properties that may have ExprRefs as values. Converts the
53
+ * ExprRefs to getters and setups a listener that is called when any of the
54
+ * expressions (upstream parameters) change.
55
+ *
56
+ * @param {{ createExpression: (expr: string) => ExprRefFunction, watchExpression?: (expr: string, listener: () => void, options?: { scopeOwned?: boolean, registerDisposer?: (disposer: () => void) => void }) => ExprRefFunction, whenPropagated?: () => Promise<void> }} paramRuntime
57
+ * @param {T} props The properties object
58
+ * @param {(props: ReadonlySet<keyof T>) => void} [listener] Listener to be called when any of the expressions change
59
+ * @param {(disposer: () => void) => void} [registerDisposer]
60
+ * @param {{ batchMode?: "microtask" | "whenPropagated" }} [options]
61
+ * @returns T
62
+ * @template {Record<string, any | import("../spec/parameter.js").ExprRef>} T
63
+ */
64
+ export function activateExprRefProps<T extends Record<string, any | import("../spec/parameter.js").ExprRef>>(paramRuntime: {
65
+ createExpression: (expr: string) => ExprRefFunction;
66
+ watchExpression?: (expr: string, listener: () => void, options?: {
67
+ scopeOwned?: boolean;
68
+ registerDisposer?: (disposer: () => void) => void;
69
+ }) => ExprRefFunction;
70
+ whenPropagated?: () => Promise<void>;
71
+ }, props: T, listener?: (props: ReadonlySet<keyof T>) => void, registerDisposer?: (disposer: () => void) => void, options?: {
72
+ batchMode?: "microtask" | "whenPropagated";
73
+ }): T;
74
+ /**
75
+ * Creates a function that always returns the same value.
76
+ *
77
+ * @param {any} value
78
+ * @returns {ExprRefFunction}
79
+ */
80
+ export function makeConstantExprRef(value: any): ExprRefFunction;
81
+ export type ExprRefFunction = import("../utils/expression.js").ExpressionFunction & {
82
+ subscribe: (listener: () => void) => () => void;
83
+ invalidate: () => void;
84
+ identifier: () => string;
85
+ };
86
+ //# sourceMappingURL=paramUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paramUtils.d.ts","sourceRoot":"","sources":["../../../src/paramRuntime/paramUtils.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AAEH;;;GAGG;AACH,6BAHW,GAAG,GACD,CAAC,IAAI,OAAO,sBAAsB,EAAE,OAAO,CAIvD;AAED;;;;;;;GAOG;AACH,+BAHa,CAAC,KADH,CAAC,GAAG,OAAO,sBAAsB,EAAE,OAAO,GAExC,CAAC,CAWb;AAED;;;GAGG;AACH,2CAHW,OAAO,sBAAsB,EAAE,SAAS,GACtC,KAAK,IAAI,OAAO,sBAAsB,EAAE,iBAAiB,CAIrE;AAED;;;GAGG;AACH,4CAHW,OAAO,sBAAsB,EAAE,SAAS,GACtC,KAAK,IAAI,OAAO,sBAAsB,EAAE,kBAAkB,CAItE;AAED;;;;;;GAMG;AACH,4CAHW,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,4CALW,OAAO,sBAAsB,EAAE,SAAS,iBACxC;IAAE,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAA;CAAE,WACvD,eAAe,GACb,GAAG,CA0Cf;AAED;;;;;;;;;;;;GAYG;AACH,qCAF4E,CAAC,SAA/D,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,sBAAsB,EAAE,OAAO,CAAE,gBANhE;IAAE,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAC;IAAC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;KAAE,KAAK,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,SAC/P,CAAC,aACD,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,qBACrC,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,YAC9B;IAAE,SAAS,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAAA;CAAE,GAkHnC,CAAC,CACtB;AAED;;;;;GAKG;AACH,2CAHW,GAAG,GACD,eAAe,CAW3B;8BApQY,OAAO,wBAAwB,EAAE,kBAAkB,GAAG;IAC9D,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,MAAM,CAAA;CACzB"}
@@ -0,0 +1,272 @@
1
+ import { isString } from "vega-util";
2
+ import {
3
+ asSelectionConfig,
4
+ createIntervalSelection,
5
+ createMultiPointSelection,
6
+ createSinglePointSelection,
7
+ isIntervalSelectionConfig,
8
+ isPointSelectionConfig,
9
+ } from "../selection/selection.js";
10
+
11
+ /**
12
+ * @typedef {import("../utils/expression.js").ExpressionFunction & {
13
+ * subscribe: (listener: () => void) => () => void,
14
+ * invalidate: () => void,
15
+ * identifier: () => string
16
+ * }} ExprRefFunction
17
+ */
18
+
19
+ /**
20
+ * @param {any} x
21
+ * @returns {x is import("../spec/parameter.js").ExprRef}
22
+ */
23
+ export function isExprRef(x) {
24
+ return typeof x == "object" && x != null && "expr" in x && isString(x.expr);
25
+ }
26
+
27
+ /**
28
+ * Removes ExprRef from the type and checks that the value is not an ExprRef.
29
+ * This is designed to be used with `activateExprRefProps`.
30
+ *
31
+ * @param {T | import("../spec/parameter.js").ExprRef} x
32
+ * @template T
33
+ * @returns {T}
34
+ */
35
+ export function withoutExprRef(x) {
36
+ if (isExprRef(x)) {
37
+ throw new Error(
38
+ "ExprRef " +
39
+ JSON.stringify(x) +
40
+ " not allowed here. Expected a scalar value."
41
+ );
42
+ }
43
+ return /** @type {T} */ (x);
44
+ }
45
+
46
+ /**
47
+ * @param {import("../spec/parameter.js").Parameter} param
48
+ * @returns {param is import("../spec/parameter.js").VariableParameter}
49
+ */
50
+ export function isVariableParameter(param) {
51
+ return ("expr" in param || "bind" in param) && !("select" in param);
52
+ }
53
+
54
+ /**
55
+ * @param {import("../spec/parameter.js").Parameter} param
56
+ * @returns {param is import("../spec/parameter.js").SelectionParameter}
57
+ */
58
+ export function isSelectionParameter(param) {
59
+ return !("expr" in param || "bind" in param) && "select" in param;
60
+ }
61
+
62
+ /**
63
+ * Validates a parameter name. If the name is invalid, throws an error.
64
+ * Otherwise, returns the name.
65
+ *
66
+ * @param {string} name
67
+ * @returns {string} the name
68
+ */
69
+ export function validateParameterName(name) {
70
+ if (!/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name)) {
71
+ throw new Error(
72
+ "Invalid parameter name: " +
73
+ name +
74
+ ". Must be a valid JavaScript identifier."
75
+ );
76
+ }
77
+
78
+ return name;
79
+ }
80
+
81
+ /**
82
+ * Computes the default value for a parameter specification.
83
+ *
84
+ * @param {import("../spec/parameter.js").Parameter} param
85
+ * @param {{ createExpression: (expr: string) => ExprRefFunction }} [paramRuntime]
86
+ * @param {ExprRefFunction} [exprFn]
87
+ * @returns {any}
88
+ */
89
+ export function getDefaultParamValue(param, paramRuntime, exprFn) {
90
+ if ("select" in param) {
91
+ const select = asSelectionConfig(param.select);
92
+ if (isPointSelectionConfig(select)) {
93
+ return select.toggle
94
+ ? createMultiPointSelection()
95
+ : createSinglePointSelection(null);
96
+ }
97
+ if (isIntervalSelectionConfig(select)) {
98
+ if (!select.encodings) {
99
+ throw new Error(
100
+ 'Interval selection "' +
101
+ param.name +
102
+ '" must have encodings defined!'
103
+ );
104
+ }
105
+ return createIntervalSelection(select.encodings);
106
+ }
107
+ throw new Error(
108
+ 'Unknown selection config for parameter "' + param.name + '".'
109
+ );
110
+ }
111
+
112
+ if ("expr" in param) {
113
+ const expr =
114
+ exprFn ??
115
+ paramRuntime?.createExpression(/** @type {string} */ (param.expr));
116
+ if (!expr) {
117
+ throw new Error(
118
+ 'Cannot evaluate expression for parameter "' + param.name + '".'
119
+ );
120
+ }
121
+ return expr(null);
122
+ }
123
+
124
+ if ("value" in param) {
125
+ return param.value;
126
+ }
127
+
128
+ return null;
129
+ }
130
+
131
+ /**
132
+ * Takes a record of properties that may have ExprRefs as values. Converts the
133
+ * ExprRefs to getters and setups a listener that is called when any of the
134
+ * expressions (upstream parameters) change.
135
+ *
136
+ * @param {{ createExpression: (expr: string) => ExprRefFunction, watchExpression?: (expr: string, listener: () => void, options?: { scopeOwned?: boolean, registerDisposer?: (disposer: () => void) => void }) => ExprRefFunction, whenPropagated?: () => Promise<void> }} paramRuntime
137
+ * @param {T} props The properties object
138
+ * @param {(props: ReadonlySet<keyof T>) => void} [listener] Listener to be called when any of the expressions change
139
+ * @param {(disposer: () => void) => void} [registerDisposer]
140
+ * @param {{ batchMode?: "microtask" | "whenPropagated" }} [options]
141
+ * @returns T
142
+ * @template {Record<string, any | import("../spec/parameter.js").ExprRef>} T
143
+ */
144
+ export function activateExprRefProps(
145
+ paramRuntime,
146
+ props,
147
+ listener,
148
+ registerDisposer,
149
+ options = {}
150
+ ) {
151
+ /** @type {Record<string, any | import("../spec/parameter.js").ExprRef>} */
152
+ const activatedProps = { ...props };
153
+
154
+ /** @type {Set<keyof T>} */
155
+ const alteredProps = new Set();
156
+
157
+ let scheduled = false;
158
+ let cancelled = false;
159
+ const batchMode = options.batchMode ?? "microtask";
160
+
161
+ const cancel = () => {
162
+ cancelled = true;
163
+ alteredProps.clear();
164
+ scheduled = false;
165
+ };
166
+
167
+ registerDisposer?.(cancel);
168
+
169
+ const flushChanges = () => {
170
+ if (cancelled) {
171
+ return;
172
+ }
173
+
174
+ if (!listener || alteredProps.size === 0) {
175
+ scheduled = false;
176
+ return;
177
+ }
178
+
179
+ const changedProps = new Set(alteredProps);
180
+ alteredProps.clear();
181
+ scheduled = false;
182
+ listener(changedProps);
183
+ };
184
+
185
+ const batchPropertyChange = (/** @type {keyof T} */ prop) => {
186
+ if (cancelled) {
187
+ return;
188
+ }
189
+
190
+ alteredProps.add(prop);
191
+ if (!scheduled) {
192
+ scheduled = true;
193
+ queueMicrotask(() => {
194
+ if (cancelled) {
195
+ return;
196
+ }
197
+
198
+ if (
199
+ batchMode == "whenPropagated" &&
200
+ paramRuntime.whenPropagated
201
+ ) {
202
+ paramRuntime
203
+ .whenPropagated()
204
+ .then(flushChanges)
205
+ .catch(() => {
206
+ flushChanges();
207
+ });
208
+ } else {
209
+ flushChanges();
210
+ }
211
+ });
212
+ }
213
+ };
214
+
215
+ for (const [key, value] of Object.entries(props)) {
216
+ if (isExprRef(value)) {
217
+ if (listener) {
218
+ const expressionListener = () => batchPropertyChange(key);
219
+ const fn = paramRuntime.watchExpression
220
+ ? paramRuntime.watchExpression(
221
+ value.expr,
222
+ expressionListener,
223
+ {
224
+ scopeOwned: !registerDisposer,
225
+ registerDisposer,
226
+ }
227
+ )
228
+ : paramRuntime.createExpression(value.expr);
229
+ if (!paramRuntime.watchExpression) {
230
+ const unsubscribe = fn.subscribe(expressionListener);
231
+ registerDisposer?.(unsubscribe);
232
+ }
233
+
234
+ Object.defineProperty(activatedProps, key, {
235
+ enumerable: true,
236
+ get() {
237
+ return fn();
238
+ },
239
+ });
240
+ } else {
241
+ const fn = paramRuntime.createExpression(value.expr);
242
+ Object.defineProperty(activatedProps, key, {
243
+ enumerable: true,
244
+ get() {
245
+ return fn();
246
+ },
247
+ });
248
+ }
249
+ } else {
250
+ activatedProps[key] = value;
251
+ }
252
+ }
253
+
254
+ return /** @type {T} */ (activatedProps);
255
+ }
256
+
257
+ /**
258
+ * Creates a function that always returns the same value.
259
+ *
260
+ * @param {any} value
261
+ * @returns {ExprRefFunction}
262
+ */
263
+ export function makeConstantExprRef(value) {
264
+ return Object.assign(() => value, {
265
+ subscribe: () => () => /** @type {void} */ (undefined),
266
+ invalidate: () => /** @type {void} */ (undefined),
267
+ identifier: () => "constant",
268
+ fields: [],
269
+ globals: [],
270
+ code: JSON.stringify(value),
271
+ });
272
+ }
@@ -0,0 +1,6 @@
1
+ import { createSinglePointSelection } from "../selection/selection.js";
2
+ import { createMultiPointSelection } from "../selection/selection.js";
3
+ import { createIntervalSelection } from "../selection/selection.js";
4
+ import { updateMultiPointSelection } from "../selection/selection.js";
5
+ export { createSinglePointSelection, createMultiPointSelection, createIntervalSelection, updateMultiPointSelection };
6
+ //# sourceMappingURL=selectionStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionStore.d.ts","sourceRoot":"","sources":["../../../src/paramRuntime/selectionStore.js"],"names":[],"mappings":"2CAKO,2BAA2B;0CAA3B,2BAA2B;wCAA3B,2BAA2B;0CAA3B,2BAA2B"}
@@ -0,0 +1,13 @@
1
+ import {
2
+ createIntervalSelection,
3
+ createMultiPointSelection,
4
+ createSinglePointSelection,
5
+ updateMultiPointSelection,
6
+ } from "../selection/selection.js";
7
+
8
+ export {
9
+ createSinglePointSelection,
10
+ createMultiPointSelection,
11
+ createIntervalSelection,
12
+ updateMultiPointSelection,
13
+ };
@@ -0,0 +1,16 @@
1
+ export type ParamRef<T> = {
2
+ id: string;
3
+ name: string;
4
+ kind: "base" | "derived" | "selection";
5
+ get: () => T;
6
+ subscribe: (listener: () => void) => () => void;
7
+ };
8
+ export type WritableParamRef<T> = ParamRef<T> & {
9
+ set: (value: T) => void;
10
+ };
11
+ export type ExprRefFunction = import("../utils/expression.js").ExpressionFunction & {
12
+ subscribe: (listener: () => void) => () => void;
13
+ invalidate: () => void;
14
+ identifier: () => string;
15
+ };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/paramRuntime/types.js"],"names":[],"mappings":"qBACa,CAAC,IACD;IACR,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;IACvC,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAA;CAChD;6BAIS,CAAC,IACD,QAAQ,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAAE;8BAIzC,OAAO,wBAAwB,EAAE,kBAAkB,GAAG;IAC9D,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,MAAM,CAAA;CACzB"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @template T
3
+ * @typedef {{
4
+ * id: string,
5
+ * name: string,
6
+ * kind: "base" | "derived" | "selection",
7
+ * get: () => T,
8
+ * subscribe: (listener: () => void) => () => void
9
+ * }} ParamRef
10
+ */
11
+
12
+ /**
13
+ * @template T
14
+ * @typedef {ParamRef<T> & { set: (value: T) => void }} WritableParamRef
15
+ */
16
+
17
+ /**
18
+ * @typedef {import("../utils/expression.js").ExpressionFunction & {
19
+ * subscribe: (listener: () => void) => () => void,
20
+ * invalidate: () => void,
21
+ * identifier: () => string
22
+ * }} ExprRefFunction
23
+ */
24
+
25
+ export {};
@@ -0,0 +1,164 @@
1
+ /**
2
+ * A class that manages parameters and expressions.
3
+ * Supports nesting and scoped parameters through a shared runtime graph.
4
+ * The architecture follows signal-graph ideas (explicit dependencies, batched
5
+ * propagation, deterministic scheduling) while keeping GenomeSpy-specific
6
+ * parameter and expression semantics.
7
+ *
8
+ * @typedef {import("../utils/expression.js").ExpressionFunction & { subscribe: (listener: () => void) => () => void, invalidate: () => void, identifier: () => string}} ExprRefFunction
9
+ */
10
+ export default class ViewParamRuntime {
11
+ /**
12
+ * @param {() => ViewParamRuntime} [parentFinder]
13
+ * An optional function that returns the parent runtime.
14
+ * N.B. The function must always return the same runtime for the same parent,
15
+ * i.e., the changing the structure of the hierarchy is NOT supported.
16
+ */
17
+ constructor(parentFinder?: () => ViewParamRuntime);
18
+ /**
19
+ * Registers a parameter definition into this runtime scope.
20
+ *
21
+ * Returns a writable setter for writable parameters (`value`, `select`,
22
+ * `push: "outer"`). For derived (`expr`) parameters, the returned setter
23
+ * throws.
24
+ *
25
+ * A parameter name can be registered only once per runtime scope.
26
+ *
27
+ * @param {Parameter} param
28
+ * @returns {ParameterSetter}
29
+ */
30
+ registerParam(param: import("../spec/parameter.js").Parameter): (value: any) => void;
31
+ /**
32
+ *
33
+ * @param {string} paramName
34
+ * @param {T} initialValue
35
+ * @param {boolean} [passive] If true, the setter will not notify listeners when the value changes.
36
+ * @returns {(value: T) => void}
37
+ * @template T
38
+ */
39
+ allocateSetter<T>(paramName: string, initialValue: T, passive?: boolean): (value: T) => void;
40
+ /**
41
+ * Sets a writable parameter value in this runtime scope.
42
+ *
43
+ * Only parameters with locally registered writable setters are supported.
44
+ * This method does not resolve through ancestors.
45
+ *
46
+ * @param {string} paramName
47
+ * @param {any} value
48
+ */
49
+ setValue(paramName: string, value: any): void;
50
+ /**
51
+ * Get the value of a parameter from this runtime.
52
+ * @param {string} paramName
53
+ */
54
+ getValue(paramName: string): any;
55
+ /**
56
+ * Subscribe to changes of a parameter's value. The listener is called only
57
+ * when the stored value changes. For expression parameters, the listener is
58
+ * called when upstream changes re-evaluate to a different value.
59
+ *
60
+ * @param {string} paramName
61
+ * @param {() => void} listener
62
+ * @returns {() => void}
63
+ */
64
+ subscribe(paramName: string, listener: () => void): () => void;
65
+ /**
66
+ * Get the value of a parameter from this runtime or its ancestors.
67
+ * @param {string} paramName
68
+ */
69
+ findValue(paramName: string): any;
70
+ /**
71
+ * Returns configs for all parameters that have been registered using `registerParam`.
72
+ */
73
+ get paramConfigs(): ReadonlyMap<string, import("../spec/parameter.js").Parameter>;
74
+ /**
75
+ *
76
+ * @param {string} paramName
77
+ * @returns {ViewParamRuntime}
78
+ */
79
+ findRuntimeForParam(paramName: string): ViewParamRuntime;
80
+ /**
81
+ * Parse expr and return a function that returns the value of the parameter.
82
+ *
83
+ * @param {string} expr
84
+ */
85
+ createExpression(expr: string): import("./types.js").ExprRefFunction;
86
+ /**
87
+ * Creates an expression and subscribes a listener that is automatically
88
+ * removed according to `options` lifecycle ownership.
89
+ *
90
+ * Lifecycle semantics:
91
+ * 1. `scopeOwned: true` (default): unsubscribe is bound to runtime scope
92
+ * disposal (`ViewParamRuntime.dispose()`).
93
+ * 2. `scopeOwned: false`: caller must own teardown, typically via
94
+ * `registerDisposer` or by storing and calling the returned unsubscribe.
95
+ * 3. `registerDisposer` can be used regardless of `scopeOwned` to bind the
96
+ * same unsubscribe to another lifecycle owner.
97
+ *
98
+ * @param {string} expr
99
+ * @param {() => void} listener
100
+ * @param {WatchExpressionOptions} [options]
101
+ * @returns {ExprRefFunction}
102
+ */
103
+ watchExpression(expr: string, listener: () => void, options?: {
104
+ /**
105
+ * Whether the subscription lifecycle is owned by this runtime scope.
106
+ * When true, the listener is unsubscribed automatically during
107
+ * `dispose()` via scope disposal. Set to false when another owner
108
+ * (for example a `View` disposer registry) controls teardown.
109
+ */
110
+ scopeOwned?: boolean;
111
+ /**
112
+ * Optional external disposer registration hook. When provided, the
113
+ * unsubscribe callback is passed to this hook in addition to any
114
+ * scope-owned registration.
115
+ */
116
+ registerDisposer?: (disposer: () => void) => void;
117
+ }): ExprRefFunction;
118
+ /**
119
+ * A convenience method for evaluating an expression.
120
+ *
121
+ * @param {string} expr
122
+ */
123
+ evaluateAndGet(expr: string): any;
124
+ /**
125
+ * @template T
126
+ * @param {() => T} fn
127
+ * @returns {T}
128
+ */
129
+ runInTransaction<T>(fn: () => T): T;
130
+ flushNow(): void;
131
+ /**
132
+ * Sync barrier only: resolves when DAG propagation/effects have flushed.
133
+ * Must not be broadened to temporal/animation convergence semantics.
134
+ *
135
+ * @param {{ signal?: AbortSignal, timeoutMs?: number }} [options]
136
+ */
137
+ whenPropagated(options?: {
138
+ signal?: AbortSignal;
139
+ timeoutMs?: number;
140
+ }): Promise<void>;
141
+ dispose(): void;
142
+ /**
143
+ * Returns true if this runtime has any parameters that are point selections.
144
+ * Point selections necessitate the use of uniqueIds in the data.
145
+ *
146
+ * @returns {boolean}
147
+ */
148
+ hasPointSelections(): boolean;
149
+ #private;
150
+ }
151
+ /**
152
+ * A class that manages parameters and expressions.
153
+ * Supports nesting and scoped parameters through a shared runtime graph.
154
+ * The architecture follows signal-graph ideas (explicit dependencies, batched
155
+ * propagation, deterministic scheduling) while keeping GenomeSpy-specific
156
+ * parameter and expression semantics.
157
+ */
158
+ export type ExprRefFunction = import("../utils/expression.js").ExpressionFunction & {
159
+ subscribe: (listener: () => void) => () => void;
160
+ invalidate: () => void;
161
+ identifier: () => string;
162
+ };
163
+ export { activateExprRefProps, getDefaultParamValue, isExprRef, isSelectionParameter, isVariableParameter, makeConstantExprRef, validateParameterName, withoutExprRef } from "./paramUtils.js";
164
+ //# sourceMappingURL=viewParamRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewParamRuntime.d.ts","sourceRoot":"","sources":["../../../src/paramRuntime/viewParamRuntime.js"],"names":[],"mappings":"AAmBA;;;;;;;;GAQG;AACH;IAqCI;;;;;OAKG;IACH,2BALW,MAAM,gBAAgB,EAgBhC;IAED;;;;;;;;;;;OAWG;IACH,wEAjEqB,GAAG,KAAK,IAAI,CAyJhC;IAED;;;;;;;OAOG;IACH,eAFa,CAAC,aAJH,MAAM,gBACN,CAAC,YACD,OAAO,GACL,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAgC9B;IAED;;;;;;;;OAQG;IACH,oBAHW,MAAM,SACN,GAAG,QAWb;IAED;;;OAGG;IACH,oBAFW,MAAM,OAIhB;IAED;;;;;;;;OAQG;IACH,qBAJW,MAAM,YACN,MAAM,IAAI,GACR,MAAM,IAAI,CAiBtB;IAED;;;OAGG;IACH,qBAFW,MAAM,OAKhB;IAED;;OAEG;IACH,oBACsB,WAAW,CAAC,MAAM,2CAAY,CAGnD;IAED;;;;OAIG;IACH,+BAHW,MAAM,GACJ,gBAAgB,CAQ5B;IAKD;;;;OAIG;IACH,uBAFW,MAAM,wCAIhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,sBALW,MAAM,YACN,MAAM,IAAI;;;;;;;qBA7SX,OAAO;;;;;;2BAKP,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI;QA0S3B,eAAe,CAY3B;IA0BD;;;;OAIG;IACH,qBAFW,MAAM,OAKhB;IAED;;;;OAIG;IACH,iBAJa,CAAC,MACH,MAAM,CAAC,GACL,CAAC,CAIb;IAED,iBAEC;IAED;;;;;OAKG;IACH,yBAFW;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,iBAItD;IAED,gBAUC;IAED;;;;;OAKG;IACH,sBAFa,OAAO,CAiBnB;;CACJ;;;;;;;;8BAhaY,OAAO,wBAAwB,EAAE,kBAAkB,GAAG;IAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,MAAM,CAAA;CAAC"}