@deck.gl/carto 8.8.2 → 8.8.5

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.
Files changed (57) hide show
  1. package/dist/dist.dev.js +298 -82
  2. package/dist/es5/api/layer-map.js +104 -17
  3. package/dist/es5/api/layer-map.js.map +1 -1
  4. package/dist/es5/api/maps-v3-client.js +191 -35
  5. package/dist/es5/api/maps-v3-client.js.map +1 -1
  6. package/dist/es5/api/parseMap.js +14 -4
  7. package/dist/es5/api/parseMap.js.map +1 -1
  8. package/dist/es5/config.js +11 -2
  9. package/dist/es5/config.js.map +1 -1
  10. package/dist/es5/layers/carto-layer.js +4 -17
  11. package/dist/es5/layers/carto-layer.js.map +1 -1
  12. package/dist/es5/style/color-bins-style.js.map +1 -1
  13. package/dist/es5/style/color-categories-style.js.map +1 -1
  14. package/dist/es5/style/color-continuous-style.js.map +1 -1
  15. package/dist/es5/style/utils.js +3 -1
  16. package/dist/es5/style/utils.js.map +1 -1
  17. package/dist/esm/api/layer-map.js +79 -14
  18. package/dist/esm/api/layer-map.js.map +1 -1
  19. package/dist/esm/api/maps-v3-client.js +90 -3
  20. package/dist/esm/api/maps-v3-client.js.map +1 -1
  21. package/dist/esm/api/parseMap.js +18 -4
  22. package/dist/esm/api/parseMap.js.map +1 -1
  23. package/dist/esm/config.js +10 -2
  24. package/dist/esm/config.js.map +1 -1
  25. package/dist/esm/layers/carto-layer.js +4 -15
  26. package/dist/esm/layers/carto-layer.js.map +1 -1
  27. package/dist/esm/style/color-bins-style.js.map +1 -1
  28. package/dist/esm/style/color-categories-style.js.map +1 -1
  29. package/dist/esm/style/color-continuous-style.js.map +1 -1
  30. package/dist/esm/style/utils.js +3 -1
  31. package/dist/esm/style/utils.js.map +1 -1
  32. package/dist.min.js +138 -138
  33. package/package.json +9 -9
  34. package/src/api/layer-map.ts +76 -13
  35. package/src/api/maps-v3-client.ts +92 -4
  36. package/src/api/parseMap.ts +6 -2
  37. package/src/config.ts +12 -2
  38. package/src/layers/carto-layer.ts +9 -29
  39. package/src/style/color-bins-style.ts +25 -3
  40. package/src/style/color-categories-style.ts +28 -4
  41. package/src/style/color-continuous-style.ts +25 -3
  42. package/src/style/utils.ts +8 -4
  43. package/typed/api/layer-map.d.ts +12 -4
  44. package/typed/api/layer-map.d.ts.map +1 -1
  45. package/typed/api/maps-v3-client.d.ts.map +1 -1
  46. package/typed/config.d.ts +2 -0
  47. package/typed/config.d.ts.map +1 -1
  48. package/typed/layers/carto-layer.d.ts +2 -7
  49. package/typed/layers/carto-layer.d.ts.map +1 -1
  50. package/typed/style/color-bins-style.d.ts +22 -3
  51. package/typed/style/color-bins-style.d.ts.map +1 -1
  52. package/typed/style/color-categories-style.d.ts +24 -4
  53. package/typed/style/color-categories-style.d.ts.map +1 -1
  54. package/typed/style/color-continuous-style.d.ts +22 -3
  55. package/typed/style/color-continuous-style.d.ts.map +1 -1
  56. package/typed/style/utils.d.ts +3 -6
  57. package/typed/style/utils.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-continuous-style.ts"],"names":["scaleLinear","getPalette","DEFAULT_PALETTE","NULL_COLOR","assert","getAttrValue","colorContinuous","attr","domain","colors","nullColor","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":"AAAA,SAAQA,WAAR,QAA0B,UAA1B;AACA,OAAOC,UAAP,IAA2BC,eAA3B,EAA4CC,UAA5C,QAA6D,WAA7D;AACA,SAAQC,MAAR,EAAmCC,YAAnC,QAAsD,SAAtD;AAEA,eAAe,SAASC,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGP,eAH6B;AAItCQ,EAAAA,SAAS,GAAGP;AAJ0B,CAAzB,EAUO;AACpBC,EAAAA,MAAM,CAACO,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAD,EAAwB,6CAAxB,CAAN;AAEA,QAAMK,OAAO,GAAG,OAAOJ,MAAP,KAAkB,QAAlB,GAA6BR,UAAU,CAACQ,MAAD,EAASD,MAAM,CAACM,MAAhB,CAAvC,GAAiEL,MAAjF;AACA,QAAMM,KAAK,GAAGf,WAAW,GAAUQ,MAArB,CAA4BA,MAA5B,EAAoCQ,KAApC,CAA0CH,OAA1C,CAAd;AAEA,SAAOI,CAAC,IAAI;AACV,UAAMC,KAAK,GAAGb,YAAY,CAACE,IAAD,EAAOU,CAAP,CAA1B;AACA,WAAO,OAAOC,KAAP,KAAiB,QAAjB,IAA6BC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAA7B,GAAsDH,KAAK,CAACG,KAAD,CAA3D,GAAqER,SAA5E;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, AttributeSelector, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}: {\n attr: AttributeSelector;\n domain: number[];\n colors?: string | Color[];\n nullColor?: Color;\n}): AttributeSelector {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n const color = scaleLinear<Color>().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-continuous-style.ts"],"names":["scaleLinear","getPalette","DEFAULT_PALETTE","NULL_COLOR","assert","getAttrValue","colorContinuous","attr","domain","colors","nullColor","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":"AACA,SAAQA,WAAR,QAA0B,UAA1B;AAEA,OAAOC,UAAP,IAA2BC,eAA3B,EAA4CC,UAA5C,QAA6D,WAA7D;AACA,SAAQC,MAAR,EAAmCC,YAAnC,QAAsD,SAAtD;AAUA,eAAe,SAASC,eAAT,CAA0C;AACvDC,EAAAA,IADuD;AAEvDC,EAAAA,MAFuD;AAGvDC,EAAAA,MAAM,GAAGP,eAH8C;AAIvDQ,EAAAA,SAAS,GAAGP;AAJ2C,CAA1C,EAsBoB;AACjCC,EAAAA,MAAM,CAACO,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAD,EAAwB,6CAAxB,CAAN;AAEA,QAAMK,OAAO,GAAG,OAAOJ,MAAP,KAAkB,QAAlB,GAA6BR,UAAU,CAACQ,MAAD,EAASD,MAAM,CAACM,MAAhB,CAAvC,GAAiEL,MAAjF;AACA,QAAMM,KAAK,GAAGf,WAAW,GAAUQ,MAArB,CAA4BA,MAA5B,EAAoCQ,KAApC,CAA0CH,OAA1C,CAAd;AAEA,SAAOI,CAAC,IAAI;AACV,UAAMC,KAAK,GAAGb,YAAY,CAACE,IAAD,EAAOU,CAAP,CAA1B;AACA,WAAO,OAAOC,KAAP,KAAiB,QAAjB,IAA6BC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAA7B,GAAsDH,KAAK,CAACG,KAAD,CAA3D,GAAqER,SAA5E;AACD,GAHD;AAID","sourcesContent":["import {AccessorFunction} from '@deck.gl/core';\nimport {scaleLinear} from 'd3-scale';\nimport {Feature} from 'geojson';\nimport getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, AttributeSelector, getAttrValue} from './utils';\n\n/**\n * Helper function for quickly creating a color continuous style.\n *\n * Data values of each field are interpolated linearly across values in the domain and\n * are then styled with a blend of the corresponding color in the range.\n *\n * @return accessor that maps objects to `Color` values\n */\nexport default function colorContinuous<DataT = Feature>({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}: {\n /** Attribute or column to symbolize by. */\n attr: AttributeSelector<DataT, number>;\n\n /** Attribute domain to define the data range. */\n domain: number[];\n\n /**\n * Color assigned to each domain value.\n *\n * Either Array of colors in RGBA or valid named CARTOColors palette.\n * @default `PurpOr`\n */\n colors?: string | Color[];\n\n /** Color for null values. @default: [204, 204, 204]*/\n nullColor?: Color;\n}): AccessorFunction<DataT, Color> {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n const color = scaleLinear<Color>().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
@@ -1,5 +1,7 @@
1
1
  const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
2
2
  export function getAttrValue(attr, d) {
3
+ var _properties;
4
+
3
5
  assert(typeof d === 'object', 'Expected "data" to be an object');
4
6
  assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
5
7
 
@@ -7,7 +9,7 @@ export function getAttrValue(attr, d) {
7
9
  return attr(d);
8
10
  }
9
11
 
10
- return d.properties[attr];
12
+ return d === null || d === void 0 ? void 0 : (_properties = d.properties) === null || _properties === void 0 ? void 0 : _properties[attr];
11
13
  }
12
14
  export function assert(condition, message = '') {
13
15
  if (!condition) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/utils.ts"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":"AAAA,MAAMA,kBAAkB,GAAGC,MAAM,CAACC,MAAP,CAAc,CAAC,UAAD,EAAa,QAAb,CAAd,CAA3B;AAKA,OAAO,SAASC,YAAT,CAAsBC,IAAtB,EAA+CC,CAA/C,EAAgE;AACrEC,EAAAA,MAAM,CAAC,OAAOD,CAAP,KAAa,QAAd,EAAwB,iCAAxB,CAAN;AACAC,EAAAA,MAAM,CAACN,kBAAkB,CAACO,QAAnB,CAA4B,OAAOH,IAAnC,CAAD,EAA2C,4CAA3C,CAAN;;AAGA,MAAI,OAAOA,IAAP,KAAgB,UAApB,EAAgC;AAC9B,WAAOA,IAAI,CAACC,CAAD,CAAX;AACD;;AACD,SAAOA,CAAC,CAACG,UAAF,CAAaJ,IAAb,CAAP;AACD;AAED,OAAO,SAASE,MAAT,CAAgBG,SAAhB,EAA2BC,OAAO,GAAG,EAArC,EAA4D;AACjE,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\ntype Row = {properties: Record<string, unknown>};\nexport type AttributeSelector = string | ((d: Row) => unknown);\n\nexport function getAttrValue(attr: AttributeSelector, d: Row): unknown {\n assert(typeof d === 'object', 'Expected \"data\" to be an object');\n assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected \"attr\" to be a function or string');\n\n // Is function\n if (typeof attr === 'function') {\n return attr(d);\n }\n return d.properties[attr];\n}\n\nexport function assert(condition, message = ''): asserts condition {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}
1
+ {"version":3,"sources":["../../../src/style/utils.ts"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":"AAEA,MAAMA,kBAAkB,GAAGC,MAAM,CAACC,MAAP,CAAc,CAAC,UAAD,EAAa,QAAb,CAAd,CAA3B;AAIA,OAAO,SAASC,YAAT,CACLC,IADK,EAELC,CAFK,EAGC;AAAA;;AACNC,EAAAA,MAAM,CAAC,OAAOD,CAAP,KAAa,QAAd,EAAwB,iCAAxB,CAAN;AACAC,EAAAA,MAAM,CAACN,kBAAkB,CAACO,QAAnB,CAA4B,OAAOH,IAAnC,CAAD,EAA2C,4CAA3C,CAAN;;AAGA,MAAI,OAAOA,IAAP,KAAgB,UAApB,EAAgC;AAC9B,WAAOA,IAAI,CAACC,CAAD,CAAX;AACD;;AACD,SAAQA,CAAR,aAAQA,CAAR,sCAAQA,CAAD,CAA2BG,UAAlC,gDAAO,YAAwCJ,IAAxC,CAAP;AACD;AAED,OAAO,SAASE,MAAT,CAAgBG,SAAhB,EAA2BC,OAAO,GAAG,EAArC,EAA4D;AACjE,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["import {Feature} from 'geojson';\n\nconst ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\nexport type AttributeSelector<DataT = Feature, OutT = any> = string | ((d: DataT) => OutT);\n\nexport function getAttrValue<DataT = Feature, OutT = any>(\n attr: string | AttributeSelector<DataT, OutT>,\n d: DataT\n): OutT {\n assert(typeof d === 'object', 'Expected \"data\" to be an object');\n assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected \"attr\" to be a function or string');\n\n // Is function\n if (typeof attr === 'function') {\n return attr(d);\n }\n return (d as unknown as Feature)?.properties?.[attr] as OutT;\n}\n\nexport function assert(condition, message = ''): asserts condition {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}