@x-tech-laboratories/x-app 0.110.0 → 0.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
14
14
  | `app/services` | An app's own work beside its calls, run by both hosts: `StartServices` gets a `HostContext` (`kind`, `database()`, `profile`, `device_name`, the server's raw `config`, `plugins_folder`, `declared_file` from `<PREFIX>_DECLARED_FILE` or `/etc/<id>/declared.json`, `announce`, `emit(event, data)` for the page's `on_event`, `side_database(name)` for a never-backed-up file such as `<base>-index.db`, `back_up`) and returns `HostServices` (`before_restore`, `after_restore`, `stop`), stopped before sync and the database. |
15
15
  | `app/links` | `app_link(scheme, route)` and `route_of_link(scheme, link)`: an app's links such as `x-notes://note/<id>` and the page route they open. |
16
16
  | `app/desktop`, `app/preload` | `run_desktop(app, electron, { main_dir })`: Electron's main process as a portal onto this computer's daemon or a server, with the window (`default_size` fixed or from the screen's free area, the daemon told while one is in front for its services' `window_in_front`), the tray (`show_tray_icon`, the app's own `tray` rows above Show, Quit and Quit completely, closing the last window leaving the app in it, `--hidden` starting there), the app's `link_scheme` links opening the window on their page (`route_of_link` to map them its own way; the page follows the `open` event), the login entry, a second launch and `--daemon`; the app's own `desktop_settings` switches sit in Settings → Desktop app beside the base's; `run_preload(app, electron)` puts every bridge on the page. Electron is handed in, so neither imports it. An app with `local_mcp: { default_port }` serves its calls as MCP on 127.0.0.1 from the desktop daemon (`electron/mcp`, page-only calls left out, calls run as `program`), turned on under Settings → MCP server. |
17
+ | `app/window_size` | `fit_window_size(work_area)`: a first window of most of the screen's free area, between 960×640 and 1800×1200 and never past the screen; hand it to `run_desktop` as `default_size`. |
17
18
  | `app/web/app_page`, `app/web/page` | `render_app({ app, pages, general_settings })`: the page on the web, the desktop or Android in the `Shell`, with sign-in in a browser, Your account, Settings (the app's general sections, each page's own, Connections, Desktop app, Sync and Backups) and `SyncButton`; `page_hooks<Methods>()` gives the app's typed `calls`, `use_data` and `use_settings`. The phone's host (`app/web/android`) loads only on Android. The page API's `on_event(name, listener)` hears the named events the app's services `emit`, on the web and the desktop. A page may have an `icon` (the sidebar then shows icon rows), a `use_badge` hook ("Inbox · 3"), `in_sidebar: false` with `active_as` for a page reached only by its route; `default_page` names the page an empty route opens, and the `use_chrome(parts)` hook gives the `sidebar` content under the rows, header `tools` and a `side_pane`. `settings_categories(props)` adds the app's own Settings categories after General, for settings no one page owns. |
18
19
  | `config/vite`, `config/electron_vite`, `config/vitest`, `config/tsconfig/*.json` | An X-app's configs as presets: `web_vite_config({ port })` and `android_vite_config()` for the page, `desktop_vite_config()` for electron-vite's window, daemon, preload and page, `vitest_config()` for tests in `tests/` in UTC with coverage of `src/` to the terminal, merged with the app's own floor so `autoUpdate` still raises it, and `base`, `node`, `web` and `tests` tsconfigs to extend. The page presets stand in for Capacitor where the app has none installed (`config/capacitor`'s `capacitor_stand_in`), so a web and desktop app needs no phone packages, and the dev server proxies `/api/`, leaving the page's own `api.ts` to Vite. |
19
20
  | `app_new` | The `x-app-new <X-Name>` command: a new X-app's files written once, laid out as the Application Standard asks, on the base app, the presets, X-App's Nix lib and its CI actions, with an example notes feature; `--port`, `--folder`, `--no-desktop` and `--no-android`. |
@@ -57,7 +58,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
57
58
  | `certificates`, `certificate_protocol`, `electron/certificates` | Servers whose https certificate the device refuses, such as a home server's self-signed one: `check_certificate` reads the certificate and what is wrong with it (self-signed, unknown authority, wrong name, expired, not yet valid), `create_certificate_trust` keeps the ones the user trusts in a JSON file, each for its own host and exact fingerprint, re-checked before it is saved, and its `methods` are the page's calls; `trust_in_session` makes Chromium accept them in a session, the window's from the next start, and `trusting_fetch` sends the main process's requests, such as the sync client's, through a Chromium session made fresh each time the list changes, so a new choice holds at once; `use_in_node` also hands them to Node's own https, which then accepts a self-signed server whose name matches. |
58
59
  | `sync_file_storage` | `file_sync_storage({ file, back_up_before_replace })`: a sync peer's keys and paired devices in a JSON file on Node, written only its owner can read (mode 0600, tightened on an existing file too), a missing or unreadable file read as none. |
59
60
  | `web/sync_storage` | `local_sync_storage({ key, back_up_before_replace })`: the same in a phone page's own local storage. `SyncDeviceMethods` and `sync_device_methods(peer)` in `sync_protocol` and `sync_peer` are the calls every app's bridge answers for its page. |
