@tamagui/static 1.0.0-alpha.6 → 1.0.0-alpha.63
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/constants.js +43 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/extractor/accessSafe.js +39 -0
- package/dist/cjs/extractor/accessSafe.js.map +7 -0
- package/dist/cjs/extractor/babelParse.js +58 -0
- package/dist/cjs/extractor/babelParse.js.map +7 -0
- package/dist/cjs/extractor/buildClassName.js +68 -0
- package/dist/cjs/extractor/buildClassName.js.map +7 -0
- package/dist/cjs/extractor/createEvaluator.js +79 -0
- package/dist/cjs/extractor/createEvaluator.js.map +7 -0
- package/dist/cjs/extractor/createExtractor.js +988 -0
- package/dist/cjs/extractor/createExtractor.js.map +7 -0
- package/dist/cjs/extractor/ensureImportingConcat.js +52 -0
- package/dist/cjs/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/cjs/extractor/evaluateAstNode.js +122 -0
- package/dist/cjs/extractor/evaluateAstNode.js.map +7 -0
- package/dist/cjs/extractor/extractHelpers.js +134 -0
- package/dist/cjs/extractor/extractHelpers.js.map +7 -0
- package/dist/cjs/extractor/extractMediaStyle.js +193 -0
- package/dist/cjs/extractor/extractMediaStyle.js.map +7 -0
- package/dist/cjs/extractor/extractToClassNames.js +295 -0
- package/dist/cjs/extractor/extractToClassNames.js.map +7 -0
- package/dist/cjs/extractor/findTopmostFunction.js +46 -0
- package/dist/cjs/extractor/findTopmostFunction.js.map +7 -0
- package/dist/cjs/extractor/generatedUid.js +56 -0
- package/dist/cjs/extractor/generatedUid.js.map +7 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js +77 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +7 -0
- package/dist/cjs/extractor/getSourceModule.js +97 -0
- package/dist/cjs/extractor/getSourceModule.js.map +7 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js +156 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +7 -0
- package/dist/cjs/extractor/hoistClassNames.js +72 -0
- package/dist/cjs/extractor/hoistClassNames.js.map +7 -0
- package/dist/cjs/extractor/literalToAst.js +121 -0
- package/dist/cjs/extractor/literalToAst.js.map +7 -0
- package/dist/cjs/extractor/loadTamagui.js +70 -0
- package/dist/cjs/extractor/loadTamagui.js.map +7 -0
- package/dist/cjs/extractor/logLines.js +40 -0
- package/dist/cjs/extractor/logLines.js.map +7 -0
- package/dist/cjs/extractor/normalizeTernaries.js +108 -0
- package/dist/cjs/extractor/normalizeTernaries.js.map +7 -0
- package/dist/cjs/extractor/removeUnusedHooks.js +107 -0
- package/dist/cjs/extractor/removeUnusedHooks.js.map +7 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/patchReactNativeWeb.js +157 -0
- package/dist/cjs/patchReactNativeWeb.js.map +7 -0
- package/dist/cjs/types.js +21 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/{constants.js → esm/constants.js} +4 -0
- package/dist/{constants.js.map → esm/constants.js.map} +3 -3
- package/dist/{extractor → esm/extractor}/accessSafe.js +0 -0
- package/dist/{extractor → esm/extractor}/accessSafe.js.map +1 -1
- package/dist/{extractor → esm/extractor}/babelParse.js +0 -0
- package/dist/{extractor → esm/extractor}/babelParse.js.map +1 -1
- package/dist/{extractor → esm/extractor}/buildClassName.js +0 -0
- package/dist/{extractor → esm/extractor}/buildClassName.js.map +1 -1
- package/dist/{extractor → esm/extractor}/createEvaluator.js +1 -1
- package/dist/esm/extractor/createEvaluator.js.map +7 -0
- package/dist/{extractor → esm/extractor}/createExtractor.js +189 -79
- package/dist/esm/extractor/createExtractor.js.map +7 -0
- package/dist/{extractor → esm/extractor}/ensureImportingConcat.js +1 -1
- package/dist/esm/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/{extractor → esm/extractor}/evaluateAstNode.js +0 -0
- package/dist/{extractor → esm/extractor}/evaluateAstNode.js.map +1 -1
- package/dist/{extractor → esm/extractor}/extractHelpers.js +25 -9
- package/dist/esm/extractor/extractHelpers.js.map +7 -0
- package/dist/{extractor → esm/extractor}/extractMediaStyle.js +3 -2
- package/dist/{extractor → esm/extractor}/extractMediaStyle.js.map +3 -3
- package/dist/{extractor → esm/extractor}/extractToClassNames.js +41 -24
- package/dist/esm/extractor/extractToClassNames.js.map +7 -0
- package/dist/{extractor → esm/extractor}/findTopmostFunction.js +0 -0
- package/dist/{extractor → esm/extractor}/findTopmostFunction.js.map +1 -1
- package/dist/{extractor → esm/extractor}/generatedUid.js +0 -0
- package/dist/{extractor → esm/extractor}/generatedUid.js.map +1 -1
- package/dist/{extractor → esm/extractor}/getPropValueFromAttributes.js +0 -0
- package/dist/{extractor → esm/extractor}/getPropValueFromAttributes.js.map +1 -1
- package/dist/{extractor → esm/extractor}/getSourceModule.js +0 -0
- package/dist/{extractor → esm/extractor}/getSourceModule.js.map +1 -1
- package/dist/{extractor → esm/extractor}/getStaticBindingsForScope.js +0 -0
- package/dist/{extractor → esm/extractor}/getStaticBindingsForScope.js.map +1 -1
- package/dist/{extractor → esm/extractor}/hoistClassNames.js +0 -0
- package/dist/{extractor → esm/extractor}/hoistClassNames.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +80 -0
- package/dist/esm/extractor/literalToAst.js.map +7 -0
- package/dist/{extractor → esm/extractor}/loadTamagui.js +8 -2
- package/dist/esm/extractor/loadTamagui.js.map +7 -0
- package/dist/esm/extractor/logLines.js +17 -0
- package/dist/esm/extractor/logLines.js.map +7 -0
- package/dist/{extractor → esm/extractor}/normalizeTernaries.js +3 -2
- package/dist/{extractor → esm/extractor}/normalizeTernaries.js.map +2 -2
- package/dist/{extractor → esm/extractor}/removeUnusedHooks.js +5 -3
- package/dist/{extractor → esm/extractor}/removeUnusedHooks.js.map +2 -2
- package/dist/{index.js → esm/index.js} +0 -0
- package/dist/{index.js.map → esm/index.js.map} +1 -1
- package/dist/{patchReactNativeWeb.js → esm/patchReactNativeWeb.js} +22 -0
- package/dist/esm/patchReactNativeWeb.js.map +7 -0
- package/dist/{types.js → esm/types.js} +0 -0
- package/dist/{types.js.map → esm/types.js.map} +0 -0
- package/dist/jsx/constants.js +13 -0
- package/dist/jsx/extractor/accessSafe.js +10 -0
- package/dist/jsx/extractor/babelParse.js +29 -0
- package/dist/jsx/extractor/buildClassName.js +39 -0
- package/dist/jsx/extractor/createEvaluator.js +50 -0
- package/dist/jsx/extractor/createExtractor.js +928 -0
- package/dist/jsx/extractor/ensureImportingConcat.js +23 -0
- package/dist/jsx/extractor/evaluateAstNode.js +93 -0
- package/dist/jsx/extractor/extractHelpers.js +109 -0
- package/dist/jsx/extractor/extractMediaStyle.js +151 -0
- package/dist/jsx/extractor/extractToClassNames.js +251 -0
- package/dist/jsx/extractor/findTopmostFunction.js +22 -0
- package/dist/jsx/extractor/generatedUid.js +27 -0
- package/dist/jsx/extractor/getPropValueFromAttributes.js +48 -0
- package/dist/jsx/extractor/getSourceModule.js +68 -0
- package/dist/jsx/extractor/getStaticBindingsForScope.js +127 -0
- package/dist/jsx/extractor/hoistClassNames.js +43 -0
- package/dist/jsx/extractor/literalToAst.js +79 -0
- package/dist/jsx/extractor/loadTamagui.js +46 -0
- package/dist/jsx/extractor/logLines.js +16 -0
- package/dist/jsx/extractor/normalizeTernaries.js +52 -0
- package/dist/jsx/extractor/removeUnusedHooks.js +79 -0
- package/dist/jsx/index.js +13 -0
- package/dist/jsx/patchReactNativeWeb.js +128 -0
- package/dist/jsx/types.js +0 -0
- package/package.json +27 -19
- package/types/constants.d.ts +6 -0
- package/types/constants.d.ts.map +1 -0
- package/types/extractor/accessSafe.d.ts +3 -0
- package/types/extractor/accessSafe.d.ts.map +1 -0
- package/types/extractor/babelParse.d.ts +5 -0
- package/types/extractor/babelParse.d.ts.map +1 -0
- package/types/extractor/buildClassName.d.ts +4 -0
- package/types/extractor/buildClassName.d.ts.map +1 -0
- package/types/extractor/createEvaluator.d.ts +12 -0
- package/types/extractor/createEvaluator.d.ts.map +1 -0
- package/types/extractor/createExtractor.d.ts +33 -0
- package/types/extractor/createExtractor.d.ts.map +1 -0
- package/types/extractor/ensureImportingConcat.d.ts +4 -0
- package/types/extractor/ensureImportingConcat.d.ts.map +1 -0
- package/types/extractor/evaluateAstNode.d.ts +3 -0
- package/types/extractor/evaluateAstNode.d.ts.map +1 -0
- package/types/extractor/extractHelpers.d.ts +12 -0
- package/types/extractor/extractHelpers.d.ts.map +1 -0
- package/types/extractor/extractMediaStyle.d.ts +10 -0
- package/types/extractor/extractMediaStyle.d.ts.map +1 -0
- package/types/extractor/extractToClassNames.d.ts +21 -0
- package/types/extractor/extractToClassNames.d.ts.map +1 -0
- package/types/extractor/findTopmostFunction.d.ts +4 -0
- package/types/extractor/findTopmostFunction.d.ts.map +1 -0
- package/types/extractor/generatedUid.d.ts +5 -0
- package/types/extractor/generatedUid.d.ts.map +1 -0
- package/types/extractor/getPropValueFromAttributes.d.ts +3 -0
- package/types/extractor/getPropValueFromAttributes.d.ts.map +1 -0
- package/types/extractor/getSourceModule.d.ts +16 -0
- package/types/extractor/getSourceModule.d.ts.map +1 -0
- package/types/extractor/getStaticBindingsForScope.d.ts +4 -0
- package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -0
- package/types/extractor/hoistClassNames.d.ts +6 -0
- package/types/extractor/hoistClassNames.d.ts.map +1 -0
- package/types/extractor/literalToAst.d.ts +4 -0
- package/types/extractor/literalToAst.d.ts.map +1 -0
- package/types/extractor/loadTamagui.d.ts +9 -0
- package/types/extractor/loadTamagui.d.ts.map +1 -0
- package/types/extractor/logLines.d.ts +2 -0
- package/types/extractor/logLines.d.ts.map +1 -0
- package/types/extractor/normalizeTernaries.d.ts +3 -0
- package/types/extractor/normalizeTernaries.d.ts.map +1 -0
- package/types/extractor/removeUnusedHooks.d.ts +3 -0
- package/types/extractor/removeUnusedHooks.d.ts.map +1 -0
- package/types/index.d.ts +8 -0
- package/types/index.d.ts.map +1 -0
- package/types/patchReactNativeWeb.d.ts +2 -0
- package/types/patchReactNativeWeb.d.ts.map +1 -0
- package/types/types.d.ts +79 -0
- package/types/types.d.ts.map +1 -0
- package/dist/extractor/createEvaluator.js.map +0 -7
- package/dist/extractor/createExtractor.js.map +0 -7
- package/dist/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/extractor/extractHelpers.js.map +0 -7
- package/dist/extractor/extractToClassNames.js.map +0 -7
- package/dist/extractor/literalToAst.js +0 -34
- package/dist/extractor/literalToAst.js.map +0 -7
- package/dist/extractor/loadTamagui.js.map +0 -7
- package/dist/index.cjs +0 -2107
- package/dist/index.cjs.map +0 -7
- package/dist/patchReactNativeWeb.js.map +0 -7
- package/src/constants.ts +0 -10
- package/src/extractor/accessSafe.ts +0 -18
- package/src/extractor/babelParse.ts +0 -27
- package/src/extractor/buildClassName.ts +0 -61
- package/src/extractor/createEvaluator.ts +0 -68
- package/src/extractor/createExtractor.ts +0 -1132
- package/src/extractor/ensureImportingConcat.ts +0 -33
- package/src/extractor/evaluateAstNode.ts +0 -121
- package/src/extractor/extractHelpers.ts +0 -102
- package/src/extractor/extractMediaStyle.ts +0 -191
- package/src/extractor/extractToClassNames.ts +0 -326
- package/src/extractor/findTopmostFunction.ts +0 -22
- package/src/extractor/generatedUid.ts +0 -43
- package/src/extractor/getPropValueFromAttributes.ts +0 -92
- package/src/extractor/getSourceModule.ts +0 -101
- package/src/extractor/getStaticBindingsForScope.ts +0 -173
- package/src/extractor/hoistClassNames.ts +0 -45
- package/src/extractor/literalToAst.ts +0 -32
- package/src/extractor/loadTamagui.ts +0 -61
- package/src/extractor/normalizeTernaries.ts +0 -60
- package/src/extractor/removeUnusedHooks.ts +0 -76
- package/src/index.ts +0 -9
- package/src/patchReactNativeWeb.ts +0 -123
- package/src/types.ts +0 -83
- package/types.d.ts +0 -215
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/extractor/literalToAst.ts"],
|
|
4
|
+
"sourcesContent": ["import * as t from '@babel/types'\n\nexport function literalToAst(literal: any): t.Expression {\n if (literal === null) {\n return t.nullLiteral()\n }\n switch (typeof literal) {\n case 'function':\n throw new Error('Unsupported')\n case 'number':\n return t.numericLiteral(literal)\n case 'string':\n return t.stringLiteral(literal)\n case 'boolean':\n return t.booleanLiteral(literal)\n case 'undefined':\n return t.unaryExpression('void', t.numericLiteral(0), true)\n default:\n if (Array.isArray(literal)) {\n return t.arrayExpression(literal.map(literalToAst))\n }\n return t.objectExpression(\n Object.keys(literal)\n .filter((k) => {\n return typeof literal[k] !== 'undefined'\n })\n .map((k) => {\n return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]))\n })\n )\n }\n}\n\nconst easyPeasies = ['BooleanLiteral', 'StringLiteral', 'NumericLiteral']\n\nexport function astToLiteral(node: any) {\n if (!node) {\n return\n }\n if (easyPeasies.includes(node.type)) {\n return node.value\n }\n if (node.name === 'undefined' && !node.value) {\n return undefined\n }\n if (t.isNullLiteral(node)) {\n return null\n }\n if (t.isObjectExpression(node)) {\n return computeProps(node.properties)\n }\n if (t.isArrayExpression(node)) {\n return node.elements.reduce(\n // @ts-ignore\n (acc, element) => [\n ...acc,\n ...(element?.type === 'SpreadElement'\n ? astToLiteral(element.argument)\n : [astToLiteral(element)]),\n ],\n []\n )\n }\n}\n\nfunction computeProps(props) {\n return props.reduce((acc, prop) => {\n if (prop.type === 'SpreadElement') {\n return {\n ...acc,\n ...astToLiteral(prop.argument),\n }\n } else if (prop.type !== 'ObjectMethod') {\n const val = astToLiteral(prop.value)\n if (val !== undefined) {\n return {\n ...acc,\n [prop.key.name]: val,\n }\n }\n }\n return acc\n }, {})\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AAEZ,sBAAsB,SAA4B;AACvD,MAAI,YAAY,MAAM;AACpB,WAAO,EAAE;AAAA;AAEX,UAAQ,OAAO;AAAA,SACR;AACH,YAAM,IAAI,MAAM;AAAA,SACb;AACH,aAAO,EAAE,eAAe;AAAA,SACrB;AACH,aAAO,EAAE,cAAc;AAAA,SACpB;AACH,aAAO,EAAE,eAAe;AAAA,SACrB;AACH,aAAO,EAAE,gBAAgB,QAAQ,EAAE,eAAe,IAAI;AAAA;AAEtD,UAAI,MAAM,QAAQ,UAAU;AAC1B,eAAO,EAAE,gBAAgB,QAAQ,IAAI;AAAA;AAEvC,aAAO,EAAE,iBACP,OAAO,KAAK,SACT,OAAO,CAAC,MAAM;AACb,eAAO,OAAO,QAAQ,OAAO;AAAA,SAE9B,IAAI,CAAC,MAAM;AACV,eAAO,EAAE,eAAe,EAAE,cAAc,IAAI,aAAa,QAAQ;AAAA;AAAA;AAAA;AAzB7D;AA+BhB,MAAM,cAAc,CAAC,kBAAkB,iBAAiB;AAEjD,sBAAsB,MAAW;AACtC,MAAI,CAAC,MAAM;AACT;AAAA;AAEF,MAAI,YAAY,SAAS,KAAK,OAAO;AACnC,WAAO,KAAK;AAAA;AAEd,MAAI,KAAK,SAAS,eAAe,CAAC,KAAK,OAAO;AAC5C,WAAO;AAAA;AAET,MAAI,EAAE,cAAc,OAAO;AACzB,WAAO;AAAA;AAET,MAAI,EAAE,mBAAmB,OAAO;AAC9B,WAAO,aAAa,KAAK;AAAA;AAE3B,MAAI,EAAE,kBAAkB,OAAO;AAC7B,WAAO,KAAK,SAAS,OAEnB,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,GAAI,oCAAS,UAAS,kBAClB,aAAa,QAAQ,YACrB,CAAC,aAAa;AAAA,OAEpB;AAAA;AAAA;AAzBU;AA8BhB,sBAAsB,OAAO;AAC3B,SAAO,MAAM,OAAO,CAAC,KAAK,SAAS;AACjC,QAAI,KAAK,SAAS,iBAAiB;AACjC,aAAO,kCACF,MACA,aAAa,KAAK;AAAA,eAEd,KAAK,SAAS,gBAAgB;AACvC,YAAM,MAAM,aAAa,KAAK;AAC9B,UAAI,QAAQ,QAAW;AACrB,eAAO,iCACF,MADE;AAAA,WAEJ,KAAK,IAAI,OAAO;AAAA;AAAA;AAAA;AAIvB,WAAO;AAAA,KACN;AAAA;AAjBI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
12
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(module2))
|
|
14
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
15
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var loadTamagui_exports = {};
|
|
25
|
+
__export(loadTamagui_exports, {
|
|
26
|
+
loadTamagui: () => loadTamagui
|
|
27
|
+
});
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_core_node = require("@tamagui/core-node");
|
|
30
|
+
let loadedTamagui = null;
|
|
31
|
+
function loadTamagui(props) {
|
|
32
|
+
if (loadedTamagui) {
|
|
33
|
+
return loadedTamagui;
|
|
34
|
+
}
|
|
35
|
+
process.env.IS_STATIC = "is_static";
|
|
36
|
+
const rnw = require("react-native-web");
|
|
37
|
+
const Mod = require("module");
|
|
38
|
+
const og = Mod.prototype.require;
|
|
39
|
+
Mod.prototype.require = function(path) {
|
|
40
|
+
if (path.endsWith(".css")) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
if (path === "@gorhom/bottom-sheet") {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
47
|
+
return rnw;
|
|
48
|
+
}
|
|
49
|
+
return og.apply(this, arguments);
|
|
50
|
+
};
|
|
51
|
+
const configPath = (0, import_path.join)(process.cwd(), props.config);
|
|
52
|
+
const tamaguiConfigExport = require(configPath);
|
|
53
|
+
const tamaguiConfig = tamaguiConfigExport["default"] || tamaguiConfigExport;
|
|
54
|
+
const components = {};
|
|
55
|
+
for (const module2 of props.components) {
|
|
56
|
+
const exported = require(module2);
|
|
57
|
+
Object.assign(components, exported);
|
|
58
|
+
}
|
|
59
|
+
process.env.IS_STATIC = void 0;
|
|
60
|
+
Mod.prototype.require = og;
|
|
61
|
+
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
62
|
+
loadedTamagui = {
|
|
63
|
+
components,
|
|
64
|
+
tamaguiConfig
|
|
65
|
+
};
|
|
66
|
+
return loadedTamagui;
|
|
67
|
+
}
|
|
68
|
+
__name(loadTamagui, "loadTamagui");
|
|
69
|
+
module.exports = __toCommonJS(loadTamagui_exports);
|
|
70
|
+
//# sourceMappingURL=loadTamagui.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/extractor/loadTamagui.ts"],
|
|
4
|
+
"sourcesContent": ["import { join } from 'path'\n\nimport type { StaticComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\nexport function loadTamagui(props: { components: string[]; config: string }): {\n components: Record<string, StaticComponent>\n tamaguiConfig: TamaguiInternalConfig\n} {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (path === '@gorhom/bottom-sheet') {\n return {}\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n }\n return og.apply(this, arguments)\n }\n\n // import config\n const configPath = join(process.cwd(), props.config)\n const tamaguiConfigExport = require(configPath)\n const tamaguiConfig = (tamaguiConfigExport['default'] ||\n tamaguiConfigExport) as TamaguiInternalConfig\n\n // import components\n const components = {}\n for (const module of props.components) {\n const exported = require(module)\n Object.assign(components, exported)\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n }\n\n return loadedTamagui\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGrB,uBAA8B;AAE9B,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA;AAKT,UAAQ,IAAI,YAAY;AACxB,QAAM,MAAM,QAAQ;AACpB,QAAM,MAAM,QAAQ;AACpB,QAAM,KAAK,IAAI,UAAU;AACzB,MAAI,UAAU,UAAU,SAAU,MAAc;AAC9C,QAAI,KAAK,SAAS,SAAS;AACzB,aAAO;AAAA;AAET,QAAI,SAAS,wBAAwB;AACnC,aAAO;AAAA;AAET,QACE,KAAK,WAAW,mBAEhB,CAAC,KAAK,WAAW,sCACjB;AACA,aAAO;AAAA;AAET,WAAO,GAAG,MAAM,MAAM;AAAA;AAIxB,QAAM,aAAa,sBAAK,QAAQ,OAAO,MAAM;AAC7C,QAAM,sBAAsB,QAAQ;AACpC,QAAM,gBAAiB,oBAAoB,cACzC;AAGF,QAAM,aAAa;AACnB,aAAW,WAAU,MAAM,YAAY;AACrC,UAAM,WAAW,QAAQ;AACzB,WAAO,OAAO,YAAY;AAAA;AAI5B,UAAQ,IAAI,YAAY;AACxB,MAAI,UAAU,UAAU;AAGxB,sCAAc;AAEd,kBAAgB;AAAA,IACd;AAAA,IACA;AAAA;AAGF,SAAO;AAAA;AAxDO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
12
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(module2))
|
|
14
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
15
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var logLines_exports = {};
|
|
25
|
+
__export(logLines_exports, {
|
|
26
|
+
logLines: () => logLines
|
|
27
|
+
});
|
|
28
|
+
const logLines = /* @__PURE__ */ __name((str) => {
|
|
29
|
+
let lines = [""];
|
|
30
|
+
const items = str.split(" ");
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
if (item.length + lines[lines.length - 1].length > 85) {
|
|
33
|
+
lines.push("");
|
|
34
|
+
}
|
|
35
|
+
lines[lines.length - 1] += item + " ";
|
|
36
|
+
}
|
|
37
|
+
return lines.map((line, i) => " " + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
38
|
+
}, "logLines");
|
|
39
|
+
module.exports = __toCommonJS(logLines_exports);
|
|
40
|
+
//# sourceMappingURL=logLines.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/extractor/logLines.ts"],
|
|
4
|
+
"sourcesContent": ["export const logLines = (str: string) => {\n let lines: string[] = ['']\n const items = str.split(' ')\n for (const item of items) {\n if (item.length + lines[lines.length - 1].length > 85) {\n lines.push('')\n }\n lines[lines.length - 1] += item + ' '\n }\n return lines.map((line, i) => ' ' + (i == 0 ? '' : ' ') + line.trim()).join('\\n')\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,WAAW,wBAAC,QAAgB;AACvC,MAAI,QAAkB,CAAC;AACvB,QAAM,QAAQ,IAAI,MAAM;AACxB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,SAAS,MAAM,MAAM,SAAS,GAAG,SAAS,IAAI;AACrD,YAAM,KAAK;AAAA;AAEb,UAAM,MAAM,SAAS,MAAM,OAAO;AAAA;AAEpC,SAAO,MAAM,IAAI,CAAC,MAAM,MAAM,gBAAiB,MAAK,IAAI,KAAK,OAAO,KAAK,QAAQ,KAAK;AAAA,GAThE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
26
|
+
var __objRest = (source, exclude) => {
|
|
27
|
+
var target = {};
|
|
28
|
+
for (var prop in source)
|
|
29
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
if (source != null && __getOwnPropSymbols)
|
|
32
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
var __export = (target, all) => {
|
|
39
|
+
for (var name in all)
|
|
40
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
41
|
+
};
|
|
42
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
43
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
44
|
+
for (let key of __getOwnPropNames(module2))
|
|
45
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
46
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
47
|
+
}
|
|
48
|
+
return target;
|
|
49
|
+
};
|
|
50
|
+
var __toESM = (module2, isNodeMode) => {
|
|
51
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
52
|
+
};
|
|
53
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
54
|
+
return (module2, temp) => {
|
|
55
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
56
|
+
};
|
|
57
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
58
|
+
var normalizeTernaries_exports = {};
|
|
59
|
+
__export(normalizeTernaries_exports, {
|
|
60
|
+
normalizeTernaries: () => normalizeTernaries
|
|
61
|
+
});
|
|
62
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
63
|
+
var t = __toESM(require("@babel/types"));
|
|
64
|
+
var import_invariant = __toESM(require("invariant"));
|
|
65
|
+
function normalizeTernaries(ternaries) {
|
|
66
|
+
(0, import_invariant.default)(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
|
|
67
|
+
if (ternaries.length === 0) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const ternariesByKey = {};
|
|
71
|
+
for (let idx = -1, len = ternaries.length; ++idx < len; ) {
|
|
72
|
+
const _a = ternaries[idx], { test, consequent, alternate, remove } = _a, rest = __objRest(_a, ["test", "consequent", "alternate", "remove"]);
|
|
73
|
+
let ternaryTest = test;
|
|
74
|
+
if (t.isExpressionStatement(test)) {
|
|
75
|
+
ternaryTest = test.expression;
|
|
76
|
+
}
|
|
77
|
+
let shouldSwap = false;
|
|
78
|
+
if (t.isUnaryExpression(test) && test.operator === "!") {
|
|
79
|
+
ternaryTest = test.argument;
|
|
80
|
+
shouldSwap = true;
|
|
81
|
+
} else if (t.isBinaryExpression(test)) {
|
|
82
|
+
if (test.operator === "!==" || test.operator === "!=") {
|
|
83
|
+
ternaryTest = t.binaryExpression(test.operator, test.left, test.right);
|
|
84
|
+
shouldSwap = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const key = (0, import_generator.default)(ternaryTest).code;
|
|
88
|
+
if (!ternariesByKey[key]) {
|
|
89
|
+
ternariesByKey[key] = __spreadProps(__spreadValues({}, rest), {
|
|
90
|
+
alternate: {},
|
|
91
|
+
consequent: {},
|
|
92
|
+
test: ternaryTest,
|
|
93
|
+
remove
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const altStyle = (shouldSwap ? consequent : alternate) ?? {};
|
|
97
|
+
const consStyle = (shouldSwap ? alternate : consequent) ?? {};
|
|
98
|
+
Object.assign(ternariesByKey[key].alternate, altStyle);
|
|
99
|
+
Object.assign(ternariesByKey[key].consequent, consStyle);
|
|
100
|
+
}
|
|
101
|
+
const ternaryExpression = Object.keys(ternariesByKey).map((key) => {
|
|
102
|
+
return ternariesByKey[key];
|
|
103
|
+
});
|
|
104
|
+
return ternaryExpression;
|
|
105
|
+
}
|
|
106
|
+
__name(normalizeTernaries, "normalizeTernaries");
|
|
107
|
+
module.exports = __toCommonJS(normalizeTernaries_exports);
|
|
108
|
+
//# sourceMappingURL=normalizeTernaries.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/extractor/normalizeTernaries.ts"],
|
|
4
|
+
"sourcesContent": ["import generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport invariant from 'invariant'\n\nimport { Ternary } from '../types'\n\nexport function normalizeTernaries(ternaries: Ternary[]) {\n invariant(Array.isArray(ternaries), 'extractStaticTernaries expects param 1 to be an array of ternaries')\n\n if (ternaries.length === 0) {\n return []\n }\n\n const ternariesByKey: { [key: string]: Ternary } = {}\n\n for (let idx = -1, len = ternaries.length; ++idx < len; ) {\n const { test, consequent, alternate, remove, ...rest } = ternaries[idx]\n\n let ternaryTest = test\n\n // strip parens\n if (t.isExpressionStatement(test)) {\n ternaryTest = (test as any).expression\n }\n\n // convert `!thing` to `thing` with swapped consequent and alternate\n let shouldSwap = false\n if (t.isUnaryExpression(test) && test.operator === '!') {\n ternaryTest = test.argument\n shouldSwap = true\n } else if (t.isBinaryExpression(test)) {\n if (test.operator === '!==' || test.operator === '!=') {\n ternaryTest = t.binaryExpression(test.operator, test.left, test.right)\n shouldSwap = true\n }\n }\n\n const key = generate(ternaryTest).code\n\n if (!ternariesByKey[key]) {\n ternariesByKey[key] = {\n ...rest,\n alternate: {},\n consequent: {},\n test: ternaryTest,\n remove,\n }\n }\n const altStyle = (shouldSwap ? consequent : alternate) ?? {}\n const consStyle = (shouldSwap ? alternate : consequent) ?? {}\n Object.assign(ternariesByKey[key].alternate, altStyle)\n Object.assign(ternariesByKey[key].consequent, consStyle)\n }\n\n const ternaryExpression = Object.keys(ternariesByKey).map((key) => {\n return ternariesByKey[key]\n })\n\n return ternaryExpression\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqB;AACrB,QAAmB;AACnB,uBAAsB;AAIf,4BAA4B,WAAsB;AACvD,gCAAU,MAAM,QAAQ,YAAY;AAEpC,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA;AAGT,QAAM,iBAA6C;AAEnD,WAAS,MAAM,IAAI,MAAM,UAAU,QAAQ,EAAE,MAAM,OAAO;AACxD,UAAyD,eAAU,MAA3D,QAAM,YAAY,WAAW,WAAoB,IAAT,iBAAS,IAAT,CAAxC,QAAM,cAAY,aAAW;AAErC,QAAI,cAAc;AAGlB,QAAI,EAAE,sBAAsB,OAAO;AACjC,oBAAe,KAAa;AAAA;AAI9B,QAAI,aAAa;AACjB,QAAI,EAAE,kBAAkB,SAAS,KAAK,aAAa,KAAK;AACtD,oBAAc,KAAK;AACnB,mBAAa;AAAA,eACJ,EAAE,mBAAmB,OAAO;AACrC,UAAI,KAAK,aAAa,SAAS,KAAK,aAAa,MAAM;AACrD,sBAAc,EAAE,iBAAiB,KAAK,UAAU,KAAK,MAAM,KAAK;AAChE,qBAAa;AAAA;AAAA;AAIjB,UAAM,MAAM,8BAAS,aAAa;AAElC,QAAI,CAAC,eAAe,MAAM;AACxB,qBAAe,OAAO,iCACjB,OADiB;AAAA,QAEpB,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,MAAM;AAAA,QACN;AAAA;AAAA;AAGJ,UAAM,WAAY,cAAa,aAAa,cAAc;AAC1D,UAAM,YAAa,cAAa,YAAY,eAAe;AAC3D,WAAO,OAAO,eAAe,KAAK,WAAW;AAC7C,WAAO,OAAO,eAAe,KAAK,YAAY;AAAA;AAGhD,QAAM,oBAAoB,OAAO,KAAK,gBAAgB,IAAI,CAAC,QAAQ;AACjE,WAAO,eAAe;AAAA;AAGxB,SAAO;AAAA;AApDO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
14
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(module2))
|
|
16
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (module2, isNodeMode) => {
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
25
|
+
return (module2, temp) => {
|
|
26
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
27
|
+
};
|
|
28
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
29
|
+
var removeUnusedHooks_exports = {};
|
|
30
|
+
__export(removeUnusedHooks_exports, {
|
|
31
|
+
removeUnusedHooks: () => removeUnusedHooks
|
|
32
|
+
});
|
|
33
|
+
var t = __toESM(require("@babel/types"));
|
|
34
|
+
const hooks = {
|
|
35
|
+
useMedia: true,
|
|
36
|
+
useTheme: true
|
|
37
|
+
};
|
|
38
|
+
function removeUnusedHooks(compFn, shouldPrintDebug) {
|
|
39
|
+
compFn.scope.crawl();
|
|
40
|
+
let bodyStatements = compFn == null ? void 0 : compFn.get("body");
|
|
41
|
+
if (!bodyStatements) {
|
|
42
|
+
console.log("no body statemnts?", compFn);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!Array.isArray(bodyStatements)) {
|
|
46
|
+
if (bodyStatements.isFunctionExpression()) {
|
|
47
|
+
bodyStatements = bodyStatements.scope.path.get("body");
|
|
48
|
+
} else {
|
|
49
|
+
bodyStatements = bodyStatements.get("body");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!bodyStatements || !Array.isArray(bodyStatements)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const statements = bodyStatements;
|
|
56
|
+
for (const statement of statements) {
|
|
57
|
+
if (!statement.isVariableDeclaration()) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const declarations = statement.get("declarations");
|
|
61
|
+
if (!Array.isArray(declarations)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const isBindingReferenced = /* @__PURE__ */ __name((name) => {
|
|
65
|
+
var _a;
|
|
66
|
+
return !!((_a = statement.scope.getBinding(name)) == null ? void 0 : _a.referenced);
|
|
67
|
+
}, "isBindingReferenced");
|
|
68
|
+
for (const declarator of declarations) {
|
|
69
|
+
const id = declarator.get("id");
|
|
70
|
+
const init = declarator.node.init;
|
|
71
|
+
if (Array.isArray(id) || Array.isArray(init)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const shouldRemove = (() => {
|
|
75
|
+
const isHook = t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name];
|
|
76
|
+
if (!isHook) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (t.isIdentifier(id.node)) {
|
|
80
|
+
const name = id.node.name;
|
|
81
|
+
return !isBindingReferenced(name);
|
|
82
|
+
} else if (t.isObjectPattern(id.node)) {
|
|
83
|
+
const propPaths = id.get("properties");
|
|
84
|
+
return propPaths.every((prop) => {
|
|
85
|
+
if (!prop.isObjectProperty())
|
|
86
|
+
return false;
|
|
87
|
+
const value = prop.get("value");
|
|
88
|
+
if (Array.isArray(value) || !value.isIdentifier())
|
|
89
|
+
return false;
|
|
90
|
+
const name = value.node.name;
|
|
91
|
+
return !isBindingReferenced(name);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
})();
|
|
96
|
+
if (shouldRemove) {
|
|
97
|
+
declarator.remove();
|
|
98
|
+
if (shouldPrintDebug) {
|
|
99
|
+
console.log(` [\u{1FA9D}] removed ${id.node["name"] ?? ""}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
__name(removeUnusedHooks, "removeUnusedHooks");
|
|
106
|
+
module.exports = __toCommonJS(removeUnusedHooks_exports);
|
|
107
|
+
//# sourceMappingURL=removeUnusedHooks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/extractor/removeUnusedHooks.ts"],
|
|
4
|
+
"sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nconst hooks = {\n useMedia: true,\n useTheme: true,\n}\n\nexport function removeUnusedHooks(compFn: NodePath<any>, shouldPrintDebug: boolean) {\n compFn.scope.crawl()\n // check the top level statements\n let bodyStatements = compFn?.get('body')\n if (!bodyStatements) {\n console.log('no body statemnts?', compFn)\n return\n }\n if (!Array.isArray(bodyStatements)) {\n if (bodyStatements.isFunctionExpression()) {\n bodyStatements = bodyStatements.scope.path.get('body')\n } else {\n bodyStatements = bodyStatements.get('body')\n }\n }\n if (!bodyStatements || !Array.isArray(bodyStatements)) {\n return\n }\n const statements = bodyStatements as NodePath<any>[]\n for (const statement of statements) {\n if (!statement.isVariableDeclaration()) {\n continue\n }\n const declarations = statement.get('declarations')\n if (!Array.isArray(declarations)) {\n continue\n }\n const isBindingReferenced = (name: string) => {\n return !!statement.scope.getBinding(name)?.referenced\n }\n for (const declarator of declarations) {\n const id = declarator.get('id')\n const init = declarator.node.init\n if (Array.isArray(id) || Array.isArray(init)) {\n continue\n }\n const shouldRemove = (() => {\n const isHook =\n t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name]\n if (!isHook) {\n return false\n }\n if (t.isIdentifier(id.node)) {\n // remove \"const media = useMedia()\"\n const name = id.node.name\n return !isBindingReferenced(name)\n } else if (t.isObjectPattern(id.node)) {\n // remove \"const { sm } = useMedia()\"\n const propPaths = id.get('properties') as NodePath<any>[]\n return propPaths.every((prop) => {\n if (!prop.isObjectProperty()) return false\n const value = prop.get('value')\n if (Array.isArray(value) || !value.isIdentifier()) return false\n const name = value.node.name\n return !isBindingReferenced(name)\n })\n }\n return false\n })()\n if (shouldRemove) {\n declarator.remove()\n if (shouldPrintDebug) {\n console.log(` [\uD83E\uDE9D] removed ${id.node['name'] ?? ''}`)\n }\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AACA,QAAmB;AAEnB,MAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,EACV,UAAU;AAAA;AAGL,2BAA2B,QAAuB,kBAA2B;AAClF,SAAO,MAAM;AAEb,MAAI,iBAAiB,iCAAQ,IAAI;AACjC,MAAI,CAAC,gBAAgB;AACnB,YAAQ,IAAI,sBAAsB;AAClC;AAAA;AAEF,MAAI,CAAC,MAAM,QAAQ,iBAAiB;AAClC,QAAI,eAAe,wBAAwB;AACzC,uBAAiB,eAAe,MAAM,KAAK,IAAI;AAAA,WAC1C;AACL,uBAAiB,eAAe,IAAI;AAAA;AAAA;AAGxC,MAAI,CAAC,kBAAkB,CAAC,MAAM,QAAQ,iBAAiB;AACrD;AAAA;AAEF,QAAM,aAAa;AACnB,aAAW,aAAa,YAAY;AAClC,QAAI,CAAC,UAAU,yBAAyB;AACtC;AAAA;AAEF,UAAM,eAAe,UAAU,IAAI;AACnC,QAAI,CAAC,MAAM,QAAQ,eAAe;AAChC;AAAA;AAEF,UAAM,sBAAsB,wBAAC,SAAiB;AAnClD;AAoCM,aAAO,CAAC,CAAC,iBAAU,MAAM,WAAW,UAA3B,mBAAkC;AAAA,OADjB;AAG5B,eAAW,cAAc,cAAc;AACrC,YAAM,KAAK,WAAW,IAAI;AAC1B,YAAM,OAAO,WAAW,KAAK;AAC7B,UAAI,MAAM,QAAQ,OAAO,MAAM,QAAQ,OAAO;AAC5C;AAAA;AAEF,YAAM,eAAgB,OAAM;AAC1B,cAAM,SACJ,EAAE,iBAAiB,SAAS,EAAE,aAAa,KAAK,WAAW,MAAM,KAAK,OAAO;AAC/E,YAAI,CAAC,QAAQ;AACX,iBAAO;AAAA;AAET,YAAI,EAAE,aAAa,GAAG,OAAO;AAE3B,gBAAM,OAAO,GAAG,KAAK;AACrB,iBAAO,CAAC,oBAAoB;AAAA,mBACnB,EAAE,gBAAgB,GAAG,OAAO;AAErC,gBAAM,YAAY,GAAG,IAAI;AACzB,iBAAO,UAAU,MAAM,CAAC,SAAS;AAC/B,gBAAI,CAAC,KAAK;AAAoB,qBAAO;AACrC,kBAAM,QAAQ,KAAK,IAAI;AACvB,gBAAI,MAAM,QAAQ,UAAU,CAAC,MAAM;AAAgB,qBAAO;AAC1D,kBAAM,OAAO,MAAM,KAAK;AACxB,mBAAO,CAAC,oBAAoB;AAAA;AAAA;AAGhC,eAAO;AAAA;AAET,UAAI,cAAc;AAChB,mBAAW;AACX,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,yBAAkB,GAAG,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AA9D3C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
TamaguiOptions: () => import_types.TamaguiOptions,
|
|
26
|
+
createExtractor: () => import_createExtractor.createExtractor,
|
|
27
|
+
literalToAst: () => import_literalToAst.literalToAst
|
|
28
|
+
});
|
|
29
|
+
var import_types = require("./types");
|
|
30
|
+
var import_createExtractor = require("./extractor/createExtractor");
|
|
31
|
+
var import_literalToAst = require("./extractor/literalToAst");
|
|
32
|
+
__reExport(src_exports, require("./constants"));
|
|
33
|
+
__reExport(src_exports, require("./extractor/extractToClassNames"));
|
|
34
|
+
__reExport(src_exports, require("./extractor/extractHelpers"));
|
|
35
|
+
__reExport(src_exports, require("./patchReactNativeWeb"));
|
|
36
|
+
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
37
|
+
module.exports = __toCommonJS(src_exports);
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["process.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport { TamaguiOptions } from './types'\nexport { createExtractor } from './extractor/createExtractor'\nexport { literalToAst } from './extractor/literalToAst'\nexport * from './constants'\nexport * from './extractor/extractToClassNames'\nexport * from './extractor/extractHelpers'\nexport * from './patchReactNativeWeb'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA+B;AAC/B,6BAAgC;AAChC,0BAA6B;AAC7B,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;AARd,QAAQ,IAAI,0BAA0B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
14
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(module2))
|
|
16
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (module2, isNodeMode) => {
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
25
|
+
return (module2, temp) => {
|
|
26
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
27
|
+
};
|
|
28
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
29
|
+
var patchReactNativeWeb_exports = {};
|
|
30
|
+
__export(patchReactNativeWeb_exports, {
|
|
31
|
+
patchReactNativeWeb: () => patchReactNativeWeb
|
|
32
|
+
});
|
|
33
|
+
var fs = __toESM(require("fs"));
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
function patchReactNativeWeb() {
|
|
36
|
+
const rootDir = require.resolve("react-native-web").replace(/\/dist.*/, "");
|
|
37
|
+
const modulePath = import_path.default.join(rootDir, "dist", "tamagui-exports.js");
|
|
38
|
+
const cjsPath = import_path.default.join(rootDir, "dist", "cjs", "tamagui-exports.js");
|
|
39
|
+
const isEqual = (() => {
|
|
40
|
+
let res = false;
|
|
41
|
+
try {
|
|
42
|
+
res = fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.readFileSync(cjsPath, "utf-8") == cjsExports;
|
|
43
|
+
} catch {
|
|
44
|
+
res = false;
|
|
45
|
+
}
|
|
46
|
+
return res;
|
|
47
|
+
})();
|
|
48
|
+
if (!isEqual) {
|
|
49
|
+
console.log("\u{1F95A} Tamagui patching react-native-web to share atomic styling primitives");
|
|
50
|
+
console.log(" > adding", modulePath);
|
|
51
|
+
console.log(" > adding", cjsPath);
|
|
52
|
+
fs.writeFileSync(modulePath, moduleExports);
|
|
53
|
+
fs.writeFileSync(cjsPath, cjsExports);
|
|
54
|
+
}
|
|
55
|
+
const classNamePatch = `if (props.dataSet && props.dataSet['__className']) { domProps.className = className ? className + ' ' + props.dataSet['__className'] : props.dataSet['__className']; delete props.dataSet['__className'] }`;
|
|
56
|
+
const domPropsPath = ["modules", "createDOMProps", "index.js"];
|
|
57
|
+
const domPropsModulePath = import_path.default.join(rootDir, "dist", ...domPropsPath);
|
|
58
|
+
const domPropsCjsPath = import_path.default.join(rootDir, "dist", "cjs", ...domPropsPath);
|
|
59
|
+
const patchClassName = /* @__PURE__ */ __name((file) => {
|
|
60
|
+
const contents = fs.readFileSync(file, "utf-8");
|
|
61
|
+
if (!contents.includes(classNamePatch)) {
|
|
62
|
+
const needle = `domProps.className = className`;
|
|
63
|
+
const patchLocation = contents.indexOf(needle) + needle.length + 5;
|
|
64
|
+
if (patchLocation < 100) {
|
|
65
|
+
console.warn(`\u26A0\uFE0F Couldn't apply className patch! Maybe using incompatible react-native-web version.`);
|
|
66
|
+
} else {
|
|
67
|
+
const before = contents.slice(0, patchLocation);
|
|
68
|
+
const after = contents.slice(patchLocation);
|
|
69
|
+
const patched = before + "\n" + classNamePatch + "\n" + after;
|
|
70
|
+
console.log(" > adding className support to react-native-web", file);
|
|
71
|
+
fs.writeFileSync(file, patched);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, "patchClassName");
|
|
75
|
+
patchClassName(domPropsModulePath);
|
|
76
|
+
patchClassName(domPropsCjsPath);
|
|
77
|
+
const moduleEntry = import_path.default.join(rootDir, "dist", "index.js");
|
|
78
|
+
const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
|
|
79
|
+
if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
|
|
80
|
+
fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
|
|
81
|
+
|
|
82
|
+
// tamagui-patch-v4
|
|
83
|
+
import * as TExports from './tamagui-exports'
|
|
84
|
+
export const TamaguiExports = TExports
|
|
85
|
+
// tamagui-patch-end
|
|
86
|
+
`);
|
|
87
|
+
}
|
|
88
|
+
const cjsEntry = import_path.default.join(rootDir, "dist", "cjs", "index.js");
|
|
89
|
+
const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
|
|
90
|
+
if (!cjsEntrySrc.includes("// tamagui-patch-v4")) {
|
|
91
|
+
fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
|
|
92
|
+
|
|
93
|
+
// tamagui-patch-v4
|
|
94
|
+
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
95
|
+
// tamagui-patch-end
|
|
96
|
+
`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__name(patchReactNativeWeb, "patchReactNativeWeb");
|
|
100
|
+
function removePatch(source) {
|
|
101
|
+
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
|
|
102
|
+
}
|
|
103
|
+
__name(removePatch, "removePatch");
|
|
104
|
+
const forwardedPropsObj = `{
|
|
105
|
+
...fwdProps.defaultProps,
|
|
106
|
+
...fwdProps.accessibilityProps,
|
|
107
|
+
...fwdProps.clickProps,
|
|
108
|
+
...fwdProps.focusProps,
|
|
109
|
+
...fwdProps.keyboardProps,
|
|
110
|
+
...fwdProps.mouseProps,
|
|
111
|
+
...fwdProps.touchProps,
|
|
112
|
+
...fwdProps.styleProps,
|
|
113
|
+
href: true,
|
|
114
|
+
lang: true,
|
|
115
|
+
onScroll: true,
|
|
116
|
+
onWheel: true,
|
|
117
|
+
pointerEvents: true
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
const moduleExports = `
|
|
121
|
+
export { atomic } from './exports/StyleSheet/compile'
|
|
122
|
+
export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
|
|
123
|
+
export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
|
|
124
|
+
export { default as i18Style } from './exports/StyleSheet/i18nStyle'
|
|
125
|
+
export { default as createDOMProps } from './modules/createDOMProps'
|
|
126
|
+
export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
|
|
127
|
+
export { default as createElement } from './exports/createElement'
|
|
128
|
+
export { default as css } from './exports/StyleSheet/css'
|
|
129
|
+
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
130
|
+
export { default as pick } from './modules/pick'
|
|
131
|
+
export { default as useElementLayout } from './modules/useElementLayout'
|
|
132
|
+
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
133
|
+
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
134
|
+
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
135
|
+
import * as fwdProps from './modules/forwardedProps'
|
|
136
|
+
export const forwardedProps = ${forwardedPropsObj}
|
|
137
|
+
`;
|
|
138
|
+
const cjsExports = `
|
|
139
|
+
exports.atomic = require('./exports/StyleSheet/compile').atomic
|
|
140
|
+
exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
|
|
141
|
+
exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
|
|
142
|
+
exports.i18Style = require('./exports/StyleSheet/i18nStyle')
|
|
143
|
+
exports.createDOMProps = require('./modules/createDOMProps')
|
|
144
|
+
exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
|
|
145
|
+
exports.createElement = require('./exports/createElement')
|
|
146
|
+
exports.css = require('./exports/StyleSheet/css')
|
|
147
|
+
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
148
|
+
exports.pick = require('./modules/pick')
|
|
149
|
+
exports.useElementLayout = require('./modules/useElementLayout')
|
|
150
|
+
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
151
|
+
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
152
|
+
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
153
|
+
const fwdProps = require('./modules/forwardedProps')
|
|
154
|
+
exports.forwardedProps = ${forwardedPropsObj}
|
|
155
|
+
`;
|
|
156
|
+
module.exports = __toCommonJS(patchReactNativeWeb_exports);
|
|
157
|
+
//# sourceMappingURL=patchReactNativeWeb.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/patchReactNativeWeb.ts"],
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs'\nimport path from 'path'\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\n const isEqual = (() => {\n let res = false\n try {\n res =\n fs.readFileSync(modulePath, 'utf-8') === moduleExports &&\n fs.readFileSync(cjsPath, 'utf-8') == cjsExports\n } catch {\n res = false\n }\n return res\n })()\n\n if (!isEqual) {\n console.log('\uD83E\uDD5A Tamagui patching react-native-web to share atomic styling primitives')\n console.log(' > adding', modulePath)\n console.log(' > adding', cjsPath)\n fs.writeFileSync(modulePath, moduleExports)\n fs.writeFileSync(cjsPath, cjsExports)\n }\n\n // patch to allow className prop\n const classNamePatch = `if (props.dataSet && props.dataSet['__className']) { domProps.className = className ? className + ' ' + props.dataSet['__className'] : props.dataSet['__className']; delete props.dataSet['__className'] }`\n const domPropsPath = ['modules', 'createDOMProps', 'index.js']\n const domPropsModulePath = path.join(rootDir, 'dist', ...domPropsPath)\n const domPropsCjsPath = path.join(rootDir, 'dist', 'cjs', ...domPropsPath)\n const patchClassName = (file: string) => {\n const contents = fs.readFileSync(file, 'utf-8')\n if (!contents.includes(classNamePatch)) {\n const needle = `domProps.className = className`\n const patchLocation = contents.indexOf(needle) + needle.length + 5\n // its far down the file\n if (patchLocation < 100) {\n console.warn(\n `\u26A0\uFE0F Couldn't apply className patch! Maybe using incompatible react-native-web version.`\n )\n } else {\n const before = contents.slice(0, patchLocation)\n const after = contents.slice(patchLocation)\n const patched = before + '\\n' + classNamePatch + '\\n' + after\n console.log(' > adding className support to react-native-web', file)\n fs.writeFileSync(file, patched)\n }\n }\n }\n patchClassName(domPropsModulePath)\n patchClassName(domPropsCjsPath)\n\n // if (props.className) {\n // domProps.className = className ? className + ' ' + props.className : props.className\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;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,kBAAiB;AAQV,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY;AACxE,QAAM,aAAa,oBAAK,KAAK,SAAS,QAAQ;AAC9C,QAAM,UAAU,oBAAK,KAAK,SAAS,QAAQ,OAAO;AAElD,QAAM,UAAW,OAAM;AACrB,QAAI,MAAM;AACV,QAAI;AACF,YACE,GAAG,aAAa,YAAY,aAAa,iBACzC,GAAG,aAAa,SAAS,YAAY;AAAA,YACvC;AACA,YAAM;AAAA;AAER,WAAO;AAAA;AAGT,MAAI,CAAC,SAAS;AACZ,YAAQ,IAAI;AACZ,YAAQ,IAAI,eAAe;AAC3B,YAAQ,IAAI,eAAe;AAC3B,OAAG,cAAc,YAAY;AAC7B,OAAG,cAAc,SAAS;AAAA;AAI5B,QAAM,iBAAiB;AACvB,QAAM,eAAe,CAAC,WAAW,kBAAkB;AACnD,QAAM,qBAAqB,oBAAK,KAAK,SAAS,QAAQ,GAAG;AACzD,QAAM,kBAAkB,oBAAK,KAAK,SAAS,QAAQ,OAAO,GAAG;AAC7D,QAAM,iBAAiB,wBAAC,SAAiB;AACvC,UAAM,WAAW,GAAG,aAAa,MAAM;AACvC,QAAI,CAAC,SAAS,SAAS,iBAAiB;AACtC,YAAM,SAAS;AACf,YAAM,gBAAgB,SAAS,QAAQ,UAAU,OAAO,SAAS;AAEjE,UAAI,gBAAgB,KAAK;AACvB,gBAAQ,KACN;AAAA,aAEG;AACL,cAAM,SAAS,SAAS,MAAM,GAAG;AACjC,cAAM,QAAQ,SAAS,MAAM;AAC7B,cAAM,UAAU,SAAS,OAAO,iBAAiB,OAAO;AACxD,gBAAQ,IAAI,qDAAqD;AACjE,WAAG,cAAc,MAAM;AAAA;AAAA;AAAA,KAfN;AAmBvB,iBAAe;AACf,iBAAe;AAOf,QAAM,cAAc,oBAAK,KAAK,SAAS,QAAQ;AAC/C,QAAM,iBAAiB,GAAG,aAAa,aAAa;AACpD,MAAI,CAAC,eAAe,SAAS,wBAAwB;AACnD,OAAG,cACD,aACA,GAAG,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASnB,QAAM,WAAW,oBAAK,KAAK,SAAS,QAAQ,OAAO;AACnD,QAAM,cAAc,GAAG,aAAa,UAAU;AAC9C,MAAI,CAAC,YAAY,SAAS,wBAAwB;AAChD,OAAG,cACD,UACA,GAAG,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA5EL;AAsFhB,qBAAqB,QAAgB;AACnC,SAAO,OAAO,QAAQ,iCAAiC;AAAA;AADhD;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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
7
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(module2))
|
|
9
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
10
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
15
|
+
return (module2, temp) => {
|
|
16
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
17
|
+
};
|
|
18
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(types_exports);
|
|
21
|
+
//# sourceMappingURL=types.js.map
|