react-native-gtkx 0.4.0-alpha.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +35 -96
  2. package/dist/adw/index.js +3 -2
  3. package/dist/adw/index.js.map +1 -1
  4. package/dist/apis/host.gtkx.js.map +1 -1
  5. package/dist/components/modal.d.ts +1 -1
  6. package/dist/components/modal.js +16 -8
  7. package/dist/components/modal.js.map +1 -1
  8. package/dist/dnd/gtk-controllers.js +1 -1
  9. package/dist/dnd/gtk-controllers.js.map +1 -1
  10. package/dist/gtk/index.js +4 -3
  11. package/dist/gtk/index.js.map +1 -1
  12. package/dist/gtkx/bridge/adw.js +1 -1
  13. package/dist/gtkx/bridge/adw.js.map +1 -1
  14. package/dist/gtkx/bridge/core.d.ts +1 -2
  15. package/dist/gtkx/bridge/core.js +2 -5
  16. package/dist/gtkx/bridge/core.js.map +1 -1
  17. package/dist/gtkx/bridge/geometry.js +1 -1
  18. package/dist/gtkx/bridge/geometry.js.map +1 -1
  19. package/dist/gtkx/bridge/layout-manager.js +18 -5
  20. package/dist/gtkx/bridge/layout-manager.js.map +1 -1
  21. package/dist/gtkx/bridge/slot-portal.js.map +1 -1
  22. package/dist/gtkx/bridge/svg-node.js +13 -6
  23. package/dist/gtkx/bridge/svg-node.js.map +1 -1
  24. package/dist/gtkx/bridge/view-box.js +19 -10
  25. package/dist/gtkx/bridge/view-box.js.map +1 -1
  26. package/dist/gtkx/bridge/widgets.generated.adw.js +1 -1
  27. package/dist/gtkx/bridge/widgets.generated.adw.js.map +1 -1
  28. package/dist/mcp/bin.js +1 -1
  29. package/dist/mcp/bin.js.map +1 -1
  30. package/dist/mcp/data/generated.d.ts +860 -531
  31. package/dist/mcp/data/generated.js +952 -538
  32. package/dist/mcp/data/generated.js.map +1 -1
  33. package/dist/mcp/resolve.d.ts +2 -2
  34. package/dist/mcp/resolve.js +2 -2
  35. package/dist/mcp/resolve.js.map +1 -1
  36. package/dist/mcp/server.js +2 -2
  37. package/dist/mcp/server.js.map +1 -1
  38. package/dist/runner/host-dev.js +5 -0
  39. package/dist/runner/host-dev.js.map +1 -1
  40. package/dist/runner/host.js +15 -0
  41. package/dist/runner/host.js.map +1 -1
  42. package/dist/runner/index.d.ts +27 -0
  43. package/dist/runner/index.js +206 -1
  44. package/dist/runner/index.js.map +1 -1
  45. package/dist/sea/assemble.d.ts +9 -0
  46. package/dist/sea/assemble.js +16 -3
  47. package/dist/sea/assemble.js.map +1 -1
  48. package/dist/sea/bundle.d.ts +37 -2
  49. package/dist/sea/bundle.js +77 -5
  50. package/dist/sea/bundle.js.map +1 -1
  51. package/dist/sea/native-shim.js +4 -3
  52. package/dist/sea/native-shim.js.map +1 -1
  53. package/dist/testing/index.js +28 -0
  54. package/dist/testing/index.js.map +1 -1
  55. package/dist/vite/index.js +3 -3
  56. package/dist/vite/index.js.map +1 -1
  57. package/dist/vitest/index.d.ts +2 -2
  58. package/dist/vitest/index.js +1 -1
  59. package/dist/vitest/index.js.map +1 -1
  60. package/package.json +9 -9
  61. package/dist/gtkx/bridge/use-signal.d.ts +0 -2
  62. package/dist/gtkx/bridge/use-signal.js +0 -41
  63. package/dist/gtkx/bridge/use-signal.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":["../../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,EAAE,CAAC,CAAC;IAC5E,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1E,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;IACxE,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;CACzE,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,MAAc,EAAa,EAAE,CAAC,CAAC;IAClD,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;IACxB,OAAO,EAAE,MA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CAAC,MAAM,CAAA;YAC5B,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;aACxB,CAAA;QACH,CAAC;QACD,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY,CAAC,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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C,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/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","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,oBAAoB,CAAC,CAAA;QAChE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,WAAW,CAChB,mBAAmB,KAAK,oEAAoE,CAC7F,CAAA;QACH,CAAC;QACD,MAAM,IAAI,GAAG,OAAO;aACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,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,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AC,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/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"]}
