From b0962ebac66982003c878a8f95d018f73970bf61 Mon Sep 17 00:00:00 2001 From: David Graham Date: Mon, 23 Mar 2020 11:33:17 -0600 Subject: [PATCH 01/18] Add mocha test suite Co-authored-by: Keith Cirkel --- .gitignore | 2 -- catalyst/test/test.js | 16 ++++++++++++++++ package.json | 5 ++++- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 catalyst/test/test.js diff --git a/.gitignore b/.gitignore index 1f61bc4..30c3528 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -*.js -*.js.map node_modules _site package-lock.json diff --git a/catalyst/test/test.js b/catalyst/test/test.js new file mode 100644 index 0000000..fd55139 --- /dev/null +++ b/catalyst/test/test.js @@ -0,0 +1,16 @@ +import assert from 'assert' +import {wrap} from '../lib/wrap.js' + +class MyController { + connectedCallback() { } +} + +describe('catalyst', function() { + it('wraps a method that exists', function() { + let called = false + wrap(MyController, "connectedCallback", () => called = true) + const controller = new MyController() + controller.connectedCallback() + assert(called) + }) +}) diff --git a/package.json b/package.json index 7a7d7de..fac5753 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,12 @@ "build": "tsc --build && npm run build:docs:reference", "build:docs": "npm run build:docs:reference && npm run build:docs:jekyll", "build:docs:jekyll": "cd docs && bundle exec jekyll build", - "build:docs:reference": "typedoc --json docs/_data/reference.json" + "build:docs:reference": "typedoc --json docs/_data/reference.json", + "pretest": "npm run build", + "test": "mocha catalyst/test/*" }, "devDependencies": { + "mocha": "^7.1.1", "tslib": "^1.10.0", "typedoc": "^0.16.11", "typescript": "^3.7.5" From 4704de454e25ba5a98965531c5bdf96727fcfab9 Mon Sep 17 00:00:00 2001 From: David Graham Date: Mon, 23 Mar 2020 12:14:08 -0600 Subject: [PATCH 02/18] Add prettier Co-authored-by: Keith Cirkel --- catalyst/test/test.js | 6 +- package.json | 7 + yarn.lock | 637 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 646 insertions(+), 4 deletions(-) diff --git a/catalyst/test/test.js b/catalyst/test/test.js index fd55139..7499b53 100644 --- a/catalyst/test/test.js +++ b/catalyst/test/test.js @@ -5,10 +5,10 @@ class MyController { connectedCallback() { } } -describe('catalyst', function() { - it('wraps a method that exists', function() { +describe('catalyst', function () { + it('wraps a method that exists', function () { let called = false - wrap(MyController, "connectedCallback", () => called = true) + wrap(MyController, 'connectedCallback', () => (called = true)) const controller = new MyController() controller.connectedCallback() assert(called) diff --git a/package.json b/package.json index fac5753..08b162d 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,15 @@ }, "devDependencies": { "mocha": "^7.1.1", + "prettier": "^2.0.1", "tslib": "^1.10.0", "typedoc": "^0.16.11", "typescript": "^3.7.5" + }, + "prettier": { + "printWidth": 120, + "semi": false, + "singleQuote": true, + "bracketSpacing": false } } diff --git a/yarn.lock b/yarn.lock index 5c8f8dc..a227cf2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,6 +7,43 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== +ansi-colors@3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" + integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +anymatch@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" + integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + backbone@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/backbone/-/backbone-1.4.0.tgz#54db4de9df7c3811c3f032f34749a4cd27f3bd12" @@ -19,6 +56,11 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= +binary-extensions@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" + integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -27,6 +69,68 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chokidar@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.0.tgz#12c0714668c55800f659e262d4962a97faf554a6" + integrity sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.2.0" + optionalDependencies: + fsevents "~2.1.1" + +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + commander@~2.20.3: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -37,6 +141,92 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= +debug@3.2.6: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + +define-properties@^1.1.2, define-properties@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" + integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + dependencies: + object-keys "^1.0.12" + +diff@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +es-abstract@^1.17.0-next.1: + version "1.17.5" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9" + integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.1.5" + is-regex "^1.0.5" + object-inspect "^1.7.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimleft "^2.1.1" + string.prototype.trimright "^2.1.1" + +es-to-primitive@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@3.0.0, find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +flat@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" + integrity sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw== + dependencies: + is-buffer "~2.0.3" + fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -51,6 +241,40 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= +fsevents@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805" + integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA== + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +glob-parent@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== + dependencies: + is-glob "^4.0.1" + +glob@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + glob@^7.0.0: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" @@ -68,6 +292,11 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== + handlebars@^4.7.2: version "4.7.3" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.3.tgz#8ece2797826886cf8082d1726ff21d2a022550ee" @@ -79,6 +308,28 @@ handlebars@^4.7.2: optionalDependencies: uglify-js "^3.1.4" +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-symbols@^1.0.0, has-symbols@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" + integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== + +has@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + highlight.js@^9.17.1: version "9.18.1" resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c" @@ -102,11 +353,82 @@ interpret@^1.0.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-buffer@~2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623" + integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A== + +is-callable@^1.1.4, is-callable@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" + integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== + +is-date-object@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" + integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-regex@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" + integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== + dependencies: + has "^1.0.3" + +is-symbol@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" + integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== + dependencies: + has-symbols "^1.0.1" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + jquery@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2" integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw== +js-yaml@3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" + integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -114,11 +436,26 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + lodash@^4.17.15: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +log-symbols@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4" + integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ== + dependencies: + chalk "^2.4.2" + lunr@^2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072" @@ -129,23 +466,116 @@ marked@^0.8.0: resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.0.tgz#ec5c0c9b93878dc52dd54be8d0e524097bd81a99" integrity sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ== -minimatch@^3.0.0, minimatch@^3.0.4: +minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== dependencies: brace-expansion "^1.1.7" +minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= +mkdirp@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.3.tgz#5a514b7179259287952881e94410ec5465659f8c" + integrity sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg== + dependencies: + minimist "^1.2.5" + +mocha@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.1.tgz#89fbb30d09429845b1bb893a830bf5771049a441" + integrity sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA== + dependencies: + ansi-colors "3.2.3" + browser-stdout "1.3.1" + chokidar "3.3.0" + debug "3.2.6" + diff "3.5.0" + escape-string-regexp "1.0.5" + find-up "3.0.0" + glob "7.1.3" + growl "1.10.5" + he "1.2.0" + js-yaml "3.13.1" + log-symbols "3.0.0" + minimatch "3.0.4" + mkdirp "0.5.3" + ms "2.1.1" + node-environment-flags "1.0.6" + object.assign "4.1.0" + strip-json-comments "2.0.1" + supports-color "6.0.0" + which "1.3.1" + wide-align "1.1.3" + yargs "13.3.2" + yargs-parser "13.1.2" + yargs-unparser "1.6.0" + +ms@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + +ms@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + neo-async@^2.6.0: version "2.6.1" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== +node-environment-flags@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088" + integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw== + dependencies: + object.getownpropertydescriptors "^2.0.3" + semver "^5.7.0" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +object-inspect@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" + integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== + +object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object.assign@4.1.0, object.assign@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + +object.getownpropertydescriptors@^2.0.3: + version "2.1.0" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz#369bf1f9592d8ab89d712dced5cb81c7c5352649" + integrity sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -161,6 +591,30 @@ optimist@^0.6.1: minimist "~0.0.1" wordwrap "~0.0.2" +p-limit@^2.0.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.2.tgz#61279b67721f5287aa1c13a9a7fbbc48c9291b1e" + integrity sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -171,11 +625,28 @@ path-parse@^1.0.6: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== +picomatch@^2.0.4: + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + +prettier@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.1.tgz#3f00ac71263be34684b2b2c8d7e7f63737592dac" + integrity sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA== + progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== +readdirp@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839" + integrity sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ== + dependencies: + picomatch "^2.0.4" + rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" @@ -183,6 +654,16 @@ rechoir@^0.6.2: dependencies: resolve "^1.1.6" +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + resolve@^1.1.6: version "1.15.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" @@ -190,6 +671,16 @@ resolve@^1.1.6: dependencies: path-parse "^1.0.6" +semver@^5.7.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + shelljs@^0.8.3: version "0.8.3" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097" @@ -204,6 +695,84 @@ source-map@^0.6.1, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + +"string-width@^1.0.2 || 2": + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +string.prototype.trimleft@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz#9bdb8ac6abd6d602b17a4ed321870d2f8dcefc74" + integrity sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag== + dependencies: + define-properties "^1.1.3" + function-bind "^1.1.1" + +string.prototype.trimright@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz#440314b15996c866ce8a0341894d45186200c5d9" + integrity sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g== + dependencies: + define-properties "^1.1.3" + function-bind "^1.1.1" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= + dependencies: + ansi-regex "^3.0.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-json-comments@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + +supports-color@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" + integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== + dependencies: + has-flag "^3.0.0" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + tslib@^1.10.0: version "1.11.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.0.tgz#f1f3528301621a53220d58373ae510ff747a66bc" @@ -264,12 +833,78 @@ universalify@^0.1.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +which@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +wide-align@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +y18n@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + +yargs-parser@13.1.2, yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-unparser@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" + integrity sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw== + dependencies: + flat "^4.1.0" + lodash "^4.17.15" + yargs "^13.3.0" + +yargs@13.3.2, yargs@^13.3.0: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" From 8ac4e8d41a85222ae4f69ffc7138afd45f4694a4 Mon Sep 17 00:00:00 2001 From: David Graham Date: Mon, 23 Mar 2020 12:22:17 -0600 Subject: [PATCH 03/18] Fix typo Co-authored-by: Keith Cirkel --- catalyst/src/wrap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/src/wrap.ts b/catalyst/src/wrap.ts index 3464f15..61c67fc 100644 --- a/catalyst/src/wrap.ts +++ b/catalyst/src/wrap.ts @@ -2,7 +2,7 @@ * A utility method which wraps a prototype method, ensuring the given function * is also called as part of the given method name. * - * Used in the `contoller()` decorator. + * Used in the `controller()` decorator. */ export function wrap(obj: any, name: string, fn: (...args: any[]) => any) { if (!obj.prototype[name]) { From 718ad39033921db93293c7feafbd418d7db99174 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 24 Mar 2020 14:34:29 +0000 Subject: [PATCH 04/18] chore: add nvmrc --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..fbda4b8 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +13.11.0 From d4e26bd0b135598d061769428ecb3a01899b96a5 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 24 Mar 2020 14:38:11 +0000 Subject: [PATCH 05/18] test: rename test file to wrap.js --- catalyst/test/{test.js => wrap.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename catalyst/test/{test.js => wrap.js} (100%) diff --git a/catalyst/test/test.js b/catalyst/test/wrap.js similarity index 100% rename from catalyst/test/test.js rename to catalyst/test/wrap.js From 1044775d6ccf77f98f613ba065a6d9cf4acdf53f Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 24 Mar 2020 16:39:26 +0000 Subject: [PATCH 06/18] test: add bind tests --- catalyst/test/bind.js | 124 ++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + 2 files changed, 126 insertions(+) create mode 100644 catalyst/test/bind.js diff --git a/catalyst/test/bind.js b/catalyst/test/bind.js new file mode 100644 index 0000000..ce39ac6 --- /dev/null +++ b/catalyst/test/bind.js @@ -0,0 +1,124 @@ +import chai from 'chai' +import {bind} from '../lib/bind.js' +import spies from 'chai-spies' +import assert from 'assert' +chai.use(spies) +const {spy} = chai +const {expect} = chai + + +describe('bind', () => { + class FakeElement { + addEventListener() {} + getAttribute() {} + closest() {} + } + class MyController { + get tagName() { return 'my-controller' } + querySelectorAll() {} + foo() {} + } + + it('queries for Elements matching data-action*="tagname"', () => { + const instance = new MyController() + spy.on(instance, 'querySelectorAll', () => []) + bind(instance) + expect(instance.querySelectorAll).to.have.been.called.once.with.exactly('[data-action*=":my-controller#"]') + }) + + it('binds events on elements based on their data-action attribute', () => { + const instance = new MyController() + spy.on(instance, 'foo') + const el = new FakeElement() + instance.querySelectorAll = () => [el] + el.closest = () => instance + el.getAttribute = () => 'click:my-controller#foo' + spy.on(el, 'addEventListener') + bind(instance) + expect(el.addEventListener).to.have.been.called.once.with('click') + const {calls} = el.addEventListener.__spy + const fn = calls[0][1] + expect(instance.foo).to.have.not.been.called() + fn() + expect(instance.foo).to.have.been.called(1) + }) + + it('does not bind elements whose closest selector is not this controller', () => { + const instance = new MyController() + spy.on(instance, 'foo') + const el = new FakeElement() + instance.querySelectorAll = () => [el] + el.closest = () => null + el.getAttribute = () => 'click:my-controller#foo' + spy.on(el, 'addEventListener') + bind(instance) + expect(el.addEventListener).to.have.not.been.called() + }) + + it('does not bind elements whose data-action does not match controller tagname', () => { + const instance = new MyController() + spy.on(instance, 'foo') + const el = new FakeElement() + instance.querySelectorAll = () => [el] + el.closest = () => null + el.getAttribute = () => 'click:other-controller#foo' + spy.on(el, 'addEventListener') + bind(instance) + expect(el.addEventListener).to.have.not.been.called() + }) + + it('does not bind methods that dont exist', () => { + const instance = new MyController() + spy.on(instance, 'foo') + const el = new FakeElement() + instance.querySelectorAll = () => [el] + el.closest = () => instance + el.getAttribute = () => 'click:my-controller#frob' + spy.on(el, 'addEventListener') + bind(instance) + expect(el.addEventListener).to.have.not.been.called() + }) + + it('can bind multiple event types', () => { + const instance = new MyController() + spy.on(instance, 'foo') + const el = new FakeElement() + instance.querySelectorAll = () => [el] + el.closest = () => instance + el.getAttribute = () => 'click:my-controller#foo submit:my-controller#foo' + spy.on(el, 'addEventListener') + bind(instance) + expect(el.addEventListener).to.have.been.called(2) + expect(el.addEventListener).to.be.first.called.with('click') + expect(el.addEventListener).to.be.second.called.with('submit') + const {calls} = el.addEventListener.__spy + expect(instance.foo).to.have.not.been.called() + calls[0][1]('a') + expect(instance.foo).to.have.been.called.once.with('a') + calls[1][1]('b') + expect(instance.foo).to.have.been.called.twice.second.with('b') + }) + + it('can bind multiple elements to the same event', () => { + const instance = new MyController() + spy.on(instance, 'foo') + const el1 = new FakeElement() + const el2 = new FakeElement() + instance.querySelectorAll = () => [el1, el2] + el1.closest = () => instance + el2.closest = () => instance + el1.getAttribute = () => 'click:my-controller#foo' + el2.getAttribute = () => 'submit:my-controller#foo' + spy.on(el1, 'addEventListener') + spy.on(el2, 'addEventListener') + bind(instance) + expect(el1.addEventListener).to.be.called.once.with('click') + expect(el2.addEventListener).to.be.called.once.with('submit') + expect(instance.foo).to.have.not.been.called() + el1.addEventListener.__spy.calls[0][1]('a') + expect(instance.foo).to.have.been.called.once.with('a') + el2.addEventListener.__spy.calls[0][1]('b') + expect(instance.foo).to.have.been.called.twice.second.with('b') + }) + +}) diff --git a/package.json b/package.json index 08b162d..6010c41 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,8 @@ "test": "mocha catalyst/test/*" }, "devDependencies": { + "chai": "^4.2.0", + "chai-spies": "^1.0.0", "mocha": "^7.1.1", "prettier": "^2.0.1", "tslib": "^1.10.0", From 79558b39f62cd3eb5f397b245fd5e4036f1e51d0 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 24 Mar 2020 16:39:38 +0000 Subject: [PATCH 07/18] test: rename description for wrap tests --- catalyst/test/wrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/test/wrap.js b/catalyst/test/wrap.js index 7499b53..1b6e0ad 100644 --- a/catalyst/test/wrap.js +++ b/catalyst/test/wrap.js @@ -5,7 +5,7 @@ class MyController { connectedCallback() { } } -describe('catalyst', function () { +describe('wrap', function () { it('wraps a method that exists', function () { let called = false wrap(MyController, 'connectedCallback', () => (called = true)) From 14fffa804fc7e93811e331b9a85b08a50500b674 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 24 Mar 2020 16:52:19 +0000 Subject: [PATCH 08/18] test: add register tests --- catalyst/test/register.js | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 catalyst/test/register.js diff --git a/catalyst/test/register.js b/catalyst/test/register.js new file mode 100644 index 0000000..a7c7901 --- /dev/null +++ b/catalyst/test/register.js @@ -0,0 +1,48 @@ +import chai from 'chai' +import {register} from '../lib/register.js' +import spies from 'chai-spies' +import assert from 'assert' +chai.use(spies) +const {spy} = chai +const {expect} = chai + +describe('register', () => { + const elements = new Map() + global.window = { + customElements: { + get(name) { return elements.get(name) }, + define(name, value) { return elements.set(name, value) }, + } + } + let sandbox + beforeEach(() => { + sandbox = spy.sandbox() + sandbox.on(window.customElements, ['get', 'define']) + }) + + afterEach(() => { + elements.clear() + sandbox.restore() + }) + + it('registers the class as a custom element, normalising the class name', () => { + class MyController {} + register(MyController) + expect(window.customElements.define).to.have.been.called.with('my-controller', MyController) + expect(elements.get('my-controller')).to.equal(MyController) + }) + + it('does not register controllers that already exist', () => { + elements.set('my-controller', {}) + class MyController {} + register(MyController) + expect(window.customElements.define).to.have.not.been.called() + }) + + it('dasherises class names', () => { + class ThisIsAnExampleOfADasherisedClassName {} + register(ThisIsAnExampleOfADasherisedClassName) + expect(window.customElements.define).to.have.been.called.with('this-is-an-example-of-a-dasherised-class-name') + }) + +}) From 6bde9215e6b8faedecce584717e3702765271d38 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 11:31:01 +0000 Subject: [PATCH 09/18] test: clean up imports --- catalyst/test/bind.js | 3 +-- catalyst/test/register.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/catalyst/test/bind.js b/catalyst/test/bind.js index ce39ac6..cfa7b8b 100644 --- a/catalyst/test/bind.js +++ b/catalyst/test/bind.js @@ -1,7 +1,6 @@ -import chai from 'chai' import {bind} from '../lib/bind.js' +import chai from 'chai' import spies from 'chai-spies' -import assert from 'assert' chai.use(spies) const {spy} = chai const {expect} = chai diff --git a/catalyst/test/register.js b/catalyst/test/register.js index a7c7901..a32b03f 100644 --- a/catalyst/test/register.js +++ b/catalyst/test/register.js @@ -1,7 +1,6 @@ -import chai from 'chai' import {register} from '../lib/register.js' +import chai from 'chai' import spies from 'chai-spies' -import assert from 'assert' chai.use(spies) const {spy} = chai const {expect} = chai From 1aadcb81f110cccfbe1d6430eae1c5b4ae45597d Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 11:31:11 +0000 Subject: [PATCH 10/18] docs: fix typo --- docs/_data/reference.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_data/reference.json b/docs/_data/reference.json index febf7a8..8b2f0f2 100644 --- a/docs/_data/reference.json +++ b/docs/_data/reference.json @@ -770,7 +770,7 @@ }, "comment": { "shortText": "A utility method which wraps a prototype method, ensuring the given function\nis also called as part of the given method name.", - "text": "Used in the `contoller()` decorator.\n" + "text": "Used in the `controller()` decorator.\n" }, "parameters": [ { From 192b5aebd23f692090291c464fd01624506d8b4b Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 11:36:02 +0000 Subject: [PATCH 11/18] test: add tests for wrap --- catalyst/test/wrap.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/catalyst/test/wrap.js b/catalyst/test/wrap.js index 1b6e0ad..2271c80 100644 --- a/catalyst/test/wrap.js +++ b/catalyst/test/wrap.js @@ -1,16 +1,31 @@ -import assert from 'assert' import {wrap} from '../lib/wrap.js' +import chai from 'chai' +import spies from 'chai-spies' +chai.use(spies) +const {spy} = chai +const {expect} = chai -class MyController { - connectedCallback() { } -} - -describe('wrap', function () { - it('wraps a method that exists', function () { - let called = false - wrap(MyController, 'connectedCallback', () => (called = true)) +describe('wrap', () => { + it('wraps a method that exists', () => { + class MyController { + connectedCallback() { } + } + spy.on(MyController.prototype, 'connectedCallback') + const original = MyController.prototype.connectedCallback + const fn = spy() + wrap(MyController, 'connectedCallback', fn) const controller = new MyController() - controller.connectedCallback() - assert(called) + controller.connectedCallback('a') + expect(fn).to.have.been.called.once.with.exactly('a') + expect(original).to.have.been.called.once.with.exactly('a') + }) + + it('assigns the method that does not exist', () => { + class MyController {} + const fn = spy() + wrap(MyController, 'connectedCallback', fn) + const controller = new MyController() + controller.connectedCallback('a') + expect(fn).to.have.been.called.once.with.exactly('a') }) }) From 8239140a5177203187090dc35e0216af7f0c9e90 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 11:38:52 +0000 Subject: [PATCH 12/18] fix: use wrap correctly in @controller --- catalyst/src/controller.ts | 4 +++- catalyst/src/wrap.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/catalyst/src/controller.ts b/catalyst/src/controller.ts index 602e362..5d4a610 100644 --- a/catalyst/src/controller.ts +++ b/catalyst/src/controller.ts @@ -13,6 +13,8 @@ interface CustomElement { * wrapping the classes `connectedCallback` method if needed. */ export function controller(classObject: CustomElement) { - wrap(classObject, 'connectedCallback', bind) + wrap(classObject, 'connectedCallback', function (this: HTMLElement) { + bind(this) + }) register(classObject) } diff --git a/catalyst/src/wrap.ts b/catalyst/src/wrap.ts index 61c67fc..b1025f4 100644 --- a/catalyst/src/wrap.ts +++ b/catalyst/src/wrap.ts @@ -9,9 +9,9 @@ export function wrap(obj: any, name: string, fn: (...args: any[]) => any) { obj.prototype[name] = fn } else { const oldFn = obj.prototype[name] - obj.prototype[name] = function () { - oldFn.call(this) - fn.call(this, this) + obj.prototype[name] = function (...args: unknown[]) { + fn.apply(this, args) + oldFn.apply(this, args) } } } From 86d4636bc833013b33fe939601fb2ae2035dde95 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 12:02:14 +0000 Subject: [PATCH 13/18] test: clean up chai destructuring --- catalyst/test/bind.js | 4 +--- catalyst/test/register.js | 3 +-- catalyst/test/wrap.js | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/catalyst/test/bind.js b/catalyst/test/bind.js index cfa7b8b..e9ff79e 100644 --- a/catalyst/test/bind.js +++ b/catalyst/test/bind.js @@ -2,9 +2,7 @@ import {bind} from '../lib/bind.js' import chai from 'chai' import spies from 'chai-spies' chai.use(spies) -const {spy} = chai -const {expect} = chai - +const {spy, expect} = chai describe('bind', () => { class FakeElement { diff --git a/catalyst/test/register.js b/catalyst/test/register.js index a32b03f..97a40fb 100644 --- a/catalyst/test/register.js +++ b/catalyst/test/register.js @@ -2,8 +2,7 @@ import {register} from '../lib/register.js' import chai from 'chai' import spies from 'chai-spies' chai.use(spies) -const {spy} = chai -const {expect} = chai +const {spy, expect} = chai describe('register', () => { const elements = new Map() diff --git a/catalyst/test/wrap.js b/catalyst/test/wrap.js index 2271c80..0f39e12 100644 --- a/catalyst/test/wrap.js +++ b/catalyst/test/wrap.js @@ -2,8 +2,7 @@ import {wrap} from '../lib/wrap.js' import chai from 'chai' import spies from 'chai-spies' chai.use(spies) -const {spy} = chai -const {expect} = chai +const {spy, expect} = chai describe('wrap', () => { it('wraps a method that exists', () => { From d0d8463dd48c97a5e046fde340e4521d63add90b Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 12:02:49 +0000 Subject: [PATCH 14/18] test: add findTarget tests --- catalyst/test/findtarget.js | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 catalyst/test/findtarget.js diff --git a/catalyst/test/findtarget.js b/catalyst/test/findtarget.js new file mode 100644 index 0000000..b98e88e --- /dev/null +++ b/catalyst/test/findtarget.js @@ -0,0 +1,68 @@ +import {findTarget, findTargets} from '../lib/findtarget.js' +import chai from 'chai' +import spies from 'chai-spies' +chai.use(spies) +const {spy} = chai +const {expect} = chai + +describe('findTarget', () => { + class FakeElement { + closest() {} + } + class MyController { + get tagName() { return 'my-controller' } + querySelectorAll() {} + } + + it('calls querySelectorAll with the controller name and target name', () => { + const instance = new MyController() + spy.on(instance, 'querySelectorAll', () => []) + findTarget(instance, 'foo') + expect(instance.querySelectorAll).to.have.been.called.once.with.exactly('[data-target*="my-controller.foo"]') + }) + + it('returns first element where closest tag is the controller', () => { + const els = [new FakeElement(), new FakeElement()] + const instance = new MyController() + spy.on(instance, 'querySelectorAll', () => els) + spy.on(els[0], 'closest', () => null) + spy.on(els[1], 'closest', () => instance) + const target = findTarget(instance, 'foo') + expect(els[0].closest).to.have.been.called.once.with.exactly('my-controller') + expect(els[1].closest).to.have.been.called.once.with.exactly('my-controller') + expect(target).to.equal(els[1]) + }) + +}) + +describe('findTargets', () => { + class FakeElement { + closest() {} + } + class MyController { + get tagName() { return 'my-controller' } + querySelectorAll() {} + } + + it('calls querySelectorAll with the controller name and target name', () => { + const instance = new MyController() + spy.on(instance, 'querySelectorAll', () => []) + findTargets(instance, 'foo') + expect(instance.querySelectorAll).to.have.been.called.once.with.exactly('[data-target*="my-controller.foo"]') + }) + + it('returns all elements where closest tag is the controller', () => { + const els = [new FakeElement(), new FakeElement(), new FakeElement()] + const instance = new MyController() + spy.on(instance, 'querySelectorAll', () => els) + spy.on(els[0], 'closest', () => instance) + spy.on(els[1], 'closest', () => null) + spy.on(els[2], 'closest', () => instance) + const targets = findTargets(instance, 'foo') + expect(els[0].closest).to.have.been.called.once.with.exactly('my-controller') + expect(els[1].closest).to.have.been.called.once.with.exactly('my-controller') + expect(els[2].closest).to.have.been.called.once.with.exactly('my-controller') + expect(targets).to.deep.equal([els[0], els[2]]) + }) + +}) From 2f4e43e3e43871121580485530ba4e78f9e928cc Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 12:03:03 +0000 Subject: [PATCH 15/18] chore: yarn install --- yarn.lock | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/yarn.lock b/yarn.lock index a227cf2..bb8909a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,6 +44,11 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + backbone@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/backbone/-/backbone-1.4.0.tgz#54db4de9df7c3811c3f032f34749a4cd27f3bd12" @@ -86,6 +91,23 @@ camelcase@^5.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== +chai-spies@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/chai-spies/-/chai-spies-1.0.0.tgz#d16b39336fb316d03abf8c375feb23c0c8bb163d" + integrity sha512-elF2ZUczBsFoP07qCfMO/zeggs8pqCf3fZGyK5+2X4AndS8jycZYID91ztD9oQ7d/0tnS963dPkd0frQEThDsg== + +chai@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" + integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.0" + type-detect "^4.0.5" + chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -95,6 +117,11 @@ chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= + chokidar@3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.0.tgz#12c0714668c55800f659e262d4962a97faf554a6" @@ -153,6 +180,13 @@ decamelize@^1.2.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== + dependencies: + type-detect "^4.0.0" + define-properties@^1.1.2, define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -256,6 +290,11 @@ get-caller-file@^2.0.1: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= + glob-parent@~5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" @@ -625,6 +664,11 @@ path-parse@^1.0.6: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== +pathval@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" + integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA= + picomatch@^2.0.4: version "2.2.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" @@ -778,6 +822,11 @@ tslib@^1.10.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.0.tgz#f1f3528301621a53220d58373ae510ff747a66bc" integrity sha512-BmndXUtiTn/VDDrJzQE7Mm22Ix3PxgLltW9bSNLoeCY31gnG2OPx0QqJnuc9oMIKioYrz487i6K9o4Pdn0j+Kg== +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + typedoc-default-themes@^0.7.2: version "0.7.2" resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.7.2.tgz#1e9896f920b58e6da0bba9d7e643738d02405a5a" From 670d4f4241d2ca9a9cb5803ff1efbe018c24aa2b Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 12:09:34 +0000 Subject: [PATCH 16/18] refactor(wrap): wrap directly, not on prototype --- catalyst/src/controller.ts | 2 +- catalyst/src/wrap.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/catalyst/src/controller.ts b/catalyst/src/controller.ts index 5d4a610..707183a 100644 --- a/catalyst/src/controller.ts +++ b/catalyst/src/controller.ts @@ -13,7 +13,7 @@ interface CustomElement { * wrapping the classes `connectedCallback` method if needed. */ export function controller(classObject: CustomElement) { - wrap(classObject, 'connectedCallback', function (this: HTMLElement) { + wrap(classObject.prototype, 'connectedCallback', function (this: HTMLElement) { bind(this) }) register(classObject) diff --git a/catalyst/src/wrap.ts b/catalyst/src/wrap.ts index b1025f4..cb27691 100644 --- a/catalyst/src/wrap.ts +++ b/catalyst/src/wrap.ts @@ -5,11 +5,11 @@ * Used in the `controller()` decorator. */ export function wrap(obj: any, name: string, fn: (...args: any[]) => any) { - if (!obj.prototype[name]) { - obj.prototype[name] = fn + if (!obj[name]) { + obj[name] = fn } else { - const oldFn = obj.prototype[name] - obj.prototype[name] = function (...args: unknown[]) { + const oldFn = obj[name] + obj[name] = function (...args: unknown[]) { fn.apply(this, args) oldFn.apply(this, args) } From 0ccd62c7e817001dc8bdbe4f393244e87c2bdfd9 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 12:11:00 +0000 Subject: [PATCH 17/18] chore: use @github/prettier-config --- package.json | 8 ++------ yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6010c41..76fd943 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "test": "mocha catalyst/test/*" }, "devDependencies": { + "@github/prettier-config": "^0.0.4", "chai": "^4.2.0", "chai-spies": "^1.0.0", "mocha": "^7.1.1", @@ -40,10 +41,5 @@ "typedoc": "^0.16.11", "typescript": "^3.7.5" }, - "prettier": { - "printWidth": 120, - "semi": false, - "singleQuote": true, - "bracketSpacing": false - } + "prettier": "@github/prettier-config" } diff --git a/yarn.lock b/yarn.lock index bb8909a..7572cac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@github/prettier-config@^0.0.4": + version "0.0.4" + resolved "https://npm.pkg.github.com/download/@github/prettier-config/0.0.4/69d843b9d8cba082ce7977ef0fe3367716462384a6857e7e9ef6b40d5868d98b#cbfddb36a7f29a81c5af155dc5827e95b23b9ccd" + integrity sha512-ZOJ+U771Mw68qp2GPbcqPt2Xg0LEl0YwiIFHXwVLAFm2TgDnsgcCHhXO8PIxOWPqSFO4S7xIMD9CBobfaWGASA== + "@types/minimatch@3.0.3": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" From 45443a1972a75ab1c60f289c06d3b293cd15c5b9 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 25 Mar 2020 12:11:56 +0000 Subject: [PATCH 18/18] style: prettier --write . --- catalyst/src/bind.ts | 27 +++++++++++++-------------- catalyst/src/controller.ts | 2 +- catalyst/src/register.ts | 7 +++---- catalyst/src/target.ts | 24 ++++++++++-------------- catalyst/test/bind.js | 5 +++-- catalyst/test/findtarget.js | 10 ++++++---- catalyst/test/register.js | 9 ++++++--- catalyst/test/wrap.js | 2 +- tsconfig.json | 10 ++-------- 9 files changed, 45 insertions(+), 51 deletions(-) diff --git a/catalyst/src/bind.ts b/catalyst/src/bind.ts index b90e88d..3c5d648 100644 --- a/catalyst/src/bind.ts +++ b/catalyst/src/bind.ts @@ -4,24 +4,23 @@ */ export function bind(controller: HTMLElement) { const tag = controller.tagName.toLowerCase() - for(const el of controller.querySelectorAll(`[data-action*=":${tag}#"]`)) { + for (const el of controller.querySelectorAll(`[data-action*=":${tag}#"]`)) { // Ignore nested elements if (el.closest(tag) !== controller) continue - // Match the pattern of `eventName:constructor#method`. - for(const binding of (el.getAttribute('data-action')||'').split(' ')) { - const [rest, method] = binding.split('#') - const [eventName, handler] = rest.split(':') - if (handler !== tag) continue - - // Check the `method` is present on the prototype - const methodDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(controller), method) - if (methodDescriptor && typeof methodDescriptor.value == 'function') { - el.addEventListener(eventName, (event: Event) => { - (controller as any)[method](event) - }) - } + // Match the pattern of `eventName:constructor#method`. + for (const binding of (el.getAttribute('data-action') || '').split(' ')) { + const [rest, method] = binding.split('#') + const [eventName, handler] = rest.split(':') + if (handler !== tag) continue + // Check the `method` is present on the prototype + const methodDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(controller), method) + if (methodDescriptor && typeof methodDescriptor.value == 'function') { + el.addEventListener(eventName, (event: Event) => { + ;(controller as any)[method](event) + }) } + } } } diff --git a/catalyst/src/controller.ts b/catalyst/src/controller.ts index 707183a..8faba72 100644 --- a/catalyst/src/controller.ts +++ b/catalyst/src/controller.ts @@ -3,7 +3,7 @@ import {bind} from './bind' import {wrap} from './wrap' interface CustomElement { - new(): HTMLElement + new (): HTMLElement } /** diff --git a/catalyst/src/register.ts b/catalyst/src/register.ts index c02c4c8..1d44670 100644 --- a/catalyst/src/register.ts +++ b/catalyst/src/register.ts @@ -1,6 +1,5 @@ - interface CustomElement { - new(): HTMLElement + new (): HTMLElement } /** @@ -14,7 +13,7 @@ export function register(classObject: CustomElement) { const name = classObject.name.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase() if (!window.customElements.get(name)) { // @ts-ignore - window[classObject.name] = classObject; - window.customElements.define(name, classObject); + window[classObject.name] = classObject + window.customElements.define(name, classObject) } } diff --git a/catalyst/src/target.ts b/catalyst/src/target.ts index 73c624b..e661aa5 100644 --- a/catalyst/src/target.ts +++ b/catalyst/src/target.ts @@ -8,14 +8,12 @@ import {findTarget, findTargets} from './findtarget' * `findTarget(this, 'foo')`. */ export function target(proto: object, key: string) { - Object.defineProperty( - proto, - key, - { - configurable: true, - get: function() { return findTarget(this, key) } + Object.defineProperty(proto, key, { + configurable: true, + get: function () { + return findTarget(this, key) } - ); + }) } /** @@ -26,12 +24,10 @@ export function target(proto: object, key: string) { * `findTargets(this, 'foo')`. */ export function targets(proto: object, key: string) { - Object.defineProperty( - proto, - key, - { - configurable: true, - get: function() { return findTargets(this, key) } + Object.defineProperty(proto, key, { + configurable: true, + get: function () { + return findTargets(this, key) } - ); + }) } diff --git a/catalyst/test/bind.js b/catalyst/test/bind.js index e9ff79e..0672f22 100644 --- a/catalyst/test/bind.js +++ b/catalyst/test/bind.js @@ -11,7 +11,9 @@ describe('bind', () => { closest() {} } class MyController { - get tagName() { return 'my-controller' } + get tagName() { + return 'my-controller' + } querySelectorAll() {} foo() {} } @@ -117,5 +119,4 @@ describe('bind', () => { el2.addEventListener.__spy.calls[0][1]('b') expect(instance.foo).to.have.been.called.twice.second.with('b') }) - }) diff --git a/catalyst/test/findtarget.js b/catalyst/test/findtarget.js index b98e88e..b61d6d1 100644 --- a/catalyst/test/findtarget.js +++ b/catalyst/test/findtarget.js @@ -10,7 +10,9 @@ describe('findTarget', () => { closest() {} } class MyController { - get tagName() { return 'my-controller' } + get tagName() { + return 'my-controller' + } querySelectorAll() {} } @@ -32,7 +34,6 @@ describe('findTarget', () => { expect(els[1].closest).to.have.been.called.once.with.exactly('my-controller') expect(target).to.equal(els[1]) }) - }) describe('findTargets', () => { @@ -40,7 +41,9 @@ describe('findTargets', () => { closest() {} } class MyController { - get tagName() { return 'my-controller' } + get tagName() { + return 'my-controller' + } querySelectorAll() {} } @@ -64,5 +67,4 @@ describe('findTargets', () => { expect(els[2].closest).to.have.been.called.once.with.exactly('my-controller') expect(targets).to.deep.equal([els[0], els[2]]) }) - }) diff --git a/catalyst/test/register.js b/catalyst/test/register.js index 97a40fb..51152c4 100644 --- a/catalyst/test/register.js +++ b/catalyst/test/register.js @@ -8,8 +8,12 @@ describe('register', () => { const elements = new Map() global.window = { customElements: { - get(name) { return elements.get(name) }, - define(name, value) { return elements.set(name, value) }, + get(name) { + return elements.get(name) + }, + define(name, value) { + return elements.set(name, value) + } } } let sandbox @@ -42,5 +46,4 @@ describe('register', () => { register(ThisIsAnExampleOfADasherisedClassName) expect(window.customElements.define).to.have.been.called.with('this-is-an-example-of-a-dasherised-class-name') }) - }) diff --git a/catalyst/test/wrap.js b/catalyst/test/wrap.js index 0f39e12..1f48d6b 100644 --- a/catalyst/test/wrap.js +++ b/catalyst/test/wrap.js @@ -7,7 +7,7 @@ const {spy, expect} = chai describe('wrap', () => { it('wraps a method that exists', () => { class MyController { - connectedCallback() { } + connectedCallback() {} } spy.on(MyController.prototype, 'connectedCallback') const original = MyController.prototype.connectedCallback diff --git a/tsconfig.json b/tsconfig.json index e524906..8fe2b35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,11 +4,7 @@ "module": "ESNext", "esModuleInterop": true, "experimentalDecorators": true, - "lib": [ - "es6", - "dom", - "dom.iterable" - ], + "lib": ["es6", "dom", "dom.iterable"], "target": "ES2020", "moduleResolution": "node", "noEmit": true, @@ -21,7 +17,5 @@ "@catalyst/*": ["*/src"] } }, - "references": [ - {"path": "./catalyst" } - ] + "references": [{"path": "./catalyst"}] }