@gjsify/gtk-host 0.47.0 → 0.49.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 (53) hide show
  1. package/README.md +158 -2
  2. package/lib/esm/adjustment.js +1 -0
  3. package/lib/esm/conformance/diagnostics.js +1 -1
  4. package/lib/esm/conformance/index.js +1 -2
  5. package/lib/esm/conformance/tree.js +2 -0
  6. package/lib/esm/conformance/window-chrome.js +1 -0
  7. package/lib/esm/descriptors/adw.js +1 -1
  8. package/lib/esm/descriptors/gtk.js +1 -1
  9. package/lib/esm/descriptors/index.js +1 -1
  10. package/lib/esm/errors.js +1 -1
  11. package/lib/esm/font-families.js +1 -0
  12. package/lib/esm/fonts.js +1 -1
  13. package/lib/esm/host.js +1 -1
  14. package/lib/esm/index.js +1 -1
  15. package/lib/esm/list-model.js +1 -0
  16. package/lib/esm/menu.js +1 -0
  17. package/lib/esm/policies.js +1 -1
  18. package/lib/esm/probe.js +1 -1
  19. package/lib/esm/props.js +1 -1
  20. package/lib/esm/style/font-family.js +3 -0
  21. package/lib/esm/style/index.js +1 -1
  22. package/lib/esm/style/paint.js +1 -1
  23. package/lib/types/adjustment.d.ts +28 -0
  24. package/lib/types/adjustment.spec.d.ts +2 -0
  25. package/lib/types/attrs.d.ts +79 -0
  26. package/lib/types/conformance/index.d.ts +28 -29
  27. package/lib/types/conformance/tree.d.ts +30 -0
  28. package/lib/types/conformance/vectors.d.mts +6 -0
  29. package/lib/types/conformance/window-chrome.d.ts +29 -0
  30. package/lib/types/descriptors/gtk.d.ts +32 -1
  31. package/lib/types/errors.d.ts +43 -0
  32. package/lib/types/font-families.d.ts +40 -0
  33. package/lib/types/font-families.spec.d.ts +2 -0
  34. package/lib/types/fonts.d.ts +45 -1
  35. package/lib/types/generated/enum-values.d.mts +38 -0
  36. package/lib/types/generated/methods.d.mts +46 -0
  37. package/lib/types/index.d.ts +1 -1
  38. package/lib/types/jsx-runtime.d.ts +2 -2
  39. package/lib/types/list-model.d.ts +38 -0
  40. package/lib/types/list-model.spec.d.ts +2 -0
  41. package/lib/types/menu.d.ts +43 -0
  42. package/lib/types/menu.spec.d.ts +2 -0
  43. package/lib/types/placement.spec.d.ts +2 -0
  44. package/lib/types/policies.d.ts +241 -1
  45. package/lib/types/react-jsx-runtime.d.ts +2 -2
  46. package/lib/types/shared-trees.spec.d.ts +2 -0
  47. package/lib/types/style/font-family.d.ts +64 -0
  48. package/lib/types/style/index.d.ts +3 -1
  49. package/lib/types/style/paint.d.ts +37 -0
  50. package/lib/types/testing/refusal.d.mts +2 -0
  51. package/lib/types/types.d.ts +177 -1
  52. package/lib/types/vue-components.d.ts +2 -2
  53. package/package.json +8 -5
package/README.md CHANGED
@@ -53,6 +53,34 @@ gjs 1.88.1:
53
53
  | a child under a childless widget | `Gtk-WARNING` at exit 0 | throws, naming the three fixes |
54
54
  | `selectable: 'false'` (a string) | JS truthiness makes it TRUE | honours `'true'`/`'false'`, throws on any other string |
55
55
  | a string for a flags property | dropped silently | throws, naming the flags GType and asking for the numeric value |
56
+ | `model: 'Blue'` on a `Gio.ListModel` property | a CRITICAL and an EMPTY list | throws `bad-list-model`, naming the tag and the kind it got |
57
+ | `model: ['a']` on `Gtk.ListView`, whose model is a `Gtk.SelectionModel` | `set_property` turns it into NULL and logs NOTHING — an empty view, and even the diagnostics gate is quiet; constructed with it, GJS throws from inside `materialize` | throws `list-model-mismatch` at the authoring call, naming the type GTK wants |
58
+ | `adjustment: 5` on a `Gtk.Adjustment` property | guesses a GType, stores nothing | throws `bad-adjustment`: a number would be the `value`, which is its own property |
59
+
60
+ ### Values that cross the seam
61
+
62
+ A GObject with no literal spelling can have a PORTABLE form in `@gjsify/adwaita-core`, and
63
+ `coerce` builds the real object from it at the ParamSpec seam — keyed on the property's
64
+ TYPE, read off the installed GTK, never on its name. The table is the list:
65
+
66
+ | authored as | for a property typed | becomes | decided in |
67
+ |---|---|---|---|
68
+ | an array of items, sections and submenus | `GMenuModel` | `Gio.Menu` | ADR 0042 § 8 |
69
+ | an array of strings or `{ value, label }` | `Gio.ListModel` — and only where a `Gtk.StringList` can satisfy it | `Gtk.StringList` of the labels | ADR 0046 § Amendment |
70
+ | an object of any of the six numbers | `Gtk.Adjustment` | `Gtk.Adjustment` | ADR 0047 § Amendment |
71
+
72
+ A real GObject passes straight through in every row, so the imperative path is untouched.
73
+ A `Gtk.StringList` the seam built is UPDATED in place on the next write rather than
74
+ replaced — `AdwComboRow:selected` is a position into the model, and measured on GTK 4.22.4
75
+ a replacement drops it to 0 even for the same strings, while a splice keeps it; an equal
76
+ array writes nothing at all (`list-model.ts`). A menu and an adjustment are replaced, for
77
+ the reasons `menu.ts` and `adjustment.ts` give.
78
+ Each conversion has its inverse (`fromGioMenu`, `fromStringList`, `fromAdjustment`), which
79
+ is what turns "the value maps onto GTK" into a round trip the shared conformance vectors
80
+ drive (`menu.spec.ts`, `list-model.spec.ts`, `adjustment.spec.ts`). The type surfaces
81
+ widen the same properties by the same rule — `WithPortableValues<T>` in `attrs.ts` — so
82
+ `<gtk-list-view model={[…]}>` is a compile error for the reason it is a runtime refusal:
83
+ `Gtk.ListView:model` is a `Gtk.SelectionModel`, which a string list is not.
56
84
 
57
85
  ## The node tree
58
86
 
@@ -77,7 +105,8 @@ already-parented ones, at exit 0.
77
105
  ## Child placement
78
106
 
79
107
  Seven policy kinds, declared per widget as data and dispatched on the policy's
80
- own `kind`. Descriptor lookup is by exact GType name; `mountRoot` is the one path
108
+ own `kind` — and one widget family that takes none of them, § *Node placement*
109
+ below. Descriptor lookup is by exact GType name; `mountRoot` is the one path
81
110
  that walks the type hierarchy (`GObject.type_is_a`, via `nearestRegistered`), so
82
111
  an application's own subclass resolves to its ancestor's rules:
83
112
 
@@ -117,6 +146,130 @@ attachment point, `layout={{ column, row, columnSpan, rowSpan }}` a `coords` cel
117
146
  `layout={{ name, title }}` a `keyed` page. Both are read at placement time, so
118
147
  changing either RE-PLACES the child rather than doing nothing.
119
148
 
149
+ ## Node placement — a portal
150
+
151
+ Every policy above ends in a call on the PARENT, which presumes an answer to a
152
+ question one widget family answers differently: **does this node go into its parent
153
+ at all?** An `Adw.Dialog` does not. It is *presented against* a parent and never
154
+ parented by it, so its position in the authored tree and its position in the GTK
155
+ tree are different places — a portal.
156
+
157
+ Descriptors therefore carry a second, orthogonal declaration
158
+ ([ADR 0045](../../../docs/adr/0045-portal-placement-in-the-gtk-host.md)). `children`
159
+ says how a parent adopts a child; `placement` says whether it adopts one at all.
160
+
161
+ ```ts
162
+ { gtype: 'AdwDialog', ctor: () => Adw.Dialog,
163
+ children: { kind: 'single', set: 'set_child' },
164
+ placement: { kind: 'portal', present: 'present', close: 'force_close' } }
165
+ ```
166
+
167
+ MEASURED on libadwaita 1.9.3 / GTK 4.22.4 / gjs 1.88.1, and every line of the seam
168
+ is one of these:
169
+
170
+ | case | result |
171
+ |---|---|
172
+ | `box.append(dialog)`, box **rooted in a window** | `Adwaita-ERROR`, **SIGABRT, exit 134**, core dump |
173
+ | `box.append(dialog)`, box **detached** | **exit 0, silent** — which is how a bare-box re-test "disproves" the row above |
174
+ | `dialog.present(box)`, box **not** in a window | opens a **separate `GtkWindow`**, exit 0, `visibleDialog` false |
175
+ | `dialog.close()` with `can-close: false` | returns **false**, emits `close-attempt`, **stays up** |
176
+ | `dialog.close()` never presented | `Adwaita-CRITICAL … that's not presented` |
177
+ | `dialog.force_close()` never presented | **silent** |
178
+ | re-`present()` for a second host | `Adwaita-CRITICAL` + `Gtk-WARNING`, **and it does not move** |
179
+ | `notify::root` on a grandchild box | fires on root and again on unroot |
180
+
181
+ So: the declared close is the **forced** one (an unmount is not a user request, and
182
+ it needs no "is it up?" probe); presenting **waits** on the parent's `notify::root`,
183
+ because every framework builds bottom-up and a `<Modal>` inserted before its tree is
184
+ rooted would otherwise float out of the application; the subscription is kept, so a
185
+ subtree moved to another toplevel is re-hosted with a close-then-present rather than
186
+ the critical; and a portal counts for nothing in the sibling index, the tail rotation,
187
+ either slot reader or `addressesOf`.
188
+
189
+ `attached` — "GTK has taken this node" — is written by the present, not by the
190
+ insert. A deferred portal is claimed by the host and not yet taken by GTK, which is
191
+ exactly the distinction that flag exists to keep.
192
+
193
+ Membership is the `Adw.Dialog` family and nothing else: `AdwDialog` plus
194
+ `AdwAboutDialog`, `AdwAlertDialog`, `AdwPreferencesDialog` and `AdwShortcutsDialog`,
195
+ each **named** rather than inherited because descriptor lookup is exact — and
196
+ `placement.spec.ts` walks `GObject.type_is_a(…, Adw.Dialog)` over the registered
197
+ table, so libadwaita's next dialog subclass fails the suite instead of aborting
198
+ somebody's application.
199
+
200
+ ### The quiet half — `toplevel`
201
+
202
+ A `Gtk.Window` is not a portal, and the arity is the reason: `gtk_window_present()`
203
+ takes no argument, so there is nothing to present it *against*. It is a root, with
204
+ one position in the tree rather than two. That made it the OTHER wrong answer to the
205
+ same question, and for a release it was simply not answered
206
+ ([ADR 0054](../../../docs/adr/0054-toplevel-placement-and-the-unparentable-refusal.md)):
207
+
208
+ | case | result |
209
+ |---|---|
210
+ | `box.append(new Gtk.Window())`, box **rooted in a window** | **exit 0, silent** — `get_parent()` is the box, `get_root()` is the window ITSELF |
211
+ | the same window, then `present()` | mapped and visible, **and still in the box's child list** |
212
+ | `close-request` handler returns `true`, then `close()` | window **still mapped and visible** |
213
+ | then `destroy()` | down, silent |
214
+ | `close()` / `destroy()` on a window never presented | **silent**, both |
215
+ | `present()` after either | `Gtk-WARNING **: A window is shown after it has been destroyed` |
216
+
217
+ So the second arm is `{ kind: 'toplevel', present: 'present', close: 'destroy' }`:
218
+ the forced call again, terminal this time; presented eagerly, because there is no
219
+ second position to wait for; honouring an authored `visible: false` rather than
220
+ overruling it. Membership is `Gtk.Root` — 19 classes in the table, 18 of which can
221
+ present themselves. `GtkDragIcon` is the one that cannot and carries no declaration;
222
+ `AdwMessageDialog` is here rather than in the portal family, because it is a
223
+ `GtkWindow`.
224
+
225
+ **Terminal is why the axis has TWO retraction verbs.** `remove` promises a detach a
226
+ later `insert` undoes, and Solid's `removeNode` takes it literally — so running the
227
+ declared close there destroyed the window and presented the corpse. `remove` calls
228
+ `detachOutsideParent`, `destroy` calls `closeOutsideParent`, and the arms differ only
229
+ here: measured, `force_close()` → `present(parent)` re-hosts a dialog with no
230
+ diagnostic, so for a portal both verbs are the same call. A toplevel detaches with
231
+ `set_visible(false)` — measured reversible, one `unmap`, no `close-request`, and the
232
+ window stays in `Gtk.Window.list_toplevels()`, which is what makes it a detach rather
233
+ than a teardown. What wants the terminal verb is a DISCARD, not a particular caller:
234
+ `materialize`'s rollback, `rebuild` and `destroy` are the three places that drop
235
+ `el.widget`, they share one `releaseWidget`, and it closes first — measured, a window
236
+ is in `list_toplevels()` from construction, so dropping the reference alone leaks one
237
+ per construct-only write and one per half-built element a rejected replay rolls back.
238
+
239
+ **ONE RETRACTION PER OPERATION, and the ordering is what delivers it.** `remove` runs the
240
+ detach once; a discard runs the close once; neither runs the other's. That needs a teardown
241
+ NOT to detach first — on the portal arm both verbs name the same method, so `destroy` was
242
+ calling `force_close` twice (counted: 1 → 2, and 2 → 3 after an explicit `remove`). Benign,
243
+ because `force_close` on a node that is not presented is silent and drops no GTK reference,
244
+ which is precisely why nothing could see it: no diagnostic, no effect on screen. So
245
+ `destroy` releases the widget BEFORE it removes, and `rebuild` skips the `removeChild` that
246
+ would do nothing else for a non-parented node. Nothing changes on screen for a toplevel —
247
+ measured, `destroy()` alone is the same single `unmap` as hide-then-destroy — and both arms
248
+ carry a vector counting the calls, because the asymmetry is what hid the defect the first
249
+ time.
250
+
251
+ ### A class that declares neither
252
+
253
+ Both arms are a DECLARATION, and `registerWidget` takes descriptors from applications
254
+ that nothing checks. So the host asks the CLASS —
255
+ `GObject.type_is_a(…, Gtk.Root)` for a toplevel, a `present()` that TAKES AN ARGUMENT
256
+ for a portal, measured over the whole table to be exactly the five `Adw.Dialog`
257
+ descendants. (`Gtk.Popover.present()` exists and takes 0, which is why the arity is
258
+ part of the question and a bare method name is not.)
259
+
260
+ `descriptorProblems()` reports such a class wherever the descriptor is silent, and
261
+ `refuseUnparentable` refuses the child at the insert with a named, catchable error —
262
+ which for the portal arm is the only report that can exist at all, because after the
263
+ append there is no process left to report from. It fires only where `placement` is
264
+ absent, so an explicit `{ kind: 'parented' }` is the way back for a consumer widget
265
+ the oracle reads wrong.
266
+
267
+ And because an abort cannot be observed by the process it kills, three vectors in
268
+ `placement.spec.ts` run in a CHILD process and read its exit signal: the raw append
269
+ is **SIGABRT**, the placement the host uses instead is exit 0, and the toplevel half
270
+ is exit 0 with an empty stderr. The first is the negative control that makes the
271
+ other assertions in the file falsifiable at all.
272
+
120
273
  ## Lists — `@gjsify/gtk-host/list`
121
274
 
122
275
  A `Gtk.ListView` is the one thing in GTK4 that cannot be an element: it installs no
@@ -200,7 +353,10 @@ the readers every vector asserts through:
200
353
  `descendants()` — read the **real** widget tree. A renderer that asserts against
201
354
  its own bookkeeping agrees with itself while the window is wrong.
202
355
  - `installDiagnosticsGate()` — GTK's failure mode is exit 0, so every vector counts
203
- GLib warnings-or-worse and fails the test that produced one.
356
+ GLib warnings-or-worse and fails the test that produced one. Without it the whole
357
+ mis-parenting class is invisible: a keyed reorder could be a no-op on screen while
358
+ **127 tests stayed green**, and a generic `insert_before` on a `Gtk.ListBox` bypassed
359
+ the row wrap and emitted **1 230 783** `Gtk-WARNING` lines at exit code 0.
204
360
 
205
361
  **One vector table runs through all three adapters.** `conformance/vectors.mts`
