@jesscss/plugin-less-compat 2.0.0-alpha.5 → 2.0.0-alpha.6
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/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/nodes/at-rule.d.ts +2 -6
- package/lib/nodes/at-rule.js +17 -68
- package/lib/nodes/at-rule.js.map +1 -1
- package/lib/nodes/attribute-selector.d.ts +2 -6
- package/lib/nodes/attribute-selector.js +14 -50
- package/lib/nodes/attribute-selector.js.map +1 -1
- package/lib/nodes/call.d.ts +2 -6
- package/lib/nodes/call.js +22 -78
- package/lib/nodes/call.js.map +1 -1
- package/lib/nodes/color.d.ts +1 -6
- package/lib/nodes/color.js +11 -45
- package/lib/nodes/color.js.map +1 -1
- package/lib/nodes/combinator.d.ts +1 -6
- package/lib/nodes/combinator.js +6 -33
- package/lib/nodes/combinator.js.map +1 -1
- package/lib/nodes/comment.d.ts +1 -6
- package/lib/nodes/comment.js +8 -40
- package/lib/nodes/comment.js.map +1 -1
- package/lib/nodes/condition.d.ts +2 -6
- package/lib/nodes/condition.js +16 -57
- package/lib/nodes/condition.js.map +1 -1
- package/lib/nodes/declaration.d.ts +2 -6
- package/lib/nodes/declaration.js +32 -75
- package/lib/nodes/declaration.js.map +1 -1
- package/lib/nodes/dimension.d.ts +1 -6
- package/lib/nodes/dimension.js +7 -45
- package/lib/nodes/dimension.js.map +1 -1
- package/lib/nodes/expression.d.ts +2 -6
- package/lib/nodes/expression.js +8 -36
- package/lib/nodes/expression.js.map +1 -1
- package/lib/nodes/extend.d.ts +1 -6
- package/lib/nodes/extend.js +15 -54
- package/lib/nodes/extend.js.map +1 -1
- package/lib/nodes/import.d.ts +2 -6
- package/lib/nodes/import.js +16 -57
- package/lib/nodes/import.js.map +1 -1
- package/lib/nodes/keyword.d.ts +1 -6
- package/lib/nodes/keyword.js +7 -35
- package/lib/nodes/keyword.js.map +1 -1
- package/lib/nodes/list.d.ts +2 -6
- package/lib/nodes/list.js +48 -137
- package/lib/nodes/list.js.map +1 -1
- package/lib/nodes/mixin.d.ts +2 -6
- package/lib/nodes/mixin.js +18 -58
- package/lib/nodes/mixin.js.map +1 -1
- package/lib/nodes/negative.d.ts +2 -6
- package/lib/nodes/negative.js +10 -39
- package/lib/nodes/negative.js.map +1 -1
- package/lib/nodes/operation.d.ts +2 -6
- package/lib/nodes/operation.js +16 -57
- package/lib/nodes/operation.js.map +1 -1
- package/lib/nodes/paren.d.ts +2 -6
- package/lib/nodes/paren.js +10 -39
- package/lib/nodes/paren.js.map +1 -1
- package/lib/nodes/quoted.d.ts +1 -6
- package/lib/nodes/quoted.js +12 -46
- package/lib/nodes/quoted.js.map +1 -1
- package/lib/nodes/reference.d.ts +1 -9
- package/lib/nodes/reference.js +33 -69
- package/lib/nodes/reference.js.map +1 -1
- package/lib/nodes/ruleset.d.ts +2 -6
- package/lib/nodes/ruleset.js +48 -89
- package/lib/nodes/ruleset.js.map +1 -1
- package/lib/nodes/selector.d.ts +2 -7
- package/lib/nodes/selector.js +112 -180
- package/lib/nodes/selector.js.map +1 -1
- package/lib/nodes/sequence.d.ts +2 -9
- package/lib/nodes/sequence.js +44 -63
- package/lib/nodes/sequence.js.map +1 -1
- package/lib/nodes/url.d.ts +1 -6
- package/lib/nodes/url.js +10 -39
- package/lib/nodes/url.js.map +1 -1
- package/lib/nodes/var-declaration.d.ts +2 -6
- package/lib/nodes/var-declaration.js +17 -56
- package/lib/nodes/var-declaration.js.map +1 -1
- package/lib/plugin.js +2 -3
- package/lib/plugin.js.map +1 -1
- package/lib/transform/adapter.d.ts +33 -0
- package/lib/transform/adapter.js +111 -0
- package/lib/transform/adapter.js.map +1 -0
- package/lib/transform/proxy.d.ts +2 -2
- package/lib/transform/to-less.js +14 -12
- package/lib/transform/to-less.js.map +1 -1
- package/package.json +16 -12
package/lib/nodes/condition.js
CHANGED
|
@@ -1,60 +1,19 @@
|
|
|
1
1
|
import { Node } from '@jesscss/core';
|
|
2
|
-
import {
|
|
2
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
3
3
|
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
// Map 'op' property (operator)
|
|
21
|
-
// Condition.value is a tuple: [left, op?, right?]
|
|
22
|
-
if (prop === 'op') {
|
|
23
|
-
const [, op] = condition.value;
|
|
24
|
-
return op || '';
|
|
25
|
-
}
|
|
26
|
-
// Map 'lvalue' property (left value)
|
|
27
|
-
if (prop === 'lvalue') {
|
|
28
|
-
const [left] = condition.value;
|
|
29
|
-
if (left instanceof Node) {
|
|
30
|
-
return toLessNode(left, { cache });
|
|
31
|
-
}
|
|
32
|
-
return left;
|
|
33
|
-
}
|
|
34
|
-
// Map 'rvalue' property (right value)
|
|
35
|
-
if (prop === 'rvalue') {
|
|
36
|
-
const [, , right] = condition.value;
|
|
37
|
-
if (right instanceof Node) {
|
|
38
|
-
return toLessNode(right, { cache });
|
|
39
|
-
}
|
|
40
|
-
return right;
|
|
41
|
-
}
|
|
42
|
-
// Map 'negate' property
|
|
43
|
-
if (prop === 'negate') {
|
|
44
|
-
return condition.options?.negate === true;
|
|
45
|
-
}
|
|
46
|
-
// Map 'accept' method for visitor traversal
|
|
47
|
-
if (prop === 'accept') {
|
|
48
|
-
return function (visitor) {
|
|
49
|
-
const lessCondition = transformConditionToLess(condition, cache);
|
|
50
|
-
const result = visitor.visit(lessCondition);
|
|
51
|
-
if (result !== lessCondition) {
|
|
52
|
-
return fromLessNode(result, { cache });
|
|
53
|
-
}
|
|
54
|
-
return condition;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return undefined;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
4
|
+
export const transformConditionToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
op: c => c.get('operator') || '',
|
|
7
|
+
lvalue: (c, cache) => {
|
|
8
|
+
const left = c.get('left');
|
|
9
|
+
return left instanceof Node ? toLessNode(left, { cache }) : left;
|
|
10
|
+
},
|
|
11
|
+
rvalue: (c, cache) => {
|
|
12
|
+
const right = c.get('right');
|
|
13
|
+
return right instanceof Node ? toLessNode(right, { cache }) : right;
|
|
14
|
+
},
|
|
15
|
+
negate: c => c.get('negate') === true
|
|
16
|
+
},
|
|
17
|
+
accept: selfVisitAccept()
|
|
18
|
+
});
|
|
60
19
|
//# sourceMappingURL=condition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../src/nodes/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,IAAI,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../src/nodes/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,IAAI,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAY;IACnE,MAAM,EAAE;QACN,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE;QAChC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACnB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC3B,OAAO,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnE,CAAC;QACD,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACnB,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACtE,CAAC;QACD,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,IAAI;KACtC;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Declaration to a Less-compatible Declaration
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformDeclarationToLess(jessDeclaration: Declaration, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformDeclarationToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/declaration.js
CHANGED
|
@@ -1,81 +1,38 @@
|
|
|
1
1
|
import { Node } from '@jesscss/core';
|
|
2
|
-
import {
|
|
2
|
+
import { createFromAdapter } from '../transform/adapter.js';
|
|
3
3
|
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
export const transformDeclarationToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
name: d => d.get('name'),
|
|
7
|
+
value: (d, cache) => {
|
|
8
|
+
const value = d.get('value');
|
|
9
|
+
return value instanceof Node ? toLessNode(value, { cache }) : value;
|
|
10
|
+
},
|
|
11
|
+
important: d => d.get('important') || false,
|
|
12
|
+
variable: d => d.options?.assign !== undefined,
|
|
13
|
+
merge: () => false
|
|
14
|
+
},
|
|
15
|
+
accept: (decl, visitor, cache) => {
|
|
16
|
+
const value = decl.get('value');
|
|
17
|
+
if (value instanceof Node) {
|
|
18
|
+
const lessValue = toLessNode(value, { cache });
|
|
19
|
+
if (lessValue?.accept) {
|
|
20
|
+
lessValue.accept(visitor);
|
|
21
|
+
}
|
|
22
|
+
else if (lessValue && visitor.visitArray) {
|
|
23
|
+
visitor.visitArray([lessValue]);
|
|
24
|
+
}
|
|
25
|
+
else if (lessValue && visitor.visit) {
|
|
26
|
+
visitor.visit(lessValue);
|
|
25
27
|
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
// Map 'important' property
|
|
29
|
-
if (prop === 'important') {
|
|
30
|
-
return decl.value.important || false;
|
|
31
|
-
}
|
|
32
|
-
// Map 'variable' property (from options.assign)
|
|
33
|
-
// Jess uses AssignmentType enum, Less uses boolean
|
|
34
|
-
if (prop === 'variable') {
|
|
35
|
-
return decl.options?.assign !== undefined;
|
|
36
|
-
}
|
|
37
|
-
// Map 'merge' property (Less uses this for merging declarations)
|
|
38
|
-
if (prop === 'merge') {
|
|
39
|
-
return false; // Default, can be set by Less visitors
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return function (visitor) {
|
|
47
|
-
// Declaration's accept only traverses its value (children)
|
|
48
|
-
// Base Node.accept() pattern: visitor.visit(this.value)
|
|
49
|
-
const value = decl.value.value;
|
|
50
|
-
if (value instanceof Node) {
|
|
51
|
-
const lessValue = toLessNode(value, { cache });
|
|
52
|
-
if (lessValue && lessValue.accept) {
|
|
53
|
-
lessValue.accept(visitor);
|
|
54
|
-
}
|
|
55
|
-
else if (lessValue && visitor.visitArray) {
|
|
56
|
-
visitor.visitArray([lessValue]);
|
|
57
|
-
}
|
|
58
|
-
else if (lessValue && visitor.visit) {
|
|
59
|
-
visitor.visit(lessValue);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else if (value && Array.isArray(value)) {
|
|
63
|
-
// If value is an array, use visitArray
|
|
64
|
-
const lessValues = value.map((v) => {
|
|
65
|
-
if (v instanceof Node) {
|
|
66
|
-
return toLessNode(v, { cache });
|
|
67
|
-
}
|
|
68
|
-
return v;
|
|
69
|
-
});
|
|
70
|
-
if (visitor.visitArray) {
|
|
71
|
-
visitor.visitArray(lessValues);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Return the declaration (accept doesn't return a replacement node)
|
|
75
|
-
return decl;
|
|
76
|
-
};
|
|
29
|
+
else if (value && Array.isArray(value)) {
|
|
30
|
+
const lessValues = value.map((v) => v instanceof Node ? toLessNode(v, { cache }) : v);
|
|
31
|
+
if (visitor.visitArray) {
|
|
32
|
+
visitor.visitArray(lessValues);
|
|
33
|
+
}
|
|
77
34
|
}
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
}
|
|
35
|
+
return decl;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
81
38
|
//# sourceMappingURL=declaration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../src/nodes/declaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../src/nodes/declaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAc;IACvE,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QACxB,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACtE,CAAC;QACD,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK;QAC3C,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS;QAC9C,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK;KACnB;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC/C,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;gBACtB,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC;iBAAM,IAAI,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC3C,OAAO,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YAClC,CAAC;iBAAM,IAAI,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,MAAM,UAAU,GAAI,KAAe,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CACjD,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CACjD,CAAC;YACF,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
|
package/lib/nodes/dimension.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Dimension or Num to a Less-compatible Dimension
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformDimensionToLess(jessDimension: Dimension | Num, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformDimensionToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/dimension.js
CHANGED
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
import { Num } from '@jesscss/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const dim = target;
|
|
10
|
-
// Map 'type' property
|
|
11
|
-
if (prop === 'type') {
|
|
12
|
-
return mapJessTypeToLessType(dim.type);
|
|
13
|
-
}
|
|
14
|
-
// Map 'typeIndex'
|
|
15
|
-
if (prop === 'typeIndex') {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
// Map 'value' property
|
|
19
|
-
if (prop === 'value') {
|
|
20
|
-
if (dim instanceof Num) {
|
|
21
|
-
return dim.value;
|
|
22
|
-
}
|
|
23
|
-
return dim.value.number;
|
|
24
|
-
}
|
|
25
|
-
// Map 'unit' property
|
|
26
|
-
if (prop === 'unit') {
|
|
27
|
-
if (dim instanceof Num) {
|
|
28
|
-
// Num has no unit, return empty string or undefined
|
|
29
|
-
return '';
|
|
30
|
-
}
|
|
31
|
-
// Dimension has unit as string, Less expects Unit node
|
|
32
|
-
// For now, return the string and let Less handle conversion
|
|
33
|
-
return dim.value.unit || '';
|
|
34
|
-
}
|
|
35
|
-
// Map 'accept' method for visitor traversal
|
|
36
|
-
if (prop === 'accept') {
|
|
37
|
-
return function (visitor) {
|
|
38
|
-
// Less Dimension has no children, so accept() should just return the dimension
|
|
39
|
-
// The visitor's visit() method will handle traversal
|
|
40
|
-
// We don't call visitor.visit() here to avoid infinite loops
|
|
41
|
-
return dim;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return undefined;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
2
|
+
import { createFromAdapter } from '../transform/adapter.js';
|
|
3
|
+
export const transformDimensionToLess = createFromAdapter({
|
|
4
|
+
fields: {
|
|
5
|
+
value: d => d.number,
|
|
6
|
+
unit: d => d instanceof Num ? '' : d.unit || ''
|
|
7
|
+
}
|
|
8
|
+
});
|
|
47
9
|
//# sourceMappingURL=dimension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimension.js","sourceRoot":"","sources":["../../src/nodes/dimension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dimension.js","sourceRoot":"","sources":["../../src/nodes/dimension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAkB;IACzE,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;QACpB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,CAAe,CAAC,IAAI,IAAI,EAAE;KAC/D;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Expression to a Less-compatible Expression
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformExpressionToLess(jessExpression: Expression, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformExpressionToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/expression.js
CHANGED
|
@@ -1,44 +1,16 @@
|
|
|
1
1
|
import { Node } from '@jesscss/core';
|
|
2
|
-
import {
|
|
2
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
3
3
|
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export function transformExpressionToLess(jessExpression, cache) {
|
|
10
|
-
return createLessProxy(jessExpression, cache, (prop, target) => {
|
|
11
|
-
const expr = target;
|
|
12
|
-
// Map 'type' property
|
|
13
|
-
if (prop === 'type') {
|
|
14
|
-
return mapJessTypeToLessType(expr.type);
|
|
15
|
-
}
|
|
16
|
-
// Map 'typeIndex'
|
|
17
|
-
if (prop === 'typeIndex') {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// Map 'value' property (Less expects array)
|
|
21
|
-
if (prop === 'value') {
|
|
22
|
-
const value = expr.value;
|
|
4
|
+
export const transformExpressionToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
value: (e, cache) => {
|
|
7
|
+
const value = e.get('value');
|
|
23
8
|
if (value instanceof Node) {
|
|
24
|
-
// Single node - wrap in array
|
|
25
9
|
return [toLessNode(value, { cache })];
|
|
26
10
|
}
|
|
27
|
-
// Expression.value is always a Node, so this shouldn't happen
|
|
28
11
|
return [value];
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const lessExpr = transformExpressionToLess(expr, cache);
|
|
34
|
-
const result = visitor.visit(lessExpr);
|
|
35
|
-
if (result !== lessExpr) {
|
|
36
|
-
return fromLessNode(result, { cache });
|
|
37
|
-
}
|
|
38
|
-
return expr;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
13
|
+
},
|
|
14
|
+
accept: selfVisitAccept()
|
|
15
|
+
});
|
|
44
16
|
//# sourceMappingURL=expression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../src/nodes/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../src/nodes/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAa;IACrE,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;gBAC1B,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;KACF;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/extend.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Extend to a Less-compatible Extend
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformExtendToLess(jessExtend: Extend, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformExtendToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/extend.js
CHANGED
|
@@ -1,57 +1,18 @@
|
|
|
1
|
-
import { Selector } from '@jesscss/core';
|
|
2
|
-
import {
|
|
1
|
+
import { ExtendFlag, Selector } from '@jesscss/core';
|
|
2
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
3
3
|
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return mapJessTypeToLessType(extend.type);
|
|
4
|
+
export const transformExtendToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
selector: (e, cache) => {
|
|
7
|
+
const selector = e.get('selector');
|
|
8
|
+
return selector instanceof Selector ? toLessNode(selector, { cache }) : selector;
|
|
9
|
+
},
|
|
10
|
+
option: e => e.get('flag') === ExtendFlag.Exact ? 'exact' : 'all',
|
|
11
|
+
index: (e) => {
|
|
12
|
+
const loc = e.location;
|
|
13
|
+
return loc.length ? loc[0] : undefined;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
// Map 'selector' property
|
|
21
|
-
if (prop === 'selector') {
|
|
22
|
-
const selector = extend.value.selector;
|
|
23
|
-
if (selector instanceof Selector) {
|
|
24
|
-
return toLessNode(selector, { cache });
|
|
25
|
-
}
|
|
26
|
-
return selector;
|
|
27
|
-
}
|
|
28
|
-
// Map 'option' property (Less uses this for extend options)
|
|
29
|
-
// Jess uses 'flag' (ExtendFlag), Less uses 'option' string
|
|
30
|
-
if (prop === 'option') {
|
|
31
|
-
const flag = extend.value.flag;
|
|
32
|
-
// ExtendFlag.All = 0 (default), ExtendFlag.Exact = 1
|
|
33
|
-
return flag === 1 ? 'exact' : 'all';
|
|
34
|
-
}
|
|
35
|
-
// Map 'index' property
|
|
36
|
-
if (prop === 'index') {
|
|
37
|
-
const loc = extend.location;
|
|
38
|
-
if (Array.isArray(loc) || !loc) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return loc.index;
|
|
42
|
-
}
|
|
43
|
-
// Map 'accept' method for visitor traversal
|
|
44
|
-
if (prop === 'accept') {
|
|
45
|
-
return function (visitor) {
|
|
46
|
-
const lessExtend = transformExtendToLess(extend, cache);
|
|
47
|
-
const result = visitor.visit(lessExtend);
|
|
48
|
-
if (result !== lessExtend) {
|
|
49
|
-
return fromLessNode(result, { cache });
|
|
50
|
-
}
|
|
51
|
-
return extend;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
15
|
+
},
|
|
16
|
+
accept: selfVisitAccept()
|
|
17
|
+
});
|
|
57
18
|
//# sourceMappingURL=extend.js.map
|
package/lib/nodes/extend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../src/nodes/extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../src/nodes/extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAS;IAC7D,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,OAAO,QAAQ,YAAY,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnF,CAAC;QACD,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;QACjE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC;YACvB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzC,CAAC;KACF;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/import.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess StyleImport to a Less-compatible Import
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformImportToLess(jessImport: StyleImport, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformImportToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/import.js
CHANGED
|
@@ -1,63 +1,22 @@
|
|
|
1
1
|
import { Node } from '@jesscss/core';
|
|
2
|
-
import {
|
|
2
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
3
3
|
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Map 'type' property
|
|
13
|
-
if (prop === 'type') {
|
|
14
|
-
return mapJessTypeToLessType(imp.type);
|
|
15
|
-
}
|
|
16
|
-
// Map 'typeIndex'
|
|
17
|
-
if (prop === 'typeIndex') {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// Map 'path' property
|
|
21
|
-
if (prop === 'path') {
|
|
22
|
-
const path = imp.value.path;
|
|
23
|
-
if (path instanceof Node) {
|
|
24
|
-
return toLessNode(path, { cache });
|
|
25
|
-
}
|
|
26
|
-
return path;
|
|
27
|
-
}
|
|
28
|
-
// Map 'options' property (Less uses this for import options)
|
|
29
|
-
// Jess stores import options in options.importOptions
|
|
30
|
-
if (prop === 'options') {
|
|
31
|
-
return imp.options?.importOptions || {};
|
|
32
|
-
}
|
|
33
|
-
// Map 'currentFileInfo' property
|
|
34
|
-
if (prop === 'currentFileInfo') {
|
|
4
|
+
export const transformImportToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
path: (imp, cache) => {
|
|
7
|
+
const path = imp.get('path');
|
|
8
|
+
return path instanceof Node ? toLessNode(path, { cache }) : path;
|
|
9
|
+
},
|
|
10
|
+
options: imp => imp.options?.importOptions || {},
|
|
11
|
+
currentFileInfo: (imp) => {
|
|
35
12
|
const loc = imp.location;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return loc || {};
|
|
40
|
-
}
|
|
41
|
-
// Map 'index' property
|
|
42
|
-
if (prop === 'index') {
|
|
13
|
+
return loc.length ? loc : {};
|
|
14
|
+
},
|
|
15
|
+
index: (imp) => {
|
|
43
16
|
const loc = imp.location;
|
|
44
|
-
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
return loc.index;
|
|
48
|
-
}
|
|
49
|
-
// Map 'accept' method for visitor traversal
|
|
50
|
-
if (prop === 'accept') {
|
|
51
|
-
return function (visitor) {
|
|
52
|
-
const lessImport = transformImportToLess(imp, cache);
|
|
53
|
-
const result = visitor.visit(lessImport);
|
|
54
|
-
if (result !== lessImport) {
|
|
55
|
-
return fromLessNode(result, { cache });
|
|
56
|
-
}
|
|
57
|
-
return imp;
|
|
58
|
-
};
|
|
17
|
+
return loc.length ? loc[0] : undefined;
|
|
59
18
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
19
|
+
},
|
|
20
|
+
accept: selfVisitAccept()
|
|
21
|
+
});
|
|
63
22
|
//# sourceMappingURL=import.js.map
|
package/lib/nodes/import.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/nodes/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/nodes/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAc;IAClE,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACnB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnE,CAAC;QACD,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,IAAI,EAAE;QAChD,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC;YACzB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,CAAC;QACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACb,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC;YACzB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzC,CAAC;KACF;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/keyword.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Keyword to a Less-compatible Keyword
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformKeywordToLess(jessKeyword: Keyword, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformKeywordToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|