@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Liam O'Dea
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @ggts-sh/spec
|
|
2
|
+
|
|
3
|
+
[](https://app.codecov.io/gh/ggts-sh/ggts/tree/main/packages%2Fspec)
|
|
4
|
+
|
|
5
|
+
PortableSpec types, published JSON Schema, `normalize()`, two-tier
|
|
6
|
+
`validate()` with the agent error contract
|
|
7
|
+
(`{ code, path, message, allowed?, fix }`), `lintSpec()`, and the fluent
|
|
8
|
+
`gg()` / `aes()` builder. No DOM, no d3. Pre-1.0.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
bun add @ggts-sh/spec # or: npm install @ggts-sh/spec
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Install alone for validation and authoring without a renderer.
|
|
15
|
+
[`@ggts-sh/svelte`](https://www.npmjs.com/package/@ggts-sh/svelte)
|
|
16
|
+
re-exports this package.
|
|
17
|
+
|
|
18
|
+
## Quick example
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { gg, aes, validate } from "@ggts-sh/spec";
|
|
22
|
+
// constrained decoding / tool schemas
|
|
23
|
+
import schema from "@ggts-sh/spec/schema/v0.json";
|
|
24
|
+
|
|
25
|
+
const spec = gg(
|
|
26
|
+
[
|
|
27
|
+
{ year: "1835", value: 12 },
|
|
28
|
+
{ year: "2026", value: 31 },
|
|
29
|
+
],
|
|
30
|
+
aes({ x: "year", y: "value" }),
|
|
31
|
+
)
|
|
32
|
+
.geomLine()
|
|
33
|
+
.spec();
|
|
34
|
+
|
|
35
|
+
const result = validate(spec, {
|
|
36
|
+
profile: {
|
|
37
|
+
fields: [
|
|
38
|
+
{ name: "year", type: "temporal" },
|
|
39
|
+
{ name: "value", type: "quantitative" },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
lint: true,
|
|
43
|
+
});
|
|
44
|
+
if (!result.ok) {
|
|
45
|
+
// Apply fix.example at path, then re-validate.
|
|
46
|
+
// { code, path, message, allowed?, fix: { description, example } }
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Agent contract
|
|
51
|
+
|
|
52
|
+
- `validate(spec)` — shape only.
|
|
53
|
+
- `validate(spec, { profile })` — data-aware without shipping rows.
|
|
54
|
+
- `validate(spec, { lint: true })` — advisories for valid-but-questionable specs.
|
|
55
|
+
- Every error carries `fix.example`. Apply it at `path` and re-validate.
|
|
56
|
+
- PortableSpec is JSON-only: no `Date`, callbacks, or regular expressions.
|
|
57
|
+
Builder `Date` values canonicalize to ISO strings.
|
|
58
|
+
- JSON aes uses `{ field: "col" }` (bare strings are invalid in JSON). The
|
|
59
|
+
builder and Svelte props accept bare-string shorthand.
|
|
60
|
+
|
|
61
|
+
## Render
|
|
62
|
+
|
|
63
|
+
- Headless SVG: [`@ggts-sh/core`](https://www.npmjs.com/package/@ggts-sh/core)
|
|
64
|
+
(`renderToSVGString`)
|
|
65
|
+
- CLI loop (validation + warnings on stderr):
|
|
66
|
+
[`@ggts-sh/cli`](https://www.npmjs.com/package/@ggts-sh/cli)
|
|
67
|
+
(`ggts render`)
|
|
68
|
+
- Svelte 5:
|
|
69
|
+
[`@ggts-sh/svelte`](https://www.npmjs.com/package/@ggts-sh/svelte)
|
|
70
|
+
|
|
71
|
+
Schema: [schema/v0.json](https://ggts.sh/schema/v0.json) · Docs:
|
|
72
|
+
[ggts.sh](https://ggts.sh/) · Repo:
|
|
73
|
+
[github.com/ggts-sh/ggts](https://github.com/ggts-sh/ggts)
|
|
74
|
+
|
|
75
|
+
[MIT](https://github.com/ggts-sh/ggts/blob/main/LICENSE) © Liam O'Dea
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Version tag of the published schema artifact (`schema/v0.json`). */
|
|
2
|
+
export declare const SCHEMA_VERSION = "v0";
|
|
3
|
+
/**
|
|
4
|
+
* Build the publishable JSON Schema document (plain data, deterministic).
|
|
5
|
+
* The v0 schema remains explicitly unstable; served from the repo until
|
|
6
|
+
* hosting infrastructure exists (no $id URL is claimed yet).
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildSchemaArtifact(): Record<string, unknown>;
|
|
9
|
+
/** The artifact serialized exactly as `schema/v0.json` is committed. */
|
|
10
|
+
export declare function schemaArtifactJSON(): string;
|
|
11
|
+
//# sourceMappingURL=artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":"AAoDA,uEAAuE;AACvE,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAe7D;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
package/dist/artifact.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema artifact builder (decision 0004: TypeBox `Type.Module`
|
|
3
|
+
* named-defs form is the shippable schema).
|
|
4
|
+
*
|
|
5
|
+
* Publish-time transforms applied here, exactly as the decision record
|
|
6
|
+
* prescribes:
|
|
7
|
+
* 1. `$ref: "Name"` (TypeBox $id-anchored refs) -> `#/$defs/Name`
|
|
8
|
+
* (standard JSON Pointer form; strict provider subsets need it).
|
|
9
|
+
* 2. `patternProperties: { "^(.*)$": S }` (TypeBox `Type.Record` emission)
|
|
10
|
+
* -> `additionalProperties: S` (semantically identical for that pattern,
|
|
11
|
+
* and inside the portable keyword set).
|
|
12
|
+
* 3. Per-def `$id` markers removed (the artifact anchors defs under $defs).
|
|
13
|
+
*
|
|
14
|
+
* `scripts/emit-schema.ts` writes the result to `schema/v0.json`; a test
|
|
15
|
+
* asserts the committed artifact matches a fresh build (staleness guard).
|
|
16
|
+
*/
|
|
17
|
+
import { PlotSpecSchema } from "./schema.js";
|
|
18
|
+
// TypeBox 0.x emitted `^(.*)$`; TypeBox 1.x emits `^.*$`. Both are
|
|
19
|
+
// "match any property name" records and rewrite to additionalProperties.
|
|
20
|
+
const RECORD_PATTERNS = new Set(["^(.*)$", "^.*$"]);
|
|
21
|
+
function transform(node, defNames) {
|
|
22
|
+
if (Array.isArray(node))
|
|
23
|
+
return node.map((n) => transform(n, defNames));
|
|
24
|
+
if (typeof node !== "object" || node === null)
|
|
25
|
+
return node;
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const [key, value] of Object.entries(node)) {
|
|
28
|
+
if (key === "$id" && typeof value === "string" && defNames.has(value))
|
|
29
|
+
continue;
|
|
30
|
+
if (key === "$ref" && typeof value === "string" && defNames.has(value)) {
|
|
31
|
+
out[key] = `#/$defs/${value}`;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (key === "patternProperties" &&
|
|
35
|
+
typeof value === "object" &&
|
|
36
|
+
value !== null &&
|
|
37
|
+
Object.keys(value).length === 1) {
|
|
38
|
+
const pattern = Object.keys(value)[0];
|
|
39
|
+
if (RECORD_PATTERNS.has(pattern)) {
|
|
40
|
+
out["additionalProperties"] = transform(value[pattern], defNames);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
out[key] = transform(value, defNames);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** Version tag of the published schema artifact (`schema/v0.json`). */
|
|
49
|
+
export const SCHEMA_VERSION = "v0";
|
|
50
|
+
/**
|
|
51
|
+
* Build the publishable JSON Schema document (plain data, deterministic).
|
|
52
|
+
* The v0 schema remains explicitly unstable; served from the repo until
|
|
53
|
+
* hosting infrastructure exists (no $id URL is claimed yet).
|
|
54
|
+
*/
|
|
55
|
+
export function buildSchemaArtifact() {
|
|
56
|
+
// JSON round-trip drops TypeBox's symbol keys and proves JSON-plainness.
|
|
57
|
+
const raw = JSON.parse(JSON.stringify(PlotSpecSchema));
|
|
58
|
+
const defNames = new Set(Object.keys(raw.$defs));
|
|
59
|
+
const transformed = transform(raw, defNames);
|
|
60
|
+
return {
|
|
61
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
62
|
+
title: "ggts PortableSpec",
|
|
63
|
+
description: "A ggts plot specification (schema v0 — UNSTABLE; served from the repo until schema hosting exists).",
|
|
64
|
+
...transformed,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** The artifact serialized exactly as `schema/v0.json` is committed. */
|
|
68
|
+
export function schemaArtifactJSON() {
|
|
69
|
+
return JSON.stringify(buildSchemaArtifact(), null, 2) + "\n";
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,mEAAmE;AACnE,yEAAyE;AACzE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,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G,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,yEAAyE;IACzE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAGpD,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,EAAE,QAAQ,CAA4B,CAAC;IACxE,OAAO;QACL,OAAO,EAAE,8CAA8C;QACvD,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,qGAAqG;QACvG,GAAG,WAAW;KACf,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluent builder core: state, layer/facet/coord/labs/theme/spec.
|
|
3
|
+
* Geom sugar mixin: builder-geoms.ts. Scale sugar mixin: builder-scales.ts.
|
|
4
|
+
* Public GGBuilder: builder.ts.
|
|
5
|
+
*/
|
|
6
|
+
import { type CoordFixedOptions, type CoordPolarOptions, type CoordRadialOptions, type CoordSfOptions, type CoordTransformOptions } from "./coord-helpers.js";
|
|
7
|
+
import type { AesInput, FacetInput, LayerInput, SpecInput } from "./normalize.js";
|
|
8
|
+
import { type AuthoringDataRef, type DataInput } from "./builder-data.js";
|
|
9
|
+
import type { A11yMode, GuidesSpec, Labs, LegendSpec, PortableSpec, PositionParams, RenderBackend, Scales, ThemeName, ThemeSpec } from "./schema.js";
|
|
10
|
+
import type { GGBuilder } from "./builder.js";
|
|
11
|
+
interface BuilderState {
|
|
12
|
+
readonly data?: AuthoringDataRef;
|
|
13
|
+
readonly aes?: AesInput;
|
|
14
|
+
readonly layers: readonly LayerInput[];
|
|
15
|
+
readonly facet?: FacetInput;
|
|
16
|
+
readonly coord?: SpecInput["coord"];
|
|
17
|
+
readonly a11y?: A11yMode;
|
|
18
|
+
readonly scales?: Scales;
|
|
19
|
+
readonly guides?: GuidesSpec;
|
|
20
|
+
readonly legend?: LegendSpec;
|
|
21
|
+
readonly labs?: Labs;
|
|
22
|
+
readonly theme?: ThemeName | ThemeSpec;
|
|
23
|
+
readonly width?: number;
|
|
24
|
+
readonly height?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Assemble a LayerInput from a geom name and sugar options. */
|
|
27
|
+
export declare function layerFrom(geom: LayerInput["geom"], options: {
|
|
28
|
+
aes?: AesInput;
|
|
29
|
+
render?: RenderBackend;
|
|
30
|
+
position?: string;
|
|
31
|
+
positionParams?: PositionParams;
|
|
32
|
+
stat?: string;
|
|
33
|
+
data?: DataInput;
|
|
34
|
+
inspect?: false;
|
|
35
|
+
}): LayerInput;
|
|
36
|
+
/**
|
|
37
|
+
* Immutable plot builder core (layer/facet/coord/labs/theme/spec).
|
|
38
|
+
* Geom sugar: WithBuilderGeoms. Scale sugar: WithBuilderScales.
|
|
39
|
+
* Final public class is GGBuilder (builder.ts). Not a public package export.
|
|
40
|
+
*/
|
|
41
|
+
export declare class GGBuilderCore {
|
|
42
|
+
#private;
|
|
43
|
+
constructor(state: BuilderState);
|
|
44
|
+
/** Add a layer (canonical form — the geom* methods are sugar for this). */
|
|
45
|
+
layer(layer: LayerInput): GGBuilder;
|
|
46
|
+
/**
|
|
47
|
+
* Facet into small multiples: wrap form ({ wrap, ncol? }) or grid form
|
|
48
|
+
* ({ rows, cols }). Bare strings are field shorthand. Field objects accept
|
|
49
|
+
* closed `levels` order and a display `labels` map. `strip.position` is
|
|
50
|
+
* top/bottom/left/right (default top); `strip.show: false` hides strip
|
|
51
|
+
* chrome. scales controls per-panel positional-scale freedom ("fixed" default).
|
|
52
|
+
*/
|
|
53
|
+
facet(facet: FacetInput): GGBuilder;
|
|
54
|
+
/** Set the coordinate system ("flip" is shorthand for { type: "flip" }). */
|
|
55
|
+
coord(coord: SpecInput["coord"] | "flip"): GGBuilder;
|
|
56
|
+
/** Sugar for .coord("flip") — THE horizontal-composition mechanism. */
|
|
57
|
+
coordFlip(): GGBuilder;
|
|
58
|
+
/** Configure a post-stat coordinate transform (distinct from scale transforms). */
|
|
59
|
+
coordTransform(options?: CoordTransformOptions): GGBuilder;
|
|
60
|
+
/** Preserve a physical y-unit/x-unit ratio in the fitted data rectangle. */
|
|
61
|
+
coordFixed(options?: CoordFixedOptions): GGBuilder;
|
|
62
|
+
/** Equal-unit spelling of coordFixed(). */
|
|
63
|
+
coordEqual(options?: CoordFixedOptions): GGBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Fixed-aspect coordinates for already-projected geom_sf maps (ggplot2
|
|
66
|
+
* coord_sf subset; #809). No CRS reproject in v1.
|
|
67
|
+
*/
|
|
68
|
+
coordSf(options?: CoordSfOptions): GGBuilder;
|
|
69
|
+
/**
|
|
70
|
+
* Polar/radial coordinates (ggplot2 coord_radial). Pie charts use
|
|
71
|
+
* theta: "y" with expand: false on a stacked bar/col.
|
|
72
|
+
*/
|
|
73
|
+
coordRadial(options?: CoordRadialOptions): GGBuilder;
|
|
74
|
+
/**
|
|
75
|
+
* ggplot2 coord_polar alias — emits type "radial" with polar defaults
|
|
76
|
+
* (clip on; direction -1 → reverse theta).
|
|
77
|
+
*/
|
|
78
|
+
coordPolar(options?: CoordPolarOptions): GGBuilder;
|
|
79
|
+
/** Set the accessibility mode ("force-svg" keeps every layer in SVG). */
|
|
80
|
+
a11y(mode: A11yMode): GGBuilder;
|
|
81
|
+
/** Configure scales (merged per scale over previous calls). */
|
|
82
|
+
scales(scales: Scales): GGBuilder;
|
|
83
|
+
/** Configure appearance-only guides (merged per aesthetic over previous calls). */
|
|
84
|
+
guides(guides: GuidesSpec): GGBuilder;
|
|
85
|
+
/** Configure the legacy legend entry order (merged over previous calls). */
|
|
86
|
+
legend(legend: LegendSpec): GGBuilder;
|
|
87
|
+
/** Set the theme: a registered name or an object with role overrides. */
|
|
88
|
+
theme(theme: ThemeName | ThemeSpec): GGBuilder;
|
|
89
|
+
/** Set human-readable labels (merged over previously set labels). */
|
|
90
|
+
labs(labs: Labs): GGBuilder;
|
|
91
|
+
/**
|
|
92
|
+
* Normalize only: channel shorthand, geom defaults, aes inheritance.
|
|
93
|
+
* Does not load TypeBox — the render pipeline runs structural gates; agents
|
|
94
|
+
* that need full schema validation should call {@link spec} (full package)
|
|
95
|
+
* or `validate()` explicitly.
|
|
96
|
+
*/
|
|
97
|
+
toPortable(): PortableSpec;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=builder-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-core.d.ts","sourceRoot":"","sources":["../src/builder-core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,O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GBuilder: builder.ts.
|
|
5
|
+
*/
|
|
6
|
+
import { coordFixed, coordPolar, coordRadial, coordSf, coordTransform, } from "./coord-helpers.js";
|
|
7
|
+
import { normalize } from "./normalize.js";
|
|
8
|
+
import { calendarDateFields, toAuthoringDataRef, toDataRef, } from "./builder-data.js";
|
|
9
|
+
/** Assemble a LayerInput from a geom name and sugar options. */
|
|
10
|
+
export function layerFrom(geom, options) {
|
|
11
|
+
const { aes: layerAes, render, position, positionParams, stat, data, inspect, ...params } = options;
|
|
12
|
+
// Do not snapshot here: every geom sugar path is `this.layer(layerFrom(...))`,
|
|
13
|
+
// and `layer()` is the single defensive-copy point (#1280). Snapshotting in
|
|
14
|
+
// both places deep-copied every row twice on `geom*({ data })`.
|
|
15
|
+
const withData = data === undefined ? {} : { data: data };
|
|
16
|
+
return {
|
|
17
|
+
geom,
|
|
18
|
+
...(stat !== undefined && { stat }),
|
|
19
|
+
...(position !== undefined && { position }),
|
|
20
|
+
...(positionParams !== undefined && { positionParams }),
|
|
21
|
+
...(render !== undefined && { render }),
|
|
22
|
+
...(inspect !== undefined && { inspect }),
|
|
23
|
+
...(layerAes !== undefined && { aes: layerAes }),
|
|
24
|
+
...withData,
|
|
25
|
+
...(Object.keys(params).length > 0 && { params }),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Immutable plot builder core (layer/facet/coord/labs/theme/spec).
|
|
30
|
+
* Geom sugar: WithBuilderGeoms. Scale sugar: WithBuilderScales.
|
|
31
|
+
* Final public class is GGBuilder (builder.ts). Not a public package export.
|
|
32
|
+
*/
|
|
33
|
+
export class GGBuilderCore {
|
|
34
|
+
#state;
|
|
35
|
+
constructor(state) {
|
|
36
|
+
this.#state = state;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Clone with a state patch. Uses `this.constructor` so the WithBuilderScales
|
|
40
|
+
* subclass (GGBuilder) is preserved across immutable transitions.
|
|
41
|
+
*/
|
|
42
|
+
#with(patch) {
|
|
43
|
+
return new this.constructor({
|
|
44
|
+
...this.#state,
|
|
45
|
+
...patch,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** Add a layer (canonical form — the geom* methods are sugar for this). */
|
|
49
|
+
layer(layer) {
|
|
50
|
+
// Sole snapshot for layer data: geom sugar and direct `.layer({ data })`
|
|
51
|
+
// both land here. Later mutation of caller-owned arrays cannot leak into
|
|
52
|
+
// `.spec()`; portable Date→ISO conversion still happens in `toPortable`.
|
|
53
|
+
if (layer.data === undefined) {
|
|
54
|
+
return this.#with({ layers: [...this.#state.layers, layer] });
|
|
55
|
+
}
|
|
56
|
+
// layer.data may be raw DataInput (geom sugar) or an AuthoringDataRef
|
|
57
|
+
// already; toAuthoringDataRef accepts both.
|
|
58
|
+
const snapped = {
|
|
59
|
+
...layer,
|
|
60
|
+
data: toAuthoringDataRef(layer.data),
|
|
61
|
+
};
|
|
62
|
+
return this.#with({ layers: [...this.#state.layers, snapped] });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Facet into small multiples: wrap form ({ wrap, ncol? }) or grid form
|
|
66
|
+
* ({ rows, cols }). Bare strings are field shorthand. Field objects accept
|
|
67
|
+
* closed `levels` order and a display `labels` map. `strip.position` is
|
|
68
|
+
* top/bottom/left/right (default top); `strip.show: false` hides strip
|
|
69
|
+
* chrome. scales controls per-panel positional-scale freedom ("fixed" default).
|
|
70
|
+
*/
|
|
71
|
+
facet(facet) {
|
|
72
|
+
return this.#with({ facet });
|
|
73
|
+
}
|
|
74
|
+
/** Set the coordinate system ("flip" is shorthand for { type: "flip" }). */
|
|
75
|
+
coord(coord) {
|
|
76
|
+
return this.#with({ coord: coord === "flip" ? { type: "flip" } : coord });
|
|
77
|
+
}
|
|
78
|
+
/** Sugar for .coord("flip") — THE horizontal-composition mechanism. */
|
|
79
|
+
coordFlip() {
|
|
80
|
+
return this.coord("flip");
|
|
81
|
+
}
|
|
82
|
+
/** Configure a post-stat coordinate transform (distinct from scale transforms). */
|
|
83
|
+
coordTransform(options = {}) {
|
|
84
|
+
return this.coord(coordTransform(options));
|
|
85
|
+
}
|
|
86
|
+
/** Preserve a physical y-unit/x-unit ratio in the fitted data rectangle. */
|
|
87
|
+
coordFixed(options = {}) {
|
|
88
|
+
return this.coord(coordFixed(options));
|
|
89
|
+
}
|
|
90
|
+
/** Equal-unit spelling of coordFixed(). */
|
|
91
|
+
coordEqual(options = {}) {
|
|
92
|
+
return this.coord(coordFixed(options));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Fixed-aspect coordinates for already-projected geom_sf maps (ggplot2
|
|
96
|
+
* coord_sf subset; #809). No CRS reproject in v1.
|
|
97
|
+
*/
|
|
98
|
+
coordSf(options = {}) {
|
|
99
|
+
return this.coord(coordSf(options));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Polar/radial coordinates (ggplot2 coord_radial). Pie charts use
|
|
103
|
+
* theta: "y" with expand: false on a stacked bar/col.
|
|
104
|
+
*/
|
|
105
|
+
coordRadial(options = {}) {
|
|
106
|
+
return this.coord(coordRadial(options));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* ggplot2 coord_polar alias — emits type "radial" with polar defaults
|
|
110
|
+
* (clip on; direction -1 → reverse theta).
|
|
111
|
+
*/
|
|
112
|
+
coordPolar(options = {}) {
|
|
113
|
+
return this.coord(coordPolar(options));
|
|
114
|
+
}
|
|
115
|
+
/** Set the accessibility mode ("force-svg" keeps every layer in SVG). */
|
|
116
|
+
a11y(mode) {
|
|
117
|
+
return this.#with({ a11y: mode });
|
|
118
|
+
}
|
|
119
|
+
/** Configure scales (merged per scale over previous calls). */
|
|
120
|
+
scales(scales) {
|
|
121
|
+
return this.#with({ scales: { ...this.#state.scales, ...scales } });
|
|
122
|
+
}
|
|
123
|
+
/** Configure appearance-only guides (merged per aesthetic over previous calls). */
|
|
124
|
+
guides(guides) {
|
|
125
|
+
return this.#with({ guides: { ...this.#state.guides, ...guides } });
|
|
126
|
+
}
|
|
127
|
+
/** Configure the legacy legend entry order (merged over previous calls). */
|
|
128
|
+
legend(legend) {
|
|
129
|
+
return this.#with({ legend: { ...this.#state.legend, ...legend } });
|
|
130
|
+
}
|
|
131
|
+
/** Set the theme: a registered name or an object with role overrides. */
|
|
132
|
+
theme(theme) {
|
|
133
|
+
return this.#with({ theme });
|
|
134
|
+
}
|
|
135
|
+
/** Set human-readable labels (merged over previously set labels). */
|
|
136
|
+
labs(labs) {
|
|
137
|
+
return this.#with({ labs: { ...this.#state.labs, ...labs } });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Normalize only: channel shorthand, geom defaults, aes inheritance.
|
|
141
|
+
* Does not load TypeBox — the render pipeline runs structural gates; agents
|
|
142
|
+
* that need full schema validation should call {@link spec} (full package)
|
|
143
|
+
* or `validate()` explicitly.
|
|
144
|
+
*/
|
|
145
|
+
toPortable() {
|
|
146
|
+
const { data, aes: plotAes, layers, facet, coord, a11y, scales, guides, legend, labs, theme, width, height, } = this.#state;
|
|
147
|
+
const calendarFields = calendarDateFields(this.#state);
|
|
148
|
+
const portableLayers = layers.map((layer) => {
|
|
149
|
+
if (layer.data === undefined)
|
|
150
|
+
return layer;
|
|
151
|
+
// layer() stores AuthoringDataRef snapshots as LayerInput.data; portable
|
|
152
|
+
// ISO conversion runs here with the final calendar-date field set.
|
|
153
|
+
return {
|
|
154
|
+
...layer,
|
|
155
|
+
data: toDataRef(layer.data, calendarFields),
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
const input = {
|
|
159
|
+
...(data !== undefined && { data: toDataRef(data, calendarFields) }),
|
|
160
|
+
...(plotAes !== undefined && { aes: plotAes }),
|
|
161
|
+
layers: portableLayers,
|
|
162
|
+
...(facet !== undefined && { facet }),
|
|
163
|
+
...(coord !== undefined && { coord }),
|
|
164
|
+
...(a11y !== undefined && { a11y }),
|
|
165
|
+
...(scales !== undefined && { scales }),
|
|
166
|
+
...(guides !== undefined && { guides }),
|
|
167
|
+
...(legend !== undefined && { legend }),
|
|
168
|
+
...(labs !== undefined && { labs }),
|
|
169
|
+
...(theme !== undefined && { theme }),
|
|
170
|
+
...(width !== undefined && { width }),
|
|
171
|
+
...(height !== undefined && { height }),
|
|
172
|
+
};
|
|
173
|
+
return normalize(input);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=builder-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-core.js","sourceRoot":"","sources":["../src/builder-core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,OAAO,EACP,cAAc,GAMf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,GAGV,MAAM,mBAAmB,CAAC;AA+B3B,gEAAgE;AAChE,MAAM,UAAU,SAAS,CACvB,IAAwB,EACxB,OAQC;IAED,MAAM,EACJ,GAAG,EAAE,QAAQ,EACb,MAAM,EACN,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,GAAG,MAAM,EACV,GAAG,OAAO,CAAC;IACZ,+EAA+E;IAC/E,4EAA4E;IAC5E,gEAAgE;IAChE,MAAM,QAAQ,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAA0B,EAAE,CAAC;IAChF,OAAO;QACL,IAAI;QACJ,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC;QACnC,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,EAAE,cAAc,EAAE,CAAC;QACvD,GAAG,CAAC,MAAM,KAAK,SAAS,IA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;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder/Svelte authoring data conversion.
|
|
3
|
+
*
|
|
4
|
+
* Accepts rows, columns, or named DataRef forms with Date cells; snapshots
|
|
5
|
+
* inputs immutably for `gg()`; and materializes portable CellValue data
|
|
6
|
+
* (ISO date/datetime strings) for `.spec()`. Geom sugar and GGBuilder live
|
|
7
|
+
* in builder.ts.
|
|
8
|
+
*/
|
|
9
|
+
import type { AesInput } from "./normalize.js";
|
|
10
|
+
import type { CellValue, DataRef, Scales } from "./schema.js";
|
|
11
|
+
/** A builder/Svelte data cell. Dates canonicalize to ISO before validation. */
|
|
12
|
+
export type AuthoringCellValue = CellValue | Date;
|
|
13
|
+
export type AuthoringRows = readonly Readonly<Record<string, AuthoringCellValue>>[];
|
|
14
|
+
export type AuthoringColumns = Readonly<Record<string, readonly AuthoringCellValue[]>>;
|
|
15
|
+
export type AuthoringDataRef = {
|
|
16
|
+
values: AuthoringRows;
|
|
17
|
+
} | {
|
|
18
|
+
columns: AuthoringColumns;
|
|
19
|
+
} | {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
/** Data accepted by gg(): authoring rows, columns, or a data reference. */
|
|
23
|
+
export type DataInput = AuthoringRows | AuthoringColumns | AuthoringDataRef;
|
|
24
|
+
export declare function toAuthoringDataRef(data: DataInput): AuthoringDataRef;
|
|
25
|
+
export declare function toDataRef(data: AuthoringDataRef, calendarFields: ReadonlySet<string>): DataRef;
|
|
26
|
+
/** Minimal state slice needed to decide calendar-date ISO truncation. */
|
|
27
|
+
export interface BuilderCalendarSource {
|
|
28
|
+
readonly aes?: AesInput;
|
|
29
|
+
readonly layers: readonly {
|
|
30
|
+
readonly aes?: AesInput;
|
|
31
|
+
}[];
|
|
32
|
+
readonly scales?: Scales;
|
|
33
|
+
}
|
|
34
|
+
/** Fields mapped on scales with temporalKind "date" (calendar ISO date cells). */
|
|
35
|
+
export declare function calendarDateFields(state: BuilderCalendarSource): ReadonlySet<string>;
|
|
36
|
+
//# sourceMappingURL=builder-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-data.d.ts","sourceRoot":"","sources":["../src/builder-data.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE9D,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAAC;AAClD,MAAM,MAAM,aAAa,GAAG,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC;AACpF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC,CAAC,CAAC;AACvF,MAAM,MAAM,gBAAgB,GACxB;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,GACzB;IAAE,OAAO,EAAE,gBAAgB,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AA6C5E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,gBAAgB,CAQpE;AAsCD,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAI9F;AAOD,yEAAyE;AACzE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS;QAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAA;KAAE,EAAE,CAAC;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,WAAW,CAAC,MAAM,CAAC,CAuBpF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder/Svelte authoring data conversion.
|
|
3
|
+
*
|
|
4
|
+
* Accepts rows, columns, or named DataRef forms with Date cells; snapshots
|
|
5
|
+
* inputs immutably for `gg()`; and materializes portable CellValue data
|
|
6
|
+
* (ISO date/datetime strings) for `.spec()`. Geom sugar and GGBuilder live
|
|
7
|
+
* in builder.ts.
|
|
8
|
+
*/
|
|
9
|
+
function isDataRef(data) {
|
|
10
|
+
if (Array.isArray(data))
|
|
11
|
+
return false;
|
|
12
|
+
const keys = Object.keys(data);
|
|
13
|
+
if (keys.length !== 1)
|
|
14
|
+
return false;
|
|
15
|
+
const key = keys[0];
|
|
16
|
+
if (key === "name")
|
|
17
|
+
return typeof data.name === "string";
|
|
18
|
+
if (key === "values")
|
|
19
|
+
return Array.isArray(data.values);
|
|
20
|
+
if (key === "columns") {
|
|
21
|
+
const columns = data.columns;
|
|
22
|
+
return typeof columns === "object" && columns !== null && !Array.isArray(columns);
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function snapshotCell(value) {
|
|
27
|
+
return value instanceof Date ? new Date(value.getTime()) : value;
|
|
28
|
+
}
|
|
29
|
+
/** True when any cell is a Date (needs clone-on-snapshot / ISO materialization). */
|
|
30
|
+
function columnHasDate(values) {
|
|
31
|
+
for (let i = 0; i < values.length; i++) {
|
|
32
|
+
if (values[i] instanceof Date)
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
function snapshotRows(rows) {
|
|
38
|
+
return rows.map((row) => Object.fromEntries(Object.entries(row).map(([key, value]) => [key, snapshotCell(value)])));
|
|
39
|
+
}
|
|
40
|
+
function snapshotColumns(columns) {
|
|
41
|
+
return Object.fromEntries(Object.entries(columns).map(([key, values]) => {
|
|
42
|
+
// No Date cells: shallow-copy the column (slice) instead of per-cell map.
|
|
43
|
+
// Isolates length/index mutation; ~4× faster on 30k-point competitive data.
|
|
44
|
+
if (!columnHasDate(values))
|
|
45
|
+
return [key, values.slice()];
|
|
46
|
+
return [key, values.map((value) => snapshotCell(value))];
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
export function toAuthoringDataRef(data) {
|
|
50
|
+
if (Array.isArray(data))
|
|
51
|
+
return { values: snapshotRows(data) };
|
|
52
|
+
if (isDataRef(data)) {
|
|
53
|
+
if ("name" in data)
|
|
54
|
+
return data;
|
|
55
|
+
if ("values" in data)
|
|
56
|
+
return { values: snapshotRows(data.values) };
|
|
57
|
+
return { columns: snapshotColumns(data.columns) };
|
|
58
|
+
}
|
|
59
|
+
return { columns: snapshotColumns(data) };
|
|
60
|
+
}
|
|
61
|
+
function portableCell(value, calendarDate) {
|
|
62
|
+
if (!(value instanceof Date))
|
|
63
|
+
return value;
|
|
64
|
+
const iso = value.toISOString();
|
|
65
|
+
return calendarDate ? iso.slice(0, 10) : iso;
|
|
66
|
+
}
|
|
67
|
+
function portableRows(rows, calendarFields) {
|
|
68
|
+
return rows.map((row) => Object.fromEntries(Object.entries(row).map(([key, value]) => [
|
|
69
|
+
key,
|
|
70
|
+
portableCell(value, calendarFields.has(key)),
|
|
71
|
+
])));
|
|
72
|
+
}
|
|
73
|
+
function portableColumns(columns, calendarFields) {
|
|
74
|
+
return Object.fromEntries(Object.entries(columns).map(([key, values]) => {
|
|
75
|
+
// Already-snapshotted non-Date columns need no ISO rewrite — share the
|
|
76
|
+
// array. Second O(n) map was a top cost on line-3×10k toPortable().
|
|
77
|
+
if (!calendarFields.has(key) && !columnHasDate(values)) {
|
|
78
|
+
return [key, values];
|
|
79
|
+
}
|
|
80
|
+
return [key, values.map((value) => portableCell(value, calendarFields.has(key)))];
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
export function toDataRef(data, calendarFields) {
|
|
84
|
+
if ("name" in data)
|
|
85
|
+
return data;
|
|
86
|
+
if ("values" in data)
|
|
87
|
+
return { values: portableRows(data.values, calendarFields) };
|
|
88
|
+
return { columns: portableColumns(data.columns, calendarFields) };
|
|
89
|
+
}
|
|
90
|
+
function mappedField(value) {
|
|
91
|
+
if (typeof value === "string")
|
|
92
|
+
return value;
|
|
93
|
+
return value !== undefined && value !== null && "field" in value ? value.field : null;
|
|
94
|
+
}
|
|
95
|
+
/** Fields mapped on scales with temporalKind "date" (calendar ISO date cells). */
|
|
96
|
+
export function calendarDateFields(state) {
|
|
97
|
+
const fields = new Set();
|
|
98
|
+
const mappings = [
|
|
99
|
+
["x", ["x", "xmin", "xmax", "xend"]],
|
|
100
|
+
["y", ["y", "ymin", "ymax", "yend"]],
|
|
101
|
+
["color", ["color"]],
|
|
102
|
+
["fill", ["fill"]],
|
|
103
|
+
["size", ["size"]],
|
|
104
|
+
["linewidth", ["linewidth"]],
|
|
105
|
+
["alpha", ["alpha"]],
|
|
106
|
+
];
|
|
107
|
+
for (const [scale, channels] of mappings) {
|
|
108
|
+
if (state.scales?.[scale]?.temporalKind !== "date")
|
|
109
|
+
continue;
|
|
110
|
+
for (const channel of channels) {
|
|
111
|
+
const plotField = mappedField(state.aes?.[channel]);
|
|
112
|
+
if (plotField !== null)
|
|
113
|
+
fields.add(plotField);
|
|
114
|
+
for (const layer of state.layers) {
|
|
115
|
+
const layerField = mappedField(layer.aes?.[channel]);
|
|
116
|
+
if (layerField !== null)
|
|
117
|
+
fields.add(layerField);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return fields;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=builder-data.js.map
|