@jesscss/plugin-less-compat 2.0.0-alpha.6 → 2.0.0-alpha.8

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.
Files changed (116) hide show
  1. package/README.md +40 -137
  2. package/lib/index.cjs +844 -0
  3. package/lib/index.d.ts +1 -0
  4. package/lib/index.js +800 -10
  5. package/lib/less-adapter.cjs +216 -0
  6. package/lib/less-adapter.js +181 -0
  7. package/lib/less-compat-structures.cjs +378 -0
  8. package/lib/less-compat-structures.d.ts +2 -2
  9. package/lib/less-compat-structures.js +367 -512
  10. package/lib/nodes/at-rule.d.ts +2 -2
  11. package/lib/nodes/attribute-selector.d.ts +2 -2
  12. package/lib/nodes/call.d.ts +2 -2
  13. package/lib/nodes/color.d.ts +2 -1
  14. package/lib/nodes/combinator.d.ts +2 -1
  15. package/lib/nodes/comment.d.ts +2 -1
  16. package/lib/nodes/condition.d.ts +2 -2
  17. package/lib/nodes/declaration.d.ts +2 -2
  18. package/lib/nodes/dimension.d.ts +2 -1
  19. package/lib/nodes/expression.d.ts +2 -2
  20. package/lib/nodes/extend.d.ts +2 -1
  21. package/lib/nodes/import.d.ts +2 -2
  22. package/lib/nodes/keyword.d.ts +2 -1
  23. package/lib/nodes/list.d.ts +3 -2
  24. package/lib/nodes/mixin.d.ts +2 -2
  25. package/lib/nodes/negative.d.ts +2 -2
  26. package/lib/nodes/operation.d.ts +2 -2
  27. package/lib/nodes/paren.d.ts +2 -2
  28. package/lib/nodes/quoted.d.ts +2 -1
  29. package/lib/nodes/reference.d.ts +2 -1
  30. package/lib/nodes/ruleset.d.ts +2 -2
  31. package/lib/nodes/selector.d.ts +2 -2
  32. package/lib/nodes/sequence.d.ts +2 -2
  33. package/lib/nodes/url.d.ts +2 -1
  34. package/lib/nodes/var-declaration.d.ts +2 -2
  35. package/lib/plugin.d.ts +44 -16
  36. package/lib/transform/adapter.d.ts +9 -11
  37. package/lib/transform/index.cjs +13 -0
  38. package/lib/transform/index.d.ts +1 -1
  39. package/lib/transform/index.js +3 -8
  40. package/lib/transform/less-adapter.d.ts +29 -0
  41. package/lib/transform.cjs +1045 -0
  42. package/lib/transform.js +1015 -0
  43. package/lib/types.d.ts +153 -28
  44. package/package.json +6 -9
  45. package/lib/index.js.map +0 -1
  46. package/lib/less-compat-structures.js.map +0 -1
  47. package/lib/nodes/at-rule.js +0 -21
  48. package/lib/nodes/at-rule.js.map +0 -1
  49. package/lib/nodes/attribute-selector.js +0 -18
  50. package/lib/nodes/attribute-selector.js.map +0 -1
  51. package/lib/nodes/call.js +0 -27
  52. package/lib/nodes/call.js.map +0 -1
  53. package/lib/nodes/color.js +0 -23
  54. package/lib/nodes/color.js.map +0 -1
  55. package/lib/nodes/combinator.js +0 -7
  56. package/lib/nodes/combinator.js.map +0 -1
  57. package/lib/nodes/comment.js +0 -9
  58. package/lib/nodes/comment.js.map +0 -1
  59. package/lib/nodes/condition.js +0 -19
  60. package/lib/nodes/condition.js.map +0 -1
  61. package/lib/nodes/declaration.js +0 -38
  62. package/lib/nodes/declaration.js.map +0 -1
  63. package/lib/nodes/dimension.js +0 -9
  64. package/lib/nodes/dimension.js.map +0 -1
  65. package/lib/nodes/expression.js +0 -16
  66. package/lib/nodes/expression.js.map +0 -1
  67. package/lib/nodes/extend.js +0 -18
  68. package/lib/nodes/extend.js.map +0 -1
  69. package/lib/nodes/import.js +0 -22
  70. package/lib/nodes/import.js.map +0 -1
  71. package/lib/nodes/index.js +0 -308
  72. package/lib/nodes/index.js.map +0 -1
  73. package/lib/nodes/keyword.js +0 -8
  74. package/lib/nodes/keyword.js.map +0 -1
  75. package/lib/nodes/list.js +0 -61
  76. package/lib/nodes/list.js.map +0 -1
  77. package/lib/nodes/mixin.js +0 -22
  78. package/lib/nodes/mixin.js.map +0 -1
  79. package/lib/nodes/negative.js +0 -13
  80. package/lib/nodes/negative.js.map +0 -1
  81. package/lib/nodes/operation.js +0 -22
  82. package/lib/nodes/operation.js.map +0 -1
  83. package/lib/nodes/paren.js +0 -13
  84. package/lib/nodes/paren.js.map +0 -1
  85. package/lib/nodes/quoted.js +0 -23
  86. package/lib/nodes/quoted.js.map +0 -1
  87. package/lib/nodes/reference.js +0 -44
  88. package/lib/nodes/reference.js.map +0 -1
  89. package/lib/nodes/ruleset.js +0 -67
  90. package/lib/nodes/ruleset.js.map +0 -1
  91. package/lib/nodes/selector.js +0 -158
  92. package/lib/nodes/selector.js.map +0 -1
  93. package/lib/nodes/sequence.js +0 -56
  94. package/lib/nodes/sequence.js.map +0 -1
  95. package/lib/nodes/url.js +0 -13
  96. package/lib/nodes/url.js.map +0 -1
  97. package/lib/nodes/var-declaration.js +0 -21
  98. package/lib/nodes/var-declaration.js.map +0 -1
  99. package/lib/plugin-utils.js +0 -100
  100. package/lib/plugin-utils.js.map +0 -1
  101. package/lib/plugin.js +0 -1026
  102. package/lib/plugin.js.map +0 -1
  103. package/lib/transform/adapter.js +0 -111
  104. package/lib/transform/adapter.js.map +0 -1
  105. package/lib/transform/from-less.js +0 -170
  106. package/lib/transform/from-less.js.map +0 -1
  107. package/lib/transform/index.js.map +0 -1
  108. package/lib/transform/proxy.d.ts +0 -32
  109. package/lib/transform/proxy.js +0 -138
  110. package/lib/transform/proxy.js.map +0 -1
  111. package/lib/transform/to-less.js +0 -130
  112. package/lib/transform/to-less.js.map +0 -1
  113. package/lib/transform/type-map.js +0 -105
  114. package/lib/transform/type-map.js.map +0 -1
  115. package/lib/types.js +0 -5
  116. package/lib/types.js.map +0 -1
