basemapkit 0.1.1 → 0.1.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,4 +1,4 @@
1
- import { language_script_pairs as G, get_country_name as q, get_multiline_name as P } from "@protomaps/basemaps";
1
+ import { language_script_pairs as D, get_country_name as q, get_multiline_name as P } from "@protomaps/basemaps";
2
2
  const k = {
3
3
  aliceblue: [240, 248, 255],
4
4
  antiquewhite: [250, 235, 215],
@@ -223,7 +223,7 @@ y.get.hwb = function(n) {
223
223
  return null;
224
224
  };
225
225
  y.to.hex = function(...n) {
226
- return "#" + C(n[0]) + C(n[1]) + C(n[2]) + (n[3] < 1 ? C(Math.round(n[3] * 255)) : "");
226
+ return "#" + A(n[0]) + A(n[1]) + A(n[2]) + (n[3] < 1 ? A(Math.round(n[3] * 255)) : "");
227
227
  };
228
228
  y.to.rgb = function(...n) {
229
229
  return n.length < 4 || n[3] === 1 ? "rgb(" + Math.round(n[0]) + ", " + Math.round(n[1]) + ", " + Math.round(n[2]) + ")" : "rgba(" + Math.round(n[0]) + ", " + Math.round(n[1]) + ", " + Math.round(n[2]) + ", " + n[3] + ")";
@@ -245,7 +245,7 @@ y.to.keyword = function(...n) {
245
245
  function z(n, e, t) {
246
246
  return Math.min(Math.max(e, n), t);
247
247
  }
248
- function C(n) {
248
+ function A(n) {
249
249
  const e = Math.round(n).toString(16).toUpperCase();
250
250
  return e.length < 2 ? "0" + e : e;
251
251
  }
@@ -748,7 +748,7 @@ const K = [
748
748
  ], I = {};
749
749
  for (const n of Object.keys(b))
750
750
  I[[...b[n].labels].sort().join("")] = n;
751
- const A = {};
751
+ const C = {};
752
752
  function h(n, e) {
753
753
  if (!(this instanceof h))
754
754
  return new h(n, e);
@@ -787,9 +787,9 @@ function h(n, e) {
787
787
  a.push(n[r[t]]);
788
788
  this.color = R(a);
789
789
  }
790
- if (A[this.model])
790
+ if (C[this.model])
791
791
  for (o = b[this.model].channels, t = 0; t < o; t++) {
792
- const i = A[this.model][t];
792
+ const i = C[this.model][t];
793
793
  i && (this.color[t] = i(this.color[t]));
794
794
  }
795
795
  this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
@@ -976,7 +976,7 @@ function an(n) {
976
976
  function d(n, e, t) {
977
977
  n = Array.isArray(n) ? n : [n];
978
978
  for (const o of n)
979
- (A[o] || (A[o] = []))[e] = t;
979
+ (C[o] || (C[o] = []))[e] = t;
980
980
  return n = n[0], function(o) {
981
981
  let i;
982
982
  return o !== void 0 ? (t && (o = t(o)), i = this[n](), i.color[e] = o, i) : (i = this[n]().color[e], t && (i = t(i)), i);
@@ -1030,16 +1030,7 @@ function un(n, e) {
1030
1030
  return n.map((t) => cn(t, e));
1031
1031
  }
1032
1032
  function pn(n, e, t = 127) {
1033
- const o = n - t, i = e >= 0 ? 1 + e * 2 : (
1034
- // Map [0, 1] to [1, 3]
1035
- 1 + e
1036
- );
1037
- let l;
1038
- if (e >= 0) {
1039
- const r = Math.abs(o) / t, a = i * (1 + r * e * 0.5);
1040
- l = t + o * a;
1041
- } else
1042
- l = t + o * i;
1033
+ const o = Math.max(-0.99, Math.min(0.99, e)), i = o < 0 ? o + 1 : 1 / (1 - o), l = t + i * (n - t);
1043
1034
  return Math.round(Math.max(0, Math.min(255, l)));
1044
1035
  }
1045
1036
  function dn(n, e, t = 127) {
@@ -1246,7 +1237,7 @@ const fn = `[
1246
1237
  "layout": {"visibility": "visible"},
1247
1238
  "paint": {
1248
1239
  "fill-opacity": ["interpolate", ["linear"], ["zoom"], 0, 1, 7, 1],
1249
- "fill-color": "rgba(170, 222, 156, 1)"
1240
+ "fill-color": "rgb(184, 224, 173)"
1250
1241
  }
1251
1242
  },
1252
1243
  {
@@ -3165,10 +3156,10 @@ const fn = `[
3165
3156
  }
3166
3157
  ]`;
3167
3158
  function Y(n, e) {
3168
- const t = G.filter((o) => o.lang === n);
3159
+ const t = D.filter((o) => o.lang === n);
3169
3160
  if (t.length === 0)
3170
3161
  throw new Error(
3171
- `The language "${n}". The languages available are: ${G.map((o) => o.lang).join(", ")}.`
3162
+ `The language "${n}". The languages available are: ${D.map((o) => o.lang).join(", ")}.`
3172
3163
  );
3173
3164
  if (e) {
3174
3165
  if (t.filter((i) => i.script === e).length)
@@ -3183,73 +3174,88 @@ function yn() {
3183
3174
  const n = Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];
3184
3175
  return Y(n, void 0) ? n : "en";
3185
3176
  }
3186
- const O = {
3187
- versatile: fn
3177
+ const E = {
3178
+ avenue: fn
3188
3179
  }, $ = {
3189
- "versatile-night": {
3190
- baseStyle: "versatile",
3180
+ "avenue-pop": {
3181
+ baseStyle: "avenue",
3182
+ colorEdit: {
3183
+ negate: !1,
3184
+ brightness: 0,
3185
+ brightnessShift: 0,
3186
+ exposure: 0,
3187
+ contrast: [0.4, 220],
3188
+ hueRotation: -8,
3189
+ saturation: -0.1,
3190
+ multiplyColor: ["#ff0000", 0],
3191
+ mixColor: ["#ff0000", 0.02]
3192
+ }
3193
+ },
3194
+ "avenue-saturated": {
3195
+ baseStyle: "avenue",
3196
+ colorEdit: {
3197
+ exposure: -1,
3198
+ saturation: 0.1
3199
+ }
3200
+ },
3201
+ "avenue-night": {
3202
+ baseStyle: "avenue",
3191
3203
  colorEdit: {
3192
3204
  brightness: -0.3,
3193
3205
  saturation: -0.8,
3194
3206
  multiplyColor: ["#171075", 0.6],
3195
- contrast: [1.6, 160]
3207
+ contrast: [0.8, 160]
3196
3208
  }
3197
3209
  },
3198
- "versatile-bright": {
3199
- baseStyle: "versatile",
3210
+ "avenue-bright": {
3211
+ baseStyle: "avenue",
3200
3212
  colorEdit: {
3201
3213
  exposure: 0.6,
3202
- saturation: -0.1,
3214
+ saturation: -0.25,
3203
3215
  hueRotation: 15,
3204
- contrast: [0.2, 220]
3216
+ contrast: [0.4, 220]
3205
3217
  }
3206
3218
  },
3207
- "versatile-bnw": {
3208
- baseStyle: "versatile",
3219
+ "avenue-bnw": {
3220
+ baseStyle: "avenue",
3209
3221
  colorEdit: {
3210
3222
  exposure: -1,
3211
3223
  saturation: -1,
3212
- contrast: [1.2, 160]
3224
+ contrast: [0.6, 160]
3213
3225
  }
3214
3226
  },
3215
- "versatile-blueprint": {
3216
- baseStyle: "versatile",
3227
+ "avenue-blueprint": {
3228
+ baseStyle: "avenue",
3217
3229
  colorEdit: {
3218
3230
  exposure: -0.7,
3219
3231
  saturation: -1,
3220
- contrast: [1.2, 160],
3232
+ contrast: [0.75, 160],
3221
3233
  mixColor: ["#3355bb", 0.15]
3222
3234
  }
3223
3235
  },
3224
- "versatile-warm": {
3225
- baseStyle: "versatile",
3236
+ "avenue-warm": {
3237
+ baseStyle: "avenue",
3226
3238
  colorEdit: {
3227
3239
  exposure: -0.7,
3228
- contrast: [-0.1, 110],
3229
- mixColor: ["#ff8800", 0.1]
3240
+ mixColor: ["#ff8800", 0.1],
3241
+ contrast: [0.1, 200]
3230
3242
  }
3231
3243
  },
3232
- "versatile-vintage": {
3233
- baseStyle: "versatile",
3244
+ "avenue-vintage": {
3245
+ baseStyle: "avenue",
3234
3246
  colorEdit: {
3235
3247
  exposure: -0.25,
3236
3248
  multiplyColor: ["#ff8800", 0.4],
3237
- hueRotation: -5
3238
- }
3239
- },
3240
- "versatile-saturated": {
3241
- baseStyle: "versatile",
3242
- colorEdit: {
3243
- exposure: -1,
3244
- saturation: 0.1
3249
+ hueRotation: -5,
3250
+ contrast: [0.2, 200]
3245
3251
  }
3246
3252
  }
3247
3253
  };
3248
3254
  function kn() {
3249
- return Object.keys(O).concat(Object.keys($));
3255
+ return Object.keys(E).concat(Object.keys($));
3250
3256
  }
3251
3257
  function xn(n, e) {
3252
- if (n in O)
3258
+ if (n in E)
3253
3259
  return U({
3254
3260
  ...e,
3255
3261
  baseStyleName: n
@@ -3275,9 +3281,9 @@ function U(n) {
3275
3281
  const g = yn();
3276
3282
  e = JSON.stringify(q(g)), t = JSON.stringify(P(g));
3277
3283
  }
3278
- if (!(n.baseStyleName in O))
3284
+ if (!(n.baseStyleName in E))
3279
3285
  throw new Error(`The base style ${n.baseStyleName} does not exist.`);
3280
- const l = O[n.baseStyleName].replaceAll('"<LANG>"', t).replaceAll('"<LANG_COUNTRY>"', e);
3286
+ const l = E[n.baseStyleName].replaceAll('"<LANG>"', t).replaceAll('"<LANG_COUNTRY>"', e);
3281
3287
  let r;
3282
3288
  if (typeof n.tilejson == "string")
3283
3289
  r = n.tilejson;
@@ -3298,12 +3304,13 @@ function U(n) {
3298
3304
  }
3299
3305
  a = a.filter((p) => p.id === "pois" || p.type !== "symbol" ? !0 : !(p.layout !== void 0 && p.layout["text-field"] !== void 0));
3300
3306
  }
3301
- const u = n.colorEdit ?? {}, _ = u.brightness ?? 0, m = u.hueRotation ?? 0, F = u.saturation ?? 0, D = u.negate ?? !1, E = u.brightnessShift ?? 0, j = u.exposure ?? 0;
3302
- return (_ !== 0 || m !== 0 || F !== 0 || D === !0 || u.multiplyColor !== void 0 || u.mixColor !== void 0 || E !== 0 || u.contrast !== void 0 || j !== 0) && T(a, (g) => {
3307
+ const u = n.colorEdit ?? {}, _ = u.brightness ?? 0, m = u.hueRotation ?? 0, F = u.saturation ?? 0, G = u.negate ?? !1, O = u.brightnessShift ?? 0, j = u.exposure ?? 0;
3308
+ return (_ !== 0 || m !== 0 || F !== 0 || G === !0 || u.multiplyColor !== void 0 || u.mixColor !== void 0 || O !== 0 || u.contrast !== void 0 || j !== 0) && T(a, (g) => {
3309
+ g === "#a6e085" && console.log("#a6e085");
3303
3310
  let p = h(g);
3304
- if (D && (p = p.negate()), m !== 0 && (p = p.rotate(m)), F !== 0 && (p = p.saturate(F)), _ > 0 ? p = p.lighten(_) : _ < 0 && (p = p.darken(_ * -1)), E !== 0) {
3311
+ if (G && (p = p.negate()), m !== 0 && (p = p.rotate(m)), F !== 0 && (p = p.saturate(F)), _ > 0 ? p = p.lighten(_) : _ < 0 && (p = p.darken(_ * -1)), O !== 0) {
3305
3312
  const M = p.hsl().array();
3306
- M[2] += E * 100, p = h.hsl(...M);
3313
+ M[2] += O * 100, p = h.hsl(...M);
3307
3314
  }
3308
3315
  Array.isArray(u.mixColor) && typeof u.mixColor[0] == "string" && typeof u.mixColor[1] == "number" && u.mixColor[1] !== 0 && (p = p.mix(h(u.mixColor[0]), u.mixColor[1]));
3309
3316
  const v = p.rgb(), H = v.alpha();