@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
|
@@ -0,0 +1,519 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Less.js Visitor base class (minimal implementation)
|
|
7
|
+
* Plugins expect this structure to exist
|
|
8
|
+
*/
|
|
9
|
+
import { isLessProxy } from './transform/proxy.js';
|
|
10
|
+
export class LessVisitor {
|
|
11
|
+
visitor;
|
|
12
|
+
// Track nodes being processed to prevent infinite recursion
|
|
13
|
+
processingNodes = new WeakSet();
|
|
14
|
+
constructor(visitor) {
|
|
15
|
+
this.visitor = visitor;
|
|
16
|
+
// Some plugins pass a visitor instance
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Visit a node - handles both modern and legacy Less.js node types
|
|
20
|
+
* Supports Less.js v2 "Directive" nodes (mapped to AtRule)
|
|
21
|
+
*
|
|
22
|
+
* In Less.js v2, at-rules were called "Directive" instead of "AtRule".
|
|
23
|
+
* For compatibility, we route AtRule nodes to visitDirective() if that method exists,
|
|
24
|
+
* allowing v2 plugins to work with modern AtRule nodes.
|
|
25
|
+
*/
|
|
26
|
+
visit(node, visitArgs) {
|
|
27
|
+
if (!node) {
|
|
28
|
+
return node;
|
|
29
|
+
}
|
|
30
|
+
if (!this.visitor) {
|
|
31
|
+
return node;
|
|
32
|
+
}
|
|
33
|
+
// Prevent infinite recursion - if we're already processing this node, skip
|
|
34
|
+
if (this.processingNodes.has(node)) {
|
|
35
|
+
return node;
|
|
36
|
+
}
|
|
37
|
+
// Mark as processing
|
|
38
|
+
this.processingNodes.add(node);
|
|
39
|
+
// Initialize visitArgs if not provided (Less.js pattern)
|
|
40
|
+
const args = visitArgs || { visitDeeper: true };
|
|
41
|
+
if (args.visitDeeper === undefined) {
|
|
42
|
+
args.visitDeeper = true;
|
|
43
|
+
}
|
|
44
|
+
const nodeType = node.type;
|
|
45
|
+
if (!nodeType || typeof nodeType !== 'string') {
|
|
46
|
+
// Fallback to generic visit if no type
|
|
47
|
+
if (typeof this.visitor.visit === 'function') {
|
|
48
|
+
const result = this.visitor.visit(node, args);
|
|
49
|
+
// Traverse children if visitDeeper is true
|
|
50
|
+
if (args.visitDeeper && node && node.accept) {
|
|
51
|
+
node.accept(this);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
// Less.js Visitor pattern: look for visit${NodeType} method
|
|
58
|
+
// e.g., visitRuleset, visitDeclaration, visitMedia, etc.
|
|
59
|
+
const visitMethodName = `visit${nodeType}`;
|
|
60
|
+
let result = node;
|
|
61
|
+
let visitMethod;
|
|
62
|
+
if (typeof this.visitor[visitMethodName] === 'function') {
|
|
63
|
+
visitMethod = this.visitor[visitMethodName];
|
|
64
|
+
}
|
|
65
|
+
else if (nodeType === 'Directive' || nodeType === 'AtRule') {
|
|
66
|
+
// Handle Less.js v2 legacy: Directive -> AtRule
|
|
67
|
+
// Also handle AtRule -> visitDirective for v2 plugin compatibility
|
|
68
|
+
// Check visitDirective first (v2 plugins), then visitAtRule (modern plugins)
|
|
69
|
+
if (typeof this.visitor.visitDirective === 'function') {
|
|
70
|
+
visitMethod = this.visitor.visitDirective;
|
|
71
|
+
}
|
|
72
|
+
else if (typeof this.visitor.visitAtRule === 'function') {
|
|
73
|
+
visitMethod = this.visitor.visitAtRule;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (nodeType === 'Rule') {
|
|
77
|
+
// Handle Less.js v2 legacy: Rule -> Declaration
|
|
78
|
+
if (typeof this.visitor.visitRule === 'function') {
|
|
79
|
+
visitMethod = this.visitor.visitRule;
|
|
80
|
+
}
|
|
81
|
+
else if (typeof this.visitor.visitDeclaration === 'function') {
|
|
82
|
+
visitMethod = this.visitor.visitDeclaration;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (nodeType === 'Reference') {
|
|
86
|
+
// Reference -> Variable mapping
|
|
87
|
+
if (typeof this.visitor.visitVariable === 'function') {
|
|
88
|
+
visitMethod = this.visitor.visitVariable;
|
|
89
|
+
}
|
|
90
|
+
else if (typeof this.visitor.visitReference === 'function') {
|
|
91
|
+
visitMethod = this.visitor.visitReference;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Call the visit method if found
|
|
95
|
+
if (visitMethod) {
|
|
96
|
+
result = visitMethod.call(this.visitor, node, args);
|
|
97
|
+
// If visitor is replacing and returned a new node, use it
|
|
98
|
+
if (this.visitor.isReplacing && result !== undefined) {
|
|
99
|
+
node = result;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (typeof this.visitor.visit === 'function') {
|
|
103
|
+
// Fallback to generic visit method
|
|
104
|
+
result = this.visitor.visit(node, args);
|
|
105
|
+
if (this.visitor.isReplacing && result !== undefined) {
|
|
106
|
+
node = result;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Less.js pattern: after calling visit method, traverse children if visitDeeper is true
|
|
110
|
+
// This matches Less.js Visitor.visit() behavior
|
|
111
|
+
// CRITICAL: Only call accept() on Less proxies, NOT on Jess nodes
|
|
112
|
+
// Jess nodes' accept() calls visitor.visit() which would cause infinite recursion
|
|
113
|
+
// Less proxies' accept() methods only traverse children, they don't call visitor.visit()
|
|
114
|
+
if (args.visitDeeper && node && node.accept) {
|
|
115
|
+
const isProxy = isLessProxy(node);
|
|
116
|
+
// Only call accept() if this is a Less proxy
|
|
117
|
+
// Less proxies have accept() that traverses children without calling visit()
|
|
118
|
+
if (isProxy) {
|
|
119
|
+
node.accept(this);
|
|
120
|
+
}
|
|
121
|
+
// If it's not a Less proxy (it's a Jess node), we should NOT call accept()
|
|
122
|
+
// because Jess's accept() calls visitor.visit() which would recurse
|
|
123
|
+
// Instead, the plugin visitor's visit() method handles Jess node traversal
|
|
124
|
+
}
|
|
125
|
+
// Note: We keep the node in processingNodes for the entire visitor lifetime
|
|
126
|
+
// to prevent re-processing. The WeakSet will be garbage collected when done.
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Visit array of nodes
|
|
131
|
+
*/
|
|
132
|
+
visitArray(nodes, visitArgs) {
|
|
133
|
+
if (!nodes) {
|
|
134
|
+
return nodes;
|
|
135
|
+
}
|
|
136
|
+
return nodes.map(node => this.visit(node, visitArgs));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Visit Directive node (Less.js v2 compatibility)
|
|
140
|
+
* Maps to AtRule for modern Less.js compatibility
|
|
141
|
+
*/
|
|
142
|
+
visitDirective(node, visitArgs) {
|
|
143
|
+
// Convert Directive to AtRule-compatible format
|
|
144
|
+
// Less.js v2 used "Directive", modern versions use "AtRule"
|
|
145
|
+
if (node && node.type === 'Directive') {
|
|
146
|
+
// Try visitDirective first (v2 plugins)
|
|
147
|
+
if (this.visitor && typeof this.visitor.visitDirective === 'function') {
|
|
148
|
+
return this.visitor.visitDirective(node, visitArgs);
|
|
149
|
+
}
|
|
150
|
+
// Fallback to visitAtRule (modern plugins)
|
|
151
|
+
if (this.visitor && typeof this.visitor.visitAtRule === 'function') {
|
|
152
|
+
return this.visitor.visitAtRule(node, visitArgs);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Default to regular visit
|
|
156
|
+
return this.visit(node, visitArgs);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Visit Rule node (Less.js v2 compatibility)
|
|
160
|
+
* Maps to Declaration for modern Less.js compatibility
|
|
161
|
+
*/
|
|
162
|
+
visitRule(node, visitArgs) {
|
|
163
|
+
// Convert Rule to Declaration-compatible format
|
|
164
|
+
// Less.js v2 used "Rule", modern versions use "Declaration"
|
|
165
|
+
if (node && (node.type === 'Rule' || node.type === 'Declaration')) {
|
|
166
|
+
// Try visitRule first (v2 plugins)
|
|
167
|
+
if (this.visitor && typeof this.visitor.visitRule === 'function') {
|
|
168
|
+
return this.visitor.visitRule(node, visitArgs);
|
|
169
|
+
}
|
|
170
|
+
// Fallback to visitDeclaration (modern plugins)
|
|
171
|
+
if (this.visitor && typeof this.visitor.visitDeclaration === 'function') {
|
|
172
|
+
return this.visitor.visitDeclaration(node, visitArgs);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Default to regular visit
|
|
176
|
+
return this.visit(node, visitArgs);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Less.js PluginManager (minimal implementation)
|
|
181
|
+
* Plugins use this to register visitors, pre/post processors, etc.
|
|
182
|
+
*/
|
|
183
|
+
export class LessPluginManager {
|
|
184
|
+
less;
|
|
185
|
+
newFactory;
|
|
186
|
+
visitors = [];
|
|
187
|
+
preProcessors = [];
|
|
188
|
+
postProcessors = [];
|
|
189
|
+
constructor(less, newFactory) {
|
|
190
|
+
this.less = less;
|
|
191
|
+
this.newFactory = newFactory;
|
|
192
|
+
// Plugins expect this constructor signature
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Add a visitor to the manager
|
|
196
|
+
*/
|
|
197
|
+
addVisitor(visitor) {
|
|
198
|
+
this.visitors.push(visitor);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Remove a visitor
|
|
202
|
+
*/
|
|
203
|
+
removeVisitor(visitor) {
|
|
204
|
+
const index = this.visitors.indexOf(visitor);
|
|
205
|
+
if (index > -1) {
|
|
206
|
+
this.visitors.splice(index, 1);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Add a pre-processor (runs before parsing)
|
|
211
|
+
*/
|
|
212
|
+
addPreProcessor(preProcessor) {
|
|
213
|
+
this.preProcessors.push(preProcessor);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Add a post-processor (runs after compilation)
|
|
217
|
+
*/
|
|
218
|
+
addPostProcessor(postProcessor) {
|
|
219
|
+
this.postProcessors.push(postProcessor);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get all visitors
|
|
223
|
+
*/
|
|
224
|
+
getVisitors() {
|
|
225
|
+
return this.visitors;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get all pre-processors
|
|
229
|
+
*/
|
|
230
|
+
getPreProcessors() {
|
|
231
|
+
return this.preProcessors;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get all post-processors
|
|
235
|
+
*/
|
|
236
|
+
getPostProcessors() {
|
|
237
|
+
return this.postProcessors;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Register a plugin (Less.js-compatible API)
|
|
241
|
+
* Some plugins use this method instead of install()
|
|
242
|
+
*/
|
|
243
|
+
registerPlugin(plugin, _options) {
|
|
244
|
+
if (!plugin) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
// If plugin has install method, call it first
|
|
248
|
+
// The install method may add the visitor itself via addVisitor()
|
|
249
|
+
if (typeof plugin.install === 'function') {
|
|
250
|
+
plugin.install(this.less, this, this.less.functions.functionRegistry);
|
|
251
|
+
}
|
|
252
|
+
// If plugin is a visitor and not already added, add it
|
|
253
|
+
// Check if it's already in the visitors array to avoid duplicates
|
|
254
|
+
const isVisitor = typeof plugin.visit === 'function' || typeof plugin.visitRuleset === 'function';
|
|
255
|
+
if (isVisitor && !this.visitors.includes(plugin)) {
|
|
256
|
+
this.addVisitor(plugin);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Less.js tree constructors (minimal implementations)
|
|
262
|
+
* Plugins may access these via functionRegistry.Call, etc.
|
|
263
|
+
*/
|
|
264
|
+
export const LessTreeConstructors = {
|
|
265
|
+
/**
|
|
266
|
+
* Anonymous node constructor
|
|
267
|
+
*/
|
|
268
|
+
Anonymous: function (value, index, fileInfo) {
|
|
269
|
+
return {
|
|
270
|
+
type: 'Anonymous',
|
|
271
|
+
value,
|
|
272
|
+
index: index || 0,
|
|
273
|
+
fileInfo: fileInfo || {},
|
|
274
|
+
accept: function (visitor) {
|
|
275
|
+
return visitor.visit(this);
|
|
276
|
+
},
|
|
277
|
+
toCSS: function () {
|
|
278
|
+
return String(value);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
/**
|
|
283
|
+
* Quoted node constructor
|
|
284
|
+
*/
|
|
285
|
+
Quoted: function (quote, value, escaped, index, fileInfo) {
|
|
286
|
+
return {
|
|
287
|
+
type: 'Quoted',
|
|
288
|
+
quote,
|
|
289
|
+
value,
|
|
290
|
+
escaped: !!escaped,
|
|
291
|
+
index: index || 0,
|
|
292
|
+
fileInfo: fileInfo || {},
|
|
293
|
+
accept: function (visitor) {
|
|
294
|
+
return visitor.visit(this);
|
|
295
|
+
},
|
|
296
|
+
toCSS: function () {
|
|
297
|
+
return `${quote}${String(value)}${quote}`;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* DetachedRuleset node constructor
|
|
303
|
+
* Used by some Less.js plugins (e.g. test-data/plugin-tree-nodes.js)
|
|
304
|
+
*/
|
|
305
|
+
DetachedRuleset: function (ruleset) {
|
|
306
|
+
return {
|
|
307
|
+
type: 'DetachedRuleset',
|
|
308
|
+
ruleset,
|
|
309
|
+
accept: function (visitor) {
|
|
310
|
+
return visitor.visit(this);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
},
|
|
314
|
+
/**
|
|
315
|
+
* Call node constructor
|
|
316
|
+
*/
|
|
317
|
+
Call: function (name, args, index, fileInfo) {
|
|
318
|
+
return {
|
|
319
|
+
type: 'Call',
|
|
320
|
+
name,
|
|
321
|
+
args: args || [],
|
|
322
|
+
index: index || 0,
|
|
323
|
+
fileInfo: fileInfo || {},
|
|
324
|
+
value: null,
|
|
325
|
+
accept: function (visitor) {
|
|
326
|
+
return visitor.visit(this);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
},
|
|
330
|
+
/**
|
|
331
|
+
* Variable node constructor
|
|
332
|
+
*/
|
|
333
|
+
Variable: function (name, index, fileInfo) {
|
|
334
|
+
return {
|
|
335
|
+
type: 'Variable',
|
|
336
|
+
name,
|
|
337
|
+
index: index || 0,
|
|
338
|
+
fileInfo: fileInfo || {},
|
|
339
|
+
value: null,
|
|
340
|
+
accept: function (visitor) {
|
|
341
|
+
return visitor.visit(this);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
},
|
|
345
|
+
/**
|
|
346
|
+
* VariableCall node constructor
|
|
347
|
+
*/
|
|
348
|
+
VariableCall: function (name, index, fileInfo) {
|
|
349
|
+
return {
|
|
350
|
+
type: 'VariableCall',
|
|
351
|
+
name,
|
|
352
|
+
index: index || 0,
|
|
353
|
+
fileInfo: fileInfo || {},
|
|
354
|
+
value: null,
|
|
355
|
+
accept: function (visitor) {
|
|
356
|
+
return visitor.visit(this);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
},
|
|
360
|
+
/**
|
|
361
|
+
* Ruleset node constructor
|
|
362
|
+
*/
|
|
363
|
+
Ruleset: function (selectors, rules, strictImports, visibilityInfo, fileInfo) {
|
|
364
|
+
return {
|
|
365
|
+
type: 'Ruleset',
|
|
366
|
+
selectors: selectors || [],
|
|
367
|
+
rules: rules || [],
|
|
368
|
+
strictImports,
|
|
369
|
+
visibilityInfo,
|
|
370
|
+
fileInfo: fileInfo || {},
|
|
371
|
+
accept: function (visitor) {
|
|
372
|
+
return visitor.visit(this);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
},
|
|
376
|
+
/**
|
|
377
|
+
* Declaration node constructor
|
|
378
|
+
*/
|
|
379
|
+
Declaration: function (name, value, index, fileInfo, variable, important) {
|
|
380
|
+
return {
|
|
381
|
+
type: 'Declaration',
|
|
382
|
+
name,
|
|
383
|
+
value,
|
|
384
|
+
index: index || 0,
|
|
385
|
+
fileInfo: fileInfo || {},
|
|
386
|
+
variable: variable || false,
|
|
387
|
+
important: important || '',
|
|
388
|
+
accept: function (visitor) {
|
|
389
|
+
return visitor.visit(this);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
},
|
|
393
|
+
/**
|
|
394
|
+
* Dimension node constructor
|
|
395
|
+
*/
|
|
396
|
+
Dimension: function (value, unit) {
|
|
397
|
+
return {
|
|
398
|
+
type: 'Dimension',
|
|
399
|
+
value,
|
|
400
|
+
unit: unit || '',
|
|
401
|
+
accept: function (visitor) {
|
|
402
|
+
return visitor.visit(this);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* Color node constructor
|
|
408
|
+
*/
|
|
409
|
+
Color: function (rgb, alpha) {
|
|
410
|
+
return {
|
|
411
|
+
type: 'Color',
|
|
412
|
+
rgb: rgb || [0, 0, 0],
|
|
413
|
+
alpha: alpha !== undefined ? alpha : 1,
|
|
414
|
+
accept: function (visitor) {
|
|
415
|
+
return visitor.visit(this);
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
/**
|
|
420
|
+
* Directive node constructor (Less.js v2 compatibility)
|
|
421
|
+
* In Less.js v2, at-rules were called "Directive" instead of "AtRule"
|
|
422
|
+
* This creates an AtRule-compatible node for backward compatibility
|
|
423
|
+
*/
|
|
424
|
+
Directive: function (name, value, rules, index, fileInfo) {
|
|
425
|
+
return {
|
|
426
|
+
type: 'Directive', // Keep type as 'Directive' for v2 compatibility
|
|
427
|
+
name: name || '',
|
|
428
|
+
value: value || null,
|
|
429
|
+
rules: rules || [],
|
|
430
|
+
index: index || 0,
|
|
431
|
+
fileInfo: fileInfo || {},
|
|
432
|
+
// Less.js v2 Directive had these methods
|
|
433
|
+
isCharset: function () {
|
|
434
|
+
return this.name === '@charset' || this.name === 'charset';
|
|
435
|
+
},
|
|
436
|
+
isRulesetLike: function () {
|
|
437
|
+
return this.rules && this.rules.length > 0;
|
|
438
|
+
},
|
|
439
|
+
accept: function (visitor) {
|
|
440
|
+
// Map visitDirective to visitAtRule for compatibility
|
|
441
|
+
if (visitor.visitDirective) {
|
|
442
|
+
return visitor.visitDirective(this);
|
|
443
|
+
}
|
|
444
|
+
// Fallback to visitAtRule or generic visit
|
|
445
|
+
if (visitor.visitAtRule) {
|
|
446
|
+
return visitor.visitAtRule(this);
|
|
447
|
+
}
|
|
448
|
+
return visitor.visit(this);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
},
|
|
452
|
+
/**
|
|
453
|
+
* Rule node constructor (Less.js v2 compatibility)
|
|
454
|
+
* In Less.js v2, declarations were called "Rule" instead of "Declaration"
|
|
455
|
+
* This creates a Declaration-compatible node for backward compatibility
|
|
456
|
+
*/
|
|
457
|
+
Rule: function (name, value, important, merge, index, fileInfo, inline, variable) {
|
|
458
|
+
return {
|
|
459
|
+
type: 'Rule', // Keep type as 'Rule' for v2 compatibility
|
|
460
|
+
name: name || '',
|
|
461
|
+
value: value || null,
|
|
462
|
+
important: important || '',
|
|
463
|
+
merge: merge || false,
|
|
464
|
+
index: index || 0,
|
|
465
|
+
fileInfo: fileInfo || {},
|
|
466
|
+
inline: inline || false,
|
|
467
|
+
variable: variable !== undefined ? variable : (name && name.charAt && name.charAt(0) === '@'),
|
|
468
|
+
accept: function (visitor) {
|
|
469
|
+
// Map visitRule to visitDeclaration for compatibility
|
|
470
|
+
if (visitor.visitRule) {
|
|
471
|
+
return visitor.visitRule(this);
|
|
472
|
+
}
|
|
473
|
+
// Fallback to visitDeclaration or generic visit
|
|
474
|
+
if (visitor.visitDeclaration) {
|
|
475
|
+
return visitor.visitDeclaration(this);
|
|
476
|
+
}
|
|
477
|
+
return visitor.visit(this);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
/**
|
|
483
|
+
* Create a Less.js-compatible mock object
|
|
484
|
+
* This provides the minimal structure that plugins expect
|
|
485
|
+
*/
|
|
486
|
+
export function createLessMock(functionRegistry) {
|
|
487
|
+
return {
|
|
488
|
+
visitors: {
|
|
489
|
+
Visitor: LessVisitor
|
|
490
|
+
},
|
|
491
|
+
functions: {
|
|
492
|
+
functionRegistry
|
|
493
|
+
},
|
|
494
|
+
tree: LessTreeConstructors,
|
|
495
|
+
PluginLoader: class {
|
|
496
|
+
},
|
|
497
|
+
// Minimal Less.js function API used by Less.js test plugins
|
|
498
|
+
// These return "Less-like" nodes; Jess-side wrappers convert them as needed.
|
|
499
|
+
dimension(value, unit) {
|
|
500
|
+
return LessTreeConstructors.Dimension(value, unit);
|
|
501
|
+
},
|
|
502
|
+
value(values) {
|
|
503
|
+
return values;
|
|
504
|
+
},
|
|
505
|
+
declaration(name, value) {
|
|
506
|
+
return LessTreeConstructors.Declaration(name, value);
|
|
507
|
+
},
|
|
508
|
+
ruleset(selector, rules) {
|
|
509
|
+
return LessTreeConstructors.Ruleset([selector], rules);
|
|
510
|
+
},
|
|
511
|
+
detachedruleset(rulesetLike) {
|
|
512
|
+
return LessTreeConstructors.DetachedRuleset(rulesetLike);
|
|
513
|
+
},
|
|
514
|
+
atrule(name, value) {
|
|
515
|
+
return { type: 'AtRule', name, value };
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
//# sourceMappingURL=less-compat-structures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"less-compat-structures.js","sourceRoot":"","sources":["../src/less-compat-structures.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,OAAO,WAAW;IAIH;IAHnB,4DAA4D;IACpD,eAAe,GAAG,IAAI,OAAO,EAAO,CAAC;IAE7C,YAAmB,OAAa;QAAb,YAAO,GAAP,OAAO,CAAM;QAC9B,uCAAuC;IACzC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAS,EAAE,SAAe;QAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,2EAA2E;QAC3E,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE/B,yDAAyD;QACzD,MAAM,IAAI,GAAG,SAAS,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC9C,uCAAuC;YACvC,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;gBAC7C,MAAM,MAAM,GAA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CAAC,WAAgB;YAC9B,OAAO,oBAAoB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAC3D,CAAC;QACD,MAAM,CAAC,IAAY,EAAE,KAAU;YAC7B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACzC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Node } from '@jesscss/core';
|
|
2
|
+
import { createLessProxy } from '../transform/proxy.js';
|
|
3
|
+
import { toLessNode } from '../transform/to-less.js';
|
|
4
|
+
import { mapJessTypeToLessType } from '../transform/type-map.js';
|
|
5
|
+
/**
|
|
6
|
+
* Transform a Jess AtRule to a Less-compatible AtRule
|
|
7
|
+
*/
|
|
8
|
+
export function transformAtRuleToLess(jessAtRule, cache) {
|
|
9
|
+
return createLessProxy(jessAtRule, cache, (prop, target) => {
|
|
10
|
+
const atRule = target;
|
|
11
|
+
// Map 'type' property
|
|
12
|
+
// Less.js v2 used "Directive" instead of "AtRule" - support both for compatibility
|
|
13
|
+
if (prop === 'type') {
|
|
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);
|
|
17
|
+
}
|
|
18
|
+
// Map 'typeIndex'
|
|
19
|
+
if (prop === 'typeIndex') {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
// Map 'name' property
|
|
23
|
+
if (prop === 'name') {
|
|
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
|
+
}
|
|
72
|
+
//# sourceMappingURL=at-rule.js.map
|
|
@@ -0,0 +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,eAAe,EAAE,MAAM,uBAAuB,CAAC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C,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,4CAA4C;QAC5C,4FAA4F;QAC5F,wGAAwG;QACxG,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAO,UAAS,OAAY;gBAC1B,sDAAsD;gBACtD,kEAAkE;gBAClE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;gBACjC,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACnD,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAO,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;oBACzE,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;wBACvB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAChC,CAAC;yBAAM,CAAC;wBACN,qCAAqC;wBACrC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;4BACjC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;gCAChC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;4BAC3B,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,+DAA+D;gBAC/D,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AttributeSelector } from '@jesscss/core';
|
|
2
|
+
import type { LessNode } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Transform a Jess AttributeSelector to a Less-compatible Attribute
|
|
5
|
+
*/
|
|
6
|
+
export declare function transformAttributeSelectorToLess(jessAttr: AttributeSelector, cache?: WeakMap<any, any>): LessNode;
|