@gtkx/react 1.0.0-rc.2 → 1.0.0-rc.4

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 (173) hide show
  1. package/README.md +4 -5
  2. package/dist/adw/config.d.ts +1 -0
  3. package/dist/adw/config.d.ts.map +1 -1
  4. package/dist/adw/config.js +1 -0
  5. package/dist/adw/config.js.map +1 -1
  6. package/dist/adw/dialog.d.ts +1 -0
  7. package/dist/adw/dialog.d.ts.map +1 -1
  8. package/dist/adw/dialog.js +1 -0
  9. package/dist/adw/dialog.js.map +1 -1
  10. package/dist/adw/element-behaviors.js +8 -39
  11. package/dist/adw/element-behaviors.js.map +1 -1
  12. package/dist/adw/element-config.d.ts +7 -4
  13. package/dist/adw/element-config.d.ts.map +1 -1
  14. package/dist/adw/element-config.js +32 -41
  15. package/dist/adw/element-config.js.map +1 -1
  16. package/dist/adw/index.d.ts +1 -0
  17. package/dist/adw/index.d.ts.map +1 -1
  18. package/dist/adw/index.js +1 -0
  19. package/dist/adw/index.js.map +1 -1
  20. package/dist/adw/prop-types.d.ts +1 -1
  21. package/dist/adw/prop-types.d.ts.map +1 -1
  22. package/dist/adw/prop-types.js.map +1 -1
  23. package/dist/bootstrap.js +1 -1
  24. package/dist/bootstrap.js.map +1 -1
  25. package/dist/components/application.d.ts +1 -0
  26. package/dist/components/application.d.ts.map +1 -1
  27. package/dist/components/application.js +1 -0
  28. package/dist/components/application.js.map +1 -1
  29. package/dist/components/element.d.ts +0 -1
  30. package/dist/components/element.d.ts.map +1 -1
  31. package/dist/components/element.js +0 -1
  32. package/dist/components/element.js.map +1 -1
  33. package/dist/components/window.d.ts +1 -0
  34. package/dist/components/window.d.ts.map +1 -1
  35. package/dist/components/window.js +14 -2
  36. package/dist/components/window.js.map +1 -1
  37. package/dist/config.d.ts +5 -2
  38. package/dist/config.d.ts.map +1 -1
  39. package/dist/config.js +3 -1
  40. package/dist/config.js.map +1 -1
  41. package/dist/element-behaviors.js +0 -1
  42. package/dist/element-behaviors.js.map +1 -1
  43. package/dist/element-config.d.ts +4 -3
  44. package/dist/element-config.d.ts.map +1 -1
  45. package/dist/element-config.js +12 -8
  46. package/dist/element-config.js.map +1 -1
  47. package/dist/hooks/use-bind-setting.d.ts +8 -7
  48. package/dist/hooks/use-bind-setting.d.ts.map +1 -1
  49. package/dist/hooks/use-bind-setting.js +2 -7
  50. package/dist/hooks/use-bind-setting.js.map +1 -1
  51. package/dist/hooks/use-parent-window.d.ts +3 -1
  52. package/dist/hooks/use-parent-window.d.ts.map +1 -1
  53. package/dist/hooks/use-parent-window.js +3 -1
  54. package/dist/hooks/use-parent-window.js.map +1 -1
  55. package/dist/hooks/use-property.d.ts +2 -2
  56. package/dist/hooks/use-property.d.ts.map +1 -1
  57. package/dist/hooks/use-property.js +1 -2
  58. package/dist/hooks/use-property.js.map +1 -1
  59. package/dist/hooks/use-setting.d.ts +2 -3
  60. package/dist/hooks/use-setting.d.ts.map +1 -1
  61. package/dist/hooks/use-setting.js +2 -3
  62. package/dist/hooks/use-setting.js.map +1 -1
  63. package/dist/hooks/use-signal.d.ts +17 -7
  64. package/dist/hooks/use-signal.d.ts.map +1 -1
  65. package/dist/hooks/use-signal.js +10 -8
  66. package/dist/hooks/use-signal.js.map +1 -1
  67. package/dist/index.d.ts +10 -2
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +8 -0
  70. package/dist/index.js.map +1 -1
  71. package/dist/internal.d.ts +5 -3
  72. package/dist/internal.d.ts.map +1 -1
  73. package/dist/internal.js +3 -3
  74. package/dist/internal.js.map +1 -1
  75. package/dist/prop-types.d.ts +60 -0
  76. package/dist/prop-types.d.ts.map +1 -1
  77. package/dist/prop-types.js.map +1 -1
  78. package/dist/reconciler/apply-props.d.ts.map +1 -1
  79. package/dist/reconciler/apply-props.js +12 -6
  80. package/dist/reconciler/apply-props.js.map +1 -1
  81. package/dist/reconciler/behaviors.d.ts +0 -15
  82. package/dist/reconciler/behaviors.d.ts.map +1 -1
  83. package/dist/reconciler/behaviors.js +12 -22
  84. package/dist/reconciler/behaviors.js.map +1 -1
  85. package/dist/reconciler/host-config.d.ts +1 -1
  86. package/dist/reconciler/host-config.d.ts.map +1 -1
  87. package/dist/reconciler/host-config.js +2 -6
  88. package/dist/reconciler/host-config.js.map +1 -1
  89. package/dist/reconciler/instance.js +1 -1
  90. package/dist/reconciler/instance.js.map +1 -1
  91. package/dist/reconciler/metadata.d.ts +1 -1
  92. package/dist/reconciler/metadata.d.ts.map +1 -1
  93. package/dist/reconciler/metadata.js +7 -7
  94. package/dist/reconciler/metadata.js.map +1 -1
  95. package/dist/reconciler/node.d.ts +2 -2
  96. package/dist/reconciler/node.d.ts.map +1 -1
  97. package/dist/reconciler/node.js +1 -1
  98. package/dist/reconciler/node.js.map +1 -1
  99. package/dist/reconciler/placement.d.ts.map +1 -1
  100. package/dist/reconciler/placement.js +28 -12
  101. package/dist/reconciler/placement.js.map +1 -1
  102. package/dist/reconciler/registry.d.ts +56 -29
  103. package/dist/reconciler/registry.d.ts.map +1 -1
  104. package/dist/reconciler/registry.js +27 -26
  105. package/dist/reconciler/registry.js.map +1 -1
  106. package/dist/reconciler/root-element.d.ts +0 -1
  107. package/dist/reconciler/root-element.d.ts.map +1 -1
  108. package/dist/reconciler/root-element.js +0 -1
  109. package/dist/reconciler/root-element.js.map +1 -1
  110. package/dist/reconciler/root.d.ts +8 -22
  111. package/dist/reconciler/root.d.ts.map +1 -1
  112. package/dist/reconciler/root.js +5 -23
  113. package/dist/reconciler/root.js.map +1 -1
  114. package/dist/reconciler/signals.d.ts +3 -4
  115. package/dist/reconciler/signals.d.ts.map +1 -1
  116. package/dist/reconciler/signals.js +14 -26
  117. package/dist/reconciler/signals.js.map +1 -1
  118. package/dist/reconciler/text.d.ts.map +1 -1
  119. package/dist/reconciler/text.js +18 -13
  120. package/dist/reconciler/text.js.map +1 -1
  121. package/dist/utils/accessible-metadata.d.ts +0 -7
  122. package/dist/utils/accessible-metadata.d.ts.map +1 -1
  123. package/dist/utils/accessible-metadata.js +0 -7
  124. package/dist/utils/accessible-metadata.js.map +1 -1
  125. package/dist/utils/accessible-props.d.ts +49 -1
  126. package/dist/utils/accessible-props.d.ts.map +1 -1
  127. package/dist/utils/accessible-props.js.map +1 -1
  128. package/dist/utils/ref-prop.d.ts +0 -6
  129. package/dist/utils/ref-prop.d.ts.map +1 -1
  130. package/dist/utils/ref-prop.js +0 -6
  131. package/dist/utils/ref-prop.js.map +1 -1
  132. package/dist/utils/settings.d.ts +6 -0
  133. package/dist/utils/settings.d.ts.map +1 -1
  134. package/dist/utils/settings.js.map +1 -1
  135. package/env.d.ts +11 -4
  136. package/package.json +5 -5
  137. package/src/adw/config.ts +1 -0
  138. package/src/adw/dialog.tsx +1 -0
  139. package/src/adw/element-behaviors.ts +8 -39
  140. package/src/adw/element-config.ts +33 -41
  141. package/src/adw/index.ts +1 -0
  142. package/src/adw/prop-types.ts +1 -1
  143. package/src/bootstrap.ts +1 -1
  144. package/src/components/application.tsx +1 -0
  145. package/src/components/element.tsx +0 -1
  146. package/src/components/window.tsx +16 -2
  147. package/src/config.ts +5 -2
  148. package/src/element-behaviors.ts +0 -1
  149. package/src/element-config.ts +12 -8
  150. package/src/hooks/use-bind-setting.ts +8 -7
  151. package/src/hooks/use-parent-window.ts +3 -1
  152. package/src/hooks/use-property.ts +2 -2
  153. package/src/hooks/use-setting.ts +2 -3
  154. package/src/hooks/use-signal.ts +20 -10
  155. package/src/index.ts +10 -2
  156. package/src/internal.ts +5 -3
  157. package/src/prop-types.ts +86 -5
  158. package/src/reconciler/apply-props.ts +12 -6
  159. package/src/reconciler/behaviors.ts +14 -23
  160. package/src/reconciler/host-config.ts +3 -8
  161. package/src/reconciler/instance.ts +1 -1
  162. package/src/reconciler/metadata.ts +8 -8
  163. package/src/reconciler/node.ts +3 -3
  164. package/src/reconciler/placement.ts +33 -13
  165. package/src/reconciler/registry.ts +70 -41
  166. package/src/reconciler/root-element.ts +0 -1
  167. package/src/reconciler/root.ts +9 -26
  168. package/src/reconciler/signals.ts +16 -37
  169. package/src/reconciler/text.ts +21 -14
  170. package/src/utils/accessible-metadata.ts +0 -7
  171. package/src/utils/accessible-props.ts +49 -1
  172. package/src/utils/ref-prop.ts +0 -6
  173. package/src/utils/settings.ts +6 -0
