@x-tech-laboratories/x-app 0.134.0 → 0.135.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
@@ -27,7 +27,7 @@ from a folder with its own `package.json` that depends on the agent package alon
27
27
  | `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`. |
28
28
  | `app/seed` | A development database of an app's example data, made by its own calls: `seed_app_database(app, { file, reset, seed })` opens a fresh file with the app's schema and hands `seed` the app's calls, refusing a file already there without `reset` (which takes its `-wal` and `-shm` too) and the desktop app's real database in `~/.config/<id>` (`real_database_path`) whatever path leads there; `run_seed(app, seed)` is the seed script's whole command line, `<file> [--reset]`, read by `seed_target`. |
29
29
  | `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, the theme kept in this browser or, for an app with `synced_theme`, in its synced setting, the sidebar's dragged width remembered on this device (`default_sidebar_width`) unless the chrome's `sidebar_width` holds it, Your account, Settings (the app's general sections, each page's own, Connections, Desktop app, Sync, Backups and Import and export, the settings as a file) 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`, a `side_pane`, a `contained` window where only the page scrolls with a `main_class` for its box, `around`, which wraps the page, such as in the app's own context or with dialogs over any page, and `bare` for the page alone with no sidebar or header, such as a strip embedded in another program. `settings_categories(props)` adds the app's own Settings categories after General, for settings no one page owns. A page's `children` fold open under its row in the sidebar (`#/diet/foods`, the title "Foods · Diet", the first shown when none is named, a single child leaving the page one row); its `use_items` hook gives rows worked out as the page runs, such as each paired device, folding open under it onto `#/devices/<id>` with the title "Pixel · Devices", and its `title(parts)` names the window for its route, such as "Job 12"; and `phone_services` loads the app's own work on the phone only there, such as reminders handed to Android, told of every write, every change from another device and each return to the app; an older version's backup schedule in the page's storage moves into the setting. In a browser, Settings ends with Users and Tokens (`users_settings`) for an admin of the server, with the app's `role_text`; an app's own `use_chrome` sidebar, such as a tree, sits under the pages' rows. |
