@deck.gl/carto 8.10.0-alpha.6 → 9.0.0-alpha.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.
Files changed (365) hide show
  1. package/dist/cartoRasterTile-worker.js +38 -30
  2. package/dist/cartoSpatialTile-worker.js +38 -30
  3. package/dist/cartoVectorTile-worker.js +75 -69
  4. package/dist/dist.dev.js +14001 -14522
  5. package/dist/es5/api/carto-api-error.js.map +1 -1
  6. package/dist/es5/api/common.js +25 -0
  7. package/dist/es5/api/common.js.map +1 -0
  8. package/dist/es5/api/endpoints.js +40 -0
  9. package/dist/es5/api/endpoints.js.map +1 -0
  10. package/dist/es5/api/fetch-map.js +560 -0
  11. package/dist/es5/api/fetch-map.js.map +1 -0
  12. package/dist/es5/api/index.js +5 -49
  13. package/dist/es5/api/index.js.map +1 -1
  14. package/dist/es5/api/layer-map.js +43 -45
  15. package/dist/es5/api/layer-map.js.map +1 -1
  16. package/dist/es5/api/{parseMap.js → parse-map.js} +5 -3
  17. package/dist/es5/api/parse-map.js.map +1 -0
  18. package/dist/es5/api/query.js +78 -0
  19. package/dist/es5/api/query.js.map +1 -0
  20. package/dist/es5/{sources/utils.js → api/request-with-parameters.js} +60 -46
  21. package/dist/es5/api/request-with-parameters.js.map +1 -0
  22. package/dist/es5/api/types.js +19 -0
  23. package/dist/es5/api/types.js.map +1 -1
  24. package/dist/es5/index.js +66 -80
  25. package/dist/es5/index.js.map +1 -1
  26. package/dist/es5/layers/h3-tile-layer.js +3 -5
  27. package/dist/es5/layers/h3-tile-layer.js.map +1 -1
  28. package/dist/es5/layers/point-label-layer.js.map +1 -1
  29. package/dist/es5/layers/quadbin-layer.js.map +1 -1
  30. package/dist/es5/layers/quadbin-tile-layer.js +1 -4
  31. package/dist/es5/layers/quadbin-tile-layer.js.map +1 -1
  32. package/dist/es5/layers/raster-layer.js +2 -0
  33. package/dist/es5/layers/raster-layer.js.map +1 -1
  34. package/dist/es5/layers/raster-tile-layer.js +1 -3
  35. package/dist/es5/layers/raster-tile-layer.js.map +1 -1
  36. package/dist/es5/layers/schema/carto-properties-tile-loader.js +60 -0
  37. package/dist/es5/layers/schema/carto-properties-tile-loader.js.map +1 -0
  38. package/dist/es5/layers/schema/carto-properties-tile.js +38 -0
  39. package/dist/es5/layers/schema/carto-properties-tile.js.map +1 -0
  40. package/dist/es5/layers/schema/carto-raster-tile-loader.js +1 -1
  41. package/dist/es5/layers/schema/carto-raster-tile-loader.js.map +1 -1
  42. package/dist/es5/layers/schema/carto-spatial-tile-loader.js +1 -1
  43. package/dist/es5/layers/schema/carto-spatial-tile-loader.js.map +1 -1
  44. package/dist/es5/layers/schema/carto-vector-tile-loader.js +1 -2
  45. package/dist/es5/layers/schema/carto-vector-tile-loader.js.map +1 -1
  46. package/dist/es5/layers/spatial-index-tile-layer.js +16 -26
  47. package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -1
  48. package/dist/es5/layers/utils.js +102 -0
  49. package/dist/es5/layers/utils.js.map +1 -1
  50. package/dist/es5/layers/vector-tile-layer.js +112 -27
  51. package/dist/es5/layers/vector-tile-layer.js.map +1 -1
  52. package/dist/es5/sources/base-source.js +56 -28
  53. package/dist/es5/sources/base-source.js.map +1 -1
  54. package/dist/es5/sources/boundary-query-source.js +51 -0
  55. package/dist/es5/sources/boundary-query-source.js.map +1 -0
  56. package/dist/es5/sources/boundary-table-source.js +51 -0
  57. package/dist/es5/sources/boundary-table-source.js.map +1 -0
  58. package/dist/es5/sources/boundary-tileset-source.js +43 -0
  59. package/dist/es5/sources/boundary-tileset-source.js.map +1 -0
  60. package/dist/es5/sources/h3-query-source.js +9 -11
  61. package/dist/es5/sources/h3-query-source.js.map +1 -1
  62. package/dist/es5/sources/h3-table-source.js +10 -12
  63. package/dist/es5/sources/h3-table-source.js.map +1 -1
  64. package/dist/es5/sources/h3-tileset-source.js +5 -5
  65. package/dist/es5/sources/h3-tileset-source.js.map +1 -1
  66. package/dist/es5/sources/index.js +46 -22
  67. package/dist/es5/sources/index.js.map +1 -1
  68. package/dist/es5/sources/quadbin-query-source.js +10 -12
  69. package/dist/es5/sources/quadbin-query-source.js.map +1 -1
  70. package/dist/es5/sources/quadbin-table-source.js +10 -12
  71. package/dist/es5/sources/quadbin-table-source.js.map +1 -1
  72. package/dist/es5/sources/quadbin-tileset-source.js +5 -5
  73. package/dist/es5/sources/quadbin-tileset-source.js.map +1 -1
  74. package/dist/es5/sources/raster-source.js +5 -5
  75. package/dist/es5/sources/raster-source.js.map +1 -1
  76. package/dist/es5/sources/types.js +2 -0
  77. package/dist/es5/sources/types.js.map +1 -0
  78. package/dist/es5/sources/vector-query-source.js +11 -12
  79. package/dist/es5/sources/vector-query-source.js.map +1 -1
  80. package/dist/es5/sources/vector-table-source.js +12 -13
  81. package/dist/es5/sources/vector-table-source.js.map +1 -1
  82. package/dist/es5/sources/vector-tileset-source.js +5 -5
  83. package/dist/es5/sources/vector-tileset-source.js.map +1 -1
  84. package/dist/es5/style/color-bins-style.js +4 -2
  85. package/dist/es5/style/color-bins-style.js.map +1 -1
  86. package/dist/es5/style/color-categories-style.js +4 -2
  87. package/dist/es5/style/color-categories-style.js.map +1 -1
  88. package/dist/es5/style/color-continuous-style.js +4 -2
  89. package/dist/es5/style/color-continuous-style.js.map +1 -1
  90. package/dist/es5/style/palette.js +1 -1
  91. package/dist/es5/style/palette.js.map +1 -1
  92. package/dist/es5/style/utils.js +4 -11
  93. package/dist/es5/style/utils.js.map +1 -1
  94. package/dist/es5/utils.js +30 -1
  95. package/dist/es5/utils.js.map +1 -1
  96. package/dist/esm/api/carto-api-error.js.map +1 -1
  97. package/dist/esm/api/common.js +13 -0
  98. package/dist/esm/api/common.js.map +1 -0
  99. package/dist/esm/api/endpoints.js +28 -0
  100. package/dist/esm/api/endpoints.js.map +1 -0
  101. package/dist/esm/api/fetch-map.js +291 -0
  102. package/dist/esm/api/fetch-map.js.map +1 -0
  103. package/dist/esm/api/index.js +2 -3
  104. package/dist/esm/api/index.js.map +1 -1
  105. package/dist/esm/api/layer-map.js +43 -35
  106. package/dist/esm/api/layer-map.js.map +1 -1
  107. package/dist/esm/api/{parseMap.js → parse-map.js} +3 -2
  108. package/dist/esm/api/parse-map.js.map +1 -0
  109. package/dist/esm/api/query.js +38 -0
  110. package/dist/esm/api/query.js.map +1 -0
  111. package/dist/esm/{sources/utils.js → api/request-with-parameters.js} +25 -12
  112. package/dist/esm/api/request-with-parameters.js.map +1 -0
  113. package/dist/esm/api/types.js +13 -1
  114. package/dist/esm/api/types.js.map +1 -1
  115. package/dist/esm/index.js +31 -9
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/layers/h3-tile-layer.js +2 -6
  118. package/dist/esm/layers/h3-tile-layer.js.map +1 -1
  119. package/dist/esm/layers/point-label-layer.js.map +1 -1
  120. package/dist/esm/layers/quadbin-layer.js.map +1 -1
  121. package/dist/esm/layers/quadbin-tile-layer.js +1 -3
  122. package/dist/esm/layers/quadbin-tile-layer.js.map +1 -1
  123. package/dist/esm/layers/raster-layer.js +1 -0
  124. package/dist/esm/layers/raster-layer.js.map +1 -1
  125. package/dist/esm/layers/raster-tile-layer.js +1 -2
  126. package/dist/esm/layers/raster-tile-layer.js.map +1 -1
  127. package/dist/esm/layers/schema/carto-properties-tile-loader.js +23 -0
  128. package/dist/esm/layers/schema/carto-properties-tile-loader.js.map +1 -0
  129. package/dist/esm/layers/schema/carto-properties-tile.js +18 -0
  130. package/dist/esm/layers/schema/carto-properties-tile.js.map +1 -0
  131. package/dist/esm/layers/schema/carto-raster-tile-loader.js +1 -1
  132. package/dist/esm/layers/schema/carto-raster-tile-loader.js.map +1 -1
  133. package/dist/esm/layers/schema/carto-spatial-tile-loader.js +1 -1
  134. package/dist/esm/layers/schema/carto-spatial-tile-loader.js.map +1 -1
  135. package/dist/esm/layers/schema/carto-vector-tile-loader.js +1 -2
  136. package/dist/esm/layers/schema/carto-vector-tile-loader.js.map +1 -1
  137. package/dist/esm/layers/spatial-index-tile-layer.js +9 -24
  138. package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -1
  139. package/dist/esm/layers/utils.js +70 -0
  140. package/dist/esm/layers/utils.js.map +1 -1
  141. package/dist/esm/layers/vector-tile-layer.js +40 -12
  142. package/dist/esm/layers/vector-tile-layer.js.map +1 -1
  143. package/dist/esm/sources/base-source.js +33 -10
  144. package/dist/esm/sources/base-source.js.map +1 -1
  145. package/dist/esm/sources/boundary-query-source.js +21 -0
  146. package/dist/esm/sources/boundary-query-source.js.map +1 -0
  147. package/dist/esm/sources/boundary-table-source.js +21 -0
  148. package/dist/esm/sources/boundary-table-source.js.map +1 -0
  149. package/dist/esm/sources/boundary-tileset-source.js +11 -0
  150. package/dist/esm/sources/boundary-tileset-source.js.map +1 -0
  151. package/dist/esm/sources/h3-query-source.js +6 -11
  152. package/dist/esm/sources/h3-query-source.js.map +1 -1
  153. package/dist/esm/sources/h3-table-source.js +7 -12
  154. package/dist/esm/sources/h3-table-source.js.map +1 -1
  155. package/dist/esm/sources/h3-tileset-source.js +3 -6
  156. package/dist/esm/sources/h3-tileset-source.js.map +1 -1
  157. package/dist/esm/sources/index.js +14 -11
  158. package/dist/esm/sources/index.js.map +1 -1
  159. package/dist/esm/sources/quadbin-query-source.js +7 -12
  160. package/dist/esm/sources/quadbin-query-source.js.map +1 -1
  161. package/dist/esm/sources/quadbin-table-source.js +7 -12
  162. package/dist/esm/sources/quadbin-table-source.js.map +1 -1
  163. package/dist/esm/sources/quadbin-tileset-source.js +3 -6
  164. package/dist/esm/sources/quadbin-tileset-source.js.map +1 -1
  165. package/dist/esm/sources/raster-source.js +3 -6
  166. package/dist/esm/sources/raster-source.js.map +1 -1
  167. package/dist/esm/sources/types.js +2 -0
  168. package/dist/esm/sources/types.js.map +1 -0
  169. package/dist/esm/sources/vector-query-source.js +6 -11
  170. package/dist/esm/sources/vector-query-source.js.map +1 -1
  171. package/dist/esm/sources/vector-table-source.js +7 -12
  172. package/dist/esm/sources/vector-table-source.js.map +1 -1
  173. package/dist/esm/sources/vector-tileset-source.js +3 -6
  174. package/dist/esm/sources/vector-tileset-source.js.map +1 -1
  175. package/dist/esm/style/color-bins-style.js +2 -1
  176. package/dist/esm/style/color-bins-style.js.map +1 -1
  177. package/dist/esm/style/color-categories-style.js +2 -1
  178. package/dist/esm/style/color-categories-style.js.map +1 -1
  179. package/dist/esm/style/color-continuous-style.js +2 -1
  180. package/dist/esm/style/color-continuous-style.js.map +1 -1
  181. package/dist/esm/style/palette.js +1 -1
  182. package/dist/esm/style/palette.js.map +1 -1
  183. package/dist/esm/style/utils.js +1 -5
  184. package/dist/esm/style/utils.js.map +1 -1
  185. package/dist/esm/utils.js +24 -1
  186. package/dist/esm/utils.js.map +1 -1
  187. package/dist.min.js +42 -46
  188. package/package.json +11 -10
  189. package/src/.DS_Store +0 -0
  190. package/src/api/carto-api-error.ts +1 -9
  191. package/src/api/common.ts +14 -0
  192. package/src/api/endpoints.ts +38 -0
  193. package/src/api/fetch-map.ts +287 -0
  194. package/src/api/index.ts +5 -5
  195. package/src/api/layer-map.ts +40 -36
  196. package/src/api/{parseMap.ts → parse-map.ts} +2 -2
  197. package/src/api/query.ts +34 -0
  198. package/src/{sources/utils.ts → api/request-with-parameters.ts} +22 -17
  199. package/src/api/types.ts +49 -0
  200. package/src/index.ts +93 -41
  201. package/src/layers/h3-tile-layer.ts +13 -18
  202. package/src/layers/point-label-layer.ts +1 -1
  203. package/src/layers/quadbin-layer.ts +3 -2
  204. package/src/layers/quadbin-tile-layer.ts +10 -11
  205. package/src/layers/raster-layer.ts +2 -2
  206. package/src/layers/raster-tile-layer.ts +11 -9
  207. package/src/layers/schema/carto-properties-tile-loader.ts +25 -0
  208. package/src/layers/schema/carto-properties-tile.ts +21 -0
  209. package/src/layers/schema/carto-vector-tile-loader.ts +5 -5
  210. package/src/layers/spatial-index-tile-layer.ts +18 -26
  211. package/src/layers/utils.ts +71 -0
  212. package/src/layers/vector-tile-layer.ts +42 -23
  213. package/src/sources/base-source.ts +35 -18
  214. package/src/sources/boundary-query-source.ts +31 -0
  215. package/src/sources/boundary-table-source.ts +31 -0
  216. package/src/sources/boundary-tileset-source.ts +14 -0
  217. package/src/sources/h3-query-source.ts +22 -22
  218. package/src/sources/h3-table-source.ts +22 -22
  219. package/src/sources/h3-tileset-source.ts +7 -9
  220. package/src/sources/index.ts +31 -22
  221. package/src/sources/quadbin-query-source.ts +22 -22
  222. package/src/sources/quadbin-table-source.ts +23 -22
  223. package/src/sources/quadbin-tileset-source.ts +7 -9
  224. package/src/sources/raster-source.ts +5 -9
  225. package/src/sources/types.ts +98 -0
  226. package/src/sources/vector-query-source.ts +15 -15
  227. package/src/sources/vector-table-source.ts +15 -15
  228. package/src/sources/vector-tileset-source.ts +7 -9
  229. package/src/style/color-bins-style.ts +2 -1
  230. package/src/style/color-categories-style.ts +2 -1
  231. package/src/style/color-continuous-style.ts +2 -1
  232. package/src/style/palette.ts +1 -1
  233. package/src/style/utils.ts +1 -6
  234. package/src/utils.ts +25 -1
  235. package/typed/api/carto-api-error.d.ts +1 -8
  236. package/typed/api/carto-api-error.d.ts.map +1 -1
  237. package/typed/api/common.d.ts +13 -0
  238. package/typed/api/common.d.ts.map +1 -0
  239. package/typed/api/endpoints.d.ts +12 -0
  240. package/typed/api/endpoints.d.ts.map +1 -0
  241. package/typed/api/fetch-map.d.ts +22 -0
  242. package/typed/api/fetch-map.d.ts.map +1 -0
  243. package/typed/api/index.d.ts +5 -5
  244. package/typed/api/index.d.ts.map +1 -1
  245. package/typed/api/layer-map.d.ts +6 -9
  246. package/typed/api/layer-map.d.ts.map +1 -1
  247. package/typed/api/{parseMap.d.ts → parse-map.d.ts} +1 -1
  248. package/typed/api/parse-map.d.ts.map +1 -0
  249. package/typed/api/query.d.ts +4 -0
  250. package/typed/api/query.d.ts.map +1 -0
  251. package/typed/api/request-with-parameters.d.ts +9 -0
  252. package/typed/api/request-with-parameters.d.ts.map +1 -0
  253. package/typed/api/types.d.ts +40 -0
  254. package/typed/api/types.d.ts.map +1 -1
  255. package/typed/index.d.ts +33 -12
  256. package/typed/index.d.ts.map +1 -1
  257. package/typed/layers/h3-tile-layer.d.ts +12 -7
  258. package/typed/layers/h3-tile-layer.d.ts.map +1 -1
  259. package/typed/layers/point-label-layer.d.ts +2 -2
  260. package/typed/layers/point-label-layer.d.ts.map +1 -1
  261. package/typed/layers/quadbin-layer.d.ts +2 -2
  262. package/typed/layers/quadbin-layer.d.ts.map +1 -1
  263. package/typed/layers/quadbin-tile-layer.d.ts +6 -6
  264. package/typed/layers/quadbin-tile-layer.d.ts.map +1 -1
  265. package/typed/layers/raster-layer.d.ts +2 -2
  266. package/typed/layers/raster-layer.d.ts.map +1 -1
  267. package/typed/layers/raster-tile-layer.d.ts +6 -5
  268. package/typed/layers/raster-tile-layer.d.ts.map +1 -1
  269. package/typed/layers/schema/carto-properties-tile-loader.d.ts +4 -0
  270. package/typed/layers/schema/carto-properties-tile-loader.d.ts.map +1 -0
  271. package/typed/layers/schema/carto-properties-tile.d.ts +10 -0
  272. package/typed/layers/schema/carto-properties-tile.d.ts.map +1 -0
  273. package/typed/layers/spatial-index-tile-layer.d.ts +10 -9
  274. package/typed/layers/spatial-index-tile-layer.d.ts.map +1 -1
  275. package/typed/layers/utils.d.ts +11 -0
  276. package/typed/layers/utils.d.ts.map +1 -1
  277. package/typed/layers/vector-tile-layer.d.ts +6 -11
  278. package/typed/layers/vector-tile-layer.d.ts.map +1 -1
  279. package/typed/sources/base-source.d.ts +4 -3
  280. package/typed/sources/base-source.d.ts.map +1 -1
  281. package/typed/sources/boundary-query-source.d.ts +10 -0
  282. package/typed/sources/boundary-query-source.d.ts.map +1 -0
  283. package/typed/sources/boundary-table-source.d.ts +9 -0
  284. package/typed/sources/boundary-table-source.d.ts.map +1 -0
  285. package/typed/sources/boundary-tileset-source.d.ts +6 -0
  286. package/typed/sources/boundary-tileset-source.d.ts.map +1 -0
  287. package/typed/sources/h3-query-source.d.ts +3 -4
  288. package/typed/sources/h3-query-source.d.ts.map +1 -1
  289. package/typed/sources/h3-table-source.d.ts +3 -4
  290. package/typed/sources/h3-table-source.d.ts.map +1 -1
  291. package/typed/sources/h3-tileset-source.d.ts +3 -4
  292. package/typed/sources/h3-tileset-source.d.ts.map +1 -1
  293. package/typed/sources/index.d.ts +28 -22
  294. package/typed/sources/index.d.ts.map +1 -1
  295. package/typed/sources/quadbin-query-source.d.ts +3 -4
  296. package/typed/sources/quadbin-query-source.d.ts.map +1 -1
  297. package/typed/sources/quadbin-table-source.d.ts +3 -4
  298. package/typed/sources/quadbin-table-source.d.ts.map +1 -1
  299. package/typed/sources/quadbin-tileset-source.d.ts +3 -4
  300. package/typed/sources/quadbin-tileset-source.d.ts.map +1 -1
  301. package/typed/sources/raster-source.d.ts +3 -4
  302. package/typed/sources/raster-source.d.ts.map +1 -1
  303. package/typed/sources/{common.d.ts → types.d.ts} +26 -42
  304. package/typed/sources/types.d.ts.map +1 -0
  305. package/typed/sources/vector-query-source.d.ts +3 -4
  306. package/typed/sources/vector-query-source.d.ts.map +1 -1
  307. package/typed/sources/vector-table-source.d.ts +3 -4
  308. package/typed/sources/vector-table-source.d.ts.map +1 -1
  309. package/typed/sources/vector-tileset-source.d.ts +3 -4
  310. package/typed/sources/vector-tileset-source.d.ts.map +1 -1
  311. package/typed/style/color-bins-style.d.ts.map +1 -1
  312. package/typed/style/color-categories-style.d.ts.map +1 -1
  313. package/typed/style/color-continuous-style.d.ts.map +1 -1
  314. package/typed/style/utils.d.ts +0 -1
  315. package/typed/style/utils.d.ts.map +1 -1
  316. package/typed/utils.d.ts +8 -0
  317. package/typed/utils.d.ts.map +1 -1
  318. package/dist/es5/api/maps-api-common.js +0 -77
  319. package/dist/es5/api/maps-api-common.js.map +0 -1
  320. package/dist/es5/api/maps-client.js +0 -220
  321. package/dist/es5/api/maps-client.js.map +0 -1
  322. package/dist/es5/api/maps-v3-client.js +0 -959
  323. package/dist/es5/api/maps-v3-client.js.map +0 -1
  324. package/dist/es5/api/parseMap.js.map +0 -1
  325. package/dist/es5/config.js +0 -84
  326. package/dist/es5/config.js.map +0 -1
  327. package/dist/es5/layers/carto-layer.js +0 -329
  328. package/dist/es5/layers/carto-layer.js.map +0 -1
  329. package/dist/es5/sources/common.js +0 -48
  330. package/dist/es5/sources/common.js.map +0 -1
  331. package/dist/es5/sources/utils.js.map +0 -1
  332. package/dist/esm/api/maps-api-common.js +0 -54
  333. package/dist/esm/api/maps-api-common.js.map +0 -1
  334. package/dist/esm/api/maps-client.js +0 -148
  335. package/dist/esm/api/maps-client.js.map +0 -1
  336. package/dist/esm/api/maps-v3-client.js +0 -638
  337. package/dist/esm/api/maps-v3-client.js.map +0 -1
  338. package/dist/esm/api/parseMap.js.map +0 -1
  339. package/dist/esm/config.js +0 -60
  340. package/dist/esm/config.js.map +0 -1
  341. package/dist/esm/layers/carto-layer.js +0 -233
  342. package/dist/esm/layers/carto-layer.js.map +0 -1
  343. package/dist/esm/sources/common.js +0 -26
  344. package/dist/esm/sources/common.js.map +0 -1
  345. package/dist/esm/sources/utils.js.map +0 -1
  346. package/src/api/maps-api-common.ts +0 -95
  347. package/src/api/maps-client.ts +0 -196
  348. package/src/api/maps-v3-client.ts +0 -659
  349. package/src/config.ts +0 -70
  350. package/src/layers/carto-layer.ts +0 -340
  351. package/src/sources/common.ts +0 -132
  352. package/typed/api/maps-api-common.d.ts +0 -76
  353. package/typed/api/maps-api-common.d.ts.map +0 -1
  354. package/typed/api/maps-client.d.ts +0 -18
  355. package/typed/api/maps-client.d.ts.map +0 -1
  356. package/typed/api/maps-v3-client.d.ts +0 -49
  357. package/typed/api/maps-v3-client.d.ts.map +0 -1
  358. package/typed/api/parseMap.d.ts.map +0 -1
  359. package/typed/config.d.ts +0 -28
  360. package/typed/config.d.ts.map +0 -1
  361. package/typed/layers/carto-layer.d.ts +0 -126
  362. package/typed/layers/carto-layer.d.ts.map +0 -1
  363. package/typed/sources/common.d.ts.map +0 -1
  364. package/typed/sources/utils.d.ts +0 -15
  365. package/typed/sources/utils.d.ts.map +0 -1
