@jesscss/plugin-less-compat 2.0.0-alpha.5 → 2.0.0-alpha.7
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/README.md +3 -2
- package/lib/index.cjs +844 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +800 -9
- package/lib/less-adapter.cjs +216 -0
- package/lib/less-adapter.js +181 -0
- package/lib/less-compat-structures.cjs +378 -0
- package/lib/less-compat-structures.d.ts +2 -2
- package/lib/less-compat-structures.js +367 -512
- package/lib/nodes/at-rule.d.ts +2 -6
- package/lib/nodes/attribute-selector.d.ts +2 -6
- package/lib/nodes/call.d.ts +2 -6
- package/lib/nodes/color.d.ts +1 -5
- package/lib/nodes/combinator.d.ts +1 -5
- package/lib/nodes/comment.d.ts +1 -5
- package/lib/nodes/condition.d.ts +2 -6
- package/lib/nodes/declaration.d.ts +2 -6
- package/lib/nodes/dimension.d.ts +1 -5
- package/lib/nodes/expression.d.ts +2 -6
- package/lib/nodes/extend.d.ts +1 -5
- package/lib/nodes/import.d.ts +2 -6
- package/lib/nodes/keyword.d.ts +1 -5
- package/lib/nodes/list.d.ts +2 -5
- package/lib/nodes/mixin.d.ts +2 -6
- package/lib/nodes/negative.d.ts +2 -6
- package/lib/nodes/operation.d.ts +2 -6
- package/lib/nodes/paren.d.ts +2 -6
- package/lib/nodes/quoted.d.ts +1 -5
- package/lib/nodes/reference.d.ts +1 -8
- package/lib/nodes/ruleset.d.ts +2 -6
- package/lib/nodes/selector.d.ts +2 -7
- package/lib/nodes/sequence.d.ts +2 -9
- package/lib/nodes/url.d.ts +1 -5
- package/lib/nodes/var-declaration.d.ts +2 -6
- package/lib/plugin.d.ts +44 -16
- package/lib/transform/adapter.d.ts +31 -0
- package/lib/transform/index.cjs +13 -0
- package/lib/transform/index.d.ts +1 -1
- package/lib/transform/index.js +3 -8
- package/lib/transform/less-adapter.d.ts +29 -0
- package/lib/transform.cjs +1045 -0
- package/lib/transform.js +1015 -0
- package/lib/types.d.ts +153 -28
- package/package.json +13 -12
- package/lib/index.js.map +0 -1
- package/lib/less-compat-structures.js.map +0 -1
- package/lib/nodes/at-rule.js +0 -72
- package/lib/nodes/at-rule.js.map +0 -1
- package/lib/nodes/attribute-selector.js +0 -54
- package/lib/nodes/attribute-selector.js.map +0 -1
- package/lib/nodes/call.js +0 -83
- package/lib/nodes/call.js.map +0 -1
- package/lib/nodes/color.js +0 -57
- package/lib/nodes/color.js.map +0 -1
- package/lib/nodes/combinator.js +0 -34
- package/lib/nodes/combinator.js.map +0 -1
- package/lib/nodes/comment.js +0 -41
- package/lib/nodes/comment.js.map +0 -1
- package/lib/nodes/condition.js +0 -60
- package/lib/nodes/condition.js.map +0 -1
- package/lib/nodes/declaration.js +0 -81
- package/lib/nodes/declaration.js.map +0 -1
- package/lib/nodes/dimension.js +0 -47
- package/lib/nodes/dimension.js.map +0 -1
- package/lib/nodes/expression.js +0 -44
- package/lib/nodes/expression.js.map +0 -1
- package/lib/nodes/extend.js +0 -57
- package/lib/nodes/extend.js.map +0 -1
- package/lib/nodes/import.js +0 -63
- package/lib/nodes/import.js.map +0 -1
- package/lib/nodes/index.js +0 -308
- package/lib/nodes/index.js.map +0 -1
- package/lib/nodes/keyword.js +0 -36
- package/lib/nodes/keyword.js.map +0 -1
- package/lib/nodes/list.js +0 -150
- package/lib/nodes/list.js.map +0 -1
- package/lib/nodes/mixin.js +0 -62
- package/lib/nodes/mixin.js.map +0 -1
- package/lib/nodes/negative.js +0 -42
- package/lib/nodes/negative.js.map +0 -1
- package/lib/nodes/operation.js +0 -63
- package/lib/nodes/operation.js.map +0 -1
- package/lib/nodes/paren.js +0 -42
- package/lib/nodes/paren.js.map +0 -1
- package/lib/nodes/quoted.js +0 -57
- package/lib/nodes/quoted.js.map +0 -1
- package/lib/nodes/reference.js +0 -80
- package/lib/nodes/reference.js.map +0 -1
- package/lib/nodes/ruleset.js +0 -108
- package/lib/nodes/ruleset.js.map +0 -1
- package/lib/nodes/selector.js +0 -226
- package/lib/nodes/selector.js.map +0 -1
- package/lib/nodes/sequence.js +0 -75
- package/lib/nodes/sequence.js.map +0 -1
- package/lib/nodes/url.js +0 -42
- package/lib/nodes/url.js.map +0 -1
- package/lib/nodes/var-declaration.js +0 -60
- package/lib/nodes/var-declaration.js.map +0 -1
- package/lib/plugin-utils.js +0 -100
- package/lib/plugin-utils.js.map +0 -1
- package/lib/plugin.js +0 -1027
- package/lib/plugin.js.map +0 -1
- package/lib/transform/from-less.js +0 -170
- package/lib/transform/from-less.js.map +0 -1
- package/lib/transform/index.js.map +0 -1
- package/lib/transform/proxy.d.ts +0 -32
- package/lib/transform/proxy.js +0 -138
- package/lib/transform/proxy.js.map +0 -1
- package/lib/transform/to-less.js +0 -128
- package/lib/transform/to-less.js.map +0 -1
- package/lib/transform/type-map.js +0 -105
- package/lib/transform/type-map.js.map +0 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +0 -1
package/lib/nodes/at-rule.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { AtRule } from '@jesscss/core';
|
|
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 { AtRule, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformAtRuleToLess: (jessNode: AtRule, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { AttributeSelector } from '@jesscss/core';
|
|
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 { AttributeSelector, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformAttributeSelectorToLess: (jessNode: AttributeSelector, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/call.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Call } from '@jesscss/core';
|
|
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 { Call, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformCallToLess: (jessNode: Call, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/color.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Color } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Color to a Less-compatible Color
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformColorToLess(jessColor: Color, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformColorToLess: (jessNode: Color, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Combinator } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Combinator to a Less-compatible Combinator
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformCombinatorToLess(jessCombinator: Combinator, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformCombinatorToLess: (jessNode: Combinator, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/comment.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Comment } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Comment to a Less-compatible Comment
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformCommentToLess(jessComment: Comment, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformCommentToLess: (jessNode: Comment, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/condition.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Condition } from '@jesscss/core';
|
|
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 { Condition, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformConditionToLess: (jessNode: Condition, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Declaration } from '@jesscss/core';
|
|
2
|
-
import
|
|
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 { Declaration, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformDeclarationToLess: (jessNode: Declaration<import("@jesscss/core").DeclarationOptions>, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/dimension.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Dimension, Num } from '@jesscss/core';
|
|
2
|
-
|
|
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;
|
|
2
|
+
export declare const transformDimensionToLess: (jessNode: Dimension | Num, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Expression } from '@jesscss/core';
|
|
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 { Expression, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformExpressionToLess: (jessNode: Expression, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/extend.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Extend } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Extend to a Less-compatible Extend
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformExtendToLess(jessExtend: Extend, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformExtendToLess: (jessNode: Extend, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/import.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { StyleImport } from '@jesscss/core';
|
|
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 { StyleImport, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformImportToLess: (jessNode: StyleImport, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/keyword.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Keyword } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Keyword to a Less-compatible Keyword
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformKeywordToLess(jessKeyword: Keyword, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformKeywordToLess: (jessNode: Keyword, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/list.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { List } from '@jesscss/core';
|
|
1
|
+
import { List, Node } from '@jesscss/core';
|
|
2
2
|
import type { LessNode } from '../types.js';
|
|
3
|
-
|
|
4
|
-
* Transform a Jess List to a Less-compatible Value
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformListToLess(jessList: List, cache?: WeakMap<any, any>): LessNode;
|
|
3
|
+
export declare const transformListToLess: (jessNode: List, cache?: WeakMap<Node, LessNode>) => LessNode;
|
package/lib/nodes/mixin.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Mixin } from '@jesscss/core';
|
|
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 { Mixin, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformMixinToLess: (jessNode: Mixin, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/negative.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Negative } from '@jesscss/core';
|
|
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 { Negative, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformNegativeToLess: (jessNode: Negative, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/operation.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Operation } from '@jesscss/core';
|
|
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 { Operation, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformOperationToLess: (jessNode: Operation, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/paren.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Paren } from '@jesscss/core';
|
|
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 { Paren, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformParenToLess: (jessNode: Paren, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/quoted.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Quoted } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Quoted to a Less-compatible Quoted
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformQuotedToLess(jessQuoted: Quoted, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformQuotedToLess: (jessNode: Quoted, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/reference.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { Reference } from '@jesscss/core';
|
|
2
|
-
|
|
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;
|
|
2
|
+
export declare const transformReferenceToLess: (jessNode: Reference, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/ruleset.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Ruleset } from '@jesscss/core';
|
|
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 { Ruleset, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformRulesetToLess: (jessNode: Ruleset, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/selector.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Node, type SelectorLike } 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 function transformSelectorToLess(sel: SelectorLike, cache?: WeakMap<Node, unknown>): LessNode;
|
package/lib/nodes/sequence.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import { Sequence } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Sequence (space-separated value list) to a Less-compatible Expression.
|
|
5
|
-
*
|
|
6
|
-
* This is critical for Less plugins that traverse into declaration values (e.g. preEval visitors
|
|
7
|
-
* that rewrite variables inside custom properties).
|
|
8
|
-
*/
|
|
9
|
-
export declare function transformSequenceToLess(jessSequence: Sequence, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { Sequence, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformSequenceToLess: (jessNode: Sequence, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/nodes/url.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { Url } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess Url to a Less-compatible URL
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformUrlToLess(jessUrl: Url, cache?: WeakMap<any, any>): LessNode;
|
|
2
|
+
export declare const transformUrlToLess: (jessNode: Url, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { VarDeclaration } from '@jesscss/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a Jess VarDeclaration to a Less-compatible Assignment
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformVarDeclarationToLess(jessVarDecl: VarDeclaration, cache?: WeakMap<any, any>): LessNode;
|
|
1
|
+
import { VarDeclaration, Node } from '@jesscss/core';
|
|
2
|
+
export declare const transformVarDeclarationToLess: (jessNode: VarDeclaration, cache?: WeakMap<Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { AbstractPlugin, type
|
|
1
|
+
import { AbstractPlugin, type PluginInterface, type PluginVisitor, type Rules } from '@jesscss/core';
|
|
2
2
|
import type { LessVisitor } from './types.js';
|
|
3
3
|
import { NodeModulesPlugin } from '@jesscss/plugin-node-modules';
|
|
4
4
|
export interface LessCompatPluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Less 4.x custom functions registered through the root
|
|
7
|
+
* `less.functions.functionRegistry.add/addMultiple` API. Keyed by function
|
|
8
|
+
* name; each is bridged onto every compiled tree's root scope so calls resolve
|
|
9
|
+
* during evaluation, exactly like the built-in Less functions.
|
|
10
|
+
*/
|
|
11
|
+
functions?: Record<string, (...args: any[]) => any>;
|
|
5
12
|
/**
|
|
6
13
|
* Less.js plugins - these will have their install() method called to extract visitors.
|
|
7
14
|
* Can be mixed with Jess plugins - Less plugins will be handled by this compat layer,
|
|
@@ -16,16 +23,20 @@ export interface LessCompatPluginOptions {
|
|
|
16
23
|
/** Enable conversion caching (default: true) */
|
|
17
24
|
cache?: boolean;
|
|
18
25
|
/**
|
|
19
|
-
* Plugin registry for @plugin directive support.
|
|
26
|
+
* Plugin registry for deprecated @plugin directive support.
|
|
20
27
|
* Maps plugin names/paths to plugin instances or factory functions.
|
|
21
28
|
* Used when processing @plugin directives in the source.
|
|
29
|
+
*
|
|
30
|
+
* @deprecated Less @plugin is deprecated. Prefer @use / @-use for script integration in .less files.
|
|
22
31
|
*/
|
|
23
32
|
pluginRegistry?: Record<string, any>;
|
|
24
33
|
/**
|
|
25
|
-
* Enable auto-loading of plugins by name (Less.js 4.x CLI behavior).
|
|
34
|
+
* Enable auto-loading of deprecated @plugin plugins by name (Less.js 4.x CLI behavior).
|
|
26
35
|
* When true (default), @plugin directives will attempt to require/import
|
|
27
36
|
* plugins by their npm package name (e.g., "less-plugin-autoprefix").
|
|
28
37
|
* Set to false to disable and only use pluginRegistry.
|
|
38
|
+
*
|
|
39
|
+
* @deprecated Less @plugin is deprecated. Prefer @use / @-use for script integration in .less files.
|
|
29
40
|
*/
|
|
30
41
|
autoLoadPlugins?: boolean;
|
|
31
42
|
/**
|
|
@@ -46,26 +57,43 @@ export declare class LessCompatPlugin extends AbstractPlugin {
|
|
|
46
57
|
private _lessPluginManager?;
|
|
47
58
|
private _currentFilePath?;
|
|
48
59
|
private _jessFunctionRegistry?;
|
|
60
|
+
private _context?;
|
|
61
|
+
/** Trees whose root scope already received the configured root functions. */
|
|
62
|
+
private _fnRegisteredTrees;
|
|
49
63
|
constructor(opts?: LessCompatPluginOptions);
|
|
50
64
|
/**
|
|
51
|
-
* Return the visitor
|
|
52
|
-
* This
|
|
53
|
-
*
|
|
65
|
+
* Return the visitor through the early visitor hook so it runs before
|
|
66
|
+
* evaluation. This keeps Less plugin visitors and preprocessors early without
|
|
67
|
+
* bringing back a public node preparation pass.
|
|
54
68
|
*
|
|
55
69
|
* Less plugins can register visitors via:
|
|
56
|
-
* - addVisitor() - these
|
|
57
|
-
* - addPreProcessor() - these
|
|
58
|
-
* - addPostProcessor() - these
|
|
70
|
+
* - addVisitor() - these run early by default
|
|
71
|
+
* - addPreProcessor() - these run early
|
|
72
|
+
* - addPostProcessor() - these run on serialized CSS after render
|
|
59
73
|
*/
|
|
60
|
-
get
|
|
74
|
+
get beforeEvalVisitor(): PluginInterface['beforeEvalVisitor'];
|
|
61
75
|
/**
|
|
62
|
-
*
|
|
63
|
-
* These visitors will run after node.eval() completes.
|
|
76
|
+
* Less post-processors operate on final CSS, not on the preRenderVisitor tree hook.
|
|
64
77
|
*/
|
|
65
|
-
get postEvalVisitor():
|
|
78
|
+
get postEvalVisitor(): PluginInterface['postEvalVisitor'];
|
|
66
79
|
runPostProcessors(css: string, extra?: Record<string, any>): string;
|
|
67
80
|
setCurrentFilePath(filePath: string): void;
|
|
68
81
|
setContext(context: any): void;
|
|
82
|
+
private createJessFunctionBindingRegistry;
|
|
83
|
+
private hasConfiguredBeforeEvalWork;
|
|
84
|
+
private sourceMayContainPluginDirective;
|
|
85
|
+
private treeContainsPluginDirective;
|
|
86
|
+
private warnForPluginDirective;
|
|
87
|
+
private markPluginDirectiveInvisible;
|
|
88
|
+
private registerDenoLessPluginFunctions;
|
|
89
|
+
private loadLessPluginFileWithDeno;
|
|
90
|
+
beforeEvalVisitorForTree(tree: Rules): PluginInterface['beforeEvalVisitor'];
|
|
91
|
+
/**
|
|
92
|
+
* Register the configured Less 4.x root functions onto a parsed tree's root
|
|
93
|
+
* scope, using the same `setFunctionBinding` mechanism the Less plugin uses
|
|
94
|
+
* for built-ins. Idempotent per tree.
|
|
95
|
+
*/
|
|
96
|
+
private registerRootFunctions;
|
|
69
97
|
/**
|
|
70
98
|
* Filter and separate Less plugins from Jess plugins
|
|
71
99
|
* This allows mixed plugin arrays to be handled correctly
|
|
@@ -74,7 +102,7 @@ export declare class LessCompatPlugin extends AbstractPlugin {
|
|
|
74
102
|
*/
|
|
75
103
|
static filterLessPlugins(plugins: any[]): {
|
|
76
104
|
lessPlugins: any[];
|
|
77
|
-
jessPlugins:
|
|
105
|
+
jessPlugins: PluginInterface[];
|
|
78
106
|
};
|
|
79
107
|
/**
|
|
80
108
|
* Return a visitor that wraps Less visitors
|
|
@@ -82,11 +110,11 @@ export declare class LessCompatPlugin extends AbstractPlugin {
|
|
|
82
110
|
* This visitor intercepts each node, converts it to Less format,
|
|
83
111
|
* runs the Less visitors, and converts back if modified.
|
|
84
112
|
*/
|
|
85
|
-
get visitor():
|
|
113
|
+
get visitor(): PluginVisitor | PluginVisitor[] | undefined;
|
|
86
114
|
}
|
|
87
115
|
/**
|
|
88
116
|
* Create a Less.js compatibility plugin
|
|
89
117
|
*/
|
|
90
|
-
declare const lessCompatPlugin:
|
|
118
|
+
declare const lessCompatPlugin: (opts?: LessCompatPluginOptions) => LessCompatPlugin;
|
|
91
119
|
export default lessCompatPlugin;
|
|
92
120
|
export { lessCompatPlugin };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
import { type LessAdapterField } from './less-adapter.js';
|
|
3
|
+
import type { LessNode } from '../types.js';
|
|
4
|
+
type NodeTransformer<T extends Node> = (jessNode: T, cache?: WeakMap<Node, LessNode>) => LessNode;
|
|
5
|
+
type AcceptFn<T extends Node> = (node: T, visitor: {
|
|
6
|
+
visitArray?: (nodes: LessNode[]) => void;
|
|
7
|
+
visit?: (node: LessNode) => unknown;
|
|
8
|
+
}, cache?: WeakMap<Node, unknown>) => T | unknown;
|
|
9
|
+
export interface NodeAdapter<T extends Node> {
|
|
10
|
+
lessType?: string | ((node: T) => string);
|
|
11
|
+
fields: Record<string, LessAdapterField<T>>;
|
|
12
|
+
accept?: AcceptFn<T>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a NodeTransformer from a declarative adapter definition.
|
|
16
|
+
*
|
|
17
|
+
* - `type` and `typeIndex` are auto-mapped.
|
|
18
|
+
* - If no `accept` is provided, leaf behavior (return self) is used.
|
|
19
|
+
* - Field lookups are dispatched from the `fields` record.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createFromAdapter<T extends Node>(adapter: NodeAdapter<T>): NodeTransformer<T>;
|
|
22
|
+
export declare function selfVisitAccept<T extends Node>(): AcceptFn<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Accept helper: traverse child nodes via visitor.visitArray.
|
|
25
|
+
*/
|
|
26
|
+
export declare function childrenAccept<T extends Node>(getChildren: (node: T, cache?: WeakMap<Node, unknown>) => Node[]): AcceptFn<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Accept helper: traverse a single child node.
|
|
29
|
+
*/
|
|
30
|
+
export declare function singleChildAccept<T extends Node>(getChild: (node: T) => Node | undefined): AcceptFn<T>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_less_adapter = require("../less-adapter.cjs");
|
|
3
|
+
const require_transform = require("../transform.cjs");
|
|
4
|
+
exports.LessAdapterBase = require_less_adapter.LessAdapterBase;
|
|
5
|
+
exports.createLessAdapter = require_less_adapter.createLessAdapter;
|
|
6
|
+
exports.fromLessNode = require_transform.fromLessNode;
|
|
7
|
+
exports.fromLessPluginReturnValue = require_transform.fromLessPluginReturnValue;
|
|
8
|
+
exports.fromLessTree = require_transform.fromLessTree;
|
|
9
|
+
exports.getLessTypeIndex = require_less_adapter.getLessTypeIndex;
|
|
10
|
+
exports.mapJessTypeToLessType = require_less_adapter.mapJessTypeToLessType;
|
|
11
|
+
exports.mapLessTypeToJessType = require_less_adapter.mapLessTypeToJessType;
|
|
12
|
+
exports.toLessNode = require_transform.toLessNode;
|
|
13
|
+
exports.toLessTree = require_transform.toLessTree;
|
package/lib/transform/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { toLessNode, toLessTree, type ToLessOptions } from './to-less.js';
|
|
5
5
|
export { fromLessNode, fromLessPluginReturnValue, fromLessTree, type FromLessOptions } from './from-less.js';
|
|
6
|
-
export {
|
|
6
|
+
export { createLessAdapter, LessAdapterBase } from './less-adapter.js';
|
|
7
7
|
export { mapJessTypeToLessType, mapLessTypeToJessType, getLessTypeIndex } from './type-map.js';
|
package/lib/transform/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { toLessNode, toLessTree } from './to-less.js';
|
|
5
|
-
export { fromLessNode, fromLessPluginReturnValue, fromLessTree } from './from-less.js';
|
|
6
|
-
export { createLessProxy, isLessProxy, getJessNodeFromProxy } from './proxy.js';
|
|
7
|
-
export { mapJessTypeToLessType, mapLessTypeToJessType, getLessTypeIndex } from './type-map.js';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { a as mapJessTypeToLessType, i as getLessTypeIndex, n as createLessAdapter, o as mapLessTypeToJessType, t as LessAdapterBase } from "../less-adapter.js";
|
|
2
|
+
import { a as fromLessTree, i as fromLessPluginReturnValue, n as toLessTree, r as fromLessNode, t as toLessNode } from "../transform.js";
|
|
3
|
+
export { LessAdapterBase, createLessAdapter, fromLessNode, fromLessPluginReturnValue, fromLessTree, getLessTypeIndex, mapJessTypeToLessType, mapLessTypeToJessType, toLessNode, toLessTree };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
declare const LESS_ADAPTER_SYMBOL: unique symbol;
|
|
3
|
+
declare const JESS_NODE_SYMBOL: unique symbol;
|
|
4
|
+
export declare const IS_ADAPTING_SYMBOL: unique symbol;
|
|
5
|
+
export type LessAdapterField<T extends Node> = ((node: T, cache?: WeakMap<Node, unknown>) => unknown) | {
|
|
6
|
+
get: (node: T, cache?: WeakMap<Node, unknown>) => unknown;
|
|
7
|
+
set?: (node: T, value: unknown, cache?: WeakMap<Node, unknown>) => void;
|
|
8
|
+
enumerable?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface LessAdapterDefinition<T extends Node> {
|
|
11
|
+
lessType?: string | ((node: T) => string);
|
|
12
|
+
fields?: Record<string, LessAdapterField<T>>;
|
|
13
|
+
accept?: (node: T, visitor: any, cache?: WeakMap<Node, unknown>) => any;
|
|
14
|
+
}
|
|
15
|
+
export type LessAdapterInstance<T extends Node = Node> = LessAdapterBase<T> & {
|
|
16
|
+
type: string;
|
|
17
|
+
typeIndex: number | undefined;
|
|
18
|
+
accept(visitor: unknown): T | unknown;
|
|
19
|
+
};
|
|
20
|
+
export declare class LessAdapterBase<T extends Node = Node> {
|
|
21
|
+
readonly [LESS_ADAPTER_SYMBOL] = true;
|
|
22
|
+
readonly [JESS_NODE_SYMBOL]: T;
|
|
23
|
+
readonly ['__jessNode']: T;
|
|
24
|
+
constructor(node: T);
|
|
25
|
+
get jessNode(): T;
|
|
26
|
+
}
|
|
27
|
+
export declare function createLessAdapter<T extends Node>(jessNode: T, definition: LessAdapterDefinition<T>, cache?: WeakMap<Node, unknown>): LessAdapterInstance<T>;
|
|
28
|
+
export declare function isAdaptingNode(node: Node): boolean;
|
|
29
|
+
export {};
|