veles 0.0.5 → 0.0.6
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/{chunk-V3EV7UG6.js → chunk-IENMGHS4.js} +12 -0
- package/dist/index.cjs +52 -38
- package/dist/index.js +44 -40
- package/dist/jsx-runtime.js +1 -1
- package/package.json +1 -1
|
@@ -64,6 +64,17 @@ function callMountHandlers(component) {
|
|
|
64
64
|
function identity(value1, value2) {
|
|
65
65
|
return value1 === value2;
|
|
66
66
|
}
|
|
67
|
+
function unique(arr) {
|
|
68
|
+
const map = /* @__PURE__ */ new Map();
|
|
69
|
+
const resultArr = [];
|
|
70
|
+
arr.forEach((element) => {
|
|
71
|
+
if (map.has(element))
|
|
72
|
+
return;
|
|
73
|
+
map.set(element, true);
|
|
74
|
+
resultArr.push(element);
|
|
75
|
+
});
|
|
76
|
+
return resultArr;
|
|
77
|
+
}
|
|
67
78
|
|
|
68
79
|
// src/create-element/parse-children.ts
|
|
69
80
|
function parseChildren({
|
|
@@ -275,6 +286,7 @@ export {
|
|
|
275
286
|
getComponentVelesNode,
|
|
276
287
|
callMountHandlers,
|
|
277
288
|
identity,
|
|
289
|
+
unique,
|
|
278
290
|
onMount,
|
|
279
291
|
onUnmount,
|
|
280
292
|
createElement,
|
package/dist/index.cjs
CHANGED
|
@@ -70,6 +70,17 @@ function callMountHandlers(component) {
|
|
|
70
70
|
function identity(value1, value2) {
|
|
71
71
|
return value1 === value2;
|
|
72
72
|
}
|
|
73
|
+
function unique(arr) {
|
|
74
|
+
const map = /* @__PURE__ */ new Map();
|
|
75
|
+
const resultArr = [];
|
|
76
|
+
arr.forEach((element) => {
|
|
77
|
+
if (map.has(element))
|
|
78
|
+
return;
|
|
79
|
+
map.set(element, true);
|
|
80
|
+
resultArr.push(element);
|
|
81
|
+
});
|
|
82
|
+
return resultArr;
|
|
83
|
+
}
|
|
73
84
|
|
|
74
85
|
// src/create-element/parse-children.ts
|
|
75
86
|
function parseChildren({
|
|
@@ -476,46 +487,49 @@ function createState(initialValue, subscribeCallback) {
|
|
|
476
487
|
// TODO: remove it from this object completely
|
|
477
488
|
// and access it from closure
|
|
478
489
|
_triggerUpdates: () => {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
490
|
+
const newTrackingSelectorElements = [];
|
|
491
|
+
trackingSelectorElements.forEach((selectorTrackingElement) => {
|
|
492
|
+
const { selectedValue, selector, cb, node, comparator } = selectorTrackingElement;
|
|
493
|
+
const newSelectedValue = selector ? selector(value) : value;
|
|
494
|
+
if (comparator(selectedValue, newSelectedValue)) {
|
|
495
|
+
newTrackingSelectorElements.push(selectorTrackingElement);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
const returnednewNode = cb ? cb(newSelectedValue) : String(newSelectedValue);
|
|
499
|
+
const newNode = !returnednewNode || typeof returnednewNode === "string" ? createTextElement(returnednewNode) : returnednewNode;
|
|
500
|
+
const { velesElementNode: oldVelesElementNode } = getComponentVelesNode(node);
|
|
501
|
+
const { velesElementNode: newVelesElementNode } = getComponentVelesNode(newNode);
|
|
502
|
+
const parentVelesElement = oldVelesElementNode.parentVelesElement;
|
|
503
|
+
const newTrackingSelectorElement = {
|
|
504
|
+
selector,
|
|
505
|
+
selectedValue: newSelectedValue,
|
|
506
|
+
cb,
|
|
507
|
+
node: newNode,
|
|
508
|
+
comparator
|
|
509
|
+
};
|
|
510
|
+
if (parentVelesElement) {
|
|
511
|
+
newVelesElementNode.parentVelesElement = parentVelesElement;
|
|
512
|
+
parentVelesElement.html.replaceChild(
|
|
513
|
+
newVelesElementNode.html,
|
|
514
|
+
oldVelesElementNode.html
|
|
515
|
+
);
|
|
516
|
+
parentVelesElement.childComponents = parentVelesElement.childComponents.map(
|
|
517
|
+
(childComponent) => childComponent === node ? newNode : node
|
|
518
|
+
);
|
|
519
|
+
node._privateMethods._callUnmountHandlers();
|
|
520
|
+
callMountHandlers(newNode);
|
|
521
|
+
newNode._privateMethods._addUnmountHandler(() => {
|
|
522
|
+
trackingSelectorElements = trackingSelectorElements.filter(
|
|
523
|
+
(el) => el !== newTrackingSelectorElement
|
|
506
524
|
);
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
trackingSelectorElements = trackingSelectorElements.filter(
|
|
511
|
-
(el) => el !== newTrackingSelectorElement
|
|
512
|
-
);
|
|
513
|
-
});
|
|
514
|
-
} else {
|
|
515
|
-
console.log("parent node was not found");
|
|
516
|
-
}
|
|
517
|
-
return newTrackingSelectorElement;
|
|
525
|
+
});
|
|
526
|
+
} else {
|
|
527
|
+
console.log("parent node was not found");
|
|
518
528
|
}
|
|
529
|
+
newTrackingSelectorElements.push(newTrackingSelectorElement);
|
|
530
|
+
});
|
|
531
|
+
trackingSelectorElements = unique(
|
|
532
|
+
trackingSelectorElements.concat(newTrackingSelectorElements)
|
|
519
533
|
);
|
|
520
534
|
trackingAttributes.forEach(({ cb, htmlElement, attributeName }) => {
|
|
521
535
|
const newAttributeValue = cb ? cb(value) : value;
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
getComponentVelesNode,
|
|
6
6
|
identity,
|
|
7
7
|
onMount,
|
|
8
|
-
onUnmount
|
|
9
|
-
|
|
8
|
+
onUnmount,
|
|
9
|
+
unique
|
|
10
|
+
} from "./chunk-IENMGHS4.js";
|
|
10
11
|
|
|
11
12
|
// src/attach-component.ts
|
|
12
13
|
function attachComponent({
|
|
@@ -189,46 +190,49 @@ function createState(initialValue, subscribeCallback) {
|
|
|
189
190
|
// TODO: remove it from this object completely
|
|
190
191
|
// and access it from closure
|
|
191
192
|
_triggerUpdates: () => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
193
|
+
const newTrackingSelectorElements = [];
|
|
194
|
+
trackingSelectorElements.forEach((selectorTrackingElement) => {
|
|
195
|
+
const { selectedValue, selector, cb, node, comparator } = selectorTrackingElement;
|
|
196
|
+
const newSelectedValue = selector ? selector(value) : value;
|
|
197
|
+
if (comparator(selectedValue, newSelectedValue)) {
|
|
198
|
+
newTrackingSelectorElements.push(selectorTrackingElement);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const returnednewNode = cb ? cb(newSelectedValue) : String(newSelectedValue);
|
|
202
|
+
const newNode = !returnednewNode || typeof returnednewNode === "string" ? createTextElement(returnednewNode) : returnednewNode;
|
|
203
|
+
const { velesElementNode: oldVelesElementNode } = getComponentVelesNode(node);
|
|
204
|
+
const { velesElementNode: newVelesElementNode } = getComponentVelesNode(newNode);
|
|
205
|
+
const parentVelesElement = oldVelesElementNode.parentVelesElement;
|
|
206
|
+
const newTrackingSelectorElement = {
|
|
207
|
+
selector,
|
|
208
|
+
selectedValue: newSelectedValue,
|
|
209
|
+
cb,
|
|
210
|
+
node: newNode,
|
|
211
|
+
comparator
|
|
212
|
+
};
|
|
213
|
+
if (parentVelesElement) {
|
|
214
|
+
newVelesElementNode.parentVelesElement = parentVelesElement;
|
|
215
|
+
parentVelesElement.html.replaceChild(
|
|
216
|
+
newVelesElementNode.html,
|
|
217
|
+
oldVelesElementNode.html
|
|
218
|
+
);
|
|
219
|
+
parentVelesElement.childComponents = parentVelesElement.childComponents.map(
|
|
220
|
+
(childComponent) => childComponent === node ? newNode : node
|
|
221
|
+
);
|
|
222
|
+
node._privateMethods._callUnmountHandlers();
|
|
223
|
+
callMountHandlers(newNode);
|
|
224
|
+
newNode._privateMethods._addUnmountHandler(() => {
|
|
225
|
+
trackingSelectorElements = trackingSelectorElements.filter(
|
|
226
|
+
(el) => el !== newTrackingSelectorElement
|
|
219
227
|
);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
trackingSelectorElements = trackingSelectorElements.filter(
|
|
224
|
-
(el) => el !== newTrackingSelectorElement
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
console.log("parent node was not found");
|
|
229
|
-
}
|
|
230
|
-
return newTrackingSelectorElement;
|
|
228
|
+
});
|
|
229
|
+
} else {
|
|
230
|
+
console.log("parent node was not found");
|
|
231
231
|
}
|
|
232
|
+
newTrackingSelectorElements.push(newTrackingSelectorElement);
|
|
233
|
+
});
|
|
234
|
+
trackingSelectorElements = unique(
|
|
235
|
+
trackingSelectorElements.concat(newTrackingSelectorElements)
|
|
232
236
|
);
|
|
233
237
|
trackingAttributes.forEach(({ cb, htmlElement, attributeName }) => {
|
|
234
238
|
const newAttributeValue = cb ? cb(value) : value;
|
package/dist/jsx-runtime.js
CHANGED