veles 0.0.8 → 0.0.9
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/README.md +4 -3
- package/dist/{chunk-4QXZSBVZ.js → chunk-2KPVWPOL.js} +1 -4
- package/dist/{chunk-GVPFIZZW.js → chunk-VW64LMPA.js} +2 -2
- package/dist/{index-BOpDMzdf.d.cts → index-BkD2Za6F.d.cts} +9 -0
- package/dist/{index-BA0L7WRK.d.ts → index-DBdVF_11.d.ts} +9 -0
- package/dist/index.cjs +2 -5
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +2 -2
- package/dist/jsx-runtime.cjs +1 -4
- package/dist/jsx-runtime.js +1 -1
- package/dist/utils/index.cjs +2 -5
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://bundlephobia.com/result?p=veles)
|
|
5
5
|
[](https://www.npmjs.com/package/veles)
|
|
6
6
|
|
|
7
|
-
> This library is
|
|
7
|
+
> This library is still in early stages, so the API is not 100% finalized
|
|
8
8
|
|
|
9
9
|
`Veles` is a component-based performance-focused UI library. The main goal of this library is to provide a composable way to build highly interactive interfaces, which should be performant out of the box, as long as you follow the recommendations.
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
This library's primary focus is in performance. What this means is that it allows you to write your code in a way which will ensure that when the data in your app changes, only the smallest relevant parts will update. Despite of similarities with React in syntax, it does not follow the same waterfall style for component re-renders. Instead, it gives you API to subscribe to atomic changes in your tracked state and re-render only parts of the UI which actually depend on the value. Internally, it renders new HTML and replaces the old node. A similar approach is done for attributes, where in case of changes, only the relevant attribute will be updated in place, but nothing else will change.
|
|
14
14
|
|
|
15
|
-
It is important to note that the performance benefits will only be observed (and relevant as well) in case of a pretty high interactivity. It might not be faster than any other UI framework on the first render, the biggest improvement lies in the power of subscribing to individual changes.
|
|
15
|
+
It is important to note that the performance benefits will only be observed (and relevant as well) in case of a pretty high interactivity. It might not be faster than any other UI framework on the first render, the biggest improvement lies in the power of subscribing to individual changes, which is especially powerful in case of lists.
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -51,10 +51,11 @@ This will render an input and will update the Text node dynamically, without re-
|
|
|
51
51
|
|
|
52
52
|
- [Getting started](https://bloomca.github.io/veles/)
|
|
53
53
|
- [API docs](https://bloomca.github.io/veles/api/)
|
|
54
|
+
- [Guides](https://bloomca.github.io/veles/guides/)
|
|
54
55
|
- [Differences from other frameworks](https://bloomca.github.io/veles/frameworks-difference.html)
|
|
55
56
|
|
|
56
57
|
There also a companion app ([veles-calendar-app](https://github.com/Bloomca/veles-calendar-app)), which is developed using Veles and is supposed to push it to the limits, identify the issues and ideally improve performance even more.
|
|
57
58
|
|
|
58
59
|
### Features
|
|
59
60
|
|
|
60
|
-
The library is under development, so some features are not available yet
|
|
61
|
+
The library is under development, so some features are not available yet. Namely the TypeScript type inferring is not the best (although the library does support TypeScript), and Portals are not implemented yet.
|
|
@@ -141,10 +141,7 @@ function assignAttribute({
|
|
|
141
141
|
// basically, any form of `on` handlers, like `onClick`, `onCopy`, etc
|
|
142
142
|
typeof value === "function" && key.startsWith("on")
|
|
143
143
|
) {
|
|
144
|
-
htmlElement.addEventListener(
|
|
145
|
-
key[2].toLocaleLowerCase() + key.slice(3),
|
|
146
|
-
value
|
|
147
|
-
);
|
|
144
|
+
htmlElement.addEventListener(key.slice(2).toLocaleLowerCase(), value);
|
|
148
145
|
} else {
|
|
149
146
|
if (typeof value === "boolean") {
|
|
150
147
|
if (value)
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
executeComponent,
|
|
6
6
|
onMount,
|
|
7
7
|
onUnmount
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2KPVWPOL.js";
|
|
9
9
|
|
|
10
10
|
// src/context/index.ts
|
|
11
11
|
var publicContextStack = [];
|
|
@@ -481,7 +481,7 @@ function updateUseAttributeValue({
|
|
|
481
481
|
if (attributeValue === newAttributeValue) {
|
|
482
482
|
return;
|
|
483
483
|
}
|
|
484
|
-
const eventName = attributeName
|
|
484
|
+
const eventName = attributeName.slice(2).toLocaleLowerCase();
|
|
485
485
|
if (attributeValue) {
|
|
486
486
|
htmlElement.removeEventListener(eventName, attributeValue);
|
|
487
487
|
}
|
|
@@ -55,6 +55,15 @@ type State<ValueType> = {
|
|
|
55
55
|
): void;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Main state factory function.
|
|
60
|
+
*
|
|
61
|
+
* This primitive is pretty much a simple observable implementation,
|
|
62
|
+
* which is tightly integrated with the UI framework for two things:
|
|
63
|
+
*
|
|
64
|
+
* - based on subscription callback, update DOM node and replace it
|
|
65
|
+
* - correctly unsbuscribe when the Node/component is unmounted
|
|
66
|
+
*/
|
|
58
67
|
declare function createState<T>(initialValue: T, subscribeCallback?: (setValue: ReturnType<typeof createState<T>>["setValue"]) => Function): State<T>;
|
|
59
68
|
|
|
60
69
|
export { type State as S, createState as c };
|
|
@@ -55,6 +55,15 @@ type State<ValueType> = {
|
|
|
55
55
|
): void;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Main state factory function.
|
|
60
|
+
*
|
|
61
|
+
* This primitive is pretty much a simple observable implementation,
|
|
62
|
+
* which is tightly integrated with the UI framework for two things:
|
|
63
|
+
*
|
|
64
|
+
* - based on subscription callback, update DOM node and replace it
|
|
65
|
+
* - correctly unsbuscribe when the Node/component is unmounted
|
|
66
|
+
*/
|
|
58
67
|
declare function createState<T>(initialValue: T, subscribeCallback?: (setValue: ReturnType<typeof createState<T>>["setValue"]) => Function): State<T>;
|
|
59
68
|
|
|
60
69
|
export { type State as S, createState as c };
|
package/dist/index.cjs
CHANGED
|
@@ -244,10 +244,7 @@ function assignAttribute({
|
|
|
244
244
|
// basically, any form of `on` handlers, like `onClick`, `onCopy`, etc
|
|
245
245
|
typeof value === "function" && key.startsWith("on")
|
|
246
246
|
) {
|
|
247
|
-
htmlElement.addEventListener(
|
|
248
|
-
key[2].toLocaleLowerCase() + key.slice(3),
|
|
249
|
-
value
|
|
250
|
-
);
|
|
247
|
+
htmlElement.addEventListener(key.slice(2).toLocaleLowerCase(), value);
|
|
251
248
|
} else {
|
|
252
249
|
if (typeof value === "boolean") {
|
|
253
250
|
if (value)
|
|
@@ -800,7 +797,7 @@ function updateUseAttributeValue({
|
|
|
800
797
|
if (attributeValue === newAttributeValue) {
|
|
801
798
|
return;
|
|
802
799
|
}
|
|
803
|
-
const eventName = attributeName
|
|
800
|
+
const eventName = attributeName.slice(2).toLocaleLowerCase();
|
|
804
801
|
if (attributeValue) {
|
|
805
802
|
htmlElement.removeEventListener(eventName, attributeValue);
|
|
806
803
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { V as VelesElement, a as VelesComponentObject, c as VelesChildren } from './types.d-CjiJHqth.cjs';
|
|
2
2
|
export { Fragment, jsx as createElement } from './jsx-runtime.cjs';
|
|
3
|
-
export { S as State, c as createState } from './index-
|
|
3
|
+
export { S as State, c as createState } from './index-BkD2Za6F.cjs';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Attach Veles component tree to a regular HTML node.
|
|
7
|
+
* Right now it will wrap the app into an additional `<div>` tag.
|
|
8
|
+
*
|
|
9
|
+
* It returns a function which when executed, will remove the Veles
|
|
10
|
+
* tree from DOM and remove all subscriptions.
|
|
11
|
+
*/
|
|
5
12
|
declare function attachComponent({ htmlElement, component, }: {
|
|
6
13
|
htmlElement: HTMLElement;
|
|
7
14
|
component: VelesElement | VelesComponentObject;
|
|
@@ -10,6 +17,11 @@ declare function attachComponent({ htmlElement, component, }: {
|
|
|
10
17
|
declare function onMount(cb: () => void | Function): void;
|
|
11
18
|
declare function onUnmount(cb: Function): void;
|
|
12
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Create a reference which has special treatment if passed as
|
|
22
|
+
* ref={ref} to any DOM Node. `ref.current` will contain the
|
|
23
|
+
* rendered node, even if it changes.
|
|
24
|
+
*/
|
|
13
25
|
declare function createRef<T>(initialRefValue?: T | null): {
|
|
14
26
|
velesRef: true;
|
|
15
27
|
current: T | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { V as VelesElement, a as VelesComponentObject, c as VelesChildren } from './types.d-CjiJHqth.js';
|
|
2
2
|
export { Fragment, jsx as createElement } from './jsx-runtime.js';
|
|
3
|
-
export { S as State, c as createState } from './index-
|
|
3
|
+
export { S as State, c as createState } from './index-DBdVF_11.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Attach Veles component tree to a regular HTML node.
|
|
7
|
+
* Right now it will wrap the app into an additional `<div>` tag.
|
|
8
|
+
*
|
|
9
|
+
* It returns a function which when executed, will remove the Veles
|
|
10
|
+
* tree from DOM and remove all subscriptions.
|
|
11
|
+
*/
|
|
5
12
|
declare function attachComponent({ htmlElement, component, }: {
|
|
6
13
|
htmlElement: HTMLElement;
|
|
7
14
|
component: VelesElement | VelesComponentObject;
|
|
@@ -10,6 +17,11 @@ declare function attachComponent({ htmlElement, component, }: {
|
|
|
10
17
|
declare function onMount(cb: () => void | Function): void;
|
|
11
18
|
declare function onUnmount(cb: Function): void;
|
|
12
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Create a reference which has special treatment if passed as
|
|
22
|
+
* ref={ref} to any DOM Node. `ref.current` will contain the
|
|
23
|
+
* rendered node, even if it changes.
|
|
24
|
+
*/
|
|
13
25
|
declare function createRef<T>(initialRefValue?: T | null): {
|
|
14
26
|
velesRef: true;
|
|
15
27
|
current: T | null;
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
createState,
|
|
6
6
|
getExecutedComponentVelesNode,
|
|
7
7
|
renderTree
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VW64LMPA.js";
|
|
9
9
|
import {
|
|
10
10
|
Fragment,
|
|
11
11
|
createElement,
|
|
12
12
|
onMount,
|
|
13
13
|
onUnmount
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2KPVWPOL.js";
|
|
15
15
|
|
|
16
16
|
// src/attach-component.ts
|
|
17
17
|
function attachComponent({
|
package/dist/jsx-runtime.cjs
CHANGED
|
@@ -143,10 +143,7 @@ function assignAttribute({
|
|
|
143
143
|
// basically, any form of `on` handlers, like `onClick`, `onCopy`, etc
|
|
144
144
|
typeof value === "function" && key.startsWith("on")
|
|
145
145
|
) {
|
|
146
|
-
htmlElement.addEventListener(
|
|
147
|
-
key[2].toLocaleLowerCase() + key.slice(3),
|
|
148
|
-
value
|
|
149
|
-
);
|
|
146
|
+
htmlElement.addEventListener(key.slice(2).toLocaleLowerCase(), value);
|
|
150
147
|
} else {
|
|
151
148
|
if (typeof value === "boolean") {
|
|
152
149
|
if (value)
|
package/dist/jsx-runtime.js
CHANGED
package/dist/utils/index.cjs
CHANGED
|
@@ -240,10 +240,7 @@ function assignAttribute({
|
|
|
240
240
|
// basically, any form of `on` handlers, like `onClick`, `onCopy`, etc
|
|
241
241
|
typeof value === "function" && key.startsWith("on")
|
|
242
242
|
) {
|
|
243
|
-
htmlElement.addEventListener(
|
|
244
|
-
key[2].toLocaleLowerCase() + key.slice(3),
|
|
245
|
-
value
|
|
246
|
-
);
|
|
243
|
+
htmlElement.addEventListener(key.slice(2).toLocaleLowerCase(), value);
|
|
247
244
|
} else {
|
|
248
245
|
if (typeof value === "boolean") {
|
|
249
246
|
if (value)
|
|
@@ -742,7 +739,7 @@ function updateUseAttributeValue({
|
|
|
742
739
|
if (attributeValue === newAttributeValue) {
|
|
743
740
|
return;
|
|
744
741
|
}
|
|
745
|
-
const eventName = attributeName
|
|
742
|
+
const eventName = attributeName.slice(2).toLocaleLowerCase();
|
|
746
743
|
if (attributeValue) {
|
|
747
744
|
htmlElement.removeEventListener(eventName, attributeValue);
|
|
748
745
|
}
|
package/dist/utils/index.d.cts
CHANGED
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED