@navita/core 0.0.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.
- package/createRenderer.d.ts +15 -0
- package/createRenderer.js +325 -0
- package/createRenderer.mjs +306 -0
- package/evaluateAndProcess.d.ts +14 -0
- package/evaluateAndProcess.js +66 -0
- package/evaluateAndProcess.mjs +51 -0
- package/index.d.ts +23 -0
- package/index.js +55 -0
- package/index.mjs +48 -0
- package/package.json +27 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as fela from 'fela';
|
|
2
|
+
import { StyleRule } from '@navita/types';
|
|
3
|
+
|
|
4
|
+
declare module 'fela' {
|
|
5
|
+
type CacheItemIsh = Parameters<Parameters<IRenderer['subscribe']>[number]>[number];
|
|
6
|
+
interface IRenderer {
|
|
7
|
+
cache: Record<string, CacheItemIsh>;
|
|
8
|
+
renderRule(rule: () => StyleRule): string;
|
|
9
|
+
renderStatic(css: StyleRule, selector: string): void;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare function createRenderer(): fela.IRenderer;
|
|
13
|
+
type Renderer = ReturnType<typeof createRenderer>;
|
|
14
|
+
|
|
15
|
+
export { Renderer, createRenderer };
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fela = require('fela');
|
|
4
|
+
var felaTools = require('fela-tools');
|
|
5
|
+
var types = require('node:util/types');
|
|
6
|
+
var v8 = require('node:v8');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var v8__namespace = /*#__PURE__*/_interopNamespaceDefault(v8);
|
|
26
|
+
|
|
27
|
+
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
28
|
+
const charLength = chars.length;
|
|
29
|
+
function nextString(id, className = '') {
|
|
30
|
+
if (id <= charLength) {
|
|
31
|
+
return chars[id - 1] + className;
|
|
32
|
+
}
|
|
33
|
+
return nextString(id / charLength | 0, chars[(id - 1) % charLength] + className);
|
|
34
|
+
}
|
|
35
|
+
function generateString(getId, blacklist = []) {
|
|
36
|
+
const className = nextString(getId());
|
|
37
|
+
if (blacklist.includes(className.toLowerCase())) {
|
|
38
|
+
return generateString(getId, blacklist);
|
|
39
|
+
}
|
|
40
|
+
return className;
|
|
41
|
+
}
|
|
42
|
+
function className(blacklist = []) {
|
|
43
|
+
return (renderer)=>{
|
|
44
|
+
renderer.generateClassName = ()=>{
|
|
45
|
+
return generateString(renderer.getNextRuleIdentifier, blacklist);
|
|
46
|
+
};
|
|
47
|
+
renderer.generateAnimationName = ()=>{
|
|
48
|
+
return generateString(renderer.getNextKeyframeIdentifier, blacklist);
|
|
49
|
+
};
|
|
50
|
+
return renderer;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function createResult(renderer, filePath, isServer) {
|
|
55
|
+
const values = renderer.evaluatedResults.get(filePath) || [];
|
|
56
|
+
if (isServer && renderer.classPropertyList) {
|
|
57
|
+
// Todo: this is just a POC. It needs to be cleaned up, but it's a different build for
|
|
58
|
+
// the server. On the client we'll use browser APIs.
|
|
59
|
+
// We're using this class list to be able to merge during runtime.
|
|
60
|
+
const newResult = (values || []).map((item)=>{
|
|
61
|
+
if (typeof item === "string") {
|
|
62
|
+
const rules = item.split(' ').map((x)=>renderer.classPropertyList.has(x) ? [
|
|
63
|
+
x,
|
|
64
|
+
[
|
|
65
|
+
...renderer.classPropertyList.get(x)
|
|
66
|
+
]
|
|
67
|
+
] : false).filter(Boolean);
|
|
68
|
+
return `new (require('@navita/css').ClassList)("${item}", ${JSON.stringify(rules)})`;
|
|
69
|
+
}
|
|
70
|
+
return JSON.stringify(item);
|
|
71
|
+
});
|
|
72
|
+
return `const $$evaluatedValues = [${newResult}];`;
|
|
73
|
+
}
|
|
74
|
+
return `const $$evaluatedValues = ${JSON.stringify(values || [])};`;
|
|
75
|
+
}
|
|
76
|
+
function evaluatedResult() {
|
|
77
|
+
return (renderer)=>{
|
|
78
|
+
renderer.evaluatedResults = new Map();
|
|
79
|
+
renderer.setEvaluatedResult = (fileName, index, value)=>{
|
|
80
|
+
if (!renderer.evaluatedResults.has(fileName)) {
|
|
81
|
+
renderer.evaluatedResults.set(fileName, []);
|
|
82
|
+
}
|
|
83
|
+
renderer.evaluatedResults.get(fileName)[index] = value;
|
|
84
|
+
};
|
|
85
|
+
renderer.getResult = (filePath, isServer)=>{
|
|
86
|
+
const result = createResult(renderer, filePath, isServer || false);
|
|
87
|
+
return {
|
|
88
|
+
result,
|
|
89
|
+
get css () {
|
|
90
|
+
return renderer.renderToString?.(filePath) || "";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
return renderer;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isMediaQuery(rule) {
|
|
99
|
+
return rule.startsWith('@media');
|
|
100
|
+
}
|
|
101
|
+
function isSupportsQuery(rule) {
|
|
102
|
+
return rule.startsWith('@supports');
|
|
103
|
+
}
|
|
104
|
+
function isPseudoSelector(rule) {
|
|
105
|
+
return rule.startsWith(':');
|
|
106
|
+
}
|
|
107
|
+
function wrapWith(atRule, query, content) {
|
|
108
|
+
return query.length > 0 ? `${atRule} ${query} {${content}}` : content;
|
|
109
|
+
}
|
|
110
|
+
function createCssRule(selector, properties) {
|
|
111
|
+
return `${selector}{${properties.map((rule)=>`${cssifyProperty(rule.property)}: ${rule.value};`).join('')}}`;
|
|
112
|
+
}
|
|
113
|
+
function generateCombinedMediaQuery(currentMediaQuery, nestedMediaQuery) {
|
|
114
|
+
if (currentMediaQuery.length === 0) {
|
|
115
|
+
return nestedMediaQuery;
|
|
116
|
+
}
|
|
117
|
+
return `${currentMediaQuery} and ${nestedMediaQuery}`;
|
|
118
|
+
}
|
|
119
|
+
function cssifyProperty(property) {
|
|
120
|
+
return property.replace(/([a-zA-Z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
121
|
+
}
|
|
122
|
+
function isObject(value) {
|
|
123
|
+
return typeof value === 'object' && !Array.isArray(value);
|
|
124
|
+
}
|
|
125
|
+
function collectAndGroupRules(cssObj, currentSupportsQuery = '', currentMediaQuery = '', currentPseudoSelector = '', groupedRules = {}) {
|
|
126
|
+
for (const [property, value] of Object.entries(cssObj)){
|
|
127
|
+
if (!isObject(value)) {
|
|
128
|
+
if (!groupedRules[currentSupportsQuery]) {
|
|
129
|
+
groupedRules[currentSupportsQuery] = {};
|
|
130
|
+
}
|
|
131
|
+
const supportsGroup = groupedRules[currentSupportsQuery];
|
|
132
|
+
if (!supportsGroup[currentMediaQuery]) {
|
|
133
|
+
supportsGroup[currentMediaQuery] = {};
|
|
134
|
+
}
|
|
135
|
+
const mediaGroup = supportsGroup[currentMediaQuery];
|
|
136
|
+
if (!mediaGroup[currentPseudoSelector]) {
|
|
137
|
+
mediaGroup[currentPseudoSelector] = [];
|
|
138
|
+
}
|
|
139
|
+
mediaGroup[currentPseudoSelector].push({
|
|
140
|
+
property,
|
|
141
|
+
value
|
|
142
|
+
});
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (isMediaQuery(property)) {
|
|
146
|
+
collectAndGroupRules(value, currentSupportsQuery, generateCombinedMediaQuery(currentMediaQuery, property.slice(6).trim()), currentPseudoSelector, groupedRules);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (isSupportsQuery(property)) {
|
|
150
|
+
collectAndGroupRules(value, generateCombinedMediaQuery(currentSupportsQuery, property.slice(9).trim()), currentMediaQuery, currentPseudoSelector, groupedRules);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (isPseudoSelector(property)) {
|
|
154
|
+
collectAndGroupRules(value, currentSupportsQuery, currentMediaQuery, currentPseudoSelector + property, groupedRules);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return groupedRules;
|
|
158
|
+
}
|
|
159
|
+
function serializeCss(selector, cssObj) {
|
|
160
|
+
const processPseudoSelectors = (pseudoSelectors)=>Object.entries(pseudoSelectors).map(([pseudo, properties])=>createCssRule(`${selector}${pseudo}`, properties)).join('');
|
|
161
|
+
const processMediaQueries = (mediaQueries)=>Object.entries(mediaQueries).map(([media, pseudoSelectors])=>wrapWith('@media', media, processPseudoSelectors(pseudoSelectors))).join('');
|
|
162
|
+
const rules = collectAndGroupRules(cssObj);
|
|
163
|
+
return Object.entries(rules).map(([supports, mediaQueries])=>wrapWith('@supports', supports, processMediaQueries(mediaQueries))).join('');
|
|
164
|
+
}
|
|
165
|
+
function nestedStatic() {
|
|
166
|
+
// Fela doesn't handle nested static styles correctly. This is a workaround for now.
|
|
167
|
+
// https://github.com/robinweser/fela/issues/876
|
|
168
|
+
// https://github.com/robinweser/fela/issues/465#issuecomment-594396150
|
|
169
|
+
// https://github.com/robinweser/fela/issues/863
|
|
170
|
+
return (renderer)=>{
|
|
171
|
+
const { renderStatic } = renderer;
|
|
172
|
+
renderer.renderStatic = (staticStyle, selector)=>{
|
|
173
|
+
return renderStatic(serializeCss(selector, staticStyle), undefined);
|
|
174
|
+
};
|
|
175
|
+
return renderer;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function renderToString() {
|
|
180
|
+
return (renderer)=>{
|
|
181
|
+
renderer.renderToString = (fileName)=>{
|
|
182
|
+
if (!renderer.getScopedCache || !renderer.accessedKeys) {
|
|
183
|
+
return felaTools.renderToString(renderer);
|
|
184
|
+
}
|
|
185
|
+
if (fileName) {
|
|
186
|
+
return felaTools.renderToString({
|
|
187
|
+
...renderer,
|
|
188
|
+
cache: renderer.getScopedCache(fileName)
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
const newCache = {};
|
|
192
|
+
for (const keys of renderer.accessedKeys.values()){
|
|
193
|
+
for (const key of keys){
|
|
194
|
+
const item = renderer.cache[key];
|
|
195
|
+
if (!item) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
newCache[key] = item;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return felaTools.renderToString({
|
|
202
|
+
...renderer,
|
|
203
|
+
cache: newCache
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
return renderer;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function scopedCache() {
|
|
211
|
+
return (renderer)=>{
|
|
212
|
+
let currentFileName;
|
|
213
|
+
const ensureCache = ()=>{
|
|
214
|
+
if (types.isProxy(renderer.cache)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
renderer.cache = new Proxy(renderer.cache, {
|
|
218
|
+
getOwnPropertyDescriptor (target, key) {
|
|
219
|
+
const result = Reflect.getOwnPropertyDescriptor(target, key);
|
|
220
|
+
const { accessedKeys } = renderer;
|
|
221
|
+
if (!currentFileName) {
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
if (!accessedKeys.has(currentFileName)) {
|
|
225
|
+
accessedKeys.set(currentFileName, new Set());
|
|
226
|
+
}
|
|
227
|
+
accessedKeys.get(currentFileName)?.add(key);
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
renderer.setFilePath = (filePath)=>{
|
|
233
|
+
currentFileName = filePath;
|
|
234
|
+
// After we've set the file path, we need to ensure that the cache is a proxy,
|
|
235
|
+
// and set up to record accessed keys.
|
|
236
|
+
// Without a filePath, the proxy on the cache doesn't make sense, so this is a good place to do it.
|
|
237
|
+
ensureCache();
|
|
238
|
+
};
|
|
239
|
+
renderer.accessedKeys = new Map();
|
|
240
|
+
renderer.clearAccessedKeys = (filePath)=>{
|
|
241
|
+
renderer.accessedKeys.get(filePath)?.clear();
|
|
242
|
+
};
|
|
243
|
+
renderer.getScopedCache = (filePath)=>{
|
|
244
|
+
const { accessedKeys } = renderer;
|
|
245
|
+
const newCache = {};
|
|
246
|
+
if (accessedKeys.has(filePath)) {
|
|
247
|
+
const keys = accessedKeys.get(filePath);
|
|
248
|
+
for (const key of keys){
|
|
249
|
+
const item = renderer.cache[key];
|
|
250
|
+
if (!item) {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
newCache[key] = item;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return newCache;
|
|
257
|
+
};
|
|
258
|
+
renderer.classPropertyList = new Map();
|
|
259
|
+
renderer.subscribe((message)=>{
|
|
260
|
+
if (message.type === 'RULE') {
|
|
261
|
+
const { declaration , className } = message;
|
|
262
|
+
const [property] = declaration.split(':');
|
|
263
|
+
if (!property) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const { classPropertyList } = renderer;
|
|
267
|
+
if (!classPropertyList.has(className)) {
|
|
268
|
+
classPropertyList.set(className, new Set());
|
|
269
|
+
}
|
|
270
|
+
classPropertyList.get(className)?.add(property);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
return renderer;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function serializedCache(keys = []) {
|
|
278
|
+
return (renderer)=>{
|
|
279
|
+
renderer.serialize = ()=>{
|
|
280
|
+
const obj = {};
|
|
281
|
+
for (const key of keys){
|
|
282
|
+
const value = renderer[key];
|
|
283
|
+
if (types.isProxy(value)) {
|
|
284
|
+
obj[key] = Object.assign({}, value);
|
|
285
|
+
} else {
|
|
286
|
+
obj[key] = value;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return v8__namespace.serialize(obj).toString('base64');
|
|
290
|
+
};
|
|
291
|
+
renderer.deserialize = (serialized)=>{
|
|
292
|
+
if (!serialized) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const data = v8__namespace.deserialize(Buffer.from(serialized, 'base64'));
|
|
296
|
+
for (const [key, value] of Object.entries(data)){
|
|
297
|
+
renderer[key] = value;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return renderer;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function createRenderer() {
|
|
305
|
+
return fela.createRenderer({
|
|
306
|
+
enhancers: [
|
|
307
|
+
className([
|
|
308
|
+
'ad'
|
|
309
|
+
]),
|
|
310
|
+
scopedCache(),
|
|
311
|
+
serializedCache([
|
|
312
|
+
'cache',
|
|
313
|
+
'classPropertyList',
|
|
314
|
+
'accessedKeys',
|
|
315
|
+
'uniqueRuleIdentifier',
|
|
316
|
+
'uniqueKeyframeIdentifier'
|
|
317
|
+
]),
|
|
318
|
+
evaluatedResult(),
|
|
319
|
+
renderToString(),
|
|
320
|
+
nestedStatic()
|
|
321
|
+
]
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
exports.createRenderer = createRenderer;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { createRequire as createRequire$1 } from 'module';
|
|
2
|
+
const require = createRequire$1(import.meta.url);
|
|
3
|
+
import { createRenderer as createRenderer$1 } from 'fela';
|
|
4
|
+
import { renderToString as renderToString$1 } from 'fela-tools';
|
|
5
|
+
import { isProxy } from 'node:util/types';
|
|
6
|
+
import * as v8 from 'node:v8';
|
|
7
|
+
|
|
8
|
+
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
9
|
+
const charLength = chars.length;
|
|
10
|
+
function nextString(id, className = '') {
|
|
11
|
+
if (id <= charLength) {
|
|
12
|
+
return chars[id - 1] + className;
|
|
13
|
+
}
|
|
14
|
+
return nextString(id / charLength | 0, chars[(id - 1) % charLength] + className);
|
|
15
|
+
}
|
|
16
|
+
function generateString(getId, blacklist = []) {
|
|
17
|
+
const className = nextString(getId());
|
|
18
|
+
if (blacklist.includes(className.toLowerCase())) {
|
|
19
|
+
return generateString(getId, blacklist);
|
|
20
|
+
}
|
|
21
|
+
return className;
|
|
22
|
+
}
|
|
23
|
+
function className(blacklist = []) {
|
|
24
|
+
return (renderer)=>{
|
|
25
|
+
renderer.generateClassName = ()=>{
|
|
26
|
+
return generateString(renderer.getNextRuleIdentifier, blacklist);
|
|
27
|
+
};
|
|
28
|
+
renderer.generateAnimationName = ()=>{
|
|
29
|
+
return generateString(renderer.getNextKeyframeIdentifier, blacklist);
|
|
30
|
+
};
|
|
31
|
+
return renderer;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createResult(renderer, filePath, isServer) {
|
|
36
|
+
const values = renderer.evaluatedResults.get(filePath) || [];
|
|
37
|
+
if (isServer && renderer.classPropertyList) {
|
|
38
|
+
// Todo: this is just a POC. It needs to be cleaned up, but it's a different build for
|
|
39
|
+
// the server. On the client we'll use browser APIs.
|
|
40
|
+
// We're using this class list to be able to merge during runtime.
|
|
41
|
+
const newResult = (values || []).map((item)=>{
|
|
42
|
+
if (typeof item === "string") {
|
|
43
|
+
const rules = item.split(' ').map((x)=>renderer.classPropertyList.has(x) ? [
|
|
44
|
+
x,
|
|
45
|
+
[
|
|
46
|
+
...renderer.classPropertyList.get(x)
|
|
47
|
+
]
|
|
48
|
+
] : false).filter(Boolean);
|
|
49
|
+
return `new (require('@navita/css').ClassList)("${item}", ${JSON.stringify(rules)})`;
|
|
50
|
+
}
|
|
51
|
+
return JSON.stringify(item);
|
|
52
|
+
});
|
|
53
|
+
return `const $$evaluatedValues = [${newResult}];`;
|
|
54
|
+
}
|
|
55
|
+
return `const $$evaluatedValues = ${JSON.stringify(values || [])};`;
|
|
56
|
+
}
|
|
57
|
+
function evaluatedResult() {
|
|
58
|
+
return (renderer)=>{
|
|
59
|
+
renderer.evaluatedResults = new Map();
|
|
60
|
+
renderer.setEvaluatedResult = (fileName, index, value)=>{
|
|
61
|
+
if (!renderer.evaluatedResults.has(fileName)) {
|
|
62
|
+
renderer.evaluatedResults.set(fileName, []);
|
|
63
|
+
}
|
|
64
|
+
renderer.evaluatedResults.get(fileName)[index] = value;
|
|
65
|
+
};
|
|
66
|
+
renderer.getResult = (filePath, isServer)=>{
|
|
67
|
+
const result = createResult(renderer, filePath, isServer || false);
|
|
68
|
+
return {
|
|
69
|
+
result,
|
|
70
|
+
get css () {
|
|
71
|
+
return renderer.renderToString?.(filePath) || "";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
return renderer;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function isMediaQuery(rule) {
|
|
80
|
+
return rule.startsWith('@media');
|
|
81
|
+
}
|
|
82
|
+
function isSupportsQuery(rule) {
|
|
83
|
+
return rule.startsWith('@supports');
|
|
84
|
+
}
|
|
85
|
+
function isPseudoSelector(rule) {
|
|
86
|
+
return rule.startsWith(':');
|
|
87
|
+
}
|
|
88
|
+
function wrapWith(atRule, query, content) {
|
|
89
|
+
return query.length > 0 ? `${atRule} ${query} {${content}}` : content;
|
|
90
|
+
}
|
|
91
|
+
function createCssRule(selector, properties) {
|
|
92
|
+
return `${selector}{${properties.map((rule)=>`${cssifyProperty(rule.property)}: ${rule.value};`).join('')}}`;
|
|
93
|
+
}
|
|
94
|
+
function generateCombinedMediaQuery(currentMediaQuery, nestedMediaQuery) {
|
|
95
|
+
if (currentMediaQuery.length === 0) {
|
|
96
|
+
return nestedMediaQuery;
|
|
97
|
+
}
|
|
98
|
+
return `${currentMediaQuery} and ${nestedMediaQuery}`;
|
|
99
|
+
}
|
|
100
|
+
function cssifyProperty(property) {
|
|
101
|
+
return property.replace(/([a-zA-Z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
function isObject(value) {
|
|
104
|
+
return typeof value === 'object' && !Array.isArray(value);
|
|
105
|
+
}
|
|
106
|
+
function collectAndGroupRules(cssObj, currentSupportsQuery = '', currentMediaQuery = '', currentPseudoSelector = '', groupedRules = {}) {
|
|
107
|
+
for (const [property, value] of Object.entries(cssObj)){
|
|
108
|
+
if (!isObject(value)) {
|
|
109
|
+
if (!groupedRules[currentSupportsQuery]) {
|
|
110
|
+
groupedRules[currentSupportsQuery] = {};
|
|
111
|
+
}
|
|
112
|
+
const supportsGroup = groupedRules[currentSupportsQuery];
|
|
113
|
+
if (!supportsGroup[currentMediaQuery]) {
|
|
114
|
+
supportsGroup[currentMediaQuery] = {};
|
|
115
|
+
}
|
|
116
|
+
const mediaGroup = supportsGroup[currentMediaQuery];
|
|
117
|
+
if (!mediaGroup[currentPseudoSelector]) {
|
|
118
|
+
mediaGroup[currentPseudoSelector] = [];
|
|
119
|
+
}
|
|
120
|
+
mediaGroup[currentPseudoSelector].push({
|
|
121
|
+
property,
|
|
122
|
+
value
|
|
123
|
+
});
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (isMediaQuery(property)) {
|
|
127
|
+
collectAndGroupRules(value, currentSupportsQuery, generateCombinedMediaQuery(currentMediaQuery, property.slice(6).trim()), currentPseudoSelector, groupedRules);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (isSupportsQuery(property)) {
|
|
131
|
+
collectAndGroupRules(value, generateCombinedMediaQuery(currentSupportsQuery, property.slice(9).trim()), currentMediaQuery, currentPseudoSelector, groupedRules);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (isPseudoSelector(property)) {
|
|
135
|
+
collectAndGroupRules(value, currentSupportsQuery, currentMediaQuery, currentPseudoSelector + property, groupedRules);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return groupedRules;
|
|
139
|
+
}
|
|
140
|
+
function serializeCss(selector, cssObj) {
|
|
141
|
+
const processPseudoSelectors = (pseudoSelectors)=>Object.entries(pseudoSelectors).map(([pseudo, properties])=>createCssRule(`${selector}${pseudo}`, properties)).join('');
|
|
142
|
+
const processMediaQueries = (mediaQueries)=>Object.entries(mediaQueries).map(([media, pseudoSelectors])=>wrapWith('@media', media, processPseudoSelectors(pseudoSelectors))).join('');
|
|
143
|
+
const rules = collectAndGroupRules(cssObj);
|
|
144
|
+
return Object.entries(rules).map(([supports, mediaQueries])=>wrapWith('@supports', supports, processMediaQueries(mediaQueries))).join('');
|
|
145
|
+
}
|
|
146
|
+
function nestedStatic() {
|
|
147
|
+
// Fela doesn't handle nested static styles correctly. This is a workaround for now.
|
|
148
|
+
// https://github.com/robinweser/fela/issues/876
|
|
149
|
+
// https://github.com/robinweser/fela/issues/465#issuecomment-594396150
|
|
150
|
+
// https://github.com/robinweser/fela/issues/863
|
|
151
|
+
return (renderer)=>{
|
|
152
|
+
const { renderStatic } = renderer;
|
|
153
|
+
renderer.renderStatic = (staticStyle, selector)=>{
|
|
154
|
+
return renderStatic(serializeCss(selector, staticStyle), undefined);
|
|
155
|
+
};
|
|
156
|
+
return renderer;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function renderToString() {
|
|
161
|
+
return (renderer)=>{
|
|
162
|
+
renderer.renderToString = (fileName)=>{
|
|
163
|
+
if (!renderer.getScopedCache || !renderer.accessedKeys) {
|
|
164
|
+
return renderToString$1(renderer);
|
|
165
|
+
}
|
|
166
|
+
if (fileName) {
|
|
167
|
+
return renderToString$1({
|
|
168
|
+
...renderer,
|
|
169
|
+
cache: renderer.getScopedCache(fileName)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
const newCache = {};
|
|
173
|
+
for (const keys of renderer.accessedKeys.values()){
|
|
174
|
+
for (const key of keys){
|
|
175
|
+
const item = renderer.cache[key];
|
|
176
|
+
if (!item) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
newCache[key] = item;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return renderToString$1({
|
|
183
|
+
...renderer,
|
|
184
|
+
cache: newCache
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
return renderer;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function scopedCache() {
|
|
192
|
+
return (renderer)=>{
|
|
193
|
+
let currentFileName;
|
|
194
|
+
const ensureCache = ()=>{
|
|
195
|
+
if (isProxy(renderer.cache)) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
renderer.cache = new Proxy(renderer.cache, {
|
|
199
|
+
getOwnPropertyDescriptor (target, key) {
|
|
200
|
+
const result = Reflect.getOwnPropertyDescriptor(target, key);
|
|
201
|
+
const { accessedKeys } = renderer;
|
|
202
|
+
if (!currentFileName) {
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
if (!accessedKeys.has(currentFileName)) {
|
|
206
|
+
accessedKeys.set(currentFileName, new Set());
|
|
207
|
+
}
|
|
208
|
+
accessedKeys.get(currentFileName)?.add(key);
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
renderer.setFilePath = (filePath)=>{
|
|
214
|
+
currentFileName = filePath;
|
|
215
|
+
// After we've set the file path, we need to ensure that the cache is a proxy,
|
|
216
|
+
// and set up to record accessed keys.
|
|
217
|
+
// Without a filePath, the proxy on the cache doesn't make sense, so this is a good place to do it.
|
|
218
|
+
ensureCache();
|
|
219
|
+
};
|
|
220
|
+
renderer.accessedKeys = new Map();
|
|
221
|
+
renderer.clearAccessedKeys = (filePath)=>{
|
|
222
|
+
renderer.accessedKeys.get(filePath)?.clear();
|
|
223
|
+
};
|
|
224
|
+
renderer.getScopedCache = (filePath)=>{
|
|
225
|
+
const { accessedKeys } = renderer;
|
|
226
|
+
const newCache = {};
|
|
227
|
+
if (accessedKeys.has(filePath)) {
|
|
228
|
+
const keys = accessedKeys.get(filePath);
|
|
229
|
+
for (const key of keys){
|
|
230
|
+
const item = renderer.cache[key];
|
|
231
|
+
if (!item) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
newCache[key] = item;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return newCache;
|
|
238
|
+
};
|
|
239
|
+
renderer.classPropertyList = new Map();
|
|
240
|
+
renderer.subscribe((message)=>{
|
|
241
|
+
if (message.type === 'RULE') {
|
|
242
|
+
const { declaration , className } = message;
|
|
243
|
+
const [property] = declaration.split(':');
|
|
244
|
+
if (!property) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const { classPropertyList } = renderer;
|
|
248
|
+
if (!classPropertyList.has(className)) {
|
|
249
|
+
classPropertyList.set(className, new Set());
|
|
250
|
+
}
|
|
251
|
+
classPropertyList.get(className)?.add(property);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
return renderer;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function serializedCache(keys = []) {
|
|
259
|
+
return (renderer)=>{
|
|
260
|
+
renderer.serialize = ()=>{
|
|
261
|
+
const obj = {};
|
|
262
|
+
for (const key of keys){
|
|
263
|
+
const value = renderer[key];
|
|
264
|
+
if (isProxy(value)) {
|
|
265
|
+
obj[key] = Object.assign({}, value);
|
|
266
|
+
} else {
|
|
267
|
+
obj[key] = value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return v8.serialize(obj).toString('base64');
|
|
271
|
+
};
|
|
272
|
+
renderer.deserialize = (serialized)=>{
|
|
273
|
+
if (!serialized) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const data = v8.deserialize(Buffer.from(serialized, 'base64'));
|
|
277
|
+
for (const [key, value] of Object.entries(data)){
|
|
278
|
+
renderer[key] = value;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
return renderer;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function createRenderer() {
|
|
286
|
+
return createRenderer$1({
|
|
287
|
+
enhancers: [
|
|
288
|
+
className([
|
|
289
|
+
'ad'
|
|
290
|
+
]),
|
|
291
|
+
scopedCache(),
|
|
292
|
+
serializedCache([
|
|
293
|
+
'cache',
|
|
294
|
+
'classPropertyList',
|
|
295
|
+
'accessedKeys',
|
|
296
|
+
'uniqueRuleIdentifier',
|
|
297
|
+
'uniqueKeyframeIdentifier'
|
|
298
|
+
]),
|
|
299
|
+
evaluatedResult(),
|
|
300
|
+
renderToString(),
|
|
301
|
+
nestedStatic()
|
|
302
|
+
]
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export { createRenderer };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Renderer } from './createRenderer.js';
|
|
2
|
+
import 'fela';
|
|
3
|
+
import '@navita/types';
|
|
4
|
+
|
|
5
|
+
interface Params {
|
|
6
|
+
source: string;
|
|
7
|
+
key?: string;
|
|
8
|
+
filepath: string;
|
|
9
|
+
isServer?: boolean;
|
|
10
|
+
renderer: Renderer;
|
|
11
|
+
}
|
|
12
|
+
declare function evaluateAndProcess({ source, renderer, filepath }: Params): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export { evaluateAndProcess };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_path = require('node:path');
|
|
4
|
+
var vm = require('node:vm');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var vm__namespace = /*#__PURE__*/_interopNamespaceDefault(vm);
|
|
24
|
+
|
|
25
|
+
async function evaluateAndProcess({ source , renderer , filepath }) {
|
|
26
|
+
/**
|
|
27
|
+
* This needs to be loaded via require. The resolving logic in vm.Script is using
|
|
28
|
+
* cjs to populate the renderer. We need to point to the same instance.
|
|
29
|
+
*/ require('./').setAdapter(renderer);
|
|
30
|
+
const requireLike = (request)=>{
|
|
31
|
+
const resolved = (()=>{
|
|
32
|
+
try {
|
|
33
|
+
return require.resolve(request, {
|
|
34
|
+
paths: [
|
|
35
|
+
node_path.dirname(filepath),
|
|
36
|
+
// This allows us to use modules in this package.
|
|
37
|
+
__dirname
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
// If we couldn't find the module, try with the request,
|
|
45
|
+
// so we'll get correct error messages.
|
|
46
|
+
return require(resolved || request);
|
|
47
|
+
};
|
|
48
|
+
const context = {};
|
|
49
|
+
const globalProperties = Object.getOwnPropertyNames(global);
|
|
50
|
+
globalProperties.forEach((key)=>{
|
|
51
|
+
context[key] = global[key];
|
|
52
|
+
});
|
|
53
|
+
const vmGlobals = new vm__namespace.Script('Object.getOwnPropertyNames(globalThis)').runInNewContext();
|
|
54
|
+
Object.keys(vmGlobals).forEach((key)=>{
|
|
55
|
+
context[key] = vmGlobals[key];
|
|
56
|
+
});
|
|
57
|
+
context['require'] = requireLike;
|
|
58
|
+
context['console'] = console;
|
|
59
|
+
const script = new vm__namespace.Script(source, {
|
|
60
|
+
filename: filepath
|
|
61
|
+
});
|
|
62
|
+
script.runInContext(vm__namespace.createContext(context));
|
|
63
|
+
renderer.setFilePath(undefined);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.evaluateAndProcess = evaluateAndProcess;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { fileURLToPath as fileURLToPath$1 } from 'url';
|
|
2
|
+
const __filename = fileURLToPath$1(import.meta.url);
|
|
3
|
+
import { dirname as dirname$1 } from 'path';
|
|
4
|
+
const __dirname = dirname$1(__filename);
|
|
5
|
+
import { createRequire as createRequire$1 } from 'module';
|
|
6
|
+
const require = createRequire$1(import.meta.url);
|
|
7
|
+
import { dirname } from 'node:path';
|
|
8
|
+
import * as vm from 'node:vm';
|
|
9
|
+
|
|
10
|
+
async function evaluateAndProcess({ source , renderer , filepath }) {
|
|
11
|
+
/**
|
|
12
|
+
* This needs to be loaded via require. The resolving logic in vm.Script is using
|
|
13
|
+
* cjs to populate the renderer. We need to point to the same instance.
|
|
14
|
+
*/ require('./').setAdapter(renderer);
|
|
15
|
+
const requireLike = (request)=>{
|
|
16
|
+
const resolved = (()=>{
|
|
17
|
+
try {
|
|
18
|
+
return require.resolve(request, {
|
|
19
|
+
paths: [
|
|
20
|
+
dirname(filepath),
|
|
21
|
+
// This allows us to use modules in this package.
|
|
22
|
+
__dirname
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
})();
|
|
29
|
+
// If we couldn't find the module, try with the request,
|
|
30
|
+
// so we'll get correct error messages.
|
|
31
|
+
return require(resolved || request);
|
|
32
|
+
};
|
|
33
|
+
const context = {};
|
|
34
|
+
const globalProperties = Object.getOwnPropertyNames(global);
|
|
35
|
+
globalProperties.forEach((key)=>{
|
|
36
|
+
context[key] = global[key];
|
|
37
|
+
});
|
|
38
|
+
const vmGlobals = new vm.Script('Object.getOwnPropertyNames(globalThis)').runInNewContext();
|
|
39
|
+
Object.keys(vmGlobals).forEach((key)=>{
|
|
40
|
+
context[key] = vmGlobals[key];
|
|
41
|
+
});
|
|
42
|
+
context['require'] = requireLike;
|
|
43
|
+
context['console'] = console;
|
|
44
|
+
const script = new vm.Script(source, {
|
|
45
|
+
filename: filepath
|
|
46
|
+
});
|
|
47
|
+
script.runInContext(vm.createContext(context));
|
|
48
|
+
renderer.setFilePath(undefined);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { evaluateAndProcess };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StyleRule, GlobalStyleRule, CSSKeyframes } from '@navita/types';
|
|
2
|
+
import { Renderer } from './createRenderer.js';
|
|
3
|
+
import 'fela';
|
|
4
|
+
|
|
5
|
+
type Adapter = {
|
|
6
|
+
generateIdentifier: typeof generateIdentifier;
|
|
7
|
+
setCss: typeof setCss;
|
|
8
|
+
setStaticCss: typeof setStaticCss;
|
|
9
|
+
setKeyFrame: typeof setKeyFrame;
|
|
10
|
+
collectResult?: typeof collectResult;
|
|
11
|
+
};
|
|
12
|
+
declare const setAdapter: (renderer: Renderer) => void;
|
|
13
|
+
declare function generateIdentifier(value: unknown): string;
|
|
14
|
+
declare function setCss(css: StyleRule): string;
|
|
15
|
+
declare function setStaticCss(selector: string, css: GlobalStyleRule): void;
|
|
16
|
+
declare function setKeyFrame(keyframe: CSSKeyframes): string;
|
|
17
|
+
declare function collectResult<T>(input: {
|
|
18
|
+
filePath: string;
|
|
19
|
+
index: number;
|
|
20
|
+
result: () => T;
|
|
21
|
+
}): T;
|
|
22
|
+
|
|
23
|
+
export { Adapter, collectResult, generateIdentifier, setAdapter, setCss, setKeyFrame, setStaticCss };
|
package/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var hash = require('@emotion/hash');
|
|
4
|
+
|
|
5
|
+
let adapter = undefined;
|
|
6
|
+
const setAdapter = (renderer)=>{
|
|
7
|
+
adapter = {
|
|
8
|
+
generateIdentifier: (value)=>{
|
|
9
|
+
const identifier = hash(JSON.stringify(value));
|
|
10
|
+
return identifier.match(/^[0-9]/) ? "_".concat(identifier) : identifier;
|
|
11
|
+
},
|
|
12
|
+
setStaticCss: (selector, css)=>{
|
|
13
|
+
return renderer.renderStatic(css, selector);
|
|
14
|
+
},
|
|
15
|
+
setCss: (css)=>{
|
|
16
|
+
return renderer.renderRule(()=>css);
|
|
17
|
+
},
|
|
18
|
+
setKeyFrame (keyframe) {
|
|
19
|
+
return renderer.renderKeyframe(()=>keyframe, JSON.stringify(keyframe));
|
|
20
|
+
},
|
|
21
|
+
collectResult ({ filePath , index , result }) {
|
|
22
|
+
// If it's the first index, we can clear the accessed keys.
|
|
23
|
+
if (index === 0) {
|
|
24
|
+
renderer.clearAccessedKeys(filePath);
|
|
25
|
+
}
|
|
26
|
+
// Filepath is used to scope the cache.
|
|
27
|
+
renderer.setFilePath(filePath);
|
|
28
|
+
const collected = result();
|
|
29
|
+
renderer.setEvaluatedResult(filePath, index, collected);
|
|
30
|
+
return collected;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
function generateIdentifier(value) {
|
|
35
|
+
return adapter?.generateIdentifier(value);
|
|
36
|
+
}
|
|
37
|
+
function setCss(css) {
|
|
38
|
+
return adapter?.setCss(css);
|
|
39
|
+
}
|
|
40
|
+
function setStaticCss(selector, css) {
|
|
41
|
+
return adapter?.setStaticCss(selector, css);
|
|
42
|
+
}
|
|
43
|
+
function setKeyFrame(keyframe) {
|
|
44
|
+
return adapter?.setKeyFrame(keyframe);
|
|
45
|
+
}
|
|
46
|
+
function collectResult(input) {
|
|
47
|
+
return adapter?.collectResult?.(input);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.collectResult = collectResult;
|
|
51
|
+
exports.generateIdentifier = generateIdentifier;
|
|
52
|
+
exports.setAdapter = setAdapter;
|
|
53
|
+
exports.setCss = setCss;
|
|
54
|
+
exports.setKeyFrame = setKeyFrame;
|
|
55
|
+
exports.setStaticCss = setStaticCss;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import hash from '@emotion/hash';
|
|
2
|
+
|
|
3
|
+
let adapter = undefined;
|
|
4
|
+
const setAdapter = (renderer)=>{
|
|
5
|
+
adapter = {
|
|
6
|
+
generateIdentifier: (value)=>{
|
|
7
|
+
const identifier = hash(JSON.stringify(value));
|
|
8
|
+
return identifier.match(/^[0-9]/) ? "_".concat(identifier) : identifier;
|
|
9
|
+
},
|
|
10
|
+
setStaticCss: (selector, css)=>{
|
|
11
|
+
return renderer.renderStatic(css, selector);
|
|
12
|
+
},
|
|
13
|
+
setCss: (css)=>{
|
|
14
|
+
return renderer.renderRule(()=>css);
|
|
15
|
+
},
|
|
16
|
+
setKeyFrame (keyframe) {
|
|
17
|
+
return renderer.renderKeyframe(()=>keyframe, JSON.stringify(keyframe));
|
|
18
|
+
},
|
|
19
|
+
collectResult ({ filePath , index , result }) {
|
|
20
|
+
// If it's the first index, we can clear the accessed keys.
|
|
21
|
+
if (index === 0) {
|
|
22
|
+
renderer.clearAccessedKeys(filePath);
|
|
23
|
+
}
|
|
24
|
+
// Filepath is used to scope the cache.
|
|
25
|
+
renderer.setFilePath(filePath);
|
|
26
|
+
const collected = result();
|
|
27
|
+
renderer.setEvaluatedResult(filePath, index, collected);
|
|
28
|
+
return collected;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
function generateIdentifier(value) {
|
|
33
|
+
return adapter?.generateIdentifier(value);
|
|
34
|
+
}
|
|
35
|
+
function setCss(css) {
|
|
36
|
+
return adapter?.setCss(css);
|
|
37
|
+
}
|
|
38
|
+
function setStaticCss(selector, css) {
|
|
39
|
+
return adapter?.setStaticCss(selector, css);
|
|
40
|
+
}
|
|
41
|
+
function setKeyFrame(keyframe) {
|
|
42
|
+
return adapter?.setKeyFrame(keyframe);
|
|
43
|
+
}
|
|
44
|
+
function collectResult(input) {
|
|
45
|
+
return adapter?.collectResult?.(input);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { collectResult, generateIdentifier, setAdapter, setCss, setKeyFrame, setStaticCss };
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@navita/core",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"private": false,
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.mjs",
|
|
10
|
+
"require": "./index.js",
|
|
11
|
+
"types": "./index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./*": {
|
|
14
|
+
"import": "./*.mjs",
|
|
15
|
+
"require": "./*.js",
|
|
16
|
+
"types": "./*.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@navita/types": "*",
|
|
22
|
+
"@emotion/hash": "^0.9.0",
|
|
23
|
+
"fela": "12.2.1",
|
|
24
|
+
"fela-tools": "12.2.1",
|
|
25
|
+
"fela-utils": "12.2.1"
|
|
26
|
+
}
|
|
27
|
+
}
|