@tamagui/static 1.0.1-beta.68 → 1.0.1-beta.71
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 +17 -31
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.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 +17 -31
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/extractor/createEvaluator.js +1 -1
- package/dist/jsx/extractor/createExtractor.js +232 -119
- package/dist/jsx/extractor/extractToClassNames.js +17 -31
- package/dist/jsx/index.js +1 -1
- package/package.json +19 -13
- package/src/extractor/createEvaluator.ts +2 -1
- package/src/extractor/createExtractor.ts +356 -161
- package/src/extractor/extractToClassNames.ts +20 -50
- package/src/index.ts +1 -1
- package/src/types.ts +6 -8
- package/types/constants.d.ts +0 -0
- package/types/constants.d.ts.map +0 -0
- package/types/extractor/accessSafe.d.ts +0 -0
- package/types/extractor/accessSafe.d.ts.map +0 -0
- package/types/extractor/babelParse.d.ts +0 -0
- package/types/extractor/babelParse.d.ts.map +0 -0
- package/types/extractor/buildClassName.d.ts +0 -0
- package/types/extractor/buildClassName.d.ts.map +0 -0
- 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/ensureImportingConcat.d.ts +0 -0
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -0
- package/types/extractor/evaluateAstNode.d.ts +0 -0
- package/types/extractor/evaluateAstNode.d.ts.map +0 -0
- package/types/extractor/extractHelpers.d.ts +0 -0
- package/types/extractor/extractHelpers.d.ts.map +0 -0
- package/types/extractor/extractMediaStyle.d.ts +0 -0
- package/types/extractor/extractMediaStyle.d.ts.map +0 -0
- package/types/extractor/extractToClassNames.d.ts +1 -6
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -0
- package/types/extractor/findTopmostFunction.d.ts.map +0 -0
- package/types/extractor/generatedUid.d.ts +0 -0
- package/types/extractor/generatedUid.d.ts.map +0 -0
- package/types/extractor/getPrefixLogs.d.ts +0 -0
- package/types/extractor/getPrefixLogs.d.ts.map +0 -0
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -0
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -0
- package/types/extractor/getSourceModule.d.ts +0 -0
- package/types/extractor/getSourceModule.d.ts.map +0 -0
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -0
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -0
- package/types/extractor/hoistClassNames.d.ts +0 -0
- package/types/extractor/hoistClassNames.d.ts.map +0 -0
- package/types/extractor/literalToAst.d.ts +0 -0
- package/types/extractor/literalToAst.d.ts.map +0 -0
- package/types/extractor/loadTamagui.d.ts +0 -0
- package/types/extractor/loadTamagui.d.ts.map +0 -0
- package/types/extractor/logLines.d.ts +0 -0
- package/types/extractor/logLines.d.ts.map +0 -0
- package/types/extractor/normalizeTernaries.d.ts +0 -0
- package/types/extractor/normalizeTernaries.d.ts.map +0 -0
- package/types/extractor/removeUnusedHooks.d.ts +0 -0
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -0
- package/types/extractor/timer.d.ts +0 -0
- package/types/extractor/timer.d.ts.map +0 -0
- package/types/extractor/validHTMLAttributes.d.ts +0 -0
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -0
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +4 -7
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/patchReactNativeWeb.js +0 -167
- package/dist/cjs/patchReactNativeWeb.js.map +0 -7
- package/dist/esm/patchReactNativeWeb.js +0 -142
- package/dist/esm/patchReactNativeWeb.js.map +0 -7
- package/dist/jsx/patchReactNativeWeb.js +0 -141
- package/src/patchReactNativeWeb.ts +0 -165
- package/types/patchReactNativeWeb.d.ts +0 -2
- package/types/patchReactNativeWeb.d.ts.map +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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(dir: string = require.resolve('react-native-web')) {\n const rootDir = dir.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": "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",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import path from "path";
|
|
4
|
-
import * as fs from "fs-extra";
|
|
5
|
-
function patchReactNativeWeb(dir = require.resolve("react-native-web")) {
|
|
6
|
-
const rootDir = dir.replace(/[\/\\]dist.*/, "");
|
|
7
|
-
const modulePath = path.join(rootDir, "dist", "tamagui-exports.js");
|
|
8
|
-
const cjsPath = path.join(rootDir, "dist", "cjs", "tamagui-exports.js");
|
|
9
|
-
const shouldPatchExports = fs.existsSync(modulePath) && fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.existsSync(cjsPath) && fs.readFileSync(cjsPath, "utf-8") === cjsExports;
|
|
10
|
-
if (!shouldPatchExports) {
|
|
11
|
-
console.log(" | patch " + path.relative(rootDir, modulePath));
|
|
12
|
-
console.log(" | patch " + path.relative(rootDir, cjsPath));
|
|
13
|
-
fs.writeFileSync(modulePath, moduleExports);
|
|
14
|
-
fs.writeFileSync(cjsPath, cjsExports);
|
|
15
|
-
}
|
|
16
|
-
const patches = [
|
|
17
|
-
{
|
|
18
|
-
id: "dom-props",
|
|
19
|
-
filePath: ["modules", "createDOMProps", "index.js"],
|
|
20
|
-
replacee: ` if (dataSet != null) {`,
|
|
21
|
-
replacer: `
|
|
22
|
-
if (props.dataSet && props.dataSet.className) {
|
|
23
|
-
const { className, ...dataSetRest } = props.dataSet
|
|
24
|
-
classList = className
|
|
25
|
-
dataSet = dataSetRest
|
|
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
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const moduleEntry = path.join(rootDir, "dist", "index.js");
|
|
61
|
-
const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
|
|
62
|
-
if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
|
|
63
|
-
fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
|
|
64
|
-
|
|
65
|
-
// tamagui-patch-v4
|
|
66
|
-
import * as TExports from './tamagui-exports'
|
|
67
|
-
export const TamaguiExports = TExports
|
|
68
|
-
// tamagui-patch-end
|
|
69
|
-
`);
|
|
70
|
-
}
|
|
71
|
-
const cjsEntry = path.join(rootDir, "dist", "cjs", "index.js");
|
|
72
|
-
const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
|
|
73
|
-
if (!cjsEntrySrc.includes("// tamagui-patch-v4")) {
|
|
74
|
-
fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
|
|
75
|
-
|
|
76
|
-
// tamagui-patch-v4
|
|
77
|
-
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
78
|
-
// tamagui-patch-end
|
|
79
|
-
`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
__name(patchReactNativeWeb, "patchReactNativeWeb");
|
|
83
|
-
function removePatch(source) {
|
|
84
|
-
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
|
|
85
|
-
}
|
|
86
|
-
__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
|
-
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
|
-
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
|
-
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
113
|
-
export { default as pick } from './modules/pick'
|
|
114
|
-
export { default as useElementLayout } from './modules/useElementLayout'
|
|
115
|
-
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
116
|
-
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
117
|
-
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
118
|
-
import * as fwdProps from './modules/forwardedProps'
|
|
119
|
-
export const forwardedProps = ${forwardedPropsObj}
|
|
120
|
-
`;
|
|
121
|
-
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
|
-
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
|
-
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
131
|
-
exports.pick = require('./modules/pick')
|
|
132
|
-
exports.useElementLayout = require('./modules/useElementLayout')
|
|
133
|
-
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
134
|
-
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
135
|
-
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
136
|
-
const fwdProps = require('./modules/forwardedProps')
|
|
137
|
-
exports.forwardedProps = ${forwardedPropsObj}
|
|
138
|
-
`;
|
|
139
|
-
export {
|
|
140
|
-
patchReactNativeWeb
|
|
141
|
-
};
|
|
142
|
-
//# sourceMappingURL=patchReactNativeWeb.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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(dir: string = require.resolve('react-native-web')) {\n const rootDir = dir.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;AAEA;AAQO,6BAA6B,MAA8B,qCAAqB;AACrF,QAAM,UAAU,IAAI,QAAQ,gBAAgB,EAAE;AAC9C,QAAM,aAAa,KAAK,KAAK,SAAS,QAAQ,oBAAoB;AAClE,QAAM,UAAU,KAAK,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,KAAK,SAAS,SAAS,UAAU,CAAC;AACjE,YAAQ,IAAI,mBAAmB,KAAK,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,KAAK,KAAK,SAAS,QAAQ,GAAG,QAAQ;AAAA,MACtC,KAAK,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,KAAK,SAAS,SAAS,IAAI,CAAC;AAC3D,SAAG,cAAc,MAAM,SAAS,QAAQ,UAAU,QAAQ,CAAC;AAAA,IAC7D;AAAA,EACF;AAGA,QAAM,cAAc,KAAK,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,KAAK,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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import path from "path";
|
|
4
|
-
import * as fs from "fs-extra";
|
|
5
|
-
function patchReactNativeWeb(dir = require.resolve("react-native-web")) {
|
|
6
|
-
const rootDir = dir.replace(/[\/\\]dist.*/, "");
|
|
7
|
-
const modulePath = path.join(rootDir, "dist", "tamagui-exports.js");
|
|
8
|
-
const cjsPath = path.join(rootDir, "dist", "cjs", "tamagui-exports.js");
|
|
9
|
-
const shouldPatchExports = fs.existsSync(modulePath) && fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.existsSync(cjsPath) && fs.readFileSync(cjsPath, "utf-8") === cjsExports;
|
|
10
|
-
if (!shouldPatchExports) {
|
|
11
|
-
console.log(" | patch " + path.relative(rootDir, modulePath));
|
|
12
|
-
console.log(" | patch " + path.relative(rootDir, cjsPath));
|
|
13
|
-
fs.writeFileSync(modulePath, moduleExports);
|
|
14
|
-
fs.writeFileSync(cjsPath, cjsExports);
|
|
15
|
-
}
|
|
16
|
-
const patches = [
|
|
17
|
-
{
|
|
18
|
-
id: "dom-props",
|
|
19
|
-
filePath: ["modules", "createDOMProps", "index.js"],
|
|
20
|
-
replacee: ` if (dataSet != null) {`,
|
|
21
|
-
replacer: `
|
|
22
|
-
if (props.dataSet && props.dataSet.className) {
|
|
23
|
-
const { className, ...dataSetRest } = props.dataSet
|
|
24
|
-
classList = className
|
|
25
|
-
dataSet = dataSetRest
|
|
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
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const moduleEntry = path.join(rootDir, "dist", "index.js");
|
|
61
|
-
const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
|
|
62
|
-
if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
|
|
63
|
-
fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
|
|
64
|
-
|
|
65
|
-
// tamagui-patch-v4
|
|
66
|
-
import * as TExports from './tamagui-exports'
|
|
67
|
-
export const TamaguiExports = TExports
|
|
68
|
-
// tamagui-patch-end
|
|
69
|
-
`);
|
|
70
|
-
}
|
|
71
|
-
const cjsEntry = path.join(rootDir, "dist", "cjs", "index.js");
|
|
72
|
-
const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
|
|
73
|
-
if (!cjsEntrySrc.includes("// tamagui-patch-v4")) {
|
|
74
|
-
fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
|
|
75
|
-
|
|
76
|
-
// tamagui-patch-v4
|
|
77
|
-
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
78
|
-
// tamagui-patch-end
|
|
79
|
-
`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
__name(patchReactNativeWeb, "patchReactNativeWeb");
|
|
83
|
-
function removePatch(source) {
|
|
84
|
-
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
|
|
85
|
-
}
|
|
86
|
-
__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
|
-
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
|
-
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
|
-
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
113
|
-
export { default as pick } from './modules/pick'
|
|
114
|
-
export { default as useElementLayout } from './modules/useElementLayout'
|
|
115
|
-
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
116
|
-
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
117
|
-
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
118
|
-
import * as fwdProps from './modules/forwardedProps'
|
|
119
|
-
export const forwardedProps = ${forwardedPropsObj}
|
|
120
|
-
`;
|
|
121
|
-
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
|
-
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
|
-
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
131
|
-
exports.pick = require('./modules/pick')
|
|
132
|
-
exports.useElementLayout = require('./modules/useElementLayout')
|
|
133
|
-
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
134
|
-
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
135
|
-
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
136
|
-
const fwdProps = require('./modules/forwardedProps')
|
|
137
|
-
exports.forwardedProps = ${forwardedPropsObj}
|
|
138
|
-
`;
|
|
139
|
-
export {
|
|
140
|
-
patchReactNativeWeb
|
|
141
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
|
|
3
|
-
import * as fs from 'fs-extra'
|
|
4
|
-
|
|
5
|
-
// were patching react-native-web so we can use some internal methods
|
|
6
|
-
// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm
|
|
7
|
-
// so we can't just require it all directly
|
|
8
|
-
// would be nice in the future to be able to eject from react-native-web entirely optionally
|
|
9
|
-
|
|
10
|
-
// keep it sync
|
|
11
|
-
export function patchReactNativeWeb(dir: string = require.resolve('react-native-web')) {
|
|
12
|
-
const rootDir = dir.replace(/[\/\\]dist.*/, '')
|
|
13
|
-
const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')
|
|
14
|
-
const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')
|
|
15
|
-
const shouldPatchExports =
|
|
16
|
-
fs.existsSync(modulePath) &&
|
|
17
|
-
fs.readFileSync(modulePath, 'utf-8') === moduleExports &&
|
|
18
|
-
fs.existsSync(cjsPath) &&
|
|
19
|
-
fs.readFileSync(cjsPath, 'utf-8') === cjsExports
|
|
20
|
-
if (!shouldPatchExports) {
|
|
21
|
-
console.log(' | patch ' + path.relative(rootDir, modulePath))
|
|
22
|
-
console.log(' | patch ' + path.relative(rootDir, cjsPath))
|
|
23
|
-
fs.writeFileSync(modulePath, moduleExports)
|
|
24
|
-
fs.writeFileSync(cjsPath, cjsExports)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// patch to allow className prop
|
|
28
|
-
const patches = [
|
|
29
|
-
{
|
|
30
|
-
id: 'dom-props',
|
|
31
|
-
filePath: ['modules', 'createDOMProps', 'index.js'],
|
|
32
|
-
replacee: ` if (dataSet != null) {`,
|
|
33
|
-
replacer: `
|
|
34
|
-
if (props.dataSet && props.dataSet.className) {
|
|
35
|
-
const { className, ...dataSetRest } = props.dataSet
|
|
36
|
-
classList = className
|
|
37
|
-
dataSet = dataSetRest
|
|
38
|
-
}
|
|
39
|
-
if (props.dataSet && props.dataSet.id) {
|
|
40
|
-
domProps['id'] = props.dataSet.id
|
|
41
|
-
}
|
|
42
|
-
if (dataSet != null) {`,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'forward-props',
|
|
46
|
-
filePath: ['modules', 'forwardedProps', 'index.js'],
|
|
47
|
-
replacee: `dataSet: true,`,
|
|
48
|
-
replacer: `id: true, dataSet: true,`,
|
|
49
|
-
},
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
for (const { filePath, replacee, replacer } of patches) {
|
|
53
|
-
const files = [
|
|
54
|
-
path.join(rootDir, 'dist', ...filePath),
|
|
55
|
-
path.join(rootDir, 'dist', 'cjs', ...filePath),
|
|
56
|
-
]
|
|
57
|
-
for (const file of files) {
|
|
58
|
-
const contents = fs.readFileSync(file, 'utf-8')
|
|
59
|
-
if (contents.includes(replacer)) {
|
|
60
|
-
continue
|
|
61
|
-
}
|
|
62
|
-
if (!contents.includes(replacee)) {
|
|
63
|
-
console.warn(
|
|
64
|
-
`⚠️ Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`,
|
|
65
|
-
{
|
|
66
|
-
replacee,
|
|
67
|
-
contents,
|
|
68
|
-
}
|
|
69
|
-
)
|
|
70
|
-
continue
|
|
71
|
-
}
|
|
72
|
-
console.log(' | patch ' + path.relative(rootDir, file))
|
|
73
|
-
fs.writeFileSync(file, contents.replace(replacee, replacer))
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// if entry files not patched, patch them:
|
|
78
|
-
const moduleEntry = path.join(rootDir, 'dist', 'index.js')
|
|
79
|
-
const moduleEntrySrc = fs.readFileSync(moduleEntry, 'utf-8')
|
|
80
|
-
if (!moduleEntrySrc.includes('// tamagui-patch-v4')) {
|
|
81
|
-
fs.writeFileSync(
|
|
82
|
-
moduleEntry,
|
|
83
|
-
`${removePatch(moduleEntrySrc)}
|
|
84
|
-
|
|
85
|
-
// tamagui-patch-v4
|
|
86
|
-
import * as TExports from './tamagui-exports'
|
|
87
|
-
export const TamaguiExports = TExports
|
|
88
|
-
// tamagui-patch-end
|
|
89
|
-
`
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
const cjsEntry = path.join(rootDir, 'dist', 'cjs', 'index.js')
|
|
93
|
-
const cjsEntrySrc = fs.readFileSync(cjsEntry, 'utf-8')
|
|
94
|
-
if (!cjsEntrySrc.includes('// tamagui-patch-v4')) {
|
|
95
|
-
fs.writeFileSync(
|
|
96
|
-
cjsEntry,
|
|
97
|
-
`${removePatch(cjsEntrySrc)}
|
|
98
|
-
|
|
99
|
-
// tamagui-patch-v4
|
|
100
|
-
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
101
|
-
// tamagui-patch-end
|
|
102
|
-
`
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function removePatch(source: string) {
|
|
108
|
-
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, '')
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// view exports/View.ts
|
|
112
|
-
const forwardedPropsObj = `{
|
|
113
|
-
...fwdProps.defaultProps,
|
|
114
|
-
...fwdProps.accessibilityProps,
|
|
115
|
-
...fwdProps.clickProps,
|
|
116
|
-
...fwdProps.focusProps,
|
|
117
|
-
...fwdProps.keyboardProps,
|
|
118
|
-
...fwdProps.mouseProps,
|
|
119
|
-
...fwdProps.touchProps,
|
|
120
|
-
...fwdProps.styleProps,
|
|
121
|
-
href: true,
|
|
122
|
-
lang: true,
|
|
123
|
-
onScroll: true,
|
|
124
|
-
onWheel: true,
|
|
125
|
-
pointerEvents: true
|
|
126
|
-
}
|
|
127
|
-
`
|
|
128
|
-
|
|
129
|
-
const moduleExports = `
|
|
130
|
-
export { atomic } from './exports/StyleSheet/compile'
|
|
131
|
-
export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
|
|
132
|
-
export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
|
|
133
|
-
export { default as i18Style } from './exports/StyleSheet/i18nStyle'
|
|
134
|
-
export { default as createDOMProps } from './modules/createDOMProps'
|
|
135
|
-
export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
|
|
136
|
-
export { default as createElement } from './exports/createElement'
|
|
137
|
-
export { default as css } from './exports/StyleSheet/css'
|
|
138
|
-
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
139
|
-
export { default as pick } from './modules/pick'
|
|
140
|
-
export { default as useElementLayout } from './modules/useElementLayout'
|
|
141
|
-
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
142
|
-
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
143
|
-
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
144
|
-
import * as fwdProps from './modules/forwardedProps'
|
|
145
|
-
export const forwardedProps = ${forwardedPropsObj}
|
|
146
|
-
`
|
|
147
|
-
|
|
148
|
-
const cjsExports = `
|
|
149
|
-
exports.atomic = require('./exports/StyleSheet/compile').atomic
|
|
150
|
-
exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
|
|
151
|
-
exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
|
|
152
|
-
exports.i18Style = require('./exports/StyleSheet/i18nStyle')
|
|
153
|
-
exports.createDOMProps = require('./modules/createDOMProps')
|
|
154
|
-
exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
|
|
155
|
-
exports.createElement = require('./exports/createElement')
|
|
156
|
-
exports.css = require('./exports/StyleSheet/css')
|
|
157
|
-
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
158
|
-
exports.pick = require('./modules/pick')
|
|
159
|
-
exports.useElementLayout = require('./modules/useElementLayout')
|
|
160
|
-
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
161
|
-
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
162
|
-
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
163
|
-
const fwdProps = require('./modules/forwardedProps')
|
|
164
|
-
exports.forwardedProps = ${forwardedPropsObj}
|
|
165
|
-
`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchReactNativeWeb.d.ts","sourceRoot":"","sources":["../src/patchReactNativeWeb.ts"],"names":[],"mappings":"AAUA,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAA4C,QA8FpF"}
|