@tko/utils 4.0.0-alpha7.3 → 4.0.0-beta1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +22 -0
  2. package/dist/array.js +156 -0
  3. package/dist/array.js.map +7 -0
  4. package/dist/async.js +20 -0
  5. package/dist/async.js.map +7 -0
  6. package/dist/bind-shim.js +18 -0
  7. package/dist/bind-shim.js.map +7 -0
  8. package/dist/css.js +27 -0
  9. package/dist/css.js.map +7 -0
  10. package/dist/dom/data.js +63 -0
  11. package/dist/dom/data.js.map +7 -0
  12. package/dist/dom/disposal.js +98 -0
  13. package/dist/dom/disposal.js.map +7 -0
  14. package/dist/dom/event.js +87 -0
  15. package/dist/dom/event.js.map +7 -0
  16. package/dist/dom/fixes.js +45 -0
  17. package/dist/dom/fixes.js.map +7 -0
  18. package/dist/dom/html.js +115 -0
  19. package/dist/dom/html.js.map +7 -0
  20. package/dist/dom/info.js +43 -0
  21. package/dist/dom/info.js.map +7 -0
  22. package/dist/dom/manipulation.js +55 -0
  23. package/dist/dom/manipulation.js.map +7 -0
  24. package/dist/dom/selectExtensions.js +62 -0
  25. package/dist/dom/selectExtensions.js.map +7 -0
  26. package/dist/dom/virtualElements.js +202 -0
  27. package/dist/dom/virtualElements.js.map +7 -0
  28. package/dist/error.js +22 -0
  29. package/dist/error.js.map +7 -0
  30. package/dist/function.js +16 -0
  31. package/dist/function.js.map +7 -0
  32. package/dist/ie.js +15 -0
  33. package/dist/ie.js.map +7 -0
  34. package/dist/index.cjs +1448 -0
  35. package/dist/index.cjs.map +7 -0
  36. package/dist/index.js +24 -0
  37. package/dist/index.js.map +7 -0
  38. package/dist/index.mjs +24 -0
  39. package/dist/index.mjs.map +7 -0
  40. package/dist/jquery.js +6 -0
  41. package/dist/jquery.js.map +7 -0
  42. package/dist/memoization.js +64 -0
  43. package/dist/memoization.js.map +7 -0
  44. package/dist/object.js +76 -0
  45. package/dist/object.js.map +7 -0
  46. package/dist/options.js +36 -0
  47. package/dist/options.js.map +7 -0
  48. package/dist/string.js +23 -0
  49. package/dist/string.js.map +7 -0
  50. package/dist/symbol.js +5 -0
  51. package/dist/symbol.js.map +7 -0
  52. package/dist/tasks.js +76 -0
  53. package/dist/tasks.js.map +7 -0
  54. package/helpers/jasmine-13-helper.ts +207 -0
  55. package/package.json +18 -26
  56. package/dist/utils.es6.js +0 -1628
  57. package/dist/utils.es6.js.map +0 -1
  58. package/dist/utils.js +0 -1645
  59. package/dist/utils.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/virtualElements.ts"],
