@tko/utils
Advanced tools
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ const { isArray } = Array; |
+2
-2
@@ -1,4 +0,4 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { safeSetTimeout } from "./error"; | ||
| import { safeSetTimeout } from "./error.js"; | ||
| export function throttle(callback, timeout) { | ||
@@ -5,0 +5,0 @@ let timeoutInstance; |
+2
-2
@@ -1,4 +0,4 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { arrayForEach, addOrRemoveItem } from "./array"; | ||
| import { arrayForEach, addOrRemoveItem } from "./array.js"; | ||
| const cssClassNameRegex = /\S+/g; | ||
@@ -5,0 +5,0 @@ function toggleDomNodeCssClass(node, classNames, shouldHaveClass) { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ const datastoreTime = (/* @__PURE__ */ new Date()).getTime(); |
@@ -1,6 +0,6 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import * as domData from "./data"; | ||
| import { default as options } from "../options"; | ||
| import { arrayRemoveItem, arrayIndexOf } from "../array"; | ||
| import * as domData from "./data.js"; | ||
| import { default as options } from "../options.js"; | ||
| import { arrayRemoveItem, arrayIndexOf } from "../array.js"; | ||
| const domDataKey = domData.nextKey(); | ||
@@ -7,0 +7,0 @@ const cleanableNodeTypes = { 1: true, 8: true, 9: true }; |
@@ -1,7 +0,7 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { objectForEach } from "../object"; | ||
| import { catchFunctionErrors } from "../error"; | ||
| import { tagNameLower } from "./info"; | ||
| import options from "../options"; | ||
| import { objectForEach } from "../object.js"; | ||
| import { catchFunctionErrors } from "../error.js"; | ||
| import { tagNameLower } from "./info.js"; | ||
| import options from "../options.js"; | ||
| const knownEvents = {}, knownEventTypesByEventName = {}; | ||
@@ -8,0 +8,0 @@ knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"]; |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export function fixUpContinuousNodeArray(continuousNodeArray, parentNode) { |
| { | ||
| "version": 3, | ||
| "sources": ["../../src/dom/fixes.ts"], | ||
| "sourcesContent": ["//\n// DOM node manipulation\n//\n\nexport function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {\n // Before acting on a set of nodes that were previously outputted by a template function, we have to reconcile\n // them against what is in the DOM right now. It may be that some of the nodes have already been removed, or that\n // new nodes might have been inserted in the middle, for example by a binding. Also, there may previously have been\n // leading comment nodes (created by rewritten string-based templates) that have since been removed during binding.\n // So, this function translates the old \"map\" output array into its best guess of the set of current DOM nodes.\n //\n // Rules:\n // [A] Any leading nodes that have been removed should be ignored\n // These most likely correspond to memoization nodes that were already removed during binding\n // See https://github.com/knockout/knockout/pull/440\n // [B] Any trailing nodes that have been remove should be ignored\n // This prevents the code here from adding unrelated nodes to the array while processing rule [C]\n // See https://github.com/knockout/knockout/pull/1903\n // [C] We want to output a continuous series of nodes. So, ignore any nodes that have already been removed,\n // and include any nodes that have been inserted among the previous collection\n\n if (continuousNodeArray.length) {\n // The parent node can be a virtual element; so get the real parent node\n parentNode = (parentNode.nodeType === Node.COMMENT_NODE && parentNode.parentNode) || parentNode\n\n // Rule [A]\n while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {\n continuousNodeArray.splice(0, 1)\n }\n\n // Rule [B]\n while (\n continuousNodeArray.length > 1\n && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode\n ) {\n continuousNodeArray.length--\n }\n\n // Rule [C]\n if (continuousNodeArray.length > 1) {\n let current = continuousNodeArray[0],\n last = continuousNodeArray[continuousNodeArray.length - 1]\n // Replace with the actual new continuous node set\n continuousNodeArray.length = 0\n while (current !== last) {\n continuousNodeArray.push(current)\n current = current.nextSibling\n }\n continuousNodeArray.push(last)\n }\n }\n return continuousNodeArray\n}\n\nexport function setOptionNodeSelectionState(optionNode, isSelected) {\n optionNode.selected = isSelected\n}\n"], | ||
| "mappings": ";;AAIO,gBAAS,yBAAyB,qBAAqB,YAAY;AAiBxE,MAAI,oBAAoB,QAAQ;AAE9B,iBAAc,WAAW,aAAa,KAAK,gBAAgB,WAAW,cAAe;AAGrF,WAAO,oBAAoB,UAAU,oBAAoB,CAAC,EAAE,eAAe,YAAY;AACrF,0BAAoB,OAAO,GAAG,CAAC;AAAA,IACjC;AAGA,WACE,oBAAoB,SAAS,KAC1B,oBAAoB,oBAAoB,SAAS,CAAC,EAAE,eAAe,YACtE;AACA,0BAAoB;AAAA,IACtB;AAGA,QAAI,oBAAoB,SAAS,GAAG;AAClC,UAAI,UAAU,oBAAoB,CAAC,GACjC,OAAO,oBAAoB,oBAAoB,SAAS,CAAC;AAE3D,0BAAoB,SAAS;AAC7B,aAAO,YAAY,MAAM;AACvB,4BAAoB,KAAK,OAAO;AAChC,kBAAU,QAAQ;AAAA,MACpB;AACA,0BAAoB,KAAK,IAAI;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAEO,gBAAS,4BAA4B,YAAY,YAAY;AAClE,aAAW,WAAW;AACxB;", | ||
| "sourcesContent": ["//\n// DOM node manipulation\n//\n\nexport function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {\n // Before acting on a set of nodes that were previously outputted by a template function, we have to reconcile\n // them against what is in the DOM right now. It may be that some of the nodes have already been removed, or that\n // new nodes might have been inserted in the middle, for example by a binding. Also, there may previously have been\n // leading comment nodes (created by rewritten string-based templates) that have since been removed during binding.\n // So, this function translates the old \"map\" output array into its best guess of the set of current DOM nodes.\n //\n // Rules:\n // [A] Any leading nodes that have been removed should be ignored\n // These most likely correspond to memoization nodes that were already removed during binding\n // See https://github.com/knockout/knockout/pull/440\n // [B] Any trailing nodes that have been remove should be ignored\n // This prevents the code here from adding unrelated nodes to the array while processing rule [C]\n // See https://github.com/knockout/knockout/pull/1903\n // [C] We want to output a continuous series of nodes. So, ignore any nodes that have already been removed,\n // and include any nodes that have been inserted among the previous collection\n\n if (continuousNodeArray.length) {\n // The parent node can be a virtual element; so get the real parent node\n parentNode = (parentNode.nodeType === Node.COMMENT_NODE && parentNode.parentNode) || parentNode\n\n // Rule [A]\n while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {\n continuousNodeArray.splice(0, 1)\n }\n\n // Rule [B]\n while (\n continuousNodeArray.length > 1 &&\n continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode\n ) {\n continuousNodeArray.length--\n }\n\n // Rule [C]\n if (continuousNodeArray.length > 1) {\n let current = continuousNodeArray[0],\n last = continuousNodeArray[continuousNodeArray.length - 1]\n // Replace with the actual new continuous node set\n continuousNodeArray.length = 0\n while (current !== last) {\n continuousNodeArray.push(current)\n current = current.nextSibling\n }\n continuousNodeArray.push(last)\n }\n }\n return continuousNodeArray\n}\n\nexport function setOptionNodeSelectionState(optionNode, isSelected) {\n optionNode.selected = isSelected\n}\n"], | ||
| "mappings": ";;AAIO,gBAAS,yBAAyB,qBAAqB,YAAY;AAiBxE,MAAI,oBAAoB,QAAQ;AAE9B,iBAAc,WAAW,aAAa,KAAK,gBAAgB,WAAW,cAAe;AAGrF,WAAO,oBAAoB,UAAU,oBAAoB,CAAC,EAAE,eAAe,YAAY;AACrF,0BAAoB,OAAO,GAAG,CAAC;AAAA,IACjC;AAGA,WACE,oBAAoB,SAAS,KAC7B,oBAAoB,oBAAoB,SAAS,CAAC,EAAE,eAAe,YACnE;AACA,0BAAoB;AAAA,IACtB;AAGA,QAAI,oBAAoB,SAAS,GAAG;AAClC,UAAI,UAAU,oBAAoB,CAAC,GACjC,OAAO,oBAAoB,oBAAoB,SAAS,CAAC;AAE3D,0BAAoB,SAAS;AAC7B,aAAO,YAAY,MAAM;AACvB,4BAAoB,KAAK,OAAO;AAChC,kBAAU,QAAQ;AAAA,MACpB;AACA,0BAAoB,KAAK,IAAI;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAEO,gBAAS,4BAA4B,YAAY,YAAY;AAClE,aAAW,WAAW;AACxB;", | ||
| "names": [] | ||
| } |
+5
-5
@@ -1,7 +0,7 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { makeArray } from "../array"; | ||
| import { emptyDomNode, moveCleanedNodesToContainerElement } from "./manipulation"; | ||
| import * as virtualElements from "./virtualElements"; | ||
| import options from "../options"; | ||
| import { makeArray } from "../array.js"; | ||
| import { emptyDomNode, moveCleanedNodesToContainerElement } from "./manipulation.js"; | ||
| import * as virtualElements from "./virtualElements.js"; | ||
| import options from "../options.js"; | ||
| const supportsTemplateTag = options.useTemplateTag && options.document && "content" in options.document.createElement("template"); | ||
@@ -8,0 +8,0 @@ function simpleHtmlParse(html, documentContext) { |
+2
-2
@@ -1,4 +0,4 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { arrayFirst } from "../array"; | ||
| import { arrayFirst } from "../array.js"; | ||
| export function domNodeIsContainedBy(node, containedByNode) { | ||
@@ -5,0 +5,0 @@ if (node === containedByNode) { |
@@ -1,5 +0,5 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { makeArray } from "../array"; | ||
| import { cleanNode, removeNode } from "./disposal"; | ||
| import { makeArray } from "../array.js"; | ||
| import { cleanNode, removeNode } from "./disposal.js"; | ||
| export function moveCleanedNodesToContainerElement(nodes) { | ||
@@ -6,0 +6,0 @@ const nodesArray = makeArray(nodes); |
@@ -1,5 +0,5 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { tagNameLower } from "./info"; | ||
| import * as domData from "./data"; | ||
| import { tagNameLower } from "./info.js"; | ||
| import * as domData from "./data.js"; | ||
| const hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty"); | ||
@@ -6,0 +6,0 @@ export const selectExtensions = { |
@@ -1,7 +0,7 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from "./manipulation"; | ||
| import { removeNode } from "./disposal"; | ||
| import { tagNameLower } from "./info"; | ||
| import * as domData from "./data"; | ||
| import { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from "./manipulation.js"; | ||
| import { removeNode } from "./disposal.js"; | ||
| import { tagNameLower } from "./info.js"; | ||
| import * as domData from "./data.js"; | ||
| export const startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/; | ||
@@ -8,0 +8,0 @@ export const endCommentRegex = /^\s*\/ko\s*$/; |
| { | ||
| "version": 3, | ||
| "sources": ["../../src/dom/virtualElements.ts"], | ||
| "sourcesContent": ["/* eslint no-cond-assign: 0 */\n//\n// Virtual Elements\n//\n//\n// \"Virtual elements\" is an abstraction on top of the usual DOM API which understands the notion that comment nodes\n// may be used to represent hierarchy (in addition to the DOM's natural hierarchy).\n// If you call the DOM-manipulating functions on ko.virtualElements, you will be able to read and write the state\n// of that virtual hierarchy\n//\n// The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)\n// without having to scatter special cases all over the binding and templating code.\n\nimport { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from './manipulation'\nimport { removeNode } from './disposal'\nimport { tagNameLower } from './info'\nimport * as domData from './data'\nimport options from '../options'\n\nexport const startCommentRegex = /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/\nexport const endCommentRegex = /^\\s*\\/ko\\s*$/\nconst htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true }\n\nexport function isStartComment(node) {\n return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue)\n}\n\nexport function isEndComment(node) {\n return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue)\n}\n\nfunction isUnmatchedEndComment(node) {\n return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey)\n}\n\nconst matchedEndCommentDataKey = '__ko_matchedEndComment__'\n\nexport function getVirtualChildren(startComment, allowUnbalanced?) {\n let currentNode = startComment\n let depth = 1\n const children = new Array()\n while ((currentNode = currentNode.nextSibling)) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true)\n depth--\n if (depth === 0) {\n return children\n }\n }\n\n children.push(currentNode)\n\n if (isStartComment(currentNode)) {\n depth++\n }\n }\n if (!allowUnbalanced) {\n throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue)\n }\n return null\n}\n\nfunction getMatchingEndComment(startComment, allowUnbalanced?) {\n const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced)\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) {\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling\n }\n return startComment.nextSibling\n } else {\n return null\n } // Must have no matching end comment, and allowUnbalanced is true\n}\n\nfunction getUnbalancedChildTags(node) {\n // e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>\n // from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->\n let childNode = node.firstChild,\n captureRemaining: any = null\n if (childNode) {\n do {\n if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes\n {\n captureRemaining.push(childNode)\n } else if (isStartComment(childNode)) {\n const matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true)\n if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set\n {\n childNode = matchingEndComment\n } else {\n captureRemaining = [childNode]\n } // It's unbalanced, so start capturing from this point\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode] // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing\n }\n } while ((childNode = childNode.nextSibling))\n }\n return captureRemaining\n}\n\nexport interface VirtualElementsAllowedBindings {\n text: boolean\n foreach: boolean\n if: boolean\n ifnot: boolean\n with: boolean\n let: boolean\n using: boolean\n template: boolean\n component: boolean\n}\n\nexport const allowedBindings: VirtualElementsAllowedBindings = Object.create(null)\nexport const hasBindingValue = isStartComment\n\nexport function childNodes(node: Node): any {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes\n}\n\nexport function emptyNode(node: Node) {\n if (!isStartComment(node)) {\n emptyDomNode(node)\n } else {\n const virtualChildren = childNodes(node)\n for (let i = 0, j = virtualChildren.length; i < j; i++) {\n removeNode(virtualChildren[i])\n }\n }\n}\n\nexport function setDomNodeChildren(node: Node, childNodes: Node[]) {\n if (!isStartComment(node)) {\n setRegularDomNodeChildren(node, childNodes)\n } else {\n emptyNode(node)\n const endCommentNode = node.nextSibling // Must be the next sibling, as we just emptied the children\n if (endCommentNode && endCommentNode.parentNode) {\n const parentNode = endCommentNode.parentNode\n for (let i = 0, j = childNodes.length; i < j; ++i) {\n parentNode.insertBefore(childNodes[i], endCommentNode)\n }\n }\n }\n}\n\nexport function prepend(containerNode: Node, nodeToPrepend: Node) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) {\n containerNode.insertBefore(nodeToPrepend, containerNode.firstChild)\n } else {\n containerNode.appendChild(nodeToPrepend)\n }\n } else {\n // Start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToPrepend, containerNode.nextSibling)\n }\n}\n\nexport function insertAfter(containerNode: Node, nodeToInsert: Node, insertAfterNode: Node) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert)\n } else if (!isStartComment(containerNode)) {\n // Insert after insertion point\n if (insertAfterNode.nextSibling) {\n containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n } else {\n containerNode.appendChild(nodeToInsert)\n }\n } else {\n // Children of start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n }\n}\n\nexport function firstChild(node: Node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error('Found invalid end comment, as the first child of ' + (node as Element).outerHTML)\n }\n return node.firstChild\n }\n if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null\n }\n return node.nextSibling\n}\n\nexport function lastChild(node: Node) {\n let nextChild = firstChild(node)\n if (!nextChild) return null\n\n let lastChildNode\n\n do {\n lastChildNode = nextChild\n } while ((nextChild = nextSibling(nextChild)))\n\n return lastChildNode\n}\n\nexport function nextSibling(node: Node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node)\n }\n\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error(\n 'Found end comment without a matching opening comment, as next sibling of ' + (node as Element).outerHTML\n )\n }\n return null\n } else {\n return node.nextSibling\n }\n}\n\nexport function previousSibling(node) {\n let depth = 0\n do {\n if (node.nodeType === Node.COMMENT_NODE) {\n if (isStartComment(node)) {\n if (--depth === 0) {\n return node\n }\n } else if (isEndComment(node)) {\n depth++\n }\n } else {\n if (depth === 0) {\n return node\n }\n }\n } while ((node = node.previousSibling))\n}\n\nexport function virtualNodeBindingValue(node): string | null {\n const regexMatch = node.nodeValue.match(startCommentRegex) as RegExpMatchArray\n return regexMatch ? regexMatch[1] : null\n}\n\nexport function normaliseVirtualElementDomStructure(elementVerified) {\n // Workaround for https://github.com/SteveSanderson/knockout/issues/155\n // (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes\n // that are direct descendants of <ul> into the preceding <li>)\n if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {\n return\n }\n\n // Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags\n // must be intended to appear *after* that child, so move them there.\n let childNode = elementVerified.firstChild\n if (childNode) {\n do {\n if (childNode.nodeType === Node.ELEMENT_NODE) {\n const unbalancedTags = getUnbalancedChildTags(childNode)\n if (unbalancedTags) {\n // Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child\n const nodeToInsertBefore = childNode.nextSibling\n for (let i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) {\n elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore)\n } else {\n elementVerified.appendChild(unbalancedTags[i])\n }\n }\n }\n }\n } while ((childNode = childNode.nextSibling))\n }\n}\n"], | ||
| "mappings": ";;AAaA,SAAS,cAAc,sBAAsB,iCAAiC;AAC9E,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,YAAY,aAAa;AAGlB,aAAM,oBAAoB;AAC1B,aAAM,kBAAkB;AAC/B,MAAM,wCAAwC,EAAE,IAAI,MAAM,IAAI,KAAK;AAE5D,gBAAS,eAAe,MAAM;AACnC,SAAO,KAAK,aAAa,KAAK,gBAAgB,kBAAkB,KAAK,KAAK,SAAS;AACrF;AAEO,gBAAS,aAAa,MAAM;AACjC,SAAO,KAAK,aAAa,KAAK,gBAAgB,gBAAgB,KAAK,KAAK,SAAS;AACnF;AAEA,SAAS,sBAAsB,MAAM;AACnC,SAAO,aAAa,IAAI,KAAK,CAAC,QAAQ,IAAI,MAAM,wBAAwB;AAC1E;AAEA,MAAM,2BAA2B;AAE1B,gBAAS,mBAAmB,cAAc,iBAAkB;AACjE,MAAI,c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O,aAAa,WAAW,CAAC,IAAI;AACtC;AAEO,gBAAS,oCAAoC,iBAAiB;AAInE,MAAI,CAAC,sCAAsC,aAAa,eAAe,CAAC,GAAG;AACzE;AAAA,EACF;AAIA,MAAI,YAAY,gBAAgB;AAChC,MAAI,WAAW;AACb,OAAG;AACD,UAAI,UAAU,aAAa,KAAK,cAAc;AAC5C,cAAM,iBAAiB,uBAAuB,SAAS;AACvD,YAAI,gBAAgB;AAElB,gBAAM,qBAAqB,UAAU;AACrC,mBAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC9C,gBAAI,oBAAoB;AACtB,8BAAgB,aAAa,eAAe,CAAC,GAAG,kBAAkB;AAAA,YACpE,OAAO;AACL,8BAAgB,YAAY,eAAe,CAAC,CAAC;AAAA,YAC/C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAU,YAAY,UAAU;AAAA,EAClC;AACF;", | ||
| "sourcesContent": ["/* eslint no-cond-assign: 0 */\n//\n// Virtual Elements\n//\n//\n// \"Virtual elements\" is an abstraction on top of the usual DOM API which understands the notion that comment nodes\n// may be used to represent hierarchy (in addition to the DOM's natural hierarchy).\n// If you call the DOM-manipulating functions on ko.virtualElements, you will be able to read and write the state\n// of that virtual hierarchy\n//\n// The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)\n// without having to scatter special cases all over the binding and templating code.\n\nimport { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from './manipulation'\nimport { removeNode } from './disposal'\nimport { tagNameLower } from './info'\nimport * as domData from './data'\nimport options from '../options'\n\nexport const startCommentRegex = /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/\nexport const endCommentRegex = /^\\s*\\/ko\\s*$/\nconst htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true }\n\nexport function isStartComment(node) {\n return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue)\n}\n\nexport function isEndComment(node) {\n return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue)\n}\n\nfunction isUnmatchedEndComment(node) {\n return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey)\n}\n\nconst matchedEndCommentDataKey = '__ko_matchedEndComment__'\n\nexport function getVirtualChildren(startComment, allowUnbalanced?) {\n let currentNode = startComment\n let depth = 1\n const children = new Array()\n while ((currentNode = currentNode.nextSibling)) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true)\n depth--\n if (depth === 0) {\n return children\n }\n }\n\n children.push(currentNode)\n\n if (isStartComment(currentNode)) {\n depth++\n }\n }\n if (!allowUnbalanced) {\n throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue)\n }\n return null\n}\n\nfunction getMatchingEndComment(startComment, allowUnbalanced?) {\n const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced)\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) {\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling\n }\n return startComment.nextSibling\n } else {\n return null\n } // Must have no matching end comment, and allowUnbalanced is true\n}\n\nfunction getUnbalancedChildTags(node) {\n // e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>\n // from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->\n let childNode = node.firstChild,\n captureRemaining: any = null\n if (childNode) {\n do {\n if (captureRemaining) {\n // We already hit an unbalanced node and are now just scooping up all subsequent nodes\n captureRemaining.push(childNode)\n } else if (isStartComment(childNode)) {\n const matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true)\n if (matchingEndComment) {\n // It's a balanced tag, so skip immediately to the end of this virtual set\n childNode = matchingEndComment\n } else {\n captureRemaining = [childNode]\n } // It's unbalanced, so start capturing from this point\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode] // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing\n }\n } while ((childNode = childNode.nextSibling))\n }\n return captureRemaining\n}\n\nexport interface VirtualElementsAllowedBindings {\n text: boolean\n foreach: boolean\n if: boolean\n ifnot: boolean\n with: boolean\n let: boolean\n using: boolean\n template: boolean\n component: boolean\n}\n\nexport const allowedBindings: VirtualElementsAllowedBindings = Object.create(null)\nexport const hasBindingValue = isStartComment\n\nexport function childNodes(node: Node): any {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes\n}\n\nexport function emptyNode(node: Node) {\n if (!isStartComment(node)) {\n emptyDomNode(node)\n } else {\n const virtualChildren = childNodes(node)\n for (let i = 0, j = virtualChildren.length; i < j; i++) {\n removeNode(virtualChildren[i])\n }\n }\n}\n\nexport function setDomNodeChildren(node: Node, childNodes: Node[]) {\n if (!isStartComment(node)) {\n setRegularDomNodeChildren(node, childNodes)\n } else {\n emptyNode(node)\n const endCommentNode = node.nextSibling // Must be the next sibling, as we just emptied the children\n if (endCommentNode && endCommentNode.parentNode) {\n const parentNode = endCommentNode.parentNode\n for (let i = 0, j = childNodes.length; i < j; ++i) {\n parentNode.insertBefore(childNodes[i], endCommentNode)\n }\n }\n }\n}\n\nexport function prepend(containerNode: Node, nodeToPrepend: Node) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) {\n containerNode.insertBefore(nodeToPrepend, containerNode.firstChild)\n } else {\n containerNode.appendChild(nodeToPrepend)\n }\n } else {\n // Start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToPrepend, containerNode.nextSibling)\n }\n}\n\nexport function insertAfter(containerNode: Node, nodeToInsert: Node, insertAfterNode: Node) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert)\n } else if (!isStartComment(containerNode)) {\n // Insert after insertion point\n if (insertAfterNode.nextSibling) {\n containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n } else {\n containerNode.appendChild(nodeToInsert)\n }\n } else {\n // Children of start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n }\n}\n\nexport function firstChild(node: Node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error('Found invalid end comment, as the first child of ' + (node as Element).outerHTML)\n }\n return node.firstChild\n }\n if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null\n }\n return node.nextSibling\n}\n\nexport function lastChild(node: Node) {\n let nextChild = firstChild(node)\n if (!nextChild) return null\n\n let lastChildNode\n\n do {\n lastChildNode = nextChild\n } while ((nextChild = nextSibling(nextChild)))\n\n return lastChildNode\n}\n\nexport function nextSibling(node: Node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node)\n }\n\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error(\n 'Found end comment without a matching opening comment, as next sibling of ' + (node as Element).outerHTML\n )\n }\n return null\n } else {\n return node.nextSibling\n }\n}\n\nexport function previousSibling(node) {\n let depth = 0\n do {\n if (node.nodeType === Node.COMMENT_NODE) {\n if (isStartComment(node)) {\n if (--depth === 0) {\n return node\n }\n } else if (isEndComment(node)) {\n depth++\n }\n } else {\n if (depth === 0) {\n return node\n }\n }\n } while ((node = node.previousSibling))\n}\n\nexport function virtualNodeBindingValue(node): string | null {\n const regexMatch = node.nodeValue.match(startCommentRegex) as RegExpMatchArray\n return regexMatch ? regexMatch[1] : null\n}\n\nexport function normaliseVirtualElementDomStructure(elementVerified) {\n // Workaround for https://github.com/SteveSanderson/knockout/issues/155\n // (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes\n // that are direct descendants of <ul> into the preceding <li>)\n if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {\n return\n }\n\n // Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags\n // must be intended to appear *after* that child, so move them there.\n let childNode = elementVerified.firstChild\n if (childNode) {\n do {\n if (childNode.nodeType === Node.ELEMENT_NODE) {\n const unbalancedTags = getUnbalancedChildTags(childNode)\n if (unbalancedTags) {\n // Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child\n const nodeToInsertBefore = childNode.nextSibling\n for (let i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) {\n elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore)\n } else {\n elementVerified.appendChild(unbalancedTags[i])\n }\n }\n }\n }\n } while ((childNode = childNode.nextSibling))\n }\n}\n"], | ||
| "mappings": ";;AAaA,SAAS,cAAc,sBAAsB,iCAAiC;AAC9E,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,YAAY,aAAa;AAGlB,aAAM,oBAAoB;AAC1B,aAAM,kBAAkB;AAC/B,MAAM,wCAAwC,EAAE,IAAI,MAAM,IAAI,KAAK;AAE5D,gBAAS,eAAe,MAAM;AACnC,SAAO,KAAK,aAAa,KAAK,gBAAgB,kBAAkB,KAAK,KAAK,SAAS;AACrF;AAEO,gBAAS,aAAa,MAAM;AACjC,SAAO,KAAK,aAAa,KAAK,gBAAgB,gBAAgB,KAAK,KAAK,SAAS;AACnF;AAEA,SAAS,sBAAsB,MAAM;AACnC,SAAO,aAAa,IAAI,KAAK,CAAC,QAAQ,IAAI,MAAM,wBAAwB;AAC1E;AAEA,MAAM,2BAA2B;AAE1B,gBAAS,mBAAmB,cAAc,iBAAkB;AACjE,MAAI,cAAc;AAClB,MAAI,QAAQ;AACZ,QAAM,WAAW,IAAI,MAAM;AAC3B,SAAQ,cAAc,YAAY,aAAc;AAC9C,QAAI,aAAa,WAAW,GAAG;AAC7B,cAAQ,IAAI,aAAa,0BAA0B,IAAI;AACvD;AACA,UAAI,UAAU,GAAG;AACf,eAAO;AAAA,MACT;AAAA,IACF;AAEA,aAAS,KAAK,WAAW;AAEzB,QAAI,eAAe,WAAW,GAAG;AAC/B;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI,MAAM,+CAA+C,aAAa,SAAS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AI,oBAAoB;AACtB,8BAAgB,aAAa,eAAe,CAAC,GAAG,kBAAkB;AAAA,YACpE,OAAO;AACL,8BAAgB,YAAY,eAAe,CAAC,CAAC;AAAA,YAC/C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAU,YAAY,UAAU;AAAA,EAClC;AACF;", | ||
| "names": ["childNodes"] | ||
| } |
+2
-2
@@ -1,4 +0,4 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import options from "./options"; | ||
| import options from "./options.js"; | ||
| export function catchFunctionErrors(delegate) { | ||
@@ -5,0 +5,0 @@ if (!options.onError) { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ function testOverwrite() { |
+67
-35
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 CommonJS | ||
| // @tko/utils 🥊 4.0.1 CommonJS | ||
| "use strict"; | ||
@@ -7,2 +7,3 @@ var __defProp = Object.defineProperty; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __export = (target, all) => { | ||
@@ -21,2 +22,3 @@ for (var name in all) | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
@@ -26,2 +28,3 @@ // index.ts | ||
| __export(index_exports, { | ||
| Options: () => Options, | ||
| addCleaner: () => addCleaner, | ||
@@ -49,2 +52,3 @@ addDisposeCallback: () => addDisposeCallback, | ||
| deferError: () => deferError, | ||
| defineOption: () => defineOption, | ||
| domData: () => data_exports, | ||
@@ -264,26 +268,29 @@ domNodeIsAttachedToDocument: () => domNodeIsAttachedToDocument, | ||
| // The following options can be set on ko.options to make a function rewriting or something similar. | ||
| this.bindingStringPreparsers = []; | ||
| __publicField(this, "bindingStringPreparsers", []); | ||
| // Reference to the own knockout instance | ||
| this.knockoutInstance = null; | ||
| this.deferUpdates = false; | ||
| __publicField(this, "knockoutInstance", null); | ||
| __publicField(this, "deferUpdates", false); | ||
| // Don't set this false, with jquery 3.7+ | ||
| this.useOnlyNativeEvents = true; | ||
| __publicField(this, "useOnlyNativeEvents", true); | ||
| // Use HTML5 <template> tags if is supported | ||
| this.useTemplateTag = true; | ||
| this.protoProperty = "__ko_proto__"; | ||
| __publicField(this, "useTemplateTag", true); | ||
| __publicField(this, "protoProperty", "__ko_proto__"); | ||
| // Modify the default attribute from `data-bind`. | ||
| this.defaultBindingAttribute = "data-bind"; | ||
| __publicField(this, "defaultBindingAttribute", "data-bind"); | ||
| // Enable/disable <!-- ko binding: ... -> style bindings | ||
| this.allowVirtualElements = true; | ||
| __publicField(this, "allowVirtualElements", true); | ||
| // Global variables that can be accessed from bindings. | ||
| this.bindingGlobals = /* @__PURE__ */ Object.create(null); | ||
| __publicField(this, "bindingGlobals", /* @__PURE__ */ Object.create(null)); | ||
| // An instance of the binding provider. | ||
| __publicField(this, "bindingProviderInstance"); | ||
| // Whether the `with` binding creates a child context when used with `as`. | ||
| this.createChildContextWithAs = false; | ||
| __publicField(this, "createChildContextWithAs", false); | ||
| // jQuery will be automatically set to globalThis.jQuery in applyBindings | ||
| // if it is (strictly equal to) undefined. Set it to true to | ||
| // disable automatically setting jQuery. | ||
| this.disableJQueryUsage = false; | ||
| this.Promise = globalThis.Promise; | ||
| this.taskScheduler = null; | ||
| this.debug = false; | ||
| __publicField(this, "disableJQueryUsage", false); | ||
| __publicField(this, "_jQuery"); | ||
| __publicField(this, "Promise", globalThis.Promise); | ||
| __publicField(this, "taskScheduler", null); | ||
| __publicField(this, "debug", false); | ||
| /** | ||
@@ -293,3 +300,3 @@ * The maximum size of template to parse. | ||
| */ | ||
| this.templateSizeLimit = 4096; | ||
| __publicField(this, "templateSizeLimit", 4096); | ||
| /** | ||
@@ -300,16 +307,16 @@ * Whether or not to allow script tags in templates. | ||
| */ | ||
| this.allowScriptTagsInTemplates = false; | ||
| this._sanitizeWarningLogged = false; | ||
| this.global = globalThis; | ||
| this.document = globalThis.document; | ||
| __publicField(this, "allowScriptTagsInTemplates", false); | ||
| __publicField(this, "_sanitizeWarningLogged", false); | ||
| __publicField(this, "global", globalThis); | ||
| __publicField(this, "document", globalThis.document); | ||
| // Filters for bindings | ||
| // data-bind="expression | filter_1 | filter_2" | ||
| this.filters = {}; | ||
| __publicField(this, "filters", {}); | ||
| // Used by the template binding. | ||
| this.includeDestroyed = false; | ||
| this.foreachHidesDestroyed = false; | ||
| __publicField(this, "includeDestroyed", false); | ||
| __publicField(this, "foreachHidesDestroyed", false); | ||
| } | ||
| get jQuery() { | ||
| var _a; | ||
| if (this.disableJQueryUsage) return; | ||
| if (this.disableJQueryUsage) return void 0; | ||
| return (_a = this._jQuery) != null ? _a : globalThis.jQuery; | ||
@@ -360,2 +367,19 @@ } | ||
| var options = new Options(); | ||
| function defineOption(name, config) { | ||
| var _a; | ||
| let _value = config.default; | ||
| Object.defineProperty(options, name, { | ||
| get() { | ||
| return _value; | ||
| }, | ||
| set(value) { | ||
| var _a2; | ||
| _value = value; | ||
| (_a2 = config.set) == null ? void 0 : _a2.call(config, value); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| (_a = config.set) == null ? void 0 : _a.call(config, _value); | ||
| } | ||
| var options_default = options; | ||
@@ -1393,15 +1417,23 @@ | ||
| var nextIndexToProcess = 0; | ||
| var w = options_default.global; | ||
| if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) { | ||
| options_default.taskScheduler = (function(callback) { | ||
| const div = w.document.createElement("div"); | ||
| new w.MutationObserver(callback).observe(div, { attributes: true }); | ||
| return function() { | ||
| div.classList.toggle("foo"); | ||
| var schedulerGlobal = options_default.global; | ||
| if (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === "function") { | ||
| options_default.taskScheduler = (callback) => schedulerGlobal.queueMicrotask(callback); | ||
| } else if (schedulerGlobal && schedulerGlobal.MutationObserver && schedulerGlobal.document && !(schedulerGlobal.navigator && schedulerGlobal.navigator.standalone)) { | ||
| options_default.taskScheduler = (function() { | ||
| let scheduledCallback = null; | ||
| let toggle = false; | ||
| const div = schedulerGlobal.document.createElement("div"); | ||
| new schedulerGlobal.MutationObserver(function() { | ||
| const callback = scheduledCallback; | ||
| scheduledCallback = null; | ||
| callback == null ? void 0 : callback(); | ||
| }).observe(div, { attributes: true }); | ||
| return function(callback) { | ||
| scheduledCallback = callback; | ||
| toggle = !toggle; | ||
| div.setAttribute("data-task-scheduler", toggle ? "1" : "0"); | ||
| }; | ||
| })(scheduledProcess); | ||
| })(); | ||
| } else { | ||
| options_default.taskScheduler = function(callback) { | ||
| setTimeout(callback, 0); | ||
| }; | ||
| options_default.taskScheduler = (callback) => setTimeout(callback, 0); | ||
| } | ||
@@ -1408,0 +1440,0 @@ function processTasks() { |
+21
-21
@@ -1,23 +0,23 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| export * from "./array"; | ||
| export * from "./async"; | ||
| export * from "./error"; | ||
| export * from "./object"; | ||
| export * from "./function"; | ||
| export * from "./string"; | ||
| export * from "./symbol"; | ||
| export * from "./css"; | ||
| export { default as options } from "./options"; | ||
| export * from "./dom/event"; | ||
| export * from "./dom/info"; | ||
| export * from "./dom/manipulation"; | ||
| export * from "./dom/fixes"; | ||
| export * from "./dom/html"; | ||
| export * from "./dom/disposal"; | ||
| export * from "./dom/selectExtensions"; | ||
| import * as memoization from "./memoization"; | ||
| import * as tasks from "./tasks"; | ||
| import * as virtualElements from "./dom/virtualElements"; | ||
| import * as domData from "./dom/data"; | ||
| export * from "./array.js"; | ||
| export * from "./async.js"; | ||
| export * from "./error.js"; | ||
| export * from "./object.js"; | ||
| export * from "./function.js"; | ||
| export * from "./string.js"; | ||
| export * from "./symbol.js"; | ||
| export * from "./css.js"; | ||
| export { default as options, defineOption, Options } from "./options.js"; | ||
| export * from "./dom/event.js"; | ||
| export * from "./dom/info.js"; | ||
| export * from "./dom/manipulation.js"; | ||
| export * from "./dom/fixes.js"; | ||
| export * from "./dom/html.js"; | ||
| export * from "./dom/disposal.js"; | ||
| export * from "./dom/selectExtensions.js"; | ||
| import * as memoization from "./memoization.js"; | ||
| import * as tasks from "./tasks.js"; | ||
| import * as virtualElements from "./dom/virtualElements.js"; | ||
| import * as domData from "./dom/data.js"; | ||
| export { tasks, virtualElements, domData, memoization }; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts"], | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './error'\nexport * from './object'\nexport * from './function'\nexport * from './string'\nexport * from './symbol'\nexport * from './css'\nexport { default as options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,eAAe;AAGnC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './error'\nexport * from './object'\nexport * from './function'\nexport * from './string'\nexport * from './symbol'\nexport * from './css'\nexport { default as options, defineOption, Options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,SAAS,cAAc,eAAe;AAG1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "names": [] | ||
| } |
+21
-21
@@ -1,23 +0,23 @@ | ||
| // @tko/utils 🥊 4.0.0 MJS | ||
| // @tko/utils 🥊 4.0.1 MJS | ||
| "use strict"; | ||
| export * from "./array"; | ||
| export * from "./async"; | ||
| export * from "./error"; | ||
| export * from "./object"; | ||
| export * from "./function"; | ||
| export * from "./string"; | ||
| export * from "./symbol"; | ||
| export * from "./css"; | ||
| export { default as options } from "./options"; | ||
| export * from "./dom/event"; | ||
| export * from "./dom/info"; | ||
| export * from "./dom/manipulation"; | ||
| export * from "./dom/fixes"; | ||
| export * from "./dom/html"; | ||
| export * from "./dom/disposal"; | ||
| export * from "./dom/selectExtensions"; | ||
| import * as memoization from "./memoization"; | ||
| import * as tasks from "./tasks"; | ||
| import * as virtualElements from "./dom/virtualElements"; | ||
| import * as domData from "./dom/data"; | ||
| export * from "./array.js"; | ||
| export * from "./async.js"; | ||
| export * from "./error.js"; | ||
| export * from "./object.js"; | ||
| export * from "./function.js"; | ||
| export * from "./string.js"; | ||
| export * from "./symbol.js"; | ||
| export * from "./css.js"; | ||
| export { default as options, defineOption, Options } from "./options.js"; | ||
| export * from "./dom/event.js"; | ||
| export * from "./dom/info.js"; | ||
| export * from "./dom/manipulation.js"; | ||
| export * from "./dom/fixes.js"; | ||
| export * from "./dom/html.js"; | ||
| export * from "./dom/disposal.js"; | ||
| export * from "./dom/selectExtensions.js"; | ||
| import * as memoization from "./memoization.js"; | ||
| import * as tasks from "./tasks.js"; | ||
| import * as virtualElements from "./dom/virtualElements.js"; | ||
| import * as domData from "./dom/data.js"; | ||
| export { tasks, virtualElements, domData, memoization }; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts"], | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './error'\nexport * from './object'\nexport * from './function'\nexport * from './string'\nexport * from './symbol'\nexport * from './css'\nexport { default as options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,eAAe;AAGnC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './error'\nexport * from './object'\nexport * from './function'\nexport * from './string'\nexport * from './symbol'\nexport * from './css'\nexport { default as options, defineOption, Options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,SAAS,cAAc,eAAe;AAG1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "names": [] | ||
| } |
@@ -1,4 +0,4 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import { arrayPushAll } from "./array"; | ||
| import { arrayPushAll } from "./array.js"; | ||
| const memos = {}; | ||
@@ -5,0 +5,0 @@ function randomMax8HexChars() { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export function hasOwnProperty(obj, propName) { |
+65
-49
@@ -1,55 +0,33 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| export class Options { | ||
| constructor() { | ||
| // The following options can be set on ko.options to make a function rewriting or something similar. | ||
| this.bindingStringPreparsers = []; | ||
| // Reference to the own knockout instance | ||
| this.knockoutInstance = null; | ||
| this.deferUpdates = false; | ||
| // Don't set this false, with jquery 3.7+ | ||
| this.useOnlyNativeEvents = true; | ||
| // Use HTML5 <template> tags if is supported | ||
| this.useTemplateTag = true; | ||
| this.protoProperty = "__ko_proto__"; | ||
| // Modify the default attribute from `data-bind`. | ||
| this.defaultBindingAttribute = "data-bind"; | ||
| // Enable/disable <!-- ko binding: ... -> style bindings | ||
| this.allowVirtualElements = true; | ||
| // Global variables that can be accessed from bindings. | ||
| this.bindingGlobals = /* @__PURE__ */ Object.create(null); | ||
| // Whether the `with` binding creates a child context when used with `as`. | ||
| this.createChildContextWithAs = false; | ||
| // jQuery will be automatically set to globalThis.jQuery in applyBindings | ||
| // if it is (strictly equal to) undefined. Set it to true to | ||
| // disable automatically setting jQuery. | ||
| this.disableJQueryUsage = false; | ||
| this.Promise = globalThis.Promise; | ||
| this.taskScheduler = null; | ||
| this.debug = false; | ||
| /** | ||
| * The maximum size of template to parse. | ||
| * Set to 0 to disable the limit. | ||
| */ | ||
| this.templateSizeLimit = 4096; | ||
| /** | ||
| * Whether or not to allow script tags in templates. | ||
| * If false, an error will be thrown if a script tag is detected in the template. | ||
| * It is not recommended to set this to true. | ||
| */ | ||
| this.allowScriptTagsInTemplates = false; | ||
| this._sanitizeWarningLogged = false; | ||
| this.global = globalThis; | ||
| this.document = globalThis.document; | ||
| // Filters for bindings | ||
| // data-bind="expression | filter_1 | filter_2" | ||
| this.filters = {}; | ||
| // Used by the template binding. | ||
| this.includeDestroyed = false; | ||
| this.foreachHidesDestroyed = false; | ||
| } | ||
| // The following options can be set on ko.options to make a function rewriting or something similar. | ||
| bindingStringPreparsers = []; | ||
| // Reference to the own knockout instance | ||
| knockoutInstance = null; | ||
| deferUpdates = false; | ||
| // Don't set this false, with jquery 3.7+ | ||
| useOnlyNativeEvents = true; | ||
| // Use HTML5 <template> tags if is supported | ||
| useTemplateTag = true; | ||
| protoProperty = "__ko_proto__"; | ||
| // Modify the default attribute from `data-bind`. | ||
| defaultBindingAttribute = "data-bind"; | ||
| // Enable/disable <!-- ko binding: ... -> style bindings | ||
| allowVirtualElements = true; | ||
| // Global variables that can be accessed from bindings. | ||
| bindingGlobals = /* @__PURE__ */ Object.create(null); | ||
| // An instance of the binding provider. | ||
| bindingProviderInstance; | ||
| // Whether the `with` binding creates a child context when used with `as`. | ||
| createChildContextWithAs = false; | ||
| // jQuery will be automatically set to globalThis.jQuery in applyBindings | ||
| // if it is (strictly equal to) undefined. Set it to true to | ||
| // disable automatically setting jQuery. | ||
| disableJQueryUsage = false; | ||
| get jQuery() { | ||
| if (this.disableJQueryUsage) return; | ||
| if (this.disableJQueryUsage) return void 0; | ||
| return this._jQuery ?? globalThis.jQuery; | ||
| } | ||
| _jQuery; | ||
| /** | ||
@@ -68,3 +46,18 @@ * Set jQuery manuall to be used by TKO. | ||
| } | ||
| Promise = globalThis.Promise; | ||
| taskScheduler = null; | ||
| debug = false; | ||
| /** | ||
| * The maximum size of template to parse. | ||
| * Set to 0 to disable the limit. | ||
| */ | ||
| templateSizeLimit = 4096; | ||
| /** | ||
| * Whether or not to allow script tags in templates. | ||
| * If false, an error will be thrown if a script tag is detected in the template. | ||
| * It is not recommended to set this to true. | ||
| */ | ||
| allowScriptTagsInTemplates = false; | ||
| _sanitizeWarningLogged = false; | ||
| /** | ||
| * Sanitize HTML templates before parsing them. Default is a no-op. | ||
@@ -84,2 +77,10 @@ * Please configure something like DOMPurify or validator.js for your environment. | ||
| } | ||
| global = globalThis; | ||
| document = globalThis.document; | ||
| // Filters for bindings | ||
| // data-bind="expression | filter_1 | filter_2" | ||
| filters = {}; | ||
| // Used by the template binding. | ||
| includeDestroyed = false; | ||
| foreachHidesDestroyed = false; | ||
| onError(e, throws = true) { | ||
@@ -100,2 +101,17 @@ if (throws) throw e; | ||
| const options = new Options(); | ||
| export function defineOption(name, config) { | ||
| let _value = config.default; | ||
| Object.defineProperty(options, name, { | ||
| get() { | ||
| return _value; | ||
| }, | ||
| set(value) { | ||
| _value = value; | ||
| config.set?.(value); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| config.set?.(_value); | ||
| } | ||
| export default options; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/options.ts"], | ||
| "sourcesContent": ["import { Provider } from '@tko/provider'\nimport type { KnockoutInstance } from '@tko/builder'\n\nexport interface CustomBindingGlobalProperties {\n [customBindingName: string]: any\n}\n\nexport type BindingStringPreparsersFunction = (bindingString: string) => string\n\n//\n// This becomes ko.options\n// --\n//\n// This is the root 'options', which must be extended by others.\nexport class Options {\n // The following options can be set on ko.options to make a function rewriting or something similar.\n bindingStringPreparsers: BindingStringPreparsersFunction[] = []\n\n // Reference to the own knockout instance\n knockoutInstance: KnockoutInstance | null = null\n\n deferUpdates: boolean = false\n\n // Don't set this false, with jquery 3.7+\n useOnlyNativeEvents: boolean = true\n\n // Use HTML5 <template> tags if is supported\n useTemplateTag: boolean = true\n\n protoProperty: string = '__ko_proto__'\n\n // Modify the default attribute from `data-bind`.\n defaultBindingAttribute: string = 'data-bind'\n\n // Enable/disable <!-- ko binding: ... -> style bindings\n allowVirtualElements: boolean = true\n\n // Global variables that can be accessed from bindings.\n bindingGlobals: object & CustomBindingGlobalProperties = Object.create(null)\n\n // An instance of the binding provider.\n bindingProviderInstance: Provider\n\n // Whether the `with` binding creates a child context when used with `as`.\n createChildContextWithAs: boolean = false\n\n // jQuery will be automatically set to globalThis.jQuery in applyBindings\n // if it is (strictly equal to) undefined. Set it to true to\n // disable automatically setting jQuery.\n disableJQueryUsage: boolean = false\n\n get jQuery(): JQueryStatic | undefined {\n if (this.disableJQueryUsage) return\n return this._jQuery ?? (globalThis as any).jQuery\n }\n\n private _jQuery: JQueryStatic | undefined\n /**\n * Set jQuery manuall to be used by TKO.\n * @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.\n */\n set jQuery(jQuery: JQueryStatic | undefined) {\n if (!jQuery) {\n this.disableJQueryUsage = true\n this._jQuery = undefined\n } else {\n this._jQuery = jQuery\n this.disableJQueryUsage = false\n }\n }\n\n Promise: PromiseConstructor = globalThis.Promise\n\n taskScheduler: any = null\n\n debug: boolean = false\n /**\n * The maximum size of template to parse.\n * Set to 0 to disable the limit.\n */\n templateSizeLimit: number = 4096\n\n /**\n * Whether or not to allow script tags in templates.\n * If false, an error will be thrown if a script tag is detected in the template.\n * It is not recommended to set this to true.\n */\n allowScriptTagsInTemplates: boolean = false\n\n private _sanitizeWarningLogged: boolean = false\n /**\n * Sanitize HTML templates before parsing them. Default is a no-op.\n * Please configure something like DOMPurify or validator.js for your environment.\n * @param html HTML string to be sanitized\n * @returns Sanitized HTML string\n */\n sanitizeHtmlTemplate(html: string): string {\n if (!this._sanitizeWarningLogged) {\n console.warn(\n \"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities.\"\n )\n this._sanitizeWarningLogged = true\n }\n return html\n }\n\n global: any = globalThis\n\n document: Document = globalThis.document\n\n // Filters for bindings\n // data-bind=\"expression | filter_1 | filter_2\"\n filters: any = {}\n\n // Used by the template binding.\n includeDestroyed: boolean = false\n\n foreachHidesDestroyed: boolean = false\n\n onError(e: any, throws: boolean = true): typeof e {\n if (throws) throw e\n return e\n }\n\n set(name: string, value: any): void {\n this[name] = value\n }\n\n // Overload getBindingHandler to have a custom lookup function.\n getBindingHandler(key: string): any {\n return null\n }\n cleanExternalData(node: Node, callback?: Function) {}\n}\n\nconst options = new Options()\n\nexport default options\n"], | ||
| "mappings": ";;AAcO,aAAM,QAAQ;AAAA,EAAd;AAEL;AAAA,mCAA6D,CAAC;AAG9D;AAAA,4BAA4C;AAE5C,wBAAwB;AAGxB;AAAA,+BAA+B;AAG/B;AAAA,0BAA0B;AAE1B,yBAAwB;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'@tko/provider'\nimport type { KnockoutInstance } from '@tko/builder'\n\nexport interface CustomBindingGlobalProperties {\n [customBindingName: string]: any\n}\n\nexport type BindingStringPreparsersFunction = (bindingString: string) => string\n\n//\n// This becomes ko.options\n// --\n//\n// This is the root 'options', which must be extended by others.\nexport class Options {\n // The following options can be set on ko.options to make a function rewriting or something similar.\n bindingStringPreparsers: BindingStringPreparsersFunction[] = []\n\n // Reference to the own knockout instance\n knockoutInstance: KnockoutInstance | null = null\n\n deferUpdates: boolean = false\n\n // Don't set this false, with jquery 3.7+\n useOnlyNativeEvents: boolean = true\n\n // Use HTML5 <template> tags if is supported\n useTemplateTag: boolean = true\n\n protoProperty: string = '__ko_proto__'\n\n // Modify the default attribute from `data-bind`.\n defaultBindingAttribute: string = 'data-bind'\n\n // Enable/disable <!-- ko binding: ... -> style bindings\n allowVirtualElements: boolean = true\n\n // Global variables that can be accessed from bindings.\n bindingGlobals: object & CustomBindingGlobalProperties = Object.create(null)\n\n // An instance of the binding provider.\n bindingProviderInstance: Provider\n\n // Whether the `with` binding creates a child context when used with `as`.\n createChildContextWithAs: boolean = false\n\n // jQuery will be automatically set to globalThis.jQuery in applyBindings\n // if it is (strictly equal to) undefined. Set it to true to\n // disable automatically setting jQuery.\n disableJQueryUsage: boolean = false\n\n get jQuery(): JQueryStatic | undefined {\n if (this.disableJQueryUsage) return undefined\n return this._jQuery ?? (globalThis as any).jQuery\n }\n\n private _jQuery: JQueryStatic | undefined\n /**\n * Set jQuery manuall to be used by TKO.\n * @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.\n */\n set jQuery(jQuery: JQueryStatic | undefined) {\n if (!jQuery) {\n this.disableJQueryUsage = true\n this._jQuery = undefined\n } else {\n this._jQuery = jQuery\n this.disableJQueryUsage = false\n }\n }\n\n Promise: PromiseConstructor = globalThis.Promise\n\n taskScheduler: any = null\n\n debug: boolean = false\n /**\n * The maximum size of template to parse.\n * Set to 0 to disable the limit.\n */\n templateSizeLimit: number = 4096\n\n /**\n * Whether or not to allow script tags in templates.\n * If false, an error will be thrown if a script tag is detected in the template.\n * It is not recommended to set this to true.\n */\n allowScriptTagsInTemplates: boolean = false\n\n private _sanitizeWarningLogged: boolean = false\n /**\n * Sanitize HTML templates before parsing them. Default is a no-op.\n * Please configure something like DOMPurify or validator.js for your environment.\n * @param html HTML string to be sanitized\n * @returns Sanitized HTML string\n */\n sanitizeHtmlTemplate(html: string): string {\n if (!this._sanitizeWarningLogged) {\n console.warn(\n \"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities.\"\n )\n this._sanitizeWarningLogged = true\n }\n return html\n }\n\n global: any = globalThis\n\n document: Document = globalThis.document\n\n // Filters for bindings\n // data-bind=\"expression | filter_1 | filter_2\"\n filters: any = {}\n\n // Used by the template binding.\n includeDestroyed: boolean = false\n\n foreachHidesDestroyed: boolean = false\n\n onError(e: any, throws: boolean = true): typeof e {\n if (throws) throw e\n return e\n }\n\n set(name: string, value: any): void {\n this[name] = value\n }\n\n // Overload getBindingHandler to have a custom lookup function.\n getBindingHandler(key: string): any {\n return null\n }\n cleanExternalData(node: Node, callback?: Function) {}\n}\n\nconst options = new Options()\n\n/**\n * Define a custom option on ko.options with an optional side-effect setter.\n * Plugins use this to register their own configuration properties.\n *\n * Must be called before applyBindings \u2014 setters run side effects at\n * configuration time, not retroactively on already-parsed bindings.\n *\n * @example\n * defineOption('strictEquality', {\n * default: false,\n * set(strict) { /* swap operator functions *\\/ }\n * })\n * // Then: ko.options.strictEquality = true\n */\nexport function defineOption<T>(name: string, config: { default: T; set?: (value: T) => void }) {\n let _value = config.default\n Object.defineProperty(options, name, {\n get() {\n return _value\n },\n set(value: T) {\n _value = value\n config.set?.(value)\n },\n enumerable: true,\n configurable: true\n })\n // Run the setter with the default value to initialize side effects\n config.set?.(_value)\n}\n\nexport default options\n"], | ||
| "mappings": ";;AAcO,aAAM,QAAQ;AAAA;AAAA,EAEnB,0BAA6D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EAEA,IAAI,MAAc,OAAkB;AAClC,SAAK,IAAI,IAAI;AAAA,EACf;AAAA;AAAA,EAGA,kBAAkB,KAAkB;AAClC,WAAO;AAAA,EACT;AAAA,EACA,kBAAkB,MAAY,UAAqB;AAAA,EAAC;AACtD;AAEA,MAAM,UAAU,IAAI,QAAQ;AAgBrB,gBAAS,aAAgB,MAAc,QAAkD;AAC9F,MAAI,SAAS,OAAO;AACpB,SAAO,eAAe,SAAS,MAAM;AAAA,IACnC,MAAM;AACJ,aAAO;AAAA,IACT;AAAA,IACA,IAAI,OAAU;AACZ,eAAS;AACT,aAAO,MAAM,KAAK;AAAA,IACpB;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AAED,SAAO,MAAM,MAAM;AACrB;AAEA,eAAe;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export function stringTrim(string) { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export const useSymbols = typeof Symbol === "function"; |
+23
-14
@@ -1,18 +0,27 @@ | ||
| // @tko/utils 🥊 4.0.0 ESM | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| import options from "./options"; | ||
| import { deferError } from "./error"; | ||
| let taskQueue = new Array(), taskQueueLength = 0, nextHandle = 1, nextIndexToProcess = 0, w = options.global; | ||
| if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) { | ||
| options.taskScheduler = (function(callback) { | ||
| const div = w.document.createElement("div"); | ||
| new w.MutationObserver(callback).observe(div, { attributes: true }); | ||
| return function() { | ||
| div.classList.toggle("foo"); | ||
| import options from "./options.js"; | ||
| import { deferError } from "./error.js"; | ||
| let taskQueue = new Array(), taskQueueLength = 0, nextHandle = 1, nextIndexToProcess = 0; | ||
| const schedulerGlobal = options.global; | ||
| if (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === "function") { | ||
| options.taskScheduler = (callback) => schedulerGlobal.queueMicrotask(callback); | ||
| } else if (schedulerGlobal && schedulerGlobal.MutationObserver && schedulerGlobal.document && !(schedulerGlobal.navigator && schedulerGlobal.navigator.standalone)) { | ||
| options.taskScheduler = (function() { | ||
| let scheduledCallback = null; | ||
| let toggle = false; | ||
| const div = schedulerGlobal.document.createElement("div"); | ||
| new schedulerGlobal.MutationObserver(function() { | ||
| const callback = scheduledCallback; | ||
| scheduledCallback = null; | ||
| callback?.(); | ||
| }).observe(div, { attributes: true }); | ||
| return function(callback) { | ||
| scheduledCallback = callback; | ||
| toggle = !toggle; | ||
| div.setAttribute("data-task-scheduler", toggle ? "1" : "0"); | ||
| }; | ||
| })(scheduledProcess); | ||
| })(); | ||
| } else { | ||
| options.taskScheduler = function(callback) { | ||
| setTimeout(callback, 0); | ||
| }; | ||
| options.taskScheduler = (callback) => setTimeout(callback, 0); | ||
| } | ||
@@ -19,0 +28,0 @@ function processTasks() { |
| { | ||
| "version": 3, | ||
| "sources": ["../src/tasks.ts"], | ||
| "sourcesContent": ["//\n// Tasks Micro-scheduler\n// ===\n//\n/* eslint no-cond-assign: 0 */\nimport options from './options'\nimport { deferError } from './error'\n\nlet taskQueue = new Array(),\n taskQueueLength = 0,\n nextHandle = 1,\n nextIndexToProcess = 0,\n w = options.global\n\nif (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {\n // Chrome 27+, Firefox 14+, IE 11+, Opera 15+, Safari 6.1+, node\n // From https://github.com/petkaantonov/bluebird * Copyright (c) 2014 Petka Antonov * License: MIT\n options.taskScheduler = (function (callback) {\n const div = w.document.createElement('div')\n new w.MutationObserver(callback).observe(div, { attributes: true })\n return function () {\n div.classList.toggle('foo')\n }\n })(scheduledProcess)\n} else {\n options.taskScheduler = function (callback) {\n setTimeout(callback, 0)\n }\n}\n\nfunction processTasks() {\n if (taskQueueLength) {\n // Each mark represents the end of a logical group of tasks and the number of these groups is\n // limited to prevent unchecked recursion.\n let mark = taskQueueLength,\n countMarks = 0\n\n // nextIndexToProcess keeps track of where we are in the queue; processTasks can be called recursively without issue\n for (let task; nextIndexToProcess < taskQueueLength; ) {\n if ((task = taskQueue[nextIndexToProcess++])) {\n if (nextIndexToProcess > mark) {\n if (++countMarks >= 5000) {\n nextIndexToProcess = taskQueueLength // skip all tasks remaining in the queue since any of them could be causing the recursion\n deferError(Error(\"'Too much recursion' after processing \" + countMarks + ' task groups.'))\n break\n }\n mark = taskQueueLength\n }\n try {\n task()\n } catch (ex) {\n deferError(ex)\n }\n }\n }\n }\n}\n\nfunction scheduledProcess() {\n processTasks()\n\n // Reset the queue\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n}\n\nfunction scheduleTaskProcessing() {\n options.taskScheduler(scheduledProcess)\n}\n\nexport function schedule(func: () => any): number {\n if (!taskQueueLength) {\n scheduleTaskProcessing()\n }\n\n taskQueue[taskQueueLength++] = func\n return nextHandle++\n}\n\nexport function cancel(handle: number) {\n const index = handle - (nextHandle - taskQueueLength)\n if (index >= nextIndexToProcess && index < taskQueueLength) {\n taskQueue[index] = null\n }\n}\n\n// For testing only: reset the queue and return the previous queue length\nexport function resetForTesting() {\n const length = taskQueueLength - nextIndexToProcess\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n return length\n}\n\nexport { processTasks as runEarly }\n"], | ||
| "mappings": ";;AAKA,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAE3B,IAAI,YAAY,IAAI,MAAM,GACxB,kBAAkB,GAClB,aAAa,GACb,qBAAqB,GACrB,IAAI,QAAQ;AAEd,IAAI,KAAK,EAAE,oBAAoB,EAAE,EAAE,aAAa,EAAE,UAAU,aAAa;AAGvE,UAAQ,iBAAiB,SAAU,UAAU;AAC3C,UAAM,MAAM,EAAE,SAAS,cAAc,KAAK;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/* eslint no-cond-assign: 0 */\nimport options from './options'\nimport { deferError } from './error'\n\nlet taskQueue = new Array(),\n taskQueueLength = 0,\n nextHandle = 1,\n nextIndexToProcess = 0\n\nconst schedulerGlobal = options.global\n\nif (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === 'function') {\n options.taskScheduler = callback => schedulerGlobal.queueMicrotask(callback)\n} else if (\n schedulerGlobal &&\n schedulerGlobal.MutationObserver &&\n schedulerGlobal.document &&\n !(schedulerGlobal.navigator && schedulerGlobal.navigator.standalone)\n) {\n options.taskScheduler = (function () {\n let scheduledCallback: null | (() => void) = null\n let toggle = false\n const div = schedulerGlobal.document.createElement('div')\n\n new schedulerGlobal.MutationObserver(function () {\n const callback = scheduledCallback\n scheduledCallback = null\n callback?.()\n }).observe(div, { attributes: true })\n\n return function (callback: () => void) {\n scheduledCallback = callback\n toggle = !toggle\n div.setAttribute('data-task-scheduler', toggle ? '1' : '0')\n }\n })()\n} else {\n options.taskScheduler = callback => setTimeout(callback, 0)\n}\n\nfunction processTasks() {\n if (taskQueueLength) {\n // Each mark represents the end of a logical group of tasks and the number of these groups is\n // limited to prevent unchecked recursion.\n let mark = taskQueueLength,\n countMarks = 0\n\n // nextIndexToProcess keeps track of where we are in the queue; processTasks can be called recursively without issue\n for (let task; nextIndexToProcess < taskQueueLength; ) {\n if ((task = taskQueue[nextIndexToProcess++])) {\n if (nextIndexToProcess > mark) {\n if (++countMarks >= 5000) {\n nextIndexToProcess = taskQueueLength // skip all tasks remaining in the queue since any of them could be causing the recursion\n deferError(Error(\"'Too much recursion' after processing \" + countMarks + ' task groups.'))\n break\n }\n mark = taskQueueLength\n }\n try {\n task()\n } catch (ex) {\n deferError(ex)\n }\n }\n }\n }\n}\n\nfunction scheduledProcess() {\n processTasks()\n\n // Reset the queue\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n}\n\nfunction scheduleTaskProcessing() {\n options.taskScheduler(scheduledProcess)\n}\n\nexport function schedule(func: () => any): number {\n if (!taskQueueLength) {\n scheduleTaskProcessing()\n }\n\n taskQueue[taskQueueLength++] = func\n return nextHandle++\n}\n\nexport function cancel(handle: number) {\n const index = handle - (nextHandle - taskQueueLength)\n if (index >= nextIndexToProcess && index < taskQueueLength) {\n taskQueue[index] = null\n }\n}\n\n// For testing only: reset the queue and return the previous queue length\nexport function resetForTesting() {\n const length = taskQueueLength - nextIndexToProcess\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n return length\n}\n\nexport { processTasks as runEarly }\n"], | ||
| "mappings": ";;AAKA,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAE3B,IAAI,YAAY,IAAI,MAAM,GACxB,kBAAkB,GAClB,aAAa,GACb,qBAAqB;AAEvB,MAAM,kBAAkB,QAAQ;AAEhC,IAAI,mBAAmB,OAAO,gBAAgB,mBAAmB,YAAY;AAC3E,UAAQ,gBAAgB,cAAY,gBAAgB,eAAe,QAAQ;AAC7E,WACE,mBACA,gBAAgB,oBAChB,gBAAgB,YAChB,EAAE,gBAAgB,aAAa,gBAAgB,UAAU,aACzD;AACA,UAAQ,iBAAiB,WAAY;AACnC,QAAI,oBAAyC;AAC7C,QAAI,SAAS;AACb,UAAM,MAAM,gBAAgB,SAAS,cAAc,KAAK;AAExD,QAAI,gBAAgB,iBAAiB,WAAY;AAC/C,YAAM,WAAW;AACjB,0BAAoB;AACpB,iBAAW;AAAA,IACb,CAAC,EAAE,QAAQ,KAAK,EAAE,YAAY,KAAK,CAAC;AAEpC,WAAO,SAAU,UAAsB;AACrC,0BAAoB;AACpB,eAAS,CAAC;AACV,UAAI,aAAa,uBAAuB,SAAS,MAAM,GAAG;AAAA,IAC5D;AAAA,EACF,GAAG;AACL,OAAO;AACL,UAAQ,gBAAgB,cAAY,WAAW,UAAU,CAAC;AAC5D;AAEA,SAAS,eAAe;AACtB,MAAI,iBAAiB;AAGnB,QAAI,OAAO,iBACT,aAAa;AAGf,aAAS,MAAM,qBAAqB,mBAAmB;AACrD,UAAK,OAAO,UAAU,oBAAoB,GAAI;AAC5C,YAAI,qBAAqB,MAAM;AAC7B,cAAI,EAAE,cAAc,KAAM;AACxB,iCAAqB;AACrB,uBAAW,MAAM,2CAA2C,aAAa,eAAe,CAAC;AACzF;AAAA,UACF;AACA,iBAAO;AAAA,QACT;AACA,YAAI;AACF,eAAK;AAAA,QACP,SAAS,IAAI;AACX,qBAAW,EAAE;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,mBAAmB;AAC1B,eAAa;AAGb,uBAAqB,kBAAkB,UAAU,SAAS;AAC5D;AAEA,SAAS,yBAAyB;AAChC,UAAQ,cAAc,gBAAgB;AACxC;AAEO,gBAAS,SAAS,MAAyB;AAChD,MAAI,CAAC,iBAAiB;AACpB,2BAAuB;AAAA,EACzB;AAEA,YAAU,iBAAiB,IAAI;AAC/B,SAAO;AACT;AAEO,gBAAS,OAAO,QAAgB;AACrC,QAAM,QAAQ,UAAU,aAAa;AACrC,MAAI,SAAS,sBAAsB,QAAQ,iBAAiB;AAC1D,cAAU,KAAK,IAAI;AAAA,EACrB;AACF;AAGO,gBAAS,kBAAkB;AAChC,QAAM,SAAS,kBAAkB;AACjC,uBAAqB,kBAAkB,UAAU,SAAS;AAC1D,SAAO;AACT;AAEA,SAAS,gBAAgB;", | ||
| "names": [] | ||
| } |
+7
-10
| { | ||
| "version": "4.0.0", | ||
| "version": "4.0.1", | ||
| "name": "@tko/utils", | ||
@@ -7,4 +7,3 @@ "description": "TKO Utilities", | ||
| "files": [ | ||
| "dist/", | ||
| "helpers/" | ||
| "dist/" | ||
| ], | ||
@@ -26,7 +25,2 @@ "repository": { | ||
| "homepage": "https://tko.io", | ||
| "karma": { | ||
| "frameworks": [ | ||
| "jasmine" | ||
| ] | ||
| }, | ||
| "dependencies": { | ||
@@ -45,5 +39,8 @@ "tslib": "^2.2.0" | ||
| "import": "./dist/index.js" | ||
| }, | ||
| "./helpers/*": "./helpers/*" | ||
| } | ||
| }, | ||
| "module": "dist/index.js", | ||
| "scripts": { | ||
| "build": "bun ../../tools/build.ts" | ||
| } | ||
| } |
| /// <reference types="jasmine" /> | ||
| import jQuery from 'jquery' | ||
| window.jQuery = jQuery | ||
| /* | ||
| * Configure the Jasmine testing framework. | ||
| */ | ||
| /* globals runs, waitsFor, jasmine */ | ||
| import { arrayMap, arrayFilter, selectExtensions, hasOwnProperty, options } from '../dist/' | ||
| window.DEBUG = true | ||
| window.amdRequire = window.require | ||
| jasmine.updateInterval = 500 | ||
| /* | ||
| Some helper functions for jasmine on the browser | ||
| */ | ||
| jasmine.resolve = function (promise: Promise<boolean>) { | ||
| let complete = false | ||
| runs(() => | ||
| promise.then(result => { | ||
| complete = result || true | ||
| }) | ||
| ) | ||
| waitsFor(() => complete) | ||
| } | ||
| jasmine.prepareTestNode = function (): HTMLElement { | ||
| // The bindings specs make frequent use of this utility function to set up | ||
| // a clean new DOM node they can execute code against | ||
| const existingNode = document.getElementById('testNode') | ||
| if (existingNode !== null && existingNode.parentNode) existingNode.parentNode.removeChild(existingNode) | ||
| const testNode = document.createElement('div') | ||
| testNode.id = 'testNode' | ||
| document.body.appendChild(testNode) | ||
| return testNode | ||
| } | ||
| jasmine.Clock.mockScheduler = function (callback) { | ||
| setTimeout(callback, 0) | ||
| } | ||
| export function useMockForTasks(options) { | ||
| jasmine.Clock.useMock() | ||
| // Make sure tasks is using setTimeout so that it uses the mock clock | ||
| if (options.taskScheduler != jasmine.Clock.mockScheduler) { | ||
| jasmine.getEnv().currentSpec.restoreAfter(options, 'taskScheduler') | ||
| options.taskScheduler = jasmine.Clock.mockScheduler | ||
| } | ||
| } | ||
| jasmine.Spec.prototype.restoreAfter = function (object, propertyName) { | ||
| const originalValue = object[propertyName] | ||
| this.after(function () { | ||
| object[propertyName] = originalValue | ||
| }) | ||
| } | ||
| jasmine.nodeText = function (node) { | ||
| return node.nodeType === Node.TEXT_NODE ? node.data : 'textContent' in node ? node.textContent : node.innerText | ||
| } | ||
| jasmine.browserSupportsProtoAssignment = { __proto__: [] } instanceof Array | ||
| jasmine.setNodeText = function (node, text: string) { | ||
| if ('textContent' in node) { | ||
| node.textContent = text | ||
| } else { | ||
| node.innerText = text | ||
| } | ||
| } | ||
| function cleanedHtml(node) { | ||
| let cleanedHtml = node.innerHTML.toLowerCase().replace(/\r\n/g, '') | ||
| // IE < 9 strips whitespace immediately following comment nodes. Normalize by doing the same on all browsers. | ||
| cleanedHtml = cleanedHtml.replace(/(<!--.*?-->)\s*/g, '$1') | ||
| // Also remove __ko__ expando properties (for DOM data) - most browsers hide these anyway but IE < 9 includes them in innerHTML | ||
| cleanedHtml = cleanedHtml.replace(/ __ko__\d+=\"(ko\d+|null)\"/g, '') | ||
| return cleanedHtml | ||
| } | ||
| /* | ||
| Custom Matchers | ||
| ~~~~~~~~~~~~~~~ | ||
| */ | ||
| const matchers = { | ||
| toHaveNodeTypes(expectedTypes) { | ||
| const values = arrayMap(this.actual, function (node) { | ||
| return node.nodeType | ||
| }) | ||
| this.actual = values // Fix explanatory message | ||
| return this.env.equals_(values, expectedTypes) | ||
| }, | ||
| toContainHtmlElementsAndText(expectedHtml) { | ||
| this.actual = cleanedHtml(this.actual).replace(/<!--.+?-->/g, '') // remove comments | ||
| return this.actual === expectedHtml | ||
| }, | ||
| toContainText(expectedText, ignoreSpaces) { | ||
| if (ignoreSpaces) { | ||
| expectedText = expectedText.replace(/\s/g, '') | ||
| } | ||
| const actualText = jasmine.nodeText(this.actual) | ||
| let cleanedActualText = actualText.replace(/\r\n/g, '\n') | ||
| if (ignoreSpaces) { | ||
| cleanedActualText = cleanedActualText.replace(/\s/g, '') | ||
| } | ||
| this.actual = cleanedActualText // Fix explanatory message | ||
| return cleanedActualText === expectedText | ||
| }, | ||
| toHaveOwnProperties(expectedProperties) { | ||
| const ownProperties = new Array() | ||
| for (const prop in this.actual) { | ||
| if (hasOwnProperty(this.actual, prop)) { | ||
| ownProperties.push(prop) | ||
| } | ||
| } | ||
| return this.env.equals_(ownProperties, expectedProperties) | ||
| }, | ||
| toHaveTexts(expectedTexts) { | ||
| const texts = arrayMap(this.actual.childNodes, jasmine.nodeText) | ||
| this.actual = texts // Fix explanatory message | ||
| return this.env.equals_(texts, expectedTexts) | ||
| }, | ||
| toHaveValues(expectedValues) { | ||
| const values = arrayFilter( | ||
| arrayMap(this.actual.childNodes, node => node.value), | ||
| value => value !== undefined | ||
| ) | ||
| this.actual = values // Fix explanatory message | ||
| return this.env.equals_(values, expectedValues) | ||
| }, | ||
| toHaveCheckedStates(expectedValues) { | ||
| const values = arrayMap(this.actual.childNodes, node => node.checked) | ||
| this.actual = values // Fix explanatory message | ||
| return this.env.equals_(values, expectedValues) | ||
| }, | ||
| toThrowContaining(expected) { | ||
| let exception | ||
| try { | ||
| this.actual() | ||
| } catch (e) { | ||
| exception = e | ||
| } | ||
| const exceptionMessage = exception && (exception.message || exception) | ||
| this.message = function () { | ||
| const notText = this.isNot ? ' not' : '' | ||
| const expectation = | ||
| 'Expected ' + this.actual.toString() + notText + " to throw exception containing '" + expected + "'" | ||
| const result = exception ? ", but it threw '" + exceptionMessage + "'" : ', but it did not throw anything' | ||
| return expectation + result | ||
| } | ||
| return exception ? this.env.contains_(exceptionMessage, expected) : false | ||
| }, | ||
| toEqualOneOf(expectedPossibilities) { | ||
| for (let i = 0; i < expectedPossibilities.length; i++) { | ||
| if (this.env.equals_(this.actual, expectedPossibilities[i])) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| }, | ||
| toContainHtml(expectedHtml, postProcessCleanedHtml) { | ||
| let cleanedHtml = this.actual.innerHTML.toLowerCase().replace(/\r\n/g, '') | ||
| // IE < 9 strips whitespace immediately following comment nodes. Normalize by doing the same on all browsers. | ||
| cleanedHtml = cleanedHtml.replace(/(<!--.*?-->)\s*/g, '$1') | ||
| expectedHtml = expectedHtml.replace(/(<!--.*?-->)\s*/g, '$1') | ||
| // Also remove __ko__ expando properties (for DOM data) - most browsers hide these anyway but IE < 9 includes them in innerHTML | ||
| cleanedHtml = cleanedHtml.replace(/ __ko__\d+=\"(ko\d+|null)\"/g, '') | ||
| if (postProcessCleanedHtml) { | ||
| cleanedHtml = postProcessCleanedHtml(cleanedHtml) | ||
| } | ||
| this.actual = cleanedHtml // Fix explanatory message | ||
| return cleanedHtml === expectedHtml | ||
| }, | ||
| toHaveSelectedValues(expectedValues) { | ||
| const selectedNodes = arrayFilter(this.actual.childNodes, node => node.selected) | ||
| const selectedValues = arrayMap(selectedNodes, node => selectExtensions.readValue(node)) | ||
| this.actual = selectedValues // Fix explanatory message | ||
| return this.env.equals_(selectedValues, expectedValues) | ||
| } | ||
| } | ||
| // | ||
| // bmh: Monkeypatch so we can catch errors in asynchronous functions. | ||
| // | ||
| jasmine.FakeTimer.prototype.runFunctionsWithinRange = function (oldMillis, nowMillis) { | ||
| let scheduledFunc | ||
| const funcsToRun = new Array() | ||
| for (const timeoutKey in this.scheduledFunctions) { | ||
| scheduledFunc = this.scheduledFunctions[timeoutKey] | ||
| if ( | ||
| scheduledFunc != jasmine.undefined | ||
| && scheduledFunc.runAtMillis >= oldMillis | ||
| && scheduledFunc.runAtMillis <= nowMillis | ||
| ) { | ||
| funcsToRun.push(scheduledFunc) | ||
| this.scheduledFunctions[timeoutKey] = jasmine.undefined | ||
| } | ||
| } | ||
| if (funcsToRun.length > 0) { | ||
| funcsToRun.sort(function (a: any, b: any) { | ||
| return a.runAtMillis - b.runAtMillis | ||
| }) | ||
| for (let i = 0; i < funcsToRun.length; ++i) { | ||
| //try { // mbest: Removed so we can catch errors in asynchronous functions | ||
| const funcToRun = funcsToRun[i] | ||
| this.nowMillis = funcToRun.runAtMillis | ||
| funcToRun.funcToCall() | ||
| if (funcToRun.recurring) { | ||
| this.scheduleFunction(funcToRun.timeoutKey, funcToRun.funcToCall, funcToRun.millis, true) | ||
| } | ||
| //} catch(e) { | ||
| //} | ||
| } | ||
| this.runFunctionsWithinRange(oldMillis, nowMillis) | ||
| } | ||
| } | ||
| beforeEach(function () { | ||
| this.addMatchers(matchers) | ||
| switchJQueryState() | ||
| }) | ||
| afterEach(function () { | ||
| expect(disableJQueryUsage).toEqual(options.disableJQueryUsage) | ||
| }) | ||
| const KARMA_STRING = '__karma__' | ||
| let disableJQueryUsage = true | ||
| function switchJQueryState() { | ||
| if (window[KARMA_STRING] && window[KARMA_STRING].config.args.includes('--noJQuery')) { | ||
| options.disableJQueryUsage = disableJQueryUsage = true | ||
| } else { | ||
| options.disableJQueryUsage = disableJQueryUsage = false | ||
| } | ||
| } |
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
7
-12.5%278489
-0.58%47
-2.08%2859
-5.39%