@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.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -0
  3. package/lib/index.d.ts +9 -0
  4. package/lib/index.js +10 -0
  5. package/lib/index.js.map +1 -0
  6. package/lib/less-compat-structures.d.ts +108 -0
  7. package/lib/less-compat-structures.js +519 -0
  8. package/lib/less-compat-structures.js.map +1 -0
  9. package/lib/nodes/at-rule.d.ts +6 -0
  10. package/lib/nodes/at-rule.js +72 -0
  11. package/lib/nodes/at-rule.js.map +1 -0
  12. package/lib/nodes/attribute-selector.d.ts +6 -0
  13. package/lib/nodes/attribute-selector.js +54 -0
  14. package/lib/nodes/attribute-selector.js.map +1 -0
  15. package/lib/nodes/call.d.ts +6 -0
  16. package/lib/nodes/call.js +83 -0
  17. package/lib/nodes/call.js.map +1 -0
  18. package/lib/nodes/color.d.ts +6 -0
  19. package/lib/nodes/color.js +57 -0
  20. package/lib/nodes/color.js.map +1 -0
  21. package/lib/nodes/combinator.d.ts +6 -0
  22. package/lib/nodes/combinator.js +34 -0
  23. package/lib/nodes/combinator.js.map +1 -0
  24. package/lib/nodes/comment.d.ts +6 -0
  25. package/lib/nodes/comment.js +41 -0
  26. package/lib/nodes/comment.js.map +1 -0
  27. package/lib/nodes/condition.d.ts +6 -0
  28. package/lib/nodes/condition.js +60 -0
  29. package/lib/nodes/condition.js.map +1 -0
  30. package/lib/nodes/declaration.d.ts +6 -0
  31. package/lib/nodes/declaration.js +81 -0
  32. package/lib/nodes/declaration.js.map +1 -0
  33. package/lib/nodes/dimension.d.ts +6 -0
  34. package/lib/nodes/dimension.js +47 -0
  35. package/lib/nodes/dimension.js.map +1 -0
  36. package/lib/nodes/expression.d.ts +6 -0
  37. package/lib/nodes/expression.js +44 -0
  38. package/lib/nodes/expression.js.map +1 -0
  39. package/lib/nodes/extend.d.ts +6 -0
  40. package/lib/nodes/extend.js +57 -0
  41. package/lib/nodes/extend.js.map +1 -0
  42. package/lib/nodes/import.d.ts +6 -0
  43. package/lib/nodes/import.js +63 -0
  44. package/lib/nodes/import.js.map +1 -0
  45. package/lib/nodes/index.d.ts +45 -0
  46. package/lib/nodes/index.js +308 -0
  47. package/lib/nodes/index.js.map +1 -0
  48. package/lib/nodes/keyword.d.ts +6 -0
  49. package/lib/nodes/keyword.js +36 -0
  50. package/lib/nodes/keyword.js.map +1 -0
  51. package/lib/nodes/list.d.ts +6 -0
  52. package/lib/nodes/list.js +150 -0
  53. package/lib/nodes/list.js.map +1 -0
  54. package/lib/nodes/mixin.d.ts +6 -0
  55. package/lib/nodes/mixin.js +62 -0
  56. package/lib/nodes/mixin.js.map +1 -0
  57. package/lib/nodes/negative.d.ts +6 -0
  58. package/lib/nodes/negative.js +42 -0
  59. package/lib/nodes/negative.js.map +1 -0
  60. package/lib/nodes/operation.d.ts +6 -0
  61. package/lib/nodes/operation.js +63 -0
  62. package/lib/nodes/operation.js.map +1 -0
  63. package/lib/nodes/paren.d.ts +6 -0
  64. package/lib/nodes/paren.js +42 -0
  65. package/lib/nodes/paren.js.map +1 -0
  66. package/lib/nodes/quoted.d.ts +6 -0
  67. package/lib/nodes/quoted.js +57 -0
  68. package/lib/nodes/quoted.js.map +1 -0
  69. package/lib/nodes/reference.d.ts +9 -0
  70. package/lib/nodes/reference.js +80 -0
  71. package/lib/nodes/reference.js.map +1 -0
  72. package/lib/nodes/ruleset.d.ts +6 -0
  73. package/lib/nodes/ruleset.js +108 -0
  74. package/lib/nodes/ruleset.js.map +1 -0
  75. package/lib/nodes/selector.d.ts +8 -0
  76. package/lib/nodes/selector.js +226 -0
  77. package/lib/nodes/selector.js.map +1 -0
  78. package/lib/nodes/sequence.d.ts +9 -0
  79. package/lib/nodes/sequence.js +75 -0
  80. package/lib/nodes/sequence.js.map +1 -0
  81. package/lib/nodes/url.d.ts +6 -0
  82. package/lib/nodes/url.js +42 -0
  83. package/lib/nodes/url.js.map +1 -0
  84. package/lib/nodes/var-declaration.d.ts +6 -0
  85. package/lib/nodes/var-declaration.js +60 -0
  86. package/lib/nodes/var-declaration.js.map +1 -0
  87. package/lib/plugin-utils.d.ts +20 -0
  88. package/lib/plugin-utils.js +100 -0
  89. package/lib/plugin-utils.js.map +1 -0
  90. package/lib/plugin.d.ts +92 -0
  91. package/lib/plugin.js +1027 -0
  92. package/lib/plugin.js.map +1 -0
  93. package/lib/transform/from-less.d.ts +30 -0
  94. package/lib/transform/from-less.js +170 -0
  95. package/lib/transform/from-less.js.map +1 -0
  96. package/lib/transform/index.d.ts +7 -0
  97. package/lib/transform/index.js +8 -0
  98. package/lib/transform/index.js.map +1 -0
  99. package/lib/transform/proxy.d.ts +32 -0
  100. package/lib/transform/proxy.js +138 -0
  101. package/lib/transform/proxy.js.map +1 -0
  102. package/lib/transform/to-less.d.ts +17 -0
  103. package/lib/transform/to-less.js +128 -0
  104. package/lib/transform/to-less.js.map +1 -0
  105. package/lib/transform/type-map.d.ts +27 -0
  106. package/lib/transform/type-map.js +105 -0
  107. package/lib/transform/type-map.js.map +1 -0
  108. package/lib/types.d.ts +33 -0
  109. package/lib/types.js +5 -0
  110. package/lib/types.js.map +1 -0
  111. package/package.json +56 -0
