@x-tech-laboratories/x-app 0.111.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
@@ -58,7 +58,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
58
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. |
59
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. |
60
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. |
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, 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. |
62
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. |
63
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. |
64
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. |
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.111.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": {