veles 0.0.2 → 0.0.3

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/dist/index.cjs CHANGED
@@ -53,6 +53,20 @@ function getComponentVelesNode(component) {
53
53
  }
54
54
  return { velesElementNode: childNode, componentsTree };
55
55
  }
56
+ function callMountHandlers(component) {
57
+ if ("velesStringElement" in component) {
58
+ return;
59
+ }
60
+ if ("velesComponent" in component) {
61
+ component._privateMethods._callMountHandlers();
62
+ callMountHandlers(component.tree);
63
+ }
64
+ if ("velesNode" in component) {
65
+ component.childComponents.forEach(
66
+ (childComponent) => callMountHandlers(childComponent)
67
+ );
68
+ }
69
+ }
56
70
  function identity(value1, value2) {
57
71
  return value1 === value2;
58
72
  }
@@ -72,6 +86,9 @@ function parseChildren({
72
86
  if (typeof childComponent === "string") {
73
87
  const text = document.createTextNode(childComponent);
74
88
  htmlElement.append(text);
89
+ } else if (typeof childComponent === "number") {
90
+ const text = document.createTextNode(String(childComponent));
91
+ htmlElement.append(text);
75
92
  } else if (typeof childComponent === "object" && childComponent && "velesNode" in childComponent && (childComponent == null ? void 0 : childComponent.velesNode)) {
76
93
  if (childComponent.phantom) {
77
94
  childComponent.childComponents.forEach((childComponentofPhantom) => {
@@ -79,14 +96,13 @@ function parseChildren({
79
96
  htmlElement.append(childComponentofPhantom.html);
80
97
  childComponentofPhantom.parentVelesElement = velesNode;
81
98
  } else {
82
- const { componentsTree, velesElementNode } = getComponentVelesNode(childComponentofPhantom);
99
+ const { velesElementNode } = getComponentVelesNode(
100
+ childComponentofPhantom
101
+ );
83
102
  if (!velesElementNode) {
84
103
  console.error("can't find HTML tree in a component chain");
85
104
  } else {
86
105
  htmlElement.append(velesElementNode.html);
87
- componentsTree.forEach((component) => {
88
- component._privateMethods._callMountHandlers();
89
- });
90
106
  velesElementNode.parentVelesElement = velesNode;
91
107
  }
92
108
  }
@@ -115,11 +131,6 @@ function parseChildren({
115
131
  console.error("can't find HTML tree in a component chain");
116
132
  } else {
117
133
  htmlElement.append(velesElementNode2.html);
118
- setTimeout(() => {
119
- componentsTree2.forEach((component) => {
120
- component._privateMethods._callMountHandlers();
121
- });
122
- }, 0);
123
134
  velesElementNode2.parentVelesElement = velesNode;
124
135
  }
125
136
  }
@@ -128,11 +139,6 @@ function parseChildren({
128
139
  } else {
129
140
  htmlElement.append(velesElementNode.html);
130
141
  }
131
- setTimeout(() => {
132
- componentsTree.forEach((component) => {
133
- component._privateMethods._callMountHandlers();
134
- });
135
- }, 0);
136
142
  velesElementNode.parentVelesElement = velesNode;
137
143
  childComponents.push(childComponent);
138
144
  }
@@ -229,7 +235,12 @@ function parseComponent({
229
235
  componentAPI.onUnmount(cb);
230
236
  },
231
237
  _callMountHandlers: () => {
232
- componentMountCbs.forEach((cb) => cb());
238
+ componentMountCbs.forEach((cb) => {
239
+ const mountCbResult = cb();
240
+ if (typeof mountCbResult === "function") {
241
+ componentAPI.onUnmount(mountCbResult);
242
+ }
243
+ });
233
244
  },
234
245
  _callUnmountHandlers: () => {
235
246
  componentUnmountCbs.forEach((cb) => cb());
@@ -292,6 +303,7 @@ function attachComponent({
292
303
  const wrappedApp = createElement("div", { children: [component] });
293
304
  const { velesElementNode } = getComponentVelesNode(wrappedApp);
294
305
  htmlElement.appendChild(velesElementNode.html);
306
+ callMountHandlers(wrappedApp);
295
307
  return () => {
296
308
  velesElementNode.html.remove();
297
309
  };
@@ -357,18 +369,19 @@ function createState(initialValue, subscribeCallback) {
357
369
  },
358
370
  useValueSelector(selector, cb, comparator = identity) {
359
371
  const selectedValue = selector ? selector(value) : value;
360
- const returnedNode = cb(selectedValue);
372
+ const returnedNode = cb ? cb(selectedValue) : String(selectedValue);
361
373
  const node = !returnedNode || typeof returnedNode === "string" ? createTextElement(returnedNode) : returnedNode;
362
- trackingSelectorElements.push({
374
+ const trackingSelectorElement = {
363
375
  selector,
364
376
  selectedValue,
365
377
  cb,
366
378
  node,
367
379
  comparator
368
- });
380
+ };
381
+ trackingSelectorElements.push(trackingSelectorElement);
369
382
  node._privateMethods._addUnmountHandler(() => {
370
383
  trackingSelectorElements = trackingSelectorElements.filter(
371
- (trackingSelectorElement) => trackingSelectorElement.cb !== cb
384
+ (el) => trackingSelectorElement !== el
372
385
  );
373
386
  });
374
387
  return node;
@@ -425,12 +438,13 @@ function createState(initialValue, subscribeCallback) {
425
438
  return wrapperComponent;
426
439
  },
427
440
  useAttribute: (cb) => {
428
- const attributeValue = cb(value);
441
+ const attributeValue = cb ? cb(value) : String(value);
429
442
  const attributeHelper = (htmlElement, attributeName, node) => {
430
- trackingAttributes.push({ cb, htmlElement, attributeName });
443
+ const trackingElement = { cb, htmlElement, attributeName };
444
+ trackingAttributes.push(trackingElement);
431
445
  node._privateMethods._addUnmountHandler(() => {
432
446
  trackingAttributes = trackingAttributes.filter(
433
- (trackingAttribute) => trackingAttribute.cb !== cb
447
+ (trackingAttribute) => trackingAttribute !== trackingElement
434
448
  );
435
449
  });
436
450
  return attributeValue;
@@ -449,7 +463,10 @@ function createState(initialValue, subscribeCallback) {
449
463
  // gives the latest value to ensure no outdated data
450
464
  // can be used for the state
451
465
  setValue: (newValueCB) => {
452
- const newValue = newValueCB(value);
466
+ const newValue = (
467
+ // @ts-expect-error
468
+ typeof newValueCB === "function" ? newValueCB(value) : newValueCB
469
+ );
453
470
  if (newValue !== value) {
454
471
  previousValue = value;
455
472
  value = newValue;
@@ -466,11 +483,18 @@ function createState(initialValue, subscribeCallback) {
466
483
  if (comparator(selectedValue, newSelectedValue)) {
467
484
  return selectorTrackingElement;
468
485
  }
469
- const returnednewNode = cb(newSelectedValue);
486
+ const returnednewNode = cb ? cb(newSelectedValue) : String(newSelectedValue);
470
487
  const newNode = !returnednewNode || typeof returnednewNode === "string" ? createTextElement(returnednewNode) : returnednewNode;
471
488
  const { velesElementNode: oldVelesElementNode } = getComponentVelesNode(node);
472
489
  const { velesElementNode: newVelesElementNode } = getComponentVelesNode(newNode);
473
490
  const parentVelesElement = oldVelesElementNode.parentVelesElement;
491
+ const newTrackingSelectorElement = {
492
+ selector,
493
+ selectedValue: newSelectedValue,
494
+ cb,
495
+ node: newNode,
496
+ comparator
497
+ };
474
498
  if (parentVelesElement) {
475
499
  newVelesElementNode.parentVelesElement = parentVelesElement;
476
500
  parentVelesElement.html.replaceChild(
@@ -481,32 +505,20 @@ function createState(initialValue, subscribeCallback) {
481
505
  (childComponent) => childComponent === node ? newNode : node
482
506
  );
483
507
  node._privateMethods._callUnmountHandlers();
484
- trackingSelectorElements.push({
485
- selector,
486
- selectedValue: newSelectedValue,
487
- cb,
488
- node: newNode,
489
- comparator
490
- });
508
+ callMountHandlers(newNode);
491
509
  newNode._privateMethods._addUnmountHandler(() => {
492
510
  trackingSelectorElements = trackingSelectorElements.filter(
493
- (trackingSelectorElement) => trackingSelectorElement.cb !== cb
511
+ (el) => el !== newTrackingSelectorElement
494
512
  );
495
513
  });
496
514
  } else {
497
515
  console.log("parent node was not found");
498
516
  }
499
- return {
500
- selectedValue: newSelectedValue,
501
- selector,
502
- cb,
503
- node: newNode,
504
- comparator
505
- };
517
+ return newTrackingSelectorElement;
506
518
  }
507
519
  );
508
520
  trackingAttributes.forEach(({ cb, htmlElement, attributeName }) => {
509
- const newAttributeValue = cb(value);
521
+ const newAttributeValue = cb ? cb(value) : String(value);
510
522
  htmlElement.setAttribute(attributeName, newAttributeValue);
511
523
  });
512
524
  trackingEffects.forEach((trackingEffect) => {
@@ -649,6 +661,7 @@ function createState(initialValue, subscribeCallback) {
649
661
  offset = offset + 1;
650
662
  currentElement = newNodeVelesElement.html;
651
663
  newElementsCount = newElementsCount + 1;
664
+ callMountHandlers(newNode);
652
665
  }
653
666
  });
654
667
  if (renderedElements.length === newRenderedElements.length + newElementsCount) {
@@ -724,4 +737,3 @@ function Fragment({ children }) {
724
737
  onMount,
725
738
  onUnmount
726
739
  });
727
- //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VelesElement, a as VelesComponent, b as VelesStringElement } from './jsx-runtime-vDysOz5d.cjs';
2
- export { F as Fragment, c as createElement } from './jsx-runtime-vDysOz5d.cjs';
1
+ import { V as VelesElement, a as VelesComponent, b as VelesStringElement } from './jsx-runtime-C2XLvZ55.cjs';
2
+ export { F as Fragment, c as createElement } from './jsx-runtime-C2XLvZ55.cjs';
3
3
 
4
4
  declare function attachComponent({ htmlElement, component, }: {
5
5
  htmlElement: HTMLElement;
@@ -21,9 +21,9 @@ type State<ValueType> = {
21
21
  skipFirstCall?: boolean;
22
22
  comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean;
23
23
  }): void;
24
- useValue(cb: (value: ValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: ValueType, value2: ValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
25
- useValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb: (value: SelectorValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
26
- useAttribute(cb: (value: ValueType) => string): AttributeHelper;
24
+ useValue(cb?: (value: ValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: ValueType, value2: ValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
25
+ useValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb?: (value: SelectorValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
26
+ useAttribute(cb?: (value: ValueType) => string): AttributeHelper;
27
27
  useValueIterator<Element>(options: {
28
28
  key: string | ((options: {
29
29
  element: Element;
@@ -36,7 +36,7 @@ type State<ValueType> = {
36
36
  }) => VelesElement | VelesComponent): VelesComponent | VelesElement | null;
37
37
  getValue(): ValueType;
38
38
  getPreviousValue(): undefined | ValueType;
39
- setValue(newValueCB: (currentValue: ValueType) => ValueType): void;
39
+ setValue(newValueCB: ((currentValue: ValueType) => ValueType) | ValueType): void;
40
40
  _triggerUpdates(): void;
41
41
  };
42
42
  declare function createState<T>(initialValue: T, subscribeCallback?: (setValue: ReturnType<typeof createState<T>>["setValue"]) => Function): State<T>;
@@ -52,7 +52,7 @@ declare function combineState<A, B, C, D, E, F, G, H>(state1: createdState<A>, s
52
52
  declare function combineState<A, B, C, D, E, F, G, H, I>(state1: createdState<A>, state2: createdState<B>, state3: createdState<C>, state4: createdState<D>, state5: createdState<E>, state6: createdState<F>, state7: createdState<G>, state8: createdState<H>, state9: createdState<I>): createdState<[A, B, C, D, E, F, G, H, I]>;
53
53
  declare function combineState<A, B, C, D, E, F, G, H, I, J>(state1: createdState<A>, state2: createdState<B>, state3: createdState<C>, state4: createdState<D>, state5: createdState<E>, state6: createdState<F>, state7: createdState<G>, state8: createdState<H>, state9: createdState<I>, state10: createdState<J>): createdState<[A, B, C, D, E, F, G, H, I, J]>;
54
54
 
55
- declare function onMount(cb: Function): void;
55
+ declare function onMount(cb: () => void | Function): void;
56
56
  declare function onUnmount(cb: Function): void;
57
57
 
58
58
  declare function createRef<T>(initialRefValue?: T | null): {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VelesElement, a as VelesComponent, b as VelesStringElement } from './jsx-runtime-vDysOz5d.js';
2
- export { F as Fragment, c as createElement } from './jsx-runtime-vDysOz5d.js';
1
+ import { V as VelesElement, a as VelesComponent, b as VelesStringElement } from './jsx-runtime-C2XLvZ55.js';
2
+ export { F as Fragment, c as createElement } from './jsx-runtime-C2XLvZ55.js';
3
3
 
4
4
  declare function attachComponent({ htmlElement, component, }: {
5
5
  htmlElement: HTMLElement;
@@ -21,9 +21,9 @@ type State<ValueType> = {
21
21
  skipFirstCall?: boolean;
22
22
  comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean;
23
23
  }): void;
24
- useValue(cb: (value: ValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: ValueType, value2: ValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
25
- useValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb: (value: SelectorValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
26
- useAttribute(cb: (value: ValueType) => string): AttributeHelper;
24
+ useValue(cb?: (value: ValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: ValueType, value2: ValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
25
+ useValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb?: (value: SelectorValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
26
+ useAttribute(cb?: (value: ValueType) => string): AttributeHelper;
27
27
  useValueIterator<Element>(options: {
28
28
  key: string | ((options: {
29
29
  element: Element;
@@ -36,7 +36,7 @@ type State<ValueType> = {
36
36
  }) => VelesElement | VelesComponent): VelesComponent | VelesElement | null;
37
37
  getValue(): ValueType;
38
38
  getPreviousValue(): undefined | ValueType;
39
- setValue(newValueCB: (currentValue: ValueType) => ValueType): void;
39
+ setValue(newValueCB: ((currentValue: ValueType) => ValueType) | ValueType): void;
40
40
  _triggerUpdates(): void;
41
41
  };
42
42
  declare function createState<T>(initialValue: T, subscribeCallback?: (setValue: ReturnType<typeof createState<T>>["setValue"]) => Function): State<T>;
@@ -52,7 +52,7 @@ declare function combineState<A, B, C, D, E, F, G, H>(state1: createdState<A>, s
52
52
  declare function combineState<A, B, C, D, E, F, G, H, I>(state1: createdState<A>, state2: createdState<B>, state3: createdState<C>, state4: createdState<D>, state5: createdState<E>, state6: createdState<F>, state7: createdState<G>, state8: createdState<H>, state9: createdState<I>): createdState<[A, B, C, D, E, F, G, H, I]>;
53
53
  declare function combineState<A, B, C, D, E, F, G, H, I, J>(state1: createdState<A>, state2: createdState<B>, state3: createdState<C>, state4: createdState<D>, state5: createdState<E>, state6: createdState<F>, state7: createdState<G>, state8: createdState<H>, state9: createdState<I>, state10: createdState<J>): createdState<[A, B, C, D, E, F, G, H, I, J]>;
54
54
 
55
- declare function onMount(cb: Function): void;
55
+ declare function onMount(cb: () => void | Function): void;
56
56
  declare function onUnmount(cb: Function): void;
57
57
 
58
58
  declare function createRef<T>(initialRefValue?: T | null): {
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  Fragment,
3
+ callMountHandlers,
3
4
  createElement,
4
5
  getComponentVelesNode,
5
6
  identity,
6
7
  onMount,
7
8
  onUnmount
8
- } from "./chunk-EVX3ZDYT.js";
9
+ } from "./chunk-V3EV7UG6.js";
9
10
 
10
11
  // src/attach-component.ts
11
12
  function attachComponent({
@@ -15,6 +16,7 @@ function attachComponent({
15
16
  const wrappedApp = createElement("div", { children: [component] });
16
17
  const { velesElementNode } = getComponentVelesNode(wrappedApp);
17
18
  htmlElement.appendChild(velesElementNode.html);
19
+ callMountHandlers(wrappedApp);
18
20
  return () => {
19
21
  velesElementNode.html.remove();
20
22
  };
@@ -80,18 +82,19 @@ function createState(initialValue, subscribeCallback) {
80
82
  },
81
83
  useValueSelector(selector, cb, comparator = identity) {
82
84
  const selectedValue = selector ? selector(value) : value;
83
- const returnedNode = cb(selectedValue);
85
+ const returnedNode = cb ? cb(selectedValue) : String(selectedValue);
84
86
  const node = !returnedNode || typeof returnedNode === "string" ? createTextElement(returnedNode) : returnedNode;
85
- trackingSelectorElements.push({
87
+ const trackingSelectorElement = {
86
88
  selector,
87
89
  selectedValue,
88
90
  cb,
89
91
  node,
90
92
  comparator
91
- });
93
+ };
94
+ trackingSelectorElements.push(trackingSelectorElement);
92
95
  node._privateMethods._addUnmountHandler(() => {
93
96
  trackingSelectorElements = trackingSelectorElements.filter(
94
- (trackingSelectorElement) => trackingSelectorElement.cb !== cb
97
+ (el) => trackingSelectorElement !== el
95
98
  );
96
99
  });
97
100
  return node;
@@ -148,12 +151,13 @@ function createState(initialValue, subscribeCallback) {
148
151
  return wrapperComponent;
149
152
  },
150
153
  useAttribute: (cb) => {
151
- const attributeValue = cb(value);
154
+ const attributeValue = cb ? cb(value) : String(value);
152
155
  const attributeHelper = (htmlElement, attributeName, node) => {
153
- trackingAttributes.push({ cb, htmlElement, attributeName });
156
+ const trackingElement = { cb, htmlElement, attributeName };
157
+ trackingAttributes.push(trackingElement);
154
158
  node._privateMethods._addUnmountHandler(() => {
155
159
  trackingAttributes = trackingAttributes.filter(
156
- (trackingAttribute) => trackingAttribute.cb !== cb
160
+ (trackingAttribute) => trackingAttribute !== trackingElement
157
161
  );
158
162
  });
159
163
  return attributeValue;
@@ -172,7 +176,10 @@ function createState(initialValue, subscribeCallback) {
172
176
  // gives the latest value to ensure no outdated data
173
177
  // can be used for the state
174
178
  setValue: (newValueCB) => {
175
- const newValue = newValueCB(value);
179
+ const newValue = (
180
+ // @ts-expect-error
181
+ typeof newValueCB === "function" ? newValueCB(value) : newValueCB
182
+ );
176
183
  if (newValue !== value) {
177
184
  previousValue = value;
178
185
  value = newValue;
@@ -189,11 +196,18 @@ function createState(initialValue, subscribeCallback) {
189
196
  if (comparator(selectedValue, newSelectedValue)) {
190
197
  return selectorTrackingElement;
191
198
  }
192
- const returnednewNode = cb(newSelectedValue);
199
+ const returnednewNode = cb ? cb(newSelectedValue) : String(newSelectedValue);
193
200
  const newNode = !returnednewNode || typeof returnednewNode === "string" ? createTextElement(returnednewNode) : returnednewNode;
194
201
  const { velesElementNode: oldVelesElementNode } = getComponentVelesNode(node);
195
202
  const { velesElementNode: newVelesElementNode } = getComponentVelesNode(newNode);
196
203
  const parentVelesElement = oldVelesElementNode.parentVelesElement;
204
+ const newTrackingSelectorElement = {
205
+ selector,
206
+ selectedValue: newSelectedValue,
207
+ cb,
208
+ node: newNode,
209
+ comparator
210
+ };
197
211
  if (parentVelesElement) {
198
212
  newVelesElementNode.parentVelesElement = parentVelesElement;
199
213
  parentVelesElement.html.replaceChild(
@@ -204,32 +218,20 @@ function createState(initialValue, subscribeCallback) {
204
218
  (childComponent) => childComponent === node ? newNode : node
205
219
  );
206
220
  node._privateMethods._callUnmountHandlers();
207
- trackingSelectorElements.push({
208
- selector,
209
- selectedValue: newSelectedValue,
210
- cb,
211
- node: newNode,
212
- comparator
213
- });
221
+ callMountHandlers(newNode);
214
222
  newNode._privateMethods._addUnmountHandler(() => {
215
223
  trackingSelectorElements = trackingSelectorElements.filter(
216
- (trackingSelectorElement) => trackingSelectorElement.cb !== cb
224
+ (el) => el !== newTrackingSelectorElement
217
225
  );
218
226
  });
219
227
  } else {
220
228
  console.log("parent node was not found");
221
229
  }
222
- return {
223
- selectedValue: newSelectedValue,
224
- selector,
225
- cb,
226
- node: newNode,
227
- comparator
228
- };
230
+ return newTrackingSelectorElement;
229
231
  }
230
232
  );
231
233
  trackingAttributes.forEach(({ cb, htmlElement, attributeName }) => {
232
- const newAttributeValue = cb(value);
234
+ const newAttributeValue = cb ? cb(value) : String(value);
233
235
  htmlElement.setAttribute(attributeName, newAttributeValue);
234
236
  });
235
237
  trackingEffects.forEach((trackingEffect) => {
@@ -372,6 +374,7 @@ function createState(initialValue, subscribeCallback) {
372
374
  offset = offset + 1;
373
375
  currentElement = newNodeVelesElement.html;
374
376
  newElementsCount = newElementsCount + 1;
377
+ callMountHandlers(newNode);
375
378
  }
376
379
  });
377
380
  if (renderedElements.length === newRenderedElements.length + newElementsCount) {
@@ -438,4 +441,3 @@ export {
438
441
  onMount,
439
442
  onUnmount
440
443
  };
441
- //# sourceMappingURL=index.js.map
@@ -214,7 +214,12 @@ type VelesComponent = {
214
214
  };
215
215
 
216
216
  // all supported child options
217
- type velesChild = string | VelesElement | VelesComponent | VelesStringElement;
217
+ type velesChild =
218
+ | string
219
+ | number
220
+ | VelesElement
221
+ | VelesComponent
222
+ | VelesStringElement;
218
223
  type VelesChildren = velesChild | velesChild[] | undefined | null;
219
224
 
220
225
  type VelesElementProps = {
@@ -232,7 +237,9 @@ type VelesElementProps = {
232
237
  } & VelesDOMElementProps;
233
238
 
234
239
  type ComponentAPI = {
235
- onMount: (cb: Function) => void;
240
+ // You can return a function from the mount callback, and it will be
241
+ // automatically registered as `onUnmount` callback
242
+ onMount: (cb: Function) => void | Function;
236
243
  onUnmount: (cb: Function) => void;
237
244
  };
238
245
 
@@ -214,7 +214,12 @@ type VelesComponent = {
214
214
  };
215
215
 
216
216
  // all supported child options
217
- type velesChild = string | VelesElement | VelesComponent | VelesStringElement;
217
+ type velesChild =
218
+ | string
219
+ | number
220
+ | VelesElement
221
+ | VelesComponent
222
+ | VelesStringElement;
218
223
  type VelesChildren = velesChild | velesChild[] | undefined | null;
219
224
 
220
225
  type VelesElementProps = {
@@ -232,7 +237,9 @@ type VelesElementProps = {
232
237
  } & VelesDOMElementProps;
233
238
 
234
239
  type ComponentAPI = {
235
- onMount: (cb: Function) => void;
240
+ // You can return a function from the mount callback, and it will be
241
+ // automatically registered as `onUnmount` callback
242
+ onMount: (cb: Function) => void | Function;
236
243
  onUnmount: (cb: Function) => void;
237
244
  };
238
245
 
@@ -65,6 +65,9 @@ function parseChildren({
65
65
  if (typeof childComponent === "string") {
66
66
  const text = document.createTextNode(childComponent);
67
67
  htmlElement.append(text);
68
+ } else if (typeof childComponent === "number") {
69
+ const text = document.createTextNode(String(childComponent));
70
+ htmlElement.append(text);
68
71
  } else if (typeof childComponent === "object" && childComponent && "velesNode" in childComponent && (childComponent == null ? void 0 : childComponent.velesNode)) {
69
72
  if (childComponent.phantom) {
70
73
  childComponent.childComponents.forEach((childComponentofPhantom) => {
@@ -72,14 +75,13 @@ function parseChildren({
72
75
  htmlElement.append(childComponentofPhantom.html);
73
76
  childComponentofPhantom.parentVelesElement = velesNode;
74
77
  } else {
75
- const { componentsTree, velesElementNode } = getComponentVelesNode(childComponentofPhantom);
78
+ const { velesElementNode } = getComponentVelesNode(
79
+ childComponentofPhantom
80
+ );
76
81
  if (!velesElementNode) {
77
82
  console.error("can't find HTML tree in a component chain");
78
83
  } else {
79
84
  htmlElement.append(velesElementNode.html);
80
- componentsTree.forEach((component) => {
81
- component._privateMethods._callMountHandlers();
82
- });
83
85
  velesElementNode.parentVelesElement = velesNode;
84
86
  }
85
87
  }
@@ -108,11 +110,6 @@ function parseChildren({
108
110
  console.error("can't find HTML tree in a component chain");
109
111
  } else {
110
112
  htmlElement.append(velesElementNode2.html);
111
- setTimeout(() => {
112
- componentsTree2.forEach((component) => {
113
- component._privateMethods._callMountHandlers();
114
- });
115
- }, 0);
116
113
  velesElementNode2.parentVelesElement = velesNode;
117
114
  }
118
115
  }
@@ -121,11 +118,6 @@ function parseChildren({
121
118
  } else {
122
119
  htmlElement.append(velesElementNode.html);
123
120
  }
124
- setTimeout(() => {
125
- componentsTree.forEach((component) => {
126
- component._privateMethods._callMountHandlers();
127
- });
128
- }, 0);
129
121
  velesElementNode.parentVelesElement = velesNode;
130
122
  childComponents.push(childComponent);
131
123
  }
@@ -208,7 +200,12 @@ function parseComponent({
208
200
  componentAPI.onUnmount(cb);
209
201
  },
210
202
  _callMountHandlers: () => {
211
- componentMountCbs.forEach((cb) => cb());
203
+ componentMountCbs.forEach((cb) => {
204
+ const mountCbResult = cb();
205
+ if (typeof mountCbResult === "function") {
206
+ componentAPI.onUnmount(mountCbResult);
207
+ }
208
+ });
212
209
  },
213
210
  _callUnmountHandlers: () => {
214
211
  componentUnmountCbs.forEach((cb) => cb());
@@ -277,4 +274,3 @@ function Fragment({ children }) {
277
274
  jsxDEV,
278
275
  jsxs
279
276
  });
280
- //# sourceMappingURL=jsx-runtime.cjs.map
@@ -1 +1 @@
1
- export { F as Fragment, c as jsx, c as jsxDEV, c as jsxs } from './jsx-runtime-vDysOz5d.cjs';
1
+ export { F as Fragment, c as jsx, c as jsxDEV, c as jsxs } from './jsx-runtime-C2XLvZ55.cjs';
@@ -1 +1 @@
1
- export { F as Fragment, c as jsx, c as jsxDEV, c as jsxs } from './jsx-runtime-vDysOz5d.js';
1
+ export { F as Fragment, c as jsx, c as jsxDEV, c as jsxs } from './jsx-runtime-C2XLvZ55.js';
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  Fragment,
3
3
  createElement
4
- } from "./chunk-EVX3ZDYT.js";
4
+ } from "./chunk-V3EV7UG6.js";
5
5
  export {
6
6
  Fragment,
7
7
  createElement as jsx,
8
8
  createElement as jsxDEV,
9
9
  createElement as jsxs
10
10
  };
11
- //# sourceMappingURL=jsx-runtime.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veles",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "UI library with main focus on performance",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/lifecycle.ts","../src/utils.ts","../src/create-element/parse-children.ts","../src/create-element/assign-attributes.ts","../src/create-element/parse-component.ts","../src/create-element/create-element.ts","../src/fragment.ts"],"sourcesContent":["import { ComponentAPI } from \"../types\";\n\n// lifecycle hooks\n// currently, all components need to be synchronous\n// so we execute them and set background context\n// since components can be nested, we need to keep the array\nconst contextStack: ComponentAPI[] = [];\n// all hooks need to know the current context\n// it should way more convenient this way compared to passing\n// `componentAPI` to every method\nlet currentContext: ComponentAPI | null = null;\n\nfunction addContext(newContext: ComponentAPI) {\n contextStack.push(newContext);\n currentContext = newContext;\n}\n\nfunction popContext() {\n contextStack.pop();\n currentContext = contextStack[contextStack.length - 1];\n}\n\nfunction onMount(cb: Function) {\n if (currentContext) {\n currentContext.onMount(cb);\n } else {\n console.error(\"missing current context\");\n }\n}\n\nfunction onUnmount(cb: Function) {\n if (currentContext) {\n currentContext.onUnmount(cb);\n } else {\n console.error(\"missing current context\");\n }\n}\n\nexport { addContext, popContext, onMount, onUnmount };\n","import type { VelesComponent, VelesElement, VelesStringElement } from \"./types\";\n\nfunction getComponentVelesNode(\n component: VelesComponent | VelesElement | VelesStringElement\n): {\n velesElementNode: VelesElement | VelesStringElement;\n componentsTree: VelesComponent[];\n} {\n const componentsTree: VelesComponent[] = [];\n\n if (\"velesStringElement\" in component) {\n return {\n velesElementNode: component,\n componentsTree: [],\n };\n }\n\n let childNode: VelesComponent | VelesElement = component;\n // we can have multiple components nested, we need to get\n // to the actual HTML to attach it\n while (\"velesComponent\" in childNode) {\n componentsTree.push(childNode);\n if (\"velesStringElement\" in childNode.tree) {\n return {\n velesElementNode: childNode.tree,\n componentsTree,\n };\n } else {\n childNode = childNode.tree;\n }\n }\n\n return { velesElementNode: childNode, componentsTree };\n}\n\nfunction identity<T>(value1: T, value2: T) {\n return value1 === value2;\n}\n\nexport { getComponentVelesNode, identity };\n","import { getComponentVelesNode } from \"../utils\";\n\nimport type {\n VelesComponent,\n VelesElement,\n VelesStringElement,\n VelesElementProps,\n} from \"../types\";\n\nfunction parseChildren({\n children,\n htmlElement,\n velesNode,\n}: {\n children: VelesElementProps[\"children\"];\n htmlElement: HTMLElement;\n velesNode: VelesElement;\n}) {\n const childComponents: (\n | VelesElement\n | VelesComponent\n | VelesStringElement\n )[] = [];\n\n if (children === undefined || children === null) {\n return childComponents;\n }\n\n (Array.isArray(children) ? children : [children]).forEach(\n (childComponent) => {\n if (typeof childComponent === \"string\") {\n const text = document.createTextNode(childComponent);\n htmlElement.append(text);\n } else if (\n typeof childComponent === \"object\" &&\n childComponent &&\n \"velesNode\" in childComponent &&\n childComponent?.velesNode\n ) {\n if (childComponent.phantom) {\n // we need to get ALL the children of it and attach it to this node\n childComponent.childComponents.forEach((childComponentofPhantom) => {\n if (\"velesNode\" in childComponentofPhantom) {\n htmlElement.append(childComponentofPhantom.html);\n childComponentofPhantom.parentVelesElement = velesNode;\n } else {\n const { componentsTree, velesElementNode } =\n getComponentVelesNode(childComponentofPhantom);\n\n if (!velesElementNode) {\n console.error(\"can't find HTML tree in a component chain\");\n } else {\n htmlElement.append(velesElementNode.html);\n\n // TODO: address the same concern as below\n componentsTree.forEach((component) => {\n component._privateMethods._callMountHandlers();\n });\n\n velesElementNode.parentVelesElement = velesNode;\n }\n }\n });\n childComponent.parentVelesElement = velesNode;\n childComponents.push(childComponent);\n } else {\n // TODO: check that it is a valid DOM Node\n htmlElement.append(childComponent.html);\n childComponent.parentVelesElement = velesNode;\n childComponents.push(childComponent);\n }\n } else if (\n typeof childComponent === \"object\" &&\n childComponent &&\n \"velesComponent\" in childComponent &&\n childComponent?.velesComponent\n ) {\n // we need to save the whole components chain, so that\n // we can trigger `mount` hooks on all of them correctly\n const { componentsTree, velesElementNode } =\n getComponentVelesNode(childComponent);\n\n if (!velesElementNode) {\n console.error(\"can't find HTML tree in a component chain\");\n } else {\n if (\"velesNode\" in velesElementNode && velesElementNode.phantom) {\n // we need to get ALL the children of it and attach it to this node\n velesElementNode.childComponents.forEach(\n (childComponentofPhantom) => {\n if (\"velesNode\" in childComponentofPhantom) {\n htmlElement.append(childComponentofPhantom.html);\n childComponentofPhantom.parentVelesElement = velesNode;\n } else {\n const { componentsTree, velesElementNode } =\n getComponentVelesNode(childComponentofPhantom);\n\n if (!velesElementNode) {\n console.error(\"can't find HTML tree in a component chain\");\n } else {\n htmlElement.append(velesElementNode.html);\n\n // Same explanation as below. Components are mounted synchronously\n setTimeout(() => {\n componentsTree.forEach((component) => {\n component._privateMethods._callMountHandlers();\n });\n }, 0);\n velesElementNode.parentVelesElement = velesNode;\n }\n }\n }\n );\n } else {\n htmlElement.append(velesElementNode.html);\n }\n\n /**\n * Components are mounted synchronously, so we can safely wait for the next\n * CPU tick and be sure that new markup is attached to DOM.\n */\n setTimeout(() => {\n componentsTree.forEach((component) => {\n component._privateMethods._callMountHandlers();\n });\n }, 0);\n velesElementNode.parentVelesElement = velesNode;\n childComponents.push(childComponent);\n }\n } else if (\n typeof childComponent === \"object\" &&\n childComponent &&\n \"velesStringElement\" in childComponent &&\n childComponent?.velesStringElement\n ) {\n // TODO: check that it is a valid DOM Node\n htmlElement.append(childComponent.html);\n childComponent.parentVelesElement = velesNode;\n childComponents.push(childComponent);\n }\n }\n );\n\n return childComponents;\n}\n\nexport { parseChildren };\n","import type { VelesElement } from \"../types\";\n\nfunction assignAttributes({\n props,\n htmlElement,\n velesNode,\n}: {\n props: Record<string, any>;\n htmlElement: HTMLElement;\n velesNode: VelesElement;\n}) {\n Object.entries(props).forEach(([key, value]) => {\n const isFunction = typeof value === \"function\";\n if (isFunction && value.velesAttribute === true) {\n const attributeValue = value(htmlElement, key, velesNode);\n htmlElement.setAttribute(key, attributeValue);\n } else if (\n // basically, any form of `on` handlers, like `onClick`, `onCopy`, etc\n isFunction &&\n key.length > 2 &&\n key.startsWith(\"on\")\n ) {\n // TODO: think if this is robust enough\n htmlElement.addEventListener(\n key[2].toLocaleLowerCase() + key.slice(3),\n value\n );\n } else {\n htmlElement.setAttribute(key, value);\n }\n });\n}\n\nexport { assignAttributes };\n","import { addContext, popContext } from \"../hooks/lifecycle\";\n\nimport type {\n VelesComponent,\n VelesStringElement,\n VelesElementProps,\n ComponentAPI,\n ComponentFunction,\n} from \"../types\";\n\nfunction parseComponent({\n element,\n props,\n}: {\n element: ComponentFunction;\n props: VelesElementProps;\n}) {\n const componentUnmountCbs: Function[] = [];\n const componentMountCbs: Function[] = [];\n const componentAPI: ComponentAPI = {\n onMount: (cb) => {\n componentMountCbs.push(cb);\n },\n onUnmount: (cb) => {\n componentUnmountCbs.push(cb);\n },\n };\n // at this moment we enter new context\n addContext(componentAPI);\n const _componentTree = element(props, componentAPI);\n\n const componentTree =\n typeof _componentTree === \"string\" || !_componentTree\n ? ({\n velesStringElement: true,\n html: document.createTextNode(\n typeof _componentTree === \"string\" ? _componentTree : \"\"\n ),\n } as VelesStringElement)\n : _componentTree;\n\n // here we exit our context\n popContext();\n const velesComponent: VelesComponent = {\n velesComponent: true,\n tree: componentTree,\n _privateMethods: {\n _addUnmountHandler: (cb: Function) => {\n componentAPI.onUnmount(cb);\n },\n _callMountHandlers: () => {\n componentMountCbs.forEach((cb) => cb());\n },\n _callUnmountHandlers: () => {\n componentUnmountCbs.forEach((cb) => cb());\n // this should trigger recursive checks, whether it is a VelesNode or VelesComponent\n // string Nodes don't have lifecycle handlers\n if (\"_privateMethods\" in velesComponent.tree) {\n velesComponent.tree._privateMethods._callUnmountHandlers();\n }\n },\n },\n };\n\n return velesComponent;\n}\n\nexport { parseComponent };\n","import { parseChildren } from \"./parse-children\";\nimport { assignAttributes } from \"./assign-attributes\";\nimport { parseComponent } from \"./parse-component\";\n\nimport type {\n VelesComponent,\n VelesElement,\n VelesElementProps,\n ComponentFunction,\n} from \"../types\";\n\nfunction createElement(\n element: string | ComponentFunction,\n props: VelesElementProps = {}\n): VelesElement | VelesComponent {\n if (typeof element === \"string\") {\n const { children, ref, phantom = false, ...otherProps } = props;\n const newElement = document.createElement(element);\n const velesNode = {} as VelesElement;\n\n if (ref?.velesRef) {\n ref.current = newElement;\n }\n\n const childComponents = parseChildren({\n children,\n htmlElement: newElement,\n velesNode,\n });\n\n // these handlers are attached directly to the DOM element\n // specifically, the top level node which is rendered after\n // using `useValue` function and also listeners from\n // `useAttribute`\n let unmountHandlers: Function[] = [];\n const callUnmountHandlers = () => {\n unmountHandlers.forEach((cb) => cb());\n unmountHandlers = [];\n\n childComponents.forEach((childComponent) => {\n childComponent._privateMethods._callUnmountHandlers();\n });\n };\n\n velesNode.html = newElement;\n velesNode.velesNode = true;\n velesNode.childComponents = childComponents;\n velesNode.phantom = phantom;\n velesNode._privateMethods = {\n _addUnmountHandler: (cb: Function) => {\n unmountHandlers.push(cb);\n },\n _callUnmountHandlers: callUnmountHandlers,\n };\n\n // assign all the DOM attributes, including event listeners\n assignAttributes({ props: otherProps, htmlElement: newElement, velesNode });\n\n return velesNode;\n\n // functions mean that we want to render another component\n } else if (typeof element === \"function\") {\n return parseComponent({ element, props });\n }\n\n // otherwise we use the API wrong, so we throw an error\n throw new Error(\n \"Veles createElement expects a valid DOM string or another component\"\n );\n}\n\nexport { createElement };\n","import { createElement } from \"./create-element\";\n\nimport type { VelesChildren } from \"./types\";\n\nfunction Fragment({ children }: { children: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