@tamagui/static 3.0.0-beta.807.1 → 3.0.0-beta.881.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 +164 -50
- package/dist/cjs/componentDiscovery.cjs +90 -0
- package/dist/cjs/domStructuralPass.cjs +16 -6
- package/dist/cjs/exports.cjs +4 -1
- package/dist/cjs/extractor/bundleConfig.cjs +23 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +1 -1
- 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 +162 -51
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/componentDiscovery.mjs +65 -0
- package/dist/esm/componentDiscovery.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +16 -6
- 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/staticEvaluationIgnoredModules.mjs +1 -1
- package/dist/esm/staticEvaluationIgnoredModules.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 +274 -105
- package/src/componentDiscovery.ts +95 -0
- package/src/domStructuralPass.ts +26 -6
- package/src/exports.ts +2 -0
- package/src/extractor/bundleConfig.ts +34 -0
- package/src/staticEvaluationIgnoredModules.ts +1 -1
- 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
|
@@ -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",
|
|
@@ -529,8 +546,8 @@ function nativeDOMProps(input, tag) {
|
|
|
529
546
|
const consume = (entry) => consumed.push(entry);
|
|
530
547
|
for (const entry of entries) {
|
|
531
548
|
const value = entrySource(input, entry);
|
|
532
|
-
const attribute = (
|
|
533
|
-
const event =
|
|
549
|
+
const attribute = (entry.name in ATTRIBUTES ? ATTRIBUTES[entry.name] : void 0) ?? (entry.name.startsWith("data-") ? ATTRIBUTES["data-*"] : void 0);
|
|
550
|
+
const event = entry.name in EVENTS ? EVENTS[entry.name] : void 0;
|
|
534
551
|
if (event) {
|
|
535
552
|
if (event.native === "none") {
|
|
536
553
|
return {
|
|
@@ -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,9 +800,21 @@ function createTamaguiCompilerHost(options) {
|
|
|
761
800
|
}
|
|
762
801
|
return resolved.join(" ");
|
|
763
802
|
};
|
|
764
|
-
const modulesById =
|
|
765
|
-
const
|
|
766
|
-
const normalizeStaticConfig = (staticConfig) =>
|
|
803
|
+
const { modulesById, componentsByModule } = options.registry ?? createComponentRegistry(options.components, options.componentModules);
|
|
804
|
+
const normalizedStyleConfigs = /* @__PURE__ */ new WeakMap();
|
|
805
|
+
const normalizeStaticConfig = (staticConfig) => {
|
|
806
|
+
if (!staticConfig.styleFrontend) return staticConfig;
|
|
807
|
+
const normalized = core.getStyleStaticConfig(staticConfig, options.tamaguiConfig);
|
|
808
|
+
const result = {
|
|
809
|
+
...staticConfig,
|
|
810
|
+
baseStyle: normalized.baseStyle,
|
|
811
|
+
defaultProps: normalized.defaultProps,
|
|
812
|
+
variants: normalized.variants,
|
|
813
|
+
passthroughClassName: normalized.passthroughClassName
|
|
814
|
+
};
|
|
815
|
+
normalizedStyleConfigs.set(result, normalized);
|
|
816
|
+
return result;
|
|
817
|
+
};
|
|
767
818
|
const directStaticConfig = (element) => {
|
|
768
819
|
const identity = element.component.provenance;
|
|
769
820
|
if (!identity) return null;
|
|
@@ -779,7 +830,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
779
830
|
const domStaticConfig = (element) => {
|
|
780
831
|
const identity = element.component.provenance;
|
|
781
832
|
const tag = element.component.name;
|
|
782
|
-
if (identity?.importedName !== "html" || !DOM_FRONTENDS.has(identity.specifier) || !
|
|
833
|
+
if (identity?.importedName !== "html" || !DOM_FRONTENDS.has(identity.specifier) || !(tag in TAGS)) {
|
|
783
834
|
return null;
|
|
784
835
|
}
|
|
785
836
|
const row = TAGS[tag];
|
|
@@ -805,7 +856,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
805
856
|
isInput: row.backing === "textinput",
|
|
806
857
|
validStyles: {
|
|
807
858
|
...validStyles,
|
|
808
|
-
...stylePropsText
|
|
859
|
+
...row.backing === "textinput" ? stylePropsInput : stylePropsText
|
|
809
860
|
},
|
|
810
861
|
defaultProps: {
|
|
811
862
|
...base.defaultProps,
|
|
@@ -828,42 +879,43 @@ function createTamaguiCompilerHost(options) {
|
|
|
828
879
|
bailouts: []
|
|
829
880
|
});
|
|
830
881
|
if (!base || !staticObject(definition.options.value)) return null;
|
|
831
|
-
const { variants, defaultVariants,
|
|
882
|
+
const { variants, defaultVariants, displayName, context, contextProps, ...defaultProps } = definition.options.value;
|
|
832
883
|
const baseClassName = definition.baseClassName?.kind === "static" && typeof definition.baseClassName.value === "string" ? definition.baseClassName.value : void 0;
|
|
884
|
+
const localStaticConfig = {
|
|
885
|
+
...base.staticConfig,
|
|
886
|
+
variants: {
|
|
887
|
+
...base.staticConfig.variants,
|
|
888
|
+
...variants
|
|
889
|
+
},
|
|
890
|
+
defaultProps: {
|
|
891
|
+
...base.staticConfig.defaultProps,
|
|
892
|
+
...defaultProps,
|
|
893
|
+
...defaultVariants
|
|
894
|
+
},
|
|
895
|
+
defaultVariants,
|
|
896
|
+
baseClassName: [base.staticConfig.baseClassName, baseClassName].filter(Boolean).join(" "),
|
|
897
|
+
context: context ?? base.staticConfig.context,
|
|
898
|
+
contextProps: context ? contextProps : contextProps ?? base.staticConfig.contextProps
|
|
899
|
+
};
|
|
900
|
+
localStaticConfig.variantStyleResolver = compilerVariantStyleResolver;
|
|
833
901
|
return {
|
|
834
902
|
key: componentKey(definition.id, definition.name),
|
|
835
903
|
displayName: displayName || base.displayName,
|
|
836
|
-
staticConfig: normalizeStaticConfig(
|
|
837
|
-
...base.staticConfig,
|
|
838
|
-
variants: {
|
|
839
|
-
...base.staticConfig.variants,
|
|
840
|
-
...variants
|
|
841
|
-
},
|
|
842
|
-
compoundVariants: [...base.staticConfig.compoundVariants ?? [], ...compoundVariants ?? []],
|
|
843
|
-
defaultProps: {
|
|
844
|
-
...base.staticConfig.defaultProps,
|
|
845
|
-
...defaultProps,
|
|
846
|
-
...defaultVariants
|
|
847
|
-
},
|
|
848
|
-
defaultVariants,
|
|
849
|
-
baseClassName: [base.staticConfig.baseClassName, baseClassName].filter(Boolean).join(" "),
|
|
850
|
-
context: context ?? base.staticConfig.context,
|
|
851
|
-
contextProps: context ? contextProps : contextProps ?? base.staticConfig.contextProps
|
|
852
|
-
})
|
|
904
|
+
staticConfig: normalizeStaticConfig(localStaticConfig)
|
|
853
905
|
};
|
|
854
906
|
};
|
|
855
907
|
const resolve = (element, styledDefinition) => {
|
|
856
908
|
const dom = domStaticConfig(element);
|
|
857
909
|
const resolved = dom ?? styledStaticConfig(styledDefinition) ?? directStaticConfig(element);
|
|
858
910
|
if (!resolved) return null;
|
|
859
|
-
const defaultProps =
|
|
911
|
+
const defaultProps = resolved.staticConfig.defaultProps ?? {};
|
|
860
912
|
return {
|
|
861
913
|
key: resolved.key,
|
|
862
914
|
canFlatten: resolved.staticConfig.acceptsClassName !== false && !resolved.staticConfig.neverFlatten && !resolved.staticConfig.context,
|
|
863
915
|
staticConfig: resolved.staticConfig,
|
|
864
916
|
displayName: resolved.displayName,
|
|
865
917
|
...dom && { domTag: dom.tag },
|
|
866
|
-
partialRuntimeSafe: !dom && !styledDefinition && Object.keys(defaultProps).length === 0 && !resolved.staticConfig.defaultVariants && !resolved.staticConfig.baseClassName && !resolved.staticConfig.baseStyle
|
|
918
|
+
partialRuntimeSafe: !dom && !styledDefinition && Object.keys(defaultProps).length === 0 && !resolved.staticConfig.defaultVariants && !resolved.staticConfig.baseClassName && !resolved.staticConfig.baseStyle
|
|
867
919
|
};
|
|
868
920
|
};
|
|
869
921
|
const isStyleProp = (name, component) => {
|
|
@@ -884,8 +936,8 @@ function createTamaguiCompilerHost(options) {
|
|
|
884
936
|
const canLowerConditionalStyleProp = (name, component) => isStyleProp(name, component) && !runtimeOnlyStyleProps.has(name);
|
|
885
937
|
const isInvalidHostStyleProp = (name, component) => {
|
|
886
938
|
const staticConfig = component.staticConfig;
|
|
887
|
-
const validStyles$1 = staticConfig.validStyles || (staticConfig.
|
|
888
|
-
return name in stylePropsAll && !isValidStyleKey(name, validStyles$1
|
|
939
|
+
const validStyles$1 = staticConfig.validStyles || (staticConfig.isInput ? stylePropsInput : staticConfig.isText ? stylePropsText : validStyles);
|
|
940
|
+
return name in stylePropsAll && !isValidStyleKey(name, validStyles$1);
|
|
889
941
|
};
|
|
890
942
|
const directStyleName = (name, component) => {
|
|
891
943
|
if (compilerStyleProps.has(name) || name === "style") {
|
|
@@ -906,13 +958,13 @@ function createTamaguiCompilerHost(options) {
|
|
|
906
958
|
}
|
|
907
959
|
process.env.TAMAGUI_TARGET = platform;
|
|
908
960
|
try {
|
|
909
|
-
core.prepareStyleStaticConfig(staticConfig);
|
|
910
961
|
return core.getSplitStyles(props, staticConfig, theme, firstThemeName, componentState, {
|
|
962
|
+
isStatic: true,
|
|
911
963
|
resolveValues: platform === "native" ? "except-theme" : "variable",
|
|
912
964
|
noClass: platform === "native",
|
|
913
965
|
isAnimated: false,
|
|
914
966
|
displayName
|
|
915
|
-
}, void 0, void 0, void 0, void 0, void 0, void 0, animationDriver);
|
|
967
|
+
}, void 0, void 0, void 0, void 0, void 0, void 0, animationDriver, normalizedStyleConfigs.get(staticConfig));
|
|
916
968
|
} finally {
|
|
917
969
|
if (previousStatic === void 0) delete process.env.IS_STATIC;
|
|
918
970
|
else process.env.IS_STATIC = previousStatic;
|
|
@@ -925,7 +977,6 @@ function createTamaguiCompilerHost(options) {
|
|
|
925
977
|
baseStyle: void 0,
|
|
926
978
|
defaultProps: {},
|
|
927
979
|
defaultVariants: void 0,
|
|
928
|
-
compoundVariants: [],
|
|
929
980
|
variants: {}
|
|
930
981
|
});
|
|
931
982
|
const styleOwners = (name, value, staticConfig) => {
|
|
@@ -1031,6 +1082,9 @@ function createTamaguiCompilerHost(options) {
|
|
|
1031
1082
|
if (!options.disablePartialExtraction && valueKind === "conditional" && canLowerConditionalStyleProp(name, component)) {
|
|
1032
1083
|
return true;
|
|
1033
1084
|
}
|
|
1085
|
+
if (component.staticConfig.resolvers?.length) {
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1034
1088
|
return !options.disablePartialExtraction && (platform === "web" && !!directStyleName(name, component) || platform === "native" && directStyleName(name, component) === "opacity");
|
|
1035
1089
|
},
|
|
1036
1090
|
developmentDebugInstrumentation,
|
|
@@ -1061,9 +1115,30 @@ function createTamaguiCompilerHost(options) {
|
|
|
1061
1115
|
props[entry.name] = entry.value.value;
|
|
1062
1116
|
}
|
|
1063
1117
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1118
|
+
if (component.staticConfig.resolvers?.length) {
|
|
1119
|
+
const unresolvedProps = input.element.entries.filter((entry) => entry.kind === "prop" && entry.value.kind !== "static");
|
|
1120
|
+
const onlyStaticBranchConditional = unresolvedProps.length === 1 && unresolvedProps[0]?.kind === "prop" && unresolvedProps[0].value.kind === "conditional" && canLowerConditionalStyleProp(unresolvedProps[0].name, component);
|
|
1121
|
+
const unresolvedProp = onlyStaticBranchConditional ? void 0 : unresolvedProps[0];
|
|
1122
|
+
if (unresolvedProp?.kind === "prop") {
|
|
1123
|
+
return bailout(input, "local/dynamic-style-value", `Component resolver prop ${unresolvedProp.name} could not be evaluated`, unresolvedProp.span, void 0, unresolvedProp.name);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
const componentOnlyProp = (name) => {
|
|
1127
|
+
let span;
|
|
1128
|
+
let unknown = false;
|
|
1129
|
+
for (const entry of input.element.entries) {
|
|
1130
|
+
if (entry.kind !== "prop" || entry.name !== name) continue;
|
|
1131
|
+
span = entry.span;
|
|
1132
|
+
if (entry.value.kind !== "static") unknown = true;
|
|
1133
|
+
}
|
|
1134
|
+
return {
|
|
1135
|
+
unknown,
|
|
1136
|
+
span
|
|
1137
|
+
};
|
|
1138
|
+
};
|
|
1139
|
+
const disableOptimization = componentOnlyProp("disableOptimization");
|
|
1140
|
+
if (disableOptimization.unknown || props.disableOptimization) {
|
|
1141
|
+
return bailout(input, "local/unsupported-target", "disableOptimization keeps the component on the runtime path", disableOptimization.span);
|
|
1067
1142
|
}
|
|
1068
1143
|
if (component.domTag && props.hidden) props.display = "none";
|
|
1069
1144
|
if (component.domTag && platform === "native") {
|
|
@@ -1086,7 +1161,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1086
1161
|
return bailout(input, "local/unsupported-target", `${runtimeEvent} requires Tamagui runtime event mapping`);
|
|
1087
1162
|
}
|
|
1088
1163
|
}
|
|
1089
|
-
const animationDefaultProps =
|
|
1164
|
+
const animationDefaultProps = component.staticConfig.defaultProps ?? {};
|
|
1090
1165
|
const animationProps = core.mergeProps(animationDefaultProps, props);
|
|
1091
1166
|
const animationNames = /* @__PURE__ */ new Set([...input.element.entries.flatMap((entry) => entry.kind === "prop" && runtimeAnimationProps.has(entry.name) ? [entry.name] : []), ...Object.keys(animationProps).filter((name) => runtimeAnimationProps.has(name) && animationProps[name] !== void 0)]);
|
|
1092
1167
|
const animateOnlyEntry = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "animateOnly");
|
|
@@ -1130,7 +1205,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1130
1205
|
const expression = input.source.slice(entry.value.span.start, entry.value.span.end);
|
|
1131
1206
|
if (resolvedCssTransition !== null && (name === "opacity" || name === "scale")) {
|
|
1132
1207
|
property = name === "opacity" ? `opacity: (${expression})` : `transform: "scale(" + (${expression}) + ")"`;
|
|
1133
|
-
} else if (entry.value.kind === "bailout" && owners.
|
|
1208
|
+
} else if (entry.value.kind === "bailout" && owners.has(name)) {
|
|
1134
1209
|
const dynamic = entry.value.dynamic;
|
|
1135
1210
|
if (dynamic?.type === "number") {
|
|
1136
1211
|
property = `${JSON.stringify(name)}: (${expression})`;
|
|
@@ -1168,16 +1243,19 @@ function createTamaguiCompilerHost(options) {
|
|
|
1168
1243
|
}
|
|
1169
1244
|
}
|
|
1170
1245
|
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));
|
|
1171
|
-
|
|
1172
|
-
|
|
1246
|
+
const themeEntry = componentOnlyProp("theme");
|
|
1247
|
+
const themeInverseEntry = componentOnlyProp("themeInverse");
|
|
1248
|
+
const themeBoundary = themeEntry.unknown || "theme" in props;
|
|
1249
|
+
if (themeBoundary || themeInverseEntry.unknown || props.themeInverse) {
|
|
1250
|
+
const themeProp = themeBoundary ? "theme" : "themeInverse";
|
|
1173
1251
|
return bailout(input, "local/unsupported-target", "Theme boundary candidates remain on the runtime path", input.element.span, {
|
|
1174
1252
|
rule: 4,
|
|
1175
1253
|
message: zeroThemeBoundaryMessage(input.element.component.name, themeProp)
|
|
1176
1254
|
});
|
|
1177
1255
|
}
|
|
1178
|
-
const
|
|
1179
|
-
if (
|
|
1180
|
-
return bailout(input, "local/unsupported-target", "asChild renders a Slot, not a host view",
|
|
1256
|
+
const asChild = componentOnlyProp("asChild");
|
|
1257
|
+
if (asChild.unknown || props.asChild) {
|
|
1258
|
+
return bailout(input, "local/unsupported-target", "asChild renders a Slot, not a host view", asChild.span);
|
|
1181
1259
|
}
|
|
1182
1260
|
if (platform === "native" && ("group" in props || "container" in props || "containerName" in props || "containerType" in props)) {
|
|
1183
1261
|
return bailout(input, "local/unsupported-target", "Native group and container providers remain on the runtime path");
|
|
@@ -1276,12 +1354,17 @@ function createTamaguiCompilerHost(options) {
|
|
|
1276
1354
|
const entry = dynamicStyleEntries[0];
|
|
1277
1355
|
return bailout(input, "local/dynamic-style-value", `Style prop ${entry.kind === "prop" ? entry.name : "unknown"} could not be safely extracted`, entry.span);
|
|
1278
1356
|
}
|
|
1279
|
-
const
|
|
1357
|
+
const resolvedStyleStaticConfig = core.getStyleStaticConfig(component.staticConfig, core.getConfig());
|
|
1358
|
+
const staticDefaultProps = resolvedStyleStaticConfig.defaultProps ?? {};
|
|
1280
1359
|
const defaultProps = platform === "web" && !component.staticConfig.isText && options.tamaguiConfig.settings.defaultPosition === "relative" && staticDefaultProps.position === void 0 ? core.mergeProps({ position: "relative" }, staticDefaultProps) : staticDefaultProps;
|
|
1281
1360
|
let completeProps = core.mergeProps(defaultProps, props);
|
|
1282
1361
|
if (platform === "native" && component.domTag && props.display === "flex") {
|
|
1283
1362
|
completeProps = core.mergeProps(core.mergeProps(defaultProps, NATIVE_FLEX_DEFAULTS), props);
|
|
1284
1363
|
}
|
|
1364
|
+
const domStyleProgram = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "style" && entry.value.kind === "dom-style");
|
|
1365
|
+
if (platform === "native" && !component.domTag && domStyleProgram) {
|
|
1366
|
+
return bailout(input, "local/unsupported-target", "Native style() pieces remain on the runtime path");
|
|
1367
|
+
}
|
|
1285
1368
|
const propsForConditional = (target, value) => {
|
|
1286
1369
|
const branchProps = {};
|
|
1287
1370
|
for (const entry of input.element.entries) {
|
|
@@ -1309,6 +1392,14 @@ function createTamaguiCompilerHost(options) {
|
|
|
1309
1392
|
}
|
|
1310
1393
|
}
|
|
1311
1394
|
const branchCompleteProps = platform === "native" && component.domTag && branchProps.display === "flex" ? core.mergeProps(core.mergeProps(defaultProps, NATIVE_FLEX_DEFAULTS), branchProps) : core.mergeProps(defaultProps, branchProps);
|
|
1395
|
+
if (platform === "native") {
|
|
1396
|
+
for (const [name, value2] of Object.entries(branchCompleteProps)) {
|
|
1397
|
+
const clause = isStyleProp(name, component) ? nativeClauseValue(value2) : null;
|
|
1398
|
+
if (clause === null || clause === "live") continue;
|
|
1399
|
+
if (clause.matched) branchCompleteProps[name] = clause.payload;
|
|
1400
|
+
else delete branchCompleteProps[name];
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1312
1403
|
return {
|
|
1313
1404
|
branchProps,
|
|
1314
1405
|
branchCompleteProps
|
|
@@ -1317,10 +1408,30 @@ function createTamaguiCompilerHost(options) {
|
|
|
1317
1408
|
if (platform === "native") {
|
|
1318
1409
|
const isClauseValue = (name, value) => isStyleProp(name, component) && (typeof value === "string" && flatClausePattern.test(value) || isClauseObjectValue(value));
|
|
1319
1410
|
const defaultVariants = component.staticConfig.defaultVariants ?? {};
|
|
1320
|
-
const
|
|
1321
|
-
if (
|
|
1411
|
+
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))));
|
|
1412
|
+
if (definitionCarriesClause) {
|
|
1322
1413
|
return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1323
1414
|
}
|
|
1415
|
+
const reducedProps = {};
|
|
1416
|
+
for (const [name, value] of Object.entries(completeProps)) {
|
|
1417
|
+
const clause = isStyleProp(name, component) ? nativeClauseValue(value) : null;
|
|
1418
|
+
if (clause === "live") {
|
|
1419
|
+
return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1420
|
+
}
|
|
1421
|
+
if (clause === null) {
|
|
1422
|
+
reducedProps[name] = value;
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if (clause.matched) reducedProps[name] = clause.payload;
|
|
1426
|
+
}
|
|
1427
|
+
completeProps = reducedProps;
|
|
1428
|
+
for (const entry of dynamicStyleEntries) {
|
|
1429
|
+
if (entry.value.kind !== "conditional") continue;
|
|
1430
|
+
for (const leaf of collectLeaves(entry.value.tree)) {
|
|
1431
|
+
if (nativeClauseValue(leaf.value) !== "live") continue;
|
|
1432
|
+
return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1324
1435
|
}
|
|
1325
1436
|
const split = resolveSplitStyles(completeProps, component.staticConfig, cssAnimationDriver, component.displayName);
|
|
1326
1437
|
if (!split) {
|
|
@@ -1332,7 +1443,6 @@ function createTamaguiCompilerHost(options) {
|
|
|
1332
1443
|
message: zeroRuleMessage(5, { detail: `an enter or exit style program on ${input.element.component.name}` })
|
|
1333
1444
|
});
|
|
1334
1445
|
}
|
|
1335
|
-
const domStyleProgram = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "style" && entry.value.kind === "dom-style");
|
|
1336
1446
|
const flatTag = component.domTag ?? (typeof props.render === "string" ? props.render : typeof defaultProps.render === "string" ? defaultProps.render : component.staticConfig.isText ? "span" : "div");
|
|
1337
1447
|
const tagEdits = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1338
1448
|
start: span.start,
|
|
@@ -1340,7 +1450,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1340
1450
|
content: input.element.form === "jsx" ? flatTag : JSON.stringify(flatTag),
|
|
1341
1451
|
origin: span
|
|
1342
1452
|
}));
|
|
1343
|
-
const isPropIgnored = (name) => isStyleProp(name, component) || isInvalidHostStyleProp(name, component);
|
|
1453
|
+
const isPropIgnored = (name) => isStyleProp(name, component) || isInvalidHostStyleProp(name, component) || componentOnlyProps.has(name);
|
|
1344
1454
|
const spreadReplacement = (form, entry) => spreadNonStyleReplacement(form, entry, isPropIgnored, (name, value) => {
|
|
1345
1455
|
if (platform !== "web") return [name, value];
|
|
1346
1456
|
if (name === "testID") return ["data-testid", value];
|
|
@@ -1350,7 +1460,7 @@ function createTamaguiCompilerHost(options) {
|
|
|
1350
1460
|
}
|
|
1351
1461
|
return [name, value];
|
|
1352
1462
|
});
|
|
1353
|
-
let styleEntries = input.element.entries.filter((entry) => entry.kind === "prop" && (
|
|
1463
|
+
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));
|
|
1354
1464
|
let invalidHostStyle;
|
|
1355
1465
|
for (const entry of input.element.entries) {
|
|
1356
1466
|
if (entry.kind === "prop") {
|
|
@@ -2018,7 +2128,7 @@ const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
|
2018
2128
|
}
|
|
2019
2129
|
};
|
|
2020
2130
|
}
|
|
2021
|
-
function bailout(input, code, message, span = input.element.span, zero) {
|
|
2131
|
+
function bailout(input, code, message, span = input.element.span, zero, prop) {
|
|
2022
2132
|
return {
|
|
2023
2133
|
ok: false,
|
|
2024
2134
|
bailout: {
|
|
@@ -2027,6 +2137,7 @@ function bailout(input, code, message, span = input.element.span, zero) {
|
|
|
2027
2137
|
message,
|
|
2028
2138
|
span,
|
|
2029
2139
|
component: input.element.component.name,
|
|
2140
|
+
...prop && { prop },
|
|
2030
2141
|
...zero && {
|
|
2031
2142
|
zeroRule: zero.rule,
|
|
2032
2143
|
zeroMessage: zero.message
|
|
@@ -2035,5 +2146,5 @@ function bailout(input, code, message, span = input.element.span, zero) {
|
|
|
2035
2146
|
};
|
|
2036
2147
|
}
|
|
2037
2148
|
|
|
2038
|
-
export { createTamaguiCompilerHost };
|
|
2149
|
+
export { createComponentRegistry, createTamaguiCompilerHost };
|
|
2039
2150
|
//# sourceMappingURL=compilerHost.mjs.map
|