@tamagui/static 1.0.1-beta.20 → 1.0.1-beta.201
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 → constants.js} +9 -4
- package/dist/constants.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/accessSafe.js +14 -4
- package/dist/{esm/extractor → extractor}/accessSafe.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/babelParse.js +20 -17
- package/dist/extractor/babelParse.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/buildClassName.js +40 -11
- package/dist/extractor/buildClassName.js.map +7 -0
- package/dist/extractor/bundle.js +117 -0
- package/dist/extractor/bundle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/createEvaluator.js +19 -14
- package/dist/extractor/createEvaluator.js.map +7 -0
- package/dist/extractor/createExtractor.js +1650 -0
- package/dist/extractor/createExtractor.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +18 -8
- package/dist/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/evaluateAstNode.js +14 -6
- package/dist/{esm/extractor → extractor}/evaluateAstNode.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/extractHelpers.js +91 -27
- package/dist/extractor/extractHelpers.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +49 -50
- package/dist/extractor/extractMediaStyle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractToClassNames.js +161 -109
- package/dist/extractor/extractToClassNames.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/findTopmostFunction.js +2 -3
- package/dist/{esm/extractor → extractor}/findTopmostFunction.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/generatedUid.js +9 -4
- package/dist/{cjs/extractor → extractor}/generatedUid.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/getPrefixLogs.js +1 -2
- package/dist/extractor/getPrefixLogs.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getPropValueFromAttributes.js +24 -15
- package/dist/extractor/getPropValueFromAttributes.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getSourceModule.js +5 -3
- package/dist/{esm/extractor → extractor}/getSourceModule.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/getStaticBindingsForScope.js +88 -38
- package/dist/extractor/getStaticBindingsForScope.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/hoistClassNames.js +5 -4
- package/dist/{esm/extractor → extractor}/hoistClassNames.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/literalToAst.js +26 -34
- package/dist/{cjs/extractor → extractor}/literalToAst.js.map +2 -2
- package/dist/extractor/loadFile.js +21 -0
- package/dist/extractor/loadFile.js.map +7 -0
- package/dist/extractor/loadTamagui.js +421 -0
- package/dist/extractor/loadTamagui.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/logLines.js +3 -3
- package/dist/{cjs/extractor → extractor}/logLines.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/normalizeTernaries.js +13 -36
- package/dist/extractor/normalizeTernaries.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js +7 -5
- package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/timer.js +11 -4
- package/dist/extractor/timer.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js +52 -0
- package/dist/extractor/validHTMLAttributes.js.map +7 -0
- package/dist/getPragmaOptions.js +68 -0
- package/dist/getPragmaOptions.js.map +7 -0
- package/dist/helpers/memoize.js +46 -0
- package/dist/helpers/memoize.js.map +7 -0
- package/dist/{cjs/index.js → index.js} +10 -7
- package/dist/index.js.map +7 -0
- package/dist/require.js +90 -0
- package/dist/require.js.map +7 -0
- package/dist/tamagui-node/tamagui.config.js +6781 -0
- package/dist/{jsx/types.js → tamagui-node/tamaguicore-components.config.js} +0 -0
- package/dist/tamagui-node/tamaguitestdesignsystem-components.config.js +31 -0
- package/dist/{cjs/types.js → types.js} +1 -0
- package/dist/types.js.map +7 -0
- package/dist/webpackPlugin.js +35 -0
- package/dist/webpackPlugin.js.map +7 -0
- package/package.json +47 -35
- package/src/constants.ts +14 -0
- package/src/extractor/accessSafe.ts +18 -0
- package/src/extractor/babelParse.ts +28 -0
- package/src/extractor/buildClassName.ts +77 -0
- package/src/extractor/bundle.ts +110 -0
- package/src/extractor/createEvaluator.ts +73 -0
- package/src/extractor/createExtractor.ts +2147 -0
- package/src/extractor/ensureImportingConcat.ts +32 -0
- package/src/extractor/evaluateAstNode.ts +121 -0
- package/src/extractor/extractHelpers.ts +201 -0
- package/src/extractor/extractMediaStyle.ts +199 -0
- package/src/extractor/extractToClassNames.ts +445 -0
- package/src/extractor/findTopmostFunction.ts +22 -0
- package/src/extractor/generatedUid.ts +43 -0
- package/src/extractor/getPrefixLogs.ts +6 -0
- package/src/extractor/getPropValueFromAttributes.ts +92 -0
- package/src/extractor/getSourceModule.ts +101 -0
- package/src/extractor/getStaticBindingsForScope.ts +227 -0
- package/src/extractor/hoistClassNames.ts +45 -0
- package/src/extractor/literalToAst.ts +84 -0
- package/src/extractor/loadFile.ts +17 -0
- package/src/extractor/loadTamagui.ts +478 -0
- package/src/extractor/logLines.ts +16 -0
- package/src/extractor/normalizeTernaries.ts +63 -0
- package/src/extractor/removeUnusedHooks.ts +76 -0
- package/src/extractor/timer.ts +29 -0
- package/src/extractor/validHTMLAttributes.ts +99 -0
- package/src/getPragmaOptions.ts +53 -0
- package/src/helpers/memoize.ts +21 -0
- package/src/index.ts +11 -0
- package/src/require.ts +107 -0
- package/src/types.ts +98 -0
- package/src/webpackPlugin.ts +9 -0
- package/tamagui.tsconfig.json +5 -0
- package/types/constants.d.ts +1 -1
- package/types/extractor/babelParse.d.ts +2 -1
- package/types/extractor/buildClassName.d.ts +5 -2
- package/types/extractor/bundle.d.ts +13 -0
- package/types/extractor/createEvaluator.d.ts +4 -4
- package/types/extractor/createExtractor.d.ts +26 -11
- package/types/extractor/extractHelpers.d.ts +16 -4
- package/types/extractor/extractMediaStyle.d.ts +3 -3
- package/types/extractor/extractToClassNames.d.ts +5 -9
- package/types/extractor/getPrefixLogs.d.ts +1 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +16 -0
- package/types/extractor/getStaticBindingsForScope.d.ts +2 -1
- package/types/extractor/loadFile.d.ts +1 -0
- package/types/extractor/loadTamagui.d.ts +22 -6
- package/types/extractor/normalizeTernaries.d.ts +1 -1
- package/types/extractor/validHTMLAttributes.d.ts +49 -0
- package/types/getPragmaOptions.d.ts +9 -0
- package/types/helpers/memoize.d.ts +8 -0
- package/types/index.d.ts +9 -7
- package/types/require.d.ts +4 -0
- package/types/types.d.ts +32 -32
- package/types/webpackPlugin.d.ts +4 -0
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/extractor/accessSafe.js.map +0 -7
- package/dist/cjs/extractor/babelParse.js.map +0 -7
- package/dist/cjs/extractor/buildClassName.js.map +0 -7
- package/dist/cjs/extractor/createEvaluator.js.map +0 -7
- package/dist/cjs/extractor/createExtractor.js +0 -1221
- package/dist/cjs/extractor/createExtractor.js.map +0 -7
- package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
- package/dist/cjs/extractor/extractHelpers.js.map +0 -7
- package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
- package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
- package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
- package/dist/cjs/extractor/getPrefixLogs.js.map +0 -7
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/cjs/extractor/getSourceModule.js.map +0 -7
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
- package/dist/cjs/extractor/loadTamagui.js +0 -106
- package/dist/cjs/extractor/loadTamagui.js.map +0 -7
- package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
- package/dist/cjs/extractor/timer.js.map +0 -7
- package/dist/cjs/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/patchReactNativeWeb.js +0 -167
- package/dist/cjs/patchReactNativeWeb.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/constants.js +0 -14
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/extractor/accessSafe.js +0 -11
- package/dist/esm/extractor/babelParse.js +0 -30
- package/dist/esm/extractor/babelParse.js.map +0 -7
- package/dist/esm/extractor/buildClassName.js +0 -40
- package/dist/esm/extractor/buildClassName.js.map +0 -7
- package/dist/esm/extractor/createEvaluator.js +0 -52
- package/dist/esm/extractor/createEvaluator.js.map +0 -7
- package/dist/esm/extractor/createExtractor.js +0 -1169
- package/dist/esm/extractor/createExtractor.js.map +0 -7
- package/dist/esm/extractor/ensureImportingConcat.js +0 -24
- package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/esm/extractor/evaluateAstNode.js +0 -94
- package/dist/esm/extractor/extractHelpers.js +0 -103
- package/dist/esm/extractor/extractHelpers.js.map +0 -7
- package/dist/esm/extractor/extractMediaStyle.js +0 -152
- package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
- package/dist/esm/extractor/extractToClassNames.js +0 -293
- package/dist/esm/extractor/extractToClassNames.js.map +0 -7
- package/dist/esm/extractor/findTopmostFunction.js +0 -23
- package/dist/esm/extractor/generatedUid.js +0 -28
- package/dist/esm/extractor/generatedUid.js.map +0 -7
- package/dist/esm/extractor/getPrefixLogs.js +0 -12
- package/dist/esm/extractor/getPrefixLogs.js.map +0 -7
- package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/esm/extractor/getSourceModule.js +0 -69
- package/dist/esm/extractor/getStaticBindingsForScope.js +0 -137
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/esm/extractor/hoistClassNames.js +0 -44
- package/dist/esm/extractor/literalToAst.js +0 -80
- package/dist/esm/extractor/literalToAst.js.map +0 -7
- package/dist/esm/extractor/loadTamagui.js +0 -84
- package/dist/esm/extractor/loadTamagui.js.map +0 -7
- package/dist/esm/extractor/logLines.js +0 -22
- package/dist/esm/extractor/logLines.js.map +0 -7
- package/dist/esm/extractor/normalizeTernaries.js +0 -53
- package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
- package/dist/esm/extractor/removeUnusedHooks.js +0 -80
- package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/esm/extractor/timer.js +0 -24
- package/dist/esm/extractor/timer.js.map +0 -7
- package/dist/esm/extractor/validHTMLAttributes.js +0 -52
- package/dist/esm/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/patchReactNativeWeb.js +0 -142
- package/dist/esm/patchReactNativeWeb.js.map +0 -7
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/jsx/constants.js +0 -13
- package/dist/jsx/extractor/accessSafe.js +0 -10
- package/dist/jsx/extractor/babelParse.js +0 -29
- package/dist/jsx/extractor/buildClassName.js +0 -39
- package/dist/jsx/extractor/createEvaluator.js +0 -51
- package/dist/jsx/extractor/createExtractor.js +0 -1168
- package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
- package/dist/jsx/extractor/evaluateAstNode.js +0 -93
- package/dist/jsx/extractor/extractHelpers.js +0 -102
- package/dist/jsx/extractor/extractMediaStyle.js +0 -151
- package/dist/jsx/extractor/extractToClassNames.js +0 -292
- package/dist/jsx/extractor/findTopmostFunction.js +0 -22
- package/dist/jsx/extractor/generatedUid.js +0 -27
- package/dist/jsx/extractor/getPrefixLogs.js +0 -11
- package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
- package/dist/jsx/extractor/getSourceModule.js +0 -68
- package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -136
- package/dist/jsx/extractor/hoistClassNames.js +0 -43
- package/dist/jsx/extractor/literalToAst.js +0 -79
- package/dist/jsx/extractor/loadTamagui.js +0 -83
- package/dist/jsx/extractor/logLines.js +0 -21
- package/dist/jsx/extractor/normalizeTernaries.js +0 -52
- package/dist/jsx/extractor/removeUnusedHooks.js +0 -79
- package/dist/jsx/extractor/timer.js +0 -23
- package/dist/jsx/extractor/validHTMLAttributes.js +0 -51
- package/dist/jsx/index.js +0 -13
- package/dist/jsx/patchReactNativeWeb.js +0 -141
- package/types/constants.d.ts.map +0 -1
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadTamagui.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/patchReactNativeWeb.d.ts +0 -2
- package/types/patchReactNativeWeb.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
import invariant from "invariant";
|
|
5
|
-
function generateUid(scope, name) {
|
|
6
|
-
invariant(typeof scope === "object", "generateUid expects a scope object as its first parameter");
|
|
7
|
-
invariant(typeof name === "string" && name !== "", "generateUid expects a valid name as its second parameter");
|
|
8
|
-
name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
|
|
9
|
-
let uid;
|
|
10
|
-
let i = 0;
|
|
11
|
-
do {
|
|
12
|
-
if (i > 1) {
|
|
13
|
-
uid = name + i;
|
|
14
|
-
} else {
|
|
15
|
-
uid = name;
|
|
16
|
-
}
|
|
17
|
-
i++;
|
|
18
|
-
} while (scope.hasLabel(uid) || scope.hasBinding(uid) || scope.hasGlobal(uid) || scope.hasReference(uid));
|
|
19
|
-
const program = scope.getProgramParent();
|
|
20
|
-
program.references[uid] = true;
|
|
21
|
-
program.uids[uid] = true;
|
|
22
|
-
return uid;
|
|
23
|
-
}
|
|
24
|
-
__name(generateUid, "generateUid");
|
|
25
|
-
export {
|
|
26
|
-
generateUid
|
|
27
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function getPrefixLogs(options) {
|
|
4
|
-
var _a;
|
|
5
|
-
const { TAMAGUI_TARGET } = process.env;
|
|
6
|
-
return (_a = options == null ? void 0 : options.prefixLogs) != null ? _a : ` ${TAMAGUI_TARGET} | `;
|
|
7
|
-
}
|
|
8
|
-
__name(getPrefixLogs, "getPrefixLogs");
|
|
9
|
-
export {
|
|
10
|
-
getPrefixLogs
|
|
11
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import generate from "@babel/generator";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
import { accessSafe } from "./accessSafe";
|
|
6
|
-
function getPropValueFromAttributes(propName, attrs) {
|
|
7
|
-
let propIndex = -1;
|
|
8
|
-
let jsxAttr = null;
|
|
9
|
-
for (let idx = -1, len = attrs.length; ++idx < len; ) {
|
|
10
|
-
const attr = attrs[idx];
|
|
11
|
-
if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {
|
|
12
|
-
propIndex = idx;
|
|
13
|
-
jsxAttr = attr;
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (!jsxAttr || jsxAttr.value == null) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
let propValue = jsxAttr.value;
|
|
21
|
-
if (t.isJSXExpressionContainer(propValue)) {
|
|
22
|
-
propValue = propValue.expression;
|
|
23
|
-
}
|
|
24
|
-
if (t.isJSXEmptyExpression(propValue)) {
|
|
25
|
-
console.error("encountered JSXEmptyExpression");
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const applicableSpreads = attrs.filter((attr, idx) => {
|
|
29
|
-
if (t.isJSXSpreadAttribute(attr)) {
|
|
30
|
-
if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {
|
|
31
|
-
return idx > propIndex;
|
|
32
|
-
}
|
|
33
|
-
if (t.isLogicalExpression(attr.argument)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
throw new Error(`unsupported spread of type "${attr.argument.type}": ${generate(attr).code}`);
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
}).map((attr) => attr.argument);
|
|
40
|
-
if (applicableSpreads.length > 0) {
|
|
41
|
-
propValue = applicableSpreads.reduce((acc, val) => t.logicalExpression("||", accessSafe(val, propName), acc), propValue);
|
|
42
|
-
}
|
|
43
|
-
return propValue;
|
|
44
|
-
}
|
|
45
|
-
__name(getPropValueFromAttributes, "getPropValueFromAttributes");
|
|
46
|
-
export {
|
|
47
|
-
getPropValueFromAttributes
|
|
48
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
function getSourceModule(itemName, itemBinding) {
|
|
5
|
-
if (!itemBinding.constant) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
let sourceModule;
|
|
9
|
-
let imported;
|
|
10
|
-
let local;
|
|
11
|
-
let destructured;
|
|
12
|
-
let usesImportSyntax = false;
|
|
13
|
-
const itemNode = itemBinding.path.node;
|
|
14
|
-
if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
|
|
15
|
-
if (t.isImportDeclaration(itemBinding.path.parent)) {
|
|
16
|
-
sourceModule = itemBinding.path.parent.source.value;
|
|
17
|
-
local = itemNode.local.name;
|
|
18
|
-
usesImportSyntax = true;
|
|
19
|
-
if (t.isImportSpecifier(itemNode)) {
|
|
20
|
-
imported = itemNode.imported["name"];
|
|
21
|
-
destructured = true;
|
|
22
|
-
} else {
|
|
23
|
-
imported = itemNode.local.name;
|
|
24
|
-
destructured = false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
} else if (t.isVariableDeclarator(itemNode) && itemNode.init != null && t.isCallExpression(itemNode.init) && t.isIdentifier(itemNode.init.callee) && itemNode.init.callee.name === "require" && itemNode.init.arguments.length === 1) {
|
|
28
|
-
const firstArg = itemNode.init.arguments[0];
|
|
29
|
-
if (!t.isStringLiteral(firstArg)) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
sourceModule = firstArg.value;
|
|
33
|
-
if (t.isIdentifier(itemNode.id)) {
|
|
34
|
-
local = itemNode.id.name;
|
|
35
|
-
imported = itemNode.id.name;
|
|
36
|
-
destructured = false;
|
|
37
|
-
} else if (t.isObjectPattern(itemNode.id)) {
|
|
38
|
-
for (const objProp of itemNode.id.properties) {
|
|
39
|
-
if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
|
|
40
|
-
local = objProp.value.name;
|
|
41
|
-
imported = objProp.key.name;
|
|
42
|
-
destructured = true;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (!local || !imported) {
|
|
47
|
-
console.error("could not find prop with value `%s`", itemName);
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
console.error("Unhandled id type: %s", itemNode.id.type);
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
destructured,
|
|
59
|
-
imported,
|
|
60
|
-
local,
|
|
61
|
-
sourceModule,
|
|
62
|
-
usesImportSyntax
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
__name(getSourceModule, "getSourceModule");
|
|
66
|
-
export {
|
|
67
|
-
getSourceModule
|
|
68
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { dirname, extname, resolve } from "path";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
import { existsSync } from "fs-extra";
|
|
6
|
-
import { evaluateAstNode } from "./evaluateAstNode";
|
|
7
|
-
import { getSourceModule } from "./getSourceModule";
|
|
8
|
-
const isLocalImport = /* @__PURE__ */ __name((path) => path.startsWith(".") || path.startsWith("/"), "isLocalImport");
|
|
9
|
-
function resolveImportPath(sourcePath, path) {
|
|
10
|
-
const sourceDir = dirname(sourcePath);
|
|
11
|
-
if (isLocalImport(path)) {
|
|
12
|
-
if (extname(path) === "") {
|
|
13
|
-
path += ".js";
|
|
14
|
-
}
|
|
15
|
-
return resolve(sourceDir, path);
|
|
16
|
-
}
|
|
17
|
-
return path;
|
|
18
|
-
}
|
|
19
|
-
__name(resolveImportPath, "resolveImportPath");
|
|
20
|
-
function importModule(path) {
|
|
21
|
-
const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
|
|
22
|
-
for (const file of filenames) {
|
|
23
|
-
if (existsSync(file)) {
|
|
24
|
-
const { unregister } = require("esbuild-register/dist/node").register({
|
|
25
|
-
target: "es2019",
|
|
26
|
-
format: "cjs"
|
|
27
|
-
});
|
|
28
|
-
try {
|
|
29
|
-
return require(file);
|
|
30
|
-
} catch {
|
|
31
|
-
} finally {
|
|
32
|
-
unregister();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
__name(importModule, "importModule");
|
|
39
|
-
function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
|
|
40
|
-
const bindings = scope.getAllBindings();
|
|
41
|
-
const ret = {};
|
|
42
|
-
if (shouldPrintDebug) {
|
|
43
|
-
console.log(" ", Object.keys(bindings).length, "variables in scope");
|
|
44
|
-
}
|
|
45
|
-
const program = scope.getProgramParent().block;
|
|
46
|
-
for (const node of program.body) {
|
|
47
|
-
if (t.isImportDeclaration(node)) {
|
|
48
|
-
const importPath = node.source.value;
|
|
49
|
-
if (!node.specifiers.length)
|
|
50
|
-
continue;
|
|
51
|
-
if (!isLocalImport(importPath)) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const moduleName = resolveImportPath(sourcePath, importPath);
|
|
55
|
-
const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
|
|
56
|
-
if (!isOnWhitelist)
|
|
57
|
-
continue;
|
|
58
|
-
const src = importModule(moduleName);
|
|
59
|
-
if (!src)
|
|
60
|
-
continue;
|
|
61
|
-
for (const specifier of node.specifiers) {
|
|
62
|
-
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
|
|
63
|
-
if (typeof src[specifier.imported.name] !== "undefined") {
|
|
64
|
-
const val = src[specifier.local.name];
|
|
65
|
-
ret[specifier.local.name] = val;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!bindingCache) {
|
|
72
|
-
throw new Error("bindingCache is a required param");
|
|
73
|
-
}
|
|
74
|
-
for (const k in bindings) {
|
|
75
|
-
const binding = bindings[k];
|
|
76
|
-
const sourceModule = getSourceModule(k, binding);
|
|
77
|
-
if (sourceModule) {
|
|
78
|
-
if (!sourceModule.sourceModule) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule);
|
|
82
|
-
const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
|
|
83
|
-
if (isOnWhitelist) {
|
|
84
|
-
const src = importModule(moduleName);
|
|
85
|
-
if (!src) {
|
|
86
|
-
console.log(`\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`);
|
|
87
|
-
return {};
|
|
88
|
-
}
|
|
89
|
-
if (sourceModule.destructured) {
|
|
90
|
-
if (sourceModule.imported) {
|
|
91
|
-
ret[k] = src[sourceModule.imported];
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
ret[k] = src;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const { parent, parentPath } = binding.path;
|
|
100
|
-
if (!t.isVariableDeclaration(parent) || parent.kind !== "const") {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k);
|
|
104
|
-
if (!dec || !dec.init) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (typeof dec.id.start !== "number" || typeof dec.id.end !== "number") {
|
|
108
|
-
console.error("dec.id.start/end is not a number");
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (!t.isIdentifier(dec.id)) {
|
|
112
|
-
console.error("dec is not an identifier");
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`;
|
|
116
|
-
if (bindingCache.hasOwnProperty(cacheKey)) {
|
|
117
|
-
ret[k] = bindingCache[cacheKey];
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
if (bindingCache.hasOwnProperty(cacheKey)) {
|
|
121
|
-
ret[k] = bindingCache[cacheKey];
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
ret[k] = evaluateAstNode(dec.init, void 0, shouldPrintDebug);
|
|
126
|
-
bindingCache[cacheKey] = ret[k];
|
|
127
|
-
continue;
|
|
128
|
-
} catch (e) {
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return ret;
|
|
132
|
-
}
|
|
133
|
-
__name(getStaticBindingsForScope, "getStaticBindingsForScope");
|
|
134
|
-
export {
|
|
135
|
-
getStaticBindingsForScope
|
|
136
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
function hoistClassNames(path, existing, expr) {
|
|
5
|
-
const hoist = hoistClassNames.bind(null, path, existing);
|
|
6
|
-
if (t.isStringLiteral(expr)) {
|
|
7
|
-
if (expr.value.trim() === "") {
|
|
8
|
-
return expr;
|
|
9
|
-
}
|
|
10
|
-
if (existing[expr.value]) {
|
|
11
|
-
return existing[expr.value];
|
|
12
|
-
}
|
|
13
|
-
const identifier = replaceStringWithVariable(expr);
|
|
14
|
-
existing[expr.value] = identifier;
|
|
15
|
-
return identifier;
|
|
16
|
-
}
|
|
17
|
-
if (t.isBinaryExpression(expr)) {
|
|
18
|
-
return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
|
|
19
|
-
}
|
|
20
|
-
if (t.isLogicalExpression(expr)) {
|
|
21
|
-
return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
|
|
22
|
-
}
|
|
23
|
-
if (t.isConditionalExpression(expr)) {
|
|
24
|
-
return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
|
|
25
|
-
}
|
|
26
|
-
return expr;
|
|
27
|
-
function replaceStringWithVariable(str) {
|
|
28
|
-
const uid = path.scope.generateUidIdentifier("cn");
|
|
29
|
-
const parent = path.findParent((path2) => path2.isProgram());
|
|
30
|
-
if (!parent)
|
|
31
|
-
throw new Error(`no program?`);
|
|
32
|
-
const variable = t.variableDeclaration("const", [
|
|
33
|
-
t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))
|
|
34
|
-
]);
|
|
35
|
-
parent.unshiftContainer("body", variable);
|
|
36
|
-
return uid;
|
|
37
|
-
}
|
|
38
|
-
__name(replaceStringWithVariable, "replaceStringWithVariable");
|
|
39
|
-
}
|
|
40
|
-
__name(hoistClassNames, "hoistClassNames");
|
|
41
|
-
export {
|
|
42
|
-
hoistClassNames
|
|
43
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
function literalToAst(literal) {
|
|
5
|
-
if (literal === null) {
|
|
6
|
-
return t.nullLiteral();
|
|
7
|
-
}
|
|
8
|
-
switch (typeof literal) {
|
|
9
|
-
case "function":
|
|
10
|
-
throw new Error("Unsupported");
|
|
11
|
-
case "number":
|
|
12
|
-
return t.numericLiteral(literal);
|
|
13
|
-
case "string":
|
|
14
|
-
return t.stringLiteral(literal);
|
|
15
|
-
case "boolean":
|
|
16
|
-
return t.booleanLiteral(literal);
|
|
17
|
-
case "undefined":
|
|
18
|
-
return t.unaryExpression("void", t.numericLiteral(0), true);
|
|
19
|
-
default:
|
|
20
|
-
if (Array.isArray(literal)) {
|
|
21
|
-
return t.arrayExpression(literal.map(literalToAst));
|
|
22
|
-
}
|
|
23
|
-
return t.objectExpression(Object.keys(literal).filter((k) => {
|
|
24
|
-
return typeof literal[k] !== "undefined";
|
|
25
|
-
}).map((k) => {
|
|
26
|
-
return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]));
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
__name(literalToAst, "literalToAst");
|
|
31
|
-
const easyPeasies = ["BooleanLiteral", "StringLiteral", "NumericLiteral"];
|
|
32
|
-
function astToLiteral(node) {
|
|
33
|
-
if (!node) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (easyPeasies.includes(node.type)) {
|
|
37
|
-
return node.value;
|
|
38
|
-
}
|
|
39
|
-
if (node.name === "undefined" && !node.value) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
if (t.isNullLiteral(node)) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
if (t.isObjectExpression(node)) {
|
|
46
|
-
return computeProps(node.properties);
|
|
47
|
-
}
|
|
48
|
-
if (t.isArrayExpression(node)) {
|
|
49
|
-
return node.elements.reduce((acc, element) => [
|
|
50
|
-
...acc,
|
|
51
|
-
...(element == null ? void 0 : element.type) === "SpreadElement" ? astToLiteral(element.argument) : [astToLiteral(element)]
|
|
52
|
-
], []);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
__name(astToLiteral, "astToLiteral");
|
|
56
|
-
function computeProps(props) {
|
|
57
|
-
return props.reduce((acc, prop) => {
|
|
58
|
-
if (prop.type === "SpreadElement") {
|
|
59
|
-
return {
|
|
60
|
-
...acc,
|
|
61
|
-
...astToLiteral(prop.argument)
|
|
62
|
-
};
|
|
63
|
-
} else if (prop.type !== "ObjectMethod") {
|
|
64
|
-
const val = astToLiteral(prop.value);
|
|
65
|
-
if (val !== void 0) {
|
|
66
|
-
return {
|
|
67
|
-
...acc,
|
|
68
|
-
[prop.key.name]: val
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return acc;
|
|
73
|
-
}, {});
|
|
74
|
-
}
|
|
75
|
-
__name(computeProps, "computeProps");
|
|
76
|
-
export {
|
|
77
|
-
astToLiteral,
|
|
78
|
-
literalToAst
|
|
79
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { createTamagui } from "@tamagui/core-node";
|
|
5
|
-
let loadedTamagui = null;
|
|
6
|
-
function loadTamagui(props) {
|
|
7
|
-
if (loadedTamagui) {
|
|
8
|
-
return loadedTamagui;
|
|
9
|
-
}
|
|
10
|
-
const configPath = join(process.cwd(), props.config);
|
|
11
|
-
const { unregister } = require("esbuild-register/dist/node").register({
|
|
12
|
-
target: "es2019",
|
|
13
|
-
format: "cjs"
|
|
14
|
-
});
|
|
15
|
-
try {
|
|
16
|
-
process.env.IS_STATIC = "is_static";
|
|
17
|
-
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
18
|
-
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
19
|
-
}
|
|
20
|
-
const proxyWorm = require("@tamagui/proxy-worm");
|
|
21
|
-
const rnw = require("react-native-web");
|
|
22
|
-
const Mod = require("module");
|
|
23
|
-
const og = Mod.prototype.require;
|
|
24
|
-
Mod.prototype.require = function(path) {
|
|
25
|
-
if (path.endsWith(".css")) {
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
|
|
29
|
-
return proxyWorm;
|
|
30
|
-
}
|
|
31
|
-
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
32
|
-
return rnw;
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
return og.apply(this, arguments);
|
|
36
|
-
} catch (err) {
|
|
37
|
-
console.error("Tamagui error loading file:\n");
|
|
38
|
-
console.log(" ", path, "\n");
|
|
39
|
-
console.log(err.message);
|
|
40
|
-
console.log(err.stack);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const exp = require(configPath);
|
|
45
|
-
const tamaguiConfig = exp["default"] || exp;
|
|
46
|
-
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
47
|
-
try {
|
|
48
|
-
const confPath = require.resolve(configPath);
|
|
49
|
-
console.log(`Received:`, tamaguiConfig);
|
|
50
|
-
throw new Error(`Can't find valid config in ${confPath}`);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const components = {};
|
|
56
|
-
for (const moduleName of props.components) {
|
|
57
|
-
const exported = require(moduleName);
|
|
58
|
-
for (const Name in exported) {
|
|
59
|
-
const val = exported[Name];
|
|
60
|
-
const staticConfig = val == null ? void 0 : val.staticConfig;
|
|
61
|
-
if (staticConfig) {
|
|
62
|
-
Object.assign(components, { [Name]: { staticConfig } });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
process.env.IS_STATIC = void 0;
|
|
67
|
-
Mod.prototype.require = og;
|
|
68
|
-
createTamagui(tamaguiConfig);
|
|
69
|
-
loadedTamagui = {
|
|
70
|
-
components,
|
|
71
|
-
tamaguiConfig
|
|
72
|
-
};
|
|
73
|
-
return loadedTamagui;
|
|
74
|
-
} catch (err) {
|
|
75
|
-
throw err;
|
|
76
|
-
} finally {
|
|
77
|
-
unregister();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
__name(loadTamagui, "loadTamagui");
|
|
81
|
-
export {
|
|
82
|
-
loadTamagui
|
|
83
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const prefix = " ";
|
|
4
|
-
const logLines = /* @__PURE__ */ __name((str, singleLine = false) => {
|
|
5
|
-
if (singleLine) {
|
|
6
|
-
return prefix + str.split(" ").join(`
|
|
7
|
-
${prefix}`);
|
|
8
|
-
}
|
|
9
|
-
let lines = [""];
|
|
10
|
-
const items = str.split(" ");
|
|
11
|
-
for (const item of items) {
|
|
12
|
-
if (item.length + lines[lines.length - 1].length > 85) {
|
|
13
|
-
lines.push("");
|
|
14
|
-
}
|
|
15
|
-
lines[lines.length - 1] += item + " ";
|
|
16
|
-
}
|
|
17
|
-
return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
18
|
-
}, "logLines");
|
|
19
|
-
export {
|
|
20
|
-
logLines
|
|
21
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import generate from "@babel/generator";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
import invariant from "invariant";
|
|
6
|
-
function normalizeTernaries(ternaries) {
|
|
7
|
-
var _a, _b;
|
|
8
|
-
invariant(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
|
|
9
|
-
if (ternaries.length === 0) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
const ternariesByKey = {};
|
|
13
|
-
for (let idx = -1, len = ternaries.length; ++idx < len; ) {
|
|
14
|
-
const { test, consequent, alternate, remove, ...rest } = ternaries[idx];
|
|
15
|
-
let ternaryTest = test;
|
|
16
|
-
if (t.isExpressionStatement(test)) {
|
|
17
|
-
ternaryTest = test.expression;
|
|
18
|
-
}
|
|
19
|
-
let shouldSwap = false;
|
|
20
|
-
if (t.isUnaryExpression(test) && test.operator === "!") {
|
|
21
|
-
ternaryTest = test.argument;
|
|
22
|
-
shouldSwap = true;
|
|
23
|
-
} else if (t.isBinaryExpression(test)) {
|
|
24
|
-
if (test.operator === "!==" || test.operator === "!=") {
|
|
25
|
-
ternaryTest = t.binaryExpression(test.operator, test.left, test.right);
|
|
26
|
-
shouldSwap = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const key = generate(ternaryTest).code;
|
|
30
|
-
if (!ternariesByKey[key]) {
|
|
31
|
-
ternariesByKey[key] = {
|
|
32
|
-
...rest,
|
|
33
|
-
alternate: {},
|
|
34
|
-
consequent: {},
|
|
35
|
-
test: ternaryTest,
|
|
36
|
-
remove
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const altStyle = (_a = shouldSwap ? consequent : alternate) != null ? _a : {};
|
|
40
|
-
const consStyle = (_b = shouldSwap ? alternate : consequent) != null ? _b : {};
|
|
41
|
-
Object.assign(ternariesByKey[key].alternate, altStyle);
|
|
42
|
-
Object.assign(ternariesByKey[key].consequent, consStyle);
|
|
43
|
-
}
|
|
44
|
-
const ternaryExpression = Object.keys(ternariesByKey).map((key) => {
|
|
45
|
-
return ternariesByKey[key];
|
|
46
|
-
});
|
|
47
|
-
return ternaryExpression;
|
|
48
|
-
}
|
|
49
|
-
__name(normalizeTernaries, "normalizeTernaries");
|
|
50
|
-
export {
|
|
51
|
-
normalizeTernaries
|
|
52
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
const hooks = {
|
|
5
|
-
useMedia: true,
|
|
6
|
-
useTheme: true
|
|
7
|
-
};
|
|
8
|
-
function removeUnusedHooks(compFn, shouldPrintDebug) {
|
|
9
|
-
var _a;
|
|
10
|
-
compFn.scope.crawl();
|
|
11
|
-
let bodyStatements = compFn == null ? void 0 : compFn.get("body");
|
|
12
|
-
if (!bodyStatements) {
|
|
13
|
-
console.log("no body statemnts?", compFn);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (!Array.isArray(bodyStatements)) {
|
|
17
|
-
if (bodyStatements.isFunctionExpression()) {
|
|
18
|
-
bodyStatements = bodyStatements.scope.path.get("body");
|
|
19
|
-
} else {
|
|
20
|
-
bodyStatements = bodyStatements.get("body");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (!bodyStatements || !Array.isArray(bodyStatements)) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const statements = bodyStatements;
|
|
27
|
-
for (const statement of statements) {
|
|
28
|
-
if (!statement.isVariableDeclaration()) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const declarations = statement.get("declarations");
|
|
32
|
-
if (!Array.isArray(declarations)) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const isBindingReferenced = /* @__PURE__ */ __name((name) => {
|
|
36
|
-
var _a2;
|
|
37
|
-
return !!((_a2 = statement.scope.getBinding(name)) == null ? void 0 : _a2.referenced);
|
|
38
|
-
}, "isBindingReferenced");
|
|
39
|
-
for (const declarator of declarations) {
|
|
40
|
-
const id = declarator.get("id");
|
|
41
|
-
const init = declarator.node.init;
|
|
42
|
-
if (Array.isArray(id) || Array.isArray(init)) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const shouldRemove = (() => {
|
|
46
|
-
const isHook = t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name];
|
|
47
|
-
if (!isHook) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
if (t.isIdentifier(id.node)) {
|
|
51
|
-
const name = id.node.name;
|
|
52
|
-
return !isBindingReferenced(name);
|
|
53
|
-
} else if (t.isObjectPattern(id.node)) {
|
|
54
|
-
const propPaths = id.get("properties");
|
|
55
|
-
return propPaths.every((prop) => {
|
|
56
|
-
if (!prop.isObjectProperty())
|
|
57
|
-
return false;
|
|
58
|
-
const value = prop.get("value");
|
|
59
|
-
if (Array.isArray(value) || !value.isIdentifier())
|
|
60
|
-
return false;
|
|
61
|
-
const name = value.node.name;
|
|
62
|
-
return !isBindingReferenced(name);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
})();
|
|
67
|
-
if (shouldRemove) {
|
|
68
|
-
declarator.remove();
|
|
69
|
-
if (shouldPrintDebug) {
|
|
70
|
-
console.log(` [\u{1FA9D}] removed ${(_a = id.node["name"]) != null ? _a : ""}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
__name(removeUnusedHooks, "removeUnusedHooks");
|
|
77
|
-
export {
|
|
78
|
-
removeUnusedHooks
|
|
79
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const timer = /* @__PURE__ */ __name(() => {
|
|
4
|
-
const start = Date.now();
|
|
5
|
-
let last = start;
|
|
6
|
-
return {
|
|
7
|
-
mark: (name, print = false) => {
|
|
8
|
-
if (print) {
|
|
9
|
-
const took = Date.now() - last;
|
|
10
|
-
last = Date.now();
|
|
11
|
-
console.log(`Time ${name}: ${took}ms`);
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
done: (print = false) => {
|
|
15
|
-
if (print) {
|
|
16
|
-
console.log(`Total time: ${Date.now() - start}ms`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}, "timer");
|
|
21
|
-
export {
|
|
22
|
-
timer
|
|
23
|
-
};
|