@aceshooting/lyra-ui 30.7.0 → 30.8.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.
@@ -0,0 +1 @@
1
+ const attachments=new WeakMap;function registerMapCustomLayers(host,attachment){return attachments.set(host,attachment),()=>{attachments.get(host)===attachment&&attachments.delete(host)}}function mapCustomLayerAttachment(host){return attachments.get(host)}export{mapCustomLayerAttachment,registerMapCustomLayers};
@@ -0,0 +1 @@
1
+ import{mapCustomLayerAttachment}from"./map-custom-layer-attachment.js";import{isMapSceneLayerHandle,loadMapSceneLayerRuntime}from"./map-scene-layer-runtime.js";const text=value=>typeof value=="string"&&value.trim().length>0;function ownValue(record,key){const descriptor=Object.getOwnPropertyDescriptor(record,key);if(descriptor&&!("value"in descriptor))throw new TypeError(`Map custom layer ${key} must be a data property.`);return descriptor?.value}function admitLayer(layer){if(typeof layer!="object"||layer===null)throw new TypeError("A map custom layer must be an object.");const id=ownValue(layer,"id"),label=ownValue(layer,"label"),before=ownValue(layer,"before"),create=layer.create;if(!text(id)||!text(label)||typeof create!="function"||before!==void 0&&!text(before))throw new TypeError("A map custom layer needs a nonblank id and label, a create() function and an optional nonblank before.");return Object.freeze({id,label,...before===void 0?{}:{before},create:context=>Reflect.apply(create,layer,[context])})}function nativeCall(map,method,name,listener){const callable=Reflect.get(map,method);typeof callable=="function"&&Reflect.apply(callable,map,[name,listener])}function eventPoint(event){if(typeof event!="object"||event===null)return;const point=Reflect.get(event,"point");if(typeof point!="object"||point===null)return;const x=Reflect.get(point,"x"),y=Reflect.get(point,"y");return typeof x=="number"&&typeof y=="number"&&Number.isFinite(x)&&Number.isFinite(y)?[x,y]:void 0}function createMapCustomLayerController(element,input,options={}){const layer=admitLayer(input),attachment=mapCustomLayerAttachment(element);if(!attachment)throw new TypeError("addMapCustomLayer() requires a connected lr-map.");const onStateChange=options.onStateChange;let status=Object.freeze({state:"loading"}),removed=!1,visible=!0,attempt=0,engine,engineMap,abort,lease;function setStatus(state,code){if(!(removed&&state!=="removed")&&!(status.state===state&&status.code===code)){status=Object.freeze(code===void 0?{state}:{state,code});try{onStateChange?.(status)}catch{}}}const onClick=event=>{const target=engine,point=eventPoint(event);!target||!visible||removed||!point||target.pick(point).then(hit=>{!hit||target!==engine||removed||typeof event!="object"||event===null||lease?.activate({id:hit.id,layerId:layer.id,...hit.position?{position:hit.position}:{}},event)},()=>{})};function stop(){attempt++,abort?.abort(),abort=void 0;const previous=engine;engine=void 0;try{previous?.dispose()}catch{}if(engineMap)try{nativeCall(engineMap,"off","click",onClick)}catch{}engineMap=void 0}function start(map){stop();const ticket=attempt,controller=abort=new AbortController;engineMap=map,setStatus("loading");try{nativeCall(map,"on","click",onClick)}catch{}loadMapSceneLayerRuntime().then(runtime=>{if(removed||ticket!==attempt)return;let created;try{if(created=runtime.createSceneLayer(map,layer,{signal:controller.signal,onState:(state,code)=>{!removed&&ticket===attempt&&setStatus(state,code)},reducedMotion:()=>lease?.reducedMotion()??!1}),!isMapSceneLayerHandle(created))throw new TypeError("Map custom layers are unavailable")}catch{if(controller.abort(),isMapSceneLayerHandle(created))try{created.dispose()}catch{}ticket===attempt&&setStatus("unavailable","engine");return}if(removed||ticket!==attempt){created.dispose();return}engine=created,visible||created.setVisible(!1)},()=>{!removed&&ticket===attempt&&setStatus("unavailable","engine")})}function remove(){if(removed)return;stop(),removed=!0;const owned=lease;lease=void 0,owned?.release(),status=Object.freeze({state:"removed"});try{onStateChange?.(status)}catch{}}lease=attachment.acquire({styleReady(map){if(!removed){if(engineMap===map){engine?.styleReady();return}start(map)}},styleInvalidated(){removed||engine?.invalidateStyle()},mapRemoved(){removed||(stop(),setStatus("loading"))},released:remove});const initial=lease.nativeMap();return initial&&start(initial),Object.freeze({id:layer.id,get status(){return status},requestRender(){removed||engine?.requestFrame()},setVisible(value){visible=!!value,removed||engine?.setVisible(visible)},async pick(point){const target=engine;if(!target||removed)return null;const hit=await target.pick(point);return target===engine&&!removed?hit:null},remove})}export{createMapCustomLayerController};
@@ -0,0 +1,63 @@
1
+ import type{LyraMapPosition}from'../components/media/map/map-scene-types.js';
2
+ /** A position resolved to meters above sea level, or why its terrain height is not known yet.*/
3
+ export type LyraMapResolvedPosition={readonly lngLat:readonly[number,number];readonly altitude:number;readonly status:'resolved';}|{readonly lngLat:readonly[number,number];readonly status:'terrain-pending'|'terrain-unavailable';};
4
+ /** CSS-pixel projection of one position; `visible` excludes clipped and horizon-occluded positions.*/
5
+ export interface LyraMapProjectedPosition{readonly point?:readonly[number,number];readonly visible:boolean;readonly status:'resolved'|'terrain-pending'|'terrain-unavailable'|'visibility-pending'|'clipped'|'occluded';}
6
+ /** A tile-local coordinate origin for one world copy; valid for the current view only.*/
7
+ export interface LyraMapGeographicOrigin{readonly tile:{readonly z:number;readonly x:number;readonly y:number;readonly wrap:number;};readonly key:string;}export type LyraMapGeographicUniform={readonly name:string;readonly type:'float';readonly value:number;}|{readonly name:string;readonly type:'vec4';readonly value:readonly[number,number,number,number];}|{readonly name:string;readonly type:'mat4';readonly value:readonly number[];};
8
+ /**
9
+ * GLSL ES 3.00 prelude and uniforms for one origin. Prefix your vertex body with `defines` and
10
+ * `vertexPrelude`, then call `lrProjectPosition(vec3)` with tile-local xy and meter z. On a globe,
11
+ * forward `lrHorizonPosition()` through a highp varying and discard fragments where
12
+ * `lrHorizonOccluded()` (from `fragmentPrelude`) returns true.
13
+ */
14
+ export interface LyraMapGeographicShader{readonly key:string;readonly vertexPrelude:string;readonly fragmentPrelude:string;readonly defines:string;readonly positionEncoding:'tile-xy-meters-z';readonly projectFunction:'lrProjectPosition';readonly horizonPositionFunction:'lrHorizonPosition';readonly horizonOccludedFunction:'lrHorizonOccluded';readonly horizonMode:'none'|'sphere';readonly uniforms:readonly LyraMapGeographicUniform[];}
15
+ /** Geographic services that outlive one frame; terrain resolution reads the current view.*/
16
+ export interface LyraMapGeographicServices{readonly limits:Readonly<Record<string,number>>;resolve(position:LyraMapPosition):LyraMapResolvedPosition;
17
+ /** The tile origin nearest the current view for a position.*/
18
+ frameFor(position:LyraMapPosition):LyraMapGeographicOrigin;
19
+ /** Offsets a resolved position by east/north/up meters on the renderer sphere.*/
20
+ fromEnu(origin:Extract<LyraMapResolvedPosition,{status:'resolved';}>,point:readonly[east:number,north:number,up:number]):LyraMapPosition;}
21
+ /** Per-frame geographic transforms; they expire when the render callback returns.*/
22
+ export interface LyraMapGeographicFrame{resolve(position:LyraMapPosition):LyraMapResolvedPosition;project(position:LyraMapPosition):LyraMapProjectedPosition;
23
+ /** Tile-local `[x, y, meters]` for a resolved position in the origin's world copy.*/
24
+ encode(position:LyraMapResolvedPosition,origin:LyraMapGeographicOrigin):readonly[number,number,number];shader(origin:LyraMapGeographicOrigin):LyraMapGeographicShader;}
25
+ /** What a custom layer receives once per mount epoch.*/
26
+ export interface LyraMapCustomLayerContext{
27
+ /** The map's own context: never resize or destroy its canvas or lose the context.*/
28
+ readonly gl:WebGL2RenderingContext;
29
+ /** Aborted when this epoch ends (removal, style replacement, context loss).*/
30
+ readonly signal:AbortSignal;readonly geographic:LyraMapGeographicServices;requestRender():void;reportState(state:'ready'|'loading'|'unavailable',code?:'terrain'|'resource'):void;}
31
+ /** The shared camera for one frame: CSS size, device pixel ratio and geographic transforms.*/
32
+ export interface LyraMapCustomLayerFrame{
33
+ /** View revision; pass it back to reject stale picks.*/
34
+ readonly revision:number;
35
+ /** Monotonic rendering milliseconds.*/
36
+ readonly time:number;readonly width:number;readonly height:number;readonly pixelRatio:number;readonly reducedMotion:boolean;readonly geographic:LyraMapGeographicFrame;}export interface LyraMapCustomLayerPick{readonly id:string;readonly position?:LyraMapPosition;}export interface LyraMapCustomLayerInstance{
37
+ /** Runs before the main pass, for offscreen work.*/
38
+ prerender?(frame:LyraMapCustomLayerFrame):void;render(frame:LyraMapCustomLayerFrame):void;
39
+ /**
40
+ * Releases this instance's GL objects. Runs on removal, style replacement, context loss and map
41
+ * disconnection; after a loss `context.gl.isContextLost()` is true and the objects are already gone.
42
+ */
43
+ dispose():void;
44
+ /** Hit-tests CSS pixel `point` for the frame `revision`; resolve null for no hit.*/
45
+ pick?(point:readonly[x:number,y:number],revision:number):Promise<LyraMapCustomLayerPick|null>;}
46
+ /** A trusted custom WebGL2 layer. `create()` runs once per mount epoch and returns a fresh instance.*/
47
+ export interface LyraMapCustomLayer{
48
+ /** Your identifier, reported as `layerId` when a pick activates.*/
49
+ readonly id:string;
50
+ /** Plain-text name.*/
51
+ readonly label:string;
52
+ /** An existing style layer id to render beneath.*/
53
+ readonly before?:string;create(context:LyraMapCustomLayerContext):LyraMapCustomLayerInstance;}
54
+ /** `removed` is final: `remove()` was called or the map disconnected.*/
55
+ export type LyraMapCustomLayerState='loading'|'ready'|'unavailable'|'removed';export type LyraMapCustomLayerCode='engine'|'render'|'invalid'|'context-lost'|'terrain'|'resource';export interface LyraMapCustomLayerStatus{readonly state:LyraMapCustomLayerState;readonly code?:LyraMapCustomLayerCode;}export interface LyraMapCustomLayerOptions{
56
+ /** Called after every state change.*/
57
+ readonly onStateChange?:(status:LyraMapCustomLayerStatus)=>void;}export interface LyraMapCustomLayerHandle{readonly id:string;
58
+ /** The latest status.*/
59
+ readonly status:LyraMapCustomLayerStatus;requestRender():void;setVisible(visible:boolean):void;
60
+ /** Asks the current instance; resolves null without an installed instance or for a stale view.*/
61
+ pick(point:readonly[x:number,y:number]):Promise<LyraMapCustomLayerPick|null>;
62
+ /** Idempotent. Disposes the instance and removes the native layer.*/
63
+ remove():void;}
@@ -0,0 +1 @@
1
+ import{resolveOptionalPeerCapability}from"./optional-peer-capabilities.js";const handleMethods=["invalidateStyle","styleReady","requestFrame","setVisible","pick","dispose"];function isMapSceneLayerRuntime(value){return typeof value=="object"&&value!==null&&"createSceneLayer"in value&&typeof value.createSceneLayer=="function"}function isMapSceneLayerHandle(value){return typeof value=="object"&&value!==null&&handleMethods.every(name=>typeof Reflect.get(value,name)=="function")}const defaultImporter=()=>import("@aceshooting/lyra-map/scene");let importer=defaultImporter,pending;function loadMapSceneLayerRuntime(){if(pending)return pending;const attempt=importer().then(module=>{const runtime=resolveOptionalPeerCapability(module,isMapSceneLayerRuntime);if(!runtime)throw new TypeError("Map custom layers are unavailable");return runtime});return pending=attempt,attempt.catch(()=>{pending===attempt&&(pending=void 0)}),attempt}function __setMapSceneLayerImporterForTesting(next){importer=next??defaultImporter,pending=void 0}export{__setMapSceneLayerImporterForTesting,isMapSceneLayerHandle,loadMapSceneLayerRuntime};
@@ -1 +1 @@
1
- const LYRA_PACKAGE_NAME="@aceshooting/lyra-ui",LYRA_PACKAGE_VERSION="30.7.0";export{LYRA_PACKAGE_NAME,LYRA_PACKAGE_VERSION};
1
+ const LYRA_PACKAGE_NAME="@aceshooting/lyra-ui",LYRA_PACKAGE_VERSION="30.8.0";export{LYRA_PACKAGE_NAME,LYRA_PACKAGE_VERSION};
@@ -0,0 +1,16 @@
1
+ import type{LyraMapCustomLayer,LyraMapCustomLayerHandle,LyraMapCustomLayerOptions}from'./internal/map-custom-layer-types.js';export type{LyraMapCustomLayer,LyraMapCustomLayerContext,LyraMapCustomLayerFrame,LyraMapCustomLayerInstance,LyraMapCustomLayerPick,LyraMapCustomLayerHandle,LyraMapCustomLayerOptions,LyraMapCustomLayerStatus,LyraMapCustomLayerState,LyraMapCustomLayerCode,LyraMapGeographicServices,LyraMapGeographicFrame,LyraMapGeographicShader,LyraMapGeographicUniform,LyraMapGeographicOrigin,LyraMapResolvedPosition,LyraMapProjectedPosition,}from'./internal/map-custom-layer-types.js';
2
+ /**
3
+ * Adds a trusted custom WebGL2 layer (a beam, coverage cone, cloud or particle effect) to a
4
+ * connected `lr-map` that uses `@aceshooting/lyra-map` or a native engine with the same
5
+ * custom-layer support. Registers no elements; the bridge loads from the optional
6
+ * `@aceshooting/lyra-map/scene` entry on first use.
7
+ *
8
+ * The layer shares the map's WebGL context, camera and depth buffer. `create()` runs for each mount
9
+ * epoch: on first install, after a style replacement and after WebGL context restoration, and the
10
+ * previous instance is disposed first. Positions are degrees with meter altitude above `sea-level`
11
+ * or displayed `terrain`. A pointer click asks `pick()`, and a hit emits `lr-map-scene-activate`
12
+ * with `kind: 'custom'` and `layerId`. Disconnecting the map removes the layer permanently.
13
+ *
14
+ * @throws {TypeError} When `map` is not a connected `lr-map` or the descriptor is malformed.
15
+ */
16
+ export declare function addMapCustomLayer(map:HTMLElement,layer:LyraMapCustomLayer,options?:LyraMapCustomLayerOptions):LyraMapCustomLayerHandle;
@@ -0,0 +1 @@
1
+ import{createMapCustomLayerController}from"./internal/map-custom-layer-controller.js";function addMapCustomLayer(map,layer,options){return createMapCustomLayerController(map,layer,options)}export{addMapCustomLayer};
@@ -9,7 +9,7 @@
9
9
  - **Release history** [CHANGELOG.md](../../CHANGELOG.md)
