@deck.gl/carto 8.6.2 → 8.6.3

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;;;;;;;AAEe,SAASA,eAAT,OAMZ;AAAA,MALDC,IAKC,QALDA,IAKC;AAAA,MAJDC,MAIC,QAJDA,MAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQC,wBAGR;AAAA,4BAFDC,SAEC;AAAA,MAFDA,SAEC,+BAFWC,mBAEX;AAAA,8BADDC,WACC;AAAA,MADDA,WACC,iCADaC,qBACb;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,MAAMS,gBAAgB,GAAG,EAAzB;AACA,MAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAJC,6CAMoBD,MAAM,CAACY,OAAP,EANpB;AAAA;;AAAA;AAMD,wDAAuC;AAAA;AAAA,UAA3BC,CAA2B;AAAA,UAAxBC,CAAwB;;AACrCL,MAAAA,gBAAgB,CAACK,CAAD,CAAhB,GAAsBJ,OAAO,CAACG,CAAD,CAA7B;AACD;AARA;AAAA;AAAA;AAAA;AAAA;;AAUD,SAAO,UAAAE,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","i","c","entries","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEe,SAASA,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGC,wBAH6B;AAItCC,EAAAA,SAAS,GAAGC,mBAJ0B;AAKtCC,EAAAA,WAAW,GAAGC;AALwB,CAAzB,EAMZ;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,QAAMS,gBAAgB,GAAG,EAAzB;AACA,QAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAEA,OAAK,MAAM,CAACW,CAAD,EAAIC,CAAJ,CAAX,IAAqBb,MAAM,CAACc,OAAP,EAArB,EAAuC;AACrCL,IAAAA,gBAAgB,CAACI,CAAD,CAAhB,GAAsBH,OAAO,CAACE,CAAD,CAA7B;AACD;;AAED,SAAOG,CAAC,IAAI;AACV,UAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
@@ -13,18 +13,17 @@ var _palette = _interopRequireWildcard(require("./palette"));
13
13
 
14
14
  var _utils = require("./utils");
15
15
 
