@tamagui/static 1.115.1 → 1.115.2

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.
Files changed (93) hide show
  1. package/dist/check-dep-versions.js +389 -0
  2. package/dist/check-dep-versions.js.map +6 -0
  3. package/dist/checkDeps.js +26 -0
  4. package/dist/checkDeps.js.map +6 -0
  5. package/dist/constants.js +34 -0
  6. package/dist/constants.js.map +6 -0
  7. package/dist/exports.js +33 -0
  8. package/dist/exports.js.map +6 -0
  9. package/dist/extractor/accessSafe.js +47 -0
  10. package/dist/extractor/accessSafe.js.map +6 -0
  11. package/dist/extractor/babelParse.js +59 -0
  12. package/dist/extractor/babelParse.js.map +6 -0
  13. package/dist/extractor/buildClassName.js +72 -0
  14. package/dist/extractor/buildClassName.js.map +6 -0
  15. package/dist/extractor/bundle.js +133 -0
  16. package/dist/extractor/bundle.js.map +6 -0
  17. package/dist/extractor/bundleConfig.js +350 -0
  18. package/dist/extractor/bundleConfig.js.map +6 -0
  19. package/dist/extractor/createEvaluator.js +54 -0
  20. package/dist/extractor/createEvaluator.js.map +6 -0
  21. package/dist/extractor/createExtractor.js +1217 -0
  22. package/dist/extractor/createExtractor.js.map +6 -0
  23. package/dist/extractor/createLogger.js +32 -0
  24. package/dist/extractor/createLogger.js.map +6 -0
  25. package/dist/extractor/ensureImportingConcat.js +50 -0
  26. package/dist/extractor/ensureImportingConcat.js.map +6 -0
  27. package/dist/extractor/esbuildAliasPlugin.js +36 -0
  28. package/dist/extractor/esbuildAliasPlugin.js.map +6 -0
  29. package/dist/extractor/evaluateAstNode.js +99 -0
  30. package/dist/extractor/evaluateAstNode.js.map +6 -0
  31. package/dist/extractor/extractHelpers.js +109 -0
  32. package/dist/extractor/extractHelpers.js.map +6 -0
  33. package/dist/extractor/extractMediaStyle.js +123 -0
  34. package/dist/extractor/extractMediaStyle.js.map +6 -0
  35. package/dist/extractor/extractToClassNames.js +291 -0
  36. package/dist/extractor/extractToClassNames.js.map +6 -0
  37. package/dist/extractor/extractToNative.js +319 -0
  38. package/dist/extractor/extractToNative.js.map +6 -0
  39. package/dist/extractor/findTopmostFunction.js +32 -0
  40. package/dist/extractor/findTopmostFunction.js.map +6 -0
  41. package/dist/extractor/generatedUid.js +42 -0
  42. package/dist/extractor/generatedUid.js.map +6 -0
  43. package/dist/extractor/getPrefixLogs.js +23 -0
  44. package/dist/extractor/getPrefixLogs.js.map +6 -0
  45. package/dist/extractor/getPropValueFromAttributes.js +65 -0
  46. package/dist/extractor/getPropValueFromAttributes.js.map +6 -0
  47. package/dist/extractor/getSourceModule.js +66 -0
  48. package/dist/extractor/getSourceModule.js.map +6 -0
  49. package/dist/extractor/getStaticBindingsForScope.js +143 -0
  50. package/dist/extractor/getStaticBindingsForScope.js.map +6 -0
  51. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +24 -0
  52. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +6 -0
  53. package/dist/extractor/hoistClassNames.js +63 -0
  54. package/dist/extractor/hoistClassNames.js.map +6 -0
  55. package/dist/extractor/literalToAst.js +90 -0
  56. package/dist/extractor/literalToAst.js.map +6 -0
  57. package/dist/extractor/loadFile.js +14 -0
  58. package/dist/extractor/loadFile.js.map +6 -0
  59. package/dist/extractor/loadTamagui.js +263 -0
  60. package/dist/extractor/loadTamagui.js.map +6 -0
  61. package/dist/extractor/logLines.js +30 -0
  62. package/dist/extractor/logLines.js.map +6 -0
  63. package/dist/extractor/normalizeTernaries.js +59 -0
  64. package/dist/extractor/normalizeTernaries.js.map +6 -0
  65. package/dist/extractor/propsToFontFamilyCache.js +34 -0
  66. package/dist/extractor/propsToFontFamilyCache.js.map +6 -0
  67. package/dist/extractor/regenerateConfig.js +111 -0
  68. package/dist/extractor/regenerateConfig.js.map +6 -0
  69. package/dist/extractor/removeUnusedHooks.js +72 -0
  70. package/dist/extractor/removeUnusedHooks.js.map +6 -0
  71. package/dist/extractor/timer.js +38 -0
  72. package/dist/extractor/timer.js.map +6 -0
  73. package/dist/extractor/validHTMLAttributes.js +68 -0
  74. package/dist/extractor/validHTMLAttributes.js.map +6 -0
  75. package/dist/extractor/watchTamaguiConfig.js +57 -0
  76. package/dist/extractor/watchTamaguiConfig.js.map +6 -0
  77. package/dist/getPragmaOptions.js +49 -0
  78. package/dist/getPragmaOptions.js.map +6 -0
  79. package/dist/helpers/memoize.js +33 -0
  80. package/dist/helpers/memoize.js.map +6 -0
  81. package/dist/helpers/requireTamaguiCore.js +30 -0
  82. package/dist/helpers/requireTamaguiCore.js.map +6 -0
  83. package/dist/index.js +30 -0
  84. package/dist/index.js.map +6 -0
  85. package/dist/registerRequire.js +96 -0
  86. package/dist/registerRequire.js.map +6 -0
  87. package/dist/server.js +58 -0
  88. package/dist/server.js.map +6 -0
  89. package/dist/setup.js +1 -0
  90. package/dist/setup.js.map +6 -0
  91. package/dist/types.js +14 -0
  92. package/dist/types.js.map +6 -0
  93. package/package.json +14 -14
