@ggts-sh/spec 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/dist/artifact.d.ts +11 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +71 -0
- package/dist/artifact.js.map +1 -0
- package/dist/builder-core.d.ts +100 -0
- package/dist/builder-core.d.ts.map +1 -0
- package/dist/builder-core.js +176 -0
- package/dist/builder-core.js.map +1 -0
- package/dist/builder-data.d.ts +36 -0
- package/dist/builder-data.d.ts.map +1 -0
- package/dist/builder-data.js +123 -0
- package/dist/builder-data.js.map +1 -0
- package/dist/builder-geoms.d.ts +128 -0
- package/dist/builder-geoms.d.ts.map +1 -0
- package/dist/builder-geoms.js +221 -0
- package/dist/builder-geoms.js.map +1 -0
- package/dist/builder-options.d.ts +323 -0
- package/dist/builder-options.d.ts.map +1 -0
- package/dist/builder-options.js +2 -0
- package/dist/builder-options.js.map +1 -0
- package/dist/builder-scales.d.ts +160 -0
- package/dist/builder-scales.d.ts.map +1 -0
- package/dist/builder-scales.js +322 -0
- package/dist/builder-scales.js.map +1 -0
- package/dist/builder.d.ts +242 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +42 -0
- package/dist/builder.js.map +1 -0
- package/dist/capabilities-data.d.ts +72 -0
- package/dist/capabilities-data.d.ts.map +1 -0
- package/dist/capabilities-data.js +337 -0
- package/dist/capabilities-data.js.map +1 -0
- package/dist/capabilities-helpers.d.ts +31 -0
- package/dist/capabilities-helpers.d.ts.map +1 -0
- package/dist/capabilities-helpers.js +41 -0
- package/dist/capabilities-helpers.js.map +1 -0
- package/dist/capabilities.d.ts +22 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +154 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/coord-helpers.d.ts +102 -0
- package/dist/coord-helpers.d.ts.map +1 -0
- package/dist/coord-helpers.js +90 -0
- package/dist/coord-helpers.js.map +1 -0
- package/dist/coord-reference-build.d.ts +50 -0
- package/dist/coord-reference-build.d.ts.map +1 -0
- package/dist/coord-reference-build.js +211 -0
- package/dist/coord-reference-build.js.map +1 -0
- package/dist/coord-reference.d.ts +52 -0
- package/dist/coord-reference.d.ts.map +1 -0
- package/dist/coord-reference.js +27 -0
- package/dist/coord-reference.js.map +1 -0
- package/dist/error-catalog.d.ts +258 -0
- package/dist/error-catalog.d.ts.map +1 -0
- package/dist/error-catalog.js +235 -0
- package/dist/error-catalog.js.map +1 -0
- package/dist/error-prose-shared.d.ts +100 -0
- package/dist/error-prose-shared.d.ts.map +1 -0
- package/dist/error-prose-shared.js +95 -0
- package/dist/error-prose-shared.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/coord-reference-data.d.ts +189 -0
- package/dist/generated/coord-reference-data.d.ts.map +1 -0
- package/dist/generated/coord-reference-data.js +212 -0
- package/dist/generated/coord-reference-data.js.map +1 -0
- package/dist/generated/geom-param-keys.d.ts +58 -0
- package/dist/generated/geom-param-keys.d.ts.map +1 -0
- package/dist/generated/geom-param-keys.js +223 -0
- package/dist/generated/geom-param-keys.js.map +1 -0
- package/dist/generated/geom-reference-data.d.ts +2377 -0
- package/dist/generated/geom-reference-data.d.ts.map +1 -0
- package/dist/generated/geom-reference-data.js +2790 -0
- package/dist/generated/geom-reference-data.js.map +1 -0
- package/dist/generated/guide-reference-data.d.ts +219 -0
- package/dist/generated/guide-reference-data.d.ts.map +1 -0
- package/dist/generated/guide-reference-data.js +253 -0
- package/dist/generated/guide-reference-data.js.map +1 -0
- package/dist/generated/plot-spec-validator.d.ts +2 -0
- package/dist/generated/plot-spec-validator.d.ts.map +1 -0
- package/dist/generated/plot-spec-validator.js +6274 -0
- package/dist/generated/plot-spec-validator.js.map +1 -0
- package/dist/generated/position-reference-data.d.ts +82 -0
- package/dist/generated/position-reference-data.d.ts.map +1 -0
- package/dist/generated/position-reference-data.js +181 -0
- package/dist/generated/position-reference-data.js.map +1 -0
- package/dist/generated/scale-reference-data.d.ts +8366 -0
- package/dist/generated/scale-reference-data.d.ts.map +1 -0
- package/dist/generated/scale-reference-data.js +9821 -0
- package/dist/generated/scale-reference-data.js.map +1 -0
- package/dist/generated/stat-reference-data.d.ts +241 -0
- package/dist/generated/stat-reference-data.d.ts.map +1 -0
- package/dist/generated/stat-reference-data.js +311 -0
- package/dist/generated/stat-reference-data.js.map +1 -0
- package/dist/geom-params-build.d.ts +3 -0
- package/dist/geom-params-build.d.ts.map +1 -0
- package/dist/geom-params-build.js +80 -0
- package/dist/geom-params-build.js.map +1 -0
- package/dist/geom-params.d.ts +13 -0
- package/dist/geom-params.d.ts.map +1 -0
- package/dist/geom-params.js +7 -0
- package/dist/geom-params.js.map +1 -0
- package/dist/geom-reference-build.d.ts +29 -0
- package/dist/geom-reference-build.d.ts.map +1 -0
- package/dist/geom-reference-build.js +221 -0
- package/dist/geom-reference-build.js.map +1 -0
- package/dist/geom-reference.d.ts +52 -0
- package/dist/geom-reference.d.ts.map +1 -0
- package/dist/geom-reference.js +72 -0
- package/dist/geom-reference.js.map +1 -0
- package/dist/guide-helpers.d.ts +20 -0
- package/dist/guide-helpers.d.ts.map +1 -0
- package/dist/guide-helpers.js +25 -0
- package/dist/guide-helpers.js.map +1 -0
- package/dist/guide-reference-build.d.ts +42 -0
- package/dist/guide-reference-build.d.ts.map +1 -0
- package/dist/guide-reference-build.js +180 -0
- package/dist/guide-reference-build.js.map +1 -0
- package/dist/guide-reference.d.ts +48 -0
- package/dist/guide-reference.d.ts.map +1 -0
- package/dist/guide-reference.js +32 -0
- package/dist/guide-reference.js.map +1 -0
- package/dist/hue-grey-palettes.d.ts +15 -0
- package/dist/hue-grey-palettes.d.ts.map +1 -0
- package/dist/hue-grey-palettes.js +77 -0
- package/dist/hue-grey-palettes.js.map +1 -0
- package/dist/index.d.ts +364 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +225 -0
- package/dist/index.js.map +1 -0
- package/dist/lint-catalog.d.ts +47 -0
- package/dist/lint-catalog.d.ts.map +1 -0
- package/dist/lint-catalog.js +39 -0
- package/dist/lint-catalog.js.map +1 -0
- package/dist/lint-layer-rules.d.ts +18 -0
- package/dist/lint-layer-rules.d.ts.map +1 -0
- package/dist/lint-layer-rules.js +145 -0
- package/dist/lint-layer-rules.js.map +1 -0
- package/dist/lint-scale-rules.d.ts +8 -0
- package/dist/lint-scale-rules.d.ts.map +1 -0
- package/dist/lint-scale-rules.js +254 -0
- package/dist/lint-scale-rules.js.map +1 -0
- package/dist/lint.d.ts +62 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +57 -0
- package/dist/lint.js.map +1 -0
- package/dist/normalize-coord.d.ts +8 -0
- package/dist/normalize-coord.d.ts.map +1 -0
- package/dist/normalize-coord.js +123 -0
- package/dist/normalize-coord.js.map +1 -0
- package/dist/normalize-input-layers-marks.d.ts +208 -0
- package/dist/normalize-input-layers-marks.d.ts.map +1 -0
- package/dist/normalize-input-layers-marks.js +2 -0
- package/dist/normalize-input-layers-marks.js.map +1 -0
- package/dist/normalize-input-layers-special.d.ts +131 -0
- package/dist/normalize-input-layers-special.d.ts.map +1 -0
- package/dist/normalize-input-layers-special.js +2 -0
- package/dist/normalize-input-layers-special.js.map +1 -0
- package/dist/normalize-input.d.ts +81 -0
- package/dist/normalize-input.d.ts.map +1 -0
- package/dist/normalize-input.js +2 -0
- package/dist/normalize-input.js.map +1 -0
- package/dist/normalize-paint.d.ts +8 -0
- package/dist/normalize-paint.d.ts.map +1 -0
- package/dist/normalize-paint.js +83 -0
- package/dist/normalize-paint.js.map +1 -0
- package/dist/normalize-scales.d.ts +7 -0
- package/dist/normalize-scales.d.ts.map +1 -0
- package/dist/normalize-scales.js +90 -0
- package/dist/normalize-scales.js.map +1 -0
- package/dist/normalize.d.ts +46 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +279 -0
- package/dist/normalize.js.map +1 -0
- package/dist/paint-helpers.d.ts +45 -0
- package/dist/paint-helpers.d.ts.map +1 -0
- package/dist/paint-helpers.js +48 -0
- package/dist/paint-helpers.js.map +1 -0
- package/dist/pipeline-error-catalog.d.ts +319 -0
- package/dist/pipeline-error-catalog.d.ts.map +1 -0
- package/dist/pipeline-error-catalog.js +260 -0
- package/dist/pipeline-error-catalog.js.map +1 -0
- package/dist/portability-check.d.ts +35 -0
- package/dist/portability-check.d.ts.map +1 -0
- package/dist/portability-check.js +121 -0
- package/dist/portability-check.js.map +1 -0
- package/dist/portability-lossy.d.ts +19 -0
- package/dist/portability-lossy.d.ts.map +1 -0
- package/dist/portability-lossy.js +65 -0
- package/dist/portability-lossy.js.map +1 -0
- package/dist/portability.d.ts +23 -0
- package/dist/portability.d.ts.map +1 -0
- package/dist/portability.js +23 -0
- package/dist/portability.js.map +1 -0
- package/dist/portable-builder.d.ts +215 -0
- package/dist/portable-builder.d.ts.map +1 -0
- package/dist/portable-builder.js +27 -0
- package/dist/portable-builder.js.map +1 -0
- package/dist/portable-entry.d.ts +16 -0
- package/dist/portable-entry.d.ts.map +1 -0
- package/dist/portable-entry.js +14 -0
- package/dist/portable-entry.js.map +1 -0
- package/dist/position-reference-build.d.ts +29 -0
- package/dist/position-reference-build.d.ts.map +1 -0
- package/dist/position-reference-build.js +115 -0
- package/dist/position-reference-build.js.map +1 -0
- package/dist/position-reference.d.ts +34 -0
- package/dist/position-reference.d.ts.map +1 -0
- package/dist/position-reference.js +19 -0
- package/dist/position-reference.js.map +1 -0
- package/dist/runtime.d.ts +139 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scale-color-helpers.d.ts +121 -0
- package/dist/scale-color-helpers.d.ts.map +1 -0
- package/dist/scale-color-helpers.js +188 -0
- package/dist/scale-color-helpers.js.map +1 -0
- package/dist/scale-color-hue-grey.d.ts +52 -0
- package/dist/scale-color-hue-grey.d.ts.map +1 -0
- package/dist/scale-color-hue-grey.js +60 -0
- package/dist/scale-color-hue-grey.js.map +1 -0
- package/dist/scale-color-stops.d.ts +85 -0
- package/dist/scale-color-stops.d.ts.map +1 -0
- package/dist/scale-color-stops.js +87 -0
- package/dist/scale-color-stops.js.map +1 -0
- package/dist/scale-color-viridis.d.ts +52 -0
- package/dist/scale-color-viridis.d.ts.map +1 -0
- package/dist/scale-color-viridis.js +68 -0
- package/dist/scale-color-viridis.js.map +1 -0
- package/dist/scale-helpers.d.ts +20 -0
- package/dist/scale-helpers.d.ts.map +1 -0
- package/dist/scale-helpers.js +20 -0
- package/dist/scale-helpers.js.map +1 -0
- package/dist/scale-multi-helpers.d.ts +61 -0
- package/dist/scale-multi-helpers.d.ts.map +1 -0
- package/dist/scale-multi-helpers.js +147 -0
- package/dist/scale-multi-helpers.js.map +1 -0
- package/dist/scale-position-helpers.d.ts +81 -0
- package/dist/scale-position-helpers.d.ts.map +1 -0
- package/dist/scale-position-helpers.js +133 -0
- package/dist/scale-position-helpers.js.map +1 -0
- package/dist/scale-reference-build.d.ts +50 -0
- package/dist/scale-reference-build.d.ts.map +1 -0
- package/dist/scale-reference-build.js +147 -0
- package/dist/scale-reference-build.js.map +1 -0
- package/dist/scale-reference-classify-color.d.ts +11 -0
- package/dist/scale-reference-classify-color.d.ts.map +1 -0
- package/dist/scale-reference-classify-color.js +292 -0
- package/dist/scale-reference-classify-color.js.map +1 -0
- package/dist/scale-reference-classify-position.d.ts +10 -0
- package/dist/scale-reference-classify-position.d.ts.map +1 -0
- package/dist/scale-reference-classify-position.js +137 -0
- package/dist/scale-reference-classify-position.js.map +1 -0
- package/dist/scale-reference-classify-style.d.ts +10 -0
- package/dist/scale-reference-classify-style.d.ts.map +1 -0
- package/dist/scale-reference-classify-style.js +194 -0
- package/dist/scale-reference-classify-style.js.map +1 -0
- package/dist/scale-reference-classify-support.d.ts +37 -0
- package/dist/scale-reference-classify-support.d.ts.map +1 -0
- package/dist/scale-reference-classify-support.js +206 -0
- package/dist/scale-reference-classify-support.js.map +1 -0
- package/dist/scale-reference.d.ts +80 -0
- package/dist/scale-reference.d.ts.map +1 -0
- package/dist/scale-reference.js +85 -0
- package/dist/scale-reference.js.map +1 -0
- package/dist/scale-style-helpers.d.ts +158 -0
- package/dist/scale-style-helpers.d.ts.map +1 -0
- package/dist/scale-style-helpers.js +197 -0
- package/dist/scale-style-helpers.js.map +1 -0
- package/dist/schema-catalog.d.ts +62 -0
- package/dist/schema-catalog.d.ts.map +1 -0
- package/dist/schema-catalog.js +208 -0
- package/dist/schema-catalog.js.map +1 -0
- package/dist/schema-declarations.d.ts +1585 -0
- package/dist/schema-declarations.d.ts.map +1 -0
- package/dist/schema-declarations.js +51 -0
- package/dist/schema-declarations.js.map +1 -0
- package/dist/schema-decls-data.d.ts +58 -0
- package/dist/schema-decls-data.d.ts.map +1 -0
- package/dist/schema-decls-data.js +151 -0
- package/dist/schema-decls-data.js.map +1 -0
- package/dist/schema-decls-guides-theme.d.ts +166 -0
- package/dist/schema-decls-guides-theme.d.ts.map +1 -0
- package/dist/schema-decls-guides-theme.js +251 -0
- package/dist/schema-decls-guides-theme.js.map +1 -0
- package/dist/schema-decls-layers-col-boxplot.d.ts +118 -0
- package/dist/schema-decls-layers-col-boxplot.d.ts.map +1 -0
- package/dist/schema-decls-layers-col-boxplot.js +239 -0
- package/dist/schema-decls-layers-col-boxplot.js.map +1 -0
- package/dist/schema-decls-layers-count-pointrange.d.ts +89 -0
- package/dist/schema-decls-layers-count-pointrange.d.ts.map +1 -0
- package/dist/schema-decls-layers-count-pointrange.js +190 -0
- package/dist/schema-decls-layers-count-pointrange.js.map +1 -0
- package/dist/schema-decls-layers-crossbar-jitter.d.ts +129 -0
- package/dist/schema-decls-layers-crossbar-jitter.d.ts.map +1 -0
- package/dist/schema-decls-layers-crossbar-jitter.js +255 -0
- package/dist/schema-decls-layers-crossbar-jitter.js.map +1 -0
- package/dist/schema-decls-layers-point-path.d.ts +49 -0
- package/dist/schema-decls-layers-point-path.d.ts.map +1 -0
- package/dist/schema-decls-layers-point-path.js +156 -0
- package/dist/schema-decls-layers-point-path.js.map +1 -0
- package/dist/schema-decls-layers-sf-blank.d.ts +89 -0
- package/dist/schema-decls-layers-sf-blank.d.ts.map +1 -0
- package/dist/schema-decls-layers-sf-blank.js +254 -0
- package/dist/schema-decls-layers-sf-blank.js.map +1 -0
- package/dist/schema-decls-layers-text-map.d.ts +80 -0
- package/dist/schema-decls-layers-text-map.d.ts.map +1 -0
- package/dist/schema-decls-layers-text-map.js +151 -0
- package/dist/schema-decls-layers-text-map.js.map +1 -0
- package/dist/schema-decls-paint.d.ts +39 -0
- package/dist/schema-decls-paint.d.ts.map +1 -0
- package/dist/schema-decls-paint.js +95 -0
- package/dist/schema-decls-paint.js.map +1 -0
- package/dist/schema-decls-params-area-abline.d.ts +85 -0
- package/dist/schema-decls-params-area-abline.d.ts.map +1 -0
- package/dist/schema-decls-params-area-abline.js +259 -0
- package/dist/schema-decls-params-area-abline.js.map +1 -0
- package/dist/schema-decls-params-col-contour.d.ts +61 -0
- package/dist/schema-decls-params-col-contour.d.ts.map +1 -0
- package/dist/schema-decls-params-col-contour.js +202 -0
- package/dist/schema-decls-params-col-contour.js.map +1 -0
- package/dist/schema-decls-params-curve-label.d.ts +64 -0
- package/dist/schema-decls-params-curve-label.d.ts.map +1 -0
- package/dist/schema-decls-params-curve-label.js +204 -0
- package/dist/schema-decls-params-curve-label.js.map +1 -0
- package/dist/schema-decls-params-errorbar-position.d.ts +83 -0
- package/dist/schema-decls-params-errorbar-position.d.ts.map +1 -0
- package/dist/schema-decls-params-errorbar-position.js +264 -0
- package/dist/schema-decls-params-errorbar-position.js.map +1 -0
- package/dist/schema-decls-params-point-path.d.ts +61 -0
- package/dist/schema-decls-params-point-path.d.ts.map +1 -0
- package/dist/schema-decls-params-point-path.js +240 -0
- package/dist/schema-decls-params-point-path.js.map +1 -0
- package/dist/schema-decls-params-violin-summary.d.ts +78 -0
- package/dist/schema-decls-params-violin-summary.d.ts.map +1 -0
- package/dist/schema-decls-params-violin-summary.js +272 -0
- package/dist/schema-decls-params-violin-summary.js.map +1 -0
- package/dist/schema-decls-plot.d.ts +80 -0
- package/dist/schema-decls-plot.d.ts.map +1 -0
- package/dist/schema-decls-plot.js +222 -0
- package/dist/schema-decls-plot.js.map +1 -0
- package/dist/schema-decls-scales-guides.d.ts +291 -0
- package/dist/schema-decls-scales-guides.d.ts.map +1 -0
- package/dist/schema-decls-scales-guides.js +189 -0
- package/dist/schema-decls-scales-guides.js.map +1 -0
- package/dist/schema-decls-scales.d.ts +124 -0
- package/dist/schema-decls-scales.d.ts.map +1 -0
- package/dist/schema-decls-scales.js +279 -0
- package/dist/schema-decls-scales.js.map +1 -0
- package/dist/schema-imports.d.ts +1679 -0
- package/dist/schema-imports.d.ts.map +1 -0
- package/dist/schema-imports.js +104 -0
- package/dist/schema-imports.js.map +1 -0
- package/dist/schema-name-schemas.d.ts +18 -0
- package/dist/schema-name-schemas.d.ts.map +1 -0
- package/dist/schema-name-schemas.js +13 -0
- package/dist/schema-name-schemas.js.map +1 -0
- package/dist/schema-names.d.ts +53 -0
- package/dist/schema-names.d.ts.map +1 -0
- package/dist/schema-names.js +229 -0
- package/dist/schema-names.js.map +1 -0
- package/dist/schema-types.d.ts +336 -0
- package/dist/schema-types.d.ts.map +1 -0
- package/dist/schema-types.js +10 -0
- package/dist/schema-types.js.map +1 -0
- package/dist/schema.d.ts +38 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +34 -0
- package/dist/schema.js.map +1 -0
- package/dist/stat-reference-build.d.ts +24 -0
- package/dist/stat-reference-build.d.ts.map +1 -0
- package/dist/stat-reference-build.js +86 -0
- package/dist/stat-reference-build.js.map +1 -0
- package/dist/stat-reference.d.ts +33 -0
- package/dist/stat-reference.d.ts.map +1 -0
- package/dist/stat-reference.js +19 -0
- package/dist/stat-reference.js.map +1 -0
- package/dist/structural-gate.d.ts +15 -0
- package/dist/structural-gate.d.ts.map +1 -0
- package/dist/structural-gate.js +34 -0
- package/dist/structural-gate.js.map +1 -0
- package/dist/temporal-column.d.ts +33 -0
- package/dist/temporal-column.d.ts.map +1 -0
- package/dist/temporal-column.js +247 -0
- package/dist/temporal-column.js.map +1 -0
- package/dist/temporal-guides.d.ts +11 -0
- package/dist/temporal-guides.d.ts.map +1 -0
- package/dist/temporal-guides.js +11 -0
- package/dist/temporal-guides.js.map +1 -0
- package/dist/temporal-interval-schema.d.ts +9 -0
- package/dist/temporal-interval-schema.d.ts.map +1 -0
- package/dist/temporal-interval-schema.js +25 -0
- package/dist/temporal-interval-schema.js.map +1 -0
- package/dist/temporal-interval.d.ts +29 -0
- package/dist/temporal-interval.d.ts.map +1 -0
- package/dist/temporal-interval.js +122 -0
- package/dist/temporal-interval.js.map +1 -0
- package/dist/temporal-parse-core.d.ts +96 -0
- package/dist/temporal-parse-core.d.ts.map +1 -0
- package/dist/temporal-parse-core.js +235 -0
- package/dist/temporal-parse-core.js.map +1 -0
- package/dist/temporal-parse-format.d.ts +13 -0
- package/dist/temporal-parse-format.d.ts.map +1 -0
- package/dist/temporal-parse-format.js +180 -0
- package/dist/temporal-parse-format.js.map +1 -0
- package/dist/temporal-parse-schema.d.ts +11 -0
- package/dist/temporal-parse-schema.d.ts.map +1 -0
- package/dist/temporal-parse-schema.js +23 -0
- package/dist/temporal-parse-schema.js.map +1 -0
- package/dist/temporal-parse.d.ts +18 -0
- package/dist/temporal-parse.d.ts.map +1 -0
- package/dist/temporal-parse.js +183 -0
- package/dist/temporal-parse.js.map +1 -0
- package/dist/temporal-polyfill.d.ts +3 -0
- package/dist/temporal-polyfill.d.ts.map +1 -0
- package/dist/temporal-polyfill.js +25 -0
- package/dist/temporal-polyfill.js.map +1 -0
- package/dist/temporal-ticks.d.ts +20 -0
- package/dist/temporal-ticks.d.ts.map +1 -0
- package/dist/temporal-ticks.js +246 -0
- package/dist/temporal-ticks.js.map +1 -0
- package/dist/temporal.d.ts +109 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +73 -0
- package/dist/temporal.js.map +1 -0
- package/dist/validate-data-checks-color-temporal.d.ts +58 -0
- package/dist/validate-data-checks-color-temporal.d.ts.map +1 -0
- package/dist/validate-data-checks-color-temporal.js +168 -0
- package/dist/validate-data-checks-color-temporal.js.map +1 -0
- package/dist/validate-data-checks-color.d.ts +28 -0
- package/dist/validate-data-checks-color.d.ts.map +1 -0
- package/dist/validate-data-checks-color.js +296 -0
- package/dist/validate-data-checks-color.js.map +1 -0
- package/dist/validate-data-checks-layer.d.ts +37 -0
- package/dist/validate-data-checks-layer.d.ts.map +1 -0
- package/dist/validate-data-checks-layer.js +343 -0
- package/dist/validate-data-checks-layer.js.map +1 -0
- package/dist/validate-data-checks-position.d.ts +45 -0
- package/dist/validate-data-checks-position.d.ts.map +1 -0
- package/dist/validate-data-checks-position.js +204 -0
- package/dist/validate-data-checks-position.js.map +1 -0
- package/dist/validate-data-checks-style-finite.d.ts +24 -0
- package/dist/validate-data-checks-style-finite.d.ts.map +1 -0
- package/dist/validate-data-checks-style-finite.js +40 -0
- package/dist/validate-data-checks-style-finite.js.map +1 -0
- package/dist/validate-data-checks-style-numeric.d.ts +26 -0
- package/dist/validate-data-checks-style-numeric.d.ts.map +1 -0
- package/dist/validate-data-checks-style-numeric.js +327 -0
- package/dist/validate-data-checks-style-numeric.js.map +1 -0
- package/dist/validate-data-checks-style.d.ts +14 -0
- package/dist/validate-data-checks-style.d.ts.map +1 -0
- package/dist/validate-data-checks-style.js +14 -0
- package/dist/validate-data-checks-style.js.map +1 -0
- package/dist/validate-data-checks-temporal.d.ts +57 -0
- package/dist/validate-data-checks-temporal.d.ts.map +1 -0
- package/dist/validate-data-checks-temporal.js +83 -0
- package/dist/validate-data-checks-temporal.js.map +1 -0
- package/dist/validate-data-checks.d.ts +31 -0
- package/dist/validate-data-checks.d.ts.map +1 -0
- package/dist/validate-data-checks.js +110 -0
- package/dist/validate-data-checks.js.map +1 -0
- package/dist/validate-data-evidence.d.ts +69 -0
- package/dist/validate-data-evidence.d.ts.map +1 -0
- package/dist/validate-data-evidence.js +329 -0
- package/dist/validate-data-evidence.js.map +1 -0
- package/dist/validate-data.d.ts +73 -0
- package/dist/validate-data.d.ts.map +1 -0
- package/dist/validate-data.js +30 -0
- package/dist/validate-data.js.map +1 -0
- package/dist/validate-map-errors.d.ts +32 -0
- package/dist/validate-map-errors.d.ts.map +1 -0
- package/dist/validate-map-errors.js +76 -0
- package/dist/validate-map-errors.js.map +1 -0
- package/dist/validate-map-forms.d.ts +43 -0
- package/dist/validate-map-forms.d.ts.map +1 -0
- package/dist/validate-map-forms.js +125 -0
- package/dist/validate-map-forms.js.map +1 -0
- package/dist/validate-map-path-keywords.d.ts +11 -0
- package/dist/validate-map-path-keywords.d.ts.map +1 -0
- package/dist/validate-map-path-keywords.js +95 -0
- package/dist/validate-map-path-keywords.js.map +1 -0
- package/dist/validate-map-path-unions.d.ts +27 -0
- package/dist/validate-map-path-unions.d.ts.map +1 -0
- package/dist/validate-map-path-unions.js +200 -0
- package/dist/validate-map-path-unions.js.map +1 -0
- package/dist/validate-schema-shape.d.ts +69 -0
- package/dist/validate-schema-shape.d.ts.map +1 -0
- package/dist/validate-schema-shape.js +156 -0
- package/dist/validate-schema-shape.js.map +1 -0
- package/dist/validate-schema-walk.d.ts +34 -0
- package/dist/validate-schema-walk.d.ts.map +1 -0
- package/dist/validate-schema-walk.js +216 -0
- package/dist/validate-schema-walk.js.map +1 -0
- package/dist/validate-structure-facet.d.ts +8 -0
- package/dist/validate-structure-facet.d.ts.map +1 -0
- package/dist/validate-structure-facet.js +67 -0
- package/dist/validate-structure-facet.js.map +1 -0
- package/dist/validate-structure-layer-computed-y.d.ts +14 -0
- package/dist/validate-structure-layer-computed-y.d.ts.map +1 -0
- package/dist/validate-structure-layer-computed-y.js +70 -0
- package/dist/validate-structure-layer-computed-y.js.map +1 -0
- package/dist/validate-structure-layer-ribbon.d.ts +8 -0
- package/dist/validate-structure-layer-ribbon.d.ts.map +1 -0
- package/dist/validate-structure-layer-ribbon.js +36 -0
- package/dist/validate-structure-layer-ribbon.js.map +1 -0
- package/dist/validate-structure-layer-rule.d.ts +14 -0
- package/dist/validate-structure-layer-rule.d.ts.map +1 -0
- package/dist/validate-structure-layer-rule.js +90 -0
- package/dist/validate-structure-layer-rule.js.map +1 -0
- package/dist/validate-structure-layer-shared.d.ts +12 -0
- package/dist/validate-structure-layer-shared.d.ts.map +1 -0
- package/dist/validate-structure-layer-shared.js +17 -0
- package/dist/validate-structure-layer-shared.js.map +1 -0
- package/dist/validate-structure-layers.d.ts +12 -0
- package/dist/validate-structure-layers.d.ts.map +1 -0
- package/dist/validate-structure-layers.js +292 -0
- package/dist/validate-structure-layers.js.map +1 -0
- package/dist/validate-structure-paint.d.ts +12 -0
- package/dist/validate-structure-paint.d.ts.map +1 -0
- package/dist/validate-structure-paint.js +87 -0
- package/dist/validate-structure-paint.js.map +1 -0
- package/dist/validate-structure-scales.d.ts +10 -0
- package/dist/validate-structure-scales.d.ts.map +1 -0
- package/dist/validate-structure-scales.js +242 -0
- package/dist/validate-structure-scales.js.map +1 -0
- package/dist/validate-structure-style-bins.d.ts +17 -0
- package/dist/validate-structure-style-bins.d.ts.map +1 -0
- package/dist/validate-structure-style-bins.js +150 -0
- package/dist/validate-structure-style-bins.js.map +1 -0
- package/dist/validate-structure.d.ts +16 -0
- package/dist/validate-structure.d.ts.map +1 -0
- package/dist/validate-structure.js +16 -0
- package/dist/validate-structure.js.map +1 -0
- package/dist/validate.d.ts +24 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +178 -0
- package/dist/validate.js.map +1 -0
- package/package.json +59 -0
- package/schema/v0.json +9618 -0
- package/src/artifact.ts +81 -0
- package/src/builder-core.ts +276 -0
- package/src/builder-data.ts +156 -0
- package/src/builder-geoms.ts +290 -0
- package/src/builder-options.ts +428 -0
- package/src/builder-scales.ts +443 -0
- package/src/builder.ts +125 -0
- package/src/capabilities-data.ts +336 -0
- package/src/capabilities-helpers.ts +54 -0
- package/src/capabilities.ts +159 -0
- package/src/coord-helpers.ts +177 -0
- package/src/coord-reference-build.ts +283 -0
- package/src/coord-reference.ts +75 -0
- package/src/error-catalog.ts +253 -0
- package/src/error-prose-shared.ts +106 -0
- package/src/errors.ts +87 -0
- package/src/generated/coord-reference-data.ts +235 -0
- package/src/generated/geom-param-keys.ts +222 -0
- package/src/generated/geom-reference-data.ts +3024 -0
- package/src/generated/guide-reference-data.ts +284 -0
- package/src/generated/plot-spec-validator.ts +7335 -0
- package/src/generated/position-reference-data.ts +191 -0
- package/src/generated/scale-reference-data.ts +10665 -0
- package/src/generated/stat-reference-data.ts +339 -0
- package/src/geom-params-build.ts +92 -0
- package/src/geom-params.ts +14 -0
- package/src/geom-reference-build.ts +292 -0
- package/src/geom-reference.ts +127 -0
- package/src/guide-helpers.ts +44 -0
- package/src/guide-reference-build.ts +249 -0
- package/src/guide-reference.ts +76 -0
- package/src/hue-grey-palettes.ts +82 -0
- package/src/index.ts +400 -0
- package/src/lint-catalog.ts +57 -0
- package/src/lint-layer-rules.ts +175 -0
- package/src/lint-scale-rules.ts +285 -0
- package/src/lint.ts +126 -0
- package/src/normalize-coord.ts +126 -0
- package/src/normalize-input-layers-marks.ts +276 -0
- package/src/normalize-input-layers-special.ts +252 -0
- package/src/normalize-input.ts +154 -0
- package/src/normalize-paint.ts +98 -0
- package/src/normalize-scales.ts +108 -0
- package/src/normalize.ts +403 -0
- package/src/paint-helpers.ts +98 -0
- package/src/pipeline-error-catalog.ts +278 -0
- package/src/portability-check.ts +155 -0
- package/src/portability-lossy.ts +81 -0
- package/src/portability.ts +31 -0
- package/src/portable-builder.ts +35 -0
- package/src/portable-entry.ts +37 -0
- package/src/position-reference-build.ts +164 -0
- package/src/position-reference.ts +41 -0
- package/src/runtime.ts +198 -0
- package/src/scale-color-helpers.ts +263 -0
- package/src/scale-color-hue-grey.ts +95 -0
- package/src/scale-color-stops.ts +177 -0
- package/src/scale-color-viridis.ts +99 -0
- package/src/scale-helpers.ts +264 -0
- package/src/scale-multi-helpers.ts +220 -0
- package/src/scale-position-helpers.ts +231 -0
- package/src/scale-reference-build.ts +222 -0
- package/src/scale-reference-classify-color.ts +334 -0
- package/src/scale-reference-classify-position.ts +164 -0
- package/src/scale-reference-classify-style.ts +229 -0
- package/src/scale-reference-classify-support.ts +298 -0
- package/src/scale-reference.ts +165 -0
- package/src/scale-style-helpers.ts +316 -0
- package/src/schema-catalog.ts +222 -0
- package/src/schema-declarations.ts +51 -0
- package/src/schema-decls-data.ts +272 -0
- package/src/schema-decls-guides-theme.ts +395 -0
- package/src/schema-decls-layers-col-boxplot.ts +410 -0
- package/src/schema-decls-layers-count-pointrange.ts +321 -0
- package/src/schema-decls-layers-crossbar-jitter.ts +443 -0
- package/src/schema-decls-layers-point-path.ts +246 -0
- package/src/schema-decls-layers-sf-blank.ts +408 -0
- package/src/schema-decls-layers-text-map.ts +259 -0
- package/src/schema-decls-paint.ts +124 -0
- package/src/schema-decls-params-area-abline.ts +440 -0
- package/src/schema-decls-params-col-contour.ts +333 -0
- package/src/schema-decls-params-curve-label.ts +343 -0
- package/src/schema-decls-params-errorbar-position.ts +446 -0
- package/src/schema-decls-params-point-path.ts +394 -0
- package/src/schema-decls-params-violin-summary.ts +447 -0
- package/src/schema-decls-plot.ts +385 -0
- package/src/schema-decls-scales-guides.ts +233 -0
- package/src/schema-decls-scales.ts +432 -0
- package/src/schema-imports.ts +116 -0
- package/src/schema-name-schemas.ts +37 -0
- package/src/schema-names.ts +243 -0
- package/src/schema-types.ts +400 -0
- package/src/schema.ts +287 -0
- package/src/stat-reference-build.ts +145 -0
- package/src/stat-reference.ts +38 -0
- package/src/structural-gate.ts +42 -0
- package/src/temporal-column.ts +323 -0
- package/src/temporal-guides.ts +32 -0
- package/src/temporal-interval-schema.ts +40 -0
- package/src/temporal-interval.ts +151 -0
- package/src/temporal-parse-core.ts +331 -0
- package/src/temporal-parse-format.ts +222 -0
- package/src/temporal-parse-schema.ts +38 -0
- package/src/temporal-parse.ts +259 -0
- package/src/temporal-polyfill.ts +27 -0
- package/src/temporal-ticks.ts +312 -0
- package/src/temporal.ts +112 -0
- package/src/validate-data-checks-color-temporal.ts +261 -0
- package/src/validate-data-checks-color.ts +395 -0
- package/src/validate-data-checks-layer.ts +492 -0
- package/src/validate-data-checks-position.ts +275 -0
- package/src/validate-data-checks-style-finite.ts +55 -0
- package/src/validate-data-checks-style-numeric.ts +455 -0
- package/src/validate-data-checks-style.ts +13 -0
- package/src/validate-data-checks-temporal.ts +129 -0
- package/src/validate-data-checks.ts +157 -0
- package/src/validate-data-evidence.ts +419 -0
- package/src/validate-data.ts +114 -0
- package/src/validate-map-errors.ts +126 -0
- package/src/validate-map-forms.ts +148 -0
- package/src/validate-map-path-keywords.ts +129 -0
- package/src/validate-map-path-unions.ts +281 -0
- package/src/validate-schema-shape.ts +232 -0
- package/src/validate-schema-walk.ts +219 -0
- package/src/validate-structure-facet.ts +76 -0
- package/src/validate-structure-layer-computed-y.ts +94 -0
- package/src/validate-structure-layer-ribbon.ts +61 -0
- package/src/validate-structure-layer-rule.ts +98 -0
- package/src/validate-structure-layer-shared.ts +29 -0
- package/src/validate-structure-layers.ts +395 -0
- package/src/validate-structure-paint.ts +101 -0
- package/src/validate-structure-scales.ts +278 -0
- package/src/validate-structure-style-bins.ts +167 -0
- package/src/validate-structure.ts +16 -0
- package/src/validate.ts +212 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalize within-mark paint on layer params: hex → lowercase #rrggbb,
|
|
3
|
+
* default gradient space → "mark". Pure; never throws.
|
|
4
|
+
*/
|
|
5
|
+
import type { ColorStop, GlowSpec, GradientPaint, LayerSpec } from "./schema.js";
|
|
6
|
+
|
|
7
|
+
function normalizeHexColor(color: string): string {
|
|
8
|
+
const match = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color);
|
|
9
|
+
if (match === null) return color;
|
|
10
|
+
const digits = match[1]!.toLowerCase();
|
|
11
|
+
return digits.length === 3
|
|
12
|
+
? `#${digits[0]}${digits[0]}${digits[1]}${digits[1]}${digits[2]}${digits[2]}`
|
|
13
|
+
: `#${digits}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function normalizeStop(stop: ColorStop): ColorStop {
|
|
17
|
+
return {
|
|
18
|
+
offset: stop.offset,
|
|
19
|
+
color: normalizeHexColor(stop.color),
|
|
20
|
+
...(stop.opacity !== undefined && { opacity: stop.opacity }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalizeGradient(paint: GradientPaint): GradientPaint {
|
|
25
|
+
const space = paint.space ?? "mark";
|
|
26
|
+
if (paint.type === "linear") {
|
|
27
|
+
return {
|
|
28
|
+
type: "linear",
|
|
29
|
+
x1: paint.x1,
|
|
30
|
+
y1: paint.y1,
|
|
31
|
+
x2: paint.x2,
|
|
32
|
+
y2: paint.y2,
|
|
33
|
+
space,
|
|
34
|
+
stops: paint.stops.map(normalizeStop),
|
|
35
|
+
fallback: normalizeHexColor(paint.fallback),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
type: "radial",
|
|
40
|
+
cx: paint.cx,
|
|
41
|
+
cy: paint.cy,
|
|
42
|
+
r: paint.r,
|
|
43
|
+
space,
|
|
44
|
+
stops: paint.stops.map(normalizeStop),
|
|
45
|
+
fallback: normalizeHexColor(paint.fallback),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function normalizeGlow(glow: GlowSpec): GlowSpec {
|
|
50
|
+
return {
|
|
51
|
+
color: normalizeHexColor(glow.color),
|
|
52
|
+
radius: glow.radius,
|
|
53
|
+
opacity: glow.opacity,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
58
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isGradientPaint(value: unknown): value is GradientPaint {
|
|
62
|
+
if (!isRecord(value)) return false;
|
|
63
|
+
return value["type"] === "linear" || value["type"] === "radial";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isGlow(value: unknown): value is GlowSpec {
|
|
67
|
+
if (!isRecord(value)) return false;
|
|
68
|
+
return (
|
|
69
|
+
typeof value["color"] === "string" &&
|
|
70
|
+
typeof value["radius"] === "number" &&
|
|
71
|
+
typeof value["opacity"] === "number"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Normalize fillPaint / strokePaint / glow on a layer's params bag. */
|
|
76
|
+
export function normalizeLayerParamsPaint(
|
|
77
|
+
params: NonNullable<LayerSpec["params"]>,
|
|
78
|
+
): NonNullable<LayerSpec["params"]> {
|
|
79
|
+
const bag: Record<string, unknown> = { ...params };
|
|
80
|
+
let changed = false;
|
|
81
|
+
|
|
82
|
+
if (isGradientPaint(bag["fillPaint"])) {
|
|
83
|
+
bag["fillPaint"] = normalizeGradient(bag["fillPaint"]);
|
|
84
|
+
changed = true;
|
|
85
|
+
}
|
|
86
|
+
if (isGradientPaint(bag["strokePaint"])) {
|
|
87
|
+
bag["strokePaint"] = normalizeGradient(bag["strokePaint"]);
|
|
88
|
+
changed = true;
|
|
89
|
+
}
|
|
90
|
+
if (isGlow(bag["glow"])) {
|
|
91
|
+
bag["glow"] = normalizeGlow(bag["glow"]);
|
|
92
|
+
changed = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Layer params is a geom-specific union; paint keys are optional extras on
|
|
96
|
+
// the supported members. Spread preserves the original structural type.
|
|
97
|
+
return changed ? { ...params, ...bag } : params;
|
|
98
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scale canonicalization for normalize() — position type rewrites and color hex.
|
|
3
|
+
* Coord: normalize-coord.ts. Layer/aes orchestration: normalize.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ColorScaleSpec, PositionScaleSpec, Scales } from "./schema.js";
|
|
7
|
+
|
|
8
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function withGuide<T extends object>(scale: T): T {
|
|
13
|
+
if (!("guide" in scale) || !isRecord(scale.guide)) return { ...scale };
|
|
14
|
+
const guide = {
|
|
15
|
+
...scale.guide,
|
|
16
|
+
...(isRecord(scale.guide["theme"]) && { theme: { ...scale.guide["theme"] } }),
|
|
17
|
+
};
|
|
18
|
+
return { ...scale, guide };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function normalizeHexColor(color: string): string {
|
|
22
|
+
const match = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color);
|
|
23
|
+
if (match === null) return color;
|
|
24
|
+
const digits = match[1]!.toLowerCase();
|
|
25
|
+
return digits.length === 3
|
|
26
|
+
? `#${digits[0]}${digits[0]}${digits[1]}${digits[1]}${digits[2]}${digits[2]}`
|
|
27
|
+
: `#${digits}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function normalizeColorScale(scale: ColorScaleSpec): ColorScaleSpec {
|
|
31
|
+
const fallbacks = {
|
|
32
|
+
...(scale.naValue !== undefined && { naValue: normalizeHexColor(scale.naValue) }),
|
|
33
|
+
...(scale.unknownValue !== undefined && {
|
|
34
|
+
unknownValue: normalizeHexColor(scale.unknownValue),
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
if (scale.type === "identity") return { ...withGuide(scale), ...fallbacks };
|
|
38
|
+
return {
|
|
39
|
+
...withGuide(scale),
|
|
40
|
+
...(Array.isArray(scale.range) && {
|
|
41
|
+
range: scale.range.map((color) => normalizeHexColor(color)),
|
|
42
|
+
}),
|
|
43
|
+
...fallbacks,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function normalizePositionScale(scale: PositionScaleSpec): PositionScaleSpec {
|
|
48
|
+
if (scale.type === "band") {
|
|
49
|
+
const {
|
|
50
|
+
temporalKind: _,
|
|
51
|
+
parse: __,
|
|
52
|
+
parseFailure: ___,
|
|
53
|
+
timezone: ____,
|
|
54
|
+
disambiguation: _____,
|
|
55
|
+
dateBreaks: ______,
|
|
56
|
+
dateMinorBreaks: _______,
|
|
57
|
+
dateLabels: ________,
|
|
58
|
+
locale: _________,
|
|
59
|
+
weekStart: __________,
|
|
60
|
+
...band
|
|
61
|
+
} = scale;
|
|
62
|
+
return band;
|
|
63
|
+
}
|
|
64
|
+
// Canonical log10: an authored `type: "log"` (base-10) IS the linear family
|
|
65
|
+
// with the log10 transform. A conflicting explicit transform (identity/sqrt)
|
|
66
|
+
// is left uncanonicalized for pipeline preflight to reject as
|
|
67
|
+
// scale-type-transform-conflict. Pure normalize never throws.
|
|
68
|
+
if (scale.type === "log" && (scale.transform === undefined || scale.transform === "log10")) {
|
|
69
|
+
return { ...scale, type: "linear", transform: "log10" };
|
|
70
|
+
}
|
|
71
|
+
// Binned is a quantitative position family; it never requests a time scale.
|
|
72
|
+
// Contradictory temporal options are left for validate() to reject.
|
|
73
|
+
if (scale.type === "binned") {
|
|
74
|
+
return { ...scale };
|
|
75
|
+
}
|
|
76
|
+
const hasTemporalGuideOption =
|
|
77
|
+
scale.dateBreaks !== undefined ||
|
|
78
|
+
scale.dateMinorBreaks !== undefined ||
|
|
79
|
+
scale.dateLabels !== undefined ||
|
|
80
|
+
scale.locale !== undefined ||
|
|
81
|
+
scale.weekStart !== undefined;
|
|
82
|
+
if ((scale.type === "linear" || scale.type === "log") && hasTemporalGuideOption) {
|
|
83
|
+
return { ...scale };
|
|
84
|
+
}
|
|
85
|
+
const requestsTime =
|
|
86
|
+
scale.type === "time" ||
|
|
87
|
+
scale.temporalKind !== undefined ||
|
|
88
|
+
scale.parse !== undefined ||
|
|
89
|
+
scale.parseFailure !== undefined ||
|
|
90
|
+
scale.timezone !== undefined ||
|
|
91
|
+
scale.disambiguation !== undefined ||
|
|
92
|
+
hasTemporalGuideOption;
|
|
93
|
+
return requestsTime ? { ...scale, type: "time" } : { ...scale };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function normalizeScales(scales: Scales): Scales {
|
|
97
|
+
return {
|
|
98
|
+
...(scales.x !== undefined && { x: withGuide(normalizePositionScale(scales.x)) }),
|
|
99
|
+
...(scales.y !== undefined && { y: withGuide(normalizePositionScale(scales.y)) }),
|
|
100
|
+
...(scales.color !== undefined && { color: normalizeColorScale(scales.color) }),
|
|
101
|
+
...(scales.fill !== undefined && { fill: normalizeColorScale(scales.fill) }),
|
|
102
|
+
...(scales.size !== undefined && { size: withGuide(scales.size) }),
|
|
103
|
+
...(scales.linewidth !== undefined && { linewidth: withGuide(scales.linewidth) }),
|
|
104
|
+
...(scales.alpha !== undefined && { alpha: withGuide(scales.alpha) }),
|
|
105
|
+
...(scales.shape !== undefined && { shape: withGuide(scales.shape) }),
|
|
106
|
+
...(scales.linetype !== undefined && { linetype: withGuide(scales.linetype) }),
|
|
107
|
+
};
|
|
108
|
+
}
|
package/src/normalize.ts
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* normalize() — the canonicalizer (plan: "One canonical form per concept").
|
|
3
|
+
*
|
|
4
|
+
* Input: a SpecInput, the TS/builder-level convenience form where channels may
|
|
5
|
+
* be bare strings ('displ' means { field: 'displ' }). The JSON Schema does NOT
|
|
6
|
+
* admit bare strings — the shorthand exists only here and in the Svelte props.
|
|
7
|
+
* Input types live in normalize-input.ts.
|
|
8
|
+
*
|
|
9
|
+
* Output: a canonical PortableSpec. Canonicalization performed:
|
|
10
|
+
* 1. Bare-string channels -> { field } (in plot aes and layer aes).
|
|
11
|
+
* 2. Geom defaults filled (GEOM_DEFAULTS): bar -> stat count + position
|
|
12
|
+
* stack; col/area -> identity + stack; everything else identity/identity.
|
|
13
|
+
* 3. Bar layers with no y channel get the count stat's default mapping
|
|
14
|
+
* y: { stat: "count" } (ggplot2's after_stat default aes).
|
|
15
|
+
* 4. Aes inheritance RESOLVED into each layer with null-unset semantics
|
|
16
|
+
* (layer channel null removes the inherited channel), and the plot-level
|
|
17
|
+
* `aes` removed from the output. Every normalized layer is self-contained.
|
|
18
|
+
* (Resolving at normalize time is what makes normalize idempotent: keeping
|
|
19
|
+
* plot aes AND merged layers would re-inherit null-unset channels on a
|
|
20
|
+
* second pass.)
|
|
21
|
+
* 5. Theme names stay strings; theme objects are cloned (both canonical).
|
|
22
|
+
* 6. Deterministic key order for every object it constructs.
|
|
23
|
+
*
|
|
24
|
+
* Scale-type inference needs data, so it lives in @ggts-sh/core (pipeline);
|
|
25
|
+
* normalize only fills structural defaults. Normalized output is itself a
|
|
26
|
+
* valid PortableSpec, and normalize(normalize(s)) deep-equals normalize(s).
|
|
27
|
+
*
|
|
28
|
+
* Scale and coord canonicalization live in normalize-scales.ts and
|
|
29
|
+
* normalize-coord.ts; this module owns channels, layers, facet, theme, and
|
|
30
|
+
* the top-level normalize() walk.
|
|
31
|
+
*/
|
|
32
|
+
import type {
|
|
33
|
+
Aes,
|
|
34
|
+
AliasGeomName,
|
|
35
|
+
ChannelValue,
|
|
36
|
+
FacetSpec,
|
|
37
|
+
GuidesSpec,
|
|
38
|
+
GuideSpec,
|
|
39
|
+
NormalizedGeomName,
|
|
40
|
+
NormalizedLayerSpec,
|
|
41
|
+
NormalizedSpec,
|
|
42
|
+
ThemeName,
|
|
43
|
+
ThemeSpec,
|
|
44
|
+
} from "./schema.js";
|
|
45
|
+
import { normalizeCoord } from "./normalize-coord.js";
|
|
46
|
+
import { normalizeLayerParamsPaint } from "./normalize-paint.js";
|
|
47
|
+
import { normalizeScales } from "./normalize-scales.js";
|
|
48
|
+
import { CHANNELS, CURRENT_EDITION, GEOM_ALIASES, GEOM_DEFAULTS } from "./schema-catalog.js";
|
|
49
|
+
import type {
|
|
50
|
+
AesInput,
|
|
51
|
+
ChannelInput,
|
|
52
|
+
FacetInput,
|
|
53
|
+
LayerInput,
|
|
54
|
+
SpecInput,
|
|
55
|
+
} from "./normalize-input.js";
|
|
56
|
+
|
|
57
|
+
// Stable public path: re-export input types so index/builder/tests keep
|
|
58
|
+
// importing from ./normalize.js (type-only dependency on normalize-input).
|
|
59
|
+
export type {
|
|
60
|
+
AesInput,
|
|
61
|
+
AreaLayerInput,
|
|
62
|
+
BarLayerInput,
|
|
63
|
+
BoxplotLayerInput,
|
|
64
|
+
ChannelInput,
|
|
65
|
+
ColLayerInput,
|
|
66
|
+
DensityLayerInput,
|
|
67
|
+
ErrorbarLayerInput,
|
|
68
|
+
LinerangeLayerInput,
|
|
69
|
+
PointrangeLayerInput,
|
|
70
|
+
CrossbarLayerInput,
|
|
71
|
+
FacetFieldInput,
|
|
72
|
+
FacetInput,
|
|
73
|
+
HistogramLayerInput,
|
|
74
|
+
FreqpolyLayerInput,
|
|
75
|
+
HlineLayerInput,
|
|
76
|
+
JitterLayerInput,
|
|
77
|
+
RibbonLayerInput,
|
|
78
|
+
SegmentLayerInput,
|
|
79
|
+
CountLayerInput,
|
|
80
|
+
ViolinLayerInput,
|
|
81
|
+
FunctionLayerInput,
|
|
82
|
+
PolygonLayerInput,
|
|
83
|
+
AblineLayerInput,
|
|
84
|
+
ContourLayerInput,
|
|
85
|
+
Density2dLayerInput,
|
|
86
|
+
Density2dFilledLayerInput,
|
|
87
|
+
DotplotLayerInput,
|
|
88
|
+
BlankLayerInput,
|
|
89
|
+
MapLayerInput,
|
|
90
|
+
SpokeLayerInput,
|
|
91
|
+
SfLayerInput,
|
|
92
|
+
SfTextLayerInput,
|
|
93
|
+
SfLabelLayerInput,
|
|
94
|
+
CurveLayerInput,
|
|
95
|
+
RugLayerInput,
|
|
96
|
+
StepLayerInput,
|
|
97
|
+
QqLayerInput,
|
|
98
|
+
QqLineLayerInput,
|
|
99
|
+
LayerInput,
|
|
100
|
+
LineLayerInput,
|
|
101
|
+
PathLayerInput,
|
|
102
|
+
PointLayerInput,
|
|
103
|
+
RasterLayerInput,
|
|
104
|
+
HexLayerInput,
|
|
105
|
+
RectLayerInput,
|
|
106
|
+
RuleLayerInput,
|
|
107
|
+
QuantileLayerInput,
|
|
108
|
+
SmoothLayerInput,
|
|
109
|
+
SpecInput,
|
|
110
|
+
TextLayerInput,
|
|
111
|
+
LabelLayerInput,
|
|
112
|
+
TileLayerInput,
|
|
113
|
+
Bin2dLayerInput,
|
|
114
|
+
VlineLayerInput,
|
|
115
|
+
} from "./normalize-input.js";
|
|
116
|
+
|
|
117
|
+
/** Canonicalize one channel: bare string -> { field }; clone canonical forms. */
|
|
118
|
+
export function normalizeChannel(input: ChannelInput): ChannelValue {
|
|
119
|
+
if (typeof input === "string") return { field: input };
|
|
120
|
+
if (input === null) return null;
|
|
121
|
+
if ("field" in input) return { field: input.field };
|
|
122
|
+
if ("value" in input) {
|
|
123
|
+
return input.scale === undefined
|
|
124
|
+
? { value: input.value }
|
|
125
|
+
: { value: input.value, scale: input.scale };
|
|
126
|
+
}
|
|
127
|
+
return { stat: input.stat };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function normalizeAes(input: AesInput | undefined): Aes | undefined {
|
|
131
|
+
if (input === undefined) return undefined;
|
|
132
|
+
const out: Record<string, ChannelValue> = {};
|
|
133
|
+
for (const channel of CHANNELS) {
|
|
134
|
+
const v = input[channel];
|
|
135
|
+
if (v === undefined) continue;
|
|
136
|
+
out[channel] = normalizeChannel(v);
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Merge plot-level aes into a layer's aes with null-unset semantics:
|
|
143
|
+
* layer channels override; a layer channel of null REMOVES the inherited
|
|
144
|
+
* channel (and does not survive into the resolved mapping).
|
|
145
|
+
*/
|
|
146
|
+
function resolveLayerAes(plotAes: Aes | undefined, layerAes: Aes | undefined): Aes | undefined {
|
|
147
|
+
const out: Record<string, ChannelValue> = {};
|
|
148
|
+
for (const channel of CHANNELS) {
|
|
149
|
+
const own = layerAes?.[channel];
|
|
150
|
+
if (own === null) continue; // explicit unset
|
|
151
|
+
const inherited = plotAes?.[channel];
|
|
152
|
+
const chosen = own ?? inherited;
|
|
153
|
+
if (chosen === undefined || chosen === null) continue;
|
|
154
|
+
out[channel] = chosen;
|
|
155
|
+
}
|
|
156
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Annotation-form rule / hline / vline layers (fixed intercepts) inherit NO
|
|
160
|
+
* plot aes — ggplot2's `inherit.aes = FALSE` on geom_vline/hline (Hadley
|
|
161
|
+
* lesson 15: honest, separate signatures for the two rule forms).
|
|
162
|
+
* Asymmetric: hline is annotation only when yintercept is set; vline only
|
|
163
|
+
* when xintercept is set; rule when either intercept is set. */
|
|
164
|
+
function isAnnotationRule(layer: LayerInput): boolean {
|
|
165
|
+
const params = layer.params as { xintercept?: unknown; yintercept?: unknown } | undefined;
|
|
166
|
+
if (layer.geom === "hline") return params?.yintercept !== undefined;
|
|
167
|
+
if (layer.geom === "vline") return params?.xintercept !== undefined;
|
|
168
|
+
if (layer.geom !== "rule") return false;
|
|
169
|
+
return params?.xintercept !== undefined || params?.yintercept !== undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Abline is always annotation-style (fixed slope/intercept; no plot aes). */
|
|
173
|
+
function isAnnotationAbline(layer: LayerInput): boolean {
|
|
174
|
+
return layer.geom === "abline";
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Convenience geom aliases (#818 / histogram / freqpoly): rewrite to the
|
|
179
|
+
* canonical geom name. Pure renames only — no cross-field params surgery.
|
|
180
|
+
*
|
|
181
|
+
* The rewrite is GEOM_ALIASES, so the alias set is one table core can key its
|
|
182
|
+
* pipeline records off (#1042) rather than a fact buried in this branch.
|
|
183
|
+
*/
|
|
184
|
+
function canonicalGeom(geom: LayerInput["geom"]): NormalizedGeomName {
|
|
185
|
+
// Own-key check, not `in`: `in` walks the prototype chain, so a geom named
|
|
186
|
+
// "constructor" or "toString" would read as an alias and rewrite to a
|
|
187
|
+
// function. Unknown names must pass through for validate() to reject.
|
|
188
|
+
return Object.hasOwn(GEOM_ALIASES, geom)
|
|
189
|
+
? GEOM_ALIASES[geom as AliasGeomName]
|
|
190
|
+
: (geom as NormalizedGeomName);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function normalizeLayer(layer: LayerInput, plotAes: Aes | undefined): NormalizedLayerSpec {
|
|
194
|
+
// Data-driven hline/vline are one-axis rules: drop the orthogonal position
|
|
195
|
+
// channel from inheritance so plot-level x+y does not trigger rule-both-axes.
|
|
196
|
+
const layerAesInput = normalizeRuleAesInput(layer);
|
|
197
|
+
|
|
198
|
+
const inherited = isAnnotationRule(layer) || isAnnotationAbline(layer) ? undefined : plotAes;
|
|
199
|
+
let aes = resolveLayerAes(inherited, normalizeAes(layerAesInput));
|
|
200
|
+
// Unknown geoms fall back to identity defaults so normalize never throws —
|
|
201
|
+
// validate() rejects them right after with the proper did-you-mean error.
|
|
202
|
+
// Own-key check for the same reason as canonicalGeom: plain `[…]` on a geom
|
|
203
|
+
// named "constructor" returns a function, which is truthy, so `??` would not
|
|
204
|
+
// fire and the layer would lose stat and position.
|
|
205
|
+
const defaults = Object.hasOwn(GEOM_DEFAULTS, layer.geom)
|
|
206
|
+
? GEOM_DEFAULTS[layer.geom]
|
|
207
|
+
: { stat: "identity" as const, position: "identity" as const };
|
|
208
|
+
// geom_sf: public stat_sf (#809 phase 7). Rewrite legacy portable
|
|
209
|
+
// `stat: "identity"` so re-normalize stays additive (draw path unchanged).
|
|
210
|
+
const rawStat = layer.stat ?? defaults.stat;
|
|
211
|
+
const stat = layer.geom === "sf" && rawStat === "identity" ? "sf" : rawStat;
|
|
212
|
+
// Stat default mappings (ggplot2's `after_stat()` default aes): the count
|
|
213
|
+
// and bin stats map y to their count column; the density stat maps y to
|
|
214
|
+
// its density column.
|
|
215
|
+
aes = normalizeStatAes(aes, stat, layer.geom);
|
|
216
|
+
const geom = canonicalGeom(layer.geom);
|
|
217
|
+
const positionParams =
|
|
218
|
+
"positionParams" in layer && layer.positionParams !== undefined
|
|
219
|
+
? { ...layer.positionParams }
|
|
220
|
+
: undefined;
|
|
221
|
+
const rawParams = layer.params === undefined ? undefined : { ...layer.params };
|
|
222
|
+
const params = rawParams === undefined ? undefined : normalizeLayerParamsPaint(rawParams);
|
|
223
|
+
// "auto" is the render default — one canonical form per concept, so it
|
|
224
|
+
// canonicalizes away (same rule as coord "cartesian" / a11y "auto").
|
|
225
|
+
const render = layer.render === "auto" ? undefined : layer.render;
|
|
226
|
+
// Jitter alias has no position field on the input type; always use defaults.
|
|
227
|
+
const position = normalizeLayerPosition(layer, defaults.position);
|
|
228
|
+
const out = {
|
|
229
|
+
geom,
|
|
230
|
+
stat,
|
|
231
|
+
position,
|
|
232
|
+
...(positionParams !== undefined && { positionParams }),
|
|
233
|
+
...(render !== undefined && { render }),
|
|
234
|
+
...(aes !== undefined && { aes }),
|
|
235
|
+
...(layer.data !== undefined && { data: layer.data }),
|
|
236
|
+
// Only `false` is expressible. Read as unknown so a raw JSON `inspect: true`
|
|
237
|
+
// is not rewritten to false — validate rejects non-false; typed input only
|
|
238
|
+
// admits false (#1065).
|
|
239
|
+
...((layer as { readonly inspect?: unknown }).inspect === false && {
|
|
240
|
+
inspect: false as const,
|
|
241
|
+
}),
|
|
242
|
+
...(params !== undefined && { params }),
|
|
243
|
+
};
|
|
244
|
+
return out as NormalizedLayerSpec;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function normalizeRuleAesInput(layer: LayerInput): LayerInput["aes"] {
|
|
248
|
+
if (layer.geom === "hline" && !isAnnotationRule(layer)) return { ...layer.aes, x: null };
|
|
249
|
+
if (layer.geom === "vline" && !isAnnotationRule(layer)) return { ...layer.aes, y: null };
|
|
250
|
+
return layer.aes;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function normalizeStatAes(
|
|
254
|
+
aes: Aes | undefined,
|
|
255
|
+
stat: string,
|
|
256
|
+
geom: LayerInput["geom"],
|
|
257
|
+
): Aes | undefined {
|
|
258
|
+
let normalized = normalizeStatPositionAes(aes, stat);
|
|
259
|
+
normalized = normalizeStatStyleAes(normalized, stat, geom);
|
|
260
|
+
return normalized;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function normalizeStatPositionAes(aes: Aes | undefined, stat: string): Aes | undefined {
|
|
264
|
+
if ((stat === "count" || stat === "bin") && aes?.y === undefined) {
|
|
265
|
+
return { ...aes, y: { stat: "count" } };
|
|
266
|
+
}
|
|
267
|
+
if (stat === "density" && aes?.y === undefined) return { ...aes, y: { stat: "density" } };
|
|
268
|
+
if (stat === "function" && aes?.y === undefined) return { ...aes, y: { stat: "y" } };
|
|
269
|
+
if (stat === "ecdf" && aes?.y === undefined) return { ...aes, y: { stat: "ecdf" } };
|
|
270
|
+
if (stat === "bindot" && aes?.y === undefined) return { ...aes, y: { stat: "stackpos" } };
|
|
271
|
+
return aes;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function normalizeStatStyleAes(
|
|
275
|
+
aes: Aes | undefined,
|
|
276
|
+
stat: string,
|
|
277
|
+
geom: LayerInput["geom"],
|
|
278
|
+
): Aes | undefined {
|
|
279
|
+
if (stat === "sum" && aes?.size === undefined) return { ...aes, size: { stat: "n" } };
|
|
280
|
+
if (stat === "bin_hex" && aes?.fill === undefined) return { ...aes, fill: { stat: "count" } };
|
|
281
|
+
if ((stat === "density_2d_filled" || geom === "density_2d_filled") && aes?.fill === undefined) {
|
|
282
|
+
return { ...aes, fill: { stat: "level" } };
|
|
283
|
+
}
|
|
284
|
+
if (stat === "bin_2d" && aes?.fill === undefined) return { ...aes, fill: { stat: "count" } };
|
|
285
|
+
return aes;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function normalizeLayerPosition(
|
|
289
|
+
layer: LayerInput,
|
|
290
|
+
defaultPosition: NormalizedLayerSpec["position"],
|
|
291
|
+
): NormalizedLayerSpec["position"] {
|
|
292
|
+
if (layer.geom === "jitter") return defaultPosition;
|
|
293
|
+
return "position" in layer && layer.position !== undefined ? layer.position : defaultPosition;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Canonicalize one facet field: bare string -> { field }; clone levels/labels. */
|
|
297
|
+
function normalizeFacetField(v: FacetInput["wrap"]): FacetSpec["wrap"] | undefined {
|
|
298
|
+
if (v === undefined) return undefined;
|
|
299
|
+
if (typeof v === "string") return { field: v };
|
|
300
|
+
const levels =
|
|
301
|
+
v.levels === undefined
|
|
302
|
+
? undefined
|
|
303
|
+
: ([...v.levels] as NonNullable<FacetSpec["wrap"]>["levels"]);
|
|
304
|
+
const labels = v.labels === undefined ? undefined : { ...v.labels };
|
|
305
|
+
return {
|
|
306
|
+
field: v.field,
|
|
307
|
+
...(levels !== undefined && { levels }),
|
|
308
|
+
...(labels !== undefined && { labels }),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Canonicalize facet strip chrome (position + show). */
|
|
313
|
+
function normalizeFacetStrip(strip: NonNullable<FacetInput["strip"]>): FacetSpec["strip"] {
|
|
314
|
+
const out: NonNullable<FacetSpec["strip"]> = {
|
|
315
|
+
...(strip.position !== undefined && { position: strip.position }),
|
|
316
|
+
...(strip.show !== undefined && { show: strip.show }),
|
|
317
|
+
};
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Canonicalize a facet input: bare-string fields -> { field }. */
|
|
322
|
+
function normalizeFacet(facet: FacetInput): FacetSpec {
|
|
323
|
+
const wrap = normalizeFacetField(facet.wrap);
|
|
324
|
+
const rows = normalizeFacetField(facet.rows);
|
|
325
|
+
const cols = normalizeFacetField(facet.cols);
|
|
326
|
+
const strip = facet.strip === undefined ? undefined : normalizeFacetStrip(facet.strip);
|
|
327
|
+
return {
|
|
328
|
+
...(wrap !== undefined && { wrap }),
|
|
329
|
+
...(rows !== undefined && { rows }),
|
|
330
|
+
...(cols !== undefined && { cols }),
|
|
331
|
+
...(facet.ncol !== undefined && { ncol: facet.ncol }),
|
|
332
|
+
...(facet.scales !== undefined && { scales: facet.scales }),
|
|
333
|
+
...(strip !== undefined && Object.keys(strip).length > 0 && { strip }),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function normalizeTheme(theme: ThemeName | ThemeSpec): ThemeName | ThemeSpec {
|
|
338
|
+
return typeof theme === "string" ? theme : { ...theme };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function normalizeGuide(guide: GuideSpec): GuideSpec {
|
|
342
|
+
return {
|
|
343
|
+
...guide,
|
|
344
|
+
...(guide.type !== "none" && guide.theme !== undefined && { theme: { ...guide.theme } }),
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const GUIDE_ORDER = [
|
|
349
|
+
"x",
|
|
350
|
+
"y",
|
|
351
|
+
"color",
|
|
352
|
+
"fill",
|
|
353
|
+
"size",
|
|
354
|
+
"linewidth",
|
|
355
|
+
"alpha",
|
|
356
|
+
"shape",
|
|
357
|
+
"linetype",
|
|
358
|
+
] as const;
|
|
359
|
+
|
|
360
|
+
function normalizeGuides(guides: GuidesSpec): GuidesSpec {
|
|
361
|
+
return Object.fromEntries(
|
|
362
|
+
GUIDE_ORDER.flatMap((aesthetic) => {
|
|
363
|
+
const guide = guides[aesthetic];
|
|
364
|
+
return guide === undefined ? [] : [[aesthetic, normalizeGuide(guide)]];
|
|
365
|
+
}),
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Canonicalize a SpecInput into a normalized PortableSpec (see module docs).
|
|
371
|
+
*
|
|
372
|
+
* The NormalizedSpec return type promises one thing the runtime enforces —
|
|
373
|
+
* canonicalGeom() has rewritten every alias geom. It promises nothing about an
|
|
374
|
+
* unknown geom: normalize() deliberately never throws on one (see below), so
|
|
375
|
+
* the type is only sound once validate() has passed on the result.
|
|
376
|
+
*/
|
|
377
|
+
export function normalize(input: SpecInput): NormalizedSpec {
|
|
378
|
+
const plotAes = normalizeAes(input.aes);
|
|
379
|
+
// Defaults canonicalize away: Cartesian/identity coord and a11y "auto" ARE
|
|
380
|
+
// the absent forms (one canonical form per concept).
|
|
381
|
+
const coord = normalizeCoord(input.coord);
|
|
382
|
+
const a11y = input.a11y === "force-svg" ? input.a11y : undefined;
|
|
383
|
+
const out: NormalizedSpec = {
|
|
384
|
+
...(input.$schema !== undefined && { $schema: input.$schema }),
|
|
385
|
+
// Defaults-edition stamping (Hadley lesson 13): absent -> current, so the
|
|
386
|
+
// spec's default look is frozen at authoring time (schema description).
|
|
387
|
+
edition: input.edition ?? CURRENT_EDITION,
|
|
388
|
+
...(input.data !== undefined && { data: input.data }),
|
|
389
|
+
...(input.datasets !== undefined && { datasets: input.datasets }),
|
|
390
|
+
layers: input.layers.map((layer) => normalizeLayer(layer, plotAes)),
|
|
391
|
+
...(input.facet !== undefined && { facet: normalizeFacet(input.facet) }),
|
|
392
|
+
...(coord !== undefined && { coord }),
|
|
393
|
+
...(input.scales !== undefined && { scales: normalizeScales(input.scales) }),
|
|
394
|
+
...(input.guides !== undefined && { guides: normalizeGuides(input.guides) }),
|
|
395
|
+
...(input.legend !== undefined && { legend: { ...input.legend } }),
|
|
396
|
+
...(input.labs !== undefined && { labs: { ...input.labs } }),
|
|
397
|
+
...(input.theme !== undefined && { theme: normalizeTheme(input.theme) }),
|
|
398
|
+
...(input.width !== undefined && { width: input.width }),
|
|
399
|
+
...(input.height !== undefined && { height: input.height }),
|
|
400
|
+
...(a11y !== undefined && { a11y }),
|
|
401
|
+
};
|
|
402
|
+
return out;
|
|
403
|
+
}
|