@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.
Files changed (49) hide show
  1. package/README.md +34 -122
  2. package/lib/index.cjs +13 -821
  3. package/lib/index.d.ts +0 -3
  4. package/lib/index.js +15 -786
  5. package/lib/plugin.d.ts +17 -109
  6. package/package.json +5 -15
  7. package/lib/less-adapter.cjs +0 -216
  8. package/lib/less-adapter.js +0 -181
  9. package/lib/less-compat-structures.cjs +0 -378
  10. package/lib/less-compat-structures.d.ts +0 -108
  11. package/lib/less-compat-structures.js +0 -374
  12. package/lib/nodes/at-rule.d.ts +0 -2
  13. package/lib/nodes/attribute-selector.d.ts +0 -2
  14. package/lib/nodes/call.d.ts +0 -2
  15. package/lib/nodes/color.d.ts +0 -2
  16. package/lib/nodes/combinator.d.ts +0 -2
  17. package/lib/nodes/comment.d.ts +0 -2
  18. package/lib/nodes/condition.d.ts +0 -2
  19. package/lib/nodes/declaration.d.ts +0 -2
  20. package/lib/nodes/dimension.d.ts +0 -2
  21. package/lib/nodes/expression.d.ts +0 -2
  22. package/lib/nodes/extend.d.ts +0 -2
  23. package/lib/nodes/import.d.ts +0 -2
  24. package/lib/nodes/index.d.ts +0 -45
  25. package/lib/nodes/keyword.d.ts +0 -2
  26. package/lib/nodes/list.d.ts +0 -3
  27. package/lib/nodes/mixin.d.ts +0 -2
  28. package/lib/nodes/negative.d.ts +0 -2
  29. package/lib/nodes/operation.d.ts +0 -2
  30. package/lib/nodes/paren.d.ts +0 -2
  31. package/lib/nodes/quoted.d.ts +0 -2
  32. package/lib/nodes/reference.d.ts +0 -2
  33. package/lib/nodes/ruleset.d.ts +0 -2
  34. package/lib/nodes/selector.d.ts +0 -3
  35. package/lib/nodes/sequence.d.ts +0 -2
  36. package/lib/nodes/url.d.ts +0 -2
  37. package/lib/nodes/var-declaration.d.ts +0 -2
  38. package/lib/plugin-utils.d.ts +0 -20
  39. package/lib/transform/adapter.d.ts +0 -31
  40. package/lib/transform/from-less.d.ts +0 -30
  41. package/lib/transform/index.cjs +0 -13
  42. package/lib/transform/index.d.ts +0 -7
  43. package/lib/transform/index.js +0 -3
  44. package/lib/transform/less-adapter.d.ts +0 -29
  45. package/lib/transform/to-less.d.ts +0 -17
  46. package/lib/transform/type-map.d.ts +0 -27
  47. package/lib/transform.cjs +0 -1045
  48. package/lib/transform.js +0 -1015
  49. package/lib/types.d.ts +0 -158