package/README.md CHANGED
@@ -1,139 +1,42 @@
1
1
  # @jesscss/plugin-less-compat
2
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
3
+ **The Less.js 4.x compatibility bridge run existing Less plugins and visitors
4
+ against the Jess AST.**
5
+
6
+ [Jess](https://github.com/jesscss/jess) *is* Less.js v5, but the Less 4.x
7
+ ecosystem has years of plugins and visitors written against the old Less AST.
8
+ This package bridges the two: it converts a Jess `Rules` tree to a
9
+ Less.js-compatible tree, runs Less 4.x visitors over it, and converts the result
10
+ back so tools like autoprefixing or minification plugins can keep working
11
+ against Jess-compiled stylesheets.
12
+
13
+ It's the load-bearing piece of the eventual **`less@5` adoption layer**: the seam
14
+ that lets a Less 4.x project move onto Jess without abandoning its existing plugin
15
+ setup.
16
+
17
+ ## How it works
18
+
19
+ - **Bidirectional transformation** between Jess AST nodes and Less.js AST nodes,
20
+ with lazy per-field conversion so only the fields a visitor touches are
21
+ materialized.
22
+ - **Visitor support** Less 4.x visitors run over the converted tree.
23
+ - Package resolution for `@plugin "name"` is delegated to
24
+ [`@jesscss/plugin-node-modules`](../jess-plugin-node-modules).
25
+
26
+ ## Status
27
+
28
+ **Alpha / experimental.** It works for the plugins it has been exercised against
29
+ (e.g. `less-plugin-autoprefix`, `less-plugin-clean-css`, `less-plugin-dls`), but
30
+ it has not been validated across the whole Less plugin ecosystem, and the surface
31
+ may change. If you need broad, battle-tested Less-plugin support today, use
32
+ Less.js directly.
33
+
34
+ The programmatic plugin/compiler API is **not yet stabilized** — the `jess` /
35
+ `lessc` CLIs are the public surface for the alpha. Watch the
36
+ [docs site](https://jesscss.github.io/) for the API once it settles. Current
37
+ design notes live in [DESIGN.md](./DESIGN.md).
38
+
39
+ - Project overview & positioning: <https://github.com/jesscss/jess#readme>
40
+ - Docs: <https://jesscss.github.io/> (currently pre-alpha content)
41
+ - Issues: <https://github.com/jesscss/jess/issues>
42
+ - License: MIT