@tko/provider.multi
Advanced tools
+388
-287
@@ -1,2 +0,3 @@ | ||
| // @tko/provider.multi 🥊 4.0.0-beta1.3 CommonJS | ||
| // @tko/provider.multi 🥊 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 provider_exports = {}; | ||
| __export(provider_exports, { | ||
| var index_exports = {}; | ||
| __export(index_exports, { | ||
| MultiProvider: () => MultiProvider | ||
| }); | ||
| module.exports = __toCommonJS(provider_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)) { | ||
@@ -260,4 +328,4 @@ action(prop, obj[prop]); | ||
| } | ||
| var target = {}; | ||
| for (var prop in source) { | ||
| const target = {}; | ||
| for (const prop in source) { | ||
| if (hasOwnProperty(source, prop)) { | ||
@@ -287,5 +355,2 @@ target[prop] = mapping(source[prop], prop, source); | ||
| // ../utils/dist/jquery.js | ||
| var jQueryInstance = options_default.global && options_default.global.jQuery; | ||
| // ../utils/dist/dom/info.js | ||
@@ -296,48 +361,40 @@ function tagNameLower(element) { | ||
| // ../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() { | ||
@@ -347,2 +404,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); | ||
@@ -352,4 +410,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; | ||
| } | ||
| } | ||
@@ -360,5 +425,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); | ||
@@ -378,3 +443,3 @@ } | ||
| function removeDisposeCallback(node, callback) { | ||
| var callbacksCollection = getDisposeCallbacksCollection(node, false); | ||
| const callbacksCollection = getDisposeCallbacksCollection(node, false); | ||
| if (callbacksCollection) { | ||
@@ -387,5 +452,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) { | ||
@@ -397,34 +462,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 = { | ||
@@ -434,3 +472,3 @@ optionValueDomDataKey: nextKey(), | ||
| switch (tagNameLower(element)) { | ||
| case "option": | ||
| case "option": { | ||
| if (element[hasDomDataExpandoProperty] === true) { | ||
@@ -440,4 +478,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: | ||
@@ -455,27 +496,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; | ||
@@ -486,2 +532,3 @@ default: | ||
| } | ||
| ; | ||
| element.value = value; | ||
@@ -501,3 +548,3 @@ break; | ||
| }); | ||
| var taskQueue = []; | ||
| var taskQueue = new Array(); | ||
| var taskQueueLength = 0; | ||
@@ -508,4 +555,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 }); | ||
@@ -515,14 +562,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 { | ||
@@ -535,4 +571,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++]) { | ||
@@ -571,3 +607,3 @@ if (nextIndexToProcess > mark) { | ||
| function cancel(handle) { | ||
| var index = handle - (nextHandle - taskQueueLength); | ||
| const index = handle - (nextHandle - taskQueueLength); | ||
| if (index >= nextIndexToProcess && index < taskQueueLength) { | ||
@@ -578,3 +614,3 @@ taskQueue[index] = null; | ||
| function resetForTesting() { | ||
| var length = taskQueueLength - nextIndexToProcess; | ||
| const length = taskQueueLength - nextIndexToProcess; | ||
| nextIndexToProcess = taskQueueLength = taskQueue.length = 0; | ||
@@ -598,3 +634,3 @@ return length; | ||
| // ../observable/dist/subscribableSymbol.js | ||
| var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable"); | ||
| var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable"); | ||
| function isSubscribable(instance) { | ||
@@ -605,3 +641,3 @@ return instance && instance[SUBSCRIBABLE_SYM] || false; | ||
| // ../observable/dist/dependencyDetection.js | ||
| var outerFrames = []; | ||
| var outerFrames = new Array(); | ||
| var currentFrame; | ||
@@ -624,3 +660,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()) | ||
| ); | ||
| } | ||
@@ -640,2 +680,3 @@ } | ||
| } | ||
| return void 0; | ||
| } | ||
@@ -646,2 +687,3 @@ function getDependencies() { | ||
| } | ||
| return void 0; | ||
| } | ||
@@ -652,2 +694,3 @@ function isInitial() { | ||
| } | ||
| return void 0; | ||
| } | ||
@@ -699,2 +742,3 @@ | ||
| } | ||
| // TC39 Observable API | ||
| unsubscribe() { | ||
@@ -709,17 +753,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") { | ||
@@ -739,3 +778,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." | ||
| ); | ||
| } | ||
@@ -745,3 +786,3 @@ deferUpdates(target); | ||
| function rateLimit(target, options2) { | ||
| var timeout, method, limitFunction; | ||
| let timeout, method, limitFunction; | ||
| if (typeof options2 === "number") { | ||
@@ -759,17 +800,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"; | ||
@@ -788,5 +825,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, () => { | ||
@@ -802,3 +837,3 @@ arrayRemoveItem(this._subscriptions[event], subscriptionInstance); | ||
| if (!this._subscriptions[event]) { | ||
| this._subscriptions[event] = []; | ||
| this._subscriptions[event] = new Array(); | ||
| } | ||
@@ -846,3 +881,3 @@ this._subscriptions[event].push(subscriptionInstance); | ||
| } else { | ||
| var total = 0; | ||
| let total = 0; | ||
| objectForEach(this._subscriptions, function(eventName, subscriptions) { | ||
@@ -902,2 +937,3 @@ if (eventName !== "dirty") { | ||
| if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) { | ||
| ; | ||
| Observable.valueWillMutate(); | ||
@@ -923,6 +959,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() { | ||
@@ -932,8 +981,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, peek2 = true) { | ||
| return this(fn(peek2 ? this.peek() : this())); | ||
| this(fn(peek2 ? this.peek() : this())); | ||
| }, | ||
| // Some observables may not always be writeable, notably computeds. | ||
| isWriteable: true | ||
@@ -951,6 +1010,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) { | ||
@@ -960,3 +1019,3 @@ self._origNotifySubscribers = self.notifySubscribers; | ||
| } | ||
| var finish = limitFunction(function() { | ||
| const finish = limitFunction(function() { | ||
| self._notificationIsPending = false; | ||
@@ -989,3 +1048,6 @@ if (selfIsObservable && pendingValue === self) { | ||
| _notifyNextChangeIfValueIsDifferent() { | ||
| if (self.isDifferent(previousValue, self.peek(true))) { | ||
| if (self.isDifferent(previousValue, self.peek( | ||
| true | ||
| /* evaluate */ | ||
| ))) { | ||
| notifyNextChange = true; | ||
@@ -1027,4 +1089,4 @@ } | ||
| let underlyingNotifySubscribersFunction; | ||
| let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd; | ||
| let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove; | ||
| const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd; | ||
| const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove; | ||
| target.beforeSubscriptionAdd = function(event) { | ||
@@ -1066,7 +1128,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)) { | ||
@@ -1093,5 +1155,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 }; | ||
| } | ||
@@ -1114,12 +1176,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; | ||
@@ -1139,8 +1203,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; | ||
@@ -1150,9 +1218,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)) { | ||
@@ -1177,4 +1245,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(); | ||
@@ -1193,9 +1261,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)) { | ||
@@ -1224,3 +1292,3 @@ value["_destroy"] = true; | ||
| replace(oldItem, newItem) { | ||
| var index = this.indexOf(oldItem); | ||
| const index = this.indexOf(oldItem); | ||
| if (index >= 0) { | ||
@@ -1239,3 +1307,3 @@ this.valueWillMutate(); | ||
| [Symbol.iterator]: function* () { | ||
| yield* this(); | ||
| yield* __yieldStar(this()); | ||
| } | ||
@@ -1246,6 +1314,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(); | ||
@@ -1257,3 +1325,3 @@ return methodCallResult === underlyingArray ? this : methodCallResult; | ||
| observableArray.fn[methodName] = function() { | ||
| var underlyingArray = this(); | ||
| const underlyingArray = this(); | ||
| return underlyingArray[methodName].apply(underlyingArray, arguments); | ||
@@ -1271,3 +1339,7 @@ }; | ||
| if (value !== void 0) { | ||
| options_default.onError(new Error("Given extraneous `value` parameter (first param should be a string, but it was an object)." + nameOrObject)); | ||
| options_default.onError( | ||
| new Error( | ||
| "Given extraneous `value` parameter (first param should be a string, but it was an object)." + nameOrObject | ||
| ) | ||
| ); | ||
| } | ||
@@ -1279,2 +1351,6 @@ Object.assign(this, nameOrObject); | ||
| } | ||
| /** | ||
| * The handler may have a `.` in it, e.g. `attr.title`, in which case the | ||
| * handler is `attr`. Otherwise it's the name given | ||
| */ | ||
| get(nameOrDotted) { | ||
@@ -1287,5 +1363,5 @@ const [name] = nameOrDotted.split("."); | ||
| // ../provider/dist/Provider.js | ||
| var Provider = class { | ||
| constructor(params = {}) { | ||
| if (this.constructor === Provider) { | ||
| var Provider = class _Provider { | ||
| constructor(params) { | ||
| if (this.constructor === _Provider) { | ||
| throw new Error("Provider is an abstract base class."); | ||
@@ -1296,5 +1372,8 @@ } | ||
| } | ||
| this.bindingHandlers = params.bindingHandlers || new BindingHandlerObject(); | ||
| this.globals = params.globals || {}; | ||
| this.bindingHandlers = (params == null ? void 0 : params.bindingHandlers) || new BindingHandlerObject(); | ||
| this.globals = (params == null ? void 0 : params.globals) || {}; | ||
| } | ||
| get FOR_NODE_TYPES() { | ||
| throw new Error("Providers must override FOR_NODE_TYPES property"); | ||
| } | ||
| setGlobals(globals) { | ||
@@ -1306,10 +1385,20 @@ this.globals = globals; | ||
| } | ||
| nodeHasBindings() { | ||
| nodeHasBindings(node, context) { | ||
| return false; | ||
| } | ||
| getBindingAccessors() { | ||
| getBindingAccessors(node, context) { | ||
| return /* @__PURE__ */ Object.create(null); | ||
| } | ||
| /** | ||
| * Preprocess a given node. | ||
| * @param {Node} node | ||
| * @returns {[Node]|null} | ||
| */ | ||
| preprocessNode(node) { | ||
| return [node]; | ||
| } | ||
| postProcess() { | ||
| } | ||
| /** For legacy binding provider assignments to | ||
| * ko.bindingProvider.instance = ... */ | ||
| get instance() { | ||
@@ -1325,8 +1414,15 @@ return this._overloadInstance || this; | ||
| } | ||
| // Given a function that returns bindings, create and return a new object that contains | ||
| // binding value-accessors functions. Each accessor function calls the original function | ||
| // so that it always gets the latest value and all dependencies are captured. This is used | ||
| // by ko.applyBindingsToNode and getBindingsAndMakeAccessors. | ||
| makeAccessorsFromFunction(callback) { | ||
| return objectMap(dependencyDetection_exports.ignore(callback), (value, key) => () => callback()[key]); | ||
| } | ||
| // Returns the valueAccessor function for a binding value | ||
| makeValueAccessor(value) { | ||
| return () => value; | ||
| } | ||
| // Given a bindings function or object, create and return a new object that contains | ||
| // binding value-accessors functions. This is used by ko.applyBindingsToNode. | ||
| makeBindingAccessors(bindings, context, node) { | ||
@@ -1342,3 +1438,3 @@ if (typeof bindings === "function") { | ||
| get FOR_NODE_TYPES() { | ||
| return [1, 3, 8]; | ||
| return [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE]; | ||
| } | ||
@@ -1350,2 +1446,4 @@ constructor(providerObject, parentProvider) { | ||
| } | ||
| // This function is used if the binding provider doesn't include a getBindingAccessors function. | ||
| // It must be called with 'this' set to the provider instance. | ||
| getBindingsAndMakeAccessors(node, context) { | ||
@@ -1365,2 +1463,3 @@ const bindingsFn = this.providerObject.getBindings.bind(this.providerObject, node, context); | ||
| } | ||
| return null; | ||
| } | ||
@@ -1374,5 +1473,5 @@ }; | ||
| } | ||
| constructor(params = {}) { | ||
| constructor(params) { | ||
| super(params); | ||
| const providers = params.providers || []; | ||
| const providers = (params == null ? void 0 : params.providers) || []; | ||
| this.nodeTypeMap = {}; | ||
@@ -1384,2 +1483,3 @@ this.nodeTypes = []; | ||
| setGlobals(globals) { | ||
| ; | ||
| [this, ...this.providers].forEach((p) => p.globals = globals); | ||
@@ -1394,3 +1494,3 @@ } | ||
| if (!nodeTypeMap[nodeType]) { | ||
| nodeTypeMap[nodeType] = []; | ||
| nodeTypeMap[nodeType] = new Array(); | ||
| } | ||
@@ -1404,3 +1504,3 @@ nodeTypeMap[nodeType].push(provider); | ||
| } | ||
| nodeHasBindings(node) { | ||
| nodeHasBindings(node, context) { | ||
| return this.providersFor(node).some((p) => p.nodeHasBindings(node)); | ||
@@ -1415,10 +1515,11 @@ } | ||
| } | ||
| return null; | ||
| } | ||
| *enumerateProviderBindings(node, ctx) { | ||
| *enumerateProviderBindings(node, context) { | ||
| for (const provider of this.providersFor(node)) { | ||
| const bindings = provider.getBindingAccessors(node, ctx); | ||
| const bindings = provider.getBindingAccessors(node, context); | ||
| if (!bindings) { | ||
| continue; | ||
| } | ||
| yield* Object.entries(bindings || {}); | ||
| yield* __yieldStar(Object.entries(bindings || {})); | ||
| if (provider.preemptive) { | ||
@@ -1429,5 +1530,5 @@ return; | ||
| } | ||
| getBindingAccessors(node, ctx) { | ||
| getBindingAccessors(node, context) { | ||
| const bindings = {}; | ||
| for (const [key, accessor] of this.enumerateProviderBindings(node, ctx)) { | ||
| for (const [key, accessor] of this.enumerateProviderBindings(node, context)) { | ||
| if (key in bindings) { | ||
@@ -1434,0 +1535,0 @@ throw new Error(`The binding "${key}" is duplicated by multiple providers`); |
+2
-1
@@ -1,2 +0,3 @@ | ||
| // @tko/provider.multi 🥊 4.0.0-beta1.3 ESM | ||
| // @tko/provider.multi 🥊 4.0.0 ESM | ||
| "use strict"; | ||
| export { default as MultiProvider } from "./MultiProvider"; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts"], | ||
| "sourcesContent": ["\nexport {default as MultiProvider} from './MultiProvider'\n"], | ||
| "mappings": ";AACA;", | ||
| "sourcesContent": ["export { default as MultiProvider } from './MultiProvider'\n"], | ||
| "mappings": ";;AAAA,SAAS,WAAW,qBAAqB;", | ||
| "names": [] | ||
| } |
+2
-1
@@ -1,2 +0,3 @@ | ||
| // @tko/provider.multi 🥊 4.0.0-beta1.3 MJS | ||
| // @tko/provider.multi 🥊 4.0.0 MJS | ||
| "use strict"; | ||
| export { default as MultiProvider } from "./MultiProvider"; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts"], | ||
| "sourcesContent": ["\nexport {default as MultiProvider} from './MultiProvider'\n"], | ||
| "mappings": ";AACA;", | ||
| "sourcesContent": ["export { default as MultiProvider } from './MultiProvider'\n"], | ||
| "mappings": ";;AAAA,SAAS,WAAW,qBAAqB;", | ||
| "names": [] | ||
| } |
+13
-12
@@ -1,5 +0,4 @@ | ||
| // @tko/provider.multi 🥊 4.0.0-beta1.3 ESM | ||
| import { | ||
| Provider | ||
| } from "@tko/provider"; | ||
| // @tko/provider.multi 🥊 4.0.0 ESM | ||
| "use strict"; | ||
| import { Provider } from "@tko/provider"; | ||
| export default class MultiProvider extends Provider { | ||
@@ -9,5 +8,5 @@ get FOR_NODE_TYPES() { | ||
| } | ||
| constructor(params = {}) { | ||
| constructor(params) { | ||
| super(params); | ||
| const providers = params.providers || []; | ||
| const providers = params?.providers || []; | ||
| this.nodeTypeMap = {}; | ||
@@ -19,2 +18,3 @@ this.nodeTypes = []; | ||
| setGlobals(globals) { | ||
| ; | ||
| [this, ...this.providers].forEach((p) => p.globals = globals); | ||
@@ -29,3 +29,3 @@ } | ||
| if (!nodeTypeMap[nodeType]) { | ||
| nodeTypeMap[nodeType] = []; | ||
| nodeTypeMap[nodeType] = new Array(); | ||
| } | ||
@@ -39,3 +39,3 @@ nodeTypeMap[nodeType].push(provider); | ||
| } | ||
| nodeHasBindings(node) { | ||
| nodeHasBindings(node, context) { | ||
| return this.providersFor(node).some((p) => p.nodeHasBindings(node)); | ||
@@ -50,6 +50,7 @@ } | ||
| } | ||
| return null; | ||
| } | ||
| *enumerateProviderBindings(node, ctx) { | ||
| *enumerateProviderBindings(node, context) { | ||
| for (const provider of this.providersFor(node)) { | ||
| const bindings = provider.getBindingAccessors(node, ctx); | ||
| const bindings = provider.getBindingAccessors(node, context); | ||
| if (!bindings) { | ||
@@ -64,5 +65,5 @@ continue; | ||
| } | ||
| getBindingAccessors(node, ctx) { | ||
| getBindingAccessors(node, context) { | ||
| const bindings = {}; | ||
| for (const [key, accessor] of this.enumerateProviderBindings(node, ctx)) { | ||
| for (const [key, accessor] of this.enumerateProviderBindings(node, context)) { | ||
| if (key in bindings) { | ||
@@ -69,0 +70,0 @@ throw new Error(`The binding "${key}" is duplicated by multiple providers`); |
| { | ||
| "version": 3, | ||
| "sources": ["../src/MultiProvider.ts"], | ||
| "sourcesContent": ["\nimport {\n Provider\n} from '@tko/provider'\n\nexport default class MultiProvider extends Provider {\n get FOR_NODE_TYPES () { return this.nodeTypes }\n\n constructor (params = {}) {\n super(params)\n const providers = params.providers || []\n this.nodeTypeMap = {}\n this.nodeTypes = []\n this.providers = []\n providers.forEach(p => this.addProvider(p))\n }\n\n setGlobals (globals) {\n [this, ...this.providers].forEach(p => (p.globals = globals))\n }\n\n addProvider (provider) {\n this.providers.push(provider)\n provider.bindingHandlers = this.bindingHandlers\n provider.globals = this.globals\n const nodeTypeMap = this.nodeTypeMap\n for (const nodeType of provider.FOR_NODE_TYPES) {\n if (!nodeTypeMap[nodeType]) { nodeTypeMap[nodeType] = [] }\n nodeTypeMap[nodeType].push(provider)\n }\n this.nodeTypes = Object.keys(this.nodeTypeMap).map(k => parseInt(k, 10))\n }\n\n providersFor (node) {\n return this.nodeTypeMap[node.nodeType] || []\n }\n\n nodeHasBindings (node) {\n return this.providersFor(node).some(p => p.nodeHasBindings(node))\n }\n\n preprocessNode (node) {\n for (const provider of this.providersFor(node)) {\n const newNodes = provider.preprocessNode(node)\n if (newNodes) { return newNodes }\n }\n }\n\n * enumerateProviderBindings (node, ctx) {\n for (const provider of this.providersFor(node)) {\n const bindings = provider.getBindingAccessors(node, ctx)\n if (!bindings) { continue }\n yield * Object.entries(bindings || {})\n if (provider.preemptive) { return }\n }\n }\n\n getBindingAccessors (node, ctx) {\n const bindings = {}\n for (const [key, accessor] of this.enumerateProviderBindings(node, ctx)) {\n if (key in bindings) {\n throw new Error(`The binding \"${key}\" is duplicated by multiple providers`)\n }\n bindings[key] = accessor\n }\n return bindings\n }\n}\n"], | ||
| "mappings": ";AACA;AAAA;AAAA;AAIA,qBAAqB,sBAAsB,SAAS;AAAA,MAC9C,iBAAkB;AAAE,WAAO,KAAK;AAAA,EAAU;AAAA,EAE9C,YAAa,SAAS,CAAC,GAAG;AACxB,UAAM,MAAM;AACZ,UAAM,YAAY,OAAO,aAAa,CAAC;AACvC,SAAK,cAAc,CAAC;AACpB,SAAK,YAAY,CAAC;AAClB,SAAK,YAAY,CAAC;AAClB,cAAU,QAAQ,OAAK,KAAK,YAAY,CAAC,CAAC;AAAA,EAC5C;AAAA,EAEA,WAAY,SAAS;AACnB,KAAC,MAAM,GAAG,KAAK,SAAS,EAAE,QAAQ,OAAM,EAAE,UAAU,OAAQ;AAAA,EAC9D;AAAA,EAEA,YAAa,UAAU;AACrB,SAAK,UAAU,KAAK,QAAQ;AAC5B,aAAS,kBAAkB,KAAK;AAChC,aAAS,UAAU,KAAK;AACxB,UAAM,cAAc,KAAK;AACzB,eAAW,YAAY,SAAS,gBAAgB;AAC9C,UAAI,CAAC,YAAY,WAAW;AAAE,oBAAY,YAAY,CAAC;AAAA,MAAE;AACzD,kBAAY,UAAU,KAAK,QAAQ;AAAA,IACrC;AACA,SAAK,YAAY,OAAO,KAAK,KAAK,WAAW,EAAE,IAAI,OAAK,SAAS,GAAG,EAAE,CAAC;AAAA,EACzE;AAAA,EAEA,aAAc,MAAM;AAClB,WAAO,KAAK,YAAY,KAAK,aAAa,CAAC;AAAA,EAC7C;AAAA,EAEA,gBAAiB,MAAM;AACrB,WAAO,KAAK,aAAa,IAAI,EAAE,KAAK,OAAK,EAAE,gBAAgB,IAAI,CAAC;AAAA,EAClE;AAAA,EAEA,eAAgB,MAAM;AACpB,eAAW,YAAY,KAAK,aAAa,IAAI,GAAG;AAC9C,YAAM,WAAW,SAAS,eAAe,IAAI;AAC7C,UAAI,UAAU;AAAE,eAAO;AAAA,MAAS;AAAA,IAClC;AAAA,EACF;AAAA,GAEE,0BAA2B,MAAM,KAAK;AACtC,eAAW,YAAY,KAAK,aAAa,IAAI,GAAG;AAC9C,YAAM,WAAW,SAAS,oBAAoB,MAAM,GAAG;AACvD,UAAI,CAAC,UAAU;AAAE;AAAA,MAAS;AAC1B,aAAQ,OAAO,QAAQ,YAAY,CAAC,CAAC;AACrC,UAAI,SAAS,YAAY;AAAE;AAAA,MAAO;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,oBAAqB,MAAM,KAAK;AAC9B,UAAM,WAAW,CAAC;AAClB,eAAW,CAAC,KAAK,aAAa,KAAK,0BAA0B,MAAM,GAAG,GAAG;AACvE,UAAI,OAAO,UAAU;AACnB,cAAM,IAAI,MAAM,gBAAgB,0CAA0C;AAAA,MAC5E;AACA,eAAS,OAAO;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AACF;", | ||
| "sourcesContent": ["import { Provider } from '@tko/provider'\n\nimport type { ProviderParamsInput } from '@tko/provider'\n\nimport type { BindingContext } from '@tko/bind'\n\nexport default class MultiProvider extends Provider {\n nodeTypes: number[]\n nodeTypeMap: Record<string, any[]>\n providers: any[]\n\n override get FOR_NODE_TYPES() {\n return this.nodeTypes\n }\n\n constructor(params?: ProviderParamsInput | null) {\n super(params)\n const providers = params?.providers || []\n this.nodeTypeMap = {}\n this.nodeTypes = []\n this.providers = []\n providers.forEach(p => this.addProvider(p))\n }\n\n override setGlobals(globals) {\n ;[this, ...this.providers].forEach(p => (p.globals = globals))\n }\n\n addProvider(provider: Provider) {\n this.providers.push(provider)\n provider.bindingHandlers = this.bindingHandlers\n provider.globals = this.globals\n const nodeTypeMap = this.nodeTypeMap\n for (const nodeType of provider.FOR_NODE_TYPES) {\n if (!nodeTypeMap[nodeType]) {\n nodeTypeMap[nodeType] = new Array()\n }\n nodeTypeMap[nodeType].push(provider)\n }\n this.nodeTypes = Object.keys(this.nodeTypeMap).map(k => parseInt(k, 10))\n }\n\n providersFor(node: Node): any[] {\n return this.nodeTypeMap[node.nodeType] || []\n }\n\n override nodeHasBindings(node: Node, context?: BindingContext): boolean {\n return this.providersFor(node).some(p => p.nodeHasBindings(node))\n }\n\n override preprocessNode(node: Node): Node[] | null {\n for (const provider of this.providersFor(node)) {\n const newNodes = provider.preprocessNode(node)\n if (newNodes) {\n return newNodes\n }\n }\n return null\n }\n\n *enumerateProviderBindings(node: Node, context) {\n for (const provider of this.providersFor(node)) {\n const bindings = provider.getBindingAccessors(node, context)\n if (!bindings) {\n continue\n }\n yield* Object.entries(bindings || {})\n if (provider.preemptive) {\n return\n }\n }\n }\n\n override getBindingAccessors(node: Node, context?: BindingContext) {\n const bindings = {}\n for (const [key, accessor] of this.enumerateProviderBindings(node, context)) {\n if (key in bindings) {\n throw new Error(`The binding \"${key}\" is duplicated by multiple providers`)\n }\n bindings[key] = accessor\n }\n return bindings\n }\n}\n"], | ||
| "mappings": ";;AAAA,SAAS,gBAAgB;AAMzB,qBAAqB,sBAAsB,SAAS;AAAA,EAKlD,IAAa,iBAAiB;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,QAAqC;AAC/C,UAAM,MAAM;AACZ,UAAM,YAAY,QAAQ,aAAa,CAAC;AACxC,SAAK,cAAc,CAAC;AACpB,SAAK,YAAY,CAAC;AAClB,SAAK,YAAY,CAAC;AAClB,cAAU,QAAQ,OAAK,KAAK,YAAY,CAAC,CAAC;AAAA,EAC5C;AAAA,EAES,WAAW,SAAS;AAC3B;AAAC,KAAC,MAAM,GAAG,KAAK,SAAS,EAAE,QAAQ,OAAM,EAAE,UAAU,OAAQ;AAAA,EAC/D;AAAA,EAEA,YAAY,UAAoB;AAC9B,SAAK,UAAU,KAAK,QAAQ;AAC5B,aAAS,kBAAkB,KAAK;AAChC,aAAS,UAAU,KAAK;AACxB,UAAM,cAAc,KAAK;AACzB,eAAW,YAAY,SAAS,gBAAgB;AAC9C,UAAI,CAAC,YAAY,QAAQ,GAAG;AAC1B,oBAAY,QAAQ,IAAI,IAAI,MAAM;AAAA,MACpC;AACA,kBAAY,QAAQ,EAAE,KAAK,QAAQ;AAAA,IACrC;AACA,SAAK,YAAY,OAAO,KAAK,KAAK,WAAW,EAAE,IAAI,OAAK,SAAS,GAAG,EAAE,CAAC;AAAA,EACzE;AAAA,EAEA,aAAa,MAAmB;AAC9B,WAAO,KAAK,YAAY,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC7C;AAAA,EAES,gBAAgB,MAAY,SAAmC;AACtE,WAAO,KAAK,aAAa,IAAI,EAAE,KAAK,OAAK,EAAE,gBAAgB,IAAI,CAAC;AAAA,EAClE;AAAA,EAES,eAAe,MAA2B;AACjD,eAAW,YAAY,KAAK,aAAa,IAAI,GAAG;AAC9C,YAAM,WAAW,SAAS,eAAe,IAAI;AAC7C,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,CAAC,0BAA0B,MAAY,SAAS;AAC9C,eAAW,YAAY,KAAK,aAAa,IAAI,GAAG;AAC9C,YAAM,WAAW,SAAS,oBAAoB,MAAM,OAAO;AAC3D,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AACA,aAAO,OAAO,QAAQ,YAAY,CAAC,CAAC;AACpC,UAAI,SAAS,YAAY;AACvB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAES,oBAAoB,MAAY,SAA0B;AACjE,UAAM,WAAW,CAAC;AAClB,eAAW,CAAC,KAAK,QAAQ,KAAK,KAAK,0BAA0B,MAAM,OAAO,GAAG;AAC3E,UAAI,OAAO,UAAU;AACnB,cAAM,IAAI,MAAM,gBAAgB,GAAG,uCAAuC;AAAA,MAC5E;AACA,eAAS,GAAG,IAAI;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AACF;", | ||
| "names": [] | ||
| } |
+3
-4
| { | ||
| "version": "4.0.0-beta1.3", | ||
| "version": "4.0.0", | ||
| "name": "@tko/provider.multi", | ||
@@ -12,3 +12,3 @@ "description": "Combine multiple other providers into one", | ||
| "dependencies": { | ||
| "@tko/provider": "^4.0.0-beta1.3", | ||
| "@tko/provider": "^4.0.0", | ||
| "tslib": "^2.2.0" | ||
@@ -43,4 +43,3 @@ }, | ||
| "url": "git+https://github.com/knockout/tko.git" | ||
| }, | ||
| "gitHead": "a8843acb8ae085915115e53a4e057b30731c635e" | ||
| } | ||
| } |
-22
| 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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
145410
0.05%1513
7.61%0
-100%9
-10%3
Infinity%Updated