10
10
  - **Deprecations** none
11
11
  - **Optional peers** none
12
- - **Themeable via** 4 parts, 6 custom properties — see this component's own `@csspart`/`@cssprop` list below
12
+ - **Themeable via** 5 parts, 6 custom properties — see this component's own `@csspart`/`@cssprop` list below
13
13
  - **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`
14
14
 
15
15
  ---
@@ -72,25 +72,39 @@ resolved in the host's owner realm.
72
72
  lost capture, disconnect/adoption, live policy/geometry mutation, no-op attempts, and a prevented
73
73
  `lr-resize-request` all emit nothing.
74
74
  - `lr-toggle-request` (cancelable) and `lr-toggle` (accepted) are the shared disclosure pair;
75
- their fresh frozen details contain `{ expanded }`. The former can veto a built-in toggle
76
- (`preventDefault()` leaves the host `collapsed` property unchanged). Neither is fired when a
77
- consumer assigns `collapsed` directly. Both details are fresh readonly/frozen snapshots.
75
+ their fresh frozen details contain `{ expanded }`. The former can veto the built-in toggle or a
76
+ call to `expand()`, `collapse()` or `toggle()` (`preventDefault()` leaves the host `collapsed`
77
+ property unchanged). Neither is fired when a consumer assigns `collapsed` directly. Both details
78
+ are fresh readonly/frozen snapshots.
79
+
80
+ **Methods:** `expand()`, `collapse()` and `toggle()` drive the fold through that same cancelable
81
+ pair, exactly as the built-in toggle does, so a consumer-owned control (in the content's own header
82
+ row, or a rail item) keeps the panel's disclosure semantics without `collapsible`. `expand()` and
83
+ `toggle()` return whether the panel is expanded afterwards, `collapse()` whether it is collapsed; a
84
+ call that would not change the state emits nothing.
78
85
 
79
86
  Events bubble and are composed, so a listener on an ancestor (for example an `lr-multi-split` that
80
87
  contains this panel and listens for its own `lr-resize-request`) should ignore events whose `target`
81
88
  is not the element it listens on. Keyboard: the arrow keys step by 16px and Home/End jump to the
82
89
  minimum/maximum extent, each through `lr-resize-request`; Alt, Ctrl and Meta chords are left to the
83
- browser. Collapsing while focus is in the content or on the handle moves focus to the collapse toggle.
90
+ browser. Collapsing while focus is in the content or on the handle moves focus to the collapse toggle,
91
+ else to the first focusable `rail` item, else to the host; expanding while focus is on a rail item
92
+ moves it to the toggle or the host, since the rail hides.
84
93
 
85
94
  `lr-resize-input` remains available for live layout feedback; `lr-resize` now provides the shared
86
95
  resize event name. Use `lr-resize-change` for persistence. Type imports move from `DockPanel*` to
87
96
  `LyraDockPanel*`.
88
97
 
89
- **Slots:** default — the panel's own content.
98
+ **Slots:** default — the panel's own content; `rail` — shown in the collapsed rail only while
99
+ `collapsed`, after the toggle, typically one icon button per section (each with its own accessible
100
+ name, usually calling `expand()`); `collapse-icon` and `expand-icon` — decorative glyphs replacing the
101
+ toggle's chevron while expanded and collapsed respectively (for example panel-close and panel-open
102
+ icons). The toggle keeps its localized accessible name, and a slotted glyph is not rotated.
90
103
 
91
104
  **CSS parts:** `base` (the panel root), `content` (wraps the default slot; hidden while `collapsed`),
92
105
  `handle` (the draggable resize edge; only rendered when not `without-resize` and not `collapsed`),
93
- `collapse-toggle` (only rendered when `collapsible`)
106
+ `collapse-toggle` (only rendered when `collapsible`), `rail` (wraps the `rail` slot; hidden unless
107
+ `collapsed`)
94
108
 
95
109
  **Themeable custom properties:** `--lr-dock-panel-collapsed-size` (default
96
110
  `var(--lr-icon-button-size)`) — the persistent "rail" width/height the panel holds at while
@@ -143,7 +157,8 @@ reconciliation emits neither resize event and preserves an in-range authored rel
143
157
  **Known gotchas:**
144
158
 
145
159
  - `collapsed` doesn't zero the panel's box — it shrinks to the persistent rail size
146
- (`--lr-dock-panel-collapsed-size`). `extent` itself is left untouched while collapsed, so
160
+ (`--lr-dock-panel-collapsed-size`). With `rail` items it stacks the toggle and those items (a
161
+ column on `start`/`end`, a row on `top`/`bottom`) and grows past that size to fit them. `extent` itself is left untouched while collapsed, so
147
162
  re-expanding restores what it was unless the current bounds require a valid clamp.
148
163
  - Parent or flex allocation shrink, direct out-of-range property writes, and live min/max changes
149
164
  reconcile atomically. A later container grow does not silently restore an extent that was clamped
@@ -2002,10 +2002,15 @@ linearly between the endpoint altitudes and adds a parabolic rise of `height` me
2002
2002
  `height * 4t(1 - t)`, peaking at the midpoint. Generated vertices carry that altitude as the third
2003
2003
  GeoJSON coordinate.
2004
2004
 
2005
- The map draws lines flat on its displayed surface, so altitude is drawn exactly only when it is
2006
- zero against that surface: `sea-level` without terrain, or `terrain`. A path or arc with any other
2007
- altitude, a nonzero arc `height`, or `sea-level` geometry while terrain is displayed is drawn as its
2008
- ground track, and the scene reports `partial` with code `altitude`. Changing terrain re-evaluates
2005
+ A path or arc at zero altitude against the displayed surface (`sea-level` without terrain, or
2006
+ `terrain`) drapes on the flat line layer. Any other altitude, a nonzero arc `height`, or `sea-level`
2007
+ geometry while terrain is displayed is drawn in 3D at its authored altitude through the custom
2008
+ layer bridge of `@aceshooting/lyra-map/scene` (see [Custom 3D layers](#custom-3d-layers)), which
2009
+ loads on first use. Its screen width stays `width` CSS pixels, depth tests against the map, and
2010
+ globe horizons hide the far side. `terrain` altitude adds displayed terrain height from the engine's
2011
+ elevation query; a segment between a `terrain` and a `sea-level` endpoint blends the two references
2012
+ linearly. When the bridge is not installed, fails to load or fails to render, those lines are drawn
2013
+ as ground tracks and the scene reports `partial` with code `altitude`. Changing terrain re-evaluates
2009
2014
  this. A style replacement reinstalls scene lines after the new style loads; clearing the scene,
2010
2015
  removing every path and arc, or disconnecting the map removes them.
2011
2016
 
@@ -2051,7 +2056,7 @@ rows remain text. Caller labels render as text. Style the surface with `scene-pa
2051
2056
  revision. Accepted empty input and clear report `empty`. Nonempty input reports `loading`, then