@@ -4,13 +4,14 @@ import { getOrInsert, indexBeforeOrEnd, remove } from "@gtkx/utils";
4
4
  import { applyAdoptedProps, markFlush } from "./apply-props.js";
5
5
  import { typeInfoFor } from "./metadata.js";
6
6
  import { DEFAULT_SLOT, ELEMENT_KIND, getOrCreateContext, LAZY_KIND, lazyTarget, nodeObject, } from "./node.js";
7
+ import { applyWrite } from "./signals.js";
7
8
  import { markTextDirty } from "./text.js";
8
9
  const createEntry = (slot, node) => {
9
10
  const object = nodeObject(node);
10
11
  if (object === null) {
11
12
  return null;
12
13
  }
13
- return { node, object, adopted: null, slot, behavior: null, attached: false };
14
+ return { node, object, adopted: null, slot, behavior: null, isAttached: false };
14
15
  };
15
16
  const siblingAt = (entries, index) => index > 0 ? (entries[index - 1]?.object ?? null) : null;
16
17
  const placeInfo = (entry, index, sibling, context) => ({
@@ -42,11 +43,16 @@ const wireBufferView = (node, parent) => {
42
43
  node.bufferView = parent.object;
43
44
  markTextDirty(node);
44
45
  };
46
+ const writeSlot = (parent, entry, value) => {
47
+ applyWrite(() => {
48
+ Reflect.set(parent.object, entry.slot, value);
49
+ });
50
+ };
45
51
  const setObjectSlot = (parent, entry) => {
46
- Reflect.set(parent.object, entry.slot, entry.object);
52
+ writeSlot(parent, entry, entry.object);
47
53
  wireBufferView(entry.node, parent);
48
54
  entry.behavior = null;
49
- entry.attached = true;
55
+ entry.isAttached = true;
50
56
  };
51
57
  const didAttach = (ctx, behavior) => {
52
58
  const attach = behavior.attach;
@@ -60,11 +66,11 @@ const didAttach = (ctx, behavior) => {
60
66
  }
61
67
  ctx.entry.behavior = behavior;
62
68
  adoptedFrom(ctx.parent, ctx.entry, behavior, claim);
63
- ctx.entry.attached = true;
69
+ ctx.entry.isAttached = true;
64
70
  applyLazyProps(ctx.entry);
65
71
  return true;
66
72
  };
67
- const attachEntry = (parent, entry, index, sibling) => {
73
+ const runAttach = (parent, entry, index, sibling) => {
68
74
  const ctx = { parent, entry, index, sibling };
69
75
  for (const behavior of typeInfoFor(parent.typeName).behaviors) {
70
76
  if (didAttach(ctx, behavior)) {
@@ -75,26 +81,36 @@ const attachEntry = (parent, entry, index, sibling) => {
75
81
  setObjectSlot(parent, entry);
76
82
  }
77
83
  };
84
+ const attachEntry = (parent, entry, index, sibling) => {
85
+ applyWrite(() => {
86
+ runAttach(parent, entry, index, sibling);
87
+ });
88
+ };
78
89
  const detachInfo = (entry, context) => ({
79
90
  slot: entry.slot,
80
91
  adopted: entry.adopted,
81
92
  props: entry.node.props,
82
93
  context,
83
94
  });
84
- const detachEntry = (parent, entry) => {
85
- if (!entry.attached) {
86
- return;
87
- }
88
- entry.attached = false;
95
+ const runDetach = (parent, entry) => {
89
96
  const behavior = entry.behavior;
90
97
  if (behavior === null) {
91
98
  if (entry.slot !== DEFAULT_SLOT) {
92
- Reflect.set(parent.object, entry.slot, null);
99
+ writeSlot(parent, entry, null);
93
100
  }
94
101
  return;
95
102
  }
96
103
  behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));
97
104
  };
105
+ const detachEntry = (parent, entry) => {
106
+ if (!entry.isAttached) {
107
+ return;
108
+ }
109
+ entry.isAttached = false;
110
+ applyWrite(() => {
111
+ runDetach(parent, entry);
112
+ });
113
+ };
98
114
  const rebuild = (parent, entries) => {
99
115
  for (const entry of entries) {
100
116
  detachEntry(parent, entry);
@@ -107,7 +123,7 @@ const rebuild = (parent, entries) => {
107
123
  const getPosition = (entries, before) => indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);
108
124
  const placeNew = (parent, entry, entries, index) => {
109
125
  attachEntry(parent, entry, index, siblingAt(entries, index));
110
- if (!entry.attached) {
126
+ if (!entry.isAttached) {
111
127
  remove(entries, entry);
112
128
  return;
113
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,GAGb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,IAAmB,EAAsB,EAAE;IAC1E,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAEhC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAClF,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,OAAsB,EAAE,KAAa,EAAyB,EAAE,CAC/E,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE5D,MAAM,SAAS,GAAG,CAAC,KAAkB,EAAE,KAAa,EAAE,OAA8B,EAAE,OAAgB,EAAa,EAAE,CAAC,CAAC;IACnH,IA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X,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEhE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrInsert, indexBeforeOrEnd, remove } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo } from \"./registry.js\";\nimport { applyAdoptedProps, markFlush } from \"./apply-props.js\";\nimport { typeInfoFor } from \"./metadata.js\";\nimport {\n DEFAULT_SLOT,\n ELEMENT_KIND,\n type ElementNode,\n getOrCreateContext,\n LAZY_KIND,\n lazyTarget,\n nodeObject,\n type PlaceableNode,\n type PlacedChild,\n} from \"./node.js\";\nimport { markTextDirty } from \"./text.js\";\n\ntype AttachContext = { parent: ElementNode; entry: PlacedChild; index: number; sibling: GObject.Object | null };\n\nconst createEntry = (slot: string, node: PlaceableNode): PlacedChild | null => {\n const object = nodeObject(node);\n\n if (object === null) {\n return null;\n }\n\n return { node, object, adopted: null, slot, behavior: null, attached: false };\n};\n\nconst siblingAt = (entries: PlacedChild[], index: number): GObject.Object | null =>\n index > 0 ? (entries[index - 1]?.object ?? null) : null;\n\nconst placeInfo = (entry: PlacedChild, index: number, sibling: GObject.Object | null, context: unknown): PlaceInfo => ({\n slot: entry.slot,\n index,\n sibling,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst adoptedFrom = (parent: ElementNode, entry: PlacedChild, behavior: ElementBehavior, claim: unknown): void => {\n if (behavior.resolve !== undefined) {\n entry.adopted = behavior.resolve(parent.object, entry.object);\n\n return;\n }\n\n entry.adopted = claim instanceof GObject.Object ? claim : null;\n};\n\nconst applyLazyProps = (entry: PlacedChild): void => {\n if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {\n return;\n }\n\n applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);\n entry.node.adopted = entry.adopted;\n};\n\nconst wireBufferView = (node: PlaceableNode, parent: ElementNode): void => {\n if (!(node.kind === ELEMENT_KIND && node.contentKind === \"buffer\" && parent.object instanceof Gtk.TextView)) {\n return;\n }\n\n node.bufferView = parent.object;\n markTextDirty(node);\n};\n\nconst setObjectSlot = (parent: ElementNode, entry: PlacedChild): void => {\n Reflect.set(parent.object, entry.slot, entry.object);\n wireBufferView(entry.node, parent);\n entry.behavior = null;\n entry.attached = true;\n};\n\nconst didAttach = (ctx: AttachContext, behavior: ElementBehavior): boolean => {\n const attach = behavior.attach;\n\n if (attach === undefined) {\n return false;\n }\n\n const context = getOrCreateContext(ctx.parent, behavior);\n const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));\n\n if (claim === undefined) {\n return false;\n }\n\n ctx.entry.behavior = behavior;\n adoptedFrom(ctx.parent, ctx.entry, behavior, claim);\n ctx.entry.attached = true;\n applyLazyProps(ctx.entry);\n\n return true;\n};\n\nconst attachEntry = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n const ctx: AttachContext = { parent, entry, index, sibling };\n\n for (const behavior of typeInfoFor(parent.typeName).behaviors) {\n if (didAttach(ctx, behavior)) {\n return;\n }\n }\n\n if (entry.slot !== DEFAULT_SLOT) {\n setObjectSlot(parent, entry);\n }\n};\n\nconst detachInfo = (entry: PlacedChild, context: unknown): DetachInfo => ({\n slot: entry.slot,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst detachEntry = (parent: ElementNode, entry: PlacedChild): void => {\n if (!entry.attached) {\n return;\n }\n\n entry.attached = false;\n const behavior = entry.behavior;\n\n if (behavior === null) {\n if (entry.slot !== DEFAULT_SLOT) {\n Reflect.set(parent.object, entry.slot, null);\n }\n\n return;\n }\n\n behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));\n};\n\nconst rebuild = (parent: ElementNode, entries: PlacedChild[]): void => {\n for (const entry of entries) {\n detachEntry(parent, entry);\n }\n\n for (const [index, entry] of entries.entries()) {\n entry.behavior = null;\n attachEntry(parent, entry, index, siblingAt(entries, index));\n }\n};\n\nconst getPosition = (entries: PlacedChild[], before: PlaceableNode | null): number =>\n indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);\n\nconst placeNew = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n attachEntry(parent, entry, index, siblingAt(entries, index));\n\n if (!entry.attached) {\n remove(entries, entry);\n\n return;\n }\n\n const isInsertedBeforeEnd = index < entries.length - 1;\n const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;\n\n if (isInsertedBeforeEnd && isCannotReorderInPlace) {\n rebuild(parent, entries);\n }\n};\n\nconst moveEntry = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n const behavior = entry.behavior;\n const reorder = behavior?.reorder;\n\n if (behavior === null || reorder === undefined) {\n rebuild(parent, entries);\n\n return;\n }\n\n const context = getOrCreateContext(parent, behavior);\n const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));\n adoptedFrom(parent, entry, behavior, claim);\n applyLazyProps(entry);\n};\n\nconst resolveEntry = (\n entries: PlacedChild[],\n existing: number,\n slot: string,\n node: PlaceableNode,\n): PlacedChild | null => {\n if (existing >= 0) {\n return entries[existing] ?? null;\n }\n\n return createEntry(slot, node);\n};\n\nconst placeChild = (\n parent: ElementNode,\n slot: string,\n node: PlaceableNode,\n before: PlaceableNode | null,\n): void => {\n const entries = getOrInsert(parent.placements, slot, () => []);\n const existing = entries.findIndex((entry) => entry.node === node);\n const entry = resolveEntry(entries, existing, slot, node);\n\n if (entry === null) {\n return;\n }\n\n const isMove = existing !== -1;\n\n if (isMove) {\n entries.splice(existing, 1);\n }\n\n const index = getPosition(entries, before);\n entries.splice(index, 0, entry);\n\n if (isMove) {\n moveEntry(parent, entry, entries, index);\n } else {\n placeNew(parent, entry, entries, index);\n }\n\n markFlush(parent);\n};\n\nconst unplaceChild = (parent: ElementNode, slot: string, node: PlaceableNode): void => {\n const entries = parent.placements.get(slot);\n\n if (entries === undefined) {\n return;\n }\n\n const index = entries.findIndex((entry) => entry.node === node);\n\n if (index === -1) {\n return;\n }\n\n const [entry] = entries.splice(index, 1);\n\n if (entry !== undefined) {\n detachEntry(parent, entry);\n }\n\n markFlush(parent);\n};\n\nexport { placeChild, unplaceChild };\n"]}
1
+ {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,GAGb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,GAAG,CAAC,IAAY,E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M,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEhE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrInsert, indexBeforeOrEnd, remove } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo } from \"./registry.js\";\nimport { applyAdoptedProps, markFlush } from \"./apply-props.js\";\nimport { typeInfoFor } from \"./metadata.js\";\nimport {\n DEFAULT_SLOT,\n ELEMENT_KIND,\n type ElementNode,\n getOrCreateContext,\n LAZY_KIND,\n lazyTarget,\n nodeObject,\n type PlaceableNode,\n type PlacedChild,\n} from \"./node.js\";\nimport { applyWrite } from \"./signals.js\";\nimport { markTextDirty } from \"./text.js\";\n\ntype AttachContext = { parent: ElementNode; entry: PlacedChild; index: number; sibling: GObject.Object | null };\n\nconst createEntry = (slot: string, node: PlaceableNode): PlacedChild | null => {\n const object = nodeObject(node);\n\n if (object === null) {\n return null;\n }\n\n return { node, object, adopted: null, slot, behavior: null, isAttached: false };\n};\n\nconst siblingAt = (entries: PlacedChild[], index: number): GObject.Object | null =>\n index > 0 ? (entries[index - 1]?.object ?? null) : null;\n\nconst placeInfo = (entry: PlacedChild, index: number, sibling: GObject.Object | null, context: unknown): PlaceInfo => ({\n slot: entry.slot,\n index,\n sibling,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst adoptedFrom = (parent: ElementNode, entry: PlacedChild, behavior: ElementBehavior, claim: unknown): void => {\n if (behavior.resolve !== undefined) {\n entry.adopted = behavior.resolve(parent.object, entry.object);\n\n return;\n }\n\n entry.adopted = claim instanceof GObject.Object ? claim : null;\n};\n\nconst applyLazyProps = (entry: PlacedChild): void => {\n if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {\n return;\n }\n\n applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);\n entry.node.adopted = entry.adopted;\n};\n\nconst wireBufferView = (node: PlaceableNode, parent: ElementNode): void => {\n if (!(node.kind === ELEMENT_KIND && node.contentKind === \"buffer\" && parent.object instanceof Gtk.TextView)) {\n return;\n }\n\n node.bufferView = parent.object;\n markTextDirty(node);\n};\n\nconst writeSlot = (parent: ElementNode, entry: PlacedChild, value: GObject.Object | null): void => {\n applyWrite(() => {\n Reflect.set(parent.object, entry.slot, value);\n });\n};\n\nconst setObjectSlot = (parent: ElementNode, entry: PlacedChild): void => {\n writeSlot(parent, entry, entry.object);\n wireBufferView(entry.node, parent);\n entry.behavior = null;\n entry.isAttached = true;\n};\n\nconst didAttach = (ctx: AttachContext, behavior: ElementBehavior): boolean => {\n const attach = behavior.attach;\n\n if (attach === undefined) {\n return false;\n }\n\n const context = getOrCreateContext(ctx.parent, behavior);\n const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));\n\n if (claim === undefined) {\n return false;\n }\n\n ctx.entry.behavior = behavior;\n adoptedFrom(ctx.parent, ctx.entry, behavior, claim);\n ctx.entry.isAttached = true;\n applyLazyProps(ctx.entry);\n\n return true;\n};\n\nconst runAttach = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n const ctx: AttachContext = { parent, entry, index, sibling };\n\n for (const behavior of typeInfoFor(parent.typeName).behaviors) {\n if (didAttach(ctx, behavior)) {\n return;\n }\n }\n\n if (entry.slot !== DEFAULT_SLOT) {\n setObjectSlot(parent, entry);\n }\n};\n\nconst attachEntry = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n applyWrite(() => {\n runAttach(parent, entry, index, sibling);\n });\n};\n\nconst detachInfo = (entry: PlacedChild, context: unknown): DetachInfo => ({\n slot: entry.slot,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst runDetach = (parent: ElementNode, entry: PlacedChild): void => {\n const behavior = entry.behavior;\n\n if (behavior === null) {\n if (entry.slot !== DEFAULT_SLOT) {\n writeSlot(parent, entry, null);\n }\n\n return;\n }\n\n behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));\n};\n\nconst detachEntry = (parent: ElementNode, entry: PlacedChild): void => {\n if (!entry.isAttached) {\n return;\n }\n\n entry.isAttached = false;\n\n applyWrite(() => {\n runDetach(parent, entry);\n });\n};\n\nconst rebuild = (parent: ElementNode, entries: PlacedChild[]): void => {\n for (const entry of entries) {\n detachEntry(parent, entry);\n }\n\n for (const [index, entry] of entries.entries()) {\n entry.behavior = null;\n attachEntry(parent, entry, index, siblingAt(entries, index));\n }\n};\n\nconst getPosition = (entries: PlacedChild[], before: PlaceableNode | null): number =>\n indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);\n\nconst placeNew = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n attachEntry(parent, entry, index, siblingAt(entries, index));\n\n if (!entry.isAttached) {\n remove(entries, entry);\n\n return;\n }\n\n const isInsertedBeforeEnd = index < entries.length - 1;\n const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;\n\n if (isInsertedBeforeEnd && isCannotReorderInPlace) {\n rebuild(parent, entries);\n }\n};\n\nconst moveEntry = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n const behavior = entry.behavior;\n const reorder = behavior?.reorder;\n\n if (behavior === null || reorder === undefined) {\n rebuild(parent, entries);\n\n return;\n }\n\n const context = getOrCreateContext(parent, behavior);\n const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));\n adoptedFrom(parent, entry, behavior, claim);\n applyLazyProps(entry);\n};\n\nconst resolveEntry = (\n entries: PlacedChild[],\n existing: number,\n slot: string,\n node: PlaceableNode,\n): PlacedChild | null => {\n if (existing >= 0) {\n return entries[existing] ?? null;\n }\n\n return createEntry(slot, node);\n};\n\nconst placeChild = (\n parent: ElementNode,\n slot: string,\n node: PlaceableNode,\n before: PlaceableNode | null,\n): void => {\n const entries = getOrInsert(parent.placements, slot, () => []);\n const existing = entries.findIndex((entry) => entry.node === node);\n const entry = resolveEntry(entries, existing, slot, node);\n\n if (entry === null) {\n return;\n }\n\n const isMove = existing !== -1;\n\n if (isMove) {\n entries.splice(existing, 1);\n }\n\n const index = getPosition(entries, before);\n entries.splice(index, 0, entry);\n\n if (isMove) {\n moveEntry(parent, entry, entries, index);\n } else {\n placeNew(parent, entry, entries, index);\n }\n\n markFlush(parent);\n};\n\nconst unplaceChild = (parent: ElementNode, slot: string, node: PlaceableNode): void => {\n const entries = parent.placements.get(slot);\n\n if (entries === undefined) {\n return;\n }\n\n const index = entries.findIndex((entry) => entry.node === node);\n\n if (index === -1) {\n return;\n }\n\n const [entry] = entries.splice(index, 1);\n\n if (entry !== undefined) {\n detachEntry(parent, entry);\n }\n\n markFlush(parent);\n};\n\nexport { placeChild, unplaceChild };\n"]}
@@ -3,90 +3,117 @@ import type * as GObject from "@gtkx/gi/gobject";
3
3
  type Props = Record<string, unknown>;
4
4
  /** Per-child values a slot hook receives while placing or moving one child. */
5
5
  type PlaceInfo = {
6
+ /** Name of the slot being filled: `children`, or the prop the child was nested under. */
6
7
  slot: string;
8
+ /** Position of the child among the slot's children. */
7
9
  index: number;
10
+ /** Object of the preceding child in the slot, or null when the child comes first. */
8
11
  sibling: GObject.Object | null;
12
+ /** Object adopted for this child by an earlier attach, or null before it has one. */
9
13
  adopted: GObject.Object | null;
14
+ /** Props of the child element. */
10
15
  props: Props;
16
+ /** Value `initialize` returned for this behavior on the parent. */
11
17
  context: unknown;
12
18
  };
13
19
  /** Per-child values a slot hook receives while removing one child. */
14
20
  type DetachInfo = {
21
+ /** Name of the slot the child is leaving. */
15
22
  slot: string;
23
+ /** Object the container adopted for this child, or null when it adopted none. */
16
24
  adopted: GObject.Object | null;
25
+ /** Props of the child element. */
17
26
  props: Props;
27
+ /** Value `initialize` returned for this behavior on the parent. */
18
28
  context: unknown;
19
29
  };
20
30
  /**
21
- * Customizes how one element type places children and applies props. Every hook receives the
22
- * GObject instance and a private per-node `context` built once by `createContext`. A slot hook
23
- * claims a child by returning a non-`undefined` value; that value, or `resolve`, is the object
24
- * the container adopts for the child. `update` returns the prop names it consumed so those props
25
- * are not also set as plain GObject properties. `create` builds the GObject for types whose
26
- * constructor does more than set properties, and is consulted for its own type only, never
27
- * inherited by subtypes.
31
+ * Customizes how one element type places children and applies props. Hooks other than `create` receive the
32
+ * GObject instance; `update`, `flush`, `mount` and `unmount` also take the private per-node context
33
+ * `initialize` built, and `attach`, `reorder` and `detach` read it off their info object. Subtypes inherit a
34
+ * type's behaviors, except for `create`, which is consulted only for the type it is registered on.
28
35
  */
29
36
  type ElementBehavior<T extends GObject.Object = GObject.Object> = {
37
+ /** Builds the GObject from its construct props, for types whose constructor does more than set properties. */
30
38
  create?: (props: Props) => GObject.Object;
31
- createContext?: (object: T) => unknown;
39
+ /** Builds the private per-node context the other hooks receive, once per node. */
40
+ initialize?: (object: T) => unknown;
41
+ /** Places a child, claiming it by returning anything other than `undefined`. */
32
42
  attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;
43
+ /** Moves an already-attached child; without it, the whole slot is detached and re-attached in order. */
33
44
  reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;
45
+ /** Removes a child this behavior attached. */
34
46
  detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;
47
+ /** Returns the object the container adopts for a child, overriding whatever `attach` returned. */
35
48
  resolve?: (object: T, child: GObject.Object) => GObject.Object | null;
49
+ /** Applies changed props and returns the names it consumed, which are then not set as GObject properties. */
36
50
  update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;
51
+ /** Runs after the commit that touched the node, once every child has been placed. */
37
52
  flush?: (object: T, context: unknown) => void;
53
+ /** Runs once the node and its initial children are attached. */
38
54
  mount?: (object: T, context: unknown) => void;
55
+ /** Runs when React deletes the node. */
39
56
  unmount?: (object: T, context: unknown) => void;
57
+ /** Props to withhold from the constructor, leaving them for a later hook to apply. */
40
58
  deferred?: string[];
41
59
  };
42
60
  /** A named export in a module, referenced as plain data (the module is never imported at runtime). */
43
61
  type ModuleExport = {
62
+ /** Specifier the export is imported from. */
44
63
  module: string;
64
+ /** Identifier the module exports it under. */
45
65
  export: string;
46
66
  };
47
67
  /**
48
- * Per-element configuration keyed by GLib type name: whether the element is lazy (its GObject is
49
- * created by its parent container, as pages and layout children are), the custom behaviors bound to
50
- * its type, an optional component that wraps the generated element, and the base props interface its
51
- * generated props extend. `component` and `props` are inert at runtime; they are read only by codegen.
68
+ * How one GLib type is rendered. `component`, `props` and `omittedProps` are inert at runtime; they are
69
+ * read only by codegen.
52
70
  */
53
71
  type ElementConfig<T extends GObject.Object = GObject.Object> = {
54
- lazy?: boolean;
72
+ /** The element has no GObject of its own; its parent container creates one, as it does for pages. */
73
+ isLazy?: boolean;
74
+ /** Behaviors bound to the type, consulted in registration order and inherited by its subtypes. */
55
75
  behaviors?: ElementBehavior<T>[];
76
+ /** Component that wraps the generated element. */
56
77
  component?: ModuleExport;
78
+ /** Base props interface the generated props extend. */
57
79
  props?: ModuleExport;
80
+ /** GObject properties to leave out of the generated props, such as those a behavior writes from children. */
81
+ omittedProps?: string[];
58
82
  };
59
83
  /**
60
84
  * Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`
61
85
  * is loaded.
62
86
  */
63
87
  declare const ELEMENTS: Record<string, ElementConfig>;
64
- /** Props a behavior applies after construction; the constructor is never given them. */
65
88
  declare const deferredProps: (behavior: ElementBehavior) => string[];
66
89
  /**
67
90
  * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's
68
- * behaviors in the order the maps are given (an earlier map's behaviors come first) and taking the last
69
- * lazy flag, component, and props seen. Use it to combine an app's element config with its behaviors.
91
+ * behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first),
92
+ * taking the last component and props seen, and marking a type lazy if any map does. Use it to combine
93
+ * an app's element config with its behaviors.
70
94
  */
71
95
  declare const mergeElementConfigs: (...maps: Record<string, ElementConfig<never>>[]) => Record<string, ElementConfig>;
72
- /**
73
- * Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the
74
- * registry. Behaviors are appended by default (the framework's built-ins register this way); pass
75
- * `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the
76
- * built-ins for the same slot, letting it override them regardless of registration order.
77
- */
78
96
  declare const registerElements: (map: Record<string, ElementConfig<never>>, options?: {
79
- prepend?: boolean;
97
+ isPrepended?: boolean;
80
98
  }) => void;
81
99
  /**
82
- * Identity helper that types the module named by the `elements` entry of `gtkx.config.ts`, enabling
83
- * editor autocompletion and type checking. Key each entry by GLib type name and annotate each hook's
84
- * object parameter with the concrete GObject class the behavior applies to.
100
+ * Identity helper that types the module named by `elements.behaviors` in `gtkx.config.ts`, enabling
101
+ * editor autocompletion and type checking. Key each entry by GLib type name and write each behavior
102
+ * with {@link defineBehavior} so its hooks receive the concrete GObject class.
85
103
  */
86
104
  declare const defineElements: (elements: Record<string, ElementConfig<never>>) => Record<string, ElementConfig<never>>;
87
- /** Spreads one config across many GLib type names. */
105
+ /**
106
+ * Types one behavior against the GObject class it applies to, so every hook's object parameter is
107
+ * inferred rather than annotated by hand. Pass the class as the type argument.
108
+ *
109
+ * ```ts
110
+ * defineElements({
111
+ * GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },
112
+ * });
113
+ * ```
114
+ */
115
+ declare const defineBehavior: <T extends GObject.Object>(hooks: ElementBehavior<T>) => ElementBehavior<never>;
88
116
  declare const forTypes: (types: string[], config: ElementConfig<never>) => Record<string, ElementConfig<never>>;
89
- /** References a base props interface exported from `@gtkx/react/internal`. */
90
117
  declare const internal: (name: string) => ModuleExport;
91
- export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, forTypes, internal, type Props, type PlaceInfo, type DetachInfo, type ElementBehavior, type ModuleExport, type ElementConfig, };
118
+ export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, defineBehavior, forTypes, internal, type Props, type PlaceInfo, type DetachInfo, type ElementBehavior, type ModuleExport, type ElementConfig, };
92
119
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/reconciler/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErC,+EAA+E;AAC/E,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,sEAAsE;AACtE,KAAK,UAAU,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,KAAK,eAAe,CAAC,CA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a,CAAC,KAAK,CAAC,CAChG,CAAC;AAEb;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,GAAI,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,OAAO,eAAe,CAAC,CAAC,CAAC,KAAG,eAAe,CAAC,KAAK,CAAU,CAAC;AAE9G,QAAA,MAAM,QAAQ,GAAI,OAAO,MAAM,EAAE,EAAE,QAAQ,aAAa,CAAC,KAAK,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAC1C,CAAC;AAE5D,QAAA,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,YAAkE,CAAC;AAEpG,OAAO,EACH,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,GACrB,CAAC"}
@@ -3,32 +3,30 @@
3
3
  * is loaded.
