@uniflowed/react-native 0.0.0-alpha.40 → 0.0.0-alpha.42

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.
@@ -68,13 +68,14 @@ async function transform(args) {
68
68
  // remounts instead of preserving state.
69
69
  refresh: false,
70
70
  sourceMap: true,
71
+ nativeStyles: true,
71
72
  });
72
73
  if (out != null) {
73
74
  if (out.css != null && out.css !== "") {
74
75
  throw new Error(
75
76
  `@uniflowed/react-native/metro: ${filename} produced StyleX CSS, but the ` +
76
- "native Metro contract cannot attach CSS to a React Native bundle yet. " +
77
- "Use native style props or keep that StyleX module out of the native route.",
77
+ "native Metro contract cannot attach CSS to a React Native bundle. " +
78
+ "Use the supported native StyleX subset or native style props.",
78
79
  );
79
80
  }
80
81
  next = out.code;
package/metro.cjs CHANGED
@@ -41,7 +41,7 @@ const metroResolverMainFields = Object.freeze(["react-native", "browser", "main"
41
41
  const metroTransformPipeline = Object.freeze([
42
42
  "flow",
43
43
  "react-compiler",
44
- "stylex-css-refusal",
44
+ "stylex-native-objects",
45
45
  "metro-babel",
46
46
  ]);
47
47
 
@@ -64,6 +64,7 @@ const nativePackages = Object.freeze([
64
64
  "react-native",
65
65
  "relay",
66
66
  "state",
67
+ "stylex",
67
68
  "temporal",
68
69
  "validator",
69
70
  ]);
@@ -85,12 +86,15 @@ function nativeResolution(previous) {
85
86
  domPackages.has(name) ||
86
87
  (name === "router" &&
87
88
  moduleName !== "@uniflowed/router/native" &&
89
+ moduleName !== "@uniflowed/router/native-navigation" &&
90
+ moduleName !== "@uniflowed/router/http-client" &&
88
91
  moduleName !== "@uniflowed/router/routing")
89
92
  ) {
90
93
  throw new Error(
91
94
  `${moduleName} needs a browser DOM and cannot be bundled for ${platform}. ` +
92
95
  `Native packages: ${nativePackages.map((item) => `@uniflowed/${item}`).join(", ")}, ` +
93
- "@uniflowed/router/native and @uniflowed/router/routing. Keep DOM components in $page.web.js.",
96
+ "@uniflowed/router/native, @uniflowed/router/native-navigation, " +
97
+ "@uniflowed/router/http-client and @uniflowed/router/routing. Keep DOM components in $page.web.js.",
94
98
  );
95
99
  }
96
100
  return (previous ?? context.resolveRequest)(context, moduleName, platform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/react-native",
3
- "version": "0.0.0-alpha.40",
3
+ "version": "0.0.0-alpha.42",
4
4
  "description": "React Native, re-exported for the Unified Toolchain for Flow.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -13,16 +13,18 @@
13
13
  "exports": {
14
14
  ".": "./index.js",
15
15
  "./metro": "./metro.cjs",
16
- "./metro-transformer.cjs": "./metro-transformer.cjs"
16
+ "./metro-transformer.cjs": "./metro-transformer.cjs",
17
+ "./test-transformer.cjs": "./test-transformer.cjs"
17
18
  },
18
19
  "files": [
19
20
  "index.js",
20
21
  "metro.cjs",
21
22
  "metro-transformer.cjs",
23
+ "test-transformer.cjs",
22
24
  "!*.test.js"
23
25
  ],
24
26
  "dependencies": {
25
- "@uniflowed/host": "0.0.0-alpha.40"
27
+ "@uniflowed/host": "0.0.0-alpha.42"
26
28
  },
27
29
  "peerDependencies": {
28
30
  "react": ">=19.2.3",
@@ -0,0 +1,41 @@
1
+ // @noflow
2
+ "use strict";
3
+ // Reuse the app's RN Babel preset for upstream native modules and Jest mock
4
+ // hoisting. App Flow syntax and StyleX use the same uf compiler as Metro.
5
+ const { createRequire } = require("node:module");
6
+ const path = require("node:path");
7
+ const { isFlowModule, transformFlowSync } = require("@uniflowed/host/transform");
8
+ module.exports = {
9
+ process(source, filename, options) {
10
+ const root = options.config.rootDir;
11
+ const load = createRequire(path.join(root, "package.json"));
12
+ const babel = load("babel-jest").createTransformer({
13
+ babelrc: false,
14
+ configFile: false,
15
+ presets: [load.resolve("@react-native/babel-preset")],
16
+ plugins: [load.resolve("@babel/plugin-transform-dynamic-import")],
17
+ });
18
+ const transformed = isFlowModule(filename)
19
+ ? transformFlowSync(source, filename, {
20
+ root,
21
+ development: true,
22
+ nativeStyles: true,
23
+ sourceMap: true,
24
+ })
25
+ : null;
26
+ return babel.process(transformed?.code ?? source, filename, options);
27
+ },
28
+ // Include the compiler version/mtime, just as Metro does, on rebuilt tools.
29
+ getCacheKey(source, filename, options) {
30
+ const crypto = require("node:crypto");
31
+ const { ufBinaryIdentity } = require("@uniflowed/host/transform");
32
+ return crypto
33
+ .createHash("sha256")
34
+ .update(source)
35
+ .update(filename)
36
+ .update(options.configString)
37
+ .update(String(ufBinaryIdentity(process.env.UF_BINARY || "uf")))
38
+ .update(require("node:fs").readFileSync(__filename))
39
+ .digest("hex");
40
+ },
41
+ };