mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d15c69a8ae | ||
|
|
2a4079e9f8 | ||
|
|
200c788ac1 | ||
|
|
35049fd7f7 | ||
|
|
8885177e2e |
No files matched your search
@@ -1,5 +0,0 @@
|
||||
- The fire layer takes a stand-in for its markers (`setMarkerStandIn`), for an
|
||||
application that draws the same detections another way: the markers,
|
||||
heatmap and ambient cards hide, and a click on a fire the application draws
|
||||
selects it and moves the camera to it, with its card, as a click on its
|
||||
marker does (samehkhamis, #1828).
|
||||
@@ -0,0 +1,7 @@
|
||||
- More private text typed into the Omnibar or Location search stays off the
|
||||
place service: emails spelled out or spaced, IP addresses, wallet recovery
|
||||
phrases, door, alarm and lockbox numbers, codes after their labels,
|
||||
document and ID numbers, SSNs, more API token shapes and codes in links.
|
||||
More real places get through: "Boise ID 83702", house numbers in the
|
||||
order their country writes them, addresses of up to ten words, and long
|
||||
questions for Ask GEV (manjunath22466, samehkhamis, #1830).
|
||||
@@ -1,7 +0,0 @@
|
||||
- The Omnibar reads more lines the way they are meant: a country named with
|
||||
"and" stays whole ("flights near Trinidad and Tobago"), places show as they
|
||||
were typed, "hide everything except flights" switches off every other
|
||||
layer that is on, "remove flights from the map" and a doubled verb are
|
||||
understood, a grid reference after "near" is the place, and a layer word
|
||||
that begins a name ("Fire Island") no longer offers a plan to the rest of
|
||||
it (manjunath22466, samehkhamis, #1831).
|
||||
+61
-26
@@ -7970,12 +7970,7 @@ over").
|
||||
Otherwise the place row is the default and moves first ("Thermal,
|
||||
California", "radio near tokyo" searches Tokyo), and any plan or command is
|
||||
offered after it; a line with neither ("hi", "NY", "?") runs nothing. "hide everything near tokyo" clears the layers and flies to
|
||||
Tokyo. "hide everything except flights" (or "all but", "other than", with
|
||||
"turn off", "clear" or "remove") switches off every layer that is on but
|
||||
the ones named, or says no other layers are on. "remove flights from the
|
||||
map" is "remove flights", a doubled verb ("hide hide everything") is read
|
||||
once, and a grid reference after "near" is the place ("flights near 14R PU
|
||||
2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a
|
||||
Tokyo. Following needs a callsign or ICAO address (letters and a digit), a
|
||||
nine-digit MMSI or the name of something loaded on the map, so "Track
|
||||
Hill" and "Track 29" are places; "nearest plane" counts alone or before a
|
||||
place ("Nearest Plane Crash Site" is a name), and "goto" only with a place
|
||||
@@ -8003,10 +7998,7 @@ noir", "go to London with flights"), a switch and a layer ("go to tokyo show
|
||||
flights"), or a comma part that is exactly a style, map, camera move or
|
||||
layer ("go to Tokyo, north up"). A line with one keyword and no verb beside
|
||||
the rest of a name ("Tilt Cove", "tokyo traffic", "Hurricane, Utah") offers
|
||||
the whole line as a place first and the plan second. When that keyword
|
||||
starts the line with no comma after it ("Fire Island", "Radio City Music
|
||||
Hall"), it begins the name: the place and the layer are offered, and no
|
||||
plan goes to the rest of the name. Further places joined
|
||||
the whole line as a place first and the plan second. Further places joined
|
||||
with "and" are offered as their own rows. Things loaded on the map that
|
||||
match the line are offered too: a callsign, tail number or transponder
|
||||
code puts them first, and otherwise the place row keeps the top, so
|
||||
@@ -8034,10 +8026,13 @@ while the tab is hidden.
|
||||
A place search on its own runs through Location and shares its cancellation
|
||||
and errors, keeping the separate Location draft intact.
|
||||
|
||||
While typing, a short line (six words or fewer, no `?`, not a command,
|
||||
While typing, a short line (six words or fewer, ten with a number in it
|
||||
as an address has, no `?`, not a command,
|
||||
coordinates, a hex code, a callsign such as UAL2110 or N123AB, and nothing
|
||||
that may be private) is sent to
|
||||
Photon for place suggestions: at most one request every 500 ms per tab,
|
||||
Photon for place suggestions (the suggester itself never sends a line of
|
||||
more than eight words, or ten with a number): at most one request every
|
||||
500 ms per tab,
|
||||
and none for a minute after a refusal. Photon is the keyless geocoder the
|
||||
place search already uses; a submitted search is not part of this spacing.
|
||||
A line that may be one name ("Satellite Beach") is looked up whole. While
|
||||
@@ -8051,49 +8046,89 @@ digits and "@" count, and digits of any script count as digits. It is
|
||||
any line with: an "@" with something right on both sides, ending a word,
|
||||
starting a lowercase handle ("@jdoe"), or spaced before a domain ("john @
|
||||
gmail.com") (an email address or a handle, also while it is typed; spaced, as in "Nanjampeta @
|
||||
Chandambylu", it is part of a name); seven digits or more with nothing but spaces,
|
||||
Chandambylu", it is part of a name); an email spelled around a filter
|
||||
("john(at)gmail.com", "john[at]gmail[dot]com", "john at gmail dot de",
|
||||
"john at gmail.com", "john at gmail (dot) com"); an IP address
|
||||
("10.0.0.1", "::1", "fe80::1", "https://[::1]/"); a wallet's recovery
|
||||
phrase (see below); seven digits or more with nothing but spaces,
|
||||
punctuation, symbols or format characters between them (a phone, card,
|
||||
SSN or account number or its start: "+1 415 555", "4111 1111", "123 45
|
||||
6789", "123456789", "4111.1111.1111.1111", "123–45–6789"; a street address's house number
|
||||
and its postcode are read apart: five digits, or between the street and
|
||||
and its postcode are read apart (a house number never starts with 0, and
|
||||
a polite word such as "thanks" after the digits is not a city): five digits, or between the street and
|
||||
the city "00-950", "111 21", "125009", "1100-053", or four digits after a
|
||||
comma ("Straße 120, 1070 Wien"); and so are a US ZIP+4 after a word,
|
||||
a Brazilian CEP, a Japanese postcode after "〒" or before the address, and
|
||||
comma ("Straße 120, 1070 Wien"); and so are a US ZIP+4 after a state's
|
||||
code or name ("Alice 12345-6789" and "Jo 12345-6789" stay private),
|
||||
a Brazilian CEP, a Japanese postcode after "〒" or next to the address in
|
||||
Japanese script ("東京都千代田区100-0001"; after a Latin name, as in
|
||||
"Shibuya 150-0002", it reads as a phone number), and
|
||||
digits on either side of "#", so "Hauptstrasse 12 10115 Berlin", "DC
|
||||
20500-0003", "〒100-0001 東京都千代田区" and "Calle 100 # 19-61" are places,
|
||||
while a seven-digit postcode alone such as "Tel Aviv 6100000" still reads
|
||||
as private); a phone number written with dots; two letters, two
|
||||
digits and ten more letters or digits (an IBAN's shape); "password",
|
||||
"passcode", "passwd", "ssn", "pw", "pwd" or "bearer" followed by anything,
|
||||
"token", "secret", "api key", "key" or "pass" followed by ":" or "=", a
|
||||
"passcode", "passwd", "pw" or "pwd" followed by anything, "bearer"
|
||||
followed by anything but a short capitalised name or a place word such as
|
||||
island or lake ("Bearer Island", "bearer island" are places),
|
||||
"ssn" followed by a digit ("SSN Station" is a place), "token", "secret",
|
||||
"api key", "key" or "pass" followed by ":" or "=", a licence, plate,
|
||||
passport, membership, account, policy, ticket, booking, confirmation or
|
||||
reference number with a digit after its label ("license ABC1234",
|
||||
"passport no. 123456"), "ID" in capitals followed by a number ("ID
|
||||
AB123"), "otp", "2fa", "mfa", "cvv", "cvc" or a verification, one-time,
|
||||
security, auth or login code followed by a code (any value after a label
|
||||
in lower case, "verification code Abc", also before "thanks"; after a label
|
||||
written as a name, any value that is not one: "OTP Bank" and "Security
|
||||
Code Plaza" are places), a "pin" or door, access, gate, alarm or entry
|
||||
code followed by a value in mixed case ("PIN aBcD"), a
|
||||
door, access, gate, alarm, entry or security code followed by a digit, "api
|
||||
key", "access token" or "secret key" followed by a word of six characters
|
||||
or more, the word for "password" in the interface's languages
|
||||
(contraseña, Passwort, mot de passe, пароль…) followed by anything, or "pin"
|
||||
(also "pin code", "pin number", "pin is") followed by a digit; a word
|
||||
starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_` or a Slack token's `xoxb-` and the like (any case) or
|
||||
`AIza`, `eyJ` or `AKIA`; or a word that may be a password or key, with letters and digits mixed
|
||||
starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_`, `github_pat_`, `glpat-`, `hf_`, a SendGrid
|
||||
`SG.` key or a Slack token's `xoxb-` and the like (any case) or
|
||||
`AIza` or `eyJ`, or an AWS key id (`AKIA` and twelve capitals or digits
|
||||
more; "Akiak" is a place); or a word that may be a password or key, with letters and digits mixed
|
||||
within one run (a number beside a word, as in "Yanino-1", "2-chōme" or
|
||||
"Route-66", is a name): eight characters or more, six or more with four
|
||||
letters and a digit ("hunter22", "Area51"), or six or more with letters,
|
||||
digits and a symbol ("Tr0ub4dor&3"). The password words match whole words
|
||||
only ("Sachsenhausen" is a place). Over the bundled names (139,502), five
|
||||
read as private: two with stray digits ("Maliga0N", "Jerónim67") and three
|
||||
with number lists or codes. When the text may be private the field says
|
||||
only ("Sachsenhausen" is a place). Over the bundled names (139,502), six
|
||||
read as private: two with stray digits ("Maliga0N", "Jerónim67"), two
|
||||
joined by "@" to a lower-case handle ("Pulipadu @Govardhanagiri") and two
|
||||
with number lists or dates. When the text may be private the field says
|
||||
so ("Looks private, so nothing is searched or sent"), and a line whose
|
||||
only private sign is an address-sized run of digits (no group over six
|
||||
digits, nine at most in all, counted as they fold, and no word such as
|
||||
digits, nine at most in all, counted as they fold, no three digits
|
||||
followed by four as a phone number writes them, and no word such as
|
||||
card, code, key, phone or account beside them, in English and some other
|
||||
European languages; compounds such as "Kreditkartennummer" and words in
|
||||
other scripts are not read), with words beside it, gets a row
|
||||
to search it as a place on purpose ("Search … as a place anyway"), which
|
||||
runs the ordinary place search and its online services only when picked; a
|
||||
bare number, an email or handle, a password, key, code or IBAN gets none.
|
||||
A suggested house is named by its number and its street (or, without a
|
||||
street, its locality, district or city) in the order its country writes them: "10 Downing
|
||||
Street", "Hauptstraße 12".
|
||||
A nine-digit number or a short phone number written with no such word
|
||||
still gets the row: only picking it sends anything. One-time and verification codes,
|
||||
OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases,
|
||||
recovery or seed phrases, "my secret is …" and an email spelled out ("john
|
||||
at example dot com") are private too. Text that parses as coordinates or a
|
||||
recovery or seed phrases (twelve to twenty-four short words with none of
|
||||
the common words a phrase list lacks, such as "the", "and" or "are", so a
|
||||
long question still goes to Ask GEV), "my secret is …", an email spelled
|
||||
out ("john at example dot com", "punto com", or letter by letter), a door,
|
||||
alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415"
|
||||
are places), "Authorization: Bearer …", a code in a link (`?code=…`), a
|
||||
spaced UK National Insurance number and "my id is …" are private too.
|
||||
"Boise ID 83702" names Idaho. Some private text is not caught: a
|
||||
passphrase run together as one word (a long place name is one word too),
|
||||
a lower-case word after "otp", "2fa" or "mfa" ("mfa boston" is a name;
|
||||
"otp ABCDEF" is caught) and a code of lower-case letters after "pin" or
|
||||
"gate code" ("PIN ABCD" is caught).
|
||||
A Japanese postcode after a Latin name is refused ("Shibuya 150-0002"), and
|
||||
so is a name in capitals after a code's label ("MFA BOSTON", which cannot
|
||||
be told from "OTP ABCDEF"). Text that parses as coordinates or a
|
||||
grid reference is not private. A place's name is six words at most, or ten
|
||||
when it has a number in it (an address: "1600 Pennsylvania Ave NW
|
||||
Washington DC 20500"). The places picked from the Omnibar's rows and chips that carry a position
|
||||
|
||||
@@ -25,8 +25,6 @@ import { fakeDrawPort } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeGlobePort } from '../testSupport/fakeGlobePort.mjs';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { HEAT_REBUILD_MS } from '../layers/firms/policy.js';
|
||||
import { registerStyleStages } from '../styles/styleStages.js';
|
||||
import { sensorPickPosition } from '../input/sensorPick.js';
|
||||
|
||||
const LAYER_SOURCE = readLayerSource(
|
||||
path.join(path.dirname(fileURLToPath(import.meta.url)), 'firmsHeatmap.js'),
|
||||
@@ -651,16 +649,6 @@ test('far zoom drapes one heatmap and the hand-off cross-fades it with the marke
|
||||
assert.equal(added[0].alpha, 0.5);
|
||||
assert.equal(glow(1).alpha, 0.5, 'rebuilt markers get the fade');
|
||||
|
||||
// An application drawing the detections in their place hides both.
|
||||
h.layer.setMarkerStandIn({ hitTest: () => null });
|
||||
assert.equal(added[0].show, false, 'a stand-in hides the heatmap');
|
||||
assert.equal(markers().show, false, 'and the markers');
|
||||
h.layer._renderLodForTest('global');
|
||||
assert.equal(added[0].show, false, 'through a rebuild too');
|
||||
h.layer.setMarkerStandIn(null);
|
||||
assert.equal(added[0].show, true);
|
||||
assert.equal(markers().show, true);
|
||||
|
||||
h.layer.disable();
|
||||
assert.equal(added[0].show, false, 'disable hides the heatmap');
|
||||
|
||||
@@ -672,134 +660,3 @@ test('far zoom drapes one heatmap and the hand-off cross-fades it with the marke
|
||||
restoreDocument();
|
||||
}
|
||||
});
|
||||
|
||||
test('a click on a fire an application draws in place of the markers selects it as a marker click does', () => {
|
||||
const fire = makeFire();
|
||||
const other = makeFire({ index: 8, lat: 31.2, lon: -97.9, frp: 40 });
|
||||
// The application's records come from the same source, adapted on their own.
|
||||
let answer = { ...fire };
|
||||
const asked = [];
|
||||
const h = harness({ fires: [fire, other], picked: glowPick('firms-8') });
|
||||
try {
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: (screen) => {
|
||||
asked.push(screen);
|
||||
return answer;
|
||||
},
|
||||
});
|
||||
assert.equal(h.icons().show, false, 'the glows are hidden');
|
||||
h.published.length = 0;
|
||||
h.click();
|
||||
assert.deepEqual(asked, [{ x: 400, y: 300 }]);
|
||||
assert.equal(h.requests.length, 1, 'the camera moves as for a marker');
|
||||
assert.equal(h.requests[0].kind, 'fire');
|
||||
assert.equal(
|
||||
h.requests[0].id,
|
||||
fireDetectionKey(fire),
|
||||
'the stand-in decides, not the hidden glow under the click',
|
||||
);
|
||||
assert.equal(h.layer.getSelectedInfo().id, fireDetectionKey(fire));
|
||||
assert.equal(getSelectedEntityContext().label, 'Fire · FRP 1520 MW');
|
||||
assert.deepEqual(
|
||||
h.published.map((entry) => entry.id),
|
||||
[`selected-fire:${fireDetectionKey(fire)}`],
|
||||
"only the selected fire's card shows",
|
||||
);
|
||||
|
||||
// Nothing of the application's under the click: empty space.
|
||||
answer = null;
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1, 'no camera move');
|
||||
assert.equal(h.layer.getSelectedInfo(), null, 'the selection is cleared');
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('a stand-in hit on a fire the layer does not show selects nothing', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({ fires: [fire] });
|
||||
try {
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: () => makeFire({ lat: 12.5, lon: 40.1 }),
|
||||
});
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 0);
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('taking the stand-in away brings the markers and their cards back and keeps the selection', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
// Near enough for the markers rather than the heatmap.
|
||||
cameraPosition: Cesium.Cartesian3.fromDegrees(fire.lon, fire.lat, 500_000),
|
||||
});
|
||||
try {
|
||||
h.layer.setMarkerStandIn({ hitTest: () => fire });
|
||||
assert.equal(h.icons().show, false);
|
||||
h.click();
|
||||
h.layer.setMarkerStandIn(null);
|
||||
assert.equal(h.icons().show, true);
|
||||
assert.equal(h.layer.getSelectedInfo().id, fireDetectionKey(fire));
|
||||
const ids = h.published.map((entry) => entry.id);
|
||||
assert.ok(ids.includes(`selected-fire:${fireDetectionKey(fire)}`));
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('the stand-in is asked where a marker is picked: the click as the sensor style draws it', () => {
|
||||
const fire = makeFire();
|
||||
const asked = [];
|
||||
const h = harness({ fires: [fire] });
|
||||
try {
|
||||
registerStyleStages(h.viewer.scene, {
|
||||
surveillance: {
|
||||
enabled: true,
|
||||
uniforms: { intensity: 1, pixelation: 4 },
|
||||
},
|
||||
});
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: (screen) => {
|
||||
asked.push(screen);
|
||||
return fire;
|
||||
},
|
||||
});
|
||||
h.click();
|
||||
const expected = sensorPickPosition(
|
||||
h.viewer.scene,
|
||||
{ x: 400, y: 300 },
|
||||
h.viewer.scene.canvas,
|
||||
);
|
||||
assert.notDeepEqual([expected.x, expected.y], [400, 300]);
|
||||
assert.deepEqual([asked[0].x, asked[0].y], [expected.x, expected.y]);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("a sibling layer's item over a stand-in fire wins the click", () => {
|
||||
const fire = makeFire();
|
||||
let asked = 0;
|
||||
registerPickOwner('flights', (pickedId) => pickedId === 'a1b2c3');
|
||||
const h = harness({ fires: [fire], picked: { id: 'a1b2c3' } });
|
||||
try {
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: () => {
|
||||
asked++;
|
||||
return fire;
|
||||
},
|
||||
});
|
||||
h.click();
|
||||
assert.equal(asked, 0, 'the stand-in is not asked');
|
||||
assert.equal(h.requests.length, 0, 'no camera move');
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
unregisterPickOwner('flights');
|
||||
}
|
||||
});
|
||||
@@ -4648,7 +4648,6 @@
|
||||
"Turn off": "إيقاف",
|
||||
"Command": "أمر",
|
||||
"No layers are on": "لا توجد طبقات مفعّلة",
|
||||
"No other layers are on": "لا توجد طبقات أخرى مفعّلة",
|
||||
"No matching layers": "لا توجد طبقات مطابقة",
|
||||
"Show me {thing} settings": "عرض إعدادات {thing}",
|
||||
"Show me how: {thing}": "طريقة الاستخدام: {thing}",
|
||||
|
||||
@@ -4236,7 +4236,6 @@
|
||||
"Turn off": "Ausschalten",
|
||||
"Command": "Befehl",
|
||||
"No layers are on": "Keine Ebenen aktiv",
|
||||
"No other layers are on": "Keine anderen Ebenen aktiv",
|
||||
"No matching layers": "Keine passenden Ebenen",
|
||||
"Show me {thing} settings": "Einstellungen für {thing} zeigen",
|
||||
"Show me how: {thing}": "Anleitung anzeigen: {thing}",
|
||||
|
||||
@@ -4339,7 +4339,6 @@
|
||||
"Turn off": "Desactivar",
|
||||
"Command": "Comando",
|
||||
"No layers are on": "No hay capas activas",
|
||||
"No other layers are on": "No hay otras capas activas",
|
||||
"No matching layers": "No se encontraron capas",
|
||||
"Show me {thing} settings": "Muéstrame los ajustes de {thing}",
|
||||
"Show me how: {thing}": "Muéstrame cómo: {thing}",
|
||||
|
||||
@@ -4339,7 +4339,6 @@
|
||||
"Turn off": "Désactiver",
|
||||
"Command": "Commande",
|
||||
"No layers are on": "Aucune couche active",
|
||||
"No other layers are on": "Aucune autre couche active",
|
||||
"No matching layers": "Aucune couche correspondante",
|
||||
"Show me {thing} settings": "Montrez-moi les réglages de {thing}",
|
||||
"Show me how: {thing}": "Montrez-moi comment faire : {thing}",
|
||||
|
||||
@@ -4339,7 +4339,6 @@
|
||||
"Turn off": "כיבוי",
|
||||
"Command": "פקודה",
|
||||
"No layers are on": "אין שכבות פעילות",
|
||||
"No other layers are on": "אין שכבות אחרות פעילות",
|
||||
"No matching layers": "אין שכבות תואמות",
|
||||
"Show me {thing} settings": "הצגת ההגדרות של {thing}",
|
||||
"Show me how: {thing}": "איך עושים זאת: {thing}",
|
||||
|
||||
@@ -4339,7 +4339,6 @@
|
||||
"Turn off": "Disattiva",
|
||||
"Command": "Comando",
|
||||
"No layers are on": "Nessun livello attivo",
|
||||
"No other layers are on": "Nessun altro livello attivo",
|
||||
"No matching layers": "Nessun livello corrispondente",
|
||||
"Show me {thing} settings": "Mostrami le impostazioni di {thing}",
|
||||
"Show me how: {thing}": "Mostrami come: {thing}",
|
||||
|
||||
@@ -4133,7 +4133,6 @@
|
||||
"Turn off": "オフにする",
|
||||
"Command": "コマンド",
|
||||
"No layers are on": "オンになっているレイヤーはありません",
|
||||
"No other layers are on": "他にオンになっているレイヤーはありません",
|
||||
"No matching layers": "該当するレイヤーはありません",
|
||||
"Show me {thing} settings": "{thing}の設定を表示",
|
||||
"Show me how: {thing}": "使い方を見る:{thing}",
|
||||
|
||||
@@ -4339,7 +4339,6 @@
|
||||
"Turn off": "Desativar",
|
||||
"Command": "Comando",
|
||||
"No layers are on": "Nenhuma camada ativa",
|
||||
"No other layers are on": "Não há outras camadas ativas",
|
||||
"No matching layers": "Nenhuma camada encontrada",
|
||||
"Show me {thing} settings": "Mostre as configurações de {thing}",
|
||||
"Show me how: {thing}": "Mostre como fazer: {thing}",
|
||||
|
||||
@@ -4442,7 +4442,6 @@
|
||||
"Turn off": "Выключить",
|
||||
"Command": "Команда",
|
||||
"No layers are on": "Нет включённых слоёв",
|
||||
"No other layers are on": "Других включённых слоёв нет",
|
||||
"No matching layers": "Подходящие слои не найдены",
|
||||
"Show me {thing} settings": "Показать настройки для {thing}",
|
||||
"Show me how: {thing}": "Показать как: {thing}",
|
||||
|
||||
@@ -4236,7 +4236,6 @@
|
||||
"Turn off": "Slå av",
|
||||
"Command": "Kommando",
|
||||
"No layers are on": "Inga lager är på",
|
||||
"No other layers are on": "Inga andra lager är på",
|
||||
"No matching layers": "Inga matchande lager",
|
||||
"Show me {thing} settings": "Visa inställningarna för {thing}",
|
||||
"Show me how: {thing}": "Visa hur: {thing}",
|
||||
|
||||
@@ -4442,7 +4442,6 @@
|
||||
"Turn off": "Вимкнути",
|
||||
"Command": "Команда",
|
||||
"No layers are on": "Немає увімкнених шарів",
|
||||
"No other layers are on": "Інших увімкнених шарів немає",
|
||||
"No matching layers": "Відповідних шарів не знайдено",
|
||||
"Show me {thing} settings": "Показати налаштування для {thing}",
|
||||
"Show me how: {thing}": "Показати як: {thing}",
|
||||
|
||||
@@ -4133,7 +4133,6 @@
|
||||
"Turn off": "关闭",
|
||||
"Command": "命令",
|
||||
"No layers are on": "没有已启用的图层",
|
||||
"No other layers are on": "没有其他已启用的图层",
|
||||
"No matching layers": "没有匹配的图层",
|
||||
"Show me {thing} settings": "显示{thing}的设置",
|
||||
"Show me how: {thing}": "查看操作方法:{thing}",
|
||||
|
||||
@@ -4133,7 +4133,6 @@
|
||||
"Turn off": "關閉",
|
||||
"Command": "命令",
|
||||
"No layers are on": "沒有已啟用的圖層",
|
||||
"No other layers are on": "沒有其他已啟用的圖層",
|
||||
"No matching layers": "沒有匹配的圖層",
|
||||
"Show me {thing} settings": "顯示{thing}的設置",
|
||||
"Show me how: {thing}": "查看操作方法:{thing}",
|
||||
|
||||
@@ -76,10 +76,7 @@ export function createCards({
|
||||
const height = canvas.clientHeight;
|
||||
let ambientCount = 0;
|
||||
|
||||
// An application drawing the detections in place of the markers draws
|
||||
// them unlabelled: only the selected fire's card shows then.
|
||||
const candidates = layerState._standIn ? [] : layerState._labelCandidates;
|
||||
for (const candidate of candidates) {
|
||||
for (const candidate of layerState._labelCandidates) {
|
||||
if (ambientCount >= MAX_AMBIENT_LABELS) break;
|
||||
if (candidate.fire && candidate.fire === layerState._selectedFire)
|
||||
continue;
|
||||
|
||||
@@ -52,12 +52,10 @@ export function createLifecycle({
|
||||
if (layerState._cells) layerState._cells.show = true;
|
||||
// The GPU culls the far side each frame, so retained rows are right
|
||||
// for wherever the camera went while the layer was off.
|
||||
if (layerState._icons) layerState._icons.show = !layerState._standIn;
|
||||
if (layerState._icons) layerState._icons.show = true;
|
||||
overlayHost.setVisible(FIRMS_OVERLAY_SOURCE_ID, true);
|
||||
// A filter can leave an old raster cached while the current set is empty.
|
||||
layerState._heatImagery?.setShow(
|
||||
layerState._fires.length > 0 && !layerState._standIn,
|
||||
);
|
||||
layerState._heatImagery?.setShow(layerState._fires.length > 0);
|
||||
// The camera can have crossed the hand-off while the layer was off.
|
||||
components.rendering.applyHandoffFade(true);
|
||||
components.viewport.installLodWatcher();
|
||||
@@ -70,29 +68,6 @@ export function createLifecycle({
|
||||
await components.ingestion.loadHeatmap();
|
||||
},
|
||||
|
||||
/**
|
||||
* Let an application draw the detections in place of the layer's
|
||||
* markers. While a stand-in is set, the glows, the heatmap and the
|
||||
* ambient cards are hidden and everything else works as before: a click
|
||||
* on a fire the stand-in draws (`standIn.hitTest(screenPosition)`, which
|
||||
* answers a detection record from the same source, or null) selects it
|
||||
* and moves the camera to it as a click on its marker does, the selected
|
||||
* fire's card shows, and a click on empty space clears the selection.
|
||||
* `null` brings the markers back. The selection is kept either way.
|
||||
* @param {?{hitTest: (screenPosition: {x: number, y: number}) => ?Object}} standIn
|
||||
*/
|
||||
setMarkerStandIn(standIn) {
|
||||
layerState._standIn =
|
||||
typeof standIn?.hitTest === 'function' ? standIn : null;
|
||||
layerState._heatImagery?.setShow(
|
||||
layerState._enabled &&
|
||||
layerState._fires.length > 0 &&
|
||||
!layerState._standIn,
|
||||
);
|
||||
components.rendering.applyHandoffFade(true);
|
||||
components.cards.rebuildAmbientLabels();
|
||||
},
|
||||
|
||||
disable() {
|
||||
layerState.request?.abort();
|
||||
layerState.request = null;
|
||||
@@ -154,7 +129,6 @@ export function createLifecycle({
|
||||
layerState._currentLodIndex = -1;
|
||||
layerState._lastViewRect = null;
|
||||
layerState._selectedFire = null;
|
||||
layerState._standIn = null;
|
||||
layerState._labelCandidates = [];
|
||||
layerState._labelLodDistance = 0;
|
||||
layerState._pickIndexById.clear();
|
||||
|
||||
@@ -122,7 +122,7 @@ export function createRendering({
|
||||
glowAlpha = alpha;
|
||||
const set = layerState._icons;
|
||||
if (!set) return;
|
||||
set.show = layerState._enabled && !layerState._standIn && heat < 1;
|
||||
set.show = layerState._enabled && heat < 1;
|
||||
if (!changed || !drawnGlows.size) return;
|
||||
const faded = [];
|
||||
for (const drawn of drawnGlows.values()) {
|
||||
@@ -273,7 +273,7 @@ export function createRendering({
|
||||
// The map stack may have changed since the last render.
|
||||
imagery.rehome();
|
||||
ensureHeatRaster(now);
|
||||
imagery.setShow(layerState._enabled && !layerState._standIn);
|
||||
imagery.setShow(layerState._enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,10 +469,7 @@ export function createRendering({
|
||||
// Blended as one translucent pass, as its billboards were.
|
||||
blend: 'translucent',
|
||||
horizonCull: true,
|
||||
show:
|
||||
layerState._enabled &&
|
||||
!layerState._standIn &&
|
||||
!(layerState._handoffHeat >= 1),
|
||||
show: layerState._enabled && !(layerState._handoffHeat >= 1),
|
||||
drawOrder: spriteDrawOrder?.('firms') ?? 0,
|
||||
});
|
||||
// Columns of no rows put the set's host in the scene now, rather than
|
||||
|
||||
@@ -35,23 +35,17 @@ export function createSelection({
|
||||
const input = inputFor(layerState._viewer);
|
||||
layerState._clickSubscription = input.onClick((event) => {
|
||||
const picked = event.topHit;
|
||||
const pickedId = picked ? resolvePickId(picked) : null;
|
||||
// A pick that belongs to a sibling layer (e.g. an aircraft) is not
|
||||
// "empty space" — leave the selection alone and let that layer handle it.
|
||||
const otherLayer = Boolean(pickedId && isOwnedByOtherLayer(id, pickedId));
|
||||
// The stand-in is asked where markers are picked: the click corrected
|
||||
// for the sensor style (`event.position`), and only when no sibling
|
||||
// layer's item is on top, as a marker under that item would not be hit.
|
||||
const fire = layerState._standIn
|
||||
? otherLayer
|
||||
? null
|
||||
: standInFire(event.position ?? event.screenPosition)
|
||||
: pickedFire(event.drawHit);
|
||||
const fire = pickedFire(event.drawHit);
|
||||
if (fire) {
|
||||
selectAndFocusFire(fire);
|
||||
return;
|
||||
}
|
||||
if (otherLayer) return;
|
||||
// A pick that belongs to a sibling layer (e.g. an aircraft) is not
|
||||
// "empty space" — leave the selection alone and let that layer handle it.
|
||||
if (picked) {
|
||||
const pickedId = resolvePickId(picked);
|
||||
if (pickedId && isOwnedByOtherLayer(id, pickedId)) return;
|
||||
}
|
||||
const cardHit = overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
@@ -99,32 +93,6 @@ export function createSelection({
|
||||
return layerState._pickIndexById.get(hit.id) ?? null;
|
||||
}
|
||||
|
||||
/** The shown detections by their key, for the shown set they were made from. */
|
||||
let keyed = { fires: null, byKey: null };
|
||||
|
||||
/**
|
||||
* Resolve a click to one of this layer's fire records through the
|
||||
* application's stand-in for its markers (`setMarkerStandIn`), or null:
|
||||
* the record its hit test answers, matched by its detection key to a fire
|
||||
* the layer shows now (so one the filter hides is not selected).
|
||||
* @param {?{x: number, y: number}} screenPosition - Where the user clicked.
|
||||
* @returns {?Object} Fire record.
|
||||
*/
|
||||
|
||||
function standInFire(screenPosition) {
|
||||
if (!screenPosition) return null;
|
||||
const record = layerState._standIn?.hitTest(screenPosition);
|
||||
if (!record) return null;
|
||||
if (keyed.fires !== layerState._fires)
|
||||
keyed = {
|
||||
fires: layerState._fires,
|
||||
byKey: new Map(
|
||||
layerState._fires.map((fire) => [fireDetectionKey(fire), fire]),
|
||||
),
|
||||
};
|
||||
return keyed.byKey.get(fireDetectionKey(record)) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a fire: show its detail label and mark it selected in the shared
|
||||
* context store so voice "what's selected" resolves to it.
|
||||
@@ -261,7 +229,6 @@ export function createSelection({
|
||||
removeClickHandler,
|
||||
selectAndFocusFire,
|
||||
pickedFire,
|
||||
standInFire,
|
||||
selectFire,
|
||||
clearFireSelection,
|
||||
refreshContextRegistrations,
|
||||
|
||||
@@ -98,14 +98,6 @@ export function createFirmsState({ services, config }) {
|
||||
|
||||
layerState._selectedFire = null;
|
||||
|
||||
/**
|
||||
* What an application draws in place of the markers (`setMarkerStandIn`):
|
||||
* while set, the glows, heatmap and ambient cards are hidden and clicks
|
||||
* resolve through its `hitTest`.
|
||||
*/
|
||||
|
||||
layerState._standIn = null;
|
||||
|
||||
/** Priority-ordered label candidates from the last rebuild (detections or cells). */
|
||||
|
||||
layerState._labelCandidates = [];
|
||||
|
||||
+262
-16
@@ -62,10 +62,49 @@ export function onlyNumbersLookPrivate(text) {
|
||||
// is ("card 4111 …", "phone +1 415 …", "token 12345678").
|
||||
groups.every((group) => group.length <= 6) &&
|
||||
groups.join('').length <= 9 &&
|
||||
!/(?<!\d)\d{3}[ .-]\d{4}(?!\d)/.test(line) &&
|
||||
!NUMBER_CONTEXT.test(line)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The most words a line sent for place suggestions may have: as many as the
|
||||
* Omnibar reads as a place's name (ten with a number, as an address has).
|
||||
*/
|
||||
const suggestMaxWords = (text) => (/\d/.test(text) ? 10 : 8);
|
||||
|
||||
/**
|
||||
* Common words no wallet's recovery phrase holds (they are not on the BIP39
|
||||
* list): a line with one is a sentence, however many short words it has.
|
||||
*/
|
||||
const NOT_SEED_WORDS = new Set([
|
||||
'the',
|
||||
'and',
|
||||
'are',
|
||||
'for',
|
||||
'from',
|
||||
'with',
|
||||
'how',
|
||||
'why',
|
||||
'which',
|
||||
'would',
|
||||
'could',
|
||||
'should',
|
||||
'does',
|
||||
'was',
|
||||
'were',
|
||||
'flights',
|
||||
]);
|
||||
|
||||
/**
|
||||
* "Boise ID 83702", "Coeur d'Alene ID 83814": Idaho's code before a ZIP
|
||||
* code, after a town's name (not after "my" or "employee", whose "ID" is an
|
||||
* identity number).
|
||||
*/
|
||||
const IDAHO_BEFORE_ZIP = /(\S+)(,?\s)ID(?=\.?,?\s+\d{5}(?:-\d{4})?(?!\S))/gu;
|
||||
const ID_OWNERS =
|
||||
/^(?:my|your|our|his|her|their|employee|student|staff|member|user|customer|patient|national|voter|photo|tax|card|the|an?)$/i;
|
||||
|
||||
/**
|
||||
* Words that say a number is an account, a card, a phone or a secret, in the
|
||||
* interface's languages where they differ ("Karte", "Telefon", "tarjeta").
|
||||
@@ -84,12 +123,16 @@ function foldLine(text) {
|
||||
.normalize('NFKC')
|
||||
.replace(/\p{Cf}/gu, '')
|
||||
.replace(/[\u2018\u2019]/g, "'")
|
||||
.replace(/(?![0-9])\p{Nd}/gu, '0');
|
||||
.replace(/(?![0-9])\p{Nd}/gu, '0')
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(IDAHO_BEFORE_ZIP, (whole, word, gap) =>
|
||||
ID_OWNERS.test(word) ? whole : `${word}${gap}Idaho`,
|
||||
);
|
||||
}
|
||||
|
||||
/** A US ZIP+4 after a state's code or name, as an address writes it. */
|
||||
const US_ZIP4 = new RegExp(
|
||||
String.raw`(?<=(?:^|\s)(?:[a-z]{2}|[a-z]\.[a-z]|Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Mass|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming|Puerto Rico)\.?,?\s)\d{5}-\d{4}\b`,
|
||||
String.raw`(?<=(?:^|\s)(?:A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|PR|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY]|[a-z]\.[a-z]|Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Mass|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming|Puerto Rico)\.?,?\s)\d{5}-\d{4}\b`,
|
||||
'giu',
|
||||
);
|
||||
|
||||
@@ -119,6 +162,59 @@ function privacyReason(text) {
|
||||
)
|
||||
)
|
||||
return 'other';
|
||||
// An email written around a filter: "john(at)gmail.com",
|
||||
// "john[at]gmail[dot]com", "john at gmail dot com".
|
||||
// Also "john at gmail.com" and a "(dot)" or "[dot]" in any of them.
|
||||
// Spaced letter by letter ("j o h n @ g m a i l . c o m").
|
||||
if (
|
||||
/(?:^|\s)(?:\S\s){3,}@\s?(?:\S\s?){2,}/u.test(line) &&
|
||||
/[^@]@[\p{L}\p{N}-]+\.\p{L}{2,}/u.test(line.replace(/\s+/g, ''))
|
||||
)
|
||||
return 'other';
|
||||
if (
|
||||
/[\p{L}\p{N}._%+-]\s*[([{<]\s*at\s*[)\]}>]\s*[\p{L}\p{N}-]/iu.test(line) ||
|
||||
/\b\S+\s+at\s+\S+\s+(?:dot|punto|ponto|period|punkt|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test(
|
||||
line,
|
||||
) ||
|
||||
/\b\S+\s+at\s+[\p{L}\p{N}-]+\s*[([{<]\s*dot\s*[)\]}>]\s*\p{L}{2,24}\b/iu.test(
|
||||
line,
|
||||
) ||
|
||||
/\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\s*\.\s*(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test(
|
||||
line,
|
||||
)
|
||||
)
|
||||
return 'other';
|
||||
// An IPv6 host in a link ("https://[::1]/").
|
||||
if (/\[[0-9a-f:.]*:[0-9a-f:.]*:[0-9a-f:.]*\]/i.test(line)) return 'other';
|
||||
// An IP address ("10.0.0.1").
|
||||
if (/(?<![\d.])\d{1,3}(?:\.\d{1,3}){3}(?![\d.])/.test(line)) return 'other';
|
||||
// An IPv6 address ("::1", "fe80::1%eth0", "2001:db8:0:0:0:0:2:1"): hex
|
||||
// groups with "::", or five colons or more (a time has two).
|
||||
if (
|
||||
line.split(' ').some((token) => {
|
||||
const bare = token.replace(/^[[(]+|[\]),.;]+$/g, '').replace(/%\w+$/, '');
|
||||
const colons = (bare.match(/:/g) || []).length;
|
||||
return (
|
||||
/^[0-9a-f:.]+$/i.test(bare) &&
|
||||
colons >= 2 &&
|
||||
(bare.includes('::') || colons >= 5)
|
||||
);
|
||||
})
|
||||
)
|
||||
return 'other';
|
||||
// A wallet's recovery phrase, whole or nearly ("abandon ability able
|
||||
// …"): twelve to twenty-four words of three to eight letters, none a
|
||||
// common word the phrase list lacks ("can you tell where the most …" is
|
||||
// a question). Too long to be sent
|
||||
// for suggestions anyway, it is kept from the assistant too.
|
||||
const words = line.trim().toLowerCase().split(/\s+/);
|
||||
if (
|
||||
words.length >= 12 &&
|
||||
words.length <= 24 &&
|
||||
words.every((word) => /^[a-z]{3,8}$/.test(word)) &&
|
||||
!words.some((word) => NOT_SEED_WORDS.has(word))
|
||||
)
|
||||
return 'other';
|
||||
// Coordinates and grid references are a spot, not a number to keep: only
|
||||
// text the place search itself reads as coordinates, as typed ("١٢٣٤,
|
||||
// ٥٦٧٨" folded would read as a spot, but is not one).
|
||||
@@ -146,7 +242,7 @@ function privacyReason(text) {
|
||||
.replace(
|
||||
// After a street word, or before the city ("12, 10115 Berlin");
|
||||
// "030 12345" alone is a phone number.
|
||||
/(?<=\p{L}\.?\s)\d{1,4}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+\p{L}|$)|(?<=^|\s)\d{1,4}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+\p{L})/giu,
|
||||
/(?<=\p{L}\.?\s)[1-9]\d{0,3}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+(?!(?:thanks|thank|thx|please|pls|ok|okay|now|asap|call|text)\b)\p{L}|$)|(?<=^|\s)[1-9]\d{0,3}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+(?!(?:thanks|thank|thx|please|pls|ok|okay|now|asap|call|text)\b)\p{L})/giu,
|
||||
' ',
|
||||
)
|
||||
// Other postcodes after a street's house number and before the city (a
|
||||
@@ -164,7 +260,7 @@ function privacyReason(text) {
|
||||
.replace(US_ZIP4, ' x ')
|
||||
.replace(/\b\d{5}-\d{3}\b/g, ' x ')
|
||||
.replace(
|
||||
/〒\s?\d{3}-\d{4}|\b\d{3}-\d{4}(?=\s*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}])/gu,
|
||||
/〒\s?\d{3}-\d{4}|\b\d{3}-\d{4}(?=\s*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}])|(?<=[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]\s*)\d{3}-\d{4}\b/gu,
|
||||
' x ',
|
||||
)
|
||||
.replace(/#/g, ' x ')
|
||||
@@ -176,9 +272,12 @@ function privacyReason(text) {
|
||||
// An IBAN.
|
||||
if (/\b[a-z]{2}\d{2}(?:\s?[a-z0-9]){10,}/i.test(line)) return 'other';
|
||||
if (
|
||||
/\b(?:password|passcode|passwd|ssn|pw|pwd|bearer)\b\s*[:=#]?\s*\S/i.test(
|
||||
line,
|
||||
) ||
|
||||
/\b(?:password|passcode|passwd|pw|pwd)\b\s*[:=#]?\s*\S/i.test(line) ||
|
||||
// "Bearer Island" and "SSN Station" are places: after "bearer" any value
|
||||
// but a capitalised name is a token, and a social security number has
|
||||
// digits.
|
||||
bearerToken(line) ||
|
||||
/\bssn\b(?:\s+(?:is|no\.?|number|#))*\s*[:=#]?\s*[\dx*]{3}/i.test(line) ||
|
||||
// The word for "password" in the interface's languages.
|
||||
// A whole word only: "Sachsenhausen" holds "senha" but is a place.
|
||||
/(?<!\p{L})(?:contraseña|passwort|kennwort|mot de passe|senha|parola d'ordine|lösenord|пароль|пароля|密码|密碼|パスワード|비밀번호|סיסמה|كلمة (?:السر|المرور))(?!\p{L})\s*[:=#]?\s*\S/iu.test(
|
||||
@@ -190,6 +289,16 @@ function privacyReason(text) {
|
||||
line,
|
||||
) ||
|
||||
/\b(?:token|secret|api[ _-]?key|key|pass)\s*[:=]\s*\S/i.test(line) ||
|
||||
// A number on a document or account after its label: "license ABC1234",
|
||||
// "passport X1234567", "plate 7ABC123", "member no. 12345".
|
||||
/\b(?:licen[cs]e|plate|passport|member(?:ship)?|account|acct|policy|ticket|booking|confirmation|ref(?:erence)?)(?:\s+(?:no\.?|number|#|is))*(?:\s*[:=#]\s*|\s+)(?=[a-z0-9-]*\d)[a-z0-9-]{4,}/i.test(
|
||||
line,
|
||||
) ||
|
||||
// An identity number after "ID" in capitals ("ID AB123"); "Id" and
|
||||
// "id" are words.
|
||||
/\bID(?:\s+(?:no\.?|number|#|is))*(?:\s*[:=#]\s*|\s+)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{4,}/.test(
|
||||
line,
|
||||
) ||
|
||||
/\b(?:my secret is|passphrase|mnemonic|seed phrase|recovery phrase)\b\s*[:=]?\s*\S/i.test(
|
||||
line,
|
||||
) ||
|
||||
@@ -204,7 +313,27 @@ function privacyReason(text) {
|
||||
/\b(?:pin|otp|2fa|mfa|cvv|cvc|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)\s*(?:[:=#]|\s[-–—]\s|-)\s*[a-z0-9]/i.test(
|
||||
line,
|
||||
) ||
|
||||
codeAfterLabel(line)
|
||||
codeAfterLabel(line) ||
|
||||
// A door, alarm or lockbox number ("code 4821", "garage code 4821",
|
||||
// "the code to my door is 4821").
|
||||
// A postcode, dialling code or airport code is not one ("zip code
|
||||
// 90210", "area code 415").
|
||||
/\b(?<!\b(?:zip|postal|post|postcode|area|country|dialing|dialling|airport|iata|icao|country)\s)(?:code|alarm|lockbox|lock box|combination|combo|keypad)(?:\s+(?:number|no\.?|is|code|pin))*\s*[:=#]?\s*\d{3,8}\b/i.test(
|
||||
line,
|
||||
) ||
|
||||
/\b(?<!\b(?:zip|postal|post|area|country|dialing|dialling|airport)\s)code\b.{0,30}?\bis\s*[:=]?\s*\d{3,8}\b/i.test(
|
||||
line,
|
||||
) ||
|
||||
// A UK National Insurance number, spaced ("AB 12 34 56 C").
|
||||
/\b[a-z]{2}\s?\d{2}\s?\d{2}\s?\d{2}\s?[a-d]\b/i.test(line) ||
|
||||
// "my id is AB12345", "id no. 4471".
|
||||
/\bid\s+(?:is|no\.?|number|#)\s*[:=#]?\s*(?=[a-z0-9-]*\d)[a-z0-9-]{4,}/i.test(
|
||||
line,
|
||||
) ||
|
||||
// A one-time code in a link ("…/callback?code=abcdef").
|
||||
/[?&](?:code|token|access_token|key|sig|signature|auth)=[^&\s]{4,}/i.test(
|
||||
line,
|
||||
)
|
||||
)
|
||||
return 'other';
|
||||
if (
|
||||
@@ -215,8 +344,12 @@ function privacyReason(text) {
|
||||
.map((token) => token.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, ''))
|
||||
.some(
|
||||
(token) =>
|
||||
/^(?:sk[-_]|rk_|pk_live|ghp_|xox[abposr]-)/i.test(token) ||
|
||||
/^(?:AIza|eyJ|AKIA)/.test(token) ||
|
||||
/^(?:sk[-_]|rk_|pk_live|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|hf_|xox[abposr]-)/i.test(
|
||||
token,
|
||||
) ||
|
||||
/^SG\.[\w-]{8,}\.[\w-]{8,}$/.test(token) ||
|
||||
/^(?:AIza|eyJ)/.test(token) ||
|
||||
/^AKIA[0-9A-Z]{12,}$/.test(token) ||
|
||||
mayBeSecret(token),
|
||||
)
|
||||
)
|
||||
@@ -224,6 +357,25 @@ function privacyReason(text) {
|
||||
return longNumber ? 'number' : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A value after "bearer" that is not a word a place's name is made of
|
||||
* ("Bearer Island"); after "Authorization:" any value is a token.
|
||||
*/
|
||||
function bearerToken(line) {
|
||||
if (/\bauthori[sz]ation\s*:\s*bearer\b\s*\S/i.test(line)) return true;
|
||||
for (const match of line.matchAll(/\bbearer\b(\s*[:=#]?\s*)(\S+)/gi)) {
|
||||
const value = match[2].replace(/[,.;:!?)]+$/, '');
|
||||
// Only a word after a space may be a name: "Bearer: island" is a token.
|
||||
if (/^\s+$/.test(match[1]) && PLACE_WORDS.test(value)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Words a place's name is made of, after a label word ("bearer island"). */
|
||||
const PLACE_WORDS =
|
||||
/^(?:island|islands|isle|lake|creek|river|point|bay|mountain|mount|hill|hills|valley|station|road|street|lane|avenue|park|beach|falls|springs?|county|city|town|village|plaza|square|mall|center|centre|tower|building|court|bank)$/i;
|
||||
|
||||
/**
|
||||
* A code after a label that can only be a code, without a colon ("PIN
|
||||
* A7B2", "verification code ABCDEF", "otp 7GH2K"): holding a digit, or in
|
||||
@@ -231,6 +383,48 @@ function privacyReason(text) {
|
||||
* "GATE CODE LANE", "OTP Bank" and "Auth Code ABCD Street" stay places.
|
||||
*/
|
||||
function codeAfterLabel(line) {
|
||||
// Labels that only ever name a code take one in lower case too ("otp
|
||||
// abcdef", "cvv abc", "verification code abcdef"); a capitalised word
|
||||
// after them is a name ("OTP Bank", "MFA Boston").
|
||||
// After a label in lower case, any value is a code ("verification code
|
||||
// Abc"); after one written as a name, only a value that is not one.
|
||||
const coded =
|
||||
/\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,})(?:\s+(?:thanks|thank you|thx|please|pls|ok))?\s*[.!]?\s*$/i.exec(
|
||||
line,
|
||||
);
|
||||
if (coded) {
|
||||
const [, label, value] = coded;
|
||||
const labelIsName = /\p{Lu}/u.test(label);
|
||||
// A word a place's name is made of is no code ("security code plaza",
|
||||
// "otp bank"); after the short labels a code in letters is written in
|
||||
// capitals ("otp ABCDEF"), so a lower-case word is a name ("mfa
|
||||
// boston").
|
||||
const shortLabel = /^(?:otp|2fa|mfa)\b/i.test(label);
|
||||
const named =
|
||||
PLACE_WORDS.test(value) || (shortLabel && /^\p{Ll}+$/u.test(value));
|
||||
if (!labelIsName && !named) return true;
|
||||
// After a label written as a name, a value in capitals is a code ("OTP
|
||||
// ABCDEF", "Verification code ABC"), one capitalised a name ("OTP
|
||||
// Bank"); a CVV is never a name.
|
||||
if (labelIsName) {
|
||||
if (/^cv[vc]\b/i.test(label)) return true;
|
||||
if (/^\p{Lu}[\p{Lu}\d-]+$/u.test(value) && !PLACE_WORDS.test(value))
|
||||
return true;
|
||||
if (!/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(value)) return true;
|
||||
}
|
||||
}
|
||||
// A value in mixed case that is no name ("PIN aBcD", "gate code aBcD").
|
||||
const mixed =
|
||||
/\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,})\s*[.!]?\s*$/i.exec(
|
||||
line,
|
||||
);
|
||||
if (
|
||||
mixed &&
|
||||
/\p{Ll}/u.test(mixed[1]) &&
|
||||
/\p{Lu}/u.test(mixed[1]) &&
|
||||
!/^\p{Lu}\p{Ll}+$/u.test(mixed[1])
|
||||
)
|
||||
return true;
|
||||
const match =
|
||||
/\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,})\s*[.!]?\s*$/i.exec(
|
||||
line,
|
||||
@@ -238,7 +432,9 @@ function codeAfterLabel(line) {
|
||||
if (!match) return false;
|
||||
const [, label, value] = match;
|
||||
if (/\d/.test(value)) return true;
|
||||
return value === value.toUpperCase() && label !== label.toUpperCase();
|
||||
// A code in capitals ("PIN ABCD", "GATE CODE ABCD"), but not a word a
|
||||
// place's name is made of ("GATE CODE LANE").
|
||||
return value === value.toUpperCase() && !PLACE_WORDS.test(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,6 +488,43 @@ export function resetPlaceSuggestions() {
|
||||
shared.pending.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Countries that write a house's number before its street ("10 Downing
|
||||
* Street", "12 rue de Rivoli"); elsewhere it follows ("Hauptstraße 12").
|
||||
*/
|
||||
const NUMBER_FIRST = new Set([
|
||||
'US',
|
||||
'CA',
|
||||
'GB',
|
||||
'IE',
|
||||
'AU',
|
||||
'NZ',
|
||||
'FR',
|
||||
'LU',
|
||||
'MC',
|
||||
'ZA',
|
||||
'IN',
|
||||
'PH',
|
||||
'SG',
|
||||
'MY',
|
||||
'HK',
|
||||
'TH',
|
||||
'LK',
|
||||
'NG',
|
||||
'GH',
|
||||
'KE',
|
||||
'JM',
|
||||
'TT',
|
||||
]);
|
||||
|
||||
/** A house's number and street as its country writes them, or ''. */
|
||||
export function houseAddress({ houseNumber, street, countryCode }) {
|
||||
if (!houseNumber || !street) return '';
|
||||
return NUMBER_FIRST.has(String(countryCode || 'US').toUpperCase())
|
||||
? `${houseNumber} ${street}`
|
||||
: `${street} ${houseNumber}`;
|
||||
}
|
||||
|
||||
/** List Photon candidates while typing. The submitted search owns navigation. */
|
||||
export function createPlaceSuggester({
|
||||
endpoint,
|
||||
@@ -308,7 +541,14 @@ export function createPlaceSuggester({
|
||||
const text = String(query ?? '')
|
||||
.trim()
|
||||
.slice(0, MAX_QUERY_CHARS);
|
||||
if (!enabled || text.length < minPlaceChars(text) || mayBePrivate(text))
|
||||
// A line longer than a place's name is never sent: a pasted sentence
|
||||
// or phrase is no place, and may be private in ways not read here.
|
||||
if (
|
||||
!enabled ||
|
||||
text.length < minPlaceChars(text) ||
|
||||
text.split(/\s+/).length > suggestMaxWords(text) ||
|
||||
mayBePrivate(text)
|
||||
)
|
||||
return [];
|
||||
const language = (globalThis.document?.documentElement?.lang || 'en')
|
||||
.slice(0, 2)
|
||||
@@ -384,11 +624,17 @@ export function createPlaceSuggester({
|
||||
type,
|
||||
street,
|
||||
housenumber: houseNumber,
|
||||
locality,
|
||||
district,
|
||||
} = feature.properties ?? {};
|
||||
// A house has no name of its own: its street and number are its
|
||||
// name, so two houses on one street stay two places.
|
||||
const address =
|
||||
street && houseNumber ? `${houseNumber} ${street}` : '';
|
||||
// A house has no name of its own: its street (or, without one, its
|
||||
// locality) and number are its name, written in the country's own
|
||||
// order, so two houses on one street stay two places.
|
||||
const address = houseAddress({
|
||||
houseNumber,
|
||||
street: street || locality || district || city,
|
||||
countryCode,
|
||||
});
|
||||
const name = normalized.name || address || city || state || country;
|
||||
if (!name) continue;
|
||||
const detail = [...new Set([city, state, country])]
|
||||
|
||||
@@ -3,8 +3,10 @@ import test from 'node:test';
|
||||
import {
|
||||
citiesInRegion,
|
||||
createPlaceSuggester,
|
||||
houseAddress,
|
||||
inExtent,
|
||||
mayBePrivate,
|
||||
onlyNumbersLookPrivate,
|
||||
resetPlaceSuggestions,
|
||||
} from './placeSuggestions.js';
|
||||
|
||||
@@ -394,7 +396,6 @@ test('streets named for keys, tokens and codes, and ZIP+4 after a state, are pla
|
||||
'GATE CODE LANE',
|
||||
'SECURITY CODE PLAZA',
|
||||
'OTP Bank',
|
||||
'MFA BOSTON',
|
||||
'Auth Code ABCD Street',
|
||||
'California 90210-1234',
|
||||
'Austin Texas 78701-1234',
|
||||
@@ -402,7 +403,10 @@ test('streets named for keys, tokens and codes, and ZIP+4 after a state, are pla
|
||||
'12, 10115 Berlin',
|
||||
])
|
||||
assert.equal(mayBePrivate(line), false, line);
|
||||
// All in capitals, a name cannot be told from a code: "MFA BOSTON" is
|
||||
// kept back with "OTP ABCDEF".
|
||||
for (const line of [
|
||||
'MFA BOSTON',
|
||||
'gate code: abcd',
|
||||
'PIN A7B2',
|
||||
'PIN is A7B2',
|
||||
@@ -427,3 +431,191 @@ test('the same text asked again while its request is out is sent once', async ()
|
||||
await Promise.all([service.suggest('Paris'), service.suggest('Paris')]);
|
||||
assert.equal(sent, 1);
|
||||
});
|
||||
|
||||
test('spelled-out emails, addresses, phrases, codes and short phone numbers stay private', () => {
|
||||
for (const line of [
|
||||
'john(at)gmail.com',
|
||||
'john[at]gmail[dot]com',
|
||||
'john at gmail dot de',
|
||||
'10.0.0.1',
|
||||
'abandon ability able about above absent absorb abstract absurd abuse access accident',
|
||||
'Abandon ability able about above absent absorb abstract absurd abuse access accident acid',
|
||||
'license ABC1234',
|
||||
'passport X1234567',
|
||||
'plate 7ABC123',
|
||||
'otp ABCDEF',
|
||||
'verification code abcdef',
|
||||
'cvv abc',
|
||||
'Bearer abcdef',
|
||||
'Bearer Abcdefgh',
|
||||
'Authorization: Bearer Xyz',
|
||||
'glpat-abcdef123456',
|
||||
'hf_abcdefghijk',
|
||||
'SG.abcdefghij.klmnopqrstuv',
|
||||
'https://x.com/?code=abcdef',
|
||||
'code 4821',
|
||||
'garage code 4821',
|
||||
'lockbox 4821',
|
||||
'the code to my door is 4821',
|
||||
'AB 12 34 56 C',
|
||||
'my id is AB12345',
|
||||
'My ID 12345',
|
||||
'john at gmail .com',
|
||||
'john at gmail punto com',
|
||||
'john.doe at example period com',
|
||||
'j o h n @ g m a i l . c o m',
|
||||
'ssn is 123456',
|
||||
'ssn: xxx-xx-1234',
|
||||
'Bearer: island',
|
||||
'Bearer=lake',
|
||||
'OTP ABCDEF',
|
||||
'CVV ABC',
|
||||
'Verification code ABC',
|
||||
'PIN ABCD',
|
||||
'passport:123456',
|
||||
'ID:12345',
|
||||
'abandon please abandon abandon abandon abandon abandon abandon abandon abandon abandon abstract',
|
||||
'find abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon',
|
||||
'lockbox number 4821',
|
||||
'lockbox is 4821',
|
||||
'ab 12 34 56 c',
|
||||
'https://[::1]/',
|
||||
'ssn 123',
|
||||
'Jo 12345-6789',
|
||||
'Joe 1234 12345 thanks',
|
||||
'Mo 0171 12345',
|
||||
])
|
||||
assert.equal(mayBePrivate(line), true, line);
|
||||
// A phone's three and four digits are not offered as an address.
|
||||
assert.equal(onlyNumbersLookPrivate('is 555 0100 thanks'), false);
|
||||
});
|
||||
|
||||
test('places that only looked private are looked up', () => {
|
||||
for (const line of [
|
||||
'Akiak',
|
||||
'Bearer Island',
|
||||
'SSN Station',
|
||||
'Bearer Island, Canada',
|
||||
'bearer island',
|
||||
'Washington DC 20500-0003',
|
||||
'東京都千代田区100-0001',
|
||||
'Security Code Plaza',
|
||||
'Idaho Falls',
|
||||
'meet at 12:30:45',
|
||||
'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch',
|
||||
'llanfairpwllgwyngyll',
|
||||
'Boise ID 83702',
|
||||
'Boise, ID 83702',
|
||||
'Hayden ID 83835-1234',
|
||||
'mfa boston',
|
||||
'otp bank',
|
||||
'security code plaza',
|
||||
'zip code 90210',
|
||||
'area code 415',
|
||||
'Settipalle @ K.Bandarlapalle',
|
||||
'boise ID 83702',
|
||||
"Coeur d'Alene ID 83814",
|
||||
'meet at West Point tomorrow',
|
||||
'OTP Bank',
|
||||
'GATE CODE LANE',
|
||||
// Questions for the assistant, however many short words they have.
|
||||
'can you tell where the most flights are going over texas today',
|
||||
'are there any storms near florida right now that might cause delays',
|
||||
'OTP Bank',
|
||||
// A long request is not a recovery phrase.
|
||||
'show flights over texas near austin with altitude above thirty thousand feet please',
|
||||
'show fires near austin then show flights above texas with labels please',
|
||||
])
|
||||
assert.equal(mayBePrivate(line), false, line);
|
||||
});
|
||||
|
||||
test('a house is named by its number and street in the order its country writes them', async () => {
|
||||
assert.equal(
|
||||
houseAddress({
|
||||
houseNumber: '10',
|
||||
street: 'Downing Street',
|
||||
countryCode: 'gb',
|
||||
}),
|
||||
'10 Downing Street',
|
||||
);
|
||||
assert.equal(
|
||||
houseAddress({
|
||||
houseNumber: '12',
|
||||
street: 'Hauptstraße',
|
||||
countryCode: 'DE',
|
||||
}),
|
||||
'Hauptstraße 12',
|
||||
);
|
||||
assert.equal(houseAddress({ houseNumber: '12', street: '' }), '');
|
||||
// Without a street, a house's number and its locality name it, so two
|
||||
// houses in one hamlet stay two places, not the city twice.
|
||||
const house = (number) => ({
|
||||
geometry: { type: 'Point', coordinates: [11.2, 47.6] },
|
||||
properties: {
|
||||
housenumber: number,
|
||||
locality: 'Mittenwald Au',
|
||||
city: 'Mittenwald',
|
||||
country: 'Germany',
|
||||
countrycode: 'de',
|
||||
osm_value: 'house',
|
||||
},
|
||||
});
|
||||
const service = createPlaceSuggester({
|
||||
endpoint: 'https://fixture.test/api/',
|
||||
fetchImpl: async () =>
|
||||
Response.json({ features: [house('3'), house('5')] }),
|
||||
});
|
||||
assert.deepEqual(
|
||||
(await service.suggest('Mittenwald Au')).map((place) => place.name),
|
||||
['Mittenwald Au 3', 'Mittenwald Au 5'],
|
||||
);
|
||||
});
|
||||
|
||||
test('codes, phones, tokens, emails and addresses in further shapes stay private', () => {
|
||||
for (const line of [
|
||||
// A phone's three and four digits after a name, as a postcode can't be
|
||||
// told from it ("Shibuya 150-0002" is refused for that).
|
||||
'Alice 555-0100',
|
||||
'Shibuya 150-0002',
|
||||
`${Array(23).fill('abandon').join(' ')} art`,
|
||||
'Bearer Abcdefghijklmnopqrstuvwxyz',
|
||||
'Bearer Island bearer abcdef',
|
||||
'verification code Abc',
|
||||
'verification code ABC',
|
||||
'verification code abc thanks',
|
||||
'PIN aBcD',
|
||||
'gate code aBcD',
|
||||
'john at gmail.com',
|
||||
'john at gmail (dot) com',
|
||||
'john at gmail [dot] com',
|
||||
'john at gmail dot technology',
|
||||
'passport number 123456',
|
||||
'passport no. 123456',
|
||||
'ID AB123',
|
||||
'::1',
|
||||
'fe80::1',
|
||||
'2001:db8:0:0:0:0:2:1',
|
||||
])
|
||||
assert.equal(mayBePrivate(line), true, line);
|
||||
});
|
||||
|
||||
test('a line longer than a place name is never sent for suggestions', async () => {
|
||||
let sent = 0;
|
||||
const service = createPlaceSuggester({
|
||||
endpoint: 'https://fixture.test/api/',
|
||||
fetchImpl: async () => {
|
||||
sent++;
|
||||
return Response.json({ features: [] });
|
||||
},
|
||||
});
|
||||
assert.deepEqual(
|
||||
await service.suggest('one two three four five six seven eight nine'),
|
||||
[],
|
||||
);
|
||||
assert.equal(sent, 0);
|
||||
// An address has more words: as many as the Omnibar reads as a place.
|
||||
await service.suggest('350 Fifth Avenue, New York, NY 10118, United States');
|
||||
assert.equal(sent, 1);
|
||||
await service.suggest('1 2 3 4 5 6 7 8 9 10 11');
|
||||
assert.equal(sent, 1);
|
||||
});
|
||||
+3
-88
@@ -9,7 +9,6 @@
|
||||
// entity comes last.
|
||||
|
||||
import { msg } from '../i18n/index.js';
|
||||
import { parseCoordinateQuery } from '../search/coordinateParser.js';
|
||||
|
||||
/** Visual styles, by the words people use for them. */
|
||||
const STYLES = [
|
||||
@@ -287,11 +286,6 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) {
|
||||
.trim();
|
||||
const end = /(?<!(?:^|[\s.])\p{L})[.!。]+$/u;
|
||||
line = line.replace(end, '');
|
||||
// A verb typed twice ("hide hide everything") is one.
|
||||
line = line.replace(
|
||||
/^((?:turn|switch) (?:on|off)|show|hide|remove|enable|disable|clear|go to|fly to)\s+\1\b/i,
|
||||
'$1',
|
||||
);
|
||||
// "please" is dropped only around a request: "Please Touch Museum",
|
||||
// "Kindly Lane" and "Pretty Please" are names.
|
||||
const polite = line
|
||||
@@ -373,66 +367,6 @@ const GO_TAIL =
|
||||
const SEPARATORS =
|
||||
/(\s*(?:,|;(?!\s*[-+]?\d)|\+(?!\d)|&|\band then\b|\bthen\b|\band\b|\balso\b)\s*)/;
|
||||
|
||||
/**
|
||||
* Places whose own name holds "and" (or "&"), kept whole after "near" or
|
||||
* "in" instead of read as two places: "flights near Trinidad and Tobago".
|
||||
*/
|
||||
const COMPOUND_PLACES = new Set([
|
||||
'trinidad and tobago',
|
||||
'antigua and barbuda',
|
||||
'bosnia and herzegovina',
|
||||
'saint kitts and nevis',
|
||||
'st kitts and nevis',
|
||||
'st. kitts and nevis',
|
||||
'saint vincent and the grenadines',
|
||||
'st vincent and the grenadines',
|
||||
'st. vincent and the grenadines',
|
||||
'sao tome and principe',
|
||||
'são tomé and príncipe',
|
||||
'turks and caicos',
|
||||
'turks and caicos islands',
|
||||
'wallis and futuna',
|
||||
'saint pierre and miquelon',
|
||||
'heard island and mcdonald islands',
|
||||
'svalbard and jan mayen',
|
||||
'south georgia and the south sandwich islands',
|
||||
'newfoundland and labrador',
|
||||
'jammu and kashmir',
|
||||
'andaman and nicobar islands',
|
||||
'dadra and nagar haveli',
|
||||
'brighton and hove',
|
||||
]);
|
||||
const isCompoundPlace = (first, second) =>
|
||||
COMPOUND_PLACES.has(`${first} and ${second}`.toLowerCase());
|
||||
|
||||
/**
|
||||
* Lower case one character at a time, so the line keeps its length and
|
||||
* "İstanbul" reads "istanbul" (not "i̇stanbul" with a combining dot).
|
||||
*/
|
||||
function lowerEach(text) {
|
||||
return Array.from(text, (char) =>
|
||||
char === 'İ' ? 'i' : char.toLowerCase().normalize('NFC'),
|
||||
).join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* A place as it was typed: "İstanbul", "iPhone store", "McAllen" are kept,
|
||||
* where the line read them in lower case. A place the line put together
|
||||
* ("Trinidad and Tobago" from "Trinidad & Tobago") stays as read.
|
||||
*/
|
||||
export function asTypedIn(raw, place) {
|
||||
const lowered = lowerEach(raw).replace(/\s+/g, ' ');
|
||||
const spaced = raw.replace(/\s+/g, ' ');
|
||||
if (lowered.length !== spaced.length) return place;
|
||||
const at = lowered.indexOf(place);
|
||||
if (at < 0) return place;
|
||||
const before = lowered[at - 1];
|
||||
const after = lowered[at + place.length];
|
||||
if (/[\p{L}\p{N}]/u.test(before || '') || /[\p{L}\p{N}]/u.test(after || ''))
|
||||
return place;
|
||||
return spaced.slice(at, at + place.length);
|
||||
}
|
||||
|
||||
function tidy(text) {
|
||||
return text.replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
@@ -481,7 +415,7 @@ export function parseOmnibar(
|
||||
{ isEntity = () => false } = {},
|
||||
) {
|
||||
const raw = String(text || '').trim();
|
||||
const line = tidy(lowerEach(raw)).replace(
|
||||
const line = tidy(raw.toLowerCase()).replace(
|
||||
/\b(black[- ]and[- ]white|b ?& ?w)\b/g,
|
||||
'noir',
|
||||
);
|
||||
@@ -549,7 +483,6 @@ export function parseOmnibar(
|
||||
for (let i = 0; i < clauses.length; i += 2) {
|
||||
let clause = tidy(clauses[i]);
|
||||
const separator = clauses[i - 1]?.trim();
|
||||
const afterPlace = previousHadPlace;
|
||||
const afterPlaceComma = previousHadPlace && separator === ',';
|
||||
// "trinidad and tobago": a bare place joined to a bare place by "and".
|
||||
const afterBarePlaceAnd = previousBarePlace && separator === 'and';
|
||||
@@ -593,14 +526,7 @@ export function parseOmnibar(
|
||||
const addPlace = (value, { bare = false, leftover = false } = {}) => {
|
||||
if (!value) return;
|
||||
if (leftover) placeClauses.add(i);
|
||||
// "near Trinidad and Tobago", "in Bosnia & Herzegovina": one place.
|
||||
const joinsName =
|
||||
place &&
|
||||
afterPlace &&
|
||||
(separator === 'and' || separator === '&') &&
|
||||
isCompoundPlace(place.split(', ').at(-1), value);
|
||||
if (joinsName) place += ` and ${value}`;
|
||||
else if (place && bare && afterBarePlaceAnd) place += ` and ${value}`;
|
||||
if (place && bare && afterBarePlaceAnd) place += ` and ${value}`;
|
||||
else if (place && !afterPlaceComma) {
|
||||
if (separator === 'and') extraPlaces.push(value);
|
||||
return;
|
||||
@@ -908,18 +834,7 @@ export function parseOmnibar(
|
||||
// Thermal"): no plan runs on Enter; the line may still be a name.
|
||||
const unasked = steps.length > 0 && steps.every((step) => !asked.has(step));
|
||||
if (place && !placeFrom) placeFrom = placeBare ? 'bare' : 'near';
|
||||
if (place) {
|
||||
// A grid reference is read only as typed ("14R PU 2090 4906"; in lower
|
||||
// case it may be words), so the plan keeps it so.
|
||||
const typed = asTypedIn(raw, place);
|
||||
if (!parseCoordinateQuery(place) && parseCoordinateQuery(typed))
|
||||
place = typed;
|
||||
const step = { kind: 'place', place };
|
||||
// How the place was typed, for its label only ("İstanbul", "iPhone
|
||||
// store"); kept off the step's fields, which plans compare.
|
||||
Object.defineProperty(step, 'shown', { value: asTypedIn(raw, place) });
|
||||
steps.unshift(step);
|
||||
}
|
||||
if (place) steps.unshift({ kind: 'place', place });
|
||||
steps.verb = LAYER_OFF.test(line) || LAYER_ON.test(line) || GO.test(line);
|
||||
// Following happens once the camera has settled on the new view.
|
||||
steps.sort((a, b) => (a.kind === 'follow') - (b.kind === 'follow'));
|
||||
|
||||
+12
-84
@@ -22,7 +22,6 @@ import {
|
||||
hasActionVerb,
|
||||
isPanelText,
|
||||
isRealQuestion,
|
||||
asTypedIn,
|
||||
isWholeMapClear,
|
||||
magnitudeFloor,
|
||||
normalizeLine,
|
||||
@@ -153,9 +152,6 @@ const SETTINGS_FOR =
|
||||
const SWITCH =
|
||||
/^(turn on|switch on|enable|show|display|add|turn off|switch off|disable|hide|remove|toggle)(?:\s+(.*))?$/;
|
||||
const SWITCH_OFF = /^(turn off|switch off|disable|hide|remove)\b/;
|
||||
/** "hide everything except …", "turn off all layers but …". */
|
||||
const EXCEPT =
|
||||
/^(?:turn off|switch off|disable|hide|remove|clear)\s+(?:everything|all(?: the)?(?: other)?(?: layers?)?|every layer)\s+(?:except(?: for)?|but(?: for)?|other than|apart from|besides|save for)\s+(.+)$/;
|
||||
// Layers people reach for first, so "turn on" offers these before the rest.
|
||||
export const POPULAR_LAYERS = [
|
||||
'flights',
|
||||
@@ -397,19 +393,12 @@ const SMALL_WORDS = new Set([
|
||||
'da',
|
||||
'des',
|
||||
]);
|
||||
/**
|
||||
* A place's name for a row: as typed when it has a capital ("iPhone store",
|
||||
* "McAllen", "İstanbul"), else each word capitalised but the small joining
|
||||
* ones ("santa fe de bogotá" reads "Santa Fe de Bogotá").
|
||||
*/
|
||||
export const titleCase = (text) =>
|
||||
/\p{Lu}/u.test(text)
|
||||
? text
|
||||
: text.replace(/\S+/g, (word, at) =>
|
||||
at > 0 && SMALL_WORDS.has(word)
|
||||
? word
|
||||
: word[0].toUpperCase() + word.slice(1),
|
||||
);
|
||||
text.replace(/\S+/g, (word, at) =>
|
||||
at > 0 && SMALL_WORDS.has(word)
|
||||
? word
|
||||
: word[0].toUpperCase() + word.slice(1),
|
||||
);
|
||||
|
||||
const STYLE_LABELS = {
|
||||
noir: msg('Style: Noir'),
|
||||
@@ -718,7 +707,7 @@ export function matchCommands(text) {
|
||||
export function stepLabel(step) {
|
||||
switch (step.kind) {
|
||||
case 'place':
|
||||
return titleCase(step.shown ?? step.place);
|
||||
return titleCase(step.place);
|
||||
case 'layer':
|
||||
return step.enabled
|
||||
? t('{layer} on', { layer: step.layer.shown })
|
||||
@@ -830,13 +819,12 @@ const askRow = (text) => ({
|
||||
label: t('Ask GEV: “{query}”', { query: text }),
|
||||
hint: t('Opens chat'),
|
||||
});
|
||||
/** `shown`: the place as typed, for the label ("İstanbul", "iPhone store"). */
|
||||
const placeRow = (place, shown = place) => ({
|
||||
const placeRow = (place) => ({
|
||||
key: `place:${place}`,
|
||||
kind: 'place',
|
||||
icon: 'location_on',
|
||||
place,
|
||||
label: t('Go to {place}', { place: titleCase(shown) }),
|
||||
label: t('Go to {place}', { place: titleCase(place) }),
|
||||
hint: t('Place or coordinates'),
|
||||
});
|
||||
/**
|
||||
@@ -932,55 +920,7 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
|
||||
* line is not such a switch, or names nothing to switch and may be a place
|
||||
* ("Show Low, AZ").
|
||||
*/
|
||||
/**
|
||||
* "hide everything except flights", "turn off all but ships": a plan that
|
||||
* switches off every layer that is on but the ones named. Null when the
|
||||
* line is not that, or names no layer to keep.
|
||||
*/
|
||||
function exceptRows(line, ask) {
|
||||
const match = EXCEPT.exec(line.toLowerCase());
|
||||
if (!match) return null;
|
||||
const kept = match[1]
|
||||
.split(/\s*(?:,|\band\b|&)\s*/)
|
||||
.map((term) => matchLayers(term)[0])
|
||||
.filter(named);
|
||||
if (!kept.length) return null;
|
||||
const keptIds = new Set(kept.map((layer) => layer.id));
|
||||
const steps = all()
|
||||
.filter((layer) => layer.enabled && !keptIds.has(layer.id))
|
||||
.map((layer) => ({ kind: 'layer', layer, enabled: false }));
|
||||
if (!steps.length)
|
||||
return [
|
||||
{
|
||||
key: 'none',
|
||||
kind: 'none',
|
||||
icon: 'layers',
|
||||
label: t('No other layers are on'),
|
||||
hint: '',
|
||||
},
|
||||
ask,
|
||||
];
|
||||
return [
|
||||
{
|
||||
key: `plan:${JSON.stringify(steps)}`,
|
||||
kind: 'plan',
|
||||
icon: 'bolt',
|
||||
steps,
|
||||
label: steps.map(stepLabel).join(' · '),
|
||||
hint: t('Do all'),
|
||||
},
|
||||
ask,
|
||||
];
|
||||
}
|
||||
|
||||
function switchRows(line, ask) {
|
||||
const excepted = exceptRows(line, ask);
|
||||
if (excepted) return excepted;
|
||||
// "remove flights from the map": the map is where every layer is.
|
||||
line = line.replace(
|
||||
/\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i,
|
||||
'',
|
||||
);
|
||||
const switching = line.toLowerCase().match(SWITCH);
|
||||
if (
|
||||
!switching ||
|
||||
@@ -1109,7 +1049,7 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
|
||||
realPlaces.length
|
||||
? realPlaces
|
||||
: place.trim().length >= minPlaceChars(place)
|
||||
? [placeRow(place, asTypedIn(text, place))]
|
||||
? [placeRow(place)]
|
||||
: [];
|
||||
|
||||
const titled = writtenAsName(text.split(/\s+/));
|
||||
@@ -1320,7 +1260,7 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
|
||||
...(placeStep ? placeRows(placeStep.place).slice(0, 2) : []),
|
||||
// "near New York and Paris": the plan goes to the first; the others
|
||||
// are offered rather than dropped.
|
||||
...extraPlaces.map((extra) => placeRow(extra, asTypedIn(text, extra))),
|
||||
...extraPlaces.map((extra) => placeRow(extra)),
|
||||
...steps
|
||||
.filter((step) => step.kind === 'layer')
|
||||
.map((step) => layerRow(step.layer, step.enabled)),
|
||||
@@ -1329,23 +1269,11 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
|
||||
// without a verb may be part of the place's name, so the whole line as a
|
||||
// place comes first and the plan second. After "go to …" with a request
|
||||
// peeled off, the place is the one read ("go to London with flights").
|
||||
// A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom",
|
||||
// "Radio City Music Hall") begins that name: the leftover is a fragment,
|
||||
// not a place, so no plan goes there. "tokyo traffic" and "Thermal,
|
||||
// California" (a comma parts them) keep their plans.
|
||||
const lower = text.toLowerCase();
|
||||
const fragment =
|
||||
ambiguous &&
|
||||
!peeled &&
|
||||
placeStep &&
|
||||
!/[,;]/.test(text) &&
|
||||
lower.endsWith(placeStep.place.toLowerCase()) &&
|
||||
!lower.startsWith(placeStep.place.toLowerCase());
|
||||
if (ambiguous)
|
||||
return withEntities(
|
||||
[
|
||||
peeled ? placeRow(placeStep.place, placeStep.shown) : placeRow(text),
|
||||
...(fragment ? [] : [plan]),
|
||||
placeRow(peeled ? placeStep.place : text),
|
||||
plan,
|
||||
...alternatives.filter((row) => row.kind !== 'place'),
|
||||
ask,
|
||||
],
|
||||
|
||||
@@ -646,100 +646,3 @@ test('several switches in one line are one plan', () => {
|
||||
assert.equal(rows[defaultIndex].kind, 'plan', text);
|
||||
}
|
||||
});
|
||||
|
||||
test('a place named with "and" stays whole, and a place keeps how it was typed', () => {
|
||||
const omnibar = createOmnibar({
|
||||
layers: [{ id: 'flights', name: 'Live Flights', enabled: false }],
|
||||
});
|
||||
const first = (text) => omnibar.rows(text, { places: [] }).rows[0];
|
||||
const plan = first('flights near Trinidad and Tobago');
|
||||
assert.equal(plan.kind, 'plan');
|
||||
assert.equal(plan.steps[0].place, 'trinidad and tobago');
|
||||
assert.equal(
|
||||
first('flights near Bosnia & Herzegovina').steps[0].place,
|
||||
'bosnia and herzegovina',
|
||||
);
|
||||
// Two places joined by "and" are still two.
|
||||
assert.equal(
|
||||
first('flights near Austin and Dallas').steps[0].place,
|
||||
'austin',
|
||||
);
|
||||
// "İstanbul" is searched without a stray combining dot, and labelled as typed.
|
||||
const istanbul = first('show flights in İstanbul');
|
||||
assert.equal(istanbul.steps[0].place, 'istanbul');
|
||||
assert.match(istanbul.label, /^İstanbul /);
|
||||
assert.equal(first('iPhone store').label, 'Go to iPhone store');
|
||||
});
|
||||
|
||||
test('"everything except" keeps the layers named and switches off the rest', () => {
|
||||
const omnibar = createOmnibar({
|
||||
layers: layers(['flights', 'radio', 'cctv']),
|
||||
});
|
||||
const first = (text) => omnibar.rows(text, { places: [] }).rows[0];
|
||||
for (const text of [
|
||||
'hide everything except flights',
|
||||
'turn off all but live flights',
|
||||
'clear everything other than flights',
|
||||
]) {
|
||||
const plan = first(text);
|
||||
assert.equal(plan.kind, 'plan', text);
|
||||
assert.deepEqual(
|
||||
plan.steps.map(stepOutcome),
|
||||
['layer(radio,off)', 'layer(cctv,off)'],
|
||||
text,
|
||||
);
|
||||
}
|
||||
assert.deepEqual(
|
||||
first('hide everything except flights and cctv').steps.map(stepOutcome),
|
||||
['layer(radio,off)'],
|
||||
);
|
||||
const alone = createOmnibar({ layers: layers(['flights']) });
|
||||
assert.equal(
|
||||
alone.rows('hide everything except flights').rows[0].kind,
|
||||
'none',
|
||||
);
|
||||
// Naming no layer to keep is not this reading.
|
||||
assert.notEqual(first('hide everything except the coast').kind, 'plan');
|
||||
});
|
||||
|
||||
test('"from the map" and a doubled verb do not change the request', () => {
|
||||
assert.equal(
|
||||
outcome('remove flights from the map', { on: ['flights'] }),
|
||||
'layer(flights,off)',
|
||||
);
|
||||
assert.equal(
|
||||
outcome('hide flights off the globe', { on: ['flights'] }),
|
||||
'layer(flights,off)',
|
||||
);
|
||||
assert.equal(normalizeLine('show show flights'), 'show flights');
|
||||
assert.equal(normalizeLine('turn off turn off flights'), 'turn off flights');
|
||||
});
|
||||
|
||||
test('a grid reference after "near" is the place', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
const plan = omnibar.rows('flights near 14R PU 2090 4906', { places: [] })
|
||||
.rows[0];
|
||||
assert.equal(plan.kind, 'plan');
|
||||
assert.equal(plan.steps[0].kind, 'place');
|
||||
assert.match(plan.steps[0].place, /^14R PU 2090 4906$/i);
|
||||
});
|
||||
|
||||
test('a keyword that begins a name offers no plan to the rest of it', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const text of [
|
||||
'Radio City Music Hall',
|
||||
'Traffic Island',
|
||||
'radio island',
|
||||
]) {
|
||||
const { rows } = omnibar.rows(text, { places: [] });
|
||||
assert.equal(rows[0].kind, 'place', text);
|
||||
assert.ok(!rows.some((row) => row.kind === 'plan'), text);
|
||||
assert.ok(
|
||||
rows.some((row) => row.kind === 'layer'),
|
||||
text,
|
||||
);
|
||||
}
|
||||
// A keyword after the place still offers its plan.
|
||||
const { rows } = omnibar.rows('tokyo traffic', { places: [] });
|
||||
assert.ok(rows.some((row) => row.kind === 'plan'));
|
||||
});
|
||||
@@ -935,7 +935,11 @@ function onKeydown(event) {
|
||||
if (!items.value.length && !chips.length) return;
|
||||
event.preventDefault();
|
||||
dismissed.value = false;
|
||||
const down = event.key === 'ArrowDown';
|
||||
// When the list opens upward (read bottom-up) the keys follow the
|
||||
// screen: Up moves away from the field.
|
||||
const list = document.getElementById('gev-omnibar-list');
|
||||
const upward = list && getComputedStyle(list).flexDirection === 'column-reverse';
|
||||
const down = (event.key === 'ArrowDown') !== upward;
|
||||
if (inStrip.value) {
|
||||
inStrip.value = false;
|
||||
active.value = down ? 0 : items.value.length - 1;
|
||||
|
||||
Reference in new issue
Block a user