@tamagui/static 1.0.0-alpha.22 → 1.0.0-alpha.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "1.0.0-alpha.22",
3
+ "version": "1.0.0-alpha.23",
4
4
  "source": "src/index.ts",
5
5
  "typings": "types",
6
6
  "main": "dist/cjs",
@@ -8,7 +8,6 @@
8
8
  "module:jsx": "dist/jsx",
9
9
  "files": [
10
10
  "types",
11
- "src",
12
11
  "dist"
13
12
  ],
14
13
  "scripts": {
@@ -44,7 +43,7 @@
44
43
  "react-native-web": "^0.17.5",
45
44
  "react-test-renderer": "18.0.0-beta-149b420f6-20211119",
46
45
  "style-loader": "^3.3.0",
47
- "typescript": "^4.4.4",
46
+ "typescript": "^4.5.2",
48
47
  "webpack": "^5.58.1"
49
48
  },
50
49
  "dependencies": {
@@ -56,10 +55,10 @@
56
55
  "@dish/babel-preset": "^0.0.6",
57
56
  "@expo/match-media": "^0.1.0",
58
57
  "@tamagui/build": "^1.0.0-alpha.22",
59
- "@tamagui/core": "^1.0.0-alpha.22",
60
- "@tamagui/core-node": "^1.0.0-alpha.22",
58
+ "@tamagui/core": "^1.0.0-alpha.23",
59
+ "@tamagui/core-node": "^1.0.0-alpha.23",
61
60
  "@tamagui/fake-react-native": "^1.0.0-alpha.17",
62
- "@tamagui/helpers": "^1.0.0-alpha.22",
61
+ "@tamagui/helpers": "^1.0.0-alpha.23",
63
62
  "babel-literal-to-ast": "^2.1.0",
64
63
  "esbuild": "^0.13.12",
65
64
  "esbuild-register": "^3.1.2",
@@ -67,10 +66,10 @@
67
66
  "fs-extra": "^9.1.0",
68
67
  "invariant": "^2.2.4",
69
68
  "lodash": "^4.17.21",
70
- "tamagui": "^1.0.0-alpha.22"
69
+ "tamagui": "^1.0.0-alpha.23"
71
70
  },
72
71
  "peerDependencies": {
73
72
  "react-native-web": "*"
74
73
  },
75
- "gitHead": "f247aca6f00c201efbc317bb24b22a62b08d1033"
74
+ "gitHead": "69fb1d82868a6525fee6b0750cb2113d88ffea79"
76
75
  }
