@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Vit Bokisch
3
+ Copyright (c) 2023-present Vit Bokisch
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # @vitus-labs/core
2
+
3
+ Shared foundation for the UI System ecosystem.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@vitus-labs/core)](https://www.npmjs.com/package/@vitus-labs/core)
6
+ [![license](https://img.shields.io/npm/l/@vitus-labs/core)](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":"c989073a-1","name":"config.ts"},{"uid":"c989073a-3","name":"isEmpty.ts"},{"uid":"c989073a-5","name":"context.tsx"},{"uid":"c989073a-7","name":"compose.ts"},{"uid":"c989073a-9","name":"render.ts"},{"name":"html/htmlTags.ts","uid":"c989073a-11"},{"uid":"c989073a-13","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"c989073a-1":{"renderedLength":1010,"gzipLength":312,"brotliLength":0,"metaUid":"c989073a-0"},"c989073a-3":{"renderedLength":426,"gzipLength":228,"brotliLength":0,"metaUid":"c989073a-2"},"c989073a-5":{"renderedLength":717,"gzipLength":320,"brotliLength":0,"metaUid":"c989073a-4"},"c989073a-7":{"renderedLength":178,"gzipLength":142,"brotliLength":0,"metaUid":"c989073a-6"},"c989073a-9":{"renderedLength":835,"gzipLength":328,"brotliLength":0,"metaUid":"c989073a-8"},"c989073a-11":{"renderedLength":2052,"gzipLength":565,"brotliLength":0,"metaUid":"c989073a-10"},"c989073a-13":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"c989073a-12"}},"nodeMetas":{"c989073a-0":{"id":"/src/config.ts","moduleParts":{"index.js":"c989073a-1"},"imported":[{"uid":"c989073a-17"}],"importedBy":[{"uid":"c989073a-12"},{"uid":"c989073a-4"}]},"c989073a-2":{"id":"/src/isEmpty.ts","moduleParts":{"index.js":"c989073a-3"},"imported":[],"importedBy":[{"uid":"c989073a-12"},{"uid":"c989073a-4"},{"uid":"c989073a-8"}]},"c989073a-4":{"id":"/src/context.tsx","moduleParts":{"index.js":"c989073a-5"},"imported":[{"uid":"c989073a-18"},{"uid":"c989073a-0"},{"uid":"c989073a-2"}],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-6":{"id":"/src/compose.ts","moduleParts":{"index.js":"c989073a-7"},"imported":[],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-8":{"id":"/src/render.ts","moduleParts":{"index.js":"c989073a-9"},"imported":[{"uid":"c989073a-18"},{"uid":"c989073a-19"},{"uid":"c989073a-2"}],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-10":{"id":"/src/html/htmlTags.ts","moduleParts":{"index.js":"c989073a-11"},"imported":[],"importedBy":[{"uid":"c989073a-16"}]},"c989073a-12":{"id":"/src/index.ts","moduleParts":{"index.js":"c989073a-13"},"imported":[{"uid":"c989073a-14"},{"uid":"c989073a-15"},{"uid":"c989073a-0"},{"uid":"c989073a-4"},{"uid":"c989073a-6"},{"uid":"c989073a-2"},{"uid":"c989073a-8"},{"uid":"c989073a-16"}],"importedBy":[],"isEntry":true},"c989073a-14":{"id":"lodash-es","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-12"}],"isExternal":true},"c989073a-15":{"id":"moize","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-12"}],"isExternal":true},"c989073a-16":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"c989073a-10"}],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-17":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-0"}],"isExternal":true},"c989073a-18":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-4"},{"uid":"c989073a-8"}],"isExternal":true},"c989073a-19":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-8"}],"isExternal":true}},"env":{"rollup":"4.55.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
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;