@gjsify/adwaita-app 0.42.0 → 0.43.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.
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{resolveDefaultResponse as e}from"./dialog-model.js";import t from"@girs/adw-1";function confirmDialog(n,r){let i=e(r.defaultResponse);return new Promise(e=>{let a=new t.AlertDialog({heading:r.heading,body:r.body??``});a.add_response(`cancel`,r.cancelLabel??`Cancel`),a.add_response(`confirm`,r.confirmLabel??`OK`),a.set_response_appearance(`confirm`,r.destructive?t.ResponseAppearance.DESTRUCTIVE:t.ResponseAppearance.SUGGESTED),a.set_default_response(i),a.set_close_response(`cancel`),a.connect(`response`,(t,n)=>e(n===`confirm`)),a.present(n)})}function errorDialog(e,n,r){return new Promise(i=>{let a=new t.AlertDialog({heading:n,body:r??``});a.add_response(`ok`,`OK`),a.set_default_response(`ok`),a.set_close_response(`ok`),a.connect(`response`,()=>i()),a.present(e)})}export{confirmDialog,errorDialog};
1
+ import"./_virtual/_rolldown/runtime.js";import{resolveDefaultResponse as e}from"./dialog-model.js";import t from"@girs/adw-1";function confirmDialog(n,r){let i=e(r.defaultResponse);return new Promise(e=>{let a=new t.AlertDialog({heading:r.heading,body:r.body??``});a.add_response(`cancel`,r.cancelLabel??`Cancel`),a.add_response(`confirm`,r.confirmLabel??`OK`),a.set_response_appearance(`confirm`,r.destructive?t.ResponseAppearance.DESTRUCTIVE:t.ResponseAppearance.SUGGESTED),a.set_default_response(i),a.set_close_response(`cancel`),a.connect(`response`,(t,n)=>e(n===`confirm`)),a.present(n)})}function errorDialog(e,n,r,i){return new Promise(a=>{let o=new t.AlertDialog({heading:n,body:r??``});o.add_response(`ok`,i??`OK`),o.set_default_response(`ok`),o.set_close_response(`ok`),o.connect(`response`,()=>a()),o.present(e)})}export{confirmDialog,errorDialog};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{AdwaitaApp as e,runAdwaitaApp as t,runApplication as n}from"./application.js";import{readAppDevHooks as r}from"./dev-hooks.js";import{confirmDialog as i,errorDialog as a}from"./dialogs.js";import{pickFile as o,saveFile as s}from"./file-dialog.js";import{createNavShell as c}from"./nav-shell.js";import{LoadToken as l,loadIntoStack as u}from"./view-loader.js";import{LoadingStack as d}from"./loading-stack.js";import{registerToastOverlay as f,showToast as p}from"./toast.js";import{findNavItem as m,resolveInitialNavIndex as h}from"./nav-model.js";export{e as AdwaitaApp,l as LoadToken,d as LoadingStack,i as confirmDialog,c as createNavShell,a as errorDialog,m as findNavItem,u as loadIntoStack,o as pickFile,r as readAppDevHooks,f as registerToastOverlay,h as resolveInitialNavIndex,t as runAdwaitaApp,n as runApplication,s as saveFile,p as showToast};
1
+ import{AdwaitaApp as e,runAdwaitaApp as t,runApplication as n}from"./application.js";import{readAppDevHooks as r}from"./dev-hooks.js";import{confirmDialog as i,errorDialog as a}from"./dialogs.js";import{pickFile as o,saveFile as s}from"./file-dialog.js";import{createNavShell as c}from"./nav-shell.js";import{LoadToken as l,loadIntoStack as u}from"./view-loader.js";import{LoadingStack as d}from"./loading-stack.js";import{registerToastOverlay as f,showToast as p}from"./toast.js";import{SYSTEM_LOCALE_DIR as m,resolveLocaleDir as h}from"./locale-dir.js";import{initLocale as g}from"./locale.js";import{findNavItem as _,resolveInitialNavIndex as v}from"./nav-model.js";export{e as AdwaitaApp,l as LoadToken,d as LoadingStack,m as SYSTEM_LOCALE_DIR,i as confirmDialog,c as createNavShell,a as errorDialog,_ as findNavItem,g as initLocale,u as loadIntoStack,o as pickFile,r as readAppDevHooks,f as registerToastOverlay,v as resolveInitialNavIndex,h as resolveLocaleDir,t as runAdwaitaApp,n as runApplication,s as saveFile,p as showToast};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";const e=`/usr/share/locale`;function resolveLocaleDir(e={}){return nonEmpty(e.localeDir)??nonEmpty(e.env?.GJSIFY_LOCALE_DIR)??nonEmpty(e.fallbackDir)??`/usr/share/locale`}function nonEmpty(e){if(e===void 0)return;let t=e.trim();return t===``?void 0:t}export{e as SYSTEM_LOCALE_DIR,resolveLocaleDir};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import{resolveLocaleDir as e}from"./locale-dir.js";import t from"@girs/glib-2.0";import n from"gettext";function initLocale(r,i={}){let a=e({...i,env:{GJSIFY_LOCALE_DIR:t.getenv(`GJSIFY_LOCALE_DIR`)??void 0}});return n.setlocale(n.LocaleCategory.ALL,``),n.bindtextdomain(r,a),n.textdomain(r),Object.assign(e=>n.dgettext(r,e),{plural:(e,t,i)=>n.dngettext(r,e,t,i),context:(e,t)=>n.dpgettext(r,e,t),localeDir:a,domain:r})}export{initLocale};
@@ -26,5 +26,12 @@ export interface ConfirmOptions {
26
26
  * on cancel/dismiss. `parent` anchors the dialog (typically the window).
27
27
  */
28
28
  export declare function confirmDialog(parent: Gtk.Widget, options: ConfirmOptions): Promise<boolean>;
29
- /** Present a single-button error `Adw.AlertDialog`; resolves when dismissed. */
30
- export declare function errorDialog(parent: Gtk.Widget, heading: string, body?: string): Promise<void>;
29
+ /**
30
+ * Present a single-button error `Adw.AlertDialog`; resolves when dismissed.
31
+ *
32
+ * `okLabel` exists for the same reason {@link ConfirmOptions} carries `cancelLabel` and
33
+ * `confirmLabel`: this is library code with no text domain of its own, so a caption it hardcodes is
34
+ * one no application can translate. The English default stays as the fallback — an app that passes
35
+ * nothing gets "OK", which is at least honest about being untranslated rather than untranslatable.
36
+ */
37
+ export declare function errorDialog(parent: Gtk.Widget, heading: string, body?: string, okLabel?: string): Promise<void>;
@@ -10,6 +10,10 @@ export type { ConfirmOptions } from './dialogs.js';
10
10
  export { registerToastOverlay, showToast } from './toast.js';
11
11
  export { pickFile, saveFile } from './file-dialog.js';
12
12
  export type { FileFilterSpec, PickFileOptions } from './file-dialog.js';
13
+ export { initLocale } from './locale.js';
14
+ export type { InitLocaleOptions, Translator } from './locale.js';
15
+ export { SYSTEM_LOCALE_DIR, resolveLocaleDir } from './locale-dir.js';
16
+ export type { ResolveLocaleDirOptions } from './locale-dir.js';
13
17
  export { readAppDevHooks } from './dev-hooks.js';
14
18
  export type { AppDevHooks, ReadAppDevHooksOptions } from './dev-hooks.js';
15
19
  export { findNavItem, resolveInitialNavIndex } from './nav-model.js';
@@ -0,0 +1,18 @@
1
+ /** `bindtextdomain`'s directory for a system install, when nothing else names one. */
2
+ export declare const SYSTEM_LOCALE_DIR = "/usr/share/locale";
3
+ export interface ResolveLocaleDirOptions {
4
+ /** Wins over everything — a dev tree (`dist/locale`), or a test fixture. */
5
+ localeDir?: string;
6
+ /** Environment to read `GJSIFY_LOCALE_DIR` from. */
7
+ env?: Record<string, string | undefined>;
8
+ /** Used when neither the option nor the environment names a directory. */
9
+ fallbackDir?: string;
10
+ }
11
+ /**
12
+ * Resolve the directory to bind a text domain to.
13
+ *
14
+ * Precedence: explicit option, then `GJSIFY_LOCALE_DIR` (exported by the `gjsify ship` launcher,
15
+ * which is the only party that knows whether the payload became `/usr`, a `--prefix` tree or
16
+ * `/app`), then the caller's fallback, then the system directory.
17
+ */
18
+ export declare function resolveLocaleDir(options?: ResolveLocaleDirOptions): string;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { type ResolveLocaleDirOptions } from './locale-dir.js';
2
+ export type InitLocaleOptions = Omit<ResolveLocaleDirOptions, 'env'>;
3
+ /** A domain-bound lookup. Callable for the common case; `plural`/`context` for the rest. */
4
+ export interface Translator {
5
+ (msgid: string): string;
6
+ /** `n`-aware lookup. Pass the untranslated singular and plural. */
7
+ plural(singular: string, plural: string, n: number): string;
8
+ /** Disambiguating lookup, for a msgid whose meaning depends on where it appears. */
9
+ context(context: string, msgid: string): string;
10
+ /** The bound directory and domain — for a diagnostic line, never for a lookup. */
11
+ readonly localeDir: string;
12
+ readonly domain: string;
13
+ }
14
+ /**
15
+ * Bind `domain` and return its lookup function.
16
+ *
17
+ * Safe to call when no catalogue exists: gettext then returns each msgid unchanged, which is why
18
+ * the msgids themselves must be the source language rather than keys.
19
+ */
20
+ export declare function initLocale(domain: string, options?: InitLocaleOptions): Translator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/adwaita-app",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Native Adwaita application shell for GJS/GTK apps — Adw.Application lifecycle (runAsync + devtools + CSS), a data-driven NavigationSplitView nav shell, an async-view mounter, and promise dialog/toast/file helpers",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -46,12 +46,12 @@
46
46
  "@girs/glib-2.0": "^4.1.0",
47
47
  "@girs/gobject-2.0": "^4.1.0",
48
48
  "@girs/gtk-4.0": "^4.1.0",
49
- "@gjsify/devtools": "^0.42.0"
49
+ "@gjsify/devtools": "^0.43.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@gjsify/cli": "^0.42.0",
53
- "@gjsify/storybook": "^0.42.0",
54
- "@gjsify/unit": "^0.42.0",
52
+ "@gjsify/cli": "^0.43.0",
53
+ "@gjsify/storybook": "^0.43.0",
54
+ "@gjsify/unit": "^0.43.0",
55
55
  "@types/node": "^25.9.2",
56
56
  "typescript": "^6.0.3"
57
57
  },