@multiplatform.one/config 9.1.0 → 9.3.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.
package/design-lint.mjs CHANGED
@@ -75,6 +75,9 @@ const copyTag = /^Copy\w*Button$/;
75
75
  // LC-176 ICON-BUTTON: an icon-only button is a bare tinted glyph. A prop that
76
76
  // paints a plate or a ring around the glyph needs the over-media plate.
77
77
  const buttonTag = /^(?:Button|IconButton|TamaguiButton|PageBarButton)$|\.Button$/;
78
+ // LC-286: a system bar's trailing action is the glyph on a round filled plate in
79
+ // its own intent, round 95's round-plate allowance, so SystemBarAction may plate.
80
+ const roundPlateHome = /^SystemBarAction$/;
78
81
  const platePaint =
79
82
  /^(?:outlined|circular|bordered|elevate|elevation|bg|backgroundColor|background|borderWidth|borderColor|variant)$/;
80
83
  const tokenFactories = new Set([
@@ -666,6 +669,7 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
666
669
  const typeChecker = () => {
667
670
  if (lazyChecker) return lazyChecker;
668
671
  const compilerOptions = {
672
+ allowJs: true,
669
673
  noLib: true,
670
674
  noResolve: true,
671
675
  types: [],
@@ -1350,6 +1354,18 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
1350
1354
  destructiveValue.test(attr.initializer?.getText(file) ?? ""),
1351
1355
  );
1352
1356
  }
1357
+ function insideRoundPlateHome(element) {
1358
+ for (let current = element.parent; current; current = current.parent) {
1359
+ const owner =
1360
+ (ts.isFunctionDeclaration(current) || ts.isVariableDeclaration(current)) &&
1361
+ current.name &&
1362
+ ts.isIdentifier(current.name)
1363
+ ? current.name.text
1364
+ : "";
1365
+ if (roundPlateHome.test(owner)) return true;
1366
+ }
1367
+ return false;
1368
+ }
1353
1369
  function platedIconButton(element) {
1354
1370
  const tag = opening(element);
1355
1371
  if (!buttonTag.test(tagText(tag.tagName)) || !iconOnly(element)) return undefined;
@@ -1357,6 +1373,7 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
1357
1373
  const plate = attribute(element, "plate");
1358
1374
  if (plate?.initializer && /["'](?:media|primary)["']/.test(plate.initializer.getText(file)))
1359
1375
  return undefined;
1376
+ if (insideRoundPlateHome(element)) return undefined;
1360
1377
  return tag.attributes.properties.find((attr) => {
1361
1378
  if (!ts.isJsxAttribute(attr)) return false;
1362
1379
  const key = name(attr.name);
@@ -1393,8 +1410,8 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
1393
1410
  `"${label}" is a standard action spelled as a word; draw its icon and put the word in the accessibility label (LC-260).`,
1394
1411
  );
1395
1412
  }
1396
- // FZ-8439 (LC-262): a sheet's Cancel and confirm live in its header,
1397
- // OverlayHeader's ✕ and accent ✓. Its body holds no action row and no word
1413
+ // FZ-8439 (LC-262): a sheet's confirm lives in its OverlayHeader title row,
1414
+ // the accent ✓, and it closes without a ✕ (FZ-11418). Its body holds no action row and no word
1398
1415
  // in an accent pill.
1399
1416
  function checkSheetActionRow(element) {
1400
1417
  if (!ts.isJsxElement(element) || !/(?:^|\.)SheetModal$/.test(tagText(opening(element).tagName)))
@@ -1418,7 +1435,7 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
1418
1435
  report(
1419
1436
  node,
1420
1437
  "sheet-action-row",
1421
- "A sheet's Cancel and confirm go in its header as OverlayHeader (✕ leading, accent ✓ trailing), not an ActionBar in the body (FZ-8439, LC-262).",
1438
+ "A sheet's confirm goes in its OverlayHeader as the accent ✓ trailing the title, and it closes by drag, scrim or Escape with no Cancel, not an ActionBar in the body (FZ-8439, FZ-11418, LC-262).",
1422
1439
  );
1423
1440
  else if (wordControl.test(tagName) && accentOn && !iconOnly(node))
1424
1441
  report(
@@ -2016,8 +2033,16 @@ function inspectCached(filename, options) {
2016
2033
  export function scanDesign(paths, options = {}) {
2017
2034
  const files = [...new Set(paths.flatMap((input) => designFiles(input)))];
2018
2035
  if (!files.length) throw new Error("No application source files found in the supplied paths.");
2019
- const errors = files.flatMap((filename) => inspectCached(filename, options));
2020
- return { files, errors, ...countDesign(errors) };
2036
+ const errors = [];
2037
+ const failures = [];
2038
+ for (const filename of files) {
2039
+ try {
2040
+ errors.push(...inspectCached(filename, options));
2041
+ } catch (error) {
2042
+ failures.push(`${filename}: not inspected, ${error.message}`);
2043
+ }
2044
+ }
2045
+ return { files, errors, failures, ...countDesign(errors) };
2021
2046
  }
2022
2047
 
2023
2048
  function parseArgs(args) {
@@ -2061,7 +2086,10 @@ function summary(scan) {
2061
2086
  .filter(([, count]) => count)
2062
2087
  .map(([rule, count]) => `${rule} ${count}`)
2063
2088
  .join(", ");
2064
- return `${scan.total} violations in ${scan.files.length} files${rules ? ` (${rules})` : ""}`;
2089
+ const failed = scan.failures?.length
2090
+ ? `, ${scan.failures.length} ${scan.failures.length === 1 ? "file" : "files"} not inspected`
2091
+ : "";
2092
+ return `${scan.total} violations in ${scan.files.length} files${rules ? ` (${rules})` : ""}${failed}`;
2065
2093
  }
2066
2094
 
2067
2095
  function scopeFrom(base) {
@@ -2147,6 +2175,12 @@ function ratchet(file, options) {
2147
2175
  paths.map((input) => path.resolve(base, input)),
2148
2176
  words,
2149
2177
  );
2178
+ if (full.failures.length) {
2179
+ process.stderr.write(
2180
+ `${full.failures.join("\n")}\nMPO design guard: ${file} cannot ratchet a partial scan. ${summary(full)}.\n`,
2181
+ );
2182
+ return 1;
2183
+ }
2150
2184
  const scan = only
2151
2185
  ? (() => {
2152
2186
  const errors = full.errors.filter((error) => only.includes(ruleOf(error)));
@@ -2322,8 +2356,10 @@ export function runDesignLint(args = process.argv.slice(2)) {
2322
2356
  if (options.baselines.length)
2323
2357
  return options.baselines.reduce((status, file) => ratchet(file, options) || status, 0);
2324
2358
  const scan = scanDesign(options.paths.length ? options.paths : scopeFrom(process.cwd()));
2325
- if (scan.errors.length) {
2326
- process.stderr.write(`${scan.errors.join("\n")}\nMPO design guard: ${summary(scan)}.\n`);
2359
+ if (scan.errors.length || scan.failures.length) {
2360
+ process.stderr.write(
2361
+ `${[...scan.errors, ...scan.failures].join("\n")}\nMPO design guard: ${summary(scan)}.\n`,
2362
+ );
2327
2363
  return 1;
2328
2364
  }
2329
2365
  process.stdout.write(`MPO design guard passed (${scan.files.length} source files).\n`);
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { i as phosphorTokenColorPlugin, n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-DR3dud79.js";
2
2
  import { t as createStorybookViteConfig } from "./storybook-BpaziEtP.js";
3
- import { t as createViteConfig } from "./vite-CeDmMMjx.js";
3
+ import { t as createViteConfig } from "./vite-CgiDLR6V.js";
4
4
  import { t as createVitestConfig } from "./vitest-B2vcGrZM.js";
5
5
 
6
6
  export { createStorybookViteConfig, createViteConfig, createVitestConfig, ensureTamaguiWorkspacePaths, phosphorTokenColorPlugin, tamaguiWorkspacePathsFile };
@@ -819,6 +819,8 @@ function registerNativePhosphorIcons() {
819
819
  });
820
820
  }
821
821
  const phosphorNativeIconBaseId = "#mpo/phosphor-native-icon-base";
822
+ /** phosphor-react-native's own `lib` (its `IconContext`), for the theme-ink shim (FZ-8996). */
823
+ const phosphorNativeIconLibId = "#mpo/phosphor-native-icon-lib";
822
824
  /**
823
825
  * Every phosphor-react-native glyph renders through its `lib/icon-base`, which
824
826
  * paints a missing colour `#000` and a Tamagui token as no paint (black too).
@@ -831,11 +833,13 @@ function phosphorNativeIconBase(nativeEntry) {
831
833
  const here = path.dirname(new URL(import.meta.url).pathname);
832
834
  const shim = [path.resolve(here, "shims/phosphorIconBase.native.js"), path.resolve(here, "../src/shims/phosphorIconBase.native.js")].find((candidate) => fs.existsSync(candidate));
833
835
  const original = path.join(path.dirname(nativeEntry), "lib", "icon-base.js");
834
- if (!shim || !fs.existsSync(original)) return null;
836
+ const lib = path.join(path.dirname(nativeEntry), "lib", "index.js");
837
+ if (!shim || !fs.existsSync(original) || !fs.existsSync(lib)) return null;
835
838
  const packageDir = `${path.sep}phosphor-react-native${path.sep}`;
836
839
  const iconBaseImport = /(?:^|[\\/])lib[\\/]icon-base(?:\.js)?$/;
837
840
  return (id, importer) => {
838
841
  if (id === "#mpo/phosphor-native-icon-base") return original;
842
+ if (id === "#mpo/phosphor-native-icon-lib") return lib;
839
843
  if (!importer || importer === shim || !importer.includes(packageDir)) return null;
840
844
  return iconBaseImport.test(id) ? shim : null;
841
845
  };
@@ -875,4 +879,4 @@ function preferBuiltWorkspaceEntryPlugin() {
875
879
  }
876
880
 
877
881
  //#endregion
878
- export { readPublicConfigKeys as a, publicConfigPlugin as i, phosphorNativeIconBase as n, phosphorNativeIconBaseId as r, createViteConfig as t };
882
+ export { publicConfigPlugin as a, phosphorNativeIconLibId as i, phosphorNativeIconBase as n, readPublicConfigKeys as o, phosphorNativeIconBaseId as r, createViteConfig as t };
package/lib/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as staleNativeDistSource, i as resolveWorkspaceNativeEntry, n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-DN-1LPcH.js";
2
2
  import { i as phosphorTokenColorPlugin } from "./tamaguiWorkspacePaths-DR3dud79.js";
3
- import { a as readPublicConfigKeys, i as publicConfigPlugin, n as phosphorNativeIconBase, r as phosphorNativeIconBaseId, t as createViteConfig } from "./vite-CeDmMMjx.js";
3
+ import { a as publicConfigPlugin, i as phosphorNativeIconLibId, n as phosphorNativeIconBase, o as readPublicConfigKeys, r as phosphorNativeIconBaseId, t as createViteConfig } from "./vite-CgiDLR6V.js";
4
4
 
5
- export { createViteConfig, discoverPublicPackageRoots, phosphorNativeIconBase, phosphorNativeIconBaseId, phosphorTokenColorPlugin, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys, resolveWorkspaceNativeEntry, staleNativeDistSource };
5
+ export { createViteConfig, discoverPublicPackageRoots, phosphorNativeIconBase, phosphorNativeIconBaseId, phosphorNativeIconLibId, phosphorTokenColorPlugin, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys, resolveWorkspaceNativeEntry, staleNativeDistSource };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "9.1.0",
3
+ "version": "9.3.0",
4
4
  "description": "Shared build and test configuration presets for multiplatform.one",
5
5
  "keywords": [
6
6
  "config",
@@ -122,7 +122,7 @@
122
122
  "@babel/parser": "^7.29.9",
123
123
  "@babel/plugin-transform-block-scoping": "^7.29.7",
124
124
  "@babel/traverse": "^7.29.10",
125
- "@multiplatform.one/utils": "^9.1.0",
125
+ "@multiplatform.one/utils": "^9.3.0",
126
126
  "@tamagui/vite-plugin": "2.7.6",
127
127
  "@vitejs/plugin-react": "^6.1.2",
128
128
  "dotenv": "^17.4.2",
package/press-lint.mjs CHANGED
@@ -51,21 +51,33 @@ function unwrap(expr) {
51
51
  return current;
52
52
  }
53
53
 
54
+ const wrapperMethods = new Set(["styleable", "extractable"]);
55
+
54
56
  /**
55
- * `styled(Base, {...})`, also under `.styleable(...)` and friends.
56
- * @param {ts.Expression} expr
57
- * @returns {ts.CallExpression | undefined}
57
+ * Where a component's styling comes from: a `styled(Base, {...})` call (also
58
+ * under `.styleable(...)` and friends), or the name of a styled base it wraps
59
+ * (`Frame.styleable(fn)`, `createStyledHOC(Frame, fn)`, a bare alias), which
60
+ * is resolved later against the file's declarations.
61
+ * @param {ts.Expression | undefined} expr
62
+ * @returns {{ call?: ts.CallExpression, base?: string }}
58
63
  */
59
- function styledCall(expr) {
60
- let current = unwrap(expr);
61
- while (ts.isCallExpression(current)) {
64
+ function styledSource(expr) {
65
+ let current = expr && unwrap(expr);
66
+ while (current && ts.isCallExpression(current)) {
62
67
  const callee = current.expression;
63
- if (ts.isIdentifier(callee) && callee.text === "styled") return current;
64
- if (ts.isPropertyAccessExpression(callee) && ts.isCallExpression(callee.expression))
65
- current = callee.expression;
66
- else return undefined;
68
+ if (ts.isIdentifier(callee) && callee.text === "styled") return { call: current };
69
+ if (ts.isIdentifier(callee) && callee.text === "createStyledHOC")
70
+ current = current.arguments[0] && unwrap(current.arguments[0]);
71
+ else if (ts.isPropertyAccessExpression(callee) && wrapsBase(callee))
72
+ current = unwrap(callee.expression);
73
+ else return {};
67
74
  }
68
- return undefined;
75
+ return current && ts.isIdentifier(current) ? { base: current.text } : {};
76
+ }
77
+
78
+ /** @param {ts.PropertyAccessExpression} callee */
79
+ function wrapsBase(callee) {
80
+ return ts.isCallExpression(callee.expression) || wrapperMethods.has(callee.name.text);
69
81
  }
70
82
 
71
83
  /**
@@ -82,8 +94,8 @@ function parse(source, filename) {
82
94
  );
83
95
  /** @type {Map<string, ts.Expression>} */
84
96
  const objects = new Map();
85
- /** @type {Map<string, ts.CallExpression>} */
86
- const styledCalls = new Map();
97
+ /** @type {Map<string, ts.Expression>} */
98
+ const styledInits = new Map();
87
99
  /** @type {Set<string>} */
88
100
  const exported = new Set();
89
101
  /** @type {Set<string>} */
@@ -93,8 +105,8 @@ function parse(source, filename) {
93
105
  if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
94
106
  const init = unwrap(node.initializer);
95
107
  if (ts.isObjectLiteralExpression(init)) objects.set(node.name.text, init);
96
- const call = styledCall(init);
97
- if (call) styledCalls.set(node.name.text, call);
108
+ const source = styledSource(init);
109
+ if (source.call || source.base) styledInits.set(node.name.text, init);
98
110
  const statement = node.parent?.parent;
99
111
  if (
100
112
  statement &&
@@ -135,6 +147,18 @@ function parse(source, filename) {
135
147
 
136
148
  /** @type {Map<string, boolean>} */
137
149
  const cache = new Map();
150
+ /**
151
+ * @param {ts.Expression | undefined} expr
152
+ * @param {Set<string>} imported
153
+ * @returns {boolean}
154
+ */
155
+ function claims(expr, imported) {
156
+ const { call, base } = styledSource(expr);
157
+ if (base) return isClaimant(base, imported);
158
+ if (!call) return false;
159
+ const [inner, ...configs] = call.arguments;
160
+ return configs.some((config) => carriesClaim(config)) || claims(inner, imported);
161
+ }
138
162
  /**
139
163
  * @param {string} name
140
164
  * @param {Set<string>} imported claimant names other files export
@@ -143,25 +167,22 @@ function parse(source, filename) {
143
167
  function isClaimant(name, imported) {
144
168
  if (cache.has(name)) return /** @type {boolean} */ (cache.get(name));
145
169
  cache.set(name, false);
146
- const call = styledCalls.get(name);
147
- let result = false;
148
- if (call) {
149
- const [base, ...configs] = call.arguments;
150
- result =
151
- configs.some((config) => carriesClaim(config)) ||
152
- (!!base && ts.isIdentifier(base) && isClaimant(base.text, imported));
153
- } else if (importedNames.has(name) && imported.has(name)) {
154
- result = true;
155
- }
170
+ const init = styledInits.get(name);
171
+ const result = init ? claims(init, imported) : importedNames.has(name) && imported.has(name);
156
172
  cache.set(name, result);
157
173
  return result;
158
174
  }
159
175
  /** @param {string} name */
176
+ function baseName(name) {
177
+ let { call, base } = styledSource(styledInits.get(name));
178
+ for (let hops = 0; call && hops < 8; hops++) ({ call, base } = styledSource(call.arguments[0]));
179
+ return base ?? "";
180
+ }
181
+ /** @param {string} name */
160
182
  function isInput(name) {
161
183
  for (let current = name, hops = 0; current && hops < 8; hops++) {
162
184
  if (inputTag.test(current)) return true;
163
- const base = styledCalls.get(current)?.arguments[0];
164
- current = base && ts.isIdentifier(base) ? base.text : "";
185
+ current = baseName(current);
165
186
  }
166
187
  return false;
167
188
  }
@@ -11,8 +11,13 @@ import path from "node:path";
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { beforeEach, describe, expect, it } from "vitest";
13
13
  import { isBlackPaint, nativePaint } from "./shims/phosphorNativeProbe.js";
14
- import { resolveIconInk } from "./shims/phosphorThemeInk.js";
15
- import { createViteConfig, phosphorNativeIconBase, phosphorNativeIconBaseId } from "./vite.js";
14
+ import { contextOutline, resolveIconInk } from "./shims/phosphorThemeInk.js";
15
+ import {
16
+ createViteConfig,
17
+ phosphorNativeIconBase,
18
+ phosphorNativeIconBaseId,
19
+ phosphorNativeIconLibId,
20
+ } from "./vite.js";
16
21
 
17
22
  type Resolver = { name?: string; resolveId?: (id: string, importer?: string) => unknown };
18
23
  const native = globalThis as unknown as { __vxrnAddNativePlugins?: Resolver[] };
@@ -51,6 +56,23 @@ describe("resolveIconInk", () => {
51
56
  });
52
57
  });
53
58
 
59
+ describe("contextOutline (FZ-8996)", () => {
60
+ it("forwards the outline a Button puts on Phosphor's context, under the icon's own props", () => {
61
+ const context = { weight: "bold", stroke: "#123", strokeWidth: 8, strokeLinejoin: "round" };
62
+ expect(contextOutline(context, {})).toEqual({
63
+ stroke: "#123",
64
+ strokeWidth: 8,
65
+ strokeLinejoin: "round",
66
+ });
67
+ expect(contextOutline(context, { strokeWidth: 2 })).toEqual({
68
+ stroke: "#123",
69
+ strokeLinejoin: "round",
70
+ });
71
+ expect(contextOutline({ weight: "bold" }, {})).toEqual({});
72
+ expect(contextOutline(undefined, {})).toEqual({});
73
+ });
74
+ });
75
+
54
76
  describe("native paint probe", () => {
55
77
  it("paints what react-native-svg draws for a colour it cannot read: black", () => {
56
78
  for (const color of [undefined, "", "currentColor", "$color12"])
@@ -87,6 +109,10 @@ describe("phosphorNativeIconBase", () => {
87
109
  expect(fs.readFileSync(shim, "utf8")).toContain(phosphorNativeIconBaseId);
88
110
  expect(swap!(phosphorNativeIconBaseId, shim)).toBe(original);
89
111
  expect(fs.existsSync(original)).toBe(true);
112
+ expect(fs.readFileSync(shim, "utf8")).toContain(phosphorNativeIconLibId);
113
+ const lib = swap!(phosphorNativeIconLibId, shim) as string;
114
+ expect(lib).toBe(path.join(path.dirname(entry), "lib", "index.js"));
115
+ expect(fs.readFileSync(lib, "utf8")).toContain("IconContext");
90
116
  });
91
117
 
92
118
  it("leaves the original's own imports and everything outside phosphor alone", () => {
@@ -118,6 +118,53 @@ describe("exportedPressClaimants", () => {
118
118
  export { Ring };`;
119
119
  expect(exportedPressClaimants(source, "Fixture.tsx").sort()).toEqual(["Pill", "Ring"]);
120
120
  });
121
+
122
+ it("follows a named styled base under .styleable() and createStyledHOC (FZ-10909)", () => {
123
+ const source = `
124
+ const Frame = styled(View, { name: "F", pressStyle: { opacity: 0.5 } });
125
+ export const Styleable = Frame.styleable((props, ref) => <Frame {...props} ref={ref} />);
126
+ export const Typed = Frame.styleable<{ on?: boolean }>((props, ref) => <Frame ref={ref} />);
127
+ export const Hoc = createStyledHOC(Frame, (props, ref) => <Frame {...props} ref={ref} />);
128
+ const Plain = styled(View, { name: "P" });
129
+ export const Quiet = Plain.styleable((props, ref) => <Plain ref={ref} />);`;
130
+ expect(exportedPressClaimants(source, "Fixture.tsx").sort()).toEqual([
131
+ "Hoc",
132
+ "Styleable",
133
+ "Typed",
134
+ ]);
135
+ });
136
+
137
+ it("resolves a base chain two hops deep behind a named frame (FZ-10909)", () => {
138
+ const source = `
139
+ const Inner = styled(View, { focusVisibleStyle: { outlineWidth: 2 } });
140
+ const Frame = styled(Inner, { name: "F" });
141
+ export const Named = Frame.styleable((props, ref) => <Frame ref={ref} />);
142
+ const Nested = styled(styled(View, { pressStyle: { opacity: 0.5 } }), { name: "N" });
143
+ export const Inline = createStyledHOC(Nested, (props, ref) => <Nested ref={ref} />);`;
144
+ expect(exportedPressClaimants(source, "Fixture.tsx").sort()).toEqual(["Inline", "Named"]);
145
+ });
146
+
147
+ it("still skips an input reached through a named base (FZ-10909)", () => {
148
+ const source = `
149
+ const FieldFrame = styled(TextInput, { focusVisibleStyle: { outlineWidth: 2 } });
150
+ export const Field = FieldFrame.styleable((props, ref) => <FieldFrame ref={ref} />);
151
+ const AreaFrame = styled(styled(TextArea, { pressStyle: { opacity: 0.5 } }), {});
152
+ export const Area = createStyledHOC(AreaFrame, (props, ref) => <AreaFrame ref={ref} />);`;
153
+ expect(exportedPressClaimants(source, "Fixture.tsx")).toEqual([]);
154
+ });
155
+
156
+ it("flags a named-base wrapper nested in a pressable, in its file and where it is imported (FZ-10909)", () => {
157
+ const source = `
158
+ const Frame = styled(View, { pressStyle: { opacity: 0.5 } });
159
+ export const Ring = Frame.styleable((props, ref) => <Frame ref={ref} />);
160
+ export const A = () => <View onPress={go}><Ring /></View>;`;
161
+ expect(find(source)).toEqual(["Ring<View"]);
162
+ const imported = new Set<string>(exportedPressClaimants(source, "Ring.tsx"));
163
+ const consumer = `
164
+ import { Ring } from "./Ring";
165
+ export const B = () => <Pressable onPress={go}><Ring /></Pressable>;`;
166
+ expect(find(consumer, imported)).toEqual(["Ring<Pressable"]);
167
+ });
121
168
  });
122
169
 
123
170
  describe("findNativeFocusWithin (FZ-8991 NATIVE-FOCUS-WITHIN)", () => {
@@ -1,5 +1,7 @@
1
1
  import IconBase from "#mpo/phosphor-native-icon-base";
2
+ import { IconContext } from "#mpo/phosphor-native-icon-lib";
3
+ import { useContext } from "react";
2
4
  import { useTheme } from "tamagui";
3
5
  import { themeInkIconBase } from "./phosphorThemeInk.js";
4
6
 
5
- export default themeInkIconBase(IconBase, useTheme);
7
+ export default themeInkIconBase(IconBase, useTheme, () => useContext(IconContext));
@@ -1,4 +1,4 @@
1
- import { createElement } from "react";
1
+ import { createElement, useContext } from "react";
2
2
  import { themeInkIconBase } from "./phosphorThemeInk.js";
3
3
 
4
4
  /**
@@ -29,21 +29,35 @@ export function isBlackPaint(paint) {
29
29
  );
30
30
  }
31
31
 
32
- function NativeIconProbe({ color, name }) {
33
- return createElement("span", { "data-native-icon": name, "data-paint": nativePaint(color) });
32
+ function nativeIconProbe(IconContext) {
33
+ return function NativeIconProbe({ color, name, weight, strokeWidth }) {
34
+ const context = IconContext ? useContext(IconContext) : undefined;
35
+ return createElement("span", {
36
+ "data-native-icon": name,
37
+ "data-paint": nativePaint(color),
38
+ "data-weight": weight ?? context?.weight ?? "regular",
39
+ "data-stroke-width": strokeWidth,
40
+ });
41
+ };
34
42
  }
35
43
 
36
44
  /**
37
45
  * A stand-in for `@phosphor-icons/react` as the native bundle sees it: every
38
46
  * icon renders through MPO's theme-ink IconBase (the swap the toolchain makes,
39
47
  * FZ-7680) onto a probe that records the paint react-native-svg would draw.
40
- * Specs mock the module with it and assert no glyph comes out black.
48
+ * Specs mock the module with it and assert no glyph comes out black. Like
49
+ * phosphor-react-native, its icons are plain functions: they take `weight`
50
+ * from props or the module's `IconContext`, and the outline only as props,
51
+ * which the theme-ink IconBase forwards from that context (FZ-8996).
41
52
  *
42
53
  * @param {Record<string, unknown>} real the real `@phosphor-icons/react` module
43
54
  * @param {() => unknown} useTheme
44
55
  */
45
56
  export function nativePhosphorModule(real, useTheme) {
46
- const Base = themeInkIconBase(NativeIconProbe, useTheme);
57
+ const IconContext = real.IconContext;
58
+ const Base = themeInkIconBase(nativeIconProbe(IconContext), useTheme, () =>
59
+ IconContext ? useContext(IconContext) : undefined,
60
+ );
47
61
  const icons = {};
48
62
  for (const [key, value] of Object.entries(real)) {
49
63
  if (!/^[A-Z]/.test(key) || /^(?:IconContext|IconBase|SSRBase)$/.test(key)) continue;
@@ -5,7 +5,13 @@ export declare function resolveIconInk(
5
5
  color: unknown,
6
6
  ): string;
7
7
 
8
+ export declare function contextOutline(
9
+ context: Record<string, unknown> | null | undefined,
10
+ props: Record<string, unknown>,
11
+ ): Record<string, unknown>;
12
+
8
13
  export declare function themeInkIconBase<P extends { color?: unknown }>(
9
14
  IconBase: ComponentType<P>,
10
15
  useTheme: () => unknown,
16
+ useIconContext?: () => Record<string, unknown> | null | undefined,
11
17
  ): ComponentType<P>;
@@ -32,18 +32,45 @@ export function resolveIconInk(theme, color) {
32
32
  return paintOf(scope.color) ?? paintOf(scope.color12) ?? paintOf(scope.color11) ?? "currentColor";
33
33
  }
34
34
 
35
+ const OUTLINE = ["stroke", "strokeWidth", "strokeLinejoin", "strokeLinecap"];
36
+
37
+ /**
38
+ * The outline props Phosphor's `IconContext` carries that the icon's own props
39
+ * don't set. phosphor-react-native's IconBase reads only colour, size, weight
40
+ * and mirroring from its context, so the bold outline a Button hands down that
41
+ * way (FZ-8996) has to be forwarded here, as the web IconBase does itself.
42
+ *
43
+ * @param {Record<string, unknown> | null | undefined} context
44
+ * @param {Record<string, unknown>} props
45
+ */
46
+ export function contextOutline(context, props) {
47
+ const out = {};
48
+ if (context == null) return out;
49
+ for (const key of OUTLINE) {
50
+ if (props[key] == null && context[key] != null) out[key] = context[key];
51
+ }
52
+ return out;
53
+ }
54
+
35
55
  /**
36
56
  * Wraps phosphor-react-native's IconBase so every glyph, whoever renders it
37
- * and however its colour was (or was not) passed, paints from the theme.
57
+ * and however its colour was (or was not) passed, paints from the theme, and
58
+ * takes the outline its `IconContext` carries (FZ-8996).
38
59
  *
39
60
  * @template P
40
61
  * @param {(props: P) => unknown} IconBase
41
62
  * @param {() => unknown} useTheme
63
+ * @param {() => Record<string, unknown> | null | undefined} [useIconContext]
42
64
  */
43
- export function themeInkIconBase(IconBase, useTheme) {
65
+ export function themeInkIconBase(IconBase, useTheme, useIconContext) {
44
66
  function ThemeInkIconBase(props) {
45
67
  const theme = useTheme();
46
- return createElement(IconBase, { ...props, color: resolveIconInk(theme, props.color) });
68
+ const context = useIconContext ? useIconContext() : undefined;
69
+ return createElement(IconBase, {
70
+ ...contextOutline(context, props),
71
+ ...props,
72
+ color: resolveIconInk(theme, props.color),
73
+ });
47
74
  }
48
75
  ThemeInkIconBase.displayName = "IconBase";
49
76
  return ThemeInkIconBase;
package/src/testTiers.js CHANGED
@@ -28,6 +28,12 @@ export function integrationConfig(config) {
28
28
  );
29
29
  return {
30
30
  ...config,
31
- test: { ...test, include: integrationSpecs, exclude, passWithNoTests: false },
31
+ test: {
32
+ ...test,
33
+ include: integrationSpecs,
34
+ exclude,
35
+ passWithNoTests: false,
36
+ env: { ...test.env, MPO_TEST_NETWORK: "online" },
37
+ },
32
38
  };
33
39
  }
package/src/vite.ts CHANGED
@@ -1122,6 +1122,8 @@ function registerNativePhosphorIcons(): void {
1122
1122
  }
1123
1123
 
1124
1124
  export const phosphorNativeIconBaseId = "#mpo/phosphor-native-icon-base";
1125
+ /** phosphor-react-native's own `lib` (its `IconContext`), for the theme-ink shim (FZ-8996). */
1126
+ export const phosphorNativeIconLibId = "#mpo/phosphor-native-icon-lib";
1125
1127
 
1126
1128
  /**
1127
1129
  * Every phosphor-react-native glyph renders through its `lib/icon-base`, which
@@ -1140,11 +1142,13 @@ export function phosphorNativeIconBase(
1140
1142
  path.resolve(here, "../src/shims/phosphorIconBase.native.js"),
1141
1143
  ].find((candidate) => fs.existsSync(candidate));
1142
1144
  const original = path.join(path.dirname(nativeEntry), "lib", "icon-base.js");
1143
- if (!shim || !fs.existsSync(original)) return null;
1145
+ const lib = path.join(path.dirname(nativeEntry), "lib", "index.js");
1146
+ if (!shim || !fs.existsSync(original) || !fs.existsSync(lib)) return null;
1144
1147
  const packageDir = `${path.sep}phosphor-react-native${path.sep}`;
1145
1148
  const iconBaseImport = /(?:^|[\\/])lib[\\/]icon-base(?:\.js)?$/;
1146
1149
  return (id, importer) => {
1147
1150
  if (id === phosphorNativeIconBaseId) return original;
1151
+ if (id === phosphorNativeIconLibId) return lib;
1148
1152
  if (!importer || importer === shim || !importer.includes(packageDir)) return null;
1149
1153
  return iconBaseImport.test(id) ? shim : null;
1150
1154
  };
@@ -404,4 +404,10 @@ describe("test tiers by file name (FZ-10556)", () => {
404
404
  "tests/lifecycle.live.spec.tsx",
405
405
  ]);
406
406
  });
407
+
408
+ it("lets the integration run reach the network and keeps a package's own env (FZ-11400)", () => {
409
+ const own = { test: { env: { TZ: "UTC" } } };
410
+ expect(integrationConfig(own).test.env).toEqual({ TZ: "UTC", MPO_TEST_NETWORK: "online" });
411
+ expect(own.test.env).toEqual({ TZ: "UTC" });
412
+ });
407
413
  });
package/types/vite.d.ts CHANGED
@@ -169,6 +169,8 @@ export { discoverPublicPackageRoots, publicPackageViteSourceAliases, resolveWork
169
169
  export { publicConfigPlugin, readPublicConfigKeys, type PublicConfigPluginOptions, } from "./publicConfig.js";
170
170
  export { phosphorTokenColorPlugin } from "./phosphorTokenColor.js";
171
171
  export declare const phosphorNativeIconBaseId = "#mpo/phosphor-native-icon-base";
172
+ /** phosphor-react-native's own `lib` (its `IconContext`), for the theme-ink shim (FZ-8996). */
173
+ export declare const phosphorNativeIconLibId = "#mpo/phosphor-native-icon-lib";
172
174
  /**
173
175
  * Every phosphor-react-native glyph renders through its `lib/icon-base`, which
174
176
  * paints a missing colour `#000` and a Tamagui token as no paint (black too).
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,MAAM,CAAC;AAI/C,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EACJ,OAAO,GACP;QACE;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QAEtB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEN;;OAEG;IACH,IAAI,CAAC,EACD,OAAO,GACP;QACE;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAEjB;;WAEG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;IAEN;;;OAGG;IACH,GAAG,CAAC,EACA,OAAO,GACP;QACE,MAAM,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3B,GAAG,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACtD,KAAK,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;QAC/B,MAAM,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,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