@tko/lifecycle 4.0.0-beta1.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LifeCycle.js +19 -10
- package/dist/LifeCycle.js.map +2 -2
- package/dist/index.cjs +425 -315
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +2 -2
- package/package.json +5 -6
- package/LICENSE +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
// @tko/lifecycle 🥊 4.0.0
|
|
1
|
+
// @tko/lifecycle 🥊 4.0.0 CommonJS
|
|
2
|
+
"use strict";
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
8
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,19 +21,51 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
21
|
return to;
|
|
17
22
|
};
|
|
18
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __await = function(promise, isYieldStar) {
|
|
25
|
+
this[0] = promise;
|
|
26
|
+
this[1] = isYieldStar;
|
|
27
|
+
};
|
|
28
|
+
var __yieldStar = (value) => {
|
|
29
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
30
|
+
if (obj == null) {
|
|
31
|
+
obj = value[__knownSymbol("iterator")]();
|
|
32
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
33
|
+
} else {
|
|
34
|
+
obj = obj.call(value);
|
|
35
|
+
method = (k) => it[k] = (v) => {
|
|
36
|
+
if (isAwait) {
|
|
37
|
+
isAwait = false;
|
|
38
|
+
if (k === "throw") throw v;
|
|
39
|
+
return v;
|
|
40
|
+
}
|
|
41
|
+
isAwait = true;
|
|
42
|
+
return {
|
|
43
|
+
done: false,
|
|
44
|
+
value: new __await(new Promise((resolve) => {
|
|
45
|
+
var x = obj[k](v);
|
|
46
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
47
|
+
resolve(x);
|
|
48
|
+
}), 1)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
53
|
+
throw x;
|
|
54
|
+
}, "return" in obj && method("return"), it;
|
|
55
|
+
};
|
|
19
56
|
|
|
20
57
|
// index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
58
|
+
var index_exports = {};
|
|
59
|
+
__export(index_exports, {
|
|
23
60
|
LifeCycle: () => LifeCycle
|
|
24
61
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
62
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
63
|
|
|
27
64
|
// ../utils/dist/array.js
|
|
28
65
|
var { isArray } = Array;
|
|
29
|
-
function arrayForEach(array, action,
|
|
66
|
+
function arrayForEach(array, action, actionOwner) {
|
|
30
67
|
if (arguments.length > 2) {
|
|
31
|
-
action = action.bind(
|
|
68
|
+
action = action.bind(actionOwner);
|
|
32
69
|
}
|
|
33
70
|
for (let i = 0, j = array.length; i < j; ++i) {
|
|
34
71
|
action(array[i], i, array);
|
|
@@ -38,7 +75,7 @@ function arrayIndexOf(array, item) {
|
|
|
38
75
|
return (isArray(array) ? array : [...array]).indexOf(item);
|
|
39
76
|
}
|
|
40
77
|
function arrayRemoveItem(array, itemToRemove) {
|
|
41
|
-
|
|
78
|
+
const index = arrayIndexOf(array, itemToRemove);
|
|
42
79
|
if (index > 0) {
|
|
43
80
|
array.splice(index, 1);
|
|
44
81
|
} else if (index === 0) {
|
|
@@ -47,7 +84,7 @@ function arrayRemoveItem(array, itemToRemove) {
|
|
|
47
84
|
}
|
|
48
85
|
function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
49
86
|
if (left.length && right.length) {
|
|
50
|
-
|
|
87
|
+
let failedCompares, l, r, leftItem, rightItem;
|
|
51
88
|
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
52
89
|
for (r = 0; rightItem = right[r]; ++r) {
|
|
53
90
|
if (leftItem.value === rightItem.value) {
|
|
@@ -75,10 +112,10 @@ function compareArrays(oldArray, newArray, options2) {
|
|
|
75
112
|
}
|
|
76
113
|
}
|
|
77
114
|
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
|
|
78
|
-
|
|
115
|
+
let myMin = Math.min, myMax = Math.max, editDistanceMatrix = new Array(), smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
|
|
79
116
|
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
80
117
|
lastRow = thisRow;
|
|
81
|
-
editDistanceMatrix.push(thisRow =
|
|
118
|
+
editDistanceMatrix.push(thisRow = new Array());
|
|
82
119
|
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
83
120
|
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
84
121
|
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
@@ -89,35 +126,38 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
89
126
|
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
90
127
|
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
91
128
|
} else {
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
const northDistance = lastRow[bigIndex] || maxDistance;
|
|
130
|
+
const westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
94
131
|
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
95
132
|
}
|
|
96
133
|
}
|
|
97
134
|
}
|
|
98
|
-
|
|
135
|
+
let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
|
|
99
136
|
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
100
137
|
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
101
138
|
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
102
|
-
notInSml.push(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
139
|
+
notInSml.push(
|
|
140
|
+
editScript[editScript.length] = {
|
|
141
|
+
// added
|
|
142
|
+
status: statusNotInSml,
|
|
143
|
+
value: bigArray[--bigIndex],
|
|
144
|
+
index: bigIndex
|
|
145
|
+
}
|
|
146
|
+
);
|
|
107
147
|
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
108
|
-
notInBig.push(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
notInBig.push(
|
|
149
|
+
editScript[editScript.length] = {
|
|
150
|
+
// deleted
|
|
151
|
+
status: statusNotInBig,
|
|
152
|
+
value: smlArray[--smlIndex],
|
|
153
|
+
index: smlIndex
|
|
154
|
+
}
|
|
155
|
+
);
|
|
113
156
|
} else {
|
|
114
157
|
--bigIndex;
|
|
115
158
|
--smlIndex;
|
|
116
|
-
if (!options2.sparse) {
|
|
117
|
-
editScript.push({
|
|
118
|
-
"status": "retained",
|
|
119
|
-
"value": bigArray[bigIndex]
|
|
120
|
-
});
|
|
159
|
+
if (!(options2 == null ? void 0 : options2.sparse)) {
|
|
160
|
+
editScript.push({ status: "retained", value: bigArray[bigIndex] });
|
|
121
161
|
}
|
|
122
162
|
}
|
|
123
163
|
}
|
|
@@ -126,40 +166,79 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
126
166
|
}
|
|
127
167
|
|
|
128
168
|
// ../utils/dist/options.js
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
var Options = class {
|
|
170
|
+
constructor() {
|
|
171
|
+
this.bindingStringPreparsers = [];
|
|
172
|
+
this.knockoutInstance = null;
|
|
173
|
+
this.deferUpdates = false;
|
|
174
|
+
this.useOnlyNativeEvents = true;
|
|
175
|
+
this.useTemplateTag = true;
|
|
176
|
+
this.protoProperty = "__ko_proto__";
|
|
177
|
+
this.defaultBindingAttribute = "data-bind";
|
|
178
|
+
this.allowVirtualElements = true;
|
|
179
|
+
this.bindingGlobals = /* @__PURE__ */ Object.create(null);
|
|
180
|
+
this.createChildContextWithAs = false;
|
|
181
|
+
this.disableJQueryUsage = false;
|
|
182
|
+
this.Promise = globalThis.Promise;
|
|
183
|
+
this.taskScheduler = null;
|
|
184
|
+
this.debug = false;
|
|
185
|
+
this.templateSizeLimit = 4096;
|
|
186
|
+
this.allowScriptTagsInTemplates = false;
|
|
187
|
+
this._sanitizeWarningLogged = false;
|
|
188
|
+
this.global = globalThis;
|
|
189
|
+
this.document = globalThis.document;
|
|
190
|
+
this.filters = {};
|
|
191
|
+
this.includeDestroyed = false;
|
|
192
|
+
this.foreachHidesDestroyed = false;
|
|
193
|
+
}
|
|
194
|
+
get jQuery() {
|
|
195
|
+
var _a;
|
|
196
|
+
if (this.disableJQueryUsage) return;
|
|
197
|
+
return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Set jQuery manuall to be used by TKO.
|
|
201
|
+
* @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
|
|
202
|
+
*/
|
|
203
|
+
set jQuery(jQuery) {
|
|
204
|
+
if (!jQuery) {
|
|
205
|
+
this.disableJQueryUsage = true;
|
|
206
|
+
this._jQuery = void 0;
|
|
207
|
+
} else {
|
|
208
|
+
this._jQuery = jQuery;
|
|
209
|
+
this.disableJQueryUsage = false;
|
|
210
|
+
}
|
|
156
211
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Sanitize HTML templates before parsing them. Default is a no-op.
|
|
214
|
+
* Please configure something like DOMPurify or validator.js for your environment.
|
|
215
|
+
* @param html HTML string to be sanitized
|
|
216
|
+
* @returns Sanitized HTML string
|
|
217
|
+
*/
|
|
218
|
+
sanitizeHtmlTemplate(html) {
|
|
219
|
+
if (!this._sanitizeWarningLogged) {
|
|
220
|
+
console.warn(
|
|
221
|
+
"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
|
|
222
|
+
);
|
|
223
|
+
this._sanitizeWarningLogged = true;
|
|
224
|
+
}
|
|
225
|
+
return html;
|
|
161
226
|
}
|
|
162
|
-
|
|
227
|
+
onError(e, throws = true) {
|
|
228
|
+
if (throws) throw e;
|
|
229
|
+
return e;
|
|
230
|
+
}
|
|
231
|
+
set(name, value) {
|
|
232
|
+
this[name] = value;
|
|
233
|
+
}
|
|
234
|
+
// Overload getBindingHandler to have a custom lookup function.
|
|
235
|
+
getBindingHandler(key) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
cleanExternalData(node, callback) {
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var options = new Options();
|
|
163
242
|
var options_default = options;
|
|
164
243
|
|
|
165
244
|
// ../utils/dist/error.js
|
|
@@ -186,7 +265,7 @@ function safeSetTimeout(handler, timeout) {
|
|
|
186
265
|
|
|
187
266
|
// ../utils/dist/async.js
|
|
188
267
|
function throttle(callback, timeout) {
|
|
189
|
-
|
|
268
|
+
let timeoutInstance;
|
|
190
269
|
return function(...args) {
|
|
191
270
|
if (!timeoutInstance) {
|
|
192
271
|
timeoutInstance = safeSetTimeout(function() {
|
|
@@ -197,33 +276,22 @@ function throttle(callback, timeout) {
|
|
|
197
276
|
};
|
|
198
277
|
}
|
|
199
278
|
function debounce(callback, timeout) {
|
|
200
|
-
|
|
279
|
+
let timeoutInstance;
|
|
201
280
|
return function(...args) {
|
|
202
281
|
clearTimeout(timeoutInstance);
|
|
203
282
|
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
204
283
|
};
|
|
205
284
|
}
|
|
206
285
|
|
|
207
|
-
// ../utils/dist/ie.js
|
|
208
|
-
var ieVersion = options_default.document && function() {
|
|
209
|
-
var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
|
|
210
|
-
while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
|
|
211
|
-
}
|
|
212
|
-
if (!version) {
|
|
213
|
-
const userAgent = window.navigator.userAgent;
|
|
214
|
-
return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
|
|
215
|
-
}
|
|
216
|
-
return version > 4 ? version : void 0;
|
|
217
|
-
}();
|
|
218
|
-
|
|
219
286
|
// ../utils/dist/object.js
|
|
220
287
|
function hasOwnProperty(obj, propName) {
|
|
221
288
|
return Object.prototype.hasOwnProperty.call(obj, propName);
|
|
222
289
|
}
|
|
223
290
|
function extend(target, source) {
|
|
224
291
|
if (source) {
|
|
225
|
-
for (
|
|
292
|
+
for (const prop of Object.keys(source)) {
|
|
226
293
|
if (hasOwnProperty(source, prop)) {
|
|
294
|
+
;
|
|
227
295
|
target[prop] = source[prop];
|
|
228
296
|
}
|
|
229
297
|
}
|
|
@@ -231,7 +299,7 @@ function extend(target, source) {
|
|
|
231
299
|
return target;
|
|
232
300
|
}
|
|
233
301
|
function objectForEach(obj, action) {
|
|
234
|
-
for (
|
|
302
|
+
for (const prop in obj) {
|
|
235
303
|
if (hasOwnProperty(obj, prop)) {
|
|
236
304
|
action(prop, obj[prop]);
|
|
237
305
|
}
|
|
@@ -261,27 +329,25 @@ function createSymbolOrString(identifier) {
|
|
|
261
329
|
return useSymbols ? Symbol(identifier) : identifier;
|
|
262
330
|
}
|
|
263
331
|
|
|
264
|
-
// ../utils/dist/jquery.js
|
|
265
|
-
var jQueryInstance = options_default.global && options_default.global.jQuery;
|
|
266
|
-
|
|
267
332
|
// ../utils/dist/dom/info.js
|
|
268
333
|
function domNodeIsContainedBy(node, containedByNode) {
|
|
269
334
|
if (node === containedByNode) {
|
|
270
335
|
return true;
|
|
271
336
|
}
|
|
272
|
-
if (node.nodeType ===
|
|
337
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
273
338
|
return false;
|
|
274
339
|
}
|
|
275
340
|
if (containedByNode.contains) {
|
|
276
|
-
return containedByNode.contains(node.nodeType !==
|
|
341
|
+
return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
|
|
277
342
|
}
|
|
278
343
|
if (containedByNode.compareDocumentPosition) {
|
|
279
344
|
return (containedByNode.compareDocumentPosition(node) & 16) == 16;
|
|
280
345
|
}
|
|
281
|
-
|
|
282
|
-
|
|
346
|
+
let parentNode = node;
|
|
347
|
+
while (parentNode && parentNode != containedByNode) {
|
|
348
|
+
parentNode = parentNode.parentNode;
|
|
283
349
|
}
|
|
284
|
-
return !!
|
|
350
|
+
return !!parentNode;
|
|
285
351
|
}
|
|
286
352
|
function domNodeIsAttachedToDocument(node) {
|
|
287
353
|
return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
|
|
@@ -290,70 +356,70 @@ function tagNameLower(element) {
|
|
|
290
356
|
return element && element.tagName && element.tagName.toLowerCase();
|
|
291
357
|
}
|
|
292
358
|
|
|
359
|
+
// ../utils/dist/dom/event.js
|
|
360
|
+
var knownEvents = {};
|
|
361
|
+
var knownEventTypesByEventName = {};
|
|
362
|
+
knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
|
|
363
|
+
knownEvents["MouseEvents"] = [
|
|
364
|
+
"click",
|
|
365
|
+
"dblclick",
|
|
366
|
+
"mousedown",
|
|
367
|
+
"mouseup",
|
|
368
|
+
"mousemove",
|
|
369
|
+
"mouseover",
|
|
370
|
+
"mouseout",
|
|
371
|
+
"mouseenter",
|
|
372
|
+
"mouseleave"
|
|
373
|
+
];
|
|
374
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
375
|
+
if (knownEventsForType.length) {
|
|
376
|
+
for (let i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
377
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
293
382
|
// ../utils/dist/dom/data.js
|
|
294
|
-
var datastoreTime = new Date().getTime();
|
|
383
|
+
var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
|
|
295
384
|
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
296
|
-
var dataStoreSymbol = Symbol("Knockout data");
|
|
297
|
-
var dataStore;
|
|
385
|
+
var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
|
|
298
386
|
var uniqueId = 0;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
},
|
|
307
|
-
clear(node) {
|
|
308
|
-
if (node[dataStoreSymbol]) {
|
|
309
|
-
delete node[dataStoreSymbol];
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
var IE = {
|
|
316
|
-
getDataforNode(node, createIfNotFound) {
|
|
317
|
-
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
318
|
-
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
|
|
319
|
-
if (!hasExistingDataStore) {
|
|
320
|
-
if (!createIfNotFound) {
|
|
321
|
-
return void 0;
|
|
322
|
-
}
|
|
323
|
-
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
|
324
|
-
dataStore[dataStoreKey] = {};
|
|
325
|
-
}
|
|
326
|
-
return dataStore[dataStoreKey];
|
|
327
|
-
},
|
|
328
|
-
clear(node) {
|
|
329
|
-
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
330
|
-
if (dataStoreKey) {
|
|
331
|
-
delete dataStore[dataStoreKey];
|
|
332
|
-
node[dataStoreKeyExpandoPropertyName] = null;
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
return false;
|
|
387
|
+
function isSafeKey(key) {
|
|
388
|
+
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
389
|
+
}
|
|
390
|
+
function getDataForNode(node, createIfNotFound) {
|
|
391
|
+
let dataForNode = node[dataStoreSymbol];
|
|
392
|
+
if (!dataForNode && createIfNotFound) {
|
|
393
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
336
394
|
}
|
|
337
|
-
|
|
338
|
-
|
|
395
|
+
return dataForNode;
|
|
396
|
+
}
|
|
339
397
|
function nextKey() {
|
|
340
398
|
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
341
399
|
}
|
|
342
400
|
function get(node, key) {
|
|
401
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
343
402
|
const dataForNode = getDataForNode(node, false);
|
|
344
403
|
return dataForNode && dataForNode[key];
|
|
345
404
|
}
|
|
346
405
|
function set(node, key, value) {
|
|
347
|
-
|
|
348
|
-
|
|
406
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
407
|
+
const dataForNode = getDataForNode(
|
|
408
|
+
node,
|
|
409
|
+
value !== void 0
|
|
410
|
+
/* createIfNotFound */
|
|
411
|
+
);
|
|
412
|
+
if (dataForNode) {
|
|
413
|
+
dataForNode[key] = value;
|
|
414
|
+
}
|
|
349
415
|
}
|
|
350
416
|
|
|
351
417
|
// ../utils/dist/dom/disposal.js
|
|
352
418
|
var domDataKey = nextKey();
|
|
353
419
|
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
354
|
-
|
|
420
|
+
let allDisposeCallbacks = get(node, domDataKey);
|
|
355
421
|
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
356
|
-
allDisposeCallbacks =
|
|
422
|
+
allDisposeCallbacks = new Array();
|
|
357
423
|
set(node, domDataKey, allDisposeCallbacks);
|
|
358
424
|
}
|
|
359
425
|
return allDisposeCallbacks;
|
|
@@ -368,7 +434,7 @@ function addDisposeCallback(node, callback) {
|
|
|
368
434
|
getDisposeCallbacksCollection(node, true).push(callback);
|
|
369
435
|
}
|
|
370
436
|
function removeDisposeCallback(node, callback) {
|
|
371
|
-
|
|
437
|
+
const callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
372
438
|
if (callbacksCollection) {
|
|
373
439
|
arrayRemoveItem(callbacksCollection, callback);
|
|
374
440
|
if (callbacksCollection.length === 0) {
|
|
@@ -376,58 +442,34 @@ function removeDisposeCallback(node, callback) {
|
|
|
376
442
|
}
|
|
377
443
|
}
|
|
378
444
|
}
|
|
379
|
-
var otherNodeCleanerFunctions =
|
|
445
|
+
var otherNodeCleanerFunctions = new Array();
|
|
380
446
|
function cleanjQueryData(node) {
|
|
381
|
-
|
|
447
|
+
const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
|
|
382
448
|
if (jQueryCleanNodeFn) {
|
|
383
449
|
jQueryCleanNodeFn([node]);
|
|
384
450
|
}
|
|
385
451
|
}
|
|
386
452
|
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
387
453
|
|
|
388
|
-
// ../utils/dist/dom/event.js
|
|
389
|
-
var knownEvents = {};
|
|
390
|
-
var knownEventTypesByEventName = {};
|
|
391
|
-
var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
|
|
392
|
-
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
|
|
393
|
-
knownEvents["MouseEvents"] = [
|
|
394
|
-
"click",
|
|
395
|
-
"dblclick",
|
|
396
|
-
"mousedown",
|
|
397
|
-
"mouseup",
|
|
398
|
-
"mousemove",
|
|
399
|
-
"mouseover",
|
|
400
|
-
"mouseout",
|
|
401
|
-
"mouseenter",
|
|
402
|
-
"mouseleave"
|
|
403
|
-
];
|
|
404
|
-
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
405
|
-
if (knownEventsForType.length) {
|
|
406
|
-
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
407
|
-
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
// ../utils/dist/dom/virtualElements.js
|
|
413
|
-
var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
|
|
414
|
-
|
|
415
454
|
// ../utils/dist/dom/html.js
|
|
416
|
-
var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
|
|
455
|
+
var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
|
|
417
456
|
|
|
418
457
|
// ../utils/dist/dom/selectExtensions.js
|
|
419
|
-
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
458
|
+
var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
420
459
|
var selectExtensions = {
|
|
421
460
|
optionValueDomDataKey: nextKey(),
|
|
422
461
|
readValue: function(element) {
|
|
423
462
|
switch (tagNameLower(element)) {
|
|
424
|
-
case "option":
|
|
463
|
+
case "option": {
|
|
425
464
|
if (element[hasDomDataExpandoProperty] === true) {
|
|
426
465
|
return get(element, selectExtensions.optionValueDomDataKey);
|
|
427
466
|
}
|
|
428
467
|
return element.value;
|
|
429
|
-
|
|
430
|
-
|
|
468
|
+
}
|
|
469
|
+
case "select": {
|
|
470
|
+
const selectElement = element;
|
|
471
|
+
return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
|
|
472
|
+
}
|
|
431
473
|
default:
|
|
432
474
|
return element.value;
|
|
433
475
|
}
|
|
@@ -440,36 +482,42 @@ var selectExtensions = {
|
|
|
440
482
|
if (hasDomDataExpandoProperty in element) {
|
|
441
483
|
delete element[hasDomDataExpandoProperty];
|
|
442
484
|
}
|
|
485
|
+
;
|
|
443
486
|
element.value = value;
|
|
444
487
|
} else {
|
|
488
|
+
const el = element;
|
|
445
489
|
set(element, selectExtensions.optionValueDomDataKey, value);
|
|
446
|
-
|
|
447
|
-
|
|
490
|
+
el[hasDomDataExpandoProperty] = true;
|
|
491
|
+
el.value = typeof value === "number" ? value : "";
|
|
448
492
|
}
|
|
449
493
|
break;
|
|
450
494
|
case "select":
|
|
451
|
-
|
|
452
|
-
value
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
495
|
+
{
|
|
496
|
+
if (value === "" || value === null) {
|
|
497
|
+
value = void 0;
|
|
498
|
+
}
|
|
499
|
+
let selection = -1;
|
|
500
|
+
const selectElement = element;
|
|
501
|
+
for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
|
|
502
|
+
optionValue = selectExtensions.readValue(selectElement.options[i]);
|
|
503
|
+
const strictEqual = optionValue === value;
|
|
504
|
+
const blankEqual = optionValue === "" && value === void 0;
|
|
505
|
+
const numericEqual = typeof value === "number" && Number(optionValue) === value;
|
|
506
|
+
if (strictEqual || blankEqual || numericEqual) {
|
|
507
|
+
selection = i;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
|
|
512
|
+
selectElement.selectedIndex = selection;
|
|
463
513
|
}
|
|
464
|
-
}
|
|
465
|
-
if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
|
|
466
|
-
element.selectedIndex = selection;
|
|
467
514
|
}
|
|
468
515
|
break;
|
|
469
516
|
default:
|
|
470
517
|
if (value === null || value === void 0) {
|
|
471
518
|
value = "";
|
|
472
519
|
}
|
|
520
|
+
;
|
|
473
521
|
element.value = value;
|
|
474
522
|
break;
|
|
475
523
|
}
|
|
@@ -484,30 +532,19 @@ __export(tasks_exports, {
|
|
|
484
532
|
runEarly: () => processTasks,
|
|
485
533
|
schedule: () => schedule
|
|
486
534
|
});
|
|
487
|
-
var taskQueue =
|
|
535
|
+
var taskQueue = new Array();
|
|
488
536
|
var taskQueueLength = 0;
|
|
489
537
|
var nextHandle = 1;
|
|
490
538
|
var nextIndexToProcess = 0;
|
|
491
539
|
var w = options_default.global;
|
|
492
540
|
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
493
|
-
options_default.taskScheduler = function(callback) {
|
|
494
|
-
|
|
541
|
+
options_default.taskScheduler = (function(callback) {
|
|
542
|
+
const div = w.document.createElement("div");
|
|
495
543
|
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
496
544
|
return function() {
|
|
497
545
|
div.classList.toggle("foo");
|
|
498
546
|
};
|
|
499
|
-
}(scheduledProcess);
|
|
500
|
-
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
|
|
501
|
-
options_default.taskScheduler = function(callback) {
|
|
502
|
-
var script = document.createElement("script");
|
|
503
|
-
script.onreadystatechange = function() {
|
|
504
|
-
script.onreadystatechange = null;
|
|
505
|
-
document.documentElement.removeChild(script);
|
|
506
|
-
script = null;
|
|
507
|
-
callback();
|
|
508
|
-
};
|
|
509
|
-
document.documentElement.appendChild(script);
|
|
510
|
-
};
|
|
547
|
+
})(scheduledProcess);
|
|
511
548
|
} else {
|
|
512
549
|
options_default.taskScheduler = function(callback) {
|
|
513
550
|
setTimeout(callback, 0);
|
|
@@ -515,8 +552,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
|
515
552
|
}
|
|
516
553
|
function processTasks() {
|
|
517
554
|
if (taskQueueLength) {
|
|
518
|
-
|
|
519
|
-
for (
|
|
555
|
+
let mark = taskQueueLength, countMarks = 0;
|
|
556
|
+
for (let task; nextIndexToProcess < taskQueueLength; ) {
|
|
520
557
|
if (task = taskQueue[nextIndexToProcess++]) {
|
|
521
558
|
if (nextIndexToProcess > mark) {
|
|
522
559
|
if (++countMarks >= 5e3) {
|
|
@@ -550,13 +587,13 @@ function schedule(func) {
|
|
|
550
587
|
return nextHandle++;
|
|
551
588
|
}
|
|
552
589
|
function cancel(handle) {
|
|
553
|
-
|
|
590
|
+
const index = handle - (nextHandle - taskQueueLength);
|
|
554
591
|
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
555
592
|
taskQueue[index] = null;
|
|
556
593
|
}
|
|
557
594
|
}
|
|
558
595
|
function resetForTesting() {
|
|
559
|
-
|
|
596
|
+
const length = taskQueueLength - nextIndexToProcess;
|
|
560
597
|
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
561
598
|
return length;
|
|
562
599
|
}
|
|
@@ -575,13 +612,13 @@ __export(dependencyDetection_exports, {
|
|
|
575
612
|
});
|
|
576
613
|
|
|
577
614
|
// ../observable/dist/subscribableSymbol.js
|
|
578
|
-
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
|
|
615
|
+
var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
|
|
579
616
|
function isSubscribable(instance) {
|
|
580
617
|
return instance && instance[SUBSCRIBABLE_SYM] || false;
|
|
581
618
|
}
|
|
582
619
|
|
|
583
620
|
// ../observable/dist/dependencyDetection.js
|
|
584
|
-
var outerFrames =
|
|
621
|
+
var outerFrames = new Array();
|
|
585
622
|
var currentFrame;
|
|
586
623
|
var lastId = 0;
|
|
587
624
|
function getId() {
|
|
@@ -599,7 +636,11 @@ function registerDependency(subscribable2) {
|
|
|
599
636
|
if (!isSubscribable(subscribable2)) {
|
|
600
637
|
throw new Error("Only subscribable things can act as dependencies");
|
|
601
638
|
}
|
|
602
|
-
currentFrame.callback.call(
|
|
639
|
+
currentFrame.callback.call(
|
|
640
|
+
currentFrame.callbackTarget,
|
|
641
|
+
subscribable2,
|
|
642
|
+
subscribable2._id || (subscribable2._id = getId())
|
|
643
|
+
);
|
|
603
644
|
}
|
|
604
645
|
}
|
|
605
646
|
function ignore(callback, callbackTarget, callbackArgs) {
|
|
@@ -614,16 +655,19 @@ function getDependenciesCount() {
|
|
|
614
655
|
if (currentFrame) {
|
|
615
656
|
return currentFrame.computed.getDependenciesCount();
|
|
616
657
|
}
|
|
658
|
+
return void 0;
|
|
617
659
|
}
|
|
618
660
|
function getDependencies() {
|
|
619
661
|
if (currentFrame) {
|
|
620
662
|
return currentFrame.computed.getDependencies();
|
|
621
663
|
}
|
|
664
|
+
return void 0;
|
|
622
665
|
}
|
|
623
666
|
function isInitial() {
|
|
624
667
|
if (currentFrame) {
|
|
625
668
|
return currentFrame.isInitial;
|
|
626
669
|
}
|
|
670
|
+
return void 0;
|
|
627
671
|
}
|
|
628
672
|
|
|
629
673
|
// ../observable/dist/defer.js
|
|
@@ -670,6 +714,7 @@ var Subscription = class {
|
|
|
670
714
|
this._node = node;
|
|
671
715
|
addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
|
|
672
716
|
}
|
|
717
|
+
// TC39 Observable API
|
|
673
718
|
unsubscribe() {
|
|
674
719
|
this.dispose();
|
|
675
720
|
}
|
|
@@ -679,21 +724,16 @@ var Subscription = class {
|
|
|
679
724
|
};
|
|
680
725
|
|
|
681
726
|
// ../observable/dist/extenders.js
|
|
682
|
-
var primitiveTypes = {
|
|
683
|
-
"undefined": 1,
|
|
684
|
-
"boolean": 1,
|
|
685
|
-
"number": 1,
|
|
686
|
-
"string": 1
|
|
687
|
-
};
|
|
727
|
+
var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
|
|
688
728
|
function valuesArePrimitiveAndEqual(a, b) {
|
|
689
|
-
|
|
729
|
+
const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
|
|
690
730
|
return oldValueIsPrimitive ? a === b : false;
|
|
691
731
|
}
|
|
692
732
|
function applyExtenders(requestedExtenders) {
|
|
693
|
-
|
|
733
|
+
let target = this;
|
|
694
734
|
if (requestedExtenders) {
|
|
695
735
|
objectForEach(requestedExtenders, function(key, value) {
|
|
696
|
-
|
|
736
|
+
const extenderHandler = extenders[key];
|
|
697
737
|
if (typeof extenderHandler === "function") {
|
|
698
738
|
target = extenderHandler(target, value) || target;
|
|
699
739
|
} else {
|
|
@@ -708,12 +748,14 @@ function notify(target, notifyWhen) {
|
|
|
708
748
|
}
|
|
709
749
|
function deferred(target, option) {
|
|
710
750
|
if (option !== true) {
|
|
711
|
-
throw new Error(
|
|
751
|
+
throw new Error(
|
|
752
|
+
"The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
|
|
753
|
+
);
|
|
712
754
|
}
|
|
713
755
|
deferUpdates(target);
|
|
714
756
|
}
|
|
715
757
|
function rateLimit(target, options2) {
|
|
716
|
-
|
|
758
|
+
let timeout, method, limitFunction;
|
|
717
759
|
if (typeof options2 === "number") {
|
|
718
760
|
timeout = options2;
|
|
719
761
|
} else {
|
|
@@ -726,21 +768,17 @@ function rateLimit(target, options2) {
|
|
|
726
768
|
return limitFunction(callback, timeout);
|
|
727
769
|
});
|
|
728
770
|
}
|
|
729
|
-
var extenders = {
|
|
730
|
-
notify,
|
|
731
|
-
deferred,
|
|
732
|
-
rateLimit
|
|
733
|
-
};
|
|
771
|
+
var extenders = { notify, deferred, rateLimit };
|
|
734
772
|
|
|
735
773
|
// ../observable/dist/subscribable.js
|
|
736
|
-
var LATEST_VALUE = Symbol("Knockout latest value");
|
|
774
|
+
var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
|
|
737
775
|
if (!Symbol.observable) {
|
|
738
|
-
Symbol.observable = Symbol.for("@tko/Symbol.observable");
|
|
776
|
+
Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
|
|
739
777
|
}
|
|
740
|
-
function
|
|
778
|
+
var subscribable = function subscribableFactory() {
|
|
741
779
|
Object.setPrototypeOf(this, ko_subscribable_fn);
|
|
742
780
|
ko_subscribable_fn.init(this);
|
|
743
|
-
}
|
|
781
|
+
};
|
|
744
782
|
var defaultEvent = "change";
|
|
745
783
|
var ko_subscribable_fn = {
|
|
746
784
|
[SUBSCRIBABLE_SYM]: true,
|
|
@@ -754,9 +792,7 @@ var ko_subscribable_fn = {
|
|
|
754
792
|
subscribe(callback, callbackTarget, event) {
|
|
755
793
|
const isTC39Callback = typeof callback === "object" && callback.next;
|
|
756
794
|
event = event || defaultEvent;
|
|
757
|
-
const observer = isTC39Callback ? callback : {
|
|
758
|
-
next: callbackTarget ? callback.bind(callbackTarget) : callback
|
|
759
|
-
};
|
|
795
|
+
const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
|
|
760
796
|
const subscriptionInstance = new Subscription(this, observer, () => {
|
|
761
797
|
arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
|
|
762
798
|
if (this.afterSubscriptionRemove) {
|
|
@@ -767,7 +803,7 @@ var ko_subscribable_fn = {
|
|
|
767
803
|
this.beforeSubscriptionAdd(event);
|
|
768
804
|
}
|
|
769
805
|
if (!this._subscriptions[event]) {
|
|
770
|
-
this._subscriptions[event] =
|
|
806
|
+
this._subscriptions[event] = new Array();
|
|
771
807
|
}
|
|
772
808
|
this._subscriptions[event].push(subscriptionInstance);
|
|
773
809
|
if (isTC39Callback && LATEST_VALUE in this) {
|
|
@@ -810,7 +846,7 @@ var ko_subscribable_fn = {
|
|
|
810
846
|
if (event) {
|
|
811
847
|
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
|
812
848
|
} else {
|
|
813
|
-
|
|
849
|
+
let total = 0;
|
|
814
850
|
objectForEach(this._subscriptions, function(eventName, subscriptions) {
|
|
815
851
|
if (eventName !== "dirty") {
|
|
816
852
|
total += subscriptions.length;
|
|
@@ -865,6 +901,7 @@ function observable(initialValue) {
|
|
|
865
901
|
function Observable() {
|
|
866
902
|
if (arguments.length > 0) {
|
|
867
903
|
if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
|
|
904
|
+
;
|
|
868
905
|
Observable.valueWillMutate();
|
|
869
906
|
Observable[LATEST_VALUE] = arguments[0];
|
|
870
907
|
Observable.valueHasMutated();
|
|
@@ -885,20 +922,43 @@ function observable(initialValue) {
|
|
|
885
922
|
return Observable;
|
|
886
923
|
}
|
|
887
924
|
observable.fn = {
|
|
925
|
+
/**
|
|
926
|
+
* Compares two values for equality.
|
|
927
|
+
* @param a The first value.
|
|
928
|
+
* @param b The second value.
|
|
929
|
+
* @returns True if the values are equal, otherwise false.
|
|
930
|
+
*/
|
|
888
931
|
equalityComparer: valuesArePrimitiveAndEqual,
|
|
932
|
+
/**
|
|
933
|
+
* Returns the current value of the observable without creating a dependency.
|
|
934
|
+
* @returns The current value.
|
|
935
|
+
*/
|
|
889
936
|
peek() {
|
|
890
937
|
return this[LATEST_VALUE];
|
|
891
938
|
},
|
|
939
|
+
/**
|
|
940
|
+
* Notifies subscribers that the value has changed.
|
|
941
|
+
*/
|
|
892
942
|
valueHasMutated() {
|
|
893
943
|
this.notifySubscribers(this[LATEST_VALUE], "spectate");
|
|
894
944
|
this.notifySubscribers(this[LATEST_VALUE]);
|
|
895
945
|
},
|
|
946
|
+
/**
|
|
947
|
+
* Notifies subscribers that the value is about to change.
|
|
948
|
+
*/
|
|
896
949
|
valueWillMutate() {
|
|
897
950
|
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
|
|
898
951
|
},
|
|
952
|
+
/**
|
|
953
|
+
* Modifies the value of the observable using a function.
|
|
954
|
+
* @param fn The function to modify the value.
|
|
955
|
+
* @param peek Whether to use the current value without creating a dependency.
|
|
956
|
+
* @returns The modified observable.
|
|
957
|
+
*/
|
|
899
958
|
modify(fn, peek22 = true) {
|
|
900
|
-
|
|
959
|
+
this(fn(peek22 ? this.peek() : this()));
|
|
901
960
|
},
|
|
961
|
+
// Some observables may not always be writeable, notably computeds.
|
|
902
962
|
isWriteable: true
|
|
903
963
|
};
|
|
904
964
|
function limitNotifySubscribers(value, event) {
|
|
@@ -911,15 +971,15 @@ function limitNotifySubscribers(value, event) {
|
|
|
911
971
|
}
|
|
912
972
|
}
|
|
913
973
|
subscribable.fn.limit = function limit(limitFunction) {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
974
|
+
const self = this;
|
|
975
|
+
const selfIsObservable = isObservable(self);
|
|
976
|
+
const beforeChange = "beforeChange";
|
|
977
|
+
let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
|
|
918
978
|
if (!self._origNotifySubscribers) {
|
|
919
979
|
self._origNotifySubscribers = self.notifySubscribers;
|
|
920
980
|
self.notifySubscribers = limitNotifySubscribers;
|
|
921
981
|
}
|
|
922
|
-
|
|
982
|
+
const finish = limitFunction(function() {
|
|
923
983
|
self._notificationIsPending = false;
|
|
924
984
|
if (selfIsObservable && pendingValue === self) {
|
|
925
985
|
pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
|
|
@@ -947,7 +1007,10 @@ subscribable.fn.limit = function limit(limitFunction) {
|
|
|
947
1007
|
}
|
|
948
1008
|
},
|
|
949
1009
|
_notifyNextChangeIfValueIsDifferent() {
|
|
950
|
-
if (self.isDifferent(previousValue, self.peek(
|
|
1010
|
+
if (self.isDifferent(previousValue, self.peek(
|
|
1011
|
+
true
|
|
1012
|
+
/* evaluate */
|
|
1013
|
+
))) {
|
|
951
1014
|
notifyNextChange = true;
|
|
952
1015
|
}
|
|
953
1016
|
},
|
|
@@ -987,8 +1050,8 @@ function trackArrayChanges(target, options2) {
|
|
|
987
1050
|
let arrayChangeSubscription;
|
|
988
1051
|
let pendingNotifications = 0;
|
|
989
1052
|
let underlyingNotifySubscribersFunction;
|
|
990
|
-
|
|
991
|
-
|
|
1053
|
+
const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
|
|
1054
|
+
const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
|
|
992
1055
|
target.beforeSubscriptionAdd = function(event) {
|
|
993
1056
|
if (underlyingBeforeSubscriptionAddFunction) {
|
|
994
1057
|
underlyingBeforeSubscriptionAddFunction.call(target, event);
|
|
@@ -1025,11 +1088,11 @@ function trackArrayChanges(target, options2) {
|
|
|
1025
1088
|
}
|
|
1026
1089
|
return underlyingNotifySubscribersFunction.apply(this, arguments);
|
|
1027
1090
|
};
|
|
1028
|
-
|
|
1091
|
+
let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
|
|
1029
1092
|
cachedDiff = null;
|
|
1030
1093
|
arrayChangeSubscription = target.subscribe(function(currentContents) {
|
|
1031
1094
|
let changes;
|
|
1032
|
-
currentContents =
|
|
1095
|
+
currentContents = new Array().concat(currentContents || []);
|
|
1033
1096
|
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1034
1097
|
changes = getChanges(previousContents, currentContents);
|
|
1035
1098
|
}
|
|
@@ -1051,9 +1114,9 @@ function trackArrayChanges(target, options2) {
|
|
|
1051
1114
|
if (!trackingChanges || pendingNotifications) {
|
|
1052
1115
|
return;
|
|
1053
1116
|
}
|
|
1054
|
-
|
|
1117
|
+
let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
|
|
1055
1118
|
function pushDiff(status, value, index) {
|
|
1056
|
-
return diff[diff.length] = {
|
|
1119
|
+
return diff[diff.length] = { status, value, index };
|
|
1057
1120
|
}
|
|
1058
1121
|
switch (operationName) {
|
|
1059
1122
|
case "push":
|
|
@@ -1071,16 +1134,18 @@ function trackArrayChanges(target, options2) {
|
|
|
1071
1134
|
}
|
|
1072
1135
|
break;
|
|
1073
1136
|
case "splice":
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1137
|
+
{
|
|
1138
|
+
const startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength), endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength), endAddIndex = startIndex + argsLength - 2, endIndex = Math.max(endDeleteIndex, endAddIndex), additions = new Array(), deletions = new Array();
|
|
1139
|
+
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
|
|
1140
|
+
if (index < endDeleteIndex) {
|
|
1141
|
+
deletions.push(pushDiff("deleted", rawArray[index], index));
|
|
1142
|
+
}
|
|
1143
|
+
if (index < endAddIndex) {
|
|
1144
|
+
additions.push(pushDiff("added", args[argsIndex], index));
|
|
1145
|
+
}
|
|
1081
1146
|
}
|
|
1147
|
+
findMovesInArrayComparison(deletions, additions);
|
|
1082
1148
|
}
|
|
1083
|
-
findMovesInArrayComparison(deletions, additions);
|
|
1084
1149
|
break;
|
|
1085
1150
|
default:
|
|
1086
1151
|
return;
|
|
@@ -1095,23 +1160,27 @@ extenders.trackArrayChanges = trackArrayChanges;
|
|
|
1095
1160
|
function observableArray(initialValues) {
|
|
1096
1161
|
initialValues = initialValues || [];
|
|
1097
1162
|
if (typeof initialValues !== "object" || !("length" in initialValues)) {
|
|
1098
|
-
throw new Error(
|
|
1163
|
+
throw new Error(
|
|
1164
|
+
"The argument passed when initializing an observable array must be an array, or null, or undefined."
|
|
1165
|
+
);
|
|
1099
1166
|
}
|
|
1100
|
-
|
|
1101
|
-
Object.setPrototypeOf(result, observableArray.fn);
|
|
1167
|
+
const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
|
|
1102
1168
|
trackArrayChanges(result);
|
|
1103
|
-
overwriteLengthPropertyIfSupported(result, { get: () =>
|
|
1169
|
+
overwriteLengthPropertyIfSupported(result, { get: () => {
|
|
1170
|
+
var _a;
|
|
1171
|
+
return (_a = result()) == null ? void 0 : _a.length;
|
|
1172
|
+
} });
|
|
1104
1173
|
return result;
|
|
1105
1174
|
}
|
|
1106
1175
|
observableArray.fn = {
|
|
1107
1176
|
remove(valueOrPredicate) {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
return
|
|
1177
|
+
const underlyingArray = this.peek();
|
|
1178
|
+
const removedValues = new Array();
|
|
1179
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
|
|
1180
|
+
return value === valueOrPredicate;
|
|
1112
1181
|
};
|
|
1113
|
-
for (
|
|
1114
|
-
|
|
1182
|
+
for (let i = 0; i < underlyingArray.length; i++) {
|
|
1183
|
+
const value = underlyingArray[i];
|
|
1115
1184
|
if (predicate(value)) {
|
|
1116
1185
|
if (removedValues.length === 0) {
|
|
1117
1186
|
this.valueWillMutate();
|
|
@@ -1131,8 +1200,8 @@ observableArray.fn = {
|
|
|
1131
1200
|
},
|
|
1132
1201
|
removeAll(arrayOfValues) {
|
|
1133
1202
|
if (arrayOfValues === void 0) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1203
|
+
const underlyingArray = this.peek();
|
|
1204
|
+
const allValues = underlyingArray.slice(0);
|
|
1136
1205
|
this.valueWillMutate();
|
|
1137
1206
|
underlyingArray.splice(0, underlyingArray.length);
|
|
1138
1207
|
this.valueHasMutated();
|
|
@@ -1146,13 +1215,13 @@ observableArray.fn = {
|
|
|
1146
1215
|
});
|
|
1147
1216
|
},
|
|
1148
1217
|
destroy(valueOrPredicate) {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
return
|
|
1218
|
+
const underlyingArray = this.peek();
|
|
1219
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
|
|
1220
|
+
return value === valueOrPredicate;
|
|
1152
1221
|
};
|
|
1153
1222
|
this.valueWillMutate();
|
|
1154
|
-
for (
|
|
1155
|
-
|
|
1223
|
+
for (let i = underlyingArray.length - 1; i >= 0; i--) {
|
|
1224
|
+
const value = underlyingArray[i];
|
|
1156
1225
|
if (predicate(value)) {
|
|
1157
1226
|
value["_destroy"] = true;
|
|
1158
1227
|
}
|
|
@@ -1176,7 +1245,7 @@ observableArray.fn = {
|
|
|
1176
1245
|
return arrayIndexOf(this(), item);
|
|
1177
1246
|
},
|
|
1178
1247
|
replace(oldItem, newItem) {
|
|
1179
|
-
|
|
1248
|
+
const index = this.indexOf(oldItem);
|
|
1180
1249
|
if (index >= 0) {
|
|
1181
1250
|
this.valueWillMutate();
|
|
1182
1251
|
this.peek()[index] = newItem;
|
|
@@ -1190,23 +1259,23 @@ observableArray.fn = {
|
|
|
1190
1259
|
return [...this()].reverse();
|
|
1191
1260
|
},
|
|
1192
1261
|
[Symbol.iterator]: function* () {
|
|
1193
|
-
yield* this();
|
|
1262
|
+
yield* __yieldStar(this());
|
|
1194
1263
|
}
|
|
1195
1264
|
};
|
|
1196
1265
|
Object.setPrototypeOf(observableArray.fn, observable.fn);
|
|
1197
1266
|
arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
1198
1267
|
observableArray.fn[methodName] = function() {
|
|
1199
|
-
|
|
1268
|
+
const underlyingArray = this.peek();
|
|
1200
1269
|
this.valueWillMutate();
|
|
1201
1270
|
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
|
|
1202
|
-
|
|
1271
|
+
const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1203
1272
|
this.valueHasMutated();
|
|
1204
1273
|
return methodCallResult === underlyingArray ? this : methodCallResult;
|
|
1205
1274
|
};
|
|
1206
1275
|
});
|
|
1207
1276
|
arrayForEach(["slice"], function(methodName) {
|
|
1208
1277
|
observableArray.fn[methodName] = function() {
|
|
1209
|
-
|
|
1278
|
+
const underlyingArray = this();
|
|
1210
1279
|
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1211
1280
|
};
|
|
1212
1281
|
});
|
|
@@ -1234,11 +1303,11 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1234
1303
|
options2.read = evaluatorFunctionOrOptions;
|
|
1235
1304
|
}
|
|
1236
1305
|
}
|
|
1237
|
-
if (typeof options2.read !== "function") {
|
|
1306
|
+
if (typeof (options2 == null ? void 0 : options2.read) !== "function") {
|
|
1238
1307
|
throw Error("Pass a function that returns the value of the computed");
|
|
1239
1308
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1309
|
+
const writeFunction = options2.write;
|
|
1310
|
+
const state = {
|
|
1242
1311
|
latestValue: void 0,
|
|
1243
1312
|
isStale: true,
|
|
1244
1313
|
isDirty: true,
|
|
@@ -1249,8 +1318,8 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1249
1318
|
isSleeping: false,
|
|
1250
1319
|
readFunction: options2.read,
|
|
1251
1320
|
evaluatorFunctionTarget: evaluatorFunctionTarget || options2.owner,
|
|
1252
|
-
disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved ||
|
|
1253
|
-
disposeWhen: options2.disposeWhen
|
|
1321
|
+
disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || null,
|
|
1322
|
+
disposeWhen: options2.disposeWhen,
|
|
1254
1323
|
domNodeDisposalCallback: null,
|
|
1255
1324
|
dependencyTracking: {},
|
|
1256
1325
|
dependenciesCount: 0,
|
|
@@ -1261,7 +1330,9 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1261
1330
|
if (typeof writeFunction === "function") {
|
|
1262
1331
|
writeFunction.apply(state.evaluatorFunctionTarget, arguments);
|
|
1263
1332
|
} else {
|
|
1264
|
-
throw new Error(
|
|
1333
|
+
throw new Error(
|
|
1334
|
+
"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."
|
|
1335
|
+
);
|
|
1265
1336
|
}
|
|
1266
1337
|
return this;
|
|
1267
1338
|
} else {
|
|
@@ -1269,6 +1340,7 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1269
1340
|
dependencyDetection_exports.registerDependency(computedObservable);
|
|
1270
1341
|
}
|
|
1271
1342
|
if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
|
|
1343
|
+
;
|
|
1272
1344
|
computedObservable.evaluateImmediate();
|
|
1273
1345
|
}
|
|
1274
1346
|
return state.latestValue;
|
|
@@ -1298,12 +1370,17 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1298
1370
|
}
|
|
1299
1371
|
}
|
|
1300
1372
|
if (!state.isSleeping && !options2.deferEvaluation) {
|
|
1373
|
+
;
|
|
1301
1374
|
computedObservable.evaluateImmediate();
|
|
1302
1375
|
}
|
|
1303
1376
|
if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
|
|
1304
|
-
addDisposeCallback(
|
|
1305
|
-
|
|
1306
|
-
|
|
1377
|
+
addDisposeCallback(
|
|
1378
|
+
state.disposeWhenNodeIsRemoved,
|
|
1379
|
+
state.domNodeDisposalCallback = function() {
|
|
1380
|
+
;
|
|
1381
|
+
computedObservable.dispose();
|
|
1382
|
+
}
|
|
1383
|
+
);
|
|
1307
1384
|
}
|
|
1308
1385
|
return computedObservable;
|
|
1309
1386
|
}
|
|
@@ -1313,14 +1390,18 @@ function computedDisposeDependencyCallback(id, entryToDispose) {
|
|
|
1313
1390
|
}
|
|
1314
1391
|
}
|
|
1315
1392
|
function computedBeginDependencyDetectionCallback(subscribable2, id) {
|
|
1316
|
-
|
|
1393
|
+
const computedObservable = this.computedObservable, state = computedObservable[computedState];
|
|
1317
1394
|
if (!state.isDisposed) {
|
|
1318
1395
|
if (this.disposalCount && this.disposalCandidates[id]) {
|
|
1319
1396
|
computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
|
|
1320
1397
|
this.disposalCandidates[id] = null;
|
|
1321
1398
|
--this.disposalCount;
|
|
1322
1399
|
} else if (!state.dependencyTracking[id]) {
|
|
1323
|
-
computedObservable.addDependencyTracking(
|
|
1400
|
+
computedObservable.addDependencyTracking(
|
|
1401
|
+
id,
|
|
1402
|
+
subscribable2,
|
|
1403
|
+
state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
|
|
1404
|
+
);
|
|
1324
1405
|
}
|
|
1325
1406
|
if (subscribable2._notificationIsPending) {
|
|
1326
1407
|
subscribable2._notifyNextChangeIfValueIsDifferent();
|
|
@@ -1334,7 +1415,7 @@ computed.fn = {
|
|
|
1334
1415
|
},
|
|
1335
1416
|
getDependencies() {
|
|
1336
1417
|
const dependencyTracking = this[computedState].dependencyTracking;
|
|
1337
|
-
const dependentObservables =
|
|
1418
|
+
const dependentObservables = new Array();
|
|
1338
1419
|
objectForEach(dependencyTracking, function(id, dependency) {
|
|
1339
1420
|
dependentObservables[dependency._order] = dependency._target;
|
|
1340
1421
|
});
|
|
@@ -1349,7 +1430,7 @@ computed.fn = {
|
|
|
1349
1430
|
trackingObj._version = target.getVersion();
|
|
1350
1431
|
},
|
|
1351
1432
|
haveDependenciesChanged() {
|
|
1352
|
-
|
|
1433
|
+
let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
|
|
1353
1434
|
for (id in dependencyTracking) {
|
|
1354
1435
|
if (hasOwnProperty(dependencyTracking, id)) {
|
|
1355
1436
|
dependency = dependencyTracking[id];
|
|
@@ -1358,10 +1439,14 @@ computed.fn = {
|
|
|
1358
1439
|
}
|
|
1359
1440
|
}
|
|
1360
1441
|
}
|
|
1442
|
+
return false;
|
|
1361
1443
|
},
|
|
1362
1444
|
markDirty() {
|
|
1363
1445
|
if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
|
|
1364
|
-
this._evalDelayed(
|
|
1446
|
+
this._evalDelayed(
|
|
1447
|
+
false
|
|
1448
|
+
/* notifyChange */
|
|
1449
|
+
);
|
|
1365
1450
|
}
|
|
1366
1451
|
},
|
|
1367
1452
|
isActive() {
|
|
@@ -1377,7 +1462,7 @@ computed.fn = {
|
|
|
1377
1462
|
},
|
|
1378
1463
|
subscribeToDependency(target) {
|
|
1379
1464
|
if (target._deferUpdates) {
|
|
1380
|
-
|
|
1465
|
+
const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
|
|
1381
1466
|
return {
|
|
1382
1467
|
_target: target,
|
|
1383
1468
|
dispose() {
|
|
@@ -1390,20 +1475,29 @@ computed.fn = {
|
|
|
1390
1475
|
}
|
|
1391
1476
|
},
|
|
1392
1477
|
evaluatePossiblyAsync() {
|
|
1393
|
-
|
|
1478
|
+
const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
|
|
1394
1479
|
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
|
1395
1480
|
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
|
1396
1481
|
this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
|
|
1397
|
-
computedObservable.evaluateImmediate(
|
|
1482
|
+
computedObservable.evaluateImmediate(
|
|
1483
|
+
true
|
|
1484
|
+
/* notifyChange */
|
|
1485
|
+
);
|
|
1398
1486
|
}, throttleEvaluationTimeout);
|
|
1399
1487
|
} else if (computedObservable._evalDelayed) {
|
|
1400
|
-
computedObservable._evalDelayed(
|
|
1488
|
+
computedObservable._evalDelayed(
|
|
1489
|
+
true
|
|
1490
|
+
/* notifyChange */
|
|
1491
|
+
);
|
|
1401
1492
|
} else {
|
|
1402
|
-
computedObservable.evaluateImmediate(
|
|
1493
|
+
computedObservable.evaluateImmediate(
|
|
1494
|
+
true
|
|
1495
|
+
/* notifyChange */
|
|
1496
|
+
);
|
|
1403
1497
|
}
|
|
1404
1498
|
},
|
|
1405
1499
|
evaluateImmediate(notifyChange) {
|
|
1406
|
-
|
|
1500
|
+
let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
|
|
1407
1501
|
if (state.isBeingEvaluated) {
|
|
1408
1502
|
return;
|
|
1409
1503
|
}
|
|
@@ -1427,8 +1521,8 @@ computed.fn = {
|
|
|
1427
1521
|
return changed;
|
|
1428
1522
|
},
|
|
1429
1523
|
evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
|
|
1430
|
-
|
|
1431
|
-
|
|
1524
|
+
let computedObservable = this, state = computedObservable[computedState], changed = false;
|
|
1525
|
+
const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
|
|
1432
1526
|
computedObservable,
|
|
1433
1527
|
disposalCandidates: state.dependencyTracking,
|
|
1434
1528
|
disposalCount: state.dependenciesCount
|
|
@@ -1441,7 +1535,7 @@ computed.fn = {
|
|
|
1441
1535
|
});
|
|
1442
1536
|
state.dependencyTracking = {};
|
|
1443
1537
|
state.dependenciesCount = 0;
|
|
1444
|
-
|
|
1538
|
+
const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
|
|
1445
1539
|
if (!state.dependenciesCount) {
|
|
1446
1540
|
computedObservable.dispose();
|
|
1447
1541
|
changed = true;
|
|
@@ -1473,7 +1567,7 @@ computed.fn = {
|
|
|
1473
1567
|
},
|
|
1474
1568
|
evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
|
|
1475
1569
|
try {
|
|
1476
|
-
|
|
1570
|
+
const readFunction = state.readFunction;
|
|
1477
1571
|
return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
|
|
1478
1572
|
} finally {
|
|
1479
1573
|
dependencyDetection_exports.end();
|
|
@@ -1513,12 +1607,16 @@ computed.fn = {
|
|
|
1513
1607
|
if (isChange) {
|
|
1514
1608
|
state.isStale = true;
|
|
1515
1609
|
}
|
|
1516
|
-
this._limitChange(
|
|
1610
|
+
this._limitChange(
|
|
1611
|
+
this,
|
|
1612
|
+
!isChange
|
|
1613
|
+
/* isDirty */
|
|
1614
|
+
);
|
|
1517
1615
|
}
|
|
1518
1616
|
});
|
|
1519
1617
|
},
|
|
1520
1618
|
dispose() {
|
|
1521
|
-
|
|
1619
|
+
const state = this[computedState];
|
|
1522
1620
|
if (!state.isSleeping && state.dependencyTracking) {
|
|
1523
1621
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
1524
1622
|
if (dependency.dispose) {
|
|
@@ -1534,7 +1632,7 @@ computed.fn = {
|
|
|
1534
1632
|
};
|
|
1535
1633
|
var pureComputedOverrides = {
|
|
1536
1634
|
beforeSubscriptionAdd(event) {
|
|
1537
|
-
|
|
1635
|
+
const computedObservable = this, state = computedObservable[computedState];
|
|
1538
1636
|
if (!state.isDisposed && state.isSleeping && event === "change") {
|
|
1539
1637
|
state.isSleeping = false;
|
|
1540
1638
|
if (state.isStale || computedObservable.haveDependenciesChanged()) {
|
|
@@ -1544,12 +1642,12 @@ var pureComputedOverrides = {
|
|
|
1544
1642
|
computedObservable.updateVersion();
|
|
1545
1643
|
}
|
|
1546
1644
|
} else {
|
|
1547
|
-
|
|
1645
|
+
const dependenciesOrder = new Array();
|
|
1548
1646
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
1549
1647
|
dependenciesOrder[dependency._order] = id;
|
|
1550
1648
|
});
|
|
1551
1649
|
arrayForEach(dependenciesOrder, function(id, order) {
|
|
1552
|
-
|
|
1650
|
+
const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
|
|
1553
1651
|
subscription._order = order;
|
|
1554
1652
|
subscription._version = dependency._version;
|
|
1555
1653
|
state.dependencyTracking[id] = subscription;
|
|
@@ -1566,7 +1664,7 @@ var pureComputedOverrides = {
|
|
|
1566
1664
|
}
|
|
1567
1665
|
},
|
|
1568
1666
|
afterSubscriptionRemove(event) {
|
|
1569
|
-
|
|
1667
|
+
const state = this[computedState];
|
|
1570
1668
|
if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
|
|
1571
1669
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
1572
1670
|
if (dependency.dispose) {
|
|
@@ -1583,7 +1681,7 @@ var pureComputedOverrides = {
|
|
|
1583
1681
|
}
|
|
1584
1682
|
},
|
|
1585
1683
|
getVersion() {
|
|
1586
|
-
|
|
1684
|
+
const state = this[computedState];
|
|
1587
1685
|
if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
|
|
1588
1686
|
this.evaluateImmediate();
|
|
1589
1687
|
}
|
|
@@ -1605,7 +1703,7 @@ observable.observablePrototypes.add(computed);
|
|
|
1605
1703
|
// ../computed/dist/throttleExtender.js
|
|
1606
1704
|
function throttleExtender(target, timeout) {
|
|
1607
1705
|
target.throttleEvaluation = timeout;
|
|
1608
|
-
|
|
1706
|
+
let writeTimeoutInstance = void 0;
|
|
1609
1707
|
return computed({
|
|
1610
1708
|
read: target,
|
|
1611
1709
|
write: function(value) {
|
|
@@ -1616,11 +1714,12 @@ function throttleExtender(target, timeout) {
|
|
|
1616
1714
|
}
|
|
1617
1715
|
});
|
|
1618
1716
|
}
|
|
1619
|
-
|
|
1717
|
+
var extenders2 = extenders;
|
|
1718
|
+
extenders2.throttle = throttleExtender;
|
|
1620
1719
|
|
|
1621
1720
|
// ../computed/dist/proxy.js
|
|
1622
|
-
var PROXY_SYM = Symbol("Knockout Proxied Object");
|
|
1623
|
-
var MIRROR_SYM = Symbol("Knockout Proxied Observables");
|
|
1721
|
+
var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
|
|
1722
|
+
var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
|
|
1624
1723
|
function makeComputed(proxy2, fn) {
|
|
1625
1724
|
return computed({
|
|
1626
1725
|
owner: proxy2,
|
|
@@ -1687,10 +1786,7 @@ function proxy(object) {
|
|
|
1687
1786
|
return Object.isExtensible(object);
|
|
1688
1787
|
},
|
|
1689
1788
|
ownKeys() {
|
|
1690
|
-
return [
|
|
1691
|
-
...Object.getOwnPropertyNames(object),
|
|
1692
|
-
...Object.getOwnPropertySymbols(object)
|
|
1693
|
-
];
|
|
1789
|
+
return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
|
|
1694
1790
|
}
|
|
1695
1791
|
});
|
|
1696
1792
|
assignOrUpdate(mirror, object, proxy2);
|
|
@@ -1710,11 +1806,18 @@ Object.assign(proxy, { getObservable, peek: peek2, isProxied });
|
|
|
1710
1806
|
// src/LifeCycle.ts
|
|
1711
1807
|
var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
|
|
1712
1808
|
var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
|
|
1713
|
-
var LifeCycle = class {
|
|
1809
|
+
var LifeCycle = class _LifeCycle {
|
|
1810
|
+
// NOTE: For more advanced integration as an ES6 mixin, see e.g.:
|
|
1811
|
+
// http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
|
|
1812
|
+
/**
|
|
1813
|
+
* Copy the properties of the LifeCycle class to the target (or its prototype)
|
|
1814
|
+
*
|
|
1815
|
+
* NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
|
|
1816
|
+
*/
|
|
1714
1817
|
static mixInto(Constructor) {
|
|
1715
1818
|
const target = Constructor.prototype || Constructor;
|
|
1716
|
-
const mixin =
|
|
1717
|
-
for (
|
|
1819
|
+
const mixin = _LifeCycle.prototype;
|
|
1820
|
+
for (const prop of Object.getOwnPropertyNames(mixin)) {
|
|
1718
1821
|
target[prop] = mixin[prop];
|
|
1719
1822
|
}
|
|
1720
1823
|
}
|
|
@@ -1742,6 +1845,13 @@ var LifeCycle = class {
|
|
|
1742
1845
|
params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
|
|
1743
1846
|
return this.addDisposable(computed(params));
|
|
1744
1847
|
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Add an event listener for the given or anchored node.
|
|
1850
|
+
* @param {node} [node] (optional) The target node (otherwise the anchored node)
|
|
1851
|
+
* @param {string} [type] Event type
|
|
1852
|
+
* @param {function|string} [action] Either call the given function or `this[action]`
|
|
1853
|
+
* @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
|
|
1854
|
+
*/
|
|
1745
1855
|
addEventListener(...args) {
|
|
1746
1856
|
const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
|
|
1747
1857
|
const [type, act, options2] = args;
|
|
@@ -1768,7 +1878,7 @@ var LifeCycle = class {
|
|
|
1768
1878
|
dispose() {
|
|
1769
1879
|
const subscriptions = this[SUBSCRIPTIONS] || [];
|
|
1770
1880
|
subscriptions.forEach((s) => s.dispose());
|
|
1771
|
-
this[SUBSCRIPTIONS] =
|
|
1881
|
+
this[SUBSCRIPTIONS] = new Array();
|
|
1772
1882
|
this[ANCHOR_NODE] = null;
|
|
1773
1883
|
}
|
|
1774
1884
|
addDisposable(subscription) {
|