16
- function colorContinuous(_ref) {
17
- var attr = _ref.attr,
18
- domain = _ref.domain,
19
- _ref$colors = _ref.colors,
20
- colors = _ref$colors === void 0 ? _palette.DEFAULT_PALETTE : _ref$colors,
21
- _ref$nullColor = _ref.nullColor,
22
- nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor;
16
+ function colorContinuous({
17
+ attr,
18
+ domain,
19
+ colors = _palette.DEFAULT_PALETTE,
20
+ nullColor = _palette.NULL_COLOR
21
+ }) {
23
22
  (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
24
- var palette = typeof colors === 'string' ? (0, _palette.default)(colors) : colors;
25
- var color = (0, _d3Scale.scaleLinear)().domain(domain).range(palette);
26
- return function (d) {
27
- var value = (0, _utils.getAttrValue)(attr, d);
23
+ const palette = typeof colors === 'string' ? (0, _palette.default)(colors) : colors;
24
+ const color = (0, _d3Scale.scaleLinear)().domain(domain).range(palette);
25
+ return d => {
26
+ const value = (0, _utils.getAttrValue)(attr, d);
28
27
  return Number.isFinite(value) ? color(value) : nullColor;
29
28
  };
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEe,SAASA,eAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,CAA7B,GAAkDA,MAAlE;AACA,MAAMO,KAAK,GAAG,4BACXR,MADW,CACJA,MADI,EAEXS,KAFW,CAELF,OAFK,CAAd;AAIA,SAAO,UAAAG,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAaZ,IAAb,EAAmBW,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors) : colors;\n const color = scaleLinear()\n .domain(domain)\n .range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEe,SAASA,eAAT,CAAyB;AACtCC,EAAAA,IADsC;AAEtCC,EAAAA,MAFsC;AAGtCC,EAAAA,MAAM,GAAGC,wBAH6B;AAItCC,EAAAA,SAAS,GAAGC;AAJ0B,CAAzB,EAKZ;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,QAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,CAA7B,GAAkDA,MAAlE;AACA,QAAMO,KAAK,GAAG,4BACXR,MADW,CACJA,MADI,EAEXS,KAFW,CAELF,OAFK,CAAd;AAIA,SAAOG,CAAC,IAAI;AACV,UAAMC,KAAK,GAAG,yBAAaZ,IAAb,EAAmBW,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors) : colors;\n const color = scaleLinear()\n .domain(domain)\n .range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
@@ -2,8 +2,6 @@
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
4
 
5
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
@@ -11,28 +9,24 @@ exports.default = getPalette;
11
9
  exports.hexToRgb = hexToRgb;
12
10
  exports.OTHERS_COLOR = exports.NULL_COLOR = exports.DEFAULT_PALETTE = void 0;
13
11
 
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
12
  var cartoColors = _interopRequireWildcard(require("cartocolor"));
17
13
 
18
14
  var _utils = require("./utils");
19
15
 
20
- var DEFAULT_PALETTE = 'PurpOr';
16
+ const DEFAULT_PALETTE = 'PurpOr';
21
17
  exports.DEFAULT_PALETTE = DEFAULT_PALETTE;
22
- var NULL_COLOR = [204, 204, 204];
18
+ const NULL_COLOR = [204, 204, 204];
23
19
  exports.NULL_COLOR = NULL_COLOR;
24
- var OTHERS_COLOR = [119, 119, 119];
20
+ const OTHERS_COLOR = [119, 119, 119];
25
21
  exports.OTHERS_COLOR = OTHERS_COLOR;
26
22
 
27
23
  function getPalette(name, numCategories) {
28
- var palette = cartoColors[name];
29
- var paletteIndex = numCategories;
24
+ const palette = cartoColors[name];
25
+ let paletteIndex = numCategories;
30
26
  (0, _utils.assert)(palette, "Palette \"".concat(name, "\" not found. Expected a CARTOColors string"));
31
- var palettesColorVariants = Object.keys(palette).filter(function (p) {
32
- return p !== 'tags';
33
- }).map(Number);
34
- var longestPaletteIndex = Math.max.apply(Math, (0, _toConsumableArray2.default)(palettesColorVariants));
35
- var smallestPaletteIndex = Math.min.apply(Math, (0, _toConsumableArray2.default)(palettesColorVariants));
27
+ const palettesColorVariants = Object.keys(palette).filter(p => p !== 'tags').map(Number);
28
+ const longestPaletteIndex = Math.max(...palettesColorVariants);
29
+ const smallestPaletteIndex = Math.min(...palettesColorVariants);
36
30
 
37
31
  if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {
38
32
  paletteIndex = longestPaletteIndex;
@@ -40,19 +34,17 @@ function getPalette(name, numCategories) {
40
34
  paletteIndex = smallestPaletteIndex;
41
35
  }
42
36
 
43
- var colors = palette[paletteIndex];
37
+ let colors = palette[paletteIndex];
44
38
 
45
39
  if (palette.tags && palette.tags.includes('qualitative')) {
46
40
  colors = colors.slice(0, -1);
47
41
  }
48
42
 
49
- return colors.map(function (c) {
50
- return hexToRgb(c);
51
- });
43
+ return colors.map(c => hexToRgb(c));
52
44
  }
53
45
 
54
46
  function hexToRgb(hex) {
55
- var result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex);
47
+ let result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex);
56
48
 
57
49
  if (result) {
58
50
  return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16), 255];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/palette.js"],"names":["DEFAULT_PALETTE","NULL_COLOR","OTHERS_COLOR","getPalette","name","numCategories","palette","cartoColors","paletteIndex","palettesColorVariants","Object","keys","filter","p","map","Number","longestPaletteIndex","Math","max","smallestPaletteIndex","min","isInteger","colors","tags","includes","slice","c","hexToRgb","hex","result","exec","parseInt"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,eAAe,GAAG,QAAxB;;AACA,IAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAnB;;AACA,IAAMC,YAAY,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,G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CAAT;;AAEA,MAAIC,MAAJ,EAAY;AACV,WAAO,CACLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CADH,EAELE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAFH,EAGLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAHH,EAILE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAJH,CAAP;AAMD;;AAED,qBAAOA,MAAP,gCAAqCD,GAArC;AAEA,SAAO3B,UAAP;AACD","sourcesContent":["import * as cartoColors from 'cartocolor';\nimport {assert} from './utils';\n\nexport const DEFAULT_PALETTE = 'PurpOr';\nexport const NULL_COLOR = [204, 204, 204];\nexport const OTHERS_COLOR = [119, 119, 119];\n\nexport default function getPalette(name, numCategories) {\n const palette = cartoColors[name];\n let paletteIndex = numCategories;\n\n assert(palette, `Palette \"${name}\" not found. Expected a CARTOColors string`);\n\n const palettesColorVariants = Object.keys(palette)\n .filter(p => p !== 'tags')\n .map(Number);\n\n const longestPaletteIndex = Math.max(...palettesColorVariants);\n const smallestPaletteIndex = Math.min(...palettesColorVariants);\n\n if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {\n paletteIndex = longestPaletteIndex;\n } else if (numCategories < smallestPaletteIndex) {\n paletteIndex = smallestPaletteIndex;\n }\n\n let colors = palette[paletteIndex];\n\n if (palette.tags && palette.tags.includes('qualitative')) {\n colors = colors.slice(0, -1);\n }\n\n return colors.map(c => hexToRgb(c));\n}\n\nexport function hexToRgb(hex) {\n // Evaluate #ABC\n let result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n 255\n ];\n }\n\n // Evaluate #ABCD\n result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n parseInt(result[4] + result[4], 16)\n ];\n }\n\n // Evaluate #ABCDEF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];\n }\n\n // Evaluate #ABCDEFAF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1], 16),\n parseInt(result[2], 16),\n parseInt(result[3], 16),\n parseInt(result[4], 16)\n ];\n }\n\n assert(result, `Hexadecimal color \"${hex}\" was not parsed correctly`);\n\n return NULL_COLOR;\n}\n"],"file":"palette.js"}
