stampd 0.1.0
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/README.md +611 -0
- package/dist/analyzer/analyzeStyle.d.ts +13 -0
- package/dist/analyzer/analyzeStyle.d.ts.map +1 -0
- package/dist/analyzer/analyzeStyle.js +43 -0
- package/dist/analyzer/analyzeStyle.js.map +1 -0
- package/dist/analyzer/classifyValue.d.ts +7 -0
- package/dist/analyzer/classifyValue.d.ts.map +1 -0
- package/dist/analyzer/classifyValue.js +30 -0
- package/dist/analyzer/classifyValue.js.map +1 -0
- package/dist/analyzer/isThemeAccess.d.ts +7 -0
- package/dist/analyzer/isThemeAccess.d.ts.map +1 -0
- package/dist/analyzer/isThemeAccess.js +17 -0
- package/dist/analyzer/isThemeAccess.js.map +1 -0
- package/dist/cli/runTransform.d.ts +2 -0
- package/dist/cli/runTransform.d.ts.map +1 -0
- package/dist/cli/runTransform.js +55 -0
- package/dist/cli/runTransform.js.map +1 -0
- package/dist/config/createTheme.d.ts +101 -0
- package/dist/config/createTheme.d.ts.map +1 -0
- package/dist/config/createTheme.js +61 -0
- package/dist/config/createTheme.js.map +1 -0
- package/dist/config/generateTypes.d.ts +2 -0
- package/dist/config/generateTypes.d.ts.map +1 -0
- package/dist/config/generateTypes.js +103 -0
- package/dist/config/generateTypes.js.map +1 -0
- package/dist/config/loadStyledConfig.d.ts +13 -0
- package/dist/config/loadStyledConfig.d.ts.map +1 -0
- package/dist/config/loadStyledConfig.js +175 -0
- package/dist/config/loadStyledConfig.js.map +1 -0
- package/dist/context/Provider.d.ts +40 -0
- package/dist/context/Provider.d.ts.map +1 -0
- package/dist/context/Provider.js +141 -0
- package/dist/context/Provider.js.map +1 -0
- package/dist/core/shouldTransform.d.ts +6 -0
- package/dist/core/shouldTransform.d.ts.map +1 -0
- package/dist/core/shouldTransform.js +28 -0
- package/dist/core/shouldTransform.js.map +1 -0
- package/dist/detectors/isStyledCall.d.ts +10 -0
- package/dist/detectors/isStyledCall.d.ts.map +1 -0
- package/dist/detectors/isStyledCall.js +20 -0
- package/dist/detectors/isStyledCall.js.map +1 -0
- package/dist/detectors/isStyledImported.d.ts +9 -0
- package/dist/detectors/isStyledImported.d.ts.map +1 -0
- package/dist/detectors/isStyledImported.js +27 -0
- package/dist/detectors/isStyledImported.js.map +1 -0
- package/dist/extractors/extractAttrs.d.ts +13 -0
- package/dist/extractors/extractAttrs.d.ts.map +1 -0
- package/dist/extractors/extractAttrs.js +40 -0
- package/dist/extractors/extractAttrs.js.map +1 -0
- package/dist/extractors/extractStyle.d.ts +24 -0
- package/dist/extractors/extractStyle.d.ts.map +1 -0
- package/dist/extractors/extractStyle.js +57 -0
- package/dist/extractors/extractStyle.js.map +1 -0
- package/dist/extractors/extractVariants.d.ts +11 -0
- package/dist/extractors/extractVariants.d.ts.map +1 -0
- package/dist/extractors/extractVariants.js +31 -0
- package/dist/extractors/extractVariants.js.map +1 -0
- package/dist/extractors/getStyledConfig.d.ts +9 -0
- package/dist/extractors/getStyledConfig.d.ts.map +1 -0
- package/dist/extractors/getStyledConfig.js +17 -0
- package/dist/extractors/getStyledConfig.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/Styled.d.ts +48 -0
- package/dist/runtime/Styled.d.ts.map +1 -0
- package/dist/runtime/Styled.js +17 -0
- package/dist/runtime/Styled.js.map +1 -0
- package/dist/theme/astFromValue.d.ts +3 -0
- package/dist/theme/astFromValue.d.ts.map +1 -0
- package/dist/theme/astFromValue.js +22 -0
- package/dist/theme/astFromValue.js.map +1 -0
- package/dist/theme/extractThemePath.d.ts +7 -0
- package/dist/theme/extractThemePath.d.ts.map +1 -0
- package/dist/theme/extractThemePath.js +21 -0
- package/dist/theme/extractThemePath.js.map +1 -0
- package/dist/theme/resolveExpression.d.ts +7 -0
- package/dist/theme/resolveExpression.d.ts.map +1 -0
- package/dist/theme/resolveExpression.js +46 -0
- package/dist/theme/resolveExpression.js.map +1 -0
- package/dist/theme/resolveThemeInStyle.d.ts +6 -0
- package/dist/theme/resolveThemeInStyle.d.ts.map +1 -0
- package/dist/theme/resolveThemeInStyle.js +26 -0
- package/dist/theme/resolveThemeInStyle.js.map +1 -0
- package/dist/theme/resolveThemePath.d.ts +8 -0
- package/dist/theme/resolveThemePath.d.ts.map +1 -0
- package/dist/theme/resolveThemePath.js +22 -0
- package/dist/theme/resolveThemePath.js.map +1 -0
- package/dist/transformers/transformStyled.d.ts +7 -0
- package/dist/transformers/transformStyled.d.ts.map +1 -0
- package/dist/transformers/transformStyled.js +104 -0
- package/dist/transformers/transformStyled.js.map +1 -0
- package/dist/transformers/transformStyledWithVariants.d.ts +22 -0
- package/dist/transformers/transformStyledWithVariants.d.ts.map +1 -0
- package/dist/transformers/transformStyledWithVariants.js +197 -0
- package/dist/transformers/transformStyledWithVariants.js.map +1 -0
- package/dist/utils/buildDefaultVariantsAST.d.ts +3 -0
- package/dist/utils/buildDefaultVariantsAST.d.ts.map +1 -0
- package/dist/utils/buildDefaultVariantsAST.js +41 -0
- package/dist/utils/buildDefaultVariantsAST.js.map +1 -0
- package/dist/utils/buildVariantsObjectAST.d.ts +3 -0
- package/dist/utils/buildVariantsObjectAST.d.ts.map +1 -0
- package/dist/utils/buildVariantsObjectAST.js +43 -0
- package/dist/utils/buildVariantsObjectAST.js.map +1 -0
- package/dist/utils/defaultFontStyle.d.ts +8 -0
- package/dist/utils/defaultFontStyle.d.ts.map +1 -0
- package/dist/utils/defaultFontStyle.js +32 -0
- package/dist/utils/defaultFontStyle.js.map +1 -0
- package/dist/utils/ensureImport.d.ts +13 -0
- package/dist/utils/ensureImport.d.ts.map +1 -0
- package/dist/utils/ensureImport.js +76 -0
- package/dist/utils/ensureImport.js.map +1 -0
- package/dist/utils/getProgramPath.d.ts +6 -0
- package/dist/utils/getProgramPath.d.ts.map +1 -0
- package/dist/utils/getProgramPath.js +10 -0
- package/dist/utils/getProgramPath.js.map +1 -0
- package/dist/utils/nodeHasPlatformSelect.d.ts +3 -0
- package/dist/utils/nodeHasPlatformSelect.d.ts.map +1 -0
- package/dist/utils/nodeHasPlatformSelect.js +37 -0
- package/dist/utils/nodeHasPlatformSelect.js.map +1 -0
- package/dist/utils/nodeHasThemeAccess.d.ts +7 -0
- package/dist/utils/nodeHasThemeAccess.d.ts.map +1 -0
- package/dist/utils/nodeHasThemeAccess.js +36 -0
- package/dist/utils/nodeHasThemeAccess.js.map +1 -0
- package/dist/utils/replaceParamWithProps.d.ts +7 -0
- package/dist/utils/replaceParamWithProps.d.ts.map +1 -0
- package/dist/utils/replaceParamWithProps.js +34 -0
- package/dist/utils/replaceParamWithProps.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { ComponentType } from "react";
|
|
3
|
+
import type { View, Text, Image, ScrollView, TextInput, Pressable, TouchableOpacity, FlatList, SectionList, KeyboardAvoidingView, ImageBackground, TouchableWithoutFeedback, ViewStyle, TextStyle, ImageStyle } from "react-native";
|
|
4
|
+
declare global {
|
|
5
|
+
namespace StyledSystem {
|
|
6
|
+
interface Theme {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
type Theme = StyledSystem.Theme;
|
|
11
|
+
type StyleInput<S> = S | ((args: {
|
|
12
|
+
theme: Theme;
|
|
13
|
+
}) => S);
|
|
14
|
+
type VariantProps<V> = V extends Record<string, Record<string, any>> ? {
|
|
15
|
+
[K in keyof V]?: keyof V[K];
|
|
16
|
+
} : {};
|
|
17
|
+
type StyledConfig<C extends React.ElementType, S> = {
|
|
18
|
+
style?: StyleInput<S>;
|
|
19
|
+
variants?: Record<string, Record<string, StyleInput<S>>>;
|
|
20
|
+
attrs?: Partial<React.ComponentPropsWithRef<C>> | ((args: {
|
|
21
|
+
theme: Theme;
|
|
22
|
+
}) => Partial<React.ComponentPropsWithRef<C>>);
|
|
23
|
+
};
|
|
24
|
+
type StyledFactory<C extends React.ElementType, S> = <V extends Record<string, Record<string, StyleInput<S>>> = {}>(config: StyledConfig<C, S> & {
|
|
25
|
+
variants?: V;
|
|
26
|
+
}) => ComponentType<React.ComponentPropsWithRef<C> & VariantProps<V>>;
|
|
27
|
+
type StyledMap = {
|
|
28
|
+
View: StyledFactory<typeof View, ViewStyle>;
|
|
29
|
+
Text: StyledFactory<typeof Text, TextStyle>;
|
|
30
|
+
Image: StyledFactory<typeof Image, ImageStyle>;
|
|
31
|
+
ImageBackground: StyledFactory<typeof ImageBackground, ViewStyle>;
|
|
32
|
+
ScrollView: StyledFactory<typeof ScrollView, ViewStyle>;
|
|
33
|
+
TextInput: StyledFactory<typeof TextInput, TextStyle>;
|
|
34
|
+
Pressable: StyledFactory<typeof Pressable, ViewStyle>;
|
|
35
|
+
TouchableOpacity: StyledFactory<typeof TouchableOpacity, ViewStyle>;
|
|
36
|
+
TouchableWithoutFeedback: StyledFactory<typeof TouchableWithoutFeedback, ViewStyle>;
|
|
37
|
+
FlatList: StyledFactory<typeof FlatList, ViewStyle>;
|
|
38
|
+
SectionList: StyledFactory<typeof SectionList, ViewStyle>;
|
|
39
|
+
KeyboardAvoidingView: StyledFactory<typeof KeyboardAvoidingView, ViewStyle>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Placeholder para compile time.
|
|
43
|
+
* Nunca executado em runtime — o plugin Babel substitui todas as chamadas
|
|
44
|
+
* Styled.X(...) por componentes React Native reais durante o build.
|
|
45
|
+
*/
|
|
46
|
+
export declare const Styled: StyledMap;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=Styled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styled.d.ts","sourceRoot":"","sources":["../../src/runtime/Styled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,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GAIG;AACH,eAAO,MAAM,MAAM,WASjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Styled = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Placeholder para compile time.
|
|
6
|
+
* Nunca executado em runtime — o plugin Babel substitui todas as chamadas
|
|
7
|
+
* Styled.X(...) por componentes React Native reais durante o build.
|
|
8
|
+
*/
|
|
9
|
+
exports.Styled = new Proxy({}, {
|
|
10
|
+
get: (_, componentName) => {
|
|
11
|
+
return () => {
|
|
12
|
+
throw new Error(`[stampd] Styled.${componentName}() não foi transformado. ` +
|
|
13
|
+
`Verifique se o plugin está configurado no babel.config.js.`);
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=Styled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styled.js","sourceRoot":"","sources":["../../src/runtime/Styled.ts"],"names":[],"mappings":";;;AA4DA;;;;GAIG;AACU,QAAA,MAAM,GAAG,IAAI,KAAK,CAAC,EAAe,EAAE;IAC/C,GAAG,EAAE,CAAC,CAAC,EAAE,aAAqB,EAAE,EAAE;QAChC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,KAAK,CACb,mBAAmB,aAAa,2BAA2B;gBACzD,4DAA4D,CAC/D,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astFromValue.d.ts","sourceRoot":"","sources":["../../src/theme/astFromValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AAEzC,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,UAAU,CAwBrD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.astFromValue = astFromValue;
|
|
4
|
+
// plugins/src/theme/astFromValue.ts
|
|
5
|
+
const core_1 = require("@babel/core");
|
|
6
|
+
function astFromValue(value) {
|
|
7
|
+
if (typeof value === "string")
|
|
8
|
+
return core_1.types.stringLiteral(value);
|
|
9
|
+
if (typeof value === "number")
|
|
10
|
+
return core_1.types.numericLiteral(value);
|
|
11
|
+
if (typeof value === "boolean")
|
|
12
|
+
return core_1.types.booleanLiteral(value);
|
|
13
|
+
if (typeof value === "object" && value !== null) {
|
|
14
|
+
if (value.__platformSelect === true) {
|
|
15
|
+
const optionProps = Object.entries(value.options).map(([key, val]) => core_1.types.objectProperty(core_1.types.identifier(key), astFromValue(val)));
|
|
16
|
+
return core_1.types.callExpression(core_1.types.memberExpression(core_1.types.identifier("Platform"), core_1.types.identifier("select")), [core_1.types.objectExpression(optionProps)]);
|
|
17
|
+
}
|
|
18
|
+
return core_1.types.objectExpression(Object.entries(value).map(([key, val]) => core_1.types.objectProperty(core_1.types.identifier(key), astFromValue(val))));
|
|
19
|
+
}
|
|
20
|
+
throw new Error("Unsupported theme value");
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=astFromValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astFromValue.js","sourceRoot":"","sources":["../../src/theme/astFromValue.ts"],"names":[],"mappings":";;AAGA,oCAwBC;AA3BD,oCAAoC;AACpC,sCAAyC;AAEzC,SAAgB,YAAY,CAAC,KAAU;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,YAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,YAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9D,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,YAAC,CAAC,cAAc,CAAC,K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CAanE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractThemePath = extractThemePath;
|
|
4
|
+
// plugins/src/theme/extractThemePath.ts
|
|
5
|
+
const core_1 = require("@babel/core");
|
|
6
|
+
/**
|
|
7
|
+
* Extrai:
|
|
8
|
+
* theme.colors.primary → ['colors','primary']
|
|
9
|
+
*/
|
|
10
|
+
function extractThemePath(node) {
|
|
11
|
+
const path = [];
|
|
12
|
+
let current = node;
|
|
13
|
+
while (core_1.types.isMemberExpression(current)) {
|
|
14
|
+
if (core_1.types.isIdentifier(current.property)) {
|
|
15
|
+
path.unshift(current.property.name);
|
|
16
|
+
}
|
|
17
|
+
current = current.object;
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=extractThemePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractThemePath.js","sourceRoot":"","sources":["../../src/theme/extractThemePath.ts"],"names":[],"mappings":";;AAOA,4CAaC;AApBD,wCAAwC;AACxC,sCAAyC;AAEzC;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,IAAwB;IACvD,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,IAAI,OAAO,GAAQ,IAAI,CAAC;IAExB,OAAO,YAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,IAAI,YAAC,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { types as t } from "@babel/core";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve expressões parcialmente.
|
|
4
|
+
* Loga um aviso quando um acesso a `theme.xxx` não pode ser resolvido em compile-time.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveExpression(node: t.Expression): t.Expression;
|
|
7
|
+
//# sourceMappingURL=resolveExpression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveExpression.d.ts","sourceRoot":"","sources":["../../src/theme/resolveExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AAoBzC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAkClE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveExpression = resolveExpression;
|
|
4
|
+
const core_1 = require("@babel/core");
|
|
5
|
+
const isThemeAccess_1 = require("../analyzer/isThemeAccess");
|
|
6
|
+
const extractThemePath_1 = require("./extractThemePath");
|
|
7
|
+
const resolveThemePath_1 = require("./resolveThemePath");
|
|
8
|
+
const astFromValue_1 = require("./astFromValue");
|
|
9
|
+
const loadStyledConfig_1 = require("../config/loadStyledConfig");
|
|
10
|
+
/** Evita spam: avisa cada caminho não-resolvido apenas uma vez por processo. */
|
|
11
|
+
const warnedPaths = new Set();
|
|
12
|
+
function warnUnresolved(pathKeys) {
|
|
13
|
+
const key = pathKeys.join(".");
|
|
14
|
+
if (warnedPaths.has(key))
|
|
15
|
+
return;
|
|
16
|
+
warnedPaths.add(key);
|
|
17
|
+
console.warn(`\x1b[33m[stampd] ⚠️ theme.${key} não encontrado em stampd.config.ts → será resolvido em runtime\x1b[0m`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve expressões parcialmente.
|
|
21
|
+
* Loga um aviso quando um acesso a `theme.xxx` não pode ser resolvido em compile-time.
|
|
22
|
+
*/
|
|
23
|
+
function resolveExpression(node) {
|
|
24
|
+
// 🔹 theme.xxx.xxx
|
|
25
|
+
if (core_1.types.isMemberExpression(node) && (0, isThemeAccess_1.isThemeAccess)(node)) {
|
|
26
|
+
const path = (0, extractThemePath_1.extractThemePath)(node);
|
|
27
|
+
const resolved = (0, resolveThemePath_1.resolveThemePath)(path);
|
|
28
|
+
if (resolved !== undefined) {
|
|
29
|
+
return (0, astFromValue_1.astFromValue)(resolved);
|
|
30
|
+
}
|
|
31
|
+
if (!(0, loadStyledConfig_1.isDynamicThemePath)(path))
|
|
32
|
+
warnUnresolved(path);
|
|
33
|
+
return node;
|
|
34
|
+
}
|
|
35
|
+
// 🔹 ternário (condicional)
|
|
36
|
+
if (core_1.types.isConditionalExpression(node)) {
|
|
37
|
+
return core_1.types.conditionalExpression(resolveExpression(node.test), resolveExpression(node.consequent), resolveExpression(node.alternate));
|
|
38
|
+
}
|
|
39
|
+
// 🔹 binary (ex: theme.color + "66")
|
|
40
|
+
if (core_1.types.isBinaryExpression(node)) {
|
|
41
|
+
return core_1.types.binaryExpression(node.operator, resolveExpression(node.left), resolveExpression(node.right));
|
|
42
|
+
}
|
|
43
|
+
// 🔹 mantém o resto (props, variáveis, etc)
|
|
44
|
+
return node;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=resolveExpression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveExpression.js","sourceRoot":"","sources":["../../src/theme/resolveExpression.ts"],"names":[],"mappings":";;AAwBA,8CAkCC;AA1DD,sCAAyC;AACzC,6DAA0D;AAC1D,yDAAsD;AACtD,yDAAsD;AACtD,iDAA8C;AAC9C,iEAAgE;AAEhE,gFAAgF;AAChF,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;AAEtC,SAAS,cAAc,CAAC,QAAkB;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,C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AAC;IAED,4CAA4C;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveThemeInStyle.d.ts","sourceRoot":"","sources":["../../src/theme/resolveThemeInStyle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AAMzC;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,CAAC,CAAC,gBAAgB,GACvB,CAAC,CAAC,gBAAgB,CAmBpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveThemeInStyle = resolveThemeInStyle;
|
|
4
|
+
// plugins/src/theme/resolveThemeInStyle.ts
|
|
5
|
+
const core_1 = require("@babel/core");
|
|
6
|
+
const resolveExpression_1 = require("./resolveExpression");
|
|
7
|
+
/**
|
|
8
|
+
* Substitui theme.xxx.xxx por valor real
|
|
9
|
+
*/
|
|
10
|
+
function resolveThemeInStyle(node) {
|
|
11
|
+
node.properties = node.properties.map((prop) => {
|
|
12
|
+
// Handle spread: ...theme.shadows.level1 → ...Platform.select({...})
|
|
13
|
+
if (core_1.types.isSpreadElement(prop) && core_1.types.isExpression(prop.argument)) {
|
|
14
|
+
return core_1.types.spreadElement((0, resolveExpression_1.resolveExpression)(prop.argument));
|
|
15
|
+
}
|
|
16
|
+
if (!core_1.types.isObjectProperty(prop))
|
|
17
|
+
return prop;
|
|
18
|
+
const value = prop.value;
|
|
19
|
+
if (core_1.types.isExpression(value)) {
|
|
20
|
+
return core_1.types.objectProperty(prop.key, (0, resolveExpression_1.resolveExpression)(value));
|
|
21
|
+
}
|
|
22
|
+
return prop;
|
|
23
|
+
});
|
|
24
|
+
return node;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=resolveThemeInStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveThemeInStyle.js","sourceRoot":"","sources":["../../src/theme/resolveThemeInStyle.ts"],"names":[],"mappings":";;AAUA,kDAqBC;AA/BD,2CAA2C;AAC3C,sCAAyC;AAIzC,2DAAwD;AAExD;;GAEG;AACH,SAAgB,mBAAmB,CACjC,IAAwB;IAExB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7C,qEAAqE;QACrE,IAAI,YAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,YAAC,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D,OAAO,YAAC,CAAC,aAAa,CAAC,IAAA,qCAAiB,EAAC,IAAI,CAAC,QAAwB,CAAC,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC,YAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAE3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzB,IAAI,YAAC,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,YAAC,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveThemePath.d.ts","sourceRoot":"","sources":["../../src/theme/resolveThemePath.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAUpD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveThemePath = resolveThemePath;
|
|
4
|
+
// plugins/src/theme/resolveThemePath.ts
|
|
5
|
+
const loadStyledConfig_1 = require("../config/loadStyledConfig");
|
|
6
|
+
/**
|
|
7
|
+
* Resolve:
|
|
8
|
+
* theme.colors.primary → '#FF0000'
|
|
9
|
+
*
|
|
10
|
+
* Usa o tema carregado de stampd.config.ts na raiz do projeto.
|
|
11
|
+
*/
|
|
12
|
+
function resolveThemePath(path) {
|
|
13
|
+
const theme = (0, loadStyledConfig_1.loadStyledConfig)();
|
|
14
|
+
let current = theme;
|
|
15
|
+
for (const key of path) {
|
|
16
|
+
if ((current === null || current === void 0 ? void 0 : current[key]) === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
current = current[key];
|
|
19
|
+
}
|
|
20
|
+
return current;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=resolveThemePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveThemePath.js","sourceRoot":"","sources":["../../src/theme/resolveThemePath.ts"],"names":[],"mappings":";;AASA,4CAUC;AAnBD,wCAAwC;AACxC,iEAA8D;AAE9D;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,IAAc;IAC7C,MAAM,KAAK,GAAG,IAAA,mCAAgB,GAAE,CAAC;IAEjC,IAAI,OAAO,GAAQ,KAAK,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,GAAG,CAAC,MAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QACnD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformStyled.d.ts","sourceRoot":"","sources":["../../src/transformers/transformStyled.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AAanD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,QAuH/D"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformStyled = transformStyled;
|
|
4
|
+
// plugins/src/transformers/transformStyled.ts
|
|
5
|
+
const core_1 = require("@babel/core");
|
|
6
|
+
const getStyledConfig_1 = require("../extractors/getStyledConfig");
|
|
7
|
+
const extractStyle_1 = require("../extractors/extractStyle");
|
|
8
|
+
const extractVariants_1 = require("../extractors/extractVariants");
|
|
9
|
+
const extractAttrs_1 = require("../extractors/extractAttrs");
|
|
10
|
+
const resolveThemeInStyle_1 = require("../theme/resolveThemeInStyle");
|
|
11
|
+
const ensureImport_1 = require("../utils/ensureImport");
|
|
12
|
+
const nodeHasPlatformSelect_1 = require("../utils/nodeHasPlatformSelect");
|
|
13
|
+
const nodeHasThemeAccess_1 = require("../utils/nodeHasThemeAccess");
|
|
14
|
+
const replaceParamWithProps_1 = require("../utils/replaceParamWithProps");
|
|
15
|
+
const defaultFontStyle_1 = require("../utils/defaultFontStyle");
|
|
16
|
+
const transformStyledWithVariants_1 = require("./transformStyledWithVariants");
|
|
17
|
+
/**
|
|
18
|
+
* Transforma:
|
|
19
|
+
* Styled.View(...) → componente React
|
|
20
|
+
*/
|
|
21
|
+
function transformStyled(path) {
|
|
22
|
+
const callee = path.get("callee");
|
|
23
|
+
if (!callee.isMemberExpression())
|
|
24
|
+
return;
|
|
25
|
+
const componentName = callee.get("property");
|
|
26
|
+
if (!componentName.isIdentifier())
|
|
27
|
+
return;
|
|
28
|
+
const config = (0, getStyledConfig_1.getStyledConfig)(path);
|
|
29
|
+
if (!config)
|
|
30
|
+
return;
|
|
31
|
+
const style = (0, extractStyle_1.extractStyle)(config);
|
|
32
|
+
if (!style)
|
|
33
|
+
return;
|
|
34
|
+
const attrs = (0, extractAttrs_1.extractAttrs)(config);
|
|
35
|
+
// Se houver variants, delega para o transformer especializado
|
|
36
|
+
const variants = (0, extractVariants_1.extractVariants)(config);
|
|
37
|
+
if (variants) {
|
|
38
|
+
(0, transformStyledWithVariants_1.transformStyledWithVariants)(path, componentName.node.name, style, variants, attrs);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let styleNode = style.node;
|
|
42
|
+
// Resolve tokens em compile time; valores de theme.light/dark permanecem como refs
|
|
43
|
+
styleNode = (0, resolveThemeInStyle_1.resolveThemeInStyle)(styleNode);
|
|
44
|
+
// Verifica se ainda há acessos dinâmicos a theme (ex: theme.colors.primary)
|
|
45
|
+
const needsTheme = style.type === "function" && (0, nodeHasThemeAccess_1.nodeHasThemeAccess)(styleNode);
|
|
46
|
+
if (style.type === "function") {
|
|
47
|
+
// Se needsTheme: filtra "theme" dos params para não virar props.theme
|
|
48
|
+
// O `theme` ficará em escopo via useStampdUI()
|
|
49
|
+
const paramsToReplace = needsTheme
|
|
50
|
+
? style.params.filter((p) => p !== "theme")
|
|
51
|
+
: style.params;
|
|
52
|
+
styleNode = (0, replaceParamWithProps_1.replaceParamWithProps)(style.path, paramsToReplace);
|
|
53
|
+
}
|
|
54
|
+
const program = path.findParent((p) => p.isProgram());
|
|
55
|
+
if (program && program.isProgram()) {
|
|
56
|
+
(0, ensureImport_1.ensureReactNativeImport)(program, componentName.node.name);
|
|
57
|
+
if ((0, nodeHasPlatformSelect_1.nodeHasPlatformSelect)(styleNode))
|
|
58
|
+
(0, ensureImport_1.ensurePlatformImport)(program);
|
|
59
|
+
if (needsTheme)
|
|
60
|
+
(0, ensureImport_1.ensureUseThemeImport)(program);
|
|
61
|
+
}
|
|
62
|
+
// Resolve tema em attrs (se houver) e constrói o spread
|
|
63
|
+
const attrsAttributes = [];
|
|
64
|
+
if (attrs) {
|
|
65
|
+
(0, resolveThemeInStyle_1.resolveThemeInStyle)(attrs.node);
|
|
66
|
+
attrsAttributes.push(core_1.types.jsxSpreadAttribute(attrs.node));
|
|
67
|
+
}
|
|
68
|
+
const defaultFont = (0, defaultFontStyle_1.buildDefaultFontStyle)(componentName.node.name);
|
|
69
|
+
const styleValue = defaultFont
|
|
70
|
+
? core_1.types.arrayExpression([defaultFont, styleNode])
|
|
71
|
+
: styleNode;
|
|
72
|
+
const jsxElement = core_1.types.jsxElement(core_1.types.jsxOpeningElement(core_1.types.jsxIdentifier(componentName.node.name), [
|
|
73
|
+
...attrsAttributes,
|
|
74
|
+
core_1.types.jsxAttribute(core_1.types.jsxIdentifier("style"), core_1.types.jsxExpressionContainer(styleValue)),
|
|
75
|
+
core_1.types.jsxSpreadAttribute(core_1.types.identifier("props")),
|
|
76
|
+
], true), null, [], true);
|
|
77
|
+
let componentFn;
|
|
78
|
+
if (needsTheme) {
|
|
79
|
+
/**
|
|
80
|
+
* Gera:
|
|
81
|
+
* (props) => {
|
|
82
|
+
* const { theme } = useStampdUI();
|
|
83
|
+
* return <View style={...} {...props} />;
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
componentFn = core_1.types.arrowFunctionExpression([core_1.types.identifier("props")], core_1.types.blockStatement([
|
|
87
|
+
core_1.types.variableDeclaration("const", [
|
|
88
|
+
core_1.types.variableDeclarator(core_1.types.objectPattern([
|
|
89
|
+
core_1.types.objectProperty(core_1.types.identifier("theme"), core_1.types.identifier("theme"), false, true),
|
|
90
|
+
]), core_1.types.callExpression(core_1.types.identifier("useStampdUI"), [])),
|
|
91
|
+
]),
|
|
92
|
+
core_1.types.returnStatement(jsxElement),
|
|
93
|
+
]));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
/**
|
|
97
|
+
* Gera:
|
|
98
|
+
* (props) => <View style={...} {...props} />
|
|
99
|
+
*/
|
|
100
|
+
componentFn = core_1.types.arrowFunctionExpression([core_1.types.identifier("props")], jsxElement);
|
|
101
|
+
}
|
|
102
|
+
path.replaceWith(componentFn);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=transformStyled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformStyled.js","sourceRoot":"","sources":["../../src/transformers/transformStyled.ts"],"names":[],"mappings":";;AAkBA,0CAuHC;AAzID,8CAA8C;AAC9C,sCAAmD;AACnD,mEAAgE;AAChE,6DAA0D;AAC1D,mEAAgE;AAChE,6DAA0D;AAC1D,sEAAmE;AACnE,wDAA4G;AAC5G,0EAAuE;AACvE,oEAAiE;AACjE,0EAAuE;AACvE,gEAAkE;AAClE,+EAA4E;AAE5E;;;GAGG;AACH,SAAgB,eAAe,CAAC,IAAgC;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAElC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;QAAE,OAAO;IAEzC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;QAAE,OAAO;IAE1C,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,MAAM,KAAK,GAAG,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,MAAM,KAAK,GAAG,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAC;IAEnC,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,IAAA,iCAAe,EAAC,MAAM,CAAC,CAAC;IACzC,IAAI,QAAQ,EAAE,CAAC;QACb,IAAA,yDAA2B,EAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnF,OAAO;IACT,CAAC;IAED,IAAI,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;IAE3B,mFAA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M,CAAC;QACN;;;WAGG;QACH,WAAW,GAAG,YAAC,CAAC,uBAAuB,CACrC,CAAC,YAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EACvB,UAAU,CACX,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NodePath, types as t } from "@babel/core";
|
|
2
|
+
import { ExtractedStyle } from "../extractors/extractStyle";
|
|
3
|
+
import { ExtractedVariants } from "../extractors/extractVariants";
|
|
4
|
+
import { ExtractedAttrs } from "../extractors/extractAttrs";
|
|
5
|
+
/**
|
|
6
|
+
* Transforma Styled.X({...}) com variants:
|
|
7
|
+
*
|
|
8
|
+
* - Resolve tema em hardcode onde possível (stampd.config.ts)
|
|
9
|
+
* - Emite `useStampdUI` e `(theme) => ({...})` SOMENTE quando necessário
|
|
10
|
+
*
|
|
11
|
+
* Caso tudo resolva:
|
|
12
|
+
* const __baseStyle_X = {...};
|
|
13
|
+
* const __variants_X = { variant: { outline: {...} } };
|
|
14
|
+
* const X = (props) => { const { variant, style, ...rest } = props; return <X ... />; };
|
|
15
|
+
*
|
|
16
|
+
* Caso haja valores runtime:
|
|
17
|
+
* const __baseStyle_X = (theme) => ({...});
|
|
18
|
+
* const __variants_X = { variant: { outline: (theme) => ({...}) } };
|
|
19
|
+
* const X = (props) => { const { theme } = useStampdUI(); ... };
|
|
20
|
+
*/
|
|
21
|
+
export declare function transformStyledWithVariants(path: NodePath<t.CallExpression>, componentName: string, style: ExtractedStyle, variants: ExtractedVariants, attrs?: ExtractedAttrs | null): void;
|
|
22
|
+
//# sourceMappingURL=transformStyledWithVariants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformStyledWithVariants.d.ts","sourceRoot":"","sources":["../../src/transformers/transformStyledWithVariants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AA0G5D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,GAAE,cAAc,GAAG,IAAW,QAgKpC"}
|