Release Vulpes OS Preview 26 with Gecko 161.0 and Tundra 0.2.0
This commit is contained in:
parent
3a1fba4efe
commit
e241a42d2f
20 changed files with 1305 additions and 331 deletions
|
|
@ -1,8 +1,10 @@
|
|||
// Local alarms survive host restarts. They cannot wake a powered-off PC.
|
||||
export class Alarms {
|
||||
constructor(identity, launch, storage, schedule) {
|
||||
constructor(identity, launch, storage, schedule, cancelTimer) {
|
||||
this.storage = storage;
|
||||
this.schedule = schedule;
|
||||
this.cancelTimer = cancelTimer;
|
||||
this.timer = null;
|
||||
this.identity = identity;
|
||||
this.launch = launch;
|
||||
this.listeners = new Map();
|
||||
|
|
@ -11,15 +13,25 @@ export class Alarms {
|
|||
}
|
||||
async init() {
|
||||
this.state = (await this.storage.load()) || { nextId: 1, records: [], pending: [] };
|
||||
this.timer = this.schedule(() => this.serial(() => this.tick()).catch(console.error), 1000);
|
||||
this.updateTimer();
|
||||
}
|
||||
updateTimer() {
|
||||
if (this.state.records.length || this.state.pending.length || this.pendingDeliverySave) {
|
||||
if (this.timer === null) this.timer = this.schedule(() => this.serial(() => this.tick()).catch(console.error), 1000);
|
||||
} else if (this.timer !== null) {
|
||||
this.cancelTimer?.(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
}
|
||||
serial(fn) {
|
||||
const p = this.queue.then(fn);
|
||||
this.queue = p.catch(() => {});
|
||||
return p;
|
||||
}
|
||||
save() {
|
||||
return this.storage.save(this.state);
|
||||
async commit(next) {
|
||||
await this.storage.save(next);
|
||||
this.state = next;
|
||||
this.updateTimer();
|
||||
}
|
||||
cleanup(actor) {
|
||||
this.listeners.delete(actor);
|
||||
|
|
@ -42,11 +54,11 @@ export class Alarms {
|
|||
}));
|
||||
if (operation === 'add') {
|
||||
if (
|
||||
!Number.isFinite(date) ||
|
||||
!Number.isFinite(+new Date(date)) || !Number.isFinite(date) ||
|
||||
!['honorTimezone', 'ignoreTimezone'].includes(respectTimezone) ||
|
||||
!Array.isArray(local) ||
|
||||
local.length !== 7 ||
|
||||
!local.every(Number.isFinite)
|
||||
!local.every(Number.isInteger) || !Number.isFinite(+new Date(...local))
|
||||
)
|
||||
throw new Error('InvalidStateError');
|
||||
if (this.state.records.filter((r) => r.owner === app.id).length >= 256)
|
||||
|
|
@ -55,19 +67,18 @@ export class Alarms {
|
|||
if (encodedData.length > 65536) throw new Error('QuotaExceededError');
|
||||
const record = {
|
||||
owner: app.id,
|
||||
id: this.state.nextId++,
|
||||
id: this.state.nextId,
|
||||
date,
|
||||
respectTimezone,
|
||||
data: JSON.parse(encodedData),
|
||||
local,
|
||||
};
|
||||
this.state.records.push(record);
|
||||
await this.save();
|
||||
await this.commit({...this.state, nextId: record.id + 1, records: [...this.state.records, record]});
|
||||
return record.id;
|
||||
}
|
||||
if (operation === 'remove') {
|
||||
this.state.records = this.state.records.filter((r) => r.owner !== app.id || r.id !== id);
|
||||
await this.save();
|
||||
const keep = r => r.owner !== app.id || r.id !== id;
|
||||
await this.commit({...this.state, records: this.state.records.filter(keep), pending: this.state.pending.filter(keep)});
|
||||
return null;
|
||||
}
|
||||
if (operation === 'subscribe') {
|
||||
|
|
@ -92,9 +103,10 @@ export class Alarms {
|
|||
async tick() {
|
||||
const ready = this.state.records.filter((r) => this.due(r) <= Date.now());
|
||||
if (ready.length) {
|
||||
this.state.records = this.state.records.filter((r) => !ready.includes(r));
|
||||
this.state.pending.push(...ready.map((r) => ({ ...r, date: this.due(r) })));
|
||||
await this.save();
|
||||
await this.commit({...this.state,
|
||||
records: this.state.records.filter(r => !ready.includes(r)),
|
||||
pending: this.state.pending.concat(ready.map(r => ({...r, date: this.due(r)}))),
|
||||
});
|
||||
}
|
||||
let changed = false;
|
||||
for (const record of [...this.state.pending]) {
|
||||
|
|
@ -112,11 +124,19 @@ export class Alarms {
|
|||
} catch (_) {
|
||||
this.listeners.delete(receiver[0]);
|
||||
}
|
||||
} else if (Date.now() - (this.lastLaunch.get(record.owner) || 0) > 5000) {
|
||||
this.lastLaunch.set(record.owner, Date.now());
|
||||
} else {
|
||||
const now = Date.now();
|
||||
const previous = this.lastLaunch.get(record.owner);
|
||||
if (now >= previous && now - previous <= 5000) continue;
|
||||
this.lastLaunch.set(record.owner, now);
|
||||
this.launch(record.owner);
|
||||
}
|
||||
}
|
||||
if (changed) await this.save();
|
||||
if (changed) this.pendingDeliverySave = true;
|
||||
if (this.pendingDeliverySave) {
|
||||
await this.storage.save(this.state);
|
||||
this.pendingDeliverySave = false;
|
||||
this.updateTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export class NativeCamera {
|
|||
}
|
||||
if (!this.session || this.session.actor !== actor || this.session.id !== params.session)
|
||||
throw Error('CAMERA_NOT_OPEN');
|
||||
if (!['frame','focus','zoom','picture','flash'].includes(params.action)) throw Error('CAMERA_INVALID_COMMAND');
|
||||
if (!['frame','focus','focusMode','zoom','picture','flash'].includes(params.action)) throw Error('CAMERA_INVALID_COMMAND');
|
||||
let controlRejected = false;
|
||||
try {
|
||||
if (params.action === 'frame') {
|
||||
|
|
|
|||
|
|
@ -230,6 +230,10 @@ export class Platform {
|
|||
if (operation === 'power') return tundraHardware({operation:'power', action:params.action});
|
||||
if (operation === 'wifi') return tundraWifi(params);
|
||||
if (operation === 'deviceSettings') return tundraRadio('deviceSettings', params);
|
||||
if (operation === 'carrierName') {
|
||||
const network = await tundraRadio('mobileSettings', {action:'network'});
|
||||
return ['registered', 'roaming'].includes(network.status) ? network.operator || '' : '';
|
||||
}
|
||||
if (operation === 'mobileSettings') return tundraRadio('mobileSettings', params);
|
||||
if (operation === 'bluetooth') return tundraBluetooth(params);
|
||||
if (['callHistory','ackCallHistory'].includes(operation)) return this.radio(operation, params);
|
||||
|
|
@ -259,7 +263,7 @@ export class Platform {
|
|||
if (operation === 'snapshot') return tundraSnapshot();
|
||||
if (operation === 'capabilities') return {
|
||||
platform:'tundra', platformName:'Tundra', model:'Nokia 2720 Flip',
|
||||
adapter:{version:'0.1.0-dev',device:'beatles'}, tundra:'0.1.0-dev',
|
||||
adapter:{version:this.runtime.release.adapters.beatles,device:'beatles'}, tundra:this.runtime.release.tundra,
|
||||
version:this.runtime.release.version, gaia:this.runtime.release.gaia,
|
||||
gecko:Services.appinfo.platformVersion, hardwareStatus:true,
|
||||
radioStatus:true, wifiControl:Services.env.get('VULPES_TUNDRA_WIFI') === '1', camera:Services.env.get('VULPES_TUNDRA_CAMERA') === '1', media:true, contacts:true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {mmsPayload} from 'resource://vulpes/services/mms.mjs';
|
||||
import { setInterval, setTimeout, clearTimeout } from 'resource://gre/modules/Timer.sys.mjs';
|
||||
import { setInterval, clearInterval, setTimeout, clearTimeout } from 'resource://gre/modules/Timer.sys.mjs';
|
||||
import {Input} from 'resource://vulpes/host/Input.sys.mjs';
|
||||
import { ScreenPower } from 'resource://vulpes/services/screen-power.mjs';
|
||||
import { Packages } from 'resource://vulpes/services/packages.mjs';
|
||||
|
|
@ -237,7 +237,7 @@ export const Runtime = {
|
|||
load: async () => ((await IOUtils.exists(alarmPath)) ? IOUtils.readJSON(alarmPath) : null),
|
||||
save: (state) => IOUtils.writeJSON(alarmPath, state, { tmpPath: alarmPath + '.tmp' }),
|
||||
},
|
||||
setInterval,
|
||||
setInterval, clearInterval,
|
||||
);
|
||||
await this.alarms.init();
|
||||
this.dataStores = new DataStoreService(this.apps, storage, (data) =>
|
||||
|
|
@ -415,9 +415,11 @@ export const Runtime = {
|
|||
return { error: { code: 'INVALID_URL' } };
|
||||
}
|
||||
if (!['http', 'https'].includes(uri.scheme)) return { error: { code: 'URL_SCHEME_DENIED' } };
|
||||
const data = { type: 'url', url: uri.spec };
|
||||
if (typeof params.data.isPrivate === 'boolean') data.isPrivate = params.data.isPrivate;
|
||||
this.broadcast(
|
||||
'activity-view',
|
||||
{ source: { name: 'view', data: { type: 'url', url: uri.spec } } },
|
||||
{ source: { name: 'view', data } },
|
||||
'system',
|
||||
);
|
||||
return { result: null };
|
||||
|
|
@ -512,7 +514,7 @@ export const Runtime = {
|
|||
if (app.id !== 'system' || typeof params?.home !== 'boolean')
|
||||
return { error: { code: 'PERMISSION_DENIED' } };
|
||||
actor.browsingContext.top.embedderElement.ownerDocument.defaultView.setHomeSurface(
|
||||
params.home,
|
||||
params.home, params.powerSplash === true, params.trayOverHome === true, params.recents === true, params.dark === true, typeof params.appId === 'string' ? params.appId : '', params.lockscreen === true, params.bootSplash === true,
|
||||
);
|
||||
return { result: null };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ export function tundraCapabilities(release) {
|
|||
platform: 'tundra',
|
||||
platformName: 'Tundra',
|
||||
model: 'Google Pixel 3a',
|
||||
tundra: '0.1.0-dev',
|
||||
adapter: { version: '0.1.0-dev', device: 'sargo' },
|
||||
tundra: release.tundra,
|
||||
adapter: { version: release.adapters.sargo, device: 'sargo' },
|
||||
version: release.version,
|
||||
gaia: release.gaia,
|
||||
gecko: Services.appinfo.platformVersion,
|
||||
|
|
@ -102,6 +102,7 @@ export async function tundraRadio(operation, params = {}) {
|
|||
|
||||
let wifiScanPending = null;
|
||||
let wifiScanCache = null;
|
||||
let wifiGeneration = 0;
|
||||
const WIFI_SCAN_CACHE_MS = 5000;
|
||||
|
||||
export async function tundraWifi(params) {
|
||||
|
|
@ -110,7 +111,11 @@ export async function tundraWifi(params) {
|
|||
throw Error('WIFI_INVALID_REQUEST');
|
||||
if (params.operation !== 'scan') {
|
||||
try { return await wifiCommand(params); }
|
||||
finally { if (['connect','connectHidden','disconnect','forget','setEnabled','hotspotPower'].includes(params.operation)) wifiScanCache = null; }
|
||||
finally { if (['connect','connectHidden','disconnect','forget','setEnabled','hotspotPower'].includes(params.operation)) {
|
||||
wifiGeneration++;
|
||||
wifiScanPending = null;
|
||||
wifiScanCache = null;
|
||||
} }
|
||||
}
|
||||
// System and Settings share a broker: at most one Python scan client exists.
|
||||
if (wifiScanPending) return wifiScanPending;
|
||||
|
|
@ -118,14 +123,15 @@ export async function tundraWifi(params) {
|
|||
if (wifiScanCache.error) throw wifiScanCache.error;
|
||||
return wifiScanCache.result;
|
||||
}
|
||||
const generation = wifiGeneration;
|
||||
wifiScanPending = wifiCommand(params).then(result => {
|
||||
wifiScanCache = {result, expires:Date.now() + WIFI_SCAN_CACHE_MS};
|
||||
if (generation === wifiGeneration) wifiScanCache = {result, expires:Date.now() + WIFI_SCAN_CACHE_MS};
|
||||
return result;
|
||||
}, error => {
|
||||
// A missing interface must not turn retries into another process storm.
|
||||
wifiScanCache = {error, expires:Date.now() + WIFI_SCAN_CACHE_MS};
|
||||
if (generation === wifiGeneration) wifiScanCache = {error, expires:Date.now() + WIFI_SCAN_CACHE_MS};
|
||||
throw error;
|
||||
}).finally(() => { wifiScanPending = null; });
|
||||
}).finally(() => { if (generation === wifiGeneration) wifiScanPending = null; });
|
||||
return wifiScanPending;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,19 @@ function unescapeText(value) {
|
|||
return value.replace(/\\([nN,;\\])/g, (_, char) => /n/i.test(char) ? '\n' : char);
|
||||
}
|
||||
|
||||
// Split before decoding: escaped commas and semicolons belong to the field.
|
||||
function components(value, separator) {
|
||||
const result = [''];
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
if (value[i] === separator) result.push('');
|
||||
else {
|
||||
result[result.length - 1] += value[i];
|
||||
if (value[i] === '\\' && i + 1 < value.length) result[result.length - 1] += value[++i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function readVCards(raw) {
|
||||
const cards = [];
|
||||
let card;
|
||||
|
|
@ -17,10 +30,11 @@ export function readVCards(raw) {
|
|||
if (!card) throw Error('INVALID_VCARD');
|
||||
if (/^END:VCARD$/i.test(line)) {
|
||||
if (!card.name.length) {
|
||||
const name = [...(card.givenName || []), ...(card.familyName || [])].join(' ');
|
||||
const name = ['honorificPrefix','givenName','additionalName','familyName','honorificSuffix']
|
||||
.flatMap(key => card[key] || []).join(' ');
|
||||
if (name) card.name.push(name);
|
||||
}
|
||||
if (!card.name.length && !card.tel.length && !card.email.length) throw Error('INVALID_VCARD');
|
||||
if (!card.name.length && !card.tel.length && !card.email.length && !card.org?.length && !card.adr?.length && !card.url?.length && !card.nickname?.length) throw Error('INVALID_VCARD');
|
||||
cards.push(card);
|
||||
card = null;
|
||||
continue;
|
||||
|
|
@ -32,17 +46,39 @@ export function readVCards(raw) {
|
|||
const value = unescapeText(field[2]);
|
||||
if (key === 'FN') card.name = [value];
|
||||
if (key === 'N') {
|
||||
const [, family, given] = /^((?:\\.|[^;\\])*)(?:;((?:\\.|[^;\\])*))?/.exec(field[2]);
|
||||
if (family) card.familyName = [unescapeText(family)];
|
||||
if (given) card.givenName = [unescapeText(given)];
|
||||
const fields = ['familyName','givenName','additionalName','honorificPrefix','honorificSuffix'];
|
||||
components(field[2], ';').slice(0, fields.length).forEach((part, i) => {
|
||||
if (part) card[fields[i]] = components(part, ',').map(unescapeText);
|
||||
});
|
||||
}
|
||||
if (key === 'TEL' || key === 'EMAIL') {
|
||||
if (key === 'NICKNAME' || key === 'CATEGORIES') {
|
||||
const name = key === 'NICKNAME' ? 'nickname' : 'category';
|
||||
(card[name] ||= []).push(...components(field[2], ',').map(unescapeText));
|
||||
}
|
||||
if (key === 'ORG' || key === 'NOTE' || key === 'TITLE') {
|
||||
const name = {ORG:'org', NOTE:'note', TITLE:'jobTitle'}[key];
|
||||
(card[name] ||= []).push(key === 'ORG' ? components(field[2], ';').map(unescapeText).join(' / ') : value);
|
||||
}
|
||||
if (['TEL','EMAIL','URL','ADR'].includes(key)) {
|
||||
const types = params.flatMap(param => {
|
||||
if (param.includes('=') && !/^TYPE=/i.test(param)) return [];
|
||||
return param.replace(/^TYPE=/i, '').replace(/"/g, '').toLowerCase().split(',');
|
||||
}).filter(Boolean).map(type => type === 'cell' ? 'mobile' : type);
|
||||
const clean = key === 'TEL' ? value.replace(/^tel:/i, '') : value.replace(/^mailto:/i, '');
|
||||
if (clean) card[key.toLowerCase()].push({value: clean, type: types.length ? types : ['other']});
|
||||
const preferred = types.includes('pref') || params.some(param => /^PREF=1$/i.test(param));
|
||||
const labels = types.filter(type => type !== 'pref');
|
||||
const entry = {type: labels.length ? labels : ['other']};
|
||||
if (preferred) entry.pref = true;
|
||||
if (key === 'ADR') {
|
||||
const [box, extended, street, locality, region, postalCode, countryName] =
|
||||
components(field[2], ';').map(unescapeText);
|
||||
Object.assign(entry, {streetAddress:[box, extended, street].filter(Boolean).join('\n'),
|
||||
locality, region, postalCode, countryName});
|
||||
} else {
|
||||
entry.value = key === 'TEL' ? value.replace(/^tel:/i, '') :
|
||||
key === 'EMAIL' ? value.replace(/^mailto:/i, '') : value;
|
||||
if (!entry.value) continue;
|
||||
}
|
||||
(card[key.toLowerCase()] ||= []).push(entry);
|
||||
}
|
||||
}
|
||||
if (card || !cards.length) throw Error('INVALID_VCARD');
|
||||
|
|
|
|||
|
|
@ -9,12 +9,9 @@ export const Views = {
|
|||
uri?.filePath !== '/index.html') {
|
||||
throw new Error('SCREENSHOT_NOT_AVAILABLE');
|
||||
}
|
||||
const image = await context.currentWindowGlobal.drawSnapshot(null, 1, 'white');
|
||||
const doc = context.top.embedderElement?.ownerDocument;
|
||||
if (!doc) {
|
||||
image.close();
|
||||
throw new Error('SCREENSHOT_NOT_AVAILABLE');
|
||||
}
|
||||
if (!doc?.defaultView) throw new Error('SCREENSHOT_NOT_AVAILABLE');
|
||||
const image = await context.currentWindowGlobal.drawSnapshot(null, doc.defaultView.devicePixelRatio, 'white');
|
||||
const canvas = doc.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
|
||||
canvas.width = image.width;
|
||||
canvas.height = image.height;
|
||||
|
|
@ -211,6 +208,15 @@ export const Views = {
|
|||
if (flags & Ci.nsIWebProgressListener.STATE_STOP) {
|
||||
emit('loadend', { backgroundColor: 'rgb(255, 255, 255)' });
|
||||
emit('titlechange', browser.contentTitle || browser.currentURI.spec);
|
||||
const page = browser.browsingContext?.currentWindowGlobal;
|
||||
if (page && ['https', 'http'].includes(browser.currentURI.scheme)) {
|
||||
page.getActor('WebInput').sendQuery('Vulpes:PageIcon').then(icon => {
|
||||
if (!icon || browser.browsingContext?.currentWindowGlobal !== page) return;
|
||||
const href = new URL(icon.href);
|
||||
if (href.origin === new URL(browser.currentURI.spec).origin)
|
||||
emit('iconchange', {href:href.href, sizes:String(icon.sizes || '')});
|
||||
}).catch(() => {});
|
||||
}
|
||||
// Replacing a navigation cancels the previous request normally.
|
||||
if (!Components.isSuccessCode(status) && status !== Cr.NS_BINDING_ABORTED)
|
||||
emit('error', { type: 'other', status });
|
||||
|
|
|
|||
|
|
@ -46,7 +46,20 @@ export class VulpesChild extends JSWindowActorChild {
|
|||
const params = Cu.cloneInto(data, {});
|
||||
params.contextId = native.browsingContext.id;
|
||||
if (params.operation === 'geometry') {
|
||||
const rect = native.getBoundingClientRect();
|
||||
const bounds = native.getBoundingClientRect();
|
||||
const left = Math.max(0, bounds.left);
|
||||
let top = Math.max(0, bounds.top);
|
||||
if (this.document.location.hostname === 'system.localhost') {
|
||||
const bar = this.document.getElementById('statusbar');
|
||||
if (bar?.checkVisibility({checkOpacity:true, checkVisibilityCSS:true})) {
|
||||
const header = bar.getBoundingClientRect();
|
||||
if (header.top <= top && header.width > 0) top = Math.max(top, header.bottom);
|
||||
}
|
||||
}
|
||||
// Gaia's collapsing toolbar can scroll the iframe above the viewport.
|
||||
// Hit-test and position the native view within the same visible rectangle.
|
||||
const rect = {left, top, width: Math.min(win.innerWidth, bounds.right) - left,
|
||||
height: Math.min(win.innerHeight, bounds.bottom) - top};
|
||||
const unobscured = frameUnobscured(this.document, native, rect);
|
||||
params.geometry = {
|
||||
left: rect.left + win.mozInnerScreenX,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export class WebInputChild extends JSWindowActorChild {
|
|||
const editable = element?.isContentEditable || element?.localName === 'textarea' ||
|
||||
(element?.localName === 'input' && ['text','search','email','url','tel','password','number'].includes(element.type));
|
||||
if (!editable || element.disabled || element.readOnly) {
|
||||
if (event.type === 'click') this.sendAsyncMessage('Vulpes:InputFocus', null);
|
||||
if (event.type === 'click' && event.isTrusted) this.sendAsyncMessage('Vulpes:WebDismissInput', null);
|
||||
return;
|
||||
}
|
||||
this.editor ||= new InputEditor(this.contentWindow);
|
||||
|
|
@ -39,6 +39,25 @@ export class WebInputChild extends JSWindowActorChild {
|
|||
this.sendAsyncMessage('Vulpes:InputFocus', this.editor.state());
|
||||
}
|
||||
receiveMessage(message) {
|
||||
if (message.name === 'Vulpes:PageIcon') {
|
||||
const doc = this.document;
|
||||
const origin = doc.location.origin;
|
||||
const candidates = [...doc.querySelectorAll('link[rel~="icon" i][href]')]
|
||||
.map(link => ({href:link.href, sizes:link.getAttribute('sizes') || ''}));
|
||||
candidates.push({href:origin + '/favicon.ico', sizes:''});
|
||||
return (async () => {
|
||||
for (const candidate of candidates.slice(0, 12)) {
|
||||
let url;
|
||||
try { url = new URL(candidate.href); } catch { continue; }
|
||||
if (url.origin !== origin || !['https:', 'http:'].includes(url.protocol)) continue;
|
||||
const image = doc.createElement('img');
|
||||
image.src = url.href;
|
||||
try { await image.decode(); } catch { continue; }
|
||||
if (image.naturalWidth) return {href:url.href, sizes:candidate.sizes};
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
}
|
||||
if (message.name !== 'Vulpes:Edit' || !this.editor) throw Error('INPUT_CONTEXT_EXPIRED');
|
||||
return this.editor.edit(message.data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,16 @@ export class WebInputParent extends JSWindowActorParent {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (message.name === 'Vulpes:WebDismissInput') {
|
||||
if (!Runtime.identity(this) && Runtime.inputIdentity(this) && Runtime.input.focus) {
|
||||
const owner = Runtime.input.focus.actor;
|
||||
if (owner.browsingContext.top === this.browsingContext.top ||
|
||||
(Runtime.identity(owner)?.id === 'system' &&
|
||||
owner.browsingContext.top.embedderElement.ownerDocument ===
|
||||
this.browsingContext.top.embedderElement.ownerDocument)) Runtime.input.hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (message.name !== 'Vulpes:InputFocus') throw Error('METHOD_NOT_SUPPORTED');
|
||||
if (Runtime.identity(this)) return; // Bundled apps already use VulpesChild.
|
||||
Runtime.input.changed(this, message.data);
|
||||
|
|
|
|||
|
|
@ -256,3 +256,9 @@ html[data-vulpes-app] .vulpes-select-label {
|
|||
}
|
||||
html[dir=rtl][data-vulpes-app] .vulpes-select-label { inset: 0 1.1rem 0 3.5rem; }
|
||||
html[data-vulpes-theme=dark] .vulpes-select-label { color: #eee; }
|
||||
|
||||
html[data-vulpes-app="calendar"] #vulpes-value-selector [role="option"] > label {
|
||||
position: static;
|
||||
inset: auto;
|
||||
height: auto;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
if (releases.has(stream)) return releases.get(stream);
|
||||
if (current === stream) current = null;
|
||||
const release = Promise.resolve().then(async () => {
|
||||
await stream.vulpesFinishRecording?.();
|
||||
try { await stream.vulpesFinishRecording?.(); } catch (error) { recordError(error); }
|
||||
emit(stream, 'previewstatechange', {newState:'stopped'});
|
||||
// Stop the capture producer before detaching its consumers. Gecko can
|
||||
// otherwise block in srcObject=null while a GPU-backed frame is in use.
|
||||
|
|
@ -465,7 +465,7 @@
|
|||
thumbnailSizes: [],
|
||||
recorderProfiles: videoMime ? {webm:profile} : {},
|
||||
flashModes: native?.flashModes?.length ? native.flashModes : ['off'],
|
||||
focusModes: native ? (native.focusModes.includes('auto') ? ['auto','infinity'] : ['fixed']) : ['fixed'],
|
||||
focusModes: native?.focusModes?.length ? native.focusModes : ['fixed'],
|
||||
sceneModes: ['auto'],
|
||||
whiteBalanceModes: ['auto'],
|
||||
isoModes: ['auto'],
|
||||
|
|
@ -671,6 +671,20 @@
|
|||
const done=recording.done;stream.stopRecording();await done;
|
||||
},
|
||||
});
|
||||
if (native?.focusModes?.some(value => value.startsWith('continuous-'))) {
|
||||
let focusMode = null;
|
||||
Object.defineProperty(stream, 'focusMode', {
|
||||
configurable: true, get: () => focusMode,
|
||||
set(value) {
|
||||
if (value === focusMode || !native.focusModes.includes(value) || value === 'fixed') return;
|
||||
focusMode = value;
|
||||
stream.vulpesCameraControl({action:'focusMode',mode:value}).catch(error => {
|
||||
if (focusMode === value) focusMode = null;
|
||||
recordError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (native) Object.defineProperty(stream,'flashMode',{
|
||||
configurable:true, get:()=>flashMode,
|
||||
set(value) {
|
||||
|
|
|
|||
|
|
@ -275,9 +275,9 @@
|
|||
}
|
||||
if (type === 'screen-on') window.ScreenManager?.turnScreenOn(true);
|
||||
if (type === 'home' || type === 'holdhome') {
|
||||
if (window.VulpesPlatform === 'tundra' && type === 'home') {
|
||||
if (window.VulpesPlatform === 'tundra' && window.ScreenManager?.screenEnabled) {
|
||||
call('settings.get', {key:'vibration.enabled'}).then(setting => {
|
||||
if (setting.value !== false) navigator.vibrate(30);
|
||||
if (setting.value !== false) navigator.vibrate(type === 'holdhome' ? [30, 60, 30] : 30);
|
||||
}).catch(console.error);
|
||||
}
|
||||
call('activities.cancel', {}).catch(console.error);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,30 @@
|
|||
});
|
||||
}
|
||||
if (app === 'system') {
|
||||
if (window.VulpesPlatform === 'tundra' && window.VulpesNativeTelephony &&
|
||||
!window.VulpesNativeRadioStatus && !navigator.mozMobileConnections) {
|
||||
let revision = 0;
|
||||
const refreshCarrier = async () => {
|
||||
const element = document.getElementById('lockscreen-conn-states');
|
||||
const current = ++revision;
|
||||
if (!element) return;
|
||||
const key = 'ril.radio.disabled';
|
||||
const request = navigator.mozSettings.createLock().get(key);
|
||||
request.onsuccess = async () => {
|
||||
if (current !== revision) return;
|
||||
const line = document.createElement('span');
|
||||
if (request.result[key]) navigator.mozL10n.setAttributes(line, 'airplaneMode');
|
||||
else line.textContent = await VulpesCompat.call('platform.carrierName', {}).catch(() => '');
|
||||
if (current !== revision || !element.isConnected) return;
|
||||
element.replaceChildren(line);
|
||||
element.hidden = !request.result[key] && !line.textContent;
|
||||
};
|
||||
};
|
||||
navigator.mozSettings.addObserver('ril.radio.disabled', refreshCarrier);
|
||||
addEventListener('lockscreen-appopened', refreshCarrier);
|
||||
addEventListener('screenchange', event => { if (event.detail.screenEnabled) refreshCarrier(); });
|
||||
navigator.mozL10n.ready(refreshCarrier);
|
||||
}
|
||||
// Android reserves the edge swipe for its own shade. A tap on Gaia's
|
||||
// status bar provides access without competing with that system gesture.
|
||||
if (window.VulpesPlatform === 'android') {
|
||||
|
|
|
|||
|
|
@ -329,3 +329,18 @@ html[data-vulpes-layout="compact"][data-vulpes-app="homescreen"] gaia-app-icon[d
|
|||
background: #04060b; padding: 1rem; text-align: center; overflow-wrap: anywhere;
|
||||
height: auto; font-size: 1.4rem; line-height: 1.5;
|
||||
}
|
||||
|
||||
#sleep-menu-container gaia-buttons {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
#sleep-menu-container gaia-buttons > button {
|
||||
margin-inline: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* The scrolling panel already reserves the Home button inset. */
|
||||
html[data-vulpes-home-overlay][data-vulpes-layout="standard"][data-vulpes-app="homescreen"] body:not(.edit-mode) #apps {
|
||||
overflow: visible;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,19 @@
|
|||
}
|
||||
let pendingNetwork = null;
|
||||
function update(network, status = network ? 'connected' : 'disconnected') {
|
||||
const changed = manager.connection.status !== status || manager.connection.network?.ssid !== network?.ssid;
|
||||
const previous = manager.connection.network;
|
||||
const info = manager.connectionInformation;
|
||||
const changed = manager.connection.status !== status || previous?.ssid !== network?.ssid ||
|
||||
previous?.vulpesId !== network?.vulpesId;
|
||||
manager.connection = {status, network};
|
||||
manager.connectionInformation = status === 'connected' && network ? {...connectionInfo,relSignalStrength:network.relSignalStrength} : null;
|
||||
if (changed) emit('statuschange', manager.connection);
|
||||
// Gaia's signal listeners require the associated network. A scan while
|
||||
// disconnected must not announce connection information for a missing AP.
|
||||
if (manager.connectionInformation) emit('connectioninfoupdate', {network, ...manager.connectionInformation});
|
||||
const current = manager.connectionInformation;
|
||||
if (current && (changed || !info || Object.keys({...info, ...current}).some(k => info[k] !== current[k]))) {
|
||||
emit('connectioninfoupdate', {network, ...current});
|
||||
}
|
||||
}
|
||||
function applyState(state) {
|
||||
power(state.enabled === true);
|
||||
|
|
@ -37,13 +43,14 @@
|
|||
if (state.enabled && (state.state === 'connecting' || (pendingNetwork && state.state === 'disconnected'))) {
|
||||
const target = state.network;
|
||||
const network = target ? {ssid:target.ssid, security:securityTypes(target.security)} : pendingNetwork;
|
||||
if (network) update(network, 'connecting');
|
||||
update(network, 'connecting');
|
||||
return;
|
||||
}
|
||||
const network=state.state==='connected' && state.network;
|
||||
update(network ? {
|
||||
...networks.find(n => network.id ? n.vulpesId === network.id : n.connected && n.ssid === network.ssid),
|
||||
ssid:network.ssid,
|
||||
...(network.id ? {vulpesId:network.id} : {}),
|
||||
security:securityTypes(network.security),
|
||||
relSignalStrength:network.signal,savedId:network.savedId,connected:true
|
||||
} : null);
|
||||
|
|
|
|||
|
|
@ -231,20 +231,45 @@
|
|||
schedule();
|
||||
}
|
||||
if (app === 'system') {
|
||||
let previous;
|
||||
let bootComplete = false;
|
||||
let returningHome = false;
|
||||
let previous, previousSplash, previousTray, previousRecents, previousDark, previousApp, previousLockscreen, previousBoot;
|
||||
const navigation = () => {
|
||||
const active = document.querySelector('.appWindow.active');
|
||||
const home = !!active?.querySelector('iframe[src*="homescreen.localhost"]') &&
|
||||
if (!bootComplete && active && !document.querySelector('#os-logo, #carrier-logo')) bootComplete = true;
|
||||
const bootSplash = !bootComplete;
|
||||
const powerMenu = !!document.querySelector('#sleep-menu.visible');
|
||||
const home = !powerMenu && !!active?.querySelector('iframe[src*="homescreen.localhost"]') &&
|
||||
!document.querySelector('#screen.locked, .attentionWindow.active');
|
||||
if (home === previous) return;
|
||||
const lockscreen = !powerMenu && !!document.querySelector('#screen.locked, .lockScreenWindow.active') &&
|
||||
!document.querySelector('.attentionWindow.active');
|
||||
const powerSplash = !!document.getElementById('poweroff-splash');
|
||||
const trayOverHome = home && !!document.querySelector('#screen.utility-tray, #screen.utility-tray-in-transition');
|
||||
const frame = active?.querySelector('iframe');
|
||||
const appId = powerMenu ? 'power-menu' : frame?.src.match(/^http:\/\/([a-z0-9-]+)\.localhost(?=[:/])/)?.[1] || '';
|
||||
// Gaia clears cards-view at the start of the return animation.
|
||||
if (document.querySelector('#task-manager.to-home')) returningHome = true;
|
||||
else if (active || powerMenu || lockscreen || powerSplash) returningHome = false;
|
||||
const recents = !powerMenu && !lockscreen && !powerSplash &&
|
||||
(returningHome || !!document.querySelector('#screen.cards-view'));
|
||||
const dark = document.documentElement.dataset.vulpesTheme === 'dark';
|
||||
if (bootSplash === previousBoot && lockscreen === previousLockscreen && appId === previousApp && recents === previousRecents && dark === previousDark && home === previous && powerSplash === previousSplash && trayOverHome === previousTray) return;
|
||||
previousBoot = bootSplash;
|
||||
previousLockscreen = lockscreen;
|
||||
previousApp = appId;
|
||||
previousRecents = recents;
|
||||
previousDark = dark;
|
||||
previousTray = trayOverHome;
|
||||
previous = home;
|
||||
call('desktop.navigation', { home }).catch(console.error);
|
||||
previousSplash = powerSplash;
|
||||
call('desktop.navigation', { home, powerSplash, trayOverHome, recents, dark, appId, lockscreen, bootSplash }).catch(console.error);
|
||||
};
|
||||
new MutationObserver(navigation).observe(document.documentElement, { attributes: true, attributeFilter: ['data-vulpes-theme'] });
|
||||
new MutationObserver(navigation).observe(document.body, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
attributeFilter: ['class', 'src'],
|
||||
});
|
||||
navigation();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
/* Navigation matches the Android preview; Gaia owns the application theme. */
|
||||
[keypad] #home { display: none; }
|
||||
#home {
|
||||
:root { background-color: #f4f4f4; }
|
||||
:root[dark-surface] { background-color: #18232e; }
|
||||
[boot-splash] #home-bar, [lock-surface] #home-bar, [tray-over-home] #home-bar, [keypad] #home-bar, [power-splash] #home-bar { display: none; }
|
||||
:root[boot-splash] { background-color: #071d35; }
|
||||
[awaiting-gaia] #system { opacity: 0; }
|
||||
#home-bar {
|
||||
appearance: none;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
|
|
@ -13,8 +16,8 @@
|
|||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: #122332;
|
||||
color: white;
|
||||
background: var(--nav-background, transparent);
|
||||
color: var(--nav-ring, white);
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
position: fixed;
|
||||
|
|
@ -22,20 +25,50 @@
|
|||
left: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
[home-active] #home {
|
||||
[home-active]:not([recents], [lock-surface]) #home-bar {
|
||||
background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
|
||||
}
|
||||
[home-active][home-at-bottom] #home {
|
||||
[home-active][home-at-bottom]:not([recents]) #home-bar {
|
||||
background: transparent;
|
||||
}
|
||||
#home {
|
||||
appearance: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
touch-action: none;
|
||||
}
|
||||
#home::before {
|
||||
content: '';
|
||||
box-sizing: border-box;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 2px solid currentColor;
|
||||
box-shadow: 0 0 0 1px rgb(0 0 0 / 48%), inset 0 0 0 1px rgb(0 0 0 / 35%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
:root:is([data-nav-app="communications"], [data-nav-app="sms"], [data-nav-app="calendar"]) {
|
||||
--nav-background: #fff;
|
||||
--nav-ring: #657073;
|
||||
}
|
||||
:root:is([data-nav-app="settings"], [data-nav-app="email"], [data-nav-app="search"], [data-nav-app="marketplace"], [data-nav-app="camera"]) {
|
||||
--nav-ring: #657073;
|
||||
}
|
||||
:root[data-nav-app="fm"] { --nav-background: #2f3337; }
|
||||
:root:is([data-nav-app="power-menu"], [data-nav-app="costcontrol"]) { --nav-background: #4d4d4d; }
|
||||
:root[data-nav-app="gallery"] { --nav-background: #040505; }
|
||||
:root:is([data-nav-app="clock"], [data-nav-app="music"], [data-nav-app="video"]) { --nav-background: #2d2d2d; }
|
||||
:root[dark-surface]:is([data-nav-app="settings"], [data-nav-app="email"]) { --nav-ring: #b8c8d8; }
|
||||
:root:is([data-nav-app="communications"], [data-nav-app="sms"], [data-nav-app="calendar"],
|
||||
[data-nav-app="settings"], [data-nav-app="email"], [data-nav-app="search"],
|
||||
[data-nav-app="camera"], [data-nav-app="gallery"], [data-nav-app="music"],
|
||||
[data-nav-app="video"], [data-nav-app="clock"], [data-nav-app="fm"],
|
||||
[data-nav-app="costcontrol"], [data-nav-app="power-menu"], [data-nav-app="marketplace"]) #home::before { box-shadow: none; }
|
||||
#home:active::before {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
|
@ -45,9 +78,9 @@
|
|||
}
|
||||
|
||||
@media (orientation: landscape) {
|
||||
#home { left:auto; right:0; top:0; bottom:0; width:44px; height:100%; }
|
||||
[home-active] #home {
|
||||
#home-bar { left:auto; right:0; top:0; bottom:0; width:44px; height:100%; }
|
||||
[home-active]:not([recents], [lock-surface]) #home-bar {
|
||||
background:linear-gradient(to left, rgba(0,0,0,0.8), transparent);
|
||||
}
|
||||
[home-active][home-at-bottom] #home { background:transparent; }
|
||||
[home-active][home-at-bottom]:not([recents]) #home-bar { background:transparent; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,17 +115,26 @@ window.addEventListener('load', async () => {
|
|||
// their existing phone dimensions unless the launcher requests fullscreen.
|
||||
{
|
||||
const screen = document.getElementById('screen');
|
||||
const homeButton = document.getElementById('home');
|
||||
const homeBar = document.getElementById('home-bar');
|
||||
if (!keypadHost && Services.env.get('VULPES_TUNDRA') !== '1') {
|
||||
// A sleeping Gaia screen is inert. Handle wake in the desktop window.
|
||||
const wake = () => {
|
||||
if (screen.inert) Runtime.broadcast('screen-on', {}, 'system');
|
||||
};
|
||||
window.addEventListener('activate', wake);
|
||||
window.addEventListener('pointerdown', wake, true);
|
||||
window.addEventListener('keydown', wake, true);
|
||||
}
|
||||
const resize = () => {
|
||||
const landscape = window.innerWidth > window.innerHeight;
|
||||
const overlay = keypadHost || document.documentElement.hasAttribute('home-active');
|
||||
const overlay = keypadHost || document.documentElement.matches('[boot-splash], [recents], [power-splash], [home-active], [lock-surface]');
|
||||
const width = Math.max(1, window.innerWidth - (landscape && !overlay ? 44 : 0));
|
||||
const height = Math.max(1, window.innerHeight - (!landscape && !overlay ? 44 : 0));
|
||||
screen.style.width = width + 'px';
|
||||
screen.style.height = height + 'px';
|
||||
browser.style.width = width + 'px';
|
||||
browser.style.height = height + 'px';
|
||||
homeButton.style.width = landscape ? '44px' : window.innerWidth + 'px';
|
||||
homeBar.style.width = landscape ? '44px' : window.innerWidth + 'px';
|
||||
// Flush the embedder's layout before notifying the remote document.
|
||||
// On Wayland its initial viewport can otherwise remain 0x0 until an
|
||||
// unrelated chrome layout query, leaving Gaia and video unpainted.
|
||||
|
|
@ -134,7 +143,15 @@ window.addEventListener('load', async () => {
|
|||
|
||||
};
|
||||
window.addEventListener('resize', resize);
|
||||
window.setHomeSurface = (home) => {
|
||||
window.setHomeSurface = (home, powerSplash, trayOverHome, recents, dark, appId, lockscreen, bootSplash) => {
|
||||
document.documentElement.removeAttribute('awaiting-gaia');
|
||||
document.documentElement.toggleAttribute('boot-splash', bootSplash);
|
||||
document.documentElement.toggleAttribute('recents', recents);
|
||||
document.documentElement.toggleAttribute('dark-surface', dark);
|
||||
document.documentElement.toggleAttribute('lock-surface', lockscreen);
|
||||
document.documentElement.dataset.navApp = lockscreen || recents || home ? '' : appId;
|
||||
document.documentElement.toggleAttribute('tray-over-home', home && trayOverHome);
|
||||
document.documentElement.toggleAttribute('power-splash', powerSplash);
|
||||
document.documentElement.toggleAttribute('home-active', home);
|
||||
resize();
|
||||
};
|
||||
|
|
@ -196,10 +213,11 @@ window.addEventListener('load', async () => {
|
|||
held = false;
|
||||
home.title = 'Accueil · maintenir pour les applications ouvertes (Ctrl+Espace)';
|
||||
home.addEventListener('pointerdown', (event) => {
|
||||
if (event.button !== 0) return;
|
||||
if (event.button !== 0 || !Runtime.power.screenEnabled) return;
|
||||
held = false;
|
||||
home.setPointerCapture(event.pointerId);
|
||||
holdTimer = setTimeout(() => {
|
||||
if (!Runtime.power.screenEnabled) return;
|
||||
held = true;
|
||||
Views.hideAll();
|
||||
Runtime.broadcast('holdhome', {}, 'system');
|
||||
|
|
@ -210,7 +228,7 @@ window.addEventListener('load', async () => {
|
|||
home.addEventListener('pointerup', cancel);
|
||||
home.addEventListener('pointercancel', cancel);
|
||||
home.addEventListener('click', () => {
|
||||
if (!held) {Views.hideAll();Runtime.broadcast('home', {}, 'system');}
|
||||
if (!held && Runtime.power.screenEnabled) {Views.hideAll();Runtime.broadcast('home', {}, 'system');}
|
||||
held = false;
|
||||
});
|
||||
window.addEventListener('keydown', (event) => {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://vulpes/content/shell.css" type="text/css"?>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" windowtype="vulpes:host" title="Vulpes — port Gecko actuel" width="480" height="844">
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" windowtype="vulpes:host" boot-splash="" awaiting-gaia="" title="Vulpes — port Gecko actuel" width="480" height="844">
|
||||
<script src="chrome://global/content/customElements.js"/>
|
||||
<script src="chrome://vulpes/content/shell.js"/>
|
||||
<html:div id="screen" style="width:480px;height:800px;background:white;position:relative"/>
|
||||
<html:button id="home" aria-label="Accueil Vulpes" title="Accueil · maintenir pour les applications ouvertes"/>
|
||||
<html:div id="screen" style="width:100vw;height:100vh;background:#071d35;position:relative"/>
|
||||
<html:div id="home-bar"><html:button id="home" aria-label="Accueil Vulpes" title="Accueil · maintenir pour les applications ouvertes"/></html:div>
|
||||
</window>
|
||||
|
|
|
|||
Loading…
Reference in a new issue