@tamagui/static 1.135.2 → 1.135.4-1761748186554
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/check-dep-versions.mjs +268 -0
- package/dist/check-dep-versions.mjs.map +1 -0
- package/dist/checkDeps.mjs +33 -0
- package/dist/checkDeps.mjs.map +1 -0
- package/dist/constants.mjs +50 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/exports.mjs +42 -0
- package/dist/exports.mjs.map +1 -0
- package/dist/extractor/accessSafe.mjs +47 -0
- package/dist/extractor/accessSafe.mjs.map +1 -0
- package/dist/extractor/babelParse.mjs +55 -0
- package/dist/extractor/babelParse.mjs.map +1 -0
- package/dist/extractor/bundle.mjs +149 -0
- package/dist/extractor/bundle.mjs.map +1 -0
- package/dist/extractor/bundleConfig.mjs +331 -0
- package/dist/extractor/bundleConfig.mjs.map +1 -0
- package/dist/extractor/concatClassName.mjs +79 -0
- package/dist/extractor/concatClassName.mjs.map +1 -0
- package/dist/extractor/createEvaluator.mjs +76 -0
- package/dist/extractor/createEvaluator.mjs.map +1 -0
- package/dist/extractor/createExtractor.mjs +976 -0
- package/dist/extractor/createExtractor.mjs.map +1 -0
- package/dist/extractor/createLogger.mjs +46 -0
- package/dist/extractor/createLogger.mjs.map +1 -0
- package/dist/extractor/errors.mjs +27 -0
- package/dist/extractor/errors.mjs.map +1 -0
- package/dist/extractor/esbuildAliasPlugin.mjs +45 -0
- package/dist/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/extractor/esbuildTsconfigPaths.mjs +85 -0
- package/dist/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/extractor/evaluateAstNode.mjs +84 -0
- package/dist/extractor/evaluateAstNode.mjs.map +1 -0
- package/dist/extractor/extractHelpers.mjs +121 -0
- package/dist/extractor/extractHelpers.mjs.map +1 -0
- package/dist/extractor/extractMediaStyle.mjs +129 -0
- package/dist/extractor/extractMediaStyle.mjs.map +1 -0
- package/dist/extractor/extractToClassNames.mjs +304 -0
- package/dist/extractor/extractToClassNames.mjs.map +1 -0
- package/dist/extractor/extractToNative.mjs +262 -0
- package/dist/extractor/extractToNative.mjs.map +1 -0
- package/dist/extractor/findTopmostFunction.mjs +35 -0
- package/dist/extractor/findTopmostFunction.mjs.map +1 -0
- package/dist/extractor/{generatedUid.native.js → generatedUid.mjs} +26 -23
- package/dist/extractor/generatedUid.mjs.map +1 -0
- package/dist/extractor/getPrefixLogs.mjs +30 -0
- package/dist/extractor/getPrefixLogs.mjs.map +1 -0
- package/dist/extractor/getPropValueFromAttributes.mjs +68 -0
- package/dist/extractor/getPropValueFromAttributes.mjs.map +1 -0
- package/dist/extractor/getSourceModule.mjs +65 -0
- package/dist/extractor/getSourceModule.mjs.map +1 -0
- package/dist/extractor/getStaticBindingsForScope.mjs +149 -0
- package/dist/extractor/getStaticBindingsForScope.mjs.map +1 -0
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +36 -0
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/extractor/literalToAst.mjs +85 -0
- package/dist/extractor/literalToAst.mjs.map +1 -0
- package/dist/extractor/loadFile.mjs +12 -0
- package/dist/extractor/loadFile.mjs.map +1 -0
- package/dist/extractor/loadTamagui.mjs +296 -0
- package/dist/extractor/loadTamagui.mjs.map +1 -0
- package/dist/extractor/logLines.mjs +36 -0
- package/dist/extractor/logLines.mjs.map +1 -0
- package/dist/extractor/{normalizeTernaries.native.js → normalizeTernaries.mjs} +45 -31
- package/dist/extractor/normalizeTernaries.mjs.map +1 -0
- package/dist/extractor/propsToFontFamilyCache.mjs +39 -0
- package/dist/extractor/propsToFontFamilyCache.mjs.map +1 -0
- package/dist/extractor/regenerateConfig.mjs +145 -0
- package/dist/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/extractor/removeUnusedHooks.mjs +77 -0
- package/dist/extractor/removeUnusedHooks.mjs.map +1 -0
- package/dist/extractor/timer.mjs +44 -0
- package/dist/extractor/timer.mjs.map +1 -0
- package/dist/extractor/{validHTMLAttributes.native.js → validHTMLAttributes.mjs} +17 -16
- package/dist/extractor/validHTMLAttributes.mjs.map +1 -0
- package/dist/extractor/watchTamaguiConfig.mjs +59 -0
- package/dist/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/getPragmaOptions.mjs +55 -0
- package/dist/getPragmaOptions.mjs.map +1 -0
- package/dist/helpers/memoize.mjs +38 -0
- package/dist/helpers/memoize.mjs.map +1 -0
- package/dist/helpers/requireTamaguiCore.mjs +34 -0
- package/dist/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -0
- package/dist/registerRequire.mjs +107 -0
- package/dist/registerRequire.mjs.map +1 -0
- package/dist/server.mjs +76 -0
- package/dist/server.mjs.map +1 -0
- package/dist/setup.mjs +2 -0
- package/dist/setup.mjs.map +1 -0
- package/dist/{types.native.js → types.mjs} +8 -6
- package/dist/types.mjs.map +1 -0
- package/package.json +19 -21
- package/dist/check-dep-versions.native.js +0 -602
- package/dist/check-dep-versions.native.js.map +0 -6
- package/dist/checkDeps.native.js +0 -34
- package/dist/checkDeps.native.js.map +0 -6
- package/dist/constants.native.js +0 -45
- package/dist/constants.native.js.map +0 -6
- package/dist/exports.native.js +0 -52
- package/dist/exports.native.js.map +0 -6
- package/dist/extractor/accessSafe.native.js +0 -48
- package/dist/extractor/accessSafe.native.js.map +0 -6
- package/dist/extractor/babelParse.native.js +0 -62
- package/dist/extractor/babelParse.native.js.map +0 -6
- package/dist/extractor/bundle.native.js +0 -168
- package/dist/extractor/bundle.native.js.map +0 -6
- package/dist/extractor/bundleConfig.native.js +0 -394
- package/dist/extractor/bundleConfig.native.js.map +0 -6
- package/dist/extractor/concatClassName.native.js +0 -69
- package/dist/extractor/concatClassName.native.js.map +0 -6
- package/dist/extractor/createEvaluator.native.js +0 -63
- package/dist/extractor/createEvaluator.native.js.map +0 -6
- package/dist/extractor/createExtractor.native.js +0 -1229
- package/dist/extractor/createExtractor.native.js.map +0 -6
- package/dist/extractor/createLogger.native.js +0 -35
- package/dist/extractor/createLogger.native.js.map +0 -6
- package/dist/extractor/errors.native.js +0 -119
- package/dist/extractor/errors.native.js.map +0 -6
- package/dist/extractor/esbuildAliasPlugin.native.js +0 -52
- package/dist/extractor/esbuildAliasPlugin.native.js.map +0 -6
- package/dist/extractor/esbuildTsconfigPaths.native.js +0 -79
- package/dist/extractor/esbuildTsconfigPaths.native.js.map +0 -6
- package/dist/extractor/evaluateAstNode.native.js +0 -98
- package/dist/extractor/evaluateAstNode.native.js.map +0 -6
- package/dist/extractor/extractHelpers.native.js +0 -183
- package/dist/extractor/extractHelpers.native.js.map +0 -6
- package/dist/extractor/extractMediaStyle.native.js +0 -138
- package/dist/extractor/extractMediaStyle.native.js.map +0 -6
- package/dist/extractor/extractToClassNames.native.js +0 -332
- package/dist/extractor/extractToClassNames.native.js.map +0 -6
- package/dist/extractor/extractToNative.native.js +0 -276
- package/dist/extractor/extractToNative.native.js.map +0 -6
- package/dist/extractor/findTopmostFunction.native.js +0 -37
- package/dist/extractor/findTopmostFunction.native.js.map +0 -6
- package/dist/extractor/generatedUid.native.js.map +0 -6
- package/dist/extractor/getPrefixLogs.native.js +0 -30
- package/dist/extractor/getPrefixLogs.native.js.map +0 -6
- package/dist/extractor/getPropValueFromAttributes.native.js +0 -68
- package/dist/extractor/getPropValueFromAttributes.native.js.map +0 -6
- package/dist/extractor/getSourceModule.native.js +0 -80
- package/dist/extractor/getSourceModule.native.js.map +0 -6
- package/dist/extractor/getStaticBindingsForScope.native.js +0 -183
- package/dist/extractor/getStaticBindingsForScope.native.js.map +0 -6
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.native.js +0 -37
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +0 -6
- package/dist/extractor/literalToAst.native.js +0 -106
- package/dist/extractor/literalToAst.native.js.map +0 -6
- package/dist/extractor/loadFile.native.js +0 -21
- package/dist/extractor/loadFile.native.js.map +0 -6
- package/dist/extractor/loadTamagui.native.js +0 -314
- package/dist/extractor/loadTamagui.native.js.map +0 -6
- package/dist/extractor/logLines.native.js +0 -53
- package/dist/extractor/logLines.native.js.map +0 -6
- package/dist/extractor/normalizeTernaries.native.js.map +0 -6
- package/dist/extractor/propsToFontFamilyCache.native.js +0 -40
- package/dist/extractor/propsToFontFamilyCache.native.js.map +0 -6
- package/dist/extractor/regenerateConfig.native.js +0 -148
- package/dist/extractor/regenerateConfig.native.js.map +0 -6
- package/dist/extractor/removeUnusedHooks.native.js +0 -111
- package/dist/extractor/removeUnusedHooks.native.js.map +0 -6
- package/dist/extractor/timer.native.js +0 -44
- package/dist/extractor/timer.native.js.map +0 -6
- package/dist/extractor/validHTMLAttributes.native.js.map +0 -6
- package/dist/extractor/watchTamaguiConfig.native.js +0 -60
- package/dist/extractor/watchTamaguiConfig.native.js.map +0 -6
- package/dist/getPragmaOptions.native.js +0 -62
- package/dist/getPragmaOptions.native.js.map +0 -6
- package/dist/helpers/memoize.native.js +0 -40
- package/dist/helpers/memoize.native.js.map +0 -6
- package/dist/helpers/requireTamaguiCore.native.js +0 -34
- package/dist/helpers/requireTamaguiCore.native.js.map +0 -6
- package/dist/index.native.js +0 -35
- package/dist/index.native.js.map +0 -6
- package/dist/registerRequire.native.js +0 -124
- package/dist/registerRequire.native.js.map +0 -6
- package/dist/server.native.js +0 -70
- package/dist/server.native.js.map +0 -6
- package/dist/setup.native.js +0 -2
- package/dist/setup.native.js.map +0 -6
- package/dist/types.native.js.map +0 -6
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
-
var extractToClassNames_exports = {};
|
|
25
|
-
__export(extractToClassNames_exports, {
|
|
26
|
-
extractToClassNames: () => extractToClassNames
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(extractToClassNames_exports);
|
|
29
|
-
var import_generator = __toESM(require("@babel/generator")), t = __toESM(require("@babel/types")), import_web = require("@tamagui/web"), path = __toESM(require("node:path")), util = __toESM(require("node:util")), import_requireTamaguiCore = require("../helpers/requireTamaguiCore"), import_babelParse = require("./babelParse"), import_createLogger = require("./createLogger"), import_extractMediaStyle = require("./extractMediaStyle"), import_normalizeTernaries = require("./normalizeTernaries"), import_propsToFontFamilyCache = require("./propsToFontFamilyCache"), import_timer = require("./timer"), import_errors = require("./errors"), import_concatClassName = require("./concatClassName"), remove = function() {
|
|
30
|
-
}, spaceString = t.stringLiteral(" ");
|
|
31
|
-
async function extractToClassNames(param) {
|
|
32
|
-
var { extractor, source, sourcePath = "", options, shouldPrintDebug } = param, tm = (0, import_timer.timer)(), { getCSSStylesAtomic, createMediaStyle } = (0, import_requireTamaguiCore.requireTamaguiCore)("web");
|
|
33
|
-
if (sourcePath.includes("node_modules"))
|
|
34
|
-
return null;
|
|
35
|
-
if (shouldPrintDebug && console.warn(`--- ${sourcePath} ---
|
|
36
|
-
|
|
37
|
-
`), typeof source != "string")
|
|
38
|
-
throw new Error("`source` must be a string of javascript");
|
|
39
|
-
if (!path.isAbsolute(sourcePath))
|
|
40
|
-
throw new Error("`sourcePath` must be an absolute path to a .js file, got: " + sourcePath);
|
|
41
|
-
/.[tj]sx?$/i.test(sourcePath || "") || console.warn(`${sourcePath.slice(0, 100)} - bad filename.`), !options.disableExtraction && !options._disableLoadTamagui && await extractor.loadTamagui(options);
|
|
42
|
-
var printLog = (0, import_createLogger.createLogger)(sourcePath, options), ast;
|
|
43
|
-
try {
|
|
44
|
-
ast = (0, import_babelParse.babelParse)(source, sourcePath);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
throw console.error("babel parse error:", sourcePath.slice(0, 100)), err;
|
|
47
|
-
}
|
|
48
|
-
tm.mark("babel-parse", shouldPrintDebug === "verbose");
|
|
49
|
-
var cssMap = /* @__PURE__ */ new Map(), tamaguiConfig = extractor.getTamagui(), res = await extractor.parse(ast, {
|
|
50
|
-
shouldPrintDebug,
|
|
51
|
-
...options,
|
|
52
|
-
platform: "web",
|
|
53
|
-
sourcePath,
|
|
54
|
-
extractStyledDefinitions: !0,
|
|
55
|
-
onStyledDefinitionRule(identifier, rules) {
|
|
56
|
-
var css = rules.join(";");
|
|
57
|
-
shouldPrintDebug && console.info(`adding styled() rule: .${identifier} ${css}`), cssMap.set(`.${identifier}`, {
|
|
58
|
-
css,
|
|
59
|
-
commentTexts: []
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
getFlattenedNode: function(param2) {
|
|
63
|
-
var { tag } = param2;
|
|
64
|
-
return tag;
|
|
65
|
-
},
|
|
66
|
-
onExtractTag: function(param2) {
|
|
67
|
-
var { parserProps, attrs, node, attemptEval, jsxPath, originalNodeName, filePath, lineNumbers, staticConfig } = param2;
|
|
68
|
-
if (staticConfig.acceptsClassName === !1)
|
|
69
|
-
throw new import_errors.BailOptimizationError();
|
|
70
|
-
var finalAttrs = [], mergeForwardBaseStyle = null, attrClassName = null, baseFontFamily = "", mediaStylesSeen = 1, comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
|
|
71
|
-
function addStyle(style) {
|
|
72
|
-
var identifier = style[import_web.StyleObjectIdentifier], rules = style[import_web.StyleObjectRules], selector = `.${identifier}`;
|
|
73
|
-
if (cssMap.has(selector)) {
|
|
74
|
-
var val = cssMap.get(selector);
|
|
75
|
-
val.commentTexts.push(comment);
|
|
76
|
-
} else rules.length && cssMap.set(selector, {
|
|
77
|
-
css: rules.join(`
|
|
78
|
-
`),
|
|
79
|
-
commentTexts: [
|
|
80
|
-
comment
|
|
81
|
-
]
|
|
82
|
-
});
|
|
83
|
-
return identifier;
|
|
84
|
-
}
|
|
85
|
-
function addStyles(style) {
|
|
86
|
-
var cssStyles = getCSSStylesAtomic(style), classNames2 = [], _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
|
|
87
|
-
try {
|
|
88
|
-
for (var _iterator2 = cssStyles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
|
|
89
|
-
var _$style = _step2.value, mediaName = _$style[0].slice(1);
|
|
90
|
-
if (tamaguiConfig.media[mediaName]) {
|
|
91
|
-
var mediaStyle = createMediaStyle(_$style, mediaName, extractor.getTamagui().media, !0, !1, mediaStylesSeen), identifier = addStyle(mediaStyle);
|
|
92
|
-
classNames2.push(identifier);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
var identifier1 = addStyle(_$style);
|
|
96
|
-
classNames2.push(identifier1);
|
|
97
|
-
}
|
|
98
|
-
} catch (err) {
|
|
99
|
-
_didIteratorError2 = !0, _iteratorError2 = err;
|
|
100
|
-
} finally {
|
|
101
|
-
try {
|
|
102
|
-
!_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
|
|
103
|
-
} finally {
|
|
104
|
-
if (_didIteratorError2)
|
|
105
|
-
throw _iteratorError2;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return classNames2;
|
|
109
|
-
}
|
|
110
|
-
var onlyTernaries = attrs.flatMap(function(attr) {
|
|
111
|
-
if (attr.type === "attr") {
|
|
112
|
-
var value = attr.value;
|
|
113
|
-
if (t.isJSXSpreadAttribute(value))
|
|
114
|
-
return console.error("Should never happen"), [];
|
|
115
|
-
if (value.name.name === "className") {
|
|
116
|
-
var inner = value.value;
|
|
117
|
-
t.isJSXExpressionContainer(inner) && (inner = inner.expression);
|
|
118
|
-
try {
|
|
119
|
-
var evaluatedValue = inner ? attemptEval(inner) : null;
|
|
120
|
-
typeof evaluatedValue == "string" && (attrClassName = t.stringLiteral(evaluatedValue));
|
|
121
|
-
} catch {
|
|
122
|
-
inner && (attrClassName || (attrClassName = inner));
|
|
123
|
-
}
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
return finalAttrs.push(value), [];
|
|
127
|
-
}
|
|
128
|
-
if (attr.type === "style")
|
|
129
|
-
return mergeForwardBaseStyle = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, attr.value), baseFontFamily = (0, import_propsToFontFamilyCache.getFontFamilyNameFromProps)(attr.value) || "", [];
|
|
130
|
-
var ternary2 = attr.value;
|
|
131
|
-
if (ternary2.inlineMediaQuery) {
|
|
132
|
-
var mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(parserProps, attr.value, jsxPath, extractor.getTamagui(), sourcePath || "", mediaStylesSeen++, shouldPrintDebug);
|
|
133
|
-
if (mediaExtraction)
|
|
134
|
-
if (mediaExtraction.mediaStyles && (mergeForwardBaseStyle = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, {
|
|
135
|
-
[`$${ternary2.inlineMediaQuery}`]: attr.value.consequent
|
|
136
|
-
})), mediaExtraction.ternaryWithoutMedia)
|
|
137
|
-
ternary2 = mediaExtraction.ternaryWithoutMedia;
|
|
138
|
-
else
|
|
139
|
-
return [];
|
|
140
|
-
}
|
|
141
|
-
var mergedAlternate, mergedConsequent;
|
|
142
|
-
return ternary2.alternate && Object.keys(ternary2.alternate).length && (mergedAlternate = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, ternary2.alternate || {}), (0, import_propsToFontFamilyCache.forwardFontFamilyName)(ternary2.alternate, mergedAlternate, baseFontFamily)), ternary2.consequent && Object.keys(ternary2.consequent).length && (mergedConsequent = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, ternary2.consequent || {}), (0, import_propsToFontFamilyCache.forwardFontFamilyName)(ternary2.consequent, mergedConsequent, baseFontFamily)), {
|
|
143
|
-
...ternary2,
|
|
144
|
-
alternate: mergedAlternate,
|
|
145
|
-
consequent: mergedConsequent
|
|
146
|
-
};
|
|
147
|
-
}), hasTernaries = !!onlyTernaries.length, baseClassNames = mergeForwardBaseStyle ? addStyles(mergeForwardBaseStyle) : null, baseClassNameStr = baseClassNames ? baseClassNames.join(" ") : "";
|
|
148
|
-
!hasTernaries && baseFontFamily && (baseClassNameStr = `font_${baseFontFamily}${baseClassNameStr ? ` ${baseClassNameStr}` : ""}`);
|
|
149
|
-
var base = staticConfig.componentName ? t.stringLiteral(`is_${staticConfig.componentName}${baseClassNameStr ? ` ${baseClassNameStr}` : ""}`) : t.stringLiteral(baseClassNameStr || "");
|
|
150
|
-
attrClassName = attrClassName;
|
|
151
|
-
var baseClassNameExpression = function() {
|
|
152
|
-
return attrClassName ? t.isStringLiteral(attrClassName) ? t.stringLiteral(base.value ? `${base.value} ${attrClassName.value}` : attrClassName.value) : t.binaryExpression("+", t.binaryExpression("+", attrClassName, spaceString), base) : base;
|
|
153
|
-
}(), expandedTernaries = [];
|
|
154
|
-
if (onlyTernaries.length) {
|
|
155
|
-
var normalizedTernaries = (0, import_normalizeTernaries.normalizeTernaries)(onlyTernaries), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
156
|
-
try {
|
|
157
|
-
for (var _iterator = normalizedTernaries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
158
|
-
var ternary = _step.value;
|
|
159
|
-
if (!expandedTernaries.length) {
|
|
160
|
-
expandTernary(ternary);
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
for (var _i = 0, _iter = [
|
|
164
|
-
...expandedTernaries
|
|
165
|
-
]; _i < _iter.length; _i++) {
|
|
166
|
-
var prev = _iter[_i];
|
|
167
|
-
expandTernary(ternary, prev);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
} catch (err) {
|
|
171
|
-
_didIteratorError = !0, _iteratorError = err;
|
|
172
|
-
} finally {
|
|
173
|
-
try {
|
|
174
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
175
|
-
} finally {
|
|
176
|
-
if (_didIteratorError)
|
|
177
|
-
throw _iteratorError;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function expandTernary(ternary2, prev2) {
|
|
182
|
-
if (ternary2.consequent && Object.keys(ternary2.consequent).length) {
|
|
183
|
-
var fontFamily = (0, import_propsToFontFamilyCache.getFontFamilyNameFromProps)(ternary2.consequent);
|
|
184
|
-
expandedTernaries.push({
|
|
185
|
-
fontFamily,
|
|
186
|
-
// prevTest && test: merge consequent
|
|
187
|
-
test: prev2 ? t.logicalExpression("&&", prev2.test, ternary2.test) : ternary2.test,
|
|
188
|
-
consequent: prev2 ? (0, import_web.mergeProps)(prev2.consequent, ternary2.consequent) : ternary2.consequent,
|
|
189
|
-
remove,
|
|
190
|
-
alternate: null
|
|
191
|
-
}), prev2 && expandedTernaries.push({
|
|
192
|
-
fontFamily,
|
|
193
|
-
// !prevTest && test: just consequent
|
|
194
|
-
test: t.logicalExpression("&&", t.unaryExpression("!", prev2.test), ternary2.test),
|
|
195
|
-
consequent: ternary2.consequent,
|
|
196
|
-
alternate: null,
|
|
197
|
-
remove
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
if (ternary2.alternate && Object.keys(ternary2.alternate).length) {
|
|
201
|
-
var fontFamily1 = (0, import_propsToFontFamilyCache.getFontFamilyNameFromProps)(ternary2.alternate), negated = t.unaryExpression("!", ternary2.test);
|
|
202
|
-
expandedTernaries.push({
|
|
203
|
-
fontFamily: fontFamily1,
|
|
204
|
-
// prevTest && !test: merge alternate
|
|
205
|
-
test: prev2 ? t.logicalExpression("&&", prev2.test, negated) : negated,
|
|
206
|
-
consequent: prev2 ? (0, import_web.mergeProps)(prev2.alternate, ternary2.alternate) : ternary2.alternate,
|
|
207
|
-
remove,
|
|
208
|
-
alternate: null
|
|
209
|
-
}), prev2 && expandedTernaries.push({
|
|
210
|
-
fontFamily: fontFamily1,
|
|
211
|
-
test: t.logicalExpression("&&", t.unaryExpression("!", prev2.test), ternary2.test),
|
|
212
|
-
consequent: ternary2.alternate,
|
|
213
|
-
remove,
|
|
214
|
-
alternate: null
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
var ternaryClassNameExpr = null;
|
|
219
|
-
if (hasTernaries) {
|
|
220
|
-
var _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
|
|
221
|
-
try {
|
|
222
|
-
for (var _iterator1 = expandedTernaries[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
223
|
-
var ternary1 = _step1.value;
|
|
224
|
-
if (ternary1.consequent) {
|
|
225
|
-
var classNames = addStyles(ternary1.consequent);
|
|
226
|
-
ternary1.fontFamily && classNames.unshift(`font_${ternary1.fontFamily}`);
|
|
227
|
-
var baseString = t.isStringLiteral(baseClassNameExpression) ? baseClassNameExpression.value : "", fullClassNameWithDups = (baseString ? `${baseString} ` : "") + classNames.join(" "), fullClassName = (0, import_concatClassName.concatClassName)(fullClassNameWithDups), classNameLiteral = t.stringLiteral(fullClassName);
|
|
228
|
-
ternaryClassNameExpr ? ternaryClassNameExpr = t.conditionalExpression(ternary1.test, classNameLiteral, ternaryClassNameExpr) : ternaryClassNameExpr = t.conditionalExpression(ternary1.test, classNameLiteral, baseClassNameExpression);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
} catch (err) {
|
|
232
|
-
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
233
|
-
} finally {
|
|
234
|
-
try {
|
|
235
|
-
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
|
236
|
-
} finally {
|
|
237
|
-
if (_didIteratorError1)
|
|
238
|
-
throw _iteratorError1;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
var finalExpression = ternaryClassNameExpr || baseClassNameExpression || null;
|
|
243
|
-
if (shouldPrintDebug && (console.info("attrs", JSON.stringify(attrs, null, 2)), console.info("expandedTernaries", JSON.stringify(expandedTernaries, null, 2)), console.info("finalExpression", JSON.stringify(finalExpression, null, 2)), console.info({
|
|
244
|
-
hasTernaries,
|
|
245
|
-
baseClassNameExpression
|
|
246
|
-
})), finalExpression) {
|
|
247
|
-
finalExpression = hoistClassNames(jsxPath, finalExpression);
|
|
248
|
-
var classNameProp = t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(finalExpression));
|
|
249
|
-
finalAttrs.unshift(classNameProp);
|
|
250
|
-
}
|
|
251
|
-
node.attributes = finalAttrs;
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled)
|
|
255
|
-
return shouldPrintDebug && console.info("no res or none modified", res), null;
|
|
256
|
-
var styles = Array.from(cssMap.values()).map(function(x) {
|
|
257
|
-
return x.css;
|
|
258
|
-
}).join(`
|
|
259
|
-
`).trim(), result = (0, import_generator.default)(ast, {
|
|
260
|
-
concise: !1,
|
|
261
|
-
filename: sourcePath,
|
|
262
|
-
// this makes the debug output terrible, and i think sourcemap works already
|
|
263
|
-
retainLines: !1,
|
|
264
|
-
sourceFileName: sourcePath,
|
|
265
|
-
sourceMaps: !0
|
|
266
|
-
}, source);
|
|
267
|
-
return shouldPrintDebug && (console.info(`
|
|
268
|
-
-------- output code -------
|
|
269
|
-
|
|
270
|
-
`, result.code.split(`
|
|
271
|
-
`).filter(function(x) {
|
|
272
|
-
return !x.startsWith("//");
|
|
273
|
-
}).join(`
|
|
274
|
-
`)), console.info(`
|
|
275
|
-
-------- output style --------
|
|
276
|
-
|
|
277
|
-
`, styles)), printLog(res), {
|
|
278
|
-
ast,
|
|
279
|
-
styles,
|
|
280
|
-
js: result.code,
|
|
281
|
-
map: result.map
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
function hoistClassNames(path2, expr) {
|
|
285
|
-
if (t.isStringLiteral(expr))
|
|
286
|
-
return hoistClassName(path2, expr.value);
|
|
287
|
-
if (t.isLogicalExpression(expr)) {
|
|
288
|
-
var left = t.isStringLiteral(expr.left) ? hoistClassName(path2, expr.left.value) : expr.left, right = t.isStringLiteral(expr.right) ? hoistClassName(path2, expr.right.value) : hoistClassNames(path2, expr.right);
|
|
289
|
-
return t.logicalExpression(expr.operator, left, right);
|
|
290
|
-
}
|
|
291
|
-
if (t.isConditionalExpression(expr)) {
|
|
292
|
-
var cons = t.isStringLiteral(expr.consequent) ? hoistClassName(path2, expr.consequent.value) : hoistClassNames(path2, expr.consequent), alt = t.isStringLiteral(expr.alternate) ? hoistClassName(path2, expr.alternate.value) : hoistClassNames(path2, expr.alternate);
|
|
293
|
-
return t.conditionalExpression(expr.test, cons, alt);
|
|
294
|
-
}
|
|
295
|
-
return expr;
|
|
296
|
-
}
|
|
297
|
-
function hoistClassName(path2, str) {
|
|
298
|
-
var uid = path2.scope.generateUidIdentifier("cn"), parent = path2.findParent(function(path3) {
|
|
299
|
-
return path3.isProgram();
|
|
300
|
-
});
|
|
301
|
-
if (!parent) throw new Error("no program?");
|
|
302
|
-
var variable = t.variableDeclaration("const", [
|
|
303
|
-
t.variableDeclarator(uid, t.stringLiteral(cleanupClassName(str)))
|
|
304
|
-
]);
|
|
305
|
-
return parent.unshiftContainer("body", variable), uid;
|
|
306
|
-
}
|
|
307
|
-
function cleanupClassName(inStr) {
|
|
308
|
-
var out = /* @__PURE__ */ new Set(), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
309
|
-
try {
|
|
310
|
-
for (var _iterator = inStr.split(" ")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
311
|
-
var part = _step.value;
|
|
312
|
-
part !== " " && part !== "font_" && out.add(part);
|
|
313
|
-
}
|
|
314
|
-
} catch (err) {
|
|
315
|
-
_didIteratorError = !0, _iteratorError = err;
|
|
316
|
-
} finally {
|
|
317
|
-
try {
|
|
318
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
319
|
-
} finally {
|
|
320
|
-
if (_didIteratorError)
|
|
321
|
-
throw _iteratorError;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return [
|
|
325
|
-
...out
|
|
326
|
-
].join(" ") + " ";
|
|
327
|
-
}
|
|
328
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
329
|
-
0 && (module.exports = {
|
|
330
|
-
extractToClassNames
|
|
331
|
-
});
|
|
332
|
-
//# sourceMappingURL=extractToClassNames.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/extractor/extractToClassNames.ts"],
|
|
4
|
-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UAAU,UAAU,QAClD,UAAU,OAAO;AAAA,IAEzB,UAAE;AACE,UAAI;AACA,cAAM;AAAA,IAEd;AAAA,EACJ;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,EACP,EAAE,KAAK,GAAG,IAAI;AAClB;",
|
|
5
|
-
"names": ["param", "classNames", "_iteratorNormalCompletion", "_didIteratorError", "_iteratorError", "_iterator", "_step", "ternary", "prev", "generate", "path"]
|
|
6
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
-
var extractToNative_exports = {};
|
|
25
|
-
__export(extractToNative_exports, {
|
|
26
|
-
extractToNative: () => extractToNative,
|
|
27
|
-
getBabelParseDefinition: () => getBabelParseDefinition,
|
|
28
|
-
getBabelPlugin: () => getBabelPlugin
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(extractToNative_exports);
|
|
31
|
-
var import_core = require("@babel/core"), import_generator = __toESM(require("@babel/generator")), import_helper_plugin_utils = require("@babel/helper-plugin-utils"), import_parser = require("@babel/parser"), import_template = __toESM(require("@babel/template")), t = __toESM(require("@babel/types")), import_node_path = require("node:path"), import_getPragmaOptions = require("../getPragmaOptions"), import_createExtractor = require("./createExtractor"), import_createLogger = require("./createLogger"), import_extractHelpers = require("./extractHelpers"), import_literalToAst = require("./literalToAst"), import_loadTamagui = require("./loadTamagui"), importNativeView = (0, import_template.default)(`
|
|
32
|
-
const __ReactNativeView = require('react-native').View;
|
|
33
|
-
const __ReactNativeText = require('react-native').Text;
|
|
34
|
-
`), importStyleSheet = (0, import_template.default)(`
|
|
35
|
-
const __ReactNativeStyleSheet = require('react-native').StyleSheet;
|
|
36
|
-
`), importWithStyle = (0, import_template.default)(`
|
|
37
|
-
const __withStableStyle = require('@tamagui/core')._withStableStyle;
|
|
38
|
-
`), importReactUseMemo = (0, import_template.default)(`
|
|
39
|
-
const __ReactUseMemo = require('react').useMemo;
|
|
40
|
-
`), extractor = (0, import_createExtractor.createExtractor)({
|
|
41
|
-
platform: "native"
|
|
42
|
-
}), tamaguiBuildOptionsLoaded;
|
|
43
|
-
function extractToNative(sourceFileName, sourceCode, options) {
|
|
44
|
-
var ast = (0, import_parser.parse)(sourceCode, {
|
|
45
|
-
sourceType: "module",
|
|
46
|
-
plugins: [
|
|
47
|
-
"jsx",
|
|
48
|
-
"typescript"
|
|
49
|
-
]
|
|
50
|
-
}), babelPlugin = getBabelPlugin(), out = (0, import_core.transformFromAstSync)(ast, sourceCode, {
|
|
51
|
-
plugins: [
|
|
52
|
-
[
|
|
53
|
-
babelPlugin,
|
|
54
|
-
options
|
|
55
|
-
]
|
|
56
|
-
],
|
|
57
|
-
configFile: !1,
|
|
58
|
-
sourceFileName,
|
|
59
|
-
filename: sourceFileName
|
|
60
|
-
});
|
|
61
|
-
if (!out)
|
|
62
|
-
throw new Error("No output returned");
|
|
63
|
-
return out;
|
|
64
|
-
}
|
|
65
|
-
function getBabelPlugin() {
|
|
66
|
-
return (0, import_helper_plugin_utils.declare)(function(api, options) {
|
|
67
|
-
return api.assertVersion(7), getBabelParseDefinition(options);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function getBabelParseDefinition(options) {
|
|
71
|
-
return {
|
|
72
|
-
name: "tamagui",
|
|
73
|
-
visitor: {
|
|
74
|
-
Program: {
|
|
75
|
-
enter(root) {
|
|
76
|
-
var _process_env_SOURCE_ROOT, _root_node_body__leadingComments, _root_node_body_, sourcePath = this.file.opts.filename;
|
|
77
|
-
if (sourcePath != null && sourcePath.includes("node_modules") || !(sourcePath != null && sourcePath.endsWith(".jsx")) && !(sourcePath != null && sourcePath.endsWith(".tsx")))
|
|
78
|
-
return;
|
|
79
|
-
!((_process_env_SOURCE_ROOT = process.env.SOURCE_ROOT) === null || _process_env_SOURCE_ROOT === void 0) && _process_env_SOURCE_ROOT.endsWith("ios") && (sourcePath = sourcePath.replace("/ios", ""));
|
|
80
|
-
var hasImportedView = !1, hasImportedViewWrapper = !1, sheetStyles = {}, sheetIdentifier = root.scope.generateUidIdentifier("sheet"), _root_node_body__leadingComments_map_join, firstCommentContents = (_root_node_body__leadingComments_map_join = (_root_node_body_ = root.node.body[0]) === null || _root_node_body_ === void 0 || (_root_node_body__leadingComments = _root_node_body_.leadingComments) === null || _root_node_body__leadingComments === void 0 ? void 0 : _root_node_body__leadingComments.map(function(comment) {
|
|
81
|
-
return (comment == null ? void 0 : comment.value) || " ";
|
|
82
|
-
}).join(" ")) !== null && _root_node_body__leadingComments_map_join !== void 0 ? _root_node_body__leadingComments_map_join : "", firstComment = firstCommentContents ? `//${firstCommentContents}` : "", { shouldPrintDebug, shouldDisable } = (0, import_getPragmaOptions.getPragmaOptions)({
|
|
83
|
-
source: firstComment,
|
|
84
|
-
path: sourcePath
|
|
85
|
-
});
|
|
86
|
-
if (shouldDisable)
|
|
87
|
-
return;
|
|
88
|
-
!options.config && !options.components && (tamaguiBuildOptionsLoaded || (tamaguiBuildOptionsLoaded = (0, import_loadTamagui.loadTamaguiBuildConfigSync)({})));
|
|
89
|
-
var finalOptions = {
|
|
90
|
-
// @ts-ignore just in case they leave it out
|
|
91
|
-
platform: "native",
|
|
92
|
-
...tamaguiBuildOptionsLoaded,
|
|
93
|
-
...options
|
|
94
|
-
}, printLog = (0, import_createLogger.createLogger)(sourcePath, finalOptions);
|
|
95
|
-
function addSheetStyle(style, node) {
|
|
96
|
-
var styleIndex = `${Object.keys(sheetStyles).length}`, key = `${styleIndex}`;
|
|
97
|
-
if (process.env.NODE_ENV === "development") {
|
|
98
|
-
var lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
|
99
|
-
key += `:${(0, import_node_path.basename)(sourcePath)}:${lineNumbers}`;
|
|
100
|
-
}
|
|
101
|
-
return sheetStyles[key] = style, readStyleExpr(key);
|
|
102
|
-
}
|
|
103
|
-
function readStyleExpr(key) {
|
|
104
|
-
return (0, import_template.default)("SHEET['KEY']")({
|
|
105
|
-
SHEET: sheetIdentifier.name,
|
|
106
|
-
KEY: key
|
|
107
|
-
}).expression;
|
|
108
|
-
}
|
|
109
|
-
var res;
|
|
110
|
-
try {
|
|
111
|
-
res = extractor.parseSync(root, {
|
|
112
|
-
importsWhitelist: [
|
|
113
|
-
"constants.js",
|
|
114
|
-
"colors.js"
|
|
115
|
-
],
|
|
116
|
-
extractStyledDefinitions: options.forceExtractStyleDefinitions,
|
|
117
|
-
excludeProps: /* @__PURE__ */ new Set([
|
|
118
|
-
"className",
|
|
119
|
-
"userSelect",
|
|
120
|
-
"whiteSpace",
|
|
121
|
-
"textOverflow",
|
|
122
|
-
"cursor",
|
|
123
|
-
"contain"
|
|
124
|
-
]),
|
|
125
|
-
shouldPrintDebug,
|
|
126
|
-
...finalOptions,
|
|
127
|
-
// disable extracting variables as no native concept of them (only theme values)
|
|
128
|
-
disableExtractVariables: options.experimentalFlattenThemesOnNative ? !1 : "theme",
|
|
129
|
-
sourcePath,
|
|
130
|
-
// disabling flattening for now
|
|
131
|
-
// it's flattening a plain <Paragraph>hello</Paragraph> which breaks things because themes
|
|
132
|
-
// thinking it's not really worth the effort to do much compilation on native
|
|
133
|
-
// for now just disable flatten as it can only run in narrow places on native
|
|
134
|
-
// disableFlattening: 'styled',
|
|
135
|
-
getFlattenedNode(param) {
|
|
136
|
-
var { isTextView } = param;
|
|
137
|
-
return hasImportedView || (hasImportedView = !0, root.unshiftContainer("body", importNativeView())), isTextView ? "__ReactNativeText" : "__ReactNativeView";
|
|
138
|
-
},
|
|
139
|
-
onExtractTag(props) {
|
|
140
|
-
assertValidTag(props.node);
|
|
141
|
-
var stylesExpr = t.arrayExpression([]), hocStylesExpr = t.arrayExpression([]), expressions = [], finalAttrs = [], themeKeysUsed = /* @__PURE__ */ new Set();
|
|
142
|
-
function getStyleExpression(style) {
|
|
143
|
-
if (style) {
|
|
144
|
-
var { plain, themed } = splitThemeStyles(style), themeExpr = null;
|
|
145
|
-
if (themed && options.experimentalFlattenThemesOnNative) {
|
|
146
|
-
for (var key in themed)
|
|
147
|
-
themeKeysUsed.add(themed[key].split("$")[1]);
|
|
148
|
-
themeExpr = getThemedStyleExpression(themed);
|
|
149
|
-
}
|
|
150
|
-
var ident = addSheetStyle(plain, props.node);
|
|
151
|
-
return themeExpr ? (addStyleExpression(ident), addStyleExpression(ident, !0), themeExpr) : ident;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
function addStyleExpression(expr) {
|
|
155
|
-
var HOC = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
|
|
156
|
-
Array.isArray(expr) ? (HOC ? hocStylesExpr : stylesExpr).elements.push(...expr) : (HOC ? hocStylesExpr : stylesExpr).elements.push(expr);
|
|
157
|
-
}
|
|
158
|
-
function getThemedStyleExpression(styles) {
|
|
159
|
-
var themedStylesAst = (0, import_literalToAst.literalToAst)(styles);
|
|
160
|
-
return themedStylesAst.properties.forEach(function(_) {
|
|
161
|
-
var prop = _;
|
|
162
|
-
prop.value.type === "StringLiteral" && (prop.value = t.memberExpression(t.identifier("theme"), t.identifier(prop.value.value.slice(1) + ".get()")));
|
|
163
|
-
}), themedStylesAst;
|
|
164
|
-
}
|
|
165
|
-
var hasDynamicStyle = !1, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
166
|
-
try {
|
|
167
|
-
for (var _iterator = props.attrs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
168
|
-
var attr = _step.value;
|
|
169
|
-
switch (attr.type) {
|
|
170
|
-
case "style": {
|
|
171
|
-
var styleExpr = getStyleExpression(attr.value);
|
|
172
|
-
addStyleExpression(styleExpr), options.experimentalFlattenThemesOnNative && addStyleExpression(styleExpr, !0);
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
case "ternary": {
|
|
176
|
-
var { consequent, alternate } = attr.value, consExpr = getStyleExpression(consequent), altExpr = getStyleExpression(alternate);
|
|
177
|
-
options.experimentalFlattenThemesOnNative && (expressions.push(attr.value.test), addStyleExpression(t.conditionalExpression(t.identifier(`_expressions[${expressions.length - 1}]`), consExpr || t.nullLiteral(), altExpr || t.nullLiteral()), !0));
|
|
178
|
-
var styleExpr1 = t.conditionalExpression(attr.value.test, consExpr || t.nullLiteral(), altExpr || t.nullLiteral());
|
|
179
|
-
addStyleExpression(styleExpr1);
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
case "attr": {
|
|
183
|
-
t.isJSXSpreadAttribute(attr.value) && (0, import_extractHelpers.isSimpleSpread)(attr.value) && (stylesExpr.elements.push(t.memberExpression(attr.value.argument, t.identifier("style"))), options.experimentalFlattenThemesOnNative && hocStylesExpr.elements.push(t.memberExpression(attr.value.argument, t.identifier("style")))), finalAttrs.push(attr.value);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
} catch (err) {
|
|
189
|
-
_didIteratorError = !0, _iteratorError = err;
|
|
190
|
-
} finally {
|
|
191
|
-
try {
|
|
192
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
193
|
-
} finally {
|
|
194
|
-
if (_didIteratorError)
|
|
195
|
-
throw _iteratorError;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if (props.node.attributes = finalAttrs, options.experimentalFlattenThemesOnNative && (themeKeysUsed.size || hocStylesExpr.elements.length > 1 || hasDynamicStyle)) {
|
|
199
|
-
hasImportedViewWrapper || (root.unshiftContainer("body", importWithStyle()), root.unshiftContainer("body", importReactUseMemo()), hasImportedViewWrapper = !0);
|
|
200
|
-
var name = props.flatNodeName || props.node.name.name, WrapperIdentifier = root.scope.generateUidIdentifier(name + "Wrapper");
|
|
201
|
-
root.pushContainer("body", t.variableDeclaration("const", [
|
|
202
|
-
t.variableDeclarator(WrapperIdentifier, t.callExpression(t.identifier("__withStableStyle"), [
|
|
203
|
-
t.identifier(name),
|
|
204
|
-
t.arrowFunctionExpression([
|
|
205
|
-
t.identifier("theme"),
|
|
206
|
-
t.identifier("_expressions")
|
|
207
|
-
], t.blockStatement([
|
|
208
|
-
t.returnStatement(t.callExpression(t.identifier("__ReactUseMemo"), [
|
|
209
|
-
t.arrowFunctionExpression([], t.blockStatement([
|
|
210
|
-
t.returnStatement(t.arrayExpression([
|
|
211
|
-
...hocStylesExpr.elements
|
|
212
|
-
]))
|
|
213
|
-
])),
|
|
214
|
-
t.arrayExpression([
|
|
215
|
-
t.spreadElement(t.identifier("_expressions"))
|
|
216
|
-
])
|
|
217
|
-
]))
|
|
218
|
-
]))
|
|
219
|
-
]))
|
|
220
|
-
])), props.node.name = WrapperIdentifier, props.jsxPath.node.closingElement && (props.jsxPath.node.closingElement.name = WrapperIdentifier), expressions.length && props.node.attributes.push(t.jsxAttribute(t.jsxIdentifier("expressions"), t.jsxExpressionContainer(t.arrayExpression(expressions))));
|
|
221
|
-
} else
|
|
222
|
-
props.node.attributes.push(t.jsxAttribute(t.jsxIdentifier("style"), t.jsxExpressionContainer(stylesExpr.elements.length === 1 ? stylesExpr.elements[0] : stylesExpr)));
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
} catch (err) {
|
|
226
|
-
if (err instanceof Error) {
|
|
227
|
-
var message = `${shouldPrintDebug === "verbose" ? err : err.message}`;
|
|
228
|
-
message.includes("Unexpected return value from visitor method") && (message = "Unexpected return value from visitor method"), console.warn("Error in Tamagui parse, skipping", message, err.stack);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (!Object.keys(sheetStyles).length) {
|
|
233
|
-
shouldPrintDebug && console.info("END no styles"), res && printLog(res);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
var sheetObject = (0, import_literalToAst.literalToAst)(sheetStyles), sheetOuter = (0, import_template.default)("const SHEET = __ReactNativeStyleSheet.create(null)")({
|
|
237
|
-
SHEET: sheetIdentifier.name
|
|
238
|
-
});
|
|
239
|
-
sheetOuter.declarations[0].init.arguments[0] = sheetObject, root.unshiftContainer("body", sheetOuter), root.unshiftContainer("body", importStyleSheet()), shouldPrintDebug && (console.info(`
|
|
240
|
-
-------- output code -------
|
|
241
|
-
`), console.info((0, import_generator.default)(root.parent).code.split(`
|
|
242
|
-
`).filter(function(x) {
|
|
243
|
-
return !x.startsWith("//");
|
|
244
|
-
}).join(`
|
|
245
|
-
`))), res && printLog(res);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
function assertValidTag(node) {
|
|
252
|
-
if (node.attributes.find(function(x) {
|
|
253
|
-
return x.type === "JSXAttribute" && x.name.name === "style";
|
|
254
|
-
})) {
|
|
255
|
-
var _process_env_DEBUG;
|
|
256
|
-
!((_process_env_DEBUG = process.env.DEBUG) === null || _process_env_DEBUG === void 0) && _process_env_DEBUG.startsWith("tamagui") && console.warn("\u26A0\uFE0F Cannot pass style attribute to extracted style");
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function splitThemeStyles(style) {
|
|
260
|
-
var themed = {}, plain = {}, noTheme = !0;
|
|
261
|
-
for (var key in style) {
|
|
262
|
-
var val = style[key];
|
|
263
|
-
val && val[0] === "$" ? (themed[key] = val, noTheme = !1) : plain[key] = val;
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
themed: noTheme ? null : themed,
|
|
267
|
-
plain
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
271
|
-
0 && (module.exports = {
|
|
272
|
-
extractToNative,
|
|
273
|
-
getBabelParseDefinition,
|
|
274
|
-
getBabelPlugin
|
|
275
|
-
});
|
|
276
|
-
//# sourceMappingURL=extractToNative.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/extractor/extractToNative.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqC,wBACrC,mBAAsB,sCACtB,6BAAwB,uCACxB,gBAAsB,0BACtB,kBAAqB,qCACrB,IAAmB,kCACnB,mBAAyB,sBACzB,0BAAiC,gCACjC,yBAAgC,8BAChC,sBAA6B,2BAC7B,wBAA+B,6BAC/B,sBAA6B,2BAC7B,qBAA2C,0BACvC,uBAAmB,gBAAAA,SAAS;AAAA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