@multiplatform.one/config 9.17.0 → 10.0.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 +29 -6
- package/lib/index.js +4 -4
- package/lib/{storybook-BpaziEtP.js → storybook-BRZwQLAM.js} +150 -9
- package/lib/storybook.js +1 -1
- package/lib/{tamaguiWorkspacePaths-DR3dud79.js → tamaguiWorkspacePaths-BFMQNk1l.js} +8 -5
- package/lib/{vite-CgiDLR6V.js → vite-DaBjbGS0.js} +40 -52
- package/lib/vite.js +4 -4
- package/lib/{vitest-B2vcGrZM.js → vitest-NTT7k5jB.js} +97 -10
- package/lib/vitest.js +2 -2
- package/lib/{workspacePublicPackages-DN-1LPcH.js → workspacePublicPackages-z0fVhgGN.js} +121 -8
- package/lint.mjs +874 -52
- package/oxlint.mjs +26 -1
- package/package.json +6 -6
- package/press-lint.mjs +86 -5
- package/spec-registry.mjs +15 -0
- package/src/lint.spec.ts +696 -12
- package/src/movedDepAliases.spec.ts +73 -0
- package/src/movedDepAliases.ts +91 -0
- package/src/nativeBlockScoping.spec.ts +12 -14
- package/src/nativeOnlyDepStubs.spec.ts +178 -0
- package/src/nativeOnlyDepStubs.ts +215 -0
- package/src/noVoicelessText.rule.spec.ts +1 -1
- package/src/noVoicelessText.spec.ts +1 -1
- package/src/oxlint.spec.ts +5 -5
- package/src/phosphorNativeInk.spec.ts +17 -18
- package/src/phosphorTokenColor.spec.ts +35 -0
- package/src/phosphorTokenColor.ts +8 -5
- package/src/press-lint.spec.ts +64 -3
- package/src/react-native.config.cjs +9 -0
- package/src/shims/phosphorThemeInk.js +6 -1
- package/src/shims/svgTouchSound.web.js +23 -0
- package/src/singletonDepAliases.spec.ts +99 -14
- package/src/singletonDepAliases.ts +102 -7
- package/src/storybook.spec.ts +0 -3
- package/src/storybook.ts +17 -6
- package/src/vite.nativeEntries.spec.ts +21 -20
- package/src/vite.spec.ts +11 -20
- package/src/vite.ts +44 -68
- package/src/vitest.spec.ts +142 -4
- package/src/vitest.ts +106 -8
- package/types/movedDepAliases.d.ts +8 -0
- package/types/movedDepAliases.d.ts.map +1 -0
- package/types/nativeOnlyDepStubs.d.ts +41 -0
- package/types/nativeOnlyDepStubs.d.ts.map +1 -0
- package/types/phosphorTokenColor.d.ts.map +1 -1
- package/types/singletonDepAliases.d.ts +55 -3
- package/types/singletonDepAliases.d.ts.map +1 -1
- package/types/storybook.d.ts.map +1 -1
- package/types/vite.d.ts +10 -1
- package/types/vite.d.ts.map +1 -1
- package/types/vitest.d.ts +46 -1
- package/types/vitest.d.ts.map +1 -1
package/design-lint.mjs
CHANGED
|
@@ -61,6 +61,8 @@ const middotJoin = /(^|[^\p{L}\p{N}])·([^\p{L}\p{N}]|$)|\s•\s/u;
|
|
|
61
61
|
const focusPaint =
|
|
62
62
|
/^(?:outline(?:Width|Color|Offset)?|boxShadow|shadow(?:Color|Opacity|Radius|Offset)|elevation)$/;
|
|
63
63
|
const focusStates = new Set(["focusStyle", "focusVisibleStyle", "focusWithinStyle"]);
|
|
64
|
+
const focusClausePaint =
|
|
65
|
+
/(?<![\w/-])(?:[@A-Za-z][\w/@-]*:)*focus(?:-visible|-within)?:(?!(?:0(?:px)?|none|transparent)(?:\s+[@A-Za-z][\w/@-]*:|\s*$))\S/;
|
|
64
66
|
// LC-149 FIELD-TRAILING-ACTION: a field's own action (reveal, clear, copy,
|
|
65
67
|
// eyedropper) is Input.Action inside the field, never an icon button beside it.
|
|
66
68
|
const fieldTag =
|
|
@@ -72,6 +74,11 @@ const rowTag = /^(?:XStack|XGroup)$|\.XGroup$/;
|
|
|
72
74
|
// copy inside its top-trailing corner), never mono text with a copy beside it.
|
|
73
75
|
const copyGlyph = /(?:Copy|Clipboard)\w*Icon\b/;
|
|
74
76
|
const copyTag = /^Copy\w*Button$/;
|
|
77
|
+
// Tamagui 3 replaced `Component.styleable(fn)` with `createStyledHOC(Component,
|
|
78
|
+
// fn)`, so a wrapped component spells its render function as the second
|
|
79
|
+
// argument. Both shapes are unwrapped while the tree is half converted.
|
|
80
|
+
const styleableWrap = /\.styleable$/;
|
|
81
|
+
const styledHocWrap = /(?:^|\.)createStyledHOC$/;
|
|
75
82
|
// LC-176 ICON-BUTTON: an icon-only button paints its recipe's plate. A prop that
|
|
76
83
|
// paints its own plate, ring or corners around the glyph needs a named plate.
|
|
77
84
|
const buttonTag = /^(?:Button|IconButton|TamaguiButton|PageBarButton)$|\.Button$/;
|
|
@@ -296,6 +303,7 @@ const labelKey =
|
|
|
296
303
|
// not seen, unless it doubles as the control's tooltip (LC-260), so syntax
|
|
297
304
|
// can't tell which case it takes.
|
|
298
305
|
const spokenKey = /^(?:aria-label|accessibilityLabel)$/;
|
|
306
|
+
const spokenCall = /^a11yProps$/;
|
|
299
307
|
const pluralHedge = /[a-z]{2,}\(s\)(?=[\s"'`?.,;:!)]|$)/;
|
|
300
308
|
const errorLead =
|
|
301
309
|
/^(?:\d|\{x\}\s*:|[A-Z][A-Z0-9]*_[A-Z0-9_]*\b|[A-Z]{2,}[A-Z0-9]*(?::|\s+\d)|[a-z][a-z0-9]*(?:[A-Z_.][A-Za-z0-9_]*)+\b)/;
|
|
@@ -804,7 +812,8 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
804
812
|
function numeric(node) {
|
|
805
813
|
const value = resolve(node);
|
|
806
814
|
if (ts.isNumericLiteral(value)) return true;
|
|
807
|
-
if (ts.isStringLiteral(value))
|
|
815
|
+
if (ts.isStringLiteral(value))
|
|
816
|
+
return /^-?\d+(?:\.\d+)?(?:px|rem|em)$|^-?\d+\.\d+$/.test(value.text);
|
|
808
817
|
if (ts.isPrefixUnaryExpression(value)) return numeric(value.operand);
|
|
809
818
|
if (ts.isBinaryExpression(value)) {
|
|
810
819
|
if (
|
|
@@ -874,6 +883,15 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
874
883
|
return undefined;
|
|
875
884
|
}
|
|
876
885
|
function checkFocus(key, value, node) {
|
|
886
|
+
const flat = resolve(value);
|
|
887
|
+
if (focusPaint.test(key) && ts.isStringLiteralLike(flat) && focusClausePaint.test(flat.text)) {
|
|
888
|
+
report(
|
|
889
|
+
node,
|
|
890
|
+
"field-focus",
|
|
891
|
+
`${key} paints its own focus clause; focus comes from MPO (FIELD_FOCUS_STYLE).`,
|
|
892
|
+
);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
877
895
|
if (!focusStates.has(key)) return;
|
|
878
896
|
const painted = paintsFocus(value);
|
|
879
897
|
if (painted)
|
|
@@ -951,7 +969,7 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
951
969
|
if (!children.some(copiesBeside)) return;
|
|
952
970
|
for (const child of children) {
|
|
953
971
|
const font = attribute(child, "fontFamily");
|
|
954
|
-
if (font?.initializer &&
|
|
972
|
+
if (font?.initializer && /(?<![\w-])\$?mono(?![\w-])/.test(font.initializer.getText(file)))
|
|
955
973
|
report(
|
|
956
974
|
child,
|
|
957
975
|
"code-block",
|
|
@@ -1120,6 +1138,8 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
1120
1138
|
return "data";
|
|
1121
1139
|
if (ts.isCallExpression(host) && /toast|notif|snack/i.test(host.expression.getText(file)))
|
|
1122
1140
|
return "text";
|
|
1141
|
+
if (ts.isCallExpression(host) && spokenCall.test(host.expression.getText(file)))
|
|
1142
|
+
return undefined;
|
|
1123
1143
|
if (
|
|
1124
1144
|
/^(?:label|title|heading)$/.test(key) &&
|
|
1125
1145
|
parent.parent.properties.some((prop) => prop.name && runningSibling.test(name(prop.name)))
|
|
@@ -1924,7 +1944,8 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
1924
1944
|
const callee = current.expression.getText(file);
|
|
1925
1945
|
if (/^(?:(?:React\.)?(?:memo|forwardRef)|observer|withStaticProperties)$/.test(callee))
|
|
1926
1946
|
current = current.arguments[0];
|
|
1927
|
-
else if (
|
|
1947
|
+
else if (styleableWrap.test(callee)) current = current.arguments[0];
|
|
1948
|
+
else if (styledHocWrap.test(callee) && current.arguments[1]) current = current.arguments[1];
|
|
1928
1949
|
else return current;
|
|
1929
1950
|
}
|
|
1930
1951
|
}
|
|
@@ -1934,8 +1955,10 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
1934
1955
|
if (ts.isArrowFunction(value) || ts.isFunctionExpression(value))
|
|
1935
1956
|
return paintsOwnSurface(value.body);
|
|
1936
1957
|
if (styledPrimitive(value)?.paints) return true;
|
|
1937
|
-
if (ts.isCallExpression(value)
|
|
1938
|
-
|
|
1958
|
+
if (ts.isCallExpression(value)) {
|
|
1959
|
+
const callee = value.expression.getText(file);
|
|
1960
|
+
if (styleableWrap.test(callee) || styledHocWrap.test(callee)) return false;
|
|
1961
|
+
}
|
|
1939
1962
|
return false;
|
|
1940
1963
|
}
|
|
1941
1964
|
function checkMpoRoles() {
|
|
@@ -2011,7 +2034,7 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
2011
2034
|
/^(?:bg|backgroundColor|background)$/.test(key) &&
|
|
2012
2035
|
value &&
|
|
2013
2036
|
!inert(value) &&
|
|
2014
|
-
!/^["'`]
|
|
2037
|
+
!/^["'`]?\$?(?:background|background-transparent)["'`]?$/.test(value.getText(file)),
|
|
2015
2038
|
);
|
|
2016
2039
|
const shape = [...keys].some(
|
|
2017
2040
|
([key, value]) =>
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as phosphorTokenColorPlugin, n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-
|
|
2
|
-
import { t as createStorybookViteConfig } from "./storybook-
|
|
3
|
-
import { t as createViteConfig } from "./vite-
|
|
4
|
-
import { t as createVitestConfig } from "./vitest-
|
|
1
|
+
import { i as phosphorTokenColorPlugin, n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
|
|
2
|
+
import { t as createStorybookViteConfig } from "./storybook-BRZwQLAM.js";
|
|
3
|
+
import { t as createViteConfig } from "./vite-DaBjbGS0.js";
|
|
4
|
+
import { t as createVitestConfig } from "./vitest-NTT7k5jB.js";
|
|
5
5
|
|
|
6
6
|
export { createStorybookViteConfig, createViteConfig, createVitestConfig, ensureTamaguiWorkspacePaths, phosphorTokenColorPlugin, tamaguiWorkspacePathsFile };
|
|
@@ -1,9 +1,146 @@
|
|
|
1
|
-
import { c as withSingletonDepAliases, r as resolvePackageMainSource, t as discoverPublicPackageRoots } from "./workspacePublicPackages-
|
|
2
|
-
import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-
|
|
1
|
+
import { c as singletonResolvePlugin, l as withSingletonDepAliases, r as resolvePackageMainSource, t as discoverPublicPackageRoots, u as movedDepAliases } from "./workspacePublicPackages-z0fVhgGN.js";
|
|
2
|
+
import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
6
7
|
|
|
8
|
+
//#region src/nativeOnlyDepStubs.ts
|
|
9
|
+
const NATIVE_ONLY_MODULES = [{
|
|
10
|
+
pkg: "react-native-svg",
|
|
11
|
+
flavours: [
|
|
12
|
+
"lib/module/fabric/NativeSvgSoundModule.js",
|
|
13
|
+
"lib/commonjs/fabric/NativeSvgSoundModule.js",
|
|
14
|
+
"src/fabric/NativeSvgSoundModule.ts"
|
|
15
|
+
],
|
|
16
|
+
specifier: "../fabric/NativeSvgSoundModule",
|
|
17
|
+
binding: "TurboModuleRegistry",
|
|
18
|
+
stub: "svgTouchSound.web.js"
|
|
19
|
+
}];
|
|
20
|
+
/** The web stand-in for `react-native`, whose exports decide every entry. */
|
|
21
|
+
const webRuntime = {
|
|
22
|
+
pkg: "react-native-web",
|
|
23
|
+
entry: "dist/index.js"
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Entries whose breakage is real in this tree, with their stub resolved.
|
|
27
|
+
*
|
|
28
|
+
* @param root Directory whose `node_modules` the packages resolve from.
|
|
29
|
+
*/
|
|
30
|
+
function nativeOnlyDepStubs(root = process.cwd()) {
|
|
31
|
+
const requireFrom = createRequire(path.join(root, "package.json"));
|
|
32
|
+
const webExports = runtimeExports(root, requireFrom);
|
|
33
|
+
const stubs = [];
|
|
34
|
+
for (const entry of NATIVE_ONLY_MODULES) {
|
|
35
|
+
if (!webExports || webExports.has(entry.binding)) continue;
|
|
36
|
+
const pkgDir = resolvePackageDir$1(entry.pkg, root, requireFrom);
|
|
37
|
+
if (!pkgDir) continue;
|
|
38
|
+
if (!entry.flavours.map((flavour) => path.join(pkgDir, flavour)).filter((file) => fs.existsSync(file)).some((file) => importsBinding(file, entry.binding))) continue;
|
|
39
|
+
const stub = stubFile(entry.stub);
|
|
40
|
+
if (!stub) continue;
|
|
41
|
+
stubs.push({
|
|
42
|
+
marker: `${path.sep}${entry.pkg}${path.sep}`,
|
|
43
|
+
specifiers: [
|
|
44
|
+
entry.specifier,
|
|
45
|
+
`${entry.specifier}.js`,
|
|
46
|
+
`${entry.specifier}.ts`
|
|
47
|
+
],
|
|
48
|
+
stub
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return stubs;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The resolver behind both plugins below, or undefined when nothing in this
|
|
55
|
+
* tree measures as broken.
|
|
56
|
+
*/
|
|
57
|
+
function nativeOnlyDepResolver(root = process.cwd()) {
|
|
58
|
+
const stubs = nativeOnlyDepStubs(root);
|
|
59
|
+
if (!stubs.length) return void 0;
|
|
60
|
+
return (id, importer) => {
|
|
61
|
+
if (!importer) return null;
|
|
62
|
+
for (const stub of stubs) {
|
|
63
|
+
if (!importer.includes(stub.marker)) continue;
|
|
64
|
+
if (stub.specifiers.includes(id)) return stub.stub;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Vite plugin for the transform pipeline (`vite build`, `storybook build`).
|
|
71
|
+
*
|
|
72
|
+
* `enforce: "pre"` is load-bearing: a normal-order plugin resolves after
|
|
73
|
+
* `vite:resolve`, which has already turned the relative specifier into a real
|
|
74
|
+
* file by then.
|
|
75
|
+
*/
|
|
76
|
+
function nativeOnlyDepStubPlugin(root = process.cwd()) {
|
|
77
|
+
const resolver = nativeOnlyDepResolver(root);
|
|
78
|
+
if (!resolver) return void 0;
|
|
79
|
+
return {
|
|
80
|
+
name: "multiplatform-native-only-dep-stubs",
|
|
81
|
+
enforce: "pre",
|
|
82
|
+
resolveId(id, importer) {
|
|
83
|
+
return resolver(id, importer);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The same resolver for the dev dep-optimizer, which runs its own rolldown
|
|
89
|
+
* build that sees neither user plugins nor `resolve.alias` for a relative
|
|
90
|
+
* specifier — only `optimizeDeps.rolldownOptions.plugins`. Carries no vite-only
|
|
91
|
+
* fields, since rolldown receives this object directly.
|
|
92
|
+
*/
|
|
93
|
+
function nativeOnlyDepStubOptimizerPlugin(root = process.cwd()) {
|
|
94
|
+
const resolver = nativeOnlyDepResolver(root);
|
|
95
|
+
if (!resolver) return void 0;
|
|
96
|
+
return {
|
|
97
|
+
name: "multiplatform-native-only-dep-stubs",
|
|
98
|
+
resolveId: resolver
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Names the web runtime re-exports, or undefined when it cannot be read. */
|
|
102
|
+
function runtimeExports(root, requireFrom) {
|
|
103
|
+
const pkgDir = resolvePackageDir$1(webRuntime.pkg, root, requireFrom);
|
|
104
|
+
if (!pkgDir) return void 0;
|
|
105
|
+
let source;
|
|
106
|
+
try {
|
|
107
|
+
source = fs.readFileSync(path.join(pkgDir, webRuntime.entry), "utf8");
|
|
108
|
+
} catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const names = /* @__PURE__ */ new Set();
|
|
112
|
+
for (const match of source.matchAll(/^export\s*\{([^}]*)\}/gm)) for (const clause of match[1].split(",")) {
|
|
113
|
+
const name = clause.trim().split(/\s+as\s+/).pop()?.trim();
|
|
114
|
+
if (name) names.add(name);
|
|
115
|
+
}
|
|
116
|
+
for (const match of source.matchAll(/^export\s+(?:const|let|var|function|class)\s+(\w+)/gm)) names.add(match[1]);
|
|
117
|
+
return names.size ? names : void 0;
|
|
118
|
+
}
|
|
119
|
+
/** Whether the module takes the binding off `react-native` by name. */
|
|
120
|
+
function importsBinding(file, binding) {
|
|
121
|
+
let source;
|
|
122
|
+
try {
|
|
123
|
+
source = fs.readFileSync(file, "utf8");
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return new RegExp(`(?:import|require)[^;]*\\b${binding}\\b[^;]*['"]react-native['"]`, "s").test(source);
|
|
128
|
+
}
|
|
129
|
+
/** `src/shims/<name>` from source, `../src/shims/<name>` from the built `lib`. */
|
|
130
|
+
function stubFile(name) {
|
|
131
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
132
|
+
return [path.resolve(here, "shims", name), path.resolve(here, "../src/shims", name)].find((candidate) => fs.existsSync(candidate));
|
|
133
|
+
}
|
|
134
|
+
function resolvePackageDir$1(pkgName, root, requireFrom) {
|
|
135
|
+
try {
|
|
136
|
+
return path.dirname(requireFrom.resolve(`${pkgName}/package.json`));
|
|
137
|
+
} catch {
|
|
138
|
+
const hoisted = path.join(root, "node_modules", ...pkgName.split("/"));
|
|
139
|
+
return fs.existsSync(path.join(hoisted, "package.json")) ? hoisted : void 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
7
144
|
//#region src/unexportedDepAliases.ts
|
|
8
145
|
/**
|
|
9
146
|
* Package subtrees that consumers deep-import but the publisher never declared
|
|
@@ -92,10 +229,14 @@ function resolvePackageDir(pkgName, root, requireFrom) {
|
|
|
92
229
|
function createStorybookViteConfig(options = {}) {
|
|
93
230
|
ensureTamaguiWorkspacePaths();
|
|
94
231
|
const workspaceRoot = options.workspaceRoot || findWorkspaceRoot();
|
|
232
|
+
const packagesDir = path.join(workspaceRoot, "packages");
|
|
233
|
+
const nativeOnlyStub = nativeOnlyDepStubPlugin(workspaceRoot);
|
|
234
|
+
const nativeOnlyStubForOptimizer = nativeOnlyDepStubOptimizerPlugin(workspaceRoot);
|
|
95
235
|
const sortedAliases = withSingletonDepAliases({
|
|
96
|
-
...discoverPackageAliases(
|
|
236
|
+
...discoverPackageAliases(packagesDir),
|
|
97
237
|
...discoverPublicPackageViteAliases(workspaceRoot),
|
|
98
|
-
...unexportedDepAliases(workspaceRoot)
|
|
238
|
+
...unexportedDepAliases(workspaceRoot),
|
|
239
|
+
...movedDepAliases(workspaceRoot)
|
|
99
240
|
}, workspaceRoot, options.aliases);
|
|
100
241
|
return {
|
|
101
242
|
define: {
|
|
@@ -129,12 +270,10 @@ function createStorybookViteConfig(options = {}) {
|
|
|
129
270
|
"react-native-web",
|
|
130
271
|
"@tamagui/core",
|
|
131
272
|
"@tamagui/web",
|
|
132
|
-
"@tamagui/helpers-icon",
|
|
133
273
|
"tamagui",
|
|
134
274
|
"@tamagui/animations-css",
|
|
135
275
|
"@tamagui/react-native-svg",
|
|
136
276
|
"@tamagui/colors",
|
|
137
|
-
"@tamagui/config",
|
|
138
277
|
"@tamagui/config/v5",
|
|
139
278
|
"@tamagui/constants",
|
|
140
279
|
"@tamagui/font-inter",
|
|
@@ -143,7 +282,6 @@ function createStorybookViteConfig(options = {}) {
|
|
|
143
282
|
"@tamagui/input",
|
|
144
283
|
"@tamagui/label",
|
|
145
284
|
"@tamagui/linear-gradient",
|
|
146
|
-
"@tamagui/lucide-icons-2",
|
|
147
285
|
"@tamagui/popover",
|
|
148
286
|
"@tamagui/portal",
|
|
149
287
|
"@tamagui/roving-focus",
|
|
@@ -152,7 +290,6 @@ function createStorybookViteConfig(options = {}) {
|
|
|
152
290
|
"@tamagui/shorthands",
|
|
153
291
|
"@tamagui/stacks",
|
|
154
292
|
"@tamagui/text",
|
|
155
|
-
"@tamagui/theme-builder",
|
|
156
293
|
"@tamagui/themes",
|
|
157
294
|
"@tamagui/toast",
|
|
158
295
|
"@tamagui/use-presence",
|
|
@@ -170,6 +307,7 @@ function createStorybookViteConfig(options = {}) {
|
|
|
170
307
|
"use-sync-external-store/with-selector",
|
|
171
308
|
"fast-deep-equal",
|
|
172
309
|
"color",
|
|
310
|
+
"warn-once",
|
|
173
311
|
"query-string",
|
|
174
312
|
"react-is"
|
|
175
313
|
],
|
|
@@ -183,11 +321,14 @@ function createStorybookViteConfig(options = {}) {
|
|
|
183
321
|
"@react-navigation/elements",
|
|
184
322
|
"@react-navigation/bottom-tabs",
|
|
185
323
|
"@react-navigation/native-stack"
|
|
186
|
-
]
|
|
324
|
+
],
|
|
325
|
+
rolldownOptions: nativeOnlyStubForOptimizer ? { plugins: [nativeOnlyStubForOptimizer] } : void 0
|
|
187
326
|
},
|
|
188
327
|
plugins: [
|
|
328
|
+
singletonResolvePlugin(workspaceRoot),
|
|
189
329
|
nodeAsyncHooksStub(),
|
|
190
330
|
phosphorTokenColorPlugin(),
|
|
331
|
+
...nativeOnlyStub ? [nativeOnlyStub] : [],
|
|
191
332
|
...options.plugins || []
|
|
192
333
|
]
|
|
193
334
|
};
|
package/lib/storybook.js
CHANGED
|
@@ -27,6 +27,8 @@ import { useTheme } from "@tamagui/core";
|
|
|
27
27
|
import IconBase from ${JSON.stringify(originalIconBase)};
|
|
28
28
|
|
|
29
29
|
const isToken = (color) => typeof color === "string" && color.charAt(0) === "$";
|
|
30
|
+
const isNamed = (color) =>
|
|
31
|
+
typeof color === "string" && color.length > 0 && color !== "currentColor";
|
|
30
32
|
|
|
31
33
|
const paintOf = (entry) => {
|
|
32
34
|
const value = entry != null && typeof entry === "object" ? entry.val : entry;
|
|
@@ -35,16 +37,17 @@ const paintOf = (entry) => {
|
|
|
35
37
|
|
|
36
38
|
const ThemeColorIconBase = forwardRef(function ThemeColorIconBase(props, ref) {
|
|
37
39
|
const theme = useTheme() || {};
|
|
40
|
+
const name = isToken(props.color) ? props.color.slice(1) : props.color;
|
|
38
41
|
const color =
|
|
39
|
-
paintOf(theme[
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
paintOf(theme[name]) ??
|
|
43
|
+
(isToken(props.color)
|
|
44
|
+
? paintOf(theme.color) ?? paintOf(theme["color-12"]) ?? paintOf(theme["color-11"])
|
|
45
|
+
: props.color);
|
|
43
46
|
return createElement(IconBase, { ...props, ref, color });
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
const TokenColorIconBase = forwardRef(function TokenColorIconBase(props, ref) {
|
|
47
|
-
return createElement(
|
|
50
|
+
return createElement(isNamed(props.color) ? ThemeColorIconBase : IconBase, { ...props, ref });
|
|
48
51
|
});
|
|
49
52
|
TokenColorIconBase.displayName = "IconBase";
|
|
50
53
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-
|
|
1
|
+
import { c as singletonResolvePlugin, d as __require, i as resolveWorkspaceNativeEntry, l as withSingletonDepAliases, o as lookupTamaguiModules, s as resolveConfig, t as discoverPublicPackageRoots, u as movedDepAliases } from "./workspacePublicPackages-z0fVhgGN.js";
|
|
2
|
+
import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import dotenv from "dotenv";
|
|
@@ -225,6 +225,7 @@ function createViteConfig(options = {}) {
|
|
|
225
225
|
dotenv.config({ path: path.resolve(projectRoot, ".env") });
|
|
226
226
|
if (publicConfigKeys.length > 0) bakePublicConfig(publicConfigKeys);
|
|
227
227
|
const vitePlugins = [];
|
|
228
|
+
vitePlugins.push(singletonResolvePlugin(projectRoot));
|
|
228
229
|
vitePlugins.push(preferBuiltWorkspaceEntryPlugin());
|
|
229
230
|
vitePlugins.push(phosphorTokenColorPlugin());
|
|
230
231
|
if (publicConfigFile) vitePlugins.push(publicConfigPlugin({
|
|
@@ -235,14 +236,14 @@ function createViteConfig(options = {}) {
|
|
|
235
236
|
if (one) {
|
|
236
237
|
vitePlugins.push(ssrReactNativeAliasPlugin());
|
|
237
238
|
vitePlugins.push(clientBrokenEsmPlugin());
|
|
238
|
-
registerNativeEngineIoBrowserTransports();
|
|
239
|
-
registerNativeSinglePackageInstances();
|
|
240
|
-
registerNativeWorkspaceEntries();
|
|
241
|
-
registerNativePhosphorIcons();
|
|
242
|
-
if (nativeFixes?.protoShadow !== false) registerNativeProtoShadowFix();
|
|
243
|
-
if (nativeFixes?.web3Stub !== false) registerNativeWeb3Stub();
|
|
244
|
-
if (nativeFixes?.blockScoping !== false) registerNativeBlockScoping();
|
|
245
|
-
registerNativeCommunityFlowStrip();
|
|
239
|
+
vitePlugins.push(registerNativeEngineIoBrowserTransports());
|
|
240
|
+
vitePlugins.push(registerNativeSinglePackageInstances());
|
|
241
|
+
vitePlugins.push(registerNativeWorkspaceEntries());
|
|
242
|
+
vitePlugins.push(registerNativePhosphorIcons());
|
|
243
|
+
if (nativeFixes?.protoShadow !== false) vitePlugins.push(registerNativeProtoShadowFix());
|
|
244
|
+
if (nativeFixes?.web3Stub !== false) vitePlugins.push(registerNativeWeb3Stub());
|
|
245
|
+
if (nativeFixes?.blockScoping !== false) vitePlugins.push(registerNativeBlockScoping());
|
|
246
|
+
vitePlugins.push(registerNativeCommunityFlowStrip());
|
|
246
247
|
if (ssrCjsExternal !== false) vitePlugins.push(ssrCjsExternalFixPlugin([...DEFAULT_SSR_CJS_EXTERNAL, ...ssrCjsExternal ?? []]));
|
|
247
248
|
}
|
|
248
249
|
if (tamagui) {
|
|
@@ -250,8 +251,7 @@ function createViteConfig(options = {}) {
|
|
|
250
251
|
vitePlugins.push(tamaguiPlugin({
|
|
251
252
|
components: tamaguiOpts.components || lookupTamaguiModules([process.cwd()]),
|
|
252
253
|
config: tamaguiOpts.config || "./config/tamagui.config.ts",
|
|
253
|
-
outputCSS: tamaguiOpts.outputCSS || "./public/tamagui.css"
|
|
254
|
-
disableWatchTamaguiConfig: true
|
|
254
|
+
outputCSS: tamaguiOpts.outputCSS || "./public/tamagui.css"
|
|
255
255
|
}));
|
|
256
256
|
}
|
|
257
257
|
if (i18n) {
|
|
@@ -347,7 +347,8 @@ function createViteConfig(options = {}) {
|
|
|
347
347
|
resolve: {
|
|
348
348
|
alias: withSingletonDepAliases({
|
|
349
349
|
"react.mjs": "react",
|
|
350
|
-
"react-compiler-runtime": "react/compiler-runtime"
|
|
350
|
+
"react-compiler-runtime": "react/compiler-runtime",
|
|
351
|
+
...movedDepAliases(projectRoot)
|
|
351
352
|
}, projectRoot),
|
|
352
353
|
dedupe: ["react-is"]
|
|
353
354
|
},
|
|
@@ -415,8 +416,20 @@ function clientBrokenEsmPlugin() {
|
|
|
415
416
|
};
|
|
416
417
|
}
|
|
417
418
|
/**
|
|
419
|
+
* A rolldown plugin for the native bundle only. one 2.x hands every vite
|
|
420
|
+
* plugin that carries `api.vxrnNative` to vxrn's native rolldown pipeline, in
|
|
421
|
+
* dev and in the native export; the vite plugin is a hookless shell under its
|
|
422
|
+
* own name, so web and SSR never run or list the native plugin.
|
|
423
|
+
*/
|
|
424
|
+
function nativeOnlyPlugin(plugin) {
|
|
425
|
+
return {
|
|
426
|
+
name: `mpo-native:${plugin.name}`,
|
|
427
|
+
api: { vxrnNative: () => plugin }
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
418
431
|
* Adds engine.io-client's `browser`-field transport redirect to vxrn's NATIVE
|
|
419
|
-
* rolldown pipeline via
|
|
432
|
+
* rolldown pipeline via one's `api.vxrnNative` hook.
|
|
420
433
|
*
|
|
421
434
|
* socket.io-client -> engine.io-client/index.js statically imports its Node
|
|
422
435
|
* transports (`./globals.node.js`, `./transports/{websocket,polling-xhr}.node.js`),
|
|
@@ -427,7 +440,7 @@ function clientBrokenEsmPlugin() {
|
|
|
427
440
|
* `WebSocket` / `XMLHttpRequest` React Native provides — but vxrn's native
|
|
428
441
|
* resolver omits the `browser` aliasField (and its rolldown binding doesn't even
|
|
429
442
|
* support `aliasFields`). vxrn's native dev engine ignores the Vite config's
|
|
430
|
-
* `resolve.alias`/`resolveId` too — BUT it DOES
|
|
443
|
+
* `resolve.alias`/`resolveId` too — BUT it DOES take one's `api.vxrnNative` plugins
|
|
431
444
|
* inside `getNativePlugins`, so a `resolveId` registered there runs on native.
|
|
432
445
|
* This re-asserts the browser redirect with no node_modules patch. Web is
|
|
433
446
|
* unaffected (engine.io is SSR-externalized and the web client already maps `browser`).
|
|
@@ -472,10 +485,7 @@ function clientBrokenEsmPlugin() {
|
|
|
472
485
|
* relative imports resolve inside the canonical copy for free.
|
|
473
486
|
*/
|
|
474
487
|
function registerNativeSinglePackageInstances() {
|
|
475
|
-
const g = globalThis;
|
|
476
488
|
const name = "vxrn-single-package-instances";
|
|
477
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
478
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
479
489
|
const rootModules = path.join(findProjectRoot(), "node_modules");
|
|
480
490
|
const storePath = /[\\/]node_modules[\\/]\.pnpm[\\/][^\\/]+[\\/]node_modules[\\/]((?:@[^\\/]+[\\/])?[^\\/]+)(?:[\\/](.*))?$/;
|
|
481
491
|
function versionOf(dir) {
|
|
@@ -505,7 +515,7 @@ function registerNativeSinglePackageInstances() {
|
|
|
505
515
|
return hoisted.get(pkg) ?? null;
|
|
506
516
|
}
|
|
507
517
|
const seen = /* @__PURE__ */ new Map();
|
|
508
|
-
|
|
518
|
+
return nativeOnlyPlugin({
|
|
509
519
|
name,
|
|
510
520
|
async resolveId(id, importer) {
|
|
511
521
|
if (!id || id.startsWith(".") || id.startsWith("/") || id.startsWith("\0")) return null;
|
|
@@ -534,12 +544,8 @@ function registerNativeSinglePackageInstances() {
|
|
|
534
544
|
});
|
|
535
545
|
}
|
|
536
546
|
function registerNativeEngineIoBrowserTransports() {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
540
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
541
|
-
g.__vxrnAddNativePlugins.push({
|
|
542
|
-
name,
|
|
547
|
+
return nativeOnlyPlugin({
|
|
548
|
+
name: "vxrn-engineio-browser-transports",
|
|
543
549
|
async resolveId(id, importer) {
|
|
544
550
|
if (importer && /engine\.io-client[\\/]build[\\/]/.test(importer) && id.endsWith(".node.js")) return this.resolve(`${id.slice(0, -8)}.js`, importer, { skipSelf: true });
|
|
545
551
|
return null;
|
|
@@ -548,7 +554,7 @@ function registerNativeEngineIoBrowserTransports() {
|
|
|
548
554
|
}
|
|
549
555
|
/**
|
|
550
556
|
* Routes workspace (`@multiplatform.one/*`) packages to their native entry on
|
|
551
|
-
* NATIVE, via
|
|
557
|
+
* NATIVE, via one's `api.vxrnNative` hook.
|
|
552
558
|
*
|
|
553
559
|
* Why this is needed: `preferBuiltWorkspaceEntryPlugin` (a Vite plugin, web/SSR only)
|
|
554
560
|
* hard-resolves every workspace bare specifier to `<root>/dist/esm/index.mjs` — the WEB
|
|
@@ -565,10 +571,7 @@ function registerNativeEngineIoBrowserTransports() {
|
|
|
565
571
|
* Web/SSR are unaffected (this plugin runs ONLY on native).
|
|
566
572
|
*/
|
|
567
573
|
function registerNativeWorkspaceEntries() {
|
|
568
|
-
const g = globalThis;
|
|
569
574
|
const name = "vxrn-workspace-native-entries";
|
|
570
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
571
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
572
575
|
let roots;
|
|
573
576
|
try {
|
|
574
577
|
roots = discoverPublicPackageRoots(findProjectRoot());
|
|
@@ -596,7 +599,7 @@ function registerNativeWorkspaceEntries() {
|
|
|
596
599
|
if (!entries.has(root)) entries.set(root, resolveWorkspaceNativeEntry(root) ?? null);
|
|
597
600
|
return entries.get(root);
|
|
598
601
|
};
|
|
599
|
-
|
|
602
|
+
return nativeOnlyPlugin({
|
|
600
603
|
name,
|
|
601
604
|
resolveId(id) {
|
|
602
605
|
const root = roots.get(id);
|
|
@@ -669,23 +672,17 @@ function requiresReact(id) {
|
|
|
669
672
|
* Object.prototype method back over an undefined shadowing own-property
|
|
670
673
|
* before any module code runs — the shadowed vars are reassigned by their
|
|
671
674
|
* own modules on init, so this only bridges the parse-to-init window.
|
|
672
|
-
* Registered through
|
|
675
|
+
* Registered through one's api.vxrnNative hook (vxrn's native engine
|
|
673
676
|
* ignores vite resolve/config). Web/SSR bundles are ESM (module-scoped vars)
|
|
674
677
|
* and unaffected.
|
|
675
678
|
*/
|
|
676
679
|
function registerNativeBlockScoping() {
|
|
677
|
-
|
|
678
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
679
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === "vxrn-native-block-scoping")) return;
|
|
680
|
-
g.__vxrnAddNativePlugins.push(nativeBlockScopingPlugin());
|
|
680
|
+
return nativeOnlyPlugin(nativeBlockScopingPlugin());
|
|
681
681
|
}
|
|
682
682
|
function registerNativeProtoShadowFix() {
|
|
683
|
-
const g = globalThis;
|
|
684
683
|
const name = "vxrn-proto-shadow-fix";
|
|
685
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
686
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
687
684
|
const snippet = "(function(){var p=Object.prototype,h=p.hasOwnProperty,ns=Object.getOwnPropertyNames(p);for(var i=0;i<ns.length;i++){var k=ns[i];if(typeof p[k]===\"function\"&&globalThis[k]===void 0&&h.call(globalThis,k)){try{globalThis[k]=p[k]}catch(e){}}}})();";
|
|
688
|
-
|
|
685
|
+
return nativeOnlyPlugin({
|
|
689
686
|
name,
|
|
690
687
|
renderChunk(code) {
|
|
691
688
|
return {
|
|
@@ -709,11 +706,8 @@ function registerNativeProtoShadowFix() {
|
|
|
709
706
|
* packages, so a consumer app needs no plugin of its own (FZ-7357).
|
|
710
707
|
*/
|
|
711
708
|
function registerNativeCommunityFlowStrip() {
|
|
712
|
-
const g = globalThis;
|
|
713
709
|
const name = "vxrn-community-flow-strip";
|
|
714
|
-
|
|
715
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
716
|
-
g.__vxrnAddNativePlugins.push({
|
|
710
|
+
return nativeOnlyPlugin({
|
|
717
711
|
name,
|
|
718
712
|
async transform(code, id) {
|
|
719
713
|
if (!/node_modules[\\/]@react-native-(community|segmented-control)[\\/].*\.jsx?$/.test(id)) return null;
|
|
@@ -747,10 +741,7 @@ function registerNativeCommunityFlowStrip() {
|
|
|
747
741
|
* normal pipeline and are unaffected.
|
|
748
742
|
*/
|
|
749
743
|
function registerNativeWeb3Stub() {
|
|
750
|
-
const g = globalThis;
|
|
751
744
|
const name = "vxrn-web3-stub";
|
|
752
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
753
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
754
745
|
try {
|
|
755
746
|
__require.resolve("@multiplatform.one/web3", { paths: [findProjectRoot(), process.cwd()] });
|
|
756
747
|
return;
|
|
@@ -758,7 +749,7 @@ function registerNativeWeb3Stub() {
|
|
|
758
749
|
const here = path.dirname(new URL(import.meta.url).pathname);
|
|
759
750
|
const shim = [path.resolve(here, "shims/web3Stub.native.js"), path.resolve(here, "../src/shims/web3Stub.native.js")].find((candidate) => fs.existsSync(candidate));
|
|
760
751
|
if (!shim) return;
|
|
761
|
-
|
|
752
|
+
return nativeOnlyPlugin({
|
|
762
753
|
name,
|
|
763
754
|
resolveId(id) {
|
|
764
755
|
if (id === "@multiplatform.one/web3/native" || id === "@multiplatform.one/web3") return shim;
|
|
@@ -789,10 +780,7 @@ function findProjectRoot() {
|
|
|
789
780
|
* when phosphor-react-native isn't installed in the consuming project.
|
|
790
781
|
*/
|
|
791
782
|
function registerNativePhosphorIcons() {
|
|
792
|
-
const g = globalThis;
|
|
793
783
|
const name = "vxrn-phosphor-native-icons";
|
|
794
|
-
g.__vxrnAddNativePlugins = g.__vxrnAddNativePlugins ?? [];
|
|
795
|
-
if (g.__vxrnAddNativePlugins.some((p) => p?.name === name)) return;
|
|
796
784
|
let nativeEntry = null;
|
|
797
785
|
try {
|
|
798
786
|
const cjsEntry = __require.resolve("phosphor-react-native", { paths: [findProjectRoot(), process.cwd()] });
|
|
@@ -802,7 +790,7 @@ function registerNativePhosphorIcons() {
|
|
|
802
790
|
nativeEntry = null;
|
|
803
791
|
}
|
|
804
792
|
const iconBase = nativeEntry ? phosphorNativeIconBase(nativeEntry) : null;
|
|
805
|
-
|
|
793
|
+
return nativeOnlyPlugin({
|
|
806
794
|
name,
|
|
807
795
|
resolveId(id, importer) {
|
|
808
796
|
if (iconBase) {
|
|
@@ -879,4 +867,4 @@ function preferBuiltWorkspaceEntryPlugin() {
|
|
|
879
867
|
}
|
|
880
868
|
|
|
881
869
|
//#endregion
|
|
882
|
-
export {
|
|
870
|
+
export { phosphorNativeIconLibId as a, phosphorNativeIconBaseId as i, nativeOnlyPlugin as n, publicConfigPlugin as o, phosphorNativeIconBase as r, readPublicConfigKeys as s, createViteConfig as t };
|
package/lib/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as staleNativeDistSource, i as resolveWorkspaceNativeEntry, n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-
|
|
2
|
-
import { i as phosphorTokenColorPlugin } from "./tamaguiWorkspacePaths-
|
|
3
|
-
import { a as
|
|
1
|
+
import { a as staleNativeDistSource, i as resolveWorkspaceNativeEntry, n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-z0fVhgGN.js";
|
|
2
|
+
import { i as phosphorTokenColorPlugin } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
|
|
3
|
+
import { a as phosphorNativeIconLibId, i as phosphorNativeIconBaseId, n as nativeOnlyPlugin, o as publicConfigPlugin, r as phosphorNativeIconBase, s as readPublicConfigKeys, t as createViteConfig } from "./vite-DaBjbGS0.js";
|
|
4
4
|
|
|
5
|
-
export { createViteConfig, discoverPublicPackageRoots, phosphorNativeIconBase, phosphorNativeIconBaseId, phosphorNativeIconLibId, phosphorTokenColorPlugin, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys, resolveWorkspaceNativeEntry, staleNativeDistSource };
|
|
5
|
+
export { createViteConfig, discoverPublicPackageRoots, nativeOnlyPlugin, phosphorNativeIconBase, phosphorNativeIconBaseId, phosphorNativeIconLibId, phosphorTokenColorPlugin, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys, resolveWorkspaceNativeEntry, staleNativeDistSource };
|