@india-boundary-corrector/leaflet-layer 0.0.1 → 0.0.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.
package/dist/index.js CHANGED
@@ -112,10 +112,10 @@ function templateToTemplateRegex(template) {
112
112
  let pattern = template.replace(/[.*+?^${}()|[\]\\]/g, (char) => {
113
113
  if (char === "{" || char === "}") return char;
114
114
  return "\\" + char;
115
- }).replace(/^https:\/\//, "https?://").replace(/^http:\/\//, "https?://").replace(/\{([a-z0-9])-([a-z0-9])\}/gi, (_2, start, end) => `(\\{${start}-${end}\\}|[a-z0-9]+)`).replace(/\{(z|x|y|s|r)\}/gi, (_2, name) => {
115
+ }).replace(/^https:\/\//, "https?://").replace(/^http:\/\//, "https?://").replace(/\{([a-z0-9])-([a-z0-9])\}/gi, (_2, start, end) => `(\\{${start}-${end}\\}|\\{s\\}|[a-z0-9]+)`).replace(/\{(z|x|y|s|r)\}/gi, (_2, name) => {
116
116
  const lowerName = name.toLowerCase();
117
117
  if (lowerName === "s") {
118
- return "(\\{s\\}|[a-z0-9]+)";
118
+ return "(\\{s\\}|\\{[a-z0-9]-[a-z0-9]\\}|[a-z0-9]+)";
119
119
  }
120
120
  if (lowerName === "r") {
121
121
  return "(\\{r\\}|@\\d+x)?";
@@ -149,6 +149,9 @@ var LayerConfig = class _LayerConfig {
149
149
  if (!id || typeof id !== "string") {
150
150
  throw new Error("LayerConfig requires a non-empty string id");
151
151
  }
152
+ if (id.includes("/")) {
153
+ throw new Error(`LayerConfig id cannot contain slashes: "${id}"`);
154
+ }
152
155
  this.id = id;
153
156
  this.startZoom = startZoom;
154
157
  this.zoomThreshold = zoomThreshold;
@@ -2650,7 +2653,7 @@ function applyMedianBlurAlongPath(ctx, features, lineWidth, tileSize, maskCanvas
2650
2653
  if (!maskCanvas || maskCanvas.width !== tileSize || maskCanvas.height !== tileSize) {
2651
2654
  maskCanvas = new OffscreenCanvas(tileSize, tileSize);
2652
2655
  }
2653
- const maskCtx = maskCanvas.getContext("2d");
2656
+ const maskCtx = maskCanvas.getContext("2d", { willReadFrequently: true });
2654
2657
  maskCtx.fillStyle = "black";
2655
2658
  maskCtx.fillRect(0, 0, tileSize, tileSize);
2656
2659
  maskCtx.strokeStyle = "white";
@@ -2852,8 +2855,11 @@ var BoundaryCorrector = class {
2852
2855
  const useOsm = zoom >= zoomThreshold;
2853
2856
  const addLayerName = useOsm ? "to-add-osm" : "to-add-ne";
2854
2857
  const delLayerName = useOsm ? "to-del-osm" : "to-del-ne";
2855
- const canvas = new OffscreenCanvas(tileSize, tileSize);
2856
- const ctx = canvas.getContext("2d");
2858
+ if (!this._canvas || this._canvas.width !== tileSize) {
2859
+ this._canvas = new OffscreenCanvas(tileSize, tileSize);
2860
+ }
2861
+ const canvas = this._canvas;
2862
+ const ctx = canvas.getContext("2d", { willReadFrequently: true });
2857
2863
  const blob = new Blob([rasterTile]);
2858
2864
  const imageBitmap = await createImageBitmap(blob);
2859
2865
  ctx.drawImage(imageBitmap, 0, 0, tileSize, tileSize);