@platforma-sdk/model 1.58.5 → 1.58.11
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.
- package/dist/_virtual/_rolldown/runtime.cjs +43 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/annotations/converter.cjs +15 -20
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +6 -2
- package/dist/annotations/converter.js +14 -18
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.cjs +1 -0
- package/dist/annotations/index.d.ts +2 -3
- package/dist/annotations/index.js +1 -0
- package/dist/annotations/types.d.ts +21 -16
- package/dist/bconfig/index.cjs +2 -0
- package/dist/bconfig/index.d.ts +5 -6
- package/dist/bconfig/index.js +2 -0
- package/dist/bconfig/lambdas.d.ts +52 -52
- package/dist/bconfig/normalization.cjs +13 -18
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +10 -6
- package/dist/bconfig/normalization.js +12 -16
- package/dist/bconfig/normalization.js.map +1 -1
- package/dist/bconfig/types.cjs +4 -3
- package/dist/bconfig/types.cjs.map +1 -1
- package/dist/bconfig/types.d.ts +10 -5
- package/dist/bconfig/types.js +4 -2
- package/dist/bconfig/types.js.map +1 -1
- package/dist/bconfig/util.d.ts +7 -4
- package/dist/bconfig/v3.d.ts +10 -6
- package/dist/block_api_v1.d.ts +62 -58
- package/dist/block_api_v2.d.ts +51 -47
- package/dist/block_api_v3.d.ts +33 -29
- package/dist/block_migrations.cjs +481 -413
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts +258 -204
- package/dist/block_migrations.js +482 -408
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +312 -343
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +143 -147
- package/dist/block_model.js +312 -341
- package/dist/block_model.js.map +1 -1
- package/dist/block_model_legacy.cjs +231 -255
- package/dist/block_model_legacy.cjs.map +1 -1
- package/dist/block_model_legacy.d.ts +108 -106
- package/dist/block_model_legacy.js +231 -253
- package/dist/block_model_legacy.js.map +1 -1
- package/dist/block_state_patch.d.ts +10 -10
- package/dist/block_state_util.cjs +15 -19
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +14 -13
- package/dist/block_state_util.js +15 -18
- package/dist/block_state_util.js.map +1 -1
- package/dist/block_storage.cjs +233 -238
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +62 -78
- package/dist/block_storage.js +234 -237
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_callbacks.cjs +156 -195
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js +156 -192
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/block_storage_facade.cjs +29 -85
- package/dist/block_storage_facade.cjs.map +1 -1
- package/dist/block_storage_facade.d.ts +83 -126
- package/dist/block_storage_facade.js +29 -83
- package/dist/block_storage_facade.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +26 -24
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +12 -7
- package/dist/components/PFrameForGraphs.js +25 -22
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlAnnotations/filter.d.ts +62 -79
- package/dist/components/PlAnnotations/filters_ui.cjs +135 -171
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +48 -46
- package/dist/components/PlAnnotations/filters_ui.js +135 -170
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts +2 -3
- package/dist/components/PlDataTable/index.cjs +2 -0
- package/dist/components/PlDataTable/index.d.ts +3 -5
- package/dist/components/PlDataTable/index.js +2 -0
- package/dist/components/PlDataTable/labels.cjs +59 -81
- package/dist/components/PlDataTable/labels.cjs.map +1 -1
- package/dist/components/PlDataTable/labels.js +58 -79
- package/dist/components/PlDataTable/labels.js.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +186 -144
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +85 -82
- package/dist/components/PlDataTable/state-migration.js +185 -142
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/table.cjs +172 -194
- package/dist/components/PlDataTable/table.cjs.map +1 -1
- package/dist/components/PlDataTable/table.d.ts +16 -12
- package/dist/components/PlDataTable/table.js +171 -192
- package/dist/components/PlDataTable/table.js.map +1 -1
- package/dist/components/PlDataTable/v4.d.ts +84 -119
- package/dist/components/PlDataTable/v5.d.ts +80 -103
- package/dist/components/PlMultiSequenceAlignment.cjs +27 -29
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +36 -27
- package/dist/components/PlMultiSequenceAlignment.js +26 -27
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
- package/dist/components/PlSelectionModel.cjs +7 -6
- package/dist/components/PlSelectionModel.cjs.map +1 -1
- package/dist/components/PlSelectionModel.d.ts +10 -8
- package/dist/components/PlSelectionModel.js +7 -5
- package/dist/components/PlSelectionModel.js.map +1 -1
- package/dist/components/index.cjs +8 -0
- package/dist/components/index.d.ts +11 -6
- package/dist/components/index.js +8 -0
- package/dist/config/actions.cjs +138 -171
- package/dist/config/actions.cjs.map +1 -1
- package/dist/config/actions.d.ts +47 -47
- package/dist/config/actions.js +146 -178
- package/dist/config/actions.js.map +1 -1
- package/dist/config/actions_kinds.d.ts +114 -121
- package/dist/config/index.cjs +1 -0
- package/dist/config/index.d.ts +6 -7
- package/dist/config/index.js +1 -0
- package/dist/config/model.d.ts +131 -127
- package/dist/config/model_meta.d.ts +4 -1
- package/dist/config/type_engine.d.ts +22 -21
- package/dist/config/type_util.d.ts +12 -10
- package/dist/env_value.cjs +5 -6
- package/dist/env_value.cjs.map +1 -1
- package/dist/env_value.d.ts +4 -1
- package/dist/env_value.js +5 -5
- package/dist/env_value.js.map +1 -1
- package/dist/filters/converters/filterToQuery.cjs +273 -239
- package/dist/filters/converters/filterToQuery.cjs.map +1 -1
- package/dist/filters/converters/filterToQuery.d.ts +6 -2
- package/dist/filters/converters/filterToQuery.js +272 -237
- package/dist/filters/converters/filterToQuery.js.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.cjs +56 -85
- package/dist/filters/converters/filterUiToExpressionImpl.cjs.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts +8 -4
- package/dist/filters/converters/filterUiToExpressionImpl.js +55 -83
- package/dist/filters/converters/filterUiToExpressionImpl.js.map +1 -1
- package/dist/filters/converters/index.cjs +2 -0
- package/dist/filters/converters/index.d.ts +2 -3
- package/dist/filters/converters/index.js +2 -0
- package/dist/filters/distill.cjs +59 -60
- package/dist/filters/distill.cjs.map +1 -1
- package/dist/filters/distill.d.ts +6 -3
- package/dist/filters/distill.js +58 -58
- package/dist/filters/distill.js.map +1 -1
- package/dist/filters/index.cjs +4 -0
- package/dist/filters/index.d.ts +5 -4
- package/dist/filters/index.js +4 -0
- package/dist/filters/traverse.cjs +31 -40
- package/dist/filters/traverse.cjs.map +1 -1
- package/dist/filters/traverse.js +31 -39
- package/dist/filters/traverse.js.map +1 -1
- package/dist/filters/types.d.ts +10 -7
- package/dist/index.cjs +193 -187
- package/dist/index.d.ts +61 -28
- package/dist/index.js +49 -41
- package/dist/internal.cjs +48 -62
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +49 -60
- package/dist/internal.js.map +1 -1
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/pframe.cjs +32 -37
- package/dist/pframe.cjs.map +1 -1
- package/dist/pframe.d.ts +14 -10
- package/dist/pframe.js +32 -35
- package/dist/pframe.js.map +1 -1
- package/dist/pframe_utils/axes.cjs +81 -114
- package/dist/pframe_utils/axes.cjs.map +1 -1
- package/dist/pframe_utils/axes.d.ts +10 -13
- package/dist/pframe_utils/axes.js +80 -112
- package/dist/pframe_utils/axes.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +61 -81
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +15 -6
- package/dist/pframe_utils/columns.js +60 -79
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +232 -253
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +39 -35
- package/dist/pframe_utils/index.js +231 -251
- package/dist/pframe_utils/index.js.map +1 -1
- package/dist/platforma.d.ts +48 -46
- package/dist/plugin_handle.cjs +6 -14
- package/dist/plugin_handle.cjs.map +1 -1
- package/dist/plugin_handle.d.ts +20 -25
- package/dist/plugin_handle.js +6 -13
- package/dist/plugin_handle.js.map +1 -1
- package/dist/plugin_model.cjs +364 -163
- package/dist/plugin_model.cjs.map +1 -1
- package/dist/plugin_model.d.ts +280 -129
- package/dist/plugin_model.js +362 -163
- package/dist/plugin_model.js.map +1 -1
- package/dist/raw_globals.cjs +10 -22
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +8 -5
- package/dist/raw_globals.js +10 -20
- package/dist/raw_globals.js.map +1 -1
- package/dist/ref_util.cjs +14 -13
- package/dist/ref_util.cjs.map +1 -1
- package/dist/ref_util.d.ts +18 -12
- package/dist/ref_util.js +14 -11
- package/dist/ref_util.js.map +1 -1
- package/dist/render/accessor.cjs +213 -226
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +115 -120
- package/dist/render/accessor.js +212 -224
- package/dist/render/accessor.js.map +1 -1
- package/dist/render/api.cjs +478 -580
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +207 -209
- package/dist/render/api.js +476 -578
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs +28 -32
- package/dist/render/future.cjs.map +1 -1
- package/dist/render/future.d.ts +15 -11
- package/dist/render/future.js +28 -30
- package/dist/render/future.js.map +1 -1
- package/dist/render/index.cjs +8 -0
- package/dist/render/index.d.ts +10 -8
- package/dist/render/index.js +8 -0
- package/dist/render/internal.cjs +33 -29
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +78 -72
- package/dist/render/internal.js +29 -26
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +42 -43
- package/dist/render/util/axis_filtering.cjs +63 -86
- package/dist/render/util/axis_filtering.cjs.map +1 -1
- package/dist/render/util/axis_filtering.d.ts +10 -7
- package/dist/render/util/axis_filtering.js +63 -85
- package/dist/render/util/axis_filtering.js.map +1 -1
- package/dist/render/util/column_collection.cjs +266 -321
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +47 -47
- package/dist/render/util/column_collection.js +264 -319
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.cjs +4 -0
- package/dist/render/util/index.d.ts +4 -5
- package/dist/render/util/index.js +4 -0
- package/dist/render/util/label.cjs +129 -163
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +45 -46
- package/dist/render/util/label.js +128 -161
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +315 -375
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +33 -32
- package/dist/render/util/pcolumn_data.js +314 -373
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +37 -42
- package/dist/render/util/pframe_upgraders.cjs.map +1 -1
- package/dist/render/util/pframe_upgraders.js +37 -41
- package/dist/render/util/pframe_upgraders.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +13 -9
- package/dist/version.cjs +6 -8
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.ts +7 -4
- package/dist/version.js +5 -5
- package/dist/version.js.map +1 -1
- package/package.json +15 -9
- package/src/block_migrations.test.ts +184 -14
- package/src/block_migrations.ts +185 -30
- package/src/block_model.ts +111 -66
- package/src/block_storage.test.ts +147 -3
- package/src/block_storage.ts +43 -8
- package/src/block_storage_callbacks.ts +9 -4
- package/src/env_value.ts +0 -2
- package/src/index.ts +12 -11
- package/src/internal.ts +0 -1
- package/src/platforma.ts +4 -4
- package/src/plugin_handle.ts +1 -1
- package/src/plugin_model.test.ts +217 -21
- package/src/plugin_model.ts +450 -55
- package/src/raw_globals.ts +0 -1
- package/dist/annotations/converter.d.ts.map +0 -1
- package/dist/annotations/index.d.ts.map +0 -1
- package/dist/annotations/types.d.ts.map +0 -1
- package/dist/bconfig/index.d.ts.map +0 -1
- package/dist/bconfig/lambdas.d.ts.map +0 -1
- package/dist/bconfig/normalization.d.ts.map +0 -1
- package/dist/bconfig/types.d.ts.map +0 -1
- package/dist/bconfig/util.d.ts.map +0 -1
- package/dist/bconfig/v3.d.ts.map +0 -1
- package/dist/block_api_v1.d.ts.map +0 -1
- package/dist/block_api_v2.d.ts.map +0 -1
- package/dist/block_api_v3.d.ts.map +0 -1
- package/dist/block_migrations.d.ts.map +0 -1
- package/dist/block_model.d.ts.map +0 -1
- package/dist/block_model_legacy.d.ts.map +0 -1
- package/dist/block_state_patch.d.ts.map +0 -1
- package/dist/block_state_util.d.ts.map +0 -1
- package/dist/block_storage.d.ts.map +0 -1
- package/dist/block_storage_callbacks.d.ts +0 -115
- package/dist/block_storage_callbacks.d.ts.map +0 -1
- package/dist/block_storage_facade.d.ts.map +0 -1
- package/dist/components/PFrameForGraphs.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
- package/dist/components/PlAnnotations/index.d.ts.map +0 -1
- package/dist/components/PlAnnotations/types.d.ts +0 -3
- package/dist/components/PlAnnotations/types.d.ts.map +0 -1
- package/dist/components/PlDataTable/index.d.ts.map +0 -1
- package/dist/components/PlDataTable/labels.d.ts +0 -7
- package/dist/components/PlDataTable/labels.d.ts.map +0 -1
- package/dist/components/PlDataTable/state-migration.d.ts.map +0 -1
- package/dist/components/PlDataTable/table.d.ts.map +0 -1
- package/dist/components/PlDataTable/v4.d.ts.map +0 -1
- package/dist/components/PlDataTable/v5.d.ts.map +0 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
- package/dist/components/PlSelectionModel.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/config/actions.d.ts.map +0 -1
- package/dist/config/actions_kinds.d.ts.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/model.d.ts.map +0 -1
- package/dist/config/model_meta.d.ts.map +0 -1
- package/dist/config/type_engine.d.ts.map +0 -1
- package/dist/config/type_util.d.ts.map +0 -1
- package/dist/env_value.d.ts.map +0 -1
- package/dist/filters/converters/filterToQuery.d.ts.map +0 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +0 -1
- package/dist/filters/converters/index.d.ts.map +0 -1
- package/dist/filters/distill.d.ts.map +0 -1
- package/dist/filters/index.d.ts.map +0 -1
- package/dist/filters/traverse.d.ts +0 -27
- package/dist/filters/traverse.d.ts.map +0 -1
- package/dist/filters/types.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -36
- package/dist/internal.d.ts.map +0 -1
- package/dist/package.json.cjs +0 -6
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -4
- package/dist/package.json.js.map +0 -1
- package/dist/pframe.d.ts.map +0 -1
- package/dist/pframe_utils/axes.d.ts.map +0 -1
- package/dist/pframe_utils/columns.d.ts.map +0 -1
- package/dist/pframe_utils/index.d.ts.map +0 -1
- package/dist/pframe_utils/querySpec.d.ts +0 -2
- package/dist/pframe_utils/querySpec.d.ts.map +0 -1
- package/dist/platforma.d.ts.map +0 -1
- package/dist/plugin_handle.d.ts.map +0 -1
- package/dist/plugin_model.d.ts.map +0 -1
- package/dist/raw_globals.d.ts.map +0 -1
- package/dist/ref_util.d.ts.map +0 -1
- package/dist/render/accessor.d.ts.map +0 -1
- package/dist/render/api.d.ts.map +0 -1
- package/dist/render/future.d.ts.map +0 -1
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/internal.d.ts.map +0 -1
- package/dist/render/traversal_ops.d.ts.map +0 -1
- package/dist/render/util/axis_filtering.d.ts.map +0 -1
- package/dist/render/util/column_collection.d.ts.map +0 -1
- package/dist/render/util/index.d.ts.map +0 -1
- package/dist/render/util/label.d.ts.map +0 -1
- package/dist/render/util/pcolumn_data.d.ts.map +0 -1
- package/dist/render/util/pframe_upgraders.d.ts +0 -3
- package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
- package/dist/render/util/split_selectors.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
package/dist/render/api.js
CHANGED
|
@@ -1,591 +1,489 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { PColumnCollection } from
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
1
|
+
import { getPluginData } from "../block_storage.js";
|
|
2
|
+
import { getCfgRenderCtx } from "../internal.js";
|
|
3
|
+
import { TreeNodeAccessor, ifDef } from "./accessor.js";
|
|
4
|
+
import { MainAccessorName, StagingAccessorName } from "./internal.js";
|
|
5
|
+
import { deriveLabels } from "./util/label.js";
|
|
6
|
+
import { allPColumnsReady } from "./util/pcolumn_data.js";
|
|
7
|
+
import { PColumnCollection } from "./util/column_collection.js";
|
|
8
|
+
import { patchInSetFilters } from "./util/pframe_upgraders.js";
|
|
9
|
+
import { AnchoredIdDeriver, PColumnName, collectSpecQueryColumns, ensurePColumn, extractAllColumns, isDataInfo, isPColumn, isPColumnSpec, isPlRef, mapDataInfo, mapPObjectData, mapPTableDef, mapPTableDefV2, mapValueInVOE, parseJson, readAnnotation, selectorsToPredicate, withEnrichments } from "@milaboratories/pl-model-common";
|
|
10
|
+
import canonicalize from "canonicalize";
|
|
11
11
|
|
|
12
|
+
//#region src/render/api.ts
|
|
12
13
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
* Helper function to match domain objects
|
|
15
|
+
* @param query Optional domain to match against
|
|
16
|
+
* @param target Optional domain to match
|
|
17
|
+
* @returns true if domains match, false otherwise
|
|
18
|
+
*/
|
|
18
19
|
function matchDomain(query, target) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (const k in target) {
|
|
24
|
-
if (query[k] !== target[k])
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
20
|
+
if (query === void 0) return target === void 0;
|
|
21
|
+
if (target === void 0) return true;
|
|
22
|
+
for (const k in target) if (query[k] !== target[k]) return false;
|
|
23
|
+
return true;
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
* Transforms PColumn data into the internal representation expected by the platform
|
|
27
|
+
* @param data Data from a PColumn to transform
|
|
28
|
+
* @returns Transformed data compatible with platform API
|
|
29
|
+
*/
|
|
34
30
|
function transformPColumnData(data) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return mapDataInfo(d, (accessor) => accessor.handle);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return d;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
class ResultPool {
|
|
48
|
-
ctx = getCfgRenderCtx();
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated use getOptions()
|
|
51
|
-
*/
|
|
52
|
-
calculateOptions(predicate) {
|
|
53
|
-
return this.ctx.calculateOptions(predicate);
|
|
54
|
-
}
|
|
55
|
-
getOptions(predicateOrSelector, opts) {
|
|
56
|
-
const predicate = typeof predicateOrSelector === "function"
|
|
57
|
-
? predicateOrSelector
|
|
58
|
-
: selectorsToPredicate(predicateOrSelector);
|
|
59
|
-
const filtered = this.getSpecs().entries.filter((s) => predicate(s.obj));
|
|
60
|
-
let labelOps = {};
|
|
61
|
-
let refsWithEnrichments = false;
|
|
62
|
-
if (typeof opts !== "undefined") {
|
|
63
|
-
if (typeof opts === "function") {
|
|
64
|
-
labelOps = opts;
|
|
65
|
-
}
|
|
66
|
-
else if (typeof opts === "object") {
|
|
67
|
-
if ("includeNativeLabel" in opts || "separator" in opts || "addLabelAsSuffix" in opts) {
|
|
68
|
-
labelOps = opts;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
opts = opts;
|
|
72
|
-
labelOps = opts.label ?? {};
|
|
73
|
-
refsWithEnrichments = opts.refsWithEnrichments ?? false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (typeof labelOps === "object")
|
|
78
|
-
return deriveLabels(filtered, (o) => o.obj, labelOps ?? {}).map(({ value: { ref }, label }) => ({
|
|
79
|
-
ref: withEnrichments(ref, refsWithEnrichments),
|
|
80
|
-
label,
|
|
81
|
-
}));
|
|
82
|
-
else
|
|
83
|
-
return filtered.map(({ ref, obj }) => ({
|
|
84
|
-
ref: withEnrichments(ref, refsWithEnrichments),
|
|
85
|
-
label: labelOps(obj, ref),
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
resolveAnchorCtx(anchorsOrCtx) {
|
|
89
|
-
if (anchorsOrCtx instanceof AnchoredIdDeriver)
|
|
90
|
-
return anchorsOrCtx;
|
|
91
|
-
const resolvedAnchors = {};
|
|
92
|
-
for (const [key, value] of Object.entries(anchorsOrCtx)) {
|
|
93
|
-
if (isPlRef(value)) {
|
|
94
|
-
const resolvedSpec = this.getPColumnSpecByRef(value);
|
|
95
|
-
if (!resolvedSpec)
|
|
96
|
-
return undefined;
|
|
97
|
-
resolvedAnchors[key] = resolvedSpec;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
resolvedAnchors[key] = value;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return new AnchoredIdDeriver(resolvedAnchors);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
|
|
107
|
-
*
|
|
108
|
-
* @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions)
|
|
109
|
-
* @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions)
|
|
110
|
-
* @param opts - Optional configuration for label generation and data waiting
|
|
111
|
-
* @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
|
|
112
|
-
*/
|
|
113
|
-
getAnchoredPColumns(anchorsOrCtx, predicateOrSelectors, opts) {
|
|
114
|
-
const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
|
|
115
|
-
if (!anchorCtx)
|
|
116
|
-
return undefined;
|
|
117
|
-
return new PColumnCollection()
|
|
118
|
-
.addColumnProvider(this)
|
|
119
|
-
.addAxisLabelProvider(this)
|
|
120
|
-
.getColumns(predicateOrSelectors, {
|
|
121
|
-
...opts,
|
|
122
|
-
anchorCtx,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Calculates anchored identifier options for columns matching a given predicate and returns their
|
|
127
|
-
* canonicalized representations.
|
|
128
|
-
*
|
|
129
|
-
* This function filters column specifications from the result pool that match the provided predicate,
|
|
130
|
-
* creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value
|
|
131
|
-
* pairs for UI components (like dropdowns).
|
|
132
|
-
*
|
|
133
|
-
* @param anchorsOrCtx - Either:
|
|
134
|
-
* - An existing AnchorCtx instance
|
|
135
|
-
* - A record mapping anchor IDs to PColumnSpec objects
|
|
136
|
-
* - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec)
|
|
137
|
-
* @param predicateOrSelectors - Either:
|
|
138
|
-
* - A predicate function that takes a PColumnSpec and returns a boolean.
|
|
139
|
-
* Only specs that return true will be included.
|
|
140
|
-
* - An APColumnSelector object for declarative filtering, which will be
|
|
141
|
-
* resolved against the provided anchors and matched using matchPColumn.
|
|
142
|
-
* - An array of APColumnSelector objects - columns matching ANY selector
|
|
143
|
-
* in the array will be included (OR operation).
|
|
144
|
-
* @param opts - Optional configuration for label generation:
|
|
145
|
-
* - labelOps: Optional configuration for label generation:
|
|
146
|
-
* - includeNativeLabel: Whether to include native column labels
|
|
147
|
-
* - separator: String to use between label parts (defaults to " / ")
|
|
148
|
-
* - addLabelAsSuffix: Whether to add labels as suffix instead of prefix
|
|
149
|
-
* - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined,
|
|
150
|
-
* if at least one column that requires splitting is missing data)
|
|
151
|
-
* @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties,
|
|
152
|
-
* or undefined if any PlRef resolution fails.
|
|
153
|
-
*/
|
|
154
|
-
getCanonicalOptions(anchorsOrCtx, predicateOrSelectors, opts) {
|
|
155
|
-
const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
|
|
156
|
-
if (!anchorCtx)
|
|
157
|
-
return undefined;
|
|
158
|
-
const entries = new PColumnCollection()
|
|
159
|
-
.addColumnProvider(this)
|
|
160
|
-
.addAxisLabelProvider(this)
|
|
161
|
-
.getUniversalEntries(predicateOrSelectors, {
|
|
162
|
-
...opts,
|
|
163
|
-
anchorCtx,
|
|
164
|
-
});
|
|
165
|
-
if (!entries)
|
|
166
|
-
return undefined;
|
|
167
|
-
return entries.map((item) => ({
|
|
168
|
-
value: item.id,
|
|
169
|
-
label: item.label,
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @deprecated use getData()
|
|
174
|
-
*/
|
|
175
|
-
getDataFromResultPool() {
|
|
176
|
-
return this.getData();
|
|
177
|
-
}
|
|
178
|
-
getData() {
|
|
179
|
-
const result = this.ctx.getDataFromResultPool();
|
|
180
|
-
return {
|
|
181
|
-
isComplete: result.isComplete,
|
|
182
|
-
entries: result.entries.map((e) => ({
|
|
183
|
-
ref: e.ref,
|
|
184
|
-
obj: {
|
|
185
|
-
...e.obj,
|
|
186
|
-
data: new TreeNodeAccessor(e.obj.data, [e.ref.blockId, e.ref.name]),
|
|
187
|
-
},
|
|
188
|
-
})),
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* @deprecated use getDataWithErrors()
|
|
193
|
-
*/
|
|
194
|
-
getDataWithErrorsFromResultPool() {
|
|
195
|
-
return this.getDataWithErrors();
|
|
196
|
-
}
|
|
197
|
-
getDataWithErrors() {
|
|
198
|
-
const result = this.ctx.getDataWithErrorsFromResultPool();
|
|
199
|
-
return {
|
|
200
|
-
isComplete: result.isComplete,
|
|
201
|
-
entries: result.entries.map((e) => ({
|
|
202
|
-
ref: e.ref,
|
|
203
|
-
obj: {
|
|
204
|
-
...e.obj,
|
|
205
|
-
data: mapValueInVOE(e.obj.data, (handle) => new TreeNodeAccessor(handle, [e.ref.blockId, e.ref.name])),
|
|
206
|
-
},
|
|
207
|
-
})),
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* @deprecated use getSpecs()
|
|
212
|
-
*/
|
|
213
|
-
getSpecsFromResultPool() {
|
|
214
|
-
return this.getSpecs();
|
|
215
|
-
}
|
|
216
|
-
getSpecs() {
|
|
217
|
-
return this.ctx.getSpecsFromResultPool();
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* @param ref a Ref
|
|
221
|
-
* @returns data associated with the ref
|
|
222
|
-
*/
|
|
223
|
-
getDataByRef(ref) {
|
|
224
|
-
// @TODO remove after 1 Jan 2025; forward compatibility
|
|
225
|
-
if (typeof this.ctx.getDataFromResultPoolByRef === "undefined")
|
|
226
|
-
return this.getData().entries.find((f) => f.ref.blockId === ref.blockId && f.ref.name === ref.name)?.obj;
|
|
227
|
-
const data = this.ctx.getDataFromResultPoolByRef(ref.blockId, ref.name); // Keep original call
|
|
228
|
-
// Need to handle undefined case before mapping
|
|
229
|
-
if (!data)
|
|
230
|
-
return undefined;
|
|
231
|
-
return mapPObjectData(data, (handle) => new TreeNodeAccessor(handle, [ref.blockId, ref.name]));
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Returns data associated with the ref ensuring that it is a p-column.
|
|
235
|
-
* @param ref a Ref
|
|
236
|
-
* @returns p-column associated with the ref
|
|
237
|
-
*/
|
|
238
|
-
getPColumnByRef(ref) {
|
|
239
|
-
const data = this.getDataByRef(ref);
|
|
240
|
-
if (!data)
|
|
241
|
-
return undefined;
|
|
242
|
-
return ensurePColumn(data);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Returns spec associated with the ref ensuring that it is a p-column spec.
|
|
246
|
-
* @param ref a Ref
|
|
247
|
-
* @returns p-column spec associated with the ref
|
|
248
|
-
*/
|
|
249
|
-
getPColumnSpecByRef(ref) {
|
|
250
|
-
const spec = this.getSpecByRef(ref);
|
|
251
|
-
if (!spec)
|
|
252
|
-
return undefined;
|
|
253
|
-
if (!isPColumnSpec(spec))
|
|
254
|
-
throw new Error(`not a PColumn spec (kind = ${spec.kind})`);
|
|
255
|
-
return spec;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* @param ref a Ref
|
|
259
|
-
* @returns object spec associated with the ref
|
|
260
|
-
*/
|
|
261
|
-
getSpecByRef(ref) {
|
|
262
|
-
return this.ctx.getSpecFromResultPoolByRef(ref.blockId, ref.name);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* @param spec object specification
|
|
266
|
-
* @returns array of data objects with compatible specs
|
|
267
|
-
* @deprecated delete this method after Jan 1, 2025
|
|
268
|
-
*/
|
|
269
|
-
findDataWithCompatibleSpec(spec) {
|
|
270
|
-
const result = [];
|
|
271
|
-
out: for (const data of this.getData().entries) {
|
|
272
|
-
if (!isPColumnSpec(data.obj.spec)) {
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
const oth = data.obj.spec;
|
|
276
|
-
if (spec.name !== oth.name) {
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
if (spec.valueType !== oth.valueType) {
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
if (spec.axesSpec.length !== oth.axesSpec.length) {
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
if (!matchDomain(spec.domain, oth.domain)) {
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
for (let i = 0; i < spec.axesSpec.length; ++i) {
|
|
289
|
-
const qAx = spec.axesSpec[i];
|
|
290
|
-
const tAx = oth.axesSpec[i];
|
|
291
|
-
if (qAx.name !== tAx.name) {
|
|
292
|
-
continue out;
|
|
293
|
-
}
|
|
294
|
-
if (qAx.type !== tAx.type) {
|
|
295
|
-
continue out;
|
|
296
|
-
}
|
|
297
|
-
if (!matchDomain(qAx.domain, tAx.domain)) {
|
|
298
|
-
continue out;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
result.push(data.obj);
|
|
302
|
-
}
|
|
303
|
-
return result;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Find labels data for a given axis id. It will search for a label column and return its data as a map.
|
|
307
|
-
* @returns a map of axis value => label
|
|
308
|
-
*/
|
|
309
|
-
findLabels(axis) {
|
|
310
|
-
const dataPool = this.getData();
|
|
311
|
-
for (const column of dataPool.entries) {
|
|
312
|
-
if (!isPColumn(column.obj))
|
|
313
|
-
continue;
|
|
314
|
-
const spec = column.obj.spec;
|
|
315
|
-
if (spec.name === PColumnName.Label &&
|
|
316
|
-
spec.axesSpec.length === 1 &&
|
|
317
|
-
spec.axesSpec[0].name === axis.name &&
|
|
318
|
-
spec.axesSpec[0].type === axis.type &&
|
|
319
|
-
matchDomain(axis.domain, spec.axesSpec[0].domain)) {
|
|
320
|
-
if (column.obj.data.resourceType.name !== "PColumnData/Json") {
|
|
321
|
-
throw Error(`Expected JSON column for labels, got: ${column.obj.data.resourceType.name}`);
|
|
322
|
-
}
|
|
323
|
-
const labels = Object.fromEntries(Object.entries(column.obj.data.getDataAsJson().data).map((e) => [JSON.parse(e[0])[0], e[1]]));
|
|
324
|
-
return labels;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return undefined;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Selects columns based on the provided selectors, returning PColumn objects
|
|
331
|
-
* with lazily loaded data.
|
|
332
|
-
*
|
|
333
|
-
* @param selectors - A predicate function, a single selector, or an array of selectors.
|
|
334
|
-
* @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
|
|
335
|
-
*/
|
|
336
|
-
selectColumns(selectors) {
|
|
337
|
-
const predicate = typeof selectors === "function" ? selectors : selectorsToPredicate(selectors);
|
|
338
|
-
const matchedSpecs = this.getSpecs().entries.filter(({ obj: spec }) => {
|
|
339
|
-
if (!isPColumnSpec(spec))
|
|
340
|
-
return false;
|
|
341
|
-
return predicate(spec);
|
|
342
|
-
});
|
|
343
|
-
// Map specs to PColumn objects with lazy data loading
|
|
344
|
-
return matchedSpecs.map(({ ref, obj: spec }) => {
|
|
345
|
-
// Type assertion needed because filter ensures it's PColumnSpec
|
|
346
|
-
const pcolumnSpec = spec;
|
|
347
|
-
let _cachedData = null; // Use null to distinguish initial state from undefined result
|
|
348
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
349
|
-
const self = this; // Capture 'this' for use inside the getter
|
|
350
|
-
return {
|
|
351
|
-
id: canonicalize(ref),
|
|
352
|
-
spec: pcolumnSpec,
|
|
353
|
-
get data() {
|
|
354
|
-
if (_cachedData !== null) {
|
|
355
|
-
return _cachedData; // Return cached data (could be undefined if fetch failed)
|
|
356
|
-
}
|
|
357
|
-
_cachedData = self.getPColumnByRef(ref)?.data;
|
|
358
|
-
return _cachedData;
|
|
359
|
-
},
|
|
360
|
-
}; // Cast needed because 'data' is a getter
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Find labels data for a given axis id of a p-column.
|
|
365
|
-
* @returns a map of axis value => label
|
|
366
|
-
*/
|
|
367
|
-
findLabelsForColumnAxis(column, axisIdx) {
|
|
368
|
-
const labels = this.findLabels(column.axesSpec[axisIdx]);
|
|
369
|
-
if (!labels)
|
|
370
|
-
return undefined;
|
|
371
|
-
const axisKeys = readAnnotation(column, `pl7.app/axisKeys/${axisIdx}`);
|
|
372
|
-
if (axisKeys !== undefined) {
|
|
373
|
-
const keys = JSON.parse(axisKeys);
|
|
374
|
-
return Object.fromEntries(keys.map((key) => {
|
|
375
|
-
return [key, labels[key] ?? "Unlabelled"];
|
|
376
|
-
}));
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
return labels;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
31
|
+
return mapPObjectData(data, (d) => {
|
|
32
|
+
if (d instanceof TreeNodeAccessor) return d.handle;
|
|
33
|
+
else if (isDataInfo(d)) return mapDataInfo(d, (accessor) => accessor.handle);
|
|
34
|
+
else return d;
|
|
35
|
+
});
|
|
382
36
|
}
|
|
37
|
+
var ResultPool = class {
|
|
38
|
+
ctx = getCfgRenderCtx();
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use getOptions()
|
|
41
|
+
*/
|
|
42
|
+
calculateOptions(predicate) {
|
|
43
|
+
return this.ctx.calculateOptions(predicate);
|
|
44
|
+
}
|
|
45
|
+
getOptions(predicateOrSelector, opts) {
|
|
46
|
+
const predicate = typeof predicateOrSelector === "function" ? predicateOrSelector : selectorsToPredicate(predicateOrSelector);
|
|
47
|
+
const filtered = this.getSpecs().entries.filter((s) => predicate(s.obj));
|
|
48
|
+
let labelOps = {};
|
|
49
|
+
let refsWithEnrichments = false;
|
|
50
|
+
if (typeof opts !== "undefined") {
|
|
51
|
+
if (typeof opts === "function") labelOps = opts;
|
|
52
|
+
else if (typeof opts === "object") if ("includeNativeLabel" in opts || "separator" in opts || "addLabelAsSuffix" in opts) labelOps = opts;
|
|
53
|
+
else {
|
|
54
|
+
opts = opts;
|
|
55
|
+
labelOps = opts.label ?? {};
|
|
56
|
+
refsWithEnrichments = opts.refsWithEnrichments ?? false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (typeof labelOps === "object") return deriveLabels(filtered, (o) => o.obj, labelOps ?? {}).map(({ value: { ref }, label }) => ({
|
|
60
|
+
ref: withEnrichments(ref, refsWithEnrichments),
|
|
61
|
+
label
|
|
62
|
+
}));
|
|
63
|
+
else return filtered.map(({ ref, obj }) => ({
|
|
64
|
+
ref: withEnrichments(ref, refsWithEnrichments),
|
|
65
|
+
label: labelOps(obj, ref)
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
resolveAnchorCtx(anchorsOrCtx) {
|
|
69
|
+
if (anchorsOrCtx instanceof AnchoredIdDeriver) return anchorsOrCtx;
|
|
70
|
+
const resolvedAnchors = {};
|
|
71
|
+
for (const [key, value] of Object.entries(anchorsOrCtx)) if (isPlRef(value)) {
|
|
72
|
+
const resolvedSpec = this.getPColumnSpecByRef(value);
|
|
73
|
+
if (!resolvedSpec) return void 0;
|
|
74
|
+
resolvedAnchors[key] = resolvedSpec;
|
|
75
|
+
} else resolvedAnchors[key] = value;
|
|
76
|
+
return new AnchoredIdDeriver(resolvedAnchors);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
|
|
80
|
+
*
|
|
81
|
+
* @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions)
|
|
82
|
+
* @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions)
|
|
83
|
+
* @param opts - Optional configuration for label generation and data waiting
|
|
84
|
+
* @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
|
|
85
|
+
*/
|
|
86
|
+
getAnchoredPColumns(anchorsOrCtx, predicateOrSelectors, opts) {
|
|
87
|
+
const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
|
|
88
|
+
if (!anchorCtx) return void 0;
|
|
89
|
+
return new PColumnCollection().addColumnProvider(this).addAxisLabelProvider(this).getColumns(predicateOrSelectors, {
|
|
90
|
+
...opts,
|
|
91
|
+
anchorCtx
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Calculates anchored identifier options for columns matching a given predicate and returns their
|
|
96
|
+
* canonicalized representations.
|
|
97
|
+
*
|
|
98
|
+
* This function filters column specifications from the result pool that match the provided predicate,
|
|
99
|
+
* creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value
|
|
100
|
+
* pairs for UI components (like dropdowns).
|
|
101
|
+
*
|
|
102
|
+
* @param anchorsOrCtx - Either:
|
|
103
|
+
* - An existing AnchorCtx instance
|
|
104
|
+
* - A record mapping anchor IDs to PColumnSpec objects
|
|
105
|
+
* - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec)
|
|
106
|
+
* @param predicateOrSelectors - Either:
|
|
107
|
+
* - A predicate function that takes a PColumnSpec and returns a boolean.
|
|
108
|
+
* Only specs that return true will be included.
|
|
109
|
+
* - An APColumnSelector object for declarative filtering, which will be
|
|
110
|
+
* resolved against the provided anchors and matched using matchPColumn.
|
|
111
|
+
* - An array of APColumnSelector objects - columns matching ANY selector
|
|
112
|
+
* in the array will be included (OR operation).
|
|
113
|
+
* @param opts - Optional configuration for label generation:
|
|
114
|
+
* - labelOps: Optional configuration for label generation:
|
|
115
|
+
* - includeNativeLabel: Whether to include native column labels
|
|
116
|
+
* - separator: String to use between label parts (defaults to " / ")
|
|
117
|
+
* - addLabelAsSuffix: Whether to add labels as suffix instead of prefix
|
|
118
|
+
* - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined,
|
|
119
|
+
* if at least one column that requires splitting is missing data)
|
|
120
|
+
* @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties,
|
|
121
|
+
* or undefined if any PlRef resolution fails.
|
|
122
|
+
*/
|
|
123
|
+
getCanonicalOptions(anchorsOrCtx, predicateOrSelectors, opts) {
|
|
124
|
+
const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
|
|
125
|
+
if (!anchorCtx) return void 0;
|
|
126
|
+
const entries = new PColumnCollection().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(predicateOrSelectors, {
|
|
127
|
+
...opts,
|
|
128
|
+
anchorCtx
|
|
129
|
+
});
|
|
130
|
+
if (!entries) return void 0;
|
|
131
|
+
return entries.map((item) => ({
|
|
132
|
+
value: item.id,
|
|
133
|
+
label: item.label
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated use getData()
|
|
138
|
+
*/
|
|
139
|
+
getDataFromResultPool() {
|
|
140
|
+
return this.getData();
|
|
141
|
+
}
|
|
142
|
+
getData() {
|
|
143
|
+
const result = this.ctx.getDataFromResultPool();
|
|
144
|
+
return {
|
|
145
|
+
isComplete: result.isComplete,
|
|
146
|
+
entries: result.entries.map((e) => ({
|
|
147
|
+
ref: e.ref,
|
|
148
|
+
obj: {
|
|
149
|
+
...e.obj,
|
|
150
|
+
data: new TreeNodeAccessor(e.obj.data, [e.ref.blockId, e.ref.name])
|
|
151
|
+
}
|
|
152
|
+
}))
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated use getDataWithErrors()
|
|
157
|
+
*/
|
|
158
|
+
getDataWithErrorsFromResultPool() {
|
|
159
|
+
return this.getDataWithErrors();
|
|
160
|
+
}
|
|
161
|
+
getDataWithErrors() {
|
|
162
|
+
const result = this.ctx.getDataWithErrorsFromResultPool();
|
|
163
|
+
return {
|
|
164
|
+
isComplete: result.isComplete,
|
|
165
|
+
entries: result.entries.map((e) => ({
|
|
166
|
+
ref: e.ref,
|
|
167
|
+
obj: {
|
|
168
|
+
...e.obj,
|
|
169
|
+
data: mapValueInVOE(e.obj.data, (handle) => new TreeNodeAccessor(handle, [e.ref.blockId, e.ref.name]))
|
|
170
|
+
}
|
|
171
|
+
}))
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated use getSpecs()
|
|
176
|
+
*/
|
|
177
|
+
getSpecsFromResultPool() {
|
|
178
|
+
return this.getSpecs();
|
|
179
|
+
}
|
|
180
|
+
getSpecs() {
|
|
181
|
+
return this.ctx.getSpecsFromResultPool();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @param ref a Ref
|
|
185
|
+
* @returns data associated with the ref
|
|
186
|
+
*/
|
|
187
|
+
getDataByRef(ref) {
|
|
188
|
+
if (typeof this.ctx.getDataFromResultPoolByRef === "undefined") return this.getData().entries.find((f) => f.ref.blockId === ref.blockId && f.ref.name === ref.name)?.obj;
|
|
189
|
+
const data = this.ctx.getDataFromResultPoolByRef(ref.blockId, ref.name);
|
|
190
|
+
if (!data) return void 0;
|
|
191
|
+
return mapPObjectData(data, (handle) => new TreeNodeAccessor(handle, [ref.blockId, ref.name]));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Returns data associated with the ref ensuring that it is a p-column.
|
|
195
|
+
* @param ref a Ref
|
|
196
|
+
* @returns p-column associated with the ref
|
|
197
|
+
*/
|
|
198
|
+
getPColumnByRef(ref) {
|
|
199
|
+
const data = this.getDataByRef(ref);
|
|
200
|
+
if (!data) return void 0;
|
|
201
|
+
return ensurePColumn(data);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns spec associated with the ref ensuring that it is a p-column spec.
|
|
205
|
+
* @param ref a Ref
|
|
206
|
+
* @returns p-column spec associated with the ref
|
|
207
|
+
*/
|
|
208
|
+
getPColumnSpecByRef(ref) {
|
|
209
|
+
const spec = this.getSpecByRef(ref);
|
|
210
|
+
if (!spec) return void 0;
|
|
211
|
+
if (!isPColumnSpec(spec)) throw new Error(`not a PColumn spec (kind = ${spec.kind})`);
|
|
212
|
+
return spec;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* @param ref a Ref
|
|
216
|
+
* @returns object spec associated with the ref
|
|
217
|
+
*/
|
|
218
|
+
getSpecByRef(ref) {
|
|
219
|
+
return this.ctx.getSpecFromResultPoolByRef(ref.blockId, ref.name);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @param spec object specification
|
|
223
|
+
* @returns array of data objects with compatible specs
|
|
224
|
+
* @deprecated delete this method after Jan 1, 2025
|
|
225
|
+
*/
|
|
226
|
+
findDataWithCompatibleSpec(spec) {
|
|
227
|
+
const result = [];
|
|
228
|
+
out: for (const data of this.getData().entries) {
|
|
229
|
+
if (!isPColumnSpec(data.obj.spec)) continue;
|
|
230
|
+
const oth = data.obj.spec;
|
|
231
|
+
if (spec.name !== oth.name) continue;
|
|
232
|
+
if (spec.valueType !== oth.valueType) continue;
|
|
233
|
+
if (spec.axesSpec.length !== oth.axesSpec.length) continue;
|
|
234
|
+
if (!matchDomain(spec.domain, oth.domain)) continue;
|
|
235
|
+
for (let i = 0; i < spec.axesSpec.length; ++i) {
|
|
236
|
+
const qAx = spec.axesSpec[i];
|
|
237
|
+
const tAx = oth.axesSpec[i];
|
|
238
|
+
if (qAx.name !== tAx.name) continue out;
|
|
239
|
+
if (qAx.type !== tAx.type) continue out;
|
|
240
|
+
if (!matchDomain(qAx.domain, tAx.domain)) continue out;
|
|
241
|
+
}
|
|
242
|
+
result.push(data.obj);
|
|
243
|
+
}
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Find labels data for a given axis id. It will search for a label column and return its data as a map.
|
|
248
|
+
* @returns a map of axis value => label
|
|
249
|
+
*/
|
|
250
|
+
findLabels(axis) {
|
|
251
|
+
const dataPool = this.getData();
|
|
252
|
+
for (const column of dataPool.entries) {
|
|
253
|
+
if (!isPColumn(column.obj)) continue;
|
|
254
|
+
const spec = column.obj.spec;
|
|
255
|
+
if (spec.name === PColumnName.Label && spec.axesSpec.length === 1 && spec.axesSpec[0].name === axis.name && spec.axesSpec[0].type === axis.type && matchDomain(axis.domain, spec.axesSpec[0].domain)) {
|
|
256
|
+
if (column.obj.data.resourceType.name !== "PColumnData/Json") throw Error(`Expected JSON column for labels, got: ${column.obj.data.resourceType.name}`);
|
|
257
|
+
return Object.fromEntries(Object.entries(column.obj.data.getDataAsJson().data).map((e) => [JSON.parse(e[0])[0], e[1]]));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Selects columns based on the provided selectors, returning PColumn objects
|
|
263
|
+
* with lazily loaded data.
|
|
264
|
+
*
|
|
265
|
+
* @param selectors - A predicate function, a single selector, or an array of selectors.
|
|
266
|
+
* @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
|
|
267
|
+
*/
|
|
268
|
+
selectColumns(selectors) {
|
|
269
|
+
const predicate = typeof selectors === "function" ? selectors : selectorsToPredicate(selectors);
|
|
270
|
+
return this.getSpecs().entries.filter(({ obj: spec }) => {
|
|
271
|
+
if (!isPColumnSpec(spec)) return false;
|
|
272
|
+
return predicate(spec);
|
|
273
|
+
}).map(({ ref, obj: spec }) => {
|
|
274
|
+
const pcolumnSpec = spec;
|
|
275
|
+
let _cachedData = null;
|
|
276
|
+
const self = this;
|
|
277
|
+
return {
|
|
278
|
+
id: canonicalize(ref),
|
|
279
|
+
spec: pcolumnSpec,
|
|
280
|
+
get data() {
|
|
281
|
+
if (_cachedData !== null) return _cachedData;
|
|
282
|
+
_cachedData = self.getPColumnByRef(ref)?.data;
|
|
283
|
+
return _cachedData;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Find labels data for a given axis id of a p-column.
|
|
290
|
+
* @returns a map of axis value => label
|
|
291
|
+
*/
|
|
292
|
+
findLabelsForColumnAxis(column, axisIdx) {
|
|
293
|
+
const labels = this.findLabels(column.axesSpec[axisIdx]);
|
|
294
|
+
if (!labels) return void 0;
|
|
295
|
+
const axisKeys = readAnnotation(column, `pl7.app/axisKeys/${axisIdx}`);
|
|
296
|
+
if (axisKeys !== void 0) {
|
|
297
|
+
const keys = JSON.parse(axisKeys);
|
|
298
|
+
return Object.fromEntries(keys.map((key) => {
|
|
299
|
+
return [key, labels[key] ?? "Unlabelled"];
|
|
300
|
+
}));
|
|
301
|
+
} else return labels;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
383
304
|
/** Main entry point to the API available within model lambdas (like outputs, sections, etc..) */
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return this.ctx.createPTableV2(mapPTableDefV2(def, (po) => transformPColumnData(po)));
|
|
496
|
-
}
|
|
497
|
-
/** @deprecated scheduled for removal from SDK */
|
|
498
|
-
getBlockLabel(blockId) {
|
|
499
|
-
return this.ctx.getBlockLabel(blockId);
|
|
500
|
-
}
|
|
501
|
-
getCurrentUnstableMarker() {
|
|
502
|
-
return this.ctx.getCurrentUnstableMarker();
|
|
503
|
-
}
|
|
504
|
-
logInfo(msg) {
|
|
505
|
-
this.ctx.logInfo(msg);
|
|
506
|
-
}
|
|
507
|
-
logWarn(msg) {
|
|
508
|
-
this.ctx.logWarn(msg);
|
|
509
|
-
}
|
|
510
|
-
logError(msg) {
|
|
511
|
-
this.ctx.logError(msg);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
305
|
+
var RenderCtxBase = class {
|
|
306
|
+
ctx;
|
|
307
|
+
constructor() {
|
|
308
|
+
this.ctx = getCfgRenderCtx();
|
|
309
|
+
}
|
|
310
|
+
dataCache;
|
|
311
|
+
get data() {
|
|
312
|
+
if (this.dataCache === void 0) {
|
|
313
|
+
const raw = this.ctx.data;
|
|
314
|
+
const value = typeof raw === "function" ? raw() : raw;
|
|
315
|
+
this.dataCache = { v: value ? JSON.parse(value) : {} };
|
|
316
|
+
}
|
|
317
|
+
return this.dataCache.v;
|
|
318
|
+
}
|
|
319
|
+
activeArgsCache;
|
|
320
|
+
/**
|
|
321
|
+
* Returns args snapshot the block was executed for (i.e. when "Run" button was pressed).
|
|
322
|
+
* Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared.
|
|
323
|
+
* */
|
|
324
|
+
get activeArgs() {
|
|
325
|
+
if (this.activeArgsCache === void 0) {
|
|
326
|
+
const raw = this.ctx.activeArgs;
|
|
327
|
+
const value = typeof raw === "function" ? raw() : raw;
|
|
328
|
+
this.activeArgsCache = { v: value ? JSON.parse(value) : void 0 };
|
|
329
|
+
}
|
|
330
|
+
return this.activeArgsCache.v;
|
|
331
|
+
}
|
|
332
|
+
getNamedAccessor(name) {
|
|
333
|
+
return ifDef(this.ctx.getAccessorHandleByName(name), (accessor) => new TreeNodeAccessor(accessor, [name]));
|
|
334
|
+
}
|
|
335
|
+
get prerun() {
|
|
336
|
+
return this.getNamedAccessor(StagingAccessorName);
|
|
337
|
+
}
|
|
338
|
+
get outputs() {
|
|
339
|
+
return this.getNamedAccessor(MainAccessorName);
|
|
340
|
+
}
|
|
341
|
+
resultPool = new ResultPool();
|
|
342
|
+
/**
|
|
343
|
+
* Find labels data for a given axis id. It will search for a label column and return its data as a map.
|
|
344
|
+
* @returns a map of axis value => label
|
|
345
|
+
* @deprecated Use resultPool.findLabels instead
|
|
346
|
+
*/
|
|
347
|
+
findLabels(axis) {
|
|
348
|
+
return this.resultPool.findLabels(axis);
|
|
349
|
+
}
|
|
350
|
+
verifyInlineAndExplicitColumnsSupport(columns) {
|
|
351
|
+
const hasInlineColumns = columns.some((c) => !(c.data instanceof TreeNodeAccessor) || isDataInfo(c.data));
|
|
352
|
+
const inlineColumnsSupport = this.ctx.featureFlags?.inlineColumnsSupport === true;
|
|
353
|
+
if (hasInlineColumns && !inlineColumnsSupport) throw Error(`Inline or explicit columns not supported`);
|
|
354
|
+
}
|
|
355
|
+
patchPTableDef(def) {
|
|
356
|
+
if (!this.ctx.featureFlags?.pTablePartitionFiltersSupport) def = {
|
|
357
|
+
...def,
|
|
358
|
+
partitionFilters: [],
|
|
359
|
+
filters: [...def.partitionFilters, ...def.filters]
|
|
360
|
+
};
|
|
361
|
+
if (!this.ctx.featureFlags?.pFrameInSetFilterSupport) def = {
|
|
362
|
+
...def,
|
|
363
|
+
partitionFilters: patchInSetFilters(def.partitionFilters),
|
|
364
|
+
filters: patchInSetFilters(def.filters)
|
|
365
|
+
};
|
|
366
|
+
return def;
|
|
367
|
+
}
|
|
368
|
+
createPFrame(def) {
|
|
369
|
+
this.verifyInlineAndExplicitColumnsSupport(def);
|
|
370
|
+
if (!allPColumnsReady(def)) return void 0;
|
|
371
|
+
return this.ctx.createPFrame(def.map((c) => transformPColumnData(c)));
|
|
372
|
+
}
|
|
373
|
+
createPTable(def) {
|
|
374
|
+
let rawDef;
|
|
375
|
+
if ("columns" in def) rawDef = this.patchPTableDef({
|
|
376
|
+
src: {
|
|
377
|
+
type: "full",
|
|
378
|
+
entries: def.columns.map((c) => ({
|
|
379
|
+
type: "column",
|
|
380
|
+
column: c
|
|
381
|
+
}))
|
|
382
|
+
},
|
|
383
|
+
partitionFilters: def.filters ?? [],
|
|
384
|
+
filters: [],
|
|
385
|
+
sorting: def.sorting ?? []
|
|
386
|
+
});
|
|
387
|
+
else rawDef = this.patchPTableDef(def);
|
|
388
|
+
const columns = extractAllColumns(rawDef.src);
|
|
389
|
+
this.verifyInlineAndExplicitColumnsSupport(columns);
|
|
390
|
+
if (!allPColumnsReady(columns)) return void 0;
|
|
391
|
+
return this.ctx.createPTable(mapPTableDef(rawDef, (po) => transformPColumnData(po)));
|
|
392
|
+
}
|
|
393
|
+
createPTableV2(def) {
|
|
394
|
+
const columns = collectSpecQueryColumns(def.query);
|
|
395
|
+
this.verifyInlineAndExplicitColumnsSupport(columns);
|
|
396
|
+
if (!allPColumnsReady(columns)) return void 0;
|
|
397
|
+
return this.ctx.createPTableV2(mapPTableDefV2(def, (po) => transformPColumnData(po)));
|
|
398
|
+
}
|
|
399
|
+
/** @deprecated scheduled for removal from SDK */
|
|
400
|
+
getBlockLabel(blockId) {
|
|
401
|
+
return this.ctx.getBlockLabel(blockId);
|
|
402
|
+
}
|
|
403
|
+
getCurrentUnstableMarker() {
|
|
404
|
+
return this.ctx.getCurrentUnstableMarker();
|
|
405
|
+
}
|
|
406
|
+
logInfo(msg) {
|
|
407
|
+
this.ctx.logInfo(msg);
|
|
408
|
+
}
|
|
409
|
+
logWarn(msg) {
|
|
410
|
+
this.ctx.logWarn(msg);
|
|
411
|
+
}
|
|
412
|
+
logError(msg) {
|
|
413
|
+
this.ctx.logError(msg);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
514
416
|
/** Main entry point to the API available within model lambdas (like outputs, sections, etc..) for v3+ blocks */
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
417
|
+
var BlockRenderCtx = class extends RenderCtxBase {
|
|
418
|
+
argsCache;
|
|
419
|
+
get args() {
|
|
420
|
+
if (this.argsCache === void 0) {
|
|
421
|
+
const raw = this.ctx.args;
|
|
422
|
+
const value = typeof raw === "function" ? raw() : raw;
|
|
423
|
+
this.argsCache = { v: value === void 0 ? void 0 : JSON.parse(value) };
|
|
424
|
+
}
|
|
425
|
+
return this.argsCache.v;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
526
428
|
/** Render context for legacy v1/v2 blocks - provides backward compatibility */
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
429
|
+
var RenderCtxLegacy = class extends RenderCtxBase {
|
|
430
|
+
argsCache;
|
|
431
|
+
get args() {
|
|
432
|
+
if (this.argsCache === void 0) {
|
|
433
|
+
const raw = this.ctx.args;
|
|
434
|
+
const value = typeof raw === "function" ? raw() : raw;
|
|
435
|
+
this.argsCache = { v: JSON.parse(value) };
|
|
436
|
+
}
|
|
437
|
+
return this.argsCache.v;
|
|
438
|
+
}
|
|
439
|
+
uiStateCache;
|
|
440
|
+
get uiState() {
|
|
441
|
+
if (this.uiStateCache === void 0) {
|
|
442
|
+
const raw = this.ctx.uiState;
|
|
443
|
+
const value = typeof raw === "function" ? raw() : raw;
|
|
444
|
+
this.uiStateCache = { v: value ? JSON.parse(value) : {} };
|
|
445
|
+
}
|
|
446
|
+
return this.uiStateCache.v;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
547
449
|
/**
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return this.paramsCache.v;
|
|
585
|
-
}
|
|
586
|
-
/** Result pool — same as block, from cfgRenderCtx methods */
|
|
587
|
-
resultPool = new ResultPool();
|
|
588
|
-
}
|
|
450
|
+
* Render context for plugin output functions.
|
|
451
|
+
* Reads plugin data from blockStorage and derives params from pre-wrapped input callbacks.
|
|
452
|
+
*
|
|
453
|
+
* Parameterized on the factory-like phantom F so that getPluginData returns
|
|
454
|
+
* InferFactoryData<F> directly — no casts needed for the data getter.
|
|
455
|
+
*
|
|
456
|
+
* @typeParam F - PluginFactoryLike phantom carrying data/params/outputs types
|
|
457
|
+
*/
|
|
458
|
+
var PluginRenderCtx = class {
|
|
459
|
+
ctx;
|
|
460
|
+
handle;
|
|
461
|
+
wrappedInputs;
|
|
462
|
+
constructor(handle, wrappedInputs) {
|
|
463
|
+
this.ctx = getCfgRenderCtx();
|
|
464
|
+
this.handle = handle;
|
|
465
|
+
this.wrappedInputs = wrappedInputs;
|
|
466
|
+
}
|
|
467
|
+
dataCache;
|
|
468
|
+
/** Plugin's persistent data from blockStorage.__plugins.{pluginId}.__data */
|
|
469
|
+
get data() {
|
|
470
|
+
if (this.dataCache === void 0) this.dataCache = { v: getPluginData(parseJson(this.ctx.blockStorage()), this.handle) };
|
|
471
|
+
return this.dataCache.v;
|
|
472
|
+
}
|
|
473
|
+
paramsCache;
|
|
474
|
+
/** Params derived from block context via pre-wrapped input callbacks */
|
|
475
|
+
get params() {
|
|
476
|
+
if (this.paramsCache === void 0) {
|
|
477
|
+
const result = {};
|
|
478
|
+
for (const [key, fn] of Object.entries(this.wrappedInputs)) result[key] = fn();
|
|
479
|
+
this.paramsCache = { v: result };
|
|
480
|
+
}
|
|
481
|
+
return this.paramsCache.v;
|
|
482
|
+
}
|
|
483
|
+
/** Result pool — same as block, from cfgRenderCtx methods */
|
|
484
|
+
resultPool = new ResultPool();
|
|
485
|
+
};
|
|
589
486
|
|
|
487
|
+
//#endregion
|
|
590
488
|
export { BlockRenderCtx, PluginRenderCtx, RenderCtxBase, RenderCtxLegacy, ResultPool };
|
|
591
|
-
//# sourceMappingURL=api.js.map
|
|
489
|
+
//# sourceMappingURL=api.js.map
|