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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +3 -2
  2. package/lib/index.cjs +844 -0
  3. package/lib/index.d.ts +1 -0
  4. package/lib/index.js +800 -10
  5. package/lib/less-adapter.cjs +216 -0
  6. package/lib/less-adapter.js +181 -0
  7. package/lib/less-compat-structures.cjs +378 -0
  8. package/lib/less-compat-structures.d.ts +2 -2
  9. package/lib/less-compat-structures.js +367 -512
  10. package/lib/nodes/at-rule.d.ts +2 -2
  11. package/lib/nodes/attribute-selector.d.ts +2 -2
  12. package/lib/nodes/call.d.ts +2 -2
  13. package/lib/nodes/color.d.ts +2 -1
  14. package/lib/nodes/combinator.d.ts +2 -1
  15. package/lib/nodes/comment.d.ts +2 -1
  16. package/lib/nodes/condition.d.ts +2 -2
  17. package/lib/nodes/declaration.d.ts +2 -2
  18. package/lib/nodes/dimension.d.ts +2 -1
  19. package/lib/nodes/expression.d.ts +2 -2
  20. package/lib/nodes/extend.d.ts +2 -1
  21. package/lib/nodes/import.d.ts +2 -2
  22. package/lib/nodes/keyword.d.ts +2 -1
  23. package/lib/nodes/list.d.ts +3 -2
  24. package/lib/nodes/mixin.d.ts +2 -2
  25. package/lib/nodes/negative.d.ts +2 -2
  26. package/lib/nodes/operation.d.ts +2 -2
  27. package/lib/nodes/paren.d.ts +2 -2
  28. package/lib/nodes/quoted.d.ts +2 -1
  29. package/lib/nodes/reference.d.ts +2 -1
  30. package/lib/nodes/ruleset.d.ts +2 -2
  31. package/lib/nodes/selector.d.ts +2 -2
  32. package/lib/nodes/sequence.d.ts +2 -2
  33. package/lib/nodes/url.d.ts +2 -1
  34. package/lib/nodes/var-declaration.d.ts +2 -2
  35. package/lib/plugin.d.ts +44 -16
  36. package/lib/transform/adapter.d.ts +9 -11
  37. package/lib/transform/index.cjs +13 -0
  38. package/lib/transform/index.d.ts +1 -1
  39. package/lib/transform/index.js +3 -8
  40. package/lib/transform/less-adapter.d.ts +29 -0
  41. package/lib/transform.cjs +1045 -0
  42. package/lib/transform.js +1015 -0
  43. package/lib/types.d.ts +153 -28
  44. package/package.json +6 -9
  45. package/lib/index.js.map +0 -1
  46. package/lib/less-compat-structures.js.map +0 -1
  47. package/lib/nodes/at-rule.js +0 -21
  48. package/lib/nodes/at-rule.js.map +0 -1
  49. package/lib/nodes/attribute-selector.js +0 -18
  50. package/lib/nodes/attribute-selector.js.map +0 -1
  51. package/lib/nodes/call.js +0 -27
  52. package/lib/nodes/call.js.map +0 -1
  53. package/lib/nodes/color.js +0 -23
  54. package/lib/nodes/color.js.map +0 -1
  55. package/lib/nodes/combinator.js +0 -7
  56. package/lib/nodes/combinator.js.map +0 -1
  57. package/lib/nodes/comment.js +0 -9
  58. package/lib/nodes/comment.js.map +0 -1
  59. package/lib/nodes/condition.js +0 -19
  60. package/lib/nodes/condition.js.map +0 -1
  61. package/lib/nodes/declaration.js +0 -38
  62. package/lib/nodes/declaration.js.map +0 -1
  63. package/lib/nodes/dimension.js +0 -9
  64. package/lib/nodes/dimension.js.map +0 -1
  65. package/lib/nodes/expression.js +0 -16
  66. package/lib/nodes/expression.js.map +0 -1
  67. package/lib/nodes/extend.js +0 -18
  68. package/lib/nodes/extend.js.map +0 -1
  69. package/lib/nodes/import.js +0 -22
  70. package/lib/nodes/import.js.map +0 -1
  71. package/lib/nodes/index.js +0 -308
  72. package/lib/nodes/index.js.map +0 -1
  73. package/lib/nodes/keyword.js +0 -8
  74. package/lib/nodes/keyword.js.map +0 -1
  75. package/lib/nodes/list.js +0 -61
  76. package/lib/nodes/list.js.map +0 -1
  77. package/lib/nodes/mixin.js +0 -22
  78. package/lib/nodes/mixin.js.map +0 -1
  79. package/lib/nodes/negative.js +0 -13
  80. package/lib/nodes/negative.js.map +0 -1
  81. package/lib/nodes/operation.js +0 -22
  82. package/lib/nodes/operation.js.map +0 -1
  83. package/lib/nodes/paren.js +0 -13
  84. package/lib/nodes/paren.js.map +0 -1
  85. package/lib/nodes/quoted.js +0 -23
  86. package/lib/nodes/quoted.js.map +0 -1
  87. package/lib/nodes/reference.js +0 -44
  88. package/lib/nodes/reference.js.map +0 -1
  89. package/lib/nodes/ruleset.js +0 -67
  90. package/lib/nodes/ruleset.js.map +0 -1
  91. package/lib/nodes/selector.js +0 -158
  92. package/lib/nodes/selector.js.map +0 -1
  93. package/lib/nodes/sequence.js +0 -56
  94. package/lib/nodes/sequence.js.map +0 -1
  95. package/lib/nodes/url.js +0 -13
  96. package/lib/nodes/url.js.map +0 -1
  97. package/lib/nodes/var-declaration.js +0 -21
  98. package/lib/nodes/var-declaration.js.map +0 -1
  99. package/lib/plugin-utils.js +0 -100
  100. package/lib/plugin-utils.js.map +0 -1
  101. package/lib/plugin.js +0 -1026
  102. package/lib/plugin.js.map +0 -1
  103. package/lib/transform/adapter.js +0 -111
  104. package/lib/transform/adapter.js.map +0 -1
  105. package/lib/transform/from-less.js +0 -170
  106. package/lib/transform/from-less.js.map +0 -1
  107. package/lib/transform/index.js.map +0 -1
  108. package/lib/transform/proxy.d.ts +0 -32
  109. package/lib/transform/proxy.js +0 -138
  110. package/lib/transform/proxy.js.map +0 -1
  111. package/lib/transform/to-less.js +0 -130
  112. package/lib/transform/to-less.js.map +0 -1
  113. package/lib/transform/type-map.js +0 -105
  114. package/lib/transform/type-map.js.map +0 -1
  115. package/lib/types.js +0 -5
  116. package/lib/types.js.map +0 -1