4
4
  */
5
5
  const ELEMENTS = {};
6
- /** Props a behavior applies after construction; the constructor is never given them. */
7
6
  const deferredProps = (behavior) => behavior.deferred ?? [];
8
7
  const mergeBehaviors = (base, added, isPrepended) => {
9
8
  const baseBehaviors = base.behaviors ?? [];
10
9
  return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];
11
10
  };
12
11
  const mergeConfigEntry = (base, added, isPrepended = false) => {
13
- const entry = { ...base };
14
- if (added.behaviors !== undefined) {
15
- entry.behaviors = mergeBehaviors(entry, added.behaviors, isPrepended);
12
+ const { behaviors, isLazy, omittedProps, ...rest } = added;
13
+ const entry = { ...base, ...rest };
14
+ if (behaviors !== undefined) {
15
+ entry.behaviors = mergeBehaviors(base, behaviors, isPrepended);
16
16
  }
17
- if (added.lazy === true) {
18
- entry.lazy = true;
17
+ if (omittedProps !== undefined) {
18
+ entry.omittedProps = [...(base.omittedProps ?? []), ...omittedProps];
19
19
  }
20
- if (added.component !== undefined) {
21
- entry.component = added.component;
22
- }
23
- if (added.props !== undefined) {
24
- entry.props = added.props;
20
+ if (isLazy === true) {
21
+ entry.isLazy = true;
25
22
  }
26
23
  return entry;
27
24
  };
28
25
  /**
29
26
  * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's
30
- * behaviors in the order the maps are given (an earlier map's behaviors come first) and taking the last
31
- * lazy flag, component, and props seen. Use it to combine an app's element config with its behaviors.
27
+ * behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first),
28
+ * taking the last component and props seen, and marking a type lazy if any map does. Use it to combine
29
+ * an app's element config with its behaviors.
32
30
  */
33
31
  const mergeElementConfigs = (...maps) => {
34
32
  const merged = {};
@@ -39,26 +37,29 @@ const mergeElementConfigs = (...maps) => {
39
37
  }
40
38
  return merged;
41
39
  };
42
- /**
43
- * Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the
44
- * registry. Behaviors are appended by default (the framework's built-ins register this way); pass
45
- * `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the
46
- * built-ins for the same slot, letting it override them regardless of registration order.
47
- */
48
40
  const registerElements = (map, options = {}) => {
49
41
  for (const [type, config] of Object.entries(map)) {
50
- ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.prepend === true);
42
+ ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.isPrepended === true);
51
43
  }
52
44
  };
53
45
  /**
54
- * Identity helper that types the module named by the `elements` entry of `gtkx.config.ts`, enabling
55
- * editor autocompletion and type checking. Key each entry by GLib type name and annotate each hook's
56
- * object parameter with the concrete GObject class the behavior applies to.
46
+ * Identity helper that types the module named by `elements.behaviors` in `gtkx.config.ts`, enabling
47
+ * editor autocompletion and type checking. Key each entry by GLib type name and write each behavior
48
+ * with {@link defineBehavior} so its hooks receive the concrete GObject class.
57
49
  */
58
50
  const defineElements = (elements) => elements;
59
- /** Spreads one config across many GLib type names. */
51
+ /**
52
+ * Types one behavior against the GObject class it applies to, so every hook's object parameter is
53
+ * inferred rather than annotated by hand. Pass the class as the type argument.
54
+ *
55
+ * ```ts
56
+ * defineElements({
57
+ * GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },
58
+ * });
59
+ * ```
60
+ */
61
+ const defineBehavior = (hooks) => hooks;
60
62
  const forTypes = (types, config) => Object.fromEntries(types.map((type) => [type, config]));
61
- /** References a base props interface exported from `@gtkx/react/internal`. */
62
63
  const internal = (name) => ({ module: "@gtkx/react/internal", export: name });
63
- export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, forTypes, internal, };
64
+ export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, defineBehavior, forTypes, internal, };
64
65
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/reconciler/registry.ts"],"names":[],"mappings":"AA8DA;;;GAGG;AACH,MAAM,QAAQ,GAAkC,EAAE,CAAC;AAEnD,wFAAwF;AACxF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAY,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;AAEvF,MAAM,cAAc,GAAG,CAAC,IAAmB,EAAE,KAAwB,EAAE,WAAoB,EAAqB,EAAE;IAC9G,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAE3C,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAE,KAA2B,EAAE,WAAW,GAAG,KAAK,EAAiB,EAAE;IAC9G,MAAM,KAAK,GAAkB,EAAE,GAAG,IAAI,EAAE,CAAC;IAEzC,I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,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;IAC9F,CAAC;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,QAA8C,EAAwC,EAAE,CAC5G,QAAQ,CAAC;AAEb,sDAAsD;AACtD,MAAM,QAAQ,GAAG,CAAC,KAAe,EAAE,MAA4B,EAAwC,EAAE,CACrG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAE5D,8EAA8E;AAC9E,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAEpG,OAAO,EACH,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,QAAQ,GAOX,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\n\n/** The props of a host element or node, as React passes them through the reconciler. */\ntype Props = Record<string, unknown>;\n\n/** Per-child values a slot hook receives while placing or moving one child. */\ntype PlaceInfo = {\n slot: string;\n index: number;\n sibling: GObject.Object | null;\n adopted: GObject.Object | null;\n props: Props;\n context: unknown;\n};\n\n/** Per-child values a slot hook receives while removing one child. */\ntype DetachInfo = {\n slot: string;\n adopted: GObject.Object | null;\n props: Props;\n context: unknown;\n};\n\n/**\n * Customizes how one element type places children and applies props. Every hook receives the\n * GObject instance and a private per-node `context` built once by `createContext`. A slot hook\n * claims a child by returning a non-`undefined` value; that value, or `resolve`, is the object\n * the container adopts for the child. `update` returns the prop names it consumed so those props\n * are not also set as plain GObject properties. `create` builds the GObject for types whose\n * constructor does more than set properties, and is consulted for its own type only, never\n * inherited by subtypes.\n */\ntype ElementBehavior<T extends GObject.Object = GObject.Object> = {\n create?: (props: Props) => GObject.Object;\n createContext?: (object: T) => unknown;\n attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;\n resolve?: (object: T, child: GObject.Object) => GObject.Object | null;\n update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;\n flush?: (object: T, context: unknown) => void;\n mount?: (object: T, context: unknown) => void;\n unmount?: (object: T, context: unknown) => void;\n deferred?: string[];\n};\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = { module: string; export: string };\n\n/**\n * Per-element configuration keyed by GLib type name: whether the element is lazy (its GObject is\n * created by its parent container, as pages and layout children are), the custom behaviors bound to\n * its type, an optional component that wraps the generated element, and the base props interface its\n * generated props extend. `component` and `props` are inert at runtime; they are read only by codegen.\n */\ntype ElementConfig<T extends GObject.Object = GObject.Object> = {\n lazy?: boolean;\n behaviors?: ElementBehavior<T>[];\n component?: ModuleExport;\n props?: ModuleExport;\n};\n\n/**\n * Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`\n * is loaded.\n */\nconst ELEMENTS: Record<string, ElementConfig> = {};\n\n/** Props a behavior applies after construction; the constructor is never given them. */\nconst deferredProps = (behavior: ElementBehavior): string[] => behavior.deferred ?? [];\n\nconst mergeBehaviors = (base: ElementConfig, added: ElementBehavior[], isPrepended: boolean): ElementBehavior[] => {\n const baseBehaviors = base.behaviors ?? [];\n\n return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];\n};\n\nconst mergeConfigEntry = (base: ElementConfig, added: ElementConfig<never>, isPrepended = false): ElementConfig => {\n const entry: ElementConfig = { ...base };\n\n if (added.behaviors !== undefined) {\n entry.behaviors = mergeBehaviors(entry, added.behaviors as ElementBehavior[], isPrepended);\n }\n\n if (added.lazy === true) {\n entry.lazy = true;\n }\n\n if (added.component !== undefined) {\n entry.component = added.component;\n }\n\n if (added.props !== undefined) {\n entry.props = added.props;\n }\n\n return entry;\n};\n\n/**\n * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's\n * behaviors in the order the maps are given (an earlier map's behaviors come first) and taking the last\n * lazy flag, component, and props seen. Use it to combine an app's element config with its behaviors.\n */\nconst mergeElementConfigs = (...maps: Record<string, ElementConfig<never>>[]): Record<string, ElementConfig> => {\n const merged: Record<string, ElementConfig> = {};\n\n for (const map of maps) {\n for (const [type, config] of Object.entries(map)) {\n merged[type] = mergeConfigEntry(merged[type] ?? {}, config);\n }\n }\n\n return merged;\n};\n\n/**\n * Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the\n * registry. Behaviors are appended by default (the framework's built-ins register this way); pass\n * `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the\n * built-ins for the same slot, letting it override them regardless of registration order.\n */\nconst registerElements = (\n map: Record<string, ElementConfig<never>>,\n options: { prepend?: boolean } = {},\n): void => {\n for (const [type, config] of Object.entries(map)) {\n ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.prepend === true);\n }\n};\n\n/**\n * Identity helper that types the module named by the `elements` entry of `gtkx.config.ts`, enabling\n * editor autocompletion and type checking. Key each entry by GLib type name and annotate each hook's\n * object parameter with the concrete GObject class the behavior applies to.\n */\nconst defineElements = (elements: Record<string, ElementConfig<never>>): Record<string, ElementConfig<never>> =>\n elements;\n\n/** Spreads one config across many GLib type names. */\nconst forTypes = (types: string[], config: ElementConfig<never>): Record<string, ElementConfig<never>> =>\n Object.fromEntries(types.map((type) => [type, config]));\n\n/** References a base props interface exported from `@gtkx/react/internal`. */\nconst internal = (name: string): ModuleExport => ({ module: \"@gtkx/react/internal\", export: name });\n\nexport {\n ELEMENTS,\n deferredProps,\n mergeElementConfigs,\n registerElements,\n defineElements,\n forTypes,\n internal,\n type Props,\n type PlaceInfo,\n type DetachInfo,\n type ElementBehavior,\n type ModuleExport,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AC,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAEpG,OAAO,EACH,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,GAOX,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\n\n/** The props of a host element or node, as React passes them through the reconciler. */\ntype Props = Record<string, unknown>;\n\n/** Per-child values a slot hook receives while placing or moving one child. */\ntype PlaceInfo = {\n /** Name of the slot being filled: `children`, or the prop the child was nested under. */\n slot: string;\n /** Position of the child among the slot's children. */\n index: number;\n /** Object of the preceding child in the slot, or null when the child comes first. */\n sibling: GObject.Object | null;\n /** Object adopted for this child by an earlier attach, or null before it has one. */\n adopted: GObject.Object | null;\n /** Props of the child element. */\n props: Props;\n /** Value `initialize` returned for this behavior on the parent. */\n context: unknown;\n};\n\n/** Per-child values a slot hook receives while removing one child. */\ntype DetachInfo = {\n /** Name of the slot the child is leaving. */\n slot: string;\n /** Object the container adopted for this child, or null when it adopted none. */\n adopted: GObject.Object | null;\n /** Props of the child element. */\n props: Props;\n /** Value `initialize` returned for this behavior on the parent. */\n context: unknown;\n};\n\n/**\n * Customizes how one element type places children and applies props. Hooks other than `create` receive the\n * GObject instance; `update`, `flush`, `mount` and `unmount` also take the private per-node context\n * `initialize` built, and `attach`, `reorder` and `detach` read it off their info object. Subtypes inherit a\n * type's behaviors, except for `create`, which is consulted only for the type it is registered on.\n */\ntype ElementBehavior<T extends GObject.Object = GObject.Object> = {\n /** Builds the GObject from its construct props, for types whose constructor does more than set properties. */\n create?: (props: Props) => GObject.Object;\n /** Builds the private per-node context the other hooks receive, once per node. */\n initialize?: (object: T) => unknown;\n /** Places a child, claiming it by returning anything other than `undefined`. */\n attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n /** Moves an already-attached child; without it, the whole slot is detached and re-attached in order. */\n reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n /** Removes a child this behavior attached. */\n detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;\n /** Returns the object the container adopts for a child, overriding whatever `attach` returned. */\n resolve?: (object: T, child: GObject.Object) => GObject.Object | null;\n /** Applies changed props and returns the names it consumed, which are then not set as GObject properties. */\n update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;\n /** Runs after the commit that touched the node, once every child has been placed. */\n flush?: (object: T, context: unknown) => void;\n /** Runs once the node and its initial children are attached. */\n mount?: (object: T, context: unknown) => void;\n /** Runs when React deletes the node. */\n unmount?: (object: T, context: unknown) => void;\n /** Props to withhold from the constructor, leaving them for a later hook to apply. */\n deferred?: string[];\n};\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = {\n /** Specifier the export is imported from. */\n module: string;\n /** Identifier the module exports it under. */\n export: string;\n};\n\n/**\n * How one GLib type is rendered. `component`, `props` and `omittedProps` are inert at runtime; they are\n * read only by codegen.\n */\ntype ElementConfig<T extends GObject.Object = GObject.Object> = {\n /** The element has no GObject of its own; its parent container creates one, as it does for pages. */\n isLazy?: boolean;\n /** Behaviors bound to the type, consulted in registration order and inherited by its subtypes. */\n behaviors?: ElementBehavior<T>[];\n /** Component that wraps the generated element. */\n component?: ModuleExport;\n /** Base props interface the generated props extend. */\n props?: ModuleExport;\n /** GObject properties to leave out of the generated props, such as those a behavior writes from children. */\n omittedProps?: string[];\n};\n\n/**\n * Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`\n * is loaded.\n */\nconst ELEMENTS: Record<string, ElementConfig> = {};\n\nconst deferredProps = (behavior: ElementBehavior): string[] => behavior.deferred ?? [];\n\nconst mergeBehaviors = (base: ElementConfig, added: ElementBehavior[], isPrepended: boolean): ElementBehavior[] => {\n const baseBehaviors = base.behaviors ?? [];\n\n return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];\n};\n\nconst mergeConfigEntry = (base: ElementConfig, added: ElementConfig<never>, isPrepended = false): ElementConfig => {\n const { behaviors, isLazy, omittedProps, ...rest } = added;\n const entry: ElementConfig = { ...base, ...rest };\n\n if (behaviors !== undefined) {\n entry.behaviors = mergeBehaviors(base, behaviors as ElementBehavior[], isPrepended);\n }\n\n if (omittedProps !== undefined) {\n entry.omittedProps = [...(base.omittedProps ?? []), ...omittedProps];\n }\n\n if (isLazy === true) {\n entry.isLazy = true;\n }\n\n return entry;\n};\n\n/**\n * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's\n * behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first),\n * taking the last component and props seen, and marking a type lazy if any map does. Use it to combine\n * an app's element config with its behaviors.\n */\nconst mergeElementConfigs = (...maps: Record<string, ElementConfig<never>>[]): Record<string, ElementConfig> => {\n const merged: Record<string, ElementConfig> = {};\n\n for (const map of maps) {\n for (const [type, config] of Object.entries(map)) {\n merged[type] = mergeConfigEntry(merged[type] ?? {}, config);\n }\n }\n\n return merged;\n};\n\nconst registerElements = (\n map: Record<string, ElementConfig<never>>,\n options: { isPrepended?: boolean } = {},\n): void => {\n for (const [type, config] of Object.entries(map)) {\n ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.isPrepended === true);\n }\n};\n\n/**\n * Identity helper that types the module named by `elements.behaviors` in `gtkx.config.ts`, enabling\n * editor autocompletion and type checking. Key each entry by GLib type name and write each behavior\n * with {@link defineBehavior} so its hooks receive the concrete GObject class.\n */\nconst defineElements = (elements: Record<string, ElementConfig<never>>): Record<string, ElementConfig<never>> =>\n elements;\n\n/**\n * Types one behavior against the GObject class it applies to, so every hook's object parameter is\n * inferred rather than annotated by hand. Pass the class as the type argument.\n *\n * ```ts\n * defineElements({\n * GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },\n * });\n * ```\n */\nconst defineBehavior = <T extends GObject.Object>(hooks: ElementBehavior<T>): ElementBehavior<never> => hooks;\n\nconst forTypes = (types: string[], config: ElementConfig<never>): Record<string, ElementConfig<never>> =>\n Object.fromEntries(types.map((type) => [type, config]));\n\nconst internal = (name: string): ModuleExport => ({ module: \"@gtkx/react/internal\", export: name });\n\nexport {\n ELEMENTS,\n deferredProps,\n mergeElementConfigs,\n registerElements,\n defineElements,\n defineBehavior,\n forTypes,\n internal,\n type Props,\n type PlaceInfo,\n type DetachInfo,\n type ElementBehavior,\n type ModuleExport,\n type ElementConfig,\n};\n"]}
@@ -5,7 +5,6 @@ type RootElement = {
5
5
  declare const ROOT_ELEMENT_BRAND: unique symbol;
6
6
  /** A shared marker value used as the default top-level container for rendering and portals. */
7
7
  declare const rootElement: RootElement;
8
- /** Reports whether an arbitrary value is a {@link rootElement} marker. */
9
8
  declare const isRootElement: (value: unknown) => value is RootElement;
10
9
  export { rootElement, isRootElement, type RootElement };
11
10
  //# sourceMappingURL=root-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"root-element.d.ts","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,KAAK,WAAW,GAAG;IAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAElD,QAAA,MAAM,kBAAkB,EAAE,OAAO,MAAwC,CAAC;AAC1E,+FAA+F;AAC/F,QAAA,MAAM,WAAW,EAAE,WAA4C,CAAC;AAEhE,0EAA0E;AAC1E,QAAA,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAC0C,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"root-element.d.ts","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,KAAK,WAAW,GAAG;IAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAElD,QAAA,MAAM,kBAAkB,EAAE,OAAO,MAAwC,CAAC;AAC1E,+FAA+F;AAC/F,QAAA,MAAM,WAAW,EAAE,WAA4C,CAAC;AAEhE,QAAA,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAC0C,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,CAAC"}
@@ -1,7 +1,6 @@
1
1
  const ROOT_ELEMENT_BRAND = Symbol.for("gtkx:root-element");
2
2
  /** A shared marker value used as the default top-level container for rendering and portals. */
3
3
  const rootElement = { [ROOT_ELEMENT_BRAND]: true };
4
- /** Reports whether an arbitrary value is a {@link rootElement} marker. */
5
4
  const isRootElement = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);
