@tamagui/static 1.0.1-beta.28 → 1.0.1-beta.29

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.
@@ -9,7 +9,8 @@ import {
9
9
  normalizeStyleObject,
10
10
  proxyThemeVariables,
11
11
  pseudos,
12
- rnw
12
+ rnw,
13
+ stylePropsTransform
13
14
  } from "@tamagui/core-node";
14
15
  import { difference, pick } from "lodash";
15
16
  import { FAILED_EVAL } from "../constants";
@@ -330,7 +331,7 @@ function createExtractor() {
330
331
  let keys = [name];
331
332
  let out = null;
332
333
  if (staticConfig.propMapper) {
333
- out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, "auto");
334
+ out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, { resolveVariablesAs: "auto" });
334
335
  if (out) {
335
336
  out = rnw.createDOMProps(isTextView ? "span" : "div", out);
336
337
  delete out.className;
@@ -600,12 +601,23 @@ function createExtractor() {
600
601
  prev2[key] = next[key];
601
602
  }
602
603
  }
604
+ }, omitInvalidStyles = function(style) {
605
+ if (staticConfig.validStyles) {
606
+ for (const key in style) {
607
+ if (stylePropsTransform[key] || !staticConfig.validStyles[key] && !pseudos[key] && !/(hoverStyle|focusStyle|pressStyle)$/.test(key)) {
608
+ if (shouldPrintDebug)
609
+ console.log(" delete invalid style", key);
610
+ delete style[key];
611
+ }
612
+ }
613
+ }
603
614
  };
604
615
  __name(isValidStyleKey, "isValidStyleKey");
605
616
  __name(evaluateAttribute, "evaluateAttribute");
606
617
  __name(isExtractable, "isExtractable");
607
618
  __name(createTernariesFromObjectProperties, "createTernariesFromObjectProperties");
608
619
  __name(mergeStyles, "mergeStyles");
620
+ __name(omitInvalidStyles, "omitInvalidStyles");
609
621
  node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
