Global style state
Shared scripts and the SDK expose getGlobalState(), chainable setGlobalStateProperty(name,value), and ['global-state',name]. Reads are asynchronous detached snapshots; script snapshots are deeply frozen. Use view.flush() in the raw SDK and map.sqs.flush() in scripts.
map.setGlobalStateProperty('themeColor', '#2879ff');
const state = await map.getGlobalState();
map.setPaintProperty('places', 'circle-color', ['global-state', 'themeColor']);
await map.sqs.flush({ render: true });
map.setGlobalStateProperty('themeColor', null);
Inline styles can declare state:{themeColor:{default:'#2879ff'}}. Each declaration accepts only default. Undeclared keys can also be written. null restores the style default or removes an undeclared key; missing expression keys evaluate to null. Use coalesce or type assertions for fallback values. Replacing the entire style reloads its defaults and clears previous global state.
Updates refresh shared paint/filter, text layout and backgrounds without replacing source data or source/layer identity. Source and rendered query filters read current state. getStyle retains expressions and declared defaults, rather than serializing runtime overrides. The existing sqs.sourceschange notification can trigger a state read; no dedicated state event is added here.
Limits: 128 keys per map, 1..256 UTF-8 bytes per key, 64KiB/8192 nodes/16 levels in values. Script argument capture additionally limits each value to 2048 nodes. Invalid values or resulting styles fail candidate validation without committing. clusterProperties rejects global-state to avoid stale aggregation. Legacy GIS CPU attribute painting must use shared layers for this feature. The independent URL basemap compiler does not yet support this expression; this is a shared-layer subset.
map.sqs.getCapabilities() reports globalState. Embedded native-library QuickJS and browser main-thread/Worker use the same method names and portable script. Acceptance script. Application mobile integration, devices and formal release remain separate acceptance work.