6
5
  export { rootElement, isRootElement };
7
6
  //# sourceMappingURL=root-element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAGA,MAAM,kBAAkB,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC1E,+FAA+F;AAC/F,MAAM,WAAW,GAAgB,EAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;AAEhE,0EAA0E;AAC1E,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoB,CAAC","sourcesContent":["/** The type of the shared {@link rootElement} marker used as a default top-level container. */\ntype RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\nconst ROOT_ELEMENT_BRAND: unique symbol = Symbol.for(\"gtkx:root-element\");\n/** A shared marker value used as the default top-level container for rendering and portals. */\nconst rootElement: RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\n/** Reports whether an arbitrary value is a {@link rootElement} marker. */\nconst isRootElement = (value: unknown): value is RootElement =>\n typeof value === \"object\" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);\n\nexport { rootElement, isRootElement, type RootElement };\n"]}
1
+ {"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAGA,MAAM,kBAAkB,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC1E,+FAA+F;AAC/F,MAAM,WAAW,GAAgB,EAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;AAEhE,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoB,CAAC","sourcesContent":["/** The type of the shared {@link rootElement} marker used as a default top-level container. */\ntype RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\nconst ROOT_ELEMENT_BRAND: unique symbol = Symbol.for(\"gtkx:root-element\");\n/** A shared marker value used as the default top-level container for rendering and portals. */\nconst rootElement: RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\nconst isRootElement = (value: unknown): value is RootElement =>\n typeof value === \"object\" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);\n\nexport { rootElement, isRootElement, type RootElement };\n"]}
@@ -1,4 +1,4 @@
1
- import type { ErrorInfo, ReactNode } from "react";
1
+ import type { ErrorInfo, ReactNode, ReactPortal } from "react";
2
2
  import * as Gdk from "@gtkx/gi/gdk";