@@ -1,959 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.mapInstantiation = mapInstantiation;
9
- exports.fetchLayerData = fetchLayerData;
10
- exports.fetchMap = fetchMap;
11
-
12
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
-
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
-
20
- var _config = require("../config");
21
-
22
- var _mapsApiCommon = require("./maps-api-common");
23
-
24
- var _cartoApiError = require("./carto-api-error");
25
-
26
- var _parseMap = require("./parseMap");
27
-
28
- var _core = require("@deck.gl/core");
29
-
30
- var _utils = require("../utils");
31
-
32
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
33
-
34
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
-
36
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37
-
38
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
39
-
40
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
41
-
42
- var MAX_GET_LENGTH = 8192;
43
- var DEFAULT_CLIENT = 'deck-gl-carto';
44
- var V3_MINOR_VERSION = '3.2';
45
-
46
- function request(_x) {
47
- return _request.apply(this, arguments);
48
- }
49
-
50
- function _request() {
51
- _request = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(_ref) {
52
- var method, url, customHeaders, accessToken, body, errorContext, headers;
53
- return _regenerator.default.wrap(function _callee$(_context) {
54
- while (1) {
55
- switch (_context.prev = _context.next) {
56
- case 0:
57
- method = _ref.method, url = _ref.url, customHeaders = _ref.headers, accessToken = _ref.accessToken, body = _ref.body, errorContext = _ref.errorContext;
58
- headers = _objectSpread(_objectSpread({}, customHeaders), {}, {
59
- Accept: 'application/json'
60
- });
61
-
62
- if (accessToken) {
63
- headers.Authorization = "Bearer ".concat(accessToken);
64
- }
65
-
66
- if (method === 'POST') {
67
- headers['Content-Type'] = 'application/json';
68
- }
69
-
70
- _context.prev = 4;
71
- _context.next = 7;
72
- return fetch(url, {
73
- method: method,
74
- headers: headers,
75
- body: body
76
- });
77
-
78
- case 7:
79
- return _context.abrupt("return", _context.sent);
80
-
81
- case 10:
82
- _context.prev = 10;
83
- _context.t0 = _context["catch"](4);
84
- throw new _cartoApiError.CartoAPIError(_context.t0, errorContext);
85
-
86
- case 13:
87
- case "end":
88
- return _context.stop();
89
- }
90
- }
91
- }, _callee, null, [[4, 10]]);
92
- }));
93
- return _request.apply(this, arguments);
94
- }
95
-
96
- function requestJson(_x2) {
97
- return _requestJson.apply(this, arguments);
98
- }
99
-
100
- function _requestJson() {
101
- _requestJson = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref2) {
102
- var method, url, headers, accessToken, body, errorContext, response, json;
103
- return _regenerator.default.wrap(function _callee2$(_context2) {
104
- while (1) {
105
- switch (_context2.prev = _context2.next) {
106
- case 0:
107
- method = _ref2.method, url = _ref2.url, headers = _ref2.headers, accessToken = _ref2.accessToken, body = _ref2.body, errorContext = _ref2.errorContext;
108
- _context2.next = 3;
109
- return request({
110
- method: method,
111
- url: url,
112
- headers: headers,
113
- accessToken: accessToken,
114
- body: body,
115
- errorContext: errorContext
116
- });
117
-
118
- case 3:
119
- response = _context2.sent;
120
- _context2.prev = 4;
121
- _context2.next = 7;
122
- return response.json();
123
-
124
- case 7:
125
- json = _context2.sent;
126
- _context2.next = 13;
127
- break;
128
-
129
- case 10:
130
- _context2.prev = 10;
131
- _context2.t0 = _context2["catch"](4);
132
- json = {
133
- error: ''
134
- };
135
-
136
- case 13:
137
- if (response.ok) {
138
- _context2.next = 15;
139
- break;
140
- }
141
-
142
- throw new _cartoApiError.CartoAPIError(json.error, errorContext, response);
143
-
144
- case 15:
145
- return _context2.abrupt("return", json);
146
-
147
- case 16:
148
- case "end":
149
- return _context2.stop();
150
- }
151
- }
152
- }, _callee2, null, [[4, 10]]);
153
- }));
154
- return _requestJson.apply(this, arguments);
155
- }
156
-
157
- function requestData(_x3) {
158
- return _requestData.apply(this, arguments);
159
- }
160
-
161
- function _requestData() {
162
- _requestData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(_ref3) {
163
- var method, url, accessToken, format, body, errorContext, data;
164
- return _regenerator.default.wrap(function _callee3$(_context3) {
165
- while (1) {
166
- switch (_context3.prev = _context3.next) {
167
- case 0:
168
- method = _ref3.method, url = _ref3.url, accessToken = _ref3.accessToken, format = _ref3.format, body = _ref3.body, errorContext = _ref3.errorContext;
169
- _context3.next = 3;
170
- return requestJson({
171
- method: method,
172
- url: url,
173
- accessToken: accessToken,
174
- body: body,
175
- errorContext: errorContext
176
- });
177
-
178
- case 3:
179
- data = _context3.sent;
180
- return _context3.abrupt("return", data.rows ? data.rows : data);
181
-
182
- case 5:
183
- case "end":
184
- return _context3.stop();
185
- }
186
- }
187
- }, _callee3);
188
- }));
189
- return _requestData.apply(this, arguments);
190
- }
191
-
192
- function getParameters(_ref4) {
193
- var type = _ref4.type,
194
- source = _ref4.source,
195
- geoColumn = _ref4.geoColumn,
196
- columns = _ref4.columns,
197
- clientId = _ref4.clientId,
198
- aggregationExp = _ref4.aggregationExp,
199
- aggregationResLevel = _ref4.aggregationResLevel,
200
- queryParameters = _ref4.queryParameters;
201
- var parameters = {
202
- client: clientId || DEFAULT_CLIENT,
203
- v: V3_MINOR_VERSION
204
- };
205
- var sourceName = type === _mapsApiCommon.MAP_TYPES.QUERY ? 'q' : 'name';
206
- parameters[sourceName] = source;
207
-
208
- if (queryParameters) {
209
- parameters.queryParameters = queryParameters;
210
- }
211
-
212
- if (geoColumn) {
213
- parameters.geo_column = geoColumn;
214
- }
215
-
216
- if (columns) {
217
- parameters.columns = columns.join(',');
218
- }
219
-
220
- if (aggregationExp) {
221
- parameters.aggregationExp = aggregationExp;
222
- } else if (isSpatialIndexGeoColumn(geoColumn)) {
223
- parameters.aggregationExp = '1 AS value';
224
- }
225
-
226
- if (aggregationResLevel) {
227
- parameters.aggregationResLevel = aggregationResLevel;
228
- }
229
-
230
- return parameters;
231
- }
232
-
233
- function isSpatialIndexGeoColumn(geoColumn) {
234
- var spatialIndex = geoColumn === null || geoColumn === void 0 ? void 0 : geoColumn.split(':')[0];
235
- return spatialIndex === 'h3' || spatialIndex === 'quadbin';
236
- }
237
-
238
- function mapInstantiation(_x4) {
239
- return _mapInstantiation.apply(this, arguments);
240
- }
241
-
242
- function _mapInstantiation() {
243
- _mapInstantiation = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(_ref5) {
244
- var type, source, connection, credentials, geoColumn, columns, clientId, headers, aggregationExp, aggregationResLevel, queryParameters, baseUrl, parameters, encodedParameters, url, accessToken, errorContext;
245
- return _regenerator.default.wrap(function _callee4$(_context4) {
246
- while (1) {
247
- switch (_context4.prev = _context4.next) {
248
- case 0:
249
- type = _ref5.type, source = _ref5.source, connection = _ref5.connection, credentials = _ref5.credentials, geoColumn = _ref5.geoColumn, columns = _ref5.columns, clientId = _ref5.clientId, headers = _ref5.headers, aggregationExp = _ref5.aggregationExp, aggregationResLevel = _ref5.aggregationResLevel, queryParameters = _ref5.queryParameters;
250
- baseUrl = "".concat(credentials.mapsUrl, "/").concat(connection, "/").concat(type);
251
- parameters = getParameters({
252
- type: type,
253
- source: source,
254
- geoColumn: geoColumn,
255
- columns: columns,
256
- clientId: clientId,
257
- aggregationResLevel: aggregationResLevel,
258
- aggregationExp: aggregationExp,
259
- queryParameters: queryParameters
260
- });
261
- encodedParameters = Object.entries(parameters).map(function (_ref12) {
262
- var _ref13 = (0, _slicedToArray2.default)(_ref12, 2),
263
- key = _ref13[0],
264
- value = _ref13[1];
265
-
266
- if (typeof value !== 'string') {
267
- value = JSON.stringify(value);
268
- }
269
-
270
- return (0, _mapsApiCommon.encodeParameter)(key, value);
271
- });
272
- url = "".concat(baseUrl, "?").concat(encodedParameters.join('&'));
273
- accessToken = credentials.accessToken;
274
- errorContext = {
275
- requestType: _mapsApiCommon.REQUEST_TYPES.INSTANTIATION,
276
- connection: connection,
277
- type: type,
278
- source: source
279
- };
280
-
281
- if (!(url.length > MAX_GET_LENGTH && type === _mapsApiCommon.MAP_TYPES.QUERY)) {
282
- _context4.next = 11;
283
- break;
284
- }
285
-
286
- _context4.next = 10;
287
- return requestJson({
288
- method: 'POST',
289
- url: baseUrl,
290
- headers: headers,
291
- accessToken: accessToken,
292
- body: JSON.stringify(parameters),
293
- errorContext: errorContext
294
- });
295
-
296
- case 10:
297
- return _context4.abrupt("return", _context4.sent);
298
-
299
- case 11:
300
- _context4.next = 13;
301
- return requestJson({
302
- url: url,
303
- headers: headers,
304
- accessToken: accessToken,
305
- errorContext: errorContext
306
- });
307
-
308
- case 13:
309
- return _context4.abrupt("return", _context4.sent);
310
-
311
- case 14:
312
- case "end":
313
- return _context4.stop();
314
- }
315
- }
316
- }, _callee4);
317
- }));
318
- return _mapInstantiation.apply(this, arguments);
319
- }
320
-
321
- function getUrlFromMetadata(metadata, format) {
322
- var m = metadata[format];
323
-
324
- if (m && !m.error && m.url) {
325
- return m.url[0];
326
- }
327
-
328
- return null;
329
- }
330
-
331
- function checkFetchLayerDataParameters(_ref6) {
332
- var type = _ref6.type,
333
- source = _ref6.source,
334
- connection = _ref6.connection,
335
- credentials = _ref6.credentials,
336
- geoColumn = _ref6.geoColumn,
337
- columns = _ref6.columns,
338
- aggregationExp = _ref6.aggregationExp,
339
- aggregationResLevel = _ref6.aggregationResLevel;
340
- (0, _utils.assert)(connection, 'Must define connection');
341
- (0, _utils.assert)(type, 'Must define a type');
342
- (0, _utils.assert)(source, 'Must define a source');
343
- (0, _utils.assert)(credentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
344
- (0, _utils.assert)(credentials.apiBaseUrl, 'Must define apiBaseUrl');
345
- (0, _utils.assert)(credentials.accessToken, 'Must define an accessToken');
346
-
347
- if (columns) {
348
- (0, _utils.assert)(_mapsApiCommon.COLUMNS_SUPPORT.includes(type), "The columns parameter is not supported by type ".concat(type));
349
- }
350
-
351
- if (geoColumn) {
352
- (0, _utils.assert)(_mapsApiCommon.GEO_COLUMN_SUPPORT.includes(type), "The geoColumn parameter is not supported by type ".concat(type));
353
- } else {
354
- (0, _utils.assert)(!aggregationExp, 'Have aggregationExp, but geoColumn parameter is missing');
355
- (0, _utils.assert)(!aggregationResLevel, 'Have aggregationResLevel, but geoColumn parameter is missing');
356
- }
357
- }
358
-
359
- function fetchLayerData(_x5) {
360
- return _fetchLayerData.apply(this, arguments);
361
- }
362
-
363
- function _fetchLayerData() {
364
- _fetchLayerData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(_ref7) {
365
- var type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, headers, aggregationExp, aggregationResLevel, queryParameters, _yield$_fetchDataUrl, url, accessToken, mapFormat, metadata, errorContext, data, result;
366
-
367
- return _regenerator.default.wrap(function _callee5$(_context5) {
368
- while (1) {
369
- switch (_context5.prev = _context5.next) {
370
- case 0:
371
- type = _ref7.type, source = _ref7.source, connection = _ref7.connection, credentials = _ref7.credentials, geoColumn = _ref7.geoColumn, columns = _ref7.columns, format = _ref7.format, formatTiles = _ref7.formatTiles, clientId = _ref7.clientId, headers = _ref7.headers, aggregationExp = _ref7.aggregationExp, aggregationResLevel = _ref7.aggregationResLevel, queryParameters = _ref7.queryParameters;
372
- _context5.next = 3;
373
- return _fetchDataUrl({
374
- type: type,
375
- source: source,
376
- connection: connection,
377
- credentials: credentials,
378
- geoColumn: geoColumn,
379
- columns: columns,
380
- format: format,
381
- formatTiles: formatTiles,
382
- clientId: clientId,
383
- headers: headers,
384
- aggregationExp: aggregationExp,
385
- aggregationResLevel: aggregationResLevel,
386
- queryParameters: queryParameters
387
- });
388
-
389
- case 3:
390
- _yield$_fetchDataUrl = _context5.sent;
391
- url = _yield$_fetchDataUrl.url;
392
- accessToken = _yield$_fetchDataUrl.accessToken;
393
- mapFormat = _yield$_fetchDataUrl.mapFormat;
394
- metadata = _yield$_fetchDataUrl.metadata;
395
- errorContext = {
396
- requestType: _mapsApiCommon.REQUEST_TYPES.DATA,
397
- connection: connection,
398
- type: type,
399
- source: source
400
- };
401
- _context5.next = 11;
402
- return requestData({
403
- url: url,
404
- format: mapFormat,
405
- accessToken: accessToken,
406
- errorContext: errorContext
407
- });
408
-
409
- case 11:
410
- data = _context5.sent;
411
- result = {
412
- data: data,
413
- format: mapFormat,
414
- schema: metadata.schema
415
- };
416
- return _context5.abrupt("return", result);
417
-
418
- case 14:
419
- case "end":
420
- return _context5.stop();
421
- }
422
- }
423
- }, _callee5);
424
- }));
425
- return _fetchLayerData.apply(this, arguments);
426
- }
427
-
428
- function _fetchDataUrl(_x6) {
429
- return _fetchDataUrl2.apply(this, arguments);
430
- }
431
-
432
- function _fetchDataUrl2() {
433
- _fetchDataUrl2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(_ref8) {
434
- var type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, headers, aggregationExp, aggregationResLevel, queryParameters, defaultCredentials, localCreds, metadata, url, mapFormat, prioritizedFormats, _i, _prioritizedFormats, f, accessToken;
435
-
436
- return _regenerator.default.wrap(function _callee6$(_context6) {
437
- while (1) {
438
- switch (_context6.prev = _context6.next) {
439
- case 0:
440
- type = _ref8.type, source = _ref8.source, connection = _ref8.connection, credentials = _ref8.credentials, geoColumn = _ref8.geoColumn, columns = _ref8.columns, format = _ref8.format, formatTiles = _ref8.formatTiles, clientId = _ref8.clientId, headers = _ref8.headers, aggregationExp = _ref8.aggregationExp, aggregationResLevel = _ref8.aggregationResLevel, queryParameters = _ref8.queryParameters;
441
- defaultCredentials = (0, _config.getDefaultCredentials)();
442
- localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
443
- checkFetchLayerDataParameters({
444
- type: type,
445
- source: source,
446
- connection: connection,
447
- credentials: localCreds,
448
- geoColumn: geoColumn,
449
- columns: columns,
450
- aggregationExp: aggregationExp,
451
- aggregationResLevel: aggregationResLevel
452
- });
453
-
454
- if (!localCreds.mapsUrl) {
455
- localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
456
- }
457
-
458
- _context6.next = 7;
459
- return mapInstantiation({
460
- type: type,
461
- source: source,
462
- connection: connection,
463
- credentials: localCreds,
464
- geoColumn: geoColumn,
465
- columns: columns,
466
- clientId: clientId,
467
- headers: headers,
468
- aggregationExp: aggregationExp,
469
- aggregationResLevel: aggregationResLevel,
470
- queryParameters: queryParameters
471
- });
472
-
473
- case 7:
474
- metadata = _context6.sent;
475
- url = null;
476
-
477
- if (!format) {
478
- _context6.next = 15;
479
- break;
480
- }
481
-
482
- mapFormat = format;
483
- url = getUrlFromMetadata(metadata, format);
484
- (0, _utils.assert)(url, "Format ".concat(format, " not available"));
485
- _context6.next = 27;
486
- break;
487
-
488
- case 15:
489
- prioritizedFormats = [_mapsApiCommon.FORMATS.GEOJSON, _mapsApiCommon.FORMATS.JSON, _mapsApiCommon.FORMATS.TILEJSON];
490
- _i = 0, _prioritizedFormats = prioritizedFormats;
491
-
492
- case 17:
493
- if (!(_i < _prioritizedFormats.length)) {
494
- _context6.next = 26;
495
- break;
496
- }
497
-
498
- f = _prioritizedFormats[_i];
499
- url = getUrlFromMetadata(metadata, f);
500
-
501
- if (!url) {
502
- _context6.next = 23;
503
- break;
504
- }
505
-
506
- mapFormat = f;
507
- return _context6.abrupt("break", 26);
508
-
509
- case 23:
510
- _i++;
511
- _context6.next = 17;
512
- break;
513
-
514
- case 26:
515
- (0, _utils.assert)(url && mapFormat, 'Unsupported data formats received from backend.');
516
-
517
- case 27:
518
- if (format === _mapsApiCommon.FORMATS.TILEJSON && formatTiles) {
519
- _core.log.assert(Object.values(_mapsApiCommon.TILE_FORMATS).includes(formatTiles), "Invalid value for formatTiles: ".concat(formatTiles, ". Use value from TILE_FORMATS"));
520
-
521
- url += "&".concat((0, _mapsApiCommon.encodeParameter)('formatTiles', formatTiles));
522
- }
523
-
524
- accessToken = localCreds.accessToken;
525
- return _context6.abrupt("return", {
526
- url: url,
527
- accessToken: accessToken,
528
- mapFormat: mapFormat,
529
- metadata: metadata
530
- });
531
-
532
- case 30:
533
- case "end":
534
- return _context6.stop();
535
- }
536
- }
537
- }, _callee6);
538
- }));
539
- return _fetchDataUrl2.apply(this, arguments);
540
- }
541
-
542
- function _fetchMapDataset(_x7, _x8, _x9, _x10, _x11) {
543
- return _fetchMapDataset2.apply(this, arguments);
544
- }
545
-
546
- function _fetchMapDataset2() {
547
- _fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(dataset, accessToken, credentials, clientId, headers) {
548
- var aggregationExp, aggregationResLevel, connection, columns, format, geoColumn, source, type, queryParameters, _yield$_fetchDataUrl2, url, mapFormat, cache, errorContext;
549
-
550
- return _regenerator.default.wrap(function _callee7$(_context7) {
551
- while (1) {
552
- switch (_context7.prev = _context7.next) {
553
- case 0:
554
- aggregationExp = dataset.aggregationExp, aggregationResLevel = dataset.aggregationResLevel, connection = dataset.connectionName, columns = dataset.columns, format = dataset.format, geoColumn = dataset.geoColumn, source = dataset.source, type = dataset.type, queryParameters = dataset.queryParameters;
555
- _context7.next = 3;
556
- return _fetchDataUrl({
557
- aggregationExp: aggregationExp,
558
- aggregationResLevel: aggregationResLevel,
559
- clientId: clientId,
560
- credentials: _objectSpread(_objectSpread({}, credentials), {}, {
561
- accessToken: accessToken
562
- }),
563
- connection: connection,
564
- columns: columns,
565
- format: format,
566
- geoColumn: geoColumn,
567
- headers: headers,
568
- source: source,
569
- type: type,
570
- queryParameters: queryParameters
571
- });
572
-
573
- case 3:
574
- _yield$_fetchDataUrl2 = _context7.sent;
575
- url = _yield$_fetchDataUrl2.url;
576
- mapFormat = _yield$_fetchDataUrl2.mapFormat;
577
- cache = parseInt(new URL(url).searchParams.get('cache') || '', 10);
578
-
579
- if (!(cache && dataset.cache === cache)) {
580
- _context7.next = 9;
581
- break;
582
- }
583
-
584
- return _context7.abrupt("return", false);
585
-
586
- case 9:
587
- dataset.cache = cache;
588
- errorContext = {
589
- requestType: _mapsApiCommon.REQUEST_TYPES.DATA,
590
- connection: connection,
591
- type: type,
592
- source: source
593
- };
594
- _context7.next = 13;
595
- return requestData({
596
- url: url,
597
- format: mapFormat,
598
- accessToken: accessToken,
599
- errorContext: errorContext
600
- });
601
-
602
- case 13:
603
- dataset.data = _context7.sent;
604
- return _context7.abrupt("return", true);
605
-
606
- case 15:
607
- case "end":
608
- return _context7.stop();
609
- }
610
- }
611
- }, _callee7);
612
- }));
613
- return _fetchMapDataset2.apply(this, arguments);
614
- }
615
-
616
- function _fetchTilestats(_x12, _x13, _x14, _x15) {
617
- return _fetchTilestats2.apply(this, arguments);
618
- }
619
-
620
- function _fetchTilestats2() {
621
- _fetchTilestats2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(attribute, dataset, accessToken, credentials) {
622
- var connection, source, type, statsUrl, baseUrl, errorContext, url, stats, attributes, index;
623
- return _regenerator.default.wrap(function _callee8$(_context8) {
624
- while (1) {
625
- switch (_context8.prev = _context8.next) {
626
- case 0:
627
- connection = dataset.connectionName, source = dataset.source, type = dataset.type;
628
- statsUrl = (0, _config.buildStatsUrlFromBase)(credentials.apiBaseUrl);
629
- baseUrl = "".concat(statsUrl, "/").concat(connection, "/");
630
-
631
- if (type === _mapsApiCommon.MAP_TYPES.QUERY) {
632
- baseUrl += attribute;
633
- } else {
634
- baseUrl += "".concat(source, "/").concat(attribute);
635
- }
636
-
637
- errorContext = {
638
- requestType: _mapsApiCommon.REQUEST_TYPES.TILE_STATS,
639
- connection: connection,
640
- type: type,
641
- source: source
642
- };
643
- url = baseUrl;
644
-
645
- if (type === _mapsApiCommon.MAP_TYPES.QUERY) {
646
- url += "?".concat((0, _mapsApiCommon.encodeParameter)('q', source));
647
- }
648
-
649
- if (!(url.length > MAX_GET_LENGTH && type === _mapsApiCommon.MAP_TYPES.QUERY)) {
650
- _context8.next = 13;
651
- break;
652
- }
653
-
654
- _context8.next = 10;
655
- return requestJson({
656
- method: 'POST',
657
- url: baseUrl,
658
- accessToken: accessToken,
659
- body: JSON.stringify({
660
- q: source
661
- }),
662
- errorContext: errorContext
663
- });
664
-
665
- case 10:
666
- stats = _context8.sent;
667
- _context8.next = 16;
668
- break;
669
-
670
- case 13:
671
- _context8.next = 15;
672
- return requestJson({
673
- url: url,
674
- accessToken: accessToken,
675
- errorContext: errorContext
676
- });
677
-
678
- case 15:
679
- stats = _context8.sent;
680
-
681
- case 16:
682
- attributes = dataset.data.tilestats.layers[0].attributes;
683
- index = attributes.findIndex(function (d) {
684
- return d.attribute === attribute;
685
- });
686
- attributes[index] = stats;
687
- return _context8.abrupt("return", true);
688
-
689
- case 20:
690
- case "end":
691
- return _context8.stop();
692
- }
693
- }
694
- }, _callee8);
695
- }));
696
- return _fetchTilestats2.apply(this, arguments);
697
- }
698
-
699
- function fillInMapDatasets(_x16, _x17, _x18, _x19) {
700
- return _fillInMapDatasets.apply(this, arguments);
701
- }
702
-
703
- function _fillInMapDatasets() {
704
- _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref9, clientId, credentials, headers) {
705
- var datasets, token, promises;
706
- return _regenerator.default.wrap(function _callee9$(_context9) {
707
- while (1) {
708
- switch (_context9.prev = _context9.next) {
709
- case 0:
710
- datasets = _ref9.datasets, token = _ref9.token;
711
- promises = datasets.map(function (dataset) {
712
- return _fetchMapDataset(dataset, token, credentials, clientId, headers);
713
- });
714
- _context9.next = 4;
715
- return Promise.all(promises);
716
-
717
- case 4:
718
- return _context9.abrupt("return", _context9.sent);
719
-
720
- case 5:
721
- case "end":
722
- return _context9.stop();
723
- }
724
- }
725
- }, _callee9);
726
- }));
727
- return _fillInMapDatasets.apply(this, arguments);
728
- }
729
-
730
- function fillInTileStats(_x20, _x21) {
731
- return _fillInTileStats.apply(this, arguments);
732
- }
733
-
734
- function _fillInTileStats() {
735
- _fillInTileStats = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10(_ref10, credentials) {
736
- var datasets, keplerMapConfig, token, attributes, layers, _iterator, _step, _loop2, filteredAttributes, _loop, _i2, _attributes, promises;
737
-
738
- return _regenerator.default.wrap(function _callee10$(_context10) {
739
- while (1) {
740
- switch (_context10.prev = _context10.next) {
741
- case 0:
742
- datasets = _ref10.datasets, keplerMapConfig = _ref10.keplerMapConfig, token = _ref10.token;
743
- attributes = [];
744
- layers = keplerMapConfig.config.visState.layers;
745
- _iterator = _createForOfIteratorHelper(layers);
746
-
747
- try {
748
- _loop2 = function _loop2() {
749
- var layer = _step.value;
750
-
751
- for (var _i3 = 0, _Object$keys = Object.keys(layer.visualChannels); _i3 < _Object$keys.length; _i3++) {
752
- var _layer$visualChannels;
753
-
754
- var channel = _Object$keys[_i3];
755
- var attribute = (_layer$visualChannels = layer.visualChannels[channel]) === null || _layer$visualChannels === void 0 ? void 0 : _layer$visualChannels.name;
756
-
757
- if (attribute) {
758
- var dataset = datasets.find(function (d) {
759
- return d.id === layer.config.dataId;
760
- });
761
-
762
- if (dataset.data.tilestats && dataset.type !== _mapsApiCommon.MAP_TYPES.TILESET) {
763
- attributes.push({
764
- attribute: attribute,
765
- dataset: dataset
766
- });
767
- }
768
- }
769
- }
770
- };
771
-
772
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
773
- _loop2();
774
- }
775
- } catch (err) {
776
- _iterator.e(err);
777
- } finally {
778
- _iterator.f();
779
- }
780
-
781
- filteredAttributes = [];
782
-
783
- _loop = function _loop() {
784
- var a = _attributes[_i2];
785
-
786
- if (!filteredAttributes.find(function (_ref14) {
787
- var attribute = _ref14.attribute,
788
- dataset = _ref14.dataset;
789
- return attribute === a.attribute && dataset === a.dataset;
790
- })) {
791
- filteredAttributes.push(a);
792
- }
793
- };
794
-
795
- for (_i2 = 0, _attributes = attributes; _i2 < _attributes.length; _i2++) {
796
- _loop();
797
- }
798
-
799
- promises = filteredAttributes.map(function (_ref15) {
800
- var attribute = _ref15.attribute,
801
- dataset = _ref15.dataset;
802
- return _fetchTilestats(attribute, dataset, token, credentials);
803
- });
804
- _context10.next = 11;
805
- return Promise.all(promises);
806
-
807
- case 11:
808
- return _context10.abrupt("return", _context10.sent);
809
-
810
- case 12:
811
- case "end":
812
- return _context10.stop();
813
- }
814
- }
815
- }, _callee10);
816
- }));
817
- return _fillInTileStats.apply(this, arguments);
818
- }
819
-
820
- function fetchMap(_x22) {
821
- return _fetchMap.apply(this, arguments);
822
- }
823
-
824
- function _fetchMap() {
825
- _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee12(_ref11) {
826
- var cartoMapId, clientId, credentials, headers, autoRefresh, onNewData, defaultCredentials, localCreds, accessToken, url, errorContext, map, stopAutoRefresh, intervalId, geojsonLayers, geojsonDatasetIds, out, textLayers, font;
827
- return _regenerator.default.wrap(function _callee12$(_context12) {
828
- while (1) {
829
- switch (_context12.prev = _context12.next) {
830
- case 0:
831
- cartoMapId = _ref11.cartoMapId, clientId = _ref11.clientId, credentials = _ref11.credentials, headers = _ref11.headers, autoRefresh = _ref11.autoRefresh, onNewData = _ref11.onNewData;
832
- defaultCredentials = (0, _config.getDefaultCredentials)();
833
- localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
834
- accessToken = localCreds.accessToken;
835
- (0, _utils.assert)(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
836
- (0, _utils.assert)(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
837
- (0, _utils.assert)(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
838
-
839
- if (!localCreds.mapsUrl) {
840
- localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
841
- }
842
-
843
- if (autoRefresh || onNewData) {
844
- (0, _utils.assert)(onNewData, 'Must define `onNewData` when using autoRefresh');
845
- (0, _utils.assert)(typeof onNewData === 'function', '`onNewData` must be a function');
846
- (0, _utils.assert)(typeof autoRefresh === 'number' && autoRefresh > 0, '`autoRefresh` must be a positive number');
847
- }
848
-
849
- url = "".concat(localCreds.mapsUrl, "/public/").concat(cartoMapId);
850
- errorContext = {
851
- requestType: _mapsApiCommon.REQUEST_TYPES.PUBLIC_MAP,
852
- mapId: cartoMapId
853
- };
854
- _context12.next = 13;
855
- return requestJson({
856
- url: url,
857
- headers: headers,
858
- accessToken: accessToken,
859
- errorContext: errorContext
860
- });
861
-
862
- case 13:
863
- map = _context12.sent;
864
-
865
- if (autoRefresh) {
866
- intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee11() {
867
- var changed;
868
- return _regenerator.default.wrap(function _callee11$(_context11) {
869
- while (1) {
870
- switch (_context11.prev = _context11.next) {
871
- case 0:
872
- _context11.next = 2;
873
- return fillInMapDatasets(map, clientId, localCreds, headers);
874
-
875
- case 2:
876
- changed = _context11.sent;
877
-
878
- if (onNewData && changed.some(function (v) {
879
- return v === true;
880
- })) {
881
- onNewData((0, _parseMap.parseMap)(map));
882
- }
883
-
884
- case 4:
885
- case "end":
886
- return _context11.stop();
887
- }
888
- }
889
- }, _callee11);
890
- })), autoRefresh * 1000);
891
-
892
- stopAutoRefresh = function stopAutoRefresh() {
893
- clearInterval(intervalId);
894
- };
895
- }
896
-
897
- geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(function (_ref17) {
898
- var type = _ref17.type;
899
- return type === 'geojson' || type === 'point';
900
- });
901
- geojsonDatasetIds = geojsonLayers.map(function (_ref18) {
902
- var config = _ref18.config;
903
- return config.dataId;
904
- });
905
- map.datasets.forEach(function (dataset) {
906
- if (geojsonDatasetIds.includes(dataset.id)) {
907
- var _geojsonLayers$find = geojsonLayers.find(function (_ref19) {
908
- var config = _ref19.config;
909
- return config.dataId === dataset.id;
910
- }),
911
- config = _geojsonLayers$find.config;
912
-
913
- dataset.format = 'geojson';
914
-
915
- if (!dataset.geoColumn && config.columns.geojson) {
916
- dataset.geoColumn = config.columns.geojson;
917
- }
918
- }
919
- });
920
- _context12.next = 20;
921
- return fillInMapDatasets(map, clientId, localCreds, headers);
922
-
923
- case 20:
924
- _context12.next = 22;
925
- return fillInTileStats(map, localCreds);
926
-
927
- case 22:
928
- out = _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
929
- stopAutoRefresh: stopAutoRefresh
930
- });
931
- textLayers = out.layers.filter(function (layer) {
932
- var pointType = layer.props.pointType || '';
933
- return pointType.includes('text');
934
- });
935
-
936
- if (!(textLayers.length && window.FontFace && !document.fonts.check('12px Inter'))) {
937
- _context12.next = 28;
938
- break;
939
- }
940
-
941
- font = new FontFace('Inter', 'url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2)');
942
- _context12.next = 28;
943
- return font.load().then(function (f) {
944
- return document.fonts.add(f);
945
- });
946
-
947
- case 28:
948
- return _context12.abrupt("return", out);
949
-
950
- case 29:
951
- case "end":
952
- return _context12.stop();
953
- }
954
- }
955
- }, _callee12);
956
- }));
957
- return _fetchMap.apply(this, arguments);
958
- }
959
- //# sourceMappingURL=maps-v3-client.js.map