package/src/constants.ts DELETED
@@ -1,10 +0,0 @@
1
- import findCacheDir from 'find-cache-dir'
2
-
3
- export const CSS_FILE_NAME = '__snack.css'
4
-
5
- // ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS
6
- // SEE matching one in concatClassName
7
- export const MEDIA_SEP = '_'
8
-
9
- // ensure cache dir
10
- export const cacheDir = findCacheDir({ name: 'tamagui', create: true })
@@ -1,18 +0,0 @@
1
- import * as t from '@babel/types'
2
-
3
- // accessSafe wraps memberExpressions in object/null checks
4
- // TODO: inject this as a function? this gets pretty repetitive
5
- export function accessSafe(obj: t.Expression, member: string): t.LogicalExpression {
6
- return t.logicalExpression(
7
- '&&',
8
- t.logicalExpression(
9
- '&&',
10
- // typeof obj === 'object
11
- t.binaryExpression('===', t.unaryExpression('typeof', obj), t.stringLiteral('object')),
12
- // obj !== null
13
- t.binaryExpression('!==', obj, t.nullLiteral())
14
- ),
15
- // obj.member
16
- t.memberExpression(obj, t.identifier(member), false)
17
- )
18
- }
@@ -1,27 +0,0 @@
1
- import * as babelParser from '@babel/parser'
2
-
3
- export const parserOptions: babelParser.ParserOptions = Object.freeze({
4
- plugins: [
5
- 'asyncGenerators',
6
- 'classProperties',
7
- 'dynamicImport',
8
- 'functionBind',
9
- 'jsx',
10
- 'numericSeparator',
11
- 'objectRestSpread',
12
- 'optionalCatchBinding',
13
- 'decorators-legacy',
14
- 'typescript',
15
- 'optionalChaining',
16
- 'nullishCoalescingOperator',
17
- // 'objectRestSpread',
18
- // 'dynamicImport'
19
- ],
20
- sourceType: 'module',
21
- })
22
-
23
- const parser = babelParser.parse.bind(babelParser)
24
-
25
- export function babelParse(code: string | Buffer): any {
26
- return parser(code.toString(), parserOptions)
27
- }
@@ -1,61 +0,0 @@
1
- import * as t from '@babel/types'
2
-
3
- import { ClassNameObject } from '../types'
4
-
5
- export function buildClassName(
6
- classNameObjects: ClassNameObject[]
7
- ): t.Expression | t.StringLiteral | null {
8
- return classNameObjects.reduce<t.Expression | null>((acc, val) => {
9
- if (acc == null) {
10
- if (
11
- // pass conditional expressions through
12
- t.isConditionalExpression(val) ||
13
- // pass non-null literals through
14
- t.isStringLiteral(val) ||
15
- t.isNumericLiteral(val)
16
- ) {
17
- return val
18
- }
19
- return t.logicalExpression('||', val, t.stringLiteral(''))
20
- }
21
-
22
- let inner: t.Expression
23
- if (t.isStringLiteral(val)) {
24
- if (t.isStringLiteral(acc)) {
25
- // join adjacent string literals
26
- return t.stringLiteral(`${acc.value} ${val.value}`)
27
- }
28
- inner = t.stringLiteral(` ${val.value}`)
29
- } else if (t.isLiteral(val)) {
30
- inner = t.binaryExpression('+', t.stringLiteral(' '), val)
31
- } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {
32
- if (t.isStringLiteral(acc)) {
33
- return t.binaryExpression('+', t.stringLiteral(`${acc.value} `), val)
34
- }
35
- inner = t.binaryExpression('+', t.stringLiteral(' '), val)
36
- } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {
37
- // identifiers and member expressions make for reasonable ternaries
38
- inner = t.conditionalExpression(
39
- val,
40
- t.binaryExpression('+', t.stringLiteral(' '), val),
41
- t.stringLiteral('')
42
- )
43
- } else {
44
- if (t.isStringLiteral(acc)) {
45
- return t.binaryExpression(
46
- '+',
47
- t.stringLiteral(`${acc.value} `),
48
- t.logicalExpression('||', val, t.stringLiteral(''))
49
- )
50
- }
51
- // use a logical expression for more complex prop values
52
- inner = t.binaryExpression(
53
- '+',
54
- t.stringLiteral(' '),
55
- t.logicalExpression('||', val, t.stringLiteral(''))
56
- )
57
- }
58
-
59
- return t.binaryExpression('+', acc, inner)
60
- }, null)
61
- }
@@ -1,68 +0,0 @@
1
- import vm from 'vm'
2
-
3
- import generate from '@babel/generator'
4
- import { NodePath } from '@babel/traverse'
5
- import * as t from '@babel/types'
6
- import type { TamaguiConfig } from '@tamagui/core'
7
-
8
- import { FAILED_EVAL } from './createExtractor'
9
- import { evaluateAstNode } from './evaluateAstNode'
10
- import { isValidThemeHook } from './extractHelpers'
11
-
12
- export function createEvaluator({
13
- tamaguiConfig,
14
- staticNamespace,
15
- sourcePath,
16
- traversePath,
17
- shouldPrintDebug,
18
- }: {
19
- tamaguiConfig: TamaguiConfig
20
- staticNamespace: Record<string, any>
21
- sourcePath: string
22
- traversePath: NodePath<t.JSXElement>
23
- shouldPrintDebug: boolean
24
- }) {
25
- // called when evaluateAstNode encounters a dynamic-looking prop
26
- const evalFn = (n: t.Node) => {
27
- // themes
28
- if (
29
- t.isMemberExpression(n) &&
30
- t.isIdentifier(n.property) &&
31
- isValidThemeHook(traversePath, n, sourcePath)
32
- ) {
33
- const key = n.property.name
34
- if (shouldPrintDebug) {
35
- console.log(' > found theme prop', key)
36
- }
37
- console.log('SHOULD FIND THEME (NESTED NOW)', key) // tamaguiConfig.themes)
38
- // if (!themeKeys.has(key)) {
39
- // throw new Error(` > accessing non-existent theme key: ${key}`)
40
- // }
41
- return `var(--${key})`
42
- }
43
- // variable
44
- if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {
45
- return staticNamespace[n.name]
46
- }
47
- const evalContext = vm.createContext(staticNamespace)
48
- const code = `(${generate(n as any).code})`
49
- // if (shouldPrintDebug) {
50
- // console.log('evaluating', { n, code, evalContext })
51
- // }
52
- return vm.runInContext(code, evalContext)
53
- }
54
-
55
- return (n: t.Node) => {
56
- return evaluateAstNode(n, evalFn)
57
- }
58
- }
59
-
60
- export function createSafeEvaluator(attemptEval: (n: t.Node) => any) {
61
- return (n: t.Node) => {
62
- try {
63
- return attemptEval(n)
64
- } catch (err) {
65
- return FAILED_EVAL
66
- }
67
- }
68
- }