@tamagui/static 1.132.16 → 1.132.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extractor/concatClassName.js +69 -0
- package/dist/extractor/concatClassName.js.map +6 -0
- package/dist/extractor/concatClassName.native.js +69 -0
- package/dist/extractor/concatClassName.native.js.map +6 -0
- package/dist/extractor/createEvaluator.js +13 -1
- package/dist/extractor/createEvaluator.js.map +1 -1
- package/dist/extractor/createEvaluator.native.js +6 -1
- package/dist/extractor/createEvaluator.native.js.map +2 -2
- package/dist/extractor/createExtractor.js +60 -114
- package/dist/extractor/createExtractor.js.map +1 -1
- package/dist/extractor/createExtractor.native.js +70 -123
- package/dist/extractor/createExtractor.native.js.map +2 -2
- package/dist/extractor/errors.js +22 -0
- package/dist/extractor/errors.js.map +6 -0
- package/dist/extractor/errors.native.js +119 -0
- package/dist/extractor/errors.native.js.map +6 -0
- package/dist/extractor/extractMediaStyle.js +1 -1
- package/dist/extractor/extractMediaStyle.js.map +1 -1
- package/dist/extractor/extractMediaStyle.native.js +1 -1
- package/dist/extractor/extractMediaStyle.native.js.map +2 -2
- package/dist/extractor/extractToClassNames.js +212 -172
- package/dist/extractor/extractToClassNames.js.map +2 -2
- package/dist/extractor/extractToClassNames.native.js +212 -188
- package/dist/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/extractor/extractToNative.js +47 -78
- package/dist/extractor/extractToNative.js.map +1 -1
- package/dist/extractor/extractToNative.native.js +23 -39
- package/dist/extractor/extractToNative.native.js.map +2 -2
- package/dist/extractor/normalizeTernaries.js +5 -3
- package/dist/extractor/normalizeTernaries.js.map +1 -1
- package/dist/extractor/normalizeTernaries.native.js +5 -3
- package/dist/extractor/normalizeTernaries.native.js.map +2 -2
- package/dist/extractor/propsToFontFamilyCache.js +7 -8
- package/dist/extractor/propsToFontFamilyCache.js.map +1 -1
- package/dist/extractor/propsToFontFamilyCache.native.js +9 -10
- package/dist/extractor/propsToFontFamilyCache.native.js.map +2 -2
- package/dist/registerRequire.js +1 -1
- package/dist/registerRequire.js.map +1 -1
- package/dist/registerRequire.native.js +1 -1
- package/dist/registerRequire.native.js.map +1 -1
- package/dist/types.native.js.map +1 -1
- package/package.json +15 -15
- package/src/extractor/concatClassName.ts +100 -0
- package/src/extractor/createEvaluator.ts +26 -1
- package/src/extractor/createExtractor.ts +108 -194
- package/src/extractor/errors.ts +1 -0
- package/src/extractor/extractMediaStyle.ts +1 -1
- package/src/extractor/extractToClassNames.ts +377 -264
- package/src/extractor/extractToNative.ts +68 -111
- package/src/extractor/normalizeTernaries.ts +10 -3
- package/src/extractor/propsToFontFamilyCache.ts +5 -5
- package/src/registerRequire.ts +1 -1
- package/src/types.ts +10 -13
- package/types/extractor/concatClassName.d.ts +8 -0
- package/types/extractor/concatClassName.d.ts.map +1 -0
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/errors.d.ts +3 -0
- package/types/extractor/errors.d.ts.map +1 -0
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/normalizeTernaries.d.ts.map +1 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +2 -2
- package/types/extractor/propsToFontFamilyCache.d.ts.map +1 -1
- package/types/types.d.ts +9 -10
- package/types/types.d.ts.map +1 -1
- package/dist/extractor/buildClassName.js +0 -72
- package/dist/extractor/buildClassName.js.map +0 -6
- package/dist/extractor/buildClassName.native.js +0 -67
- package/dist/extractor/buildClassName.native.js.map +0 -6
- package/dist/extractor/ensureImportingConcat.js +0 -50
- package/dist/extractor/ensureImportingConcat.js.map +0 -6
- package/dist/extractor/ensureImportingConcat.native.js +0 -49
- package/dist/extractor/ensureImportingConcat.native.js.map +0 -6
- package/dist/extractor/hoistClassNames.js +0 -63
- package/dist/extractor/hoistClassNames.js.map +0 -6
- package/dist/extractor/hoistClassNames.native.js +0 -66
- package/dist/extractor/hoistClassNames.native.js.map +0 -6
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/hoistClassNames.ts +0 -52
- package/types/extractor/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
@@ -0,0 +1,69 @@
|
|
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)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
15
|
+
var concatClassName_exports = {};
|
16
|
+
__export(concatClassName_exports, {
|
17
|
+
concatClassName: () => concatClassName
|
18
|
+
});
|
19
|
+
module.exports = __toCommonJS(concatClassName_exports);
|
20
|
+
function concatClassName(_cn) {
|
21
|
+
const args = arguments, usedPrefixes = [];
|
22
|
+
let final = "";
|
23
|
+
const len = args.length;
|
24
|
+
let propObjects = null;
|
25
|
+
for (let x = len; x >= 0; x--) {
|
26
|
+
const cns = args[x];
|
27
|
+
if (!cns) continue;
|
28
|
+
if (!Array.isArray(cns) && typeof cns != "string") {
|
29
|
+
propObjects = propObjects || [], propObjects.push(cns);
|
30
|
+
continue;
|
31
|
+
}
|
32
|
+
const names = Array.isArray(cns) ? cns : cns.split(" "), numNames = names.length;
|
33
|
+
for (let i = numNames - 1; i >= 0; i--) {
|
34
|
+
const name = names[i];
|
35
|
+
if (!name || name === " ") continue;
|
36
|
+
if (name[0] !== "_") {
|
37
|
+
final = name + " " + final;
|
38
|
+
continue;
|
39
|
+
}
|
40
|
+
const splitIndex = name.indexOf("-");
|
41
|
+
if (splitIndex < 1) {
|
42
|
+
final = name + " " + final;
|
43
|
+
continue;
|
44
|
+
}
|
45
|
+
const isMediaQuery = name[splitIndex + 1] === "_", styleKey = name.slice(1, name.lastIndexOf("-")), mediaKey = isMediaQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null, uid = mediaKey ? styleKey + mediaKey : styleKey;
|
46
|
+
if (usedPrefixes.indexOf(uid) > -1)
|
47
|
+
continue;
|
48
|
+
usedPrefixes.push(uid);
|
49
|
+
const propName = styleKey;
|
50
|
+
propName && propObjects && propObjects.some((po) => {
|
51
|
+
if (mediaKey) {
|
52
|
+
const propKey = pseudoInvert[mediaKey];
|
53
|
+
return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
|
54
|
+
}
|
55
|
+
return po && propName in po && po[propName] !== null;
|
56
|
+
}) || (final = name + " " + final);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return final;
|
60
|
+
}
|
61
|
+
const pseudoInvert = {
|
62
|
+
hover: "hoverStyle",
|
63
|
+
focus: "focusStyle",
|
64
|
+
press: "pressStyle",
|
65
|
+
focusVisible: "focusVisibleStyle",
|
66
|
+
focusWithin: "focusWithinStyle",
|
67
|
+
disabled: "disabledStyle"
|
68
|
+
};
|
69
|
+
//# sourceMappingURL=concatClassName.js.map
|
@@ -0,0 +1,6 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/extractor/concatClassName.ts"],
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,gBAAgB,KAAqD;AACnF,QAAM,OAAO,WACP,eAAyB,CAAC;AAChC,MAAI,QAAQ;AAEZ,QAAM,MAAM,KAAK;AACjB,MAAI,cAAmB;AACvB,WAAS,IAAI,KAAK,KAAK,GAAG,KAAK;AAC7B,UAAM,MAAM,KAAK,CAAC;AAElB,QAAI,CAAC,IAAK;AACV,QAAI,CAAC,MAAM,QAAQ,GAAG,KAAK,OAAO,OAAQ,UAAU;AAElD,oBAAc,eAAe,CAAC,GAC9B,YAAY,KAAK,GAAG;AACpB;AAAA,IACF;AAEA,UAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,IAAI,MAAM,GAAG,GAChD,WAAW,MAAM;AACvB,aAAS,IAAI,WAAW,GAAG,KAAK,GAAG,KAAK;AACtC,YAAM,OAAO,MAAM,CAAC;AAEpB,UAAI,CAAC,QAAQ,SAAS,IAAK;AAC3B,UAAI,KAAK,CAAC,MAAM,KAAK;AAEnB,gBAAQ,OAAO,MAAM;AACrB;AAAA,MACF;AAEA,YAAM,aAAa,KAAK,QAAQ,GAAG;AACnC,UAAI,aAAa,GAAG;AAClB,gBAAQ,OAAO,MAAM;AAErB;AAAA,MACF;AAKA,YAAM,eAHW,KAAK,aAAa,CAAC,MAGF,KAK5B,WAAW,KAAK,MAAM,GAAG,KAAK,YAAY,GAAG,CAAC,GAE9C,WAAW,eAAe,KAAK,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,MACvE,MAAM,WAAW,WAAW,WAAW;AAG7C,UAAI,aAAa,QAAQ,GAAG,IAAI;AAE9B;AAEF,mBAAa,KAAK,GAAG;AAGrB,YAAM,WAAW;AACjB,MAAI,YAAY,eAEZ,YAAY,KAAK,CAAC,OAAO;AACvB,YAAI,UAAU;AACZ,gBAAM,UAAU,aAAa,QAAQ;AACrC,iBAAO,MAAM,GAAG,OAAO,KAAK,YAAY,GAAG,OAAO,KAAK,GAAG,OAAO,MAAM;AAAA,QACzE;AAEA,eADY,MAAM,YAAY,MAAM,GAAG,QAAQ,MAAM;AAAA,MAEvD,CAAC,MAOL,QAAQ,OAAO,MAAM;AAAA,IACvB;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,cAAc;AAAA,EACd,aAAa;AAAA,EACb,UAAU;AACZ;",
|
5
|
+
"names": []
|
6
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
16
|
+
var concatClassName_exports = {};
|
17
|
+
__export(concatClassName_exports, {
|
18
|
+
concatClassName: () => concatClassName
|
19
|
+
});
|
20
|
+
module.exports = __toCommonJS(concatClassName_exports);
|
21
|
+
function concatClassName(_cn) {
|
22
|
+
for (var args = arguments, usedPrefixes = [], final = "", len = args.length, propObjects = null, x = len; x >= 0; x--) {
|
23
|
+
var _loop = function(i2) {
|
24
|
+
var name = names[i2];
|
25
|
+
if (!name || name === " ") return "continue";
|
26
|
+
if (name[0] !== "_")
|
27
|
+
return final = name + " " + final, "continue";
|
28
|
+
var splitIndex = name.indexOf("-");
|
29
|
+
if (splitIndex < 1)
|
30
|
+
return final = name + " " + final, "continue";
|
31
|
+
var nextChar = name[splitIndex + 1], isMediaQuery = nextChar === "_", styleKey = name.slice(1, name.lastIndexOf("-")), mediaKey = isMediaQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null, uid = mediaKey ? styleKey + mediaKey : styleKey;
|
32
|
+
if (usedPrefixes.indexOf(uid) > -1)
|
33
|
+
return "continue";
|
34
|
+
usedPrefixes.push(uid);
|
35
|
+
var propName = styleKey;
|
36
|
+
if (propName && propObjects && propObjects.some(function(po) {
|
37
|
+
if (mediaKey) {
|
38
|
+
var propKey = pseudoInvert[mediaKey];
|
39
|
+
return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
|
40
|
+
}
|
41
|
+
var res = po && propName in po && po[propName] !== null;
|
42
|
+
return res;
|
43
|
+
}))
|
44
|
+
return "continue";
|
45
|
+
final = name + " " + final;
|
46
|
+
}, cns = args[x];
|
47
|
+
if (cns) {
|
48
|
+
if (!Array.isArray(cns) && typeof cns != "string") {
|
49
|
+
propObjects = propObjects || [], propObjects.push(cns);
|
50
|
+
continue;
|
51
|
+
}
|
52
|
+
for (var names = Array.isArray(cns) ? cns : cns.split(" "), numNames = names.length, i = numNames - 1; i >= 0; i--) _loop(i);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return final;
|
56
|
+
}
|
57
|
+
var pseudoInvert = {
|
58
|
+
hover: "hoverStyle",
|
59
|
+
focus: "focusStyle",
|
60
|
+
press: "pressStyle",
|
61
|
+
focusVisible: "focusVisibleStyle",
|
62
|
+
focusWithin: "focusWithinStyle",
|
63
|
+
disabled: "disabledStyle"
|
64
|
+
};
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
66
|
+
0 && (module.exports = {
|
67
|
+
concatClassName
|
68
|
+
});
|
69
|
+
//# sourceMappingURL=concatClassName.js.map
|
@@ -0,0 +1,6 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/extractor/concatClassName.ts"],
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;AAUO,SAASA,gBAAgBC,KAA2C;AAOzE,WANMC,OAAOC,WACPC,eAAyB,CAAA,GAC3BC,QAAQ,IAENC,MAAMJ,KAAKK,QACbC,cAAmB,MACdC,IAAIH,KAAKG,KAAK,GAAGA,KAAK;;AAc3B,UAAMC,OAAOC,MAAMC,EAAAA;AAEnB,UAAI,CAACF,QAAQA,SAAS,IAAK,QAAA;AAC3B,UAAIA,KAAK,CAAA,MAAO;AAEdL,uBAAQK,OAAO,MAAML,OACrB;AAGF,UAAMQ,aAAaH,KAAKI,QAAQ,GAAA;AAChC,UAAID,aAAa;AACfR,uBAAQK,OAAO,MAAML,OAErB;AAGF,UAAMU,WAAWL,KAAKG,aAAa,CAAA,GAG7BG,eAAeD,aAAa,KAK5BE,WAAWP,KAAKQ,MAAM,GAAGR,KAAKS,YAAY,GAAA,CAAA,GAE1CC,WAAWJ,eAAeN,KAAKQ,MAAML,aAAa,GAAGA,aAAa,CAAA,IAAK,MACvEQ,MAAMD,WAAWH,WAAWG,WAAWH;AAG7C,UAAIb,aAAaU,QAAQO,GAAAA,IAAO;AAE9B,eAAA;AAEFjB,mBAAakB,KAAKD,GAAAA;AAGlB,UAAME,WAAWN;AACjB,UAAIM,YAAYf,eAEZA,YAAYgB,KAAK,SAACC,IAAAA;AAChB,YAAIL,UAAU;AACZ,cAAMM,UAAUC,aAAaP,QAAAA;AAC7B,iBAAOK,MAAMA,GAAGC,OAAAA,KAAYH,YAAYE,GAAGC,OAAAA,KAAYD,GAAGC,OAAAA,MAAa;QACzE;AACA,YAAME,MAAMH,MAAMF,YAAYE,MAAMA,GAAGF,QAAAA,MAAc;AACrD,eAAOK;MACT,CAAA;AAGA,eAAA;AAIJvB,cAAQK,OAAO,MAAML;IACvB,GApEMwB,MAAM3B,KAAKO,CAAAA;AAEjB,QAAKoB,KACL;UAAI,CAACC,MAAMC,QAAQF,GAAAA,KAAQ,OAAOA,OAAQ,UAAU;AAElDrB,sBAAcA,eAAe,CAAA,GAC7BA,YAAYc,KAAKO,GAAAA;AACjB;MACF;AAIA,eAFMlB,QAAQmB,MAAMC,QAAQF,GAAAA,IAAOA,MAAMA,IAAIG,MAAM,GAAA,GAC7CC,WAAWtB,MAAMJ,QACdK,IAAIqB,WAAW,GAAGrB,KAAK,GAAGA,IAAAA,OAAAA,CAAAA;;EAyDrC;AAEA,SAAOP;AACT;AAEA,IAAMsB,eAAe;EACnBO,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,cAAc;EACdC,aAAa;EACbC,UAAU;AACZ;",
|
5
|
+
"names": ["concatClassName", "_cn", "args", "arguments", "usedPrefixes", "final", "len", "length", "propObjects", "x", "name", "names", "i", "splitIndex", "indexOf", "nextChar", "isMediaQuery", "styleKey", "slice", "lastIndexOf", "mediaKey", "uid", "push", "propName", "some", "po", "propKey", "pseudoInvert", "res", "cns", "Array", "isArray", "split", "numNames", "hover", "focus", "press", "focusVisible", "focusWithin", "disabled"]
|
6
|
+
}
|
@@ -38,7 +38,19 @@ function createEvaluator({
|
|
38
38
|
if (t.isIdentifier(n) && typeof staticNamespace[n.name] < "u")
|
39
39
|
return staticNamespace[n.name];
|
40
40
|
const evalContext = import_node_vm.default.createContext(staticNamespace), codeWithTypescriptAnnotations = `(${(0, import_generator.default)(n).code})`, code = import_esbuild.default.transformSync(codeWithTypescriptAnnotations, { loader: "tsx" }).code.replace(/;\n$/, "");
|
41
|
-
|
41
|
+
shouldPrintDebug && console.info("evaluating", code);
|
42
|
+
const result1 = import_node_vm.default.runInContext(code, evalContext), result2 = import_node_vm.default.runInContext(code, evalContext);
|
43
|
+
if (!(Object.is(result1, result2) || typeof result1 == "object" && typeof result2 == "object" && JSON.stringify(result1) === JSON.stringify(result2)))
|
44
|
+
throw shouldPrintDebug && console.info(
|
45
|
+
"Bailing on non-deterministic expression:",
|
46
|
+
code,
|
47
|
+
`
|
48
|
+
First result:`,
|
49
|
+
result1,
|
50
|
+
"Second result:",
|
51
|
+
result2
|
52
|
+
), new Error("Non-deterministic value, bailing");
|
53
|
+
return result1;
|
42
54
|
};
|
43
55
|
return (n) => (0, import_evaluateAstNode.evaluateAstNode)(n, evalFn);
|
44
56
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/extractor/createEvaluator.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe,6BAEf,mBAAqB,sCAErB,IAAmB,kCACnB,iBAAoB,6BAEpB,mBAA4B,yBAE5B,yBAAgC;AAEzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QAAI,EAAE,aAAa,CAAC,KAAK,OAAO,gBAAgB,EAAE,IAAI,IAAM;AAC1D,aAAO,gBAAgB,EAAE,IAAI;
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe,6BAEf,mBAAqB,sCAErB,IAAmB,kCACnB,iBAAoB,6BAEpB,mBAA4B,yBAE5B,yBAAgC;AAEzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QAAI,EAAE,aAAa,CAAC,KAAK,OAAO,gBAAgB,EAAE,IAAI,IAAM;AAC1D,aAAO,gBAAgB,EAAE,IAAI;AAG/B,UAAM,cAAc,eAAAA,QAAG,cAAc,eAAe,GAE9C,gCAAgC,QAAI,iBAAAC,SAAS,CAAQ,EAAE,IAAI,KAC3D,OAAO,eAAAC,QACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,IAAI,oBACF,QAAQ,KAAK,cAAc,IAAI;AAGjC,UAAM,UAAU,eAAAF,QAAG,aAAa,MAAM,WAAW,GAC3C,UAAU,eAAAA,QAAG,aAAa,MAAM,WAAW;AAQjD,QAAI,EALF,OAAO,GAAG,SAAS,OAAO,KACzB,OAAO,WAAY,YAClB,OAAO,WAAY,YACnB,KAAK,UAAU,OAAO,MAAM,KAAK,UAAU,OAAO;AAGpD,YAAI,oBACF,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,GAEI,IAAI,MAAM,kCAAkC;AAGpD,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,UACC,wCAAgB,GAAG,MAAM;AAEpC;AAEO,SAAS,oBAAoB,aAAiC;AACnE,SAAO,CAAC,MAAc;AACpB,QAAI;AACF,aAAO,YAAY,CAAC;AAAA,IACtB,QAAc;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
5
5
|
"names": ["vm", "generate", "esbuild"]
|
6
6
|
}
|
@@ -35,7 +35,12 @@ function createEvaluator(param) {
|
|
35
35
|
var evalContext = import_node_vm.default.createContext(staticNamespace), codeWithTypescriptAnnotations = `(${(0, import_generator.default)(n).code})`, code = import_esbuild.default.transformSync(codeWithTypescriptAnnotations, {
|
36
36
|
loader: "tsx"
|
37
37
|
}).code.replace(/;\n$/, "");
|
38
|
-
|
38
|
+
shouldPrintDebug && console.info("evaluating", code);
|
39
|
+
var result1 = import_node_vm.default.runInContext(code, evalContext), result2 = import_node_vm.default.runInContext(code, evalContext), isDeterministic = Object.is(result1, result2) || typeof result1 == "object" && typeof result2 == "object" && JSON.stringify(result1) === JSON.stringify(result2);
|
40
|
+
if (!isDeterministic)
|
41
|
+
throw shouldPrintDebug && console.info("Bailing on non-deterministic expression:", code, `
|
42
|
+
First result:`, result1, "Second result:", result2), new Error("Non-deterministic value, bailing");
|
43
|
+
return result1;
|
39
44
|
};
|
40
45
|
return function(n) {
|
41
46
|
return (0, import_evaluateAstNode.evaluateAstNode)(n, evalFn);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/extractor/createEvaluator.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;qBAAe,6BAEf,mBAAqB,sCAErB,IAAmB,kCACnB,iBAAoB,6BAEpB,mBAA4B,yBAE5B,yBAAgC;AAEzB,SAASA,gBAAgB,OAY/B;MAZ+B,EAC9BC,OACAC,iBACAC,YACAC,cACAC,iBAAgB,IALc,OAcxBC,SAAS,SAACC,GAAAA;AAEd,QAAIC,EAAEC,aAAaF,CAAAA,KAAM,OAAOL,gBAAgBK,EAAEG,IAAI,IAAM;AAC1D,aAAOR,gBAAgBK,EAAEG,IAAI;
|
5
|
-
"names": ["createEvaluator", "props", "staticNamespace", "sourcePath", "traversePath", "shouldPrintDebug", "evalFn", "n", "t", "isIdentifier", "name", "evalContext", "vm", "createContext", "codeWithTypescriptAnnotations", "generate", "code", "esbuild", "transformSync", "loader", "replace", "console", "info", "runInContext", "evaluateAstNode", "createSafeEvaluator", "attemptEval", "FAILED_EVAL"]
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;qBAAe,6BAEf,mBAAqB,sCAErB,IAAmB,kCACnB,iBAAoB,6BAEpB,mBAA4B,yBAE5B,yBAAgC;AAEzB,SAASA,gBAAgB,OAY/B;MAZ+B,EAC9BC,OACAC,iBACAC,YACAC,cACAC,iBAAgB,IALc,OAcxBC,SAAS,SAACC,GAAAA;AAEd,QAAIC,EAAEC,aAAaF,CAAAA,KAAM,OAAOL,gBAAgBK,EAAEG,IAAI,IAAM;AAC1D,aAAOR,gBAAgBK,EAAEG,IAAI;AAG/B,QAAMC,cAAcC,eAAAA,QAAGC,cAAcX,eAAAA,GAE/BY,gCAAgC,QAAIC,iBAAAA,SAASR,CAAAA,EAAUS,IAAI,KAC3DA,OAAOC,eAAAA,QACVC,cAAcJ,+BAA+B;MAAEK,QAAQ;IAAM,CAAA,EAC7DH,KAAKI,QAAQ,QAAQ,EAAA;AAExB,IAAIf,oBACFgB,QAAQC,KAAK,cAAcN,IAAAA;AAG7B,QAAMO,UAAUX,eAAAA,QAAGY,aAAaR,MAAML,WAAAA,GAChCc,UAAUb,eAAAA,QAAGY,aAAaR,MAAML,WAAAA,GAEhCe,kBACJC,OAAOC,GAAGL,SAASE,OAAAA,KAClB,OAAOF,WAAY,YAClB,OAAOE,WAAY,YACnBI,KAAKC,UAAUP,OAAAA,MAAaM,KAAKC,UAAUL,OAAAA;AAE/C,QAAI,CAACC;AACH,YAAIrB,oBACFgB,QAAQC,KACN,4CACAN,MACA;gBACAO,SACA,kBACAE,OAAAA,GAGE,IAAIM,MAAM,kCAAkC;AAGpD,WAAOR;EACT;AAEA,SAAO,SAAChB,GAAAA;AACN,eAAOyB,wCAAgBzB,GAAGD,MAAAA;EAC5B;AACF;AAEO,SAAS2B,oBAAoBC,aAA+B;AACjE,SAAO,SAAC3B,GAAAA;AACN,QAAI;AACF,aAAO2B,YAAY3B,CAAAA;IACrB,QAAc;AACZ,aAAO4B;IACT;EACF;AACF;",
|
5
|
+
"names": ["createEvaluator", "props", "staticNamespace", "sourcePath", "traversePath", "shouldPrintDebug", "evalFn", "n", "t", "isIdentifier", "name", "evalContext", "vm", "createContext", "codeWithTypescriptAnnotations", "generate", "code", "esbuild", "transformSync", "loader", "replace", "console", "info", "result1", "runInContext", "result2", "isDeterministic", "Object", "is", "JSON", "stringify", "Error", "evaluateAstNode", "createSafeEvaluator", "attemptEval", "FAILED_EVAL"]
|
6
6
|
}
|
@@ -25,7 +25,7 @@ __export(createExtractor_exports, {
|
|
25
25
|
createExtractor: () => createExtractor
|
26
26
|
});
|
27
27
|
module.exports = __toCommonJS(createExtractor_exports);
|
28
|
-
var import_traverse = __toESM(require("@babel/traverse")), t = __toESM(require("@babel/types")), import_cli_color = require("@tamagui/cli-color"), reactNativeWebInternals = __toESM(require("@tamagui/react-native-web-internals")), import_web = require("@tamagui/web"), import_node_path = require("node:path"), import_constants = require("../constants"), import_requireTamaguiCore = require("../helpers/requireTamaguiCore"), import_createEvaluator = require("./createEvaluator"), import_evaluateAstNode = require("./evaluateAstNode"), import_extractHelpers = require("./extractHelpers"), import_findTopmostFunction = require("./findTopmostFunction"), import_getStaticBindingsForScope = require("./getStaticBindingsForScope"), import_literalToAst = require("./literalToAst"), import_loadTamagui = require("./loadTamagui"), import_logLines = require("./logLines"), import_normalizeTernaries = require("./normalizeTernaries"), import_propsToFontFamilyCache = require("./propsToFontFamilyCache"), import_timer = require("./timer"), import_validHTMLAttributes = require("./validHTMLAttributes");
|
28
|
+
var import_traverse = __toESM(require("@babel/traverse")), t = __toESM(require("@babel/types")), import_cli_color = require("@tamagui/cli-color"), reactNativeWebInternals = __toESM(require("@tamagui/react-native-web-internals")), import_web = require("@tamagui/web"), import_node_path = require("node:path"), import_constants = require("../constants"), import_requireTamaguiCore = require("../helpers/requireTamaguiCore"), import_createEvaluator = require("./createEvaluator"), import_evaluateAstNode = require("./evaluateAstNode"), import_extractHelpers = require("./extractHelpers"), import_findTopmostFunction = require("./findTopmostFunction"), import_getStaticBindingsForScope = require("./getStaticBindingsForScope"), import_literalToAst = require("./literalToAst"), import_loadTamagui = require("./loadTamagui"), import_logLines = require("./logLines"), import_normalizeTernaries = require("./normalizeTernaries"), import_propsToFontFamilyCache = require("./propsToFontFamilyCache"), import_timer = require("./timer"), import_validHTMLAttributes = require("./validHTMLAttributes"), import_errors = require("./errors");
|
29
29
|
const UNTOUCHED_PROPS = {
|
30
30
|
key: !0,
|
31
31
|
style: !0,
|
@@ -98,11 +98,10 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
98
98
|
evaluateVars = !0,
|
99
99
|
sourcePath = "",
|
100
100
|
onExtractTag,
|
101
|
-
|
101
|
+
onStyledDefinitionRule,
|
102
102
|
getFlattenedNode,
|
103
103
|
disable,
|
104
104
|
disableExtraction,
|
105
|
-
disableExtractInlineMedia,
|
106
105
|
disableExtractVariables,
|
107
106
|
disableDebugAttr,
|
108
107
|
enableDynamicEvaluation = !1,
|
@@ -366,7 +365,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
366
365
|
}), out.rulesToInsert)
|
367
366
|
for (const key in out.rulesToInsert) {
|
368
367
|
const styleObject = out.rulesToInsert[key];
|
369
|
-
|
368
|
+
onStyledDefinitionRule?.(
|
370
369
|
styleObject[import_web.StyleObjectIdentifier],
|
371
370
|
styleObject[import_web.StyleObjectRules]
|
372
371
|
);
|
@@ -439,11 +438,8 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
439
438
|
const [test, alt, cons] = conditional;
|
440
439
|
if (!test) throw new Error("no test");
|
441
440
|
return [alt, cons].some((side) => side && !isStaticObject(side)) ? (shouldPrintDebug && logger.info(`not extractable ${alt} ${cons}`), attr) : [
|
442
|
-
...
|
443
|
-
...cons &&
|
444
|
-
t.unaryExpression("!", test),
|
445
|
-
cons
|
446
|
-
) || []
|
441
|
+
...flattenNestedTernaries(test, alt) || [],
|
442
|
+
...cons && flattenNestedTernaries(t.unaryExpression("!", test), cons) || []
|
447
443
|
].map((ternary) => ({
|
448
444
|
type: "ternary",
|
449
445
|
value: ternary
|
@@ -470,11 +466,9 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
470
466
|
if (name[0] === "$" && t.isJSXExpressionContainer(attribute?.value)) {
|
471
467
|
const shortname = name.slice(1);
|
472
468
|
if (mediaQueryConfig[shortname]) {
|
473
|
-
if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
|
474
|
-
return attr;
|
475
469
|
const expression = attribute.value.expression;
|
476
470
|
if (!t.isJSXEmptyExpression(expression)) {
|
477
|
-
const ternaries2 =
|
471
|
+
const ternaries2 = flattenNestedTernaries(
|
478
472
|
t.stringLiteral(shortname),
|
479
473
|
expression,
|
480
474
|
{
|
@@ -562,12 +556,6 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
562
556
|
const staticLogical = getStaticLogical(value);
|
563
557
|
if (staticLogical)
|
564
558
|
return shouldPrintDebug === "verbose" && logger.info(` static ternary ${name} = ${value}`), { type: "ternary", value: staticLogical };
|
565
|
-
if (options.experimentalFlattenDynamicValues && isValidStyleKey(name, staticConfig))
|
566
|
-
return {
|
567
|
-
type: "dynamic-style",
|
568
|
-
value,
|
569
|
-
name: tamaguiConfig?.shorthands[name] || name
|
570
|
-
};
|
571
559
|
return inlined.set(name, !0), shouldPrintDebug && logger.info(` ! inline no match ${name} ${value}`), attr;
|
572
560
|
function addBinaryConditional(operator, staticExpr, cond) {
|
573
561
|
if (getStaticConditional(cond)) {
|
@@ -629,7 +617,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
629
617
|
const propName = prop.key.name;
|
630
618
|
return !isValidStyleKey(propName, staticConfig) && propName !== "tag" ? (shouldPrintDebug && logger.info([" not a valid style prop!", propName].join(" ")), !1) : !0;
|
631
619
|
});
|
632
|
-
},
|
620
|
+
}, flattenNestedTernaries = function(test, side, ternaryPartial = {}) {
|
633
621
|
if (!side)
|
634
622
|
return null;
|
635
623
|
if (!isStaticObject(side))
|
@@ -637,28 +625,6 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
637
625
|
return side.properties.flatMap((property) => {
|
638
626
|
if (!t.isObjectProperty(property))
|
639
627
|
throw new Error("expected object property");
|
640
|
-
if (t.isIdentifier(property.key)) {
|
641
|
-
const key = property.key.name, mediaQueryKey = key.slice(1);
|
642
|
-
if (key[0] === "$" && mediaQueryConfig[mediaQueryKey])
|
643
|
-
if (t.isExpression(property.value)) {
|
644
|
-
const ternaries2 = createTernariesFromObjectProperties(
|
645
|
-
t.stringLiteral(mediaQueryKey),
|
646
|
-
property.value,
|
647
|
-
{
|
648
|
-
inlineMediaQuery: mediaQueryKey
|
649
|
-
}
|
650
|
-
);
|
651
|
-
if (ternaries2)
|
652
|
-
return ternaries2.map((value) => ({
|
653
|
-
...ternaryPartial,
|
654
|
-
...value,
|
655
|
-
// ensure media query test stays on left side (see getMediaQueryTernary)
|
656
|
-
test: t.logicalExpression("&&", value.test, test)
|
657
|
-
}));
|
658
|
-
logger.info(["\u26A0\uFE0F no ternaries?", property].join(" "));
|
659
|
-
} else
|
660
|
-
logger.info(["\u26A0\uFE0F not expression", property].join(" "));
|
661
|
-
}
|
662
628
|
if (t.isConditionalExpression(property.value)) {
|
663
629
|
const [truthy, falsy] = [
|
664
630
|
t.objectExpression([
|
@@ -728,7 +694,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
728
694
|
const val = attr.value;
|
729
695
|
t.isStringLiteral(val) && (tagName = val.value);
|
730
696
|
}), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
|
731
|
-
const
|
697
|
+
const flatNodeName = getFlattenedNode?.({ isTextView, tag: tagName }), inlineProps = /* @__PURE__ */ new Set([
|
732
698
|
// adding some always inline props
|
733
699
|
"dataSet",
|
734
700
|
...restProps.inlineProps || [],
|
@@ -823,46 +789,53 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
823
789
|
(INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
|
824
790
|
}
|
825
791
|
const canFlattenProps = inlined.size === 0;
|
826
|
-
let shouldFlatten = !!(
|
792
|
+
let shouldFlatten = !!(flatNodeName && !shouldDeopt && canFlattenProps && !hasSpread && !staticConfig.isStyledHOC && !staticConfig.isHOC && !staticConfig.isReactNative && staticConfig.neverFlatten !== !0 && (staticConfig.neverFlatten !== "jsx" || hasOnlyStringChildren));
|
827
793
|
const usedThemeKeys = /* @__PURE__ */ new Set();
|
828
794
|
if (themeAccessListeners.add((key) => {
|
829
795
|
disableExtractVariables && (usedThemeKeys.add(key), shouldFlatten = !1, shouldPrintDebug === "verbose" && logger.info([" ! accessing theme key, avoid flatten", key].join(" ")));
|
830
|
-
}), shouldFlatten) {
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
796
|
+
}), !shouldFlatten) {
|
797
|
+
shouldPrintDebug && logger.info(
|
798
|
+
`Deopting ${JSON.stringify({
|
799
|
+
shouldFlatten,
|
800
|
+
shouldDeopt,
|
801
|
+
canFlattenProps,
|
802
|
+
hasSpread,
|
803
|
+
neverFlatten: staticConfig.neverFlatten
|
804
|
+
})}`
|
805
|
+
), node.attributes = ogAttributes;
|
806
|
+
return;
|
807
|
+
}
|
808
|
+
let skipMap = !1;
|
809
|
+
const defaultStyleAttrs = Object.keys(defaultProps).flatMap((key) => {
|
810
|
+
if (skipMap) return [];
|
811
|
+
const value = defaultProps[key];
|
812
|
+
if (key === "theme" && !themeVal)
|
813
|
+
return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", { value: t.stringLiteral(value) })), themeVal = { value: t.stringLiteral(value) }, [];
|
814
|
+
if (!isValidStyleKey(key, staticConfig))
|
815
|
+
return [];
|
816
|
+
const name = tamaguiConfig?.shorthands[key] || key;
|
817
|
+
if (value === void 0) {
|
818
|
+
logger.warn(
|
819
|
+
`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`
|
820
|
+
), shouldDeopt = !0;
|
821
|
+
return;
|
822
|
+
}
|
823
|
+
return name[0] === "$" && mediaQueryConfig[name.slice(1)] ? (defaultProps[key] = void 0, evaluateAttribute({
|
824
|
+
node: t.jsxAttribute(
|
825
|
+
t.jsxIdentifier(name),
|
826
|
+
t.jsxExpressionContainer(
|
827
|
+
t.objectExpression(
|
828
|
+
Object.keys(value).filter((k) => typeof value[k] < "u").map((k) => t.objectProperty(t.identifier(k), (0, import_literalToAst.literalToAst)(value[k])))
|
856
829
|
)
|
857
830
|
)
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
}
|
863
|
-
}
|
864
|
-
|
865
|
-
|
831
|
+
)
|
832
|
+
})) : {
|
833
|
+
type: "style",
|
834
|
+
name,
|
835
|
+
value: { [name]: value }
|
836
|
+
};
|
837
|
+
});
|
838
|
+
skipMap || defaultStyleAttrs.length && (attrs = [...defaultStyleAttrs, ...attrs]);
|
866
839
|
let ternaries = [];
|
867
840
|
attrs = attrs.reduce((out, cur) => {
|
868
841
|
const next = attrs[attrs.indexOf(cur) + 1];
|
@@ -886,9 +859,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
886
859
|
}
|
887
860
|
}
|
888
861
|
return cur.type === "ternary" || out.push(cur), out;
|
889
|
-
}, []).flat()
|
890
|
-
const shouldWrapTheme = shouldFlatten && themeVal;
|
891
|
-
if (shouldWrapTheme && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(
|
862
|
+
}, []).flat(), themeVal && (programPath ? (shouldPrintDebug && logger.info([" - wrapping theme", themeVal].join(" ")), attrs = attrs.filter(
|
892
863
|
(x) => !(x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme")
|
893
864
|
), hasImportedTheme || (hasImportedTheme = !0, programPath.node.body.push(
|
894
865
|
t.importDeclaration(
|
@@ -910,31 +881,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
910
881
|
)
|
911
882
|
)) : console.warn(
|
912
883
|
`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`
|
913
|
-
)), shouldPrintDebug
|
914
|
-
try {
|
915
|
-
logger.info(
|
916
|
-
[
|
917
|
-
" flatten?",
|
918
|
-
shouldFlatten,
|
919
|
-
(0, import_extractHelpers.objToStr)({
|
920
|
-
hasSpread,
|
921
|
-
shouldDeopt,
|
922
|
-
canFlattenProps,
|
923
|
-
shouldWrapTheme,
|
924
|
-
hasOnlyStringChildren
|
925
|
-
}),
|
926
|
-
"inlined",
|
927
|
-
inlined.size,
|
928
|
-
[...inlined]
|
929
|
-
].join(" ")
|
930
|
-
);
|
931
|
-
} catch {
|
932
|
-
}
|
933
|
-
if (shouldDeopt || !shouldFlatten) {
|
934
|
-
shouldPrintDebug && logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`), node.attributes = ogAttributes;
|
935
|
-
return;
|
936
|
-
}
|
937
|
-
shouldPrintDebug && logger.info(
|
884
|
+
)), shouldPrintDebug && logger.info(
|
938
885
|
[` - attrs (flattened):
|
939
886
|
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(
|
940
887
|
" "
|
@@ -1077,7 +1024,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1077
1024
|
process.env.IS_STATIC = before;
|
1078
1025
|
}
|
1079
1026
|
};
|
1080
|
-
|
1027
|
+
attrs.unshift({
|
1081
1028
|
type: "style",
|
1082
1029
|
value: defaultProps
|
1083
1030
|
}), attrs = attrs.reduce((acc, cur) => {
|
@@ -1169,7 +1116,6 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1169
1116
|
if (attr.type === "style")
|
1170
1117
|
for (const key in attr.value)
|
1171
1118
|
existingStyleKeys.has(key) ? (shouldPrintDebug && logger.info([` >> delete existing ${key}`].join(" ")), delete attr.value[key]) : existingStyleKeys.add(key);
|
1172
|
-
attr.type === "dynamic-style" && (existingStyleKeys.has(attr.name) ? attrs[i] = void 0 : existingStyleKeys.add(attr.name));
|
1173
1119
|
}
|
1174
1120
|
if (options.experimentalFlattenThemesOnNative && (attrs = attrs.filter(Boolean)), !shouldFlatten && inlineWhenUnflattened.size) {
|
1175
1121
|
for (const [index, attr] of attrs.entries())
|
@@ -1180,11 +1126,11 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1180
1126
|
val ? (delete attr.value[key], attrs.splice(index - 1, 0, val.attr)) : delete attr.value[key];
|
1181
1127
|
}
|
1182
1128
|
}
|
1183
|
-
if (attrs = attrs.filter((x) => !(
|
1129
|
+
if (attrs = attrs.filter((x) => !(x.type === "style" && Object.keys(x.value).length === 0)), !shouldFlatten && platform2 === "native")
|
1184
1130
|
return shouldPrintDebug && logger.info(
|
1185
1131
|
`Disabled flattening except for simple cases on native for now: ${JSON.stringify(
|
1186
1132
|
{
|
1187
|
-
flatNode,
|
1133
|
+
flatNode: flatNodeName,
|
1188
1134
|
shouldDeopt,
|
1189
1135
|
canFlattenProps,
|
1190
1136
|
hasSpread,
|
@@ -1204,7 +1150,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1204
1150
|
hasSpread ? " has spread" : "",
|
1205
1151
|
staticConfig.neverFlatten ? "neverFlatten" : ""
|
1206
1152
|
].join(" ")
|
1207
|
-
), logger.info(` -
|
1153
|
+
), logger.info(` - attrs (end):
|
1208
1154
|
${(0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))}`)), onExtractTag({
|
1209
1155
|
parserProps: propsWithFileInfo,
|
1210
1156
|
attrs,
|
@@ -1212,18 +1158,18 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1212
1158
|
lineNumbers,
|
1213
1159
|
filePath,
|
1214
1160
|
config: tamaguiConfig,
|
1161
|
+
flatNodeName,
|
1215
1162
|
attemptEval,
|
1216
1163
|
jsxPath: traversePath,
|
1217
1164
|
originalNodeName,
|
1218
|
-
isFlattened: shouldFlatten,
|
1219
1165
|
programPath,
|
1220
1166
|
completeProps,
|
1221
1167
|
staticConfig
|
1222
|
-
});
|
1168
|
+
}), shouldFlatten && (shouldPrintDebug && logger.info([" [\u2705] flattened", originalNodeName, flatNodeName].join(" ")), node.name.name = flatNodeName, res.flattened++, closingElement && (closingElement.name.name = flatNodeName));
|
1223
1169
|
} catch (err) {
|
1224
|
-
node.attributes = ogAttributes, console.error(
|
1170
|
+
node.attributes = ogAttributes, err instanceof import_errors.BailOptimizationError || (console.error(
|
1225
1171
|
`@tamagui/static error, reverting optimization. In ${filePath} ${lineNumbers} on ${originalNodeName}: ${err.message}. For stack trace set environment TAMAGUI_DEBUG=1`
|
1226
|
-
), process.env.TAMAGUI_DEBUG === "1" && console.error(err.stack);
|
1172
|
+
), process.env.TAMAGUI_DEBUG === "1" && console.error(err.stack));
|
1227
1173
|
} finally {
|
1228
1174
|
debugPropValue && (shouldPrintDebug = ogDebug);
|
1229
1175
|
}
|