@tko/binding.foreach
Advanced tools
+25
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/binding.foreach 🥊 4.0.0 ESM | ||
| // @tko/binding.foreach 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -42,2 +42,26 @@ import { | ||
| export class ForEachBinding extends AsyncBindingHandler { | ||
| // NOTE: valid valueAccessors include: | ||
| // [] | ||
| // observable([]) | ||
| // observableArray([]) | ||
| // computed | ||
| // {data: array, name: string, as: string} | ||
| afterAdd; | ||
| static animateFrame; | ||
| as; | ||
| beforeRemove; | ||
| container; | ||
| changeSubs; | ||
| data; | ||
| generateContext; | ||
| $indexHasBeenRequested; | ||
| templateNode; | ||
| changeQueue; | ||
| firstLastNodesList; | ||
| indexesToDelete; | ||
| isNotEmpty; | ||
| rendering_queued; | ||
| pendingDeletes; | ||
| afterQueueFlush; | ||
| beforeQueueFlush; | ||
| constructor(params) { | ||
@@ -44,0 +68,0 @@ super(params); |
| { | ||
| "version": 3, | ||
| "sources": ["../src/foreach.ts"], | ||
| "sourcesContent": ["// index.js\n// --------\n// Fast For Each\n//\n// Employing sound techniques to make a faster Knockout foreach binding.\n// --------\n\nimport {\n arrayForEach,\n cleanNode,\n options,\n virtualElements,\n createSymbolOrString,\n domData,\n domNodeIsContainedBy\n} from '@tko/utils'\n\nimport { isObservable, unwrap, observable } from '@tko/observable'\n\nimport type { ObservableArray } from '@tko/observable'\n\nimport { contextFor, applyBindingsToDescendants, AsyncBindingHandler } from '@tko/bind'\n\nimport type { AllBindings } from '@tko/bind'\n\n// Utilities\nconst MAX_LIST_SIZE = 9007199254740991\n\n// from https://github.com/jonschlinkert/is-plain-object\nfunction isPlainObject(o): o is Record<string, any> {\n return !!o && typeof o === 'object' && o.constructor === Object\n}\n\ninterface ChangeMap {\n added: ChangeAddItem[]\n deleted: any[]\n}\n\ninterface ChangeAddItemBase {\n status: 'added'\n index: number\n}\n\ninterface ChangeAddBatchItem extends ChangeAddItemBase {\n isBatch: true\n values: any[]\n}\n\ninterface ChangeAddOneItem extends ChangeAddItemBase {\n isBatch?: false\n value: any\n}\n\ntype ChangeAddItem = ChangeAddBatchItem | ChangeAddOneItem\n\nconst supportsDocumentFragment = options.document && typeof options.document.createDocumentFragment === 'function'\n\n// Get a copy of the (possibly virtual) child nodes of the given element,\n// put them into a container, then empty the given node.\nfunction makeTemplateNode(sourceNode) {\n const container = document.createElement('div')\n let parentNode\n if (sourceNode.content) {\n // For e.g. <template> tags\n parentNode = sourceNode.content\n } else if (sourceNode.tagName === 'SCRIPT') {\n parentNode = document.createElement('div')\n parentNode.innerHTML = sourceNode.text\n } else {\n // Anything else e.g. <div>\n parentNode = sourceNode\n }\n arrayForEach(virtualElements.childNodes(parentNode), function (child) {\n // FIXME - This cloneNode could be expensive; we may prefer to iterate over the\n // parentNode children in reverse (so as not to foul the indexes as childNodes are\n // removed from parentNode when inserted into the container)\n if (child) {\n container.insertBefore(child.cloneNode(true), null)\n }\n })\n return container\n}\n\n// Mimic a KO change item 'add'\nfunction valueToChangeAddItem(value, index): ChangeAddItem {\n return { status: 'added', value: value, index: index }\n}\n\n// store a symbol for caching the pending delete info index in the data item objects\nconst PENDING_DELETE_INDEX_SYM = createSymbolOrString('_ko_ffe_pending_delete_index')\n\nexport class ForEachBinding extends AsyncBindingHandler {\n // NOTE: valid valueAccessors include:\n // []\n // observable([])\n // observableArray([])\n // computed\n // {data: array, name: string, as: string}\n afterAdd\n override allBindings: AllBindings\n static animateFrame\n as\n beforeRemove\n container\n changeSubs: any\n data\n generateContext\n $indexHasBeenRequested: boolean\n templateNode\n changeQueue: any[]\n firstLastNodesList: { first: Node; last: Node }[]\n indexesToDelete: any[]\n isNotEmpty: any\n rendering_queued: boolean\n pendingDeletes: any[]\n afterQueueFlush\n beforeQueueFlush\n\n constructor(params) {\n super(params)\n const settings: any = {}\n if (isPlainObject(this.value)) {\n Object.assign(settings, this.value)\n }\n\n this.as = settings.as || this.allBindings.get('as')\n\n this.data = settings.data || (unwrap(this.$context.$rawData) === this.value ? this.$context.$rawData : this.value)\n\n this.container = virtualElements.isStartComment(this.$element) ? this.$element.parentNode : this.$element\n this.generateContext = this.createContextGenerator(this.as)\n this.$indexHasBeenRequested = false\n\n this.templateNode = makeTemplateNode(\n settings.templateNode || (settings.name ? document.getElementById(settings.name)?.cloneNode(true) : this.$element)\n )\n ;['afterAdd', 'beforeRemove', 'afterQueueFlush', 'beforeQueueFlush'].forEach(p => {\n this[p] = settings[p] || this.allBindings.get(p)\n })\n\n this.changeQueue = new Array()\n this.firstLastNodesList = new Array()\n this.indexesToDelete = new Array()\n this.rendering_queued = false\n this.pendingDeletes = new Array()\n\n // Expose the conditional so that if the `foreach` data is empty, successive\n // 'else' bindings will appear.\n this.isNotEmpty = observable(Boolean(unwrap(this.data).length))\n domData.set(this.$element, 'conditional', { elseChainSatisfied: this.isNotEmpty })\n\n // Remove existing content.\n virtualElements.emptyNode(this.$element)\n\n // Prime content\n const primeData = unwrap(this.data)\n if (primeData && primeData.map) {\n this.onArrayChange(primeData.map(valueToChangeAddItem), true)\n } else {\n this.completeBinding()\n }\n\n // Watch for changes\n if (isObservable(this.data)) {\n if (!(this.data as ObservableArray).indexOf) {\n // Make sure the observable is trackable.\n this.data = this.data.extend({ trackArrayChanges: true })\n }\n this.changeSubs = this.data.subscribe(this.onArrayChange, this, 'arrayChange')\n }\n }\n\n override dispose() {\n if (this.changeSubs) {\n this.changeSubs.dispose()\n }\n this.flushPendingDeletes()\n }\n\n // If the array changes we register the change.\n onArrayChange(changeSet, isInitial) {\n const changeMap: ChangeMap = { added: [], deleted: [] }\n\n // knockout array change notification index handling:\n // - sends the original array indexes for deletes\n // - sends the new array indexes for adds\n // - sorts them all by index in ascending order\n // because of this, when checking for possible batch additions, any delete can be between to adds with neighboring indexes, so only additions should be checked\n for (let i = 0, len = changeSet.length; i < len; i++) {\n if (changeMap.added.length && changeSet[i].status === 'added') {\n let lastAdd = changeMap.added[changeMap.added.length - 1]\n const lastIndex = lastAdd.isBatch ? lastAdd.index + lastAdd.values!.length - 1 : lastAdd.index\n if (lastIndex + 1 === changeSet[i].index) {\n if (!lastAdd.isBatch) {\n // transform the last addition into a batch addition object\n lastAdd = { isBatch: true, status: 'added', index: lastAdd.index, values: [lastAdd.value] }\n changeMap.added.splice(changeMap.added.length - 1, 1, lastAdd)\n }\n lastAdd.values!.push(changeSet[i].value)\n continue\n }\n }\n\n changeMap[changeSet[i].status].push(changeSet[i])\n }\n\n if (changeMap.deleted.length > 0) {\n this.changeQueue.push.apply(this.changeQueue, changeMap.deleted)\n this.changeQueue.push({ status: 'clearDeletedIndexes' })\n }\n\n this.changeQueue.push.apply(this.changeQueue, changeMap.added)\n // Once a change is registered, the ticking count-down starts for the processQueue.\n if (this.changeQueue.length > 0 && !this.rendering_queued) {\n this.rendering_queued = true\n if (isInitial) {\n this.processQueue()\n } else {\n ForEachBinding.animateFrame.call(window, () => this.processQueue())\n }\n }\n }\n\n startQueueFlush() {\n // Callback so folks can do things before the queue flush.\n if (typeof this.beforeQueueFlush === 'function') {\n this.beforeQueueFlush(this.changeQueue)\n }\n }\n\n endQueueFlush() {\n // Callback so folks can do things.\n if (typeof this.afterQueueFlush === 'function') {\n this.afterQueueFlush(this.changeQueue)\n }\n }\n\n // Reflect all the changes in the queue in the DOM, then wipe the queue.\n processQueue() {\n const isEmpty = !unwrap(this.data).length\n let lowestIndexChanged = MAX_LIST_SIZE\n\n this.startQueueFlush()\n\n arrayForEach(this.changeQueue, changeItem => {\n if (typeof changeItem.index === 'number') {\n lowestIndexChanged = Math.min(lowestIndexChanged, changeItem.index)\n }\n this[changeItem.status](changeItem)\n })\n this.flushPendingDeletes()\n this.rendering_queued = false\n\n // Update our indexes.\n if (this.$indexHasBeenRequested) {\n this.updateIndexes(lowestIndexChanged)\n }\n\n this.endQueueFlush()\n this.changeQueue = new Array()\n\n // Update the conditional exposed on the domData\n if (isEmpty !== !this.isNotEmpty()) {\n this.isNotEmpty(!isEmpty)\n }\n }\n\n /**\n * Once the $index has been asked for once, start calculating it.\n * Note that this significantly degrades performance, from O(1) to O(n)\n * for arbitrary changes to the list.\n */\n _first$indexRequest(ctx$indexRequestedFrom) {\n this.$indexHasBeenRequested = true\n for (let i = 0, len = this.firstLastNodesList.length; i < len; ++i) {\n const ctx = this.getContextStartingFrom(this.firstLastNodesList[i].first)\n // Overwrite the defineProperty.\n if (ctx) {\n ctx.$index = observable(i)\n }\n }\n return ctx$indexRequestedFrom.$index()\n }\n\n _contextExtensions($ctx) {\n Object.assign($ctx, { $list: this.data })\n if (this.$indexHasBeenRequested) {\n $ctx.$index = $ctx.$index || observable()\n } else {\n Object.defineProperty($ctx, '$index', {\n value: () => this._first$indexRequest($ctx),\n configurable: true,\n writable: true\n })\n }\n return $ctx\n }\n\n /**\n * Return a function that generates the context for a given node.\n *\n * We generate a single function that reduces our inner-loop calculations,\n * which has a good chance of being optimized by the browser.\n *\n * @param {string} as The name given to each item in the list\n * @param {bool} index Whether to calculate indexes\n * @return {function} A function(dataValue) that returns the context\n */\n createContextGenerator(as) {\n const $ctx = this.$context\n if (as) {\n return v => this._contextExtensions($ctx.extend({ [as]: v }))\n } else {\n return v => $ctx.createChildContext(v, undefined, ctx => this._contextExtensions(ctx))\n }\n }\n\n updateFirstLastNodesList(index, children) {\n const first = children[0]\n const last = children[children.length - 1]\n this.firstLastNodesList.splice(index, 0, { first, last })\n }\n\n // Process a changeItem with {status: 'added', ...}\n added(changeItem: ChangeAddItem) {\n const index = changeItem.index\n const valuesToAdd = changeItem.isBatch ? changeItem.values : [changeItem.value]\n const referenceElement = this.getLastNodeBeforeIndex(index)\n // gather all childnodes for a possible batch insertion\n const allChildNodes: Node[] = []\n const asyncBindingResults = new Array()\n let children\n\n for (let i = 0, len = valuesToAdd.length; i < len; ++i) {\n // we check if we have a pending delete with reusable nodesets for this data, and if yes, we reuse one nodeset\n const pendingDelete = this.getPendingDeleteFor(valuesToAdd[i])\n if (pendingDelete && pendingDelete.nodesets.length) {\n children = pendingDelete.nodesets.pop()\n this.updateFirstLastNodesList(index + i, children)\n } else {\n const templateClone = this.templateNode.cloneNode(true)\n children = virtualElements.childNodes(templateClone)\n this.updateFirstLastNodesList(index + i, children)\n\n // Apply bindings first, and then process child nodes,\n // because bindings can add childnodes.\n const bindingResult = applyBindingsToDescendants(this.generateContext(valuesToAdd[i]), templateClone)\n asyncBindingResults.push(bindingResult)\n }\n\n allChildNodes.push(...children)\n }\n\n if (typeof this.afterAdd === 'function') {\n this.afterAdd({\n nodeOrArrayInserted: this.insertAllAfter(allChildNodes, referenceElement),\n foreachInstance: this\n })\n } else {\n this.insertAllAfter(allChildNodes, referenceElement)\n }\n\n this.completeBinding(Promise.all(asyncBindingResults))\n }\n\n getNodesForIndex(index) {\n const result = new Array()\n let ptr = this.firstLastNodesList[index].first\n const last = this.firstLastNodesList[index].last\n result.push(ptr)\n while (ptr && ptr !== last) {\n ptr = ptr.nextSibling!\n result.push(ptr)\n }\n return result\n }\n\n getLastNodeBeforeIndex(index) {\n if (index < 1 || index - 1 >= this.firstLastNodesList.length) {\n return null\n }\n return this.firstLastNodesList[index - 1].last\n }\n\n /**\n * Get the active (focused) node, if it's a child of the given node.\n */\n activeChildElement(node) {\n const active = document.activeElement\n if (domNodeIsContainedBy(active!, node)) {\n return active\n }\n return null\n }\n\n insertAllAfter(nodeOrNodeArrayToInsert, insertAfterNode) {\n let frag\n let len\n let i\n let active: any = null\n const containerNode = this.$element\n\n // Poor man's node and array check.\n if (nodeOrNodeArrayToInsert.nodeType === undefined && nodeOrNodeArrayToInsert.length === undefined) {\n throw new Error('Expected a single node or a node array')\n }\n if (nodeOrNodeArrayToInsert.nodeType !== undefined) {\n active = this.activeChildElement(nodeOrNodeArrayToInsert)\n virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert, insertAfterNode)\n return [nodeOrNodeArrayToInsert]\n } else if (nodeOrNodeArrayToInsert.length === 1) {\n active = this.activeChildElement(nodeOrNodeArrayToInsert[0])\n virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert[0], insertAfterNode)\n } else if (supportsDocumentFragment) {\n frag = document.createDocumentFragment()\n for (i = 0, len = nodeOrNodeArrayToInsert.length; i !== len; ++i) {\n active = active || this.activeChildElement(nodeOrNodeArrayToInsert[i])\n frag.appendChild(nodeOrNodeArrayToInsert[i])\n }\n virtualElements.insertAfter(containerNode, frag, insertAfterNode)\n } else {\n // Nodes are inserted in reverse order - pushed down immediately after\n // the last node for the previous item or as the first node of element.\n for (i = nodeOrNodeArrayToInsert.length - 1; i >= 0; --i) {\n active = active || this.activeChildElement(nodeOrNodeArrayToInsert[i])\n const child = nodeOrNodeArrayToInsert[i]\n if (!child) {\n break\n }\n virtualElements.insertAfter(containerNode, child, insertAfterNode)\n }\n }\n\n if (active) {\n active.focus()\n }\n\n return nodeOrNodeArrayToInsert\n }\n\n // checks if the deleted data item should be handled with delay for a possible reuse at additions\n shouldDelayDeletion(data) {\n return data && (typeof data === 'object' || typeof data === 'function')\n }\n\n // gets the pending deletion info for this data item\n getPendingDeleteFor(data: any[]) {\n const index = data && data[PENDING_DELETE_INDEX_SYM]\n if (index === undefined) return null\n return this.pendingDeletes[index]\n }\n\n // tries to find the existing pending delete info for this data item, and if it can't, it registeres one\n getOrCreatePendingDeleteFor(data) {\n let pd = this.getPendingDeleteFor(data)\n if (pd) {\n return pd\n }\n pd = { data: data, nodesets: [] }\n data[PENDING_DELETE_INDEX_SYM] = this.pendingDeletes.length\n this.pendingDeletes.push(pd)\n return pd\n }\n\n // Process a changeItem with {status: 'deleted', ...}\n deleted(changeItem) {\n // if we should delay the deletion of this data, we add the nodeset to the pending delete info object\n if (this.shouldDelayDeletion(changeItem.value)) {\n const pd = this.getOrCreatePendingDeleteFor(changeItem.value)\n pd.nodesets.push(this.getNodesForIndex(changeItem.index))\n } else {\n // simple data, just remove the nodes\n this.removeNodes(this.getNodesForIndex(changeItem.index))\n }\n this.indexesToDelete.push(changeItem.index)\n }\n\n // removes a set of nodes from the DOM\n removeNodes(nodes) {\n if (!nodes.length) {\n return\n }\n\n function removeFn() {\n const parent = nodes[0].parentNode\n for (let i = nodes.length - 1; i >= 0; --i) {\n cleanNode(nodes[i])\n parent.removeChild(nodes[i])\n }\n }\n\n if (this.beforeRemove) {\n const beforeRemoveReturn = this.beforeRemove({ nodesToRemove: nodes, foreachInstance: this }) || {}\n // If beforeRemove returns a `then`\u2013able e.g. a Promise, we remove\n // the nodes when that thenable completes. We pass any errors to\n // ko.onError.\n if (typeof beforeRemoveReturn.then === 'function') {\n beforeRemoveReturn.then(removeFn, options.onError)\n }\n } else {\n removeFn()\n }\n }\n\n // flushes the pending delete info store\n // this should be called after queue processing has finished, so that data items and remaining (not reused) nodesets get cleaned up\n // we also call it on dispose not to leave any mess\n flushPendingDeletes() {\n for (let i = 0, len = this.pendingDeletes.length; i !== len; ++i) {\n const pd = this.pendingDeletes[i]\n while (pd.nodesets.length) {\n this.removeNodes(pd.nodesets.pop())\n }\n if (pd.data && pd.data[PENDING_DELETE_INDEX_SYM] !== undefined) {\n delete pd.data[PENDING_DELETE_INDEX_SYM]\n }\n }\n this.pendingDeletes = new Array()\n }\n\n // We batch our deletion of item indexes in our parallel array.\n // See brianmhunt/knockout-fast-foreach#6/#8\n clearDeletedIndexes() {\n // We iterate in reverse on the presumption (following the unit tests) that KO's diff engine\n // processes diffs (esp. deletes) monotonically ascending i.e. from index 0 -> N.\n for (let i = this.indexesToDelete.length - 1; i >= 0; --i) {\n this.firstLastNodesList.splice(this.indexesToDelete[i], 1)\n }\n this.indexesToDelete = new Array()\n }\n\n updateIndexes(fromIndex) {\n let ctx\n for (let i = fromIndex, len = this.firstLastNodesList.length; i < len; ++i) {\n ctx = this.getContextStartingFrom(this.firstLastNodesList[i].first)\n if (ctx) {\n ctx.$index(i)\n }\n }\n }\n\n getContextStartingFrom(node) {\n let ctx\n while (node) {\n ctx = contextFor(node)\n if (ctx) {\n return ctx\n }\n node = node.nextSibling\n }\n }\n\n /**\n * Set whether the binding is always synchronous.\n * Useful during testing.\n */\n static setSync(toggle) {\n const w = options.global\n if (toggle) {\n ForEachBinding.animateFrame = function (frame) {\n frame()\n }\n } else {\n ForEachBinding.animateFrame =\n w.requestAnimationFrame\n || w.webkitRequestAnimationFrame\n || w.mozRequestAnimationFrame\n || w.msRequestAnimationFrame\n || function (cb) {\n return w.setTimeout(cb, 1000 / 60)\n }\n }\n }\n\n override get controlsDescendants() {\n return true\n }\n static override get allowVirtualElements() {\n return true\n }\n\n /* TODO: Remove; for legacy/testing */\n static get ForEach() {\n return this\n }\n static get PENDING_DELETE_INDEX_SYM() {\n return PENDING_DELETE_INDEX_SYM\n }\n}\n"], | ||
| "mappings": ";;AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc,QAAQ,kBAAkB;AAIjD,SAAS,YAAY,4BAA4B,2BAA2B;AAK5E,MAAM,gBAAgB;AAGtB,SAAS,cAAc,GAA6B;AAClD,SAAO,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,EAAE,gBAAgB;AAC3D;AAwBA,MAAM,2BAA2B,QAAQ,YAAY,OAAO,QAAQ,SAAS,2BAA2B;AAIxG,SAAS,iBAAiB,YAAY;AACpC,QAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,MAAI;AACJ,MAAI,WAAW,SAAS;AAEtB,iBAAa,WAAW;AAAA,EAC1B,WAAW,WAAW,YAAY,UAAU;AAC1C,iBAAa,SAAS,cAAc,KAAK;AACzC,eAAW,YAAY,WAAW;AAAA,EACpC,OAAO;AAEL,iBAAa;AAAA,EACf;AACA,eAAa,gBAAgB,WAAW,UAAU,GAAG,SAAU,OAAO;AAIpE,QAAI,OAAO;AACT,gBAAU,aAAa,MAAM,UAAU,IAAI,GAAG,IAAI;AAAA,IACpD;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAGA,SAAS,qBAAqB,OAAO,OAAsB;AACzD,SAAO,EAAE,QAAQ,SAAS,OAA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A;AAAA;AAAA;AAAA,EAMA,OAAO,QAAQ,QAAQ;AACrB,UAAM,IAAI,QAAQ;AAClB,QAAI,QAAQ;AACV,qBAAe,eAAe,SAAU,OAAO;AAC7C,cAAM;AAAA,MACR;AAAA,IACF,OAAO;AACL,qBAAe,eACb,EAAE,yBACC,EAAE,+BACF,EAAE,4BACF,EAAE,2BACF,SAAU,IAAI;AACf,eAAO,EAAE,WAAW,IAAI,MAAO,EAAE;AAAA,MACnC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,IAAa,sBAAsB;AACjC,WAAO;AAAA,EACT;AAAA,EACA,WAAoB,uBAAuB;AACzC,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,WAAW,UAAU;AACnB,WAAO;AAAA,EACT;AAAA,EACA,WAAW,2BAA2B;AACpC,WAAO;AAAA,EACT;AACF;", | ||
| "sourcesContent": ["// index.js\n// --------\n// Fast For Each\n//\n// Employing sound techniques to make a faster Knockout foreach binding.\n// --------\n\nimport {\n arrayForEach,\n cleanNode,\n options,\n virtualElements,\n createSymbolOrString,\n domData,\n domNodeIsContainedBy\n} from '@tko/utils'\n\nimport { isObservable, unwrap, observable } from '@tko/observable'\n\nimport type { ObservableArray } from '@tko/observable'\n\nimport { contextFor, applyBindingsToDescendants, AsyncBindingHandler } from '@tko/bind'\n\nimport type { AllBindings } from '@tko/bind'\n\n// Utilities\nconst MAX_LIST_SIZE = 9007199254740991\n\n// from https://github.com/jonschlinkert/is-plain-object\nfunction isPlainObject(o): o is Record<string, any> {\n return !!o && typeof o === 'object' && o.constructor === Object\n}\n\ninterface ChangeMap {\n added: ChangeAddItem[]\n deleted: any[]\n}\n\ninterface ChangeAddItemBase {\n status: 'added'\n index: number\n}\n\ninterface ChangeAddBatchItem extends ChangeAddItemBase {\n isBatch: true\n values: any[]\n}\n\ninterface ChangeAddOneItem extends ChangeAddItemBase {\n isBatch?: false\n value: any\n}\n\ntype ChangeAddItem = ChangeAddBatchItem | ChangeAddOneItem\n\nconst supportsDocumentFragment = options.document && typeof options.document.createDocumentFragment === 'function'\n\n// Get a copy of the (possibly virtual) child nodes of the given element,\n// put them into a container, then empty the given node.\nfunction makeTemplateNode(sourceNode) {\n const container = document.createElement('div')\n let parentNode\n if (sourceNode.content) {\n // For e.g. <template> tags\n parentNode = sourceNode.content\n } else if (sourceNode.tagName === 'SCRIPT') {\n parentNode = document.createElement('div')\n parentNode.innerHTML = sourceNode.text\n } else {\n // Anything else e.g. <div>\n parentNode = sourceNode\n }\n arrayForEach(virtualElements.childNodes(parentNode), function (child) {\n // FIXME - This cloneNode could be expensive; we may prefer to iterate over the\n // parentNode children in reverse (so as not to foul the indexes as childNodes are\n // removed from parentNode when inserted into the container)\n if (child) {\n container.insertBefore(child.cloneNode(true), null)\n }\n })\n return container\n}\n\n// Mimic a KO change item 'add'\nfunction valueToChangeAddItem(value, index): ChangeAddItem {\n return { status: 'added', value: value, index: index }\n}\n\n// store a symbol for caching the pending delete info index in the data item objects\nconst PENDING_DELETE_INDEX_SYM = createSymbolOrString('_ko_ffe_pending_delete_index')\n\nexport class ForEachBinding extends AsyncBindingHandler {\n // NOTE: valid valueAccessors include:\n // []\n // observable([])\n // observableArray([])\n // computed\n // {data: array, name: string, as: string}\n afterAdd\n static animateFrame\n as\n beforeRemove\n container\n changeSubs: any\n data\n generateContext\n $indexHasBeenRequested: boolean\n templateNode\n changeQueue: any[]\n firstLastNodesList: { first: Node; last: Node }[]\n indexesToDelete: any[]\n isNotEmpty: any\n rendering_queued: boolean\n pendingDeletes: any[]\n afterQueueFlush\n beforeQueueFlush\n\n constructor(params) {\n super(params)\n const settings: any = {}\n if (isPlainObject(this.value)) {\n Object.assign(settings, this.value)\n }\n\n this.as = settings.as || this.allBindings.get('as')\n\n this.data = settings.data || (unwrap(this.$context.$rawData) === this.value ? this.$context.$rawData : this.value)\n\n this.container = virtualElements.isStartComment(this.$element) ? this.$element.parentNode : this.$element\n this.generateContext = this.createContextGenerator(this.as)\n this.$indexHasBeenRequested = false\n\n this.templateNode = makeTemplateNode(\n settings.templateNode || (settings.name ? document.getElementById(settings.name)?.cloneNode(true) : this.$element)\n )\n ;['afterAdd', 'beforeRemove', 'afterQueueFlush', 'beforeQueueFlush'].forEach(p => {\n this[p] = settings[p] || this.allBindings.get(p)\n })\n\n this.changeQueue = new Array()\n this.firstLastNodesList = new Array()\n this.indexesToDelete = new Array()\n this.rendering_queued = false\n this.pendingDeletes = new Array()\n\n // Expose the conditional so that if the `foreach` data is empty, successive\n // 'else' bindings will appear.\n this.isNotEmpty = observable(Boolean(unwrap(this.data).length))\n domData.set(this.$element, 'conditional', { elseChainSatisfied: this.isNotEmpty })\n\n // Remove existing content.\n virtualElements.emptyNode(this.$element)\n\n // Prime content\n const primeData = unwrap(this.data)\n if (primeData && primeData.map) {\n this.onArrayChange(primeData.map(valueToChangeAddItem), true)\n } else {\n this.completeBinding()\n }\n\n // Watch for changes\n if (isObservable(this.data)) {\n if (!(this.data as ObservableArray).indexOf) {\n // Make sure the observable is trackable.\n this.data = this.data.extend({ trackArrayChanges: true })\n }\n this.changeSubs = this.data.subscribe(this.onArrayChange, this, 'arrayChange')\n }\n }\n\n override dispose() {\n if (this.changeSubs) {\n this.changeSubs.dispose()\n }\n this.flushPendingDeletes()\n }\n\n // If the array changes we register the change.\n onArrayChange(changeSet, isInitial) {\n const changeMap: ChangeMap = { added: [], deleted: [] }\n\n // knockout array change notification index handling:\n // - sends the original array indexes for deletes\n // - sends the new array indexes for adds\n // - sorts them all by index in ascending order\n // because of this, when checking for possible batch additions, any delete can be between to adds with neighboring indexes, so only additions should be checked\n for (let i = 0, len = changeSet.length; i < len; i++) {\n if (changeMap.added.length && changeSet[i].status === 'added') {\n let lastAdd = changeMap.added[changeMap.added.length - 1]\n const lastIndex = lastAdd.isBatch ? lastAdd.index + lastAdd.values!.length - 1 : lastAdd.index\n if (lastIndex + 1 === changeSet[i].index) {\n if (!lastAdd.isBatch) {\n // transform the last addition into a batch addition object\n lastAdd = { isBatch: true, status: 'added', index: lastAdd.index, values: [lastAdd.value] }\n changeMap.added.splice(changeMap.added.length - 1, 1, lastAdd)\n }\n lastAdd.values!.push(changeSet[i].value)\n continue\n }\n }\n\n changeMap[changeSet[i].status].push(changeSet[i])\n }\n\n if (changeMap.deleted.length > 0) {\n this.changeQueue.push.apply(this.changeQueue, changeMap.deleted)\n this.changeQueue.push({ status: 'clearDeletedIndexes' })\n }\n\n this.changeQueue.push.apply(this.changeQueue, changeMap.added)\n // Once a change is registered, the ticking count-down starts for the processQueue.\n if (this.changeQueue.length > 0 && !this.rendering_queued) {\n this.rendering_queued = true\n if (isInitial) {\n this.processQueue()\n } else {\n ForEachBinding.animateFrame.call(window, () => this.processQueue())\n }\n }\n }\n\n startQueueFlush() {\n // Callback so folks can do things before the queue flush.\n if (typeof this.beforeQueueFlush === 'function') {\n this.beforeQueueFlush(this.changeQueue)\n }\n }\n\n endQueueFlush() {\n // Callback so folks can do things.\n if (typeof this.afterQueueFlush === 'function') {\n this.afterQueueFlush(this.changeQueue)\n }\n }\n\n // Reflect all the changes in the queue in the DOM, then wipe the queue.\n processQueue() {\n const isEmpty = !unwrap(this.data).length\n let lowestIndexChanged = MAX_LIST_SIZE\n\n this.startQueueFlush()\n\n arrayForEach(this.changeQueue, changeItem => {\n if (typeof changeItem.index === 'number') {\n lowestIndexChanged = Math.min(lowestIndexChanged, changeItem.index)\n }\n this[changeItem.status](changeItem)\n })\n this.flushPendingDeletes()\n this.rendering_queued = false\n\n // Update our indexes.\n if (this.$indexHasBeenRequested) {\n this.updateIndexes(lowestIndexChanged)\n }\n\n this.endQueueFlush()\n this.changeQueue = new Array()\n\n // Update the conditional exposed on the domData\n if (isEmpty !== !this.isNotEmpty()) {\n this.isNotEmpty(!isEmpty)\n }\n }\n\n /**\n * Once the $index has been asked for once, start calculating it.\n * Note that this significantly degrades performance, from O(1) to O(n)\n * for arbitrary changes to the list.\n */\n _first$indexRequest(ctx$indexRequestedFrom) {\n this.$indexHasBeenRequested = true\n for (let i = 0, len = this.firstLastNodesList.length; i < len; ++i) {\n const ctx = this.getContextStartingFrom(this.firstLastNodesList[i].first)\n // Overwrite the defineProperty.\n if (ctx) {\n ctx.$index = observable(i)\n }\n }\n return ctx$indexRequestedFrom.$index()\n }\n\n _contextExtensions($ctx) {\n Object.assign($ctx, { $list: this.data })\n if (this.$indexHasBeenRequested) {\n $ctx.$index = $ctx.$index || observable()\n } else {\n Object.defineProperty($ctx, '$index', {\n value: () => this._first$indexRequest($ctx),\n configurable: true,\n writable: true\n })\n }\n return $ctx\n }\n\n /**\n * Return a function that generates the context for a given node.\n *\n * We generate a single function that reduces our inner-loop calculations,\n * which has a good chance of being optimized by the browser.\n *\n * @param {string} as The name given to each item in the list\n * @param {bool} index Whether to calculate indexes\n * @return {function} A function(dataValue) that returns the context\n */\n createContextGenerator(as) {\n const $ctx = this.$context\n if (as) {\n return v => this._contextExtensions($ctx.extend({ [as]: v }))\n } else {\n return v => $ctx.createChildContext(v, undefined, ctx => this._contextExtensions(ctx))\n }\n }\n\n updateFirstLastNodesList(index, children) {\n const first = children[0]\n const last = children[children.length - 1]\n this.firstLastNodesList.splice(index, 0, { first, last })\n }\n\n // Process a changeItem with {status: 'added', ...}\n added(changeItem: ChangeAddItem) {\n const index = changeItem.index\n const valuesToAdd = changeItem.isBatch ? changeItem.values : [changeItem.value]\n const referenceElement = this.getLastNodeBeforeIndex(index)\n // gather all childnodes for a possible batch insertion\n const allChildNodes: Node[] = []\n const asyncBindingResults = new Array()\n let children\n\n for (let i = 0, len = valuesToAdd.length; i < len; ++i) {\n // we check if we have a pending delete with reusable nodesets for this data, and if yes, we reuse one nodeset\n const pendingDelete = this.getPendingDeleteFor(valuesToAdd[i])\n if (pendingDelete && pendingDelete.nodesets.length) {\n children = pendingDelete.nodesets.pop()\n this.updateFirstLastNodesList(index + i, children)\n } else {\n const templateClone = this.templateNode.cloneNode(true)\n children = virtualElements.childNodes(templateClone)\n this.updateFirstLastNodesList(index + i, children)\n\n // Apply bindings first, and then process child nodes,\n // because bindings can add childnodes.\n const bindingResult = applyBindingsToDescendants(this.generateContext(valuesToAdd[i]), templateClone)\n asyncBindingResults.push(bindingResult)\n }\n\n allChildNodes.push(...children)\n }\n\n if (typeof this.afterAdd === 'function') {\n this.afterAdd({\n nodeOrArrayInserted: this.insertAllAfter(allChildNodes, referenceElement),\n foreachInstance: this\n })\n } else {\n this.insertAllAfter(allChildNodes, referenceElement)\n }\n\n this.completeBinding(Promise.all(asyncBindingResults))\n }\n\n getNodesForIndex(index) {\n const result = new Array()\n let ptr = this.firstLastNodesList[index].first\n const last = this.firstLastNodesList[index].last\n result.push(ptr)\n while (ptr && ptr !== last) {\n ptr = ptr.nextSibling!\n result.push(ptr)\n }\n return result\n }\n\n getLastNodeBeforeIndex(index) {\n if (index < 1 || index - 1 >= this.firstLastNodesList.length) {\n return null\n }\n return this.firstLastNodesList[index - 1].last\n }\n\n /**\n * Get the active (focused) node, if it's a child of the given node.\n */\n activeChildElement(node) {\n const active = document.activeElement\n if (domNodeIsContainedBy(active!, node)) {\n return active\n }\n return null\n }\n\n insertAllAfter(nodeOrNodeArrayToInsert, insertAfterNode) {\n let frag\n let len\n let i\n let active: any = null\n const containerNode = this.$element\n\n // Poor man's node and array check.\n if (nodeOrNodeArrayToInsert.nodeType === undefined && nodeOrNodeArrayToInsert.length === undefined) {\n throw new Error('Expected a single node or a node array')\n }\n if (nodeOrNodeArrayToInsert.nodeType !== undefined) {\n active = this.activeChildElement(nodeOrNodeArrayToInsert)\n virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert, insertAfterNode)\n return [nodeOrNodeArrayToInsert]\n } else if (nodeOrNodeArrayToInsert.length === 1) {\n active = this.activeChildElement(nodeOrNodeArrayToInsert[0])\n virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert[0], insertAfterNode)\n } else if (supportsDocumentFragment) {\n frag = document.createDocumentFragment()\n for (i = 0, len = nodeOrNodeArrayToInsert.length; i !== len; ++i) {\n active = active || this.activeChildElement(nodeOrNodeArrayToInsert[i])\n frag.appendChild(nodeOrNodeArrayToInsert[i])\n }\n virtualElements.insertAfter(containerNode, frag, insertAfterNode)\n } else {\n // Nodes are inserted in reverse order - pushed down immediately after\n // the last node for the previous item or as the first node of element.\n for (i = nodeOrNodeArrayToInsert.length - 1; i >= 0; --i) {\n active = active || this.activeChildElement(nodeOrNodeArrayToInsert[i])\n const child = nodeOrNodeArrayToInsert[i]\n if (!child) {\n break\n }\n virtualElements.insertAfter(containerNode, child, insertAfterNode)\n }\n }\n\n if (active) {\n active.focus()\n }\n\n return nodeOrNodeArrayToInsert\n }\n\n // checks if the deleted data item should be handled with delay for a possible reuse at additions\n shouldDelayDeletion(data) {\n return data && (typeof data === 'object' || typeof data === 'function')\n }\n\n // gets the pending deletion info for this data item\n getPendingDeleteFor(data: any[]) {\n const index = data && data[PENDING_DELETE_INDEX_SYM]\n if (index === undefined) return null\n return this.pendingDeletes[index]\n }\n\n // tries to find the existing pending delete info for this data item, and if it can't, it registeres one\n getOrCreatePendingDeleteFor(data) {\n let pd = this.getPendingDeleteFor(data)\n if (pd) {\n return pd\n }\n pd = { data: data, nodesets: [] }\n data[PENDING_DELETE_INDEX_SYM] = this.pendingDeletes.length\n this.pendingDeletes.push(pd)\n return pd\n }\n\n // Process a changeItem with {status: 'deleted', ...}\n deleted(changeItem) {\n // if we should delay the deletion of this data, we add the nodeset to the pending delete info object\n if (this.shouldDelayDeletion(changeItem.value)) {\n const pd = this.getOrCreatePendingDeleteFor(changeItem.value)\n pd.nodesets.push(this.getNodesForIndex(changeItem.index))\n } else {\n // simple data, just remove the nodes\n this.removeNodes(this.getNodesForIndex(changeItem.index))\n }\n this.indexesToDelete.push(changeItem.index)\n }\n\n // removes a set of nodes from the DOM\n removeNodes(nodes) {\n if (!nodes.length) {\n return\n }\n\n function removeFn() {\n const parent = nodes[0].parentNode\n for (let i = nodes.length - 1; i >= 0; --i) {\n cleanNode(nodes[i])\n parent.removeChild(nodes[i])\n }\n }\n\n if (this.beforeRemove) {\n const beforeRemoveReturn = this.beforeRemove({ nodesToRemove: nodes, foreachInstance: this }) || {}\n // If beforeRemove returns a `then`\u2013able e.g. a Promise, we remove\n // the nodes when that thenable completes. We pass any errors to\n // ko.onError.\n if (typeof beforeRemoveReturn.then === 'function') {\n beforeRemoveReturn.then(removeFn, options.onError)\n }\n } else {\n removeFn()\n }\n }\n\n // flushes the pending delete info store\n // this should be called after queue processing has finished, so that data items and remaining (not reused) nodesets get cleaned up\n // we also call it on dispose not to leave any mess\n flushPendingDeletes() {\n for (let i = 0, len = this.pendingDeletes.length; i !== len; ++i) {\n const pd = this.pendingDeletes[i]\n while (pd.nodesets.length) {\n this.removeNodes(pd.nodesets.pop())\n }\n if (pd.data && pd.data[PENDING_DELETE_INDEX_SYM] !== undefined) {\n delete pd.data[PENDING_DELETE_INDEX_SYM]\n }\n }\n this.pendingDeletes = new Array()\n }\n\n // We batch our deletion of item indexes in our parallel array.\n // See brianmhunt/knockout-fast-foreach#6/#8\n clearDeletedIndexes() {\n // We iterate in reverse on the presumption (following the unit tests) that KO's diff engine\n // processes diffs (esp. deletes) monotonically ascending i.e. from index 0 -> N.\n for (let i = this.indexesToDelete.length - 1; i >= 0; --i) {\n this.firstLastNodesList.splice(this.indexesToDelete[i], 1)\n }\n this.indexesToDelete = new Array()\n }\n\n updateIndexes(fromIndex) {\n let ctx\n for (let i = fromIndex, len = this.firstLastNodesList.length; i < len; ++i) {\n ctx = this.getContextStartingFrom(this.firstLastNodesList[i].first)\n if (ctx) {\n ctx.$index(i)\n }\n }\n }\n\n getContextStartingFrom(node) {\n let ctx\n while (node) {\n ctx = contextFor(node)\n if (ctx) {\n return ctx\n }\n node = node.nextSibling\n }\n }\n\n /**\n * Set whether the binding is always synchronous.\n * Useful during testing.\n */\n static setSync(toggle) {\n const w = options.global\n if (toggle) {\n ForEachBinding.animateFrame = function (frame) {\n frame()\n }\n } else {\n ForEachBinding.animateFrame =\n w.requestAnimationFrame ||\n w.webkitRequestAnimationFrame ||\n w.mozRequestAnimationFrame ||\n w.msRequestAnimationFrame ||\n function (cb) {\n return w.setTimeout(cb, 1000 / 60)\n }\n }\n }\n\n override get controlsDescendants() {\n return true\n }\n static override get allowVirtualElements() {\n return true\n }\n\n /* TODO: Remove; for legacy/testing */\n static get ForEach() {\n return this\n }\n static get PENDING_DELETE_INDEX_SYM() {\n return PENDING_DELETE_INDEX_SYM\n }\n}\n"], | ||
| "mappings": ";;AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc,QAAQ,kBAAkB;AAIjD,SAAS,YAAY,4BAA4B,2BAA2B;AAK5E,MAAM,gBAAgB;AAGtB,SAAS,cAAc,GAA6B;AAClD,SAAO,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,EAAE,gBAAgB;AAC3D;AAwBA,MAAM,2BAA2B,QAAQ,YAAY,OAAO,QAAQ,SAAS,2BAA2B;AAIxG,SAAS,iBAAiB,YAAY;AACpC,QAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,MAAI;AACJ,MAAI,WAAW,SAAS;AAEtB,iBAAa,WAAW;AAAA,EAC1B,WAAW,WAAW,YAAY,UAAU;AAC1C,iBAAa,SAAS,cAAc,KAAK;AACzC,eAAW,YAAY,WAAW;AAAA,EACpC,OAAO;AAEL,iBAAa;AAAA,EACf;AACA,eAAa,gBAAgB,WAAW,UAAU,GAAG,SAAU,OAAO;AAIpE,QAAI,OAAO;AACT,gBAAU,aAAa,MAAM,UAAU,IAAI,GAAG,IAAI;AAAA,IACpD;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAGA,SAAS,qBAAqB,OAAO,OAAsB;AACzD,SAAO,EAAE,QAAQ,SAAS,OAAc,MAAa;AACvD;AAGA,MAAM,2BAA2B,qBAAqB,8BAA8B;AAE7E,aAAM,uBAAuB,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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O,MAAM;AACX,YAAM,WAAW,IAAI;AACrB,UAAI,KAAK;AACP,eAAO;AAAA,MACT;AACA,aAAO,KAAK;AAAA,IACd;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,QAAQ,QAAQ;AACrB,UAAM,IAAI,QAAQ;AAClB,QAAI,QAAQ;AACV,qBAAe,eAAe,SAAU,OAAO;AAC7C,cAAM;AAAA,MACR;AAAA,IACF,OAAO;AACL,qBAAe,eACb,EAAE,yBACF,EAAE,+BACF,EAAE,4BACF,EAAE,2BACF,SAAU,IAAI;AACZ,eAAO,EAAE,WAAW,IAAI,MAAO,EAAE;AAAA,MACnC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,IAAa,sBAAsB;AACjC,WAAO;AAAA,EACT;AAAA,EACA,WAAoB,uBAAuB;AACzC,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,WAAW,UAAU;AACnB,WAAO;AAAA,EACT;AAAA,EACA,WAAW,2BAA2B;AACpC,WAAO;AAAA,EACT;AACF;", | ||
| "names": [] | ||
| } |
+2
-2
@@ -1,5 +0,5 @@ | ||
| // @tko/binding.foreach 🥊 4.0.0 ESM | ||
| // @tko/binding.foreach 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { ForEachBinding } from "./foreach"; | ||
| import { ForEachBinding } from "./foreach.js"; | ||
| export const bindings = { foreach: ForEachBinding }; | ||
| ForEachBinding.setSync(false); |
+2
-2
@@ -1,5 +0,5 @@ | ||
| // @tko/binding.foreach 🥊 4.0.0 MJS | ||
| // @tko/binding.foreach 🥊 4.0.1 MJS | ||
| "use strict"; | ||
| import { ForEachBinding } from "./foreach"; | ||
| import { ForEachBinding } from "./foreach.js"; | ||
| export const bindings = { foreach: ForEachBinding }; | ||
| ForEachBinding.setSync(false); |
+11
-17
| { | ||
| "version": "4.0.0", | ||
| "version": "4.0.1", | ||
| "name": "@tko/binding.foreach", | ||
| "description": "Knockout Foreach Binding", | ||
| "module": "dist/binding.foreach.js", | ||
| "module": "dist/index.js", | ||
| "files": [ | ||
| "dist/", | ||
| "helpers/" | ||
| "dist/" | ||
| ], | ||
@@ -26,15 +25,8 @@ "repository": { | ||
| "dependencies": { | ||
| "@tko/bind": "^4.0.0", | ||
| "@tko/observable": "^4.0.0", | ||
| "@tko/provider": "^4.0.0", | ||
| "@tko/utils": "^4.0.0", | ||
| "@tko/bind": "^4.0.1", | ||
| "@tko/observable": "^4.0.1", | ||
| "@tko/provider": "^4.0.1", | ||
| "@tko/utils": "^4.0.1", | ||
| "tslib": "^2.2.0" | ||
| }, | ||
| "karma": { | ||
| "frameworks": [ | ||
| "mocha", | ||
| "chai", | ||
| "sinon" | ||
| ] | ||
| }, | ||
| "licenses": [ | ||
@@ -50,5 +42,7 @@ { | ||
| "import": "./dist/index.js" | ||
| }, | ||
| "./helpers/*": "./helpers/*" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "build": "bun ../../tools/build.ts" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
94429
-74.18%923
-75.08%1
Infinity%Updated
Updated
Updated
Updated