react-native-gtkx 0.3.0-alpha.1 → 0.4.0-alpha.2
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.
- package/README.md +1 -1
- package/dist/adw/index.d.ts +3 -2
- package/dist/adw/index.js +21 -4
- package/dist/adw/index.js.map +1 -1
- package/dist/adw/widgets.generated.d.ts +1 -1
- package/dist/adw/widgets.generated.js +2 -2
- package/dist/adw/widgets.generated.js.map +1 -1
- package/dist/animated/create-animated.d.ts +2 -0
- package/dist/animated/create-animated.js +2 -0
- package/dist/animated/create-animated.js.map +1 -1
- package/dist/animated/event.d.ts +15 -0
- package/dist/animated/event.js +80 -0
- package/dist/animated/event.js.map +1 -0
- package/dist/animated/index.d.ts +4 -0
- package/dist/animated/index.js +8 -0
- package/dist/animated/index.js.map +1 -1
- package/dist/animated/spring.d.ts +10 -0
- package/dist/animated/spring.js +20 -6
- package/dist/animated/spring.js.map +1 -1
- package/dist/animated/timing.d.ts +10 -0
- package/dist/animated/timing.js +21 -13
- package/dist/animated/timing.js.map +1 -1
- package/dist/apis/host.gtkx.js +70 -11
- package/dist/apis/host.gtkx.js.map +1 -1
- package/dist/common/navigation-stack.d.ts +6 -3
- package/dist/common/navigation-stack.js +8 -1
- package/dist/common/navigation-stack.js.map +1 -1
- package/dist/common/widget.js +2 -11
- package/dist/common/widget.js.map +1 -1
- package/dist/components/animated.d.ts +1 -0
- package/dist/components/animated.js +28 -4
- package/dist/components/animated.js.map +1 -1
- package/dist/components/app-registry.js +32 -8
- package/dist/components/app-registry.js.map +1 -1
- package/dist/components/request-animation-frame.d.ts +33 -0
- package/dist/components/request-animation-frame.js +83 -0
- package/dist/components/request-animation-frame.js.map +1 -0
- package/dist/components/scroll-view.js +60 -2
- package/dist/components/scroll-view.js.map +1 -1
- package/dist/components/virtualized-list.js +1 -4
- package/dist/components/virtualized-list.js.map +1 -1
- package/dist/dnd/autoscroll.d.ts +44 -0
- package/dist/dnd/autoscroll.js +176 -0
- package/dist/dnd/autoscroll.js.map +1 -0
- package/dist/dnd/grid-order.d.ts +45 -0
- package/dist/dnd/grid-order.js +151 -0
- package/dist/dnd/grid-order.js.map +1 -0
- package/dist/dnd/grid.d.ts +44 -0
- package/dist/dnd/grid.js +397 -0
- package/dist/dnd/grid.js.map +1 -0
- package/dist/dnd/gtk-controllers.d.ts +16 -2
- package/dist/dnd/gtk-controllers.js +23 -3
- package/dist/dnd/gtk-controllers.js.map +1 -1
- package/dist/dnd/index.d.ts +4 -2
- package/dist/dnd/index.js +9 -2
- package/dist/dnd/index.js.map +1 -1
- package/dist/dnd/order-state.d.ts +14 -0
- package/dist/dnd/order-state.js +55 -0
- package/dist/dnd/order-state.js.map +1 -0
- package/dist/dnd/order.d.ts +19 -0
- package/dist/dnd/order.js +19 -0
- package/dist/dnd/order.js.map +1 -1
- package/dist/dnd/sortable.d.ts +29 -4
- package/dist/dnd/sortable.js +308 -115
- package/dist/dnd/sortable.js.map +1 -1
- package/dist/dnd/types.d.ts +236 -14
- package/dist/dnd/types.js +30 -0
- package/dist/dnd/types.js.map +1 -1
- package/dist/gesture-handler-compat/attach-context.d.ts +29 -0
- package/dist/gesture-handler-compat/attach-context.js +90 -0
- package/dist/gesture-handler-compat/attach-context.js.map +1 -0
- package/dist/gesture-handler-compat/detector-runtime.d.ts +14 -3
- package/dist/gesture-handler-compat/detector-runtime.js +15 -5
- package/dist/gesture-handler-compat/detector-runtime.js.map +1 -1
- package/dist/gesture-handler-compat/detector.js +57 -2
- package/dist/gesture-handler-compat/detector.js.map +1 -1
- package/dist/gesture-handler-compat/gesture-state-manager.d.ts +5 -0
- package/dist/gesture-handler-compat/gesture-state-manager.js +77 -0
- package/dist/gesture-handler-compat/gesture-state-manager.js.map +1 -0
- package/dist/gesture-handler-compat/index.d.ts +2 -2
- package/dist/gesture-handler-compat/index.js +38 -33
- package/dist/gesture-handler-compat/index.js.map +1 -1
- package/dist/gesture-handler-compat/recognizer.d.ts +12 -1
- package/dist/gesture-handler-compat/recognizer.js +23 -9
- package/dist/gesture-handler-compat/recognizer.js.map +1 -1
- package/dist/gesture-handler-compat/tag-registry.d.ts +14 -0
- package/dist/gesture-handler-compat/tag-registry.js +19 -0
- package/dist/gesture-handler-compat/tag-registry.js.map +1 -0
- package/dist/globals/index.d.ts +47 -0
- package/dist/globals/index.js +181 -0
- package/dist/globals/index.js.map +1 -0
- package/dist/globals/install.d.ts +1 -0
- package/dist/globals/install.js +14 -0
- package/dist/globals/install.js.map +1 -0
- package/dist/gtkx/bridge/adw-namespace.d.ts +2 -0
- package/dist/gtkx/bridge/adw-namespace.js +26 -0
- package/dist/gtkx/bridge/adw-namespace.js.map +1 -0
- package/dist/gtkx/bridge/adw.d.ts +23 -0
- package/dist/gtkx/bridge/adw.js +93 -0
- package/dist/gtkx/bridge/adw.js.map +1 -0
- package/dist/gtkx/bridge/color-scheme-parse.d.ts +11 -0
- package/dist/gtkx/bridge/color-scheme-parse.js +42 -0
- package/dist/gtkx/bridge/color-scheme-parse.js.map +1 -0
- package/dist/gtkx/bridge/color-scheme-portal.d.ts +24 -0
- package/dist/gtkx/bridge/color-scheme-portal.js +172 -0
- package/dist/gtkx/bridge/color-scheme-portal.js.map +1 -0
- package/dist/gtkx/bridge/core.d.ts +25 -0
- package/dist/gtkx/bridge/core.js +69 -0
- package/dist/gtkx/bridge/core.js.map +1 -0
- package/dist/gtkx/bridge/drag-layer.d.ts +27 -0
- package/dist/gtkx/bridge/drag-layer.js +177 -0
- package/dist/gtkx/bridge/drag-layer.js.map +1 -0
- package/dist/gtkx/bridge/index.d.ts +1 -27
- package/dist/gtkx/bridge/index.js +12 -71
- package/dist/gtkx/bridge/index.js.map +1 -1
- package/dist/gtkx/bridge/widgets.generated.adw.d.ts +1 -0
- package/dist/gtkx/bridge/widgets.generated.adw.js +16 -0
- package/dist/gtkx/bridge/widgets.generated.adw.js.map +1 -0
- package/dist/gtkx/bridge/widgets.generated.d.ts +0 -1
- package/dist/gtkx/bridge/widgets.generated.js +3 -3
- package/dist/gtkx/bridge/widgets.generated.js.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/data/generated.d.ts +41 -20
- package/dist/mcp/data/generated.js +46 -20
- package/dist/mcp/data/generated.js.map +1 -1
- package/dist/metro/index.d.ts +1 -0
- package/dist/metro/index.js +12 -0
- package/dist/metro/index.js.map +1 -1
- package/dist/navigation/sidebar.js +2 -45
- package/dist/navigation/sidebar.js.map +1 -1
- package/dist/reanimated-compat/animatable-value.d.ts +158 -0
- package/dist/reanimated-compat/animatable-value.js +316 -0
- package/dist/reanimated-compat/animatable-value.js.map +1 -0
- package/dist/reanimated-compat/animation.d.ts +34 -13
- package/dist/reanimated-compat/animation.js +97 -25
- package/dist/reanimated-compat/animation.js.map +1 -1
- package/dist/reanimated-compat/mutable.js +6 -6
- package/dist/reanimated-compat/mutable.js.map +1 -1
- package/dist/reanimated-compat/updater-animations.js +32 -12
- package/dist/reanimated-compat/updater-animations.js.map +1 -1
- package/dist/runner/host-dev.js +5 -1
- package/dist/runner/host-dev.js.map +1 -1
- package/dist/runner/host.js +9 -1
- package/dist/runner/host.js.map +1 -1
- package/dist/vite/index.js +130 -0
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/gtkx/bridge/theme.d.ts +0 -4
- package/dist/gtkx/bridge/theme.js +0 -5
- package/dist/gtkx/bridge/theme.js.map +0 -1
package/dist/vite/index.js.map
CHANGED
|
@@ -1 +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,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,OAA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V,WAAW;oBACX,cAAc;oBACd,aAAa;oBACb,eAAe;oBACf,gEAAgE;oBAChE,kDAAkD;oBAClD,wBAAwB;oBACxB,0BAA0B;oBAC1B,OAAO;iBACR;aACF;SACF,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ;YAC9B,uEAAuE;YACvE,qEAAqE;YACrE,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;YAC7C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACrB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE;oBACrD,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAA;gBACF,OAAO,QAAQ,IAAI,OAAO,CAAA;YAC5B,CAAC;YACD,OAAO,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,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// vite loads the config's imported packages with BARE Node, so this subpath\n// (like ./metro and ./runner) must not contain EXTENSIONLESS relative imports\n// — the pure resolution helpers live here rather than in a sibling module,\n// and the one import that does cross a file boundary spells out its `.js`.\nimport { existsSync } from \"node:fs\"\nimport { dirname, extname, isAbsolute, resolve } from \"node:path\"\nimport type { Plugin } from \"vite\"\nimport {\n applyAliases,\n compileAliases,\n DEFAULT_ALIAS_TABLE,\n type AliasOverrides,\n} from \"../aliases/index.js\"\n\n// Re-exported so an app configuring `aliases` never has to reach past the\n// preset subpath it already imports.\nexport {\n CONFIGURABLE_ALIASES,\n DEFAULT_ALIASES,\n PLATFORM_ALIAS,\n} from \"../aliases/index.js\"\nexport type {\n AliasOverride,\n AliasOverrides,\n AliasPattern,\n AliasTable,\n CompiledAlias,\n} from \"../aliases/index.js\"\n\n// --- 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_GTKX = \"react-native-gtkx\"\n\n/**\n * Applies the DEFAULT alias table (../aliases/index.ts) to one specifier:\n * `react-native` and its subpaths onto `react-native-gtkx`, and the five\n * package substitutions onto their compat subpaths. Returns null for every\n * other specifier, including `react-native-gtkx` itself.\n *\n * Exported for tests and for apps driving vite by hand. The plugin does NOT\n * call it — the plugin resolves through the table its own `aliases` option\n * produced, so an app's deltas apply.\n */\nexport const rewriteReactNativeImport = (source: string): string | null =>\n applyAliases(DEFAULT_ALIAS_TABLE, source)\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// Source extensions Metro strips before trying platform variants: an\n// import of \"./useLinking.js\" (the TS-ESM style react-navigation and most\n// compiled RN libraries use) must still find useLinking.native.tsx /\n// useLinking.native.js — Metro resolves the BASE name platform-first, the\n// literal file is only the fallback.\nconst STRIPPABLE_EXTENSIONS = new Set([\".js\", \".jsx\", \".mjs\", \".ts\", \".tsx\"])\n\n/**\n * Metro platform-extension resolution for a single import: relative (or\n * absolute) specifiers that are extensionless — or carry a strippable\n * source extension — try platform candidates first; the first existing\n * candidate wins; the `?query` suffix is carried over. Returns null when\n * 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 const extension = extname(specifier)\n if (extension !== \"\" && !STRIPPABLE_EXTENSIONS.has(extension)) {\n return null\n }\n const withExtension = isAbsolute(specifier)\n ? specifier\n : resolve(dirname(splitQuery(importer).specifier), specifier)\n const base =\n extension === \"\" ? withExtension : withExtension.slice(0, -extension.length)\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 * Deltas over the preset's package aliases, keyed by package name — a\n * string target, a `{ pattern, replace }` rule, or `false` to drop one of\n * ours so the real package loads. Identical semantics to the Metro\n * preset's option of the same name: both compile the same table.\n * Invalid entries throw here, while the config is being read.\n */\n aliases?: AliasOverrides\n}\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 // Throws on an unknown key, an overlapping pattern or an attempt to remove\n // the platform alias — at config load, naming what is valid.\n const aliases = compileAliases(options.aliases)\n return {\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: (_config, env) => ({\n // `__DEV__` is part of the react-native runtime contract, not a Metro\n // detail: RN's own modules branch on it and so does every library\n // written against them (`@gorhom/bottom-sheet`'s logger and four of its\n // components read it at module scope). The Metro path gets it from the\n // app's stock RN preset; nothing supplied it on the vite path, so a\n // library that reads it crashed the bundle at startup with\n // \"ReferenceError: __DEV__ is not defined\" — found by building\n // spike/core-exports rather than by reading anything.\n //\n // vite's mode is the honest source: `gtkx dev` builds in development,\n // `gtkx build` in production, which is exactly the distinction RN draws.\n define: {\n __DEV__: JSON.stringify(env.mode !== \"production\"),\n },\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 // \"react-native-reanimated\" for the same reason as \"react-native\": an\n // app that also ships iOS/Android keeps the real package installed, it\n // resolves natively, and ssr.external: true would hand Node a codebase\n // built around a Babel plugin and a worklet runtime before the alias\n // ever gets a chance to rewrite the import.\n // \"react-native-worklets\" is the same case one package over — it is\n // where that worklet runtime actually lives since Reanimated 4.\n //\n // The rule those are instances of, stated once so the next alias does\n // not have to rediscover it: EVERY package name in the alias table must\n // be listed here. An alias is a resolveId hook, and a bare specifier\n // that vite externalizes never reaches one — so on the dev path the\n // alias silently loses to whatever is installed under the real name.\n // That is not hypothetical: an app that also ships iOS and Android has\n // all of them in node_modules, which is the case the alias exists to\n // serve. `react-native-gesture-handler` proved it — this list once held\n // three of the six names, its real package loaded, and it failed on an\n // extensionless internal import Node cannot resolve (found by running\n // the gallery's upstream-libraries section, which installs it).\n //\n // So the list is DERIVED rather than written out: it is exactly the\n // table's package names, and a name can no longer go missing from one\n // of the two places it has to appear.\n //\n // `aliases.names` includes the packages an app turned OFF with `false`,\n // deliberately. Dropping an alias means the REAL package loads, and the\n // real package imports `react-native` at module scope — an import that\n // only reaches the platform alias if Node never gets the package first.\n // Un-aliasing a package is therefore a reason to keep it inside the\n // pipeline, not a reason to let it out.\n noExternal: [\n REACT_NATIVE_GTKX,\n ...aliases.names,\n // @react-navigation is not aliased, but must go through the pipeline\n // too: it imports `react-native`, and an externalized copy resolves\n // that to the real Flow package (SyntaxError: Unexpected token\n // 'typeof') instead of our alias. Only bites on the dev path — a\n // production build inlines everything anyway.\n /^@react-navigation\\//,\n ],\n },\n resolve: {\n // RC4-WORKAROUND(runtime-dedupe): see docs/gtkx-rc4-notes.md\n // The gtkx runtime and react are single-instance hosts: when the app\n // and react-native-gtkx resolve them from different node_modules\n // (file:-installed package, nested installs), two bundled copies\n // double-init the runtime and GLib aborts. dedupe pins every copy to\n // the project's own resolution.\n dedupe: [\n \"@gtkx/css\",\n \"@gtkx/gi\",\n \"@gtkx/jsx\",\n \"@gtkx/native\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n // react-navigation is context-based: two bundled copies of core\n // fail with \"couldn't find a navigation context\".\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"react\",\n ],\n },\n }),\n\n async resolveId(source, importer) {\n // The app's table, not the default one: a package dropped with `false`\n // falls through to vite's own resolution and the real package loads.\n const aliased = applyAliases(aliases, source)\n if (aliased !== null) {\n const resolved = await this.resolve(aliased, importer, {\n skipSelf: true,\n })\n return resolved ?? aliased\n }\n return resolvePlatformSpecifier(source, importer, existsSync, options)\n },\n }\n}\n\nexport default reactNativeGtkx\n"]}
|
|
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,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEjE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,mBAAmB,GAEpB,MAAM,qBAAqB,CAAA;AAE5B,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAA;AAsB5B,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,iBAAiB,GAAG,mBAAmB,CAAA;AAE7C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,wBAA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,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;QAED,IAAI,CAAC,EAAE;YACL,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAA;YACb,CAAC;YACD,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;YACzD,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,GAAG,CAAA;QAC/E,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,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// vite loads the config's imported packages with BARE Node, so this subpath\n// (like ./metro and ./runner) must not contain EXTENSIONLESS relative imports\n// — the pure resolution helpers live here rather than in a sibling module,\n// and the one import that does cross a file boundary spells out its `.js`.\nimport { existsSync } from \"node:fs\"\nimport { createRequire } from \"node:module\"\nimport { dirname, extname, isAbsolute, resolve } from \"node:path\"\nimport type { Plugin } from \"vite\"\nimport {\n applyAliases,\n compileAliases,\n DEFAULT_ALIAS_TABLE,\n type AliasOverrides,\n} from \"../aliases/index.js\"\n\n// Re-exported so an app configuring `aliases` never has to reach past the\n// preset subpath it already imports.\nexport {\n CONFIGURABLE_ALIASES,\n DEFAULT_ALIASES,\n PLATFORM_ALIAS,\n} from \"../aliases/index.js\"\nexport type {\n AliasOverride,\n AliasOverrides,\n AliasPattern,\n AliasTable,\n CompiledAlias,\n} from \"../aliases/index.js\"\n\n// --- 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_GTKX = \"react-native-gtkx\"\n\n/**\n * Applies the DEFAULT alias table (../aliases/index.ts) to one specifier:\n * `react-native` and its subpaths onto `react-native-gtkx`, and the five\n * package substitutions onto their compat subpaths. Returns null for every\n * other specifier, including `react-native-gtkx` itself.\n *\n * Exported for tests and for apps driving vite by hand. The plugin does NOT\n * call it — the plugin resolves through the table its own `aliases` option\n * produced, so an app's deltas apply.\n */\nexport const rewriteReactNativeImport = (source: string): string | null =>\n applyAliases(DEFAULT_ALIAS_TABLE, source)\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// Source extensions Metro strips before trying platform variants: an\n// import of \"./useLinking.js\" (the TS-ESM style react-navigation and most\n// compiled RN libraries use) must still find useLinking.native.tsx /\n// useLinking.native.js — Metro resolves the BASE name platform-first, the\n// literal file is only the fallback.\nconst STRIPPABLE_EXTENSIONS = new Set([\".js\", \".jsx\", \".mjs\", \".ts\", \".tsx\"])\n\n/**\n * Metro platform-extension resolution for a single import: relative (or\n * absolute) specifiers that are extensionless — or carry a strippable\n * source extension — try platform candidates first; the first existing\n * candidate wins; the `?query` suffix is carried over. Returns null when\n * 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 const extension = extname(specifier)\n if (extension !== \"\" && !STRIPPABLE_EXTENSIONS.has(extension)) {\n return null\n }\n const withExtension = isAbsolute(specifier)\n ? specifier\n : resolve(dirname(splitQuery(importer).specifier), specifier)\n const base =\n extension === \"\" ? withExtension : withExtension.slice(0, -extension.length)\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 bridge's Adw probe (gtkx/bridge/adw.ts) needs to know, AT BUILD TIME,\n// whether this app's codegen store actually generated Adwaita bindings —\n// see the epic's own regression notes (.claude/epics/adw-optional/006). A\n// runtime-only check (a bare specifier assembled from string parts, so\n// Rollup's build-time graph walk never reaches it) is invisible to the\n// STATIC machinery every other gtkx import gets for free: `resolve.dedupe`\n// (RC4-WORKAROUND(runtime-dedupe) above) and `gtkx build`'s own asset\n// pipeline for the native addon (`@gtkx/cli`'s `gtkx:native` plugin, which\n// rewrites every STATICALLY reachable `@gtkx/native` import onto the single\n// `dist/gtkx.node` it emits) both only ever see specifiers Rollup's graph\n// walk actually visits. A second, independently-resolved copy of the native\n// addon double-initializes the gtkx runtime and aborts the process\n// (`g_log_set_writer_func() called multiple times`) — the exact failure\n// `runtime-dedupe` exists for, reached through a path dedupe cannot see.\n//\n// The fix: make the specifier a literal wherever Adw genuinely exists, so\n// it gets the SAME static treatment as every other gtkx import — and prune\n// it entirely wherever it does not, so `gtkx:undeclared-library` never\n// throws on the plain-GTK profile. `__GTKX_ADW_AVAILABLE__` is that lever:\n// a `define`d boolean CONSTANT (like `__DEV__` above), true only when this\n// app's OWN codegen store actually has an \"adw\" entry. The bridge guards\n// its probe on it; when the guard folds to a literal `false`, esbuild's\n// dead-code elimination removes the whole probe body — literal specifiers\n// and all — before Rollup's build ever walks the module graph, so the\n// undeclared-library plugin never sees them either.\n//\n// require.resolve, not a static/dynamic import: this file is a vite CONFIG\n// module (not part of the app's own bundle), so nothing here is subject to\n// the eslint bridge fence or Rollup's build-time graph at all — it is a\n// plain Node path lookup, run once while vite starts, mirroring exactly\n// what `gtkx:undeclared-library`'s own resolveId does with `this.resolve`.\nconst hasAdwStore = (root: string): boolean => {\n try {\n createRequire(resolve(root, \"package.json\")).resolve(\n [\"@gtkx\", \"gi\", \"adw\"].join(\"/\"),\n )\n return true\n } catch {\n return false\n }\n}\n\n// The two raw specifiers every Adw-dependent file in the bridge imports as a\n// LITERAL (gtkx/bridge/adw.ts's own probe, gtkx/bridge/adw-namespace.ts,\n// gtkx/bridge/widgets.generated.adw.ts) — needed as literals so `gtkx\n// build`'s real Rollup graph gives them the same static treatment as every\n// other gtkx import (see the doc above and .claude/epics/adw-optional/006.md).\n// That literal-ness has a cost `gtkx build` never pays but `gtkx dev` and\n// vitest do: both run every file through Vite's SSR module runner, which\n// resolves every import() call it can find in a file's text — including one\n// inside a dead `if (__GTKX_ADW_AVAILABLE__ === false)` branch — as part of\n// loading that FILE, before any of the file's own code (the runtime guard,\n// the try/catch around it) ever executes. `esbuild`'s dead-code elimination\n// is what makes the literal safe for `gtkx build`, and it is a real BUNDLE\n// optimization, not something the dev server or vitest's request-based\n// transform ever performs — so on a store with no \"Adw-1\" declared, every\n// one of those three files failed to even LOAD (a raw \"'./adw' is not\n// exported\" resolver error out of Vite's own builtin:vite-resolve, not any\n// message this package writes), which took the ENTIRE package down with it:\n// gtkx/bridge/adw.ts is an ordinary dependency of apis/host.gtkx.ts,\n// components/app-registry.tsx and common/navigation-stack.tsx, so nothing\n// that reaches any of those — which is most of the surface — could load\n// either. Found writing .claude/epics/adw-optional/005.md's own guard\n// tests: spike/plain-gtk's PRE-EXISTING alert/appearance GTK tests (003.md,\n// 004.md) failed the exact same way.\n//\n// Fixed the same way `gtkx:undeclared-library` itself is a resolveId hook,\n// not a source change: intercept these two specifiers HERE, before Vite's\n// own resolver (or gtkx's) ever sees them, whenever this app's store\n// genuinely lacks Adw — resolving them to a tiny virtual module that THROWS\n// ONLY WHEN ACTUALLY EVALUATED (i.e. lazily, exactly when something really\n// awaits the dynamic import, or — for the two eager importers above — when\n// something actually loads react-native-gtkx/adw). That is late enough for\n// gtkx/bridge/adw.ts's own `try { ... } catch { return null }` to catch it\n// as a genuine rejected promise, same as it always could for a specifier\n// Node's own loader could not find; for the two EAGER importers, it turns\n// what used to be a generic third-party resolver error into this package's\n// own named, actionable throw (the ONE message text below, since neither\n// eager importer has a call-site \"feature\" name available to it the way\n// requireAdwGi/requireAdwJsx's callers do — see gtkx/bridge/adw.ts). When\n// the store DOES have Adw, `hasAdwStore` is true and this hook falls\n// through to real resolution, unchanged: `gtkx build`'s dedupe and native-\n// asset rewrite still see a real, literal specifier.\nconst ADW_ONLY_SPECIFIERS = new Set([\"@gtkx/gi/adw\", \"@gtkx/jsx/adw\"])\nconst ADW_UNAVAILABLE_PREFIX = \"\\0gtkx-adw-unavailable:\"\nconst adwUnavailableMessage = (specifier: string): string =>\n `[react-native-gtkx] \"${specifier}\" requires \"Adw-1\" in this app's ` +\n \"gtkx.config.ts `libraries` — see docs/api.md (the plain-GTK profile) \" +\n \"for what needs Adw unconditionally and what falls back without it.\"\n\n// --- the vite plugin ----------------------------------------------------\n\nexport type ReactNativeGtkxOptions = PlatformResolutionOptions & {\n /**\n * Deltas over the preset's package aliases, keyed by package name — a\n * string target, a `{ pattern, replace }` rule, or `false` to drop one of\n * ours so the real package loads. Identical semantics to the Metro\n * preset's option of the same name: both compile the same table.\n * Invalid entries throw here, while the config is being read.\n */\n aliases?: AliasOverrides\n}\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 // Throws on an unknown key, an overlapping pattern or an attempt to remove\n // the platform alias — at config load, naming what is valid.\n const aliases = compileAliases(options.aliases)\n return {\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: (_config, env) => ({\n // `__DEV__` is part of the react-native runtime contract, not a Metro\n // detail: RN's own modules branch on it and so does every library\n // written against them (`@gorhom/bottom-sheet`'s logger and four of its\n // components read it at module scope). The Metro path gets it from the\n // app's stock RN preset; nothing supplied it on the vite path, so a\n // library that reads it crashed the bundle at startup with\n // \"ReferenceError: __DEV__ is not defined\" — found by building\n // spike/core-exports rather than by reading anything.\n //\n // vite's mode is the honest source: `gtkx dev` builds in development,\n // `gtkx build` in production, which is exactly the distinction RN draws.\n define: {\n __DEV__: JSON.stringify(env.mode !== \"production\"),\n // See hasAdwStore's doc above — process.cwd(), not _config.root:\n // `gtkx dev`/`gtkx build` always run from the app's own directory\n // (root defaults there too), and this must be resolvable before the\n // rest of the merged config is settled.\n __GTKX_ADW_AVAILABLE__: JSON.stringify(hasAdwStore(process.cwd())),\n },\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 // \"react-native-reanimated\" for the same reason as \"react-native\": an\n // app that also ships iOS/Android keeps the real package installed, it\n // resolves natively, and ssr.external: true would hand Node a codebase\n // built around a Babel plugin and a worklet runtime before the alias\n // ever gets a chance to rewrite the import.\n // \"react-native-worklets\" is the same case one package over — it is\n // where that worklet runtime actually lives since Reanimated 4.\n //\n // The rule those are instances of, stated once so the next alias does\n // not have to rediscover it: EVERY package name in the alias table must\n // be listed here. An alias is a resolveId hook, and a bare specifier\n // that vite externalizes never reaches one — so on the dev path the\n // alias silently loses to whatever is installed under the real name.\n // That is not hypothetical: an app that also ships iOS and Android has\n // all of them in node_modules, which is the case the alias exists to\n // serve. `react-native-gesture-handler` proved it — this list once held\n // three of the six names, its real package loaded, and it failed on an\n // extensionless internal import Node cannot resolve (found by running\n // the gallery's upstream-libraries section, which installs it).\n //\n // So the list is DERIVED rather than written out: it is exactly the\n // table's package names, and a name can no longer go missing from one\n // of the two places it has to appear.\n //\n // `aliases.names` includes the packages an app turned OFF with `false`,\n // deliberately. Dropping an alias means the REAL package loads, and the\n // real package imports `react-native` at module scope — an import that\n // only reaches the platform alias if Node never gets the package first.\n // Un-aliasing a package is therefore a reason to keep it inside the\n // pipeline, not a reason to let it out.\n noExternal: [\n REACT_NATIVE_GTKX,\n ...aliases.names,\n // @react-navigation is not aliased, but must go through the pipeline\n // too: it imports `react-native`, and an externalized copy resolves\n // that to the real Flow package (SyntaxError: Unexpected token\n // 'typeof') instead of our alias. Only bites on the dev path — a\n // production build inlines everything anyway.\n /^@react-navigation\\//,\n ],\n },\n resolve: {\n // RC4-WORKAROUND(runtime-dedupe): see docs/gtkx-rc4-notes.md\n // The gtkx runtime and react are single-instance hosts: when the app\n // and react-native-gtkx resolve them from different node_modules\n // (file:-installed package, nested installs), two bundled copies\n // double-init the runtime and GLib aborts. dedupe pins every copy to\n // the project's own resolution.\n dedupe: [\n \"@gtkx/css\",\n \"@gtkx/gi\",\n \"@gtkx/jsx\",\n \"@gtkx/native\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n // react-navigation is context-based: two bundled copies of core\n // fail with \"couldn't find a navigation context\".\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"react\",\n ],\n },\n build: {\n rolldownOptions: {\n output: {\n // A literal, code-split dynamic import (the Adw seam,\n // gtkx/bridge/adw.ts — see its own doc and 006 above) lands its\n // chunk under the Rolldown default `assets/[name]-[hash].js`\n // UNLESS told otherwise. `@gtkx/cli`'s own `gtkx:native` plugin\n // rewrites every reachable `@gtkx/native` import into\n // `require(\"./gtkx.node\")` — a path RELATIVE TO WHATEVER FILE\n // THE REWRITE LANDS IN, correct only when that file sits next to\n // the emitted `dist/gtkx.node` asset. The entry chunk is pinned\n // there already (`entryFileNames: \"bundle.js\"`, set by\n // `@gtkx/cli`'s own builder); a chunk placed one level down in\n // `assets/` breaks the SAME relative path\n // (\"Cannot find module './gtkx.node'\" — reproduced building\n // examples/gallery with the Adw seam's dynamic import made\n // literal). Keeping every chunk in `dist/` alongside the entry\n // and the addon sidesteps the mismatch instead of guessing at\n // gtkx's own relative-path assumption.\n chunkFileNames: \"[name]-[hash].js\",\n },\n },\n },\n }),\n\n async resolveId(source, importer) {\n // See ADW_ONLY_SPECIFIERS' own doc above: on a store with no \"Adw-1\",\n // resolving either of these for real fails the whole file that\n // imports them, before that file's own code (a runtime guard, a\n // try/catch) ever runs. Checked first, ahead of the alias table below\n // (neither specifier is in it).\n if (ADW_ONLY_SPECIFIERS.has(source) && !hasAdwStore(process.cwd())) {\n return ADW_UNAVAILABLE_PREFIX + source\n }\n // The app's table, not the default one: a package dropped with `false`\n // falls through to vite's own resolution and the real package loads.\n const aliased = applyAliases(aliases, source)\n if (aliased !== null) {\n const resolved = await this.resolve(aliased, importer, {\n skipSelf: true,\n })\n return resolved ?? aliased\n }\n return resolvePlatformSpecifier(source, importer, existsSync, options)\n },\n\n load(id) {\n if (!id.startsWith(ADW_UNAVAILABLE_PREFIX)) {\n return null\n }\n const specifier = id.slice(ADW_UNAVAILABLE_PREFIX.length)\n return `throw new Error(${JSON.stringify(adwUnavailableMessage(specifier))})`\n },\n }\n}\n\nexport default reactNativeGtkx\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gtkx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha.2",
|
|
4
4
|
"description": "React Native components and APIs for Linux desktop, rendered as native GTK4 widgets via gtkx",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Anton Petrov <anton@itsmepetrov.com>",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Adw from "@gtkx/gi/adw";
|
|
2
|
-
export const styleManager = () => Adw.StyleManager.getDefault();
|
|
3
|
-
// The Appearance API subscribes to notify::dark on the style manager.
|
|
4
|
-
export const colorScheme = () => styleManager().getDark() ? "dark" : "light";
|
|
5
|
-
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../src/gtkx/bridge/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAInC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE,CACjD,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,CAAA;AAE/B,sEAAsE;AACtE,MAAM,CAAC,MAAM,WAAW,GAAG,GAAgB,EAAE,CAC3C,YAAY,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA","sourcesContent":["import * as Adw from \"@gtkx/gi/adw\"\n\nexport type ColorScheme = \"light\" | \"dark\"\n\nexport const styleManager = (): Adw.StyleManager =>\n Adw.StyleManager.getDefault()\n\n// The Appearance API subscribes to notify::dark on the style manager.\nexport const colorScheme = (): ColorScheme =>\n styleManager().getDark() ? \"dark\" : \"light\"\n"]}
|