@@ -0,0 +1,216 @@
1
+ //#region src/transform/type-map.ts
2
+ /**
3
+ * Type mapping utilities for converting between Jess and Less node types
4
+ */
5
+ /**
6
+ * Map Jess node types to Less node types
7
+ *
8
+ * @param jessType - The Jess node type
9
+ * @returns The corresponding Less node type
10
+ */
11
+ function mapJessTypeToLessType(jessType) {
12
+ return {
13
+ Ruleset: "Ruleset",
14
+ Declaration: "Declaration",
15
+ SelectorList: "Selector",
16
+ ComplexSelector: "Selector",
17
+ CompoundSelector: "Selector",
18
+ BasicSelector: "Element",
19
+ Combinator: "Combinator",
20
+ AttributeSelector: "Attribute",
21
+ Dimension: "Dimension",
22
+ Num: "Dimension",
23
+ Reference: "Variable",
24
+ Mixin: "MixinDefinition",
25
+ Call: "Call",
26
+ Operation: "Operation",
27
+ Expression: "Expression",
28
+ Sequence: "Expression",
29
+ Quoted: "Quoted",
30
+ Url: "URL",
31
+ Color: "Color",
32
+ Comment: "Comment",
33
+ AtRule: "AtRule",
34
+ StyleImport: "Import",
35
+ Extend: "Extend",
36
+ Condition: "Condition",
37
+ Paren: "Paren",
38
+ Negative: "Negative",
39
+ List: "Value",
40
+ VarDeclaration: "Assignment",
41
+ Keyword: "Keyword"
42
+ }[jessType] || jessType;
43
+ }
44
+ /**
45
+ * Map Less node types to Jess node types
46
+ *
47
+ * @param lessType - The Less node type
48
+ * @returns The corresponding Jess node type
49
+ */
50
+ function mapLessTypeToJessType(lessType) {
51
+ return {
52
+ Ruleset: "Ruleset",
53
+ Declaration: "Declaration",
54
+ Selector: "SelectorList",
55
+ Element: "BasicSelector",
56
+ Combinator: "Combinator",
57
+ Attribute: "AttributeSelector",
58
+ Dimension: "Dimension",
59
+ Variable: "Reference",
60
+ Property: "Reference",
61
+ VariableCall: "Reference",
62
+ MixinDefinition: "Mixin",
63
+ MixinCall: "Call",
64
+ Call: "Call",
65
+ Operation: "Operation",
66
+ Expression: "Expression",
67
+ Quoted: "Quoted",
68
+ URL: "Url",
69
+ Color: "Color",
70
+ Comment: "Comment",
71
+ AtRule: "AtRule",
72
+ Directive: "AtRule",
73
+ Rule: "Declaration",
74
+ Import: "StyleImport",
75
+ Extend: "Extend",
76
+ Condition: "Condition",
77
+ Paren: "Paren",
78
+ Negative: "Negative",
79
+ Value: "List",
80
+ Assignment: "VarDeclaration",
81
+ Keyword: "Keyword"
82
+ }[lessType] || lessType;
83
+ }
84
+ /**
85
+ * Get Less typeIndex for a Jess node type
86
+ *
87
+ * Less.js uses typeIndex for visitor caching. This function
88
+ * maps Jess types to their corresponding Less typeIndex values.
89
+ *
90
+ * @param jessType - The Jess node type
91
+ * @returns The Less typeIndex, or undefined if not found
92
+ */
93
+ function getLessTypeIndex$1(_jessType) {}
94
+ //#endregion
95
+ //#region src/transform/less-adapter.ts
96
+ const LESS_ADAPTER_SYMBOL = Symbol("less-adapter");
97
+ const JESS_NODE_SYMBOL = Symbol("jess-node");
98
+ const ACTIVE_ADAPTATIONS = /* @__PURE__ */ new WeakSet();
99
+ function getLessTypeIndex(_lessType) {}
100
+ function normalizeField(field) {
101
+ if (typeof field === "function") return { get: field };
102
+ return field;
103
+ }
104
+ var LessAdapterBase = class {
105
+ [LESS_ADAPTER_SYMBOL] = true;
106
+ [JESS_NODE_SYMBOL];
107
+ constructor(node) {
108
+ this[JESS_NODE_SYMBOL] = node;
109
+ Object.defineProperty(this, "__jessNode", {
110
+ enumerable: false,
111
+ configurable: false,
112
+ writable: false,
113
+ value: node
114
+ });
115
+ }
116
+ get jessNode() {
117
+ return this.__jessNode;
118
+ }
119
+ };
120
+ var LessNodeAdapter = class extends LessAdapterBase {
121
+ lessType;
122
+ cache;
123
+ acceptImpl;
124
+ constructor(node, definition, cache) {
125
+ super(node);
126
+ this.lessType = definition.lessType;
127
+ this.cache = cache;
128
+ this.acceptImpl = definition.accept;
129
+ Object.defineProperties(this, {
130
+ type: {
131
+ enumerable: true,
132
+ configurable: true,
133
+ get: () => {
134
+ if (typeof this.lessType === "function") return this.lessType(this.jessNode);
135
+ return this.lessType ?? mapJessTypeToLessType(this.jessNode.type);
136
+ }
137
+ },
138
+ typeIndex: {
139
+ enumerable: true,
140
+ configurable: true,
141
+ get: () => {
142
+ return getLessTypeIndex(typeof this.lessType === "function" ? this.lessType(this.jessNode) : this.lessType ?? mapJessTypeToLessType(this.jessNode.type));
143
+ }
144
+ },
145
+ accept: {
146
+ enumerable: false,
147
+ configurable: true,
148
+ value: (visitor) => {
149
+ if (this.acceptImpl) return this.acceptImpl(this.jessNode, visitor, this.cache);
150
+ return this.jessNode;
151
+ }
152
+ }
153
+ });
154
+ for (const [key, rawField] of Object.entries(definition.fields ?? {})) {
155
+ const field = normalizeField(rawField);
156
+ Object.defineProperty(this, key, {
157
+ enumerable: field.enumerable ?? true,
158
+ configurable: true,
159
+ get: () => field.get(this.jessNode, this.cache),
160
+ set: field.set ? (value) => field.set(this.jessNode, value, this.cache) : void 0
161
+ });
162
+ }
163
+ }
164
+ };
165
+ function createLessAdapter(jessNode, definition, cache) {
166
+ const cached = cache?.get(jessNode);
167
+ if (cached instanceof LessNodeAdapter) return cached;
168
+ ACTIVE_ADAPTATIONS.add(jessNode);
169
+ try {
170
+ const adapter = new LessNodeAdapter(jessNode, definition, cache);
171
+ cache?.set(jessNode, adapter);
172
+ return adapter;
173
+ } finally {
174
+ ACTIVE_ADAPTATIONS.delete(jessNode);
175
+ }
176
+ }
177
+ function isAdaptingNode(node) {
178
+ return ACTIVE_ADAPTATIONS.has(node);
179
+ }
180
+ //#endregion
181
+ Object.defineProperty(exports, "LessAdapterBase", {
182
+ enumerable: true,
183
+ get: function() {
184
+ return LessAdapterBase;
185
+ }
186
+ });
187
+ Object.defineProperty(exports, "createLessAdapter", {
188
+ enumerable: true,
189
+ get: function() {
190
+ return createLessAdapter;
191
+ }
192
+ });
193
+ Object.defineProperty(exports, "getLessTypeIndex", {
194
+ enumerable: true,
195
+ get: function() {
196
+ return getLessTypeIndex$1;
197
+ }
198
+ });
199
+ Object.defineProperty(exports, "isAdaptingNode", {
200
+ enumerable: true,
201
+ get: function() {
202
+ return isAdaptingNode;
203
+ }
204
+ });
205
+ Object.defineProperty(exports, "mapJessTypeToLessType", {
206
+ enumerable: true,
207
+ get: function() {
208
+ return mapJessTypeToLessType;
209
+ }
210
+ });
211
+ Object.defineProperty(exports, "mapLessTypeToJessType", {
212
+ enumerable: true,
213
+ get: function() {
214
+ return mapLessTypeToJessType;
215
+ }
216
+ });
@@ -0,0 +1,181 @@
1
+ //#region src/transform/type-map.ts
2
+ /**
3
+ * Type mapping utilities for converting between Jess and Less node types
4
+ */
5
+ /**
6
+ * Map Jess node types to Less node types
7
+ *
8
+ * @param jessType - The Jess node type
9
+ * @returns The corresponding Less node type
10
+ */
11
+ function mapJessTypeToLessType(jessType) {
12
+ return {
13
+ Ruleset: "Ruleset",
14
+ Declaration: "Declaration",
15
+ SelectorList: "Selector",
16
+ ComplexSelector: "Selector",
17
+ CompoundSelector: "Selector",
18
+ BasicSelector: "Element",
19
+ Combinator: "Combinator",
20
+ AttributeSelector: "Attribute",
21
+ Dimension: "Dimension",
22
+ Num: "Dimension",
23
+ Reference: "Variable",
24
+ Mixin: "MixinDefinition",
25
+ Call: "Call",
26
+ Operation: "Operation",
27
+ Expression: "Expression",
28
+ Sequence: "Expression",
29
+ Quoted: "Quoted",
30
+ Url: "URL",
31
+ Color: "Color",
32
+ Comment: "Comment",
33
+ AtRule: "AtRule",
34
+ StyleImport: "Import",
35
+ Extend: "Extend",
36
+ Condition: "Condition",
37
+ Paren: "Paren",
38
+ Negative: "Negative",
39
+ List: "Value",
40
+ VarDeclaration: "Assignment",
41
+ Keyword: "Keyword"
42
+ }[jessType] || jessType;
43
+ }
44
+ /**
45
+ * Map Less node types to Jess node types
46
+ *
47
+ * @param lessType - The Less node type
48
+ * @returns The corresponding Jess node type
49
+ */
50
+ function mapLessTypeToJessType(lessType) {
51
+ return {
52
+ Ruleset: "Ruleset",
53
+ Declaration: "Declaration",
54
+ Selector: "SelectorList",
55
+ Element: "BasicSelector",
56
+ Combinator: "Combinator",
57
+ Attribute: "AttributeSelector",
58
+ Dimension: "Dimension",
59
+ Variable: "Reference",
60
+ Property: "Reference",
61
+ VariableCall: "Reference",
62
+ MixinDefinition: "Mixin",
63
+ MixinCall: "Call",
64
+ Call: "Call",
65
+ Operation: "Operation",
66
+ Expression: "Expression",
67
+ Quoted: "Quoted",
68
+ URL: "Url",
69
+ Color: "Color",
70
+ Comment: "Comment",
71
+ AtRule: "AtRule",
72
+ Directive: "AtRule",
73
+ Rule: "Declaration",
74
+ Import: "StyleImport",
75
+ Extend: "Extend",
76
+ Condition: "Condition",
77
+ Paren: "Paren",
78
+ Negative: "Negative",
79
+ Value: "List",
80
+ Assignment: "VarDeclaration",
81
+ Keyword: "Keyword"
82
+ }[lessType] || lessType;
83
+ }
84
+ /**
85
+ * Get Less typeIndex for a Jess node type
86
+ *
87
+ * Less.js uses typeIndex for visitor caching. This function
88
+ * maps Jess types to their corresponding Less typeIndex values.
89
+ *
90
+ * @param jessType - The Jess node type
91
+ * @returns The Less typeIndex, or undefined if not found
92
+ */
93
+ function getLessTypeIndex$1(_jessType) {}
94
+ //#endregion
95
+ //#region src/transform/less-adapter.ts
96
+ const LESS_ADAPTER_SYMBOL = Symbol("less-adapter");
97
+ const JESS_NODE_SYMBOL = Symbol("jess-node");
98
+ const ACTIVE_ADAPTATIONS = /* @__PURE__ */ new WeakSet();
99
+ function getLessTypeIndex(_lessType) {}
100
+ function normalizeField(field) {
101
+ if (typeof field === "function") return { get: field };
102
+ return field;
103
+ }
104
+ var LessAdapterBase = class {
105
+ [LESS_ADAPTER_SYMBOL] = true;
106
+ [JESS_NODE_SYMBOL];
107
+ constructor(node) {
108
+ this[JESS_NODE_SYMBOL] = node;
109
+ Object.defineProperty(this, "__jessNode", {
110
+ enumerable: false,
111
+ configurable: false,
112
+ writable: false,
113
+ value: node
114
+ });
115
+ }
116
+ get jessNode() {
117
+ return this.__jessNode;
118
+ }
119
+ };
120
+ var LessNodeAdapter = class extends LessAdapterBase {
121
+ lessType;
122
+ cache;
123
+ acceptImpl;
124
+ constructor(node, definition, cache) {
125
+ super(node);
126
+ this.lessType = definition.lessType;
127
+ this.cache = cache;
128
+ this.acceptImpl = definition.accept;
129
+ Object.defineProperties(this, {
130
+ type: {
131
+ enumerable: true,
132
+ configurable: true,
133
+ get: () => {
134
+ if (typeof this.lessType === "function") return this.lessType(this.jessNode);
135
+ return this.lessType ?? mapJessTypeToLessType(this.jessNode.type);
136
+ }
137
+ },
138
+ typeIndex: {
139
+ enumerable: true,
140
+ configurable: true,
141
+ get: () => {
142
+ return getLessTypeIndex(typeof this.lessType === "function" ? this.lessType(this.jessNode) : this.lessType ?? mapJessTypeToLessType(this.jessNode.type));
143
+ }
144
+ },
145
+ accept: {
146
+ enumerable: false,
147
+ configurable: true,
148
+ value: (visitor) => {
149
+ if (this.acceptImpl) return this.acceptImpl(this.jessNode, visitor, this.cache);
150
+ return this.jessNode;
151
+ }
152
+ }
153
+ });
154
+ for (const [key, rawField] of Object.entries(definition.fields ?? {})) {
155
+ const field = normalizeField(rawField);
156
+ Object.defineProperty(this, key, {
157
+ enumerable: field.enumerable ?? true,
158
+ configurable: true,
159
+ get: () => field.get(this.jessNode, this.cache),
160
+ set: field.set ? (value) => field.set(this.jessNode, value, this.cache) : void 0
161
+ });
162
+ }
163
+ }
164
+ };
165
+ function createLessAdapter(jessNode, definition, cache) {
166
+ const cached = cache?.get(jessNode);
167
+ if (cached instanceof LessNodeAdapter) return cached;
168
+ ACTIVE_ADAPTATIONS.add(jessNode);
169
+ try {
170
+ const adapter = new LessNodeAdapter(jessNode, definition, cache);
171
+ cache?.set(jessNode, adapter);
172
+ return adapter;
173
+ } finally {
174
+ ACTIVE_ADAPTATIONS.delete(jessNode);
175
+ }
176
+ }
177
+ function isAdaptingNode(node) {
178
+ return ACTIVE_ADAPTATIONS.has(node);
179
+ }
180
+ //#endregion
181
+ export { mapJessTypeToLessType as a, getLessTypeIndex$1 as i, createLessAdapter as n, mapLessTypeToJessType as o, isAdaptingNode as r, LessAdapterBase as t };