react-native-gtkx 0.3.0-alpha.1 → 0.4.0-alpha.3

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 (169) hide show
  1. package/README.md +35 -96
  2. package/dist/adw/index.d.ts +3 -2
  3. package/dist/adw/index.js +24 -6
  4. package/dist/adw/index.js.map +1 -1
  5. package/dist/adw/widgets.generated.d.ts +1 -1
  6. package/dist/adw/widgets.generated.js +2 -2
  7. package/dist/adw/widgets.generated.js.map +1 -1
  8. package/dist/animated/create-animated.d.ts +2 -0
  9. package/dist/animated/create-animated.js +2 -0
  10. package/dist/animated/create-animated.js.map +1 -1
  11. package/dist/animated/event.d.ts +15 -0
  12. package/dist/animated/event.js +80 -0
  13. package/dist/animated/event.js.map +1 -0
  14. package/dist/animated/index.d.ts +4 -0
  15. package/dist/animated/index.js +8 -0
  16. package/dist/animated/index.js.map +1 -1
  17. package/dist/animated/spring.d.ts +10 -0
  18. package/dist/animated/spring.js +20 -6
  19. package/dist/animated/spring.js.map +1 -1
  20. package/dist/animated/timing.d.ts +10 -0
  21. package/dist/animated/timing.js +21 -13
  22. package/dist/animated/timing.js.map +1 -1
  23. package/dist/apis/host.gtkx.js +70 -11
  24. package/dist/apis/host.gtkx.js.map +1 -1
  25. package/dist/common/navigation-stack.d.ts +6 -3
  26. package/dist/common/navigation-stack.js +8 -1
  27. package/dist/common/navigation-stack.js.map +1 -1
  28. package/dist/common/widget.js +2 -11
  29. package/dist/common/widget.js.map +1 -1
  30. package/dist/components/animated.d.ts +1 -0
  31. package/dist/components/animated.js +28 -4
  32. package/dist/components/animated.js.map +1 -1
  33. package/dist/components/app-registry.js +32 -8
  34. package/dist/components/app-registry.js.map +1 -1
  35. package/dist/components/request-animation-frame.d.ts +33 -0
  36. package/dist/components/request-animation-frame.js +83 -0
  37. package/dist/components/request-animation-frame.js.map +1 -0
  38. package/dist/components/scroll-view.js +60 -2
  39. package/dist/components/scroll-view.js.map +1 -1
  40. package/dist/components/virtualized-list.js +1 -4
  41. package/dist/components/virtualized-list.js.map +1 -1
  42. package/dist/dnd/autoscroll.d.ts +44 -0
  43. package/dist/dnd/autoscroll.js +176 -0
  44. package/dist/dnd/autoscroll.js.map +1 -0
  45. package/dist/dnd/grid-order.d.ts +45 -0
  46. package/dist/dnd/grid-order.js +151 -0
  47. package/dist/dnd/grid-order.js.map +1 -0
  48. package/dist/dnd/grid.d.ts +44 -0
  49. package/dist/dnd/grid.js +397 -0
  50. package/dist/dnd/grid.js.map +1 -0
  51. package/dist/dnd/gtk-controllers.d.ts +16 -2
  52. package/dist/dnd/gtk-controllers.js +24 -4
  53. package/dist/dnd/gtk-controllers.js.map +1 -1
  54. package/dist/dnd/index.d.ts +4 -2
  55. package/dist/dnd/index.js +9 -2
  56. package/dist/dnd/index.js.map +1 -1
  57. package/dist/dnd/order-state.d.ts +14 -0
  58. package/dist/dnd/order-state.js +55 -0
  59. package/dist/dnd/order-state.js.map +1 -0
  60. package/dist/dnd/order.d.ts +19 -0
  61. package/dist/dnd/order.js +19 -0
  62. package/dist/dnd/order.js.map +1 -1
  63. package/dist/dnd/sortable.d.ts +29 -4
  64. package/dist/dnd/sortable.js +308 -115
  65. package/dist/dnd/sortable.js.map +1 -1
  66. package/dist/dnd/types.d.ts +236 -14
  67. package/dist/dnd/types.js +30 -0
  68. package/dist/dnd/types.js.map +1 -1
  69. package/dist/gesture-handler-compat/attach-context.d.ts +29 -0
  70. package/dist/gesture-handler-compat/attach-context.js +90 -0
  71. package/dist/gesture-handler-compat/attach-context.js.map +1 -0
  72. package/dist/gesture-handler-compat/detector-runtime.d.ts +14 -3
  73. package/dist/gesture-handler-compat/detector-runtime.js +15 -5
  74. package/dist/gesture-handler-compat/detector-runtime.js.map +1 -1
  75. package/dist/gesture-handler-compat/detector.js +57 -2
  76. package/dist/gesture-handler-compat/detector.js.map +1 -1
  77. package/dist/gesture-handler-compat/gesture-state-manager.d.ts +5 -0
  78. package/dist/gesture-handler-compat/gesture-state-manager.js +77 -0
  79. package/dist/gesture-handler-compat/gesture-state-manager.js.map +1 -0
  80. package/dist/gesture-handler-compat/index.d.ts +2 -2
  81. package/dist/gesture-handler-compat/index.js +38 -33
  82. package/dist/gesture-handler-compat/index.js.map +1 -1
  83. package/dist/gesture-handler-compat/recognizer.d.ts +12 -1
  84. package/dist/gesture-handler-compat/recognizer.js +23 -9
  85. package/dist/gesture-handler-compat/recognizer.js.map +1 -1
  86. package/dist/gesture-handler-compat/tag-registry.d.ts +14 -0
  87. package/dist/gesture-handler-compat/tag-registry.js +19 -0
  88. package/dist/gesture-handler-compat/tag-registry.js.map +1 -0
  89. package/dist/globals/index.d.ts +47 -0
  90. package/dist/globals/index.js +181 -0
  91. package/dist/globals/index.js.map +1 -0
  92. package/dist/globals/install.d.ts +1 -0
  93. package/dist/globals/install.js +14 -0
  94. package/dist/globals/install.js.map +1 -0
  95. package/dist/gtk/index.js +4 -3
  96. package/dist/gtk/index.js.map +1 -1
  97. package/dist/gtkx/bridge/adw-namespace.d.ts +2 -0
  98. package/dist/gtkx/bridge/adw-namespace.js +26 -0
  99. package/dist/gtkx/bridge/adw-namespace.js.map +1 -0
  100. package/dist/gtkx/bridge/adw.d.ts +23 -0
  101. package/dist/gtkx/bridge/adw.js +93 -0
  102. package/dist/gtkx/bridge/adw.js.map +1 -0
  103. package/dist/gtkx/bridge/color-scheme-parse.d.ts +11 -0
  104. package/dist/gtkx/bridge/color-scheme-parse.js +42 -0
  105. package/dist/gtkx/bridge/color-scheme-parse.js.map +1 -0
  106. package/dist/gtkx/bridge/color-scheme-portal.d.ts +24 -0
  107. package/dist/gtkx/bridge/color-scheme-portal.js +172 -0
  108. package/dist/gtkx/bridge/color-scheme-portal.js.map +1 -0
  109. package/dist/gtkx/bridge/core.d.ts +25 -0
  110. package/dist/gtkx/bridge/core.js +69 -0
  111. package/dist/gtkx/bridge/core.js.map +1 -0
  112. package/dist/gtkx/bridge/drag-layer.d.ts +27 -0
  113. package/dist/gtkx/bridge/drag-layer.js +177 -0
  114. package/dist/gtkx/bridge/drag-layer.js.map +1 -0
  115. package/dist/gtkx/bridge/index.d.ts +1 -27
  116. package/dist/gtkx/bridge/index.js +12 -71
  117. package/dist/gtkx/bridge/index.js.map +1 -1
  118. package/dist/gtkx/bridge/view-box.js +1 -1
  119. package/dist/gtkx/bridge/view-box.js.map +1 -1
  120. package/dist/gtkx/bridge/widgets.generated.adw.d.ts +1 -0
  121. package/dist/gtkx/bridge/widgets.generated.adw.js +16 -0
  122. package/dist/gtkx/bridge/widgets.generated.adw.js.map +1 -0
  123. package/dist/gtkx/bridge/widgets.generated.d.ts +0 -1
  124. package/dist/gtkx/bridge/widgets.generated.js +3 -3
  125. package/dist/gtkx/bridge/widgets.generated.js.map +1 -1
  126. package/dist/index.js +20 -0
  127. package/dist/index.js.map +1 -1
  128. package/dist/mcp/bin.js +1 -1
  129. package/dist/mcp/bin.js.map +1 -1
  130. package/dist/mcp/data/generated.d.ts +815 -481
  131. package/dist/mcp/data/generated.js +933 -513
  132. package/dist/mcp/data/generated.js.map +1 -1
  133. package/dist/mcp/resolve.d.ts +2 -2
  134. package/dist/mcp/resolve.js +2 -2
  135. package/dist/mcp/resolve.js.map +1 -1
  136. package/dist/mcp/server.js +2 -2
  137. package/dist/mcp/server.js.map +1 -1
  138. package/dist/metro/index.d.ts +1 -0
  139. package/dist/metro/index.js +12 -0
  140. package/dist/metro/index.js.map +1 -1
  141. package/dist/navigation/sidebar.js +2 -45
  142. package/dist/navigation/sidebar.js.map +1 -1
  143. package/dist/reanimated-compat/animatable-value.d.ts +158 -0
  144. package/dist/reanimated-compat/animatable-value.js +316 -0
  145. package/dist/reanimated-compat/animatable-value.js.map +1 -0
  146. package/dist/reanimated-compat/animation.d.ts +34 -13
  147. package/dist/reanimated-compat/animation.js +97 -25
  148. package/dist/reanimated-compat/animation.js.map +1 -1
  149. package/dist/reanimated-compat/mutable.js +6 -6
  150. package/dist/reanimated-compat/mutable.js.map +1 -1
  151. package/dist/reanimated-compat/updater-animations.js +32 -12
  152. package/dist/reanimated-compat/updater-animations.js.map +1 -1
  153. package/dist/runner/host-dev.js +5 -1
  154. package/dist/runner/host-dev.js.map +1 -1
  155. package/dist/runner/host.js +9 -1
  156. package/dist/runner/host.js.map +1 -1
  157. package/dist/sea/bundle.js +1 -1
  158. package/dist/sea/bundle.js.map +1 -1
  159. package/dist/sea/native-shim.js +3 -2
  160. package/dist/sea/native-shim.js.map +1 -1
  161. package/dist/vite/index.js +130 -0
  162. package/dist/vite/index.js.map +1 -1
  163. package/dist/vitest/index.d.ts +1 -1
  164. package/dist/vitest/index.js +1 -1
  165. package/dist/vitest/index.js.map +1 -1
  166. package/package.json +1 -1
  167. package/dist/gtkx/bridge/theme.d.ts +0 -4
  168. package/dist/gtkx/bridge/theme.js +0 -5
  169. package/dist/gtkx/bridge/theme.js.map +0 -1
