@jesscss/plugin-less-compat 2.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +139 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/less-compat-structures.d.ts +108 -0
- package/lib/less-compat-structures.js +519 -0
- package/lib/less-compat-structures.js.map +1 -0
- package/lib/nodes/at-rule.d.ts +6 -0
- package/lib/nodes/at-rule.js +72 -0
- package/lib/nodes/at-rule.js.map +1 -0
- package/lib/nodes/attribute-selector.d.ts +6 -0
- package/lib/nodes/attribute-selector.js +54 -0
- package/lib/nodes/attribute-selector.js.map +1 -0
- package/lib/nodes/call.d.ts +6 -0
- package/lib/nodes/call.js +83 -0
- package/lib/nodes/call.js.map +1 -0
- package/lib/nodes/color.d.ts +6 -0
- package/lib/nodes/color.js +57 -0
- package/lib/nodes/color.js.map +1 -0
- package/lib/nodes/combinator.d.ts +6 -0
- package/lib/nodes/combinator.js +34 -0
- package/lib/nodes/combinator.js.map +1 -0
- package/lib/nodes/comment.d.ts +6 -0
- package/lib/nodes/comment.js +41 -0
- package/lib/nodes/comment.js.map +1 -0
- package/lib/nodes/condition.d.ts +6 -0
- package/lib/nodes/condition.js +60 -0
- package/lib/nodes/condition.js.map +1 -0
- package/lib/nodes/declaration.d.ts +6 -0
- package/lib/nodes/declaration.js +81 -0
- package/lib/nodes/declaration.js.map +1 -0
- package/lib/nodes/dimension.d.ts +6 -0
- package/lib/nodes/dimension.js +47 -0
- package/lib/nodes/dimension.js.map +1 -0
- package/lib/nodes/expression.d.ts +6 -0
- package/lib/nodes/expression.js +44 -0
- package/lib/nodes/expression.js.map +1 -0
- package/lib/nodes/extend.d.ts +6 -0
- package/lib/nodes/extend.js +57 -0
- package/lib/nodes/extend.js.map +1 -0
- package/lib/nodes/import.d.ts +6 -0
- package/lib/nodes/import.js +63 -0
- package/lib/nodes/import.js.map +1 -0
- package/lib/nodes/index.d.ts +45 -0
- package/lib/nodes/index.js +308 -0
- package/lib/nodes/index.js.map +1 -0
- package/lib/nodes/keyword.d.ts +6 -0
- package/lib/nodes/keyword.js +36 -0
- package/lib/nodes/keyword.js.map +1 -0
- package/lib/nodes/list.d.ts +6 -0
- package/lib/nodes/list.js +150 -0
- package/lib/nodes/list.js.map +1 -0
- package/lib/nodes/mixin.d.ts +6 -0
- package/lib/nodes/mixin.js +62 -0
- package/lib/nodes/mixin.js.map +1 -0
- package/lib/nodes/negative.d.ts +6 -0
- package/lib/nodes/negative.js +42 -0
- package/lib/nodes/negative.js.map +1 -0
- package/lib/nodes/operation.d.ts +6 -0
- package/lib/nodes/operation.js +63 -0
- package/lib/nodes/operation.js.map +1 -0
- package/lib/nodes/paren.d.ts +6 -0
- package/lib/nodes/paren.js +42 -0
- package/lib/nodes/paren.js.map +1 -0
- package/lib/nodes/quoted.d.ts +6 -0
- package/lib/nodes/quoted.js +57 -0
- package/lib/nodes/quoted.js.map +1 -0
- package/lib/nodes/reference.d.ts +9 -0
- package/lib/nodes/reference.js +80 -0
- package/lib/nodes/reference.js.map +1 -0
- package/lib/nodes/ruleset.d.ts +6 -0
- package/lib/nodes/ruleset.js +108 -0
- package/lib/nodes/ruleset.js.map +1 -0
- package/lib/nodes/selector.d.ts +8 -0
- package/lib/nodes/selector.js +226 -0
- package/lib/nodes/selector.js.map +1 -0
- package/lib/nodes/sequence.d.ts +9 -0
- package/lib/nodes/sequence.js +75 -0
- package/lib/nodes/sequence.js.map +1 -0
- package/lib/nodes/url.d.ts +6 -0
- package/lib/nodes/url.js +42 -0
- package/lib/nodes/url.js.map +1 -0
- package/lib/nodes/var-declaration.d.ts +6 -0
- package/lib/nodes/var-declaration.js +60 -0
- package/lib/nodes/var-declaration.js.map +1 -0
- package/lib/plugin-utils.d.ts +20 -0
- package/lib/plugin-utils.js +100 -0
- package/lib/plugin-utils.js.map +1 -0
- package/lib/plugin.d.ts +92 -0
- package/lib/plugin.js +1027 -0
- package/lib/plugin.js.map +1 -0
- package/lib/transform/from-less.d.ts +30 -0
- package/lib/transform/from-less.js +170 -0
- package/lib/transform/from-less.js.map +1 -0
- package/lib/transform/index.d.ts +7 -0
- package/lib/transform/index.js +8 -0
- package/lib/transform/index.js.map +1 -0
- package/lib/transform/proxy.d.ts +32 -0
- package/lib/transform/proxy.js +138 -0
- package/lib/transform/proxy.js.map +1 -0
- package/lib/transform/to-less.d.ts +17 -0
- package/lib/transform/to-less.js +128 -0
- package/lib/transform/to-less.js.map +1 -0
- package/lib/transform/type-map.d.ts +27 -0
- package/lib/transform/type-map.js +105 -0
- package/lib/transform/type-map.js.map +1 -0
- package/lib/types.d.ts +33 -0
- package/lib/types.js +5 -0
- package/lib/types.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Matthew Dean
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @jesscss/plugin-less-compat
|
|
2
|
+
|
|
3
|
+
Less.js compatibility layer for Jess. This plugin enables Less.js plugins and visitors to work seamlessly with Jess-compiled stylesheets by providing bidirectional transformation between Jess AST nodes and Less.js AST nodes.
|
|
4
|
+
|
|
5
|
+
## ⚠️ Experimental Status
|
|
6
|
+
|
|
7
|
+
**This package is experimental and largely LLM-generated.** It was created to explore compatibility between Jess and Less.js plugins, but:
|
|
8
|
+
|
|
9
|
+
- **No long-term maintenance commitment**: This package is unlikely to be actively maintained in the future
|
|
10
|
+
- **Use at your own risk**: While it may work for some use cases, it has not been thoroughly tested across all Less.js plugins
|
|
11
|
+
- **Breaking changes likely**: The API and implementation may change or be removed without notice
|
|
12
|
+
- **Not production-ready**: This is an experimental exploration, not a production-grade compatibility layer
|
|
13
|
+
|
|
14
|
+
If you need Less.js plugin compatibility, consider:
|
|
15
|
+
- Using Less.js directly for projects that require extensive Less.js plugin support
|
|
16
|
+
- Contributing improvements if you find this package useful
|
|
17
|
+
- Creating your own compatibility layer tailored to your specific needs
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- 🔄 **Bidirectional Transformation**: Convert between Jess and Less AST nodes
|
|
22
|
+
- 🎯 **Lazy Conversion**: Proxy-based lazy conversion for optimal performance
|
|
23
|
+
- 🔌 **Plugin Compatibility**: Use existing Less.js plugins with Jess
|
|
24
|
+
- 🧩 **Visitor Support**: Run Less.js visitors on Jess AST trees
|
|
25
|
+
- 📦 **Type Safe**: Full TypeScript support
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @jesscss/plugin-less-compat
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Basic Usage with Less Plugins
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Compiler } from '@jesscss/jess';
|
|
39
|
+
import lessPlugin from '@jesscss/plugin-less';
|
|
40
|
+
import { lessCompatPlugin } from '@jesscss/plugin-less-compat';
|
|
41
|
+
import autoprefix from 'less-plugin-autoprefix';
|
|
42
|
+
|
|
43
|
+
const compiler = new Compiler({
|
|
44
|
+
plugins: [
|
|
45
|
+
lessPlugin(),
|
|
46
|
+
lessCompatPlugin({
|
|
47
|
+
visitors: [autoprefix]
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const result = await compiler.compile('styles.less');
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Advanced: Direct Transformation
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { toLessTree, fromLessTree } from '@jesscss/plugin-less-compat/transform';
|
|
59
|
+
import customLessVisitor from './custom-visitor';
|
|
60
|
+
|
|
61
|
+
const jessTree = parseJess(source);
|
|
62
|
+
const lessTree = toLessTree(jessTree);
|
|
63
|
+
|
|
64
|
+
// Apply custom Less visitor
|
|
65
|
+
lessTree.accept(customLessVisitor);
|
|
66
|
+
|
|
67
|
+
// Convert back to Jess
|
|
68
|
+
const modifiedJessTree = fromLessTree(lessTree);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Using with Multiple Less Plugins
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { lessCompatPlugin } from '@jesscss/plugin-less-compat';
|
|
75
|
+
import autoprefix from 'less-plugin-autoprefix';
|
|
76
|
+
import cleanCSS from 'less-plugin-clean-css';
|
|
77
|
+
|
|
78
|
+
const compiler = new Compiler({
|
|
79
|
+
plugins: [
|
|
80
|
+
lessPlugin(),
|
|
81
|
+
lessCompatPlugin({
|
|
82
|
+
visitors: [
|
|
83
|
+
autoprefix,
|
|
84
|
+
cleanCSS
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Supported Less Plugins
|
|
92
|
+
|
|
93
|
+
This package has been tested with:
|
|
94
|
+
|
|
95
|
+
- ✅ `less-plugin-autoprefix` - Automatic vendor prefixing
|
|
96
|
+
- ✅ `less-plugin-clean-css` - CSS minification
|
|
97
|
+
- ✅ `less-plugin-dls` - Design Language System support
|
|
98
|
+
|
|
99
|
+
Other Less.js plugins should work, but may require additional testing.
|
|
100
|
+
|
|
101
|
+
## API
|
|
102
|
+
|
|
103
|
+
### `lessCompatPlugin(options?)`
|
|
104
|
+
|
|
105
|
+
Creates a Jess plugin that enables Less.js compatibility.
|
|
106
|
+
|
|
107
|
+
**Options:**
|
|
108
|
+
- `visitors?: LessVisitor[]` - Array of Less.js visitors to apply
|
|
109
|
+
- `cache?: boolean` - Enable conversion caching (default: `true`)
|
|
110
|
+
|
|
111
|
+
### `toLessTree(jessRules: Rules)`
|
|
112
|
+
|
|
113
|
+
Converts a Jess `Rules` tree to a Less.js-compatible tree.
|
|
114
|
+
|
|
115
|
+
### `fromLessTree(lessTree: LessNode)`
|
|
116
|
+
|
|
117
|
+
Converts a Less.js tree back to a Jess `Rules` tree.
|
|
118
|
+
|
|
119
|
+
### `toLessNode(jessNode: Node, options?)`
|
|
120
|
+
|
|
121
|
+
Converts a single Jess node to a Less.js-compatible node.
|
|
122
|
+
|
|
123
|
+
### `fromLessNode(lessNode: LessNode, options?)`
|
|
124
|
+
|
|
125
|
+
Converts a single Less.js node back to a Jess node.
|
|
126
|
+
|
|
127
|
+
## Implementation Status
|
|
128
|
+
|
|
129
|
+
This package is currently in **alpha**.
|
|
130
|
+
|
|
131
|
+
Developer notes and historical analyses live in [DESIGN.md](./DESIGN.md) and `_archive/`.
|
|
132
|
+
|
|
133
|
+
## Contributing
|
|
134
|
+
|
|
135
|
+
Contributions welcome! Please see the main Jess repository for contribution guidelines.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jesscss/plugin-less-compat
|
|
3
|
+
*
|
|
4
|
+
* Less.js compatibility layer for Jess.
|
|
5
|
+
* Enables Less.js plugins and visitors to work with Jess AST.
|
|
6
|
+
*/
|
|
7
|
+
export { LessCompatPlugin, default as lessCompatPlugin, type LessCompatPluginOptions } from './plugin.js';
|
|
8
|
+
export * from './transform/index.js';
|
|
9
|
+
export { isLessPlugin, isJessPlugin, filterPlugins } from './plugin-utils.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jesscss/plugin-less-compat
|
|
3
|
+
*
|
|
4
|
+
* Less.js compatibility layer for Jess.
|
|
5
|
+
* Enables Less.js plugins and visitors to work with Jess AST.
|
|
6
|
+
*/
|
|
7
|
+
export { LessCompatPlugin, default as lessCompatPlugin } from './plugin.js';
|
|
8
|
+
export * from './transform/index.js';
|
|
9
|
+
export { isLessPlugin, isJessPlugin, filterPlugins } from './plugin-utils.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Less.js-compatible structures for plugin compatibility
|
|
3
|
+
* These are standalone implementations that don't require the actual Less.js library
|
|
4
|
+
*/
|
|
5
|
+
export declare class LessVisitor {
|
|
6
|
+
visitor?: any | undefined;
|
|
7
|
+
private processingNodes;
|
|
8
|
+
constructor(visitor?: any | undefined);
|
|
9
|
+
/**
|
|
10
|
+
* Visit a node - handles both modern and legacy Less.js node types
|
|
11
|
+
* Supports Less.js v2 "Directive" nodes (mapped to AtRule)
|
|
12
|
+
*
|
|
13
|
+
* In Less.js v2, at-rules were called "Directive" instead of "AtRule".
|
|
14
|
+
* For compatibility, we route AtRule nodes to visitDirective() if that method exists,
|
|
15
|
+
* allowing v2 plugins to work with modern AtRule nodes.
|
|
16
|
+
*/
|
|
17
|
+
visit(node: any, visitArgs?: any): any;
|
|
18
|
+
/**
|
|
19
|
+
* Visit array of nodes
|
|
20
|
+
*/
|
|
21
|
+
visitArray(nodes: any[], visitArgs?: any): any[];
|
|
22
|
+
/**
|
|
23
|
+
* Visit Directive node (Less.js v2 compatibility)
|
|
24
|
+
* Maps to AtRule for modern Less.js compatibility
|
|
25
|
+
*/
|
|
26
|
+
visitDirective(node: any, visitArgs?: any): any;
|
|
27
|
+
/**
|
|
28
|
+
* Visit Rule node (Less.js v2 compatibility)
|
|
29
|
+
* Maps to Declaration for modern Less.js compatibility
|
|
30
|
+
*/
|
|
31
|
+
visitRule(node: any, visitArgs?: any): any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Less.js PluginManager (minimal implementation)
|
|
35
|
+
* Plugins use this to register visitors, pre/post processors, etc.
|
|
36
|
+
*/
|
|
37
|
+
export declare class LessPluginManager {
|
|
38
|
+
less: any;
|
|
39
|
+
newFactory?: boolean | undefined;
|
|
40
|
+
visitors: any[];
|
|
41
|
+
preProcessors: any[];
|
|
42
|
+
postProcessors: any[];
|
|
43
|
+
constructor(less: any, newFactory?: boolean | undefined);
|
|
44
|
+
/**
|
|
45
|
+
* Add a visitor to the manager
|
|
46
|
+
*/
|
|
47
|
+
addVisitor(visitor: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* Remove a visitor
|
|
50
|
+
*/
|
|
51
|
+
removeVisitor(visitor: any): void;
|
|
52
|
+
/**
|
|
53
|
+
* Add a pre-processor (runs before parsing)
|
|
54
|
+
*/
|
|
55
|
+
addPreProcessor(preProcessor: any): void;
|
|
56
|
+
/**
|
|
57
|
+
* Add a post-processor (runs after compilation)
|
|
58
|
+
*/
|
|
59
|
+
addPostProcessor(postProcessor: any): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get all visitors
|
|
62
|
+
*/
|
|
63
|
+
getVisitors(): any[];
|
|
64
|
+
/**
|
|
65
|
+
* Get all pre-processors
|
|
66
|
+
*/
|
|
67
|
+
getPreProcessors(): any[];
|
|
68
|
+
/**
|
|
69
|
+
* Get all post-processors
|
|
70
|
+
*/
|
|
71
|
+
getPostProcessors(): any[];
|
|
72
|
+
/**
|
|
73
|
+
* Register a plugin (Less.js-compatible API)
|
|
74
|
+
* Some plugins use this method instead of install()
|
|
75
|
+
*/
|
|
76
|
+
registerPlugin(plugin: any, _options?: any): void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Less.js tree constructors (minimal implementations)
|
|
80
|
+
* Plugins may access these via functionRegistry.Call, etc.
|
|
81
|
+
*/
|
|
82
|
+
export declare const LessTreeConstructors: Record<string, any>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a Less.js-compatible mock object
|
|
85
|
+
* This provides the minimal structure that plugins expect
|
|
86
|
+
*/
|
|
87
|
+
export declare function createLessMock(functionRegistry: any): {
|
|
88
|
+
visitors: {
|
|
89
|
+
Visitor: typeof LessVisitor;
|
|
90
|
+
};
|
|
91
|
+
functions: {
|
|
92
|
+
functionRegistry: any;
|
|
93
|
+
};
|
|
94
|
+
tree: Record<string, any>;
|
|
95
|
+
PluginLoader: {
|
|
96
|
+
new (): {};
|
|
97
|
+
};
|
|
98
|
+
dimension(value: number, unit?: string): any;
|
|
99
|
+
value(values: any[]): any[];
|
|
100
|
+
declaration(name: string, value: any): any;
|
|
101
|
+
ruleset(selector: any, rules: any[]): any;
|
|
102
|
+
detachedruleset(rulesetLike: any): any;
|
|
103
|
+
atrule(name: string, value: any): {
|
|
104
|
+
type: string;
|
|
105
|
+
name: string;
|
|
106
|
+
value: any;
|
|
107
|
+
};
|
|
108
|
+
};
|