1
+ {"version":3,"sources":["../../../src/style/palette.js"],"names":["DEFAULT_PALETTE","NULL_COLOR","OTHERS_COLOR","getPalette","name","numCategories","palette","cartoColors","paletteIndex","palettesColorVariants","Object","keys","filter","p","map","Number","longestPaletteIndex","Math","max","smallestPaletteIndex","min","isInteger","colors","tags","includes","slice","c","hexToRgb","hex","result","exec","parseInt"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,eAAe,GAAG,QAAxB;;AACA,MAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAnB;;AACA,MAAMC,YAAY,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAArB;;;AAEQ,SAASC,UAAT,CAAoBC,IAApB,EAA0BC,aAA1B,EAAyC;AACtD,QAAMC,OAAO,GAAGC,WAAW,CAACH,IAAD,CAA3B;AACA,MAAII,YAAY,GAAGH,aAAnB;AAEA,qBAAOC,OAAP,sBAA4BF,IAA5B;AAEA,QAAMK,qBAAqB,GAAGC,MAAM,CAACC,IAAP,CAAYL,OAAZ,EAC3BM,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P,gCAAqCD,GAArC;AAEA,SAAO3B,UAAP;AACD","sourcesContent":["import * as cartoColors from 'cartocolor';\nimport {assert} from './utils';\n\nexport const DEFAULT_PALETTE = 'PurpOr';\nexport const NULL_COLOR = [204, 204, 204];\nexport const OTHERS_COLOR = [119, 119, 119];\n\nexport default function getPalette(name, numCategories) {\n const palette = cartoColors[name];\n let paletteIndex = numCategories;\n\n assert(palette, `Palette \"${name}\" not found. Expected a CARTOColors string`);\n\n const palettesColorVariants = Object.keys(palette)\n .filter(p => p !== 'tags')\n .map(Number);\n\n const longestPaletteIndex = Math.max(...palettesColorVariants);\n const smallestPaletteIndex = Math.min(...palettesColorVariants);\n\n if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {\n paletteIndex = longestPaletteIndex;\n } else if (numCategories < smallestPaletteIndex) {\n paletteIndex = smallestPaletteIndex;\n }\n\n let colors = palette[paletteIndex];\n\n if (palette.tags && palette.tags.includes('qualitative')) {\n colors = colors.slice(0, -1);\n }\n\n return colors.map(c => hexToRgb(c));\n}\n\nexport function hexToRgb(hex) {\n // Evaluate #ABC\n let result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n 255\n ];\n }\n\n // Evaluate #ABCD\n result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n parseInt(result[4] + result[4], 16)\n ];\n }\n\n // Evaluate #ABCDEF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];\n }\n\n // Evaluate #ABCDEFAF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1], 16),\n parseInt(result[2], 16),\n parseInt(result[3], 16),\n parseInt(result[4], 16)\n ];\n }\n\n assert(result, `Hexadecimal color \"${hex}\" was not parsed correctly`);\n\n return NULL_COLOR;\n}\n"],"file":"palette.js"}
@@ -1,35 +1,28 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.getAttrValue = getAttrValue;
9
7
  exports.assert = assert;
10
-
11
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
-
13
- var ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
8
+ const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
14
9
 
15
10
  function getAttrValue(attr, d) {
16
- assert((0, _typeof2.default)(d) === 'object', 'Expected "data" to be an object');
17
- assert(ALLOWED_ATTR_TYPES.includes((0, _typeof2.default)(attr)), 'Expected "attr" to be a function or string');
11
+ assert(typeof d === 'object', 'Expected "data" to be an object');
12
+ assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
18
13
 
19
- if ((0, _typeof2.default)(attr) === ALLOWED_ATTR_TYPES[0]) {
14
+ if (typeof attr === ALLOWED_ATTR_TYPES[0]) {
20
15
  return attr(d);
21
16
  }
22
17
 
23
- if ((0, _typeof2.default)(attr) === ALLOWED_ATTR_TYPES[1]) {
18
+ if (typeof attr === ALLOWED_ATTR_TYPES[1]) {
24
19
  return d.properties[attr];
25
20
  }
26
21
 
27
22
  return {};
28
23
  }
29
24
 
30
- function assert(condition) {
31
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
32
-
25
+ function assert(condition, message = '') {
33
26
  if (!condition) {
34
27
  throw new Error("CARTO style error: ".concat(message));
35
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/utils.js"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":";;;;;;;;;;;;AAAA,IAAMA,kBAAkB,GAAGC,MAAM,CAACC,MAAP,CAAc,CAAC,UAAD,EAAa,QAAb,CAAd,CAA3B;;AAEO,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,CAA5B,EAA+B;AACpCC,EAAAA,MAAM,CAAC,sBAAOD,CAAP,MAAa,QAAd,EAAwB,iCAAxB,CAAN;AACAC,EAAAA,MAAM,CAACN,kBAAkB,CAACO,QAAnB,uBAAmCH,IAAnC,EAAD,EAA2C,4CAA3C,CAAN;;AAGA,MAAI,sBAAOA,IAAP,MAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOI,IAAI,CAACC,CAAD,CAAX;AACD;;AAGD,MAAI,sBAAOD,IAAP,MAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOK,CAAC,CAACG,UAAF,CAAaJ,IAAb,CAAP;AACD;;AAED,SAAO,EAAP;AACD;;AAEM,SAASE,MAAT,CAAgBG,SAAhB,EAAyC;AAAA,MAAdC,OAAc,uEAAJ,EAAI;;AAC9C,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\nexport function getAttrValue(attr, d) {\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 === ALLOWED_ATTR_TYPES[0]) {\n return attr(d);\n }\n\n // Is string\n if (typeof attr === ALLOWED_ATTR_TYPES[1]) {\n return d.properties[attr];\n }\n\n return {};\n}\n\nexport function assert(condition, message = '') {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}
1
+ {"version":3,"sources":["../../../src/style/utils.js"],"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;;AAEO,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,CAA5B,EAA+B;AACpCC,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,KAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOI,IAAI,CAACC,CAAD,CAAX;AACD;;AAGD,MAAI,OAAOD,IAAP,KAAgBJ,kBAAkB,CAAC,CAAD,CAAtC,EAA2C;AACzC,WAAOK,CAAC,CAACG,UAAF,CAAaJ,IAAb,CAAP;AACD;;AAED,SAAO,EAAP;AACD;;AAEM,SAASE,MAAT,CAAgBG,SAAhB,EAA2BC,OAAO,GAAG,EAArC,EAAyC;AAC9C,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\nexport function getAttrValue(attr, d) {\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 === ALLOWED_ATTR_TYPES[0]) {\n return attr(d);\n }\n\n // Is string\n if (typeof attr === ALLOWED_ATTR_TYPES[1]) {\n return d.properties[attr];\n }\n\n return {};\n}\n\nexport function assert(condition, message = '') {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/carto",
3
3
  "description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
4
4
  "license": "MIT",
5
- "version": "8.6.2",
5
+ "version": "8.6.3",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -44,5 +44,5 @@
44
44
  "@deck.gl/layers": "^8.0.0",
45
45
  "@loaders.gl/core": "^3.0.0"
46
46
  },
47
- "gitHead": "8ee546f7a28f93ba0e661bdf7ba18b45f1c07704"
47
+ "gitHead": "938ee03697eecbaced24c9df637d53ab42375df1"
48
48
  }