@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.
- package/README.md +3 -2
- package/lib/index.cjs +844 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +800 -10
- package/lib/less-adapter.cjs +216 -0
- package/lib/less-adapter.js +181 -0
- package/lib/less-compat-structures.cjs +378 -0
- package/lib/less-compat-structures.d.ts +2 -2
- package/lib/less-compat-structures.js +367 -512
- package/lib/nodes/at-rule.d.ts +2 -2
- package/lib/nodes/attribute-selector.d.ts +2 -2
- package/lib/nodes/call.d.ts +2 -2
- package/lib/nodes/color.d.ts +2 -1
- package/lib/nodes/combinator.d.ts +2 -1
- package/lib/nodes/comment.d.ts +2 -1
- package/lib/nodes/condition.d.ts +2 -2
- package/lib/nodes/declaration.d.ts +2 -2
- package/lib/nodes/dimension.d.ts +2 -1
- package/lib/nodes/expression.d.ts +2 -2
- package/lib/nodes/extend.d.ts +2 -1
- package/lib/nodes/import.d.ts +2 -2
- package/lib/nodes/keyword.d.ts +2 -1
- package/lib/nodes/list.d.ts +3 -2
- package/lib/nodes/mixin.d.ts +2 -2
- package/lib/nodes/negative.d.ts +2 -2
- package/lib/nodes/operation.d.ts +2 -2
- package/lib/nodes/paren.d.ts +2 -2
- package/lib/nodes/quoted.d.ts +2 -1
- package/lib/nodes/reference.d.ts +2 -1
- package/lib/nodes/ruleset.d.ts +2 -2
- package/lib/nodes/selector.d.ts +2 -2
- package/lib/nodes/sequence.d.ts +2 -2
- package/lib/nodes/url.d.ts +2 -1
- package/lib/nodes/var-declaration.d.ts +2 -2
- package/lib/plugin.d.ts +44 -16
- package/lib/transform/adapter.d.ts +9 -11
- package/lib/transform/index.cjs +13 -0
- package/lib/transform/index.d.ts +1 -1
- package/lib/transform/index.js +3 -8
- package/lib/transform/less-adapter.d.ts +29 -0
- package/lib/transform.cjs +1045 -0
- package/lib/transform.js +1015 -0
- package/lib/types.d.ts +153 -28
- package/package.json +6 -9
- package/lib/index.js.map +0 -1
- package/lib/less-compat-structures.js.map +0 -1
- package/lib/nodes/at-rule.js +0 -21
- package/lib/nodes/at-rule.js.map +0 -1
- package/lib/nodes/attribute-selector.js +0 -18
- package/lib/nodes/attribute-selector.js.map +0 -1
- package/lib/nodes/call.js +0 -27
- package/lib/nodes/call.js.map +0 -1
- package/lib/nodes/color.js +0 -23
- package/lib/nodes/color.js.map +0 -1
- package/lib/nodes/combinator.js +0 -7
- package/lib/nodes/combinator.js.map +0 -1
- package/lib/nodes/comment.js +0 -9
- package/lib/nodes/comment.js.map +0 -1
- package/lib/nodes/condition.js +0 -19
- package/lib/nodes/condition.js.map +0 -1
- package/lib/nodes/declaration.js +0 -38
- package/lib/nodes/declaration.js.map +0 -1
- package/lib/nodes/dimension.js +0 -9
- package/lib/nodes/dimension.js.map +0 -1
- package/lib/nodes/expression.js +0 -16
- package/lib/nodes/expression.js.map +0 -1
- package/lib/nodes/extend.js +0 -18
- package/lib/nodes/extend.js.map +0 -1
- package/lib/nodes/import.js +0 -22
- package/lib/nodes/import.js.map +0 -1
- package/lib/nodes/index.js +0 -308
- package/lib/nodes/index.js.map +0 -1
- package/lib/nodes/keyword.js +0 -8
- package/lib/nodes/keyword.js.map +0 -1
- package/lib/nodes/list.js +0 -61
- package/lib/nodes/list.js.map +0 -1
- package/lib/nodes/mixin.js +0 -22
- package/lib/nodes/mixin.js.map +0 -1
- package/lib/nodes/negative.js +0 -13
- package/lib/nodes/negative.js.map +0 -1
- package/lib/nodes/operation.js +0 -22
- package/lib/nodes/operation.js.map +0 -1
- package/lib/nodes/paren.js +0 -13
- package/lib/nodes/paren.js.map +0 -1
- package/lib/nodes/quoted.js +0 -23
- package/lib/nodes/quoted.js.map +0 -1
- package/lib/nodes/reference.js +0 -44
- package/lib/nodes/reference.js.map +0 -1
- package/lib/nodes/ruleset.js +0 -67
- package/lib/nodes/ruleset.js.map +0 -1
- package/lib/nodes/selector.js +0 -158
- package/lib/nodes/selector.js.map +0 -1
- package/lib/nodes/sequence.js +0 -56
- package/lib/nodes/sequence.js.map +0 -1
- package/lib/nodes/url.js +0 -13
- package/lib/nodes/url.js.map +0 -1
- package/lib/nodes/var-declaration.js +0 -21
- package/lib/nodes/var-declaration.js.map +0 -1
- package/lib/plugin-utils.js +0 -100
- package/lib/plugin-utils.js.map +0 -1
- package/lib/plugin.js +0 -1026
- package/lib/plugin.js.map +0 -1
- package/lib/transform/adapter.js +0 -111
- package/lib/transform/adapter.js.map +0 -1
- package/lib/transform/from-less.js +0 -170
- package/lib/transform/from-less.js.map +0 -1
- package/lib/transform/index.js.map +0 -1
- package/lib/transform/proxy.d.ts +0 -32
- package/lib/transform/proxy.js +0 -138
- package/lib/transform/proxy.js.map +0 -1
- package/lib/transform/to-less.js +0 -130
- package/lib/transform/to-less.js.map +0 -1
- package/lib/transform/type-map.js +0 -105
- package/lib/transform/type-map.js.map +0 -1
- package/lib/types.js +0 -5
- 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 };
|