@basemaps/lambda-tiler 7.14.0 → 7.16.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.js CHANGED
@@ -77377,9 +77377,16 @@ credentials.onFileSystemFound = (acc, fs4, path2) => {
77377
77377
  applyS3MiddleWare(fs4);
77378
77378
  fsa.register(acc.prefix, fs4);
77379
77379
  };
77380
+ function splitConfig(x) {
77381
+ if (x.startsWith("["))
77382
+ return JSON.parse(x);
77383
+ return x.split(",");
77384
+ }
77380
77385
  var credentialPath = Env.get(Env.AwsRoleConfigPath);
77381
- if (credentialPath)
77382
- credentials.registerConfig(fsa.toUrl(credentialPath), s3Fs);
77386
+ if (credentialPath) {
77387
+ for (const loc of splitConfig(credentialPath))
77388
+ credentials.registerConfig(fsa.toUrl(loc), s3Fs);
77389
+ }
77383
77390
  s3Fs.credentials = credentials;
77384
77391
  fsa.register("https://", new FsHttp());
77385
77392
  fsa.register("s3://", s3Fs);
@@ -78417,16 +78424,11 @@ var CHAR_2 = "2".charCodeAt(0);
78417
78424
  var CHAR_3 = "3".charCodeAt(0);
78418
78425
 
78419
78426
  // ../geo/build/xy.order.js
78420
- var XyOrder;
78421
- (function(XyOrder2) {
78422
- XyOrder2[XyOrder2["Xy"] = 0] = "Xy";
78423
- XyOrder2[XyOrder2["Yx"] = 1] = "Yx";
78424
- })(XyOrder || (XyOrder = {}));
78425
78427
  function getXyOrder(epsg) {
78426
- if (epsg === Epsg.Nztm2000) {
78427
- return XyOrder.Yx;
78428
- }
78429
- return XyOrder.Xy;
78428
+ const code = typeof epsg === "number" ? epsg : epsg.code;
78429
+ if (code === EpsgCode.Nztm2000 || code === EpsgCode.Citm2000)
78430
+ return "yx";
78431
+ return "xy";
78430
78432
  }
78431
78433
 
78432
78434
  // ../geo/build/tile.matrix.set.js