2052
2057
  one settled state: `ready` when every object is installed on the map exactly; `partial` with a code
2053
2058
  when some objects are missing or approximated; or `unavailable` with a code when nothing could be
2054
- drawn. Codes are `altitude` (drawn as a ground track), `model` (models are not drawn), `engine` (the
2059
+ drawn. Codes are `altitude` (drawn as a ground track because the 3D bridge is unavailable), `model` (models are not drawn), `engine` (the
2055
2060
  map, its optional scene renderer or a native layer failed), `limit` (generated geometry exceeds the
2056
2061
  vertex limit) and `context-lost` (the WebGL context is lost; drawing resumes on restore). When
2057
2062
  several apply, the most significant is reported in that reverse order, `context-lost` first. A
@@ -2060,9 +2065,10 @@ means installed, not visible: the viewport, terrain and occlusion still apply. R
2060
2065
  reports `error` with `invalid` or `limit` while retaining the previous accepted revision, and
2061
2066
  renderer progress does not replace that report until a new scene is accepted. `loading` and
2062
2067
  `ready` are not announced; `partial` is announced politely and `unavailable`, `empty` and `error`
2063
- assertively. The `scene-status` part shows the current text except when `ready`. `lr-map-scene-activate` emits immutable `{ id, kind, source,
2068
+ assertively. The `scene-status` part shows the current text except when `ready`. `lr-map-scene-activate` emits immutable `{ id, kind, layerId?, source,
2064
2069
  position? }` detail, with `source: 'pointer' | 'keyboard'`; positional marker/model actions include
2065
- the accepted geographic position. Both events bubble, are composed and are noncancelable.
2070
+ the accepted geographic position. A pointer click that a custom 3D layer's `pick()` hits reports
2071
+ `kind: 'custom'`, the hit `id`, the layer's `layerId` and the hit's optional `position`. Both events bubble, are composed and are noncancelable.
2066
2072
 
2067
2073
  ### Declarative globe and terrain configuration
2068
2074
 
@@ -2233,3 +2239,83 @@ support), `'inactive-map'` (disconnected), `'already-bound'` (another session ow
2233
2239
  `'invalid-viewpoint'`, `'invalid-tour'`, `'invalid-follow'`, `'invalid-clock'`,
2234
2240
  `'invalid-options'` or `'disposed'`. Input records must be plain own-data objects; accessors and
2235
2241
  unknown fields are rejected without being read.
2242
+
2243
+ ### Custom 3D layers
2244
+
2245
+ Import `addMapCustomLayer` from `@aceshooting/lyra-ui/map-custom-layers.js` to add a trusted WebGL2
2246
+ effect, such as a beam, coverage cone, cloud or particle system, to a connected `lr-map`. It
2247
+ registers no element; the bridge loads from the optional `@aceshooting/lyra-map/scene` entry on
2248
+ first use, so ordinary `lr-map` imports never load it. Rendering a beam or cone does not compute its
2249
+ physical validity; that stays application logic.
2250
+
2251
+ ```ts
2252
+ import '@aceshooting/lyra-ui/components/lr-map.js';
2253
+ import { addMapCustomLayer, type LyraMapCustomLayer } from '@aceshooting/lyra-ui/map-custom-layers.js';
2254
+
2255
+ const beam: LyraMapCustomLayer = {
2256
+ id: 'uplink-beam', label: 'Uplink beam',
2257
+ create(context) {
2258
+ const { gl } = context; // the map's own WebGL2 context
2259
+ const vao = gl.createVertexArray();
2260
+ let program: WebGLProgram | undefined;
2261
+ return {
2262
+ render(frame) {
2263
+ const top = frame.geographic.resolve({ lngLat: [6.13, 49.61], altitude: 20_000 });
2264
+ if (top.status !== 'resolved') return;
2265
+ const origin = context.geographic.frameFor(top);
2266
+ const shader = frame.geographic.shader(origin); // prelude, defines, uniforms
2267
+ const xyz = frame.geographic.encode(top, origin); // tile-local x, y and meters
2268
+ program ??= compile(gl, shader); // your GLSL body calls lrProjectPosition()
2269
+ upload(gl, program, shader.uniforms, xyz);
2270
+ gl.bindVertexArray(vao); gl.drawArrays(gl.TRIANGLES, 0, 36);
2271
+ },
2272
+ dispose() { if (!gl.isContextLost()) gl.deleteVertexArray(vao); },
2273
+ pick: async ([x, y], revision) => null,
2274
+ };
2275
+ },
2276
+ };
2277
+ const map = document.querySelector('lr-map')!;
2278
+ const layer = addMapCustomLayer(map, beam, { onStateChange: ({ state, code }) => console.log(state, code) });
2279
+ map.addEventListener('lr-map-scene-activate', event => {
2280
+ if (event.detail.kind === 'custom') select(event.detail.layerId, event.detail.id);
2281
+ });
2282
+ layer.remove();
2283
+ ```
2284
+
2285
+ - **Geographic transforms.** Positions are `{ lngLat, altitude?, altitudeReference? }` in degrees
2286
+ and meters. `resolve()` returns meters above sea level; `terrain` adds the displayed terrain
2287
+ height (including exaggeration) from the engine's elevation query, reporting `terrain-pending`
2288
+ until its DEM tile loads and `terrain-unavailable` without terrain. `frameFor()` picks a tile
2289
+ origin in the world copy nearest the view, `encode()` returns tile-local `[x, y, meters]` for it,
2290
+ `fromEnu()` offsets a resolved position by east/north/up meters, and `project()` returns CSS
2291
+ pixel `point` and `visible`. Frame services expire when `render()` returns; keep what `pick()`
2292
+ needs.
2293
+ - **Shared camera.** `shader(origin)` returns GLSL ES 3.00 `defines`, `vertexPrelude`,
2294
+ `fragmentPrelude` and `uniforms` (projection matrices, tile Mercator coordinates, clipping plane,
2295
+ globe transition). Prefix your shaders with them and call `lrProjectPosition(vec3)`. The same code
2296
+ draws in Mercator, globe and the transition between them; on a globe forward
2297
+ `lrHorizonPosition()` and discard where `lrHorizonOccluded()` returns true. The layer draws in
2298
+ the map's 3D pass with its depth buffer and premultiplied alpha blending. `frame` also carries
2299
+ CSS `width`/`height`, `pixelRatio`, `time`, `revision` and the map's `reducedMotion`; stop
2300
+ animation when it is true.
2301
+ - **Lifecycle.** `create()` runs for each mount epoch: on first install, after a `mapStyle`
2302
+ replacement and after WebGL context restoration. The previous instance is disposed first, so
2303
+ allocate GL objects in `create()` or lazily in `render()`. A lost context disposes the instance
2304
+ without GL work (`context.gl.isContextLost()` is true) and reports `unavailable` with
2305
+ `context-lost`; restoration reinstalls it. `remove()` and disconnecting the map dispose it and
2306
+ report the final `removed` state. Never resize the canvas or lose the context yourself.
2307
+ - **Status.** `handle.status` and `onStateChange` report `loading`, `ready` after a completed frame,
2308
+ `unavailable` with `engine` (the optional bridge did not load or the map engine refused the
2309
+ layer), `render` (a callback threw; the layer stays retired until the next style replacement),
2310
+ `invalid`, `context-lost`, or a code the layer reports through `context.reportState()`, and
2311
+ `removed`. `ready` does not assert visible pixels.
2312
+ - **Picking.** A pointer click calls `pick(point, revision)` with CSS pixels; a hit `{ id,
2313
+ position? }` emits `lr-map-scene-activate` with `kind: 'custom'`. `handle.pick(point)` asks
2314
+ directly. Results resolve `null` after the view, epoch or layer changed.
2315
+
2316
+ Both the modular engine and `engine="maplibre"` support the bridge; it needs `@aceshooting/lyra-map`
2317
+ installed. `requestRender()` schedules a frame for animation and `setVisible(false)` skips drawing.
2318
+ The layer descriptor is snapshotted once; `id` and `label` are nonblank strings and `before` names
2319
+ an existing style layer to render beneath. A malformed descriptor or an element that is not a
2320
+ connected `lr-map` throws `TypeError`. Custom layers add no text alternative: describe what they show
2321
+ in the surrounding page or scene list.
package/llms/peers.md CHANGED
@@ -39,8 +39,8 @@ for the page.
39
39
  |---|---|---|
40
40
  | `@aceshooting/lyra-3d` | `^1.2.0` | `lr-chart-3d`, `lr-embedding-explorer`, `lr-graph`, `lr-image-viewer`, `lr-knowledge-graph-explorer`, `lr-model-viewer`, `lr-video` |
41
41
  | `@aceshooting/lyra-flags` | `^2.3.1` | _(loaded by a shared internal module)_ |
42
- | `@aceshooting/lyra-map` | `^1.4.0` | `lr-geojson-viewer`, `lr-map` |
43
- | `@aceshooting/lyra-translations` | `^30.7.0` | _(not referenced by any component)_ |
42
+ | `@aceshooting/lyra-map` | `^1.5.0` | `lr-geojson-viewer`, `lr-map` |
43
+ | `@aceshooting/lyra-translations` | `^30.8.0` | _(not referenced by any component)_ |
44
44
  | `@aiden0z/pptx-renderer` | `^1.4.0` | `lr-pptx-viewer` |
45
45
  | `@sgratzl/chartjs-chart-boxplot` | `^4.0.0` | `lr-box-plot` |
46
46
  | `chart.js` | `^4.0.1` | `lr-bar-chart`, `lr-box-plot`, `lr-bubble-chart`, `lr-chart`, `lr-doughnut-chart`, `lr-histogram`, `lr-line-chart`, `lr-pie-chart`, `lr-polar-area-chart`, `lr-radar-chart`, `lr-scatter-chart` |
@@ -1025,6 +1025,83 @@ signal performs no attachment. Releasing never pauses other consumers.
1025
1025
  and tracking types are `MapCameraSessionSnapshot`, `MapCameraSessionReason`, `MapCameraSessionMode`,
1026
1026
  `MapCameraTrackingStatus` and `MapCameraTrackingIssue`.
1027
1027
 
1028
+ - **`map-custom-layers-contracts`** — Trusted custom WebGL2 layers (beams, coverage cones, clouds,
1029
+ particles) on a connected `lr-map`, sharing its context, camera and depth; see the `lr-map` custom
1030
+ 3D layers section of the media reference. Import: `@aceshooting/lyra-ui/map-custom-layers.js`.
1031
+ `addMapCustomLayer(map: HTMLElement, layer: LyraMapCustomLayer, options?: LyraMapCustomLayerOptions): LyraMapCustomLayerHandle`
1032
+ `LyraMapCustomLayer {
1033
+ readonly id: string;
1034
+ readonly label: string;
1035
+ readonly before?: string;
1036
+ create(context: LyraMapCustomLayerContext): LyraMapCustomLayerInstance;
1037
+ }`
1038
+ `LyraMapCustomLayerContext {
1039
+ readonly gl: WebGL2RenderingContext;
1040
+ readonly signal: AbortSignal;
1041
+ readonly geographic: LyraMapGeographicServices;
1042
+ requestRender(): void;
1043
+ reportState(state: 'ready' | 'loading' | 'unavailable', code?: 'terrain' | 'resource'): void;
1044
+ }`
1045
+ `LyraMapCustomLayerFrame {
1046
+ readonly revision: number;
1047
+ readonly time: number;
1048
+ readonly width: number;
1049
+ readonly height: number;
1050
+ readonly pixelRatio: number;
1051
+ readonly reducedMotion: boolean;
1052
+ readonly geographic: LyraMapGeographicFrame;
1053
+ }`
1054
+ `LyraMapCustomLayerInstance {
1055
+ prerender?(frame: LyraMapCustomLayerFrame): void;
1056
+ render(frame: LyraMapCustomLayerFrame): void;
1057
+ dispose(): void;
1058
+ pick?(point: readonly [x: number, y: number], revision: number): Promise<LyraMapCustomLayerPick | null>;
1059
+ }`
1060
+ `LyraMapCustomLayerPick { readonly id: string; readonly position?: LyraMapPosition; }`
1061
+ `LyraMapCustomLayerOptions { readonly onStateChange?: (status: LyraMapCustomLayerStatus) => void; }`
1062
+ `LyraMapCustomLayerStatus { readonly state: LyraMapCustomLayerState; readonly code?: LyraMapCustomLayerCode; }`
1063
+ `LyraMapCustomLayerHandle {
1064
+ readonly id: string;
1065
+ readonly status: LyraMapCustomLayerStatus;
1066
+ requestRender(): void;
1067
+ setVisible(visible: boolean): void;
1068
+ pick(point: readonly [x: number, y: number]): Promise<LyraMapCustomLayerPick | null>;
1069
+ remove(): void;
1070
+ }`
1071
+ `LyraMapGeographicServices {
1072
+ readonly limits: Readonly<Record<string, number>>;
1073
+ resolve(position: LyraMapPosition): LyraMapResolvedPosition;
1074
+ frameFor(position: LyraMapPosition): LyraMapGeographicOrigin;
1075
+ fromEnu(origin: Extract<LyraMapResolvedPosition, { status: 'resolved' }>, point: readonly [east: number, north: number, up: number]): LyraMapPosition;
1076
+ }`
1077
+ `LyraMapGeographicFrame {
1078
+ resolve(position: LyraMapPosition): LyraMapResolvedPosition;
1079
+ project(position: LyraMapPosition): LyraMapProjectedPosition;
1080
+ encode(position: LyraMapResolvedPosition, origin: LyraMapGeographicOrigin): readonly [number, number, number];
1081
+ shader(origin: LyraMapGeographicOrigin): LyraMapGeographicShader;
1082
+ }`
1083
+ `LyraMapGeographicOrigin { readonly tile: { readonly z: number; readonly x: number; readonly y: number; readonly wrap: number }; readonly key: string; }`
1084
+ `LyraMapProjectedPosition {
1085
+ readonly point?: readonly [number, number];
1086
+ readonly visible: boolean;
1087
+ readonly status: 'resolved' | 'terrain-pending' | 'terrain-unavailable' | 'visibility-pending' | 'clipped' | 'occluded';
1088
+ }`
1089
+ `LyraMapGeographicShader {
1090
+ readonly key: string;
1091
+ readonly vertexPrelude: string;
1092
+ readonly fragmentPrelude: string;
1093
+ readonly defines: string;
1094
+ readonly positionEncoding: 'tile-xy-meters-z';
1095
+ readonly projectFunction: 'lrProjectPosition';
1096
+ readonly horizonPositionFunction: 'lrHorizonPosition';
1097
+ readonly horizonOccludedFunction: 'lrHorizonOccluded';
1098
+ readonly horizonMode: 'none' | 'sphere';
1099
+ readonly uniforms: readonly LyraMapGeographicUniform[];
1100
+ }`
1101
+ `LyraMapGeographicUniform`, `LyraMapResolvedPosition`, `LyraMapCustomLayerState`
1102
+ (`'loading' | 'ready' | 'unavailable' | 'removed'`) and `LyraMapCustomLayerCode`
1103
+ (`'engine' | 'render' | 'invalid' | 'context-lost' | 'terrain' | 'resource'`) complete the types.
1104
+
1028
1105
  ## Reference artifacts
1029
1106
 
1030
1107
  The package includes authored family and shared references plus derived index, component, token,
package/llms/shared.md CHANGED
@@ -4261,6 +4261,83 @@ signal performs no attachment. Releasing never pauses other consumers.
4261
4261
  and tracking types are `MapCameraSessionSnapshot`, `MapCameraSessionReason`, `MapCameraSessionMode`,
4262
4262
  `MapCameraTrackingStatus` and `MapCameraTrackingIssue`.
4263
4263
 
4264
+ - **`map-custom-layers-contracts`** — Trusted custom WebGL2 layers (beams, coverage cones, clouds,
4265
+ particles) on a connected `lr-map`, sharing its context, camera and depth; see the `lr-map` custom
4266
+ 3D layers section of the media reference. Import: `@aceshooting/lyra-ui/map-custom-layers.js`.
4267
+ `addMapCustomLayer(map: HTMLElement, layer: LyraMapCustomLayer, options?: LyraMapCustomLayerOptions): LyraMapCustomLayerHandle`
4268
+ `LyraMapCustomLayer {
4269
+ readonly id: string;
4270
+ readonly label: string;
4271
+ readonly before?: string;
4272
+ create(context: LyraMapCustomLayerContext): LyraMapCustomLayerInstance;
4273
+ }`
4274
+ `LyraMapCustomLayerContext {
4275
+ readonly gl: WebGL2RenderingContext;
4276
+ readonly signal: AbortSignal;
4277
+ readonly geographic: LyraMapGeographicServices;
4278
+ requestRender(): void;
4279
+ reportState(state: 'ready' | 'loading' | 'unavailable', code?: 'terrain' | 'resource'): void;
4280
+ }`
4281
+ `LyraMapCustomLayerFrame {
4282
+ readonly revision: number;
4283
+ readonly time: number;
4284
+ readonly width: number;
4285
+ readonly height: number;
4286
+ readonly pixelRatio: number;
4287
+ readonly reducedMotion: boolean;
4288
+ readonly geographic: LyraMapGeographicFrame;
4289
+ }`
4290
+ `LyraMapCustomLayerInstance {
4291
+ prerender?(frame: LyraMapCustomLayerFrame): void;
4292
+ render(frame: LyraMapCustomLayerFrame): void;
4293
+ dispose(): void;
4294
+ pick?(point: readonly [x: number, y: number], revision: number): Promise<LyraMapCustomLayerPick | null>;
4295
+ }`
4296
+ `LyraMapCustomLayerPick { readonly id: string; readonly position?: LyraMapPosition; }`
4297
+ `LyraMapCustomLayerOptions { readonly onStateChange?: (status: LyraMapCustomLayerStatus) => void; }`
4298
+ `LyraMapCustomLayerStatus { readonly state: LyraMapCustomLayerState; readonly code?: LyraMapCustomLayerCode; }`
4299
+ `LyraMapCustomLayerHandle {
4300
+ readonly id: string;
4301
+ readonly status: LyraMapCustomLayerStatus;
4302
+ requestRender(): void;
4303
+ setVisible(visible: boolean): void;
4304
+ pick(point: readonly [x: number, y: number]): Promise<LyraMapCustomLayerPick | null>;
4305
+ remove(): void;
4306
+ }`
4307
+ `LyraMapGeographicServices {
4308
+ readonly limits: Readonly<Record<string, number>>;
4309
+ resolve(position: LyraMapPosition): LyraMapResolvedPosition;
4310
+ frameFor(position: LyraMapPosition): LyraMapGeographicOrigin;
4311
+ fromEnu(origin: Extract<LyraMapResolvedPosition, { status: 'resolved' }>, point: readonly [east: number, north: number, up: number]): LyraMapPosition;
4312
+ }`
4313
+ `LyraMapGeographicFrame {
4314
+ resolve(position: LyraMapPosition): LyraMapResolvedPosition;
4315
+ project(position: LyraMapPosition): LyraMapProjectedPosition;
4316
+ encode(position: LyraMapResolvedPosition, origin: LyraMapGeographicOrigin): readonly [number, number, number];
4317
+ shader(origin: LyraMapGeographicOrigin): LyraMapGeographicShader;
4318
+ }`
4319
+ `LyraMapGeographicOrigin { readonly tile: { readonly z: number; readonly x: number; readonly y: number; readonly wrap: number }; readonly key: string; }`
4320
+ `LyraMapProjectedPosition {
4321
+ readonly point?: readonly [number, number];
4322
+ readonly visible: boolean;
4323
+ readonly status: 'resolved' | 'terrain-pending' | 'terrain-unavailable' | 'visibility-pending' | 'clipped' | 'occluded';
4324
+ }`
4325
+ `LyraMapGeographicShader {
4326
+ readonly key: string;
4327
+ readonly vertexPrelude: string;
4328
+ readonly fragmentPrelude: string;
4329
+ readonly defines: string;
4330
+ readonly positionEncoding: 'tile-xy-meters-z';
4331
+ readonly projectFunction: 'lrProjectPosition';
4332
+ readonly horizonPositionFunction: 'lrHorizonPosition';
4333
+ readonly horizonOccludedFunction: 'lrHorizonOccluded';
4334
+ readonly horizonMode: 'none' | 'sphere';
4335
+ readonly uniforms: readonly LyraMapGeographicUniform[];
4336
+ }`
4337
+ `LyraMapGeographicUniform`, `LyraMapResolvedPosition`, `LyraMapCustomLayerState`
4338
+ (`'loading' | 'ready' | 'unavailable' | 'removed'`) and `LyraMapCustomLayerCode`
4339
+ (`'engine' | 'render' | 'invalid' | 'context-lost' | 'terrain' | 'resource'`) complete the types.
4340
+
4264
4341
  ## Reference artifacts
4265
4342
 
4266
4343
  The package includes authored family and shared references plus derived index, component, token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aceshooting/lyra-ui",
3
- "version": "30.7.0",
3
+ "version": "30.8.0",
4
4
  "description": "Free, independent Lit web components: an open-source alternative to Shoelace and Web Awesome with accessible forms, dashboards, charts, and agent UI.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -1880,6 +1880,10 @@
1880
1880
  "types": "./dist/map-camera-session.d.ts",
1881
1881
  "default": "./dist/map-camera-session.js"
1882
1882
  },
1883
+ "./map-custom-layers.js": {
1884
+ "types": "./dist/map-custom-layers.d.ts",
1885
+ "default": "./dist/map-custom-layers.js"
1886
+ },
1883
1887
  "./theme/presets.js": null,
1884
1888
  "./theme/presets/shadcn.js": null
1885
1889
  },
@@ -2646,8 +2650,8 @@
2646
2650
  "peerDependencies": {
2647
2651
  "@aceshooting/lyra-3d": "^1.2.0",
2648
2652
  "@aceshooting/lyra-flags": "^2.3.1",
2649
- "@aceshooting/lyra-map": "^1.4.0",
2650
- "@aceshooting/lyra-translations": "^30.7.0",
2653
+ "@aceshooting/lyra-map": "^1.5.0",
2654
+ "@aceshooting/lyra-translations": "^30.8.0",
2651
2655
  "@aiden0z/pptx-renderer": "^1.4.0",
2652
2656
  "@sgratzl/chartjs-chart-boxplot": "^4.0.0",
2653
2657
  "chart.js": "^4.0.1",
@@ -2778,7 +2782,7 @@
2778
2782
  "devDependencies": {
2779
2783
  "@aceshooting/lyra-3d": "1.2.0",
2780
2784
  "@aceshooting/lyra-flags": "^2.3.1",
2781
- "@aceshooting/lyra-map": "1.4.0",
2785
+ "@aceshooting/lyra-map": "1.5.0",
2782
2786
  "@aiden0z/pptx-renderer": "^1.4.0",
2783
2787
  "@codecov/bundle-analyzer": "^2.0.1",
2784
2788
  "@custom-elements-manifest/analyzer": "^0.11.0",