@tarojs/rn-style-transformer 4.0.1-alpha.0 → 4.0.1

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.
Files changed (98) hide show
  1. package/.eslintrc.js +8 -0
  2. package/LICENSE +8 -8
  3. package/README.md +21 -36
  4. package/__tests__/config.spec.js +203 -0
  5. package/__tests__/index.spec.js +252 -0
  6. package/__tests__/platform.spec.js +78 -0
  7. package/__tests__/styles/b.css +3 -0
  8. package/__tests__/styles/b.less +3 -0
  9. package/__tests__/styles/b.rn.css +3 -0
  10. package/__tests__/styles/b.scss +3 -0
  11. package/__tests__/styles/b.styl +3 -0
  12. package/__tests__/styles/c.css +3 -0
  13. package/__tests__/styles/c.less +5 -0
  14. package/__tests__/styles/c.rn.scss +5 -0
  15. package/__tests__/styles/c.scss +5 -0
  16. package/__tests__/styles/d.rn.scss +3 -0
  17. package/__tests__/styles/d.scss +3 -0
  18. package/__tests__/styles/mixins.scss +18 -0
  19. package/__tests__/styles/nest.rn.less +3 -0
  20. package/__tests__/styles/variable.scss +1 -0
  21. package/babel.config.js +12 -0
  22. package/dist/index.js +5 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/transforms/StyleSheet/ColorPropType.js.map +1 -1
  25. package/dist/transforms/StyleSheet/ImageStylePropTypes.js +1 -1
  26. package/dist/transforms/StyleSheet/ImageStylePropTypes.js.map +1 -1
  27. package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js +1 -1
  28. package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js.map +1 -1
  29. package/dist/transforms/StyleSheet/StyleSheetValidation.js +1 -1
  30. package/dist/transforms/StyleSheet/StyleSheetValidation.js.map +1 -1
  31. package/dist/transforms/StyleSheet/TextStylePropTypes.js +1 -1
  32. package/dist/transforms/StyleSheet/TextStylePropTypes.js.map +1 -1
  33. package/dist/transforms/StyleSheet/TransformPropTypes.js.map +1 -1
  34. package/dist/transforms/StyleSheet/ViewStylePropTypes.js +1 -1
  35. package/dist/transforms/StyleSheet/ViewStylePropTypes.js.map +1 -1
  36. package/dist/transforms/StyleSheet/deprecatedPropType.js.map +1 -1
  37. package/dist/transforms/StyleSheet/normalizeColor.js.map +1 -1
  38. package/dist/transforms/index.js +6 -6
  39. package/dist/transforms/index.js.map +1 -1
  40. package/dist/transforms/less.js +1 -1
  41. package/dist/transforms/less.js.map +1 -1
  42. package/dist/transforms/postcss.js +5 -17
  43. package/dist/transforms/postcss.js.map +1 -1
  44. package/dist/transforms/sass.js +2 -2
  45. package/dist/transforms/sass.js.map +1 -1
  46. package/dist/transforms/stylus.js +1 -1
  47. package/dist/transforms/stylus.js.map +1 -1
  48. package/dist/utils/index.js +2 -2
  49. package/dist/utils/index.js.map +1 -1
  50. package/dist/utils/reporterSkip.js.map +1 -1
  51. package/jest.config.js +8 -0
  52. package/package.json +31 -34
  53. package/src/config/rn-stylelint.json +5 -0
  54. package/src/index.ts +52 -0
  55. package/src/transforms/StyleSheet/ColorPropType.ts +76 -0
  56. package/src/transforms/StyleSheet/ImageResizeMode.ts +50 -0
  57. package/src/transforms/StyleSheet/ImageStylePropTypes.ts +62 -0
  58. package/src/transforms/StyleSheet/LayoutPropTypes.ts +559 -0
  59. package/src/transforms/StyleSheet/ShadowPropTypesIOS.ts +48 -0
  60. package/src/transforms/StyleSheet/StyleSheetValidation.ts +81 -0
  61. package/src/transforms/StyleSheet/TextStylePropTypes.ts +123 -0
  62. package/src/transforms/StyleSheet/TransformPropTypes.ts +109 -0
  63. package/src/transforms/StyleSheet/ViewStylePropTypes.ts +61 -0
  64. package/src/transforms/StyleSheet/deprecatedPropType.ts +31 -0
  65. package/src/transforms/StyleSheet/index.ts +5 -0
  66. package/src/transforms/StyleSheet/normalizeColor.ts +369 -0
  67. package/src/transforms/index.ts +231 -0
  68. package/src/transforms/less.ts +50 -0
  69. package/src/transforms/postcss.ts +96 -0
  70. package/src/transforms/sass.ts +151 -0
  71. package/src/transforms/stylus.ts +124 -0
  72. package/src/types/index.ts +242 -0
  73. package/src/utils/index.ts +229 -0
  74. package/src/utils/lessImport.ts +50 -0
  75. package/src/utils/reporterSkip.ts +27 -0
  76. package/tsconfig.json +12 -0
  77. package/dist/index.d.ts +0 -8
  78. package/dist/transforms/StyleSheet/ColorPropType.d.ts +0 -10
  79. package/dist/transforms/StyleSheet/ImageResizeMode.d.ts +0 -6
  80. package/dist/transforms/StyleSheet/ImageStylePropTypes.d.ts +0 -128
  81. package/dist/transforms/StyleSheet/LayoutPropTypes.d.ts +0 -388
  82. package/dist/transforms/StyleSheet/ShadowPropTypesIOS.d.ts +0 -45
  83. package/dist/transforms/StyleSheet/StyleSheetValidation.d.ts +0 -15
  84. package/dist/transforms/StyleSheet/TextStylePropTypes.d.ts +0 -191
  85. package/dist/transforms/StyleSheet/TransformPropTypes.d.ts +0 -67
  86. package/dist/transforms/StyleSheet/ViewStylePropTypes.d.ts +0 -136
  87. package/dist/transforms/StyleSheet/deprecatedPropType.d.ts +0 -13
  88. package/dist/transforms/StyleSheet/index.d.ts +0 -2
  89. package/dist/transforms/StyleSheet/normalizeColor.d.ts +0 -10
  90. package/dist/transforms/index.d.ts +0 -56
  91. package/dist/transforms/less.d.ts +0 -2
  92. package/dist/transforms/postcss.d.ts +0 -13
  93. package/dist/transforms/sass.d.ts +0 -2
  94. package/dist/transforms/stylus.d.ts +0 -3
  95. package/dist/types/index.d.ts +0 -206
  96. package/dist/utils/index.d.ts +0 -21
  97. package/dist/utils/lessImport.d.ts +0 -5
  98. package/dist/utils/reporterSkip.d.ts +0 -7