@@ -0,0 +1,291 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var extractToClassNames_exports = {};
24
+ __export(extractToClassNames_exports, {
25
+ extractToClassNames: () => extractToClassNames
26
+ });
27
+ module.exports = __toCommonJS(extractToClassNames_exports);
28
+ var path = __toESM(require("node:path")), util = __toESM(require("node:util")), import_generator = __toESM(require("@babel/generator")), t = __toESM(require("@babel/types")), helpers = __toESM(require("@tamagui/helpers")), import_requireTamaguiCore = require("../helpers/requireTamaguiCore"), import_babelParse = require("./babelParse"), import_buildClassName = require("./buildClassName"), import_createLogger = require("./createLogger"), import_ensureImportingConcat = require("./ensureImportingConcat"), import_extractHelpers = require("./extractHelpers"), import_extractMediaStyle = require("./extractMediaStyle"), import_hoistClassNames = require("./hoistClassNames"), import_propsToFontFamilyCache = require("./propsToFontFamilyCache"), import_timer = require("./timer");
29
+ const mergeStyleGroups = {
30
+ shadowOpacity: !0,
31
+ shadowRadius: !0,
32
+ shadowColor: !0,
33
+ shadowOffset: !0
34
+ };
35
+ async function extractToClassNames({
36
+ extractor,
37
+ source,
38
+ sourcePath = "",
39
+ options,
40
+ shouldPrintDebug
41
+ }) {
42
+ const tm = (0, import_timer.timer)(), { getStylesAtomic } = (0, import_requireTamaguiCore.requireTamaguiCore)("web");
43
+ if (sourcePath.includes("node_modules"))
44
+ return null;
45
+ if (shouldPrintDebug && console.warn(`--- ${sourcePath} ---
46
+
47
+ `), typeof source != "string")
48
+ throw new Error("`source` must be a string of javascript");
49
+ if (!path.isAbsolute(sourcePath))
50
+ throw new Error(
51
+ "`sourcePath` must be an absolute path to a .js file, got: " + sourcePath
52
+ );
53
+ /.[tj]sx?$/i.test(sourcePath || "") || console.warn(`${sourcePath.slice(0, 100)} - bad filename.`), !options.disableExtraction && !options._disableLoadTamagui && await extractor.loadTamagui(options);
54
+ const printLog = (0, import_createLogger.createLogger)(sourcePath, options);
55
+ let ast;
56
+ try {
57
+ ast = (0, import_babelParse.babelParse)(source, sourcePath);
58
+ } catch (err) {
59
+ throw console.error("babel parse error:", sourcePath.slice(0, 100)), err;
60
+ }
61
+ tm.mark("babel-parse", shouldPrintDebug === "verbose");
62
+ const cssMap = /* @__PURE__ */ new Map(), existingHoists = {};
63
+ let hasFlattened = !1;
64
+ const res = await extractor.parse(ast, {
65
+ shouldPrintDebug,
66
+ ...options,
67
+ platform: "web",
68
+ sourcePath,
69
+ extractStyledDefinitions: !0,
70
+ onStyleRule(identifier, rules) {
71
+ const css = rules.join(";");
72
+ shouldPrintDebug && console.info(`adding styled() rule: .${identifier} ${css}`), cssMap.set(`.${identifier}`, { css, commentTexts: [] });
73
+ },
74
+ getFlattenedNode: ({ tag }) => (hasFlattened = !0, tag),
75
+ onExtractTag: ({
76
+ parserProps,
77
+ attrs,
78
+ node,
79
+ attemptEval,
80
+ jsxPath,
81
+ originalNodeName,
82
+ filePath,
83
+ lineNumbers,
84
+ programPath,
85
+ isFlattened,
86
+ staticConfig
87
+ }) => {
88
+ if (staticConfig.acceptsClassName === !1) {
89
+ shouldPrintDebug && console.info("bail, acceptsClassName is false");
90
+ return;
91
+ }
92
+ const didFlattenThisTag = hasFlattened;
93
+ hasFlattened = !1;
94
+ let finalClassNames = [];
95
+ const finalAttrs = [];
96
+ let finalStyles = [], viewStyles = {};
97
+ for (const attr of attrs)
98
+ attr.type === "style" && (viewStyles = {
99
+ ...viewStyles,
100
+ ...attr.value
101
+ });
102
+ const ensureNeededPrevStyle = (style) => {
103
+ if (!Object.keys(style).some((key) => mergeStyleGroups[key]))
104
+ return style;
105
+ for (const k in mergeStyleGroups)
106
+ k in viewStyles && (style[k] = style[k] ?? viewStyles[k]);
107
+ return style;
108
+ }, addStyles = (style) => {
109
+ if (!style) return [];
110
+ const styleWithPrev = ensureNeededPrevStyle(style), res2 = getStylesAtomic(styleWithPrev);
111
+ return res2.length && (finalStyles = [...finalStyles, ...res2]), res2;
112
+ };
113
+ let lastMediaImportance = 1;
114
+ for (const attr of attrs)
115
+ switch (attr.type) {
116
+ case "style": {
117
+ if (isFlattened) {
118
+ const styles2 = addStyles(attr.value), newFontFamily = (0, import_propsToFontFamilyCache.getFontFamilyClassNameFromProps)(attr.value) || "", newClassNames = helpers.concatClassName(
119
+ styles2.map((x) => x[helpers.StyleObjectIdentifier]).join(" ") + newFontFamily
120
+ ), existing = finalClassNames.find(
121
+ (x) => x.type == "StringLiteral"
122
+ );
123
+ if (existing) {
124
+ let previous = existing.value;
125
+ newFontFamily && (shouldPrintDebug && console.info(` newFontFamily: ${newFontFamily}`), previous = previous.replace(/font_[a-z]+/i, "")), existing.value = `${previous} ${newClassNames}`;
126
+ } else
127
+ finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)];
128
+ } else {
129
+ const styles2 = getStylesAtomic(attr.value);
130
+ finalStyles = [...finalStyles, ...styles2];
131
+ for (const style of styles2) {
132
+ const prop = style[helpers.StyleObjectPseudo] ? `${style[helpers.StyleObjectProperty]}-${style[helpers.StyleObjectPseudo]}` : style[helpers.StyleObjectProperty];
133
+ finalAttrs.push(
134
+ t.jsxAttribute(
135
+ t.jsxIdentifier(prop),
136
+ t.stringLiteral(style[helpers.StyleObjectIdentifier])
137
+ )
138
+ );
139
+ }
140
+ }
141
+ break;
142
+ }
143
+ case "attr": {
144
+ const val = attr.value;
145
+ if (t.isJSXSpreadAttribute(val))
146
+ (0, import_extractHelpers.isSimpleSpread)(val) && finalClassNames.push(
147
+ t.logicalExpression(
148
+ "&&",
149
+ val.argument,
150
+ t.memberExpression(val.argument, t.identifier("className"))
151
+ )
152
+ );
153
+ else if (val.name.name === "className") {
154
+ const value = val.value;
155
+ if (value)
156
+ try {
157
+ const evaluatedValue = attemptEval(value);
158
+ finalClassNames.push(t.stringLiteral(evaluatedValue));
159
+ } catch {
160
+ finalClassNames.push(value.expression);
161
+ }
162
+ continue;
163
+ }
164
+ finalAttrs.push(val);
165
+ break;
166
+ }
167
+ case "ternary": {
168
+ const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(
169
+ parserProps,
170
+ attr.value,
171
+ jsxPath,
172
+ extractor.getTamagui(),
173
+ sourcePath || "",
174
+ lastMediaImportance,
175
+ shouldPrintDebug
176
+ );
177
+ if (shouldPrintDebug && mediaExtraction && console.info(
178
+ "ternary (mediaStyles)",
179
+ mediaExtraction.ternaryWithoutMedia?.inlineMediaQuery ?? "",
180
+ mediaExtraction.mediaStyles.map((x) => x[helpers.StyleObjectIdentifier]).join(".")
181
+ ), !mediaExtraction) {
182
+ shouldPrintDebug && mediaExtraction && console.info("add ternary"), addTernaryStyle(
183
+ attr.value,
184
+ addStyles(attr.value.consequent),
185
+ addStyles(attr.value.alternate)
186
+ );
187
+ continue;
188
+ }
189
+ lastMediaImportance++, mediaExtraction.mediaStyles && (finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]), mediaExtraction.ternaryWithoutMedia ? addTernaryStyle(
190
+ mediaExtraction.ternaryWithoutMedia,
191
+ mediaExtraction.mediaStyles,
192
+ []
193
+ ) : finalClassNames = [
194
+ ...finalClassNames,
195
+ ...mediaExtraction.mediaStyles.map(
196
+ (x) => t.stringLiteral(x[helpers.StyleObjectIdentifier])
197
+ )
198
+ ];
199
+ break;
200
+ }
201
+ }
202
+ function addTernaryStyle(ternary, a, b) {
203
+ const cCN = a.map((x) => x[helpers.StyleObjectIdentifier]).join(" "), aCN = b.map((x) => x[helpers.StyleObjectIdentifier]).join(" ");
204
+ a.length && b.length ? finalClassNames.push(
205
+ t.conditionalExpression(
206
+ ternary.test,
207
+ t.stringLiteral(cCN),
208
+ t.stringLiteral(aCN)
209
+ )
210
+ ) : finalClassNames.push(
211
+ t.conditionalExpression(
212
+ ternary.test,
213
+ t.stringLiteral(" " + cCN),
214
+ t.stringLiteral(" " + aCN)
215
+ )
216
+ );
217
+ }
218
+ if (shouldPrintDebug === "verbose" && console.info(` finalClassNames AST
219
+ `, JSON.stringify(finalClassNames, null, 2)), node.attributes = finalAttrs, finalClassNames.length) {
220
+ const extraClassNames = (() => {
221
+ let value = "";
222
+ return isFlattened && (process.env.TAMAGUI_DEBUG_OPTIMIZATIONS && (value += "is_tamagui_flattened"), staticConfig.componentName && (value += ` is_${staticConfig.componentName}`)), value;
223
+ })(), names = (0, import_buildClassName.buildClassName)(finalClassNames, extraClassNames), nameExpr = names ? (0, import_hoistClassNames.hoistClassNames)(jsxPath, existingHoists, names) : null;
224
+ let expr = nameExpr;
225
+ if (nameExpr && !t.isIdentifier(nameExpr) && didFlattenThisTag) {
226
+ (0, import_ensureImportingConcat.ensureImportingConcat)(programPath);
227
+ const simpleSpreads = attrs.filter((x) => x.type === "attr" && t.isJSXSpreadAttribute(x.value) && (0, import_extractHelpers.isSimpleSpread)(x.value));
228
+ expr = t.callExpression(t.identifier("concatClassName"), [
229
+ expr,
230
+ ...simpleSpreads.map((val) => val.value.argument)
231
+ ]);
232
+ }
233
+ node.attributes.push(
234
+ t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(expr))
235
+ );
236
+ }
237
+ const comment = util.format(
238
+ "/* %s:%s (%s) */",
239
+ filePath,
240
+ lineNumbers,
241
+ originalNodeName
242
+ );
243
+ for (const styleObject of finalStyles) {
244
+ const identifier = styleObject[helpers.StyleObjectIdentifier], rules = styleObject[helpers.StyleObjectRules], className = `.${identifier}`;
245
+ if (cssMap.has(className)) {
246
+ if (comment) {
247
+ const val = cssMap.get(className);
248
+ val.commentTexts.push(comment), cssMap.set(className, val);
249
+ }
250
+ } else rules.length && cssMap.set(className, {
251
+ css: rules.join(`
252
+ `),
253
+ commentTexts: [comment]
254
+ });
255
+ }
256
+ }
257
+ });
258
+ if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled)
259
+ return shouldPrintDebug && console.info("no res or none modified", res), null;
260
+ const styles = Array.from(cssMap.values()).map((x) => x.css).join(`
261
+ `).trim(), result = (0, import_generator.default)(
262
+ ast,
263
+ {
264
+ concise: !1,
265
+ filename: sourcePath,
266
+ // this makes the debug output terrible, and i think sourcemap works already
267
+ retainLines: !1,
268
+ sourceFileName: sourcePath,
269
+ sourceMaps: !0
270
+ },
271
+ source
272
+ );
273
+ return shouldPrintDebug && (console.info(
274
+ `
275
+ -------- output code -------
276
+
277
+ `,
278
+ result.code.split(`
279
+ `).filter((x) => !x.startsWith("//")).join(`
280
+ `)
281
+ ), console.info(`
282
+ -------- output style --------
283
+
284
+ `, styles)), printLog(res), {
285
+ ast,
286
+ styles,
287
+ js: result.code,
288
+ map: result.map
289
+ };
290
+ }
291
+ //# sourceMappingURL=extractToClassNames.js.map
@@ -0,0 +1,6 @@
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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7B,OAAO,IAAI,WAAW,GAAG;AAAA,UAC3B;AAAA,cACK,CAAI,MAAM,UACf,OAAO,IAAI,WAAW;AAAA,UACpB,KAAK,MAAM,KAAK;AAAA,CAAI;AAAA,UACpB,cAAc,CAAC,OAAO;AAAA,QACxB,CAAC;AAAA,MAEL;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,CAAC,OAAQ,CAAC,IAAI,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
+ }
@@ -0,0 +1,319 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var extractToNative_exports = {};
24
+ __export(extractToNative_exports, {
25
+ extractToNative: () => extractToNative,
26
+ getBabelParseDefinition: () => getBabelParseDefinition,
27
+ getBabelPlugin: () => getBabelPlugin
28
+ });
29
+ module.exports = __toCommonJS(extractToNative_exports);
30
+ var import_node_path = require("node:path"), 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_createExtractor = require("./createExtractor"), import_getPragmaOptions = require("../getPragmaOptions"), import_createLogger = require("./createLogger"), import_extractHelpers = require("./extractHelpers"), import_literalToAst = require("./literalToAst"), import_loadTamagui = require("./loadTamagui");
31
+ const 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
+ `), extractor = (0, import_createExtractor.createExtractor)({ platform: "native" });
39
+ let tamaguiBuildOptionsLoaded;
40
+ function extractToNative(sourceFileName, sourceCode, options) {
41
+ const ast = (0, import_parser.parse)(sourceCode, {
42
+ sourceType: "module",
43
+ plugins: ["jsx", "typescript"]
44
+ }), babelPlugin = getBabelPlugin(), out = (0, import_core.transformFromAstSync)(ast, sourceCode, {
45
+ plugins: [[babelPlugin, options]],
46
+ configFile: !1,
47
+ sourceFileName,
48
+ filename: sourceFileName
49
+ });
50
+ if (!out)
51
+ throw new Error("No output returned");
52
+ return out;
53
+ }
54
+ function getBabelPlugin() {
55
+ return (0, import_helper_plugin_utils.declare)((api, options) => (api.assertVersion(7), getBabelParseDefinition(options)));
56
+ }
57
+ function getBabelParseDefinition(options) {
58
+ return {
59
+ name: "tamagui",
60
+ visitor: {
61
+ Program: {
62
+ enter(root) {
63
+ let sourcePath = this.file.opts.filename;
64
+ if (sourcePath?.includes("node_modules") || !sourcePath?.endsWith(".jsx") && !sourcePath?.endsWith(".tsx"))
65
+ return;
66
+ process.env.SOURCE_ROOT?.endsWith("ios") && (sourcePath = sourcePath.replace("/ios", ""));
67
+ let hasImportedView = !1, hasImportedViewWrapper = !1;
68
+ const sheetStyles = {}, sheetIdentifier = root.scope.generateUidIdentifier("sheet"), firstCommentContents = (
69
+ // join because you can join together multiple pragmas
70
+ root.node.body[0]?.leadingComments?.map((comment) => comment?.value || " ").join(" ") ?? ""
71
+ ), firstComment = firstCommentContents ? `//${firstCommentContents}` : "", { shouldPrintDebug, shouldDisable } = (0, import_getPragmaOptions.getPragmaOptions)({
72
+ source: firstComment,
73
+ path: sourcePath
74
+ });
75
+ if (shouldDisable)
76
+ return;
77
+ !options.config && !options.components && (tamaguiBuildOptionsLoaded ||= (0, import_loadTamagui.loadTamaguiBuildConfigSync)({}));
78
+ const finalOptions = {
79
+ // @ts-ignore just in case they leave it out
80
+ platform: "native",
81
+ ...tamaguiBuildOptionsLoaded,
82
+ ...options
83
+ }, printLog = (0, import_createLogger.createLogger)(sourcePath, finalOptions);
84
+ function addSheetStyle(style, node) {
85
+ let key = `${`${Object.keys(sheetStyles).length}`}`;
86
+ if (process.env.NODE_ENV === "development") {
87
+ const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
88
+ key += `:${(0, import_node_path.basename)(sourcePath)}:${lineNumbers}`;
89
+ }
90
+ return sheetStyles[key] = style, readStyleExpr(key);
91
+ }
92
+ function readStyleExpr(key) {
93
+ return (0, import_template.default)("SHEET['KEY']")({
94
+ SHEET: sheetIdentifier.name,
95
+ KEY: key
96
+ }).expression;
97
+ }
98
+ let res;
99
+ try {
100
+ res = extractor.parseSync(root, {
101
+ importsWhitelist: ["constants.js", "colors.js"],
102
+ extractStyledDefinitions: options.forceExtractStyleDefinitions,
103
+ excludeProps: /* @__PURE__ */ new Set([
104
+ "className",
105
+ "userSelect",
106
+ "whiteSpace",
107
+ "textOverflow",
108
+ "cursor",
109
+ "contain"
110
+ ]),
111
+ shouldPrintDebug,
112
+ ...finalOptions,
113
+ // disable this extraction for now at least, need to figure out merging theme vs non-theme
114
+ // because theme need to stay in render(), whereas non-theme can be extracted
115
+ // for now just turn it off entirely at a small perf loss
116
+ disableExtractInlineMedia: !0,
117
+ // disable extracting variables as no native concept of them (only theme values)
118
+ disableExtractVariables: options.experimentalFlattenThemesOnNative ? !1 : "theme",
119
+ sourcePath,
120
+ // disabling flattening for now
121
+ // it's flattening a plain <Paragraph>hello</Paragraph> which breaks things because themes
122
+ // thinking it's not really worth the effort to do much compilation on native
123
+ // for now just disable flatten as it can only run in narrow places on native
124
+ // disableFlattening: 'styled',
125
+ getFlattenedNode({ isTextView }) {
126
+ return hasImportedView || (hasImportedView = !0, root.unshiftContainer("body", importNativeView())), isTextView ? "__ReactNativeText" : "__ReactNativeView";
127
+ },
128
+ onExtractTag(props) {
129
+ const { isFlattened } = props;
130
+ if (!isFlattened)
131
+ return;
132
+ assertValidTag(props.node);
133
+ const stylesExpr = t.arrayExpression([]), hocStylesExpr = t.arrayExpression([]), expressions = [], finalAttrs = [], themeKeysUsed = /* @__PURE__ */ new Set();
134
+ function getStyleExpression(style) {
135
+ if (!style) return;
136
+ const { plain, themed } = splitThemeStyles(style);
137
+ let themeExpr = null;
138
+ if (themed && options.experimentalFlattenThemesOnNative) {
139
+ for (const key in themed)
140
+ themeKeysUsed.add(themed[key].split("$")[1]);
141
+ themeExpr = getThemedStyleExpression(themed);
142
+ }
143
+ const ident = addSheetStyle(plain, props.node);
144
+ return themeExpr ? (addStyleExpression(ident), addStyleExpression(ident, !0), themeExpr) : ident;
145
+ }
146
+ function addStyleExpression(expr, HOC = !1) {
147
+ Array.isArray(expr) ? (HOC ? hocStylesExpr : stylesExpr).elements.push(...expr) : (HOC ? hocStylesExpr : stylesExpr).elements.push(expr);
148
+ }
149
+ function getThemedStyleExpression(styles) {
150
+ const themedStylesAst = (0, import_literalToAst.literalToAst)(styles);
151
+ return themedStylesAst.properties.forEach((_) => {
152
+ const prop = _;
153
+ prop.value.type === "StringLiteral" && (prop.value = t.memberExpression(
154
+ t.identifier("theme"),
155
+ t.identifier(prop.value.value.slice(1) + ".get()")
156
+ ));
157
+ }), themedStylesAst;
158
+ }
159
+ let hasDynamicStyle = !1;
160
+ for (const attr of props.attrs)
161
+ switch (attr.type) {
162
+ case "style": {
163
+ let styleExpr = getStyleExpression(attr.value);
164
+ addStyleExpression(styleExpr), options.experimentalFlattenThemesOnNative && addStyleExpression(styleExpr, !0);
165
+ break;
166
+ }
167
+ case "ternary": {
168
+ const { consequent, alternate } = attr.value, consExpr = getStyleExpression(consequent), altExpr = getStyleExpression(alternate);
169
+ options.experimentalFlattenThemesOnNative && (expressions.push(attr.value.test), addStyleExpression(
170
+ t.conditionalExpression(
171
+ t.identifier(`_expressions[${expressions.length - 1}]`),
172
+ consExpr || t.nullLiteral(),
173
+ altExpr || t.nullLiteral()
174
+ ),
175
+ !0
176
+ ));
177
+ const styleExpr = t.conditionalExpression(
178
+ attr.value.test,
179
+ consExpr || t.nullLiteral(),
180
+ altExpr || t.nullLiteral()
181
+ );
182
+ addStyleExpression(
183
+ styleExpr
184
+ // TODO: what is this for ?
185
+ // isFlattened ? simpleHash(JSON.stringify({ consequent, alternate })) : undefined
186
+ );
187
+ break;
188
+ }
189
+ case "dynamic-style": {
190
+ hasDynamicStyle = !0, expressions.push(attr.value), options.experimentalFlattenDynamicValues ? addStyleExpression(
191
+ t.objectExpression([
192
+ t.objectProperty(
193
+ t.identifier(attr.name),
194
+ t.identifier(`_expressions[${expressions.length - 1}]`)
195
+ )
196
+ ]),
197
+ !0
198
+ ) : addStyleExpression(
199
+ t.objectExpression([
200
+ t.objectProperty(
201
+ t.identifier(attr.name),
202
+ attr.value
203
+ )
204
+ ])
205
+ );
206
+ break;
207
+ }
208
+ case "attr": {
209
+ t.isJSXSpreadAttribute(attr.value) && (0, import_extractHelpers.isSimpleSpread)(attr.value) && (stylesExpr.elements.push(
210
+ t.memberExpression(attr.value.argument, t.identifier("style"))
211
+ ), options.experimentalFlattenThemesOnNative && hocStylesExpr.elements.push(
212
+ t.memberExpression(
213
+ attr.value.argument,
214
+ t.identifier("style")
215
+ )
216
+ )), finalAttrs.push(attr.value);
217
+ break;
218
+ }
219
+ }
220
+ if (props.node.attributes = finalAttrs, props.isFlattened)
221
+ if (options.experimentalFlattenThemesOnNative && (themeKeysUsed.size || hocStylesExpr.elements.length > 1 || hasDynamicStyle)) {
222
+ hasImportedViewWrapper || (root.unshiftContainer("body", importWithStyle()), hasImportedViewWrapper = !0);
223
+ const name = props.node.name.name, WrapperIdentifier = root.scope.generateUidIdentifier(
224
+ name + "Wrapper"
225
+ );
226
+ root.pushContainer(
227
+ "body",
228
+ t.variableDeclaration("const", [
229
+ t.variableDeclarator(
230
+ WrapperIdentifier,
231
+ t.callExpression(t.identifier("__withStableStyle"), [
232
+ t.identifier(name),
233
+ t.arrowFunctionExpression(
234
+ [t.identifier("theme"), t.identifier("_expressions")],
235
+ t.blockStatement([
236
+ t.returnStatement(
237
+ t.callExpression(
238
+ t.memberExpression(
239
+ t.identifier("React"),
240
+ t.identifier("useMemo")
241
+ ),
242
+ [
243
+ t.arrowFunctionExpression(
244
+ [],
245
+ t.blockStatement([
246
+ t.returnStatement(
247
+ t.arrayExpression([...hocStylesExpr.elements])
248
+ )
249
+ ])
250
+ ),
251
+ t.arrayExpression([
252
+ t.spreadElement(t.identifier("_expressions"))
253
+ ])
254
+ ]
255
+ )
256
+ )
257
+ ])
258
+ )
259
+ ])
260
+ )
261
+ ])
262
+ ), props.node.name = WrapperIdentifier, props.jsxPath.node.closingElement && (props.jsxPath.node.closingElement.name = WrapperIdentifier), expressions.length && props.node.attributes.push(
263
+ t.jsxAttribute(
264
+ t.jsxIdentifier("expressions"),
265
+ t.jsxExpressionContainer(t.arrayExpression(expressions))
266
+ )
267
+ );
268
+ } else
269
+ props.node.attributes.push(
270
+ t.jsxAttribute(
271
+ t.jsxIdentifier("style"),
272
+ t.jsxExpressionContainer(
273
+ stylesExpr.elements.length === 1 ? stylesExpr.elements[0] : stylesExpr
274
+ )
275
+ )
276
+ );
277
+ }
278
+ });
279
+ } catch (err) {
280
+ if (err instanceof Error) {
281
+ let message = `${shouldPrintDebug === "verbose" ? err : err.message}`;
282
+ 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);
283
+ return;
284
+ }
285
+ }
286
+ if (!Object.keys(sheetStyles).length) {
287
+ shouldPrintDebug && console.info("END no styles"), res && printLog(res);
288
+ return;
289
+ }
290
+ const sheetObject = (0, import_literalToAst.literalToAst)(sheetStyles), sheetOuter = (0, import_template.default)(
291
+ "const SHEET = __ReactNativeStyleSheet.create(null)"
292
+ )({
293
+ SHEET: sheetIdentifier.name
294
+ });
295
+ sheetOuter.declarations[0].init.arguments[0] = sheetObject, root.unshiftContainer("body", sheetOuter), root.unshiftContainer("body", importStyleSheet()), shouldPrintDebug && (console.info(`
296
+ -------- output code -------
297
+ `), console.info(
298
+ (0, import_generator.default)(root.parent).code.split(`
299
+ `).filter((x) => !x.startsWith("//")).join(`
300
+ `)
301
+ )), res && printLog(res);
302
+ }
303
+ }
304
+ }
305
+ };
306
+ }
307
+ function assertValidTag(node) {
308
+ 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");
309
+ }
310
+ function splitThemeStyles(style) {
311
+ const themed = {}, plain = {};
312
+ let noTheme = !0;
313
+ for (const key in style) {
314
+ const val = style[key];
315
+ val && val[0] === "$" ? (themed[key] = val, noTheme = !1) : plain[key] = val;
316
+ }
317
+ return { themed: noTheme ? null : themed, plain };
318
+ }
319
+ //# sourceMappingURL=extractToNative.js.map
@@ -0,0 +1,6 @@
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,I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