@gjsify/adwaita-web 0.62.0 → 0.63.1-next.235

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.
Files changed (43) hide show
  1. package/README.md +31 -0
  2. package/dist/adwaita-web.css +4 -0
  3. package/dist/adwaita-web.css.map +1 -1
  4. package/lib/types/canvas2d/canvas2d-bridge.d.ts +26 -5
  5. package/lib/types/elements/adw-application-window.d.ts +26 -7
  6. package/lib/types/elements/adw-bottom-sheet.d.ts +3 -0
  7. package/lib/types/elements/adw-data-grid.d.ts +4 -0
  8. package/lib/types/elements/adw-window-features.d.ts +39 -0
  9. package/lib/types/elements/adw-window.d.ts +11 -24
  10. package/lib/types/elements/gtk-application-window.d.ts +12 -4
  11. package/lib/types/elements/gtk-window.d.ts +44 -0
  12. package/lib/types/gtk-window.spec.d.ts +6 -0
  13. package/lib/types/pango-markup.d.ts +10 -0
  14. package/lib/types/pango-markup.spec.d.ts +1 -0
  15. package/lib/types/source-view/copy-glyph.d.ts +6 -0
  16. package/lib/types/source-view/copy-glyph.spec.d.ts +1 -0
  17. package/lib/types/styles.generated.d.ts +1 -1
  18. package/package.json +13 -12
  19. package/scss/_window.scss +7 -2
  20. package/src/adw-application-window.spec.ts +8 -0
  21. package/src/adw-data-grid.spec.ts +11 -0
  22. package/src/adw-window.spec.ts +8 -0
  23. package/src/application.spec.ts +34 -1
  24. package/src/application.ts +16 -0
  25. package/src/bottom-sheet.spec.ts +9 -0
  26. package/src/canvas2d/canvas2d-bridge.ts +24 -8
  27. package/src/elements/adw-alert-dialog.ts +8 -5
  28. package/src/elements/adw-application-window.ts +90 -20
  29. package/src/elements/adw-banner.ts +14 -9
  30. package/src/elements/adw-bottom-sheet.ts +9 -0
  31. package/src/elements/adw-data-grid.ts +18 -0
  32. package/src/elements/adw-window-features.ts +128 -0
  33. package/src/elements/adw-window.ts +45 -108
  34. package/src/elements/gtk-application-window.ts +17 -6
  35. package/src/elements/gtk-window.ts +170 -18
  36. package/src/gtk-window.spec.ts +133 -0
  37. package/src/pango-markup.spec.ts +257 -0
  38. package/src/pango-markup.ts +266 -0
  39. package/src/source-view/adw-source-view.ts +2 -8
  40. package/src/source-view/copy-glyph.spec.ts +46 -0
  41. package/src/source-view/copy-glyph.ts +52 -0
  42. package/src/styles.generated.ts +1 -1
  43. package/src/test.browser.mts +4 -0
@@ -1,7 +1,28 @@
1
- type ReadyCallback = (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D) => void;
1
+ /**
2
+ * The DOM types this element names, resolved through `globalThis` so the published `.d.ts`
3
+ * never names a `lib.dom` type directly: a consumer that loads `lib.dom` gets the real ones,
4
+ * one that does not still type-checks the declarations with `skipLibCheck: false`.
5
+ */
6
+ export type BridgeCanvas = typeof globalThis extends {
7
+ HTMLCanvasElement: {
8
+ prototype: infer T;
9
+ };
10
+ } ? T : object;
11
+ export type BridgeContext2D = typeof globalThis extends {
12
+ CanvasRenderingContext2D: {
13
+ prototype: infer T;
14
+ };
15
+ } ? T : object;
16
+ /** `FrameRequestCallback` without `lib.dom`. */
17
+ export type FrameCallback = (time: number) => void;
18
+ type ElementConstructor = typeof globalThis extends {
19
+ HTMLElement: infer C;
20
+ } ? C : abstract new () => object;
21
+ declare const HostElement: ElementConstructor;
22
+ type ReadyCallback = (canvas: BridgeCanvas, ctx: BridgeContext2D) => void;
2
23
  type ResizeCallback = (width: number, height: number) => void;
3
24
  type SignalHandler = (emitter: Canvas2DBridgeElement, ...args: unknown[]) => unknown;