@@ -78506,7 +78508,7 @@ var TileMatrixSet = class {
78506
78508
  if (projection == null)
78507
78509
  throw new Error(`Unable to find supported projection ${def.supportedCRS}`);
78508
78510
  this.projection = projection;
78509
- if (getXyOrder(this.projection) === XyOrder.Yx) {
78511
+ if (getXyOrder(this.projection) === "yx") {
78510
78512
  this.indexX = 1;
78511
78513
  this.indexY = 0;
78512
78514
  }
@@ -78706,6 +78708,204 @@ var TileMatrixSet = class {
78706
78708
  }
78707
78709
  };
78708
78710
 
78711
+ // ../geo/build/tms/citm2000.js
78712
+ var Citm2000Tmst = {
78713
+ type: "TileMatrixSetType",
78714
+ title: "Debug tile matrix for EPSG:3793",
78715
+ abstract: "",
78716
+ identifier: "CITM2000Quad",
78717
+ supportedCRS: "https://www.opengis.net/def/crs/EPSG/0/3793",
78718
+ boundingBox: {
78719
+ type: "BoundingBoxType",
78720
+ crs: "https://www.opengis.net/def/crs/EPSG/0/3793",
78721
+ lowerCorner: [5051234111622438e-9, 3.4301543757978342e6],
78722
+ upperCorner: [5207777145550478e-9, 3.5866974097258747e6]
78723
+ },
78724
+ tileMatrix: [
78725
+ {
78726
+ type: "TileMatrixType",
78727
+ identifier: "0",
78728
+ scaleDenominator: 218391509386217e-8,
78729
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78730
+ tileWidth: 256,
78731
+ tileHeight: 256,
78732
+ matrixWidth: 1,
78733
+ matrixHeight: 1
78734
+ },
78735
+ {
78736
+ type: "TileMatrixType",
78737
+ identifier: "1",
78738
+ scaleDenominator: 109195754693108e-8,
78739
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78740
+ tileWidth: 256,
78741
+ tileHeight: 256,
78742
+ matrixWidth: 2,
78743
+ matrixHeight: 2
78744
+ },
78745
+ {
78746
+ type: "TileMatrixType",
78747
+ identifier: "2",
78748
+ scaleDenominator: 545978.773465544,
78749
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78750
+ tileWidth: 256,
78751
+ tileHeight: 256,
78752
+ matrixWidth: 4,
78753
+ matrixHeight: 4
78754
+ },
78755
+ {
78756
+ type: "TileMatrixType",
78757
+ identifier: "3",
78758
+ scaleDenominator: 272989.386732772,
78759
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78760
+ tileWidth: 256,
78761
+ tileHeight: 256,
78762
+ matrixWidth: 8,
78763
+ matrixHeight: 8
78764
+ },
78765
+ {
78766
+ type: "TileMatrixType",
78767
+ identifier: "4",
78768
+ scaleDenominator: 136494.693366386,
78769
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78770
+ tileWidth: 256,
78771
+ tileHeight: 256,
78772
+ matrixWidth: 16,
78773
+ matrixHeight: 16
78774
+ },
78775
+ {
78776
+ type: "TileMatrixType",
78777
+ identifier: "5",
78778
+ scaleDenominator: 68247.346683193,
78779
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78780
+ tileWidth: 256,
78781
+ tileHeight: 256,
78782
+ matrixWidth: 32,
78783
+ matrixHeight: 32
78784
+ },
78785
+ {
78786
+ type: "TileMatrixType",
78787
+ identifier: "6",
78788
+ scaleDenominator: 34123.6733415964,
78789
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78790
+ tileWidth: 256,
78791
+ tileHeight: 256,
78792
+ matrixWidth: 64,
78793
+ matrixHeight: 64
78794
+ },
78795
+ {
78796
+ type: "TileMatrixType",
78797
+ identifier: "7",
78798
+ scaleDenominator: 17061.8366707982,
78799
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78800
+ tileWidth: 256,
78801
+ tileHeight: 256,
78802
+ matrixWidth: 128,
78803
+ matrixHeight: 128
78804
+ },
78805
+ {
78806
+ type: "TileMatrixType",
78807
+ identifier: "8",
78808
+ scaleDenominator: 8530.91833539913,
78809
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78810
+ tileWidth: 256,
78811
+ tileHeight: 256,
78812
+ matrixWidth: 256,
78813
+ matrixHeight: 256
78814
+ },
78815
+ {
78816
+ type: "TileMatrixType",
78817
+ identifier: "9",
78818
+ scaleDenominator: 4265.45916769956,
78819
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78820
+ tileWidth: 256,
78821
+ tileHeight: 256,
78822
+ matrixWidth: 512,
78823
+ matrixHeight: 512
78824
+ },
78825
+ {
78826
+ type: "TileMatrixType",
78827
+ identifier: "10",
78828
+ scaleDenominator: 2132.72958384978,
78829
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78830
+ tileWidth: 256,
78831
+ tileHeight: 256,
78832
+ matrixWidth: 1024,
78833
+ matrixHeight: 1024
78834
+ },
78835
+ {
78836
+ type: "TileMatrixType",
78837
+ identifier: "11",
78838
+ scaleDenominator: 1066.36479192489,
78839
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78840
+ tileWidth: 256,
78841
+ tileHeight: 256,
78842
+ matrixWidth: 2048,
78843
+ matrixHeight: 2048
78844
+ },
78845
+ {
78846
+ type: "TileMatrixType",
78847
+ identifier: "12",
78848
+ scaleDenominator: 533.182395962445,
78849
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78850
+ tileWidth: 256,
78851
+ tileHeight: 256,
78852
+ matrixWidth: 4096,
78853
+ matrixHeight: 4096
78854
+ },
78855
+ {
78856
+ type: "TileMatrixType",
78857
+ identifier: "13",
78858
+ scaleDenominator: 266.591197981222,
78859
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78860
+ tileWidth: 256,
78861
+ tileHeight: 256,
78862
+ matrixWidth: 8192,
78863
+ matrixHeight: 8192
78864
+ },
78865
+ {
78866
+ type: "TileMatrixType",
78867
+ identifier: "14",
78868
+ scaleDenominator: 133.295598990611,
78869
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78870
+ tileWidth: 256,
78871
+ tileHeight: 256,
78872
+ matrixWidth: 16384,
78873
+ matrixHeight: 16384
78874
+ },
78875
+ {
78876
+ type: "TileMatrixType",
78877
+ identifier: "15",
78878
+ scaleDenominator: 66.6477994953056,
78879
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78880
+ tileWidth: 256,
78881
+ tileHeight: 256,
78882
+ matrixWidth: 32768,
78883
+ matrixHeight: 32768
78884
+ },
78885
+ {
78886
+ type: "TileMatrixType",
78887
+ identifier: "16",
78888
+ scaleDenominator: 33.3238997476528,
78889
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
78890
+ tileWidth: 256,
78891
+ tileHeight: 256,
78892
+ matrixWidth: 65536,
78893
+ matrixHeight: 65536
78894
+ }
78895
+ ],
78896
+ $generated: {
78897
+ package: "@basemaps/cli",
78898
+ version: "v7.14.0-4-g2766010d",
78899
+ hash: "2766010d8d2bb8b673f6bcbef2fe2636f2e0f4ea",
78900
+ createdAt: "2025-02-10T20:34:46.643Z"
78901
+ },
78902
+ $options: {
78903
+ sourceTileMatrix: "WebMercatorQuad",
78904
+ zoomOffset: 8
78905
+ }
78906
+ };
78907
+ var Citm2000Tms = new TileMatrixSet(Citm2000Tmst);
78908
+
78709
78909
  // ../geo/build/tms/google.js
78710
78910
  var GoogleTmst = {
78711
78911
  type: "TileMatrixSetType",
@@ -78982,11 +79182,12 @@ var Nztm2000QuadTms = new TileMatrixSet(Nztm20002.Nztm2000Quad);
78982
79182
  // ../geo/build/tms/index.js
78983
79183
  var TileMatrixSets = {
78984
79184
  /** All TileMatrixSets that are currently supported */
78985
- All: [GoogleTms, Nztm2000Tms, Nztm2000QuadTms],
79185
+ All: [GoogleTms, Nztm2000Tms, Nztm2000QuadTms, Citm2000Tms],
78986
79186
  /** Default mapping of EPSG code to Tile matrix set */
78987
79187
  Defaults: /* @__PURE__ */ new Map([
78988
79188
  [Epsg.Google.code, GoogleTms],
78989
- [Epsg.Nztm2000.code, Nztm2000Tms]
79189
+ [Epsg.Nztm2000.code, Nztm2000Tms],
79190
+ [Epsg.Citm2000.code, Citm2000Tms]
78990
79191
  ]),
78991
79192
  /**
78992
79193
  * Get a tile matrix set by EPSG Code
@@ -82268,9 +82469,9 @@ var Router = class {
82268
82469
  };
82269
82470
 
82270
82471
  // ../../node_modules/@linzjs/lambda/build/src/function.js
82271
- var version2 = "v7.13.0-9-g72f2a811";
82272
- var hash = "72f2a811d4851c6f50758617c9e65179d2b27bc8";
82273
- var buildId = "12978670711-1";
82472
+ var version2 = "v7.15.1-10-g25fa7659";
82473
+ var hash = "25fa7659b84a40205ceacda8b2ca5f48e1dc6f7b";
82474
+ var buildId = "14319632927-1";
82274
82475
  var versionInfo = { version: version2, hash, buildId };
82275
82476
  async function runFunction(req, fn) {
82276
82477
  if (!req.timer.timers.has("lambda"))
@@ -82555,14 +82756,20 @@ var SafeBuckets = /* @__PURE__ */ new Set([
82555
82756
  var SafeProtocols = /* @__PURE__ */ new Set([new URL("s3://foo").protocol, new URL("memory://foo.json").protocol]);
82556
82757
  var ConfigLoader = class {
82557
82758
  /** Exposed for testing */
82558
- static async getDefaultConfig() {
82759
+ static async getDefaultConfig(req) {
82559
82760
  const config = getDefaultConfig();
82560
- if (config.assets == null) {
82561
- const cb = await config.ConfigBundle.get(config.ConfigBundle.id("latest"));
82562
- if (cb)
82563
- config.assets = cb.assets;
82564
- }
82565
- return config;
82761
+ const cb = await config.ConfigBundle.get("cb_latest");
82762
+ if (cb == null)
82763
+ return config;
82764
+ req?.timer.start("config:load");
82765
+ return CachedConfig.get(Fsa.toUrl(cb.path)).then((cfg) => {
82766
+ req?.timer.end("config:load");
82767
+ if (cfg == null)
82768
+ throw new LambdaHttpResponse(500, "Unable to find latest configuration");
82769
+ if (cfg.assets == null)
82770
+ cfg.assets = cb.assets;
82771
+ return cfg;
82772
+ });
82566
82773
  }
82567
82774
  /** Lookup the config path from a request and return a standardized location */
82568
82775
  static extract(req) {
@@ -82877,6 +83084,8 @@ var Validate = {
82877
83084
  * Defaults to standard image format output if no outputs are defined on the tileset
82878
83085
  */
82879
83086
  pipeline(tileSet, tileType, pipeline2) {
83087
+ if (tileSet.outputs?.length === 1 && pipeline2 == null)
83088
+ pipeline2 = tileSet.outputs[0].name;
82880
83089
  if (pipeline2 != null && pipeline2 !== "rgba") {
82881
83090
  if (tileSet.outputs == null)
82882
83091
  throw new LambdaHttpResponse(404, "TileSet has no pipelines");
@@ -84625,7 +84834,7 @@ function cropResize(tiff, data, comp, mode) {
84625
84834
  const cropVal = comp.crop;
84626
84835
  if (cropVal == null)
84627
84836
  return data;
84628
- return applyCrop(tiff, data, cropVal);
84837
+ return applyCrop(data, cropVal);
84629
84838
  }
84630
84839
  if (data.channels !== 1)
84631
84840
  throw new Error("Unable to crop-resize more than one channel got:" + data.channels);
@@ -84661,14 +84870,14 @@ function cropResize(tiff, data, comp, mode) {
84661
84870
  throw new Error("Unable to use resize kernel: " + mode);
84662
84871
  }
84663
84872
  }
84664
- function applyCrop(_tiff, data, crop) {
84665
- const output = new Float32Array(crop.width * crop.height * data.channels);
84873
+ function applyCrop(data, crop) {
84874
+ const output = getOutputBuffer(data, { width: crop.width, height: crop.height });
84666
84875
  for (let y = 0; y < crop.height; y++) {
84667
84876
  const source = ((y + crop.y) * data.width + crop.x) * data.channels;
84668
84877
  const length = crop.width * data.channels;
84669
- output.set(data.pixels.subarray(source, source + length), y * crop.width);
84878
+ output.pixels.set(data.pixels.subarray(source, source + length), y * crop.width);
84670
84879
  }
84671
- return { pixels: output, width: crop.width, height: crop.height, channels: data.channels, depth: "float32" };
84880
+ return output;
84672
84881
  }
84673
84882
  function resizeNearest(data, comp, source, target) {
84674
84883
  const maxWidth = Math.min(comp.source.width, data.width) - 1;
@@ -84766,9 +84975,21 @@ function resizeBilinear(data, comp, source, target, noData) {
84766
84975
  return ret;
84767
84976
  }
84768
84977
 
84769
- // ../tiler-sharp/build/pipeline/pipeline.color.ramp.js
84978
+ // ../tiler-sharp/build/pipeline/colorize/color.ramp.js
84770
84979
  var ColorRamp = class {
84771
84980
  constructor(ramp) {
84981
+ Object.defineProperty(this, "min", {
84982
+ enumerable: true,
84983
+ configurable: true,
84984
+ writable: true,
84985
+ value: void 0
84986
+ });
84987
+ Object.defineProperty(this, "max", {
84988
+ enumerable: true,
84989
+ configurable: true,
84990
+ writable: true,
84991
+ value: void 0
84992
+ });
84772
84993
  Object.defineProperty(this, "ramps", {
84773
84994
  enumerable: true,
84774
84995
  configurable: true,
@@ -84781,38 +85002,89 @@ var ColorRamp = class {
84781
85002
  const numbers = parts.map(Number);
84782
85003
  this.ramps.push({ v: numbers[0], color: numbers.slice(1) });
84783
85004
  }
85005
+ this.min = this.ramps[0].v;
85006
+ this.max = this.ramps[this.ramps.length - 1].v;
84784
85007
  }
84785
- get(num) {
84786
- const first = this.ramps[0];
84787
- if (num <= first.v)
84788
- return first.color;
85008
+ set(val2, data, targetOffset) {
85009
+ if (val2 <= this.min) {
85010
+ const color = this.ramps[0].color;
85011
+ data[targetOffset] = color[0];
85012
+ data[targetOffset + 1] = color[1];
85013
+ data[targetOffset + 2] = color[2];
85014
+ data[targetOffset + 3] = color[3];
85015
+ return;
85016
+ } else if (val2 >= this.max) {
85017
+ const color = this.ramps[this.ramps.length - 1].color;
85018
+ data[targetOffset] = color[0];
85019
+ data[targetOffset + 1] = color[1];
85020
+ data[targetOffset + 2] = color[2];
85021
+ data[targetOffset + 3] = color[3];
85022
+ return;
85023
+ }
84789
85024
  for (let i = 0; i < this.ramps.length - 1; i++) {
84790
85025
  const ramp = this.ramps[i];
84791
- if (num < ramp.v)
85026
+ if (val2 < ramp.v)
84792
85027
  continue;
84793
- if (ramp.v === num)
84794
- return ramp.color;
85028
+ if (ramp.v === val2) {
85029
+ const color = ramp.color;
85030
+ data[targetOffset] = color[0];
85031
+ data[targetOffset + 1] = color[1];
85032
+ data[targetOffset + 2] = color[2];
85033
+ data[targetOffset + 3] = color[3];
85034
+ return;
85035
+ }
84795
85036
  const rampNext = this.ramps[i + 1];
84796
- if (num >= rampNext.v)
85037
+ if (val2 >= rampNext.v)
84797
85038
  continue;
84798
85039
  const range = rampNext.v - ramp.v;
84799
- const offset = num - ramp.v;
85040
+ const offset = val2 - ramp.v;
84800
85041
  const scale = offset / range;
84801
85042
  const r = Math.round((rampNext.color[0] - ramp.color[0]) * scale + ramp.color[0]);
84802
85043
  const g = Math.round((rampNext.color[1] - ramp.color[1]) * scale + ramp.color[1]);
84803
85044
  const b = Math.round((rampNext.color[2] - ramp.color[2]) * scale + ramp.color[2]);
84804
85045
  const a = Math.round((rampNext.color[3] - ramp.color[3]) * scale + ramp.color[3]);
84805
- return [r, g, b, a];
85046
+ data[targetOffset] = r;
85047
+ data[targetOffset + 1] = g;
85048
+ data[targetOffset + 2] = b;
85049
+ data[targetOffset + 3] = a;
85050
+ return;
84806
85051
  }
84807
- return this.ramps[this.ramps.length - 1].color;
85052
+ throw new Error("Ramp value assertion failure");
84808
85053
  }
84809
85054
  };
85055
+
85056
+ // ../tiler-sharp/build/pipeline/colorize/grey.scale.js
85057
+ var GreyScale = class {
85058
+ constructor(minVal, maxVal) {
85059
+ Object.defineProperty(this, "min", {
85060
+ enumerable: true,
85061
+ configurable: true,
85062
+ writable: true,
85063
+ value: void 0
85064
+ });
85065
+ Object.defineProperty(this, "max", {
85066
+ enumerable: true,
85067
+ configurable: true,
85068
+ writable: true,
85069
+ value: void 0
85070
+ });
85071
+ this.min = minVal;
85072
+ this.max = maxVal;
85073
+ }
85074
+ set(val2, data, targetOffset) {
85075
+ const scaledValue = (val2 - this.min) * 255 / (this.max - this.min);
85076
+ data[targetOffset] = scaledValue;
85077
+ data[targetOffset + 1] = scaledValue;
85078
+ data[targetOffset + 2] = scaledValue;
85079
+ data[targetOffset + 3] = 255;
85080
+ }
85081
+ };
85082
+
85083
+ // ../tiler-sharp/build/pipeline/pipeline.color.ramp.js
84810
85084
  var Ramps = {
84811
85085
  float32: new ColorRamp(DefaultColorRamp),
84812
- uint8: new ColorRamp(`0 0 0 0 255
84813
- 255 255 255 255 255`),
84814
- uint32: new ColorRamp(`0 0 0 0 255
84815
- ${2 ** 32 - 1} 255 255 255 255`)
85086
+ uint8: new GreyScale(0, 255),
85087
+ uint32: new GreyScale(0, 2 ** 32 - 1)
84816
85088
  };
84817
85089
  var PipelineColorRamp = {
84818
85090
  type: "color-ramp",
@@ -84834,11 +85106,7 @@ var PipelineColorRamp = {
84834
85106
  if (noData != null && px === noData)
84835
85107
  continue;
84836
85108
  const target = i * 4;
84837
- const color = ramp.get(px);
84838
- raw[target + 0] = color[0];
84839
- raw[target + 1] = color[1];
84840
- raw[target + 2] = color[2];
84841
- raw[target + 3] = color[3];
85109
+ ramp.set(px, raw, target);
84842
85110
  }
84843
85111
  return output;
84844
85112
  }
@@ -86521,17 +86789,17 @@ function versionGet() {
86521
86789
  * last git version tag
86522
86790
  * @example "v6.42.1"
86523
86791
  */
86524
- version: "v7.13.0-9-g72f2a811",
86792
+ version: "v7.15.1-10-g25fa7659",
86525
86793
  /**
86526
86794
  * Full git commit hash
86527
86795
  * @example "e4231b1ee62c276c8657c56677ced02681dfe5d6"
86528
86796
  */
86529
- hash: "72f2a811d4851c6f50758617c9e65179d2b27bc8",
86797
+ hash: "25fa7659b84a40205ceacda8b2ca5f48e1dc6f7b",
86530
86798
  /**
86531
86799
  * The exact build that this release was run from
86532
86800
  * @example "1658821493-3"
86533
86801
  */
86534
- buildId: "12978670711-1"
86802
+ buildId: "14319632927-1"
86535
86803
  });
86536
86804
  return Promise.resolve(response);
86537
86805
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/lambda-tiler",
3
- "version": "7.14.0",
3
+ "version": "7.16.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
@@ -115,9 +115,9 @@
115
115
  "license": "Apache-2.0"
116
116
  },
117
117
  "node_modules/semver": {
118
- "version": "7.6.3",
119
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
120
- "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
118
+ "version": "7.7.1",
119
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
120
+ "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
121
121
  "license": "ISC",
122
122
  "bin": {
123
123
  "semver": "bin/semver.js"
@@ -100,7 +100,7 @@ Options:
100
100
  -i --increment [<level>]
101
101
  Increment a version by the specified level. Level can
102
102
  be one of: major, minor, patch, premajor, preminor,
103
- prepatch, or prerelease. Default level is 'patch'.
103
+ prepatch, prerelease, or release. Default level is 'patch'.
104
104
  Only one version may be specified.
105
105
 
106
106
  --preid <identifier>
@@ -141,6 +141,8 @@ A "version" is described by the `v2.0.0` specification found at
141
141
  <https://semver.org/>.
142
142
 
143
143
  A leading `"="` or `"v"` character is stripped off and ignored.
144
+ Support for stripping a leading "v" is kept for compatibility with `v1.0.0` of the SemVer
145
+ specification but should not be used anymore.
144
146
 
145
147
  ## Ranges
146
148
 
@@ -237,6 +239,13 @@ $ semver 1.2.4-beta.0 -i prerelease
237
239
  1.2.4-beta.1
238
240
  ```
239
241
 
242
+ To get out of the prerelease phase, use the `release` option:
243
+
244
+ ```bash
245
+ $ semver 1.2.4-beta.1 -i release
246
+ 1.2.4
247
+ ```
248
+
240
249
  #### Prerelease Identifier Base
241
250
 
242
251
  The method `.inc` takes an optional parameter 'identifierBase' string
@@ -415,10 +424,10 @@ Strict-mode Comparators and Ranges will be strict about the SemVer
415
424
  strings that they parse.
416
425
 
417
426
  * `valid(v)`: Return the parsed version, or null if it's not valid.
418
- * `inc(v, release, options, identifier, identifierBase)`:
427
+ * `inc(v, releaseType, options, identifier, identifierBase)`:
419
428
  Return the version incremented by the release
420
429
  type (`major`, `premajor`, `minor`, `preminor`, `patch`,
421
- `prepatch`, or `prerelease`), or null if it's not valid
430
+ `prepatch`, `prerelease`, or `release`), or null if it's not valid
422
431
  * `premajor` in one call will bump the version up to the next major
423
432
  version and down to a prerelease of that major version.
424
433
  `preminor`, and `prepatch` work the same way.
@@ -426,6 +435,7 @@ strings that they parse.
426
435
  same as `prepatch`. It increments the patch version and then makes a
427
436
  prerelease. If the input version is already a prerelease it simply
428
437
  increments it.
438
+ * `release` will remove any prerelease part of the version.
429
439
  * `identifier` can be used to prefix `premajor`, `preminor`,
430
440
  `prepatch`, or `prerelease` version increments. `identifierBase`
431
441
  is the base to be used for the `prerelease` identifier.
@@ -477,7 +487,7 @@ strings that they parse.
477
487
 
478
488
  ### Ranges
479
489
 
480
- * `validRange(range)`: Return the valid range or null if it's not valid
490
+ * `validRange(range)`: Return the valid range or null if it's not valid.
481
491
  * `satisfies(version, range)`: Return true if the version satisfies the
482
492
  range.
483
493
  * `maxSatisfying(versions, range)`: Return the highest version in the list
@@ -61,6 +61,7 @@ const main = () => {
61
61
  switch (argv[0]) {
62
62
  case 'major': case 'minor': case 'patch': case 'prerelease':
63
63
  case 'premajor': case 'preminor': case 'prepatch':
64
+ case 'release':
64
65
  inc = argv.shift()
65
66
  break
66
67
  default:
@@ -149,7 +150,7 @@ Options:
149
150
  -i --increment [<level>]
150
151
  Increment a version by the specified level. Level can
151
152
  be one of: major, minor, patch, premajor, preminor,
152
- prepatch, or prerelease. Default level is 'patch'.
153
+ prepatch, prerelease, or release. Default level is 'patch'.
153
154
  Only one version may be specified.
154
155
 
155
156
  --preid <identifier>
@@ -1,6 +1,6 @@
1
1
  const debug = require('../internal/debug')
2
2
  const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
3
- const { safeRe: re, t } = require('../internal/re')
3
+ const { safeRe: re, safeSrc: src, t } = require('../internal/re')
4
4
 
5
5
  const parseOptions = require('../internal/parse-options')
6
6
  const { compareIdentifiers } = require('../internal/identifiers')
@@ -10,7 +10,7 @@ class SemVer {
10
10
 
11
11
  if (version instanceof SemVer) {
12
12
  if (version.loose === !!options.loose &&
13
- version.includePrerelease === !!options.includePrerelease) {
13
+ version.includePrerelease === !!options.includePrerelease) {
14
14
  return version
15
15
  } else {
16
16
  version = version.version
@@ -176,6 +176,20 @@ class SemVer {
176
176
  // preminor will bump the version up to the next minor release, and immediately
177
177
  // down to pre-release. premajor and prepatch work the same way.
178
178
  inc (release, identifier, identifierBase) {
179
+ if (release.startsWith('pre')) {
180
+ if (!identifier && identifierBase === false) {
181
+ throw new Error('invalid increment argument: identifier is empty')
182
+ }
183
+ // Avoid an invalid semver results
184
+ if (identifier) {
185
+ const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`)
186
+ const match = `-${identifier}`.match(r)
187
+ if (!match || match[1] !== identifier) {
188
+ throw new Error(`invalid identifier: ${identifier}`)
189
+ }
190
+ }
191
+ }
192
+
179
193
  switch (release) {
180
194
  case 'premajor':
181
195
  this.prerelease.length = 0
@@ -206,6 +220,12 @@ class SemVer {
206
220
  }
207
221
  this.inc('pre', identifier, identifierBase)
208
222
  break
223
+ case 'release':
224
+ if (this.prerelease.length === 0) {
225
+ throw new Error(`version ${this.raw} is not a prerelease`)
226
+ }
227
+ this.prerelease.length = 0
228
+ break
209
229
 
210
230
  case 'major':
211
231
  // If this is a pre-major version, bump up to the same major version.
@@ -249,10 +269,6 @@ class SemVer {
249
269
  case 'pre': {
250
270
  const base = Number(identifierBase) ? 1 : 0
251
271
 
252
- if (!identifier && identifierBase === false) {
253
- throw new Error('invalid increment argument: identifier is empty')
254
- }
255
-
256
272
  if (this.prerelease.length === 0) {
257
273
  this.prerelease = [base]
258
274
  } else {