@@ -205,6 +205,11 @@ catch {
205
205
  if (!response.ok) {
206
206
  fail(`Metro returned ${response.status} for the dev bundle:\n${await response.text()}`);
207
207
  }
208
+ // 1.2-WORKAROUND(gtk-application-argv): same fix as host.ts — see that
209
+ // file for the full explanation. Here argv[2] is the dev bundle URL, not
210
+ // a file; strip it before the bundle mounts <GtkApplication> and its
211
+ // effect reads process.argv.slice(2) as the GApplication command line.
212
+ process.argv.length = 2;
208
213
  vm.runInThisContext(await response.text(), { filename: bundleUrl });
209
214
  installDevMenu();
210
215
  const HMRClient = fromApp("metro-runtime/src/modules/HMRClient");
@@ -1 +1 @@
1
- {"version":3,"file":"host-dev.js","sourceRoot":"","sources":["../../src/runner/host-dev.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uEAAuE;AACvE,oEAAoE;AACpE,0EAA0E;AAC1E,0EAA0E;AAC1E,EAAE;AACF,uEAAuE;AACvE,wEAAwE;AACxE,wEAAwE;AACxE,oEAAoE;AACpE,qEAAqE;AACrE,yEAAyE;AACzE,iEAAiE;AACjE,yBAAyB;AACzB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EACL,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,yBAAyB,CAAA;AAIhC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAS,EAAE;IACtC,OAAO,CAAC,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA;AAED,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;IACxC,IAAI,CACF,QAAQ,OAAO,CAAC,OAAO,gEAAgE,CACxF,CAAA;AACH,CAAC;AAED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["// The DEV host: fetch the dev bundle from a Metro dev server, execute it,\n// subscribe to HMR updates and let react-refresh re-render through the\n// @gtkx/react reconciler with component state preserved. Spawned by\n// `run-linux --dev` as `node dist/runner/host-dev.js <bundle-url>`; exits\n// with code 65 when a full refresh is required — the supervisor restarts.\n//\n// Division of labor (validated by spike/rn-platform, FINDINGS-dev.md):\n// metro-runtime's dev require scopes the react-refresh registration per\n// module and applies hot updates once global.__ReactRefresh exists; its\n// HMRClient speaks the /hot websocket protocol verbatim over Node's\n// global WebSocket. This file only adds the dev pieces on top of the\n// release host (./host.ts — deliberately self-contained twins: both must\n// stay runnable under bare Node, so they cannot share a relative\n// extensionless import).\nimport { createRequire, registerHooks } from \"node:module\"\nimport { join } from \"node:path\"\nimport { pathToFileURL } from \"node:url\"\nimport vm from \"node:vm\"\nimport {\n HOST_MODULE_EXTERNALS,\n OPTIONAL_HOST_MODULE_EXTERNALS,\n} from \"react-native-gtkx/metro\"\n\ntype HostModule = Record<string, unknown>\n\nconst fail = (message: string): never => {\n console.error(`[react-native-gtkx] ${message}`)\n process.exit(1)\n}\n\nif (typeof registerHooks !== \"function\") {\n fail(\n `Node ${process.version} lacks module.registerHooks — the linux host needs Node >= 24.`,\n )\n}\n\n// react and the reconciler must run their DEV builds for react-refresh.\nprocess.env.NODE_ENV = process.env.NODE_ENV ?? \"development\"\n\nconst bundleUrl = process.argv[2]\nif (!bundleUrl) {\n fail(\"usage: node host-dev.js <metro-dev-bundle-url>\")\n}\n\n// Resolution anchors: react-refresh and metro-runtime ship with the APP's\n// react-native; @gtkx/* resolve as this package's dependencies; react must\n// be the exact instance the reconciler sees (see host.ts).\nconst fromApp = createRequire(join(process.cwd(), \"package.json\"))\nconst fromPackage = createRequire(import.meta.url)\nconst fromGtkxReact = createRequire(fromPackage.resolve(\"@gtkx/react\"))\n\n// --- react-refresh: inject BEFORE @gtkx/react loads (the reconciler\n// registers into the patched devtools hook).\nconst RefreshRuntime = fromApp(\"react-refresh/runtime\") as Record<\n string,\n unknown\n> & { injectIntoGlobalHook(target: unknown): void }\nRefreshRuntime.injectIntoGlobalHook(globalThis)\nglobalThis.$RefreshReg$ = () => {}\nglobalThis.$RefreshSig$ = () => (type: unknown) => type\nglobalThis.__ReactRefresh = {\n ...RefreshRuntime,\n performFullRefresh(reason: string) {\n console.warn(\n `[react-native-gtkx] full refresh required (${reason}) — restarting`,\n )\n process.exit(65)\n },\n}\n\n// --- virtual:gtkx-config (same mechanism and same module shape as the\n// release host — see host.ts for why each export is needed).\nconst CONFIG_REQUIRED =\n \"gtkx.config.ts with an applicationId is required in the app root \" +\n '(export default defineConfig({ applicationId: \"...\", libraries: [...] })).'\nconst { createConfigLoader } = await import(\n pathToFileURL(fromPackage.resolve(\"@gtkx/config/internal\")).href\n)\nconst gtkxConfig = await createConfigLoader()\n .resolve(process.cwd())\n .catch((error: unknown) => fail(`${CONFIG_REQUIRED}\\n${String(error)}`))\nif (!gtkxConfig.applicationId) {\n fail(CONFIG_REQUIRED)\n}\nif (gtkxConfig.elements !== null) {\n fail(\n \"gtkx.config.ts `elements.behaviors` is not supported on the linux \" +\n \"platform — react-native-gtkx owns element behaviors.\",\n )\n}\nconst configModuleUrl = new URL(\"./__virtual-gtkx-config.mjs\", import.meta.url)\n .href\nconst lazyElements = Object.fromEntries(\n gtkxConfig.lazyElements.map((type: string) => [type, { isLazy: true }]),\n)\nconst configModuleSource = [\n `export * from \"@gtkx/jsx/metadata\";`,\n `export const applicationId = ${JSON.stringify(gtkxConfig.applicationId)};`,\n `export const userEventSignals = ${JSON.stringify(gtkxConfig.userEventSignals)};`,\n `export const elements = ${JSON.stringify(lazyElements)};`,\n].join(\"\\n\")\nregisterHooks({\n resolve(specifier, context, nextResolve) {\n if (specifier === \"virtual:gtkx-config\") {\n return { url: configModuleUrl, shortCircuit: true }\n }\n return nextResolve(specifier, context)\n },\n load(url, context, nextLoad) {\n if (url === configModuleUrl) {\n return {\n format: \"module\",\n source: configModuleSource,\n shortCircuit: true,\n }\n }\n return nextLoad(url, context)\n },\n})\n\n// --- host modules (same interop merging as the release host).\nconst resolveExternal = (name: string): string =>\n name === \"react\" || name.startsWith(\"react/\")\n ? fromGtkxReact.resolve(name)\n : fromPackage.resolve(name)\n\nconst load = async (name: string): Promise<HostModule> => {\n const namespace: HostModule = await import(\n pathToFileURL(resolveExternal(name)).href\n )\n const merged: HostModule = { __esModule: true, ...namespace }\n if (!(\"default\" in namespace)) {\n merged.default = namespace\n }\n return merged\n}\n\nglobalThis.__hostModules = {}\nfor (const name of HOST_MODULE_EXTERNALS) {\n try {\n globalThis.__hostModules[name] = await load(name)\n } catch (error) {\n if (OPTIONAL_HOST_MODULE_EXTERNALS.has(name)) {\n // See host.ts's identical guard — expected on the plain-GTK profile.\n continue\n }\n fail(\n `failed to load host module \"${name}\" — is the codegen store in ` +\n `place (npx gtkx codegen) and GTK4/libadwaita installed?\\n${String(error)}`,\n )\n }\n}\nglobalThis.__hostRequire = createRequire(import.meta.url)\n\n// --- Dev Menu (Ctrl+Shift+D, the react-native-windows precedent).\n// Installed before the bundle runs so DevSettings.reload works from app\n// code; the key controller attaches once the app window exists.\nconst requestReload = (reason?: string): never => {\n console.warn(\n `[react-native-gtkx] reload requested${reason ? ` (${reason})` : \"\"} — restarting`,\n )\n return process.exit(65)\n}\nglobalThis.__rnGtkxDevHost = { reload: requestReload }\n\n// Structural slices of the GTK wrappers the menu touches — the host talks\n// to codegen namespaces through __hostModules, untyped by design.\ntype DevMenuWindow = { addController(controller: unknown): void }\ntype DevMenuDialog = {\n setHeading(heading: string): void\n setBody(body: string): void\n addResponse(id: string, label: string): void\n setResponseAppearance(id: string, appearance: unknown): void\n setDefaultResponse(id: string): void\n setCloseResponse(id: string): void\n choose(parent: DevMenuWindow): Promise<string>\n}\n\nconst installDevMenu = (): void => {\n const gtk = globalThis.__hostModules[\"@gtkx/gi/gtk\"] as {\n EventControllerKey: new () => {\n on(signal: string, handler: (...args: unknown[]) => unknown): void\n }\n }\n const gdk = globalThis.__hostModules[\"@gtkx/gi/gdk\"] as {\n ModifierType: { CONTROL_MASK: number; SHIFT_MASK: number }\n }\n const adw = globalThis.__hostModules[\"@gtkx/gi/adw\"] as {\n AlertDialog: new () => DevMenuDialog\n ResponseAppearance: { SUGGESTED: unknown }\n }\n const gio = globalThis.__hostModules[\"@gtkx/gi/gio\"] as {\n Application: {\n getDefault():\n { getActiveWindow?: () => DevMenuWindow | null } | null | undefined\n }\n }\n // GDK keysyms for latin letters equal their ASCII codes.\n const KEY_UPPER_D = 0x44\n const KEY_LOWER_D = 0x64\n\n let menuOpen = false\n const openDevMenu = async (window: DevMenuWindow): Promise<void> => {\n if (menuOpen) {\n return\n }\n menuOpen = true\n try {\n const items = globalThis.__rnGtkxDevMenuItems ?? []\n const dialog = new adw.AlertDialog()\n dialog.setHeading(\"React Native Dev Menu\")\n dialog.setBody(bundleUrl!)\n dialog.addResponse(\"cancel\", \"Cancel\")\n items.forEach((item, index) => {\n dialog.addResponse(`custom-${index}`, item.title)\n })\n dialog.addResponse(\"reload\", \"Reload\")\n dialog.setResponseAppearance(\"reload\", adw.ResponseAppearance.SUGGESTED)\n dialog.setDefaultResponse(\"reload\")\n dialog.setCloseResponse(\"cancel\")\n const response = await dialog.choose(window)\n if (response === \"reload\") {\n requestReload()\n }\n const custom = /^custom-(\\d+)$/.exec(response)\n if (custom) {\n items[Number(custom[1])]?.handler()\n }\n } catch (error) {\n console.error(`[react-native-gtkx] dev menu failed: ${String(error)}`)\n } finally {\n menuOpen = false\n }\n }\n\n const attach = (): void => {\n const window = gio.Application.getDefault()?.getActiveWindow?.()\n if (!window) {\n // The bundle opens the window asynchronously (application activate).\n setTimeout(attach, 200)\n return\n }\n const controller = new gtk.EventControllerKey()\n controller.on(\"key-pressed\", (keyval, _keycode, state) => {\n const modifiers = state as number\n const wanted =\n (modifiers & gdk.ModifierType.CONTROL_MASK) !== 0 &&\n (modifiers & gdk.ModifierType.SHIFT_MASK) !== 0 &&\n (keyval === KEY_UPPER_D || keyval === KEY_LOWER_D)\n if (wanted) {\n void openDevMenu(window)\n return true\n }\n return false\n })\n window.addController(controller)\n console.warn(\"[react-native-gtkx] dev menu ready (Ctrl+Shift+D)\")\n }\n attach()\n}\n\n// --- fetch and run the dev bundle.\nlet response: Response\ntry {\n response = await fetch(bundleUrl!)\n} catch {\n fail(`Metro dev server is not reachable (${bundleUrl}).`)\n throw new Error(\"unreachable\")\n}\nif (!response.ok) {\n fail(\n `Metro returned ${response.status} for the dev bundle:\\n${await response.text()}`,\n )\n}\nvm.runInThisContext(await response.text(), { filename: bundleUrl })\ninstallDevMenu()\n\n// --- HMR: metro-runtime's own client (ships with react-native).\ntype HmrErrorBody = { type?: string; message?: string }\ntype HmrClient = {\n send(message: string): void\n enable(): void\n on(event: string, listener: (body?: HmrErrorBody) => void): void\n}\nconst HMRClient = fromApp(\"metro-runtime/src/modules/HMRClient\") as new (\n url: string,\n) => HmrClient\nconst client = new HMRClient(\n bundleUrl!.replace(/^http/, \"ws\").replace(/\\/[^/]*$/, \"/hot\"),\n)\nclient.send(\n JSON.stringify({ type: \"register-entrypoints\", entryPoints: [bundleUrl] }),\n)\nclient.enable()\nclient.on(\"update-done\", () => {\n console.warn(\"[react-native-gtkx] hot update applied\")\n})\nclient.on(\"error\", (body) => {\n console.error(\n `[react-native-gtkx] Metro error (${body?.type ?? \"unknown\"}):\\n${body?.message ?? \"\"}`,\n )\n})\nclient.on(\"close\", () => {\n console.warn(\n \"[react-native-gtkx] HMR connection closed (the window keeps running without hot updates)\",\n )\n})\n"]}
1
+ {"version":3,"file":"host-dev.js","sourceRoot":"","sources":["../../src/runner/host-dev.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uEAAuE;AACvE,oEAAoE;AACpE,0EAA0E;AAC1E,0EAA0E;AAC1E,EAAE;AACF,uEAAuE;AACvE,wEAAwE;AACxE,wEAAwE;AACxE,oEAAoE;AACpE,qEAAqE;AACrE,yEAAyE;AACzE,iEAAiE;AACjE,yBAAyB;AACzB,O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,CAAC,CAC9D,CAAA;AACD,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAC3E,CAAA;AACD,MAAM,CAAC,MAAM,EAAE,CAAA;AACf,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;IAC5B,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAA;AACxD,CAAC,CAAC,CAAA;AACF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;IAC1B,OAAO,CAAC,KAAK,CACX,oCAAoC,IAAI,EAAE,IAAI,IAAI,SAAS,OAAO,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,CACxF,CAAA;AACH,CAAC,CAAC,CAAA;AACF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;IACtB,OAAO,CAAC,IAAI,CACV,0FAA0F,CAC3F,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["// The DEV host: fetch the dev bundle from a Metro dev server, execute it,\n// subscribe to HMR updates and let react-refresh re-render through the\n// @gtkx/react reconciler with component state preserved. Spawned by\n// `run-linux --dev` as `node dist/runner/host-dev.js <bundle-url>`; exits\n// with code 65 when a full refresh is required — the supervisor restarts.\n//\n// Division of labor (validated by spike/rn-platform, FINDINGS-dev.md):\n// metro-runtime's dev require scopes the react-refresh registration per\n// module and applies hot updates once global.__ReactRefresh exists; its\n// HMRClient speaks the /hot websocket protocol verbatim over Node's\n// global WebSocket. This file only adds the dev pieces on top of the\n// release host (./host.ts — deliberately self-contained twins: both must\n// stay runnable under bare Node, so they cannot share a relative\n// extensionless import).\nimport { createRequire, registerHooks } from \"node:module\"\nimport { join } from \"node:path\"\nimport { pathToFileURL } from \"node:url\"\nimport vm from \"node:vm\"\nimport {\n HOST_MODULE_EXTERNALS,\n OPTIONAL_HOST_MODULE_EXTERNALS,\n} from \"react-native-gtkx/metro\"\n\ntype HostModule = Record<string, unknown>\n\nconst fail = (message: string): never => {\n console.error(`[react-native-gtkx] ${message}`)\n process.exit(1)\n}\n\nif (typeof registerHooks !== \"function\") {\n fail(\n `Node ${process.version} lacks module.registerHooks — the linux host needs Node >= 24.`,\n )\n}\n\n// react and the reconciler must run their DEV builds for react-refresh.\nprocess.env.NODE_ENV = process.env.NODE_ENV ?? \"development\"\n\nconst bundleUrl = process.argv[2]\nif (!bundleUrl) {\n fail(\"usage: node host-dev.js <metro-dev-bundle-url>\")\n}\n\n// Resolution anchors: react-refresh and metro-runtime ship with the APP's\n// react-native; @gtkx/* resolve as this package's dependencies; react must\n// be the exact instance the reconciler sees (see host.ts).\nconst fromApp = createRequire(join(process.cwd(), \"package.json\"))\nconst fromPackage = createRequire(import.meta.url)\nconst fromGtkxReact = createRequire(fromPackage.resolve(\"@gtkx/react\"))\n\n// --- react-refresh: inject BEFORE @gtkx/react loads (the reconciler\n// registers into the patched devtools hook).\nconst RefreshRuntime = fromApp(\"react-refresh/runtime\") as Record<\n string,\n unknown\n> & { injectIntoGlobalHook(target: unknown): void }\nRefreshRuntime.injectIntoGlobalHook(globalThis)\nglobalThis.$RefreshReg$ = () => {}\nglobalThis.$RefreshSig$ = () => (type: unknown) => type\nglobalThis.__ReactRefresh = {\n ...RefreshRuntime,\n performFullRefresh(reason: string) {\n console.warn(\n `[react-native-gtkx] full refresh required (${reason}) — restarting`,\n )\n process.exit(65)\n },\n}\n\n// --- virtual:gtkx-config (same mechanism and same module shape as the\n// release host — see host.ts for why each export is needed).\nconst CONFIG_REQUIRED =\n \"gtkx.config.ts with an applicationId is required in the app root \" +\n '(export default defineConfig({ applicationId: \"...\", libraries: [...] })).'\nconst { createConfigLoader } = await import(\n pathToFileURL(fromPackage.resolve(\"@gtkx/config/internal\")).href\n)\nconst gtkxConfig = await createConfigLoader()\n .resolve(process.cwd())\n .catch((error: unknown) => fail(`${CONFIG_REQUIRED}\\n${String(error)}`))\nif (!gtkxConfig.applicationId) {\n fail(CONFIG_REQUIRED)\n}\nif (gtkxConfig.elements !== null) {\n fail(\n \"gtkx.config.ts `elements.behaviors` is not supported on the linux \" +\n \"platform — react-native-gtkx owns element behaviors.\",\n )\n}\nconst configModuleUrl = new URL(\"./__virtual-gtkx-config.mjs\", import.meta.url)\n .href\nconst lazyElements = Object.fromEntries(\n gtkxConfig.lazyElements.map((type: string) => [type, { isLazy: true }]),\n)\nconst configModuleSource = [\n `export * from \"@gtkx/jsx/metadata\";`,\n `export const applicationId = ${JSON.stringify(gtkxConfig.applicationId)};`,\n `export const userEventSignals = ${JSON.stringify(gtkxConfig.userEventSignals)};`,\n `export const elements = ${JSON.stringify(lazyElements)};`,\n].join(\"\\n\")\nregisterHooks({\n resolve(specifier, context, nextResolve) {\n if (specifier === \"virtual:gtkx-config\") {\n return { url: configModuleUrl, shortCircuit: true }\n }\n return nextResolve(specifier, context)\n },\n load(url, context, nextLoad) {\n if (url === configModuleUrl) {\n return {\n format: \"module\",\n source: configModuleSource,\n shortCircuit: true,\n }\n }\n return nextLoad(url, context)\n },\n})\n\n// --- host modules (same interop merging as the release host).\nconst resolveExternal = (name: string): string =>\n name === \"react\" || name.startsWith(\"react/\")\n ? fromGtkxReact.resolve(name)\n : fromPackage.resolve(name)\n\nconst load = async (name: string): Promise<HostModule> => {\n const namespace: HostModule = await import(\n pathToFileURL(resolveExternal(name)).href\n )\n const merged: HostModule = { __esModule: true, ...namespace }\n if (!(\"default\" in namespace)) {\n merged.default = namespace\n }\n return merged\n}\n\nglobalThis.__hostModules = {}\nfor (const name of HOST_MODULE_EXTERNALS) {\n try {\n globalThis.__hostModules[name] = await load(name)\n } catch (error) {\n if (OPTIONAL_HOST_MODULE_EXTERNALS.has(name)) {\n // See host.ts's identical guard — expected on the plain-GTK profile.\n continue\n }\n fail(\n `failed to load host module \"${name}\" — is the codegen store in ` +\n `place (npx gtkx codegen) and GTK4/libadwaita installed?\\n${String(error)}`,\n )\n }\n}\nglobalThis.__hostRequire = createRequire(import.meta.url)\n\n// --- Dev Menu (Ctrl+Shift+D, the react-native-windows precedent).\n// Installed before the bundle runs so DevSettings.reload works from app\n// code; the key controller attaches once the app window exists.\nconst requestReload = (reason?: string): never => {\n console.warn(\n `[react-native-gtkx] reload requested${reason ? ` (${reason})` : \"\"} — restarting`,\n )\n return process.exit(65)\n}\nglobalThis.__rnGtkxDevHost = { reload: requestReload }\n\n// Structural slices of the GTK wrappers the menu touches — the host talks\n// to codegen namespaces through __hostModules, untyped by design.\ntype DevMenuWindow = { addController(controller: unknown): void }\ntype DevMenuDialog = {\n setHeading(heading: string): void\n setBody(body: string): void\n addResponse(id: string, label: string): void\n setResponseAppearance(id: string, appearance: unknown): void\n setDefaultResponse(id: string): void\n setCloseResponse(id: string): void\n choose(parent: DevMenuWindow): Promise<string>\n}\n\nconst installDevMenu = (): void => {\n const gtk = globalThis.__hostModules[\"@gtkx/gi/gtk\"] as {\n EventControllerKey: new () => {\n on(signal: string, handler: (...args: unknown[]) => unknown): void\n }\n }\n const gdk = globalThis.__hostModules[\"@gtkx/gi/gdk\"] as {\n ModifierType: { CONTROL_MASK: number; SHIFT_MASK: number }\n }\n const adw = globalThis.__hostModules[\"@gtkx/gi/adw\"] as {\n AlertDialog: new () => DevMenuDialog\n ResponseAppearance: { SUGGESTED: unknown }\n }\n const gio = globalThis.__hostModules[\"@gtkx/gi/gio\"] as {\n Application: {\n getDefault():\n { getActiveWindow?: () => DevMenuWindow | null } | null | undefined\n }\n }\n // GDK keysyms for latin letters equal their ASCII codes.\n const KEY_UPPER_D = 0x44\n const KEY_LOWER_D = 0x64\n\n let menuOpen = false\n const openDevMenu = async (window: DevMenuWindow): Promise<void> => {\n if (menuOpen) {\n return\n }\n menuOpen = true\n try {\n const items = globalThis.__rnGtkxDevMenuItems ?? []\n const dialog = new adw.AlertDialog()\n dialog.setHeading(\"React Native Dev Menu\")\n dialog.setBody(bundleUrl!)\n dialog.addResponse(\"cancel\", \"Cancel\")\n items.forEach((item, index) => {\n dialog.addResponse(`custom-${index}`, item.title)\n })\n dialog.addResponse(\"reload\", \"Reload\")\n dialog.setResponseAppearance(\"reload\", adw.ResponseAppearance.SUGGESTED)\n dialog.setDefaultResponse(\"reload\")\n dialog.setCloseResponse(\"cancel\")\n const response = await dialog.choose(window)\n if (response === \"reload\") {\n requestReload()\n }\n const custom = /^custom-(\\d+)$/.exec(response)\n if (custom) {\n items[Number(custom[1])]?.handler()\n }\n } catch (error) {\n console.error(`[react-native-gtkx] dev menu failed: ${String(error)}`)\n } finally {\n menuOpen = false\n }\n }\n\n const attach = (): void => {\n const window = gio.Application.getDefault()?.getActiveWindow?.()\n if (!window) {\n // The bundle opens the window asynchronously (application activate).\n setTimeout(attach, 200)\n return\n }\n const controller = new gtk.EventControllerKey()\n controller.on(\"key-pressed\", (keyval, _keycode, state) => {\n const modifiers = state as number\n const wanted =\n (modifiers & gdk.ModifierType.CONTROL_MASK) !== 0 &&\n (modifiers & gdk.ModifierType.SHIFT_MASK) !== 0 &&\n (keyval === KEY_UPPER_D || keyval === KEY_LOWER_D)\n if (wanted) {\n void openDevMenu(window)\n return true\n }\n return false\n })\n window.addController(controller)\n console.warn(\"[react-native-gtkx] dev menu ready (Ctrl+Shift+D)\")\n }\n attach()\n}\n\n// --- fetch and run the dev bundle.\nlet response: Response\ntry {\n response = await fetch(bundleUrl!)\n} catch {\n fail(`Metro dev server is not reachable (${bundleUrl}).`)\n throw new Error(\"unreachable\")\n}\nif (!response.ok) {\n fail(\n `Metro returned ${response.status} for the dev bundle:\\n${await response.text()}`,\n )\n}\n// 1.2-WORKAROUND(gtk-application-argv): same fix as host.ts — see that\n// file for the full explanation. Here argv[2] is the dev bundle URL, not\n// a file; strip it before the bundle mounts <GtkApplication> and its\n// effect reads process.argv.slice(2) as the GApplication command line.\nprocess.argv.length = 2\nvm.runInThisContext(await response.text(), { filename: bundleUrl })\ninstallDevMenu()\n\n// --- HMR: metro-runtime's own client (ships with react-native).\ntype HmrErrorBody = { type?: string; message?: string }\ntype HmrClient = {\n send(message: string): void\n enable(): void\n on(event: string, listener: (body?: HmrErrorBody) => void): void\n}\nconst HMRClient = fromApp(\"metro-runtime/src/modules/HMRClient\") as new (\n url: string,\n) => HmrClient\nconst client = new HMRClient(\n bundleUrl!.replace(/^http/, \"ws\").replace(/\\/[^/]*$/, \"/hot\"),\n)\nclient.send(\n JSON.stringify({ type: \"register-entrypoints\", entryPoints: [bundleUrl] }),\n)\nclient.enable()\nclient.on(\"update-done\", () => {\n console.warn(\"[react-native-gtkx] hot update applied\")\n})\nclient.on(\"error\", (body) => {\n console.error(\n `[react-native-gtkx] Metro error (${body?.type ?? \"unknown\"}):\\n${body?.message ?? \"\"}`,\n )\n})\nclient.on(\"close\", () => {\n console.warn(\n \"[react-native-gtkx] HMR connection closed (the window keeps running without hot updates)\",\n )\n})\n"]}
@@ -122,6 +122,21 @@ catch {
122
122
  fail(`bundle not found at ${bundlePath} — run react-native run-linux.`);
123
123
  throw new Error("unreachable");
124
124
  }
125
+ // 1.2-WORKAROUND(gtk-application-argv): @gtkx/react's <GtkApplication>
126
+ // now builds the GApplication's own command line from
127
+ // `process.argv.slice(2)` (components/application.js, `runApplication`'s
128
+ // new argv parameter) and hands anything left over to GLib's local
129
+ // command-line handling, which treats stray positionals as files to
130
+ // open. This process's OWN positional argv[2] is our bundle path, not a
131
+ // user-facing argument — left in place it reaches GApplication as a
132
+ // "file" no app declares G_APPLICATION_HANDLES_OPEN for
133
+ // ("GLib-GIO-CRITICAL: This application can not open files"), and the
134
+ // window never activates. Truncate before the bundle (which mounts
135
+ // <GtkApplication> from an effect, so this always runs first) sees it.
136
+ // Removal condition: @gtkx/react exposes a way to pass runApplication's
137
+ // argv explicitly (an `argv` prop on <GtkApplication>, or an
138
+ // options object) instead of always reading process.argv itself.
139
+ process.argv.length = 2;
125
140
  // The entry calls AppRegistry.runApplication itself (the react-native-web
126
141
  // pattern); the GLib main loop keeps the process alive afterwards.
127
142
  vm.runInThisContext(source, { filename: bundlePath });
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/runner/host.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,gDAAgD;AAChD,yEAAyE;AACzE,iDAAiD;AACjD,EAAE;AACF,0EAA0E;AAC1E,sEAAsE;AACtE,qDAAqD;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EACL,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,yBAAyB,CAAA;AAIhC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAS,EAAE;IACtC,OAAO,CAAC,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA;AAED,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;IACxC,IAAI,CACF,QAAQ,OAAO,CAAC,OAAO,gEAAgE,CACxF,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,sEAAsE;AACtE,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAClD,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;AAEvE,MAAM,eAAe,GAAG,CAAC,IAAY,EAAU,EAAE,CAC/C,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC3C,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7B,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA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,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,8BAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,sEAAsE;YACtE,mEAAmE;YACnE,wDAAwD;YACxD,iEAAiE;YACjE,uDAAuD;YACvD,SAAQ;QACV,CAAC;QACD,IAAI,CACF,+BAA+B,IAAI,8BAA8B;YAC/D,4DAA4D,MAAM,CAAC,KAAK,CAAC,EAAE,CAC9E,CAAA;IACH,CAAC;AACH,CAAC;AACD,sEAAsE;AACtE,UAAU,CAAC,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEzD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAClC,IAAI,CAAC,UAAU,EAAE,CAAC;IAChB,IAAI,CAAC,6CAA6C,CAAC,CAAA;AACrD,CAAC;AACD,IAAI,MAAc,CAAA;AAClB,IAAI,CAAC;IACH,MAAM,GAAG,YAAY,CAAC,UAAW,EAAE,MAAM,CAAC,CAAA;AAC5C,CAAC;AAAC,MAAM,CAAC;IACP,IAAI,CAAC,uBAAuB,UAAU,gCAAgC,CAAC,CAAA;IACvE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;AAChC,CAAC;AACD,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA","sourcesContent":["// The Node+GTK host: executes a Metro jsbundle built for the linux\n// platform. Spawned by the run-linux command as\n// `node dist/runner/host.js <bundle>`; the bundle's externalized proxies\n// (see ../metro) read the modules injected here.\n//\n// This file must stay runnable under BARE Node: no extensionless relative\n// imports — only builtins, bare dependency specifiers and the package\n// self-reference (resolved through the exports map).\nimport { readFileSync } from \"node:fs\"\nimport { createRequire, registerHooks } from \"node:module\"\nimport { pathToFileURL } from \"node:url\"\nimport vm from \"node:vm\"\nimport {\n HOST_MODULE_EXTERNALS,\n OPTIONAL_HOST_MODULE_EXTERNALS,\n} from \"react-native-gtkx/metro\"\n\ntype HostModule = Record<string, unknown>\n\nconst fail = (message: string): never => {\n console.error(`[react-native-gtkx] ${message}`)\n process.exit(1)\n}\n\nif (typeof registerHooks !== \"function\") {\n fail(\n `Node ${process.version} lacks module.registerHooks — the linux host needs Node >= 24.`,\n )\n}\n\n// Resolution anchors. @gtkx/* and @gtkx/config resolve as THIS package's\n// dependencies; react resolves FROM @gtkx/react's real location — the\n// reconciler and the app must share one React instance, and anchoring at\n// the app could pick up a second copy installed by npm peer auto-install.\nconst fromPackage = createRequire(import.meta.url)\nconst fromGtkxReact = createRequire(fromPackage.resolve(\"@gtkx/react\"))\n\nconst resolveExternal = (name: string): string =>\n name === \"react\" || name.startsWith(\"react/\")\n ? fromGtkxReact.resolve(name)\n : fromPackage.resolve(name)\n\n// import() handles both ESM and CJS; merge a `default` for Babel's\n// default-import interop when the module has none of its own.\nconst load = async (name: string): Promise<HostModule> => {\n const namespace: HostModule = await import(\n pathToFileURL(resolveExternal(name)).href\n )\n const merged: HostModule = { __esModule: true, ...namespace }\n if (!(\"default\" in namespace)) {\n merged.default = namespace\n }\n return merged\n}\n\n// @gtkx/react imports `virtual:gtkx-config` — JSX metadata plus the values\n// resolved from gtkx.config.ts (applicationId for the GApplication, the\n// userEventSignals suppressed during commits and the elements config the\n// reconciler registry is primed with). In the vite path the gtkx CLI plugin\n// serves it; replicate it with a loader hook, mirroring @gtkx/config's own\n// renderConfigModule. The fake module URL is anchored inside this package so\n// the re-exported bare specifier resolves through node_modules.\nconst CONFIG_REQUIRED =\n \"gtkx.config.ts with an applicationId is required in the app root \" +\n '(export default defineConfig({ applicationId: \"...\", libraries: [...] })).'\nconst { createConfigLoader } = await import(\"@gtkx/config/internal\")\n// The loader validates the config, so a missing or malformed one throws.\n// rc.3 turned the loader from a bare function into `{ load, resolve }`;\n// `resolve` is the runtime projection this module needs.\nconst gtkxConfig = await createConfigLoader()\n .resolve(process.cwd())\n .catch((error: unknown) => fail(`${CONFIG_REQUIRED}\\n${String(error)}`))\nif (!gtkxConfig.applicationId) {\n fail(CONFIG_REQUIRED)\n}\n// A behaviors module would have to be bundled and merged through\n// @gtkx/react/config; the react-native surface owns element behaviors, so no\n// app declares one — refuse rather than silently drop it.\nif (gtkxConfig.elements !== null) {\n fail(\n \"gtkx.config.ts `elements.behaviors` is not supported on the linux \" +\n \"platform — react-native-gtkx owns element behaviors.\",\n )\n}\nconst configModuleUrl = new URL(\"./__virtual-gtkx-config.mjs\", import.meta.url)\n .href\nconst lazyElements = Object.fromEntries(\n gtkxConfig.lazyElements.map((type) => [type, { isLazy: true }]),\n)\nconst configModuleSource = [\n `export * from \"@gtkx/jsx/metadata\";`,\n `export const applicationId = ${JSON.stringify(gtkxConfig.applicationId)};`,\n `export const userEventSignals = ${JSON.stringify(gtkxConfig.userEventSignals)};`,\n `export const elements = ${JSON.stringify(lazyElements)};`,\n].join(\"\\n\")\nregisterHooks({\n resolve(specifier, context, nextResolve) {\n if (specifier === \"virtual:gtkx-config\") {\n return { url: configModuleUrl, shortCircuit: true }\n }\n return nextResolve(specifier, context)\n },\n load(url, context, nextLoad) {\n if (url === configModuleUrl) {\n return {\n format: \"module\",\n source: configModuleSource,\n shortCircuit: true,\n }\n }\n return nextLoad(url, context)\n },\n})\n\nglobalThis.__hostModules = {}\nfor (const name of HOST_MODULE_EXTERNALS) {\n try {\n globalThis.__hostModules[name] = await load(name)\n } catch (error) {\n if (OPTIONAL_HOST_MODULE_EXTERNALS.has(name)) {\n // Expected and fine: this app's gtkx.config.ts never declared the GIR\n // library this module binds (e.g. \"Adw-1\" — the plain-GTK profile,\n // see .claude/epics/adw-optional/001.md). Left unset in\n // __hostModules; a feature that actually needs it throws its own\n // named error when it is reached, not here at startup.\n continue\n }\n fail(\n `failed to load host module \"${name}\" — is the codegen store in ` +\n `place (npx gtkx codegen) and GTK4/libadwaita installed?\\n${String(error)}`,\n )\n }\n}\n// Node builtin proxies resolve lazily through the host's own require.\nglobalThis.__hostRequire = createRequire(import.meta.url)\n\nconst bundlePath = process.argv[2]\nif (!bundlePath) {\n fail(\"usage: node host.js <path/to/main.jsbundle>\")\n}\nlet source: string\ntry {\n source = readFileSync(bundlePath!, \"utf8\")\n} catch {\n fail(`bundle not found at ${bundlePath} — run react-native run-linux.`)\n throw new Error(\"unreachable\")\n}\n// The entry calls AppRegistry.runApplication itself (the react-native-web\n// pattern); the GLib main loop keeps the process alive afterwards.\nvm.runInThisContext(source, { filename: bundlePath })\n"]}
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/runner/host.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,gDAAgD;AAChD,yEAAyE;AACzE,iDAAiD;AACjD,EAAE;AACF,0EAA0E;AAC1E,sEAAsE;AACtE,qDAAqD;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EACL,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,yBAAyB,CAAA;AAIhC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAS,EAAE;IACtC,OAAO,CAAC,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA;AAED,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;IACxC,IAAI,CACF,QAAQ,OAAO,CAAC,OAAO,gEAAgE,CACxF,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,sEAAsE;AACtE,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,WAAW,GAAG,a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C;AACD,uEAAuE;AACvE,sDAAsD;AACtD,yEAAyE;AACzE,mEAAmE;AACnE,oEAAoE;AACpE,wEAAwE;AACxE,oEAAoE;AACpE,wDAAwD;AACxD,sEAAsE;AACtE,mEAAmE;AACnE,uEAAuE;AACvE,wEAAwE;AACxE,6DAA6D;AAC7D,iEAAiE;AACjE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;AACvB,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA","sourcesContent":["// The Node+GTK host: executes a Metro jsbundle built for the linux\n// platform. Spawned by the run-linux command as\n// `node dist/runner/host.js <bundle>`; the bundle's externalized proxies\n// (see ../metro) read the modules injected here.\n//\n// This file must stay runnable under BARE Node: no extensionless relative\n// imports — only builtins, bare dependency specifiers and the package\n// self-reference (resolved through the exports map).\nimport { readFileSync } from \"node:fs\"\nimport { createRequire, registerHooks } from \"node:module\"\nimport { pathToFileURL } from \"node:url\"\nimport vm from \"node:vm\"\nimport {\n HOST_MODULE_EXTERNALS,\n OPTIONAL_HOST_MODULE_EXTERNALS,\n} from \"react-native-gtkx/metro\"\n\ntype HostModule = Record<string, unknown>\n\nconst fail = (message: string): never => {\n console.error(`[react-native-gtkx] ${message}`)\n process.exit(1)\n}\n\nif (typeof registerHooks !== \"function\") {\n fail(\n `Node ${process.version} lacks module.registerHooks — the linux host needs Node >= 24.`,\n )\n}\n\n// Resolution anchors. @gtkx/* and @gtkx/config resolve as THIS package's\n// dependencies; react resolves FROM @gtkx/react's real location — the\n// reconciler and the app must share one React instance, and anchoring at\n// the app could pick up a second copy installed by npm peer auto-install.\nconst fromPackage = createRequire(import.meta.url)\nconst fromGtkxReact = createRequire(fromPackage.resolve(\"@gtkx/react\"))\n\nconst resolveExternal = (name: string): string =>\n name === \"react\" || name.startsWith(\"react/\")\n ? fromGtkxReact.resolve(name)\n : fromPackage.resolve(name)\n\n// import() handles both ESM and CJS; merge a `default` for Babel's\n// default-import interop when the module has none of its own.\nconst load = async (name: string): Promise<HostModule> => {\n const namespace: HostModule = await import(\n pathToFileURL(resolveExternal(name)).href\n )\n const merged: HostModule = { __esModule: true, ...namespace }\n if (!(\"default\" in namespace)) {\n merged.default = namespace\n }\n return merged\n}\n\n// @gtkx/react imports `virtual:gtkx-config` — JSX metadata plus the values\n// resolved from gtkx.config.ts (applicationId for the GApplication, the\n// userEventSignals suppressed during commits and the elements config the\n// reconciler registry is primed with). In the vite path the gtkx CLI plugin\n// serves it; replicate it with a loader hook, mirroring @gtkx/config's own\n// renderConfigModule. The fake module URL is anchored inside this package so\n// the re-exported bare specifier resolves through node_modules.\nconst CONFIG_REQUIRED =\n \"gtkx.config.ts with an applicationId is required in the app root \" +\n '(export default defineConfig({ applicationId: \"...\", libraries: [...] })).'\nconst { createConfigLoader } = await import(\"@gtkx/config/internal\")\n// The loader validates the config, so a missing or malformed one throws.\n// rc.3 turned the loader from a bare function into `{ load, resolve }`;\n// `resolve` is the runtime projection this module needs.\nconst gtkxConfig = await createConfigLoader()\n .resolve(process.cwd())\n .catch((error: unknown) => fail(`${CONFIG_REQUIRED}\\n${String(error)}`))\nif (!gtkxConfig.applicationId) {\n fail(CONFIG_REQUIRED)\n}\n// A behaviors module would have to be bundled and merged through\n// @gtkx/react/config; the react-native surface owns element behaviors, so no\n// app declares one — refuse rather than silently drop it.\nif (gtkxConfig.elements !== null) {\n fail(\n \"gtkx.config.ts `elements.behaviors` is not supported on the linux \" +\n \"platform — react-native-gtkx owns element behaviors.\",\n )\n}\nconst configModuleUrl = new URL(\"./__virtual-gtkx-config.mjs\", import.meta.url)\n .href\nconst lazyElements = Object.fromEntries(\n gtkxConfig.lazyElements.map((type) => [type, { isLazy: true }]),\n)\nconst configModuleSource = [\n `export * from \"@gtkx/jsx/metadata\";`,\n `export const applicationId = ${JSON.stringify(gtkxConfig.applicationId)};`,\n `export const userEventSignals = ${JSON.stringify(gtkxConfig.userEventSignals)};`,\n `export const elements = ${JSON.stringify(lazyElements)};`,\n].join(\"\\n\")\nregisterHooks({\n resolve(specifier, context, nextResolve) {\n if (specifier === \"virtual:gtkx-config\") {\n return { url: configModuleUrl, shortCircuit: true }\n }\n return nextResolve(specifier, context)\n },\n load(url, context, nextLoad) {\n if (url === configModuleUrl) {\n return {\n format: \"module\",\n source: configModuleSource,\n shortCircuit: true,\n }\n }\n return nextLoad(url, context)\n },\n})\n\nglobalThis.__hostModules = {}\nfor (const name of HOST_MODULE_EXTERNALS) {\n try {\n globalThis.__hostModules[name] = await load(name)\n } catch (error) {\n if (OPTIONAL_HOST_MODULE_EXTERNALS.has(name)) {\n // Expected and fine: this app's gtkx.config.ts never declared the GIR\n // library this module binds (e.g. \"Adw-1\" — the plain-GTK profile,\n // see .claude/epics/adw-optional/001.md). Left unset in\n // __hostModules; a feature that actually needs it throws its own\n // named error when it is reached, not here at startup.\n continue\n }\n fail(\n `failed to load host module \"${name}\" — is the codegen store in ` +\n `place (npx gtkx codegen) and GTK4/libadwaita installed?\\n${String(error)}`,\n )\n }\n}\n// Node builtin proxies resolve lazily through the host's own require.\nglobalThis.__hostRequire = createRequire(import.meta.url)\n\nconst bundlePath = process.argv[2]\nif (!bundlePath) {\n fail(\"usage: node host.js <path/to/main.jsbundle>\")\n}\nlet source: string\ntry {\n source = readFileSync(bundlePath!, \"utf8\")\n} catch {\n fail(`bundle not found at ${bundlePath} — run react-native run-linux.`)\n throw new Error(\"unreachable\")\n}\n// 1.2-WORKAROUND(gtk-application-argv): @gtkx/react's <GtkApplication>\n// now builds the GApplication's own command line from\n// `process.argv.slice(2)` (components/application.js, `runApplication`'s\n// new argv parameter) and hands anything left over to GLib's local\n// command-line handling, which treats stray positionals as files to\n// open. This process's OWN positional argv[2] is our bundle path, not a\n// user-facing argument — left in place it reaches GApplication as a\n// \"file\" no app declares G_APPLICATION_HANDLES_OPEN for\n// (\"GLib-GIO-CRITICAL: This application can not open files\"), and the\n// window never activates. Truncate before the bundle (which mounts\n// <GtkApplication> from an effect, so this always runs first) sees it.\n// Removal condition: @gtkx/react exposes a way to pass runApplication's\n// argv explicitly (an `argv` prop on <GtkApplication>, or an\n// options object) instead of always reading process.argv itself.\nprocess.argv.length = 2\n// The entry calls AppRegistry.runApplication itself (the react-native-web\n// pattern); the GLib main loop keeps the process alive afterwards.\nvm.runInThisContext(source, { filename: bundlePath })\n"]}
@@ -15,6 +15,20 @@ type BuildLinuxArgs = {
15
15
  sea?: boolean;
16
16
  seaOutput?: string;
17
17
  };
18
+ type DeployLinuxArgs = {
19
+ entryFile: string;
20
+ target?: string;
21
+ out?: string;
22
+ printManifests?: boolean;
23
+ skipBuild?: boolean;
24
+ };
25
+ /** Vite's own convention for "this directory is a vite project" — every
26
+ * vite-path example in this repo (gallery, monitor, tasks-app, tasks-nav)
27
+ * has exactly one of these at its root, and no Metro app does (hn-app and
28
+ * rn-app have `metro.config.js` and a root `index.js` instead). Exported so
29
+ * the detection itself is unit-testable without spawning anything. */
30
+ export declare const VITE_CONFIG_CANDIDATES: string[];
31
+ export declare const isViteProject: (root: string) => boolean;
18
32
  /** Commands contributed to the RN CLI by the package's react-native.config.js. */
19
33
  export declare const commands: ({
20
34
  name: string;
@@ -42,5 +56,18 @@ export declare const commands: ({
42
56
  default?: undefined;
43
57
  })[];
44
58
  func: (_argv: string[], config: CliConfig, args: BuildLinuxArgs) => Promise<void>;
59
+ } | {
60
+ name: string;
61
+ description: string;
62
+ options: ({
63
+ name: string;
64
+ description: string;
65
+ default: string;
66
+ } | {
67
+ name: string;
68
+ description: string;
69
+ default?: undefined;
70
+ })[];
71
+ func: (_argv: string[], config: CliConfig, args: DeployLinuxArgs) => Promise<void>;
45
72
  })[];
46
73
  export {};