4
- export declare class Canvas2DBridgeElement extends HTMLElement {
25
+ export declare class Canvas2DBridgeElement extends HostElement {
5
26
  static readonly GTypeName = "GjsifyCanvas2DBridge";
6
27
  /** The signals `connect()` accepts, as `Gtk.Widget` names them. */
7
28
  static readonly signals: Record<string, string>;
@@ -28,15 +49,15 @@ export declare class Canvas2DBridgeElement extends HTMLElement {
28
49
  set content_height(v: number);
29
50
  private _write;
30
51
  /** The `<canvas>` backing this widget. Available after the first allocation. */
31
- get canvas(): HTMLCanvasElement | null;
52
+ get canvas(): BridgeCanvas | null;
32
53
  /** The browser's own 2D context; available after the first allocation. */
33
- getContext(_id: '2d'): CanvasRenderingContext2D | null;
54
+ getContext(_id: '2d'): BridgeContext2D | null;
34
55
  /** Runs `cb` once the 2D context is ready, synchronously if it already is. */
35
56
  onReady(cb: ReadyCallback): void;
36
57
  /** Runs `cb` on every allocation change, with the canvas dimensions already updated. */
37
58
  onResize(cb: ResizeCallback): void;
38
59
  /** The browser's own, here only so the call reads the same on every target. */
39
- requestAnimationFrame(cb: FrameRequestCallback): number;
60
+ requestAnimationFrame(cb: FrameCallback): number;
40
61
  /** A no-op: the browser already has `requestAnimationFrame` and `performance`. */
41
62
  installGlobals(): void;
42
63
  /** `gtk_widget_queue_draw`: nothing to blit here, the canvas IS the screen. */
@@ -1,11 +1,21 @@
1
1
  import { type AdwMenuInput, type AdwMenuModel } from '@gjsify/adwaita-core';
2
- import { AdwWindow } from './adw-window.js';
3
- export declare class AdwApplicationWindow extends AdwWindow {
4
- /** `Gtk.Window:application`: setting it is `add_window` (ADR 0098), set by `defineWindowApplication`. */
5
- application: object | null;
6
- private _menubarEl;
2
+ import type { AdwBreakpoint } from '@gjsify/adwaita-core';
3
+ import type { AdwSlot } from '../slotted-children.js';
4
+ import { GtkApplicationWindow } from './gtk-application-window.js';
5
+ export declare class AdwApplicationWindow extends GtkApplicationWindow {
6
+ private readonly _features;
7
7
  private _model;
8
+ private _menubarEl;
8
9
  static get observedAttributes(): string[];
10
+ /** The content area — the Adw.Window:content property. */
11
+ get contentArea(): HTMLDivElement;
12
+ get content(): HTMLElement | null;
13
+ set content(value: HTMLElement | null);
14
+ get breakpoints(): readonly AdwBreakpoint[];
15
+ get currentBreakpoint(): AdwBreakpoint | null;
16
+ get dialogs(): readonly HTMLElement[];
17
+ get visibleDialog(): HTMLElement | null;
18
+ addBreakpoint(condition: string): AdwBreakpoint;
9
19
  /** Whether this window shows the application's menubar (Gtk.ApplicationWindow:show-menubar). */
10
20
  get showMenubar(): boolean;
11
21
  set showMenubar(value: boolean);
@@ -15,7 +25,13 @@ export declare class AdwApplicationWindow extends AdwWindow {
15
25
  /** The menubar strip, or null before the window is connected. */
16
26
  get menubar(): HTMLDivElement | null;
17
27
  connectedCallback(): void;
28
+ disconnectedCallback(): void;
18
29
  attributeChangedCallback(name: string): void;
30
+ /** `Adw.ApplicationWindow` has no titlebar of its own, like `Adw.Window`. */
31
+ protected hasTitlebar(): boolean;
32
+ protected strips(): Node[];
33
+ protected extraSlots(): AdwSlot[];
34
+ protected renderFrameSize(): void;
19
35
  /**
20
36
  * The menubar, INSIDE the content area rather than beside it.
21
37
  *
@@ -23,7 +39,10 @@ export declare class AdwApplicationWindow extends AdwWindow {
23
39
  * into the content area, so a sibling would be re-homed into it one tick later. The
24
40
  * content area's own children are not watched, so prepending here is stable — and
25
41
  * it is also where the bar belongs: above the toolbar view, inside the window box.
42
+ * Replaces the base's observer: this bar is filled from the model, not from a slot,
43
+ * and observing it would re-trigger every render.
26
44
  */
27
- private _buildMenubar;
28
- private _renderMenubar;
45
+ protected _followMenubar(): void;
46
+ protected menubarSection(): HTMLDivElement;
47
+ protected _renderMenubar(): void;
29
48
  }
@@ -28,6 +28,9 @@ export declare class AdwBottomSheet extends HTMLElement {
28
28
  /** Whether the content is dimmed and blocked while the sheet is open (`AdwBottomSheet:modal`). */
29
29
  get modal(): boolean;
30
30
  set modal(value: boolean);
31
+ /** `adw_bottom_sheet_get_modal` — the NativeScript port's only door to it (ADR 0112). */
32
+ get_modal(): boolean;
33
+ set_modal(modal: boolean): void;
31
34
  /** Whether the user can dismiss the sheet (dimming / Escape / sheet.close). */
32
35
  get canClose(): boolean;
33
36
  set canClose(value: boolean);
@@ -12,6 +12,10 @@ export declare class AdwDataGrid extends HTMLElement {
12
12
  set columns(value: ReadonlyArray<AdwDataGridColumn>);
13
13
  get rows(): AdwDataGridRow[];
14
14
  set rows(value: ReadonlyArray<AdwDataGridRow>);
15
+ get_columns(): AdwDataGridColumn[];
16
+ set_columns(value: ReadonlyArray<AdwDataGridColumn>): void;
17
+ get_rows(): AdwDataGridRow[];
18
+ set_rows(value: ReadonlyArray<AdwDataGridRow>): void;
15
19
  /** The optional grid caption/title (reflected to the attribute). */
16
20
  get caption(): string;
17
21
  set caption(value: string);
@@ -0,0 +1,39 @@
1
+ import { AdwBreakpoint } from '@gjsify/adwaita-core';
2
+ export declare class AdwWindowFeatures {
3
+ private readonly _host;
4
+ private _contentEl;
5
+ private _breakpoints;
6
+ private _disposeBreakpoints;
7
+ private _openDialogs;
8
+ constructor(_host: HTMLElement);
9
+ /** The content area, or `null` before the window is first connected. */
10
+ get contentArea(): HTMLDivElement | null;
11
+ /** The content widget — the first child of the content area. */
12
+ get content(): HTMLElement | null;
13
+ set content(value: HTMLElement | null);
14
+ get breakpoints(): readonly AdwBreakpoint[];
15
+ get currentBreakpoint(): AdwBreakpoint | null;
16
+ get dialogs(): readonly HTMLElement[];
17
+ get visibleDialog(): HTMLElement | null;
18
+ /**
19
+ * Take the content area the Gtk parent built, once. Tracks open dialogs presented inside
20
+ * the window: an AdwDialog raises `notify::open`, which bubbles to the host.
21
+ */
22
+ adopt(contentEl: HTMLDivElement): void;
23
+ /**
24
+ * Add a breakpoint (adw_window_add_breakpoint). The breakpoint evaluates against the
25
+ * window's own box and sets a `data-breakpoint` attribute when applied.
26
+ */
27
+ addBreakpoint(condition: string): AdwBreakpoint;
28
+ /**
29
+ * Bind the breakpoints to THIS box.
30
+ *
31
+ * NOT once per lifetime: `release` drops the disposer, so a window moved between
32
+ * parents would come back deaf — and a window is exactly the thing a client-side route
33
+ * change re-parents. Re-binding is cheap and idempotent, and it re-measures the new box.
34
+ */
35
+ bind(): void;
36
+ release(): void;
37
+ /** The window's size request — GTK's, not CSS's, so an absent attribute means the default. */
38
+ applySizeRequest(): void;
39
+ }
@@ -1,10 +1,8 @@
1
- import { AdwBreakpoint } from '@gjsify/adwaita-core';
2
- export declare class AdwWindow extends HTMLElement {
3
- private _initialized;
4
- private _contentEl;
5
- private _breakpoints;
6
- private _disposeBreakpoints;
7
- private _openDialogs;
1
+ import type { AdwBreakpoint } from '@gjsify/adwaita-core';
2
+ import type { AdwSlot } from '../slotted-children.js';
3
+ import { GtkWindow } from './gtk-window.js';
4
+ export declare class AdwWindow extends GtkWindow {
5
+ private readonly _features;
8
6
  static get observedAttributes(): string[];
9
7
  /** The content area — the Adw.Window:content property. */
10
8
  get contentArea(): HTMLDivElement;
@@ -19,25 +17,14 @@ export declare class AdwWindow extends HTMLElement {
19
17
  get dialogs(): readonly HTMLElement[];
20
18
  /** The currently visible dialog, or null when none is (Adw.Window:visible-dialog). */
21
19
  get visibleDialog(): HTMLElement | null;
22
- /**
23
- * Add a breakpoint to this window (adw_window_add_breakpoint).
24
- * The breakpoint evaluates against the window's own box and sets a
25
- * `data-breakpoint` attribute when applied.
26
- */
20
+ /** Add a breakpoint to this window (adw_window_add_breakpoint). */
27
21
  addBreakpoint(condition: string): AdwBreakpoint;
28
22
  connectedCallback(): void;
29
23
  disconnectedCallback(): void;
30
24
  attributeChangedCallback(name: string): void;
31
- private _buildOnce;
32
- /**
33
- * Bind the breakpoints to THIS box.
34
- *
35
- * NOT once per lifetime: `disconnectedCallback` releases the disposer, so a
36
- * window moved between parents would come back deaf — and a window is exactly
37
- * the thing a client-side route change re-parents. Re-binding is cheap and
38
- * idempotent, and it re-measures the new box on the way.
39
- */
40
- private _bindBreakpoints;
41
- /** The window's size request — GTK's, not CSS's, so an absent attribute means the default. */
42
- private _applySizeRequest;
25
+ /** `Adw.Window` has no titlebar of its own: you pair it with a header bar. */
26
+ protected hasTitlebar(): boolean;
27
+ protected strips(): Node[];
28
+ protected extraSlots(): AdwSlot[];
29
+ protected renderFrameSize(): void;
43
30
  }
@@ -1,8 +1,16 @@
1
+ import type { ActionLike } from '@gjsify/adwaita-core';
2
+ import type { GtkApplication } from '../application.js';
1
3
  import type { AdwSlot } from '../slotted-children.js';
2
4
  import { GtkWindow } from './gtk-window.js';
3
5
  export declare class GtkApplicationWindow extends GtkWindow {
4
6
  /** `Gtk.Window:application`: setting it is `add_window` (ADR 0098), set by `defineWindowApplication`. */
5
- application: object | null;
7
+ application: GtkApplication | null;
8
+ /** `Gio.ActionMap.add_action`: installed by `installActionMap`; the action is reachable as `win.<name>`. */
9
+ add_action: (action: ActionLike) => void;
10
+ /** `Gio.ActionMap.lookup_action`: the window's own action, or `null`. */
11
+ lookup_action: (name: string) => ActionLike | null;
12
+ /** `Gio.ActionMap.remove_action`: removing an unknown name does nothing. */
13
+ remove_action: (name: string) => void;
6
14
  private _menubar;
7
15
  private _menubarObserver;
8
16
  static get observedAttributes(): string[];
@@ -13,7 +21,7 @@ export declare class GtkApplicationWindow extends GtkWindow {
13
21
  * The menubar strip, created once and reused: `strips()` and `extraSlots()` both ask for
14
22
  * it, so whichever runs first builds it and the other finds it.
15
23
  */
16
- private menubarSection;
24
+ protected menubarSection(): HTMLDivElement;
17
25
  /**
18
26
  * Titlebar, then menubar, then content — the order `update_menubar` parents the bar at
19
27
  * (:418) inside a window whose titlebar sits above its own child.
@@ -31,6 +39,6 @@ export declare class GtkApplicationWindow extends GtkWindow {
31
39
  * The observer is what makes the second half live: `bindSlottedChildren` adopts a
32
40
  * `slot="menubar"` child after connect, and a bar that appeared then must appear.
33
41
  */
34
- private _followMenubar;
35
- private _renderMenubar;
42
+ protected _followMenubar(): void;
43
+ protected _renderMenubar(): void;
36
44
  }
@@ -13,6 +13,12 @@ export declare class GtkWindow extends HTMLElement {
13
13
  private _titleLabel;
14
14
  /** Watches the strip for an author's titlebar arriving after the build. */
15
15
  private _titlebarObserver;
16
+ /** `is-active` and `focus-widget`; `maximized` stays the attribute above. */
17
+ private readonly _members;
18
+ private readonly _closing;
19
+ private readonly _syncActive;
20
+ private readonly _onFocusIn;
21
+ private readonly _onFocusOut;
16
22
  static get observedAttributes(): string[];
17
23
  /**
18
24
  * `Gtk.Window:title` — the window's title.
@@ -54,6 +60,9 @@ export declare class GtkWindow extends HTMLElement {
54
60
  private _offByDefault;
55
61
  connectedCallback(): void;
56
62
  disconnectedCallback(): void;
63
+ private _watchActivity;
64
+ private _documentIsActive;
65
+ private _notifyMember;
57
66
  /**
58
67
  * A `slot="titlebar"` child adopted AFTER the build has to take the strip over from the
59
68
  * server-side decoration, and `_render` is the one that notices — nothing else here runs
@@ -70,11 +79,22 @@ export declare class GtkWindow extends HTMLElement {
70
79
  * call's invariant (see `slotted-children.ts`).
71
80
  */
72
81
  protected strips(): Node[];
82
+ /**
83
+ * Whether this window has a titlebar strip at all. `Adw.Window` has none (it styles nothing
84
+ * itself, you pair it with a header bar), so a subclass answers `false` and neither the
85
+ * `titlebar` slot nor the server-side decoration is built.
86
+ */
87
+ protected hasTitlebar(): boolean;
73
88
  /** The slots a subclass adds beside `titlebar`; none by default. */
74
89
  protected extraSlots(): AdwSlot[];
75
90
  attributeChangedCallback(name: string): void;
76
91
  private _property;
77
92
  private _render;
93
+ /**
94
+ * The frame's box from `default-width` / `default-height`; an absent one clears it. A subclass
95
+ * with a size request of its own (`Adw.Window`'s 360×200) replaces this.
96
+ */
97
+ protected renderFrameSize(): void;
78
98
  /**
79
99
  * The strip, in the two shapes a window can be in. With a `titlebar` child the strip
80
100
  * holds exactly that — GTK hands the whole titlebar to the bar, decorations and all. With
@@ -90,8 +110,32 @@ export declare class GtkWindow extends HTMLElement {
90
110
  * it, hide the window when `hide-on-close` is set and DESTROY it otherwise. "Destroy" is
91
111
  * the one word this port cannot mean — a page has no unref — so the default detaches the
92
112
  * frame, which is the same observable outcome for everything above it.
113
+ *
114
+ * A frame that is not in the page is not realized, so there is nothing to close; a listener
115
+ * that calls `close()` again is ignored, as GTK ignores it. Answers whether the window went
116
+ * away (hidden or detached), `false` when a listener took the request over or it was ignored.
93
117
  */
94
118
  close(): boolean;
119
+ /**
120
+ * `gtk_window_present`: show the frame. GTK also raises and focuses the toplevel, which is
121
+ * the window manager's to grant; a page owns no such surface, so this is only the first half.
122
+ */
123
+ present(): void;
124
+ /** `Gtk.Window:is-active` — see the header: the document's focus, while this frame is shown. */
125
+ get isActive(): boolean;
126
+ /** `gtk_window_is_active`. */
127
+ is_active(): boolean;
128
+ /** `Gtk.Window:focus-widget`, read live from the document. */
129
+ get focusWidget(): Element | null;
130
+ /** `gtk_window_get_focus`: the element inside the frame that has focus, or `null`. */
131
+ get_focus(): Element | null;
132
+ /**
133
+ * `gtk_window_set_focus`. `null` clears the focus. An element outside the frame is refused:
134
+ * GTK's window only focuses its own descendants.
135
+ */
136
+ set_focus(widget: Element | null): void;
137
+ /** `gtk_window_is_maximized`: the FRAME's state, not the browser window's. */
138
+ is_maximized(): boolean;
95
139
  /**
96
140
  * `gtk_window_maximize`. ASYNCHRONOUS in GTK — the GIR says so at gtkwindow.c:1044 — so
97
141
  * the property is the thing a caller watches, and this writes it directly rather than
@@ -1 +1,7 @@
1
+ import { type WindowSubject } from '@gjsify/adwaita-core/conformance';
2
+ /** The `Gtk.Window` conformance subject for any window element (`gtk-window`, `adw-window`, …). */
3
+ export declare function webWindowSubject(tag: string): {
4
+ subject: WindowSubject;
5
+ dispose: () => void;
6
+ };
1
7
  export declare const GtkWindowTest: () => Promise<void>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Render Pango markup into `target`, replacing its content — the one door every
3
+ * `use-markup` surface in this package goes through.
4
+ *
5
+ * The `null` branch is the C fallback and is the SECURITY property: markup that does not
6
+ * parse is written as TEXT, so an unrecognised tag can never become an element. Callers
7
+ * that want markup only when a caller has asked for it read that from their own flag and
8
+ * pass plain text here — this function never decides whether markup is meant.
9
+ */
10
+ export declare function renderPangoMarkup(target: HTMLElement, markup: string): void;
@@ -0,0 +1 @@
1
+ export declare const PangoMarkupTest: () => Promise<void>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A recognisable copy glyph rendered inline so the opt-in `source-view` subpath needs no
3
+ * icon CSS. `doc` is a parameter so a caller outside the main document (a shadow root in
4
+ * another frame) gets nodes its own tree can adopt.
5
+ */
6
+ export declare function createCopyGlyph(doc?: Document): SVGSVGElement;
@@ -0,0 +1 @@
1
+ export declare const CopyGlyphTest: () => Promise<void>;