@tamagui/static 2.7.7 → 3.0.0-beta.643.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/check-dep-versions.cjs +355 -0
- package/dist/cjs/checkDeps.cjs +302 -0
- package/dist/cjs/compiler.cjs +286 -0
- package/dist/cjs/compilerHost.cjs +1695 -0
- package/dist/cjs/constants.cjs +33 -0
- package/dist/cjs/domStructuralPass.cjs +112 -0
- package/dist/cjs/exports.cjs +42 -0
- package/dist/cjs/extractor/addLocalExports.cjs +64 -0
- package/dist/cjs/extractor/bundle.cjs +203 -0
- package/dist/cjs/extractor/bundleConfig.cjs +747 -0
- package/dist/cjs/extractor/concatClassName.cjs +117 -0
- package/dist/cjs/extractor/detectModuleFormat.cjs +54 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.cjs +47 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +92 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +38 -0
- package/dist/cjs/extractor/loadTamagui.cjs +344 -0
- package/dist/cjs/extractor/regenerateConfig.cjs +161 -0
- package/dist/cjs/extractor/watchTamaguiConfig.cjs +64 -0
- package/dist/cjs/getPragmaOptions.cjs +67 -0
- package/dist/cjs/helpers/memoize.cjs +42 -0
- package/dist/cjs/helpers/requireTamaguiCore.cjs +40 -0
- package/dist/cjs/index.cjs +34 -0
- package/dist/cjs/registerRequire.cjs +220 -0
- package/dist/cjs/server.cjs +66 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +86 -0
- package/dist/cjs/types.cjs +17 -0
- package/dist/cjs/zero/artifact.cjs +145 -0
- package/dist/cjs/zero/graph.cjs +209 -0
- package/dist/cjs/zero/identity.cjs +61 -0
- package/dist/cjs/zero/index.cjs +26 -0
- package/dist/cjs/zero/islands.cjs +232 -0
- package/dist/cjs/zero/options.cjs +163 -0
- package/dist/cjs/zero/ownership.cjs +79 -0
- package/dist/cjs/zero/theme.cjs +328 -0
- package/dist/cjs/zero/transform.cjs +203 -0
- package/dist/esm/check-dep-versions.mjs +329 -0
- package/dist/esm/check-dep-versions.mjs.map +1 -0
- package/dist/esm/checkDeps.mjs +279 -0
- package/dist/esm/checkDeps.mjs.map +1 -0
- package/dist/esm/compiler.mjs +255 -0
- package/dist/esm/compiler.mjs.map +1 -0
- package/dist/esm/compilerHost.mjs +1675 -0
- package/dist/esm/compilerHost.mjs.map +1 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +92 -0
- package/dist/esm/domStructuralPass.mjs.map +1 -0
- package/dist/esm/exports.mjs +26 -0
- package/dist/esm/extractor/addLocalExports.mjs +44 -0
- package/dist/esm/extractor/addLocalExports.mjs.map +1 -0
- package/dist/esm/extractor/bundle.mjs +173 -0
- package/dist/esm/extractor/bundle.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.mjs +706 -0
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -0
- package/dist/esm/extractor/concatClassName.mjs +96 -0
- package/dist/esm/extractor/concatClassName.mjs.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.mjs +31 -0
- package/dist/esm/extractor/detectModuleFormat.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs +26 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +18 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +306 -0
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -0
- package/dist/esm/extractor/regenerateConfig.mjs +131 -0
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs +43 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.mjs +46 -0
- package/dist/esm/getPragmaOptions.mjs.map +1 -0
- package/dist/esm/helpers/memoize.mjs +21 -0
- package/dist/esm/helpers/memoize.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs +19 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/registerRequire.mjs +195 -0
- package/dist/esm/registerRequire.mjs.map +1 -0
- package/dist/esm/server.mjs +40 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/setup.mjs +0 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs +61 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/zero/artifact.mjs +119 -0
- package/dist/esm/zero/artifact.mjs.map +1 -0
- package/dist/esm/zero/graph.mjs +170 -0
- package/dist/esm/zero/graph.mjs.map +1 -0
- package/dist/esm/zero/identity.mjs +36 -0
- package/dist/esm/zero/identity.mjs.map +1 -0
- package/dist/esm/zero/index.mjs +15 -0
- package/dist/esm/zero/islands.mjs +197 -0
- package/dist/esm/zero/islands.mjs.map +1 -0
- package/dist/esm/zero/options.mjs +129 -0
- package/dist/esm/zero/options.mjs.map +1 -0
- package/dist/esm/zero/ownership.mjs +48 -0
- package/dist/esm/zero/ownership.mjs.map +1 -0
- package/dist/esm/zero/theme.mjs +303 -0
- package/dist/esm/zero/theme.mjs.map +1 -0
- package/dist/esm/zero/transform.mjs +177 -0
- package/dist/esm/zero/transform.mjs.map +1 -0
- package/package.json +33 -43
- package/src/check-dep-versions.ts +2 -2
- package/src/checkDeps.ts +3 -2
- package/src/compiler.ts +425 -0
- package/src/compilerHost.ts +3125 -0
- package/src/constants.ts +0 -5
- package/src/domStructuralPass.ts +170 -0
- package/src/exports.ts +3 -6
- package/src/extractor/addLocalExports.ts +49 -0
- package/src/extractor/bundle.ts +20 -35
- package/src/extractor/bundleConfig.ts +334 -187
- package/src/extractor/concatClassName.ts +13 -20
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +5 -4
- package/src/extractor/loadTamagui.ts +196 -143
- package/src/extractor/regenerateConfig.ts +65 -13
- package/src/extractor/watchTamaguiConfig.ts +6 -1
- package/src/helpers/requireTamaguiCore.ts +6 -1
- package/src/registerRequire.ts +94 -132
- package/src/staticEvaluationIgnoredModules.ts +74 -0
- package/src/types.ts +2 -107
- package/src/zero/artifact.ts +142 -0
- package/src/zero/graph.ts +359 -0
- package/src/zero/identity.ts +73 -0
- package/src/zero/index.ts +8 -0
- package/src/zero/islands.ts +262 -0
- package/src/zero/options.ts +239 -0
- package/src/zero/ownership.ts +113 -0
- package/src/zero/theme.ts +478 -0
- package/src/zero/transform.ts +320 -0
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/compiler.d.ts +117 -0
- package/types/compiler.d.ts.map +1 -0
- package/types/compilerHost.d.ts +25 -0
- package/types/compilerHost.d.ts.map +1 -0
- package/types/constants.d.ts +0 -1
- package/types/constants.d.ts.map +1 -1
- package/types/domStructuralPass.d.ts +3 -0
- package/types/domStructuralPass.d.ts.map +1 -0
- package/types/exports.d.ts +3 -6
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/addLocalExports.d.ts +3 -0
- package/types/extractor/addLocalExports.d.ts.map +1 -0
- package/types/extractor/bundle.d.ts +66 -65
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +19 -4
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +26 -3
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchTamaguiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +2 -2
- package/types/registerRequire.d.ts.map +1 -1
- package/types/staticEvaluationIgnoredModules.d.ts +9 -0
- package/types/staticEvaluationIgnoredModules.d.ts.map +1 -0
- package/types/types.d.ts +2 -90
- package/types/types.d.ts.map +1 -1
- package/types/zero/artifact.d.ts +44 -0
- package/types/zero/artifact.d.ts.map +1 -0
- package/types/zero/graph.d.ts +139 -0
- package/types/zero/graph.d.ts.map +1 -0
- package/types/zero/identity.d.ts +33 -0
- package/types/zero/identity.d.ts.map +1 -0
- package/types/zero/index.d.ts +9 -0
- package/types/zero/index.d.ts.map +1 -0
- package/types/zero/islands.d.ts +56 -0
- package/types/zero/islands.d.ts.map +1 -0
- package/types/zero/options.d.ts +58 -0
- package/types/zero/options.d.ts.map +1 -0
- package/types/zero/ownership.d.ts +51 -0
- package/types/zero/ownership.d.ts.map +1 -0
- package/types/zero/theme.d.ts +83 -0
- package/types/zero/theme.d.ts.map +1 -0
- package/types/zero/transform.d.ts +53 -0
- package/types/zero/transform.d.ts.map +1 -0
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -48
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -129
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1968
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -108
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -475
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadTamagui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -100
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchTamaguiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireTamaguiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
- package/src/extractor/accessSafe.ts +0 -22
- package/src/extractor/babelParse.ts +0 -38
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/createEvaluator.ts +0 -82
- package/src/extractor/createExtractor.ts +0 -2970
- package/src/extractor/createLogger.ts +0 -41
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/errors.ts +0 -1
- package/src/extractor/evaluateAstNode.ts +0 -136
- package/src/extractor/extractHelpers.ts +0 -211
- package/src/extractor/extractMediaStyle.ts +0 -194
- package/src/extractor/extractToClassNames.ts +0 -733
- package/src/extractor/extractToNative.ts +0 -506
- package/src/extractor/findTopmostFunction.ts +0 -24
- package/src/extractor/generatedUid.ts +0 -41
- package/src/extractor/getPrefixLogs.ts +0 -9
- package/src/extractor/getPropValueFromAttributes.ts +0 -95
- package/src/extractor/getSourceModule.ts +0 -96
- package/src/extractor/getStaticBindingsForScope.ts +0 -237
- package/src/extractor/hasTopLevelAwait.ts +0 -28
- package/src/extractor/hoistClassNames.ts +0 -52
- package/src/extractor/literalToAst.ts +0 -85
- package/src/extractor/loadFile.ts +0 -17
- package/src/extractor/logLines.ts +0 -16
- package/src/extractor/normalizeTernaries.ts +0 -89
- package/src/extractor/propsToFontFamilyCache.ts +0 -18
- package/src/extractor/removeUnusedHooks.ts +0 -83
- package/src/extractor/timer.ts +0 -25
- package/src/extractor/validHTMLAttributes.ts +0 -52
- package/src/worker.ts +0 -142
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts +0 -12
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts +0 -32
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/createLogger.d.ts +0 -3
- package/types/extractor/createLogger.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/errors.d.ts +0 -3
- package/types/extractor/errors.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts +0 -28
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -11
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts +0 -25
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/extractToNative.d.ts +0 -13
- package/types/extractor/extractToNative.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts +0 -3
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -19
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -5
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hasTopLevelAwait.d.ts +0 -2
- package/types/extractor/hasTopLevelAwait.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadFile.d.ts +0 -1
- package/types/extractor/loadFile.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts +0 -5
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +0 -4
- package/types/extractor/propsToFontFamilyCache.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -52
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/worker.d.ts +0 -46
- package/types/worker.d.ts.map +0 -1
- /package/dist/{setup.cjs → cjs/setup.cjs} +0 -0
|
@@ -0,0 +1,1695 @@
|
|
|
1
|
+
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var compilerHost_exports = {};
|
|
23
|
+
__export(compilerHost_exports, { createTamaguiCompilerHost: () => createTamaguiCompilerHost });
|
|
24
|
+
module.exports = __toCommonJS(compilerHost_exports);
|
|
25
|
+
var import_compiler_core = require("@tamagui/compiler-core");
|
|
26
|
+
var import_helpers = require("@tamagui/helpers");
|
|
27
|
+
var import_dom = require("@tamagui/dom");
|
|
28
|
+
var import_style_grammar = require("@tamagui/style-grammar");
|
|
29
|
+
var import_web = require("@tamagui/web");
|
|
30
|
+
var import_concatClassName = require("./extractor/concatClassName.cjs");
|
|
31
|
+
var import_requireTamaguiCore = require("./helpers/requireTamaguiCore.cjs");
|
|
32
|
+
const DOM_FRONTENDS = /* @__PURE__ */ new Set([
|
|
33
|
+
"tamagui",
|
|
34
|
+
"tamagui/dom",
|
|
35
|
+
"@tamagui/core",
|
|
36
|
+
"@tamagui/core/dom",
|
|
37
|
+
"@tamagui/tailwind"
|
|
38
|
+
]);
|
|
39
|
+
const componentState = {
|
|
40
|
+
focus: false,
|
|
41
|
+
focusVisible: false,
|
|
42
|
+
focusWithin: false,
|
|
43
|
+
hover: false,
|
|
44
|
+
unmounted: true,
|
|
45
|
+
press: false,
|
|
46
|
+
pressIn: false,
|
|
47
|
+
disabled: false
|
|
48
|
+
};
|
|
49
|
+
function staticObject(value) {
|
|
50
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
const flatClausePattern = /(?:^|\s)@?[A-Za-z][A-Za-z0-9-]*(?:\/[A-Za-z0-9_-]+)?:/;
|
|
53
|
+
const nativeInheritedKeywordPattern = /(?:^|:)(?:inherit|unset)(?=\s|$)/;
|
|
54
|
+
const nativeInitialKeywordPattern = /(?:^|:)initial(?=\s|$)/;
|
|
55
|
+
const nativeRuntimeOnlyStyleProperties = /* @__PURE__ */ new Set(["textIndent"]);
|
|
56
|
+
function componentKey(resolvedId, exportName) {
|
|
57
|
+
return `${resolvedId}#${exportName}`;
|
|
58
|
+
}
|
|
59
|
+
function cssFromRules(rules) {
|
|
60
|
+
return Object.values(rules).flatMap((styleObject) => {
|
|
61
|
+
const identifier = styleObject?.[import_helpers.StyleObjectIdentifier];
|
|
62
|
+
const styleRules = styleObject?.[import_helpers.StyleObjectRules];
|
|
63
|
+
return identifier && Array.isArray(styleRules) ? styleRules : [];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function jsxClassName(value) {
|
|
67
|
+
return `className=${JSON.stringify(value)}`;
|
|
68
|
+
}
|
|
69
|
+
function objectClassName(value) {
|
|
70
|
+
return `className: ${JSON.stringify(value)}`;
|
|
71
|
+
}
|
|
72
|
+
function serializedStyle(style, dynamicProperties) {
|
|
73
|
+
if (dynamicProperties.length === 0) return style ? JSON.stringify(style) : "";
|
|
74
|
+
return `{ ${[...style ? Object.entries(style).map(([name, value]) => `${JSON.stringify(name)}: ${JSON.stringify(value)}`) : [], ...dynamicProperties].join(", ")} }`;
|
|
75
|
+
}
|
|
76
|
+
function jsxStyleAttributes(className, style, dynamicProperties = []) {
|
|
77
|
+
const serialized = serializedStyle(style, dynamicProperties);
|
|
78
|
+
return [className ? jsxClassName(className) : "", serialized ? `style={${serialized}}` : ""].filter(Boolean).join(" ");
|
|
79
|
+
}
|
|
80
|
+
function objectStyleProperties(className, style, dynamicProperties = []) {
|
|
81
|
+
const serialized = serializedStyle(style, dynamicProperties);
|
|
82
|
+
return [className ? objectClassName(className) : "", serialized ? `style: ${serialized}` : ""].filter(Boolean).join(", ");
|
|
83
|
+
}
|
|
84
|
+
function extractedStyleArtifacts(split, props, config, includeRuntimeBase = true, hasStyleFrontend = false) {
|
|
85
|
+
const callerClassName = !hasStyleFrontend && typeof props.className === "string" ? props.className : "";
|
|
86
|
+
const viewClassName = typeof split.viewProps?.className === "string" ? split.viewProps.className : "";
|
|
87
|
+
const classNameWithoutCaller = callerClassName && viewClassName.endsWith(callerClassName) ? viewClassName.slice(0, -callerClassName.length).trimEnd() : viewClassName;
|
|
88
|
+
const rules = split.rulesToInsert ?? {};
|
|
89
|
+
const mediaNames = new Set(Object.keys(config.media ?? {}));
|
|
90
|
+
const pseudoNames = [
|
|
91
|
+
"hover",
|
|
92
|
+
"press",
|
|
93
|
+
"focus",
|
|
94
|
+
"focusVisible",
|
|
95
|
+
"focusWithin",
|
|
96
|
+
"disabled"
|
|
97
|
+
];
|
|
98
|
+
const buckets = {
|
|
99
|
+
group: [],
|
|
100
|
+
normal: [],
|
|
101
|
+
pseudo: [],
|
|
102
|
+
theme: [],
|
|
103
|
+
media: []
|
|
104
|
+
};
|
|
105
|
+
const classKeys = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const [key, identifier] of Object.entries(split.classNames ?? {})) if (typeof identifier === "string") classKeys.set(identifier, key);
|
|
107
|
+
const identifiers = /* @__PURE__ */ new Set([...classKeys.keys(), ...Object.values(rules).flatMap((styleObject) => {
|
|
108
|
+
const identifier = styleObject?.[import_helpers.StyleObjectIdentifier];
|
|
109
|
+
return typeof identifier === "string" ? [identifier] : [];
|
|
110
|
+
})]);
|
|
111
|
+
for (const identifier of identifiers) {
|
|
112
|
+
const key = classKeys.get(identifier) ?? "";
|
|
113
|
+
const css2 = cssFromRules(Object.fromEntries(Object.entries(rules).filter(([, styleObject]) => styleObject?.[import_helpers.StyleObjectIdentifier] === identifier))).join("");
|
|
114
|
+
if (identifier.startsWith("t_group_")) buckets.group.push(identifier);
|
|
115
|
+
else if (pseudoNames.some((name) => key.endsWith(`-${name}`))) buckets.pseudo.push(identifier);
|
|
116
|
+
else if (css2.includes(".t_")) buckets.theme.push(identifier);
|
|
117
|
+
else if ([...mediaNames].some((name) => key.endsWith(`-${name}`))) buckets.media.push(identifier);
|
|
118
|
+
else buckets.normal.push(identifier);
|
|
119
|
+
}
|
|
120
|
+
const orderedIdentifiers = [
|
|
121
|
+
...buckets.group,
|
|
122
|
+
...buckets.normal,
|
|
123
|
+
...buckets.pseudo,
|
|
124
|
+
...buckets.theme,
|
|
125
|
+
...buckets.media
|
|
126
|
+
];
|
|
127
|
+
const orderedSet = new Set(orderedIdentifiers);
|
|
128
|
+
const baseViewClassName = includeRuntimeBase ? classNameWithoutCaller.split(/\s+/).filter((token) => token && !orderedSet.has(token)).join(" ") : "";
|
|
129
|
+
const css = orderedIdentifiers.flatMap((identifier) => {
|
|
130
|
+
const identifierRules = cssFromRules(Object.fromEntries(Object.entries(rules).filter(([, styleObject]) => styleObject?.[import_helpers.StyleObjectIdentifier] === identifier)));
|
|
131
|
+
return buckets.theme.includes(identifier) ? identifierRules.map((rule) => rule.replace(":root:root:root.t_", ":root:root:root:root.t_")) : identifierRules;
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
className: (0, import_concatClassName.concatClassName)(baseViewClassName, orderedIdentifiers, callerClassName),
|
|
135
|
+
css
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function compiledPropsEdits(input, styleEntries, replacement) {
|
|
139
|
+
const propsSpan = input.element.propsSpan;
|
|
140
|
+
if (!propsSpan) return null;
|
|
141
|
+
const original = input.source.slice(propsSpan.start, propsSpan.end);
|
|
142
|
+
const trimmed = original.trim();
|
|
143
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return [{
|
|
144
|
+
start: propsSpan.start,
|
|
145
|
+
end: propsSpan.end,
|
|
146
|
+
content: `{ ${replacement} }`,
|
|
147
|
+
origin: propsSpan
|
|
148
|
+
}];
|
|
149
|
+
if (styleEntries.length === 0) {
|
|
150
|
+
const close = original.lastIndexOf("}");
|
|
151
|
+
const separator = original.slice(1, close).trim() ? ", " : " ";
|
|
152
|
+
const position = propsSpan.start + close;
|
|
153
|
+
return [{
|
|
154
|
+
start: position,
|
|
155
|
+
end: position,
|
|
156
|
+
content: `${separator}${replacement} `,
|
|
157
|
+
origin: propsSpan
|
|
158
|
+
}];
|
|
159
|
+
}
|
|
160
|
+
const edits = [];
|
|
161
|
+
for (const [index, entry] of styleEntries.entries()) {
|
|
162
|
+
let start = entry.span.start;
|
|
163
|
+
let end = entry.span.end;
|
|
164
|
+
if (index === 0) {
|
|
165
|
+
edits.push({
|
|
166
|
+
start,
|
|
167
|
+
end,
|
|
168
|
+
content: replacement,
|
|
169
|
+
origin: entry.span
|
|
170
|
+
});
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
let cursor = end - propsSpan.start;
|
|
174
|
+
while (cursor < original.length - 1 && /\s/.test(original[cursor])) cursor++;
|
|
175
|
+
if (original[cursor] === ",") end = propsSpan.start + cursor + 1;
|
|
176
|
+
else {
|
|
177
|
+
cursor = start - propsSpan.start - 1;
|
|
178
|
+
while (cursor > 0 && /\s/.test(original[cursor])) cursor--;
|
|
179
|
+
if (original[cursor] === ",") start = propsSpan.start + cursor;
|
|
180
|
+
}
|
|
181
|
+
edits.push({
|
|
182
|
+
start,
|
|
183
|
+
end,
|
|
184
|
+
content: "",
|
|
185
|
+
origin: entry.span
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const merged = [];
|
|
189
|
+
for (const edit of edits.sort((left, right) => left.start - right.start)) {
|
|
190
|
+
const previous = merged.at(-1);
|
|
191
|
+
if (previous && edit.start <= previous.end && !previous.content && !edit.content) previous.end = Math.max(previous.end, edit.end);
|
|
192
|
+
else merged.push(edit);
|
|
193
|
+
}
|
|
194
|
+
return merged;
|
|
195
|
+
}
|
|
196
|
+
const compilerStyleProps = /* @__PURE__ */ new Set([
|
|
197
|
+
"className",
|
|
198
|
+
"style",
|
|
199
|
+
"group",
|
|
200
|
+
"transition",
|
|
201
|
+
"animation",
|
|
202
|
+
"animateOnly",
|
|
203
|
+
"animatePresence",
|
|
204
|
+
"animatedBy",
|
|
205
|
+
"fontFamily",
|
|
206
|
+
"render"
|
|
207
|
+
]);
|
|
208
|
+
const runtimeAnimationProps = /* @__PURE__ */ new Set([
|
|
209
|
+
"transition",
|
|
210
|
+
"animation",
|
|
211
|
+
"animateOnly",
|
|
212
|
+
"animatePresence",
|
|
213
|
+
"animatedBy"
|
|
214
|
+
]);
|
|
215
|
+
const cssShorthandConflicts = {
|
|
216
|
+
background: [
|
|
217
|
+
"backgroundAttachment",
|
|
218
|
+
"backgroundBlendMode",
|
|
219
|
+
"backgroundClip",
|
|
220
|
+
"backgroundColor",
|
|
221
|
+
"backgroundImage",
|
|
222
|
+
"backgroundOrigin",
|
|
223
|
+
"backgroundPosition",
|
|
224
|
+
"backgroundRepeat",
|
|
225
|
+
"backgroundSize"
|
|
226
|
+
],
|
|
227
|
+
border: [
|
|
228
|
+
"borderTop",
|
|
229
|
+
"borderTopColor",
|
|
230
|
+
"borderTopStyle",
|
|
231
|
+
"borderTopWidth",
|
|
232
|
+
"borderRight",
|
|
233
|
+
"borderRightColor",
|
|
234
|
+
"borderRightStyle",
|
|
235
|
+
"borderRightWidth",
|
|
236
|
+
"borderBottom",
|
|
237
|
+
"borderBottomColor",
|
|
238
|
+
"borderBottomStyle",
|
|
239
|
+
"borderBottomWidth",
|
|
240
|
+
"borderLeft",
|
|
241
|
+
"borderLeftColor",
|
|
242
|
+
"borderLeftStyle",
|
|
243
|
+
"borderLeftWidth",
|
|
244
|
+
"borderColor",
|
|
245
|
+
"borderStyle",
|
|
246
|
+
"borderWidth",
|
|
247
|
+
"borderImage",
|
|
248
|
+
"borderImageOutset",
|
|
249
|
+
"borderImageRepeat",
|
|
250
|
+
"borderImageSlice",
|
|
251
|
+
"borderImageSource",
|
|
252
|
+
"borderImageWidth",
|
|
253
|
+
"borderInlineColor",
|
|
254
|
+
"borderInlineEndColor",
|
|
255
|
+
"borderInlineEndStyle",
|
|
256
|
+
"borderInlineEndWidth",
|
|
257
|
+
"borderInlineStartColor",
|
|
258
|
+
"borderInlineStartStyle",
|
|
259
|
+
"borderInlineStartWidth",
|
|
260
|
+
"borderInlineStyle",
|
|
261
|
+
"borderInlineWidth"
|
|
262
|
+
],
|
|
263
|
+
borderTop: [
|
|
264
|
+
"borderTopColor",
|
|
265
|
+
"borderTopStyle",
|
|
266
|
+
"borderTopWidth"
|
|
267
|
+
],
|
|
268
|
+
borderRight: [
|
|
269
|
+
"borderRightColor",
|
|
270
|
+
"borderRightStyle",
|
|
271
|
+
"borderRightWidth",
|
|
272
|
+
"borderInlineColor",
|
|
273
|
+
"borderInlineEndColor",
|
|
274
|
+
"borderInlineEndStyle",
|
|
275
|
+
"borderInlineEndWidth",
|
|
276
|
+
"borderInlineStartColor",
|
|
277
|
+
"borderInlineStartStyle",
|
|
278
|
+
"borderInlineStartWidth",
|
|
279
|
+
"borderInlineStyle",
|
|
280
|
+
"borderInlineWidth"
|
|
281
|
+
],
|
|
282
|
+
borderBottom: [
|
|
283
|
+
"borderBottomColor",
|
|
284
|
+
"borderBottomStyle",
|
|
285
|
+
"borderBottomWidth"
|
|
286
|
+
],
|
|
287
|
+
borderLeft: [
|
|
288
|
+
"borderLeftColor",
|
|
289
|
+
"borderLeftStyle",
|
|
290
|
+
"borderLeftWidth",
|
|
291
|
+
"borderInlineColor",
|
|
292
|
+
"borderInlineEndColor",
|
|
293
|
+
"borderInlineEndStyle",
|
|
294
|
+
"borderInlineEndWidth",
|
|
295
|
+
"borderInlineStartColor",
|
|
296
|
+
"borderInlineStartStyle",
|
|
297
|
+
"borderInlineStartWidth",
|
|
298
|
+
"borderInlineStyle",
|
|
299
|
+
"borderInlineWidth"
|
|
300
|
+
],
|
|
301
|
+
borderImage: [
|
|
302
|
+
"borderImageOutset",
|
|
303
|
+
"borderImageRepeat",
|
|
304
|
+
"borderImageSlice",
|
|
305
|
+
"borderImageSource",
|
|
306
|
+
"borderImageWidth"
|
|
307
|
+
],
|
|
308
|
+
outline: [
|
|
309
|
+
"outlineColor",
|
|
310
|
+
"outlineStyle",
|
|
311
|
+
"outlineWidth"
|
|
312
|
+
],
|
|
313
|
+
gap: ["columnGap", "rowGap"],
|
|
314
|
+
gridColumn: ["gridColumnEnd", "gridColumnStart"],
|
|
315
|
+
gridRow: ["gridRowEnd", "gridRowStart"],
|
|
316
|
+
marginInline: [
|
|
317
|
+
"marginInlineEnd",
|
|
318
|
+
"marginInlineStart",
|
|
319
|
+
"marginEnd",
|
|
320
|
+
"marginStart",
|
|
321
|
+
"marginLeft",
|
|
322
|
+
"marginRight"
|
|
323
|
+
],
|
|
324
|
+
paddingInline: [
|
|
325
|
+
"paddingInlineEnd",
|
|
326
|
+
"paddingInlineStart",
|
|
327
|
+
"paddingEnd",
|
|
328
|
+
"paddingStart",
|
|
329
|
+
"paddingLeft",
|
|
330
|
+
"paddingRight"
|
|
331
|
+
],
|
|
332
|
+
insetInline: [
|
|
333
|
+
"insetInlineEnd",
|
|
334
|
+
"insetInlineStart",
|
|
335
|
+
"end",
|
|
336
|
+
"start",
|
|
337
|
+
"left",
|
|
338
|
+
"right"
|
|
339
|
+
],
|
|
340
|
+
borderInlineColor: [
|
|
341
|
+
"borderInlineEndColor",
|
|
342
|
+
"borderInlineStartColor",
|
|
343
|
+
"borderEndColor",
|
|
344
|
+
"borderStartColor",
|
|
345
|
+
"borderLeftColor",
|
|
346
|
+
"borderRightColor"
|
|
347
|
+
],
|
|
348
|
+
borderInlineStyle: [
|
|
349
|
+
"borderInlineEndStyle",
|
|
350
|
+
"borderInlineStartStyle",
|
|
351
|
+
"borderEndStyle",
|
|
352
|
+
"borderStartStyle",
|
|
353
|
+
"borderLeftStyle",
|
|
354
|
+
"borderRightStyle"
|
|
355
|
+
],
|
|
356
|
+
borderInlineWidth: [
|
|
357
|
+
"borderInlineEndWidth",
|
|
358
|
+
"borderInlineStartWidth",
|
|
359
|
+
"borderEndWidth",
|
|
360
|
+
"borderStartWidth",
|
|
361
|
+
"borderLeftWidth",
|
|
362
|
+
"borderRightWidth"
|
|
363
|
+
],
|
|
364
|
+
mask: [
|
|
365
|
+
"maskBorder",
|
|
366
|
+
"maskBorderMode",
|
|
367
|
+
"maskBorderOutset",
|
|
368
|
+
"maskBorderRepeat",
|
|
369
|
+
"maskBorderSlice",
|
|
370
|
+
"maskBorderSource",
|
|
371
|
+
"maskBorderWidth",
|
|
372
|
+
"maskClip",
|
|
373
|
+
"maskComposite",
|
|
374
|
+
"maskImage",
|
|
375
|
+
"maskMode",
|
|
376
|
+
"maskOrigin",
|
|
377
|
+
"maskPosition",
|
|
378
|
+
"maskRepeat",
|
|
379
|
+
"maskSize"
|
|
380
|
+
],
|
|
381
|
+
maskBorder: [
|
|
382
|
+
"maskBorderMode",
|
|
383
|
+
"maskBorderOutset",
|
|
384
|
+
"maskBorderRepeat",
|
|
385
|
+
"maskBorderSlice",
|
|
386
|
+
"maskBorderSource",
|
|
387
|
+
"maskBorderWidth"
|
|
388
|
+
]
|
|
389
|
+
};
|
|
390
|
+
const cssConflictFamilies = [
|
|
391
|
+
/* @__PURE__ */ new Set([
|
|
392
|
+
"marginInline",
|
|
393
|
+
"marginInlineEnd",
|
|
394
|
+
"marginInlineStart",
|
|
395
|
+
"marginEnd",
|
|
396
|
+
"marginStart",
|
|
397
|
+
"marginLeft",
|
|
398
|
+
"marginRight"
|
|
399
|
+
]),
|
|
400
|
+
/* @__PURE__ */ new Set([
|
|
401
|
+
"paddingInline",
|
|
402
|
+
"paddingInlineEnd",
|
|
403
|
+
"paddingInlineStart",
|
|
404
|
+
"paddingEnd",
|
|
405
|
+
"paddingStart",
|
|
406
|
+
"paddingLeft",
|
|
407
|
+
"paddingRight"
|
|
408
|
+
]),
|
|
409
|
+
/* @__PURE__ */ new Set([
|
|
410
|
+
"insetInline",
|
|
411
|
+
"insetInlineEnd",
|
|
412
|
+
"insetInlineStart",
|
|
413
|
+
"end",
|
|
414
|
+
"start",
|
|
415
|
+
"left",
|
|
416
|
+
"right"
|
|
417
|
+
]),
|
|
418
|
+
/* @__PURE__ */ new Set([
|
|
419
|
+
"borderInlineColor",
|
|
420
|
+
"borderInlineEndColor",
|
|
421
|
+
"borderInlineStartColor",
|
|
422
|
+
"borderEndColor",
|
|
423
|
+
"borderStartColor",
|
|
424
|
+
"borderLeftColor",
|
|
425
|
+
"borderRightColor"
|
|
426
|
+
]),
|
|
427
|
+
/* @__PURE__ */ new Set([
|
|
428
|
+
"borderInlineStyle",
|
|
429
|
+
"borderInlineEndStyle",
|
|
430
|
+
"borderInlineStartStyle",
|
|
431
|
+
"borderEndStyle",
|
|
432
|
+
"borderStartStyle",
|
|
433
|
+
"borderLeftStyle",
|
|
434
|
+
"borderRightStyle"
|
|
435
|
+
]),
|
|
436
|
+
/* @__PURE__ */ new Set([
|
|
437
|
+
"borderInlineWidth",
|
|
438
|
+
"borderInlineEndWidth",
|
|
439
|
+
"borderInlineStartWidth",
|
|
440
|
+
"borderEndWidth",
|
|
441
|
+
"borderStartWidth",
|
|
442
|
+
"borderLeftWidth",
|
|
443
|
+
"borderRightWidth"
|
|
444
|
+
])
|
|
445
|
+
];
|
|
446
|
+
function cssOwnersConflict(left, right) {
|
|
447
|
+
for (const leftOwner of left) for (const rightOwner of right) if (leftOwner === rightOwner || cssShorthandConflicts[leftOwner]?.includes(rightOwner) || cssShorthandConflicts[rightOwner]?.includes(leftOwner) || cssConflictFamilies.some((family) => family.has(leftOwner) && family.has(rightOwner))) return true;
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
const runtimeEventProps = /* @__PURE__ */ new Set([
|
|
451
|
+
"onHoverIn",
|
|
452
|
+
"onHoverOut",
|
|
453
|
+
"onLongPress",
|
|
454
|
+
"onPress",
|
|
455
|
+
"onPressIn",
|
|
456
|
+
"onPressOut"
|
|
457
|
+
]);
|
|
458
|
+
const DOM_STYLE_ATTRIBUTES = new Map(Object.entries(import_dom.ATTRIBUTES).filter(([name, row]) => row.native !== "none" && row.nativeProp && row.nativeProp !== name && row.nativeProp in import_helpers.stylePropsText).map(([name, row]) => [name, row.nativeProp]));
|
|
459
|
+
const nativePointerEventProps = /* @__PURE__ */ new Set([
|
|
460
|
+
"onPointerCancel",
|
|
461
|
+
"onPointerDown",
|
|
462
|
+
"onPointerEnter",
|
|
463
|
+
"onPointerLeave",
|
|
464
|
+
"onPointerMove",
|
|
465
|
+
"onPointerUp"
|
|
466
|
+
]);
|
|
467
|
+
function isSerializableNativeStyle(value) {
|
|
468
|
+
if (value == null || typeof value === "number" || typeof value === "boolean") return true;
|
|
469
|
+
if (typeof value === "string") return true;
|
|
470
|
+
if (Array.isArray(value)) return value.every(isSerializableNativeStyle);
|
|
471
|
+
if (!staticObject(value)) return false;
|
|
472
|
+
const prototype = Object.getPrototypeOf(value);
|
|
473
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
474
|
+
return Object.values(value).every(isSerializableNativeStyle);
|
|
475
|
+
}
|
|
476
|
+
function unusedIdentifier(source, base) {
|
|
477
|
+
let candidate = base;
|
|
478
|
+
let suffix = 0;
|
|
479
|
+
while (new RegExp(`\\b${candidate}\\b`).test(source)) candidate = `${base}${++suffix}`;
|
|
480
|
+
return candidate;
|
|
481
|
+
}
|
|
482
|
+
const VIEW_WRAPPER_PROPS = /^(aria-|accessibilityState$|accessibilityValue$|id$|tabIndex$|nativeID$)/;
|
|
483
|
+
function isBareHostView(element) {
|
|
484
|
+
return !element.entries.some((entry) => entry.kind === "child" || entry.kind === "spread" || entry.kind === "prop" && VIEW_WRAPPER_PROPS.test(entry.name));
|
|
485
|
+
}
|
|
486
|
+
function entrySource(input, entry) {
|
|
487
|
+
return entry.value.kind === "static" ? JSON.stringify(entry.value.value) : input.source.slice(entry.value.span.start, entry.value.span.end);
|
|
488
|
+
}
|
|
489
|
+
function renamedPropEdit(input, entry, name) {
|
|
490
|
+
if (entry.name === name) return null;
|
|
491
|
+
const content = input.source.slice(entry.span.start, entry.span.end);
|
|
492
|
+
const offset = content.indexOf(entry.name);
|
|
493
|
+
if (offset === -1) return null;
|
|
494
|
+
const quoted = content[offset - 1] === "\"" || content[offset - 1] === "'";
|
|
495
|
+
return {
|
|
496
|
+
start: entry.span.start + offset,
|
|
497
|
+
end: entry.span.start + offset + entry.name.length,
|
|
498
|
+
content: input.element.form === "jsx" || quoted ? name : JSON.stringify(name),
|
|
499
|
+
origin: entry.span
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function serializedProps(form, props) {
|
|
503
|
+
return props.map(([name, value]) => form === "jsx" ? `${name}={${value}}` : `${JSON.stringify(name)}: ${value}`).join(form === "jsx" ? " " : ", ");
|
|
504
|
+
}
|
|
505
|
+
function nativeDOMProps(input, tag) {
|
|
506
|
+
const consumed = [];
|
|
507
|
+
const edits = [];
|
|
508
|
+
const additions = [];
|
|
509
|
+
const nested = /* @__PURE__ */ new Map();
|
|
510
|
+
const entries = input.element.entries.filter((entry) => entry.kind === "prop");
|
|
511
|
+
const names = new Set(entries.map((entry) => entry.name));
|
|
512
|
+
if (names.has("ref") || tag === "br") additions.push(["__tag", JSON.stringify(tag)]);
|
|
513
|
+
if (import_dom.TAGS[tag].backing === "text" || import_dom.TAGS[tag].backing === "textinput") additions.push(["__inherit", "true"]);
|
|
514
|
+
const add = (name, value) => additions.push([name, value]);
|
|
515
|
+
const consume = (entry) => consumed.push(entry);
|
|
516
|
+
for (const entry of entries) {
|
|
517
|
+
const value = entrySource(input, entry);
|
|
518
|
+
const attribute = (Object.hasOwn(import_dom.ATTRIBUTES, entry.name) ? import_dom.ATTRIBUTES[entry.name] : void 0) ?? (entry.name.startsWith("data-") ? import_dom.ATTRIBUTES["data-*"] : void 0);
|
|
519
|
+
const event = Object.hasOwn(import_dom.EVENTS, entry.name) ? import_dom.EVENTS[entry.name] : void 0;
|
|
520
|
+
if (event) {
|
|
521
|
+
if (event.native === "none") return {
|
|
522
|
+
consumed,
|
|
523
|
+
edits,
|
|
524
|
+
additions,
|
|
525
|
+
diagnostic: `${entry.name} has no native DOM event equivalent`,
|
|
526
|
+
diagnosticSpan: entry.span
|
|
527
|
+
};
|
|
528
|
+
if (entry.name === "onKeyDown" && tag !== "input" && tag !== "textarea") return {
|
|
529
|
+
consumed,
|
|
530
|
+
edits,
|
|
531
|
+
additions,
|
|
532
|
+
diagnostic: `onKeyDown requires a native text-entry control`,
|
|
533
|
+
diagnosticSpan: entry.span
|
|
534
|
+
};
|
|
535
|
+
if ([
|
|
536
|
+
"onClick",
|
|
537
|
+
"onLoad",
|
|
538
|
+
"onError",
|
|
539
|
+
"onChange",
|
|
540
|
+
"onInput",
|
|
541
|
+
"onKeyDown"
|
|
542
|
+
].includes(entry.name)) continue;
|
|
543
|
+
if (event.nativeProp) {
|
|
544
|
+
const edit2 = renamedPropEdit(input, entry, event.nativeProp);
|
|
545
|
+
if (edit2) edits.push(edit2);
|
|
546
|
+
}
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (!attribute || attribute.native === "none" || entry.name === "style") continue;
|
|
550
|
+
if (DOM_STYLE_ATTRIBUTES.has(entry.name)) {
|
|
551
|
+
if (entry.value.kind !== "static") return {
|
|
552
|
+
consumed,
|
|
553
|
+
edits,
|
|
554
|
+
additions,
|
|
555
|
+
diagnostic: `html.${tag} ${entry.name} must be statically known for native lowering`,
|
|
556
|
+
diagnosticSpan: entry.span
|
|
557
|
+
};
|
|
558
|
+
consume(entry);
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (entry.name === "hidden") {
|
|
562
|
+
if (entry.value.kind !== "static") return {
|
|
563
|
+
consumed,
|
|
564
|
+
edits,
|
|
565
|
+
additions,
|
|
566
|
+
diagnostic: `html.${tag} hidden must be statically known for native lowering`,
|
|
567
|
+
diagnosticSpan: entry.span
|
|
568
|
+
};
|
|
569
|
+
consume(entry);
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (entry.name === "tabIndex") {
|
|
573
|
+
consume(entry);
|
|
574
|
+
add("focusable", `(${value}) === 0`);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
if (entry.name === "readOnly") {
|
|
578
|
+
consume(entry);
|
|
579
|
+
add("editable", `!(${value})`);
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
if (entry.name === "disabled") {
|
|
583
|
+
consume(entry);
|
|
584
|
+
add("disabled", value);
|
|
585
|
+
add("focusable", `!(${value})`);
|
|
586
|
+
if (tag === "input" || tag === "textarea") add("editable", `!(${value})`);
|
|
587
|
+
const state = nested.get("accessibilityState") ?? [];
|
|
588
|
+
state.push(["disabled", value]);
|
|
589
|
+
nested.set("accessibilityState", state);
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
if (entry.name === "type") {
|
|
593
|
+
consume(entry);
|
|
594
|
+
if (tag === "input" && entry.value.kind !== "static") return {
|
|
595
|
+
consumed,
|
|
596
|
+
edits,
|
|
597
|
+
additions,
|
|
598
|
+
diagnostic: `html.input type must be statically known for native lowering`,
|
|
599
|
+
diagnosticSpan: entry.span
|
|
600
|
+
};
|
|
601
|
+
if (tag === "input" && entry.value.kind === "static") {
|
|
602
|
+
const type = entry.value.value;
|
|
603
|
+
if (type === "password") add("secureTextEntry", "true");
|
|
604
|
+
else if (typeof type === "string" && type !== "text" && import_dom.NATIVE_INPUT_TYPES.includes(type)) {
|
|
605
|
+
if (!names.has("inputMode")) add("inputMode", JSON.stringify(type === "number" ? "numeric" : type));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
if (entry.name === "aria-hidden") {
|
|
611
|
+
consume(entry);
|
|
612
|
+
add("accessibilityElementsHidden", value);
|
|
613
|
+
add("importantForAccessibility", `(${value}) ? "no-hide-descendants" : "auto"`);
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
if (entry.name === "aria-live") {
|
|
617
|
+
consume(entry);
|
|
618
|
+
add("accessibilityLiveRegion", entry.value.kind === "static" && entry.value.value === "off" ? "\"none\"" : value);
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
const nativeProp = attribute.nativeProp;
|
|
622
|
+
if (!nativeProp) continue;
|
|
623
|
+
if (nativeProp.includes(".")) {
|
|
624
|
+
consume(entry);
|
|
625
|
+
const [parent, child] = nativeProp.split(".");
|
|
626
|
+
const values = nested.get(parent) ?? [];
|
|
627
|
+
values.push([child, value]);
|
|
628
|
+
nested.set(parent, values);
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
const edit = renamedPropEdit(input, entry, nativeProp);
|
|
632
|
+
if (edit) edits.push(edit);
|
|
633
|
+
}
|
|
634
|
+
for (const [name, values] of nested) add(name, `{ ${values.map(([key, value]) => `${key}: ${value}`).join(", ")} }`);
|
|
635
|
+
if (!names.has("role") && import_dom.TAGS[tag].role) add("role", JSON.stringify(import_dom.TAGS[tag].role));
|
|
636
|
+
if (tag === "textarea") add("multiline", "true");
|
|
637
|
+
return {
|
|
638
|
+
consumed,
|
|
639
|
+
edits,
|
|
640
|
+
additions
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function webDOMProps(input, tag) {
|
|
644
|
+
const edits = [];
|
|
645
|
+
const additions = [];
|
|
646
|
+
const entries = input.element.entries.filter((entry) => entry.kind === "prop");
|
|
647
|
+
const names = new Set(entries.map((entry) => entry.name));
|
|
648
|
+
for (const entry of entries) {
|
|
649
|
+
if (entry.name === "for") {
|
|
650
|
+
const edit = renamedPropEdit(input, entry, "htmlFor");
|
|
651
|
+
if (edit) edits.push(edit);
|
|
652
|
+
}
|
|
653
|
+
if (entry.name === "role" && entry.value.kind === "static" && entry.value.value === "none") edits.push({
|
|
654
|
+
start: entry.value.span.start,
|
|
655
|
+
end: entry.value.span.end,
|
|
656
|
+
content: JSON.stringify("presentation"),
|
|
657
|
+
origin: entry.value.span
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
if (tag === "button" && !names.has("type")) additions.push(["type", "\"button\""]);
|
|
661
|
+
if ((tag === "input" || tag === "textarea") && !names.has("dir")) additions.push(["dir", "\"auto\""]);
|
|
662
|
+
return {
|
|
663
|
+
edits,
|
|
664
|
+
additions
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function createTamaguiCompilerHost(options) {
|
|
668
|
+
const platform = options.target === "native" ? "native" : "web";
|
|
669
|
+
const core = (0, import_requireTamaguiCore.requireTamaguiCore)(platform);
|
|
670
|
+
const firstThemeName = Object.keys(options.tamaguiConfig.themes ?? {})[0] ?? "";
|
|
671
|
+
const theme = options.tamaguiConfig.themes?.[firstThemeName] ?? {};
|
|
672
|
+
const modifierRegistry = (0, import_style_grammar.createModifierRegistry)({
|
|
673
|
+
mediaNames: options.tamaguiConfig.media ?? {},
|
|
674
|
+
themeNames: options.tamaguiConfig.themes ?? {}
|
|
675
|
+
}).registry;
|
|
676
|
+
const configuredAnimationDriver = options.tamaguiConfig.animations;
|
|
677
|
+
const configuredCssAnimationDriver = platform === "web" && configuredAnimationDriver?.outputStyle === "css" && !options.tamaguiConfig.animationDrivers ? configuredAnimationDriver : null;
|
|
678
|
+
const resolveStaticCssTransition = (value, transitionPresets) => {
|
|
679
|
+
if (platform !== "web" || typeof value !== "string") return null;
|
|
680
|
+
const transitionPresetNames = new Set(Object.keys(transitionPresets));
|
|
681
|
+
const program = (0, import_style_grammar.parseValue)(value, modifierRegistry);
|
|
682
|
+
if (!program.ok) return null;
|
|
683
|
+
const resolvedPayloads = [];
|
|
684
|
+
const payloads = [program.value.base, ...program.value.clauses.map((clause) => clause.payload)].filter((payload) => payload !== null);
|
|
685
|
+
if (payloads.length === 0) return null;
|
|
686
|
+
for (const payload of payloads) {
|
|
687
|
+
const transition = (0, import_style_grammar.parseTransition)(payload, transitionPresetNames);
|
|
688
|
+
if (!transition.ok) return null;
|
|
689
|
+
if (transition.value.kind === "global" || transition.value.entries.every((entry) => entry.timing.type === "css")) {
|
|
690
|
+
resolvedPayloads.push(payload);
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (transition.value.entries.length !== 1 || transition.value.entries[0].timing.type !== "preset") return null;
|
|
694
|
+
const preset = transitionPresets[transition.value.entries[0].timing.name];
|
|
695
|
+
if (typeof preset !== "string") return null;
|
|
696
|
+
const parsedPreset = (0, import_style_grammar.parseTransition)(preset);
|
|
697
|
+
if (!parsedPreset.ok || parsedPreset.value.kind !== "transition" || parsedPreset.value.entries.length !== 1 || parsedPreset.value.entries[0].property !== "all" || parsedPreset.value.entries[0].timing.type !== "css") return null;
|
|
698
|
+
resolvedPayloads.push(`all ${preset}`);
|
|
699
|
+
}
|
|
700
|
+
let payloadIndex = 0;
|
|
701
|
+
const resolved = [];
|
|
702
|
+
if (program.value.base !== null) resolved.push(resolvedPayloads[payloadIndex++]);
|
|
703
|
+
for (const clause of program.value.clauses) resolved.push(`${clause.modifiers.join(":")}:${resolvedPayloads[payloadIndex++]}`);
|
|
704
|
+
return resolved.join(" ");
|
|
705
|
+
};
|
|
706
|
+
const modulesById = new Map(options.componentModules.map((module2) => [module2.resolvedId, module2.moduleName]));
|
|
707
|
+
const componentsByModule = new Map(options.components.map((component) => [component.moduleName, component]));
|
|
708
|
+
const normalizeStaticConfig = (staticConfig) => staticConfig.styleFrontend?.normalizeStaticConfig?.(staticConfig, options.tamaguiConfig) ?? staticConfig;
|
|
709
|
+
const directStaticConfig = (element) => {
|
|
710
|
+
const identity = element.component.provenance;
|
|
711
|
+
if (!identity) return null;
|
|
712
|
+
const moduleName = modulesById.get(identity.resolvedId);
|
|
713
|
+
const info = (moduleName ? componentsByModule.get(moduleName) : void 0)?.nameToInfo[identity.importedName];
|
|
714
|
+
return info ? {
|
|
715
|
+
key: componentKey(identity.resolvedId, identity.importedName),
|
|
716
|
+
staticConfig: normalizeStaticConfig(info.staticConfig),
|
|
717
|
+
displayName: info.displayName
|
|
718
|
+
} : null;
|
|
719
|
+
};
|
|
720
|
+
const domStaticConfig = (element) => {
|
|
721
|
+
const identity = element.component.provenance;
|
|
722
|
+
const tag = element.component.name;
|
|
723
|
+
if (identity?.importedName !== "html" || !DOM_FRONTENDS.has(identity.specifier) || !Object.hasOwn(import_dom.TAGS, tag)) return null;
|
|
724
|
+
const row = import_dom.TAGS[tag];
|
|
725
|
+
const base = (row.backing === "text" || row.backing === "textinput" ? core.Text : core.View)?.staticConfig;
|
|
726
|
+
if (!base) return null;
|
|
727
|
+
const platformDefaults = platform === "web" ? {
|
|
728
|
+
...import_dom.DISPLAY_WEB_RESET[row.display],
|
|
729
|
+
...row.defaults,
|
|
730
|
+
...import_dom.TAG_WEB_DEFAULTS[tag]
|
|
731
|
+
} : {
|
|
732
|
+
...import_dom.NATIVE_ELEMENT_DEFAULTS,
|
|
733
|
+
...row.display === "block" ? import_dom.NATIVE_BLOCK_DEFAULTS : null,
|
|
734
|
+
...row.defaults,
|
|
735
|
+
...row.nativeDefaults
|
|
736
|
+
};
|
|
737
|
+
return {
|
|
738
|
+
key: componentKey(identity.resolvedId, `html.${tag}`),
|
|
739
|
+
tag,
|
|
740
|
+
displayName: tag,
|
|
741
|
+
staticConfig: normalizeStaticConfig({
|
|
742
|
+
...base,
|
|
743
|
+
isInput: row.backing === "textinput",
|
|
744
|
+
validStyles: {
|
|
745
|
+
...import_helpers.validStyles,
|
|
746
|
+
...import_helpers.stylePropsText
|
|
747
|
+
},
|
|
748
|
+
defaultProps: {
|
|
749
|
+
...base.defaultProps,
|
|
750
|
+
...platformDefaults
|
|
751
|
+
}
|
|
752
|
+
})
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
const styledStaticConfig = (definition) => {
|
|
756
|
+
if (!definition || definition.options.kind !== "static") return null;
|
|
757
|
+
const base = directStaticConfig({
|
|
758
|
+
kind: "element",
|
|
759
|
+
form: "jsx",
|
|
760
|
+
id: definition.id,
|
|
761
|
+
span: definition.span,
|
|
762
|
+
propsSpan: null,
|
|
763
|
+
component: definition.base,
|
|
764
|
+
complete: true,
|
|
765
|
+
entries: [],
|
|
766
|
+
bailouts: []
|
|
767
|
+
});
|
|
768
|
+
if (!base || !staticObject(definition.options.value)) return null;
|
|
769
|
+
const { variants, defaultVariants, compoundVariants, displayName, context, contextProps, ...defaultProps } = definition.options.value;
|
|
770
|
+
const baseClassName = definition.baseClassName?.kind === "static" && typeof definition.baseClassName.value === "string" ? definition.baseClassName.value : void 0;
|
|
771
|
+
return {
|
|
772
|
+
key: componentKey(definition.id, definition.name),
|
|
773
|
+
displayName: displayName || base.displayName,
|
|
774
|
+
staticConfig: normalizeStaticConfig({
|
|
775
|
+
...base.staticConfig,
|
|
776
|
+
variants: {
|
|
777
|
+
...base.staticConfig.variants,
|
|
778
|
+
...variants
|
|
779
|
+
},
|
|
780
|
+
compoundVariants: [...base.staticConfig.compoundVariants ?? [], ...compoundVariants ?? []],
|
|
781
|
+
defaultProps: {
|
|
782
|
+
...base.staticConfig.defaultProps,
|
|
783
|
+
...defaultProps,
|
|
784
|
+
...defaultVariants
|
|
785
|
+
},
|
|
786
|
+
defaultVariants,
|
|
787
|
+
baseClassName: [base.staticConfig.baseClassName, baseClassName].filter(Boolean).join(" "),
|
|
788
|
+
context: context ?? base.staticConfig.context,
|
|
789
|
+
contextProps: context ? contextProps : contextProps ?? base.staticConfig.contextProps
|
|
790
|
+
})
|
|
791
|
+
};
|
|
792
|
+
};
|
|
793
|
+
const resolve = (element, styledDefinition) => {
|
|
794
|
+
const dom = domStaticConfig(element);
|
|
795
|
+
const resolved = dom ?? styledStaticConfig(styledDefinition) ?? directStaticConfig(element);
|
|
796
|
+
if (!resolved) return null;
|
|
797
|
+
const defaultProps = core.getDefaultProps(resolved.staticConfig) ?? {};
|
|
798
|
+
return {
|
|
799
|
+
key: resolved.key,
|
|
800
|
+
canFlatten: resolved.staticConfig.acceptsClassName !== false && !resolved.staticConfig.neverFlatten && !resolved.staticConfig.context,
|
|
801
|
+
staticConfig: resolved.staticConfig,
|
|
802
|
+
displayName: resolved.displayName,
|
|
803
|
+
...dom && { domTag: dom.tag },
|
|
804
|
+
partialRuntimeSafe: !dom && !styledDefinition && Object.keys(defaultProps).length === 0 && !resolved.staticConfig.defaultVariants && !resolved.staticConfig.baseClassName && !resolved.staticConfig.baseStyle && (resolved.staticConfig.compoundVariants?.length ?? 0) === 0
|
|
805
|
+
};
|
|
806
|
+
};
|
|
807
|
+
const isStyleProp = (name, component) => {
|
|
808
|
+
const staticConfig = component.staticConfig;
|
|
809
|
+
return compilerStyleProps.has(name) || name in (options.tamaguiConfig.shorthands ?? {}) || !!staticConfig.validStyles?.[name] || !!staticConfig.variants?.[name];
|
|
810
|
+
};
|
|
811
|
+
const runtimeOnlyStyleProps = /* @__PURE__ */ new Set([
|
|
812
|
+
"className",
|
|
813
|
+
"style",
|
|
814
|
+
"group",
|
|
815
|
+
"transition",
|
|
816
|
+
"animation",
|
|
817
|
+
"animateOnly",
|
|
818
|
+
"animatePresence",
|
|
819
|
+
"animatedBy",
|
|
820
|
+
"render"
|
|
821
|
+
]);
|
|
822
|
+
const canLowerConditionalStyleProp = (name, component) => isStyleProp(name, component) && !runtimeOnlyStyleProps.has(name);
|
|
823
|
+
const isInvalidHostStyleProp = (name, component) => {
|
|
824
|
+
const staticConfig = component.staticConfig;
|
|
825
|
+
const validStyles = staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? import_helpers.stylePropsText : import_helpers.validStyles);
|
|
826
|
+
return name in import_helpers.stylePropsAll && !(0, import_web.isValidStyleKey)(name, validStyles, staticConfig.accept);
|
|
827
|
+
};
|
|
828
|
+
const directStyleName = (name, component) => {
|
|
829
|
+
if (compilerStyleProps.has(name) || name === "style") return null;
|
|
830
|
+
const staticConfig = component.staticConfig;
|
|
831
|
+
if (staticConfig.variants?.[name]) return null;
|
|
832
|
+
const expanded = options.tamaguiConfig.shorthands?.[name] ?? name;
|
|
833
|
+
return staticConfig.validStyles?.[expanded] ? expanded : null;
|
|
834
|
+
};
|
|
835
|
+
const resolveSplitStyles = (props, staticConfig, animationDriver, displayName) => {
|
|
836
|
+
const previousStatic = process.env.IS_STATIC;
|
|
837
|
+
const previousTarget = "web";
|
|
838
|
+
if (platform === "native") process.env.IS_STATIC = "is_static";
|
|
839
|
+
else delete process.env.IS_STATIC;
|
|
840
|
+
process.env.TAMAGUI_TARGET = platform;
|
|
841
|
+
try {
|
|
842
|
+
return core.getSplitStyles(props, staticConfig, theme, firstThemeName, componentState, {
|
|
843
|
+
resolveValues: platform === "native" ? "except-theme" : "variable",
|
|
844
|
+
noClass: platform === "native",
|
|
845
|
+
isAnimated: false,
|
|
846
|
+
displayName
|
|
847
|
+
}, void 0, void 0, void 0, void 0, void 0, void 0, animationDriver);
|
|
848
|
+
} finally {
|
|
849
|
+
if (previousStatic === void 0) delete process.env.IS_STATIC;
|
|
850
|
+
else process.env.IS_STATIC = previousStatic;
|
|
851
|
+
if (previousTarget === void 0) delete "web";
|
|
852
|
+
else process.env.TAMAGUI_TARGET = previousTarget;
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
const partialStaticConfig = (staticConfig) => ({
|
|
856
|
+
...staticConfig,
|
|
857
|
+
baseStyle: void 0,
|
|
858
|
+
defaultProps: {},
|
|
859
|
+
defaultVariants: void 0,
|
|
860
|
+
compoundVariants: [],
|
|
861
|
+
variants: {}
|
|
862
|
+
});
|
|
863
|
+
const styleOwners = (name, value, staticConfig) => {
|
|
864
|
+
const split = resolveSplitStyles({ [name]: value }, partialStaticConfig(staticConfig));
|
|
865
|
+
if (!split) return null;
|
|
866
|
+
const inlineStyle = split.viewProps?.style;
|
|
867
|
+
if (staticObject(inlineStyle) && !inlineStyle["$$css"] && Object.keys(inlineStyle).length > 0) return null;
|
|
868
|
+
const owners = new Set(Object.keys(split.classNames ?? {}));
|
|
869
|
+
for (const styleObject of Object.values(split.rulesToInsert ?? {})) {
|
|
870
|
+
const property = styleObject?.[import_helpers.StyleObjectProperty];
|
|
871
|
+
if (typeof property === "string") owners.add(property);
|
|
872
|
+
}
|
|
873
|
+
return owners.size > 0 ? owners : null;
|
|
874
|
+
};
|
|
875
|
+
const dynamicStyleOwners = (name, staticConfig) => {
|
|
876
|
+
const owners = styleOwners(name, name === "transform" ? [{ scale: 1 }] : name === "transformMatrix" ? [
|
|
877
|
+
1,
|
|
878
|
+
0,
|
|
879
|
+
0,
|
|
880
|
+
1,
|
|
881
|
+
0,
|
|
882
|
+
0
|
|
883
|
+
] : name === "shadowOffset" ? {
|
|
884
|
+
width: 0,
|
|
885
|
+
height: 0
|
|
886
|
+
} : name === "shadowColor" ? "black" : name === "border" || name === "outline" ? "0 solid transparent" : name === "position" ? "relative" : name === "objectFit" ? "contain" : 0, staticConfig);
|
|
887
|
+
if (!owners || name !== "flex") return owners;
|
|
888
|
+
const shorthandOwners = styleOwners(name, "0 1 auto", staticConfig);
|
|
889
|
+
if (!shorthandOwners) return null;
|
|
890
|
+
for (const owner of shorthandOwners) owners.add(owner);
|
|
891
|
+
return owners;
|
|
892
|
+
};
|
|
893
|
+
const developmentDebugInstrumentation = (input, result) => {
|
|
894
|
+
if (process.env.NODE_ENV !== "development") return;
|
|
895
|
+
const debugEntry = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "debug" && entry.value.kind === "static" && entry.value.value === "verbose");
|
|
896
|
+
if (!debugEntry) return;
|
|
897
|
+
const component = input.component;
|
|
898
|
+
const styleEntries = input.element.entries.filter((entry) => entry.kind === "prop" && entry.name !== "debug" && (entry.name === "style" || isStyleProp(entry.name, component)));
|
|
899
|
+
const flattened = result.ok && !!result.flattened;
|
|
900
|
+
const tiers = result.ok ? [
|
|
901
|
+
"lowered",
|
|
902
|
+
...flattened ? ["flattened"] : [],
|
|
903
|
+
...input.styledDefinition ? ["styled"] : []
|
|
904
|
+
] : ["bailed"];
|
|
905
|
+
const why = result.ok ? flattened ? "Static styles were lowered and the component was flattened to a host element." : "Static styles were lowered while the Tamagui component remained at runtime." : result.bailout.message;
|
|
906
|
+
const styles = styleEntries.map((entry) => {
|
|
907
|
+
if (!result.ok) return {
|
|
908
|
+
prop: entry.name,
|
|
909
|
+
tier: "bailed",
|
|
910
|
+
runtime: true,
|
|
911
|
+
why: `${result.bailout.message}. The Tamagui runtime resolved this prop.`
|
|
912
|
+
};
|
|
913
|
+
const edited = result.edits.some((edit) => edit.start < entry.span.end && edit.end > entry.span.start);
|
|
914
|
+
if (!flattened && !edited) return {
|
|
915
|
+
prop: entry.name,
|
|
916
|
+
tier: "bailed",
|
|
917
|
+
runtime: true,
|
|
918
|
+
why: "This prop remained for Tamagui runtime resolution."
|
|
919
|
+
};
|
|
920
|
+
if (entry.value.kind === "static") {
|
|
921
|
+
const split = resolveSplitStyles({ [entry.name]: entry.value.value }, partialStaticConfig(component.staticConfig));
|
|
922
|
+
if (!Boolean(split && (Object.keys(split.classNames ?? {}).length > 0 || Object.keys(split.rulesToInsert ?? {}).length > 0 || staticObject(split.style) && Object.keys(split.style).length > 0 || staticObject(split.viewProps?.style) && Object.keys(split.viewProps.style).length > 0))) return {
|
|
923
|
+
prop: entry.name,
|
|
924
|
+
tier: flattened ? "flattened" : "lowered",
|
|
925
|
+
dropped: true,
|
|
926
|
+
why: `No ${platform} style output was produced for this prop.`
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
return {
|
|
930
|
+
prop: entry.name,
|
|
931
|
+
tier: flattened ? "flattened" : "lowered",
|
|
932
|
+
why: flattened ? "The compiler emitted this prop on the flattened host element." : "The compiler lowered this prop while retaining the Tamagui component."
|
|
933
|
+
};
|
|
934
|
+
});
|
|
935
|
+
const receipt = JSON.stringify({
|
|
936
|
+
component: input.element.component.name,
|
|
937
|
+
tiers,
|
|
938
|
+
why,
|
|
939
|
+
styles
|
|
940
|
+
});
|
|
941
|
+
const content = flattened ? input.element.form === "jsx" ? `{...(console.info('\u{1F539} Tamagui style receipt', ${receipt}), {})}` : `...(console.info('\u{1F539} Tamagui style receipt', ${receipt}), {})` : input.element.form === "jsx" ? `debug="verbose" __tamaguiStyleDebugReceipt={${receipt}}` : `debug: "verbose", __tamaguiStyleDebugReceipt: ${receipt}`;
|
|
942
|
+
return [{
|
|
943
|
+
start: debugEntry.span.start,
|
|
944
|
+
end: debugEntry.span.end,
|
|
945
|
+
content,
|
|
946
|
+
origin: debugEntry.span
|
|
947
|
+
}];
|
|
948
|
+
};
|
|
949
|
+
return {
|
|
950
|
+
resolveComponent: resolve,
|
|
951
|
+
isStyleProp,
|
|
952
|
+
canLowerDynamicStyleProp(name, component, valueKind) {
|
|
953
|
+
if (!options.disablePartialExtraction && valueKind === "conditional" && canLowerConditionalStyleProp(name, component)) return true;
|
|
954
|
+
return !options.disablePartialExtraction && (platform === "web" && !!directStyleName(name, component) || platform === "native" && directStyleName(name, component) === "opacity");
|
|
955
|
+
},
|
|
956
|
+
developmentDebugInstrumentation,
|
|
957
|
+
lowerCandidate(input) {
|
|
958
|
+
const component = input.component;
|
|
959
|
+
if (!component.canFlatten) return bailout(input, "local/unsupported-target", component.staticConfig.acceptsClassName === false ? `${component.key} does not accept className` : component.staticConfig.neverFlatten ? `${component.key} is never flattened (behavior HOC)` : `${component.key} provides a styled context`, input.element.span, { rule: 6 });
|
|
960
|
+
if (options.zeroRuntime) {
|
|
961
|
+
const spread = input.element.entries.find((entry) => entry.kind === "spread");
|
|
962
|
+
if (spread) return bailout(input, "local/unsafe-style-spread", "Zero-runtime rejects prop spreads", spread.span, {
|
|
963
|
+
rule: 1,
|
|
964
|
+
message: (0, import_compiler_core.zeroRuleMessage)(1, { component: input.element.component.name })
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
const props = {};
|
|
968
|
+
for (const entry of input.element.entries) {
|
|
969
|
+
if (entry.kind === "child" || entry.value.kind !== "static") continue;
|
|
970
|
+
if (entry.kind === "spread") {
|
|
971
|
+
if (!staticObject(entry.value.value)) return bailout(input, "local/unsafe-style-spread", "Static spread did not materialize to an object", entry.span);
|
|
972
|
+
Object.assign(props, entry.value.value);
|
|
973
|
+
} else props[entry.name] = entry.value.value;
|
|
974
|
+
}
|
|
975
|
+
const disableOptimizationEntry = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "disableOptimization");
|
|
976
|
+
if (disableOptimizationEntry || Object.hasOwn(props, "disableOptimization")) return bailout(input, "local/unsupported-target", "disableOptimization keeps the component on the runtime path", disableOptimizationEntry?.span);
|
|
977
|
+
if (component.domTag && props.hidden) props.display = "none";
|
|
978
|
+
if (component.domTag && platform === "native") {
|
|
979
|
+
for (const [name, styleKey] of DOM_STYLE_ATTRIBUTES) if (name in props) {
|
|
980
|
+
props[styleKey] = props[name];
|
|
981
|
+
delete props[name];
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if (platform === "native" && component.domTag === "input" && typeof props.type === "string" && !import_dom.NATIVE_INPUT_TYPES.includes(props.type)) return bailout(input, "local/unsupported-target", `input type ${props.type} has no native text-entry control`);
|
|
985
|
+
const dynamicStyleEntries = input.element.entries.filter((entry) => entry.kind === "prop" && (entry.value.kind === "bailout" || entry.value.kind === "conditional") && isStyleProp(entry.name, component));
|
|
986
|
+
{
|
|
987
|
+
const needsRuntimeMapping = (name) => runtimeEventProps.has(name) || platform === "native" && !component.domTag && nativePointerEventProps.has(name);
|
|
988
|
+
const directRuntimeEvent = input.element.entries.find((entry) => entry.kind === "prop" && needsRuntimeMapping(entry.name));
|
|
989
|
+
const runtimeEvent = directRuntimeEvent?.kind === "prop" ? directRuntimeEvent.name : Object.keys(props).find(needsRuntimeMapping);
|
|
990
|
+
if (runtimeEvent) return bailout(input, "local/unsupported-target", `${runtimeEvent} requires Tamagui runtime event mapping`);
|
|
991
|
+
}
|
|
992
|
+
const animationDefaultProps = core.getDefaultProps(component.staticConfig) ?? {};
|
|
993
|
+
const animationProps = core.mergeProps(animationDefaultProps, props);
|
|
994
|
+
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)]);
|
|
995
|
+
const animateOnlyEntry = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "animateOnly");
|
|
996
|
+
if (animationNames.has("animateOnly")) return bailout(input, "local/unsupported-target", "Animated candidates remain on the runtime path", animateOnlyEntry?.span, {
|
|
997
|
+
rule: 5,
|
|
998
|
+
message: (0, import_compiler_core.zeroRuleMessage)(5, { detail: animateOnlyEntry ? `animateOnly on ${input.element.component.name}` : `animateOnly in the styled() definition of ${input.element.component.name}` })
|
|
999
|
+
});
|
|
1000
|
+
const transitionEntry = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "transition");
|
|
1001
|
+
const animatedBy = typeof animationProps.animatedBy === "string" ? animationProps.animatedBy.trim() : null;
|
|
1002
|
+
const namedAnimationDriver = animatedBy === null ? null : options.tamaguiConfig.animationDrivers?.[animatedBy];
|
|
1003
|
+
const cssAnimationDriver = (platform === "web" && namedAnimationDriver?.outputStyle === "css" ? namedAnimationDriver : null) ?? (animatedBy === null || animatedBy === "default" ? configuredCssAnimationDriver : null);
|
|
1004
|
+
const resolvedCssTransition = animationNames.has("transition") && cssAnimationDriver ? resolveStaticCssTransition(animationProps.transition, cssAnimationDriver.animations ?? {}) : null;
|
|
1005
|
+
if (resolvedCssTransition !== null) props.transition = resolvedCssTransition;
|
|
1006
|
+
const animatedByNeedsRuntime = animationNames.has("animatedBy") && !animationNames.has("transition") && (dynamicStyleEntries.length > 0 || Object.keys(animationProps).some((name) => name !== "animatedBy" && (isStyleProp(name, component) && typeof animationProps[name] === "string" && animationProps[name].includes(":") || name === "animationConfig" || name === "forceStyle" || name === "onTransition")));
|
|
1007
|
+
const runtimeAnimationRequired = animationNames.has("transition") && resolvedCssTransition === null || [...animationNames].some((name) => name !== "transition" && name !== "animatedBy" && name !== "animateOnly") || animatedByNeedsRuntime;
|
|
1008
|
+
let dynamicHostStyleProperties = null;
|
|
1009
|
+
if (resolvedCssTransition !== null && dynamicStyleEntries.length > 0 && !input.element.entries.some((entry) => entry.kind === "spread")) {
|
|
1010
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1011
|
+
const properties = [];
|
|
1012
|
+
const dynamicOwners = /* @__PURE__ */ new Set();
|
|
1013
|
+
for (const entry of dynamicStyleEntries) {
|
|
1014
|
+
if (entry.kind !== "prop" || entry.value.kind !== "bailout" && entry.value.kind !== "conditional") continue;
|
|
1015
|
+
const name = directStyleName(entry.name, component);
|
|
1016
|
+
if (name !== "opacity" && name !== "scale" || seen.has(name)) {
|
|
1017
|
+
properties.length = 0;
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
const owners = dynamicStyleOwners(name, component.staticConfig);
|
|
1021
|
+
if (!owners) {
|
|
1022
|
+
properties.length = 0;
|
|
1023
|
+
break;
|
|
1024
|
+
}
|
|
1025
|
+
seen.add(name);
|
|
1026
|
+
for (const owner of owners) dynamicOwners.add(owner);
|
|
1027
|
+
const expression = input.source.slice(entry.value.span.start, entry.value.span.end);
|
|
1028
|
+
properties.push(name === "opacity" ? `opacity: (${expression})` : `transform: "scale(" + (${expression}) + ")"`);
|
|
1029
|
+
}
|
|
1030
|
+
if (properties.length === dynamicStyleEntries.length && !input.element.entries.some((entry) => {
|
|
1031
|
+
if (entry.kind !== "prop" || entry.value.kind !== "static") return false;
|
|
1032
|
+
const name = directStyleName(entry.name, component);
|
|
1033
|
+
if (!name) return false;
|
|
1034
|
+
const owners = styleOwners(name, entry.value.value, component.staticConfig);
|
|
1035
|
+
return !!owners && cssOwnersConflict(owners, dynamicOwners);
|
|
1036
|
+
})) dynamicHostStyleProperties = properties;
|
|
1037
|
+
}
|
|
1038
|
+
const supportsWebConditionalClasses = platform === "web" && !options.disablePartialExtraction && (input.element.form === "jsx" || input.element.propsSpan !== null) && dynamicHostStyleProperties === null && dynamicStyleEntries.length === 1 && dynamicStyleEntries.every((entry) => entry.kind === "prop" && entry.value.kind === "conditional" && canLowerConditionalStyleProp(entry.name, component));
|
|
1039
|
+
if ("theme" in props || "themeInverse" in props) {
|
|
1040
|
+
const themeProp = "theme" in props ? "theme" : "themeInverse";
|
|
1041
|
+
return bailout(input, "local/unsupported-target", "Theme boundary candidates remain on the runtime path", input.element.span, {
|
|
1042
|
+
rule: 4,
|
|
1043
|
+
message: (0, import_compiler_core.zeroThemeBoundaryMessage)(input.element.component.name, themeProp)
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
const asChildEntry = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "asChild");
|
|
1047
|
+
if (asChildEntry || Object.hasOwn(props, "asChild")) return bailout(input, "local/unsupported-target", "asChild renders a Slot, not a host view", asChildEntry?.span);
|
|
1048
|
+
if (platform === "native" && ("group" in props || "container" in props || "containerName" in props || "containerType" in props)) return bailout(input, "local/unsupported-target", "Native group containers remain on the runtime path");
|
|
1049
|
+
if (runtimeAnimationRequired && !cssAnimationDriver) return bailout(input, "local/unsupported-target", "Animated candidates remain on the runtime path", transitionEntry?.span, {
|
|
1050
|
+
rule: 5,
|
|
1051
|
+
message: (0, import_compiler_core.zeroRuleMessage)(5, { detail: `the animation configured on ${input.element.component.name}` })
|
|
1052
|
+
});
|
|
1053
|
+
if (platform === "web" && (dynamicStyleEntries.length > 0 || runtimeAnimationRequired) && dynamicHostStyleProperties === null && !supportsWebConditionalClasses && component.partialRuntimeSafe) {
|
|
1054
|
+
const hasSpread = input.element.entries.some((entry) => entry.kind === "spread");
|
|
1055
|
+
const unsupportedRuntimeStyle = input.element.entries.find((entry) => entry.kind === "prop" && isStyleProp(entry.name, component) && !runtimeAnimationProps.has(entry.name) && !directStyleName(entry.name, component));
|
|
1056
|
+
if (!hasSpread && !unsupportedRuntimeStyle) {
|
|
1057
|
+
const dynamicOwners = /* @__PURE__ */ new Set();
|
|
1058
|
+
let canProveDynamicOwnership = true;
|
|
1059
|
+
for (const entry of dynamicStyleEntries) {
|
|
1060
|
+
if (entry.kind !== "prop") continue;
|
|
1061
|
+
const name = directStyleName(entry.name, component);
|
|
1062
|
+
if (!name) {
|
|
1063
|
+
canProveDynamicOwnership = false;
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
const owners = dynamicStyleOwners(name, component.staticConfig);
|
|
1067
|
+
if (!owners) {
|
|
1068
|
+
canProveDynamicOwnership = false;
|
|
1069
|
+
break;
|
|
1070
|
+
}
|
|
1071
|
+
for (const owner of owners) dynamicOwners.add(owner);
|
|
1072
|
+
}
|
|
1073
|
+
const staticStyleEntries = canProveDynamicOwnership ? input.element.entries.filter((entry) => {
|
|
1074
|
+
if (entry.kind !== "prop" || entry.value.kind !== "static") return false;
|
|
1075
|
+
if (runtimeAnimationProps.has(entry.name)) return false;
|
|
1076
|
+
const name = directStyleName(entry.name, component);
|
|
1077
|
+
if (!name) return false;
|
|
1078
|
+
const owners = styleOwners(name, entry.value.value, component.staticConfig);
|
|
1079
|
+
return !!owners && !cssOwnersConflict(owners, dynamicOwners);
|
|
1080
|
+
}) : [];
|
|
1081
|
+
if (staticStyleEntries.length > 0) {
|
|
1082
|
+
const partialProps = {};
|
|
1083
|
+
for (const entry of staticStyleEntries) if (entry.kind === "prop" && entry.value.kind === "static") partialProps[entry.name] = entry.value.value;
|
|
1084
|
+
const partialSplit = resolveSplitStyles(partialProps, partialStaticConfig(component.staticConfig));
|
|
1085
|
+
const partialInlineStyle = partialSplit?.viewProps?.style;
|
|
1086
|
+
const hasPartialInlineStyle = staticObject(partialInlineStyle) && !partialInlineStyle["$$css"] && Object.keys(partialInlineStyle).length > 0;
|
|
1087
|
+
if (partialSplit && !hasPartialInlineStyle) {
|
|
1088
|
+
const artifacts2 = extractedStyleArtifacts(partialSplit, partialProps, options.tamaguiConfig, false);
|
|
1089
|
+
if (artifacts2.className) if (input.element.form !== "jsx") {
|
|
1090
|
+
const propsEdits = compiledPropsEdits(input, staticStyleEntries, objectClassName(artifacts2.className));
|
|
1091
|
+
if (propsEdits) return {
|
|
1092
|
+
ok: true,
|
|
1093
|
+
edits: propsEdits,
|
|
1094
|
+
css: artifacts2.css,
|
|
1095
|
+
imports: [],
|
|
1096
|
+
flattened: false
|
|
1097
|
+
};
|
|
1098
|
+
} else {
|
|
1099
|
+
const [first2, ...rest2] = staticStyleEntries;
|
|
1100
|
+
return {
|
|
1101
|
+
ok: true,
|
|
1102
|
+
edits: [{
|
|
1103
|
+
start: first2.span.start,
|
|
1104
|
+
end: first2.span.end,
|
|
1105
|
+
content: jsxClassName(artifacts2.className),
|
|
1106
|
+
origin: first2.span
|
|
1107
|
+
}, ...rest2.map((entry) => ({
|
|
1108
|
+
start: entry.span.start,
|
|
1109
|
+
end: entry.span.end,
|
|
1110
|
+
content: "",
|
|
1111
|
+
origin: entry.span
|
|
1112
|
+
}))],
|
|
1113
|
+
css: artifacts2.css,
|
|
1114
|
+
imports: [],
|
|
1115
|
+
flattened: false
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (runtimeAnimationRequired) return bailout(input, "local/unsupported-target", "Animated candidates remain on the runtime path", transitionEntry?.span, {
|
|
1123
|
+
rule: 5,
|
|
1124
|
+
message: (0, import_compiler_core.zeroRuleMessage)(5, { detail: `the animation configured on ${input.element.component.name}` })
|
|
1125
|
+
});
|
|
1126
|
+
const supportsNativeDynamicStyles = platform === "native" && !options.disablePartialExtraction && (input.element.form === "jsx" || input.element.propsSpan !== null) && dynamicStyleEntries.every((entry) => entry.kind === "prop" && (directStyleName(entry.name, component) === "opacity" || entry.value.kind === "conditional" && canLowerConditionalStyleProp(entry.name, component)));
|
|
1127
|
+
if (dynamicStyleEntries.length > 0 && dynamicHostStyleProperties === null && !supportsNativeDynamicStyles && !supportsWebConditionalClasses) {
|
|
1128
|
+
const entry = dynamicStyleEntries[0];
|
|
1129
|
+
return bailout(input, "local/dynamic-style-value", `Style prop ${entry.kind === "prop" ? entry.name : "unknown"} could not be safely extracted`, entry.span);
|
|
1130
|
+
}
|
|
1131
|
+
const staticDefaultProps = core.getDefaultProps(component.staticConfig) ?? {};
|
|
1132
|
+
const defaultProps = platform === "web" && !component.staticConfig.isText && options.tamaguiConfig.settings.defaultPosition === "relative" && staticDefaultProps.position === void 0 ? core.mergeProps({ position: "relative" }, staticDefaultProps) : staticDefaultProps;
|
|
1133
|
+
let completeProps = core.mergeProps(defaultProps, props);
|
|
1134
|
+
if (platform === "native" && component.domTag && props.display === "flex") completeProps = core.mergeProps(core.mergeProps(defaultProps, import_dom.NATIVE_FLEX_DEFAULTS), props);
|
|
1135
|
+
if (platform === "native") {
|
|
1136
|
+
const isClauseValue = (name, value) => isStyleProp(name, component) && typeof value === "string" && flatClausePattern.test(value);
|
|
1137
|
+
const defaultVariants = component.staticConfig.defaultVariants ?? {};
|
|
1138
|
+
if (Object.entries(completeProps).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))))) return bailout(input, "local/unsupported-target", "Native conditional value programs remain on the runtime path");
|
|
1139
|
+
}
|
|
1140
|
+
const split = resolveSplitStyles(completeProps, component.staticConfig, cssAnimationDriver, component.displayName);
|
|
1141
|
+
if (!split) return bailout(input, "local/style-resolution-failed", "getSplitStyles returned no static result");
|
|
1142
|
+
if (split.programLifecycleStyleKeys?.enter?.size || split.programLifecycleStyleKeys?.exit?.size) return bailout(input, "local/unsupported-target", "Lifecycle value programs remain on the runtime path", input.element.span, {
|
|
1143
|
+
rule: 5,
|
|
1144
|
+
message: (0, import_compiler_core.zeroRuleMessage)(5, { detail: `an enter or exit style program on ${input.element.component.name}` })
|
|
1145
|
+
});
|
|
1146
|
+
const domStyleProgram = input.element.entries.find((entry) => entry.kind === "prop" && entry.name === "style" && entry.value.kind === "dom-style");
|
|
1147
|
+
const flatTag = component.domTag ?? (typeof props.render === "string" ? props.render : typeof defaultProps.render === "string" ? defaultProps.render : component.staticConfig.isText ? "span" : "div");
|
|
1148
|
+
const tagEdits = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1149
|
+
start: span.start,
|
|
1150
|
+
end: span.end,
|
|
1151
|
+
content: input.element.form === "jsx" ? flatTag : JSON.stringify(flatTag),
|
|
1152
|
+
origin: span
|
|
1153
|
+
}));
|
|
1154
|
+
let styleEntries = input.element.entries.filter((entry) => entry.kind === "prop" && (isStyleProp(entry.name, component) || isInvalidHostStyleProp(entry.name, component)) || entry.kind === "spread" && entry.value.kind === "static" && staticObject(entry.value.value) && Object.keys(entry.value.value).every((name) => isStyleProp(name, component) || isInvalidHostStyleProp(name, component)));
|
|
1155
|
+
let invalidHostStyle;
|
|
1156
|
+
for (const entry of input.element.entries) {
|
|
1157
|
+
if (entry.kind === "prop") {
|
|
1158
|
+
if (isInvalidHostStyleProp(entry.name, component)) {
|
|
1159
|
+
invalidHostStyle = {
|
|
1160
|
+
entry,
|
|
1161
|
+
name: entry.name
|
|
1162
|
+
};
|
|
1163
|
+
break;
|
|
1164
|
+
}
|
|
1165
|
+
continue;
|
|
1166
|
+
}
|
|
1167
|
+
if (entry.kind === "spread" && entry.value.kind === "static" && staticObject(entry.value.value)) {
|
|
1168
|
+
const name = Object.keys(entry.value.value).find((name2) => isInvalidHostStyleProp(name2, component));
|
|
1169
|
+
if (name) {
|
|
1170
|
+
invalidHostStyle = {
|
|
1171
|
+
entry,
|
|
1172
|
+
name
|
|
1173
|
+
};
|
|
1174
|
+
break;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (invalidHostStyle) return bailout(input, "local/unsupported-target", `"${invalidHostStyle.name}" is a text style prop and this component is not text. Use a Text-based component, or html.* for raw web elements.`, invalidHostStyle.entry.span);
|
|
1179
|
+
const webPropEdits = platform === "web" ? input.element.entries.flatMap((entry) => {
|
|
1180
|
+
if (entry.kind !== "prop" || entry.name !== "testID") return [];
|
|
1181
|
+
const content = input.source.slice(entry.span.start, entry.span.end);
|
|
1182
|
+
const nameOffset = content.indexOf("testID");
|
|
1183
|
+
if (nameOffset === -1) return [];
|
|
1184
|
+
const alreadyQuoted = content[nameOffset - 1] === "\"" || content[nameOffset - 1] === "'";
|
|
1185
|
+
return [{
|
|
1186
|
+
start: entry.span.start + nameOffset,
|
|
1187
|
+
end: entry.span.start + nameOffset + 6,
|
|
1188
|
+
content: input.element.form === "jsx" || alreadyQuoted ? "data-testid" : `'data-testid'`,
|
|
1189
|
+
origin: entry.span
|
|
1190
|
+
}];
|
|
1191
|
+
}) : [];
|
|
1192
|
+
const webDOMResult = platform === "web" && component.domTag ? webDOMProps(input, component.domTag) : {
|
|
1193
|
+
edits: [],
|
|
1194
|
+
additions: []
|
|
1195
|
+
};
|
|
1196
|
+
webPropEdits.push(...webDOMResult.edits);
|
|
1197
|
+
const unsafeSpread = input.element.entries.find((entry) => entry.kind === "spread" && !styleEntries.includes(entry) && entry.value.kind === "static" && staticObject(entry.value.value) && Object.keys(entry.value.value).some((name) => isStyleProp(name, component)));
|
|
1198
|
+
if (unsafeSpread) return bailout(input, "local/unsafe-style-spread", "A mixed style/non-style spread cannot be removed transactionally", unsafeSpread.span);
|
|
1199
|
+
if (platform === "native") {
|
|
1200
|
+
const nativeStyleResolved = split.viewProps?.style;
|
|
1201
|
+
let themedStyleKeys = null;
|
|
1202
|
+
let nativeStyle = nativeStyleResolved;
|
|
1203
|
+
if (staticObject(nativeStyleResolved)) {
|
|
1204
|
+
for (const [styleKey, styleValue] of Object.entries(nativeStyleResolved)) {
|
|
1205
|
+
if (!core.containsThemeRef(styleValue)) continue;
|
|
1206
|
+
const themeKey = core.themeRefKey(styleValue);
|
|
1207
|
+
if (!themeKey) return bailout(input, "local/dynamic-style-value", `Style ${styleKey} uses a theme value in a compound or modified position that compiled output cannot represent`);
|
|
1208
|
+
(themedStyleKeys ||= {})[styleKey] = themeKey;
|
|
1209
|
+
}
|
|
1210
|
+
if (themedStyleKeys) {
|
|
1211
|
+
const plain = {};
|
|
1212
|
+
for (const [styleKey, styleValue] of Object.entries(nativeStyleResolved)) if (!(styleKey in themedStyleKeys)) plain[styleKey] = styleValue;
|
|
1213
|
+
nativeStyle = plain;
|
|
1214
|
+
}
|
|
1215
|
+
} else if (core.containsThemeRef(nativeStyleResolved)) return bailout(input, "local/dynamic-style-value", "Theme values inside non-object native style output stay on the runtime path");
|
|
1216
|
+
if (!isSerializableNativeStyle(nativeStyle)) return bailout(input, "local/unsupported-target", "Native style output is not a static serializable value");
|
|
1217
|
+
const nativeStyleLocal = unusedIdentifier(input.source, `__TamaguiNativeStyle${input.element.span.start}`);
|
|
1218
|
+
const nativeStyleImports = [{
|
|
1219
|
+
content: `
|
|
1220
|
+
function ${nativeStyleLocal}() { return ${nativeStyleLocal}._ ?? (${nativeStyleLocal}._ = ${JSON.stringify(nativeStyle ?? {})}); } ${nativeStyleLocal}();`,
|
|
1221
|
+
origin: input.element.component.span
|
|
1222
|
+
}];
|
|
1223
|
+
const nativeStyleSource = `${nativeStyleLocal}._ ?? ${nativeStyleLocal}()`;
|
|
1224
|
+
let nativeFastPath;
|
|
1225
|
+
if (themedStyleKeys && options.experimentalNativeFastPath && dynamicStyleEntries.length === 0 && !input.element.entries.some((entry) => entry.kind === "spread")) {
|
|
1226
|
+
const mappingLocal = unusedIdentifier(input.source, `__TamaguiNativeMapping${input.element.span.start}`);
|
|
1227
|
+
nativeFastPath = {
|
|
1228
|
+
mappingLocal,
|
|
1229
|
+
imports: [{
|
|
1230
|
+
content: `
|
|
1231
|
+
const ${mappingLocal} = ${JSON.stringify(themedStyleKeys)};`,
|
|
1232
|
+
origin: input.element.component.span
|
|
1233
|
+
}]
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
if (component.domTag) {
|
|
1237
|
+
if (themedStyleKeys) return bailout(input, "local/unsupported-target", "Theme values on DOM-tag native output stay on the runtime path");
|
|
1238
|
+
const row = import_dom.TAGS[component.domTag];
|
|
1239
|
+
const basePrimitive = import_dom.NATIVE_BACKING[row.backing].primitive;
|
|
1240
|
+
let primitive = basePrimitive;
|
|
1241
|
+
const propsResult = nativeDOMProps(input, component.domTag);
|
|
1242
|
+
if (propsResult.diagnostic) return bailout(input, "local/unsupported-target", propsResult.diagnostic, propsResult.diagnosticSpan);
|
|
1243
|
+
styleEntries = [.../* @__PURE__ */ new Set([...styleEntries, ...propsResult.consumed])];
|
|
1244
|
+
let nativeDOMStyleSource = nativeStyleSource;
|
|
1245
|
+
let runtimeStyleSource = null;
|
|
1246
|
+
if (domStyleProgram?.kind === "prop" && domStyleProgram.value.kind === "dom-style") {
|
|
1247
|
+
const needsRuntime = domStyleProgram.value.items.some((item) => item.value.kind === "static" && staticObject(item.value.value) && (Object.keys(item.value.value).some((property) => nativeRuntimeOnlyStyleProperties.has(property)) || Object.values(item.value.value).some((value) => typeof value === "string" && (flatClausePattern.test(value) || nativeInheritedKeywordPattern.test(value)))));
|
|
1248
|
+
const itemSources = [];
|
|
1249
|
+
for (const item of domStyleProgram.value.items) {
|
|
1250
|
+
if (item.value.kind !== "static" || !staticObject(item.value.value)) return bailout(input, "local/dynamic-style-value", "Every style() handle in a style array must be statically evaluable", item.value.span);
|
|
1251
|
+
if (Object.values(item.value.value).some((value2) => typeof value2 === "string" && nativeInitialKeywordPattern.test(value2))) return bailout(input, "local/unsupported-target", "Native DOM style() does not support the CSS initial keyword, matching the pinned upstream limitation", item.value.span);
|
|
1252
|
+
let value;
|
|
1253
|
+
if (needsRuntime) value = JSON.stringify(item.value.value);
|
|
1254
|
+
else {
|
|
1255
|
+
const itemStyle = resolveSplitStyles(item.value.value, partialStaticConfig(component.staticConfig))?.viewProps?.style;
|
|
1256
|
+
if (!isSerializableNativeStyle(itemStyle) || core.containsThemeRef(itemStyle)) return bailout(input, "local/unsupported-target", "Native style() output is not serializable", item.value.span);
|
|
1257
|
+
value = JSON.stringify(itemStyle ?? {});
|
|
1258
|
+
}
|
|
1259
|
+
const condition = item.condition ? input.source.slice(item.condition.start, item.condition.end) : null;
|
|
1260
|
+
itemSources.push(condition ? `(${condition}) && ${value}` : value);
|
|
1261
|
+
}
|
|
1262
|
+
if (needsRuntime) {
|
|
1263
|
+
primitive = `DOMRuntime${basePrimitive.slice(3)}`;
|
|
1264
|
+
runtimeStyleSource = `[${itemSources.join(", ")}]`;
|
|
1265
|
+
} else nativeDOMStyleSource = `[${[nativeDOMStyleSource, ...itemSources].join(", ")}]`;
|
|
1266
|
+
}
|
|
1267
|
+
const nativeLocal2 = unusedIdentifier(input.source, `__Tamagui${primitive}`);
|
|
1268
|
+
const propertyContent = [
|
|
1269
|
+
input.element.form === "jsx" ? `style={${nativeDOMStyleSource}}` : `style: ${nativeDOMStyleSource}`,
|
|
1270
|
+
runtimeStyleSource ? input.element.form === "jsx" ? `__styles={${runtimeStyleSource}}` : `__styles: ${runtimeStyleSource}` : "",
|
|
1271
|
+
serializedProps(input.element.form, propsResult.additions)
|
|
1272
|
+
].filter(Boolean).join(input.element.form === "jsx" ? " " : ", ");
|
|
1273
|
+
const primitiveTagEdits = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1274
|
+
start: span.start,
|
|
1275
|
+
end: span.end,
|
|
1276
|
+
content: input.element.form === "jsx" ? nativeLocal2 : JSON.stringify(nativeLocal2).slice(1, -1),
|
|
1277
|
+
origin: span
|
|
1278
|
+
}));
|
|
1279
|
+
const literalEdits = [];
|
|
1280
|
+
const imports = [...nativeStyleImports, {
|
|
1281
|
+
content: `
|
|
1282
|
+
import { ${primitive} as ${nativeLocal2} } from ${JSON.stringify(import_dom.NATIVE_PRIMITIVE_MODULE)}
|
|
1283
|
+
`,
|
|
1284
|
+
origin: input.element.component.span
|
|
1285
|
+
}];
|
|
1286
|
+
if (import_dom.NATIVE_BACKING[row.backing].wrapsLiteralText) {
|
|
1287
|
+
const textLocal = unusedIdentifier(input.source, "__TamaguiDOMText");
|
|
1288
|
+
const createElementLocal = unusedIdentifier(input.source, "__TamaguiCreateElement");
|
|
1289
|
+
let needsText = false;
|
|
1290
|
+
let needsCreateElement = false;
|
|
1291
|
+
for (const entry of input.element.entries) {
|
|
1292
|
+
if (entry.kind !== "child") continue;
|
|
1293
|
+
if (entry.value.kind === "empty" || entry.value.kind === "element" || entry.value.kind === "static" && (entry.value.value === null || typeof entry.value.value === "boolean")) continue;
|
|
1294
|
+
if (entry.value.kind !== "static" || entry.value.literalOrigin !== true || typeof entry.value.value !== "string" && typeof entry.value.value !== "number") return bailout(input, "local/unsupported-child", `html.${component.domTag} has a direct child that may render unwrapped native text; write a literal as JSX text or wrap the child in html.span`, entry.span);
|
|
1295
|
+
needsText = true;
|
|
1296
|
+
const child = input.source.slice(entry.span.start, entry.span.end);
|
|
1297
|
+
if (input.element.form === "jsx") literalEdits.push({
|
|
1298
|
+
start: entry.span.start,
|
|
1299
|
+
end: entry.span.end,
|
|
1300
|
+
content: `<${textLocal} __inherit>${child}</${textLocal}>`,
|
|
1301
|
+
origin: entry.span
|
|
1302
|
+
});
|
|
1303
|
+
else {
|
|
1304
|
+
needsCreateElement = true;
|
|
1305
|
+
literalEdits.push({
|
|
1306
|
+
start: entry.span.start,
|
|
1307
|
+
end: entry.span.end,
|
|
1308
|
+
content: `${createElementLocal}(${textLocal}, { __inherit: true }, ${child})`,
|
|
1309
|
+
origin: entry.span
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (needsText) imports.push({
|
|
1314
|
+
content: `
|
|
1315
|
+
import { DOMText as ${textLocal} } from ${JSON.stringify(import_dom.NATIVE_PRIMITIVE_MODULE)}
|
|
1316
|
+
`,
|
|
1317
|
+
origin: input.element.component.span
|
|
1318
|
+
});
|
|
1319
|
+
if (needsCreateElement) imports.push({
|
|
1320
|
+
content: `
|
|
1321
|
+
import { createElement as ${createElementLocal} } from "react"
|
|
1322
|
+
`,
|
|
1323
|
+
origin: input.element.component.span
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
const propsEdits = input.element.form === "jsx" ? styleEntries.length === 0 ? [{
|
|
1327
|
+
start: input.element.component.span.end,
|
|
1328
|
+
end: input.element.component.span.end,
|
|
1329
|
+
content: ` ${propertyContent}`,
|
|
1330
|
+
origin: input.element.component.span
|
|
1331
|
+
}] : [{
|
|
1332
|
+
start: styleEntries[0].span.start,
|
|
1333
|
+
end: styleEntries[0].span.end,
|
|
1334
|
+
content: propertyContent,
|
|
1335
|
+
origin: styleEntries[0].span
|
|
1336
|
+
}, ...styleEntries.slice(1).map((entry) => ({
|
|
1337
|
+
start: entry.span.start,
|
|
1338
|
+
end: entry.span.end,
|
|
1339
|
+
content: "",
|
|
1340
|
+
origin: entry.span
|
|
1341
|
+
}))] : compiledPropsEdits(input, styleEntries, propertyContent);
|
|
1342
|
+
if (!propsEdits) return bailout(input, "local/unsupported-target", `Compiled ${input.element.form} call has no editable props argument`);
|
|
1343
|
+
return {
|
|
1344
|
+
ok: true,
|
|
1345
|
+
edits: [
|
|
1346
|
+
...primitiveTagEdits,
|
|
1347
|
+
...propsResult.edits,
|
|
1348
|
+
...propsEdits,
|
|
1349
|
+
...literalEdits
|
|
1350
|
+
],
|
|
1351
|
+
css: [],
|
|
1352
|
+
imports,
|
|
1353
|
+
flattened: true
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
const nativeName = component.staticConfig.isText ? "Text" : "View";
|
|
1357
|
+
const useHostView = options.experimentalNativeFastPath && nativeName === "View" && isBareHostView(input.element);
|
|
1358
|
+
const nativeExport = useHostView ? "unstable_NativeView" : nativeName;
|
|
1359
|
+
const nativeLocal = unusedIdentifier(input.source, `__TamaguiNative${useHostView ? "HostView" : nativeName}`);
|
|
1360
|
+
if (themedStyleKeys && options.disablePartialExtraction) return bailout(input, "local/dynamic-style-value", "Theme values require partial extraction, which is disabled");
|
|
1361
|
+
if (dynamicStyleEntries.length > 0 || themedStyleKeys) {
|
|
1362
|
+
if (nativeFastPath) {
|
|
1363
|
+
const fastLocal = `__TamaguiNativeFast${nativeName}${input.element.span.start}`;
|
|
1364
|
+
const tagEdits4 = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1365
|
+
start: span.start,
|
|
1366
|
+
end: span.end,
|
|
1367
|
+
content: fastLocal,
|
|
1368
|
+
origin: span
|
|
1369
|
+
}));
|
|
1370
|
+
const [first4, ...rest4] = styleEntries;
|
|
1371
|
+
const styleEdits = styleEntries.length === 0 ? [] : input.element.form === "jsx" ? [{
|
|
1372
|
+
start: first4.span.start,
|
|
1373
|
+
end: first4.span.end,
|
|
1374
|
+
content: "",
|
|
1375
|
+
origin: first4.span
|
|
1376
|
+
}, ...rest4.map((entry) => ({
|
|
1377
|
+
start: entry.span.start,
|
|
1378
|
+
end: entry.span.end,
|
|
1379
|
+
content: "",
|
|
1380
|
+
origin: entry.span
|
|
1381
|
+
}))] : compiledPropsEdits(input, styleEntries, `_expressions: []`);
|
|
1382
|
+
if (!styleEdits) return bailout(input, "local/unsupported-target", `Compiled ${input.element.form} call has no editable props argument`);
|
|
1383
|
+
return {
|
|
1384
|
+
ok: true,
|
|
1385
|
+
edits: [...tagEdits4, ...styleEdits],
|
|
1386
|
+
css: [],
|
|
1387
|
+
imports: [
|
|
1388
|
+
...nativeStyleImports,
|
|
1389
|
+
...nativeFastPath.imports,
|
|
1390
|
+
{
|
|
1391
|
+
content: `
|
|
1392
|
+
const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
1393
|
+
origin: input.element.component.span
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
content: `
|
|
1397
|
+
const ${fastLocal} = require('@tamagui/core')._withNativeStyle(${nativeLocal}, ${nativeStyleSource}, ${nativeFastPath.mappingLocal});`,
|
|
1398
|
+
origin: input.element.component.span
|
|
1399
|
+
}
|
|
1400
|
+
],
|
|
1401
|
+
flattened: true
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
const stableLocal = `__TamaguiStable${nativeName}${input.element.span.start}`;
|
|
1405
|
+
const expressions = [];
|
|
1406
|
+
const plainDynamicParts = [];
|
|
1407
|
+
const conditionalParts = [];
|
|
1408
|
+
const conditionalKeys = /* @__PURE__ */ new Set();
|
|
1409
|
+
const baseStyleForDiff = staticObject(nativeStyleResolved) ? nativeStyleResolved : {};
|
|
1410
|
+
for (const entry of dynamicStyleEntries) if (entry.value.kind === "conditional" && directStyleName(entry.name, component) !== "opacity") {
|
|
1411
|
+
const branchDiffs = [];
|
|
1412
|
+
for (const branchValue of [entry.value.whenTrue, entry.value.whenFalse]) {
|
|
1413
|
+
const branchSplit = resolveSplitStyles({
|
|
1414
|
+
...completeProps,
|
|
1415
|
+
[entry.name]: branchValue
|
|
1416
|
+
}, component.staticConfig, cssAnimationDriver, component.displayName);
|
|
1417
|
+
const branchStyle = branchSplit?.viewProps?.style;
|
|
1418
|
+
if (!staticObject(branchStyle)) return bailout(input, "local/dynamic-style-value", `Conditional ${entry.name} branch did not resolve to a static native style`, entry.value.span);
|
|
1419
|
+
for (const viewPropsKey of /* @__PURE__ */ new Set([...Object.keys(branchSplit?.viewProps ?? {}), ...Object.keys(split.viewProps ?? {})])) {
|
|
1420
|
+
if (viewPropsKey === "style") continue;
|
|
1421
|
+
if (JSON.stringify(branchSplit?.viewProps?.[viewPropsKey]) !== JSON.stringify(split.viewProps?.[viewPropsKey])) return bailout(input, "local/dynamic-style-value", `Conditional ${entry.name} branch changes ${viewPropsKey}, which the compiled style array cannot express`, entry.value.span);
|
|
1422
|
+
}
|
|
1423
|
+
for (const key of Object.keys(baseStyleForDiff)) if (!(key in branchStyle)) return bailout(input, "local/dynamic-style-value", `Conditional ${entry.name} branch removes ${key}, which an additive style array cannot express`, entry.value.span);
|
|
1424
|
+
const diff = {};
|
|
1425
|
+
for (const [key, value] of Object.entries(branchStyle)) if (JSON.stringify(baseStyleForDiff[key]) !== JSON.stringify(value)) diff[key] = value;
|
|
1426
|
+
if (!isSerializableNativeStyle(diff) || core.containsThemeRef(diff)) return bailout(input, "local/dynamic-style-value", `Conditional ${entry.name} branch style is not statically representable`, entry.value.span);
|
|
1427
|
+
for (const key of Object.keys(diff)) if (conditionalKeys.has(key)) return bailout(input, "local/dynamic-style-value", `Multiple conditionals contribute ${key}; their interaction cannot be resolved per-branch`, entry.value.span);
|
|
1428
|
+
branchDiffs.push(diff);
|
|
1429
|
+
}
|
|
1430
|
+
for (const diff of branchDiffs) for (const key of Object.keys(diff)) conditionalKeys.add(key);
|
|
1431
|
+
const index = expressions.length;
|
|
1432
|
+
expressions.push(input.source.slice(entry.value.test.start, entry.value.test.end));
|
|
1433
|
+
conditionalParts.push(`expressions[${index}] ? ${JSON.stringify(branchDiffs[0])} : ${JSON.stringify(branchDiffs[1])}`);
|
|
1434
|
+
} else {
|
|
1435
|
+
const index = expressions.length;
|
|
1436
|
+
expressions.push(input.source.slice(entry.value.span.start, entry.value.span.end));
|
|
1437
|
+
plainDynamicParts.push(`${JSON.stringify(directStyleName(entry.name, component))}: expressions[${index}]`);
|
|
1438
|
+
}
|
|
1439
|
+
const dynamicStyle = plainDynamicParts.join(", ");
|
|
1440
|
+
const themedStyle = themedStyleKeys ? Object.entries(themedStyleKeys).map(([styleKey, themeKey]) => `${JSON.stringify(styleKey)}: _theme[${JSON.stringify(themeKey)}]?.get()`).join(", ") : null;
|
|
1441
|
+
const styleParts = [
|
|
1442
|
+
nativeStyleSource,
|
|
1443
|
+
...themedStyle ? [`{ ${themedStyle} }`] : [],
|
|
1444
|
+
...conditionalParts,
|
|
1445
|
+
...dynamicStyle ? [`{ ${dynamicStyle} }`] : []
|
|
1446
|
+
];
|
|
1447
|
+
const tagEdits3 = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1448
|
+
start: span.start,
|
|
1449
|
+
end: span.end,
|
|
1450
|
+
content: stableLocal,
|
|
1451
|
+
origin: span
|
|
1452
|
+
}));
|
|
1453
|
+
const [first3, ...rest3] = styleEntries;
|
|
1454
|
+
const expressionEdits = styleEntries.length === 0 ? [] : input.element.form === "jsx" ? [{
|
|
1455
|
+
start: first3.span.start,
|
|
1456
|
+
end: first3.span.end,
|
|
1457
|
+
content: expressions.length > 0 ? `_expressions={[${expressions.join(", ")}]}` : "",
|
|
1458
|
+
origin: first3.span
|
|
1459
|
+
}, ...rest3.map((entry) => ({
|
|
1460
|
+
start: entry.span.start,
|
|
1461
|
+
end: entry.span.end,
|
|
1462
|
+
content: "",
|
|
1463
|
+
origin: entry.span
|
|
1464
|
+
}))] : compiledPropsEdits(input, styleEntries, `_expressions: [${expressions.join(", ")}]`);
|
|
1465
|
+
if (!expressionEdits) return bailout(input, "local/unsupported-target", `Compiled ${input.element.form} call has no editable props argument`);
|
|
1466
|
+
return {
|
|
1467
|
+
ok: true,
|
|
1468
|
+
edits: [...tagEdits3, ...expressionEdits],
|
|
1469
|
+
css: [],
|
|
1470
|
+
imports: [
|
|
1471
|
+
...nativeStyleImports,
|
|
1472
|
+
{
|
|
1473
|
+
content: `
|
|
1474
|
+
const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
1475
|
+
origin: input.element.component.span
|
|
1476
|
+
},
|
|
1477
|
+
{
|
|
1478
|
+
content: `
|
|
1479
|
+
const ${stableLocal} = require('@tamagui/core')._withStableStyle(${nativeLocal}, (_theme, expressions) => [${styleParts.join(", ")}], ${themedStyleKeys ? "true" : "false"}, false);`,
|
|
1480
|
+
origin: input.element.component.span
|
|
1481
|
+
}
|
|
1482
|
+
],
|
|
1483
|
+
flattened: true
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
const styleContent = `style: ${nativeStyleSource}`;
|
|
1487
|
+
const tagEdits2 = [input.element.component.span, input.element.component.closingSpan].filter((span) => !!span).map((span) => ({
|
|
1488
|
+
start: span.start,
|
|
1489
|
+
end: span.end,
|
|
1490
|
+
content: nativeLocal,
|
|
1491
|
+
origin: span
|
|
1492
|
+
}));
|
|
1493
|
+
if (input.element.form !== "jsx") {
|
|
1494
|
+
const propsEdits = compiledPropsEdits(input, styleEntries, styleContent);
|
|
1495
|
+
if (!propsEdits) return bailout(input, "local/unsupported-target", `Compiled ${input.element.form} call has no editable props argument`);
|
|
1496
|
+
return {
|
|
1497
|
+
ok: true,
|
|
1498
|
+
edits: [...tagEdits2, ...propsEdits],
|
|
1499
|
+
css: [],
|
|
1500
|
+
imports: [...nativeStyleImports, {
|
|
1501
|
+
content: `
|
|
1502
|
+
const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
1503
|
+
origin: input.element.component.span
|
|
1504
|
+
}],
|
|
1505
|
+
flattened: true
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
if (styleEntries.length === 0) return {
|
|
1509
|
+
ok: true,
|
|
1510
|
+
edits: [...tagEdits2, {
|
|
1511
|
+
start: input.element.component.span.end,
|
|
1512
|
+
end: input.element.component.span.end,
|
|
1513
|
+
content: ` style={${nativeStyleSource}}`,
|
|
1514
|
+
origin: input.element.component.span
|
|
1515
|
+
}],
|
|
1516
|
+
css: [],
|
|
1517
|
+
imports: [...nativeStyleImports, {
|
|
1518
|
+
content: `
|
|
1519
|
+
const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
1520
|
+
origin: input.element.component.span
|
|
1521
|
+
}],
|
|
1522
|
+
flattened: true
|
|
1523
|
+
};
|
|
1524
|
+
const [first2, ...rest2] = styleEntries;
|
|
1525
|
+
return {
|
|
1526
|
+
ok: true,
|
|
1527
|
+
edits: [
|
|
1528
|
+
...tagEdits2,
|
|
1529
|
+
...webPropEdits,
|
|
1530
|
+
{
|
|
1531
|
+
start: first2.span.start,
|
|
1532
|
+
end: first2.span.end,
|
|
1533
|
+
content: `style={${nativeStyleSource}}`,
|
|
1534
|
+
origin: first2.span
|
|
1535
|
+
},
|
|
1536
|
+
...rest2.map((entry) => ({
|
|
1537
|
+
start: entry.span.start,
|
|
1538
|
+
end: entry.span.end,
|
|
1539
|
+
content: "",
|
|
1540
|
+
origin: entry.span
|
|
1541
|
+
}))
|
|
1542
|
+
],
|
|
1543
|
+
css: [],
|
|
1544
|
+
imports: [...nativeStyleImports, {
|
|
1545
|
+
content: `
|
|
1546
|
+
const ${nativeLocal} = require('react-native').${nativeExport};`,
|
|
1547
|
+
origin: input.element.component.span
|
|
1548
|
+
}],
|
|
1549
|
+
flattened: true
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
const artifacts = extractedStyleArtifacts(split, props, options.tamaguiConfig, !component.domTag, Boolean(component.staticConfig.styleFrontend));
|
|
1553
|
+
const className = artifacts.className;
|
|
1554
|
+
const rawInlineStyle = split.viewProps?.style;
|
|
1555
|
+
const inlineStyle = staticObject(rawInlineStyle) && !rawInlineStyle["$$css"] && Object.keys(rawInlineStyle).length > 0 ? rawInlineStyle : null;
|
|
1556
|
+
if (rawInlineStyle && !inlineStyle && !isSerializableNativeStyle(rawInlineStyle)) return bailout(input, "local/unsupported-target", "Web inline style output is not a static serializable value");
|
|
1557
|
+
const programCSS = [];
|
|
1558
|
+
const programClassSources = [];
|
|
1559
|
+
if (domStyleProgram?.kind === "prop" && domStyleProgram.value.kind === "dom-style") for (const item of domStyleProgram.value.items) {
|
|
1560
|
+
if (item.value.kind !== "static" || !staticObject(item.value.value)) return bailout(input, "local/dynamic-style-value", "Every style() handle in a style array must be statically evaluable", item.value.span);
|
|
1561
|
+
const itemSplit = resolveSplitStyles(item.value.value, partialStaticConfig(component.staticConfig));
|
|
1562
|
+
if (!itemSplit) return bailout(input, "local/style-resolution-failed", "A style() handle could not be resolved", item.value.span);
|
|
1563
|
+
const itemInline = itemSplit.viewProps?.style;
|
|
1564
|
+
if (staticObject(itemInline) && !itemInline["$$css"] && Object.keys(itemInline).length > 0) return bailout(input, "local/unsupported-target", "Conditional web style() handles must lower to CSS classes", item.value.span);
|
|
1565
|
+
const itemArtifacts = extractedStyleArtifacts(itemSplit, item.value.value, options.tamaguiConfig, false);
|
|
1566
|
+
programCSS.push(...itemArtifacts.css);
|
|
1567
|
+
if (itemArtifacts.className) {
|
|
1568
|
+
const condition = item.condition ? input.source.slice(item.condition.start, item.condition.end) : null;
|
|
1569
|
+
programClassSources.push(condition ? `(${condition}) && ${JSON.stringify(itemArtifacts.className)}` : JSON.stringify(itemArtifacts.className));
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
let webClassName = className;
|
|
1573
|
+
const webConditionalCSS = [];
|
|
1574
|
+
const webConditionalEntries = supportsWebConditionalClasses ? dynamicStyleEntries.filter((entry) => entry.value.kind === "conditional") : [];
|
|
1575
|
+
for (const entry of webConditionalEntries) {
|
|
1576
|
+
if (entry.value.kind !== "conditional") continue;
|
|
1577
|
+
const branches = [];
|
|
1578
|
+
for (const branchValue of [entry.value.whenTrue, entry.value.whenFalse]) {
|
|
1579
|
+
const branchSplit = resolveSplitStyles({
|
|
1580
|
+
...completeProps,
|
|
1581
|
+
[entry.name]: branchValue
|
|
1582
|
+
}, component.staticConfig, cssAnimationDriver, component.displayName);
|
|
1583
|
+
if (!branchSplit) return bailout(input, "local/dynamic-style-value", `Conditional ${entry.name} branch could not be resolved`, entry.value.span);
|
|
1584
|
+
for (const viewPropsKey of /* @__PURE__ */ new Set([...Object.keys(branchSplit.viewProps ?? {}), ...Object.keys(split.viewProps ?? {})])) {
|
|
1585
|
+
if (viewPropsKey === "className") continue;
|
|
1586
|
+
if (JSON.stringify(branchSplit.viewProps?.[viewPropsKey]) !== JSON.stringify(split.viewProps?.[viewPropsKey])) return bailout(input, "local/dynamic-style-value", `Conditional ${entry.name} branch changes ${viewPropsKey}, which conditional classes cannot express`, entry.value.span);
|
|
1587
|
+
}
|
|
1588
|
+
const branchArtifacts = extractedStyleArtifacts(branchSplit, {
|
|
1589
|
+
...props,
|
|
1590
|
+
[entry.name]: branchValue
|
|
1591
|
+
}, options.tamaguiConfig, !component.domTag, Boolean(component.staticConfig.styleFrontend));
|
|
1592
|
+
branches.push({
|
|
1593
|
+
classes: branchArtifacts.className.split(" ").filter(Boolean),
|
|
1594
|
+
css: branchArtifacts.css
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
const [whenTrue, whenFalse] = branches;
|
|
1598
|
+
const shared = new Set(whenTrue.classes.filter((item) => whenFalse.classes.includes(item)));
|
|
1599
|
+
const trueOnly = whenTrue.classes.filter((item) => !shared.has(item));
|
|
1600
|
+
const falseOnly = whenFalse.classes.filter((item) => !shared.has(item));
|
|
1601
|
+
webClassName = [...shared].join(" ");
|
|
1602
|
+
webConditionalCSS.push(...whenTrue.css, ...whenFalse.css);
|
|
1603
|
+
if (trueOnly.length > 0 || falseOnly.length > 0) {
|
|
1604
|
+
const test = input.source.slice(entry.value.test.start, entry.value.test.end);
|
|
1605
|
+
programClassSources.push(`(${test}) ? ${JSON.stringify(trueOnly.join(" "))} : ${JSON.stringify(falseOnly.join(" "))}`);
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
const classNameExpression = programClassSources.length > 0 ? `[${[JSON.stringify(webClassName), ...programClassSources].join(", ")}].filter(Boolean).join(" ")` : null;
|
|
1609
|
+
const serializedInlineStyle = serializedStyle(inlineStyle, dynamicHostStyleProperties ?? []);
|
|
1610
|
+
const jsxWebStyle = classNameExpression ? [`className={${classNameExpression}}`, serializedInlineStyle ? `style={${serializedInlineStyle}}` : ""].filter(Boolean).join(" ") : jsxStyleAttributes(webClassName, inlineStyle, dynamicHostStyleProperties ?? []);
|
|
1611
|
+
const objectWebStyle = classNameExpression ? [`className: ${classNameExpression}`, serializedInlineStyle ? `style: ${serializedInlineStyle}` : ""].filter(Boolean).join(", ") : objectStyleProperties(webClassName, inlineStyle, dynamicHostStyleProperties ?? []);
|
|
1612
|
+
const webCSS = [.../* @__PURE__ */ new Set([
|
|
1613
|
+
...artifacts.css,
|
|
1614
|
+
...programCSS,
|
|
1615
|
+
...webConditionalCSS
|
|
1616
|
+
])];
|
|
1617
|
+
const webExtraProps = serializedProps(input.element.form, webDOMResult.additions);
|
|
1618
|
+
if (input.element.form !== "jsx") {
|
|
1619
|
+
const replacement = [objectWebStyle, webExtraProps].filter(Boolean).join(", ");
|
|
1620
|
+
const propsEdits = compiledPropsEdits(input, styleEntries, replacement);
|
|
1621
|
+
if (!propsEdits) return bailout(input, "local/unsupported-target", `Compiled ${input.element.form} call has no editable props argument`);
|
|
1622
|
+
return {
|
|
1623
|
+
ok: true,
|
|
1624
|
+
edits: [
|
|
1625
|
+
...tagEdits,
|
|
1626
|
+
...webPropEdits,
|
|
1627
|
+
...propsEdits
|
|
1628
|
+
],
|
|
1629
|
+
css: webCSS,
|
|
1630
|
+
imports: [],
|
|
1631
|
+
flattened: true
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
if (styleEntries.length === 0) {
|
|
1635
|
+
const attributes2 = [jsxWebStyle, webExtraProps].filter(Boolean).join(" ");
|
|
1636
|
+
return {
|
|
1637
|
+
ok: true,
|
|
1638
|
+
edits: attributes2 ? [
|
|
1639
|
+
...tagEdits,
|
|
1640
|
+
...webPropEdits,
|
|
1641
|
+
{
|
|
1642
|
+
start: input.element.component.span.end,
|
|
1643
|
+
end: input.element.component.span.end,
|
|
1644
|
+
content: ` ${attributes2}`,
|
|
1645
|
+
origin: input.element.component.span
|
|
1646
|
+
}
|
|
1647
|
+
] : [...tagEdits, ...webPropEdits],
|
|
1648
|
+
css: webCSS,
|
|
1649
|
+
imports: [],
|
|
1650
|
+
flattened: true
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
const [first, ...rest] = styleEntries;
|
|
1654
|
+
const attributes = [jsxWebStyle, webExtraProps].filter(Boolean).join(" ");
|
|
1655
|
+
return {
|
|
1656
|
+
ok: true,
|
|
1657
|
+
edits: [
|
|
1658
|
+
...tagEdits,
|
|
1659
|
+
...webPropEdits,
|
|
1660
|
+
{
|
|
1661
|
+
start: first.span.start,
|
|
1662
|
+
end: first.span.end,
|
|
1663
|
+
content: attributes,
|
|
1664
|
+
origin: first.span
|
|
1665
|
+
},
|
|
1666
|
+
...rest.map((entry) => ({
|
|
1667
|
+
start: entry.span.start,
|
|
1668
|
+
end: entry.span.end,
|
|
1669
|
+
content: "",
|
|
1670
|
+
origin: entry.span
|
|
1671
|
+
}))
|
|
1672
|
+
],
|
|
1673
|
+
css: webCSS,
|
|
1674
|
+
imports: [],
|
|
1675
|
+
flattened: true
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
function bailout(input, code, message, span = input.element.span, zero) {
|
|
1681
|
+
return {
|
|
1682
|
+
ok: false,
|
|
1683
|
+
bailout: {
|
|
1684
|
+
code,
|
|
1685
|
+
kind: "local",
|
|
1686
|
+
message,
|
|
1687
|
+
span,
|
|
1688
|
+
component: input.element.component.name,
|
|
1689
|
+
...zero && {
|
|
1690
|
+
zeroRule: zero.rule,
|
|
1691
|
+
zeroMessage: zero.message
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
}
|