@navita/engine 0.2.2 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/_rolldown/runtime.cjs +23 -0
- package/cache.cjs +26 -26
- package/cache.mjs +28 -24
- package/helpers/declarationsToBlock.cjs +10 -14
- package/helpers/declarationsToBlock.mjs +12 -12
- package/helpers/generateCombinedAtRules.cjs +5 -7
- package/helpers/generateCombinedAtRules.mjs +7 -5
- package/helpers/getPropertyPriority.cjs +221 -260
- package/helpers/getPropertyPriority.mjs +223 -258
- package/helpers/hyphenateProperty.cjs +8 -9
- package/helpers/hyphenateProperty.mjs +10 -7
- package/helpers/isContainerQuery.cjs +4 -4
- package/helpers/isContainerQuery.mjs +6 -2
- package/helpers/isMediaQuery.cjs +4 -4
- package/helpers/isMediaQuery.mjs +6 -2
- package/helpers/isNestedSelector.cjs +5 -5
- package/helpers/isNestedSelector.mjs +7 -3
- package/helpers/isObject.cjs +4 -4
- package/helpers/isObject.mjs +6 -2
- package/helpers/isSupportsQuery.cjs +4 -4
- package/helpers/isSupportsQuery.mjs +6 -2
- package/helpers/normalizeCSSVarsProperty.cjs +7 -11
- package/helpers/normalizeCSSVarsProperty.mjs +9 -9
- package/helpers/normalizeCSSVarsValue.cjs +6 -8
- package/helpers/normalizeCSSVarsValue.mjs +8 -6
- package/helpers/normalizeNestedProperty.cjs +5 -7
- package/helpers/normalizeNestedProperty.mjs +7 -5
- package/helpers/pixelifyProperties.cjs +50 -53
- package/helpers/pixelifyProperties.mjs +52 -51
- package/helpers/splitSelectorList.cjs +55 -0
- package/helpers/splitSelectorList.mjs +57 -0
- package/helpers/splitStyleBlocks.cjs +23 -25
- package/helpers/splitStyleBlocks.mjs +25 -23
- package/helpers/transformContentProperty.cjs +4 -5
- package/helpers/transformContentProperty.mjs +6 -3
- package/identifiers/IDGenerator.cjs +9 -9
- package/identifiers/IDGenerator.mjs +11 -7
- package/identifiers/alphaIDGenerator.cjs +23 -26
- package/identifiers/alphaIDGenerator.mjs +25 -24
- package/identifiers/propertyValueIDGenerator.cjs +18 -23
- package/identifiers/propertyValueIDGenerator.mjs +20 -21
- package/index.cjs +187 -238
- package/index.d.ts +91 -84
- package/index.mjs +184 -234
- package/package.json +1 -1
- package/printers/printFontFaces.cjs +7 -12
- package/printers/printFontFaces.mjs +9 -10
- package/printers/printKeyFrames.cjs +10 -16
- package/printers/printKeyFrames.mjs +12 -14
- package/printers/printSourceMap.cjs +34 -39
- package/printers/printSourceMap.mjs +36 -37
- package/printers/printStyleBlocks.cjs +71 -70
- package/printers/printStyleBlocks.mjs +73 -68
- package/printers/sortAtRules.cjs +8 -7
- package/printers/sortAtRules.mjs +7 -4
- package/processKeyframes.cjs +16 -22
- package/processKeyframes.mjs +19 -20
- package/processStyles.cjs +99 -105
- package/processStyles.mjs +101 -103
- package/types.cjs +0 -2
- package/types.mjs +4 -1
- package/wrappers/classList.cjs +4 -5
- package/wrappers/classList.mjs +6 -3
- package/wrappers/static.cjs +4 -5
- package/wrappers/static.mjs +6 -3
- package/printers/sortStatic.cjs +0 -7
- package/printers/sortStatic.mjs +0 -5
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
//#region src/identifiers/alphaIDGenerator.ts
|
|
5
|
+
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
6
|
+
const charLength = 52;
|
|
7
|
+
var AlphaIDGenerator = class {
|
|
8
|
+
blacklist;
|
|
9
|
+
counter = 1;
|
|
10
|
+
constructor(blacklist = ["ad"]) {
|
|
11
|
+
this.blacklist = blacklist;
|
|
12
|
+
}
|
|
13
|
+
next() {
|
|
14
|
+
const nextString = (id, className = "") => {
|
|
15
|
+
if (id <= charLength) return chars[id - 1] + className;
|
|
16
|
+
return nextString(id / charLength | 0, chars[(id - 1) % charLength] + className);
|
|
17
|
+
};
|
|
18
|
+
let className;
|
|
19
|
+
do
|
|
20
|
+
className = nextString(this.counter++);
|
|
21
|
+
while (this.blacklist.includes(className.toLowerCase()));
|
|
22
|
+
return className;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
25
26
|
export { AlphaIDGenerator };
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return `${entry.key}${entry.cache[value]}`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_identifiers_alphaIDGenerator = require("./alphaIDGenerator.cjs");
|
|
3
|
+
//#region src/identifiers/propertyValueIDGenerator.ts
|
|
4
|
+
var PropertyValueIDGenerator = class {
|
|
5
|
+
property = new require_identifiers_alphaIDGenerator.AlphaIDGenerator();
|
|
6
|
+
cache = {};
|
|
7
|
+
next({ property, media = "", support = "", container = "", pseudo = "", value }) {
|
|
8
|
+
const propertyKey = `m${media}s${support}c${container}ps${pseudo}p${property}`;
|
|
9
|
+
if (this.cache[propertyKey] === void 0) this.cache[propertyKey] = {
|
|
10
|
+
key: this.property.next(),
|
|
11
|
+
cache: {}
|
|
12
|
+
};
|
|
13
|
+
const entry = this.cache[propertyKey];
|
|
14
|
+
if (entry.cache[value] === void 0) entry.cache[value] = Object.keys(entry.cache).length + 1;
|
|
15
|
+
return `${entry.key}${entry.cache[value]}`;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
24
19
|
exports.PropertyValueIDGenerator = PropertyValueIDGenerator;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { AlphaIDGenerator } from "./alphaIDGenerator.mjs";
|
|
5
|
+
//#region src/identifiers/propertyValueIDGenerator.ts
|
|
6
|
+
var PropertyValueIDGenerator = class {
|
|
7
|
+
property = new AlphaIDGenerator();
|
|
8
|
+
cache = {};
|
|
9
|
+
next({ property, media = "", support = "", container = "", pseudo = "", value }) {
|
|
10
|
+
const propertyKey = `m${media}s${support}c${container}ps${pseudo}p${property}`;
|
|
11
|
+
if (this.cache[propertyKey] === void 0) this.cache[propertyKey] = {
|
|
12
|
+
key: this.property.next(),
|
|
13
|
+
cache: {}
|
|
14
|
+
};
|
|
15
|
+
const entry = this.cache[propertyKey];
|
|
16
|
+
if (entry.cache[value] === void 0) entry.cache[value] = Object.keys(entry.cache).length + 1;
|
|
17
|
+
return `${entry.key}${entry.cache[value]}`;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
22
21
|
export { PropertyValueIDGenerator };
|
package/index.cjs
CHANGED
|
@@ -1,241 +1,190 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_cache = require("./cache.cjs");
|
|
4
|
+
const require_helpers_isObject = require("./helpers/isObject.cjs");
|
|
5
|
+
const require_helpers_splitStyleBlocks = require("./helpers/splitStyleBlocks.cjs");
|
|
6
|
+
const require_identifiers_alphaIDGenerator = require("./identifiers/alphaIDGenerator.cjs");
|
|
7
|
+
const require_identifiers_IDGenerator = require("./identifiers/IDGenerator.cjs");
|
|
8
|
+
const require_identifiers_propertyValueIDGenerator = require("./identifiers/propertyValueIDGenerator.cjs");
|
|
9
|
+
const require_printers_printFontFaces = require("./printers/printFontFaces.cjs");
|
|
10
|
+
const require_printers_printKeyFrames = require("./printers/printKeyFrames.cjs");
|
|
11
|
+
const require_printers_printSourceMap = require("./printers/printSourceMap.cjs");
|
|
12
|
+
const require_printers_printStyleBlocks = require("./printers/printStyleBlocks.cjs");
|
|
13
|
+
const require_printers_sortAtRules = require("./printers/sortAtRules.cjs");
|
|
14
|
+
const require_processKeyframes = require("./processKeyframes.cjs");
|
|
15
|
+
const require_processStyles = require("./processStyles.cjs");
|
|
16
|
+
const require_wrappers_classList = require("./wrappers/classList.cjs");
|
|
17
|
+
const require_wrappers_static = require("./wrappers/static.cjs");
|
|
18
|
+
let node_path = require("node:path");
|
|
19
|
+
node_path = require_runtime.__toESM(node_path);
|
|
20
|
+
let _emotion_hash = require("@emotion/hash");
|
|
21
|
+
_emotion_hash = require_runtime.__toESM(_emotion_hash);
|
|
22
|
+
//#region src/index.ts
|
|
21
23
|
const defaultOptions = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
enableSourceMaps: false,
|
|
25
|
+
enableDebugIdentifiers: false
|
|
24
26
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.filePath = filePath;
|
|
188
|
-
}
|
|
189
|
-
getUsedFilePaths() {
|
|
190
|
-
return Object.keys(this.usedIds);
|
|
191
|
-
}
|
|
192
|
-
getItems(caches) {
|
|
193
|
-
return Object.keys(caches).reduce((acc, key)=>({
|
|
194
|
-
...acc,
|
|
195
|
-
[key]: this.caches[key].items(caches[key])
|
|
196
|
-
}), {});
|
|
197
|
-
}
|
|
198
|
-
clearUsedIds(filePath) {
|
|
199
|
-
if (filePath === undefined) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
this.usedIds[filePath] = {};
|
|
203
|
-
}
|
|
204
|
-
addUsedIds(cacheType, identifiers) {
|
|
205
|
-
const { filePath } = this;
|
|
206
|
-
if (filePath === undefined) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (this.usedIds[filePath] === undefined) {
|
|
210
|
-
this.usedIds[filePath] = {};
|
|
211
|
-
}
|
|
212
|
-
if (this.usedIds[filePath][cacheType] === undefined) {
|
|
213
|
-
this.usedIds[filePath][cacheType] = [];
|
|
214
|
-
}
|
|
215
|
-
this.usedIds[filePath][cacheType] = [
|
|
216
|
-
...new Set([
|
|
217
|
-
...this.usedIds[filePath][cacheType],
|
|
218
|
-
...identifiers
|
|
219
|
-
])
|
|
220
|
-
];
|
|
221
|
-
}
|
|
222
|
-
getCacheIds(filePaths = []) {
|
|
223
|
-
return filePaths.reduce((acc, filePath)=>({
|
|
224
|
-
...acc,
|
|
225
|
-
...Object.keys(this.usedIds[filePath] || []).reduce((cache, key)=>({
|
|
226
|
-
...cache,
|
|
227
|
-
[key]: [
|
|
228
|
-
...acc[key] || [],
|
|
229
|
-
...this.usedIds[filePath][key] || []
|
|
230
|
-
]
|
|
231
|
-
}), {})
|
|
232
|
-
}), Object.keys(this.caches).reduce((acc, key)=>({
|
|
233
|
-
...acc,
|
|
234
|
-
[key]: []
|
|
235
|
-
}), {}));
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
exports.ClassList = classList.ClassList;
|
|
240
|
-
exports.Static = _static.Static;
|
|
27
|
+
var Engine = class {
|
|
28
|
+
caches = {
|
|
29
|
+
rule: new require_cache.Cache(new require_identifiers_propertyValueIDGenerator.PropertyValueIDGenerator()),
|
|
30
|
+
static: new require_cache.Cache(new require_identifiers_IDGenerator.IDGenerator()),
|
|
31
|
+
keyframes: new require_cache.Cache(new require_identifiers_alphaIDGenerator.AlphaIDGenerator()),
|
|
32
|
+
fontFace: new require_cache.Cache(new require_identifiers_alphaIDGenerator.AlphaIDGenerator()),
|
|
33
|
+
identifiers: new require_cache.Cache(new require_identifiers_alphaIDGenerator.AlphaIDGenerator())
|
|
34
|
+
};
|
|
35
|
+
usedIds = {};
|
|
36
|
+
filePath;
|
|
37
|
+
identifierCount = 0;
|
|
38
|
+
options = {};
|
|
39
|
+
sourceMapReferences = {};
|
|
40
|
+
constructor(options = {}) {
|
|
41
|
+
this.options = {
|
|
42
|
+
...defaultOptions,
|
|
43
|
+
...Object.keys(options).reduce((acc, key) => {
|
|
44
|
+
if (options[key] !== void 0) acc[key] = options[key];
|
|
45
|
+
return acc;
|
|
46
|
+
}, {})
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
addStatic(selector, styles) {
|
|
50
|
+
this.addUsedIds("static", require_processStyles.processStyles({
|
|
51
|
+
type: "static",
|
|
52
|
+
cache: this.caches.static
|
|
53
|
+
})({
|
|
54
|
+
styles,
|
|
55
|
+
selector
|
|
56
|
+
}).map((style) => style.id));
|
|
57
|
+
return new require_wrappers_static.Static();
|
|
58
|
+
}
|
|
59
|
+
addStyle(styles) {
|
|
60
|
+
const ids = require_processStyles.processStyles({
|
|
61
|
+
type: "rule",
|
|
62
|
+
cache: this.caches.rule
|
|
63
|
+
})({ styles }).map((rule) => rule.id);
|
|
64
|
+
this.addUsedIds("rule", ids);
|
|
65
|
+
return new require_wrappers_classList.ClassList(ids.join(" "));
|
|
66
|
+
}
|
|
67
|
+
addFontFace(fontFace) {
|
|
68
|
+
const { id } = this.caches.fontFace.getOrStore({
|
|
69
|
+
type: "fontFace",
|
|
70
|
+
rule: Array.isArray(fontFace) ? fontFace : [fontFace]
|
|
71
|
+
});
|
|
72
|
+
this.addUsedIds("fontFace", [id]);
|
|
73
|
+
return id;
|
|
74
|
+
}
|
|
75
|
+
addKeyframes(keyframes) {
|
|
76
|
+
const { id } = this.caches.keyframes.getOrStore({
|
|
77
|
+
type: "keyframes",
|
|
78
|
+
rule: require_processKeyframes.processKeyframes(keyframes)
|
|
79
|
+
});
|
|
80
|
+
this.addUsedIds("keyframes", [id]);
|
|
81
|
+
return id;
|
|
82
|
+
}
|
|
83
|
+
addSourceMapReference({ filePath, identifier, classList, line, column, index }) {
|
|
84
|
+
if (!this.options.enableSourceMaps) return false;
|
|
85
|
+
const { name } = node_path.default.parse(filePath);
|
|
86
|
+
const extraClass = this.options.enableDebugIdentifiers ? `${name}_${identifier}` : "";
|
|
87
|
+
const selector = "." + classList.toString().split(" ").concat(extraClass).filter(Boolean).join(".");
|
|
88
|
+
const newFilePath = node_path.default.relative(this.options.context || process.cwd(), filePath);
|
|
89
|
+
if (index === 0 || !this.sourceMapReferences[newFilePath]) this.sourceMapReferences[newFilePath] = [];
|
|
90
|
+
this.sourceMapReferences[newFilePath][index] = {
|
|
91
|
+
selector,
|
|
92
|
+
line,
|
|
93
|
+
column
|
|
94
|
+
};
|
|
95
|
+
return extraClass;
|
|
96
|
+
}
|
|
97
|
+
clearSourceMapReferences(filePath) {
|
|
98
|
+
const newFilePath = node_path.default.relative(this.options.context || process.cwd(), filePath);
|
|
99
|
+
this.sourceMapReferences[newFilePath] = [];
|
|
100
|
+
}
|
|
101
|
+
clearCache(filePath) {
|
|
102
|
+
this.clearUsedIds(filePath);
|
|
103
|
+
this.clearSourceMapReferences(filePath);
|
|
104
|
+
}
|
|
105
|
+
generateIdentifier(value) {
|
|
106
|
+
if (typeof value === "undefined") {
|
|
107
|
+
let identifier = (0, _emotion_hash.default)((this.identifierCount++).toString(36));
|
|
108
|
+
if (identifier.match(/^\d/)) identifier = `_${identifier}`;
|
|
109
|
+
return identifier;
|
|
110
|
+
}
|
|
111
|
+
const newValue = JSON.stringify(value);
|
|
112
|
+
const { id } = this.caches.identifiers.getOrStore({ value: newValue });
|
|
113
|
+
this.addUsedIds("identifiers", [id]);
|
|
114
|
+
return `_${id}`;
|
|
115
|
+
}
|
|
116
|
+
renderCssToString(options) {
|
|
117
|
+
const { filePaths, usedIds, opinionatedLayers = false } = options || {};
|
|
118
|
+
const { keyframes: keyframesCache, fontFace: fontFaceCache, static: staticCache, rule: ruleCache } = usedIds ?? this.getCacheIds(filePaths ?? Object.keys(this.usedIds));
|
|
119
|
+
const { atRules, lowPrioRules, rules } = require_helpers_splitStyleBlocks.splitStyleBlocks(this.caches.rule.items(ruleCache));
|
|
120
|
+
const keyFrameCss = require_printers_printKeyFrames.printKeyFrames(this.caches.keyframes.items(keyframesCache));
|
|
121
|
+
const fontFaceCss = require_printers_printFontFaces.printFontFaces(this.caches.fontFace.items(fontFaceCache));
|
|
122
|
+
const staticCss = require_printers_printStyleBlocks.printStyleBlocks(this.caches.static.items(staticCache));
|
|
123
|
+
const atRulesCss = require_printers_printStyleBlocks.printStyleBlocks(require_printers_sortAtRules.sortAtRules(atRules));
|
|
124
|
+
const lowPrioRulesCss = require_printers_printStyleBlocks.printStyleBlocks(lowPrioRules);
|
|
125
|
+
const rulesCss = require_printers_printStyleBlocks.printStyleBlocks(rules);
|
|
126
|
+
if (opinionatedLayers) {
|
|
127
|
+
const result = `${keyFrameCss}${fontFaceCss}` + (staticCss.length > 0 ? `@layer s{${staticCss}}` : "") + (lowPrioRulesCss.length > 0 ? `@layer lpr{${lowPrioRulesCss}}` : "") + (rulesCss.length > 0 ? `@layer r{${rulesCss}}` : "") + (atRulesCss.length > 0 ? `@layer at{${atRulesCss}}` : "");
|
|
128
|
+
if (result.length > 0) return `@layer s,lpr,r,at;${result}`;
|
|
129
|
+
return "";
|
|
130
|
+
}
|
|
131
|
+
const content = keyFrameCss + fontFaceCss + staticCss + lowPrioRulesCss + rulesCss + atRulesCss;
|
|
132
|
+
if (this.options.enableSourceMaps) return require_printers_printSourceMap.printSourceMap(this.sourceMapReferences, content);
|
|
133
|
+
return content;
|
|
134
|
+
}
|
|
135
|
+
serialize() {
|
|
136
|
+
const { caches, usedIds, identifierCount, sourceMapReferences: sourceMapReferencesData } = this;
|
|
137
|
+
const sourceMapReferences = this.options.enableSourceMaps ? sourceMapReferencesData : void 0;
|
|
138
|
+
return JSON.stringify({
|
|
139
|
+
caches,
|
|
140
|
+
usedIds,
|
|
141
|
+
identifierCount,
|
|
142
|
+
sourceMapReferences
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async deserialize(buffer) {
|
|
146
|
+
const data = JSON.parse(buffer.toString());
|
|
147
|
+
function assign(target, source) {
|
|
148
|
+
for (const key in source) if (require_helpers_isObject.isObject(target[key]) && require_helpers_isObject.isObject(source[key])) assign(target[key], source[key]);
|
|
149
|
+
else target[key] = source[key];
|
|
150
|
+
return target;
|
|
151
|
+
}
|
|
152
|
+
assign(this, data);
|
|
153
|
+
}
|
|
154
|
+
setFilePath(filePath) {
|
|
155
|
+
this.filePath = filePath;
|
|
156
|
+
}
|
|
157
|
+
getUsedFilePaths() {
|
|
158
|
+
return Object.keys(this.usedIds);
|
|
159
|
+
}
|
|
160
|
+
getItems(caches) {
|
|
161
|
+
const result = {};
|
|
162
|
+
for (const key of Object.keys(caches)) result[key] = this.caches[key].items(caches[key]);
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
clearUsedIds(filePath) {
|
|
166
|
+
if (filePath === void 0) return;
|
|
167
|
+
this.usedIds[filePath] = {};
|
|
168
|
+
}
|
|
169
|
+
addUsedIds(cacheType, identifiers) {
|
|
170
|
+
const { filePath } = this;
|
|
171
|
+
if (filePath === void 0) return;
|
|
172
|
+
if (this.usedIds[filePath] === void 0) this.usedIds[filePath] = {};
|
|
173
|
+
if (this.usedIds[filePath][cacheType] === void 0) this.usedIds[filePath][cacheType] = [];
|
|
174
|
+
this.usedIds[filePath][cacheType] = [.../* @__PURE__ */ new Set([...this.usedIds[filePath][cacheType], ...identifiers])];
|
|
175
|
+
}
|
|
176
|
+
getCacheIds(filePaths = []) {
|
|
177
|
+
const result = {};
|
|
178
|
+
for (const key of Object.keys(this.caches)) result[key] = [];
|
|
179
|
+
for (const filePath of filePaths) {
|
|
180
|
+
const used = this.usedIds[filePath];
|
|
181
|
+
if (!used) continue;
|
|
182
|
+
for (const key of Object.keys(used)) result[key] = [...result[key] || [], ...used[key] || []];
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
exports.ClassList = require_wrappers_classList.ClassList;
|
|
241
189
|
exports.Engine = Engine;
|
|
190
|
+
exports.Static = require_wrappers_static.Static;
|