Shared type expressions
Shared type expressions (08.5)
Supports MapLibre-style boolean/number/string/object assertions with ordered candidates, array item-type/length assertions, typeof,properties and get/has with optional objects and string-name expressions. Syntax follows the official expression reference; the shared Rust evaluator is independently implemented without the MapLibre runtime.
map.setPaintProperty('places-layer','circle-color',
['case',['boolean',['feature-state','selected'],false],'#ff00ff','#0000ff']);
map.setPaintProperty('places-layer','circle-radius',
['number',['get','height',['object',['literal',{height:18}]]],6]);
await map.sqs.flush({render:true});
Assertions do not coerce numeric strings. They select the first candidate of the requested type and short-circuit later evaluation; failure uses existing paint defaults/warnings or explicit query-filter errors. array supports value,type/value,type/length/value forms with string/number/boolean item types and nonnegative integer lengths up to65536. Array typeof results include item type/length, e.g.array<number, 2>; mixed items use value. get returns null for missing keys,has distinguishes missing from present null,and invalid object inputs fail explicitly.
This describes JSON types; collator,format/image-specific values,remaining expressions stay in subsequent tasks. Existing node/depth,source and display budgets apply; feature-state is paint-only. GeoJSON/shared MVT use identical semantics; setStyle(URL) basemaps retain their separate expression scope. The complete HTML and portable script include selection,ordering,views,queries,credits and disposal.
Variable scope (08.6)
Shared paint,filter and query expressions support let/var. Variables are visible in the let result; inner bindings shadow outer ones. Binding values resolve only enclosing-scope variables. Bindings evaluate on demand,so unused runtime errors do not execute. Names use nonempty ASCII letters/digits/underscores,up to256 bytes. Unbound names and invalid structures reject before mutation.
map.setPaintProperty('places-layer','circle-color',
['let','selected',['boolean',['feature-state','selected'],false],
['case',['var','selected'],'#ff00ff','#0000ff']]);
map.setPaintProperty('places-layer','circle-radius',
['let','large',18,['step',['zoom'],6,4,['var','large']]]);
await map.sqs.flush({render:true});
Camera zoom may drive a terminal step/interpolate inside outer let expressions; it cannot appear in binding values or other positions. Shared layers continue reevaluating actual zoom. Each evaluation permits8192 steps/64 levels; AST limits remain1024 nodes/32 levels. Budget failures use existing paint defaults/warnings; layer/query filters report RESOURCE_LIMIT and mutations leave no partial layer/reference.
The complete HTML and portable script include all buttons,credits and cleanup through native and real WASM main-thread/strict Worker. Implementation is independent against the public expression specification,without MapLibre code. Remaining operators and complete layer types continue in tasks.