@@ -1,206 +0,0 @@
1
- /// <reference types="node" />
2
- import type { ProcessOptions } from 'postcss';
3
- import type { Options } from 'sass';
4
- export interface SassConfig {
5
- sass?: SassGlobalConfig;
6
- alias?: Record<string, string>;
7
- options: Options<'sync'>;
8
- additionalData?: string | ((key: string) => string);
9
- }
10
- export interface SassGlobalConfig {
11
- resource?: string | string[];
12
- projectDirectory?: string;
13
- data?: string;
14
- }
15
- export interface PostcssConfig {
16
- options: ProcessOptions;
17
- scalable: boolean;
18
- pxtransform?: {
19
- enable: boolean;
20
- config: any;
21
- };
22
- }
23
- interface SourceMapOption {
24
- sourceMapURL?: string;
25
- sourceMapBasepath?: string;
26
- sourceMapRootpath?: string;
27
- outputSourceFiles?: boolean;
28
- sourceMapFileInline?: boolean;
29
- }
30
- export interface LessOptions {
31
- sourceMap?: SourceMapOption;
32
- /** Filename of the main file to be passed to less.render() */
33
- filename?: string;
34
- /** The locations for less looking for files in @import rules */
35
- paths?: string[];
36
- /** True, if run the less parser and just reports errors without any output. */
37
- lint?: boolean;
38
- /** Pre-load global Less.js plugins */
39
- plugins?: Plugin[];
40
- /** @deprecated If true, compress using less built-in compression. */
41
- compress?: boolean;
42
- strictImports?: boolean;
43
- /** If true, allow imports from insecure https hosts. */
44
- insecure?: boolean;
45
- depends?: boolean;
46
- maxLineLen?: number;
47
- /** @deprecated If false, No color in compiling. */
48
- color?: boolean;
49
- /** @deprecated False by default. */
50
- ieCompat?: boolean;
51
- /** @deprecated If true, enable evaluation of JavaScript inline in `.less` files. */
52
- javascriptEnabled?: boolean;
53
- /** Whether output file information and line numbers in compiled CSS code. */
54
- dumpLineNumbers?: 'comment' | string;
55
- /** Add a path to every generated import and url in output css files. */
56
- rootpath?: string;
57
- /** Math mode options for avoiding symbol conficts on math expressions. */
58
- math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number;
59
- /** If true, stops any warnings from being shown. */
60
- silent?: boolean;
61
- /** Without this option, Less attempts to guess at the output unit when it does maths. */
62
- strictUnits?: boolean;
63
- /** Defines a variable that can be referenced by the file. */
64
- globalVars?: {
65
- [key: string]: string;
66
- };
67
- /** Puts Var declaration at the end of base file. */
68
- modifyVars?: {
69
- [key: string]: string;
70
- };
71
- /** Read files synchronously in Node.js */
72
- syncImport?: boolean;
73
- }
74
- export interface LessConfig {
75
- alias?: Record<string, string>;
76
- options: LessOptions;
77
- additionalData?: string | ((key: string) => string);
78
- }
79
- declare class Evaluator {
80
- }
81
- interface Dictionary<T> {
82
- [key: string]: T;
83
- }
84
- export interface StylusRenderOptions {
85
- globals?: Dictionary<any>;
86
- functions?: Dictionary<any>;
87
- imports?: string[];
88
- paths?: string[];
89
- filename?: string;
90
- Evaluator?: typeof Evaluator;
91
- /**
92
- * Specify Stylus plugins to use. Plugins may be passed as
93
- * strings instead of importing them in your Webpack config.
94
- *
95
- * @type {(string|Function)[]}
96
- * @default []
97
- */
98
- use: (string | ((string: any) => string))[];
99
- /**
100
- * Add path(s) to the import lookup paths.
101
- *
102
- * @type {string[]}
103
- * @default []
104
- */
105
- include: string[];
106
- /**
107
- * Import the specified Stylus files/paths.
108
- *
109
- * @type {string[]}
110
- * @default []
111
- */
112
- import: string[];
113
- /**
114
- * Define Stylus variables or functions.
115
- *
116
- * @type {Array|Object}
117
- * @default {}
118
- */
119
- define: Array<any> | Record<string, any>;
120
- /**
121
- * Include regular CSS on @import.
122
- *
123
- * @type {boolean}
124
- * @default false
125
- */
126
- includeCSS: boolean;
127
- /**
128
- * Resolve relative url()'s inside imported files.
129
- *
130
- * @see https://stylus-lang.com/docs/js.html#stylusresolveroptions
131
- *
132
- * @type {boolean|Object}
133
- * @default { nocheck: true }
134
- */
135
- /**
136
- * Emits comments in the generated CSS indicating the corresponding Stylus line.
137
- *
138
- * @see https://stylus-lang.com/docs/executable.html
139
- *
140
- * @type {boolean}
141
- * @default false
142
- */
143
- lineNumbers: boolean;
144
- /**
145
- * @type {boolean}
146
- * @default false
147
- */
148
- disableCache: boolean;
149
- /**
150
- * Move @import and @charset to the top.
151
- *
152
- * @see https://stylus-lang.com/docs/executable.html
153
- *
154
- * @type {boolean}
155
- * @default false
156
- */
157
- hoistAtrules: boolean;
158
- }
159
- export interface StylusConfig {
160
- alias?: Record<string, string>;
161
- options: StylusRenderOptions;
162
- additionalData?: string | ((key: string) => string);
163
- }
164
- interface RNConfig {
165
- postcss?: PostcssConfig;
166
- sass?: SassConfig;
167
- less?: LessConfig;
168
- stylus?: StylusConfig;
169
- }
170
- export interface Config {
171
- designWidth?: number | ((size?: string | number) => number);
172
- deviceRatio?: Record<string, number>;
173
- sass?: SassGlobalConfig;
174
- alias?: Record<string, string>;
175
- rn?: RNConfig;
176
- }
177
- export interface TransformOptions {
178
- dev?: boolean;
179
- hot?: boolean;
180
- minify?: boolean;
181
- platform: 'android' | 'ios';
182
- projectRoot?: string;
183
- publicPath?: string;
184
- customTransformOptions?: any;
185
- config?: Config;
186
- }
187
- export declare const enum ResolveLogLevelEnum {
188
- ERROR = "error",
189
- WARNING = "warning"
190
- }
191
- export interface ResolveStyleOptions {
192
- basedir: string;
193
- platform: 'android' | 'ios';
194
- paths?: string[];
195
- logLevel?: ResolveLogLevelEnum;
196
- defaultExt?: string;
197
- alias?: Record<string, string>;
198
- }
199
- export interface RenderResult {
200
- css: string | Buffer;
201
- map?: string | Buffer;
202
- }
203
- export interface RenderAdditionalResult extends RenderResult {
204
- additionalData: string;
205
- }
206
- export {};
@@ -1,21 +0,0 @@
1
- import { ResolveStyleOptions } from '../types';
2
- export declare function insertBefore(source?: string, additional?: string): string | undefined;
3
- /**
4
- * sort scss source by \@use
5
- * @param source scss source
6
- * @returns sorted scss source
7
- */
8
- export declare function sortStyle(source: any): any;
9
- export declare function insertAfter(source?: string, additional?: string): string | undefined;
10
- export declare function findVariant(name: any, extensions: any, includePaths: any): string;
11
- /**
12
- * 返回存在的文件path
13
- * @param id import id
14
- * @param opts { basedir, platform, paths }
15
- */
16
- export declare function resolveStyle(id: string, opts: ResolveStyleOptions): string;
17
- export declare function normalizePath(file: any): any;
18
- export declare function normalizeSourceMap(map: any, resourcePath: any): any;
19
- export declare function getAdditionalData(data: string, config?: string | ((key: string) => string)): string;
20
- declare const _default: {};
21
- export default _default;
@@ -1,5 +0,0 @@
1
- declare function makeLessImport(options: any): {
2
- install: (_: any, pluginManager: any) => void;
3
- minVersion: number[];
4
- };
5
- export default makeLessImport;
@@ -1,7 +0,0 @@
1
- export default function reporterSkip({ skipRows, filename }: {
2
- skipRows: any;
3
- filename: any;
4
- }): {
5
- postcssPlugin: string;
6
- Once(css: any, result: any): void;
7
- };