@tko/computed 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/computed.js +71 -39
- package/dist/computed.js.map +3 -3
- package/dist/index.cjs +413 -315
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +6 -16
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +6 -16
- package/dist/index.mjs.map +2 -2
- package/dist/proxy.js +7 -15
- package/dist/proxy.js.map +3 -3
- package/dist/throttleExtender.js +6 -8
- package/dist/throttleExtender.js.map +2 -2
- package/dist/when.js +3 -4
- package/dist/when.js.map +2 -2
- package/package.json +4 -5
- package/LICENSE +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
// @tko/computed 🥊 4.0.0
|
|
1
|
+
// @tko/computed 🥊 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,10 +21,42 @@ 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
|
computed: () => computed,
|
|
24
61
|
isComputed: () => isComputed,
|
|
25
62
|
isPureComputed: () => isPureComputed,
|
|
@@ -28,13 +65,13 @@ __export(computed_exports, {
|
|
|
28
65
|
throttleExtender: () => throttleExtender,
|
|
29
66
|
when: () => when
|
|
30
67
|
});
|
|
31
|
-
module.exports = __toCommonJS(
|
|
68
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
69
|
|
|
33
70
|
// ../utils/dist/array.js
|
|
34
71
|
var { isArray } = Array;
|
|
35
|
-
function arrayForEach(array, action,
|
|
72
|
+
function arrayForEach(array, action, actionOwner) {
|
|
36
73
|
if (arguments.length > 2) {
|
|
37
|
-
action = action.bind(
|
|
74
|
+
action = action.bind(actionOwner);
|
|
38
75
|
}
|
|
39
76
|
for (let i = 0, j = array.length; i < j; ++i) {
|
|
40
77
|
action(array[i], i, array);
|
|
@@ -44,7 +81,7 @@ function arrayIndexOf(array, item) {
|
|
|
44
81
|
return (isArray(array) ? array : [...array]).indexOf(item);
|
|
45
82
|
}
|
|
46
83
|
function arrayRemoveItem(array, itemToRemove) {
|
|
47
|
-
|
|
84
|
+
const index = arrayIndexOf(array, itemToRemove);
|
|
48
85
|
if (index > 0) {
|
|
49
86
|
array.splice(index, 1);
|
|
50
87
|
} else if (index === 0) {
|
|
@@ -53,7 +90,7 @@ function arrayRemoveItem(array, itemToRemove) {
|
|
|
53
90
|
}
|
|
54
91
|
function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
55
92
|
if (left.length && right.length) {
|
|
56
|
-
|
|
93
|
+
let failedCompares, l, r, leftItem, rightItem;
|
|
57
94
|
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
58
95
|
for (r = 0; rightItem = right[r]; ++r) {
|
|
59
96
|
if (leftItem.value === rightItem.value) {
|
|
@@ -81,10 +118,10 @@ function compareArrays(oldArray, newArray, options2) {
|
|
|
81
118
|
}
|
|
82
119
|
}
|
|
83
120
|
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
|
|
84
|
-
|
|
121
|
+
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;
|
|
85
122
|
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
86
123
|
lastRow = thisRow;
|
|
87
|
-
editDistanceMatrix.push(thisRow =
|
|
124
|
+
editDistanceMatrix.push(thisRow = new Array());
|
|
88
125
|
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
89
126
|
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
90
127
|
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
@@ -95,35 +132,38 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
95
132
|
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
96
133
|
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
97
134
|
} else {
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
const northDistance = lastRow[bigIndex] || maxDistance;
|
|
136
|
+
const westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
100
137
|
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
101
138
|
}
|
|
102
139
|
}
|
|
103
140
|
}
|
|
104
|
-
|
|
141
|
+
let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
|
|
105
142
|
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
106
143
|
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
107
144
|
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
108
|
-
notInSml.push(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
145
|
+
notInSml.push(
|
|
146
|
+
editScript[editScript.length] = {
|
|
147
|
+
// added
|
|
148
|
+
status: statusNotInSml,
|
|
149
|
+
value: bigArray[--bigIndex],
|
|
150
|
+
index: bigIndex
|
|
151
|
+
}
|
|
152
|
+
);
|
|
113
153
|
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
114
|
-
notInBig.push(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
154
|
+
notInBig.push(
|
|
155
|
+
editScript[editScript.length] = {
|
|
156
|
+
// deleted
|
|
157
|
+
status: statusNotInBig,
|
|
158
|
+
value: smlArray[--smlIndex],
|
|
159
|
+
index: smlIndex
|
|
160
|
+
}
|
|
161
|
+
);
|
|
119
162
|
} else {
|
|
120
163
|
--bigIndex;
|
|
121
164
|
--smlIndex;
|
|
122
|
-
if (!options2.sparse) {
|
|
123
|
-
editScript.push({
|
|
124
|
-
"status": "retained",
|
|
125
|
-
"value": bigArray[bigIndex]
|
|
126
|
-
});
|
|
165
|
+
if (!(options2 == null ? void 0 : options2.sparse)) {
|
|
166
|
+
editScript.push({ status: "retained", value: bigArray[bigIndex] });
|
|
127
167
|
}
|
|
128
168
|
}
|
|
129
169
|
}
|
|
@@ -132,40 +172,79 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
132
172
|
}
|
|
133
173
|
|
|
134
174
|
// ../utils/dist/options.js
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
175
|
+
var Options = class {
|
|
176
|
+
constructor() {
|
|
177
|
+
this.bindingStringPreparsers = [];
|
|
178
|
+
this.knockoutInstance = null;
|
|
179
|
+
this.deferUpdates = false;
|
|
180
|
+
this.useOnlyNativeEvents = true;
|
|
181
|
+
this.useTemplateTag = true;
|
|
182
|
+
this.protoProperty = "__ko_proto__";
|
|
183
|
+
this.defaultBindingAttribute = "data-bind";
|
|
184
|
+
this.allowVirtualElements = true;
|
|
185
|
+
this.bindingGlobals = /* @__PURE__ */ Object.create(null);
|
|
186
|
+
this.createChildContextWithAs = false;
|
|
187
|
+
this.disableJQueryUsage = false;
|
|
188
|
+
this.Promise = globalThis.Promise;
|
|
189
|
+
this.taskScheduler = null;
|
|
190
|
+
this.debug = false;
|
|
191
|
+
this.templateSizeLimit = 4096;
|
|
192
|
+
this.allowScriptTagsInTemplates = false;
|
|
193
|
+
this._sanitizeWarningLogged = false;
|
|
194
|
+
this.global = globalThis;
|
|
195
|
+
this.document = globalThis.document;
|
|
196
|
+
this.filters = {};
|
|
197
|
+
this.includeDestroyed = false;
|
|
198
|
+
this.foreachHidesDestroyed = false;
|
|
199
|
+
}
|
|
200
|
+
get jQuery() {
|
|
201
|
+
var _a;
|
|
202
|
+
if (this.disableJQueryUsage) return;
|
|
203
|
+
return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Set jQuery manuall to be used by TKO.
|
|
207
|
+
* @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
|
|
208
|
+
*/
|
|
209
|
+
set jQuery(jQuery) {
|
|
210
|
+
if (!jQuery) {
|
|
211
|
+
this.disableJQueryUsage = true;
|
|
212
|
+
this._jQuery = void 0;
|
|
213
|
+
} else {
|
|
214
|
+
this._jQuery = jQuery;
|
|
215
|
+
this.disableJQueryUsage = false;
|
|
216
|
+
}
|
|
162
217
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
218
|
+
/**
|
|
219
|
+
* Sanitize HTML templates before parsing them. Default is a no-op.
|
|
220
|
+
* Please configure something like DOMPurify or validator.js for your environment.
|
|
221
|
+
* @param html HTML string to be sanitized
|
|
222
|
+
* @returns Sanitized HTML string
|
|
223
|
+
*/
|
|
224
|
+
sanitizeHtmlTemplate(html) {
|
|
225
|
+
if (!this._sanitizeWarningLogged) {
|
|
226
|
+
console.warn(
|
|
227
|
+
"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
|
|
228
|
+
);
|
|
229
|
+
this._sanitizeWarningLogged = true;
|
|
230
|
+
}
|
|
231
|
+
return html;
|
|
167
232
|
}
|
|
168
|
-
|
|
233
|
+
onError(e, throws = true) {
|
|
234
|
+
if (throws) throw e;
|
|
235
|
+
return e;
|
|
236
|
+
}
|
|
237
|
+
set(name, value) {
|
|
238
|
+
this[name] = value;
|
|
239
|
+
}
|
|
240
|
+
// Overload getBindingHandler to have a custom lookup function.
|
|
241
|
+
getBindingHandler(key) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
cleanExternalData(node, callback) {
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var options = new Options();
|
|
169
248
|
var options_default = options;
|
|
170
249
|
|
|
171
250
|
// ../utils/dist/error.js
|
|
@@ -192,7 +271,7 @@ function safeSetTimeout(handler, timeout) {
|
|
|
192
271
|
|
|
193
272
|
// ../utils/dist/async.js
|
|
194
273
|
function throttle(callback, timeout) {
|
|
195
|
-
|
|
274
|
+
let timeoutInstance;
|
|
196
275
|
return function(...args) {
|
|
197
276
|
if (!timeoutInstance) {
|
|
198
277
|
timeoutInstance = safeSetTimeout(function() {
|
|
@@ -203,33 +282,22 @@ function throttle(callback, timeout) {
|
|
|
203
282
|
};
|
|
204
283
|
}
|
|
205
284
|
function debounce(callback, timeout) {
|
|
206
|
-
|
|
285
|
+
let timeoutInstance;
|
|
207
286
|
return function(...args) {
|
|
208
287
|
clearTimeout(timeoutInstance);
|
|
209
288
|
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
210
289
|
};
|
|
211
290
|
}
|
|
212
291
|
|
|
213
|
-
// ../utils/dist/ie.js
|
|
214
|
-
var ieVersion = options_default.document && function() {
|
|
215
|
-
var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
|
|
216
|
-
while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
|
|
217
|
-
}
|
|
218
|
-
if (!version) {
|
|
219
|
-
const userAgent = window.navigator.userAgent;
|
|
220
|
-
return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
|
|
221
|
-
}
|
|
222
|
-
return version > 4 ? version : void 0;
|
|
223
|
-
}();
|
|
224
|
-
|
|
225
292
|
// ../utils/dist/object.js
|
|
226
293
|
function hasOwnProperty(obj, propName) {
|
|
227
294
|
return Object.prototype.hasOwnProperty.call(obj, propName);
|
|
228
295
|
}
|
|
229
296
|
function extend(target, source) {
|
|
230
297
|
if (source) {
|
|
231
|
-
for (
|
|
298
|
+
for (const prop of Object.keys(source)) {
|
|
232
299
|
if (hasOwnProperty(source, prop)) {
|
|
300
|
+
;
|
|
233
301
|
target[prop] = source[prop];
|
|
234
302
|
}
|
|
235
303
|
}
|
|
@@ -237,7 +305,7 @@ function extend(target, source) {
|
|
|
237
305
|
return target;
|
|
238
306
|
}
|
|
239
307
|
function objectForEach(obj, action) {
|
|
240
|
-
for (
|
|
308
|
+
for (const prop in obj) {
|
|
241
309
|
if (hasOwnProperty(obj, prop)) {
|
|
242
310
|
action(prop, obj[prop]);
|
|
243
311
|
}
|
|
@@ -267,27 +335,25 @@ function createSymbolOrString(identifier) {
|
|
|
267
335
|
return useSymbols ? Symbol(identifier) : identifier;
|
|
268
336
|
}
|
|
269
337
|
|
|
270
|
-
// ../utils/dist/jquery.js
|
|
271
|
-
var jQueryInstance = options_default.global && options_default.global.jQuery;
|
|
272
|
-
|
|
273
338
|
// ../utils/dist/dom/info.js
|
|
274
339
|
function domNodeIsContainedBy(node, containedByNode) {
|
|
275
340
|
if (node === containedByNode) {
|
|
276
341
|
return true;
|
|
277
342
|
}
|
|
278
|
-
if (node.nodeType ===
|
|
343
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
279
344
|
return false;
|
|
280
345
|
}
|
|
281
346
|
if (containedByNode.contains) {
|
|
282
|
-
return containedByNode.contains(node.nodeType !==
|
|
347
|
+
return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
|
|
283
348
|
}
|
|
284
349
|
if (containedByNode.compareDocumentPosition) {
|
|
285
350
|
return (containedByNode.compareDocumentPosition(node) & 16) == 16;
|
|
286
351
|
}
|
|
287
|
-
|
|
288
|
-
|
|
352
|
+
let parentNode = node;
|
|
353
|
+
while (parentNode && parentNode != containedByNode) {
|
|
354
|
+
parentNode = parentNode.parentNode;
|
|
289
355
|
}
|
|
290
|
-
return !!
|
|
356
|
+
return !!parentNode;
|
|
291
357
|
}
|
|
292
358
|
function domNodeIsAttachedToDocument(node) {
|
|
293
359
|
return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
|
|
@@ -296,70 +362,70 @@ function tagNameLower(element) {
|
|
|
296
362
|
return element && element.tagName && element.tagName.toLowerCase();
|
|
297
363
|
}
|
|
298
364
|
|
|
365
|
+
// ../utils/dist/dom/event.js
|
|
366
|
+
var knownEvents = {};
|
|
367
|
+
var knownEventTypesByEventName = {};
|
|
368
|
+
knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
|
|
369
|
+
knownEvents["MouseEvents"] = [
|
|
370
|
+
"click",
|
|
371
|
+
"dblclick",
|
|
372
|
+
"mousedown",
|
|
373
|
+
"mouseup",
|
|
374
|
+
"mousemove",
|
|
375
|
+
"mouseover",
|
|
376
|
+
"mouseout",
|
|
377
|
+
"mouseenter",
|
|
378
|
+
"mouseleave"
|
|
379
|
+
];
|
|
380
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
381
|
+
if (knownEventsForType.length) {
|
|
382
|
+
for (let i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
383
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
|
|
299
388
|
// ../utils/dist/dom/data.js
|
|
300
|
-
var datastoreTime = new Date().getTime();
|
|
389
|
+
var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
|
|
301
390
|
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
302
|
-
var dataStoreSymbol = Symbol("Knockout data");
|
|
303
|
-
var dataStore;
|
|
391
|
+
var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
|
|
304
392
|
var uniqueId = 0;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
clear(node) {
|
|
314
|
-
if (node[dataStoreSymbol]) {
|
|
315
|
-
delete node[dataStoreSymbol];
|
|
316
|
-
return true;
|
|
317
|
-
}
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
var IE = {
|
|
322
|
-
getDataforNode(node, createIfNotFound) {
|
|
323
|
-
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
324
|
-
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
|
|
325
|
-
if (!hasExistingDataStore) {
|
|
326
|
-
if (!createIfNotFound) {
|
|
327
|
-
return void 0;
|
|
328
|
-
}
|
|
329
|
-
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
|
330
|
-
dataStore[dataStoreKey] = {};
|
|
331
|
-
}
|
|
332
|
-
return dataStore[dataStoreKey];
|
|
333
|
-
},
|
|
334
|
-
clear(node) {
|
|
335
|
-
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
336
|
-
if (dataStoreKey) {
|
|
337
|
-
delete dataStore[dataStoreKey];
|
|
338
|
-
node[dataStoreKeyExpandoPropertyName] = null;
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
return false;
|
|
393
|
+
function isSafeKey(key) {
|
|
394
|
+
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
395
|
+
}
|
|
396
|
+
function getDataForNode(node, createIfNotFound) {
|
|
397
|
+
let dataForNode = node[dataStoreSymbol];
|
|
398
|
+
if (!dataForNode && createIfNotFound) {
|
|
399
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
342
400
|
}
|
|
343
|
-
|
|
344
|
-
|
|
401
|
+
return dataForNode;
|
|
402
|
+
}
|
|
345
403
|
function nextKey() {
|
|
346
404
|
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
347
405
|
}
|
|
348
406
|
function get(node, key) {
|
|
407
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
349
408
|
const dataForNode = getDataForNode(node, false);
|
|
350
409
|
return dataForNode && dataForNode[key];
|
|
351
410
|
}
|
|
352
411
|
function set(node, key, value) {
|
|
353
|
-
|
|
354
|
-
|
|
412
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
413
|
+
const dataForNode = getDataForNode(
|
|
414
|
+
node,
|
|
415
|
+
value !== void 0
|
|
416
|
+
/* createIfNotFound */
|
|
417
|
+
);
|
|
418
|
+
if (dataForNode) {
|
|
419
|
+
dataForNode[key] = value;
|
|
420
|
+
}
|
|
355
421
|
}
|
|
356
422
|
|
|
357
423
|
// ../utils/dist/dom/disposal.js
|
|
358
424
|
var domDataKey = nextKey();
|
|
359
425
|
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
360
|
-
|
|
426
|
+
let allDisposeCallbacks = get(node, domDataKey);
|
|
361
427
|
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
362
|
-
allDisposeCallbacks =
|
|
428
|
+
allDisposeCallbacks = new Array();
|
|
363
429
|
set(node, domDataKey, allDisposeCallbacks);
|
|
364
430
|
}
|
|
365
431
|
return allDisposeCallbacks;
|
|
@@ -374,7 +440,7 @@ function addDisposeCallback(node, callback) {
|
|
|
374
440
|
getDisposeCallbacksCollection(node, true).push(callback);
|
|
375
441
|
}
|
|
376
442
|
function removeDisposeCallback(node, callback) {
|
|
377
|
-
|
|
443
|
+
const callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
378
444
|
if (callbacksCollection) {
|
|
379
445
|
arrayRemoveItem(callbacksCollection, callback);
|
|
380
446
|
if (callbacksCollection.length === 0) {
|
|
@@ -382,58 +448,34 @@ function removeDisposeCallback(node, callback) {
|
|
|
382
448
|
}
|
|
383
449
|
}
|
|
384
450
|
}
|
|
385
|
-
var otherNodeCleanerFunctions =
|
|
451
|
+
var otherNodeCleanerFunctions = new Array();
|
|
386
452
|
function cleanjQueryData(node) {
|
|
387
|
-
|
|
453
|
+
const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
|
|
388
454
|
if (jQueryCleanNodeFn) {
|
|
389
455
|
jQueryCleanNodeFn([node]);
|
|
390
456
|
}
|
|
391
457
|
}
|
|
392
458
|
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
393
459
|
|
|
394
|
-
// ../utils/dist/dom/event.js
|
|
395
|
-
var knownEvents = {};
|
|
396
|
-
var knownEventTypesByEventName = {};
|
|
397
|
-
var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
|
|
398
|
-
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
|
|
399
|
-
knownEvents["MouseEvents"] = [
|
|
400
|
-
"click",
|
|
401
|
-
"dblclick",
|
|
402
|
-
"mousedown",
|
|
403
|
-
"mouseup",
|
|
404
|
-
"mousemove",
|
|
405
|
-
"mouseover",
|
|
406
|
-
"mouseout",
|
|
407
|
-
"mouseenter",
|
|
408
|
-
"mouseleave"
|
|
409
|
-
];
|
|
410
|
-
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
411
|
-
if (knownEventsForType.length) {
|
|
412
|
-
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
413
|
-
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
// ../utils/dist/dom/virtualElements.js
|
|
419
|
-
var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
|
|
420
|
-
|
|
421
460
|
// ../utils/dist/dom/html.js
|
|
422
|
-
var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
|
|
461
|
+
var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
|
|
423
462
|
|
|
424
463
|
// ../utils/dist/dom/selectExtensions.js
|
|
425
|
-
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
464
|
+
var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
426
465
|
var selectExtensions = {
|
|
427
466
|
optionValueDomDataKey: nextKey(),
|
|
428
467
|
readValue: function(element) {
|
|
429
468
|
switch (tagNameLower(element)) {
|
|
430
|
-
case "option":
|
|
469
|
+
case "option": {
|
|
431
470
|
if (element[hasDomDataExpandoProperty] === true) {
|
|
432
471
|
return get(element, selectExtensions.optionValueDomDataKey);
|
|
433
472
|
}
|
|
434
473
|
return element.value;
|
|
435
|
-
|
|
436
|
-
|
|
474
|
+
}
|
|
475
|
+
case "select": {
|
|
476
|
+
const selectElement = element;
|
|
477
|
+
return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
|
|
478
|
+
}
|
|
437
479
|
default:
|
|
438
480
|
return element.value;
|
|
439
481
|
}
|
|
@@ -446,36 +488,42 @@ var selectExtensions = {
|
|
|
446
488
|
if (hasDomDataExpandoProperty in element) {
|
|
447
489
|
delete element[hasDomDataExpandoProperty];
|
|
448
490
|
}
|
|
491
|
+
;
|
|
449
492
|
element.value = value;
|
|
450
493
|
} else {
|
|
494
|
+
const el = element;
|
|
451
495
|
set(element, selectExtensions.optionValueDomDataKey, value);
|
|
452
|
-
|
|
453
|
-
|
|
496
|
+
el[hasDomDataExpandoProperty] = true;
|
|
497
|
+
el.value = typeof value === "number" ? value : "";
|
|
454
498
|
}
|
|
455
499
|
break;
|
|
456
500
|
case "select":
|
|
457
|
-
|
|
458
|
-
value
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
501
|
+
{
|
|
502
|
+
if (value === "" || value === null) {
|
|
503
|
+
value = void 0;
|
|
504
|
+
}
|
|
505
|
+
let selection = -1;
|
|
506
|
+
const selectElement = element;
|
|
507
|
+
for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
|
|
508
|
+
optionValue = selectExtensions.readValue(selectElement.options[i]);
|
|
509
|
+
const strictEqual = optionValue === value;
|
|
510
|
+
const blankEqual = optionValue === "" && value === void 0;
|
|
511
|
+
const numericEqual = typeof value === "number" && Number(optionValue) === value;
|
|
512
|
+
if (strictEqual || blankEqual || numericEqual) {
|
|
513
|
+
selection = i;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
|
|
518
|
+
selectElement.selectedIndex = selection;
|
|
469
519
|
}
|
|
470
|
-
}
|
|
471
|
-
if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
|
|
472
|
-
element.selectedIndex = selection;
|
|
473
520
|
}
|
|
474
521
|
break;
|
|
475
522
|
default:
|
|
476
523
|
if (value === null || value === void 0) {
|
|
477
524
|
value = "";
|
|
478
525
|
}
|
|
526
|
+
;
|
|
479
527
|
element.value = value;
|
|
480
528
|
break;
|
|
481
529
|
}
|
|
@@ -490,30 +538,19 @@ __export(tasks_exports, {
|
|
|
490
538
|
runEarly: () => processTasks,
|
|
491
539
|
schedule: () => schedule
|
|
492
540
|
});
|
|
493
|
-
var taskQueue =
|
|
541
|
+
var taskQueue = new Array();
|
|
494
542
|
var taskQueueLength = 0;
|
|
495
543
|
var nextHandle = 1;
|
|
496
544
|
var nextIndexToProcess = 0;
|
|
497
545
|
var w = options_default.global;
|
|
498
546
|
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
499
|
-
options_default.taskScheduler = function(callback) {
|
|
500
|
-
|
|
547
|
+
options_default.taskScheduler = (function(callback) {
|
|
548
|
+
const div = w.document.createElement("div");
|
|
501
549
|
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
502
550
|
return function() {
|
|
503
551
|
div.classList.toggle("foo");
|
|
504
552
|
};
|
|
505
|
-
}(scheduledProcess);
|
|
506
|
-
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
|
|
507
|
-
options_default.taskScheduler = function(callback) {
|
|
508
|
-
var script = document.createElement("script");
|
|
509
|
-
script.onreadystatechange = function() {
|
|
510
|
-
script.onreadystatechange = null;
|
|
511
|
-
document.documentElement.removeChild(script);
|
|
512
|
-
script = null;
|
|
513
|
-
callback();
|
|
514
|
-
};
|
|
515
|
-
document.documentElement.appendChild(script);
|
|
516
|
-
};
|
|
553
|
+
})(scheduledProcess);
|
|
517
554
|
} else {
|
|
518
555
|
options_default.taskScheduler = function(callback) {
|
|
519
556
|
setTimeout(callback, 0);
|
|
@@ -521,8 +558,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
|
521
558
|
}
|
|
522
559
|
function processTasks() {
|
|
523
560
|
if (taskQueueLength) {
|
|
524
|
-
|
|
525
|
-
for (
|
|
561
|
+
let mark = taskQueueLength, countMarks = 0;
|
|
562
|
+
for (let task; nextIndexToProcess < taskQueueLength; ) {
|
|
526
563
|
if (task = taskQueue[nextIndexToProcess++]) {
|
|
527
564
|
if (nextIndexToProcess > mark) {
|
|
528
565
|
if (++countMarks >= 5e3) {
|
|
@@ -556,13 +593,13 @@ function schedule(func) {
|
|
|
556
593
|
return nextHandle++;
|
|
557
594
|
}
|
|
558
595
|
function cancel(handle) {
|
|
559
|
-
|
|
596
|
+
const index = handle - (nextHandle - taskQueueLength);
|
|
560
597
|
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
561
598
|
taskQueue[index] = null;
|
|
562
599
|
}
|
|
563
600
|
}
|
|
564
601
|
function resetForTesting() {
|
|
565
|
-
|
|
602
|
+
const length = taskQueueLength - nextIndexToProcess;
|
|
566
603
|
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
567
604
|
return length;
|
|
568
605
|
}
|
|
@@ -581,13 +618,13 @@ __export(dependencyDetection_exports, {
|
|
|
581
618
|
});
|
|
582
619
|
|
|
583
620
|
// ../observable/dist/subscribableSymbol.js
|
|
584
|
-
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
|
|
621
|
+
var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
|
|
585
622
|
function isSubscribable(instance) {
|
|
586
623
|
return instance && instance[SUBSCRIBABLE_SYM] || false;
|
|
587
624
|
}
|
|
588
625
|
|
|
589
626
|
// ../observable/dist/dependencyDetection.js
|
|
590
|
-
var outerFrames =
|
|
627
|
+
var outerFrames = new Array();
|
|
591
628
|
var currentFrame;
|
|
592
629
|
var lastId = 0;
|
|
593
630
|
function getId() {
|
|
@@ -605,7 +642,11 @@ function registerDependency(subscribable2) {
|
|
|
605
642
|
if (!isSubscribable(subscribable2)) {
|
|
606
643
|
throw new Error("Only subscribable things can act as dependencies");
|
|
607
644
|
}
|
|
608
|
-
currentFrame.callback.call(
|
|
645
|
+
currentFrame.callback.call(
|
|
646
|
+
currentFrame.callbackTarget,
|
|
647
|
+
subscribable2,
|
|
648
|
+
subscribable2._id || (subscribable2._id = getId())
|
|
649
|
+
);
|
|
609
650
|
}
|
|
610
651
|
}
|
|
611
652
|
function ignore(callback, callbackTarget, callbackArgs) {
|
|
@@ -620,16 +661,19 @@ function getDependenciesCount() {
|
|
|
620
661
|
if (currentFrame) {
|
|
621
662
|
return currentFrame.computed.getDependenciesCount();
|
|
622
663
|
}
|
|
664
|
+
return void 0;
|
|
623
665
|
}
|
|
624
666
|
function getDependencies() {
|
|
625
667
|
if (currentFrame) {
|
|
626
668
|
return currentFrame.computed.getDependencies();
|
|
627
669
|
}
|
|
670
|
+
return void 0;
|
|
628
671
|
}
|
|
629
672
|
function isInitial() {
|
|
630
673
|
if (currentFrame) {
|
|
631
674
|
return currentFrame.isInitial;
|
|
632
675
|
}
|
|
676
|
+
return void 0;
|
|
633
677
|
}
|
|
634
678
|
|
|
635
679
|
// ../observable/dist/defer.js
|
|
@@ -676,6 +720,7 @@ var Subscription = class {
|
|
|
676
720
|
this._node = node;
|
|
677
721
|
addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
|
|
678
722
|
}
|
|
723
|
+
// TC39 Observable API
|
|
679
724
|
unsubscribe() {
|
|
680
725
|
this.dispose();
|
|
681
726
|
}
|
|
@@ -685,21 +730,16 @@ var Subscription = class {
|
|
|
685
730
|
};
|
|
686
731
|
|
|
687
732
|
// ../observable/dist/extenders.js
|
|
688
|
-
var primitiveTypes = {
|
|
689
|
-
"undefined": 1,
|
|
690
|
-
"boolean": 1,
|
|
691
|
-
"number": 1,
|
|
692
|
-
"string": 1
|
|
693
|
-
};
|
|
733
|
+
var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
|
|
694
734
|
function valuesArePrimitiveAndEqual(a, b) {
|
|
695
|
-
|
|
735
|
+
const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
|
|
696
736
|
return oldValueIsPrimitive ? a === b : false;
|
|
697
737
|
}
|
|
698
738
|
function applyExtenders(requestedExtenders) {
|
|
699
|
-
|
|
739
|
+
let target = this;
|
|
700
740
|
if (requestedExtenders) {
|
|
701
741
|
objectForEach(requestedExtenders, function(key, value) {
|
|
702
|
-
|
|
742
|
+
const extenderHandler = extenders[key];
|
|
703
743
|
if (typeof extenderHandler === "function") {
|
|
704
744
|
target = extenderHandler(target, value) || target;
|
|
705
745
|
} else {
|
|
@@ -714,12 +754,14 @@ function notify(target, notifyWhen) {
|
|
|
714
754
|
}
|
|
715
755
|
function deferred(target, option) {
|
|
716
756
|
if (option !== true) {
|
|
717
|
-
throw new Error(
|
|
757
|
+
throw new Error(
|
|
758
|
+
"The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
|
|
759
|
+
);
|
|
718
760
|
}
|
|
719
761
|
deferUpdates(target);
|
|
720
762
|
}
|
|
721
763
|
function rateLimit(target, options2) {
|
|
722
|
-
|
|
764
|
+
let timeout, method, limitFunction;
|
|
723
765
|
if (typeof options2 === "number") {
|
|
724
766
|
timeout = options2;
|
|
725
767
|
} else {
|
|
@@ -732,21 +774,17 @@ function rateLimit(target, options2) {
|
|
|
732
774
|
return limitFunction(callback, timeout);
|
|
733
775
|
});
|
|
734
776
|
}
|
|
735
|
-
var extenders = {
|
|
736
|
-
notify,
|
|
737
|
-
deferred,
|
|
738
|
-
rateLimit
|
|
739
|
-
};
|
|
777
|
+
var extenders = { notify, deferred, rateLimit };
|
|
740
778
|
|
|
741
779
|
// ../observable/dist/subscribable.js
|
|
742
|
-
var LATEST_VALUE = Symbol("Knockout latest value");
|
|
780
|
+
var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
|
|
743
781
|
if (!Symbol.observable) {
|
|
744
|
-
Symbol.observable = Symbol.for("@tko/Symbol.observable");
|
|
782
|
+
Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
|
|
745
783
|
}
|
|
746
|
-
function
|
|
784
|
+
var subscribable = function subscribableFactory() {
|
|
747
785
|
Object.setPrototypeOf(this, ko_subscribable_fn);
|
|
748
786
|
ko_subscribable_fn.init(this);
|
|
749
|
-
}
|
|
787
|
+
};
|
|
750
788
|
var defaultEvent = "change";
|
|
751
789
|
var ko_subscribable_fn = {
|
|
752
790
|
[SUBSCRIBABLE_SYM]: true,
|
|
@@ -760,9 +798,7 @@ var ko_subscribable_fn = {
|
|
|
760
798
|
subscribe(callback, callbackTarget, event) {
|
|
761
799
|
const isTC39Callback = typeof callback === "object" && callback.next;
|
|
762
800
|
event = event || defaultEvent;
|
|
763
|
-
const observer = isTC39Callback ? callback : {
|
|
764
|
-
next: callbackTarget ? callback.bind(callbackTarget) : callback
|
|
765
|
-
};
|
|
801
|
+
const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
|
|
766
802
|
const subscriptionInstance = new Subscription(this, observer, () => {
|
|
767
803
|
arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
|
|
768
804
|
if (this.afterSubscriptionRemove) {
|
|
@@ -773,7 +809,7 @@ var ko_subscribable_fn = {
|
|
|
773
809
|
this.beforeSubscriptionAdd(event);
|
|
774
810
|
}
|
|
775
811
|
if (!this._subscriptions[event]) {
|
|
776
|
-
this._subscriptions[event] =
|
|
812
|
+
this._subscriptions[event] = new Array();
|
|
777
813
|
}
|
|
778
814
|
this._subscriptions[event].push(subscriptionInstance);
|
|
779
815
|
if (isTC39Callback && LATEST_VALUE in this) {
|
|
@@ -816,7 +852,7 @@ var ko_subscribable_fn = {
|
|
|
816
852
|
if (event) {
|
|
817
853
|
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
|
818
854
|
} else {
|
|
819
|
-
|
|
855
|
+
let total = 0;
|
|
820
856
|
objectForEach(this._subscriptions, function(eventName, subscriptions) {
|
|
821
857
|
if (eventName !== "dirty") {
|
|
822
858
|
total += subscriptions.length;
|
|
@@ -871,6 +907,7 @@ function observable(initialValue) {
|
|
|
871
907
|
function Observable() {
|
|
872
908
|
if (arguments.length > 0) {
|
|
873
909
|
if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
|
|
910
|
+
;
|
|
874
911
|
Observable.valueWillMutate();
|
|
875
912
|
Observable[LATEST_VALUE] = arguments[0];
|
|
876
913
|
Observable.valueHasMutated();
|
|
@@ -891,20 +928,43 @@ function observable(initialValue) {
|
|
|
891
928
|
return Observable;
|
|
892
929
|
}
|
|
893
930
|
observable.fn = {
|
|
931
|
+
/**
|
|
932
|
+
* Compares two values for equality.
|
|
933
|
+
* @param a The first value.
|
|
934
|
+
* @param b The second value.
|
|
935
|
+
* @returns True if the values are equal, otherwise false.
|
|
936
|
+
*/
|
|
894
937
|
equalityComparer: valuesArePrimitiveAndEqual,
|
|
938
|
+
/**
|
|
939
|
+
* Returns the current value of the observable without creating a dependency.
|
|
940
|
+
* @returns The current value.
|
|
941
|
+
*/
|
|
895
942
|
peek() {
|
|
896
943
|
return this[LATEST_VALUE];
|
|
897
944
|
},
|
|
945
|
+
/**
|
|
946
|
+
* Notifies subscribers that the value has changed.
|
|
947
|
+
*/
|
|
898
948
|
valueHasMutated() {
|
|
899
949
|
this.notifySubscribers(this[LATEST_VALUE], "spectate");
|
|
900
950
|
this.notifySubscribers(this[LATEST_VALUE]);
|
|
901
951
|
},
|
|
952
|
+
/**
|
|
953
|
+
* Notifies subscribers that the value is about to change.
|
|
954
|
+
*/
|
|
902
955
|
valueWillMutate() {
|
|
903
956
|
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
|
|
904
957
|
},
|
|
958
|
+
/**
|
|
959
|
+
* Modifies the value of the observable using a function.
|
|
960
|
+
* @param fn The function to modify the value.
|
|
961
|
+
* @param peek Whether to use the current value without creating a dependency.
|
|
962
|
+
* @returns The modified observable.
|
|
963
|
+
*/
|
|
905
964
|
modify(fn, peek22 = true) {
|
|
906
|
-
|
|
965
|
+
this(fn(peek22 ? this.peek() : this()));
|
|
907
966
|
},
|
|
967
|
+
// Some observables may not always be writeable, notably computeds.
|
|
908
968
|
isWriteable: true
|
|
909
969
|
};
|
|
910
970
|
function limitNotifySubscribers(value, event) {
|
|
@@ -917,15 +977,15 @@ function limitNotifySubscribers(value, event) {
|
|
|
917
977
|
}
|
|
918
978
|
}
|
|
919
979
|
subscribable.fn.limit = function limit(limitFunction) {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
980
|
+
const self = this;
|
|
981
|
+
const selfIsObservable = isObservable(self);
|
|
982
|
+
const beforeChange = "beforeChange";
|
|
983
|
+
let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
|
|
924
984
|
if (!self._origNotifySubscribers) {
|
|
925
985
|
self._origNotifySubscribers = self.notifySubscribers;
|
|
926
986
|
self.notifySubscribers = limitNotifySubscribers;
|
|
927
987
|
}
|
|
928
|
-
|
|
988
|
+
const finish = limitFunction(function() {
|
|
929
989
|
self._notificationIsPending = false;
|
|
930
990
|
if (selfIsObservable && pendingValue === self) {
|
|
931
991
|
pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
|
|
@@ -953,7 +1013,10 @@ subscribable.fn.limit = function limit(limitFunction) {
|
|
|
953
1013
|
}
|
|
954
1014
|
},
|
|
955
1015
|
_notifyNextChangeIfValueIsDifferent() {
|
|
956
|
-
if (self.isDifferent(previousValue, self.peek(
|
|
1016
|
+
if (self.isDifferent(previousValue, self.peek(
|
|
1017
|
+
true
|
|
1018
|
+
/* evaluate */
|
|
1019
|
+
))) {
|
|
957
1020
|
notifyNextChange = true;
|
|
958
1021
|
}
|
|
959
1022
|
},
|
|
@@ -993,8 +1056,8 @@ function trackArrayChanges(target, options2) {
|
|
|
993
1056
|
let arrayChangeSubscription;
|
|
994
1057
|
let pendingNotifications = 0;
|
|
995
1058
|
let underlyingNotifySubscribersFunction;
|
|
996
|
-
|
|
997
|
-
|
|
1059
|
+
const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
|
|
1060
|
+
const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
|
|
998
1061
|
target.beforeSubscriptionAdd = function(event) {
|
|
999
1062
|
if (underlyingBeforeSubscriptionAddFunction) {
|
|
1000
1063
|
underlyingBeforeSubscriptionAddFunction.call(target, event);
|
|
@@ -1031,11 +1094,11 @@ function trackArrayChanges(target, options2) {
|
|
|
1031
1094
|
}
|
|
1032
1095
|
return underlyingNotifySubscribersFunction.apply(this, arguments);
|
|
1033
1096
|
};
|
|
1034
|
-
|
|
1097
|
+
let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
|
|
1035
1098
|
cachedDiff = null;
|
|
1036
1099
|
arrayChangeSubscription = target.subscribe(function(currentContents) {
|
|
1037
1100
|
let changes;
|
|
1038
|
-
currentContents =
|
|
1101
|
+
currentContents = new Array().concat(currentContents || []);
|
|
1039
1102
|
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1040
1103
|
changes = getChanges(previousContents, currentContents);
|
|
1041
1104
|
}
|
|
@@ -1057,9 +1120,9 @@ function trackArrayChanges(target, options2) {
|
|
|
1057
1120
|
if (!trackingChanges || pendingNotifications) {
|
|
1058
1121
|
return;
|
|
1059
1122
|
}
|
|
1060
|
-
|
|
1123
|
+
let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
|
|
1061
1124
|
function pushDiff(status, value, index) {
|
|
1062
|
-
return diff[diff.length] = {
|
|
1125
|
+
return diff[diff.length] = { status, value, index };
|
|
1063
1126
|
}
|
|
1064
1127
|
switch (operationName) {
|
|
1065
1128
|
case "push":
|
|
@@ -1077,16 +1140,18 @@ function trackArrayChanges(target, options2) {
|
|
|
1077
1140
|
}
|
|
1078
1141
|
break;
|
|
1079
1142
|
case "splice":
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1143
|
+
{
|
|
1144
|
+
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();
|
|
1145
|
+
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
|
|
1146
|
+
if (index < endDeleteIndex) {
|
|
1147
|
+
deletions.push(pushDiff("deleted", rawArray[index], index));
|
|
1148
|
+
}
|
|
1149
|
+
if (index < endAddIndex) {
|
|
1150
|
+
additions.push(pushDiff("added", args[argsIndex], index));
|
|
1151
|
+
}
|
|
1087
1152
|
}
|
|
1153
|
+
findMovesInArrayComparison(deletions, additions);
|
|
1088
1154
|
}
|
|
1089
|
-
findMovesInArrayComparison(deletions, additions);
|
|
1090
1155
|
break;
|
|
1091
1156
|
default:
|
|
1092
1157
|
return;
|
|
@@ -1101,23 +1166,27 @@ extenders.trackArrayChanges = trackArrayChanges;
|
|
|
1101
1166
|
function observableArray(initialValues) {
|
|
1102
1167
|
initialValues = initialValues || [];
|
|
1103
1168
|
if (typeof initialValues !== "object" || !("length" in initialValues)) {
|
|
1104
|
-
throw new Error(
|
|
1169
|
+
throw new Error(
|
|
1170
|
+
"The argument passed when initializing an observable array must be an array, or null, or undefined."
|
|
1171
|
+
);
|
|
1105
1172
|
}
|
|
1106
|
-
|
|
1107
|
-
Object.setPrototypeOf(result, observableArray.fn);
|
|
1173
|
+
const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
|
|
1108
1174
|
trackArrayChanges(result);
|
|
1109
|
-
overwriteLengthPropertyIfSupported(result, { get: () =>
|
|
1175
|
+
overwriteLengthPropertyIfSupported(result, { get: () => {
|
|
1176
|
+
var _a;
|
|
1177
|
+
return (_a = result()) == null ? void 0 : _a.length;
|
|
1178
|
+
} });
|
|
1110
1179
|
return result;
|
|
1111
1180
|
}
|
|
1112
1181
|
observableArray.fn = {
|
|
1113
1182
|
remove(valueOrPredicate) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
return
|
|
1183
|
+
const underlyingArray = this.peek();
|
|
1184
|
+
const removedValues = new Array();
|
|
1185
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
|
|
1186
|
+
return value === valueOrPredicate;
|
|
1118
1187
|
};
|
|
1119
|
-
for (
|
|
1120
|
-
|
|
1188
|
+
for (let i = 0; i < underlyingArray.length; i++) {
|
|
1189
|
+
const value = underlyingArray[i];
|
|
1121
1190
|
if (predicate(value)) {
|
|
1122
1191
|
if (removedValues.length === 0) {
|
|
1123
1192
|
this.valueWillMutate();
|
|
@@ -1137,8 +1206,8 @@ observableArray.fn = {
|
|
|
1137
1206
|
},
|
|
1138
1207
|
removeAll(arrayOfValues) {
|
|
1139
1208
|
if (arrayOfValues === void 0) {
|
|
1140
|
-
|
|
1141
|
-
|
|
1209
|
+
const underlyingArray = this.peek();
|
|
1210
|
+
const allValues = underlyingArray.slice(0);
|
|
1142
1211
|
this.valueWillMutate();
|
|
1143
1212
|
underlyingArray.splice(0, underlyingArray.length);
|
|
1144
1213
|
this.valueHasMutated();
|
|
@@ -1152,13 +1221,13 @@ observableArray.fn = {
|
|
|
1152
1221
|
});
|
|
1153
1222
|
},
|
|
1154
1223
|
destroy(valueOrPredicate) {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
return
|
|
1224
|
+
const underlyingArray = this.peek();
|
|
1225
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
|
|
1226
|
+
return value === valueOrPredicate;
|
|
1158
1227
|
};
|
|
1159
1228
|
this.valueWillMutate();
|
|
1160
|
-
for (
|
|
1161
|
-
|
|
1229
|
+
for (let i = underlyingArray.length - 1; i >= 0; i--) {
|
|
1230
|
+
const value = underlyingArray[i];
|
|
1162
1231
|
if (predicate(value)) {
|
|
1163
1232
|
value["_destroy"] = true;
|
|
1164
1233
|
}
|
|
@@ -1182,7 +1251,7 @@ observableArray.fn = {
|
|
|
1182
1251
|
return arrayIndexOf(this(), item);
|
|
1183
1252
|
},
|
|
1184
1253
|
replace(oldItem, newItem) {
|
|
1185
|
-
|
|
1254
|
+
const index = this.indexOf(oldItem);
|
|
1186
1255
|
if (index >= 0) {
|
|
1187
1256
|
this.valueWillMutate();
|
|
1188
1257
|
this.peek()[index] = newItem;
|
|
@@ -1196,23 +1265,23 @@ observableArray.fn = {
|
|
|
1196
1265
|
return [...this()].reverse();
|
|
1197
1266
|
},
|
|
1198
1267
|
[Symbol.iterator]: function* () {
|
|
1199
|
-
yield* this();
|
|
1268
|
+
yield* __yieldStar(this());
|
|
1200
1269
|
}
|
|
1201
1270
|
};
|
|
1202
1271
|
Object.setPrototypeOf(observableArray.fn, observable.fn);
|
|
1203
1272
|
arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
1204
1273
|
observableArray.fn[methodName] = function() {
|
|
1205
|
-
|
|
1274
|
+
const underlyingArray = this.peek();
|
|
1206
1275
|
this.valueWillMutate();
|
|
1207
1276
|
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
|
|
1208
|
-
|
|
1277
|
+
const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1209
1278
|
this.valueHasMutated();
|
|
1210
1279
|
return methodCallResult === underlyingArray ? this : methodCallResult;
|
|
1211
1280
|
};
|
|
1212
1281
|
});
|
|
1213
1282
|
arrayForEach(["slice"], function(methodName) {
|
|
1214
1283
|
observableArray.fn[methodName] = function() {
|
|
1215
|
-
|
|
1284
|
+
const underlyingArray = this();
|
|
1216
1285
|
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1217
1286
|
};
|
|
1218
1287
|
});
|
|
@@ -1240,11 +1309,11 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1240
1309
|
options2.read = evaluatorFunctionOrOptions;
|
|
1241
1310
|
}
|
|
1242
1311
|
}
|
|
1243
|
-
if (typeof options2.read !== "function") {
|
|
1312
|
+
if (typeof (options2 == null ? void 0 : options2.read) !== "function") {
|
|
1244
1313
|
throw Error("Pass a function that returns the value of the computed");
|
|
1245
1314
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1315
|
+
const writeFunction = options2.write;
|
|
1316
|
+
const state = {
|
|
1248
1317
|
latestValue: void 0,
|
|
1249
1318
|
isStale: true,
|
|
1250
1319
|
isDirty: true,
|
|
@@ -1255,8 +1324,8 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1255
1324
|
isSleeping: false,
|
|
1256
1325
|
readFunction: options2.read,
|
|
1257
1326
|
evaluatorFunctionTarget: evaluatorFunctionTarget || options2.owner,
|
|
1258
|
-
disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved ||
|
|
1259
|
-
disposeWhen: options2.disposeWhen
|
|
1327
|
+
disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || null,
|
|
1328
|
+
disposeWhen: options2.disposeWhen,
|
|
1260
1329
|
domNodeDisposalCallback: null,
|
|
1261
1330
|
dependencyTracking: {},
|
|
1262
1331
|
dependenciesCount: 0,
|
|
@@ -1267,7 +1336,9 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1267
1336
|
if (typeof writeFunction === "function") {
|
|
1268
1337
|
writeFunction.apply(state.evaluatorFunctionTarget, arguments);
|
|
1269
1338
|
} else {
|
|
1270
|
-
throw new Error(
|
|
1339
|
+
throw new Error(
|
|
1340
|
+
"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."
|
|
1341
|
+
);
|
|
1271
1342
|
}
|
|
1272
1343
|
return this;
|
|
1273
1344
|
} else {
|
|
@@ -1275,6 +1346,7 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1275
1346
|
dependencyDetection_exports.registerDependency(computedObservable);
|
|
1276
1347
|
}
|
|
1277
1348
|
if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
|
|
1349
|
+
;
|
|
1278
1350
|
computedObservable.evaluateImmediate();
|
|
1279
1351
|
}
|
|
1280
1352
|
return state.latestValue;
|
|
@@ -1304,12 +1376,17 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options2)
|
|
|
1304
1376
|
}
|
|
1305
1377
|
}
|
|
1306
1378
|
if (!state.isSleeping && !options2.deferEvaluation) {
|
|
1379
|
+
;
|
|
1307
1380
|
computedObservable.evaluateImmediate();
|
|
1308
1381
|
}
|
|
1309
1382
|
if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
|
|
1310
|
-
addDisposeCallback(
|
|
1311
|
-
|
|
1312
|
-
|
|
1383
|
+
addDisposeCallback(
|
|
1384
|
+
state.disposeWhenNodeIsRemoved,
|
|
1385
|
+
state.domNodeDisposalCallback = function() {
|
|
1386
|
+
;
|
|
1387
|
+
computedObservable.dispose();
|
|
1388
|
+
}
|
|
1389
|
+
);
|
|
1313
1390
|
}
|
|
1314
1391
|
return computedObservable;
|
|
1315
1392
|
}
|
|
@@ -1319,14 +1396,18 @@ function computedDisposeDependencyCallback(id, entryToDispose) {
|
|
|
1319
1396
|
}
|
|
1320
1397
|
}
|
|
1321
1398
|
function computedBeginDependencyDetectionCallback(subscribable2, id) {
|
|
1322
|
-
|
|
1399
|
+
const computedObservable = this.computedObservable, state = computedObservable[computedState];
|
|
1323
1400
|
if (!state.isDisposed) {
|
|
1324
1401
|
if (this.disposalCount && this.disposalCandidates[id]) {
|
|
1325
1402
|
computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
|
|
1326
1403
|
this.disposalCandidates[id] = null;
|
|
1327
1404
|
--this.disposalCount;
|
|
1328
1405
|
} else if (!state.dependencyTracking[id]) {
|
|
1329
|
-
computedObservable.addDependencyTracking(
|
|
1406
|
+
computedObservable.addDependencyTracking(
|
|
1407
|
+
id,
|
|
1408
|
+
subscribable2,
|
|
1409
|
+
state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
|
|
1410
|
+
);
|
|
1330
1411
|
}
|
|
1331
1412
|
if (subscribable2._notificationIsPending) {
|
|
1332
1413
|
subscribable2._notifyNextChangeIfValueIsDifferent();
|
|
@@ -1340,7 +1421,7 @@ computed.fn = {
|
|
|
1340
1421
|
},
|
|
1341
1422
|
getDependencies() {
|
|
1342
1423
|
const dependencyTracking = this[computedState].dependencyTracking;
|
|
1343
|
-
const dependentObservables =
|
|
1424
|
+
const dependentObservables = new Array();
|
|
1344
1425
|
objectForEach(dependencyTracking, function(id, dependency) {
|
|
1345
1426
|
dependentObservables[dependency._order] = dependency._target;
|
|
1346
1427
|
});
|
|
@@ -1355,7 +1436,7 @@ computed.fn = {
|
|
|
1355
1436
|
trackingObj._version = target.getVersion();
|
|
1356
1437
|
},
|
|
1357
1438
|
haveDependenciesChanged() {
|
|
1358
|
-
|
|
1439
|
+
let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
|
|
1359
1440
|
for (id in dependencyTracking) {
|
|
1360
1441
|
if (hasOwnProperty(dependencyTracking, id)) {
|
|
1361
1442
|
dependency = dependencyTracking[id];
|
|
@@ -1364,10 +1445,14 @@ computed.fn = {
|
|
|
1364
1445
|
}
|
|
1365
1446
|
}
|
|
1366
1447
|
}
|
|
1448
|
+
return false;
|
|
1367
1449
|
},
|
|
1368
1450
|
markDirty() {
|
|
1369
1451
|
if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
|
|
1370
|
-
this._evalDelayed(
|
|
1452
|
+
this._evalDelayed(
|
|
1453
|
+
false
|
|
1454
|
+
/* notifyChange */
|
|
1455
|
+
);
|
|
1371
1456
|
}
|
|
1372
1457
|
},
|
|
1373
1458
|
isActive() {
|
|
@@ -1383,7 +1468,7 @@ computed.fn = {
|
|
|
1383
1468
|
},
|
|
1384
1469
|
subscribeToDependency(target) {
|
|
1385
1470
|
if (target._deferUpdates) {
|
|
1386
|
-
|
|
1471
|
+
const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
|
|
1387
1472
|
return {
|
|
1388
1473
|
_target: target,
|
|
1389
1474
|
dispose() {
|
|
@@ -1396,20 +1481,29 @@ computed.fn = {
|
|
|
1396
1481
|
}
|
|
1397
1482
|
},
|
|
1398
1483
|
evaluatePossiblyAsync() {
|
|
1399
|
-
|
|
1484
|
+
const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
|
|
1400
1485
|
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
|
1401
1486
|
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
|
1402
1487
|
this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
|
|
1403
|
-
computedObservable.evaluateImmediate(
|
|
1488
|
+
computedObservable.evaluateImmediate(
|
|
1489
|
+
true
|
|
1490
|
+
/* notifyChange */
|
|
1491
|
+
);
|
|
1404
1492
|
}, throttleEvaluationTimeout);
|
|
1405
1493
|
} else if (computedObservable._evalDelayed) {
|
|
1406
|
-
computedObservable._evalDelayed(
|
|
1494
|
+
computedObservable._evalDelayed(
|
|
1495
|
+
true
|
|
1496
|
+
/* notifyChange */
|
|
1497
|
+
);
|
|
1407
1498
|
} else {
|
|
1408
|
-
computedObservable.evaluateImmediate(
|
|
1499
|
+
computedObservable.evaluateImmediate(
|
|
1500
|
+
true
|
|
1501
|
+
/* notifyChange */
|
|
1502
|
+
);
|
|
1409
1503
|
}
|
|
1410
1504
|
},
|
|
1411
1505
|
evaluateImmediate(notifyChange) {
|
|
1412
|
-
|
|
1506
|
+
let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
|
|
1413
1507
|
if (state.isBeingEvaluated) {
|
|
1414
1508
|
return;
|
|
1415
1509
|
}
|
|
@@ -1433,8 +1527,8 @@ computed.fn = {
|
|
|
1433
1527
|
return changed;
|
|
1434
1528
|
},
|
|
1435
1529
|
evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
|
|
1436
|
-
|
|
1437
|
-
|
|
1530
|
+
let computedObservable = this, state = computedObservable[computedState], changed = false;
|
|
1531
|
+
const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
|
|
1438
1532
|
computedObservable,
|
|
1439
1533
|
disposalCandidates: state.dependencyTracking,
|
|
1440
1534
|
disposalCount: state.dependenciesCount
|
|
@@ -1447,7 +1541,7 @@ computed.fn = {
|
|
|
1447
1541
|
});
|
|
1448
1542
|
state.dependencyTracking = {};
|
|
1449
1543
|
state.dependenciesCount = 0;
|
|
1450
|
-
|
|
1544
|
+
const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
|
|
1451
1545
|
if (!state.dependenciesCount) {
|
|
1452
1546
|
computedObservable.dispose();
|
|
1453
1547
|
changed = true;
|
|
@@ -1479,7 +1573,7 @@ computed.fn = {
|
|
|
1479
1573
|
},
|
|
1480
1574
|
evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
|
|
1481
1575
|
try {
|
|
1482
|
-
|
|
1576
|
+
const readFunction = state.readFunction;
|
|
1483
1577
|
return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
|
|
1484
1578
|
} finally {
|
|
1485
1579
|
dependencyDetection_exports.end();
|
|
@@ -1519,12 +1613,16 @@ computed.fn = {
|
|
|
1519
1613
|
if (isChange) {
|
|
1520
1614
|
state.isStale = true;
|
|
1521
1615
|
}
|
|
1522
|
-
this._limitChange(
|
|
1616
|
+
this._limitChange(
|
|
1617
|
+
this,
|
|
1618
|
+
!isChange
|
|
1619
|
+
/* isDirty */
|
|
1620
|
+
);
|
|
1523
1621
|
}
|
|
1524
1622
|
});
|
|
1525
1623
|
},
|
|
1526
1624
|
dispose() {
|
|
1527
|
-
|
|
1625
|
+
const state = this[computedState];
|
|
1528
1626
|
if (!state.isSleeping && state.dependencyTracking) {
|
|
1529
1627
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
1530
1628
|
if (dependency.dispose) {
|
|
@@ -1540,7 +1638,7 @@ computed.fn = {
|
|
|
1540
1638
|
};
|
|
1541
1639
|
var pureComputedOverrides = {
|
|
1542
1640
|
beforeSubscriptionAdd(event) {
|
|
1543
|
-
|
|
1641
|
+
const computedObservable = this, state = computedObservable[computedState];
|
|
1544
1642
|
if (!state.isDisposed && state.isSleeping && event === "change") {
|
|
1545
1643
|
state.isSleeping = false;
|
|
1546
1644
|
if (state.isStale || computedObservable.haveDependenciesChanged()) {
|
|
@@ -1550,12 +1648,12 @@ var pureComputedOverrides = {
|
|
|
1550
1648
|
computedObservable.updateVersion();
|
|
1551
1649
|
}
|
|
1552
1650
|
} else {
|
|
1553
|
-
|
|
1651
|
+
const dependenciesOrder = new Array();
|
|
1554
1652
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
1555
1653
|
dependenciesOrder[dependency._order] = id;
|
|
1556
1654
|
});
|
|
1557
1655
|
arrayForEach(dependenciesOrder, function(id, order) {
|
|
1558
|
-
|
|
1656
|
+
const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
|
|
1559
1657
|
subscription._order = order;
|
|
1560
1658
|
subscription._version = dependency._version;
|
|
1561
1659
|
state.dependencyTracking[id] = subscription;
|
|
@@ -1572,7 +1670,7 @@ var pureComputedOverrides = {
|
|
|
1572
1670
|
}
|
|
1573
1671
|
},
|
|
1574
1672
|
afterSubscriptionRemove(event) {
|
|
1575
|
-
|
|
1673
|
+
const state = this[computedState];
|
|
1576
1674
|
if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
|
|
1577
1675
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
1578
1676
|
if (dependency.dispose) {
|
|
@@ -1589,7 +1687,7 @@ var pureComputedOverrides = {
|
|
|
1589
1687
|
}
|
|
1590
1688
|
},
|
|
1591
1689
|
getVersion() {
|
|
1592
|
-
|
|
1690
|
+
const state = this[computedState];
|
|
1593
1691
|
if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
|
|
1594
1692
|
this.evaluateImmediate();
|
|
1595
1693
|
}
|
|
@@ -1615,18 +1713,20 @@ function isPureComputed(instance) {
|
|
|
1615
1713
|
}
|
|
1616
1714
|
function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
|
|
1617
1715
|
if (typeof evaluatorFunctionOrOptions === "function") {
|
|
1618
|
-
|
|
1716
|
+
const evaluator = evaluatorFunctionOrOptions;
|
|
1717
|
+
return computed(evaluator, evaluatorFunctionTarget, { pure: true });
|
|
1619
1718
|
} else {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1719
|
+
let options2 = evaluatorFunctionOrOptions;
|
|
1720
|
+
options2 = extend({}, options2);
|
|
1721
|
+
options2.pure = true;
|
|
1722
|
+
return computed(options2, evaluatorFunctionTarget);
|
|
1623
1723
|
}
|
|
1624
1724
|
}
|
|
1625
1725
|
|
|
1626
1726
|
// src/throttleExtender.ts
|
|
1627
1727
|
function throttleExtender(target, timeout) {
|
|
1628
1728
|
target.throttleEvaluation = timeout;
|
|
1629
|
-
|
|
1729
|
+
let writeTimeoutInstance = void 0;
|
|
1630
1730
|
return computed({
|
|
1631
1731
|
read: target,
|
|
1632
1732
|
write: function(value) {
|
|
@@ -1637,11 +1737,12 @@ function throttleExtender(target, timeout) {
|
|
|
1637
1737
|
}
|
|
1638
1738
|
});
|
|
1639
1739
|
}
|
|
1640
|
-
|
|
1740
|
+
var extenders2 = extenders;
|
|
1741
|
+
extenders2.throttle = throttleExtender;
|
|
1641
1742
|
|
|
1642
1743
|
// src/proxy.ts
|
|
1643
|
-
var PROXY_SYM = Symbol("Knockout Proxied Object");
|
|
1644
|
-
var MIRROR_SYM = Symbol("Knockout Proxied Observables");
|
|
1744
|
+
var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
|
|
1745
|
+
var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
|
|
1645
1746
|
function makeComputed(proxy2, fn) {
|
|
1646
1747
|
return computed({
|
|
1647
1748
|
owner: proxy2,
|
|
@@ -1708,10 +1809,7 @@ function proxy(object) {
|
|
|
1708
1809
|
return Object.isExtensible(object);
|
|
1709
1810
|
},
|
|
1710
1811
|
ownKeys() {
|
|
1711
|
-
return [
|
|
1712
|
-
...Object.getOwnPropertyNames(object),
|
|
1713
|
-
...Object.getOwnPropertySymbols(object)
|
|
1714
|
-
];
|
|
1812
|
+
return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
|
|
1715
1813
|
}
|
|
1716
1814
|
});
|
|
1717
1815
|
assignOrUpdate(mirror, object, proxy2);
|