@tamagui/static 1.0.0-alpha.5 → 1.0.0-alpha.50
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 +919 -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 +124 -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 +289 -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 +62 -0
- package/dist/cjs/extractor/literalToAst.js.map +7 -0
- package/dist/cjs/extractor/loadTamagui.js +64 -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 +128 -76
- 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 +6 -4
- package/dist/{extractor → esm/extractor}/extractHelpers.js.map +3 -3
- package/dist/{extractor → esm/extractor}/extractMediaStyle.js +3 -2
- package/dist/{extractor → esm/extractor}/extractMediaStyle.js.map +2 -2
- package/dist/{extractor → esm/extractor}/extractToClassNames.js +38 -35
- 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/{extractor → esm/extractor}/literalToAst.js +0 -0
- package/dist/{extractor → esm/extractor}/literalToAst.js.map +1 -1
- package/dist/{extractor → esm/extractor}/loadTamagui.js +1 -1
- 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} +40 -3
- 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 +856 -0
- package/dist/jsx/extractor/ensureImportingConcat.js +23 -0
- package/dist/jsx/extractor/evaluateAstNode.js +93 -0
- package/dist/jsx/extractor/extractHelpers.js +95 -0
- package/dist/jsx/extractor/extractMediaStyle.js +151 -0
- package/dist/jsx/extractor/extractToClassNames.js +245 -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 +33 -0
- package/dist/jsx/extractor/loadTamagui.js +40 -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 +24 -18
- 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 +3 -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/extractToClassNames.js.map +0 -7
- package/dist/extractor/loadTamagui.js.map +0 -7
- package/dist/index.cjs +0 -2085
- 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 -1116
- 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 -337
- 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 -107
- package/src/types.ts +0 -80
- package/types.d.ts +0 -210
|
@@ -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 > 100) {
|
|
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 > 100) {\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,KAAK;AACtD,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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n exclude?: RegExp\n logTimings?: boolean\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: string[]\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: Object\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n sourcePath?: string\n shouldPrintDebug?: boolean\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type StyleObject = {\n property: string\n value: string\n className: string\n identifier: string\n rules: string[]\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,8 +2,12 @@ import findCacheDir from "find-cache-dir";
|
|
|
2
2
|
const CSS_FILE_NAME = "__snack.css";
|
|
3
3
|
const MEDIA_SEP = "_";
|
|
4
4
|
const cacheDir = findCacheDir({ name: "tamagui", create: true });
|
|
5
|
+
const FAILED_EVAL = Symbol("failed_style_eval");
|
|
6
|
+
const CONCAT_CLASSNAME_IMPORT = "concatClassName";
|
|
5
7
|
export {
|
|
8
|
+
CONCAT_CLASSNAME_IMPORT,
|
|
6
9
|
CSS_FILE_NAME,
|
|
10
|
+
FAILED_EVAL,
|
|
7
11
|
MEDIA_SEP,
|
|
8
12
|
cacheDir
|
|
9
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
4
|
-
"sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n"],
|
|
5
|
-
"mappings": "AAAA;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,WAAW,aAAa,EAAE,MAAM,WAAW,QAAQ;",
|
|
3
|
+
"sources": ["../../src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n\nexport const FAILED_EVAL = Symbol('failed_style_eval')\nexport const CONCAT_CLASSNAME_IMPORT = 'concatClassName'\n"],
|
|
5
|
+
"mappings": "AAAA;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,WAAW,aAAa,EAAE,MAAM,WAAW,QAAQ;AAEzD,MAAM,cAAc,OAAO;AAC3B,MAAM,0BAA0B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/extractor/accessSafe.ts"],
|
|
4
4
|
"sourcesContent": ["import * as t from '@babel/types'\n\n// accessSafe wraps memberExpressions in object/null checks\n// TODO: inject this as a function? this gets pretty repetitive\nexport function accessSafe(obj: t.Expression, member: string): t.LogicalExpression {\n return t.logicalExpression(\n '&&',\n t.logicalExpression(\n '&&',\n // typeof obj === 'object\n t.binaryExpression('===', t.unaryExpression('typeof', obj), t.stringLiteral('object')),\n // obj !== null\n t.binaryExpression('!==', obj, t.nullLiteral())\n ),\n // obj.member\n t.memberExpression(obj, t.identifier(member), false)\n )\n}\n"],
|
|
5
5
|
"mappings": ";;AAAA;AAIO,oBAAoB,KAAmB,QAAqC;AACjF,SAAO,EAAE,kBACP,MACA,EAAE,kBACA,MAEA,EAAE,iBAAiB,OAAO,EAAE,gBAAgB,UAAU,MAAM,EAAE,cAAc,YAE5E,EAAE,iBAAiB,OAAO,KAAK,EAAE,iBAGnC,EAAE,iBAAiB,KAAK,EAAE,WAAW,SAAS;AAAA;AAXlC;",
|
|
6
6
|
"names": []
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/extractor/babelParse.ts"],
|
|
4
4
|
"sourcesContent": ["import * as babelParser from '@babel/parser'\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins: [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n // 'objectRestSpread',\n // 'dynamicImport'\n ],\n sourceType: 'module',\n})\n\nconst parser = babelParser.parse.bind(babelParser)\n\nexport function babelParse(code: string | Buffer): any {\n return parser(code.toString(), parserOptions)\n}\n"],
|
|
5
5
|
"mappings": ";;AAAA;AAEO,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAIF,YAAY;AAAA;AAGd,MAAM,SAAS,YAAY,MAAM,KAAK;AAE/B,oBAAoB,MAA4B;AACrD,SAAO,OAAO,KAAK,YAAY;AAAA;AADjB;",
|
|
6
6
|
"names": []
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/extractor/buildClassName.ts"],
|
|
4
4
|
"sourcesContent": ["import * as t from '@babel/types'\n\nimport { ClassNameObject } from '../types'\n\nexport function buildClassName(\n classNameObjects: ClassNameObject[]\n): t.Expression | t.StringLiteral | null {\n return classNameObjects.reduce<t.Expression | null>((acc, val) => {\n if (acc == null) {\n if (\n // pass conditional expressions through\n t.isConditionalExpression(val) ||\n // pass non-null literals through\n t.isStringLiteral(val) ||\n t.isNumericLiteral(val)\n ) {\n return val\n }\n return t.logicalExpression('||', val, t.stringLiteral(''))\n }\n\n let inner: t.Expression\n if (t.isStringLiteral(val)) {\n if (t.isStringLiteral(acc)) {\n // join adjacent string literals\n return t.stringLiteral(`${acc.value} ${val.value}`)\n }\n inner = t.stringLiteral(` ${val.value}`)\n } else if (t.isLiteral(val)) {\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression('+', t.stringLiteral(`${acc.value} `), val)\n }\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {\n // identifiers and member expressions make for reasonable ternaries\n inner = t.conditionalExpression(\n val,\n t.binaryExpression('+', t.stringLiteral(' '), val),\n t.stringLiteral('')\n )\n } else {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression(\n '+',\n t.stringLiteral(`${acc.value} `),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n // use a logical expression for more complex prop values\n inner = t.binaryExpression(\n '+',\n t.stringLiteral(' '),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n\n return t.binaryExpression('+', acc, inner)\n }, null)\n}\n"],
|
|
5
5
|
"mappings": ";;AAAA;AAIO,wBACL,kBACuC;AACvC,SAAO,iBAAiB,OAA4B,CAAC,KAAK,QAAQ;AAChE,QAAI,OAAO,MAAM;AACf,UAEE,EAAE,wBAAwB,QAE1B,EAAE,gBAAgB,QAClB,EAAE,iBAAiB,MACnB;AACA,eAAO;AAAA;AAET,aAAO,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc;AAAA;AAGxD,QAAI;AACJ,QAAI,EAAE,gBAAgB,MAAM;AAC1B,UAAI,EAAE,gBAAgB,MAAM;AAE1B,eAAO,EAAE,cAAc,GAAG,IAAI,SAAS,IAAI;AAAA;AAE7C,cAAQ,EAAE,cAAc,IAAI,IAAI;AAAA,eACvB,EAAE,UAAU,MAAM;AAC3B,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,MAAM;AAAA,eAC7C,EAAE,wBAAwB,QAAQ,EAAE,mBAAmB,MAAM;AACtE,UAAI,EAAE,gBAAgB,MAAM;AAC1B,eAAO,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,IAAI,WAAW;AAAA;AAEnE,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,MAAM;AAAA,eAC7C,EAAE,aAAa,QAAQ,EAAE,mBAAmB,MAAM;AAE3D,cAAQ,EAAE,sBACR,KACA,EAAE,iBAAiB,KAAK,EAAE,cAAc,MAAM,MAC9C,EAAE,cAAc;AAAA,WAEb;AACL,UAAI,EAAE,gBAAgB,MAAM;AAC1B,eAAO,EAAE,iBACP,KACA,EAAE,cAAc,GAAG,IAAI,WACvB,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc;AAAA;AAInD,cAAQ,EAAE,iBACR,KACA,EAAE,cAAc,MAChB,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc;AAAA;AAInD,WAAO,EAAE,iBAAiB,KAAK,KAAK;AAAA,KACnC;AAAA;AAvDW;",
|
|
6
6
|
"names": []
|