610
622
  if (shouldPrintDebug) {
611
623
  console.log("\n");
@@ -867,9 +879,8 @@ function createExtractor() {
867
879
  console.log(" - ensureOverriden:", Object.keys(ensureOverridden).join(", "));
868
880
  }
869
881
  attrs = attrs.reduce((acc, cur) => {
870
- if (!cur) {
882
+ if (!cur)
871
883
  return acc;
872
- }
873
884
  if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value)) {
874
885
  if (shouldFlatten) {
875
886
  if (cur.value.name.name === "tag") {
@@ -977,7 +988,7 @@ function createExtractor() {
977
988
  if (shouldPrintDebug) {
978
989
  console.log(" - attrs (combined \u{1F500}): \n", logLines(attrs.map(attrStr).join(", ")));
979
990
  console.log(" - defaultProps: \n", logLines(objToStr(staticConfig.defaultProps)));
980
- console.log(" - completeStaticProps: \n", logLines(objToStr(completeStaticProps)));
991
+ console.log(" - completeProps: \n", logLines(objToStr(completeProps)));
981
992
  }
982
993
  const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
983
994
  if (!props2 || !Object.keys(props2).length) {
@@ -1003,15 +1014,7 @@ function createExtractor() {
1003
1014
  ...out.style,
1004
1015
  ...out.pseudos
1005
1016
  };
1006
- if (staticConfig.validStyles) {
1007
- for (const key in outStyle) {
1008
- if (!staticConfig.validStyles[key] && !pseudos[key] && !/(hover|focus|press)Style$/.test(key)) {
1009
- if (shouldPrintDebug)
1010
- console.log(" delete invalid style", key);
1011
- delete outStyle[key];
1012
- }
1013
- }
1014
- }
1017
+ omitInvalidStyles(outStyle);
1015
1018
  if (shouldPrintDebug) {
1016
1019
  console.log(` getStyles ${debugName} (props):
1017
1020
  `, logLines(objToStr(props2)));
@@ -1026,13 +1029,13 @@ function createExtractor() {
1026
1029
  return {};
1027
1030
  }
1028
1031
  }, "getStyles");
1029
- const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
1030
- if (!completeStylesProcessed) {
1032
+ const completeStyles = getStyles(completeProps, "completeStyles");
1033
+ if (!completeStyles) {
1031
1034
  throw new Error(`Impossible, no styles`);
1032
1035
  }
1033
- const stylesToAddToInitialGroup = shouldFlatten ? difference(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps)) : [];
1034
- if (stylesToAddToInitialGroup.length) {
1035
- const toAdd = pick(completeStylesProcessed, ...stylesToAddToInitialGroup);
1036
+ const addInitialStyleKeys = shouldFlatten ? difference(Object.keys(completeStyles), Object.keys(completeStaticProps)) : [];
1037
+ if (addInitialStyleKeys.length) {
1038
+ const toAdd = pick(completeStyles, ...addInitialStyleKeys);
1036
1039
  const firstGroup = attrs.find((x) => x.type === "style");
1037
1040
  if (shouldPrintDebug) {
1038
1041
  console.log(" toAdd", objToStr(toAdd));
@@ -1040,13 +1043,14 @@ function createExtractor() {
1040
1043
  if (!firstGroup) {
1041
1044
  attrs.unshift({ type: "style", value: toAdd });
1042
1045
  } else {
1046
+ omitInvalidStyles(firstGroup.value);
1043
1047
  Object.assign(firstGroup.value, toAdd);
1044
1048
  }
1045
1049
  }
1046
1050
  if (shouldPrintDebug) {
1047
- console.log(" -- stylesToAddToInitialGroup", stylesToAddToInitialGroup.join(", "), { shouldFlatten });
1051
+ console.log(" -- addInitialStyleKeys", addInitialStyleKeys.join(", "), { shouldFlatten });
1048
1052
  console.log(" -- completeStaticProps:\n", logLines(objToStr(completeStaticProps)));
1049
- console.log(" -- completeStylesProcessed:\n", logLines(objToStr(completeStylesProcessed)));
1053
+ console.log(" -- completeStyles:\n", logLines(objToStr(completeStyles)));
1050
1054
  }
1051
1055
  let getStyleError = null;
1052
1056
  for (const attr of attrs) {
@@ -1071,7 +1075,7 @@ function createExtractor() {
1071
1075
  if (shouldPrintDebug)
1072
1076
  console.log(" * styles out", logLines(objToStr(styles)));
1073
1077
  if (styles) {
1074
- attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
1078
+ attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStyles[k]]));
1075
1079
  }
1076
1080
  continue;
1077
1081
  }
@@ -79,10 +79,13 @@ function extractToClassNames({
79
79
  let finalClassNames = [];
80
80
  let finalAttrs = [];
81
81
  let finalStyles = [];
82
- const viewStyles = {};
82
+ let viewStyles = {};
83
83
  for (const attr of attrs) {
84
84
  if (attr.type === "style") {
85
- Object.assign(viewStyles, attr.value);
85
+ viewStyles = {
86
+ ...viewStyles,
87
+ ...attr.value
88
+ };
86
89
  }
87
90
  }
88
91
  const ensureNeededPrevStyle = /* @__PURE__ */ __name((style) => {
@@ -129,6 +132,9 @@ function extractToClassNames({
129
132
  }
130
133
  }
131
134
  for (const style of styles2) {
135
+ if (style.pseudo) {
136
+ continue;
137
+ }
132
138
  finalAttrs.push(t.jsxAttribute(t.jsxIdentifier(style.property), t.stringLiteral(style.identifier)));
133
139
  }
134
140
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "1.0.1-beta.28",
3
+ "version": "1.0.1-beta.29",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -34,11 +34,11 @@
34
34
  "@babel/parser": "^7.15.7",
35
35
  "@babel/traverse": "^7.15.4",
36
36
  "@expo/match-media": "^0.3.0",
37
- "@tamagui/build": "^1.0.1-beta.28",
38
- "@tamagui/core-node": "^1.0.1-beta.28",
39
- "@tamagui/fake-react-native": "^1.0.1-beta.28",
40
- "@tamagui/helpers": "^1.0.1-beta.28",
41
- "@tamagui/proxy-worm": "^1.0.1-beta.28",
37
+ "@tamagui/build": "^1.0.1-beta.29",
38
+ "@tamagui/core-node": "^1.0.1-beta.29",
39
+ "@tamagui/fake-react-native": "^1.0.1-beta.29",
40
+ "@tamagui/helpers": "^1.0.1-beta.29",
41
+ "@tamagui/proxy-worm": "^1.0.1-beta.29",
42
42
  "babel-literal-to-ast": "^2.1.0",
43
43
  "esbuild": "^0.14.36",
44
44
  "esbuild-register": "^3.3.2",
@@ -46,7 +46,7 @@
46
46
  "fs-extra": "^9.1.0",
47
47
  "invariant": "^2.2.4",
48
48
  "lodash": "^4.17.21",
49
- "tamagui": "^1.0.1-beta.28"
49
+ "tamagui": "^1.0.1-beta.29"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@babel/plugin-syntax-typescript": "^7.14.5",
@@ -1 +1 @@
1
- {"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAOtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;wBAqBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,kPAiBrC,mBAAmB;;;;;;EA0/C3B"}
1
+ {"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAQtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;wBAqBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,kPAiBrC,mBAAmB;;;;;;EAw/C3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"extractToClassNames.d.ts","sourceRoot":"","sources":["../../src/extractor/extractToClassNames.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAKjC,OAAO,EAAE,aAAa,EAAE,MAAM,SA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CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAA;IACX,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,OAAO,GACR,EAAE;IACD,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAA;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,iBAAiB,GAAG,IAAI,CAwY3B"}