@navita/engine 0.2.2 → 3.0.0-next.0

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 (67) hide show
  1. package/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/cache.cjs +26 -26
  3. package/cache.mjs +28 -24
  4. package/helpers/declarationsToBlock.cjs +10 -14
  5. package/helpers/declarationsToBlock.mjs +12 -12
  6. package/helpers/generateCombinedAtRules.cjs +5 -7
  7. package/helpers/generateCombinedAtRules.mjs +7 -5
  8. package/helpers/getPropertyPriority.cjs +221 -260
  9. package/helpers/getPropertyPriority.mjs +223 -258
  10. package/helpers/hyphenateProperty.cjs +8 -9
  11. package/helpers/hyphenateProperty.mjs +10 -7
  12. package/helpers/isContainerQuery.cjs +4 -4
  13. package/helpers/isContainerQuery.mjs +6 -2
  14. package/helpers/isMediaQuery.cjs +4 -4
  15. package/helpers/isMediaQuery.mjs +6 -2
  16. package/helpers/isNestedSelector.cjs +5 -5
  17. package/helpers/isNestedSelector.mjs +7 -3
  18. package/helpers/isObject.cjs +4 -4
  19. package/helpers/isObject.mjs +6 -2
  20. package/helpers/isSupportsQuery.cjs +4 -4
  21. package/helpers/isSupportsQuery.mjs +6 -2
  22. package/helpers/normalizeCSSVarsProperty.cjs +7 -11
  23. package/helpers/normalizeCSSVarsProperty.mjs +9 -9
  24. package/helpers/normalizeCSSVarsValue.cjs +6 -8
  25. package/helpers/normalizeCSSVarsValue.mjs +8 -6
  26. package/helpers/normalizeNestedProperty.cjs +5 -7
  27. package/helpers/normalizeNestedProperty.mjs +7 -5
  28. package/helpers/pixelifyProperties.cjs +50 -53
  29. package/helpers/pixelifyProperties.mjs +52 -51
  30. package/helpers/splitSelectorList.cjs +55 -0
  31. package/helpers/splitSelectorList.mjs +57 -0
  32. package/helpers/splitStyleBlocks.cjs +23 -25
  33. package/helpers/splitStyleBlocks.mjs +25 -23
  34. package/helpers/transformContentProperty.cjs +4 -5
  35. package/helpers/transformContentProperty.mjs +6 -3
  36. package/identifiers/IDGenerator.cjs +9 -9
  37. package/identifiers/IDGenerator.mjs +11 -7
  38. package/identifiers/alphaIDGenerator.cjs +23 -26
  39. package/identifiers/alphaIDGenerator.mjs +25 -24
  40. package/identifiers/propertyValueIDGenerator.cjs +18 -23
  41. package/identifiers/propertyValueIDGenerator.mjs +20 -21
  42. package/index.cjs +187 -238
  43. package/index.d.ts +91 -84
  44. package/index.mjs +184 -234
  45. package/package.json +1 -1
  46. package/printers/printFontFaces.cjs +7 -12
  47. package/printers/printFontFaces.mjs +9 -10
  48. package/printers/printKeyFrames.cjs +10 -16
  49. package/printers/printKeyFrames.mjs +12 -14
  50. package/printers/printSourceMap.cjs +34 -39
  51. package/printers/printSourceMap.mjs +36 -37
  52. package/printers/printStyleBlocks.cjs +71 -70
  53. package/printers/printStyleBlocks.mjs +73 -68
  54. package/printers/sortAtRules.cjs +8 -7
  55. package/printers/sortAtRules.mjs +7 -4
  56. package/processKeyframes.cjs +16 -22
  57. package/processKeyframes.mjs +19 -20
  58. package/processStyles.cjs +99 -105
  59. package/processStyles.mjs +101 -103
  60. package/types.cjs +0 -2
  61. package/types.mjs +4 -1
  62. package/wrappers/classList.cjs +4 -5
  63. package/wrappers/classList.mjs +6 -3
  64. package/wrappers/static.cjs +4 -5
  65. package/wrappers/static.mjs +6 -3
  66. package/printers/sortStatic.cjs +0 -7
  67. package/printers/sortStatic.mjs +0 -5
