@tamagui/static 1.100.6 → 1.101.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/extractor/createExtractor.js +21 -12
- package/dist/cjs/extractor/createExtractor.js.map +1 -1
- package/dist/cjs/extractor/createExtractor.native.js +18 -12
- package/dist/cjs/extractor/createExtractor.native.js.map +2 -2
- package/dist/cjs/extractor/extractMediaStyle.js +2 -2
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.native.js +2 -2
- package/dist/cjs/extractor/extractMediaStyle.native.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +17 -15
- package/dist/cjs/extractor/extractToClassNames.js.map +1 -1
- package/dist/cjs/extractor/extractToClassNames.native.js +12 -14
- package/dist/cjs/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/cjs/extractor/extractToNative.js +319 -0
- package/dist/cjs/extractor/extractToNative.js.map +6 -0
- package/dist/cjs/extractor/extractToNative.native.js +353 -0
- package/dist/cjs/extractor/extractToNative.native.js.map +6 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +2 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/extractor/createExtractor.js +24 -11
- package/dist/esm/extractor/createExtractor.js.map +1 -1
- package/dist/esm/extractor/createExtractor.mjs +16 -12
- package/dist/esm/extractor/createExtractor.native.js +18 -11
- package/dist/esm/extractor/createExtractor.native.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.js +2 -2
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.mjs +2 -2
- package/dist/esm/extractor/extractMediaStyle.native.js +2 -2
- package/dist/esm/extractor/extractMediaStyle.native.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +16 -15
- package/dist/esm/extractor/extractToClassNames.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.mjs +14 -16
- package/dist/esm/extractor/extractToClassNames.native.js +11 -14
- package/dist/esm/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/esm/extractor/extractToNative.js +309 -0
- package/dist/esm/extractor/extractToNative.js.map +6 -0
- package/dist/esm/extractor/extractToNative.mjs +232 -0
- package/dist/esm/extractor/extractToNative.native.js +329 -0
- package/dist/esm/extractor/extractToNative.native.js.map +6 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +16 -15
- package/src/extractor/createExtractor.ts +23 -22
- package/src/extractor/extractMediaStyle.ts +2 -2
- package/src/extractor/extractToClassNames.ts +30 -16
- package/src/extractor/extractToNative.ts +504 -0
- package/src/index.ts +1 -0
- package/types/extractor/babelParse.d.ts +0 -1
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +0 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts +13 -0
- package/types/extractor/extractToNative.d.ts.map +1 -0
- package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
@@ -0,0 +1,353 @@
|
|
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_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_static = require("@tamagui/static");
|
32
|
+
function _array_like_to_array(arr, len) {
|
33
|
+
(len == null || len > arr.length) && (len = arr.length);
|
34
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
35
|
+
return arr2;
|
36
|
+
}
|
37
|
+
function _array_without_holes(arr) {
|
38
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
39
|
+
}
|
40
|
+
function _define_property(obj, key, value) {
|
41
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
42
|
+
value,
|
43
|
+
enumerable: !0,
|
44
|
+
configurable: !0,
|
45
|
+
writable: !0
|
46
|
+
}) : obj[key] = value, obj;
|
47
|
+
}
|
48
|
+
function _instanceof(left, right) {
|
49
|
+
return right != null && typeof Symbol < "u" && right[Symbol.hasInstance] ? !!right[Symbol.hasInstance](left) : left instanceof right;
|
50
|
+
}
|
51
|
+
function _iterable_to_array(iter) {
|
52
|
+
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
53
|
+
}
|
54
|
+
function _non_iterable_spread() {
|
55
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
56
|
+
}
|
57
|
+
function _object_spread(target) {
|
58
|
+
for (var i = 1; i < arguments.length; i++) {
|
59
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
60
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
61
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
62
|
+
}))), ownKeys2.forEach(function(key) {
|
63
|
+
_define_property(target, key, source[key]);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
return target;
|
67
|
+
}
|
68
|
+
function ownKeys(object, enumerableOnly) {
|
69
|
+
var keys = Object.keys(object);
|
70
|
+
if (Object.getOwnPropertySymbols) {
|
71
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
72
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
73
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
74
|
+
})), keys.push.apply(keys, symbols);
|
75
|
+
}
|
76
|
+
return keys;
|
77
|
+
}
|
78
|
+
function _object_spread_props(target, source) {
|
79
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
80
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
81
|
+
}), target;
|
82
|
+
}
|
83
|
+
function _to_consumable_array(arr) {
|
84
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
85
|
+
}
|
86
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
87
|
+
if (o) {
|
88
|
+
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
89
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
90
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
91
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
var importNativeView = (0, import_template.default)(`
|
95
|
+
const __ReactNativeView = require('react-native').View;
|
96
|
+
const __ReactNativeText = require('react-native').Text;
|
97
|
+
`), importStyleSheet = (0, import_template.default)(`
|
98
|
+
const __ReactNativeStyleSheet = require('react-native').StyleSheet;
|
99
|
+
`), importWithStyle = (0, import_template.default)(`
|
100
|
+
const __withStableStyle = require('@tamagui/core')._withStableStyle;
|
101
|
+
`), extractor = (0, import_static.createExtractor)({
|
102
|
+
platform: "native"
|
103
|
+
}), tamaguiBuildOptionsLoaded;
|
104
|
+
function extractToNative(sourceFileName, sourceCode, options) {
|
105
|
+
var ast = (0, import_parser.parse)(sourceCode, {
|
106
|
+
sourceType: "module",
|
107
|
+
plugins: [
|
108
|
+
"jsx",
|
109
|
+
"typescript"
|
110
|
+
]
|
111
|
+
}), babelPlugin = getBabelPlugin(), out = (0, import_core.transformFromAstSync)(ast, sourceCode, {
|
112
|
+
plugins: [
|
113
|
+
[
|
114
|
+
babelPlugin,
|
115
|
+
options
|
116
|
+
]
|
117
|
+
],
|
118
|
+
configFile: !1,
|
119
|
+
sourceFileName,
|
120
|
+
filename: sourceFileName
|
121
|
+
});
|
122
|
+
if (!out)
|
123
|
+
throw new Error("No output returned");
|
124
|
+
return out;
|
125
|
+
}
|
126
|
+
function getBabelPlugin() {
|
127
|
+
return (0, import_helper_plugin_utils.declare)(function(api, options) {
|
128
|
+
return api.assertVersion(7), getBabelParseDefinition(options);
|
129
|
+
});
|
130
|
+
}
|
131
|
+
function getBabelParseDefinition(options) {
|
132
|
+
return {
|
133
|
+
name: "tamagui",
|
134
|
+
visitor: {
|
135
|
+
Program: {
|
136
|
+
enter: function(root) {
|
137
|
+
var _process_env_SOURCE_ROOT, _root_node_body__leadingComments, _root_node_body_, sourcePath = this.file.opts.filename;
|
138
|
+
if (sourcePath != null && sourcePath.includes("node_modules") || !(sourcePath != null && sourcePath.endsWith(".jsx")) && !(sourcePath != null && sourcePath.endsWith(".tsx")))
|
139
|
+
return;
|
140
|
+
!((_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", ""));
|
141
|
+
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) {
|
142
|
+
return (comment == null ? void 0 : comment.value) || " ";
|
143
|
+
}).join(" ")) !== null && _root_node_body__leadingComments_map_join !== void 0 ? _root_node_body__leadingComments_map_join : "", firstComment = firstCommentContents ? "//".concat(firstCommentContents) : "", _getPragmaOptions = (0, import_static.getPragmaOptions)({
|
144
|
+
source: firstComment,
|
145
|
+
path: sourcePath
|
146
|
+
}), shouldPrintDebug = _getPragmaOptions.shouldPrintDebug, shouldDisable = _getPragmaOptions.shouldDisable;
|
147
|
+
if (shouldDisable)
|
148
|
+
return;
|
149
|
+
!options.config && !options.components && (tamaguiBuildOptionsLoaded || (tamaguiBuildOptionsLoaded = (0, import_static.loadTamaguiBuildConfigSync)({})));
|
150
|
+
var finalOptions = _object_spread({
|
151
|
+
// @ts-ignore just in case they leave it out
|
152
|
+
platform: "native"
|
153
|
+
}, tamaguiBuildOptionsLoaded, options), printLog = (0, import_static.createLogger)(sourcePath, finalOptions);
|
154
|
+
function addSheetStyle(style, node) {
|
155
|
+
var styleIndex = "".concat(Object.keys(sheetStyles).length), key = "".concat(styleIndex);
|
156
|
+
if (process.env.NODE_ENV === "development") {
|
157
|
+
var lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? "-".concat(node.loc.end.line) : "") : "";
|
158
|
+
key += ":".concat((0, import_node_path.basename)(sourcePath), ":").concat(lineNumbers);
|
159
|
+
}
|
160
|
+
return sheetStyles[key] = style, readStyleExpr(key);
|
161
|
+
}
|
162
|
+
function readStyleExpr(key) {
|
163
|
+
return (0, import_template.default)("SHEET['KEY']")({
|
164
|
+
SHEET: sheetIdentifier.name,
|
165
|
+
KEY: key
|
166
|
+
}).expression;
|
167
|
+
}
|
168
|
+
var res;
|
169
|
+
try {
|
170
|
+
res = extractor.parseSync(root, _object_spread_props(_object_spread({
|
171
|
+
importsWhitelist: [
|
172
|
+
"constants.js",
|
173
|
+
"colors.js"
|
174
|
+
],
|
175
|
+
extractStyledDefinitions: options.forceExtractStyleDefinitions,
|
176
|
+
excludeProps: /* @__PURE__ */ new Set([
|
177
|
+
"className",
|
178
|
+
"userSelect",
|
179
|
+
"whiteSpace",
|
180
|
+
"textOverflow",
|
181
|
+
"cursor",
|
182
|
+
"contain"
|
183
|
+
]),
|
184
|
+
shouldPrintDebug
|
185
|
+
}, finalOptions), {
|
186
|
+
// disable this extraction for now at least, need to figure out merging theme vs non-theme
|
187
|
+
// because theme need to stay in render(), whereas non-theme can be extracted
|
188
|
+
// for now just turn it off entirely at a small perf loss
|
189
|
+
disableExtractInlineMedia: !0,
|
190
|
+
// disable extracting variables as no native concept of them (only theme values)
|
191
|
+
disableExtractVariables: options.experimentalFlattenThemesOnNative ? !1 : "theme",
|
192
|
+
sourcePath,
|
193
|
+
// disabling flattening for now
|
194
|
+
// it's flattening a plain <Paragraph>hello</Paragraph> which breaks things because themes
|
195
|
+
// thinking it's not really worth the effort to do much compilation on native
|
196
|
+
// for now just disable flatten as it can only run in narrow places on native
|
197
|
+
// disableFlattening: 'styled',
|
198
|
+
getFlattenedNode: function(param) {
|
199
|
+
var isTextView = param.isTextView;
|
200
|
+
return hasImportedView || (hasImportedView = !0, root.unshiftContainer("body", importNativeView())), isTextView ? "__ReactNativeText" : "__ReactNativeView";
|
201
|
+
},
|
202
|
+
onExtractTag: function(props) {
|
203
|
+
var isFlattened = props.isFlattened;
|
204
|
+
if (!isFlattened)
|
205
|
+
return;
|
206
|
+
assertValidTag(props.node);
|
207
|
+
var stylesExpr = t.arrayExpression([]), hocStylesExpr = t.arrayExpression([]), expressions = [], finalAttrs = [], themeKeysUsed = /* @__PURE__ */ new Set();
|
208
|
+
function getStyleExpression(style) {
|
209
|
+
if (style) {
|
210
|
+
var _splitThemeStyles = splitThemeStyles(style), plain = _splitThemeStyles.plain, themed = _splitThemeStyles.themed, themeExpr = null;
|
211
|
+
if (themed && options.experimentalFlattenThemesOnNative) {
|
212
|
+
for (var key in themed)
|
213
|
+
themeKeysUsed.add(themed[key].split("$")[1]);
|
214
|
+
themeExpr = getThemedStyleExpression(themed);
|
215
|
+
}
|
216
|
+
var ident = addSheetStyle(plain, props.node);
|
217
|
+
return themeExpr ? (addStyleExpression(ident), addStyleExpression(ident, !0), themeExpr) : ident;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
function addStyleExpression(expr) {
|
221
|
+
var HOC = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
|
222
|
+
if (Array.isArray(expr)) {
|
223
|
+
var _elements;
|
224
|
+
(_elements = (HOC ? hocStylesExpr : stylesExpr).elements).push.apply(_elements, _to_consumable_array(expr));
|
225
|
+
} else
|
226
|
+
(HOC ? hocStylesExpr : stylesExpr).elements.push(expr);
|
227
|
+
}
|
228
|
+
function getThemedStyleExpression(styles) {
|
229
|
+
var themedStylesAst = (0, import_static.literalToAst)(styles);
|
230
|
+
return themedStylesAst.properties.forEach(function(_) {
|
231
|
+
var prop = _;
|
232
|
+
prop.value.type === "StringLiteral" && (prop.value = t.memberExpression(t.identifier("theme"), t.identifier(prop.value.value.slice(1) + ".get()")));
|
233
|
+
}), themedStylesAst;
|
234
|
+
}
|
235
|
+
var hasDynamicStyle = !1, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
236
|
+
try {
|
237
|
+
for (var _iterator = props.attrs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
238
|
+
var attr = _step.value;
|
239
|
+
switch (attr.type) {
|
240
|
+
case "style": {
|
241
|
+
var styleExpr = getStyleExpression(attr.value);
|
242
|
+
addStyleExpression(styleExpr), options.experimentalFlattenThemesOnNative && addStyleExpression(styleExpr, !0);
|
243
|
+
break;
|
244
|
+
}
|
245
|
+
case "ternary": {
|
246
|
+
var _attr_value = attr.value, consequent = _attr_value.consequent, alternate = _attr_value.alternate, consExpr = getStyleExpression(consequent), altExpr = getStyleExpression(alternate);
|
247
|
+
options.experimentalFlattenThemesOnNative && (expressions.push(attr.value.test), addStyleExpression(t.conditionalExpression(t.identifier("_expressions[".concat(expressions.length - 1, "]")), consExpr || t.nullLiteral(), altExpr || t.nullLiteral()), !0));
|
248
|
+
var styleExpr1 = t.conditionalExpression(attr.value.test, consExpr || t.nullLiteral(), altExpr || t.nullLiteral());
|
249
|
+
addStyleExpression(styleExpr1);
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
case "dynamic-style": {
|
253
|
+
hasDynamicStyle = !0, expressions.push(attr.value), options.experimentalFlattenDynamicValues ? addStyleExpression(t.objectExpression([
|
254
|
+
t.objectProperty(t.identifier(attr.name), t.identifier("_expressions[".concat(expressions.length - 1, "]")))
|
255
|
+
]), !0) : addStyleExpression(t.objectExpression([
|
256
|
+
t.objectProperty(t.identifier(attr.name), attr.value)
|
257
|
+
]));
|
258
|
+
break;
|
259
|
+
}
|
260
|
+
case "attr": {
|
261
|
+
t.isJSXSpreadAttribute(attr.value) && (0, import_static.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);
|
262
|
+
break;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
} catch (err) {
|
267
|
+
_didIteratorError = !0, _iteratorError = err;
|
268
|
+
} finally {
|
269
|
+
try {
|
270
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
271
|
+
} finally {
|
272
|
+
if (_didIteratorError)
|
273
|
+
throw _iteratorError;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
if (props.node.attributes = finalAttrs, props.isFlattened)
|
277
|
+
if (options.experimentalFlattenThemesOnNative && (themeKeysUsed.size || hocStylesExpr.elements.length > 1 || hasDynamicStyle)) {
|
278
|
+
hasImportedViewWrapper || (root.unshiftContainer("body", importWithStyle()), hasImportedViewWrapper = !0);
|
279
|
+
var name = props.node.name.name, WrapperIdentifier = root.scope.generateUidIdentifier(name + "Wrapper");
|
280
|
+
root.pushContainer("body", t.variableDeclaration("const", [
|
281
|
+
t.variableDeclarator(WrapperIdentifier, t.callExpression(t.identifier("__withStableStyle"), [
|
282
|
+
t.identifier(name),
|
283
|
+
t.arrowFunctionExpression([
|
284
|
+
t.identifier("theme"),
|
285
|
+
t.identifier("_expressions")
|
286
|
+
], t.blockStatement([
|
287
|
+
t.returnStatement(t.callExpression(t.memberExpression(t.identifier("React"), t.identifier("useMemo")), [
|
288
|
+
t.arrowFunctionExpression([], t.blockStatement([
|
289
|
+
t.returnStatement(t.arrayExpression(_to_consumable_array(hocStylesExpr.elements)))
|
290
|
+
])),
|
291
|
+
t.arrayExpression([
|
292
|
+
t.spreadElement(t.identifier("_expressions"))
|
293
|
+
])
|
294
|
+
]))
|
295
|
+
]))
|
296
|
+
]))
|
297
|
+
])), 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))));
|
298
|
+
} else
|
299
|
+
props.node.attributes.push(t.jsxAttribute(t.jsxIdentifier("style"), t.jsxExpressionContainer(stylesExpr.elements.length === 1 ? stylesExpr.elements[0] : stylesExpr)));
|
300
|
+
}
|
301
|
+
}));
|
302
|
+
} catch (err) {
|
303
|
+
if (_instanceof(err, Error)) {
|
304
|
+
var message = "".concat(shouldPrintDebug === "verbose" ? err : err.message);
|
305
|
+
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);
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
if (!Object.keys(sheetStyles).length) {
|
310
|
+
shouldPrintDebug && console.info("END no styles"), res && printLog(res);
|
311
|
+
return;
|
312
|
+
}
|
313
|
+
var sheetObject = (0, import_static.literalToAst)(sheetStyles), sheetOuter = (0, import_template.default)("const SHEET = __ReactNativeStyleSheet.create(null)")({
|
314
|
+
SHEET: sheetIdentifier.name
|
315
|
+
});
|
316
|
+
sheetOuter.declarations[0].init.arguments[0] = sheetObject, root.unshiftContainer("body", sheetOuter), root.unshiftContainer("body", importStyleSheet()), shouldPrintDebug && (console.info(`
|
317
|
+
-------- output code -------
|
318
|
+
`), console.info((0, import_generator.default)(root.parent).code.split(`
|
319
|
+
`).filter(function(x) {
|
320
|
+
return !x.startsWith("//");
|
321
|
+
}).join(`
|
322
|
+
`))), res && printLog(res);
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
};
|
327
|
+
}
|
328
|
+
function assertValidTag(node) {
|
329
|
+
if (node.attributes.find(function(x) {
|
330
|
+
return x.type === "JSXAttribute" && x.name.name === "style";
|
331
|
+
})) {
|
332
|
+
var _process_env_DEBUG;
|
333
|
+
!((_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");
|
334
|
+
}
|
335
|
+
}
|
336
|
+
function splitThemeStyles(style) {
|
337
|
+
var themed = {}, plain = {}, noTheme = !0;
|
338
|
+
for (var key in style) {
|
339
|
+
var val = style[key];
|
340
|
+
val && val[0] === "$" ? (themed[key] = val, noTheme = !1) : plain[key] = val;
|
341
|
+
}
|
342
|
+
return {
|
343
|
+
themed: noTheme ? null : themed,
|
344
|
+
plain
|
345
|
+
};
|
346
|
+
}
|
347
|
+
// Annotate the CommonJS export names for ESM import in node:
|
348
|
+
0 && (module.exports = {
|
349
|
+
extractToNative,
|
350
|
+
getBabelParseDefinition,
|
351
|
+
getBabelPlugin
|
352
|
+
});
|
353
|
+
//# sourceMappingURL=extractToNative.js.map
|
@@ -0,0 +1,6 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/extractor/Users/n8/tamagui/packages/static/src/extractor/extractToNative.ts"],
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAyB,sBAEzB,cAA2D,wBAC3D,mBAAsB,sCACtB,6BAAwB,uCACxB,gBAAsB,0BACtB,kBAAqB,qCACrB,IAAmB,kCAEnB,gBAOO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,IAAMA,uBAAmBC,gBAAAA,SAAU;;;CAAA,GAK7BC,uBAAmBD,gBA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AA,IAIR8B,OAAKnB,SAASmB,GAAAA;QACpB;MACF;IACF;EACF;AACF;AAEA,SAASgB,eAAepD,MAAyB;AAC/C,MAAIA,KAAKwG,WAAWiC,KAAK,SAACF,GAAAA;WAAMA,EAAEpD,SAAS,kBAAkBoD,EAAE5J,KAAKA,SAAS;MAAU;QAGjFK;AAAJ,IAAIA,wBAAAA,QAAQM,IAAIoJ,WAAK,QAAjB1J,uBAAAA,WAAAA,mBAAmBwJ,WAAW,SAAA,KAChCd,QAAQC,KAAK,6DAAA;EAEjB;AACF;AAEA,SAAS9D,iBAAiBzC,OAAa;AACrC,MAAM2C,SAAiB,CAAC,GAClBD,QAAgB,CAAC,GACnB6E,UAAU;AACd,WAAWlH,OAAOL,OAAO;AACvB,QAAMwH,MAAMxH,MAAMK,GAAAA;AAClB,IAAImH,OAAOA,IAAI,CAAA,MAAO,OACpB7E,OAAOtC,GAAAA,IAAOmH,KACdD,UAAU,MAEV7E,MAAMrC,GAAAA,IAAOmH;EAEjB;AACA,SAAO;IAAE7E,QAAQ4E,UAAU,OAAO5E;IAAQD;EAAM;AAClD;",
|
5
|
+
"names": ["importNativeView", "template", "importStyleSheet", "importWithStyle", "extractor", "createExtractor", "platform", "tamaguiBuildOptionsLoaded", "extractToNative", "sourceFileName", "sourceCode", "options", "ast", "parse", "sourceType", "plugins", "babelPlugin", "getBabelPlugin", "out", "transformFromAstSync", "configFile", "filename", "Error", "declare", "api", "assertVersion", "getBabelParseDefinition", "name", "visitor", "Program", "enter", "root", "process", "sourcePath", "file", "opts", "includes", "endsWith", "env", "SOURCE_ROOT", "replace", "hasImportedView", "hasImportedViewWrapper", "sheetStyles", "sheetIdentifier", "scope", "generateUidIdentifier", "firstCommentContents", "node", "body", "leadingComments", "map", "comment", "value", "join", "firstComment", "getPragmaOptions", "source", "path", "shouldPrintDebug", "shouldDisable", "config", "components", "loadTamaguiBuildConfigSync", "finalOptions", "printLog", "createLogger", "addSheetStyle", "style", "styleIndex", "Object", "keys", "length", "key", "NODE_ENV", "lineNumbers", "loc", "start", "line", "end", "basename", "readStyleExpr", "SHEET", "KEY", "res", "parseSync", "importsWhitelist", "extractStyledDefinitions", "forceExtractStyleDefinitions", "excludeProps", "Set", "disableExtractInlineMedia", "disableExtractVariables", "experimentalFlattenThemesOnNative", "getFlattenedNode", "isTextView", "unshiftContainer", "onExtractTag", "props", "isFlattened", "assertValidTag", "stylesExpr", "t", "arrayExpression", "hocStylesExpr", "expressions", "finalAttrs", "themeKeysUsed", "getStyleExpression", "splitThemeStyles", "plain", "themed", "themeExpr", "add", "split", "getThemedStyleExpression", "ident", "addStyleExpression", "expr", "HOC", "Array", "isArray", "elements", "push", "styles", "themedStylesAst", "literalToAst", "properties", "forEach", "_", "prop", "type", "memberExpression", "identifier", "slice", "hasDynamicStyle", "attrs", "attr", "styleExpr", "consequent", "alternate", "consExpr", "altExpr", "test", "conditionalExpression", "nullLiteral", "experimentalFlattenDynamicValues", "objectExpression", "objectProperty", "isJSXSpreadAttribute", "isSimpleSpread", "argument", "attributes", "size", "WrapperIdentifier", "pushContainer", "variableDeclaration", "variableDeclarator", "callExpression", "arrowFunctionExpression", "blockStatement", "returnStatement", "spreadElement", "jsxPath", "closingElement", "jsxAttribute", "jsxIdentifier", "jsxExpressionContainer", "err", "message", "console", "warn", "stack", "info", "sheetObject", "sheetOuter", "declarations", "init", "arguments", "generator", "parent", "code", "filter", "x", "startsWith", "find", "DEBUG", "noTheme", "val"]
|
6
|
+
}
|
package/dist/cjs/index.js
CHANGED
@@ -25,6 +25,7 @@ __reExport(src_exports, require("./types"), module.exports);
|
|
25
25
|
var import_createExtractor = require("./extractor/createExtractor"), import_literalToAst = require("./extractor/literalToAst");
|
26
26
|
__reExport(src_exports, require("./constants"), module.exports);
|
27
27
|
__reExport(src_exports, require("./extractor/extractToClassNames"), module.exports);
|
28
|
+
__reExport(src_exports, require("./extractor/extractToNative"), module.exports);
|
28
29
|
__reExport(src_exports, require("./extractor/extractHelpers"), module.exports);
|
29
30
|
__reExport(src_exports, require("./extractor/loadTamagui"), module.exports);
|
30
31
|
__reExport(src_exports, require("./extractor/watchTamaguiConfig"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/index.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAO;AACP,wBAAc,wBADd;AAEA,wBAAc,wBAFd;AAGA,wBAAc,oBAHd;AAIA,6BAAgC,wCAChC,sBAA6B;AAC7B,wBAAc,wBANd;AAOA,wBAAc,4CAPd;AAQA,wBAAc,
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAO;AACP,wBAAc,wBADd;AAEA,wBAAc,wBAFd;AAGA,wBAAc,oBAHd;AAIA,6BAAgC,wCAChC,sBAA6B;AAC7B,wBAAc,wBANd;AAOA,wBAAc,4CAPd;AAQA,wBAAc,wCARd;AASA,wBAAc,uCATd;AAUA,wBAAc,oCAVd;AAWA,wBAAc,2CAXd;AAYA,wBAAc,qCAZd;AAaA,wBAAc,8BAbd;AAcA,wBAAc,+BAdd;",
|
5
5
|
"names": []
|
6
6
|
}
|
package/dist/cjs/index.native.js
CHANGED
@@ -26,6 +26,7 @@ __reExport(src_exports, require("./types"), module.exports);
|
|
26
26
|
var import_createExtractor = require("./extractor/createExtractor"), import_literalToAst = require("./extractor/literalToAst");
|
27
27
|
__reExport(src_exports, require("./constants"), module.exports);
|
28
28
|
__reExport(src_exports, require("./extractor/extractToClassNames"), module.exports);
|
29
|
+
__reExport(src_exports, require("./extractor/extractToNative"), module.exports);
|
29
30
|
__reExport(src_exports, require("./extractor/extractHelpers"), module.exports);
|
30
31
|
__reExport(src_exports, require("./extractor/loadTamagui"), module.exports);
|
31
32
|
__reExport(src_exports, require("./extractor/watchTamaguiConfig"), module.exports);
|
@@ -41,6 +42,7 @@ __reExport(src_exports, require("./getPragmaOptions"), module.exports);
|
|
41
42
|
...require("./types"),
|
42
43
|
...require("./constants"),
|
43
44
|
...require("./extractor/extractToClassNames"),
|
45
|
+
...require("./extractor/extractToNative"),
|
44
46
|
...require("./extractor/extractHelpers"),
|
45
47
|
...require("./extractor/loadTamagui"),
|
46
48
|
...require("./extractor/watchTamaguiConfig"),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/packages/static/src/index.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;mBAAO;AACP,wBAAc,wBADd;AAEA,wBAAc,wBAFd;AAGA,wBAAc,oBAHd;AAIA,6BAAgC,wCAChC,sBAA6B;AAC7B,wBAAc,wBANd;AAOA,wBAAc,4CAPd;AAQA,wBAAc,
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;mBAAO;AACP,wBAAc,wBADd;AAEA,wBAAc,wBAFd;AAGA,wBAAc,oBAHd;AAIA,6BAAgC,wCAChC,sBAA6B;AAC7B,wBAAc,wBANd;AAOA,wBAAc,4CAPd;AAQA,wBAAc,wCARd;AASA,wBAAc,uCATd;AAUA,wBAAc,oCAVd;AAWA,wBAAc,2CAXd;AAYA,wBAAc,qCAZd;AAaA,wBAAc,8BAbd;AAcA,wBAAc,+BAdd;",
|
5
5
|
"names": []
|
6
6
|
}
|
@@ -2,6 +2,10 @@ import { basename, relative } from "node:path";
|
|
2
2
|
import traverse from "@babel/traverse";
|
3
3
|
import * as t from "@babel/types";
|
4
4
|
import { Color, colorLog } from "@tamagui/cli-color";
|
5
|
+
import {
|
6
|
+
StyleObjectIdentifier,
|
7
|
+
StyleObjectRules
|
8
|
+
} from "@tamagui/web";
|
5
9
|
import * as reactNativeWebInternals from "react-native-web-internals";
|
6
10
|
import { FAILED_EVAL } from "../constants";
|
7
11
|
import { requireTamaguiCore } from "../helpers/requireTamaguiCore";
|
@@ -170,7 +174,10 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
170
174
|
`
|
171
175
|
), console.info(" Got config:", tamaguiConfig), process.exit(0));
|
172
176
|
const firstThemeName = Object.keys(tamaguiConfig?.themes || {})[0], firstTheme = tamaguiConfig?.themes[firstThemeName] || {};
|
173
|
-
(!firstTheme || typeof firstTheme != "object")
|
177
|
+
if (!firstTheme || typeof firstTheme != "object") {
|
178
|
+
const err = `Missing theme ${firstThemeName}, an error occurred when importing your config`;
|
179
|
+
throw console.info(err, "Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), new Error(err);
|
180
|
+
}
|
174
181
|
const proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
|
175
182
|
get(target, key) {
|
176
183
|
return Reflect.has(target, key) && themeAccessListeners.forEach((cb) => cb(String(key))), Reflect.get(target, key);
|
@@ -351,7 +358,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
351
358
|
JSON.stringify(classNames, null, 2),
|
352
359
|
`
|
353
360
|
rulesToInsert:`,
|
354
|
-
out.rulesToInsert.flatMap((
|
361
|
+
out.rulesToInsert.flatMap((styleObject) => styleObject[StyleObjectRules]).join(`
|
355
362
|
`)
|
356
363
|
].join(" ")
|
357
364
|
), definition.properties = definition.properties.map((prop) => {
|
@@ -360,14 +367,17 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
360
367
|
const key = prop.key.name, value = classNames[key];
|
361
368
|
return value ? t.objectProperty(t.stringLiteral(key), t.stringLiteral(value)) : prop;
|
362
369
|
}), out.rulesToInsert)
|
363
|
-
for (const
|
364
|
-
onStyleRule?.(
|
370
|
+
for (const styleObject of out.rulesToInsert)
|
371
|
+
onStyleRule?.(
|
372
|
+
styleObject[StyleObjectIdentifier],
|
373
|
+
styleObject[StyleObjectRules]
|
374
|
+
);
|
365
375
|
res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
|
366
376
|
},
|
367
377
|
JSXElement(traversePath) {
|
368
378
|
tm.mark("jsx-element", !!shouldPrintDebug);
|
369
379
|
const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
|
370
|
-
if (
|
380
|
+
if (closingElement && t.isJSXMemberExpression(closingElement?.name) || !t.isJSXIdentifier(node.name)) {
|
371
381
|
shouldPrintDebug && logger.info(" skip non-identifier element");
|
372
382
|
return;
|
373
383
|
}
|
@@ -375,13 +385,16 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
375
385
|
let moduleName = "";
|
376
386
|
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
|
377
387
|
shouldPrintDebug && logger.info(
|
378
|
-
` - Binding
|
388
|
+
` - Binding in component ${componentName} not valid import: "${binding.identifier.name}" isn't in ${moduleName}
|
389
|
+
`
|
379
390
|
);
|
380
391
|
return;
|
381
392
|
}
|
382
393
|
const component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
|
383
394
|
if (!component || !component.staticConfig) {
|
384
|
-
shouldPrintDebug && logger.info(`
|
395
|
+
shouldPrintDebug && logger.info(`
|
396
|
+
- No Tamagui conf for: ${node.name.name}
|
397
|
+
`);
|
385
398
|
return;
|
386
399
|
}
|
387
400
|
const originalNodeName = node.name.name;
|
@@ -389,9 +402,8 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
389
402
|
const filePath = `./${relative(process.cwd(), sourcePath)}`, lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "", codePosition = `${filePath}:${lineNumbers}`, debugPropValue = node.attributes.filter(
|
390
403
|
(n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug"
|
391
404
|
).map((n) => n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1)[0];
|
392
|
-
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(
|
393
|
-
|
394
|
-
`\x1B[33m%s\x1B[0m ${componentName} | ${codePosition} -------------------`
|
405
|
+
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(
|
406
|
+
`\x1B[33m\x1B[0m ${componentName} | ${codePosition} -------------------`
|
395
407
|
), logger.info(
|
396
408
|
[
|
397
409
|
"\x1B[1m",
|
@@ -409,7 +421,8 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
409
421
|
t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
|
410
422
|
)
|
411
423
|
)), shouldDisableExtraction) {
|
412
|
-
shouldPrintDebug === "verbose" &&
|
424
|
+
shouldPrintDebug === "verbose" && logger.info(` \u274C Extraction disabled: ${JSON.stringify(disableExtraction)}
|
425
|
+
`);
|
413
426
|
return;
|
414
427
|
}
|
415
428
|
try {
|