@tamagui/static 1.0.0-beta.153 → 1.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +1 -5
  2. package/dist/cjs/constants.js +8 -0
  3. package/dist/cjs/extractor/accessSafe.js +4 -0
  4. package/dist/cjs/extractor/babelParse.js +5 -0
  5. package/dist/cjs/extractor/babelParse.js.map +2 -2
  6. package/dist/cjs/extractor/buildClassName.js +4 -0
  7. package/dist/cjs/extractor/createEvaluator.js +5 -0
  8. package/dist/cjs/extractor/createExtractor.js +150 -99
  9. package/dist/cjs/extractor/createExtractor.js.map +2 -2
  10. package/dist/cjs/extractor/ensureImportingConcat.js +4 -0
  11. package/dist/cjs/extractor/evaluateAstNode.js +4 -0
  12. package/dist/cjs/extractor/extractHelpers.js +11 -0
  13. package/dist/cjs/extractor/extractMediaStyle.js +5 -0
  14. package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
  15. package/dist/cjs/extractor/extractToClassNames.js +19 -8
  16. package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
  17. package/dist/cjs/extractor/findTopmostFunction.js +4 -0
  18. package/dist/cjs/extractor/generatedUid.js +4 -0
  19. package/dist/cjs/extractor/getPrefixLogs.js +4 -0
  20. package/dist/cjs/extractor/getPropValueFromAttributes.js +4 -0
  21. package/dist/cjs/extractor/getSourceModule.js +4 -0
  22. package/dist/cjs/extractor/getStaticBindingsForScope.js +14 -1
  23. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +2 -2
  24. package/dist/cjs/extractor/hoistClassNames.js +4 -0
  25. package/dist/cjs/extractor/literalToAst.js +5 -0
  26. package/dist/cjs/extractor/loadTamagui.js +69 -46
  27. package/dist/cjs/extractor/loadTamagui.js.map +2 -2
  28. package/dist/cjs/extractor/logLines.js +4 -0
  29. package/dist/cjs/extractor/normalizeTernaries.js +4 -0
  30. package/dist/cjs/extractor/removeUnusedHooks.js +4 -0
  31. package/dist/cjs/extractor/timer.js +46 -0
  32. package/dist/cjs/extractor/timer.js.map +7 -0
  33. package/dist/cjs/extractor/validHTMLAttributes.js +4 -0
  34. package/dist/cjs/index.js +6 -0
  35. package/dist/cjs/patchReactNativeWeb.js +23 -7
  36. package/dist/cjs/patchReactNativeWeb.js.map +2 -2
  37. package/dist/esm/extractor/babelParse.js.map +2 -2
  38. package/dist/esm/extractor/createExtractor.js +154 -106
  39. package/dist/esm/extractor/createExtractor.js.map +2 -2
  40. package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
  41. package/dist/esm/extractor/extractToClassNames.js +15 -8
  42. package/dist/esm/extractor/extractToClassNames.js.map +2 -2
  43. package/dist/esm/extractor/getStaticBindingsForScope.js +10 -1
  44. package/dist/esm/extractor/getStaticBindingsForScope.js.map +2 -2
  45. package/dist/esm/extractor/loadTamagui.js +65 -46
  46. package/dist/esm/extractor/loadTamagui.js.map +2 -2
  47. package/dist/esm/extractor/timer.js +24 -0
  48. package/dist/esm/extractor/timer.js.map +7 -0
  49. package/dist/esm/patchReactNativeWeb.js +19 -7
  50. package/dist/esm/patchReactNativeWeb.js.map +2 -2
  51. package/dist/jsx/extractor/createExtractor.js +154 -106
  52. package/dist/jsx/extractor/extractToClassNames.js +15 -8
  53. package/dist/jsx/extractor/getStaticBindingsForScope.js +10 -1
  54. package/dist/jsx/extractor/loadTamagui.js +65 -46
  55. package/dist/jsx/extractor/timer.js +23 -0
  56. package/dist/jsx/patchReactNativeWeb.js +19 -7
  57. package/package.json +12 -12
  58. package/types/extractor/babelParse.d.ts.map +1 -1
  59. package/types/extractor/createExtractor.d.ts +2 -0
  60. package/types/extractor/createExtractor.d.ts.map +1 -1
  61. package/types/extractor/extractMediaStyle.d.ts +1 -1
  62. package/types/extractor/extractMediaStyle.d.ts.map +1 -1
  63. package/types/extractor/extractToClassNames.d.ts +2 -1
  64. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  65. package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -1
  66. package/types/extractor/loadTamagui.d.ts.map +1 -1
  67. package/types/extractor/timer.d.ts +5 -0
  68. package/types/extractor/timer.d.ts.map +1 -0
  69. package/types/patchReactNativeWeb.d.ts.map +1 -1
  70. package/LICENSE +0 -21
@@ -39,6 +39,8 @@ function patchReactNativeWeb() {
39
39
  }
40
40
  const patches = [
41
41
  {
42
+ id: "dom-props",
43
+ filePath: ["modules", "createDOMProps", "index.js"],
42
44
  replacee: ` if (dataSet != null) {`,
43
45
  replacer: `
44
46
  if (props.dataSet && props.dataSet.className) {
@@ -46,15 +48,25 @@ function patchReactNativeWeb() {
46
48
  classList = className
47
49
  dataSet = dataSetRest
48
50
  }
51
+ if (props.dataSet && props.dataSet.id) {
52
+ domProps['id'] = props.dataSet.id
53
+ }
49
54
  if (dataSet != null) {`
55
+ },
56
+ {
57
+ id: "forward-props",
58
+ filePath: ["modules", "forwardedProps", "index.js"],
59
+ replacee: `dataSet: true,`,
60
+ replacer: `id: true, dataSet: true,`
50
61
  }
51
62
  ];
