@gjsify/adwaita-core 0.31.0 → 0.32.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.
Files changed (112) hide show
  1. package/lib/esm/about-dialog.js +3 -0
  2. package/lib/esm/action-row.js +1 -0
  3. package/lib/esm/avatar.js +1 -0
  4. package/lib/esm/banner.js +1 -0
  5. package/lib/esm/button-content.js +1 -0
  6. package/lib/esm/carousel.js +1 -0
  7. package/lib/esm/checks.js +1 -0
  8. package/lib/esm/chrome.js +1 -0
  9. package/lib/esm/conformance/about-dialog.js +6 -0
  10. package/lib/esm/conformance/action-row.js +1 -0
  11. package/lib/esm/conformance/avatar.js +1 -0
  12. package/lib/esm/conformance/banner.js +1 -0
  13. package/lib/esm/conformance/button-content.js +1 -0
  14. package/lib/esm/conformance/carousel.js +1 -0
  15. package/lib/esm/conformance/checks.js +1 -0
  16. package/lib/esm/conformance/chrome.js +1 -0
  17. package/lib/esm/conformance/data-grid.js +1 -0
  18. package/lib/esm/conformance/dialog.js +1 -0
  19. package/lib/esm/conformance/entry-row.js +1 -0
  20. package/lib/esm/conformance/index.js +1 -0
  21. package/lib/esm/conformance/navigation-view.js +1 -0
  22. package/lib/esm/conformance/popover.js +1 -0
  23. package/lib/esm/conformance/preferences.js +1 -0
  24. package/lib/esm/conformance/rows.js +1 -0
  25. package/lib/esm/conformance/sidebar.js +1 -0
  26. package/lib/esm/conformance/split-button.js +1 -0
  27. package/lib/esm/conformance/split-view.js +1 -0
  28. package/lib/esm/conformance/tab-view.js +1 -0
  29. package/lib/esm/conformance/view-stack.js +1 -0
  30. package/lib/esm/conformance/view-switcher.js +1 -0
  31. package/lib/esm/conformance/wrap-box.js +1 -0
  32. package/lib/esm/data-grid.js +1 -0
  33. package/lib/esm/dialog.js +1 -1
  34. package/lib/esm/entry-row.js +1 -0
  35. package/lib/esm/glib.js +1 -0
  36. package/lib/esm/index.js +1 -1
  37. package/lib/esm/navigation-view.js +1 -0
  38. package/lib/esm/popover.js +1 -0
  39. package/lib/esm/preferences.js +1 -0
  40. package/lib/esm/rows.js +1 -1
  41. package/lib/esm/sidebar.js +1 -0
  42. package/lib/esm/split-button.js +1 -0
  43. package/lib/esm/split-view.js +1 -0
  44. package/lib/esm/tab-view.js +1 -0
  45. package/lib/esm/view-stack.js +1 -0
  46. package/lib/esm/view-switcher.js +1 -0
  47. package/lib/types/about-dialog.d.ts +391 -0
  48. package/lib/types/about-dialog.spec.d.ts +2 -0
  49. package/lib/types/action-row.d.ts +270 -0
  50. package/lib/types/action-row.spec.d.ts +2 -0
  51. package/lib/types/avatar.d.ts +112 -0
  52. package/lib/types/avatar.spec.d.ts +2 -0
  53. package/lib/types/banner.d.ts +104 -0
  54. package/lib/types/banner.spec.d.ts +2 -0
  55. package/lib/types/button-content.d.ts +141 -0
  56. package/lib/types/button-content.spec.d.ts +2 -0
  57. package/lib/types/carousel.d.ts +535 -0
  58. package/lib/types/carousel.spec.d.ts +2 -0
  59. package/lib/types/checks.d.ts +63 -0
  60. package/lib/types/checks.spec.d.ts +2 -0
  61. package/lib/types/chrome.d.ts +355 -0
  62. package/lib/types/chrome.spec.d.ts +2 -0
  63. package/lib/types/conformance/about-dialog.d.ts +300 -0
  64. package/lib/types/conformance/action-row.d.ts +186 -0
  65. package/lib/types/conformance/avatar.d.ts +61 -0
  66. package/lib/types/conformance/banner.d.ts +91 -0
  67. package/lib/types/conformance/button-content.d.ts +110 -0
  68. package/lib/types/conformance/carousel.d.ts +284 -0
  69. package/lib/types/conformance/checks.d.ts +29 -0
  70. package/lib/types/conformance/chrome.d.ts +195 -0
  71. package/lib/types/conformance/data-grid.d.ts +134 -0
  72. package/lib/types/conformance/dialog.d.ts +97 -0
  73. package/lib/types/conformance/entry-row.d.ts +185 -0
  74. package/lib/types/conformance/index.d.ts +44 -0
  75. package/lib/types/conformance/navigation-view.d.ts +235 -0
  76. package/lib/types/conformance/popover.d.ts +56 -0
  77. package/lib/types/conformance/preferences.d.ts +170 -0
  78. package/lib/types/conformance/rows.d.ts +51 -0
  79. package/lib/types/conformance/sidebar.d.ts +182 -0
  80. package/lib/types/conformance/split-button.d.ts +189 -0
  81. package/lib/types/conformance/split-view.d.ts +290 -0
  82. package/lib/types/conformance/tab-view.d.ts +441 -0
  83. package/lib/types/conformance/view-stack.d.ts +121 -0
  84. package/lib/types/conformance/view-switcher.d.ts +443 -0
  85. package/lib/types/conformance/wrap-box.d.ts +134 -0
  86. package/lib/types/data-grid.d.ts +140 -0
  87. package/lib/types/data-grid.spec.d.ts +2 -0
  88. package/lib/types/dialog.d.ts +144 -0
  89. package/lib/types/entry-row.d.ts +308 -0
  90. package/lib/types/entry-row.spec.d.ts +2 -0
  91. package/lib/types/glib.d.ts +49 -0
  92. package/lib/types/index.d.ts +43 -4
  93. package/lib/types/navigation-view.d.ts +343 -0
  94. package/lib/types/navigation-view.spec.d.ts +2 -0
  95. package/lib/types/popover.d.ts +155 -0
  96. package/lib/types/popover.spec.d.ts +2 -0
  97. package/lib/types/preferences.d.ts +349 -0
  98. package/lib/types/preferences.spec.d.ts +2 -0
  99. package/lib/types/rows.d.ts +49 -2
  100. package/lib/types/sidebar.d.ts +308 -0
  101. package/lib/types/sidebar.spec.d.ts +2 -0
  102. package/lib/types/split-button.d.ts +316 -0
  103. package/lib/types/split-button.spec.d.ts +2 -0
  104. package/lib/types/split-view.d.ts +714 -0
  105. package/lib/types/split-view.spec.d.ts +2 -0
  106. package/lib/types/tab-view.d.ts +616 -0
  107. package/lib/types/tab-view.spec.d.ts +2 -0
  108. package/lib/types/view-stack.d.ts +266 -0
  109. package/lib/types/view-stack.spec.d.ts +2 -0
  110. package/lib/types/view-switcher.d.ts +521 -0
  111. package/lib/types/view-switcher.spec.d.ts +2 -0
  112. package/package.json +8 -4
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,616 @@
1
+ /**
2
+ * Input shape for a tab page.
3
+ *
4
+ * Every optional field takes `null` as "absent" because that is what
5
+ * `getAttribute` returns. `title` and `tooltip` coerce `null` to `''` exactly as
6
+ * `adw_tab_page_set_title`/`set_tooltip` do (`g_set_str (&self->title, title ?
7
+ * title : "")`, adw-tab-view.c:3021, :3064); `icon` and `indicatorIcon` stay
8
+ * `null`, because "no icon" is a state `tabIconState` branches on.
9
+ *
10
+ * There is deliberately no `pinned` and no `parentId` here: a page's pinned
11
+ * state may only change through {@link TabViewState.setPagePinned}, which has to
12
+ * re-order at the same time (adw-tab-view.c:4059-4078), and the parent is an
13
+ * argument of {@link TabViewState.addPage}, mirroring
14
+ * `adw_tab_view_add_page (self, child, parent)`.
15
+ */
16
+ export interface AdwTabPageSpec<T = unknown> {
17
+ /**
18
+ * Stable identity of the page. libadwaita keys everything by the `AdwTabPage`
19
+ * POINTER — never by title — so a string id is the platform-neutral stand-in,
20
+ * and two pages sharing an id would be two pages sharing a pointer. Ids are
21
+ * therefore unique per view; a duplicate is refused, not silently accepted.
22
+ */
23
+ id: string;
24
+ /** Tab label. `null`/absent is `''`, never `undefined`. */
25
+ title?: string | null;
26
+ /** Tooltip; falls back to the title when empty ({@link tabTooltip}). */
27
+ tooltip?: string | null;
28
+ /** GTK icon name shown in the tab, or `null` for none. */
29
+ icon?: string | null;
30
+ /** Icon shown in the indicator slot (`AdwTabPage:indicator-icon`), or `null`. */
31
+ indicatorIcon?: string | null;
32
+ /** Whether the tab draws a spinner instead of its icon (`AdwTabPage:loading`). */
33
+ loading?: boolean;
34
+ /** Whether the tab draws the attention dot (`AdwTabPage:needs-attention`). */
35
+ needsAttention?: boolean;
36
+ /** The renderer's page node — an `HTMLElement` on web, a NativeScript `View` on NS. */
37
+ content?: T;
38
+ }
39
+ /**
40
+ * A resolved page, as a renderer reads it.
41
+ *
42
+ * Fully readonly: the C setters all notify, so a renderer that mutates a record
43
+ * in place would repaint nothing. Every field has a
44
+ * `TabViewState.setPage<Field>` counterpart which emits an `'updated'` change.
45
+ */
46
+ export interface AdwTabPageState<T = unknown> {
47
+ /** Stable identity — the stand-in for the `AdwTabPage` pointer. */
48
+ readonly id: string;
49
+ /** Tab label, already coerced from `null` to `''`. */
50
+ readonly title: string;
51
+ /** Tooltip, already coerced from `null` to `''`. Empty means "use the title". */
52
+ readonly tooltip: string;
53
+ /** GTK icon name, or `null` when the page has none. */
54
+ readonly icon: string | null;
55
+ /** Indicator icon name, or `null`. */
56
+ readonly indicatorIcon: string | null;
57
+ /** Whether a spinner replaces the icon. */
58
+ readonly loading: boolean;
59
+ /** Whether the attention indicator is drawn. */
60
+ readonly needsAttention: boolean;
61
+ /** Whether the page sits in the pinned prefix — see {@link TabViewState.setPagePinned}. */
62
+ readonly pinned: boolean;
63
+ /** Id of the page this one was opened from, or `null`. Drives the close successor. */
64
+ readonly parentId: string | null;
65
+ /** Whether a {@link TabViewState.closePage} is awaiting {@link TabViewState.closePageFinish}. */
66
+ readonly closing: boolean;
67
+ /** The renderer's page node, `undefined` for a headless page. */
68
+ readonly content: T | undefined;
69
+ }
70
+ /**
71
+ * The `close-page` seam — the one place the widget asks the application a
72
+ * question, in the same shape as `AdwToastQueueHandlers`.
73
+ *
74
+ * Return `true` to confirm the close, `false` to deny it, or `'defer'` to hold
75
+ * the page in the closing state until {@link TabViewState.closePageFinish} is
76
+ * called — which is how an app shows a "save before closing?" dialog. With no
77
+ * handler installed the default is `!page.pinned`, i.e. `close_page_cb`'s
78
+ * `adw_tab_view_close_page_finish (self, page, !adw_tab_page_get_pinned (page))`
79
+ * (adw-tab-view.c:1987-1993).
80
+ */
81
+ export interface TabViewHandlers<T = unknown> {
82
+ /** Decide the fate of a close request. */
83
+ onClosePage?: (page: AdwTabPageState<T>) => boolean | 'defer';
84
+ }
85
+ /**
86
+ * Payload of a selection change — the `notify::selected-page` half.
87
+ *
88
+ * Deliberately four plain fields and no live model object: this escapes into
89
+ * consumer code as a DOM `CustomEvent.detail` / a NativeScript event, and handing
90
+ * out the record would let a listener mutate the view's own page.
91
+ */
92
+ export interface TabViewSelectionChange {
93
+ /** Id of the newly-selected page, `null` when the view is empty. */
94
+ selectedId: string | null;
95
+ /** Its index, `-1` when the view is empty (`detach_page`, adw-tab-view.c:1912-1913). */
96
+ selectedIndex: number;
97
+ /** Id of the page that was selected before, `null` when there was none. */
98
+ previousId: string | null;
99
+ /**
100
+ * `true` for an explicit selection (a tab click, a keyboard shortcut, a
101
+ * {@link TabViewState.setSelectedPage} call); `false` for one the model made
102
+ * on its own — the auto-select of the first page and the close successor.
103
+ *
104
+ * libadwaita notifies identically on both (`set_selected_page`,
105
+ * adw-tab-view.c:1854); the flag exists so a bound tab bar can tell a user
106
+ * pick from a model-driven one, exactly as `ViewStackState` tags its own.
107
+ */
108
+ interactive: boolean;
109
+ }
110
+ /** Subscriber for {@link TabViewState} selection changes. */
111
+ export type TabViewSelectionListener = (change: TabViewSelectionChange) => void;
112
+ /**
113
+ * What happened to the page LIST — the `page-attached` / `page-detached` /
114
+ * `page-reordered` signals (adw-tab-view.c:1778, :1932, :4561) plus the two the
115
+ * C expresses as per-page `notify::` instead of a view signal.
116
+ *
117
+ * `'pinned'` is `adw_tab_view_set_page_pinned`'s combined flip-and-re-order
118
+ * (:4059-4078); `'updated'` stands in for `notify::title` / `::tooltip` /
119
+ * `::icon` / `::loading` / `::indicator-icon` / `::needs-attention`, which
120
+ * `AdwTab` connects to in order to re-render one tab live (adw-tab.c:930-931).
121
+ */
122
+ export type TabViewPagesChangeKind = 'attached' | 'detached' | 'reordered' | 'pinned' | 'updated';
123
+ /**
124
+ * One page-list change. A renderer subscribes to this to insert, remove or move
125
+ * exactly ONE tab instead of rebuilding the bar — which is what both ports did
126
+ * (web built the bar once at connect and never again; NS tore down and rebuilt
127
+ * every button on every close).
128
+ */
129
+ export interface TabViewPagesChange {
130
+ /** Which kind of change this is. */
131
+ kind: TabViewPagesChangeKind;
132
+ /** The page it happened to. */
133
+ id: string;
134
+ /** Its index AFTER the change; for `'detached'`, the index it was removed from. */
135
+ position: number;
136
+ /** Its index BEFORE the change; `-1` for `'attached'`. */
137
+ previousPosition: number;
138
+ }
139
+ /** Subscriber for {@link TabViewState} page-list changes. */
140
+ export type TabViewPagesListener = (change: TabViewPagesChange) => void;
141
+ /** What a tab draws in its icon and indicator slots — the result of {@link tabIconState}. */
142
+ export interface TabIconState {
143
+ /** The icon name to paint, or `null` when there is none to paint. */
144
+ icon: string | null;
145
+ /** Whether a spinner replaces the icon image. */
146
+ spinner: boolean;
147
+ /** Whether the icon slot is shown at all. */
148
+ iconVisible: boolean;
149
+ /** Whether the indicator slot is shown at all. */
150
+ indicatorVisible: boolean;
151
+ }
152
+ /**
153
+ * `Adw.TabBar:autohide` defaults to TRUE (adw-tab-bar.c:606-607, and
154
+ * `self->autohide = TRUE` in init, :781).
155
+ *
156
+ * Named so a renderer whose spelling cannot express it — an HTML boolean
157
+ * attribute is absent-means-false, so `<adw-tab-view autohide>` inverts the
158
+ * platform default — is making a DELIBERATE, citable decision rather than a
159
+ * silent one.
160
+ */
161
+ export declare const DEFAULT_TAB_AUTOHIDE = true;
162
+ /**
163
+ * Whether `Adw.TabBar` shows its tabs: `!autohide || nPages > 1 ||
164
+ * nPinnedPages >= 1 || isTransferringPage` (`update_autohide_cb`,
165
+ * adw-tab-bar.c:142-164).
166
+ *
167
+ * The `nPinnedPages >= 1` clause is the one that surprises — a single PINNED tab
168
+ * keeps the bar up — and it is missing from the web port, which only ever
169
+ * compared the page count. The `isTransferringPage` clause keeps the bar up
170
+ * while a drag is in flight so there is somewhere to drop.
171
+ */
172
+ export declare function tabsRevealed(state: {
173
+ /** `AdwTabBar:autohide`. */
174
+ autohide: boolean;
175
+ /** `adw_tab_view_get_n_pages`. */
176
+ nPages: number;
177
+ /** `adw_tab_view_get_n_pinned_pages`. */
178
+ nPinnedPages: number;
179
+ /** `adw_tab_view_get_is_transferring_page` — a drag-n-drop tab transfer is running. */
180
+ isTransferringPage: boolean;
181
+ }): boolean;
182
+ /**
183
+ * Whether a tab shows its close button: `!pinned && ((hovering && fullyVisible)
184
+ * || selected || dragging)`.
185
+ *
186
+ * The three-term half is `update_state` (adw-tab.c:124); the `!pinned` gate is
187
+ * applied once at construction, where a pinned tab hides both its title and its
188
+ * close button outright (adw-tab.c:645-650). Each port shipped a different
189
+ * SINGLE term of this: web showed the button unconditionally, NS only on the
190
+ * selected tab. The `fullyVisible` conjunct is why a hovered tab that is half
191
+ * scrolled out of the bar shows nothing.
192
+ */
193
+ export declare function tabCloseVisible(state: {
194
+ /** Pointer is over the tab. */
195
+ hovering: boolean;
196
+ /** The tab is not clipped by the bar's scroll region. */
197
+ fullyVisible: boolean;
198
+ /** The tab is the selected one. */
199
+ selected: boolean;
200
+ /** The tab is being dragged. */
201
+ dragging: boolean;
202
+ /** The tab is pinned. */
203
+ pinned: boolean;
204
+ }): boolean;
205
+ /**
206
+ * The tooltip a tab shows: its own `tooltip` when non-empty, otherwise the page
207
+ * title (`update_tooltip`, adw-tab.c:137-146; identical in
208
+ * adw-tab-thumbnail.c). Neither port had tooltips at all.
209
+ */
210
+ export declare function tabTooltip(page: Pick<AdwTabPageState, 'tooltip' | 'title'>): string;
211
+ /**
212
+ * Whether {@link tabTooltip}'s result is Pango MARKUP rather than plain text.
213
+ *
214
+ * C branches on exactly this: a non-empty `tooltip` goes through
215
+ * `gtk_widget_set_tooltip_markup`, the title fallback through
216
+ * `gtk_widget_set_tooltip_text` (adw-tab.c:141-146). The distinction is not
217
+ * cosmetic — a renderer that pushed a marked-up tooltip through an HTML sink
218
+ * would be executing page-supplied markup, and one that escaped the title would
219
+ * show the escapes.
220
+ */
221
+ export declare function tabTooltipIsMarkup(page: Pick<AdwTabPageState, 'tooltip'>): boolean;
222
+ /**
223
+ * What a tab paints in its icon + indicator slots (`update_icons`,
224
+ * adw-tab.c:171-198).
225
+ *
226
+ * Three rules, in the order C applies them: `loading` wins and installs a
227
+ * spinner WITHOUT replacing the icon name (so the icon reappears when loading
228
+ * ends); a PINNED page with no icon of its own falls back to the view's
229
+ * `default-icon`; and the icon slot is shown iff there is something to show AND
230
+ * the page is either not pinned or has no indicator — on a pinned tab the
231
+ * indicator REPLACES the icon, because a pinned tab is a single-glyph chip.
232
+ *
233
+ * Neither port models loading, indicators or a default icon; this is the
234
+ * derivation they need before they can.
235
+ */
236
+ export declare function tabIconState<T>(page: Pick<AdwTabPageState<T>, 'icon' | 'indicatorIcon' | 'loading' | 'pinned'>, defaultIcon: string | null): TabIconState;
237
+ /**
238
+ * Whether `pageId` is `parentId` or a (possibly indirect) descendant of it —
239
+ * `is_descendant_of` (adw-tab-view.c:1735-1742).
240
+ *
241
+ * The loop is `while (page && page != parent) page = parent_of (page);` and it
242
+ * therefore returns TRUE for `page == parent` WITHOUT taking a step. That
243
+ * non-obvious identity case is what makes "close a tab you opened from another
244
+ * tab" land back on the opener: when the previous page IS the parent, the
245
+ * descendant branch fires and selects it instead of falling through to the next
246
+ * page.
247
+ */
248
+ export declare function isDescendantOfPage<T>(pages: readonly AdwTabPageState<T>[], pageId: string | null, parentId: string): boolean;
249
+ /**
250
+ * Which page ends up selected once `closingId` is removed — the pure kernel of
251
+ * `select_previous_page` (adw-tab-view.c:1857-1897), extracted so the rule is
252
+ * testable without a live view.
253
+ *
254
+ * Ranked, and the ranking is the point:
255
+ * 1. the closing page is not the selected one → nothing moves (the C returns at
256
+ * :1864-1865, so `set_selected_page` is never called and NOTHING notifies);
257
+ * 2. it has a parent and is not first, and the PREVIOUS page is a descendant of
258
+ * that parent → the previous page (:1869-1878) — a page is its own
259
+ * descendant, so "the previous page IS the opener" hits this branch;
260
+ * 3. same, but the previous page and the parent are BOTH pinned → the parent
261
+ * (:1885-1890), because a page opened from a pinned parent is placed after
262
+ * the LAST pinned page rather than directly after its parent;
263
+ * 4. otherwise the next page, else the previous page (:1893-1896);
264
+ * 5. neither exists → `null`, i.e. the view empties.
265
+ *
266
+ * Returns `selectedId` unchanged in case 1, so the caller can compare and skip
267
+ * the notification. Takes no `nPinnedPages`: the two pinned tests read
268
+ * `page.pinned` off the records, and a parameter nothing reads is worse than a
269
+ * signature that does not have it.
270
+ */
271
+ export declare function successorAfterClose<T>(pages: readonly AdwTabPageState<T>[], closingId: string, selectedId: string | null): string | null;
272
+ /**
273
+ * The `Adw.TabView` model: an ordered page list with a pinned prefix, a selected
274
+ * page, and the close protocol — with the C guard, ordering and successor rules
275
+ * applied once for every renderer.
276
+ *
277
+ * `T` is the renderer's page-content type; the machine never looks inside it.
278
+ * Nothing here renders, reads a global or holds a timer, so an instance is a
279
+ * plain value a test can drive step by step.
280
+ */
281
+ export declare class TabViewState<T = unknown> {
282
+ /**
283
+ * The ordered list + the selection, composed rather than restated —
284
+ * `ViewStackState` already owns the index guards, the
285
+ * selection-follows-the-page bookkeeping and the fan-out. Its `name` is this
286
+ * view's page id and its `content` is the tab record; its `title`/`icon` are
287
+ * never read here, because a tab's title is mutable and a second copy of it
288
+ * would be a second truth.
289
+ */
290
+ private readonly _stack;
291
+ private readonly _handlers;
292
+ private readonly _selectionListeners;
293
+ private readonly _pagesListeners;
294
+ private readonly _diagnostics;
295
+ private _selectedId;
296
+ /** Set while an insert runs — see {@link _deferredSelection}. */
297
+ private _deferSelection;
298
+ /**
299
+ * A selection change parked until the `'attached'` change has gone out.
300
+ *
301
+ * This is C's `g_object_freeze_notify` / `thaw_notify` around `insert_page`
302
+ * (adw-tab-view.c:1947-1961), not a scheduling trick: `attach_page` emits
303
+ * `page-attached` as a SIGNAL (immediate) and the auto-select's
304
+ * `notify::selected-page` only lands at thaw, so a renderer is guaranteed to
305
+ * have built the tab before it is told to mark it selected.
306
+ */
307
+ private _deferredSelection;
308
+ private _pagesSource;
309
+ private _pagesView;
310
+ constructor(handlers?: TabViewHandlers<T>);
311
+ /** Subscribe to selection changes. Returns an unsubscribe function. */
312
+ subscribe(listener: TabViewSelectionListener): () => void;
313
+ /**
314
+ * Subscribe to page-list changes. Returns an unsubscribe function.
315
+ *
316
+ * Kept separate from {@link subscribe} because libadwaita keeps them separate
317
+ * too — `props[PROP_SELECTED_PAGE]` versus the `AdwTabPages` list model — and
318
+ * a renderer needs them at different granularities.
319
+ */
320
+ subscribePages(listener: TabViewPagesListener): () => void;
321
+ private _emitSelection;
322
+ private _emitPages;
323
+ private _flushDeferredSelection;
324
+ /**
325
+ * Every page in order — a frozen projection, so a renderer cannot reorder the
326
+ * model by writing to the array it was handed.
327
+ *
328
+ * Cached against the inner list's identity rather than an invalidation flag:
329
+ * `ViewStackState` drops its own cached projection on exactly the structural
330
+ * changes that matter, so there is no second bookkeeping to forget to update.
331
+ */
332
+ get pages(): readonly AdwTabPageState<T>[];
333
+ /** Number of pages — `adw_tab_view_get_n_pages` (adw-tab-view.c:3610). */
334
+ get nPages(): number;
335
+ /**
336
+ * Number of pinned pages — `adw_tab_view_get_n_pinned_pages`
337
+ * (adw-tab-view.c:3628).
338
+ *
339
+ * DERIVED from the prefix invariant instead of bookkept as C's
340
+ * `set_n_pinned_pages` counter is (:1696-1706). The invariant "the pinned
341
+ * pages are exactly `[0, nPinnedPages)`" is what every insert, reorder and
342
+ * first/last hop depends on; deriving the count makes it machine-true rather
343
+ * than something four mutators must each remember to keep true.
344
+ */
345
+ get nPinnedPages(): number;
346
+ /**
347
+ * The page at `position`, or `null`.
348
+ *
349
+ * Refuses a non-integer, negative or out-of-range position instead of
350
+ * clamping: `adw_tab_view_get_nth_page` takes an `int` and asserts
351
+ * `position >= 0` / `position < n_pages` (adw-tab-view.c:4126-4134), and no
352
+ * clamping path exists anywhere in the file. This single guard is what the
353
+ * NativeScript port lacked when a fractional index blanked the widget.
354
+ */
355
+ getNthPage(position: number): AdwTabPageState<T> | null;
356
+ /** Index of the page with `id`, `-1` when absent — `adw_tab_view_get_page_position` (:4152). */
357
+ getPagePosition(id: string): number;
358
+ /** The page with `id`, or `null`. */
359
+ getPage(id: string): AdwTabPageState<T> | null;
360
+ /** Whether `id` is waiting for a {@link closePageFinish} (`page->closing`, :4396-4399). */
361
+ isClosing(id: string): boolean;
362
+ /**
363
+ * Every diagnostic C would have printed as a `g_return_if_fail` warning, in
364
+ * order — an unknown page id, a duplicate id, an insert or reorder outside
365
+ * its partition. Kept as data so a test can assert on the class instead of on
366
+ * stderr, exactly as `ViewStackState.diagnostics` does.
367
+ */
368
+ get diagnostics(): readonly string[];
369
+ /** Id of the selected page, `null` when the view is empty. */
370
+ get selectedId(): string | null;
371
+ /** Index of the selected page, `-1` when the view is empty. */
372
+ get selectedIndex(): number;
373
+ /** The selected page, or `null`. */
374
+ get selectedPage(): AdwTabPageState<T> | null;
375
+ /**
376
+ * Select a page by id. Returns whether the selection changed.
377
+ *
378
+ * An unknown id is refused, and `null` is accepted only while the view is
379
+ * empty — `adw_tab_view_set_selected_page` asserts `ADW_IS_TAB_PAGE` +
380
+ * `page_belongs_to_this_view` when `n_pages > 0` and `selected_page == NULL`
381
+ * otherwise (adw-tab-view.c:3686-3693).
382
+ *
383
+ * `interactive` defaults to `true` because this IS the explicit call, the
384
+ * same convention `ViewStackState.setVisibleIndex` uses; the model-driven
385
+ * paths (the first-page auto-select and the close successor) pass `false`.
386
+ */
387
+ setSelectedPage(id: string | null, interactive?: boolean): boolean;
388
+ /**
389
+ * Select the page at `n` — the Alt+1…Alt+9 / Alt+0 path (`select_nth_page_cb`,
390
+ * adw-tab-view.c:2136-2163; Alt+0 is `n = 9`, since pages count from 0).
391
+ *
392
+ * Pure delegation to the composed selection primitive, which already refuses
393
+ * a non-integer, a negative, an out-of-range and the already-selected index
394
+ * and emits nothing for any of them (adw-tab-view.c:2145, :2158-2159). That
395
+ * is the whole reason this family builds ON `ViewStackState` instead of
396
+ * beside it.
397
+ */
398
+ selectNthPage(n: number): boolean;
399
+ /**
400
+ * Select the page before the selected one; `false` when it is already first
401
+ * (`adw_tab_view_select_previous_page`, adw-tab-view.c:3708-3730). Does NOT
402
+ * wrap — {@link cyclePreviousPage} is the wrapping variant.
403
+ */
404
+ selectPreviousPage(): boolean;
405
+ /**
406
+ * Select the page after the selected one; `false` when it is already last
407
+ * (`adw_tab_view_select_next_page`, adw-tab-view.c:3741-3763). Does NOT wrap.
408
+ */
409
+ selectNextPage(): boolean;
410
+ /**
411
+ * Select the first page in the selected page's own partition, hopping the
412
+ * partition boundary once (`adw_tab_view_select_first_page`,
413
+ * adw-tab-view.c:3764-3789).
414
+ *
415
+ * From a non-pinned page it goes to index `nPinnedPages` — the first
416
+ * NON-pinned tab — and only when that is already the selected page does it
417
+ * fall through to index 0, i.e. into pinned territory. From a pinned page
418
+ * there is no fallback, so Ctrl+Home on the first pinned tab does nothing.
419
+ */
420
+ selectFirstPage(): boolean;
421
+ /**
422
+ * Select the last page in the selected page's own partition, hopping the
423
+ * boundary once (`adw_tab_view_select_last_page`, adw-tab-view.c:3793-3818):
424
+ * from the LAST pinned tab it continues to the last non-pinned one.
425
+ */
426
+ selectLastPage(): boolean;
427
+ /**
428
+ * Ctrl+Tab: the next page, WRAPPING to the first (`select_page_cb`'s forward
429
+ * branch, adw-tab-view.c:2030-2041).
430
+ *
431
+ * Returns `false` outright on a view of one page or fewer — the shortcut
432
+ * PROPAGATES there rather than ringing the error bell (:2008), which is how
433
+ * Ctrl+Tab keeps working for whatever contains the tab view.
434
+ */
435
+ cycleNextPage(): boolean;
436
+ /**
437
+ * Ctrl+Shift+Tab: the previous page, WRAPPING to the last
438
+ * (`select_page_cb`'s backward branch, adw-tab-view.c:2017-2028).
439
+ *
440
+ * Ctrl+Home / Ctrl+End take the `last` branch of the same callback and map to
441
+ * {@link selectFirstPage} / {@link selectLastPage}, which deliberately do NOT
442
+ * wrap.
443
+ */
444
+ cyclePreviousPage(): boolean;
445
+ /**
446
+ * Add a page opened FROM `parentId`, deriving its position instead of taking
447
+ * one (`adw_tab_view_add_page`, adw-tab-view.c:4188-4223). Returns the
448
+ * position used, or `-1` when the page was refused.
449
+ *
450
+ * Three rules: a `null` parent appends; a PINNED parent inserts after the last
451
+ * pinned page (a pinned tab has no room for its children beside it); and a
452
+ * non-pinned parent inserts after the parent AND after every consecutive
453
+ * descendant of it, so opening three links from one tab keeps them in the
454
+ * order they were opened rather than reversing them.
455
+ *
456
+ * The new page is never itself pinned — `create_and_insert_page` is called
457
+ * with `pinned = FALSE` even for a pinned parent (:4222).
458
+ */
459
+ addPage(spec: AdwTabPageSpec<T>, parentId?: string | null): number;
460
+ /**
461
+ * Insert a NON-pinned page at `position`, which must be in
462
+ * `[nPinnedPages, nPages]` — inserting before a pinned page is a programmer
463
+ * error C refuses outright (`adw_tab_view_insert`, adw-tab-view.c:4246-4247).
464
+ * Returns the position, or `-1` when refused.
465
+ */
466
+ insertPage(spec: AdwTabPageSpec<T>, position: number): number;
467
+ /** Insert as the FIRST non-pinned page (`adw_tab_view_prepend`, adw-tab-view.c:4262). */
468
+ prependPage(spec: AdwTabPageSpec<T>): number;
469
+ /** Insert as the LAST non-pinned page (`adw_tab_view_append`, adw-tab-view.c:4284). */
470
+ appendPage(spec: AdwTabPageSpec<T>): number;
471
+ /**
472
+ * Insert a PINNED page at `position`, which must be in `[0, nPinnedPages]` —
473
+ * a pinned page after a non-pinned one is refused
474
+ * (`adw_tab_view_insert_pinned`, adw-tab-view.c:4312-4313).
475
+ * Returns the position, or `-1` when refused.
476
+ */
477
+ insertPinnedPage(spec: AdwTabPageSpec<T>, position: number): number;
478
+ /** Insert as the FIRST pinned page (`adw_tab_view_prepend_pinned`, adw-tab-view.c:4331). */
479
+ prependPinnedPage(spec: AdwTabPageSpec<T>): number;
480
+ /** Insert as the LAST pinned page (`adw_tab_view_append_pinned`, adw-tab-view.c:4353). */
481
+ appendPinnedPage(spec: AdwTabPageSpec<T>): number;
482
+ private _insert;
483
+ /**
484
+ * Pin or unpin a page AND re-order it in the same step, returning its new
485
+ * position — or `-1` when it is already in that state
486
+ * (`adw_tab_view_set_page_pinned`, adw-tab-view.c:4047-4086).
487
+ *
488
+ * Pinning moves the page to index `nPinnedPages`; unpinning moves it to
489
+ * `nPinnedPages - 1`. Both are computed from the count BEFORE the flip, and
490
+ * both are indices into the list WITHOUT the moved page — which is why
491
+ * unpinning the SECOND of two pinned pages returns 1 and moves nothing while
492
+ * still changing the pinned count.
493
+ *
494
+ * This is the single derivation neither port has and the one most likely to
495
+ * be got wrong by hand.
496
+ */
497
+ setPagePinned(id: string, pinned: boolean): number;
498
+ /**
499
+ * Request that `id` be closed, opening the two-phase protocol: the page is
500
+ * marked closing, the handler runs, and the close is then confirmed, denied
501
+ * or left deferred (`adw_tab_view_close_page`, adw-tab-view.c:4386-4400).
502
+ *
503
+ * Returns whether the request was STARTED — `false` means it was ignored
504
+ * because the id is unknown or the page is already awaiting a
505
+ * {@link closePageFinish}. That re-entrancy guard (`if (page->closing)
506
+ * return;`, :4396-4397) is what stops a second click on the close button from
507
+ * running a save dialog twice.
508
+ *
509
+ * With no handler installed a non-pinned page is closed and a PINNED page is
510
+ * denied and stays — `close_page_cb` (:1986-1993).
511
+ */
512
+ closePage(id: string): boolean;
513
+ /**
514
+ * Complete a {@link closePage}. Returns whether the page was detached.
515
+ *
516
+ * `confirm: false` clears the closing flag and leaves the page exactly where
517
+ * it was, so `closePage` can be called for it again; `confirm: true` detaches
518
+ * it (`adw_tab_view_close_page_finish`, adw-tab-view.c:4419-4437). Calling it
519
+ * for a page that is not closing is refused, as C's
520
+ * `g_return_if_fail (page->closing)` is (:4426).
521
+ *
522
+ * Neither renderer had this seam, which is why an app could not show a
523
+ * "save before closing?" dialog on either.
524
+ */
525
+ closePageFinish(id: string, confirm: boolean): boolean;
526
+ /**
527
+ * Remove a page unconditionally, running the successor rule FIRST. Returns
528
+ * the removed page, or `null` when the id is unknown.
529
+ *
530
+ * The order is load-bearing: `detach_page` calls `select_previous_page` at
531
+ * adw-tab-view.c:1906 and only removes at :1915, so the successor is chosen
532
+ * while the closing page is still in the list. Choosing it afterwards gives
533
+ * different answers for every parent-aware case, because "the previous page"
534
+ * is no longer the same page.
535
+ *
536
+ * Closing the LAST page empties the view: the selection becomes `null` at
537
+ * index `-1` and that DOES notify (:1912-1913) — both ports reported index 0
538
+ * for a page-less view.
539
+ *
540
+ * DEVIATIONS, both deliberate: the empty-view notification is emitted AFTER
541
+ * the removal rather than before it, so a listener reading `pages` and
542
+ * `selectedIndex` during the callback sees one consistent state; and pages
543
+ * parented to the removed one are re-pointed at its own parent, which C gets
544
+ * for free from `page_parent_notify_cb` (:293-303) when the detached page is
545
+ * finalized — without it a dangling parent id would quietly disable the
546
+ * successor rule for every child.
547
+ */
548
+ detachPage(id: string): AdwTabPageState<T> | null;
549
+ /**
550
+ * Request a close for every page except `id`
551
+ * (`adw_tab_view_close_other_pages`, adw-tab-view.c:4444-4463).
552
+ *
553
+ * The walk is DESCENDING, and that is part of the spec rather than an
554
+ * implementation detail: each confirmed close shifts every later index, so an
555
+ * ascending walk would skip pages. The ids are snapshotted first, so a
556
+ * handler that adds a page mid-batch cannot make the batch visit it.
557
+ */
558
+ closeOtherPages(id: string): void;
559
+ /** Request a close for every page before `id`, descending (adw-tab-view.c:4485). */
560
+ closePagesBefore(id: string): void;
561
+ /** Request a close for every page after `id`, descending (adw-tab-view.c:4511). */
562
+ closePagesAfter(id: string): void;
563
+ /**
564
+ * Move a page to `position` WITHIN ITS OWN PARTITION. Returns whether it
565
+ * moved (`adw_tab_view_reorder_page`, adw-tab-view.c:4526-4569).
566
+ *
567
+ * A pinned page may only land in `[0, nPinnedPages)` and a non-pinned one in
568
+ * `[nPinnedPages, nPages)`; anything else is the programmer error C refuses
569
+ * (:4542-4548). An unchanged position returns `false` without emitting
570
+ * (:4552-4553) — which is what makes `reorderFirst` on the first non-pinned
571
+ * tab a no-op rather than a drag into pinned territory.
572
+ */
573
+ reorderPage(id: string, position: number): boolean;
574
+ /**
575
+ * Move a page one slot earlier, stopping at its partition's first index
576
+ * (`adw_tab_view_reorder_backward`, adw-tab-view.c:4586-4604) — so the first
577
+ * NON-pinned tab cannot be dragged into pinned territory.
578
+ */
579
+ reorderBackward(id: string): boolean;
580
+ /**
581
+ * Move a page one slot later, stopping at its partition's last index
582
+ * (`adw_tab_view_reorder_forward`, adw-tab-view.c:4617-4635).
583
+ */
584
+ reorderForward(id: string): boolean;
585
+ /** Move a page to the first slot of its partition (adw-tab-view.c:4646-4661). */
586
+ reorderFirst(id: string): boolean;
587
+ /** Move a page to the last slot of its partition (adw-tab-view.c:4672-4687). */
588
+ reorderLast(id: string): boolean;
589
+ private _reorderMissing;
590
+ /**
591
+ * Set a page's title; `null` becomes `''`, matching
592
+ * `g_set_str (&self->title, title ? title : "")` (adw-tab-view.c:3021).
593
+ * Returns whether it changed.
594
+ *
595
+ * The whole reason this exists: `AdwTab` connects to `notify::title` and
596
+ * re-renders the label live (adw-tab.c:930-931), while both ports snapshotted
597
+ * the title once — the web one even declaring `observedAttributes = ['title']`
598
+ * with no `attributeChangedCallback` behind it.
599
+ */
600
+ setPageTitle(id: string, title: string | null): boolean;
601
+ /** Set a page's tooltip; `null` becomes `''` (adw-tab-view.c:3064). */
602
+ setPageTooltip(id: string, tooltip: string | null): boolean;
603
+ /** Set a page's icon name, `null` for none (`adw_tab_page_set_icon`, adw-tab-view.c:3101). */
604
+ setPageIcon(id: string, icon: string | null): boolean;
605
+ /** Set a page's indicator icon, `null` for none (adw-tab-view.c:3198). */
606
+ setPageIndicatorIcon(id: string, icon: string | null): boolean;
607
+ /** Set whether the tab draws a spinner (`adw_tab_page_set_loading`, adw-tab-view.c:3143). */
608
+ setPageLoading(id: string, loading: boolean): boolean;
609
+ /** Set the attention indicator (`adw_tab_page_set_needs_attention`, adw-tab-view.c:3333). */
610
+ setPageNeedsAttention(id: string, needsAttention: boolean): boolean;
611
+ private _update;
612
+ /** The mutable records, in order — the same objects {@link pages} exposes readonly. */
613
+ private _records;
614
+ private _recordAt;
615
+ private _recordOf;
616
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;