# HG changeset patch # User cin # Date 2020-01-26 09:47:53 # Node ID b6ccfccf314fcf3ad0387ca6cc4de0e55356f30b # Parent 8e944df97a6828cb1ffd2bdc492f34121f27fc25 typescript strict mode Added TAP traits, TAP text writer diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ typescript { lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] listFiles = true declaration = true + strict = true types = [] module = "amd" it.target = "es5" diff --git a/package-lock.json b/package-lock.json --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,15 @@ "js-tokens": "^4.0.0" } }, + "@babel/runtime": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.3.tgz", + "integrity": "sha512-fVHx1rzEmwB130VTkLnxR+HmxcTjGzH12LYQcFFoBwakMd3aOMD4OsRN7tGG/UOYE2ektgFrS8uACAoRk1CY0w==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, "@implab/core-amd": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@implab/core-amd/-/core-amd-1.3.2.tgz", @@ -29,15 +38,9 @@ "dev": true }, "@types/chai": { - "version": "4.2.7", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", - "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", - "dev": true - }, - "@types/node": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.0.tgz", - "integrity": "sha512-j2tekvJCO7j22cs+LO6i0kRPhmQ9MXaPZ55TzOc1lzkN5b6BWqq4AFjl04s1oRRQ1v5rSe+KEvnLUSTonuls/A==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.3.tgz", + "integrity": "sha512-f5dXGzOJycyzSMdaXVhiBhauL4dYydXwVpavfQ1mVCaGjR56a9QfklXObUxlIY9bGTmCPHEEZ04I16BZ/8w5ww==", "dev": true }, "@types/requirejs": { @@ -46,14 +49,11 @@ "integrity": "sha512-b2soeyuU76rMbcRJ4e0hEl0tbMhFwZeTC0VZnfuWlfGlk6BwWNsev6kFu/twKABPX29wkX84wU2o+cEJoXsiTw==", "dev": true }, - "@types/tape": { - "version": "4.2.33", - "resolved": "https://registry.npmjs.org/@types/tape/-/tape-4.2.33.tgz", - "integrity": "sha512-ltfyuY5BIkYlGuQfwqzTDT8f0q8Z5DGppvUnWGs39oqDmMd6/UWhNpX3ZMh/VYvfxs3rFGHMrLC/eGRdLiDGuw==", - "dev": true, - "requires": { - "@types/node": "*" - } + "@types/yaml": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/yaml/-/yaml-1.2.0.tgz", + "integrity": "sha512-GW8b9qM+ebgW3/zjzPm0I1NxMvLaz/YKT9Ph6tTb+Fkeyzd9yLTvQ6ciQ2MorTRmb/qXmfjMerRpG4LviixaqQ==", + "dev": true }, "acorn": { "version": "7.1.0", @@ -80,15 +80,18 @@ } }, "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", + "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } }, "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "ansi-styles": { @@ -109,6 +112,12 @@ "sprintf-js": "~1.0.2" } }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, "astral-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", @@ -143,6 +152,20 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "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": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -160,13 +183,19 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "restore-cursor": "^3.1.0" } }, "cli-width": { @@ -232,11 +261,14 @@ "ms": "^2.1.1" } }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", - "dev": true + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } }, "deep-is": { "version": "0.1.3", @@ -244,25 +276,10 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, - "defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true - }, "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, "doctrine": { @@ -275,9 +292,9 @@ } }, "dojo": { - "version": "1.10.10", - "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.10.10.tgz", - "integrity": "sha512-kg79C8Yyd317cG3MgXGMH4AeQ8TgNr8H/PpA3BRms7DTfl0CJCRAgGE/C6d9Nw55s1ID/fEsfS+P3bj1s7dWgA==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.16.0.tgz", + "integrity": "sha512-DUiXyoLK6vMF5BPr/qiMLTxDMfiM9qlzN1jxfDsVfuvB/CwhYpNxA/M4mbqKN8PCVGLmccXBJbfmFJPP5+zmzw==", "dev": true }, "dojo-typings": { @@ -290,49 +307,11 @@ } }, "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "es-abstract": { - "version": "1.17.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", - "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", - "dev": true, - "requires": { - "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" - }, - "dependencies": { - "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true - } - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -340,9 +319,9 @@ "dev": true }, "eslint": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.1.0.tgz", - "integrity": "sha512-QhrbdRD7ofuV09IuE2ySWBz0FyXCq0rriLTZXZqaWSI79CVtHVRdkFuFTViiqzZhkCgfOh9USpriuGN2gIpZDQ==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -352,19 +331,19 @@ "debug": "^4.0.1", "doctrine": "^3.0.0", "eslint-scope": "^5.0.0", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^6.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", "esquery": "^1.0.1", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^5.0.0", - "globals": "^11.7.0", + "globals": "^12.1.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.4.1", + "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", @@ -373,7 +352,7 @@ "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.2", + "optionator": "^0.8.3", "progress": "^2.0.0", "regexpp": "^2.0.1", "semver": "^6.1.2", @@ -486,9 +465,9 @@ "dev": true }, "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", + "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", "dev": true, "requires": { "escape-string-regexp": "^1.0.5" @@ -520,33 +499,24 @@ "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", "dev": true }, - "for-each": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", - "dev": true, - "requires": { - "is-callable": "^1.1.3" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -571,18 +541,12 @@ } }, "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", + "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", "dev": true, "requires": { - "function-bind": "^1.1.1" + "type-fest": "^0.8.1" } }, "has-flag": { @@ -591,12 +555,6 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -645,38 +603,26 @@ "dev": true }, "inquirer": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz", - "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.3.tgz", + "integrity": "sha512-+OiOVeVydu4hnCGLCSX+wedovR/Yzskv9BFqUNNKq9uU2qg7LCcCo3R86S2E7WLo0y/x2pnEZfZe1CoYnORUAw==", "dev": true, "requires": { - "ansi-escapes": "^3.2.0", + "ansi-escapes": "^4.2.1", "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", + "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.12", - "mute-stream": "0.0.7", + "figures": "^3.0.0", + "lodash": "^4.17.15", + "mute-stream": "0.0.8", "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", + "rxjs": "^6.5.3", + "string-width": "^4.1.0", "strip-ansi": "^5.1.0", "through": "^2.3.6" } }, - "is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", - "dev": true - }, - "is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", - "dev": true - }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -684,9 +630,9 @@ "dev": true }, "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, "is-glob": { @@ -704,24 +650,6 @@ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -773,9 +701,9 @@ "dev": true }, "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "minimatch": { @@ -809,9 +737,9 @@ "dev": true }, "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, "natural-compare": { @@ -826,30 +754,6 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, - "object-inspect": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", - "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", - "dev": true - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -860,12 +764,12 @@ } }, "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "mimic-fn": "^2.1.0" } }, "optionator": { @@ -915,6 +819,12 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -933,22 +843,22 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "regenerator-runtime": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "dev": true + }, "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, - "requirejs": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", - "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", - "dev": true - }, "resolve": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", - "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", + "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -961,24 +871,15 @@ "dev": true }, "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", "dev": true, "requires": { - "onetime": "^2.0.0", + "onetime": "^5.1.0", "signal-exit": "^3.0.2" } }, - "resumer": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", - "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", - "dev": true, - "requires": { - "through": "~2.3.4" - } - }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -1048,6 +949,14 @@ "ansi-styles": "^3.2.0", "astral-regex": "^1.0.0", "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } } }, "sprintf-js": { @@ -1057,57 +966,27 @@ "dev": true }, "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" }, "dependencies": { "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^5.0.0" } } } }, - "string.prototype.trim": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", - "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.5.0", - "function-bind": "^1.0.2" - } - }, - "string.prototype.trimleft": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", - "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - }, - "string.prototype.trimright": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", - "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -1152,6 +1031,18 @@ "string-width": "^3.0.0" }, "dependencies": { + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -1165,35 +1056,6 @@ } } }, - "tape": { - "version": "4.11.0", - "resolved": "https://registry.npmjs.org/tape/-/tape-4.11.0.tgz", - "integrity": "sha512-yixvDMX7q7JIs/omJSzSZrqulOV51EC9dK8dM0TzImTIkHWfe2/kFyL5v+d9C+SrCMaICk59ujsqFAVidDqDaA==", - "dev": true, - "requires": { - "deep-equal": "~1.0.1", - "defined": "~1.0.0", - "for-each": "~0.3.3", - "function-bind": "~1.1.1", - "glob": "~7.1.4", - "has": "~1.0.3", - "inherits": "~2.0.4", - "minimist": "~1.2.0", - "object-inspect": "~1.6.0", - "resolve": "~1.11.1", - "resumer": "~0.0.0", - "string.prototype.trim": "~1.1.2", - "through": "~2.3.8" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -1222,23 +1084,23 @@ "dev": true }, "tslint": { - "version": "5.18.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.18.0.tgz", - "integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.0.0.tgz", + "integrity": "sha512-9nLya8GBtlFmmFMW7oXXwoXS1NkrccqTqAtwXzdPV9e2mqSEvCki6iHL/Fbzi5oqbugshzgGPk7KBb2qNP1DSA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", "chalk": "^2.3.0", "commander": "^2.12.1", - "diff": "^3.2.0", + "diff": "^4.0.1", "glob": "^7.1.1", "js-yaml": "^3.13.1", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", - "tslib": "^1.8.0", + "tslib": "^1.10.0", "tsutils": "^2.29.0" }, "dependencies": { @@ -1268,10 +1130,22 @@ "prelude-ls": "~1.1.2" } }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "typescript": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.5.tgz", - "integrity": "sha512-BEjlc0Z06ORZKbtcxGrIvvwYs5hAnuo6TKdNFL55frVDlB+na3z5bsLhFaIxmT+dPWgBIjMo6aNnTOgHHmHgiQ==", + "version": "3.7.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz", + "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==", "dev": true }, "uri-js": { @@ -1318,6 +1192,15 @@ "requires": { "mkdirp": "^0.5.1" } + }, + "yaml": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz", + "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.6.3" + } } } } diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -1,14 +1,15 @@ { "devDependencies": { - "@types/node": "8.0.0", - "@types/tape": "~4.2.33", "@types/requirejs": "2.1.31", "dojo": "1.16.0", "dojo-typings": "1.11.9", - "tape": "~4.13.0", "typescript": "~3.7.5", "eslint": "6.8.0", "tslint": "6.0.0", - "@implab/core-amd": "^1.3.2" + "@implab/core-amd": "^1.3.2", + "yaml": "~1.7.2", + "@types/yaml": "1.2.0", + "chai": "4.2.0", + "@types/chai": "4.1.3" } } diff --git a/src/main/ts/NlsBundle.ts b/src/main/ts/NlsBundle.ts --- a/src/main/ts/NlsBundle.ts +++ b/src/main/ts/NlsBundle.ts @@ -36,7 +36,7 @@ export class NlsBundle _cache: MapOf>; - constructor(defNls: T, locales: MapOf) { + constructor(defNls: T, locales?: MapOf) { this.default = defNls; this._locales = locales || {}; this._cache = {}; @@ -51,17 +51,20 @@ export class NlsBundle a.push(x); locales.unshift(a.join("-")); return a; - }, []); + }, new Array()); return this._resolveLocale(locales); } _resolveLocale(locales: string[]): PromiseOrValue { if (!locales.length) - return; + return this.default; const locale = locales.shift(); + if (!locale) + return this._resolveLocale(locales); + if (this._cache[locale]) return this._cache[locale]; @@ -69,7 +72,7 @@ export class NlsBundle if (isCallback(data)) data = data(); - const parent = locales.length ? this._resolveLocale(locales) : this.default; + const parent = this._resolveLocale(locales); return this._cache[locale] = when(data, x => { return when(parent, y => this._cache[locale] = chainObjects(y, x)); diff --git a/src/main/ts/declare.ts b/src/main/ts/declare.ts --- a/src/main/ts/declare.ts +++ b/src/main/ts/declare.ts @@ -132,7 +132,7 @@ export function djclass any) => function () { + const proxy = (m: (...args: any[]) => any) => function (this: any) { return this.inherited(m, arguments); }; @@ -199,11 +199,11 @@ interface MemberBindSpec { getter?: boolean; } -function isNodeBindSpec(v): v is NodeBindSpec { +function isNodeBindSpec(v: any): v is NodeBindSpec { return "node" in v; } -function isMemberBindSpec(v): v is MemberBindSpec { +function isMemberBindSpec(v: any): v is MemberBindSpec { return "member" in v; } @@ -220,7 +220,7 @@ export function bind(params: NodeBindSpe else if (isMemberBindSpec(params)) { return (target: any, name: string) => { target[name] = null; - target[makeSetterName(name)] = function (v) { + target[makeSetterName(name)] = function (v: any) { this._set(name, v); this[params.member].set(params.property, v); }; diff --git a/src/main/ts/djx/BuildContextBase.ts b/src/main/ts/djx/BuildContextBase.ts --- a/src/main/ts/djx/BuildContextBase.ts +++ b/src/main/ts/djx/BuildContextBase.ts @@ -1,12 +1,12 @@ -import { isNull, mixin } from "@implab/core-amd/safe"; +import { isNull, mixin, argumentNotNull } from "@implab/core-amd/safe"; import { isPlainObject, isNode, isBuildContext } from "./traits"; export abstract class BuildContextBase { _attrs = {}; - _children = []; + _children = new Array(); - _created: boolean; + _created: boolean = false; visitNext(v: any) { if (isNull(v)) @@ -28,9 +28,6 @@ export abstract class BuildContextBase { } getChildDom(v: any) { - if (isNull(v)) - return; - const tv = typeof v; if (tv === "string" || tv === "number" || tv === "boolean" || v instanceof RegExp || v instanceof Date) { return document.createTextNode(v.toString()); @@ -48,8 +45,8 @@ export abstract class BuildContextBase { ensureCreated() { if (!this._created) { this._create(this._attrs, this._children); - this._children = null; - this._attrs = null; + this._children = []; + this._attrs = {}; this._created = true; } } diff --git a/src/main/ts/djx/DjxWidgetBase.ts b/src/main/ts/djx/DjxWidgetBase.ts --- a/src/main/ts/djx/DjxWidgetBase.ts +++ b/src/main/ts/djx/DjxWidgetBase.ts @@ -17,23 +17,28 @@ export abstract class DjxWidgetBase exte _processTemplateNode( baseNode: T, getAttrFunc: (baseNode: T, attr: string) => string, - attachFunc: (node: T, type: string, func?: (...args: any[]) => any) => dojo.Handle + // tslint:disable-next-line: ban-types + attachFunc: (node: T, type: string, func?: Function) => dojo.Handle ): boolean { if (isNode(baseNode)) { const w = registry.byNode(baseNode); if (w) { // from dijit/_WidgetsInTemplateMixin this._processTemplateNode(w, - (n, p) => n[p], // callback to get a property of a widget + (n, p) => n.get(p), // callback to get a property of a widget (widget, type, callback) => { + if (!callback) + throw new Error("The callback must be specified"); + // callback to do data-dojo-attach-event to a widget if (type in widget) { // back-compat, remove for 2.0 - return widget.connect(widget, type, callback); + return widget.connect(widget, type, callback as EventListener); } else { // 1.x may never hit this branch, but it's the default for 2.0 return widget.on(type, callback); } + }); // don't process widgets internals return false; diff --git a/src/main/ts/djx/HtmlElementContext.ts b/src/main/ts/djx/HtmlElementContext.ts --- a/src/main/ts/djx/HtmlElementContext.ts +++ b/src/main/ts/djx/HtmlElementContext.ts @@ -6,7 +6,7 @@ import { BuildContextBase } from "./Buil export class HtmlElementContext extends BuildContextBase { elementType: string; - _element: HTMLElement; + _element: HTMLElement | undefined; constructor(elementType: string) { argumentNotEmptyString(elementType, "elementType"); @@ -16,10 +16,15 @@ export class HtmlElementContext extends } _addChild(child: any): void { + if (!this._element) + throw new Error("The HTML element isn't created"); dom.place(this.getChildDom(child), this._element); } _setAttrs(attrs: object): void { + if (!this._element) + throw new Error("The HTML element isn't created"); + attr.set(this._element, attrs); } @@ -31,6 +36,9 @@ export class HtmlElementContext extends } _getDomElement() { + if (!this._element) + throw new Error("The HTML element isn't created"); + return this._element; } diff --git a/src/main/ts/djx/WidgetContext.ts b/src/main/ts/djx/WidgetContext.ts --- a/src/main/ts/djx/WidgetContext.ts +++ b/src/main/ts/djx/WidgetContext.ts @@ -7,7 +7,7 @@ import { BuildContextBase } from "./Buil export class WidgetContext extends BuildContextBase { widgetClass: _WidgetBaseConstructor; - _instance: _WidgetBase; + _instance: _WidgetBase | undefined; constructor(widgetClass: _WidgetBaseConstructor) { super(); @@ -17,14 +17,14 @@ export class WidgetContext extends Build } _addChild(child: any): void { - if (!this._instance.containerNode) + if (!this._instance || !this._instance.containerNode) throw new Error("Widget doesn't support adding children"); dom.place(this.getChildDom(child), this._instance.containerNode); } _setAttrs(attrs: object): void { - this._instance.set(attrs); + this._instance?.set(attrs); } _create(attrs: object, children: any[]) { @@ -34,6 +34,8 @@ export class WidgetContext extends Build } _getDomElement() { + if (!this._instance) + throw new Error("The instance of the widget isn't created"); return this._instance.domNode; } diff --git a/src/main/typings/declarations.d.ts b/src/main/typings/declarations.d.ts new file mode 100644 diff --git a/src/test/ts/Tap.ts b/src/test/ts/Tap.ts new file mode 100644 --- /dev/null +++ b/src/test/ts/Tap.ts @@ -0,0 +1,148 @@ +import { stringify } from "yaml"; + +export interface TapWriter { + version(): void; + plan(n: number): void; + fail(e: any): void; + ok(msg: string): void; + skip(msg: string): void; + bailOut(msg: string): void; + comment(msg: string): void; + yaml(data: any): void; + end(): void; +} + +enum TapState { + Init, + VersionWritten, + Ready, + ReadyWithoutPlan, + End +} + +export abstract class AbstractTapWriter implements TapWriter { + private _state = TapState.Init; + private _version = 13; + private _testIndex = 1; + + private _moveVersion() { + switch (this._state) { + case TapState.Init: + this._state = TapState.VersionWritten; + break; + default: + throw new Error("Invalid operation"); + } + + } + + private _movePlan() { + switch (this._state) { + case TapState.Init: + case TapState.VersionWritten: + this._state = TapState.Ready; + break; + case TapState.ReadyWithoutPlan: + this._state = TapState.End; + break; + default: + throw new Error("Invalid operation"); + } + } + + private _moveTestResult() { + switch (this._state) { + case TapState.Init: + case TapState.VersionWritten: + this._state = TapState.ReadyWithoutPlan; + break; + case TapState.Ready: + case TapState.ReadyWithoutPlan: + break; + default: + throw new Error("Invalid operation"); + } + } + + private _moveEnd() { + switch (this._state) { + case TapState.End: + throw new Error("Invalid operation"); + default: + this._state = TapState.End; + } + } + + private _moveDiag() { + switch (this._state) { + case TapState.Init: + case TapState.VersionWritten: + this._state = TapState.ReadyWithoutPlan; + break; + case TapState.Ready: + case TapState.ReadyWithoutPlan: + break; + default: + throw new Error("Invalid operation"); + } + } + + version() { + this._moveVersion(); + + this._writeLine(`TAP version ${this._version}`); + } + + plan(n: number) { + this._movePlan(); + + this._writeLine(`1..${n}`); + } + + fail(e: any) { + this._moveTestResult(); + + this._writeText(`not ok ${this._testIndex} ${e}`); + this._testIndex++; + } + + ok(msg: string) { + this._moveTestResult(); + + this._writeText(`ok ${this._testIndex} ${msg}`); + this._testIndex++; + } + skip(msg: string) { + this._moveTestResult(); + + this._writeText(`ok ${this._testIndex} # SKIPPED: ${msg}`); + this._testIndex++; + } + bailOut(msg: string) { + this._moveEnd(); + + this._writeText(`Bail out! ${msg}`); + } + comment(msg: string) { + this._moveDiag(); + + this._writeText(`# ${msg}`); + } + yaml(data: any) { + this._moveDiag(); + + this._writeLine(" ---"); + stringify(data).split("\r\n?").forEach(line => this._writeLine(" " + line)); + this._writeLine(" ..."); + } + end() { + this._moveEnd(); + } + + private _writeText(text: string) { + text.split("\r\n?").forEach((line, i) => this._writeLine(i ? "# " + line : line)); + } + + abstract _writeLine(text: string): void; + +} diff --git a/src/test/ts/TestTraits.ts b/src/test/ts/TestTraits.ts --- a/src/test/ts/TestTraits.ts +++ b/src/test/ts/TestTraits.ts @@ -1,18 +1,21 @@ import { IObservable, ICancellation, IDestroyable } from "@implab/core-amd/interfaces"; import { Cancellation } from "@implab/core-amd/Cancellation"; import { TraceEvent, LogLevel, WarnLevel, DebugLevel, TraceSource } from "@implab/core-amd/log/TraceSource"; -import * as tape from "tape"; import { argumentNotNull, destroy } from "@implab/core-amd/safe"; +import { TapWriter } from "./Tap"; + + export class TapeWriter implements IDestroyable { - private readonly _tape: tape.Test; + + private readonly _t: TapWriter; private readonly _subscriptions = new Array(); private _destroyed; - constructor(t: tape.Test) { - argumentNotNull(t, "tape"); - this._tape = t; + constructor(t: TapWriter) { + argumentNotNull(t, "test"); + } writeEvents(source: IObservable, ct: ICancellation = Cancellation.none) { @@ -27,13 +30,13 @@ export class TapeWriter implements IDest writeEvent(next: TraceEvent) { if (next.level >= DebugLevel) { - this._tape.comment(`DEBUG ${next.source.id} ${next}`); + this._t.comment(`DEBUG ${next.source.id} ${next}`); } else if (next.level >= LogLevel) { - this._tape.comment(`LOG ${next.source.id} ${next}`); + this._t.comment(`LOG ${next.source.id} ${next}`); } else if (next.level >= WarnLevel) { - this._tape.comment(`WARN ${next.source.id} ${next}`); + this._t.comment(`WARN ${next.source.id} ${next}`); } else { - this._tape.comment(`ERROR ${next.source.id} ${next}`); + this._t.comment(`ERROR ${next.source.id} ${next}`); } } @@ -42,33 +45,13 @@ export class TapeWriter implements IDest } } -export function test(name: string, cb: (t: tape.Test, trace: TraceSource) => any) { - tape(name, async t => { - const writer = new TapeWriter(t); - - // this trace is not announced through the TraceSource global registry - const trace = new TraceSource(name); - trace.level = DebugLevel; - writer.writeEvents(trace.events); - - const h = TraceSource.on(ts => { - ts.level = DebugLevel; - writer.writeEvents(ts.events); - }); +type TestCallback = (ok: (msg:string) => void, fail: (msg:string) => void, trace: TraceSource) => void; +type AsyncTestCallback = (trace: TraceSource) => PromiseLike | void; - try { - await cb(t, trace); - } catch (e) { +export function test(name: string, cb: TestCallback | AsyncTestCallback) { + +} - // verbose error information - // tslint:disable-next-line - console.error(e); - t.fail(e); +export function run() { - } finally { - t.end(); - destroy(writer); - destroy(h); - } - }); } diff --git a/src/test/ts/TextTapWriter.ts b/src/test/ts/TextTapWriter.ts new file mode 100644 --- /dev/null +++ b/src/test/ts/TextTapWriter.ts @@ -0,0 +1,18 @@ +import { AbstractTapWriter } from "./Tap"; +import { TextWriter } from "@implab/core-amd/interfaces"; + +export class TextTapWriter extends AbstractTapWriter { + + private readonly _writer: TextWriter; + + constructor(writer: TextWriter) { + super(); + + this._writer = writer; + } + + _writeLine(text: string) { + this._writer.writeLine(text); + } + +} \ No newline at end of file diff --git a/src/test/ts/dummy.ts b/src/test/ts/dummy.ts --- a/src/test/ts/dummy.ts +++ b/src/test/ts/dummy.ts @@ -1,10 +1,16 @@ -import * as tape from "tape"; +import { test } from "./TestTraits"; +import { delay } from "@implab/core-amd/safe"; +import { assert } from "chai"; -tape("simple", t => { - t.pass("sync assert"); +test("simple", (ok, fail, log) => { setTimeout(() => { - t.pass("async assert"); // end should be called after the last assertion - t.end(); + ok("async assert"); }, 100); }); + +test("simple", async log => { + await delay(0); + + assert.ok(true); // everything is fine +}); diff --git a/src/tsconfig.json b/src/tsconfig.json --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "moduleResolution": "node", "noEmitOnError": true, + "strict": true, "types": [], "experimentalDecorators": true, "jsxFactory": "createElement",