react-native-gtkx 0.1.0-alpha.1

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 (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/animated/composite.d.ts +5 -0
  4. package/dist/animated/composite.js +132 -0
  5. package/dist/animated/composite.js.map +1 -0
  6. package/dist/animated/create-animated.d.ts +12 -0
  7. package/dist/animated/create-animated.js +17 -0
  8. package/dist/animated/create-animated.js.map +1 -0
  9. package/dist/animated/easing.d.ts +11 -0
  10. package/dist/animated/easing.js +91 -0
  11. package/dist/animated/easing.js.map +1 -0
  12. package/dist/animated/frame-loop.d.ts +6 -0
  13. package/dist/animated/frame-loop.js +25 -0
  14. package/dist/animated/frame-loop.js.map +1 -0
  15. package/dist/animated/index.d.ts +6 -0
  16. package/dist/animated/index.js +7 -0
  17. package/dist/animated/index.js.map +1 -0
  18. package/dist/animated/interpolate.d.ts +2 -0
  19. package/dist/animated/interpolate.js +90 -0
  20. package/dist/animated/interpolate.js.map +1 -0
  21. package/dist/animated/native-driver.d.ts +1 -0
  22. package/dist/animated/native-driver.js +17 -0
  23. package/dist/animated/native-driver.js.map +1 -0
  24. package/dist/animated/spring.d.ts +3 -0
  25. package/dist/animated/spring.js +67 -0
  26. package/dist/animated/spring.js.map +1 -0
  27. package/dist/animated/timing.d.ts +3 -0
  28. package/dist/animated/timing.js +30 -0
  29. package/dist/animated/timing.js.map +1 -0
  30. package/dist/animated/types.d.ts +51 -0
  31. package/dist/animated/types.js +6 -0
  32. package/dist/animated/types.js.map +1 -0
  33. package/dist/animated/value-animation.d.ts +9 -0
  34. package/dist/animated/value-animation.js +65 -0
  35. package/dist/animated/value-animation.js.map +1 -0
  36. package/dist/animated/value.d.ts +46 -0
  37. package/dist/animated/value.js +130 -0
  38. package/dist/animated/value.js.map +1 -0
  39. package/dist/apis/alert.d.ts +16 -0
  40. package/dist/apis/alert.js +33 -0
  41. package/dist/apis/alert.js.map +1 -0
  42. package/dist/apis/app-state.d.ts +11 -0
  43. package/dist/apis/app-state.js +54 -0
  44. package/dist/apis/app-state.js.map +1 -0
  45. package/dist/apis/appearance.d.ts +12 -0
  46. package/dist/apis/appearance.js +33 -0
  47. package/dist/apis/appearance.js.map +1 -0
  48. package/dist/apis/dev-settings.d.ts +9 -0
  49. package/dist/apis/dev-settings.js +25 -0
  50. package/dist/apis/dev-settings.js.map +1 -0
  51. package/dist/apis/dimensions.d.ts +14 -0
  52. package/dist/apis/dimensions.js +80 -0
  53. package/dist/apis/dimensions.js.map +1 -0
  54. package/dist/apis/emitter.d.ts +8 -0
  55. package/dist/apis/emitter.js +35 -0
  56. package/dist/apis/emitter.js.map +1 -0
  57. package/dist/apis/hooks.d.ts +11 -0
  58. package/dist/apis/hooks.js +29 -0
  59. package/dist/apis/hooks.js.map +1 -0
  60. package/dist/apis/host.d.ts +45 -0
  61. package/dist/apis/host.gtkx.d.ts +2 -0
  62. package/dist/apis/host.gtkx.js +301 -0
  63. package/dist/apis/host.gtkx.js.map +1 -0
  64. package/dist/apis/host.js +6 -0
  65. package/dist/apis/host.js.map +1 -0
  66. package/dist/apis/index.d.ts +39 -0
  67. package/dist/apis/index.js +21 -0
  68. package/dist/apis/index.js.map +1 -0
  69. package/dist/apis/linking.d.ts +7 -0
  70. package/dist/apis/linking.js +28 -0
  71. package/dist/apis/linking.js.map +1 -0
  72. package/dist/apis/platform.d.ts +14 -0
  73. package/dist/apis/platform.js +23 -0
  74. package/dist/apis/platform.js.map +1 -0
  75. package/dist/components/activity-indicator.d.ts +10 -0
  76. package/dist/components/activity-indicator.js +21 -0
  77. package/dist/components/activity-indicator.js.map +1 -0
  78. package/dist/components/animated.d.ts +34 -0
  79. package/dist/components/animated.js +152 -0
  80. package/dist/components/animated.js.map +1 -0
  81. package/dist/components/app-registry.d.ts +14 -0
  82. package/dist/components/app-registry.js +61 -0
  83. package/dist/components/app-registry.js.map +1 -0
  84. package/dist/components/flat-list.d.ts +48 -0
  85. package/dist/components/flat-list.js +23 -0
  86. package/dist/components/flat-list.js.map +1 -0
  87. package/dist/components/host-node.d.ts +10 -0
  88. package/dist/components/host-node.js +10 -0
  89. package/dist/components/host-node.js.map +1 -0
  90. package/dist/components/image-loader.d.ts +17 -0
  91. package/dist/components/image-loader.js +54 -0
  92. package/dist/components/image-loader.js.map +1 -0
  93. package/dist/components/image.d.ts +19 -0
  94. package/dist/components/image.js +73 -0
  95. package/dist/components/image.js.map +1 -0
  96. package/dist/components/index.d.ts +14 -0
  97. package/dist/components/index.js +14 -0
  98. package/dist/components/index.js.map +1 -0
  99. package/dist/components/modal.d.ts +12 -0
  100. package/dist/components/modal.js +18 -0
  101. package/dist/components/modal.js.map +1 -0
  102. package/dist/components/pressable.d.ts +33 -0
  103. package/dist/components/pressable.js +116 -0
  104. package/dist/components/pressable.js.map +1 -0
  105. package/dist/components/rect-store.d.ts +17 -0
  106. package/dist/components/rect-store.js +40 -0
  107. package/dist/components/rect-store.js.map +1 -0
  108. package/dist/components/root.d.ts +8 -0
  109. package/dist/components/root.js +59 -0
  110. package/dist/components/root.js.map +1 -0
  111. package/dist/components/scroll-view.d.ts +56 -0
  112. package/dist/components/scroll-view.js +324 -0
  113. package/dist/components/scroll-view.js.map +1 -0
  114. package/dist/components/switch.d.ts +11 -0
  115. package/dist/components/switch.js +20 -0
  116. package/dist/components/switch.js.map +1 -0
  117. package/dist/components/text-input.d.ts +23 -0
  118. package/dist/components/text-input.js +151 -0
  119. package/dist/components/text-input.js.map +1 -0
  120. package/dist/components/text.d.ts +11 -0
  121. package/dist/components/text.js +100 -0
  122. package/dist/components/text.js.map +1 -0
  123. package/dist/components/use-layout-child.d.ts +36 -0
  124. package/dist/components/use-layout-child.js +177 -0
  125. package/dist/components/use-layout-child.js.map +1 -0
  126. package/dist/components/view.d.ts +13 -0
  127. package/dist/components/view.js +60 -0
  128. package/dist/components/view.js.map +1 -0
  129. package/dist/components/virtualized-list.d.ts +67 -0
  130. package/dist/components/virtualized-list.js +519 -0
  131. package/dist/components/virtualized-list.js.map +1 -0
  132. package/dist/contracts.d.ts +119 -0
  133. package/dist/contracts.js +5 -0
  134. package/dist/contracts.js.map +1 -0
  135. package/dist/gtkx/bridge/index.d.ts +16 -0
  136. package/dist/gtkx/bridge/index.js +25 -0
  137. package/dist/gtkx/bridge/index.js.map +1 -0
  138. package/dist/gtkx/bridge/layout-manager.d.ts +11 -0
  139. package/dist/gtkx/bridge/layout-manager.js +87 -0
  140. package/dist/gtkx/bridge/layout-manager.js.map +1 -0
  141. package/dist/gtkx/bridge/measure.d.ts +9 -0
  142. package/dist/gtkx/bridge/measure.js +20 -0
  143. package/dist/gtkx/bridge/measure.js.map +1 -0
  144. package/dist/gtkx/bridge/theme.d.ts +4 -0
  145. package/dist/gtkx/bridge/theme.js +5 -0
  146. package/dist/gtkx/bridge/theme.js.map +1 -0
  147. package/dist/gtkx/bridge/view-box.d.ts +7 -0
  148. package/dist/gtkx/bridge/view-box.js +40 -0
  149. package/dist/gtkx/bridge/view-box.js.map +1 -0
  150. package/dist/index.d.ts +6 -0
  151. package/dist/index.js +7 -0
  152. package/dist/index.js.map +1 -0
  153. package/dist/layout/apply-style.d.ts +4 -0
  154. package/dist/layout/apply-style.js +148 -0
  155. package/dist/layout/apply-style.js.map +1 -0
  156. package/dist/layout/engine.d.ts +22 -0
  157. package/dist/layout/engine.js +90 -0
  158. package/dist/layout/engine.js.map +1 -0
  159. package/dist/layout/index.d.ts +3 -0
  160. package/dist/layout/index.js +4 -0
  161. package/dist/layout/index.js.map +1 -0
  162. package/dist/layout/node.d.ts +33 -0
  163. package/dist/layout/node.js +151 -0
  164. package/dist/layout/node.js.map +1 -0
  165. package/dist/layout/yoga.d.ts +13 -0
  166. package/dist/layout/yoga.js +52 -0
  167. package/dist/layout/yoga.js.map +1 -0
  168. package/dist/metro/index.d.ts +42 -0
  169. package/dist/metro/index.js +119 -0
  170. package/dist/metro/index.js.map +1 -0
  171. package/dist/runner/host-dev.d.ts +1 -0
  172. package/dist/runner/host-dev.js +208 -0
  173. package/dist/runner/host-dev.js.map +1 -0
  174. package/dist/runner/host.d.ts +1 -0
  175. package/dist/runner/host.js +101 -0
  176. package/dist/runner/host.js.map +1 -0
  177. package/dist/runner/index.d.ts +26 -0
  178. package/dist/runner/index.js +179 -0
  179. package/dist/runner/index.js.map +1 -0
  180. package/dist/style/colors.d.ts +17 -0
  181. package/dist/style/colors.js +375 -0
  182. package/dist/style/colors.js.map +1 -0
  183. package/dist/style/dev-warning.d.ts +2 -0
  184. package/dist/style/dev-warning.js +18 -0
  185. package/dist/style/dev-warning.js.map +1 -0
  186. package/dist/style/index.d.ts +7 -0
  187. package/dist/style/index.js +14 -0
  188. package/dist/style/index.js.map +1 -0
  189. package/dist/style/registry.d.ts +12 -0
  190. package/dist/style/registry.gtkx.d.ts +2 -0
  191. package/dist/style/registry.gtkx.js +9 -0
  192. package/dist/style/registry.gtkx.js.map +1 -0
  193. package/dist/style/registry.js +23 -0
  194. package/dist/style/registry.js.map +1 -0
  195. package/dist/style/split-style.d.ts +6 -0
  196. package/dist/style/split-style.js +107 -0
  197. package/dist/style/split-style.js.map +1 -0
  198. package/dist/style/style-sheet.d.ts +43 -0
  199. package/dist/style/style-sheet.js +57 -0
  200. package/dist/style/style-sheet.js.map +1 -0
  201. package/dist/style/text-align.d.ts +7 -0
  202. package/dist/style/text-align.js +22 -0
  203. package/dist/style/text-align.js.map +1 -0
  204. package/dist/style/visual-css.d.ts +6 -0
  205. package/dist/style/visual-css.js +133 -0
  206. package/dist/style/visual-css.js.map +1 -0
  207. package/dist/vite/index.d.ts +53 -0
  208. package/dist/vite/index.js +127 -0
  209. package/dist/vite/index.js.map +1 -0
  210. package/package.json +88 -0
  211. package/react-native.config.js +21 -0
  212. package/types.d.ts +43 -0
  213. package/types.js +4 -0
@@ -0,0 +1,127 @@
1
+ // react-native-gtkx/vite — makes a gtkx project React Native compatible.
2
+ // The gtkx CLI (dev and build) starts vite with an inline config that never
3
+ // sets `configFile: false`, so vite picks up the project's vite.config.ts
4
+ // from the root and merges it beneath the CLI config; this preset plugs in
5
+ // there as a single plugin.
6
+ //
7
+ // Single self-contained file on purpose: vite loads the config's imported
8
+ // packages with BARE Node, so this subpath (like ./metro and ./runner) must
9
+ // not contain extensionless relative imports — the pure resolution helpers
10
+ // live here rather than in a sibling module.
11
+ import { existsSync } from "node:fs";
12
+ import { dirname, extname, isAbsolute, resolve } from "node:path";
13
+ export const DEFAULT_PLATFORMS = ["linux", "native"];
14
+ export const DEFAULT_EXTENSIONS = ["tsx", "ts", "jsx", "js"];
15
+ const REACT_NATIVE = "react-native";
16
+ const REACT_NATIVE_GTKX = "react-native-gtkx";
17
+ /**
18
+ * Maps `react-native` (and its subpaths) to `react-native-gtkx`.
19
+ * Returns null for every other specifier, including `react-native-gtkx`
20
+ * itself and lookalikes such as `react-native-web`.
21
+ */
22
+ export const rewriteReactNativeImport = (source) => {
23
+ if (source === REACT_NATIVE) {
24
+ return REACT_NATIVE_GTKX;
25
+ }
26
+ if (source.startsWith(`${REACT_NATIVE}/`)) {
27
+ return `${REACT_NATIVE_GTKX}${source.slice(REACT_NATIVE.length)}`;
28
+ }
29
+ return null;
30
+ };
31
+ /** Splits a vite specifier into its path part and its `?query` suffix. */
32
+ export const splitQuery = (source) => {
33
+ const index = source.indexOf("?");
34
+ if (index === -1) {
35
+ return { specifier: source, query: "" };
36
+ }
37
+ return { specifier: source.slice(0, index), query: source.slice(index) };
38
+ };
39
+ const isRelative = (specifier) => specifier.startsWith("./") || specifier.startsWith("../");
40
+ /**
41
+ * Ordered platform suffixes, platform-major: every extension of the first
42
+ * platform is tried before any extension of the next one
43
+ * (`.linux.tsx`, `.linux.ts`, …, `.native.tsx`, …).
44
+ */
45
+ export const platformSuffixes = (options = {}) => {
46
+ const platforms = options.platforms ?? DEFAULT_PLATFORMS;
47
+ const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
48
+ return platforms.flatMap((platform) => extensions.map((extension) => `.${platform}.${extension}`));
49
+ };
50
+ /**
51
+ * Candidate file paths for an extensionless base path, in priority order:
52
+ * direct platform files first, then platform index files of a directory —
53
+ * mirroring Metro, which exhausts file resolution before directory resolution.
54
+ * The base file itself is not a candidate: when no platform file exists the
55
+ * plugin bails out and the default resolver picks the base module.
56
+ */
57
+ export const platformCandidates = (base, options = {}) => {
58
+ const suffixes = platformSuffixes(options);
59
+ return [
60
+ ...suffixes.map((suffix) => `${base}${suffix}`),
61
+ ...suffixes.map((suffix) => `${base}/index${suffix}`),
62
+ ];
63
+ };
64
+ /**
65
+ * Metro platform-extension resolution for a single import:
66
+ * only extensionless relative (or absolute) specifiers participate; the first
67
+ * existing candidate wins; the `?query` suffix is carried over. Returns null
68
+ * when the import is out of scope or no platform file exists, handing the
69
+ * import back to the default resolver.
70
+ */
71
+ export const resolvePlatformSpecifier = (source, importer, exists, options = {}) => {
72
+ if (importer === undefined || source.startsWith("\0")) {
73
+ return null;
74
+ }
75
+ const { specifier, query } = splitQuery(source);
76
+ if (!isRelative(specifier) && !isAbsolute(specifier)) {
77
+ return null;
78
+ }
79
+ if (extname(specifier) !== "") {
80
+ return null;
81
+ }
82
+ const base = isAbsolute(specifier)
83
+ ? specifier
84
+ : resolve(dirname(splitQuery(importer).specifier), specifier);
85
+ for (const candidate of platformCandidates(base, options)) {
86
+ if (exists(candidate)) {
87
+ return candidate + query;
88
+ }
89
+ }
90
+ return null;
91
+ };
92
+ /**
93
+ * Vite plugin: aliases `react-native` (and subpaths) to `react-native-gtkx`
94
+ * and resolves Metro-style platform extensions
95
+ * (`.linux.tsx` → `.native.tsx` → base) for extensionless imports.
96
+ */
97
+ export const reactNativeGtkx = (options = {}) => ({
98
+ name: "react-native-gtkx:preset",
99
+ // Before vite's own resolver and the gtkx CLI plugins: the alias must win
100
+ // over node resolution and platform files must win over the base file.
101
+ enforce: "pre",
102
+ config: () => ({
103
+ ssr: {
104
+ // `gtkx dev` runs vite with ssr.external: true, which would hand
105
+ // react-native-gtkx straight to node. Keep the package inside the
106
+ // vite pipeline; noExternal wins over external: true.
107
+ //
108
+ // "react-native" must be listed too: with ssr.external: true vite
109
+ // externalizes a bare import BEFORE the plugin pipeline whenever the
110
+ // package resolves natively — and the real react-native (a Flow
111
+ // codebase Node cannot parse) exists in RN monorepos. noExternal
112
+ // forces the full plugin resolution, where the alias rewrites the
113
+ // import to react-native-gtkx.
114
+ noExternal: ["react-native-gtkx", "react-native"],
115
+ },
116
+ }),
117
+ async resolveId(source, importer) {
118
+ const aliased = rewriteReactNativeImport(source);
119
+ if (aliased !== null) {
120
+ const resolved = await this.resolve(aliased, importer, { skipSelf: true });
121
+ return resolved ?? aliased;
122
+ }
123
+ return resolvePlatformSpecifier(source, importer, existsSync, options);
124
+ },
125
+ });
126
+ export default reactNativeGtkx;
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,6CAA6C;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAgBjE,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAsB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAE/E,MAAM,YAAY,GAAG,cAAc,CAAA;AACnC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAiB,EAAE;IACxE,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AC,EAAE,CAAC;QAC1D,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACtB,OAAO,SAAS,GAAG,KAAK,CAAA;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAMD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAAkC,EAAE,EAC5B,EAAE,CAAC,CAAC;IACZ,IAAI,EAAE,0BAA0B;IAChC,0EAA0E;IAC1E,uEAAuE;IACvE,OAAO,EAAE,KAAK;IAEd,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACb,GAAG,EAAE;YACH,iEAAiE;YACjE,kEAAkE;YAClE,sDAAsD;YACtD,EAAE;YACF,kEAAkE;YAClE,qEAAqE;YACrE,gEAAgE;YAChE,iEAAiE;YACjE,kEAAkE;YAClE,+BAA+B;YAC/B,UAAU,EAAE,CAAC,mBAAmB,EAAE,cAAc,CAAC;SAClD;KACF,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ;QAC9B,MAAM,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAA;QAChD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;YAC1E,OAAO,QAAQ,IAAI,OAAO,CAAA;QAC5B,CAAC;QACD,OAAO,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACxE,CAAC;CACF,CAAC,CAAA;AAEF,eAAe,eAAe,CAAA","sourcesContent":["// react-native-gtkx/vite — makes a gtkx project React Native compatible.\n// The gtkx CLI (dev and build) starts vite with an inline config that never\n// sets `configFile: false`, so vite picks up the project's vite.config.ts\n// from the root and merges it beneath the CLI config; this preset plugs in\n// there as a single plugin.\n//\n// Single self-contained file on purpose: vite loads the config's imported\n// packages with BARE Node, so this subpath (like ./metro and ./runner) must\n// not contain extensionless relative imports — the pure resolution helpers\n// live here rather than in a sibling module.\nimport { existsSync } from \"node:fs\"\nimport { dirname, extname, isAbsolute, resolve } from \"node:path\"\nimport type { Plugin } from \"vite\"\n\n// --- pure resolution logic (unit-tested directly) -----------------------\n\n/** Options shared by the preset factory and the pure resolver helpers. */\nexport type PlatformResolutionOptions = {\n /** Platform suffix priority, most specific first. Default: [\"linux\", \"native\"]. */\n platforms?: readonly string[]\n /** Source extensions tried for every platform suffix. Default: [\"tsx\", \"ts\", \"jsx\", \"js\"]. */\n extensions?: readonly string[]\n}\n\n/** Predicate the plugin injects as fs.existsSync; tests inject fakes. */\nexport type FileExists = (filePath: string) => boolean\n\nexport const DEFAULT_PLATFORMS: readonly string[] = [\"linux\", \"native\"]\nexport const DEFAULT_EXTENSIONS: readonly string[] = [\"tsx\", \"ts\", \"jsx\", \"js\"]\n\nconst REACT_NATIVE = \"react-native\"\nconst REACT_NATIVE_GTKX = \"react-native-gtkx\"\n\n/**\n * Maps `react-native` (and its subpaths) to `react-native-gtkx`.\n * Returns null for every other specifier, including `react-native-gtkx`\n * itself and lookalikes such as `react-native-web`.\n */\nexport const rewriteReactNativeImport = (source: string): string | null => {\n if (source === REACT_NATIVE) {\n return REACT_NATIVE_GTKX\n }\n if (source.startsWith(`${REACT_NATIVE}/`)) {\n return `${REACT_NATIVE_GTKX}${source.slice(REACT_NATIVE.length)}`\n }\n return null\n}\n\n/** Splits a vite specifier into its path part and its `?query` suffix. */\nexport const splitQuery = (\n source: string,\n): { specifier: string; query: string } => {\n const index = source.indexOf(\"?\")\n if (index === -1) {\n return { specifier: source, query: \"\" }\n }\n return { specifier: source.slice(0, index), query: source.slice(index) }\n}\n\nconst isRelative = (specifier: string): boolean =>\n specifier.startsWith(\"./\") || specifier.startsWith(\"../\")\n\n/**\n * Ordered platform suffixes, platform-major: every extension of the first\n * platform is tried before any extension of the next one\n * (`.linux.tsx`, `.linux.ts`, …, `.native.tsx`, …).\n */\nexport const platformSuffixes = (\n options: PlatformResolutionOptions = {},\n): string[] => {\n const platforms = options.platforms ?? DEFAULT_PLATFORMS\n const extensions = options.extensions ?? DEFAULT_EXTENSIONS\n return platforms.flatMap((platform) =>\n extensions.map((extension) => `.${platform}.${extension}`),\n )\n}\n\n/**\n * Candidate file paths for an extensionless base path, in priority order:\n * direct platform files first, then platform index files of a directory —\n * mirroring Metro, which exhausts file resolution before directory resolution.\n * The base file itself is not a candidate: when no platform file exists the\n * plugin bails out and the default resolver picks the base module.\n */\nexport const platformCandidates = (\n base: string,\n options: PlatformResolutionOptions = {},\n): string[] => {\n const suffixes = platformSuffixes(options)\n return [\n ...suffixes.map((suffix) => `${base}${suffix}`),\n ...suffixes.map((suffix) => `${base}/index${suffix}`),\n ]\n}\n\n/**\n * Metro platform-extension resolution for a single import:\n * only extensionless relative (or absolute) specifiers participate; the first\n * existing candidate wins; the `?query` suffix is carried over. Returns null\n * when the import is out of scope or no platform file exists, handing the\n * import back to the default resolver.\n */\nexport const resolvePlatformSpecifier = (\n source: string,\n importer: string | undefined,\n exists: FileExists,\n options: PlatformResolutionOptions = {},\n): string | null => {\n if (importer === undefined || source.startsWith(\"\\0\")) {\n return null\n }\n const { specifier, query } = splitQuery(source)\n if (!isRelative(specifier) && !isAbsolute(specifier)) {\n return null\n }\n if (extname(specifier) !== \"\") {\n return null\n }\n const base = isAbsolute(specifier)\n ? specifier\n : resolve(dirname(splitQuery(importer).specifier), specifier)\n for (const candidate of platformCandidates(base, options)) {\n if (exists(candidate)) {\n return candidate + query\n }\n }\n return null\n}\n\n// --- the vite plugin ----------------------------------------------------\n\nexport type ReactNativeGtkxOptions = PlatformResolutionOptions\n\n/**\n * Vite plugin: aliases `react-native` (and subpaths) to `react-native-gtkx`\n * and resolves Metro-style platform extensions\n * (`.linux.tsx` → `.native.tsx` → base) for extensionless imports.\n */\nexport const reactNativeGtkx = (\n options: ReactNativeGtkxOptions = {},\n): Plugin => ({\n name: \"react-native-gtkx:preset\",\n // Before vite's own resolver and the gtkx CLI plugins: the alias must win\n // over node resolution and platform files must win over the base file.\n enforce: \"pre\",\n\n config: () => ({\n ssr: {\n // `gtkx dev` runs vite with ssr.external: true, which would hand\n // react-native-gtkx straight to node. Keep the package inside the\n // vite pipeline; noExternal wins over external: true.\n //\n // \"react-native\" must be listed too: with ssr.external: true vite\n // externalizes a bare import BEFORE the plugin pipeline whenever the\n // package resolves natively — and the real react-native (a Flow\n // codebase Node cannot parse) exists in RN monorepos. noExternal\n // forces the full plugin resolution, where the alias rewrites the\n // import to react-native-gtkx.\n noExternal: [\"react-native-gtkx\", \"react-native\"],\n },\n }),\n\n async resolveId(source, importer) {\n const aliased = rewriteReactNativeImport(source)\n if (aliased !== null) {\n const resolved = await this.resolve(aliased, importer, { skipSelf: true })\n return resolved ?? aliased\n }\n return resolvePlatformSpecifier(source, importer, existsSync, options)\n },\n})\n\nexport default reactNativeGtkx\n"]}
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "react-native-gtkx",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "React Native components and APIs for Linux desktop, rendered as native GTK4 widgets via gtkx",
5
+ "license": "MIT",
6
+ "author": "Anton Petrov <anton@itsmepetrov.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/itsmepetrov/react-native-gtkx.git",
10
+ "directory": "packages/react-native-gtkx"
11
+ },
12
+ "homepage": "https://github.com/itsmepetrov/react-native-gtkx#readme",
13
+ "bugs": "https://github.com/itsmepetrov/react-native-gtkx/issues",
14
+ "keywords": [
15
+ "react-native",
16
+ "react",
17
+ "gtk",
18
+ "gtk4",
19
+ "libadwaita",
20
+ "linux",
21
+ "desktop",
22
+ "gnome",
23
+ "yoga",
24
+ "out-of-tree-platform"
25
+ ],
26
+ "type": "module",
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "engines": {
30
+ "node": ">=22.15"
31
+ },
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "default": "./dist/index.js"
37
+ },
38
+ "./metro": {
39
+ "types": "./dist/metro/index.d.ts",
40
+ "default": "./dist/metro/index.js"
41
+ },
42
+ "./runner": {
43
+ "types": "./dist/runner/index.d.ts",
44
+ "default": "./dist/runner/index.js"
45
+ },
46
+ "./vite": {
47
+ "types": "./dist/vite/index.d.ts",
48
+ "default": "./dist/vite/index.js"
49
+ },
50
+ "./types": {
51
+ "types": "./types.d.ts",
52
+ "default": "./types.js"
53
+ }
54
+ },
55
+ "scripts": {
56
+ "prepack": "bash ../../scripts/sync-package-readme.sh",
57
+ "build:dist": "rm -rf dist && tsc -p tsconfig.build.json",
58
+ "watch:dist": "tsc -p tsconfig.build.json --watch --preserveWatchOutput"
59
+ },
60
+ "peerDependencies": {
61
+ "react": "^19",
62
+ "vite": "^7.0.0 || ^8.0.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "vite": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "dependencies": {
70
+ "@gtkx/cli": "1.0.0-rc.1",
71
+ "@gtkx/config": "1.0.0-rc.1",
72
+ "@gtkx/css": "1.0.0-rc.1",
73
+ "@gtkx/react": "1.0.0-rc.1",
74
+ "@gtkx/runtime": "1.0.0-rc.1",
75
+ "yoga-layout": "^3.2.1"
76
+ },
77
+ "devDependencies": {
78
+ "@gtkx/testing": "1.0.0-rc.1",
79
+ "@gtkx/vitest": "1.0.0-rc.1",
80
+ "vite": "^8.1.4"
81
+ },
82
+ "files": [
83
+ "dist",
84
+ "react-native.config.js",
85
+ "types.d.ts",
86
+ "types.js"
87
+ ]
88
+ }
@@ -0,0 +1,21 @@
1
+ // Out-of-tree platform declaration (the react-native-windows model): apps
2
+ // depending on this package get the "linux" platform and the run-linux
3
+ // command registered with the RN CLI. The package is type:module, so this
4
+ // config is an ES module — the CLI loads dependency configs through a
5
+ // loader that accepts both. The self-reference resolves through the
6
+ // exports map into the built dist.
7
+ import { commands } from "react-native-gtkx/runner"
8
+
9
+ export default {
10
+ commands,
11
+ platforms: {
12
+ linux: {
13
+ npmPackageName: "react-native-gtkx",
14
+ // The out-of-tree contract requires both hooks. They feed autolinking
15
+ // of platform-native project files — our "native" is plain Node
16
+ // modules resolved at runtime, so there is nothing to link.
17
+ projectConfig: () => null,
18
+ dependencyConfig: () => null,
19
+ },
20
+ },
21
+ }
package/types.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ // TypeScript extensions for the linux platform, applied to the STOCK
2
+ // react-native types via module augmentation. Reference this file once in
3
+ // the app — e.g. an env.d.ts containing:
4
+ //
5
+ // import "react-native-gtkx/types"
6
+ //
7
+ // and `Platform.select({ linux: ... })` typechecks against the regular
8
+ // react-native types (interfaces merge; the closed inline parameter types
9
+ // of the stock overloads cannot be reopened, so the linux-aware signatures
10
+ // are added as overloads). Future platform-specific props on standard
11
+ // components (the react-native-windows pattern) belong here too.
12
+ //
13
+ // Known limitation: `Platform.OS === "linux"` cannot be taught to the
14
+ // stock types — property types do not merge. Use
15
+ // `Platform.select({ linux: ..., default: ... })` in typed code.
16
+
17
+ declare module "react-native" {
18
+ interface PlatformStatic {
19
+ select<T>(
20
+ specifics: {
21
+ linux?: T
22
+ ios?: T
23
+ android?: T
24
+ macos?: T
25
+ windows?: T
26
+ web?: T
27
+ native?: T
28
+ } & { default: T },
29
+ ): T
30
+ select<T>(specifics: {
31
+ linux: T
32
+ ios?: T
33
+ android?: T
34
+ macos?: T
35
+ windows?: T
36
+ web?: T
37
+ native?: T
38
+ default?: T
39
+ }): T | undefined
40
+ }
41
+ }
42
+
43
+ export {}
package/types.js ADDED
@@ -0,0 +1,4 @@
1
+ // Runtime stub for the type-only "react-native-gtkx/types" subpath: the
2
+ // module exists purely for its ambient declarations (see types.d.ts), but
3
+ // an accidental runtime import must not crash.
4
+ export {}