@@ -49,7 +49,7 @@ type ResolveResult = ResolvedEntity | AmbiguousResult | NotFoundResult;
49
49
  */
50
50
  declare const resolveComponent: (query: string) => ResolveResult;
51
51
  /** Formats a resolved entity into the plain object the tool returns as
52
- * JSON text — one shape per kind, matching what docs/api.md and
53
- * docs/platform-layer.md actually document for it. */
52
+ * JSON text — one shape per kind, matching what docs/reference/ and
53
+ * docs/architecture/ actually document for it. */
54
54
  declare const formatEntity: (entity: Entity) => Record<string, unknown>;
55
55
  export { formatEntity, resolveComponent, type Candidate, type Entity, type ResolveResult, };
@@ -103,8 +103,8 @@ const resolveComponent = (query) => {
103
103
  return { status: "not-found", query: trimmed, suggestions };
104
104
  };
105
105
  /** Formats a resolved entity into the plain object the tool returns as
106
- * JSON text — one shape per kind, matching what docs/api.md and
107
- * docs/platform-layer.md actually document for it. */
106
+ * JSON text — one shape per kind, matching what docs/reference/ and
107
+ * docs/architecture/ actually document for it. */
108
108
  const formatEntity = (entity) => {
109
109
  switch (entity.kind) {
110
110
  case "portable-component":
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../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C,CAAC,CAAC;YAClB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;YAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;gBACzB,CAAC,CAAC,8KAA8K;gBAChL,CAAC,CAAC,yKAAyK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;YAChO,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,IAAI;aACL,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EACL,YAAY,EACZ,gBAAgB,GAIjB,CAAA","sourcesContent":["// Name resolution for rn_gtkx_describe_component: turns a free-form name\n// into exactly one of the surface's entities, or says clearly why it\n// could not (ambiguous vs. not-found) instead of guessing.\nimport {\n ADW_WIDGETS,\n COMMON_PRIMITIVES,\n GTK_WIDGETS,\n PORTABLE_APIS,\n PORTABLE_COMPONENTS,\n type CommonRecord,\n type PortableRecord,\n type WidgetRecord,\n} from \"./data/generated.js\"\n\ntype Entity =\n | { kind: \"portable-component\"; record: PortableRecord }\n | { kind: \"portable-api\"; record: PortableRecord }\n | { kind: \"common\"; record: CommonRecord }\n | { kind: \"gtk-widget\"; record: WidgetRecord }\n | { kind: \"adw-widget\"; record: WidgetRecord }\n\ntype Candidate = { name: string; subpath: string; kind: Entity[\"kind\"] }\n\ntype ResolvedEntity = {\n status: \"resolved\"\n entity: Entity\n matchedBy: \"exact\" | \"case-insensitive\" | \"prefix\" | \"substring\"\n}\ntype AmbiguousResult = {\n status: \"ambiguous\"\n query: string\n candidates: readonly Candidate[]\n}\ntype NotFoundResult = {\n status: \"not-found\"\n query: string\n suggestions: readonly Candidate[]\n}\ntype ResolveResult = ResolvedEntity | AmbiguousResult | NotFoundResult\n\nconst ALL_ENTITIES: readonly Entity[] = [\n ...PORTABLE_COMPONENTS.map((record): Entity => ({\n kind: \"portable-component\",\n record,\n })),\n ...PORTABLE_APIS.map((record): Entity => ({ kind: \"portable-api\", record })),\n ...COMMON_PRIMITIVES.map((record): Entity => ({ kind: \"common\", record })),\n ...GTK_WIDGETS.map((record): Entity => ({ kind: \"gtk-widget\", record })),\n ...ADW_WIDGETS.map((record): Entity => ({ kind: \"adw-widget\", record })),\n]\n\nconst candidateOf = (entity: Entity): Candidate => ({\n name: entity.record.name,\n subpath: entity.record.subpath,\n kind: entity.kind,\n})\n\n// Unweighted Levenshtein distance — 200-odd short names, no need for\n// anything fancier to rank \"closest known name\" suggestions.\nconst levenshtein = (a: string, b: string): number => {\n const rows = a.length + 1\n const cols = b.length + 1\n const dp: number[][] = Array.from({ length: rows }, () =>\n new Array<number>(cols).fill(0),\n )\n for (let i = 0; i < rows; i++) {\n dp[i]![0] = i\n }\n for (let j = 0; j < cols; j++) {\n dp[0]![j] = j\n }\n for (let i = 1; i < rows; i++) {\n for (let j = 1; j < cols; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n dp[i]![j] = Math.min(\n dp[i - 1]![j]! + 1,\n dp[i]![j - 1]! + 1,\n dp[i - 1]![j - 1]! + cost,\n )\n }\n }\n return dp[rows - 1]![cols - 1]!\n}\n\nconst MAX_CANDIDATES = 20\nconst MAX_SUGGESTIONS = 5\nconst PREFIXES = [\"Gtk\", \"Adw\"] as const\n\n/**\n * Resolves a free-form name to exactly one surface entity:\n * 1. exact match, then case-insensitive exact match;\n * 2. Gtk<name>/Adw<name> exact match — tried BEFORE substring search, so\n * \"Popover\" resolves cleanly to GtkPopover instead of landing ambiguous\n * against GtkPopoverBin/GtkPopoverMenu/GtkPopoverMenuBar too;\n * 3. substring search (case-insensitive): one hit resolves, several are\n * reported as ambiguous candidates (never guessed), zero fall through\n * to a not-found response with the closest known names by edit\n * distance.\n */\nconst resolveComponent = (query: string): ResolveResult => {\n const trimmed = query.trim()\n const lower = trimmed.toLowerCase()\n\n if (lower.length === 0) {\n return { status: \"not-found\", query: trimmed, suggestions: [] }\n }\n\n const exact = ALL_ENTITIES.find((e) => e.record.name === trimmed)\n if (exact) {\n return { status: \"resolved\", entity: exact, matchedBy: \"exact\" }\n }\n\n const caseInsensitive = ALL_ENTITIES.find(\n (e) => e.record.name.toLowerCase() === lower,\n )\n if (caseInsensitive) {\n return {\n status: \"resolved\",\n entity: caseInsensitive,\n matchedBy: \"case-insensitive\",\n }\n }\n\n if (!/^(gtk|adw)/i.test(trimmed)) {\n for (const prefix of PREFIXES) {\n const prefixedLower = `${prefix}${trimmed}`.toLowerCase()\n const match = ALL_ENTITIES.find(\n (e) => e.record.name.toLowerCase() === prefixedLower,\n )\n if (match) {\n return { status: \"resolved\", entity: match, matchedBy: \"prefix\" }\n }\n }\n }\n\n const substringMatches = ALL_ENTITIES.filter((e) =>\n e.record.name.toLowerCase().includes(lower),\n )\n if (substringMatches.length === 1) {\n return {\n status: \"resolved\",\n entity: substringMatches[0]!,\n matchedBy: \"substring\",\n }\n }\n if (substringMatches.length > 1) {\n return {\n status: \"ambiguous\",\n query: trimmed,\n candidates: substringMatches.slice(0, MAX_CANDIDATES).map(candidateOf),\n }\n }\n\n const suggestions = ALL_ENTITIES.map((entity) => ({\n entity,\n distance: levenshtein(lower, entity.record.name.toLowerCase()),\n }))\n .sort((a, b) => a.distance - b.distance)\n .slice(0, MAX_SUGGESTIONS)\n .map(({ entity }) => candidateOf(entity))\n\n return { status: \"not-found\", query: trimmed, suggestions }\n}\n\n/** Formats a resolved entity into the plain object the tool returns as\n * JSON text — one shape per kind, matching what docs/api.md and\n * docs/platform-layer.md actually document for it. */\nconst formatEntity = (entity: Entity): Record<string, unknown> => {\n switch (entity.kind) {\n case \"portable-component\":\n case \"portable-api\": {\n const record = entity.record\n return {\n kind: entity.kind,\n name: record.name,\n subpath: record.subpath,\n ...(record.gtkImplementation !== undefined\n ? { gtkImplementation: record.gtkImplementation }\n : {}),\n supported: record.supported,\n differences: record.differences,\n }\n }\n case \"common\": {\n const record = entity.record\n return {\n kind: entity.kind,\n name: record.name,\n subpath: record.subpath,\n summary: record.summary,\n }\n }\n case \"gtk-widget\":\n case \"adw-widget\": {\n const record = entity.record\n const note = record.wrapped\n ? \"Takes `style` + `onLayout`; React Native layout positions and styles it. Outside RN layout (e.g. inside an AdwHeaderBar slot) it steps aside and renders as the bare widget.\"\n : `Raw export — exactly as gtkx binds it, no \\`style\\`/\\`onLayout\\` (wrap it yourself with wrapReactNative from react-native-gtkx/gtk if you need RN layout to drive it).${record.reason ? ` Why raw: ${record.reason}` : \"\"}`\n return {\n kind: entity.kind,\n name: record.name,\n subpath: record.subpath,\n wrapped: record.wrapped,\n ...(record.reason !== undefined ? { reason: record.reason } : {}),\n note,\n }\n }\n }\n}\n\nexport {\n formatEntity,\n resolveComponent,\n type Candidate,\n type Entity,\n type ResolveResult,\n}\n"]}
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/mcp/resolve.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,qEAAqE;AACrE,2DAA2D;AAC3D,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,mBAAmB,GAIpB,MAAM,qBAAqB,CAAA;AA4B5B,MAAM,YAAY,GAAsB;IACtC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAU,EAAE,CAAC,CAAC;QAC9C,IAAI,EAAE,oBAAoB;QAC1B,MAAM;KACP,CAAC,CAAC;IACH,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM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,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,IAAI;aACL,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EACL,YAAY,EACZ,gBAAgB,GAIjB,CAAA","sourcesContent":["// Name resolution for rn_gtkx_describe_component: turns a free-form name\n// into exactly one of the surface's entities, or says clearly why it\n// could not (ambiguous vs. not-found) instead of guessing.\nimport {\n ADW_WIDGETS,\n COMMON_PRIMITIVES,\n GTK_WIDGETS,\n PORTABLE_APIS,\n PORTABLE_COMPONENTS,\n type CommonRecord,\n type PortableRecord,\n type WidgetRecord,\n} from \"./data/generated.js\"\n\ntype Entity =\n | { kind: \"portable-component\"; record: PortableRecord }\n | { kind: \"portable-api\"; record: PortableRecord }\n | { kind: \"common\"; record: CommonRecord }\n | { kind: \"gtk-widget\"; record: WidgetRecord }\n | { kind: \"adw-widget\"; record: WidgetRecord }\n\ntype Candidate = { name: string; subpath: string; kind: Entity[\"kind\"] }\n\ntype ResolvedEntity = {\n status: \"resolved\"\n entity: Entity\n matchedBy: \"exact\" | \"case-insensitive\" | \"prefix\" | \"substring\"\n}\ntype AmbiguousResult = {\n status: \"ambiguous\"\n query: string\n candidates: readonly Candidate[]\n}\ntype NotFoundResult = {\n status: \"not-found\"\n query: string\n suggestions: readonly Candidate[]\n}\ntype ResolveResult = ResolvedEntity | AmbiguousResult | NotFoundResult\n\nconst ALL_ENTITIES: readonly Entity[] = [\n ...PORTABLE_COMPONENTS.map((record): Entity => ({\n kind: \"portable-component\",\n record,\n })),\n ...PORTABLE_APIS.map((record): Entity => ({ kind: \"portable-api\", record })),\n ...COMMON_PRIMITIVES.map((record): Entity => ({ kind: \"common\", record })),\n ...GTK_WIDGETS.map((record): Entity => ({ kind: \"gtk-widget\", record })),\n ...ADW_WIDGETS.map((record): Entity => ({ kind: \"adw-widget\", record })),\n]\n\nconst candidateOf = (entity: Entity): Candidate => ({\n name: entity.record.name,\n subpath: entity.record.subpath,\n kind: entity.kind,\n})\n\n// Unweighted Levenshtein distance — 200-odd short names, no need for\n// anything fancier to rank \"closest known name\" suggestions.\nconst levenshtein = (a: string, b: string): number => {\n const rows = a.length + 1\n const cols = b.length + 1\n const dp: number[][] = Array.from({ length: rows }, () =>\n new Array<number>(cols).fill(0),\n )\n for (let i = 0; i < rows; i++) {\n dp[i]![0] = i\n }\n for (let j = 0; j < cols; j++) {\n dp[0]![j] = j\n }\n for (let i = 1; i < rows; i++) {\n for (let j = 1; j < cols; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n dp[i]![j] = Math.min(\n dp[i - 1]![j]! + 1,\n dp[i]![j - 1]! + 1,\n dp[i - 1]![j - 1]! + cost,\n )\n }\n }\n return dp[rows - 1]![cols - 1]!\n}\n\nconst MAX_CANDIDATES = 20\nconst MAX_SUGGESTIONS = 5\nconst PREFIXES = [\"Gtk\", \"Adw\"] as const\n\n/**\n * Resolves a free-form name to exactly one surface entity:\n * 1. exact match, then case-insensitive exact match;\n * 2. Gtk<name>/Adw<name> exact match — tried BEFORE substring search, so\n * \"Popover\" resolves cleanly to GtkPopover instead of landing ambiguous\n * against GtkPopoverBin/GtkPopoverMenu/GtkPopoverMenuBar too;\n * 3. substring search (case-insensitive): one hit resolves, several are\n * reported as ambiguous candidates (never guessed), zero fall through\n * to a not-found response with the closest known names by edit\n * distance.\n */\nconst resolveComponent = (query: string): ResolveResult => {\n const trimmed = query.trim()\n const lower = trimmed.toLowerCase()\n\n if (lower.length === 0) {\n return { status: \"not-found\", query: trimmed, suggestions: [] }\n }\n\n const exact = ALL_ENTITIES.find((e) => e.record.name === trimmed)\n if (exact) {\n return { status: \"resolved\", entity: exact, matchedBy: \"exact\" }\n }\n\n const caseInsensitive = ALL_ENTITIES.find(\n (e) => e.record.name.toLowerCase() === lower,\n )\n if (caseInsensitive) {\n return {\n status: \"resolved\",\n entity: caseInsensitive,\n matchedBy: \"case-insensitive\",\n }\n }\n\n if (!/^(gtk|adw)/i.test(trimmed)) {\n for (const prefix of PREFIXES) {\n const prefixedLower = `${prefix}${trimmed}`.toLowerCase()\n const match = ALL_ENTITIES.find(\n (e) => e.record.name.toLowerCase() === prefixedLower,\n )\n if (match) {\n return { status: \"resolved\", entity: match, matchedBy: \"prefix\" }\n }\n }\n }\n\n const substringMatches = ALL_ENTITIES.filter((e) =>\n e.record.name.toLowerCase().includes(lower),\n )\n if (substringMatches.length === 1) {\n return {\n status: \"resolved\",\n entity: substringMatches[0]!,\n matchedBy: \"substring\",\n }\n }\n if (substringMatches.length > 1) {\n return {\n status: \"ambiguous\",\n query: trimmed,\n candidates: substringMatches.slice(0, MAX_CANDIDATES).map(candidateOf),\n }\n }\n\n const suggestions = ALL_ENTITIES.map((entity) => ({\n entity,\n distance: levenshtein(lower, entity.record.name.toLowerCase()),\n }))\n .sort((a, b) => a.distance - b.distance)\n .slice(0, MAX_SUGGESTIONS)\n .map(({ entity }) => candidateOf(entity))\n\n return { status: \"not-found\", query: trimmed, suggestions }\n}\n\n/** Formats a resolved entity into the plain object the tool returns as\n * JSON text — one shape per kind, matching what docs/reference/ and\n * docs/architecture/ actually document for it. */\nconst formatEntity = (entity: Entity): Record<string, unknown> => {\n switch (entity.kind) {\n case \"portable-component\":\n case \"portable-api\": {\n const record = entity.record\n return {\n kind: entity.kind,\n name: record.name,\n subpath: record.subpath,\n ...(record.gtkImplementation !== undefined\n ? { gtkImplementation: record.gtkImplementation }\n : {}),\n supported: record.supported,\n differences: record.differences,\n }\n }\n case \"common\": {\n const record = entity.record\n return {\n kind: entity.kind,\n name: record.name,\n subpath: record.subpath,\n summary: record.summary,\n }\n }\n case \"gtk-widget\":\n case \"adw-widget\": {\n const record = entity.record\n const note = record.wrapped\n ? \"Takes `style` + `onLayout`; React Native layout positions and styles it. Outside RN layout (e.g. inside an AdwHeaderBar slot) it steps aside and renders as the bare widget.\"\n : `Raw export — exactly as gtkx binds it, no \\`style\\`/\\`onLayout\\` (wrap it yourself with wrapReactNative from react-native-gtkx/gtk if you need RN layout to drive it).${record.reason ? ` Why raw: ${record.reason}` : \"\"}`\n return {\n kind: entity.kind,\n name: record.name,\n subpath: record.subpath,\n wrapped: record.wrapped,\n ...(record.reason !== undefined ? { reason: record.reason } : {}),\n note,\n }\n }\n }\n}\n\nexport {\n formatEntity,\n resolveComponent,\n type Candidate,\n type Entity,\n type ResolveResult,\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  // generated data in ./data/generated.ts — no @gtkx/* import anywhere in
3
3
  // this module or its dependents, so this runs on any OS without GTK
4
4
  // installed (an agent reading a react-native-gtkx project on a Mac, for
5
- // instance). See docs/getting-started.md for how a consumer registers it.
5
+ // instance). See docs/guide/toolchains.md for how a consumer registers it.
6
6
  import { createRequire } from "node:module";
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -97,7 +97,7 @@ const describeComponentTool = () => defineTool({
97
97
  const searchDocsTool = () => defineTool({
98
98
  name: "rn_gtkx_search_docs",
99
99
  title: "Search react-native-gtkx docs",
100
- description: "Free-text search over the docs (getting-started, the platform layer, " +
100
+ description: "Free-text search over the docs (the guide, the platform layer, " +
101
101
  "gtkx rc.3 workarounds/quirks, navigation). The fallback tool: use it " +
102
102
  "for symptoms and known-issue questions that rn_gtkx_describe_component " +
103
103
  "cannot answer by name (workarounds are keyed by mechanism, not by " +
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wEAAwE;AACxE,oEAAoE;AACpE,wEAAwE;AACxE,0EAA0E;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,oBAAoB,E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,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;aACrD,IAAI,CAAC,aAAa,CAAC,CAAA;QACtB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACF,CAAC,CAAA;AAEJ,MAAM,UAAU,GAAG,GAAW,EAAE,CAAC;IAC/B,eAAe,EAAE;IACjB,qBAAqB,EAAE;IACvB,cAAc,EAAE;CACjB,CAAA;AAED,MAAM,eAAe,GAAG,GAAc,EAAE;IACtC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAA;IAC5D,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,EAAE,CAAC;QAChC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC5B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IACrC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAChC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA","sourcesContent":["// The MCP server itself: three tools over stdio, backed entirely by the\n// generated data in ./data/generated.ts — no @gtkx/* import anywhere in\n// this module or its dependents, so this runs on any OS without GTK\n// installed (an agent reading a react-native-gtkx project on a Mac, for\n// instance). See docs/getting-started.md for how a consumer registers it.\nimport { createRequire } from \"node:module\"\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\nimport { z } from \"zod\"\nimport { listSurface, SURFACE_AREAS } from \"./list.js\"\nimport { formatEntity, resolveComponent } from \"./resolve.js\"\nimport { searchDocs } from \"./search.js\"\nimport {\n defineTool,\n registerTool,\n textContent,\n textError,\n type Tool,\n} from \"./tool.js\"\n\nconst require = createRequire(import.meta.url)\n// Package root is two levels up from dist/mcp/server.js (dist/mcp -> dist\n// -> package root). package.json ships in every npm tarball regardless of\n// the \"files\" allowlist, so this needs no extra packaging step.\nconst { version } = require(\"../../package.json\") as { version: string }\n\nconst SERVER_NAME = \"react-native-gtkx-mcp\"\nconst DEFAULT_SEARCH_LIMIT = 10\nconst MAX_SEARCH_LIMIT = 20\n\nconst listSurfaceShape = {\n area: z\n .enum(SURFACE_AREAS)\n .optional()\n .describe(\n \"Area to list. Omit for an overview with counts across all areas: \" +\n SURFACE_AREAS.join(\", \") +\n \".\",\n ),\n}\n\nconst describeComponentShape = {\n name: z\n .string()\n .describe(\n \"A component/API/widget name: a portable react-native export (e.g. \" +\n '\"FlatList\"), a react-native-gtkx/gtk or /adw widget with or ' +\n 'without its Gtk/Adw prefix (e.g. \"Popover\" resolves to ' +\n '\"GtkPopover\"), or a react-native-gtkx/common export (e.g. ' +\n '\"NavigationStack\"). Case-insensitive.',\n ),\n}\n\nconst searchDocsShape = {\n query: z\n .string()\n .describe(\n \"Free-text query — a symptom, a GTK term, an option name. Use this \" +\n \"when rn_gtkx_describe_component does not have a name to look up, \" +\n 'e.g. \"known issues\", \"chrome content\", \"windowSize\".',\n ),\n limit: z\n .number()\n .int()\n .min(1)\n .max(MAX_SEARCH_LIMIT)\n .optional()\n .describe(\n `Maximum number of results (default ${DEFAULT_SEARCH_LIMIT}, max ${MAX_SEARCH_LIMIT}).`,\n ),\n}\n\nconst listSurfaceTool = (): Tool =>\n defineTool({\n name: \"rn_gtkx_list_surface\",\n title: \"List the react-native-gtkx surface\",\n description:\n \"Browse the react-native-gtkx surface without knowing an exact name first: \" +\n \"portable react-native components/APIs, the react-native-gtkx/gtk and \" +\n \"/adw widget lists (wrapped vs. raw), and react-native-gtkx/common. \" +\n \"Without `area`, returns counts and where to look next.\",\n inputSchema: listSurfaceShape,\n handler: ({ area }) => textContent(listSurface(area)),\n })\n\nconst describeComponentTool = (): Tool =>\n defineTool({\n name: \"rn_gtkx_describe_component\",\n title: \"Describe a react-native-gtkx component\",\n description:\n \"Look up one component/widget/API by name: does it exist, which \" +\n \"subpath it is exported from, what GTK widget backs it (for \" +\n \"portable components), what differs from React Native, and whether \" +\n \"a gtk/adw widget is wrapped (takes `style`/`onLayout`) or raw. The \" +\n \"single most useful tool here — start with this before \" +\n \"rn_gtkx_search_docs.\",\n inputSchema: describeComponentShape,\n handler: ({ name }) => {\n const result = resolveComponent(name)\n if (result.status === \"resolved\") {\n const body = {\n matchedBy: result.matchedBy,\n ...formatEntity(result.entity),\n }\n return textContent(JSON.stringify(body, null, 2))\n }\n if (result.status === \"ambiguous\") {\n const lines = result.candidates\n .map((c) => `- ${c.name} (${c.subpath}, ${c.kind})`)\n .join(\"\\n\")\n return textError(\n `\"${result.query}\" matches ${result.candidates.length} names — call again with one of:\\n${lines}`,\n )\n }\n const lines = result.suggestions\n .map((c) => `- ${c.name} (${c.subpath}, ${c.kind})`)\n .join(\"\\n\")\n return textError(\n `No component named \"${result.query}\".` +\n (lines.length > 0\n ? ` Closest known names:\\n${lines}`\n : \" rn_gtkx_list_surface has the full index.\"),\n )\n },\n })\n\nconst searchDocsTool = (): Tool =>\n defineTool({\n name: \"rn_gtkx_search_docs\",\n title: \"Search react-native-gtkx docs\",\n description:\n \"Free-text search over the docs (getting-started, the platform layer, \" +\n \"gtkx rc.3 workarounds/quirks, navigation). The fallback tool: use it \" +\n \"for symptoms and known-issue questions that rn_gtkx_describe_component \" +\n \"cannot answer by name (workarounds are keyed by mechanism, not by \" +\n \"component).\",\n inputSchema: searchDocsShape,\n handler: ({ query, limit }) => {\n const results = searchDocs(query, limit ?? DEFAULT_SEARCH_LIMIT)\n if (results.length === 0) {\n return textContent(\n `No matches for \"${query}\". Try rn_gtkx_list_surface or rn_gtkx_describe_component instead.`,\n )\n }\n const body = results\n .map((r) => `## ${r.doc} — ${r.heading}\\n\\n${r.text}`)\n .join(\"\\n\\n---\\n\\n\")\n return textContent(body)\n },\n })\n\nconst buildTools = (): Tool[] => [\n listSurfaceTool(),\n describeComponentTool(),\n searchDocsTool(),\n]\n\nconst createMcpServer = (): McpServer => {\n const server = new McpServer({ name: SERVER_NAME, version })\n for (const tool of buildTools()) {\n registerTool(server, tool)\n }\n return server\n}\n\nconst main = async (): Promise<void> => {\n const server = createMcpServer()\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\nexport { buildTools, createMcpServer, main, SERVER_NAME }\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wEAAwE;AACxE,oEAAoE;AACpE,wEAAwE;AACxE,2EAA2E;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,GAEV,MAAM,WAAW,CAAA;AAElB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,0EAA0E;AAC1E,0EAA0E;AAC1E,gEAAgE;AAChE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAwB,CAAA;AAExE,MAAM,WAAW,GAAG,uBAAuB,CAAA;AAC3C,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAC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mB,EAAE;IACrC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAChC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA","sourcesContent":["// The MCP server itself: three tools over stdio, backed entirely by the\n// generated data in ./data/generated.ts — no @gtkx/* import anywhere in\n// this module or its dependents, so this runs on any OS without GTK\n// installed (an agent reading a react-native-gtkx project on a Mac, for\n// instance). See docs/guide/toolchains.md for how a consumer registers it.\nimport { createRequire } from \"node:module\"\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\nimport { z } from \"zod\"\nimport { listSurface, SURFACE_AREAS } from \"./list.js\"\nimport { formatEntity, resolveComponent } from \"./resolve.js\"\nimport { searchDocs } from \"./search.js\"\nimport {\n defineTool,\n registerTool,\n textContent,\n textError,\n type Tool,\n} from \"./tool.js\"\n\nconst require = createRequire(import.meta.url)\n// Package root is two levels up from dist/mcp/server.js (dist/mcp -> dist\n// -> package root). package.json ships in every npm tarball regardless of\n// the \"files\" allowlist, so this needs no extra packaging step.\nconst { version } = require(\"../../package.json\") as { version: string }\n\nconst SERVER_NAME = \"react-native-gtkx-mcp\"\nconst DEFAULT_SEARCH_LIMIT = 10\nconst MAX_SEARCH_LIMIT = 20\n\nconst listSurfaceShape = {\n area: z\n .enum(SURFACE_AREAS)\n .optional()\n .describe(\n \"Area to list. Omit for an overview with counts across all areas: \" +\n SURFACE_AREAS.join(\", \") +\n \".\",\n ),\n}\n\nconst describeComponentShape = {\n name: z\n .string()\n .describe(\n \"A component/API/widget name: a portable react-native export (e.g. \" +\n '\"FlatList\"), a react-native-gtkx/gtk or /adw widget with or ' +\n 'without its Gtk/Adw prefix (e.g. \"Popover\" resolves to ' +\n '\"GtkPopover\"), or a react-native-gtkx/common export (e.g. ' +\n '\"NavigationStack\"). Case-insensitive.',\n ),\n}\n\nconst searchDocsShape = {\n query: z\n .string()\n .describe(\n \"Free-text query — a symptom, a GTK term, an option name. Use this \" +\n \"when rn_gtkx_describe_component does not have a name to look up, \" +\n 'e.g. \"known issues\", \"chrome content\", \"windowSize\".',\n ),\n limit: z\n .number()\n .int()\n .min(1)\n .max(MAX_SEARCH_LIMIT)\n .optional()\n .describe(\n `Maximum number of results (default ${DEFAULT_SEARCH_LIMIT}, max ${MAX_SEARCH_LIMIT}).`,\n ),\n}\n\nconst listSurfaceTool = (): Tool =>\n defineTool({\n name: \"rn_gtkx_list_surface\",\n title: \"List the react-native-gtkx surface\",\n description:\n \"Browse the react-native-gtkx surface without knowing an exact name first: \" +\n \"portable react-native components/APIs, the react-native-gtkx/gtk and \" +\n \"/adw widget lists (wrapped vs. raw), and react-native-gtkx/common. \" +\n \"Without `area`, returns counts and where to look next.\",\n inputSchema: listSurfaceShape,\n handler: ({ area }) => textContent(listSurface(area)),\n })\n\nconst describeComponentTool = (): Tool =>\n defineTool({\n name: \"rn_gtkx_describe_component\",\n title: \"Describe a react-native-gtkx component\",\n description:\n \"Look up one component/widget/API by name: does it exist, which \" +\n \"subpath it is exported from, what GTK widget backs it (for \" +\n \"portable components), what differs from React Native, and whether \" +\n \"a gtk/adw widget is wrapped (takes `style`/`onLayout`) or raw. The \" +\n \"single most useful tool here — start with this before \" +\n \"rn_gtkx_search_docs.\",\n inputSchema: describeComponentShape,\n handler: ({ name }) => {\n const result = resolveComponent(name)\n if (result.status === \"resolved\") {\n const body = {\n matchedBy: result.matchedBy,\n ...formatEntity(result.entity),\n }\n return textContent(JSON.stringify(body, null, 2))\n }\n if (result.status === \"ambiguous\") {\n const lines = result.candidates\n .map((c) => `- ${c.name} (${c.subpath}, ${c.kind})`)\n .join(\"\\n\")\n return textError(\n `\"${result.query}\" matches ${result.candidates.length} names — call again with one of:\\n${lines}`,\n )\n }\n const lines = result.suggestions\n .map((c) => `- ${c.name} (${c.subpath}, ${c.kind})`)\n .join(\"\\n\")\n return textError(\n `No component named \"${result.query}\".` +\n (lines.length > 0\n ? ` Closest known names:\\n${lines}`\n : \" rn_gtkx_list_surface has the full index.\"),\n )\n },\n })\n\nconst searchDocsTool = (): Tool =>\n defineTool({\n name: \"rn_gtkx_search_docs\",\n title: \"Search react-native-gtkx docs\",\n description:\n \"Free-text search over the docs (the guide, the platform layer, \" +\n \"gtkx rc.3 workarounds/quirks, navigation). The fallback tool: use it \" +\n \"for symptoms and known-issue questions that rn_gtkx_describe_component \" +\n \"cannot answer by name (workarounds are keyed by mechanism, not by \" +\n \"component).\",\n inputSchema: searchDocsShape,\n handler: ({ query, limit }) => {\n const results = searchDocs(query, limit ?? DEFAULT_SEARCH_LIMIT)\n if (results.length === 0) {\n return textContent(\n `No matches for \"${query}\". Try rn_gtkx_list_surface or rn_gtkx_describe_component instead.`,\n )\n }\n const body = results\n .map((r) => `## ${r.doc} — ${r.heading}\\n\\n${r.text}`)\n .join(\"\\n\\n---\\n\\n\")\n return textContent(body)\n },\n })\n\nconst buildTools = (): Tool[] => [\n listSurfaceTool(),\n describeComponentTool(),\n searchDocsTool(),\n]\n\nconst createMcpServer = (): McpServer => {\n const server = new McpServer({ name: SERVER_NAME, version })\n for (const tool of buildTools()) {\n registerTool(server, tool)\n }\n return server\n}\n\nconst main = async (): Promise<void> => {\n const server = createMcpServer()\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\nexport { buildTools, createMcpServer, main, SERVER_NAME }\n"]}
@@ -3,6 +3,7 @@ export { CONFIGURABLE_ALIASES, DEFAULT_ALIASES, PLATFORM_ALIAS, } from "../alias
3
3
  export type { AliasOverride, AliasOverrides, AliasPattern, AliasTable, CompiledAlias, } from "../aliases/index.js";
4
4
  /** Modules the run-linux host provides to the bundle at runtime. */
5
5
  export declare const HOST_MODULE_EXTERNALS: string[];
6
+ export declare const OPTIONAL_HOST_MODULE_EXTERNALS: Set<string>;
6
7
  export declare const LINUX_PLATFORM = "linux";
7
8
  export type MetroResolutionContext = {
8
9
  resolveRequest: MetroResolver;
@@ -54,6 +54,18 @@ export const HOST_MODULE_EXTERNALS = [
54
54
  "react/jsx-dev-runtime",
55
55
  "yoga-layout",
56
56
  ];
57
+ // Present in the codegen store only when the app's gtkx.config.ts declares
58
+ // "Adw-1" (see .claude/epics/adw-optional/001.md — the plain-GTK profile).
59
+ // Still generated a proxy unconditionally, same as every other external
60
+ // above (so an app that later adds "Adw-1" needs no Metro config change) —
61
+ // but the runner (../runner/host.ts, ../runner/host-dev.ts) must not treat
62
+ // EITHER one failing to load as fatal the way it does for the rest of this
63
+ // list: that failure is the expected, normal shape of a plain-GTK app, not
64
+ // a broken install.
65
+ export const OPTIONAL_HOST_MODULE_EXTERNALS = new Set([
66
+ "@gtkx/gi/adw",
67
+ "@gtkx/jsx/adw",
68
+ ]);
57
69
  export const LINUX_PLATFORM = "linux";
58
70
  const sanitize = (name) => name.replace(/[@/:]/g, "_") + ".js";
59
71
  const hostModuleProxy = (name) =>
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metro/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,sBAAsB;AACtB,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,qEAAqE;AACrE,sCAAsC;AACtC,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,+CAA+C;AAC/C,oEAAoE;AACpE,oEAAoE;AACpE,2EAA2E;AAC3E,wDAAwD;AACxD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAA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B,EAAE,GAAG,EAAE,CAAC,EAAE;SACxC;KACwB,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// Metro preset for the linux out-of-tree platform: wrap the app's Metro\n// config with `withLinuxPlatform` and the standard RN toolchain bundles for\n// `--platform linux`.\n//\n// What it does on top of RN defaults (validated by spike/rn-platform):\n//\n// 1. Adds \"linux\" to resolver.platforms (`.linux.tsx` extensions and\n// Platform.OS come along with it).\n// 2. Redirects `react-native` (and subpaths) to `react-native-gtkx` — the\n// out-of-tree npmPackageName declaration alone does not alias imports\n// for `bundle`, the resolver has to — plus five package substitutions\n// for libraries whose real implementation cannot run here. The rules\n// are data, shared with the vite preset: see ../aliases/index.ts.\n// 3. EXTERNALIZES host-side singletons. Unlike react-native-windows, whose\n// native side lives outside the JS bundle by construction, our \"native\"\n// is Node modules with NAPI bindings (@gtkx/*) plus yoga-layout's WASM —\n// Metro cannot bundle those. react (and its jsx runtimes) must also stay\n// host-side: the reconciler inside @gtkx/react and the app have to share\n// one React instance. Every external resolves to a generated proxy that\n// reads the real module from global.__hostModules — the run-linux host\n// injects them before executing the bundle.\n// 4. Proxies Node builtins through the host's require: apps on this\n// platform may use the whole Node API, it is a platform feature.\n// 5. Drops InitializeCore (RN's mobile environment polyfills): the runtime\n// environment IS Node, the host provides everything.\nimport { mkdirSync, writeFileSync } from \"node:fs\"\nimport { builtinModules, isBuiltin } from \"node:module\"\nimport { join } from \"node:path\"\n// Explicit .js: bare Node loads metro.config.ts and does not guess extensions.\nimport {\n applyAliases,\n compileAliases,\n type AliasOverrides,\n} from \"../aliases/index.js\"\n\n// Re-exported so an app configuring `aliases` never has to reach past the\n// preset subpath it already imports.\nexport {\n CONFIGURABLE_ALIASES,\n DEFAULT_ALIASES,\n PLATFORM_ALIAS,\n} from \"../aliases/index.js\"\nexport type {\n AliasOverride,\n AliasOverrides,\n AliasPattern,\n AliasTable,\n CompiledAlias,\n} from \"../aliases/index.js\"\n\n/** Modules the run-linux host provides to the bundle at runtime. */\nexport const HOST_MODULE_EXTERNALS = [\n \"@gtkx/css\",\n \"@gtkx/gi/adw\",\n \"@gtkx/gi/gdk\",\n \"@gtkx/gi/gio\",\n \"@gtkx/gi/glib\",\n \"@gtkx/gi/gobject\",\n \"@gtkx/gi/graphene\",\n \"@gtkx/gi/gsk\",\n \"@gtkx/gi/gtk\",\n \"@gtkx/gi/pango\",\n \"@gtkx/jsx/adw\",\n \"@gtkx/jsx/gio\",\n \"@gtkx/jsx/gtk\",\n \"@gtkx/react\",\n \"@gtkx/react/internal\",\n \"@gtkx/runtime\",\n \"react\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"yoga-layout\",\n]\n\nexport const LINUX_PLATFORM = \"linux\"\n\n// Structural slices of Metro's config/resolution types: Metro is the app's\n// dependency, not ours — depending on its types here would pin versions.\nexport type MetroResolutionContext = {\n resolveRequest: MetroResolver\n}\nexport type MetroResolution = { type: string; filePath?: string }\nexport type MetroResolver = (\n context: MetroResolutionContext,\n moduleName: string,\n platform: string | null,\n) => MetroResolution\n\nexport type MetroLikeConfig = {\n projectRoot?: string\n resolver?: {\n platforms?: readonly string[]\n resolveRequest?: MetroResolver | null\n }\n serializer?: {\n getModulesRunBeforeMainModule?: (entryFilePath: string) => string[]\n }\n}\n\nexport type LinuxPlatformOptions = {\n /** Extra host-provided modules to keep out of the bundle. */\n externals?: readonly string[]\n /** Proxy directory override (default: node_modules/.react-native-gtkx). */\n proxyDir?: string\n /**\n * Deltas over the preset's package aliases, keyed by package name — a\n * string target, a `{ pattern, replace }` rule, or `false` to drop one of\n * ours so the real package loads. See ../aliases/index.ts and docs/api.md.\n * Invalid entries throw here, while the config is being read.\n */\n aliases?: AliasOverrides\n}\n\nconst sanitize = (name: string): string => name.replace(/[@/:]/g, \"_\") + \".js\"\n\nconst hostModuleProxy = (name: string): string =>\n // The run-linux host guarantees __hostModules before executing the bundle.\n `module.exports = global.__hostModules[${JSON.stringify(name)}]\\n`\n\nconst builtinProxy = (name: string): string =>\n `module.exports = global.__hostRequire(${JSON.stringify(name)})\\n`\n\n// Every proxy is generated eagerly when the config loads: Metro crawls the\n// file map before transforming, and files that appear mid-build lose the\n// race (\"Failed to get the SHA-1\"). The builtin list is finite, so the\n// whole proxy set can exist up front.\nconst generateProxies = (dir: string, externals: Set<string>): void => {\n mkdirSync(dir, { recursive: true })\n for (const name of externals) {\n writeFileSync(join(dir, sanitize(name)), hostModuleProxy(name))\n }\n for (const bare of builtinModules) {\n writeFileSync(join(dir, sanitize(bare)), builtinProxy(bare))\n writeFileSync(\n join(dir, sanitize(`node:${bare}`)),\n builtinProxy(`node:${bare}`),\n )\n }\n}\n\nexport type LinuxPlatformConfig<T extends MetroLikeConfig> = T & {\n resolver: {\n platforms: string[]\n resolveRequest: MetroResolver\n }\n serializer: {\n getModulesRunBeforeMainModule: (entryFilePath: string) => string[]\n }\n}\n\n/**\n * Wraps a Metro config (RN's getDefaultConfig output) with everything the\n * linux platform needs. Composes with an existing custom resolveRequest —\n * non-linux platforms fall through to it untouched.\n */\nexport const withLinuxPlatform = <T extends MetroLikeConfig>(\n config: T,\n options: LinuxPlatformOptions = {},\n): LinuxPlatformConfig<T> => {\n const externals = new Set([\n ...HOST_MODULE_EXTERNALS,\n ...(options.externals ?? []),\n ])\n const proxyDir =\n options.proxyDir ??\n join(\n config.projectRoot ?? process.cwd(),\n \"node_modules\",\n \".react-native-gtkx\",\n \"metro-externals\",\n )\n generateProxies(proxyDir, externals)\n // Throws on an unknown key, an overlapping pattern or an attempt to remove\n // the platform alias — at config load, naming what is valid.\n const aliases = compileAliases(options.aliases)\n const previousResolve = config.resolver?.resolveRequest ?? null\n\n const fallback: MetroResolver = (context, moduleName, platform) =>\n previousResolve\n ? previousResolve(context, moduleName, platform)\n : context.resolveRequest(context, moduleName, platform)\n\n const resolveRequest: MetroResolver = (context, moduleName, platform) => {\n if (platform !== LINUX_PLATFORM) {\n return fallback(context, moduleName, platform)\n }\n if (externals.has(moduleName) || isBuiltin(moduleName)) {\n return {\n type: \"sourceFile\",\n filePath: join(proxyDir, sanitize(moduleName)),\n }\n }\n // The five package substitutions plus the platform alias, from the table\n // both presets share (../aliases/index.ts). Each rule is anchored to its\n // package name and matches the exact name or a slash-prefixed subpath,\n // with the tail transplanted onto the target — the guard, not just the\n // order, is what keeps `react-native-reanimated-dnd` out of the\n // `react-native-reanimated` rule and the real, unrelated\n // `react-native-worklets-core` out of the `react-native-worklets` one.\n const aliased = applyAliases(aliases, moduleName)\n if (aliased !== null) {\n return fallback(context, aliased, platform)\n }\n return fallback(context, moduleName, platform)\n }\n\n // The cast: T may carry narrower resolver/serializer types than the ones\n // rebuilt here — the runtime shape is a strict superset of both.\n return {\n ...config,\n resolver: {\n ...config.resolver,\n platforms: [\n ...new Set([...(config.resolver?.platforms ?? []), LINUX_PLATFORM]),\n ],\n resolveRequest,\n },\n serializer: {\n ...config.serializer,\n // RN prepends InitializeCore (Hermes Promise, nativeLoggingHook\n // console...). Our runtime environment IS Node — nothing to\n // initialize inside the bundle.\n getModulesRunBeforeMainModule: () => [],\n },\n } as LinuxPlatformConfig<T>\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metro/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,sBAAsB;AACtB,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,qEAAqE;AACrE,sCAAsC;AACtC,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,+CAA+C;AAC/C,oEAAoE;AACpE,oEAAoE;AACpE,2EAA2E;AAC3E,wDAAwD;AACxD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa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AAG,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;aACpE;YACD,cAAc;SACf;QACD,UAAU,EAAE;YACV,GAAG,MAAM,CAAC,UAAU;YACpB,gEAAgE;YAChE,4DAA4D;YAC5D,gCAAgC;YAChC,6BAA6B,EAAE,GAAG,EAAE,CAAC,EAAE;SACxC;KACwB,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// Metro preset for the linux out-of-tree platform: wrap the app's Metro\n// config with `withLinuxPlatform` and the standard RN toolchain bundles for\n// `--platform linux`.\n//\n// What it does on top of RN defaults (validated by spike/rn-platform):\n//\n// 1. Adds \"linux\" to resolver.platforms (`.linux.tsx` extensions and\n// Platform.OS come along with it).\n// 2. Redirects `react-native` (and subpaths) to `react-native-gtkx` — the\n// out-of-tree npmPackageName declaration alone does not alias imports\n// for `bundle`, the resolver has to — plus five package substitutions\n// for libraries whose real implementation cannot run here. The rules\n// are data, shared with the vite preset: see ../aliases/index.ts.\n// 3. EXTERNALIZES host-side singletons. Unlike react-native-windows, whose\n// native side lives outside the JS bundle by construction, our \"native\"\n// is Node modules with NAPI bindings (@gtkx/*) plus yoga-layout's WASM —\n// Metro cannot bundle those. react (and its jsx runtimes) must also stay\n// host-side: the reconciler inside @gtkx/react and the app have to share\n// one React instance. Every external resolves to a generated proxy that\n// reads the real module from global.__hostModules — the run-linux host\n// injects them before executing the bundle.\n// 4. Proxies Node builtins through the host's require: apps on this\n// platform may use the whole Node API, it is a platform feature.\n// 5. Drops InitializeCore (RN's mobile environment polyfills): the runtime\n// environment IS Node, the host provides everything.\nimport { mkdirSync, writeFileSync } from \"node:fs\"\nimport { builtinModules, isBuiltin } from \"node:module\"\nimport { join } from \"node:path\"\n// Explicit .js: bare Node loads metro.config.ts and does not guess extensions.\nimport {\n applyAliases,\n compileAliases,\n type AliasOverrides,\n} from \"../aliases/index.js\"\n\n// Re-exported so an app configuring `aliases` never has to reach past the\n// preset subpath it already imports.\nexport {\n CONFIGURABLE_ALIASES,\n DEFAULT_ALIASES,\n PLATFORM_ALIAS,\n} from \"../aliases/index.js\"\nexport type {\n AliasOverride,\n AliasOverrides,\n AliasPattern,\n AliasTable,\n CompiledAlias,\n} from \"../aliases/index.js\"\n\n/** Modules the run-linux host provides to the bundle at runtime. */\nexport const HOST_MODULE_EXTERNALS = [\n \"@gtkx/css\",\n \"@gtkx/gi/adw\",\n \"@gtkx/gi/gdk\",\n \"@gtkx/gi/gio\",\n \"@gtkx/gi/glib\",\n \"@gtkx/gi/gobject\",\n \"@gtkx/gi/graphene\",\n \"@gtkx/gi/gsk\",\n \"@gtkx/gi/gtk\",\n \"@gtkx/gi/pango\",\n \"@gtkx/jsx/adw\",\n \"@gtkx/jsx/gio\",\n \"@gtkx/jsx/gtk\",\n \"@gtkx/react\",\n \"@gtkx/react/internal\",\n \"@gtkx/runtime\",\n \"react\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"yoga-layout\",\n]\n\n// Present in the codegen store only when the app's gtkx.config.ts declares\n// \"Adw-1\" (see .claude/epics/adw-optional/001.md — the plain-GTK profile).\n// Still generated a proxy unconditionally, same as every other external\n// above (so an app that later adds \"Adw-1\" needs no Metro config change) —\n// but the runner (../runner/host.ts, ../runner/host-dev.ts) must not treat\n// EITHER one failing to load as fatal the way it does for the rest of this\n// list: that failure is the expected, normal shape of a plain-GTK app, not\n// a broken install.\nexport const OPTIONAL_HOST_MODULE_EXTERNALS = new Set<string>([\n \"@gtkx/gi/adw\",\n \"@gtkx/jsx/adw\",\n])\n\nexport const LINUX_PLATFORM = \"linux\"\n\n// Structural slices of Metro's config/resolution types: Metro is the app's\n// dependency, not ours — depending on its types here would pin versions.\nexport type MetroResolutionContext = {\n resolveRequest: MetroResolver\n}\nexport type MetroResolution = { type: string; filePath?: string }\nexport type MetroResolver = (\n context: MetroResolutionContext,\n moduleName: string,\n platform: string | null,\n) => MetroResolution\n\nexport type MetroLikeConfig = {\n projectRoot?: string\n resolver?: {\n platforms?: readonly string[]\n resolveRequest?: MetroResolver | null\n }\n serializer?: {\n getModulesRunBeforeMainModule?: (entryFilePath: string) => string[]\n }\n}\n\nexport type LinuxPlatformOptions = {\n /** Extra host-provided modules to keep out of the bundle. */\n externals?: readonly string[]\n /** Proxy directory override (default: node_modules/.react-native-gtkx). */\n proxyDir?: string\n /**\n * Deltas over the preset's package aliases, keyed by package name — a\n * string target, a `{ pattern, replace }` rule, or `false` to drop one of\n * ours so the real package loads. See ../aliases/index.ts and docs/api.md.\n * Invalid entries throw here, while the config is being read.\n */\n aliases?: AliasOverrides\n}\n\nconst sanitize = (name: string): string => name.replace(/[@/:]/g, \"_\") + \".js\"\n\nconst hostModuleProxy = (name: string): string =>\n // The run-linux host guarantees __hostModules before executing the bundle.\n `module.exports = global.__hostModules[${JSON.stringify(name)}]\\n`\n\nconst builtinProxy = (name: string): string =>\n `module.exports = global.__hostRequire(${JSON.stringify(name)})\\n`\n\n// Every proxy is generated eagerly when the config loads: Metro crawls the\n// file map before transforming, and files that appear mid-build lose the\n// race (\"Failed to get the SHA-1\"). The builtin list is finite, so the\n// whole proxy set can exist up front.\nconst generateProxies = (dir: string, externals: Set<string>): void => {\n mkdirSync(dir, { recursive: true })\n for (const name of externals) {\n writeFileSync(join(dir, sanitize(name)), hostModuleProxy(name))\n }\n for (const bare of builtinModules) {\n writeFileSync(join(dir, sanitize(bare)), builtinProxy(bare))\n writeFileSync(\n join(dir, sanitize(`node:${bare}`)),\n builtinProxy(`node:${bare}`),\n )\n }\n}\n\nexport type LinuxPlatformConfig<T extends MetroLikeConfig> = T & {\n resolver: {\n platforms: string[]\n resolveRequest: MetroResolver\n }\n serializer: {\n getModulesRunBeforeMainModule: (entryFilePath: string) => string[]\n }\n}\n\n/**\n * Wraps a Metro config (RN's getDefaultConfig output) with everything the\n * linux platform needs. Composes with an existing custom resolveRequest —\n * non-linux platforms fall through to it untouched.\n */\nexport const withLinuxPlatform = <T extends MetroLikeConfig>(\n config: T,\n options: LinuxPlatformOptions = {},\n): LinuxPlatformConfig<T> => {\n const externals = new Set([\n ...HOST_MODULE_EXTERNALS,\n ...(options.externals ?? []),\n ])\n const proxyDir =\n options.proxyDir ??\n join(\n config.projectRoot ?? process.cwd(),\n \"node_modules\",\n \".react-native-gtkx\",\n \"metro-externals\",\n )\n generateProxies(proxyDir, externals)\n // Throws on an unknown key, an overlapping pattern or an attempt to remove\n // the platform alias — at config load, naming what is valid.\n const aliases = compileAliases(options.aliases)\n const previousResolve = config.resolver?.resolveRequest ?? null\n\n const fallback: MetroResolver = (context, moduleName, platform) =>\n previousResolve\n ? previousResolve(context, moduleName, platform)\n : context.resolveRequest(context, moduleName, platform)\n\n const resolveRequest: MetroResolver = (context, moduleName, platform) => {\n if (platform !== LINUX_PLATFORM) {\n return fallback(context, moduleName, platform)\n }\n if (externals.has(moduleName) || isBuiltin(moduleName)) {\n return {\n type: \"sourceFile\",\n filePath: join(proxyDir, sanitize(moduleName)),\n }\n }\n // The five package substitutions plus the platform alias, from the table\n // both presets share (../aliases/index.ts). Each rule is anchored to its\n // package name and matches the exact name or a slash-prefixed subpath,\n // with the tail transplanted onto the target — the guard, not just the\n // order, is what keeps `react-native-reanimated-dnd` out of the\n // `react-native-reanimated` rule and the real, unrelated\n // `react-native-worklets-core` out of the `react-native-worklets` one.\n const aliased = applyAliases(aliases, moduleName)\n if (aliased !== null) {\n return fallback(context, aliased, platform)\n }\n return fallback(context, moduleName, platform)\n }\n\n // The cast: T may carry narrower resolver/serializer types than the ones\n // rebuilt here — the runtime shape is a strict superset of both.\n return {\n ...config,\n resolver: {\n ...config.resolver,\n platforms: [\n ...new Set([...(config.resolver?.platforms ?? []), LINUX_PLATFORM]),\n ],\n resolveRequest,\n },\n serializer: {\n ...config.serializer,\n // RN prepends InitializeCore (Hermes Promise, nativeLoggingHook\n // console...). Our runtime environment IS Node — nothing to\n // initialize inside the bundle.\n getModulesRunBeforeMainModule: () => [],\n },\n } as LinuxPlatformConfig<T>\n}\n"]}
@@ -289,24 +289,7 @@ const SidebarNavigator = ({ initialRouteName, screenOptions, sidebarTitle = "Sid
289
289
  // Adwaita's own defaults for a sidebar of rows. Set explicitly
290
290
  // because they are what keeps the sidebar's width off the window's
291
291
  // minimum now that the scrolled window no longer propagates it.
292
- minSidebarWidth: 180, maxSidebarWidth: 280, onNotifyShowContent: handleShowContentChanged, sidebar: _jsx(AdwNavigationPage, { title: sidebarTitle, tag: "sidebar", children: _jsx(AdwToolbarView, { topBar:
293
- // The sidebar pane's own chrome, mounted exactly the way the
294
- // content HeaderBar below mounts its slots. It used to be a
295
- // bare `<AdwHeaderBar />` with nothing an app could reach:
296
- // `examples/tasks-nav` wanted its "New List" button here
297
- // (where GNOME — and the gtkx tutorial this app family is
298
- // modelled on — puts a sidebar's add action) and had to move
299
- // it onto the CONTENT header instead, next to that header's
300
- // own "New Task" +, leaving the user with two identical plus
301
- // buttons and no way to tell them apart.
302
- _jsx(AdwHeaderBar, { titleWidget: sidebarHeaderTitle ? (_jsx(HeaderSlotContent, { children: sidebarHeaderTitle() })) : undefined, start: sidebarHeaderLeft ? (_jsx(HeaderSlotContent, { children: sidebarHeaderLeft() })) : undefined, end: sidebarHeaderRight ? (_jsx(HeaderSlotContent, { children: sidebarHeaderRight() })) : undefined }), children: sidebarContent ? (
303
- // The whole pane is the app's, mounted the way a page body
304
- // is: a layout root that FILLS the pane, so React Native
305
- // content — the common case — behaves as it does anywhere
306
- // else. A sidebar built from GTK widgets instead wraps
307
- // itself in WidgetContent, the same escape hatch
308
- // contentLayout: "widget" is for a screen body.
309
- _jsx(SlotContent, { children: sidebarContent(sidebarContentProps) })) : (_jsx(_Fragment, { children: _jsx(GtkScrolledWindow, { hscrollbarPolicy: Gtk.PolicyType.NEVER, children: _jsx(GtkListBox, { ref: listRef, cssClasses: ["navigation-sidebar"], onRowSelected: (row) => {
292
+ minSidebarWidth: 180, maxSidebarWidth: 280, onNotifyShowContent: handleShowContentChanged, sidebar: _jsx(AdwNavigationPage, { title: sidebarTitle, tag: "sidebar", children: _jsx(AdwToolbarView, { topBar: _jsx(AdwHeaderBar, { titleWidget: sidebarHeaderTitle ? (_jsx(HeaderSlotContent, { children: sidebarHeaderTitle() })) : undefined, start: sidebarHeaderLeft ? (_jsx(HeaderSlotContent, { children: sidebarHeaderLeft() })) : undefined, end: sidebarHeaderRight ? (_jsx(HeaderSlotContent, { children: sidebarHeaderRight() })) : undefined }), children: sidebarContent ? (_jsx(SlotContent, { children: sidebarContent(sidebarContentProps) })) : (_jsx(_Fragment, { children: _jsx(GtkScrolledWindow, { hscrollbarPolicy: Gtk.PolicyType.NEVER, children: _jsx(GtkListBox, { ref: listRef, cssClasses: ["navigation-sidebar"], onRowSelected: (row) => {
310
293
  if (!row) {
311
294
  return;
312
295
  }
@@ -386,33 +369,7 @@ const SidebarNavigator = ({ initialRouteName, screenOptions, sidebarTitle = "Sid
386
369
  : []),
387
370
  ...(activeButtons?.map((button) => (_jsx(GtkButton, { iconName: button.icon, tooltipText: button.tooltip, onClicked: button.onPress }, button.id))) ?? []),
388
371
  ] }), children: activeOptions.contentLayout === "widget" ? (_jsx(WidgetContent, { children: activeDescriptor?.render() }, active.key)) : (_jsx(SlotContent, { children: activeDescriptor?.render() }, active.key)) }) }) }));
389
- return (_jsx(NavigationContent, { children: collapseWidth === undefined ? (splitView) : (
390
- // A breakpoint's setters may only target widgets INSIDE the bin
391
- // they're attached to, never the bin itself (Adwaita's own
392
- // restriction) — so the split view must be the bin's child.
393
- //
394
- // widthRequest/heightRequest: Adwaita's own contract for
395
- // AdwBreakpointBin — adding a breakpoint makes it report NO minimum
396
- // size, and its docs say these properties "must always be set" in
397
- // that case (otherwise it warns on every use: "does not have a
398
- // minimum size, set the 'width-request' and 'height-request'
399
- // properties to specify it").
400
- //
401
- // The value is load-bearing, not a formality: this bin is NOT laid
402
- // out by Yoga. Under `chrome: "content"` — the chrome this navigator
403
- // requires — it is the window's own child, so GTK's size negotiation
404
- // is what decides how narrow the window may go, and the bin's
405
- // reported minimum IS that floor. Left at zero, the window resizes
406
- // straight past what the pane inside can draw and Adwaita clips it
407
- // rather than adapting it: "AdwNavigationSplitView exceeds
408
- // AdwBreakpointBin width: requested 469 px, 360 px available", felt
409
- // as a task list running off the right edge. See minWidth's doc.
410
- //
411
- // Whatever the value, it must never be 0: the current @gtkx property
412
- // diffing treats 0 as "unset" for numeric props (falsy skip) and
413
- // never issues the native call, so a 0 would silently leave the bin
414
- // with no minimum at all.
415
- _jsx(AdwBreakpointBin, { widthRequest: minWidth, heightRequest: minHeight, breakpoints: _jsx(AdwBreakpoint, { ref: breakpointRef, condition: Adw.BreakpointCondition.newLength(Adw.BreakpointConditionLengthType.MAX_WIDTH, collapseWidth, Adw.LengthUnit.SP) }), children: splitView })) }));
372
+ return (_jsx(NavigationContent, { children: collapseWidth === undefined ? (splitView) : (_jsx(AdwBreakpointBin, { widthRequest: minWidth, heightRequest: minHeight, breakpoints: _jsx(AdwBreakpoint, { ref: breakpointRef, condition: Adw.BreakpointCondition.newLength(Adw.BreakpointConditionLengthType.MAX_WIDTH, collapseWidth, Adw.LengthUnit.SP) }), children: splitView })) }));
416
373
  };
417
374
  const sidebarFactory = createNavigatorFactory(SidebarNavigator);
418
375
  export const createSidebarNavigator = () => sidebarFactory();