@tko/provider.multi 4.0.0-beta1.0 → 4.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/dist/MultiProvider.js +13 -12
- package/dist/MultiProvider.js.map +2 -2
- package/dist/index.cjs +388 -287
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +2 -2
- package/package.json +3 -4
- package/LICENSE +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
// @tko/provider.multi 🥊 4.0.0
|
|
1
|
+
// @tko/provider.multi 🥊 4.0.0 CommonJS
|
|
2
|
+
"use strict";
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
8
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,19 +21,51 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
21
|
return to;
|
|
17
22
|
};
|
|
18
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __await = function(promise, isYieldStar) {
|
|
25
|
+
this[0] = promise;
|
|
26
|
+
this[1] = isYieldStar;
|
|
27
|
+
};
|
|
28
|
+
var __yieldStar = (value) => {
|
|
29
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
30
|
+
if (obj == null) {
|
|
31
|
+
obj = value[__knownSymbol("iterator")]();
|
|
32
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
33
|
+
} else {
|
|
34
|
+
obj = obj.call(value);
|
|
35
|
+
method = (k) => it[k] = (v) => {
|
|
36
|
+
if (isAwait) {
|
|
37
|
+
isAwait = false;
|
|
38
|
+
if (k === "throw") throw v;
|
|
39
|
+
return v;
|
|
40
|
+
}
|
|
41
|
+
isAwait = true;
|
|
42
|
+
return {
|
|
43
|
+
done: false,
|
|
44
|
+
value: new __await(new Promise((resolve) => {
|
|
45
|
+
var x = obj[k](v);
|
|
46
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
47
|
+
resolve(x);
|
|
48
|
+
}), 1)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
53
|
+
throw x;
|
|
54
|
+
}, "return" in obj && method("return"), it;
|
|
55
|
+
};
|
|
19
56
|
|
|
20
57
|
// index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
58
|
+
var index_exports = {};
|
|
59
|
+
__export(index_exports, {
|
|
23
60
|
MultiProvider: () => MultiProvider
|
|
24
61
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
62
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
63
|
|
|
27
64
|
// ../utils/dist/array.js
|
|
28
65
|
var { isArray } = Array;
|
|
29
|
-
function arrayForEach(array, action,
|
|
66
|
+
function arrayForEach(array, action, actionOwner) {
|
|
30
67
|
if (arguments.length > 2) {
|
|
31
|
-
action = action.bind(
|
|
68
|
+
action = action.bind(actionOwner);
|
|
32
69
|
}
|
|
33
70
|
for (let i = 0, j = array.length; i < j; ++i) {
|
|
34
71
|
action(array[i], i, array);
|
|
@@ -38,7 +75,7 @@ function arrayIndexOf(array, item) {
|
|
|
38
75
|
return (isArray(array) ? array : [...array]).indexOf(item);
|
|
39
76
|
}
|
|
40
77
|
function arrayRemoveItem(array, itemToRemove) {
|
|
41
|
-
|
|
78
|
+
const index = arrayIndexOf(array, itemToRemove);
|
|
42
79
|
if (index > 0) {
|
|
43
80
|
array.splice(index, 1);
|
|
44
81
|
} else if (index === 0) {
|
|
@@ -47,7 +84,7 @@ function arrayRemoveItem(array, itemToRemove) {
|
|
|
47
84
|
}
|
|
48
85
|
function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
49
86
|
if (left.length && right.length) {
|
|
50
|
-
|
|
87
|
+
let failedCompares, l, r, leftItem, rightItem;
|
|
51
88
|
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
52
89
|
for (r = 0; rightItem = right[r]; ++r) {
|
|
53
90
|
if (leftItem.value === rightItem.value) {
|
|
@@ -75,10 +112,10 @@ function compareArrays(oldArray, newArray, options2) {
|
|
|
75
112
|
}
|
|
76
113
|
}
|
|
77
114
|
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
|
|
78
|
-
|
|
115
|
+
let myMin = Math.min, myMax = Math.max, editDistanceMatrix = new Array(), smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
|
|
79
116
|
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
80
117
|
lastRow = thisRow;
|
|
81
|
-
editDistanceMatrix.push(thisRow =
|
|
118
|
+
editDistanceMatrix.push(thisRow = new Array());
|
|
82
119
|
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
83
120
|
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
84
121
|
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
@@ -89,35 +126,38 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
89
126
|
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
90
127
|
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
91
128
|
} else {
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
const northDistance = lastRow[bigIndex] || maxDistance;
|
|
130
|
+
const westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
94
131
|
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
95
132
|
}
|
|
96
133
|
}
|
|
97
134
|
}
|
|
98
|
-
|
|
135
|
+
let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
|
|
99
136
|
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
100
137
|
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
101
138
|
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
102
|
-
notInSml.push(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
139
|
+
notInSml.push(
|
|
140
|
+
editScript[editScript.length] = {
|
|
141
|
+
// added
|
|
142
|
+
status: statusNotInSml,
|
|
143
|
+
value: bigArray[--bigIndex],
|
|
144
|
+
index: bigIndex
|
|
145
|
+
}
|
|
146
|
+
);
|
|
107
147
|
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
108
|
-
notInBig.push(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
notInBig.push(
|
|
149
|
+
editScript[editScript.length] = {
|
|
150
|
+
// deleted
|
|
151
|
+
status: statusNotInBig,
|
|
152
|
+
value: smlArray[--smlIndex],
|
|
153
|
+
index: smlIndex
|
|
154
|
+
}
|
|
155
|
+
);
|
|
113
156
|
} else {
|
|
114
157
|
--bigIndex;
|
|
115
158
|
--smlIndex;
|
|
116
|
-
if (!options2.sparse) {
|
|
117
|
-
editScript.push({
|
|
118
|
-
"status": "retained",
|
|
119
|
-
"value": bigArray[bigIndex]
|
|
120
|
-
});
|
|
159
|
+
if (!(options2 == null ? void 0 : options2.sparse)) {
|
|
160
|
+
editScript.push({ status: "retained", value: bigArray[bigIndex] });
|
|
121
161
|
}
|
|
122
162
|
}
|
|
123
163
|
}
|
|
@@ -126,40 +166,79 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
126
166
|
}
|
|
127
167
|
|
|
128
168
|
// ../utils/dist/options.js
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
var Options = class {
|
|
170
|
+
constructor() {
|
|
171
|
+
this.bindingStringPreparsers = [];
|
|
172
|
+
this.knockoutInstance = null;
|
|
173
|
+
this.deferUpdates = false;
|
|
174
|
+
this.useOnlyNativeEvents = true;
|
|
175
|
+
this.useTemplateTag = true;
|
|
176
|
+
this.protoProperty = "__ko_proto__";
|
|
177
|
+
this.defaultBindingAttribute = "data-bind";
|
|
178
|
+
this.allowVirtualElements = true;
|
|
179
|
+
this.bindingGlobals = /* @__PURE__ */ Object.create(null);
|
|
180
|
+
this.createChildContextWithAs = false;
|
|
181
|
+
this.disableJQueryUsage = false;
|
|
182
|
+
this.Promise = globalThis.Promise;
|
|
183
|
+
this.taskScheduler = null;
|
|
184
|
+
this.debug = false;
|
|
185
|
+
this.templateSizeLimit = 4096;
|
|
186
|
+
this.allowScriptTagsInTemplates = false;
|
|
187
|
+
this._sanitizeWarningLogged = false;
|
|
188
|
+
this.global = globalThis;
|
|
189
|
+
this.document = globalThis.document;
|
|
190
|
+
this.filters = {};
|
|
191
|
+
this.includeDestroyed = false;
|
|
192
|
+
this.foreachHidesDestroyed = false;
|
|
193
|
+
}
|
|
194
|
+
get jQuery() {
|
|
195
|
+
var _a;
|
|
196
|
+
if (this.disableJQueryUsage) return;
|
|
197
|
+
return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Set jQuery manuall to be used by TKO.
|
|
201
|
+
* @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
|
|
202
|
+
*/
|
|
203
|
+
set jQuery(jQuery) {
|
|
204
|
+
if (!jQuery) {
|
|
205
|
+
this.disableJQueryUsage = true;
|
|
206
|
+
this._jQuery = void 0;
|
|
207
|
+
} else {
|
|
208
|
+
this._jQuery = jQuery;
|
|
209
|
+
this.disableJQueryUsage = false;
|
|
210
|
+
}
|
|
156
211
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Sanitize HTML templates before parsing them. Default is a no-op.
|
|
214
|
+
* Please configure something like DOMPurify or validator.js for your environment.
|
|
215
|
+
* @param html HTML string to be sanitized
|
|
216
|
+
* @returns Sanitized HTML string
|
|
217
|
+
*/
|
|
218
|
+
sanitizeHtmlTemplate(html) {
|
|
219
|
+
if (!this._sanitizeWarningLogged) {
|
|
220
|
+
console.warn(
|
|
221
|
+
"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
|
|
222
|
+
);
|
|
223
|
+
this._sanitizeWarningLogged = true;
|
|
224
|
+
}
|
|
225
|
+
return html;
|
|
161
226
|
}
|
|
162
|
-
|
|
227
|
+
onError(e, throws = true) {
|
|
228
|
+
if (throws) throw e;
|
|
229
|
+
return e;
|
|
230
|
+
}
|
|
231
|
+
set(name, value) {
|
|
232
|
+
this[name] = value;
|
|
233
|
+
}
|
|
234
|
+
// Overload getBindingHandler to have a custom lookup function.
|
|
235
|
+
getBindingHandler(key) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
cleanExternalData(node, callback) {
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var options = new Options();
|
|
163
242
|
var options_default = options;
|
|
164
243
|
|
|
165
244
|
// ../utils/dist/error.js
|
|
@@ -186,7 +265,7 @@ function safeSetTimeout(handler, timeout) {
|
|
|
186
265
|
|
|
187
266
|
// ../utils/dist/async.js
|
|
188
267
|
function throttle(callback, timeout) {
|
|
189
|
-
|
|
268
|
+
let timeoutInstance;
|
|
190
269
|
return function(...args) {
|
|
191
270
|
if (!timeoutInstance) {
|
|
192
271
|
timeoutInstance = safeSetTimeout(function() {
|
|
@@ -197,33 +276,22 @@ function throttle(callback, timeout) {
|
|
|
197
276
|
};
|
|
198
277
|
}
|
|
199
278
|
function debounce(callback, timeout) {
|
|
200
|
-
|
|
279
|
+
let timeoutInstance;
|
|
201
280
|
return function(...args) {
|
|
202
281
|
clearTimeout(timeoutInstance);
|
|
203
282
|
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
204
283
|
};
|
|
205
284
|
}
|
|
206
285
|
|
|
207
|
-
// ../utils/dist/ie.js
|
|
208
|
-
var ieVersion = options_default.document && function() {
|
|
209
|
-
var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
|
|
210
|
-
while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
|
|
211
|
-
}
|
|
212
|
-
if (!version) {
|
|
213
|
-
const userAgent = window.navigator.userAgent;
|
|
214
|
-
return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
|
|
215
|
-
}
|
|
216
|
-
return version > 4 ? version : void 0;
|
|
217
|
-
}();
|
|
218
|
-
|
|
219
286
|
// ../utils/dist/object.js
|
|
220
287
|
function hasOwnProperty(obj, propName) {
|
|
221
288
|
return Object.prototype.hasOwnProperty.call(obj, propName);
|
|
222
289
|
}
|
|
223
290
|
function extend(target, source) {
|
|
224
291
|
if (source) {
|
|
225
|
-
for (
|
|
292
|
+
for (const prop of Object.keys(source)) {
|
|
226
293
|
if (hasOwnProperty(source, prop)) {
|
|
294
|
+
;
|
|
227
295
|
target[prop] = source[prop];
|
|
228
296
|
}
|
|
229
297
|
}
|
|
@@ -231,7 +299,7 @@ function extend(target, source) {
|
|
|
231
299
|
return target;
|
|
232
300
|
}
|
|
233
301
|
function objectForEach(obj, action) {
|
|
234
|
-
for (
|
|
302
|
+
for (const prop in obj) {
|
|
235
303
|
if (hasOwnProperty(obj, prop)) {
|
|
236
304
|
action(prop, obj[prop]);
|
|
237
305
|
}
|
|
@@ -244,8 +312,8 @@ function objectMap(source, mapping, thisArg) {
|
|
|
244
312
|
if (arguments.length > 2) {
|
|
245
313
|
mapping = mapping.bind(thisArg);
|
|
246
314
|
}
|
|
247
|
-
|
|
248
|
-
for (
|
|
315
|
+
const target = {};
|
|
316
|
+
for (const prop in source) {
|
|
249
317
|
if (hasOwnProperty(source, prop)) {
|
|
250
318
|
target[prop] = mapping(source[prop], prop, source);
|
|
251
319
|
}
|
|
@@ -270,78 +338,75 @@ function overwriteLengthPropertyIfSupported(fn, descriptor) {
|
|
|
270
338
|
}
|
|
271
339
|
}
|
|
272
340
|
|
|
273
|
-
// ../utils/dist/jquery.js
|
|
274
|
-
var jQueryInstance = options_default.global && options_default.global.jQuery;
|
|
275
|
-
|
|
276
341
|
// ../utils/dist/dom/info.js
|
|
277
342
|
function tagNameLower(element) {
|
|
278
343
|
return element && element.tagName && element.tagName.toLowerCase();
|
|
279
344
|
}
|
|
280
345
|
|
|
346
|
+
// ../utils/dist/dom/event.js
|
|
347
|
+
var knownEvents = {};
|
|
348
|
+
var knownEventTypesByEventName = {};
|
|
349
|
+
knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
|
|
350
|
+
knownEvents["MouseEvents"] = [
|
|
351
|
+
"click",
|
|
352
|
+
"dblclick",
|
|
353
|
+
"mousedown",
|
|
354
|
+
"mouseup",
|
|
355
|
+
"mousemove",
|
|
356
|
+
"mouseover",
|
|
357
|
+
"mouseout",
|
|
358
|
+
"mouseenter",
|
|
359
|
+
"mouseleave"
|
|
360
|
+
];
|
|
361
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
362
|
+
if (knownEventsForType.length) {
|
|
363
|
+
for (let i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
364
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
281
369
|
// ../utils/dist/dom/data.js
|
|
282
|
-
var datastoreTime = new Date().getTime();
|
|
370
|
+
var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
|
|
283
371
|
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
284
|
-
var dataStoreSymbol = Symbol("Knockout data");
|
|
285
|
-
var dataStore;
|
|
372
|
+
var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
|
|
286
373
|
var uniqueId = 0;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
clear(node) {
|
|
296
|
-
if (node[dataStoreSymbol]) {
|
|
297
|
-
delete node[dataStoreSymbol];
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
var IE = {
|
|
304
|
-
getDataforNode(node, createIfNotFound) {
|
|
305
|
-
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
306
|
-
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
|
|
307
|
-
if (!hasExistingDataStore) {
|
|
308
|
-
if (!createIfNotFound) {
|
|
309
|
-
return void 0;
|
|
310
|
-
}
|
|
311
|
-
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
|
312
|
-
dataStore[dataStoreKey] = {};
|
|
313
|
-
}
|
|
314
|
-
return dataStore[dataStoreKey];
|
|
315
|
-
},
|
|
316
|
-
clear(node) {
|
|
317
|
-
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
318
|
-
if (dataStoreKey) {
|
|
319
|
-
delete dataStore[dataStoreKey];
|
|
320
|
-
node[dataStoreKeyExpandoPropertyName] = null;
|
|
321
|
-
return true;
|
|
322
|
-
}
|
|
323
|
-
return false;
|
|
374
|
+
function isSafeKey(key) {
|
|
375
|
+
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
376
|
+
}
|
|
377
|
+
function getDataForNode(node, createIfNotFound) {
|
|
378
|
+
let dataForNode = node[dataStoreSymbol];
|
|
379
|
+
if (!dataForNode && createIfNotFound) {
|
|
380
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
324
381
|
}
|
|
325
|
-
|
|
326
|
-
|
|
382
|
+
return dataForNode;
|
|
383
|
+
}
|
|
327
384
|
function nextKey() {
|
|
328
385
|
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
329
386
|
}
|
|
330
387
|
function get(node, key) {
|
|
388
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
331
389
|
const dataForNode = getDataForNode(node, false);
|
|
332
390
|
return dataForNode && dataForNode[key];
|
|
333
391
|
}
|
|
334
392
|
function set(node, key, value) {
|
|
335
|
-
|
|
336
|
-
|
|
393
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
394
|
+
const dataForNode = getDataForNode(
|
|
395
|
+
node,
|
|
396
|
+
value !== void 0
|
|
397
|
+
/* createIfNotFound */
|
|
398
|
+
);
|
|
399
|
+
if (dataForNode) {
|
|
400
|
+
dataForNode[key] = value;
|
|
401
|
+
}
|
|
337
402
|
}
|
|
338
403
|
|
|
339
404
|
// ../utils/dist/dom/disposal.js
|
|
340
405
|
var domDataKey = nextKey();
|
|
341
406
|
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
342
|
-
|
|
407
|
+
let allDisposeCallbacks = get(node, domDataKey);
|
|
343
408
|
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
344
|
-
allDisposeCallbacks =
|
|
409
|
+
allDisposeCallbacks = new Array();
|
|
345
410
|
set(node, domDataKey, allDisposeCallbacks);
|
|
346
411
|
}
|
|
347
412
|
return allDisposeCallbacks;
|
|
@@ -356,7 +421,7 @@ function addDisposeCallback(node, callback) {
|
|
|
356
421
|
getDisposeCallbacksCollection(node, true).push(callback);
|
|
357
422
|
}
|
|
358
423
|
function removeDisposeCallback(node, callback) {
|
|
359
|
-
|
|
424
|
+
const callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
360
425
|
if (callbacksCollection) {
|
|
361
426
|
arrayRemoveItem(callbacksCollection, callback);
|
|
362
427
|
if (callbacksCollection.length === 0) {
|
|
@@ -364,58 +429,34 @@ function removeDisposeCallback(node, callback) {
|
|
|
364
429
|
}
|
|
365
430
|
}
|
|
366
431
|
}
|
|
367
|
-
var otherNodeCleanerFunctions =
|
|
432
|
+
var otherNodeCleanerFunctions = new Array();
|
|
368
433
|
function cleanjQueryData(node) {
|
|
369
|
-
|
|
434
|
+
const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
|
|
370
435
|
if (jQueryCleanNodeFn) {
|
|
371
436
|
jQueryCleanNodeFn([node]);
|
|
372
437
|
}
|
|
373
438
|
}
|
|
374
439
|
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
375
440
|
|
|
376
|
-
// ../utils/dist/dom/event.js
|
|
377
|
-
var knownEvents = {};
|
|
378
|
-
var knownEventTypesByEventName = {};
|
|
379
|
-
var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
|
|
380
|
-
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
|
|
381
|
-
knownEvents["MouseEvents"] = [
|
|
382
|
-
"click",
|
|
383
|
-
"dblclick",
|
|
384
|
-
"mousedown",
|
|
385
|
-
"mouseup",
|
|
386
|
-
"mousemove",
|
|
387
|
-
"mouseover",
|
|
388
|
-
"mouseout",
|
|
389
|
-
"mouseenter",
|
|
390
|
-
"mouseleave"
|
|
391
|
-
];
|
|
392
|
-
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
393
|
-
if (knownEventsForType.length) {
|
|
394
|
-
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
395
|
-
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// ../utils/dist/dom/virtualElements.js
|
|
401
|
-
var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
|
|
402
|
-
|
|
403
441
|
// ../utils/dist/dom/html.js
|
|
404
|
-
var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
|
|
442
|
+
var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
|
|
405
443
|
|
|
406
444
|
// ../utils/dist/dom/selectExtensions.js
|
|
407
|
-
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
445
|
+
var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
408
446
|
var selectExtensions = {
|
|
409
447
|
optionValueDomDataKey: nextKey(),
|
|
410
448
|
readValue: function(element) {
|
|
411
449
|
switch (tagNameLower(element)) {
|
|
412
|
-
case "option":
|
|
450
|
+
case "option": {
|
|
413
451
|
if (element[hasDomDataExpandoProperty] === true) {
|
|
414
452
|
return get(element, selectExtensions.optionValueDomDataKey);
|
|
415
453
|
}
|
|
416
454
|
return element.value;
|
|
417
|
-
|
|
418
|
-
|
|
455
|
+
}
|
|
456
|
+
case "select": {
|
|
457
|
+
const selectElement = element;
|
|
458
|
+
return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
|
|
459
|
+
}
|
|
419
460
|
default:
|
|
420
461
|
return element.value;
|
|
421
462
|
}
|
|
@@ -428,36 +469,42 @@ var selectExtensions = {
|
|
|
428
469
|
if (hasDomDataExpandoProperty in element) {
|
|
429
470
|
delete element[hasDomDataExpandoProperty];
|
|
430
471
|
}
|
|
472
|
+
;
|
|
431
473
|
element.value = value;
|
|
432
474
|
} else {
|
|
475
|
+
const el = element;
|
|
433
476
|
set(element, selectExtensions.optionValueDomDataKey, value);
|
|
434
|
-
|
|
435
|
-
|
|
477
|
+
el[hasDomDataExpandoProperty] = true;
|
|
478
|
+
el.value = typeof value === "number" ? value : "";
|
|
436
479
|
}
|
|
437
480
|
break;
|
|
438
481
|
case "select":
|
|
439
|
-
|
|
440
|
-
value
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
482
|
+
{
|
|
483
|
+
if (value === "" || value === null) {
|
|
484
|
+
value = void 0;
|
|
485
|
+
}
|
|
486
|
+
let selection = -1;
|
|
487
|
+
const selectElement = element;
|
|
488
|
+
for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
|
|
489
|
+
optionValue = selectExtensions.readValue(selectElement.options[i]);
|
|
490
|
+
const strictEqual = optionValue === value;
|
|
491
|
+
const blankEqual = optionValue === "" && value === void 0;
|
|
492
|
+
const numericEqual = typeof value === "number" && Number(optionValue) === value;
|
|
493
|
+
if (strictEqual || blankEqual || numericEqual) {
|
|
494
|
+
selection = i;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
|
|
499
|
+
selectElement.selectedIndex = selection;
|
|
451
500
|
}
|
|
452
|
-
}
|
|
453
|
-
if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
|
|
454
|
-
element.selectedIndex = selection;
|
|
455
501
|
}
|
|
456
502
|
break;
|
|
457
503
|
default:
|
|
458
504
|
if (value === null || value === void 0) {
|
|
459
505
|
value = "";
|
|
460
506
|
}
|
|
507
|
+
;
|
|
461
508
|
element.value = value;
|
|
462
509
|
break;
|
|
463
510
|
}
|
|
@@ -472,30 +519,19 @@ __export(tasks_exports, {
|
|
|
472
519
|
runEarly: () => processTasks,
|
|
473
520
|
schedule: () => schedule
|
|
474
521
|
});
|
|
475
|
-
var taskQueue =
|
|
522
|
+
var taskQueue = new Array();
|
|
476
523
|
var taskQueueLength = 0;
|
|
477
524
|
var nextHandle = 1;
|
|
478
525
|
var nextIndexToProcess = 0;
|
|
479
526
|
var w = options_default.global;
|
|
480
527
|
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
481
|
-
options_default.taskScheduler = function(callback) {
|
|
482
|
-
|
|
528
|
+
options_default.taskScheduler = (function(callback) {
|
|
529
|
+
const div = w.document.createElement("div");
|
|
483
530
|
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
484
531
|
return function() {
|
|
485
532
|
div.classList.toggle("foo");
|
|
486
533
|
};
|
|
487
|
-
}(scheduledProcess);
|
|
488
|
-
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
|
|
489
|
-
options_default.taskScheduler = function(callback) {
|
|
490
|
-
var script = document.createElement("script");
|
|
491
|
-
script.onreadystatechange = function() {
|
|
492
|
-
script.onreadystatechange = null;
|
|
493
|
-
document.documentElement.removeChild(script);
|
|
494
|
-
script = null;
|
|
495
|
-
callback();
|
|
496
|
-
};
|
|
497
|
-
document.documentElement.appendChild(script);
|
|
498
|
-
};
|
|
534
|
+
})(scheduledProcess);
|
|
499
535
|
} else {
|
|
500
536
|
options_default.taskScheduler = function(callback) {
|
|
501
537
|
setTimeout(callback, 0);
|
|
@@ -503,8 +539,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
|
503
539
|
}
|
|
504
540
|
function processTasks() {
|
|
505
541
|
if (taskQueueLength) {
|
|
506
|
-
|
|
507
|
-
for (
|
|
542
|
+
let mark = taskQueueLength, countMarks = 0;
|
|
543
|
+
for (let task; nextIndexToProcess < taskQueueLength; ) {
|
|
508
544
|
if (task = taskQueue[nextIndexToProcess++]) {
|
|
509
545
|
if (nextIndexToProcess > mark) {
|
|
510
546
|
if (++countMarks >= 5e3) {
|
|
@@ -538,13 +574,13 @@ function schedule(func) {
|
|
|
538
574
|
return nextHandle++;
|
|
539
575
|
}
|
|
540
576
|
function cancel(handle) {
|
|
541
|
-
|
|
577
|
+
const index = handle - (nextHandle - taskQueueLength);
|
|
542
578
|
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
543
579
|
taskQueue[index] = null;
|
|
544
580
|
}
|
|
545
581
|
}
|
|
546
582
|
function resetForTesting() {
|
|
547
|
-
|
|
583
|
+
const length = taskQueueLength - nextIndexToProcess;
|
|
548
584
|
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
549
585
|
return length;
|
|
550
586
|
}
|
|
@@ -563,13 +599,13 @@ __export(dependencyDetection_exports, {
|
|
|
563
599
|
});
|
|
564
600
|
|
|
565
601
|
// ../observable/dist/subscribableSymbol.js
|
|
566
|
-
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
|
|
602
|
+
var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
|
|
567
603
|
function isSubscribable(instance) {
|
|
568
604
|
return instance && instance[SUBSCRIBABLE_SYM] || false;
|
|
569
605
|
}
|
|
570
606
|
|
|
571
607
|
// ../observable/dist/dependencyDetection.js
|
|
572
|
-
var outerFrames =
|
|
608
|
+
var outerFrames = new Array();
|
|
573
609
|
var currentFrame;
|
|
574
610
|
var lastId = 0;
|
|
575
611
|
function getId() {
|
|
@@ -587,7 +623,11 @@ function registerDependency(subscribable2) {
|
|
|
587
623
|
if (!isSubscribable(subscribable2)) {
|
|
588
624
|
throw new Error("Only subscribable things can act as dependencies");
|
|
589
625
|
}
|
|
590
|
-
currentFrame.callback.call(
|
|
626
|
+
currentFrame.callback.call(
|
|
627
|
+
currentFrame.callbackTarget,
|
|
628
|
+
subscribable2,
|
|
629
|
+
subscribable2._id || (subscribable2._id = getId())
|
|
630
|
+
);
|
|
591
631
|
}
|
|
592
632
|
}
|
|
593
633
|
function ignore(callback, callbackTarget, callbackArgs) {
|
|
@@ -602,16 +642,19 @@ function getDependenciesCount() {
|
|
|
602
642
|
if (currentFrame) {
|
|
603
643
|
return currentFrame.computed.getDependenciesCount();
|
|
604
644
|
}
|
|
645
|
+
return void 0;
|
|
605
646
|
}
|
|
606
647
|
function getDependencies() {
|
|
607
648
|
if (currentFrame) {
|
|
608
649
|
return currentFrame.computed.getDependencies();
|
|
609
650
|
}
|
|
651
|
+
return void 0;
|
|
610
652
|
}
|
|
611
653
|
function isInitial() {
|
|
612
654
|
if (currentFrame) {
|
|
613
655
|
return currentFrame.isInitial;
|
|
614
656
|
}
|
|
657
|
+
return void 0;
|
|
615
658
|
}
|
|
616
659
|
|
|
617
660
|
// ../observable/dist/defer.js
|
|
@@ -658,6 +701,7 @@ var Subscription = class {
|
|
|
658
701
|
this._node = node;
|
|
659
702
|
addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
|
|
660
703
|
}
|
|
704
|
+
// TC39 Observable API
|
|
661
705
|
unsubscribe() {
|
|
662
706
|
this.dispose();
|
|
663
707
|
}
|
|
@@ -667,21 +711,16 @@ var Subscription = class {
|
|
|
667
711
|
};
|
|
668
712
|
|
|
669
713
|
// ../observable/dist/extenders.js
|
|
670
|
-
var primitiveTypes = {
|
|
671
|
-
"undefined": 1,
|
|
672
|
-
"boolean": 1,
|
|
673
|
-
"number": 1,
|
|
674
|
-
"string": 1
|
|
675
|
-
};
|
|
714
|
+
var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
|
|
676
715
|
function valuesArePrimitiveAndEqual(a, b) {
|
|
677
|
-
|
|
716
|
+
const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
|
|
678
717
|
return oldValueIsPrimitive ? a === b : false;
|
|
679
718
|
}
|
|
680
719
|
function applyExtenders(requestedExtenders) {
|
|
681
|
-
|
|
720
|
+
let target = this;
|
|
682
721
|
if (requestedExtenders) {
|
|
683
722
|
objectForEach(requestedExtenders, function(key, value) {
|
|
684
|
-
|
|
723
|
+
const extenderHandler = extenders[key];
|
|
685
724
|
if (typeof extenderHandler === "function") {
|
|
686
725
|
target = extenderHandler(target, value) || target;
|
|
687
726
|
} else {
|
|
@@ -696,12 +735,14 @@ function notify(target, notifyWhen) {
|
|
|
696
735
|
}
|
|
697
736
|
function deferred(target, option) {
|
|
698
737
|
if (option !== true) {
|
|
699
|
-
throw new Error(
|
|
738
|
+
throw new Error(
|
|
739
|
+
"The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
|
|
740
|
+
);
|
|
700
741
|
}
|
|
701
742
|
deferUpdates(target);
|
|
702
743
|
}
|
|
703
744
|
function rateLimit(target, options2) {
|
|
704
|
-
|
|
745
|
+
let timeout, method, limitFunction;
|
|
705
746
|
if (typeof options2 === "number") {
|
|
706
747
|
timeout = options2;
|
|
707
748
|
} else {
|
|
@@ -714,21 +755,17 @@ function rateLimit(target, options2) {
|
|
|
714
755
|
return limitFunction(callback, timeout);
|
|
715
756
|
});
|
|
716
757
|
}
|
|
717
|
-
var extenders = {
|
|
718
|
-
notify,
|
|
719
|
-
deferred,
|
|
720
|
-
rateLimit
|
|
721
|
-
};
|
|
758
|
+
var extenders = { notify, deferred, rateLimit };
|
|
722
759
|
|
|
723
760
|
// ../observable/dist/subscribable.js
|
|
724
|
-
var LATEST_VALUE = Symbol("Knockout latest value");
|
|
761
|
+
var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
|
|
725
762
|
if (!Symbol.observable) {
|
|
726
|
-
Symbol.observable = Symbol.for("@tko/Symbol.observable");
|
|
763
|
+
Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
|
|
727
764
|
}
|
|
728
|
-
function
|
|
765
|
+
var subscribable = function subscribableFactory() {
|
|
729
766
|
Object.setPrototypeOf(this, ko_subscribable_fn);
|
|
730
767
|
ko_subscribable_fn.init(this);
|
|
731
|
-
}
|
|
768
|
+
};
|
|
732
769
|
var defaultEvent = "change";
|
|
733
770
|
var ko_subscribable_fn = {
|
|
734
771
|
[SUBSCRIBABLE_SYM]: true,
|
|
@@ -742,9 +779,7 @@ var ko_subscribable_fn = {
|
|
|
742
779
|
subscribe(callback, callbackTarget, event) {
|
|
743
780
|
const isTC39Callback = typeof callback === "object" && callback.next;
|
|
744
781
|
event = event || defaultEvent;
|
|
745
|
-
const observer = isTC39Callback ? callback : {
|
|
746
|
-
next: callbackTarget ? callback.bind(callbackTarget) : callback
|
|
747
|
-
};
|
|
782
|
+
const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
|
|
748
783
|
const subscriptionInstance = new Subscription(this, observer, () => {
|
|
749
784
|
arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
|
|
750
785
|
if (this.afterSubscriptionRemove) {
|
|
@@ -755,7 +790,7 @@ var ko_subscribable_fn = {
|
|
|
755
790
|
this.beforeSubscriptionAdd(event);
|
|
756
791
|
}
|
|
757
792
|
if (!this._subscriptions[event]) {
|
|
758
|
-
this._subscriptions[event] =
|
|
793
|
+
this._subscriptions[event] = new Array();
|
|
759
794
|
}
|
|
760
795
|
this._subscriptions[event].push(subscriptionInstance);
|
|
761
796
|
if (isTC39Callback && LATEST_VALUE in this) {
|
|
@@ -798,7 +833,7 @@ var ko_subscribable_fn = {
|
|
|
798
833
|
if (event) {
|
|
799
834
|
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
|
800
835
|
} else {
|
|
801
|
-
|
|
836
|
+
let total = 0;
|
|
802
837
|
objectForEach(this._subscriptions, function(eventName, subscriptions) {
|
|
803
838
|
if (eventName !== "dirty") {
|
|
804
839
|
total += subscriptions.length;
|
|
@@ -853,6 +888,7 @@ function observable(initialValue) {
|
|
|
853
888
|
function Observable() {
|
|
854
889
|
if (arguments.length > 0) {
|
|
855
890
|
if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
|
|
891
|
+
;
|
|
856
892
|
Observable.valueWillMutate();
|
|
857
893
|
Observable[LATEST_VALUE] = arguments[0];
|
|
858
894
|
Observable.valueHasMutated();
|
|
@@ -873,20 +909,43 @@ function observable(initialValue) {
|
|
|
873
909
|
return Observable;
|
|
874
910
|
}
|
|
875
911
|
observable.fn = {
|
|
912
|
+
/**
|
|
913
|
+
* Compares two values for equality.
|
|
914
|
+
* @param a The first value.
|
|
915
|
+
* @param b The second value.
|
|
916
|
+
* @returns True if the values are equal, otherwise false.
|
|
917
|
+
*/
|
|
876
918
|
equalityComparer: valuesArePrimitiveAndEqual,
|
|
919
|
+
/**
|
|
920
|
+
* Returns the current value of the observable without creating a dependency.
|
|
921
|
+
* @returns The current value.
|
|
922
|
+
*/
|
|
877
923
|
peek() {
|
|
878
924
|
return this[LATEST_VALUE];
|
|
879
925
|
},
|
|
926
|
+
/**
|
|
927
|
+
* Notifies subscribers that the value has changed.
|
|
928
|
+
*/
|
|
880
929
|
valueHasMutated() {
|
|
881
930
|
this.notifySubscribers(this[LATEST_VALUE], "spectate");
|
|
882
931
|
this.notifySubscribers(this[LATEST_VALUE]);
|
|
883
932
|
},
|
|
933
|
+
/**
|
|
934
|
+
* Notifies subscribers that the value is about to change.
|
|
935
|
+
*/
|
|
884
936
|
valueWillMutate() {
|
|
885
937
|
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
|
|
886
938
|
},
|
|
939
|
+
/**
|
|
940
|
+
* Modifies the value of the observable using a function.
|
|
941
|
+
* @param fn The function to modify the value.
|
|
942
|
+
* @param peek Whether to use the current value without creating a dependency.
|
|
943
|
+
* @returns The modified observable.
|
|
944
|
+
*/
|
|
887
945
|
modify(fn, peek2 = true) {
|
|
888
|
-
|
|
946
|
+
this(fn(peek2 ? this.peek() : this()));
|
|
889
947
|
},
|
|
948
|
+
// Some observables may not always be writeable, notably computeds.
|
|
890
949
|
isWriteable: true
|
|
891
950
|
};
|
|
892
951
|
function limitNotifySubscribers(value, event) {
|
|
@@ -899,15 +958,15 @@ function limitNotifySubscribers(value, event) {
|
|
|
899
958
|
}
|
|
900
959
|
}
|
|
901
960
|
subscribable.fn.limit = function limit(limitFunction) {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
961
|
+
const self = this;
|
|
962
|
+
const selfIsObservable = isObservable(self);
|
|
963
|
+
const beforeChange = "beforeChange";
|
|
964
|
+
let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
|
|
906
965
|
if (!self._origNotifySubscribers) {
|
|
907
966
|
self._origNotifySubscribers = self.notifySubscribers;
|
|
908
967
|
self.notifySubscribers = limitNotifySubscribers;
|
|
909
968
|
}
|
|
910
|
-
|
|
969
|
+
const finish = limitFunction(function() {
|
|
911
970
|
self._notificationIsPending = false;
|
|
912
971
|
if (selfIsObservable && pendingValue === self) {
|
|
913
972
|
pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
|
|
@@ -935,7 +994,10 @@ subscribable.fn.limit = function limit(limitFunction) {
|
|
|
935
994
|
}
|
|
936
995
|
},
|
|
937
996
|
_notifyNextChangeIfValueIsDifferent() {
|
|
938
|
-
if (self.isDifferent(previousValue, self.peek(
|
|
997
|
+
if (self.isDifferent(previousValue, self.peek(
|
|
998
|
+
true
|
|
999
|
+
/* evaluate */
|
|
1000
|
+
))) {
|
|
939
1001
|
notifyNextChange = true;
|
|
940
1002
|
}
|
|
941
1003
|
},
|
|
@@ -972,8 +1034,8 @@ function trackArrayChanges(target, options2) {
|
|
|
972
1034
|
let arrayChangeSubscription;
|
|
973
1035
|
let pendingNotifications = 0;
|
|
974
1036
|
let underlyingNotifySubscribersFunction;
|
|
975
|
-
|
|
976
|
-
|
|
1037
|
+
const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
|
|
1038
|
+
const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
|
|
977
1039
|
target.beforeSubscriptionAdd = function(event) {
|
|
978
1040
|
if (underlyingBeforeSubscriptionAddFunction) {
|
|
979
1041
|
underlyingBeforeSubscriptionAddFunction.call(target, event);
|
|
@@ -1010,11 +1072,11 @@ function trackArrayChanges(target, options2) {
|
|
|
1010
1072
|
}
|
|
1011
1073
|
return underlyingNotifySubscribersFunction.apply(this, arguments);
|
|
1012
1074
|
};
|
|
1013
|
-
|
|
1075
|
+
let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
|
|
1014
1076
|
cachedDiff = null;
|
|
1015
1077
|
arrayChangeSubscription = target.subscribe(function(currentContents) {
|
|
1016
1078
|
let changes;
|
|
1017
|
-
currentContents =
|
|
1079
|
+
currentContents = new Array().concat(currentContents || []);
|
|
1018
1080
|
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1019
1081
|
changes = getChanges(previousContents, currentContents);
|
|
1020
1082
|
}
|
|
@@ -1036,9 +1098,9 @@ function trackArrayChanges(target, options2) {
|
|
|
1036
1098
|
if (!trackingChanges || pendingNotifications) {
|
|
1037
1099
|
return;
|
|
1038
1100
|
}
|
|
1039
|
-
|
|
1101
|
+
let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
|
|
1040
1102
|
function pushDiff(status, value, index) {
|
|
1041
|
-
return diff[diff.length] = {
|
|
1103
|
+
return diff[diff.length] = { status, value, index };
|
|
1042
1104
|
}
|
|
1043
1105
|
switch (operationName) {
|
|
1044
1106
|
case "push":
|
|
@@ -1056,16 +1118,18 @@ function trackArrayChanges(target, options2) {
|
|
|
1056
1118
|
}
|
|
1057
1119
|
break;
|
|
1058
1120
|
case "splice":
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1121
|
+
{
|
|
1122
|
+
const startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength), endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength), endAddIndex = startIndex + argsLength - 2, endIndex = Math.max(endDeleteIndex, endAddIndex), additions = new Array(), deletions = new Array();
|
|
1123
|
+
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
|
|
1124
|
+
if (index < endDeleteIndex) {
|
|
1125
|
+
deletions.push(pushDiff("deleted", rawArray[index], index));
|
|
1126
|
+
}
|
|
1127
|
+
if (index < endAddIndex) {
|
|
1128
|
+
additions.push(pushDiff("added", args[argsIndex], index));
|
|
1129
|
+
}
|
|
1066
1130
|
}
|
|
1131
|
+
findMovesInArrayComparison(deletions, additions);
|
|
1067
1132
|
}
|
|
1068
|
-
findMovesInArrayComparison(deletions, additions);
|
|
1069
1133
|
break;
|
|
1070
1134
|
default:
|
|
1071
1135
|
return;
|
|
@@ -1080,23 +1144,27 @@ extenders.trackArrayChanges = trackArrayChanges;
|
|
|
1080
1144
|
function observableArray(initialValues) {
|
|
1081
1145
|
initialValues = initialValues || [];
|
|
1082
1146
|
if (typeof initialValues !== "object" || !("length" in initialValues)) {
|
|
1083
|
-
throw new Error(
|
|
1147
|
+
throw new Error(
|
|
1148
|
+
"The argument passed when initializing an observable array must be an array, or null, or undefined."
|
|
1149
|
+
);
|
|
1084
1150
|
}
|
|
1085
|
-
|
|
1086
|
-
Object.setPrototypeOf(result, observableArray.fn);
|
|
1151
|
+
const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
|
|
1087
1152
|
trackArrayChanges(result);
|
|
1088
|
-
overwriteLengthPropertyIfSupported(result, { get: () =>
|
|
1153
|
+
overwriteLengthPropertyIfSupported(result, { get: () => {
|
|
1154
|
+
var _a;
|
|
1155
|
+
return (_a = result()) == null ? void 0 : _a.length;
|
|
1156
|
+
} });
|
|
1089
1157
|
return result;
|
|
1090
1158
|
}
|
|
1091
1159
|
observableArray.fn = {
|
|
1092
1160
|
remove(valueOrPredicate) {
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
return
|
|
1161
|
+
const underlyingArray = this.peek();
|
|
1162
|
+
const removedValues = new Array();
|
|
1163
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
|
|
1164
|
+
return value === valueOrPredicate;
|
|
1097
1165
|
};
|
|
1098
|
-
for (
|
|
1099
|
-
|
|
1166
|
+
for (let i = 0; i < underlyingArray.length; i++) {
|
|
1167
|
+
const value = underlyingArray[i];
|
|
1100
1168
|
if (predicate(value)) {
|
|
1101
1169
|
if (removedValues.length === 0) {
|
|
1102
1170
|
this.valueWillMutate();
|
|
@@ -1116,8 +1184,8 @@ observableArray.fn = {
|
|
|
1116
1184
|
},
|
|
1117
1185
|
removeAll(arrayOfValues) {
|
|
1118
1186
|
if (arrayOfValues === void 0) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1187
|
+
const underlyingArray = this.peek();
|
|
1188
|
+
const allValues = underlyingArray.slice(0);
|
|
1121
1189
|
this.valueWillMutate();
|
|
1122
1190
|
underlyingArray.splice(0, underlyingArray.length);
|
|
1123
1191
|
this.valueHasMutated();
|
|
@@ -1131,13 +1199,13 @@ observableArray.fn = {
|
|
|
1131
1199
|
});
|
|
1132
1200
|
},
|
|
1133
1201
|
destroy(valueOrPredicate) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
return
|
|
1202
|
+
const underlyingArray = this.peek();
|
|
1203
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
|
|
1204
|
+
return value === valueOrPredicate;
|
|
1137
1205
|
};
|
|
1138
1206
|
this.valueWillMutate();
|
|
1139
|
-
for (
|
|
1140
|
-
|
|
1207
|
+
for (let i = underlyingArray.length - 1; i >= 0; i--) {
|
|
1208
|
+
const value = underlyingArray[i];
|
|
1141
1209
|
if (predicate(value)) {
|
|
1142
1210
|
value["_destroy"] = true;
|
|
1143
1211
|
}
|
|
@@ -1161,7 +1229,7 @@ observableArray.fn = {
|
|
|
1161
1229
|
return arrayIndexOf(this(), item);
|
|
1162
1230
|
},
|
|
1163
1231
|
replace(oldItem, newItem) {
|
|
1164
|
-
|
|
1232
|
+
const index = this.indexOf(oldItem);
|
|
1165
1233
|
if (index >= 0) {
|
|
1166
1234
|
this.valueWillMutate();
|
|
1167
1235
|
this.peek()[index] = newItem;
|
|
@@ -1175,23 +1243,23 @@ observableArray.fn = {
|
|
|
1175
1243
|
return [...this()].reverse();
|
|
1176
1244
|
},
|
|
1177
1245
|
[Symbol.iterator]: function* () {
|
|
1178
|
-
yield* this();
|
|
1246
|
+
yield* __yieldStar(this());
|
|
1179
1247
|
}
|
|
1180
1248
|
};
|
|
1181
1249
|
Object.setPrototypeOf(observableArray.fn, observable.fn);
|
|
1182
1250
|
arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
1183
1251
|
observableArray.fn[methodName] = function() {
|
|
1184
|
-
|
|
1252
|
+
const underlyingArray = this.peek();
|
|
1185
1253
|
this.valueWillMutate();
|
|
1186
1254
|
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
|
|
1187
|
-
|
|
1255
|
+
const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1188
1256
|
this.valueHasMutated();
|
|
1189
1257
|
return methodCallResult === underlyingArray ? this : methodCallResult;
|
|
1190
1258
|
};
|
|
1191
1259
|
});
|
|
1192
1260
|
arrayForEach(["slice"], function(methodName) {
|
|
1193
1261
|
observableArray.fn[methodName] = function() {
|
|
1194
|
-
|
|
1262
|
+
const underlyingArray = this();
|
|
1195
1263
|
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1196
1264
|
};
|
|
1197
1265
|
});
|
|
@@ -1204,13 +1272,21 @@ var BindingHandlerObject = class {
|
|
|
1204
1272
|
this[nameOrObject] = value;
|
|
1205
1273
|
} else if (typeof nameOrObject === "object") {
|
|
1206
1274
|
if (value !== void 0) {
|
|
1207
|
-
options_default.onError(
|
|
1275
|
+
options_default.onError(
|
|
1276
|
+
new Error(
|
|
1277
|
+
"Given extraneous `value` parameter (first param should be a string, but it was an object)." + nameOrObject
|
|
1278
|
+
)
|
|
1279
|
+
);
|
|
1208
1280
|
}
|
|
1209
1281
|
Object.assign(this, nameOrObject);
|
|
1210
1282
|
} else {
|
|
1211
1283
|
options_default.onError(new Error("Given a bad binding handler type: " + nameOrObject));
|
|
1212
1284
|
}
|
|
1213
1285
|
}
|
|
1286
|
+
/**
|
|
1287
|
+
* The handler may have a `.` in it, e.g. `attr.title`, in which case the
|
|
1288
|
+
* handler is `attr`. Otherwise it's the name given
|
|
1289
|
+
*/
|
|
1214
1290
|
get(nameOrDotted) {
|
|
1215
1291
|
const [name] = nameOrDotted.split(".");
|
|
1216
1292
|
return this[name];
|
|
@@ -1218,16 +1294,19 @@ var BindingHandlerObject = class {
|
|
|
1218
1294
|
};
|
|
1219
1295
|
|
|
1220
1296
|
// ../provider/dist/Provider.js
|
|
1221
|
-
var Provider = class {
|
|
1222
|
-
constructor(params
|
|
1223
|
-
if (this.constructor ===
|
|
1297
|
+
var Provider = class _Provider {
|
|
1298
|
+
constructor(params) {
|
|
1299
|
+
if (this.constructor === _Provider) {
|
|
1224
1300
|
throw new Error("Provider is an abstract base class.");
|
|
1225
1301
|
}
|
|
1226
1302
|
if (!("FOR_NODE_TYPES" in this)) {
|
|
1227
1303
|
throw new Error("Providers must have FOR_NODE_TYPES property");
|
|
1228
1304
|
}
|
|
1229
|
-
this.bindingHandlers = params.bindingHandlers || new BindingHandlerObject();
|
|
1230
|
-
this.globals = params.globals || {};
|
|
1305
|
+
this.bindingHandlers = (params == null ? void 0 : params.bindingHandlers) || new BindingHandlerObject();
|
|
1306
|
+
this.globals = (params == null ? void 0 : params.globals) || {};
|
|
1307
|
+
}
|
|
1308
|
+
get FOR_NODE_TYPES() {
|
|
1309
|
+
throw new Error("Providers must override FOR_NODE_TYPES property");
|
|
1231
1310
|
}
|
|
1232
1311
|
setGlobals(globals) {
|
|
1233
1312
|
this.globals = globals;
|
|
@@ -1235,14 +1314,24 @@ var Provider = class {
|
|
|
1235
1314
|
get preemptive() {
|
|
1236
1315
|
return false;
|
|
1237
1316
|
}
|
|
1238
|
-
nodeHasBindings() {
|
|
1317
|
+
nodeHasBindings(node, context) {
|
|
1318
|
+
return false;
|
|
1239
1319
|
}
|
|
1240
|
-
getBindingAccessors() {
|
|
1320
|
+
getBindingAccessors(node, context) {
|
|
1321
|
+
return /* @__PURE__ */ Object.create(null);
|
|
1241
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Preprocess a given node.
|
|
1325
|
+
* @param {Node} node
|
|
1326
|
+
* @returns {[Node]|null}
|
|
1327
|
+
*/
|
|
1242
1328
|
preprocessNode(node) {
|
|
1329
|
+
return [node];
|
|
1243
1330
|
}
|
|
1244
1331
|
postProcess() {
|
|
1245
1332
|
}
|
|
1333
|
+
/** For legacy binding provider assignments to
|
|
1334
|
+
* ko.bindingProvider.instance = ... */
|
|
1246
1335
|
get instance() {
|
|
1247
1336
|
return this._overloadInstance || this;
|
|
1248
1337
|
}
|
|
@@ -1253,12 +1342,19 @@ var Provider = class {
|
|
|
1253
1342
|
this._overloadInstance = new LegacyProvider(provider, this);
|
|
1254
1343
|
}
|
|
1255
1344
|
}
|
|
1345
|
+
// Given a function that returns bindings, create and return a new object that contains
|
|
1346
|
+
// binding value-accessors functions. Each accessor function calls the original function
|
|
1347
|
+
// so that it always gets the latest value and all dependencies are captured. This is used
|
|
1348
|
+
// by ko.applyBindingsToNode and getBindingsAndMakeAccessors.
|
|
1256
1349
|
makeAccessorsFromFunction(callback) {
|
|
1257
1350
|
return objectMap(dependencyDetection_exports.ignore(callback), (value, key) => () => callback()[key]);
|
|
1258
1351
|
}
|
|
1352
|
+
// Returns the valueAccessor function for a binding value
|
|
1259
1353
|
makeValueAccessor(value) {
|
|
1260
1354
|
return () => value;
|
|
1261
1355
|
}
|
|
1356
|
+
// Given a bindings function or object, create and return a new object that contains
|
|
1357
|
+
// binding value-accessors functions. This is used by ko.applyBindingsToNode.
|
|
1262
1358
|
makeBindingAccessors(bindings, context, node) {
|
|
1263
1359
|
if (typeof bindings === "function") {
|
|
1264
1360
|
return this.makeAccessorsFromFunction(bindings.bind(null, context, node));
|
|
@@ -1269,13 +1365,15 @@ var Provider = class {
|
|
|
1269
1365
|
};
|
|
1270
1366
|
var LegacyProvider = class extends Provider {
|
|
1271
1367
|
get FOR_NODE_TYPES() {
|
|
1272
|
-
return [
|
|
1368
|
+
return [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE];
|
|
1273
1369
|
}
|
|
1274
1370
|
constructor(providerObject, parentProvider) {
|
|
1275
1371
|
super();
|
|
1276
1372
|
Object.assign(this, { providerObject });
|
|
1277
1373
|
this.bindingHandlers = providerObject.bindingHandlers || parentProvider.bindingHandlers;
|
|
1278
1374
|
}
|
|
1375
|
+
// This function is used if the binding provider doesn't include a getBindingAccessors function.
|
|
1376
|
+
// It must be called with 'this' set to the provider instance.
|
|
1279
1377
|
getBindingsAndMakeAccessors(node, context) {
|
|
1280
1378
|
const bindingsFn = this.providerObject.getBindings.bind(this.providerObject, node, context);
|
|
1281
1379
|
return this.makeAccessorsFromFunction(bindingsFn);
|
|
@@ -1290,6 +1388,7 @@ var LegacyProvider = class extends Provider {
|
|
|
1290
1388
|
if (this.providerObject.preprocessNode) {
|
|
1291
1389
|
return this.providerObject.preprocessNode(node);
|
|
1292
1390
|
}
|
|
1391
|
+
return null;
|
|
1293
1392
|
}
|
|
1294
1393
|
};
|
|
1295
1394
|
|
|
@@ -1298,15 +1397,16 @@ var MultiProvider = class extends Provider {
|
|
|
1298
1397
|
get FOR_NODE_TYPES() {
|
|
1299
1398
|
return this.nodeTypes;
|
|
1300
1399
|
}
|
|
1301
|
-
constructor(params
|
|
1400
|
+
constructor(params) {
|
|
1302
1401
|
super(params);
|
|
1303
|
-
const providers = params.providers || [];
|
|
1402
|
+
const providers = (params == null ? void 0 : params.providers) || [];
|
|
1304
1403
|
this.nodeTypeMap = {};
|
|
1305
1404
|
this.nodeTypes = [];
|
|
1306
1405
|
this.providers = [];
|
|
1307
1406
|
providers.forEach((p) => this.addProvider(p));
|
|
1308
1407
|
}
|
|
1309
1408
|
setGlobals(globals) {
|
|
1409
|
+
;
|
|
1310
1410
|
[this, ...this.providers].forEach((p) => p.globals = globals);
|
|
1311
1411
|
}
|
|
1312
1412
|
addProvider(provider) {
|
|
@@ -1316,7 +1416,7 @@ var MultiProvider = class extends Provider {
|
|
|
1316
1416
|
const nodeTypeMap = this.nodeTypeMap;
|
|
1317
1417
|
for (const nodeType of provider.FOR_NODE_TYPES) {
|
|
1318
1418
|
if (!nodeTypeMap[nodeType]) {
|
|
1319
|
-
nodeTypeMap[nodeType] =
|
|
1419
|
+
nodeTypeMap[nodeType] = new Array();
|
|
1320
1420
|
}
|
|
1321
1421
|
nodeTypeMap[nodeType].push(provider);
|
|
1322
1422
|
}
|
|
@@ -1325,7 +1425,7 @@ var MultiProvider = class extends Provider {
|
|
|
1325
1425
|
providersFor(node) {
|
|
1326
1426
|
return this.nodeTypeMap[node.nodeType] || [];
|
|
1327
1427
|
}
|
|
1328
|
-
nodeHasBindings(node) {
|
|
1428
|
+
nodeHasBindings(node, context) {
|
|
1329
1429
|
return this.providersFor(node).some((p) => p.nodeHasBindings(node));
|
|
1330
1430
|
}
|
|
1331
1431
|
preprocessNode(node) {
|
|
@@ -1335,22 +1435,23 @@ var MultiProvider = class extends Provider {
|
|
|
1335
1435
|
return newNodes;
|
|
1336
1436
|
}
|
|
1337
1437
|
}
|
|
1438
|
+
return null;
|
|
1338
1439
|
}
|
|
1339
|
-
*enumerateProviderBindings(node,
|
|
1440
|
+
*enumerateProviderBindings(node, context) {
|
|
1340
1441
|
for (const provider of this.providersFor(node)) {
|
|
1341
|
-
const bindings = provider.getBindingAccessors(node,
|
|
1442
|
+
const bindings = provider.getBindingAccessors(node, context);
|
|
1342
1443
|
if (!bindings) {
|
|
1343
1444
|
continue;
|
|
1344
1445
|
}
|
|
1345
|
-
yield* Object.entries(bindings || {});
|
|
1446
|
+
yield* __yieldStar(Object.entries(bindings || {}));
|
|
1346
1447
|
if (provider.preemptive) {
|
|
1347
1448
|
return;
|
|
1348
1449
|
}
|
|
1349
1450
|
}
|
|
1350
1451
|
}
|
|
1351
|
-
getBindingAccessors(node,
|
|
1452
|
+
getBindingAccessors(node, context) {
|
|
1352
1453
|
const bindings = {};
|
|
1353
|
-
for (const [key, accessor] of this.enumerateProviderBindings(node,
|
|
1454
|
+
for (const [key, accessor] of this.enumerateProviderBindings(node, context)) {
|
|
1354
1455
|
if (key in bindings) {
|
|
1355
1456
|
throw new Error(`The binding "${key}" is duplicated by multiple providers`);
|
|
1356
1457
|
}
|