30
- | `app/web/page_dashboards` | A page's own dashboards: a page declares `dashboard: { data_sources, ready_cards, initial, place }` and the base app draws `Dashboards` on its main route, above its view or in its place, each person's kept per page under the account preference `dashboards`, which every app's server allows and cleans with `clean_page_dashboards`, or on the device where no one signs in; the tabs' menu adds, renames, duplicates, resets and deletes them. |
30
+ | `app/web/page_dashboards` | A page's own dashboards: a page declares `dashboard: { data_sources, ready_cards, initial, place }` and the base app draws `Dashboards` on its main route, above its view, below it (`place: "below"`), where the view draws `PageDashboardsHere` (`"inline"`, such as under its heading) or in its place (`"only"`), each person's kept per page under the account preference `dashboards`, which every app's server allows and cleans with `clean_page_dashboards`, or on the device where no one signs in; the tabs' menu adds, renames, duplicates, resets and deletes them. |
31
31
  | `config/vite`, `config/electron_vite`, `config/vitest`, `config/electron_builder`, `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. `electron_builder_config({ id, name, app_id, comment, categories, link_scheme })` is the desktop app's AppImage and Flatpak bundle for electron-builder, the Flatpak keeping its data in `~/.config/<id>` as the other builds do, and reaching what else `flatpak_permissions` names, such as `--system-talk-name=org.bluez`. |
32
32
  | `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`. |
33
33
  | `idle_watch` | `step_idle_watch`: time away from the computer while something runs, such as a timer: each look at the idle seconds (the desktop's `get_idle_seconds`) moves the watch on, and once someone comes back it hands back the stretch away (`AwaySpan`) when it passed the threshold, a long gap between looks, as when the computer slept, counting as time away from the last look; `fresh_idle_watch` to start. |
@@ -1,14 +1,17 @@
1
1
  import "@x-tech-laboratories/halon/halon-tokens.css";
2
2
  import "@x-tech-laboratories/halon/halon.css";
3
3
  import type { App } from "../define.ts";
4
- import { type AppPages } from "./settings_page.tsx";
4
+ import type { AccountPrefsClient } from "../../web/react/account_prefs.ts";
5
+ import { type AppPage, type AppPages } from "./settings_page.tsx";
5
6
  export type { AppChrome, AppPage, AppPages, AppSubpage, PageSettingsProps } from "./settings_page.tsx";
6
7
  export type { PageDashboard } from "./page_dashboards.tsx";
8
+ export { PageDashboardsHere } from "./page_dashboards.tsx";
7
9
  export declare const default_sidebar_width: {
8
10
  default_width: number;
9
11
  min: number;
10
12
  max: number;
11
13
  };
14
+ export declare function with_dashboards(shown: AppPage, rest: string[], app_id: string, client: AccountPrefsClient | null): React.ReactNode;
12
15
  export declare function AppView({ pages }: {
13
16
  pages: AppPages;
14
17
  }): import("react").JSX.Element;
@@ -18,8 +18,9 @@ import { apply_theme_colors, local_theme_storage, pinned_theme_choice, read_serv
18
18
  import { phone_outside_fetch } from "../outside_fetch.js";
19
19
  import { desktop_api, is_android, is_desktop, web_api } from "./hosts.js";
20
20
  import { calls, data_watch, page, set_page_api, set_page_reach, use_data, use_settings } from "./page.js";
21
- import { PageDashboardsView } from "./page_dashboards.js";
21
+ import { PageDashboardsProvider, PageDashboardsView } from "./page_dashboards.js";
22
22
  import { SettingsView } from "./settings_page.js";
23
+ export { PageDashboardsHere } from "./page_dashboards.js";
23
24
  // ── Pages ────────────────────────────────────────────────────────────────────
24
25
  // Relative, so a server behind a proxy under a folder keeps it.
25
26
  const accounts = create_accounts_client({ base: "api" });
@@ -100,14 +101,19 @@ function use_default_page(pages) {
100
101
  return null;
101
102
  return pages.pages.some((each) => each.id === chosen.data) ? String(chosen.data) : fallback;
102
103
  }
104
+ // A page's view with its dashboards above it, below it, where it puts them or in its place, on its main route.
103
105
  // A page's view with its dashboards above it, or in its place, on its main route.
104
- function with_dashboards(shown, rest, app_id, client) {
106
+ export function with_dashboards(shown, rest, app_id, client) {
105
107
  if (!shown.dashboard || rest.length > 0)
106
108
  return shown.view(rest);
107
- const dashboards = _jsx(PageDashboardsView, { app_id: app_id, page_id: shown.id, dashboard: shown.dashboard, client: client });
109
+ const dashboards = _jsx("div", { className: "page", children: _jsx(PageDashboardsView, { app_id: app_id, page_id: shown.id, dashboard: shown.dashboard, client: client }) });
110
+ if (shown.dashboard.place === "inline")
111
+ return _jsx(PageDashboardsProvider, { dashboards: _jsx(PageDashboardsView, { app_id: app_id, page_id: shown.id, dashboard: shown.dashboard, client: client }), children: shown.view(rest) });
108
112
  if (shown.dashboard.place === "only")
109
- return _jsx("div", { className: "page", children: dashboards });
110
- return _jsxs(_Fragment, { children: [_jsx("div", { className: "page", children: dashboards }), shown.view(rest)] });
113
+ return dashboards;
114
+ if (shown.dashboard.place === "below")
115
+ return _jsxs(_Fragment, { children: [shown.view(rest), dashboards] });
116
+ return _jsxs(_Fragment, { children: [dashboards, shown.view(rest)] });
111
117
  }
112
118
  function Pages({ pages, account }) {
113
119
  const default_page = use_default_page(pages);
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from "react";
1
2
  import { type Dashboard } from "../../dashboard.ts";
2
3
  import type { AccountPrefsClient } from "../../web/react/account_prefs.ts";
3
4
  import { type DataSource, type ReadyCardKind } from "../../web/react/dashboard.tsx";
@@ -5,10 +6,15 @@ export interface PageDashboard {
5
6
  data_sources: DataSource[];
6
7
  ready_cards?: ReadyCardKind[];
7
8
  initial?: () => Dashboard;
8
- place?: "above" | "only";
9
+ place?: "above" | "below" | "inline" | "only";
9
10
  refresh_in_milliseconds?: number;
10
11
  }
11
12
  export declare const page_dashboards_pref = "dashboards";
13
+ export declare function PageDashboardsProvider({ dashboards, children }: {
14
+ dashboards: ReactNode;
15
+ children: ReactNode;
16
+ }): import("react").JSX.Element;
17
+ export declare function PageDashboardsHere(): import("react").JSX.Element;
12
18
  interface PageDashboardsProps {
13
19
  app_id: string;
14
20
  page_id: string;
@@ -1,8 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  // A page's own dashboards, as the base app draws them above the page: the app declares the data its cards may chart,
3
3
  // its ready-made cards and the dashboard each person starts with, and every person arranges their own, kept with their
4
4
  // account or, with no one signed in, on this device. The tabs' menu adds, renames, duplicates, resets and deletes them.
5
5
  // ── Imports ──────────────────────────────────────────────────────────────────
6
+ import { createContext, useContext } from "react";
6
7
  import { clean_page_dashboards } from "../../dashboard.js";
7
8
  import { use_account_pref } from "../../web/react/account_prefs.js";
8
9
  import { Dashboards } from "../../web/react/dashboard.js";
@@ -12,6 +13,16 @@ import { toast } from "../../web/react/toasts.js";
12
13
  import { data_watch } from "./page.js";
13
14
  // The account preference every page's dashboards are kept under, which the base app's server allows.
14
15
  export const page_dashboards_pref = "dashboards";
16
+ // ── Placing ──────────────────────────────────────────────────────────────────
17
+ const PlacedDashboards = createContext(null);
18
+ // Hands a page's dashboards to the `PageDashboardsHere` its view draws, for a page whose dashboards go "inline".
19
+ export function PageDashboardsProvider({ dashboards, children }) {
20
+ return _jsx(PlacedDashboards.Provider, { value: dashboards, children: children });
21
+ }
22
+ // Where a page that places its dashboards "inline" draws them in its view; nothing on any other page or route.
23
+ export function PageDashboardsHere() {
24
+ return _jsx(_Fragment, { children: useContext(PlacedDashboards) });
25
+ }
15
26
  // ── Keeping ──────────────────────────────────────────────────────────────────
16
27
  const no_dashboards = {};
17
28
  const is_page_dashboards = (value) => typeof value === "object" && value !== null && JSON.stringify(clean_page_dashboards(value)) === JSON.stringify(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-tech-laboratories/x-app",
3
- "version": "0.134.0",
3
+ "version": "0.135.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": {