@tamagui/static 1.0.1-beta.66 → 1.0.1-beta.69
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/cjs/extractor/createEvaluator.js +1 -1
- package/dist/cjs/extractor/createEvaluator.js.map +2 -2
- package/dist/cjs/extractor/createExtractor.js +227 -115
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +16 -20
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/patchReactNativeWeb.js +29 -89
- package/dist/cjs/patchReactNativeWeb.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/extractor/createEvaluator.js +1 -1
- package/dist/esm/extractor/createEvaluator.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +232 -119
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +16 -20
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/patchReactNativeWeb.js +29 -89
- package/dist/esm/patchReactNativeWeb.js.map +2 -2
- package/dist/jsx/extractor/createEvaluator.js +1 -1
- package/dist/jsx/extractor/createExtractor.js +232 -119
- package/dist/jsx/extractor/extractToClassNames.js +16 -20
- package/dist/jsx/patchReactNativeWeb.js +29 -89
- package/package.json +17 -12
- package/src/extractor/createEvaluator.ts +2 -1
- package/src/extractor/createExtractor.ts +356 -161
- package/src/extractor/extractToClassNames.ts +20 -31
- package/src/patchReactNativeWeb.ts +47 -96
- package/src/types.ts +6 -8
- package/types/extractor/createEvaluator.d.ts +1 -1
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +2 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/patchReactNativeWeb.d.ts.map +1 -1
- package/types/types.d.ts +4 -7
- package/types/types.d.ts.map +1 -1
|
@@ -2,80 +2,56 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import path from "path";
|
|
4
4
|
import * as fs from "fs-extra";
|
|
5
|
+
const PATCH_PREFIX = "tamagui-patch-";
|
|
6
|
+
const PATCH_VERSION = `${PATCH_PREFIX}-v5`;
|
|
7
|
+
const PATCH_COMMENT = `// ${PATCH_VERSION}`;
|
|
8
|
+
const PATCH_END_COMMENT = `// tamagui-patch-end`;
|
|
5
9
|
function patchReactNativeWeb(dir = require.resolve("react-native-web")) {
|
|
6
10
|
const rootDir = dir.replace(/[\/\\]dist.*/, "");
|
|
11
|
+
const pkgJSON = fs.readJSONSync(path.join(rootDir, "package.json"));
|
|
12
|
+
if (pkgJSON.version.split(".")[1] !== "18") {
|
|
13
|
+
console.error(`\u26D4\uFE0F Error! Tamagui as of beta 69 only works with react-native-web version 0.18.x`, pkgJSON.version);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
7
16
|
const modulePath = path.join(rootDir, "dist", "tamagui-exports.js");
|
|
8
17
|
const cjsPath = path.join(rootDir, "dist", "cjs", "tamagui-exports.js");
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
18
|
+
const alreadyPatchedImports = fs.existsSync(modulePath) && fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.existsSync(cjsPath) && fs.readFileSync(cjsPath, "utf-8") === cjsExports;
|
|
19
|
+
if (!alreadyPatchedImports) {
|
|
11
20
|
console.log(" | patch " + path.relative(rootDir, modulePath));
|
|
12
|
-
console.log(" | patch " + path.relative(rootDir, cjsPath));
|
|
13
21
|
fs.writeFileSync(modulePath, moduleExports);
|
|
22
|
+
console.log(" | patch " + path.relative(rootDir, cjsPath));
|
|
14
23
|
fs.writeFileSync(cjsPath, cjsExports);
|
|
15
24
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
if (props.dataSet && props.dataSet.id) {
|
|
28
|
-
domProps['id'] = props.dataSet.id
|
|
29
|
-
}
|
|
30
|
-
if (dataSet != null) {`
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: "forward-props",
|
|
34
|
-
filePath: ["modules", "forwardedProps", "index.js"],
|
|
35
|
-
replacee: `dataSet: true,`,
|
|
36
|
-
replacer: `id: true, dataSet: true,`
|
|
37
|
-
}
|
|
38
|
-
];
|
|
39
|
-
for (const { filePath, replacee, replacer } of patches) {
|
|
40
|
-
const files = [
|
|
41
|
-
path.join(rootDir, "dist", ...filePath),
|
|
42
|
-
path.join(rootDir, "dist", "cjs", ...filePath)
|
|
43
|
-
];
|
|
44
|
-
for (const file of files) {
|
|
45
|
-
const contents = fs.readFileSync(file, "utf-8");
|
|
46
|
-
if (contents.includes(replacer)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (!contents.includes(replacee)) {
|
|
50
|
-
console.warn(`\u26A0\uFE0F Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`, {
|
|
51
|
-
replacee,
|
|
52
|
-
contents
|
|
53
|
-
});
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
console.log(" | patch " + path.relative(rootDir, file));
|
|
57
|
-
fs.writeFileSync(file, contents.replace(replacee, replacer));
|
|
58
|
-
}
|
|
25
|
+
const dpFile = path.join(rootDir, "dist", "modules", "createDOMProps", "index.js");
|
|
26
|
+
const dpPatched = fs.readFileSync(path.join(__dirname, "..", "..", "patches", "18", "createDOMProps.js"), "utf-8");
|
|
27
|
+
const dpFileCJS = path.join(rootDir, "dist", "cjs", "modules", "createDOMProps", "index.js");
|
|
28
|
+
const dpCJSPatched = fs.readFileSync(path.join(__dirname, "..", "..", "patches", "18", "createDOMProps.cjs.js"), "utf-8");
|
|
29
|
+
const alreadyPatchedDOMProps = fs.readFileSync(dpFile, "utf-8") === dpPatched && fs.readFileSync(dpFileCJS, "utf-8") === dpCJSPatched;
|
|
30
|
+
if (!alreadyPatchedDOMProps) {
|
|
31
|
+
console.log(" | patch " + path.relative(rootDir, dpFile));
|
|
32
|
+
fs.writeFileSync(dpFile, dpPatched);
|
|
33
|
+
console.log(" | patch " + path.relative(rootDir, dpFileCJS));
|
|
34
|
+
fs.writeFileSync(dpFileCJS, dpCJSPatched);
|
|
59
35
|
}
|
|
60
36
|
const moduleEntry = path.join(rootDir, "dist", "index.js");
|
|
61
37
|
const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
|
|
62
|
-
if (!moduleEntrySrc.includes(
|
|
38
|
+
if (!moduleEntrySrc.includes(PATCH_COMMENT)) {
|
|
63
39
|
fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
|
|
64
40
|
|
|
65
|
-
|
|
41
|
+
${PATCH_COMMENT}
|
|
66
42
|
import * as TExports from './tamagui-exports'
|
|
67
43
|
export const TamaguiExports = TExports
|
|
68
|
-
|
|
44
|
+
${PATCH_END_COMMENT}
|
|
69
45
|
`);
|
|
70
46
|
}
|
|
71
47
|
const cjsEntry = path.join(rootDir, "dist", "cjs", "index.js");
|
|
72
48
|
const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
|
|
73
|
-
if (!cjsEntrySrc.includes(
|
|
49
|
+
if (!cjsEntrySrc.includes(PATCH_COMMENT)) {
|
|
74
50
|
fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
|
|
75
51
|
|
|
76
|
-
|
|
77
|
-
exports.TamaguiExports =
|
|
78
|
-
|
|
52
|
+
${PATCH_COMMENT}
|
|
53
|
+
exports.TamaguiExports = require("./tamagui-exports");
|
|
54
|
+
${PATCH_END_COMMENT}
|
|
79
55
|
`);
|
|
80
56
|
}
|
|
81
57
|
}
|
|
@@ -84,57 +60,21 @@ function removePatch(source) {
|
|
|
84
60
|
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
|
|
85
61
|
}
|
|
86
62
|
__name(removePatch, "removePatch");
|
|
87
|
-
const forwardedPropsObj = `{
|
|
88
|
-
...fwdProps.defaultProps,
|
|
89
|
-
...fwdProps.accessibilityProps,
|
|
90
|
-
...fwdProps.clickProps,
|
|
91
|
-
...fwdProps.focusProps,
|
|
92
|
-
...fwdProps.keyboardProps,
|
|
93
|
-
...fwdProps.mouseProps,
|
|
94
|
-
...fwdProps.touchProps,
|
|
95
|
-
...fwdProps.styleProps,
|
|
96
|
-
href: true,
|
|
97
|
-
lang: true,
|
|
98
|
-
onScroll: true,
|
|
99
|
-
onWheel: true,
|
|
100
|
-
pointerEvents: true
|
|
101
|
-
}
|
|
102
|
-
`;
|
|
103
63
|
const moduleExports = `
|
|
104
|
-
export { atomic } from './exports/StyleSheet/compile'
|
|
105
|
-
export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
|
|
106
|
-
export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
|
|
107
|
-
export { default as i18Style } from './exports/StyleSheet/i18nStyle'
|
|
108
64
|
export { default as createDOMProps } from './modules/createDOMProps'
|
|
109
|
-
export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
|
|
110
|
-
export { default as createElement } from './exports/createElement'
|
|
111
|
-
export { default as css } from './exports/StyleSheet/css'
|
|
112
65
|
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
113
|
-
export { default as pick } from './modules/pick'
|
|
114
66
|
export { default as useElementLayout } from './modules/useElementLayout'
|
|
115
67
|
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
116
68
|
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
117
69
|
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
118
|
-
import * as fwdProps from './modules/forwardedProps'
|
|
119
|
-
export const forwardedProps = ${forwardedPropsObj}
|
|
120
70
|
`;
|
|
121
71
|
const cjsExports = `
|
|
122
|
-
exports.atomic = require('./exports/StyleSheet/compile').atomic
|
|
123
|
-
exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
|
|
124
|
-
exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
|
|
125
|
-
exports.i18Style = require('./exports/StyleSheet/i18nStyle')
|
|
126
72
|
exports.createDOMProps = require('./modules/createDOMProps')
|
|
127
|
-
exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
|
|
128
|
-
exports.createElement = require('./exports/createElement')
|
|
129
|
-
exports.css = require('./exports/StyleSheet/css')
|
|
130
73
|
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
131
|
-
exports.pick = require('./modules/pick')
|
|
132
74
|
exports.useElementLayout = require('./modules/useElementLayout')
|
|
133
75
|
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
134
76
|
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
135
77
|
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
136
|
-
const fwdProps = require('./modules/forwardedProps')
|
|
137
|
-
exports.forwardedProps = ${forwardedPropsObj}
|
|
138
78
|
`;
|
|
139
79
|
export {
|
|
140
80
|
patchReactNativeWeb
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.69",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"clean": "tamagui-build clean",
|
|
18
18
|
"clean:build": "tamagui-build clean:build",
|
|
19
19
|
"test": "NODE_ENV=test TAMAGUI_COMPILE_PROCESS=1 jest --forceExit",
|
|
20
|
-
"test:
|
|
20
|
+
"test:output": "TAMAGUI_TARGET=web node -r esbuild-register test-output.tsx",
|
|
21
|
+
"test:babel": "DISABLE_PRE_TEST=true yarn test tests/babel-test.tsx",
|
|
21
22
|
"test:debug": "NODE_ENV=test TAMAGUI_COMPILE_PROCESS=1 DEBUG_FILE=extract-specs.tsx DEBUG=1 yarn test",
|
|
22
23
|
"test:watch": "NODE_ENV=test TAMAGUI_COMPILE_PROCESS=1 yarn test --watch",
|
|
23
24
|
"test:update-snapshots": "NODE_ENV=test jest --updateSnapshot"
|
|
@@ -36,11 +37,11 @@
|
|
|
36
37
|
"@babel/parser": "^7.15.7",
|
|
37
38
|
"@babel/traverse": "^7.15.4",
|
|
38
39
|
"@expo/match-media": "^0.3.0",
|
|
39
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
40
|
-
"@tamagui/core-node": "^1.0.1-beta.
|
|
41
|
-
"@tamagui/fake-react-native": "^1.0.1-beta.
|
|
42
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
43
|
-
"@tamagui/proxy-worm": "^1.0.1-beta.
|
|
40
|
+
"@tamagui/build": "^1.0.1-beta.69",
|
|
41
|
+
"@tamagui/core-node": "^1.0.1-beta.69",
|
|
42
|
+
"@tamagui/fake-react-native": "^1.0.1-beta.69",
|
|
43
|
+
"@tamagui/helpers": "^1.0.1-beta.69",
|
|
44
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.69",
|
|
44
45
|
"babel-literal-to-ast": "^2.1.0",
|
|
45
46
|
"esbuild": "^0.14.36",
|
|
46
47
|
"esbuild-register": "^3.3.2",
|
|
@@ -48,13 +49,15 @@
|
|
|
48
49
|
"fs-extra": "^9.1.0",
|
|
49
50
|
"invariant": "^2.2.4",
|
|
50
51
|
"lodash": "^4.17.21",
|
|
51
|
-
"tamagui": "^1.0.1-beta.
|
|
52
|
+
"tamagui": "^1.0.1-beta.69"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@babel/plugin-syntax-typescript": "^7.14.5",
|
|
55
56
|
"@babel/types": "^7.15.6",
|
|
56
57
|
"@dish/babel-preset": "^0.0.6",
|
|
57
|
-
"@
|
|
58
|
+
"@tamagui/config-base": "^1.0.1-beta.69",
|
|
59
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
60
|
+
"@testing-library/react": "^13.3.0",
|
|
58
61
|
"@types/jest": "*",
|
|
59
62
|
"@types/node": "^16.11.9",
|
|
60
63
|
"@types/react-native": "^0.67.3",
|
|
@@ -62,15 +65,17 @@
|
|
|
62
65
|
"babel-loader": "^8.2.5",
|
|
63
66
|
"css-loader": "^5.2.4",
|
|
64
67
|
"esbuild-loader": "^2.18.0",
|
|
65
|
-
"jest": "^
|
|
68
|
+
"jest": "^28.1.1",
|
|
69
|
+
"jest-dom": "^4.0.0",
|
|
70
|
+
"jest-environment-jsdom": "^28.1.1",
|
|
66
71
|
"null-loader": "^4.0.1",
|
|
67
72
|
"react": "*",
|
|
68
73
|
"react-dom": "*",
|
|
69
74
|
"react-native-web": "^0.17.5",
|
|
70
|
-
"react-test-renderer": "^18.
|
|
75
|
+
"react-test-renderer": "^18.2.0",
|
|
71
76
|
"style-loader": "^3.3.0",
|
|
72
77
|
"typescript": "^4.7.2",
|
|
73
|
-
"webpack": "^5.
|
|
78
|
+
"webpack": "^5.73.0"
|
|
74
79
|
},
|
|
75
80
|
"peerDependencies": {
|
|
76
81
|
"react-native-web": "*"
|
|
@@ -21,7 +21,7 @@ export function createEvaluator({
|
|
|
21
21
|
tamaguiConfig: TamaguiConfig
|
|
22
22
|
staticNamespace: Record<string, any>
|
|
23
23
|
sourcePath: string
|
|
24
|
-
traversePath
|
|
24
|
+
traversePath?: NodePath<t.JSXElement>
|
|
25
25
|
shouldPrintDebug: boolean | 'verbose'
|
|
26
26
|
}) {
|
|
27
27
|
// called when evaluateAstNode encounters a dynamic-looking prop
|
|
@@ -30,6 +30,7 @@ export function createEvaluator({
|
|
|
30
30
|
if (
|
|
31
31
|
t.isMemberExpression(n) &&
|
|
32
32
|
t.isIdentifier(n.property) &&
|
|
33
|
+
traversePath &&
|
|
33
34
|
isValidThemeHook(traversePath, n, sourcePath)
|
|
34
35
|
) {
|
|
35
36
|
const key = n.property.name
|