@tamagui/static 3.0.0-beta.1313.1 → 3.0.0-beta.1341.1
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/dist/cjs/compilerHost.cjs +51 -3
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +49 -10
- package/dist/esm/compilerHost.mjs +52 -4
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +48 -10
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -1
- package/package.json +18 -18
- package/src/compilerHost.ts +119 -4
- package/src/extractor/esbuildTsconfigPaths.ts +57 -12
- package/types/compilerHost.d.ts.map +1 -1
- package/types/extractor/esbuildTsconfigPaths.d.ts +2 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
- package/types/zero/identity.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createPathsMatcher, getTsconfig, parseTsconfig } from "get-tsconfig";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
|
-
import { createPathsMatcher, getTsconfig, parseTsconfig } from "get-tsconfig";
|
|
4
4
|
|
|
5
5
|
const name = "tsconfig-paths";
|
|
6
6
|
function loadTsconfig(tsconfig, cwd = process.cwd()) {
|
|
@@ -26,27 +26,65 @@ function createTsconfigPathsMatcher(tsconfig, cwd = process.cwd()) {
|
|
|
26
26
|
const loaded = loadTsconfig(tsconfig, cwd);
|
|
27
27
|
return loaded ? createPathsMatcher(loaded) : null;
|
|
28
28
|
}
|
|
29
|
+
function loadTsconfigPathMatcher(tsconfig) {
|
|
30
|
+
let result;
|
|
31
|
+
if (!tsconfig) {
|
|
32
|
+
result = getTsconfig(process.cwd()) || getTsconfig(process.cwd(), "jsconfig.json");
|
|
33
|
+
} else if (typeof tsconfig === "string") {
|
|
34
|
+
if (fs.existsSync(tsconfig)) {
|
|
35
|
+
const configPath = path.resolve(tsconfig);
|
|
36
|
+
result = {
|
|
37
|
+
config: parseTsconfig(configPath),
|
|
38
|
+
path: configPath
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
throw new Error(`Specified tsconfig file not found: ${tsconfig}`);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
result = {
|
|
45
|
+
config: tsconfig,
|
|
46
|
+
path: path.join(process.cwd(), "tsconfig.json")
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!result) return () => [];
|
|
50
|
+
const matchPaths = createPathsMatcher(result);
|
|
51
|
+
const patterns = Object.keys(result.config.compilerOptions?.paths || {});
|
|
52
|
+
if (!matchPaths || patterns.length === 0) return () => [];
|
|
53
|
+
return (specifier) => {
|
|
54
|
+
const matchesExplicitPath = patterns.some((pattern) => {
|
|
55
|
+
const wildcardIndex = pattern.indexOf("*");
|
|
56
|
+
if (wildcardIndex === -1) return pattern === specifier;
|
|
57
|
+
return specifier.startsWith(pattern.slice(0, wildcardIndex)) && specifier.endsWith(pattern.slice(wildcardIndex + 1));
|
|
58
|
+
});
|
|
59
|
+
return matchesExplicitPath ? matchPaths(specifier) : [];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
29
62
|
function TsconfigPathsPlugin() {
|
|
30
|
-
const
|
|
63
|
+
const matchTsconfigPath = loadTsconfigPathMatcher();
|
|
31
64
|
return {
|
|
32
65
|
name,
|
|
33
66
|
setup(build) {
|
|
34
67
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
35
|
-
|
|
68
|
+
const pluginData = args.pluginData;
|
|
69
|
+
if (pluginData?.tamaguiTsconfigPaths || pluginData?.tamaguiTsconfigPathsResolved) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (args.path.startsWith("@tamagui/")) {
|
|
36
73
|
return null;
|
|
37
74
|
}
|
|
38
|
-
for (const candidate of
|
|
75
|
+
for (const candidate of matchTsconfigPath(args.path)) {
|
|
39
76
|
const resolved = await build.resolve(candidate, {
|
|
40
77
|
importer: args.importer,
|
|
41
78
|
kind: args.kind,
|
|
42
79
|
namespace: args.namespace,
|
|
43
|
-
resolveDir: args.resolveDir,
|
|
44
80
|
pluginData: {
|
|
45
|
-
...args.pluginData,
|
|
46
|
-
tamaguiTsconfigPaths: true
|
|
47
|
-
|
|
81
|
+
...args.pluginData && typeof args.pluginData === "object" ? args.pluginData : {},
|
|
82
|
+
tamaguiTsconfigPaths: true,
|
|
83
|
+
tamaguiTsconfigPathsResolved: true
|
|
84
|
+
},
|
|
85
|
+
resolveDir: args.resolveDir
|
|
48
86
|
});
|
|
49
|
-
if (resolved.
|
|
87
|
+
if (resolved.path && !resolved.path.endsWith(".d.ts") && resolved.errors.length === 0) {
|
|
50
88
|
return resolved;
|
|
51
89
|
}
|
|
52
90
|
}
|
|
@@ -56,5 +94,5 @@ function TsconfigPathsPlugin() {
|
|
|
56
94
|
};
|
|
57
95
|
}
|
|
58
96
|
|
|
59
|
-
export { TsconfigPathsPlugin, createTsconfigPathsMatcher };
|
|
97
|
+
export { TsconfigPathsPlugin, createTsconfigPathsMatcher, loadTsconfigPathMatcher };
|
|
60
98
|
//# sourceMappingURL=esbuildTsconfigPaths.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuildTsconfigPaths.js","names":[],"sources":["esm/extractor/esbuildTsconfigPaths.js"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"esbuildTsconfigPaths.js","names":[],"sources":["esm/extractor/esbuildTsconfigPaths.js"],"sourcesContent":["import {\n createPathsMatcher,\n getTsconfig,\n parseTsconfig\n} from \"get-tsconfig\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nconst name = \"tsconfig-paths\";\nfunction loadTsconfig(tsconfig, cwd = process.cwd()) {\n if (!tsconfig) {\n return getTsconfig(cwd) || getTsconfig(cwd, \"jsconfig.json\");\n }\n if (typeof tsconfig === \"string\") {\n const configPath = path.resolve(cwd, tsconfig);\n if (!fs.existsSync(configPath)) {\n throw new Error(`Specified tsconfig file not found: ${configPath}`);\n }\n return { path: configPath, config: parseTsconfig(configPath) };\n }\n return {\n path: path.join(cwd, \"tsconfig.json\"),\n config: tsconfig\n };\n}\nfunction createTsconfigPathsMatcher(tsconfig, cwd = process.cwd()) {\n const loaded = loadTsconfig(tsconfig, cwd);\n return loaded ? createPathsMatcher(loaded) : null;\n}\nfunction loadTsconfigPathMatcher(tsconfig) {\n let result;\n if (!tsconfig) {\n result = getTsconfig(process.cwd()) || getTsconfig(process.cwd(), \"jsconfig.json\");\n } else if (typeof tsconfig === \"string\") {\n if (fs.existsSync(tsconfig)) {\n const configPath = path.resolve(tsconfig);\n result = { config: parseTsconfig(configPath), path: configPath };\n } else {\n throw new Error(`Specified tsconfig file not found: ${tsconfig}`);\n }\n } else {\n result = { config: tsconfig, path: path.join(process.cwd(), \"tsconfig.json\") };\n }\n if (!result) return () => [];\n const matchPaths = createPathsMatcher(result);\n const patterns = Object.keys(result.config.compilerOptions?.paths || {});\n if (!matchPaths || patterns.length === 0) return () => [];\n return (specifier) => {\n const matchesExplicitPath = patterns.some((pattern) => {\n const wildcardIndex = pattern.indexOf(\"*\");\n if (wildcardIndex === -1) return pattern === specifier;\n return specifier.startsWith(pattern.slice(0, wildcardIndex)) && specifier.endsWith(pattern.slice(wildcardIndex + 1));\n });\n return matchesExplicitPath ? matchPaths(specifier) : [];\n };\n}\nfunction TsconfigPathsPlugin() {\n const matchTsconfigPath = loadTsconfigPathMatcher();\n return {\n name,\n setup(build) {\n build.onResolve({ filter: /.*/ }, async (args) => {\n const pluginData = args.pluginData;\n if (pluginData?.tamaguiTsconfigPaths || pluginData?.tamaguiTsconfigPathsResolved) {\n return null;\n }\n if (args.path.startsWith(\"@tamagui/\")) {\n return null;\n }\n for (const candidate of matchTsconfigPath(args.path)) {\n const resolved = await build.resolve(candidate, {\n importer: args.importer,\n kind: args.kind,\n namespace: args.namespace,\n pluginData: {\n ...args.pluginData && typeof args.pluginData === \"object\" ? args.pluginData : {},\n tamaguiTsconfigPaths: true,\n tamaguiTsconfigPathsResolved: true\n },\n resolveDir: args.resolveDir\n });\n if (resolved.path && !resolved.path.endsWith(\".d.ts\") && resolved.errors.length === 0) {\n return resolved;\n }\n }\n return null;\n });\n }\n };\n}\nexport {\n TsconfigPathsPlugin,\n createTsconfigPathsMatcher,\n loadTsconfigPathMatcher\n};\n//# sourceMappingURL=esbuildTsconfigPaths.js.map\n"],"mappings":";;;;;AAOA,MAAM,OAAO;AACb,SAAS,aAAa,UAAU,MAAM,QAAQ,IAAI,GAAG;CACnD,IAAI,CAAC,UAAU;EACb,OAAO,YAAY,GAAG,KAAK,YAAY,KAAK,eAAe;CAC7D;CACA,IAAI,OAAO,aAAa,UAAU;EAChC,MAAM,aAAa,KAAK,QAAQ,KAAK,QAAQ;EAC7C,IAAI,CAAC,GAAG,WAAW,UAAU,GAAG;GAC9B,MAAM,IAAI,MAAM,sCAAsC,YAAY;EACpE;EACA,OAAO;GAAE,MAAM;GAAY,QAAQ,cAAc,UAAU;EAAE;CAC/D;CACA,OAAO;EACL,MAAM,KAAK,KAAK,KAAK,eAAe;EACpC,QAAQ;CACV;AACF;AACA,SAAS,2BAA2B,UAAU,MAAM,QAAQ,IAAI,GAAG;CACjE,MAAM,SAAS,aAAa,UAAU,GAAG;CACzC,OAAO,SAAS,mBAAmB,MAAM,IAAI;AAC/C;AACA,SAAS,wBAAwB,UAAU;CACzC,IAAI;CACJ,IAAI,CAAC,UAAU;EACb,SAAS,YAAY,QAAQ,IAAI,CAAC,KAAK,YAAY,QAAQ,IAAI,GAAG,eAAe;CACnF,OAAO,IAAI,OAAO,aAAa,UAAU;EACvC,IAAI,GAAG,WAAW,QAAQ,GAAG;GAC3B,MAAM,aAAa,KAAK,QAAQ,QAAQ;GACxC,SAAS;IAAE,QAAQ,cAAc,UAAU;IAAG,MAAM;GAAW;EACjE,OAAO;GACL,MAAM,IAAI,MAAM,sCAAsC,UAAU;EAClE;CACF,OAAO;EACL,SAAS;GAAE,QAAQ;GAAU,MAAM,KAAK,KAAK,QAAQ,IAAI,GAAG,eAAe;EAAE;CAC/E;CACA,IAAI,CAAC,QAAQ,aAAa,CAAC;CAC3B,MAAM,aAAa,mBAAmB,MAAM;CAC5C,MAAM,WAAW,OAAO,KAAK,OAAO,OAAO,iBAAiB,SAAS,CAAC,CAAC;CACvE,IAAI,CAAC,cAAc,SAAS,WAAW,GAAG,aAAa,CAAC;CACxD,QAAQ,cAAc;EACpB,MAAM,sBAAsB,SAAS,MAAM,YAAY;GACrD,MAAM,gBAAgB,QAAQ,QAAQ,GAAG;GACzC,IAAI,kBAAkB,CAAC,GAAG,OAAO,YAAY;GAC7C,OAAO,UAAU,WAAW,QAAQ,MAAM,GAAG,aAAa,CAAC,KAAK,UAAU,SAAS,QAAQ,MAAM,gBAAgB,CAAC,CAAC;EACrH,CAAC;EACD,OAAO,sBAAsB,WAAW,SAAS,IAAI,CAAC;CACxD;AACF;AACA,SAAS,sBAAsB;CAC7B,MAAM,oBAAoB,wBAAwB;CAClD,OAAO;EACL;EACA,MAAM,OAAO;GACX,MAAM,UAAU,EAAE,QAAQ,KAAK,GAAG,OAAO,SAAS;IAChD,MAAM,aAAa,KAAK;IACxB,IAAI,YAAY,wBAAwB,YAAY,8BAA8B;KAChF,OAAO;IACT;IACA,IAAI,KAAK,KAAK,WAAW,WAAW,GAAG;KACrC,OAAO;IACT;IACA,KAAK,MAAM,aAAa,kBAAkB,KAAK,IAAI,GAAG;KACpD,MAAM,WAAW,MAAM,MAAM,QAAQ,WAAW;MAC9C,UAAU,KAAK;MACf,MAAM,KAAK;MACX,WAAW,KAAK;MAChB,YAAY;OACV,GAAG,KAAK,cAAc,OAAO,KAAK,eAAe,WAAW,KAAK,aAAa,CAAC;OAC/E,sBAAsB;OACtB,8BAA8B;MAChC;MACA,YAAY,KAAK;KACnB,CAAC;KACD,IAAI,SAAS,QAAQ,CAAC,SAAS,KAAK,SAAS,OAAO,KAAK,SAAS,OAAO,WAAW,GAAG;MACrF,OAAO;KACT;IACF;IACA,OAAO;GACT,CAAC;EACH;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1341.1",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -45,22 +45,22 @@
|
|
|
45
45
|
"clean:build": "tamagui-build clean:build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tamagui/animation-helpers": "3.0.0-beta.
|
|
49
|
-
"@tamagui/cli-color": "3.0.0-beta.
|
|
50
|
-
"@tamagui/compiler-core": "3.0.0-beta.
|
|
51
|
-
"@tamagui/config-default": "3.0.0-beta.
|
|
52
|
-
"@tamagui/core": "3.0.0-beta.
|
|
53
|
-
"@tamagui/dom": "3.0.0-beta.
|
|
54
|
-
"@tamagui/fake-react-native": "3.0.0-beta.
|
|
55
|
-
"@tamagui/generate-themes": "3.0.0-beta.
|
|
56
|
-
"@tamagui/helpers": "3.0.0-beta.
|
|
57
|
-
"@tamagui/helpers-node": "3.0.0-beta.
|
|
58
|
-
"@tamagui/react-native-web-internals": "3.0.0-beta.
|
|
59
|
-
"@tamagui/react-native-web-lite": "3.0.0-beta.
|
|
60
|
-
"@tamagui/shorthands": "3.0.0-beta.
|
|
61
|
-
"@tamagui/style-grammar": "3.0.0-beta.
|
|
62
|
-
"@tamagui/types": "3.0.0-beta.
|
|
63
|
-
"@tamagui/web": "3.0.0-beta.
|
|
48
|
+
"@tamagui/animation-helpers": "3.0.0-beta.1341.1",
|
|
49
|
+
"@tamagui/cli-color": "3.0.0-beta.1341.1",
|
|
50
|
+
"@tamagui/compiler-core": "3.0.0-beta.1341.1",
|
|
51
|
+
"@tamagui/config-default": "3.0.0-beta.1341.1",
|
|
52
|
+
"@tamagui/core": "3.0.0-beta.1341.1",
|
|
53
|
+
"@tamagui/dom": "3.0.0-beta.1341.1",
|
|
54
|
+
"@tamagui/fake-react-native": "3.0.0-beta.1341.1",
|
|
55
|
+
"@tamagui/generate-themes": "3.0.0-beta.1341.1",
|
|
56
|
+
"@tamagui/helpers": "3.0.0-beta.1341.1",
|
|
57
|
+
"@tamagui/helpers-node": "3.0.0-beta.1341.1",
|
|
58
|
+
"@tamagui/react-native-web-internals": "3.0.0-beta.1341.1",
|
|
59
|
+
"@tamagui/react-native-web-lite": "3.0.0-beta.1341.1",
|
|
60
|
+
"@tamagui/shorthands": "3.0.0-beta.1341.1",
|
|
61
|
+
"@tamagui/style-grammar": "3.0.0-beta.1341.1",
|
|
62
|
+
"@tamagui/types": "3.0.0-beta.1341.1",
|
|
63
|
+
"@tamagui/web": "3.0.0-beta.1341.1",
|
|
64
64
|
"browserslist": "^4.28.1",
|
|
65
65
|
"check-dependency-version-consistency": "^4.1.0",
|
|
66
66
|
"esbuild": "0.28.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"react-native-web": "~0.21.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@tamagui/build": "3.0.0-beta.
|
|
76
|
+
"@tamagui/build": "3.0.0-beta.1341.1",
|
|
77
77
|
"@types/find-root": "^1.1.2",
|
|
78
78
|
"@types/node": "^22.1.0",
|
|
79
79
|
"@types/webpack": "^4.41.26",
|
package/src/compilerHost.ts
CHANGED
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
} from '@tamagui/helpers'
|
|
28
28
|
import {
|
|
29
29
|
ATTRIBUTES,
|
|
30
|
-
DISPLAY_WEB_RESET,
|
|
31
30
|
EVENTS,
|
|
32
31
|
NATIVE_BACKING,
|
|
33
32
|
NATIVE_BLOCK_DEFAULTS,
|
|
@@ -699,6 +698,61 @@ function isSerializableNativeStyle(value: unknown): boolean {
|
|
|
699
698
|
return Object.values(value).every(isSerializableNativeStyle)
|
|
700
699
|
}
|
|
701
700
|
|
|
701
|
+
/**
|
|
702
|
+
* native host styles contain only completed pixel metrics. this compact record
|
|
703
|
+
* retains the authored text metric long enough for a DOM primitive or runtime
|
|
704
|
+
* Text descendant to apply it against its effective font size.
|
|
705
|
+
*/
|
|
706
|
+
type NativeTextMetrics = {
|
|
707
|
+
fontSize?: number
|
|
708
|
+
lineHeight?: number | `${number}px` | 'normal'
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function nativeTextMetrics(result: unknown): NativeTextMetrics | null {
|
|
712
|
+
const value = (result as { nativeTextMetrics?: unknown } | null)?.nativeTextMetrics
|
|
713
|
+
if (!staticObject(value)) return null
|
|
714
|
+
const { fontSize, lineHeight } = value
|
|
715
|
+
if (
|
|
716
|
+
(fontSize !== undefined && typeof fontSize !== 'number') ||
|
|
717
|
+
(lineHeight !== undefined &&
|
|
718
|
+
typeof lineHeight !== 'number' &&
|
|
719
|
+
typeof lineHeight !== 'string')
|
|
720
|
+
) {
|
|
721
|
+
return null
|
|
722
|
+
}
|
|
723
|
+
return fontSize === undefined && lineHeight === undefined
|
|
724
|
+
? null
|
|
725
|
+
: (value as NativeTextMetrics)
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function mergeNativeTextMetrics(
|
|
729
|
+
current: NativeTextMetrics | null,
|
|
730
|
+
next: NativeTextMetrics | null
|
|
731
|
+
): NativeTextMetrics | null {
|
|
732
|
+
if (!current) return next
|
|
733
|
+
if (!next) return current
|
|
734
|
+
return {
|
|
735
|
+
fontSize: next.fontSize ?? current.fontSize,
|
|
736
|
+
lineHeight: next.lineHeight ?? current.lineHeight,
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
function hasChildThatMayRenderReactNode(element: MaterializedElement): boolean {
|
|
741
|
+
return element.entries.some((entry) => {
|
|
742
|
+
if (entry.kind !== 'child' || entry.value.kind === 'empty') return false
|
|
743
|
+
if (entry.value.kind === 'element') return true
|
|
744
|
+
if (entry.value.kind === 'bailout') return entry.value.dynamic === null
|
|
745
|
+
if (entry.value.kind === 'conditional') {
|
|
746
|
+
return collectLeaves(entry.value.tree).some(
|
|
747
|
+
({ value }) =>
|
|
748
|
+
value === undefined || (value !== null && typeof value === 'object')
|
|
749
|
+
)
|
|
750
|
+
}
|
|
751
|
+
if (entry.value.kind !== 'static') return true
|
|
752
|
+
return entry.value.value !== null && typeof entry.value.value === 'object'
|
|
753
|
+
})
|
|
754
|
+
}
|
|
755
|
+
|
|
702
756
|
function unusedIdentifier(source: string, base: string): string {
|
|
703
757
|
let candidate = base
|
|
704
758
|
let suffix = 0
|
|
@@ -1037,6 +1091,7 @@ export function createTamaguiCompilerHost(
|
|
|
1037
1091
|
!options.tamaguiConfig.animationDrivers
|
|
1038
1092
|
? configuredAnimationDriver
|
|
1039
1093
|
: null
|
|
1094
|
+
const nativeTextMetricsByElement = new WeakMap<MaterializedElement, NativeTextMetrics>()
|
|
1040
1095
|
const resolveStaticCssTransition = (
|
|
1041
1096
|
value: unknown,
|
|
1042
1097
|
transitionPresets: Record<string, unknown>
|
|
@@ -1148,10 +1203,13 @@ export function createTamaguiCompilerHost(
|
|
|
1148
1203
|
| StaticConfig
|
|
1149
1204
|
| undefined
|
|
1150
1205
|
if (!base) return null
|
|
1206
|
+
// Web keeps only the semantic defaults as atomic defaults. Undoing the
|
|
1207
|
+
// browser stylesheet is the `:where(.is_DOM)` host reset, and the
|
|
1208
|
+
// extracted className below keeps the runtime base so compiled hosts
|
|
1209
|
+
// carry `is_DOM` for it to match.
|
|
1151
1210
|
const platformDefaults =
|
|
1152
1211
|
platform === 'web'
|
|
1153
1212
|
? {
|
|
1154
|
-
...DISPLAY_WEB_RESET[row.display],
|
|
1155
1213
|
...row.defaults,
|
|
1156
1214
|
...TAG_WEB_DEFAULTS[tag],
|
|
1157
1215
|
}
|
|
@@ -1167,6 +1225,7 @@ export function createTamaguiCompilerHost(
|
|
|
1167
1225
|
displayName: tag,
|
|
1168
1226
|
staticConfig: normalizeStaticConfig({
|
|
1169
1227
|
...base,
|
|
1228
|
+
isDOM: true,
|
|
1170
1229
|
isInput: row.backing === 'textinput',
|
|
1171
1230
|
// CSS text properties may be authored on any element and inherited by
|
|
1172
1231
|
// descendant text, including from a View-backed tag on native.
|
|
@@ -2445,6 +2504,52 @@ export function createTamaguiCompilerHost(
|
|
|
2445
2504
|
'getSplitStyles returned no static result'
|
|
2446
2505
|
)
|
|
2447
2506
|
}
|
|
2507
|
+
const nativeMetrics = platform === 'native' ? nativeTextMetrics(split) : null
|
|
2508
|
+
if (nativeMetrics) nativeTextMetricsByElement.set(input.element, nativeMetrics)
|
|
2509
|
+
const hasDynamicFontSize = dynamicStyleEntries.some((entry) => {
|
|
2510
|
+
const name = directStyleName(entry.name, component)
|
|
2511
|
+
return name === 'fontFamily' || name === 'fontSize'
|
|
2512
|
+
})
|
|
2513
|
+
const hasUnresolvedNativeLineHeight =
|
|
2514
|
+
typeof nativeMetrics?.lineHeight === 'number' &&
|
|
2515
|
+
nativeMetrics.fontSize === undefined &&
|
|
2516
|
+
!hasDynamicFontSize
|
|
2517
|
+
const hasDynamicTextMetric = dynamicStyleEntries.some((entry) => {
|
|
2518
|
+
const name = directStyleName(entry.name, component)
|
|
2519
|
+
return (
|
|
2520
|
+
name === 'fontFamily' ||
|
|
2521
|
+
name === 'fontSize' ||
|
|
2522
|
+
name === 'lineHeight' ||
|
|
2523
|
+
(name === null && !!component.staticConfig.variants?.[entry.name])
|
|
2524
|
+
)
|
|
2525
|
+
})
|
|
2526
|
+
const changesInheritedNativeFontSize =
|
|
2527
|
+
nativeMetrics?.fontSize !== undefined && nativeMetrics.lineHeight === undefined
|
|
2528
|
+
// flattened core Text goes straight to react-native Text, which cannot
|
|
2529
|
+
// carry this semantic record to a runtime child. the component path
|
|
2530
|
+
// completes it once through the shared metric context.
|
|
2531
|
+
if (
|
|
2532
|
+
platform === 'native' &&
|
|
2533
|
+
component.staticConfig.isText &&
|
|
2534
|
+
!component.domTag &&
|
|
2535
|
+
(hasUnresolvedNativeLineHeight ||
|
|
2536
|
+
changesInheritedNativeFontSize ||
|
|
2537
|
+
(hasChildThatMayRenderReactNode(input.element) &&
|
|
2538
|
+
(nativeMetrics !== null || hasDynamicTextMetric)) ||
|
|
2539
|
+
input.module.elements.some(
|
|
2540
|
+
(ancestor) =>
|
|
2541
|
+
ancestor !== input.element &&
|
|
2542
|
+
ancestor.span.start < input.element.span.start &&
|
|
2543
|
+
ancestor.span.end > input.element.span.end &&
|
|
2544
|
+
nativeTextMetricsByElement.has(ancestor)
|
|
2545
|
+
))
|
|
2546
|
+
) {
|
|
2547
|
+
return bailout(
|
|
2548
|
+
input,
|
|
2549
|
+
'local/unsupported-target',
|
|
2550
|
+
'Native text metrics need the runtime Text provider for this subtree'
|
|
2551
|
+
)
|
|
2552
|
+
}
|
|
2448
2553
|
if (
|
|
2449
2554
|
split.programLifecycleStyleKeys?.enter?.size ||
|
|
2450
2555
|
split.programLifecycleStyleKeys?.exit?.size
|
|
@@ -2686,6 +2791,7 @@ export function createTamaguiCompilerHost(
|
|
|
2686
2791
|
}
|
|
2687
2792
|
styleEntries = [...new Set([...styleEntries, ...propsResult.consumed])]
|
|
2688
2793
|
let nativeDOMStyleSource = nativeStyleSource
|
|
2794
|
+
let nativeDOMMetrics = nativeMetrics
|
|
2689
2795
|
let runtimeStyleSource: string | null = null
|
|
2690
2796
|
if (
|
|
2691
2797
|
domStyleProgram?.kind === 'prop' &&
|
|
@@ -2749,6 +2855,10 @@ export function createTamaguiCompilerHost(
|
|
|
2749
2855
|
item.value.span
|
|
2750
2856
|
)
|
|
2751
2857
|
}
|
|
2858
|
+
nativeDOMMetrics = mergeNativeTextMetrics(
|
|
2859
|
+
nativeDOMMetrics,
|
|
2860
|
+
nativeTextMetrics(itemSplit)
|
|
2861
|
+
)
|
|
2752
2862
|
value = JSON.stringify(itemStyle ?? {})
|
|
2753
2863
|
}
|
|
2754
2864
|
const condition = item.condition
|
|
@@ -2773,6 +2883,11 @@ export function createTamaguiCompilerHost(
|
|
|
2773
2883
|
? `__styles={${runtimeStyleSource}}`
|
|
2774
2884
|
: `__styles: ${runtimeStyleSource}`
|
|
2775
2885
|
: '',
|
|
2886
|
+
nativeDOMMetrics
|
|
2887
|
+
? serializedProps(input.element.form, [
|
|
2888
|
+
['__textMetrics', JSON.stringify(nativeDOMMetrics)],
|
|
2889
|
+
])
|
|
2890
|
+
: '',
|
|
2776
2891
|
serializedProps(input.element.form, propsResult.additions),
|
|
2777
2892
|
]
|
|
2778
2893
|
.filter(Boolean)
|
|
@@ -3316,7 +3431,7 @@ export function createTamaguiCompilerHost(
|
|
|
3316
3431
|
split,
|
|
3317
3432
|
props,
|
|
3318
3433
|
options.tamaguiConfig,
|
|
3319
|
-
|
|
3434
|
+
true,
|
|
3320
3435
|
Boolean(component.staticConfig.styleFrontend)
|
|
3321
3436
|
)
|
|
3322
3437
|
const className = artifacts.className
|
|
@@ -3518,7 +3633,7 @@ export function createTamaguiCompilerHost(
|
|
|
3518
3633
|
branchSplit,
|
|
3519
3634
|
branchProps,
|
|
3520
3635
|
options.tamaguiConfig,
|
|
3521
|
-
|
|
3636
|
+
true,
|
|
3522
3637
|
Boolean(component.staticConfig.styleFrontend)
|
|
3523
3638
|
)
|
|
3524
3639
|
leafArtifactsMap.set(leaf, {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild'
|
|
2
|
-
import fs from 'node:fs'
|
|
3
|
-
import path from 'node:path'
|
|
4
2
|
import {
|
|
5
3
|
createPathsMatcher,
|
|
6
4
|
getTsconfig,
|
|
@@ -8,10 +6,13 @@ import {
|
|
|
8
6
|
type TsConfigJsonResolved,
|
|
9
7
|
type TsConfigResult,
|
|
10
8
|
} from 'get-tsconfig'
|
|
9
|
+
import fs from 'node:fs'
|
|
10
|
+
import path from 'node:path'
|
|
11
11
|
|
|
12
12
|
const name = 'tsconfig-paths'
|
|
13
13
|
|
|
14
14
|
type Tsconfig = Pick<TsConfigJsonResolved, 'compilerOptions'>
|
|
15
|
+
type TsconfigPathMatcher = (specifier: string) => string[]
|
|
15
16
|
|
|
16
17
|
function loadTsconfig(
|
|
17
18
|
tsconfig?: Tsconfig | string,
|
|
@@ -43,37 +44,81 @@ export function createTsconfigPathsMatcher(
|
|
|
43
44
|
return loaded ? createPathsMatcher(loaded) : null
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
export function loadTsconfigPathMatcher(
|
|
48
|
+
tsconfig?: TsConfigJsonResolved | string
|
|
49
|
+
): TsconfigPathMatcher {
|
|
50
|
+
let result: TsConfigResult | null
|
|
51
|
+
if (!tsconfig) {
|
|
52
|
+
result = getTsconfig(process.cwd()) || getTsconfig(process.cwd(), 'jsconfig.json')
|
|
53
|
+
} else if (typeof tsconfig === 'string') {
|
|
54
|
+
if (fs.existsSync(tsconfig)) {
|
|
55
|
+
const configPath = path.resolve(tsconfig)
|
|
56
|
+
result = { config: parseTsconfig(configPath), path: configPath }
|
|
57
|
+
} else {
|
|
58
|
+
throw new Error(`Specified tsconfig file not found: ${tsconfig}`)
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
result = { config: tsconfig, path: path.join(process.cwd(), 'tsconfig.json') }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!result) return () => []
|
|
65
|
+
const matchPaths = createPathsMatcher(result)
|
|
66
|
+
const patterns = Object.keys(result.config.compilerOptions?.paths || {})
|
|
67
|
+
if (!matchPaths || patterns.length === 0) return () => []
|
|
68
|
+
|
|
69
|
+
return (specifier) => {
|
|
70
|
+
const matchesExplicitPath = patterns.some((pattern) => {
|
|
71
|
+
const wildcardIndex = pattern.indexOf('*')
|
|
72
|
+
if (wildcardIndex === -1) return pattern === specifier
|
|
73
|
+
return (
|
|
74
|
+
specifier.startsWith(pattern.slice(0, wildcardIndex)) &&
|
|
75
|
+
specifier.endsWith(pattern.slice(wildcardIndex + 1))
|
|
76
|
+
)
|
|
77
|
+
})
|
|
78
|
+
return matchesExplicitPath ? matchPaths(specifier) : []
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
46
82
|
export function TsconfigPathsPlugin(): Plugin {
|
|
47
|
-
const
|
|
83
|
+
const matchTsconfigPath = loadTsconfigPathMatcher()
|
|
48
84
|
|
|
49
85
|
return {
|
|
50
86
|
name,
|
|
51
87
|
setup(build) {
|
|
52
88
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
89
|
+
const pluginData = args.pluginData as
|
|
90
|
+
| { tamaguiTsconfigPaths?: boolean; tamaguiTsconfigPathsResolved?: boolean }
|
|
91
|
+
| undefined
|
|
53
92
|
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(args.pluginData as { tamaguiTsconfigPaths?: boolean } | undefined)
|
|
57
|
-
?.tamaguiTsconfigPaths
|
|
93
|
+
pluginData?.tamaguiTsconfigPaths ||
|
|
94
|
+
pluginData?.tamaguiTsconfigPathsResolved
|
|
58
95
|
) {
|
|
59
96
|
return null
|
|
60
97
|
}
|
|
61
98
|
|
|
62
|
-
|
|
99
|
+
// skip @tamagui packages - they should be externalized, not resolved via tsconfig
|
|
100
|
+
if (args.path.startsWith('@tamagui/')) {
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
for (const candidate of matchTsconfigPath(args.path)) {
|
|
63
105
|
const resolved = await build.resolve(candidate, {
|
|
64
106
|
importer: args.importer,
|
|
65
107
|
kind: args.kind,
|
|
66
108
|
namespace: args.namespace,
|
|
67
|
-
resolveDir: args.resolveDir,
|
|
68
109
|
pluginData: {
|
|
69
|
-
...(args.pluginData
|
|
110
|
+
...(args.pluginData && typeof args.pluginData === 'object'
|
|
111
|
+
? args.pluginData
|
|
112
|
+
: {}),
|
|
70
113
|
tamaguiTsconfigPaths: true,
|
|
114
|
+
tamaguiTsconfigPathsResolved: true,
|
|
71
115
|
},
|
|
116
|
+
resolveDir: args.resolveDir,
|
|
72
117
|
})
|
|
73
118
|
if (
|
|
74
|
-
resolved.errors.length === 0 &&
|
|
75
119
|
resolved.path &&
|
|
76
|
-
!resolved.path.endsWith('.d.ts')
|
|
120
|
+
!resolved.path.endsWith('.d.ts') &&
|
|
121
|
+
resolved.errors.length === 0
|
|
77
122
|
) {
|
|
78
123
|
return resolved
|
|
79
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilerHost.d.ts","sourceRoot":"","sources":["../src/compilerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,cAAc,EAQf,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"compilerHost.d.ts","sourceRoot":"","sources":["../src/compilerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,cAAc,EAQf,MAAM,wBAAwB,CAAA;AAoC/B,OAAO,KAAK,EAAiC,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAExF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAIhE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;CAClD;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,gBAAgB,EAAE,EACvC,gBAAgB,EAAE,SAAS,uBAAuB,EAAE,GACnD,yBAAyB,CAS3B;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,cAAc,CAAA;IACtB,aAAa,EAAE,qBAAqB,CAAA;IACpC,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,gBAAgB,EAAE,uBAAuB,EAAE,CAAA;IAC3C,qFAAqF;IACrF,QAAQ,CAAC,EAAE,yBAAyB,CAAA;IACpC,wEAAwE;IACxE,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,mEAAmE;IACnE,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAu5BD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,oBAAoB,CAqvFtB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild';
|
|
2
2
|
import { type TsConfigJsonResolved } from 'get-tsconfig';
|
|
3
3
|
type Tsconfig = Pick<TsConfigJsonResolved, 'compilerOptions'>;
|
|
4
|
+
type TsconfigPathMatcher = (specifier: string) => string[];
|
|
4
5
|
export declare function createTsconfigPathsMatcher(tsconfig?: Tsconfig | string, cwd?: string): ((specifier: string) => string[]) | null;
|
|
6
|
+
export declare function loadTsconfigPathMatcher(tsconfig?: TsConfigJsonResolved | string): TsconfigPathMatcher;
|
|
5
7
|
export declare function TsconfigPathsPlugin(): Plugin;
|
|
6
8
|
export {};
|
|
7
9
|
//# sourceMappingURL=esbuildTsconfigPaths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuildTsconfigPaths.d.ts","sourceRoot":"","sources":["../../src/extractor/esbuildTsconfigPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"esbuildTsconfigPaths.d.ts","sourceRoot":"","sources":["../../src/extractor/esbuildTsconfigPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAIL,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAA;AAMrB,KAAK,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAA;AAC7D,KAAK,mBAAmB,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;AAwB1D,wBAAgB,0BAA0B,CACxC,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,EAC5B,GAAG,SAAgB,GAClB,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,GAAG,IAAI,CAG1C;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,MAAM,GACvC,mBAAmB,CA+BrB;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAiD5C"}
|
package/types/zero/identity.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { TamaguiRuntimeLiteral } from './options';
|
|
|
3
3
|
* Bumped whenever the zero transform's emitted output changes shape. It rides
|
|
4
4
|
* the lowering plan version so a compiler change also invalidates zero caches.
|
|
5
5
|
*/
|
|
6
|
-
export declare const ZERO_COMPILER_VERSION = "zero-1/plan-
|
|
6
|
+
export declare const ZERO_COMPILER_VERSION = "zero-1/plan-5";
|
|
7
7
|
/**
|
|
8
8
|
* Every integration records this tuple in its cache and build identity. The CSS
|
|
9
9
|
* path alone is insufficient because the artifact's content can change in place.
|