@mapbox/mapbox-gl-style-spec 14.1.0 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -581,12 +581,12 @@ var source_vector = {
581
581
  },
582
582
  url: {
583
583
  type: "string",
584
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
584
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
585
585
  },
586
586
  tiles: {
587
587
  type: "array",
588
588
  value: "string",
589
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
589
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
590
590
  },
591
591
  bounds: {
592
592
  type: "array",
@@ -660,12 +660,12 @@ var source_raster = {
660
660
  },
661
661
  url: {
662
662
  type: "string",
663
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
663
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
664
664
  },
665
665
  tiles: {
666
666
  type: "array",
667
667
  value: "string",
668
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
668
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
669
669
  },
670
670
  bounds: {
671
671
  type: "array",
@@ -741,12 +741,12 @@ var source_raster_dem = {
741
741
  },
742
742
  url: {
743
743
  type: "string",
744
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
744
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
745
745
  },
746
746
  tiles: {
747
747
  type: "array",
748
748
  value: "string",
749
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
749
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
750
750
  },
751
751
  bounds: {
752
752
  type: "array",
@@ -822,12 +822,12 @@ var source_raster_array = {
822
822
  },
823
823
  url: {
824
824
  type: "string",
825
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
825
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
826
826
  },
827
827
  tiles: {
828
828
  type: "array",
829
829
  value: "string",
830
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
830
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
831
831
  },
832
832
  bounds: {
833
833
  type: "array",
@@ -1180,7 +1180,7 @@ var layer = {
1180
1180
  },
1181
1181
  "source-layer": {
1182
1182
  type: "string",
1183
- doc: "Layer to use from a vector tile source. Required for vector tile sources; prohibited for all other source types, including GeoJSON sources."
1183
+ doc: "Layer to use from a vector tile source. Required for vector and raster-array sources; prohibited for all other source types, including GeoJSON sources."
1184
1184
  },
1185
1185
  slot: {
1186
1186
  type: "string",
@@ -6885,7 +6885,12 @@ var paint_raster = {
6885
6885
  required: false,
6886
6886
  "property-type": "data-constant",
6887
6887
  transition: false,
6888
- doc: "Displayed band of raster array source layer",
6888
+ requires: [
6889
+ {
6890
+ source: "raster-array"
6891
+ }
6892
+ ],
6893
+ doc: "Displayed band of raster array source layer. Defaults to the first band if not set.",
6889
6894
  example: "band-name",
6890
6895
  "sdk-support": {
6891
6896
  "basic functionality": {
@@ -8299,12 +8304,6 @@ var v8 = {
8299
8304
  },
8300
8305
  transition: true,
8301
8306
  doc: "Controls the intensity of shading near ground and concave angles between walls. Default value 0.0 disables ambient occlusion and values around 0.3 provide the most plausible results for buildings.",
8302
- requires: [
8303
- "lights",
8304
- {
8305
- "!": "fill-extrusion-flood-light-intensity"
8306
- }
8307
- ],
8308
8307
  "sdk-support": {
8309
8308
  "basic functionality": {
8310
8309
  js: "3.0.0",
@@ -8328,10 +8327,7 @@ var v8 = {
8328
8327
  transition: true,
8329
8328
  doc: "Shades area near ground and concave angles between walls where the radius defines only vertical impact. Default value 3.0 corresponds to height of one floor and brings the most plausible results for buildings. This property works only with legacy light. When 3D lights are enabled `fill-extrusion-ambient-occlusion-wall-radius` and `fill-extrusion-ambient-occlusion-ground-radius` are used instead.",
8330
8329
  requires: [
8331
- "fill-extrusion-edge-radius",
8332
- {
8333
- "!": "fill-extrusion-flood-light-intensity"
8334
- }
8330
+ "fill-extrusion-edge-radius"
8335
8331
  ],
8336
8332
  "sdk-support": {
8337
8333
  "basic functionality": {
@@ -8356,10 +8352,7 @@ var v8 = {
8356
8352
  doc: "Shades area near ground and concave angles between walls where the radius defines only vertical impact. Default value 3.0 corresponds to height of one floor and brings the most plausible results for buildings.",
8357
8353
  requires: [
8358
8354
  "lights",
8359
- "fill-extrusion-edge-radius",
8360
- {
8361
- "!": "fill-extrusion-flood-light-intensity"
8362
- }
8355
+ "fill-extrusion-edge-radius"
8363
8356
  ],
8364
8357
  "sdk-support": {
8365
8358
  "basic functionality": {
@@ -8383,10 +8376,7 @@ var v8 = {
8383
8376
  transition: true,
8384
8377
  doc: "The extent of the ambient occlusion effect on the ground beneath the extruded buildings in meters.",
8385
8378
  requires: [
8386
- "lights",
8387
- {
8388
- "!": "fill-extrusion-flood-light-intensity"
8389
- }
8379
+ "lights"
8390
8380
  ],
8391
8381
  "sdk-support": {
8392
8382
  "basic functionality": {
@@ -8404,10 +8394,7 @@ var v8 = {
8404
8394
  maximum: 1,
8405
8395
  doc: "Provides a control to futher fine-tune the look of the ambient occlusion on the ground beneath the extruded buildings. Lower values give the effect a more solid look while higher values make it smoother.",
8406
8396
  requires: [
8407
- "lights",
8408
- {
8409
- "!": "fill-extrusion-flood-light-intensity"
8410
- }
8397
+ "lights"
8411
8398
  ],
8412
8399
  transition: true,
8413
8400
  expression: {
@@ -8430,10 +8417,7 @@ var v8 = {
8430
8417
  "default": "#ffffff",
8431
8418
  doc: "The color of the flood light effect on the walls of the extruded buildings.",
8432
8419
  requires: [
8433
- "lights",
8434
- {
8435
- "!": "fill-extrusion-ambient-occlusion-intensity"
8436
- }
8420
+ "lights"
8437
8421
  ],
8438
8422
  transition: true,
8439
8423
  expression: {
@@ -8459,10 +8443,7 @@ var v8 = {
8459
8443
  maximum: 1,
8460
8444
  doc: "The intensity of the flood light color.",
8461
8445
  requires: [
8462
- "lights",
8463
- {
8464
- "!": "fill-extrusion-ambient-occlusion-intensity"
8465
- }
8446
+ "lights"
8466
8447
  ],
8467
8448
  transition: true,
8468
8449
  expression: {
@@ -8488,10 +8469,7 @@ var v8 = {
8488
8469
  minimum: 0,
8489
8470
  doc: "The extent of the flood light effect on the walls of the extruded buildings in meters.",
8490
8471
  requires: [
8491
- "lights",
8492
- {
8493
- "!": "fill-extrusion-ambient-occlusion-intensity"
8494
- }
8472
+ "lights"
8495
8473
  ],
8496
8474
  transition: true,
8497
8475
  expression: {
@@ -8519,13 +8497,9 @@ var v8 = {
8519
8497
  type: "number",
8520
8498
  units: "meters",
8521
8499
  "default": 0,
8522
- minimum: 0,
8523
8500
  doc: "The extent of the flood light effect on the ground beneath the extruded buildings in meters.",
8524
8501
  requires: [
8525
- "lights",
8526
- {
8527
- "!": "fill-extrusion-ambient-occlusion-intensity"
8528
- }
8502
+ "lights"
8529
8503
  ],
8530
8504
  transition: true,
8531
8505
  expression: {
@@ -8556,10 +8530,7 @@ var v8 = {
8556
8530
  maximum: 1,
8557
8531
  doc: "Provides a control to futher fine-tune the look of the flood light on the ground beneath the extruded buildings. Lower values give the effect a more solid look while higher values make it smoother.",
8558
8532
  requires: [
8559
- "lights",
8560
- {
8561
- "!": "fill-extrusion-ambient-occlusion-intensity"
8562
- }
8533
+ "lights"
8563
8534
  ],
8564
8535
  transition: true,
8565
8536
  expression: {
@@ -8625,7 +8596,7 @@ var v8 = {
8625
8596
  "default": 0,
8626
8597
  minimum: 0,
8627
8598
  maximum: 1,
8628
- doc: "This parameter defines the range for the fade-out effect before an automatic content cutoff on pitched map views. The automatic cutoff range is calculated according to the minimum required zoom level of the source and layer. The fade range is expressed in relation to the height of the map view. A value of 1.0 indicates that the content is faded to the same extent as the map's height in pixels, while a value close to zero represents a sharp cutoff. When the value is set to 0.0, the cutoff is completely disabled. Note: The property has no effect on the map if terrain is enabled.",
8599
+ doc: "This parameter defines the range for the fade-out effect before an automatic content cutoff on pitched map views. Fade out is implemented by scaling down and removing buildings in the fade range in a staggered fashion. Opacity is not changed. The fade range is expressed in relation to the height of the map view. A value of 1.0 indicates that the content is faded to the same extent as the map's height in pixels, while a value close to zero represents a sharp cutoff. When the value is set to 0.0, the cutoff is completely disabled. Note: The property has no effect on the map if terrain is enabled.",
8629
8600
  transition: false,
8630
8601
  expression: {
8631
8602
  interpolated: false
@@ -8766,6 +8737,7 @@ function stringify(passedObj, options = {}) {
8766
8737
  }(passedObj, '', 0);
8767
8738
  }
8768
8739
 
8740
+ //
8769
8741
  function sortKeysBy(obj, reference) {
8770
8742
  const result = {};
8771
8743
  for (const key in reference) {
@@ -8809,1177 +8781,6 @@ function format(style, space = 2) {
8809
8781
  return stringify(style, { indent: space });
8810
8782
  }
8811
8783
 
8812
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8813
-
8814
- function getDefaultExportFromCjs (x) {
8815
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
8816
- }
8817
-
8818
- var url = {};
8819
-
8820
- var punycode$1 = {exports: {}};
8821
-
8822
- /*! https://mths.be/punycode v1.3.2 by @mathias */
8823
- punycode$1.exports;
8824
-
8825
- (function (module, exports) {
8826
- (function (root) {
8827
- /** Detect free variables */
8828
- var freeExports = exports && !exports.nodeType && exports;
8829
- var freeModule = module && !module.nodeType && module;
8830
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
8831
- if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
8832
- root = freeGlobal;
8833
- }
8834
- /**
8835
- * The `punycode` object.
8836
- * @name punycode
8837
- * @type Object
8838
- */
8839
- var punycode,
8840
- /** Highest positive signed 32-bit float value */
8841
- maxInt = 2147483647,
8842
- // aka. 0x7FFFFFFF or 2^31-1
8843
- /** Bootstring parameters */
8844
- base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128,
8845
- // 0x80
8846
- delimiter = '-',
8847
- // '\x2D'
8848
- /** Regular expressions */
8849
- regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/,
8850
- // unprintable ASCII chars + non-ASCII chars
8851
- regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g,
8852
- // RFC 3490 separators
8853
- /** Error messages */
8854
- errors = {
8855
- 'overflow': 'Overflow: input needs wider integers to process',
8856
- 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
8857
- 'invalid-input': 'Invalid input'
8858
- },
8859
- /** Convenience shortcuts */
8860
- baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode,
8861
- /** Temporary variable */
8862
- key;
8863
- /*--------------------------------------------------------------------------*/
8864
- /**
8865
- * A generic error utility function.
8866
- * @private
8867
- * @param {String} type The error type.
8868
- * @returns {Error} Throws a `RangeError` with the applicable error message.
8869
- */
8870
- function error(type) {
8871
- throw RangeError(errors[type]);
8872
- }
8873
- /**
8874
- * A generic `Array#map` utility function.
8875
- * @private
8876
- * @param {Array} array The array to iterate over.
8877
- * @param {Function} callback The function that gets called for every array
8878
- * item.
8879
- * @returns {Array} A new array of values returned by the callback function.
8880
- */
8881
- function map(array, fn) {
8882
- var length = array.length;
8883
- var result = [];
8884
- while (length--) {
8885
- result[length] = fn(array[length]);
8886
- }
8887
- return result;
8888
- }
8889
- /**
8890
- * A simple `Array#map`-like wrapper to work with domain name strings or email
8891
- * addresses.
8892
- * @private
8893
- * @param {String} domain The domain name or email address.
8894
- * @param {Function} callback The function that gets called for every
8895
- * character.
8896
- * @returns {Array} A new string of characters returned by the callback
8897
- * function.
8898
- */
8899
- function mapDomain(string, fn) {
8900
- var parts = string.split('@');
8901
- var result = '';
8902
- if (parts.length > 1) {
8903
- // In email addresses, only the domain name should be punycoded. Leave
8904
- // the local part (i.e. everything up to `@`) intact.
8905
- result = parts[0] + '@';
8906
- string = parts[1];
8907
- }
8908
- // Avoid `split(regex)` for IE8 compatibility. See #17.
8909
- string = string.replace(regexSeparators, '.');
8910
- var labels = string.split('.');
8911
- var encoded = map(labels, fn).join('.');
8912
- return result + encoded;
8913
- }
8914
- /**
8915
- * Creates an array containing the numeric code points of each Unicode
8916
- * character in the string. While JavaScript uses UCS-2 internally,
8917
- * this function will convert a pair of surrogate halves (each of which
8918
- * UCS-2 exposes as separate characters) into a single code point,
8919
- * matching UTF-16.
8920
- * @see `punycode.ucs2.encode`
8921
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
8922
- * @memberOf punycode.ucs2
8923
- * @name decode
8924
- * @param {String} string The Unicode input string (UCS-2).
8925
- * @returns {Array} The new array of code points.
8926
- */
8927
- function ucs2decode(string) {
8928
- var output = [], counter = 0, length = string.length, value, extra;
8929
- while (counter < length) {
8930
- value = string.charCodeAt(counter++);
8931
- if (value >= 55296 && value <= 56319 && counter < length) {
8932
- // high surrogate, and there is a next character
8933
- extra = string.charCodeAt(counter++);
8934
- if ((extra & 64512) == 56320) {
8935
- // low surrogate
8936
- output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
8937
- } else {
8938
- // unmatched surrogate; only append this code unit, in case the next
8939
- // code unit is the high surrogate of a surrogate pair
8940
- output.push(value);
8941
- counter--;
8942
- }
8943
- } else {
8944
- output.push(value);
8945
- }
8946
- }
8947
- return output;
8948
- }
8949
- /**
8950
- * Creates a string based on an array of numeric code points.
8951
- * @see `punycode.ucs2.decode`
8952
- * @memberOf punycode.ucs2
8953
- * @name encode
8954
- * @param {Array} codePoints The array of numeric code points.
8955
- * @returns {String} The new Unicode string (UCS-2).
8956
- */
8957
- function ucs2encode(array) {
8958
- return map(array, function (value) {
8959
- var output = '';
8960
- if (value > 65535) {
8961
- value -= 65536;
8962
- output += stringFromCharCode(value >>> 10 & 1023 | 55296);
8963
- value = 56320 | value & 1023;
8964
- }
8965
- output += stringFromCharCode(value);
8966
- return output;
8967
- }).join('');
8968
- }
8969
- /**
8970
- * Converts a basic code point into a digit/integer.
8971
- * @see `digitToBasic()`
8972
- * @private
8973
- * @param {Number} codePoint The basic numeric code point value.
8974
- * @returns {Number} The numeric value of a basic code point (for use in
8975
- * representing integers) in the range `0` to `base - 1`, or `base` if
8976
- * the code point does not represent a value.
8977
- */
8978
- function basicToDigit(codePoint) {
8979
- if (codePoint - 48 < 10) {
8980
- return codePoint - 22;
8981
- }
8982
- if (codePoint - 65 < 26) {
8983
- return codePoint - 65;
8984
- }
8985
- if (codePoint - 97 < 26) {
8986
- return codePoint - 97;
8987
- }
8988
- return base;
8989
- }
8990
- /**
8991
- * Converts a digit/integer into a basic code point.
8992
- * @see `basicToDigit()`
8993
- * @private
8994
- * @param {Number} digit The numeric value of a basic code point.
8995
- * @returns {Number} The basic code point whose value (when used for
8996
- * representing integers) is `digit`, which needs to be in the range
8997
- * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
8998
- * used; else, the lowercase form is used. The behavior is undefined
8999
- * if `flag` is non-zero and `digit` has no uppercase form.
9000
- */
9001
- function digitToBasic(digit, flag) {
9002
- // 0..25 map to ASCII a..z or A..Z
9003
- // 26..35 map to ASCII 0..9
9004
- return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
9005
- }
9006
- /**
9007
- * Bias adaptation function as per section 3.4 of RFC 3492.
9008
- * http://tools.ietf.org/html/rfc3492#section-3.4
9009
- * @private
9010
- */
9011
- function adapt(delta, numPoints, firstTime) {
9012
- var k = 0;
9013
- delta = firstTime ? floor(delta / damp) : delta >> 1;
9014
- delta += floor(delta / numPoints);
9015
- for (; delta > baseMinusTMin * tMax >> 1; k += base) {
9016
- delta = floor(delta / baseMinusTMin);
9017
- }
9018
- return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
9019
- }
9020
- /**
9021
- * Converts a Punycode string of ASCII-only symbols to a string of Unicode
9022
- * symbols.
9023
- * @memberOf punycode
9024
- * @param {String} input The Punycode string of ASCII-only symbols.
9025
- * @returns {String} The resulting string of Unicode symbols.
9026
- */
9027
- function decode(input) {
9028
- // Don't use UCS-2
9029
- var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t,
9030
- /** Cached calculation results */
9031
- baseMinusT;
9032
- // Handle the basic code points: let `basic` be the number of input code
9033
- // points before the last delimiter, or `0` if there is none, then copy
9034
- // the first basic code points to the output.
9035
- basic = input.lastIndexOf(delimiter);
9036
- if (basic < 0) {
9037
- basic = 0;
9038
- }
9039
- for (j = 0; j < basic; ++j) {
9040
- // if it's not a basic code point
9041
- if (input.charCodeAt(j) >= 128) {
9042
- error('not-basic');
9043
- }
9044
- output.push(input.charCodeAt(j));
9045
- }
9046
- // Main decoding loop: start just after the last delimiter if any basic code
9047
- // points were copied; start at the beginning otherwise.
9048
- for (index = basic > 0 ? basic + 1 : 0; index < inputLength;) {
9049
- // `index` is the index of the next character to be consumed.
9050
- // Decode a generalized variable-length integer into `delta`,
9051
- // which gets added to `i`. The overflow checking is easier
9052
- // if we increase `i` as we go, then subtract off its starting
9053
- // value at the end to obtain `delta`.
9054
- for (oldi = i, w = 1, k = base;; k += base) {
9055
- if (index >= inputLength) {
9056
- error('invalid-input');
9057
- }
9058
- digit = basicToDigit(input.charCodeAt(index++));
9059
- if (digit >= base || digit > floor((maxInt - i) / w)) {
9060
- error('overflow');
9061
- }
9062
- i += digit * w;
9063
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
9064
- if (digit < t) {
9065
- break;
9066
- }
9067
- baseMinusT = base - t;
9068
- if (w > floor(maxInt / baseMinusT)) {
9069
- error('overflow');
9070
- }
9071
- w *= baseMinusT;
9072
- }
9073
- out = output.length + 1;
9074
- bias = adapt(i - oldi, out, oldi == 0);
9075
- // `i` was supposed to wrap around from `out` to `0`,
9076
- // incrementing `n` each time, so we'll fix that now:
9077
- if (floor(i / out) > maxInt - n) {
9078
- error('overflow');
9079
- }
9080
- n += floor(i / out);
9081
- i %= out;
9082
- // Insert `n` at position `i` of the output
9083
- output.splice(i++, 0, n);
9084
- }
9085
- return ucs2encode(output);
9086
- }
9087
- /**
9088
- * Converts a string of Unicode symbols (e.g. a domain name label) to a
9089
- * Punycode string of ASCII-only symbols.
9090
- * @memberOf punycode
9091
- * @param {String} input The string of Unicode symbols.
9092
- * @returns {String} The resulting Punycode string of ASCII-only symbols.
9093
- */
9094
- function encode(input) {
9095
- var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [],
9096
- /** `inputLength` will hold the number of code points in `input`. */
9097
- inputLength,
9098
- /** Cached calculation results */
9099
- handledCPCountPlusOne, baseMinusT, qMinusT;
9100
- // Convert the input in UCS-2 to Unicode
9101
- input = ucs2decode(input);
9102
- // Cache the length
9103
- inputLength = input.length;
9104
- // Initialize the state
9105
- n = initialN;
9106
- delta = 0;
9107
- bias = initialBias;
9108
- // Handle the basic code points
9109
- for (j = 0; j < inputLength; ++j) {
9110
- currentValue = input[j];
9111
- if (currentValue < 128) {
9112
- output.push(stringFromCharCode(currentValue));
9113
- }
9114
- }
9115
- handledCPCount = basicLength = output.length;
9116
- // `handledCPCount` is the number of code points that have been handled;
9117
- // `basicLength` is the number of basic code points.
9118
- // Finish the basic string - if it is not empty - with a delimiter
9119
- if (basicLength) {
9120
- output.push(delimiter);
9121
- }
9122
- // Main encoding loop:
9123
- while (handledCPCount < inputLength) {
9124
- // All non-basic code points < n have been handled already. Find the next
9125
- // larger one:
9126
- for (m = maxInt, j = 0; j < inputLength; ++j) {
9127
- currentValue = input[j];
9128
- if (currentValue >= n && currentValue < m) {
9129
- m = currentValue;
9130
- }
9131
- }
9132
- // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
9133
- // but guard against overflow
9134
- handledCPCountPlusOne = handledCPCount + 1;
9135
- if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
9136
- error('overflow');
9137
- }
9138
- delta += (m - n) * handledCPCountPlusOne;
9139
- n = m;
9140
- for (j = 0; j < inputLength; ++j) {
9141
- currentValue = input[j];
9142
- if (currentValue < n && ++delta > maxInt) {
9143
- error('overflow');
9144
- }
9145
- if (currentValue == n) {
9146
- // Represent delta as a generalized variable-length integer
9147
- for (q = delta, k = base;; k += base) {
9148
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
9149
- if (q < t) {
9150
- break;
9151
- }
9152
- qMinusT = q - t;
9153
- baseMinusT = base - t;
9154
- output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
9155
- q = floor(qMinusT / baseMinusT);
9156
- }
9157
- output.push(stringFromCharCode(digitToBasic(q, 0)));
9158
- bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
9159
- delta = 0;
9160
- ++handledCPCount;
9161
- }
9162
- }
9163
- ++delta;
9164
- ++n;
9165
- }
9166
- return output.join('');
9167
- }
9168
- /**
9169
- * Converts a Punycode string representing a domain name or an email address
9170
- * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
9171
- * it doesn't matter if you call it on a string that has already been
9172
- * converted to Unicode.
9173
- * @memberOf punycode
9174
- * @param {String} input The Punycoded domain name or email address to
9175
- * convert to Unicode.
9176
- * @returns {String} The Unicode representation of the given Punycode
9177
- * string.
9178
- */
9179
- function toUnicode(input) {
9180
- return mapDomain(input, function (string) {
9181
- return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
9182
- });
9183
- }
9184
- /**
9185
- * Converts a Unicode string representing a domain name or an email address to
9186
- * Punycode. Only the non-ASCII parts of the domain name will be converted,
9187
- * i.e. it doesn't matter if you call it with a domain that's already in
9188
- * ASCII.
9189
- * @memberOf punycode
9190
- * @param {String} input The domain name or email address to convert, as a
9191
- * Unicode string.
9192
- * @returns {String} The Punycode representation of the given domain name or
9193
- * email address.
9194
- */
9195
- function toASCII(input) {
9196
- return mapDomain(input, function (string) {
9197
- return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
9198
- });
9199
- }
9200
- /*--------------------------------------------------------------------------*/
9201
- /** Define the public API */
9202
- punycode = {
9203
- /**
9204
- * A string representing the current Punycode.js version number.
9205
- * @memberOf punycode
9206
- * @type String
9207
- */
9208
- 'version': '1.3.2',
9209
- /**
9210
- * An object of methods to convert from JavaScript's internal character
9211
- * representation (UCS-2) to Unicode code points, and back.
9212
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
9213
- * @memberOf punycode
9214
- * @type Object
9215
- */
9216
- 'ucs2': {
9217
- 'decode': ucs2decode,
9218
- 'encode': ucs2encode
9219
- },
9220
- 'decode': decode,
9221
- 'encode': encode,
9222
- 'toASCII': toASCII,
9223
- 'toUnicode': toUnicode
9224
- };
9225
- /** Expose `punycode` */
9226
- // Some AMD build optimizers, like r.js, check for specific condition patterns
9227
- // like the following:
9228
- if (freeExports && freeModule) {
9229
- if (module.exports == freeExports) {
9230
- // in Node.js or RingoJS v0.8.0+
9231
- freeModule.exports = punycode;
9232
- } else {
9233
- // in Narwhal or RingoJS v0.7.0-
9234
- for (key in punycode) {
9235
- punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
9236
- }
9237
- }
9238
- } else {
9239
- // in Rhino or a web browser
9240
- root.punycode = punycode;
9241
- }
9242
- }(commonjsGlobal));
9243
- } (punycode$1, punycode$1.exports));
9244
-
9245
- var punycodeExports = punycode$1.exports;
9246
-
9247
- var util$1 = {
9248
- isString: function (arg) {
9249
- return typeof arg === 'string';
9250
- },
9251
- isObject: function (arg) {
9252
- return typeof arg === 'object' && arg !== null;
9253
- },
9254
- isNull: function (arg) {
9255
- return arg === null;
9256
- },
9257
- isNullOrUndefined: function (arg) {
9258
- return arg == null;
9259
- }
9260
- };
9261
-
9262
- var querystring$1 = {};
9263
-
9264
- // If obj.hasOwnProperty has been overridden, then calling
9265
- // obj.hasOwnProperty(prop) will break.
9266
- // See: https://github.com/joyent/node/issues/1707
9267
- function hasOwnProperty(obj, prop) {
9268
- return Object.prototype.hasOwnProperty.call(obj, prop);
9269
- }
9270
- var decode = function (qs, sep, eq, options) {
9271
- sep = sep || '&';
9272
- eq = eq || '=';
9273
- var obj = {};
9274
- if (typeof qs !== 'string' || qs.length === 0) {
9275
- return obj;
9276
- }
9277
- var regexp = /\+/g;
9278
- qs = qs.split(sep);
9279
- var maxKeys = 1000;
9280
- if (options && typeof options.maxKeys === 'number') {
9281
- maxKeys = options.maxKeys;
9282
- }
9283
- var len = qs.length;
9284
- // maxKeys <= 0 means that we should not limit keys count
9285
- if (maxKeys > 0 && len > maxKeys) {
9286
- len = maxKeys;
9287
- }
9288
- for (var i = 0; i < len; ++i) {
9289
- var x = qs[i].replace(regexp, '%20'), idx = x.indexOf(eq), kstr, vstr, k, v;
9290
- if (idx >= 0) {
9291
- kstr = x.substr(0, idx);
9292
- vstr = x.substr(idx + 1);
9293
- } else {
9294
- kstr = x;
9295
- vstr = '';
9296
- }
9297
- k = decodeURIComponent(kstr);
9298
- v = decodeURIComponent(vstr);
9299
- if (!hasOwnProperty(obj, k)) {
9300
- obj[k] = v;
9301
- } else if (Array.isArray(obj[k])) {
9302
- obj[k].push(v);
9303
- } else {
9304
- obj[k] = [
9305
- obj[k],
9306
- v
9307
- ];
9308
- }
9309
- }
9310
- return obj;
9311
- };
9312
-
9313
- var stringifyPrimitive = function (v) {
9314
- switch (typeof v) {
9315
- case 'string':
9316
- return v;
9317
- case 'boolean':
9318
- return v ? 'true' : 'false';
9319
- case 'number':
9320
- return isFinite(v) ? v : '';
9321
- default:
9322
- return '';
9323
- }
9324
- };
9325
- var encode = function (obj, sep, eq, name) {
9326
- sep = sep || '&';
9327
- eq = eq || '=';
9328
- if (obj === null) {
9329
- obj = undefined;
9330
- }
9331
- if (typeof obj === 'object') {
9332
- return Object.keys(obj).map(function (k) {
9333
- var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
9334
- if (Array.isArray(obj[k])) {
9335
- return obj[k].map(function (v) {
9336
- return ks + encodeURIComponent(stringifyPrimitive(v));
9337
- }).join(sep);
9338
- } else {
9339
- return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
9340
- }
9341
- }).join(sep);
9342
- }
9343
- if (!name)
9344
- return '';
9345
- return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj));
9346
- };
9347
-
9348
- querystring$1.decode = querystring$1.parse = decode;
9349
- querystring$1.encode = querystring$1.stringify = encode;
9350
-
9351
- var punycode = punycodeExports;
9352
- var util = util$1;
9353
- url.parse = urlParse;
9354
- url.resolve = urlResolve;
9355
- url.resolveObject = urlResolveObject;
9356
- url.format = urlFormat;
9357
- url.Url = Url;
9358
- function Url() {
9359
- this.protocol = null;
9360
- this.slashes = null;
9361
- this.auth = null;
9362
- this.host = null;
9363
- this.port = null;
9364
- this.hostname = null;
9365
- this.hash = null;
9366
- this.search = null;
9367
- this.query = null;
9368
- this.pathname = null;
9369
- this.path = null;
9370
- this.href = null;
9371
- }
9372
- // Reference: RFC 3986, RFC 1808, RFC 2396
9373
- // define these here so at least they only have to be
9374
- // compiled once on the first module load.
9375
- var protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/,
9376
- // Special case for a simple path URL
9377
- simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
9378
- // RFC 2396: characters reserved for delimiting URLs.
9379
- // We actually just auto-escape these.
9380
- delims = [
9381
- '<',
9382
- '>',
9383
- '"',
9384
- '`',
9385
- ' ',
9386
- '\r',
9387
- '\n',
9388
- '\t'
9389
- ],
9390
- // RFC 2396: characters not allowed for various reasons.
9391
- unwise = [
9392
- '{',
9393
- '}',
9394
- '|',
9395
- '\\',
9396
- '^',
9397
- '`'
9398
- ].concat(delims),
9399
- // Allowed by RFCs, but cause of XSS attacks. Always escape these.
9400
- autoEscape = ['\''].concat(unwise),
9401
- // Characters that are never ever allowed in a hostname.
9402
- // Note that any invalid chars are also handled, but these
9403
- // are the ones that are *expected* to be seen, so we fast-path
9404
- // them.
9405
- nonHostChars = [
9406
- '%',
9407
- '/',
9408
- '?',
9409
- ';',
9410
- '#'
9411
- ].concat(autoEscape), hostEndingChars = [
9412
- '/',
9413
- '?',
9414
- '#'
9415
- ], hostnameMaxLen = 255, hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
9416
- // protocols that can allow "unsafe" and "unwise" chars.
9417
- unsafeProtocol = {
9418
- 'javascript': true,
9419
- 'javascript:': true
9420
- },
9421
- // protocols that never have a hostname.
9422
- hostlessProtocol = {
9423
- 'javascript': true,
9424
- 'javascript:': true
9425
- },
9426
- // protocols that always contain a // bit.
9427
- slashedProtocol = {
9428
- 'http': true,
9429
- 'https': true,
9430
- 'ftp': true,
9431
- 'gopher': true,
9432
- 'file': true,
9433
- 'http:': true,
9434
- 'https:': true,
9435
- 'ftp:': true,
9436
- 'gopher:': true,
9437
- 'file:': true
9438
- }, querystring = querystring$1;
9439
- function urlParse(url, parseQueryString, slashesDenoteHost) {
9440
- if (url && util.isObject(url) && url instanceof Url)
9441
- return url;
9442
- var u = new Url();
9443
- u.parse(url, parseQueryString, slashesDenoteHost);
9444
- return u;
9445
- }
9446
- Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
9447
- if (!util.isString(url)) {
9448
- throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
9449
- }
9450
- // Copy chrome, IE, opera backslash-handling behavior.
9451
- // Back slashes before the query string get converted to forward slashes
9452
- // See: https://code.google.com/p/chromium/issues/detail?id=25916
9453
- var queryIndex = url.indexOf('?'), splitter = queryIndex !== -1 && queryIndex < url.indexOf('#') ? '?' : '#', uSplit = url.split(splitter), slashRegex = /\\/g;
9454
- uSplit[0] = uSplit[0].replace(slashRegex, '/');
9455
- url = uSplit.join(splitter);
9456
- var rest = url;
9457
- // trim before proceeding.
9458
- // This is to support parse stuff like " http://foo.com \n"
9459
- rest = rest.trim();
9460
- if (!slashesDenoteHost && url.split('#').length === 1) {
9461
- // Try fast path regexp
9462
- var simplePath = simplePathPattern.exec(rest);
9463
- if (simplePath) {
9464
- this.path = rest;
9465
- this.href = rest;
9466
- this.pathname = simplePath[1];
9467
- if (simplePath[2]) {
9468
- this.search = simplePath[2];
9469
- if (parseQueryString) {
9470
- this.query = querystring.parse(this.search.substr(1));
9471
- } else {
9472
- this.query = this.search.substr(1);
9473
- }
9474
- } else if (parseQueryString) {
9475
- this.search = '';
9476
- this.query = {};
9477
- }
9478
- return this;
9479
- }
9480
- }
9481
- var proto = protocolPattern.exec(rest);
9482
- if (proto) {
9483
- proto = proto[0];
9484
- var lowerProto = proto.toLowerCase();
9485
- this.protocol = lowerProto;
9486
- rest = rest.substr(proto.length);
9487
- }
9488
- // figure out if it's got a host
9489
- // user@server is *always* interpreted as a hostname, and url
9490
- // resolution will treat //foo/bar as host=foo,path=bar because that's
9491
- // how the browser resolves relative URLs.
9492
- if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
9493
- var slashes = rest.substr(0, 2) === '//';
9494
- if (slashes && !(proto && hostlessProtocol[proto])) {
9495
- rest = rest.substr(2);
9496
- this.slashes = true;
9497
- }
9498
- }
9499
- if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
9500
- // there's a hostname.
9501
- // the first instance of /, ?, ;, or # ends the host.
9502
- //
9503
- // If there is an @ in the hostname, then non-host chars *are* allowed
9504
- // to the left of the last @ sign, unless some host-ending character
9505
- // comes *before* the @-sign.
9506
- // URLs are obnoxious.
9507
- //
9508
- // ex:
9509
- // http://a@b@c/ => user:a@b host:c
9510
- // http://a@b?@c => user:a host:c path:/?@c
9511
- // v0.12 TODO(isaacs): This is not quite how Chrome does things.
9512
- // Review our test case against browsers more comprehensively.
9513
- // find the first instance of any hostEndingChars
9514
- var hostEnd = -1;
9515
- for (var i = 0; i < hostEndingChars.length; i++) {
9516
- var hec = rest.indexOf(hostEndingChars[i]);
9517
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
9518
- hostEnd = hec;
9519
- }
9520
- // at this point, either we have an explicit point where the
9521
- // auth portion cannot go past, or the last @ char is the decider.
9522
- var auth, atSign;
9523
- if (hostEnd === -1) {
9524
- // atSign can be anywhere.
9525
- atSign = rest.lastIndexOf('@');
9526
- } else {
9527
- // atSign must be in auth portion.
9528
- // http://a@b/c@d => host:b auth:a path:/c@d
9529
- atSign = rest.lastIndexOf('@', hostEnd);
9530
- }
9531
- // Now we have a portion which is definitely the auth.
9532
- // Pull that off.
9533
- if (atSign !== -1) {
9534
- auth = rest.slice(0, atSign);
9535
- rest = rest.slice(atSign + 1);
9536
- this.auth = decodeURIComponent(auth);
9537
- }
9538
- // the host is the remaining to the left of the first non-host char
9539
- hostEnd = -1;
9540
- for (var i = 0; i < nonHostChars.length; i++) {
9541
- var hec = rest.indexOf(nonHostChars[i]);
9542
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
9543
- hostEnd = hec;
9544
- }
9545
- // if we still have not hit it, then the entire thing is a host.
9546
- if (hostEnd === -1)
9547
- hostEnd = rest.length;
9548
- this.host = rest.slice(0, hostEnd);
9549
- rest = rest.slice(hostEnd);
9550
- // pull out port.
9551
- this.parseHost();
9552
- // we've indicated that there is a hostname,
9553
- // so even if it's empty, it has to be present.
9554
- this.hostname = this.hostname || '';
9555
- // if hostname begins with [ and ends with ]
9556
- // assume that it's an IPv6 address.
9557
- var ipv6Hostname = this.hostname[0] === '[' && this.hostname[this.hostname.length - 1] === ']';
9558
- // validate a little.
9559
- if (!ipv6Hostname) {
9560
- var hostparts = this.hostname.split(/\./);
9561
- for (var i = 0, l = hostparts.length; i < l; i++) {
9562
- var part = hostparts[i];
9563
- if (!part)
9564
- continue;
9565
- if (!part.match(hostnamePartPattern)) {
9566
- var newpart = '';
9567
- for (var j = 0, k = part.length; j < k; j++) {
9568
- if (part.charCodeAt(j) > 127) {
9569
- // we replace non-ASCII char with a temporary placeholder
9570
- // we need this to make sure size of hostname is not
9571
- // broken by replacing non-ASCII by nothing
9572
- newpart += 'x';
9573
- } else {
9574
- newpart += part[j];
9575
- }
9576
- }
9577
- // we test again with ASCII char only
9578
- if (!newpart.match(hostnamePartPattern)) {
9579
- var validParts = hostparts.slice(0, i);
9580
- var notHost = hostparts.slice(i + 1);
9581
- var bit = part.match(hostnamePartStart);
9582
- if (bit) {
9583
- validParts.push(bit[1]);
9584
- notHost.unshift(bit[2]);
9585
- }
9586
- if (notHost.length) {
9587
- rest = '/' + notHost.join('.') + rest;
9588
- }
9589
- this.hostname = validParts.join('.');
9590
- break;
9591
- }
9592
- }
9593
- }
9594
- }
9595
- if (this.hostname.length > hostnameMaxLen) {
9596
- this.hostname = '';
9597
- } else {
9598
- // hostnames are always lower case.
9599
- this.hostname = this.hostname.toLowerCase();
9600
- }
9601
- if (!ipv6Hostname) {
9602
- // IDNA Support: Returns a punycoded representation of "domain".
9603
- // It only converts parts of the domain name that
9604
- // have non-ASCII characters, i.e. it doesn't matter if
9605
- // you call it with a domain that already is ASCII-only.
9606
- this.hostname = punycode.toASCII(this.hostname);
9607
- }
9608
- var p = this.port ? ':' + this.port : '';
9609
- var h = this.hostname || '';
9610
- this.host = h + p;
9611
- this.href += this.host;
9612
- // strip [ and ] from the hostname
9613
- // the host field still retains them, though
9614
- if (ipv6Hostname) {
9615
- this.hostname = this.hostname.substr(1, this.hostname.length - 2);
9616
- if (rest[0] !== '/') {
9617
- rest = '/' + rest;
9618
- }
9619
- }
9620
- }
9621
- // now rest is set to the post-host stuff.
9622
- // chop off any delim chars.
9623
- if (!unsafeProtocol[lowerProto]) {
9624
- // First, make 100% sure that any "autoEscape" chars get
9625
- // escaped, even if encodeURIComponent doesn't think they
9626
- // need to be.
9627
- for (var i = 0, l = autoEscape.length; i < l; i++) {
9628
- var ae = autoEscape[i];
9629
- if (rest.indexOf(ae) === -1)
9630
- continue;
9631
- var esc = encodeURIComponent(ae);
9632
- if (esc === ae) {
9633
- esc = escape(ae);
9634
- }
9635
- rest = rest.split(ae).join(esc);
9636
- }
9637
- }
9638
- // chop off from the tail first.
9639
- var hash = rest.indexOf('#');
9640
- if (hash !== -1) {
9641
- // got a fragment string.
9642
- this.hash = rest.substr(hash);
9643
- rest = rest.slice(0, hash);
9644
- }
9645
- var qm = rest.indexOf('?');
9646
- if (qm !== -1) {
9647
- this.search = rest.substr(qm);
9648
- this.query = rest.substr(qm + 1);
9649
- if (parseQueryString) {
9650
- this.query = querystring.parse(this.query);
9651
- }
9652
- rest = rest.slice(0, qm);
9653
- } else if (parseQueryString) {
9654
- // no query string, but parseQueryString still requested
9655
- this.search = '';
9656
- this.query = {};
9657
- }
9658
- if (rest)
9659
- this.pathname = rest;
9660
- if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
9661
- this.pathname = '/';
9662
- }
9663
- //to support http.request
9664
- if (this.pathname || this.search) {
9665
- var p = this.pathname || '';
9666
- var s = this.search || '';
9667
- this.path = p + s;
9668
- }
9669
- // finally, reconstruct the href based on what has been validated.
9670
- this.href = this.format();
9671
- return this;
9672
- };
9673
- // format a parsed object into a url string
9674
- function urlFormat(obj) {
9675
- // ensure it's an object, and not a string url.
9676
- // If it's an obj, this is a no-op.
9677
- // this way, you can call url_format() on strings
9678
- // to clean up potentially wonky urls.
9679
- if (util.isString(obj))
9680
- obj = urlParse(obj);
9681
- if (!(obj instanceof Url))
9682
- return Url.prototype.format.call(obj);
9683
- return obj.format();
9684
- }
9685
- Url.prototype.format = function () {
9686
- var auth = this.auth || '';
9687
- if (auth) {
9688
- auth = encodeURIComponent(auth);
9689
- auth = auth.replace(/%3A/i, ':');
9690
- auth += '@';
9691
- }
9692
- var protocol = this.protocol || '', pathname = this.pathname || '', hash = this.hash || '', host = false, query = '';
9693
- if (this.host) {
9694
- host = auth + this.host;
9695
- } else if (this.hostname) {
9696
- host = auth + (this.hostname.indexOf(':') === -1 ? this.hostname : '[' + this.hostname + ']');
9697
- if (this.port) {
9698
- host += ':' + this.port;
9699
- }
9700
- }
9701
- if (this.query && util.isObject(this.query) && Object.keys(this.query).length) {
9702
- query = querystring.stringify(this.query);
9703
- }
9704
- var search = this.search || query && '?' + query || '';
9705
- if (protocol && protocol.substr(-1) !== ':')
9706
- protocol += ':';
9707
- // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
9708
- // unless they had them to begin with.
9709
- if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
9710
- host = '//' + (host || '');
9711
- if (pathname && pathname.charAt(0) !== '/')
9712
- pathname = '/' + pathname;
9713
- } else if (!host) {
9714
- host = '';
9715
- }
9716
- if (hash && hash.charAt(0) !== '#')
9717
- hash = '#' + hash;
9718
- if (search && search.charAt(0) !== '?')
9719
- search = '?' + search;
9720
- pathname = pathname.replace(/[?#]/g, function (match) {
9721
- return encodeURIComponent(match);
9722
- });
9723
- search = search.replace('#', '%23');
9724
- return protocol + host + pathname + search + hash;
9725
- };
9726
- function urlResolve(source, relative) {
9727
- return urlParse(source, false, true).resolve(relative);
9728
- }
9729
- Url.prototype.resolve = function (relative) {
9730
- return this.resolveObject(urlParse(relative, false, true)).format();
9731
- };
9732
- function urlResolveObject(source, relative) {
9733
- if (!source)
9734
- return relative;
9735
- return urlParse(source, false, true).resolveObject(relative);
9736
- }
9737
- Url.prototype.resolveObject = function (relative) {
9738
- if (util.isString(relative)) {
9739
- var rel = new Url();
9740
- rel.parse(relative, false, true);
9741
- relative = rel;
9742
- }
9743
- var result = new Url();
9744
- var tkeys = Object.keys(this);
9745
- for (var tk = 0; tk < tkeys.length; tk++) {
9746
- var tkey = tkeys[tk];
9747
- result[tkey] = this[tkey];
9748
- }
9749
- // hash is always overridden, no matter what.
9750
- // even href="" will remove it.
9751
- result.hash = relative.hash;
9752
- // if the relative url is empty, then there's nothing left to do here.
9753
- if (relative.href === '') {
9754
- result.href = result.format();
9755
- return result;
9756
- }
9757
- // hrefs like //foo/bar always cut to the protocol.
9758
- if (relative.slashes && !relative.protocol) {
9759
- // take everything except the protocol from relative
9760
- var rkeys = Object.keys(relative);
9761
- for (var rk = 0; rk < rkeys.length; rk++) {
9762
- var rkey = rkeys[rk];
9763
- if (rkey !== 'protocol')
9764
- result[rkey] = relative[rkey];
9765
- }
9766
- //urlParse appends trailing / to urls like http://www.example.com
9767
- if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
9768
- result.path = result.pathname = '/';
9769
- }
9770
- result.href = result.format();
9771
- return result;
9772
- }
9773
- if (relative.protocol && relative.protocol !== result.protocol) {
9774
- // if it's a known url protocol, then changing
9775
- // the protocol does weird things
9776
- // first, if it's not file:, then we MUST have a host,
9777
- // and if there was a path
9778
- // to begin with, then we MUST have a path.
9779
- // if it is file:, then the host is dropped,
9780
- // because that's known to be hostless.
9781
- // anything else is assumed to be absolute.
9782
- if (!slashedProtocol[relative.protocol]) {
9783
- var keys = Object.keys(relative);
9784
- for (var v = 0; v < keys.length; v++) {
9785
- var k = keys[v];
9786
- result[k] = relative[k];
9787
- }
9788
- result.href = result.format();
9789
- return result;
9790
- }
9791
- result.protocol = relative.protocol;
9792
- if (!relative.host && !hostlessProtocol[relative.protocol]) {
9793
- var relPath = (relative.pathname || '').split('/');
9794
- while (relPath.length && !(relative.host = relPath.shift()));
9795
- if (!relative.host)
9796
- relative.host = '';
9797
- if (!relative.hostname)
9798
- relative.hostname = '';
9799
- if (relPath[0] !== '')
9800
- relPath.unshift('');
9801
- if (relPath.length < 2)
9802
- relPath.unshift('');
9803
- result.pathname = relPath.join('/');
9804
- } else {
9805
- result.pathname = relative.pathname;
9806
- }
9807
- result.search = relative.search;
9808
- result.query = relative.query;
9809
- result.host = relative.host || '';
9810
- result.auth = relative.auth;
9811
- result.hostname = relative.hostname || relative.host;
9812
- result.port = relative.port;
9813
- // to support http.request
9814
- if (result.pathname || result.search) {
9815
- var p = result.pathname || '';
9816
- var s = result.search || '';
9817
- result.path = p + s;
9818
- }
9819
- result.slashes = result.slashes || relative.slashes;
9820
- result.href = result.format();
9821
- return result;
9822
- }
9823
- var isSourceAbs = result.pathname && result.pathname.charAt(0) === '/', isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === '/', mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname, removeAllDots = mustEndAbs, srcPath = result.pathname && result.pathname.split('/') || [], relPath = relative.pathname && relative.pathname.split('/') || [], psychotic = result.protocol && !slashedProtocol[result.protocol];
9824
- // if the url is a non-slashed url, then relative
9825
- // links like ../.. should be able
9826
- // to crawl up to the hostname, as well. This is strange.
9827
- // result.protocol has already been set by now.
9828
- // Later on, put the first path part into the host field.
9829
- if (psychotic) {
9830
- result.hostname = '';
9831
- result.port = null;
9832
- if (result.host) {
9833
- if (srcPath[0] === '')
9834
- srcPath[0] = result.host;
9835
- else
9836
- srcPath.unshift(result.host);
9837
- }
9838
- result.host = '';
9839
- if (relative.protocol) {
9840
- relative.hostname = null;
9841
- relative.port = null;
9842
- if (relative.host) {
9843
- if (relPath[0] === '')
9844
- relPath[0] = relative.host;
9845
- else
9846
- relPath.unshift(relative.host);
9847
- }
9848
- relative.host = null;
9849
- }
9850
- mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
9851
- }
9852
- if (isRelAbs) {
9853
- // it's absolute.
9854
- result.host = relative.host || relative.host === '' ? relative.host : result.host;
9855
- result.hostname = relative.hostname || relative.hostname === '' ? relative.hostname : result.hostname;
9856
- result.search = relative.search;
9857
- result.query = relative.query;
9858
- srcPath = relPath; // fall through to the dot-handling below.
9859
- } else if (relPath.length) {
9860
- // it's relative
9861
- // throw away the existing file, and take the new path instead.
9862
- if (!srcPath)
9863
- srcPath = [];
9864
- srcPath.pop();
9865
- srcPath = srcPath.concat(relPath);
9866
- result.search = relative.search;
9867
- result.query = relative.query;
9868
- } else if (!util.isNullOrUndefined(relative.search)) {
9869
- // just pull out the search.
9870
- // like href='?foo'.
9871
- // Put this after the other two cases because it simplifies the booleans
9872
- if (psychotic) {
9873
- result.hostname = result.host = srcPath.shift();
9874
- //occationaly the auth can get stuck only in host
9875
- //this especially happens in cases like
9876
- //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
9877
- var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
9878
- if (authInHost) {
9879
- result.auth = authInHost.shift();
9880
- result.host = result.hostname = authInHost.shift();
9881
- }
9882
- }
9883
- result.search = relative.search;
9884
- result.query = relative.query;
9885
- //to support http.request
9886
- if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
9887
- result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
9888
- }
9889
- result.href = result.format();
9890
- return result;
9891
- }
9892
- if (!srcPath.length) {
9893
- // no path at all. easy.
9894
- // we've already handled the other stuff above.
9895
- result.pathname = null;
9896
- //to support http.request
9897
- if (result.search) {
9898
- result.path = '/' + result.search;
9899
- } else {
9900
- result.path = null;
9901
- }
9902
- result.href = result.format();
9903
- return result;
9904
- }
9905
- // if a url ENDs in . or .., then it must get a trailing slash.
9906
- // however, if it ends in anything else non-slashy,
9907
- // then it must NOT get a trailing slash.
9908
- var last = srcPath.slice(-1)[0];
9909
- var hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..') || last === '';
9910
- // strip single dots, resolve double dots to parent dir
9911
- // if the path tries to go above the root, `up` ends up > 0
9912
- var up = 0;
9913
- for (var i = srcPath.length; i >= 0; i--) {
9914
- last = srcPath[i];
9915
- if (last === '.') {
9916
- srcPath.splice(i, 1);
9917
- } else if (last === '..') {
9918
- srcPath.splice(i, 1);
9919
- up++;
9920
- } else if (up) {
9921
- srcPath.splice(i, 1);
9922
- up--;
9923
- }
9924
- }
9925
- // if the path is allowed to go above the root, restore leading ..s
9926
- if (!mustEndAbs && !removeAllDots) {
9927
- for (; up--; up) {
9928
- srcPath.unshift('..');
9929
- }
9930
- }
9931
- if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
9932
- srcPath.unshift('');
9933
- }
9934
- if (hasTrailingSlash && srcPath.join('/').substr(-1) !== '/') {
9935
- srcPath.push('');
9936
- }
9937
- var isAbsolute = srcPath[0] === '' || srcPath[0] && srcPath[0].charAt(0) === '/';
9938
- // put the host back
9939
- if (psychotic) {
9940
- result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : '';
9941
- //occationaly the auth can get stuck only in host
9942
- //this especially happens in cases like
9943
- //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
9944
- var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
9945
- if (authInHost) {
9946
- result.auth = authInHost.shift();
9947
- result.host = result.hostname = authInHost.shift();
9948
- }
9949
- }
9950
- mustEndAbs = mustEndAbs || result.host && srcPath.length;
9951
- if (mustEndAbs && !isAbsolute) {
9952
- srcPath.unshift('');
9953
- }
9954
- if (!srcPath.length) {
9955
- result.pathname = null;
9956
- result.path = null;
9957
- } else {
9958
- result.pathname = srcPath.join('/');
9959
- }
9960
- //to support request.http
9961
- if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
9962
- result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
9963
- }
9964
- result.auth = relative.auth || result.auth;
9965
- result.slashes = result.slashes || relative.slashes;
9966
- result.href = result.format();
9967
- return result;
9968
- };
9969
- Url.prototype.parseHost = function () {
9970
- var host = this.host;
9971
- var port = portPattern.exec(host);
9972
- if (port) {
9973
- port = port[0];
9974
- if (port !== ':') {
9975
- this.port = port.substr(1);
9976
- }
9977
- host = host.substr(0, host.length - port.length);
9978
- }
9979
- if (host)
9980
- this.hostname = host;
9981
- };
9982
-
9983
8784
  //
9984
8785
  function getPropertyReference(propertyName) {
9985
8786
  for (let i = 0; i < v8.layout.length; i++) {
@@ -10039,6 +8840,7 @@ function eachProperty(style, options, callback) {
10039
8840
  });
10040
8841
  }
10041
8842
 
8843
+ //
10042
8844
  function eachLayout(layer, callback) {
10043
8845
  for (const k in layer) {
10044
8846
  if (k.indexOf('layout') === 0) {
@@ -10136,7 +8938,7 @@ function migrateToV8 (style) {
10136
8938
  });
10137
8939
  });
10138
8940
  function migrateFontstackURL(input) {
10139
- const inputParsed = url.parse(input);
8941
+ const inputParsed = new URL(input);
10140
8942
  const inputPathnameParts = inputParsed.pathname.split('/');
10141
8943
  if (inputParsed.protocol !== 'mapbox:') {
10142
8944
  return input;
@@ -10345,6 +9147,10 @@ function isValidNativeType(provided, allowedTypes) {
10345
9147
  });
10346
9148
  }
10347
9149
 
9150
+ function getDefaultExportFromCjs (x) {
9151
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
9152
+ }
9153
+
10348
9154
  var csscolorparser = {};
10349
9155
 
10350
9156
  var parseCSSColor_1;
@@ -11543,8 +10349,6 @@ Color.blue = new Color(0, 0, 1, 1);
11543
10349
  var Color$1 = Color;
11544
10350
 
11545
10351
  //
11546
- // Flow type declarations for Intl cribbed from
11547
- // https://github.com/facebook/flow/issues/1270
11548
10352
  class Collator {
11549
10353
  constructor(caseSensitive, diacriticSensitive, locale) {
11550
10354
  if (caseSensitive)
@@ -12309,7 +11113,7 @@ const geometryTypes = [
12309
11113
  'Polygon'
12310
11114
  ];
12311
11115
  class EvaluationContext {
12312
- constructor(options) {
11116
+ constructor(scope, options) {
12313
11117
  this.globals = null;
12314
11118
  this.feature = null;
12315
11119
  this.featureState = null;
@@ -12319,6 +11123,7 @@ class EvaluationContext {
12319
11123
  this.canonical = null;
12320
11124
  this.featureTileCoord = null;
12321
11125
  this.featureDistanceData = null;
11126
+ this.scope = scope;
12322
11127
  this.options = options;
12323
11128
  }
12324
11129
  id() {
@@ -12418,7 +11223,7 @@ class CompoundExpression {
12418
11223
  overloadIndex++;
12419
11224
  // Use a fresh context for each attempted signature so that, if
12420
11225
  // we eventually succeed, we haven't polluted `context.errors`.
12421
- signatureContext = new ParsingContext$1(context.registry, context.path, null, context.scope, undefined, context.options);
11226
+ signatureContext = new ParsingContext$1(context.registry, context.path, null, context.scope, undefined, context._scope, context.options);
12422
11227
  // First parse all the args, potentially coercing to the
12423
11228
  // types expected by this overload.
12424
11229
  const parsedArgs = [];
@@ -14547,13 +13352,14 @@ class ParsingContext {
14547
13352
  // implementations to infer argument types: Expression#parse() need not
14548
13353
  // check that the output type of the parsed expression matches
14549
13354
  // `expectedType`.
14550
- constructor(registry, path = [], expectedType, scope = new Scope$1(), errors = [], options) {
13355
+ constructor(registry, path = [], expectedType, scope = new Scope$1(), errors = [], _scope, options) {
14551
13356
  this.registry = registry;
14552
13357
  this.path = path;
14553
13358
  this.key = path.map(part => `[${ part }]`).join('');
14554
13359
  this.scope = scope;
14555
13360
  this.errors = errors;
14556
13361
  this.expectedType = expectedType;
13362
+ this._scope = _scope;
14557
13363
  this.options = options;
14558
13364
  }
14559
13365
  /**
@@ -14618,7 +13424,7 @@ class ParsingContext {
14618
13424
  // parsed/compiled result. Expressions that expect an image should
14619
13425
  // not be resolved here so we can later get the available images.
14620
13426
  if (!(parsed instanceof Literal$1) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
14621
- const ec = new EvaluationContext$1(this.options);
13427
+ const ec = new EvaluationContext$1(this._scope, this.options);
14622
13428
  try {
14623
13429
  parsed = new Literal$1(parsed.type, parsed.evaluate(ec));
14624
13430
  } catch (e) {
@@ -14652,7 +13458,7 @@ class ParsingContext {
14652
13458
  concat(index, expectedType, bindings) {
14653
13459
  const path = typeof index === 'number' ? this.path.concat(index) : this.path;
14654
13460
  const scope = bindings ? this.scope.concat(bindings) : this.scope;
14655
- return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this.options);
13461
+ return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options);
14656
13462
  }
14657
13463
  /**
14658
13464
  * Push a parsing (or type checking) error into the `this.errors`
@@ -16264,16 +15070,28 @@ function clampToAllowedNumber(value, min, max, step) {
16264
15070
  }
16265
15071
  return value;
16266
15072
  }
15073
+ const FQIDSeparator = '\x1F';
16267
15074
  function getConfig(ctx, key, scope) {
16268
- if (scope.length) {
16269
- key += `\u{1f}${ scope }`;
16270
- }
15075
+ // Create a fully qualified key from the requested scope
15076
+ // and the scope from the current evaluation context
15077
+ key = [
15078
+ key,
15079
+ scope,
15080
+ ctx.scope
15081
+ ].filter(Boolean).join(FQIDSeparator);
16271
15082
  const config = ctx.getConfig(key);
16272
15083
  if (!config)
16273
15084
  return null;
16274
15085
  const {type, value, values, minValue, maxValue, stepValue} = config;
16275
15086
  const defaultValue = config.default.evaluate(ctx);
16276
- let result = value ? value.evaluate(ctx) : defaultValue;
15087
+ let result = defaultValue;
15088
+ if (value) {
15089
+ // temporarily override scope to parent to evaluate config expressions passed from the parent
15090
+ const originalScope = ctx.scope;
15091
+ ctx.scope = (originalScope || '').split(FQIDSeparator).slice(1).join(FQIDSeparator);
15092
+ result = value.evaluate(ctx);
15093
+ ctx.scope = originalScope;
15094
+ }
16277
15095
  if (type)
16278
15096
  result = coerceValue(type, result);
16279
15097
  if (value !== undefined && result !== undefined && values && !values.includes(result)) {
@@ -16412,7 +15230,7 @@ CompoundExpression$1.register(expressions, {
16412
15230
  overloads: [
16413
15231
  [
16414
15232
  [StringType],
16415
- (ctx, [key]) => getConfig(ctx, key.evaluate(ctx), '')
15233
+ (ctx, [key]) => getConfig(ctx, key.evaluate(ctx))
16416
15234
  ],
16417
15235
  [
16418
15236
  [
@@ -16939,6 +15757,7 @@ function supportsInterpolation(spec) {
16939
15757
  return !!spec.expression && spec.expression.interpolated;
16940
15758
  }
16941
15759
 
15760
+ //
16942
15761
  function isFunction(value) {
16943
15762
  return typeof value === 'object' && value !== null && !Array.isArray(value);
16944
15763
  }
@@ -17186,10 +16005,10 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
17186
16005
  }
17187
16006
 
17188
16007
  class StyleExpression {
17189
- constructor(expression, propertySpec, options) {
16008
+ constructor(expression, propertySpec, scope, options) {
17190
16009
  this.expression = expression;
17191
16010
  this._warningHistory = {};
17192
- this._evaluator = new EvaluationContext$1(options);
16011
+ this._evaluator = new EvaluationContext$1(scope, options);
17193
16012
  this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
17194
16013
  this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
17195
16014
  }
@@ -17246,14 +16065,14 @@ function isExpression(expression) {
17246
16065
  *
17247
16066
  * @private
17248
16067
  */
17249
- function createExpression(expression, propertySpec, options) {
17250
- const parser = new ParsingContext$1(definitions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, options);
16068
+ function createExpression(expression, propertySpec, scope, options) {
16069
+ const parser = new ParsingContext$1(definitions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, scope, options);
17251
16070
  // For string-valued properties, coerce to string at the top level rather than asserting.
17252
16071
  const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);
17253
16072
  if (!parsed) {
17254
16073
  return error(parser.errors);
17255
16074
  }
17256
- return success(new StyleExpression(parsed, propertySpec, options));
16075
+ return success(new StyleExpression(parsed, propertySpec, scope, options));
17257
16076
  }
17258
16077
  class ZoomConstantExpression {
17259
16078
  constructor(kind, expression, isLightConstant) {
@@ -17294,8 +16113,8 @@ class ZoomDependentExpression {
17294
16113
  }
17295
16114
  }
17296
16115
  }
17297
- function createPropertyExpression(expression, propertySpec, options) {
17298
- expression = createExpression(expression, propertySpec, options);
16116
+ function createPropertyExpression(expression, propertySpec, scope, options) {
16117
+ expression = createExpression(expression, propertySpec, scope, options);
17299
16118
  if (expression.result === 'error') {
17300
16119
  return expression;
17301
16120
  }
@@ -17349,11 +16168,11 @@ class StylePropertyFunction {
17349
16168
  };
17350
16169
  }
17351
16170
  }
17352
- function normalizePropertyExpression(value, specification, options) {
16171
+ function normalizePropertyExpression(value, specification, scope, options) {
17353
16172
  if (isFunction(value)) {
17354
16173
  return new StylePropertyFunction(value, specification);
17355
16174
  } else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
17356
- const expression = createPropertyExpression(value, specification, options);
16175
+ const expression = createPropertyExpression(value, specification, scope, options);
17357
16176
  if (expression.result === 'error') {
17358
16177
  // this should have been caught in validation
17359
16178
  throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
@@ -18370,6 +17189,7 @@ function migrateToExpressions (style) {
18370
17189
  return style;
18371
17190
  }
18372
17191
 
17192
+ //
18373
17193
  /**
18374
17194
  * Migrate a Mapbox GL Style to the latest version.
18375
17195
  *
@@ -18399,6 +17219,7 @@ function migrate (style) {
18399
17219
  return style;
18400
17220
  }
18401
17221
 
17222
+ //
18402
17223
  function composite (style) {
18403
17224
  const styleIDs = [];
18404
17225
  const sourceIDs = [];
@@ -19957,7 +18778,7 @@ function validateSource(options) {
19957
18778
  'raster-dem'
19958
18779
  ].includes(type)) {
19959
18780
  if (!value.url && !value.tiles) {
19960
- errors.push(new ValidationError(key, value, 'Either "url" or "tiles" is required.'));
18781
+ errors.push(new ValidationWarning(key, value, 'Either "url" or "tiles" is required.'));
19961
18782
  }
19962
18783
  }
19963
18784
  switch (type) {
@@ -21524,6 +20345,7 @@ var jsonlint$1 = {};
21524
20345
 
21525
20346
  var jsonlint = /*@__PURE__*/getDefaultExportFromCjs(jsonlint$1);
21526
20347
 
20348
+ //
21527
20349
  function readStyle(style) {
21528
20350
  if (style instanceof String || typeof style === 'string' || style instanceof Buffer) {
21529
20351
  try {