@tamagui/static 3.0.0-beta.831.1 → 3.0.0-beta.889.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/compiler.cjs +17 -5
- package/dist/cjs/compilerHost.cjs +148 -39
- package/dist/cjs/componentDiscovery.cjs +94 -0
- package/dist/cjs/domStructuralPass.cjs +12 -2
- package/dist/cjs/exports.cjs +4 -1
- package/dist/cjs/extractor/bundleConfig.cjs +23 -0
- package/dist/cjs/zero/theme.cjs +5 -20
- package/dist/esm/compiler.mjs +18 -6
- package/dist/esm/compiler.mjs.map +1 -1
- package/dist/esm/compilerHost.mjs +146 -40
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/componentDiscovery.mjs +69 -0
- package/dist/esm/componentDiscovery.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +12 -2
- package/dist/esm/domStructuralPass.mjs.map +1 -1
- package/dist/esm/exports.mjs +4 -1
- package/dist/esm/extractor/bundleConfig.mjs +23 -1
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -1
- package/dist/esm/zero/theme.mjs +5 -20
- package/dist/esm/zero/theme.mjs.map +1 -1
- package/package.json +17 -17
- package/src/compiler.ts +27 -5
- package/src/compilerHost.ts +262 -74
- package/src/componentDiscovery.ts +105 -0
- package/src/domStructuralPass.ts +22 -2
- package/src/exports.ts +2 -0
- package/src/extractor/bundleConfig.ts +34 -0
- package/src/zero/theme.ts +12 -21
- package/types/compiler.d.ts +13 -0
- package/types/compiler.d.ts.map +1 -1
- package/types/compilerHost.d.ts +13 -0
- package/types/compilerHost.d.ts.map +1 -1
- package/types/componentDiscovery.d.ts +27 -0
- package/types/componentDiscovery.d.ts.map +1 -0
- package/types/domStructuralPass.d.ts.map +1 -1
- package/types/exports.d.ts +2 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +7 -0
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/zero/theme.d.ts +0 -1
- package/types/zero/theme.d.ts.map +1 -1
package/dist/cjs/zero/theme.cjs
CHANGED
|
@@ -31,11 +31,7 @@ var import_helpers = require("@tamagui/helpers");
|
|
|
31
31
|
var import_web = require("@tamagui/web");
|
|
32
32
|
var import_theme_update = require("@tamagui/web/theme-update");
|
|
33
33
|
const MAX_THEME_BRANCHES = 8;
|
|
34
|
-
const LOWERABLE_RESERVED_PROPS = /* @__PURE__ */ new Set([
|
|
35
|
-
"name",
|
|
36
|
-
"reset",
|
|
37
|
-
"contain"
|
|
38
|
-
]);
|
|
34
|
+
const LOWERABLE_RESERVED_PROPS = /* @__PURE__ */ new Set(["name", "contain"]);
|
|
39
35
|
function jsxAttributeName(attribute) {
|
|
40
36
|
const name = (0, import_compiler_core.childNode)(attribute, "name");
|
|
41
37
|
return name && typeof name.name === "string" ? name.name : null;
|
|
@@ -98,7 +94,7 @@ function resolveThemeChain(chain, rootThemeName, config) {
|
|
|
98
94
|
const next = [];
|
|
99
95
|
for (const parent of branches) {
|
|
100
96
|
for (const option of node.options) {
|
|
101
|
-
const resolved = (0, import_web.resolveThemeName)(parent.name, option.name,
|
|
97
|
+
const resolved = (0, import_web.resolveThemeName)(parent.name, option.name, config.themes);
|
|
102
98
|
const tests = [parent.test, option.test].filter(Boolean);
|
|
103
99
|
next.push({
|
|
104
100
|
test: tests.length ? tests.join(" && ") : null,
|
|
@@ -126,7 +122,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
126
122
|
test: null,
|
|
127
123
|
name: void 0
|
|
128
124
|
}];
|
|
129
|
-
let reset = false;
|
|
130
125
|
let contain = false;
|
|
131
126
|
const themeKeyProps = {};
|
|
132
127
|
for (const attribute of (0, import_compiler_core.childNodes)(opening, "attributes")) {
|
|
@@ -191,7 +186,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
191
186
|
});
|
|
192
187
|
continue;
|
|
193
188
|
}
|
|
194
|
-
if (key === "reset") reset = literal2;
|
|
195
189
|
if (key === "contain") contain = literal2;
|
|
196
190
|
continue;
|
|
197
191
|
}
|
|
@@ -222,15 +216,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
222
216
|
}
|
|
223
217
|
themeKeyProps[key] = literal;
|
|
224
218
|
}
|
|
225
|
-
if (kind === "Theme" && reset && options.some((option) => option.name !== void 0)) {
|
|
226
|
-
violations.push({
|
|
227
|
-
rule: 4,
|
|
228
|
-
code: "local/unsupported-target",
|
|
229
|
-
span: span(opening),
|
|
230
|
-
component: "Theme",
|
|
231
|
-
message: (0, import_compiler_core.zeroRuleMessage)(4, { detail: "a <Theme> with both name and reset, which cannot mean one theme," })
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
219
|
if (!closing) {
|
|
235
220
|
violations.push({
|
|
236
221
|
rule: 4,
|
|
@@ -241,7 +226,8 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
241
226
|
});
|
|
242
227
|
}
|
|
243
228
|
const issues = [];
|
|
244
|
-
const
|
|
229
|
+
const themeUpdateConfig = config;
|
|
230
|
+
const inlineValues = kind === "ThemeUpdate" && Object.keys(themeKeyProps).length ? (0, import_theme_update.getInlineValuesFromProps)(themeKeyProps, themeUpdateConfig, (issue) => issues.push(issue)) : null;
|
|
245
231
|
for (const issue of issues) {
|
|
246
232
|
violations.push({
|
|
247
233
|
rule: 3,
|
|
@@ -255,7 +241,7 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
255
241
|
})
|
|
256
242
|
});
|
|
257
243
|
}
|
|
258
|
-
const inlineCSS = inlineValues ? (0, import_theme_update.getVariablesCSSRules)(inlineValues,
|
|
244
|
+
const inlineCSS = inlineValues ? (0, import_theme_update.getVariablesCSSRules)(inlineValues, themeUpdateConfig) : null;
|
|
259
245
|
if (inlineCSS) css.set(inlineCSS.identifier, inlineCSS.rules.join(""));
|
|
260
246
|
if (violations.length) return {
|
|
261
247
|
node: null,
|
|
@@ -269,7 +255,6 @@ function readStaticTheme(element, id, source, config, kind = "Theme") {
|
|
|
269
255
|
opening,
|
|
270
256
|
closing,
|
|
271
257
|
options,
|
|
272
|
-
reset,
|
|
273
258
|
contain,
|
|
274
259
|
layer: inlineValues && inlineCSS ? {
|
|
275
260
|
inlineValues,
|
package/dist/esm/compiler.mjs
CHANGED
|
@@ -2,7 +2,8 @@ import { CompilerSession, LOWERED_MODULE_PLAN_VERSION, ModulePlanCache, PLAN_CAC
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { ComponentDiscovery } from "./componentDiscovery.mjs";
|
|
6
|
+
import { createComponentRegistry, createTamaguiCompilerHost } from "./compilerHost.mjs";
|
|
6
7
|
import { domStructuralPass } from "./domStructuralPass.mjs";
|
|
7
8
|
import { loadTamagui } from "./extractor/loadTamagui.mjs";
|
|
8
9
|
import { resolveZeroRuntimeSync } from "./zero/options.mjs";
|
|
@@ -90,6 +91,7 @@ var CompilerFrontend = class {
|
|
|
90
91
|
planCaches = /* @__PURE__ */ new Map();
|
|
91
92
|
moduleRecords = /* @__PURE__ */ new Map();
|
|
92
93
|
moduleContext = null;
|
|
94
|
+
discovery = new ComponentDiscovery();
|
|
93
95
|
/**
|
|
94
96
|
* One cache per project root and platform. Absent when the project produced
|
|
95
97
|
* no content stamp, in which case plans are never persisted rather than
|
|
@@ -183,14 +185,18 @@ var CompilerFrontend = class {
|
|
|
183
185
|
if (!projectInfo.tamaguiConfig || !projectInfo.components) {
|
|
184
186
|
throw new Error("The compiler requires evaluated Tamagui config and components");
|
|
185
187
|
}
|
|
188
|
+
const componentModules = input.project.componentModules.map((component) => ({
|
|
189
|
+
moduleName: component.moduleName,
|
|
190
|
+
resolvedId: cleanId(component.id)
|
|
191
|
+
}));
|
|
192
|
+
const registry = createComponentRegistry(projectInfo.components, componentModules);
|
|
193
|
+
this.discovery.seed(registry);
|
|
186
194
|
const host = createTamaguiCompilerHost({
|
|
187
195
|
target: input.target,
|
|
188
196
|
tamaguiConfig: projectInfo.tamaguiConfig,
|
|
189
197
|
components: projectInfo.components,
|
|
190
|
-
componentModules
|
|
191
|
-
|
|
192
|
-
resolvedId: cleanId(component.id)
|
|
193
|
-
})),
|
|
198
|
+
componentModules,
|
|
199
|
+
registry,
|
|
194
200
|
disablePartialExtraction: input.project.disablePartialExtraction,
|
|
195
201
|
experimentalNativeFastPath: input.project.experimentalNativeFastPath,
|
|
196
202
|
zeroRuntime: input.project.zeroRuntime
|
|
@@ -204,7 +210,8 @@ var CompilerFrontend = class {
|
|
|
204
210
|
planCache: this.planCacheFor(input),
|
|
205
211
|
async load(id) {
|
|
206
212
|
return modules.get(id) ?? null;
|
|
207
|
-
}
|
|
213
|
+
},
|
|
214
|
+
prepare: (module) => this.discovery.prepare(module, registry, input.evaluate)
|
|
208
215
|
},
|
|
209
216
|
structuralPass: domStructuralPass
|
|
210
217
|
});
|
|
@@ -215,10 +222,15 @@ var CompilerFrontend = class {
|
|
|
215
222
|
invalidatedIds: [...invalidated].sort()
|
|
216
223
|
};
|
|
217
224
|
}
|
|
225
|
+
/** host-resolved ids of every module discovery found components in */
|
|
226
|
+
discoveredModuleIds() {
|
|
227
|
+
return this.discovery.ids();
|
|
228
|
+
}
|
|
218
229
|
async buildTree(input) {
|
|
219
230
|
const moduleContext = compilerContext(input);
|
|
220
231
|
if (this.moduleContext !== moduleContext) {
|
|
221
232
|
this.moduleRecords.clear();
|
|
233
|
+
this.discovery.clear();
|
|
222
234
|
this.moduleContext = moduleContext;
|
|
223
235
|
}
|
|
224
236
|
const componentBySpecifier = new Map(input.project.componentModules.map((component) => [component.moduleName, resolvedModuleId(cleanId(component.id))]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","names":[],"sources":["esm/compiler.js"],"sourcesContent":["import {\n CompilerSession,\n LOWERED_MODULE_PLAN_VERSION,\n ModulePlanCache,\n PLAN_CACHE_SCHEMA_VERSION,\n contentHash,\n defaultPlanCacheRoot,\n resolvedModuleId,\n stableStringify,\n yukuFactory\n} from \"@tamagui/compiler-core\";\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { createTamaguiCompilerHost } from \"./compilerHost\";\nimport { domStructuralPass } from \"./domStructuralPass\";\nimport { loadTamagui } from \"./extractor/loadTamagui\";\nimport { resolveZeroRuntimeSync } from \"./zero/options\";\nasync function loadCompilerProject({\n root,\n target,\n options: optionsIn,\n generation,\n rebuild = false,\n hostVersions = [],\n missingProjectMessage = \"Unable to load the Tamagui compiler project\",\n load = loadTamagui,\n resolveComponents\n}) {\n const components = [\n .../* @__PURE__ */ new Set([\"@tamagui/core\", ...optionsIn.components || [\"tamagui\"]])\n ];\n const options = {\n ...optionsIn,\n root,\n platform: target,\n components\n };\n const zeroRuntime = resolveZeroRuntimeSync(options, root).mode;\n if (zeroRuntime === \"enforce\") options.outputCSS = void 0;\n const projectInfo = await load(options, rebuild);\n if (!projectInfo?.tamaguiConfig || !projectInfo.components) {\n throw new Error(missingProjectMessage);\n }\n const componentModules = resolveComponents ? await resolveComponents(components, projectInfo, options) : [];\n const disablePartialExtraction = !!options.disablePartialExtraction;\n const experimentalNativeFastPath = target === \"native\" && options.experimental?.nativeFastPath === true;\n return {\n projectInfo,\n componentModules,\n generation: typeof generation === \"function\" ? generation(projectInfo, componentModules, options) : generation,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n cacheStamp: compilerProjectStamp({\n stampSources: projectInfo.stampSources ?? [],\n hostVersions,\n target,\n componentModules,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n development: process.env.NODE_ENV === \"development\"\n })\n };\n}\nconst requireFromCompiler = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst compilerPackageVersions = [\"@tamagui/compiler-core\", \"@tamagui/static\"].map(\n (name) => `${name}@${requireFromCompiler(`${name}/package.json`).version}`\n);\nfunction compilerProjectStamp(input) {\n if (!input.stampSources.length) return null;\n const sources = [];\n for (const file of [...new Set(input.stampSources)].sort()) {\n try {\n sources.push([file, contentHash(readFileSync(file))]);\n } catch {\n return null;\n }\n }\n return contentHash(\n stableStringify({\n schema: PLAN_CACHE_SCHEMA_VERSION,\n plan: LOWERED_MODULE_PLAN_VERSION,\n packages: [...compilerPackageVersions, ...input.hostVersions].sort(),\n target: input.target,\n development: input.development,\n componentModules: input.componentModules.map(({ moduleName, id }) => [\n moduleName,\n cleanId(id)\n ]),\n disablePartialExtraction: input.disablePartialExtraction,\n experimentalNativeFastPath: input.experimentalNativeFastPath,\n zeroRuntime: input.zeroRuntime,\n sources\n })\n );\n}\nfunction cleanId(id) {\n return id.split(/[?#]/, 1)[0];\n}\nfunction externalId(specifier) {\n return resolvedModuleId(`external://${encodeURIComponent(specifier)}`);\n}\nfunction compilerContext(input) {\n return `${input.root}\\0${input.target}\\0${input.environment ?? \"\"}\\0${input.project.generation}`;\n}\nfunction sourceCanBeLinked(root, id) {\n const clean = cleanId(id);\n const normalized = clean.replace(/\\\\/g, \"/\");\n if (!path.isAbsolute(clean) || normalized.includes(\"/node_modules/\")) return false;\n const relative = path.relative(root, clean);\n return relative === \"\" || relative !== \"..\" && !relative.startsWith(`..${path.sep}`);\n}\nclass CompilerFrontend {\n session = new CompilerSession();\n queue = Promise.resolve();\n planCaches = /* @__PURE__ */ new Map();\n moduleRecords = /* @__PURE__ */ new Map();\n moduleContext = null;\n /**\n * One cache per project root and platform. Absent when the project produced\n * no content stamp, in which case plans are never persisted rather than\n * persisted under an identity that cannot see a config change.\n */\n planCacheFor(input) {\n const stamp = input.project.cacheStamp;\n if (!stamp) return void 0;\n const root = defaultPlanCacheRoot(input.root, input.target);\n let store = this.planCaches.get(root);\n if (!store) {\n store = new ModulePlanCache(root);\n this.planCaches.set(root, store);\n }\n return { store, stamp };\n }\n /** Hits, misses and writes across every plan cache this frontend has used. */\n get planCacheStats() {\n const total = { hits: 0, misses: 0, writes: 0 };\n for (const store of this.planCaches.values()) {\n total.hits += store.stats.hits;\n total.misses += store.stats.misses;\n total.writes += store.stats.writes;\n }\n return total;\n }\n compile(input) {\n const operation = this.queue.then(async () => {\n const previousTarget = process.env.TAMAGUI_TARGET;\n const previousStatic = process.env.IS_STATIC;\n try {\n return await this.compileNow(input);\n } finally {\n if (previousTarget === void 0) delete process.env.TAMAGUI_TARGET;\n else process.env.TAMAGUI_TARGET = previousTarget;\n if (previousStatic === void 0) delete process.env.IS_STATIC;\n else process.env.IS_STATIC = previousStatic;\n }\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n update(input) {\n const operation = this.queue.then(async () => {\n const { modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n return [...invalidated].sort();\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n has(id) {\n return this.session.has(resolvedModuleId(cleanId(id)));\n }\n dependentsOf(id) {\n return this.session.dependentsOf(resolvedModuleId(cleanId(id)));\n }\n remove(id) {\n const operation = this.queue.then(async () => {\n const result = await this.session.remove(resolvedModuleId(cleanId(id)));\n for (const invalidatedId of result.invalidatedIds) {\n this.moduleRecords.delete(invalidatedId);\n }\n return result;\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n parseCount(id) {\n return this.session.parseCount(resolvedModuleId(cleanId(id)));\n }\n async compileNow(input) {\n const { rootModule, modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n const projectInfo = input.project.projectInfo;\n if (!projectInfo.tamaguiConfig || !projectInfo.components) {\n throw new Error(\"The compiler requires evaluated Tamagui config and components\");\n }\n const host = createTamaguiCompilerHost({\n target: input.target,\n tamaguiConfig: projectInfo.tamaguiConfig,\n components: projectInfo.components,\n componentModules: input.project.componentModules.map((component) => ({\n moduleName: component.moduleName,\n resolvedId: cleanId(component.id)\n })),\n disablePartialExtraction: input.project.disablePartialExtraction,\n experimentalNativeFastPath: input.project.experimentalNativeFastPath,\n zeroRuntime: input.project.zeroRuntime\n });\n const result = await this.session.compile({\n module: rootModule,\n adapter: {\n target: input.target,\n projectGeneration: input.project.generation,\n host,\n planCache: this.planCacheFor(input),\n async load(id) {\n return modules.get(id) ?? null;\n }\n },\n structuralPass: domStructuralPass\n });\n for (const id of result.invalidatedIds) invalidated.add(id);\n return {\n plan: result.plan,\n output: result.output,\n invalidatedIds: [...invalidated].sort()\n };\n }\n async buildTree(input) {\n const moduleContext = compilerContext(input);\n if (this.moduleContext !== moduleContext) {\n this.moduleRecords.clear();\n this.moduleContext = moduleContext;\n }\n const componentBySpecifier = new Map(\n input.project.componentModules.map((component) => [\n component.moduleName,\n resolvedModuleId(cleanId(component.id))\n ])\n );\n const modules = /* @__PURE__ */ new Map();\n const loading = /* @__PURE__ */ new Set();\n const addInstalledClosure = (module) => {\n if (modules.has(module.id) || loading.has(module.id)) return;\n loading.add(module.id);\n for (const dependency of module.imports) {\n if (dependency.external) continue;\n const installedDependency = this.moduleRecords.get(dependency.resolvedId);\n if (installedDependency && this.session.has(dependency.resolvedId)) {\n addInstalledClosure(installedDependency);\n }\n }\n modules.set(module.id, module);\n loading.delete(module.id);\n };\n const loadModule = async (rawId, source) => {\n const id = resolvedModuleId(cleanId(rawId));\n const existing = modules.get(id);\n if (existing) return existing;\n const installed = this.moduleRecords.get(id);\n if (installed?.source === source && this.session.has(id)) {\n addInstalledClosure(installed);\n return installed;\n }\n if (loading.has(id)) {\n return { id, source, imports: [] };\n }\n loading.add(id);\n const imports = [];\n for (const specifier of yukuFactory.scanImports(id, source)) {\n const configuredComponent = componentBySpecifier.get(specifier);\n if (configuredComponent) {\n imports.push({ specifier, resolvedId: configuredComponent, external: true });\n continue;\n }\n const resolution = await input.resolve(specifier, id);\n if (!resolution) continue;\n const canLink = !resolution.external && sourceCanBeLinked(input.root, resolution.id);\n const resolvedId = canLink ? resolvedModuleId(cleanId(resolution.id)) : path.isAbsolute(cleanId(resolution.id)) ? resolvedModuleId(cleanId(resolution.id)) : externalId(specifier);\n imports.push({ specifier, resolvedId, external: !canLink });\n if (canLink && !modules.has(resolvedId) && !loading.has(resolvedId)) {\n const installedDependency = this.moduleRecords.get(resolvedId);\n if (installedDependency && this.session.has(resolvedId)) {\n addInstalledClosure(installedDependency);\n } else {\n const dependencySource = await input.load(resolution.id);\n if (dependencySource !== null) {\n await loadModule(resolution.id, dependencySource);\n }\n }\n }\n }\n const module = { id, source, imports };\n modules.set(id, module);\n loading.delete(id);\n return module;\n };\n const rootModule = await loadModule(input.id, input.source);\n return { rootModule, modules };\n }\n}\nexport {\n CompilerFrontend,\n compilerProjectStamp,\n loadCompilerProject\n};\n//# sourceMappingURL=compiler.js.map\n"],"mappings":";;;;;;;;;;AAkBA,eAAe,oBAAoB,EACjC,MACA,QACA,SAAS,WACT,YACA,UAAU,OACV,eAAe,CAAC,GAChB,wBAAwB,+CACxB,OAAO,aACP,qBACC;CACD,MAAM,aAAa,CACjB,mBAAmB,IAAI,IAAI,CAAC,iBAAiB,GAAG,UAAU,cAAc,CAAC,SAAS,CAAC,CAAC,CACtF;CACA,MAAM,UAAU;EACd,GAAG;EACH;EACA,UAAU;EACV;CACF;CACA,MAAM,cAAc,uBAAuB,SAAS,IAAI,CAAC,CAAC;CAC1D,IAAI,gBAAgB,WAAW,QAAQ,YAAY,KAAK;CACxD,MAAM,cAAc,MAAM,KAAK,SAAS,OAAO;CAC/C,IAAI,CAAC,aAAa,iBAAiB,CAAC,YAAY,YAAY;EAC1D,MAAM,IAAI,MAAM,qBAAqB;CACvC;CACA,MAAM,mBAAmB,oBAAoB,MAAM,kBAAkB,YAAY,aAAa,OAAO,IAAI,CAAC;CAC1G,MAAM,2BAA2B,CAAC,CAAC,QAA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CHEMA_VERSION,\n contentHash,\n defaultPlanCacheRoot,\n resolvedModuleId,\n stableStringify,\n yukuFactory\n} from \"@tamagui/compiler-core\";\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { ComponentDiscovery } from \"./componentDiscovery\";\nimport { createComponentRegistry, createTamaguiCompilerHost } from \"./compilerHost\";\nimport { domStructuralPass } from \"./domStructuralPass\";\nimport { loadTamagui } from \"./extractor/loadTamagui\";\nimport { resolveZeroRuntimeSync } from \"./zero/options\";\nasync function loadCompilerProject({\n root,\n target,\n options: optionsIn,\n generation,\n rebuild = false,\n hostVersions = [],\n missingProjectMessage = \"Unable to load the Tamagui compiler project\",\n load = loadTamagui,\n resolveComponents\n}) {\n const components = [\n .../* @__PURE__ */ new Set([\"@tamagui/core\", ...optionsIn.components || [\"tamagui\"]])\n ];\n const options = {\n ...optionsIn,\n root,\n platform: target,\n components\n };\n const zeroRuntime = resolveZeroRuntimeSync(options, root).mode;\n if (zeroRuntime === \"enforce\") options.outputCSS = void 0;\n const projectInfo = await load(options, rebuild);\n if (!projectInfo?.tamaguiConfig || !projectInfo.components) {\n throw new Error(missingProjectMessage);\n }\n const componentModules = resolveComponents ? await resolveComponents(components, projectInfo, options) : [];\n const disablePartialExtraction = !!options.disablePartialExtraction;\n const experimentalNativeFastPath = target === \"native\" && options.experimental?.nativeFastPath === true;\n return {\n projectInfo,\n componentModules,\n generation: typeof generation === \"function\" ? generation(projectInfo, componentModules, options) : generation,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n cacheStamp: compilerProjectStamp({\n stampSources: projectInfo.stampSources ?? [],\n hostVersions,\n target,\n componentModules,\n disablePartialExtraction,\n experimentalNativeFastPath,\n zeroRuntime: zeroRuntime !== \"off\",\n development: process.env.NODE_ENV === \"development\"\n })\n };\n}\nconst requireFromCompiler = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst compilerPackageVersions = [\"@tamagui/compiler-core\", \"@tamagui/static\"].map(\n (name) => `${name}@${requireFromCompiler(`${name}/package.json`).version}`\n);\nfunction compilerProjectStamp(input) {\n if (!input.stampSources.length) return null;\n const sources = [];\n for (const file of [...new Set(input.stampSources)].sort()) {\n try {\n sources.push([file, contentHash(readFileSync(file))]);\n } catch {\n return null;\n }\n }\n return contentHash(\n stableStringify({\n schema: PLAN_CACHE_SCHEMA_VERSION,\n plan: LOWERED_MODULE_PLAN_VERSION,\n packages: [...compilerPackageVersions, ...input.hostVersions].sort(),\n target: input.target,\n development: input.development,\n componentModules: input.componentModules.map(({ moduleName, id }) => [\n moduleName,\n cleanId(id)\n ]),\n disablePartialExtraction: input.disablePartialExtraction,\n experimentalNativeFastPath: input.experimentalNativeFastPath,\n zeroRuntime: input.zeroRuntime,\n sources\n })\n );\n}\nfunction cleanId(id) {\n return id.split(/[?#]/, 1)[0];\n}\nfunction externalId(specifier) {\n return resolvedModuleId(`external://${encodeURIComponent(specifier)}`);\n}\nfunction compilerContext(input) {\n return `${input.root}\\0${input.target}\\0${input.environment ?? \"\"}\\0${input.project.generation}`;\n}\nfunction sourceCanBeLinked(root, id) {\n const clean = cleanId(id);\n const normalized = clean.replace(/\\\\/g, \"/\");\n if (!path.isAbsolute(clean) || normalized.includes(\"/node_modules/\")) return false;\n const relative = path.relative(root, clean);\n return relative === \"\" || relative !== \"..\" && !relative.startsWith(`..${path.sep}`);\n}\nclass CompilerFrontend {\n session = new CompilerSession();\n queue = Promise.resolve();\n planCaches = /* @__PURE__ */ new Map();\n moduleRecords = /* @__PURE__ */ new Map();\n moduleContext = null;\n discovery = new ComponentDiscovery();\n /**\n * One cache per project root and platform. Absent when the project produced\n * no content stamp, in which case plans are never persisted rather than\n * persisted under an identity that cannot see a config change.\n */\n planCacheFor(input) {\n const stamp = input.project.cacheStamp;\n if (!stamp) return void 0;\n const root = defaultPlanCacheRoot(input.root, input.target);\n let store = this.planCaches.get(root);\n if (!store) {\n store = new ModulePlanCache(root);\n this.planCaches.set(root, store);\n }\n return { store, stamp };\n }\n /** Hits, misses and writes across every plan cache this frontend has used. */\n get planCacheStats() {\n const total = { hits: 0, misses: 0, writes: 0 };\n for (const store of this.planCaches.values()) {\n total.hits += store.stats.hits;\n total.misses += store.stats.misses;\n total.writes += store.stats.writes;\n }\n return total;\n }\n compile(input) {\n const operation = this.queue.then(async () => {\n const previousTarget = process.env.TAMAGUI_TARGET;\n const previousStatic = process.env.IS_STATIC;\n try {\n return await this.compileNow(input);\n } finally {\n if (previousTarget === void 0) delete process.env.TAMAGUI_TARGET;\n else process.env.TAMAGUI_TARGET = previousTarget;\n if (previousStatic === void 0) delete process.env.IS_STATIC;\n else process.env.IS_STATIC = previousStatic;\n }\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n update(input) {\n const operation = this.queue.then(async () => {\n const { modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n return [...invalidated].sort();\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n has(id) {\n return this.session.has(resolvedModuleId(cleanId(id)));\n }\n dependentsOf(id) {\n return this.session.dependentsOf(resolvedModuleId(cleanId(id)));\n }\n remove(id) {\n const operation = this.queue.then(async () => {\n const result = await this.session.remove(resolvedModuleId(cleanId(id)));\n for (const invalidatedId of result.invalidatedIds) {\n this.moduleRecords.delete(invalidatedId);\n }\n return result;\n });\n this.queue = operation.catch(() => void 0);\n return operation;\n }\n parseCount(id) {\n return this.session.parseCount(resolvedModuleId(cleanId(id)));\n }\n async compileNow(input) {\n const { rootModule, modules } = await this.buildTree(input);\n const invalidated = /* @__PURE__ */ new Set();\n for (const module of modules.values()) {\n for (const id of await this.session.update(module)) invalidated.add(id);\n this.moduleRecords.set(module.id, module);\n }\n const projectInfo = input.project.projectInfo;\n if (!projectInfo.tamaguiConfig || !projectInfo.components) {\n throw new Error(\"The compiler requires evaluated Tamagui config and components\");\n }\n const componentModules = input.project.componentModules.map((component) => ({\n moduleName: component.moduleName,\n resolvedId: cleanId(component.id)\n }));\n const registry = createComponentRegistry(projectInfo.components, componentModules);\n this.discovery.seed(registry);\n const host = createTamaguiCompilerHost({\n target: input.target,\n tamaguiConfig: projectInfo.tamaguiConfig,\n components: projectInfo.components,\n componentModules,\n registry,\n disablePartialExtraction: input.project.disablePartialExtraction,\n experimentalNativeFastPath: input.project.experimentalNativeFastPath,\n zeroRuntime: input.project.zeroRuntime\n });\n const result = await this.session.compile({\n module: rootModule,\n adapter: {\n target: input.target,\n projectGeneration: input.project.generation,\n host,\n planCache: this.planCacheFor(input),\n async load(id) {\n return modules.get(id) ?? null;\n },\n prepare: (module) => this.discovery.prepare(module, registry, input.evaluate)\n },\n structuralPass: domStructuralPass\n });\n for (const id of result.invalidatedIds) invalidated.add(id);\n return {\n plan: result.plan,\n output: result.output,\n invalidatedIds: [...invalidated].sort()\n };\n }\n /** host-resolved ids of every module discovery found components in */\n discoveredModuleIds() {\n return this.discovery.ids();\n }\n async buildTree(input) {\n const moduleContext = compilerContext(input);\n if (this.moduleContext !== moduleContext) {\n this.moduleRecords.clear();\n this.discovery.clear();\n this.moduleContext = moduleContext;\n }\n const componentBySpecifier = new Map(\n input.project.componentModules.map((component) => [\n component.moduleName,\n resolvedModuleId(cleanId(component.id))\n ])\n );\n const modules = /* @__PURE__ */ new Map();\n const loading = /* @__PURE__ */ new Set();\n const addInstalledClosure = (module) => {\n if (modules.has(module.id) || loading.has(module.id)) return;\n loading.add(module.id);\n for (const dependency of module.imports) {\n if (dependency.external) continue;\n const installedDependency = this.moduleRecords.get(dependency.resolvedId);\n if (installedDependency && this.session.has(dependency.resolvedId)) {\n addInstalledClosure(installedDependency);\n }\n }\n modules.set(module.id, module);\n loading.delete(module.id);\n };\n const loadModule = async (rawId, source) => {\n const id = resolvedModuleId(cleanId(rawId));\n const existing = modules.get(id);\n if (existing) return existing;\n const installed = this.moduleRecords.get(id);\n if (installed?.source === source && this.session.has(id)) {\n addInstalledClosure(installed);\n return installed;\n }\n if (loading.has(id)) {\n return { id, source, imports: [] };\n }\n loading.add(id);\n const imports = [];\n for (const specifier of yukuFactory.scanImports(id, source)) {\n const configuredComponent = componentBySpecifier.get(specifier);\n if (configuredComponent) {\n imports.push({ specifier, resolvedId: configuredComponent, external: true });\n continue;\n }\n const resolution = await input.resolve(specifier, id);\n if (!resolution) continue;\n const canLink = !resolution.external && sourceCanBeLinked(input.root, resolution.id);\n const resolvedId = canLink ? resolvedModuleId(cleanId(resolution.id)) : path.isAbsolute(cleanId(resolution.id)) ? resolvedModuleId(cleanId(resolution.id)) : externalId(specifier);\n imports.push({ specifier, resolvedId, external: !canLink });\n if (canLink && !modules.has(resolvedId) && !loading.has(resolvedId)) {\n const installedDependency = this.moduleRecords.get(resolvedId);\n if (installedDependency && this.session.has(resolvedId)) {\n addInstalledClosure(installedDependency);\n } else {\n const dependencySource = await input.load(resolution.id);\n if (dependencySource !== null) {\n await loadModule(resolution.id, dependencySource);\n }\n }\n }\n }\n const module = { id, source, imports };\n modules.set(id, module);\n loading.delete(id);\n return module;\n };\n const rootModule = await loadModule(input.id, input.source);\n return { rootModule, modules };\n }\n}\nexport {\n CompilerFrontend,\n compilerProjectStamp,\n loadCompilerProject\n};\n//# sourceMappingURL=compiler.js.map\n"],"mappings":";;;;;;;;;;;AAmBA,eAAe,oBAAoB,EACjC,MACA,QACA,SAAS,WACT,YACA,UAAU,OACV,eAAe,CAAC,GAChB,wBAAwB,+CACxB,OAAO,aACP,qBACC;CACD,MAAM,aAAa,CACjB,mBAAmB,IAAI,IAAI,CAAC,iBAAiB,GAAG,UAAU,cAAc,CAAC,SAAS,CAAC,CAAC,CACtF;CACA,MAAM,UAAU;EACd,GAAG;EACH;EACA,UAAU;EACV;CACF;CACA,MAAM,cAAc,uBAAuB,SAAS,IAAI,CAAC,CAAC;CAC1D,IAAI,gBAAgB,WAAW,QAAQ,YAAY,KAAK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,mBAAmB;KACzC,OAAO;MACL,MAAM,mBAAmB,MAAM,MAAM,KAAK,WAAW,EAAE;MACvD,IAAI,qBAAqB,MAAM;OAC7B,MAAM,WAAW,WAAW,IAAI,gBAAgB;MAClD;KACF;IACF;GACF;GACA,MAAM,SAAS;IAAE;IAAI;IAAQ;GAAQ;GACrC,QAAQ,IAAI,IAAI,MAAM;GACtB,QAAQ,OAAO,EAAE;GACjB,OAAO;EACT;EACA,MAAM,aAAa,MAAM,WAAW,MAAM,IAAI,MAAM,MAAM;EAC1D,OAAO;GAAE;GAAY;EAAQ;CAC/B;AACF"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { collectLeaves, zeroRuleMessage, zeroThemeBoundaryMessage } from "@tamagui/compiler-core";
|
|
2
|
-
import { StyleObjectIdentifier, StyleObjectProperty, StyleObjectRules, StyleObjectValue, stylePropsAll, stylePropsText, validStyles } from "@tamagui/helpers";
|
|
2
|
+
import { StyleObjectIdentifier, StyleObjectProperty, StyleObjectRules, StyleObjectValue, stylePropsAll, stylePropsInput, stylePropsText, validStyles } from "@tamagui/helpers";
|
|
3
3
|
import { ATTRIBUTES, DISPLAY_WEB_RESET, EVENTS, NATIVE_BACKING, NATIVE_BLOCK_DEFAULTS, NATIVE_ELEMENT_DEFAULTS, NATIVE_FLEX_DEFAULTS, NATIVE_INPUT_TYPES, NATIVE_PRIMITIVE_MODULE, TAGS, TAG_WEB_DEFAULTS } from "@tamagui/dom";
|
|
4
4
|
import { createModifierRegistry, parseTransition, parseValue } from "@tamagui/style-grammar/tooling";
|
|
5
5
|
import { isValidStyleKey } from "@tamagui/web";
|
|
6
6
|
import { concatClassName } from "./extractor/concatClassName.mjs";
|
|
7
7
|
import { requireTamaguiCore } from "./helpers/requireTamaguiCore.mjs";
|
|
8
8
|
|
|
9
|
+
function createComponentRegistry(components, componentModules) {
|
|
10
|
+
return {
|
|
11
|
+
modulesById: new Map(componentModules.map((module) => [module.resolvedId, module.moduleName])),
|
|
12
|
+
componentsByModule: new Map(components.map((component) => [component.moduleName, component]))
|
|
13
|
+
};
|
|
14
|
+
}
|
|
9
15
|
const DOM_FRONTENDS = /* @__PURE__ */ new Set([
|
|
10
16
|
"tamagui",
|
|
11
17
|
"tamagui/dom",
|
|
@@ -214,6 +220,11 @@ const runtimeAnimationProps = /* @__PURE__ */ new Set([
|
|
|
214
220
|
"animatePresence",
|
|
215
221
|
"animatedBy"
|
|
216
222
|
]);
|
|
223
|
+
const componentOnlyProps = /* @__PURE__ */ new Set([
|
|
224
|
+
"asChild",
|
|
225
|
+
"disableOptimization",
|
|
226
|
+
"themeInverse"
|
|
227
|
+
]);
|
|
217
228
|
const cssShorthandConflicts = {
|
|
218
229
|
background: [
|
|
219
230
|
"backgroundAttachment",
|
|
@@ -390,6 +401,12 @@ const cssShorthandConflicts = {
|
|
|
390
401
|
]
|
|
391
402
|
};
|
|
392
403
|
const cssConflictFamilies = [
|
|
404
|
+
/* @__PURE__ */ new Set(["width", "inlineSize"]),
|
|
405
|
+
/* @__PURE__ */ new Set(["minWidth", "minInlineSize"]),
|
|
406
|
+
/* @__PURE__ */ new Set(["maxWidth", "maxInlineSize"]),
|
|
407
|
+
/* @__PURE__ */ new Set(["height", "blockSize"]),
|
|
408
|
+
/* @__PURE__ */ new Set(["minHeight", "minBlockSize"]),
|
|
409
|
+
/* @__PURE__ */ new Set(["maxHeight", "maxBlockSize"]),
|
|
393
410
|
/* @__PURE__ */ new Set([
|
|
394
411
|
"marginInline",
|
|
395
412
|
"marginInlineEnd",
|
|
@@ -701,6 +718,7 @@ function webDOMProps(input, tag) {
|
|
|
701
718
|
function createTamaguiCompilerHost(options) {
|
|
702
719
|
const platform = options.target === "native" ? "native" : "web";
|
|
703
720
|
const core = requireTamaguiCore(platform);
|
|
721
|
+
const compilerVariantStyleResolver = core.styled(core.View, {}).staticConfig.variantStyleResolver;
|
|
704
722
|
const firstThemeName = Object.keys(options.tamaguiConfig.themes ?? {})[0] ?? "";
|
|
705
723
|
const firstTheme = options.tamaguiConfig.themes?.[firstThemeName] ?? {};
|
|
706
724
|
const theme = firstTheme;
|
|
@@ -723,6 +741,27 @@ function createTamaguiCompilerHost(options) {
|
|
|
723
741
|
}
|
|
724
742
|
return false;
|
|
725
743
|
};
|
|
744
|
+
const platformModifiersRegistered = modifierRegistry.get("web") === "platform" && modifierRegistry.get("native") === "platform";
|
|
745
|
+
const nativeClauseValue = (value) => {
|
|
746
|
+
if (typeof value !== "string" || !flatClausePattern.test(value)) {
|
|
747
|
+
return isClauseObjectValue(value) ? "live" : null;
|
|
748
|
+
}
|
|
749
|
+
if (!platformModifiersRegistered) return "live";
|
|
750
|
+
const parsed = parseValue(value, modifierRegistry);
|
|
751
|
+
if (!parsed.ok || parsed.value.clauses.length === 0) return "live";
|
|
752
|
+
let payload = parsed.value.base;
|
|
753
|
+
let matched = parsed.value.base !== null;
|
|
754
|
+
for (const clause of parsed.value.clauses) {
|
|
755
|
+
if (clause.modifiers.includes("web")) continue;
|
|
756
|
+
if (clause.modifiers.length !== 1 || clause.modifiers[0] !== "native") return "live";
|
|
757
|
+
payload = clause.payload;
|
|
758
|
+
matched = true;
|
|
759
|
+
}
|
|
760
|
+
return {
|
|
761
|
+
payload,
|
|
762
|
+
matched
|
|
763
|
+
};
|
|
764
|
+
};
|
|
726
765
|
const configuredAnimationDriver = options.tamaguiConfig.animations;
|
|
727
766
|
const configuredCssAnimationDriver = platform === "web" && configuredAnimationDriver?.outputStyle === "css" && !options.tamaguiConfig.animationDrivers ? configuredAnimationDriver : null;
|
|
728
767
|
const resolveStaticCssTransition = (value, transitionPresets) => {
|
|
@@ -761,8 +800,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
761
800
|
}
|
|
762
801
|
return resolved.join(" ");
|
|
763
802
|
};
|
|
764
|
-
const modulesById =
|
|
765
|
-
const componentsByModule = new Map(options.components.map((component) => [component.moduleName, component]));
|
|
803
|
+
const { modulesById, componentsByModule } = options.registry ?? createComponentRegistry(options.components, options.componentModules);
|
|
766
804
|
const normalizedStyleConfigs = /* @__PURE__ */ new WeakMap();
|
|
767
805
|
const normalizeStaticConfig = (staticConfig) => {
|
|
768
806
|
if (!staticConfig.styleFrontend) return staticConfig;
|
|
@@ -818,7 +856,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
818
856
|
isInput: row.backing === "textinput",
|
|
819
857
|
validStyles: {
|
|
820
858
|
...validStyles,
|
|
821
|
-
...stylePropsText
|
|
859
|
+
...row.backing === "textinput" ? stylePropsInput : stylePropsText
|
|
822
860
|
},
|
|
823
861
|
defaultProps: {
|
|
824
862
|
...base.defaultProps,
|
|
@@ -829,6 +867,10 @@ function createTamaguiCompilerHost(options) {
|
|
|
829
867
|
};
|
|
830
868
|
const styledStaticConfig = (definition) => {
|
|
831
869
|
if (!definition || definition.options.kind !== "static") return null;
|
|
870
|
+
const staticConfig = definition.staticConfig;
|
|
871
|
+
if (staticConfig && (staticConfig.kind !== "static" || !staticObject(staticConfig.value))) {
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
832
874
|
const base = directStaticConfig({
|
|
833
875
|
kind: "element",
|
|
834
876
|
form: "jsx",
|
|
@@ -843,30 +885,33 @@ function createTamaguiCompilerHost(options) {
|
|
|
843
885
|
if (!base || !staticObject(definition.options.value)) return null;
|
|
844
886
|
const { variants, defaultVariants, displayName, context, contextProps, ...defaultProps } = definition.options.value;
|
|
845
887
|
const baseClassName = definition.baseClassName?.kind === "static" && typeof definition.baseClassName.value === "string" ? definition.baseClassName.value : void 0;
|
|
888
|
+
const localStaticConfig = {
|
|
889
|
+
...base.staticConfig,
|
|
890
|
+
...staticConfig?.value,
|
|
891
|
+
variants: {
|
|
892
|
+
...base.staticConfig.variants,
|
|
893
|
+
...variants
|
|
894
|
+
},
|
|
895
|
+
defaultProps: {
|
|
896
|
+
...base.staticConfig.defaultProps,
|
|
897
|
+
...defaultProps,
|
|
898
|
+
...defaultVariants
|
|
899
|
+
},
|
|
900
|
+
defaultVariants,
|
|
901
|
+
baseClassName: [base.staticConfig.baseClassName, baseClassName].filter(Boolean).join(" "),
|
|
902
|
+
context: context ?? base.staticConfig.context,
|
|
903
|
+
contextProps: context ? contextProps : contextProps ?? base.staticConfig.contextProps
|
|
904
|
+
};
|
|
905
|
+
localStaticConfig.variantStyleResolver = compilerVariantStyleResolver;
|
|
846
906
|
return {
|
|
847
907
|
key: componentKey(definition.id, definition.name),
|
|
848
908
|
displayName: displayName || base.displayName,
|
|
849
|
-
staticConfig: normalizeStaticConfig(
|
|
850
|
-
...base.staticConfig,
|
|
851
|
-
variants: {
|
|
852
|
-
...base.staticConfig.variants,
|
|
853
|
-
...variants
|
|
854
|
-
},
|
|
855
|
-
defaultProps: {
|
|
856
|
-
...base.staticConfig.defaultProps,
|
|
857
|
-
...defaultProps,
|
|
858
|
-
...defaultVariants
|
|
859
|
-
},
|
|
860
|
-
defaultVariants,
|
|
861
|
-
baseClassName: [base.staticConfig.baseClassName, baseClassName].filter(Boolean).join(" "),
|
|
862
|
-
context: context ?? base.staticConfig.context,
|
|
863
|
-
contextProps: context ? contextProps : contextProps ?? base.staticConfig.contextProps
|
|
864
|
-
})
|
|
909
|
+
staticConfig: normalizeStaticConfig(localStaticConfig)
|
|
865
910
|
};
|
|
866
911
|
};
|
|
867
912
|
const resolve = (element, styledDefinition) => {
|
|
868
913
|
const dom = domStaticConfig(element);
|
|
869
|
-
const resolved = dom ??
|
|
914
|
+
const resolved = dom ?? directStaticConfig(element) ?? styledStaticConfig(styledDefinition);
|
|
870
915
|
if (!resolved) return null;
|
|
871
916
|
const defaultProps = resolved.staticConfig.defaultProps ?? {};
|
|
872
917
|
return {
|
|
@@ -896,8 +941,8 @@ function createTamaguiCompilerHost(options) {
|
|
|
896
941
|
const canLowerConditionalStyleProp = (name, component) => isStyleProp(name, component) && !runtimeOnlyStyleProps.has(name);
|
|
897
942
|
const isInvalidHostStyleProp = (name, component) => {
|
|
898
943
|
const staticConfig = component.staticConfig;
|
|
899
|
-
const validStyles$1 = staticConfig.validStyles || (staticConfig.
|
|
900
|
-
return name in stylePropsAll && !isValidStyleKey(name, validStyles$1
|
|
944
|
+
const validStyles$1 = staticConfig.validStyles || (staticConfig.isInput ? stylePropsInput : staticConfig.isText ? stylePropsText : validStyles);
|
|
945
|
+
return name in stylePropsAll && !isValidStyleKey(name, validStyles$1);
|
|
901
946
|
};
|
|
902
947
|
const directStyleName = (name, component) => {
|
|
903
948
|
if (compilerStyleProps.has(name) || name === "style") {
|
|
@@ -919,6 +964,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
919
964
|
process.env.TAMAGUI_TARGET = platform;
|
|
920
965
|
try {
|
|
921
966
|
return core.getSplitStyles(props, staticConfig, theme, firstThemeName, componentState, {
|
|
967
|
+
isStatic: true,
|
|
922
968
|
resolveValues: platform === "native" ? "except-theme" : "variable",
|
|
923
969
|
noClass: platform === "native",
|
|
924
970
|
isAnimated: false,
|
|
@@ -1041,6 +1087,9 @@ function createTamaguiCompilerHost(options) {
|
|
|
1041
1087
|
if (!options.disablePartialExtraction && valueKind === "conditional" && canLowerConditionalStyleProp(name, component)) {
|
|
1042
1088
|
return true;
|
|
1043
1089
|
}
|
|
1090
|
+
if (component.staticConfig.resolvers?.length) {
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1044
1093
|
return !options.disablePartialExtraction && (platform === "web" && !!directStyleName(name, component) || platform === "native" && directStyleName(name, component) === "opacity");
|
|
1045
1094
|
},
|
|
1046
1095
|
developmentDebugInstrumentation,
|
|
@@ -1071,9 +1120,30 @@ function createTamaguiCompilerHost(options) {
|
|
|
1071
1120
|
props[entry.name] = entry.value.value;
|
|
1072
1121
|
}
|
|
1073
1122
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1123
|
+
if (component.staticConfig.resolvers?.length) {
|
|
1124
|
+
const unresolvedProps = input.element.entries.filter((entry) => entry.kind === "prop" && entry.value.kind !== "static");
|
|
1125
|
+
const onlyStaticBranchConditional = unresolvedProps.length === 1 && unresolvedProps[0]?.kind === "prop" && unresolvedProps[0].value.kind === "conditional" && canLowerConditionalStyleProp(unresolvedProps[0].name, component);
|
|
1126
|
+
const unresolvedProp = onlyStaticBranchConditional ? void 0 : unresolvedProps[0];
|
|
1127
|
+
if (unresolvedProp?.kind === "prop") {
|
|
1128
|
+
return bailout(input, "local/dynamic-style-value", `Component resolver prop ${unresolvedProp.name} could not be evaluated`, unresolvedProp.span, void 0, unresolvedProp.name);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
const componentOnlyProp = (name) => {
|
|
1132
|
+
let span;
|
|
1133
|
+
let unknown = false;
|
|
1134
|
+
for (const entry of input.element.entries) {
|
|
1135
|
+
if (entry.kind !== "prop" || entry.name !== name) continue;
|
|
1136
|
+
span = entry.span;
|
|
1137
|
+
if (entry.value.kind !== "static") unknown = true;
|
|
1138
|
+
}
|
|
1139
|
+
return {
|
|
1140
|
+
unknown,
|
|
1141
|
+
span
|
|
1142
|
+
};
|
|
1143
|
+
};
|
|
1144
|
+
const disableOptimization = componentOnlyProp("disableOptimization");
|
|
1145
|
+
if (disableOptimization.unknown || props.disableOptimization) {
|
|
1146
|
+
return bailout(input, "local/unsupported-target", "disableOptimization keeps the component on the runtime path", disableOptimization.span);
|
|
1077
1147
|
}
|
|
1078
1148
|
if (component.domTag && props.hidden) props.display = "none";
|
|
1079
1149
|
if (component.domTag && platform === "native") {
|
|
@@ -1140,7 +1210,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1140
1210
|
const expression = input.source.slice(entry.value.span.start, entry.value.span.end);
|
|
1141
1211
|
if (resolvedCssTransition !== null && (name === "opacity" || name === "scale")) {
|
|
1142
1212
|
property = name === "opacity" ? `opacity: (${expression})` : `transform: "scale(" + (${expression}) + ")"`;
|
|
1143
|
-
} else if (entry.value.kind === "bailout" && owners.
|
|
1213
|
+
} else if (entry.value.kind === "bailout" && owners.has(name)) {
|
|
1144
1214
|
const dynamic = entry.value.dynamic;
|
|
1145
1215
|
if (dynamic?.type === "number") {
|
|
1146
1216
|
property = `${JSON.stringify(name)}: (${expression})`;
|
|
@@ -1178,16 +1248,19 @@ function createTamaguiCompilerHost(options) {
|
|
|
1178
1248
|
}
|
|
1179
1249
|
}
|
|
1180
1250
|
const supportsWebConditionalClasses = platform === "web" && !options.disablePartialExtraction && (input.element.form === "jsx" || input.element.propsSpan !== null) && dynamicHostStyleProperties === null && dynamicStyleEntries.length > 0 && dynamicStyleEntries.every((entry) => entry.kind === "prop" && entry.value.kind === "conditional" && canLowerConditionalStyleProp(entry.name, component));
|
|
1181
|
-
|
|
1182
|
-
|
|
1251
|
+
const themeEntry = componentOnlyProp("theme");
|
|
1252
|
+
const themeInverseEntry = componentOnlyProp("themeInverse");
|
|
1253
|
+
const themeBoundary = themeEntry.unknown || "theme" in props;
|
|
1254
|
+
if (themeBoundary || themeInverseEntry.unknown || props.themeInverse) {
|
|
1255
|
+
const themeProp = themeBoundary ? "theme" : "themeInverse";
|
|
1183
1256
|
return bailout(input, "local/unsupported-target", "Theme boundary candidates remain on the runtime path", input.element.span, {
|
|
1184
1257
|
rule: 4,
|
|
1185
1258
|
message: zeroThemeBoundaryMessage(input.element.component.name, themeProp)
|
|
1186
1259
|
});
|
|
1187
1260
|
}
|
|
1188
|
-
const
|
|
1189
|
-
if (
|
|
1190
|
-
return bailout(input, "local/unsupported-target", "asChild renders a Slot, not a host view",
|
|
1261
|
+
const asChild = componentOnlyProp("asChild");
|
|
1262
|
+
if (asChild.unknown || props.asChild) {
|
|
1263
|
+
return bailout(input, "local/unsupported-target", "asChild renders a Slot, not a host view", asChild.span);
|
|
1191
1264
|
}
|
|
1192
1265
|
if (platform === "native" && ("group" in props || "container" in props || "containerName" in props || "containerType" in props)) {
|
|
1193
1266
|
return bailout(input, "local/unsupported-target", "Native group and container providers remain on the runtime path");
|
|
@@ -1286,12 +1359,17 @@ function createTamaguiCompilerHost(options) {
|
|
|
1286
1359
|
const entry = dynamicStyleEntries[0];
|
|
1287
1360
|
return bailout(input, "local/dynamic-style-value", `Style prop ${entry.kind === "prop" ? entry.name : "unknown"} could not be safely extracted`, entry.span);
|
|
1288
1361
|
}
|
|
1289
|
-
const
|
|
1362
|
+
const resolvedStyleStaticConfig = core.getStyleStaticConfig(component.staticConfig, core.getConfig());
|
|
1363
|
+
const staticDefaultProps = resolvedStyleStaticConfig.defaultProps ?? {};
|
|
1290
1364
|
const defaultProps = platform === "web" && !component.staticConfig.isText && options.tamaguiConfig.settings.defaultPosition === "relative" && staticDefaultProps.position === void 0 ? core.mergeProps({ position: "relative" }, staticDefaultProps) : staticDefaultProps;
|
|
1291
1365
|
let completeProps = core.mergeProps(defaultProps, props);
|
|
1292
1366
|
if (platform === "native" && component.domTag && props.display === "flex") {
|
|
1293
1367
|
completeProps = core.mergeProps(core.mergeProps(defaultProps, NATIVE_FLEX_DEFAULTS), props);
|
|
1294
1368
|
}
|
|
1369
|
+
const domStyleProgram = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "style" && entry.value.kind === "dom-style");
|
|
1370
|
+
if (platform === "native" && !component.domTag && domStyleProgram) {
|
|
1371
|
+
return bailout(input, "local/unsupported-target", "Native style() pieces remain on the runtime path");
|
|
1372
|
+
}
|
|
1295
1373
|
const propsForConditional = (target, value) => {
|
|
1296
1374
|
const branchProps = {};
|
|
1297
1375
|
for (const entry of input.element.entries) {
|
|
@@ -1319,6 +1397,14 @@ function createTamaguiCompilerHost(options) {
|
|
|
1319
1397
|
}
|
|
1320
1398
|
}
|
|
1321
1399
|
const branchCompleteProps = platform === "native" && component.domTag && branchProps.display === "flex" ? core.mergeProps(core.mergeProps(defaultProps, NATIVE_FLEX_DEFAULTS), branchProps) : core.mergeProps(defaultProps, branchProps);
|
|
1400
|
+
if (platform === "native") {
|
|
1401
|
+
for (const [name, value2] of Object.entries(branchCompleteProps)) {
|
|
1402
|
+
const clause = isStyleProp(name, component) ? nativeClauseValue(value2) : null;
|
|
1403
|
+
if (clause === null || clause === "live") continue;
|
|
1404
|
+
if (clause.matched) branchCompleteProps[name] = clause.payload;
|
|
1405
|
+
else delete branchCompleteProps[name];
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1322
1408
|
return {
|
|
1323
1409
|
branchProps,
|
|
1324
1410
|
branchCompleteProps
|
|
@@ -1327,10 +1413,30 @@ function createTamaguiCompilerHost(options) {
|
|
|
1327
1413
|
if (platform === "native") {
|
|
1328
1414
|
const isClauseValue = (name, value) => isStyleProp(name, component) && (typeof value === "string" && flatClausePattern.test(value) || isClauseObjectValue(value));
|
|
1329
1415
|
const defaultVariants = component.staticConfig.defaultVariants ?? {};
|
|
1330
|
-
const
|
|
1331
|
-
if (
|
|
1416
|
+
const definitionCarriesClause = Object.entries(resolvedStyleStaticConfig.baseStyle ?? {}).some(([name, value]) => isClauseValue(name, value)) || Object.entries(component.staticConfig.variants ?? {}).some(([variantName, definitions]) => (completeProps[variantName] !== void 0 || defaultVariants[variantName] !== void 0) && staticObject(definitions) && Object.values(definitions).some((definition) => staticObject(definition) && Object.entries(definition).some(([name, value]) => isClauseValue(name, value))));
|
|
1417
|
+
if (definitionCarriesClause) {
|
|
1332
1418
|
return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1333
1419
|
}
|
|
1420
|
+
const reducedProps = {};
|
|
1421
|
+
for (const [name, value] of Object.entries(completeProps)) {
|
|
1422
|
+
const clause = isStyleProp(name, component) ? nativeClauseValue(value) : null;
|
|
1423
|
+
if (clause === "live") {
|
|
1424
|
+
return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1425
|
+
}
|
|
1426
|
+
if (clause === null) {
|
|
1427
|
+
reducedProps[name] = value;
|
|
1428
|
+
continue;
|
|
1429
|
+
}
|
|
1430
|
+
if (clause.matched) reducedProps[name] = clause.payload;
|
|
1431
|
+
}
|
|
1432
|
+
completeProps = reducedProps;
|
|
1433
|
+
for (const entry of dynamicStyleEntries) {
|
|
1434
|
+
if (entry.value.kind !== "conditional") continue;
|
|
1435
|
+
for (const leaf of collectLeaves(entry.value.tree)) {
|
|
1436
|
+
if (nativeClauseValue(leaf.value) !== "live") continue;
|
|
1437
|
+
return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1334
1440
|
}
|
|
1335
1441
|
const split = resolveSplitStyles(completeProps, component.staticConfig, cssAnimationDriver, component.displayName);
|
|
1336
1442
|
if (!split) {
|
|
@@ -1342,7 +1448,6 @@ function createTamaguiCompilerHost(options) {
|
|
|
1342
1448
|
message: zeroRuleMessage(5, { detail: `an enter or exit style program on ${input.element.component.name}` })
|
|
1343
1449
|
});
|
|
1344
1450
|
}
|
|
1345
|
-
const domStyleProgram = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "style" && entry.value.kind === "dom-style");
|
|
1346
1451
|
const flatTag = component.domTag ?? (typeof props.render === "string" ? props.render : typeof defaultProps.render === "string" ? defaultProps.render : component.staticConfig.isText ? "span" : "div");
|
|
1347
1452
|
const tagEdits = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1348
1453
|
start: span.start,
|
|
@@ -1350,7 +1455,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1350
1455
|
content: input.element.form === "jsx" ? flatTag : JSON.stringify(flatTag),
|
|
1351
1456
|
origin: span
|
|
1352
1457
|
}));
|
|
1353
|
-
const isPropIgnored = (name) => isStyleProp(name, component) || isInvalidHostStyleProp(name, component);
|
|
1458
|
+
const isPropIgnored = (name) => isStyleProp(name, component) || isInvalidHostStyleProp(name, component) || componentOnlyProps.has(name);
|
|
1354
1459
|
const spreadReplacement = (form, entry) => spreadNonStyleReplacement(form, entry, isPropIgnored, (name, value) => {
|
|
1355
1460
|
if (platform !== "web") return [name, value];
|
|
1356
1461
|
if (name === "testID") return ["data-testid", value];
|
|
@@ -1360,7 +1465,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1360
1465
|
}
|
|
1361
1466
|
return [name, value];
|
|
1362
1467
|
});
|
|
1363
|
-
let styleEntries = input.element.entries.filter((entry) => entry.kind === "prop" && (
|
|
1468
|
+
let styleEntries = input.element.entries.filter((entry) => entry.kind === "prop" && isPropIgnored(entry.name) || entry.kind === "spread" && entry.value.kind === "static" && staticObject(entry.value.value) && Object.keys(entry.value.value).some(isPropIgnored));
|
|
1364
1469
|
let invalidHostStyle;
|
|
1365
1470
|
for (const entry of input.element.entries) {
|
|
1366
1471
|
if (entry.kind === "prop") {
|
|
@@ -2028,7 +2133,7 @@ const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
|
2028
2133
|
}
|
|
2029
2134
|
};
|
|
2030
2135
|
}
|
|
2031
|
-
function bailout(input, code, message, span = input.element.span, zero) {
|
|
2136
|
+
function bailout(input, code, message, span = input.element.span, zero, prop) {
|
|
2032
2137
|
return {
|
|
2033
2138
|
ok: false,
|
|
2034
2139
|
bailout: {
|
|
@@ -2037,6 +2142,7 @@ function bailout(input, code, message, span = input.element.span, zero) {
|
|
|
2037
2142
|
message,
|
|
2038
2143
|
span,
|
|
2039
2144
|
component: input.element.component.name,
|
|
2145
|
+
...prop && { prop },
|
|
2040
2146
|
...zero && {
|
|
2041
2147
|
zeroRule: zero.rule,
|
|
2042
2148
|
zeroMessage: zero.message
|
|
@@ -2045,5 +2151,5 @@ function bailout(input, code, message, span = input.element.span, zero) {
|
|
|
2045
2151
|
};
|
|
2046
2152
|
}
|
|
2047
2153
|
|
|
2048
|
-
export { createTamaguiCompilerHost };
|
|
2154
|
+
export { createComponentRegistry, createTamaguiCompilerHost };
|
|
2049
2155
|
//# sourceMappingURL=compilerHost.mjs.map
|