@multiplatform.one/config 9.1.0 → 9.2.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 +44 -8
- package/lib/index.js +1 -1
- package/lib/{vite-CeDmMMjx.js → vite-CgiDLR6V.js} +6 -2
- package/lib/vite.js +2 -2
- package/package.json +2 -2
- package/src/phosphorNativeInk.spec.ts +28 -2
- package/src/shims/phosphorIconBase.native.js +3 -1
- package/src/shims/phosphorNativeProbe.js +19 -5
- package/src/shims/phosphorThemeInk.d.ts +6 -0
- package/src/shims/phosphorThemeInk.js +30 -3
- package/src/testTiers.js +7 -1
- package/src/vite.ts +5 -1
- package/src/vitest.spec.ts +6 -0
- package/types/vite.d.ts +2 -0
- package/types/vite.d.ts.map +1 -1
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
|
|
1397
|
-
//
|
|
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
|
|
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 =
|
|
2020
|
-
|
|
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
|
-
|
|
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(
|
|
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-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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.
|
|
3
|
+
"version": "9.2.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.
|
|
125
|
+
"@multiplatform.one/utils": "^9.2.0",
|
|
126
126
|
"@tamagui/vite-plugin": "2.7.6",
|
|
127
127
|
"@vitejs/plugin-react": "^6.1.2",
|
|
128
128
|
"dotenv": "^17.4.2",
|
|
@@ -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 {
|
|
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", () => {
|
|
@@ -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
|
|
33
|
-
return
|
|
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
|
|
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
|
-
|
|
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: {
|
|
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
|
-
|
|
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
|
};
|
package/src/vitest.spec.ts
CHANGED
|
@@ -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).
|
package/types/vite.d.ts.map
CHANGED
|
@@ -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;IA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