@lexriver/dome 1.5.11 → 2.0.0
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/out/{AnimatedArray.d.ts → src/AnimatedArray.d.mts} +29 -29
- package/out/{AnimatedArray.js → src/AnimatedArray.mjs} +52 -51
- package/out/{AnimatedTable.d.ts → src/AnimatedTable.d.mts} +38 -38
- package/out/{AnimatedTable.js → src/AnimatedTable.mjs} +88 -91
- package/out/{AnimatedText.d.ts → src/AnimatedText.d.mts} +13 -13
- package/out/{AnimatedText.js → src/AnimatedText.mjs} +24 -24
- package/out/{Animation.d.ts → src/Animation.d.mts} +4 -4
- package/out/{temp-test.d.ts → src/Animation.mjs} +1 -1
- package/out/{Dome.d.ts → src/Dome.d.mts} +9 -9
- package/out/{Dome.js → src/Dome.mjs} +291 -295
- package/out/{DomeComponent.d.ts → src/DomeComponent.d.mts} +22 -19
- package/out/{DomeComponent.js → src/DomeComponent.mjs} +47 -44
- package/out/{DomeManipulator.d.ts → src/DomeManipulator.d.mts} +48 -48
- package/out/{DomeManipulator.js → src/DomeManipulator.mjs} +329 -329
- package/out/src/DomeRouter.console-test.d.mts +1 -0
- package/out/{DomeRouter.console-test.js → src/DomeRouter.console-test.mjs} +44 -44
- package/out/{DomeRouter.d.ts → src/DomeRouter.d.mts} +30 -30
- package/out/{DomeRouter.js → src/DomeRouter.mjs} +236 -237
- package/out/{LongestCommonSubsequence.d.ts → src/LongestCommonSubsequence.d.mts} +15 -15
- package/out/{LongestCommonSubsequence.js → src/LongestCommonSubsequence.mjs} +164 -164
- package/out/src/index.d.mts +11 -0
- package/out/src/index.mjs +11 -0
- package/out/src/temp-test.d.mts +1 -0
- package/out/{temp-test.js → src/temp-test.mjs} +20 -20
- package/out/vitest.config.d.ts +2 -0
- package/out/vitest.config.js +9 -0
- package/package.json +16 -14
- package/src/{AnimatedArray.ts → AnimatedArray.mts} +3 -3
- package/src/{AnimatedTable.ts → AnimatedTable.mts} +6 -6
- package/src/{AnimatedText.ts → AnimatedText.mts} +4 -4
- package/src/{Dome.ts → Dome.mts} +7 -11
- package/src/{DomeComponent.ts → DomeComponent.mts} +3 -3
- package/src/{DomeManipulator.ts → DomeManipulator.mts} +5 -5
- package/src/{DomeRouter.ts → DomeRouter.mts} +3 -3
- package/src/index.mts +12 -0
- package/src/{temp-test.ts → temp-test.mts} +1 -1
- package/tsconfig.json +57 -60
- package/vitest.config.ts +10 -0
- package/jest.config.js +0 -22
- package/out/Animation.js +0 -0
- package/out/DomeRouter.console-test.d.ts +0 -0
- package/out/index.d.ts +0 -12
- package/out/index.js +0 -14
- package/src/index.ts +0 -14
- /package/src/{Animation.ts → Animation.mts} +0 -0
- /package/src/{DomeRouter.console-test.ts → DomeRouter.console-test.mts} +0 -0
- /package/src/{LongestCommonSubsequence.ts → LongestCommonSubsequence.mts} +0 -0
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
export var LongestCommonSubsequence;
|
|
2
|
-
(function (LongestCommonSubsequence) {
|
|
3
|
-
// https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/longest-common-subsequence
|
|
4
|
-
function getLongestCommonSubsequence(set1, set2) {
|
|
5
|
-
// Init LCS matrix.
|
|
6
|
-
const lcsMatrix = Array(set2.length + 1).fill(null).map(() => Array(set1.length + 1).fill(null));
|
|
7
|
-
// Fill first row with zeros.
|
|
8
|
-
for (let columnIndex = 0; columnIndex <= set1.length; columnIndex += 1) {
|
|
9
|
-
lcsMatrix[0][columnIndex] = 0;
|
|
10
|
-
}
|
|
11
|
-
// Fill first column with zeros.
|
|
12
|
-
for (let rowIndex = 0; rowIndex <= set2.length; rowIndex += 1) {
|
|
13
|
-
lcsMatrix[rowIndex][0] = 0;
|
|
14
|
-
}
|
|
15
|
-
// Fill rest of the column that correspond to each of two strings.
|
|
16
|
-
for (let rowIndex = 1; rowIndex <= set2.length; rowIndex += 1) {
|
|
17
|
-
for (let columnIndex = 1; columnIndex <= set1.length; columnIndex += 1) {
|
|
18
|
-
if (set1[columnIndex - 1] === set2[rowIndex - 1]) {
|
|
19
|
-
lcsMatrix[rowIndex][columnIndex] = lcsMatrix[rowIndex - 1][columnIndex - 1] + 1;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
lcsMatrix[rowIndex][columnIndex] = Math.max(lcsMatrix[rowIndex - 1][columnIndex], lcsMatrix[rowIndex][columnIndex - 1]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
// Calculate LCS based on LCS matrix.
|
|
27
|
-
if (!lcsMatrix[set2.length][set1.length]) {
|
|
28
|
-
// If the length of largest common string is zero then return empty string.
|
|
29
|
-
return [''];
|
|
30
|
-
}
|
|
31
|
-
const longestSequence = [];
|
|
32
|
-
let columnIndex = set1.length;
|
|
33
|
-
let rowIndex = set2.length;
|
|
34
|
-
while (columnIndex > 0 || rowIndex > 0) {
|
|
35
|
-
if (set1[columnIndex - 1] === set2[rowIndex - 1]) {
|
|
36
|
-
// Move by diagonal left-top.
|
|
37
|
-
longestSequence.unshift(set1[columnIndex - 1]);
|
|
38
|
-
columnIndex -= 1;
|
|
39
|
-
rowIndex -= 1;
|
|
40
|
-
}
|
|
41
|
-
else if (lcsMatrix[rowIndex][columnIndex] === lcsMatrix[rowIndex][columnIndex - 1]) {
|
|
42
|
-
// Move left.
|
|
43
|
-
columnIndex -= 1;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// Move up.
|
|
47
|
-
rowIndex -= 1;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return longestSequence;
|
|
51
|
-
}
|
|
52
|
-
LongestCommonSubsequence.getLongestCommonSubsequence = getLongestCommonSubsequence;
|
|
53
|
-
function getPatch({ oldArray, newArray, onRemove, onAdd }) {
|
|
54
|
-
const lcsArray = getLongestCommonSubsequence(oldArray, newArray);
|
|
55
|
-
let countOfOperations = 0;
|
|
56
|
-
// console.log('oldArray=', oldArray.join(' '))
|
|
57
|
-
// console.log('newArray=', newArray.join(' '))
|
|
58
|
-
// console.log('lcsArray=', lcsArray.join(' '))
|
|
59
|
-
// old: A B B B C
|
|
60
|
-
// new: X X B B B B C
|
|
61
|
-
// lcs: B B B C
|
|
62
|
-
//let lcsStartIndexForOld = 0
|
|
63
|
-
//let lcsStartIndexForNew = 0
|
|
64
|
-
let lcsIndex = 0;
|
|
65
|
-
//let newIndex = 0
|
|
66
|
-
for (let oldIndex = 0; oldIndex < oldArray.length; oldIndex++) {
|
|
67
|
-
let oldItem = oldArray[oldIndex];
|
|
68
|
-
//let oldItemInLcs = itemInArray(oldItem, lcsArray, lcsStartIndexForOld)
|
|
69
|
-
let oldItemInLcs = lcsArray[lcsIndex] == oldItem;
|
|
70
|
-
//console.log('oldIndex=', oldIndex, 'oldItem=', oldItem, 'in LCS=', oldItemInLcs)
|
|
71
|
-
if (oldItemInLcs) {
|
|
72
|
-
//lcsStartIndexForOld++
|
|
73
|
-
lcsIndex++;
|
|
74
|
-
// so we must keep this element
|
|
75
|
-
//continue
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
onRemove(oldIndex - countOfOperations, oldItem);
|
|
79
|
-
//indexForOperation++
|
|
80
|
-
countOfOperations++;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
lcsIndex = 0;
|
|
84
|
-
for (let newIndex = 0; newIndex < newArray.length; newIndex++) {
|
|
85
|
-
let newItem = newArray[newIndex];
|
|
86
|
-
//let newItemInLcs = itemInArray(newItem, lcsArray, lcsStartIndexForNew)
|
|
87
|
-
let newItemInLcs = lcsArray[lcsIndex] == newItem;
|
|
88
|
-
if (newItemInLcs) {
|
|
89
|
-
lcsIndex++;
|
|
90
|
-
//lcsStartIndexForNew++
|
|
91
|
-
//keep
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
onAdd(newIndex, newItem);
|
|
95
|
-
countOfOperations++;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return countOfOperations;
|
|
99
|
-
}
|
|
100
|
-
LongestCommonSubsequence.getPatch = getPatch;
|
|
101
|
-
function getPatchOrdered({ oldArray, newArray, onRemove, onAdd }) {
|
|
102
|
-
const lcsArray = getLongestCommonSubsequence(oldArray, newArray);
|
|
103
|
-
//let countOfOperations = 0
|
|
104
|
-
// console.log('oldArray=', oldArray.join(' '))
|
|
105
|
-
// console.log('newArray=', newArray.join(' '))
|
|
106
|
-
// console.log('lcsArray=', lcsArray.join(' '))
|
|
107
|
-
// old: A B B B C
|
|
108
|
-
// new: X X B B B B C
|
|
109
|
-
// lcs: B B B C
|
|
110
|
-
let lcsIndexForOld = 0;
|
|
111
|
-
let lcsIndexForNew = 0;
|
|
112
|
-
//let lcsIndex = 0
|
|
113
|
-
let oldIndex = 0;
|
|
114
|
-
let newIndex = 0;
|
|
115
|
-
let countOfRemoveOperations = 0;
|
|
116
|
-
let countOfAddOperations = 0;
|
|
117
|
-
let indexForOperation = 0;
|
|
118
|
-
while (oldIndex < oldArray.length || newIndex < newArray.length) {
|
|
119
|
-
while (oldIndex < oldArray.length) {
|
|
120
|
-
let oldItem = oldArray[oldIndex];
|
|
121
|
-
//let oldItemInLcs = itemInArray(oldItem, lcsArray, lcsStartIndexForOld)
|
|
122
|
-
let oldItemInLcs = lcsArray[lcsIndexForOld] == oldItem;
|
|
123
|
-
//console.log('oldItem', oldIndex, oldItem, oldItemInLcs)
|
|
124
|
-
if (oldItemInLcs) {
|
|
125
|
-
//lcsStartIndexForNew++
|
|
126
|
-
//lcsStartIndexForOld++
|
|
127
|
-
lcsIndexForOld++;
|
|
128
|
-
//indexForOperation++
|
|
129
|
-
oldIndex++;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
//onRemove(oldIndex-countOfRemoveOperations, oldItem)
|
|
134
|
-
onRemove(indexForOperation, oldItem);
|
|
135
|
-
countOfRemoveOperations++;
|
|
136
|
-
oldIndex++;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
while (newIndex < newArray.length) {
|
|
140
|
-
let newItem = newArray[newIndex];
|
|
141
|
-
//let newItemInLcs = itemInArray(newItem, lcsArray, lcsStartIndexForNew)
|
|
142
|
-
let newItemInLcs = lcsArray[lcsIndexForNew] == newItem;
|
|
143
|
-
//console.log('newItem', oldIndex, newItem, newItemInLcs)
|
|
144
|
-
if (newItemInLcs) {
|
|
145
|
-
//lcsStartIndexForNew++
|
|
146
|
-
lcsIndexForNew++;
|
|
147
|
-
indexForOperation++;
|
|
148
|
-
newIndex++;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
onAdd(indexForOperation, newItem);
|
|
153
|
-
indexForOperation++;
|
|
154
|
-
countOfAddOperations++;
|
|
155
|
-
newIndex++;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// console.log('countOf(+)operations', countOfAddOperations)
|
|
160
|
-
// console.log('countOf(-)operations', countOfRemoveOperations)
|
|
161
|
-
return countOfAddOperations + countOfRemoveOperations;
|
|
162
|
-
}
|
|
163
|
-
LongestCommonSubsequence.getPatchOrdered = getPatchOrdered;
|
|
164
|
-
})(LongestCommonSubsequence || (LongestCommonSubsequence = {}));
|
|
1
|
+
export var LongestCommonSubsequence;
|
|
2
|
+
(function (LongestCommonSubsequence) {
|
|
3
|
+
// https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/sets/longest-common-subsequence
|
|
4
|
+
function getLongestCommonSubsequence(set1, set2) {
|
|
5
|
+
// Init LCS matrix.
|
|
6
|
+
const lcsMatrix = Array(set2.length + 1).fill(null).map(() => Array(set1.length + 1).fill(null));
|
|
7
|
+
// Fill first row with zeros.
|
|
8
|
+
for (let columnIndex = 0; columnIndex <= set1.length; columnIndex += 1) {
|
|
9
|
+
lcsMatrix[0][columnIndex] = 0;
|
|
10
|
+
}
|
|
11
|
+
// Fill first column with zeros.
|
|
12
|
+
for (let rowIndex = 0; rowIndex <= set2.length; rowIndex += 1) {
|
|
13
|
+
lcsMatrix[rowIndex][0] = 0;
|
|
14
|
+
}
|
|
15
|
+
// Fill rest of the column that correspond to each of two strings.
|
|
16
|
+
for (let rowIndex = 1; rowIndex <= set2.length; rowIndex += 1) {
|
|
17
|
+
for (let columnIndex = 1; columnIndex <= set1.length; columnIndex += 1) {
|
|
18
|
+
if (set1[columnIndex - 1] === set2[rowIndex - 1]) {
|
|
19
|
+
lcsMatrix[rowIndex][columnIndex] = lcsMatrix[rowIndex - 1][columnIndex - 1] + 1;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
lcsMatrix[rowIndex][columnIndex] = Math.max(lcsMatrix[rowIndex - 1][columnIndex], lcsMatrix[rowIndex][columnIndex - 1]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Calculate LCS based on LCS matrix.
|
|
27
|
+
if (!lcsMatrix[set2.length][set1.length]) {
|
|
28
|
+
// If the length of largest common string is zero then return empty string.
|
|
29
|
+
return [''];
|
|
30
|
+
}
|
|
31
|
+
const longestSequence = [];
|
|
32
|
+
let columnIndex = set1.length;
|
|
33
|
+
let rowIndex = set2.length;
|
|
34
|
+
while (columnIndex > 0 || rowIndex > 0) {
|
|
35
|
+
if (set1[columnIndex - 1] === set2[rowIndex - 1]) {
|
|
36
|
+
// Move by diagonal left-top.
|
|
37
|
+
longestSequence.unshift(set1[columnIndex - 1]);
|
|
38
|
+
columnIndex -= 1;
|
|
39
|
+
rowIndex -= 1;
|
|
40
|
+
}
|
|
41
|
+
else if (lcsMatrix[rowIndex][columnIndex] === lcsMatrix[rowIndex][columnIndex - 1]) {
|
|
42
|
+
// Move left.
|
|
43
|
+
columnIndex -= 1;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Move up.
|
|
47
|
+
rowIndex -= 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return longestSequence;
|
|
51
|
+
}
|
|
52
|
+
LongestCommonSubsequence.getLongestCommonSubsequence = getLongestCommonSubsequence;
|
|
53
|
+
function getPatch({ oldArray, newArray, onRemove, onAdd }) {
|
|
54
|
+
const lcsArray = getLongestCommonSubsequence(oldArray, newArray);
|
|
55
|
+
let countOfOperations = 0;
|
|
56
|
+
// console.log('oldArray=', oldArray.join(' '))
|
|
57
|
+
// console.log('newArray=', newArray.join(' '))
|
|
58
|
+
// console.log('lcsArray=', lcsArray.join(' '))
|
|
59
|
+
// old: A B B B C
|
|
60
|
+
// new: X X B B B B C
|
|
61
|
+
// lcs: B B B C
|
|
62
|
+
//let lcsStartIndexForOld = 0
|
|
63
|
+
//let lcsStartIndexForNew = 0
|
|
64
|
+
let lcsIndex = 0;
|
|
65
|
+
//let newIndex = 0
|
|
66
|
+
for (let oldIndex = 0; oldIndex < oldArray.length; oldIndex++) {
|
|
67
|
+
let oldItem = oldArray[oldIndex];
|
|
68
|
+
//let oldItemInLcs = itemInArray(oldItem, lcsArray, lcsStartIndexForOld)
|
|
69
|
+
let oldItemInLcs = lcsArray[lcsIndex] == oldItem;
|
|
70
|
+
//console.log('oldIndex=', oldIndex, 'oldItem=', oldItem, 'in LCS=', oldItemInLcs)
|
|
71
|
+
if (oldItemInLcs) {
|
|
72
|
+
//lcsStartIndexForOld++
|
|
73
|
+
lcsIndex++;
|
|
74
|
+
// so we must keep this element
|
|
75
|
+
//continue
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
onRemove(oldIndex - countOfOperations, oldItem);
|
|
79
|
+
//indexForOperation++
|
|
80
|
+
countOfOperations++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
lcsIndex = 0;
|
|
84
|
+
for (let newIndex = 0; newIndex < newArray.length; newIndex++) {
|
|
85
|
+
let newItem = newArray[newIndex];
|
|
86
|
+
//let newItemInLcs = itemInArray(newItem, lcsArray, lcsStartIndexForNew)
|
|
87
|
+
let newItemInLcs = lcsArray[lcsIndex] == newItem;
|
|
88
|
+
if (newItemInLcs) {
|
|
89
|
+
lcsIndex++;
|
|
90
|
+
//lcsStartIndexForNew++
|
|
91
|
+
//keep
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
onAdd(newIndex, newItem);
|
|
95
|
+
countOfOperations++;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return countOfOperations;
|
|
99
|
+
}
|
|
100
|
+
LongestCommonSubsequence.getPatch = getPatch;
|
|
101
|
+
function getPatchOrdered({ oldArray, newArray, onRemove, onAdd }) {
|
|
102
|
+
const lcsArray = getLongestCommonSubsequence(oldArray, newArray);
|
|
103
|
+
//let countOfOperations = 0
|
|
104
|
+
// console.log('oldArray=', oldArray.join(' '))
|
|
105
|
+
// console.log('newArray=', newArray.join(' '))
|
|
106
|
+
// console.log('lcsArray=', lcsArray.join(' '))
|
|
107
|
+
// old: A B B B C
|
|
108
|
+
// new: X X B B B B C
|
|
109
|
+
// lcs: B B B C
|
|
110
|
+
let lcsIndexForOld = 0;
|
|
111
|
+
let lcsIndexForNew = 0;
|
|
112
|
+
//let lcsIndex = 0
|
|
113
|
+
let oldIndex = 0;
|
|
114
|
+
let newIndex = 0;
|
|
115
|
+
let countOfRemoveOperations = 0;
|
|
116
|
+
let countOfAddOperations = 0;
|
|
117
|
+
let indexForOperation = 0;
|
|
118
|
+
while (oldIndex < oldArray.length || newIndex < newArray.length) {
|
|
119
|
+
while (oldIndex < oldArray.length) {
|
|
120
|
+
let oldItem = oldArray[oldIndex];
|
|
121
|
+
//let oldItemInLcs = itemInArray(oldItem, lcsArray, lcsStartIndexForOld)
|
|
122
|
+
let oldItemInLcs = lcsArray[lcsIndexForOld] == oldItem;
|
|
123
|
+
//console.log('oldItem', oldIndex, oldItem, oldItemInLcs)
|
|
124
|
+
if (oldItemInLcs) {
|
|
125
|
+
//lcsStartIndexForNew++
|
|
126
|
+
//lcsStartIndexForOld++
|
|
127
|
+
lcsIndexForOld++;
|
|
128
|
+
//indexForOperation++
|
|
129
|
+
oldIndex++;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
//onRemove(oldIndex-countOfRemoveOperations, oldItem)
|
|
134
|
+
onRemove(indexForOperation, oldItem);
|
|
135
|
+
countOfRemoveOperations++;
|
|
136
|
+
oldIndex++;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
while (newIndex < newArray.length) {
|
|
140
|
+
let newItem = newArray[newIndex];
|
|
141
|
+
//let newItemInLcs = itemInArray(newItem, lcsArray, lcsStartIndexForNew)
|
|
142
|
+
let newItemInLcs = lcsArray[lcsIndexForNew] == newItem;
|
|
143
|
+
//console.log('newItem', oldIndex, newItem, newItemInLcs)
|
|
144
|
+
if (newItemInLcs) {
|
|
145
|
+
//lcsStartIndexForNew++
|
|
146
|
+
lcsIndexForNew++;
|
|
147
|
+
indexForOperation++;
|
|
148
|
+
newIndex++;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
onAdd(indexForOperation, newItem);
|
|
153
|
+
indexForOperation++;
|
|
154
|
+
countOfAddOperations++;
|
|
155
|
+
newIndex++;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// console.log('countOf(+)operations', countOfAddOperations)
|
|
160
|
+
// console.log('countOf(-)operations', countOfRemoveOperations)
|
|
161
|
+
return countOfAddOperations + countOfRemoveOperations;
|
|
162
|
+
}
|
|
163
|
+
LongestCommonSubsequence.getPatchOrdered = getPatchOrdered;
|
|
164
|
+
})(LongestCommonSubsequence || (LongestCommonSubsequence = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from '@lexriver/async';
|
|
2
|
+
export * from '@lexriver/data-types';
|
|
3
|
+
export * from '@lexriver/observable';
|
|
4
|
+
export * from '@lexriver/type-event';
|
|
5
|
+
export * from './AnimatedArray.mjs';
|
|
6
|
+
export * from './AnimatedTable.mjs';
|
|
7
|
+
export * from './AnimatedText.mjs';
|
|
8
|
+
export * from './Dome.mjs';
|
|
9
|
+
export * from './DomeComponent.mjs';
|
|
10
|
+
export * from './DomeManipulator.mjs';
|
|
11
|
+
export * from './DomeRouter.console-test.mjs';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from '@lexriver/async';
|
|
2
|
+
export * from '@lexriver/data-types';
|
|
3
|
+
export * from '@lexriver/observable';
|
|
4
|
+
export * from '@lexriver/type-event';
|
|
5
|
+
export * from './AnimatedArray.mjs';
|
|
6
|
+
export * from './AnimatedTable.mjs';
|
|
7
|
+
export * from './AnimatedText.mjs';
|
|
8
|
+
export * from './Dome.mjs';
|
|
9
|
+
export * from './DomeComponent.mjs';
|
|
10
|
+
export * from './DomeManipulator.mjs';
|
|
11
|
+
export * from './DomeRouter.console-test.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { LongestCommonSubsequence } from "./LongestCommonSubsequence";
|
|
2
|
-
let oldArray = "ABCD".split('');
|
|
3
|
-
let newArray = "AXYZBCD345".split('');
|
|
4
|
-
const countOfOperations = LongestCommonSubsequence.getPatchOrdered({
|
|
5
|
-
oldArray: [...oldArray],
|
|
6
|
-
newArray: newArray,
|
|
7
|
-
onRemove: (index, item) => {
|
|
8
|
-
console.log('-', item, index);
|
|
9
|
-
oldArray.splice(index, 1);
|
|
10
|
-
},
|
|
11
|
-
onAdd: (index, item) => {
|
|
12
|
-
console.log('+', item, index);
|
|
13
|
-
oldArray.splice(index, 0, item);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
console.log('expecting equal', oldArray, newArray);
|
|
17
|
-
console.log('countOfOperations=', countOfOperations);
|
|
18
|
-
//expect(oldArray).toEqual(newArray)
|
|
19
|
-
// console.log('result oldArray=', oldArray)
|
|
20
|
-
// console.log('result nweArray=', newArray)
|
|
1
|
+
import { LongestCommonSubsequence } from "./LongestCommonSubsequence.mjs";
|
|
2
|
+
let oldArray = "ABCD".split('');
|
|
3
|
+
let newArray = "AXYZBCD345".split('');
|
|
4
|
+
const countOfOperations = LongestCommonSubsequence.getPatchOrdered({
|
|
5
|
+
oldArray: [...oldArray],
|
|
6
|
+
newArray: newArray,
|
|
7
|
+
onRemove: (index, item) => {
|
|
8
|
+
console.log('-', item, index);
|
|
9
|
+
oldArray.splice(index, 1);
|
|
10
|
+
},
|
|
11
|
+
onAdd: (index, item) => {
|
|
12
|
+
console.log('+', item, index);
|
|
13
|
+
oldArray.splice(index, 0, item);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
console.log('expecting equal', oldArray, newArray);
|
|
17
|
+
console.log('countOfOperations=', countOfOperations);
|
|
18
|
+
//expect(oldArray).toEqual(newArray)
|
|
19
|
+
// console.log('result oldArray=', oldArray)
|
|
20
|
+
// console.log('result nweArray=', newArray)
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"type": "module",
|
|
3
2
|
"sideEffects": false,
|
|
4
3
|
"name": "@lexriver/dome",
|
|
5
|
-
"version": "
|
|
6
|
-
"description": "",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"description": "DOM manipulator",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": "./out/src/index.mjs",
|
|
9
8
|
"scripts": {
|
|
10
|
-
"
|
|
9
|
+
"test": "vitest",
|
|
10
|
+
"build": "rimraf out && tsc"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"typescript",
|
|
@@ -23,14 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "^
|
|
27
|
-
"
|
|
26
|
+
"@types/node": "^22.7.0",
|
|
27
|
+
"rimraf": "^6.0.1",
|
|
28
|
+
"typescript": "^5.6.2",
|
|
29
|
+
"vitest": "^2.1.1"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
|
-
"@lexriver/async": "^
|
|
31
|
-
"@lexriver/data-types": "^
|
|
32
|
-
"@lexriver/observable": "^
|
|
33
|
-
"svg-tag-names": "^
|
|
34
|
-
"ts-debounce": "^
|
|
32
|
+
"@lexriver/async": "^3.0.1",
|
|
33
|
+
"@lexriver/data-types": "^3.0.5",
|
|
34
|
+
"@lexriver/observable": "^3.0.0",
|
|
35
|
+
"svg-tag-names": "^3.0.1",
|
|
36
|
+
"ts-debounce": "^4.0.0"
|
|
35
37
|
}
|
|
36
|
-
}
|
|
38
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Animation } from './Animation.mjs'
|
|
2
|
+
import { DomeManipulator } from "./DomeManipulator.mjs"
|
|
3
|
+
import { LongestCommonSubsequence } from "./LongestCommonSubsequence.mjs"
|
|
4
4
|
|
|
5
5
|
interface KeyToElementPair{
|
|
6
6
|
key:string
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ObservableVariable } from '@lexriver/observable'
|
|
2
|
+
import { Animation } from './Animation.mjs'
|
|
3
|
+
import { DomeManipulator } from "./DomeManipulator.mjs"
|
|
4
|
+
import { AnimatedArray, DomeComponent } from "./index.mjs"
|
|
5
5
|
|
|
6
6
|
interface Attrs<T>{
|
|
7
|
-
isLoadingO?:
|
|
8
|
-
itemsO:
|
|
7
|
+
isLoadingO?:ObservableVariable<boolean>
|
|
8
|
+
itemsO:ObservableVariable<T[]>
|
|
9
9
|
animationShowRow:Animation
|
|
10
10
|
animationHideRow:Animation
|
|
11
11
|
animationHideTable?:Animation
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ObservableVariable } from "@lexriver/observable";
|
|
2
|
+
import { CssClass, DomeManipulator } from "./DomeManipulator.mjs";
|
|
3
|
+
import { DomeComponent } from "./index.mjs";
|
|
4
4
|
|
|
5
5
|
interface Attrs{
|
|
6
|
-
textO:
|
|
6
|
+
textO:ObservableVariable<string>
|
|
7
7
|
tag?:string
|
|
8
8
|
class?:CssClass
|
|
9
9
|
}
|
package/src/{Dome.ts → Dome.mts}
RENAMED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// inspiration: https://github.com/vadimdemedes/dom-chef/blob/master/index.js
|
|
2
|
-
//import svgTagNames from 'svg-tag-names'
|
|
3
2
|
const svgTagNames = require('svg-tag-names')
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { DomeManipulator } from './DomeManipulator'
|
|
8
|
-
import { ObservableValue, checkIfObservable } from '@lexriver/observable'
|
|
9
|
-
import { DomeComponent } from './DomeComponent'
|
|
10
|
-
import { DataTypes} from '@lexriver/data-types'
|
|
3
|
+
import { DataTypes } from '@lexriver/data-types'
|
|
4
|
+
import { ObservableVariable, checkIfObservable } from '@lexriver/observable'
|
|
5
|
+
import { DomeComponent } from './DomeComponent.mjs'
|
|
6
|
+
import { DomeManipulator } from './DomeManipulator.mjs'
|
|
11
7
|
|
|
12
8
|
const filename = '[Dome]: '
|
|
13
9
|
|
|
@@ -219,7 +215,7 @@ const build = (tagName, attrs, children:DocumentFragment) => {
|
|
|
219
215
|
console.error('value=', value)
|
|
220
216
|
throw new Error('Please provide Observable<boolean> as argument for visibleIf')
|
|
221
217
|
}
|
|
222
|
-
let obs = value as
|
|
218
|
+
let obs = value as ObservableVariable<boolean>
|
|
223
219
|
obs.eventOnChange.subscribe((isVisible) => {
|
|
224
220
|
if(isVisible){
|
|
225
221
|
DomeManipulator.unhideElementAsync(el)
|
|
@@ -266,7 +262,7 @@ const build = (tagName, attrs, children:DocumentFragment) => {
|
|
|
266
262
|
* @param name
|
|
267
263
|
* @param element
|
|
268
264
|
*/
|
|
269
|
-
function assignDynamicCssClasses(name: string, value: {[key:string]:boolean|
|
|
265
|
+
function assignDynamicCssClasses(name: string, value: {[key:string]:boolean|ObservableVariable<boolean>}, element: any) {
|
|
270
266
|
if (DataTypes.isObjectWithKeys(value) == false){
|
|
271
267
|
DomeManipulator.setCssClasses(element, value)
|
|
272
268
|
return
|
|
@@ -283,7 +279,7 @@ function assignDynamicCssClasses(name: string, value: {[key:string]:boolean|Obse
|
|
|
283
279
|
}
|
|
284
280
|
|
|
285
281
|
} else if (checkIfObservable(v)) {
|
|
286
|
-
let o = v as
|
|
282
|
+
let o = v as ObservableVariable<boolean>
|
|
287
283
|
o.eventOnChange.subscribe((showThiCssClass) => {
|
|
288
284
|
if(!DomeManipulator.isInDom(element)) return {unsubscribe:true} //TODO: test it
|
|
289
285
|
// reassign whole attribute
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Animation } from './Animation'
|
|
3
|
-
import {
|
|
1
|
+
import { debounce } from 'ts-debounce'
|
|
2
|
+
import { Animation } from './Animation.mjs'
|
|
3
|
+
import { DomeManipulator } from "./DomeManipulator.mjs"
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
interface InternalAttrs{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ObservableValue, checkIfObservable } from "@lexriver/observable"
|
|
2
|
-
import { Animation } from './Animation'
|
|
3
1
|
import { Async } from "@lexriver/async"
|
|
4
2
|
import { DataTypes } from "@lexriver/data-types"
|
|
3
|
+
import { ObservableVariable, checkIfObservable } from "@lexriver/observable"
|
|
4
|
+
import { Animation } from './Animation.mjs'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
export type CssClass = {[key:string]:boolean|
|
|
7
|
+
export type CssClass = {[key:string]:boolean|ObservableVariable<boolean>} | string[] | string
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export namespace DomeManipulator {
|
|
10
10
|
|
|
11
11
|
export async function hideElementAsync(element: Element, animation?:Animation) {
|
|
12
12
|
if(!element) throw new Error('hideElementAsync failed, no element')
|
|
@@ -256,7 +256,7 @@ export module DomeManipulator {
|
|
|
256
256
|
let classNameArray: Array<string> = []
|
|
257
257
|
for (let [k, v] of Object.entries(value)) {
|
|
258
258
|
if (checkIfObservable(v)) {
|
|
259
|
-
if ((v as
|
|
259
|
+
if ((v as ObservableVariable<boolean>).get()) {
|
|
260
260
|
classNameArray.push(k)
|
|
261
261
|
}
|
|
262
262
|
} else if (v) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DomeManipulator } from "./DomeManipulator"
|
|
1
|
+
import { DomeManipulator } from "./DomeManipulator.mjs"
|
|
2
2
|
|
|
3
|
-
const filename = '[DomeRouter]'
|
|
3
|
+
// const filename = '[DomeRouter]'
|
|
4
4
|
|
|
5
5
|
export type RouteAction = (
|
|
6
6
|
params:{[key:string]:string},
|
|
@@ -19,7 +19,7 @@ interface HistoryUrl{
|
|
|
19
19
|
scroll:number
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export
|
|
22
|
+
export namespace DomeRouter {
|
|
23
23
|
const historyUrls:HistoryUrl[] = []
|
|
24
24
|
const scrollPositionByUrl = new Map<string, number>()
|
|
25
25
|
export let maxHistoryUrlsCount:number = 20
|
package/src/index.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from '@lexriver/async'
|
|
2
|
+
export * from '@lexriver/data-types'
|
|
3
|
+
export * from '@lexriver/observable'
|
|
4
|
+
export * from '@lexriver/type-event'
|
|
5
|
+
export * from './AnimatedArray.mjs'
|
|
6
|
+
export * from './AnimatedTable.mjs'
|
|
7
|
+
export * from './AnimatedText.mjs'
|
|
8
|
+
export * from './Dome.mjs'
|
|
9
|
+
export * from './DomeComponent.mjs'
|
|
10
|
+
export * from './DomeManipulator.mjs'
|
|
11
|
+
export * from './DomeRouter.console-test.mjs'
|
|
12
|
+
|