60
- | `backups` | Named backups of an app's data in any store, newest first, with daily automatic ones kept to a set number; `keep_backing_up` takes them on a schedule the app keeps, and `BackupMethods` are the calls a page makes to whatever holds them. |
61
+ | `backups` | Named backups of an app's data in any store, newest first, with daily automatic ones kept to a set number; `keep_backing_up` takes them on a schedule the app keeps, `read_backup_schedule(saved)` reads a saved schedule back with the default where it is missing or damaged, and `BackupMethods` are the calls a page makes to whatever holds them. |
61
62
  | `phone_certificates` | `phone_certificates()`: the page's certificate calls on a phone, answered by X-App's Android plugin `XLibsCertificates`, which `cap sync` adds by itself: it reads a server's certificate and what is wrong with it, keeps the ones the user trusts for their own host and fingerprint, and installs a WebView client that lets the page's requests through to them, so `SyncSettings`, `SyncCertificatePrompt` and `TrustedCertificates` work on a phone as on the desktop. Forgetting one holds from the app's next start, since the WebView keeps a connection it already opened. An app that sets its own WebView client replaces that one. |
62
63
  | `phone_backups` | `phone_backups`: a phone app's `backups` in a folder the user picks once in its storage, where file managers and sync apps reach them, through X-App's Android plugin `XLibsBackupFolder`, which `cap sync` adds by itself; `restore` backs up first, swaps the phone database's bytes and saves, `folder_name` and `choose_folder` for the settings row, and daily backups wait quietly until a folder is picked. |
63
64
  | `phone_notices` | `keep_phone_notices`: notices handed to a phone ahead of time through Capacitor's local notifications, the app passing its own `LocalNotifications`, since a phone has no daemon; `refresh` takes back every pending notice and sets the soonest 64 of the next 14 days again, `ask_permission` asks once, `show` puts a notice up at once with no alarm (`isExactNotification: false`), so a notice for now never needs Android's exact-alarm leave or opens its settings screen, `exact: false` lets the notices set ahead ring inexactly too, and a tap hands the notice's `extra` back, such as a link to open. `notice_id` names a key as Android's number. |
@@ -0,0 +1,7 @@
1
+ export declare function fit_window_size(work_area: {
2
+ width: number;
3
+ height: number;
4
+ }): {
5
+ width: number;
6
+ height: number;
7
+ };
@@ -0,0 +1,7 @@
1
+ // The size a desktop app's first window opens at, worked out from the screen.
2
+ // Most of the screen's free area: room for a sidebar, a page and a side pane on a large screen, never past the screen.
3
+ // Hand it to `run_desktop` as `default_size`; once moved or resized, the window keeps where it was left.
4
+ export function fit_window_size(work_area) {
5
+ const within = (share, total, least, most) => Math.min(total, Math.max(least, Math.min(most, Math.round(total * share))));
6
+ return { width: within(0.85, work_area.width, 960, 1800), height: within(0.88, work_area.height, 640, 1200) };
7
+ }
package/dist/backups.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Backup, BackupSchedule } from "./backup_protocol.ts";
1
+ import { type Backup, type BackupSchedule } from "./backup_protocol.ts";
2
2
  export { backup_method_names, default_backup_schedule, type Backup, type BackupClient, type BackupMethods, type BackupSchedule } from "./backup_protocol.ts";
3
3
  export interface BackupNaming {
4
4
  pattern: RegExp;
@@ -26,6 +26,7 @@ export interface Backups {
26
26
  keep_automatic: (to_keep: number, interval_in_milliseconds?: number, now?: Date) => Promise<void>;
27
27
  }
28
28
  export declare function backups(naming: BackupNaming, store: BackupStore): Backups;
29
+ export declare function read_backup_schedule(saved: unknown): BackupSchedule;
29
30
  export interface KeepBackingUpOptions {
30
31
  check_every_ms?: number;
31
32
  on_error?: (error: unknown) => void;
package/dist/backups.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // Named backups of an app's data: the name says when each was taken and whether it was automatic, and daily ones keep a set number.
2
+ import { default_backup_schedule } from "./backup_protocol.js";
2
3
  export { backup_method_names, default_backup_schedule } from "./backup_protocol.js";
3
4
  const escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
5
  // Names such as tasks-2026-06-10T09-30-00Z-auto.db for the prefix "tasks" and the extension ".db", and
@@ -55,6 +56,15 @@ export function backups(naming, store) {
55
56
  };
56
57
  return { naming, list, create: (is_automatic) => create(is_automatic), remove, keep_automatic };
57
58
  }
59
+ // ── Schedule ─────────────────────────────────────────────────────────────────
60
+ // A schedule saved on the device, each part the default where it is missing or damaged.
61
+ export function read_backup_schedule(saved) {
62
+ const schedule = saved;
63
+ return {
64
+ automatic: typeof schedule?.automatic === "boolean" ? schedule.automatic : default_backup_schedule.automatic,
65
+ to_keep: typeof schedule?.to_keep === "number" && schedule.to_keep >= 0 ? Math.round(schedule.to_keep) : default_backup_schedule.to_keep,
66
+ };
67
+ }
58
68
  // Takes the automatic backups now and on every check; check again after the schedule changes. Returns the function that stops it.
59
69
  export function keep_backing_up(kept, schedule, options = {}) {
60
70
  const on_error = options.on_error ?? ((error) => console.error("automatic backup failed:", error));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-tech-laboratories/x-app",
3
- "version": "0.110.0",
3
+ "version": "0.112.0",
4
4
  "description": "Code the X-apps share: agents and their long runs, passwords and sign-in, the Fastify server pieces, durations, and the web page's helpers and widgets",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {