meshai/work/dashboard-frontend/node_modules/js-tokens
malice 2c46c9104d
feat(region-routing): unified per-family routing cards + region-scoped family→channel routing (#87)
* 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>
2026-07-07 16:52:03 -06:00
..
CHANGELOG.md feat(region-routing): unified per-family routing cards + region-scoped family→channel routing (#87) 2026-07-07 16:52:03 -06:00
index.js feat(region-routing): unified per-family routing cards + region-scoped family→channel routing (#87) 2026-07-07 16:52:03 -06:00
LICENSE feat(region-routing): unified per-family routing cards + region-scoped family→channel routing (#87) 2026-07-07 16:52:03 -06:00
package.json feat(region-routing): unified per-family routing cards + region-scoped family→channel routing (#87) 2026-07-07 16:52:03 -06:00
README.md feat(region-routing): unified per-family routing cards + region-scoped family→channel routing (#87) 2026-07-07 16:52:03 -06:00

Overview Build Status

A regex that tokenizes JavaScript.

var jsTokens = require("js-tokens").default

var jsString = "var foo=opts.foo;\n..."

jsString.match(jsTokens)
// ["var", " ", "foo", "=", "opts", ".", "foo", ";", "\n", ...]

Installation

npm install js-tokens

import jsTokens from "js-tokens"
// or:
var jsTokens = require("js-tokens").default

Usage

jsTokens

A regex with the g flag that matches JavaScript tokens.

The regex always matches, even invalid JavaScript and the empty string.

The next match is always directly after the previous.

var token = matchToToken(match)

import {matchToToken} from "js-tokens"
// or:
var matchToToken = require("js-tokens").matchToToken

Takes a match returned by jsTokens.exec(string), and returns a {type: String, value: String} object. The following types are available:

  • string
  • comment
  • regex
  • number
  • name
  • punctuator
  • whitespace
  • invalid

Multi-line comments and strings also have a closed property indicating if the token was closed or not (see below).

Comments and strings both come in several flavors. To distinguish them, check if the token starts with //, /*, ', " or `.

Names are ECMAScript IdentifierNames, that is, including both identifiers and keywords. You may use is-keyword-js to tell them apart.

Whitespace includes both line terminators and other whitespace.

ECMAScript support

The intention is to always support the latest ECMAScript version whose feature set has been finalized.

If adding support for a newer version requires changes, a new version with a major verion bump will be released.

Currently, ECMAScript 2018 is supported.

Invalid code handling

Unterminated strings are still matched as strings. JavaScript strings cannot contain (unescaped) newlines, so unterminated strings simply end at the end of the line. Unterminated template strings can contain unescaped newlines, though, so they go on to the end of input.

Unterminated multi-line comments are also still matched as comments. They simply go on to the end of the input.

Unterminated regex literals are likely matched as division and whatever is inside the regex.

Invalid ASCII characters have their own capturing group.

Invalid non-ASCII characters are treated as names, to simplify the matching of names (except unicode spaces which are treated as whitespace). Note: See also the ES2018 section.

Regex literals may contain invalid regex syntax. They are still matched as regex literals. They may also contain repeated regex flags, to keep the regex simple.

Strings may contain invalid escape sequences.

Limitations

Tokenizing JavaScript using regexes—in fact, one single regex—wont be perfect. But thats not the point either.

You may compare jsTokens with esprima by using esprima-compare.js. See npm run esprima-compare!

Template string interpolation

Template strings are matched as single tokens, from the starting ` to the ending `, including interpolations (whose tokens are not matched individually).

Matching template string interpolations requires recursive balancing of { and }—something that JavaScript regexes cannot do. Only one level of nesting is supported.

Division and regex literals collision

Consider this example:

var g = 9.82
var number = bar / 2/g

var regex = / 2/g

A human can easily understand that in the number line were dealing with division, and in the regex line were dealing with a regex literal. How come? Because humans can look at the whole code to put the / characters in context. A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also look backwards. See the ES2018 section).

When the jsTokens regex scans throught the above, it will see the following at the end of both the number and regex rows:

/ 2/g

It is then impossible to know if that is a regex literal, or part of an expression dealing with division.

Here is a similar case:

foo /= 2/g
foo(/= 2/g)

The first line divides the foo variable with 2/g. The second line calls the foo function with the regex literal /= 2/g. Again, since jsTokens only sees forwards, it cannot tell the two cases apart.

There are some cases where we can tell division and regex literals apart, though.

First off, we have the simple cases where theres only one slash in the line:

var foo = 2/g
foo /= 2

Regex literals cannot contain newlines, so the above cases are correctly identified as division. Things are only problematic when there are more than one non-comment slash in a single line.

Secondly, not every character is a valid regex flag.

var number = bar / 2/e

The above example is also correctly identified as division, because e is not a valid regex flag. I initially wanted to future-proof by allowing [a-zA-Z]* (any letter) as flags, but it is not worth it since it increases the amount of ambigous cases. So only the standard g, m, i, y and u flags are allowed. This means that the above example will be identified as division as long as you dont rename the e variable to some permutation of gmiyus 1 to 6 characters long.

Lastly, we can look forward for information.

  • If the token following what looks like a regex literal is not valid after a regex literal, but is valid in a division expression, then the regex literal is treated as division instead. For example, a flagless regex cannot be followed by a string, number or name, but all of those three can be the denominator of a division.
  • Generally, if what looks like a regex literal is followed by an operator, the regex literal is treated as division instead. This is because regexes are seldomly used with operators (such as +, *, && and ==), but division could likely be part of such an expression.

Please consult the regex source and the test cases for precise information on when regex or division is matched (should you need to know). In short, you could sum it up as:

If the end of a statement looks like a regex literal (even if it isnt), it will be treated as one. Otherwise it should work as expected (if you write sane code).

ES2018

ES2018 added some nice regex improvements to the language.

These things would be nice to do, but are not critical. They probably have to wait until the oldest maintained Node.js LTS release supports those features.

License

MIT.