@jesscss/plugin-less-compat 2.0.0-alpha.7 → 2.0.0-alpha.9
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 +34 -122
- package/lib/index.cjs +13 -821
- package/lib/index.d.ts +0 -3
- package/lib/index.js +15 -786
- package/lib/plugin.d.ts +17 -109
- package/package.json +5 -15
- package/lib/less-adapter.cjs +0 -216
- package/lib/less-adapter.js +0 -181
- package/lib/less-compat-structures.cjs +0 -378
- package/lib/less-compat-structures.d.ts +0 -108
- package/lib/less-compat-structures.js +0 -374
- package/lib/nodes/at-rule.d.ts +0 -2
- package/lib/nodes/attribute-selector.d.ts +0 -2
- package/lib/nodes/call.d.ts +0 -2
- package/lib/nodes/color.d.ts +0 -2
- package/lib/nodes/combinator.d.ts +0 -2
- package/lib/nodes/comment.d.ts +0 -2
- package/lib/nodes/condition.d.ts +0 -2
- package/lib/nodes/declaration.d.ts +0 -2
- package/lib/nodes/dimension.d.ts +0 -2
- package/lib/nodes/expression.d.ts +0 -2
- package/lib/nodes/extend.d.ts +0 -2
- package/lib/nodes/import.d.ts +0 -2
- package/lib/nodes/index.d.ts +0 -45
- package/lib/nodes/keyword.d.ts +0 -2
- package/lib/nodes/list.d.ts +0 -3
- package/lib/nodes/mixin.d.ts +0 -2
- package/lib/nodes/negative.d.ts +0 -2
- package/lib/nodes/operation.d.ts +0 -2
- package/lib/nodes/paren.d.ts +0 -2
- package/lib/nodes/quoted.d.ts +0 -2
- package/lib/nodes/reference.d.ts +0 -2
- package/lib/nodes/ruleset.d.ts +0 -2
- package/lib/nodes/selector.d.ts +0 -3
- package/lib/nodes/sequence.d.ts +0 -2
- package/lib/nodes/url.d.ts +0 -2
- package/lib/nodes/var-declaration.d.ts +0 -2
- package/lib/plugin-utils.d.ts +0 -20
- package/lib/transform/adapter.d.ts +0 -31
- package/lib/transform/from-less.d.ts +0 -30
- package/lib/transform/index.cjs +0 -13
- package/lib/transform/index.d.ts +0 -7
- package/lib/transform/index.js +0 -3
- package/lib/transform/less-adapter.d.ts +0 -29
- package/lib/transform/to-less.d.ts +0 -17
- package/lib/transform/type-map.d.ts +0 -27
- package/lib/transform.cjs +0 -1045
- package/lib/transform.js +0 -1015
- package/lib/types.d.ts +0 -158
package/README.md
CHANGED
|
@@ -1,140 +1,52 @@
|
|
|
1
1
|
# @jesscss/plugin-less-compat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**An AST-v2 native-function contribution package.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Jess](https://github.com/jesscss/jess) accepts typed AST-v2 `Fn` values here.
|
|
6
|
+
The public compiler does **not** support Less 4 visitors, `functionRegistry`
|
|
7
|
+
callbacks, `@plugin` scripts, post-processors, or conversion between Less tree
|
|
8
|
+
nodes and Jess values.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
## How it works
|
|
8
11
|
|
|
9
|
-
- **
|
|
10
|
-
|
|
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
|
|
12
|
+
- **Native functions only** — pass `Fn` values from `@jesscss/core/value`; their
|
|
13
|
+
bodies receive typed values and `FnCtx` capabilities.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- Contributing improvements if you find this package useful
|
|
17
|
-
- Creating your own compatibility layer tailored to your specific needs
|
|
15
|
+
For example, migrate a Less `functionRegistry.add('increment', fn)` contribution
|
|
16
|
+
to a typed function and register it through `functions`:
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
```ts
|
|
19
|
+
import { Compiler } from 'jess';
|
|
20
|
+
import { defineFunction, makeDimension } from '@jesscss/core/value';
|
|
21
|
+
import lessCompatPlugin from '@jesscss/plugin-less-compat';
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
]
|
|
23
|
+
const increment = defineFunction('increment', {
|
|
24
|
+
params: [{ kinds: ['Dimension'] }] as const,
|
|
25
|
+
body: value => makeDimension(value.number + 1, value.unit)
|
|
50
26
|
});
|
|
51
27
|
|
|
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
28
|
const compiler = new Compiler({
|
|
79
|
-
plugins: [
|
|
80
|
-
lessPlugin(),
|
|
81
|
-
lessCompatPlugin({
|
|
82
|
-
visitors: [
|
|
83
|
-
autoprefix,
|
|
84
|
-
cleanCSS
|
|
85
|
-
]
|
|
86
|
-
})
|
|
87
|
-
]
|
|
29
|
+
compile: { plugins: [lessCompatPlugin({ functions: [increment] })] }
|
|
88
30
|
});
|
|
89
31
|
```
|
|
90
32
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
Current design notes live in [DESIGN.md](./DESIGN.md). Older transition notes
|
|
132
|
-
were removed from the working tree; use git history for archaeology.
|
|
33
|
+
The old `plugins`/`functionRegistry` option is not a compatibility shim: it is
|
|
34
|
+
not part of this package's public options. Legacy Less visitors, tree values,
|
|
35
|
+
and script-plugin hooks must be migrated to an AST-v2 plugin or run under
|
|
36
|
+
Less.js directly.
|
|
133
37
|
|
|
134
|
-
##
|
|
38
|
+
## Status
|
|
135
39
|
|
|
136
|
-
|
|
40
|
+
**Alpha / experimental.** The supported public route is native function
|
|
41
|
+
contribution only. If you need Less visitors, `functionRegistry`, script-plugin,
|
|
42
|
+
or post-processor support today, use Less.js directly.
|
|
137
43
|
|
|
138
|
-
|
|
44
|
+
The programmatic plugin/compiler API is **not yet stabilized** — the `jess` CLI
|
|
45
|
+
is the documented public surface for the alpha. Watch the
|
|
46
|
+
[docs site](https://jesscss.github.io/) for the API once it settles. Current
|
|
47
|
+
design notes live in [DESIGN.md](./DESIGN.md).
|
|
139
48
|
|
|
140
|
-
|
|
49
|
+
- Project overview & positioning: <https://github.com/jesscss/jess#readme>
|
|
50
|
+
- Docs: <https://jesscss.github.io/> (currently pre-alpha content)
|
|
51
|
+
- Issues: <https://github.com/jesscss/jess/issues>
|
|
52
|
+
- License: MIT
|