@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/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* Enables Less.js plugins and visitors to work with Jess AST.
|
|
6
6
|
*/
|
|
7
7
|
export { LessCompatPlugin, default as lessCompatPlugin, type LessCompatPluginOptions } from './plugin.js';
|
|
8
|
+
export { default } from './plugin.js';
|
|
8
9
|
export * from './transform/index.js';
|
|
9
10
|
export { isLessPlugin, isJessPlugin, filterPlugins } from './plugin-utils.js';
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Enables Less.js plugins and visitors to work with Jess AST.
|
|
6
6
|
*/
|
|
7
7
|
export { LessCompatPlugin, default as lessCompatPlugin } from './plugin.js';
|
|
8
|
+
export { default } from './plugin.js';
|
|
8
9
|
export * from './transform/index.js';
|
|
9
10
|
export { isLessPlugin, isJessPlugin, filterPlugins } from './plugin-utils.js';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,gBAAgB,EAAgC,MAAM,aAAa,CAAC;AAC1G,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,gBAAgB,EAAgC,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/nodes/at-rule.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess AtRule to a Less-compatible AtRule
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformAtRuleToLess(jessAtRule: AtRule, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformAtRuleToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/at-rule.js
CHANGED
|
@@ -1,72 +1,21 @@
|
|
|
1
1
|
import { Node } from '@jesscss/core';
|
|
2
|
-
import {
|
|
2
|
+
import { createFromAdapter, childrenAccept } from '../transform/adapter.js';
|
|
3
3
|
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// For Less.js v2 compatibility, we can return "Directive" if needed
|
|
15
|
-
// But by default, map to "AtRule" (modern)
|
|
16
|
-
return mapJessTypeToLessType(atRule.type);
|
|
4
|
+
export const transformAtRuleToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
name: a => a.get('name'),
|
|
7
|
+
value: (a, cache) => {
|
|
8
|
+
const prelude = a.get('prelude');
|
|
9
|
+
return prelude instanceof Node ? toLessNode(prelude, { cache }) : prelude;
|
|
10
|
+
},
|
|
11
|
+
rules: (a, cache) => {
|
|
12
|
+
const rules = a.get('rules');
|
|
13
|
+
return rules ? rules.value.map((r) => toLessNode(r, { cache })) : [];
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return atRule.value.name;
|
|
25
|
-
}
|
|
26
|
-
// Map 'value' property (Less expects Value node or array)
|
|
27
|
-
// Jess uses 'prelude' instead of 'value'
|
|
28
|
-
if (prop === 'value') {
|
|
29
|
-
const prelude = atRule.value.prelude;
|
|
30
|
-
if (prelude instanceof Node) {
|
|
31
|
-
return toLessNode(prelude, { cache });
|
|
32
|
-
}
|
|
33
|
-
return prelude;
|
|
34
|
-
}
|
|
35
|
-
// Map 'rules' property (for @media, @keyframes, etc.)
|
|
36
|
-
if (prop === 'rules') {
|
|
37
|
-
const rules = atRule.value.rules;
|
|
38
|
-
if (rules) {
|
|
39
|
-
return rules.value.map((r) => toLessNode(r, { cache }));
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
// Map 'accept' method for visitor traversal
|
|
44
|
-
// AtRule's accept should ONLY traverse children (rules), NOT call visitor methods on itself
|
|
45
|
-
// The visitor's visit() method already called visitAtRule() or visitDirective() before calling accept()
|
|
46
|
-
if (prop === 'accept') {
|
|
47
|
-
return function (visitor) {
|
|
48
|
-
// AtRule's accept only traverses its rules (children)
|
|
49
|
-
// Less.js AtRule.accept() pattern: visitor.visitArray(this.rules)
|
|
50
|
-
const rules = atRule.value.rules;
|
|
51
|
-
if (rules && rules.value && rules.value.length > 0) {
|
|
52
|
-
const lessRules = rules.value.map((r) => toLessNode(r, { cache }));
|
|
53
|
-
if (visitor.visitArray) {
|
|
54
|
-
visitor.visitArray(lessRules);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Fallback: call accept on each rule
|
|
58
|
-
for (const lessRule of lessRules) {
|
|
59
|
-
if (lessRule && lessRule.accept) {
|
|
60
|
-
lessRule.accept(visitor);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Return the atRule (accept doesn't return a replacement node)
|
|
66
|
-
return atRule;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
15
|
+
},
|
|
16
|
+
accept: childrenAccept((a) => {
|
|
17
|
+
const rules = a.get('rules');
|
|
18
|
+
return rules?.value?.length ? [...rules.value] : [];
|
|
19
|
+
})
|
|
20
|
+
});
|
|
72
21
|
//# sourceMappingURL=at-rule.js.map
|
package/lib/nodes/at-rule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"at-rule.js","sourceRoot":"","sources":["../../src/nodes/at-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"at-rule.js","sourceRoot":"","sources":["../../src/nodes/at-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAS;IAC7D,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,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACjC,OAAO,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC5E,CAAC;QACD,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,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;QAC7E,CAAC;KACF;IACD,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,CAAC,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess AttributeSelector to a Less-compatible Attribute
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformAttributeSelectorToLess(jessAttr: AttributeSelector, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformAttributeSelectorToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
|
@@ -1,54 +1,18 @@
|
|
|
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
|
-
return mapJessTypeToLessType(attr.type);
|
|
4
|
+
export const transformAttributeSelectorToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
key: (a, cache) => {
|
|
7
|
+
const name = a.get('name');
|
|
8
|
+
return name instanceof Node ? toLessNode(name, { cache }) : name;
|
|
9
|
+
},
|
|
10
|
+
op: a => a.get('op') || '',
|
|
11
|
+
value: (a, cache) => {
|
|
12
|
+
const value = a.get('value');
|
|
13
|
+
return value instanceof Node ? toLessNode(value, { cache }) : value;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
// Map 'key' property (Less uses 'key', Jess uses 'name')
|
|
21
|
-
if (prop === 'key') {
|
|
22
|
-
const name = attr.value.name;
|
|
23
|
-
if (name instanceof Node) {
|
|
24
|
-
return toLessNode(name, { cache });
|
|
25
|
-
}
|
|
26
|
-
return name;
|
|
27
|
-
}
|
|
28
|
-
// Map 'op' property (operator)
|
|
29
|
-
if (prop === 'op') {
|
|
30
|
-
return attr.value.op || '';
|
|
31
|
-
}
|
|
32
|
-
// Map 'value' property
|
|
33
|
-
if (prop === 'value') {
|
|
34
|
-
const value = attr.value.value;
|
|
35
|
-
if (value instanceof Node) {
|
|
36
|
-
return toLessNode(value, { cache });
|
|
37
|
-
}
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
// Map 'accept' method for visitor traversal
|
|
41
|
-
if (prop === 'accept') {
|
|
42
|
-
return function (visitor) {
|
|
43
|
-
const lessAttr = transformAttributeSelectorToLess(attr, cache);
|
|
44
|
-
const result = visitor.visit(lessAttr);
|
|
45
|
-
if (result !== lessAttr) {
|
|
46
|
-
return fromLessNode(result, { cache });
|
|
47
|
-
}
|
|
48
|
-
return attr;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return undefined;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
15
|
+
},
|
|
16
|
+
accept: selfVisitAccept()
|
|
17
|
+
});
|
|
54
18
|
//# sourceMappingURL=attribute-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute-selector.js","sourceRoot":"","sources":["../../src/nodes/attribute-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"attribute-selector.js","sourceRoot":"","sources":["../../src/nodes/attribute-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,gCAAgC,GAAG,iBAAiB,CAAoB;IACnF,MAAM,EAAE;QACN,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAChB,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,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;QAC1B,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/call.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Call to a Less-compatible Call or MixinCall
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformCallToLess(jessCall: Call, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformCallToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/call.js
CHANGED
|
@@ -1,83 +1,27 @@
|
|
|
1
1
|
import { Node } from '@jesscss/core';
|
|
2
|
-
import {
|
|
2
|
+
import { createFromAdapter, childrenAccept } 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
|
-
// Less distinguishes between Call and MixinCall, but Jess uses Call for both
|
|
13
|
-
// We'll default to Call, but this could be enhanced to detect mixin calls
|
|
14
|
-
if (prop === 'type') {
|
|
15
|
-
return mapJessTypeToLessType(call.type);
|
|
16
|
-
}
|
|
17
|
-
// Map 'typeIndex'
|
|
18
|
-
if (prop === 'typeIndex') {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
// Map 'name' property
|
|
22
|
-
if (prop === 'name') {
|
|
23
|
-
return call.value.name;
|
|
24
|
-
}
|
|
25
|
-
// Map 'args' property
|
|
26
|
-
if (prop === 'args') {
|
|
27
|
-
const args = call.value.args;
|
|
28
|
-
if (args) {
|
|
29
|
-
return args.value.map((arg) => {
|
|
30
|
-
if (arg instanceof Node) {
|
|
31
|
-
return toLessNode(arg, { cache });
|
|
32
|
-
}
|
|
33
|
-
return arg;
|
|
34
|
-
});
|
|
4
|
+
export const transformCallToLess = createFromAdapter({
|
|
5
|
+
fields: {
|
|
6
|
+
name: c => c.get('name'),
|
|
7
|
+
args: (c, cache) => {
|
|
8
|
+
const args = c.get('args');
|
|
9
|
+
if (!args) {
|
|
10
|
+
return [];
|
|
35
11
|
}
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (Array.isArray(loc) || !loc) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
return loc.index;
|
|
45
|
-
}
|
|
46
|
-
// Map 'accept' method for visitor traversal
|
|
47
|
-
if (prop === 'accept') {
|
|
48
|
-
return function (visitor) {
|
|
49
|
-
// Less Call's accept() should traverse args if they exist
|
|
50
|
-
// But we don't call visitor.visit() here to avoid infinite loops
|
|
51
|
-
// The visitor's visit() method will handle traversal
|
|
52
|
-
// If args exist, we should traverse them using visitArray
|
|
53
|
-
const args = call.value.args;
|
|
54
|
-
if (args && args.value.length > 0) {
|
|
55
|
-
const lessArgs = args.value
|
|
56
|
-
.map((arg) => {
|
|
57
|
-
if (arg instanceof Node) {
|
|
58
|
-
return toLessNode(arg, { cache });
|
|
59
|
-
}
|
|
60
|
-
return arg;
|
|
61
|
-
})
|
|
62
|
-
.filter((arg) => arg !== undefined && arg !== null); // Filter out undefined/null
|
|
63
|
-
if (lessArgs.length > 0) {
|
|
64
|
-
if (visitor.visitArray) {
|
|
65
|
-
visitor.visitArray(lessArgs);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
// Fallback: call accept on each arg if visitArray not available
|
|
69
|
-
for (const lessArg of lessArgs) {
|
|
70
|
-
if (lessArg && lessArg.accept) {
|
|
71
|
-
lessArg.accept(visitor);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return call;
|
|
78
|
-
};
|
|
12
|
+
return args.get('value').map((arg) => arg instanceof Node ? toLessNode(arg, { cache }) : arg);
|
|
13
|
+
},
|
|
14
|
+
index: (c) => {
|
|
15
|
+
const loc = c.location;
|
|
16
|
+
return loc.length ? loc[0] : undefined;
|
|
79
17
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
18
|
+
},
|
|
19
|
+
accept: childrenAccept((c) => {
|
|
20
|
+
const args = c.get('args');
|
|
21
|
+
const argsValue = args?.get('value');
|
|
22
|
+
return argsValue?.length
|
|
23
|
+
? argsValue.filter((a) => a instanceof Node)
|
|
24
|
+
: [];
|
|
25
|
+
})
|
|
26
|
+
});
|
|
83
27
|
//# sourceMappingURL=call.js.map
|
package/lib/nodes/call.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/nodes/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/nodes/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAO;IACzD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QACxB,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACjB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CACxC,GAAG,YAAY,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CACvD,CAAC;QACJ,CAAC;QACD,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,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,SAAS,EAAE,MAAM;YACtB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,YAAY,IAAI,CAAW;YAC3D,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CAAC;CACH,CAAC,CAAC"}
|
package/lib/nodes/color.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Color to a Less-compatible Color
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformColorToLess(jessColor: Color, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformColorToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/color.js
CHANGED
|
@@ -1,57 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// Map 'type' property
|
|
10
|
-
if (prop === 'type') {
|
|
11
|
-
return mapJessTypeToLessType(color.type);
|
|
12
|
-
}
|
|
13
|
-
// Map 'typeIndex'
|
|
14
|
-
if (prop === 'typeIndex') {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
// Map 'rgb' property
|
|
18
|
-
if (prop === 'rgb') {
|
|
19
|
-
return color.value.rgb || [0, 0, 0];
|
|
20
|
-
}
|
|
21
|
-
// Map 'alpha' property
|
|
22
|
-
if (prop === 'alpha') {
|
|
23
|
-
return color._alpha;
|
|
24
|
-
}
|
|
25
|
-
// Map 'value' property (Less expects string representation)
|
|
26
|
-
if (prop === 'value') {
|
|
27
|
-
// Convert color to string representation
|
|
28
|
-
// Less uses format like '#rrggbb' or 'rgba(r, g, b, a)'
|
|
29
|
-
const rgb = color.value.rgb;
|
|
30
|
-
const alpha = color._alpha;
|
|
1
|
+
import { createFromAdapter } from '../transform/adapter.js';
|
|
2
|
+
export const transformColorToLess = createFromAdapter({
|
|
3
|
+
fields: {
|
|
4
|
+
rgb: c => c.rgb || [0, 0, 0],
|
|
5
|
+
alpha: c => c._alpha,
|
|
6
|
+
value: (c) => {
|
|
7
|
+
const rgb = c.rgb;
|
|
8
|
+
const alpha = c._alpha;
|
|
31
9
|
if (rgb && alpha !== undefined && alpha < 1) {
|
|
32
10
|
return `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${alpha})`;
|
|
33
11
|
}
|
|
34
12
|
if (rgb) {
|
|
35
|
-
// Convert to hex
|
|
36
13
|
const hex = rgb.map((v) => {
|
|
37
14
|
const numericValue = Array.isArray(v) ? v[0] : v;
|
|
38
|
-
|
|
39
|
-
return h;
|
|
15
|
+
return Math.round(numericValue).toString(16).padStart(2, '0');
|
|
40
16
|
}).join('');
|
|
41
17
|
return `#${hex}`;
|
|
42
18
|
}
|
|
43
19
|
return '';
|
|
44
20
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Color nodes typically don't have children to traverse, so this is a no-op
|
|
48
|
-
if (prop === 'accept') {
|
|
49
|
-
return function (visitor) {
|
|
50
|
-
// Color nodes don't have children to traverse
|
|
51
|
-
// The visitor.visit() was already called by our plugin wrapper
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
57
23
|
//# sourceMappingURL=color.js.map
|
package/lib/nodes/color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/nodes/color.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/nodes/color.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAQ;IAC3D,MAAM,EAAE;QACN,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5B,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;QACpB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;YAClB,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;YACvB,IAAI,GAAG,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBAC5C,OAAO,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC;YAC3D,CAAC;YACD,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACxB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;gBAChE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACZ,OAAO,IAAI,GAAG,EAAE,CAAC;YACnB,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Combinator to a Less-compatible Combinator
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformCombinatorToLess(jessCombinator: Combinator, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformCombinatorToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/combinator.js
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return createLessProxy(jessCombinator, cache, (prop, target) => {
|
|
8
|
-
const combinator = target;
|
|
9
|
-
// Map 'type' property
|
|
10
|
-
if (prop === 'type') {
|
|
11
|
-
return mapJessTypeToLessType(combinator.type);
|
|
12
|
-
}
|
|
13
|
-
// Map 'typeIndex'
|
|
14
|
-
if (prop === 'typeIndex') {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
// Map 'value' property
|
|
18
|
-
if (prop === 'value') {
|
|
19
|
-
return combinator.value;
|
|
20
|
-
}
|
|
21
|
-
// Map 'accept' method for visitor traversal
|
|
22
|
-
if (prop === 'accept') {
|
|
23
|
-
return function (visitor) {
|
|
24
|
-
// Less Combinator has no children, so accept() should just return the combinator
|
|
25
|
-
// The visitor's visit() method will be called by the visitor itself
|
|
26
|
-
// We don't need to call visitor.visit() here - that would create a loop
|
|
27
|
-
// if the visitor's visit() method calls accept() again
|
|
28
|
-
return combinator;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
1
|
+
import { createFromAdapter } from '../transform/adapter.js';
|
|
2
|
+
export const transformCombinatorToLess = createFromAdapter({
|
|
3
|
+
fields: {
|
|
4
|
+
value: c => c.value
|
|
5
|
+
}
|
|
6
|
+
});
|
|
34
7
|
//# sourceMappingURL=combinator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../src/nodes/combinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../src/nodes/combinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAa;IACrE,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK;KACpB;CACF,CAAC,CAAC"}
|
package/lib/nodes/comment.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LessNode } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Comment to a Less-compatible Comment
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformCommentToLess(jessComment: Comment, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
export declare const transformCommentToLess: (jessNode: import("@jesscss/core").Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|
package/lib/nodes/comment.js
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const comment = target;
|
|
10
|
-
// Map 'type' property
|
|
11
|
-
if (prop === 'type') {
|
|
12
|
-
return mapJessTypeToLessType(comment.type);
|
|
13
|
-
}
|
|
14
|
-
// Map 'typeIndex'
|
|
15
|
-
if (prop === 'typeIndex') {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
// Map 'value' property
|
|
19
|
-
if (prop === 'value') {
|
|
20
|
-
return comment.value;
|
|
21
|
-
}
|
|
22
|
-
// Map 'silent' property (Less uses this for /* */ vs // comments)
|
|
23
|
-
if (prop === 'silent') {
|
|
24
|
-
// Jess doesn't distinguish, default to false (block comment)
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
// Map 'accept' method for visitor traversal
|
|
28
|
-
if (prop === 'accept') {
|
|
29
|
-
return function (visitor) {
|
|
30
|
-
const lessComment = transformCommentToLess(comment, cache);
|
|
31
|
-
const result = visitor.visit(lessComment);
|
|
32
|
-
if (result !== lessComment) {
|
|
33
|
-
return fromLessNode(result, { cache });
|
|
34
|
-
}
|
|
35
|
-
return comment;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
1
|
+
import { createFromAdapter, selfVisitAccept } from '../transform/adapter.js';
|
|
2
|
+
export const transformCommentToLess = createFromAdapter({
|
|
3
|
+
fields: {
|
|
4
|
+
value: c => c.value,
|
|
5
|
+
silent: () => false
|
|
6
|
+
},
|
|
7
|
+
accept: selfVisitAccept()
|
|
8
|
+
});
|
|
41
9
|
//# sourceMappingURL=comment.js.map
|
package/lib/nodes/comment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../src/nodes/comment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../src/nodes/comment.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;QACnB,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK;KACpB;IACD,MAAM,EAAE,eAAe,EAAE;CAC1B,CAAC,CAAC"}
|
package/lib/nodes/condition.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Condition to a Less-compatible Condition
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformConditionToLess(jessCondition: Condition, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformConditionToLess: (jessNode: Node, cache?: WeakMap<any, any>) => import("../types.js").LessNode;
|