@vitus-labs/core 1.2.2 → 1.2.3-alpha.56
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/LICENSE +1 -1
- package/README.md +147 -0
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.d.ts +230 -217
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +413 -257
- package/lib/index.js.map +1 -1
- package/package.json +17 -22
- package/lib/types/compose.d.ts +0 -10
- package/lib/types/compose.d.ts.map +0 -1
- package/lib/types/config.d.ts +0 -24
- package/lib/types/config.d.ts.map +0 -1
- package/lib/types/context.d.ts +0 -16
- package/lib/types/context.d.ts.map +0 -1
- package/lib/types/html/htmlElementAttrs.d.ts +0 -108
- package/lib/types/html/htmlElementAttrs.d.ts.map +0 -1
- package/lib/types/html/htmlTags.d.ts +0 -6
- package/lib/types/html/htmlTags.d.ts.map +0 -1
- package/lib/types/html/index.d.ts +0 -7
- package/lib/types/html/index.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -15
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/isEmpty.d.ts +0 -4
- package/lib/types/isEmpty.d.ts.map +0 -1
- package/lib/types/render.d.ts +0 -9
- package/lib/types/render.d.ts.map +0 -1
- package/lib/types/types.d.ts +0 -3
- package/lib/types/types.d.ts.map +0 -1
package/LICENSE
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# @vitus-labs/core
|
|
2
|
+
|
|
3
|
+
Shared foundation for the UI System ecosystem.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@vitus-labs/core)
|
|
6
|
+
[](https://github.com/vitus-labs/ui-system/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Provides utility functions, a styling engine bridge, theme context, and HTML tag definitions used across all `@vitus-labs` packages. No external utility dependencies — all implementations are built-in with prototype pollution protection where applicable.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @vitus-labs/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## API
|
|
17
|
+
|
|
18
|
+
### Provider & Context
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { Provider, context, config, init } from '@vitus-labs/core'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Provider** wraps your app with a theme context. It bridges styled-components' `ThemeProvider` with the internal context system.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { Provider } from '@vitus-labs/core'
|
|
28
|
+
|
|
29
|
+
<Provider theme={{ rootSize: 16, breakpoints: { xs: 0, md: 768 } }}>
|
|
30
|
+
{children}
|
|
31
|
+
</Provider>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**config / init** — configure the styling engine. By default wired to `styled-components`, but can be swapped for another CSS-in-JS library.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { config } from '@vitus-labs/core'
|
|
38
|
+
|
|
39
|
+
const { styled, css } = config
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Utilities
|
|
43
|
+
|
|
44
|
+
#### compose
|
|
45
|
+
|
|
46
|
+
Right-to-left function composition.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { compose } from '@vitus-labs/core'
|
|
50
|
+
|
|
51
|
+
const transform = compose(toUpperCase, trim, normalize)
|
|
52
|
+
transform(' hello ') // => 'HELLO'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### render
|
|
56
|
+
|
|
57
|
+
Flexible element renderer. Handles components, elements, primitives, and arrays.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { render } from '@vitus-labs/core'
|
|
61
|
+
|
|
62
|
+
render('hello') // => 'hello'
|
|
63
|
+
render(MyComponent) // => <MyComponent />
|
|
64
|
+
render(<div>hi</div>) // => clones element
|
|
65
|
+
render(null) // => null
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### isEmpty
|
|
69
|
+
|
|
70
|
+
Type-safe emptiness check. Returns `true` for `null`, `undefined`, `{}`, `[]`, and non-object primitives.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { isEmpty } from '@vitus-labs/core'
|
|
74
|
+
|
|
75
|
+
isEmpty({}) // => true
|
|
76
|
+
isEmpty([]) // => true
|
|
77
|
+
isEmpty(null) // => true
|
|
78
|
+
isEmpty({ a: 1 }) // => false
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### omit / pick
|
|
82
|
+
|
|
83
|
+
Create objects without or with only specified keys. Accept nullable inputs.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { omit, pick } from '@vitus-labs/core'
|
|
87
|
+
|
|
88
|
+
omit({ a: 1, b: 2, c: 3 }, ['b']) // => { a: 1, c: 3 }
|
|
89
|
+
pick({ a: 1, b: 2, c: 3 }, ['a', 'b']) // => { a: 1, b: 2 }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### set / get
|
|
93
|
+
|
|
94
|
+
Nested property access and mutation by dot/bracket path. `set` has built-in prototype pollution protection — keys like `__proto__`, `constructor`, and `prototype` are blocked.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { set, get } from '@vitus-labs/core'
|
|
98
|
+
|
|
99
|
+
const obj = {}
|
|
100
|
+
set(obj, 'a.b.c', 42) // => { a: { b: { c: 42 } } }
|
|
101
|
+
get(obj, 'a.b.c') // => 42
|
|
102
|
+
get(obj, 'a.x', 'default') // => 'default'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### merge
|
|
106
|
+
|
|
107
|
+
Deep merge objects left-to-right. Only plain objects are recursed into; arrays are replaced wholesale. Prototype pollution keys are blocked.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { merge } from '@vitus-labs/core'
|
|
111
|
+
|
|
112
|
+
merge({ a: { x: 1 } }, { a: { y: 2 } }) // => { a: { x: 1, y: 2 } }
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### throttle
|
|
116
|
+
|
|
117
|
+
Limits function execution to at most once per wait period. Returns a throttled function with a `.cancel()` method.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { throttle } from '@vitus-labs/core'
|
|
121
|
+
|
|
122
|
+
const throttled = throttle(handleResize, 200)
|
|
123
|
+
window.addEventListener('resize', throttled)
|
|
124
|
+
// cleanup: throttled.cancel()
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### HTML Constants
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { HTML_TAGS, HTML_TEXT_TAGS } from '@vitus-labs/core'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- **HTML_TAGS** — array of 100+ valid HTML tag names
|
|
134
|
+
- **HTML_TEXT_TAGS** — array of text-content tags (h1–h6, p, span, strong, em, etc.)
|
|
135
|
+
|
|
136
|
+
Both have corresponding TypeScript union types: `HTMLTags` and `HTMLTextTags`.
|
|
137
|
+
|
|
138
|
+
## Peer Dependencies
|
|
139
|
+
|
|
140
|
+
| Package | Version |
|
|
141
|
+
| ------- | ------- |
|
|
142
|
+
| react | >= 19 |
|
|
143
|
+
| styled-components | >= 6 |
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"44034ba7-1","name":"compose.ts"},{"uid":"44034ba7-3","name":"config.ts"},{"uid":"44034ba7-5","name":"isEmpty.ts"},{"uid":"44034ba7-7","name":"context.tsx"},{"uid":"44034ba7-9","name":"hoistNonReactStatics.ts"},{"name":"html/htmlTags.ts","uid":"44034ba7-11"},{"uid":"44034ba7-13","name":"render.ts"},{"uid":"44034ba7-15","name":"utils.ts"},{"uid":"44034ba7-17","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"44034ba7-1":{"renderedLength":313,"gzipLength":240,"brotliLength":0,"metaUid":"44034ba7-0"},"44034ba7-3":{"renderedLength":795,"gzipLength":311,"brotliLength":0,"metaUid":"44034ba7-2"},"44034ba7-5":{"renderedLength":236,"gzipLength":163,"brotliLength":0,"metaUid":"44034ba7-4"},"44034ba7-7":{"renderedLength":1041,"gzipLength":496,"brotliLength":0,"metaUid":"44034ba7-6"},"44034ba7-9":{"renderedLength":1747,"gzipLength":641,"brotliLength":0,"metaUid":"44034ba7-8"},"44034ba7-11":{"renderedLength":1363,"gzipLength":483,"brotliLength":0,"metaUid":"44034ba7-10"},"44034ba7-13":{"renderedLength":577,"gzipLength":275,"brotliLength":0,"metaUid":"44034ba7-12"},"44034ba7-15":{"renderedLength":2911,"gzipLength":1054,"brotliLength":0,"metaUid":"44034ba7-14"},"44034ba7-17":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"44034ba7-16"}},"nodeMetas":{"44034ba7-0":{"id":"/src/compose.ts","moduleParts":{"index.js":"44034ba7-1"},"imported":[],"importedBy":[{"uid":"44034ba7-16"}]},"44034ba7-2":{"id":"/src/config.ts","moduleParts":{"index.js":"44034ba7-3"},"imported":[{"uid":"44034ba7-19"}],"importedBy":[{"uid":"44034ba7-16"},{"uid":"44034ba7-6"}]},"44034ba7-4":{"id":"/src/isEmpty.ts","moduleParts":{"index.js":"44034ba7-5"},"imported":[],"importedBy":[{"uid":"44034ba7-16"},{"uid":"44034ba7-6"},{"uid":"44034ba7-12"}]},"44034ba7-6":{"id":"/src/context.tsx","moduleParts":{"index.js":"44034ba7-7"},"imported":[{"uid":"44034ba7-20"},{"uid":"44034ba7-2"},{"uid":"44034ba7-4"},{"uid":"44034ba7-21"}],"importedBy":[{"uid":"44034ba7-16"}]},"44034ba7-8":{"id":"/src/hoistNonReactStatics.ts","moduleParts":{"index.js":"44034ba7-9"},"imported":[{"uid":"44034ba7-22"}],"importedBy":[{"uid":"44034ba7-16"}]},"44034ba7-10":{"id":"/src/html/htmlTags.ts","moduleParts":{"index.js":"44034ba7-11"},"imported":[],"importedBy":[{"uid":"44034ba7-18"}]},"44034ba7-12":{"id":"/src/render.ts","moduleParts":{"index.js":"44034ba7-13"},"imported":[{"uid":"44034ba7-20"},{"uid":"44034ba7-22"},{"uid":"44034ba7-4"}],"importedBy":[{"uid":"44034ba7-16"}]},"44034ba7-14":{"id":"/src/utils.ts","moduleParts":{"index.js":"44034ba7-15"},"imported":[],"importedBy":[{"uid":"44034ba7-16"}]},"44034ba7-16":{"id":"/src/index.ts","moduleParts":{"index.js":"44034ba7-17"},"imported":[{"uid":"44034ba7-0"},{"uid":"44034ba7-2"},{"uid":"44034ba7-6"},{"uid":"44034ba7-8"},{"uid":"44034ba7-18"},{"uid":"44034ba7-4"},{"uid":"44034ba7-12"},{"uid":"44034ba7-14"}],"importedBy":[],"isEntry":true},"44034ba7-18":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"44034ba7-10"}],"importedBy":[{"uid":"44034ba7-16"}]},"44034ba7-19":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"44034ba7-2"}]},"44034ba7-20":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"44034ba7-6"},{"uid":"44034ba7-12"}]},"44034ba7-21":{"id":"react/jsx-runtime","moduleParts":{},"imported":[],"importedBy":[{"uid":"44034ba7-6"}]},"44034ba7-22":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"44034ba7-8"},{"uid":"44034ba7-12"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|