@tko/binding.template 4.0.0-alpha8.0 → 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/dist/foreach.js +32 -0
- package/dist/foreach.js.map +7 -0
- package/dist/index.cjs +3518 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +15 -0
- package/dist/index.mjs.map +7 -0
- package/dist/nativeTemplateEngine.js +27 -0
- package/dist/nativeTemplateEngine.js.map +7 -0
- package/dist/templateEngine.js +38 -0
- package/dist/templateEngine.js.map +7 -0
- package/dist/templateSources.js +80 -0
- package/dist/templateSources.js.map +7 -0
- package/dist/templating.js +315 -0
- package/dist/templating.js.map +7 -0
- package/helpers/{dummyTemplateEngine.js → dummyTemplateEngine.ts} +4 -3
- package/package.json +20 -30
- package/dist/binding.template.es6.js +0 -557
- package/dist/binding.template.es6.js.map +0 -1
- package/dist/binding.template.js +0 -576
- package/dist/binding.template.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3518 @@
|
|
|
1
|
+
// @tko/binding.template 🥊 4.0.0-beta1.0 CommonJS
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// index.ts
|
|
21
|
+
var binding_exports = {};
|
|
22
|
+
__export(binding_exports, {
|
|
23
|
+
TemplateBindingHandler: () => TemplateBindingHandler,
|
|
24
|
+
anonymousTemplate: () => anonymousTemplate,
|
|
25
|
+
bindings: () => bindings,
|
|
26
|
+
domElement: () => domElement,
|
|
27
|
+
nativeTemplateEngine: () => nativeTemplateEngine,
|
|
28
|
+
renderTemplate: () => renderTemplate,
|
|
29
|
+
setTemplateEngine: () => setTemplateEngine,
|
|
30
|
+
templateEngine: () => templateEngine
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(binding_exports);
|
|
33
|
+
|
|
34
|
+
// ../utils/dist/array.js
|
|
35
|
+
var { isArray } = Array;
|
|
36
|
+
function arrayForEach(array, action, thisArg) {
|
|
37
|
+
if (arguments.length > 2) {
|
|
38
|
+
action = action.bind(thisArg);
|
|
39
|
+
}
|
|
40
|
+
for (let i = 0, j = array.length; i < j; ++i) {
|
|
41
|
+
action(array[i], i, array);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function arrayIndexOf(array, item) {
|
|
45
|
+
return (isArray(array) ? array : [...array]).indexOf(item);
|
|
46
|
+
}
|
|
47
|
+
function arrayFirst(array, predicate, predicateOwner) {
|
|
48
|
+
return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
|
|
49
|
+
}
|
|
50
|
+
function arrayMap(array = [], mapping, thisArg) {
|
|
51
|
+
if (arguments.length > 2) {
|
|
52
|
+
mapping = mapping.bind(thisArg);
|
|
53
|
+
}
|
|
54
|
+
return array === null ? [] : Array.from(array, mapping);
|
|
55
|
+
}
|
|
56
|
+
function arrayRemoveItem(array, itemToRemove) {
|
|
57
|
+
var index = arrayIndexOf(array, itemToRemove);
|
|
58
|
+
if (index > 0) {
|
|
59
|
+
array.splice(index, 1);
|
|
60
|
+
} else if (index === 0) {
|
|
61
|
+
array.shift();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function arrayFilter(array, predicate, thisArg) {
|
|
65
|
+
if (arguments.length > 2) {
|
|
66
|
+
predicate = predicate.bind(thisArg);
|
|
67
|
+
}
|
|
68
|
+
return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);
|
|
69
|
+
}
|
|
70
|
+
function arrayPushAll(array, valuesToPush) {
|
|
71
|
+
if (isArray(valuesToPush)) {
|
|
72
|
+
array.push.apply(array, valuesToPush);
|
|
73
|
+
} else {
|
|
74
|
+
for (var i = 0, j = valuesToPush.length; i < j; i++) {
|
|
75
|
+
array.push(valuesToPush[i]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return array;
|
|
79
|
+
}
|
|
80
|
+
function makeArray(arrayLikeObject) {
|
|
81
|
+
return Array.from(arrayLikeObject);
|
|
82
|
+
}
|
|
83
|
+
function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
84
|
+
if (left.length && right.length) {
|
|
85
|
+
var failedCompares, l, r, leftItem, rightItem;
|
|
86
|
+
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
87
|
+
for (r = 0; rightItem = right[r]; ++r) {
|
|
88
|
+
if (leftItem.value === rightItem.value) {
|
|
89
|
+
leftItem.moved = rightItem.index;
|
|
90
|
+
rightItem.moved = leftItem.index;
|
|
91
|
+
right.splice(r, 1);
|
|
92
|
+
failedCompares = r = 0;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
failedCompares += r;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var statusNotInOld = "added";
|
|
101
|
+
var statusNotInNew = "deleted";
|
|
102
|
+
function compareArrays(oldArray, newArray, options3) {
|
|
103
|
+
options3 = typeof options3 === "boolean" ? { dontLimitMoves: options3 } : options3 || {};
|
|
104
|
+
oldArray = oldArray || [];
|
|
105
|
+
newArray = newArray || [];
|
|
106
|
+
if (oldArray.length < newArray.length) {
|
|
107
|
+
return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options3);
|
|
108
|
+
} else {
|
|
109
|
+
return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options3);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options3) {
|
|
113
|
+
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;
|
|
114
|
+
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
115
|
+
lastRow = thisRow;
|
|
116
|
+
editDistanceMatrix.push(thisRow = []);
|
|
117
|
+
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
118
|
+
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
119
|
+
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
120
|
+
if (!bigIndex) {
|
|
121
|
+
thisRow[bigIndex] = smlIndex + 1;
|
|
122
|
+
} else if (!smlIndex) {
|
|
123
|
+
thisRow[bigIndex] = bigIndex + 1;
|
|
124
|
+
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
125
|
+
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
126
|
+
} else {
|
|
127
|
+
var northDistance = lastRow[bigIndex] || maxDistance;
|
|
128
|
+
var westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
129
|
+
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
var editScript = [], meMinusOne, notInSml = [], notInBig = [];
|
|
134
|
+
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
135
|
+
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
136
|
+
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
137
|
+
notInSml.push(editScript[editScript.length] = {
|
|
138
|
+
"status": statusNotInSml,
|
|
139
|
+
"value": bigArray[--bigIndex],
|
|
140
|
+
"index": bigIndex
|
|
141
|
+
});
|
|
142
|
+
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
143
|
+
notInBig.push(editScript[editScript.length] = {
|
|
144
|
+
"status": statusNotInBig,
|
|
145
|
+
"value": smlArray[--smlIndex],
|
|
146
|
+
"index": smlIndex
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
--bigIndex;
|
|
150
|
+
--smlIndex;
|
|
151
|
+
if (!options3.sparse) {
|
|
152
|
+
editScript.push({
|
|
153
|
+
"status": "retained",
|
|
154
|
+
"value": bigArray[bigIndex]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
findMovesInArrayComparison(notInBig, notInSml, !options3.dontLimitMoves && smlIndexMax * 10);
|
|
160
|
+
return editScript.reverse();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ../utils/dist/options.js
|
|
164
|
+
var options = {
|
|
165
|
+
deferUpdates: false,
|
|
166
|
+
useOnlyNativeEvents: false,
|
|
167
|
+
protoProperty: "__ko_proto__",
|
|
168
|
+
defaultBindingAttribute: "data-bind",
|
|
169
|
+
allowVirtualElements: true,
|
|
170
|
+
bindingGlobals: /* @__PURE__ */ Object.create(null),
|
|
171
|
+
bindingProviderInstance: null,
|
|
172
|
+
createChildContextWithAs: false,
|
|
173
|
+
jQuery: globalThis.jQuery,
|
|
174
|
+
Promise: globalThis.Promise,
|
|
175
|
+
taskScheduler: null,
|
|
176
|
+
debug: false,
|
|
177
|
+
global: globalThis,
|
|
178
|
+
document: globalThis.document,
|
|
179
|
+
filters: {},
|
|
180
|
+
includeDestroyed: false,
|
|
181
|
+
foreachHidesDestroyed: false,
|
|
182
|
+
onError: function(e) {
|
|
183
|
+
throw e;
|
|
184
|
+
},
|
|
185
|
+
set: function(name, value) {
|
|
186
|
+
options[name] = value;
|
|
187
|
+
},
|
|
188
|
+
getBindingHandler() {
|
|
189
|
+
},
|
|
190
|
+
cleanExternalData() {
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
Object.defineProperty(options, "$", {
|
|
194
|
+
get: function() {
|
|
195
|
+
return options.jQuery;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
var options_default = options;
|
|
199
|
+
|
|
200
|
+
// ../utils/dist/error.js
|
|
201
|
+
function catchFunctionErrors(delegate) {
|
|
202
|
+
if (!options_default.onError) {
|
|
203
|
+
return delegate;
|
|
204
|
+
}
|
|
205
|
+
return (...args) => {
|
|
206
|
+
try {
|
|
207
|
+
return delegate(...args);
|
|
208
|
+
} catch (err) {
|
|
209
|
+
options_default.onError(err);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function deferError(error) {
|
|
214
|
+
safeSetTimeout(function() {
|
|
215
|
+
throw error;
|
|
216
|
+
}, 0);
|
|
217
|
+
}
|
|
218
|
+
function safeSetTimeout(handler, timeout) {
|
|
219
|
+
return setTimeout(catchFunctionErrors(handler), timeout);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ../utils/dist/async.js
|
|
223
|
+
function throttle(callback, timeout) {
|
|
224
|
+
var timeoutInstance;
|
|
225
|
+
return function(...args) {
|
|
226
|
+
if (!timeoutInstance) {
|
|
227
|
+
timeoutInstance = safeSetTimeout(function() {
|
|
228
|
+
timeoutInstance = void 0;
|
|
229
|
+
callback(...args);
|
|
230
|
+
}, timeout);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function debounce(callback, timeout) {
|
|
235
|
+
var timeoutInstance;
|
|
236
|
+
return function(...args) {
|
|
237
|
+
clearTimeout(timeoutInstance);
|
|
238
|
+
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ../utils/dist/ie.js
|
|
243
|
+
var ieVersion = options_default.document && function() {
|
|
244
|
+
var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
|
|
245
|
+
while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
|
|
246
|
+
}
|
|
247
|
+
if (!version) {
|
|
248
|
+
const userAgent = window.navigator.userAgent;
|
|
249
|
+
return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
|
|
250
|
+
}
|
|
251
|
+
return version > 4 ? version : void 0;
|
|
252
|
+
}();
|
|
253
|
+
|
|
254
|
+
// ../utils/dist/object.js
|
|
255
|
+
function hasOwnProperty(obj, propName) {
|
|
256
|
+
return Object.prototype.hasOwnProperty.call(obj, propName);
|
|
257
|
+
}
|
|
258
|
+
function isObjectLike(obj) {
|
|
259
|
+
if (obj === null) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
return typeof obj === "object" || typeof obj === "function";
|
|
263
|
+
}
|
|
264
|
+
function extend(target, source) {
|
|
265
|
+
if (source) {
|
|
266
|
+
for (var prop in source) {
|
|
267
|
+
if (hasOwnProperty(source, prop)) {
|
|
268
|
+
target[prop] = source[prop];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return target;
|
|
273
|
+
}
|
|
274
|
+
function objectForEach(obj, action) {
|
|
275
|
+
for (var prop in obj) {
|
|
276
|
+
if (hasOwnProperty(obj, prop)) {
|
|
277
|
+
action(prop, obj[prop]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function objectMap(source, mapping, thisArg) {
|
|
282
|
+
if (!source) {
|
|
283
|
+
return source;
|
|
284
|
+
}
|
|
285
|
+
if (arguments.length > 2) {
|
|
286
|
+
mapping = mapping.bind(thisArg);
|
|
287
|
+
}
|
|
288
|
+
var target = {};
|
|
289
|
+
for (var prop in source) {
|
|
290
|
+
if (hasOwnProperty(source, prop)) {
|
|
291
|
+
target[prop] = mapping(source[prop], prop, source);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return target;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// ../utils/dist/function.js
|
|
298
|
+
function testOverwrite() {
|
|
299
|
+
try {
|
|
300
|
+
Object.defineProperty(function x() {
|
|
301
|
+
}, "length", {});
|
|
302
|
+
return true;
|
|
303
|
+
} catch (e) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
var functionSupportsLengthOverwrite = testOverwrite();
|
|
308
|
+
function overwriteLengthPropertyIfSupported(fn, descriptor) {
|
|
309
|
+
if (functionSupportsLengthOverwrite) {
|
|
310
|
+
Object.defineProperty(fn, "length", descriptor);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ../utils/dist/string.js
|
|
315
|
+
function stringTrim(string) {
|
|
316
|
+
return string === null || string === void 0 ? "" : string.trim ? string.trim() : string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, "");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ../utils/dist/symbol.js
|
|
320
|
+
var useSymbols = typeof Symbol === "function";
|
|
321
|
+
function createSymbolOrString(identifier) {
|
|
322
|
+
return useSymbols ? Symbol(identifier) : identifier;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ../utils/dist/jquery.js
|
|
326
|
+
var jQueryInstance = options_default.global && options_default.global.jQuery;
|
|
327
|
+
|
|
328
|
+
// ../utils/dist/dom/info.js
|
|
329
|
+
function domNodeIsContainedBy(node, containedByNode) {
|
|
330
|
+
if (node === containedByNode) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
if (node.nodeType === 11) {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
if (containedByNode.contains) {
|
|
337
|
+
return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
|
|
338
|
+
}
|
|
339
|
+
if (containedByNode.compareDocumentPosition) {
|
|
340
|
+
return (containedByNode.compareDocumentPosition(node) & 16) == 16;
|
|
341
|
+
}
|
|
342
|
+
while (node && node != containedByNode) {
|
|
343
|
+
node = node.parentNode;
|
|
344
|
+
}
|
|
345
|
+
return !!node;
|
|
346
|
+
}
|
|
347
|
+
function domNodeIsAttachedToDocument(node) {
|
|
348
|
+
return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
|
|
349
|
+
}
|
|
350
|
+
function anyDomNodeIsAttachedToDocument(nodes) {
|
|
351
|
+
return !!arrayFirst(nodes, domNodeIsAttachedToDocument);
|
|
352
|
+
}
|
|
353
|
+
function tagNameLower(element) {
|
|
354
|
+
return element && element.tagName && element.tagName.toLowerCase();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// ../utils/dist/dom/data.js
|
|
358
|
+
var data_exports = {};
|
|
359
|
+
__export(data_exports, {
|
|
360
|
+
clear: () => clear,
|
|
361
|
+
get: () => get,
|
|
362
|
+
getOrSet: () => getOrSet,
|
|
363
|
+
nextKey: () => nextKey,
|
|
364
|
+
set: () => set
|
|
365
|
+
});
|
|
366
|
+
var datastoreTime = new Date().getTime();
|
|
367
|
+
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
368
|
+
var dataStoreSymbol = Symbol("Knockout data");
|
|
369
|
+
var dataStore;
|
|
370
|
+
var uniqueId = 0;
|
|
371
|
+
var modern = {
|
|
372
|
+
getDataForNode(node, createIfNotFound) {
|
|
373
|
+
let dataForNode = node[dataStoreSymbol];
|
|
374
|
+
if (!dataForNode && createIfNotFound) {
|
|
375
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
376
|
+
}
|
|
377
|
+
return dataForNode;
|
|
378
|
+
},
|
|
379
|
+
clear(node) {
|
|
380
|
+
if (node[dataStoreSymbol]) {
|
|
381
|
+
delete node[dataStoreSymbol];
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
var IE = {
|
|
388
|
+
getDataforNode(node, createIfNotFound) {
|
|
389
|
+
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
390
|
+
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
|
|
391
|
+
if (!hasExistingDataStore) {
|
|
392
|
+
if (!createIfNotFound) {
|
|
393
|
+
return void 0;
|
|
394
|
+
}
|
|
395
|
+
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
|
396
|
+
dataStore[dataStoreKey] = {};
|
|
397
|
+
}
|
|
398
|
+
return dataStore[dataStoreKey];
|
|
399
|
+
},
|
|
400
|
+
clear(node) {
|
|
401
|
+
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
402
|
+
if (dataStoreKey) {
|
|
403
|
+
delete dataStore[dataStoreKey];
|
|
404
|
+
node[dataStoreKeyExpandoPropertyName] = null;
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
var { getDataForNode, clear } = ieVersion ? IE : modern;
|
|
411
|
+
function nextKey() {
|
|
412
|
+
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
413
|
+
}
|
|
414
|
+
function get(node, key) {
|
|
415
|
+
const dataForNode = getDataForNode(node, false);
|
|
416
|
+
return dataForNode && dataForNode[key];
|
|
417
|
+
}
|
|
418
|
+
function set(node, key, value) {
|
|
419
|
+
var dataForNode = getDataForNode(node, value !== void 0);
|
|
420
|
+
dataForNode && (dataForNode[key] = value);
|
|
421
|
+
}
|
|
422
|
+
function getOrSet(node, key, value) {
|
|
423
|
+
const dataForNode = getDataForNode(node, true);
|
|
424
|
+
return dataForNode[key] || (dataForNode[key] = value);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// ../utils/dist/dom/disposal.js
|
|
428
|
+
var domDataKey = nextKey();
|
|
429
|
+
var cleanableNodeTypes = { 1: true, 8: true, 9: true };
|
|
430
|
+
var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
|
|
431
|
+
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
432
|
+
var allDisposeCallbacks = get(node, domDataKey);
|
|
433
|
+
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
434
|
+
allDisposeCallbacks = [];
|
|
435
|
+
set(node, domDataKey, allDisposeCallbacks);
|
|
436
|
+
}
|
|
437
|
+
return allDisposeCallbacks;
|
|
438
|
+
}
|
|
439
|
+
function destroyCallbacksCollection(node) {
|
|
440
|
+
set(node, domDataKey, void 0);
|
|
441
|
+
}
|
|
442
|
+
function cleanSingleNode(node) {
|
|
443
|
+
var callbacks = getDisposeCallbacksCollection(node, false);
|
|
444
|
+
if (callbacks) {
|
|
445
|
+
callbacks = callbacks.slice(0);
|
|
446
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
447
|
+
callbacks[i](node);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
clear(node);
|
|
451
|
+
for (let i = 0, j = otherNodeCleanerFunctions.length; i < j; ++i) {
|
|
452
|
+
otherNodeCleanerFunctions[i](node);
|
|
453
|
+
}
|
|
454
|
+
if (options_default.cleanExternalData) {
|
|
455
|
+
options_default.cleanExternalData(node);
|
|
456
|
+
}
|
|
457
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
458
|
+
cleanNodesInList(node.childNodes, true);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function cleanNodesInList(nodeList, onlyComments) {
|
|
462
|
+
const cleanedNodes = [];
|
|
463
|
+
let lastCleanedNode;
|
|
464
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
465
|
+
if (!onlyComments || nodeList[i].nodeType === 8) {
|
|
466
|
+
cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
|
|
467
|
+
if (nodeList[i] !== lastCleanedNode) {
|
|
468
|
+
while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function addDisposeCallback(node, callback) {
|
|
475
|
+
if (typeof callback !== "function") {
|
|
476
|
+
throw new Error("Callback must be a function");
|
|
477
|
+
}
|
|
478
|
+
getDisposeCallbacksCollection(node, true).push(callback);
|
|
479
|
+
}
|
|
480
|
+
function removeDisposeCallback(node, callback) {
|
|
481
|
+
var callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
482
|
+
if (callbacksCollection) {
|
|
483
|
+
arrayRemoveItem(callbacksCollection, callback);
|
|
484
|
+
if (callbacksCollection.length === 0) {
|
|
485
|
+
destroyCallbacksCollection(node);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function cleanNode(node) {
|
|
490
|
+
if (cleanableNodeTypes[node.nodeType]) {
|
|
491
|
+
cleanSingleNode(node);
|
|
492
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
493
|
+
cleanNodesInList(node.getElementsByTagName("*"));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return node;
|
|
497
|
+
}
|
|
498
|
+
function removeNode(node) {
|
|
499
|
+
cleanNode(node);
|
|
500
|
+
if (node.parentNode) {
|
|
501
|
+
node.parentNode.removeChild(node);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
var otherNodeCleanerFunctions = [];
|
|
505
|
+
function cleanjQueryData(node) {
|
|
506
|
+
var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
|
|
507
|
+
if (jQueryCleanNodeFn) {
|
|
508
|
+
jQueryCleanNodeFn([node]);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
512
|
+
|
|
513
|
+
// ../utils/dist/dom/event.js
|
|
514
|
+
var knownEvents = {};
|
|
515
|
+
var knownEventTypesByEventName = {};
|
|
516
|
+
var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
|
|
517
|
+
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
|
|
518
|
+
knownEvents["MouseEvents"] = [
|
|
519
|
+
"click",
|
|
520
|
+
"dblclick",
|
|
521
|
+
"mousedown",
|
|
522
|
+
"mouseup",
|
|
523
|
+
"mousemove",
|
|
524
|
+
"mouseover",
|
|
525
|
+
"mouseout",
|
|
526
|
+
"mouseenter",
|
|
527
|
+
"mouseleave"
|
|
528
|
+
];
|
|
529
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
530
|
+
if (knownEventsForType.length) {
|
|
531
|
+
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
532
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
// ../utils/dist/dom/manipulation.js
|
|
538
|
+
function moveCleanedNodesToContainerElement(nodes) {
|
|
539
|
+
var nodesArray = makeArray(nodes);
|
|
540
|
+
var templateDocument = nodesArray[0] && nodesArray[0].ownerDocument || document;
|
|
541
|
+
var container = templateDocument.createElement("div");
|
|
542
|
+
for (var i = 0, j = nodesArray.length; i < j; i++) {
|
|
543
|
+
container.appendChild(cleanNode(nodesArray[i]));
|
|
544
|
+
}
|
|
545
|
+
return container;
|
|
546
|
+
}
|
|
547
|
+
function setDomNodeChildren(domNode, childNodes2) {
|
|
548
|
+
emptyDomNode(domNode);
|
|
549
|
+
if (childNodes2) {
|
|
550
|
+
for (var i = 0, j = childNodes2.length; i < j; i++) {
|
|
551
|
+
domNode.appendChild(childNodes2[i]);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {
|
|
556
|
+
var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
|
|
557
|
+
if (nodesToReplaceArray.length > 0) {
|
|
558
|
+
var insertionPoint = nodesToReplaceArray[0];
|
|
559
|
+
var parent = insertionPoint.parentNode;
|
|
560
|
+
for (var i = 0, j = newNodesArray.length; i < j; i++) {
|
|
561
|
+
parent.insertBefore(newNodesArray[i], insertionPoint);
|
|
562
|
+
}
|
|
563
|
+
for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {
|
|
564
|
+
removeNode(nodesToReplaceArray[i]);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function emptyDomNode(domNode) {
|
|
569
|
+
while (domNode.firstChild) {
|
|
570
|
+
removeNode(domNode.firstChild);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// ../utils/dist/dom/fixes.js
|
|
575
|
+
function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
|
|
576
|
+
if (continuousNodeArray.length) {
|
|
577
|
+
parentNode = parentNode.nodeType === 8 && parentNode.parentNode || parentNode;
|
|
578
|
+
while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {
|
|
579
|
+
continuousNodeArray.splice(0, 1);
|
|
580
|
+
}
|
|
581
|
+
while (continuousNodeArray.length > 1 && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode) {
|
|
582
|
+
continuousNodeArray.length--;
|
|
583
|
+
}
|
|
584
|
+
if (continuousNodeArray.length > 1) {
|
|
585
|
+
var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
|
|
586
|
+
continuousNodeArray.length = 0;
|
|
587
|
+
while (current !== last) {
|
|
588
|
+
continuousNodeArray.push(current);
|
|
589
|
+
current = current.nextSibling;
|
|
590
|
+
}
|
|
591
|
+
continuousNodeArray.push(last);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return continuousNodeArray;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// ../utils/dist/dom/virtualElements.js
|
|
598
|
+
var virtualElements_exports = {};
|
|
599
|
+
__export(virtualElements_exports, {
|
|
600
|
+
allowedBindings: () => allowedBindings,
|
|
601
|
+
childNodes: () => childNodes,
|
|
602
|
+
emptyNode: () => emptyNode,
|
|
603
|
+
endCommentRegex: () => endCommentRegex,
|
|
604
|
+
firstChild: () => firstChild,
|
|
605
|
+
getVirtualChildren: () => getVirtualChildren,
|
|
606
|
+
hasBindingValue: () => hasBindingValue,
|
|
607
|
+
insertAfter: () => insertAfter,
|
|
608
|
+
isEndComment: () => isEndComment,
|
|
609
|
+
isStartComment: () => isStartComment,
|
|
610
|
+
lastChild: () => lastChild,
|
|
611
|
+
nextSibling: () => nextSibling,
|
|
612
|
+
normaliseVirtualElementDomStructure: () => normaliseVirtualElementDomStructure,
|
|
613
|
+
prepend: () => prepend,
|
|
614
|
+
previousSibling: () => previousSibling,
|
|
615
|
+
setDomNodeChildren: () => setDomNodeChildren2,
|
|
616
|
+
startCommentRegex: () => startCommentRegex,
|
|
617
|
+
virtualNodeBindingValue: () => virtualNodeBindingValue
|
|
618
|
+
});
|
|
619
|
+
var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
|
|
620
|
+
var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
|
621
|
+
var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
|
|
622
|
+
var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
|
|
623
|
+
function isStartComment(node) {
|
|
624
|
+
return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
|
|
625
|
+
}
|
|
626
|
+
function isEndComment(node) {
|
|
627
|
+
return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
|
|
628
|
+
}
|
|
629
|
+
function isUnmatchedEndComment(node) {
|
|
630
|
+
return isEndComment(node) && !get(node, matchedEndCommentDataKey);
|
|
631
|
+
}
|
|
632
|
+
var matchedEndCommentDataKey = "__ko_matchedEndComment__";
|
|
633
|
+
function getVirtualChildren(startComment, allowUnbalanced) {
|
|
634
|
+
var currentNode = startComment;
|
|
635
|
+
var depth = 1;
|
|
636
|
+
var children = [];
|
|
637
|
+
while (currentNode = currentNode.nextSibling) {
|
|
638
|
+
if (isEndComment(currentNode)) {
|
|
639
|
+
set(currentNode, matchedEndCommentDataKey, true);
|
|
640
|
+
depth--;
|
|
641
|
+
if (depth === 0) {
|
|
642
|
+
return children;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
children.push(currentNode);
|
|
646
|
+
if (isStartComment(currentNode)) {
|
|
647
|
+
depth++;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (!allowUnbalanced) {
|
|
651
|
+
throw new Error("Cannot find closing comment tag to match: " + startComment.nodeValue);
|
|
652
|
+
}
|
|
653
|
+
return null;
|
|
654
|
+
}
|
|
655
|
+
function getMatchingEndComment(startComment, allowUnbalanced) {
|
|
656
|
+
var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
|
|
657
|
+
if (allVirtualChildren) {
|
|
658
|
+
if (allVirtualChildren.length > 0) {
|
|
659
|
+
return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
|
|
660
|
+
}
|
|
661
|
+
return startComment.nextSibling;
|
|
662
|
+
} else {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function getUnbalancedChildTags(node) {
|
|
667
|
+
var childNode = node.firstChild, captureRemaining = null;
|
|
668
|
+
if (childNode) {
|
|
669
|
+
do {
|
|
670
|
+
if (captureRemaining) {
|
|
671
|
+
captureRemaining.push(childNode);
|
|
672
|
+
} else if (isStartComment(childNode)) {
|
|
673
|
+
var matchingEndComment = getMatchingEndComment(childNode, true);
|
|
674
|
+
if (matchingEndComment) {
|
|
675
|
+
childNode = matchingEndComment;
|
|
676
|
+
} else {
|
|
677
|
+
captureRemaining = [childNode];
|
|
678
|
+
}
|
|
679
|
+
} else if (isEndComment(childNode)) {
|
|
680
|
+
captureRemaining = [childNode];
|
|
681
|
+
}
|
|
682
|
+
} while (childNode = childNode.nextSibling);
|
|
683
|
+
}
|
|
684
|
+
return captureRemaining;
|
|
685
|
+
}
|
|
686
|
+
var allowedBindings = {};
|
|
687
|
+
var hasBindingValue = isStartComment;
|
|
688
|
+
function childNodes(node) {
|
|
689
|
+
return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
|
|
690
|
+
}
|
|
691
|
+
function emptyNode(node) {
|
|
692
|
+
if (!isStartComment(node)) {
|
|
693
|
+
emptyDomNode(node);
|
|
694
|
+
} else {
|
|
695
|
+
var virtualChildren = childNodes(node);
|
|
696
|
+
for (var i = 0, j = virtualChildren.length; i < j; i++) {
|
|
697
|
+
removeNode(virtualChildren[i]);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function setDomNodeChildren2(node, childNodes2) {
|
|
702
|
+
if (!isStartComment(node)) {
|
|
703
|
+
setDomNodeChildren(node, childNodes2);
|
|
704
|
+
} else {
|
|
705
|
+
emptyNode(node);
|
|
706
|
+
const endCommentNode = node.nextSibling;
|
|
707
|
+
const parentNode = endCommentNode.parentNode;
|
|
708
|
+
for (var i = 0, j = childNodes2.length; i < j; ++i) {
|
|
709
|
+
parentNode.insertBefore(childNodes2[i], endCommentNode);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function prepend(containerNode, nodeToPrepend) {
|
|
714
|
+
if (!isStartComment(containerNode)) {
|
|
715
|
+
if (containerNode.firstChild) {
|
|
716
|
+
containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);
|
|
717
|
+
} else {
|
|
718
|
+
containerNode.appendChild(nodeToPrepend);
|
|
719
|
+
}
|
|
720
|
+
} else {
|
|
721
|
+
containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
|
|
725
|
+
if (!insertAfterNode) {
|
|
726
|
+
prepend(containerNode, nodeToInsert);
|
|
727
|
+
} else if (!isStartComment(containerNode)) {
|
|
728
|
+
if (insertAfterNode.nextSibling) {
|
|
729
|
+
containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
|
|
730
|
+
} else {
|
|
731
|
+
containerNode.appendChild(nodeToInsert);
|
|
732
|
+
}
|
|
733
|
+
} else {
|
|
734
|
+
containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
function firstChild(node) {
|
|
738
|
+
if (!isStartComment(node)) {
|
|
739
|
+
if (node.firstChild && isEndComment(node.firstChild)) {
|
|
740
|
+
throw new Error("Found invalid end comment, as the first child of " + node.outerHTML);
|
|
741
|
+
}
|
|
742
|
+
return node.firstChild;
|
|
743
|
+
}
|
|
744
|
+
if (!node.nextSibling || isEndComment(node.nextSibling)) {
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
return node.nextSibling;
|
|
748
|
+
}
|
|
749
|
+
function lastChild(node) {
|
|
750
|
+
let nextChild = firstChild(node);
|
|
751
|
+
let lastChildNode;
|
|
752
|
+
do {
|
|
753
|
+
lastChildNode = nextChild;
|
|
754
|
+
} while (nextChild = nextSibling(nextChild));
|
|
755
|
+
return lastChildNode;
|
|
756
|
+
}
|
|
757
|
+
function nextSibling(node) {
|
|
758
|
+
if (isStartComment(node)) {
|
|
759
|
+
node = getMatchingEndComment(node);
|
|
760
|
+
}
|
|
761
|
+
if (node.nextSibling && isEndComment(node.nextSibling)) {
|
|
762
|
+
if (isUnmatchedEndComment(node.nextSibling)) {
|
|
763
|
+
throw Error("Found end comment without a matching opening comment, as next sibling of " + node.outerHTML);
|
|
764
|
+
}
|
|
765
|
+
return null;
|
|
766
|
+
} else {
|
|
767
|
+
return node.nextSibling;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
function previousSibling(node) {
|
|
771
|
+
var depth = 0;
|
|
772
|
+
do {
|
|
773
|
+
if (node.nodeType === 8) {
|
|
774
|
+
if (isStartComment(node)) {
|
|
775
|
+
if (--depth === 0) {
|
|
776
|
+
return node;
|
|
777
|
+
}
|
|
778
|
+
} else if (isEndComment(node)) {
|
|
779
|
+
depth++;
|
|
780
|
+
}
|
|
781
|
+
} else {
|
|
782
|
+
if (depth === 0) {
|
|
783
|
+
return node;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
} while (node = node.previousSibling);
|
|
787
|
+
}
|
|
788
|
+
function virtualNodeBindingValue(node) {
|
|
789
|
+
var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
|
|
790
|
+
return regexMatch ? regexMatch[1] : null;
|
|
791
|
+
}
|
|
792
|
+
function normaliseVirtualElementDomStructure(elementVerified) {
|
|
793
|
+
if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
var childNode = elementVerified.firstChild;
|
|
797
|
+
if (childNode) {
|
|
798
|
+
do {
|
|
799
|
+
if (childNode.nodeType === 1) {
|
|
800
|
+
var unbalancedTags = getUnbalancedChildTags(childNode);
|
|
801
|
+
if (unbalancedTags) {
|
|
802
|
+
var nodeToInsertBefore = childNode.nextSibling;
|
|
803
|
+
for (var i = 0; i < unbalancedTags.length; i++) {
|
|
804
|
+
if (nodeToInsertBefore) {
|
|
805
|
+
elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
|
|
806
|
+
} else {
|
|
807
|
+
elementVerified.appendChild(unbalancedTags[i]);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
} while (childNode = childNode.nextSibling);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// ../utils/dist/dom/html.js
|
|
817
|
+
var none = [0, "", ""];
|
|
818
|
+
var table = [1, "<table>", "</table>"];
|
|
819
|
+
var tbody = [2, "<table><tbody>", "</tbody></table>"];
|
|
820
|
+
var colgroup = [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"];
|
|
821
|
+
var tr = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
|
|
822
|
+
var select = [1, "<select multiple='multiple'>", "</select>"];
|
|
823
|
+
var fieldset = [1, "<fieldset>", "</fieldset>"];
|
|
824
|
+
var map = [1, "<map>", "</map>"];
|
|
825
|
+
var object = [1, "<object>", "</object>"];
|
|
826
|
+
var lookup = {
|
|
827
|
+
"area": map,
|
|
828
|
+
"col": colgroup,
|
|
829
|
+
"colgroup": table,
|
|
830
|
+
"caption": table,
|
|
831
|
+
"legend": fieldset,
|
|
832
|
+
"thead": table,
|
|
833
|
+
"tbody": table,
|
|
834
|
+
"tfoot": table,
|
|
835
|
+
"tr": tbody,
|
|
836
|
+
"td": tr,
|
|
837
|
+
"th": tr,
|
|
838
|
+
"option": select,
|
|
839
|
+
"optgroup": select,
|
|
840
|
+
"param": object
|
|
841
|
+
};
|
|
842
|
+
var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
|
|
843
|
+
function getWrap(tags) {
|
|
844
|
+
const m = tags.match(/^(?:<!--.*?-->\s*?)*?<([a-z]+)[\s>]/);
|
|
845
|
+
return m && lookup[m[1]] || none;
|
|
846
|
+
}
|
|
847
|
+
function simpleHtmlParse(html, documentContext) {
|
|
848
|
+
documentContext || (documentContext = document);
|
|
849
|
+
var windowContext = documentContext["parentWindow"] || documentContext["defaultView"] || window;
|
|
850
|
+
var tags = stringTrim(html).toLowerCase(), div = documentContext.createElement("div"), wrap = getWrap(tags), depth = wrap[0];
|
|
851
|
+
var markup = "ignored<div>" + wrap[1] + html + wrap[2] + "</div>";
|
|
852
|
+
if (typeof windowContext["innerShiv"] === "function") {
|
|
853
|
+
div.appendChild(windowContext["innerShiv"](markup));
|
|
854
|
+
} else {
|
|
855
|
+
div.innerHTML = markup;
|
|
856
|
+
}
|
|
857
|
+
while (depth--) {
|
|
858
|
+
div = div.lastChild;
|
|
859
|
+
}
|
|
860
|
+
return makeArray(div.lastChild.childNodes);
|
|
861
|
+
}
|
|
862
|
+
function templateHtmlParse(html, documentContext) {
|
|
863
|
+
if (!documentContext) {
|
|
864
|
+
documentContext = document;
|
|
865
|
+
}
|
|
866
|
+
var template = documentContext.createElement("template");
|
|
867
|
+
template.innerHTML = html;
|
|
868
|
+
return makeArray(template.content.childNodes);
|
|
869
|
+
}
|
|
870
|
+
function jQueryHtmlParse(html, documentContext) {
|
|
871
|
+
if (jQueryInstance.parseHTML) {
|
|
872
|
+
return jQueryInstance.parseHTML(html, documentContext) || [];
|
|
873
|
+
} else {
|
|
874
|
+
var elems = jQueryInstance.clean([html], documentContext);
|
|
875
|
+
if (elems && elems[0]) {
|
|
876
|
+
var elem = elems[0];
|
|
877
|
+
while (elem.parentNode && elem.parentNode.nodeType !== 11) {
|
|
878
|
+
elem = elem.parentNode;
|
|
879
|
+
}
|
|
880
|
+
if (elem.parentNode) {
|
|
881
|
+
elem.parentNode.removeChild(elem);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return elems;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
function parseHtmlFragment(html, documentContext) {
|
|
888
|
+
return supportsTemplateTag ? templateHtmlParse(html, documentContext) : jQueryInstance ? jQueryHtmlParse(html, documentContext) : simpleHtmlParse(html, documentContext);
|
|
889
|
+
}
|
|
890
|
+
function parseHtmlForTemplateNodes(html, documentContext) {
|
|
891
|
+
const nodes = parseHtmlFragment(html, documentContext);
|
|
892
|
+
return nodes.length && nodes[0].parentElement || moveCleanedNodesToContainerElement(nodes);
|
|
893
|
+
}
|
|
894
|
+
function setHtml(node, html) {
|
|
895
|
+
emptyDomNode(node);
|
|
896
|
+
if (typeof html === "function") {
|
|
897
|
+
html = html();
|
|
898
|
+
}
|
|
899
|
+
if (html !== null && html !== void 0) {
|
|
900
|
+
if (typeof html !== "string") {
|
|
901
|
+
html = html.toString();
|
|
902
|
+
}
|
|
903
|
+
if (jQueryInstance && !supportsTemplateTag) {
|
|
904
|
+
jQueryInstance(node).html(html);
|
|
905
|
+
} else {
|
|
906
|
+
var parsedNodes = parseHtmlFragment(html, node.ownerDocument);
|
|
907
|
+
if (node.nodeType === 8) {
|
|
908
|
+
if (html === null) {
|
|
909
|
+
emptyNode(node);
|
|
910
|
+
} else {
|
|
911
|
+
setDomNodeChildren2(node, parsedNodes);
|
|
912
|
+
}
|
|
913
|
+
} else {
|
|
914
|
+
for (var i = 0; i < parsedNodes.length; i++) {
|
|
915
|
+
node.appendChild(parsedNodes[i]);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// ../utils/dist/dom/selectExtensions.js
|
|
923
|
+
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
924
|
+
var selectExtensions = {
|
|
925
|
+
optionValueDomDataKey: nextKey(),
|
|
926
|
+
readValue: function(element) {
|
|
927
|
+
switch (tagNameLower(element)) {
|
|
928
|
+
case "option":
|
|
929
|
+
if (element[hasDomDataExpandoProperty] === true) {
|
|
930
|
+
return get(element, selectExtensions.optionValueDomDataKey);
|
|
931
|
+
}
|
|
932
|
+
return element.value;
|
|
933
|
+
case "select":
|
|
934
|
+
return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
|
|
935
|
+
default:
|
|
936
|
+
return element.value;
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
writeValue: function(element, value, allowUnset) {
|
|
940
|
+
switch (tagNameLower(element)) {
|
|
941
|
+
case "option":
|
|
942
|
+
if (typeof value === "string") {
|
|
943
|
+
set(element, selectExtensions.optionValueDomDataKey, void 0);
|
|
944
|
+
if (hasDomDataExpandoProperty in element) {
|
|
945
|
+
delete element[hasDomDataExpandoProperty];
|
|
946
|
+
}
|
|
947
|
+
element.value = value;
|
|
948
|
+
} else {
|
|
949
|
+
set(element, selectExtensions.optionValueDomDataKey, value);
|
|
950
|
+
element[hasDomDataExpandoProperty] = true;
|
|
951
|
+
element.value = typeof value === "number" ? value : "";
|
|
952
|
+
}
|
|
953
|
+
break;
|
|
954
|
+
case "select":
|
|
955
|
+
if (value === "" || value === null) {
|
|
956
|
+
value = void 0;
|
|
957
|
+
}
|
|
958
|
+
var selection = -1;
|
|
959
|
+
for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
|
|
960
|
+
optionValue = selectExtensions.readValue(element.options[i]);
|
|
961
|
+
const strictEqual = optionValue === value;
|
|
962
|
+
const blankEqual = optionValue === "" && value === void 0;
|
|
963
|
+
const numericEqual = typeof value === "number" && Number(optionValue) === value;
|
|
964
|
+
if (strictEqual || blankEqual || numericEqual) {
|
|
965
|
+
selection = i;
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
|
|
970
|
+
element.selectedIndex = selection;
|
|
971
|
+
}
|
|
972
|
+
break;
|
|
973
|
+
default:
|
|
974
|
+
if (value === null || value === void 0) {
|
|
975
|
+
value = "";
|
|
976
|
+
}
|
|
977
|
+
element.value = value;
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
// ../utils/dist/memoization.js
|
|
984
|
+
var memoization_exports = {};
|
|
985
|
+
__export(memoization_exports, {
|
|
986
|
+
memoize: () => memoize,
|
|
987
|
+
parseMemoText: () => parseMemoText,
|
|
988
|
+
unmemoize: () => unmemoize,
|
|
989
|
+
unmemoizeDomNodeAndDescendants: () => unmemoizeDomNodeAndDescendants
|
|
990
|
+
});
|
|
991
|
+
var memos = {};
|
|
992
|
+
function randomMax8HexChars() {
|
|
993
|
+
return ((1 + Math.random()) * 4294967296 | 0).toString(16).substring(1);
|
|
994
|
+
}
|
|
995
|
+
function generateRandomId() {
|
|
996
|
+
return randomMax8HexChars() + randomMax8HexChars();
|
|
997
|
+
}
|
|
998
|
+
function findMemoNodes(rootNode, appendToArray) {
|
|
999
|
+
if (!rootNode) {
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
if (rootNode.nodeType == 8) {
|
|
1003
|
+
var memoId = parseMemoText(rootNode.nodeValue);
|
|
1004
|
+
if (memoId != null) {
|
|
1005
|
+
appendToArray.push({ domNode: rootNode, memoId });
|
|
1006
|
+
}
|
|
1007
|
+
} else if (rootNode.nodeType == 1) {
|
|
1008
|
+
for (var i = 0, childNodes2 = rootNode.childNodes, j = childNodes2.length; i < j; i++) {
|
|
1009
|
+
findMemoNodes(childNodes2[i], appendToArray);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
function memoize(callback) {
|
|
1014
|
+
if (typeof callback !== "function") {
|
|
1015
|
+
throw new Error("You can only pass a function to memoization.memoize()");
|
|
1016
|
+
}
|
|
1017
|
+
var memoId = generateRandomId();
|
|
1018
|
+
memos[memoId] = callback;
|
|
1019
|
+
return "<!--[ko_memo:" + memoId + "]-->";
|
|
1020
|
+
}
|
|
1021
|
+
function unmemoize(memoId, callbackParams) {
|
|
1022
|
+
var callback = memos[memoId];
|
|
1023
|
+
if (callback === void 0) {
|
|
1024
|
+
throw new Error("Couldn't find any memo with ID " + memoId + ". Perhaps it's already been unmemoized.");
|
|
1025
|
+
}
|
|
1026
|
+
try {
|
|
1027
|
+
callback.apply(null, callbackParams || []);
|
|
1028
|
+
return true;
|
|
1029
|
+
} finally {
|
|
1030
|
+
delete memos[memoId];
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
function unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray) {
|
|
1034
|
+
var memos2 = [];
|
|
1035
|
+
findMemoNodes(domNode, memos2);
|
|
1036
|
+
for (var i = 0, j = memos2.length; i < j; i++) {
|
|
1037
|
+
var node = memos2[i].domNode;
|
|
1038
|
+
var combinedParams = [node];
|
|
1039
|
+
if (extraCallbackParamsArray) {
|
|
1040
|
+
arrayPushAll(combinedParams, extraCallbackParamsArray);
|
|
1041
|
+
}
|
|
1042
|
+
unmemoize(memos2[i].memoId, combinedParams);
|
|
1043
|
+
node.nodeValue = "";
|
|
1044
|
+
if (node.parentNode) {
|
|
1045
|
+
node.parentNode.removeChild(node);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function parseMemoText(memoText) {
|
|
1050
|
+
var match = memoText.match(/^\[ko_memo\:(.*?)\]$/);
|
|
1051
|
+
return match ? match[1] : null;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// ../utils/dist/tasks.js
|
|
1055
|
+
var tasks_exports = {};
|
|
1056
|
+
__export(tasks_exports, {
|
|
1057
|
+
cancel: () => cancel,
|
|
1058
|
+
resetForTesting: () => resetForTesting,
|
|
1059
|
+
runEarly: () => processTasks,
|
|
1060
|
+
schedule: () => schedule
|
|
1061
|
+
});
|
|
1062
|
+
var taskQueue = [];
|
|
1063
|
+
var taskQueueLength = 0;
|
|
1064
|
+
var nextHandle = 1;
|
|
1065
|
+
var nextIndexToProcess = 0;
|
|
1066
|
+
var w = options_default.global;
|
|
1067
|
+
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
1068
|
+
options_default.taskScheduler = function(callback) {
|
|
1069
|
+
var div = w.document.createElement("div");
|
|
1070
|
+
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
1071
|
+
return function() {
|
|
1072
|
+
div.classList.toggle("foo");
|
|
1073
|
+
};
|
|
1074
|
+
}(scheduledProcess);
|
|
1075
|
+
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
|
|
1076
|
+
options_default.taskScheduler = function(callback) {
|
|
1077
|
+
var script = document.createElement("script");
|
|
1078
|
+
script.onreadystatechange = function() {
|
|
1079
|
+
script.onreadystatechange = null;
|
|
1080
|
+
document.documentElement.removeChild(script);
|
|
1081
|
+
script = null;
|
|
1082
|
+
callback();
|
|
1083
|
+
};
|
|
1084
|
+
document.documentElement.appendChild(script);
|
|
1085
|
+
};
|
|
1086
|
+
} else {
|
|
1087
|
+
options_default.taskScheduler = function(callback) {
|
|
1088
|
+
setTimeout(callback, 0);
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
function processTasks() {
|
|
1092
|
+
if (taskQueueLength) {
|
|
1093
|
+
var mark = taskQueueLength, countMarks = 0;
|
|
1094
|
+
for (var task; nextIndexToProcess < taskQueueLength; ) {
|
|
1095
|
+
if (task = taskQueue[nextIndexToProcess++]) {
|
|
1096
|
+
if (nextIndexToProcess > mark) {
|
|
1097
|
+
if (++countMarks >= 5e3) {
|
|
1098
|
+
nextIndexToProcess = taskQueueLength;
|
|
1099
|
+
deferError(Error("'Too much recursion' after processing " + countMarks + " task groups."));
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
mark = taskQueueLength;
|
|
1103
|
+
}
|
|
1104
|
+
try {
|
|
1105
|
+
task();
|
|
1106
|
+
} catch (ex) {
|
|
1107
|
+
deferError(ex);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
function scheduledProcess() {
|
|
1114
|
+
processTasks();
|
|
1115
|
+
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
1116
|
+
}
|
|
1117
|
+
function scheduleTaskProcessing() {
|
|
1118
|
+
options_default.taskScheduler(scheduledProcess);
|
|
1119
|
+
}
|
|
1120
|
+
function schedule(func) {
|
|
1121
|
+
if (!taskQueueLength) {
|
|
1122
|
+
scheduleTaskProcessing();
|
|
1123
|
+
}
|
|
1124
|
+
taskQueue[taskQueueLength++] = func;
|
|
1125
|
+
return nextHandle++;
|
|
1126
|
+
}
|
|
1127
|
+
function cancel(handle) {
|
|
1128
|
+
var index = handle - (nextHandle - taskQueueLength);
|
|
1129
|
+
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
1130
|
+
taskQueue[index] = null;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
function resetForTesting() {
|
|
1134
|
+
var length = taskQueueLength - nextIndexToProcess;
|
|
1135
|
+
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
1136
|
+
return length;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// ../observable/dist/dependencyDetection.js
|
|
1140
|
+
var dependencyDetection_exports = {};
|
|
1141
|
+
__export(dependencyDetection_exports, {
|
|
1142
|
+
begin: () => begin,
|
|
1143
|
+
end: () => end,
|
|
1144
|
+
getDependencies: () => getDependencies,
|
|
1145
|
+
getDependenciesCount: () => getDependenciesCount,
|
|
1146
|
+
ignore: () => ignore,
|
|
1147
|
+
ignoreDependencies: () => ignore,
|
|
1148
|
+
isInitial: () => isInitial,
|
|
1149
|
+
registerDependency: () => registerDependency
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
// ../observable/dist/subscribableSymbol.js
|
|
1153
|
+
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
|
|
1154
|
+
function isSubscribable(instance) {
|
|
1155
|
+
return instance && instance[SUBSCRIBABLE_SYM] || false;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// ../observable/dist/dependencyDetection.js
|
|
1159
|
+
var outerFrames = [];
|
|
1160
|
+
var currentFrame;
|
|
1161
|
+
var lastId = 0;
|
|
1162
|
+
function getId() {
|
|
1163
|
+
return ++lastId;
|
|
1164
|
+
}
|
|
1165
|
+
function begin(options3) {
|
|
1166
|
+
outerFrames.push(currentFrame);
|
|
1167
|
+
currentFrame = options3;
|
|
1168
|
+
}
|
|
1169
|
+
function end() {
|
|
1170
|
+
currentFrame = outerFrames.pop();
|
|
1171
|
+
}
|
|
1172
|
+
function registerDependency(subscribable2) {
|
|
1173
|
+
if (currentFrame) {
|
|
1174
|
+
if (!isSubscribable(subscribable2)) {
|
|
1175
|
+
throw new Error("Only subscribable things can act as dependencies");
|
|
1176
|
+
}
|
|
1177
|
+
currentFrame.callback.call(currentFrame.callbackTarget, subscribable2, subscribable2._id || (subscribable2._id = getId()));
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function ignore(callback, callbackTarget, callbackArgs) {
|
|
1181
|
+
try {
|
|
1182
|
+
begin();
|
|
1183
|
+
return callback.apply(callbackTarget, callbackArgs || []);
|
|
1184
|
+
} finally {
|
|
1185
|
+
end();
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function getDependenciesCount() {
|
|
1189
|
+
if (currentFrame) {
|
|
1190
|
+
return currentFrame.computed.getDependenciesCount();
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function getDependencies() {
|
|
1194
|
+
if (currentFrame) {
|
|
1195
|
+
return currentFrame.computed.getDependencies();
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
function isInitial() {
|
|
1199
|
+
if (currentFrame) {
|
|
1200
|
+
return currentFrame.isInitial;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// ../observable/dist/defer.js
|
|
1205
|
+
function deferUpdates(target) {
|
|
1206
|
+
if (target._deferUpdates) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
target._deferUpdates = true;
|
|
1210
|
+
target.limit(function(callback) {
|
|
1211
|
+
let handle;
|
|
1212
|
+
let ignoreUpdates = false;
|
|
1213
|
+
return function() {
|
|
1214
|
+
if (!ignoreUpdates) {
|
|
1215
|
+
tasks_exports.cancel(handle);
|
|
1216
|
+
handle = tasks_exports.schedule(callback);
|
|
1217
|
+
try {
|
|
1218
|
+
ignoreUpdates = true;
|
|
1219
|
+
target.notifySubscribers(void 0, "dirty");
|
|
1220
|
+
} finally {
|
|
1221
|
+
ignoreUpdates = false;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
// ../observable/dist/Subscription.js
|
|
1229
|
+
var Subscription = class {
|
|
1230
|
+
constructor(target, observer, disposeCallback) {
|
|
1231
|
+
this._target = target;
|
|
1232
|
+
this._callback = observer.next;
|
|
1233
|
+
this._disposeCallback = disposeCallback;
|
|
1234
|
+
this._isDisposed = false;
|
|
1235
|
+
this._domNodeDisposalCallback = null;
|
|
1236
|
+
}
|
|
1237
|
+
dispose() {
|
|
1238
|
+
if (this._domNodeDisposalCallback) {
|
|
1239
|
+
removeDisposeCallback(this._node, this._domNodeDisposalCallback);
|
|
1240
|
+
}
|
|
1241
|
+
this._isDisposed = true;
|
|
1242
|
+
this._disposeCallback();
|
|
1243
|
+
}
|
|
1244
|
+
disposeWhenNodeIsRemoved(node) {
|
|
1245
|
+
this._node = node;
|
|
1246
|
+
addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
|
|
1247
|
+
}
|
|
1248
|
+
unsubscribe() {
|
|
1249
|
+
this.dispose();
|
|
1250
|
+
}
|
|
1251
|
+
get closed() {
|
|
1252
|
+
return this._isDisposed;
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
// ../observable/dist/extenders.js
|
|
1257
|
+
var primitiveTypes = {
|
|
1258
|
+
"undefined": 1,
|
|
1259
|
+
"boolean": 1,
|
|
1260
|
+
"number": 1,
|
|
1261
|
+
"string": 1
|
|
1262
|
+
};
|
|
1263
|
+
function valuesArePrimitiveAndEqual(a, b) {
|
|
1264
|
+
var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
|
|
1265
|
+
return oldValueIsPrimitive ? a === b : false;
|
|
1266
|
+
}
|
|
1267
|
+
function applyExtenders(requestedExtenders) {
|
|
1268
|
+
var target = this;
|
|
1269
|
+
if (requestedExtenders) {
|
|
1270
|
+
objectForEach(requestedExtenders, function(key, value) {
|
|
1271
|
+
var extenderHandler = extenders[key];
|
|
1272
|
+
if (typeof extenderHandler === "function") {
|
|
1273
|
+
target = extenderHandler(target, value) || target;
|
|
1274
|
+
} else {
|
|
1275
|
+
options_default.onError(new Error("Extender not found: " + key));
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
return target;
|
|
1280
|
+
}
|
|
1281
|
+
function notify(target, notifyWhen) {
|
|
1282
|
+
target.equalityComparer = notifyWhen == "always" ? null : valuesArePrimitiveAndEqual;
|
|
1283
|
+
}
|
|
1284
|
+
function deferred(target, option) {
|
|
1285
|
+
if (option !== true) {
|
|
1286
|
+
throw new Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");
|
|
1287
|
+
}
|
|
1288
|
+
deferUpdates(target);
|
|
1289
|
+
}
|
|
1290
|
+
function rateLimit(target, options22) {
|
|
1291
|
+
var timeout, method, limitFunction;
|
|
1292
|
+
if (typeof options22 === "number") {
|
|
1293
|
+
timeout = options22;
|
|
1294
|
+
} else {
|
|
1295
|
+
timeout = options22.timeout;
|
|
1296
|
+
method = options22.method;
|
|
1297
|
+
}
|
|
1298
|
+
target._deferUpdates = false;
|
|
1299
|
+
limitFunction = method === "notifyWhenChangesStop" ? debounce : throttle;
|
|
1300
|
+
target.limit(function(callback) {
|
|
1301
|
+
return limitFunction(callback, timeout);
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
var extenders = {
|
|
1305
|
+
notify,
|
|
1306
|
+
deferred,
|
|
1307
|
+
rateLimit
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
// ../observable/dist/subscribable.js
|
|
1311
|
+
var LATEST_VALUE = Symbol("Knockout latest value");
|
|
1312
|
+
if (!Symbol.observable) {
|
|
1313
|
+
Symbol.observable = Symbol.for("@tko/Symbol.observable");
|
|
1314
|
+
}
|
|
1315
|
+
function subscribable() {
|
|
1316
|
+
Object.setPrototypeOf(this, ko_subscribable_fn);
|
|
1317
|
+
ko_subscribable_fn.init(this);
|
|
1318
|
+
}
|
|
1319
|
+
var defaultEvent = "change";
|
|
1320
|
+
var ko_subscribable_fn = {
|
|
1321
|
+
[SUBSCRIBABLE_SYM]: true,
|
|
1322
|
+
[Symbol.observable]() {
|
|
1323
|
+
return this;
|
|
1324
|
+
},
|
|
1325
|
+
init(instance) {
|
|
1326
|
+
instance._subscriptions = { change: [] };
|
|
1327
|
+
instance._versionNumber = 1;
|
|
1328
|
+
},
|
|
1329
|
+
subscribe(callback, callbackTarget, event) {
|
|
1330
|
+
const isTC39Callback = typeof callback === "object" && callback.next;
|
|
1331
|
+
event = event || defaultEvent;
|
|
1332
|
+
const observer = isTC39Callback ? callback : {
|
|
1333
|
+
next: callbackTarget ? callback.bind(callbackTarget) : callback
|
|
1334
|
+
};
|
|
1335
|
+
const subscriptionInstance = new Subscription(this, observer, () => {
|
|
1336
|
+
arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
|
|
1337
|
+
if (this.afterSubscriptionRemove) {
|
|
1338
|
+
this.afterSubscriptionRemove(event);
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
if (this.beforeSubscriptionAdd) {
|
|
1342
|
+
this.beforeSubscriptionAdd(event);
|
|
1343
|
+
}
|
|
1344
|
+
if (!this._subscriptions[event]) {
|
|
1345
|
+
this._subscriptions[event] = [];
|
|
1346
|
+
}
|
|
1347
|
+
this._subscriptions[event].push(subscriptionInstance);
|
|
1348
|
+
if (isTC39Callback && LATEST_VALUE in this) {
|
|
1349
|
+
observer.next(this[LATEST_VALUE]);
|
|
1350
|
+
}
|
|
1351
|
+
return subscriptionInstance;
|
|
1352
|
+
},
|
|
1353
|
+
notifySubscribers(valueToNotify, event) {
|
|
1354
|
+
event = event || defaultEvent;
|
|
1355
|
+
if (event === defaultEvent) {
|
|
1356
|
+
this.updateVersion();
|
|
1357
|
+
}
|
|
1358
|
+
if (this.hasSubscriptionsForEvent(event)) {
|
|
1359
|
+
const subs = event === defaultEvent && this._changeSubscriptions || [...this._subscriptions[event]];
|
|
1360
|
+
try {
|
|
1361
|
+
begin();
|
|
1362
|
+
for (let i = 0, subscriptionInstance; subscriptionInstance = subs[i]; ++i) {
|
|
1363
|
+
if (!subscriptionInstance._isDisposed) {
|
|
1364
|
+
subscriptionInstance._callback(valueToNotify);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
} finally {
|
|
1368
|
+
end();
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
},
|
|
1372
|
+
getVersion() {
|
|
1373
|
+
return this._versionNumber;
|
|
1374
|
+
},
|
|
1375
|
+
hasChanged(versionToCheck) {
|
|
1376
|
+
return this.getVersion() !== versionToCheck;
|
|
1377
|
+
},
|
|
1378
|
+
updateVersion() {
|
|
1379
|
+
++this._versionNumber;
|
|
1380
|
+
},
|
|
1381
|
+
hasSubscriptionsForEvent(event) {
|
|
1382
|
+
return this._subscriptions[event] && this._subscriptions[event].length;
|
|
1383
|
+
},
|
|
1384
|
+
getSubscriptionsCount(event) {
|
|
1385
|
+
if (event) {
|
|
1386
|
+
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
|
1387
|
+
} else {
|
|
1388
|
+
var total = 0;
|
|
1389
|
+
objectForEach(this._subscriptions, function(eventName, subscriptions) {
|
|
1390
|
+
if (eventName !== "dirty") {
|
|
1391
|
+
total += subscriptions.length;
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
return total;
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
isDifferent(oldValue, newValue) {
|
|
1398
|
+
return !this.equalityComparer || !this.equalityComparer(oldValue, newValue);
|
|
1399
|
+
},
|
|
1400
|
+
once(cb) {
|
|
1401
|
+
const subs = this.subscribe((nv) => {
|
|
1402
|
+
subs.dispose();
|
|
1403
|
+
cb(nv);
|
|
1404
|
+
});
|
|
1405
|
+
},
|
|
1406
|
+
when(test, returnValue) {
|
|
1407
|
+
const current = this.peek();
|
|
1408
|
+
const givenRv = arguments.length > 1;
|
|
1409
|
+
const testFn = typeof test === "function" ? test : (v) => v === test;
|
|
1410
|
+
if (testFn(current)) {
|
|
1411
|
+
return options_default.Promise.resolve(givenRv ? returnValue : current);
|
|
1412
|
+
}
|
|
1413
|
+
return new options_default.Promise((resolve, reject) => {
|
|
1414
|
+
const subs = this.subscribe((newValue) => {
|
|
1415
|
+
if (testFn(newValue)) {
|
|
1416
|
+
subs.dispose();
|
|
1417
|
+
resolve(givenRv ? returnValue : newValue);
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
});
|
|
1421
|
+
},
|
|
1422
|
+
yet(test, ...args) {
|
|
1423
|
+
const testFn = typeof test === "function" ? test : (v) => v === test;
|
|
1424
|
+
const negated = (v) => !testFn(v);
|
|
1425
|
+
return this.when(negated, ...args);
|
|
1426
|
+
},
|
|
1427
|
+
next() {
|
|
1428
|
+
return new Promise((resolve) => this.once(resolve));
|
|
1429
|
+
},
|
|
1430
|
+
toString() {
|
|
1431
|
+
return "[object Object]";
|
|
1432
|
+
},
|
|
1433
|
+
extend: applyExtenders
|
|
1434
|
+
};
|
|
1435
|
+
Object.setPrototypeOf(ko_subscribable_fn, Function.prototype);
|
|
1436
|
+
subscribable.fn = ko_subscribable_fn;
|
|
1437
|
+
|
|
1438
|
+
// ../observable/dist/observable.js
|
|
1439
|
+
function observable(initialValue) {
|
|
1440
|
+
function Observable() {
|
|
1441
|
+
if (arguments.length > 0) {
|
|
1442
|
+
if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
|
|
1443
|
+
Observable.valueWillMutate();
|
|
1444
|
+
Observable[LATEST_VALUE] = arguments[0];
|
|
1445
|
+
Observable.valueHasMutated();
|
|
1446
|
+
}
|
|
1447
|
+
return this;
|
|
1448
|
+
} else {
|
|
1449
|
+
registerDependency(Observable);
|
|
1450
|
+
return Observable[LATEST_VALUE];
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
overwriteLengthPropertyIfSupported(Observable, { value: void 0 });
|
|
1454
|
+
Observable[LATEST_VALUE] = initialValue;
|
|
1455
|
+
subscribable.fn.init(Observable);
|
|
1456
|
+
Object.setPrototypeOf(Observable, observable.fn);
|
|
1457
|
+
if (options_default.deferUpdates) {
|
|
1458
|
+
deferUpdates(Observable);
|
|
1459
|
+
}
|
|
1460
|
+
return Observable;
|
|
1461
|
+
}
|
|
1462
|
+
observable.fn = {
|
|
1463
|
+
equalityComparer: valuesArePrimitiveAndEqual,
|
|
1464
|
+
peek() {
|
|
1465
|
+
return this[LATEST_VALUE];
|
|
1466
|
+
},
|
|
1467
|
+
valueHasMutated() {
|
|
1468
|
+
this.notifySubscribers(this[LATEST_VALUE], "spectate");
|
|
1469
|
+
this.notifySubscribers(this[LATEST_VALUE]);
|
|
1470
|
+
},
|
|
1471
|
+
valueWillMutate() {
|
|
1472
|
+
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
|
|
1473
|
+
},
|
|
1474
|
+
modify(fn, peek22 = true) {
|
|
1475
|
+
return this(fn(peek22 ? this.peek() : this()));
|
|
1476
|
+
},
|
|
1477
|
+
isWriteable: true
|
|
1478
|
+
};
|
|
1479
|
+
function limitNotifySubscribers(value, event) {
|
|
1480
|
+
if (!event || event === defaultEvent) {
|
|
1481
|
+
this._limitChange(value);
|
|
1482
|
+
} else if (event === "beforeChange") {
|
|
1483
|
+
this._limitBeforeChange(value);
|
|
1484
|
+
} else {
|
|
1485
|
+
this._origNotifySubscribers(value, event);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
subscribable.fn.limit = function limit(limitFunction) {
|
|
1489
|
+
var self = this;
|
|
1490
|
+
var selfIsObservable = isObservable(self);
|
|
1491
|
+
var beforeChange = "beforeChange";
|
|
1492
|
+
var ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
|
|
1493
|
+
if (!self._origNotifySubscribers) {
|
|
1494
|
+
self._origNotifySubscribers = self.notifySubscribers;
|
|
1495
|
+
self.notifySubscribers = limitNotifySubscribers;
|
|
1496
|
+
}
|
|
1497
|
+
var finish = limitFunction(function() {
|
|
1498
|
+
self._notificationIsPending = false;
|
|
1499
|
+
if (selfIsObservable && pendingValue === self) {
|
|
1500
|
+
pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
|
|
1501
|
+
}
|
|
1502
|
+
const shouldNotify = notifyNextChange || didUpdate && self.isDifferent(previousValue, pendingValue);
|
|
1503
|
+
self._notifyNextChange = didUpdate = ignoreBeforeChange = false;
|
|
1504
|
+
if (shouldNotify) {
|
|
1505
|
+
self._origNotifySubscribers(previousValue = pendingValue);
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
Object.assign(self, {
|
|
1509
|
+
_limitChange(value, isDirty) {
|
|
1510
|
+
if (!isDirty || !self._notificationIsPending) {
|
|
1511
|
+
didUpdate = !isDirty;
|
|
1512
|
+
}
|
|
1513
|
+
self._changeSubscriptions = [...self._subscriptions[defaultEvent]];
|
|
1514
|
+
self._notificationIsPending = ignoreBeforeChange = true;
|
|
1515
|
+
pendingValue = value;
|
|
1516
|
+
finish();
|
|
1517
|
+
},
|
|
1518
|
+
_limitBeforeChange(value) {
|
|
1519
|
+
if (!ignoreBeforeChange) {
|
|
1520
|
+
previousValue = value;
|
|
1521
|
+
self._origNotifySubscribers(value, beforeChange);
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
_notifyNextChangeIfValueIsDifferent() {
|
|
1525
|
+
if (self.isDifferent(previousValue, self.peek(true))) {
|
|
1526
|
+
notifyNextChange = true;
|
|
1527
|
+
}
|
|
1528
|
+
},
|
|
1529
|
+
_recordUpdate() {
|
|
1530
|
+
didUpdate = true;
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
};
|
|
1534
|
+
Object.setPrototypeOf(observable.fn, subscribable.fn);
|
|
1535
|
+
var protoProperty = observable.protoProperty = options_default.protoProperty;
|
|
1536
|
+
observable.fn[protoProperty] = observable;
|
|
1537
|
+
observable.observablePrototypes = /* @__PURE__ */ new Set([observable]);
|
|
1538
|
+
function isObservable(instance) {
|
|
1539
|
+
const proto = typeof instance === "function" && instance[protoProperty];
|
|
1540
|
+
if (proto && !observable.observablePrototypes.has(proto)) {
|
|
1541
|
+
throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");
|
|
1542
|
+
}
|
|
1543
|
+
return !!proto;
|
|
1544
|
+
}
|
|
1545
|
+
function unwrap(value) {
|
|
1546
|
+
return isObservable(value) ? value() : value;
|
|
1547
|
+
}
|
|
1548
|
+
function peek(value) {
|
|
1549
|
+
return isObservable(value) ? value.peek() : value;
|
|
1550
|
+
}
|
|
1551
|
+
function isWriteableObservable(instance) {
|
|
1552
|
+
return isObservable(instance) && instance.isWriteable;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
// ../observable/dist/observableArray.changeTracking.js
|
|
1556
|
+
var arrayChangeEventName = "arrayChange";
|
|
1557
|
+
function trackArrayChanges(target, options3) {
|
|
1558
|
+
target.compareArrayOptions = {};
|
|
1559
|
+
if (options3 && typeof options3 === "object") {
|
|
1560
|
+
extend(target.compareArrayOptions, options3);
|
|
1561
|
+
}
|
|
1562
|
+
target.compareArrayOptions.sparse = true;
|
|
1563
|
+
if (target.cacheDiffForKnownOperation) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
let trackingChanges = false;
|
|
1567
|
+
let cachedDiff = null;
|
|
1568
|
+
let arrayChangeSubscription;
|
|
1569
|
+
let pendingNotifications = 0;
|
|
1570
|
+
let underlyingNotifySubscribersFunction;
|
|
1571
|
+
let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
|
|
1572
|
+
let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
|
|
1573
|
+
target.beforeSubscriptionAdd = function(event) {
|
|
1574
|
+
if (underlyingBeforeSubscriptionAddFunction) {
|
|
1575
|
+
underlyingBeforeSubscriptionAddFunction.call(target, event);
|
|
1576
|
+
}
|
|
1577
|
+
if (event === arrayChangeEventName) {
|
|
1578
|
+
trackChanges();
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
target.afterSubscriptionRemove = function(event) {
|
|
1582
|
+
if (underlyingAfterSubscriptionRemoveFunction) {
|
|
1583
|
+
underlyingAfterSubscriptionRemoveFunction.call(target, event);
|
|
1584
|
+
}
|
|
1585
|
+
if (event === arrayChangeEventName && !target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1586
|
+
if (underlyingNotifySubscribersFunction) {
|
|
1587
|
+
target.notifySubscribers = underlyingNotifySubscribersFunction;
|
|
1588
|
+
underlyingNotifySubscribersFunction = void 0;
|
|
1589
|
+
}
|
|
1590
|
+
if (arrayChangeSubscription) {
|
|
1591
|
+
arrayChangeSubscription.dispose();
|
|
1592
|
+
}
|
|
1593
|
+
arrayChangeSubscription = null;
|
|
1594
|
+
trackingChanges = false;
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
function trackChanges() {
|
|
1598
|
+
if (trackingChanges) {
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
trackingChanges = true;
|
|
1602
|
+
underlyingNotifySubscribersFunction = target["notifySubscribers"];
|
|
1603
|
+
target.notifySubscribers = function(valueToNotify, event) {
|
|
1604
|
+
if (!event || event === defaultEvent) {
|
|
1605
|
+
++pendingNotifications;
|
|
1606
|
+
}
|
|
1607
|
+
return underlyingNotifySubscribersFunction.apply(this, arguments);
|
|
1608
|
+
};
|
|
1609
|
+
var previousContents = [].concat(target.peek() === void 0 ? [] : target.peek());
|
|
1610
|
+
cachedDiff = null;
|
|
1611
|
+
arrayChangeSubscription = target.subscribe(function(currentContents) {
|
|
1612
|
+
let changes;
|
|
1613
|
+
currentContents = [].concat(currentContents || []);
|
|
1614
|
+
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1615
|
+
changes = getChanges(previousContents, currentContents);
|
|
1616
|
+
}
|
|
1617
|
+
previousContents = currentContents;
|
|
1618
|
+
cachedDiff = null;
|
|
1619
|
+
pendingNotifications = 0;
|
|
1620
|
+
if (changes && changes.length) {
|
|
1621
|
+
target.notifySubscribers(changes, arrayChangeEventName);
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
function getChanges(previousContents, currentContents) {
|
|
1626
|
+
if (!cachedDiff || pendingNotifications > 1) {
|
|
1627
|
+
cachedDiff = trackArrayChanges.compareArrays(previousContents, currentContents, target.compareArrayOptions);
|
|
1628
|
+
}
|
|
1629
|
+
return cachedDiff;
|
|
1630
|
+
}
|
|
1631
|
+
target.cacheDiffForKnownOperation = function(rawArray, operationName, args) {
|
|
1632
|
+
if (!trackingChanges || pendingNotifications) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
var diff = [], arrayLength = rawArray.length, argsLength = args.length, offset = 0;
|
|
1636
|
+
function pushDiff(status, value, index) {
|
|
1637
|
+
return diff[diff.length] = { "status": status, "value": value, "index": index };
|
|
1638
|
+
}
|
|
1639
|
+
switch (operationName) {
|
|
1640
|
+
case "push":
|
|
1641
|
+
offset = arrayLength;
|
|
1642
|
+
case "unshift":
|
|
1643
|
+
for (let index = 0; index < argsLength; index++) {
|
|
1644
|
+
pushDiff("added", args[index], offset + index);
|
|
1645
|
+
}
|
|
1646
|
+
break;
|
|
1647
|
+
case "pop":
|
|
1648
|
+
offset = arrayLength - 1;
|
|
1649
|
+
case "shift":
|
|
1650
|
+
if (arrayLength) {
|
|
1651
|
+
pushDiff("deleted", rawArray[offset], offset);
|
|
1652
|
+
}
|
|
1653
|
+
break;
|
|
1654
|
+
case "splice":
|
|
1655
|
+
var 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 = [], deletions = [];
|
|
1656
|
+
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
|
|
1657
|
+
if (index < endDeleteIndex) {
|
|
1658
|
+
deletions.push(pushDiff("deleted", rawArray[index], index));
|
|
1659
|
+
}
|
|
1660
|
+
if (index < endAddIndex) {
|
|
1661
|
+
additions.push(pushDiff("added", args[argsIndex], index));
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
findMovesInArrayComparison(deletions, additions);
|
|
1665
|
+
break;
|
|
1666
|
+
default:
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
cachedDiff = diff;
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
trackArrayChanges.compareArrays = compareArrays;
|
|
1673
|
+
extenders.trackArrayChanges = trackArrayChanges;
|
|
1674
|
+
|
|
1675
|
+
// ../observable/dist/observableArray.js
|
|
1676
|
+
function observableArray(initialValues) {
|
|
1677
|
+
initialValues = initialValues || [];
|
|
1678
|
+
if (typeof initialValues !== "object" || !("length" in initialValues)) {
|
|
1679
|
+
throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
|
|
1680
|
+
}
|
|
1681
|
+
var result = observable(initialValues);
|
|
1682
|
+
Object.setPrototypeOf(result, observableArray.fn);
|
|
1683
|
+
trackArrayChanges(result);
|
|
1684
|
+
overwriteLengthPropertyIfSupported(result, { get: () => result().length });
|
|
1685
|
+
return result;
|
|
1686
|
+
}
|
|
1687
|
+
function isObservableArray(instance) {
|
|
1688
|
+
return isObservable(instance) && typeof instance.remove === "function" && typeof instance.push === "function";
|
|
1689
|
+
}
|
|
1690
|
+
observableArray.fn = {
|
|
1691
|
+
remove(valueOrPredicate) {
|
|
1692
|
+
var underlyingArray = this.peek();
|
|
1693
|
+
var removedValues = [];
|
|
1694
|
+
var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
|
|
1695
|
+
return value2 === valueOrPredicate;
|
|
1696
|
+
};
|
|
1697
|
+
for (var i = 0; i < underlyingArray.length; i++) {
|
|
1698
|
+
var value = underlyingArray[i];
|
|
1699
|
+
if (predicate(value)) {
|
|
1700
|
+
if (removedValues.length === 0) {
|
|
1701
|
+
this.valueWillMutate();
|
|
1702
|
+
}
|
|
1703
|
+
if (underlyingArray[i] !== value) {
|
|
1704
|
+
throw Error("Array modified during remove; cannot remove item");
|
|
1705
|
+
}
|
|
1706
|
+
removedValues.push(value);
|
|
1707
|
+
underlyingArray.splice(i, 1);
|
|
1708
|
+
i--;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
if (removedValues.length) {
|
|
1712
|
+
this.valueHasMutated();
|
|
1713
|
+
}
|
|
1714
|
+
return removedValues;
|
|
1715
|
+
},
|
|
1716
|
+
removeAll(arrayOfValues) {
|
|
1717
|
+
if (arrayOfValues === void 0) {
|
|
1718
|
+
var underlyingArray = this.peek();
|
|
1719
|
+
var allValues = underlyingArray.slice(0);
|
|
1720
|
+
this.valueWillMutate();
|
|
1721
|
+
underlyingArray.splice(0, underlyingArray.length);
|
|
1722
|
+
this.valueHasMutated();
|
|
1723
|
+
return allValues;
|
|
1724
|
+
}
|
|
1725
|
+
if (!arrayOfValues) {
|
|
1726
|
+
return [];
|
|
1727
|
+
}
|
|
1728
|
+
return this["remove"](function(value) {
|
|
1729
|
+
return arrayIndexOf(arrayOfValues, value) >= 0;
|
|
1730
|
+
});
|
|
1731
|
+
},
|
|
1732
|
+
destroy(valueOrPredicate) {
|
|
1733
|
+
var underlyingArray = this.peek();
|
|
1734
|
+
var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
|
|
1735
|
+
return value2 === valueOrPredicate;
|
|
1736
|
+
};
|
|
1737
|
+
this.valueWillMutate();
|
|
1738
|
+
for (var i = underlyingArray.length - 1; i >= 0; i--) {
|
|
1739
|
+
var value = underlyingArray[i];
|
|
1740
|
+
if (predicate(value)) {
|
|
1741
|
+
value["_destroy"] = true;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
this.valueHasMutated();
|
|
1745
|
+
},
|
|
1746
|
+
destroyAll(arrayOfValues) {
|
|
1747
|
+
if (arrayOfValues === void 0) {
|
|
1748
|
+
return this.destroy(function() {
|
|
1749
|
+
return true;
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
if (!arrayOfValues) {
|
|
1753
|
+
return [];
|
|
1754
|
+
}
|
|
1755
|
+
return this.destroy(function(value) {
|
|
1756
|
+
return arrayIndexOf(arrayOfValues, value) >= 0;
|
|
1757
|
+
});
|
|
1758
|
+
},
|
|
1759
|
+
indexOf(item) {
|
|
1760
|
+
return arrayIndexOf(this(), item);
|
|
1761
|
+
},
|
|
1762
|
+
replace(oldItem, newItem) {
|
|
1763
|
+
var index = this.indexOf(oldItem);
|
|
1764
|
+
if (index >= 0) {
|
|
1765
|
+
this.valueWillMutate();
|
|
1766
|
+
this.peek()[index] = newItem;
|
|
1767
|
+
this.valueHasMutated();
|
|
1768
|
+
}
|
|
1769
|
+
},
|
|
1770
|
+
sorted(compareFn) {
|
|
1771
|
+
return [...this()].sort(compareFn);
|
|
1772
|
+
},
|
|
1773
|
+
reversed() {
|
|
1774
|
+
return [...this()].reverse();
|
|
1775
|
+
},
|
|
1776
|
+
[Symbol.iterator]: function* () {
|
|
1777
|
+
yield* this();
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
Object.setPrototypeOf(observableArray.fn, observable.fn);
|
|
1781
|
+
arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
1782
|
+
observableArray.fn[methodName] = function() {
|
|
1783
|
+
var underlyingArray = this.peek();
|
|
1784
|
+
this.valueWillMutate();
|
|
1785
|
+
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
|
|
1786
|
+
var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1787
|
+
this.valueHasMutated();
|
|
1788
|
+
return methodCallResult === underlyingArray ? this : methodCallResult;
|
|
1789
|
+
};
|
|
1790
|
+
});
|
|
1791
|
+
arrayForEach(["slice"], function(methodName) {
|
|
1792
|
+
observableArray.fn[methodName] = function() {
|
|
1793
|
+
var underlyingArray = this();
|
|
1794
|
+
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1795
|
+
};
|
|
1796
|
+
});
|
|
1797
|
+
observableArray.trackArrayChanges = trackArrayChanges;
|
|
1798
|
+
|
|
1799
|
+
// src/templateSources.ts
|
|
1800
|
+
var templateScript = 1;
|
|
1801
|
+
var templateTextArea = 2;
|
|
1802
|
+
var templateTemplate = 3;
|
|
1803
|
+
var templateElement = 4;
|
|
1804
|
+
function domElement(element) {
|
|
1805
|
+
this.domElement = element;
|
|
1806
|
+
if (!element) {
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
var tagNameLower2 = tagNameLower(element);
|
|
1810
|
+
this.templateType = tagNameLower2 === "script" ? templateScript : tagNameLower2 === "textarea" ? templateTextArea : tagNameLower2 == "template" && element.content && element.content.nodeType === 11 ? templateTemplate : templateElement;
|
|
1811
|
+
}
|
|
1812
|
+
domElement.prototype.text = function() {
|
|
1813
|
+
var elemContentsProperty = this.templateType === templateScript ? "text" : this.templateType === templateTextArea ? "value" : "innerHTML";
|
|
1814
|
+
if (arguments.length == 0) {
|
|
1815
|
+
return this.domElement[elemContentsProperty];
|
|
1816
|
+
} else {
|
|
1817
|
+
var valueToWrite = arguments[0];
|
|
1818
|
+
if (elemContentsProperty === "innerHTML") {
|
|
1819
|
+
setHtml(this.domElement, valueToWrite);
|
|
1820
|
+
} else {
|
|
1821
|
+
this.domElement[elemContentsProperty] = valueToWrite;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
var dataDomDataPrefix = data_exports.nextKey() + "_";
|
|
1826
|
+
domElement.prototype.data = function(key) {
|
|
1827
|
+
if (arguments.length === 1) {
|
|
1828
|
+
return data_exports.get(this.domElement, dataDomDataPrefix + key);
|
|
1829
|
+
} else {
|
|
1830
|
+
data_exports.set(this.domElement, dataDomDataPrefix + key, arguments[1]);
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
var templatesDomDataKey = data_exports.nextKey();
|
|
1834
|
+
function getTemplateDomData(element) {
|
|
1835
|
+
return data_exports.get(element, templatesDomDataKey) || {};
|
|
1836
|
+
}
|
|
1837
|
+
function setTemplateDomData(element, data) {
|
|
1838
|
+
data_exports.set(element, templatesDomDataKey, data);
|
|
1839
|
+
}
|
|
1840
|
+
domElement.prototype.nodes = function() {
|
|
1841
|
+
var element = this.domElement;
|
|
1842
|
+
if (arguments.length == 0) {
|
|
1843
|
+
const templateData = getTemplateDomData(element);
|
|
1844
|
+
let nodes = templateData.containerData || (this.templateType === templateTemplate ? element.content : this.templateType === templateElement ? element : void 0);
|
|
1845
|
+
if (!nodes || templateData.alwaysCheckText) {
|
|
1846
|
+
const text = this["text"]();
|
|
1847
|
+
if (text) {
|
|
1848
|
+
nodes = parseHtmlForTemplateNodes(text, element.ownerDocument);
|
|
1849
|
+
this["text"]("");
|
|
1850
|
+
setTemplateDomData(element, { containerData: nodes, alwaysCheckText: true });
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
return nodes;
|
|
1854
|
+
} else {
|
|
1855
|
+
var valueToWrite = arguments[0];
|
|
1856
|
+
setTemplateDomData(element, { containerData: valueToWrite });
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
function anonymousTemplate(element) {
|
|
1860
|
+
this.domElement = element;
|
|
1861
|
+
}
|
|
1862
|
+
anonymousTemplate.prototype = new domElement();
|
|
1863
|
+
anonymousTemplate.prototype.constructor = anonymousTemplate;
|
|
1864
|
+
anonymousTemplate.prototype.text = function() {
|
|
1865
|
+
if (arguments.length == 0) {
|
|
1866
|
+
var templateData = getTemplateDomData(this.domElement);
|
|
1867
|
+
if (templateData.textData === void 0 && templateData.containerData) {
|
|
1868
|
+
templateData.textData = templateData.containerData.innerHTML;
|
|
1869
|
+
}
|
|
1870
|
+
return templateData.textData;
|
|
1871
|
+
} else {
|
|
1872
|
+
var valueToWrite = arguments[0];
|
|
1873
|
+
setTemplateDomData(this.domElement, { textData: valueToWrite });
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
|
|
1877
|
+
// src/templateEngine.ts
|
|
1878
|
+
function templateEngine() {
|
|
1879
|
+
}
|
|
1880
|
+
extend(templateEngine.prototype, {
|
|
1881
|
+
renderTemplateSource: function(templateSource, bindingContext2, options3, templateDocument) {
|
|
1882
|
+
options3.onError("Override renderTemplateSource");
|
|
1883
|
+
},
|
|
1884
|
+
createJavaScriptEvaluatorBlock: function(script) {
|
|
1885
|
+
options_default.onError("Override createJavaScriptEvaluatorBlock");
|
|
1886
|
+
},
|
|
1887
|
+
makeTemplateSource: function(template, templateDocument) {
|
|
1888
|
+
if (typeof template === "string") {
|
|
1889
|
+
templateDocument = templateDocument || document;
|
|
1890
|
+
var elem = templateDocument.getElementById(template);
|
|
1891
|
+
if (!elem) {
|
|
1892
|
+
options_default.onError("Cannot find template with ID " + template);
|
|
1893
|
+
}
|
|
1894
|
+
return new domElement(elem);
|
|
1895
|
+
} else if (template.nodeType == 1 || template.nodeType == 8) {
|
|
1896
|
+
return new anonymousTemplate(template);
|
|
1897
|
+
} else {
|
|
1898
|
+
options_default.onError("Unknown template type: " + template);
|
|
1899
|
+
}
|
|
1900
|
+
},
|
|
1901
|
+
renderTemplate: function(template, bindingContext2, options3, templateDocument) {
|
|
1902
|
+
var templateSource = this["makeTemplateSource"](template, templateDocument);
|
|
1903
|
+
return this.renderTemplateSource(templateSource, bindingContext2, options3, templateDocument);
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
|
|
1907
|
+
// ../computed/dist/computed.js
|
|
1908
|
+
var computedState = createSymbolOrString("_state");
|
|
1909
|
+
var DISPOSED_STATE = {
|
|
1910
|
+
dependencyTracking: null,
|
|
1911
|
+
dependenciesCount: 0,
|
|
1912
|
+
isDisposed: true,
|
|
1913
|
+
isStale: false,
|
|
1914
|
+
isDirty: false,
|
|
1915
|
+
isSleeping: false,
|
|
1916
|
+
disposeWhenNodeIsRemoved: null,
|
|
1917
|
+
readFunction: null,
|
|
1918
|
+
_options: null
|
|
1919
|
+
};
|
|
1920
|
+
function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22) {
|
|
1921
|
+
if (typeof evaluatorFunctionOrOptions === "object") {
|
|
1922
|
+
options22 = evaluatorFunctionOrOptions;
|
|
1923
|
+
} else {
|
|
1924
|
+
options22 = options22 || {};
|
|
1925
|
+
if (evaluatorFunctionOrOptions) {
|
|
1926
|
+
options22.read = evaluatorFunctionOrOptions;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
if (typeof options22.read !== "function") {
|
|
1930
|
+
throw Error("Pass a function that returns the value of the computed");
|
|
1931
|
+
}
|
|
1932
|
+
var writeFunction = options22.write;
|
|
1933
|
+
var state = {
|
|
1934
|
+
latestValue: void 0,
|
|
1935
|
+
isStale: true,
|
|
1936
|
+
isDirty: true,
|
|
1937
|
+
isBeingEvaluated: false,
|
|
1938
|
+
suppressDisposalUntilDisposeWhenReturnsFalse: false,
|
|
1939
|
+
isDisposed: false,
|
|
1940
|
+
pure: false,
|
|
1941
|
+
isSleeping: false,
|
|
1942
|
+
readFunction: options22.read,
|
|
1943
|
+
evaluatorFunctionTarget: evaluatorFunctionTarget || options22.owner,
|
|
1944
|
+
disposeWhenNodeIsRemoved: options22.disposeWhenNodeIsRemoved || options22.disposeWhenNodeIsRemoved || null,
|
|
1945
|
+
disposeWhen: options22.disposeWhen || options22.disposeWhen,
|
|
1946
|
+
domNodeDisposalCallback: null,
|
|
1947
|
+
dependencyTracking: {},
|
|
1948
|
+
dependenciesCount: 0,
|
|
1949
|
+
evaluationTimeoutInstance: null
|
|
1950
|
+
};
|
|
1951
|
+
function computedObservable() {
|
|
1952
|
+
if (arguments.length > 0) {
|
|
1953
|
+
if (typeof writeFunction === "function") {
|
|
1954
|
+
writeFunction.apply(state.evaluatorFunctionTarget, arguments);
|
|
1955
|
+
} else {
|
|
1956
|
+
throw new Error("Cannot write a value to a computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
|
|
1957
|
+
}
|
|
1958
|
+
return this;
|
|
1959
|
+
} else {
|
|
1960
|
+
if (!state.isDisposed) {
|
|
1961
|
+
dependencyDetection_exports.registerDependency(computedObservable);
|
|
1962
|
+
}
|
|
1963
|
+
if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
|
|
1964
|
+
computedObservable.evaluateImmediate();
|
|
1965
|
+
}
|
|
1966
|
+
return state.latestValue;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
computedObservable[computedState] = state;
|
|
1970
|
+
computedObservable.isWriteable = typeof writeFunction === "function";
|
|
1971
|
+
subscribable.fn.init(computedObservable);
|
|
1972
|
+
Object.setPrototypeOf(computedObservable, computed.fn);
|
|
1973
|
+
if (options22.pure) {
|
|
1974
|
+
state.pure = true;
|
|
1975
|
+
state.isSleeping = true;
|
|
1976
|
+
extend(computedObservable, pureComputedOverrides);
|
|
1977
|
+
} else if (options22.deferEvaluation) {
|
|
1978
|
+
extend(computedObservable, deferEvaluationOverrides);
|
|
1979
|
+
}
|
|
1980
|
+
if (options_default.deferUpdates) {
|
|
1981
|
+
extenders.deferred(computedObservable, true);
|
|
1982
|
+
}
|
|
1983
|
+
if (options_default.debug) {
|
|
1984
|
+
computedObservable._options = options22;
|
|
1985
|
+
}
|
|
1986
|
+
if (state.disposeWhenNodeIsRemoved) {
|
|
1987
|
+
state.suppressDisposalUntilDisposeWhenReturnsFalse = true;
|
|
1988
|
+
if (!state.disposeWhenNodeIsRemoved.nodeType) {
|
|
1989
|
+
state.disposeWhenNodeIsRemoved = null;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
if (!state.isSleeping && !options22.deferEvaluation) {
|
|
1993
|
+
computedObservable.evaluateImmediate();
|
|
1994
|
+
}
|
|
1995
|
+
if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
|
|
1996
|
+
addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function() {
|
|
1997
|
+
computedObservable.dispose();
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
return computedObservable;
|
|
2001
|
+
}
|
|
2002
|
+
function computedDisposeDependencyCallback(id, entryToDispose) {
|
|
2003
|
+
if (entryToDispose !== null && entryToDispose.dispose) {
|
|
2004
|
+
entryToDispose.dispose();
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
function computedBeginDependencyDetectionCallback(subscribable2, id) {
|
|
2008
|
+
var computedObservable = this.computedObservable, state = computedObservable[computedState];
|
|
2009
|
+
if (!state.isDisposed) {
|
|
2010
|
+
if (this.disposalCount && this.disposalCandidates[id]) {
|
|
2011
|
+
computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
|
|
2012
|
+
this.disposalCandidates[id] = null;
|
|
2013
|
+
--this.disposalCount;
|
|
2014
|
+
} else if (!state.dependencyTracking[id]) {
|
|
2015
|
+
computedObservable.addDependencyTracking(id, subscribable2, state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2));
|
|
2016
|
+
}
|
|
2017
|
+
if (subscribable2._notificationIsPending) {
|
|
2018
|
+
subscribable2._notifyNextChangeIfValueIsDifferent();
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
computed.fn = {
|
|
2023
|
+
equalityComparer: valuesArePrimitiveAndEqual,
|
|
2024
|
+
getDependenciesCount() {
|
|
2025
|
+
return this[computedState].dependenciesCount;
|
|
2026
|
+
},
|
|
2027
|
+
getDependencies() {
|
|
2028
|
+
const dependencyTracking = this[computedState].dependencyTracking;
|
|
2029
|
+
const dependentObservables = [];
|
|
2030
|
+
objectForEach(dependencyTracking, function(id, dependency) {
|
|
2031
|
+
dependentObservables[dependency._order] = dependency._target;
|
|
2032
|
+
});
|
|
2033
|
+
return dependentObservables;
|
|
2034
|
+
},
|
|
2035
|
+
addDependencyTracking(id, target, trackingObj) {
|
|
2036
|
+
if (this[computedState].pure && target === this) {
|
|
2037
|
+
throw Error("A 'pure' computed must not be called recursively");
|
|
2038
|
+
}
|
|
2039
|
+
this[computedState].dependencyTracking[id] = trackingObj;
|
|
2040
|
+
trackingObj._order = this[computedState].dependenciesCount++;
|
|
2041
|
+
trackingObj._version = target.getVersion();
|
|
2042
|
+
},
|
|
2043
|
+
haveDependenciesChanged() {
|
|
2044
|
+
var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
|
|
2045
|
+
for (id in dependencyTracking) {
|
|
2046
|
+
if (hasOwnProperty(dependencyTracking, id)) {
|
|
2047
|
+
dependency = dependencyTracking[id];
|
|
2048
|
+
if (this._evalDelayed && dependency._target._notificationIsPending || dependency._target.hasChanged(dependency._version)) {
|
|
2049
|
+
return true;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
},
|
|
2054
|
+
markDirty() {
|
|
2055
|
+
if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
|
|
2056
|
+
this._evalDelayed(false);
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
isActive() {
|
|
2060
|
+
const state = this[computedState];
|
|
2061
|
+
return state.isDirty || state.dependenciesCount > 0;
|
|
2062
|
+
},
|
|
2063
|
+
respondToChange() {
|
|
2064
|
+
if (!this._notificationIsPending) {
|
|
2065
|
+
this.evaluatePossiblyAsync();
|
|
2066
|
+
} else if (this[computedState].isDirty) {
|
|
2067
|
+
this[computedState].isStale = true;
|
|
2068
|
+
}
|
|
2069
|
+
},
|
|
2070
|
+
subscribeToDependency(target) {
|
|
2071
|
+
if (target._deferUpdates) {
|
|
2072
|
+
var dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
|
|
2073
|
+
return {
|
|
2074
|
+
_target: target,
|
|
2075
|
+
dispose() {
|
|
2076
|
+
dirtySub.dispose();
|
|
2077
|
+
changeSub.dispose();
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
} else {
|
|
2081
|
+
return target.subscribe(this.evaluatePossiblyAsync, this);
|
|
2082
|
+
}
|
|
2083
|
+
},
|
|
2084
|
+
evaluatePossiblyAsync() {
|
|
2085
|
+
var computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
|
|
2086
|
+
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
|
2087
|
+
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
|
2088
|
+
this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
|
|
2089
|
+
computedObservable.evaluateImmediate(true);
|
|
2090
|
+
}, throttleEvaluationTimeout);
|
|
2091
|
+
} else if (computedObservable._evalDelayed) {
|
|
2092
|
+
computedObservable._evalDelayed(true);
|
|
2093
|
+
} else {
|
|
2094
|
+
computedObservable.evaluateImmediate(true);
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
evaluateImmediate(notifyChange) {
|
|
2098
|
+
var computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
|
|
2099
|
+
if (state.isBeingEvaluated) {
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
if (state.isDisposed) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
if (state.disposeWhenNodeIsRemoved && !domNodeIsAttachedToDocument(state.disposeWhenNodeIsRemoved) || disposeWhen && disposeWhen()) {
|
|
2106
|
+
if (!state.suppressDisposalUntilDisposeWhenReturnsFalse) {
|
|
2107
|
+
computedObservable.dispose();
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
2110
|
+
} else {
|
|
2111
|
+
state.suppressDisposalUntilDisposeWhenReturnsFalse = false;
|
|
2112
|
+
}
|
|
2113
|
+
state.isBeingEvaluated = true;
|
|
2114
|
+
try {
|
|
2115
|
+
changed = this.evaluateImmediate_CallReadWithDependencyDetection(notifyChange);
|
|
2116
|
+
} finally {
|
|
2117
|
+
state.isBeingEvaluated = false;
|
|
2118
|
+
}
|
|
2119
|
+
return changed;
|
|
2120
|
+
},
|
|
2121
|
+
evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
|
|
2122
|
+
var computedObservable = this, state = computedObservable[computedState], changed = false;
|
|
2123
|
+
var isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
|
|
2124
|
+
computedObservable,
|
|
2125
|
+
disposalCandidates: state.dependencyTracking,
|
|
2126
|
+
disposalCount: state.dependenciesCount
|
|
2127
|
+
};
|
|
2128
|
+
dependencyDetection_exports.begin({
|
|
2129
|
+
callbackTarget: dependencyDetectionContext,
|
|
2130
|
+
callback: computedBeginDependencyDetectionCallback,
|
|
2131
|
+
computed: computedObservable,
|
|
2132
|
+
isInitial: isInitial2
|
|
2133
|
+
});
|
|
2134
|
+
state.dependencyTracking = {};
|
|
2135
|
+
state.dependenciesCount = 0;
|
|
2136
|
+
var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
|
|
2137
|
+
if (!state.dependenciesCount) {
|
|
2138
|
+
computedObservable.dispose();
|
|
2139
|
+
changed = true;
|
|
2140
|
+
} else {
|
|
2141
|
+
changed = computedObservable.isDifferent(state.latestValue, newValue);
|
|
2142
|
+
}
|
|
2143
|
+
if (changed) {
|
|
2144
|
+
if (!state.isSleeping) {
|
|
2145
|
+
computedObservable.notifySubscribers(state.latestValue, "beforeChange");
|
|
2146
|
+
} else {
|
|
2147
|
+
computedObservable.updateVersion();
|
|
2148
|
+
}
|
|
2149
|
+
state.latestValue = newValue;
|
|
2150
|
+
if (options_default.debug) {
|
|
2151
|
+
computedObservable._latestValue = newValue;
|
|
2152
|
+
}
|
|
2153
|
+
computedObservable.notifySubscribers(state.latestValue, "spectate");
|
|
2154
|
+
if (!state.isSleeping && notifyChange) {
|
|
2155
|
+
computedObservable.notifySubscribers(state.latestValue);
|
|
2156
|
+
}
|
|
2157
|
+
if (computedObservable._recordUpdate) {
|
|
2158
|
+
computedObservable._recordUpdate();
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
if (isInitial2) {
|
|
2162
|
+
computedObservable.notifySubscribers(state.latestValue, "awake");
|
|
2163
|
+
}
|
|
2164
|
+
return changed;
|
|
2165
|
+
},
|
|
2166
|
+
evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
|
|
2167
|
+
try {
|
|
2168
|
+
var readFunction = state.readFunction;
|
|
2169
|
+
return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
|
|
2170
|
+
} finally {
|
|
2171
|
+
dependencyDetection_exports.end();
|
|
2172
|
+
if (dependencyDetectionContext.disposalCount && !state.isSleeping) {
|
|
2173
|
+
objectForEach(dependencyDetectionContext.disposalCandidates, computedDisposeDependencyCallback);
|
|
2174
|
+
}
|
|
2175
|
+
state.isStale = state.isDirty = false;
|
|
2176
|
+
}
|
|
2177
|
+
},
|
|
2178
|
+
peek(forceEvaluate) {
|
|
2179
|
+
const state = this[computedState];
|
|
2180
|
+
if (state.isDirty && (forceEvaluate || !state.dependenciesCount) || state.isSleeping && this.haveDependenciesChanged()) {
|
|
2181
|
+
this.evaluateImmediate();
|
|
2182
|
+
}
|
|
2183
|
+
return state.latestValue;
|
|
2184
|
+
},
|
|
2185
|
+
get [LATEST_VALUE]() {
|
|
2186
|
+
return this.peek();
|
|
2187
|
+
},
|
|
2188
|
+
limit(limitFunction) {
|
|
2189
|
+
const state = this[computedState];
|
|
2190
|
+
subscribable.fn.limit.call(this, limitFunction);
|
|
2191
|
+
Object.assign(this, {
|
|
2192
|
+
_evalIfChanged() {
|
|
2193
|
+
if (!this[computedState].isSleeping) {
|
|
2194
|
+
if (this[computedState].isStale) {
|
|
2195
|
+
this.evaluateImmediate();
|
|
2196
|
+
} else {
|
|
2197
|
+
this[computedState].isDirty = false;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return state.latestValue;
|
|
2201
|
+
},
|
|
2202
|
+
_evalDelayed(isChange) {
|
|
2203
|
+
this._limitBeforeChange(state.latestValue);
|
|
2204
|
+
state.isDirty = true;
|
|
2205
|
+
if (isChange) {
|
|
2206
|
+
state.isStale = true;
|
|
2207
|
+
}
|
|
2208
|
+
this._limitChange(this, !isChange);
|
|
2209
|
+
}
|
|
2210
|
+
});
|
|
2211
|
+
},
|
|
2212
|
+
dispose() {
|
|
2213
|
+
var state = this[computedState];
|
|
2214
|
+
if (!state.isSleeping && state.dependencyTracking) {
|
|
2215
|
+
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2216
|
+
if (dependency.dispose) {
|
|
2217
|
+
dependency.dispose();
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
if (state.disposeWhenNodeIsRemoved && state.domNodeDisposalCallback) {
|
|
2222
|
+
removeDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback);
|
|
2223
|
+
}
|
|
2224
|
+
Object.assign(state, DISPOSED_STATE);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
var pureComputedOverrides = {
|
|
2228
|
+
beforeSubscriptionAdd(event) {
|
|
2229
|
+
var computedObservable = this, state = computedObservable[computedState];
|
|
2230
|
+
if (!state.isDisposed && state.isSleeping && event === "change") {
|
|
2231
|
+
state.isSleeping = false;
|
|
2232
|
+
if (state.isStale || computedObservable.haveDependenciesChanged()) {
|
|
2233
|
+
state.dependencyTracking = null;
|
|
2234
|
+
state.dependenciesCount = 0;
|
|
2235
|
+
if (computedObservable.evaluateImmediate()) {
|
|
2236
|
+
computedObservable.updateVersion();
|
|
2237
|
+
}
|
|
2238
|
+
} else {
|
|
2239
|
+
var dependenciesOrder = [];
|
|
2240
|
+
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2241
|
+
dependenciesOrder[dependency._order] = id;
|
|
2242
|
+
});
|
|
2243
|
+
arrayForEach(dependenciesOrder, function(id, order) {
|
|
2244
|
+
var dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
|
|
2245
|
+
subscription._order = order;
|
|
2246
|
+
subscription._version = dependency._version;
|
|
2247
|
+
state.dependencyTracking[id] = subscription;
|
|
2248
|
+
});
|
|
2249
|
+
if (computedObservable.haveDependenciesChanged()) {
|
|
2250
|
+
if (computedObservable.evaluateImmediate()) {
|
|
2251
|
+
computedObservable.updateVersion();
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
if (!state.isDisposed) {
|
|
2256
|
+
computedObservable.notifySubscribers(state.latestValue, "awake");
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
},
|
|
2260
|
+
afterSubscriptionRemove(event) {
|
|
2261
|
+
var state = this[computedState];
|
|
2262
|
+
if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
|
|
2263
|
+
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2264
|
+
if (dependency.dispose) {
|
|
2265
|
+
state.dependencyTracking[id] = {
|
|
2266
|
+
_target: dependency._target,
|
|
2267
|
+
_order: dependency._order,
|
|
2268
|
+
_version: dependency._version
|
|
2269
|
+
};
|
|
2270
|
+
dependency.dispose();
|
|
2271
|
+
}
|
|
2272
|
+
});
|
|
2273
|
+
state.isSleeping = true;
|
|
2274
|
+
this.notifySubscribers(void 0, "asleep");
|
|
2275
|
+
}
|
|
2276
|
+
},
|
|
2277
|
+
getVersion() {
|
|
2278
|
+
var state = this[computedState];
|
|
2279
|
+
if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
|
|
2280
|
+
this.evaluateImmediate();
|
|
2281
|
+
}
|
|
2282
|
+
return subscribable.fn.getVersion.call(this);
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
var deferEvaluationOverrides = {
|
|
2286
|
+
beforeSubscriptionAdd(event) {
|
|
2287
|
+
if (event === "change" || event === "beforeChange") {
|
|
2288
|
+
this.peek();
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
Object.setPrototypeOf(computed.fn, subscribable.fn);
|
|
2293
|
+
var protoProp = observable.protoProperty;
|
|
2294
|
+
computed.fn[protoProp] = computed;
|
|
2295
|
+
observable.observablePrototypes.add(computed);
|
|
2296
|
+
function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
|
|
2297
|
+
if (typeof evaluatorFunctionOrOptions === "function") {
|
|
2298
|
+
return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, { "pure": true });
|
|
2299
|
+
} else {
|
|
2300
|
+
evaluatorFunctionOrOptions = extend({}, evaluatorFunctionOrOptions);
|
|
2301
|
+
evaluatorFunctionOrOptions.pure = true;
|
|
2302
|
+
return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// ../computed/dist/throttleExtender.js
|
|
2307
|
+
function throttleExtender(target, timeout) {
|
|
2308
|
+
target.throttleEvaluation = timeout;
|
|
2309
|
+
var writeTimeoutInstance = null;
|
|
2310
|
+
return computed({
|
|
2311
|
+
read: target,
|
|
2312
|
+
write: function(value) {
|
|
2313
|
+
clearTimeout(writeTimeoutInstance);
|
|
2314
|
+
writeTimeoutInstance = setTimeout(function() {
|
|
2315
|
+
target(value);
|
|
2316
|
+
}, timeout);
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
extenders.throttle = throttleExtender;
|
|
2321
|
+
|
|
2322
|
+
// ../computed/dist/proxy.js
|
|
2323
|
+
var PROXY_SYM = Symbol("Knockout Proxied Object");
|
|
2324
|
+
var MIRROR_SYM = Symbol("Knockout Proxied Observables");
|
|
2325
|
+
function makeComputed(proxy2, fn) {
|
|
2326
|
+
return computed({
|
|
2327
|
+
owner: proxy2,
|
|
2328
|
+
read: fn,
|
|
2329
|
+
write: fn,
|
|
2330
|
+
pure: "pure" in fn ? fn.pure : true,
|
|
2331
|
+
deferEvaluation: "deferEvaluation" in fn ? fn.deferEvaluation : true
|
|
2332
|
+
}).extend({ deferred: true });
|
|
2333
|
+
}
|
|
2334
|
+
function setOrCreate(mirror, prop, value, proxy2) {
|
|
2335
|
+
if (!mirror[prop]) {
|
|
2336
|
+
const ctr = Array.isArray(value) ? observableArray : typeof value === "function" ? makeComputed.bind(null, proxy2) : observable;
|
|
2337
|
+
mirror[prop] = ctr(value);
|
|
2338
|
+
} else {
|
|
2339
|
+
mirror[prop](value);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
function assignOrUpdate(mirror, object2, proxy2) {
|
|
2343
|
+
for (const key of Object.keys(object2)) {
|
|
2344
|
+
setOrCreate(mirror, key, object2[key], proxy2);
|
|
2345
|
+
}
|
|
2346
|
+
return object2;
|
|
2347
|
+
}
|
|
2348
|
+
function proxy(object2) {
|
|
2349
|
+
const mirror = { [PROXY_SYM]: object2 };
|
|
2350
|
+
mirror[MIRROR_SYM] = mirror;
|
|
2351
|
+
const proxy2 = new Proxy(function() {
|
|
2352
|
+
}, {
|
|
2353
|
+
has(target, prop) {
|
|
2354
|
+
return prop in mirror;
|
|
2355
|
+
},
|
|
2356
|
+
get(target, prop) {
|
|
2357
|
+
return unwrap(mirror[prop]);
|
|
2358
|
+
},
|
|
2359
|
+
set(target, prop, value, receiver) {
|
|
2360
|
+
setOrCreate(mirror, prop, value, proxy2);
|
|
2361
|
+
object2[prop] = value;
|
|
2362
|
+
return true;
|
|
2363
|
+
},
|
|
2364
|
+
deleteProperty(property) {
|
|
2365
|
+
delete mirror[property];
|
|
2366
|
+
return delete object2[property];
|
|
2367
|
+
},
|
|
2368
|
+
apply(target, thisArg, [props]) {
|
|
2369
|
+
if (props) {
|
|
2370
|
+
assignOrUpdate(mirror, props, proxy2);
|
|
2371
|
+
return Object.assign(object2, props);
|
|
2372
|
+
}
|
|
2373
|
+
return object2;
|
|
2374
|
+
},
|
|
2375
|
+
getPrototypeOf() {
|
|
2376
|
+
return Object.getPrototypeOf(object2);
|
|
2377
|
+
},
|
|
2378
|
+
setPrototypeOf(target, proto) {
|
|
2379
|
+
return Object.setPrototypeOf(object2, proto);
|
|
2380
|
+
},
|
|
2381
|
+
defineProperty(target, prop, desc) {
|
|
2382
|
+
return Object.defineProperty(object2, prop, desc);
|
|
2383
|
+
},
|
|
2384
|
+
preventExtensions() {
|
|
2385
|
+
return Object.preventExtensions(object2);
|
|
2386
|
+
},
|
|
2387
|
+
isExtensible() {
|
|
2388
|
+
return Object.isExtensible(object2);
|
|
2389
|
+
},
|
|
2390
|
+
ownKeys() {
|
|
2391
|
+
return [
|
|
2392
|
+
...Object.getOwnPropertyNames(object2),
|
|
2393
|
+
...Object.getOwnPropertySymbols(object2)
|
|
2394
|
+
];
|
|
2395
|
+
}
|
|
2396
|
+
});
|
|
2397
|
+
assignOrUpdate(mirror, object2, proxy2);
|
|
2398
|
+
return proxy2;
|
|
2399
|
+
}
|
|
2400
|
+
function getObservable(proxied, prop) {
|
|
2401
|
+
return proxied[MIRROR_SYM][prop];
|
|
2402
|
+
}
|
|
2403
|
+
function peek2(proxied, prop) {
|
|
2404
|
+
return getObservable(proxied, prop).peek();
|
|
2405
|
+
}
|
|
2406
|
+
function isProxied(proxied) {
|
|
2407
|
+
return PROXY_SYM in proxied;
|
|
2408
|
+
}
|
|
2409
|
+
Object.assign(proxy, { getObservable, peek: peek2, isProxied });
|
|
2410
|
+
|
|
2411
|
+
// ../bind/dist/bindingEvent.js
|
|
2412
|
+
var contextAncestorBindingInfo = Symbol("_ancestorBindingInfo");
|
|
2413
|
+
var boundElementDomDataKey = data_exports.nextKey();
|
|
2414
|
+
var bindingEvent = {
|
|
2415
|
+
childrenComplete: "childrenComplete",
|
|
2416
|
+
descendantsComplete: "descendantsComplete",
|
|
2417
|
+
subscribe(node, event, callback, context) {
|
|
2418
|
+
const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey, {});
|
|
2419
|
+
if (!bindingInfo.eventSubscribable) {
|
|
2420
|
+
bindingInfo.eventSubscribable = new subscribable();
|
|
2421
|
+
}
|
|
2422
|
+
return bindingInfo.eventSubscribable.subscribe(callback, context, event);
|
|
2423
|
+
},
|
|
2424
|
+
notify(node, event) {
|
|
2425
|
+
const bindingInfo = data_exports.get(node, boundElementDomDataKey);
|
|
2426
|
+
if (bindingInfo) {
|
|
2427
|
+
if (bindingInfo.eventSubscribable) {
|
|
2428
|
+
bindingInfo.eventSubscribable.notifySubscribers(node, event);
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
};
|
|
2433
|
+
|
|
2434
|
+
// ../bind/dist/bindingContext.js
|
|
2435
|
+
var boundElementDomDataKey2 = data_exports.nextKey();
|
|
2436
|
+
var contextSubscribeSymbol = Symbol("Knockout Context Subscription");
|
|
2437
|
+
var inheritParentIndicator = Symbol("Knockout Parent Indicator");
|
|
2438
|
+
function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
|
|
2439
|
+
const self = this;
|
|
2440
|
+
const shouldInheritData = dataItemOrAccessor === inheritParentIndicator;
|
|
2441
|
+
const realDataItemOrAccessor = shouldInheritData ? void 0 : dataItemOrAccessor;
|
|
2442
|
+
const isFunc = typeof realDataItemOrAccessor === "function" && !isObservable(realDataItemOrAccessor);
|
|
2443
|
+
self.ko = options_default.knockoutInstance;
|
|
2444
|
+
let nodes;
|
|
2445
|
+
let subscribable2;
|
|
2446
|
+
function updateContext() {
|
|
2447
|
+
const dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor;
|
|
2448
|
+
let dataItem = unwrap(dataItemOrObservable);
|
|
2449
|
+
if (parentContext) {
|
|
2450
|
+
if (parentContext[contextSubscribeSymbol]) {
|
|
2451
|
+
parentContext[contextSubscribeSymbol]();
|
|
2452
|
+
}
|
|
2453
|
+
extend(self, parentContext);
|
|
2454
|
+
if (contextAncestorBindingInfo in parentContext) {
|
|
2455
|
+
self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];
|
|
2456
|
+
}
|
|
2457
|
+
} else {
|
|
2458
|
+
self.$parents = [];
|
|
2459
|
+
self.$root = dataItem;
|
|
2460
|
+
}
|
|
2461
|
+
self[contextSubscribeSymbol] = subscribable2;
|
|
2462
|
+
if (shouldInheritData) {
|
|
2463
|
+
dataItem = self.$data;
|
|
2464
|
+
} else {
|
|
2465
|
+
self.$rawData = dataItemOrObservable;
|
|
2466
|
+
self.$data = dataItem;
|
|
2467
|
+
}
|
|
2468
|
+
if (dataItemAlias) {
|
|
2469
|
+
self[dataItemAlias] = dataItem;
|
|
2470
|
+
}
|
|
2471
|
+
if (extendCallback) {
|
|
2472
|
+
extendCallback(self, parentContext, dataItem);
|
|
2473
|
+
}
|
|
2474
|
+
return self.$data;
|
|
2475
|
+
}
|
|
2476
|
+
if (settings && settings.exportDependencies) {
|
|
2477
|
+
updateContext();
|
|
2478
|
+
} else {
|
|
2479
|
+
subscribable2 = pureComputed(updateContext);
|
|
2480
|
+
subscribable2.peek();
|
|
2481
|
+
if (subscribable2.isActive()) {
|
|
2482
|
+
self[contextSubscribeSymbol] = subscribable2;
|
|
2483
|
+
subscribable2["equalityComparer"] = null;
|
|
2484
|
+
} else {
|
|
2485
|
+
self[contextSubscribeSymbol] = void 0;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
Object.assign(bindingContext.prototype, {
|
|
2490
|
+
lookup(token, globals, node) {
|
|
2491
|
+
switch (token) {
|
|
2492
|
+
case "$element":
|
|
2493
|
+
return node;
|
|
2494
|
+
case "$context":
|
|
2495
|
+
return this;
|
|
2496
|
+
case "this":
|
|
2497
|
+
case "$data":
|
|
2498
|
+
return this.$data;
|
|
2499
|
+
}
|
|
2500
|
+
const $data = this.$data;
|
|
2501
|
+
if (isObjectLike($data) && token in $data) {
|
|
2502
|
+
return $data[token];
|
|
2503
|
+
}
|
|
2504
|
+
if (token in this) {
|
|
2505
|
+
return this[token];
|
|
2506
|
+
}
|
|
2507
|
+
if (token in globals) {
|
|
2508
|
+
return globals[token];
|
|
2509
|
+
}
|
|
2510
|
+
throw new Error(`The variable "${token}" was not found on $data, $context, or globals.`);
|
|
2511
|
+
},
|
|
2512
|
+
createChildContext(dataItemOrAccessor, dataItemAlias, extendCallback, settings) {
|
|
2513
|
+
return new bindingContext(dataItemOrAccessor, this, dataItemAlias, function(self, parentContext) {
|
|
2514
|
+
self.$parentContext = parentContext;
|
|
2515
|
+
self.$parent = parentContext.$data;
|
|
2516
|
+
self.$parents = (parentContext.$parents || []).slice(0);
|
|
2517
|
+
self.$parents.unshift(self.$parent);
|
|
2518
|
+
if (extendCallback) {
|
|
2519
|
+
extendCallback(self);
|
|
2520
|
+
}
|
|
2521
|
+
}, settings);
|
|
2522
|
+
},
|
|
2523
|
+
extend(properties) {
|
|
2524
|
+
return new bindingContext(inheritParentIndicator, this, null, function(self, parentContext) {
|
|
2525
|
+
extend(self, typeof properties === "function" ? properties.call(self) : properties);
|
|
2526
|
+
});
|
|
2527
|
+
},
|
|
2528
|
+
createStaticChildContext(dataItemOrAccessor, dataItemAlias) {
|
|
2529
|
+
return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { "exportDependencies": true });
|
|
2530
|
+
}
|
|
2531
|
+
});
|
|
2532
|
+
function storedBindingContextForNode(node) {
|
|
2533
|
+
const bindingInfo = data_exports.get(node, boundElementDomDataKey2);
|
|
2534
|
+
return bindingInfo && bindingInfo.context;
|
|
2535
|
+
}
|
|
2536
|
+
function contextFor(node) {
|
|
2537
|
+
if (node && (node.nodeType === 1 || node.nodeType === 8)) {
|
|
2538
|
+
return storedBindingContextForNode(node);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function dataFor(node) {
|
|
2542
|
+
var context = contextFor(node);
|
|
2543
|
+
return context ? context.$data : void 0;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
// ../lifecycle/dist/LifeCycle.js
|
|
2547
|
+
var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
|
|
2548
|
+
var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
|
|
2549
|
+
var LifeCycle = class {
|
|
2550
|
+
static mixInto(Constructor) {
|
|
2551
|
+
const target = Constructor.prototype || Constructor;
|
|
2552
|
+
const mixin = LifeCycle.prototype;
|
|
2553
|
+
for (let prop of Object.getOwnPropertyNames(mixin)) {
|
|
2554
|
+
target[prop] = mixin[prop];
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
subscribe(observable2, action, subscriptionType) {
|
|
2558
|
+
if (typeof action === "string") {
|
|
2559
|
+
action = this[action];
|
|
2560
|
+
}
|
|
2561
|
+
this.addDisposable(observable2.subscribe(action, this, subscriptionType));
|
|
2562
|
+
}
|
|
2563
|
+
computed(params) {
|
|
2564
|
+
if (typeof params === "string") {
|
|
2565
|
+
params = { read: this[params], write: this[params] };
|
|
2566
|
+
}
|
|
2567
|
+
if (typeof params === "object") {
|
|
2568
|
+
params = Object.assign({ owner: this }, params);
|
|
2569
|
+
} else if (typeof params === "function") {
|
|
2570
|
+
const proto = Object.getPrototypeOf(this);
|
|
2571
|
+
if (proto && proto[params.name] === params) {
|
|
2572
|
+
params = params.bind(this);
|
|
2573
|
+
}
|
|
2574
|
+
params = { read: params, write: params };
|
|
2575
|
+
} else {
|
|
2576
|
+
throw new Error("LifeCycle::computed not given a valid type.");
|
|
2577
|
+
}
|
|
2578
|
+
params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
|
|
2579
|
+
return this.addDisposable(computed(params));
|
|
2580
|
+
}
|
|
2581
|
+
addEventListener(...args) {
|
|
2582
|
+
const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
|
|
2583
|
+
const [type, act, options3] = args;
|
|
2584
|
+
const handler = typeof act === "string" ? this[act].bind(this) : act;
|
|
2585
|
+
this.__addEventListener(node, type, handler, options3);
|
|
2586
|
+
}
|
|
2587
|
+
__addEventListener(node, eventType, handler, options3) {
|
|
2588
|
+
node.addEventListener(eventType, handler, options3);
|
|
2589
|
+
function dispose() {
|
|
2590
|
+
node.removeEventListener(eventType, handler);
|
|
2591
|
+
}
|
|
2592
|
+
addDisposeCallback(node, dispose);
|
|
2593
|
+
this.addDisposable({ dispose });
|
|
2594
|
+
}
|
|
2595
|
+
anchorTo(nodeOrLifeCycle) {
|
|
2596
|
+
if ("addDisposable" in nodeOrLifeCycle) {
|
|
2597
|
+
nodeOrLifeCycle.addDisposable(this);
|
|
2598
|
+
this[ANCHOR_NODE] = null;
|
|
2599
|
+
} else {
|
|
2600
|
+
this[ANCHOR_NODE] = nodeOrLifeCycle;
|
|
2601
|
+
addDisposeCallback(nodeOrLifeCycle, () => this[ANCHOR_NODE] === nodeOrLifeCycle && this.dispose());
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
dispose() {
|
|
2605
|
+
const subscriptions = this[SUBSCRIPTIONS] || [];
|
|
2606
|
+
subscriptions.forEach((s) => s.dispose());
|
|
2607
|
+
this[SUBSCRIPTIONS] = [];
|
|
2608
|
+
this[ANCHOR_NODE] = null;
|
|
2609
|
+
}
|
|
2610
|
+
addDisposable(subscription) {
|
|
2611
|
+
const subscriptions = this[SUBSCRIPTIONS] || [];
|
|
2612
|
+
if (!this[SUBSCRIPTIONS]) {
|
|
2613
|
+
this[SUBSCRIPTIONS] = subscriptions;
|
|
2614
|
+
}
|
|
2615
|
+
if (typeof subscription.dispose !== "function") {
|
|
2616
|
+
throw new Error("Lifecycle::addDisposable argument missing `dispose`.");
|
|
2617
|
+
}
|
|
2618
|
+
subscriptions.push(subscription);
|
|
2619
|
+
return subscription;
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
|
|
2623
|
+
// ../bind/dist/BindingHandler.js
|
|
2624
|
+
var BindingHandler = class extends LifeCycle {
|
|
2625
|
+
constructor(params) {
|
|
2626
|
+
super();
|
|
2627
|
+
const { $element, valueAccessor, allBindings, $context } = params;
|
|
2628
|
+
Object.assign(this, {
|
|
2629
|
+
valueAccessor,
|
|
2630
|
+
allBindings,
|
|
2631
|
+
$element,
|
|
2632
|
+
$context,
|
|
2633
|
+
$data: $context.$data
|
|
2634
|
+
});
|
|
2635
|
+
this.anchorTo($element);
|
|
2636
|
+
}
|
|
2637
|
+
get value() {
|
|
2638
|
+
return this.valueAccessor();
|
|
2639
|
+
}
|
|
2640
|
+
set value(v) {
|
|
2641
|
+
const va = this.valueAccessor();
|
|
2642
|
+
if (isWriteableObservable(va)) {
|
|
2643
|
+
va(v);
|
|
2644
|
+
} else {
|
|
2645
|
+
this.valueAccessor(v);
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
get controlsDescendants() {
|
|
2649
|
+
return false;
|
|
2650
|
+
}
|
|
2651
|
+
static get allowVirtualElements() {
|
|
2652
|
+
return false;
|
|
2653
|
+
}
|
|
2654
|
+
static get isBindingHandlerClass() {
|
|
2655
|
+
return true;
|
|
2656
|
+
}
|
|
2657
|
+
get bindingCompleted() {
|
|
2658
|
+
return true;
|
|
2659
|
+
}
|
|
2660
|
+
static registerAs(name, provider = options_default.bindingProviderInstance) {
|
|
2661
|
+
provider.bindingHandlers.set(name, this);
|
|
2662
|
+
}
|
|
2663
|
+
};
|
|
2664
|
+
var ResolveSymbol = Symbol("Async Binding Resolved");
|
|
2665
|
+
var AsyncBindingHandler = class extends BindingHandler {
|
|
2666
|
+
constructor(params) {
|
|
2667
|
+
super(params);
|
|
2668
|
+
this.bindingCompletion = new Promise((resolve) => {
|
|
2669
|
+
this[ResolveSymbol] = resolve;
|
|
2670
|
+
});
|
|
2671
|
+
this.completeBinding = (bindingResult) => this[ResolveSymbol](bindingResult);
|
|
2672
|
+
}
|
|
2673
|
+
get bindingCompleted() {
|
|
2674
|
+
return this.bindingCompletion;
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
|
|
2678
|
+
// ../bind/dist/LegacyBindingHandler.js
|
|
2679
|
+
var PossibleWeakMap = options_default.global.WeakMap || Map;
|
|
2680
|
+
var legacyBindingMap = new PossibleWeakMap();
|
|
2681
|
+
var LegacyBindingHandler = class extends BindingHandler {
|
|
2682
|
+
constructor(params) {
|
|
2683
|
+
super(params);
|
|
2684
|
+
const handler = this.handler;
|
|
2685
|
+
this.onError = params.onError;
|
|
2686
|
+
if (typeof handler.dispose === "function") {
|
|
2687
|
+
this.addDisposable(handler);
|
|
2688
|
+
}
|
|
2689
|
+
try {
|
|
2690
|
+
this.initReturn = handler.init && handler.init(...this.legacyArgs);
|
|
2691
|
+
} catch (e) {
|
|
2692
|
+
params.onError("init", e);
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
onValueChange() {
|
|
2696
|
+
const handler = this.handler;
|
|
2697
|
+
if (typeof handler.update !== "function") {
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
try {
|
|
2701
|
+
handler.update(...this.legacyArgs);
|
|
2702
|
+
} catch (e) {
|
|
2703
|
+
this.onError("update", e);
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
get legacyArgs() {
|
|
2707
|
+
return [
|
|
2708
|
+
this.$element,
|
|
2709
|
+
this.valueAccessor,
|
|
2710
|
+
this.allBindings,
|
|
2711
|
+
this.$data,
|
|
2712
|
+
this.$context
|
|
2713
|
+
];
|
|
2714
|
+
}
|
|
2715
|
+
get controlsDescendants() {
|
|
2716
|
+
const objectToTest = this.initReturn || this.handler || {};
|
|
2717
|
+
return objectToTest.controlsDescendantBindings;
|
|
2718
|
+
}
|
|
2719
|
+
static getOrCreateFor(key, handler) {
|
|
2720
|
+
if (legacyBindingMap.has(handler)) {
|
|
2721
|
+
return legacyBindingMap.get(handler);
|
|
2722
|
+
}
|
|
2723
|
+
const newLegacyHandler = this.createFor(key, handler);
|
|
2724
|
+
legacyBindingMap.set(handler, newLegacyHandler);
|
|
2725
|
+
return newLegacyHandler;
|
|
2726
|
+
}
|
|
2727
|
+
static createFor(key, handler) {
|
|
2728
|
+
if (typeof handler === "function") {
|
|
2729
|
+
const [initFn, disposeFn] = [handler, handler.dispose];
|
|
2730
|
+
return class extends LegacyBindingHandler {
|
|
2731
|
+
get handler() {
|
|
2732
|
+
const init = initFn.bind(this);
|
|
2733
|
+
const dispose = disposeFn ? disposeFn.bind(this) : null;
|
|
2734
|
+
return { init, dispose };
|
|
2735
|
+
}
|
|
2736
|
+
static get after() {
|
|
2737
|
+
return handler.after;
|
|
2738
|
+
}
|
|
2739
|
+
static get allowVirtualElements() {
|
|
2740
|
+
return handler.allowVirtualElements || virtualElements_exports.allowedBindings[key];
|
|
2741
|
+
}
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
if (typeof handler === "object") {
|
|
2745
|
+
return class extends LegacyBindingHandler {
|
|
2746
|
+
get handler() {
|
|
2747
|
+
return handler;
|
|
2748
|
+
}
|
|
2749
|
+
static get after() {
|
|
2750
|
+
return handler.after;
|
|
2751
|
+
}
|
|
2752
|
+
static get allowVirtualElements() {
|
|
2753
|
+
return handler.allowVirtualElements || virtualElements_exports.allowedBindings[key];
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2756
|
+
}
|
|
2757
|
+
throw new Error("The given handler is not an appropriate type.");
|
|
2758
|
+
}
|
|
2759
|
+
};
|
|
2760
|
+
|
|
2761
|
+
// ../bind/dist/applyBindings.js
|
|
2762
|
+
var bindingDoesNotRecurseIntoElementTypes = {
|
|
2763
|
+
"script": true,
|
|
2764
|
+
"textarea": true,
|
|
2765
|
+
"template": true
|
|
2766
|
+
};
|
|
2767
|
+
function getBindingProvider() {
|
|
2768
|
+
return options_default.bindingProviderInstance.instance || options_default.bindingProviderInstance;
|
|
2769
|
+
}
|
|
2770
|
+
function isProviderForNode(provider, node) {
|
|
2771
|
+
const nodeTypes = provider.FOR_NODE_TYPES || [1, 3, 8];
|
|
2772
|
+
return nodeTypes.includes(node.nodeType);
|
|
2773
|
+
}
|
|
2774
|
+
function asProperHandlerClass(handler, bindingKey) {
|
|
2775
|
+
if (!handler) {
|
|
2776
|
+
return;
|
|
2777
|
+
}
|
|
2778
|
+
return handler.isBindingHandlerClass ? handler : LegacyBindingHandler.getOrCreateFor(bindingKey, handler);
|
|
2779
|
+
}
|
|
2780
|
+
function getBindingHandlerFromComponent(bindingKey, $component) {
|
|
2781
|
+
if (!$component || typeof $component.getBindingHandler !== "function") {
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
return asProperHandlerClass($component.getBindingHandler(bindingKey));
|
|
2785
|
+
}
|
|
2786
|
+
function getBindingHandler(bindingKey) {
|
|
2787
|
+
const bindingDefinition = options_default.getBindingHandler(bindingKey) || getBindingProvider().bindingHandlers.get(bindingKey);
|
|
2788
|
+
return asProperHandlerClass(bindingDefinition, bindingKey);
|
|
2789
|
+
}
|
|
2790
|
+
function evaluateValueAccessor(valueAccessor) {
|
|
2791
|
+
return valueAccessor();
|
|
2792
|
+
}
|
|
2793
|
+
function applyBindingsToDescendantsInternal(bindingContext2, elementOrVirtualElement, asyncBindingsApplied) {
|
|
2794
|
+
let nextInQueue = virtualElements_exports.firstChild(elementOrVirtualElement);
|
|
2795
|
+
if (!nextInQueue) {
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
let currentChild;
|
|
2799
|
+
const provider = getBindingProvider();
|
|
2800
|
+
const preprocessNode = provider.preprocessNode;
|
|
2801
|
+
if (preprocessNode) {
|
|
2802
|
+
while (currentChild = nextInQueue) {
|
|
2803
|
+
nextInQueue = virtualElements_exports.nextSibling(currentChild);
|
|
2804
|
+
preprocessNode.call(provider, currentChild);
|
|
2805
|
+
}
|
|
2806
|
+
nextInQueue = virtualElements_exports.firstChild(elementOrVirtualElement);
|
|
2807
|
+
}
|
|
2808
|
+
while (currentChild = nextInQueue) {
|
|
2809
|
+
nextInQueue = virtualElements_exports.nextSibling(currentChild);
|
|
2810
|
+
applyBindingsToNodeAndDescendantsInternal(bindingContext2, currentChild, asyncBindingsApplied);
|
|
2811
|
+
}
|
|
2812
|
+
bindingEvent.notify(elementOrVirtualElement, bindingEvent.childrenComplete);
|
|
2813
|
+
}
|
|
2814
|
+
function hasBindings(node) {
|
|
2815
|
+
const provider = getBindingProvider();
|
|
2816
|
+
return isProviderForNode(provider, node) && provider.nodeHasBindings(node);
|
|
2817
|
+
}
|
|
2818
|
+
function nodeOrChildHasBindings(node) {
|
|
2819
|
+
return hasBindings(node) || [...node.childNodes].some((c) => nodeOrChildHasBindings(c));
|
|
2820
|
+
}
|
|
2821
|
+
function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied) {
|
|
2822
|
+
var isElement = nodeVerified.nodeType === 1;
|
|
2823
|
+
if (isElement) {
|
|
2824
|
+
virtualElements_exports.normaliseVirtualElementDomStructure(nodeVerified);
|
|
2825
|
+
}
|
|
2826
|
+
let shouldApplyBindings = isElement || hasBindings(nodeVerified);
|
|
2827
|
+
const { shouldBindDescendants } = shouldApplyBindings ? applyBindingsToNodeInternal(nodeVerified, null, bindingContext2, asyncBindingsApplied) : { shouldBindDescendants: true };
|
|
2828
|
+
if (shouldBindDescendants && !bindingDoesNotRecurseIntoElementTypes[tagNameLower(nodeVerified)]) {
|
|
2829
|
+
applyBindingsToDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
function* topologicalSortBindings(bindings2, $component) {
|
|
2833
|
+
const results = [];
|
|
2834
|
+
const bindingsConsidered = {};
|
|
2835
|
+
const cyclicDependencyStack = [];
|
|
2836
|
+
objectForEach(bindings2, function pushBinding(bindingKey) {
|
|
2837
|
+
if (!bindingsConsidered[bindingKey]) {
|
|
2838
|
+
const binding = getBindingHandlerFromComponent(bindingKey, $component) || getBindingHandler(bindingKey);
|
|
2839
|
+
if (!binding) {
|
|
2840
|
+
return;
|
|
2841
|
+
}
|
|
2842
|
+
if (binding.after) {
|
|
2843
|
+
cyclicDependencyStack.push(bindingKey);
|
|
2844
|
+
arrayForEach(binding.after, function(bindingDependencyKey) {
|
|
2845
|
+
if (!bindings2[bindingDependencyKey]) {
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
if (arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {
|
|
2849
|
+
throw Error("Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", "));
|
|
2850
|
+
} else {
|
|
2851
|
+
pushBinding(bindingDependencyKey);
|
|
2852
|
+
}
|
|
2853
|
+
});
|
|
2854
|
+
cyclicDependencyStack.length--;
|
|
2855
|
+
}
|
|
2856
|
+
results.push([bindingKey, binding]);
|
|
2857
|
+
}
|
|
2858
|
+
bindingsConsidered[bindingKey] = true;
|
|
2859
|
+
});
|
|
2860
|
+
for (const result of results) {
|
|
2861
|
+
yield result;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyncBindingsApplied) {
|
|
2865
|
+
const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey2, {});
|
|
2866
|
+
const alreadyBound = bindingInfo.alreadyBound;
|
|
2867
|
+
if (!sourceBindings) {
|
|
2868
|
+
if (alreadyBound) {
|
|
2869
|
+
if (!nodeOrChildHasBindings(node)) {
|
|
2870
|
+
return false;
|
|
2871
|
+
}
|
|
2872
|
+
onBindingError({
|
|
2873
|
+
during: "apply",
|
|
2874
|
+
errorCaptured: new Error("You cannot apply bindings multiple times to the same element."),
|
|
2875
|
+
element: node,
|
|
2876
|
+
bindingContext: bindingContext2
|
|
2877
|
+
});
|
|
2878
|
+
return false;
|
|
2879
|
+
}
|
|
2880
|
+
bindingInfo.alreadyBound = true;
|
|
2881
|
+
}
|
|
2882
|
+
if (!alreadyBound) {
|
|
2883
|
+
bindingInfo.context = bindingContext2;
|
|
2884
|
+
}
|
|
2885
|
+
var bindings2;
|
|
2886
|
+
if (sourceBindings && typeof sourceBindings !== "function") {
|
|
2887
|
+
bindings2 = sourceBindings;
|
|
2888
|
+
} else {
|
|
2889
|
+
const provider = getBindingProvider();
|
|
2890
|
+
const getBindings = provider.getBindingAccessors;
|
|
2891
|
+
if (isProviderForNode(provider, node)) {
|
|
2892
|
+
var bindingsUpdater = computed(function() {
|
|
2893
|
+
bindings2 = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
|
|
2894
|
+
if (bindings2 && bindingContext2[contextSubscribeSymbol]) {
|
|
2895
|
+
bindingContext2[contextSubscribeSymbol]();
|
|
2896
|
+
}
|
|
2897
|
+
return bindings2;
|
|
2898
|
+
}, null, { disposeWhenNodeIsRemoved: node });
|
|
2899
|
+
if (!bindings2 || !bindingsUpdater.isActive()) {
|
|
2900
|
+
bindingsUpdater = null;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
var bindingHandlerThatControlsDescendantBindings;
|
|
2905
|
+
if (bindings2) {
|
|
2906
|
+
let allBindings = function() {
|
|
2907
|
+
return objectMap(bindingsUpdater ? bindingsUpdater() : bindings2, evaluateValueAccessor);
|
|
2908
|
+
};
|
|
2909
|
+
const $component = bindingContext2.$component || {};
|
|
2910
|
+
const allBindingHandlers = {};
|
|
2911
|
+
data_exports.set(node, "bindingHandlers", allBindingHandlers);
|
|
2912
|
+
const getValueAccessor = bindingsUpdater ? (bindingKey) => function(optionalValue) {
|
|
2913
|
+
const valueAccessor = bindingsUpdater()[bindingKey];
|
|
2914
|
+
if (arguments.length === 0) {
|
|
2915
|
+
return evaluateValueAccessor(valueAccessor);
|
|
2916
|
+
} else {
|
|
2917
|
+
return valueAccessor(optionalValue);
|
|
2918
|
+
}
|
|
2919
|
+
} : (bindingKey) => bindings2[bindingKey];
|
|
2920
|
+
allBindings.has = (key) => key in bindings2;
|
|
2921
|
+
allBindings.get = (key) => bindings2[key] && evaluateValueAccessor(getValueAccessor(key));
|
|
2922
|
+
if (bindingEvent.childrenComplete in bindings2) {
|
|
2923
|
+
bindingEvent.subscribe(node, bindingEvent.childrenComplete, () => {
|
|
2924
|
+
const callback = evaluateValueAccessor(bindings2[bindingEvent.childrenComplete]);
|
|
2925
|
+
if (!callback) {
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
const nodes = virtualElements_exports.childNodes(node);
|
|
2929
|
+
if (nodes.length) {
|
|
2930
|
+
callback(nodes, dataFor(nodes[0]));
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2933
|
+
}
|
|
2934
|
+
const bindingsGenerated = topologicalSortBindings(bindings2, $component);
|
|
2935
|
+
const nodeAsyncBindingPromises = /* @__PURE__ */ new Set();
|
|
2936
|
+
for (const [key, BindingHandlerClass] of bindingsGenerated) {
|
|
2937
|
+
let reportBindingError = function(during, errorCaptured) {
|
|
2938
|
+
onBindingError({
|
|
2939
|
+
during,
|
|
2940
|
+
errorCaptured,
|
|
2941
|
+
bindings: bindings2,
|
|
2942
|
+
allBindings,
|
|
2943
|
+
bindingKey: key,
|
|
2944
|
+
bindingContext: bindingContext2,
|
|
2945
|
+
element: node,
|
|
2946
|
+
valueAccessor: getValueAccessor(key)
|
|
2947
|
+
});
|
|
2948
|
+
};
|
|
2949
|
+
if (node.nodeType === 8 && !BindingHandlerClass.allowVirtualElements) {
|
|
2950
|
+
throw new Error(`The binding '${key}' cannot be used with virtual elements`);
|
|
2951
|
+
}
|
|
2952
|
+
try {
|
|
2953
|
+
const bindingHandler = dependencyDetection_exports.ignore(() => new BindingHandlerClass({
|
|
2954
|
+
allBindings,
|
|
2955
|
+
$element: node,
|
|
2956
|
+
$context: bindingContext2,
|
|
2957
|
+
onError: reportBindingError,
|
|
2958
|
+
valueAccessor(...v) {
|
|
2959
|
+
return getValueAccessor(key)(...v);
|
|
2960
|
+
}
|
|
2961
|
+
}));
|
|
2962
|
+
if (bindingHandler.onValueChange) {
|
|
2963
|
+
dependencyDetection_exports.ignore(() => bindingHandler.computed("onValueChange"));
|
|
2964
|
+
}
|
|
2965
|
+
allBindingHandlers[key] = bindingHandler;
|
|
2966
|
+
if (bindingHandler.controlsDescendants) {
|
|
2967
|
+
if (bindingHandlerThatControlsDescendantBindings !== void 0) {
|
|
2968
|
+
throw new Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + key + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
|
|
2969
|
+
}
|
|
2970
|
+
bindingHandlerThatControlsDescendantBindings = key;
|
|
2971
|
+
}
|
|
2972
|
+
if (bindingHandler.bindingCompleted instanceof Promise) {
|
|
2973
|
+
asyncBindingsApplied.add(bindingHandler.bindingCompleted);
|
|
2974
|
+
nodeAsyncBindingPromises.add(bindingHandler.bindingCompleted);
|
|
2975
|
+
}
|
|
2976
|
+
} catch (err) {
|
|
2977
|
+
reportBindingError("creation", err);
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
triggerDescendantsComplete(node, bindings2, nodeAsyncBindingPromises);
|
|
2981
|
+
}
|
|
2982
|
+
const shouldBindDescendants = bindingHandlerThatControlsDescendantBindings === void 0;
|
|
2983
|
+
return { shouldBindDescendants };
|
|
2984
|
+
}
|
|
2985
|
+
function triggerDescendantsComplete(node, bindings2, nodeAsyncBindingPromises) {
|
|
2986
|
+
const hasBindingHandler = bindingEvent.descendantsComplete in bindings2;
|
|
2987
|
+
const hasFirstChild = virtualElements_exports.firstChild(node);
|
|
2988
|
+
const accessor = hasBindingHandler && evaluateValueAccessor(bindings2[bindingEvent.descendantsComplete]);
|
|
2989
|
+
const callback = () => {
|
|
2990
|
+
bindingEvent.notify(node, bindingEvent.descendantsComplete);
|
|
2991
|
+
if (accessor && hasFirstChild) {
|
|
2992
|
+
accessor(node);
|
|
2993
|
+
}
|
|
2994
|
+
};
|
|
2995
|
+
if (nodeAsyncBindingPromises.size) {
|
|
2996
|
+
Promise.all(nodeAsyncBindingPromises).then(callback);
|
|
2997
|
+
} else {
|
|
2998
|
+
callback();
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
|
|
3002
|
+
return viewModelOrBindingContext && viewModelOrBindingContext instanceof bindingContext ? viewModelOrBindingContext : new bindingContext(viewModelOrBindingContext, void 0, void 0, extendContextCallback);
|
|
3003
|
+
}
|
|
3004
|
+
function applyBindings(viewModelOrBindingContext, rootNode, extendContextCallback) {
|
|
3005
|
+
const asyncBindingsApplied = /* @__PURE__ */ new Set();
|
|
3006
|
+
if (!options_default.jQuery === void 0 && options_default.jQuery) {
|
|
3007
|
+
options_default.jQuery = options_default.jQuery;
|
|
3008
|
+
}
|
|
3009
|
+
if (!rootNode) {
|
|
3010
|
+
rootNode = window.document.body;
|
|
3011
|
+
if (!rootNode) {
|
|
3012
|
+
throw Error("ko.applyBindings: could not find window.document.body; has the document been loaded?");
|
|
3013
|
+
}
|
|
3014
|
+
} else if (rootNode.nodeType !== 1 && rootNode.nodeType !== 8) {
|
|
3015
|
+
throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");
|
|
3016
|
+
}
|
|
3017
|
+
const rootContext = getBindingContext(viewModelOrBindingContext, extendContextCallback);
|
|
3018
|
+
applyBindingsToNodeAndDescendantsInternal(rootContext, rootNode, asyncBindingsApplied);
|
|
3019
|
+
return Promise.all(asyncBindingsApplied);
|
|
3020
|
+
}
|
|
3021
|
+
function onBindingError(spec) {
|
|
3022
|
+
var error, bindingText;
|
|
3023
|
+
if (spec.bindingKey) {
|
|
3024
|
+
error = spec.errorCaptured;
|
|
3025
|
+
spec.message = 'Unable to process binding "' + spec.bindingKey + '" in binding "' + spec.bindingKey + '"\nMessage: ' + (error.message ? error.message : error);
|
|
3026
|
+
} else {
|
|
3027
|
+
error = spec.errorCaptured;
|
|
3028
|
+
}
|
|
3029
|
+
try {
|
|
3030
|
+
extend(error, spec);
|
|
3031
|
+
} catch (e) {
|
|
3032
|
+
spec.stack = error.stack;
|
|
3033
|
+
error = new Error(error.message ? error.message : error);
|
|
3034
|
+
extend(error, spec);
|
|
3035
|
+
}
|
|
3036
|
+
options_default.onError(error);
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
// ../bind/dist/arrayToDomNodeChildren.js
|
|
3040
|
+
function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {
|
|
3041
|
+
var mappedNodes = [];
|
|
3042
|
+
var dependentObservable = computed(function() {
|
|
3043
|
+
var newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
|
|
3044
|
+
if (mappedNodes.length > 0) {
|
|
3045
|
+
replaceDomNodes(mappedNodes, newMappedNodes);
|
|
3046
|
+
if (callbackAfterAddingNodes) {
|
|
3047
|
+
dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
mappedNodes.length = 0;
|
|
3051
|
+
arrayPushAll(mappedNodes, newMappedNodes);
|
|
3052
|
+
}, null, { disposeWhenNodeIsRemoved: containerNode, disposeWhen: function() {
|
|
3053
|
+
return !anyDomNodeIsAttachedToDocument(mappedNodes);
|
|
3054
|
+
} });
|
|
3055
|
+
return { mappedNodes, dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0 };
|
|
3056
|
+
}
|
|
3057
|
+
var lastMappingResultDomDataKey = data_exports.nextKey();
|
|
3058
|
+
var deletedItemDummyValue = data_exports.nextKey();
|
|
3059
|
+
function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, callbackAfterAddingNodes, editScript) {
|
|
3060
|
+
array = array || [];
|
|
3061
|
+
if (typeof array.length === "undefined") {
|
|
3062
|
+
array = [array];
|
|
3063
|
+
}
|
|
3064
|
+
options3 = options3 || {};
|
|
3065
|
+
let lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
|
|
3066
|
+
let isFirstExecution = !lastMappingResult;
|
|
3067
|
+
var newMappingResult = [];
|
|
3068
|
+
var lastMappingResultIndex = 0;
|
|
3069
|
+
var newMappingResultIndex = 0;
|
|
3070
|
+
var nodesToDelete = [];
|
|
3071
|
+
var itemsToProcess = [];
|
|
3072
|
+
var itemsForBeforeRemoveCallbacks = [];
|
|
3073
|
+
var itemsForMoveCallbacks = [];
|
|
3074
|
+
var itemsForAfterAddCallbacks = [];
|
|
3075
|
+
var mapData;
|
|
3076
|
+
let countWaitingForRemove = 0;
|
|
3077
|
+
function itemAdded(value) {
|
|
3078
|
+
mapData = { arrayEntry: value, indexObservable: observable(newMappingResultIndex++) };
|
|
3079
|
+
newMappingResult.push(mapData);
|
|
3080
|
+
itemsToProcess.push(mapData);
|
|
3081
|
+
if (!isFirstExecution) {
|
|
3082
|
+
itemsForAfterAddCallbacks.push(mapData);
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
function itemMovedOrRetained(oldPosition) {
|
|
3086
|
+
mapData = lastMappingResult[oldPosition];
|
|
3087
|
+
if (newMappingResultIndex !== oldPosition) {
|
|
3088
|
+
itemsForMoveCallbacks.push(mapData);
|
|
3089
|
+
}
|
|
3090
|
+
mapData.indexObservable(newMappingResultIndex++);
|
|
3091
|
+
fixUpContinuousNodeArray(mapData.mappedNodes, domNode);
|
|
3092
|
+
newMappingResult.push(mapData);
|
|
3093
|
+
itemsToProcess.push(mapData);
|
|
3094
|
+
}
|
|
3095
|
+
function callCallback(callback, items) {
|
|
3096
|
+
if (callback) {
|
|
3097
|
+
for (var i2 = 0, n = items.length; i2 < n; i2++) {
|
|
3098
|
+
arrayForEach(items[i2].mappedNodes, function(node2) {
|
|
3099
|
+
callback(node2, i2, items[i2].arrayEntry);
|
|
3100
|
+
});
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
if (isFirstExecution) {
|
|
3105
|
+
arrayForEach(array, itemAdded);
|
|
3106
|
+
} else {
|
|
3107
|
+
if (!editScript || lastMappingResult && lastMappingResult["_countWaitingForRemove"]) {
|
|
3108
|
+
var lastArray = isFirstExecution ? [] : arrayMap(lastMappingResult, function(x) {
|
|
3109
|
+
return x.arrayEntry;
|
|
3110
|
+
});
|
|
3111
|
+
var compareOptions = {
|
|
3112
|
+
"dontLimitMoves": options3["dontLimitMoves"],
|
|
3113
|
+
"sparse": true
|
|
3114
|
+
};
|
|
3115
|
+
editScript = compareArrays(lastArray, array, compareOptions);
|
|
3116
|
+
}
|
|
3117
|
+
for (var i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
|
|
3118
|
+
movedIndex = editScriptItem["moved"];
|
|
3119
|
+
itemIndex = editScriptItem["index"];
|
|
3120
|
+
switch (editScriptItem["status"]) {
|
|
3121
|
+
case "deleted":
|
|
3122
|
+
while (lastMappingResultIndex < itemIndex) {
|
|
3123
|
+
itemMovedOrRetained(lastMappingResultIndex++);
|
|
3124
|
+
}
|
|
3125
|
+
if (movedIndex === void 0) {
|
|
3126
|
+
mapData = lastMappingResult[lastMappingResultIndex];
|
|
3127
|
+
if (mapData.dependentObservable) {
|
|
3128
|
+
mapData.dependentObservable.dispose();
|
|
3129
|
+
mapData.dependentObservable = void 0;
|
|
3130
|
+
}
|
|
3131
|
+
if (fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {
|
|
3132
|
+
if (options3["beforeRemove"]) {
|
|
3133
|
+
newMappingResult.push(mapData);
|
|
3134
|
+
itemsToProcess.push(mapData);
|
|
3135
|
+
countWaitingForRemove++;
|
|
3136
|
+
if (mapData.arrayEntry === deletedItemDummyValue) {
|
|
3137
|
+
mapData = null;
|
|
3138
|
+
} else {
|
|
3139
|
+
itemsForBeforeRemoveCallbacks.push(mapData);
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
if (mapData) {
|
|
3143
|
+
nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
lastMappingResultIndex++;
|
|
3148
|
+
break;
|
|
3149
|
+
case "added":
|
|
3150
|
+
while (newMappingResultIndex < itemIndex) {
|
|
3151
|
+
itemMovedOrRetained(lastMappingResultIndex++);
|
|
3152
|
+
}
|
|
3153
|
+
if (movedIndex !== void 0) {
|
|
3154
|
+
itemMovedOrRetained(movedIndex);
|
|
3155
|
+
} else {
|
|
3156
|
+
itemAdded(editScriptItem["value"]);
|
|
3157
|
+
}
|
|
3158
|
+
break;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
while (newMappingResultIndex < array.length) {
|
|
3162
|
+
itemMovedOrRetained(lastMappingResultIndex++);
|
|
3163
|
+
}
|
|
3164
|
+
newMappingResult["_countWaitingForRemove"] = countWaitingForRemove;
|
|
3165
|
+
}
|
|
3166
|
+
data_exports.set(domNode, lastMappingResultDomDataKey, newMappingResult);
|
|
3167
|
+
callCallback(options3["beforeMove"], itemsForMoveCallbacks);
|
|
3168
|
+
arrayForEach(nodesToDelete, options3["beforeRemove"] ? cleanNode : removeNode);
|
|
3169
|
+
i = 0;
|
|
3170
|
+
for (var nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[i]; i++) {
|
|
3171
|
+
if (!mapData.mappedNodes) {
|
|
3172
|
+
extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
|
|
3173
|
+
}
|
|
3174
|
+
for (var j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
|
|
3175
|
+
if (node !== nextNode) {
|
|
3176
|
+
virtualElements_exports.insertAfter(domNode, node, lastNode);
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
if (!mapData.initialized && callbackAfterAddingNodes) {
|
|
3180
|
+
callbackAfterAddingNodes(mapData.arrayEntry, mapData.mappedNodes, mapData.indexObservable);
|
|
3181
|
+
mapData.initialized = true;
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
callCallback(options3["beforeRemove"], itemsForBeforeRemoveCallbacks);
|
|
3185
|
+
for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
|
|
3186
|
+
itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
|
|
3187
|
+
}
|
|
3188
|
+
callCallback(options3["afterMove"], itemsForMoveCallbacks);
|
|
3189
|
+
callCallback(options3["afterAdd"], itemsForAfterAddCallbacks);
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
// src/templating.ts
|
|
3193
|
+
var _templateEngine;
|
|
3194
|
+
var cleanContainerDomDataKey = data_exports.nextKey();
|
|
3195
|
+
function setTemplateEngine(tEngine) {
|
|
3196
|
+
if (tEngine !== void 0 && !(tEngine instanceof templateEngine)) {
|
|
3197
|
+
throw new Error("templateEngine must inherit from ko.templateEngine");
|
|
3198
|
+
}
|
|
3199
|
+
_templateEngine = tEngine;
|
|
3200
|
+
}
|
|
3201
|
+
function invokeForEachNodeInContinuousRange(firstNode, lastNode, action) {
|
|
3202
|
+
let node;
|
|
3203
|
+
let nextInQueue = firstNode;
|
|
3204
|
+
let firstOutOfRangeNode = virtualElements_exports.nextSibling(lastNode);
|
|
3205
|
+
while (nextInQueue && (node = nextInQueue) !== firstOutOfRangeNode) {
|
|
3206
|
+
nextInQueue = virtualElements_exports.nextSibling(node);
|
|
3207
|
+
action(node, nextInQueue);
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingContext2, afterBindingCallback) {
|
|
3211
|
+
if (continuousNodeArray.length) {
|
|
3212
|
+
var firstNode = continuousNodeArray[0];
|
|
3213
|
+
var lastNode = continuousNodeArray[continuousNodeArray.length - 1];
|
|
3214
|
+
var parentNode = firstNode.parentNode;
|
|
3215
|
+
var provider = options_default.bindingProviderInstance;
|
|
3216
|
+
var preprocessNode = provider.preprocessNode;
|
|
3217
|
+
if (preprocessNode) {
|
|
3218
|
+
invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node, nextNodeInRange) {
|
|
3219
|
+
var nodePreviousSibling = node.previousSibling;
|
|
3220
|
+
var newNodes = preprocessNode.call(provider, node);
|
|
3221
|
+
if (newNodes) {
|
|
3222
|
+
if (node === firstNode) {
|
|
3223
|
+
firstNode = newNodes[0] || nextNodeInRange;
|
|
3224
|
+
}
|
|
3225
|
+
if (node === lastNode) {
|
|
3226
|
+
lastNode = newNodes[newNodes.length - 1] || nodePreviousSibling;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
continuousNodeArray.length = 0;
|
|
3231
|
+
if (!firstNode) {
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
if (firstNode === lastNode) {
|
|
3235
|
+
continuousNodeArray.push(firstNode);
|
|
3236
|
+
} else {
|
|
3237
|
+
continuousNodeArray.push(firstNode, lastNode);
|
|
3238
|
+
fixUpContinuousNodeArray(continuousNodeArray, parentNode);
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {
|
|
3242
|
+
if (node.nodeType === 1 || node.nodeType === 8) {
|
|
3243
|
+
applyBindings(bindingContext2, node).then(afterBindingCallback);
|
|
3244
|
+
}
|
|
3245
|
+
});
|
|
3246
|
+
invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {
|
|
3247
|
+
if (node.nodeType === 1 || node.nodeType === 8) {
|
|
3248
|
+
memoization_exports.unmemoizeDomNodeAndDescendants(node, [bindingContext2]);
|
|
3249
|
+
}
|
|
3250
|
+
});
|
|
3251
|
+
fixUpContinuousNodeArray(continuousNodeArray, parentNode);
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
function getFirstNodeFromPossibleArray(nodeOrNodeArray) {
|
|
3255
|
+
return nodeOrNodeArray.nodeType ? nodeOrNodeArray : nodeOrNodeArray.length > 0 ? nodeOrNodeArray[0] : null;
|
|
3256
|
+
}
|
|
3257
|
+
function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingContext2, options3, afterBindingCallback) {
|
|
3258
|
+
options3 = options3 || {};
|
|
3259
|
+
var firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
|
|
3260
|
+
var templateDocument = (firstTargetNode || template || {}).ownerDocument;
|
|
3261
|
+
var templateEngineToUse = options3.templateEngine || _templateEngine;
|
|
3262
|
+
var renderedNodesArray = templateEngineToUse.renderTemplate(template, bindingContext2, options3, templateDocument);
|
|
3263
|
+
if (typeof renderedNodesArray.length !== "number" || renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType !== "number") {
|
|
3264
|
+
throw new Error("Template engine must return an array of DOM nodes");
|
|
3265
|
+
}
|
|
3266
|
+
var haveAddedNodesToParent = false;
|
|
3267
|
+
switch (renderMode) {
|
|
3268
|
+
case "replaceChildren":
|
|
3269
|
+
virtualElements_exports.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
|
|
3270
|
+
haveAddedNodesToParent = true;
|
|
3271
|
+
break;
|
|
3272
|
+
case "replaceNode":
|
|
3273
|
+
replaceDomNodes(targetNodeOrNodeArray, renderedNodesArray);
|
|
3274
|
+
haveAddedNodesToParent = true;
|
|
3275
|
+
break;
|
|
3276
|
+
case "ignoreTargetNode":
|
|
3277
|
+
break;
|
|
3278
|
+
default:
|
|
3279
|
+
throw new Error("Unknown renderMode: " + renderMode);
|
|
3280
|
+
}
|
|
3281
|
+
if (haveAddedNodesToParent) {
|
|
3282
|
+
activateBindingsOnContinuousNodeArray(renderedNodesArray, bindingContext2, afterBindingCallback);
|
|
3283
|
+
if (options3.afterRender) {
|
|
3284
|
+
dependencyDetection_exports.ignore(options3.afterRender, null, [renderedNodesArray, bindingContext2["$data"]]);
|
|
3285
|
+
}
|
|
3286
|
+
if (renderMode === "replaceChildren") {
|
|
3287
|
+
bindingEvent.notify(targetNodeOrNodeArray, bindingEvent.childrenComplete);
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
return renderedNodesArray;
|
|
3291
|
+
}
|
|
3292
|
+
function resolveTemplateName(template, data, context) {
|
|
3293
|
+
if (isObservable(template)) {
|
|
3294
|
+
return template();
|
|
3295
|
+
} else if (typeof template === "function") {
|
|
3296
|
+
return template(data, context);
|
|
3297
|
+
} else {
|
|
3298
|
+
return template;
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
function renderTemplate(template, dataOrBindingContext, options3, targetNodeOrNodeArray, renderMode, afterBindingCallback) {
|
|
3302
|
+
options3 = options3 || {};
|
|
3303
|
+
if ((options3.templateEngine || _templateEngine) === void 0) {
|
|
3304
|
+
throw new Error("Set a template engine before calling renderTemplate");
|
|
3305
|
+
}
|
|
3306
|
+
renderMode = renderMode || "replaceChildren";
|
|
3307
|
+
if (targetNodeOrNodeArray) {
|
|
3308
|
+
var firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
|
|
3309
|
+
var whenToDispose = function() {
|
|
3310
|
+
return !firstTargetNode || !domNodeIsAttachedToDocument(firstTargetNode);
|
|
3311
|
+
};
|
|
3312
|
+
var activelyDisposeWhenNodeIsRemoved = firstTargetNode && renderMode === "replaceNode" ? firstTargetNode.parentNode : firstTargetNode;
|
|
3313
|
+
return computed(function() {
|
|
3314
|
+
var bindingContext2 = dataOrBindingContext && dataOrBindingContext instanceof bindingContext ? dataOrBindingContext : new bindingContext(dataOrBindingContext, null, null, null, { "exportDependencies": true });
|
|
3315
|
+
var templateName = resolveTemplateName(template, bindingContext2.$data, bindingContext2);
|
|
3316
|
+
const renderedNodesArray = executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext2, options3, afterBindingCallback);
|
|
3317
|
+
if (renderMode === "replaceNode") {
|
|
3318
|
+
targetNodeOrNodeArray = renderedNodesArray;
|
|
3319
|
+
firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);
|
|
3320
|
+
}
|
|
3321
|
+
}, null, { disposeWhen: whenToDispose, disposeWhenNodeIsRemoved: activelyDisposeWhenNodeIsRemoved });
|
|
3322
|
+
} else {
|
|
3323
|
+
return memoization_exports.memoize(function(domNode) {
|
|
3324
|
+
renderTemplate(template, dataOrBindingContext, options3, domNode, "replaceNode");
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
function renderTemplateForEach(template, arrayOrObservableArray, options3, targetNode, parentBindingContext, afterBindingCallback) {
|
|
3329
|
+
var arrayItemContext;
|
|
3330
|
+
function executeTemplateForArrayItem(arrayValue, index) {
|
|
3331
|
+
if (options3.as) {
|
|
3332
|
+
if (options_default.createChildContextWithAs) {
|
|
3333
|
+
arrayItemContext = parentBindingContext.createChildContext(arrayValue, options3.as, (context) => {
|
|
3334
|
+
context.$index = index;
|
|
3335
|
+
});
|
|
3336
|
+
} else {
|
|
3337
|
+
arrayItemContext = parentBindingContext.extend({
|
|
3338
|
+
[options3.as]: arrayValue,
|
|
3339
|
+
$index: index
|
|
3340
|
+
});
|
|
3341
|
+
}
|
|
3342
|
+
} else {
|
|
3343
|
+
arrayItemContext = parentBindingContext.createChildContext(arrayValue, options3.as, (context) => {
|
|
3344
|
+
context.$index = index;
|
|
3345
|
+
});
|
|
3346
|
+
}
|
|
3347
|
+
var templateName = resolveTemplateName(template, arrayValue, arrayItemContext);
|
|
3348
|
+
return executeTemplate(targetNode, "ignoreTargetNode", templateName, arrayItemContext, options3, afterBindingCallback);
|
|
3349
|
+
}
|
|
3350
|
+
var activateBindingsCallback = function(arrayValue, addedNodesArray) {
|
|
3351
|
+
activateBindingsOnContinuousNodeArray(addedNodesArray, arrayItemContext, afterBindingCallback);
|
|
3352
|
+
if (options3.afterRender) {
|
|
3353
|
+
options3.afterRender(addedNodesArray, arrayValue);
|
|
3354
|
+
}
|
|
3355
|
+
arrayItemContext = null;
|
|
3356
|
+
};
|
|
3357
|
+
function localSetDomNodeChildrenFromArrayMapping(newArray, changeList) {
|
|
3358
|
+
dependencyDetection_exports.ignore(setDomNodeChildrenFromArrayMapping, null, [targetNode, newArray, executeTemplateForArrayItem, options3, activateBindingsCallback, changeList]);
|
|
3359
|
+
bindingEvent.notify(targetNode, bindingEvent.childrenComplete);
|
|
3360
|
+
}
|
|
3361
|
+
const shouldHideDestroyed = options3.includeDestroyed === false || options_default.foreachHidesDestroyed && !options3.includeDestroyed;
|
|
3362
|
+
if (!shouldHideDestroyed && !options3.beforeRemove && isObservableArray(arrayOrObservableArray)) {
|
|
3363
|
+
localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray.peek());
|
|
3364
|
+
var subscription = arrayOrObservableArray.subscribe(function(changeList) {
|
|
3365
|
+
localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray(), changeList);
|
|
3366
|
+
}, null, "arrayChange");
|
|
3367
|
+
subscription.disposeWhenNodeIsRemoved(targetNode);
|
|
3368
|
+
return subscription;
|
|
3369
|
+
} else {
|
|
3370
|
+
return computed(function() {
|
|
3371
|
+
var unwrappedArray = unwrap(arrayOrObservableArray) || [];
|
|
3372
|
+
const unwrappedIsIterable = Symbol.iterator in unwrappedArray;
|
|
3373
|
+
if (!unwrappedIsIterable) {
|
|
3374
|
+
unwrappedArray = [unwrappedArray];
|
|
3375
|
+
}
|
|
3376
|
+
if (shouldHideDestroyed) {
|
|
3377
|
+
unwrappedArray = arrayFilter(unwrappedArray, function(item) {
|
|
3378
|
+
return item === void 0 || item === null || !unwrap(item._destroy);
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3381
|
+
localSetDomNodeChildrenFromArrayMapping(unwrappedArray);
|
|
3382
|
+
}, null, { disposeWhenNodeIsRemoved: targetNode });
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
var templateComputedDomDataKey = data_exports.nextKey();
|
|
3386
|
+
var TemplateBindingHandler = class extends AsyncBindingHandler {
|
|
3387
|
+
constructor(params) {
|
|
3388
|
+
super(params);
|
|
3389
|
+
const element = this.$element;
|
|
3390
|
+
const bindingValue = unwrap(this.value);
|
|
3391
|
+
data_exports.set(element, "conditional", {
|
|
3392
|
+
elseChainSatisfied: observable(true)
|
|
3393
|
+
});
|
|
3394
|
+
if (typeof bindingValue === "string" || bindingValue.name) {
|
|
3395
|
+
this.bindNamedTemplate();
|
|
3396
|
+
} else if ("nodes" in bindingValue) {
|
|
3397
|
+
this.bindNodeTemplate(bindingValue.nodes || []);
|
|
3398
|
+
} else {
|
|
3399
|
+
this.bindAnonymousTemplate();
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
bindNamedTemplate() {
|
|
3403
|
+
virtualElements_exports.emptyNode(this.$element);
|
|
3404
|
+
}
|
|
3405
|
+
bindNodeTemplate(nodes) {
|
|
3406
|
+
if (isObservable(nodes)) {
|
|
3407
|
+
throw new Error('The "nodes" option must be a plain, non-observable array.');
|
|
3408
|
+
}
|
|
3409
|
+
let container = nodes[0] && nodes[0].parentNode;
|
|
3410
|
+
if (!container || !data_exports.get(container, cleanContainerDomDataKey)) {
|
|
3411
|
+
container = moveCleanedNodesToContainerElement(nodes);
|
|
3412
|
+
data_exports.set(container, cleanContainerDomDataKey, true);
|
|
3413
|
+
}
|
|
3414
|
+
new anonymousTemplate(this.$element).nodes(container);
|
|
3415
|
+
}
|
|
3416
|
+
bindAnonymousTemplate() {
|
|
3417
|
+
const templateNodes = virtualElements_exports.childNodes(this.$element);
|
|
3418
|
+
if (templateNodes.length === 0) {
|
|
3419
|
+
throw new Error("Anonymous template defined, but no template content was provided.");
|
|
3420
|
+
}
|
|
3421
|
+
const container = moveCleanedNodesToContainerElement(templateNodes);
|
|
3422
|
+
new anonymousTemplate(this.$element).nodes(container);
|
|
3423
|
+
}
|
|
3424
|
+
onValueChange() {
|
|
3425
|
+
const element = this.$element;
|
|
3426
|
+
const bindingContext2 = this.$context;
|
|
3427
|
+
var value = this.value;
|
|
3428
|
+
var options3 = unwrap(value);
|
|
3429
|
+
var shouldDisplay = true;
|
|
3430
|
+
var templateComputed = null;
|
|
3431
|
+
var elseChainSatisfied = data_exports.get(element, "conditional").elseChainSatisfied;
|
|
3432
|
+
var templateName;
|
|
3433
|
+
if (typeof options3 === "string") {
|
|
3434
|
+
templateName = value;
|
|
3435
|
+
options3 = {};
|
|
3436
|
+
} else {
|
|
3437
|
+
templateName = options3.name;
|
|
3438
|
+
if ("if" in options3) {
|
|
3439
|
+
shouldDisplay = unwrap(options3.if);
|
|
3440
|
+
}
|
|
3441
|
+
if (shouldDisplay && "ifnot" in options3) {
|
|
3442
|
+
shouldDisplay = !unwrap(options3.ifnot);
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
if ("foreach" in options3) {
|
|
3446
|
+
var dataArray = shouldDisplay && options3.foreach || [];
|
|
3447
|
+
templateComputed = renderTemplateForEach(templateName || element, dataArray, options3, element, bindingContext2, this.completeBinding);
|
|
3448
|
+
elseChainSatisfied((unwrap(dataArray) || []).length !== 0);
|
|
3449
|
+
} else if (shouldDisplay) {
|
|
3450
|
+
var innerBindingContext = "data" in options3 ? bindingContext2.createStaticChildContext(options3.data, options3.as) : bindingContext2;
|
|
3451
|
+
templateComputed = renderTemplate(templateName || element, innerBindingContext, options3, element, void 0, this.completeBinding);
|
|
3452
|
+
elseChainSatisfied(true);
|
|
3453
|
+
} else {
|
|
3454
|
+
virtualElements_exports.emptyNode(element);
|
|
3455
|
+
elseChainSatisfied(false);
|
|
3456
|
+
}
|
|
3457
|
+
this.disposeOldComputedAndStoreNewOne(element, templateComputed);
|
|
3458
|
+
}
|
|
3459
|
+
disposeOldComputedAndStoreNewOne(element, newComputed) {
|
|
3460
|
+
let oldComputed = data_exports.get(element, templateComputedDomDataKey);
|
|
3461
|
+
if (oldComputed && typeof oldComputed.dispose === "function") {
|
|
3462
|
+
oldComputed.dispose();
|
|
3463
|
+
}
|
|
3464
|
+
data_exports.set(element, templateComputedDomDataKey, newComputed && (!newComputed.isActive || newComputed.isActive()) ? newComputed : void 0);
|
|
3465
|
+
}
|
|
3466
|
+
get controlsDescendants() {
|
|
3467
|
+
return true;
|
|
3468
|
+
}
|
|
3469
|
+
static get allowVirtualElements() {
|
|
3470
|
+
return true;
|
|
3471
|
+
}
|
|
3472
|
+
};
|
|
3473
|
+
|
|
3474
|
+
// src/nativeTemplateEngine.ts
|
|
3475
|
+
function nativeTemplateEngine() {
|
|
3476
|
+
}
|
|
3477
|
+
nativeTemplateEngine.prototype = new templateEngine();
|
|
3478
|
+
nativeTemplateEngine.prototype.constructor = nativeTemplateEngine;
|
|
3479
|
+
nativeTemplateEngine.prototype.renderTemplateSource = function(templateSource, bindingContext2, options3, templateDocument) {
|
|
3480
|
+
var useNodesIfAvailable = !(ieVersion < 9), templateNodesFunc = useNodesIfAvailable ? templateSource.nodes : null, templateNodes = templateNodesFunc ? templateSource.nodes() : null;
|
|
3481
|
+
if (templateNodes) {
|
|
3482
|
+
return makeArray(templateNodes.cloneNode(true).childNodes);
|
|
3483
|
+
} else {
|
|
3484
|
+
var templateText = templateSource.text();
|
|
3485
|
+
return parseHtmlFragment(templateText, templateDocument);
|
|
3486
|
+
}
|
|
3487
|
+
};
|
|
3488
|
+
nativeTemplateEngine.instance = new nativeTemplateEngine();
|
|
3489
|
+
setTemplateEngine(nativeTemplateEngine.instance);
|
|
3490
|
+
|
|
3491
|
+
// src/foreach.ts
|
|
3492
|
+
var TemplateForEachBindingHandler = class extends TemplateBindingHandler {
|
|
3493
|
+
get value() {
|
|
3494
|
+
const modelValue = this.valueAccessor();
|
|
3495
|
+
const unwrappedValue = peek(modelValue);
|
|
3496
|
+
if (!unwrappedValue || typeof unwrappedValue.length === "number") {
|
|
3497
|
+
return { foreach: modelValue, templateEngine: nativeTemplateEngine.instance };
|
|
3498
|
+
}
|
|
3499
|
+
unwrap(modelValue);
|
|
3500
|
+
return {
|
|
3501
|
+
foreach: unwrappedValue.data,
|
|
3502
|
+
as: unwrappedValue.as,
|
|
3503
|
+
includeDestroyed: unwrappedValue.includeDestroyed,
|
|
3504
|
+
afterAdd: unwrappedValue.afterAdd,
|
|
3505
|
+
beforeRemove: unwrappedValue.beforeRemove,
|
|
3506
|
+
afterRender: unwrappedValue.afterRender,
|
|
3507
|
+
beforeMove: unwrappedValue.beforeMove,
|
|
3508
|
+
afterMove: unwrappedValue.afterMove,
|
|
3509
|
+
templateEngine: nativeTemplateEngine.instance
|
|
3510
|
+
};
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3513
|
+
|
|
3514
|
+
// src/index.ts
|
|
3515
|
+
var bindings = {
|
|
3516
|
+
foreach: TemplateForEachBindingHandler,
|
|
3517
|
+
template: TemplateBindingHandler
|
|
3518
|
+
};
|