@@ -1,25 +1,26 @@
1
- const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
2
- const charLength = chars.length;
3
- class AlphaIDGenerator {
4
- constructor(blacklist = [
5
- 'ad'
6
- ]){
7
- this.blacklist = blacklist;
8
- this.counter = 1;
9
- }
10
- next() {
11
- const nextString = (id, className = '')=>{
12
- if (id <= charLength) {
13
- return chars[id - 1] + className;
14
- }
15
- return nextString(id / charLength | 0, chars[(id - 1) % charLength] + className);
16
- };
17
- let className;
18
- do {
19
- className = nextString(this.counter++);
20
- }while (this.blacklist.includes(className.toLowerCase()))
21
- return className;
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
- 'use strict';
2
-
3
- var alphaIDGenerator = require('./alphaIDGenerator.cjs');
4
-
5
- class PropertyValueIDGenerator {
6
- property = new alphaIDGenerator.AlphaIDGenerator();
7
- cache = {};
8
- next({ property , media ='' , support ='' , container ='' , pseudo ='' , value }) {
9
- const propertyKey = `m${media}s${support}c${container}ps${pseudo}p${property}`;
10
- if (this.cache[propertyKey] === undefined) {
11
- this.cache[propertyKey] = {
12
- key: this.property.next(),
13
- cache: {}
14
- };
15
- }
16
- const entry = this.cache[propertyKey];
17
- if (entry.cache[value] === undefined) {
18
- entry.cache[value] = Object.keys(entry.cache).length + 1;
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 { AlphaIDGenerator } from './alphaIDGenerator.mjs';
2
-
3
- class PropertyValueIDGenerator {
4
- property = new AlphaIDGenerator();
5
- cache = {};
6
- next({ property , media ='' , support ='' , container ='' , pseudo ='' , value }) {
7
- const propertyKey = `m${media}s${support}c${container}ps${pseudo}p${property}`;
8
- if (this.cache[propertyKey] === undefined) {
9
- this.cache[propertyKey] = {
10
- key: this.property.next(),
11
- cache: {}
12
- };
13
- }
14
- const entry = this.cache[propertyKey];
15
- if (entry.cache[value] === undefined) {
16
- entry.cache[value] = Object.keys(entry.cache).length + 1;
17
- }
18
- return `${entry.key}${entry.cache[value]}`;
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
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var hash = require('@emotion/hash');
5
- var cache = require('./cache.cjs');
6
- var isObject = require('./helpers/isObject.cjs');
7
- var splitStyleBlocks = require('./helpers/splitStyleBlocks.cjs');
8
- var IDGenerator = require('./identifiers/IDGenerator.cjs');
9
- var alphaIDGenerator = require('./identifiers/alphaIDGenerator.cjs');
10
- var propertyValueIDGenerator = require('./identifiers/propertyValueIDGenerator.cjs');
11
- var printFontFaces = require('./printers/printFontFaces.cjs');
12
- var printKeyFrames = require('./printers/printKeyFrames.cjs');
13
- var printSourceMap = require('./printers/printSourceMap.cjs');
14
- var printStyleBlocks = require('./printers/printStyleBlocks.cjs');
15
- var sortAtRules = require('./printers/sortAtRules.cjs');
16
- var processKeyframes = require('./processKeyframes.cjs');
17
- var processStyles = require('./processStyles.cjs');
18
- var classList = require('./wrappers/classList.cjs');
19
- var _static = require('./wrappers/static.cjs');
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
- enableSourceMaps: false,
23
- enableDebugIdentifiers: false
24
+ enableSourceMaps: false,
25
+ enableDebugIdentifiers: false
24
26
  };
25
- class Engine {
26
- caches = {
27
- rule: new cache.Cache(new propertyValueIDGenerator.PropertyValueIDGenerator()),
28
- static: new cache.Cache(new IDGenerator.IDGenerator()),
29
- keyframes: new cache.Cache(new alphaIDGenerator.AlphaIDGenerator()),
30
- fontFace: new cache.Cache(new alphaIDGenerator.AlphaIDGenerator()),
31
- identifiers: new cache.Cache(new alphaIDGenerator.AlphaIDGenerator())
32
- };
33
- usedIds = {};
34
- identifierCount = 0;
35
- options = {};
36
- sourceMapReferences = {};
37
- constructor(options = {}){
38
- this.options = {
39
- ...defaultOptions,
40
- ...Object.keys(options).reduce((acc, key)=>{
41
- if (options[key] !== undefined) {
42
- acc[key] = options[key];
43
- }
44
- return acc;
45
- }, {})
46
- };
47
- }
48
- addStatic(selector, styles) {
49
- this.addUsedIds("static", processStyles.processStyles({
50
- type: "static",
51
- cache: this.caches.static
52
- })({
53
- styles,
54
- selector
55
- }).map((style)=>style.id));
56
- return new _static.Static();
57
- }
58
- addStyle(styles) {
59
- const rules = processStyles.processStyles({
60
- type: "rule",
61
- cache: this.caches.rule
62
- })({
63
- styles
64
- });
65
- const ids = rules.map((rule)=>rule.id);
66
- this.addUsedIds("rule", ids);
67
- return new classList.ClassList(ids.join(" "));
68
- }
69
- addFontFace(fontFace) {
70
- const { id } = this.caches.fontFace.getOrStore({
71
- type: "fontFace",
72
- rule: Array.isArray(fontFace) ? fontFace : [
73
- fontFace
74
- ]
75
- });
76
- this.addUsedIds("fontFace", [
77
- id
78
- ]);
79
- return id;
80
- }
81
- addKeyframes(keyframes) {
82
- const { id } = this.caches.keyframes.getOrStore({
83
- type: "keyframes",
84
- rule: processKeyframes.processKeyframes(keyframes)
85
- });
86
- this.addUsedIds("keyframes", [
87
- id
88
- ]);
89
- return id;
90
- }
91
- addSourceMapReference({ filePath , identifier , classList , line , column , index }) {
92
- if (!this.options.enableSourceMaps) {
93
- return false;
94
- }
95
- const { name } = path.parse(filePath);
96
- const extraClass = this.options.enableDebugIdentifiers ? `${name}_${identifier}` : '';
97
- const selector = '.' + classList.toString().split(' ').concat(extraClass).filter(Boolean).join('.');
98
- const newFilePath = path.relative(this.options.context || process.cwd(), filePath);
99
- if (index === 0 || !this.sourceMapReferences[newFilePath]) {
100
- this.sourceMapReferences[newFilePath] = [];
101
- }
102
- this.sourceMapReferences[newFilePath][index] = {
103
- selector,
104
- line,
105
- column
106
- };
107
- return extraClass;
108
- }
109
- clearSourceMapReferences(filePath) {
110
- const newFilePath = path.relative(this.options.context || process.cwd(), filePath);
111
- this.sourceMapReferences[newFilePath] = [];
112
- }
113
- clearCache(filePath) {
114
- this.clearUsedIds(filePath);
115
- this.clearSourceMapReferences(filePath);
116
- }
117
- generateIdentifier(value) {
118
- if (typeof value === 'undefined') {
119
- let identifier = hash((this.identifierCount++).toString(36));
120
- if (identifier.match(/^\d/)) {
121
- identifier = `_${identifier}`;
122
- }
123
- return identifier;
124
- }
125
- const newValue = JSON.stringify(value);
126
- const { id } = this.caches.identifiers.getOrStore({
127
- value: newValue
128
- });
129
- this.addUsedIds("identifiers", [
130
- id
131
- ]);
132
- return `_${id}`;
133
- }
134
- renderCssToString(options) {
135
- const { filePaths , usedIds , opinionatedLayers =false } = options || {};
136
- // We prioritize ids over filePaths. If neither are provided, we use all the used filePaths.
137
- const { keyframes: keyframesCache , fontFace: fontFaceCache , static: staticCache , rule: ruleCache } = usedIds ?? this.getCacheIds(filePaths ?? Object.keys(this.usedIds));
138
- const { atRules , lowPrioRules , rules } = splitStyleBlocks.splitStyleBlocks(this.caches.rule.items(ruleCache));
139
- const keyFrameCss = printKeyFrames.printKeyFrames(this.caches.keyframes.items(keyframesCache));
140
- const fontFaceCss = printFontFaces.printFontFaces(this.caches.fontFace.items(fontFaceCache));
141
- const staticCss = printStyleBlocks.printStyleBlocks(this.caches.static.items(staticCache));
142
- const atRulesCss = printStyleBlocks.printStyleBlocks(sortAtRules.sortAtRules(atRules));
143
- const lowPrioRulesCss = printStyleBlocks.printStyleBlocks(lowPrioRules);
144
- const rulesCss = printStyleBlocks.printStyleBlocks(rules);
145
- if (opinionatedLayers) {
146
- 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}}` : '');
147
- if (result.length > 0) {
148
- // s - static
149
- // lpr - low priority rules
150
- // r - rules
151
- // at - at rules
152
- return `@layer s,lpr,r,at;${result}`;
153
- }
154
- return '';
155
- }
156
- const content = keyFrameCss + fontFaceCss + staticCss + lowPrioRulesCss + rulesCss + atRulesCss;
157
- if (this.options.enableSourceMaps) {
158
- return printSourceMap.printSourceMap(this.sourceMapReferences, content);
159
- }
160
- return content;
161
- }
162
- serialize() {
163
- const { caches , usedIds , identifierCount , sourceMapReferences: sourceMapReferencesData } = this;
164
- const sourceMapReferences = this.options.enableSourceMaps ? sourceMapReferencesData : undefined;
165
- return JSON.stringify({
166
- caches,
167
- usedIds,
168
- identifierCount,
169
- sourceMapReferences
170
- });
171
- }
172
- async deserialize(buffer) {
173
- const data = JSON.parse(buffer.toString());
174
- function assign(target, source) {
175
- for(const key in source){
176
- if (isObject.isObject(target[key]) && isObject.isObject(source[key])) {
177
- assign(target[key], source[key]);
178
- } else {
179
- target[key] = source[key];
180
- }
181
- }
182
- return target;
183
- }
184
- assign(this, data);
185
- }
186
- setFilePath(filePath) {
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;