52
- const dataSetPath = ["modules", "createDOMProps", "index.js"];
53
- const dataSetModulePath = import_path.default.join(rootDir, "dist", ...dataSetPath);
54
- const dataSetCjsPath = import_path.default.join(rootDir, "dist", "cjs", ...dataSetPath);
55
- for (const file of [dataSetModulePath, dataSetCjsPath]) {
56
- const contents = fs.readFileSync(file, "utf-8");
57
- for (const { replacee, replacer } of patches) {
63
+ for (const { filePath, replacee, replacer } of patches) {
64
+ const files = [
65
+ import_path.default.join(rootDir, "dist", ...filePath),
66
+ import_path.default.join(rootDir, "dist", "cjs", ...filePath)
67
+ ];
68
+ for (const file of files) {
69
+ const contents = fs.readFileSync(file, "utf-8");
58
70
  if (contents.includes(replacer)) {
59
71
  continue;
60
72
  }
@@ -66,7 +78,7 @@ function patchReactNativeWeb() {
66
78
  continue;
67
79
  }
68
80
  console.log(" | patch " + import_path.default.relative(rootDir, file));
69
- fs.writeFileSync(file, contents.replaceAll(replacee, replacer));
81
+ fs.writeFileSync(file, contents.replace(replacee, replacer));
70
82
  }
71
83
  }
72
84
  const moduleEntry = import_path.default.join(rootDir, "dist", "index.js");
@@ -148,4 +160,8 @@ exports.useResponderEvents = require('./modules/useResponderEvents')
148
160
  const fwdProps = require('./modules/forwardedProps')
149
161
  exports.forwardedProps = ${forwardedPropsObj}
150
162
  `;
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ patchReactNativeWeb
166
+ });
151
167
  //# sourceMappingURL=patchReactNativeWeb.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/patchReactNativeWeb.ts"],
4
- "sourcesContent": ["import path from 'path'\n\nimport * as fs from 'fs-extra'\n\n// were patching react-native-web so we can use some internal methods\n// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm\n// so we can't just require it all directly\n// would be nice in the future to be able to eject from react-native-web entirely optionally\n\n// keep it sync\nexport function patchReactNativeWeb() {\n const rootDir = require.resolve('react-native-web').replace(/\\/dist.*/, '')\n const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')\n const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')\n const shouldPatchExports =\n fs.existsSync(modulePath) &&\n fs.readFileSync(modulePath, 'utf-8') === moduleExports &&\n fs.existsSync(cjsPath) &&\n fs.readFileSync(cjsPath, 'utf-8') === cjsExports\n if (!shouldPatchExports) {\n console.log(' | patch ' + path.relative(rootDir, modulePath))\n console.log(' | patch ' + path.relative(rootDir, cjsPath))\n fs.writeFileSync(modulePath, moduleExports)\n fs.writeFileSync(cjsPath, cjsExports)\n }\n\n // patch to allow className prop\n const patches = [\n {\n replacee: ` if (dataSet != null) {`,\n replacer: `\n if (props.dataSet && props.dataSet.className) {\n const { className, ...dataSetRest } = props.dataSet\n classList = className\n dataSet = dataSetRest\n }\n if (dataSet != null) {`,\n },\n ]\n\n const dataSetPath = ['modules', 'createDOMProps', 'index.js']\n const dataSetModulePath = path.join(rootDir, 'dist', ...dataSetPath)\n const dataSetCjsPath = path.join(rootDir, 'dist', 'cjs', ...dataSetPath)\n\n for (const file of [dataSetModulePath, dataSetCjsPath]) {\n const contents = fs.readFileSync(file, 'utf-8')\n for (const { replacee, replacer } of patches) {\n if (contents.includes(replacer)) {\n continue\n }\n if (!contents.includes(replacee)) {\n console.warn(\n `\u26A0\uFE0F Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`,\n {\n replacee,\n contents,\n }\n )\n continue\n }\n console.log(' | patch ' + path.relative(rootDir, file))\n fs.writeFileSync(file, contents.replaceAll(replacee, replacer))\n }\n }\n // if entry files not patched, patch them:\n const moduleEntry = path.join(rootDir, 'dist', 'index.js')\n const moduleEntrySrc = fs.readFileSync(moduleEntry, 'utf-8')\n if (!moduleEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n moduleEntry,\n `${removePatch(moduleEntrySrc)}\n\n// tamagui-patch-v4\nimport * as TExports from './tamagui-exports'\nexport const TamaguiExports = TExports\n// tamagui-patch-end\n`\n )\n }\n const cjsEntry = path.join(rootDir, 'dist', 'cjs', 'index.js')\n const cjsEntrySrc = fs.readFileSync(cjsEntry, 'utf-8')\n if (!cjsEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n cjsEntry,\n `${removePatch(cjsEntrySrc)}\n\n// tamagui-patch-v4\nexports.TamaguiExports = _interopRequireDefault(require(\"./tamagui-exports\"));\n// tamagui-patch-end\n`\n )\n }\n}\n\nfunction removePatch(source: string) {\n return source.replace(/\\/\\/ tamagui-patch([.\\s\\S]*)/g, '')\n}\n\n// view exports/View.ts\nconst forwardedPropsObj = `{\n ...fwdProps.defaultProps,\n ...fwdProps.accessibilityProps,\n ...fwdProps.clickProps,\n ...fwdProps.focusProps,\n ...fwdProps.keyboardProps,\n ...fwdProps.mouseProps,\n ...fwdProps.touchProps,\n ...fwdProps.styleProps,\n href: true,\n lang: true,\n onScroll: true,\n onWheel: true,\n pointerEvents: true\n}\n`\n\nconst moduleExports = `\nexport { atomic } from './exports/StyleSheet/compile'\nexport { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'\nexport { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'\nexport { default as i18Style } from './exports/StyleSheet/i18nStyle'\nexport { default as createDOMProps } from './modules/createDOMProps'\nexport { default as AccessibilityUtil } from './modules/AccessibilityUtil'\nexport { default as createElement } from './exports/createElement'\nexport { default as css } from './exports/StyleSheet/css'\nexport { default as TextAncestorContext } from './exports/Text/TextAncestorContext'\nexport { default as pick } from './modules/pick'\nexport { default as useElementLayout } from './modules/useElementLayout'\nexport { default as useMergeRefs } from './modules/useMergeRefs'\nexport { default as usePlatformMethods } from './modules/usePlatformMethods'\nexport { default as useResponderEvents } from './modules/useResponderEvents'\nimport * as fwdProps from './modules/forwardedProps'\nexport const forwardedProps = ${forwardedPropsObj}\n`\n\nconst cjsExports = `\nexports.atomic = require('./exports/StyleSheet/compile').atomic\nexports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')\nexports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')\nexports.i18Style = require('./exports/StyleSheet/i18nStyle')\nexports.createDOMProps = require('./modules/createDOMProps')\nexports.AccessibilityUtil = require('./modules/AccessibilityUtil')\nexports.createElement = require('./exports/createElement')\nexports.css = require('./exports/StyleSheet/css')\nexports.TextAncestorContext = require('./exports/Text/TextAncestorContext')\nexports.pick = require('./modules/pick')\nexports.useElementLayout = require('./modules/useElementLayout')\nexports.useMergeRefs = require('./modules/useMergeRefs')\nexports.usePlatformMethods = require('./modules/usePlatformMethods')\nexports.useResponderEvents = require('./modules/useResponderEvents')\nconst fwdProps = require('./modules/forwardedProps')\nexports.forwardedProps = ${forwardedPropsObj}\n`\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,SAAoB;AAQb,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY,EAAE;AAC1E,QAAM,aAAa,oBAAK,KAAK,SAAS,QAAQ,oBAAoB;AAClE,QAAM,UAAU,oBAAK,KAAK,SAAS,QAAQ,OAAO,oBAAoB;AACtE,QAAM,qBACJ,GAAG,WAAW,UAAU,KACxB,GAAG,aAAa,YAAY,OAAO,MAAM,iBACzC,GAAG,WAAW,OAAO,KACrB,GAAG,aAAa,SAAS,OAAO,MAAM;AACxC,MAAI,CAAC,oBAAoB;AACvB,YAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,UAAU,CAAC;AACjE,YAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,OAAO,CAAC;AAC9D,OAAG,cAAc,YAAY,aAAa;AAC1C,OAAG,cAAc,SAAS,UAAU;AAAA,EACtC;AAGA,QAAM,UAAU;AAAA,IACd;AAAA,MACE,UAAU;AAAA,MACV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOZ;AAAA,EACF;AAEA,QAAM,cAAc,CAAC,WAAW,kBAAkB,UAAU;AAC5D,QAAM,oBAAoB,oBAAK,KAAK,SAAS,QAAQ,GAAG,WAAW;AACnE,QAAM,iBAAiB,oBAAK,KAAK,SAAS,QAAQ,OAAO,GAAG,WAAW;AAEvE,aAAW,QAAQ,CAAC,mBAAmB,cAAc,GAAG;AACtD,UAAM,WAAW,GAAG,aAAa,MAAM,OAAO;AAC9C,eAAW,EAAE,UAAU,cAAc,SAAS;AAC5C,UAAI,SAAS,SAAS,QAAQ,GAAG;AAC/B;AAAA,MACF;AACA,UAAI,CAAC,SAAS,SAAS,QAAQ,GAAG;AAChC,gBAAQ,KACN,0GACA;AAAA,UACE;AAAA,UACA;AAAA,QACF,CACF;AACA;AAAA,MACF;AACA,cAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,IAAI,CAAC;AAC3D,SAAG,cAAc,MAAM,SAAS,WAAW,UAAU,QAAQ,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,QAAM,cAAc,oBAAK,KAAK,SAAS,QAAQ,UAAU;AACzD,QAAM,iBAAiB,GAAG,aAAa,aAAa,OAAO;AAC3D,MAAI,CAAC,eAAe,SAAS,qBAAqB,GAAG;AACnD,OAAG,cACD,aACA,GAAG,YAAY,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAO/B;AAAA,EACF;AACA,QAAM,WAAW,oBAAK,KAAK,SAAS,QAAQ,OAAO,UAAU;AAC7D,QAAM,cAAc,GAAG,aAAa,UAAU,OAAO;AACrD,MAAI,CAAC,YAAY,SAAS,qBAAqB,GAAG;AAChD,OAAG,cACD,UACA,GAAG,YAAY,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,CAM5B;AAAA,EACF;AACF;AAlFgB;AAoFhB,qBAAqB,QAAgB;AACnC,SAAO,OAAO,QAAQ,iCAAiC,EAAE;AAC3D;AAFS;AAKT,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB1B,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAgBU;AAAA;AAGhC,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAgBQ;AAAA;",
4
+ "sourcesContent": ["import path from 'path'\n\nimport * as fs from 'fs-extra'\n\n// were patching react-native-web so we can use some internal methods\n// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm\n// so we can't just require it all directly\n// would be nice in the future to be able to eject from react-native-web entirely optionally\n\n// keep it sync\nexport function patchReactNativeWeb() {\n const rootDir = require.resolve('react-native-web').replace(/\\/dist.*/, '')\n const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')\n const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')\n const shouldPatchExports =\n fs.existsSync(modulePath) &&\n fs.readFileSync(modulePath, 'utf-8') === moduleExports &&\n fs.existsSync(cjsPath) &&\n fs.readFileSync(cjsPath, 'utf-8') === cjsExports\n if (!shouldPatchExports) {\n console.log(' | patch ' + path.relative(rootDir, modulePath))\n console.log(' | patch ' + path.relative(rootDir, cjsPath))\n fs.writeFileSync(modulePath, moduleExports)\n fs.writeFileSync(cjsPath, cjsExports)\n }\n\n // patch to allow className prop\n const patches = [\n {\n id: 'dom-props',\n filePath: ['modules', 'createDOMProps', 'index.js'],\n replacee: ` if (dataSet != null) {`,\n replacer: `\n if (props.dataSet && props.dataSet.className) {\n const { className, ...dataSetRest } = props.dataSet\n classList = className\n dataSet = dataSetRest\n }\n if (props.dataSet && props.dataSet.id) {\n domProps['id'] = props.dataSet.id\n }\n if (dataSet != null) {`,\n },\n {\n id: 'forward-props',\n filePath: ['modules', 'forwardedProps', 'index.js'],\n replacee: `dataSet: true,`,\n replacer: `id: true, dataSet: true,`,\n },\n ]\n\n for (const { filePath, replacee, replacer } of patches) {\n const files = [\n path.join(rootDir, 'dist', ...filePath),\n path.join(rootDir, 'dist', 'cjs', ...filePath),\n ]\n for (const file of files) {\n const contents = fs.readFileSync(file, 'utf-8')\n if (contents.includes(replacer)) {\n continue\n }\n if (!contents.includes(replacee)) {\n console.warn(\n `\u26A0\uFE0F Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`,\n {\n replacee,\n contents,\n }\n )\n continue\n }\n console.log(' | patch ' + path.relative(rootDir, file))\n fs.writeFileSync(file, contents.replace(replacee, replacer))\n }\n }\n\n // if entry files not patched, patch them:\n const moduleEntry = path.join(rootDir, 'dist', 'index.js')\n const moduleEntrySrc = fs.readFileSync(moduleEntry, 'utf-8')\n if (!moduleEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n moduleEntry,\n `${removePatch(moduleEntrySrc)}\n\n// tamagui-patch-v4\nimport * as TExports from './tamagui-exports'\nexport const TamaguiExports = TExports\n// tamagui-patch-end\n`\n )\n }\n const cjsEntry = path.join(rootDir, 'dist', 'cjs', 'index.js')\n const cjsEntrySrc = fs.readFileSync(cjsEntry, 'utf-8')\n if (!cjsEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n cjsEntry,\n `${removePatch(cjsEntrySrc)}\n\n// tamagui-patch-v4\nexports.TamaguiExports = _interopRequireDefault(require(\"./tamagui-exports\"));\n// tamagui-patch-end\n`\n )\n }\n}\n\nfunction removePatch(source: string) {\n return source.replace(/\\/\\/ tamagui-patch([.\\s\\S]*)/g, '')\n}\n\n// view exports/View.ts\nconst forwardedPropsObj = `{\n ...fwdProps.defaultProps,\n ...fwdProps.accessibilityProps,\n ...fwdProps.clickProps,\n ...fwdProps.focusProps,\n ...fwdProps.keyboardProps,\n ...fwdProps.mouseProps,\n ...fwdProps.touchProps,\n ...fwdProps.styleProps,\n href: true,\n lang: true,\n onScroll: true,\n onWheel: true,\n pointerEvents: true\n}\n`\n\nconst moduleExports = `\nexport { atomic } from './exports/StyleSheet/compile'\nexport { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'\nexport { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'\nexport { default as i18Style } from './exports/StyleSheet/i18nStyle'\nexport { default as createDOMProps } from './modules/createDOMProps'\nexport { default as AccessibilityUtil } from './modules/AccessibilityUtil'\nexport { default as createElement } from './exports/createElement'\nexport { default as css } from './exports/StyleSheet/css'\nexport { default as TextAncestorContext } from './exports/Text/TextAncestorContext'\nexport { default as pick } from './modules/pick'\nexport { default as useElementLayout } from './modules/useElementLayout'\nexport { default as useMergeRefs } from './modules/useMergeRefs'\nexport { default as usePlatformMethods } from './modules/usePlatformMethods'\nexport { default as useResponderEvents } from './modules/useResponderEvents'\nimport * as fwdProps from './modules/forwardedProps'\nexport const forwardedProps = ${forwardedPropsObj}\n`\n\nconst cjsExports = `\nexports.atomic = require('./exports/StyleSheet/compile').atomic\nexports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')\nexports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')\nexports.i18Style = require('./exports/StyleSheet/i18nStyle')\nexports.createDOMProps = require('./modules/createDOMProps')\nexports.AccessibilityUtil = require('./modules/AccessibilityUtil')\nexports.createElement = require('./exports/createElement')\nexports.css = require('./exports/StyleSheet/css')\nexports.TextAncestorContext = require('./exports/Text/TextAncestorContext')\nexports.pick = require('./modules/pick')\nexports.useElementLayout = require('./modules/useElementLayout')\nexports.useMergeRefs = require('./modules/useMergeRefs')\nexports.usePlatformMethods = require('./modules/usePlatformMethods')\nexports.useResponderEvents = require('./modules/useResponderEvents')\nconst fwdProps = require('./modules/forwardedProps')\nexports.forwardedProps = ${forwardedPropsObj}\n`\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,SAAoB;AAQb,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY,EAAE;AAC1E,QAAM,aAAa,oBAAK,KAAK,SAAS,QAAQ,oBAAoB;AAClE,QAAM,UAAU,oBAAK,KAAK,SAAS,QAAQ,OAAO,oBAAoB;AACtE,QAAM,qBACJ,GAAG,WAAW,UAAU,KACxB,GAAG,aAAa,YAAY,OAAO,MAAM,iBACzC,GAAG,WAAW,OAAO,KACrB,GAAG,aAAa,SAAS,OAAO,MAAM;AACxC,MAAI,CAAC,oBAAoB;AACvB,YAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,UAAU,CAAC;AACjE,YAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,OAAO,CAAC;AAC9D,OAAG,cAAc,YAAY,aAAa;AAC1C,OAAG,cAAc,SAAS,UAAU;AAAA,EACtC;AAGA,QAAM,UAAU;AAAA,IACd;AAAA,MACE,IAAI;AAAA,MACJ,UAAU,CAAC,WAAW,kBAAkB,UAAU;AAAA,MAClD,UAAU;AAAA,MACV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUZ;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,UAAU,CAAC,WAAW,kBAAkB,UAAU;AAAA,MAClD,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,aAAW,EAAE,UAAU,UAAU,cAAc,SAAS;AACtD,UAAM,QAAQ;AAAA,MACZ,oBAAK,KAAK,SAAS,QAAQ,GAAG,QAAQ;AAAA,MACtC,oBAAK,KAAK,SAAS,QAAQ,OAAO,GAAG,QAAQ;AAAA,IAC/C;AACA,eAAW,QAAQ,OAAO;AACxB,YAAM,WAAW,GAAG,aAAa,MAAM,OAAO;AAC9C,UAAI,SAAS,SAAS,QAAQ,GAAG;AAC/B;AAAA,MACF;AACA,UAAI,CAAC,SAAS,SAAS,QAAQ,GAAG;AAChC,gBAAQ,KACN,0GACA;AAAA,UACE;AAAA,UACA;AAAA,QACF,CACF;AACA;AAAA,MACF;AACA,cAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,IAAI,CAAC;AAC3D,SAAG,cAAc,MAAM,SAAS,QAAQ,UAAU,QAAQ,CAAC;AAAA,IAC7D;AAAA,EACF;AAGA,QAAM,cAAc,oBAAK,KAAK,SAAS,QAAQ,UAAU;AACzD,QAAM,iBAAiB,GAAG,aAAa,aAAa,OAAO;AAC3D,MAAI,CAAC,eAAe,SAAS,qBAAqB,GAAG;AACnD,OAAG,cACD,aACA,GAAG,YAAY,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAO/B;AAAA,EACF;AACA,QAAM,WAAW,oBAAK,KAAK,SAAS,QAAQ,OAAO,UAAU;AAC7D,QAAM,cAAc,GAAG,aAAa,UAAU,OAAO;AACrD,MAAI,CAAC,YAAY,SAAS,qBAAqB,GAAG;AAChD,OAAG,cACD,UACA,GAAG,YAAY,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,CAM5B;AAAA,EACF;AACF;AA9FgB;AAgGhB,qBAAqB,QAAgB;AACnC,SAAO,OAAO,QAAQ,iCAAiC,EAAE;AAC3D;AAFS;AAKT,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB1B,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAgBU;AAAA;AAGhC,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAgBQ;AAAA;",
6
6
  "names": []
7
7
  }
@@ -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 // 'objectRestSpread',\n // 'dynamicImport'\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;AAEO,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,EAGF;AAAA,EACA,YAAY;AACd,CAAC;AAED,MAAM,SAAS,YAAY,MAAM,KAAK,WAAW;AAE1C,oBAAoB,MAA4B;AACrD,SAAO,OAAO,KAAK,SAAS,GAAG,aAAa;AAC9C;AAFgB;",
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;AAEO,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
  }
@@ -1,10 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { relative } from "path";
3
4
  import traverse from "@babel/traverse";
4
5
  import * as t from "@babel/types";
5
6
  import {
6
7
  getSplitStyles,
7
8
  mediaQueryConfig,
9
+ normalizeStyleObject,
10
+ proxyThemeVariables,
8
11
  pseudos,
9
12
  rnw
10
13
  } from "@tamagui/core-node";
@@ -20,6 +23,7 @@ import { loadTamagui } from "./loadTamagui";
20
23
  import { logLines } from "./logLines";
21
24
  import { normalizeTernaries } from "./normalizeTernaries";
22
25
  import { removeUnusedHooks } from "./removeUnusedHooks";
26
+ import { timer } from "./timer";
23
27
  import { validHTMLAttributes } from "./validHTMLAttributes";
24
28
  const UNTOUCHED_PROPS = {
25
29
  key: true,
@@ -47,10 +51,6 @@ function createExtractor() {
47
51
  process.exit(1);
48
52
  }
49
53
  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);
50
- require("esbuild-register/dist/node").register({
51
- target: "es2019",
52
- format: "cjs"
53
- });
54
54
  let loadedTamaguiConfig;
55
55
  let hasLogged = false;
56
56
  return {
@@ -83,12 +83,18 @@ function createExtractor() {
83
83
  if (!Array.isArray(props.components)) {
84
84
  throw new Error(`Must provide components array with list of Tamagui component modules`);
85
85
  }
86
+ const ogDebug = shouldPrintDebug;
87
+ const tm = timer();
86
88
  const { components, tamaguiConfig } = loadTamagui({
87
89
  config,
88
90
  components: props.components || ["tamagui"]
89
91
  });
92
+ if (shouldPrintDebug === "verbose") {
93
+ console.log("tamagui.config.ts:", { components, config });
94
+ }
95
+ tm.mark("load-tamagui", shouldPrintDebug === "verbose");
90
96
  loadedTamaguiConfig = tamaguiConfig;
91
- const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]];
97
+ const defaultTheme = proxyThemeVariables(tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]);
92
98
  const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
93
99
  const isInternalImport = /* @__PURE__ */ __name((importStr) => {
94
100
  return isInsideTamagui(sourcePath) && importStr[0] === ".";
@@ -100,6 +106,9 @@ function createExtractor() {
100
106
  obj[name] = components[name];
101
107
  return obj;
102
108
  }, {});
109
+ if (shouldPrintDebug === "verbose") {
110
+ console.log("validComponents", Object.keys(validComponents));
111
+ }
103
112
  let doesUseValidImport = false;
104
113
  let hasImportedTheme = false;
105
114
  for (const bodyPath of body) {
@@ -107,11 +116,16 @@ function createExtractor() {
107
116
  continue;
108
117
  const node = "node" in bodyPath ? bodyPath.node : bodyPath;
109
118
  const from = node.source.value;
110
- if (props.components.includes(from) || isInternalImport(from)) {
111
- if (node.specifiers.some((specifier) => {
119
+ const isValidImport = props.components.includes(from) || isInternalImport(from);
120
+ if (isValidImport) {
121
+ const isValidComponent = node.specifiers.some((specifier) => {
112
122
  const name = specifier.local.name;
113
123
  return validComponents[name] || validHooks[name];
114
- })) {
124
+ });
125
+ if (shouldPrintDebug === "verbose") {
126
+ console.log("import from", from, { isValidComponent });
127
+ }
128
+ if (isValidComponent) {
115
129
  doesUseValidImport = true;
116
130
  break;
117
131
  }
@@ -123,6 +137,7 @@ function createExtractor() {
123
137
  if (!doesUseValidImport) {
124
138
  return null;
125
139
  }
140
+ tm.mark("import-check", shouldPrintDebug === "verbose");
126
141
  let couldntParse = false;
127
142
  const modifiedComponents = /* @__PURE__ */ new Set();
128
143
  const bindingCache = {};
@@ -144,6 +159,7 @@ function createExtractor() {
144
159
  },
145
160
  JSXElement(traversePath) {
146
161
  var _a, _b, _c, _d, _e;
162
+ tm.mark("jsx-element", shouldPrintDebug === "verbose");
147
163
  const node = traversePath.node.openingElement;
148
164
  const ogAttributes = node.attributes;
149
165
  const componentName = findComponentName(traversePath.scope);
@@ -170,13 +186,18 @@ function createExtractor() {
170
186
  }
171
187
  const originalNodeName = node.name.name;
172
188
  res.found++;
173
- const filePath = sourcePath.replace(process.cwd(), ".");
189
+ const filePath = `./${relative(process.cwd(), sourcePath)}`;
174
190
  const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
175
- const preName = componentName ? `${componentName}.` : "";
176
- const tagId = `${preName}${node.name.name}@${filePath.replace("./", "")}:${lineNumbers}`;
177
- const hasBooleanDebugTrue = node.attributes.some((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
178
- if (hasBooleanDebugTrue) {
179
- shouldPrintDebug = true;
191
+ const tagId = [componentName, `${node.name.name}`, `${filePath}:${lineNumbers}`].filter(Boolean);
192
+ const debugPropValue = node.attributes.filter((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug").map((n) => {
193
+ if (n.value === null)
194
+ return true;
195
+ if (t.isStringLiteral(n.value))
196
+ return n.value.value;
197
+ return false;
198
+ })[0];
199
+ if (debugPropValue) {
200
+ shouldPrintDebug = debugPropValue;
180
201
  }
181
202
  try {
182
203
  let isValidStyleKey = function(name) {
@@ -300,6 +321,10 @@ function createExtractor() {
300
321
  }
301
322
  }
302
323
  }
324
+ if (name === "theme") {
325
+ inlined.set("theme", attr.value);
326
+ return attr;
327
+ }
303
328
  const styleValue = attemptEvalSafe(value);
304
329
  if (!isValidStyleKey(name)) {
305
330
  let keys = [name];
@@ -315,10 +340,6 @@ function createExtractor() {
315
340
  let didInline = false;
316
341
  const attributes = keys.map((key) => {
317
342
  const val = out[key];
318
- if (key === "theme") {
319
- inlined.set(key, val);
320
- return attr;
321
- }
322
343
  if (isValidStyleKey(key)) {
323
344
  return {
324
345
  type: "style",
@@ -395,14 +416,14 @@ function createExtractor() {
395
416
  }
396
417
  const staticConditional = getStaticConditional(value);
397
418
  if (staticConditional) {
398
- if (shouldPrintDebug) {
399
- console.log(` static conditional ${name} = `, value);
419
+ if (shouldPrintDebug === "verbose") {
420
+ console.log(` static conditional ${name}`, value);
400
421
  }
401
422
  return { type: "ternary", value: staticConditional };
402
423
  }
403
424
  const staticLogical = getStaticLogical(value);
404
425
  if (staticLogical) {
405
- if (shouldPrintDebug) {
426
+ if (shouldPrintDebug === "verbose") {
406
427
  console.log(` static ternary ${name} = `, value);
407
428
  }
408
429
  return { type: "ternary", value: staticLogical };
@@ -435,9 +456,6 @@ function createExtractor() {
435
456
  function getStaticConditional(value2) {
436
457
  if (t.isConditionalExpression(value2)) {
437
458
  try {
438
- if (shouldPrintDebug) {
439
- console.log("attempt", value2.alternate, value2.consequent);
440
- }
441
459
  const aVal = attemptEval(value2.alternate);
442
460
  const cVal = attemptEval(value2.consequent);
443
461
  if (shouldPrintDebug) {
@@ -568,9 +586,15 @@ function createExtractor() {
568
586
  });
569
587
  });
570
588
  }, mergeStyles = function(prev2, next) {
589
+ normalizeStyleObject(next);
571
590
  for (const key in next) {
572
591
  if (pseudos[key]) {
573
592
  prev2[key] = prev2[key] || {};
593
+ if (shouldPrintDebug) {
594
+ if (!next[key] || !prev2[key]) {
595
+ console.log("warn: missing", key, prev2, next);
596
+ }
597
+ }
574
598
  Object.assign(prev2[key], next[key]);
575
599
  } else {
576
600
  prev2[key] = next[key];
@@ -584,12 +608,13 @@ function createExtractor() {
584
608
  __name(mergeStyles, "mergeStyles");
585
609
  node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
586
610
  if (shouldPrintDebug) {
587
- console.log(`
588
- <${originalNodeName} /> (${tagId})`);
611
+ console.log("\n");
612
+ console.log("\x1B[33m%s\x1B[0m", `${tagId[0]} | ${tagId[2]} -------------------`);
613
+ console.log("\x1B[1m", "\x1B[32m", `<${originalNodeName} />`);
589
614
  }
590
615
  if (shouldAddDebugProp && !disableDebugAttr) {
591
616
  res.modified++;
592
- node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(tagId)));
617
+ node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(tagId.join(" "))));
593
618
  }
594
619
  const shouldLog = !hasLogged;
595
620
  if (shouldLog) {
@@ -680,6 +705,7 @@ function createExtractor() {
680
705
  if (couldntParse) {
681
706
  return;
682
707
  }
708
+ tm.mark("jsx-element-flattened", shouldPrintDebug === "verbose");
683
709
  node.attributes = flattenedAttrs;
684
710
  if (staticConfig.defaultProps) {
685
711
  for (const key in staticConfig.defaultProps) {
@@ -705,6 +731,7 @@ function createExtractor() {
705
731
  attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
706
732
  try {
707
733
  const res2 = evaluateAttribute(path);
734
+ tm.mark("jsx-element-evaluate-attr", shouldPrintDebug === "verbose");
708
735
  if (!res2) {
709
736
  path.remove();
710
737
  }
@@ -767,73 +794,48 @@ function createExtractor() {
767
794
  out.push(cur);
768
795
  return out;
769
796
  }, []).flat();
770
- const completeStaticProps = {
771
- ...Object.keys(attrs).reduce((acc, index) => {
772
- const cur = attrs[index];
773
- if (cur.type === "style") {
774
- Object.assign(acc, cur.value);
775
- }
776
- if (cur.type === "attr") {
777
- if (t.isJSXSpreadAttribute(cur.value)) {
778
- return acc;
779
- }
780
- if (!t.isJSXIdentifier(cur.value.name)) {
781
- return acc;
782
- }
783
- const key = cur.value.name.name;
784
- const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
785
- if (value === FAILED_EVAL) {
786
- return acc;
787
- }
788
- acc[key] = value;
789
- }
790
- return acc;
791
- }, {})
792
- };
793
797
  const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x));
794
798
  const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
795
- const themeVal = inlined.get("theme");
799
+ let themeVal = inlined.get("theme");
796
800
  inlined.delete("theme");
797
801
  const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
798
- const shouldWrapInnerTheme = allOtherPropsExtractable && !!(hasOnlyStringChildren && themeVal);
799
- const canFlattenProps = inlined.size === 0 || shouldWrapInnerTheme || allOtherPropsExtractable;
802
+ const shouldWrapThme = allOtherPropsExtractable && !!themeVal;
803
+ const canFlattenProps = inlined.size === 0 || shouldWrapThme || allOtherPropsExtractable;
800
804
  let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
801
- if (shouldFlatten && shouldWrapInnerTheme) {
802
- if (typeof themeVal !== "string") {
803
- console.warn("??");
804
- return;
805
- }
805
+ if (shouldPrintDebug) {
806
+ console.log(" - flatten?", objToStr({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapThme, allOtherPropsExtractable, hasOnlyStringChildren }));
807
+ }
808
+ if (shouldFlatten && shouldWrapThme) {
806
809
  if (shouldPrintDebug) {
807
810
  console.log(" - wrapping theme", allOtherPropsExtractable, themeVal);
808
811
  }
812
+ attrs = attrs.filter((x) => x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme" ? false : true);
809
813
  if (!hasImportedTheme) {
810
814
  hasImportedTheme = true;
811
815
  programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/core")));
812
816
  }
813
817
  traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
814
- t.jsxAttribute(t.jsxIdentifier("name"), t.stringLiteral(`${themeVal}`))
818
+ t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
815
819
  ]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]));
816
820
  }
817
821
  if (shouldFlatten && staticConfig.defaultProps) {
818
822
  const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
819
823
  if (!isValidStyleKey(key)) {
820
- return;
824
+ return [];
821
825
  }
822
- try {
823
- const serialize = require("babel-literal-to-ast");
824
- const val = staticConfig.defaultProps[key];
825
- const value = serialize(val);
826
- const name = tamaguiConfig.shorthands[key] || key;
827
- return {
828
- type: "style",
829
- name,
830
- value
831
- };
832
- } catch (err) {
833
- console.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key}
834
- error: ${err}`);
826
+ const value = staticConfig.defaultProps[key];
827
+ const name = tamaguiConfig.shorthands[key] || key;
828
+ if (value === void 0) {
829
+ console.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`);
835
830
  shouldDeopt = true;
831
+ return;
836
832
  }
833
+ const attr = {
834
+ type: "style",
835
+ name,
836
+ value: { [name]: value }
837
+ };
838
+ return attr;
837
839
  });
838
840
  if (defaultStyleAttrs.length) {
839
841
  attrs = [...defaultStyleAttrs, ...attrs];
@@ -901,6 +903,7 @@ function createExtractor() {
901
903
  acc.push(cur);
902
904
  return acc;
903
905
  }, []);
906
+ tm.mark("jsx-element-expanded", shouldPrintDebug === "verbose");
904
907
  if (shouldPrintDebug) {
905
908
  console.log(" - attrs (expanded): \n", logLines(attrs.map(attrStr).join(", ")));
906
909
  }
@@ -937,54 +940,91 @@ function createExtractor() {
937
940
  acc.push(cur);
938
941
  return acc;
939
942
  }, []);
940
- if (shouldPrintDebug) {
941
- console.log(" - attrs (combined \u{1F500}): \n", logLines(attrs.map(attrStr).join(", ")));
942
- }
943
+ const state = {
944
+ noClassNames: true,
945
+ focus: false,
946
+ hover: false,
947
+ mounted: true,
948
+ press: false,
949
+ pressIn: false
950
+ };
951
+ const completeStaticProps = Object.keys(attrs).reduce((acc, index) => {
952
+ const cur = attrs[index];
953
+ if (cur.type === "style") {
954
+ normalizeStyleObject(cur.value);
955
+ Object.assign(acc, cur.value);
956
+ }
957
+ if (cur.type === "attr") {
958
+ if (t.isJSXSpreadAttribute(cur.value)) {
959
+ return acc;
960
+ }
961
+ if (!t.isJSXIdentifier(cur.value.name)) {
962
+ return acc;
963
+ }
964
+ const key = cur.value.name.name;
965
+ const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
966
+ if (value === FAILED_EVAL) {
967
+ return acc;
968
+ }
969
+ acc[key] = value;
970
+ }
971
+ return acc;
972
+ }, {});
943
973
  const completeProps = {
944
974
  ...staticConfig.defaultProps,
945
975
  ...completeStaticProps
946
976
  };
977
+ if (shouldPrintDebug) {
978
+ console.log(" - attrs (combined \u{1F500}): \n", logLines(attrs.map(attrStr).join(", ")));
979
+ console.log(" - defaultProps: \n", logLines(objToStr(staticConfig.defaultProps)));
980
+ console.log(" - completeStaticProps: \n", logLines(objToStr(completeStaticProps)));
981
+ }
947
982
  const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
948
- if (!props2)
949
- return;
950
- if (!Object.keys(props2).length)
951
- return;
983
+ if (!props2 || !Object.keys(props2).length) {
984
+ if (shouldPrintDebug)
985
+ console.log(" getStyles() no props");
986
+ return {};
987
+ }
952
988
  if (excludeProps && !!excludeProps.size) {
953
989
  for (const key in props2) {
954
990
  if (excludeProps.has(key)) {
991
+ if (shouldPrintDebug)
992
+ console.log(" delete excluded", key);
955
993
  delete props2[key];
956
994
  }
957
995
  }
958
996
  }
959
- const out = getSplitStyles(props2, staticConfig, defaultTheme, {
960
- noClassNames: true,
961
- fallbackProps: completeProps,
962
- focus: false,
963
- hover: false,
964
- mounted: true,
965
- press: false,
966
- pressIn: false
967
- });
968
- const outStyle = {
969
- ...out.style,
970
- ...out.pseudos
971
- };
972
- for (const key in outStyle) {
997
+ try {
998
+ const out = getSplitStyles(props2, staticConfig, defaultTheme, {
999
+ ...state,
1000
+ fallbackProps: completeProps
1001
+ });
1002
+ const outStyle = {
1003
+ ...out.style,
1004
+ ...out.pseudos
1005
+ };
973
1006
  if (staticConfig.validStyles) {
974
- if (!staticConfig.validStyles[key] && !pseudos[key]) {
975
- delete outStyle[key];
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
+ }
976
1013
  }
977
1014
  }
978
- }
979
- if (shouldPrintDebug === "verbose") {
980
- console.log(` getStyles ${debugName} (props):
1015
+ if (shouldPrintDebug) {
1016
+ console.log(` getStyles ${debugName} (props):
981
1017
  `, logLines(objToStr(props2)));
982
- console.log(` getStyles ${debugName} (out.viewProps):
1018
+ console.log(` getStyles ${debugName} (out.viewProps):
983
1019
  `, logLines(objToStr(out.viewProps)));
984
- console.log(` getStyles ${debugName} (out.style):
1020
+ console.log(` getStyles ${debugName} (out.style):
985
1021
  `, logLines(objToStr(outStyle || {}), true));
1022
+ }
1023
+ return outStyle;
1024
+ } catch (err) {
1025
+ console.log("error", err.message, err.stack);
1026
+ return {};
986
1027
  }
987
- return outStyle;
988
1028
  }, "getStyles");
989
1029
  const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
990
1030
  if (!completeStylesProcessed) {
@@ -1025,11 +1065,13 @@ function createExtractor() {
1025
1065
  console.log(" => tern ", attrStr(attr));
1026
1066
  continue;
1027
1067
  case "style":
1068
+ if (shouldPrintDebug)
1069
+ console.log(" * styles in", logLines(objToStr(attr.value)));
1028
1070
  const styles = getStyles(attr.value, "style");
1071
+ if (shouldPrintDebug)
1072
+ console.log(" * styles out", logLines(objToStr(styles)));
1029
1073
  if (styles) {
1030
1074
  attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
1031
- } else {
1032
- console.warn("?????????");
1033
1075
  }
1034
1076
  continue;
1035
1077
  }
@@ -1037,6 +1079,7 @@ function createExtractor() {
1037
1079
  getStyleError = err;
1038
1080
  }
1039
1081
  }
1082
+ tm.mark("jsx-element-styles", shouldPrintDebug === "verbose");
1040
1083
  if (getStyleError) {
1041
1084
  console.log(" \u26A0\uFE0F postprocessing error, deopt", getStyleError);
1042
1085
  node.attributes = ogAttributes;
@@ -1060,6 +1103,9 @@ function createExtractor() {
1060
1103
  if (attr.type === "style") {
1061
1104
  for (const key in attr.value) {
1062
1105
  if (existingStyleKeys.has(key)) {
1106
+ if (shouldPrintDebug) {
1107
+ console.log(" >> delete existing", key);
1108
+ }
1063
1109
  delete attr.value[key];
1064
1110
  } else {
1065
1111
  existingStyleKeys.add(key);
@@ -1095,12 +1141,13 @@ function createExtractor() {
1095
1141
  } catch (err) {
1096
1142
  throw err;
1097
1143
  } finally {
1098
- if (hasBooleanDebugTrue) {
1099
- shouldPrintDebug = false;
1144
+ if (debugPropValue) {
1145
+ shouldPrintDebug = ogDebug;
1100
1146
  }
1101
1147
  }
1102
1148
  }
1103
1149
  });
1150
+ tm.mark("jsx-done", shouldPrintDebug === "verbose");
1104
1151
  if (modifiedComponents.size) {
1105
1152
  const all = Array.from(modifiedComponents);
1106
1153
  if (shouldPrintDebug) {
@@ -1110,6 +1157,7 @@ function createExtractor() {
1110
1157
  removeUnusedHooks(comp, shouldPrintDebug);
1111
1158
  }
1112
1159
  }
1160
+ tm.done(shouldPrintDebug === "verbose");
1113
1161
  return res;
1114
1162
  }
1115
1163
  };