@codeleap/styles 4.2.8 → 4.2.10
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 +4 -5
- package/package.json.bak +3 -4
- package/src/lib/borderCreator.ts +5 -3
- package/src/lib/constants.ts +3 -0
- package/src/lib/dynamicVariants.ts +28 -13
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -26
- package/dist/lib/Cacher.d.ts +0 -37
- package/dist/lib/Cacher.js +0 -104
- package/dist/lib/StaleControl.d.ts +0 -21
- package/dist/lib/StaleControl.js +0 -78
- package/dist/lib/StyleCache.d.ts +0 -20
- package/dist/lib/StyleCache.js +0 -83
- package/dist/lib/StylePersistor.d.ts +0 -13
- package/dist/lib/StylePersistor.js +0 -22
- package/dist/lib/StyleRegistry.d.ts +0 -47
- package/dist/lib/StyleRegistry.js +0 -513
- package/dist/lib/borderCreator.d.ts +0 -11
- package/dist/lib/borderCreator.js +0 -44
- package/dist/lib/constants.d.ts +0 -5
- package/dist/lib/constants.js +0 -8
- package/dist/lib/createAppVariants.d.ts +0 -6
- package/dist/lib/createAppVariants.js +0 -9
- package/dist/lib/createStyles.d.ts +0 -4
- package/dist/lib/createStyles.js +0 -27
- package/dist/lib/createTheme.d.ts +0 -7
- package/dist/lib/createTheme.js +0 -74
- package/dist/lib/defaultVariants.d.ts +0 -178
- package/dist/lib/defaultVariants.js +0 -179
- package/dist/lib/dynamicVariants.d.ts +0 -12
- package/dist/lib/dynamicVariants.js +0 -88
- package/dist/lib/hashKey.d.ts +0 -1
- package/dist/lib/hashKey.js +0 -14
- package/dist/lib/hooks.d.ts +0 -8
- package/dist/lib/hooks.js +0 -76
- package/dist/lib/index.d.ts +0 -10
- package/dist/lib/index.js +0 -37
- package/dist/lib/mediaQuery.d.ts +0 -11
- package/dist/lib/mediaQuery.js +0 -65
- package/dist/lib/minifier.d.ts +0 -6
- package/dist/lib/minifier.js +0 -21
- package/dist/lib/multiplierProperty.d.ts +0 -3
- package/dist/lib/multiplierProperty.js +0 -13
- package/dist/lib/spacing.d.ts +0 -11
- package/dist/lib/spacing.js +0 -104
- package/dist/lib/themeStore.d.ts +0 -7
- package/dist/lib/themeStore.js +0 -9
- package/dist/lib/utils.d.ts +0 -8
- package/dist/lib/utils.js +0 -177
- package/dist/lib/validateTheme.d.ts +0 -2
- package/dist/lib/validateTheme.js +0 -68
- package/dist/types/cache.d.ts +0 -1
- package/dist/types/cache.js +0 -2
- package/dist/types/component.d.ts +0 -25
- package/dist/types/component.js +0 -2
- package/dist/types/core.d.ts +0 -20
- package/dist/types/core.js +0 -2
- package/dist/types/icon.d.ts +0 -4
- package/dist/types/icon.js +0 -3
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -21
- package/dist/types/spacing.d.ts +0 -6
- package/dist/types/spacing.js +0 -21
- package/dist/types/style.d.ts +0 -14
- package/dist/types/style.js +0 -2
- package/dist/types/theme.d.ts +0 -67
- package/dist/types/theme.js +0 -2
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/styles",
|
|
3
|
-
"version": "4.2.
|
|
4
|
-
"main": "
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "4.2.10",
|
|
4
|
+
"main": "src/index.ts",
|
|
6
5
|
"license": "UNLICENSED",
|
|
7
6
|
"repository": {
|
|
8
7
|
"url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
|
|
@@ -10,11 +9,11 @@
|
|
|
10
9
|
"directory": "packages/styles"
|
|
11
10
|
},
|
|
12
11
|
"devDependencies": {
|
|
13
|
-
"@codeleap/config": "4.2.
|
|
12
|
+
"@codeleap/config": "4.2.10",
|
|
14
13
|
"ts-node-dev": "1.1.8"
|
|
15
14
|
},
|
|
16
15
|
"scripts": {
|
|
17
|
-
"build": "
|
|
16
|
+
"build": "echo \"No build script specified\"",
|
|
18
17
|
"lint": "eslint -c .eslintrc.js --fix \"./src/**/*.{ts,tsx,js,jsx}\"",
|
|
19
18
|
"test": "./node_modules/.bin/mocha --require ts-node/register src/tests/**/*.spec.ts",
|
|
20
19
|
"run-sc": "tsnd --transpile-only",
|
package/package.json.bak
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/styles",
|
|
3
|
-
"version": "4.2.
|
|
4
|
-
"main": "
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "4.2.10",
|
|
4
|
+
"main": "src/index.ts",
|
|
6
5
|
"license": "UNLICENSED",
|
|
7
6
|
"repository": {
|
|
8
7
|
"url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
|
|
@@ -14,7 +13,7 @@
|
|
|
14
13
|
"ts-node-dev": "1.1.8"
|
|
15
14
|
},
|
|
16
15
|
"scripts": {
|
|
17
|
-
"build": "
|
|
16
|
+
"build": "echo \"No build script specified\"",
|
|
18
17
|
"lint": "eslint -c .eslintrc.js --fix \"./src/**/*.{ts,tsx,js,jsx}\"",
|
|
19
18
|
"test": "./node_modules/.bin/mocha --require ts-node/register src/tests/**/*.spec.ts",
|
|
20
19
|
"run-sc": "tsnd --transpile-only",
|
package/src/lib/borderCreator.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IColors, ICSS } from '../types'
|
|
2
|
+
import { StyleConstants } from './constants'
|
|
2
3
|
import { borderDirection } from './dynamicVariants'
|
|
3
4
|
import { themeStore } from './themeStore'
|
|
4
5
|
import { capitalize } from './utils'
|
|
@@ -18,12 +19,13 @@ export const borderCreator: BorderCreator = (args) => {
|
|
|
18
19
|
color: colorKey,
|
|
19
20
|
width = 1,
|
|
20
21
|
style = 'solid',
|
|
21
|
-
directions = ['left', 'top', 'bottom', 'right']
|
|
22
|
+
directions = ['left', 'top', 'bottom', 'right'],
|
|
22
23
|
} = args
|
|
23
24
|
|
|
24
25
|
const theme = themeStore.getState().current
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
const color = theme?.colors?.[colorKey] ?? colorKey
|
|
27
29
|
|
|
28
30
|
const borderStyles: ICSS = {}
|
|
29
31
|
|
|
@@ -33,7 +35,7 @@ export const borderCreator: BorderCreator = (args) => {
|
|
|
33
35
|
borderStyles[`${property}Color`] = color
|
|
34
36
|
borderStyles[`${property}Width`] = width
|
|
35
37
|
|
|
36
|
-
if (
|
|
38
|
+
if (StyleConstants.IS_BROWSER) {
|
|
37
39
|
borderStyles[`${property}Style`] = style
|
|
38
40
|
}
|
|
39
41
|
}
|
package/src/lib/constants.ts
CHANGED
|
@@ -11,18 +11,18 @@ export const borderDirection = [...borderYDirection, ...borderXDirection, ''] as
|
|
|
11
11
|
export const borderProperties = ['color', 'radius', 'width'] as const
|
|
12
12
|
|
|
13
13
|
export const cursorTypes = [
|
|
14
|
-
'not-allowed',
|
|
15
|
-
'help',
|
|
16
|
-
'pointer',
|
|
17
|
-
'wait',
|
|
18
|
-
''
|
|
14
|
+
'not-allowed',
|
|
15
|
+
'help',
|
|
16
|
+
'pointer',
|
|
17
|
+
'wait',
|
|
18
|
+
'',
|
|
19
19
|
] as const
|
|
20
20
|
|
|
21
21
|
export type Value =
|
|
22
22
|
| number
|
|
23
23
|
| ''
|
|
24
24
|
|
|
25
|
-
export type DynamicVariants =
|
|
25
|
+
export type DynamicVariants =
|
|
26
26
|
`${typeof colorVariants[number]}:${keyof IColors}` |
|
|
27
27
|
`border${Capitalize<typeof borderDirection[number]>}Width:${keyof IBorderRadius}` |
|
|
28
28
|
`border${Capitalize<typeof borderDirection[number]>}Color:${keyof IColors}` |
|
|
@@ -30,9 +30,12 @@ export type DynamicVariants =
|
|
|
30
30
|
`border${Capitalize<typeof borderYDirection[number]>}${Capitalize<typeof borderXDirection[number]>}Radius:${keyof IBorderRadius}` |
|
|
31
31
|
`cursor:${typeof cursorTypes[number]}` |
|
|
32
32
|
`bg:${keyof IColors}` |
|
|
33
|
+
`br:${keyof IBorderRadius}` |
|
|
34
|
+
`cl:${keyof IColors}` |
|
|
33
35
|
`scale:${Value}`
|
|
34
36
|
|
|
35
37
|
export const createDynamicVariants = () => {
|
|
38
|
+
|
|
36
39
|
const dynamicVariants = {}
|
|
37
40
|
|
|
38
41
|
function createVariant(variantName: string, variantReturn: any) {
|
|
@@ -41,7 +44,7 @@ export const createDynamicVariants = () => {
|
|
|
41
44
|
|
|
42
45
|
colorVariants.forEach(variant => {
|
|
43
46
|
createVariant(variant, (theme, color: keyof IColors) => ({
|
|
44
|
-
[variant]: theme
|
|
47
|
+
[variant]: theme.colors[color],
|
|
45
48
|
}))
|
|
46
49
|
})
|
|
47
50
|
|
|
@@ -51,7 +54,7 @@ export const createDynamicVariants = () => {
|
|
|
51
54
|
const variant = `border${capitalize(direction)}${capitalize(y)}Radius`
|
|
52
55
|
|
|
53
56
|
createVariant(variant, (theme, value: keyof IBorderRadius) => ({
|
|
54
|
-
[variant]: theme
|
|
57
|
+
[variant]: theme.borderRadius[value],
|
|
55
58
|
}))
|
|
56
59
|
})
|
|
57
60
|
}
|
|
@@ -60,21 +63,33 @@ export const createDynamicVariants = () => {
|
|
|
60
63
|
const variant = `border${capitalize(direction)}${capitalize(property)}`
|
|
61
64
|
|
|
62
65
|
createVariant(variant, (theme, value: string) => ({
|
|
63
|
-
[variant]: property == 'color' ? theme
|
|
66
|
+
[variant]: property == 'color' ? theme.colors[value] : theme.borderRadius[value],
|
|
64
67
|
}))
|
|
65
68
|
})
|
|
66
69
|
})
|
|
67
70
|
|
|
68
71
|
createVariant('cursor', (theme, cursor: typeof cursorTypes[number]) => ({ cursor }))
|
|
69
72
|
|
|
70
|
-
createVariant('bg', (theme, color: keyof IColors) => ({
|
|
71
|
-
backgroundColor: theme
|
|
73
|
+
createVariant('bg', (theme, color: keyof IColors) => ({
|
|
74
|
+
backgroundColor: theme.colors[color],
|
|
75
|
+
}))
|
|
76
|
+
|
|
77
|
+
createVariant('cl', (theme, color: keyof IColors) => ({
|
|
78
|
+
color: theme.colors[color],
|
|
72
79
|
}))
|
|
73
80
|
|
|
74
|
-
createVariant('effect', (theme, effect: keyof IEffects) => theme
|
|
81
|
+
createVariant('effect', (theme, effect: keyof IEffects) => theme.effects[effect])
|
|
75
82
|
|
|
76
83
|
createVariant('scale', (theme, value: any) => ({
|
|
77
|
-
transform:
|
|
84
|
+
transform: theme.isBrowser ? `scale(${value})` : [{ 'scale': Number(value) }],
|
|
85
|
+
}))
|
|
86
|
+
|
|
87
|
+
createVariant('br', (theme, value: keyof IBorderRadius) => ({
|
|
88
|
+
borderRadius: theme.borderRadius[value],
|
|
89
|
+
}))
|
|
90
|
+
|
|
91
|
+
createVariant('borderRadius', (theme, value: keyof IBorderRadius) => ({
|
|
92
|
+
borderRadius: theme.borderRadius[value],
|
|
78
93
|
}))
|
|
79
94
|
|
|
80
95
|
return dynamicVariants
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.deepmerge = void 0;
|
|
21
|
-
require("./lib/constants");
|
|
22
|
-
require("./lib/utils");
|
|
23
|
-
__exportStar(require("./lib"), exports);
|
|
24
|
-
__exportStar(require("./types"), exports);
|
|
25
|
-
var deepmerge_1 = require("@fastify/deepmerge");
|
|
26
|
-
Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return __importDefault(deepmerge_1).default; } });
|
package/dist/lib/Cacher.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { StateStorage } from 'zustand/middleware';
|
|
2
|
-
import { AnyRecord } from '../types';
|
|
3
|
-
import { CacheType } from '../types/cache';
|
|
4
|
-
type StorePersistor = {
|
|
5
|
-
cached: AnyRecord;
|
|
6
|
-
cacheFor: (key: string, value: any) => void;
|
|
7
|
-
staleTime: Date;
|
|
8
|
-
reset: () => void;
|
|
9
|
-
};
|
|
10
|
-
export declare class Cache<T extends any = any> {
|
|
11
|
-
registryName: CacheType;
|
|
12
|
-
private storage;
|
|
13
|
-
persistCache: boolean;
|
|
14
|
-
cache: Record<string, T>;
|
|
15
|
-
persistor: any;
|
|
16
|
-
store: StorePersistor;
|
|
17
|
-
constructor(registryName: CacheType, storage?: StateStorage, persistCache?: boolean);
|
|
18
|
-
keyFor(cacheBaseKey: string, data: Array<any> | any): {
|
|
19
|
-
key: string;
|
|
20
|
-
value: T;
|
|
21
|
-
};
|
|
22
|
-
cacheFor(key: string, cache: T): T;
|
|
23
|
-
setCache(cache: Record<string, T>): void;
|
|
24
|
-
clear(): void;
|
|
25
|
-
createPersistor(registryName: string): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<StorePersistor>, "persist"> & {
|
|
26
|
-
persist: {
|
|
27
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<StorePersistor, StorePersistor>>) => void;
|
|
28
|
-
clearStorage: () => void;
|
|
29
|
-
rehydrate: () => void | Promise<void>;
|
|
30
|
-
hasHydrated: () => boolean;
|
|
31
|
-
onHydrate: (fn: (state: StorePersistor) => void) => () => void;
|
|
32
|
-
onFinishHydration: (fn: (state: StorePersistor) => void) => () => void;
|
|
33
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<StorePersistor, StorePersistor>>;
|
|
34
|
-
};
|
|
35
|
-
}>;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
package/dist/lib/Cacher.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Cache = void 0;
|
|
4
|
-
var zustand_1 = require("zustand");
|
|
5
|
-
var middleware_1 = require("zustand/middleware");
|
|
6
|
-
var constants_1 = require("./constants");
|
|
7
|
-
var hashKey_1 = require("./hashKey");
|
|
8
|
-
function getStaleTime() {
|
|
9
|
-
var time = 7;
|
|
10
|
-
var currentTime = new Date();
|
|
11
|
-
currentTime.setDate(currentTime.getDate() + time);
|
|
12
|
-
return currentTime;
|
|
13
|
-
}
|
|
14
|
-
var Cache = /** @class */ (function () {
|
|
15
|
-
function Cache(registryName, storage, persistCache) {
|
|
16
|
-
if (storage === void 0) { storage = null; }
|
|
17
|
-
if (persistCache === void 0) { persistCache = !!storage; }
|
|
18
|
-
this.registryName = registryName;
|
|
19
|
-
this.storage = storage;
|
|
20
|
-
this.persistCache = persistCache;
|
|
21
|
-
this.cache = {};
|
|
22
|
-
this.persistor = null;
|
|
23
|
-
this.store = {
|
|
24
|
-
cached: {},
|
|
25
|
-
cacheFor: function () { return null; },
|
|
26
|
-
reset: function () { return null; },
|
|
27
|
-
staleTime: null
|
|
28
|
-
};
|
|
29
|
-
if (!persistCache)
|
|
30
|
-
return;
|
|
31
|
-
this.createPersistor(registryName);
|
|
32
|
-
if (!constants_1.StyleConstants.STORE_CACHE_ENABLED || !this.persistor)
|
|
33
|
-
return;
|
|
34
|
-
var currentTime = new Date();
|
|
35
|
-
var staleTime = new Date(this.store.staleTime);
|
|
36
|
-
var isStaled = currentTime > staleTime;
|
|
37
|
-
if (isStaled) {
|
|
38
|
-
this.store.reset();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.setCache(this.store.cached);
|
|
42
|
-
}
|
|
43
|
-
Cache.prototype.keyFor = function (cacheBaseKey, data) {
|
|
44
|
-
var _a;
|
|
45
|
-
var values = [cacheBaseKey, data];
|
|
46
|
-
var cacheKey = (0, hashKey_1.hashKey)(values);
|
|
47
|
-
var cachedValue = (_a = this.cache[cacheKey]) !== null && _a !== void 0 ? _a : null;
|
|
48
|
-
return {
|
|
49
|
-
key: cacheKey,
|
|
50
|
-
value: cachedValue,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
Cache.prototype.cacheFor = function (key, cache) {
|
|
54
|
-
this.cache[key] = cache;
|
|
55
|
-
if (this.persistCache)
|
|
56
|
-
this.store.cacheFor(key, cache);
|
|
57
|
-
return cache;
|
|
58
|
-
};
|
|
59
|
-
Cache.prototype.setCache = function (cache) {
|
|
60
|
-
this.cache = cache;
|
|
61
|
-
};
|
|
62
|
-
Cache.prototype.clear = function () {
|
|
63
|
-
this.cache = {};
|
|
64
|
-
if (this.persistCache)
|
|
65
|
-
this.persistor.persist.clearStorage();
|
|
66
|
-
};
|
|
67
|
-
Cache.prototype.createPersistor = function (registryName) {
|
|
68
|
-
var _this = this;
|
|
69
|
-
if (!this.persistCache)
|
|
70
|
-
return null;
|
|
71
|
-
var persistor = (0, zustand_1.create)((0, middleware_1.persist)(function (set, get) { return ({
|
|
72
|
-
staleTime: getStaleTime(),
|
|
73
|
-
cached: {},
|
|
74
|
-
cacheFor: function (key, value) { return set(function (store) {
|
|
75
|
-
var cached = store.cached;
|
|
76
|
-
cached[key] = value;
|
|
77
|
-
return {
|
|
78
|
-
cached: cached
|
|
79
|
-
};
|
|
80
|
-
}); },
|
|
81
|
-
reset: function () { return set({
|
|
82
|
-
cached: {},
|
|
83
|
-
staleTime: getStaleTime()
|
|
84
|
-
}); }
|
|
85
|
-
}); }, {
|
|
86
|
-
name: "@styles.caches.".concat(registryName),
|
|
87
|
-
version: constants_1.StyleConstants.STORES_PERSIST_VERSION,
|
|
88
|
-
migrate: function (persistedState, version) {
|
|
89
|
-
if (version != constants_1.StyleConstants.STORES_PERSIST_VERSION) {
|
|
90
|
-
persistedState.staleTime = getStaleTime();
|
|
91
|
-
persistedState.cached = {};
|
|
92
|
-
return persistedState;
|
|
93
|
-
}
|
|
94
|
-
return persistedState;
|
|
95
|
-
},
|
|
96
|
-
storage: (0, middleware_1.createJSONStorage)(function () { return _this.storage; }),
|
|
97
|
-
}));
|
|
98
|
-
this.persistor = persistor;
|
|
99
|
-
this.store = persistor.getState();
|
|
100
|
-
return persistor;
|
|
101
|
-
};
|
|
102
|
-
return Cache;
|
|
103
|
-
}());
|
|
104
|
-
exports.Cache = Cache;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare class StaleControl {
|
|
2
|
-
private staleTime;
|
|
3
|
-
private staleTimeIdentifier;
|
|
4
|
-
private wiperInterval;
|
|
5
|
-
private wiperId;
|
|
6
|
-
constructor(staleTime?: number, // minutes
|
|
7
|
-
staleTimeIdentifier?: string, wiperInterval?: number);
|
|
8
|
-
isStaled(value: string): boolean;
|
|
9
|
-
insertStaleTime(value: string): string;
|
|
10
|
-
refreshStaleTime(value: string): string;
|
|
11
|
-
extractStaleTime(value: string): {
|
|
12
|
-
staleTime: Date;
|
|
13
|
-
value: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* wipe staled cache; verify isStaled values and remove
|
|
17
|
-
*/
|
|
18
|
-
cacheWiper(): void;
|
|
19
|
-
registerCacheWiper(): void;
|
|
20
|
-
unregisterCacheWiper(): void;
|
|
21
|
-
}
|
package/dist/lib/StaleControl.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.StaleControl = void 0;
|
|
20
|
-
var StaleControl = /** @class */ (function () {
|
|
21
|
-
function StaleControl(staleTime, // minutes
|
|
22
|
-
staleTimeIdentifier, wiperInterval) {
|
|
23
|
-
if (staleTime === void 0) { staleTime = 60; }
|
|
24
|
-
if (staleTimeIdentifier === void 0) { staleTimeIdentifier = '//:'; }
|
|
25
|
-
if (wiperInterval === void 0) { wiperInterval = 30 * 60 * 1000; }
|
|
26
|
-
this.staleTime = staleTime;
|
|
27
|
-
this.staleTimeIdentifier = staleTimeIdentifier;
|
|
28
|
-
this.wiperInterval = wiperInterval;
|
|
29
|
-
this.wiperId = null;
|
|
30
|
-
}
|
|
31
|
-
StaleControl.prototype.isStaled = function (value) {
|
|
32
|
-
var staleTime = this.extractStaleTime(value).staleTime;
|
|
33
|
-
var currentTime = new Date();
|
|
34
|
-
var isStaled = currentTime > staleTime;
|
|
35
|
-
return isStaled;
|
|
36
|
-
};
|
|
37
|
-
StaleControl.prototype.insertStaleTime = function (value) {
|
|
38
|
-
var currentTime = new Date();
|
|
39
|
-
currentTime.setMinutes(currentTime.getMinutes() + this.staleTime);
|
|
40
|
-
var staleTime = currentTime.toISOString();
|
|
41
|
-
var valueWithStaleTime = "".concat(value).concat(this.staleTimeIdentifier).concat(staleTime);
|
|
42
|
-
return valueWithStaleTime;
|
|
43
|
-
};
|
|
44
|
-
StaleControl.prototype.refreshStaleTime = function (value) {
|
|
45
|
-
var extractedValue = this.extractStaleTime(value).value;
|
|
46
|
-
var refreshedValue = this.insertStaleTime(extractedValue);
|
|
47
|
-
return refreshedValue;
|
|
48
|
-
};
|
|
49
|
-
StaleControl.prototype.extractStaleTime = function (value) {
|
|
50
|
-
var _a = __read(value === null || value === void 0 ? void 0 : value.split(this.staleTimeIdentifier), 2), extractedValue = _a[0], _staleTime = _a[1];
|
|
51
|
-
var staleTime = new Date(_staleTime);
|
|
52
|
-
return {
|
|
53
|
-
staleTime: staleTime,
|
|
54
|
-
value: extractedValue,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* wipe staled cache; verify isStaled values and remove
|
|
59
|
-
*/
|
|
60
|
-
StaleControl.prototype.cacheWiper = function () {
|
|
61
|
-
throw new Error('Cache Wiper not implement');
|
|
62
|
-
};
|
|
63
|
-
StaleControl.prototype.registerCacheWiper = function () {
|
|
64
|
-
var _this = this;
|
|
65
|
-
if (this.wiperId !== null) {
|
|
66
|
-
this.unregisterCacheWiper();
|
|
67
|
-
}
|
|
68
|
-
this.wiperId = setInterval(function () {
|
|
69
|
-
_this.cacheWiper();
|
|
70
|
-
}, this.wiperInterval);
|
|
71
|
-
};
|
|
72
|
-
StaleControl.prototype.unregisterCacheWiper = function () {
|
|
73
|
-
clearInterval(this.wiperId);
|
|
74
|
-
this.wiperId = null;
|
|
75
|
-
};
|
|
76
|
-
return StaleControl;
|
|
77
|
-
}());
|
|
78
|
-
exports.StaleControl = StaleControl;
|
package/dist/lib/StyleCache.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Cache } from './Cacher';
|
|
2
|
-
import { CacheType } from '../types/cache';
|
|
3
|
-
import { StateStorage } from 'zustand/middleware';
|
|
4
|
-
export declare class StyleCache {
|
|
5
|
-
baseKey: string;
|
|
6
|
-
styles: Cache<any>;
|
|
7
|
-
compositions: Cache<any>;
|
|
8
|
-
responsive: Cache<any>;
|
|
9
|
-
variants: Cache;
|
|
10
|
-
common: Cache;
|
|
11
|
-
components: Cache;
|
|
12
|
-
constructor(storage: StateStorage);
|
|
13
|
-
registerBaseKey(keys: Array<any>): string;
|
|
14
|
-
wipeCache(): void;
|
|
15
|
-
keyFor(type: CacheType, keyData: Array<any> | any): {
|
|
16
|
-
key: string;
|
|
17
|
-
value: any;
|
|
18
|
-
};
|
|
19
|
-
cacheFor(type: CacheType, key: string, value: any): any;
|
|
20
|
-
}
|
package/dist/lib/StyleCache.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.StyleCache = void 0;
|
|
29
|
-
var Cacher_1 = require("./Cacher");
|
|
30
|
-
var hashKey_1 = require("./hashKey");
|
|
31
|
-
var constants_1 = require("./constants");
|
|
32
|
-
var minifier_1 = require("./minifier");
|
|
33
|
-
var StyleCache = /** @class */ (function () {
|
|
34
|
-
function StyleCache(storage) {
|
|
35
|
-
this.styles = new Cacher_1.Cache('styles');
|
|
36
|
-
this.compositions = new Cacher_1.Cache('compositions');
|
|
37
|
-
this.responsive = new Cacher_1.Cache('responsive');
|
|
38
|
-
this.variants = new Cacher_1.Cache('variants', storage);
|
|
39
|
-
this.common = new Cacher_1.Cache('common', storage);
|
|
40
|
-
this.components = new Cacher_1.Cache('components', storage);
|
|
41
|
-
}
|
|
42
|
-
StyleCache.prototype.registerBaseKey = function (keys) {
|
|
43
|
-
keys.push(constants_1.StyleConstants.STORES_PERSIST_VERSION);
|
|
44
|
-
var baseKey = (0, hashKey_1.hashKey)(keys);
|
|
45
|
-
this.baseKey = baseKey;
|
|
46
|
-
return baseKey;
|
|
47
|
-
};
|
|
48
|
-
StyleCache.prototype.wipeCache = function () {
|
|
49
|
-
this.components.clear();
|
|
50
|
-
this.responsive.clear();
|
|
51
|
-
this.compositions.clear();
|
|
52
|
-
this.variants.clear();
|
|
53
|
-
this.common.clear();
|
|
54
|
-
this.styles.clear();
|
|
55
|
-
};
|
|
56
|
-
StyleCache.prototype.keyFor = function (type, keyData) {
|
|
57
|
-
var _a;
|
|
58
|
-
var cache = this[type];
|
|
59
|
-
var withFunctionsHash = Object.values(keyData).map(function (value) {
|
|
60
|
-
if (typeof value === 'function') {
|
|
61
|
-
return value.toString();
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
64
|
-
});
|
|
65
|
-
var values = __spreadArray([this.baseKey], __read(withFunctionsHash), false);
|
|
66
|
-
var cacheKey = (0, hashKey_1.hashKey)(values);
|
|
67
|
-
var cachedValue = minifier_1.minifier.decompress((_a = cache.cache[cacheKey]) !== null && _a !== void 0 ? _a : null);
|
|
68
|
-
return {
|
|
69
|
-
key: cacheKey,
|
|
70
|
-
value: cachedValue,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
StyleCache.prototype.cacheFor = function (type, key, value) {
|
|
74
|
-
if (!constants_1.StyleConstants.CACHE_ENABLED) {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
var cache = this[type];
|
|
78
|
-
var minifiedValue = minifier_1.minifier.compress(value);
|
|
79
|
-
return cache.cacheFor(key, minifiedValue);
|
|
80
|
-
};
|
|
81
|
-
return StyleCache;
|
|
82
|
-
}());
|
|
83
|
-
exports.StyleCache = StyleCache;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StateStorage } from 'zustand/middleware';
|
|
2
|
-
export type StoragePersistor = {
|
|
3
|
-
set: (key: string, value: any) => void;
|
|
4
|
-
get: (key: string) => any;
|
|
5
|
-
del: (key: string) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare class StylePersistor implements StateStorage {
|
|
8
|
-
private storage;
|
|
9
|
-
constructor(storage: StoragePersistor);
|
|
10
|
-
setItem(name: string, value: string): void;
|
|
11
|
-
getItem(name: string): string | null;
|
|
12
|
-
removeItem(name: string): void;
|
|
13
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StylePersistor = void 0;
|
|
4
|
-
var minifier_1 = require("./minifier");
|
|
5
|
-
var StylePersistor = /** @class */ (function () {
|
|
6
|
-
function StylePersistor(storage) {
|
|
7
|
-
this.storage = storage;
|
|
8
|
-
}
|
|
9
|
-
StylePersistor.prototype.setItem = function (name, value) {
|
|
10
|
-
return this.storage.set(name, value);
|
|
11
|
-
};
|
|
12
|
-
StylePersistor.prototype.getItem = function (name) {
|
|
13
|
-
var _a;
|
|
14
|
-
var persistedValue = (_a = this.storage) === null || _a === void 0 ? void 0 : _a.get(name);
|
|
15
|
-
return minifier_1.minifier.decompress(persistedValue !== null && persistedValue !== void 0 ? persistedValue : null);
|
|
16
|
-
};
|
|
17
|
-
StylePersistor.prototype.removeItem = function (name) {
|
|
18
|
-
return this.storage.del(name);
|
|
19
|
-
};
|
|
20
|
-
return StylePersistor;
|
|
21
|
-
}());
|
|
22
|
-
exports.StylePersistor = StylePersistor;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { AnyRecord, AnyStyledComponent, ICSS, ITheme, StyleAggregator, StyleProp, VariantStyleSheet } from '../types';
|
|
2
|
-
import { MultiplierFunction } from './spacing';
|
|
3
|
-
import { StateStorage } from 'zustand/middleware';
|
|
4
|
-
export declare class CodeleapStyleRegistry {
|
|
5
|
-
stylesheets: Record<string, VariantStyleSheet>;
|
|
6
|
-
commonVariants: Record<string, ICSS | MultiplierFunction>;
|
|
7
|
-
aggregators: Record<string, StyleAggregator>;
|
|
8
|
-
components: Record<string, AnyStyledComponent>;
|
|
9
|
-
private theme;
|
|
10
|
-
private styleCache;
|
|
11
|
-
constructor(storage: StateStorage);
|
|
12
|
-
computeCommonVariantStyle(componentName: string, variant: string, component?: any): {
|
|
13
|
-
[x: number]: ICSS;
|
|
14
|
-
};
|
|
15
|
-
computeVariantStyle(componentName: string, variants: string[], _component?: any): ICSS;
|
|
16
|
-
isCompositionStyle(component: AnyStyledComponent, style: any): {
|
|
17
|
-
isComposition: boolean;
|
|
18
|
-
composition: {};
|
|
19
|
-
};
|
|
20
|
-
isResponsiveStyle(style: any): {
|
|
21
|
-
responsiveStyleKey: string;
|
|
22
|
-
isResponsive: boolean;
|
|
23
|
-
};
|
|
24
|
-
getDefaultVariantStyle(componentName: string, defaultVariantStyleName?: string): any;
|
|
25
|
-
mergeStylesWithCache<T = unknown>(styles: ICSS[], key: string): T;
|
|
26
|
-
getRegisteredComponent(componentName: string): {
|
|
27
|
-
rootElement: string;
|
|
28
|
-
registeredComponent: AnyStyledComponent;
|
|
29
|
-
};
|
|
30
|
-
getResponsiveStyle(componentName: string, responsiveStyleKey: string, style: object): any;
|
|
31
|
-
getStyles(componentName: string, _style: any, component?: any, predicateObj?: (style: any) => any): {};
|
|
32
|
-
private getMediaQuery;
|
|
33
|
-
getStyleWithResponsive(componentName: string, style: any, component?: any): any;
|
|
34
|
-
getCompositionStyle(componentName: string, composition: Record<string, any>, style: any): any;
|
|
35
|
-
styleFor<T = unknown>(componentName: string, componentStyle: StyleProp<T>, mergeWithDefaultStyle?: boolean): T;
|
|
36
|
-
registerCommonVariants(): void;
|
|
37
|
-
registerVariants<Composition extends string = any>(componentName: string, variants: VariantStyleSheet, aggregator?: StyleAggregator<Composition>): void;
|
|
38
|
-
registerComponent(component: AnyStyledComponent): void;
|
|
39
|
-
/**
|
|
40
|
-
* These should be overwritten by the end-user to support
|
|
41
|
-
* custom style merging logic, such as StyleSheet.flatten
|
|
42
|
-
*/
|
|
43
|
-
createStyle(css: ICSS): ICSS;
|
|
44
|
-
update(): void;
|
|
45
|
-
private copyStyle;
|
|
46
|
-
createStyles<K extends string = string>(styles: Record<K, StyleProp<AnyRecord, ''>> | ((theme: ITheme) => Record<K, StyleProp<AnyRecord, ''>>)): Record<K, ICSS>;
|
|
47
|
-
}
|