@tamagui/static 1.0.1-beta.75 → 1.0.1-beta.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/extractor/createExtractor.js +9 -6
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +2 -2
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/loadTamagui.js +41 -5
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +111 -72
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.js +27 -12
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.js +30 -16
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/getPrefixLogs.js +1 -2
- package/dist/esm/extractor/getPrefixLogs.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +22 -7
- package/dist/esm/extractor/literalToAst.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.js +42 -5
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/normalizeTernaries.js +36 -7
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.js +3 -4
- package/dist/esm/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +10 -7
- package/dist/jsx/extractor/extractToClassNames.js +2 -2
- package/dist/jsx/extractor/loadTamagui.js +27 -5
- package/dist/jsx/index.js +1 -0
- package/package.json +11 -11
- package/src/extractor/createExtractor.ts +10 -7
- package/src/extractor/extractToClassNames.ts +2 -2
- package/src/extractor/loadTamagui.ts +42 -36
- package/src/index.ts +1 -0
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +10 -4
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
mediaQueryConfig,
|
|
9
9
|
normalizeStyleObject,
|
|
10
10
|
proxyThemeVariables,
|
|
11
|
-
|
|
11
|
+
pseudoDescriptors,
|
|
12
12
|
rnw,
|
|
13
13
|
stylePropsTransform
|
|
14
14
|
} from "@tamagui/core-node";
|
|
@@ -56,7 +56,7 @@ function createExtractor() {
|
|
|
56
56
|
let hasLogged = false;
|
|
57
57
|
function isValidStyleKey(name, staticConfig) {
|
|
58
58
|
var _a;
|
|
59
|
-
return !!(!!((_a = staticConfig.validStyles) == null ? void 0 : _a[name]) || !!
|
|
59
|
+
return !!(!!((_a = staticConfig.validStyles) == null ? void 0 : _a[name]) || !!pseudoDescriptors[name] || loadedTamaguiConfig.shorthands[name] || (name[0] === "$" ? !!mediaQueryConfig[name.slice(1)] : false));
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
62
62
|
getTamagui() {
|
|
@@ -251,6 +251,7 @@ function createExtractor() {
|
|
|
251
251
|
const atomics = getStylesAtomic(out.style);
|
|
252
252
|
for (const atomic of atomics) {
|
|
253
253
|
for (const rule of atomic.rules) {
|
|
254
|
+
out.rulesToInsert = out.rulesToInsert || [];
|
|
254
255
|
out.rulesToInsert.push([atomic.identifier, rule]);
|
|
255
256
|
}
|
|
256
257
|
classNames[atomic.property] = atomic.identifier;
|
|
@@ -260,8 +261,10 @@ function createExtractor() {
|
|
|
260
261
|
const val = classNames[cn];
|
|
261
262
|
definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)));
|
|
262
263
|
}
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
if (out.rulesToInsert) {
|
|
265
|
+
for (const [identifier, rule] of out.rulesToInsert) {
|
|
266
|
+
onStyleRule == null ? void 0 : onStyleRule(identifier, [rule]);
|
|
267
|
+
}
|
|
265
268
|
}
|
|
266
269
|
res.styled++;
|
|
267
270
|
if (shouldPrintDebug) {
|
|
@@ -709,7 +712,7 @@ function createExtractor() {
|
|
|
709
712
|
}, mergeStyles = function(prev2, next) {
|
|
710
713
|
normalizeStyleObject(next);
|
|
711
714
|
for (const key in next) {
|
|
712
|
-
if (
|
|
715
|
+
if (pseudoDescriptors[key]) {
|
|
713
716
|
prev2[key] = prev2[key] || {};
|
|
714
717
|
if (shouldPrintDebug) {
|
|
715
718
|
if (!next[key] || !prev2[key]) {
|
|
@@ -724,7 +727,7 @@ function createExtractor() {
|
|
|
724
727
|
}, omitInvalidStyles = function(style) {
|
|
725
728
|
if (staticConfig.validStyles) {
|
|
726
729
|
for (const key in style) {
|
|
727
|
-
if (stylePropsTransform[key] || !staticConfig.validStyles[key] && !
|
|
730
|
+
if (stylePropsTransform[key] || !staticConfig.validStyles[key] && !pseudoDescriptors[key] && !/(hoverStyle|focusStyle|pressStyle)$/.test(key)) {
|
|
728
731
|
if (shouldPrintDebug)
|
|
729
732
|
console.log(" delete invalid style", key);
|
|
730
733
|
delete style[key];
|
|
@@ -1113,7 +1116,7 @@ function createExtractor() {
|
|
|
1113
1116
|
if (cur.type === "style") {
|
|
1114
1117
|
const key = Object.keys(cur.value)[0];
|
|
1115
1118
|
const value = cur.value[key];
|
|
1116
|
-
const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !
|
|
1119
|
+
const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !pseudoDescriptors[key] && !key.startsWith("data-");
|
|
1117
1120
|
if (shouldKeepOriginalAttr) {
|
|
1118
1121
|
if (shouldPrintDebug) {
|
|
1119
1122
|
console.log(" - keeping as non-style", key);
|
|
@@ -263,8 +263,8 @@ function extractToClassNames({
|
|
|
263
263
|
const numFlattened = `${res.flattened}`.padStart(3);
|
|
264
264
|
const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : "";
|
|
265
265
|
const timing = Date.now() - start;
|
|
266
|
-
const timingWarning = timing >
|
|
267
|
-
const timingStr = `${timing}ms${timingWarning}`.padStart(6);
|
|
266
|
+
const timingWarning = timing > 150 ? "\u26A0\uFE0F" : timing > 150 ? "\u2622\uFE0F" : "";
|
|
267
|
+
const timingStr = `${timing}ms ${timingWarning}`.padStart(6);
|
|
268
268
|
const pre = getPrefixLogs(options);
|
|
269
269
|
const memStr = memory ? `(${memory})` : "";
|
|
270
270
|
console.log(`${pre} ${path2} ${numFound} \xB7 ${numOptimized} \xB7 ${numFlattened} \xB7 ${numStyled} ${timingStr} ${memStr}`);
|
|
@@ -6,7 +6,6 @@ function loadTamagui(props) {
|
|
|
6
6
|
return loadedTamagui;
|
|
7
7
|
}
|
|
8
8
|
const configPath = join(process.cwd(), props.config);
|
|
9
|
-
const x = Math.random();
|
|
10
9
|
const { unregister } = require("esbuild-register/dist/node").register({
|
|
11
10
|
target: "es2019",
|
|
12
11
|
format: "cjs"
|
|
@@ -20,7 +19,9 @@ function loadTamagui(props) {
|
|
|
20
19
|
const rnw = require("react-native-web");
|
|
21
20
|
const Mod = require("module");
|
|
22
21
|
const og = Mod.prototype.require;
|
|
22
|
+
const nameToPaths = {};
|
|
23
23
|
Mod.prototype.require = function(path) {
|
|
24
|
+
var _a, _b, _c;
|
|
24
25
|
if (path.endsWith(".css")) {
|
|
25
26
|
return {};
|
|
26
27
|
}
|
|
@@ -31,7 +32,26 @@ function loadTamagui(props) {
|
|
|
31
32
|
return rnw;
|
|
32
33
|
}
|
|
33
34
|
try {
|
|
34
|
-
|
|
35
|
+
const out = og.apply(this, arguments);
|
|
36
|
+
if (!nameToPaths[path]) {
|
|
37
|
+
if (out && typeof out === "object") {
|
|
38
|
+
for (const key in out) {
|
|
39
|
+
try {
|
|
40
|
+
const conf = (_a = out[key]) == null ? void 0 : _a.staticConfig;
|
|
41
|
+
if (conf) {
|
|
42
|
+
if (conf.componentName) {
|
|
43
|
+
(_c = nameToPaths[_b = conf.componentName]) != null ? _c : nameToPaths[_b] = /* @__PURE__ */ new Set();
|
|
44
|
+
const fullName = path.startsWith(".") ? join(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
|
|
45
|
+
nameToPaths[conf.componentName].add(fullName);
|
|
46
|
+
} else {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
35
55
|
} catch (err) {
|
|
36
56
|
console.error("Tamagui error loading file:\n", path, err.message, "\n", err.stack);
|
|
37
57
|
process.exit(1);
|
|
@@ -55,7 +75,8 @@ function loadTamagui(props) {
|
|
|
55
75
|
const val = exported[Name];
|
|
56
76
|
const staticConfig = val == null ? void 0 : val.staticConfig;
|
|
57
77
|
if (staticConfig) {
|
|
58
|
-
|
|
78
|
+
const { Component, reactNativeWebComponent, ...sc } = staticConfig;
|
|
79
|
+
Object.assign(components, { [Name]: { staticConfig: sc } });
|
|
59
80
|
}
|
|
60
81
|
}
|
|
61
82
|
}
|
|
@@ -64,11 +85,12 @@ function loadTamagui(props) {
|
|
|
64
85
|
createTamagui(tamaguiConfig);
|
|
65
86
|
loadedTamagui = {
|
|
66
87
|
components,
|
|
67
|
-
tamaguiConfig
|
|
88
|
+
tamaguiConfig,
|
|
89
|
+
nameToPaths
|
|
68
90
|
};
|
|
69
91
|
return loadedTamagui;
|
|
70
92
|
} catch (err) {
|
|
71
|
-
console.log("
|
|
93
|
+
console.log("Error loading Tamagui", err);
|
|
72
94
|
throw err;
|
|
73
95
|
} finally {
|
|
74
96
|
unregister();
|
package/dist/jsx/index.js
CHANGED
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.78",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -38,26 +38,26 @@
|
|
|
38
38
|
"@babel/parser": "^7.15.7",
|
|
39
39
|
"@babel/traverse": "^7.15.4",
|
|
40
40
|
"@expo/match-media": "^0.3.0",
|
|
41
|
-
"@tamagui/build": "^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/patch-rnw": "^1.0.1-beta.
|
|
46
|
-
"@tamagui/proxy-worm": "^1.0.1-beta.
|
|
41
|
+
"@tamagui/build": "^1.0.1-beta.78",
|
|
42
|
+
"@tamagui/core-node": "^1.0.1-beta.78",
|
|
43
|
+
"@tamagui/fake-react-native": "^1.0.1-beta.78",
|
|
44
|
+
"@tamagui/helpers": "^1.0.1-beta.78",
|
|
45
|
+
"@tamagui/patch-rnw": "^1.0.1-beta.78",
|
|
46
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.78",
|
|
47
47
|
"babel-literal-to-ast": "^2.1.0",
|
|
48
48
|
"esbuild": "^0.14.36",
|
|
49
49
|
"esbuild-register": "^3.3.2",
|
|
50
50
|
"find-cache-dir": "^3.3.2",
|
|
51
|
-
"fs-extra": "^
|
|
51
|
+
"fs-extra": "^10.1.0",
|
|
52
52
|
"invariant": "^2.2.4",
|
|
53
53
|
"lodash": "^4.17.21",
|
|
54
|
-
"tamagui": "^1.0.1-beta.
|
|
54
|
+
"tamagui": "^1.0.1-beta.78"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@babel/plugin-syntax-typescript": "^7.14.5",
|
|
58
58
|
"@babel/types": "^7.15.6",
|
|
59
59
|
"@dish/babel-preset": "^0.0.6",
|
|
60
|
-
"@tamagui/config-base": "^1.0.1-beta.
|
|
60
|
+
"@tamagui/config-base": "^1.0.1-beta.78",
|
|
61
61
|
"@testing-library/jest-dom": "^5.16.4",
|
|
62
62
|
"@testing-library/react": "^13.3.0",
|
|
63
63
|
"@types/jest": "*",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"react-native-web": "^0.17.5",
|
|
77
77
|
"react-test-renderer": "^18.2.0",
|
|
78
78
|
"style-loader": "^3.3.1",
|
|
79
|
-
"typescript": "^4.7.
|
|
79
|
+
"typescript": "^4.7.4",
|
|
80
80
|
"webpack": "^5.73.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
mediaQueryConfig,
|
|
13
13
|
normalizeStyleObject,
|
|
14
14
|
proxyThemeVariables,
|
|
15
|
-
|
|
15
|
+
pseudoDescriptors,
|
|
16
16
|
rnw,
|
|
17
17
|
stylePropsTransform,
|
|
18
18
|
} from '@tamagui/core-node'
|
|
@@ -86,7 +86,7 @@ export function createExtractor() {
|
|
|
86
86
|
function isValidStyleKey(name: string, staticConfig: StaticConfigParsed) {
|
|
87
87
|
return !!(
|
|
88
88
|
!!staticConfig.validStyles?.[name] ||
|
|
89
|
-
!!
|
|
89
|
+
!!pseudoDescriptors[name] ||
|
|
90
90
|
// disable variants because caching at the variant level = less work
|
|
91
91
|
// and expanding variants can get huge, i'm betting cost of many props
|
|
92
92
|
// is more than cost of expanding variants once for cache
|
|
@@ -370,6 +370,7 @@ export function createExtractor() {
|
|
|
370
370
|
const atomics = getStylesAtomic(out.style)
|
|
371
371
|
for (const atomic of atomics) {
|
|
372
372
|
for (const rule of atomic.rules) {
|
|
373
|
+
out.rulesToInsert = out.rulesToInsert || []
|
|
373
374
|
out.rulesToInsert.push([atomic.identifier, rule])
|
|
374
375
|
}
|
|
375
376
|
classNames[atomic.property] = atomic.identifier
|
|
@@ -384,8 +385,10 @@ export function createExtractor() {
|
|
|
384
385
|
definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)))
|
|
385
386
|
}
|
|
386
387
|
|
|
387
|
-
|
|
388
|
-
|
|
388
|
+
if (out.rulesToInsert) {
|
|
389
|
+
for (const [identifier, rule] of out.rulesToInsert) {
|
|
390
|
+
onStyleRule?.(identifier, [rule])
|
|
391
|
+
}
|
|
389
392
|
}
|
|
390
393
|
|
|
391
394
|
res.styled++
|
|
@@ -1570,7 +1573,7 @@ export function createExtractor() {
|
|
|
1570
1573
|
normalizeStyleObject(next)
|
|
1571
1574
|
for (const key in next) {
|
|
1572
1575
|
// merge pseudos
|
|
1573
|
-
if (
|
|
1576
|
+
if (pseudoDescriptors[key]) {
|
|
1574
1577
|
prev[key] = prev[key] || {}
|
|
1575
1578
|
if (shouldPrintDebug) {
|
|
1576
1579
|
if (!next[key] || !prev[key]) {
|
|
@@ -1597,7 +1600,7 @@ export function createExtractor() {
|
|
|
1597
1600
|
// (stylePropsTransform[key] ||
|
|
1598
1601
|
// de-opt if non-style
|
|
1599
1602
|
!validStyles[key] &&
|
|
1600
|
-
!
|
|
1603
|
+
!pseudoDescriptors[key] &&
|
|
1601
1604
|
!key.startsWith('data-')
|
|
1602
1605
|
|
|
1603
1606
|
if (shouldKeepOriginalAttr) {
|
|
@@ -1704,7 +1707,7 @@ export function createExtractor() {
|
|
|
1704
1707
|
if (
|
|
1705
1708
|
stylePropsTransform[key] ||
|
|
1706
1709
|
(!staticConfig.validStyles[key] &&
|
|
1707
|
-
!
|
|
1710
|
+
!pseudoDescriptors[key] &&
|
|
1708
1711
|
!/(hoverStyle|focusStyle|pressStyle)$/.test(key))
|
|
1709
1712
|
) {
|
|
1710
1713
|
if (shouldPrintDebug) console.log(' delete invalid style', key)
|
|
@@ -378,8 +378,8 @@ export function extractToClassNames({
|
|
|
378
378
|
const numFlattened = `${res.flattened}`.padStart(3)
|
|
379
379
|
const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : ''
|
|
380
380
|
const timing = Date.now() - start
|
|
381
|
-
const timingWarning = timing >
|
|
382
|
-
const timingStr = `${timing}ms${timingWarning}`.padStart(6)
|
|
381
|
+
const timingWarning = timing > 150 ? '⚠️' : timing > 150 ? '☢️' : ''
|
|
382
|
+
const timingStr = `${timing}ms ${timingWarning}`.padStart(6)
|
|
383
383
|
const pre = getPrefixLogs(options)
|
|
384
384
|
const memStr = memory ? `(${memory})` : ''
|
|
385
385
|
console.log(
|
|
@@ -1,36 +1,27 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
2
|
|
|
3
|
-
import type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'
|
|
3
|
+
import type { StaticConfig, TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'
|
|
4
4
|
import { createTamagui } from '@tamagui/core-node'
|
|
5
5
|
|
|
6
6
|
let loadedTamagui: any = null
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type NameToPaths = {
|
|
9
|
+
[key: string]: Set<string>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type TamaguiProjectInfo = {
|
|
9
13
|
components: Record<string, TamaguiComponent>
|
|
10
14
|
tamaguiConfig: TamaguiInternalConfig
|
|
11
|
-
|
|
15
|
+
nameToPaths: NameToPaths
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function loadTamagui(props: { components: string[]; config: string }): TamaguiProjectInfo {
|
|
12
19
|
if (loadedTamagui) {
|
|
13
20
|
return loadedTamagui
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
const configPath = join(process.cwd(), props.config)
|
|
17
24
|
|
|
18
|
-
// threaded caching avoiding 1s loading of large configs every save
|
|
19
|
-
// const cachePath = join(cacheDir, 'tamagui-conf-cached.json')
|
|
20
|
-
// const confStat = statSync(configPath)
|
|
21
|
-
|
|
22
|
-
// // TODO may want to disable, its pretty optimistic at caching...
|
|
23
|
-
// try {
|
|
24
|
-
// const confCache = readFileSync(cachePath, 'utf-8')
|
|
25
|
-
// const confParsed = JSON.parse(confCache)
|
|
26
|
-
// if (confParsed && confParsed.mtime === confStat.mtime) {
|
|
27
|
-
// return confParsed.value
|
|
28
|
-
// }
|
|
29
|
-
// } catch {
|
|
30
|
-
// // ok, no cache
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
const x = Math.random()
|
|
34
25
|
const { unregister } = require('esbuild-register/dist/node').register({
|
|
35
26
|
target: 'es2019',
|
|
36
27
|
format: 'cjs',
|
|
@@ -50,6 +41,8 @@ export function loadTamagui(props: { components: string[]; config: string }): {
|
|
|
50
41
|
const rnw = require('react-native-web')
|
|
51
42
|
const Mod = require('module')
|
|
52
43
|
const og = Mod.prototype.require
|
|
44
|
+
const nameToPaths: NameToPaths = {}
|
|
45
|
+
|
|
53
46
|
Mod.prototype.require = function (path: string) {
|
|
54
47
|
if (path.endsWith('.css')) {
|
|
55
48
|
return {}
|
|
@@ -69,7 +62,30 @@ export function loadTamagui(props: { components: string[]; config: string }): {
|
|
|
69
62
|
return rnw
|
|
70
63
|
}
|
|
71
64
|
try {
|
|
72
|
-
|
|
65
|
+
const out = og.apply(this, arguments)
|
|
66
|
+
if (!nameToPaths[path]) {
|
|
67
|
+
if (out && typeof out === 'object') {
|
|
68
|
+
for (const key in out) {
|
|
69
|
+
try {
|
|
70
|
+
const conf = out[key]?.staticConfig as StaticConfig
|
|
71
|
+
if (conf) {
|
|
72
|
+
if (conf.componentName) {
|
|
73
|
+
nameToPaths[conf.componentName] ??= new Set()
|
|
74
|
+
const fullName = path.startsWith('.')
|
|
75
|
+
? join(`${this.path.replace(/dist(\/cjs)?/, 'src')}`, path)
|
|
76
|
+
: path
|
|
77
|
+
nameToPaths[conf.componentName].add(fullName)
|
|
78
|
+
} else {
|
|
79
|
+
// console.log('no name component', path)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
// ok
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return out
|
|
73
89
|
} catch (err: any) {
|
|
74
90
|
console.error('Tamagui error loading file:\n', path, err.message, '\n', err.stack)
|
|
75
91
|
// avoid infinite loops
|
|
@@ -97,9 +113,11 @@ export function loadTamagui(props: { components: string[]; config: string }): {
|
|
|
97
113
|
const exported = require(moduleName)
|
|
98
114
|
for (const Name in exported) {
|
|
99
115
|
const val = exported[Name]
|
|
100
|
-
const staticConfig = val?.staticConfig
|
|
116
|
+
const staticConfig = val?.staticConfig as StaticConfig | undefined
|
|
101
117
|
if (staticConfig) {
|
|
102
|
-
|
|
118
|
+
// remove non-stringifyable
|
|
119
|
+
const { Component, reactNativeWebComponent, ...sc } = staticConfig
|
|
120
|
+
Object.assign(components, { [Name]: { staticConfig: sc } })
|
|
103
121
|
}
|
|
104
122
|
}
|
|
105
123
|
}
|
|
@@ -114,24 +132,12 @@ export function loadTamagui(props: { components: string[]; config: string }): {
|
|
|
114
132
|
loadedTamagui = {
|
|
115
133
|
components,
|
|
116
134
|
tamaguiConfig,
|
|
135
|
+
nameToPaths,
|
|
117
136
|
}
|
|
118
137
|
|
|
119
|
-
// save cache
|
|
120
|
-
// try {
|
|
121
|
-
// writeFileSync(
|
|
122
|
-
// cachePath,
|
|
123
|
-
// JSON.stringify({
|
|
124
|
-
// value: loadedTamagui,
|
|
125
|
-
// mtime: confStat.mtime,
|
|
126
|
-
// })
|
|
127
|
-
// )
|
|
128
|
-
// } catch (err: any) {
|
|
129
|
-
// console.log(`Error: tamagui config not stringifiable, caching disabled "${err.message}"`)
|
|
130
|
-
// }
|
|
131
|
-
|
|
132
138
|
return loadedTamagui
|
|
133
139
|
} catch (err) {
|
|
134
|
-
console.log('
|
|
140
|
+
console.log('Error loading Tamagui', err)
|
|
135
141
|
throw err
|
|
136
142
|
} finally {
|
|
137
143
|
unregister()
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAUtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;wBAkCb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,iSAoBrC,mBAAmB;;;;;;;
|
|
1
|
+
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAUtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;wBAkCb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,iSAoBrC,mBAAmB;;;;;;;EAywD3B"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
declare type NameToPaths = {
|
|
3
|
+
[key: string]: Set<string>;
|
|
4
|
+
};
|
|
5
|
+
export declare type TamaguiProjectInfo = {
|
|
6
6
|
components: Record<string, TamaguiComponent>;
|
|
7
7
|
tamaguiConfig: TamaguiInternalConfig;
|
|
8
|
+
nameToPaths: NameToPaths;
|
|
8
9
|
};
|
|
10
|
+
export declare function loadTamagui(props: {
|
|
11
|
+
components: string[];
|
|
12
|
+
config: string;
|
|
13
|
+
}): TamaguiProjectInfo;
|
|
14
|
+
export {};
|
|
9
15
|
//# sourceMappingURL=loadTamagui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTamagui.d.ts","sourceRoot":"","sources":["../../src/extractor/loadTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"loadTamagui.d.ts","sourceRoot":"","sources":["../../src/extractor/loadTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAK1F,aAAK,WAAW,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;CAC3B,CAAA;AAED,oBAAY,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC5C,aAAa,EAAE,qBAAqB,CAAA;IACpC,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,kBAAkB,CA+H/F"}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,iCAAiC,CAAA;AAC/C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,iCAAiC,CAAA;AAC/C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA"}
|