@jesscss/plugin-less-compat 2.0.0-alpha.4 → 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/paren.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paren.js","sourceRoot":"","sources":["../../src/nodes/paren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"paren.js","sourceRoot":"","sources":["../../src/nodes/paren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAQ;IAC3D,MAAM,EAAE;QACN,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;KACF;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/quoted.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Quoted to a Less-compatible Quoted
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformQuotedToLess(jessQuoted: Quoted, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformQuotedToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/quoted.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
import { Any, Interpolated } from '@jesscss/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export function transformQuotedToLess(jessQuoted, cache) {
|
|
9
|
-
return createLessProxy(jessQuoted, cache, (prop, target) => {
|
|
10
|
-
const quoted = target;
|
|
11
|
-
// Map 'type' property
|
|
12
|
-
if (prop === 'type') {
|
|
13
|
-
return mapJessTypeToLessType(quoted.type);
|
|
14
|
-
}
|
|
15
|
-
// Map 'typeIndex'
|
|
16
|
-
if (prop === 'typeIndex') {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
// Map 'value' property
|
|
20
|
-
if (prop === 'value') {
|
|
21
|
-
const value = quoted.value;
|
|
2
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
3
|
+
export const transformQuotedToLess = createFromAdapter({
|
|
4
|
+
fields: {
|
|
5
|
+
value: (q) => {
|
|
6
|
+
const value = q.get('value');
|
|
22
7
|
if (typeof value === 'string') {
|
|
23
8
|
return value;
|
|
24
9
|
}
|
|
@@ -26,32 +11,13 @@ export function transformQuotedToLess(jessQuoted, cache) {
|
|
|
26
11
|
return value.value;
|
|
27
12
|
}
|
|
28
13
|
if (value instanceof Interpolated) {
|
|
29
|
-
|
|
30
|
-
// Less handles interpolation differently, so we convert to string
|
|
31
|
-
return String(value.value);
|
|
14
|
+
return String(value.get('source'));
|
|
32
15
|
}
|
|
33
16
|
return String(value);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (prop === 'escaped') {
|
|
41
|
-
return quoted.options?.escaped === true;
|
|
42
|
-
}
|
|
43
|
-
// Map 'accept' method for visitor traversal
|
|
44
|
-
if (prop === 'accept') {
|
|
45
|
-
return function (visitor) {
|
|
46
|
-
const lessQuoted = transformQuotedToLess(quoted, cache);
|
|
47
|
-
const result = visitor.visit(lessQuoted);
|
|
48
|
-
if (result !== lessQuoted) {
|
|
49
|
-
return fromLessNode(result, { cache });
|
|
50
|
-
}
|
|
51
|
-
return quoted;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
17
|
+
},
|
|
18
|
+
quote: q => q.quote || '"',
|
|
19
|
+
escaped: q => q.escaped === true
|
|
20
|
+
},
|
|
21
|
+
accept: selfVisitAccept()
|
|
22
|
+
});
|
|
57
23
|
//# sourceMappingURL=quoted.js.map
|
package/lib/nodes/quoted.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quoted.js","sourceRoot":"","sources":["../../src/nodes/quoted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,GAAG,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"quoted.js","sourceRoot":"","sources":["../../src/nodes/quoted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,GAAG,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAS;IAC7D,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC,KAAK,CAAC;YACrB,CAAC;YACD,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;gBAClC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG;QAC1B,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI;KACjC;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/reference.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Reference to a Less-compatible Variable, Property, or VariableCall
|
|
5
|
-
*
|
|
6
|
-
* Jess has unified Reference with options.type
|
|
7
|
-
* Less has separate Variable, Property, and VariableCall nodes
|
|
8
|
-
*/
|
|
9
|
-
export declare function transformReferenceToLess(jessReference: Reference, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformReferenceToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/reference.js
CHANGED
|
@@ -1,80 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export function transformReferenceToLess(jessReference, cache) {
|
|
9
|
-
const refType = jessReference.options?.type || 'variable';
|
|
10
|
-
// Determine Less node type based on Jess reference type
|
|
11
|
-
let lessType;
|
|
12
|
-
if (refType === 'property') {
|
|
13
|
-
lessType = 'Property';
|
|
14
|
-
}
|
|
15
|
-
else if (refType === 'function' || refType === 'mixin') {
|
|
16
|
-
lessType = 'VariableCall';
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
lessType = 'Variable'; // Default to Variable
|
|
20
|
-
}
|
|
21
|
-
return createLessProxy(jessReference, cache, (prop, target) => {
|
|
22
|
-
const ref = target;
|
|
23
|
-
// Map 'type' property
|
|
24
|
-
if (prop === 'type') {
|
|
25
|
-
return lessType;
|
|
1
|
+
import { createFromAdapter } from '../transform/adapter.js';
|
|
2
|
+
export const transformReferenceToLess = createFromAdapter({
|
|
3
|
+
lessType: (ref) => {
|
|
4
|
+
const refType = ref.options?.type || 'variable';
|
|
5
|
+
if (refType === 'property') {
|
|
6
|
+
return 'Property';
|
|
26
7
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return undefined;
|
|
8
|
+
if (refType === 'function' || refType === 'mixin') {
|
|
9
|
+
return 'VariableCall';
|
|
30
10
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
11
|
+
return 'Variable';
|
|
12
|
+
},
|
|
13
|
+
fields: {
|
|
14
|
+
name: (ref) => {
|
|
15
|
+
const refType = ref.options?.type || 'variable';
|
|
16
|
+
const lessType = refType === 'property'
|
|
17
|
+
? 'Property'
|
|
18
|
+
: (refType === 'function' || refType === 'mixin')
|
|
19
|
+
? 'VariableCall'
|
|
20
|
+
: 'Variable';
|
|
21
|
+
const key = ref.get('key');
|
|
36
22
|
if (typeof key === 'string') {
|
|
37
|
-
// Less variables include the leading "@"
|
|
38
23
|
if (lessType === 'Variable' && !key.startsWith('@')) {
|
|
39
24
|
return `@${key}`;
|
|
40
25
|
}
|
|
41
26
|
return key;
|
|
42
27
|
}
|
|
43
|
-
if (typeof key === 'number') {
|
|
44
|
-
return String(key);
|
|
45
|
-
}
|
|
46
|
-
// For other types, convert to string representation
|
|
47
28
|
return String(key);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// Less VariableCall structure might need special handling
|
|
54
|
-
return ref;
|
|
55
|
-
}
|
|
56
|
-
// Map 'index' property
|
|
57
|
-
if (prop === 'index') {
|
|
58
|
-
const loc = ref.location;
|
|
59
|
-
if (Array.isArray(loc) || !loc) {
|
|
60
|
-
return undefined;
|
|
29
|
+
},
|
|
30
|
+
value: (ref) => {
|
|
31
|
+
const refType = ref.options?.type || 'variable';
|
|
32
|
+
if (refType === 'function' || refType === 'mixin') {
|
|
33
|
+
return ref;
|
|
61
34
|
}
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (prop === 'accept') {
|
|
72
|
-
return function (visitor) {
|
|
73
|
-
// Reference nodes don't have children to traverse
|
|
74
|
-
// The visitor.visit() was already called by our plugin wrapper
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return undefined;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
35
|
+
return undefined;
|
|
36
|
+
},
|
|
37
|
+
index: (ref) => {
|
|
38
|
+
const loc = ref.location;
|
|
39
|
+
return loc.length ? loc[0] : undefined;
|
|
40
|
+
},
|
|
41
|
+
currentFileInfo: ref => ref.location || {}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
80
44
|
//# sourceMappingURL=reference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/nodes/reference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/nodes/reference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAY;IACnE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;QAChB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,UAAU,CAAC;QAChD,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;YAC3B,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,IAAI,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;YAClD,OAAO,cAAc,CAAC;QACxB,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM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/ruleset.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Ruleset to a Less-compatible Ruleset
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformRulesetToLess(jessRuleset: Ruleset, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformRulesetToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/ruleset.js
CHANGED
|
@@ -1,108 +1,67 @@
|
|
|
1
1
|
import { Nil, SelectorList } 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
|
-
export function transformRulesetToLess(jessRuleset, cache) {
|
|
9
|
-
return createLessProxy(jessRuleset, cache, (prop, target) => {
|
|
10
|
-
const ruleset = target;
|
|
11
|
-
// Map 'type' property
|
|
12
|
-
if (prop === 'type') {
|
|
13
|
-
return mapJessTypeToLessType(ruleset.type);
|
|
14
|
-
}
|
|
15
|
-
// typeIndex is handled automatically by the base proxy handler
|
|
16
|
-
// Map 'selectors' property (Less expects array, Jess has single Selector | Nil)
|
|
17
|
-
if (prop === 'selectors') {
|
|
18
|
-
const selector = ruleset.value.selector;
|
|
19
|
-
// Handle Nil selector
|
|
4
|
+
export const transformRulesetToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
selectors: (rs, cache) => {
|
|
7
|
+
const selector = rs.get('selector');
|
|
20
8
|
if (selector instanceof Nil) {
|
|
21
9
|
return [];
|
|
22
10
|
}
|
|
23
|
-
// Handle SelectorList - convert to array
|
|
24
11
|
if (selector instanceof SelectorList) {
|
|
25
|
-
return selector.value.map((s) => toLessNode(s, { cache }));
|
|
12
|
+
return selector.get('value').map((s) => toLessNode(s, { cache }));
|
|
26
13
|
}
|
|
27
|
-
// Single selector - wrap in array
|
|
28
14
|
return [toLessNode(selector, { cache })];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const rules = ruleset.value.rules;
|
|
33
|
-
// Rules has a value array of nodes
|
|
15
|
+
},
|
|
16
|
+
rules: (rs, cache) => {
|
|
17
|
+
const rules = rs.get('rules');
|
|
34
18
|
return rules.value.map((r) => toLessNode(r, { cache }));
|
|
35
19
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const lessSelectors = selector.value.map((s) => {
|
|
52
|
-
const lessSel = toLessNode(s, { cache });
|
|
53
|
-
// Ensure we have a Less proxy, not a Jess node
|
|
54
|
-
return lessSel;
|
|
55
|
-
});
|
|
56
|
-
if (visitor.visitArray) {
|
|
57
|
-
visitor.visitArray(lessSelectors);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Fallback: call accept on each selector if visitArray not available
|
|
61
|
-
for (const lessSel of lessSelectors) {
|
|
62
|
-
if (lessSel && lessSel.accept) {
|
|
63
|
-
lessSel.accept(visitor);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// Single selector - convert to Less format BEFORE calling visitArray
|
|
70
|
-
const lessSelector = toLessNode(selector, { cache });
|
|
71
|
-
if (lessSelector) {
|
|
72
|
-
if (visitor.visitArray) {
|
|
73
|
-
visitor.visitArray([lessSelector]);
|
|
74
|
-
}
|
|
75
|
-
else if (lessSelector.accept) {
|
|
76
|
-
lessSelector.accept(visitor);
|
|
77
|
-
}
|
|
20
|
+
},
|
|
21
|
+
accept: (ruleset, visitor, cache) => {
|
|
22
|
+
const selector = ruleset.get('selector');
|
|
23
|
+
const rules = ruleset.get('rules');
|
|
24
|
+
// Traverse selectors
|
|
25
|
+
if (selector && !(selector instanceof Nil)) {
|
|
26
|
+
if (selector instanceof SelectorList) {
|
|
27
|
+
const lessSelectors = selector.get('value').map((s) => toLessNode(s, { cache }));
|
|
28
|
+
if (visitor.visitArray) {
|
|
29
|
+
visitor.visitArray(lessSelectors);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
for (const ls of lessSelectors) {
|
|
33
|
+
if (ls?.accept) {
|
|
34
|
+
ls.accept(visitor);
|
|
78
35
|
}
|
|
79
36
|
}
|
|
80
37
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const lessRules = rules.value.map((r) => {
|
|
86
|
-
const lessRule = toLessNode(r, { cache });
|
|
87
|
-
// Ensure we have a Less proxy, not a Jess node
|
|
88
|
-
return lessRule;
|
|
89
|
-
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const lessSelector = toLessNode(selector, { cache });
|
|
41
|
+
if (lessSelector) {
|
|
90
42
|
if (visitor.visitArray) {
|
|
91
|
-
visitor.visitArray(
|
|
43
|
+
visitor.visitArray([lessSelector]);
|
|
92
44
|
}
|
|
93
|
-
else {
|
|
94
|
-
|
|
95
|
-
for (const lessRule of lessRules) {
|
|
96
|
-
if (lessRule && lessRule.accept) {
|
|
97
|
-
lessRule.accept(visitor);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
45
|
+
else if (lessSelector.accept) {
|
|
46
|
+
lessSelector.accept(visitor);
|
|
100
47
|
}
|
|
101
48
|
}
|
|
102
|
-
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Traverse rules
|
|
52
|
+
if (rules?.value?.length > 0) {
|
|
53
|
+
const lessRules = rules.value.map((r) => toLessNode(r, { cache }));
|
|
54
|
+
if (visitor.visitArray) {
|
|
55
|
+
visitor.visitArray(lessRules);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
for (const lr of lessRules) {
|
|
59
|
+
if (lr?.accept) {
|
|
60
|
+
lr.accept(visitor);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
103
64
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
108
67
|
//# sourceMappingURL=ruleset.js.map
|
package/lib/nodes/ruleset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruleset.js","sourceRoot":"","sources":["../../src/nodes/ruleset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,GAAG,EAAY,YAAY,EAAQ,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ruleset.js","sourceRoot":"","sources":["../../src/nodes/ruleset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,GAAG,EAAY,YAAY,EAAQ,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAU;IAC/D,MAAM,EAAE;QACN,SAAS,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;YACvB,MAAM,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACpC,IAAI,QAAQ,YAAY,GAAG,EAAE,CAAC;gBAC5B,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,IAAI,QAAQ,YAAY,YAAY,EAAE,CAAC;gBACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YAC9E,C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C,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBACrD,IAAI,YAAY,EAAE,CAAC;oBACjB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;wBACvB,OAAO,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;oBACrC,CAAC;yBAAM,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;wBAC/B,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,iBAAiB;QACjB,IAAI,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAO,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YACzE,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;oBAC3B,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC;wBACf,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
package/lib/nodes/selector.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
2
|
import type { LessNode } from '../types.js';
|
|
3
|
-
|
|
4
|
-
* Transform a Jess Selector to a Less-compatible Selector
|
|
5
|
-
*
|
|
6
|
-
* Less Selector is an array of Element nodes
|
|
7
|
-
*/
|
|
8
|
-
export declare function transformSelectorToLess(jessSelector: Selector | SelectorList, cache?: WeakMap<any, any>): LessNode;
|
|
3
|
+
export declare const transformSelectorToLess: (jessNode: Node, cache?: WeakMap<any, any>) => LessNode;
|