@tamagui/static 1.0.0-beta.153 → 1.0.0-beta.181
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/cjs/constants.js +8 -0
- package/dist/cjs/extractor/accessSafe.js +4 -0
- package/dist/cjs/extractor/babelParse.js +5 -0
- package/dist/cjs/extractor/babelParse.js.map +2 -2
- package/dist/cjs/extractor/buildClassName.js +4 -0
- package/dist/cjs/extractor/createEvaluator.js +5 -0
- package/dist/cjs/extractor/createExtractor.js +120 -72
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/ensureImportingConcat.js +4 -0
- package/dist/cjs/extractor/evaluateAstNode.js +4 -0
- package/dist/cjs/extractor/extractHelpers.js +11 -0
- package/dist/cjs/extractor/extractMediaStyle.js +5 -0
- package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +12 -4
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/findTopmostFunction.js +4 -0
- package/dist/cjs/extractor/generatedUid.js +4 -0
- package/dist/cjs/extractor/getPrefixLogs.js +4 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js +4 -0
- package/dist/cjs/extractor/getSourceModule.js +4 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js +4 -0
- package/dist/cjs/extractor/hoistClassNames.js +4 -0
- package/dist/cjs/extractor/literalToAst.js +5 -0
- package/dist/cjs/extractor/loadTamagui.js +67 -47
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/cjs/extractor/logLines.js +4 -0
- package/dist/cjs/extractor/normalizeTernaries.js +4 -0
- package/dist/cjs/extractor/removeUnusedHooks.js +4 -0
- package/dist/cjs/extractor/timer.js +46 -0
- package/dist/cjs/extractor/timer.js.map +7 -0
- package/dist/cjs/extractor/validHTMLAttributes.js +4 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/patchReactNativeWeb.js +23 -7
- package/dist/cjs/patchReactNativeWeb.js.map +2 -2
- package/dist/esm/extractor/babelParse.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +123 -79
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +8 -4
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/loadTamagui.js +63 -47
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/timer.js +24 -0
- package/dist/esm/extractor/timer.js.map +7 -0
- package/dist/esm/patchReactNativeWeb.js +19 -7
- package/dist/esm/patchReactNativeWeb.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +123 -79
- package/dist/jsx/extractor/extractToClassNames.js +8 -4
- package/dist/jsx/extractor/loadTamagui.js +63 -47
- package/dist/jsx/extractor/timer.js +23 -0
- package/dist/jsx/patchReactNativeWeb.js +19 -7
- package/package.json +9 -9
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/timer.d.ts +5 -0
- package/types/extractor/timer.d.ts.map +1 -0
- package/types/patchReactNativeWeb.d.ts.map +1 -1
package/dist/cjs/constants.js
CHANGED
|
@@ -33,4 +33,12 @@ const MEDIA_SEP = "_";
|
|
|
33
33
|
const cacheDir = (0, import_find_cache_dir.default)({ name: "tamagui", create: true });
|
|
34
34
|
const FAILED_EVAL = Symbol("failed_style_eval");
|
|
35
35
|
const CONCAT_CLASSNAME_IMPORT = "concatClassName";
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
CONCAT_CLASSNAME_IMPORT,
|
|
39
|
+
CSS_FILE_NAME,
|
|
40
|
+
FAILED_EVAL,
|
|
41
|
+
MEDIA_SEP,
|
|
42
|
+
cacheDir
|
|
43
|
+
});
|
|
36
44
|
//# sourceMappingURL=constants.js.map
|
|
@@ -29,4 +29,8 @@ function accessSafe(obj, member) {
|
|
|
29
29
|
return t.logicalExpression("&&", t.logicalExpression("&&", t.binaryExpression("===", t.unaryExpression("typeof", obj), t.stringLiteral("object")), t.binaryExpression("!==", obj, t.nullLiteral())), t.memberExpression(obj, t.identifier(member), false));
|
|
30
30
|
}
|
|
31
31
|
__name(accessSafe, "accessSafe");
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
accessSafe
|
|
35
|
+
});
|
|
32
36
|
//# sourceMappingURL=accessSafe.js.map
|
|
@@ -48,4 +48,9 @@ function babelParse(code) {
|
|
|
48
48
|
return parser(code.toString(), parserOptions);
|
|
49
49
|
}
|
|
50
50
|
__name(babelParse, "babelParse");
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
babelParse,
|
|
54
|
+
parserOptions
|
|
55
|
+
});
|
|
51
56
|
//# sourceMappingURL=babelParse.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/babelParse.ts"],
|
|
4
|
-
"sourcesContent": ["import * as babelParser from '@babel/parser'\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins: [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as babelParser from '@babel/parser'\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins: [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n ],\n sourceType: 'module',\n})\n\nconst parser = babelParser.parse.bind(babelParser)\n\nexport function babelParse(code: string | Buffer): any {\n return parser(code.toString(), parserOptions)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AACd,CAAC;AAED,MAAM,SAAS,YAAY,MAAM,KAAK,WAAW;AAE1C,oBAAoB,MAA4B;AACrD,SAAO,OAAO,KAAK,SAAS,GAAG,aAAa;AAC9C;AAFgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -58,4 +58,8 @@ function buildClassName(classNameObjects) {
|
|
|
58
58
|
}, null);
|
|
59
59
|
}
|
|
60
60
|
__name(buildClassName, "buildClassName");
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
buildClassName
|
|
64
|
+
});
|
|
61
65
|
//# sourceMappingURL=buildClassName.js.map
|
|
@@ -70,4 +70,9 @@ function createSafeEvaluator(attemptEval) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
__name(createSafeEvaluator, "createSafeEvaluator");
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
createEvaluator,
|
|
76
|
+
createSafeEvaluator
|
|
77
|
+
});
|
|
73
78
|
//# sourceMappingURL=createEvaluator.js.map
|
|
@@ -68,6 +68,7 @@ var import_loadTamagui = require("./loadTamagui");
|
|
|
68
68
|
var import_logLines = require("./logLines");
|
|
69
69
|
var import_normalizeTernaries = require("./normalizeTernaries");
|
|
70
70
|
var import_removeUnusedHooks = require("./removeUnusedHooks");
|
|
71
|
+
var import_timer = require("./timer");
|
|
71
72
|
var import_validHTMLAttributes = require("./validHTMLAttributes");
|
|
72
73
|
const UNTOUCHED_PROPS = {
|
|
73
74
|
key: true,
|
|
@@ -95,10 +96,6 @@ function createExtractor() {
|
|
|
95
96
|
process.exit(1);
|
|
96
97
|
}
|
|
97
98
|
const shouldAddDebugProp = !process.env.npm_package_dependencies_next && process.env.TAMAGUI_TARGET !== "native" && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS);
|
|
98
|
-
require("esbuild-register/dist/node").register({
|
|
99
|
-
target: "es2019",
|
|
100
|
-
format: "cjs"
|
|
101
|
-
});
|
|
102
99
|
let loadedTamaguiConfig;
|
|
103
100
|
let hasLogged = false;
|
|
104
101
|
return {
|
|
@@ -146,10 +143,15 @@ function createExtractor() {
|
|
|
146
143
|
if (!Array.isArray(props.components)) {
|
|
147
144
|
throw new Error(`Must provide components array with list of Tamagui component modules`);
|
|
148
145
|
}
|
|
146
|
+
const tm = (0, import_timer.timer)();
|
|
149
147
|
const { components, tamaguiConfig } = (0, import_loadTamagui.loadTamagui)({
|
|
150
148
|
config,
|
|
151
149
|
components: props.components || ["tamagui"]
|
|
152
150
|
});
|
|
151
|
+
if (shouldPrintDebug === "verbose") {
|
|
152
|
+
console.log("tamagui.config.ts:", { components, config });
|
|
153
|
+
}
|
|
154
|
+
tm.mark("load-tamagui", shouldPrintDebug === "verbose");
|
|
153
155
|
loadedTamaguiConfig = tamaguiConfig;
|
|
154
156
|
const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]];
|
|
155
157
|
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
|
@@ -163,6 +165,9 @@ function createExtractor() {
|
|
|
163
165
|
obj[name] = components[name];
|
|
164
166
|
return obj;
|
|
165
167
|
}, {});
|
|
168
|
+
if (shouldPrintDebug === "verbose") {
|
|
169
|
+
console.log("validComponents", Object.keys(validComponents));
|
|
170
|
+
}
|
|
166
171
|
let doesUseValidImport = false;
|
|
167
172
|
let hasImportedTheme = false;
|
|
168
173
|
for (const bodyPath of body) {
|
|
@@ -170,11 +175,16 @@ function createExtractor() {
|
|
|
170
175
|
continue;
|
|
171
176
|
const node = "node" in bodyPath ? bodyPath.node : bodyPath;
|
|
172
177
|
const from = node.source.value;
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
const isValidImport = props.components.includes(from) || isInternalImport(from);
|
|
179
|
+
if (isValidImport) {
|
|
180
|
+
const isValidComponent = node.specifiers.some((specifier) => {
|
|
175
181
|
const name = specifier.local.name;
|
|
176
182
|
return validComponents[name] || validHooks[name];
|
|
177
|
-
})
|
|
183
|
+
});
|
|
184
|
+
if (shouldPrintDebug === "verbose") {
|
|
185
|
+
console.log("import from", from, { isValidComponent });
|
|
186
|
+
}
|
|
187
|
+
if (isValidComponent) {
|
|
178
188
|
doesUseValidImport = true;
|
|
179
189
|
break;
|
|
180
190
|
}
|
|
@@ -186,6 +196,7 @@ function createExtractor() {
|
|
|
186
196
|
if (!doesUseValidImport) {
|
|
187
197
|
return null;
|
|
188
198
|
}
|
|
199
|
+
tm.mark("import-check", shouldPrintDebug === "verbose");
|
|
189
200
|
let couldntParse = false;
|
|
190
201
|
const modifiedComponents = /* @__PURE__ */ new Set();
|
|
191
202
|
const bindingCache = {};
|
|
@@ -207,6 +218,7 @@ function createExtractor() {
|
|
|
207
218
|
},
|
|
208
219
|
JSXElement(traversePath) {
|
|
209
220
|
var _a2, _b2, _c;
|
|
221
|
+
tm.mark("jsx-element", shouldPrintDebug === "verbose");
|
|
210
222
|
const node = traversePath.node.openingElement;
|
|
211
223
|
const ogAttributes = node.attributes;
|
|
212
224
|
const componentName = (0, import_extractHelpers.findComponentName)(traversePath.scope);
|
|
@@ -631,6 +643,11 @@ function createExtractor() {
|
|
|
631
643
|
for (const key in next) {
|
|
632
644
|
if (import_core_node.pseudos[key]) {
|
|
633
645
|
prev2[key] = prev2[key] || {};
|
|
646
|
+
if (shouldPrintDebug) {
|
|
647
|
+
if (!next[key] || !prev2[key]) {
|
|
648
|
+
console.log("warn: missing", key, prev2, next);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
634
651
|
Object.assign(prev2[key], next[key]);
|
|
635
652
|
} else {
|
|
636
653
|
prev2[key] = next[key];
|
|
@@ -740,6 +757,7 @@ function createExtractor() {
|
|
|
740
757
|
if (couldntParse) {
|
|
741
758
|
return;
|
|
742
759
|
}
|
|
760
|
+
tm.mark("jsx-element-flattened", shouldPrintDebug === "verbose");
|
|
743
761
|
node.attributes = flattenedAttrs;
|
|
744
762
|
if (staticConfig.defaultProps) {
|
|
745
763
|
for (const key in staticConfig.defaultProps) {
|
|
@@ -765,6 +783,7 @@ function createExtractor() {
|
|
|
765
783
|
attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
|
766
784
|
try {
|
|
767
785
|
const res2 = evaluateAttribute(path);
|
|
786
|
+
tm.mark("jsx-element-evaluate-attr", shouldPrintDebug === "verbose");
|
|
768
787
|
if (!res2) {
|
|
769
788
|
path.remove();
|
|
770
789
|
}
|
|
@@ -827,43 +846,25 @@ function createExtractor() {
|
|
|
827
846
|
out.push(cur);
|
|
828
847
|
return out;
|
|
829
848
|
}, []).flat();
|
|
830
|
-
const completeStaticProps = __spreadValues({}, Object.keys(attrs).reduce((acc, index) => {
|
|
831
|
-
const cur = attrs[index];
|
|
832
|
-
if (cur.type === "style") {
|
|
833
|
-
Object.assign(acc, cur.value);
|
|
834
|
-
}
|
|
835
|
-
if (cur.type === "attr") {
|
|
836
|
-
if (t.isJSXSpreadAttribute(cur.value)) {
|
|
837
|
-
return acc;
|
|
838
|
-
}
|
|
839
|
-
if (!t.isJSXIdentifier(cur.value.name)) {
|
|
840
|
-
return acc;
|
|
841
|
-
}
|
|
842
|
-
const key = cur.value.name.name;
|
|
843
|
-
const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
|
|
844
|
-
if (value === import_constants.FAILED_EVAL) {
|
|
845
|
-
return acc;
|
|
846
|
-
}
|
|
847
|
-
acc[key] = value;
|
|
848
|
-
}
|
|
849
|
-
return acc;
|
|
850
|
-
}, {}));
|
|
851
849
|
const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x));
|
|
852
850
|
const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
|
|
853
851
|
const themeVal = inlined.get("theme");
|
|
854
852
|
inlined.delete("theme");
|
|
855
853
|
const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
|
|
856
|
-
const
|
|
857
|
-
const canFlattenProps = inlined.size === 0 ||
|
|
854
|
+
const shouldWrapThme = allOtherPropsExtractable && !!themeVal;
|
|
855
|
+
const canFlattenProps = inlined.size === 0 || shouldWrapThme || allOtherPropsExtractable;
|
|
858
856
|
let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
|
|
859
|
-
if (
|
|
857
|
+
if (shouldPrintDebug) {
|
|
858
|
+
console.log(" >>", { hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapThme, allOtherPropsExtractable, hasOnlyStringChildren });
|
|
859
|
+
}
|
|
860
|
+
if (shouldFlatten && shouldWrapThme) {
|
|
860
861
|
if (typeof themeVal !== "string") {
|
|
861
|
-
console.warn("??");
|
|
862
862
|
return;
|
|
863
863
|
}
|
|
864
864
|
if (shouldPrintDebug) {
|
|
865
865
|
console.log(" - wrapping theme", allOtherPropsExtractable, themeVal);
|
|
866
866
|
}
|
|
867
|
+
attrs = attrs.filter((x) => x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme" ? false : true);
|
|
867
868
|
if (!hasImportedTheme) {
|
|
868
869
|
hasImportedTheme = true;
|
|
869
870
|
programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/core")));
|
|
@@ -875,23 +876,21 @@ function createExtractor() {
|
|
|
875
876
|
if (shouldFlatten && staticConfig.defaultProps) {
|
|
876
877
|
const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
|
|
877
878
|
if (!isValidStyleKey(key)) {
|
|
878
|
-
return;
|
|
879
|
+
return [];
|
|
879
880
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
const name = tamaguiConfig.shorthands[key] || key;
|
|
885
|
-
return {
|
|
886
|
-
type: "style",
|
|
887
|
-
name,
|
|
888
|
-
value
|
|
889
|
-
};
|
|
890
|
-
} catch (err) {
|
|
891
|
-
console.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key}
|
|
892
|
-
error: ${err}`);
|
|
881
|
+
const value = staticConfig.defaultProps[key];
|
|
882
|
+
const name = tamaguiConfig.shorthands[key] || key;
|
|
883
|
+
if (value === void 0) {
|
|
884
|
+
console.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`);
|
|
893
885
|
shouldDeopt = true;
|
|
886
|
+
return;
|
|
894
887
|
}
|
|
888
|
+
const attr = {
|
|
889
|
+
type: "style",
|
|
890
|
+
name,
|
|
891
|
+
value: { [name]: value }
|
|
892
|
+
};
|
|
893
|
+
return attr;
|
|
895
894
|
});
|
|
896
895
|
if (defaultStyleAttrs.length) {
|
|
897
896
|
attrs = [...defaultStyleAttrs, ...attrs];
|
|
@@ -959,6 +958,7 @@ function createExtractor() {
|
|
|
959
958
|
acc.push(cur);
|
|
960
959
|
return acc;
|
|
961
960
|
}, []);
|
|
961
|
+
tm.mark("jsx-element-expanded", shouldPrintDebug === "verbose");
|
|
962
962
|
if (shouldPrintDebug) {
|
|
963
963
|
console.log(" - attrs (expanded): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
964
964
|
}
|
|
@@ -995,48 +995,84 @@ function createExtractor() {
|
|
|
995
995
|
acc.push(cur);
|
|
996
996
|
return acc;
|
|
997
997
|
}, []);
|
|
998
|
+
const state = {
|
|
999
|
+
noClassNames: true,
|
|
1000
|
+
focus: false,
|
|
1001
|
+
hover: false,
|
|
1002
|
+
mounted: true,
|
|
1003
|
+
press: false,
|
|
1004
|
+
pressIn: false
|
|
1005
|
+
};
|
|
1006
|
+
const completeStaticProps = Object.keys(attrs).reduce((acc, index) => {
|
|
1007
|
+
const cur = attrs[index];
|
|
1008
|
+
if (cur.type === "style") {
|
|
1009
|
+
(0, import_core_node.normalizeStyleObject)(cur.value);
|
|
1010
|
+
Object.assign(acc, cur.value);
|
|
1011
|
+
}
|
|
1012
|
+
if (cur.type === "attr") {
|
|
1013
|
+
if (t.isJSXSpreadAttribute(cur.value)) {
|
|
1014
|
+
return acc;
|
|
1015
|
+
}
|
|
1016
|
+
if (!t.isJSXIdentifier(cur.value.name)) {
|
|
1017
|
+
return acc;
|
|
1018
|
+
}
|
|
1019
|
+
const key = cur.value.name.name;
|
|
1020
|
+
const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
|
|
1021
|
+
if (value === import_constants.FAILED_EVAL) {
|
|
1022
|
+
return acc;
|
|
1023
|
+
}
|
|
1024
|
+
acc[key] = value;
|
|
1025
|
+
}
|
|
1026
|
+
return acc;
|
|
1027
|
+
}, {});
|
|
1028
|
+
const completeProps = __spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps);
|
|
998
1029
|
if (shouldPrintDebug) {
|
|
999
1030
|
console.log(" - attrs (combined \u{1F500}): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
1031
|
+
console.log(" - defaultProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(staticConfig.defaultProps)));
|
|
1032
|
+
console.log(" - completeStaticProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStaticProps)));
|
|
1000
1033
|
}
|
|
1001
|
-
const completeProps = __spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps);
|
|
1002
1034
|
const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
|
|
1003
|
-
if (!props2)
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
return;
|
|
1035
|
+
if (!props2 || !Object.keys(props2).length) {
|
|
1036
|
+
if (shouldPrintDebug)
|
|
1037
|
+
console.log(" getStyles() no props");
|
|
1038
|
+
return {};
|
|
1039
|
+
}
|
|
1007
1040
|
if (excludeProps && !!excludeProps.size) {
|
|
1008
1041
|
for (const key in props2) {
|
|
1009
1042
|
if (excludeProps.has(key)) {
|
|
1043
|
+
if (shouldPrintDebug)
|
|
1044
|
+
console.log(" delete excluded", key);
|
|
1010
1045
|
delete props2[key];
|
|
1011
1046
|
}
|
|
1012
1047
|
}
|
|
1013
1048
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
mounted: true,
|
|
1020
|
-
press: false,
|
|
1021
|
-
pressIn: false
|
|
1022
|
-
});
|
|
1023
|
-
const outStyle = __spreadValues(__spreadValues({}, out.style), out.pseudos);
|
|
1024
|
-
for (const key in outStyle) {
|
|
1049
|
+
try {
|
|
1050
|
+
const out = (0, import_core_node.getSplitStyles)(props2, staticConfig, defaultTheme, __spreadProps(__spreadValues({}, state), {
|
|
1051
|
+
fallbackProps: completeProps
|
|
1052
|
+
}));
|
|
1053
|
+
const outStyle = __spreadValues(__spreadValues({}, out.style), out.pseudos);
|
|
1025
1054
|
if (staticConfig.validStyles) {
|
|
1026
|
-
|
|
1027
|
-
|
|
1055
|
+
for (const key in outStyle) {
|
|
1056
|
+
if (!staticConfig.validStyles[key] && !import_core_node.pseudos[key] && !/(hover|focus|press)Style$/.test(key)) {
|
|
1057
|
+
if (shouldPrintDebug)
|
|
1058
|
+
console.log(" delete invalid style", key);
|
|
1059
|
+
delete outStyle[key];
|
|
1060
|
+
}
|
|
1028
1061
|
}
|
|
1029
1062
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
console.log(` getStyles ${debugName} (props):
|
|
1063
|
+
if (shouldPrintDebug) {
|
|
1064
|
+
console.log(` getStyles ${debugName} (props):
|
|
1033
1065
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(props2)));
|
|
1034
|
-
|
|
1066
|
+
console.log(` getStyles ${debugName} (out.viewProps):
|
|
1035
1067
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(out.viewProps)));
|
|
1036
|
-
|
|
1068
|
+
console.log(` getStyles ${debugName} (out.style):
|
|
1037
1069
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(outStyle || {}), true));
|
|
1070
|
+
}
|
|
1071
|
+
return outStyle;
|
|
1072
|
+
} catch (err) {
|
|
1073
|
+
console.log("error", err.message, err.stack);
|
|
1074
|
+
return {};
|
|
1038
1075
|
}
|
|
1039
|
-
return outStyle;
|
|
1040
1076
|
}, "getStyles");
|
|
1041
1077
|
const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
|
|
1042
1078
|
if (!completeStylesProcessed) {
|
|
@@ -1077,11 +1113,13 @@ function createExtractor() {
|
|
|
1077
1113
|
console.log(" => tern ", (0, import_extractHelpers.attrStr)(attr));
|
|
1078
1114
|
continue;
|
|
1079
1115
|
case "style":
|
|
1116
|
+
if (shouldPrintDebug)
|
|
1117
|
+
console.log(" * styles in", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(attr.value)));
|
|
1080
1118
|
const styles = getStyles(attr.value, "style");
|
|
1119
|
+
if (shouldPrintDebug)
|
|
1120
|
+
console.log(" * styles out", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(styles)));
|
|
1081
1121
|
if (styles) {
|
|
1082
1122
|
attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
|
|
1083
|
-
} else {
|
|
1084
|
-
console.warn("?????????");
|
|
1085
1123
|
}
|
|
1086
1124
|
continue;
|
|
1087
1125
|
}
|
|
@@ -1089,6 +1127,7 @@ function createExtractor() {
|
|
|
1089
1127
|
getStyleError = err;
|
|
1090
1128
|
}
|
|
1091
1129
|
}
|
|
1130
|
+
tm.mark("jsx-element-styles", shouldPrintDebug === "verbose");
|
|
1092
1131
|
if (getStyleError) {
|
|
1093
1132
|
console.log(" \u26A0\uFE0F postprocessing error, deopt", getStyleError);
|
|
1094
1133
|
node.attributes = ogAttributes;
|
|
@@ -1112,6 +1151,9 @@ function createExtractor() {
|
|
|
1112
1151
|
if (attr.type === "style") {
|
|
1113
1152
|
for (const key in attr.value) {
|
|
1114
1153
|
if (existingStyleKeys.has(key)) {
|
|
1154
|
+
if (shouldPrintDebug) {
|
|
1155
|
+
console.log(" >> delete existing", key);
|
|
1156
|
+
}
|
|
1115
1157
|
delete attr.value[key];
|
|
1116
1158
|
} else {
|
|
1117
1159
|
existingStyleKeys.add(key);
|
|
@@ -1153,6 +1195,7 @@ function createExtractor() {
|
|
|
1153
1195
|
}
|
|
1154
1196
|
}
|
|
1155
1197
|
});
|
|
1198
|
+
tm.mark("jsx-done", shouldPrintDebug === "verbose");
|
|
1156
1199
|
if (modifiedComponents.size) {
|
|
1157
1200
|
const all = Array.from(modifiedComponents);
|
|
1158
1201
|
if (shouldPrintDebug) {
|
|
@@ -1162,9 +1205,14 @@ function createExtractor() {
|
|
|
1162
1205
|
(0, import_removeUnusedHooks.removeUnusedHooks)(comp, shouldPrintDebug);
|
|
1163
1206
|
}
|
|
1164
1207
|
}
|
|
1208
|
+
tm.done(shouldPrintDebug === "verbose");
|
|
1165
1209
|
return res;
|
|
1166
1210
|
}
|
|
1167
1211
|
};
|
|
1168
1212
|
}
|
|
1169
1213
|
__name(createExtractor, "createExtractor");
|
|
1214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1215
|
+
0 && (module.exports = {
|
|
1216
|
+
createExtractor
|
|
1217
|
+
});
|
|
1170
1218
|
//# sourceMappingURL=createExtractor.js.map
|