@gjsify/gtk-host 0.41.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +454 -6
  2. package/lib/esm/adapters/react.js +1 -0
  3. package/lib/esm/adapters/solid.js +1 -0
  4. package/lib/esm/adapters/vue.js +1 -0
  5. package/lib/esm/attrs.js +0 -0
  6. package/lib/esm/conformance/diagnostics.js +2 -2
  7. package/lib/esm/conformance/index.js +2 -2
  8. package/lib/esm/descriptors/index.js +1 -1
  9. package/lib/esm/errors.js +1 -1
  10. package/lib/esm/generated/props.js +0 -0
  11. package/lib/esm/generated/widgets.js +1 -0
  12. package/lib/esm/host.js +1 -1
  13. package/lib/esm/index.js +1 -1
  14. package/lib/esm/jsx-runtime.js +1 -0
  15. package/lib/esm/policies.js +1 -1
  16. package/lib/esm/probe.js +1 -0
  17. package/lib/esm/props.js +1 -1
  18. package/lib/esm/react-jsx-runtime.js +1 -0
  19. package/lib/esm/registry.js +1 -1
  20. package/lib/esm/signals.js +1 -1
  21. package/lib/esm/tags.js +2 -0
  22. package/lib/esm/vue-components.js +0 -0
  23. package/lib/types/adapters/react.d.ts +175 -0
  24. package/lib/types/adapters/react.spec.d.ts +2 -0
  25. package/lib/types/adapters/solid.d.ts +78 -0
  26. package/lib/types/adapters/solid.spec.d.ts +2 -0
  27. package/lib/types/adapters/vue.d.ts +24 -0
  28. package/lib/types/adapters/vue.spec.d.ts +2 -0
  29. package/lib/types/attrs.d.ts +102 -0
  30. package/lib/types/buildable.spec.d.ts +2 -0
  31. package/lib/types/conformance/diagnostics.d.ts +14 -0
  32. package/lib/types/conformance/index.d.ts +24 -1
  33. package/lib/types/conformance/vectors.d.mts +34 -0
  34. package/lib/types/descriptors/index.d.ts +52 -1
  35. package/lib/types/errors.d.ts +21 -0
  36. package/lib/types/generated/props.d.ts +5505 -0
  37. package/lib/types/generated/surface-data.d.mts +22 -0
  38. package/lib/types/generated/widgets.d.ts +3 -0
  39. package/lib/types/generated.spec.d.ts +4 -0
  40. package/lib/types/generator/emit-types.d.mts +54 -0
  41. package/lib/types/generator/emit.d.mts +50 -0
  42. package/lib/types/generator/gir.d.mts +156 -0
  43. package/lib/types/generator/main.d.mts +23 -0
  44. package/lib/types/generator/mini.fixture.d.mts +30 -0
  45. package/lib/types/generator/surface.d.mts +62 -0
  46. package/lib/types/generator/tsmap.d.mts +73 -0
  47. package/lib/types/generator.spec.d.ts +2 -0
  48. package/lib/types/host.d.ts +102 -1
  49. package/lib/types/index.d.ts +6 -3
  50. package/lib/types/jsx-runtime.d.ts +70 -0
  51. package/lib/types/policies.d.ts +58 -0
  52. package/lib/types/probe.d.ts +58 -0
  53. package/lib/types/props.d.ts +49 -2
  54. package/lib/types/react-jsx-runtime.d.ts +108 -0
  55. package/lib/types/registry.d.ts +1 -1
  56. package/lib/types/signals.d.ts +16 -1
  57. package/lib/types/tags.d.ts +25 -0
  58. package/lib/types/testing/gate.d.mts +2 -0
  59. package/lib/types/types.d.ts +56 -3
  60. package/lib/types/vue-components.d.ts +46 -0
  61. package/package.json +77 -7