3
3
  import { type Container } from "./host-config.js";
4
4
  type RootErrorCallbacks = {
@@ -9,36 +9,25 @@ type RootErrorCallbacks = {
9
9
  type ReconcilerRootOptions = RootErrorCallbacks & {
10
10
  containerInfo: Container;
11
11
  };
12
- /** A root that mounts an element tree into an explicit container and reports render errors. */
13
12
  type ReconcilerRoot = {
14
13
  update: (element: ReactNode) => void;
15
14
  unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;
16
15
  };
17
16
  /** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */
18
17
  type Root = {
18
+ /** Mounts an element tree into the container, or updates the tree already mounted there. */
19
19
  render: (element: ReactNode) => void;
20
+ /** Unmounts the rendered tree and runs its effect cleanups. */
20
21
  unmount: () => void;
21
22
  };
22
23
  type ErrorHandler = (error: unknown) => void;
23
- /**
24
- * Installs a process-wide handler for errors thrown while rendering or applying an update.
25
- *
26
- * @param handler The handler to install.
27
- * @returns The previously installed handler, or null.
28
- */
29
24
  declare const setReconcilerErrorHandler: (handler: ErrorHandler) => ErrorHandler | null;
30
- /**
31
- * Creates a root that mounts an element tree into a container, routing render errors to the supplied callbacks.
32
- *
33
- * @param options The container to render into and the error callbacks to route failures to.
34
- * @returns A {@link ReconcilerRoot}.
35
- */
36
25
  declare const createReconcilerRoot: (options: ReconcilerRootOptions) => ReconcilerRoot;
37
26
  /**
38
- * Creates a render root for a GTKX application.
27
+ * Creates a render root for a GTKX application. Uncaught render errors are rethrown and errors caught by an
28
+ * error boundary are logged.
39
29
  *
40
- * @param container The top-level container to render into; defaults to the shared {@link rootElement}.
41
- * @returns A {@link Root} exposing render and unmount.
30
+ * @param container The GObject to render into; defaults to the shared {@link rootElement}, which holds no object.
42
31
  */
43
32
  declare const createRoot: (container?: Container) => Root;
44
33
  /** Unmounts every active render root and stops the originating signal from propagating further. */
@@ -46,11 +35,8 @@ declare const quit: () => typeof Gdk.EVENT_STOP;
46
35
  /**
47
36
  * Renders children into a container other than the surrounding tree.
48
37
  *
49
- * @param children The element tree to render.
50
- * @param container The GObject, application, or {@link rootElement} to render into.
51
- * @param key An optional stable key.
52
- * @returns A React portal.
38
+ * @param container The GObject to render into, or {@link rootElement} to render at the top level.
53
39
  */
54
- declare const createPortal: (children: ReactNode, container: Container, key?: string) => ReactNode;
40
+ declare const createPortal: (children: ReactNode, container: Container, key?: string) => ReactPortal;
55
41
  export { setReconcilerErrorHandler, createReconcilerRoot, createRoot, quit, createPortal, type ReconcilerRoot, type Root, };
56
42
  //# sourceMappingURL=root.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,kBAAkB,CAAC;AAM9D,KAAK,kBAAkB,GAAG;IACtB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC5D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1D,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF,KAAK,qBAAqB,GAAG,kBAAkB,GAAG;IAAE,aAAa,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/E,+FAA+F;AAC/F,KAAK,cAAc,GAAG;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjF,CAAC;AAEF,+GAA+G;AAC/G,KAAK,IAAI,GAAG;IACR,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,YAAY,GAAG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