@carto/api-client 0.5.5-alpha.0 → 0.5.6-alpha.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.
@@ -99,7 +99,6 @@ var require_thenBy_module = __commonJS({
99
99
  // src/index.ts
100
100
  var src_exports = {};
101
101
  __export(src_exports, {
102
- AGGREGATION: () => AGGREGATION,
103
102
  ApiVersion: () => ApiVersion,
104
103
  BASEMAP: () => basemap_styles_default,
105
104
  CartoAPIError: () => CartoAPIError,
@@ -149,7 +148,6 @@ __export(src_exports, {
149
148
  getApplicableFilters: () => getApplicableFilters,
150
149
  getClient: () => getClient,
151
150
  getColorAccessor: () => getColorAccessor,
152
- getColorValueAccessor: () => getColorValueAccessor,
153
151
  getColumnNameFromGeoColumn: () => getColumnNameFromGeoColumn,
154
152
  getDataFilterExtensionProps: () => getDataFilterExtensionProps,
155
153
  getDefaultAggregationExpColumnAliasForLayerType: () => getDefaultAggregationExpColumnAliasForLayerType,
@@ -3351,9 +3349,9 @@ function compare(x, y) {
3351
3349
  for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
3352
3350
  return k == l ? 0 : k > l ^ a ? 1 : -1;
3353
3351
  }
3354
- function intCheck(n, min3, max3, name) {
3355
- if (n < min3 || n > max3 || n !== mathfloor(n)) {
3356
- throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min3 || n > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
3352
+ function intCheck(n, min2, max2, name) {
3353
+ if (n < min2 || n > max2 || n !== mathfloor(n)) {
3354
+ throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min2 || n > max2 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
3357
3355
  }
3358
3356
  }
3359
3357
  function isOdd(n) {
@@ -6521,7 +6519,10 @@ var WidgetRemoteSource = class extends WidgetSource {
6521
6519
  spatialFiltersMode,
6522
6520
  ...params
6523
6521
  } = options;
6524
- const { column, operation: operation2, operationColumn } = params;
6522
+ const { column, operation: operation2, operationColumn, operationExp } = params;
6523
+ if (operation2 === "custom") {
6524
+ assert2(operationExp, "operationExp is required for custom operation");
6525
+ }
6525
6526
  return executeModel({
6526
6527
  model: "category",
6527
6528
  source: {
@@ -6532,6 +6533,7 @@ var WidgetRemoteSource = class extends WidgetSource {
6532
6533
  params: {
6533
6534
  column,
6534
6535
  operation: operation2,
6536
+ operationExp,
6535
6537
  operationColumn: operationColumn || column
6536
6538
  },
6537
6539
  opts: { signal, headers: this.props.headers }
@@ -6577,6 +6579,9 @@ var WidgetRemoteSource = class extends WidgetSource {
6577
6579
  ...params
6578
6580
  } = options;
6579
6581
  const { column, operation: operation2 } = params;
6582
+ if (operation2 === "custom") {
6583
+ assert2(operationExp, "operationExp is required for custom operation");
6584
+ }
6580
6585
  return executeModel({
6581
6586
  model: "formula",
6582
6587
  source: {
@@ -6715,12 +6720,16 @@ var WidgetRemoteSource = class extends WidgetSource {
6715
6720
  operationColumn,
6716
6721
  joinOperation,
6717
6722
  operation: operation2,
6723
+ operationExp,
6718
6724
  stepSize,
6719
6725
  stepMultiplier,
6720
6726
  splitByCategory,
6721
6727
  splitByCategoryLimit,
6722
6728
  splitByCategoryValues
6723
6729
  } = params;
6730
+ if (operation2 === "custom") {
6731
+ assert2(operationExp, "operationExp is required for custom operation");
6732
+ }
6724
6733
  return executeModel({
6725
6734
  model: "timeseries",
6726
6735
  source: {
@@ -6735,6 +6744,7 @@ var WidgetRemoteSource = class extends WidgetSource {
6735
6744
  operationColumn: operationColumn || column,
6736
6745
  joinOperation,
6737
6746
  operation: operation2,
6747
+ operationExp,
6738
6748
  splitByCategory,
6739
6749
  splitByCategoryLimit,
6740
6750
  splitByCategoryValues
@@ -6831,11 +6841,11 @@ function min(values, keys, joinOperation) {
6831
6841
  Infinity
6832
6842
  );
6833
6843
  }
6834
- let min3 = Number.POSITIVE_INFINITY;
6844
+ let min2 = Number.POSITIVE_INFINITY;
6835
6845
  for (const value of values) {
6836
- min3 = Math.min(min3, value);
6846
+ min2 = Math.min(min2, value);
6837
6847
  }
6838
- return min3;
6848
+ return min2;
6839
6849
  }
6840
6850
  function max(values, keys, joinOperation) {
6841
6851
  const normalizedKeys = normalizeKeys(keys);
@@ -6845,11 +6855,11 @@ function max(values, keys, joinOperation) {
6845
6855
  -Infinity
6846
6856
  );
6847
6857
  }
6848
- let max3 = Number.NEGATIVE_INFINITY;
6858
+ let max2 = Number.NEGATIVE_INFINITY;
6849
6859
  for (const value of values) {
6850
- max3 = Math.max(max3, value);
6860
+ max2 = Math.max(max2, value);
6851
6861
  }
6852
- return max3;
6862
+ return max2;
6853
6863
  }
6854
6864
  function normalizeKeys(keys) {
6855
6865
  return Array.isArray(keys) ? keys : typeof keys === "string" ? [keys] : void 0;
@@ -7643,6 +7653,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
7643
7653
  return { rows: [] };
7644
7654
  }
7645
7655
  assertColumn(this._features, column, operationColumn);
7656
+ assert2(
7657
+ operation2 !== "custom",
7658
+ "Custom operation not supported for tilesets"
7659
+ );
7646
7660
  const rows = groupValuesByDateColumn({
7647
7661
  data: filteredFeatures,
7648
7662
  valuesColumns: normalizeColumns(operationColumn || column),
@@ -8415,75 +8429,19 @@ function ascending(a, b) {
8415
8429
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
8416
8430
  }
8417
8431
 
8418
- // node_modules/d3-array/src/number.js
8419
- init_cjs_shims();
8420
- function* numbers(values, valueof) {
8421
- if (valueof === void 0) {
8422
- for (let value of values) {
8423
- if (value != null && (value = +value) >= value) {
8424
- yield value;
8425
- }
8426
- }
8427
- } else {
8428
- let index = -1;
8429
- for (let value of values) {
8430
- if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
8431
- yield value;
8432
- }
8433
- }
8434
- }
8435
- }
8436
-
8437
- // node_modules/d3-array/src/deviation.js
8438
- init_cjs_shims();
8439
-
8440
- // node_modules/d3-array/src/variance.js
8441
- init_cjs_shims();
8442
- function variance(values, valueof) {
8443
- let count = 0;
8444
- let delta;
8445
- let mean = 0;
8446
- let sum3 = 0;
8447
- if (valueof === void 0) {
8448
- for (let value of values) {
8449
- if (value != null && (value = +value) >= value) {
8450
- delta = value - mean;
8451
- mean += delta / ++count;
8452
- sum3 += delta * (value - mean);
8453
- }
8454
- }
8455
- } else {
8456
- let index = -1;
8457
- for (let value of values) {
8458
- if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
8459
- delta = value - mean;
8460
- mean += delta / ++count;
8461
- sum3 += delta * (value - mean);
8462
- }
8463
- }
8464
- }
8465
- if (count > 1) return sum3 / (count - 1);
8466
- }
8467
-
8468
- // node_modules/d3-array/src/deviation.js
8469
- function deviation(values, valueof) {
8470
- const v2 = variance(values, valueof);
8471
- return v2 ? Math.sqrt(v2) : v2;
8472
- }
8473
-
8474
8432
  // node_modules/d3-array/src/extent.js
8475
8433
  init_cjs_shims();
8476
8434
  function extent(values, valueof) {
8477
- let min3;
8478
- let max3;
8435
+ let min2;
8436
+ let max2;
8479
8437
  if (valueof === void 0) {
8480
8438
  for (const value of values) {
8481
8439
  if (value != null) {
8482
- if (min3 === void 0) {
8483
- if (value >= value) min3 = max3 = value;
8440
+ if (min2 === void 0) {
8441
+ if (value >= value) min2 = max2 = value;
8484
8442
  } else {
8485
- if (min3 > value) min3 = value;
8486
- if (max3 < value) max3 = value;
8443
+ if (min2 > value) min2 = value;
8444
+ if (max2 < value) max2 = value;
8487
8445
  }
8488
8446
  }
8489
8447
  }
@@ -8491,16 +8449,16 @@ function extent(values, valueof) {
8491
8449
  let index = -1;
8492
8450
  for (let value of values) {
8493
8451
  if ((value = valueof(value, ++index, values)) != null) {
8494
- if (min3 === void 0) {
8495
- if (value >= value) min3 = max3 = value;
8452
+ if (min2 === void 0) {
8453
+ if (value >= value) min2 = max2 = value;
8496
8454
  } else {
8497
- if (min3 > value) min3 = value;
8498
- if (max3 < value) max3 = value;
8455
+ if (min2 > value) min2 = value;
8456
+ if (max2 < value) max2 = value;
8499
8457
  }
8500
8458
  }
8501
8459
  }
8502
8460
  }
8503
- return [min3, max3];
8461
+ return [min2, max2];
8504
8462
  }
8505
8463
 
8506
8464
  // node_modules/d3-array/src/group.js
@@ -8634,109 +8592,6 @@ function groupSort(values, reduce, key) {
8634
8592
  return (reduce.length !== 2 ? sort(rollup(values, reduce, key), ([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk)) : sort(group(values, key), ([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk))).map(([key2]) => key2);
8635
8593
  }
8636
8594
 
8637
- // node_modules/d3-array/src/quantile.js
8638
- init_cjs_shims();
8639
-
8640
- // node_modules/d3-array/src/max.js
8641
- init_cjs_shims();
8642
- function max2(values, valueof) {
8643
- let max3;
8644
- if (valueof === void 0) {
8645
- for (const value of values) {
8646
- if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
8647
- max3 = value;
8648
- }
8649
- }
8650
- } else {
8651
- let index = -1;
8652
- for (let value of values) {
8653
- if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
8654
- max3 = value;
8655
- }
8656
- }
8657
- }
8658
- return max3;
8659
- }
8660
-
8661
- // node_modules/d3-array/src/min.js
8662
- init_cjs_shims();
8663
- function min2(values, valueof) {
8664
- let min3;
8665
- if (valueof === void 0) {
8666
- for (const value of values) {
8667
- if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
8668
- min3 = value;
8669
- }
8670
- }
8671
- } else {
8672
- let index = -1;
8673
- for (let value of values) {
8674
- if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
8675
- min3 = value;
8676
- }
8677
- }
8678
- }
8679
- return min3;
8680
- }
8681
-
8682
- // node_modules/d3-array/src/quickselect.js
8683
- init_cjs_shims();
8684
- function quickselect(array, k, left = 0, right = Infinity, compare2) {
8685
- k = Math.floor(k);
8686
- left = Math.floor(Math.max(0, left));
8687
- right = Math.floor(Math.min(array.length - 1, right));
8688
- if (!(left <= k && k <= right)) return array;
8689
- compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
8690
- while (right > left) {
8691
- if (right - left > 600) {
8692
- const n = right - left + 1;
8693
- const m = k - left + 1;
8694
- const z = Math.log(n);
8695
- const s = 0.5 * Math.exp(2 * z / 3);
8696
- const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
8697
- const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
8698
- const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
8699
- quickselect(array, k, newLeft, newRight, compare2);
8700
- }
8701
- const t = array[k];
8702
- let i = left;
8703
- let j = right;
8704
- swap(array, left, k);
8705
- if (compare2(array[right], t) > 0) swap(array, left, right);
8706
- while (i < j) {
8707
- swap(array, i, j), ++i, --j;
8708
- while (compare2(array[i], t) < 0) ++i;
8709
- while (compare2(array[j], t) > 0) --j;
8710
- }
8711
- if (compare2(array[left], t) === 0) swap(array, left, j);
8712
- else ++j, swap(array, j, right);
8713
- if (j <= k) left = j + 1;
8714
- if (k <= j) right = j - 1;
8715
- }
8716
- return array;
8717
- }
8718
- function swap(array, i, j) {
8719
- const t = array[i];
8720
- array[i] = array[j];
8721
- array[j] = t;
8722
- }
8723
-
8724
- // node_modules/d3-array/src/quantile.js
8725
- function quantile(values, p, valueof) {
8726
- values = Float64Array.from(numbers(values, valueof));
8727
- if (!(n = values.length) || isNaN(p = +p)) return;
8728
- if (p <= 0 || n < 2) return min2(values);
8729
- if (p >= 1) return max2(values);
8730
- var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = max2(quickselect(values, i0).subarray(0, i0 + 1)), value1 = min2(values.subarray(i0 + 1));
8731
- return value0 + (value1 - value0) * (i - i0);
8732
- }
8733
-
8734
- // node_modules/d3-array/src/median.js
8735
- init_cjs_shims();
8736
- function median(values, valueof) {
8737
- return quantile(values, 0.5, valueof);
8738
- }
8739
-
8740
8595
  // node_modules/d3-color/src/index.js
8741
8596
  init_cjs_shims();
8742
8597
 
@@ -9031,12 +8886,12 @@ function hslConvert(o) {
9031
8886
  if (!o) return new Hsl();
9032
8887
  if (o instanceof Hsl) return o;
9033
8888
  o = o.rgb();
9034
- var r = o.r / 255, g = o.g / 255, b = o.b / 255, min3 = Math.min(r, g, b), max3 = Math.max(r, g, b), h = NaN, s = max3 - min3, l = (max3 + min3) / 2;
8889
+ var r = o.r / 255, g = o.g / 255, b = o.b / 255, min2 = Math.min(r, g, b), max2 = Math.max(r, g, b), h = NaN, s = max2 - min2, l = (max2 + min2) / 2;
9035
8890
  if (s) {
9036
- if (r === max3) h = (g - b) / s + (g < b) * 6;
9037
- else if (g === max3) h = (b - r) / s + 2;
8891
+ if (r === max2) h = (g - b) / s + (g < b) * 6;
8892
+ else if (g === max2) h = (b - r) / s + 2;
9038
8893
  else h = (r - g) / s + 4;
9039
- s /= l < 0.5 ? max3 + min3 : 2 - max3 - min3;
8894
+ s /= l < 0.5 ? max2 + min2 : 2 - max2 - min2;
9040
8895
  h *= 60;
9041
8896
  } else {
9042
8897
  s = l > 0 && l < 1 ? 0 : h;
@@ -9176,25 +9031,11 @@ function identity2(v2) {
9176
9031
  return v2;
9177
9032
  }
9178
9033
  var UNKNOWN_COLOR = "#868d91";
9179
- var AGGREGATION = {
9180
- average: "MEAN",
9181
- maximum: "MAX",
9182
- minimum: "MIN",
9183
- sum: "SUM"
9184
- };
9185
9034
  var OPACITY_MAP = {
9186
9035
  getFillColor: "opacity",
9187
9036
  getLineColor: "strokeOpacity",
9188
9037
  getTextColor: "opacity"
9189
9038
  };
9190
- var AGGREGATION_FUNC = {
9191
- "count unique": (values, accessor) => groupSort(values, (v2) => v2.length, accessor).length,
9192
- median,
9193
- // Unfortunately mode() is only available in d3-array@3+ which is ESM only
9194
- mode: (values, accessor) => groupSort(values, (v2) => v2.length, accessor).pop(),
9195
- stddev: deviation,
9196
- variance
9197
- };
9198
9039
  var hexToRGBA = (c) => {
9199
9040
  const { r, g, b, opacity } = rgb(c);
9200
9041
  return [r, g, b, 255 * opacity];
@@ -9290,11 +9131,11 @@ function domainFromAttribute(attribute, scaleType, scaleLength) {
9290
9131
  if (scaleType === "quantile" && attribute.quantiles) {
9291
9132
  return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9292
9133
  }
9293
- let { min: min3 } = attribute;
9294
- if (scaleType === "log" && min3 === 0) {
9295
- min3 = 1e-5;
9134
+ let { min: min2 } = attribute;
9135
+ if (scaleType === "log" && min2 === 0) {
9136
+ min2 = 1e-5;
9296
9137
  }
9297
- return [min3, attribute.max];
9138
+ return [min2, attribute.max];
9298
9139
  }
9299
9140
  function domainFromValues(values, scaleType) {
9300
9141
  if (scaleType === "ordinal" || scaleType === "point") {
@@ -9352,11 +9193,6 @@ function findAccessorKey(keys, properties) {
9352
9193
  }
9353
9194
  return keys;
9354
9195
  }
9355
- function getColorValueAccessor({ name }, colorAggregation, data) {
9356
- const aggregator = AGGREGATION_FUNC[colorAggregation];
9357
- const accessor = (values) => aggregator(values, (p) => p[name]);
9358
- return normalizeAccessor(accessor, data);
9359
- }
9360
9196
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9361
9197
  const scale2 = calculateLayerScale(
9362
9198
  colorColumn || name,
@@ -9374,7 +9210,7 @@ function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range
9374
9210
  const { r, g, b } = rgb(scale2(propertyValue));
9375
9211
  return [r, g, b, propertyValue === null ? 0 : alpha];
9376
9212
  };
9377
- return normalizeAccessor(accessor, data);
9213
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9378
9214
  }
9379
9215
  function calculateLayerScale(name, scaleType, range, data) {
9380
9216
  const scale2 = SCALE_FUNCS[scaleType]();
@@ -9461,7 +9297,7 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9461
9297
  const propertyValue = properties[accessorKeys[0]];
9462
9298
  return scale2(propertyValue);
9463
9299
  };
9464
- return normalizeAccessor(accessor, data);
9300
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9465
9301
  }
9466
9302
  var FORMATS = {
9467
9303
  date: formatDate,
@@ -9478,10 +9314,10 @@ function getTextAccessor({ name, type }, data) {
9478
9314
  return normalizeAccessor(accessor, data);
9479
9315
  }
9480
9316
  function calculateClusterRadius(properties, stats, radiusRange, column) {
9481
- const { min: min3, max: max3 } = stats[column];
9317
+ const { min: min2, max: max2 } = stats[column];
9482
9318
  const value = properties[column];
9483
- if (min3 === max3) return radiusRange[1];
9484
- const normalizedValue = (value - min3) / (max3 - min3);
9319
+ if (min2 === max2) return radiusRange[1];
9320
+ const normalizedValue = (value - min2) / (max2 - min2);
9485
9321
  return radiusRange[0] + normalizedValue * (radiusRange[1] - radiusRange[0]);
9486
9322
  }
9487
9323
  function getDefaultAggregationExpColumnAliasForLayerType(layerType, provider, schema) {
@@ -9542,6 +9378,14 @@ function parseMap(json) {
9542
9378
  assert2(data, `No data loaded for dataId: ${dataId}`);
9543
9379
  const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
9544
9380
  const styleProps = createStyleProps(config3, propMap);
9381
+ const { channelProps, scales } = createChannelProps(
9382
+ id,
9383
+ type,
9384
+ config3,
9385
+ visualChannels,
9386
+ data,
9387
+ dataset
9388
+ );
9545
9389
  const layer = {
9546
9390
  type,
9547
9391
  filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
@@ -9551,22 +9395,15 @@ function parseMap(json) {
9551
9395
  ...defaultProps2,
9552
9396
  ...createInteractionProps(interactionConfig),
9553
9397
  ...styleProps,
9554
- ...createChannelProps(
9555
- id,
9556
- type,
9557
- config3,
9558
- visualChannels,
9559
- data,
9560
- dataset
9561
- ),
9562
- // Must come after style
9398
+ ...channelProps,
9563
9399
  ...createParametersProp(
9564
9400
  layerBlending,
9565
9401
  styleProps.parameters || {}
9566
9402
  ),
9567
9403
  // Must come after style
9568
9404
  ...createLoadOptions(token)
9569
- }
9405
+ },
9406
+ scales
9570
9407
  };
9571
9408
  return layer;
9572
9409
  } catch (e) {
@@ -9633,69 +9470,47 @@ function createStyleProps(config2, mapping) {
9633
9470
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
9634
9471
  return result;
9635
9472
  }
9636
- function createChannelProps(id, type, config2, visualChannels, data, dataset) {
9473
+ function domainAndRangeFromScale(scale2) {
9474
+ return {
9475
+ domain: scale2.domain(),
9476
+ range: scale2.range()
9477
+ };
9478
+ }
9479
+ function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
9637
9480
  const {
9638
9481
  colorField,
9639
9482
  colorScale,
9640
9483
  radiusField,
9641
9484
  radiusScale,
9642
- sizeField,
9643
- sizeScale,
9644
9485
  strokeColorField,
9645
9486
  strokeColorScale,
9646
9487
  weightField
9647
9488
  } = visualChannels;
9648
- let { heightField, heightScale } = visualChannels;
9649
- if (type === "hexagonId") {
9650
- heightField = sizeField;
9651
- heightScale = sizeScale;
9652
- }
9489
+ const { heightField, heightScale } = visualChannels;
9653
9490
  const { textLabel, visConfig } = config2;
9654
9491
  const result = {};
9655
- if (type === "grid" || type === "hexagon") {
9656
- result.colorScaleType = colorScale;
9657
- if (colorField) {
9658
- const { colorAggregation } = config2.visConfig;
9659
- if (!AGGREGATION[colorAggregation]) {
9660
- result.getColorValue = getColorValueAccessor(
9661
- colorField,
9662
- colorAggregation,
9663
- data
9664
- );
9665
- } else {
9666
- result.getColorWeight = (d) => d[colorField.name];
9667
- }
9668
- }
9669
- } else if (colorField) {
9492
+ const scales = {};
9493
+ if (colorField) {
9670
9494
  const { colorAggregation: aggregation, colorRange: range } = visConfig;
9671
- result.getFillColor = getColorAccessor(
9495
+ const { accessor, scale: scale2 } = getColorAccessor(
9672
9496
  colorField,
9673
- // @ts-ignore
9674
9497
  colorScale,
9675
9498
  { aggregation, range },
9676
9499
  visConfig.opacity,
9677
9500
  data
9678
9501
  );
9502
+ result.getFillColor = accessor;
9503
+ scales.fillColor = {
9504
+ field: colorField,
9505
+ type: colorScale,
9506
+ ...domainAndRangeFromScale(scale2)
9507
+ };
9508
+ } else if (visConfig.filled) {
9509
+ scales.fillColor = {};
9679
9510
  }
9680
- if (type === "point") {
9681
- const altitude = config2.columns?.altitude;
9682
- if (altitude) {
9683
- result.dataTransform = (data2) => {
9684
- data2.features.forEach(
9685
- ({ geometry, properties }) => {
9686
- const { type: type2, coordinates } = geometry;
9687
- if (type2 === "Point") {
9688
- coordinates[2] = properties[altitude];
9689
- }
9690
- }
9691
- );
9692
- return data2;
9693
- };
9694
- }
9695
- }
9696
- if (type === "clusterTile") {
9511
+ if (layerType === "clusterTile") {
9697
9512
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
9698
- type,
9513
+ layerType,
9699
9514
  dataset.providerId,
9700
9515
  data.schema
9701
9516
  );
@@ -9734,49 +9549,67 @@ function createChannelProps(id, type, config2, visualChannels, data, dataset) {
9734
9549
  return calculateClusterTextFontSize(radius);
9735
9550
  };
9736
9551
  }
9737
- if (radiusField || sizeField) {
9738
- result.getPointRadius = getSizeAccessor(
9739
- // @ts-ignore
9740
- radiusField || sizeField,
9741
- // @ts-ignore
9742
- radiusScale || sizeScale,
9552
+ if (radiusField) {
9553
+ const { accessor, scale: scale2 } = getSizeAccessor(
9554
+ radiusField,
9555
+ radiusScale,
9743
9556
  visConfig.sizeAggregation,
9744
9557
  visConfig.radiusRange || visConfig.sizeRange,
9745
9558
  data
9746
9559
  );
9560
+ result.getPointRadius = accessor;
9561
+ scales.pointRadius = {
9562
+ field: radiusField,
9563
+ type: radiusScale || "identity",
9564
+ ...domainAndRangeFromScale(scale2)
9565
+ };
9747
9566
  }
9748
9567
  if (strokeColorField) {
9749
- const fallbackOpacity = type === "point" ? visConfig.opacity : 1;
9750
- const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : fallbackOpacity;
9568
+ const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
9751
9569
  const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
9752
- result.getLineColor = getColorAccessor(
9570
+ const { accessor, scale: scale2 } = getColorAccessor(
9753
9571
  strokeColorField,
9754
- // @ts-ignore
9755
9572
  strokeColorScale,
9756
- // @ts-ignore
9757
9573
  { aggregation, range },
9758
9574
  opacity,
9759
9575
  data
9760
9576
  );
9577
+ result.getLineColor = accessor;
9578
+ scales.lineColor = {
9579
+ field: strokeColorField,
9580
+ type: strokeColorScale,
9581
+ ...domainAndRangeFromScale(scale2)
9582
+ };
9761
9583
  }
9762
9584
  if (heightField && visConfig.enable3d) {
9763
- result.getElevation = getSizeAccessor(
9585
+ const { accessor, scale: scale2 } = getSizeAccessor(
9764
9586
  heightField,
9765
- // @ts-ignore
9766
9587
  heightScale,
9767
9588
  visConfig.heightAggregation,
9768
9589
  visConfig.heightRange || visConfig.sizeRange,
9769
9590
  data
9770
9591
  );
9592
+ result.getElevation = accessor;
9593
+ scales.elevation = {
9594
+ field: heightField,
9595
+ type: heightScale || "identity",
9596
+ ...domainAndRangeFromScale(scale2)
9597
+ };
9771
9598
  }
9772
9599
  if (weightField) {
9773
- result.getWeight = getSizeAccessor(
9600
+ const { accessor, scale: scale2 } = getSizeAccessor(
9774
9601
  weightField,
9775
9602
  void 0,
9776
9603
  visConfig.weightAggregation,
9777
9604
  void 0,
9778
9605
  data
9779
9606
  );
9607
+ result.getWeight = accessor;
9608
+ scales.weight = {
9609
+ field: weightField,
9610
+ type: "identity",
9611
+ ...domainAndRangeFromScale(scale2)
9612
+ };
9780
9613
  }
9781
9614
  if (visConfig.customMarkers) {
9782
9615
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -9814,17 +9647,16 @@ function createChannelProps(id, type, config2, visualChannels, data, dataset) {
9814
9647
  result.getIconSize = getPointRadius;
9815
9648
  }
9816
9649
  if (visualChannels.rotationField) {
9817
- result.getIconAngle = negateAccessor(
9818
- getSizeAccessor(
9819
- visualChannels.rotationField,
9820
- void 0,
9821
- null,
9822
- void 0,
9823
- data
9824
- )
9650
+ const { accessor } = getSizeAccessor(
9651
+ visualChannels.rotationField,
9652
+ void 0,
9653
+ null,
9654
+ void 0,
9655
+ data
9825
9656
  );
9657
+ result.getIconAngle = negateAccessor(accessor);
9826
9658
  }
9827
- } else if (type === "point" || type === "tileset") {
9659
+ } else if (layerType === "tileset") {
9828
9660
  result.pointType = "circle";
9829
9661
  }
9830
9662
  if (textLabel && textLabel.length && textLabel[0].field) {
@@ -9867,7 +9699,7 @@ function createChannelProps(id, type, config2, visualChannels, data, dataset) {
9867
9699
  }
9868
9700
  };
9869
9701
  }
9870
- return result;
9702
+ return { channelProps: result, scales };
9871
9703
  }
9872
9704
  function createLoadOptions(accessToken) {
9873
9705
  return {
@@ -10440,7 +10272,6 @@ function _getHexagonResolution(viewport, tileSize) {
10440
10272
  }
10441
10273
  // Annotate the CommonJS export names for ESM import in node:
10442
10274
  0 && (module.exports = {
10443
- AGGREGATION,
10444
10275
  ApiVersion,
10445
10276
  BASEMAP,
10446
10277
  CartoAPIError,
@@ -10490,7 +10321,6 @@ function _getHexagonResolution(viewport, tileSize) {
10490
10321
  getApplicableFilters,
10491
10322
  getClient,
10492
10323
  getColorAccessor,
10493
- getColorValueAccessor,
10494
10324
  getColumnNameFromGeoColumn,
10495
10325
  getDataFilterExtensionProps,
10496
10326
  getDefaultAggregationExpColumnAliasForLayerType,