package/lib/esm/host.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import{lookupWidget as t,nearestRegistered as n}from"./registry.js";import{addressOf as r,insertChild as i,makeWrapper as a,removeChild as o}from"./policies.js";import{beginHostWrite as s,clearHandlers as c,endHostWrite as l,isEventProp as u,setHandler as d,toSignalName as f}from"./signals.js";import{coerce as p,defaultValue as m,paramSpecs as h,requireSpec as g,toPropertyName as _}from"./props.js";import v from"gi://GObject";function createElement(e,n){let r={kind:`element`,descriptor:t(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};if(n)for(let[e,t]of Object.entries(n))setProp(r,e,t);return r}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;let t=e.descriptor.ctor(),n=h(t,e.descriptor.gtype),r={};for(let[t,i]of Object.entries(e.props))r[t]=p(g(n,e.descriptor.gtype,t),i,e.descriptor.gtype);s();try{e.widget=new t(r)}finally{l()}try{replayInto(e)}catch(t){c(e);for(let t of childSnapshot(e))t.kind===`element`&&t.attached&&(o(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)d(e,t,n);for(let t=e.first;t;t=t.next)t.kind===`element`&&attach(e,t);e.textFromChildren&&flushText(e)}function setProp(e,t,n,r){if(u(t))return setEventHandler(e,t,n);if(t===`slot`)return setSlot(e,n);if(t===`layout`){let t=n,r=e.parent;if(!r||!e.widget){e.layout=t;return}let i=e.layout;replaceAt(e,r,()=>{e.layout=t},()=>{e.layout=i});return}let i=_(t),a=g(h(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,i),o=n===void 0?m(a):p(a,n,e.descriptor.gtype),c=i in e.props?e.props[i]:void 0;if(n===void 0?delete e.props[i]:e.props[i]=n,e.widget){if((a.flags&v.ParamFlags.CONSTRUCT_ONLY)!==0)return rebuild(e,i,c);s();try{e.widget.set_property(i,o)}finally{l()}}}function setEventHandler(e,t,n){e.widget?d(e,t,n):n&&assertSignalExists(e,t),n?e.listeners.set(t,n):e.listeners.delete(t)}function assertSignalExists(t,n){let r=f(n,t.descriptor.eventAliases).split(`::`)[0],i=t.descriptor.ctor().$gtype;if(v.signal_lookup(r,i)===0)throw e.unknownSignal(t.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){o(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 r=e.parent;if(e.widget){c(e);for(let t of childSnapshot(e))t.kind===`element`&&(o(e,t),t.attached=!1);r&&o(r,e)}e.widget=null,e.wrapper=null,e.attached=!1;try{materialize(e)}catch(i){t!==void 0&&(n===void 0?delete e.props[t]:e.props[t]=n);try{materialize(e),r&&attach(r,e)}catch{}throw i}r&&attach(r,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;for(let t of childSnapshot(e))destroy(t)}function flushText(e){let t=``,n=!1;for(let r of childNodes(e))r.kind===`text`&&(t+=r.data,n=!0);t===``&&!e.textFromChildren||(writeTextSink(e,t),e.textFromChildren=n)}function writeTextSink(t,n){let r=t.descriptor.textSink;if(!r)throw e.textNotAccepted(t.descriptor.gtype,n);materialize(t);let i=g(h(t.descriptor.ctor(),t.descriptor.gtype),t.descriptor.gtype,r);s();try{t.widget.set_property(r,p(i,n,t.descriptor.gtype))}finally{l()}t.props[r]=n}function*childNodes(e){for(let t=e.first;t;t=t.next)yield t}function childSnapshot(e){let t=[];for(let n=e.first;n;n=n.next)t.push(n);return t}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);let n=null,a=0;for(let i=e.first;i&&i!==t;i=i.next)i.kind!==`element`||!i.attached||(n=r(i),a+=1);let o=[];for(let e=t.next;e;e=e.next)e.kind===`element`&&e.attached&&o.push(e);i({parent:e,child:t,prevWidget:n,index:a,following:o}),t.attached=!0}function ensureWrapper(e,t){if(t.wrapper)return;let n=a(e.descriptor.children,t.widget);n&&(t.wrapper=n)}function insert(e,t,n=null){let r=e.parent,i=e.next;e.parent&&remove(e),link(t,e,n);try{e.kind===`element`?attach(t,e):e.kind===`text`&&flushText(t)}catch(t){throw unlink(e),r&&restore(e,r,i),t}}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 remove(e){let t=e.parent;t&&e.kind===`element`&&(o(t,e),e.attached=!1,e.wrapper&&=(e.wrapper.set_child(null),null)),unlink(e),t&&e.kind===`text`&&flushText(t)}function clearContainer(e){for(;e.first;)remove(e.first)}function destroy(e){if(e.kind===`element`){for(let t of childSnapshot(e))destroy(t);c(e),e.listeners.clear()}if(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}}function mountRoot(t,r){materialize(t);let a=r.constructor.$gtype,o=n(a);if(!o)throw e.unknownTag(gtypeNameOf(r));let s={kind:`element`,descriptor:o,widget:r,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},c=directChildren(r);link(s,t,null);try{ensureWrapper(s,t),i({parent:s,child:t,prevWidget:c.length>0?c[c.length-1]:null,index:c.length,following:[]}),t.attached=!0}catch(e){throw unlink(t),e}}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=>v.type_name(e.constructor.$gtype),parentNode=e=>e.parent,firstChild=e=>e.first,nextSibling=e=>e.next,prevSibling=e=>e.prev;export{clearContainer,createAnchor,createElement,createText,destroy,firstChild,insert,isText,materialize,mountRoot,nextSibling,parentNode,prevSibling,remove,setElementText,setEventHandler,setProp,setSlot,setText};
1
+ import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import{addressOf as t,insertChild as n,makeDetachedContainer as r,makeWrapper as i,removeChild as a,setterSlotOf as o,setterSlots as s,slotOccupant as c}from"./policies.js";import{beginHostWrite as l,clearHandlers as u,endHostWrite as d,isEventProp as f,setHandler as p,toSignalName as m}from"./signals.js";import{coerce as h,paramSpecs as g,removedValue as _,requireSpec as v,toPropertyName as y}from"./props.js";import{lookupWidget as b,nearestRegistered as x}from"./registry.js";import S from"gi://GObject";function createElement(e,t){let n={kind:`element`,descriptor:b(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(t){if(t.widget)return t.widget;for(let n of t.descriptor.requiresProps??[])if(!(n in t.props))throw e.missingConstructProp(t.descriptor.gtype,n);let n=t.descriptor.ctor(),r=g(n,t.descriptor.gtype),i={};for(let[e,n]of Object.entries(t.props))i[e]=h(v(r,t.descriptor.gtype,e),n,t.descriptor.gtype);l();try{t.widget=new n(i)}finally{d()}try{replayInto(t)}catch(e){u(t);for(let e of childSnapshot(t))e.kind===`element`&&e.attached&&(a(t,e),e.attached=!1);throw t.widget=null,t.wrapper=null,e}return t.widget}function replayInto(e){for(let[t,n]of e.listeners)p(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,n,r){if(f(t))return setEventHandler(e,t,n);if(t===`slot`)return setSlot(e,n);if(t===`layout`){let t=n,r=e.parent;if(!r||!e.widget){e.layout=t;return}let i=e.layout;replaceAt(e,r,()=>{e.layout=t},()=>{e.layout=i});return}let i=y(t),a=v(g(e.descriptor.ctor(),e.descriptor.gtype),e.descriptor.gtype,i),o=n==null,s=o?_(e.descriptor,a):h(a,n,e.descriptor.gtype),c=i in e.props?e.props[i]:void 0;if(o?delete e.props[i]:e.props[i]=n,e.widget){if((a.flags&S.ParamFlags.CONSTRUCT_ONLY)!==0)return rebuild(e,i,c);l();try{e.widget.set_property(i,s)}finally{d()}}}function setEventHandler(e,t,n){e.widget?p(e,t,n):n&&assertSignalExists(e,t),n?e.listeners.set(t,n):e.listeners.delete(t)}function assertSignalExists(t,n){let r=m(n,t.descriptor.eventAliases).split(`::`)[0],i=t.descriptor.ctor().$gtype;if(S.signal_lookup(r,i)===0)throw e.unknownSignal(t.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){a(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 r=e.parent;if(e.widget){u(e);for(let t of childSnapshot(e))t.kind===`element`&&(a(e,t),t.attached=!1);r&&a(r,e)}e.widget=null,e.wrapper=null,e.attached=!1;try{materialize(e)}catch(i){t!==void 0&&(n===void 0?delete e.props[t]:e.props[t]=n);try{materialize(e),r&&attach(r,e)}catch{}throw i}r&&attach(r,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&&o(e,t)&&(yield t)}const holdsElementInSetterSlot=e=>!setterSlotChildren(e).next().done;function writeTextSink(t,n){let r=t.descriptor.textSink;if(!r)throw e.textNotAccepted(t.descriptor.gtype,n);materialize(t);let i=t.descriptor.children,a=i.kind===`single`?i.set:null;if(a&&!holdsOursInSlot(t,null)&&appOccupant(t.widget,t.descriptor,a))throw e.occupiedSlot(t.descriptor.gtype,`text`,a);let o=v(g(t.descriptor.ctor(),t.descriptor.gtype),t.descriptor.gtype,r);l();try{t.widget.set_property(r,h(o,n,t.descriptor.gtype))}finally{d()}t.props[r]=n;for(let e of setterSlotChildren(t))e.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(t,n){let r=0;for(let i=t;i;i=i.next){if(++r>1e5)throw e.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,r){if(!e.widget)return;materialize(r),ensureWrapper(e,r),refuseOccupiedSlot(e,r);let i=e.foreign.length>0?e.foreign.filter(t=>t.get_parent()===e.widget):e.foreign,a=i.length>0?i[i.length-1]:null,o=i.length;for(let n of siblingsFrom(e.first,e)){if(n===r)break;n.kind!==`element`||!n.attached||(a=t(n),o+=1)}let s=[];for(let t of siblingsFrom(r.next,e))t.kind===`element`&&t.attached&&s.push(t);n({parent:e,child:r,prevWidget:a,index:o,following:s}),r.attached=!0}function refuseOccupiedSlot(t,n){let r=o(t,n);if(r&&!holdsOursInSlot(t,n.slot)&&appOccupant(t.widget,t.descriptor,r))throw e.occupiedSlot(t.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(e,t){if(t.wrapper)return;let n=i(e.descriptor.children,t.widget);n&&(t.wrapper=n)}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(t){if(!isHostElement(t))throw e.notAHostParent(describeValue(t))}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?S.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 remove(e){let t=e.parent;t&&e.kind===`element`&&(a(t,e),e.attached=!1,e.wrapper&&=(e.wrapper.set_child(null),null)),unlink(e),t&&e.kind===`text`&&flushText(t)}function destroyChildren(e){for(let t of childSnapshot(e))destroy(t)}function disconnectHandlers(e){u(e),e.listeners.clear()}function destroy(e){if(e.kind===`element`&&(destroyChildren(e),u(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(t){if(t.kind!==`element`)throw e.notAnElement(t.kind);if(t.destroyed)throw e.destroyedNode(t.descriptor.gtype);return materialize(t)}const createDetachedContainer=()=>adopt(r());function adopt(t){let n=t.constructor.$gtype,r=x(n);if(!r)throw e.unknownTag(gtypeNameOf(t));return{kind:`element`,descriptor:r,widget:t,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(t,r)}}function adoptedChildren(e,t){let n=s(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=c(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=>S.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{clearRegistry as t,hasWidget as n,lookupWidget as r,nearestRegistered as i,registerWidget as a,registerWidgets as o,registeredTags as s}from"./registry.js";import{ADW_DESCRIPTORS as c}from"./descriptors/adw.js";import{GTK_DESCRIPTORS as l}from"./descriptors/gtk.js";import{BUILTIN_DESCRIPTORS as u,registerBuiltinWidgets as d}from"./descriptors/index.js";import{addressOf as f,reorderMode as p}from"./policies.js";import{isEventProp as m,toSignalName as h}from"./signals.js";import{constructOnlyNames as g,isConstructOnly as _,isWritable as v,paramSpecs as y,toPropertyName as b}from"./props.js";import{clearContainer as x,createAnchor as S,createElement as C,createText as w,destroy as T,firstChild as E,insert as D,isText as O,materialize as k,mountRoot as A,nextSibling as j,parentNode as M,prevSibling as N,remove as P,setElementText as F,setEventHandler as I,setProp as L,setSlot as R,setText as z}from"./host.js";import"./types.js";export{c as ADW_DESCRIPTORS,u as BUILTIN_DESCRIPTORS,l as GTK_DESCRIPTORS,e as GtkHostError,f as addressOf,x as clearContainer,t as clearRegistry,g as constructOnlyNames,S as createAnchor,C as createElement,w as createText,T as destroy,E as firstChild,n as hasWidget,D as insert,_ as isConstructOnly,m as isEventProp,O as isText,v as isWritable,r as lookupWidget,k as materialize,A as mountRoot,i as nearestRegistered,j as nextSibling,y as paramSpecs,M as parentNode,N as prevSibling,d as registerBuiltinWidgets,a as registerWidget,o as registerWidgets,s as registeredTags,P as remove,p as reorderMode,F as setElementText,I as setEventHandler,L as setProp,R as setSlot,z as setText,b as toPropertyName,h as toSignalName};
1
+ import{GtkHostError as e}from"./errors.js";import{addressOf as t,reorderMode as n}from"./policies.js";import{isEventProp as r,toSignalName as i}from"./signals.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{probeEnabled as $,runHostProbe as ee,runHostProbeApp as te}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,t as addressOf,b as adopt,d as assertInjective,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,r 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,$ as probeEnabled,Z as registerBuiltinWidgets,_ as registerWidget,v as registerWidgets,y as registeredTags,L as remove,n as reorderMode,ee as runHostProbe,te as runHostProbeApp,R as setElementText,z as setEventHandler,B as setProp,V as setSlot,H as setText,Q as tableProvenance,f as tagOf,u as toPropertyName,i as toSignalName,U as widgetOf};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";const e=`@gjsify/gtk-host/jsx-runtime is a TYPE surface, not an automatic JSX runtime. Set "jsx": "preserve" and compile with babel-preset-solid (Solid) or the Vue SFC compiler (Vue) — those emit the renderer calls. With "jsx": "react-jsx" TypeScript emits jsx()/jsxs() calls instead, and no GTK tree can come out of them.`;function jsx(){throw Error(e)}function jsxs(){throw Error(e)}function jsxDEV(){throw Error(e)}function Fragment(){throw Error(e)}export{Fragment,jsx,jsxDEV,jsxs};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{GtkHostError as e,err as t}from"./errors.js";import n 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){if(e.kind!==`indexed`||!e.wrap)return null;if(e.wrap===`list-box-row`){if(t instanceof n.ListBoxRow)return null;let e=new n.ListBoxRow;return e.set_child(t),e}if(t instanceof n.FlowBoxChild)return null;let r=new n.FlowBoxChild;return r.set_child(t),r}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`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}}function appendChild(e,n,r){let i=e.descriptor.children,a=addressOf(n);switch(i.kind){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`){let slotOf=e=>e.slot??i.defaultSlot,e=slotOf(t);if(i.slots[e]?.startsWith(`set_`))return;a=n.filter(t=>slotOf(t)===e)}for(let t of a)detachChild(e,t,r);for(let t of a)appendChild(e,t,r)}function detachChild(e,t,n){let r=e.descriptor.children,i=t.wrapper??t.widget;if(i)switch(r.kind){case`none`:return;case`single`:clearIfCurrent(n,r.set,i);return;case`slotted`:{let e=r.slots[t.slot??r.defaultSlot];if(e?.startsWith(`set_`)){clearIfCurrent(n,e,i);return}n[r.remove](i);return}case`ordered`:case`indexed`:case`keyed`:case`coords`:n[r.remove](i);return}}function clearIfCurrent(e,t,n){let r=t.replace(/^set_/,`get_`),i=typeof e[r]==`function`?e[r]():void 0;(i===void 0||i===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`ordered`:return e.reorder;case`indexed`:return`native`;case`slotted`:case`keyed`:return`remove-all`;case`coords`:case`single`:case`none`:return`n/a`}}export{addressOf,insertChild,makeWrapper,removeChild,reorderMode};
1
+ import"./_virtual/_rolldown/runtime.js";import{GtkHostError as e,err as t}from"./errors.js";import n 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){if(e.kind!==`indexed`||!e.wrap)return null;if(e.wrap===`list-box-row`){if(t instanceof n.ListBoxRow)return null;let e=new n.ListBoxRow;return e.set_child(t),e}if(t instanceof n.FlowBoxChild)return null;let r=new n.FlowBoxChild;return r.set_child(t),r}const makeDetachedContainer=()=>new n.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 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,t,n){let r=e.descriptor.children,i=t.wrapper??t.widget;if(i)switch(r.kind){case`none`:case`uncurated`:return;case`single`:clearIfCurrent(n,r.set,i);return;case`slotted`:{let a=setterSlotOf(e,t);if(a){clearIfCurrent(n,a,i);return}n[r.remove](i);return}case`ordered`:case`indexed`:case`keyed`:case`coords`:n[r.remove](i);return;default:return unhandledPolicy(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`:case`keyed`:return`remove-all`;case`coords`:case`single`:case`none`:return`n/a`;default:return unhandledPolicy(e)}}export{addressOf,insertChild,makeDetachedContainer,makeWrapper,removeChild,reorderMode,setterSlotOf,setterSlots,slotOccupant,unhandledPolicy};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import{installDiagnosticsGate as e}from"./conformance/diagnostics.js";import t from"gi://Gtk?version=4.0";import n from"gi://Adw?version=1";import r from"gi://GLib";import i from"system";function probeEnabled(){let e=r.getenv(`GJSIFY_HOST_PROBE`);if(e===null)return!1;let t=e.toLowerCase();return t!==``&&t!==`0`&&t!==`false`}const a=`<gtk-host probe: recorder self-check>`;function recorderIsHonest(e,t){let n=t.length;e(a,!1);let r=t.length===n+1&&t[n]===a;t.length=n,e(a,!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`}function runHostProbe(t,n=null){let r=t.label??`PROBE`,i=e();i.reset();let a=[],check=(e,t)=>{t||a.push(e)},o=recorderIsHonest(check,a);o!==null&&a.push(o);let s={};try{s=t.assert(t.build(n),check)}catch(e){a.push(`threw: ${e.message}`)}let c=i.seen.length;check(`no GTK diagnostics (saw ${c})`,c===0);let l=JSON.stringify({...a.length>0?{failures:a}:{},diagnostics:c,...s});return print(`${r}: ${a.length>0?`FAIL`:`PASS`} ${l}`),+(a.length>0)}async function runHostProbeApp(e){if(probeEnabled())return t.init(),i.exit(runHostProbe(e,null));let r=new n.Application({application_id:e.applicationId});r.connect(`activate`,()=>{let t=runHostProbe(e,r);t!==0&&i.exit(t),e.present(e.build(r))}),await r.runAsync([])}export{probeEnabled,runHostProbe,runHostProbeApp};
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";import n from"gi://Adw?version=1";import r from"gi://Gtk?version=4.0";import i from"gi://Gdk?version=4.0";import a from"gi://Pango";const o=[[`Gtk`,r],[`Adw`,n],[`Gdk`,i],[`Pango`,a],[`G`,t]];function toPropertyName(e){return e.includes(`-`)?e:e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}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}}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}function defaultValue(e){return e.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,defaultValue,isConstructOnly,isWritable,paramSpecs,requireSpec,toPropertyName};
1
+ import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import t from"gi://GObject";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";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 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,isConstructOnly,isWritable,lookupEnumNick,paramSpecs,removedValue,requireSpec,toPropertyName,withoutKeys};
@@ -0,0 +1 @@
1
+ import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{jsxDEV as r}from"react/jsx-dev-runtime";const i=t,a=n,o=r;export{e as Fragment,i as jsx,o as jsxDEV,a as jsxs};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import t from"gi://GObject";const n=new Map;function registerWidget(e){n.set(e.gtype,e)}function registerWidgets(e){for(let t of e)registerWidget(t)}function lookupWidget(t){let r=n.get(t);if(!r)throw e.unknownTag(t);return r}const hasWidget=e=>n.has(e),registeredTags=()=>[...n.keys()].sort();function nearestRegistered(e){let r,i=-1;for(let a of n.values()){let n;try{n=a.ctor().$gtype}catch{continue}if(!t.type_is_a(e,n))continue;let o=depthOf(n);o>i&&(r=a,i=o)}return r}function depthOf(e){let n=0,r=e;for(;r;){let e=t.type_parent(r);if(!e)break;n+=1,r=e}return n}function clearRegistry(){n.clear()}export{clearRegistry,hasWidget,lookupWidget,nearestRegistered,registerWidget,registerWidgets,registeredTags};
1
+ import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";import{tagOf as t}from"./tags.js";import n from"gi://GObject";const r=new Map,i=new Map;function registerWidget(e){r.set(e.gtype,e);let n=t(e.gtype);n!==e.gtype&&i.set(n,e)}function registerWidgets(e){for(let t of e)registerWidget(t)}function lookupWidget(t){let n=r.get(t)??i.get(t);if(!n)throw e.unknownTag(t);return n}const hasWidget=e=>r.has(e)||i.has(e),registeredTags=()=>[...r.keys()].sort();function nearestRegistered(e){for(let t=e;t;t=n.type_parent(t)){let e=n.type_name(t);if(!e)break;let i=r.get(e);if(i)return i}}function clearRegistry(){r.clear(),i.clear()}export{clearRegistry,hasWidget,lookupWidget,nearestRegistered,registerWidget,registerWidgets,registeredTags};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";function toSignalName(e,t){if(t?.[e])return t[e];if(e.startsWith(`on:`))return e.slice(3);let n=e.slice(2);return n.startsWith(`Notify`)?`notify::${kebab(n.slice(6))}`:kebab(n)}const kebab=e=>e.replace(/^./,e=>e.toLowerCase()).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function isEventProp(e){return e.startsWith(`on:`)||e.length>2&&e.startsWith(`on`)&&e[2]===e[2].toUpperCase()&&e[2]!==e[2].toLowerCase()}let t=0;const beginHostWrite=()=>{t+=1},endHostWrite=()=>{--t},inHostWrite=()=>t>0;function setHandler(t,n,r){let i=toSignalName(n,t.descriptor.eventAliases),a=t.handlers.get(i),o=t.widget;if(a&&a.prop!==n&&r)throw e.signalTaken(t.descriptor.gtype,n,a.prop,i);if(a&&(o.disconnect(a.id),t.handlers.delete(i)),!r)return;let s=i.startsWith(`notify::`),c=o.connect(i,(...e)=>{if(!(s&&inHostWrite()))return r(...e.slice(1))});t.handlers.set(i,{id:c,prop:n})}function clearHandlers(e){if(!e.widget){e.handlers.clear();return}let t=e.widget;for(let{id:n}of e.handlers.values())t.disconnect(n);e.handlers.clear()}export{beginHostWrite,clearHandlers,endHostWrite,inHostWrite,isEventProp,setHandler,toSignalName};
1
+ import"./_virtual/_rolldown/runtime.js";import{err as e}from"./errors.js";const t=/(?:Once|Passive|Capture)$/;function parseEventProp(n,r){if(r?.[n])return{signal:r[n],once:!1};if(n.startsWith(`on:`))return{signal:n.slice(3),once:!1};let i=n.slice(2),a=!1;for(let r=t.exec(i);r;r=t.exec(i)){let t=r[0];if(t!==`Once`)throw e.eventModifier(n,t.toLowerCase());a=!0,i=i.slice(0,i.length-t.length)}return i===`Notify`?{signal:`notify`,once:a}:i.startsWith(`Notify`)?{signal:`notify::${kebab(i.slice(6))}`,once:a}:{signal:kebab(i),once:a}}const toSignalName=(e,t)=>parseEventProp(e,t).signal,kebab=e=>e.replace(/^./,e=>e.toLowerCase()).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function isEventProp(e){return e.startsWith(`on:`)||e.length>2&&e.startsWith(`on`)&&e[2]===e[2].toUpperCase()&&e[2]!==e[2].toLowerCase()}let n=0;const beginHostWrite=()=>{n+=1},endHostWrite=()=>{--n},inHostWrite=()=>n>0;function setHandler(t,n,r){let{signal:i,once:a}=parseEventProp(n,t.descriptor.eventAliases),o=t.handlers.get(i),s=t.widget;if(o&&o.prop!==n&&r)throw e.signalTaken(t.descriptor.gtype,n,o.prop,i);if(o&&(s.disconnect(o.id),t.handlers.delete(i)),!r)return;let c=i.startsWith(`notify::`),l=s.connect(i,(...e)=>{if(!(c&&inHostWrite()))return a&&t.handlers.get(i)?.id===l&&(s.disconnect(l),t.handlers.delete(i)),r(...e.slice(1))});t.handlers.set(i,{id:l,prop:n})}function clearHandlers(e){if(!e.widget){e.handlers.clear();return}let t=e.widget;for(let{id:n}of e.handlers.values())t.disconnect(n);e.handlers.clear()}export{beginHostWrite,clearHandlers,endHostWrite,inHostWrite,isEventProp,parseEventProp,setHandler,toSignalName};
@@ -0,0 +1,2 @@
1
+ import"./_virtual/_rolldown/runtime.js";function tagOf(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=n>0?e[n-1]:``,a=n+1<e.length?e[n+1]:``;r>=`A`&&r<=`Z`&&n>0&&(!(i>=`A`&&i<=`Z`)||a!==``&&a>=`a`&&a<=`z`)&&t.push(`-`),t.push(r.toLowerCase())}return t.join(``)}function assertInjective(e){let t=new Map,n=[];for(let r of e){let e=tagOf(r),i=t.get(e);i?n.push(`${e} <- ${i} and ${r}`):t.set(e,r)}if(n.length>0)throw Error(`tag map is not injective:\n ${n.join(`
2
+ `)}`)}export{assertInjective,tagOf};
File without changes
@@ -0,0 +1,175 @@
1
+ import type { ReactNode } from 'react';
2
+ import type Gtk from '@girs/gtk-4.0';
3
+ import { adopt, widgetOf } from '../host.js';
4
+ import type { HostElement, HostNode, HostText } from '../types.js';
5
+ /** What React hands `createInstance`: the vnode props, `children` included. */
6
+ export type ReactProps = Record<string, unknown>;
7
+ /** One authored property that changed: name, next value, previous value. */
8
+ type PropChange = readonly [key: string, next: unknown, prev: unknown];
9
+ /**
10
+ * The HostConfig, exported because it IS the contract.
11
+ *
12
+ * `react.spec.ts` builds a second reconciler over a Proxy of this object to read
13
+ * the member set the INSTALLED `react-reconciler` asks for, so a version that
14
+ * starts asking for something new fails a test instead of returning `undefined`
15
+ * in a commit. It is also the seam for a consumer who needs a differently
16
+ * configured reconciler (a `LegacyRoot`, a different event priority) without
17
+ * restating the mapping.
18
+ */
19
+ export declare const gtkHostConfig: {
20
+ supportsMutation: boolean;
21
+ supportsPersistence: boolean;
22
+ supportsHydration: boolean;
23
+ isPrimaryRenderer: boolean;
24
+ noTimeout: -1;
25
+ scheduleTimeout: typeof setTimeout;
26
+ cancelTimeout: typeof clearTimeout;
27
+ createInstance: (type: string, props: ReactProps) => HostElement;
28
+ createTextInstance: (text: string) => HostText;
29
+ appendInitialChild: (parent: HostElement, child: HostNode) => void;
30
+ finalizeInitialChildren: () => boolean;
31
+ /**
32
+ * `false`, always — one text path instead of two.
33
+ *
34
+ * `true` would tell React to skip text instances for this element and leave
35
+ * the string in `props.children` for the adapter to write. The host already
36
+ * owns that translation: a text NODE is concatenated into the descriptor's
37
+ * `textSink`, and a widget without one refuses text BY TAG NAME. Answering
38
+ * `true` would move that decision into the adapter, where it would be a
39
+ * widget-knowledge test — the one thing ADR 0027 § 7 forbids an adapter.
40
+ *
41
+ * It also keeps `resetTextContent` unreachable: React sets the `ContentReset`
42
+ * flag only when `shouldSetTextContent` was true for the PREVIOUS props.
43
+ */
44
+ shouldSetTextContent: () => boolean;
45
+ getRootHostContext: () => null;
46
+ getChildHostContext: (parentHostContext: null) => null;
47
+ /**
48
+ * What a `ref` receives — the author's widget, never the host's wrapper.
49
+ *
50
+ * `<GtkListBox><GtkButton ref={…}/>` puts the button inside a
51
+ * `GtkListBoxRow` the host created. Handing that row back would give the
52
+ * author a widget they never wrote and whose `label` write does nothing.
53
+ */
54
+ getPublicInstance: (instance: HostElement) => Gtk.Widget;
55
+ prepareForCommit: () => null;
56
+ resetAfterCommit: () => void;
57
+ preparePortalMount: () => void;
58
+ /**
59
+ * The priority every update outside React's own event system gets.
60
+ *
61
+ * React DOM derives this from the DOM event being handled (a click is
62
+ * discrete, a scroll continuous). A GTK signal handler is not a DOM event and
63
+ * there is no ambient event to read, so every update is a default-lane one —
64
+ * the same answer `react-art` and `react-nil` give. Consequence, stated
65
+ * because it is load-bearing: a `setState` from a GTK handler is CONCURRENT,
66
+ * so it lands when `scheduler` next runs, i.e. on the next GLib main-loop
67
+ * iteration. `flushSync` is the escape hatch, and the spec pumps the main
68
+ * context to prove the scheduled path works at all under GJS.
69
+ */
70
+ getCurrentEventPriority: () => number;
71
+ appendChild: (parent: HostElement, child: HostNode) => void;
72
+ appendChildToContainer: (container: HostElement, child: HostNode) => void;
73
+ insertBefore: (parent: HostElement, child: HostNode, before: HostNode) => void;
74
+ insertInContainerBefore: (container: HostElement, child: HostNode, before: HostNode) => void;
75
+ removeChild: (_parent: HostElement, child: HostNode) => void;
76
+ removeChildFromContainer: (_container: HostElement, child: HostNode) => void;
77
+ /**
78
+ * React clears the root before its FIRST commit — and the application's own
79
+ * chrome must survive it.
80
+ *
81
+ * `updateHostRoot` sets the `Snapshot` flag whenever the previous render
82
+ * produced no child, and `commitBeforeMutationEffects` then calls this on the
83
+ * container. In the DOM that discards leftover markup. Here the container is a
84
+ * widget the application built and filled, so this clears what the HOST put
85
+ * there (the shadow children) and never `el.foreign`, which `adopt` recorded
86
+ * precisely so placement can offset past it.
87
+ *
88
+ * `destroy` rather than `remove`, for the same reason `removeChild` uses it:
89
+ * GJS blocks JS callbacks during GC, so a detached node keeps its handlers
90
+ * for the life of the process.
91
+ */
92
+ clearContainer: (container: HostElement) => void;
93
+ prepareUpdate: (_instance: HostElement, _type: string, oldProps: ReactProps, newProps: ReactProps) => PropChange[] | null;
94
+ commitUpdate: (instance: HostElement, updatePayload: PropChange[]) => void;
95
+ commitTextUpdate: (textInstance: HostText, _oldText: string, newText: string) => void;
96
+ commitMount: () => void;
97
+ resetTextContent: (instance: HostElement) => void;
98
+ hideInstance: (instance: HostElement) => void;
99
+ unhideInstance: (instance: HostElement) => void;
100
+ /**
101
+ * A text run owns no widget, so hiding it means emptying what it contributes.
102
+ *
103
+ * The parent's text sink is a concatenation of its text children, so writing
104
+ * `''` removes exactly this run and leaves its siblings. Nothing has to be
105
+ * remembered: React hands the text back to `unhideTextInstance` as the fiber's
106
+ * own `memoizedProps`.
107
+ */
108
+ hideTextInstance: (textInstance: HostText) => void;
109
+ unhideTextInstance: (textInstance: HostText, text: string) => void;
110
+ getInstanceFromNode: () => null;
111
+ getInstanceFromScope: () => null;
112
+ prepareScopeUpdate: () => void;
113
+ beforeActiveInstanceBlur: () => void;
114
+ afterActiveInstanceBlur: () => void;
115
+ detachDeletedInstance: () => void;
116
+ };
117
+ export type GtkHostConfig = typeof gtkHostConfig;
118
+ /**
119
+ * Run `fn` and flush every update it schedules before returning.
120
+ *
121
+ * The default lane is concurrent (see `getCurrentEventPriority`), so a `setState`
122
+ * from a GTK signal handler lands on a later main-loop iteration. In an
123
+ * application that is right — GTK is running a main loop. Outside one, and in a
124
+ * test, this is how a change becomes visible without pumping.
125
+ */
126
+ export declare const flushSync: <T>(fn: () => T) => T;
127
+ export interface ReactRoot {
128
+ /** Render (or re-render) this tree. Synchronous — the widgets exist on return. */
129
+ render(element: ReactNode): void;
130
+ /** Unmount the tree, tearing every widget and handler down. */
131
+ unmount(): void;
132
+ /** The host element wrapping the application's container. */
133
+ readonly container: HostElement;
134
+ }
135
+ export interface ReactRootOptions {
136
+ /**
137
+ * What to do with an error React RECOVERED from — a render an error boundary
138
+ * caught and retried, or a commit that had to fall back.
139
+ *
140
+ * The default is `console.error`, which is what `react-dom` does
141
+ * (`reportError`, absent under GJS). Rethrowing is deliberately NOT the
142
+ * default: React calls this from inside the commit, so a throw would break
143
+ * the error boundary that just did its job. A test passes its own recorder
144
+ * and asserts nothing arrived.
145
+ */
146
+ onRecoverableError?(error: Error): void;
147
+ }
148
+ /**
149
+ * A React root over a widget the application owns.
150
+ *
151
+ * `adopt` is the bridge every adapter needs: React's `createContainer` wants a
152
+ * container of the renderer's own type and an application has a `Gtk.Widget`. It
153
+ * also records what the container already held, so the tree renders AFTER the
154
+ * application's own chrome instead of above it.
155
+ *
156
+ * `render` flushes synchronously. React's own `createRoot().render()` does not,
157
+ * and the reason to differ is measured rather than stylistic: without a GLib main
158
+ * loop nothing drives `scheduler`, so an unflushed first render leaves the
159
+ * container empty with no error — the silent-empty-window failure this package
160
+ * exists to refuse. An application that wants concurrent behaviour has
161
+ * `reconciler`-level control through `gtkHostConfig`.
162
+ */
163
+ export declare function createRoot(container: Gtk.Widget, options?: ReactRootOptions): ReactRoot;
164
+ /** `createRoot(container).render(element)`, for the common case. */
165
+ export declare function mount(element: ReactNode, container: Gtk.Widget, options?: ReactRootOptions): ReactRoot;
166
+ /**
167
+ * Re-exported, not re-implemented: the Solid adapter carried the SAME function and
168
+ * Vue carried none. It is a host op now, with coded errors instead of bare ones.
169
+ */
170
+ export { widgetOf };
171
+ /**
172
+ * Re-exported because a React app mounting into a second, hand-held container
173
+ * needs it and importing the host separately is a second module for one function.
174
+ */
175
+ export { adopt };
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,78 @@
1
+ import type Gtk from '@girs/gtk-4.0';
2
+ import { widgetOf } from '../host.js';
3
+ import type { HostNode } from '../types.js';
4
+ export declare const render: (code: () => HostNode, node: HostNode) => () => void, effect: <T>(fn: (prev?: T) => T, init?: T) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, createComponent: <T>(Comp: (props: T) => HostNode, props: T) => HostNode, createElement: (tag: string) => HostNode, createTextNode: (value: string) => HostNode, insertNode: (parent: HostNode, node: HostNode, anchor?: HostNode) => void, insert: <T>(parent: any, accessor: T | (() => T), marker?: any | null, initial?: any) => HostNode, spread: <T>(node: any, accessor: (() => T) | T, skipChildren?: boolean) => void, setProp: <T>(node: HostNode, name: string, value: T, prev?: T) => T, mergeProps: (...sources: unknown[]) => unknown, use: <A, T>(fn: (element: HostNode, arg: A) => T, element: HostNode, arg: A) => T;
5
+ /**
6
+ * Render a Solid component into a widget the application owns.
7
+ *
8
+ * `render` wants a host node as its container; an application has a `Gtk.Widget`.
9
+ * `adopt` bridges that through the same descriptor table every other parent uses,
10
+ * so a `GObject.registerClass` subclass of a known container works unchanged.
11
+ *
12
+ * Returns Solid's disposer. Calling it unmounts the tree — and because the host's
13
+ * `destroy` is eager (GJS blocks JS callbacks during GC), that is also what
14
+ * disconnects the signal handlers.
15
+ */
16
+ export declare function mount(code: () => HostNode, container: Gtk.Widget): () => void;
17
+ /** `<For each={items}>` — keyed by item identity, so a reorder MOVES nodes. */
18
+ export declare const For: <T>(props: {
19
+ each: readonly T[] | undefined | null | false;
20
+ fallback?: HostNode;
21
+ children: (item: T, index: () => number) => HostNode;
22
+ }) => HostNode;
23
+ /** `<Index each={items}>` — keyed by position; the item is an accessor. */
24
+ export declare const Index: <T>(props: {
25
+ each: readonly T[] | undefined | null | false;
26
+ fallback?: HostNode;
27
+ children: (item: () => T, index: number) => HostNode;
28
+ }) => HostNode;
29
+ /**
30
+ * `<Show when={cond}>` — a conditional branch.
31
+ *
32
+ * The child function receives an ACCESSOR, not the value: Solid's runtime passes
33
+ * `keyed ? c : () => …`, so without `keyed` a `(item) => item.name` reads `.name`
34
+ * off a function and renders the function's own name — no type error, no runtime
35
+ * error, wrong string on screen. `keyed: true` opts into the value.
36
+ */
37
+ export declare const Show: {
38
+ <T>(props: {
39
+ when: T | undefined | null | false;
40
+ keyed: true;
41
+ fallback?: HostNode;
42
+ children: HostNode | ((item: NonNullable<T>) => HostNode);
43
+ }): HostNode;
44
+ <T>(props: {
45
+ when: T | undefined | null | false;
46
+ keyed?: false;
47
+ fallback?: HostNode;
48
+ children: HostNode | ((item: () => NonNullable<T>) => HostNode);
49
+ }): HostNode;
50
+ };
51
+ /**
52
+ * `<Dynamic component={…}>` — the one control-flow component Solid does NOT ship
53
+ * renderer-agnostically.
54
+ *
55
+ * `For`, `Index` and `Show` live in `solid-js` and reconcile whatever their
56
+ * children return, so this adapter only re-types them. `Dynamic` lives in
57
+ * `solid-js/web`, and that package IS the DOM renderer: its string branch is
58
+ * `document.createElement(component)` followed by the DOM's `spread`. Under a
59
+ * universal renderer it therefore produces a DOM element nobody here can place —
60
+ * measured as `container: ["GtkBox"]`, box children `[]`, no throw, no
61
+ * diagnostic, exit 0. Re-implementing it over the host ops is four lines and it
62
+ * is the only honest alternative to that silence.
63
+ *
64
+ * A `component` that is neither a tag nor a function is REFUSED, where Solid's
65
+ * own `switch` falls through and returns undefined: `component={registry[key]}`
66
+ * with a key that missed is the single most common way to render nothing by
67
+ * accident, and rendering nothing on purpose is `<Show>`'s job.
68
+ */
69
+ export declare function Dynamic<P extends Record<string, unknown>>(props: P & {
70
+ component: string | ((props: P) => HostNode);
71
+ }): HostNode;
72
+ /**
73
+ * Re-exported, not re-implemented: this and the React adapter carried the SAME
74
+ * function, and Vue carried none — so a Vue app had no supported way to reach a
75
+ * widget at all. It is a host op now (`../host.js`), and its two refusals are
76
+ * coded errors rather than the bare `new Error` they used to be.
77
+ */
78
+ export { widgetOf };
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import type Gtk from '@girs/gtk-4.0';
2
+ import { adopt, widgetOf } from '../host.js';
3
+ import type { HostElement } from '../types.js';
4
+ export declare const render: import("@vue/runtime-core").RootRenderFunction<HostElement>, createApp: import("@vue/runtime-core").CreateAppFunction<HostElement>;
5
+ /**
6
+ * Re-exported because a Vue app needs it and importing the host separately is a
7
+ * second module for one function: `<Teleport :to="adopt(el)">` is the explicit
8
+ * spelling of what `insert` now does implicitly, and it is the one to reach for
9
+ * when the same target is also addressed by hand.
10
+ *
11
+ * `widgetOf` for the same reason — and it is NEW here, not moved: Solid and React
12
+ * each carried their own copy and this adapter carried none, so a Vue app's only
13
+ * route to a widget was `materialize()`, the very call `widgetOf`'s destroyed-node
14
+ * refusal exists to intercept.
15
+ */
16
+ export { adopt, widgetOf };
17
+ /**
18
+ * Mount a Vue app into a widget the application owns.
19
+ *
20
+ * `createApp(...).mount(container)` wants a host element; an application has a
21
+ * `Gtk.Widget`. `adopt` bridges that and records what the container already held,
22
+ * so the app renders AFTER the application's own chrome rather than above it.
23
+ */
24
+ export declare function mount(rootComponent: Parameters<typeof createApp>[0], container: Gtk.Widget): import("@vue/runtime-core").App<HostElement>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,102 @@
1
+ import type GObject from '@girs/gobject-2.0';
2
+ import type { HostNode } from './types.js';
3
+ /**
4
+ * A `notify::` handler.
5
+ *
6
+ * The host strips the emitting object (`next(...args.slice(1))` in `signals.ts`),
7
+ * so what reaches the callback is the ParamSpec alone. Declared HERE rather than in
8
+ * the generated file because it is the same for every property in GTK — and because
9
+ * a generator that emitted it would have to import GObject for a type that has
10
+ * nothing to do with the GIR it read.
11
+ */
12
+ export type NotifyHandler = (pspec: GObject.ParamSpec) => void;
13
+ declare const outParam: unique symbol;
14
+ /**
15
+ * A signal parameter GIR declares `out`/`inout` with `caller-allocates="0"`.
16
+ *
17
+ * GJS still passes an argument in that position, and what it holds is whatever
18
+ * was in the memory the marshaller allocated: measured on gjs 1.88.1 / GTK
19
+ * 4.22.4, a handler on `Gtk.SpinButton::input` receives `new_value` as
20
+ * `6.9526682391035e-310`, and one on `Gtk.Editable::insert-text` receives
21
+ * `position` as `1711500784`. Both arrive as ordinary numbers. Nothing warns.
22
+ *
23
+ * So the slot is DECLARED — dropping it would silently shift every parameter
24
+ * after it — and given a type nothing can be read out of, and nothing but
25
+ * itself assigns to. Annotating the parameter `number` is then a compile error
26
+ * naming the position, which is the only place a reader would have looked.
27
+ *
28
+ * `caller-allocates="1"` is a different thing and keeps its real type: there the
29
+ * callee is handed a live object to FILL, as `Gtk.Overlay::get-child-position`
30
+ * is handed a `Gdk.Rectangle`.
31
+ */
32
+ export type OutParam = {
33
+ readonly [outParam]: never;
34
+ };
35
+ /**
36
+ * What may appear as a child, mirroring Solid's own `JSX.Element`.
37
+ *
38
+ * The shape is copied from `solid-js/types/jsx.d.ts` because a renderer's element
39
+ * union is not a free choice: a string, a number and a boolean are all legal
40
+ * children there, an array of children is legal recursively, and a FUNCTION is
41
+ * not. Substituting our host node for the DOM's `Node` is the only change.
42
+ */
43
+ export type ElementChild = HostNode | ElementChildren | string | number | boolean | null | undefined;
44
+ export interface ElementChildren extends Array<ElementChild> {
45
+ }
46
+ /**
47
+ * Add the `.once` spelling of every event prop, without generating 2× the members.
48
+ *
49
+ * `signals.ts` accepts `onClickedOnce` for every `onClicked`, including every
50
+ * `onNotifyFooOnce`, which would be another ~1000 generated members. A mapped type
51
+ * derives them from the interface instead — including the ones a consumer adds by
52
+ * declaration merging.
53
+ */
54
+ export type WithOnce<T> = T & {
55
+ [K in keyof T & string as K extends `on${string}` ? `${K}Once` : never]?: T[K];
56
+ };
57
+ /** Which of a container's slots this child goes into. Read by `setSlot()`. */
58
+ export interface SlotAttribute {
59
+ slot?: string | null;
60
+ }
61
+ /**
62
+ * The `on:<raw-signal-name>` escape hatch, typed.
63
+ *
64
+ * `parseEventProp` takes `on:` + a signal name verbatim, which is how a signal
65
+ * whose name resists the camelCase derivation gets bound at all. The handler type
66
+ * is deliberately the widest one that is not `any`: parameters of `never` accept
67
+ * a handler declared with any parameters, so nothing a consumer writes is refused.
68
+ * An inline arrow's parameter arrives as `never` here, which is the price of an
69
+ * escape hatch that carries no signal-specific knowledge.
70
+ */
71
+ export interface RawSignalAttributes {
72
+ [key: `on:${string}`]: ((...args: never[]) => unknown) | undefined;
73
+ }
74
+ /**
75
+ * Per-element attributes a JSX dialect needs on top of the GObject properties.
76
+ *
77
+ * `ref` and `children` MUST be real members of the element's own props. Measured:
78
+ * TypeScript unions `JSX.IntrinsicAttributes` into the attributes of a COMPONENT
79
+ * and not of an intrinsic element, so a `ref` that is not declared here is
80
+ * rejected outright (TS2322) — and `children` that is not declared makes every
81
+ * nested element an error (TS2559). `children` must also be OPTIONAL: a required
82
+ * one makes `<gtk-box/>` an error (TS2741).
83
+ *
84
+ * `T` is the widget's own instance type, so `ref={(el) => …}` infers `el` as
85
+ * `Gtk.Box` rather than the `unknown` a DOM renderer settles for.
86
+ */
87
+ export interface JsxAttributes<T> extends SlotAttribute, RawSignalAttributes {
88
+ children?: ElementChild;
89
+ ref?: T | ((el: T) => void) | undefined;
90
+ }
91
+ /**
92
+ * Per-element attributes for Vue.
93
+ *
94
+ * Deliberately NOT `JsxAttributes`: Vue supplies `ref` and `key` itself through
95
+ * `VNodeProps`, which every registered component's props are intersected with.
96
+ * Declaring our own `ref` would intersect two different `ref` types and could
97
+ * leave the property unusable, so the Vue surface adds only what Vue does not —
98
+ * and `children` is a SLOT in Vue, never a prop.
99
+ */
100
+ export interface VueAttributes extends SlotAttribute, RawSignalAttributes {
101
+ }
102
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -14,4 +14,18 @@ export interface DiagnosticsGate {
14
14
  * what GLib's default writer does with `G_MESSAGES_DEBUG` unset: message-and-above
15
15
  * is printed, info/debug is not.
16
16
  */
17
+ /**
18
+ * What a log record SAYS — and never the empty string.
19
+ *
20
+ * `MESSAGE` is a structured field like any other, and a record is allowed to
21
+ * arrive without one. The first version answered `String(raw ?? '')`, so such a
22
+ * record was counted and then described as nothing: a CI run failed with
23
+ * `GTK reported 1 diagnostic(s) that would have passed at exit 0:` followed by a
24
+ * BLANK LIST, over a test that had just constructed 164 widgets. A gate that can
25
+ * count a failure but not name it sends the reader back to guessing, which is the
26
+ * state this whole module exists to end.
27
+ *
28
+ * So a record with no `MESSAGE` is rendered from the fields it does carry.
29
+ */
30
+ export declare function describeLogRecord(fields: unknown, decoder?: TextDecoder): string;
17
31
  export declare function installDiagnosticsGate(): DiagnosticsGate;
@@ -1,4 +1,4 @@
1
- export { installDiagnosticsGate, type DiagnosticsGate } from './diagnostics.js';
1
+ export { describeLogRecord, installDiagnosticsGate, type DiagnosticsGate } from './diagnostics.js';
2
2
  import type Gtk from '@girs/gtk-4.0';
3
3
  import type { ChildPolicy, HostElement, WidgetDescriptor } from '../types.js';
4
4
  /** Every method name a policy names, so the check does not have to know the shapes. */
@@ -22,5 +22,28 @@ export declare function gtkChildren(widget: Gtk.Widget): Gtk.Widget[];
22
22
  export declare const gtkChildTypes: (widget: Gtk.Widget) => string[];
23
23
  /** The addresses a host element's element-children occupy, in shadow order. */
24
24
  export declare function addressesOf(el: HostElement): Gtk.Widget[];
25
+ /**
26
+ * First STRICT descendant matching `pred`, breadth-first over the REAL GTK tree.
27
+ *
28
+ * Both showcase probes wrote this, identically. It excludes the root on purpose:
29
+ * every caller is asking "what did the renderer put INSIDE this", and a root that
30
+ * matches its own predicate answers a different question.
31
+ *
32
+ * Breadth-first is not incidental either — `findDescendant(root, w => w instanceof
33
+ * Gtk.Box)` on an Adwaita window finds an INTERNAL box of the header bar before
34
+ * anything the author wrote, which is why a probe that needs a specific widget
35
+ * reaches it through a landmark (a button's `get_parent()`) rather than by type.
36
+ * Measured: with a search-by-type version, authoring `orientation="horizontal"`
37
+ * still printed PROBE: PASS with byte-identical output.
38
+ */
39
+ export declare function findDescendant(root: Gtk.Widget, pred: (widget: Gtk.Widget) => boolean): Gtk.Widget | null;
40
+ /**
41
+ * Every widget in a subtree, ROOT FIRST and depth-first — GTK's own document order.
42
+ *
43
+ * Depth-first and not breadth-first, because the callers that collect (rather than
44
+ * search) are asserting on ORDER: "the rows land before the counter row" is only a
45
+ * claim about the tree if the walk visits it the way the tree reads.
46
+ */
47
+ export declare function descendants(root: Gtk.Widget): Gtk.Widget[];
25
48
  /** Recursive GType dump — what a devtools tree walk would show. */
26
49
  export declare function dumpTree(widget: Gtk.Widget, depth?: number): string;
@@ -0,0 +1,34 @@
1
+ import Gtk from 'gi://Gtk?version=4.0';
2
+ import type { DiagnosticsGate } from './diagnostics.js';
3
+ /** A tree in the one shape all three adapters can build: tag, props, children. */
4
+ export interface VectorElement {
5
+ readonly tag: string;
6
+ readonly props?: Record<string, unknown>;
7
+ /** A string child is a TEXT NODE — never a bulk `setElementText` write. */
8
+ readonly children?: readonly VectorNode[];
9
+ }
10
+ export type VectorNode = string | VectorElement;
11
+ /** `h('GtkBox', { spacing: 6 }, h('GtkLabel', null, 'hi'))`. */
12
+ export declare const h: (tag: string, props?: Record<string, unknown> | null, ...children: VectorNode[]) => VectorElement;
13
+ export interface VectorMount {
14
+ /**
15
+ * Re-render the SAME tree shape with new props and new text, flushed — Vue's
16
+ * `nextTick`, React's `flushSync`, Solid's synchronous effects.
17
+ */
18
+ patch(tree: VectorElement): Promise<void>;
19
+ unmount(): void;
20
+ }
21
+ export interface VectorHarness {
22
+ /** Names the describe block, so a failure says which adapter. */
23
+ readonly framework: string;
24
+ /** Mount `tree` into a container the application owns, flushed on return. */
25
+ mount(container: Gtk.Widget, tree: VectorElement): Promise<VectorMount>;
26
+ }
27
+ /**
28
+ * Every vector, against one adapter.
29
+ *
30
+ * `gated` rather than a bare `describe`: `@gjsify/unit` keeps ONE
31
+ * `beforeEach`/`afterEach` slot per module and nulls both when a describe returns,
32
+ * so hooks registered outside the block cover exactly one sibling.
33
+ */
34
+ export declare function runAdapterVectors(harness: VectorHarness, gate: DiagnosticsGate): Promise<void>;