@gjsify/adwaita-core 0.55.0 → 0.57.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/lib/esm/application.js +1 -0
- package/lib/esm/conformance/application.js +1 -0
- package/lib/esm/conformance/constructs.js +2 -2
- package/lib/esm/conformance/glib-timers.js +1 -0
- package/lib/esm/conformance/gobject.js +1 -0
- package/lib/esm/conformance/index.js +1 -1
- package/lib/esm/conformance/menu-actions.js +1 -0
- package/lib/esm/conformance/menu-tree.js +1 -0
- package/lib/esm/conformance/popup-menu-plan.js +1 -0
- package/lib/esm/conformance/shared-trees.js +1 -1
- package/lib/esm/gio-actions.js +1 -0
- package/lib/esm/glib-timers.js +1 -0
- package/lib/esm/gobject.js +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/markup.js +2 -2
- package/lib/esm/menu-actions.js +1 -0
- package/lib/esm/menu-tree.js +1 -0
- package/lib/esm/popup-menu-plan.js +2 -0
- package/lib/esm/tags.js +1 -1
- package/lib/types/application.d.ts +80 -0
- package/lib/types/application.gjs.spec.d.ts +2 -0
- package/lib/types/application.spec.d.ts +2 -0
- package/lib/types/conformance/application.d.ts +88 -0
- package/lib/types/conformance/constructs.d.ts +4 -3
- package/lib/types/conformance/glib-timers.d.ts +35 -0
- package/lib/types/conformance/gobject.d.ts +35 -0
- package/lib/types/conformance/index.d.ts +12 -0
- package/lib/types/conformance/menu-actions.d.ts +36 -0
- package/lib/types/conformance/menu-tree.d.ts +18 -0
- package/lib/types/conformance/popup-menu-plan.d.ts +30 -0
- package/lib/types/conformance/shared-trees.d.ts +21 -1
- package/lib/types/gio-actions.d.ts +67 -0
- package/lib/types/glib-timers.d.ts +21 -0
- package/lib/types/glib-timers.gjs.spec.d.ts +2 -0
- package/lib/types/glib-timers.spec.d.ts +2 -0
- package/lib/types/gobject.d.ts +202 -0
- package/lib/types/gobject.gjs.spec.d.ts +2 -0
- package/lib/types/gobject.spec.d.ts +2 -0
- package/lib/types/index.d.ts +13 -0
- package/lib/types/menu-actions.d.ts +16 -0
- package/lib/types/menu-actions.gjs.spec.d.ts +2 -0
- package/lib/types/menu-actions.spec.d.ts +2 -0
- package/lib/types/menu-tree.d.ts +12 -0
- package/lib/types/menu-tree.spec.d.ts +2 -0
- package/lib/types/popup-menu-plan.d.ts +47 -0
- package/lib/types/popup-menu-plan.spec.d.ts +2 -0
- package/lib/types/tags.d.ts +43 -1
- package/package.json +3 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type GObjectNamespace } from '../gobject.js';
|
|
2
|
+
import type { ConstructHarness } from './constructs.js';
|
|
3
|
+
/** The rows of ADR 0098 § 1 that carry a claim; every one needs a vector. */
|
|
4
|
+
export declare const APPLICATION_ROWS: readonly ["lifecycle", "order", "unlock", "actions", "windows", "resolution", "refusal"];
|
|
5
|
+
export type ApplicationRow = (typeof APPLICATION_ROWS)[number];
|
|
6
|
+
type Handler = (...args: unknown[]) => unknown;
|
|
7
|
+
/** The part of `Gtk.Application` the vectors read. */
|
|
8
|
+
export interface ApplicationLike {
|
|
9
|
+
connect(signal: string, handler: Handler): number;
|
|
10
|
+
runAsync(argv: string[]): Promise<number>;
|
|
11
|
+
quit(): void;
|
|
12
|
+
vfunc_startup(): void;
|
|
13
|
+
vfunc_activate(): void;
|
|
14
|
+
add_action(action: object): void;
|
|
15
|
+
lookup_action(name: string): object | null;
|
|
16
|
+
remove_action(name: string): void;
|
|
17
|
+
has_action(name: string): boolean;
|
|
18
|
+
list_actions(): string[];
|
|
19
|
+
activate_action(name: string, parameter: null): void;
|
|
20
|
+
add_window(window: object): void;
|
|
21
|
+
remove_window(window: object): void;
|
|
22
|
+
get_windows(): object[];
|
|
23
|
+
get_active_window(): object | null;
|
|
24
|
+
get_application_id(): string | null;
|
|
25
|
+
[member: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface SimpleActionLike {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
connect(signal: 'activate', handler: Handler): number;
|
|
30
|
+
[member: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** Widgets a window scene needs; absent on a subject that cannot build a window (GJS without a display). */
|
|
33
|
+
export interface ApplicationScene {
|
|
34
|
+
/** `new Gtk.ApplicationWindow({ application })`. */
|
|
35
|
+
window(app: ApplicationLike): object;
|
|
36
|
+
/** A button placed in the window. */
|
|
37
|
+
buttonIn(window: object): object;
|
|
38
|
+
/** A button inside a popover owned by a menu button placed in the window. */
|
|
39
|
+
popoverButtonIn(window: object): object;
|
|
40
|
+
/** A button with no window above it. */
|
|
41
|
+
loose(): object;
|
|
42
|
+
/** `activate_action(name)` of the widget: whether an enabled action ran. */
|
|
43
|
+
activate(widget: object, name: string): boolean;
|
|
44
|
+
/** `Gtk.ApplicationWindow.add_action`. */
|
|
45
|
+
addWindowAction(window: object, action: object): void;
|
|
46
|
+
}
|
|
47
|
+
/** What a driver hands the vectors. */
|
|
48
|
+
export interface ApplicationSubject {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/** True for real GJS: refusal vectors are the subset's own and are not run there. */
|
|
51
|
+
readonly isOracle: boolean;
|
|
52
|
+
readonly GObject: GObjectNamespace;
|
|
53
|
+
/** `Gtk.Application`, or `Gio.Application` where GJS has no display. */
|
|
54
|
+
readonly Application: new (params?: Record<string, unknown>) => ApplicationLike;
|
|
55
|
+
readonly SimpleAction: new (params: {
|
|
56
|
+
name: string;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
}) => SimpleActionLike;
|
|
59
|
+
/** `Gio.ApplicationFlags.HANDLES_OPEN`: a flag other than the default. */
|
|
60
|
+
readonly handlesOpen: number;
|
|
61
|
+
readonly scene?: ApplicationScene;
|
|
62
|
+
/**
|
|
63
|
+
* Runs the application to its end. Ports: `runAsync`. GJS inside a test runner cannot (its own
|
|
64
|
+
* main loop is running, and `runAsync` refuses), so the oracle registers and activates instead.
|
|
65
|
+
*/
|
|
66
|
+
run?(app: ApplicationLike): Promise<number>;
|
|
67
|
+
/** Makes the action API usable before a run (`g_application_register` on GJS); a port needs nothing. */
|
|
68
|
+
ready?(app: ApplicationLike): void;
|
|
69
|
+
}
|
|
70
|
+
export interface ApplicationVector {
|
|
71
|
+
readonly row: ApplicationRow;
|
|
72
|
+
readonly rule: string;
|
|
73
|
+
readonly holds: 'oracle' | 'subset';
|
|
74
|
+
/** Needs `subject.scene`. */
|
|
75
|
+
readonly windowed?: true;
|
|
76
|
+
/** `Class.vfunc_name` entries of `UNLOCKED_VFUNCS` this vector proves against GJS. */
|
|
77
|
+
readonly unlocks?: readonly string[];
|
|
78
|
+
readonly observe: (subject: ApplicationSubject) => unknown;
|
|
79
|
+
readonly shows: unknown;
|
|
80
|
+
}
|
|
81
|
+
export declare const APPLICATION_VECTORS: readonly ApplicationVector[];
|
|
82
|
+
/** Every `Class.vfunc_name` of `UNLOCKED_VFUNCS`, for the gate that an entry without a vector fails. */
|
|
83
|
+
export declare function unlockedVfuncNames(): string[];
|
|
84
|
+
/** The entries of `UNLOCKED_VFUNCS` no vector proves. */
|
|
85
|
+
export declare function unprovenVfuncs(vectors?: readonly ApplicationVector[]): string[];
|
|
86
|
+
/** Holds a subject to the vectors. Windowed vectors need `subject.scene`. */
|
|
87
|
+
export declare function driveApplicationVectors(subject: ApplicationSubject, harness: ConstructHarness, vectors?: readonly ApplicationVector[]): Promise<void>;
|
|
88
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SharedTreeNode } from './shared-trees.js';
|
|
2
2
|
/** The construct kinds, in the order the tables list them. */
|
|
3
|
-
export declare const CONSTRUCT_KINDS: readonly ["layout", "strings", "responses", "page", "extern", "signal", "bind", "breakpoint"];
|
|
3
|
+
export declare const CONSTRUCT_KINDS: readonly ["layout", "strings", "responses", "page", "extern", "signal", "bind", "breakpoint", "sibling-object"];
|
|
4
4
|
export type ConstructKind = (typeof CONSTRUCT_KINDS)[number];
|
|
5
5
|
/** `implemented`, or the sentence a human can act on — it is the text the error prints. */
|
|
6
6
|
export type ConstructCapability = 'implemented' | {
|
|
@@ -52,8 +52,9 @@ export interface ConstructVector {
|
|
|
52
52
|
}
|
|
53
53
|
export declare const CONSTRUCT_VECTORS: readonly ConstructVector[];
|
|
54
54
|
/**
|
|
55
|
-
* The sizes a renderer feeds the `breakpoint`
|
|
56
|
-
* reads the
|
|
55
|
+
* The sizes a renderer feeds the `breakpoint` and `sibling-object` vectors through its own size
|
|
56
|
+
* source, in order, and reads the label after each: wide, then narrow enough for the condition,
|
|
57
|
+
* then wide again.
|
|
57
58
|
*/
|
|
58
59
|
export declare const BREAKPOINT_VECTOR_SIZES: readonly {
|
|
59
60
|
readonly width: number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ConstructHarness } from './constructs.js';
|
|
2
|
+
/** The part of `GLib` the vectors read. */
|
|
3
|
+
export interface GLibTimersLike {
|
|
4
|
+
readonly PRIORITY_HIGH: number;
|
|
5
|
+
readonly PRIORITY_DEFAULT: number;
|
|
6
|
+
readonly PRIORITY_HIGH_IDLE: number;
|
|
7
|
+
readonly PRIORITY_DEFAULT_IDLE: number;
|
|
8
|
+
readonly PRIORITY_LOW: number;
|
|
9
|
+
readonly SOURCE_REMOVE: boolean;
|
|
10
|
+
readonly SOURCE_CONTINUE: boolean;
|
|
11
|
+
idle_add(priority: number, run: () => boolean | void): number;
|
|
12
|
+
timeout_add(priority: number, milliseconds: number, run: () => boolean | void): number;
|
|
13
|
+
source_remove(sourceId: number): boolean;
|
|
14
|
+
}
|
|
15
|
+
/** What a driver hands the vectors. */
|
|
16
|
+
export interface GLibTimersSubject {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly isOracle: boolean;
|
|
19
|
+
readonly GLib: GLibTimersLike;
|
|
20
|
+
/** Resolves after `milliseconds` of the subject's own loop; the loop must keep running meanwhile. */
|
|
21
|
+
settle(milliseconds: number): Promise<void>;
|
|
22
|
+
/** Runs `body` with the subject's error log silenced (a throwing callback logs by design). */
|
|
23
|
+
quiet(body: () => Promise<void>): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare const GLIB_TIMER_ROWS: readonly ["constants", "timeout", "idle", "remove", "throw", "arguments"];
|
|
26
|
+
export type GLibTimerRow = (typeof GLIB_TIMER_ROWS)[number];
|
|
27
|
+
export interface GLibTimerVector {
|
|
28
|
+
readonly row: GLibTimerRow;
|
|
29
|
+
readonly rule: string;
|
|
30
|
+
readonly observe: (subject: GLibTimersSubject) => unknown;
|
|
31
|
+
readonly shows: unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare const GLIB_TIMER_VECTORS: readonly GLibTimerVector[];
|
|
34
|
+
/** Holds a subject to the vectors. */
|
|
35
|
+
export declare function driveGLibTimerVectors(subject: GLibTimersSubject, harness: ConstructHarness, vectors?: readonly GLibTimerVector[]): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BindingFlag, BlueprintTemplate, GObjectConstructor, GObjectInstance, GObjectNamespace } from '../gobject.js';
|
|
2
|
+
import type { ConstructHarness } from './constructs.js';
|
|
3
|
+
/** The rows of ADR 0096 § 2 that carry a claim; every one needs a vector. */
|
|
4
|
+
export declare const GOBJECT_ROWS: readonly ["registerClass", "field-form", "ParamSpec", "Signals", "instance API", "type_ensure", "vfunc", "binding engine", "template"];
|
|
5
|
+
export type GObjectRow = (typeof GOBJECT_ROWS)[number];
|
|
6
|
+
/** A template, in both spellings: GtkBuilder XML for GJS, the projected tree for a port. */
|
|
7
|
+
export interface GObjectTemplateSource {
|
|
8
|
+
readonly className: string;
|
|
9
|
+
readonly tree: BlueprintTemplate;
|
|
10
|
+
readonly xml: string;
|
|
11
|
+
}
|
|
12
|
+
/** What a driver hands the vectors. */
|
|
13
|
+
export interface GObjectSubject {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/** True for real GJS: refusal vectors are the subset's own and are not run there. */
|
|
16
|
+
readonly isOracle: boolean;
|
|
17
|
+
readonly GObject: GObjectNamespace;
|
|
18
|
+
/** The widget base a templated class extends (`Gtk.Box` on GJS); absent when there is no display. */
|
|
19
|
+
readonly Widget?: GObjectConstructor;
|
|
20
|
+
/** The value to put in `Template`. */
|
|
21
|
+
template(source: GObjectTemplateSource): unknown;
|
|
22
|
+
/** The binding engine; `bind_property` on GJS, which is not exported by the ports. */
|
|
23
|
+
bind(source: GObjectInstance, sourceProperty: string, target: GObjectInstance, targetProperty: string, flags: readonly BindingFlag[]): void;
|
|
24
|
+
}
|
|
25
|
+
export interface GObjectVector {
|
|
26
|
+
readonly row: GObjectRow;
|
|
27
|
+
readonly rule: string;
|
|
28
|
+
readonly holds: 'oracle' | 'subset';
|
|
29
|
+
readonly widget?: true;
|
|
30
|
+
readonly observe: (subject: GObjectSubject) => unknown;
|
|
31
|
+
readonly shows: unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare const GOBJECT_VECTORS: readonly GObjectVector[];
|
|
34
|
+
/** Holds a subject to the vectors. Widget vectors need `subject.Widget`; the caller reports their absence. */
|
|
35
|
+
export declare function driveGObjectVectors(subject: GObjectSubject, harness: ConstructHarness, vectors?: readonly GObjectVector[]): Promise<void>;
|
|
@@ -84,3 +84,15 @@ export { SHARED_TREE_BLOCKS_WITHOUT_EXPECTATIONS, SHARED_TREE_TABLES, authoredNo
|
|
|
84
84
|
export type { SharedTreeExpectation, SharedTreeNode, SharedTreeObservable, SharedTreePlacement, } from './shared-trees.js';
|
|
85
85
|
export { CONSTRUCT_KINDS, BREAKPOINT_VECTOR_SIZES, EXTERN_VECTOR_CLASS, CONSTRUCT_VECTORS, UnsupportedConstructError, assertTreeConstructs, constructUsesOf, driveConstructVectors, } from './constructs.js';
|
|
86
86
|
export type { ConstructCapabilities, ConstructCapability, ConstructHarness, ConstructKind, ConstructRenderer, ConstructUse, ConstructVector, } from './constructs.js';
|
|
87
|
+
export { GOBJECT_ROWS, GOBJECT_VECTORS, driveGObjectVectors } from './gobject.js';
|
|
88
|
+
export { APPLICATION_ROWS, APPLICATION_VECTORS, driveApplicationVectors, unprovenVfuncs, unlockedVfuncNames, } from './application.js';
|
|
89
|
+
export type { ApplicationLike, ApplicationRow, ApplicationScene, ApplicationSubject, ApplicationVector, SimpleActionLike, } from './application.js';
|
|
90
|
+
export { GLIB_TIMER_ROWS, GLIB_TIMER_VECTORS, driveGLibTimerVectors } from './glib-timers.js';
|
|
91
|
+
export type { GLibTimerRow, GLibTimersLike, GLibTimersSubject, GLibTimerVector } from './glib-timers.js';
|
|
92
|
+
export type { GObjectRow, GObjectSubject, GObjectTemplateSource, GObjectVector } from './gobject.js';
|
|
93
|
+
export { POPUP_MENU_PLAN_VECTORS, popupMenuOutline } from './popup-menu-plan.js';
|
|
94
|
+
export type { PopupMenuPlanVector } from './popup-menu-plan.js';
|
|
95
|
+
export { MENU_ACTION_VECTORS, driveMenuActionVectors, registryMenuActionScene } from './menu-actions.js';
|
|
96
|
+
export type { MenuActionGroupSpec, MenuActionScene, MenuActionVector } from './menu-actions.js';
|
|
97
|
+
export { MENU_TREE_VECTORS } from './menu-tree.js';
|
|
98
|
+
export type { MenuTreeVector } from './menu-tree.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ConstructHarness } from './constructs.js';
|
|
2
|
+
export interface MenuActionGroupSpec {
|
|
3
|
+
readonly at: 'outer' | 'button';
|
|
4
|
+
readonly prefix: string;
|
|
5
|
+
/** `enabled` of each action by name; the name is also what its handler logs, with `at`. */
|
|
6
|
+
readonly actions: Readonly<Record<string, boolean>>;
|
|
7
|
+
}
|
|
8
|
+
export interface MenuActionVector {
|
|
9
|
+
readonly rule: string;
|
|
10
|
+
readonly groups: readonly MenuActionGroupSpec[];
|
|
11
|
+
/** The detailed action the one item names. */
|
|
12
|
+
readonly action: string;
|
|
13
|
+
readonly sensitive: boolean;
|
|
14
|
+
readonly fired: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const MENU_ACTION_VECTORS: ReadonlyArray<MenuActionVector>;
|
|
17
|
+
export interface MenuActionScene {
|
|
18
|
+
/** A fresh chain: `outer` is the ROOT (the window) and `button` a descendant of it, and is where resolution starts. */
|
|
19
|
+
chain(): {
|
|
20
|
+
outer: object;
|
|
21
|
+
button: object;
|
|
22
|
+
};
|
|
23
|
+
/** Insert a group of `actions` (name → enabled) at `widget`; `onActivate` hears each activation by name. */
|
|
24
|
+
insertGroup(widget: object, prefix: string, actions: Readonly<Record<string, boolean>>, onActivate: (action: string) => void): void;
|
|
25
|
+
/** Whether an item naming `detailed` reads as sensitive from `button`. */
|
|
26
|
+
sensitive(button: object, detailed: string): boolean;
|
|
27
|
+
/** What choosing an item that names `detailed` does from `button`. */
|
|
28
|
+
activate(button: object, detailed: string): void;
|
|
29
|
+
}
|
|
30
|
+
/** The registry of ADR 0098 over a port's parent link: what the browser and NativeScript drive. */
|
|
31
|
+
export declare function registryMenuActionScene(chain: () => {
|
|
32
|
+
outer: object;
|
|
33
|
+
button: object;
|
|
34
|
+
}, parent: (node: object) => object | null | undefined): MenuActionScene;
|
|
35
|
+
/** Runs {@link MENU_ACTION_VECTORS} on a port's tree walk, or on GTK itself (the oracle). */
|
|
36
|
+
export declare function driveMenuActionVectors(name: string, scene: MenuActionScene, { describe, it, expect }: ConstructHarness): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AdwMenuNode } from '../menu.js';
|
|
2
|
+
export interface MenuTreeVector {
|
|
3
|
+
readonly rule: string;
|
|
4
|
+
/** A `GtkMenuButton` tree. */
|
|
5
|
+
readonly tree: {
|
|
6
|
+
readonly tag: 'GtkMenuButton';
|
|
7
|
+
readonly props?: Record<string, string>;
|
|
8
|
+
readonly menus?: Record<string, readonly AdwMenuNode[]>;
|
|
9
|
+
readonly menuModels?: Record<string, readonly AdwMenuNode[]>;
|
|
10
|
+
};
|
|
11
|
+
/** The `kind` of each top-level node `menuModel` holds, or a fragment of the refusal. */
|
|
12
|
+
readonly result: {
|
|
13
|
+
readonly kinds: readonly string[];
|
|
14
|
+
} | {
|
|
15
|
+
readonly refused: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare const MENU_TREE_VECTORS: ReadonlyArray<MenuTreeVector>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AdwMenuActions, AdwMenuInput } from '../menu.js';
|
|
2
|
+
export interface PopupMenuPlanVector {
|
|
3
|
+
readonly rule: string;
|
|
4
|
+
readonly input: AdwMenuInput;
|
|
5
|
+
readonly actions?: AdwMenuActions;
|
|
6
|
+
/** The groups, in order, as {@link popupMenuOutline} writes them. */
|
|
7
|
+
readonly outline: readonly string[];
|
|
8
|
+
/** The refusals by name; empty when the menu is renderable. */
|
|
9
|
+
readonly refused: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const POPUP_MENU_PLAN_VECTORS: ReadonlyArray<PopupMenuPlanVector>;
|
|
12
|
+
interface OutlineLevel {
|
|
13
|
+
groups: ReadonlyArray<{
|
|
14
|
+
checkable: string;
|
|
15
|
+
entries: ReadonlyArray<{
|
|
16
|
+
kind: 'item';
|
|
17
|
+
title: string;
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
checked: boolean;
|
|
20
|
+
role: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'submenu';
|
|
23
|
+
title: string;
|
|
24
|
+
level: OutlineLevel;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/** The plan as the one-line-per-group text the vectors state. */
|
|
29
|
+
export declare function popupMenuOutline(level: OutlineLevel): string[];
|
|
30
|
+
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { AdwMenuNode } from '../menu.js';
|
|
2
|
+
/** One node of an authored menu: the normalised model of ADR 0042 (ADR 0097 § 1). */
|
|
3
|
+
export type MenuNodeShape = AdwMenuNode;
|
|
1
4
|
/**
|
|
2
5
|
* One node of an authored tree — the shape `ADWAITA_GALLERY_SHARED_TREES` is written in.
|
|
3
6
|
*
|
|
@@ -189,6 +192,23 @@ export interface SharedTreeNode {
|
|
|
189
192
|
};
|
|
190
193
|
}[];
|
|
191
194
|
}[];
|
|
195
|
+
/**
|
|
196
|
+
* Root only: the OBJECT roots the file declares beside this one — `Adw.AlertDialog dialog { }`
|
|
197
|
+
* or `$Learn learn { }` after the template — each a tree of its own (ADR 0093). They share the
|
|
198
|
+
* root's id scope, so a setter or a reference may name one, and a renderer hands the built
|
|
199
|
+
* object back to the code beside the file; none of them is a child of the root.
|
|
200
|
+
*/
|
|
201
|
+
siblings?: readonly SharedTreeNode[];
|
|
202
|
+
/**
|
|
203
|
+
* Root only: the root `menu id { }` of the file, by id (ADR 0097 § 1). A `menu-model: id`
|
|
204
|
+
* property stays the scalar id; the builder resolves it here.
|
|
205
|
+
*/
|
|
206
|
+
menus?: Readonly<Record<string, readonly MenuNodeShape[]>>;
|
|
207
|
+
/**
|
|
208
|
+
* The menu written AT a property (`menu-model: menu { }`), by property name: the model itself,
|
|
209
|
+
* not an id into `menus` (ADR 0097 § 1).
|
|
210
|
+
*/
|
|
211
|
+
menuModels?: Readonly<Record<string, readonly MenuNodeShape[]>>;
|
|
192
212
|
children?: readonly SharedTreeNode[];
|
|
193
213
|
}
|
|
194
214
|
/**
|
|
@@ -242,7 +262,7 @@ export declare const SHARED_TREE_TABLES: readonly ["BANNER_BUTTON_TEXT_VECTORS",
|
|
|
242
262
|
*/
|
|
243
263
|
export declare const SHARED_TREE_BLOCKS_WITHOUT_EXPECTATIONS: Readonly<Record<string, string>>;
|
|
244
264
|
/** Every authored node of `root`, in pre-order — the sequence a realised tree must reproduce. */
|
|
245
|
-
export declare function authoredNodes(root: SharedTreeNode): {
|
|
265
|
+
export declare function authoredNodes(root: SharedTreeNode, address?: string): {
|
|
246
266
|
node: SharedTreeNode;
|
|
247
267
|
path: string;
|
|
248
268
|
}[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** `activate` handler: the action that fired and the caller's parameter (`null` when none). */
|
|
2
|
+
export type ActionActivateHandler = (action: SimpleAction, parameter: unknown) => void;
|
|
3
|
+
/** What a registry holds and a widget walk activates. */
|
|
4
|
+
export interface ActionLike {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
activate(parameter?: unknown): void;
|
|
8
|
+
}
|
|
9
|
+
/** What a group answers; `Gio.ActionMap` and the groups of `insertActionGroup` both do. */
|
|
10
|
+
export interface ActionGroupLike {
|
|
11
|
+
lookup_action(name: string): ActionLike | null;
|
|
12
|
+
}
|
|
13
|
+
export interface SimpleActionProps {
|
|
14
|
+
name: string;
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
/** Held, never checked: an action activates with whatever the caller passes. */
|
|
17
|
+
parameter_type?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** `Gio.SimpleAction`: `name`, `enabled`, the `activate` signal and `activate()`. */
|
|
20
|
+
export declare class SimpleAction implements ActionLike {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
readonly parameter_type: unknown;
|
|
24
|
+
private readonly _handlers;
|
|
25
|
+
private _nextId;
|
|
26
|
+
constructor(props: SimpleActionProps);
|
|
27
|
+
/** `g_signal_connect`. Only `activate` exists; any other name is refused rather than ignored. */
|
|
28
|
+
connect(signal: 'activate', handler: ActionActivateHandler): number;
|
|
29
|
+
disconnect(id: number): void;
|
|
30
|
+
/** `g_action_activate`. A disabled action swallows it, as GIO does. */
|
|
31
|
+
activate(parameter?: unknown): void;
|
|
32
|
+
}
|
|
33
|
+
/** The registry behind `Gio.ActionMap` and `Gio.ActionGroup`. */
|
|
34
|
+
export declare class ActionRegistry implements ActionGroupLike {
|
|
35
|
+
private readonly _actions;
|
|
36
|
+
/** `g_action_map_add_action`: an existing name is replaced. */
|
|
37
|
+
add(action: ActionLike): void;
|
|
38
|
+
remove(name: string): void;
|
|
39
|
+
lookup_action(name: string): ActionLike | null;
|
|
40
|
+
has(name: string): boolean;
|
|
41
|
+
list(): string[];
|
|
42
|
+
}
|
|
43
|
+
/** The registry an owner (an application, a window) carries; made on first use. */
|
|
44
|
+
export declare function actionRegistryOf(owner: object, create?: boolean): ActionRegistry | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Gives a prototype `Gio.ActionMap` (`add_action`, `lookup_action`, `remove_action`) and, with
|
|
47
|
+
* `group`, `Gio.ActionGroup`. A window is an ActionMap only: its `activate_action` is the WIDGET's,
|
|
48
|
+
* which takes `win.x`, so the group half stays off it.
|
|
49
|
+
*/
|
|
50
|
+
export declare function installActionMap(proto: object, group?: boolean): void;
|
|
51
|
+
/** `gtk_widget_insert_action_group`: `group`'s actions resolve as `prefix.name` below `widget`. `null` removes it. */
|
|
52
|
+
export declare function insertActionGroup(widget: object, prefix: string, group: ActionGroupLike | null): void;
|
|
53
|
+
/** The application a window belongs to (`Gtk.Window:application`), or `null`. */
|
|
54
|
+
export declare function applicationOfWindow(window: object): ActionGroupLike | null;
|
|
55
|
+
/** Records or clears the application of a window. `Application.add_window` / `remove_window` call it. */
|
|
56
|
+
export declare function linkWindow(window: object, application: ActionGroupLike | null): void;
|
|
57
|
+
/**
|
|
58
|
+
* The group a widget finds for `prefix`: the nearest explicit group up the chain, the `win` actions
|
|
59
|
+
* of the first node that carries an ActionMap, and the application of the first node that is a window
|
|
60
|
+
* of one (`app`). A widget with no window above it finds none, which is not an empty group (ADR 0042 § 2).
|
|
61
|
+
*/
|
|
62
|
+
export declare function findActionGroup(widget: object, prefix: string, parent: (node: object) => object | null | undefined): ActionGroupLike | null;
|
|
63
|
+
/**
|
|
64
|
+
* What a `Gtk.Actionable` does when it fires: split `prefix.name`, find the group, activate. Returns
|
|
65
|
+
* whether an enabled action ran, so a caller can tell a wired button from a dangling name.
|
|
66
|
+
*/
|
|
67
|
+
export declare function activateWidgetAction(widget: object, fullName: string, parent: (node: object) => object | null | undefined, parameter?: unknown): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The slice of a host event loop the timers need. */
|
|
2
|
+
export interface TimerHost {
|
|
3
|
+
setTimeout(run: () => void, milliseconds: number): unknown;
|
|
4
|
+
clearTimeout(handle: unknown): void;
|
|
5
|
+
}
|
|
6
|
+
export type SourceFunc = () => boolean | void;
|
|
7
|
+
/** `GLib` as far as this subset goes. */
|
|
8
|
+
export interface GLibTimers {
|
|
9
|
+
readonly PRIORITY_HIGH: number;
|
|
10
|
+
readonly PRIORITY_DEFAULT: number;
|
|
11
|
+
readonly PRIORITY_HIGH_IDLE: number;
|
|
12
|
+
readonly PRIORITY_DEFAULT_IDLE: number;
|
|
13
|
+
readonly PRIORITY_LOW: number;
|
|
14
|
+
readonly SOURCE_REMOVE: boolean;
|
|
15
|
+
readonly SOURCE_CONTINUE: boolean;
|
|
16
|
+
idle_add(priority: number, run: SourceFunc): number;
|
|
17
|
+
timeout_add(priority: number, milliseconds: number, run: SourceFunc): number;
|
|
18
|
+
source_remove(sourceId: number): boolean;
|
|
19
|
+
}
|
|
20
|
+
/** One main context's worth of sources; the namespace object of a port is one of these. */
|
|
21
|
+
export declare function createGLibTimers(host?: TimerHost): GLibTimers;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { SharedTreeNode } from './conformance/shared-trees.js';
|
|
2
|
+
/** What `registerClass` accepts as `Template`: the projected tree of a `?template` import (ADR 0096 § 4). */
|
|
3
|
+
export type BlueprintTemplate = SharedTreeNode;
|
|
4
|
+
/** The subset asked for something it does not list. `feature` is the name that was refused. */
|
|
5
|
+
export declare class UnsupportedGObjectError extends Error {
|
|
6
|
+
readonly feature: string;
|
|
7
|
+
constructor(feature: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** An opaque GType token: it names a type and proves nothing else. */
|
|
10
|
+
export interface GType {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const TYPE_STRING: GType;
|
|
14
|
+
export declare const TYPE_BOOLEAN: GType;
|
|
15
|
+
export declare const TYPE_INT: GType;
|
|
16
|
+
export declare const TYPE_UINT: GType;
|
|
17
|
+
export declare const TYPE_DOUBLE: GType;
|
|
18
|
+
export declare const ParamFlags: {
|
|
19
|
+
readonly READABLE: 1;
|
|
20
|
+
readonly WRITABLE: 2;
|
|
21
|
+
readonly READWRITE: 3;
|
|
22
|
+
readonly CONSTRUCT: 4;
|
|
23
|
+
readonly CONSTRUCT_ONLY: 8;
|
|
24
|
+
};
|
|
25
|
+
export type ParamKind = 'boolean' | 'string' | 'int' | 'uint' | 'double';
|
|
26
|
+
export declare class ParamSpec {
|
|
27
|
+
readonly kind: ParamKind;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly nick: string;
|
|
30
|
+
readonly blurb: string;
|
|
31
|
+
readonly flags: number;
|
|
32
|
+
readonly minimum?: number;
|
|
33
|
+
readonly maximum?: number;
|
|
34
|
+
private readonly defaultValue;
|
|
35
|
+
private constructor();
|
|
36
|
+
static boolean(name: string, nick: string, blurb: string, flags: number, defaultValue: boolean): ParamSpec;
|
|
37
|
+
static string(name: string, nick: string, blurb: string, flags: number, defaultValue: string | null): ParamSpec;
|
|
38
|
+
static int(name: string, nick: string, blurb: string, flags: number, minimum: number, maximum: number, defaultValue: number): ParamSpec;
|
|
39
|
+
static uint(name: string, nick: string, blurb: string, flags: number, minimum: number, maximum: number, defaultValue: number): ParamSpec;
|
|
40
|
+
static double(name: string, nick: string, blurb: string, flags: number, minimum: number, maximum: number, defaultValue: number): ParamSpec;
|
|
41
|
+
get_default_value(): unknown;
|
|
42
|
+
}
|
|
43
|
+
/** GJS's own symbols, so a class written in the field form (`static [GObject.properties] = …`) registers. */
|
|
44
|
+
export declare const META_SYMBOLS: {
|
|
45
|
+
readonly GTypeName: symbol;
|
|
46
|
+
readonly GTypeFlags: symbol;
|
|
47
|
+
readonly interfaces: symbol;
|
|
48
|
+
readonly properties: symbol;
|
|
49
|
+
readonly signals: symbol;
|
|
50
|
+
readonly requires: symbol;
|
|
51
|
+
readonly template: symbol;
|
|
52
|
+
readonly cssName: symbol;
|
|
53
|
+
readonly children: symbol;
|
|
54
|
+
readonly internalChildren: symbol;
|
|
55
|
+
};
|
|
56
|
+
/** What a port's widget tree gives back for one built template. */
|
|
57
|
+
export interface BuiltTemplate {
|
|
58
|
+
/** The children to attach to the host, in order. */
|
|
59
|
+
readonly children: readonly object[];
|
|
60
|
+
/** Every object the template names with an `id`, for `InternalChildren`. */
|
|
61
|
+
readonly objects: Readonly<Record<string, object>>;
|
|
62
|
+
}
|
|
63
|
+
export type BindingFlag = 'bidirectional' | 'sync-create' | 'invert-boolean';
|
|
64
|
+
export interface Binding {
|
|
65
|
+
unbind(): void;
|
|
66
|
+
}
|
|
67
|
+
/** What the builder of a port is handed: the instance, its handlers and the binding engine. */
|
|
68
|
+
export interface TemplateScope {
|
|
69
|
+
/** The template instance — the scope of every handler and the `template` bind source. */
|
|
70
|
+
readonly instance: object;
|
|
71
|
+
/** `_createClosure`: looked up on the instance, bound to `options.object` or the instance. */
|
|
72
|
+
handler(name: string, options?: {
|
|
73
|
+
object?: object;
|
|
74
|
+
flags?: readonly string[];
|
|
75
|
+
}): (...args: unknown[]) => unknown;
|
|
76
|
+
bind(source: GObjectInstance, sourceProperty: string, target: GObjectInstance, targetProperty: string, flags?: readonly BindingFlag[]): Binding;
|
|
77
|
+
}
|
|
78
|
+
/** The one thing a port implements over its widget model (ADR 0096 § 1). */
|
|
79
|
+
export interface GObjectDoor {
|
|
80
|
+
readonly name: string;
|
|
81
|
+
/** Dispatches the named event on a widget that is not the core's to dispatch. */
|
|
82
|
+
dispatch(target: object, event: string, args: readonly unknown[]): void;
|
|
83
|
+
/** Listens for it; the handler is called `(target, ...args)`. Returns the disconnect. */
|
|
84
|
+
listen(target: object, event: string, handler: (...args: unknown[]) => unknown): () => void;
|
|
85
|
+
/** Creates the widgets of a template, wiring signals and binds through `scope`. */
|
|
86
|
+
createFromTree(tree: BlueprintTemplate, scope: TemplateScope, host: object): BuiltTemplate;
|
|
87
|
+
/** Gives the built children to the host. A port may defer the attach to its own lifecycle. */
|
|
88
|
+
attach(host: object, built: BuiltTemplate): void;
|
|
89
|
+
/** A class was registered: the port defines its element and its `$GTypeName` template entry. */
|
|
90
|
+
register(klass: ClassLike, info: RegisteredClass): void;
|
|
91
|
+
}
|
|
92
|
+
export type ClassLike = abstract new (...args: never[]) => object;
|
|
93
|
+
export interface RegisteredClass {
|
|
94
|
+
readonly klass: ClassLike;
|
|
95
|
+
readonly typeName: string;
|
|
96
|
+
readonly gtype: GType;
|
|
97
|
+
readonly properties: readonly ParamSpec[];
|
|
98
|
+
/** Signal name → its parameter types. */
|
|
99
|
+
readonly signals: Readonly<Record<string, readonly GType[]>>;
|
|
100
|
+
readonly template?: BlueprintTemplate;
|
|
101
|
+
readonly internalChildren: readonly string[];
|
|
102
|
+
readonly cssName?: string;
|
|
103
|
+
readonly door: GObjectDoor;
|
|
104
|
+
}
|
|
105
|
+
export declare function registeredClassOf(klass: object): RegisteredClass | undefined;
|
|
106
|
+
export type SignalHandler = (emitter: GObjectInstance, ...args: unknown[]) => unknown;
|
|
107
|
+
/** The instance surface of a registered class (ADR 0096 § 2, "instance API" row). */
|
|
108
|
+
export interface GObjectInstance {
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
notify(name: string): void;
|
|
111
|
+
connect(signal: string, handler: SignalHandler): number;
|
|
112
|
+
disconnect(id: number): void;
|
|
113
|
+
emit(signal: string, ...args: unknown[]): void;
|
|
114
|
+
}
|
|
115
|
+
export declare function connectInstance(instance: GObjectInstance, signal: string, handler: SignalHandler): number;
|
|
116
|
+
export declare function disconnectInstance(instance: GObjectInstance, id: number): void;
|
|
117
|
+
export declare function emitInstance(instance: GObjectInstance, signal: string, ...args: unknown[]): void;
|
|
118
|
+
export declare function notifyInstance(instance: GObjectInstance, name: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* `g_object_bind_property` for the three flags the template builders need. The target follows the
|
|
121
|
+
* source on every `notify::<source property>`; `bidirectional` makes the source follow the target
|
|
122
|
+
* back, `invert-boolean` negates what crosses, `sync-create` transfers once at bind time.
|
|
123
|
+
*/
|
|
124
|
+
export declare function bindProperties(source: GObjectInstance, sourceProperty: string, target: GObjectInstance, targetProperty: string, flags?: readonly BindingFlag[]): Binding;
|
|
125
|
+
export declare function createClosure(thisArg: object, handlerName: string, swapped: boolean, connectObject?: object): (...args: unknown[]) => unknown;
|
|
126
|
+
/**
|
|
127
|
+
* Runs ADR 0096 § 3 steps 4–5 for a registered instance, in GJS's order: every template of the
|
|
128
|
+
* class chain is built first (base first), then the construct properties are set, and only then
|
|
129
|
+
* is each `InternalChildren` id installed as `this._<id>`. So `this._x` is `undefined` inside a
|
|
130
|
+
* property setter that runs during construction and defined once `super(params)` returns.
|
|
131
|
+
*
|
|
132
|
+
* Returns the params that are not declared properties, for the port's own construct bag.
|
|
133
|
+
*/
|
|
134
|
+
export declare function constructRegistered(instance: object, params?: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
135
|
+
export interface SignalMeta {
|
|
136
|
+
param_types?: readonly GType[];
|
|
137
|
+
[refused: string]: unknown;
|
|
138
|
+
}
|
|
139
|
+
export interface ClassMeta {
|
|
140
|
+
GTypeName?: string;
|
|
141
|
+
Template?: unknown;
|
|
142
|
+
InternalChildren?: readonly string[];
|
|
143
|
+
Properties?: Readonly<Record<string, ParamSpec>>;
|
|
144
|
+
Signals?: Readonly<Record<string, SignalMeta>>;
|
|
145
|
+
CssName?: string;
|
|
146
|
+
[refused: string]: unknown;
|
|
147
|
+
}
|
|
148
|
+
export interface RegisterClass {
|
|
149
|
+
<T extends ClassLike>(meta: ClassMeta, klass: T): T;
|
|
150
|
+
<T extends ClassLike>(klass: T): T;
|
|
151
|
+
}
|
|
152
|
+
/** A core class declares the GIR type its `vfunc_*` are listed under in {@link UNLOCKED_VFUNCS}. */
|
|
153
|
+
export declare const GIR_TYPE: unique symbol;
|
|
154
|
+
/**
|
|
155
|
+
* The `vfunc_*` a registered class may override (ADR 0098 § 1a), keyed by the GIR class that declares
|
|
156
|
+
* them. Every other `vfunc_*` is refused by name. An entry needs a vector of `APPLICATION_VECTORS`
|
|
157
|
+
* (`unlocks`) that holds on real GJS; `application.spec.ts` fails an entry without one.
|
|
158
|
+
*/
|
|
159
|
+
export declare const UNLOCKED_VFUNCS: Readonly<Record<string, readonly string[]>>;
|
|
160
|
+
/**
|
|
161
|
+
* Registers a core class that is no widget and has no template (`Gio.Application`), so its signals
|
|
162
|
+
* resolve through the registry like a registered class's own. The door is one that names the
|
|
163
|
+
* missing widget model: such a class has no event system to fall through to.
|
|
164
|
+
*/
|
|
165
|
+
export declare function registerBaseClass(klass: ClassLike, typeName: string, signals: Readonly<Record<string, readonly GType[]>>, properties?: readonly ParamSpec[]): void;
|
|
166
|
+
export type GObjectConstructor = new (params?: Record<string, unknown>) => GObjectInstance;
|
|
167
|
+
/** `GObject.Object` for a registered class with no widget model beneath it. */
|
|
168
|
+
export declare class GObjectObject {
|
|
169
|
+
[key: string]: unknown;
|
|
170
|
+
constructor(params?: Record<string, unknown>);
|
|
171
|
+
notify(name: string): void;
|
|
172
|
+
connect(signal: string, handler: SignalHandler): number;
|
|
173
|
+
disconnect(id: number): void;
|
|
174
|
+
emit(signal: string, ...args: unknown[]): void;
|
|
175
|
+
}
|
|
176
|
+
export interface GObjectNamespace {
|
|
177
|
+
readonly Object: GObjectConstructor;
|
|
178
|
+
readonly registerClass: RegisterClass;
|
|
179
|
+
readonly ParamSpec: typeof ParamSpec;
|
|
180
|
+
readonly ParamFlags: typeof ParamFlags;
|
|
181
|
+
readonly TYPE_STRING: GType;
|
|
182
|
+
readonly TYPE_BOOLEAN: GType;
|
|
183
|
+
readonly TYPE_INT: GType;
|
|
184
|
+
readonly TYPE_UINT: GType;
|
|
185
|
+
readonly TYPE_DOUBLE: GType;
|
|
186
|
+
readonly GTypeName: symbol;
|
|
187
|
+
readonly GTypeFlags: symbol;
|
|
188
|
+
readonly interfaces: symbol;
|
|
189
|
+
readonly properties: symbol;
|
|
190
|
+
readonly signals: symbol;
|
|
191
|
+
readonly requires: symbol;
|
|
192
|
+
readonly __gtkTemplate__: symbol;
|
|
193
|
+
readonly __gtkCssName__: symbol;
|
|
194
|
+
readonly __gtkChildren__: symbol;
|
|
195
|
+
readonly __gtkInternalChildren__: symbol;
|
|
196
|
+
type_ensure(gtype: GType): void;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The `GObject` namespace of a port: `registerClass` registers against `door`. There is no
|
|
200
|
+
* `bind_property` here until a consumer calls it (ADR 0096 § 2); the engine is {@link bindProperties}.
|
|
201
|
+
*/
|
|
202
|
+
export declare function createGObject(door: GObjectDoor): GObjectNamespace;
|