206
362
  (a `.mts` file, so it never reaches the published bundle: it imports
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import e from"gi://GObject?version=2.0";import t from"gi://Gtk?version=4.0";import{normalizeAdjustment as n}from"@gjsify/adwaita-core";function buildAdjustment(e){let r=n(e);return new t.Adjustment({lower:r.lower,upper:r.upper,stepIncrement:r.stepIncrement,pageIncrement:r.pageIncrement,pageSize:r.pageSize,value:r.value})}const isPortableAdjustment=t=>typeof t==`object`&&!!t&&!Array.isArray(t)&&!(t instanceof e.Object);function fromAdjustment(e){return{value:e.value,lower:e.lower,upper:e.upper,stepIncrement:e.stepIncrement,pageIncrement:e.pageIncrement,pageSize:e.pageSize}}export{buildAdjustment,fromAdjustment,isPortableAdjustment};
@@ -1,2 +1,2 @@
1
- import"../_virtual/_rolldown/runtime.js";import e from"gi://GLib?version=2.0";const t=[`Vulkan: `];function isEnvironmentDiagnostic(e){return t.some(t=>e.startsWith(t))}let n=null;function describeLogRecord(e,t=new TextDecoder){let text=e=>e instanceof Uint8Array?t.decode(e):String(e),n=e,r=n?.MESSAGE;if(r!=null){let e=text(r);if(e!==``)return e}let i=n?Object.keys(n).filter(e=>e!==`MESSAGE`&&n[e]!==void 0&&n[e]!==null).map(e=>`${e}=${text(n[e])}`):[];return i.length>0?`<no MESSAGE field> ${i.join(` `)}`:`<a log record with no MESSAGE and no other field>`}function installDiagnosticsGate(){if(n)return n;let t=[],r=[],i=new TextDecoder,a=e.getenv(`G_MESSAGES_DEBUG`)!==null;return e.log_set_writer_func((n,o)=>{try{let s=describeLogRecord(o,i),c=n&e.LogLevelFlags.LEVEL_MASK;c<=e.LogLevelFlags.LEVEL_WARNING&&(isEnvironmentDiagnostic(s)?r:t).push(s),(a||c<=e.LogLevelFlags.LEVEL_MESSAGE)&&printerr(s)}catch{printerr(`<gtk-host: a log message could not be decoded>`)}return e.LogWriterOutput.HANDLED}),n={seen:t,environment:r,reset(){t.length=0,r.length=0},assertQuiet(e){let n=r.length;if(r.length=0,t.length===0)return;let i=t.length,a=t.join(`
1
+ import"../_virtual/_rolldown/runtime.js";import e from"gi://GLib?version=2.0";const t=[`Vulkan: `,`gdk_surface_thaw_updates: `];function isEnvironmentDiagnostic(e){return t.some(t=>e.startsWith(t))}let n=null;function describeLogRecord(e,t=new TextDecoder){let text=e=>e instanceof Uint8Array?t.decode(e):String(e),n=e,r=n?.MESSAGE;if(r!=null){let e=text(r);if(e!==``)return e}let i=n?Object.keys(n).filter(e=>e!==`MESSAGE`&&n[e]!==void 0&&n[e]!==null).map(e=>`${e}=${text(n[e])}`):[];return i.length>0?`<no MESSAGE field> ${i.join(` `)}`:`<a log record with no MESSAGE and no other field>`}function installDiagnosticsGate(){if(n)return n;let t=[],r=[],i=new TextDecoder,a=e.getenv(`G_MESSAGES_DEBUG`)!==null;return e.log_set_writer_func((n,o)=>{try{let s=describeLogRecord(o,i),c=n&e.LogLevelFlags.LEVEL_MASK;c<=e.LogLevelFlags.LEVEL_WARNING&&(isEnvironmentDiagnostic(s)?r:t).push(s),(a||c<=e.LogLevelFlags.LEVEL_MESSAGE)&&printerr(s)}catch{printerr(`<gtk-host: a log message could not be decoded>`)}return e.LogWriterOutput.HANDLED}),n={seen:t,environment:r,reset(){t.length=0,r.length=0},assertQuiet(e){let n=r.length;if(r.length=0,t.length===0)return;let i=t.length,a=t.join(`
2
2
  `);t.length=0;let o=n>0?`\n (plus ${n} diagnostic(s) about the HOST's graphics stack, not the tree — see isEnvironmentDiagnostic)`:``;throw Error(`${e?e+`: `:``}GTK reported ${i} diagnostic(s) that would have passed at exit 0:\n ${a}${o}`)}},n}export{describeLogRecord,installDiagnosticsGate,isEnvironmentDiagnostic};
@@ -1,2 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{adderSlots as e,addressOf as t,unhandledPolicy as n}from"../policies.js";import{describeLogRecord as r,installDiagnosticsGate as i,isEnvironmentDiagnostic as a}from"./diagnostics.js";import{BUILTIN_DESCRIPTORS as o}from"../descriptors/index.js";import s from"gi://GObject?version=2.0";function methodsOf(e){switch(e.kind){case`none`:case`uncurated`:return[];case`single`:return[e.set];case`ordered`:return e.after?[e.append,e.after,e.remove]:[e.append,e.remove];case`indexed`:return[e.insert,e.remove];case`slotted`:return e.remove?[...Object.values(e.slots),e.remove]:Object.values(e.slots);case`keyed`:return[e.add,e.remove];case`coords`:return[e.attach,e.remove];default:return n(e)}}function descriptorProblems(e=o){let t=[];for(let n of e){let e;try{e=n.ctor()}catch(e){t.push({gtype:n.gtype,problem:`ctor() threw: ${e.message}`});continue}if(!e)continue;let r=s.type_name(e.$gtype);r!==n.gtype&&t.push({gtype:n.gtype,problem:`ctor() is ${r}, not ${n.gtype}`});for(let i of methodsOf(n.children))typeof e.prototype[i]!=`function`&&t.push({gtype:n.gtype,problem:`declares children.${i}(), which ${r} does not have`});if(n.textSink){let i=e.list_properties().find(e=>e.get_name()===n.textSink);i?(i.flags&s.ParamFlags.WRITABLE)===0?t.push({gtype:n.gtype,problem:`declares a READ-ONLY textSink "${n.textSink}"`}):s.type_is_a(i.value_type,s.TYPE_STRING)||t.push({gtype:n.gtype,problem:`declares textSink "${n.textSink}", which is ${s.type_name(i.value_type)}, not a string`}):t.push({gtype:n.gtype,problem:`declares textSink "${n.textSink}", which ${r} does not have`})}t.push(...policyProblems(n,e,r))}return t}function policyProblems(t,n,r){let i=[],a=n.prototype,o=t.children,requireGetter=(e,n)=>{let o=e.replace(/^set_/,`get_`);typeof a[o]!=`function`&&i.push({gtype:t.gtype,problem:`${n} uses ${e}() but ${r} has no ${o}(), so removal cannot check whether this child is still the one in place`})};if(o.kind===`single`&&requireGetter(o.set,`children.set`),o.kind===`slotted`){for(let[e,t]of Object.entries(o.slots))t.startsWith(`set_`)&&requireGetter(t,`slot "${e}"`);for(let e of Object.keys(o.wrapSlots??{}))e in o.slots||i.push({gtype:t.gtype,problem:`wrapSlots names "${e}", which is not one of ${Object.keys(o.slots).join(`, `)}`});o.defaultSlot in o.slots||i.push({gtype:t.gtype,problem:`defaultSlot "${o.defaultSlot}" is not one of ${Object.keys(o.slots).join(`, `)}`});let n=e(o);n.length>0&&!o.remove&&i.push({gtype:t.gtype,problem:`slot(s) ${n.map(e=>`"${e}"`).join(`, `)} are adder-backed, so removal needs a "remove" method and this policy names none`})}if(o.kind===`ordered`&&o.reorder===`native`&&!o.after&&i.push({gtype:t.gtype,problem:`claims reorder: 'native' with no "after" method — reorderMode() would tell an adapter the wrong thing`}),o.kind===`keyed`){let e=a[o.add],n=o.titled?3:1;typeof e==`function`&&e.length!==n&&i.push({gtype:t.gtype,problem:`titled: ${o.titled} implies ${o.add}() takes ${n} argument(s), but ${r}'s takes ${e.length}`})}return i}function gtkChildren(e){let t=[],n=e;if(typeof n.get_first_child!=`function`)return t;for(let e=n.get_first_child();e;e=e.get_next_sibling())t.push(e);return t}const gtkChildTypes=e=>gtkChildren(e).map(e=>s.type_name(e.constructor.$gtype));function addressesOf(e){let n=[];for(let r=e.first;r;r=r.next)r.kind===`element`&&r.widget&&n.push(t(r));return n}function findDescendant(e,t){let n=[e];for(;n.length>0;){let r=n.shift();if(r!==e&&t(r))return r;n.push(...gtkChildren(r))}return null}function descendants(e){let t=[e];for(let n of gtkChildren(e))t.push(...descendants(n));return t}function dumpTree(e,t=0){let n=s.type_name(e.constructor.$gtype),r=[`${` `.repeat(t)}${n}`];for(let n of gtkChildren(e))r.push(dumpTree(n,t+1));return r.join(`
2
- `)}export{addressesOf,descendants,r as describeLogRecord,descriptorProblems,dumpTree,findDescendant,gtkChildTypes,gtkChildren,i as installDiagnosticsGate,a as isEnvironmentDiagnostic,methodsOf};
1
+ import"../_virtual/_rolldown/runtime.js";import{adderSlots as e,addressOf as t,classPlacementKind as n,isUnparented as r,placementOf as i,unhandledPlacement as a,unhandledPolicy as o}from"../policies.js";import{describeLogRecord as s,installDiagnosticsGate as c,isEnvironmentDiagnostic as l}from"./diagnostics.js";import{descendants as u,dumpTree as d,findDescendant as f,gtkChildTypes as p,gtkChildren as m}from"./tree.js";import{windowChromeCensus as h,windowChromeProblems as g}from"./window-chrome.js";import{BUILTIN_DESCRIPTORS as _}from"../descriptors/index.js";import v from"gi://GObject?version=2.0";function methodsOf(e){switch(e.kind){case`none`:case`uncurated`:return[];case`single`:return[e.set];case`ordered`:return e.after?[e.append,e.after,e.remove]:[e.append,e.remove];case`indexed`:return[e.insert,e.remove];case`slotted`:return e.remove?[...Object.values(e.slots),e.remove]:Object.values(e.slots);case`keyed`:return[e.add,e.remove];case`coords`:return[e.attach,e.remove];default:return o(e)}}function placementMethodsOf(e){switch(e.kind){case`parented`:return[];case`portal`:case`toplevel`:return[e.present,e.close];default:return a(e)}}function presentArityOf(e){switch(e.kind){case`parented`:return null;case`portal`:return 1;case`toplevel`:return 0;default:return a(e)}}function descriptorProblems(e=_){let t=[];for(let r of e){let e;try{e=r.ctor()}catch(e){t.push({gtype:r.gtype,problem:`ctor() threw: ${e.message}`});continue}if(!e)continue;let a=v.type_name(e.$gtype);a!==r.gtype&&t.push({gtype:r.gtype,problem:`ctor() is ${a}, not ${r.gtype}`});for(let n of methodsOf(r.children))typeof e.prototype[n]!=`function`&&t.push({gtype:r.gtype,problem:`declares children.${n}(), which ${a} does not have`});let o=i(r);for(let n of placementMethodsOf(o))typeof e.prototype[n]!=`function`&&t.push({gtype:r.gtype,problem:`declares placement.${n}(), which ${a} does not have`});let s=presentArityOf(o);if(s!==null&&o.kind!==`parented`){let n=e.prototype[o.present];typeof n==`function`&&n.length!==s&&t.push({gtype:r.gtype,problem:`placement.${o.present}() takes ${n.length} argument(s) on ${a}, and a ${o.kind} is presented with exactly ${s}`})}let c=e.prototype.present,l=n(e.$gtype,c);if(l&&o.kind===`parented`&&typeof c==`function`&&t.push({gtype:r.gtype,problem:l===`toplevel`?`implements Gtk.Root and declares no placement, so a parent would take it as an ordinary child — which GTK accepts at exit 0, leaving a root with a parent; it needs placement: { kind: 'toplevel', … }`:`has a present() that takes a parent and declares no placement, so a parent would call its adder on it — which is g_error() and aborts the process; it needs placement: { kind: 'portal', … }`}),r.textSink){let n=e.list_properties().find(e=>e.get_name()===r.textSink);n?(n.flags&v.ParamFlags.WRITABLE)===0?t.push({gtype:r.gtype,problem:`declares a READ-ONLY textSink "${r.textSink}"`}):v.type_is_a(n.value_type,v.TYPE_STRING)||t.push({gtype:r.gtype,problem:`declares textSink "${r.textSink}", which is ${v.type_name(n.value_type)}, not a string`}):t.push({gtype:r.gtype,problem:`declares textSink "${r.textSink}", which ${a} does not have`})}if(r.children.kind===`indexed`&&r.children.perLineCap!==void 0){let n=r.children.perLineCap,i=e.list_properties().find(e=>e.get_name()===n);i?(i.flags&v.ParamFlags.WRITABLE)===0?t.push({gtype:r.gtype,problem:`declares a READ-ONLY perLineCap "${n}"`}):v.type_is_a(i.value_type,v.TYPE_UINT)||t.push({gtype:r.gtype,problem:`declares perLineCap "${n}", which is ${v.type_name(i.value_type)}, not a count`}):t.push({gtype:r.gtype,problem:`declares perLineCap "${n}", which ${a} does not have`})}t.push(...policyProblems(r,e,a))}return t}function policyProblems(t,n,r){let i=[],a=n.prototype,o=t.children,requireGetter=(e,n)=>{let o=e.replace(/^set_/,`get_`);typeof a[o]!=`function`&&i.push({gtype:t.gtype,problem:`${n} uses ${e}() but ${r} has no ${o}(), so removal cannot check whether this child is still the one in place`})};if(o.kind===`single`&&requireGetter(o.set,`children.set`),o.kind===`slotted`){for(let[e,t]of Object.entries(o.slots))t.startsWith(`set_`)&&requireGetter(t,`slot "${e}"`);for(let e of Object.keys(o.wrapSlots??{}))e in o.slots||i.push({gtype:t.gtype,problem:`wrapSlots names "${e}", which is not one of ${Object.keys(o.slots).join(`, `)}`});o.defaultSlot in o.slots||i.push({gtype:t.gtype,problem:`defaultSlot "${o.defaultSlot}" is not one of ${Object.keys(o.slots).join(`, `)}`});let n=e(o);n.length>0&&!o.remove&&i.push({gtype:t.gtype,problem:`slot(s) ${n.map(e=>`"${e}"`).join(`, `)} are adder-backed, so removal needs a "remove" method and this policy names none`})}if(o.kind===`ordered`&&o.reorder===`native`&&!o.after&&i.push({gtype:t.gtype,problem:`claims reorder: 'native' with no "after" method — reorderMode() would tell an adapter the wrong thing`}),o.kind===`keyed`){let e=a[o.add],n=o.titled?3:1;typeof e==`function`&&e.length!==n&&i.push({gtype:t.gtype,problem:`titled: ${o.titled} implies ${o.add}() takes ${n} argument(s), but ${r}'s takes ${e.length}`})}return i}function addressesOf(e){let n=[];for(let i=e.first;i;i=i.next)i.kind===`element`&&i.widget&&!r(i)&&n.push(t(i));return n}export{addressesOf,u as descendants,s as describeLogRecord,descriptorProblems,d as dumpTree,f as findDescendant,p as gtkChildTypes,m as gtkChildren,c as installDiagnosticsGate,l as isEnvironmentDiagnostic,methodsOf,placementMethodsOf,presentArityOf,h as windowChromeCensus,g as windowChromeProblems};
@@ -0,0 +1,2 @@
1
+ import"../_virtual/_rolldown/runtime.js";import e from"gi://GObject?version=2.0";function gtkChildren(e){let t=[],n=e;if(typeof n.get_first_child!=`function`)return t;for(let e=n.get_first_child();e;e=e.get_next_sibling())t.push(e);return t}const gtkChildTypes=t=>gtkChildren(t).map(t=>e.type_name(t.constructor.$gtype));function findDescendant(e,t){let n=[e];for(;n.length>0;){let r=n.shift();if(r!==e&&t(r))return r;n.push(...gtkChildren(r))}return null}function descendants(e){let t=[e];for(let n of gtkChildren(e))t.push(...descendants(n));return t}function dumpTree(t,n=0){let r=e.type_name(t.constructor.$gtype),i=[`${` `.repeat(n)}${r}`];for(let e of gtkChildren(t))i.push(dumpTree(e,n+1));return i.join(`
2
+ `)}export{descendants,dumpTree,findDescendant,gtkChildTypes,gtkChildren};
@@ -0,0 +1 @@
1
+ import"../_virtual/_rolldown/runtime.js";import{descendants as e}from"./tree.js";import t from"gi://GObject?version=2.0";import n from"gi://Gtk?version=4.0";const typeOf=e=>t.type_name(e.constructor.$gtype)??`(unregistered GType)`,isHeaderBar=e=>e===`AdwHeaderBar`||e===`GtkHeaderBar`;function windowChromeCensus(t){let r=0,i=0,a=0;for(let o of e(t)){let e=typeOf(o);if(isHeaderBar(e)){o.get_mapped()&&a++;continue}if(e!==`GtkWindowControls`)continue;let t=o;!t.get_mapped()||t.get_empty()||(t.get_side()===n.PackType.START?r++:i++)}return{start:r,end:i,headerBars:a,mapped:t.get_mapped()}}function windowChromeProblems(e){let t=windowChromeCensus(e),n=typeOf(e);if(!t.mapped)return[`${n} is not mapped, so nothing under it draws yet and every count is 0 — present() the window before asking, or this reads as green having measured nothing`];let r=[],i=`${t.headerBars} mapped header bar(s)`;for(let[e,a]of[[`start`,t.start],[`end`,t.end]])a<=1||r.push(`${a} sets of window controls draw at the ${e} of their header bar in this ${n}, and a window has one — ${a-1} of those close buttons close nothing the user is looking at (${i})`);return t.start+t.end===0&&r.push(`no window control draws anywhere in this ${n}, so its chrome offers no way to close or move it (${i}) — an Adwaita window carries no titlebar of its own, so a header bar has to`),r}export{windowChromeCensus,windowChromeProblems};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import e from"gi://Adw?version=1";const t=[{gtype:`AdwToggle`,ctor:()=>e.Toggle,children:{kind:`single`,set:`set_child`}},{gtype:`AdwApplicationWindow`,ctor:()=>e.ApplicationWindow,children:{kind:`single`,set:`set_content`}},{gtype:`AdwWindow`,ctor:()=>e.Window,children:{kind:`single`,set:`set_content`}},{gtype:`AdwBin`,ctor:()=>e.Bin,children:{kind:`single`,set:`set_child`}},{gtype:`AdwToolbarView`,ctor:()=>e.ToolbarView,children:{kind:`slotted`,slots:{top:`add_top_bar`,bottom:`add_bottom_bar`,content:`set_content`},defaultSlot:`content`,remove:`remove`}},{gtype:`AdwHeaderBar`,ctor:()=>e.HeaderBar,children:{kind:`slotted`,slots:{start:`pack_start`,end:`pack_end`,title:`set_title_widget`},defaultSlot:`start`,remove:`remove`}},{gtype:`AdwPreferencesGroup`,ctor:()=>e.PreferencesGroup,children:{kind:`ordered`,append:`add`,remove:`remove`,reorder:`remove-all`}},{gtype:`AdwPreferencesPage`,ctor:()=>e.PreferencesPage,children:{kind:`indexed`,insert:`insert`,remove:`remove`,wrap:null}},{gtype:`AdwActionRow`,ctor:()=>e.ActionRow,children:{kind:`slotted`,slots:{prefix:`add_prefix`,suffix:`add_suffix`},defaultSlot:`suffix`,remove:`remove`}},{gtype:`AdwExpanderRow`,ctor:()=>e.ExpanderRow,children:{kind:`slotted`,slots:{prefix:`add_prefix`,suffix:`add_suffix`,row:`add_row`},defaultSlot:`row`,remove:`remove`,wrapSlots:{row:`list-box-row`}}},{gtype:`AdwStatusPage`,ctor:()=>e.StatusPage,children:{kind:`single`,set:`set_child`}},{gtype:`AdwNavigationView`,ctor:()=>e.NavigationView,children:{kind:`keyed`,add:`add`,remove:`remove`,nameFrom:`tag`,titled:!1}},{gtype:`AdwNavigationPage`,ctor:()=>e.NavigationPage,children:{kind:`single`,set:`set_child`}},{gtype:`AdwViewStack`,ctor:()=>e.ViewStack,children:{kind:`keyed`,add:`add_titled`,remove:`remove`,nameFrom:`name`,titled:!0,hideBeforeRemove:!0}},{gtype:`AdwClamp`,ctor:()=>e.Clamp,children:{kind:`single`,set:`set_child`}},{gtype:`AdwToastOverlay`,ctor:()=>e.ToastOverlay,children:{kind:`single`,set:`set_child`}},{gtype:`AdwClampScrollable`,ctor:()=>e.ClampScrollable,children:{kind:`single`,set:`set_child`}},{gtype:`AdwBreakpointBin`,ctor:()=>e.BreakpointBin,children:{kind:`single`,set:`set_child`}},{gtype:`AdwNavigationSplitView`,ctor:()=>e.NavigationSplitView,children:{kind:`slotted`,slots:{sidebar:`set_sidebar`,content:`set_content`},defaultSlot:`content`}},{gtype:`AdwOverlaySplitView`,ctor:()=>e.OverlaySplitView,children:{kind:`slotted`,slots:{sidebar:`set_sidebar`,content:`set_content`},defaultSlot:`content`}},{gtype:`AdwWrapBox`,ctor:()=>e.WrapBox,children:{kind:`ordered`,append:`append`,after:`insert_child_after`,remove:`remove`,reorder:`native`}}];export{t as ADW_DESCRIPTORS};
1
+ import"../_virtual/_rolldown/runtime.js";import{TOPLEVEL as e}from"./gtk.js";import t from"gi://Adw?version=1";const n={kind:`portal`,present:`present`,close:`force_close`},r=[{gtype:`AdwDialog`,ctor:()=>t.Dialog,children:{kind:`single`,set:`set_child`},placement:n},{gtype:`AdwAlertDialog`,ctor:()=>t.AlertDialog,children:{kind:`uncurated`},placement:n},{gtype:`AdwAboutDialog`,ctor:()=>t.AboutDialog,children:{kind:`uncurated`},placement:n},{gtype:`AdwPreferencesDialog`,ctor:()=>t.PreferencesDialog,children:{kind:`uncurated`},placement:n},{gtype:`AdwShortcutsDialog`,ctor:()=>t.ShortcutsDialog,children:{kind:`uncurated`},placement:n},{gtype:`AdwToggle`,ctor:()=>t.Toggle,children:{kind:`single`,set:`set_child`}},{gtype:`AdwApplicationWindow`,ctor:()=>t.ApplicationWindow,children:{kind:`single`,set:`set_content`},placement:e},{gtype:`AdwWindow`,ctor:()=>t.Window,children:{kind:`single`,set:`set_content`},placement:e},{gtype:`AdwMessageDialog`,ctor:()=>t.MessageDialog,children:{kind:`uncurated`},placement:e},{gtype:`AdwAboutWindow`,ctor:()=>t.AboutWindow,children:{kind:`uncurated`},placement:e},{gtype:`AdwPreferencesWindow`,ctor:()=>t.PreferencesWindow,children:{kind:`uncurated`},placement:e},{gtype:`AdwBin`,ctor:()=>t.Bin,children:{kind:`single`,set:`set_child`}},{gtype:`AdwToolbarView`,ctor:()=>t.ToolbarView,children:{kind:`slotted`,slots:{top:`add_top_bar`,bottom:`add_bottom_bar`,content:`set_content`},defaultSlot:`content`,remove:`remove`}},{gtype:`AdwHeaderBar`,ctor:()=>t.HeaderBar,children:{kind:`slotted`,slots:{start:`pack_start`,end:`pack_end`,title:`set_title_widget`},defaultSlot:`start`,remove:`remove`}},{gtype:`AdwPreferencesGroup`,ctor:()=>t.PreferencesGroup,children:{kind:`ordered`,append:`add`,remove:`remove`,reorder:`remove-all`}},{gtype:`AdwPreferencesPage`,ctor:()=>t.PreferencesPage,children:{kind:`indexed`,insert:`insert`,remove:`remove`,wrap:null}},{gtype:`AdwActionRow`,ctor:()=>t.ActionRow,children:{kind:`slotted`,slots:{prefix:`add_prefix`,suffix:`add_suffix`},defaultSlot:`suffix`,remove:`remove`}},{gtype:`AdwExpanderRow`,ctor:()=>t.ExpanderRow,children:{kind:`slotted`,slots:{prefix:`add_prefix`,suffix:`add_suffix`,row:`add_row`},defaultSlot:`row`,remove:`remove`,wrapSlots:{row:`list-box-row`}}},{gtype:`AdwStatusPage`,ctor:()=>t.StatusPage,children:{kind:`single`,set:`set_child`}},{gtype:`AdwNavigationView`,ctor:()=>t.NavigationView,children:{kind:`keyed`,add:`add`,remove:`remove`,nameFrom:`tag`,titled:!1}},{gtype:`AdwNavigationPage`,ctor:()=>t.NavigationPage,children:{kind:`single`,set:`set_child`}},{gtype:`AdwViewStack`,ctor:()=>t.ViewStack,children:{kind:`keyed`,add:`add_titled`,remove:`remove`,nameFrom:`name`,titled:!0,hideBeforeRemove:!0}},{gtype:`AdwClamp`,ctor:()=>t.Clamp,children:{kind:`single`,set:`set_child`}},{gtype:`AdwToastOverlay`,ctor:()=>t.ToastOverlay,children:{kind:`single`,set:`set_child`}},{gtype:`AdwClampScrollable`,ctor:()=>t.ClampScrollable,children:{kind:`single`,set:`set_child`}},{gtype:`AdwBreakpointBin`,ctor:()=>t.BreakpointBin,children:{kind:`single`,set:`set_child`}},{gtype:`AdwNavigationSplitView`,ctor:()=>t.NavigationSplitView,children:{kind:`slotted`,slots:{sidebar:`set_sidebar`,content:`set_content`},defaultSlot:`content`}},{gtype:`AdwOverlaySplitView`,ctor:()=>t.OverlaySplitView,children:{kind:`slotted`,slots:{sidebar:`set_sidebar`,content:`set_content`},defaultSlot:`content`}},{gtype:`AdwWrapBox`,ctor:()=>t.WrapBox,children:{kind:`ordered`,append:`append`,after:`insert_child_after`,remove:`remove`,reorder:`native`}}];export{r as ADW_DESCRIPTORS};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import e from"gi://Gtk?version=4.0";const t=[{gtype:`GtkBox`,ctor:()=>e.Box,children:{kind:`ordered`,append:`append`,after:`insert_child_after`,remove:`remove`,reorder:`native`}},{gtype:`GtkWindow`,ctor:()=>e.Window,children:{kind:`single`,set:`set_child`}},{gtype:`GtkApplicationWindow`,ctor:()=>e.ApplicationWindow,children:{kind:`single`,set:`set_child`}},{gtype:`GtkScrolledWindow`,ctor:()=>e.ScrolledWindow,children:{kind:`single`,set:`set_child`}},{gtype:`GtkFrame`,ctor:()=>e.Frame,children:{kind:`single`,set:`set_child`}},{gtype:`GtkOverlay`,ctor:()=>e.Overlay,children:{kind:`slotted`,slots:{child:`set_child`,overlay:`add_overlay`},defaultSlot:`child`,remove:`remove_overlay`}},{gtype:`GtkLabel`,ctor:()=>e.Label,children:{kind:`none`},textSink:`label`},{gtype:`GtkButton`,ctor:()=>e.Button,children:{kind:`single`,set:`set_child`},textSink:`label`},{gtype:`GtkToggleButton`,ctor:()=>e.ToggleButton,children:{kind:`single`,set:`set_child`},textSink:`label`},{gtype:`GtkImage`,ctor:()=>e.Image,children:{kind:`none`}},{gtype:`GtkSwitch`,ctor:()=>e.Switch,children:{kind:`none`}},{gtype:`GtkEntry`,ctor:()=>e.Entry,children:{kind:`none`},textSink:`text`},{gtype:`GtkListBox`,ctor:()=>e.ListBox,children:{kind:`indexed`,insert:`insert`,remove:`remove`,wrap:`list-box-row`}},{gtype:`GtkFlowBox`,ctor:()=>e.FlowBox,children:{kind:`indexed`,insert:`insert`,remove:`remove`,wrap:`flow-box-child`}},{gtype:`GtkListBoxRow`,ctor:()=>e.ListBoxRow,children:{kind:`single`,set:`set_child`}},{gtype:`GtkListItem`,ctor:()=>e.ListItem,children:{kind:`single`,set:`set_child`}},{gtype:`GtkListHeader`,ctor:()=>e.ListHeader,children:{kind:`single`,set:`set_child`}},{gtype:`GtkColumnViewCell`,ctor:()=>e.ColumnViewCell,children:{kind:`single`,set:`set_child`}},{gtype:`GtkStack`,ctor:()=>e.Stack,children:{kind:`keyed`,add:`add_titled`,remove:`remove`,nameFrom:`name`,titled:!0}},{gtype:`GtkGrid`,ctor:()=>e.Grid,children:{kind:`coords`,attach:`attach`,remove:`remove`}},{gtype:`GtkHeaderBar`,ctor:()=>e.HeaderBar,children:{kind:`slotted`,slots:{start:`pack_start`,end:`pack_end`,title:`set_title_widget`},defaultSlot:`start`,remove:`remove`}}];export{t as GTK_DESCRIPTORS};
1
+ import"../_virtual/_rolldown/runtime.js";import e from"gi://Gtk?version=4.0";const t={kind:`toplevel`,present:`present`,close:`destroy`},n=[{gtype:`GtkBox`,ctor:()=>e.Box,children:{kind:`ordered`,append:`append`,after:`insert_child_after`,remove:`remove`,reorder:`native`}},{gtype:`GtkWindow`,ctor:()=>e.Window,children:{kind:`single`,set:`set_child`},placement:t},{gtype:`GtkApplicationWindow`,ctor:()=>e.ApplicationWindow,children:{kind:`single`,set:`set_child`},placement:t},{gtype:`GtkDialog`,ctor:()=>e.Dialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkAboutDialog`,ctor:()=>e.AboutDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkMessageDialog`,ctor:()=>e.MessageDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkAssistant`,ctor:()=>e.Assistant,children:{kind:`uncurated`},placement:t},{gtype:`GtkAppChooserDialog`,ctor:()=>e.AppChooserDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkColorChooserDialog`,ctor:()=>e.ColorChooserDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkFileChooserDialog`,ctor:()=>e.FileChooserDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkFontChooserDialog`,ctor:()=>e.FontChooserDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkShortcutsWindow`,ctor:()=>e.ShortcutsWindow,children:{kind:`uncurated`},placement:t},{gtype:`GtkPageSetupUnixDialog`,ctor:()=>e.PageSetupUnixDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkPrintUnixDialog`,ctor:()=>e.PrintUnixDialog,children:{kind:`uncurated`},placement:t},{gtype:`GtkAspectFrame`,ctor:()=>e.AspectFrame,children:{kind:`single`,set:`set_child`}},{gtype:`GtkScrolledWindow`,ctor:()=>e.ScrolledWindow,children:{kind:`single`,set:`set_child`}},{gtype:`GtkFrame`,ctor:()=>e.Frame,children:{kind:`single`,set:`set_child`}},{gtype:`GtkOverlay`,ctor:()=>e.Overlay,children:{kind:`slotted`,slots:{child:`set_child`,overlay:`add_overlay`},defaultSlot:`child`,remove:`remove_overlay`}},{gtype:`GtkLabel`,ctor:()=>e.Label,children:{kind:`none`},textSink:`label`},{gtype:`GtkButton`,ctor:()=>e.Button,children:{kind:`single`,set:`set_child`},textSink:`label`},{gtype:`GtkToggleButton`,ctor:()=>e.ToggleButton,children:{kind:`single`,set:`set_child`},textSink:`label`},{gtype:`GtkImage`,ctor:()=>e.Image,children:{kind:`none`}},{gtype:`GtkSwitch`,ctor:()=>e.Switch,children:{kind:`none`}},{gtype:`GtkEntry`,ctor:()=>e.Entry,children:{kind:`none`},textSink:`text`},{gtype:`GtkListBox`,ctor:()=>e.ListBox,children:{kind:`indexed`,insert:`insert`,remove:`remove`,wrap:`list-box-row`}},{gtype:`GtkFlowBox`,ctor:()=>e.FlowBox,children:{kind:`indexed`,insert:`insert`,remove:`remove`,wrap:`flow-box-child`,perLineCap:`max-children-per-line`}},{gtype:`GtkListBoxRow`,ctor:()=>e.ListBoxRow,children:{kind:`single`,set:`set_child`}},{gtype:`GtkListItem`,ctor:()=>e.ListItem,children:{kind:`single`,set:`set_child`}},{gtype:`GtkListHeader`,ctor:()=>e.ListHeader,children:{kind:`single`,set:`set_child`}},{gtype:`GtkColumnViewCell`,ctor:()=>e.ColumnViewCell,children:{kind:`single`,set:`set_child`}},{gtype:`GtkStack`,ctor:()=>e.Stack,children:{kind:`keyed`,add:`add_titled`,remove:`remove`,nameFrom:`name`,titled:!0}},{gtype:`GtkGrid`,ctor:()=>e.Grid,children:{kind:`coords`,attach:`attach`,remove:`remove`}},{gtype:`GtkHeaderBar`,ctor:()=>e.HeaderBar,children:{kind:`slotted`,slots:{start:`pack_start`,end:`pack_end`,title:`set_title_widget`},defaultSlot:`start`,remove:`remove`}}];export{n as GTK_DESCRIPTORS,t as TOPLEVEL};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{registerWidgets as e}from"../registry.js";import{GENERATED_PROVENANCE as t,GENERATED_WIDGETS as n}from"../generated/widgets.js";import{ADW_DESCRIPTORS as r}from"./adw.js";import{GTK_DESCRIPTORS as i}from"./gtk.js";const a=[...i,...r],o={AdwLayoutSlot:[`id`]};function mergeGenerated(e,t){let n=[...e],r=new Set(e.map(e=>e.gtype));for(let e of t){if(r.has(e.gtype))continue;let t=o[e.gtype];n.push({gtype:e.gtype,ctor:e.ctor,children:{kind:`uncurated`},...t?{requiresProps:t}:{}})}return n}const s=mergeGenerated(a,n);function registerBuiltinWidgets(){e(s)}const tableProvenance=()=>({gir:t,curated:a.length,generated:n.length,total:s.length});export{r as ADW_DESCRIPTORS,s as BUILTIN_DESCRIPTORS,a as CURATED_DESCRIPTORS,t as GENERATED_PROVENANCE,n as GENERATED_WIDGETS,i as GTK_DESCRIPTORS,o as REQUIRED_CONSTRUCT_PROPS,mergeGenerated,registerBuiltinWidgets,tableProvenance};
1
+ import"../_virtual/_rolldown/runtime.js";import{registerWidgets as e}from"../registry.js";import{GENERATED_PROVENANCE as t,GENERATED_WIDGETS as n}from"../generated/widgets.js";import{GTK_DESCRIPTORS as r}from"./gtk.js";import{ADW_DESCRIPTORS as i}from"./adw.js";const a=[...r,...i],o={AdwLayoutSlot:[`id`]};function mergeGenerated(e,t){let n=[...e],r=new Set(e.map(e=>e.gtype));for(let e of t){if(r.has(e.gtype))continue;let t=o[e.gtype];n.push({gtype:e.gtype,ctor:e.ctor,children:{kind:`uncurated`},...t?{requiresProps:t}:{}})}return n}const s=mergeGenerated(a,n);function registerBuiltinWidgets(){e(s)}const tableProvenance=()=>({gir:t,curated:a.length,generated:n.length,total:s.length});export{i as ADW_DESCRIPTORS,s as BUILTIN_DESCRIPTORS,a as CURATED_DESCRIPTORS,t as GENERATED_PROVENANCE,n as GENERATED_WIDGETS,r as GTK_DESCRIPTORS,o as REQUIRED_CONSTRUCT_PROPS,mergeGenerated,registerBuiltinWidgets,tableProvenance};
package/lib/esm/errors.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";var GtkHostError=class extends Error{constructor(e,t){super(t),this.code=e,this.name=`GtkHostError`}};const e={unknownTag:e=>new GtkHostError(`unknown-tag`,`No descriptor registered for <${e}>. Register one with registerWidget({ gtype: '${e}', … }). Being a real GType in the installed typelib is not enough on its own.`),missingConstructProp:(e,t)=>new GtkHostError(`missing-construct-prop`,`<${e}> cannot be constructed without ${t}. In the installed library this is not an exception but a g_error(): the process ABORTS (SIGABRT, exit 134, core dump) with no catch and no diagnostic, so the host refuses here while a refusal is still reportable. Author ${t} on the element.`),unknownProp:(e,t)=>new GtkHostError(`unknown-prop`,`<${e}> has no property "${t}". Check the spelling against the installed GTK (camelCase and kebab-case both resolve), or bind it as a signal with on${t[0]?.toUpperCase()}${t.slice(1)}.`),readOnlyProp:(e,t)=>new GtkHostError(`read-only-prop`,`<${e}>.${t} is read-only in the installed GTK. Writing it is a silent no-op in GObject, so this host refuses it instead of dropping the value.`),badEnum:(e,t,n,r)=>new GtkHostError(`bad-enum`,`<${e}>.${t} expects ${r}, and "${n}" is not one of its values. Note that GObject accepts the wrong string SILENTLY — the property would have kept its old value.`),unknownSignal:(e,t,n)=>new GtkHostError(`unknown-signal`,`<${e}> emits no signal "${n}" (bound as ${t}). Check the spelling against the installed GTK, or use the escape hatch on:<raw-signal-name> if the name is irregular.`),signalTaken:(e,t,n,r)=>new GtkHostError(`signal-taken`,`<${e}> already binds "${r}" through ${n}, so ${t} would silently replace it — GObject has one handler per connect, and this host keeps one per signal name. Use one spelling, or combine the two callbacks yourself.`),eventModifier:(e,t)=>new GtkHostError(`event-modifier`,`${e} carries the DOM listener modifier ".${t}", which has no GObject meaning: a signal is emitted on one object and does not propagate through a tree, so there is no capture phase and nothing to be passive about. Drop the modifier (${e.slice(0,e.length-t.length)}); for GTK4's own propagation phases set "propagation-phase" on a Gtk.EventController instead.`),badString:(e,t,n)=>new GtkHostError(`bad-string`,`<${e}>.${t} is a string property and got a ${n}. Numbers and booleans are stringified; anything else has no unambiguous spelling, and GObject would have thrown from inside the next rebuild.`),badBoolean:(e,t,n)=>new GtkHostError(`bad-boolean`,`<${e}>.${t} is a boolean and got the string "${n}". JS truthiness would make "false" mean TRUE — the exact silent-wrong-value this host exists to refuse. Pass a real boolean.`),badFlags:(e,t,n,r)=>new GtkHostError(`bad-flags`,`<${e}>.${t} expects the flags type ${r}, and a string ("${n}") cannot be resolved to one. Pass the numeric value (bitwise-or the members). GObject would have dropped the string silently.`),unresolvableEnum:e=>new GtkHostError(`unresolvable-enum`,`Cannot resolve the enum type ${e} to a GI namespace. Pass the numeric value instead, or extend ENUM_NAMESPACES in props.ts.`),textNotAccepted:(e,t)=>new GtkHostError(`text-not-accepted`,`<${e}> has no text sink, so the text ${JSON.stringify(t.slice(0,32))} has nowhere to go. Wrap it in a widget that takes text (<GtkLabel>), or set the property directly.`),unclaimedChild:(e,t)=>new GtkHostError(`unclaimed-child`,`<${e}> declares children: { kind: 'none' }, so it cannot adopt <${t}>. Fix one of three things: give the parent a child policy, wrap the child in a container, or set the child on a property (e.g. a "child" or "content" property).`),unknownSlot:(e,t,n)=>new GtkHostError(`unknown-slot`,`<${e}> has no slot "${t}". Known slots: ${n.join(`, `)}.`),slotNeedsRemove:(e,t,n)=>new GtkHostError(`slot-needs-remove`,`<${e}> puts children into slot "${t}" with ${n}() and its policy names no "remove" method, so this child cannot be taken out again. A set_-prefixed slot is emptied by writing null back through the setter and needs nothing; an adder-backed one needs children.remove. Add it to the descriptor.`),rejectedChild:(e,t,n)=>new GtkHostError(`rejected-child`,`<${e}> refused <${t}>: ${n}. The container accepts only certain child types (e.g. AdwPreferencesPage takes AdwPreferencesGroup); the descriptor cannot know that, GTK does.`),uncuratedPlacement:(e,t)=>new GtkHostError(`uncurated-placement`,`<${e}> comes from the GENERATED table, which knows the tag but not how the widget adopts a child, so it cannot take <${t}>. Guessing is the one thing that is not available here: \`add\`, \`append\` and \`set_child\` all exist somewhere in GTK and calling the wrong one is a warning at exit 0. Add a curated policy for ${e} in descriptors/, or mount into a container that has one.`),siblingCycle:e=>new GtkHostError(`sibling-cycle`,`The child list of <${e}> does not terminate. A renderer linked a node to itself or into a loop; the host refuses to walk it rather than spin. This is a host or adapter bug, not an application one — please report it with the reordering that produced it.`),notAWidget:e=>new GtkHostError(`not-a-widget`,`<${e}> is not a Gtk.Widget, so it cannot be placed as a child. Non-widget GObjects (controllers, filters, models) attach to a property, not to a parent.`),occupiedSlot:(e,t,n)=>new GtkHostError(`occupied-slot`,`<${e}> already holds a child the application put there, and ${n}() takes only ONE — placing <${t}> would unparent it. GTK does that silently: no throw, no warning, exit 0, and the application's own widget is simply gone. Mount into a container of your own inside <${e}>, or clear the existing child first (${n}(null)) if replacing it is the intent.`),notAnElement:e=>new GtkHostError(`not-an-element`,`Only an element node owns a widget, and this node is a ${e}. A text node's content lives in its PARENT's text sink and an anchor owns nothing at all — neither has a widget to hand back. Ask the parent element instead.`),destroyedNode:e=>new GtkHostError(`destroyed-node`,`<${e}> was destroyed, so its widget is gone. Asking again would MATERIALISE a fresh, propertyless, unparented widget — \`destroy\` clears props and layout precisely so a destroyed element cannot look re-materialisable — and a caller holding that widget would be looking at nothing on screen.`),notAHostParent:e=>new GtkHostError(`not-a-host-parent`,`insert() needs a host element as the parent and got ${e}. A raw widget cannot be one: the shadow tree lives in the host's own fields, so writing them onto a GObject wrapper renders nothing and reports nothing — Vue's <Teleport to="someWidget"> hands the widget through verbatim and landed exactly here. Wrap it with adopt(widget) first, which is what mountRoot() does.`)};export{GtkHostError,e as err};
1
+ import"./_virtual/_rolldown/runtime.js";var GtkHostError=class extends Error{constructor(e,t){super(t),this.code=e,this.name=`GtkHostError`}};const e={unknownTag:e=>new GtkHostError(`unknown-tag`,`No descriptor registered for <${e}>. Register one with registerWidget({ gtype: '${e}', … }). Being a real GType in the installed typelib is not enough on its own.`),missingConstructProp:(e,t)=>new GtkHostError(`missing-construct-prop`,`<${e}> cannot be constructed without ${t}. In the installed library this is not an exception but a g_error(): the process ABORTS (SIGABRT, exit 134, core dump) with no catch and no diagnostic, so the host refuses here while a refusal is still reportable. Author ${t} on the element.`),unknownProp:(e,t)=>new GtkHostError(`unknown-prop`,`<${e}> has no property "${t}". Check the spelling against the installed GTK (camelCase and kebab-case both resolve), or bind it as a signal with on${t[0]?.toUpperCase()}${t.slice(1)}.`),readOnlyProp:(e,t)=>new GtkHostError(`read-only-prop`,`<${e}>.${t} is read-only in the installed GTK. Writing it is a silent no-op in GObject, so this host refuses it instead of dropping the value.`),noAccessor:(e,t,n)=>new GtkHostError(`no-accessor`,`<${e}>.${t} has to be written through its JS accessor — a null or a list cannot be handed to set_property, which guesses a GType and finds none — and GJS installed no "${n}" on this object. Assigning it anyway would create a plain JS property: no GObject write, no error, and notify::${t} never fires.`),badDetailedAction:(e,t,n)=>new GtkHostError(`bad-detailed-action`,`The menu item "${e}" names the action ${JSON.stringify(t)}, which GIO cannot parse: ${n}. In the installed GIO this is not an exception but a g_error() inside g_menu_item_set_detailed_action: the process ABORTS (SIGABRT, exit 134) with no catch and no diagnostic, so the host refuses here while a refusal is still reportable. A detailed action name is "app.act", "app.act::target" or "app.act(variant)".`),badListModel:(e,t,n)=>new GtkHostError(`bad-list-model`,`<${e}>.${t} is a Gio.ListModel and got ${n}. Write the portable list model — an array of strings or of { value, label } descriptors (ADR 0046) — or a real Gio.ListModel. Anything else reaches set_property as a value GObject cannot store: a CRITICAL at exit 0 and an EMPTY list, which a reader cannot tell from "no items yet".`),listModelMismatch:(e,t,n)=>new GtkHostError(`list-model-mismatch`,`<${e}>.${t} is a ${n}, and the portable list model becomes a Gtk.StringList — a Gio.ListModel, not a ${n}. GObject would turn that write into NULL without a diagnostic and leave the widget empty at exit 0. Wrap it yourself (Gtk.NoSelection.new(new Gtk.StringList({ strings }))), or use @gjsify/gtk-host/list for a factory-driven view.`),badAdjustment:(e,t,n)=>new GtkHostError(`bad-adjustment`,`<${e}>.${t} is a Gtk.Adjustment and got ${n}. Write the portable adjustment — an object naming any of value, lower, upper, stepIncrement, pageIncrement, pageSize (ADR 0047) — or a real Gtk.Adjustment. A bare number is refused on purpose: it would be the value, and value is a property of its own on every widget that takes an adjustment, so ${t}={3} and value={3} would be two spellings of one write.`),badEnum:(e,t,n,r)=>new GtkHostError(`bad-enum`,`<${e}>.${t} expects ${r}, and "${n}" is not one of its values. Note that GObject accepts the wrong string SILENTLY — the property would have kept its old value.`),unknownSignal:(e,t,n)=>new GtkHostError(`unknown-signal`,`<${e}> emits no signal "${n}" (bound as ${t}). Check the spelling against the installed GTK, or use the escape hatch on:<raw-signal-name> if the name is irregular.`),signalTaken:(e,t,n,r)=>new GtkHostError(`signal-taken`,`<${e}> already binds "${r}" through ${n}, so ${t} would silently replace it — GObject has one handler per connect, and this host keeps one per signal name. Use one spelling, or combine the two callbacks yourself.`),eventModifier:(e,t)=>new GtkHostError(`event-modifier`,`${e} carries the DOM listener modifier ".${t}", which has no GObject meaning: a signal is emitted on one object and does not propagate through a tree, so there is no capture phase and nothing to be passive about. Drop the modifier (${e.slice(0,e.length-t.length)}); for GTK4's own propagation phases set "propagation-phase" on a Gtk.EventController instead.`),badString:(e,t,n)=>new GtkHostError(`bad-string`,`<${e}>.${t} is a string property and got a ${n}. Numbers and booleans are stringified; anything else has no unambiguous spelling, and GObject would have thrown from inside the next rebuild.`),badBoolean:(e,t,n)=>new GtkHostError(`bad-boolean`,`<${e}>.${t} is a boolean and got the string "${n}". JS truthiness would make "false" mean TRUE — the exact silent-wrong-value this host exists to refuse. Pass a real boolean.`),badFlags:(e,t,n,r)=>new GtkHostError(`bad-flags`,`<${e}>.${t} expects the flags type ${r}, and a string ("${n}") cannot be resolved to one. Pass the numeric value (bitwise-or the members). GObject would have dropped the string silently.`),unresolvableEnum:e=>new GtkHostError(`unresolvable-enum`,`Cannot resolve the enum type ${e} to a GI namespace. Pass the numeric value instead, or extend ENUM_NAMESPACES in props.ts.`),textNotAccepted:(e,t)=>new GtkHostError(`text-not-accepted`,`<${e}> has no text sink, so the text ${JSON.stringify(t.slice(0,32))} has nowhere to go. Wrap it in a widget that takes text (<GtkLabel>), or set the property directly.`),unclaimedChild:(e,t)=>new GtkHostError(`unclaimed-child`,`<${e}> declares children: { kind: 'none' }, so it cannot adopt <${t}>. Fix one of three things: give the parent a child policy, wrap the child in a container, or set the child on a property (e.g. a "child" or "content" property).`),unknownSlot:(e,t,n)=>new GtkHostError(`unknown-slot`,`<${e}> has no slot "${t}". Known slots: ${n.join(`, `)}.`),slotNeedsRemove:(e,t,n)=>new GtkHostError(`slot-needs-remove`,`<${e}> puts children into slot "${t}" with ${n}() and its policy names no "remove" method, so this child cannot be taken out again. A set_-prefixed slot is emptied by writing null back through the setter and needs nothing; an adder-backed one needs children.remove. Add it to the descriptor.`),rejectedChild:(e,t,n)=>new GtkHostError(`rejected-child`,`<${e}> refused <${t}>: ${n}. The container accepts only certain child types (e.g. AdwPreferencesPage takes AdwPreferencesGroup); the descriptor cannot know that, GTK does.`),uncuratedPlacement:(e,t)=>new GtkHostError(`uncurated-placement`,`<${e}> comes from the GENERATED table, which knows the tag but not how the widget adopts a child, so it cannot take <${t}>. Guessing is the one thing that is not available here: \`add\`, \`append\` and \`set_child\` all exist somewhere in GTK and calling the wrong one is a warning at exit 0. Add a curated policy for ${e} in descriptors/, or mount into a container that has one.`),siblingCycle:e=>new GtkHostError(`sibling-cycle`,`The child list of <${e}> does not terminate. A renderer linked a node to itself or into a loop; the host refuses to walk it rather than spin. This is a host or adapter bug, not an application one — please report it with the reordering that produced it.`),notAWidget:e=>new GtkHostError(`not-a-widget`,`<${e}> is not a Gtk.Widget, so it cannot be placed as a child. Non-widget GObjects (controllers, filters, models) attach to a property, not to a parent.`),occupiedSlot:(e,t,n)=>new GtkHostError(`occupied-slot`,`<${e}> already holds a child the application put there, and ${n}() takes only ONE — placing <${t}> would unparent it. GTK does that silently: no throw, no warning, exit 0, and the application's own widget is simply gone. Mount into a container of your own inside <${e}>, or clear the existing child first (${n}(null)) if replacing it is the intent.`),placementMethodMissing:(e,t,n,r)=>new GtkHostError(`placement-method-missing`,`<${e}> declares placement: { kind: '${t}', ${r}: '${n}' } and the installed class has no ${n}(). A node with this placement is placed by calling that method on the node itself — nothing goes into the parent — so without it the node can never reach the screen and never leave it. Fix the descriptor, or drop the placement and give the widget an ordinary child policy.`),unparentableChild:(e,t,n,r)=>new GtkHostError(`unparentable-child`,`<${e}> cannot adopt <${t}>: ${r}. In the installed libraries placing it anyway is not an exception — it is either a g_error() that ABORTS the process (SIGABRT, exit 134, no catch, no diagnostic) or an acceptance at exit 0 that leaves a root inside a child list — so the host refuses here while a refusal is still reportable. Declare placement: { kind: '${n}', … } on the descriptor for <${t}> so the host places it the way the library does, or, if this widget really is an ordinary child, say so with placement: { kind: 'parented' }.`),notAnElement:e=>new GtkHostError(`not-an-element`,`Only an element node owns a widget, and this node is a ${e}. A text node's content lives in its PARENT's text sink and an anchor owns nothing at all — neither has a widget to hand back. Ask the parent element instead.`),destroyedNode:e=>new GtkHostError(`destroyed-node`,`<${e}> was destroyed, so its widget is gone. Asking again would MATERIALISE a fresh, propertyless, unparented widget — \`destroy\` clears props and layout precisely so a destroyed element cannot look re-materialisable — and a caller holding that widget would be looking at nothing on screen.`),notAHostParent:e=>new GtkHostError(`not-a-host-parent`,`insert() needs a host element as the parent and got ${e}. A raw widget cannot be one: the shadow tree lives in the host's own fields, so writing them onto a GObject wrapper renders nothing and reports nothing — Vue's <Teleport to="someWidget"> hands the widget through verbatim and landed exactly here. Wrap it with adopt(widget) first, which is what mountRoot() does.`)};export{GtkHostError,e as err};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";const e=/^(.*\S)\s\d+pt$/,fold=e=>e.trim().toLowerCase();function matchFontFamily(t,n){let r=fold(t),i=n.find(e=>fold(e)===r);if(i!==void 0)return{declared:t,family:i,kind:`exact`,candidates:[i]};let a=n.filter(t=>{let n=e.exec(t);return n!==null&&fold(n[1])===r});if(a.length===1)return{declared:t,family:a[0],kind:`optical`,candidates:a};if(a.length>1)return{declared:t,family:void 0,kind:`ambiguous`,candidates:a};let o=e.exec(t.trim());if(o!==null){let e=n.find(e=>fold(e)===fold(o[1]));if(e!==void 0)return{declared:t,family:e,kind:`optical`,candidates:[e]}}return{declared:t,family:void 0,kind:`absent`,candidates:[]}}function matchFontFamilies(e,t){return e.map(e=>matchFontFamily(e,t))}function describeFontFamilyMatch(e){switch(e.kind){case`exact`:return`${e.declared}: on the font map under that name`;case`optical`:return`${e.declared}: on the font map as "${e.family}" — this font stack keeps the optical-size axis in the family name, so the declared name resolves to nothing and Pango substitutes the default sans without a word. Ask for the name on the right.`;case`ambiguous`:return`${e.declared}: the font map carries ${e.candidates.length} optical sizes of it (${e.candidates.join(`, `)}) and no family under the declared name. Which one to use at which point size is a design decision, so nothing here picks for you.`;case`absent`:return`${e.declared}: NOT on the font map. Text asking for it renders in a substituted family — Pango does not report a missing family, so nothing else will say so.`}}export{describeFontFamilyMatch,matchFontFamilies,matchFontFamily};
package/lib/esm/fonts.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{isFontFace as e,resolveFontDir as t}from"./font-dir.js";import n from"gi://GLib?version=2.0";import r from"gi://Gio?version=2.0";import i from"gi://PangoCairo?version=1.0";function isUnsupportedByFontMap(e){return e instanceof n.Error&&e.matches(r.io_error_quark(),r.IOErrorEnum.NOT_SUPPORTED)}function initFonts(e={}){let a=t({...e,env:{GJSIFY_FONT_DIR:n.getenv(`GJSIFY_FONT_DIR`)??void 0}}),o=[],s=[],c=[];if(a===void 0)return{dir:a,registered:o,declined:s,failed:c};let l=[];collectFaces(r.File.new_for_path(a),l,c);let u=i.FontMap.get_default();for(let e of l.sort())try{u.add_font_file(e),o.push(e)}catch(t){if(isUnsupportedByFontMap(t)){s.push(e);continue}c.push({path:e,message:messageOf(t)})}for(let e of c)console.warn(`initFonts: ${e.path} could not be read as an application font (${e.message}). Text asking for a family this application ships will render in a substituted one.`);return{dir:a,registered:o,declined:s,failed:c}}function collectFaces(t,n,i){try{let a=t.enumerate_children(`standard::name,standard::type`,r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);for(let t=a.next_file(null);t!==null;t=a.next_file(null)){let o=a.get_child(t),s=o.get_path();s!==null&&(t.get_file_type()===r.FileType.DIRECTORY?collectFaces(o,n,i):e(t.get_name())&&n.push(s))}}catch(e){i.push({path:t.get_path()??``,message:messageOf(e)})}}function messageOf(e){return e instanceof n.Error||e instanceof Error?e.message:String(e)}export{initFonts,isUnsupportedByFontMap};
1
+ import"./_virtual/_rolldown/runtime.js";import{isFontFace as e,resolveFontDir as t}from"./font-dir.js";import{describeFontFamilyMatch as n,matchFontFamilies as r,matchFontFamily as i}from"./font-families.js";import a from"gi://Gio?version=2.0";import o from"gi://GLib?version=2.0";import s from"gi://PangoCairo?version=1.0";function isUnsupportedByFontMap(e){return e instanceof o.Error&&e.matches(a.io_error_quark(),a.IOErrorEnum.NOT_SUPPORTED)}function initFonts(e={}){let i=t({...e,env:{GJSIFY_FONT_DIR:o.getenv(`GJSIFY_FONT_DIR`)??void 0}}),c=[],l=[],u=[],d=e.expectedFamilies??[];if(i===void 0&&d.length===0)return{dir:i,registered:c,declined:l,failed:u,families:[],matches:[]};let f=s.FontMap.get_default(),p=i===void 0?[]:familyNames(f);if(i!==void 0){let e=[];collectFaces(a.File.new_for_path(i),e,u);for(let t of e.sort())try{f.add_font_file(t),c.push(t)}catch(e){if(isUnsupportedByFontMap(e)){l.push(t);continue}u.push({path:t,message:messageOf(e)})}}let m=familyNames(f),h=i===void 0?[]:m.filter(e=>!p.includes(e)).sort(),g=r(d,m);for(let e of u)console.warn(`initFonts: ${e.path} could not be read as an application font (${e.message}). Text asking for a family this application ships will render in a substituted one.`);for(let e of g)e.kind!==`exact`&&console.warn(`initFonts: ${n(e)}`);return{dir:i,registered:c,declined:l,failed:u,families:h,matches:g}}function familyNames(e){return e.list_families().map(e=>e.get_name())}function collectFaces(t,n,r){try{let i=t.enumerate_children(`standard::name,standard::type`,a.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);for(let t=i.next_file(null);t!==null;t=i.next_file(null)){let o=i.get_child(t),s=o.get_path();s!==null&&(t.get_file_type()===a.FileType.DIRECTORY?collectFaces(o,n,r):e(t.get_name())&&n.push(s))}}catch(e){r.push({path:t.get_path()??``,message:messageOf(e)})}}function messageOf(e){return e instanceof o.Error||e instanceof Error?e.message:String(e)}export{n as describeFontFamilyMatch,initFonts,isUnsupportedByFontMap,r as matchFontFamilies,i as matchFontFamily};
package/lib/esm/host.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{GtkHostError as e,err as t}from"./errors.js";import{beginHostWrite as n,clearHandlers as r,endHostWrite as i,isEventProp as a,setHandler as o,toSignalName as s}from"./signals.js";import{addressOf as c,insertChild as l,makeDetachedContainer as u,makeWrapper as d,removeChild as f,setterSlotOf as p,setterSlots as m,slotOccupant as h}from"./policies.js";import{coerce as g,paramSpecs as _,removedValue as v,requireSpec as y,toPropertyName as b}from"./props.js";import{lookupWidget as x,nearestRegistered as S}from"./registry.js";import C from"gi://GObject?version=2.0";function createElement(e,t){let n={kind:`element`,descriptor:x(e),widget:null,wrapper:null,slot:null,parent:null,prev:null,next:null,first:null,last:null,handlers:new Map,listeners:new Map,props:{},layout:null,textFromChildren:!1,attached:!1,destroyed:!1,foreign:[]};if(t)for(let[e,r]of Object.entries(t))setProp(n,e,r);return n}const createText=e=>({kind:`text`,data:e,parent:null,prev:null,next:null}),createAnchor=(e=``)=>({kind:`anchor`,data:e,parent:null,prev:null,next:null}),isText=e=>e.kind===`text`;function materialize(e){if(e.widget)return e.widget;for(let n of e.descriptor.requiresProps??[])if(!(n in e.props))throw t.missingConstructProp(e.descriptor.gtype,n);let a=e.descriptor.ctor(),o=_(a,e.descriptor.gtype),s={};for(let[t,n]of Object.entries(e.props))s[t]=g(y(o,e.descriptor.gtype,t),n,e.descriptor.gtype);n(null);try{e.widget=new a(s)}finally{i()}try{replayInto(e)}catch(t){r(e);for(let t of childSnapshot(e))t.kind===`element`&&t.attached&&(f(e,t),t.attached=!1);throw e.widget=null,e.wrapper=null,t}return e.widget}function replayInto(e){for(let[t,n]of e.listeners)o(e,t,n);for(let t of siblingsFrom(e.first,e))t.kind===`element`&&attach(e,t);e.textFromChildren&&flushText(e)}function setProp(e,t,r,o){if(a(t))return setEventHandler(e,t,r);if(t===`slot`)return setSlot(e,r);if(t===`layout`){let t=r,n=e.parent;if(!n||!e.widget){e.layout=t;return}let i=e.layout;replaceAt(e,n,()=>{e.layout=t},()=>{e.layout=i});return}let s=b(t),c=y(_(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,s),l=r==null,u=l?v(e.descriptor,c):g(c,r,e.descriptor.gtype),d=s in e.props?e.props[s]:void 0;if(l?delete e.props[s]:e.props[s]=r,e.widget){if((c.flags&C.ParamFlags.CONSTRUCT_ONLY)!==0)return rebuild(e,s,d);n(e.widget);try{writeProperty(e.widget,s,u)}finally{i()}}}function writeProperty(e,t,n){if(!Array.isArray(n)){e.set_property(t,n);return}let r=t.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase());e[r]=n}function setEventHandler(e,t,n){e.widget?o(e,t,n):n&&assertSignalExists(e,t),n?e.listeners.set(t,n):e.listeners.delete(t)}function assertSignalExists(e,n){let r=s(n,e.descriptor.eventAliases).split(`::`)[0],i=e.descriptor.ctor().$gtype;if(C.signal_lookup(r,i)===0)throw t.unknownSignal(e.descriptor.gtype,n,r)}function setSlot(e,t){if(e.slot===t)return;let n=e.parent;if(!n||!e.widget){e.slot=t;return}let r=e.slot;replaceAt(e,n,()=>{e.slot=t},()=>{e.slot=r})}function replaceAt(e,t,n,r){f(t,e),e.attached=!1,n();try{attach(t,e)}catch(n){r();try{attach(t,e)}catch{}throw n}}function rebuild(e,t,n){let i=e.parent;if(e.widget){r(e);for(let t of childSnapshot(e))t.kind===`element`&&(f(e,t),t.attached=!1);i&&f(i,e)}e.widget=null,e.wrapper=null,e.attached=!1;try{materialize(e)}catch(r){t!==void 0&&(n===void 0?delete e.props[t]:e.props[t]=n);try{materialize(e),i&&attach(i,e)}catch{}throw r}i&&attach(i,e)}function setText(e,t){e.data=t,e.kind===`text`&&e.parent&&flushText(e.parent)}function setElementText(e,t){writeTextSink(e,t),e.textFromChildren=!1,destroyChildren(e)}function flushText(e){let t=``,n=!1;for(let r of childNodes(e))r.kind===`text`&&(t+=r.data,n=!0);if(t===``&&!e.textFromChildren)return;let r=e.descriptor.textSink;if(t===``&&r&&holdsElementInSetterSlot(e)){e.textFromChildren=!1,delete e.props[r];return}writeTextSink(e,t),e.textFromChildren=n}function*setterSlotChildren(e){for(let t of siblingsFrom(e.first,e))t.kind===`element`&&t.attached&&p(e,t)&&(yield t)}const holdsElementInSetterSlot=e=>!setterSlotChildren(e).next().done;function writeTextSink(e,r){let a=e.descriptor.textSink;if(!a)throw t.textNotAccepted(e.descriptor.gtype,r);materialize(e);let o=e.descriptor.children,s=o.kind===`single`?o.set:null;if(s&&!holdsOursInSlot(e,null)&&appOccupant(e.widget,e.descriptor,s))throw t.occupiedSlot(e.descriptor.gtype,`text`,s);let c=y(_(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,a);n(e.widget);try{e.widget.set_property(a,g(c,r,e.descriptor.gtype))}finally{i()}e.props[a]=r;for(let t of setterSlotChildren(e))t.attached=!1}function*childNodes(e){yield*siblingsFrom(e.first,e)}function childSnapshot(e){let t=[];for(let n of siblingsFrom(e.first,e))t.push(n);return t}function*siblingsFrom(e,n){let r=0;for(let i=e;i;i=i.next){if(++r>1e5)throw t.siblingCycle(n.descriptor.gtype);yield i}}function link(e,t,n){t.parent=e,n?(t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:e.first=t,n.prev=t):(t.prev=e.last,t.next=null,e.last?e.last.next=t:e.first=t,e.last=t)}function unlink(e){let t=e.parent;t&&(e.prev?e.prev.next=e.next:t.first=e.next,e.next?e.next.prev=e.prev:t.last=e.prev,e.prev=null,e.next=null,e.parent=null)}function attach(e,t){if(!e.widget)return;materialize(t),ensureWrapper(e,t),refuseOccupiedSlot(e,t);let n=e.foreign.length>0?e.foreign.filter(t=>t.get_parent()===e.widget):e.foreign,r=n.length>0?n[n.length-1]:null,i=n.length;for(let n of siblingsFrom(e.first,e)){if(n===t)break;n.kind!==`element`||!n.attached||(r=c(n),i+=1)}let a=[];for(let n of siblingsFrom(t.next,e))n.kind===`element`&&n.attached&&a.push(n);l({parent:e,child:t,prevWidget:r,index:i,following:a}),t.attached=!0}function refuseOccupiedSlot(e,n){let r=p(e,n);if(r&&!holdsOursInSlot(e,n.slot)&&appOccupant(e.widget,e.descriptor,r))throw t.occupiedSlot(e.descriptor.gtype,n.descriptor.gtype,r)}function holdsOursInSlot(e,t){for(let n of siblingsFrom(e.first,e))if(n.kind===`element`&&n.attached&&n.slot===t)return!0;return!1}function ensureWrapper(n,r){if(r.wrapper)return;let i;try{i=d(n.descriptor.children,r.widget,r.slot)}catch(i){throw i instanceof e?i:t.rejectedChild(n.descriptor.gtype,r.descriptor.gtype,i.message)}i&&(r.wrapper=i)}function insert(e,t,n=null){assertHostParent(t);let r=e.parent,i=e.next,a=n===e?i:n;e.parent&&remove(e),link(t,e,a);try{e.kind===`element`?attach(t,e):e.kind===`text`&&flushText(t)}catch(t){throw unlink(e),r&&restore(e,r,i),t}}function assertHostParent(e){if(!isHostElement(e))throw t.notAHostParent(describeValue(e))}function isHostElement(e){let t=e;return!!t&&t.kind===`element`&&typeof t.descriptor==`object`}function describeValue(e){if(e==null)return String(e);if(typeof e!=`object`)return`a ${typeof e}`;let t=e.tagName;if(typeof t==`string`)return`a DOM element <${t.toLowerCase()}>`;let n=e.constructor?.$gtype,r=n?C.type_name(n)??`an unnamed GType`:null;if(r!==null&&r!==`JSObject`)return r;let i=e.constructor?.name;return i&&i!==`Object`?`a ${i}`:`a plain object`}function restore(e,t,n){try{link(t,e,n),e.kind===`element`?attach(t,e):e.kind===`text`&&flushText(t)}catch{unlink(e)}}function restoreTextSink(e){let t=e.descriptor.textSink;if(!t||e.destroyed||!e.widget)return;let r=e.descriptor.children;if(r.kind!==`single`||holdsOursInSlot(e,null)||h(e.widget,r.set))return;let a=t.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),o=e.props[t]??e.props[a];if(typeof o!=`string`||o===``)return;let s=y(_(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,t);n(e.widget);try{e.widget.set_property(t,g(s,o,e.descriptor.gtype))}finally{i()}}function remove(e){let t=e.parent;t&&e.kind===`element`&&(f(t,e),e.attached=!1,e.wrapper&&=(e.wrapper.set_child(null),null),restoreTextSink(t)),unlink(e),t&&e.kind===`text`&&flushText(t)}function destroyChildren(e){for(let t of childSnapshot(e))destroy(t)}function disconnectHandlers(e){r(e),e.listeners.clear()}function destroy(e){if(e.kind===`element`&&(destroyChildren(e),r(e),e.listeners.clear()),remove(e),e.kind===`element`){let t=e.widget;t&&typeof t.destroy==`function`&&typeof t.get_parent==`function`&&t.get_parent()===null&&t.destroy(),e.widget=null,e.wrapper=null,e.props={},e.layout=null,e.textFromChildren=!1,e.destroyed=!0}}function mountRoot(e,t){materialize(e),insert(e,adopt(t))}function widgetOf(e){if(e.kind!==`element`)throw t.notAnElement(e.kind);if(e.destroyed)throw t.destroyedNode(e.descriptor.gtype);return materialize(e)}const createDetachedContainer=()=>adopt(u());function adopt(e){let n=e.constructor.$gtype,r=S(n);if(!r)throw t.unknownTag(gtypeNameOf(e));return{kind:`element`,descriptor:r,widget:e,wrapper:null,slot:null,parent:null,prev:null,next:null,first:null,last:null,handlers:new Map,listeners:new Map,props:{},layout:null,textFromChildren:!1,attached:!0,destroyed:!1,foreign:adoptedChildren(e,r)}}function adoptedChildren(e,t){let n=m(t.children);if(n.length===0)return directChildren(e);let r=[];for(let i of n){let n=appOccupant(e,t,i);n&&r.push(n)}return r}function appOccupant(e,t,n){let r=h(e,n);if(!r)return null;let i=t.textSink;if(!i)return r;let a=e[i.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())];return typeof a==`string`&&a!==``?null:r}function directChildren(e){let t=[],n=e;if(typeof n.get_first_child!=`function`)return t;for(let e=n.get_first_child();e;e=e.get_next_sibling())t.push(e);return t}const gtypeNameOf=e=>C.type_name(e.constructor.$gtype),parentNode=e=>e.parent,firstChild=e=>e.first,nextSibling=e=>e.next,prevSibling=e=>e.prev;export{adopt,createAnchor,createDetachedContainer,createElement,createText,describeValue,destroy,destroyChildren,disconnectHandlers,firstChild,insert,isHostElement,isText,materialize,mountRoot,nextSibling,parentNode,prevSibling,remove,setElementText,setEventHandler,setProp,setSlot,setText,widgetOf};
1
+ import"./_virtual/_rolldown/runtime.js";import{GtkHostError as e,err as t}from"./errors.js";import{beginHostWrite as n,clearHandlers as r,endHostWrite as i,isEventProp as a,setHandler as o,toSignalName as s}from"./signals.js";import{addressOf as c,closeOutsideParent as l,detachOutsideParent as u,insertChild as d,isUnparented as f,makeDetachedContainer as p,makeWrapper as m,outsideParentOf as h,placeOutsideParent as g,refuseUnparentable as _,removeChild as v,setterSlotOf as y,setterSlots as b,slotOccupant as x}from"./policies.js";import{reconcileStringList as S}from"./list-model.js";import{coerce as C,isConstructOnly as w,paramSpecs as T,removedValue as E,requireSpec as D,toPropertyName as O}from"./props.js";import{lookupWidget as k,nearestRegistered as A}from"./registry.js";import j from"gi://GObject?version=2.0";function createElement(e,t){let n={kind:`element`,descriptor:k(e),widget:null,wrapper:null,slot:null,parent:null,prev:null,next:null,first:null,last:null,handlers:new Map,listeners:new Map,props:{},layout:null,textFromChildren:!1,attached:!1,destroyed:!1,foreign:[],portalWatch:null};if(t)for(let[e,r]of Object.entries(t))setProp(n,e,r);return n}const createText=e=>({kind:`text`,data:e,parent:null,prev:null,next:null}),createAnchor=(e=``)=>({kind:`anchor`,data:e,parent:null,prev:null,next:null}),isText=e=>e.kind===`text`;function releaseWidget(e){let t=e.widget?h(e.descriptor):null;t&&l(e,t),e.widget=null,e.wrapper=null}function materialize(e){if(e.widget)return e.widget;for(let n of e.descriptor.requiresProps??[])if(!(n in e.props))throw t.missingConstructProp(e.descriptor.gtype,n);let a=e.descriptor.ctor(),o=T(a,e.descriptor.gtype),s={};for(let[t,n]of Object.entries(e.props))s[t]=C(D(o,e.descriptor.gtype,t),n,e.descriptor.gtype);n(null);try{e.widget=new a(s)}finally{i()}try{replayInto(e)}catch(t){r(e);for(let t of childSnapshot(e))t.kind===`element`&&t.attached&&(v(e,t),t.attached=!1);throw releaseWidget(e),t}return e.widget}function replayInto(e){for(let[t,n]of e.listeners)o(e,t,n);for(let t of siblingsFrom(e.first,e))t.kind===`element`&&attach(e,t);e.textFromChildren&&flushText(e)}function setProp(e,t,r,o){if(a(t))return setEventHandler(e,t,r);if(t===`slot`)return setSlot(e,r);if(t===`layout`){let t=r,n=e.parent;if(!n||!e.widget){e.layout=t;return}let i=e.layout;replaceAt(e,n,()=>{e.layout=t},()=>{e.layout=i});return}let s=O(t),c=D(T(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,s),l=r==null,u=l?E(e.descriptor,c):C(c,r,e.descriptor.gtype);e.widget!==null&&takesAccessorRoute(u)&&!w(c)&&requireAccessor(e,e.widget,s);let d=s in e.props?e.props[s]:void 0;if(l?delete e.props[s]:e.props[s]=r,e.widget){if(w(c))return rebuild(e,s,d);n(e.widget);try{S(e.widget,accessorName(s),u)||writeProperty(e.widget,s,u)}finally{i()}}}function writeProperty(e,t,n){if(!takesAccessorRoute(n)){e.set_property(t,n);return}let r=accessorName(t);e[r]=n}const accessorName=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase()),takesAccessorRoute=e=>e===null||Array.isArray(e);function requireAccessor(e,n,r){let i=accessorName(r);if(!(i in n))throw t.noAccessor(e.descriptor.gtype,r,i)}function setEventHandler(e,t,n){e.widget?o(e,t,n):n&&assertSignalExists(e,t),n?e.listeners.set(t,n):e.listeners.delete(t)}function assertSignalExists(e,n){let r=s(n,e.descriptor.eventAliases).split(`::`)[0],i=e.descriptor.ctor().$gtype;if(j.signal_lookup(r,i)===0)throw t.unknownSignal(e.descriptor.gtype,n,r)}function setSlot(e,t){if(e.slot===t)return;let n=e.parent;if(!n||!e.widget){e.slot=t;return}let r=e.slot;replaceAt(e,n,()=>{e.slot=t},()=>{e.slot=r})}function replaceAt(e,t,n,r){v(t,e),e.attached=!1,n();try{attach(t,e)}catch(n){r();try{attach(t,e)}catch{}throw n}}function rebuild(e,t,n){let i=e.parent;if(e.widget){r(e);for(let t of childSnapshot(e))t.kind===`element`&&(v(e,t),t.attached=!1);i&&!h(e.descriptor)&&v(i,e)}releaseWidget(e),e.attached=!1;try{materialize(e)}catch(r){t!==void 0&&(n===void 0?delete e.props[t]:e.props[t]=n);try{materialize(e),i&&attach(i,e)}catch{}throw r}i&&attach(i,e)}function setText(e,t){e.data=t,e.kind===`text`&&e.parent&&flushText(e.parent)}function setElementText(e,t){writeTextSink(e,t),e.textFromChildren=!1,destroyChildren(e)}function flushText(e){let t=``,n=!1;for(let r of childNodes(e))r.kind===`text`&&(t+=r.data,n=!0);if(t===``&&!e.textFromChildren)return;let r=e.descriptor.textSink;if(t===``&&r&&holdsElementInSetterSlot(e)){e.textFromChildren=!1,delete e.props[r];return}writeTextSink(e,t),e.textFromChildren=n}function*setterSlotChildren(e){for(let t of siblingsFrom(e.first,e))t.kind===`element`&&t.attached&&!f(t)&&y(e,t)&&(yield t)}const holdsElementInSetterSlot=e=>!setterSlotChildren(e).next().done;function writeTextSink(e,r){let a=e.descriptor.textSink;if(!a)throw t.textNotAccepted(e.descriptor.gtype,r);materialize(e);let o=e.descriptor.children,s=o.kind===`single`?o.set:null;if(s&&!holdsOursInSlot(e,null)&&appOccupant(e.widget,e.descriptor,s))throw t.occupiedSlot(e.descriptor.gtype,`text`,s);let c=D(T(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,a);n(e.widget);try{e.widget.set_property(a,C(c,r,e.descriptor.gtype))}finally{i()}e.props[a]=r;for(let t of setterSlotChildren(e))t.attached=!1}function*childNodes(e){yield*siblingsFrom(e.first,e)}function childSnapshot(e){let t=[];for(let n of siblingsFrom(e.first,e))t.push(n);return t}function*siblingsFrom(e,n){let r=0;for(let i=e;i;i=i.next){if(++r>1e5)throw t.siblingCycle(n.descriptor.gtype);yield i}}function link(e,t,n){t.parent=e,n?(t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:e.first=t,n.prev=t):(t.prev=e.last,t.next=null,e.last?e.last.next=t:e.first=t,e.last=t)}function unlink(e){let t=e.parent;t&&(e.prev?e.prev.next=e.next:t.first=e.next,e.next?e.next.prev=e.prev:t.last=e.prev,e.prev=null,e.next=null,e.parent=null)}function attach(e,t){if(!e.widget)return;materialize(t);let n=h(t.descriptor);if(n){t.attached=g(e,t,n);return}_(e,t),ensureWrapper(e,t),refuseOccupiedSlot(e,t);let r=e.foreign.length>0?e.foreign.filter(t=>t.get_parent()===e.widget):e.foreign,i=r.length>0?r[r.length-1]:null,a=r.length;for(let n of siblingsFrom(e.first,e)){if(n===t)break;n.kind!==`element`||!n.attached||f(n)||(i=c(n),a+=1)}let o=[];for(let n of siblingsFrom(t.next,e))n.kind===`element`&&n.attached&&!f(n)&&o.push(n);d({parent:e,child:t,prevWidget:i,index:a,following:o}),t.attached=!0}function refuseOccupiedSlot(e,n){let r=y(e,n);if(r&&!holdsOursInSlot(e,n.slot)&&appOccupant(e.widget,e.descriptor,r))throw t.occupiedSlot(e.descriptor.gtype,n.descriptor.gtype,r)}function holdsOursInSlot(e,t){for(let n of siblingsFrom(e.first,e))if(n.kind===`element`&&n.attached&&n.slot===t&&!f(n))return!0;return!1}function ensureWrapper(n,r){if(r.wrapper)return;let i;try{i=m(n.descriptor.children,r.widget,r.slot)}catch(i){throw i instanceof e?i:t.rejectedChild(n.descriptor.gtype,r.descriptor.gtype,i.message)}i&&(r.wrapper=i)}function insert(e,t,n=null){assertHostParent(t);let r=e.parent,i=e.next,a=n===e?i:n;e.parent&&remove(e),link(t,e,a);try{e.kind===`element`?attach(t,e):e.kind===`text`&&flushText(t)}catch(t){throw unlink(e),r&&restore(e,r,i),t}}function assertHostParent(e){if(!isHostElement(e))throw t.notAHostParent(describeValue(e))}function isHostElement(e){let t=e;return!!t&&t.kind===`element`&&typeof t.descriptor==`object`}function describeValue(e){if(e==null)return String(e);if(typeof e!=`object`)return`a ${typeof e}`;let t=e.tagName;if(typeof t==`string`)return`a DOM element <${t.toLowerCase()}>`;let n=e.constructor?.$gtype,r=n?j.type_name(n)??`an unnamed GType`:null;if(r!==null&&r!==`JSObject`)return r;let i=e.constructor?.name;return i&&i!==`Object`?`a ${i}`:`a plain object`}function restore(e,t,n){try{link(t,e,n),e.kind===`element`?attach(t,e):e.kind===`text`&&flushText(t)}catch{unlink(e)}}function restoreTextSink(e){let t=e.descriptor.textSink;if(!t||e.destroyed||!e.widget)return;let r=e.descriptor.children;if(r.kind!==`single`||holdsOursInSlot(e,null)||x(e.widget,r.set))return;let a=t.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),o=e.props[t]??e.props[a];if(typeof o!=`string`||o===``)return;let s=D(T(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,t);n(e.widget);try{e.widget.set_property(t,C(s,o,e.descriptor.gtype))}finally{i()}}function remove(e){let t=e.parent;if(!t&&e.kind===`element`){let t=h(e.descriptor);t&&(u(e,t),e.attached=!1)}t&&e.kind===`element`&&(v(t,e),e.attached=!1,e.wrapper&&=(e.wrapper.set_child(null),null),restoreTextSink(t)),unlink(e),t&&e.kind===`text`&&flushText(t)}function destroyChildren(e){for(let t of childSnapshot(e))destroy(t)}function disconnectHandlers(e){r(e),e.listeners.clear()}function destroy(e){e.kind===`element`&&(destroyChildren(e),r(e),e.listeners.clear());let t=e.kind===`element`?h(e.descriptor):null;if(t&&releaseWidget(e),remove(e),e.kind===`element`){let n=e.widget;!t&&n&&typeof n.destroy==`function`&&typeof n.get_parent==`function`&&n.get_parent()===null&&n.destroy(),releaseWidget(e),e.props={},e.layout=null,e.textFromChildren=!1,e.destroyed=!0}}function mountRoot(e,t){materialize(e),insert(e,adopt(t))}function widgetOf(e){if(e.kind!==`element`)throw t.notAnElement(e.kind);if(e.destroyed)throw t.destroyedNode(e.descriptor.gtype);return materialize(e)}const createDetachedContainer=()=>adopt(p());function adopt(e){let n=e.constructor.$gtype,r=A(n);if(!r)throw t.unknownTag(gtypeNameOf(e));return{kind:`element`,descriptor:r,widget:e,wrapper:null,slot:null,parent:null,prev:null,next:null,first:null,last:null,handlers:new Map,listeners:new Map,props:{},layout:null,textFromChildren:!1,attached:!0,destroyed:!1,foreign:adoptedChildren(e,r),portalWatch:null}}function adoptedChildren(e,t){let n=b(t.children);if(n.length===0)return directChildren(e);let r=[];for(let i of n){let n=appOccupant(e,t,i);n&&r.push(n)}return r}function appOccupant(e,t,n){let r=x(e,n);if(!r)return null;let i=t.textSink;if(!i)return r;let a=e[i.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())];return typeof a==`string`&&a!==``?null:r}function directChildren(e){let t=[],n=e;if(typeof n.get_first_child!=`function`)return t;for(let e=n.get_first_child();e;e=e.get_next_sibling())t.push(e);return t}const gtypeNameOf=e=>j.type_name(e.constructor.$gtype),parentNode=e=>e.parent,firstChild=e=>e.first,nextSibling=e=>e.next,prevSibling=e=>e.prev;export{adopt,createAnchor,createDetachedContainer,createElement,createText,describeValue,destroy,destroyChildren,disconnectHandlers,firstChild,insert,isHostElement,isText,materialize,mountRoot,nextSibling,parentNode,prevSibling,remove,setElementText,setEventHandler,setProp,setSlot,setText,widgetOf};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{GtkHostError as e}from"./errors.js";import{isEventProp as t,toSignalName as n}from"./signals.js";import{addressOf as r,reorderMode as i}from"./policies.js";import{constructOnlyNames as a,isConstructOnly as o,isWritable as s,lookupEnumNick as c,paramSpecs as l,toPropertyName as u}from"./props.js";import{assertInjective as d,tagOf as f}from"./tags.js";import{clearRegistry as p,hasWidget as m,lookupWidget as h,nearestRegistered as g,registerWidget as _,registerWidgets as v,registeredTags as y}from"./registry.js";import{adopt as b,createAnchor as x,createDetachedContainer as S,createElement as C,createText as w,destroy as T,destroyChildren as E,disconnectHandlers as D,firstChild as O,insert as k,isHostElement as A,isText as j,materialize as M,mountRoot as N,nextSibling as P,parentNode as F,prevSibling as I,remove as L,setElementText as R,setEventHandler as z,setProp as B,setSlot as V,setText as H,widgetOf as U}from"./host.js";import{GENERATED_PROVENANCE as W,GENERATED_WIDGETS as G}from"./generated/widgets.js";import{ADW_DESCRIPTORS as K}from"./descriptors/adw.js";import{GTK_DESCRIPTORS as q}from"./descriptors/gtk.js";import{BUILTIN_DESCRIPTORS as J,CURATED_DESCRIPTORS as Y,mergeGenerated as X,registerBuiltinWidgets as Z,tableProvenance as Q}from"./descriptors/index.js";import"./types.js";import{blankReason as $,checkRendered as ee,probeEnabled as te,runHostProbe as ne,runHostProbeApp as re,shotEvidence as ie}from"./probe.js";export{K as ADW_DESCRIPTORS,J as BUILTIN_DESCRIPTORS,Y as CURATED_DESCRIPTORS,W as GENERATED_PROVENANCE,G as GENERATED_WIDGETS,q as GTK_DESCRIPTORS,e as GtkHostError,r as addressOf,b as adopt,d as assertInjective,$ as blankReason,ee as checkRendered,p as clearRegistry,a as constructOnlyNames,x as createAnchor,S as createDetachedContainer,C as createElement,w as createText,T as destroy,E as destroyChildren,D as disconnectHandlers,O as firstChild,m as hasWidget,k as insert,o as isConstructOnly,t as isEventProp,A as isHostElement,j as isText,s as isWritable,c as lookupEnumNick,h as lookupWidget,M as materialize,X as mergeGenerated,N as mountRoot,g as nearestRegistered,P as nextSibling,l as paramSpecs,F as parentNode,I as prevSibling,te as probeEnabled,Z as registerBuiltinWidgets,_ as registerWidget,v as registerWidgets,y as registeredTags,L as remove,i as reorderMode,ne as runHostProbe,re as runHostProbeApp,R as setElementText,z as setEventHandler,B as setProp,V as setSlot,H as setText,ie as shotEvidence,Q as tableProvenance,f as tagOf,u as toPropertyName,n as toSignalName,U as widgetOf};
1
+ import{GtkHostError as e}from"./errors.js";import{isEventProp as t,toSignalName as n}from"./signals.js";import{addressOf as r,isPortal as i,placementOf as a,portalOf as o,reorderMode as s}from"./policies.js";import{constructOnlyNames as c,isConstructOnly as l,isWritable as u,lookupEnumNick as d,paramSpecs as f,toPropertyName as p}from"./props.js";import{assertInjective as m,tagOf as h}from"./tags.js";import{clearRegistry as g,hasWidget as _,lookupWidget as v,nearestRegistered as y,registerWidget as b,registerWidgets as x,registeredTags as S}from"./registry.js";import{adopt as C,createAnchor as w,createDetachedContainer as T,createElement as E,createText as D,destroy as O,destroyChildren as k,disconnectHandlers as A,firstChild as j,insert as M,isHostElement as N,isText as P,materialize as F,mountRoot as I,nextSibling as L,parentNode as R,prevSibling as z,remove as B,setElementText as V,setEventHandler as H,setProp as U,setSlot as W,setText as G,widgetOf as K}from"./host.js";import{GENERATED_PROVENANCE as q,GENERATED_WIDGETS as J}from"./generated/widgets.js";import{GTK_DESCRIPTORS as Y}from"./descriptors/gtk.js";import{ADW_DESCRIPTORS as X}from"./descriptors/adw.js";import{BUILTIN_DESCRIPTORS as Z,CURATED_DESCRIPTORS as Q,mergeGenerated as $,registerBuiltinWidgets as ee,tableProvenance as te}from"./descriptors/index.js";import"./types.js";import{blankReason as ne,checkRendered as re,probeEnabled as ie,runHostProbe as ae,runHostProbeApp as oe,shotEvidence as se}from"./probe.js";export{X as ADW_DESCRIPTORS,Z as BUILTIN_DESCRIPTORS,Q as CURATED_DESCRIPTORS,q as GENERATED_PROVENANCE,J as GENERATED_WIDGETS,Y as GTK_DESCRIPTORS,e as GtkHostError,r as addressOf,C as adopt,m as assertInjective,ne as blankReason,re as checkRendered,g as clearRegistry,c as constructOnlyNames,w as createAnchor,T as createDetachedContainer,E as createElement,D as createText,O as destroy,k as destroyChildren,A as disconnectHandlers,j as firstChild,_ as hasWidget,M as insert,l as isConstructOnly,t as isEventProp,N as isHostElement,i as isPortal,P as isText,u as isWritable,d as lookupEnumNick,v as lookupWidget,F as materialize,$ as mergeGenerated,I as mountRoot,y as nearestRegistered,L as nextSibling,f as paramSpecs,R as parentNode,a as placementOf,o as portalOf,z as prevSibling,ie as probeEnabled,ee as registerBuiltinWidgets,b as registerWidget,x as registerWidgets,S as registeredTags,B as remove,s as reorderMode,ae as runHostProbe,oe as runHostProbeApp,V as setElementText,H as setEventHandler,U as setProp,W as setSlot,G as setText,se as shotEvidence,te as tableProvenance,h as tagOf,p as toPropertyName,n as toSignalName,K as widgetOf};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import e from"gi://Gtk?version=4.0";import{normalizeComboOptions as t}from"@gjsify/adwaita-core";const n=new WeakSet;function buildStringList(r){let i=new e.StringList({strings:t(r).map(e=>e.label)});return n.add(i),i}const isPortableListModel=e=>Array.isArray(e);function stringsOf(e){let t=[];for(let n=0;n<e.get_n_items();n+=1)t.push(e.get_string(n)??``);return t}function reconcileStringList(t,r,i){if(!(i instanceof e.StringList)||!n.has(i))return!1;let a=t[r];if(!(a instanceof e.StringList)||!n.has(a))return!1;let o=stringsOf(a),s=stringsOf(i),c=0;for(;c<o.length&&c<s.length&&o[c]===s[c];)c+=1;let l=o.length,u=s.length;for(;l>c&&u>c&&o[l-1]===s[u-1];)--l,--u;return(c!==l||c!==u)&&a.splice(c,l-c,s.slice(c,u)),!0}function fromStringList(e){return stringsOf(e).map(e=>({value:e,label:e}))}export{buildStringList,fromStringList,isPortableListModel,reconcileStringList,stringsOf};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import{normalizeMenuModel as t}from"@gjsify/adwaita-core";import n from"gi://Gio?version=2.0";import r from"gi://GLib?version=2.0";const i={label:`label`,action:`action`,icon:`icon`,verbIcon:`verb-icon`,accel:`accel`,hiddenWhen:`hidden-when`,custom:`custom`,id:`id`};function requireDetailedAction(t,r){try{n.Action.parse_detailed_name(t)}catch(n){throw e.badDetailedAction(r,t,n instanceof Error?n.message:String(n))}}function itemOf(e){let t=new n.MenuItem;if(e.kind===`item`){e.action!==void 0&&(requireDetailedAction(e.action,e.label),t.set_detailed_action(e.action));for(let[n,a]of Object.entries(i)){let i=e[n];n===`action`||typeof i!=`string`||t.set_attribute_value(a,r.Variant.new_string(i))}return e.useMarkup===!0&&t.set_attribute_value(`use-markup`,r.Variant.new_string(`true`)),t}let a=buildGioMenu(e.items);return e.kind===`section`?(t.set_section(a),e.label!==void 0&&t.set_label(e.label),e.displayHint!==void 0&&t.set_attribute_value(`display-hint`,r.Variant.new_string(e.displayHint)),e.textDirection!==void 0&&t.set_attribute_value(`text-direction`,r.Variant.new_string(e.textDirection)),t):(t.set_submenu(a),t.set_label(e.label),e.icon!==void 0&&t.set_attribute_value(`icon`,r.Variant.new_string(e.icon)),e.submenuAction!==void 0&&t.set_attribute_value(`submenu-action`,r.Variant.new_string(e.submenuAction)),e.macosSpecial!==void 0&&t.set_attribute_value(`gtk-macos-special`,r.Variant.new_string(e.macosSpecial)),t)}function buildGioMenu(e){let r=new n.Menu;for(let n of t(e))r.append_item(itemOf(n));return r}const isPortableMenu=e=>Array.isArray(e);function attr(e,t,n){let i=e.get_item_attribute_value(t,n,r.VariantType.new(`s`));return i===null?void 0:i.get_string()[0]}function detailedAction(e,t){let n=attr(e,t,`action`);if(n===void 0)return;let r=e.get_item_attribute_value(t,`target`,null);return r===null?n:r.get_type_string()===`s`?`${n}::${r.get_string()[0]}`:`${n}(${r.print(!1)})`}function fromGioMenu(e){let t=[];for(let r=0;r<e.get_n_items();r+=1){let i=e.get_item_link(r,n.MENU_LINK_SECTION),a=e.get_item_link(r,n.MENU_LINK_SUBMENU),o=attr(e,r,`label`);if(i!==null){let n={kind:`section`,items:fromGioMenu(i)};o!==void 0&&(n.label=o);let a=attr(e,r,`display-hint`);a!==void 0&&(n.displayHint=a);let s=attr(e,r,`text-direction`);s!==void 0&&(n.textDirection=s),t.push(n);continue}if(a!==null){let n={kind:`submenu`,label:o??``,items:fromGioMenu(a)};for(let[t,i]of[[`icon`,`icon`],[`submenuAction`,`submenu-action`],[`macosSpecial`,`gtk-macos-special`]]){let a=attr(e,r,i);a!==void 0&&(n[t]=a)}t.push(n);continue}let s={kind:`item`,label:o??``},c=detailedAction(e,r);c!==void 0&&(s.action=c);for(let[t,n]of[[`icon`,`icon`],[`verbIcon`,`verb-icon`],[`accel`,`accel`],[`hiddenWhen`,`hidden-when`],[`custom`,`custom`],[`id`,`id`]]){let i=attr(e,r,n);i!==void 0&&(s[t]=i)}attr(e,r,`use-markup`)!==void 0&&(s.useMarkup=!0),t.push(s)}return t}export{buildGioMenu,fromGioMenu,isPortableMenu};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{GtkHostError as e,err as t}from"./errors.js";import{beginHostWrite as n,endHostWrite as r}from"./signals.js";import i from"gi://Gtk?version=4.0";function addressOf(e){let n=e.wrapper??e.widget;if(!n)throw t.notAWidget(e.descriptor.gtype);return n}function makeWrapper(e,t,n){let r=e.kind===`indexed`?e.wrap:e.kind===`slotted`?e.wrapSlots?.[n??e.defaultSlot]??null:null;if(!r)return null;if(r===`list-box-row`){if(t instanceof i.ListBoxRow)return null;let e=new i.ListBoxRow;return e.set_child(t),e}if(t instanceof i.FlowBoxChild)return null;let a=new i.FlowBoxChild;return a.set_child(t),a}const makeDetachedContainer=()=>new i.Box;function unhandledPolicy(e){throw Error(`unhandled child policy: ${JSON.stringify(e)}`)}function setterSlotOf(e,t){let n=e.descriptor.children;if(n.kind===`single`)return n.set;if(n.kind!==`slotted`)return null;let r=n.slots[t.slot??n.defaultSlot];return r?.startsWith(`set_`)===!0?r:null}function adderSlots(e){return e.kind===`slotted`?Object.entries(e.slots).filter(([,e])=>!e.startsWith(`set_`)).map(([e])=>e):[]}function setterSlots(e){return e.kind===`single`?[e.set]:e.kind===`slotted`?Object.values(e.slots).filter(e=>e.startsWith(`set_`)):[]}function slotOccupant(e,t){let n=e,r=t.replace(/^set_/,`get_`);if(typeof n[r]==`function`)return n[r]()??null}function insertChild(n){try{placeChild(n)}catch(r){throw r instanceof e?r:t.rejectedChild(n.parent.descriptor.gtype,n.child.descriptor.gtype,r.message)}}function placeChild(e){let{parent:n,child:r}=e,i=n.descriptor.children,a=n.widget,o=addressOf(r);switch(i.kind){case`none`:throw t.unclaimedChild(n.descriptor.gtype,r.descriptor.gtype);case`uncurated`:throw t.uncuratedPlacement(n.descriptor.gtype,r.descriptor.gtype);case`single`:a[i.set](o);return;case`indexed`:a[i.insert](o,e.index);return;case`coords`:appendChild(n,r,a);return;case`ordered`:if(i.after){a[i.after](o,e.prevWidget??null);return}case`slotted`:case`keyed`:appendChild(n,r,a),rotateTail(n,r,e.following,a);return;default:return unhandledPolicy(i)}}function appendChild(e,n,r){let i=e.descriptor.children,a=addressOf(n);switch(i.kind){case`uncurated`:throw t.uncuratedPlacement(e.descriptor.gtype,n.descriptor.gtype);case`ordered`:r[i.append](a);return;case`slotted`:{let o=n.slot??i.defaultSlot,s=i.slots[o];if(!s)throw t.unknownSlot(e.descriptor.gtype,o,Object.keys(i.slots));r[s](a);return}case`keyed`:{let e=n.layout?.[i.nameFrom]??n.slot,t=n.layout?.title;i.titled?r[i.add](a,e??null,t??e??``):r[i.add](a);return}case`coords`:{let e=n.layout??{};r[i.attach](a,e.column??0,e.row??0,e.columnSpan??1,e.rowSpan??1);return}default:throw t.unclaimedChild(e.descriptor.gtype,n.descriptor.gtype)}}function rotateTail(e,t,n,r){let i=e.descriptor.children,a=n;if(i.kind===`slotted`){if(setterSlotOf(e,t))return;let slotOf=e=>e.slot??i.defaultSlot,r=slotOf(t);a=n.filter(e=>slotOf(e)===r)}for(let t of a)detachChild(e,t,r);for(let t of a)appendChild(e,t,r)}function detachChild(e,n,r){let i=e.descriptor.children,a=n.wrapper??n.widget;if(a)switch(i.kind){case`none`:case`uncurated`:return;case`single`:clearIfCurrent(r,i.set,a);return;case`slotted`:{let o=setterSlotOf(e,n);if(o){clearIfCurrent(r,o,a);return}let s=n.slot??i.defaultSlot;if(!i.remove)throw t.slotNeedsRemove(e.descriptor.gtype,s,i.slots[s]??`?`);r[i.remove](a);return}case`keyed`:{let e=i.hideBeforeRemove===!0&&a.get_visible();e&&writeVisible(a,!1),r[i.remove](a),e&&writeVisible(a,!0);return}case`ordered`:case`indexed`:case`coords`:r[i.remove](a);return;default:return unhandledPolicy(i)}}function writeVisible(e,t){n(null);try{e.set_visible(t)}finally{r()}}function clearIfCurrent(e,t,n){let r=slotOccupant(e,t);(r===void 0||r===n)&&e[t](null)}function removeChild(e,t){let n=e.widget;n&&t.attached&&detachChild(e,t,n)}function reorderMode(e){switch(e.kind){case`uncurated`:return`n/a`;case`ordered`:return e.reorder;case`indexed`:return`native`;case`slotted`:return adderSlots(e).length>0?`remove-all`:`n/a`;case`keyed`:return`remove-all`;case`coords`:case`single`:case`none`:return`n/a`;default:return unhandledPolicy(e)}}export{adderSlots,addressOf,insertChild,makeDetachedContainer,makeWrapper,removeChild,reorderMode,setterSlotOf,setterSlots,slotOccupant,unhandledPolicy};
1
+ import"./_virtual/_rolldown/runtime.js";import{GtkHostError as e,err as t}from"./errors.js";import{beginHostWrite as n,endHostWrite as r}from"./signals.js";import i from"gi://GObject?version=2.0";import a from"gi://Gtk?version=4.0";function addressOf(e){let n=e.wrapper??e.widget;if(!n)throw t.notAWidget(e.descriptor.gtype);return n}function makeWrapper(e,t,n){let r=e.kind===`indexed`?e.wrap:e.kind===`slotted`?e.wrapSlots?.[n??e.defaultSlot]??null:null;if(!r)return null;if(r===`list-box-row`){if(t instanceof a.ListBoxRow)return null;let e=new a.ListBoxRow;return e.set_child(t),e}if(t instanceof a.FlowBoxChild)return null;let i=new a.FlowBoxChild;return i.set_child(t),i}const makeDetachedContainer=()=>new a.Box;function unhandledPolicy(e){throw Error(`unhandled child policy: ${JSON.stringify(e)}`)}function setterSlotOf(e,t){let n=e.descriptor.children;if(n.kind===`single`)return n.set;if(n.kind!==`slotted`)return null;let r=n.slots[t.slot??n.defaultSlot];return r?.startsWith(`set_`)===!0?r:null}function adderSlots(e){return e.kind===`slotted`?Object.entries(e.slots).filter(([,e])=>!e.startsWith(`set_`)).map(([e])=>e):[]}function setterSlots(e){return e.kind===`single`?[e.set]:e.kind===`slotted`?Object.values(e.slots).filter(e=>e.startsWith(`set_`)):[]}function slotOccupant(e,t){let n=e,r=t.replace(/^set_/,`get_`);if(typeof n[r]==`function`)return n[r]()??null}const o={kind:`parented`},placementOf=e=>e.placement??o;function outsideParentOf(e){let t=placementOf(e);switch(t.kind){case`parented`:return null;case`portal`:case`toplevel`:return t;default:return unhandledPlacement(t)}}function portalOf(e){let t=outsideParentOf(e);return t?.kind===`portal`?t:null}function unhandledPlacement(e){throw Error(`unhandled node placement: ${JSON.stringify(e)}`)}const isPortal=e=>portalOf(e.descriptor)!==null,isUnparented=e=>outsideParentOf(e.descriptor)!==null;function placementMethod(e,n,r,i){let a=e.widget?.[r];if(typeof a!=`function`)throw t.placementMethodMissing(e.descriptor.gtype,n.kind,r,i);return a}const toplevelOf=e=>{let t=e.get_root();return t instanceof a.Window?t:null};function presentPortal(e,t,n){let r=e.widget;return r?(placementMethod(t,n,n.present,`present`),placementMethod(t,n,n.close,`close`),watchPortalRoot(r,t,n),placeAgainst(r,t,n)):!1}function placeAgainst(e,t,n){let r=t.widget;if(!r)return!1;let i=toplevelOf(e);if(!i)return placementMethod(t,n,n.close,`close`).call(r),!1;if(r.get_parent()){if(toplevelOf(r)===i)return!0;placementMethod(t,n,n.close,`close`).call(r)}return placementMethod(t,n,n.present,`present`).call(r,e),!0}function watchPortalRoot(e,t,n){t.portalWatch?.widget!==e&&(t.portalWatch&&retractPortalWatch(t),t.portalWatch={widget:e,id:e.connect(`notify::root`,()=>{t.attached=placeAgainst(e,t,n)})})}function retractPortalWatch(e){let t=e.portalWatch;t&&(e.portalWatch=null,t.widget.disconnect(t.id))}function retractPortal(e,t){retractPortalWatch(e),e.widget&&placementMethod(e,t,t.close,`close`).call(e.widget)}function presentToplevel(e,t){let n=e.widget;if(!n)return!1;let r=placementMethod(e,t,t.present,`present`);return placementMethod(e,t,t.close,`close`),e.props.visible!==!1&&r.call(n),!0}function closeToplevel(e,t){e.widget&&placementMethod(e,t,t.close,`close`).call(e.widget)}function detachToplevel(e){let t=e.widget;t&&t.set_visible(!1)}function placeOutsideParent(e,t,n){switch(n.kind){case`portal`:return presentPortal(e,t,n);case`toplevel`:return presentToplevel(t,n);default:return unhandledPlacement(n)}}function detachOutsideParent(e,t){switch(t.kind){case`portal`:return retractPortal(e,t);case`toplevel`:return detachToplevel(e);default:return unhandledPlacement(t)}}function closeOutsideParent(e,t){switch(t.kind){case`portal`:return retractPortal(e,t);case`toplevel`:return closeToplevel(e,t);default:return unhandledPlacement(t)}}function classPlacementKind(e,t){return i.type_is_a(e,a.Root.$gtype)?`toplevel`:typeof t==`function`&&t.length===1?`portal`:null}function nodePlacementKind(e){let t=e.constructor?.$gtype;return t?classPlacementKind(t,e.present):null}function refuseUnparentable(e,n){if(n.descriptor.placement!==void 0)return;let r=n.widget;if(!r)return;let i=nodePlacementKind(r);if(i)throw t.unparentableChild(e.descriptor.gtype,n.descriptor.gtype,i,i===`toplevel`?`${n.descriptor.gtype} implements Gtk.Root, so it IS a toplevel and cannot have a parent`:`${n.descriptor.gtype}.present() takes a parent, so it is presented AGAINST one and never placed into one`)}function insertChild(n){try{placeChild(n)}catch(r){throw r instanceof e?r:t.rejectedChild(n.parent.descriptor.gtype,n.child.descriptor.gtype,r.message)}syncPerLineCap(n.parent)}function placeChild(e){let{parent:n,child:r}=e,i=n.descriptor.children,a=n.widget,o=addressOf(r);switch(i.kind){case`none`:throw t.unclaimedChild(n.descriptor.gtype,r.descriptor.gtype);case`uncurated`:throw t.uncuratedPlacement(n.descriptor.gtype,r.descriptor.gtype);case`single`:a[i.set](o);return;case`indexed`:a[i.insert](o,e.index);return;case`coords`:appendChild(n,r,a);return;case`ordered`:if(i.after){a[i.after](o,e.prevWidget??null);return}case`slotted`:case`keyed`:appendChild(n,r,a),rotateTail(n,r,e.following,a);return;default:return unhandledPolicy(i)}}function appendChild(e,n,r){let i=e.descriptor.children,a=addressOf(n);switch(i.kind){case`uncurated`:throw t.uncuratedPlacement(e.descriptor.gtype,n.descriptor.gtype);case`ordered`:r[i.append](a);return;case`slotted`:{let o=n.slot??i.defaultSlot,s=i.slots[o];if(!s)throw t.unknownSlot(e.descriptor.gtype,o,Object.keys(i.slots));r[s](a);return}case`keyed`:{let e=n.layout?.[i.nameFrom]??n.slot,t=n.layout?.title;i.titled?r[i.add](a,e??null,t??e??``):r[i.add](a);return}case`coords`:{let e=n.layout??{};r[i.attach](a,e.column??0,e.row??0,e.columnSpan??1,e.rowSpan??1);return}default:throw t.unclaimedChild(e.descriptor.gtype,n.descriptor.gtype)}}function rotateTail(e,t,n,r){let i=e.descriptor.children,a=n;if(i.kind===`slotted`){if(setterSlotOf(e,t))return;let slotOf=e=>e.slot??i.defaultSlot,r=slotOf(t);a=n.filter(e=>slotOf(e)===r)}for(let t of a)detachChild(e,t,r);for(let t of a)appendChild(e,t,r)}function detachChild(e,n,r){let i=e.descriptor.children,a=n.wrapper??n.widget;if(a)switch(i.kind){case`none`:case`uncurated`:return;case`single`:clearIfCurrent(r,i.set,a);return;case`slotted`:{let o=setterSlotOf(e,n);if(o){clearIfCurrent(r,o,a);return}let s=n.slot??i.defaultSlot;if(!i.remove)throw t.slotNeedsRemove(e.descriptor.gtype,s,i.slots[s]??`?`);r[i.remove](a);return}case`keyed`:{let e=i.hideBeforeRemove===!0&&a.get_visible();e&&writeVisible(a,!1),r[i.remove](a),e&&writeVisible(a,!0);return}case`ordered`:case`indexed`:case`coords`:r[i.remove](a);return;default:return unhandledPolicy(i)}}function writeVisible(e,t){n(null);try{e.set_visible(t)}finally{r()}}function clearIfCurrent(e,t,n){let r=slotOccupant(e,t);(r===void 0||r===n)&&e[t](null)}function removeChild(e,t){let n=outsideParentOf(t.descriptor);if(n)return detachOutsideParent(t,n);let r=e.widget;r&&t.attached&&(detachChild(e,t,r),syncPerLineCap(e))}function syncPerLineCap(e){let t=e.descriptor.children;if(t.kind!==`indexed`||t.perLineCap===void 0||e.props[t.perLineCap]!==void 0)return;let i=e.widget;if(!i)return;let a=0;for(let e=i.get_first_child();e!==null;e=e.get_next_sibling())a+=1;n(null);try{i.set_property(t.perLineCap,Math.min(65535,Math.max(1,a)))}finally{r()}}function reorderMode(e){switch(e.kind){case`uncurated`:return`n/a`;case`ordered`:return e.reorder;case`indexed`:return`native`;case`slotted`:return adderSlots(e).length>0?`remove-all`:`n/a`;case`keyed`:return`remove-all`;case`coords`:case`single`:case`none`:return`n/a`;default:return unhandledPolicy(e)}}export{adderSlots,addressOf,classPlacementKind,closeOutsideParent,closeToplevel,detachOutsideParent,detachToplevel,insertChild,isPortal,isUnparented,makeDetachedContainer,makeWrapper,nodePlacementKind,outsideParentOf,placeOutsideParent,placementOf,portalOf,presentPortal,presentToplevel,refuseUnparentable,removeChild,reorderMode,retractPortal,setterSlotOf,setterSlots,slotOccupant,unhandledPlacement,unhandledPolicy};
package/lib/esm/probe.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{installDiagnosticsGate as e}from"./conformance/diagnostics.js";import{descendants as t}from"./conformance/index.js";import n from"gi://Gtk?version=4.0";import r from"gi://Adw?version=1";import i from"gi://GLib?version=2.0";import a from"system";function probeEnabled(){let e=i.getenv(`GJSIFY_HOST_PROBE`);if(e===null)return!1;let t=e.toLowerCase();return t!==``&&t!==`0`&&t!==`false`}const o=`<gtk-host probe: recorder self-check>`;function recorderIsHonest(e,t){let n=t.length;e(o,!1);let r=t.length===n+1&&t[n]===o;t.length=n,e(o,!0);let i=t.length===n;return t.length=n,r&&i?null:r?`the probe recorder records a PASSING check as a failure, so every assertion below is a false alarm`:`the probe recorder did not record a failed check, so every assertion below is unverifiable`}async function runHostProbe(t){let n=t.label??`PROBE`,r=e();r.reset();let i=[],check=(e,t)=>{t||i.push(e)},a=recorderIsHonest(check,i);a!==null&&i.push(a);let o={};try{let e=t.build(null);o=await t.assert(e,check),t.teardown?.(e)}catch(e){i.push(`threw: ${e.message}`)}let s=r.seen.length;check(`no GTK diagnostics (saw ${s})`,s===0);let c=JSON.stringify({...i.length>0?{failures:i}:{},diagnostics:s,...o});return print(`${n}: ${i.length>0?`FAIL`:`PASS`} ${c}`),+(i.length>0)}async function runHostProbeApp(e){if(probeEnabled())return n.init(),a.exit(await runHostProbe(e));let t=new r.Application({application_id:e.applicationId});t.connect(`activate`,()=>{t.hold(),(async()=>{try{let n=await runHostProbe(e);if(n!==0)return a.exit(n);e.present(e.build(t))}catch(t){return printerr(`JS ERROR: ${e.applicationId} probe threw: ${String(t)}`),a.exit(1)}finally{t.release()}})()}),await t.runAsync([])}function shotEvidence(e,n){let r=n(e);return{widgets:t(e).length-1,width:e.get_width(),height:e.get_height(),bytes:r?r.length:0}}function blankReason(e){return e.widgets===0?`nothing was rendered into the container: it has no children at all, which is what a refused render, an unmounted root and a component returning null all look like from GTK`:e.width<=0||e.height<=0?`the container is allocated ${e.width}×${e.height}: its ${e.widgets} widget(s) exist and occupy nothing`:e.bytes===0?`the capture produced no PNG: the widget has no renderer yet, so it was measured before it was ever on screen`:null}function checkRendered(e,t,n){let r=blankReason(n);e(r===null?t:`${t} — ${r}`,r===null)}export{blankReason,checkRendered,probeEnabled,runHostProbe,runHostProbeApp,shotEvidence};
1
+ import"./_virtual/_rolldown/runtime.js";import{installDiagnosticsGate as e}from"./conformance/diagnostics.js";import{descendants as t}from"./conformance/tree.js";import"./conformance/index.js";import n from"gi://Gtk?version=4.0";import r from"gi://Adw?version=1";import i from"gi://GLib?version=2.0";import a from"system";function probeEnabled(){let e=i.getenv(`GJSIFY_HOST_PROBE`);if(e===null)return!1;let t=e.toLowerCase();return t!==``&&t!==`0`&&t!==`false`}const o=`<gtk-host probe: recorder self-check>`;function recorderIsHonest(e,t){let n=t.length;e(o,!1);let r=t.length===n+1&&t[n]===o;t.length=n,e(o,!0);let i=t.length===n;return t.length=n,r&&i?null:r?`the probe recorder records a PASSING check as a failure, so every assertion below is a false alarm`:`the probe recorder did not record a failed check, so every assertion below is unverifiable`}async function runHostProbe(t){let n=t.label??`PROBE`,r=e();r.reset();let i=[],check=(e,t)=>{t||i.push(e)},a=recorderIsHonest(check,i);a!==null&&i.push(a);let o={};try{let e=t.build(null);o=await t.assert(e,check),t.teardown?.(e)}catch(e){i.push(`threw: ${e.message}`)}let s=r.seen.length;check(`no GTK diagnostics (saw ${s})`,s===0);let c=JSON.stringify({...i.length>0?{failures:i}:{},diagnostics:s,...o});return print(`${n}: ${i.length>0?`FAIL`:`PASS`} ${c}`),+(i.length>0)}async function runHostProbeApp(e){if(probeEnabled())return n.init(),a.exit(await runHostProbe(e));let t=new r.Application({application_id:e.applicationId});t.connect(`activate`,()=>{t.hold(),(async()=>{try{let n=await runHostProbe(e);if(n!==0)return a.exit(n);e.present(e.build(t))}catch(t){return printerr(`JS ERROR: ${e.applicationId} probe threw: ${String(t)}`),a.exit(1)}finally{t.release()}})()}),await t.runAsync([])}function shotEvidence(e,n){let r=n(e);return{widgets:t(e).length-1,width:e.get_width(),height:e.get_height(),bytes:r?r.length:0}}function blankReason(e){return e.widgets===0?`nothing was rendered into the container: it has no children at all, which is what a refused render, an unmounted root and a component returning null all look like from GTK`:e.width<=0||e.height<=0?`the container is allocated ${e.width}×${e.height}: its ${e.widgets} widget(s) exist and occupy nothing`:e.bytes===0?`the capture produced no PNG: the widget has no renderer yet, so it was measured before it was ever on screen`:null}function checkRendered(e,t,n){let r=blankReason(n);e(r===null?t:`${t} — ${r}`,r===null)}export{blankReason,checkRendered,probeEnabled,runHostProbe,runHostProbeApp,shotEvidence};
package/lib/esm/props.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import t from"gi://GObject?version=2.0";import n from"gi://Gtk?version=4.0";import r from"gi://Adw?version=1";import i from"gi://Gdk?version=4.0";import a from"gi://Pango?version=1.0";const o=[[`Gtk`,n],[`Adw`,r],[`Gdk`,i],[`Pango`,a],[`G`,t]];function toPropertyName(e){return e.includes(`-`)?e:e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function withoutKeys(e,t){if(!e)return;let n;for(let r of Object.keys(e))t.has(r)||((n??={})[r]=e[r]);return n}const s=new Map;function paramSpecs(e,t){let n=s.get(t);if(n)return n;n=new Map;for(let t of e.list_properties())n.set(t.get_name(),t);return s.set(t,n),n}const isFlag=(e,t)=>(e&t)!==0,isWritable=e=>isFlag(e.flags,t.ParamFlags.WRITABLE),isConstructOnly=e=>isFlag(e.flags,t.ParamFlags.CONSTRUCT_ONLY);function constructOnlyNames(e,t){let n=[];for(let[r,i]of paramSpecs(e,t))isConstructOnly(i)&&isWritable(i)&&n.push(r);return n}function resolveEnumValue(e,t){for(let[n,r]of o){if(!e.startsWith(n))continue;let i=r[e.slice(n.length)];if(!i)continue;let a=i[t.toUpperCase().replace(/-/g,`_`)];return typeof a==`number`?{resolved:!0,value:a}:{resolved:!0}}return{resolved:!1}}const lookupEnumNick=(e,t)=>resolveEnumValue(e,t).value;function enumMembers(e){for(let[t,n]of o){if(!e.startsWith(t))continue;let r=n[e.slice(t.length)];if(r)return Object.keys(r).filter(e=>e!==`$gtype`&&typeof r[e]==`number`)}}function coerce(n,r,i){if(r==null)return r;let a=n.value_type;if(t.type_is_a(a,t.TYPE_ENUM)&&typeof r==`string`){let o=t.type_name(a),s=resolveEnumValue(o,r);if(s.value!==void 0)return s.value;throw s.resolved?e.badEnum(i,n.get_name(),r,o):e.unresolvableEnum(o)}if(t.type_is_a(a,t.TYPE_FLAGS)&&typeof r==`string`)throw e.badFlags(i,n.get_name(),r,t.type_name(a));if(t.type_is_a(a,t.TYPE_BOOLEAN)){if(typeof r==`boolean`)return r;if(r===`true`)return!0;if(r===`false`)return!1;if(typeof r==`string`)throw e.badBoolean(i,n.get_name(),r);return!!r}if(t.type_is_a(a,t.TYPE_STRING)){if(typeof r==`string`)return r;if(typeof r==`number`||typeof r==`boolean`)return String(r);throw e.badString(i,n.get_name(),typeof r)}return(t.type_is_a(a,t.TYPE_INT)||t.type_is_a(a,t.TYPE_UINT)||t.type_is_a(a,t.TYPE_INT64)||t.type_is_a(a,t.TYPE_UINT64))&&typeof r==`number`?Math.trunc(r):r}const c=[t.TYPE_BOOLEAN,t.TYPE_STRING,t.TYPE_INT,t.TYPE_UINT,t.TYPE_INT64,t.TYPE_UINT64,t.TYPE_DOUBLE,t.TYPE_FLOAT],isScalarSpec=e=>t.type_is_a(e.value_type,t.TYPE_ENUM)||c.some(n=>t.type_is_a(e.value_type,n)),toAccessorName=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase()),l=new Map;function constructedDefaults(e){let r=l.get(e.gtype);if(r)return r;let i=new Map;l.set(e.gtype,i);let a=e.ctor(),o;try{let t={};for(let n of e.requiresProps??[])t[n]=``;o=new a(t)}catch{return i}for(let[n,r]of paramSpecs(a,e.gtype)){if(!isWritable(r)||isConstructOnly(r)||!isFlag(r.flags,t.ParamFlags.READABLE)||isFlag(r.flags,t.ParamFlags.DEPRECATED)||!isScalarSpec(r))continue;let e=toAccessorName(n);e in o&&i.set(n,o[e])}return o instanceof n.Window&&o.destroy(),i}function removedValue(e,t){let n=constructedDefaults(e),r=t.get_name();return n.has(r)?n.get(r):t.get_default_value()}function requireSpec(t,n,r){let i=t.get(r);if(!i)throw e.unknownProp(n,r);if(!isWritable(i))throw e.readOnlyProp(n,r);return i}export{coerce,constructOnlyNames,enumMembers,isConstructOnly,isWritable,lookupEnumNick,paramSpecs,removedValue,requireSpec,toPropertyName,withoutKeys};
1
+ import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import{buildStringList as t,isPortableListModel as n}from"./list-model.js";import{buildAdjustment as r,isPortableAdjustment as i}from"./adjustment.js";import{buildGioMenu as a,isPortableMenu as o}from"./menu.js";import s from"gi://GObject?version=2.0";import c from"gi://Gtk?version=4.0";import l from"gi://Adw?version=1";import u from"gi://Gdk?version=4.0";import d from"gi://Gio?version=2.0";import f from"gi://Pango?version=1.0";const p=[[`Gtk`,c],[`Adw`,l],[`Gdk`,u],[`Pango`,f],[`G`,s]];function toPropertyName(e){return e.includes(`-`)?e:e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function withoutKeys(e,t){if(!e)return;let n;for(let r of Object.keys(e))t.has(r)||((n??={})[r]=e[r]);return n}const m=new Map;function paramSpecs(e,t){let n=m.get(t);if(n)return n;n=new Map;for(let t of e.list_properties())n.set(t.get_name(),t);return m.set(t,n),n}const isFlag=(e,t)=>(e&t)!==0,isWritable=e=>isFlag(e.flags,s.ParamFlags.WRITABLE),isConstructOnly=e=>isFlag(e.flags,s.ParamFlags.CONSTRUCT_ONLY);function constructOnlyNames(e,t){let n=[];for(let[r,i]of paramSpecs(e,t))isConstructOnly(i)&&isWritable(i)&&n.push(r);return n}function resolveEnumValue(e,t){for(let[n,r]of p){if(!e.startsWith(n))continue;let i=r[e.slice(n.length)];if(!i)continue;let a=i[t.toUpperCase().replace(/-/g,`_`)];return typeof a==`number`?{resolved:!0,value:a}:{resolved:!0}}return{resolved:!1}}const lookupEnumNick=(e,t)=>resolveEnumValue(e,t).value;function enumMembers(e){for(let[t,n]of p){if(!e.startsWith(t))continue;let r=n[e.slice(t.length)];if(r)return Object.keys(r).filter(e=>e!==`$gtype`&&typeof r[e]==`number`)}}const kindOf=e=>Array.isArray(e)?`an array`:`a ${typeof e}`;function coerce(l,u,f){if(u==null)return u;let p=l.value_type;if(s.type_is_a(p,d.MenuModel.$gtype)&&o(u))return a(u);if(s.type_is_a(p,d.ListModel.$gtype)&&!(u instanceof s.Object)){if(!n(u))throw e.badListModel(f,l.get_name(),kindOf(u));if(!s.type_is_a(c.StringList.$gtype,p))throw e.listModelMismatch(f,l.get_name(),s.type_name(p));return t(u)}if(s.type_is_a(p,c.Adjustment.$gtype)&&!(u instanceof s.Object)){if(!i(u))throw e.badAdjustment(f,l.get_name(),kindOf(u));return r(u)}if(s.type_is_a(p,s.TYPE_ENUM)&&typeof u==`string`){let t=s.type_name(p),n=resolveEnumValue(t,u);if(n.value!==void 0)return n.value;throw n.resolved?e.badEnum(f,l.get_name(),u,t):e.unresolvableEnum(t)}if(s.type_is_a(p,s.TYPE_FLAGS)&&typeof u==`string`)throw e.badFlags(f,l.get_name(),u,s.type_name(p));if(s.type_is_a(p,s.TYPE_BOOLEAN)){if(typeof u==`boolean`)return u;if(u===`true`)return!0;if(u===`false`)return!1;if(typeof u==`string`)throw e.badBoolean(f,l.get_name(),u);return!!u}if(s.type_is_a(p,s.TYPE_STRING)){if(typeof u==`string`)return u;if(typeof u==`number`||typeof u==`boolean`)return String(u);throw e.badString(f,l.get_name(),typeof u)}return(s.type_is_a(p,s.TYPE_INT)||s.type_is_a(p,s.TYPE_UINT)||s.type_is_a(p,s.TYPE_INT64)||s.type_is_a(p,s.TYPE_UINT64))&&typeof u==`number`?Math.trunc(u):u}const h=[s.TYPE_BOOLEAN,s.TYPE_STRING,s.TYPE_INT,s.TYPE_UINT,s.TYPE_INT64,s.TYPE_UINT64,s.TYPE_DOUBLE,s.TYPE_FLOAT],isScalarSpec=e=>s.type_is_a(e.value_type,s.TYPE_ENUM)||h.some(t=>s.type_is_a(e.value_type,t)),toAccessorName=e=>e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase()),g=new Map;function constructedDefaults(e){let t=g.get(e.gtype);if(t)return t;let n=new Map;g.set(e.gtype,n);let r=e.ctor(),i;try{let t={};for(let n of e.requiresProps??[])t[n]=``;i=new r(t)}catch{return n}for(let[t,a]of paramSpecs(r,e.gtype)){if(!isWritable(a)||isConstructOnly(a)||!isFlag(a.flags,s.ParamFlags.READABLE)||isFlag(a.flags,s.ParamFlags.DEPRECATED)||!isScalarSpec(a))continue;let e=toAccessorName(t);e in i&&n.set(t,i[e])}return i instanceof c.Window&&i.destroy(),n}function removedValue(e,t){let n=constructedDefaults(e),r=t.get_name();return n.has(r)?n.get(r):t.get_default_value()}function requireSpec(t,n,r){let i=t.get(r);if(!i)throw e.unknownProp(n,r);if(!isWritable(i))throw e.readOnlyProp(n,r);return i}export{coerce,constructOnlyNames,enumMembers,isConstructOnly,isWritable,lookupEnumNick,paramSpecs,removedValue,requireSpec,toPropertyName,withoutKeys};
@@ -0,0 +1,3 @@
1
+ import"../_virtual/_rolldown/runtime.js";import{UnknownUtilityError as e}from"./errors.js";const t=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`,`math`,`fangsong`,`emoji`]),n=new Set([`inherit`,`initial`,`unset`,`revert`,`revert-layer`]),r=/^"(?:[^"\\\n\r\f]|\\[\s\S])*"$|^'(?:[^'\\\n\r\f]|\\[\s\S])*'$/,i=/^[a-zA-Z-][\w-]*\(/,a=new Set([` `,` `,`
2
+ `,`\r`,`\f`]);function quote(e){let t=`"`;for(let n of e){let e=n.codePointAt(0)??0;n===`"`||n===`\\`?t+=`\\${n}`:e<32||e===127?t+=`\\${e.toString(16)} `:t+=n}return`${t}"`}function members(e){let t=[],n=0,r=0,i=null,o=!0;for(let s=0;s<e.length;s++){let c=e[s];if(i!==null){c===`\\`?s++:c===i&&(i=null);continue}if((o||r>0)&&(c===`"`||c===`'`))i=c;else if(c===`(`)r++;else if(c===`)`&&r>0)r--;else if(c===`,`&&r===0){t.push(e.slice(n,s)),n=s+1,o=!0;continue}a.has(c)||(o=!1)}return t.push(e.slice(n)),t}function isCompleteCall(e){if(!i.test(e))return!1;let t=0,n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n!==null){i===`\\`?r++:i===n&&(n=null);continue}if(i===`"`||i===`'`)n=i;else if(i===`(`)t++;else if(i===`)`){if(t--,t===0)return r===e.length-1;if(t<0)return!1}}return!1}function serialiseFontFamily(a){let o=members(a),s=o.length===1;return o.map(o=>{let c=o.trim();if(c===``)throw new e(a,`is a font-family list with an empty member. GTK answers a missing family with "Expected a string" and drops the whole declaration, so the list is refused here instead`);if(r.test(c))return c;if(i.test(c)){if(isCompleteCall(c))return c;throw new e(a,`opens a function the member never closes. A function is the one member handed to GTK verbatim, so an unclosed one emits declaration text this module did not write — measured, "var(--x); color: red" emits a second declaration with no parse error at all`)}let l=c.toLowerCase();return t.has(l)||s&&n.has(l)?c:quote(c)}).join(`, `)}const o=[{authored:`Source Sans 3`,emitted:`"Source Sans 3"`,bare:`refused`},{authored:`M PLUS 1p`,emitted:`"M PLUS 1p"`,bare:`refused`},{authored:`8514oem`,emitted:`"8514oem"`,bare:`refused`},{authored:`Foo.Bar`,emitted:`"Foo.Bar"`,bare:`refused`},{authored:`Cantarell`,emitted:`"Cantarell"`,bare:`accepted`},{authored:`Fira Code`,emitted:`"Fira Code"`,bare:`accepted`},{authored:`Liberation Serif`,emitted:`"Liberation Serif"`,bare:`accepted`},{authored:`sans-serif`,emitted:`sans-serif`,bare:`accepted`},{authored:`monospace`,emitted:`monospace`,bare:`accepted`},{authored:`system-ui`,emitted:`system-ui`,bare:`accepted`},{authored:`Sans-Serif`,emitted:`Sans-Serif`,bare:`accepted`},{authored:`inherit`,emitted:`inherit`,bare:`accepted`},{authored:`Source Sans 3, sans-serif`,emitted:`"Source Sans 3", sans-serif`,bare:`refused`},{authored:`'Source Sans 3', sans-serif`,emitted:`'Source Sans 3', sans-serif`,bare:`accepted`},{authored:`Fira Code, ui-monospace, monospace`,emitted:`"Fira Code", ui-monospace, monospace`,bare:`accepted`},{authored:`"Source Sans 3"`,emitted:`"Source Sans 3"`,bare:`accepted`},{authored:`'Noto Sans'`,emitted:`'Noto Sans'`,bare:`accepted`},{authored:`"Foo, Bar", sans-serif`,emitted:`"Foo, Bar", sans-serif`,bare:`accepted`},{authored:`Marion's Hand, sans-serif`,emitted:`"Marion's Hand", sans-serif`,bare:`refused`},{authored:`var(--font-sans)`,emitted:`var(--font-sans)`,bare:`accepted`},{authored:`var(--font-sans, sans-serif)`,emitted:`var(--font-sans, sans-serif)`,bare:`accepted`},{authored:`var(--a, var(--b, sans-serif))`,emitted:`var(--a, var(--b, sans-serif))`,bare:`accepted`},{authored:`Say "Ah"`,emitted:`"Say \\"Ah\\""`,bare:`refused`},{authored:`Back\\slash`,emitted:`"Back\\\\slash"`,bare:`misread`},{authored:`Two
3
+ Lines`,emitted:`"Two\\a Lines"`,bare:`misread`},{authored:`"Two\rLines"`,emitted:`"\\"Two\\d Lines\\""`,bare:`refused`}];export{o as FONT_FAMILY_VECTORS,serialiseFontFamily};
@@ -1 +1 @@
1
- import{StyleSheetError as e,assertContained as t}from"./document.js";import{UnknownUtilityError as n}from"./errors.js";import{GTK_CSS_PROBES as r,GTK_CSS_PROPERTIES as i,NOT_GTK_CSS as a}from"./gtk-css.js";import{GTK_WIDGET_PROPERTIES as o,GTK_WIDGET_PROPERTY_PROBES as s,NOT_GTK_WIDGET_PROPERTIES as c}from"./gtk-props.js";import{MINIMAL_TOKENS as l,TAILWIND_DEFAULT_TOKENS as u,lookupToken as d,mergeTokens as f,requireToken as p,tailwindDefaultHint as m}from"./tokens.js";import{PAINT_PROPERTIES as h,partitionPaint as g,resolvePaintUtility as _}from"./paint.js";import{LAYOUT_PROPERTIES as v,partitionLayout as y,resolveLayoutUtility as b}from"./layout.js";import{partition as x,resolveUtilities as S,resolveUtility as C}from"./resolve.js";import{StyleSheet as w,VARIANT_PSEUDO as T}from"./sheet.js";import{ADWAITA_NAMED_COLORS as E,NEUTRAL_THEME as D,NOT_ADWAITA_NAMED_COLORS as O,THEME_PROVIDER_PRIORITY as k,ThemeRegistry as A}from"./theme.js";export{E as ADWAITA_NAMED_COLORS,r as GTK_CSS_PROBES,i as GTK_CSS_PROPERTIES,o as GTK_WIDGET_PROPERTIES,s as GTK_WIDGET_PROPERTY_PROBES,v as LAYOUT_PROPERTIES,l as MINIMAL_TOKENS,D as NEUTRAL_THEME,O as NOT_ADWAITA_NAMED_COLORS,a as NOT_GTK_CSS,c as NOT_GTK_WIDGET_PROPERTIES,h as PAINT_PROPERTIES,w as StyleSheet,e as StyleSheetError,u as TAILWIND_DEFAULT_TOKENS,k as THEME_PROVIDER_PRIORITY,A as ThemeRegistry,n as UnknownUtilityError,T as VARIANT_PSEUDO,t as assertContained,d as lookupToken,f as mergeTokens,x as partition,y as partitionLayout,g as partitionPaint,p as requireToken,b as resolveLayoutUtility,_ as resolvePaintUtility,S as resolveUtilities,C as resolveUtility,m as tailwindDefaultHint};
1
+ import{StyleSheetError as e,assertContained as t}from"./document.js";import{UnknownUtilityError as n}from"./errors.js";import{FONT_FAMILY_VECTORS as r,serialiseFontFamily as i}from"./font-family.js";import{GTK_CSS_PROBES as a,GTK_CSS_PROPERTIES as o,NOT_GTK_CSS as s}from"./gtk-css.js";import{GTK_WIDGET_PROPERTIES as c,GTK_WIDGET_PROPERTY_PROBES as l,NOT_GTK_WIDGET_PROPERTIES as u}from"./gtk-props.js";import{MINIMAL_TOKENS as d,TAILWIND_DEFAULT_TOKENS as f,lookupToken as p,mergeTokens as m,requireToken as h,tailwindDefaultHint as g}from"./tokens.js";import{CSS_VALUE as _,CSS_VALUE_KIND as v,PAINT_PROPERTIES as y,partitionPaint as b,resolvePaintUtility as x}from"./paint.js";import{LAYOUT_PROPERTIES as S,partitionLayout as C,resolveLayoutUtility as w}from"./layout.js";import{partition as T,resolveUtilities as E,resolveUtility as D}from"./resolve.js";import{StyleSheet as O,VARIANT_PSEUDO as k}from"./sheet.js";import{ADWAITA_NAMED_COLORS as A,NEUTRAL_THEME as j,NOT_ADWAITA_NAMED_COLORS as M,THEME_PROVIDER_PRIORITY as N,ThemeRegistry as P}from"./theme.js";export{A as ADWAITA_NAMED_COLORS,_ as CSS_VALUE,v as CSS_VALUE_KIND,r as FONT_FAMILY_VECTORS,a as GTK_CSS_PROBES,o as GTK_CSS_PROPERTIES,c as GTK_WIDGET_PROPERTIES,l as GTK_WIDGET_PROPERTY_PROBES,S as LAYOUT_PROPERTIES,d as MINIMAL_TOKENS,j as NEUTRAL_THEME,M as NOT_ADWAITA_NAMED_COLORS,s as NOT_GTK_CSS,u as NOT_GTK_WIDGET_PROPERTIES,y as PAINT_PROPERTIES,O as StyleSheet,e as StyleSheetError,f as TAILWIND_DEFAULT_TOKENS,N as THEME_PROVIDER_PRIORITY,P as ThemeRegistry,n as UnknownUtilityError,k as VARIANT_PSEUDO,t as assertContained,p as lookupToken,m as mergeTokens,T as partition,C as partitionLayout,b as partitionPaint,h as requireToken,w as resolveLayoutUtility,x as resolvePaintUtility,E as resolveUtilities,D as resolveUtility,i as serialiseFontFamily,g as tailwindDefaultHint};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{UnknownUtilityError as e}from"./errors.js";import{GTK_CSS_PROPERTIES as t}from"./gtk-css.js";import{lookupToken as n,requireToken as r,tailwindDefaultHint as i}from"./tokens.js";const a={backgroundColor:`background-color`,color:`color`,opacity:`opacity`,borderRadius:`border-radius`,borderTopLeftRadius:`border-top-left-radius`,borderTopRightRadius:`border-top-right-radius`,borderBottomLeftRadius:`border-bottom-left-radius`,borderBottomRightRadius:`border-bottom-right-radius`,borderWidth:`border-width`,borderTopWidth:`border-top-width`,borderRightWidth:`border-right-width`,borderBottomWidth:`border-bottom-width`,borderLeftWidth:`border-left-width`,borderColor:`border-color`,fontSize:`font-size`,fontWeight:`font-weight`,fontFamily:`font-family`,fontStyle:`font-style`,letterSpacing:`letter-spacing`,lineHeight:`line-height`,textDecorationLine:`text-decoration-line`,textTransform:`text-transform`},withAlpha=(t,n)=>{let r=Number(n);if(!Number.isFinite(r)||r<0||r>100)throw new e(`${t}/${n}`,`the alpha modifier must be 0–100, got "${n}"`);return`alpha(${t}, ${r/100})`};function resolvePaintUtility(t,a){if(t.includes(`:`))throw new e(t,`strip the variant prefix before resolving; this resolves the utility itself`);let l=t.lastIndexOf(`/`),u=l===-1?void 0:t.slice(l+1),d=l===-1?t:t.slice(0,l),colour=e=>u===void 0?e:withAlpha(e,u),noAlpha=()=>{if(u!==void 0)throw new e(t,`an alpha modifier only applies to a colour utility`)};switch(d){case`underline`:return noAlpha(),{textDecorationLine:`underline`};case`line-through`:return noAlpha(),{textDecorationLine:`line-through`};case`no-underline`:return noAlpha(),{textDecorationLine:`none`};case`uppercase`:return noAlpha(),{textTransform:`uppercase`};case`lowercase`:return noAlpha(),{textTransform:`lowercase`};case`capitalize`:return noAlpha(),{textTransform:`capitalize`};case`normal-case`:return noAlpha(),{textTransform:`none`};case`italic`:return noAlpha(),{fontStyle:`italic`};case`not-italic`:return noAlpha(),{fontStyle:`normal`};case`rounded`:return noAlpha(),{borderRadius:r(a.borderRadius,`DEFAULT`,t,`borderRadius`)};case`border`:return noAlpha(),{borderWidth:r(a.borderWidth,`DEFAULT`,t,`borderWidth`)}}let f=d.indexOf(`-`),p=f===-1?d:d.slice(0,f),m=f===-1?``:d.slice(f+1);switch(p){case`bg`:return{backgroundColor:colour(r(a.colors,m,t,`colors`))};case`opacity`:return noAlpha(),{opacity:r(a.opacity,m,t,`opacity`)};case`rounded`:{noAlpha();let e=o[m];return e===void 0?{borderRadius:r(a.borderRadius,m,t,`borderRadius`)}:{[e]:r(a.borderRadius,`DEFAULT`,t,`borderRadius`)}}case`border`:{let o=s[m];if(o!==void 0)return noAlpha(),{[o]:r(a.borderWidth,`DEFAULT`,t,`borderWidth`)};let c=n(a.borderWidth,m),l=n(a.colors,m);if(c!==void 0&&l!==void 0)throw new e(t,`"${m}" is in both the borderWidth and colors scales, so this utility is ambiguous`);if(c!==void 0)return noAlpha(),{borderWidth:c};if(l!==void 0)return{borderColor:colour(l)};throw new e(t,`"${m}" is in neither the borderWidth nor the colors scale`+(i(`borderWidth`,m)||i(`colors`,m)))}case`text`:{if(c.has(m))return null;let r=n(a.fontSize,m),o=n(a.colors,m);if(r!==void 0&&o!==void 0)throw new e(t,`"${m}" is in both the fontSize and colors scales, so this utility is ambiguous`);if(r!==void 0)return noAlpha(),{fontSize:r};if(o!==void 0)return{color:colour(o)};throw new e(t,`"${m}" is in neither the fontSize nor the colors scale`+(i(`fontSize`,m)||i(`colors`,m)))}case`font`:{noAlpha();let r=n(a.fontWeight,m),i=n(a.fontFamily,m);if(r!==void 0&&i!==void 0)throw new e(t,`"${m}" is in both the fontWeight and fontFamily scales, so this utility is ambiguous`);if(r!==void 0)return{fontWeight:r};if(i!==void 0)return{fontFamily:i};throw new e(t,`"${m}" is in neither the fontWeight nor the fontFamily scale`)}case`tracking`:return noAlpha(),{letterSpacing:r(a.letterSpacing,m,t,`letterSpacing`)};case`leading`:return noAlpha(),{lineHeight:r(a.lineHeight,m,t,`lineHeight`)}}return null}const o={tl:`borderTopLeftRadius`,tr:`borderTopRightRadius`,bl:`borderBottomLeftRadius`,br:`borderBottomRightRadius`},s={t:`borderTopWidth`,r:`borderRightWidth`,b:`borderBottomWidth`,l:`borderLeftWidth`},c=new Set([`left`,`center`,`right`,`justify`,`start`,`end`]),l=new Set(Object.keys(a));function partitionPaint(n){let r=[];for(let[i,o]of Object.entries(n)){if(o===void 0)continue;let n=a[i];if(n===void 0)throw new e(i,`is not a property the paint partition routes`);if(!t.has(n))throw new e(i,`maps to "${n}", which GTK does not accept — see gtk-css.ts`);r.push(`${n}: ${o}`)}let i=r.some(e=>/^border(-(top|right|bottom|left))?-width:/.test(e)),o=r.some(e=>/^border(-(top|right|bottom|left))?-style:/.test(e));return i&&!o&&r.push(`border-style: solid`),r}export{a as CSS_NAME,l as PAINT_PROPERTIES,partitionPaint,resolvePaintUtility};
1
+ import"../_virtual/_rolldown/runtime.js";import{UnknownUtilityError as e}from"./errors.js";import{serialiseFontFamily as t}from"./font-family.js";import{GTK_CSS_PROPERTIES as n}from"./gtk-css.js";import{lookupToken as r,requireToken as i,tailwindDefaultHint as a}from"./tokens.js";const o={backgroundColor:`background-color`,color:`color`,opacity:`opacity`,borderRadius:`border-radius`,borderTopLeftRadius:`border-top-left-radius`,borderTopRightRadius:`border-top-right-radius`,borderBottomLeftRadius:`border-bottom-left-radius`,borderBottomRightRadius:`border-bottom-right-radius`,borderWidth:`border-width`,borderTopWidth:`border-top-width`,borderRightWidth:`border-right-width`,borderBottomWidth:`border-bottom-width`,borderLeftWidth:`border-left-width`,borderColor:`border-color`,fontSize:`font-size`,fontWeight:`font-weight`,fontFamily:`font-family`,fontStyle:`font-style`,letterSpacing:`letter-spacing`,lineHeight:`line-height`,textDecorationLine:`text-decoration-line`,textTransform:`text-transform`},s={backgroundColor:`colour`,color:`colour`,opacity:`number`,borderRadius:`length`,borderTopLeftRadius:`length`,borderTopRightRadius:`length`,borderBottomLeftRadius:`length`,borderBottomRightRadius:`length`,borderWidth:`length`,borderTopWidth:`length`,borderRightWidth:`length`,borderBottomWidth:`length`,borderLeftWidth:`length`,borderColor:`colour`,fontSize:`length`,fontWeight:`number`,fontFamily:`name`,fontStyle:`keyword`,letterSpacing:`length`,lineHeight:`number`,textDecorationLine:`keyword`,textTransform:`keyword`},c={fontFamily:t},withAlpha=(t,n)=>{let r=Number(n);if(!Number.isFinite(r)||r<0||r>100)throw new e(`${t}/${n}`,`the alpha modifier must be 0–100, got "${n}"`);return`alpha(${t}, ${r/100})`};function resolvePaintUtility(t,n){if(t.includes(`:`))throw new e(t,`strip the variant prefix before resolving; this resolves the utility itself`);let o=t.lastIndexOf(`/`),s=o===-1?void 0:t.slice(o+1),c=o===-1?t:t.slice(0,o),colour=e=>s===void 0?e:withAlpha(e,s),noAlpha=()=>{if(s!==void 0)throw new e(t,`an alpha modifier only applies to a colour utility`)};switch(c){case`underline`:return noAlpha(),{textDecorationLine:`underline`};case`line-through`:return noAlpha(),{textDecorationLine:`line-through`};case`no-underline`:return noAlpha(),{textDecorationLine:`none`};case`uppercase`:return noAlpha(),{textTransform:`uppercase`};case`lowercase`:return noAlpha(),{textTransform:`lowercase`};case`capitalize`:return noAlpha(),{textTransform:`capitalize`};case`normal-case`:return noAlpha(),{textTransform:`none`};case`italic`:return noAlpha(),{fontStyle:`italic`};case`not-italic`:return noAlpha(),{fontStyle:`normal`};case`rounded`:return noAlpha(),{borderRadius:i(n.borderRadius,`DEFAULT`,t,`borderRadius`)};case`border`:return noAlpha(),{borderWidth:i(n.borderWidth,`DEFAULT`,t,`borderWidth`)}}let f=c.indexOf(`-`),p=f===-1?c:c.slice(0,f),m=f===-1?``:c.slice(f+1);switch(p){case`bg`:return{backgroundColor:colour(i(n.colors,m,t,`colors`))};case`opacity`:return noAlpha(),{opacity:i(n.opacity,m,t,`opacity`)};case`rounded`:{noAlpha();let e=l[m];return e===void 0?{borderRadius:i(n.borderRadius,m,t,`borderRadius`)}:{[e]:i(n.borderRadius,`DEFAULT`,t,`borderRadius`)}}case`border`:{let o=u[m];if(o!==void 0)return noAlpha(),{[o]:i(n.borderWidth,`DEFAULT`,t,`borderWidth`)};let s=r(n.borderWidth,m),c=r(n.colors,m);if(s!==void 0&&c!==void 0)throw new e(t,`"${m}" is in both the borderWidth and colors scales, so this utility is ambiguous`);if(s!==void 0)return noAlpha(),{borderWidth:s};if(c!==void 0)return{borderColor:colour(c)};throw new e(t,`"${m}" is in neither the borderWidth nor the colors scale`+(a(`borderWidth`,m)||a(`colors`,m)))}case`text`:{if(d.has(m))return null;let i=r(n.fontSize,m),o=r(n.colors,m);if(i!==void 0&&o!==void 0)throw new e(t,`"${m}" is in both the fontSize and colors scales, so this utility is ambiguous`);if(i!==void 0)return noAlpha(),{fontSize:i};if(o!==void 0)return{color:colour(o)};throw new e(t,`"${m}" is in neither the fontSize nor the colors scale`+(a(`fontSize`,m)||a(`colors`,m)))}case`font`:{noAlpha();let i=r(n.fontWeight,m),a=r(n.fontFamily,m);if(i!==void 0&&a!==void 0)throw new e(t,`"${m}" is in both the fontWeight and fontFamily scales, so this utility is ambiguous`);if(i!==void 0)return{fontWeight:i};if(a!==void 0)return{fontFamily:a};throw new e(t,`"${m}" is in neither the fontWeight nor the fontFamily scale`)}case`tracking`:return noAlpha(),{letterSpacing:i(n.letterSpacing,m,t,`letterSpacing`)};case`leading`:return noAlpha(),{lineHeight:i(n.lineHeight,m,t,`lineHeight`)}}return null}const l={tl:`borderTopLeftRadius`,tr:`borderTopRightRadius`,bl:`borderBottomLeftRadius`,br:`borderBottomRightRadius`},u={t:`borderTopWidth`,r:`borderRightWidth`,b:`borderBottomWidth`,l:`borderLeftWidth`},d=new Set([`left`,`center`,`right`,`justify`,`start`,`end`]),f=new Set(Object.keys(o));function partitionPaint(t){let r=[];for(let[i,a]of Object.entries(t)){if(a===void 0)continue;let t=o[i];if(t===void 0)throw new e(i,`is not a property the paint partition routes`);if(!n.has(t))throw new e(i,`maps to "${t}", which GTK does not accept — see gtk-css.ts`);let s=c[i];r.push(`${t}: ${s===void 0?a:s(a)}`)}let i=r.some(e=>/^border(-(top|right|bottom|left))?-width:/.test(e)),a=r.some(e=>/^border(-(top|right|bottom|left))?-style:/.test(e));return i&&!a&&r.push(`border-style: solid`),r}export{o as CSS_NAME,c as CSS_VALUE,s as CSS_VALUE_KIND,f as PAINT_PROPERTIES,partitionPaint,resolvePaintUtility};