@x-tech-laboratories/x-app 0.107.0 → 0.108.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
@@ -15,7 +15,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
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
17
  | `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
- | `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. |
18
+ | `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
19
  | `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`. |
20
20
  | `durations` | `parse_duration` for settings such as `"2h30m"`, `format_duration` in months down to seconds and "less than a second" below one, `format_age`, and `format_clock` for a playing time such as `"3:07"`, with `{ hours: "always" }` writing `"0:03:07"` so a column of times lines up and `empty` for no time. |
21
21
  | `log` | Loggers by scope and level from a setting such as `"warn,play:debug"`; a malformed setting falls back instead of silencing logging, and a setting read through a function applies to loggers made before it arrived; a dotted scope such as `app.core.db` without its own level takes its nearest parent's. |
@@ -221,6 +221,9 @@ The rest of an app's files are short calls into X-App too:
221
221
  - **Nix**: X-App's flake has a `lib` with `package`, `desktop_package`, `module`, `shell` and `android_shell`, each
222
222
  taking the app's package set and its `nix/app.nix` (name, display name, variables' prefix, port, database file and
223
223
  words); the app's `nix/flake.nix` takes `github:x-tech-laboratories/X-App` as an input and calls them.
224
+ An app with git dependencies names each lock entry's https URL in `git_dependencies`, which the packages fetch and
225
+ copy in, and `link_scheme`, such as `"codex"`, makes the desktop entry open its links; the desktop wrapper sets
226
+ `<PREFIX>_LAUNCHER` so the login entry runs the installed command.
224
227
  - **Android**: `npm run build:android` builds the phone's page and runs `x-app-android`, which makes or updates the
225
228
  Capacitor project in `android/`, so the app keeps only `capacitor.config.json` and leaves `android/` out of git.
226
229
  - **CI**: the app's `ci` job runs `x-tech-laboratories/X-App/.github/actions/app-ci@main`, its `nix` job
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "vite";
2
+ export declare function has_package(root: string, name: string): boolean;
3
+ export declare function capacitor_stand_in(root?: string): Plugin;
@@ -0,0 +1,33 @@
1
+ // Stands in for Capacitor in an app that has no phone app: the base app's page loads its phone host only on a phone,
2
+ // but the bundler still follows that import, so without Capacitor installed the build would fail. An app that has
3
+ // Capacitor gets the real one.
4
+ // ── Imports ──────────────────────────────────────────────────────────────────
5
+ import { createRequire } from "node:module";
6
+ import { join } from "node:path";
7
+ // ── Stand-ins ────────────────────────────────────────────────────────────────
8
+ // What the base app takes from each package, none of which a page off the phone ever calls.
9
+ const stand_ins = {
10
+ "@capacitor/core": `export function registerPlugin() { throw new Error("Capacitor is not installed in this app."); }\nexport const Capacitor = { getPlatform: () => "web", isNativePlatform: () => false };\n`,
11
+ "@capacitor/app": `export const App = { addListener: () => { throw new Error("Capacitor is not installed in this app."); } };\n`,
12
+ };
13
+ const prefix = "\0x-app-capacitor:";
14
+ // Whether the app at root has the package installed.
15
+ export function has_package(root, name) {
16
+ try {
17
+ createRequire(join(root, "package.json")).resolve(name);
18
+ return true;
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ }
24
+ // Points the Capacitor imports at stand-ins when the app at root, the working directory unless given, lacks them.
25
+ export function capacitor_stand_in(root = process.cwd()) {
26
+ const missing = new Set(Object.keys(stand_ins).filter((name) => !has_package(root, name)));
27
+ return {
28
+ name: "x-app-capacitor-stand-in",
29
+ enforce: "pre",
30
+ resolveId: (source) => (missing.has(source) ? prefix + source : null),
31
+ load: (id) => (id.startsWith(prefix) ? stand_ins[id.slice(prefix.length)] : null),
32
+ };
33
+ }
@@ -3,6 +3,7 @@
3
3
  import { resolve } from "node:path";
4
4
  import react from "@vitejs/plugin-react";
5
5
  import { externalizeDepsPlugin } from "electron-vite";
6
+ import { capacitor_stand_in } from "./capacitor.js";
6
7
  export function desktop_vite_config(options = {}) {
7
8
  const daemon = options.daemon === undefined ? "src/daemon/main.ts" : options.daemon;
8
9
  return {
@@ -16,7 +17,7 @@ export function desktop_vite_config(options = {}) {
16
17
  },
17
18
  renderer: {
18
19
  root: resolve("src/web"),
19
- plugins: [react()],
20
+ plugins: [react(), capacitor_stand_in()],
20
21
  build: { rollupOptions: { input: { index: resolve("src/web/index.html") } } },
21
22
  },
22
23
  };
@@ -1,6 +1,7 @@
1
1
  // The base app's Vite configs: the page for a browser, and the page for the phone app, built from src/web.
2
2
  // ── Imports ──────────────────────────────────────────────────────────────────
3
3
  import react from "@vitejs/plugin-react";
4
+ import { capacitor_stand_in } from "./capacitor.js";
4
5
  // The page for a browser, with relative paths so a proxy can serve it under a folder; the dev page reaches the API
5
6
  // through the separately running server.
6
7
  export function web_vite_config({ port }) {
@@ -8,9 +9,10 @@ export function web_vite_config({ port }) {
8
9
  return {
9
10
  root: "src/web",
10
11
  base: "./",
11
- plugins: [react()],
12
+ plugins: [react(), capacitor_stand_in()],
12
13
  build: { outDir: "../../out/web", emptyOutDir: true },
13
- server: { proxy: { "/api": server, "/login": server } },
14
+ // With the slash, so the page's own src/web/api.ts is served by Vite rather than sent to the server.
15
+ server: { proxy: { "/api/": server, "/login": server } },
14
16
  };
15
17
  }
16
18
  // ── Android ──────────────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-tech-laboratories/x-app",
3
- "version": "0.107.0",
3
+ "version": "0.108.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": {