@tamagui/static 1.115.2 → 1.115.4
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/package.json +16 -16
- package/dist/check-dep-versions.cjs +0 -267
- package/dist/check-dep-versions.cjs.map +0 -6
- package/dist/checkDeps.cjs +0 -32
- package/dist/checkDeps.cjs.map +0 -6
- package/dist/constants.cjs +0 -49
- package/dist/constants.cjs.map +0 -6
- package/dist/exports.cjs +0 -40
- package/dist/exports.cjs.map +0 -6
- package/dist/extractor/accessSafe.cjs +0 -46
- package/dist/extractor/accessSafe.cjs.map +0 -6
- package/dist/extractor/babelParse.cjs +0 -54
- package/dist/extractor/babelParse.cjs.map +0 -6
- package/dist/extractor/buildClassName.cjs +0 -62
- package/dist/extractor/buildClassName.cjs.map +0 -6
- package/dist/extractor/bundle.cjs +0 -146
- package/dist/extractor/bundle.cjs.map +0 -6
- package/dist/extractor/bundleConfig.cjs +0 -322
- package/dist/extractor/bundleConfig.cjs.map +0 -6
- package/dist/extractor/createEvaluator.cjs +0 -70
- package/dist/extractor/createEvaluator.cjs.map +0 -6
- package/dist/extractor/createExtractor.cjs +0 -1008
- package/dist/extractor/createExtractor.cjs.map +0 -6
- package/dist/extractor/createLogger.cjs +0 -45
- package/dist/extractor/createLogger.cjs.map +0 -6
- package/dist/extractor/ensureImportingConcat.cjs +0 -48
- package/dist/extractor/ensureImportingConcat.cjs.map +0 -6
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -44
- package/dist/extractor/esbuildAliasPlugin.cjs.map +0 -6
- package/dist/extractor/evaluateAstNode.cjs +0 -83
- package/dist/extractor/evaluateAstNode.cjs.map +0 -6
- package/dist/extractor/extractHelpers.cjs +0 -120
- package/dist/extractor/extractHelpers.cjs.map +0 -6
- package/dist/extractor/extractMediaStyle.cjs +0 -129
- package/dist/extractor/extractMediaStyle.cjs.map +0 -6
- package/dist/extractor/extractToClassNames.cjs +0 -254
- package/dist/extractor/extractToClassNames.cjs.map +0 -6
- package/dist/extractor/extractToNative.cjs +0 -274
- package/dist/extractor/extractToNative.cjs.map +0 -6
- package/dist/extractor/findTopmostFunction.cjs +0 -34
- package/dist/extractor/findTopmostFunction.cjs.map +0 -6
- package/dist/extractor/generatedUid.cjs +0 -47
- package/dist/extractor/generatedUid.cjs.map +0 -6
- package/dist/extractor/getPrefixLogs.cjs +0 -28
- package/dist/extractor/getPrefixLogs.cjs.map +0 -6
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -67
- package/dist/extractor/getPropValueFromAttributes.cjs.map +0 -6
- package/dist/extractor/getSourceModule.cjs +0 -68
- package/dist/extractor/getSourceModule.cjs.map +0 -6
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -148
- package/dist/extractor/getStaticBindingsForScope.cjs.map +0 -6
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -29
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs.map +0 -6
- package/dist/extractor/hoistClassNames.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs.map +0 -6
- package/dist/extractor/literalToAst.cjs +0 -84
- package/dist/extractor/literalToAst.cjs.map +0 -6
- package/dist/extractor/loadFile.cjs +0 -11
- package/dist/extractor/loadFile.cjs.map +0 -6
- package/dist/extractor/loadTamagui.cjs +0 -284
- package/dist/extractor/loadTamagui.cjs.map +0 -6
- package/dist/extractor/logLines.cjs +0 -35
- package/dist/extractor/logLines.cjs.map +0 -6
- package/dist/extractor/normalizeTernaries.cjs +0 -68
- package/dist/extractor/normalizeTernaries.cjs.map +0 -6
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -38
- package/dist/extractor/propsToFontFamilyCache.cjs.map +0 -6
- package/dist/extractor/regenerateConfig.cjs +0 -144
- package/dist/extractor/regenerateConfig.cjs.map +0 -6
- package/dist/extractor/removeUnusedHooks.cjs +0 -76
- package/dist/extractor/removeUnusedHooks.cjs.map +0 -6
- package/dist/extractor/timer.cjs +0 -43
- package/dist/extractor/timer.cjs.map +0 -6
- package/dist/extractor/validHTMLAttributes.cjs +0 -73
- package/dist/extractor/validHTMLAttributes.cjs.map +0 -6
- package/dist/extractor/watchTamaguiConfig.cjs +0 -58
- package/dist/extractor/watchTamaguiConfig.cjs.map +0 -6
- package/dist/getPragmaOptions.cjs +0 -54
- package/dist/getPragmaOptions.cjs.map +0 -6
- package/dist/helpers/memoize.cjs +0 -37
- package/dist/helpers/memoize.cjs.map +0 -6
- package/dist/helpers/requireTamaguiCore.cjs +0 -33
- package/dist/helpers/requireTamaguiCore.cjs.map +0 -6
- package/dist/index.cjs +0 -40
- package/dist/index.cjs.map +0 -6
- package/dist/registerRequire.cjs +0 -102
- package/dist/registerRequire.cjs.map +0 -6
- package/dist/server.cjs +0 -75
- package/dist/server.cjs.map +0 -6
- package/dist/setup.cjs +0 -0
- package/dist/setup.cjs.map +0 -6
- package/dist/types.cjs +0 -16
- package/dist/types.cjs.map +0 -6
@@ -1,254 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var extractToClassNames_exports = {};
|
33
|
-
__export(extractToClassNames_exports, {
|
34
|
-
extractToClassNames: () => extractToClassNames
|
35
|
-
});
|
36
|
-
module.exports = __toCommonJS(extractToClassNames_exports);
|
37
|
-
var path = __toESM(require("node:path")),
|
38
|
-
util = __toESM(require("node:util")),
|
39
|
-
import_generator = __toESM(require("@babel/generator")),
|
40
|
-
t = __toESM(require("@babel/types")),
|
41
|
-
helpers = __toESM(require("@tamagui/helpers")),
|
42
|
-
import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs"),
|
43
|
-
import_babelParse = require("./babelParse.cjs"),
|
44
|
-
import_buildClassName = require("./buildClassName.cjs"),
|
45
|
-
import_createLogger = require("./createLogger.cjs"),
|
46
|
-
import_ensureImportingConcat = require("./ensureImportingConcat.cjs"),
|
47
|
-
import_extractHelpers = require("./extractHelpers.cjs"),
|
48
|
-
import_extractMediaStyle = require("./extractMediaStyle.cjs"),
|
49
|
-
import_hoistClassNames = require("./hoistClassNames.cjs"),
|
50
|
-
import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs"),
|
51
|
-
import_timer = require("./timer.cjs");
|
52
|
-
const mergeStyleGroups = {
|
53
|
-
shadowOpacity: !0,
|
54
|
-
shadowRadius: !0,
|
55
|
-
shadowColor: !0,
|
56
|
-
shadowOffset: !0
|
57
|
-
};
|
58
|
-
async function extractToClassNames({
|
59
|
-
extractor,
|
60
|
-
source,
|
61
|
-
sourcePath = "",
|
62
|
-
options,
|
63
|
-
shouldPrintDebug
|
64
|
-
}) {
|
65
|
-
const tm = (0, import_timer.timer)(),
|
66
|
-
{
|
67
|
-
getStylesAtomic
|
68
|
-
} = (0, import_requireTamaguiCore.requireTamaguiCore)("web");
|
69
|
-
if (sourcePath.includes("node_modules")) return null;
|
70
|
-
if (shouldPrintDebug && console.warn(`--- ${sourcePath} ---
|
71
|
-
|
72
|
-
`), typeof source != "string") throw new Error("`source` must be a string of javascript");
|
73
|
-
if (!path.isAbsolute(sourcePath)) throw new Error("`sourcePath` must be an absolute path to a .js file, got: " + sourcePath);
|
74
|
-
/.[tj]sx?$/i.test(sourcePath || "") || console.warn(`${sourcePath.slice(0, 100)} - bad filename.`), !options.disableExtraction && !options._disableLoadTamagui && (await extractor.loadTamagui(options));
|
75
|
-
const printLog = (0, import_createLogger.createLogger)(sourcePath, options);
|
76
|
-
let ast;
|
77
|
-
try {
|
78
|
-
ast = (0, import_babelParse.babelParse)(source, sourcePath);
|
79
|
-
} catch (err) {
|
80
|
-
throw console.error("babel parse error:", sourcePath.slice(0, 100)), err;
|
81
|
-
}
|
82
|
-
tm.mark("babel-parse", shouldPrintDebug === "verbose");
|
83
|
-
const cssMap = /* @__PURE__ */new Map(),
|
84
|
-
existingHoists = {};
|
85
|
-
let hasFlattened = !1;
|
86
|
-
const res = await extractor.parse(ast, {
|
87
|
-
shouldPrintDebug,
|
88
|
-
...options,
|
89
|
-
platform: "web",
|
90
|
-
sourcePath,
|
91
|
-
extractStyledDefinitions: !0,
|
92
|
-
onStyleRule(identifier, rules) {
|
93
|
-
const css = rules.join(";");
|
94
|
-
shouldPrintDebug && console.info(`adding styled() rule: .${identifier} ${css}`), cssMap.set(`.${identifier}`, {
|
95
|
-
css,
|
96
|
-
commentTexts: []
|
97
|
-
});
|
98
|
-
},
|
99
|
-
getFlattenedNode: ({
|
100
|
-
tag
|
101
|
-
}) => (hasFlattened = !0, tag),
|
102
|
-
onExtractTag: ({
|
103
|
-
parserProps,
|
104
|
-
attrs,
|
105
|
-
node,
|
106
|
-
attemptEval,
|
107
|
-
jsxPath,
|
108
|
-
originalNodeName,
|
109
|
-
filePath,
|
110
|
-
lineNumbers,
|
111
|
-
programPath,
|
112
|
-
isFlattened,
|
113
|
-
staticConfig
|
114
|
-
}) => {
|
115
|
-
if (staticConfig.acceptsClassName === !1) {
|
116
|
-
shouldPrintDebug && console.info("bail, acceptsClassName is false");
|
117
|
-
return;
|
118
|
-
}
|
119
|
-
const didFlattenThisTag = hasFlattened;
|
120
|
-
hasFlattened = !1;
|
121
|
-
let finalClassNames = [];
|
122
|
-
const finalAttrs = [];
|
123
|
-
let finalStyles = [],
|
124
|
-
viewStyles = {};
|
125
|
-
for (const attr of attrs) attr.type === "style" && (viewStyles = {
|
126
|
-
...viewStyles,
|
127
|
-
...attr.value
|
128
|
-
});
|
129
|
-
const ensureNeededPrevStyle = style => {
|
130
|
-
if (!Object.keys(style).some(key => mergeStyleGroups[key])) return style;
|
131
|
-
for (const k in mergeStyleGroups) k in viewStyles && (style[k] = style[k] ?? viewStyles[k]);
|
132
|
-
return style;
|
133
|
-
},
|
134
|
-
addStyles = style => {
|
135
|
-
if (!style) return [];
|
136
|
-
const styleWithPrev = ensureNeededPrevStyle(style),
|
137
|
-
res2 = getStylesAtomic(styleWithPrev);
|
138
|
-
return res2.length && (finalStyles = [...finalStyles, ...res2]), res2;
|
139
|
-
};
|
140
|
-
let lastMediaImportance = 1;
|
141
|
-
for (const attr of attrs) switch (attr.type) {
|
142
|
-
case "style":
|
143
|
-
{
|
144
|
-
if (isFlattened) {
|
145
|
-
const styles2 = addStyles(attr.value),
|
146
|
-
newFontFamily = (0, import_propsToFontFamilyCache.getFontFamilyClassNameFromProps)(attr.value) || "",
|
147
|
-
newClassNames = helpers.concatClassName(styles2.map(x => x[helpers.StyleObjectIdentifier]).join(" ") + newFontFamily),
|
148
|
-
existing = finalClassNames.find(x => x.type == "StringLiteral");
|
149
|
-
if (existing) {
|
150
|
-
let previous = existing.value;
|
151
|
-
newFontFamily && (shouldPrintDebug && console.info(` newFontFamily: ${newFontFamily}`), previous = previous.replace(/font_[a-z]+/i, "")), existing.value = `${previous} ${newClassNames}`;
|
152
|
-
} else finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)];
|
153
|
-
} else {
|
154
|
-
const styles2 = getStylesAtomic(attr.value);
|
155
|
-
finalStyles = [...finalStyles, ...styles2];
|
156
|
-
for (const style of styles2) {
|
157
|
-
const prop = style[helpers.StyleObjectPseudo] ? `${style[helpers.StyleObjectProperty]}-${style[helpers.StyleObjectPseudo]}` : style[helpers.StyleObjectProperty];
|
158
|
-
finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(prop), t.stringLiteral(style[helpers.StyleObjectIdentifier])));
|
159
|
-
}
|
160
|
-
}
|
161
|
-
break;
|
162
|
-
}
|
163
|
-
case "attr":
|
164
|
-
{
|
165
|
-
const val = attr.value;
|
166
|
-
if (t.isJSXSpreadAttribute(val)) (0, import_extractHelpers.isSimpleSpread)(val) && finalClassNames.push(t.logicalExpression("&&", val.argument, t.memberExpression(val.argument, t.identifier("className"))));else if (val.name.name === "className") {
|
167
|
-
const value = val.value;
|
168
|
-
if (value) try {
|
169
|
-
const evaluatedValue = attemptEval(value);
|
170
|
-
finalClassNames.push(t.stringLiteral(evaluatedValue));
|
171
|
-
} catch {
|
172
|
-
finalClassNames.push(value.expression);
|
173
|
-
}
|
174
|
-
continue;
|
175
|
-
}
|
176
|
-
finalAttrs.push(val);
|
177
|
-
break;
|
178
|
-
}
|
179
|
-
case "ternary":
|
180
|
-
{
|
181
|
-
const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(parserProps, attr.value, jsxPath, extractor.getTamagui(), sourcePath || "", lastMediaImportance, shouldPrintDebug);
|
182
|
-
if (shouldPrintDebug && mediaExtraction && console.info("ternary (mediaStyles)", mediaExtraction.ternaryWithoutMedia?.inlineMediaQuery ?? "", mediaExtraction.mediaStyles.map(x => x[helpers.StyleObjectIdentifier]).join(".")), !mediaExtraction) {
|
183
|
-
shouldPrintDebug && mediaExtraction && console.info("add ternary"), addTernaryStyle(attr.value, addStyles(attr.value.consequent), addStyles(attr.value.alternate));
|
184
|
-
continue;
|
185
|
-
}
|
186
|
-
lastMediaImportance++, mediaExtraction.mediaStyles && (finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]), mediaExtraction.ternaryWithoutMedia ? addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, []) : finalClassNames = [...finalClassNames, ...mediaExtraction.mediaStyles.map(x => t.stringLiteral(x[helpers.StyleObjectIdentifier]))];
|
187
|
-
break;
|
188
|
-
}
|
189
|
-
}
|
190
|
-
function addTernaryStyle(ternary, a, b) {
|
191
|
-
const cCN = a.map(x => x[helpers.StyleObjectIdentifier]).join(" "),
|
192
|
-
aCN = b.map(x => x[helpers.StyleObjectIdentifier]).join(" ");
|
193
|
-
a.length && b.length ? finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))) : finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(" " + cCN), t.stringLiteral(" " + aCN)));
|
194
|
-
}
|
195
|
-
if (shouldPrintDebug === "verbose" && console.info(` finalClassNames AST
|
196
|
-
`, JSON.stringify(finalClassNames, null, 2)), node.attributes = finalAttrs, finalClassNames.length) {
|
197
|
-
const extraClassNames = (() => {
|
198
|
-
let value = "";
|
199
|
-
return isFlattened && (process.env.TAMAGUI_DEBUG_OPTIMIZATIONS && (value += "is_tamagui_flattened"), staticConfig.componentName && (value += ` is_${staticConfig.componentName}`)), value;
|
200
|
-
})(),
|
201
|
-
names = (0, import_buildClassName.buildClassName)(finalClassNames, extraClassNames),
|
202
|
-
nameExpr = names ? (0, import_hoistClassNames.hoistClassNames)(jsxPath, existingHoists, names) : null;
|
203
|
-
let expr = nameExpr;
|
204
|
-
if (nameExpr && !t.isIdentifier(nameExpr) && didFlattenThisTag) {
|
205
|
-
(0, import_ensureImportingConcat.ensureImportingConcat)(programPath);
|
206
|
-
const simpleSpreads = attrs.filter(x => x.type === "attr" && t.isJSXSpreadAttribute(x.value) && (0, import_extractHelpers.isSimpleSpread)(x.value));
|
207
|
-
expr = t.callExpression(t.identifier("concatClassName"), [expr, ...simpleSpreads.map(val => val.value.argument)]);
|
208
|
-
}
|
209
|
-
node.attributes.push(t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr)));
|
210
|
-
}
|
211
|
-
const comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
|
212
|
-
for (const styleObject of finalStyles) {
|
213
|
-
const identifier = styleObject[helpers.StyleObjectIdentifier],
|
214
|
-
rules = styleObject[helpers.StyleObjectRules],
|
215
|
-
className = `.${identifier}`;
|
216
|
-
if (cssMap.has(className)) {
|
217
|
-
if (comment) {
|
218
|
-
const val = cssMap.get(className);
|
219
|
-
val.commentTexts.push(comment), cssMap.set(className, val);
|
220
|
-
}
|
221
|
-
} else rules.length && cssMap.set(className, {
|
222
|
-
css: rules.join(`
|
223
|
-
`),
|
224
|
-
commentTexts: [comment]
|
225
|
-
});
|
226
|
-
}
|
227
|
-
}
|
228
|
-
});
|
229
|
-
if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled) return shouldPrintDebug && console.info("no res or none modified", res), null;
|
230
|
-
const styles = Array.from(cssMap.values()).map(x => x.css).join(`
|
231
|
-
`).trim(),
|
232
|
-
result = (0, import_generator.default)(ast, {
|
233
|
-
concise: !1,
|
234
|
-
filename: sourcePath,
|
235
|
-
// this makes the debug output terrible, and i think sourcemap works already
|
236
|
-
retainLines: !1,
|
237
|
-
sourceFileName: sourcePath,
|
238
|
-
sourceMaps: !0
|
239
|
-
}, source);
|
240
|
-
return shouldPrintDebug && (console.info(`
|
241
|
-
-------- output code -------
|
242
|
-
|
243
|
-
`, result.code.split(`
|
244
|
-
`).filter(x => !x.startsWith("//")).join(`
|
245
|
-
`)), console.info(`
|
246
|
-
-------- output style --------
|
247
|
-
|
248
|
-
`, styles)), printLog(res), {
|
249
|
-
ast,
|
250
|
-
styles,
|
251
|
-
js: result.code,
|
252
|
-
map: result.map
|
253
|
-
};
|
254
|
-
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 3,
|
3
|
-
"sources": ["../../src/extractor/extractToClassNames.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB,+BACtB,OAAsB,+BAEtB,mBAAqB,sCACrB,IAAmB,kCACnB,UAAyB,sCAGzB,4BAAmC,0CAEnC,oBAA2B,yBAC3B,wBAA+B,6BAE/B,sBAA6B,2BAC7B,+BAAsC,oCACtC,wBAA+B,6BAC/B,2BAAkC,gCAClC,yBAAgC,8BAChC,gCAAgD,qCAChD,eAAsB;AAEtB,MAAM,mBAAmB;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAChB;AAkBA,eAAsB,oBAAoB;AAAA,EACxC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AACF,GAAgE;AAC9D,QAAM,SAAK,oBAAM,GACX,EAAE,gBAAgB,QAAI,8CAAmB,KAAK;AAEpD,MAAI,WAAW,SAAS,cAAc;AACpC,WAAO;AAOT,MAJI,oBACF,QAAQ,KAAK,OAAO,UAAU;AAAA;AAAA,CAAW,GAGvC,OAAO,UAAW;AACpB,UAAM,IAAI,MAAM,yCAAyC;AAE3D,MAAI,CAAC,KAAK,WAAW,UAAU;AAC7B,UAAM,IAAI;AAAA,MACR,+DAA+D;AAAA,IACjE;AAGF,EAAK,aAAa,KAAK,cAAc,EAAE,KACrC,QAAQ,KAAK,GAAG,WAAW,MAAM,GAAG,GAAG,CAAC,kBAAkB,GAGxD,CAAC,QAAQ,qBAAqB,CAAC,QAAQ,uBAEzC,MAAM,UAAU,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,YAAY,CAAC,IAAI,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI;AACrE,WAAI,oBACF,QAAQ,KAAK,2BAA2B,GAAG,GAEtC;AAGT,QAAM,SAAS,MAAM,KAAK,OAAO,OAAO,CAAC,EACtC,IAAI,CAAC,MAAM,EAAE,GAAG,EAChB,KAAK;AAAA,CAAI,EACT,KAAK,GAGF,aAAS,iBAAAC;AAAA,IACb;AAAA,IACA;AAAA,MACE,SAAS;AAAA,MACT,UAAU;AAAA;AAAA,MAEV,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACd;AAAA,IACA;AAAA,EACF;AAEA,SAAI,qBACF,QAAQ;AAAA,IACN;AAAA;AAAA;AAAA;AAAA,IACA,OAAO,KACJ,MAAM;AAAA,CAAI,EACV,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,IAAI,CAAC,EACjC,KAAK;AAAA,CAAI;AAAA,EACd,GACA,QAAQ,KAAK;AAAA;AAAA;AAAA,GAA0C,MAAM,IAG/D,SAAS,GAAG,GAEL;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA,EACd;AACF;",
|
5
|
-
"names": ["res", "styles", "generate"]
|
6
|
-
}
|
@@ -1,274 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var extractToNative_exports = {};
|
33
|
-
__export(extractToNative_exports, {
|
34
|
-
extractToNative: () => extractToNative,
|
35
|
-
getBabelParseDefinition: () => getBabelParseDefinition,
|
36
|
-
getBabelPlugin: () => getBabelPlugin
|
37
|
-
});
|
38
|
-
module.exports = __toCommonJS(extractToNative_exports);
|
39
|
-
var import_node_path = require("node:path"),
|
40
|
-
import_core = require("@babel/core"),
|
41
|
-
import_generator = __toESM(require("@babel/generator")),
|
42
|
-
import_helper_plugin_utils = require("@babel/helper-plugin-utils"),
|
43
|
-
import_parser = require("@babel/parser"),
|
44
|
-
import_template = __toESM(require("@babel/template")),
|
45
|
-
t = __toESM(require("@babel/types")),
|
46
|
-
import_createExtractor = require("./createExtractor.cjs"),
|
47
|
-
import_getPragmaOptions = require("../getPragmaOptions.cjs"),
|
48
|
-
import_createLogger = require("./createLogger.cjs"),
|
49
|
-
import_extractHelpers = require("./extractHelpers.cjs"),
|
50
|
-
import_literalToAst = require("./literalToAst.cjs"),
|
51
|
-
import_loadTamagui = require("./loadTamagui.cjs");
|
52
|
-
const importNativeView = (0, import_template.default)(`
|
53
|
-
const __ReactNativeView = require('react-native').View;
|
54
|
-
const __ReactNativeText = require('react-native').Text;
|
55
|
-
`),
|
56
|
-
importStyleSheet = (0, import_template.default)(`
|
57
|
-
const __ReactNativeStyleSheet = require('react-native').StyleSheet;
|
58
|
-
`),
|
59
|
-
importWithStyle = (0, import_template.default)(`
|
60
|
-
const __withStableStyle = require('@tamagui/core')._withStableStyle;
|
61
|
-
`),
|
62
|
-
extractor = (0, import_createExtractor.createExtractor)({
|
63
|
-
platform: "native"
|
64
|
-
});
|
65
|
-
let tamaguiBuildOptionsLoaded;
|
66
|
-
function extractToNative(sourceFileName, sourceCode, options) {
|
67
|
-
const ast = (0, import_parser.parse)(sourceCode, {
|
68
|
-
sourceType: "module",
|
69
|
-
plugins: ["jsx", "typescript"]
|
70
|
-
}),
|
71
|
-
babelPlugin = getBabelPlugin(),
|
72
|
-
out = (0, import_core.transformFromAstSync)(ast, sourceCode, {
|
73
|
-
plugins: [[babelPlugin, options]],
|
74
|
-
configFile: !1,
|
75
|
-
sourceFileName,
|
76
|
-
filename: sourceFileName
|
77
|
-
});
|
78
|
-
if (!out) throw new Error("No output returned");
|
79
|
-
return out;
|
80
|
-
}
|
81
|
-
function getBabelPlugin() {
|
82
|
-
return (0, import_helper_plugin_utils.declare)((api, options) => (api.assertVersion(7), getBabelParseDefinition(options)));
|
83
|
-
}
|
84
|
-
function getBabelParseDefinition(options) {
|
85
|
-
return {
|
86
|
-
name: "tamagui",
|
87
|
-
visitor: {
|
88
|
-
Program: {
|
89
|
-
enter(root) {
|
90
|
-
let sourcePath = this.file.opts.filename;
|
91
|
-
if (sourcePath?.includes("node_modules") || !sourcePath?.endsWith(".jsx") && !sourcePath?.endsWith(".tsx")) return;
|
92
|
-
process.env.SOURCE_ROOT?.endsWith("ios") && (sourcePath = sourcePath.replace("/ios", ""));
|
93
|
-
let hasImportedView = !1,
|
94
|
-
hasImportedViewWrapper = !1;
|
95
|
-
const sheetStyles = {},
|
96
|
-
sheetIdentifier = root.scope.generateUidIdentifier("sheet"),
|
97
|
-
firstCommentContents =
|
98
|
-
// join because you can join together multiple pragmas
|
99
|
-
root.node.body[0]?.leadingComments?.map(comment => comment?.value || " ").join(" ") ?? "",
|
100
|
-
firstComment = firstCommentContents ? `//${firstCommentContents}` : "",
|
101
|
-
{
|
102
|
-
shouldPrintDebug,
|
103
|
-
shouldDisable
|
104
|
-
} = (0, import_getPragmaOptions.getPragmaOptions)({
|
105
|
-
source: firstComment,
|
106
|
-
path: sourcePath
|
107
|
-
});
|
108
|
-
if (shouldDisable) return;
|
109
|
-
!options.config && !options.components && (tamaguiBuildOptionsLoaded ||= (0, import_loadTamagui.loadTamaguiBuildConfigSync)({}));
|
110
|
-
const finalOptions = {
|
111
|
-
// @ts-ignore just in case they leave it out
|
112
|
-
platform: "native",
|
113
|
-
...tamaguiBuildOptionsLoaded,
|
114
|
-
...options
|
115
|
-
},
|
116
|
-
printLog = (0, import_createLogger.createLogger)(sourcePath, finalOptions);
|
117
|
-
function addSheetStyle(style, node) {
|
118
|
-
let key = `${`${Object.keys(sheetStyles).length}`}`;
|
119
|
-
if (process.env.NODE_ENV === "development") {
|
120
|
-
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
121
|
-
key += `:${(0, import_node_path.basename)(sourcePath)}:${lineNumbers}`;
|
122
|
-
}
|
123
|
-
return sheetStyles[key] = style, readStyleExpr(key);
|
124
|
-
}
|
125
|
-
function readStyleExpr(key) {
|
126
|
-
return (0, import_template.default)("SHEET['KEY']")({
|
127
|
-
SHEET: sheetIdentifier.name,
|
128
|
-
KEY: key
|
129
|
-
}).expression;
|
130
|
-
}
|
131
|
-
let res;
|
132
|
-
try {
|
133
|
-
res = extractor.parseSync(root, {
|
134
|
-
importsWhitelist: ["constants.js", "colors.js"],
|
135
|
-
extractStyledDefinitions: options.forceExtractStyleDefinitions,
|
136
|
-
excludeProps: /* @__PURE__ */new Set(["className", "userSelect", "whiteSpace", "textOverflow", "cursor", "contain"]),
|
137
|
-
shouldPrintDebug,
|
138
|
-
...finalOptions,
|
139
|
-
// disable this extraction for now at least, need to figure out merging theme vs non-theme
|
140
|
-
// because theme need to stay in render(), whereas non-theme can be extracted
|
141
|
-
// for now just turn it off entirely at a small perf loss
|
142
|
-
disableExtractInlineMedia: !0,
|
143
|
-
// disable extracting variables as no native concept of them (only theme values)
|
144
|
-
disableExtractVariables: options.experimentalFlattenThemesOnNative ? !1 : "theme",
|
145
|
-
sourcePath,
|
146
|
-
// disabling flattening for now
|
147
|
-
// it's flattening a plain <Paragraph>hello</Paragraph> which breaks things because themes
|
148
|
-
// thinking it's not really worth the effort to do much compilation on native
|
149
|
-
// for now just disable flatten as it can only run in narrow places on native
|
150
|
-
// disableFlattening: 'styled',
|
151
|
-
getFlattenedNode({
|
152
|
-
isTextView
|
153
|
-
}) {
|
154
|
-
return hasImportedView || (hasImportedView = !0, root.unshiftContainer("body", importNativeView())), isTextView ? "__ReactNativeText" : "__ReactNativeView";
|
155
|
-
},
|
156
|
-
onExtractTag(props) {
|
157
|
-
const {
|
158
|
-
isFlattened
|
159
|
-
} = props;
|
160
|
-
if (!isFlattened) return;
|
161
|
-
assertValidTag(props.node);
|
162
|
-
const stylesExpr = t.arrayExpression([]),
|
163
|
-
hocStylesExpr = t.arrayExpression([]),
|
164
|
-
expressions = [],
|
165
|
-
finalAttrs = [],
|
166
|
-
themeKeysUsed = /* @__PURE__ */new Set();
|
167
|
-
function getStyleExpression(style) {
|
168
|
-
if (!style) return;
|
169
|
-
const {
|
170
|
-
plain,
|
171
|
-
themed
|
172
|
-
} = splitThemeStyles(style);
|
173
|
-
let themeExpr = null;
|
174
|
-
if (themed && options.experimentalFlattenThemesOnNative) {
|
175
|
-
for (const key in themed) themeKeysUsed.add(themed[key].split("$")[1]);
|
176
|
-
themeExpr = getThemedStyleExpression(themed);
|
177
|
-
}
|
178
|
-
const ident = addSheetStyle(plain, props.node);
|
179
|
-
return themeExpr ? (addStyleExpression(ident), addStyleExpression(ident, !0), themeExpr) : ident;
|
180
|
-
}
|
181
|
-
function addStyleExpression(expr, HOC = !1) {
|
182
|
-
Array.isArray(expr) ? (HOC ? hocStylesExpr : stylesExpr).elements.push(...expr) : (HOC ? hocStylesExpr : stylesExpr).elements.push(expr);
|
183
|
-
}
|
184
|
-
function getThemedStyleExpression(styles) {
|
185
|
-
const themedStylesAst = (0, import_literalToAst.literalToAst)(styles);
|
186
|
-
return themedStylesAst.properties.forEach(_ => {
|
187
|
-
const prop = _;
|
188
|
-
prop.value.type === "StringLiteral" && (prop.value = t.memberExpression(t.identifier("theme"), t.identifier(prop.value.value.slice(1) + ".get()")));
|
189
|
-
}), themedStylesAst;
|
190
|
-
}
|
191
|
-
let hasDynamicStyle = !1;
|
192
|
-
for (const attr of props.attrs) switch (attr.type) {
|
193
|
-
case "style":
|
194
|
-
{
|
195
|
-
let styleExpr = getStyleExpression(attr.value);
|
196
|
-
addStyleExpression(styleExpr), options.experimentalFlattenThemesOnNative && addStyleExpression(styleExpr, !0);
|
197
|
-
break;
|
198
|
-
}
|
199
|
-
case "ternary":
|
200
|
-
{
|
201
|
-
const {
|
202
|
-
consequent,
|
203
|
-
alternate
|
204
|
-
} = attr.value,
|
205
|
-
consExpr = getStyleExpression(consequent),
|
206
|
-
altExpr = getStyleExpression(alternate);
|
207
|
-
options.experimentalFlattenThemesOnNative && (expressions.push(attr.value.test), addStyleExpression(t.conditionalExpression(t.identifier(`_expressions[${expressions.length - 1}]`), consExpr || t.nullLiteral(), altExpr || t.nullLiteral()), !0));
|
208
|
-
const styleExpr = t.conditionalExpression(attr.value.test, consExpr || t.nullLiteral(), altExpr || t.nullLiteral());
|
209
|
-
addStyleExpression(styleExpr
|
210
|
-
// TODO: what is this for ?
|
211
|
-
// isFlattened ? simpleHash(JSON.stringify({ consequent, alternate })) : undefined
|
212
|
-
);
|
213
|
-
break;
|
214
|
-
}
|
215
|
-
case "dynamic-style":
|
216
|
-
{
|
217
|
-
hasDynamicStyle = !0, expressions.push(attr.value), options.experimentalFlattenDynamicValues ? addStyleExpression(t.objectExpression([t.objectProperty(t.identifier(attr.name), t.identifier(`_expressions[${expressions.length - 1}]`))]), !0) : addStyleExpression(t.objectExpression([t.objectProperty(t.identifier(attr.name), attr.value)]));
|
218
|
-
break;
|
219
|
-
}
|
220
|
-
case "attr":
|
221
|
-
{
|
222
|
-
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);
|
223
|
-
break;
|
224
|
-
}
|
225
|
-
}
|
226
|
-
if (props.node.attributes = finalAttrs, props.isFlattened) if (options.experimentalFlattenThemesOnNative && (themeKeysUsed.size || hocStylesExpr.elements.length > 1 || hasDynamicStyle)) {
|
227
|
-
hasImportedViewWrapper || (root.unshiftContainer("body", importWithStyle()), hasImportedViewWrapper = !0);
|
228
|
-
const name = props.node.name.name,
|
229
|
-
WrapperIdentifier = root.scope.generateUidIdentifier(name + "Wrapper");
|
230
|
-
root.pushContainer("body", t.variableDeclaration("const", [t.variableDeclarator(WrapperIdentifier, t.callExpression(t.identifier("__withStableStyle"), [t.identifier(name), t.arrowFunctionExpression([t.identifier("theme"), t.identifier("_expressions")], t.blockStatement([t.returnStatement(t.callExpression(t.memberExpression(t.identifier("React"), t.identifier("useMemo")), [t.arrowFunctionExpression([], t.blockStatement([t.returnStatement(t.arrayExpression([...hocStylesExpr.elements]))])), t.arrayExpression([t.spreadElement(t.identifier("_expressions"))])]))]))]))])), 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))));
|
231
|
-
} else props.node.attributes.push(t.jsxAttribute(t.jsxIdentifier("style"), t.jsxExpressionContainer(stylesExpr.elements.length === 1 ? stylesExpr.elements[0] : stylesExpr)));
|
232
|
-
}
|
233
|
-
});
|
234
|
-
} catch (err) {
|
235
|
-
if (err instanceof Error) {
|
236
|
-
let message = `${shouldPrintDebug === "verbose" ? err : err.message}`;
|
237
|
-
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);
|
238
|
-
return;
|
239
|
-
}
|
240
|
-
}
|
241
|
-
if (!Object.keys(sheetStyles).length) {
|
242
|
-
shouldPrintDebug && console.info("END no styles"), res && printLog(res);
|
243
|
-
return;
|
244
|
-
}
|
245
|
-
const sheetObject = (0, import_literalToAst.literalToAst)(sheetStyles),
|
246
|
-
sheetOuter = (0, import_template.default)("const SHEET = __ReactNativeStyleSheet.create(null)")({
|
247
|
-
SHEET: sheetIdentifier.name
|
248
|
-
});
|
249
|
-
sheetOuter.declarations[0].init.arguments[0] = sheetObject, root.unshiftContainer("body", sheetOuter), root.unshiftContainer("body", importStyleSheet()), shouldPrintDebug && (console.info(`
|
250
|
-
-------- output code -------
|
251
|
-
`), console.info((0, import_generator.default)(root.parent).code.split(`
|
252
|
-
`).filter(x => !x.startsWith("//")).join(`
|
253
|
-
`))), res && printLog(res);
|
254
|
-
}
|
255
|
-
}
|
256
|
-
}
|
257
|
-
};
|
258
|
-
}
|
259
|
-
function assertValidTag(node) {
|
260
|
-
node.attributes.find(x => x.type === "JSXAttribute" && x.name.name === "style") && process.env.DEBUG?.startsWith("tamagui") && console.warn("\u26A0\uFE0F Cannot pass style attribute to extracted style");
|
261
|
-
}
|
262
|
-
function splitThemeStyles(style) {
|
263
|
-
const themed = {},
|
264
|
-
plain = {};
|
265
|
-
let noTheme = !0;
|
266
|
-
for (const key in style) {
|
267
|
-
const val = style[key];
|
268
|
-
val && val[0] === "$" ? (themed[key] = val, noTheme = !1) : plain[key] = val;
|
269
|
-
}
|
270
|
-
return {
|
271
|
-
themed: noTheme ? null : themed,
|
272
|
-
plain
|
273
|
-
};
|
274
|
-
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 3,
|
3
|
-
"sources": ["../../src/extractor/extractToNative.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB,sBAEzB,cAA2D,wBAC3D,mBAAsB,sCACtB,6BAAwB,uCACxB,gBAAsB,0BACtB,kBAAqB,qCACrB,IAAmB,kCACnB,yBAAgC,8BAChC,0BAAiC,gCAEjC,sBAA6B,2BAC7B,wBAA+B,6BAC/B,sBAA6B,2BAC7B,qBAA2C;AAE3C,MAAM,uBAAmB,gBAAAA,SAAS;AAAA;AAAA;AAAA,CAGjC,GAEK,uBAAmB,gBAAAA,SAAS;AAAA;AAAA,CAEjC,GAEK,sBAAkB,gBAAAA,SAAS;AAAA;AAAA,CAEhC,GAEK,gBAAY,wCAAgB,EAAE,UAAU,SAAS,CAAC;AAExD,IAAI;AAEG,SAAS,gBACd,gBACA,YACA,SACiB;AACjB,QAAM,UAAM,qBAAM,YAAY;AAAA,IAC5B,YAAY;AAAA,IACZ,SAAS,CAAC,OAAO,YAAY;AAAA,EAC/B,CAAC,GAEK,cAAc,eAAe,GAE7B,UAAM,kCAAqB,KAAK,YAAY;AAAA,IAChD,SAAS,CAAC,CAAC,aAAa,OAAO,CAAC;AAAA,IAChC,YAAY;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,EACZ,CAAC;AAED,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,oBAAoB;AAGtC,SAAO;AACT;AAEO,SAAS,iBAAiB;AAC/B,aAAO,oCAAQ,CAAC,KAAK,aACnB,IAAI,cAAc,CAAC,GACZ,wBAAwB,OAAO,EACvC;AACH;AAEO,SAAS,wBAAwB,SAAyB;AAC/D,SAAO;AAAA,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,IAAI,OAAO,WAAW,SAAS,KACzC,QAAQ,KAAK,6DAAmD;AAGtE;AAEA,SAAS,iBAAiB,OAAe;AACvC,QAAM,SAAiB,CAAC,GAClB,QAAgB,CAAC;AACvB,MAAI,UAAU;AACd,aAAW,OAAO,OAAO;AACvB,UAAM,MAAM,MAAM,GAAG;AACrB,IAAI,OAAO,IAAI,CAAC,MAAM,OACpB,OAAO,GAAG,IAAI,KACd,UAAU,MAEV,MAAM,GAAG,IAAI;AAAA,EAEjB;AACA,SAAO,EAAE,QAAQ,UAAU,OAAO,QAAQ,MAAM;AAClD;",
|
5
|
-
"names": ["template", "generator"]
|
6
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
-
var __export = (target, all) => {
|
6
|
-
for (var name in all) __defProp(target, name, {
|
7
|
-
get: all[name],
|
8
|
-
enumerable: !0
|
9
|
-
});
|
10
|
-
},
|
11
|
-
__copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
13
|
-
get: () => from[key],
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
15
|
-
});
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
19
|
-
value: !0
|
20
|
-
}), mod);
|
21
|
-
var findTopmostFunction_exports = {};
|
22
|
-
__export(findTopmostFunction_exports, {
|
23
|
-
findTopmostFunction: () => findTopmostFunction
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(findTopmostFunction_exports);
|
26
|
-
function findTopmostFunction(jsxPath) {
|
27
|
-
const isFunction = path => path.isArrowFunctionExpression() || path.isFunctionDeclaration() || path.isFunctionExpression();
|
28
|
-
let compFn = jsxPath.findParent(isFunction);
|
29
|
-
for (; compFn;) {
|
30
|
-
const parent = compFn.findParent(isFunction);
|
31
|
-
if (parent) compFn = parent;else break;
|
32
|
-
}
|
33
|
-
return compFn || null;
|
34
|
-
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 3,
|
3
|
-
"sources": ["../../src/extractor/findTopmostFunction.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,oBAAoB,SAAiC;AAEnE,QAAM,aAAa,CAAC,SAClB,KAAK,0BAA0B,KAC/B,KAAK,sBAAsB,KAC3B,KAAK,qBAAqB;AAC5B,MAAI,SAA+B,QAAQ,WAAW,UAAU;AAChE,SAAO,UAAQ;AACb,UAAM,SAAS,OAAO,WAAW,UAAU;AAC3C,QAAI;AACF,eAAS;AAAA;AAET;AAAA,EAEJ;AACA,SAAK,UAEI;AAGX;",
|
5
|
-
"names": []
|
6
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var generatedUid_exports = {};
|
33
|
-
__export(generatedUid_exports, {
|
34
|
-
generateUid: () => generateUid
|
35
|
-
});
|
36
|
-
module.exports = __toCommonJS(generatedUid_exports);
|
37
|
-
var t = __toESM(require("@babel/types"));
|
38
|
-
function generateUid(scope, name) {
|
39
|
-
if (typeof scope != "object") throw "generateUid expects a scope object as its first parameter";
|
40
|
-
if (!(typeof name == "string" && name !== "")) throw "generateUid expects a valid name as its second parameter";
|
41
|
-
name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
|
42
|
-
let uid,
|
43
|
-
i = 0;
|
44
|
-
do i > 1 ? uid = name + i : uid = name, i++; while (scope.hasLabel(uid) || scope.hasBinding(uid) || scope.hasGlobal(uid) || scope.hasReference(uid));
|
45
|
-
const program = scope.getProgramParent();
|
46
|
-
return program.references[uid] = !0, program.uids[uid] = !0, uid;
|
47
|
-
}
|