@tamagui/static 1.0.1-beta.133 → 1.0.1-beta.136

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/require.ts"],
4
- "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Module = require('module')\nconst og = Module.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\n// just for catching egregious amounts of errors in a tight loop\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 50)\n\nexport function registerRequire() {\n if (Module.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Module.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css') || path.endsWith('.json') || path.endsWith('.ttf')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient' ||\n path === '@expo/vector-icons'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n if (SHOULD_DEBUG) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring\\n`,\n err.message,\n err.stack\n )\n }\n const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 200\n if (++tries > max) {\n console.log(\n `Too many errors loading design system, exiting (set TAMAGUI_MAX_ERRORS to override)..`\n )\n // avoid infinite loops\n process.exit(1)\n }\n // return proxyWorm by default\n return proxyWorm\n }\n }\n\n return Module.prototype.require\n}\n\nexport function unregisterRequire() {\n Module.prototype.require = og\n}\n"],
5
- "mappings": "AAAA;AAIA;AAEA,MAAM,cAAc,CAAC;AACrB,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,KAAK,OAAO,UAAU;AAC5B,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAGpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,EAAE;AAEE,2BAA2B;AAChC,MAAI,OAAO,UAAU,YAAY,WAAW,cAAc;AACxD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AACtC,QAAM,OAAO,QAAQ,oBAAoB;AAEzC,SAAO,UAAU,UAAU,SAAU,MAAc;AA7BrD;AA8BI,QAAI,cAAc;AAChB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,OAAO,KAAK,KAAK,SAAS,MAAM,GAAG;AAC5E,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,0BACT,SAAS,sBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,aAAO;AAAA,IAET;AACA,QAAI,SAAS,iBAAiB;AAC5B,aAAO;AAAA,IACT;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,UAAI,CAAC,YAAY,OAAO;AACtB,YAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qBAAW,OAAO,KAAK;AACrB,gBAAI;AACF,oBAAM,OAAO,UAAI,SAAJ,mBAAU;AACvB,kBAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,yCAAY,KAAK,mBAAjB,8BAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,KAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,UAAI,cAAc;AAChB,gBAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,SACJ,IAAI,KACN;AAAA,MACF;AACA,YAAM,MAAM,QAAQ,IAAI,qBAAqB,CAAC,QAAQ,IAAI,qBAAqB;AAC/E,UAAI,EAAE,QAAQ,KAAK;AACjB,gBAAQ,IACN,uFACF;AAEA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,OAAO,UAAU;AAC1B;AAEO,6BAA6B;AAClC,SAAO,UAAU,UAAU;AAC7B;",
4
+ "sourcesContent": ["import { join, sep } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Module = require('module')\nconst og = Module.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\n// just for catching egregious amounts of errors in a tight loop\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 50)\n\nexport function registerRequire() {\n if (Module.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Module.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css') || path.endsWith('.json') || path.endsWith('.ttf')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient' ||\n path === '@expo/vector-icons'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports'.replace(/\\//g, sep))\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n if (SHOULD_DEBUG) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring\\n`,\n err.message,\n err.stack\n )\n }\n const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 200\n if (++tries > max) {\n console.log(\n `Too many errors loading design system, exiting (set TAMAGUI_MAX_ERRORS to override)..`\n )\n // avoid infinite loops\n process.exit(1)\n }\n // return proxyWorm by default\n return proxyWorm\n }\n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Ae;AACtB,yCAAY,KAAK,mBAAjB,8BAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,KAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,UAAI,cAAc;AAChB,gBAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,SACJ,IAAI,KACN;AAAA,MACF;AACA,YAAM,MAAM,QAAQ,IAAI,qBAAqB,CAAC,QAAQ,IAAI,qBAAqB;AAC/E,UAAI,EAAE,QAAQ,KAAK;AACjB,gBAAQ,IACN,uFACF;AAEA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,OAAO,UAAU;AAC1B;AAEO,6BAA6B;AAClC,SAAO,UAAU,UAAU;AAC7B;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "1.0.1-beta.133",
3
+ "version": "1.0.1-beta.136",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -34,14 +34,14 @@
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.133",
38
- "@tamagui/config-default-node": "^1.0.1-beta.133",
39
- "@tamagui/core-node": "^1.0.1-beta.133",
40
- "@tamagui/fake-react-native": "^1.0.1-beta.133",
41
- "@tamagui/helpers": "^1.0.1-beta.133",
42
- "@tamagui/patch-rnw": "^1.0.1-beta.133",
43
- "@tamagui/proxy-worm": "^1.0.1-beta.133",
44
- "@tamagui/shorthands": "^1.0.1-beta.133",
37
+ "@tamagui/build": "^1.0.1-beta.136",
38
+ "@tamagui/config-default-node": "^1.0.1-beta.136",
39
+ "@tamagui/core-node": "^1.0.1-beta.136",
40
+ "@tamagui/fake-react-native": "^1.0.1-beta.136",
41
+ "@tamagui/helpers": "^1.0.1-beta.136",
42
+ "@tamagui/patch-rnw": "^1.0.1-beta.136",
43
+ "@tamagui/proxy-worm": "^1.0.1-beta.136",
44
+ "@tamagui/shorthands": "^1.0.1-beta.136",
45
45
  "babel-literal-to-ast": "^2.1.0",
46
46
  "esbuild": "^0.14.49",
47
47
  "esbuild-register": "^3.3.3",
@@ -49,7 +49,7 @@
49
49
  "fs-extra": "^10.1.0",
50
50
  "invariant": "^2.2.4",
51
51
  "lodash": "^4.17.21",
52
- "tamagui": "^1.0.1-beta.133"
52
+ "tamagui": "^1.0.1-beta.136"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@babel/plugin-syntax-typescript": "^7.14.5",
@@ -69,8 +69,8 @@
69
69
  "react-test-renderer": "^18.2.0",
70
70
  "style-loader": "^3.3.1",
71
71
  "typescript": "^4.7.4",
72
- "vitest": "^0.19.1",
73
- "webpack": "^5.73.0"
72
+ "vitest": "^0.20.3",
73
+ "webpack": "^5.74.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react-native-web": "*"
@@ -1,4 +1,4 @@
1
- import { relative } from 'path'
1
+ import { basename, relative } from 'path'
2
2
 
3
3
  import traverse, { NodePath, Visitor } from '@babel/traverse'
4
4
  import * as t from '@babel/types'
@@ -446,9 +446,8 @@ export function createExtractor() {
446
446
  ? node.loc.start.line +
447
447
  (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : '')
448
448
  : ''
449
- const tagId = [componentName, `${node.name.name}`, `${filePath}:${lineNumbers}`].filter(
450
- Boolean
451
- )
449
+
450
+ const codePosition = `${filePath}:${lineNumbers}`
452
451
 
453
452
  // debug just one
454
453
  const debugPropValue = node.attributes
@@ -465,41 +464,53 @@ export function createExtractor() {
465
464
  shouldPrintDebug = debugPropValue
466
465
  }
467
466
 
468
- try {
469
- node.attributes.find(
470
- (n) =>
471
- t.isJSXAttribute(n) &&
472
- t.isJSXIdentifier(n.name) &&
473
- n.name.name === 'debug' &&
474
- n.value === null
467
+ if (shouldPrintDebug) {
468
+ console.log('\n')
469
+ console.log(
470
+ '\x1b[33m%s\x1b[0m',
471
+ `${componentName} | ${codePosition} -------------------`
475
472
  )
473
+ console.log(
474
+ '\x1b[1m',
475
+ '\x1b[32m',
476
+ `<${originalNodeName} />`,
477
+ disableDebugAttr ? '' : '🐛'
478
+ )
479
+ }
476
480
 
477
- if (shouldPrintDebug) {
478
- console.log('\n')
479
- console.log('\x1b[33m%s\x1b[0m', `${tagId[0]} | ${tagId[2]} -------------------`)
480
- console.log('\x1b[1m', '\x1b[32m', `<${originalNodeName} />`)
481
- }
482
-
483
- // add data-is
484
- if (shouldAddDebugProp && !disableDebugAttr) {
485
- res.modified++
481
+ // add data-* debug attributes
482
+ if (shouldAddDebugProp && !disableDebugAttr) {
483
+ res.modified++
484
+ node.attributes.unshift(
485
+ t.jsxAttribute(t.jsxIdentifier('data-is'), t.stringLiteral(node.name.name))
486
+ )
487
+ if (componentName) {
486
488
  node.attributes.unshift(
487
- t.jsxAttribute(t.jsxIdentifier('data-is'), t.stringLiteral(tagId.join(' ')))
489
+ t.jsxAttribute(t.jsxIdentifier('data-in'), t.stringLiteral(componentName))
488
490
  )
489
491
  }
490
492
 
491
- const shouldLog = !hasLogged
492
- if (shouldLog) {
493
- console.log(` 1️⃣ Inline optimized 2️⃣ Inline flattened 3️⃣ styled() extracted`)
494
- const prefix = ' |'
495
- // prettier-ignore
496
- console.log(prefixLogs || prefix, ' total · 1️⃣ · 2️⃣ · 3️⃣')
497
- hasLogged = true
498
- }
499
- if (disableExtraction) {
500
- return
501
- }
493
+ node.attributes.unshift(
494
+ t.jsxAttribute(
495
+ t.jsxIdentifier('data-at'),
496
+ t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
497
+ )
498
+ )
499
+ }
502
500
 
501
+ const shouldLog = !hasLogged
502
+ if (shouldLog) {
503
+ console.log(` 1️⃣ Inline optimized 2️⃣ Inline flattened 3️⃣ styled() extracted`)
504
+ const prefix = ' |'
505
+ // prettier-ignore
506
+ console.log(prefixLogs || prefix, ' total · 1️⃣ · 2️⃣ · 3️⃣')
507
+ hasLogged = true
508
+ }
509
+ if (disableExtraction) {
510
+ return
511
+ }
512
+
513
+ try {
503
514
  const { staticConfig } = component
504
515
  const variants = staticConfig.variants || {}
505
516
  const isTextView = staticConfig.isText || false
package/src/require.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { join } from 'path'
1
+ import { join, sep } from 'path'
2
2
 
3
3
  import type { StaticConfig } from '@tamagui/core-node'
4
4
 
@@ -45,7 +45,7 @@ export function registerRequire() {
45
45
  if (
46
46
  path.startsWith('react-native') &&
47
47
  // allow our rnw.tsx imports through
48
- !path.startsWith('react-native-web/dist/cjs/exports')
48
+ !path.startsWith('react-native-web/dist/cjs/exports'.replace(/\//g, sep))
49
49
  ) {
50
50
  return rnw
51
51
  // return og('react-native-web')