From 0c8fd1f957ef3727b44321812a3d1f66effbeec3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 5 Jan 2021 10:50:59 -0500 Subject: [PATCH] convert to JS --- package-lock.json | 862 +++++++---------------------- package.json | 23 +- rollup.config.js | 11 +- src/index.js | 14 + src/index.ts | 17 - src/load.js | 67 +++ src/load.ts | 58 -- src/package.json | 3 + src/{transform.ts => transform.js} | 234 +++++--- test/{test.ts => test.mjs} | 2 +- tsconfig.json | 28 +- 11 files changed, 484 insertions(+), 835 deletions(-) create mode 100644 src/index.js delete mode 100644 src/index.ts create mode 100644 src/load.js delete mode 100644 src/load.ts create mode 100644 src/package.json rename src/{transform.ts => transform.js} (76%) rename test/{test.ts => test.mjs} (92%) diff --git a/package-lock.json b/package-lock.json index fc38c2c..355528e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,24 +36,25 @@ "integrity": "sha512-3NsZsJIA/22P3QUyrEDNA2D133H4j224twJrdipXN38dpnIOzAbUDtOwkcJ5pXmn75w7LSQDjA4tO9dm1XlqlA==", "dev": true }, - "@rollup/plugin-replace": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.3.3.tgz", - "integrity": "sha512-XPmVXZ7IlaoWaJLkSCDaa0Y6uVo5XQYHhiMFzOd5qSv5rE+t/UJToPIOE56flKIxBFQI27ONsxb7dqHnwSsjKQ==", + "@rollup/plugin-buble": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz", + "integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==", "dev": true, "requires": { "@rollup/pluginutils": "^3.0.8", - "magic-string": "^0.25.5" + "@types/buble": "^0.19.2", + "buble": "^0.20.0" } }, - "@rollup/plugin-typescript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-6.0.0.tgz", - "integrity": "sha512-Y5U2L4eaF3wUSgCZRMdvNmuzWkKMyN3OwvhAdbzAi5sUqedaBk/XbzO4T7RlViDJ78MOPhwAIv2FtId/jhMtbg==", + "@rollup/plugin-replace": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.3.4.tgz", + "integrity": "sha512-waBhMzyAtjCL1GwZes2jaE9MjuQ/DQF2BatH3fRivUF3z0JBFrU0U6iBNC/4WR+2rLKhaAhPWDNPYp4mI6RqdQ==", "dev": true, "requires": { "@rollup/pluginutils": "^3.1.0", - "resolve": "^1.17.0" + "magic-string": "^0.25.7" } }, "@rollup/pluginutils": { @@ -67,28 +68,49 @@ "picomatch": "^2.2.2" } }, + "@types/buble": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz", + "integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==", + "dev": true, + "requires": { + "magic-string": "^0.25.0" + } + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, - "@types/mocha": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.3.tgz", - "integrity": "sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg==", + "@types/node": { + "version": "14.14.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.20.tgz", + "integrity": "sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==", "dev": true }, - "@types/node": { - "version": "14.11.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.1.tgz", - "integrity": "sha512-oTQgnd0hblfLsJ6BvJzzSL+Inogp3lq9fGgqRkMB/ziKMgEUaFl801OncOzUmalfzt14N0oPHMK47ipl+wbTIw==", + "acorn": { + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", + "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", + "dev": true + }, + "acorn-dynamic-import": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", + "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", + "dev": true + }, + "acorn-jsx": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", + "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", "dev": true }, "ajv": { - "version": "6.12.5", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.5.tgz", - "integrity": "sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==", + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -118,18 +140,6 @@ "color-convert": "^1.9.0" } }, - "any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", - "dev": true - }, - "array-filter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz", - "integrity": "sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=", - "dev": true - }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -145,27 +155,12 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, - "async": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", - "dev": true - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, - "available-typed-arrays": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz", - "integrity": "sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==", - "dev": true, - "requires": { - "array-filter": "^1.0.0" - } - }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -173,9 +168,9 @@ "dev": true }, "aws4": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", - "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", + "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, "balanced-match": { @@ -212,6 +207,29 @@ "concat-map": "0.0.1" } }, + "buble": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz", + "integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==", + "dev": true, + "requires": { + "acorn": "^6.4.1", + "acorn-dynamic-import": "^4.0.0", + "acorn-jsx": "^5.2.0", + "chalk": "^2.4.2", + "magic-string": "^0.25.7", + "minimist": "^1.2.5", + "regexpu-core": "4.5.4" + }, + "dependencies": { + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + } + } + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -286,8 +304,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true, - "optional": true + "dev": true }, "combined-stream": { "version": "1.0.8", @@ -298,12 +315,6 @@ "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true - }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -322,12 +333,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "cycle": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", - "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=", - "dev": true - }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -337,37 +342,6 @@ "assert-plus": "^1.0.0" } }, - "deep-equal": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.0.3.tgz", - "integrity": "sha512-Spqdl4H+ky45I9ByyJtXteOm9CaIrPmnIPmOhrkKGNYWeDgCvJ8jNYVCTjChxW4FqGuZnLHADc8EKRMX6+CgvA==", - "dev": true, - "requires": { - "es-abstract": "^1.17.5", - "es-get-iterator": "^1.1.0", - "is-arguments": "^1.0.4", - "is-date-object": "^1.0.2", - "is-regex": "^1.0.5", - "isarray": "^2.0.5", - "object-is": "^1.1.2", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "regexp.prototype.flags": "^1.3.0", - "side-channel": "^1.0.2", - "which-boxed-primitive": "^1.0.1", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.2" - } - }, - "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" - } - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -375,15 +349,15 @@ "dev": true }, "dequal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dequal/-/dequal-1.0.1.tgz", - "integrity": "sha512-Fx8jxibzkJX2aJgyfSdLhr9tlRoTnHKrRJuu2XHlAgKioN2j19/Bcbe0d4mFXYZ3+wpE2KVobUVTfDutcD17xQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz", + "integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==", "dev": true }, "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true }, "ecc-jsbn": { @@ -396,51 +370,6 @@ "safer-buffer": "^2.1.0" } }, - "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", - "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.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-get-iterator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.0.tgz", - "integrity": "sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==", - "dev": true, - "requires": { - "es-abstract": "^1.17.4", - "has-symbols": "^1.0.1", - "is-arguments": "^1.0.4", - "is-map": "^2.0.1", - "is-set": "^2.0.1", - "is-string": "^1.0.5", - "isarray": "^2.0.5" - } - }, - "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", @@ -476,12 +405,6 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", "dev": true }, - "eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", - "dev": true - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -503,12 +426,6 @@ "escape-string-regexp": "^1.0.5" } }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -551,12 +468,6 @@ "rimraf": "2" } }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, "get-port": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", @@ -608,27 +519,12 @@ "har-schema": "^2.0.0" } }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "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 - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -640,12 +536,6 @@ "sshpk": "^1.7.0" } }, - "i": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz", - "integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=", - "dev": true - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -709,36 +599,6 @@ } } }, - "is-arguments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", - "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", - "dev": true - }, - "is-bigint": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.0.tgz", - "integrity": "sha512-t5mGUXC/xRheCK431ylNiSkGGpBp8bHENBcENTkDT6ppwPzEVxNGZRvgvmOEfbWkFhA7D2GEuE2mmQTr78sl2g==", - "dev": true - }, - "is-boolean-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.0.1.tgz", - "integrity": "sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ==", - "dev": true - }, - "is-callable": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz", - "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==", - "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-domain": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/is-domain/-/is-domain-0.0.1.tgz", @@ -751,90 +611,12 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, - "is-map": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz", - "integrity": "sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==", - "dev": true - }, - "is-negative-zero": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.0.tgz", - "integrity": "sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE=", - "dev": true - }, - "is-number-object": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", - "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - }, - "is-set": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.1.tgz", - "integrity": "sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==", - "dev": true - }, - "is-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", - "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", - "dev": true - }, - "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" - } - }, - "is-typed-array": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.3.tgz", - "integrity": "sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ==", - "dev": true, - "requires": { - "available-typed-arrays": "^1.0.0", - "es-abstract": "^1.17.4", - "foreach": "^2.0.5", - "has-symbols": "^1.0.1" - } - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, - "is-weakmap": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz", - "integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==", - "dev": true - }, - "is-weakset": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.1.tgz", - "integrity": "sha512-pi4vhbhVHGLxohUw7PhGsueT4vRGFoXhP7+RGN0jKIv9+8PWYCQTqtADngrxOm2g46hoH0+g8uZZBzMrvVGDmw==", - "dev": true - }, - "isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true - }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -881,6 +663,12 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -912,21 +700,15 @@ } }, "kleur": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.1.tgz", - "integrity": "sha512-BsNhM6T/yTWFG580CRnYhT3LfUuPK7Hwrm+W2H0G8lK/nogalP5Nsrh/cHjxVVkzl0sFm7z8b8rNcZCfKxeoxA==", - "dev": true - }, - "lines-and-columns": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", - "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.3.tgz", + "integrity": "sha512-H1tr8QP2PxFTNwAFM74Mui2b6ovcY9FoxJefgrwxY+OCJcq01k5nvhf4M/KnizzrJvLRap5STUy7dgDV35iUBw==", "dev": true }, "local-access": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/local-access/-/local-access-1.0.1.tgz", - "integrity": "sha512-ykt2pgN0aqIy6KQC1CqdWTWkmUwNgaOS6dcpHVjyBJONA+Xi7AtSB1vuxC/U/0tjIP3wcRudwQk1YYzUvzk2bA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/local-access/-/local-access-1.1.0.tgz", + "integrity": "sha512-XfegD5pyTAfb+GY6chk283Ox5z8WexG56OvM06RWLpAc/UHozO8X6xAxEkIitZOtsSMM1Yr3DkHgW5W+onLhCw==", "dev": true }, "locate-character": { @@ -957,24 +739,24 @@ "dev": true }, "mime": { - "version": "2.4.6", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", - "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==", + "version": "2.4.7", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.7.tgz", + "integrity": "sha512-dhNd1uA2u397uQk3Nv5LM4lm93WYDUXFn3Fu291FJerns4jyTudqhIWe4W04YLy7Uk1tm1Ore04NpjRvQp/NPA==", "dev": true }, "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", + "version": "1.45.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz", + "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==", "dev": true }, "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "version": "2.1.28", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz", + "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==", "dev": true, "requires": { - "mime-db": "1.44.0" + "mime-db": "1.45.0" } }, "mimic-fn": { @@ -1033,35 +815,12 @@ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, - "mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dev": true, - "requires": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, - "ncp": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz", - "integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ=", - "dev": true - }, "netrc": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/netrc/-/netrc-0.1.4.tgz", "integrity": "sha1-a+lPysqNd63gqWcNxGCRTJRHJEQ=", "dev": true }, - "node-modules-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", - "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", - "dev": true - }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -1074,62 +833,6 @@ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object-is": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.2.tgz", - "integrity": "sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - } - }, - "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.1", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.1.tgz", - "integrity": "sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.0", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - }, - "dependencies": { - "es-abstract": { - "version": "1.18.0-next.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.0.tgz", - "integrity": "sha512-elZXTZXKn51hUBdJjSZGYRujuzilgXo8vSPQzjGYXLvSlGiCo8VO8ZGV3kjo9a0WNJJ57hENagwbtlRuHuzkcQ==", - "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.2.0", - "is-negative-zero": "^2.0.0", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - } - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1166,12 +869,6 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -1184,25 +881,10 @@ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true }, - "pirates": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.1.tgz", - "integrity": "sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==", - "dev": true, - "requires": { - "node-modules-regexp": "^1.0.0" - } - }, - "pkginfo": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", - "integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=", - "dev": true - }, "pretty-ms": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.0.tgz", - "integrity": "sha512-J3aPWiC5e9ZeZFuSeBraGxSkGMOvulSWsxDByOcbD1Pr75YL3LSNIKIb52WXbCLE1sS5s4inBBbryjF4Y05Ceg==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz", + "integrity": "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==", "dev": true, "requires": { "parse-ms": "^2.1.0" @@ -1214,19 +896,6 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, - "prompt": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/prompt/-/prompt-0.2.14.tgz", - "integrity": "sha1-V3VPZPVD/XsIRXB8gY7OYY8F/9w=", - "dev": true, - "requires": { - "pkginfo": "0.x.x", - "read": "1.0.x", - "revalidator": "0.1.x", - "utile": "0.2.x", - "winston": "0.8.x" - } - }, "psl": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", @@ -1263,14 +932,48 @@ "mute-stream": "~0.0.4" } }, - "regexp.prototype.flags": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", - "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "regenerate": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "dev": true + }, + "regenerate-unicode-properties": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz", + "integrity": "sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA==", "dev": true, "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1" + "regenerate": "^1.4.0" + } + }, + "regexpu-core": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz", + "integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==", + "dev": true, + "requires": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^8.0.2", + "regjsgen": "^0.5.0", + "regjsparser": "^0.6.0", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.1.0" + } + }, + "regjsgen": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz", + "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==", + "dev": true + }, + "regjsparser": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.4.tgz", + "integrity": "sha512-64O87/dPDgfk8/RQqC4gkZoGyyWFIEUTTh80CU6CWuK5vkCGyekIx+oKcEIYtP/RAxSQltCZHCNu/mdd7fqlJw==", + "dev": true, + "requires": { + "jsesc": "~0.5.0" } }, "request": { @@ -1301,15 +1004,6 @@ "uuid": "^3.3.2" } }, - "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - }, "restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -1320,12 +1014,6 @@ "signal-exit": "^3.0.2" } }, - "revalidator": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", - "integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs=", - "dev": true - }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -1336,9 +1024,9 @@ } }, "rollup": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.27.1.tgz", - "integrity": "sha512-GiWHQvnmMgBktSpY/1+nrGpwPsTw4b9P28og2uedfeq4JZ16rzAmnQ5Pm/E0/BEmDNia1ZbY7+qu3nBgNa19Hg==", + "version": "2.36.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.36.0.tgz", + "integrity": "sha512-L38QyQK77bkJy9nPyeydnHFK6xMofqumh4scTV2d4RG4EFq6pGdxnn67dVHFUDJ9J0PSEQx8zn1FiVS5TydsKg==", "dev": true, "requires": { "fsevents": "~2.1.2" @@ -1372,9 +1060,9 @@ } }, "sade": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/sade/-/sade-1.7.3.tgz", - "integrity": "sha512-m4BctppMvJ60W1dXnHq7jMmFe3hPJZDAH85kQ3ACTo7XZNVUuTItCQ+2HfyaMeV5cKrbw7l4vD/6We3GBxvdJw==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.7.4.tgz", + "integrity": "sha512-y5yauMD93rX840MwUJr7C1ysLFBgMspsdTo4UVrDg3fXDvtwOyIqykhVAAm6fk/3au77773itJStObgK+LKaiA==", "dev": true, "requires": { "mri": "^1.1.0" @@ -1407,38 +1095,6 @@ "randombytes": "^2.1.0" } }, - "side-channel": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.3.tgz", - "integrity": "sha512-A6+ByhlLkksFoUepsGxfj5x1gTSrs+OydsRptUxeNCabQpCFUvcwIczgOigI8vhY/OJCnPnyE9rGiwgvr9cS1g==", - "dev": true, - "requires": { - "es-abstract": "^1.18.0-next.0", - "object-inspect": "^1.8.0" - }, - "dependencies": { - "es-abstract": { - "version": "1.18.0-next.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.0.tgz", - "integrity": "sha512-elZXTZXKn51hUBdJjSZGYRujuzilgXo8vSPQzjGYXLvSlGiCo8VO8ZGV3kjo9a0WNJJ57hENagwbtlRuHuzkcQ==", - "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.2.0", - "is-negative-zero": "^2.0.0", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - } - } - }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -1446,9 +1102,9 @@ "dev": true }, "sirv": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.6.tgz", - "integrity": "sha512-LRGu7Op4Xl9hhigOy2kcB53zAYTjNDdpooey49dIU0cMdpOv9ithVf7nstk3jvs8EhMiT/VORoyazZYGgw4vnA==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.10.tgz", + "integrity": "sha512-H5EZCoZaggEUQy8ocKsF7WAToGuZhjJlLvM3XOef46CbdIgbNeQ1p32N1PCuCjkVYwrAVOSMacN6CXXgIzuspg==", "dev": true, "requires": { "@polka/url": "^1.0.0-next.9", @@ -1457,9 +1113,9 @@ } }, "sirv-cli": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.6.tgz", - "integrity": "sha512-K/iY1OHG7hTw4GzLoqMhwzKCbgWmx5joYAAF2+CwyiamWCpVzAgNVWgAc0JmSA2Gf3wseov05il2QbFTGTZMVg==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.10.tgz", + "integrity": "sha512-8mLTRkvzpZXMyUZJ1whf84YHN/mm2r2+j5sU1ZYr5n2jA8VkFItNPk53oysOo+0QxBVp9aUjggkAsQp1d7L3OQ==", "dev": true, "requires": { "console-clear": "^1.1.0", @@ -1468,7 +1124,7 @@ "local-access": "^1.0.1", "sade": "^1.6.0", "semiver": "^1.0.0", - "sirv": "^1.0.6", + "sirv": "^1.0.10", "tinydate": "^1.0.0" }, "dependencies": { @@ -1528,12 +1184,6 @@ "tweetnacl": "~0.14.0" } }, - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", - "dev": true - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -1544,26 +1194,6 @@ "strip-ansi": "^4.0.0" } }, - "string.prototype.trimend": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", - "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - } - }, - "string.prototype.trimstart": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", - "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - } - }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -1573,20 +1203,6 @@ "ansi-regex": "^3.0.0" } }, - "sucrase": { - "version": "3.15.0", - "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.15.0.tgz", - "integrity": "sha512-05TJOUfMgckH7wKqfk/1p4G6q16nIeW/GHQwD44vkT0mQMqqzgfHCwkX3whNmwyOo7nVF0jDLwVu/qOBTtsscw==", - "dev": true, - "requires": { - "commander": "^4.0.0", - "glob": "7.1.6", - "lines-and-columns": "^1.1.6", - "mz": "^2.7.0", - "pirates": "^4.0.1", - "ts-interface-checker": "^0.1.9" - } - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -1597,19 +1213,19 @@ } }, "surge": { - "version": "0.21.6", - "resolved": "https://registry.npmjs.org/surge/-/surge-0.21.6.tgz", - "integrity": "sha512-FejQvGH9G1Xt9nWGaQnwX5anKReDJkFUrAh3/UCroJTf/M91hId8JOt1N6Glgh9T2Sz8G4DFaFFHJsoPaI5DBw==", + "version": "0.21.7", + "resolved": "https://registry.npmjs.org/surge/-/surge-0.21.7.tgz", + "integrity": "sha512-XcMY2Z3I4kBZ1zVTOkeKmTcnAy/r9Mnu87+/3fAaN6ZCVnNy4Qtdh6ai77NwyORIltRP1cOn05sAi+nYoy5taQ==", "dev": true, "requires": { "cli-table3": "^0.5.1", + "colors": "^1.4.0", "inquirer": "^6.2.2", "is-domain": "0.0.1", "minimist": "1.2.3", "moniker": "0.1.2", "netrc": "0.1.4", "progress": "1.1.8", - "prompt": "~0.2.14", "read": "1.0.5", "request": "^2.88.0", "split": "0.3.1", @@ -1666,24 +1282,6 @@ } } }, - "thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dev": true, - "requires": { - "any-promise": "^1.0.0" - } - }, - "thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", - "dev": true, - "requires": { - "thenify": ">= 3.1.0 < 4" - } - }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -1721,16 +1319,10 @@ "punycode": "^2.1.1" } }, - "ts-interface-checker": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", - "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", - "dev": true - }, "tslib": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, "tunnel-agent": { @@ -1748,10 +1340,32 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, - "typescript": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.3.tgz", - "integrity": "sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==", + "unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "dev": true + }, + "unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dev": true, + "requires": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + } + }, + "unicode-match-property-value-ecmascript": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz", + "integrity": "sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ==", + "dev": true + }, + "unicode-property-aliases-ecmascript": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz", + "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==", "dev": true }, "uri-js": { @@ -1769,20 +1383,6 @@ "integrity": "sha1-+4CQGIPzOLPL7TU49fqiatr38uc=", "dev": true }, - "utile": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/utile/-/utile-0.2.1.tgz", - "integrity": "sha1-kwyI6ZCY1iIINMNWy9mncFItkNc=", - "dev": true, - "requires": { - "async": "~0.2.9", - "deep-equal": "*", - "i": "0.3.x", - "mkdirp": "0.x.x", - "ncp": "0.4.x", - "rimraf": "2.x.x" - } - }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -1790,16 +1390,24 @@ "dev": true }, "uvu": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.3.3.tgz", - "integrity": "sha512-5oeS+bkoRM5FGjXMXCZvjLLeUB9P5HXn2LFiTQaItopJFBtXuJ2XxWkWJNe2NgWthxFUOZR+eyhodgiaFqv7wQ==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.1.tgz", + "integrity": "sha512-JGxttnOGDFs77FaZ0yMUHIzczzQ5R1IlDeNW6Wymw6gAscwMdAffVOP6TlxLIfReZyK8tahoGwWZaTCJzNFDkg==", "dev": true, "requires": { - "dequal": "^1.0.0", - "diff": "^4.0.2", + "dequal": "^2.0.0", + "diff": "^5.0.0", "kleur": "^4.0.3", "sade": "^1.7.3", - "totalist": "^1.1.0" + "totalist": "^2.0.0" + }, + "dependencies": { + "totalist": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-2.0.0.tgz", + "integrity": "sha512-+Y17F0YzxfACxTyjfhnJQEe7afPA0GSpYlFkl2VFMxYP7jshQf9gXV7cH47EfToBumFThfKBvfAcoUn6fdNeRQ==", + "dev": true + } } }, "verror": { @@ -1813,74 +1421,6 @@ "extsprintf": "^1.2.0" } }, - "which-boxed-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz", - "integrity": "sha512-7BT4TwISdDGBgaemWU0N0OU7FeAEJ9Oo2P1PHRm/FCWoEi2VLWC9b6xvxAA3C/NMpxg3HXVgi0sMmGbNUbNepQ==", - "dev": true, - "requires": { - "is-bigint": "^1.0.0", - "is-boolean-object": "^1.0.0", - "is-number-object": "^1.0.3", - "is-string": "^1.0.4", - "is-symbol": "^1.0.2" - } - }, - "which-collection": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz", - "integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==", - "dev": true, - "requires": { - "is-map": "^2.0.1", - "is-set": "^2.0.1", - "is-weakmap": "^2.0.1", - "is-weakset": "^2.0.1" - } - }, - "which-typed-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.2.tgz", - "integrity": "sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ==", - "dev": true, - "requires": { - "available-typed-arrays": "^1.0.2", - "es-abstract": "^1.17.5", - "foreach": "^2.0.5", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.1", - "is-typed-array": "^1.1.3" - } - }, - "winston": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/winston/-/winston-0.8.3.tgz", - "integrity": "sha1-ZLar9M0Brcrv1QCTk7HY6L7BnbA=", - "dev": true, - "requires": { - "async": "0.2.x", - "colors": "0.6.x", - "cycle": "1.0.x", - "eyes": "0.1.x", - "isstream": "0.1.x", - "pkginfo": "0.3.x", - "stack-trace": "0.0.x" - }, - "dependencies": { - "colors": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", - "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", - "dev": true - }, - "pkginfo": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", - "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", - "dev": true - } - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 620129b..20bdc6c 100644 --- a/package.json +++ b/package.json @@ -9,25 +9,22 @@ "index.dev.js" ], "devDependencies": { - "@rollup/plugin-replace": "^2.3.3", - "@rollup/plugin-typescript": "^6.0.0", - "@types/mocha": "^8.0.3", - "@types/node": "^14.11.1", - "kleur": "^4.1.1", + "@rollup/plugin-buble": "^0.21.3", + "@rollup/plugin-replace": "^2.3.4", + "@types/node": "^14.14.20", + "kleur": "^4.1.3", "locate-character": "^2.0.5", - "pretty-ms": "^7.0.0", - "rollup": "^2.27.1", + "pretty-ms": "^7.0.1", + "rollup": "^2.36.0", "rollup-plugin-terser": "^7.0.2", - "sirv-cli": "^1.0.6", - "sucrase": "^3.15.0", - "surge": "^0.21.6", - "typescript": "^4.0.3", - "uvu": "^0.3.3" + "sirv-cli": "^1.0.10", + "surge": "^0.21.7", + "uvu": "^0.5.1" }, "scripts": { "dev": "rollup -cw", "build": "rollup -c", - "test": "uvu -r sucrase/register/ts test test.ts", + "test": "uvu test test.mjs", "prepublishOnly": "npm test && npm run build", "deploy": "npm run build && npm run demos:build && surge demos --domain shimport-demos.surge.sh", "demos:build": "cp index.js demos/shimport.js && cp index.dev.js demos/shimport.dev.js && node demos/build.js", diff --git a/rollup.config.js b/rollup.config.js index ec8836d..6ac8d89 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,24 +1,23 @@ -import typescript from '@rollup/plugin-typescript'; +import buble from '@rollup/plugin-buble'; import replace from '@rollup/plugin-replace'; import { terser } from 'rollup-plugin-terser'; import pkg from './package.json'; const config = dev => ({ - input: 'src/index.ts', + input: 'src/index.js', output: [ { file: dev ? 'index.dev.js' : pkg.main, format: 'iife', - name: '__shimport__' + name: '__shimport__', + esModule: false } ], plugins: [ replace({ __VERSION__: pkg.version }), - typescript({ - typescript: require('typescript') - }), + buble(), !dev && terser({ output: { comments: false diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..481b227 --- /dev/null +++ b/src/index.js @@ -0,0 +1,14 @@ +//@ts-check +import { transform } from './transform.js'; +import { define, load } from './load.js'; + +if (typeof document !== 'undefined') { + const scr = document.querySelector('[data-main]'); + if (scr) { + load(new URL(scr.getAttribute('data-main'), document.baseURI).toString()); + } +} + +const VERSION = "__VERSION__"; + +export { transform, define, load, VERSION }; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 4893105..0000000 --- a/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { transform } from './transform'; -import { define, load } from './load'; - -interface Script extends Element { - dataset: Record; -} - -if (typeof document !== 'undefined') { - const scr: Script = document.querySelector('[data-main]'); - if (scr) { - load(new URL(scr.getAttribute('data-main'), document.baseURI)); - } -} - -const VERSION = "__VERSION__"; - -export { transform, define, load, VERSION }; \ No newline at end of file diff --git a/src/load.js b/src/load.js new file mode 100644 index 0000000..26ee382 --- /dev/null +++ b/src/load.js @@ -0,0 +1,67 @@ +// @ts-check +import { transform } from './transform.js'; + +/** @type {Record>} */ +const promises = {}; + +/** @typedef {(id: string) => Promise} __Import */ +/** @typedef {Record} __Exports */ + +/** + * @param {string} id + * @param {string[]} deps + * @param {(__import: __Import, __exports: __Exports, ...deps: any[]) => void} factory + */ +export function define(id, deps, factory) { + const __import = (dep) => load(new URL(dep, id).toString()); + + return Promise.all(deps.map(__import)).then(__deps => { + const __exports = {}; + + factory(__import, __exports, ...__deps); + return __exports; + }); +} + +/** + * @param {string} url + */ +export function load(url) { + return promises[url] || ( + promises[url] = fetch(url) + .then(r => r.text()) + .then(text => evaluate(transform(text, url))) + ); +} + +let uid = 1; + +/** + * @param {string} code + */ +function evaluate(code) { + if (typeof document !== 'undefined' && typeof URL !== 'undefined') { + return new Promise(fulfil => { + const id = `__shimport__${uid++}`; + + // creating a script tag gives us proper stack traces + const blob = new Blob([`${id}=${code}`], { + type: 'application/javascript' + }); + + const script = document.createElement('script'); + script.src = URL.createObjectURL(blob); + + script.onload = () => { + fulfil(window[id]); + delete window[id]; + }; + + document.head.appendChild(script); + }); + + } else { + // for browsers without `URL` + return (0,eval)(code); + } +} \ No newline at end of file diff --git a/src/load.ts b/src/load.ts deleted file mode 100644 index 2b7f471..0000000 --- a/src/load.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { transform } from './transform'; - -const promises: Record> = {}; - -type __Import = (id: string) => Promise; -type __Exports = Record; - -export function define( - id: string, - deps: string[], - factory: (__import: __Import, __exports: __Exports, ...deps: any[]) => void -) { - const __import = (dep: string) => load(new URL(dep, id)); - - return Promise.all(deps.map(__import)).then(__deps => { - const __exports = {}; - - factory(__import, __exports, ...__deps); - return __exports; - }); -} - -export function load(url: string | URL) { - return promises[url] || ( - promises[url] = fetch(url) - .then(r => r.text()) - .then(text => evaluate(transform(text, url))) - ); -} - -let uid = 1; - -function evaluate(code: string) { - if (typeof document !== 'undefined' && typeof URL !== 'undefined') { - return new Promise(fulfil => { - const id = `__shimport__${uid++}`; - - // creating a script tag gives us proper stack traces - const blob = new Blob([`${id}=${code}`], { - type: 'application/javascript' - }); - - const script = document.createElement('script'); - script.src = URL.createObjectURL(blob); - - script.onload = () => { - fulfil((window as any)[id]); - delete (window as any)[id]; - }; - - document.head.appendChild(script); - }); - - } else { - // for browsers without `URL` - return (0,eval)(code); - } -} \ No newline at end of file diff --git a/src/package.json b/src/package.json new file mode 100644 index 0000000..47dc78d --- /dev/null +++ b/src/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} \ No newline at end of file diff --git a/src/transform.ts b/src/transform.js similarity index 76% rename from src/transform.ts rename to src/transform.js index 7158296..47216d0 100644 --- a/src/transform.ts +++ b/src/transform.js @@ -1,28 +1,44 @@ -type State = { +//@ts-check + +/** @typedef {{ name?: string; pattern: RegExp; handlers: Array<(i?: number, token?: string) => State | void> -}; +}} State */ -type Specifier = { +/** @typedef {{ name: string; as: string; -} +}} Specifier */ -interface Range { +/** @typedef {{ start: number; end: number; + toString: (nameBySource?: Map) => string; + specifiers?: Specifier[]; [key: string]: any; -} - -function get_alias(specifiers: Specifier[], name: string) { +}} Range */ + +/** + * + * @param {Specifier[]} specifiers + * @param {string} name + */ +function get_alias(specifiers, name) { let i = specifiers.length; while (i--) { if (specifiers[i].name === name) return specifiers[i].as; } } -function importDecl(str: string, start: number, end: number, specifiers: Specifier[], source: string) { +/** + * @param {string} str + * @param {number} start + * @param {number} end + * @param {Specifier[]} specifiers + * @param {string} source + */ +function importDecl(str, start, end, specifiers, source) { const name = get_alias(specifiers, '*') || get_alias(specifiers, 'default'); return { @@ -37,7 +53,12 @@ function importDecl(str: string, start: number, end: number, specifiers: Specifi }; } -function exportDefaultDeclaration(str: string, start: number, end: number) { +/** + * @param {string} str + * @param {number} start + * @param {number} end + */ +function exportDefaultDeclaration(str, start, end) { const match = /^\s*(?:(class)(\s+extends|\s*{)|(function)\s*\()/.exec(str.slice(end)); if (match) { @@ -68,14 +89,25 @@ function exportDefaultDeclaration(str: string, start: number, end: number) { }; } -function exportSpecifiersDeclaration(str: string, start: number, specifiersStart: number, specifiersEnd: number, end: number, source: string) { +/** + * @param {string} str + * @param {number} start + * @param {number} specifiersStart + * @param {number} specifiersEnd + * @param {number} end + * @param {string} source + */ +function exportSpecifiersDeclaration(str, start, specifiersStart, specifiersEnd, end, source) { const specifiers = processSpecifiers(str.slice(specifiersStart + 1, specifiersEnd - 1).trim()); return { start, end, source, - toString(nameBySource: Map) { + /** + * @param {Map} nameBySource + */ + toString(nameBySource) { const name = source && nameBySource.get(source); return specifiers @@ -87,7 +119,12 @@ function exportSpecifiersDeclaration(str: string, start: number, specifiersStart }; } -function exportDecl(str: string, start: number, c: number) { +/** + * @param {string} str + * @param {number} start + * @param {number} c + */ +function exportDecl(str, start, c) { const end = c; while (str[c] && /\S/.test(str[c])) c += 1; @@ -109,12 +146,21 @@ function exportDecl(str: string, start: number, c: number) { }; } -function exportStarDeclaration(str: string, start: number, end: number, source: string) { +/** + * @param {string} str + * @param {number} start + * @param {number} end + * @param {string} source + */ +function exportStarDeclaration(str, start, end, source) { return { start, end, source, - toString(nameBySource: Map) { + /** + * @param {Map} nameBySource + */ + toString(nameBySource) { return `Object.assign(__exports, ${nameBySource.get(source)}); /*${str.slice(start, end)}*/`; } }; @@ -129,12 +175,18 @@ const keywordChars = /[a-zA-Z_$0-9]/; const whitespace_obj = { ' ': 1, '\t': 1, '\n': 1, '\r': 1, '\f': 1, '\v': 1, '\u00A0': 1, '\u2028': 1, '\u2029': 1 }; -function isWhitespace(char: string) { +/** + * @param {string} char + */ +function isWhitespace(char) { // this is faster than testing a regex return char in whitespace_obj; } -function isQuote(char: string) { +/** + * @param {string} char + */ +function isQuote(char) { return char === "'" || char === '"'; } @@ -142,7 +194,11 @@ const namespaceImport = /^\*\s+as\s+(\w+)$/; const defaultAndStarImport = /(\w+)\s*,\s*\*\s*as\s*(\w+)$/; const defaultAndNamedImport = /(\w+)\s*,\s*{(.+)}$/; -function processImportSpecifiers(str: string): Specifier[] { +/** + * @param {string} str + * @returns {Specifier[]} + */ +function processImportSpecifiers(str) { let match = namespaceImport.exec(str); if (match) { return [{ name: '*', as: match[1] }]; @@ -165,7 +221,11 @@ function processImportSpecifiers(str: string): Specifier[] { return []; } -function processSpecifiers(str: string) { +/** + * @param {string} str + * @returns {Specifier[]} + */ +function processSpecifiers(str) { return str ? str.split(',').map(part => { const [name, , as] = part.trim().split(/[^\S]+/); @@ -174,7 +234,11 @@ function processSpecifiers(str: string) { : []; } -function getImportDeclaration(str: string, i: number) { +/** + * @param {string} str + * @param {number} i + */ +function getImportDeclaration(str, i) { const start = i; const specifierStart = i += 6; @@ -195,7 +259,10 @@ function getImportDeclaration(str: string, i: number) { ); } -function getImportStatement(i: number) { +/** + * @param {number} i + */ +function getImportStatement(i) { return { start: i, end: i + 6, @@ -207,7 +274,12 @@ function getImportStatement(i: number) { const importMetaUrlPattern = /^import\s*\.\s*meta\s*\.\s*url/; -function getImportMetaUrl(str: string, start: number, id: string) { +/** + * @param {string} str + * @param {number} start + * @param {string} id + */ +function getImportMetaUrl(str, start, id) { const match = importMetaUrlPattern.exec(str.slice(start)); if (match) { return { @@ -220,7 +292,11 @@ function getImportMetaUrl(str: string, start: number, id: string) { } } -function getExportDeclaration(str: string, i: number) { +/** + * @param {string} str + * @param {number} i + */ +function getExportDeclaration(str, i) { const start = i; i += 6; @@ -292,28 +368,45 @@ function getExportDeclaration(str: string, i: number) { ); } -function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { - let escapedFrom: State; +/** + * @param {string} str + * @param {string} id + * @returns {[Range[], Range[], Range[], Range[]]} + */ +function find(str, id) { + /** @type {State} */ + let escapedFrom; let regexEnabled = true; let pfixOp = false; - const stack: State[] = []; + /** @type {State[]} */ + const stack = []; let lsci = -1; // last significant character index const lsc = () => str[lsci]; - var parenMatches: Record = {}; - var openingParenPositions: Record = {}; - var parenDepth = 0; + /** @type {Record} */ + const parenMatches = {}; + + /** @type {Record} */ + const openingParenPositions = {}; + let parenDepth = 0; + + /** @type {Range[]} */ + const importDeclarations = []; + + /** @type {Range[]} */ + const importStatements = []; + + /** @type {Range[]} */ + const importMetaUrls = []; - const importDeclarations: Range[] = []; - const importStatements: Range[] = []; - const importMetaUrls: Range[] = []; - const exportDeclarations: Range[] = []; + /** @type {Range[]} */ + const exportDeclarations = []; function tokenClosesExpression() { if (lsc() === ')') { - var c = parenMatches[lsci]; + let c = parenMatches[lsci]; while (isWhitespace(str[c - 1])) { c -= 1; } @@ -326,54 +419,55 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { return true; } - const base: State = { + /** @type {State} */ + const base = { pattern: /(?:(\()|(\))|({)|(})|(")|(')|(\/\/)|(\/\*)|(\/)|(`)|(import)|(export)|(\+\+|--))/g, handlers: [ // ( - (i: number) => { + (i) => { lsci = i; openingParenPositions[parenDepth++] = i; }, // ) - (i: number) => { + (i) => { lsci = i; parenMatches[i] = openingParenPositions[--parenDepth]; }, // { - (i: number) => { + (i) => { lsci = i; stack.push(base); }, // } - (i: number) => { + (i) => { lsci = i; return stack.pop(); }, // " - (i: number) => { + (i) => { stack.push(base); return double_quoted; }, // ' - (i: number) => { + (i) => { stack.push(base); return single_quoted; }, // // - (i: number) => line_comment, + (i) => line_comment, // /* - (i: number) => block_comment, + (i) => block_comment, // / - (i: number) => { + (i) => { // could be start of regex literal OR division punctuator. Solution via // http://stackoverflow.com/questions/5519596/when-parsing-javascript-what-determines-the-meaning-of-a-slash/27120110#27120110 @@ -410,10 +504,10 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { }, // ` - (i: number) => template_string, + (i) => template_string, // import - (i: number) => { + (i) => { if (i === 0 || isWhitespace(str[i - 1]) || punctuatorChars.test(str[i - 1])) { let j = i + 6; let char; @@ -447,7 +541,7 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { }, // export - (i: number) => { + (i) => { if (i === 0 || isWhitespace(str[i - 1]) || punctuatorChars.test(str[i - 1])) { if (/export[\s\n{]/.test(str.slice(i, i + 7))) { const d = getExportDeclaration(str, i); @@ -458,28 +552,30 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { }, // ++/-- - (i: number) => { + (i) => { pfixOp = (!pfixOp && str[i - 1] === '+'); } ] }; - const slash: State = { + /** @type {State} */ + const slash = { pattern: /(?:(\[)|(\\)|(.))/g, handlers: [ // [ - (i: number) => regexEnabled ? regex_character : base, + (i) => regexEnabled ? regex_character : base, // \\ - (i: number) => ((escapedFrom = regex), escaped), + (i) => ((escapedFrom = regex), escaped), // anything else - (i: number) => regexEnabled && !pfixOp ? regex : base + (i) => regexEnabled && !pfixOp ? regex : base ] }; - const regex: State = { + /** @type {State} */ + const regex = { pattern: /(?:(\[)|(\\)|(\/))/g, handlers: [ @@ -494,7 +590,8 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; - const regex_character: State = { + /** @type {State} */ + const regex_character = { pattern: /(?:(\])|(\\))/g, handlers: [ @@ -506,7 +603,8 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; - const double_quoted: State = { + /** @type {State} */ + const double_quoted = { pattern: /(?:(\\)|("))/g, handlers: [ @@ -518,7 +616,8 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; - const single_quoted: State = { + /** @type {State} */ + const single_quoted = { pattern: /(?:(\\)|('))/g, handlers: [ @@ -530,7 +629,8 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; - const escaped: State = { + /** @type {State} */ + const escaped = { pattern: /(.)/g, handlers: [ @@ -538,7 +638,8 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; - const template_string: State = { + /** @type {State} */ + const template_string = { pattern: /(?:(\${)|(\\)|(`))/g, handlers: [ @@ -556,6 +657,7 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; + /** @type {State} */ const line_comment = { pattern: /((?:\n|$))/g, @@ -565,6 +667,7 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ] }; + /** @type {State} */ const block_comment = { pattern: /(\*\/)/g, @@ -608,7 +711,11 @@ function find(str: string, id: string): [Range[], Range[], Range[], Range[]] { ]; } -export function transform(source: string, id: string) { +/** + * @param {string} source + * @param {string} id + */ +export function transform(source, id) { const [ importDeclarations, importStatements, @@ -636,16 +743,17 @@ export function transform(source: string, id: string) { const names = ['__import', '__exports'].concat(Array.from(nameBySource.values())) .join(', '); - const hoisted: string[] = []; + /** @type {string[]} */ + const hoisted = []; importDeclarations.forEach(decl => { const name = nameBySource.get(decl.source); decl.specifiers - .sort((a: Specifier, b: Specifier) => { + .sort((a, b) => { if (a.name === 'default') return 1; if (b.name === 'default') return -1; }) - .forEach((s: Specifier) => { + .forEach((s) => { if (s.name !== '*') { const assignment = (s.name === 'default' && s.as === name) ? `${s.as} = ${name}.default; ` @@ -658,7 +766,7 @@ export function transform(source: string, id: string) { let transformed = `__shimport__.define('${id}', [${deps}], function(${names}){ ${hoisted.join('')}`; - const ranges: any[] = [ + const ranges = [ ...importDeclarations, ...importStatements, ...importMetaUrls, diff --git a/test/test.ts b/test/test.mjs similarity index 92% rename from test/test.ts rename to test/test.mjs index 68ef0cc..593a8c8 100644 --- a/test/test.ts +++ b/test/test.mjs @@ -1,7 +1,7 @@ import { test } from 'uvu'; import * as fs from 'fs'; import * as assert from 'assert'; -import * as shimport from '../src/index'; +import * as shimport from '../src/index.js'; fs.readdirSync('test/samples').forEach(dir => { if (dir[0] === '.') return; diff --git a/tsconfig.json b/tsconfig.json index f7c2fe9..d7d4d80 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,13 @@ { - "compilerOptions": { - "noImplicitAny": true, - "diagnostics": true, - "noImplicitThis": true, - "noEmitOnError": true, - "lib": ["es5", "es6", "dom"] - }, - "target": "ES5", - "module": "ES6", - "include": [ - "src" - ], - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "compilerOptions": { + "allowJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "types" + }, + + "include": [ + "src", + "test" + ] +}