@tamagui/static 1.0.1-beta.192 → 1.0.1-beta.194
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/extractor/babelParse.js.map +2 -2
- package/dist/extractor/bundle.js +117 -0
- package/dist/extractor/bundle.js.map +7 -0
- package/dist/extractor/createExtractor.js +147 -79
- package/dist/extractor/createExtractor.js.map +3 -3
- package/dist/extractor/extractHelpers.js +41 -6
- package/dist/extractor/extractHelpers.js.map +2 -2
- package/dist/extractor/extractToClassNames.js +2 -1
- package/dist/extractor/extractToClassNames.js.map +2 -2
- package/dist/extractor/getPropValueFromAttributes.js.map +2 -2
- package/dist/extractor/loadTamagui.js +219 -117
- package/dist/extractor/loadTamagui.js.map +3 -3
- package/dist/extractor/normalizeTernaries.js.map +2 -2
- package/dist/getPragmaOptions.js +1 -1
- package/dist/getPragmaOptions.js.map +2 -2
- package/dist/index.js +0 -1
- package/dist/index.js.map +2 -2
- package/dist/require.js +13 -7
- package/dist/require.js.map +2 -2
- package/dist/tamagui-node/tamagui.config.js +6781 -0
- package/dist/tamagui-node/tamaguicore-components.config.js +0 -0
- package/dist/tamagui-node/tamaguitestdesignsystem-components.config.js +31 -0
- package/dist/types.js.map +1 -1
- package/package.json +20 -17
- package/src/extractor/babelParse.ts +3 -2
- package/src/extractor/bundle.ts +110 -0
- package/src/extractor/createExtractor.ts +167 -70
- package/src/extractor/extractHelpers.ts +57 -10
- package/src/extractor/extractToClassNames.ts +12 -9
- package/src/extractor/getPropValueFromAttributes.ts +1 -1
- package/src/extractor/loadTamagui.ts +256 -145
- package/src/extractor/normalizeTernaries.ts +1 -1
- package/src/getPragmaOptions.ts +2 -1
- package/src/index.ts +0 -1
- package/src/require.ts +16 -8
- package/src/types.ts +5 -1
- package/types/extractor/babelParse.d.ts +2 -1
- package/types/extractor/bundle.d.ts +13 -0
- package/types/extractor/extractHelpers.d.ts +13 -3
- package/types/extractor/extractToClassNames.d.ts +3 -2
- package/types/extractor/findTopmostFunction.d.ts +1 -1
- package/types/extractor/loadTamagui.d.ts +9 -2
- package/types/index.d.ts +0 -1
- package/types/types.d.ts +4 -1
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
|
|
5
|
+
// ../test-design-system/dist/cjs/index.js
|
|
6
|
+
var __defProp2 = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = /* @__PURE__ */ __name((target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
}, "__export");
|
|
14
|
+
var __copyProps = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
}, "__copyProps");
|
|
22
|
+
var __toCommonJS = /* @__PURE__ */ __name((mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
MyStack: () => MyStack
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
var import_core = require("@tamagui/core-node");
|
|
29
|
+
var MyStack = (0, import_core.styled)(import_core.Stack, {
|
|
30
|
+
backgroundColor: "green"
|
|
31
|
+
});
|
package/dist/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { PseudoStyles, StaticConfig } from '@tamagui/core-node'\nimport type { StyleObject } from '@tamagui/helpers'\nimport type { TamaguiOptions } from '@tamagui/helpers-node'\nimport type { ViewStyle } from 'react-native'\n\nexport type { TamaguiOptions } from '@tamagui/helpers-node'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface LogOptions {\n clear?: boolean\n timestamp?: boolean\n error?: Error | null\n}\n\nexport interface Logger {\n info(msg: string, options?: LogOptions): void\n warn(msg: string, options?: LogOptions): void\n error(msg: string, options?: LogOptions): void\n}\n\nexport type ExtractorOptions = {\n logger?: Logger\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n completeProps: Record<string, any>\n staticConfig: StaticConfig\n}\n\nexport type TamaguiOptionsWithFileInfo = TamaguiOptions & {\n sourcePath: string\n}\n\nexport type ExtractorParseProps = TamaguiOptionsWithFileInfo & {\n target: 'native' | 'html'\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode?: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { PseudoStyles, StaticConfig } from '@tamagui/core-node'\nimport type { StyleObject } from '@tamagui/helpers'\nimport type { TamaguiOptions } from '@tamagui/helpers-node'\nimport type { ViewStyle } from 'react-native'\n\nimport { LoadedComponents } from './index'\n\nexport type { TamaguiOptions } from '@tamagui/helpers-node'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface LogOptions {\n clear?: boolean\n timestamp?: boolean\n error?: Error | null\n}\n\nexport interface Logger {\n info(msg: string, options?: LogOptions): void\n warn(msg: string, options?: LogOptions): void\n error(msg: string, options?: LogOptions): void\n}\n\nexport type ExtractorOptions = {\n logger?: Logger\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n parserProps: TamaguiOptionsWithFileInfo\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n completeProps: Record<string, any>\n staticConfig: StaticConfig\n}\n\nexport type TamaguiOptionsWithFileInfo = TamaguiOptions & {\n sourcePath: string\n allLoadedComponents: LoadedComponents[]\n}\n\nexport type ExtractorParseProps = Omit<TamaguiOptionsWithFileInfo, 'allLoadedComponents'> & {\n target: 'native' | 'html'\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode?: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.194",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist",
|
|
7
7
|
"files": [
|
|
8
8
|
"tamagui.tsconfig.json",
|
|
9
|
-
"patches",
|
|
10
9
|
"src",
|
|
11
10
|
"types",
|
|
12
11
|
"dist"
|
|
@@ -37,39 +36,43 @@
|
|
|
37
36
|
"@babel/runtime": "^7.18.9",
|
|
38
37
|
"@babel/traverse": "^7.18.11",
|
|
39
38
|
"@expo/match-media": "^0.3.0",
|
|
40
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
41
|
-
"@tamagui/cli-color": "^1.0.1-beta.
|
|
42
|
-
"@tamagui/config-default-node": "^1.0.1-beta.
|
|
43
|
-
"@tamagui/core-node": "^1.0.1-beta.
|
|
44
|
-
"@tamagui/fake-react-native": "^1.0.1-beta.
|
|
45
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
46
|
-
"@tamagui/helpers-node": "^1.0.1-beta.
|
|
47
|
-
"@tamagui/
|
|
48
|
-
"@tamagui/
|
|
49
|
-
"@tamagui/
|
|
50
|
-
"@tamagui/shorthands": "^1.0.1-beta.
|
|
39
|
+
"@tamagui/build": "^1.0.1-beta.194",
|
|
40
|
+
"@tamagui/cli-color": "^1.0.1-beta.194",
|
|
41
|
+
"@tamagui/config-default-node": "^1.0.1-beta.194",
|
|
42
|
+
"@tamagui/core-node": "^1.0.1-beta.194",
|
|
43
|
+
"@tamagui/fake-react-native": "^1.0.1-beta.194",
|
|
44
|
+
"@tamagui/helpers": "^1.0.1-beta.194",
|
|
45
|
+
"@tamagui/helpers-node": "^1.0.1-beta.194",
|
|
46
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.194",
|
|
47
|
+
"@tamagui/react-native-svg": "^1.0.1-beta.194",
|
|
48
|
+
"@tamagui/rnw": "^1.0.1-beta.194",
|
|
49
|
+
"@tamagui/shorthands": "^1.0.1-beta.194",
|
|
51
50
|
"babel-literal-to-ast": "^2.1.0",
|
|
52
|
-
"esbuild": "^0.15.
|
|
51
|
+
"esbuild": "^0.15.11",
|
|
53
52
|
"esbuild-register": "^3.3.3",
|
|
54
53
|
"find-cache-dir": "^3.3.2",
|
|
55
54
|
"find-root": "^1.1.0",
|
|
56
55
|
"fs-extra": "^10.1.0",
|
|
57
56
|
"invariant": "^2.2.4",
|
|
58
57
|
"lodash": "^4.17.21",
|
|
59
|
-
"react-native-web-lite": "^1.0.1-beta.
|
|
60
|
-
"tamagui": "^1.0.1-beta.
|
|
58
|
+
"react-native-web-lite": "^1.0.1-beta.194",
|
|
59
|
+
"tamagui": "^1.0.1-beta.194"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
62
|
"@babel/plugin-syntax-typescript": "^7.18.6",
|
|
64
|
-
"@babel/types": "^7.
|
|
63
|
+
"@babel/types": "^7.19.4",
|
|
65
64
|
"@dish/babel-preset": "^0.0.6",
|
|
65
|
+
"@tamagui/test-design-system": "^1.0.1-beta.194",
|
|
66
66
|
"@testing-library/react": "^13.3.0",
|
|
67
|
+
"@types/babel__generator": "^7.6.4",
|
|
68
|
+
"@types/babel__traverse": "^7.18.2",
|
|
67
69
|
"@types/find-root": "^1.1.2",
|
|
68
70
|
"@types/node": "^16.11.9",
|
|
69
71
|
"@types/react-native": "^0.69.2",
|
|
70
72
|
"@types/webpack": "^4.41.26",
|
|
71
73
|
"babel-loader": "^8.2.5",
|
|
72
74
|
"css-loader": "^5.2.4",
|
|
75
|
+
"dedent": "^0.7.0",
|
|
73
76
|
"esbuild-loader": "^2.19.0",
|
|
74
77
|
"null-loader": "^4.0.1",
|
|
75
78
|
"react": "*",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as babelParser from '@babel/parser'
|
|
2
|
+
import * as t from '@babel/types'
|
|
2
3
|
|
|
3
4
|
const plugins: babelParser.ParserPlugin[] = [
|
|
4
5
|
'asyncGenerators',
|
|
@@ -22,6 +23,6 @@ export const parserOptions: babelParser.ParserOptions = Object.freeze({
|
|
|
22
23
|
|
|
23
24
|
const parser = babelParser.parse.bind(babelParser)
|
|
24
25
|
|
|
25
|
-
export function babelParse(code: string | Buffer):
|
|
26
|
-
return parser(code.toString(), parserOptions)
|
|
26
|
+
export function babelParse(code: string | Buffer): t.File {
|
|
27
|
+
return parser(code.toString(), parserOptions) as any
|
|
27
28
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { basename, dirname, join } from 'path'
|
|
2
|
+
|
|
3
|
+
import esbuild from 'esbuild'
|
|
4
|
+
import { pathExists, stat, writeFile } from 'fs-extra'
|
|
5
|
+
|
|
6
|
+
import { resolveWebOrNativeSpecificEntry } from './loadTamagui'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* For internal loading of new files
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type Props = Omit<Partial<esbuild.BuildOptions>, 'entryPoints'> & {
|
|
13
|
+
outfile: string
|
|
14
|
+
entryPoints: string[]
|
|
15
|
+
resolvePlatformSpecificEntries?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getESBuildConfig(
|
|
19
|
+
{ entryPoints, resolvePlatformSpecificEntries, ...options }: Props,
|
|
20
|
+
aliases?: Record<string, string>
|
|
21
|
+
) {
|
|
22
|
+
const alias = require('@tamagui/core-node').aliasPlugin
|
|
23
|
+
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log(`Building`, entryPoints)
|
|
26
|
+
}
|
|
27
|
+
const tsconfig = join(__dirname, '..', '..', 'tamagui.tsconfig.json')
|
|
28
|
+
|
|
29
|
+
const resolvedEntryPoints = !resolvePlatformSpecificEntries
|
|
30
|
+
? entryPoints
|
|
31
|
+
: entryPoints.map(resolveWebOrNativeSpecificEntry)
|
|
32
|
+
|
|
33
|
+
const res: esbuild.BuildOptions = {
|
|
34
|
+
bundle: true,
|
|
35
|
+
entryPoints: resolvedEntryPoints,
|
|
36
|
+
format: 'cjs',
|
|
37
|
+
target: 'node18',
|
|
38
|
+
jsx: 'transform',
|
|
39
|
+
jsxFactory: 'react',
|
|
40
|
+
allowOverwrite: true,
|
|
41
|
+
keepNames: true,
|
|
42
|
+
platform: 'node',
|
|
43
|
+
tsconfig,
|
|
44
|
+
loader: {
|
|
45
|
+
'.js': 'jsx',
|
|
46
|
+
},
|
|
47
|
+
logLevel: 'warning',
|
|
48
|
+
plugins: [
|
|
49
|
+
{
|
|
50
|
+
name: 'external',
|
|
51
|
+
setup(build) {
|
|
52
|
+
build.onResolve({ filter: /@tamagui\/core/ }, (args) => {
|
|
53
|
+
return {
|
|
54
|
+
path: '@tamagui/core-node',
|
|
55
|
+
external: true,
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
build.onResolve({ filter: /^(react-native|react-native\/.*)$/ }, (args) => {
|
|
60
|
+
return {
|
|
61
|
+
path: 'react-native-web-lite',
|
|
62
|
+
external: true,
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
alias({
|
|
68
|
+
...aliases,
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
...options,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return res
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function bundle(props: Props, aliases?: Record<string, string>) {
|
|
78
|
+
await asyncLock(props)
|
|
79
|
+
return esbuild.build(getESBuildConfig(props, aliases))
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function bundleSync(props: Props, aliases?: Record<string, string>) {
|
|
83
|
+
return esbuild.buildSync(getESBuildConfig(props, aliases))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// until i do fancier things w plugins:
|
|
87
|
+
async function asyncLock(props: Props) {
|
|
88
|
+
const lockFile = join(dirname(props.outfile), basename(props.outfile, '.lock'))
|
|
89
|
+
const lockStat = await stat(lockFile).catch(() => {
|
|
90
|
+
/* ok */
|
|
91
|
+
})
|
|
92
|
+
const lockedMsAgo = !lockStat
|
|
93
|
+
? Infinity
|
|
94
|
+
: new Date().getTime() - new Date(lockStat.mtime).getTime()
|
|
95
|
+
if (lockedMsAgo < 500) {
|
|
96
|
+
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
97
|
+
// eslint-disable-next-line no-console
|
|
98
|
+
console.log(`Waiting for existing build`, props.entryPoints)
|
|
99
|
+
}
|
|
100
|
+
let tries = 5
|
|
101
|
+
while (tries--) {
|
|
102
|
+
if (await pathExists(props.outfile)) {
|
|
103
|
+
return
|
|
104
|
+
} else {
|
|
105
|
+
await new Promise((res) => setTimeout(res, 50))
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
void writeFile(lockFile, '')
|
|
110
|
+
}
|