maplibre-gl-nightlayer 1.0.0-alpha.13 → 1.0.0-alpha.14

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/main.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Decimal } from '@kikuchan/decimal';
1
2
  import type { CustomLayerInterface, CustomRenderMethodInput, Map as MaplibreMap } from 'maplibre-gl';
2
3
  import type { mat4 } from 'gl-matrix';
3
4
  /**
@@ -5,7 +6,7 @@ import type { mat4 } from 'gl-matrix';
5
6
  * @param date If null, the current date is used.
6
7
  * @returns The subsolar point.
7
8
  */
8
- export declare function getSubsolarPoint(date?: Date): {
9
+ export declare function getSubsolarPoint(date?: Decimal | null): {
9
10
  lng: number;
10
11
  lat: number;
11
12
  };
@@ -84,11 +85,13 @@ export declare class NightLayer implements CustomLayerInterface {
84
85
  * @returns The date. If null, the current date is used.
85
86
  */
86
87
  getDate(): Date | null;
88
+ getTime(): Decimal | null;
87
89
  /**
88
90
  * Set the date for the shadow.
89
91
  * @param date If null, the current date is used.
90
92
  */
91
93
  setDate(date: Date | null): void;
94
+ setTime(date: Date | null | number | Decimal): void;
92
95
  /**
93
96
  * Get the opacity of the shadow.
94
97
  * @returns The opacity. 0.0 means fully transparent, 1.0 means fully opaque.
package/dist/main.js CHANGED
@@ -1,25 +1,25 @@
1
- import{MercatorCoordinate as f,createTileMesh as d}from"maplibre-gl";function p(n){return n*Math.PI/180}function g(n){return n/Math.PI*180}function l(n){const[t,r,u,o]=n.map(a=>a/255);return[t*o,r*o,u*o,o]}function b(n){n=n||new Date;const t=(n.getTime()-Date.UTC(n.getUTCFullYear(),0,0))/864e5,r=2*Math.PI/365.24,u=p(23.44),o=.0167,a=(t+9)*r,e=a+2*o*Math.sin((t-3)*r),i=(a-Math.atan2(Math.sin(e),Math.cos(e)*Math.cos(u)))/Math.PI,s=720*(i-Math.trunc(i+.5)),h=-15*(n.getUTCHours()+n.getUTCMinutes()/60+n.getUTCSeconds()/3600+n.getUTCMilliseconds()/36e5-12+s/60),m=g(Math.asin(Math.sin(-u)*Math.cos(e)));return{lng:h,lat:m}}class _{id="nightlayer";type="custom";renderingMode="2d";#n;#a;#c;#f;#s;#o;#u;#h;#e;#t;#i;#r;#l;#m;constructor(t={}){this.#a=t.opacity??.5,this.#u=t.twilightSteps??0,this.#h=t.twilightAttenuation??.5,this.#o=t.updateInterval??1e4,this.setColor(t.color??[0,0,0,255]),this.setDaytimeColor(t.daytimeColor??[0,0,0,0]),this.setDate(t.date??null)}#d(){const t=this.#n===null;this.#s&&(clearInterval(this.#s),this.#s=void 0),t&&this.#o>0&&(this.#s=setInterval(()=>this.#t?.triggerRepaint(),this.#o))}getSubsolarPoint(){return b(this.#n||new Date)}getDate(){return this.#n}setDate(t){this.#n=t,this.#d(),this.#t?.triggerRepaint()}getOpacity(){return this.#a}setOpacity(t){this.#a=t,this.#t?.triggerRepaint()}getColor(){return this.#c}setColor(t){this.#c=[...t.slice(0,3),t?.[3]??255],this.#t?.triggerRepaint()}getDaytimeColor(){return this.#f}setDaytimeColor(t){this.#f=[...t.slice(0,3),t?.[3]??255],this.#t?.triggerRepaint()}getTwilightSteps(){return this.#u}setTwilightSteps(t){this.#u=t,this.#t?.triggerRepaint()}getTwilightAttenuation(){return this.#h}setTwilightAttenuation(t){this.#h=t,this.#t?.triggerRepaint()}getUpdateInterval(){return this.#o}setUpdateInterval(t){this.#o=t,this.#d()}onAdd(t,r){this.#e=new Map,this.#i=r.createBuffer(),this.#r=r.createBuffer(),this.#t=t}onRemove(){this.#e=void 0,this.#t=void 0,this.#i=void 0,this.#r=void 0}#p(t,r){const o=`#version 300 es
1
+ import{Decimal as f}from"@kikuchan/decimal";import{MercatorCoordinate as v,createTileMesh as A}from"maplibre-gl";function x(n){return n*Math.PI/180}function w(n){return n/Math.PI*180}const R=86400n,S=719528n,y=146097n;function m(n,t){const i=n/t;return n%t!==0n&&n<0n!=t<0n?i-1n:i}function D(n,t){return n-m(n,t)*t}function E(n){return n%4n!==0n?!1:n%100n!==0n?!0:n%400n===0n}function T(n){const t=n.floor(0),i=t.integer(),u=n.sub(t),a=m(i,R),s=D(i,R);let e=a+S;e-=60n;const r=m(e,y),o=e-r*y,c=m(o-o/1460n+o/36524n-o/146096n,365n);let h=c+r*400n;const d=o-(365n*c+c/4n-c/100n),l=(5n*d+2n)/153n,p=d-(153n*l+2n)/5n+1n;let b=l+3n;b>12n&&(b-=12n,h+=1n);const C=[31n,E(h)?29n:28n,31n,30n,31n,30n,31n,31n,30n,31n,30n,31n];let _=p;for(let g=0;g<Number(b)-1;g+=1)_+=C[g];const M=f(s.toString()).add(u);return{dayOfYear:_,secondsOfDayDecimal:M}}function L(n){const[t,i,u,a]=n.map(s=>s/255);return[t*a,i*a,u*a,a]}function I(n){n==null&&(n=f(Date.now()/1e3));const{dayOfYear:t,secondsOfDayDecimal:i}=T(n),u=f(t.toString()).add(i.div(86400)).number(),a=2*Math.PI/365.24,s=x(23.44),e=.0167,r=(u+9)*a,o=r+2*e*Math.sin((u-3)*a),c=(r-Math.atan2(Math.sin(o),Math.cos(o)*Math.cos(s)))/Math.PI,h=720*(c-Math.trunc(c+.5)),l=-15*(i.div(3600).number()-12+h/60),p=w(Math.asin(Math.sin(-s)*Math.cos(o)));return{lng:l,lat:p}}class B{id="nightlayer";type="custom";renderingMode="2d";#e;#a;#h;#f;#s;#o;#u;#c;#n;#t;#i;#r;#l;#m;constructor(t={}){this.#a=t.opacity??.5,this.#u=t.twilightSteps??0,this.#c=t.twilightAttenuation??.5,this.#o=t.updateInterval??1e4,this.setColor(t.color??[0,0,0,255]),this.setDaytimeColor(t.daytimeColor??[0,0,0,0]),this.setDate(t.date??null)}#d(){const t=this.#e===null;this.#s&&(clearInterval(this.#s),this.#s=void 0),t&&this.#o>0&&(this.#s=setInterval(()=>this.#t?.triggerRepaint(),this.#o))}getSubsolarPoint(){return I(this.#e)}getDate(){return this.#e?new Date(this.#e.mul(1e3).number()):null}getTime(){return this.#e}setDate(t){this.setTime(t)}setTime(t){t instanceof Date&&(t=f(t.getTime()).div(1e3)),this.#e=f(t),this.#d(),this.#t?.triggerRepaint()}getOpacity(){return this.#a}setOpacity(t){this.#a=t,this.#t?.triggerRepaint()}getColor(){return this.#h}setColor(t){this.#h=[...t.slice(0,3),t?.[3]??255],this.#t?.triggerRepaint()}getDaytimeColor(){return this.#f}setDaytimeColor(t){this.#f=[...t.slice(0,3),t?.[3]??255],this.#t?.triggerRepaint()}getTwilightSteps(){return this.#u}setTwilightSteps(t){this.#u=t,this.#t?.triggerRepaint()}getTwilightAttenuation(){return this.#c}setTwilightAttenuation(t){this.#c=t,this.#t?.triggerRepaint()}getUpdateInterval(){return this.#o}setUpdateInterval(t){this.#o=t,this.#d()}onAdd(t,i){this.#n=new Map,this.#i=i.createBuffer(),this.#r=i.createBuffer(),this.#t=t}onRemove(){this.#n=void 0,this.#t=void 0,this.#i=void 0,this.#r=void 0}#p(t,i){const a=`#version 300 es
2
2
  precision highp float;
3
3
 
4
4
  in vec2 a_position;
5
5
  out vec2 v_position;
6
6
 
7
- ${!r.vertexShaderPrelude?`
7
+ ${!i.vertexShaderPrelude?`
8
8
  uniform mat4 u_matrix;
9
9
 
10
10
  vec4 projectTile(vec2 pos) {
11
11
  return u_matrix * vec4(pos, 0., 1.);
12
12
  }
13
13
  `:`
14
- ${r.vertexShaderPrelude}
15
- ${r.define}
14
+ ${i.vertexShaderPrelude}
15
+ ${i.define}
16
16
  `}
17
17
 
18
18
  void main() {
19
19
  gl_Position = projectTile(a_position);
20
20
  v_position = a_position;
21
21
  }
22
- `,a=`#version 300 es
22
+ `,s=`#version 300 es
23
23
  precision highp float;
24
24
 
25
25
  in vec2 v_position;
@@ -69,4 +69,4 @@ ${!r.vertexShaderPrelude?`
69
69
  }
70
70
  float brightness = clamp(pow(clamp(1. - att, 0., 1.), twilightLevel), 0., 1.);
71
71
  fragColor = mix(u_night_color, u_daytime_color, brightness) * u_opacity;
72
- }`,e=t.createShader(t.VERTEX_SHADER);if(!e)throw new Error("failed to create vertex shader");t.shaderSource(e,o),t.compileShader(e);const i=t.createShader(t.FRAGMENT_SHADER);if(!i)throw new Error("failed to create fragment shader");t.shaderSource(i,a),t.compileShader(i);const s=t.createProgram();if(!s)throw new Error("failed to create program");return t.attachShader(s,e),t.attachShader(s,i),t.linkProgram(s),s}#g(t){if(!this.#t||!this.#i||!this.#r)return;const[r,u]=this.#t.getBounds().toArray(),o=Math.floor(f.fromLngLat(r).x),a=Math.ceil(f.fromLngLat(u).x),e=this.#t.style?.projection?.name==="globe"?"globe":[o,a].join(":");if(e===this.#m)return;let i;e==="globe"?(i=d({granularity:100,generateBorders:!1,extendToNorthPole:!0,extendToSouthPole:!0},"16bit"),i.vertices=new Float32Array(new Int16Array(i.vertices)).map(s=>s/8192).buffer):i={vertices:new Float32Array([o,0,a,0,o,1,o,1,a,0,a,1]).buffer,indices:new Uint16Array([0,1,2,3,4,5]).buffer,uses32bitIndices:!1},t.bindBuffer(t.ARRAY_BUFFER,this.#i),t.bufferData(t.ARRAY_BUFFER,i.vertices,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#r),t.bufferData(t.ELEMENT_ARRAY_BUFFER,i.indices,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this.#l=i.indices.byteLength/2,this.#m=e}render(t,r,u){if(u||(u=r),!this.#e||!this.#i||!this.#r||!this.#t)return;const o=u.shaderData||{},a=o.variantName||"default";this.#e.has(a)||this.#e.set(a,this.#p(t,o));const e=this.#e.get(a);if(!e)return;const{lng:i,lat:s}=this.getSubsolarPoint();if(t.useProgram(e),t.uniform2fv(t.getUniformLocation(e,"u_subsolar"),[i,s]),t.uniform1f(t.getUniformLocation(e,"u_opacity"),this.#a),t.uniform4fv(t.getUniformLocation(e,"u_night_color"),l(this.#c)),t.uniform4fv(t.getUniformLocation(e,"u_daytime_color"),l(this.#f)),t.uniform1f(t.getUniformLocation(e,"u_twilight_steps"),this.#u),t.uniform1f(t.getUniformLocation(e,"u_twilight_attenuation"),this.#h),"getProjectionDataForCustomLayer"in this.#t.transform){const h=this.#t.transform.getProjectionDataForCustomLayer(!0);t.uniformMatrix4fv(t.getUniformLocation(e,"u_projection_fallback_matrix"),!1,h.fallbackMatrix),t.uniformMatrix4fv(t.getUniformLocation(e,"u_projection_matrix"),!1,h.mainMatrix),t.uniform4f(t.getUniformLocation(e,"u_projection_tile_mercator_coords"),...h.tileMercatorCoords),t.uniform4f(t.getUniformLocation(e,"u_projection_clipping_plane"),...h.clippingPlane),t.uniform1f(t.getUniformLocation(e,"u_projection_transition"),h.projectionTransition)}else t.uniformMatrix4fv(t.getUniformLocation(e,"u_matrix"),!1,r);this.#g(t),t.bindBuffer(t.ARRAY_BUFFER,this.#i),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#r);const c=t.getAttribLocation(e,"a_position");t.enableVertexAttribArray(c),t.vertexAttribPointer(c,2,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLES,this.#l,t.UNSIGNED_SHORT,0)}}var C=_;export{_ as NightLayer,C as default,b as getSubsolarPoint};
72
+ }`,e=t.createShader(t.VERTEX_SHADER);if(!e)throw new Error("failed to create vertex shader");t.shaderSource(e,a),t.compileShader(e);const r=t.createShader(t.FRAGMENT_SHADER);if(!r)throw new Error("failed to create fragment shader");t.shaderSource(r,s),t.compileShader(r);const o=t.createProgram();if(!o)throw new Error("failed to create program");return t.attachShader(o,e),t.attachShader(o,r),t.linkProgram(o),o}#b(t){if(!this.#t||!this.#i||!this.#r)return;const[i,u]=this.#t.getBounds().toArray(),a=Math.floor(v.fromLngLat(i).x),s=Math.ceil(v.fromLngLat(u).x),e=this.#t.style?.projection?.name==="globe"?"globe":[a,s].join(":");if(e===this.#m)return;let r;e==="globe"?(r=A({granularity:100,generateBorders:!1,extendToNorthPole:!0,extendToSouthPole:!0},"16bit"),r.vertices=new Float32Array(new Int16Array(r.vertices)).map(o=>o/8192).buffer):r={vertices:new Float32Array([a,0,s,0,a,1,a,1,s,0,s,1]).buffer,indices:new Uint16Array([0,1,2,3,4,5]).buffer,uses32bitIndices:!1},t.bindBuffer(t.ARRAY_BUFFER,this.#i),t.bufferData(t.ARRAY_BUFFER,r.vertices,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#r),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r.indices,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this.#l=r.indices.byteLength/2,this.#m=e}render(t,i,u){if(u||(u=i),!this.#n||!this.#i||!this.#r||!this.#t)return;const a=u.shaderData||{},s=a.variantName||"default";this.#n.has(s)||this.#n.set(s,this.#p(t,a));const e=this.#n.get(s);if(!e)return;const{lng:r,lat:o}=this.getSubsolarPoint();if(t.useProgram(e),t.uniform2fv(t.getUniformLocation(e,"u_subsolar"),[r,o]),t.uniform1f(t.getUniformLocation(e,"u_opacity"),this.#a),t.uniform4fv(t.getUniformLocation(e,"u_night_color"),L(this.#h)),t.uniform4fv(t.getUniformLocation(e,"u_daytime_color"),L(this.#f)),t.uniform1f(t.getUniformLocation(e,"u_twilight_steps"),this.#u),t.uniform1f(t.getUniformLocation(e,"u_twilight_attenuation"),this.#c),"getProjectionDataForCustomLayer"in this.#t.transform){const h=this.#t.transform.getProjectionDataForCustomLayer(!0);t.uniformMatrix4fv(t.getUniformLocation(e,"u_projection_fallback_matrix"),!1,h.fallbackMatrix),t.uniformMatrix4fv(t.getUniformLocation(e,"u_projection_matrix"),!1,h.mainMatrix),t.uniform4f(t.getUniformLocation(e,"u_projection_tile_mercator_coords"),...h.tileMercatorCoords),t.uniform4f(t.getUniformLocation(e,"u_projection_clipping_plane"),...h.clippingPlane),t.uniform1f(t.getUniformLocation(e,"u_projection_transition"),h.projectionTransition)}else t.uniformMatrix4fv(t.getUniformLocation(e,"u_matrix"),!1,i);this.#b(t),t.bindBuffer(t.ARRAY_BUFFER,this.#i),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#r);const c=t.getAttribLocation(e,"a_position");t.enableVertexAttribArray(c),t.vertexAttribPointer(c,2,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLES,this.#l,t.UNSIGNED_SHORT,0)}}var F=B;export{B as NightLayer,F as default,I as getSubsolarPoint};
@@ -1,18 +1,18 @@
1
- "use strict";var nightLayer=(()=>{var f=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var o in t)f(r,o,{get:t[o],enumerable:!0})},M=(r,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of v(t))!C.call(r,i)&&i!==o&&f(r,i,{get:()=>t[i],enumerable:!(s=_(t,i))||s.enumerable});return r};var L=r=>M(f({},"__esModule",{value:!0}),r);var w={};R(w,{NightLayer:()=>c,default:()=>y,getSubsolarPoint:()=>g});var{createTileMesh:d,MercatorCoordinate:m}=maplibregl;function x(r){return r*Math.PI/180}function A(r){return r/Math.PI*180}function p(r){let[t,o,s,i]=r.map(a=>a/255);return[t*i,o*i,s*i,i]}function g(r){r=r||new Date;let t=(r.getTime()-Date.UTC(r.getUTCFullYear(),0,0))/864e5,o=2*Math.PI/365.24,s=x(23.44),i=.0167,a=(t+9)*o,e=a+2*i*Math.sin((t-3)*o),n=(a-Math.atan2(Math.sin(e),Math.cos(e)*Math.cos(s)))/Math.PI,u=720*(n-Math.trunc(n+.5)),h=-15*(r.getUTCHours()+r.getUTCMinutes()/60+r.getUTCSeconds()/3600+r.getUTCMilliseconds()/36e5-12+u/60),b=A(Math.asin(Math.sin(-s)*Math.cos(e)));return{lng:h,lat:b}}var c=class{id="nightlayer";type="custom";renderingMode="2d";#n;#a;#c;#l;#s;#o;#u;#h;#e;#t;#r;#i;#f;#m;constructor(t={}){this.#a=t.opacity??.5,this.#u=t.twilightSteps??0,this.#h=t.twilightAttenuation??.5,this.#o=t.updateInterval??1e4,this.setColor(t.color??[0,0,0,255]),this.setDaytimeColor(t.daytimeColor??[0,0,0,0]),this.setDate(t.date??null)}#d(){let t=this.#n===null;this.#s&&(clearInterval(this.#s),this.#s=void 0),t&&this.#o>0&&(this.#s=setInterval(()=>this.#t?.triggerRepaint(),this.#o))}getSubsolarPoint(){return g(this.#n||new Date)}getDate(){return this.#n}setDate(t){this.#n=t,this.#d(),this.#t?.triggerRepaint()}getOpacity(){return this.#a}setOpacity(t){this.#a=t,this.#t?.triggerRepaint()}getColor(){return this.#c}setColor(t){this.#c=[...t.slice(0,3),t?.[3]??255],this.#t?.triggerRepaint()}getDaytimeColor(){return this.#l}setDaytimeColor(t){this.#l=[...t.slice(0,3),t?.[3]??255],this.#t?.triggerRepaint()}getTwilightSteps(){return this.#u}setTwilightSteps(t){this.#u=t,this.#t?.triggerRepaint()}getTwilightAttenuation(){return this.#h}setTwilightAttenuation(t){this.#h=t,this.#t?.triggerRepaint()}getUpdateInterval(){return this.#o}setUpdateInterval(t){this.#o=t,this.#d()}onAdd(t,o){this.#e=new Map,this.#r=o.createBuffer(),this.#i=o.createBuffer(),this.#t=t}onRemove(){this.#e=void 0,this.#t=void 0,this.#r=void 0,this.#i=void 0}#p(t,o){let i=`#version 300 es
1
+ "use strict";var nightLayer=(()=>{var S=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var H=(n,t)=>{for(var i in t)S(n,i,{get:t[i],enumerable:!0})},K=(n,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of V(t))!X.call(n,r)&&r!==i&&S(n,r,{get:()=>t[r],enumerable:!(e=z(t,r))||e.enumerable});return n};var J=n=>K(S({},"__esModule",{value:!0}),n);var dt={};H(dt,{NightLayer:()=>E,default:()=>ct,getSubsolarPoint:()=>k});function w(n,t="Digits must be an integer"){if(typeof n=="number"){if(!Number.isFinite(n)||!Number.isInteger(n))throw Error(t);return BigInt(n)}return n}function M(n){let t=w(n);return t<0n?0n:t}function Q(n){let t=Number(n);return t<D.length?D[t]:5n**BigInt(n)}function y(n){let t=Number(n);return t<I.length?I[t]:10n**BigInt(n)}function B(n,t,i){let e=BigInt(t);if(e<=0n)return new v(1n);let r=new v(1n),a=n.clone();for(;e&1n&&r.mul$(a,i),e>>=1n,e!==0n;)a.mul$(a,i);return r}function tt(n,t,i,e){if(t.isZero()||e<=0)return new v(1n);let{guardPrec:r,rootPrec:a}=et(i,e),s=L(t.coeff).toString().padStart(e,"0"),o=n.round(a),u=new v(1n);for(let h=0;h<e;h++){o=o.root(10n,a);let f=s.charCodeAt(h)-48;if(f<=0)continue;let l=B(o.clone(),f,r);u.mul$(l,r)}return u.round$(i)}function L(n){return n<0n?-n:n}function T(n){if(n==="")throw Error("Invalid number");let t=1n,i=n;if(i[0]==="-"?(t=-1n,i=i.slice(1)):i[0]==="+"&&(i=i.slice(1)),i==="")throw Error("Invalid number");let e=i.indexOf("."),r=i,a="";e>=0&&(r=i.slice(0,e),a=i.slice(e+1)),r===""&&(r="0");let s=(r+a).replace(/^0+/,"");return{coeff:t*BigInt(s===""?"0":s),digits:BigInt(a.length)}}function N(n){let t=n.search(/[eE]/);if(t===-1)return T(n);let i=n.slice(0,t),e=n.slice(t+1);if(e.trim()==="")throw Error("Invalid number");let{coeff:r,digits:a}=T(i);return{coeff:r,digits:a-BigInt(e)}}function _(n,t){let i=n.digits>t.digits?n.digits:t.digits,e=i-n.digits,r=i-t.digits;return{digits:i,aCoeff:n.coeff*y(e),bCoeff:t.coeff*y(r)}}function F(n){let t=Math.max(0,Number(n));return Math.min(2**53-1,t)}function it(n,t,i){let e=F(t),r=F(i),a=Math.max(e,r)+1,s=Math.max(a,1),o=n+s;for(;;){let u=Math.ceil(o*ot)+s,h=Math.max(u*2,1),f=Math.max(a,Math.ceil(Math.log10(h))+1);if(f<=s){let l=o+s;return{guardPrec:s,fracPrec:o,bits:u,divPrec:l}}s=f,o=n+s}}function et(n,t){let i=Math.max(1,t),e=Math.max(6,Math.ceil(Math.log10(i*4))+2),r=n+BigInt(e);return{guardPrec:r,rootPrec:r+BigInt(Math.max(e,6))}}function rt(n,t){let i=Math.max(1,t.toString().replace("-","").length),e=Math.max(12,i+4);return{iterPrec:n+BigInt(e),stopShift:n+2n}}function U(n,t,i,e){let r=[],a=[],s=new v(t),o=1n,u=i+Math.max(e,1);for(;s.le(n);)r.push(s),a.push(o),s=s.mul(s),o*=2n;let h=new v(n),f=0n;for(let l=r.length-1;l>=0;l--){let d=r[l];h.ge(d)&&(h.div$(d,u),f+=a[l])}return{exponent:f,remainder:h}}function nt(n,t,i,e){let r=i+Math.max(e,1);if(n.eq(b))return{exponent:0n,remainder:b.clone()};if(n.ge(b))return U(n,t,i,e);let a=U(b.div(n,r),t,i,e);return a.remainder.eq(b)?{exponent:-a.exponent,remainder:b.clone()}:{exponent:-a.exponent-1n,remainder:b.div(a.remainder,r).mul$(t)}}var v=class x{coeff;digits;constructor(t,i){if(typeof t=="number"){if(t!==t||t===1/0||t===-1/0)throw Error("Invalid number");({coeff:this.coeff,digits:this.digits}=N(t.toString()))}else if(typeof t=="string"){let e=t.trim();if(e==="")throw Error("Invalid number");({coeff:this.coeff,digits:this.digits}=N(e))}else if(typeof t=="bigint")this.coeff=t,this.digits=i??0n;else if(typeof t=="object"&&t&&"coeff"in t&&typeof t.coeff=="bigint"&&"digits"in t&&typeof t.digits=="bigint")this.coeff=t.coeff,this.digits=t.digits;else throw Error("Invalid input type for Decimal")}clone(){return new x({coeff:this.coeff,digits:this.digits})}#t(t,i=0n){return G(t)&&(i=t.digits,t=t.coeff),this.coeff=t,this.digits=i,this}#r(t,i,e){let r=this.coeff,a=t.coeff,s=t.digits+i-this.digits;s>=0n?r*=y(s):a*=y(-s);let o=r/a,u=r-o*a;if(u!==0n&&e!=="trunc"){let h=r>=0n;switch(e){case"floor":h||(o-=1n);break;case"ceil":h&&(o+=1n);break;case"round":{let f=L(u),l=a<0n?-a:a;f*2n>=l&&(o+=h?1n:-1n);break}default:break}}return this.#t(o,i)}#e(t,i="trunc"){let e=w(t);if(this.isZero())return this.digits=e,this;if(e===this.digits)return this;if(e>this.digits){let r=y(e-this.digits);return this.coeff*=r,this.digits=e,this}return this.#r(b,e,i)}#o(){if(this.coeff===0n)return this.digits=0n,this;if(this.digits<=0n)return this;for(;this.digits>0n&&this.coeff%10n==0n;)this.coeff/=10n,this.digits-=1n;return this}round$(t=0,i=!1){let e=w(t);return!i&&this.digits<=e?this:this.#e(e,"round")}round(t=0,i=!1){return this.clone().round$(t,i)}roundBy$(t,i="round"){let e=new x(t).abs();if(e.isZero())throw Error("Cannot align to zero");return this.div$(e,0n,i).mul$(e)}roundBy(t,i="round"){return this.clone().roundBy$(t,i)}floor$(t=0,i=!1){let e=w(t);return!i&&this.digits<=e?this:this.#e(e,"floor")}floor(t=0,i=!1){return this.clone().floor$(t,i)}floorBy$(t){return this.roundBy$(t,"floor")}floorBy(t){return this.clone().floorBy$(t)}ceil$(t=0,i=!1){let e=w(t);return!i&&this.digits<=e?this:this.#e(e,"ceil")}ceil(t=0,i=!1){return this.clone().ceil$(t,i)}ceilBy$(t){return this.roundBy$(t,"ceil")}ceilBy(t){return this.clone().ceilBy$(t)}trunc$(t=0,i=!1){let e=w(t);return!i&&this.digits<=e?this:this.#e(e,"trunc")}trunc(t=0,i=!1){return this.clone().trunc$(t,i)}rescale$(t,i="trunc"){return t==null?this.#o():this.#e(t,i)}rescale(t,i="trunc"){return this.clone().rescale$(t,i)}truncBy$(t){return this.roundBy$(t,"trunc")}truncBy(t){return this.clone().truncBy$(t)}#n(t){let i=this.clone();return t(this),[this,i.sub$(this)]}split$(t,i="floor"){return this.#n(e=>e.#e(t??0n,i))}split(t,i="floor"){return this.clone().split$(t,i)}splitBy$(t,i="floor"){return this.#n(e=>e.roundBy$(t,i))}splitBy(t,i="floor"){return this.clone().splitBy$(t,i)}neg$(t){return t!==!1&&(this.coeff=-this.coeff),this}neg(t){return this.clone().neg$(t)}isZero(){return this.coeff===0n}isPositive(){return this.coeff>0n}isNegative(){return this.coeff<0n}add$(t){let i=c(t),{digits:e,aCoeff:r,bCoeff:a}=_(this,i);return this.coeff=r+a,this.digits=e,this}add(t){return this.clone().add$(t)}sub$(t){let i=c(t),{digits:e,aCoeff:r,bCoeff:a}=_(this,i);return this.coeff=r-a,this.digits=e,this}sub(t){return this.clone().sub$(t)}mul$(t,i){let e=c(t);return this.coeff*=e.coeff,this.digits+=e.digits,i!==void 0&&this.round$(i),this}mul(t,i){return this.clone().mul$(t,i)}shift10$(t){let i=w(t,"Shift amount must be an integer");return i===0n||(this.digits-=i),this}shift10(t){return this.clone().shift10$(t)}inverse$(t=p){if(this.isZero())throw Error("Division by zero");let i=M(t),e=this.clone();return this.#t(1n).div$(e,i)}inverse(t=p){return this.clone().inverse$(t)}div$(t,i,e="round"){let r=i===void 0,a=M(i??p),s=c(t);if(s.isZero())throw Error("Division by zero");return this.isZero()?this:(this.#r(s,a,e),r?this.#o():this)}div(t,i,e="round"){return this.clone().div$(t,i,e)}abs$(){return this.isNegative()&&(this.coeff=-this.coeff),this}abs(){return this.clone().abs$()}mod$(t){let i=c(t);if(i.isZero())throw Error("Division by zero");let{digits:e,aCoeff:r,bCoeff:a}=_(this,i);return this.coeff=r%a,this.digits=e,this}mod(t){return this.clone().mod$(t)}modPositive$(t){let i=c(t);if(i.isNegative())throw Error("Modulo divisor must be positive");return this.mod$(i),this.isNegative()&&this.add$(i),this}modPositive(t){return this.clone().modPositive$(t)}clamp$(t,i){let e=c(t),r=c(i);if(e&&r&&e.gt(r))throw Error("Invalid clamp range");return e&&this.lt(e)?(this.coeff=e.coeff,this.digits=e.digits,this):r&&this.gt(r)?(this.coeff=r.coeff,this.digits=r.digits,this):this}clamp(t,i){return this.clone().clamp$(t,i)}cmp(t){let i=c(t),{aCoeff:e,bCoeff:r}=_(this,i);return e===r?0:e>r?1:-1}eq(t){return this.cmp(t)===0}neq(t){return this.cmp(t)!==0}lt(t){return this.cmp(t)<0}gt(t){return this.cmp(t)>0}le(t){return this.cmp(t)<=0}ge(t){return this.cmp(t)>=0}between(t,i){let e=c(t),r=c(i);if(e&&r&&e.gt(r))throw Error("Invalid between range");return!(e&&this.lt(e)||r&&this.gt(r))}isCloseTo(t,i){let e=c(i);if(e.isNegative())throw Error("Tolerance must be non-negative");return this.sub(t).abs$().le(e)}pow$(t,i=p){let e=M(i),r=c(t);if(r.isZero())return this.#t(1n);if(this.isZero()){if(r.isNegative())throw Error("Zero to negative exponent is undefined");return this}let a=r.isNegative(),[s,o]=r.abs().split$(),u=this.clone(),h=o.isZero()?0:Number(o.digits);if(u.isNegative()&&h>0)throw Error("Fractional exponent requires non-negative base");let f=B(u,s.coeff),l=e;h>0&&(l=e+BigInt(Math.max(4,h)));let d=tt(u,o,l,h);h>0&&f.mul$(d,l);let g=l>e?l:e,m=h>0?l:e;return a?this.#t(1n).div$(f,g):(f.round$(g,!0),this.#t(f)),this.round$(m,m===0n),this}pow(t,i=p){return this.clone().pow$(t,i)}root$(t,i=p){let e=w(t,"Root degree must be an integer");if(e<=0n)throw Error("Invalid root degree");let r=M(i);if(e===1n)return r<this.digits?this:this.trunc$(r,!0);if(this.isZero())return this;let a=this.isNegative();if(a&&e%2n==0n)throw Error("Even root of negative value is not defined");let s=this.abs(),o=e-1n,{iterPrec:u,stopShift:h}=rt(r,e),f=O(-h),l=(()=>{let d=s.number();if(Number.isFinite(d)&&d>0){let g=Number(e);if(g>0){let m=d**(1/g);if(Number.isFinite(m)&&m>0)return new x(m).round$(u,!0)}}return new x(O(s.order()/e)).round$(u,!0)})();this.#t(l.coeff,l.digits),this.isZero()&&this.#t(1n);for(let d=0;d<64;d++){let g=B(this.clone(),o,u);if(g.isZero())break;let m=s.div(g,u),$=this.mul(o,u).add$(m).div$(e,u);if($.isCloseTo(this,f)||$.eq(this)){this.#t($);break}this.#t($)}return this.round$(u,!0),this.round$(r,r===0n),a&&this.neg$(),this}root(t,i=p){return this.clone().root$(t,i)}sqrt$(t=p){return this.root$(2n,t)}sqrt(t=p){return this.clone().sqrt$(t)}log$(t,i=p){let e=Number(M(i)),r=new x(t);if(!this.isPositive())throw Error("Logarithm argument must be positive");if(!r.isPositive())throw Error("Logarithm base must be positive");if(r.eq(b))throw Error("Logarithm base cannot be one");let{guardPrec:a,fracPrec:s,bits:o,divPrec:u}=it(e,r.digits,this.digits),h=r.lt(b),f=h?b.div(r,u):r,{exponent:l,remainder:d}=nt(this,f,s,a);if(this.#t(l),s>0){let m=0n;for(let $=0;$<o;$++)d.mul$(d,u),m<<=1n,d.ge(f)&&(d.div$(f,u),m|=1n);m!==0n&&this.add$({coeff:m*Q(o),digits:BigInt(o)})}let g=e===0?0:s;return this.round$(g),h&&this.neg$(),this}log(t,i=p){return this.clone().log$(t,i)}sign$(){return this.isZero()?this:(this.coeff=this.coeff<0n?-1n:1n,this.digits=0n,this)}sign(){return this.clone().sign$()}order(){if(this.isZero())throw RangeError("order undefined for 0");return BigInt(L(this.coeff).toString().length)-1n-this.digits}toFixed(t){let i="Fraction digits must be a non-negative integer",e=w(t,i);if(e<0n)throw Error(i);return this.round(e,!0).toString()}toString(){if(this.coeff===0n)return this.digits<=0n?"0":`0.${"0".repeat(Number(this.digits))}`;let t=this.coeff<0n,i=t?"-":"",e=(t?-this.coeff:this.coeff).toString();if(this.digits<=0n)return`${i}${e}${"0".repeat(Number(-this.digits))}`;let r=Number(this.digits),a=e.padStart(r+1,"0"),s=a.length-r;return`${i}${a.slice(0,s)}.${a.slice(s).padEnd(r,"0")}`}[Symbol.for("nodejs.util.inspect.custom")](t,i){return"colors"in i&&i?.colors?`\x1B[33m${this.toString()}\x1B[m \x1B[90m(${this.coeff} * 10 ** ${-this.digits})\x1B[m`:this.toString()}number(){return Number(this.toString())}integer(){return this.digits<=0n?this.coeff*y(-this.digits):this.coeff/y(this.digits)}},p=18n,ot=Math.log2(10),b=new v(1n),D=[],I=[];(function(){for(let n=0;n<256;n++)I[n]=10n**BigInt(n),D[n]=5n**BigInt(n)})();function c(n){return n==null||G(n)?n:new v(n)}(function(n){function t(o){return o instanceof v}n.isDecimal=t;function i(o){return!!(t(o)||typeof o=="string"||typeof o=="number"||typeof o=="bigint"||typeof o=="object"&&o&&"coeff"in o&&"digits"in o&&typeof o.coeff=="bigint"&&typeof o.digits=="bigint")}n.isDecimalLike=i;function e(o){return new v({coeff:1n,digits:-BigInt(o)})}n.pow10=e;function r(...o){let u=null,h=null;for(let f=0;f<o.length;f++){let l=c(o[f]);l!=null&&((u===null||l.lt(u))&&(u=l),(h===null||l.gt(h))&&(h=l))}return[u,h]}n.minmax=r;function a(...o){return r(...o)[0]}n.min=a;function s(...o){return r(...o)[1]}n.max=s})(c||={});var G=c.isDecimal,gt=c.isDecimalLike,O=c.pow10,pt=c.minmax,bt=c.min,vt=c.max;var{createTileMesh:Y,MercatorCoordinate:A}=maplibregl;function st(n){return n*Math.PI/180}function at(n){return n/Math.PI*180}var j=86400n,ut=719528n,W=146097n;function C(n,t){let i=n/t;return n%t!==0n&&n<0n!=t<0n?i-1n:i}function ht(n,t){return n-C(n,t)*t}function ft(n){return n%4n!==0n?!1:n%100n!==0n?!0:n%400n===0n}function lt(n){let t=n.floor(0),i=t.integer(),e=n.sub(t),r=C(i,j),a=ht(i,j),s=r+ut;s-=60n;let o=C(s,W),u=s-o*W,h=C(u-u/1460n+u/36524n-u/146096n,365n),f=h+o*400n,l=u-(365n*h+h/4n-h/100n),d=(5n*l+2n)/153n,g=l-(153n*d+2n)/5n+1n,m=d+3n;m>12n&&(m-=12n,f+=1n);let $=[31n,ft(f)?29n:28n,31n,30n,31n,30n,31n,31n,30n,31n,30n,31n],P=g;for(let R=0;R<Number(m)-1;R+=1)P+=$[R];let q=c(a.toString()).add(e);return{dayOfYear:P,secondsOfDayDecimal:q}}function Z(n){let[t,i,e,r]=n.map(a=>a/255);return[t*r,i*r,e*r,r]}function k(n){n==null&&(n=c(Date.now()/1e3));let{dayOfYear:t,secondsOfDayDecimal:i}=lt(n),e=c(t.toString()).add(i.div(86400)).number(),r=2*Math.PI/365.24,a=st(23.44),s=.0167,o=(e+9)*r,u=o+2*s*Math.sin((e-3)*r),h=(o-Math.atan2(Math.sin(u),Math.cos(u)*Math.cos(a)))/Math.PI,f=720*(h-Math.trunc(h+.5)),d=-15*(i.div(3600).number()-12+f/60),g=at(Math.asin(Math.sin(-a)*Math.cos(u)));return{lng:d,lat:g}}var E=class{id="nightlayer";type="custom";renderingMode="2d";#t;#r;#e;#o;#n;#h;#f;#l;#s;#i;#a;#u;#c;#d;constructor(t={}){this.#r=t.opacity??.5,this.#f=t.twilightSteps??0,this.#l=t.twilightAttenuation??.5,this.#h=t.updateInterval??1e4,this.setColor(t.color??[0,0,0,255]),this.setDaytimeColor(t.daytimeColor??[0,0,0,0]),this.setDate(t.date??null)}#m(){let t=this.#t===null;this.#n&&(clearInterval(this.#n),this.#n=void 0),t&&this.#h>0&&(this.#n=setInterval(()=>this.#i?.triggerRepaint(),this.#h))}getSubsolarPoint(){return k(this.#t)}getDate(){return this.#t?new Date(this.#t.mul(1e3).number()):null}getTime(){return this.#t}setDate(t){this.setTime(t)}setTime(t){t instanceof Date&&(t=c(t.getTime()).div(1e3)),this.#t=c(t),this.#m(),this.#i?.triggerRepaint()}getOpacity(){return this.#r}setOpacity(t){this.#r=t,this.#i?.triggerRepaint()}getColor(){return this.#e}setColor(t){this.#e=[...t.slice(0,3),t?.[3]??255],this.#i?.triggerRepaint()}getDaytimeColor(){return this.#o}setDaytimeColor(t){this.#o=[...t.slice(0,3),t?.[3]??255],this.#i?.triggerRepaint()}getTwilightSteps(){return this.#f}setTwilightSteps(t){this.#f=t,this.#i?.triggerRepaint()}getTwilightAttenuation(){return this.#l}setTwilightAttenuation(t){this.#l=t,this.#i?.triggerRepaint()}getUpdateInterval(){return this.#h}setUpdateInterval(t){this.#h=t,this.#m()}onAdd(t,i){this.#s=new Map,this.#a=i.createBuffer(),this.#u=i.createBuffer(),this.#i=t}onRemove(){this.#s=void 0,this.#i=void 0,this.#a=void 0,this.#u=void 0}#g(t,i){let r=`#version 300 es
2
2
  precision highp float;
3
3
 
4
4
  in vec2 a_position;
5
5
  out vec2 v_position;
6
6
 
7
- ${!o.vertexShaderPrelude?`
7
+ ${!i.vertexShaderPrelude?`
8
8
  uniform mat4 u_matrix;
9
9
 
10
10
  vec4 projectTile(vec2 pos) {
11
11
  return u_matrix * vec4(pos, 0., 1.);
12
12
  }
13
13
  `:`
14
- ${o.vertexShaderPrelude}
15
- ${o.define}
14
+ ${i.vertexShaderPrelude}
15
+ ${i.define}
16
16
  `}
17
17
 
18
18
  void main() {
@@ -69,4 +69,4 @@ ${!o.vertexShaderPrelude?`
69
69
  }
70
70
  float brightness = clamp(pow(clamp(1. - att, 0., 1.), twilightLevel), 0., 1.);
71
71
  fragColor = mix(u_night_color, u_daytime_color, brightness) * u_opacity;
72
- }`,e=t.createShader(t.VERTEX_SHADER);if(!e)throw new Error("failed to create vertex shader");t.shaderSource(e,i),t.compileShader(e);let n=t.createShader(t.FRAGMENT_SHADER);if(!n)throw new Error("failed to create fragment shader");t.shaderSource(n,a),t.compileShader(n);let u=t.createProgram();if(!u)throw new Error("failed to create program");return t.attachShader(u,e),t.attachShader(u,n),t.linkProgram(u),u}#g(t){if(!this.#t||!this.#r||!this.#i)return;let[o,s]=this.#t.getBounds().toArray(),i=Math.floor(m.fromLngLat(o).x),a=Math.ceil(m.fromLngLat(s).x),e=this.#t.style?.projection?.name==="globe"?"globe":[i,a].join(":");if(e===this.#m)return;let n;e==="globe"?(n=d({granularity:100,generateBorders:!1,extendToNorthPole:!0,extendToSouthPole:!0},"16bit"),n.vertices=new Float32Array(new Int16Array(n.vertices)).map(u=>u/8192).buffer):n={vertices:new Float32Array([i,0,a,0,i,1,i,1,a,0,a,1]).buffer,indices:new Uint16Array([0,1,2,3,4,5]).buffer,uses32bitIndices:!1},t.bindBuffer(t.ARRAY_BUFFER,this.#r),t.bufferData(t.ARRAY_BUFFER,n.vertices,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#i),t.bufferData(t.ELEMENT_ARRAY_BUFFER,n.indices,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this.#f=n.indices.byteLength/2,this.#m=e}render(t,o,s){if(s||(s=o),!this.#e||!this.#r||!this.#i||!this.#t)return;let i=s.shaderData||{},a=i.variantName||"default";this.#e.has(a)||this.#e.set(a,this.#p(t,i));let e=this.#e.get(a);if(!e)return;let{lng:n,lat:u}=this.getSubsolarPoint();if(t.useProgram(e),t.uniform2fv(t.getUniformLocation(e,"u_subsolar"),[n,u]),t.uniform1f(t.getUniformLocation(e,"u_opacity"),this.#a),t.uniform4fv(t.getUniformLocation(e,"u_night_color"),p(this.#c)),t.uniform4fv(t.getUniformLocation(e,"u_daytime_color"),p(this.#l)),t.uniform1f(t.getUniformLocation(e,"u_twilight_steps"),this.#u),t.uniform1f(t.getUniformLocation(e,"u_twilight_attenuation"),this.#h),"getProjectionDataForCustomLayer"in this.#t.transform){let h=this.#t.transform.getProjectionDataForCustomLayer(!0);t.uniformMatrix4fv(t.getUniformLocation(e,"u_projection_fallback_matrix"),!1,h.fallbackMatrix),t.uniformMatrix4fv(t.getUniformLocation(e,"u_projection_matrix"),!1,h.mainMatrix),t.uniform4f(t.getUniformLocation(e,"u_projection_tile_mercator_coords"),...h.tileMercatorCoords),t.uniform4f(t.getUniformLocation(e,"u_projection_clipping_plane"),...h.clippingPlane),t.uniform1f(t.getUniformLocation(e,"u_projection_transition"),h.projectionTransition)}else t.uniformMatrix4fv(t.getUniformLocation(e,"u_matrix"),!1,o);this.#g(t),t.bindBuffer(t.ARRAY_BUFFER,this.#r),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#i);let l=t.getAttribLocation(e,"a_position");t.enableVertexAttribArray(l),t.vertexAttribPointer(l,2,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLES,this.#f,t.UNSIGNED_SHORT,0)}},y=c;return L(w);})();
72
+ }`,s=t.createShader(t.VERTEX_SHADER);if(!s)throw new Error("failed to create vertex shader");t.shaderSource(s,r),t.compileShader(s);let o=t.createShader(t.FRAGMENT_SHADER);if(!o)throw new Error("failed to create fragment shader");t.shaderSource(o,a),t.compileShader(o);let u=t.createProgram();if(!u)throw new Error("failed to create program");return t.attachShader(u,s),t.attachShader(u,o),t.linkProgram(u),u}#p(t){if(!this.#i||!this.#a||!this.#u)return;let[i,e]=this.#i.getBounds().toArray(),r=Math.floor(A.fromLngLat(i).x),a=Math.ceil(A.fromLngLat(e).x),s=this.#i.style?.projection?.name==="globe"?"globe":[r,a].join(":");if(s===this.#d)return;let o;s==="globe"?(o=Y({granularity:100,generateBorders:!1,extendToNorthPole:!0,extendToSouthPole:!0},"16bit"),o.vertices=new Float32Array(new Int16Array(o.vertices)).map(u=>u/8192).buffer):o={vertices:new Float32Array([r,0,a,0,r,1,r,1,a,0,a,1]).buffer,indices:new Uint16Array([0,1,2,3,4,5]).buffer,uses32bitIndices:!1},t.bindBuffer(t.ARRAY_BUFFER,this.#a),t.bufferData(t.ARRAY_BUFFER,o.vertices,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#u),t.bufferData(t.ELEMENT_ARRAY_BUFFER,o.indices,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this.#c=o.indices.byteLength/2,this.#d=s}render(t,i,e){if(e||(e=i),!this.#s||!this.#a||!this.#u||!this.#i)return;let r=e.shaderData||{},a=r.variantName||"default";this.#s.has(a)||this.#s.set(a,this.#g(t,r));let s=this.#s.get(a);if(!s)return;let{lng:o,lat:u}=this.getSubsolarPoint();if(t.useProgram(s),t.uniform2fv(t.getUniformLocation(s,"u_subsolar"),[o,u]),t.uniform1f(t.getUniformLocation(s,"u_opacity"),this.#r),t.uniform4fv(t.getUniformLocation(s,"u_night_color"),Z(this.#e)),t.uniform4fv(t.getUniformLocation(s,"u_daytime_color"),Z(this.#o)),t.uniform1f(t.getUniformLocation(s,"u_twilight_steps"),this.#f),t.uniform1f(t.getUniformLocation(s,"u_twilight_attenuation"),this.#l),"getProjectionDataForCustomLayer"in this.#i.transform){let f=this.#i.transform.getProjectionDataForCustomLayer(!0);t.uniformMatrix4fv(t.getUniformLocation(s,"u_projection_fallback_matrix"),!1,f.fallbackMatrix),t.uniformMatrix4fv(t.getUniformLocation(s,"u_projection_matrix"),!1,f.mainMatrix),t.uniform4f(t.getUniformLocation(s,"u_projection_tile_mercator_coords"),...f.tileMercatorCoords),t.uniform4f(t.getUniformLocation(s,"u_projection_clipping_plane"),...f.clippingPlane),t.uniform1f(t.getUniformLocation(s,"u_projection_transition"),f.projectionTransition)}else t.uniformMatrix4fv(t.getUniformLocation(s,"u_matrix"),!1,i);this.#p(t),t.bindBuffer(t.ARRAY_BUFFER,this.#a),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.#u);let h=t.getAttribLocation(s,"a_position");t.enableVertexAttribArray(h),t.vertexAttribPointer(h,2,t.FLOAT,!1,0,0),t.drawElements(t.TRIANGLES,this.#c,t.UNSIGNED_SHORT,0)}},ct=E;return J(dt);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maplibre-gl-nightlayer",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.14",
4
4
  "description": "A Night Layer for MapLibre GL JS",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -36,6 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@biomejs/biome": "^2.3.8",
38
38
  "@fal-works/esbuild-plugin-global-externals": "^2.1.2",
39
+ "@kikuchan/decimal": "0.1.0-alpha.4",
39
40
  "esbuild": "^0.27.1",
40
41
  "gl-matrix": "^3.4.4",
41
42
  "maplibre-gl": "5.14.0",