@tamagui/static 1.0.1-beta.198 → 1.0.1-beta.199
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/extractor/extractHelpers.js +3 -3
- package/dist/extractor/extractHelpers.js.map +2 -2
- package/dist/helpers/memoize.js +46 -0
- package/dist/helpers/memoize.js.map +7 -0
- package/package.json +13 -13
- package/src/extractor/extractHelpers.ts +1 -1
- package/src/helpers/memoize.ts +21 -0
- package/types/helpers/memoize.d.ts +8 -0
|
@@ -43,7 +43,7 @@ var import_path = require("path");
|
|
|
43
43
|
var import_generator = __toESM(require("@babel/generator"));
|
|
44
44
|
var t = __toESM(require("@babel/types"));
|
|
45
45
|
var import_find_root = __toESM(require("find-root"));
|
|
46
|
-
var
|
|
46
|
+
var import_memoize = require("../helpers/memoize.js");
|
|
47
47
|
function isPresent(input) {
|
|
48
48
|
return input != null;
|
|
49
49
|
}
|
|
@@ -171,10 +171,10 @@ const isValidImport = (props, moduleName, componentName) => {
|
|
|
171
171
|
}
|
|
172
172
|
return Boolean(getValidImport(props, moduleName, componentName));
|
|
173
173
|
};
|
|
174
|
-
const getValidComponentPackages = (0,
|
|
174
|
+
const getValidComponentPackages = (0, import_memoize.memoize)((props) => {
|
|
175
175
|
return [.../* @__PURE__ */ new Set(["@tamagui/core", "tamagui", ...props.components])];
|
|
176
176
|
});
|
|
177
|
-
const getValidComponentsPaths = (0,
|
|
177
|
+
const getValidComponentsPaths = (0, import_memoize.memoize)((props) => {
|
|
178
178
|
return getValidComponentPackages(props).map((pkg) => {
|
|
179
179
|
const root = (0, import_find_root.default)(pkg);
|
|
180
180
|
return (0, import_path.basename)(root);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/extractor/extractHelpers.ts"],
|
|
4
|
-
"sourcesContent": ["import { basename, relative } from 'path'\n\nimport generate from '@babel/generator'\nimport type { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport findRoot from 'find-root'\nimport { memoize } from '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmC;AAEnC,uBAAqB;AAErB,QAAmB;AACnB,uBAAqB;
|
|
4
|
+
"sourcesContent": ["import { basename, relative } from 'path'\n\nimport generate from '@babel/generator'\nimport type { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport findRoot from 'find-root'\n\nimport { memoize } from '../helpers/memoize.js'\nimport type { ExtractedAttr, TamaguiOptionsWithFileInfo, Ternary } from '../types.js'\n\n// import { astToLiteral } from './literalToAst'\n\nexport function isPresent<T extends Object>(input: null | void | undefined | T): input is T {\n return input != null\n}\n\nexport function isSimpleSpread(node: t.JSXSpreadAttribute) {\n return t.isIdentifier(node.argument) || t.isMemberExpression(node.argument)\n}\n\nexport const attrStr = (attr?: ExtractedAttr) => {\n return !attr\n ? ''\n : attr.type === 'attr'\n ? getNameAttr(attr.value)\n : attr.type === 'ternary'\n ? `...${ternaryStr(attr.value)}`\n : `${attr.type}(${objToStr(attr.value)})`\n}\n\nexport const objToStr = (obj: any, spacer = ', ') => {\n if (!obj) {\n return `${obj}`\n }\n return `{${Object.entries(obj)\n .map(\n ([k, v]) =>\n `${k}:${\n Array.isArray(v)\n ? `[...]`\n : v && typeof v === 'object'\n ? `${objToStr(v, ',')}`\n : JSON.stringify(v)\n }`\n )\n .join(spacer)}}`\n}\n\nconst getNameAttr = (attr: t.JSXAttribute | t.JSXSpreadAttribute) => {\n if (t.isJSXSpreadAttribute(attr)) {\n return `...${attr.argument['name']}`\n }\n return 'name' in attr ? attr.name.name : `unknown-${attr['type']}`\n}\n\nexport const ternaryStr = (x: Ternary) => {\n const conditional = t.isIdentifier(x.test)\n ? x.test.name\n : t.isMemberExpression(x.test)\n ? [x.test.object['name'], x.test.property['name']]\n : generate(x.test as any).code\n return [\n 'ternary(',\n conditional,\n isFilledObj(x.consequent) ? ` ? ${objToStr(x.consequent)}` : ' ? \uD83D\uDEAB',\n isFilledObj(x.alternate) ? ` : ${objToStr(x.alternate)}` : ' : \uD83D\uDEAB',\n ')',\n ]\n .flat()\n .join('')\n}\n\nconst isFilledObj = (obj: any) => obj && Object.keys(obj).length\n\nexport function findComponentName(scope) {\n const componentName = ''\n let cur = scope.path\n while (cur.parentPath && !t.isProgram(cur.parentPath.parent)) {\n cur = cur.parentPath\n }\n let node = cur.parent\n if (t.isExportNamedDeclaration(node)) {\n node = node.declaration\n }\n if (t.isVariableDeclaration(node)) {\n const [dec] = node.declarations\n if (t.isVariableDeclarator(dec) && t.isIdentifier(dec.id)) {\n return dec.id.name\n }\n }\n if (t.isFunctionDeclaration(node)) {\n return node.id?.name\n }\n return componentName\n}\n\nexport function isValidThemeHook(\n props: TamaguiOptionsWithFileInfo,\n jsxPath: NodePath<t.JSXElement>,\n n: t.MemberExpression,\n sourcePath: string\n) {\n if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property)) return false\n const bindings = jsxPath.scope.getAllBindings()\n const binding = bindings[n.object.name]\n if (!binding?.path) return false\n if (!binding.path.isVariableDeclarator()) return false\n const init = binding.path.node.init\n if (!t.isCallExpression(init)) return false\n if (!t.isIdentifier(init.callee)) return false\n // TODO could support renaming useTheme by looking up import first\n if (init.callee.name !== 'useTheme') return false\n const importNode = binding.scope.getBinding('useTheme')?.path.parent\n if (!t.isImportDeclaration(importNode)) return false\n if (!isValidImport(props, sourcePath)) {\n return false\n }\n return true\n}\n\nexport const isInsideComponentPackage = (props: TamaguiOptionsWithFileInfo, moduleName: string) => {\n return getValidComponentsPaths(props).some((path) => {\n return moduleName.startsWith(path)\n })\n}\n\nexport const isComponentPackage = (props: TamaguiOptionsWithFileInfo, srcName: string) => {\n return getValidComponentsPaths(props).some((path) => {\n return srcName.startsWith(path)\n })\n}\n\nexport function getValidComponent(\n props: TamaguiOptionsWithFileInfo,\n moduleName: string,\n componentName: string\n) {\n // must be uppercase of course\n if (componentName[0].toUpperCase() !== componentName[0]) {\n return false\n }\n\n for (const loaded of props.allLoadedComponents) {\n const isInModule = moduleName === '*' || moduleName.startsWith(loaded.moduleName)\n const foundComponent = loaded.nameToInfo[componentName]\n // eslint-disable-next-line no-console\n if (isInModule && foundComponent) {\n return foundComponent\n }\n }\n\n return null\n}\n\nexport const isValidModule = (props: TamaguiOptionsWithFileInfo, moduleName: string) => {\n if (typeof moduleName !== 'string') {\n throw new Error(`No module name`)\n }\n const isLocal = moduleName.startsWith('.')\n return {\n isLocal,\n isValid: isLocal\n ? isInsideComponentPackage(props, moduleName)\n : isComponentPackage(props, moduleName),\n }\n}\n\nexport const getValidImport = (\n props: TamaguiOptionsWithFileInfo,\n moduleName: string,\n componentName?: string\n) => {\n const { isValid, isLocal } = isValidModule(props, moduleName)\n if (!isValid || !componentName) {\n return null\n }\n return getValidComponent(props, isLocal ? '*' : moduleName, componentName) || null\n}\n\nexport const isValidImport = (\n props: TamaguiOptionsWithFileInfo,\n moduleName: string,\n componentName?: string\n) => {\n if (!componentName) {\n return isValidModule(props, moduleName).isValid\n }\n return Boolean(getValidImport(props, moduleName, componentName))\n}\n\nconst getValidComponentPackages = memoize((props: TamaguiOptionsWithFileInfo) => {\n // just always look for `tamagui` and `@tamagui/core`\n return [...new Set(['@tamagui/core', 'tamagui', ...props.components])]\n})\n\nconst getValidComponentsPaths = memoize((props: TamaguiOptionsWithFileInfo) => {\n return getValidComponentPackages(props).map((pkg) => {\n const root = findRoot(pkg)\n return basename(root)\n })\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmC;AAEnC,uBAAqB;AAErB,QAAmB;AACnB,uBA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,MAAM,gBAAgB,CAC3B,OACA,YACA,kBACG;AACH,MAAI,CAAC,eAAe;AAClB,WAAO,cAAc,OAAO,UAAU,EAAE;AAAA,EAC1C;AACA,SAAO,QAAQ,eAAe,OAAO,YAAY,aAAa,CAAC;AACjE;AAEA,MAAM,gCAA4B,wBAAQ,CAAC,UAAsC;AAE/E,SAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,iBAAiB,WAAW,GAAG,MAAM,UAAU,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,8BAA0B,wBAAQ,CAAC,UAAsC;AAC7E,SAAO,0BAA0B,KAAK,EAAE,IAAI,CAAC,QAAQ;AACnD,UAAM,WAAO,iBAAAC,SAAS,GAAG;AACzB,eAAO,sBAAS,IAAI;AAAA,EACtB,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": ["generate", "findRoot"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var memoize_exports = {};
|
|
20
|
+
__export(memoize_exports, {
|
|
21
|
+
memoize: () => memoize
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(memoize_exports);
|
|
24
|
+
function memoize(func, resolver) {
|
|
25
|
+
if (typeof func !== "function" || resolver != null && typeof resolver !== "function") {
|
|
26
|
+
throw new TypeError("Expected a function");
|
|
27
|
+
}
|
|
28
|
+
const memoized = function(...args) {
|
|
29
|
+
const key = resolver ? resolver.apply(this, args) : args[0];
|
|
30
|
+
const cache = memoized.cache;
|
|
31
|
+
if (cache.has(key)) {
|
|
32
|
+
return cache.get(key);
|
|
33
|
+
}
|
|
34
|
+
const result = func.apply(this, args);
|
|
35
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
memoized.cache = new (memoize.Cache || Map)();
|
|
39
|
+
return memoized;
|
|
40
|
+
}
|
|
41
|
+
memoize.Cache = Map;
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
memoize
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=memoize.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/memoize.ts"],
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\nexport function memoize(func?: Function, resolver?: any) {\n if (typeof func !== 'function' || (resolver != null && typeof resolver !== 'function')) {\n throw new TypeError('Expected a function')\n }\n const memoized = function (...args) {\n const key = resolver ? resolver.apply(this, args) : args[0]\n const cache = memoized.cache\n\n if (cache.has(key)) {\n return cache.get(key)\n }\n const result = func.apply(this, args)\n memoized.cache = cache.set(key, result) || cache\n return result\n }\n memoized.cache = new (memoize.Cache || Map)()\n return memoized\n}\n\nmemoize.Cache = Map\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,SAAS,QAAQ,MAAiB,UAAgB;AACvD,MAAI,OAAO,SAAS,cAAe,YAAY,QAAQ,OAAO,aAAa,YAAa;AACtF,UAAM,IAAI,UAAU,qBAAqB;AAAA,EAC3C;AACA,QAAM,WAAW,YAAa,MAAM;AAClC,UAAM,MAAM,WAAW,SAAS,MAAM,MAAM,IAAI,IAAI,KAAK;AACzD,UAAM,QAAQ,SAAS;AAEvB,QAAI,MAAM,IAAI,GAAG,GAAG;AAClB,aAAO,MAAM,IAAI,GAAG;AAAA,IACtB;AACA,UAAM,SAAS,KAAK,MAAM,MAAM,IAAI;AACpC,aAAS,QAAQ,MAAM,IAAI,KAAK,MAAM,KAAK;AAC3C,WAAO;AAAA,EACT;AACA,WAAS,QAAQ,KAAK,QAAQ,SAAS,KAAK;AAC5C,SAAO;AACT;AAEA,QAAQ,QAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.199",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"@babel/runtime": "^7.19.4",
|
|
37
37
|
"@babel/traverse": "^7.19.6",
|
|
38
38
|
"@expo/match-media": "^0.3.0",
|
|
39
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
40
|
-
"@tamagui/cli-color": "^1.0.1-beta.
|
|
41
|
-
"@tamagui/config-default-node": "^1.0.1-beta.
|
|
42
|
-
"@tamagui/core-node": "^1.0.1-beta.
|
|
43
|
-
"@tamagui/fake-react-native": "^1.0.1-beta.
|
|
44
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
45
|
-
"@tamagui/helpers-node": "^1.0.1-beta.
|
|
46
|
-
"@tamagui/proxy-worm": "^1.0.1-beta.
|
|
47
|
-
"@tamagui/shorthands": "^1.0.1-beta.
|
|
39
|
+
"@tamagui/build": "^1.0.1-beta.199",
|
|
40
|
+
"@tamagui/cli-color": "^1.0.1-beta.199",
|
|
41
|
+
"@tamagui/config-default-node": "^1.0.1-beta.199",
|
|
42
|
+
"@tamagui/core-node": "^1.0.1-beta.199",
|
|
43
|
+
"@tamagui/fake-react-native": "^1.0.1-beta.199",
|
|
44
|
+
"@tamagui/helpers": "^1.0.1-beta.199",
|
|
45
|
+
"@tamagui/helpers-node": "^1.0.1-beta.199",
|
|
46
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.199",
|
|
47
|
+
"@tamagui/shorthands": "^1.0.1-beta.199",
|
|
48
48
|
"babel-literal-to-ast": "^2.1.0",
|
|
49
49
|
"esbuild": "^0.15.11",
|
|
50
50
|
"esbuild-register": "^3.3.3",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"fs-extra": "^10.1.0",
|
|
54
54
|
"invariant": "^2.2.4",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
|
-
"react-native-web-internals": "^1.0.1-beta.
|
|
57
|
-
"react-native-web-lite": "^1.0.1-beta.
|
|
56
|
+
"react-native-web-internals": "^1.0.1-beta.199",
|
|
57
|
+
"react-native-web-lite": "^1.0.1-beta.199"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@babel/plugin-syntax-typescript": "^7.18.6",
|
|
61
61
|
"@babel/types": "^7.19.4",
|
|
62
62
|
"@dish/babel-preset": "^0.0.6",
|
|
63
|
-
"@tamagui/test-design-system": "^1.0.1-beta.
|
|
63
|
+
"@tamagui/test-design-system": "^1.0.1-beta.199",
|
|
64
64
|
"@testing-library/react": "^13.3.0",
|
|
65
65
|
"@types/babel__generator": "^7.6.4",
|
|
66
66
|
"@types/babel__traverse": "^7.18.2",
|
|
@@ -4,8 +4,8 @@ import generate from '@babel/generator'
|
|
|
4
4
|
import type { NodePath } from '@babel/traverse'
|
|
5
5
|
import * as t from '@babel/types'
|
|
6
6
|
import findRoot from 'find-root'
|
|
7
|
-
import { memoize } from 'lodash'
|
|
8
7
|
|
|
8
|
+
import { memoize } from '../helpers/memoize.js'
|
|
9
9
|
import type { ExtractedAttr, TamaguiOptionsWithFileInfo, Ternary } from '../types.js'
|
|
10
10
|
|
|
11
11
|
// import { astToLiteral } from './literalToAst'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export function memoize(func?: Function, resolver?: any) {
|
|
3
|
+
if (typeof func !== 'function' || (resolver != null && typeof resolver !== 'function')) {
|
|
4
|
+
throw new TypeError('Expected a function')
|
|
5
|
+
}
|
|
6
|
+
const memoized = function (...args) {
|
|
7
|
+
const key = resolver ? resolver.apply(this, args) : args[0]
|
|
8
|
+
const cache = memoized.cache
|
|
9
|
+
|
|
10
|
+
if (cache.has(key)) {
|
|
11
|
+
return cache.get(key)
|
|
12
|
+
}
|
|
13
|
+
const result = func.apply(this, args)
|
|
14
|
+
memoized.cache = cache.set(key, result) || cache
|
|
15
|
+
return result
|
|
16
|
+
}
|
|
17
|
+
memoized.cache = new (memoize.Cache || Map)()
|
|
18
|
+
return memoized
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
memoize.Cache = Map
|