@tamagui/static 1.0.0-beta.9 → 1.0.1-beta.101
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/accessSafe.js +0 -2
- package/dist/cjs/extractor/accessSafe.js.map +1 -1
- package/dist/cjs/extractor/babelParse.js +15 -16
- package/dist/cjs/extractor/babelParse.js.map +2 -2
- package/dist/cjs/extractor/buildClassName.js +0 -2
- package/dist/cjs/extractor/buildClassName.js.map +1 -1
- package/dist/cjs/extractor/createEvaluator.js +9 -7
- package/dist/cjs/extractor/createEvaluator.js.map +2 -2
- package/dist/cjs/extractor/createExtractor.js +318 -145
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/ensureImportingConcat.js +0 -2
- package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/cjs/extractor/evaluateAstNode.js +0 -2
- package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
- package/dist/cjs/extractor/extractHelpers.js +11 -16
- package/dist/cjs/extractor/extractHelpers.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.js +3 -8
- package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +27 -42
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/findTopmostFunction.js +1 -3
- package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
- package/dist/cjs/extractor/generatedUid.js +0 -2
- package/dist/cjs/extractor/generatedUid.js.map +1 -1
- package/dist/cjs/extractor/getPrefixLogs.js +0 -2
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -2
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/cjs/extractor/getSourceModule.js +0 -2
- package/dist/cjs/extractor/getSourceModule.js.map +1 -1
- package/dist/cjs/extractor/getStaticBindingsForScope.js +1 -5
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/cjs/extractor/hoistClassNames.js +0 -3
- package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
- package/dist/cjs/extractor/literalToAst.js +0 -4
- package/dist/cjs/extractor/literalToAst.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.js +43 -10
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/cjs/extractor/logLines.js +2 -3
- package/dist/cjs/extractor/logLines.js.map +1 -1
- package/dist/cjs/extractor/normalizeTernaries.js +0 -2
- package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.js +2 -4
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/cjs/extractor/timer.js +2 -3
- package/dist/cjs/extractor/timer.js.map +1 -1
- package/dist/cjs/extractor/validHTMLAttributes.js +51 -0
- package/dist/cjs/extractor/validHTMLAttributes.js.map +2 -2
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/extractor/accessSafe.js +0 -3
- package/dist/esm/extractor/accessSafe.js.map +1 -1
- package/dist/esm/extractor/babelParse.js +15 -17
- package/dist/esm/extractor/babelParse.js.map +2 -2
- package/dist/esm/extractor/buildClassName.js +0 -3
- package/dist/esm/extractor/buildClassName.js.map +1 -1
- package/dist/esm/extractor/createEvaluator.js +9 -8
- package/dist/esm/extractor/createEvaluator.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +405 -195
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/ensureImportingConcat.js +0 -3
- package/dist/esm/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/esm/extractor/evaluateAstNode.js +0 -3
- package/dist/esm/extractor/evaluateAstNode.js.map +1 -1
- package/dist/esm/extractor/extractHelpers.js +11 -17
- package/dist/esm/extractor/extractHelpers.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.js +29 -20
- package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +53 -52
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/findTopmostFunction.js +1 -4
- package/dist/esm/extractor/findTopmostFunction.js.map +1 -1
- package/dist/esm/extractor/generatedUid.js +0 -3
- package/dist/esm/extractor/generatedUid.js.map +1 -1
- package/dist/esm/extractor/getPrefixLogs.js +1 -5
- package/dist/esm/extractor/getPrefixLogs.js.map +1 -1
- package/dist/esm/extractor/getPropValueFromAttributes.js +0 -3
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/esm/extractor/getSourceModule.js +0 -3
- package/dist/esm/extractor/getSourceModule.js.map +1 -1
- package/dist/esm/extractor/getStaticBindingsForScope.js +1 -6
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/esm/extractor/hoistClassNames.js +0 -4
- package/dist/esm/extractor/hoistClassNames.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +21 -11
- package/dist/esm/extractor/literalToAst.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.js +44 -11
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/logLines.js +2 -4
- package/dist/esm/extractor/logLines.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.js +35 -9
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.js +5 -9
- package/dist/esm/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/esm/extractor/timer.js +2 -4
- package/dist/esm/extractor/timer.js.map +1 -1
- package/dist/esm/extractor/validHTMLAttributes.js +50 -0
- package/dist/esm/extractor/validHTMLAttributes.js.map +2 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/jsx/constants.js +1 -0
- package/dist/jsx/constants.js.map +7 -0
- package/dist/jsx/extractor/accessSafe.js +1 -3
- package/dist/jsx/extractor/accessSafe.js.map +7 -0
- package/dist/jsx/extractor/babelParse.js +16 -17
- package/dist/jsx/extractor/babelParse.js.map +7 -0
- package/dist/jsx/extractor/buildClassName.js +1 -3
- package/dist/jsx/extractor/buildClassName.js.map +7 -0
- package/dist/jsx/extractor/createEvaluator.js +10 -8
- package/dist/jsx/extractor/createEvaluator.js.map +7 -0
- package/dist/jsx/extractor/createExtractor.js +325 -150
- package/dist/jsx/extractor/createExtractor.js.map +7 -0
- package/dist/jsx/extractor/ensureImportingConcat.js +1 -3
- package/dist/jsx/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/jsx/extractor/evaluateAstNode.js +1 -3
- package/dist/jsx/extractor/evaluateAstNode.js.map +7 -0
- package/dist/jsx/extractor/extractHelpers.js +12 -17
- package/dist/jsx/extractor/extractHelpers.js.map +7 -0
- package/dist/jsx/extractor/extractMediaStyle.js +4 -9
- package/dist/jsx/extractor/extractMediaStyle.js.map +7 -0
- package/dist/jsx/extractor/extractToClassNames.js +31 -43
- package/dist/jsx/extractor/extractToClassNames.js.map +7 -0
- package/dist/jsx/extractor/findTopmostFunction.js +2 -4
- package/dist/jsx/extractor/findTopmostFunction.js.map +7 -0
- package/dist/jsx/extractor/generatedUid.js +1 -3
- package/dist/jsx/extractor/generatedUid.js.map +7 -0
- package/dist/jsx/extractor/getPrefixLogs.js +1 -3
- package/dist/jsx/extractor/getPrefixLogs.js.map +7 -0
- package/dist/jsx/extractor/getPropValueFromAttributes.js +1 -3
- package/dist/jsx/extractor/getPropValueFromAttributes.js.map +7 -0
- package/dist/jsx/extractor/getSourceModule.js +1 -3
- package/dist/jsx/extractor/getSourceModule.js.map +7 -0
- package/dist/jsx/extractor/getStaticBindingsForScope.js +2 -6
- package/dist/jsx/extractor/getStaticBindingsForScope.js.map +7 -0
- package/dist/jsx/extractor/hoistClassNames.js +1 -4
- package/dist/jsx/extractor/hoistClassNames.js.map +7 -0
- package/dist/jsx/extractor/literalToAst.js +1 -5
- package/dist/jsx/extractor/literalToAst.js.map +7 -0
- package/dist/jsx/extractor/loadTamagui.js +30 -11
- package/dist/jsx/extractor/loadTamagui.js.map +7 -0
- package/dist/jsx/extractor/logLines.js +3 -4
- package/dist/jsx/extractor/logLines.js.map +7 -0
- package/dist/jsx/extractor/normalizeTernaries.js +1 -3
- package/dist/jsx/extractor/normalizeTernaries.js.map +7 -0
- package/dist/jsx/extractor/removeUnusedHooks.js +3 -5
- package/dist/jsx/extractor/removeUnusedHooks.js.map +7 -0
- package/dist/jsx/extractor/timer.js +3 -4
- package/dist/jsx/extractor/timer.js.map +7 -0
- package/dist/jsx/extractor/validHTMLAttributes.js +51 -0
- package/dist/jsx/extractor/validHTMLAttributes.js.map +7 -0
- package/dist/jsx/index.js +3 -1
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/types.js.map +7 -0
- package/package.json +28 -20
- package/src/constants.ts +13 -0
- package/src/extractor/accessSafe.ts +18 -0
- package/src/extractor/babelParse.ts +27 -0
- package/src/extractor/buildClassName.ts +61 -0
- package/src/extractor/createEvaluator.ts +75 -0
- package/src/extractor/createExtractor.ts +1928 -0
- package/src/extractor/ensureImportingConcat.ts +39 -0
- package/src/extractor/evaluateAstNode.ts +121 -0
- package/src/extractor/extractHelpers.ts +119 -0
- package/src/extractor/extractMediaStyle.ts +192 -0
- package/src/extractor/extractToClassNames.ts +393 -0
- package/src/extractor/findTopmostFunction.ts +22 -0
- package/src/extractor/generatedUid.ts +43 -0
- package/src/extractor/getPrefixLogs.ts +6 -0
- package/src/extractor/getPropValueFromAttributes.ts +92 -0
- package/src/extractor/getSourceModule.ts +101 -0
- package/src/extractor/getStaticBindingsForScope.ts +183 -0
- package/src/extractor/hoistClassNames.ts +45 -0
- package/src/extractor/literalToAst.ts +84 -0
- package/src/extractor/loadTamagui.ts +145 -0
- package/src/extractor/logLines.ts +16 -0
- package/src/extractor/normalizeTernaries.ts +63 -0
- package/src/extractor/removeUnusedHooks.ts +76 -0
- package/src/extractor/timer.ts +18 -0
- package/src/extractor/validHTMLAttributes.ts +99 -0
- package/src/index.ts +10 -0
- package/src/types.ts +96 -0
- 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 +1 -1
- 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 +3 -4
- 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 +1 -1
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -0
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- 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 +10 -4
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- 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 +49 -0
- package/types/extractor/validHTMLAttributes.d.ts.map +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +6 -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/types/patchReactNativeWeb.d.ts +0 -2
- package/types/patchReactNativeWeb.d.ts.map +0 -1
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
-
var patchReactNativeWeb_exports = {};
|
|
23
|
-
__export(patchReactNativeWeb_exports, {
|
|
24
|
-
patchReactNativeWeb: () => patchReactNativeWeb
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(patchReactNativeWeb_exports);
|
|
27
|
-
var import_path = __toESM(require("path"));
|
|
28
|
-
var fs = __toESM(require("fs-extra"));
|
|
29
|
-
function patchReactNativeWeb() {
|
|
30
|
-
const rootDir = require.resolve("react-native-web").replace(/\/dist.*/, "");
|
|
31
|
-
const modulePath = import_path.default.join(rootDir, "dist", "tamagui-exports.js");
|
|
32
|
-
const cjsPath = import_path.default.join(rootDir, "dist", "cjs", "tamagui-exports.js");
|
|
33
|
-
const shouldPatchExports = fs.existsSync(modulePath) && fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.existsSync(cjsPath) && fs.readFileSync(cjsPath, "utf-8") === cjsExports;
|
|
34
|
-
if (!shouldPatchExports) {
|
|
35
|
-
console.log(" | patch " + import_path.default.relative(rootDir, modulePath));
|
|
36
|
-
console.log(" | patch " + import_path.default.relative(rootDir, cjsPath));
|
|
37
|
-
fs.writeFileSync(modulePath, moduleExports);
|
|
38
|
-
fs.writeFileSync(cjsPath, cjsExports);
|
|
39
|
-
}
|
|
40
|
-
const patches = [
|
|
41
|
-
{
|
|
42
|
-
id: "dom-props",
|
|
43
|
-
filePath: ["modules", "createDOMProps", "index.js"],
|
|
44
|
-
replacee: ` if (dataSet != null) {`,
|
|
45
|
-
replacer: `
|
|
46
|
-
if (props.dataSet && props.dataSet.className) {
|
|
47
|
-
const { className, ...dataSetRest } = props.dataSet
|
|
48
|
-
classList = className
|
|
49
|
-
dataSet = dataSetRest
|
|
50
|
-
}
|
|
51
|
-
if (props.dataSet && props.dataSet.id) {
|
|
52
|
-
domProps['id'] = props.dataSet.id
|
|
53
|
-
}
|
|
54
|
-
if (dataSet != null) {`
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: "forward-props",
|
|
58
|
-
filePath: ["modules", "forwardedProps", "index.js"],
|
|
59
|
-
replacee: `dataSet: true,`,
|
|
60
|
-
replacer: `id: true, dataSet: true,`
|
|
61
|
-
}
|
|
62
|
-
];
|
|
63
|
-
for (const { filePath, replacee, replacer } of patches) {
|
|
64
|
-
const files = [
|
|
65
|
-
import_path.default.join(rootDir, "dist", ...filePath),
|
|
66
|
-
import_path.default.join(rootDir, "dist", "cjs", ...filePath)
|
|
67
|
-
];
|
|
68
|
-
for (const file of files) {
|
|
69
|
-
const contents = fs.readFileSync(file, "utf-8");
|
|
70
|
-
if (contents.includes(replacer)) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (!contents.includes(replacee)) {
|
|
74
|
-
console.warn(`\u26A0\uFE0F Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`, {
|
|
75
|
-
replacee,
|
|
76
|
-
contents
|
|
77
|
-
});
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
console.log(" | patch " + import_path.default.relative(rootDir, file));
|
|
81
|
-
fs.writeFileSync(file, contents.replace(replacee, replacer));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const moduleEntry = import_path.default.join(rootDir, "dist", "index.js");
|
|
85
|
-
const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
|
|
86
|
-
if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
|
|
87
|
-
fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
|
|
88
|
-
|
|
89
|
-
// tamagui-patch-v4
|
|
90
|
-
import * as TExports from './tamagui-exports'
|
|
91
|
-
export const TamaguiExports = TExports
|
|
92
|
-
// tamagui-patch-end
|
|
93
|
-
`);
|
|
94
|
-
}
|
|
95
|
-
const cjsEntry = import_path.default.join(rootDir, "dist", "cjs", "index.js");
|
|
96
|
-
const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
|
|
97
|
-
if (!cjsEntrySrc.includes("// tamagui-patch-v4")) {
|
|
98
|
-
fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
|
|
99
|
-
|
|
100
|
-
// tamagui-patch-v4
|
|
101
|
-
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
102
|
-
// tamagui-patch-end
|
|
103
|
-
`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
__name(patchReactNativeWeb, "patchReactNativeWeb");
|
|
107
|
-
function removePatch(source) {
|
|
108
|
-
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
|
|
109
|
-
}
|
|
110
|
-
__name(removePatch, "removePatch");
|
|
111
|
-
const forwardedPropsObj = `{
|
|
112
|
-
...fwdProps.defaultProps,
|
|
113
|
-
...fwdProps.accessibilityProps,
|
|
114
|
-
...fwdProps.clickProps,
|
|
115
|
-
...fwdProps.focusProps,
|
|
116
|
-
...fwdProps.keyboardProps,
|
|
117
|
-
...fwdProps.mouseProps,
|
|
118
|
-
...fwdProps.touchProps,
|
|
119
|
-
...fwdProps.styleProps,
|
|
120
|
-
href: true,
|
|
121
|
-
lang: true,
|
|
122
|
-
onScroll: true,
|
|
123
|
-
onWheel: true,
|
|
124
|
-
pointerEvents: true
|
|
125
|
-
}
|
|
126
|
-
`;
|
|
127
|
-
const moduleExports = `
|
|
128
|
-
export { atomic } from './exports/StyleSheet/compile'
|
|
129
|
-
export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
|
|
130
|
-
export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
|
|
131
|
-
export { default as i18Style } from './exports/StyleSheet/i18nStyle'
|
|
132
|
-
export { default as createDOMProps } from './modules/createDOMProps'
|
|
133
|
-
export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
|
|
134
|
-
export { default as createElement } from './exports/createElement'
|
|
135
|
-
export { default as css } from './exports/StyleSheet/css'
|
|
136
|
-
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
137
|
-
export { default as pick } from './modules/pick'
|
|
138
|
-
export { default as useElementLayout } from './modules/useElementLayout'
|
|
139
|
-
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
140
|
-
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
141
|
-
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
142
|
-
import * as fwdProps from './modules/forwardedProps'
|
|
143
|
-
export const forwardedProps = ${forwardedPropsObj}
|
|
144
|
-
`;
|
|
145
|
-
const cjsExports = `
|
|
146
|
-
exports.atomic = require('./exports/StyleSheet/compile').atomic
|
|
147
|
-
exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
|
|
148
|
-
exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
|
|
149
|
-
exports.i18Style = require('./exports/StyleSheet/i18nStyle')
|
|
150
|
-
exports.createDOMProps = require('./modules/createDOMProps')
|
|
151
|
-
exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
|
|
152
|
-
exports.createElement = require('./exports/createElement')
|
|
153
|
-
exports.css = require('./exports/StyleSheet/css')
|
|
154
|
-
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
155
|
-
exports.pick = require('./modules/pick')
|
|
156
|
-
exports.useElementLayout = require('./modules/useElementLayout')
|
|
157
|
-
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
158
|
-
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
159
|
-
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
160
|
-
const fwdProps = require('./modules/forwardedProps')
|
|
161
|
-
exports.forwardedProps = ${forwardedPropsObj}
|
|
162
|
-
`;
|
|
163
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
-
0 && (module.exports = {
|
|
165
|
-
patchReactNativeWeb
|
|
166
|
-
});
|
|
167
|
-
//# 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() {\n const rootDir = require.resolve('react-native-web').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 =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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAgBQ;AAAA;",
|
|
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() {
|
|
6
|
-
const rootDir = require.resolve("react-native-web").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() {\n const rootDir = require.resolve('react-native-web').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,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY,EAAE;AAC1E,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,S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,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() {
|
|
6
|
-
const rootDir = require.resolve("react-native-web").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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchReactNativeWeb.d.ts","sourceRoot":"","sources":["../src/patchReactNativeWeb.ts"],"names":[],"mappings":"AAUA,wBAAgB,mBAAmB,SA8FlC"}
|