* feat(region-routing): P1 tagging + region_routes primitive + read/write API + preview launcher - config.py: add Coverage.region_tagging (bool=False); add RegionRouteMatrix dataclass (enabled, cells) above NotificationsConfig; add region_routes field to NotificationsConfig; add explicit hydration branch for region_routes in _dict_to_dataclass mirroring destinations pattern. - coverage_area.py: add MonitoringArea.name (str|None=None, frozen); update areas_from_config to preserve name; refactor inline geom extraction from classify_event_areas into shared _event_geom_json helper; add matching_area_names(geom_json, areas)->list[str] (additive, all named matches, config-order, deduped; gate unchanged); add event_region_names convenience wrapper. - coverage_filter.py: add region_tagging ctor kwarg; stamp event.region/ regions before the gate when region_tagging=True and areas non-empty and not event.regions (never clobbers satpass preset). - pipeline/__init__.py: wire region_tagging into CoverageFilter construction. - notification_routes.py: add GET /notifications/regions (named coverage area names, config-order, deduped); GET /notifications/region-routing (matrix as JSON); POST /notifications/region-routing (explicit RMW — only region_routes changes, toggles/rules/destinations survive). - scripts/preview_dashboard.py: mesh-free launcher — dashboard API only, no mesh connector, no broadcast loop; vite runs separately. All 87 coverage tests pass; 300 total pass; 6 pre-existing failures unchanged (adapter config count mismatch + MeshCore EventType.NEW_CONTACT). * feat(region-routing): manual region x family matrix editor page Adds RegionRoutingMatrix.tsx — a plain editor over the region_routes config primitive. Rows = families (via useFamilies()), cols = regions (from GET /api/notifications/regions). Each cell exposes MT channel (ChannelPicker single + includeDisabled), MC channel name (text input), min_severity select (routine/priority/critical/immediate), and an enabled checkbox. Only cells where MT or MC is set are included in the sparse POST payload. Master enable toggle maps to top-level enabled. MT budget guard warns when more than 7 distinct MT indices are in use. Sticky family column; horizontal scroll for wide region sets. Registers route /region-routing in App.tsx and adds "Region Routing" nav entry (Map icon) under the Meshtastic section in Layout.tsx, immediately after Routing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(region-routing): regions endpoint reads saved (disk) coverage so routing columns are dynamic without a bot restart; preview reloads config after writes * feat(routing): unify MT/MC routing into per-family cards; region routing as an in-card expand; remove rules/destinations UI + standalone page * refactor(routing): move Meshtastic Routing from /notifications to /meshtastic/routing (mirror /meshcore/routing); redirect legacy path * feat(region-routing): dispatcher honors region_routes matrix (authoritative-on-match, per-region cooldown, per-channel dedup); non-matrix path unchanged Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(region-routing): matrix dedup key must match boot-restore 2-tuple form (prevents restart re-broadcast flood); regression test --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| index.js | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
lru cache
A cache object that deletes the least-recently-used items.
Installation:
npm install lru-cache --save
Usage:
var LRU = require("lru-cache")
, options = { max: 500
, length: function (n, key) { return n * 2 + key.length }
, dispose: function (key, n) { n.close() }
, maxAge: 1000 * 60 * 60 }
, cache = new LRU(options)
, otherCache = new LRU(50) // sets just the max size
cache.set("key", "value")
cache.get("key") // "value"
// non-string keys ARE fully supported
// but note that it must be THE SAME object, not
// just a JSON-equivalent object.
var someObject = { a: 1 }
cache.set(someObject, 'a value')
// Object keys are not toString()-ed
cache.set('[object Object]', 'a different value')
assert.equal(cache.get(someObject), 'a value')
// A similar object with same keys/values won't work,
// because it's a different object identity
assert.equal(cache.get({ a: 1 }), undefined)
cache.reset() // empty the cache
If you put more stuff in it, then items will fall out.
If you try to put an oversized thing in it, then it'll fall out right away.
Options
maxThe maximum size of the cache, checked by applying the length function to all values in the cache. Not setting this is kind of silly, since that's the whole purpose of this lib, but it defaults toInfinity. Setting it to a non-number or negative number will throw aTypeError. Setting it to 0 makes it beInfinity.maxAgeMaximum age in ms. Items are not pro-actively pruned out as they age, but if you try to get an item that is too old, it'll drop it and return undefined instead of giving it to you. Setting this to a negative value will make everything seem old! Setting it to a non-number will throw aTypeError.lengthFunction that is used to calculate the length of stored items. If you're storing strings or buffers, then you probably want to do something likefunction(n, key){return n.length}. The default isfunction(){return 1}, which is fine if you want to storemaxlike-sized things. The item is passed as the first argument, and the key is passed as the second argumnet.disposeFunction that is called on items when they are dropped from the cache. This can be handy if you want to close file descriptors or do other cleanup tasks when items are no longer accessible. Called withkey, value. It's called before actually removing the item from the internal cache, so if you want to immediately put it back in, you'll have to do that in anextTickorsetTimeoutcallback or it won't do anything.staleBy default, if you set amaxAge, it'll only actually pull stale items out of the cache when youget(key). (That is, it's not pre-emptively doing asetTimeoutor anything.) If you setstale:true, it'll return the stale value before deleting it. If you don't set this, then it'll returnundefinedwhen you try to get a stale entry, as if it had already been deleted.noDisposeOnSetBy default, if you set adispose()method, then it'll be called whenever aset()operation overwrites an existing key. If you set this option,dispose()will only be called when a key falls out of the cache, not when it is overwritten.updateAgeOnGetWhen using time-expiring entries withmaxAge, setting this totruewill make each item's effective time update to the current time whenever it is retrieved from cache, causing it to not expire. (It can still fall out of cache based on recency of use, of course.)
API
-
set(key, value, maxAge) -
get(key) => valueBoth of these will update the "recently used"-ness of the key. They do what you think.
maxAgeis optional and overrides the cachemaxAgeoption if provided.If the key is not found,
get()will returnundefined.The key and val can be any value.
-
peek(key)Returns the key value (or
undefinedif not found) without updating the "recently used"-ness of the key.(If you find yourself using this a lot, you might be using the wrong sort of data structure, but there are some use cases where it's handy.)
-
del(key)Deletes a key out of the cache.
-
reset()Clear the cache entirely, throwing away all values.
-
has(key)Check if a key is in the cache, without updating the recent-ness or deleting it for being stale.
-
forEach(function(value,key,cache), [thisp])Just like
Array.prototype.forEach. Iterates over all the keys in the cache, in order of recent-ness. (Ie, more recently used items are iterated over first.) -
rforEach(function(value,key,cache), [thisp])The same as
cache.forEach(...)but items are iterated over in reverse order. (ie, less recently used items are iterated over first.) -
keys()Return an array of the keys in the cache.
-
values()Return an array of the values in the cache.
-
lengthReturn total length of objects in cache taking into account
lengthoptions function. -
itemCountReturn total quantity of objects currently in cache. Note, that
stale(see options) items are returned as part of this item count. -
dump()Return an array of the cache entries ready for serialization and usage with 'destinationCache.load(arr)`.
-
load(cacheEntriesArray)Loads another cache entries array, obtained with
sourceCache.dump(), into the cache. The destination cache is reset before loading new entries -
prune()Manually iterates over the entire cache proactively pruning old entries