@codeleap/styles 6.2.3 → 6.3.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/package.json +2 -2
- package/package.json.bak +1 -1
- package/src/theme/tests/themeStore.spec.ts +37 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/styles",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"directory": "packages/styles"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@codeleap/config": "6.
|
|
12
|
+
"@codeleap/config": "6.3.0",
|
|
13
13
|
"ts-node-dev": "^1.1.8"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
package/package.json.bak
CHANGED
|
@@ -14,7 +14,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
14
14
|
it('should handle theme management', () => {
|
|
15
15
|
const mockTheme = {
|
|
16
16
|
colors: { primary: '#007bff' },
|
|
17
|
-
spacing: { small: '8px' }
|
|
17
|
+
spacing: { small: '8px' },
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
store.setTheme(mockTheme)
|
|
@@ -39,21 +39,21 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
39
39
|
secondary: `#${(i * 2).toString(16).padStart(6, '0')}`,
|
|
40
40
|
background: `#${(i * 3).toString(16).padStart(6, '0')}`,
|
|
41
41
|
surface: `#${(i * 4).toString(16).padStart(6, '0')}`,
|
|
42
|
-
text: `#${(i * 5).toString(16).padStart(6, '0')}
|
|
42
|
+
text: `#${(i * 5).toString(16).padStart(6, '0')}`,
|
|
43
43
|
},
|
|
44
44
|
spacing: {
|
|
45
45
|
xs: `${i}px`,
|
|
46
46
|
sm: `${i * 2}px`,
|
|
47
47
|
md: `${i * 4}px`,
|
|
48
48
|
lg: `${i * 8}px`,
|
|
49
|
-
xl: `${i * 16}px
|
|
49
|
+
xl: `${i * 16}px`,
|
|
50
50
|
},
|
|
51
51
|
typography: {
|
|
52
52
|
fontSize: `${i}px`,
|
|
53
53
|
fontWeight: i % 900,
|
|
54
|
-
lineHeight: i / 100
|
|
54
|
+
lineHeight: i / 100,
|
|
55
55
|
},
|
|
56
|
-
iteration: i
|
|
56
|
+
iteration: i,
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
store.setTheme(theme)
|
|
@@ -88,14 +88,14 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
88
88
|
variants: {
|
|
89
89
|
light: `#${(scheme * color + 100000).toString(16).padStart(6, '0')}`,
|
|
90
90
|
dark: `#${(scheme * color + 200000).toString(16).padStart(6, '0')}`,
|
|
91
|
-
medium: `#${(scheme * color + 300000).toString(16).padStart(6, '0')}
|
|
91
|
+
medium: `#${(scheme * color + 300000).toString(16).padStart(6, '0')}`,
|
|
92
92
|
},
|
|
93
93
|
states: {
|
|
94
94
|
hover: `#${(scheme * color + 400000).toString(16).padStart(6, '0')}`,
|
|
95
95
|
active: `#${(scheme * color + 500000).toString(16).padStart(6, '0')}`,
|
|
96
96
|
disabled: `#${(scheme * color + 600000).toString(16).padStart(6, '0')}`,
|
|
97
|
-
focus: `#${(scheme * color + 700000).toString(16).padStart(6, '0')}
|
|
98
|
-
}
|
|
97
|
+
focus: `#${(scheme * color + 700000).toString(16).padStart(6, '0')}`,
|
|
98
|
+
},
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
colorSchemes[`scheme_${scheme}`] = colors
|
|
@@ -120,8 +120,8 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
120
120
|
base: {
|
|
121
121
|
primary: '#000000',
|
|
122
122
|
secondary: '#111111',
|
|
123
|
-
tertiary: '#222222'
|
|
124
|
-
}
|
|
123
|
+
tertiary: '#222222',
|
|
124
|
+
},
|
|
125
125
|
})
|
|
126
126
|
|
|
127
127
|
for (let i = 0; i < operations; i++) {
|
|
@@ -130,7 +130,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
130
130
|
primary: `#${i.toString(16).padStart(6, '0')}`,
|
|
131
131
|
accent: `#${(i * 2).toString(16).padStart(6, '0')}`,
|
|
132
132
|
background: `#${(i * 3).toString(16).padStart(6, '0')}`,
|
|
133
|
-
customColor: `#${(i * 4).toString(16).padStart(6, '0')}
|
|
133
|
+
customColor: `#${(i * 4).toString(16).padStart(6, '0')}`,
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// Inject scheme
|
|
@@ -150,7 +150,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
150
150
|
const endTime = performance.now()
|
|
151
151
|
const executionTime = endTime - startTime
|
|
152
152
|
|
|
153
|
-
expect(executionTime).toBeLessThan(
|
|
153
|
+
expect(executionTime).toBeLessThan(3500) // Should be fast
|
|
154
154
|
console.log(`Color scheme operations: ${operations} inject/eject operations in ${executionTime.toFixed(2)}ms`)
|
|
155
155
|
})
|
|
156
156
|
|
|
@@ -172,14 +172,14 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
172
172
|
margin: `${comp * variant}px`,
|
|
173
173
|
borderRadius: `${variant / 2}px`,
|
|
174
174
|
transform: `rotate(${variant}deg) scale(${1 + comp / 100})`,
|
|
175
|
-
boxShadow: `${variant}px ${comp}px ${comp + variant}px rgba(${comp}, ${variant}, ${comp + variant}, 0.${variant})
|
|
175
|
+
boxShadow: `${variant}px ${comp}px ${comp + variant}px rgba(${comp}, ${variant}, ${comp + variant}, 0.${variant})`,
|
|
176
176
|
},
|
|
177
177
|
states: {
|
|
178
178
|
hover: { opacity: 0.8 + (variant / 100) },
|
|
179
179
|
active: { transform: `scale(${1 + variant / 1000})` },
|
|
180
180
|
disabled: { opacity: 0.5 },
|
|
181
|
-
focus: { outline: `${variant}px solid #${comp.toString(16).padStart(6, '0')}` }
|
|
182
|
-
}
|
|
181
|
+
focus: { outline: `${variant}px solid #${comp.toString(16).padStart(6, '0')}` },
|
|
182
|
+
},
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
variants[`component_${comp}`] = componentVariants
|
|
@@ -206,7 +206,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
206
206
|
// Simultaneous updates
|
|
207
207
|
store.setTheme({
|
|
208
208
|
colors: { primary: `#${i.toString(16).padStart(6, '0')}` },
|
|
209
|
-
iteration: i
|
|
209
|
+
iteration: i,
|
|
210
210
|
})
|
|
211
211
|
|
|
212
212
|
store.setColorScheme(`scheme_${i % 50}`)
|
|
@@ -215,14 +215,14 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
215
215
|
[`component_${i}`]: {
|
|
216
216
|
[`variant_${i}`]: {
|
|
217
217
|
className: `test-${i}`,
|
|
218
|
-
styles: { color: `#${i.toString(16).padStart(6, '0')}` }
|
|
219
|
-
}
|
|
220
|
-
}
|
|
218
|
+
styles: { color: `#${i.toString(16).padStart(6, '0')}` },
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
221
|
})
|
|
222
222
|
|
|
223
223
|
store.injectColorScheme(`dynamic_${i % 100}`, {
|
|
224
224
|
primary: `#${(i * 2).toString(16).padStart(6, '0')}`,
|
|
225
|
-
secondary: `#${(i * 3).toString(16).padStart(6, '0')}
|
|
225
|
+
secondary: `#${(i * 3).toString(16).padStart(6, '0')}`,
|
|
226
226
|
})
|
|
227
227
|
|
|
228
228
|
// Verify consistency every 200 iterations
|
|
@@ -251,7 +251,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
251
251
|
spacing: {},
|
|
252
252
|
calculators: {},
|
|
253
253
|
transformers: {},
|
|
254
|
-
validators: {}
|
|
254
|
+
validators: {},
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
const startTime = performance.now()
|
|
@@ -268,14 +268,14 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
268
268
|
offset: input + (i * 3.14159),
|
|
269
269
|
computed: Math.sin(input + i) * 100,
|
|
270
270
|
conditional: input > i ? input * 2 : input / 2,
|
|
271
|
-
recursive: i > 0 ? theme.calculators[`calc_${i - 1}`]?.(input) || input : input
|
|
271
|
+
recursive: i > 0 ? theme.calculators[`calc_${i - 1}`]?.(input) || input : input,
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
// Spacing functions
|
|
276
276
|
theme.spacing[`space_${i}`] = (multiplier = 1) => `${i * 8 * multiplier}px`
|
|
277
277
|
|
|
278
|
-
// Color functions
|
|
278
|
+
// Color functions
|
|
279
279
|
theme.colors[`color_${i}`] = (opacity = 1) => {
|
|
280
280
|
const r = (i * 37) % 256
|
|
281
281
|
const g = (i * 73) % 256
|
|
@@ -324,7 +324,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
324
324
|
// Test some complex chaining every 100 iterations
|
|
325
325
|
if (i % 100 === 0) {
|
|
326
326
|
const chainResult = getThemeStore()?.transformers[`transform_${i}`]?.(
|
|
327
|
-
getThemeStore()?.calculators[`calc_${i}`]?.(testValue) || 0
|
|
327
|
+
getThemeStore()?.calculators[`calc_${i}`]?.(testValue) || 0,
|
|
328
328
|
)
|
|
329
329
|
if (chainResult) executionResults++
|
|
330
330
|
}
|
|
@@ -350,7 +350,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
350
350
|
fibonacci: {},
|
|
351
351
|
factorial: {},
|
|
352
352
|
compose: {},
|
|
353
|
-
pipeline: {}
|
|
353
|
+
pipeline: {},
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
// Fibonacci functions
|
|
@@ -392,7 +392,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
392
392
|
(x) => x + i,
|
|
393
393
|
(x) => Math.pow(x, 1.5),
|
|
394
394
|
(x) => x % 1000,
|
|
395
|
-
(x) => theme.compose[`comp_${Math.min(i, depth - 1)}`]?.(x) || x
|
|
395
|
+
(x) => theme.compose[`comp_${Math.min(i, depth - 1)}`]?.(x) || x,
|
|
396
396
|
]
|
|
397
397
|
return steps.reduce((acc, fn) => fn(acc), input)
|
|
398
398
|
}
|
|
@@ -427,7 +427,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
427
427
|
// Test chained execution
|
|
428
428
|
if (i % 50 === 0) {
|
|
429
429
|
const chainedResult = getThemeStore()?.pipeline[`pipe_${i % depth}`]?.(
|
|
430
|
-
getThemeStore()?.compose[`comp_${i % depth}`]?.(testValue) || 0
|
|
430
|
+
getThemeStore()?.compose[`comp_${i % depth}`]?.(testValue) || 0,
|
|
431
431
|
)
|
|
432
432
|
if (typeof chainedResult === 'number') successfulExecutions++
|
|
433
433
|
}
|
|
@@ -452,7 +452,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
452
452
|
const theme = {
|
|
453
453
|
factories: {},
|
|
454
454
|
generated: {},
|
|
455
|
-
dynamicComputed: {}
|
|
455
|
+
dynamicComputed: {},
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
const startTime = performance.now()
|
|
@@ -467,9 +467,9 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
467
467
|
original: value,
|
|
468
468
|
scaled: value * (config.scale || 1),
|
|
469
469
|
formatted: `${config.prefix || ''}${value}${config.suffix || ''}`,
|
|
470
|
-
computed: Math.pow(value, config.power || 1)
|
|
470
|
+
computed: Math.pow(value, config.power || 1),
|
|
471
471
|
}),
|
|
472
|
-
composer: (...fns) => (value) => fns.reduce((acc, fn) => fn(acc), value)
|
|
472
|
+
composer: (...fns) => (value) => fns.reduce((acc, fn) => fn(acc), value),
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
475
|
|
|
@@ -483,7 +483,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
483
483
|
max: i * 100,
|
|
484
484
|
prefix: `gen_${i}_`,
|
|
485
485
|
suffix: `_${j}`,
|
|
486
|
-
power: 1 + (j / 5)
|
|
486
|
+
power: 1 + (j / 5),
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
const generatedFunctions = theme.factories[`factory_${i}`](config)
|
|
@@ -499,7 +499,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
499
499
|
calculated: calc,
|
|
500
500
|
isValid: valid,
|
|
501
501
|
transformed: transform,
|
|
502
|
-
final: valid ? transform.computed : 0
|
|
502
|
+
final: valid ? transform.computed : 0,
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
}
|
|
@@ -545,7 +545,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
545
545
|
const composed = generated.composer(
|
|
546
546
|
(x) => x * 2,
|
|
547
547
|
(x) => x + 10,
|
|
548
|
-
generated.calculator
|
|
548
|
+
generated.calculator,
|
|
549
549
|
)(testValue)
|
|
550
550
|
if (typeof composed === 'number') executionCount++
|
|
551
551
|
}
|
|
@@ -581,7 +581,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
581
581
|
colors: {},
|
|
582
582
|
spacing: {},
|
|
583
583
|
typography: {},
|
|
584
|
-
components: {}
|
|
584
|
+
components: {},
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
for (let i = 0; i < itemsPerSet; i++) {
|
|
@@ -590,7 +590,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
590
590
|
hugeTheme.typography[`font_${i}`] = `${i}px`
|
|
591
591
|
hugeTheme.components[`comp_${i}`] = {
|
|
592
592
|
styles: { margin: `${i}px` },
|
|
593
|
-
variants: Array.from({ length: 10 }, (_, j) => `variant_${j}`)
|
|
593
|
+
variants: Array.from({ length: 10 }, (_, j) => `variant_${j}`),
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
596
|
|
|
@@ -630,7 +630,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
630
630
|
for (let i = 0; i < updates; i++) {
|
|
631
631
|
themeStore.setTheme({
|
|
632
632
|
colors: { primary: `#${i.toString(16).padStart(6, '0')}` },
|
|
633
|
-
iteration: i
|
|
633
|
+
iteration: i,
|
|
634
634
|
})
|
|
635
635
|
themeStore.setColorScheme(`scheme_${i % 100}`)
|
|
636
636
|
|
|
@@ -681,7 +681,7 @@ describe('ThemeStore - Heavy Load Tests', () => {
|
|
|
681
681
|
for (let i = 0; i < updates; i++) {
|
|
682
682
|
themeStore.setTheme({
|
|
683
683
|
colors: { primary: `#${i.toString(16).padStart(6, '0')}` },
|
|
684
|
-
iteration: i
|
|
684
|
+
iteration: i,
|
|
685
685
|
})
|
|
686
686
|
}
|
|
687
687
|
|