@@ -0,0 +1,57 @@
1
+ import { Selector } 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
+ import { fromLessNode } from '../transform/from-less.js';
6
+ /**
7
+ * Transform a Jess Extend to a Less-compatible Extend
8
+ */
9
+ export function transformExtendToLess(jessExtend, cache) {
10
+ return createLessProxy(jessExtend, cache, (prop, target) => {
11
+ const extend = target;
12
+ // Map 'type' property
13
+ if (prop === 'type') {
14
+ return mapJessTypeToLessType(extend.type);
15
+ }
16
+ // Map 'typeIndex'
17
+ if (prop === 'typeIndex') {
18
+ return undefined;
19
+ }
20
+ // Map 'selector' property
21
+ if (prop === 'selector') {
22
+ const selector = extend.value.selector;
23
+ if (selector instanceof Selector) {
24
+ return toLessNode(selector, { cache });
25
+ }
26
+ return selector;
27
+ }
28
+ // Map 'option' property (Less uses this for extend options)
29
+ // Jess uses 'flag' (ExtendFlag), Less uses 'option' string
30
+ if (prop === 'option') {
31
+ const flag = extend.value.flag;
32
+ // ExtendFlag.All = 0 (default), ExtendFlag.Exact = 1
33
+ return flag === 1 ? 'exact' : 'all';
34
+ }
35
+ // Map 'index' property
36
+ if (prop === 'index') {
37
+ const loc = extend.location;
38
+ if (Array.isArray(loc) || !loc) {
39
+ return undefined;
40
+ }
41
+ return loc.index;
42
+ }
43
+ // Map 'accept' method for visitor traversal
44
+ if (prop === 'accept') {
45
+ return function (visitor) {
46
+ const lessExtend = transformExtendToLess(extend, cache);
47
+ const result = visitor.visit(lessExtend);
48
+ if (result !== lessExtend) {
49
+ return fromLessNode(result, { cache });
50
+ }
51
+ return extend;
52
+ };
53
+ }
54
+ return undefined;
55
+ });
56
+ }
57
+ //# sourceMappingURL=extend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extend.js","sourceRoot":"","sources":["../../src/nodes/extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAkB,EAClB,KAAyB;IAEzB,OAAO,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACzD,MAAM,MAAM,GAAG,MAAgB,CAAC;QAEhC,sBAAsB;QACtB,IAAI,IAAI,KA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EAAE,CAAC;oBAC1B,OAAO,YAAY,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzC,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { StyleImport } from '@jesscss/core';
2
+ import type { LessNode } from '../types.js';
3
+ /**
4
+ * Transform a Jess StyleImport to a Less-compatible Import
5
+ */
6
+ export declare function transformImportToLess(jessImport: StyleImport, cache?: WeakMap<any, any>): LessNode;
@@ -0,0 +1,63 @@
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
+ import { fromLessNode } from '../transform/from-less.js';
6
+ /**
7
+ * Transform a Jess StyleImport to a Less-compatible Import
8
+ */
9
+ export function transformImportToLess(jessImport, cache) {
10
+ return createLessProxy(jessImport, cache, (prop, target) => {
11
+ const imp = target;
12
+ // Map 'type' property
13
+ if (prop === 'type') {
14
+ return mapJessTypeToLessType(imp.type);
15
+ }
16
+ // Map 'typeIndex'
17
+ if (prop === 'typeIndex') {
18
+ return undefined;
19
+ }
20
+ // Map 'path' property
21
+ if (prop === 'path') {
22
+ const path = imp.value.path;
23
+ if (path instanceof Node) {
24
+ return toLessNode(path, { cache });
25
+ }
26
+ return path;
27
+ }
28
+ // Map 'options' property (Less uses this for import options)
29
+ // Jess stores import options in options.importOptions
30
+ if (prop === 'options') {
31
+ return imp.options?.importOptions || {};
32
+ }
33
+ // Map 'currentFileInfo' property
34
+ if (prop === 'currentFileInfo') {
35
+ const loc = imp.location;
36
+ if (Array.isArray(loc)) {
37
+ return {};
38
+ }
39
+ return loc || {};
40
+ }
41
+ // Map 'index' property
42
+ if (prop === 'index') {
43
+ const loc = imp.location;
44
+ if (Array.isArray(loc) || !loc) {
45
+ return undefined;
46
+ }
47
+ return loc.index;
48
+ }
49
+ // Map 'accept' method for visitor traversal
50
+ if (prop === 'accept') {
51
+ return function (visitor) {
52
+ const lessImport = transformImportToLess(imp, cache);
53
+ const result = visitor.visit(lessImport);
54
+ if (result !== lessImport) {
55
+ return fromLessNode(result, { cache });
56
+ }
57
+ return imp;
58
+ };
59
+ }
60
+ return undefined;
61
+ });
62
+ }
63
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/nodes/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAuB,EACvB,KAAyB;IAEzB,OAAO,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACzD,MAAM,GAAG,GAAG,MAAqB,CAAC;QAElC,sBAAsB;QACtB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QAED,kBAAkB;QAClB,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,sBAAsB;QACtB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAC5B,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;gBACzB,OAAO,UAAU,CAAC,IAAI,EAAE,EAAE,KAA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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;
@@ -0,0 +1,308 @@
1
+ /**
2
+ * Node transformer registry
3
+ * Maps Jess node types to their Less transformation functions
4
+ */
5
+ import { transformRulesetToLess } from './ruleset.js';
6
+ import { transformDeclarationToLess } from './declaration.js';
7
+ import { transformMixinToLess } from './mixin.js';
8
+ import { transformDimensionToLess } from './dimension.js';
9
+ import { transformColorToLess } from './color.js';
10
+ import { transformOperationToLess } from './operation.js';
11
+ import { transformExpressionToLess } from './expression.js';
12
+ import { transformSequenceToLess } from './sequence.js';
13
+ import { transformQuotedToLess } from './quoted.js';
14
+ import { transformUrlToLess } from './url.js';
15
+ import { transformCommentToLess } from './comment.js';
16
+ import { transformAtRuleToLess } from './at-rule.js';
17
+ import { transformImportToLess } from './import.js';
18
+ import { transformExtendToLess } from './extend.js';
19
+ import { transformConditionToLess } from './condition.js';
20
+ import { transformParenToLess } from './paren.js';
21
+ import { transformNegativeToLess } from './negative.js';
22
+ import { transformListToLess } from './list.js';
23
+ import { transformVarDeclarationToLess } from './var-declaration.js';
24
+ import { transformKeywordToLess } from './keyword.js';
25
+ import { transformCombinatorToLess } from './combinator.js';
26
+ import { transformAttributeSelectorToLess } from './attribute-selector.js';
27
+ import { transformCallToLess } from './call.js';
28
+ import { transformSelectorToLess } from './selector.js';
29
+ import { transformReferenceToLess } from './reference.js';
30
+ // Type guards for specific node types
31
+ export function isRuleset(node) {
32
+ return node.type === 'Ruleset';
33
+ }
34
+ export function isDeclaration(node) {
35
+ return node.type === 'Declaration';
36
+ }
37
+ export function isMixin(node) {
38
+ return node.type === 'Mixin';
39
+ }
40
+ export function isDimension(node) {
41
+ return node.type === 'Dimension';
42
+ }
43
+ export function isNum(node) {
44
+ return node.type === 'Num';
45
+ }
46
+ export function isColor(node) {
47
+ return node.type === 'Color';
48
+ }
49
+ export function isOperation(node) {
50
+ return node.type === 'Operation';
51
+ }
52
+ export function isExpression(node) {
53
+ return node.type === 'Expression';
54
+ }
55
+ export function isSequence(node) {
56
+ return node.type === 'Sequence';
57
+ }
58
+ export function isQuoted(node) {
59
+ return node.type === 'Quoted';
60
+ }
61
+ export function isUrl(node) {
62
+ return node.type === 'Url';
63
+ }
64
+ export function isComment(node) {
65
+ return node.type === 'Comment';
66
+ }
67
+ export function isAtRule(node) {
68
+ return node.type === 'AtRule';
69
+ }
70
+ export function isStyleImport(node) {
71
+ return node.type === 'StyleImport';
72
+ }
73
+ export function isExtend(node) {
74
+ return node.type === 'Extend';
75
+ }
76
+ export function isCondition(node) {
77
+ return node.type === 'Condition';
78
+ }
79
+ export function isParen(node) {
80
+ return node.type === 'Paren';
81
+ }
82
+ export function isNegative(node) {
83
+ return node.type === 'Negative';
84
+ }
85
+ export function isList(node) {
86
+ return node.type === 'List';
87
+ }
88
+ export function isVarDeclaration(node) {
89
+ return node.type === 'VarDeclaration';
90
+ }
91
+ export function isKeyword(node) {
92
+ return node.type === 'Keyword';
93
+ }
94
+ export function isCombinator(node) {
95
+ return node.type === 'Combinator';
96
+ }
97
+ export function isAttributeSelector(node) {
98
+ return node.type === 'AttributeSelector';
99
+ }
100
+ export function isCall(node) {
101
+ return node.type === 'Call';
102
+ }
103
+ export function isSelector(node) {
104
+ return node.type === 'SelectorList' || node.type === 'ComplexSelector'
105
+ || node.type === 'CompoundSelector' || node.type === 'BasicSelector';
106
+ }
107
+ export function isReference(node) {
108
+ return node.type === 'Reference';
109
+ }
110
+ /**
111
+ * Registry of node transformers
112
+ */
113
+ const transformers = new Map();
114
+ // Register all transformers
115
+ transformers.set('Ruleset', (node, cache) => {
116
+ if (isRuleset(node)) {
117
+ return transformRulesetToLess(node, cache);
118
+ }
119
+ throw new Error(`Expected Ruleset node, got ${node.type}`);
120
+ });
121
+ transformers.set('Declaration', (node, cache) => {
122
+ if (isDeclaration(node)) {
123
+ return transformDeclarationToLess(node, cache);
124
+ }
125
+ throw new Error(`Expected Declaration node, got ${node.type}`);
126
+ });
127
+ transformers.set('Mixin', (node, cache) => {
128
+ if (isMixin(node)) {
129
+ return transformMixinToLess(node, cache);
130
+ }
131
+ throw new Error(`Expected Mixin node, got ${node.type}`);
132
+ });
133
+ transformers.set('Dimension', (node, cache) => {
134
+ if (isDimension(node)) {
135
+ return transformDimensionToLess(node, cache);
136
+ }
137
+ throw new Error(`Expected Dimension node, got ${node.type}`);
138
+ });
139
+ transformers.set('Num', (node, cache) => {
140
+ if (isNum(node)) {
141
+ return transformDimensionToLess(node, cache);
142
+ }
143
+ throw new Error(`Expected Num node, got ${node.type}`);
144
+ });
145
+ transformers.set('Color', (node, cache) => {
146
+ if (isColor(node)) {
147
+ return transformColorToLess(node, cache);
148
+ }
149
+ throw new Error(`Expected Color node, got ${node.type}`);
150
+ });
151
+ transformers.set('Operation', (node, cache) => {
152
+ if (isOperation(node)) {
153
+ return transformOperationToLess(node, cache);
154
+ }
155
+ throw new Error(`Expected Operation node, got ${node.type}`);
156
+ });
157
+ transformers.set('Expression', (node, cache) => {
158
+ if (isExpression(node)) {
159
+ return transformExpressionToLess(node, cache);
160
+ }
161
+ throw new Error(`Expected Expression node, got ${node.type}`);
162
+ });
163
+ transformers.set('Sequence', (node, cache) => {
164
+ if (isSequence(node)) {
165
+ return transformSequenceToLess(node, cache);
166
+ }
167
+ throw new Error(`Expected Sequence node, got ${node.type}`);
168
+ });
169
+ transformers.set('Quoted', (node, cache) => {
170
+ if (isQuoted(node)) {
171
+ return transformQuotedToLess(node, cache);
172
+ }
173
+ throw new Error(`Expected Quoted node, got ${node.type}`);
174
+ });
175
+ transformers.set('Url', (node, cache) => {
176
+ if (isUrl(node)) {
177
+ return transformUrlToLess(node, cache);
178
+ }
179
+ throw new Error(`Expected Url node, got ${node.type}`);
180
+ });
181
+ transformers.set('Comment', (node, cache) => {
182
+ if (isComment(node)) {
183
+ return transformCommentToLess(node, cache);
184
+ }
185
+ throw new Error(`Expected Comment node, got ${node.type}`);
186
+ });
187
+ transformers.set('AtRule', (node, cache) => {
188
+ if (isAtRule(node)) {
189
+ return transformAtRuleToLess(node, cache);
190
+ }
191
+ throw new Error(`Expected AtRule node, got ${node.type}`);
192
+ });
193
+ transformers.set('StyleImport', (node, cache) => {
194
+ if (isStyleImport(node)) {
195
+ return transformImportToLess(node, cache);
196
+ }
197
+ throw new Error(`Expected StyleImport node, got ${node.type}`);
198
+ });
199
+ transformers.set('Extend', (node, cache) => {
200
+ if (isExtend(node)) {
201
+ return transformExtendToLess(node, cache);
202
+ }
203
+ throw new Error(`Expected Extend node, got ${node.type}`);
204
+ });
205
+ transformers.set('Condition', (node, cache) => {
206
+ if (isCondition(node)) {
207
+ return transformConditionToLess(node, cache);
208
+ }
209
+ throw new Error(`Expected Condition node, got ${node.type}`);
210
+ });
211
+ transformers.set('Paren', (node, cache) => {
212
+ if (isParen(node)) {
213
+ return transformParenToLess(node, cache);
214
+ }
215
+ throw new Error(`Expected Paren node, got ${node.type}`);
216
+ });
217
+ transformers.set('Negative', (node, cache) => {
218
+ if (isNegative(node)) {
219
+ return transformNegativeToLess(node, cache);
220
+ }
221
+ throw new Error(`Expected Negative node, got ${node.type}`);
222
+ });
223
+ transformers.set('List', (node, cache) => {
224
+ if (isList(node)) {
225
+ return transformListToLess(node, cache);
226
+ }
227
+ throw new Error(`Expected List node, got ${node.type}`);
228
+ });
229
+ transformers.set('VarDeclaration', (node, cache) => {
230
+ if (isVarDeclaration(node)) {
231
+ return transformVarDeclarationToLess(node, cache);
232
+ }
233
+ throw new Error(`Expected VarDeclaration node, got ${node.type}`);
234
+ });
235
+ transformers.set('Keyword', (node, cache) => {
236
+ if (isKeyword(node)) {
237
+ return transformKeywordToLess(node, cache);
238
+ }
239
+ throw new Error(`Expected Keyword node, got ${node.type}`);
240
+ });
241
+ transformers.set('Combinator', (node, cache) => {
242
+ if (isCombinator(node)) {
243
+ return transformCombinatorToLess(node, cache);
244
+ }
245
+ throw new Error(`Expected Combinator node, got ${node.type}`);
246
+ });
247
+ transformers.set('AttributeSelector', (node, cache) => {
248
+ if (isAttributeSelector(node)) {
249
+ return transformAttributeSelectorToLess(node, cache);
250
+ }
251
+ throw new Error(`Expected AttributeSelector node, got ${node.type}`);
252
+ });
253
+ transformers.set('Call', (node, cache) => {
254
+ if (isCall(node)) {
255
+ return transformCallToLess(node, cache);
256
+ }
257
+ throw new Error(`Expected Call node, got ${node.type}`);
258
+ });
259
+ // Selector types
260
+ transformers.set('SelectorList', (node, cache) => {
261
+ if (isSelector(node)) {
262
+ return transformSelectorToLess(node, cache);
263
+ }
264
+ throw new Error(`Expected Selector node, got ${node.type}`);
265
+ });
266
+ transformers.set('ComplexSelector', (node, cache) => {
267
+ if (isSelector(node)) {
268
+ return transformSelectorToLess(node, cache);
269
+ }
270
+ throw new Error(`Expected Selector node, got ${node.type}`);
271
+ });
272
+ transformers.set('CompoundSelector', (node, cache) => {
273
+ if (isSelector(node)) {
274
+ return transformSelectorToLess(node, cache);
275
+ }
276
+ throw new Error(`Expected Selector node, got ${node.type}`);
277
+ });
278
+ transformers.set('BasicSelector', (node, cache) => {
279
+ if (isSelector(node)) {
280
+ return transformSelectorToLess(node, cache);
281
+ }
282
+ throw new Error(`Expected Selector node, got ${node.type}`);
283
+ });
284
+ transformers.set('Reference', (node, cache) => {
285
+ if (isReference(node)) {
286
+ return transformReferenceToLess(node, cache);
287
+ }
288
+ throw new Error(`Expected Reference node, got ${node.type}`);
289
+ });
290
+ /**
291
+ * Get the transformer for a Jess node type
292
+ */
293
+ export function getTransformer(nodeType) {
294
+ return transformers.get(nodeType);
295
+ }
296
+ /**
297
+ * Check if a transformer exists for a node type
298
+ */
299
+ export function hasTransformer(nodeType) {
300
+ return transformers.has(nodeType);
301
+ }
302
+ /**
303
+ * Register a new transformer
304
+ */
305
+ export function registerTransformer(nodeType, transformer) {
306
+ transformers.set(nodeType, transformer);
307
+ }
308
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","s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AAC,CAAC;AAC9D,CAAC,CAAC,CAAC;AAEH,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IAC5C,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,wBAAwB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,WAA4B;IAE5B,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Keyword } from '@jesscss/core';
2
+ import type { LessNode } from '../types.js';
3
+ /**
4
+ * Transform a Jess Keyword to a Less-compatible Keyword
5
+ */
6
+ export declare function transformKeywordToLess(jessKeyword: Keyword, cache?: WeakMap<any, any>): LessNode;
@@ -0,0 +1,36 @@
1
+ import { createLessProxy } from '../transform/proxy.js';
2
+ import { mapJessTypeToLessType } from '../transform/type-map.js';
3
+ import { fromLessNode } from '../transform/from-less.js';
4
+ /**
5
+ * Transform a Jess Keyword to a Less-compatible Keyword
6
+ */
7
+ export function transformKeywordToLess(jessKeyword, cache) {
8
+ return createLessProxy(jessKeyword, cache, (prop, target) => {
9
+ const keyword = target;
10
+ // Map 'type' property
11
+ if (prop === 'type') {
12
+ return mapJessTypeToLessType(keyword.type);
13
+ }
14
+ // Map 'typeIndex'
15
+ if (prop === 'typeIndex') {
16
+ return undefined;
17
+ }
18
+ // Map 'value' property
19
+ if (prop === 'value') {
20
+ return keyword.value;
21
+ }
22
+ // Map 'accept' method for visitor traversal
23
+ if (prop === 'accept') {
24
+ return function (visitor) {
25
+ const lessKeyword = transformKeywordToLess(keyword, cache);
26
+ const result = visitor.visit(lessKeyword);
27
+ if (result !== lessKeyword) {
28
+ return fromLessNode(result, { cache });
29
+ }
30
+ return keyword;
31
+ };
32
+ }
33
+ return undefined;
34
+ });
35
+ }
36
+ //# sourceMappingURL=keyword.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../src/nodes/keyword.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAoB,EACpB,KAAyB;IAEzB,OAAO,eAAe,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QAC1D,MAAM,OAAO,GAAG,MAAiB,CAAC;QAElC,sBAAsB;QACtB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,qBAAqB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;QAED,kBAAkB;QAClB,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,uBAAuB;QACvB,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,KAAK,CAAC;QACvB,CAAC;QAED,4CAA4C;QAC5C,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAO,UAAS,OAAY;gBAC1B,MAAM,WAAW,GAAG,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;gBAC1C,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;oBAC3B,OAAO,YAAY,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzC,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { List } from '@jesscss/core';
2
+ import type { LessNode } from '../types.js';
3
+ /**
4
+ * Transform a Jess List to a Less-compatible Value
5
+ */
6
+ export declare function transformListToLess(jessList: List, cache?: WeakMap<any, any>): LessNode;