@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/keyword.js
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return createLessProxy(jessKeyword, cache, (prop, target) => {
|
|
9
|
-
const keyword = target;
|
|
10
|
-
// Map 'type' property
|
|
11
|
-
if (prop === 'type') {
|
|
12
|
-
return mapJessTypeToLessType(keyword.type);
|
|
13
|
-
}
|
|
14
|
-
// Map 'typeIndex'
|
|
15
|
-
if (prop === 'typeIndex') {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
// Map 'value' property
|
|
19
|
-
if (prop === 'value') {
|
|
20
|
-
return keyword.value;
|
|
21
|
-
}
|
|
22
|
-
// Map 'accept' method for visitor traversal
|
|
23
|
-
if (prop === 'accept') {
|
|
24
|
-
return function (visitor) {
|
|
25
|
-
const lessKeyword = transformKeywordToLess(keyword, cache);
|
|
26
|
-
const result = visitor.visit(lessKeyword);
|
|
27
|
-
if (result !== lessKeyword) {
|
|
28
|
-
return fromLessNode(result, { cache });
|
|
29
|
-
}
|
|
30
|
-
return keyword;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
1
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
2
|
+
export const transformKeywordToLess = createFromAdapter({
|
|
3
|
+
fields: {
|
|
4
|
+
value: k => k.value
|
|
5
|
+
},
|
|
6
|
+
accept: selfVisitAccept()
|
|
7
|
+
});
|
|
36
8
|
//# sourceMappingURL=keyword.js.map
|
package/lib/nodes/keyword.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../src/nodes/keyword.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../src/nodes/keyword.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAU;IAC/D,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK;KACpB;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/list.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess List to a Less-compatible Value
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformListToLess(jessList: List, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformListToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/list.js
CHANGED
|
@@ -1,150 +1,61 @@
|
|
|
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
|
-
// Map 'type' property
|
|
12
|
-
if (prop === 'type') {
|
|
13
|
-
return mapJessTypeToLessType(list.type);
|
|
14
|
-
}
|
|
15
|
-
// Map 'typeIndex'
|
|
16
|
-
if (prop === 'typeIndex') {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
// Get filtered, converted value array (used by multiple properties)
|
|
20
|
-
const getFilteredValue = () => {
|
|
21
|
-
const value = list.value;
|
|
22
|
-
if (Array.isArray(value)) {
|
|
23
|
-
return value
|
|
24
|
-
.map((item) => {
|
|
25
|
-
if (!item) {
|
|
26
|
-
return null; // Mark null/undefined for filtering
|
|
27
|
-
}
|
|
28
|
-
if (item instanceof Node) {
|
|
29
|
-
const lessItem = toLessNode(item, { cache });
|
|
30
|
-
// If toLessNode returns undefined, skip it
|
|
31
|
-
return lessItem || null;
|
|
32
|
-
}
|
|
33
|
-
return item;
|
|
34
|
-
})
|
|
35
|
-
.filter((item) => item !== undefined && item !== null); // Filter out undefined/null
|
|
4
|
+
function getFilteredValue(list, cache) {
|
|
5
|
+
const data = list.get('value');
|
|
6
|
+
if (Array.isArray(data)) {
|
|
7
|
+
return data
|
|
8
|
+
.map((item) => {
|
|
9
|
+
if (!item) {
|
|
10
|
+
return null;
|
|
36
11
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (value && typeof value === 'object' && 'type' in value) {
|
|
40
|
-
// Check if it's a Node-like object
|
|
41
|
-
const lessValue = toLessNode(value, { cache });
|
|
42
|
-
return lessValue ? [lessValue] : [];
|
|
43
|
-
}
|
|
44
|
-
return [value];
|
|
12
|
+
if (item instanceof Node) {
|
|
13
|
+
return toLessNode(item, { cache }) || null;
|
|
45
14
|
}
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (prop === 'length') {
|
|
55
|
-
return getFilteredValue().length;
|
|
15
|
+
return item;
|
|
16
|
+
})
|
|
17
|
+
.filter((item) => item != null);
|
|
18
|
+
}
|
|
19
|
+
if (data != null) {
|
|
20
|
+
if (data && typeof data === 'object' && 'type' in data) {
|
|
21
|
+
const lessValue = toLessNode(data, { cache });
|
|
22
|
+
return lessValue ? [lessValue] : [];
|
|
56
23
|
}
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
return [data];
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
export const transformListToLess = createFromAdapter({
|
|
29
|
+
fields: {
|
|
30
|
+
value: (l, cache) => getFilteredValue(l, cache),
|
|
31
|
+
length: (l, cache) => getFilteredValue(l, cache).length
|
|
32
|
+
},
|
|
33
|
+
dynamicField: (prop, l, cache) => {
|
|
59
34
|
if (typeof prop === 'string' && /^\d+$/.test(prop)) {
|
|
60
|
-
|
|
61
|
-
const index = parseInt(prop, 10);
|
|
62
|
-
return filtered[index];
|
|
35
|
+
return getFilteredValue(l, cache)[parseInt(prop, 10)];
|
|
63
36
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
.map((item) => {
|
|
76
|
-
if (item instanceof Node) {
|
|
77
|
-
const lessItem = toLessNode(item, { cache });
|
|
78
|
-
return lessItem || null;
|
|
79
|
-
}
|
|
80
|
-
return item;
|
|
81
|
-
})
|
|
82
|
-
.filter((item) => item !== undefined && item !== null);
|
|
83
|
-
// Handle reverse order if needed
|
|
84
|
-
const itemsToIterate = reverse ? [...filteredValue].reverse() : filteredValue;
|
|
85
|
-
for (const item of itemsToIterate) {
|
|
86
|
-
if (item === undefined || item === null) {
|
|
87
|
-
continue; // Skip undefined/null items (shouldn't happen after filtering, but be safe)
|
|
88
|
-
}
|
|
89
|
-
if (item instanceof Node || (item && typeof item === 'object' && 'type' in item)) {
|
|
90
|
-
// It's a node (either Jess node or Less proxy)
|
|
91
|
-
if (includePrePost) {
|
|
92
|
-
// For now, just yield the item (pre/post handling can be added later if needed)
|
|
93
|
-
yield item;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
yield item;
|
|
97
|
-
}
|
|
98
|
-
if (deep && item instanceof Node) {
|
|
99
|
-
// Recursively yield children if deep is true
|
|
100
|
-
if (item.children) {
|
|
101
|
-
yield* item.children(deep, reverse, includePrePost);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
yield item;
|
|
107
|
-
}
|
|
37
|
+
return undefined;
|
|
38
|
+
},
|
|
39
|
+
accept: (list, visitor, cache) => {
|
|
40
|
+
const value = list.get('value');
|
|
41
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
42
|
+
const lessItems = value
|
|
43
|
+
.map((item) => item instanceof Node ? toLessNode(item, { cache }) : item)
|
|
44
|
+
.filter((item) => item != null);
|
|
45
|
+
if (lessItems.length > 0) {
|
|
46
|
+
if (visitor.visitArray) {
|
|
47
|
+
visitor.visitArray(lessItems);
|
|
108
48
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return function (visitor) {
|
|
114
|
-
// Less List's accept() should traverse value items if they exist
|
|
115
|
-
// But we don't call visitor.visit() here to avoid infinite loops
|
|
116
|
-
// The visitor's visit() method will handle traversal
|
|
117
|
-
// If value exists, we should traverse items using visitArray
|
|
118
|
-
const value = list.value;
|
|
119
|
-
if (Array.isArray(value) && value.length > 0) {
|
|
120
|
-
const lessItems = value
|
|
121
|
-
.map((item) => {
|
|
122
|
-
if (item instanceof Node) {
|
|
123
|
-
return toLessNode(item, { cache });
|
|
124
|
-
}
|
|
125
|
-
return item;
|
|
126
|
-
})
|
|
127
|
-
.filter((item) => item !== undefined && item !== null); // Filter out undefined/null
|
|
128
|
-
if (lessItems.length > 0) {
|
|
129
|
-
if (visitor.visitArray) {
|
|
130
|
-
visitor.visitArray(lessItems);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// Fallback: call accept on each item if visitArray not available
|
|
134
|
-
for (const lessItem of lessItems) {
|
|
135
|
-
if (lessItem && lessItem.accept) {
|
|
136
|
-
lessItem.accept(visitor);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
49
|
+
else {
|
|
50
|
+
for (const li of lessItems) {
|
|
51
|
+
if (li?.accept) {
|
|
52
|
+
li.accept(visitor);
|
|
139
53
|
}
|
|
140
54
|
}
|
|
141
55
|
}
|
|
142
|
-
|
|
143
|
-
// Get the proxy from cache or create it
|
|
144
|
-
return cache && cache.has(list) ? cache.get(list) : transformListToLess(list, cache);
|
|
145
|
-
};
|
|
56
|
+
}
|
|
146
57
|
}
|
|
147
|
-
return
|
|
148
|
-
}
|
|
149
|
-
}
|
|
58
|
+
return cache?.has(list) ? cache.get(list) : list;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
150
61
|
//# sourceMappingURL=list.js.map
|
package/lib/nodes/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/nodes/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/nodes/list.ts"],"names":[],"mappings":"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"}
|
package/lib/nodes/mixin.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Mixin to a Less-compatible MixinDefinition
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformMixinToLess(jessMixin: Mixin, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformMixinToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/mixin.js
CHANGED
|
@@ -1,62 +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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
export const transformMixinToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
name: m => m.get('name'),
|
|
7
|
+
params: (m, cache) => {
|
|
8
|
+
const params = m.get('params');
|
|
9
|
+
return params instanceof Node ? toLessNode(params, { cache }) : params;
|
|
10
|
+
},
|
|
11
|
+
rules: (m, cache) => {
|
|
12
|
+
const rules = m.get('rules');
|
|
13
|
+
return rules?.value ? rules.value.map((r) => toLessNode(r, { cache })) : [];
|
|
14
|
+
},
|
|
15
|
+
condition: (m, cache) => {
|
|
16
|
+
const guard = m.get('guard');
|
|
17
|
+
return guard instanceof Node ? toLessNode(guard, { cache }) : guard;
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
// Map 'name' property
|
|
21
|
-
if (prop === 'name') {
|
|
22
|
-
return mixin.value.name;
|
|
23
|
-
}
|
|
24
|
-
// Map 'params' property
|
|
25
|
-
if (prop === 'params') {
|
|
26
|
-
const params = mixin.value.params;
|
|
27
|
-
if (params instanceof Node) {
|
|
28
|
-
return toLessNode(params, { cache });
|
|
29
|
-
}
|
|
30
|
-
return params;
|
|
31
|
-
}
|
|
32
|
-
// Map 'rules' property
|
|
33
|
-
if (prop === 'rules') {
|
|
34
|
-
const rules = mixin.value.rules;
|
|
35
|
-
if (rules && rules.value) {
|
|
36
|
-
return rules.value.map((r) => toLessNode(r, { cache }));
|
|
37
|
-
}
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
// Map 'condition' property (from guard)
|
|
41
|
-
if (prop === 'condition') {
|
|
42
|
-
const guard = mixin.value.guard;
|
|
43
|
-
if (guard instanceof Node) {
|
|
44
|
-
return toLessNode(guard, { cache });
|
|
45
|
-
}
|
|
46
|
-
return guard;
|
|
47
|
-
}
|
|
48
|
-
// Map 'accept' method for visitor traversal
|
|
49
|
-
if (prop === 'accept') {
|
|
50
|
-
return function (visitor) {
|
|
51
|
-
const lessMixin = transformMixinToLess(mixin, cache);
|
|
52
|
-
const result = visitor.visit(lessMixin);
|
|
53
|
-
if (result !== lessMixin) {
|
|
54
|
-
return fromLessNode(result, { cache });
|
|
55
|
-
}
|
|
56
|
-
return mixin;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
19
|
+
},
|
|
20
|
+
accept: selfVisitAccept()
|
|
21
|
+
});
|
|
62
22
|
//# sourceMappingURL=mixin.js.map
|
package/lib/nodes/mixin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixin.js","sourceRoot":"","sources":["../../src/nodes/mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mixin.js","sourceRoot":"","sources":["../../src/nodes/mixin.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,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QACxB,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACnB,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO,MAAM,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACzE,CAAC;QACD,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAO,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,CAAC;QACD,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACtB,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/negative.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Negative to a Less-compatible Negative
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformNegativeToLess(jessNegative: Negative, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformNegativeToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/negative.js
CHANGED
|
@@ -1,42 +1,13 @@
|
|
|
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
|
-
if (prop === 'type') {
|
|
14
|
-
return mapJessTypeToLessType(negative.type);
|
|
15
|
-
}
|
|
16
|
-
// Map 'typeIndex'
|
|
17
|
-
if (prop === 'typeIndex') {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// Map 'value' property
|
|
21
|
-
if (prop === 'value') {
|
|
22
|
-
const value = negative.value;
|
|
23
|
-
if (value instanceof Node) {
|
|
24
|
-
return toLessNode(value, { cache });
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
// Map 'accept' method for visitor traversal
|
|
29
|
-
if (prop === 'accept') {
|
|
30
|
-
return function (visitor) {
|
|
31
|
-
const lessNegative = transformNegativeToLess(negative, cache);
|
|
32
|
-
const result = visitor.visit(lessNegative);
|
|
33
|
-
if (result !== lessNegative) {
|
|
34
|
-
return fromLessNode(result, { cache });
|
|
35
|
-
}
|
|
36
|
-
return negative;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return undefined;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
4
|
+
export const transformNegativeToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
value: (n, cache) => {
|
|
7
|
+
const value = n.get('value');
|
|
8
|
+
return value instanceof Node ? toLessNode(value, { cache }) : value;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
accept: selfVisitAccept()
|
|
12
|
+
});
|
|
42
13
|
//# sourceMappingURL=negative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"negative.js","sourceRoot":"","sources":["../../src/nodes/negative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"negative.js","sourceRoot":"","sources":["../../src/nodes/negative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAW;IACjE,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/operation.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Operation to a Less-compatible Operation
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformOperationToLess(jessOperation: Operation, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformOperationToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/operation.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
|
-
|
|
13
|
-
if (prop === 'type') {
|
|
14
|
-
return mapJessTypeToLessType(op.type);
|
|
15
|
-
}
|
|
16
|
-
// Map 'typeIndex'
|
|
17
|
-
if (prop === 'typeIndex') {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// Map 'op' property (operator)
|
|
21
|
-
if (prop === 'op') {
|
|
22
|
-
// Jess stores as [left, op, right], extract op
|
|
23
|
-
const value = op.value;
|
|
24
|
-
if (Array.isArray(value) && value.length >= 2) {
|
|
25
|
-
return value[1]; // Operator is in the middle
|
|
4
|
+
export const transformOperationToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
op: o => o.get('operator') || '',
|
|
7
|
+
operands: (o, cache) => {
|
|
8
|
+
const operands = [];
|
|
9
|
+
const left = o.get('left');
|
|
10
|
+
const right = o.get('right');
|
|
11
|
+
if (left instanceof Node) {
|
|
12
|
+
operands.push(left);
|
|
26
13
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Map 'operands' property
|
|
30
|
-
if (prop === 'operands') {
|
|
31
|
-
const value = op.value;
|
|
32
|
-
if (Array.isArray(value)) {
|
|
33
|
-
// Extract left and right operands, skip operator
|
|
34
|
-
const operands = [];
|
|
35
|
-
for (let i = 0; i < value.length; i++) {
|
|
36
|
-
const item = value[i];
|
|
37
|
-
if (item instanceof Node) {
|
|
38
|
-
operands.push(item);
|
|
39
|
-
}
|
|
40
|
-
else if (typeof item === 'string' && i === 1) {
|
|
41
|
-
// Skip operator
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return operands.map(o => toLessNode(o, { cache }));
|
|
14
|
+
if (right instanceof Node) {
|
|
15
|
+
operands.push(right);
|
|
46
16
|
}
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
// Map 'accept' method for visitor traversal
|
|
50
|
-
if (prop === 'accept') {
|
|
51
|
-
return function (visitor) {
|
|
52
|
-
const lessOp = transformOperationToLess(op, cache);
|
|
53
|
-
const result = visitor.visit(lessOp);
|
|
54
|
-
if (result !== lessOp) {
|
|
55
|
-
return fromLessNode(result, { cache });
|
|
56
|
-
}
|
|
57
|
-
return op;
|
|
58
|
-
};
|
|
17
|
+
return operands.map(n => toLessNode(n, { cache }));
|
|
59
18
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
19
|
+
},
|
|
20
|
+
accept: selfVisitAccept()
|
|
21
|
+
});
|
|
63
22
|
//# sourceMappingURL=operation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/nodes/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,IAAI,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/nodes/operation.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,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAW,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC3B,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;gBACzB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;gBAC1B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACrD,CAAC;KACF;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/paren.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Paren to a Less-compatible Paren
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformParenToLess(jessParen: Paren, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformParenToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/paren.js
CHANGED
|
@@ -1,42 +1,13 @@
|
|
|
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
|
-
if (prop === 'type') {
|
|
14
|
-
return mapJessTypeToLessType(paren.type);
|
|
15
|
-
}
|
|
16
|
-
// Map 'typeIndex'
|
|
17
|
-
if (prop === 'typeIndex') {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// Map 'value' property
|
|
21
|
-
if (prop === 'value') {
|
|
22
|
-
const value = paren.value;
|
|
23
|
-
if (value instanceof Node) {
|
|
24
|
-
return toLessNode(value, { cache });
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
// Map 'accept' method for visitor traversal
|
|
29
|
-
if (prop === 'accept') {
|
|
30
|
-
return function (visitor) {
|
|
31
|
-
const lessParen = transformParenToLess(paren, cache);
|
|
32
|
-
const result = visitor.visit(lessParen);
|
|
33
|
-
if (result !== lessParen) {
|
|
34
|
-
return fromLessNode(result, { cache });
|
|
35
|
-
}
|
|
36
|
-
return paren;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return undefined;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
4
|
+
export const transformParenToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
value: (p, cache) => {
|
|
7
|
+
const value = p.get('value');
|
|
8
|
+
return value instanceof Node ? toLessNode(value, { cache }) : value;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
accept: selfVisitAccept()
|
|
12
|
+
});
|
|
42
13
|
//# sourceMappingURL=paren.js.map
|