@tko/utils 4.0.0-alpha7.3 → 4.0.0-beta1.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/LICENSE +22 -0
- package/dist/array.js +156 -0
- package/dist/array.js.map +7 -0
- package/dist/async.js +20 -0
- package/dist/async.js.map +7 -0
- package/dist/bind-shim.js +18 -0
- package/dist/bind-shim.js.map +7 -0
- package/dist/css.js +27 -0
- package/dist/css.js.map +7 -0
- package/dist/dom/data.js +63 -0
- package/dist/dom/data.js.map +7 -0
- package/dist/dom/disposal.js +98 -0
- package/dist/dom/disposal.js.map +7 -0
- package/dist/dom/event.js +87 -0
- package/dist/dom/event.js.map +7 -0
- package/dist/dom/fixes.js +45 -0
- package/dist/dom/fixes.js.map +7 -0
- package/dist/dom/html.js +115 -0
- package/dist/dom/html.js.map +7 -0
- package/dist/dom/info.js +43 -0
- package/dist/dom/info.js.map +7 -0
- package/dist/dom/manipulation.js +55 -0
- package/dist/dom/manipulation.js.map +7 -0
- package/dist/dom/selectExtensions.js +62 -0
- package/dist/dom/selectExtensions.js.map +7 -0
- package/dist/dom/virtualElements.js +202 -0
- package/dist/dom/virtualElements.js.map +7 -0
- package/dist/error.js +22 -0
- package/dist/error.js.map +7 -0
- package/dist/function.js +16 -0
- package/dist/function.js.map +7 -0
- package/dist/ie.js +15 -0
- package/dist/ie.js.map +7 -0
- package/dist/index.cjs +1448 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +7 -0
- package/dist/jquery.js +6 -0
- package/dist/jquery.js.map +7 -0
- package/dist/memoization.js +64 -0
- package/dist/memoization.js.map +7 -0
- package/dist/object.js +76 -0
- package/dist/object.js.map +7 -0
- package/dist/options.js +36 -0
- package/dist/options.js.map +7 -0
- package/dist/string.js +23 -0
- package/dist/string.js.map +7 -0
- package/dist/symbol.js +5 -0
- package/dist/symbol.js.map +7 -0
- package/dist/tasks.js +76 -0
- package/dist/tasks.js.map +7 -0
- package/helpers/jasmine-13-helper.ts +207 -0
- package/package.json +18 -26
- package/dist/utils.es6.js +0 -1628
- package/dist/utils.es6.js.map +0 -1
- package/dist/utils.js +0 -1645
- package/dist/utils.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php
|
|
2
|
+
|
|
3
|
+
Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors
|
|
4
|
+
http://knockoutjs.com/
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/dist/array.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
const { isArray } = Array;
|
|
3
|
+
export function arrayForEach(array, action, thisArg) {
|
|
4
|
+
if (arguments.length > 2) {
|
|
5
|
+
action = action.bind(thisArg);
|
|
6
|
+
}
|
|
7
|
+
for (let i = 0, j = array.length; i < j; ++i) {
|
|
8
|
+
action(array[i], i, array);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function arrayIndexOf(array, item) {
|
|
12
|
+
return (isArray(array) ? array : [...array]).indexOf(item);
|
|
13
|
+
}
|
|
14
|
+
export function arrayFirst(array, predicate, predicateOwner) {
|
|
15
|
+
return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
|
|
16
|
+
}
|
|
17
|
+
export function arrayMap(array = [], mapping, thisArg) {
|
|
18
|
+
if (arguments.length > 2) {
|
|
19
|
+
mapping = mapping.bind(thisArg);
|
|
20
|
+
}
|
|
21
|
+
return array === null ? [] : Array.from(array, mapping);
|
|
22
|
+
}
|
|
23
|
+
export function arrayRemoveItem(array, itemToRemove) {
|
|
24
|
+
var index = arrayIndexOf(array, itemToRemove);
|
|
25
|
+
if (index > 0) {
|
|
26
|
+
array.splice(index, 1);
|
|
27
|
+
} else if (index === 0) {
|
|
28
|
+
array.shift();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function arrayGetDistinctValues(array = []) {
|
|
32
|
+
const seen = /* @__PURE__ */ new Set();
|
|
33
|
+
if (array === null) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return (isArray(array) ? array : [...array]).filter((item) => seen.has(item) ? false : seen.add(item));
|
|
37
|
+
}
|
|
38
|
+
export function arrayFilter(array, predicate, thisArg) {
|
|
39
|
+
if (arguments.length > 2) {
|
|
40
|
+
predicate = predicate.bind(thisArg);
|
|
41
|
+
}
|
|
42
|
+
return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);
|
|
43
|
+
}
|
|
44
|
+
export function arrayPushAll(array, valuesToPush) {
|
|
45
|
+
if (isArray(valuesToPush)) {
|
|
46
|
+
array.push.apply(array, valuesToPush);
|
|
47
|
+
} else {
|
|
48
|
+
for (var i = 0, j = valuesToPush.length; i < j; i++) {
|
|
49
|
+
array.push(valuesToPush[i]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return array;
|
|
53
|
+
}
|
|
54
|
+
export function addOrRemoveItem(array, value, included) {
|
|
55
|
+
var existingEntryIndex = arrayIndexOf(typeof array.peek === "function" ? array.peek() : array, value);
|
|
56
|
+
if (existingEntryIndex < 0) {
|
|
57
|
+
if (included) {
|
|
58
|
+
array.push(value);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
if (!included) {
|
|
62
|
+
array.splice(existingEntryIndex, 1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function makeArray(arrayLikeObject) {
|
|
67
|
+
return Array.from(arrayLikeObject);
|
|
68
|
+
}
|
|
69
|
+
export function range(min, max) {
|
|
70
|
+
min = typeof min === "function" ? min() : min;
|
|
71
|
+
max = typeof max === "function" ? max() : max;
|
|
72
|
+
var result = [];
|
|
73
|
+
for (var i = min; i <= max; i++) {
|
|
74
|
+
result.push(i);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
export function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
79
|
+
if (left.length && right.length) {
|
|
80
|
+
var failedCompares, l, r, leftItem, rightItem;
|
|
81
|
+
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
82
|
+
for (r = 0; rightItem = right[r]; ++r) {
|
|
83
|
+
if (leftItem.value === rightItem.value) {
|
|
84
|
+
leftItem.moved = rightItem.index;
|
|
85
|
+
rightItem.moved = leftItem.index;
|
|
86
|
+
right.splice(r, 1);
|
|
87
|
+
failedCompares = r = 0;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
failedCompares += r;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const statusNotInOld = "added";
|
|
96
|
+
const statusNotInNew = "deleted";
|
|
97
|
+
export function compareArrays(oldArray, newArray, options) {
|
|
98
|
+
options = typeof options === "boolean" ? { dontLimitMoves: options } : options || {};
|
|
99
|
+
oldArray = oldArray || [];
|
|
100
|
+
newArray = newArray || [];
|
|
101
|
+
if (oldArray.length < newArray.length) {
|
|
102
|
+
return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options);
|
|
103
|
+
} else {
|
|
104
|
+
return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options) {
|
|
108
|
+
var myMin = Math.min, myMax = Math.max, editDistanceMatrix = [], smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
|
|
109
|
+
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
110
|
+
lastRow = thisRow;
|
|
111
|
+
editDistanceMatrix.push(thisRow = []);
|
|
112
|
+
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
113
|
+
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
114
|
+
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
115
|
+
if (!bigIndex) {
|
|
116
|
+
thisRow[bigIndex] = smlIndex + 1;
|
|
117
|
+
} else if (!smlIndex) {
|
|
118
|
+
thisRow[bigIndex] = bigIndex + 1;
|
|
119
|
+
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
120
|
+
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
121
|
+
} else {
|
|
122
|
+
var northDistance = lastRow[bigIndex] || maxDistance;
|
|
123
|
+
var westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
124
|
+
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
var editScript = [], meMinusOne, notInSml = [], notInBig = [];
|
|
129
|
+
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
130
|
+
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
131
|
+
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
132
|
+
notInSml.push(editScript[editScript.length] = {
|
|
133
|
+
"status": statusNotInSml,
|
|
134
|
+
"value": bigArray[--bigIndex],
|
|
135
|
+
"index": bigIndex
|
|
136
|
+
});
|
|
137
|
+
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
138
|
+
notInBig.push(editScript[editScript.length] = {
|
|
139
|
+
"status": statusNotInBig,
|
|
140
|
+
"value": smlArray[--smlIndex],
|
|
141
|
+
"index": smlIndex
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
--bigIndex;
|
|
145
|
+
--smlIndex;
|
|
146
|
+
if (!options.sparse) {
|
|
147
|
+
editScript.push({
|
|
148
|
+
"status": "retained",
|
|
149
|
+
"value": bigArray[bigIndex]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
findMovesInArrayComparison(notInBig, notInSml, !options.dontLimitMoves && smlIndexMax * 10);
|
|
155
|
+
return editScript.reverse();
|
|
156
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/array.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Array utilities\n//\n// Note that the array functions may be called with\n// Array-like things, such as NodeList.\n\nconst {isArray} = Array\n\nexport function arrayForEach (array, action, thisArg) {\n if (arguments.length > 2) { action = action.bind(thisArg) }\n for (let i = 0, j = array.length; i < j; ++i) {\n action(array[i], i, array)\n }\n}\n\nexport function arrayIndexOf (array, item) {\n return (isArray(array) ? array : [...array]).indexOf(item)\n}\n\nexport function arrayFirst (array, predicate, predicateOwner) {\n return (isArray(array) ? array : [...array])\n .find(predicate, predicateOwner)\n}\n\nexport function arrayMap (array = [], mapping, thisArg) {\n if (arguments.length > 2) { mapping = mapping.bind(thisArg) }\n return array === null ? [] : Array.from(array, mapping)\n}\n\nexport function arrayRemoveItem (array, itemToRemove) {\n var index = arrayIndexOf(array, itemToRemove)\n if (index > 0) {\n array.splice(index, 1)\n } else if (index === 0) {\n array.shift()\n }\n}\n\nexport function arrayGetDistinctValues (array = []) {\n const seen = new Set()\n if (array === null) { return [] }\n return (isArray(array) ? array : [...array])\n .filter(item => seen.has(item) ? false : seen.add(item))\n}\n\nexport function arrayFilter (array, predicate, thisArg) {\n if (arguments.length > 2) { predicate = predicate.bind(thisArg) }\n return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate)\n}\n\nexport function arrayPushAll (array, valuesToPush) {\n if (isArray(valuesToPush)) {\n array.push.apply(array, valuesToPush)\n } else {\n for (var i = 0, j = valuesToPush.length; i < j; i++) { array.push(valuesToPush[i]) }\n }\n return array\n}\n\nexport function addOrRemoveItem (array, value, included) {\n var existingEntryIndex = arrayIndexOf(typeof array.peek === 'function' ? array.peek() : array, value)\n if (existingEntryIndex < 0) {\n if (included) { array.push(value) }\n } else {\n if (!included) { array.splice(existingEntryIndex, 1) }\n }\n}\n\nexport function makeArray (arrayLikeObject) {\n return Array.from(arrayLikeObject)\n}\n\nexport function range (min, max) {\n min = typeof min === 'function' ? min() : min\n max = typeof max === 'function' ? max() : max\n var result = []\n for (var i = min; i <= max; i++) { result.push(i) }\n return result\n}\n\n// Go through the items that have been added and deleted and try to find matches between them.\nexport function findMovesInArrayComparison (left, right, limitFailedCompares) {\n if (left.length && right.length) {\n var failedCompares, l, r, leftItem, rightItem\n for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {\n for (r = 0; rightItem = right[r]; ++r) {\n if (leftItem.value === rightItem.value) {\n leftItem.moved = rightItem.index\n rightItem.moved = leftItem.index\n right.splice(r, 1) // This item is marked as moved; so remove it from right list\n failedCompares = r = 0 // Reset failed compares count because we're checking for consecutive failures\n break\n }\n }\n failedCompares += r\n }\n }\n}\n\nconst statusNotInOld = 'added'\nconst statusNotInNew = 'deleted'\n\n // Simple calculation based on Levenshtein distance.\nexport function compareArrays (oldArray, newArray, options) {\n // For backward compatibility, if the third arg is actually a bool, interpret\n // it as the old parameter 'dontLimitMoves'. Newer code should use { dontLimitMoves: true }.\n options = (typeof options === 'boolean') ? { dontLimitMoves: options } : (options || {})\n oldArray = oldArray || []\n newArray = newArray || []\n\n if (oldArray.length < newArray.length) { return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options) } else { return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options) }\n}\n\nfunction compareSmallArrayToBigArray (smlArray, bigArray, statusNotInSml, statusNotInBig, options) {\n var myMin = Math.min,\n myMax = Math.max,\n editDistanceMatrix = [],\n smlIndex, smlIndexMax = smlArray.length,\n bigIndex, bigIndexMax = bigArray.length,\n compareRange = (bigIndexMax - smlIndexMax) || 1,\n maxDistance = smlIndexMax + bigIndexMax + 1,\n thisRow, lastRow,\n bigIndexMaxForRow, bigIndexMinForRow\n\n for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {\n lastRow = thisRow\n editDistanceMatrix.push(thisRow = [])\n bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange)\n bigIndexMinForRow = myMax(0, smlIndex - 1)\n for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {\n if (!bigIndex) {\n thisRow[bigIndex] = smlIndex + 1\n } else if (!smlIndex) {\n // Top row - transform empty array into new array via additions\n thisRow[bigIndex] = bigIndex + 1\n } else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {\n thisRow[bigIndex] = lastRow[bigIndex - 1]\n } else { // copy value (no edit)\n var northDistance = lastRow[bigIndex] || maxDistance // not in big (deletion)\n var westDistance = thisRow[bigIndex - 1] || maxDistance // not in small (addition)\n thisRow[bigIndex] = myMin(northDistance, westDistance) + 1\n }\n }\n }\n\n var editScript = [], meMinusOne, notInSml = [], notInBig = []\n for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex;) {\n meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1\n if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {\n notInSml.push(editScript[editScript.length] = { // added\n 'status': statusNotInSml,\n 'value': bigArray[--bigIndex],\n 'index': bigIndex })\n } else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {\n notInBig.push(editScript[editScript.length] = { // deleted\n 'status': statusNotInBig,\n 'value': smlArray[--smlIndex],\n 'index': smlIndex })\n } else {\n --bigIndex\n --smlIndex\n if (!options.sparse) {\n editScript.push({\n 'status': 'retained',\n 'value': bigArray[bigIndex] })\n }\n }\n }\n\n // Set a limit on the number of consecutive non-matching comparisons; having it a multiple of\n // smlIndexMax keeps the time complexity of this algorithm linear.\n findMovesInArrayComparison(notInBig, notInSml, !options.dontLimitMoves && smlIndexMax * 10)\n\n return editScript.reverse()\n}\n"],
|
|
5
|
+
"mappings": ";AAMA,MAAM,EAAC,YAAW;AAEX,6BAAuB,OAAO,QAAQ,SAAS;AACpD,MAAI,UAAU,SAAS,GAAG;AAAE,aAAS,OAAO,KAAK,OAAO;AAAA,EAAE;AAC1D,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,IAAI,GAAG,EAAE,GAAG;AAC5C,WAAO,MAAM,IAAI,GAAG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AAW,aAAa,YAAY,YAAW;AAC1E,iBAAa,mBAAmB,UAAU,YAAY;AACtD,QAAI,YAAY,eAAe,mBAAmB,UAAU,WAAW,IAAI;AACzE,eAAS,KAAK,WAAW,WAAW,UAAU;AAAA,QAC5C,UAAU;AAAA,QACV,SAAS,SAAS,EAAE;AAAA,QACpB,SAAS;AAAA,MAAS,CAAC;AAAA,IACvB,WAAW,YAAY,eAAe,mBAAmB,WAAW,GAAG,WAAW;AAChF,eAAS,KAAK,WAAW,WAAW,UAAU;AAAA,QAC5C,UAAU;AAAA,QACV,SAAS,SAAS,EAAE;AAAA,QACpB,SAAS;AAAA,MAAS,CAAC;AAAA,IACvB,OAAO;AACL,QAAE;AACF,QAAE;AACF,UAAI,CAAC,QAAQ,QAAQ;AACnB,mBAAW,KAAK;AAAA,UACd,UAAU;AAAA,UACV,SAAS,SAAS;AAAA,QAAU,CAAC;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AAIA,6BAA2B,UAAU,UAAU,CAAC,QAAQ,kBAAkB,cAAc,EAAE;AAE1F,SAAO,WAAW,QAAQ;AAC5B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/async.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
import { safeSetTimeout } from "./error";
|
|
3
|
+
export function throttle(callback, timeout) {
|
|
4
|
+
var timeoutInstance;
|
|
5
|
+
return function(...args) {
|
|
6
|
+
if (!timeoutInstance) {
|
|
7
|
+
timeoutInstance = safeSetTimeout(function() {
|
|
8
|
+
timeoutInstance = void 0;
|
|
9
|
+
callback(...args);
|
|
10
|
+
}, timeout);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function debounce(callback, timeout) {
|
|
15
|
+
var timeoutInstance;
|
|
16
|
+
return function(...args) {
|
|
17
|
+
clearTimeout(timeoutInstance);
|
|
18
|
+
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/async.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Asynchronous functionality\n// ---\nimport { safeSetTimeout } from './error'\n\nexport function throttle (callback, timeout) {\n var timeoutInstance\n return function (...args) {\n if (!timeoutInstance) {\n timeoutInstance = safeSetTimeout(function () {\n timeoutInstance = undefined\n callback(...args)\n }, timeout)\n }\n }\n}\n\nexport function debounce (callback, timeout) {\n var timeoutInstance\n return function (...args) {\n clearTimeout(timeoutInstance)\n timeoutInstance = safeSetTimeout(() => callback(...args), timeout)\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAEO,yBAAmB,UAAU,SAAS;AAC3C,MAAI;AACJ,SAAO,YAAa,MAAM;AACxB,QAAI,CAAC,iBAAiB;AACpB,wBAAkB,eAAe,WAAY;AAC3C,0BAAkB;AAClB,iBAAS,GAAG,IAAI;AAAA,MAClB,GAAG,OAAO;AAAA,IACZ;AAAA,EACF;AACF;AAEO,yBAAmB,UAAU,SAAS;AAC3C,MAAI;AACJ,SAAO,YAAa,MAAM;AACxB,iBAAa,eAAe;AAC5B,sBAAkB,eAAe,MAAM,SAAS,GAAG,IAAI,GAAG,OAAO;AAAA,EACnE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
if (!Function.prototype["bind"]) {
|
|
3
|
+
Function.prototype["bind"] = function(object) {
|
|
4
|
+
var originalFunction = this;
|
|
5
|
+
if (arguments.length === 1) {
|
|
6
|
+
return function() {
|
|
7
|
+
return originalFunction.apply(object, arguments);
|
|
8
|
+
};
|
|
9
|
+
} else {
|
|
10
|
+
var partialArgs = Array.prototype.slice.call(arguments, 1);
|
|
11
|
+
return function() {
|
|
12
|
+
var args = partialArgs.slice(0);
|
|
13
|
+
args.push.apply(args, arguments);
|
|
14
|
+
return originalFunction.apply(object, args);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/bind-shim.ts"],
|
|
4
|
+
"sourcesContent": ["\nif (!Function.prototype['bind']) {\n // Shim/polyfill JavaScript Function.bind.\n // This implementation is based on the one in prototype.js\n Function.prototype['bind'] = function (object) {\n var originalFunction = this\n if (arguments.length === 1) {\n return function () {\n return originalFunction.apply(object, arguments)\n }\n } else {\n var partialArgs = Array.prototype.slice.call(arguments, 1)\n return function () {\n var args = partialArgs.slice(0)\n args.push.apply(args, arguments)\n return originalFunction.apply(object, args)\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AACA,IAAI,CAAC,SAAS,UAAU,SAAS;AAG/B,WAAS,UAAU,UAAU,SAAU,QAAQ;AAC7C,QAAI,mBAAmB;AACvB,QAAI,UAAU,WAAW,GAAG;AAC1B,aAAO,WAAY;AACjB,eAAO,iBAAiB,MAAM,QAAQ,SAAS;AAAA,MACjD;AAAA,IACF,OAAO;AACL,UAAI,cAAc,MAAM,UAAU,MAAM,KAAK,WAAW,CAAC;AACzD,aAAO,WAAY;AACjB,YAAI,OAAO,YAAY,MAAM,CAAC;AAC9B,aAAK,KAAK,MAAM,MAAM,SAAS;AAC/B,eAAO,iBAAiB,MAAM,QAAQ,IAAI;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/css.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
import { arrayForEach, addOrRemoveItem } from "./array";
|
|
3
|
+
var cssClassNameRegex = /\S+/g;
|
|
4
|
+
function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
|
|
5
|
+
var addOrRemoveFn;
|
|
6
|
+
if (!classNames) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (typeof node.classList === "object") {
|
|
10
|
+
addOrRemoveFn = node.classList[shouldHaveClass ? "add" : "remove"];
|
|
11
|
+
arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
|
12
|
+
addOrRemoveFn.call(node.classList, className);
|
|
13
|
+
});
|
|
14
|
+
} else if (typeof node.className["baseVal"] === "string") {
|
|
15
|
+
toggleObjectClassPropertyString(node.className, "baseVal", classNames, shouldHaveClass);
|
|
16
|
+
} else {
|
|
17
|
+
toggleObjectClassPropertyString(node, "className", classNames, shouldHaveClass);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {
|
|
21
|
+
var currentClassNames = obj[prop].match(cssClassNameRegex) || [];
|
|
22
|
+
arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
|
23
|
+
addOrRemoveItem(currentClassNames, className, shouldHaveClass);
|
|
24
|
+
});
|
|
25
|
+
obj[prop] = currentClassNames.join(" ");
|
|
26
|
+
}
|
|
27
|
+
export { toggleDomNodeCssClass };
|
package/dist/css.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/css.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// DOM - CSS\n//\n\nimport { arrayForEach, addOrRemoveItem } from './array'\n\n// For details on the pattern for changing node classes\n// see: https://github.com/knockout/knockout/issues/1597\nvar cssClassNameRegex = /\\S+/g\n\nfunction toggleDomNodeCssClass (node, classNames, shouldHaveClass) {\n var addOrRemoveFn\n if (!classNames) { return }\n if (typeof node.classList === 'object') {\n addOrRemoveFn = node.classList[shouldHaveClass ? 'add' : 'remove']\n arrayForEach(classNames.match(cssClassNameRegex), function (className) {\n addOrRemoveFn.call(node.classList, className)\n })\n } else if (typeof node.className['baseVal'] === 'string') {\n // SVG tag .classNames is an SVGAnimatedString instance\n toggleObjectClassPropertyString(node.className, 'baseVal', classNames, shouldHaveClass)\n } else {\n // node.className ought to be a string.\n toggleObjectClassPropertyString(node, 'className', classNames, shouldHaveClass)\n }\n}\n\nfunction toggleObjectClassPropertyString (obj, prop, classNames, shouldHaveClass) {\n // obj/prop is either a node/'className' or a SVGAnimatedString/'baseVal'.\n var currentClassNames = obj[prop].match(cssClassNameRegex) || []\n arrayForEach(classNames.match(cssClassNameRegex), function (className) {\n addOrRemoveItem(currentClassNames, className, shouldHaveClass)\n })\n obj[prop] = currentClassNames.join(' ')\n}\n\nexport { toggleDomNodeCssClass }\n"],
|
|
5
|
+
"mappings": ";AAIA;AAIA,IAAI,oBAAoB;AAExB,+BAAgC,MAAM,YAAY,iBAAiB;AACjE,MAAI;AACJ,MAAI,CAAC,YAAY;AAAE;AAAA,EAAO;AAC1B,MAAI,OAAO,KAAK,cAAc,UAAU;AACtC,oBAAgB,KAAK,UAAU,kBAAkB,QAAQ;AACzD,iBAAa,WAAW,MAAM,iBAAiB,GAAG,SAAU,WAAW;AACrE,oBAAc,KAAK,KAAK,WAAW,SAAS;AAAA,IAC9C,CAAC;AAAA,EACH,WAAW,OAAO,KAAK,UAAU,eAAe,UAAU;AAExD,oCAAgC,KAAK,WAAW,WAAW,YAAY,eAAe;AAAA,EACxF,OAAO;AAEL,oCAAgC,MAAM,aAAa,YAAY,eAAe;AAAA,EAChF;AACF;AAEA,yCAA0C,KAAK,MAAM,YAAY,iBAAiB;AAEhF,MAAI,oBAAoB,IAAI,MAAM,MAAM,iBAAiB,KAAK,CAAC;AAC/D,eAAa,WAAW,MAAM,iBAAiB,GAAG,SAAU,WAAW;AACrE,oBAAgB,mBAAmB,WAAW,eAAe;AAAA,EAC/D,CAAC;AACD,MAAI,QAAQ,kBAAkB,KAAK,GAAG;AACxC;AAEA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/dom/data.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
import { ieVersion } from "../ie";
|
|
3
|
+
const datastoreTime = new Date().getTime();
|
|
4
|
+
const dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
5
|
+
const dataStoreSymbol = Symbol("Knockout data");
|
|
6
|
+
var dataStore;
|
|
7
|
+
let uniqueId = 0;
|
|
8
|
+
const modern = {
|
|
9
|
+
getDataForNode(node, createIfNotFound) {
|
|
10
|
+
let dataForNode = node[dataStoreSymbol];
|
|
11
|
+
if (!dataForNode && createIfNotFound) {
|
|
12
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
13
|
+
}
|
|
14
|
+
return dataForNode;
|
|
15
|
+
},
|
|
16
|
+
clear(node) {
|
|
17
|
+
if (node[dataStoreSymbol]) {
|
|
18
|
+
delete node[dataStoreSymbol];
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const IE = {
|
|
25
|
+
getDataforNode(node, createIfNotFound) {
|
|
26
|
+
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
27
|
+
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
|
|
28
|
+
if (!hasExistingDataStore) {
|
|
29
|
+
if (!createIfNotFound) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
|
33
|
+
dataStore[dataStoreKey] = {};
|
|
34
|
+
}
|
|
35
|
+
return dataStore[dataStoreKey];
|
|
36
|
+
},
|
|
37
|
+
clear(node) {
|
|
38
|
+
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
39
|
+
if (dataStoreKey) {
|
|
40
|
+
delete dataStore[dataStoreKey];
|
|
41
|
+
node[dataStoreKeyExpandoPropertyName] = null;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const { getDataForNode, clear } = ieVersion ? IE : modern;
|
|
48
|
+
export function nextKey() {
|
|
49
|
+
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
50
|
+
}
|
|
51
|
+
function get(node, key) {
|
|
52
|
+
const dataForNode = getDataForNode(node, false);
|
|
53
|
+
return dataForNode && dataForNode[key];
|
|
54
|
+
}
|
|
55
|
+
function set(node, key, value) {
|
|
56
|
+
var dataForNode = getDataForNode(node, value !== void 0);
|
|
57
|
+
dataForNode && (dataForNode[key] = value);
|
|
58
|
+
}
|
|
59
|
+
function getOrSet(node, key, value) {
|
|
60
|
+
const dataForNode = getDataForNode(node, true);
|
|
61
|
+
return dataForNode[key] || (dataForNode[key] = value);
|
|
62
|
+
}
|
|
63
|
+
export { get, set, getOrSet, clear };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/data.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// DOM node data\n//\nimport { ieVersion } from '../ie'\n\nconst datastoreTime = new Date().getTime()\nconst dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`\nconst dataStoreSymbol = Symbol('Knockout data')\nvar dataStore\nlet uniqueId = 0\n\n/*\n * We considered using WeakMap, but it has a problem in IE 11 and Edge that\n * prevents using it cross-window, so instead we just store the data directly\n * on the node. See https://github.com/knockout/knockout/issues/2141\n */\nconst modern = {\n getDataForNode (node, createIfNotFound) {\n let dataForNode = node[dataStoreSymbol]\n if (!dataForNode && createIfNotFound) {\n dataForNode = node[dataStoreSymbol] = {}\n }\n return dataForNode\n },\n\n clear (node) {\n if (node[dataStoreSymbol]) {\n delete node[dataStoreSymbol]\n return true\n }\n return false\n }\n}\n\n/**\n * Old IE versions have memory issues if you store objects on the node, so we\n * use a separate data storage and link to it from the node using a string key.\n */\nconst IE = {\n getDataforNode (node, createIfNotFound) {\n let dataStoreKey = node[dataStoreKeyExpandoPropertyName]\n const hasExistingDataStore = dataStoreKey && (dataStoreKey !== 'null') && dataStore[dataStoreKey]\n if (!hasExistingDataStore) {\n if (!createIfNotFound) {\n return undefined\n }\n dataStoreKey = node[dataStoreKeyExpandoPropertyName] = 'ko' + uniqueId++\n dataStore[dataStoreKey] = {}\n }\n return dataStore[dataStoreKey]\n },\n\n clear (node) {\n const dataStoreKey = node[dataStoreKeyExpandoPropertyName]\n if (dataStoreKey) {\n delete dataStore[dataStoreKey]\n node[dataStoreKeyExpandoPropertyName] = null\n return true // Exposing 'did clean' flag purely so specs can infer whether things have been cleaned up as intended\n }\n return false\n }\n}\n\nconst {getDataForNode, clear} = ieVersion ? IE : modern\n\n/**\n * Create a unique key-string identifier.\n */\nexport function nextKey () {\n return (uniqueId++) + dataStoreKeyExpandoPropertyName\n}\n\nfunction get (node, key) {\n const dataForNode = getDataForNode(node, false)\n return dataForNode && dataForNode[key]\n}\n\nfunction set (node, key, value) {\n // Make sure we don't actually create a new domData key if we are actually deleting a value\n var dataForNode = getDataForNode(node, value !== undefined /* createIfNotFound */)\n dataForNode && (dataForNode[key] = value)\n}\n\nfunction getOrSet (node, key, value) {\n const dataForNode = getDataForNode(node, true, /* createIfNotFound */)\n return dataForNode[key] || (dataForNode[key] = value)\n}\n\nexport { get, set, getOrSet, clear }\n"],
|
|
5
|
+
"mappings": ";AAGA;AAEA,MAAM,gBAAgB,IAAI,KAAK,EAAE,QAAQ;AACzC,MAAM,kCAAkC,SAAS;AACjD,MAAM,kBAAkB,OAAO,eAAe;AAC9C,IAAI;AACJ,IAAI,WAAW;AAOf,MAAM,SAAS;AAAA,EACb,eAAgB,MAAM,kBAAkB;AACtC,QAAI,cAAc,KAAK;AACvB,QAAI,CAAC,eAAe,kBAAkB;AACpC,oBAAc,KAAK,mBAAmB,CAAC;AAAA,IACzC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAO,MAAM;AACX,QAAI,KAAK,kBAAkB;AACzB,aAAO,KAAK;AACZ,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;AAMA,MAAM,KAAK;AAAA,EACT,eAAgB,MAAM,kBAAkB;AACtC,QAAI,eAAe,KAAK;AACxB,UAAM,uBAAuB,gBAAiB,iBAAiB,UAAW,UAAU;AACpF,QAAI,CAAC,sBAAsB;AACzB,UAAI,CAAC,kBAAkB;AACrB,eAAO;AAAA,MACT;AACA,qBAAe,KAAK,mCAAmC,OAAO;AAC9D,gBAAU,gBAAgB,CAAC;AAAA,IAC7B;AACA,WAAO,UAAU;AAAA,EACnB;AAAA,EAEA,MAAO,MAAM;AACX,UAAM,eAAe,KAAK;AAC1B,QAAI,cAAc;AAChB,aAAO,UAAU;AACjB,WAAK,mCAAmC;AACxC,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;AAEA,MAAM,EAAC,gBAAgB,UAAS,YAAY,KAAK;AAK1C,0BAAoB;AACzB,SAAQ,aAAc;AACxB;AAEA,aAAc,MAAM,KAAK;AACvB,QAAM,cAAc,eAAe,MAAM,KAAK;AAC9C,SAAO,eAAe,YAAY;AACpC;AAEA,aAAc,MAAM,KAAK,OAAO;AAE9B,MAAI,cAAc,eAAe,MAAM,UAAU,MAAgC;AACjF,iBAAgB,aAAY,OAAO;AACrC;AAEA,kBAAmB,MAAM,KAAK,OAAO;AACnC,QAAM,cAAc,eAAe,MAAM,IAA4B;AACrE,SAAO,YAAY,QAAS,aAAY,OAAO;AACjD;AAEA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
import * as domData from "./data";
|
|
3
|
+
import { default as options } from "../options";
|
|
4
|
+
import { arrayRemoveItem, arrayIndexOf } from "../array";
|
|
5
|
+
import { jQueryInstance } from "../jquery";
|
|
6
|
+
var domDataKey = domData.nextKey();
|
|
7
|
+
var cleanableNodeTypes = { 1: true, 8: true, 9: true };
|
|
8
|
+
var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
|
|
9
|
+
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
10
|
+
var allDisposeCallbacks = domData.get(node, domDataKey);
|
|
11
|
+
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
12
|
+
allDisposeCallbacks = [];
|
|
13
|
+
domData.set(node, domDataKey, allDisposeCallbacks);
|
|
14
|
+
}
|
|
15
|
+
return allDisposeCallbacks;
|
|
16
|
+
}
|
|
17
|
+
function destroyCallbacksCollection(node) {
|
|
18
|
+
domData.set(node, domDataKey, void 0);
|
|
19
|
+
}
|
|
20
|
+
function cleanSingleNode(node) {
|
|
21
|
+
var callbacks = getDisposeCallbacksCollection(node, false);
|
|
22
|
+
if (callbacks) {
|
|
23
|
+
callbacks = callbacks.slice(0);
|
|
24
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
25
|
+
callbacks[i](node);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
domData.clear(node);
|
|
29
|
+
for (let i = 0, j = otherNodeCleanerFunctions.length; i < j; ++i) {
|
|
30
|
+
otherNodeCleanerFunctions[i](node);
|
|
31
|
+
}
|
|
32
|
+
if (options.cleanExternalData) {
|
|
33
|
+
options.cleanExternalData(node);
|
|
34
|
+
}
|
|
35
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
36
|
+
cleanNodesInList(node.childNodes, true);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function cleanNodesInList(nodeList, onlyComments) {
|
|
40
|
+
const cleanedNodes = [];
|
|
41
|
+
let lastCleanedNode;
|
|
42
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
43
|
+
if (!onlyComments || nodeList[i].nodeType === 8) {
|
|
44
|
+
cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
|
|
45
|
+
if (nodeList[i] !== lastCleanedNode) {
|
|
46
|
+
while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function addDisposeCallback(node, callback) {
|
|
53
|
+
if (typeof callback !== "function") {
|
|
54
|
+
throw new Error("Callback must be a function");
|
|
55
|
+
}
|
|
56
|
+
getDisposeCallbacksCollection(node, true).push(callback);
|
|
57
|
+
}
|
|
58
|
+
export function removeDisposeCallback(node, callback) {
|
|
59
|
+
var callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
60
|
+
if (callbacksCollection) {
|
|
61
|
+
arrayRemoveItem(callbacksCollection, callback);
|
|
62
|
+
if (callbacksCollection.length === 0) {
|
|
63
|
+
destroyCallbacksCollection(node);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function cleanNode(node) {
|
|
68
|
+
if (cleanableNodeTypes[node.nodeType]) {
|
|
69
|
+
cleanSingleNode(node);
|
|
70
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
71
|
+
cleanNodesInList(node.getElementsByTagName("*"));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return node;
|
|
75
|
+
}
|
|
76
|
+
export function removeNode(node) {
|
|
77
|
+
cleanNode(node);
|
|
78
|
+
if (node.parentNode) {
|
|
79
|
+
node.parentNode.removeChild(node);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const otherNodeCleanerFunctions = [];
|
|
83
|
+
export function addCleaner(fn) {
|
|
84
|
+
otherNodeCleanerFunctions.push(fn);
|
|
85
|
+
}
|
|
86
|
+
export function removeCleaner(fn) {
|
|
87
|
+
const fnIndex = otherNodeCleanerFunctions.indexOf(fn);
|
|
88
|
+
if (fnIndex >= 0) {
|
|
89
|
+
otherNodeCleanerFunctions.splice(fnIndex, 1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function cleanjQueryData(node) {
|
|
93
|
+
var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
|
|
94
|
+
if (jQueryCleanNodeFn) {
|
|
95
|
+
jQueryCleanNodeFn([node]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/disposal.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// DOM node disposal\n//\n/* eslint no-cond-assign: 0 */\nimport * as domData from './data'\nimport { default as options } from '../options'\nimport {arrayRemoveItem, arrayIndexOf} from '../array'\nimport {jQueryInstance} from '../jquery'\n\nvar domDataKey = domData.nextKey()\n// Node types:\n// 1: Element\n// 8: Comment\n// 9: Document\nvar cleanableNodeTypes = { 1: true, 8: true, 9: true }\nvar cleanableNodeTypesWithDescendants = { 1: true, 9: true }\n\nfunction getDisposeCallbacksCollection (node, createIfNotFound) {\n var allDisposeCallbacks = domData.get(node, domDataKey)\n if ((allDisposeCallbacks === undefined) && createIfNotFound) {\n allDisposeCallbacks = []\n domData.set(node, domDataKey, allDisposeCallbacks)\n }\n return allDisposeCallbacks\n}\nfunction destroyCallbacksCollection (node) {\n domData.set(node, domDataKey, undefined)\n}\n\nfunction cleanSingleNode (node) {\n // Run all the dispose callbacks\n var callbacks = getDisposeCallbacksCollection(node, false)\n if (callbacks) {\n callbacks = callbacks.slice(0) // Clone, as the array may be modified during iteration (typically, callbacks will remove themselves)\n for (let i = 0; i < callbacks.length; i++) { callbacks[i](node) }\n }\n\n // Erase the DOM data\n domData.clear(node)\n\n // Perform cleanup needed by external libraries (currently only jQuery, but can be extended)\n for (let i = 0, j = otherNodeCleanerFunctions.length; i < j; ++i) {\n otherNodeCleanerFunctions[i](node)\n }\n\n if (options.cleanExternalData) {\n options.cleanExternalData(node)\n }\n\n // Clear any immediate-child comment nodes, as these wouldn't have been found by\n // node.getElementsByTagName('*') in cleanNode() (comment nodes aren't elements)\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\n cleanNodesInList(node.childNodes, true /* onlyComments */)\n }\n}\n\nfunction cleanNodesInList (nodeList, onlyComments) {\n const cleanedNodes = []\n let lastCleanedNode\n for (var i = 0; i < nodeList.length; i++) {\n if (!onlyComments || nodeList[i].nodeType === 8) {\n cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);\n if (nodeList[i] !== lastCleanedNode) {\n while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {}\n }\n }\n }\n}\n\n// Exports\nexport function addDisposeCallback (node, callback) {\n if (typeof callback !== 'function') { throw new Error('Callback must be a function') }\n getDisposeCallbacksCollection(node, true).push(callback)\n}\n\nexport function removeDisposeCallback (node, callback) {\n var callbacksCollection = getDisposeCallbacksCollection(node, false)\n if (callbacksCollection) {\n arrayRemoveItem(callbacksCollection, callback)\n if (callbacksCollection.length === 0) { destroyCallbacksCollection(node) }\n }\n}\n\nexport function cleanNode (node) {\n // First clean this node, where applicable\n if (cleanableNodeTypes[node.nodeType]) {\n cleanSingleNode(node)\n\n // ... then its descendants, where applicable\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\n cleanNodesInList(node.getElementsByTagName(\"*\"))\n }\n }\n return node\n}\n\nexport function removeNode (node) {\n cleanNode(node)\n if (node.parentNode) { node.parentNode.removeChild(node) }\n}\n\n// Expose supplemental node cleaning functions.\nexport const otherNodeCleanerFunctions = []\n\nexport function addCleaner (fn) {\n otherNodeCleanerFunctions.push(fn)\n}\n\nexport function removeCleaner (fn) {\n const fnIndex = otherNodeCleanerFunctions.indexOf(fn)\n if (fnIndex >= 0) { otherNodeCleanerFunctions.splice(fnIndex, 1) }\n}\n\n// Special support for jQuery here because it's so commonly used.\n// Many jQuery plugins (including jquery.tmpl) store data using jQuery's equivalent of domData\n// so notify it to tear down any resources associated with the node & descendants here.\nexport function cleanjQueryData (node) {\n var jQue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|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
import { objectForEach } from "../object";
|
|
3
|
+
import { jQueryInstance } from "../jquery";
|
|
4
|
+
import { ieVersion } from "../ie";
|
|
5
|
+
import { catchFunctionErrors } from "../error";
|
|
6
|
+
import { tagNameLower } from "./info";
|
|
7
|
+
import { addDisposeCallback } from "./disposal";
|
|
8
|
+
import options from "../options";
|
|
9
|
+
var knownEvents = {}, knownEventTypesByEventName = {};
|
|
10
|
+
var keyEventTypeName = options.global.navigator && /Firefox\/2/i.test(options.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
|
|
11
|
+
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
|
|
12
|
+
knownEvents["MouseEvents"] = [
|
|
13
|
+
"click",
|
|
14
|
+
"dblclick",
|
|
15
|
+
"mousedown",
|
|
16
|
+
"mouseup",
|
|
17
|
+
"mousemove",
|
|
18
|
+
"mouseover",
|
|
19
|
+
"mouseout",
|
|
20
|
+
"mouseenter",
|
|
21
|
+
"mouseleave"
|
|
22
|
+
];
|
|
23
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
24
|
+
if (knownEventsForType.length) {
|
|
25
|
+
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
26
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
function isClickOnCheckableElement(element, eventType) {
|
|
31
|
+
if (tagNameLower(element) !== "input" || !element.type)
|
|
32
|
+
return false;
|
|
33
|
+
if (eventType.toLowerCase() != "click")
|
|
34
|
+
return false;
|
|
35
|
+
var inputType = element.type;
|
|
36
|
+
return inputType == "checkbox" || inputType == "radio";
|
|
37
|
+
}
|
|
38
|
+
var eventsThatMustBeRegisteredUsingAttachEvent = { "propertychange": true };
|
|
39
|
+
let jQueryEventAttachName;
|
|
40
|
+
export function registerEventHandler(element, eventType, handler, eventOptions = false) {
|
|
41
|
+
const wrappedHandler = catchFunctionErrors(handler);
|
|
42
|
+
const mustUseAttachEvent = ieVersion && eventsThatMustBeRegisteredUsingAttachEvent[eventType];
|
|
43
|
+
const mustUseNative = Boolean(eventOptions);
|
|
44
|
+
if (!options.useOnlyNativeEvents && !mustUseAttachEvent && !mustUseNative && jQueryInstance) {
|
|
45
|
+
if (!jQueryEventAttachName) {
|
|
46
|
+
jQueryEventAttachName = typeof jQueryInstance(element).on === "function" ? "on" : "bind";
|
|
47
|
+
}
|
|
48
|
+
jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);
|
|
49
|
+
} else if (!mustUseAttachEvent && typeof element.addEventListener === "function") {
|
|
50
|
+
element.addEventListener(eventType, wrappedHandler, eventOptions);
|
|
51
|
+
} else if (typeof element.attachEvent !== "undefined") {
|
|
52
|
+
const attachEventHandler = function(event) {
|
|
53
|
+
wrappedHandler.call(element, event);
|
|
54
|
+
};
|
|
55
|
+
const attachEventName = "on" + eventType;
|
|
56
|
+
element.attachEvent(attachEventName, attachEventHandler);
|
|
57
|
+
addDisposeCallback(element, function() {
|
|
58
|
+
element.detachEvent(attachEventName, attachEventHandler);
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
throw new Error("Browser doesn't support addEventListener or attachEvent");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function triggerEvent(element, eventType) {
|
|
65
|
+
if (!(element && element.nodeType)) {
|
|
66
|
+
throw new Error("element must be a DOM node when calling triggerEvent");
|
|
67
|
+
}
|
|
68
|
+
var useClickWorkaround = isClickOnCheckableElement(element, eventType);
|
|
69
|
+
if (!options.useOnlyNativeEvents && jQueryInstance && !useClickWorkaround) {
|
|
70
|
+
jQueryInstance(element).trigger(eventType);
|
|
71
|
+
} else if (typeof document.createEvent === "function") {
|
|
72
|
+
if (typeof element.dispatchEvent === "function") {
|
|
73
|
+
var eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
|
|
74
|
+
var event = document.createEvent(eventCategory);
|
|
75
|
+
event.initEvent(eventType, true, true, options.global, 0, 0, 0, 0, 0, false, false, false, false, 0, element);
|
|
76
|
+
element.dispatchEvent(event);
|
|
77
|
+
} else {
|
|
78
|
+
throw new Error("The supplied element doesn't support dispatchEvent");
|
|
79
|
+
}
|
|
80
|
+
} else if (useClickWorkaround && element.click) {
|
|
81
|
+
element.click();
|
|
82
|
+
} else if (typeof element.fireEvent !== "undefined") {
|
|
83
|
+
element.fireEvent("on" + eventType);
|
|
84
|
+
} else {
|
|
85
|
+
throw new Error("Browser doesn't support triggering events");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/event.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// DOM Events\n//\n\nimport { objectForEach } from '../object'\nimport { jQueryInstance } from '../jquery'\nimport { ieVersion } from '../ie'\nimport { catchFunctionErrors } from '../error'\n\nimport { tagNameLower } from './info'\nimport { addDisposeCallback } from './disposal'\nimport options from '../options'\n\n// Represent the known event types in a compact way, then at runtime transform it into a hash with event name as key (for fast lookup)\nvar knownEvents = {},\n knownEventTypesByEventName = {}\n\nvar keyEventTypeName = (options.global.navigator && /Firefox\\/2/i.test(options.global.navigator.userAgent)) ? 'KeyboardEvent' : 'UIEvents'\n\nknownEvents[keyEventTypeName] = ['keyup', 'keydown', 'keypress']\n\nknownEvents['MouseEvents'] = [\n 'click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', 'mouseover',\n 'mouseout', 'mouseenter', 'mouseleave']\n\nobjectForEach(knownEvents, function (eventType, knownEventsForType) {\n if (knownEventsForType.length) {\n for (var i = 0, j = knownEventsForType.length; i < j; i++) { knownEventTypesByEventName[knownEventsForType[i]] = eventType }\n }\n})\n\nfunction isClickOnCheckableElement (element, eventType) {\n if ((tagNameLower(element) !== 'input') || !element.type) return false\n if (eventType.toLowerCase() != 'click') return false\n var inputType = element.type\n return (inputType == 'checkbox') || (inputType == 'radio')\n}\n\n// Workaround for an IE9 issue - https://github.com/SteveSanderson/knockout/issues/406\nvar eventsThatMustBeRegisteredUsingAttachEvent = { 'propertychange': true }\nlet jQueryEventAttachName\n\nexport function registerEventHandler (element, eventType, handler, eventOptions = false) {\n const wrappedHandler = catchFunctionErrors(handler)\n const mustUseAttachEvent = ieVersion && eventsThatMustBeRegisteredUsingAttachEvent[eventType]\n const mustUseNative = Boolean(eventOptions)\n\n if (!options.useOnlyNativeEvents && !mustUseAttachEvent && !mustUseNative && jQueryInstance) {\n if (!jQueryEventAttachName) {\n jQueryEventAttachName = (typeof jQueryInstance(element).on === 'function') ? 'on' : 'bind'\n }\n jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler)\n } else if (!mustUseAttachEvent && typeof element.addEventListener === 'function') {\n element.addEventListener(eventType, wrappedHandler, eventOptions)\n } else if (typeof element.attachEvent !== 'undefined') {\n const attachEventHandler = function (event) { wrappedHandler.call(element, event) }\n const attachEventName = 'on' + eventType\n element.attachEvent(attachEventName, attachEventHandler)\n\n // IE does not dispose attachEvent handlers automatically (unlike with addEventListener)\n // so to avoid leaks, we have to remove them manually. See bug #856\n addDisposeCallback(element, function () {\n element.detachEvent(attachEventName, attachEventHandler)\n })\n } else {\n throw new Error(\"Browser doesn't support addEventListener or attachEvent\")\n }\n}\n\nexport function triggerEvent (element, eventType) {\n if (!(element && element.nodeType)) { throw new Error('element must be a DOM node when calling triggerEvent') }\n\n // For click events on checkboxes and radio buttons, jQuery toggles the element checked state *after* the\n // event handler runs instead of *before*. (This was fixed in 1.9 for checkboxes but not for radio buttons.)\n // IE doesn't change the checked state when you trigger the click event using \"fireEvent\".\n // In both cases, we'll use the click method instead.\n var useClickWorkaround = isClickOnCheckableElement(element, eventType)\n\n if (!options.useOnlyNativeEvents && jQueryInstance && !useClickWorkaround) {\n jQueryInstance(element).trigger(eventType)\n } else if (typeof document.createEvent === 'function') {\n if (typeof element.dispatchEvent === 'function') {\n var eventCategory = knownEventTypesByEventName[eventType] || 'HTMLEvents'\n var event = document.createEvent(eventCategory)\n event.initEvent(eventType, true, true, options.global, 0, 0, 0, 0, 0, false, false, false, false, 0, element)\n element.dispatchEvent(event)\n } else { throw new Error(\"The supplied element doesn't support dispatchEvent\") }\n } else if (useClickWorkaround && element.click) {\n element.click()\n } else if (typeof element.fireEvent !== 'undefined') {\n element.fireEvent('on' + eventType)\n } else {\n throw new Error(\"Browser doesn't support triggering events\")\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA,IAAI,cAAc,CAAC,GACjB,6BAA6B,CAAC;AAEhC,IAAI,mBAAoB,QAAQ,OAAO,aAAa,cAAc,KAAK,QAAQ,OAAO,UAAU,SAAS,IAAK,kBAAkB;AAEhI,YAAY,oBAAoB,CAAC,SAAS,WAAW,UAAU;AAE/D,YAAY,iBAAiB;AAAA,EAC3B;AAAA,EAAS;AAAA,EAAY;AAAA,EAAa;AAAA,EAAW;AAAA,EAAa;AAAA,EAC1D;AAAA,EAAY;AAAA,EAAc;AAAY;AAExC,cAAc,aAAa,SAAU,WAAW,oBAAoB;AAClE,MAAI,mBAAmB,QAAQ;AAC7B,aAAS,IAAI,GAAG,IAAI,mBAAmB,QAAQ,IAAI,GAAG,KAAK;AAAE,iCAA2B,mBAAmB,MAAM;AAAA,IAAU;AAAA,EAC7H;AACF,CAAC;AAED,mCAAoC,SAAS,WAAW;AACtD,MAAK,aAAa,OAAO,MAAM,WAAY,CAAC,QAAQ;AAAM,WAAO;AACjE,MAAI,UAAU,YAAY,KAAK;AAAS,WAAO;AAC/C,MAAI,YAAY,QAAQ;AACxB,SAAQ,aAAa,cAAgB,aAAa;AACpD;AAGA,IAAI,6CAA6C,EAAE,kBAAkB,KAAK;AAC1E,IAAI;AAEG,qCAA+B,SAAS,WAAW,SAAS,e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