ggaction 0.0.21 → 0.0.23
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/CHANGELOG.md +90 -0
- package/README.md +83 -90
- package/knowledge/action-card.schema.json +1 -1
- package/knowledge/action-cards.json +1 -1
- package/knowledge/intent-taxonomy.json +1 -1
- package/knowledge/mcp-resources.json +1 -1
- package/package.json +11 -4
- package/src/BasicChartProgram.js +1 -1
- package/src/accessibility.js +1 -0
- package/src/actions/boxPlots/components.js +1 -96
- package/src/actions/boxPlots/create.js +6 -1
- package/src/actions/boxPlots/edit.js +8 -0
- package/src/actions/boxPlots/materialize.js +3 -0
- package/src/actions/boxPlots/options.js +1 -1
- package/src/actions/canvas/actions.js +2 -1
- package/src/actions/canvas/index.js +3 -0
- package/src/actions/canvas/plotBorder.js +2 -1
- package/src/actions/canvas/plotOrder.js +14 -0
- package/src/actions/charts/area.js +1 -1
- package/src/actions/charts/bar.js +4 -4
- package/src/actions/charts/density.js +1 -1
- package/src/actions/charts/ecdf.js +1 -1
- package/src/actions/charts/endpoints.js +54 -5
- package/src/actions/charts/heatmap.js +1 -1
- package/src/actions/charts/histogram.js +1 -1
- package/src/actions/charts/horizon.js +1 -1
- package/src/actions/charts/index.js +2 -1
- package/src/actions/charts/interval-regression.js +3 -3
- package/src/actions/charts/line.js +1 -1
- package/src/actions/charts/radar.js +63 -3
- package/src/actions/charts/raincloud.js +37 -6
- package/src/actions/charts/rug-strip.js +2 -2
- package/src/actions/charts/scatter.js +3 -3
- package/src/actions/charts/text.js +1 -1
- package/src/actions/composition/actions.js +10 -3
- package/src/actions/coordinates/actions.js +2 -0
- package/src/actions/data/basic.js +6 -0
- package/src/actions/data/derived.js +6 -2
- package/src/actions/data/edit.js +22 -36
- package/src/actions/data/filter.js +1 -376
- package/src/actions/data/flatten.js +19 -0
- package/src/actions/data/index.js +6 -0
- package/src/actions/data/lookup.js +50 -0
- package/src/actions/data/raincloudFilter.js +56 -0
- package/src/actions/data/shared.js +10 -0
- package/src/actions/data/timeUnit.js +1 -1
- package/src/actions/distributions/revision.js +3 -1
- package/src/actions/encodings/angle.js +2 -1
- package/src/actions/encodings/appearance.js +38 -13
- package/src/actions/encodings/channels.js +14 -3
- package/src/actions/encodings/color/continuous.js +26 -10
- package/src/actions/encodings/color/index.js +50 -20
- package/src/actions/encodings/color/policy.js +57 -4
- package/src/actions/encodings/parallel.js +4 -0
- package/src/actions/encodings/position/policies/bar.js +10 -6
- package/src/actions/encodings/position/policies/line.js +1 -152
- package/src/actions/encodings/position/resolve.js +4 -1
- package/src/actions/encodings/ranged.js +46 -0
- package/src/actions/encodings/remove.js +1 -1
- package/src/actions/encodings/ruleAppearance.js +7 -6
- package/src/actions/encodings/shared.js +14 -2
- package/src/actions/encodings/stroke.js +20 -14
- package/src/actions/encodings/strokeDash.js +9 -11
- package/src/actions/encodings/text.js +30 -2
- package/src/actions/errorBars/edit.js +24 -4
- package/src/actions/facets/actions.js +1 -793
- package/src/actions/facets/derive.js +34 -5
- package/src/actions/facets/replay.js +1 -38
- package/src/actions/gradientPlots/components.js +21 -9
- package/src/actions/gradientPlots/create.js +4 -2
- package/src/actions/gradientPlots/edit.js +18 -1
- package/src/actions/gradientPlots/materialize.js +35 -36
- package/src/actions/gradientPlots/options.js +1 -1
- package/src/actions/gradientPlots/paint.js +13 -7
- package/src/actions/guides/applicability.js +2 -0
- package/src/actions/guides/axes/axes.js +39 -0
- package/src/actions/guides/axes/axis.js +9 -5
- package/src/actions/guides/axes/edit.js +11 -8
- package/src/actions/guides/axes/labels.js +24 -8
- package/src/actions/guides/axes/parallel/policy.js +3 -5
- package/src/actions/guides/axes/parallel/resolve.js +4 -3
- package/src/actions/guides/axes/policy.js +22 -0
- package/src/actions/guides/axes/tickGroups.js +4 -2
- package/src/actions/guides/axes/ticks.js +22 -4
- package/src/actions/guides/axes/titles.js +19 -6
- package/src/actions/guides/facadeAxes.js +3 -0
- package/src/actions/guides/grids/grid.js +3 -1
- package/src/actions/guides/grids/resolve.js +7 -11
- package/src/actions/guides/guides.js +21 -1
- package/src/actions/guides/legends/categorical/actions.js +1 -515
- package/src/actions/guides/legends/categorical/components.js +1 -4
- package/src/actions/guides/legends/categorical/layout.js +5 -2
- package/src/actions/guides/legends/categorical/options.js +4 -0
- package/src/actions/guides/legends/categorical/resolve.js +8 -3
- package/src/actions/guides/legends/categorical/symbols.js +3 -3
- package/src/actions/guides/legends/colorSize.js +2 -0
- package/src/actions/guides/legends/continuous/common.js +1 -1
- package/src/actions/guides/legends/continuous/gradient.js +1 -360
- package/src/actions/guides/legends/continuous/interval.js +1 -1
- package/src/actions/guides/legends/continuous/opacity.js +15 -1
- package/src/actions/guides/legends/edit.js +1 -1
- package/src/actions/guides/legends/focused.js +1 -1
- package/src/actions/guides/legends/lane.js +1 -1
- package/src/actions/guides/legends/sampling.js +1 -140
- package/src/actions/guides/legends/strokeWidth.js +3 -2
- package/src/actions/guides/legends/transition.js +19 -2
- package/src/actions/guides/polar/axes/facade.js +5 -4
- package/src/actions/guides/polar/axes/labels.js +5 -4
- package/src/actions/guides/polar/axes/titles.js +5 -4
- package/src/actions/guides/polar/resolve.js +2 -1
- package/src/actions/guides/tickValues.js +7 -7
- package/src/actions/marks/arc/actions.js +5 -7
- package/src/actions/marks/area/actions.js +9 -3
- package/src/actions/marks/bar/create.js +4 -2
- package/src/actions/marks/bar/edit.js +9 -6
- package/src/actions/marks/bar/materialize.js +5 -3
- package/src/actions/marks/dependentReferences.js +87 -0
- package/src/actions/marks/index.js +2 -0
- package/src/actions/marks/lifecycle.js +2 -1
- package/src/actions/marks/line/actions.js +24 -6
- package/src/actions/marks/line/materialize.js +7 -3
- package/src/actions/marks/point/create.js +5 -4
- package/src/actions/marks/point/edit.js +6 -3
- package/src/actions/marks/point/jitter.js +6 -6
- package/src/actions/marks/point/materialize.js +36 -39
- package/src/actions/marks/rect/actions.js +16 -4
- package/src/actions/marks/references.js +183 -35
- package/src/actions/marks/rule/actions.js +20 -9
- package/src/actions/marks/shared.js +2 -1
- package/src/actions/marks/text/actions.js +10 -3
- package/src/actions/marks/tick/actions.js +11 -2
- package/src/actions/primitives/editGraphics.js +28 -3
- package/src/actions/primitives/index.js +9 -0
- package/src/actions/primitives/semanticAction.js +13 -7
- package/src/actions/primitives/semanticValidation/layer.js +20 -0
- package/src/actions/primitives/semanticValidation/scale.js +8 -1
- package/src/actions/regression/create.js +6 -1
- package/src/actions/regression/edit.js +10 -1
- package/src/actions/scales/channels.js +1 -1
- package/src/actions/scales/consumers/common.js +19 -1
- package/src/actions/scales/consumers/families.js +2 -2
- package/src/actions/scales/consumers/seriesLayout.js +4 -3
- package/src/actions/scales/edit.js +11 -0
- package/src/actions/scales/editPolicy.js +5 -3
- package/src/actions/scales/preview.js +2 -1
- package/src/actions/scales/quantitativeColor.js +2 -4
- package/src/actions/selection/actions.js +10 -1
- package/src/actions/theme/reconcile.js +37 -9
- package/src/core/compositionState.js +26 -7
- package/src/core/datasetReferences.js +17 -0
- package/src/core/facetAxisPolicy.js +30 -0
- package/src/core/immutable.js +1 -0
- package/src/core/resourceReferences.js +5 -3
- package/src/core/validation.js +4 -0
- package/src/core/vocabulary.js +24 -2
- package/src/grammar/aggregate.js +1 -0
- package/src/grammar/arcs.js +1 -1
- package/src/grammar/areaSeries.js +1 -1
- package/src/grammar/axisTextPlacement.js +1 -1
- package/src/grammar/bars/policy.js +2 -2
- package/src/grammar/curveCommands.js +35 -2
- package/src/grammar/datasetDependencies.js +97 -0
- package/src/grammar/datasetSchema.js +32 -2
- package/src/grammar/facetHeaders.js +1 -0
- package/src/grammar/facets/dependencies.js +6 -2
- package/src/grammar/facets/guides.js +7 -5
- package/src/grammar/facets/legendIntent.js +6 -2
- package/src/grammar/facets/scales.js +27 -7
- package/src/grammar/flatten.js +85 -0
- package/src/grammar/histogram.js +13 -1
- package/src/grammar/horizon.js +1 -494
- package/src/grammar/jitter.js +2 -2
- package/src/grammar/legendSpacing.js +45 -0
- package/src/grammar/lineMissing.js +90 -0
- package/src/grammar/lineSeries.js +1 -376
- package/src/grammar/lookup.js +97 -0
- package/src/grammar/markFilter.js +4 -2
- package/src/grammar/markLabels.js +8 -3
- package/src/grammar/numeric.js +1 -1
- package/src/grammar/pathCommands.js +1 -1
- package/src/grammar/pathSeries.js +1 -109
- package/src/grammar/pointPolygon.js +81 -0
- package/src/grammar/pointShapes.js +15 -15
- package/src/grammar/rects.js +1 -1
- package/src/grammar/regression/derive.js +1 -195
- package/src/grammar/regression/parameters.js +7 -0
- package/src/grammar/scales/appearance.js +1 -1
- package/src/grammar/scales/color.js +1 -1
- package/src/grammar/scales/colorConsumers.js +1 -63
- package/src/grammar/scales/continuous.js +58 -1
- package/src/grammar/scales/definition.js +1 -1
- package/src/grammar/scales/ordinal.js +5 -2
- package/src/grammar/scales/policies.js +3 -3
- package/src/grammar/schemas/graphicBounds.js +40 -12
- package/src/grammar/schemas/graphicClip.js +23 -0
- package/src/grammar/schemas/graphicTree.js +16 -0
- package/src/grammar/statisticalReference.js +22 -0
- package/src/grammar/text.js +65 -1
- package/src/grammar/ticks.js +92 -1
- package/src/grammar/timeUnit.js +9 -3
- package/src/grammar/transformTopology.js +3 -1
- package/src/grammar/transforms.js +24 -0
- package/src/inspection.js +1 -495
- package/src/inspectionDescriptors.js +1 -1
- package/src/layout/canvas.js +1 -1
- package/src/layout/facetContentFlow.js +101 -0
- package/src/layout/facetHeaderTitles.js +1 -0
- package/src/layout/facetTopLane.js +29 -0
- package/src/layout/facets.js +1 -1
- package/src/layout/guideCollisions.js +9 -3
- package/src/layout/legendGroup.js +1 -1
- package/src/layout/legendItems.js +26 -10
- package/src/layout/legendSpacing.js +66 -0
- package/src/layout/plotDrawOrder.js +17 -0
- package/src/materialization/bars/histogram.js +8 -2
- package/src/materialization/bars/resolve.js +1 -1
- package/src/materialization/composition.js +1 -0
- package/src/materialization/compositionSnapshot.js +22 -2
- package/src/materialization/dataProvenance.js +1 -1
- package/src/materialization/facetContentBounds.js +96 -0
- package/src/materialization/facetGuides/layout.js +1 -1
- package/src/materialization/facetGuides/placement.js +39 -11
- package/src/materialization/facetGuides/preparation.js +43 -24
- package/src/materialization/facetHeaders.js +1 -1
- package/src/materialization/facetTopLane.js +25 -0
- package/src/materialization/facets.js +1 -1
- package/src/materialization/graphicHierarchy.js +30 -1
- package/src/materialization/graphicTranslation.js +2 -0
- package/src/materialization/guides/layout.js +1 -1
- package/src/materialization/guides/resources.js +1 -1
- package/src/materialization/legends.js +1 -1
- package/src/materialization/markClip.js +26 -0
- package/src/materialization/marks/capabilities.js +3 -2
- package/src/materialization/marks/grouping.js +7 -5
- package/src/materialization/marks/index.js +4 -2
- package/src/materialization/marks/policies.js +4 -0
- package/src/materialization/plotDrawOrder.js +44 -0
- package/src/materialization/rect.js +11 -3
- package/src/materialization/scaleGuideDependencies.js +13 -5
- package/src/materialization/selection/items/common.js +1 -1
- package/src/materialization/selection/items/path.js +1 -0
- package/src/materialization/selection/policies/index.js +2 -1
- package/src/materialization/text.js +10 -5
- package/src/mcp/cli.js +0 -0
- package/src/persistence/validation.js +114 -18
- package/src/persistence.js +4 -2
- package/src/renderers/canvas/index.js +16 -0
- package/src/renderers/canvas/isolated.js +11 -1
- package/src/renderers/canvas/native.js +7 -0
- package/src/renderers/canvas/scene.js +66 -0
- package/src/renderers/canvas/text.js +3 -2
- package/src/renderers/svg.js +1 -617
- package/src/renderers/svgSerialization.js +643 -0
- package/src/renderers/transitionScene.js +67 -0
- package/src/scene.js +89 -0
- package/src/selectors/axes.js +1 -1
- package/src/selectors/datasets.js +1 -0
- package/src/selectors/grids.js +9 -0
- package/src/selectors/markClip.js +28 -0
- package/src/selectors/raincloud.js +7 -0
- package/src/version.js +1 -1
- package/types/basic.d.ts +7 -0
- package/types/index.d.ts +8 -0
- package/types/program.d.ts +286 -70
- package/types/scene.d.ts +35 -0
|
@@ -8,12 +8,14 @@ const TRANSFORM_TOPOLOGY = Object.freeze({
|
|
|
8
8
|
density: Object.freeze({ facetTopology: "statistical" }),
|
|
9
9
|
ecdf: Object.freeze({ facetTopology: "statistical" }),
|
|
10
10
|
filter: Object.freeze({ facetTopology: "rowPreserving" }),
|
|
11
|
+
flatten: Object.freeze({ facetTopology: "statistical" }),
|
|
12
|
+
lookup: Object.freeze({ facetTopology: "rowPreserving" }),
|
|
11
13
|
fold: Object.freeze({ facetTopology: "statistical" }),
|
|
12
14
|
gradientProfile: Object.freeze({ facetTopology: "statistical" }),
|
|
13
15
|
horizon: Object.freeze({ facetTopology: "statistical" }),
|
|
14
16
|
interval: Object.freeze({ facetTopology: "statistical" }),
|
|
15
17
|
impute: Object.freeze({ facetTopology: "statistical" }),
|
|
16
|
-
markFilter: Object.freeze({ provenanceTransparent: true }),
|
|
18
|
+
markFilter: Object.freeze({ provenanceTransparent: true, facetTopology: "statistical" }),
|
|
17
19
|
normalize: Object.freeze({ facetTopology: "statistical" }),
|
|
18
20
|
regression: Object.freeze({ facetTopology: "statistical" }),
|
|
19
21
|
regressionStatistics: Object.freeze({ facetTopology: "statistical" }),
|
|
@@ -29,6 +29,8 @@ import {
|
|
|
29
29
|
validateFilterTransform
|
|
30
30
|
} from "./filter.js";
|
|
31
31
|
import { normalizeFoldTransform, validateFoldTransform } from "./fold.js";
|
|
32
|
+
import { normalizeFlattenTransform, validateFlattenTransform } from "./flatten.js";
|
|
33
|
+
import {normalizeLookupTransform,validateLookupTransform} from "./lookup.js";
|
|
32
34
|
import {
|
|
33
35
|
requestedGradientProfileTransform,
|
|
34
36
|
validateGradientProfileTransform
|
|
@@ -381,6 +383,28 @@ const TRANSFORM_POLICIES = Object.freeze({
|
|
|
381
383
|
normalizeEdit: normalizeFilterTransformEdit,
|
|
382
384
|
outputRoles: () => ({})
|
|
383
385
|
}),
|
|
386
|
+
flatten: Object.freeze({
|
|
387
|
+
...findTransformTopology("flatten"),
|
|
388
|
+
validate: validateFlattenTransform,
|
|
389
|
+
materializeOp: "materializeFlattenData",
|
|
390
|
+
replayTransform: requestedTransform,
|
|
391
|
+
editable: true,
|
|
392
|
+
normalizeEdit: normalizeSimple(normalizeFlattenTransform),
|
|
393
|
+
outputRoles: transform => Object.fromEntries(
|
|
394
|
+
transform.fields.map((field, index) => [`value:${field}`, transform.as[index]])
|
|
395
|
+
)
|
|
396
|
+
}),
|
|
397
|
+
lookup: Object.freeze({
|
|
398
|
+
...findTransformTopology("lookup"),
|
|
399
|
+
validate:validateLookupTransform,
|
|
400
|
+
materializeOp:"materializeLookupData",
|
|
401
|
+
replayTransform:requestedTransform,
|
|
402
|
+
editable:true,
|
|
403
|
+
normalizeEdit:normalizeSimple(normalizeLookupTransform),
|
|
404
|
+
outputRoles:transform=>Object.fromEntries(transform.lookup.fields.map((field,index)=>[
|
|
405
|
+
`value:${field}`,transform.lookup.as[index]
|
|
406
|
+
]))
|
|
407
|
+
}),
|
|
384
408
|
fold: Object.freeze({
|
|
385
409
|
...findTransformTopology("fold"),
|
|
386
410
|
validate: validateFoldTransform,
|
package/src/inspection.js
CHANGED
|
@@ -1,495 +1 @@
|
|
|
1
|
-
import { ChartProgram } from "./ChartProgram.js";
|
|
2
|
-
import { BasicChartProgram } from "./BasicChartProgram.js";
|
|
3
|
-
import { getWrappedActionMetadata } from "./core/action.js";
|
|
4
|
-
import { cloneAndFreeze, isPlainObject } from "./core/immutable.js";
|
|
5
|
-
import { encodeValue } from "./persistence/codec.js";
|
|
6
|
-
import {
|
|
7
|
-
findDataset,
|
|
8
|
-
hasDatasetOwner,
|
|
9
|
-
resolveDatasetReference
|
|
10
|
-
} from "./selectors/datasets.js";
|
|
11
|
-
import { findLayer } from "./selectors/layers.js";
|
|
12
|
-
import { findSemanticScale } from "./selectors/scales.js";
|
|
13
|
-
import { findCoordinate } from "./selectors/coordinates.js";
|
|
14
|
-
import { inferDatasetSchema } from "./grammar/datasetSchema.js";
|
|
15
|
-
import { BUILTIN_ACTION_DESCRIPTOR_RECORDS } from "./inspectionDescriptors.js";
|
|
16
|
-
|
|
17
|
-
const KINDS = new Set(["data", "mark", "scale", "coordinate", "guide"]);
|
|
18
|
-
const ACTION_DESCRIPTORS = new Map(BUILTIN_ACTION_DESCRIPTOR_RECORDS.map(
|
|
19
|
-
([name, options, idOptions, prerequisites, entryPoints]) => [name, {
|
|
20
|
-
options: options.map(([path, required, kind, choices, unit]) => ({
|
|
21
|
-
path, required, kind,
|
|
22
|
-
...(choices === null ? {} : { choices }),
|
|
23
|
-
...(unit === null ? {} : { unit })
|
|
24
|
-
})),
|
|
25
|
-
idOptions,
|
|
26
|
-
prerequisites,
|
|
27
|
-
entryPoints
|
|
28
|
-
}]
|
|
29
|
-
));
|
|
30
|
-
|
|
31
|
-
function requireProgram(program, label = "Program") {
|
|
32
|
-
if (!(program instanceof ChartProgram || program instanceof BasicChartProgram)) {
|
|
33
|
-
throw new TypeError(`${label} must be a ggaction program.`);
|
|
34
|
-
}
|
|
35
|
-
if (program.actionStack.length !== 0) throw new Error(`${label} must have a closed action stack.`);
|
|
36
|
-
return program;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function atChildPath(program, childPath = []) {
|
|
40
|
-
if (!Array.isArray(childPath)) throw new TypeError("childPath must be an array.");
|
|
41
|
-
let current = program;
|
|
42
|
-
for (const id of childPath) {
|
|
43
|
-
if (typeof id !== "string" || !Object.hasOwn(current.children, id)) {
|
|
44
|
-
throw new Error(`Unknown program child "${String(id)}".`);
|
|
45
|
-
}
|
|
46
|
-
current = current.children[id];
|
|
47
|
-
}
|
|
48
|
-
return current;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function validateTarget(target) {
|
|
52
|
-
if (!isPlainObject(target) || !KINDS.has(target.kind) || typeof target.id !== "string" || target.id.length === 0) {
|
|
53
|
-
throw new TypeError("Inspection target requires a supported kind and non-empty id.");
|
|
54
|
-
}
|
|
55
|
-
return target;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function findResource(program, target) {
|
|
59
|
-
const current = atChildPath(program, target.childPath);
|
|
60
|
-
if (target.kind === "data") {
|
|
61
|
-
return hasDatasetOwner(current, target.id)
|
|
62
|
-
? resolveDatasetReference(current, target.id, "Inspection target")
|
|
63
|
-
: findDataset(current, target.id);
|
|
64
|
-
}
|
|
65
|
-
if (target.kind === "mark") return findLayer(current, target.id);
|
|
66
|
-
if (target.kind === "scale") return findSemanticScale(current, target.id);
|
|
67
|
-
if (target.kind === "coordinate") return findCoordinate(current, target.id);
|
|
68
|
-
return current.semanticSpec.guides[target.id];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function resourceRef(kind, id, childPath) {
|
|
72
|
-
return { kind, id, ...(childPath?.length ? { childPath: [...childPath] } : {}) };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function getDatasetSchema(program, { data, childPath } = {}) {
|
|
76
|
-
requireProgram(program);
|
|
77
|
-
const current = atChildPath(program, childPath);
|
|
78
|
-
if (typeof data !== "string" || data.length === 0) throw new TypeError("getDatasetSchema requires data.");
|
|
79
|
-
const dataset = resolveDatasetReference(current, data, "Dataset schema data");
|
|
80
|
-
const schema = dataset.schema ?? inferDatasetSchema(dataset.values ?? []);
|
|
81
|
-
return cloneAndFreeze({ data: dataset.id, schema });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function describeAction(program, { action, target, options = {} } = {}) {
|
|
85
|
-
requireProgram(program);
|
|
86
|
-
if (typeof action !== "string" || action.length === 0) throw new TypeError("describeAction requires action.");
|
|
87
|
-
if (!isPlainObject(options)) throw new TypeError("describeAction options must be a plain object.");
|
|
88
|
-
let targetResource;
|
|
89
|
-
if (target !== undefined) {
|
|
90
|
-
validateTarget(target);
|
|
91
|
-
targetResource = findResource(program, target);
|
|
92
|
-
if (targetResource === undefined) {
|
|
93
|
-
return cloneAndFreeze({
|
|
94
|
-
version: 1, action, applicability: "incompatible", parameterDefinitions: [], requirements: [],
|
|
95
|
-
checks: [{ name: "target", status: "failed", evidencePaths: [], findings: [] }],
|
|
96
|
-
findings: [{ severity: "error", code: "missing-resource", reason: "target-unavailable", message: `Unknown ${target.kind} "${target.id}".`, resource: resourceRef(target.kind, target.id, target.childPath) }]
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
if (options.target !== undefined && options.target !== target.id) {
|
|
100
|
-
return cloneAndFreeze({
|
|
101
|
-
version: 1, action, applicability: "incompatible", parameterDefinitions: [], requirements: [],
|
|
102
|
-
checks: [{ name: "target", status: "failed", evidencePaths: ["target"], findings: [] }],
|
|
103
|
-
findings: [{ severity: "error", code: "incompatible-resource", reason: "target-mismatch", message: `Inspection target "${target.id}" conflicts with options.target "${options.target}".`, resource: resourceRef(target.kind, target.id, target.childPath), optionPath: "target" }]
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if (action === "encodeShape" && (target.kind !== "mark" || targetResource.mark?.type !== "point")) {
|
|
107
|
-
return cloneAndFreeze({
|
|
108
|
-
version: 1, action, applicability: "unsupported", parameterDefinitions: [], requirements: [],
|
|
109
|
-
checks: [{ name: "target", status: "not_applicable", evidencePaths: ["target"], findings: [] }],
|
|
110
|
-
findings: [{ severity: "info", code: "unsupported-combination", reason: "mark-type", message: "encodeShape supports Point marks.", resource: resourceRef(target.kind, target.id, target.childPath) }]
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const fn = program[action];
|
|
115
|
-
const metadata = typeof fn === "function" ? getWrappedActionMetadata(fn) : undefined;
|
|
116
|
-
if (metadata === undefined) {
|
|
117
|
-
return cloneAndFreeze({
|
|
118
|
-
version: 1, action, applicability: typeof fn === "function" ? "unverified" : "unsupported",
|
|
119
|
-
parameterDefinitions: [], requirements: [], checks: [], findings: [{ severity: "info", code: "unsupported-format", reason: typeof fn === "function" ? "extension-unverified" : "action-unavailable", message: `Action "${action}" has no built-in inspection descriptor.` }]
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
const descriptor = ACTION_DESCRIPTORS.get(action);
|
|
123
|
-
const optionNames = metadata.options ?? descriptor?.options.map(option => option.path);
|
|
124
|
-
if (optionNames === undefined) {
|
|
125
|
-
return cloneAndFreeze({
|
|
126
|
-
version: 1, action, applicability: "unverified", parameterDefinitions: [], requirements: [],
|
|
127
|
-
checks: [{ name: "execution", status: "not_run", evidencePaths: [], findings: [] }],
|
|
128
|
-
findings: [{ severity: "info", code: "unsupported-format", reason: "descriptor-unavailable", message: `Action "${action}" is registered but its static option descriptor is unavailable.` }]
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
const unknown = Object.keys(options).find(key => !optionNames.includes(key));
|
|
132
|
-
const required = descriptor?.options.filter(option => option.required).map(option => option.path) ?? [];
|
|
133
|
-
const missing = required.filter(key => options[key] === undefined);
|
|
134
|
-
let fieldFinding = [];
|
|
135
|
-
if (targetResource !== undefined && target.kind === "mark") {
|
|
136
|
-
const schema = getDatasetSchema(program, {
|
|
137
|
-
data: targetResource.data,
|
|
138
|
-
childPath: target.childPath
|
|
139
|
-
}).schema;
|
|
140
|
-
if (schema.completeness === "known") {
|
|
141
|
-
const fields = new Set(schema.fields.map(field => field.name));
|
|
142
|
-
fieldFinding = (descriptor?.options ?? [])
|
|
143
|
-
.filter(definition => definition.kind === "field" &&
|
|
144
|
-
typeof options[definition.path] === "string" &&
|
|
145
|
-
!fields.has(options[definition.path]))
|
|
146
|
-
.map(definition => ({
|
|
147
|
-
severity: "error",
|
|
148
|
-
code: "missing-resource",
|
|
149
|
-
reason: "field-unavailable",
|
|
150
|
-
message: `Dataset does not contain field "${options[definition.path]}".`,
|
|
151
|
-
resource: resourceRef("data", targetResource.data, target.childPath),
|
|
152
|
-
optionPath: definition.path
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const finding = unknown !== undefined
|
|
157
|
-
? [{ severity: "error", code: "invalid-option", reason: "unknown-option", message: `Unknown ${action} option "${unknown}".`, optionPath: unknown }]
|
|
158
|
-
: [...missing.map(key => ({ severity: "info", code: "missing-input", reason: "required-option", message: `${action} requires option "${key}".`, optionPath: key })), ...fieldFinding];
|
|
159
|
-
const applicability = unknown !== undefined || fieldFinding.length ? "incompatible" : missing.length ? "needs-input" : "supported";
|
|
160
|
-
return cloneAndFreeze({
|
|
161
|
-
version: 1,
|
|
162
|
-
action,
|
|
163
|
-
applicability,
|
|
164
|
-
parameterDefinitions: descriptor?.options.map(definition => ({
|
|
165
|
-
...definition,
|
|
166
|
-
active: true
|
|
167
|
-
})) ?? optionNames.map(path => ({ path, kind: "object", required: false, active: true })),
|
|
168
|
-
requirements: missing.map(optionPath => ({ reason: "required-option", optionPath })),
|
|
169
|
-
checks: [
|
|
170
|
-
{ name: "option-shape", status: unknown === undefined ? "passed" : "failed", evidencePaths: Object.keys(options), findings: unknown === undefined ? [] : finding },
|
|
171
|
-
{ name: "execution", status: "not_run", evidencePaths: [], findings: [] }
|
|
172
|
-
],
|
|
173
|
-
findings: finding
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function canonicalInput(value) {
|
|
178
|
-
if (Array.isArray(value)) return value.map(canonicalInput);
|
|
179
|
-
if (!isPlainObject(value)) return value;
|
|
180
|
-
return Object.fromEntries(Object.keys(value).sort().map(
|
|
181
|
-
key => [key, canonicalInput(value[key])]
|
|
182
|
-
));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function canonical(value) {
|
|
186
|
-
return JSON.stringify(encodeValue(canonicalInput(value)));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function resources(program, childPath = [], output = []) {
|
|
190
|
-
for (const value of program.semanticSpec.datasets) output.push({ ref: resourceRef("data", value.id, childPath), value });
|
|
191
|
-
for (const [orderIndex, value] of program.semanticSpec.layers.entries()) output.push({
|
|
192
|
-
ref: resourceRef("mark", value.id, childPath),
|
|
193
|
-
value: { semantic: value, graphic: program.graphicSpec.objects[value.id], config: program.markConfigs[value.id], orderIndex }
|
|
194
|
-
});
|
|
195
|
-
for (const value of program.semanticSpec.scales) output.push({ ref: resourceRef("scale", value.id, childPath), value: { semantic: value, resolved: program.resolvedScales[value.id] } });
|
|
196
|
-
for (const value of program.semanticSpec.coordinates) output.push({ ref: resourceRef("coordinate", value.id, childPath), value });
|
|
197
|
-
for (const [id, value] of Object.entries(program.semanticSpec.guides)) output.push({ ref: resourceRef("guide", id, childPath), value: { semantic: value, graphic: program.graphicSpec.objects[id], config: program.guideConfigs[id] } });
|
|
198
|
-
if (Object.keys(program.semanticSpec.title).length) output.push({ ref: resourceRef("guide", "title", childPath), value: { semantic: program.semanticSpec.title, config: program.guideConfigs.title } });
|
|
199
|
-
if (program.graphicSpec.objects.canvas !== undefined) output.push({
|
|
200
|
-
ref: resourceRef("canvas", "canvas", childPath),
|
|
201
|
-
value: program.graphicSpec.objects.canvas
|
|
202
|
-
});
|
|
203
|
-
if (Object.keys(program.compositionSpec ?? {}).length > 0) output.push({
|
|
204
|
-
ref: resourceRef("composition", "layout", childPath),
|
|
205
|
-
value: program.compositionSpec
|
|
206
|
-
});
|
|
207
|
-
for (const [id, child] of Object.entries(program.children)) resources(child, [...childPath, id], output);
|
|
208
|
-
return output;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function refKey(ref) { return `${ref.childPath?.join("/") ?? ""}|${ref.kind}|${ref.id}`; }
|
|
212
|
-
function effect(kind) { return kind === "data" ? "data" : kind === "scale" ? "scale" : kind === "guide" ? "guide" : ["coordinate", "canvas", "composition"].includes(kind) ? "structure" : "style"; }
|
|
213
|
-
function changeEffect(a, b, kind) {
|
|
214
|
-
if (kind !== "mark" || a === undefined || b === undefined) return effect(kind);
|
|
215
|
-
if (a.value.orderIndex !== b.value.orderIndex) return "structure";
|
|
216
|
-
if (canonical(a.value.semantic?.encoding) !== canonical(b.value.semantic?.encoding) ||
|
|
217
|
-
a.value.semantic?.data !== b.value.semantic?.data) return "binding";
|
|
218
|
-
if (canonical(a.value.semantic) !== canonical(b.value.semantic)) return "structure";
|
|
219
|
-
return "style";
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function comparePrograms(before, after, { target } = {}) {
|
|
223
|
-
requireProgram(before, "Before program");
|
|
224
|
-
requireProgram(after, "After program");
|
|
225
|
-
if (target !== undefined) validateTarget(target);
|
|
226
|
-
const left = new Map(resources(before).map(item => [refKey(item.ref), item]));
|
|
227
|
-
const right = new Map(resources(after).map(item => [refKey(item.ref), item]));
|
|
228
|
-
const keys = [...new Set([...left.keys(), ...right.keys()])].sort();
|
|
229
|
-
let changes = keys.flatMap(key => {
|
|
230
|
-
const a = left.get(key); const b = right.get(key); const item = a ?? b;
|
|
231
|
-
if (a !== undefined && b !== undefined && canonical(a.value) === canonical(b.value)) return [];
|
|
232
|
-
const semanticRoles = item.ref.kind === "mark" && a !== undefined && b !== undefined
|
|
233
|
-
? [...new Set([...Object.keys(a.value.semantic?.encoding ?? {}), ...Object.keys(b.value.semantic?.encoding ?? {})])]
|
|
234
|
-
.filter(role => canonical(a.value.semantic?.encoding?.[role]) !== canonical(b.value.semantic?.encoding?.[role]))
|
|
235
|
-
: [];
|
|
236
|
-
return [{ resource: item.ref, operation: a === undefined ? "add" : b === undefined ? "remove" : "modify", effect: changeEffect(a, b, item.ref.kind), roles: semanticRoles }];
|
|
237
|
-
});
|
|
238
|
-
if (target !== undefined) {
|
|
239
|
-
const targetKeys = [before, after].flatMap(candidate => {
|
|
240
|
-
const resolved = findResource(candidate, target);
|
|
241
|
-
return resolved === undefined ? [] : [refKey(resourceRef(
|
|
242
|
-
target.kind,
|
|
243
|
-
target.kind === "data" ? resolved.id : target.id,
|
|
244
|
-
target.childPath
|
|
245
|
-
))];
|
|
246
|
-
});
|
|
247
|
-
if (targetKeys.length === 0) throw new Error(`Unknown ${target.kind} "${target.id}" in both programs.`);
|
|
248
|
-
const connected = new Set(targetKeys);
|
|
249
|
-
for (const map of [left, right]) {
|
|
250
|
-
let advanced = true;
|
|
251
|
-
while (advanced) {
|
|
252
|
-
advanced = false;
|
|
253
|
-
for (const [candidateKey, candidate] of map) {
|
|
254
|
-
if (connected.has(candidateKey)) continue;
|
|
255
|
-
const path = canonical(candidate.ref.childPath ?? []);
|
|
256
|
-
const consumes = [...connected].some(connectedKey => {
|
|
257
|
-
const source = map.get(connectedKey);
|
|
258
|
-
if (source === undefined || canonical(source.ref.childPath ?? []) !== path) return false;
|
|
259
|
-
if (source.ref.kind === "data") {
|
|
260
|
-
return candidate.ref.kind === "data"
|
|
261
|
-
? candidate.value.source === source.ref.id
|
|
262
|
-
: candidate.ref.kind === "mark" && candidate.value.semantic?.data === source.ref.id;
|
|
263
|
-
}
|
|
264
|
-
if (source.ref.kind === "mark") {
|
|
265
|
-
return (candidate.ref.kind === "mark" && candidate.value.semantic?.source === source.ref.id) ||
|
|
266
|
-
(candidate.ref.kind === "guide" && (candidate.value.semantic?.target === source.ref.id || candidate.value.config?.target === source.ref.id));
|
|
267
|
-
}
|
|
268
|
-
if (source.ref.kind === "scale") {
|
|
269
|
-
return (candidate.ref.kind === "mark" && Object.values(candidate.value.semantic?.encoding ?? {}).some(
|
|
270
|
-
encoding => encoding?.scale === source.ref.id || encoding?.dimensions?.some(dimension => dimension.scale === source.ref.id)
|
|
271
|
-
)) || (candidate.ref.kind === "guide" && (candidate.value.semantic?.scale === source.ref.id || candidate.value.config?.scale === source.ref.id));
|
|
272
|
-
}
|
|
273
|
-
return source.ref.kind === "coordinate" && candidate.ref.kind === "mark" &&
|
|
274
|
-
candidate.value.semantic?.coordinate === source.ref.id;
|
|
275
|
-
});
|
|
276
|
-
if (consumes) { connected.add(candidateKey); advanced = true; }
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
changes = changes.filter(change => connected.has(refKey(change.resource)));
|
|
281
|
-
}
|
|
282
|
-
const extensionUnknown = ![ChartProgram, BasicChartProgram].includes(before.constructor) ||
|
|
283
|
-
![ChartProgram, BasicChartProgram].includes(after.constructor);
|
|
284
|
-
const findings = extensionUnknown ? [{
|
|
285
|
-
severity: "info", code: "unsupported-format", reason: "extension-unverified",
|
|
286
|
-
message: "Extension-owned semantic equivalence could not be fully verified."
|
|
287
|
-
}] : [];
|
|
288
|
-
return cloneAndFreeze({
|
|
289
|
-
version: 1,
|
|
290
|
-
equivalence: changes.length ? "different" : extensionUnknown ? "unknown" : "equal",
|
|
291
|
-
completeProgramComparison: target === undefined,
|
|
292
|
-
changes,
|
|
293
|
-
affected: changes.map(change => change.resource),
|
|
294
|
-
findings
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function itemBounds(properties, type) {
|
|
299
|
-
if (!isPlainObject(properties)) return null;
|
|
300
|
-
if (type === "circle") {
|
|
301
|
-
if (!Number.isFinite(properties.x) || !Number.isFinite(properties.y) ||
|
|
302
|
-
!Number.isFinite(properties.radius) || properties.radius < 0) return null;
|
|
303
|
-
return { x: properties.x - properties.radius, y: properties.y - properties.radius,
|
|
304
|
-
width: properties.radius * 2, height: properties.radius * 2 };
|
|
305
|
-
}
|
|
306
|
-
if (type === "rect") {
|
|
307
|
-
if (![properties.x, properties.y, properties.width, properties.height].every(Number.isFinite)) return null;
|
|
308
|
-
return { x: Math.min(properties.x, properties.x + properties.width),
|
|
309
|
-
y: Math.min(properties.y, properties.y + properties.height),
|
|
310
|
-
width: Math.abs(properties.width), height: Math.abs(properties.height) };
|
|
311
|
-
}
|
|
312
|
-
if (type === "path" && Array.isArray(properties.commands)) {
|
|
313
|
-
const points = properties.commands.flatMap(command =>
|
|
314
|
-
Number.isFinite(command.x) && Number.isFinite(command.y) ? [[command.x, command.y]] : []
|
|
315
|
-
);
|
|
316
|
-
if (points.length === 0) return null;
|
|
317
|
-
const xs = points.map(point => point[0]);
|
|
318
|
-
const ys = points.map(point => point[1]);
|
|
319
|
-
return { x: Math.min(...xs), y: Math.min(...ys),
|
|
320
|
-
width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) };
|
|
321
|
-
}
|
|
322
|
-
if ([properties.x1, properties.y1, properties.x2, properties.y2].every(Number.isFinite)) {
|
|
323
|
-
return { x: Math.min(properties.x1, properties.x2), y: Math.min(properties.y1, properties.y2),
|
|
324
|
-
width: Math.abs(properties.x2 - properties.x1), height: Math.abs(properties.y2 - properties.y1) };
|
|
325
|
-
}
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function inspectMark(program, layer, childPath) {
|
|
330
|
-
const graphic = program.graphicSpec.objects[layer.id];
|
|
331
|
-
const dataset = findDataset(program, layer.data);
|
|
332
|
-
const boundedTypes = new Set(["circle", "rect", "line", "path"]);
|
|
333
|
-
const items = graphic?.items ?? (graphic?.properties ? [{ properties: graphic.properties }] : []);
|
|
334
|
-
const concreteTypes = items.map(item => item.type ?? graphic?.type);
|
|
335
|
-
const logicalSupported = graphic !== undefined && concreteTypes.every(type =>
|
|
336
|
-
boundedTypes.has(type) || type === "text"
|
|
337
|
-
);
|
|
338
|
-
const geometrySupported = logicalSupported && concreteTypes.every(type => boundedTypes.has(type));
|
|
339
|
-
const opacityZero = items.filter(item => item.properties.opacity === 0).length;
|
|
340
|
-
const zeroSize = items.filter(item => { const b = itemBounds(item.properties, item.type ?? graphic?.type); return b !== null && b.width === 0 && b.height === 0; }).length;
|
|
341
|
-
const bounds = items.map(item => itemBounds(item.properties, item.type ?? graphic?.type)).filter(Boolean);
|
|
342
|
-
const canvas = program.graphicSpec.objects.canvas?.properties;
|
|
343
|
-
const outside = Number.isFinite(canvas?.width) && Number.isFinite(canvas?.height)
|
|
344
|
-
? bounds.filter(bound => bound.x + bound.width < 0 || bound.y + bound.height < 0 ||
|
|
345
|
-
bound.x > canvas.width || bound.y > canvas.height).length
|
|
346
|
-
: null;
|
|
347
|
-
const union = bounds.length === 0 ? null : {
|
|
348
|
-
x: Math.min(...bounds.map(item => item.x)), y: Math.min(...bounds.map(item => item.y)),
|
|
349
|
-
width: Math.max(...bounds.map(item => item.x + item.width)) - Math.min(...bounds.map(item => item.x)),
|
|
350
|
-
height: Math.max(...bounds.map(item => item.y + item.height)) - Math.min(...bounds.map(item => item.y))
|
|
351
|
-
};
|
|
352
|
-
const grain = ["line", "area"].includes(layer.mark?.type) ? "series" : "item";
|
|
353
|
-
return {
|
|
354
|
-
owner: resourceRef("mark", layer.id, childPath), grain,
|
|
355
|
-
rawRows: dataset?.values?.length ?? null,
|
|
356
|
-
logicalDataItems: logicalSupported ? items.length : null,
|
|
357
|
-
drawablePrimitives: logicalSupported ? items.length : null,
|
|
358
|
-
visibleCandidates: geometrySupported ? Math.max(0, items.length - new Set([
|
|
359
|
-
...items.map((item, index) => item.properties.opacity === 0 ? index : -1),
|
|
360
|
-
...items.map((item, index) => { const b = itemBounds(item.properties, item.type ?? graphic?.type); return b !== null && b.width === 0 && b.height === 0 ? index : -1; }),
|
|
361
|
-
...(outside === null ? [] : items.map((item, index) => { const b = itemBounds(item.properties, item.type ?? graphic?.type); return b !== null && (b.x + b.width < 0 || b.y + b.height < 0 || b.x > canvas.width || b.y > canvas.height) ? index : -1; }))
|
|
362
|
-
].filter(index => index >= 0)).size) : null,
|
|
363
|
-
flags: [
|
|
364
|
-
{ reason: "opacity-zero", count: opacityZero },
|
|
365
|
-
{ reason: "zero-size", count: zeroSize },
|
|
366
|
-
{ reason: "outside-clip", count: outside },
|
|
367
|
-
{ reason: "missing-skipped", count: layer.mark?.missing === "skip" && dataset?.values
|
|
368
|
-
? Math.max(0, dataset.values.length - items.length) : null }
|
|
369
|
-
],
|
|
370
|
-
bounds: union,
|
|
371
|
-
sourceRefs: dataset === undefined ? [] : [resourceRef("data", dataset.id, childPath)],
|
|
372
|
-
checks: [
|
|
373
|
-
{ name: "concrete-structure", status: graphic === undefined ? "failed" : logicalSupported ? "passed" : "not_applicable", evidencePaths: [layer.id], findings: [] },
|
|
374
|
-
{ name: "pixel-visibility", status: "not_run", evidencePaths: [], findings: [] }
|
|
375
|
-
]
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function inspectGuide(program, id, childPath) {
|
|
380
|
-
const markIds = new Set(program.semanticSpec.layers.map(layer => layer.id));
|
|
381
|
-
const pattern = id === "axis" ? /axis/iu
|
|
382
|
-
: id === "grid" ? /grid/iu
|
|
383
|
-
: id === "legend" ? /legend/iu
|
|
384
|
-
: id === "title" ? /title|subtitle/iu
|
|
385
|
-
: new RegExp(id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "iu");
|
|
386
|
-
const graphicIds = Object.keys(program.graphicSpec.objects).filter(candidate =>
|
|
387
|
-
candidate !== "canvas" && !candidate.startsWith("plot-") &&
|
|
388
|
-
!markIds.has(candidate) && pattern.test(candidate)
|
|
389
|
-
);
|
|
390
|
-
const items = graphicIds.flatMap(candidate => {
|
|
391
|
-
const graphic = program.graphicSpec.objects[candidate];
|
|
392
|
-
if (Array.isArray(graphic?.items)) return graphic.items;
|
|
393
|
-
return graphic?.properties === undefined ? [] : [{ properties: graphic.properties }];
|
|
394
|
-
});
|
|
395
|
-
const semantic = id === "title"
|
|
396
|
-
? program.semanticSpec.title
|
|
397
|
-
: program.semanticSpec.guides[id];
|
|
398
|
-
const sourceRefs = [];
|
|
399
|
-
function collectRefs(value) {
|
|
400
|
-
if (!isPlainObject(value)) return;
|
|
401
|
-
if (typeof value.scale === "string") sourceRefs.push(resourceRef("scale", value.scale, childPath));
|
|
402
|
-
if (typeof value.coordinate === "string") sourceRefs.push(resourceRef("coordinate", value.coordinate, childPath));
|
|
403
|
-
for (const child of Object.values(value)) collectRefs(child);
|
|
404
|
-
}
|
|
405
|
-
collectRefs(semantic);
|
|
406
|
-
return {
|
|
407
|
-
owner: resourceRef("guide", id, childPath),
|
|
408
|
-
grain: "unknown",
|
|
409
|
-
rawRows: null,
|
|
410
|
-
logicalDataItems: items.length,
|
|
411
|
-
drawablePrimitives: items.length,
|
|
412
|
-
visibleCandidates: null,
|
|
413
|
-
flags: [
|
|
414
|
-
{ reason: "opacity-zero", count: null },
|
|
415
|
-
{ reason: "zero-size", count: null },
|
|
416
|
-
{ reason: "outside-clip", count: null },
|
|
417
|
-
{ reason: "missing-skipped", count: null }
|
|
418
|
-
],
|
|
419
|
-
bounds: null,
|
|
420
|
-
sourceRefs: [...new Map(sourceRefs.map(ref => [refKey(ref), ref])).values()],
|
|
421
|
-
checks: [
|
|
422
|
-
{ name: "concrete-structure", status: graphicIds.length > 0 ? "passed" : "not_applicable", evidencePaths: graphicIds, findings: [] },
|
|
423
|
-
{ name: "pixel-visibility", status: "not_run", evidencePaths: [], findings: [] }
|
|
424
|
-
]
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
export function inspectProgram(program, { target } = {}) {
|
|
429
|
-
requireProgram(program);
|
|
430
|
-
if (target !== undefined) validateTarget(target);
|
|
431
|
-
const views = [];
|
|
432
|
-
function visit(current, path = []) {
|
|
433
|
-
const visited = new Set();
|
|
434
|
-
const active = new Set();
|
|
435
|
-
function validateGraphic(id) {
|
|
436
|
-
if (active.has(id)) throw new Error(`Graphic hierarchy contains a cycle at "${id}".`);
|
|
437
|
-
if (visited.has(id)) throw new Error(`Graphic "${id}" is referenced more than once.`);
|
|
438
|
-
const object = current.graphicSpec.objects[id];
|
|
439
|
-
if (object === undefined) throw new Error(`Graphic hierarchy references missing object "${id}".`);
|
|
440
|
-
visited.add(id); active.add(id);
|
|
441
|
-
for (const child of object.children ?? []) validateGraphic(child);
|
|
442
|
-
active.delete(id);
|
|
443
|
-
}
|
|
444
|
-
for (const id of current.graphicSpec.order) validateGraphic(id);
|
|
445
|
-
for (const layer of current.semanticSpec.layers) views.push(inspectMark(current, layer, path));
|
|
446
|
-
for (const id of Object.keys(current.semanticSpec.guides)) {
|
|
447
|
-
views.push(inspectGuide(current, id, path));
|
|
448
|
-
}
|
|
449
|
-
if (Object.keys(current.semanticSpec.title).length > 0) {
|
|
450
|
-
views.push(inspectGuide(current, "title", path));
|
|
451
|
-
}
|
|
452
|
-
for (const [id, child] of Object.entries(current.children)) visit(child, [...path, id]);
|
|
453
|
-
}
|
|
454
|
-
visit(program);
|
|
455
|
-
let filtered = views;
|
|
456
|
-
if (target !== undefined) {
|
|
457
|
-
const current = atChildPath(program, target.childPath);
|
|
458
|
-
const targetResource = findResource(program, target);
|
|
459
|
-
if (targetResource === undefined) {
|
|
460
|
-
throw new Error(`Unknown ${target.kind} "${target.id}".`);
|
|
461
|
-
}
|
|
462
|
-
filtered = views.filter(view => {
|
|
463
|
-
if (canonical(view.owner.childPath ?? []) !== canonical(target.childPath ?? [])) return false;
|
|
464
|
-
if (target.kind === "mark") return view.owner.id === target.id;
|
|
465
|
-
const layer = findLayer(current, view.owner.id);
|
|
466
|
-
if (target.kind === "data") return layer?.data === targetResource.id;
|
|
467
|
-
if (target.kind === "coordinate") return layer?.coordinate === target.id;
|
|
468
|
-
if (target.kind === "scale") return Object.values(layer?.encoding ?? {}).some(
|
|
469
|
-
encoding => encoding?.scale === target.id || encoding?.dimensions?.some(dimension => dimension.scale === target.id)
|
|
470
|
-
);
|
|
471
|
-
if (target.kind === "guide") return view.owner.kind === "guide" && view.owner.id === target.id;
|
|
472
|
-
return false;
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
const calculations = [];
|
|
476
|
-
function collectCalculations(current, path = []) {
|
|
477
|
-
for (const family of Object.values(current.materializationConfigs.calculations ?? {})) {
|
|
478
|
-
if (!isPlainObject(family)) continue;
|
|
479
|
-
for (const report of Object.values(family)) {
|
|
480
|
-
calculations.push(path.length === 0 ? report : { ...report, childPath: path });
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
for (const [id, child] of Object.entries(current.children)) {
|
|
484
|
-
collectCalculations(child, [...path, id]);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
collectCalculations(program);
|
|
488
|
-
const unsupported = filtered.filter(view => view.logicalDataItems === null).map(view => view.owner);
|
|
489
|
-
return cloneAndFreeze({
|
|
490
|
-
version: 1, views: filtered,
|
|
491
|
-
calculations,
|
|
492
|
-
checks: [{ name: "pixel-visibility", status: "not_run", evidencePaths: [], findings: [] }],
|
|
493
|
-
findings: [], coverage: { partial: filtered.some(view => view.checks.some(check => check.status !== "passed")), unsupported }
|
|
494
|
-
});
|
|
495
|
-
}
|
|
1
|
+
import{resolveGraphicClipBounds as B,resolveGraphicParentOffset as W}from"./grammar/schemas/graphicBounds.js";import{resolveFacetDefinition as K,resolveFacetGridDefinition as L}from"./grammar/facets/index.js";import{APPEARANCE_MARK_TYPES as V}from"./core/vocabulary.js";import{ChartProgram as E}from"./ChartProgram.js";import{BasicChartProgram as C}from"./BasicChartProgram.js";import{getWrappedActionMetadata as J}from"./core/action.js";import{cloneAndFreeze as b,isOwned as _,isPlainObject as S}from"./core/immutable.js";import{encodeValue as Y}from"./persistence/codec.js";import{findDataset as z,hasDatasetOwner as Z,resolveDatasetReference as F}from"./selectors/datasets.js";import{findLayer as G}from"./selectors/layers.js";import{findSemanticScale as H}from"./selectors/scales.js";import{findCoordinate as Q}from"./selectors/coordinates.js";import{inferDatasetSchema as X}from"./grammar/datasetSchema.js";import{BUILTIN_ACTION_DESCRIPTOR_RECORDS as ee}from"./inspectionDescriptors.js";const ne=new Set(["data","mark","scale","coordinate","guide"]),ie=new Map(ee.map(([e,n,i,t,c])=>[e,{options:n.map(([m,l,k,d,a])=>({path:m,required:l,kind:k,...d===null?{}:{choices:d},...a===null?{}:{unit:a}})),idOptions:i,prerequisites:t,entryPoints:c}]));function P(e,n="Program"){if(!(e instanceof E||e instanceof C))throw new TypeError(`${n} must be a ggaction program.`);if(e.actionStack.length!==0)throw new Error(`${n} must have a closed action stack.`);return e}function $(e,n=[]){if(!Array.isArray(n))throw new TypeError("childPath must be an array.");let i=e;for(const t of n){if(typeof t!="string"||!Object.hasOwn(i.children,t))throw new Error(`Unknown program child "${String(t)}".`);i=i.children[t]}return i}function R(e){if(!S(e)||!ne.has(e.kind)||typeof e.id!="string"||e.id.length===0)throw new TypeError("Inspection target requires a supported kind and non-empty id.");return e}function I(e,n){const i=$(e,n.childPath);return n.kind==="data"?Z(i,n.id)?F(i,n.id,"Inspection target"):z(i,n.id):n.kind==="mark"?G(i,n.id):n.kind==="scale"?H(i,n.id):n.kind==="coordinate"?Q(i,n.id):i.semanticSpec.guides[n.id]}function g(e,n,i){return{kind:e,id:n,...i?.length?{childPath:[...i]}:{}}}function te(e,{data:n,childPath:i}={}){P(e);const t=$(e,i);if(typeof n!="string"||n.length===0)throw new TypeError("getDatasetSchema requires data.");const c=F(t,n,"Dataset schema data"),m=c.schema??X(c.values??[]);return b({data:c.id,schema:m})}function be(e,{action:n,target:i,options:t={}}={}){if(P(e),typeof n!="string"||n.length===0)throw new TypeError("describeAction requires action.");if(!S(t))throw new TypeError("describeAction options must be a plain object.");let c;if(i!==void 0){if(R(i),c=I(e,i),c===void 0)return b({version:1,action:n,applicability:"incompatible",parameterDefinitions:[],requirements:[],checks:[{name:"target",status:"failed",evidencePaths:[],findings:[]}],findings:[{severity:"error",code:"missing-resource",reason:"target-unavailable",message:`Unknown ${i.kind} "${i.id}".`,resource:g(i.kind,i.id,i.childPath)}]});if(t.target!==void 0&&t.target!==i.id)return b({version:1,action:n,applicability:"incompatible",parameterDefinitions:[],requirements:[],checks:[{name:"target",status:"failed",evidencePaths:["target"],findings:[]}],findings:[{severity:"error",code:"incompatible-resource",reason:"target-mismatch",message:`Inspection target "${i.id}" conflicts with options.target "${t.target}".`,resource:g(i.kind,i.id,i.childPath),optionPath:"target"}]});const f=V[n];if(f&&(i.kind!=="mark"||!f.includes(c.mark?.type)))return b({version:1,action:n,applicability:"unsupported",parameterDefinitions:[],requirements:[],checks:[{name:"target",status:"not_applicable",evidencePaths:["target"],findings:[]}],findings:[{severity:"info",code:"unsupported-combination",reason:"mark-type",message:`${n} supports ${f.join(", ")} marks.`,resource:g(i.kind,i.id,i.childPath)}]})}const m=e[n],l=typeof m=="function"?J(m):void 0;if(l===void 0)return b({version:1,action:n,applicability:typeof m=="function"?"unverified":"unsupported",parameterDefinitions:[],requirements:[],checks:[],findings:[{severity:"info",code:"unsupported-format",reason:typeof m=="function"?"extension-unverified":"action-unavailable",message:`Action "${n}" has no built-in inspection descriptor.`}]});const k=ie.get(n),d=l.options??k?.options.map(f=>f.path);if(d===void 0)return b({version:1,action:n,applicability:"unverified",parameterDefinitions:[],requirements:[],checks:[{name:"execution",status:"not_run",evidencePaths:[],findings:[]}],findings:[{severity:"info",code:"unsupported-format",reason:"descriptor-unavailable",message:`Action "${n}" is registered but its static option descriptor is unavailable.`}]});const a=Object.keys(t).find(f=>!d.includes(f)),o=(k?.options.filter(f=>f.required).map(f=>f.path)??[]).filter(f=>t[f]===void 0);let p=[];if(c!==void 0&&i.kind==="mark"){const f=$(e,i.childPath),O=n.startsWith("edit")&&n.endsWith("Plot")?Object.entries(f.markConfigs[i.id]??{}).find(([r])=>r.toLowerCase()===n.slice(4).toLowerCase())?.[1]:void 0,x=O?.source===void 0?c.data:t.data??O.source,y=te(e,{data:x,childPath:i.childPath}).schema;if(y.completeness==="known"){const r=new Set(y.fields.map(v=>v.name));p=(k?.options??[]).filter(v=>v.kind==="field"&&typeof t[v.path]=="string"&&!r.has(t[v.path])).map(v=>({severity:"error",code:"missing-resource",reason:"field-unavailable",message:`Dataset does not contain field "${t[v.path]}".`,resource:g("data",x,i.childPath),optionPath:v.path}))}}if(a===void 0&&o.length===0&&(n==="facet"&&t.field||n==="facetGrid"&&t.rows&&t.columns))try{(n==="facet"?K:L)(e.semanticSpec,t)}catch(f){p.push({severity:"error",code:"unsupported-combination",reason:"facet-partition",message:f.message,optionPath:"data"})}const u=a!==void 0?[{severity:"error",code:"invalid-option",reason:"unknown-option",message:`Unknown ${n} option "${a}".`,optionPath:a}]:[...o.map(f=>({severity:"info",code:"missing-input",reason:"required-option",message:`${n} requires option "${f}".`,optionPath:f})),...p],h=a!==void 0||p.length?"incompatible":o.length?"needs-input":"supported";return b({version:1,action:n,applicability:h,parameterDefinitions:k?.options.map(f=>({...f,active:!0}))??d.map(f=>({path:f,kind:"object",required:!1,active:!0})),requirements:o.map(f=>({reason:"required-option",optionPath:f})),checks:[{name:"option-shape",status:a===void 0?"passed":"failed",evidencePaths:Object.keys(t),findings:a===void 0?[]:u},{name:"execution",status:"not_run",evidencePaths:[],findings:[]}],findings:u})}function T(e){return Array.isArray(e)?e.map(T):S(e)?Object.fromEntries(Object.keys(e).sort().map(n=>[n,T(e[n])])):e}function j(e){return JSON.stringify(Y(T(e)))}const D=new WeakMap;function M(e,n){if(Object.is(e,n))return!0;if(e===null||n===null||typeof e!="object"||typeof n!="object"||Array.isArray(e)!==Array.isArray(n))return!1;if(!Array.isArray(e)&&(!S(e)||!S(n)))return j(e)===j(n);const i=_(e)&&_(n),t=i?D.get(e)?.get(n):void 0;if(t!==void 0)return t;const c=Object.keys(e),m=(!Array.isArray(e)||e.length===n.length)&&c.length===Object.keys(n).length&&c.every(l=>Object.hasOwn(n,l)&&M(e[l],n[l]));return i&&(D.has(e)||D.set(e,new WeakMap),D.get(e).set(n,m)),m}function N(e,n=[],i=[]){for(const t of e.semanticSpec.datasets)i.push({ref:g("data",t.id,n),value:t});for(const[t,c]of e.semanticSpec.layers.entries())i.push({ref:g("mark",c.id,n),value:{semantic:c,graphic:e.graphicSpec.objects[c.id],config:e.markConfigs[c.id],orderIndex:t}});for(const t of e.semanticSpec.scales)i.push({ref:g("scale",t.id,n),value:{semantic:t,resolved:e.resolvedScales[t.id]}});for(const t of e.semanticSpec.coordinates)i.push({ref:g("coordinate",t.id,n),value:t});for(const[t,c]of Object.entries(e.semanticSpec.guides))i.push({ref:g("guide",t,n),value:{semantic:c,graphic:e.graphicSpec.objects[t],config:e.guideConfigs[t]}});Object.keys(e.semanticSpec.title).length&&i.push({ref:g("guide","title",n),value:{semantic:e.semanticSpec.title,config:e.titleConfig}}),e.graphicSpec.objects.canvas!==void 0&&i.push({ref:g("canvas","canvas",n),value:e.graphicSpec.objects.canvas}),Object.keys(e.compositionSpec??{}).length>0&&i.push({ref:g("composition","layout",n),value:e.compositionSpec});for(const[t,c]of Object.entries(e.children))N(c,[...n,t],i);return i}function A(e){return`${e.childPath?.join("/")??""}|${e.kind}|${e.id}`}function se(e){return e==="data"?"data":e==="scale"?"scale":e==="guide"?"guide":["coordinate","canvas","composition"].includes(e)?"structure":"style"}function re(e,n,i){return i!=="mark"||e===void 0||n===void 0?se(i):e.value.orderIndex!==n.value.orderIndex?"structure":!M(e.value.semantic?.encoding,n.value.semantic?.encoding)||e.value.semantic?.data!==n.value.semantic?.data?"binding":M(e.value.semantic,n.value.semantic)?"style":"structure"}function Se(e,n,{target:i}={}){P(e,"Before program"),P(n,"After program"),i!==void 0&&R(i);const t=new Map(N(e).map(a=>[A(a.ref),a])),c=new Map(N(n).map(a=>[A(a.ref),a]));let l=[...new Set([...t.keys(),...c.keys()])].sort().flatMap(a=>{const s=t.get(a),o=c.get(a),p=s??o;if(s!==void 0&&o!==void 0&&M(s.value,o.value))return[];const u=p.ref.kind==="mark"&&s!==void 0&&o!==void 0?[...new Set([...Object.keys(s.value.semantic?.encoding??{}),...Object.keys(o.value.semantic?.encoding??{})])].filter(h=>!M(s.value.semantic?.encoding?.[h],o.value.semantic?.encoding?.[h])):[];return[{resource:p.ref,operation:s===void 0?"add":o===void 0?"remove":"modify",effect:re(s,o,p.ref.kind),roles:u}]});if(i!==void 0){const a=[e,n].flatMap(o=>{const p=I(o,i);return p===void 0?[]:[A(g(i.kind,i.kind==="data"?p.id:i.id,i.childPath))]});if(a.length===0)throw new Error(`Unknown ${i.kind} "${i.id}" in both programs.`);const s=new Set(a);for(const o of[t,c]){let p=!0;for(;p;){p=!1;for(const[u,h]of o){if(s.has(u))continue;const f=j(h.ref.childPath??[]);[...s].some(x=>{const y=o.get(x);return y===void 0||j(y.ref.childPath??[])!==f?!1:y.ref.kind==="data"?h.ref.kind==="data"?h.value.source===y.ref.id:h.ref.kind==="mark"&&h.value.semantic?.data===y.ref.id:y.ref.kind==="mark"?h.ref.kind==="mark"&&h.value.semantic?.source===y.ref.id||h.ref.kind==="guide"&&(h.value.semantic?.target===y.ref.id||h.value.config?.target===y.ref.id):y.ref.kind==="scale"?h.ref.kind==="mark"&&Object.values(h.value.semantic?.encoding??{}).some(r=>r?.scale===y.ref.id||r?.dimensions?.some(v=>v.scale===y.ref.id))||h.ref.kind==="guide"&&(h.value.semantic?.scale===y.ref.id||h.value.config?.scale===y.ref.id):y.ref.kind==="coordinate"&&h.ref.kind==="mark"&&h.value.semantic?.coordinate===y.ref.id})&&(s.add(u),p=!0)}}}l=l.filter(o=>s.has(A(o.resource)))}const k=![E,C].includes(e.constructor)||![E,C].includes(n.constructor),d=k?[{severity:"info",code:"unsupported-format",reason:"extension-unverified",message:"Extension-owned semantic equivalence could not be fully verified."}]:[];return b({version:1,equivalence:l.length?"different":k?"unknown":"equal",completeProgramComparison:i===void 0,changes:l,affected:l.map(a=>a.resource),findings:d})}function q(e,n){if(!S(e))return null;if(n==="circle")return!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.radius)||e.radius<0?null:{x:e.x-e.radius,y:e.y-e.radius,width:e.radius*2,height:e.radius*2};if(n==="rect")return[e.x,e.y,e.width,e.height].every(Number.isFinite)?{x:Math.min(e.x,e.x+e.width),y:Math.min(e.y,e.y+e.height),width:Math.abs(e.width),height:Math.abs(e.height)}:null;if(n==="path"&&Array.isArray(e.commands)){const i=e.commands.flatMap(m=>Number.isFinite(m.x)&&Number.isFinite(m.y)?[[m.x,m.y]]:[]);if(i.length===0)return null;const t=i.map(m=>m[0]),c=i.map(m=>m[1]);return{x:Math.min(...t),y:Math.min(...c),width:Math.max(...t)-Math.min(...t),height:Math.max(...c)-Math.min(...c)}}return[e.x1,e.y1,e.x2,e.y2].every(Number.isFinite)?{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)}:null}function ce(e,n,i){const t=e.graphicSpec.objects[n.id],c=z(e,n.data),m=new Set(["circle","rect","line","path"]),l=t?.items??(t?.properties?[{properties:t.properties}]:[]),k=l.map(r=>r.type??t?.type),d=t!==void 0&&k.every(r=>m.has(r)||r==="text"),a=d&&k.every(r=>m.has(r)),s=l.filter(r=>r.properties.opacity===0).length,o=l.filter(r=>{const v=q(r.properties,r.type??t?.type);return v!==null&&v.width===0&&v.height===0}).length,p=l.map(r=>q(r.properties,r.type??t?.type)).filter(Boolean),u=t===void 0?void 0:B(e.graphicSpec,n.id,{rootViewport:!0}),h=t===void 0?[0,0]:W(e.graphicSpec,n.id),f=u===void 0?null:l.flatMap((r,v)=>{const w=q(r.properties,r.type??t.type);return w!==null&&(u.right<=u.left||u.bottom<=u.top||w.x+h[0]+w.width<u.left||w.y+h[1]+w.height<u.top||w.x+h[0]>u.right||w.y+h[1]>u.bottom)?[v]:[]}),O=f?.length??null,x=p.length===0?null:{x:Math.min(...p.map(r=>r.x)),y:Math.min(...p.map(r=>r.y)),width:Math.max(...p.map(r=>r.x+r.width))-Math.min(...p.map(r=>r.x)),height:Math.max(...p.map(r=>r.y+r.height))-Math.min(...p.map(r=>r.y))},y=["line","area"].includes(n.mark?.type)?"series":"item";return{owner:g("mark",n.id,i),grain:y,rawRows:c?.values?.length??null,logicalDataItems:d?l.length:null,drawablePrimitives:d?l.length:null,visibleCandidates:a?Math.max(0,l.length-new Set([...l.map((r,v)=>r.properties.opacity===0?v:-1),...l.map((r,v)=>{const w=q(r.properties,r.type??t?.type);return w!==null&&w.width===0&&w.height===0?v:-1}),...f??[]].filter(r=>r>=0)).size):null,flags:[{reason:"opacity-zero",count:s},{reason:"zero-size",count:o},{reason:"outside-clip",count:O},{reason:"missing-skipped",count:n.mark?.missing==="skip"&&c?.values?Math.max(0,c.values.length-l.length):null}],bounds:x,sourceRefs:c===void 0?[]:[g("data",c.id,i)],checks:[{name:"concrete-structure",status:t===void 0&&!e.compositionSpec?.facet?"failed":d?"passed":"not_applicable",evidencePaths:[n.id],findings:[]},{name:"pixel-visibility",status:"not_run",evidencePaths:[],findings:[]}]}}function U(e,n,i){const t=new Set(e.semanticSpec.layers.map(s=>s.id)),c=n==="axis"?/axis/iu:n==="grid"?/grid/iu:n==="legend"?/legend/iu:n==="title"?/title|subtitle/iu:new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"iu"),m=Object.keys(e.graphicSpec.objects).filter(s=>s!=="canvas"&&!s.startsWith("plot-")&&!t.has(s)&&c.test(s)),l=m.flatMap(s=>{const o=e.graphicSpec.objects[s];return Array.isArray(o?.items)?o.items:o?.properties===void 0?[]:[{properties:o.properties}]}),k=n==="title"?e.semanticSpec.title:e.semanticSpec.guides[n],d=[];function a(s){if(S(s)){typeof s.scale=="string"&&d.push(g("scale",s.scale,i)),typeof s.coordinate=="string"&&d.push(g("coordinate",s.coordinate,i));for(const o of Object.values(s))a(o)}}return a(k),{owner:g("guide",n,i),grain:"unknown",rawRows:null,logicalDataItems:l.length,drawablePrimitives:l.length,visibleCandidates:null,flags:[{reason:"opacity-zero",count:null},{reason:"zero-size",count:null},{reason:"outside-clip",count:null},{reason:"missing-skipped",count:null}],bounds:null,sourceRefs:[...new Map(d.map(s=>[A(s),s])).values()],checks:[{name:"concrete-structure",status:m.length>0?"passed":"not_applicable",evidencePaths:m,findings:[]},{name:"pixel-visibility",status:"not_run",evidencePaths:[],findings:[]}]}}function xe(e,{target:n}={}){P(e),n!==void 0&&R(n);const i=[];function t(d,a=[]){const s=new Set,o=new Set;function p(u){if(o.has(u))throw new Error(`Graphic hierarchy contains a cycle at "${u}".`);if(s.has(u))throw new Error(`Graphic "${u}" is referenced more than once.`);const h=d.graphicSpec.objects[u];if(h===void 0)throw new Error(`Graphic hierarchy references missing object "${u}".`);s.add(u),o.add(u);for(const f of h.children??[])p(f);o.delete(u)}for(const u of d.graphicSpec.order)p(u);for(const u of d.semanticSpec.layers)i.push(ce(d,u,a));for(const u of Object.keys(d.semanticSpec.guides))i.push(U(d,u,a));Object.keys(d.semanticSpec.title).length>0&&i.push(U(d,"title",a));for(const[u,h]of Object.entries(d.children))t(h,[...a,u])}t(e);let c=i;if(n!==void 0){const d=$(e,n.childPath),a=I(e,n);if(a===void 0)throw new Error(`Unknown ${n.kind} "${n.id}".`);c=i.filter(s=>{if(j(s.owner.childPath??[])!==j(n.childPath??[]))return!1;if(n.kind==="mark")return s.owner.id===n.id;const o=G(d,s.owner.id);return n.kind==="data"?o?.data===a.id:n.kind==="coordinate"?o?.coordinate===n.id:n.kind==="scale"?Object.values(o?.encoding??{}).some(p=>p?.scale===n.id||p?.dimensions?.some(u=>u.scale===n.id)):n.kind==="guide"?s.owner.kind==="guide"&&s.owner.id===n.id:!1})}const m=[];function l(d,a=[]){for(const s of Object.values(d.materializationConfigs.calculations??{}))if(S(s))for(const o of Object.values(s))m.push(a.length===0?o:{...o,childPath:a});for(const[s,o]of Object.entries(d.children))l(o,[...a,s])}l(e);const k=c.filter(d=>d.logicalDataItems===null).map(d=>d.owner);return b({version:1,views:c,calculations:m,checks:[{name:"pixel-visibility",status:"not_run",evidencePaths:[],findings:[]}],findings:[],coverage:{partial:c.some(d=>d.checks.some(a=>a.status!=="passed")),unsupported:k}})}export{Se as comparePrograms,be as describeAction,te as getDatasetSchema,xe as inspectProgram};
|