Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@tko/lifecycle

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tko/lifecycle - npm Package Compare versions

Comparing version
4.0.0-beta1.3
to
4.0.0
+425
-315
dist/index.cjs

@@ -1,2 +0,3 @@

// @tko/lifecycle 🥊 4.0.0-beta1.3 CommonJS
// @tko/lifecycle 🥊 4.0.0 CommonJS
"use strict";
var __defProp = Object.defineProperty;

@@ -6,2 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
var __typeError = (msg) => {
throw TypeError(msg);
};
var __export = (target, all) => {

@@ -20,15 +25,47 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __await = function(promise, isYieldStar) {
this[0] = promise;
this[1] = isYieldStar;
};
var __yieldStar = (value) => {
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
if (obj == null) {
obj = value[__knownSymbol("iterator")]();
method = (k) => it[k] = (x) => obj[k](x);
} else {
obj = obj.call(value);
method = (k) => it[k] = (v) => {
if (isAwait) {
isAwait = false;
if (k === "throw") throw v;
return v;
}
isAwait = true;
return {
done: false,
value: new __await(new Promise((resolve) => {
var x = obj[k](v);
if (!(x instanceof Object)) __typeError("Object expected");
resolve(x);
}), 1)
};
};
}
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
throw x;
}, "return" in obj && method("return"), it;
};
// index.ts
var lifecycle_exports = {};
__export(lifecycle_exports, {
var index_exports = {};
__export(index_exports, {
LifeCycle: () => LifeCycle
});
module.exports = __toCommonJS(lifecycle_exports);
module.exports = __toCommonJS(index_exports);
// ../utils/dist/array.js
var { isArray } = Array;
function arrayForEach(array, action, thisArg) {
function arrayForEach(array, action, actionOwner) {
if (arguments.length > 2) {
action = action.bind(thisArg);
action = action.bind(actionOwner);
}

@@ -43,3 +80,3 @@ for (let i = 0, j = array.length; i < j; ++i) {

function arrayRemoveItem(array, itemToRemove) {
var index = arrayIndexOf(array, itemToRemove);
const index = arrayIndexOf(array, itemToRemove);
if (index > 0) {

@@ -53,3 +90,3 @@ array.splice(index, 1);

if (left.length && right.length) {
var failedCompares, l, r, leftItem, rightItem;
let failedCompares, l, r, leftItem, rightItem;
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {

@@ -82,6 +119,6 @@ for (r = 0; rightItem = right[r]; ++r) {

function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) {
var myMin = Math.min, myMax = Math.max, editDistanceMatrix = [], smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
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;
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
lastRow = thisRow;
editDistanceMatrix.push(thisRow = []);
editDistanceMatrix.push(thisRow = new Array());
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);

@@ -97,4 +134,4 @@ bigIndexMinForRow = myMax(0, smlIndex - 1);

} else {
var northDistance = lastRow[bigIndex] || maxDistance;
var westDistance = thisRow[bigIndex - 1] || maxDistance;
const northDistance = lastRow[bigIndex] || maxDistance;
const westDistance = thisRow[bigIndex - 1] || maxDistance;
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;

@@ -104,25 +141,28 @@ }

}
var editScript = [], meMinusOne, notInSml = [], notInBig = [];
let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
notInSml.push(editScript[editScript.length] = {
"status": statusNotInSml,
"value": bigArray[--bigIndex],
"index": bigIndex
});
notInSml.push(
editScript[editScript.length] = {
// added
status: statusNotInSml,
value: bigArray[--bigIndex],
index: bigIndex
}
);
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
notInBig.push(editScript[editScript.length] = {
"status": statusNotInBig,
"value": smlArray[--smlIndex],
"index": smlIndex
});
notInBig.push(
editScript[editScript.length] = {
// deleted
status: statusNotInBig,
value: smlArray[--smlIndex],
index: smlIndex
}
);
} else {
--bigIndex;
--smlIndex;
if (!options2.sparse) {
editScript.push({
"status": "retained",
"value": bigArray[bigIndex]
});
if (!(options2 == null ? void 0 : options2.sparse)) {
editScript.push({ status: "retained", value: bigArray[bigIndex] });
}

@@ -136,36 +176,75 @@ }

// ../utils/dist/options.js
var options = {
deferUpdates: false,
useOnlyNativeEvents: false,
protoProperty: "__ko_proto__",
defaultBindingAttribute: "data-bind",
allowVirtualElements: true,
bindingGlobals: /* @__PURE__ */ Object.create(null),
bindingProviderInstance: null,
createChildContextWithAs: false,
jQuery: globalThis.jQuery,
Promise: globalThis.Promise,
taskScheduler: null,
debug: false,
global: globalThis,
document: globalThis.document,
filters: {},
includeDestroyed: false,
foreachHidesDestroyed: false,
onError: function(e) {
throw e;
},
set: function(name, value) {
options[name] = value;
},
getBindingHandler() {
},
cleanExternalData() {
var Options = class {
constructor() {
this.bindingStringPreparsers = [];
this.knockoutInstance = null;
this.deferUpdates = false;
this.useOnlyNativeEvents = true;
this.useTemplateTag = true;
this.protoProperty = "__ko_proto__";
this.defaultBindingAttribute = "data-bind";
this.allowVirtualElements = true;
this.bindingGlobals = /* @__PURE__ */ Object.create(null);
this.createChildContextWithAs = false;
this.disableJQueryUsage = false;
this.Promise = globalThis.Promise;
this.taskScheduler = null;
this.debug = false;
this.templateSizeLimit = 4096;
this.allowScriptTagsInTemplates = false;
this._sanitizeWarningLogged = false;
this.global = globalThis;
this.document = globalThis.document;
this.filters = {};
this.includeDestroyed = false;
this.foreachHidesDestroyed = false;
}
get jQuery() {
var _a;
if (this.disableJQueryUsage) return;
return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
}
/**
* Set jQuery manuall to be used by TKO.
* @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
*/
set jQuery(jQuery) {
if (!jQuery) {
this.disableJQueryUsage = true;
this._jQuery = void 0;
} else {
this._jQuery = jQuery;
this.disableJQueryUsage = false;
}
}
/**
* Sanitize HTML templates before parsing them. Default is a no-op.
* Please configure something like DOMPurify or validator.js for your environment.
* @param html HTML string to be sanitized
* @returns Sanitized HTML string
*/
sanitizeHtmlTemplate(html) {
if (!this._sanitizeWarningLogged) {
console.warn(
"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
);
this._sanitizeWarningLogged = true;
}
return html;
}
onError(e, throws = true) {
if (throws) throw e;
return e;
}
set(name, value) {
this[name] = value;
}
// Overload getBindingHandler to have a custom lookup function.
getBindingHandler(key) {
return null;
}
cleanExternalData(node, callback) {
}
};
Object.defineProperty(options, "$", {
get: function() {
return options.jQuery;
}
});
var options = new Options();
var options_default = options;

@@ -197,3 +276,3 @@

function throttle(callback, timeout) {
var timeoutInstance;
let timeoutInstance;
return function(...args) {

@@ -209,3 +288,3 @@ if (!timeoutInstance) {

function debounce(callback, timeout) {
var timeoutInstance;
let timeoutInstance;
return function(...args) {

@@ -217,14 +296,2 @@ clearTimeout(timeoutInstance);

// ../utils/dist/ie.js
var ieVersion = options_default.document && function() {
var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
}
if (!version) {
const userAgent = window.navigator.userAgent;
return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
}
return version > 4 ? version : void 0;
}();
// ../utils/dist/object.js

@@ -236,4 +303,5 @@ function hasOwnProperty(obj, propName) {

if (source) {
for (var prop in source) {
for (const prop of Object.keys(source)) {
if (hasOwnProperty(source, prop)) {
;
target[prop] = source[prop];

@@ -246,3 +314,3 @@ }

function objectForEach(obj, action) {
for (var prop in obj) {
for (const prop in obj) {
if (hasOwnProperty(obj, prop)) {

@@ -277,5 +345,2 @@ action(prop, obj[prop]);

// ../utils/dist/jquery.js
var jQueryInstance = options_default.global && options_default.global.jQuery;
// ../utils/dist/dom/info.js

@@ -286,7 +351,7 @@ function domNodeIsContainedBy(node, containedByNode) {

}
if (node.nodeType === 11) {
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
return false;
}
if (containedByNode.contains) {
return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
}

@@ -296,6 +361,7 @@ if (containedByNode.compareDocumentPosition) {

}
while (node && node != containedByNode) {
node = node.parentNode;
let parentNode = node;
while (parentNode && parentNode != containedByNode) {
parentNode = parentNode.parentNode;
}
return !!node;
return !!parentNode;
}

@@ -309,48 +375,40 @@ function domNodeIsAttachedToDocument(node) {

// ../utils/dist/dom/event.js
var knownEvents = {};
var knownEventTypesByEventName = {};
knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
knownEvents["MouseEvents"] = [
"click",
"dblclick",
"mousedown",
"mouseup",
"mousemove",
"mouseover",
"mouseout",
"mouseenter",
"mouseleave"
];
objectForEach(knownEvents, function(eventType, knownEventsForType) {
if (knownEventsForType.length) {
for (let i = 0, j = knownEventsForType.length; i < j; i++) {
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
}
}
});
// ../utils/dist/dom/data.js
var datastoreTime = new Date().getTime();
var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
var dataStoreSymbol = Symbol("Knockout data");
var dataStore;
var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
var uniqueId = 0;
var modern = {
getDataForNode(node, createIfNotFound) {
let dataForNode = node[dataStoreSymbol];
if (!dataForNode && createIfNotFound) {
dataForNode = node[dataStoreSymbol] = {};
}
return dataForNode;
},
clear(node) {
if (node[dataStoreSymbol]) {
delete node[dataStoreSymbol];
return true;
}
return false;
function isSafeKey(key) {
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
}
function getDataForNode(node, createIfNotFound) {
let dataForNode = node[dataStoreSymbol];
if (!dataForNode && createIfNotFound) {
dataForNode = node[dataStoreSymbol] = {};
}
};
var IE = {
getDataforNode(node, createIfNotFound) {
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
if (!hasExistingDataStore) {
if (!createIfNotFound) {
return void 0;
}
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
dataStore[dataStoreKey] = {};
}
return dataStore[dataStoreKey];
},
clear(node) {
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
if (dataStoreKey) {
delete dataStore[dataStoreKey];
node[dataStoreKeyExpandoPropertyName] = null;
return true;
}
return false;
}
};
var { getDataForNode, clear } = ieVersion ? IE : modern;
return dataForNode;
}
function nextKey() {

@@ -360,2 +418,3 @@ return uniqueId++ + dataStoreKeyExpandoPropertyName;

function get(node, key) {
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
const dataForNode = getDataForNode(node, false);

@@ -365,4 +424,11 @@ return dataForNode && dataForNode[key];

function set(node, key, value) {
var dataForNode = getDataForNode(node, value !== void 0);
dataForNode && (dataForNode[key] = value);
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
const dataForNode = getDataForNode(
node,
value !== void 0
/* createIfNotFound */
);
if (dataForNode) {
dataForNode[key] = value;
}
}

@@ -373,5 +439,5 @@

function getDisposeCallbacksCollection(node, createIfNotFound) {
var allDisposeCallbacks = get(node, domDataKey);
let allDisposeCallbacks = get(node, domDataKey);
if (allDisposeCallbacks === void 0 && createIfNotFound) {
allDisposeCallbacks = [];
allDisposeCallbacks = new Array();
set(node, domDataKey, allDisposeCallbacks);

@@ -391,3 +457,3 @@ }

function removeDisposeCallback(node, callback) {
var callbacksCollection = getDisposeCallbacksCollection(node, false);
const callbacksCollection = getDisposeCallbacksCollection(node, false);
if (callbacksCollection) {

@@ -400,5 +466,5 @@ arrayRemoveItem(callbacksCollection, callback);

}
var otherNodeCleanerFunctions = [];
var otherNodeCleanerFunctions = new Array();
function cleanjQueryData(node) {
var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
if (jQueryCleanNodeFn) {

@@ -410,34 +476,7 @@ jQueryCleanNodeFn([node]);

// ../utils/dist/dom/event.js
var knownEvents = {};
var knownEventTypesByEventName = {};
var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
knownEvents["MouseEvents"] = [
"click",
"dblclick",
"mousedown",
"mouseup",
"mousemove",
"mouseover",
"mouseout",
"mouseenter",
"mouseleave"
];
objectForEach(knownEvents, function(eventType, knownEventsForType) {
if (knownEventsForType.length) {
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
}
}
});
// ../utils/dist/dom/virtualElements.js
var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
// ../utils/dist/dom/html.js
var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
// ../utils/dist/dom/selectExtensions.js
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
var selectExtensions = {

@@ -447,3 +486,3 @@ optionValueDomDataKey: nextKey(),

switch (tagNameLower(element)) {
case "option":
case "option": {
if (element[hasDomDataExpandoProperty] === true) {

@@ -453,4 +492,7 @@ return get(element, selectExtensions.optionValueDomDataKey);

return element.value;
case "select":
return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
}
case "select": {
const selectElement = element;
return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
}
default:

@@ -468,27 +510,32 @@ return element.value;

}
;
element.value = value;
} else {
const el = element;
set(element, selectExtensions.optionValueDomDataKey, value);
element[hasDomDataExpandoProperty] = true;
element.value = typeof value === "number" ? value : "";
el[hasDomDataExpandoProperty] = true;
el.value = typeof value === "number" ? value : "";
}
break;
case "select":
if (value === "" || value === null) {
value = void 0;
}
var selection = -1;
for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
optionValue = selectExtensions.readValue(element.options[i]);
const strictEqual = optionValue === value;
const blankEqual = optionValue === "" && value === void 0;
const numericEqual = typeof value === "number" && Number(optionValue) === value;
if (strictEqual || blankEqual || numericEqual) {
selection = i;
break;
{
if (value === "" || value === null) {
value = void 0;
}
let selection = -1;
const selectElement = element;
for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
optionValue = selectExtensions.readValue(selectElement.options[i]);
const strictEqual = optionValue === value;
const blankEqual = optionValue === "" && value === void 0;
const numericEqual = typeof value === "number" && Number(optionValue) === value;
if (strictEqual || blankEqual || numericEqual) {
selection = i;
break;
}
}
if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
selectElement.selectedIndex = selection;
}
}
if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
element.selectedIndex = selection;
}
break;

@@ -499,2 +546,3 @@ default:

}
;
element.value = value;

@@ -514,3 +562,3 @@ break;

});
var taskQueue = [];
var taskQueue = new Array();
var taskQueueLength = 0;

@@ -521,4 +569,4 @@ var nextHandle = 1;

if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
options_default.taskScheduler = function(callback) {
var div = w.document.createElement("div");
options_default.taskScheduler = (function(callback) {
const div = w.document.createElement("div");
new w.MutationObserver(callback).observe(div, { attributes: true });

@@ -528,14 +576,3 @@ return function() {

};
}(scheduledProcess);
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
options_default.taskScheduler = function(callback) {
var script = document.createElement("script");
script.onreadystatechange = function() {
script.onreadystatechange = null;
document.documentElement.removeChild(script);
script = null;
callback();
};
document.documentElement.appendChild(script);
};
})(scheduledProcess);
} else {

@@ -548,4 +585,4 @@ options_default.taskScheduler = function(callback) {

if (taskQueueLength) {
var mark = taskQueueLength, countMarks = 0;
for (var task; nextIndexToProcess < taskQueueLength; ) {
let mark = taskQueueLength, countMarks = 0;
for (let task; nextIndexToProcess < taskQueueLength; ) {
if (task = taskQueue[nextIndexToProcess++]) {

@@ -584,3 +621,3 @@ if (nextIndexToProcess > mark) {

function cancel(handle) {
var index = handle - (nextHandle - taskQueueLength);
const index = handle - (nextHandle - taskQueueLength);
if (index >= nextIndexToProcess && index < taskQueueLength) {

@@ -591,3 +628,3 @@ taskQueue[index] = null;

function resetForTesting() {
var length = taskQueueLength - nextIndexToProcess;
const length = taskQueueLength - nextIndexToProcess;
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;

@@ -611,3 +648,3 @@ return length;

// ../observable/dist/subscribableSymbol.js
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
function isSubscribable(instance) {

@@ -618,3 +655,3 @@ return instance && instance[SUBSCRIBABLE_SYM] || false;

// ../observable/dist/dependencyDetection.js
var outerFrames = [];
var outerFrames = new Array();
var currentFrame;

@@ -637,3 +674,7 @@ var lastId = 0;

}
currentFrame.callback.call(currentFrame.callbackTarget, subscribable2, subscribable2._id || (subscribable2._id = getId()));
currentFrame.callback.call(
currentFrame.callbackTarget,
subscribable2,
subscribable2._id || (subscribable2._id = getId())
);
}

@@ -653,2 +694,3 @@ }

}
return void 0;
}

@@ -659,2 +701,3 @@ function getDependencies() {

}
return void 0;
}

@@ -665,2 +708,3 @@ function isInitial() {

}
return void 0;
}

@@ -712,2 +756,3 @@

}
// TC39 Observable API
unsubscribe() {

@@ -722,17 +767,12 @@ this.dispose();

// ../observable/dist/extenders.js
var primitiveTypes = {
"undefined": 1,
"boolean": 1,
"number": 1,
"string": 1
};
var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
function valuesArePrimitiveAndEqual(a, b) {
var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
return oldValueIsPrimitive ? a === b : false;
}
function applyExtenders(requestedExtenders) {
var target = this;
let target = this;
if (requestedExtenders) {
objectForEach(requestedExtenders, function(key, value) {
var extenderHandler = extenders[key];
const extenderHandler = extenders[key];
if (typeof extenderHandler === "function") {

@@ -752,3 +792,5 @@ target = extenderHandler(target, value) || target;

if (option !== true) {
throw new Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");
throw new Error(
"The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
);
}

@@ -758,3 +800,3 @@ deferUpdates(target);

function rateLimit(target, options2) {
var timeout, method, limitFunction;
let timeout, method, limitFunction;
if (typeof options2 === "number") {

@@ -772,17 +814,13 @@ timeout = options2;

}
var extenders = {
notify,
deferred,
rateLimit
};
var extenders = { notify, deferred, rateLimit };
// ../observable/dist/subscribable.js
var LATEST_VALUE = Symbol("Knockout latest value");
var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
if (!Symbol.observable) {
Symbol.observable = Symbol.for("@tko/Symbol.observable");
Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
}
function subscribable() {
var subscribable = function subscribableFactory() {
Object.setPrototypeOf(this, ko_subscribable_fn);
ko_subscribable_fn.init(this);
}
};
var defaultEvent = "change";

@@ -801,5 +839,3 @@ var ko_subscribable_fn = {

event = event || defaultEvent;
const observer = isTC39Callback ? callback : {
next: callbackTarget ? callback.bind(callbackTarget) : callback
};
const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
const subscriptionInstance = new Subscription(this, observer, () => {

@@ -815,3 +851,3 @@ arrayRemoveItem(this._subscriptions[event], subscriptionInstance);

if (!this._subscriptions[event]) {
this._subscriptions[event] = [];
this._subscriptions[event] = new Array();
}

@@ -859,3 +895,3 @@ this._subscriptions[event].push(subscriptionInstance);

} else {
var total = 0;
let total = 0;
objectForEach(this._subscriptions, function(eventName, subscriptions) {

@@ -915,2 +951,3 @@ if (eventName !== "dirty") {

if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
;
Observable.valueWillMutate();

@@ -936,6 +973,19 @@ Observable[LATEST_VALUE] = arguments[0];

observable.fn = {
/**
* Compares two values for equality.
* @param a The first value.
* @param b The second value.
* @returns True if the values are equal, otherwise false.
*/
equalityComparer: valuesArePrimitiveAndEqual,
/**
* Returns the current value of the observable without creating a dependency.
* @returns The current value.
*/
peek() {
return this[LATEST_VALUE];
},
/**
* Notifies subscribers that the value has changed.
*/
valueHasMutated() {

@@ -945,8 +995,18 @@ this.notifySubscribers(this[LATEST_VALUE], "spectate");

},
/**
* Notifies subscribers that the value is about to change.
*/
valueWillMutate() {
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
},
/**
* Modifies the value of the observable using a function.
* @param fn The function to modify the value.
* @param peek Whether to use the current value without creating a dependency.
* @returns The modified observable.
*/
modify(fn, peek22 = true) {
return this(fn(peek22 ? this.peek() : this()));
this(fn(peek22 ? this.peek() : this()));
},
// Some observables may not always be writeable, notably computeds.
isWriteable: true

@@ -964,6 +1024,6 @@ };

subscribable.fn.limit = function limit(limitFunction) {
var self = this;
var selfIsObservable = isObservable(self);
var beforeChange = "beforeChange";
var ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
const self = this;
const selfIsObservable = isObservable(self);
const beforeChange = "beforeChange";
let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
if (!self._origNotifySubscribers) {

@@ -973,3 +1033,3 @@ self._origNotifySubscribers = self.notifySubscribers;

}
var finish = limitFunction(function() {
const finish = limitFunction(function() {
self._notificationIsPending = false;

@@ -1002,3 +1062,6 @@ if (selfIsObservable && pendingValue === self) {

_notifyNextChangeIfValueIsDifferent() {
if (self.isDifferent(previousValue, self.peek(true))) {
if (self.isDifferent(previousValue, self.peek(
true
/* evaluate */
))) {
notifyNextChange = true;

@@ -1043,4 +1106,4 @@ }

let underlyingNotifySubscribersFunction;
let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
target.beforeSubscriptionAdd = function(event) {

@@ -1082,7 +1145,7 @@ if (underlyingBeforeSubscriptionAddFunction) {

};
var previousContents = [].concat(target.peek() === void 0 ? [] : target.peek());
let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
cachedDiff = null;
arrayChangeSubscription = target.subscribe(function(currentContents) {
let changes;
currentContents = [].concat(currentContents || []);
currentContents = new Array().concat(currentContents || []);
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {

@@ -1109,5 +1172,5 @@ changes = getChanges(previousContents, currentContents);

}
var diff = [], arrayLength = rawArray.length, argsLength = args.length, offset = 0;
let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
function pushDiff(status, value, index) {
return diff[diff.length] = { "status": status, "value": value, "index": index };
return diff[diff.length] = { status, value, index };
}

@@ -1130,12 +1193,14 @@ switch (operationName) {

case "splice":
var startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength), endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength), endAddIndex = startIndex + argsLength - 2, endIndex = Math.max(endDeleteIndex, endAddIndex), additions = [], deletions = [];
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
if (index < endDeleteIndex) {
deletions.push(pushDiff("deleted", rawArray[index], index));
{
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();
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
if (index < endDeleteIndex) {
deletions.push(pushDiff("deleted", rawArray[index], index));
}
if (index < endAddIndex) {
additions.push(pushDiff("added", args[argsIndex], index));
}
}
if (index < endAddIndex) {
additions.push(pushDiff("added", args[argsIndex], index));
}
findMovesInArrayComparison(deletions, additions);
}
findMovesInArrayComparison(deletions, additions);
break;

@@ -1155,8 +1220,12 @@ default:

if (typeof initialValues !== "object" || !("length" in initialValues)) {
throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
throw new Error(
"The argument passed when initializing an observable array must be an array, or null, or undefined."
);
}
var result = observable(initialValues);
Object.setPrototypeOf(result, observableArray.fn);
const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
trackArrayChanges(result);
overwriteLengthPropertyIfSupported(result, { get: () => result().length });
overwriteLengthPropertyIfSupported(result, { get: () => {
var _a;
return (_a = result()) == null ? void 0 : _a.length;
} });
return result;

@@ -1166,9 +1235,9 @@ }

remove(valueOrPredicate) {
var underlyingArray = this.peek();
var removedValues = [];
var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
return value2 === valueOrPredicate;
const underlyingArray = this.peek();
const removedValues = new Array();
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
return value === valueOrPredicate;
};
for (var i = 0; i < underlyingArray.length; i++) {
var value = underlyingArray[i];
for (let i = 0; i < underlyingArray.length; i++) {
const value = underlyingArray[i];
if (predicate(value)) {

@@ -1193,4 +1262,4 @@ if (removedValues.length === 0) {

if (arrayOfValues === void 0) {
var underlyingArray = this.peek();
var allValues = underlyingArray.slice(0);
const underlyingArray = this.peek();
const allValues = underlyingArray.slice(0);
this.valueWillMutate();

@@ -1209,9 +1278,9 @@ underlyingArray.splice(0, underlyingArray.length);

destroy(valueOrPredicate) {
var underlyingArray = this.peek();
var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
return value2 === valueOrPredicate;
const underlyingArray = this.peek();
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value) {
return value === valueOrPredicate;
};
this.valueWillMutate();
for (var i = underlyingArray.length - 1; i >= 0; i--) {
var value = underlyingArray[i];
for (let i = underlyingArray.length - 1; i >= 0; i--) {
const value = underlyingArray[i];
if (predicate(value)) {

@@ -1240,3 +1309,3 @@ value["_destroy"] = true;

replace(oldItem, newItem) {
var index = this.indexOf(oldItem);
const index = this.indexOf(oldItem);
if (index >= 0) {

@@ -1255,3 +1324,3 @@ this.valueWillMutate();

[Symbol.iterator]: function* () {
yield* this();
yield* __yieldStar(this());
}

@@ -1262,6 +1331,6 @@ };

observableArray.fn[methodName] = function() {
var underlyingArray = this.peek();
const underlyingArray = this.peek();
this.valueWillMutate();
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
this.valueHasMutated();

@@ -1273,3 +1342,3 @@ return methodCallResult === underlyingArray ? this : methodCallResult;

observableArray.fn[methodName] = function() {
var underlyingArray = this();
const underlyingArray = this();
return underlyingArray[methodName].apply(underlyingArray, arguments);

@@ -1302,7 +1371,7 @@ };

}
if (typeof options2.read !== "function") {
if (typeof (options2 == null ? void 0 : options2.read) !== "function") {
throw Error("Pass a function that returns the value of the computed");
}
var writeFunction = options2.write;
var state = {
const writeFunction = options2.write;
const state = {
latestValue: void 0,

@@ -1318,4 +1387,4 @@ isStale: true,

evaluatorFunctionTarget: evaluatorFunctionTarget || options2.owner,
disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || options2.disposeWhenNodeIsRemoved || null,
disposeWhen: options2.disposeWhen || options2.disposeWhen,
disposeWhenNodeIsRemoved: options2.disposeWhenNodeIsRemoved || null,
disposeWhen: options2.disposeWhen,
domNodeDisposalCallback: null,

@@ -1331,3 +1400,5 @@ dependencyTracking: {},

} else {
throw new Error("Cannot write a value to a computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
throw new Error(
"Cannot write a value to a computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters."
);
}

@@ -1340,2 +1411,3 @@ return this;

if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
;
computedObservable.evaluateImmediate();

@@ -1370,8 +1442,13 @@ }

if (!state.isSleeping && !options2.deferEvaluation) {
;
computedObservable.evaluateImmediate();
}
if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function() {
computedObservable.dispose();
});
addDisposeCallback(
state.disposeWhenNodeIsRemoved,
state.domNodeDisposalCallback = function() {
;
computedObservable.dispose();
}
);
}

@@ -1386,3 +1463,3 @@ return computedObservable;

function computedBeginDependencyDetectionCallback(subscribable2, id) {
var computedObservable = this.computedObservable, state = computedObservable[computedState];
const computedObservable = this.computedObservable, state = computedObservable[computedState];
if (!state.isDisposed) {

@@ -1394,3 +1471,7 @@ if (this.disposalCount && this.disposalCandidates[id]) {

} else if (!state.dependencyTracking[id]) {
computedObservable.addDependencyTracking(id, subscribable2, state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2));
computedObservable.addDependencyTracking(
id,
subscribable2,
state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
);
}

@@ -1409,3 +1490,3 @@ if (subscribable2._notificationIsPending) {

const dependencyTracking = this[computedState].dependencyTracking;
const dependentObservables = [];
const dependentObservables = new Array();
objectForEach(dependencyTracking, function(id, dependency) {

@@ -1425,3 +1506,3 @@ dependentObservables[dependency._order] = dependency._target;

haveDependenciesChanged() {
var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
for (id in dependencyTracking) {

@@ -1435,6 +1516,10 @@ if (hasOwnProperty(dependencyTracking, id)) {

}
return false;
},
markDirty() {
if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
this._evalDelayed(false);
this._evalDelayed(
false
/* notifyChange */
);
}

@@ -1455,3 +1540,3 @@ },

if (target._deferUpdates) {
var dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
return {

@@ -1469,16 +1554,25 @@ _target: target,

evaluatePossiblyAsync() {
var computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
clearTimeout(this[computedState].evaluationTimeoutInstance);
this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
computedObservable.evaluateImmediate(true);
computedObservable.evaluateImmediate(
true
/* notifyChange */
);
}, throttleEvaluationTimeout);
} else if (computedObservable._evalDelayed) {
computedObservable._evalDelayed(true);
computedObservable._evalDelayed(
true
/* notifyChange */
);
} else {
computedObservable.evaluateImmediate(true);
computedObservable.evaluateImmediate(
true
/* notifyChange */
);
}
},
evaluateImmediate(notifyChange) {
var computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
if (state.isBeingEvaluated) {

@@ -1507,4 +1601,4 @@ return;

evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
var computedObservable = this, state = computedObservable[computedState], changed = false;
var isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
let computedObservable = this, state = computedObservable[computedState], changed = false;
const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
computedObservable,

@@ -1522,3 +1616,3 @@ disposalCandidates: state.dependencyTracking,

state.dependenciesCount = 0;
var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
if (!state.dependenciesCount) {

@@ -1555,3 +1649,3 @@ computedObservable.dispose();

try {
var readFunction = state.readFunction;
const readFunction = state.readFunction;
return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();

@@ -1596,3 +1690,7 @@ } finally {

}
this._limitChange(this, !isChange);
this._limitChange(
this,
!isChange
/* isDirty */
);
}

@@ -1602,3 +1700,3 @@ });

dispose() {
var state = this[computedState];
const state = this[computedState];
if (!state.isSleeping && state.dependencyTracking) {

@@ -1619,3 +1717,3 @@ objectForEach(state.dependencyTracking, function(id, dependency) {

beforeSubscriptionAdd(event) {
var computedObservable = this, state = computedObservable[computedState];
const computedObservable = this, state = computedObservable[computedState];
if (!state.isDisposed && state.isSleeping && event === "change") {

@@ -1630,3 +1728,3 @@ state.isSleeping = false;

} else {
var dependenciesOrder = [];
const dependenciesOrder = new Array();
objectForEach(state.dependencyTracking, function(id, dependency) {

@@ -1636,3 +1734,3 @@ dependenciesOrder[dependency._order] = id;

arrayForEach(dependenciesOrder, function(id, order) {
var dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
subscription._order = order;

@@ -1654,3 +1752,3 @@ subscription._version = dependency._version;

afterSubscriptionRemove(event) {
var state = this[computedState];
const state = this[computedState];
if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {

@@ -1672,3 +1770,3 @@ objectForEach(state.dependencyTracking, function(id, dependency) {

getVersion() {
var state = this[computedState];
const state = this[computedState];
if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {

@@ -1695,3 +1793,3 @@ this.evaluateImmediate();

target.throttleEvaluation = timeout;
var writeTimeoutInstance = null;
let writeTimeoutInstance = void 0;
return computed({

@@ -1707,7 +1805,8 @@ read: target,

}
extenders.throttle = throttleExtender;
var extenders2 = extenders;
extenders2.throttle = throttleExtender;
// ../computed/dist/proxy.js
var PROXY_SYM = Symbol("Knockout Proxied Object");
var MIRROR_SYM = Symbol("Knockout Proxied Observables");
var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
function makeComputed(proxy2, fn) {

@@ -1779,6 +1878,3 @@ return computed({

ownKeys() {
return [
...Object.getOwnPropertyNames(object),
...Object.getOwnPropertySymbols(object)
];
return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
}

@@ -1803,7 +1899,14 @@ });

var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
var LifeCycle = class {
var LifeCycle = class _LifeCycle {
// NOTE: For more advanced integration as an ES6 mixin, see e.g.:
// http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
/**
* Copy the properties of the LifeCycle class to the target (or its prototype)
*
* NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
*/
static mixInto(Constructor) {
const target = Constructor.prototype || Constructor;
const mixin = LifeCycle.prototype;
for (let prop of Object.getOwnPropertyNames(mixin)) {
const mixin = _LifeCycle.prototype;
for (const prop of Object.getOwnPropertyNames(mixin)) {
target[prop] = mixin[prop];

@@ -1836,2 +1939,9 @@ }

}
/**
* Add an event listener for the given or anchored node.
* @param {node} [node] (optional) The target node (otherwise the anchored node)
* @param {string} [type] Event type
* @param {function|string} [action] Either call the given function or `this[action]`
* @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
*/
addEventListener(...args) {

@@ -1863,3 +1973,3 @@ const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];

subscriptions.forEach((s) => s.dispose());
this[SUBSCRIPTIONS] = [];
this[SUBSCRIPTIONS] = new Array();
this[ANCHOR_NODE] = null;

@@ -1866,0 +1976,0 @@ }

@@ -1,2 +0,3 @@

// @tko/lifecycle 🥊 4.0.0-beta1.3 ESM
// @tko/lifecycle 🥊 4.0.0 ESM
"use strict";
export { default as LifeCycle } from "./LifeCycle";
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["\nexport {default as LifeCycle} from './LifeCycle'\n"],
"mappings": ";AACA;",
"sourcesContent": ["export { default as LifeCycle } from './LifeCycle'\n"],
"mappings": ";;AAAA,SAAS,WAAW,iBAAiB;",
"names": []
}

@@ -1,2 +0,3 @@

// @tko/lifecycle 🥊 4.0.0-beta1.3 MJS
// @tko/lifecycle 🥊 4.0.0 MJS
"use strict";
export { default as LifeCycle } from "./LifeCycle";
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["\nexport {default as LifeCycle} from './LifeCycle'\n"],
"mappings": ";AACA;",
"sourcesContent": ["export { default as LifeCycle } from './LifeCycle'\n"],
"mappings": ";;AAAA,SAAS,WAAW,iBAAiB;",
"names": []
}

@@ -0,17 +1,19 @@

// @tko/lifecycle 🥊 4.0.0 ESM
"use strict";
// @tko/lifecycle 🥊 4.0.0-beta1.3 ESM
import {
addDisposeCallback,
createSymbolOrString
} from "@tko/utils";
import {
computed
} from "@tko/computed";
import { addDisposeCallback, createSymbolOrString } from "@tko/utils";
import { computed } from "@tko/computed";
const SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
const ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
export default class LifeCycle {
// NOTE: For more advanced integration as an ES6 mixin, see e.g.:
// http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
/**
* Copy the properties of the LifeCycle class to the target (or its prototype)
*
* NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
*/
static mixInto(Constructor) {
const target = Constructor.prototype || Constructor;
const mixin = LifeCycle.prototype;
for (let prop of Object.getOwnPropertyNames(mixin)) {
for (const prop of Object.getOwnPropertyNames(mixin)) {
target[prop] = mixin[prop];

@@ -44,2 +46,9 @@ }

}
/**
* Add an event listener for the given or anchored node.
* @param {node} [node] (optional) The target node (otherwise the anchored node)
* @param {string} [type] Event type
* @param {function|string} [action] Either call the given function or `this[action]`
* @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
*/
addEventListener(...args) {

@@ -71,3 +80,3 @@ const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];

subscriptions.forEach((s) => s.dispose());
this[SUBSCRIPTIONS] = [];
this[SUBSCRIPTIONS] = new Array();
this[ANCHOR_NODE] = null;

@@ -74,0 +83,0 @@ }

{
"version": 3,
"sources": ["../src/LifeCycle.ts"],
"sourcesContent": ["'use strict'\n\nimport {\n addDisposeCallback, createSymbolOrString\n} from '@tko/utils'\n\nimport {\n computed\n} from '@tko/computed'\n\nconst SUBSCRIPTIONS = createSymbolOrString('LifeCycle Subscriptions List')\nconst ANCHOR_NODE = createSymbolOrString('LifeCycle Anchor Node')\n\nexport default class LifeCycle {\n // NOTE: For more advanced integration as an ES6 mixin, see e.g.:\n // http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/\n\n /**\n * Copy the properties of the LifeCycle class to the target (or its prototype)\n *\n * NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.\n */\n static mixInto (Constructor) {\n const target = Constructor.prototype || Constructor\n const mixin = LifeCycle.prototype\n for (let prop of Object.getOwnPropertyNames(mixin)) {\n target[prop] = mixin[prop]\n }\n }\n\n subscribe (observable, action, subscriptionType) {\n if (typeof action === 'string') { action = this[action] }\n this.addDisposable(observable.subscribe(action, this, subscriptionType))\n }\n\n computed (params) {\n if (typeof params === 'string') {\n params = { read: this[params], write: this[params] }\n }\n\n if (typeof params === 'object') {\n params = Object.assign({ owner: this }, params)\n } else if (typeof params === 'function') {\n const proto = Object.getPrototypeOf(this)\n if (proto && proto[params.name] === params) { params = params.bind(this) }\n params = { read: params, write: params }\n } else {\n throw new Error('LifeCycle::computed not given a valid type.')\n }\n\n params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE]\n return this.addDisposable(computed(params))\n }\n\n /**\n * Add an event listener for the given or anchored node.\n * @param {node} [node] (optional) The target node (otherwise the anchored node)\n * @param {string} [type] Event type\n * @param {function|string} [action] Either call the given function or `this[action]`\n * @param {object} [options] (optional) Passed as `options` to `node.addEventListener`\n */\n addEventListener (...args) {\n const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE]\n const [type, act, options] = args\n const handler = typeof act === 'string' ? this[act].bind(this) : act\n this.__addEventListener(node, type, handler, options)\n }\n\n __addEventListener (node, eventType, handler, options) {\n node.addEventListener(eventType, handler, options)\n function dispose () { node.removeEventListener(eventType, handler) }\n addDisposeCallback(node, dispose)\n this.addDisposable({ dispose })\n }\n\n anchorTo (nodeOrLifeCycle) {\n if ('addDisposable' in nodeOrLifeCycle) {\n nodeOrLifeCycle.addDisposable(this)\n this[ANCHOR_NODE] = null // re-anchor on `anchorTo` calls\n } else {\n this[ANCHOR_NODE] = nodeOrLifeCycle\n addDisposeCallback(nodeOrLifeCycle, () => this[ANCHOR_NODE] === nodeOrLifeCycle && this.dispose())\n }\n }\n\n dispose () {\n const subscriptions = this[SUBSCRIPTIONS] || []\n subscriptions.forEach(s => s.dispose())\n this[SUBSCRIPTIONS] = []\n this[ANCHOR_NODE] = null\n }\n\n addDisposable (subscription) {\n const subscriptions = this[SUBSCRIPTIONS] || []\n if (!this[SUBSCRIPTIONS]) { this[SUBSCRIPTIONS] = subscriptions }\n if (typeof subscription.dispose !== 'function') {\n throw new Error('Lifecycle::addDisposable argument missing `dispose`.')\n }\n subscriptions.push(subscription)\n return subscription\n }\n}\n"],
"mappings": ";;AAEA;AAAA;AAAA;AAAA;AAIA;AAAA;AAAA;AAIA,MAAM,gBAAgB,qBAAqB,8BAA8B;AACzE,MAAM,cAAc,qBAAqB,uBAAuB;AAEhE,qBAAqB,UAAU;AAAA,SAStB,QAAS,aAAa;AAC3B,UAAM,SAAS,YAAY,aAAa;AACxC,UAAM,QAAQ,UAAU;AACxB,aAAS,QAAQ,OAAO,oBAAoB,KAAK,GAAG;AAClD,aAAO,QAAQ,MAAM;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,UAAW,YAAY,QAAQ,kBAAkB;AAC/C,QAAI,OAAO,WAAW,UAAU;AAAE,eAAS,KAAK;AAAA,IAAQ;AACxD,SAAK,cAAc,WAAW,UAAU,QAAQ,MAAM,gBAAgB,CAAC;AAAA,EACzE;AAAA,EAEA,SAAU,QAAQ;AAChB,QAAI,OAAO,WAAW,UAAU;AAC9B,eAAS,EAAE,MAAM,KAAK,SAAS,OAAO,KAAK,QAAQ;AAAA,IACrD;AAEA,QAAI,OAAO,WAAW,UAAU;AAC9B,eAAS,OAAO,OAAO,EAAE,OAAO,KAAK,GAAG,MAAM;AAAA,IAChD,WAAW,OAAO,WAAW,YAAY;AACvC,YAAM,QAAQ,OAAO,eAAe,IAAI;AACxC,UAAI,SAAS,MAAM,OAAO,UAAU,QAAQ;AAAE,iBAAS,OAAO,KAAK,IAAI;AAAA,MAAE;AACzE,eAAS,EAAE,MAAM,QAAQ,OAAO,OAAO;AAAA,IACzC,OAAO;AACL,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AAEA,WAAO,2BAA2B,KAAK;AACvC,WAAO,KAAK,cAAc,SAAS,MAAM,CAAC;AAAA,EAC5C;AAAA,EASA,oBAAqB,MAAM;AACzB,UAAM,OAAO,KAAK,GAAG,WAAW,KAAK,MAAM,IAAI,KAAK;AACpD,UAAM,CAAC,MAAM,KAAK,WAAW;AAC7B,UAAM,UAAU,OAAO,QAAQ,WAAW,KAAK,KAAK,KAAK,IAAI,IAAI;AACjE,SAAK,mBAAmB,MAAM,MAAM,SAAS,OAAO;AAAA,EACtD;AAAA,EAEA,mBAAoB,MAAM,WAAW,SAAS,SAAS;AACrD,SAAK,iBAAiB,WAAW,SAAS,OAAO;AACjD,uBAAoB;AAAE,WAAK,oBAAoB,WAAW,OAAO;AAAA,IAAE;AACnE,uBAAmB,MAAM,OAAO;AAChC,SAAK,cAAc,EAAE,QAAQ,CAAC;AAAA,EAChC;AAAA,EAEA,SAAU,iBAAiB;AACzB,QAAI,mBAAmB,iBAAiB;AACtC,sBAAgB,cAAc,IAAI;AAClC,WAAK,eAAe;AAAA,IACtB,OAAO;AACL,WAAK,eAAe;AACpB,yBAAmB,iBAAiB,MAAM,KAAK,iBAAiB,mBAAmB,KAAK,QAAQ,CAAC;AAAA,IACnG;AAAA,EACF;AAAA,EAEA,UAAW;AACT,UAAM,gBAAgB,KAAK,kBAAkB,CAAC;AAC9C,kBAAc,QAAQ,OAAK,EAAE,QAAQ,CAAC;AACtC,SAAK,iBAAiB,CAAC;AACvB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,cAAe,cAAc;AAC3B,UAAM,gBAAgB,KAAK,kBAAkB,CAAC;AAC9C,QAAI,CAAC,KAAK,gBAAgB;AAAE,WAAK,iBAAiB;AAAA,IAAc;AAChE,QAAI,OAAO,aAAa,YAAY,YAAY;AAC9C,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AACA,kBAAc,KAAK,YAAY;AAC/B,WAAO;AAAA,EACT;AACF;",
"sourcesContent": ["'use strict'\n\nimport { addDisposeCallback, createSymbolOrString } from '@tko/utils'\n\nimport { computed } from '@tko/computed'\n\nconst SUBSCRIPTIONS = createSymbolOrString('LifeCycle Subscriptions List')\nconst ANCHOR_NODE = createSymbolOrString('LifeCycle Anchor Node')\n\nexport default class LifeCycle {\n // NOTE: For more advanced integration as an ES6 mixin, see e.g.:\n // http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/\n\n /**\n * Copy the properties of the LifeCycle class to the target (or its prototype)\n *\n * NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.\n */\n static mixInto(Constructor) {\n const target = Constructor.prototype || Constructor\n const mixin = LifeCycle.prototype\n for (const prop of Object.getOwnPropertyNames(mixin)) {\n target[prop] = mixin[prop]\n }\n }\n\n subscribe(observable, action, subscriptionType) {\n if (typeof action === 'string') {\n action = this[action]\n }\n this.addDisposable(observable.subscribe(action, this, subscriptionType))\n }\n\n computed(params) {\n if (typeof params === 'string') {\n params = { read: this[params], write: this[params] }\n }\n\n if (typeof params === 'object') {\n params = Object.assign({ owner: this }, params)\n } else if (typeof params === 'function') {\n const proto = Object.getPrototypeOf(this)\n if (proto && proto[params.name] === params) {\n params = params.bind(this)\n }\n params = { read: params, write: params }\n } else {\n throw new Error('LifeCycle::computed not given a valid type.')\n }\n\n params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE]\n return this.addDisposable(computed(params))\n }\n\n /**\n * Add an event listener for the given or anchored node.\n * @param {node} [node] (optional) The target node (otherwise the anchored node)\n * @param {string} [type] Event type\n * @param {function|string} [action] Either call the given function or `this[action]`\n * @param {object} [options] (optional) Passed as `options` to `node.addEventListener`\n */\n addEventListener(...args) {\n const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE]\n const [type, act, options] = args\n const handler = typeof act === 'string' ? this[act].bind(this) : act\n this.__addEventListener(node, type, handler, options)\n }\n\n __addEventListener(node, eventType, handler, options) {\n node.addEventListener(eventType, handler, options)\n function dispose() {\n node.removeEventListener(eventType, handler)\n }\n addDisposeCallback(node, dispose)\n this.addDisposable({ dispose })\n }\n\n anchorTo(nodeOrLifeCycle: Node | LifeCycle) {\n if ('addDisposable' in nodeOrLifeCycle) {\n nodeOrLifeCycle.addDisposable(this)\n this[ANCHOR_NODE] = null // re-anchor on `anchorTo` calls\n } else {\n this[ANCHOR_NODE] = nodeOrLifeCycle\n addDisposeCallback(nodeOrLifeCycle, () => this[ANCHOR_NODE] === nodeOrLifeCycle && this.dispose())\n }\n }\n\n dispose() {\n const subscriptions = this[SUBSCRIPTIONS] || []\n subscriptions.forEach(s => s.dispose())\n this[SUBSCRIPTIONS] = new Array()\n this[ANCHOR_NODE] = null\n }\n\n addDisposable(subscription) {\n const subscriptions = this[SUBSCRIPTIONS] || []\n if (!this[SUBSCRIPTIONS]) {\n this[SUBSCRIPTIONS] = subscriptions\n }\n if (typeof subscription.dispose !== 'function') {\n throw new Error('Lifecycle::addDisposable argument missing `dispose`.')\n }\n subscriptions.push(subscription)\n return subscription\n }\n}\n"],
"mappings": ";;AAEA,SAAS,oBAAoB,4BAA4B;AAEzD,SAAS,gBAAgB;AAEzB,MAAM,gBAAgB,qBAAqB,8BAA8B;AACzE,MAAM,cAAc,qBAAqB,uBAAuB;AAEhE,qBAAqB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7B,OAAO,QAAQ,aAAa;AAC1B,UAAM,SAAS,YAAY,aAAa;AACxC,UAAM,QAAQ,UAAU;AACxB,eAAW,QAAQ,OAAO,oBAAoB,KAAK,GAAG;AACpD,aAAO,IAAI,IAAI,MAAM,IAAI;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,UAAU,YAAY,QAAQ,kBAAkB;AAC9C,QAAI,OAAO,WAAW,UAAU;AAC9B,eAAS,KAAK,MAAM;AAAA,IACtB;AACA,SAAK,cAAc,WAAW,UAAU,QAAQ,MAAM,gBAAgB,CAAC;AAAA,EACzE;AAAA,EAEA,SAAS,QAAQ;AACf,QAAI,OAAO,WAAW,UAAU;AAC9B,eAAS,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,KAAK,MAAM,EAAE;AAAA,IACrD;AAEA,QAAI,OAAO,WAAW,UAAU;AAC9B,eAAS,OAAO,OAAO,EAAE,OAAO,KAAK,GAAG,MAAM;AAAA,IAChD,WAAW,OAAO,WAAW,YAAY;AACvC,YAAM,QAAQ,OAAO,eAAe,IAAI;AACxC,UAAI,SAAS,MAAM,OAAO,IAAI,MAAM,QAAQ;AAC1C,iBAAS,OAAO,KAAK,IAAI;AAAA,MAC3B;AACA,eAAS,EAAE,MAAM,QAAQ,OAAO,OAAO;AAAA,IACzC,OAAO;AACL,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AAEA,WAAO,2BAA2B,KAAK,WAAW;AAClD,WAAO,KAAK,cAAc,SAAS,MAAM,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,oBAAoB,MAAM;AACxB,UAAM,OAAO,KAAK,CAAC,EAAE,WAAW,KAAK,MAAM,IAAI,KAAK,WAAW;AAC/D,UAAM,CAAC,MAAM,KAAK,OAAO,IAAI;AAC7B,UAAM,UAAU,OAAO,QAAQ,WAAW,KAAK,GAAG,EAAE,KAAK,IAAI,IAAI;AACjE,SAAK,mBAAmB,MAAM,MAAM,SAAS,OAAO;AAAA,EACtD;AAAA,EAEA,mBAAmB,MAAM,WAAW,SAAS,SAAS;AACpD,SAAK,iBAAiB,WAAW,SAAS,OAAO;AACjD,aAAS,UAAU;AACjB,WAAK,oBAAoB,WAAW,OAAO;AAAA,IAC7C;AACA,uBAAmB,MAAM,OAAO;AAChC,SAAK,cAAc,EAAE,QAAQ,CAAC;AAAA,EAChC;AAAA,EAEA,SAAS,iBAAmC;AAC1C,QAAI,mBAAmB,iBAAiB;AACtC,sBAAgB,cAAc,IAAI;AAClC,WAAK,WAAW,IAAI;AAAA,IACtB,OAAO;AACL,WAAK,WAAW,IAAI;AACpB,yBAAmB,iBAAiB,MAAM,KAAK,WAAW,MAAM,mBAAmB,KAAK,QAAQ,CAAC;AAAA,IACnG;AAAA,EACF;AAAA,EAEA,UAAU;AACR,UAAM,gBAAgB,KAAK,aAAa,KAAK,CAAC;AAC9C,kBAAc,QAAQ,OAAK,EAAE,QAAQ,CAAC;AACtC,SAAK,aAAa,IAAI,IAAI,MAAM;AAChC,SAAK,WAAW,IAAI;AAAA,EACtB;AAAA,EAEA,cAAc,cAAc;AAC1B,UAAM,gBAAgB,KAAK,aAAa,KAAK,CAAC;AAC9C,QAAI,CAAC,KAAK,aAAa,GAAG;AACxB,WAAK,aAAa,IAAI;AAAA,IACxB;AACA,QAAI,OAAO,aAAa,YAAY,YAAY;AAC9C,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AACA,kBAAc,KAAK,YAAY;AAC/B,WAAO;AAAA,EACT;AACF;",
"names": []
}
{
"version": "4.0.0-beta1.3",
"version": "4.0.0",
"module": "dist/lifecycle.js",
"dependencies": {
"@tko/computed": "^4.0.0-beta1.3",
"@tko/utils": "^4.0.0-beta1.3",
"@tko/computed": "^4.0.0",
"@tko/utils": "^4.0.0",
"tslib": "^2.2.0"
},
"peerDependencies": {
"@tko/observable": "^4.0.0-alpha8.0"
"@tko/observable": "^4.0.0"
},

@@ -46,4 +46,3 @@ "files": [

"url": "https://github.com/knockout/tko/issues"
},
"gitHead": "a8843acb8ae085915115e53a4e057b30731c635e"
}
}
The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php
Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors
http://knockoutjs.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Sorry, the diff of this file is too big to display