@tarojs/rn-style-transformer 3.5.1 → 3.5.2
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/__tests__/config.spec.js +2 -2
- package/__tests__/index.spec.js +3 -3
- package/__tests__/platform.spec.js +4 -3
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/transforms/index.js +2 -2
- package/dist/transforms/index.js.map +1 -1
- package/dist/transforms/less.js.map +1 -1
- package/dist/transforms/postcss.js.map +1 -1
- package/dist/transforms/sass.js +3 -1
- package/dist/transforms/sass.js.map +1 -1
- package/dist/transforms/stylus.js +0 -2
- package/dist/transforms/stylus.js.map +1 -1
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lessImport.js +2 -2
- package/dist/utils/lessImport.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +6 -12
- package/src/transforms/index.ts +10 -24
- package/src/transforms/less.ts +2 -61
- package/src/transforms/postcss.ts +1 -10
- package/src/transforms/sass.ts +5 -20
- package/src/transforms/stylus.ts +4 -106
- package/src/types/index.ts +218 -8
- package/src/utils/index.ts +4 -4
- package/src/utils/lessImport.ts +3 -3
package/__tests__/config.spec.js
CHANGED
|
@@ -35,14 +35,14 @@ const defaultConfig = {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async function run (src, filename = './__tests__/styles/a.css', debug) {
|
|
38
|
-
let options
|
|
38
|
+
let options = { platform: 'android' }
|
|
39
39
|
let config
|
|
40
40
|
|
|
41
41
|
if (typeof src === 'object') {
|
|
42
42
|
({
|
|
43
43
|
src,
|
|
44
44
|
filename = './__tests__/styles/a.css',
|
|
45
|
-
options,
|
|
45
|
+
options = { platform: 'android' },
|
|
46
46
|
debug,
|
|
47
47
|
config
|
|
48
48
|
} = src || {})
|
package/__tests__/index.spec.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import StyleTransform, { getWrapedCSS } from '../src/transforms'
|
|
2
2
|
|
|
3
3
|
// 初始化
|
|
4
|
-
const styleTransform = new StyleTransform()
|
|
4
|
+
const styleTransform = new StyleTransform({})
|
|
5
5
|
|
|
6
6
|
async function run (src, filename = './__tests__/styles/a.css', debug) {
|
|
7
|
-
let options
|
|
7
|
+
let options = { platform: 'android' }
|
|
8
8
|
|
|
9
9
|
if (typeof src === 'object') {
|
|
10
10
|
({
|
|
11
11
|
src,
|
|
12
12
|
filename = './__tests__/styles/a.css',
|
|
13
|
-
options,
|
|
13
|
+
options = { platform: 'android' },
|
|
14
14
|
debug
|
|
15
15
|
} = src || {})
|
|
16
16
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import StyleTransform, { getWrapedCSS } from '../src/transforms'
|
|
2
2
|
|
|
3
3
|
// 初始化config
|
|
4
|
-
const styleTransform = new StyleTransform()
|
|
4
|
+
const styleTransform = new StyleTransform({})
|
|
5
5
|
|
|
6
|
-
async function run (src, filename = './__tests__/styles/a.css', options, debug) {
|
|
6
|
+
async function run (src, filename = './__tests__/styles/a.css', options = { platform: 'android' }, debug) {
|
|
7
7
|
if (typeof src === 'object') {
|
|
8
8
|
({
|
|
9
9
|
src,
|
|
10
10
|
filename = './__tests__/styles/a.css',
|
|
11
|
-
options,
|
|
11
|
+
options = { platform: 'android' },
|
|
12
12
|
debug
|
|
13
13
|
} = src || {})
|
|
14
14
|
}
|
|
@@ -63,6 +63,7 @@ describe('style transform in cross platform', () => {
|
|
|
63
63
|
|
|
64
64
|
it('nest sass import cross platform', async () => {
|
|
65
65
|
const css = await run({
|
|
66
|
+
filename: './__tests__/styles/a.scss',
|
|
66
67
|
src: "@import './c.scss';"
|
|
67
68
|
})
|
|
68
69
|
expect(css).toEqual(getWrapedCSS(`{
|
package/dist/index.js
CHANGED
|
@@ -28,13 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.rollupTransform = exports.transform = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
|
-
// import semver from 'semver'
|
|
32
|
-
// import reactNativePKG from 'react-native/package.json'
|
|
33
31
|
const transforms_1 = __importDefault(require("./transforms"));
|
|
34
32
|
const RN_CSS_EXT = ['.css', '.scss', '.sass', '.less', '.styl', '.stylus'];
|
|
35
|
-
// 目前仅支持React-Native 0.60+
|
|
36
|
-
// const reactNativeVersionString = reactNativePKG.version
|
|
37
|
-
// const reactNativeMinorVersion = semver.minor(reactNativeVersionString)
|
|
38
33
|
const upstreamTransformer = require('metro-react-native-babel-transformer');
|
|
39
34
|
const getSingleStyleTransform = styleTransformIns();
|
|
40
35
|
function styleTransformIns() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAE5B,8DAAyC;AAGzC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AAC1E,MAAM,mBAAmB,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAA;AAE3E,MAAM,uBAAuB,GAAG,iBAAiB,EAAE,CAAA;AAEnD,SAAS,iBAAiB;IACxB,IAAI,cAAc,GAA0B,IAAI,CAAA;IAChD,OAAO,UAAU,MAAc;QAC7B,aAAa;QACb,IAAI,CAAC,cAAc,EAAE;YACnB,cAAc,GAAG,IAAI,oBAAc,CAAC,MAAM,CAAC,CAAA;SAC5C;QACD,OAAO,cAAc,CAAA;IACvB,CAAC,CAAA;AACH,CAA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|
package/dist/transforms/index.js
CHANGED
|
@@ -86,7 +86,7 @@ const DEFAULT_RN_CONFIG = {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
class StyleTransform {
|
|
89
|
-
constructor(config
|
|
89
|
+
constructor(config) {
|
|
90
90
|
this.processConfigMap = new Map();
|
|
91
91
|
this.init = (config) => {
|
|
92
92
|
var _a;
|
|
@@ -183,7 +183,7 @@ class StyleTransform {
|
|
|
183
183
|
* @param {object} transform
|
|
184
184
|
* @return {string} JSONString
|
|
185
185
|
*/
|
|
186
|
-
async transform(src, filename, options
|
|
186
|
+
async transform(src, filename, options) {
|
|
187
187
|
var _a;
|
|
188
188
|
// printLog(processTypeEnum.START, '样式文件处理开始', filename)
|
|
189
189
|
const result = await this.processStyle(src, filename, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0E;AAC1E,2CAA4B;AAC5B,wFAAmD;AAGnD,oCAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0E;AAC1E,2CAA4B;AAC5B,wFAAmD;AAGnD,oCAA6C;AAC7C,kDAAkC;AAClC,qDAAgE;AAChE,kDAAkC;AAClC,6CAAmD;AACnD,mDAAkF;AAIlF,SAAgB,YAAY,CAAE,GAAG;IAC/B,OAAO;;;;;;;mCAO0B,GAAG;CACrC,CAAA;AACD,CAAC;AAVD,oCAUC;AAED;;GAEG;AACH,SAAS,aAAa,CAAE,EAAE,WAAW,EAAE,QAAQ,EAAE;IAC/C,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;QAC9B,IAAI;YACF,iCAAoB,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;SACtD;QAAC,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GAAG,EAAE,QAAQ,CAAC;oBACvC,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,KAAK;iBAClB,GACF;SACF,CACF,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACd,uCACK,MAAM,KACT,QAAQ,IACT;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,CAAE,GAAW,EAAE,QAAgB,EAAE,OAAyB;;QACvE,wDAAwD;QACxD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QAE9D,4DAA4D;QAC5D,MAAM,WAAW,GAAG,IAAA,kCAAY,EAC9B,MAAM,CAAC,GAAG,EACV;YACE,iBAAiB,EAAE,IAAI;YACvB,QAAQ,EAAE,MAAA,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,0CAAE,QAAQ;SAC3C,CACF,CAAA;QAED,0BAA0B;QAC1B,aAAa,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAA;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;aAC7C,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC;aACvC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAA;QAE1C,qBAAqB;QACrB,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;CACF;AArJD,iCAqJC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"less.js","sourceRoot":"","sources":["../../src/transforms/less.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,2CAA4B;AAG5B,oCAA0D;AAC1D,qEAAgD;
|
|
1
|
+
{"version":3,"file":"less.js","sourceRoot":"","sources":["../../src/transforms/less.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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C,KAAK,IAChB,MAAM,CAAC,OAAO,EAEpB,CAAC,IAAI,CAAC,CAAC,MAAoB,EAAE,EAAE;QAC9B,OAAO,gCAAK,MAAM,KAAE,cAAc,GAA4B,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AArBD,4BAqBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcss.js","sourceRoot":"","sources":["../../src/transforms/postcss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoF;AACpF,2CAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"postcss.js","sourceRoot":"","sources":["../../src/transforms/postcss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoF;AACpF,2CAA4B;AAC5B,sDAA6B;AAC7B,oEAA0C;AAC1C,8EAA6C;AAC7C,qCAA6C;AAE7C,oFAAyD;AACzD,oCAAuC;AACvC,yEAAgD;AAEhD,MAAM,wBAAwB,GAE1B;IACF,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI;KACf;CACF,CAAA;AAED,SAAgB,kBAAkB,CAAE,EAClC,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf;IACC,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;IAE5G,IAAI,WAAW,EAAE;QACf,wBAAwB,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;KAC1D;IAED,IAAI,WAAW,EAAE;QACf,wBAAwB,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;KAC1D;IACD,MAAM,iBAAiB,GAAG,IAAA,uBAAc,EAAC,EAAE,EAAE,wBAAwB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;IAEjG,MAAM,OAAO,GAAG;QACd,IAAA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G,IAAA,cAAW,EAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACtE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAE,YAAoB,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAA;SACtE;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,cAAc,UAAU,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/E,IAAA,iBAAQ,EAAC,GAAG,0CAA0B,CAAA;SACvC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC;AAlED,gDAkEC;AAED,SAAwB,SAAS,CAAE,GAAW,EAAE,QAAgB,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;IACpF,OAAO,IAAA,iBAAO,EAAC,OAAO,CAAC;SACpB,OAAO,CAAC,GAAG,kBAAI,IAAI,EAAE,QAAQ,IAAK,OAAO,EAAG;SAC5C,IAAI,CAAC,MAAM,CAAC,EAAE;QACb,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC;AAND,4BAMC"}
|
package/dist/transforms/sass.js
CHANGED
|
@@ -133,7 +133,9 @@ function transform(src, filename, config, transformOptions) {
|
|
|
133
133
|
if (!data) {
|
|
134
134
|
data = `\n${data}`; // fix empty file error. reference https://github.com/sass/node-sass/blob/91c40a0bf0a3923ab9f91b82dcd479c25486235a/lib/index.js#L430
|
|
135
135
|
}
|
|
136
|
-
return renderToCSS(data, filename, Object.assign({
|
|
136
|
+
return renderToCSS(data, filename, Object.assign({
|
|
137
|
+
// file: filename, // fix[issues/11983]: with file option,dart-sass importer donot execute。
|
|
138
|
+
outFile: `${filename}.map`, sourceMap: true, alias: config.alias }, config.options), transformOptions).then((result) => {
|
|
137
139
|
return Object.assign(Object.assign({}, result), { additionalData });
|
|
138
140
|
});
|
|
139
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sass.js","sourceRoot":"","sources":["../../src/transforms/sass.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;
|
|
1
|
+
{"version":3,"file":"sass.js","sourceRoot":"","sources":["../../src/transforms/sass.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAG5B,oCAAqF;AAErF;;GAEG;AACH,SAAS,qBAAqB;IAC5B,IAAI,WAAW,GAAG,WAAW,CAAA;IAE7B,IAAI;QACF,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;KAC7B;IAAC,OAAO,KAAK,EAAE;QACd,IAAI;YACF,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACvB,WAAW,GAAG,MAAM,CAAA;SACrB;QAAC,OAAO,WAAW,EAAE;YACpB,WAAW,GAAG,MAAM,CAAA;SACrB;KACF;IAED,OAAO,OAAO,CAAC,WAAW,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAA;AAElD,SAAS,OAAO,CAAE,QAAgB,EAAE,OAAe;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAA;KAC5C;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAE,QAAgB,EAAE,QAAgB,EAAE,OAAe;IAC/E,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACtC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAA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,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.defaultOptions = void 0;
|
|
7
7
|
const stylus_1 = __importDefault(require("stylus"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
-
class Evaluator {
|
|
10
|
-
}
|
|
11
9
|
exports.defaultOptions = {
|
|
12
10
|
use: [],
|
|
13
11
|
include: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylus.js","sourceRoot":"","sources":["../../src/transforms/stylus.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAG3B,oCAA0D;
|
|
1
|
+
{"version":3,"file":"stylus.js","sourceRoot":"","sources":["../../src/transforms/stylus.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAG3B,oCAA0D;AAE7C,QAAA,cAAc,GAAwB;IACjD,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,KAAK;IACjB,kCAAkC;IAClC,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,KAAK;CACpB,CAAA;AAED,SAAS,WAAW,CAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAyB;IACtE,MAAM,aAAa,mBAAK,QAAQ,IAAK,OAAO,CAAE,CAAA;IAC9C,MAAM,IAAI,GAAG,IAAA,gBAAM,EAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAEvC,IAAI,CAAC,GAAG,CACN,WAAW,EACX;QACE,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,GAAG;KACd,CACF,CAAA;IAED,iCAAiC;IACjC,IAAI,aAAa,CAAC,UAAU,EAAE;QAC5B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;KAC9B;IAED,IAAI,aAAa,CAAC,YAAY,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC,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MAAM,KAAE,cAAc,GAA4B,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AAXD,4BAWC"}
|
package/dist/types/index.js
CHANGED
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;AAwFA,SAAS;AACT,MAAM,SAAS;CAAI"}
|
package/dist/utils/index.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.findVariant = findVariant;
|
|
|
80
80
|
* @param opts { basedir, platform, paths }
|
|
81
81
|
*/
|
|
82
82
|
function resolveStyle(id, opts) {
|
|
83
|
-
const { basedir, platform, paths = [], alias = {}, defaultExt = '', logLevel = "error" /*
|
|
83
|
+
const { basedir, platform, paths = [], alias = {}, defaultExt = '', logLevel = "error" /* ResolveLogLevelEnum.ERROR */ } = opts;
|
|
84
84
|
id = id.trim();
|
|
85
85
|
Object.keys(alias).forEach(key => {
|
|
86
86
|
if (id.startsWith(key)) {
|
|
@@ -122,10 +122,10 @@ function resolveStyle(id, opts) {
|
|
|
122
122
|
${includePaths.join(',\n ')}
|
|
123
123
|
]
|
|
124
124
|
`;
|
|
125
|
-
if (logLevel === "error" /*
|
|
125
|
+
if (logLevel === "error" /* ResolveLogLevelEnum.ERROR */) {
|
|
126
126
|
throw new Error(levelMessage);
|
|
127
127
|
}
|
|
128
|
-
if (logLevel === "warning" /*
|
|
128
|
+
if (logLevel === "warning" /* ResolveLogLevelEnum.WARNING */) {
|
|
129
129
|
(0, helper_1.printLog)("warning" /* processTypeEnum.WARNING */, levelMessage);
|
|
130
130
|
return id;
|
|
131
131
|
}
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;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G,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7C,qCAAqC;YACrC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBAC7B,OAAO,MAAM,CAAA;aACd;YAED,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;YAErC,oDAAoD;YACpD,IAAI,UAAU,KAAK,eAAe,IAAI,UAAU,KAAK,eAAe,EAAE;gBACpE,MAAM,cAAc,GAClB,UAAU,KAAK,eAAe,IAAI,UAAU;oBAC1C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;oBACjD,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;gBAE3B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC,CAAA;aACjE;YAED,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;KACH;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAzCD,gDAyCC;AACD,WAAW;AAEX,SAAgB,iBAAiB,CAAE,IAAY,EAAE,MAA2C;IAC1F,IAAI,cAAc,GAAG,EAAE,CAAA;IACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,cAAc;YACZ,OAAO,MAAM,KAAK,UAAU;gBAC1B,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;gBACnB,CAAC,CAAC,MAAM,CAAA;KACb;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AATD,8CASC;AAED,kBAAe,EAAE,CAAA"}
|
package/dist/utils/lessImport.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const less_1 = __importDefault(require("less"));
|
|
7
7
|
const index_1 = require("./index");
|
|
8
|
-
class
|
|
8
|
+
class LessImporter extends less_1.default.FileManager {
|
|
9
9
|
constructor(opt) {
|
|
10
10
|
super();
|
|
11
11
|
this.alias = {};
|
|
@@ -32,7 +32,7 @@ class Importer extends less_1.default.FileManager {
|
|
|
32
32
|
function makeLessImport(options) {
|
|
33
33
|
return {
|
|
34
34
|
install: (_, pluginManager) => {
|
|
35
|
-
pluginManager.addFileManager(new
|
|
35
|
+
pluginManager.addFileManager(new LessImporter(options));
|
|
36
36
|
},
|
|
37
37
|
minVersion: [2, 7, 1]
|
|
38
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lessImport.js","sourceRoot":"","sources":["../../src/utils/lessImport.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AAEvB,mCAAsC;AAEtC,MAAM,
|
|
1
|
+
{"version":3,"file":"lessImport.js","sourceRoot":"","sources":["../../src/utils/lessImport.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AAEvB,mCAAsC;AAEtC,MAAM,YAAa,SAAQ,cAAI,CAAC,WAAW;IAIzC,YAAa,GAAG;QACd,KAAK,EAAE,CAAA;QAHT,UAAK,GAA2B,EAAE,CAAA;QAIhC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAA;IACb,CAAC;IAED,YAAY;QACV,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,QAAgB,EAChB,gBAAwB,EACxB,OAAY,EACZ,WAAgB;QAEhB,MAAM,WAAW,GAAG;YAClB,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,OAAO;SACpB,CAAA;QACD,MAAM,eAAe,GAAG,IAAA,oBAAY,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;QAE3D,OAAO,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IAChF,CAAC;CACF;AAED,SAAS,cAAc,CAAE,OAAO;IAC9B,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE;YAC5B,aAAa,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;QACzD,CAAC;QACD,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACtB,CAAA;AACH,CAAC;AAED,kBAAe,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/rn-style-transformer",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "提供Taro RN 统一处理样式文件能力",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -16,21 +16,21 @@
|
|
|
16
16
|
"npm": ">=6.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tarojs/helper": "3.5.
|
|
19
|
+
"@tarojs/helper": "3.5.2",
|
|
20
20
|
"fbjs": "^2.0.0",
|
|
21
21
|
"less": "^3.12.2",
|
|
22
22
|
"postcss": "^8.4.12",
|
|
23
23
|
"postcss-import": "^12.0.1",
|
|
24
|
-
"postcss-pxtransform": "3.5.
|
|
24
|
+
"postcss-pxtransform": "3.5.2",
|
|
25
25
|
"postcss-reporter": "^6.0.1",
|
|
26
26
|
"prop-types": "^15.7.2",
|
|
27
27
|
"resolve": "^1.22.0",
|
|
28
|
-
"sass": "1.
|
|
28
|
+
"sass": "1.37.5",
|
|
29
29
|
"stylelint": "^14.9.1",
|
|
30
|
-
"stylelint-config-taro-rn": "3.5.
|
|
31
|
-
"stylelint-taro-rn": "3.5.
|
|
30
|
+
"stylelint-config-taro-rn": "3.5.2",
|
|
31
|
+
"stylelint-taro-rn": "3.5.2",
|
|
32
32
|
"stylus": "^0.55.0",
|
|
33
|
-
"taro-css-to-react-native": "3.5.
|
|
33
|
+
"taro-css-to-react-native": "3.5.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "jest",
|
package/src/index.ts
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import * as path from 'path'
|
|
2
2
|
|
|
3
|
-
// import semver from 'semver'
|
|
4
|
-
// import reactNativePKG from 'react-native/package.json'
|
|
5
3
|
import StyleTransform from './transforms'
|
|
4
|
+
import { Config, TransformOptions } from './types'
|
|
6
5
|
|
|
7
6
|
const RN_CSS_EXT = ['.css', '.scss', '.sass', '.less', '.styl', '.stylus']
|
|
8
|
-
|
|
9
|
-
// 目前仅支持React-Native 0.60+
|
|
10
|
-
// const reactNativeVersionString = reactNativePKG.version
|
|
11
|
-
// const reactNativeMinorVersion = semver.minor(reactNativeVersionString)
|
|
12
|
-
|
|
13
7
|
const upstreamTransformer = require('metro-react-native-babel-transformer')
|
|
14
8
|
|
|
15
9
|
const getSingleStyleTransform = styleTransformIns()
|
|
16
10
|
|
|
17
11
|
function styleTransformIns () {
|
|
18
12
|
let styleTransform: StyleTransform | null = null
|
|
19
|
-
return function (config) {
|
|
13
|
+
return function (config: Config) {
|
|
20
14
|
// 初始化 config
|
|
21
15
|
if (!styleTransform) {
|
|
22
16
|
styleTransform = new StyleTransform(config)
|
|
@@ -25,7 +19,7 @@ function styleTransformIns () {
|
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
|
|
28
|
-
export async function transform (src: string, filename: string, options) {
|
|
22
|
+
export async function transform (src: string, filename: string, options: TransformOptions) {
|
|
29
23
|
if (typeof src === 'object') {
|
|
30
24
|
// handle RN >= 0.46
|
|
31
25
|
({ src, filename, options } = src)
|
|
@@ -43,13 +37,13 @@ export async function transform (src: string, filename: string, options) {
|
|
|
43
37
|
return upstreamTransformer.transform({ src, filename, options })
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
export function rollupTransform (options) {
|
|
40
|
+
export function rollupTransform (options: TransformOptions) {
|
|
47
41
|
return {
|
|
48
42
|
name: 'rn-style-transformer', // this name will show up in warnings and errors
|
|
49
|
-
async transform (src, filename) {
|
|
43
|
+
async transform (src: string, filename: string) {
|
|
50
44
|
const ext = path.extname(filename)
|
|
51
45
|
if (RN_CSS_EXT.includes(ext)) {
|
|
52
|
-
const styleTransform = getSingleStyleTransform(
|
|
46
|
+
const styleTransform = getSingleStyleTransform(options.config)
|
|
53
47
|
const code = await styleTransform.transform(src, filename, options)
|
|
54
48
|
return { code }
|
|
55
49
|
}
|
package/src/transforms/index.ts
CHANGED
|
@@ -2,13 +2,15 @@ import { printLog, processTypeEnum, recursiveMerge } from '@tarojs/helper'
|
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import transformCSS from 'taro-css-to-react-native'
|
|
4
4
|
|
|
5
|
-
import { RenderAdditionalResult, TransformOptions } from '../types'
|
|
5
|
+
import { Config, PostcssConfig, RenderAdditionalResult, TransformOptions } from '../types'
|
|
6
6
|
import { normalizeSourceMap } from '../utils'
|
|
7
|
-
import lessTransform
|
|
8
|
-
import postcssTransform, {
|
|
9
|
-
import sassTransform
|
|
7
|
+
import lessTransform from './less'
|
|
8
|
+
import postcssTransform, { makePostcssPlugins } from './postcss'
|
|
9
|
+
import sassTransform from './sass'
|
|
10
10
|
import { StyleSheetValidation } from './StyleSheet'
|
|
11
|
-
import stylusTransform, {
|
|
11
|
+
import stylusTransform, { defaultOptions as stylusDefaultOptions } from './stylus'
|
|
12
|
+
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
export function getWrapedCSS (css) {
|
|
14
16
|
return `
|
|
@@ -36,22 +38,6 @@ function validateStyle ({ styleObject, filename }) {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
interface RNConfig {
|
|
41
|
-
postcss?: PostcssConfig
|
|
42
|
-
sass?: SassConfig
|
|
43
|
-
less?: LessConfig
|
|
44
|
-
stylus?: StylusConfig
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface Config {
|
|
48
|
-
designWidth: number
|
|
49
|
-
deviceRatio: { [key: number]: number }
|
|
50
|
-
sass: SassGlobalConfig
|
|
51
|
-
alias: Record<string, string>
|
|
52
|
-
rn: RNConfig
|
|
53
|
-
}
|
|
54
|
-
|
|
55
41
|
interface PostcssParam {
|
|
56
42
|
css: string
|
|
57
43
|
map: any
|
|
@@ -97,11 +83,11 @@ export default class StyleTransform {
|
|
|
97
83
|
|
|
98
84
|
processConfigMap = new Map()
|
|
99
85
|
|
|
100
|
-
constructor (config
|
|
86
|
+
constructor (config: Config) {
|
|
101
87
|
this.init(config)
|
|
102
88
|
}
|
|
103
89
|
|
|
104
|
-
init = (config) => {
|
|
90
|
+
init = (config: Config) => {
|
|
105
91
|
this.config = {
|
|
106
92
|
designWidth: config.designWidth || designWidth,
|
|
107
93
|
deviceRatio: config.deviceRatio || deviceRatio,
|
|
@@ -219,7 +205,7 @@ export default class StyleTransform {
|
|
|
219
205
|
* @param {object} transform
|
|
220
206
|
* @return {string} JSONString
|
|
221
207
|
*/
|
|
222
|
-
async transform (src: string, filename: string, options
|
|
208
|
+
async transform (src: string, filename: string, options: TransformOptions) {
|
|
223
209
|
// printLog(processTypeEnum.START, '样式文件处理开始', filename)
|
|
224
210
|
const result = await this.processStyle(src, filename, options)
|
|
225
211
|
|
package/src/transforms/less.ts
CHANGED
|
@@ -1,69 +1,10 @@
|
|
|
1
1
|
import less from 'less'
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
|
|
4
|
-
import { RenderAdditionalResult, RenderResult } from '../types'
|
|
4
|
+
import { LessConfig, RenderAdditionalResult, RenderResult } from '../types'
|
|
5
5
|
import { getAdditionalData, insertBefore } from '../utils'
|
|
6
6
|
import makeLessImport from '../utils/lessImport'
|
|
7
7
|
|
|
8
|
-
interface SourceMapOption {
|
|
9
|
-
sourceMapURL?: string
|
|
10
|
-
sourceMapBasepath?: string
|
|
11
|
-
sourceMapRootpath?: string
|
|
12
|
-
outputSourceFiles?: boolean
|
|
13
|
-
sourceMapFileInline?: boolean
|
|
14
|
-
}
|
|
15
|
-
// http://lesscss.org/usage/#less-options
|
|
16
|
-
export interface Options {
|
|
17
|
-
sourceMap?: SourceMapOption
|
|
18
|
-
/** Filename of the main file to be passed to less.render() */
|
|
19
|
-
filename?: string
|
|
20
|
-
/** The locations for less looking for files in @import rules */
|
|
21
|
-
paths?: string[]
|
|
22
|
-
/** True, if run the less parser and just reports errors without any output. */
|
|
23
|
-
lint?: boolean
|
|
24
|
-
/** Pre-load global Less.js plugins */
|
|
25
|
-
plugins?: Plugin[]
|
|
26
|
-
/** @deprecated If true, compress using less built-in compression. */
|
|
27
|
-
compress?: boolean
|
|
28
|
-
strictImports?: boolean
|
|
29
|
-
/** If true, allow imports from insecure https hosts. */
|
|
30
|
-
insecure?: boolean
|
|
31
|
-
depends?: boolean
|
|
32
|
-
maxLineLen?: number
|
|
33
|
-
/** @deprecated If false, No color in compiling. */
|
|
34
|
-
color?: boolean
|
|
35
|
-
/** @deprecated False by default. */
|
|
36
|
-
ieCompat?: boolean
|
|
37
|
-
/** @deprecated If true, enable evaluation of JavaScript inline in `.less` files. */
|
|
38
|
-
javascriptEnabled?: boolean
|
|
39
|
-
/** Whether output file information and line numbers in compiled CSS code. */
|
|
40
|
-
dumpLineNumbers?: 'comment' | string
|
|
41
|
-
/** Add a path to every generated import and url in output css files. */
|
|
42
|
-
rootpath?: string
|
|
43
|
-
/** Math mode options for avoiding symbol conficts on math expressions. */
|
|
44
|
-
math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number
|
|
45
|
-
/** If true, stops any warnings from being shown. */
|
|
46
|
-
silent?: boolean
|
|
47
|
-
/** Without this option, Less attempts to guess at the output unit when it does maths. */
|
|
48
|
-
strictUnits?: boolean
|
|
49
|
-
/** Defines a variable that can be referenced by the file. */
|
|
50
|
-
globalVars?: {
|
|
51
|
-
[key: string]: string
|
|
52
|
-
}
|
|
53
|
-
/** Puts Var declaration at the end of base file. */
|
|
54
|
-
modifyVars?: {
|
|
55
|
-
[key: string]: string
|
|
56
|
-
}
|
|
57
|
-
/** Read files synchronously in Node.js */
|
|
58
|
-
syncImport?: boolean
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface Config {
|
|
62
|
-
alias?: Record<string, string>
|
|
63
|
-
options: Options
|
|
64
|
-
additionalData?: string | ((key: string) => string)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
8
|
function renderToCSS (src, filename, options = {} as any) {
|
|
68
9
|
// default plugins
|
|
69
10
|
const plugins = [makeLessImport(options)]
|
|
@@ -88,7 +29,7 @@ function renderToCSS (src, filename, options = {} as any) {
|
|
|
88
29
|
export default function transform (
|
|
89
30
|
src: string,
|
|
90
31
|
filename: string,
|
|
91
|
-
config:
|
|
32
|
+
config: LessConfig
|
|
92
33
|
) {
|
|
93
34
|
const additionalData = getAdditionalData(src, config.additionalData)
|
|
94
35
|
const data = insertBefore(src, additionalData)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNpmPkg, printLog, processTypeEnum, recursiveMerge } from '@tarojs/helper'
|
|
2
2
|
import * as path from 'path'
|
|
3
|
-
import postcss
|
|
3
|
+
import postcss from 'postcss'
|
|
4
4
|
import postcssImport from 'postcss-import'
|
|
5
5
|
import pxtransform from 'postcss-pxtransform'
|
|
6
6
|
import { sync as resolveSync } from 'resolve'
|
|
@@ -9,15 +9,6 @@ import stylelintConfig from '../config/rn-stylelint.json'
|
|
|
9
9
|
import { resolveStyle } from '../utils'
|
|
10
10
|
import reporterSkip from '../utils/reporterSkip'
|
|
11
11
|
|
|
12
|
-
export interface Config {
|
|
13
|
-
options: ProcessOptions // https://github.com/postcss/postcss#options
|
|
14
|
-
scalable: boolean // 控制是否对 css value 进行 scalePx2dp 转换
|
|
15
|
-
pxtransform: {
|
|
16
|
-
enable: boolean
|
|
17
|
-
config: any
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
const defaultPxtransformOption: {
|
|
22
13
|
[key: string]: any
|
|
23
14
|
} = {
|
package/src/transforms/sass.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs'
|
|
2
2
|
import * as path from 'path'
|
|
3
|
-
import { Options } from 'sass'
|
|
4
3
|
|
|
5
|
-
import { RenderAdditionalResult, RenderResult, TransformOptions } from '../types'
|
|
4
|
+
import { RenderAdditionalResult, RenderResult, SassConfig, SassGlobalConfig,TransformOptions } from '../types'
|
|
6
5
|
import { getAdditionalData, insertAfter, insertBefore, resolveStyle } from '../utils'
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -27,20 +26,6 @@ function getSassImplementation () {
|
|
|
27
26
|
|
|
28
27
|
const sassImplementation = getSassImplementation()
|
|
29
28
|
|
|
30
|
-
// https://github.com/sass/node-sass#options
|
|
31
|
-
export interface Config {
|
|
32
|
-
sass?: SassGlobalConfig
|
|
33
|
-
alias?: Record<string, string>
|
|
34
|
-
options?: Options<'sync'>
|
|
35
|
-
additionalData?: string | ((key: string) => string)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface SassGlobalConfig {
|
|
39
|
-
resource?: string | string[]
|
|
40
|
-
projectDirectory?: string
|
|
41
|
-
data?: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
29
|
function makeURL (resource: string, rootDir: string) {
|
|
45
30
|
const url = path.resolve(rootDir, resource)
|
|
46
31
|
if (!fs.existsSync(url)) {
|
|
@@ -70,7 +55,7 @@ function getGlobalResource (filename: string, config: SassGlobalConfig) {
|
|
|
70
55
|
return insertAfter(resource, config?.data)
|
|
71
56
|
}
|
|
72
57
|
|
|
73
|
-
function combineResource (src: string, filename: string, config:
|
|
58
|
+
function combineResource (src: string, filename: string, config: SassConfig) {
|
|
74
59
|
// sass config
|
|
75
60
|
const globalResource = getGlobalResource(filename, config.sass || {})
|
|
76
61
|
|
|
@@ -80,7 +65,7 @@ function combineResource (src: string, filename: string, config: Config) {
|
|
|
80
65
|
return insertAfter(globalResource, additionalData)
|
|
81
66
|
}
|
|
82
67
|
|
|
83
|
-
function renderToCSS (src, filename, options, transformOptions) {
|
|
68
|
+
function renderToCSS (src, filename, options, transformOptions: TransformOptions) {
|
|
84
69
|
const defaultOpts = {
|
|
85
70
|
importer: function (...params) { /* url, prev, done */
|
|
86
71
|
let [url, prev] = params
|
|
@@ -135,7 +120,7 @@ function renderToCSS (src, filename, options, transformOptions) {
|
|
|
135
120
|
export default function transform (
|
|
136
121
|
src: string,
|
|
137
122
|
filename: string,
|
|
138
|
-
config:
|
|
123
|
+
config: SassConfig,
|
|
139
124
|
transformOptions: TransformOptions
|
|
140
125
|
) {
|
|
141
126
|
const additionalData = combineResource(src, filename, config)
|
|
@@ -149,7 +134,7 @@ export default function transform (
|
|
|
149
134
|
data,
|
|
150
135
|
filename,
|
|
151
136
|
{
|
|
152
|
-
file: filename,
|
|
137
|
+
// file: filename, // fix[issues/11983]: with file option,dart-sass importer donot execute。
|
|
153
138
|
outFile: `${filename}.map`,
|
|
154
139
|
sourceMap: true, // If no outFile is set, sourceMap parameter is ignored.
|
|
155
140
|
alias: config.alias,
|
package/src/transforms/stylus.ts
CHANGED
|
@@ -1,111 +1,9 @@
|
|
|
1
1
|
import stylus from 'stylus'
|
|
2
2
|
|
|
3
|
-
import { RenderAdditionalResult, RenderResult } from '../types'
|
|
3
|
+
import { RenderAdditionalResult, RenderResult, StylusConfig, StylusRenderOptions } from '../types'
|
|
4
4
|
import { getAdditionalData, insertBefore } from '../utils'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
interface Dictionary<T> {
|
|
9
|
-
[key: string]: T
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// https://stylus-lang.com/docs/js.html
|
|
13
|
-
interface RenderOptions {
|
|
14
|
-
globals?: Dictionary<any>
|
|
15
|
-
functions?: Dictionary<any>
|
|
16
|
-
imports?: string[]
|
|
17
|
-
paths?: string[]
|
|
18
|
-
filename?: string
|
|
19
|
-
Evaluator?: typeof Evaluator
|
|
20
|
-
/**
|
|
21
|
-
* Specify Stylus plugins to use. Plugins may be passed as
|
|
22
|
-
* strings instead of importing them in your Webpack config.
|
|
23
|
-
*
|
|
24
|
-
* @type {(string|Function)[]}
|
|
25
|
-
* @default []
|
|
26
|
-
*/
|
|
27
|
-
use: (string | ((string) => string))[]
|
|
28
|
-
/**
|
|
29
|
-
* Add path(s) to the import lookup paths.
|
|
30
|
-
*
|
|
31
|
-
* @type {string[]}
|
|
32
|
-
* @default []
|
|
33
|
-
*/
|
|
34
|
-
include: string[]
|
|
35
|
-
/**
|
|
36
|
-
* Import the specified Stylus files/paths.
|
|
37
|
-
*
|
|
38
|
-
* @type {string[]}
|
|
39
|
-
* @default []
|
|
40
|
-
*/
|
|
41
|
-
import: string[]
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Define Stylus variables or functions.
|
|
45
|
-
*
|
|
46
|
-
* @type {Array|Object}
|
|
47
|
-
* @default {}
|
|
48
|
-
*/
|
|
49
|
-
// Array is the recommended syntax: [key, value, raw]
|
|
50
|
-
define: Array<any> | Record<string, any>
|
|
51
|
-
// Object is deprecated syntax (there is no possibility to specify "raw')
|
|
52
|
-
// define: {
|
|
53
|
-
// $development: process.env.NODE_ENV === 'development',
|
|
54
|
-
// rawVar: 42,
|
|
55
|
-
// },
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Include regular CSS on @import.
|
|
59
|
-
*
|
|
60
|
-
* @type {boolean}
|
|
61
|
-
* @default false
|
|
62
|
-
*/
|
|
63
|
-
includeCSS: boolean
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Resolve relative url()'s inside imported files.
|
|
67
|
-
*
|
|
68
|
-
* @see https://stylus-lang.com/docs/js.html#stylusresolveroptions
|
|
69
|
-
*
|
|
70
|
-
* @type {boolean|Object}
|
|
71
|
-
* @default { nocheck: true }
|
|
72
|
-
*/
|
|
73
|
-
// resolveURL: boolean | Record<string, any>,
|
|
74
|
-
// resolveURL: { nocheck: true },
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Emits comments in the generated CSS indicating the corresponding Stylus line.
|
|
78
|
-
*
|
|
79
|
-
* @see https://stylus-lang.com/docs/executable.html
|
|
80
|
-
*
|
|
81
|
-
* @type {boolean}
|
|
82
|
-
* @default false
|
|
83
|
-
*/
|
|
84
|
-
lineNumbers: boolean
|
|
85
|
-
/**
|
|
86
|
-
* @type {boolean}
|
|
87
|
-
* @default false
|
|
88
|
-
*/
|
|
89
|
-
disableCache: boolean
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Move @import and @charset to the top.
|
|
93
|
-
*
|
|
94
|
-
* @see https://stylus-lang.com/docs/executable.html
|
|
95
|
-
*
|
|
96
|
-
* @type {boolean}
|
|
97
|
-
* @default false
|
|
98
|
-
*/
|
|
99
|
-
hoistAtrules: boolean
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface Config {
|
|
103
|
-
alias?: Record<string, string>
|
|
104
|
-
options: RenderOptions
|
|
105
|
-
additionalData?: string | ((key: string) => string)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export const defaultOptions = {
|
|
6
|
+
export const defaultOptions: StylusRenderOptions = {
|
|
109
7
|
use: [],
|
|
110
8
|
include: [],
|
|
111
9
|
import: [],
|
|
@@ -117,7 +15,7 @@ export const defaultOptions = {
|
|
|
117
15
|
disableCache: false
|
|
118
16
|
}
|
|
119
17
|
|
|
120
|
-
function renderToCSS (src, filename, options = {} as
|
|
18
|
+
function renderToCSS (src, filename, options = {} as StylusRenderOptions) {
|
|
121
19
|
const stylusOptions = { filename, ...options }
|
|
122
20
|
const styl = stylus(src, stylusOptions)
|
|
123
21
|
|
|
@@ -212,7 +110,7 @@ function renderToCSS (src, filename, options = {} as RenderOptions) {
|
|
|
212
110
|
})
|
|
213
111
|
}
|
|
214
112
|
|
|
215
|
-
export default function transform (src: string, filename: string, config:
|
|
113
|
+
export default function transform (src: string, filename: string, config: StylusConfig) {
|
|
216
114
|
const additionalData = getAdditionalData(src, config.additionalData)
|
|
217
115
|
const data = insertBefore(src, additionalData)
|
|
218
116
|
|
package/src/types/index.ts
CHANGED
|
@@ -1,14 +1,223 @@
|
|
|
1
|
+
import { ProcessOptions } from 'postcss'
|
|
2
|
+
import { Options } from 'sass'
|
|
3
|
+
|
|
4
|
+
// sass
|
|
5
|
+
// https://github.com/sass/node-sass#options
|
|
6
|
+
export interface SassConfig {
|
|
7
|
+
sass?: SassGlobalConfig
|
|
8
|
+
alias?: Record<string, string>
|
|
9
|
+
options: Options
|
|
10
|
+
additionalData?: string | ((key: string) => string)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SassGlobalConfig {
|
|
14
|
+
resource?: string | string[]
|
|
15
|
+
projectDirectory?: string
|
|
16
|
+
data?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// postcss
|
|
20
|
+
export interface PostcssConfig {
|
|
21
|
+
options: ProcessOptions // https://github.com/postcss/postcss#options
|
|
22
|
+
scalable: boolean // 控制是否对 css value 进行 scalePx2dp 转换
|
|
23
|
+
pxtransform?: {
|
|
24
|
+
enable: boolean
|
|
25
|
+
config: any
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// less
|
|
30
|
+
interface SourceMapOption {
|
|
31
|
+
sourceMapURL?: string
|
|
32
|
+
sourceMapBasepath?: string
|
|
33
|
+
sourceMapRootpath?: string
|
|
34
|
+
outputSourceFiles?: boolean
|
|
35
|
+
sourceMapFileInline?: boolean
|
|
36
|
+
}
|
|
37
|
+
// http://lesscss.org/usage/#less-options
|
|
38
|
+
export interface LessOptions {
|
|
39
|
+
sourceMap?: SourceMapOption
|
|
40
|
+
/** Filename of the main file to be passed to less.render() */
|
|
41
|
+
filename?: string
|
|
42
|
+
/** The locations for less looking for files in @import rules */
|
|
43
|
+
paths?: string[]
|
|
44
|
+
/** True, if run the less parser and just reports errors without any output. */
|
|
45
|
+
lint?: boolean
|
|
46
|
+
/** Pre-load global Less.js plugins */
|
|
47
|
+
plugins?: Plugin[]
|
|
48
|
+
/** @deprecated If true, compress using less built-in compression. */
|
|
49
|
+
compress?: boolean
|
|
50
|
+
strictImports?: boolean
|
|
51
|
+
/** If true, allow imports from insecure https hosts. */
|
|
52
|
+
insecure?: boolean
|
|
53
|
+
depends?: boolean
|
|
54
|
+
maxLineLen?: number
|
|
55
|
+
/** @deprecated If false, No color in compiling. */
|
|
56
|
+
color?: boolean
|
|
57
|
+
/** @deprecated False by default. */
|
|
58
|
+
ieCompat?: boolean
|
|
59
|
+
/** @deprecated If true, enable evaluation of JavaScript inline in `.less` files. */
|
|
60
|
+
javascriptEnabled?: boolean
|
|
61
|
+
/** Whether output file information and line numbers in compiled CSS code. */
|
|
62
|
+
dumpLineNumbers?: 'comment' | string
|
|
63
|
+
/** Add a path to every generated import and url in output css files. */
|
|
64
|
+
rootpath?: string
|
|
65
|
+
/** Math mode options for avoiding symbol conficts on math expressions. */
|
|
66
|
+
math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number
|
|
67
|
+
/** If true, stops any warnings from being shown. */
|
|
68
|
+
silent?: boolean
|
|
69
|
+
/** Without this option, Less attempts to guess at the output unit when it does maths. */
|
|
70
|
+
strictUnits?: boolean
|
|
71
|
+
/** Defines a variable that can be referenced by the file. */
|
|
72
|
+
globalVars?: {
|
|
73
|
+
[key: string]: string
|
|
74
|
+
}
|
|
75
|
+
/** Puts Var declaration at the end of base file. */
|
|
76
|
+
modifyVars?: {
|
|
77
|
+
[key: string]: string
|
|
78
|
+
}
|
|
79
|
+
/** Read files synchronously in Node.js */
|
|
80
|
+
syncImport?: boolean
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface LessConfig {
|
|
84
|
+
alias?: Record<string, string>
|
|
85
|
+
options: LessOptions
|
|
86
|
+
additionalData?: string | ((key: string) => string)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// stylus
|
|
90
|
+
class Evaluator { }
|
|
91
|
+
|
|
92
|
+
interface Dictionary<T> {
|
|
93
|
+
[key: string]: T
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// https://stylus-lang.com/docs/js.html
|
|
97
|
+
export interface StylusRenderOptions {
|
|
98
|
+
globals?: Dictionary<any>
|
|
99
|
+
functions?: Dictionary<any>
|
|
100
|
+
imports?: string[]
|
|
101
|
+
paths?: string[]
|
|
102
|
+
filename?: string
|
|
103
|
+
Evaluator?: typeof Evaluator
|
|
104
|
+
/**
|
|
105
|
+
* Specify Stylus plugins to use. Plugins may be passed as
|
|
106
|
+
* strings instead of importing them in your Webpack config.
|
|
107
|
+
*
|
|
108
|
+
* @type {(string|Function)[]}
|
|
109
|
+
* @default []
|
|
110
|
+
*/
|
|
111
|
+
use: (string | ((string) => string))[]
|
|
112
|
+
/**
|
|
113
|
+
* Add path(s) to the import lookup paths.
|
|
114
|
+
*
|
|
115
|
+
* @type {string[]}
|
|
116
|
+
* @default []
|
|
117
|
+
*/
|
|
118
|
+
include: string[]
|
|
119
|
+
/**
|
|
120
|
+
* Import the specified Stylus files/paths.
|
|
121
|
+
*
|
|
122
|
+
* @type {string[]}
|
|
123
|
+
* @default []
|
|
124
|
+
*/
|
|
125
|
+
import: string[]
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Define Stylus variables or functions.
|
|
129
|
+
*
|
|
130
|
+
* @type {Array|Object}
|
|
131
|
+
* @default {}
|
|
132
|
+
*/
|
|
133
|
+
// Array is the recommended syntax: [key, value, raw]
|
|
134
|
+
define: Array<any> | Record<string, any>
|
|
135
|
+
// Object is deprecated syntax (there is no possibility to specify "raw')
|
|
136
|
+
// define: {
|
|
137
|
+
// $development: process.env.NODE_ENV === 'development',
|
|
138
|
+
// rawVar: 42,
|
|
139
|
+
// },
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Include regular CSS on @import.
|
|
143
|
+
*
|
|
144
|
+
* @type {boolean}
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
includeCSS: boolean
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Resolve relative url()'s inside imported files.
|
|
151
|
+
*
|
|
152
|
+
* @see https://stylus-lang.com/docs/js.html#stylusresolveroptions
|
|
153
|
+
*
|
|
154
|
+
* @type {boolean|Object}
|
|
155
|
+
* @default { nocheck: true }
|
|
156
|
+
*/
|
|
157
|
+
// resolveURL: boolean | Record<string, any>,
|
|
158
|
+
// resolveURL: { nocheck: true },
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Emits comments in the generated CSS indicating the corresponding Stylus line.
|
|
162
|
+
*
|
|
163
|
+
* @see https://stylus-lang.com/docs/executable.html
|
|
164
|
+
*
|
|
165
|
+
* @type {boolean}
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
168
|
+
lineNumbers: boolean
|
|
169
|
+
/**
|
|
170
|
+
* @type {boolean}
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
173
|
+
disableCache: boolean
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Move @import and @charset to the top.
|
|
177
|
+
*
|
|
178
|
+
* @see https://stylus-lang.com/docs/executable.html
|
|
179
|
+
*
|
|
180
|
+
* @type {boolean}
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
183
|
+
hoistAtrules: boolean
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface StylusConfig {
|
|
187
|
+
alias?: Record<string, string>
|
|
188
|
+
options: StylusRenderOptions
|
|
189
|
+
additionalData?: string | ((key: string) => string)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// config
|
|
193
|
+
interface RNConfig {
|
|
194
|
+
postcss?: PostcssConfig
|
|
195
|
+
sass?: SassConfig
|
|
196
|
+
less?: LessConfig
|
|
197
|
+
stylus?: StylusConfig
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface Config {
|
|
201
|
+
designWidth?: number
|
|
202
|
+
deviceRatio?: { [key: number]: number }
|
|
203
|
+
sass?: SassGlobalConfig
|
|
204
|
+
alias?: Record<string, string>
|
|
205
|
+
rn: RNConfig
|
|
206
|
+
}
|
|
207
|
+
|
|
1
208
|
export interface TransformOptions {
|
|
2
|
-
dev
|
|
3
|
-
hot
|
|
4
|
-
minify
|
|
209
|
+
dev?: boolean
|
|
210
|
+
hot?: boolean
|
|
211
|
+
minify?: boolean
|
|
5
212
|
platform: 'android' | 'ios'
|
|
6
|
-
projectRoot
|
|
7
|
-
publicPath
|
|
8
|
-
customTransformOptions
|
|
213
|
+
projectRoot?: string
|
|
214
|
+
publicPath?: string
|
|
215
|
+
customTransformOptions?: any
|
|
216
|
+
config: Config
|
|
9
217
|
}
|
|
10
218
|
|
|
11
|
-
|
|
219
|
+
// resolve
|
|
220
|
+
export const enum ResolveLogLevelEnum {
|
|
12
221
|
ERROR = 'error',
|
|
13
222
|
WARNING = 'warning',
|
|
14
223
|
}
|
|
@@ -17,11 +226,12 @@ export interface ResolveStyleOptions {
|
|
|
17
226
|
basedir: string
|
|
18
227
|
platform: 'android' | 'ios'
|
|
19
228
|
paths?: string[]
|
|
20
|
-
logLevel?:
|
|
229
|
+
logLevel?: ResolveLogLevelEnum
|
|
21
230
|
defaultExt?: string
|
|
22
231
|
alias?: Record<string, string>
|
|
23
232
|
}
|
|
24
233
|
|
|
234
|
+
// postcss result
|
|
25
235
|
export interface RenderResult {
|
|
26
236
|
css: string | Buffer
|
|
27
237
|
map?: string | Buffer
|
package/src/utils/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as path from 'path'
|
|
|
4
4
|
import * as resolve from 'resolve'
|
|
5
5
|
import nodeModulesPaths from 'resolve/lib/node-modules-paths'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { ResolveLogLevelEnum, ResolveStyleOptions } from '../types'
|
|
8
8
|
|
|
9
9
|
export function insertBefore (source?: string, additional?: string) {
|
|
10
10
|
if (!source && !additional) {
|
|
@@ -63,7 +63,7 @@ export function resolveStyle (id: string, opts: ResolveStyleOptions) {
|
|
|
63
63
|
paths = [],
|
|
64
64
|
alias = {},
|
|
65
65
|
defaultExt = '',
|
|
66
|
-
logLevel =
|
|
66
|
+
logLevel = ResolveLogLevelEnum.ERROR
|
|
67
67
|
} = opts
|
|
68
68
|
id = id.trim()
|
|
69
69
|
Object.keys(alias).forEach(key => {
|
|
@@ -108,10 +108,10 @@ export function resolveStyle (id: string, opts: ResolveStyleOptions) {
|
|
|
108
108
|
${includePaths.join(',\n ')}
|
|
109
109
|
]
|
|
110
110
|
`
|
|
111
|
-
if (logLevel ===
|
|
111
|
+
if (logLevel === ResolveLogLevelEnum.ERROR) {
|
|
112
112
|
throw new Error(levelMessage)
|
|
113
113
|
}
|
|
114
|
-
if (logLevel ===
|
|
114
|
+
if (logLevel === ResolveLogLevelEnum.WARNING) {
|
|
115
115
|
printLog(processTypeEnum.WARNING, levelMessage)
|
|
116
116
|
return id
|
|
117
117
|
}
|
package/src/utils/lessImport.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Less from 'less'
|
|
2
2
|
|
|
3
3
|
import { resolveStyle } from './index'
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class LessImporter extends Less.FileManager {
|
|
6
6
|
platform: 'android' | 'ios'
|
|
7
7
|
alias: Record<string, string> = {}
|
|
8
8
|
|
|
@@ -41,7 +41,7 @@ class Importer extends less.FileManager {
|
|
|
41
41
|
function makeLessImport (options) {
|
|
42
42
|
return {
|
|
43
43
|
install: (_, pluginManager) => {
|
|
44
|
-
pluginManager.addFileManager(new
|
|
44
|
+
pluginManager.addFileManager(new LessImporter(options))
|
|
45
45
|
},
|
|
46
46
|
minVersion: [2, 7, 1]
|
|
47
47
|
}
|