@@ -1,374 +0,0 @@
1
- import { t as LessAdapterBase } from "./less-adapter.js";
2
- //#region src/less-compat-structures.ts
3
- /**
4
- * Minimal Less.js-compatible structures for plugin compatibility
5
- * These are standalone implementations that don't require the actual Less.js library
6
- */
7
- /**
8
- * Less.js Visitor base class (minimal implementation)
9
- * Plugins expect this structure to exist
10
- */
11
- var LessVisitor = class {
12
- processingNodes = /* @__PURE__ */ new WeakSet();
13
- constructor(visitor) {
14
- this.visitor = visitor;
15
- }
16
- /**
17
- * Visit a node - handles both modern and legacy Less.js node types
18
- * Supports Less.js v2 "Directive" nodes (mapped to AtRule)
19
- *
20
- * In Less.js v2, at-rules were called "Directive" instead of "AtRule".
21
- * For compatibility, we route AtRule nodes to visitDirective() if that method exists,
22
- * allowing v2 plugins to work with modern AtRule nodes.
23
- */
24
- visit(node, visitArgs) {
25
- if (!node) return node;
26
- if (typeof node !== "object") return node;
27
- if (!this.visitor) return node;
28
- if (this.processingNodes.has(node)) return node;
29
- this.processingNodes.add(node);
30
- const args = visitArgs || { visitDeeper: true };
31
- if (args.visitDeeper === void 0) args.visitDeeper = true;
32
- const nodeType = node.type;
33
- if (!nodeType || typeof nodeType !== "string") {
34
- if (typeof this.visitor.visit === "function") {
35
- const result = this.visitor.visit(node, args);
36
- if (args.visitDeeper && node && node.accept) node.accept(this);
37
- return result;
38
- }
39
- return node;
40
- }
41
- const visitMethodName = `visit${nodeType}`;
42
- let result = node;
43
- let visitMethod;
44
- if (typeof this.visitor[visitMethodName] === "function") visitMethod = this.visitor[visitMethodName];
45
- else if (nodeType === "Directive" || nodeType === "AtRule") {
46
- if (typeof this.visitor.visitDirective === "function") visitMethod = this.visitor.visitDirective;
47
- else if (typeof this.visitor.visitAtRule === "function") visitMethod = this.visitor.visitAtRule;
48
- } else if (nodeType === "Rule") {
49
- if (typeof this.visitor.visitRule === "function") visitMethod = this.visitor.visitRule;
50
- else if (typeof this.visitor.visitDeclaration === "function") visitMethod = this.visitor.visitDeclaration;
51
- } else if (nodeType === "Reference") {
52
- if (typeof this.visitor.visitVariable === "function") visitMethod = this.visitor.visitVariable;
53
- else if (typeof this.visitor.visitReference === "function") visitMethod = this.visitor.visitReference;
54
- }
55
- if (visitMethod) {
56
- result = visitMethod.call(this.visitor, node, args);
57
- if (this.visitor.isReplacing && result !== void 0) node = result;
58
- } else if (typeof this.visitor.visit === "function") {
59
- result = this.visitor.visit(node, args);
60
- if (this.visitor.isReplacing && result !== void 0) node = result;
61
- }
62
- if (args.visitDeeper && node && node.accept) {
63
- if (node instanceof LessAdapterBase) node.accept(this);
64
- }
65
- return result;
66
- }
67
- /**
68
- * Visit array of nodes
69
- */
70
- visitArray(nodes, visitArgs) {
71
- if (!nodes) return nodes;
72
- return nodes.map((node) => this.visit(node, visitArgs));
73
- }
74
- /**
75
- * Visit Directive node (Less.js v2 compatibility)
76
- * Maps to AtRule for modern Less.js compatibility
77
- */
78
- visitDirective(node, visitArgs) {
79
- if (node && node.type === "Directive") {
80
- if (this.visitor && typeof this.visitor.visitDirective === "function") return this.visitor.visitDirective(node, visitArgs);
81
- if (this.visitor && typeof this.visitor.visitAtRule === "function") return this.visitor.visitAtRule(node, visitArgs);
82
- }
83
- return this.visit(node, visitArgs);
84
- }
85
- /**
86
- * Visit Rule node (Less.js v2 compatibility)
87
- * Maps to Declaration for modern Less.js compatibility
88
- */
89
- visitRule(node, visitArgs) {
90
- if (node && (node.type === "Rule" || node.type === "Declaration")) {
91
- if (this.visitor && typeof this.visitor.visitRule === "function") return this.visitor.visitRule(node, visitArgs);
92
- if (this.visitor && typeof this.visitor.visitDeclaration === "function") return this.visitor.visitDeclaration(node, visitArgs);
93
- }
94
- return this.visit(node, visitArgs);
95
- }
96
- };
97
- /**
98
- * Less.js PluginManager (minimal implementation)
99
- * Plugins use this to register visitors, pre/post processors, etc.
100
- */
101
- var LessPluginManager = class {
102
- visitors = [];
103
- preProcessors = [];
104
- postProcessors = [];
105
- constructor(less, newFactory) {
106
- this.less = less;
107
- this.newFactory = newFactory;
108
- }
109
- /**
110
- * Add a visitor to the manager
111
- */
112
- addVisitor(visitor) {
113
- this.visitors.push(visitor);
114
- }
115
- /**
116
- * Remove a visitor
117
- */
118
- removeVisitor(visitor) {
119
- const index = this.visitors.indexOf(visitor);
120
- if (index > -1) this.visitors.splice(index, 1);
121
- }
122
- /**
123
- * Add a pre-processor (runs before parsing)
124
- */
125
- addPreProcessor(preProcessor) {
126
- this.preProcessors.push(preProcessor);
127
- }
128
- /**
129
- * Add a post-processor (runs after compilation)
130
- */
131
- addPostProcessor(postProcessor) {
132
- this.postProcessors.push(postProcessor);
133
- }
134
- /**
135
- * Get all visitors
136
- */
137
- getVisitors() {
138
- return this.visitors;
139
- }
140
- /**
141
- * Get all pre-processors
142
- */
143
- getPreProcessors() {
144
- return this.preProcessors;
145
- }
146
- /**
147
- * Get all post-processors
148
- */
149
- getPostProcessors() {
150
- return this.postProcessors;
151
- }
152
- /**
153
- * Register a plugin (Less.js-compatible API)
154
- * Some plugins use this method instead of install()
155
- */
156
- registerPlugin(plugin, _options) {
157
- if (!plugin) return;
158
- if (typeof plugin.install === "function") plugin.install(this.less, this, this.less.functions.functionRegistry);
159
- if ((typeof plugin.visit === "function" || typeof plugin.visitRuleset === "function") && !this.visitors.includes(plugin)) this.addVisitor(plugin);
160
- }
161
- };
162
- /**
163
- * Less.js tree constructors (minimal implementations)
164
- * Plugins may access these via functionRegistry.Call, etc.
165
- */
166
- const LessTreeConstructors = {
167
- Anonymous: function(value, index, fileInfo) {
168
- return {
169
- type: "Anonymous",
170
- value,
171
- index: index || 0,
172
- fileInfo: fileInfo || {},
173
- accept: function(visitor) {
174
- return visitor.visit(this);
175
- },
176
- toCSS: function() {
177
- return String(value);
178
- }
179
- };
180
- },
181
- Quoted: function(quote, value, escaped, index, fileInfo) {
182
- return {
183
- type: "Quoted",
184
- quote,
185
- value,
186
- escaped: !!escaped,
187
- index: index || 0,
188
- fileInfo: fileInfo || {},
189
- accept: function(visitor) {
190
- return visitor.visit(this);
191
- },
192
- toCSS: function() {
193
- return `${quote}${String(value)}${quote}`;
194
- }
195
- };
196
- },
197
- DetachedRuleset: function(ruleset) {
198
- return {
199
- type: "DetachedRuleset",
200
- ruleset,
201
- accept: function(visitor) {
202
- return visitor.visit(this);
203
- }
204
- };
205
- },
206
- Call: function(name, args, index, fileInfo) {
207
- return {
208
- type: "Call",
209
- name,
210
- args: args || [],
211
- index: index || 0,
212
- fileInfo: fileInfo || {},
213
- value: null,
214
- accept: function(visitor) {
215
- return visitor.visit(this);
216
- }
217
- };
218
- },
219
- Variable: function(name, index, fileInfo) {
220
- return {
221
- type: "Variable",
222
- name,
223
- index: index || 0,
224
- fileInfo: fileInfo || {},
225
- value: null,
226
- accept: function(visitor) {
227
- return visitor.visit(this);
228
- }
229
- };
230
- },
231
- VariableCall: function(name, index, fileInfo) {
232
- return {
233
- type: "VariableCall",
234
- name,
235
- index: index || 0,
236
- fileInfo: fileInfo || {},
237
- value: null,
238
- accept: function(visitor) {
239
- return visitor.visit(this);
240
- }
241
- };
242
- },
243
- Ruleset: function(selectors, rules, strictImports, visibilityInfo, fileInfo) {
244
- return {
245
- type: "Ruleset",
246
- selectors: selectors || [],
247
- rules: rules || [],
248
- strictImports,
249
- visibilityInfo,
250
- fileInfo: fileInfo || {},
251
- accept: function(visitor) {
252
- return visitor.visit(this);
253
- }
254
- };
255
- },
256
- Declaration: function(name, value, index, fileInfo, variable, important) {
257
- return {
258
- type: "Declaration",
259
- name,
260
- value,
261
- index: index || 0,
262
- fileInfo: fileInfo || {},
263
- variable: variable || false,
264
- important: important || "",
265
- accept: function(visitor) {
266
- return visitor.visit(this);
267
- }
268
- };
269
- },
270
- Dimension: function(value, unit) {
271
- return {
272
- type: "Dimension",
273
- value,
274
- unit: unit || "",
275
- accept: function(visitor) {
276
- return visitor.visit(this);
277
- }
278
- };
279
- },
280
- Color: function(rgb, alpha) {
281
- let rgbArray;
282
- if (typeof rgb === "string") {
283
- const hex = rgb.replace(/^#/, "");
284
- rgbArray = (hex.length >= 6 ? hex.match(/.{2}/g) ?? [] : hex.split("").map((c) => c + c)).slice(0, 3).map((c) => parseInt(c, 16));
285
- } else rgbArray = rgb || [
286
- 0,
287
- 0,
288
- 0
289
- ];
290
- return {
291
- type: "Color",
292
- rgb: rgbArray,
293
- alpha: alpha !== void 0 ? alpha : 1,
294
- accept: function(visitor) {
295
- return visitor.visit(this);
296
- }
297
- };
298
- },
299
- Directive: function(name, value, rules, index, fileInfo) {
300
- return {
301
- type: "Directive",
302
- name: name || "",
303
- value: value || null,
304
- rules: rules || [],
305
- index: index || 0,
306
- fileInfo: fileInfo || {},
307
- isCharset: function() {
308
- return this.name === "@charset" || this.name === "charset";
309
- },
310
- isRulesetLike: function() {
311
- return this.rules && this.rules.length > 0;
312
- },
313
- accept: function(visitor) {
314
- if (visitor.visitDirective) return visitor.visitDirective(this);
315
- if (visitor.visitAtRule) return visitor.visitAtRule(this);
316
- return visitor.visit(this);
317
- }
318
- };
319
- },
320
- Rule: function(name, value, important, merge, index, fileInfo, inline, variable) {
321
- return {
322
- type: "Rule",
323
- name: name || "",
324
- value: value || null,
325
- important: important || "",
326
- merge: merge || false,
327
- index: index || 0,
328
- fileInfo: fileInfo || {},
329
- inline: inline || false,
330
- variable: variable !== void 0 ? variable : name && name.charAt && name.charAt(0) === "@",
331
- accept: function(visitor) {
332
- if (visitor.visitRule) return visitor.visitRule(this);
333
- if (visitor.visitDeclaration) return visitor.visitDeclaration(this);
334
- return visitor.visit(this);
335
- }
336
- };
337
- }
338
- };
339
- /**
340
- * Create a Less.js-compatible mock object
341
- * This provides the minimal structure that plugins expect
342
- */
343
- function createLessMock(functionRegistry) {
344
- return {
345
- visitors: { Visitor: LessVisitor },
346
- functions: { functionRegistry },
347
- tree: LessTreeConstructors,
348
- PluginLoader: class {},
349
- dimension(value, unit) {
350
- return LessTreeConstructors.Dimension(value, unit);
351
- },
352
- value(values) {
353
- return values;
354
- },
355
- declaration(name, value) {
356
- return LessTreeConstructors.Declaration(name, value);
357
- },
358
- ruleset(selector, rules) {
359
- return LessTreeConstructors.Ruleset([selector], rules);
360
- },
361
- detachedruleset(rulesetLike) {
362
- return LessTreeConstructors.DetachedRuleset(rulesetLike);
363
- },
364
- atrule(name, value) {
365
- return {
366
- type: "AtRule",
367
- name,
368
- value
369
- };
370
- }
371
- };
372
- }
373
- //#endregion
374
- export { LessPluginManager, LessTreeConstructors, LessVisitor, createLessMock };
@@ -1,2 +0,0 @@
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,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { Color } from '@jesscss/core';
2
- export declare const transformColorToLess: (jessNode: Color, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
1
- import { Combinator } from '@jesscss/core';
2
- export declare const transformCombinatorToLess: (jessNode: Combinator, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
1
- import { Comment } from '@jesscss/core';
2
- export declare const transformCommentToLess: (jessNode: Comment, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
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,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { Dimension, Num } from '@jesscss/core';
2
- export declare const transformDimensionToLess: (jessNode: Dimension | Num, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { Extend } from '@jesscss/core';
2
- export declare const transformExtendToLess: (jessNode: Extend, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
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;
@@ -1,45 +0,0 @@
1
- /**
2
- * Node transformer registry
3
- * Maps Jess node types to their Less transformation functions
4
- */
5
- import { Node, Ruleset, Declaration, Mixin, Dimension, Num, Color, Operation, Expression, Quoted, Url, Comment, AtRule, StyleImport, Extend, Condition, Paren, Negative, List, VarDeclaration, Keyword, Combinator, AttributeSelector, Call, Selector, SelectorList, Reference, Sequence } from '@jesscss/core';
6
- import type { LessNode } from '../types.js';
7
- export type NodeTransformer = (jessNode: Node, cache?: WeakMap<any, any>) => LessNode;
8
- export declare function isRuleset(node: Node): node is Ruleset;
9
- export declare function isDeclaration(node: Node): node is Declaration;
10
- export declare function isMixin(node: Node): node is Mixin;
11
- export declare function isDimension(node: Node): node is Dimension;
12
- export declare function isNum(node: Node): node is Num;
13
- export declare function isColor(node: Node): node is Color;
14
- export declare function isOperation(node: Node): node is Operation;
15
- export declare function isExpression(node: Node): node is Expression;
16
- export declare function isSequence(node: Node): node is Sequence;
17
- export declare function isQuoted(node: Node): node is Quoted;
18
- export declare function isUrl(node: Node): node is Url;
19
- export declare function isComment(node: Node): node is Comment;
20
- export declare function isAtRule(node: Node): node is AtRule;
21
- export declare function isStyleImport(node: Node): node is StyleImport;
22
- export declare function isExtend(node: Node): node is Extend;
23
- export declare function isCondition(node: Node): node is Condition;
24
- export declare function isParen(node: Node): node is Paren;
25
- export declare function isNegative(node: Node): node is Negative;
26
- export declare function isList(node: Node): node is List;
27
- export declare function isVarDeclaration(node: Node): node is VarDeclaration;
28
- export declare function isKeyword(node: Node): node is Keyword;
29
- export declare function isCombinator(node: Node): node is Combinator;
30
- export declare function isAttributeSelector(node: Node): node is AttributeSelector;
31
- export declare function isCall(node: Node): node is Call;
32
- export declare function isSelector(node: Node): node is Selector | SelectorList;
33
- export declare function isReference(node: Node): node is Reference;
34
- /**
35
- * Get the transformer for a Jess node type
36
- */
37
- export declare function getTransformer(nodeType: string): NodeTransformer | undefined;
38
- /**
39
- * Check if a transformer exists for a node type
40
- */
41
- export declare function hasTransformer(nodeType: string): boolean;
42
- /**
43
- * Register a new transformer
44
- */
45
- export declare function registerTransformer(nodeType: string, transformer: NodeTransformer): void;
@@ -1,2 +0,0 @@
1
- import { Keyword } from '@jesscss/core';
2
- export declare const transformKeywordToLess: (jessNode: Keyword, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,3 +0,0 @@
1
- import { List, Node } from '@jesscss/core';
2
- import type { LessNode } from '../types.js';
3
- export declare const transformListToLess: (jessNode: List, cache?: WeakMap<Node, LessNode>) => LessNode;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { Quoted } from '@jesscss/core';
2
- export declare const transformQuotedToLess: (jessNode: Quoted, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
1
- import { Reference } from '@jesscss/core';
2
- export declare const transformReferenceToLess: (jessNode: Reference, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- import { Node, type SelectorLike } from '@jesscss/core';
2
- import type { LessNode } from '../types.js';
3
- export declare function transformSelectorToLess(sel: SelectorLike, cache?: WeakMap<Node, unknown>): LessNode;
@@ -1,2 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { Url } from '@jesscss/core';
2
- export declare const transformUrlToLess: (jessNode: Url, cache?: WeakMap<import("@jesscss/core").Node, import("../types.js").LessNode>) => import("../types.js").LessNode;
@@ -1,2 +0,0 @@
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;
@@ -1,20 +0,0 @@
1
- /**
2
- * Utilities for working with Less.js plugins in Jess
3
- */
4
- import type { PluginInterface } from '@jesscss/core';
5
- /**
6
- * Detect if a plugin is a Less.js plugin
7
- */
8
- export declare function isLessPlugin(plugin: any): boolean;
9
- /**
10
- * Detect if a plugin is a Jess plugin
11
- */
12
- export declare function isJessPlugin(plugin: any): plugin is PluginInterface;
13
- /**
14
- * Filter and separate Less plugins from Jess plugins
15
- * This allows mixed plugin arrays to be handled correctly
16
- */
17
- export declare function filterPlugins(plugins: any[]): {
18
- lessPlugins: any[];
19
- jessPlugins: PluginInterface[];
20
- };
@@ -1,31 +0,0 @@
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 {};
@@ -1,30 +0,0 @@
1
- import { Node, Rules } from '@jesscss/core';
2
- export type LessNode = any;
3
- export interface FromLessOptions {
4
- /** Cache conversions to avoid repeated work */
5
- cache?: WeakMap<any, Node>;
6
- /** When true, boolean return values are treated as "no output" (Less statement context) */
7
- statementContext?: boolean;
8
- }
9
- /**
10
- * Convert a Less node back to a Jess node
11
- *
12
- * @param lessNode - The Less node to convert
13
- * @param options - Conversion options
14
- * @returns A Jess node
15
- */
16
- export declare function fromLessNode(lessNode: LessNode, options?: FromLessOptions): Node;
17
- /**
18
- * Convert a Less plugin function return value to a Jess node.
19
- * Handles primitives (number, boolean), Less nodes (via fromLessNode), and toCSS() objects.
20
- * Use this for @plugin-loaded function results so conversion is centralized here.
21
- */
22
- export declare function fromLessPluginReturnValue(value: unknown, options?: FromLessOptions): Node | undefined;
23
- /**
24
- * Convert an entire Less tree back to Jess Rules
25
- *
26
- * @param lessTree - The Less tree to convert
27
- * @param options - Conversion options
28
- * @returns A Jess Rules tree
29
- */
30
- export declare function fromLessTree(lessTree: LessNode, _options?: FromLessOptions): Rules;
@@ -1,13 +0,0 @@
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;
@@ -1,7 +0,0 @@
1
- /**
2
- * Transformation utilities for converting between Jess and Less AST nodes
3
- */
4
- export { toLessNode, toLessTree, type ToLessOptions } from './to-less.js';
5
- export { fromLessNode, fromLessPluginReturnValue, fromLessTree, type FromLessOptions } from './from-less.js';
6
- export { createLessAdapter, LessAdapterBase } from './less-adapter.js';
7
- export { mapJessTypeToLessType, mapLessTypeToJessType, getLessTypeIndex } from './type-map.js';
@@ -1,3 +0,0 @@
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 };