4
+ "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\n// IE 9 cannot reliably read the \"nodeValue\" property of a comment node (see https://github.com/SteveSanderson/knockout/issues/186)\n// but it does give them a nonstandard alternative property called \"text\" that it can read reliably. Other browsers don't have that property.\n// So, use node.text where available, and node.nodeValue elsewhere\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\nvar commentNodesHaveTextProperty = options.document && options.document.createComment('test').text === '<!--test-->'\n\nexport var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*ko(?:\\s+([\\s\\S]+))?\\s*-->$/ : /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/\nexport var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*\\/ko\\s*-->$/ : /^\\s*\\/ko\\s*$/\nvar htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true }\n\nexport function isStartComment (node) {\n return (node.nodeType == 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue)\n}\n\nexport function isEndComment (node) {\n return (node.nodeType == 8) && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : 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 var currentNode = startComment\n var depth = 1\n var children = []\n while (currentNode = currentNode.nextSibling) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true)\n depth--\n if (depth === 0) { return children }\n }\n\n children.push(currentNode)\n\n if (isStartComment(currentNode)) { depth++ }\n }\n if (!allowUnbalanced) { throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue) }\n return null\n}\n\nfunction getMatchingEndComment (startComment, allowUnbalanced) {\n var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced)\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) { return allVirtualChildren[allVirtualChildren.length - 1].nextSibling }\n return startComment.nextSibling\n } else { return null } // 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 var childNode = node.firstChild, captureRemaining = 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 { captureRemaining.push(childNode) } else if (isStartComment(childNode)) {\n var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true)\n if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set\n { childNode = matchingEndComment } else { captureRemaining = [childNode] } // 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 var allowedBindings = {}\nexport var hasBindingValue = isStartComment\n\nexport function childNodes (node) {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes\n}\n\nexport function emptyNode (node) {\n if (!isStartComment(node)) { emptyDomNode(node) } else {\n var virtualChildren = childNodes(node)\n for (var i = 0, j = virtualChildren.length; i < j; i++) { removeNode(virtualChildren[i]) }\n }\n}\n\nexport function setDomNodeChildren (node, childNodes) {\n if (!isStartComment(node)) { setRegularDomNodeChildren(node, childNodes) } else {\n emptyNode(node)\n const endCommentNode = node.nextSibling // Must be the next sibling, as we just emptied the children\n const parentNode = endCommentNode.parentNode\n for (var i = 0, j = childNodes.length; i < j; ++i) {\n parentNode.insertBefore(childNodes[i], endCommentNode)\n }\n }\n}\n\nexport function prepend (containerNode, nodeToPrepend) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) { containerNode.insertBefore(nodeToPrepend, containerNode.firstChild) } else { containerNode.appendChild(nodeToPrepend) }\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, nodeToInsert, insertAfterNode) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert)\n } else if (!isStartComment(containerNode)) {\n // Insert after insertion point\n if (insertAfterNode.nextSibling) { containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling) } else { containerNode.appendChild(nodeToInsert) }\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) {\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.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) {\n let nextChild = firstChild(node)\n let lastChildNode\n\n do {\n lastChildNode = nextChild\n } while (nextChild = nextSibling(nextChild))\n\n return lastChildNode\n}\n\nexport function nextSibling (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('Found end comment without a matching opening comment, as next sibling of ' + node.outerHTML)\n }\n return null\n } else {\n return node.nextSibling\n }\n}\n\nexport function previousSibling (node) {\n var depth = 0\n do {\n if (node.nodeType === 8) {\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) { return node }\n }\n } while (node = node.previousSibling)\n}\n\nexport function virtualNodeBindingValue (node) {\n var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex)\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)]) { return }\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 var childNode = elementVerified.firstChild\n if (childNode) {\n do {\n if (childNode.nodeType === 1) {\n var 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 var nodeToInsertBefore = childNode.nextSibling\n for (var i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) { elementVerified.insertBefore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,8EAA8E,KAAK,SAAS;AAAA,IAC1G;AACA,WAAO;AAAA,EACT,OAAO;AACL,WAAO,KAAK;AAAA,EACd;AACF;AAEO,gCAA0B,MAAM;AACrC,MAAI,QAAQ;AACZ,KAAG;AACD,QAAI,KAAK,aAAa,GAAG;AACvB,UAAI,eAAe,IAAI,GAAG;AACxB,YAAI,EAAE,UAAU,GAAG;AACjB,iBAAO;AAAA,QACT;AAAA,MACF,WAAW,aAAa,IAAI,GAAG;AAC7B;AAAA,MACF;AAAA,IACF,OAAO;AACL,UAAI,UAAU,GAAG;AAAE,eAAO;AAAA,MAAK;AAAA,IACjC;AAAA,EACF,SAAS,OAAO,KAAK;AACvB;AAEO,wCAAkC,MAAM;AAC7C,MAAI,aAAc,gCAA+B,KAAK,OAAO,KAAK,WAAW,MAAM,iBAAiB;AACpG,SAAO,aAAa,WAAW,KAAK;AACtC;AAEO,oDAA8C,iBAAiB;AAIpE,MAAI,CAAC,sCAAsC,aAAa,eAAe,IAAI;AAAE;AAAA,EAAO;AAIpF,MAAI,YAAY,gBAAgB;AAChC,MAAI,WAAW;AACb,OAAG;AACD,UAAI,UAAU,aAAa,GAAG;AAC5B,YAAI,iBAAiB,uBAAuB,SAAS;AACrD,YAAI,gBAAgB;AAElB,cAAI,qBAAqB,UAAU;AACnC,mBAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC9C,gBAAI,oBAAoB;AAAE,8BAAgB,aAAa,eAAe,IAAI,kBAAkB;AAAA,YAAE,OAAO;AAAE,8BAAgB,YAAY,eAAe,EAAE;AAAA,YAAE;AAAA,UACxJ;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,YAAY,UAAU;AAAA,EACjC;AACF;",
6
+ "names": []
7
+ }
package/dist/error.js ADDED
@@ -0,0 +1,22 @@
1
+ // @tko/utils 🥊 4.0.0-beta1.0 ESM
2
+ import options from "./options";
3
+ export function catchFunctionErrors(delegate) {
4
+ if (!options.onError) {
5
+ return delegate;
6
+ }
7
+ return (...args) => {
8
+ try {
9
+ return delegate(...args);
10
+ } catch (err) {
11
+ options.onError(err);
12
+ }
13
+ };
14
+ }
15
+ export function deferError(error) {
16
+ safeSetTimeout(function() {
17
+ throw error;
18
+ }, 0);
19
+ }
20
+ export function safeSetTimeout(handler, timeout) {
21
+ return setTimeout(catchFunctionErrors(handler), timeout);
22
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/error.ts"],
4
+ "sourcesContent": ["//\n// Error handling\n// ---\n//\n// The default onError handler is to re-throw.\nimport options from './options'\n\nexport function catchFunctionErrors (delegate) {\n if (!options.onError) { return delegate }\n return (...args) => {\n try {\n return delegate(...args)\n } catch (err) {\n options.onError(err)\n }\n }\n}\n\nexport function deferError (error) {\n safeSetTimeout(function () { throw error }, 0)\n}\n\nexport function safeSetTimeout (handler, timeout) {\n return setTimeout(catchFunctionErrors(handler), timeout)\n}\n"],
5
+ "mappings": ";AAKA;AAEO,oCAA8B,UAAU;AAC7C,MAAI,CAAC,QAAQ,SAAS;AAAE,WAAO;AAAA,EAAS;AACxC,SAAO,IAAI,SAAS;AAClB,QAAI;AACF,aAAO,SAAS,GAAG,IAAI;AAAA,IACzB,SAAS,KAAP;AACA,cAAQ,QAAQ,GAAG;AAAA,IACrB;AAAA,EACF;AACF;AAEO,2BAAqB,OAAO;AACjC,iBAAe,WAAY;AAAE,UAAM;AAAA,EAAM,GAAG,CAAC;AAC/C;AAEO,+BAAyB,SAAS,SAAS;AAChD,SAAO,WAAW,oBAAoB,OAAO,GAAG,OAAO;AACzD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ // @tko/utils 🥊 4.0.0-beta1.0 ESM
2
+ function testOverwrite() {
3
+ try {
4
+ Object.defineProperty(function x() {
5
+ }, "length", {});
6
+ return true;
7
+ } catch (e) {
8
+ return false;
9
+ }
10
+ }
11
+ export const functionSupportsLengthOverwrite = testOverwrite();
12
+ export function overwriteLengthPropertyIfSupported(fn, descriptor) {
13
+ if (functionSupportsLengthOverwrite) {
14
+ Object.defineProperty(fn, "length", descriptor);
15
+ }
16
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/function.ts"],
4
+ "sourcesContent": ["\nfunction testOverwrite () {\n try {\n Object.defineProperty(function x () {}, 'length', {})\n return true\n } catch (e) {\n return false\n }\n}\n\nexport const functionSupportsLengthOverwrite = testOverwrite()\n\nexport function overwriteLengthPropertyIfSupported (fn, descriptor) {\n if (functionSupportsLengthOverwrite) {\n Object.defineProperty(fn, 'length', descriptor)\n }\n}\n"],
5
+ "mappings": ";AACA,yBAA0B;AACxB,MAAI;AACF,WAAO,eAAe,aAAc;AAAA,IAAC,GAAG,UAAU,CAAC,CAAC;AACpD,WAAO;AAAA,EACT,SAAS,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,aAAM,kCAAkC,cAAc;AAEtD,mDAA6C,IAAI,YAAY;AAClE,MAAI,iCAAiC;AACnC,WAAO,eAAe,IAAI,UAAU,UAAU;AAAA,EAChD;AACF;",
6
+ "names": []
7
+ }
package/dist/ie.js ADDED
@@ -0,0 +1,15 @@
1
+ // @tko/utils 🥊 4.0.0-beta1.0 ESM
2
+ import options from "./options";
3
+ const ieVersion = options.document && function() {
4
+ var version = 3, div = options.document.createElement("div"), iElems = div.getElementsByTagName("i");
5
+ while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
6
+ }
7
+ if (!version) {
8
+ const userAgent = window.navigator.userAgent;
9
+ return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
10
+ }
11
+ return version > 4 ? version : void 0;
12
+ }();
13
+ const isIe6 = ieVersion === 6;
14
+ const isIe7 = ieVersion === 7;
15
+ export { ieVersion, isIe6, isIe7 };
package/dist/ie.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/ie.ts"],
4
+ "sourcesContent": ["//\n// Detection and Workarounds for Internet Explorer\n//\nimport options from './options'\n\nconst ieVersion = options.document && (function () {\n var version = 3, div = options.document.createElement('div'), iElems = div.getElementsByTagName('i')\n\n // Keep constructing conditional HTML blocks until we hit one that resolves to an empty fragment\n while (\n div.innerHTML = '<!--[if gt IE ' + (++version) + ']><i></i><![endif]-->',\n iElems[0]\n ) {}\n\n if (!version) {\n const userAgent = window.navigator.userAgent\n // Detect IE 10/11\n return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/)\n }\n return version > 4 ? version : undefined\n}())\n\nconst isIe6 = ieVersion === 6\nconst isIe7 = ieVersion === 7\n\nexport { ieVersion, isIe6, isIe7 }\n"],
5
+ "mappings": ";AAGA;AAEA,MAAM,YAAY,QAAQ,YAAa,WAAY;AACjD,MAAI,UAAU,GAAG,MAAM,QAAQ,SAAS,cAAc,KAAK,GAAG,SAAS,IAAI,qBAAqB,GAAG;AAGnG,SACM,IAAI,YAAY,mBAAoB,EAAE,UAAW,yBACjD,OAAO,IACT;AAAA,EAAC;AAEL,MAAI,CAAC,SAAS;AACZ,UAAM,YAAY,OAAO,UAAU;AAEnC,WAAO,GAAG,MAAM,cAAc,KAAK,GAAG,MAAM,aAAa;AAAA,EAC3D;AACA,SAAO,UAAU,IAAI,UAAU;AACjC,EAAE;AAEF,MAAM,QAAQ,cAAc;AAC5B,MAAM,QAAQ,cAAc;AAE5B;",
6
+ "names": []
7
+ }