diff --git a/.gitignore b/.gitignore index 0771922..65048e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules -/dist \ No newline at end of file +/dist +/pages +.vscode \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 30cf3b9..3623d72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,580 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { + "@rollup/plugin-commonjs": "^24.0.1", + "@rollup/plugin-node-resolve": "^15.0.1", + "rollup": "^3.15.0", + "rollup-plugin-typescript2": "^0.34.1", "typescript": "^4.9.5" } }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@rollup/plugin-commonjs": { + "version": "24.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-24.0.1.tgz", + "integrity": "sha512-15LsiWRZk4eOGqvrJyu3z3DaBu5BhXIMeWnijSRvd8irrrg9SHpQ1pH+BUK4H6Z9wL9yOxZJMTLU+Au86XHxow==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "glob": "^8.0.3", + "is-reference": "1.2.1", + "magic-string": "^0.27.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.1.tgz", + "integrity": "sha512-ReY88T7JhJjeRVbfCyNj+NXAG3IIsVMsX9b5/9jC98dRP8/yxlZdz7mHZbHk5zHr24wZZICS5AcXsFZAXYUQEg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.0", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@types/estree": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", + "dev": true + }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true + }, + "node_modules/deepmerge": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", + "integrity": "sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-core-module": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/magic-string": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz", + "integrity": "sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/rollup": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.15.0.tgz", + "integrity": "sha512-F9hrCAhnp5/zx/7HYmftvsNBkMfLfk/dXUh73hPSM2E3CRgap65orDNJbLetoiUFwSAk6iHPLvBrZ5iHYvzqsg==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-typescript2": { + "version": "0.34.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.34.1.tgz", + "integrity": "sha512-P4cHLtGikESmqi1CA+tdMDUv8WbQV48mzPYt77TSTOPJpERyZ9TXdDgjSDix8Fkqce6soYz3+fa4lrC93IEkcw==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^4.1.2", + "find-cache-dir": "^3.3.2", + "fs-extra": "^10.0.0", + "semver": "^7.3.7", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "rollup": ">=1.26.3", + "typescript": ">=2.4.0" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -24,6 +595,27 @@ "engines": { "node": ">=4.2.0" } + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } } diff --git a/package.json b/package.json index c960351..bb05ba6 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "date-convert-ad-bs", - "version": "0.1.0", + "version": "1.0.0", "description": "Convert AD to BS and vice versa", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "tsc", + "build": "rollup -c", "prepare": "npm run build" }, "repository": { @@ -24,7 +24,13 @@ }, "homepage": "https://github.com/Ulleri-Tech/date-convert-AD-BS#readme", "devDependencies": { + "@rollup/plugin-commonjs": "^24.0.1", + "@rollup/plugin-node-resolve": "^15.0.1", + "rollup": "^3.15.0", + "rollup-plugin-typescript2": "^0.34.1", "typescript": "^4.9.5" }, - "files": ["/dist/**/*"] + "files": [ + "/dist/**/*" + ] } diff --git a/rollup.config.mjs b/rollup.config.mjs new file mode 100644 index 0000000..7a3ba2e --- /dev/null +++ b/rollup.config.mjs @@ -0,0 +1,22 @@ +import typescript from 'rollup-plugin-typescript2'; +import commonjs from '@rollup/plugin-commonjs'; +import nodeResolve from '@rollup/plugin-node-resolve'; + +export default { + input: 'src/index.ts', + output: [ + { + file: 'dist/index.cjs.js', + format: 'cjs' + }, + { + file: 'dist/index.esm.js', + format: 'es' + } + ], + plugins: [ + typescript(), + nodeResolve(), + commonjs(), + ] +} \ No newline at end of file diff --git a/src/constant.ts b/src/constant.ts new file mode 100644 index 0000000..028210b --- /dev/null +++ b/src/constant.ts @@ -0,0 +1,244 @@ +import { DaysEachMonthBS } from "./types"; + +// 1943 April 14 to 2044 April 16(nearly) +export const numberOfDaysEachYearBS = { + '2000': 365, + '2001': 365, + '2002': 365, + '2003': 366, + '2004': 365, + '2005': 365, + '2006': 365, + '2007': 366, + '2008': 365, + '2009': 365, + '2010': 365, + '2011': 366, + '2012': 365, + '2013': 365, + '2014': 365, + '2015': 366, + '2016': 365, + '2017': 365, + '2018': 365, + '2019': 366, + '2020': 365, + '2021': 365, + '2022': 365, + '2023': 366, + '2024': 365, + '2025': 365, + '2026': 366, + '2027': 365, + '2028': 365, + '2029': 365, + '2030': 366, + '2031': 365, + '2032': 365, + '2033': 365, + '2034': 366, + '2035': 365, + '2036': 365, + '2037': 365, + '2038': 366, + '2039': 365, + '2040': 365, + '2041': 365, + '2042': 366, + '2043': 365, + '2044': 365, + '2045': 365, + '2046': 366, + '2047': 365, + '2048': 365, + '2049': 365, + '2050': 366, + '2051': 365, + '2052': 365, + '2053': 365, + '2054': 366, + '2055': 365, + '2056': 365, + '2057': 366, + '2058': 365, + '2059': 365, + '2060': 365, + '2061': 366, + '2062': 365, + '2063': 365, + '2064': 365, + '2065': 366, + '2066': 365, + '2067': 365, + '2068': 365, + '2069': 366, + '2070': 365, + '2071': 365, + '2072': 365, + '2073': 366, + '2074': 365, + '2075': 365, + '2076': 365, + '2077': 366, + '2078': 365, + '2079': 365, + '2080': 365, + '2081': 366, + '2082': 366, + '2083': 365, + '2084': 365, + '2085': 367, + '2086': 366, + '2087': 366, + '2088': 365, + '2089': 366, + '2090': 366, + '2091': 366, + '2092': 366, + '2093': 366, + '2094': 365, + '2095': 366, + '2096': 364, + '2097': 366, + '2098': 366, + '2099': 365, + '2100': 365 +} as const; + +export const numberOfDaysEachMonthBS:DaysEachMonthBS= { + "2000": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2001": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2002": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2003": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2004": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2005": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2006": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2007": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2008": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + "2009": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2010": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2011": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2012": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + "2013": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2014": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2015": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2016": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + "2017": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2018": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2019": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2020": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + "2021": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2022": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + "2023": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2024": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + "2025": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2026": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2027": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2028": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2029": [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + "2030": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2031": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2032": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2033": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2034": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2035": [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + "2036": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2037": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2038": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2039": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + "2040": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2041": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2042": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2043": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + "2044": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2045": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2046": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2047": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + "2048": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2049": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + "2050": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2051": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + "2052": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2053": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + "2054": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2055": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2056": [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + "2057": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2058": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + "2059": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2060": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2061": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2062": [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], + "2063": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2064": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2065": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2066": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + "2067": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2068": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2069": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2070": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + "2071": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + "2072": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + "2073": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + "2074": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + "2075": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + '2076': [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + '2077': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + '2078': [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + '2079': [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + '2080': [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + '2081': [31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2082': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2083': [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + '2084': [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + '2085': [31, 32, 31, 32, 31, 31, 30, 30, 29, 30, 30, 30], + '2086': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2087': [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], + '2088': [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30], + '2089': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2090': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2091': [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], + '2092': [31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2093': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2094': [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + '2095': [31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30], + '2096': [30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + '2097': [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + '2098': [31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 30, 31], + '2099': [31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30], + '2100': [31, 32, 31, 32, 30, 31, 30, 29, 30, 29, 30, 30] +} + +export const MONTH_NAME_BS = [ + 'वैशाख', + 'जेठ', + 'आषाढ', + 'श्रवण', + 'भद्र', + 'अश्विन', + 'कार्तिक', + 'मङ्सिर', + 'पौष', + 'माघ', + 'फाल्गुन', + 'चैत्र' +] as const; + +export const NEPALI_NUMBER = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'] as const; + +export const weekDayBS = [ + 'आइतबार', + 'सोमबार', + 'मङ्गलबार', + 'बुधवार', + 'बिहीबार', + 'शुक्रबार', + 'शनिबार' +] as const; + +export const MAX_DAY_DIFF = 36898; +export const MIN_AD_YEAR = 1943; // 2000 +export const MIN_BS_YEAR = 2000; // 1943 +export const MIN_AD_MONTH = 3; // 0 (Baisakh) +export const MIN_AD_DAY= 14; // 1 (first day) +export const MILLS_IN_DAY = 86400000; // 24*60*60*1000 \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1280317..f96791f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,117 @@ -export class Log{ - static initial(){ - console.log("Libray works") +import { numberOfDaysEachYearBS, numberOfDaysEachMonthBS, MAX_DAY_DIFF, MIN_AD_YEAR, MIN_AD_MONTH, MIN_AD_DAY, MILLS_IN_DAY, MIN_BS_YEAR, weekDayBS, MONTH_NAME_BS } from "./constant"; +import { convertToNepali } from "./utils"; + +export function ADTOBS(year: number, month: number, day: number): string { + + const START_DATE = new Date(MIN_AD_YEAR, MIN_AD_MONTH, MIN_AD_DAY); + + if (!year) year = new Date().getUTCFullYear(); + if (!month) month = new Date().getUTCMonth(); + if (!day) day = new Date().getUTCDate(); + + const dayDiff = Math.ceil( + (new Date(year, month, day).getTime() - START_DATE.getTime()) / MILLS_IN_DAY + ); + + if (dayDiff < 0 || dayDiff > MAX_DAY_DIFF) { + return "Invalid Date out of range"; + } + if (month < 0 || month > 11 || day < 0 || day > 32) { + return "Invalid Date"; + } + let year_bs = String(MIN_BS_YEAR); + let totalCount = 0; + let countUptoPreviousYear = 0; + + // find Year only first + for (const [key, value] of Object.entries(numberOfDaysEachYearBS)) { + countUptoPreviousYear = totalCount; + totalCount += value; + if (totalCount > dayDiff) { + year_bs = key; + break; } + } + let nthDayofYear = dayDiff - countUptoPreviousYear + 1; + + //find month + let total_count_month_wise = 0; + let countUptoPreviousMonth = 0; + let month_bs = 0; + + for ( + let i = 0; + i < numberOfDaysEachMonthBS[year_bs].length && + nthDayofYear > total_count_month_wise; + i++ + ) { + countUptoPreviousMonth = total_count_month_wise; + total_count_month_wise += numberOfDaysEachMonthBS[year_bs][i]; + if (countUptoPreviousMonth > 0) { + month_bs++; + } + } + + let day_bs = nthDayofYear - countUptoPreviousMonth; + return formatBSDate(+year_bs, month_bs + 1, day_bs); +} + +function formatBSDate(year: number, month: number, day: number) { + let monthStr: string; + let dayStr: string; + if (month < 10) monthStr = "0" + month; + else monthStr = month + ""; + + if (day < 10) dayStr = "0" + day; + else dayStr = day + ""; + return `${year}-${monthStr}-${dayStr}`; +} + +export function BSTOAD(year: number, month: number, day: number):string { + let year_num = +year; + let day_num = +day; + + if (year_num < 2000 || year_num > 2100) { + return "Invalid Date out of range" + } + + let dayCount = 0; + + for (const [key, value] of Object.entries(numberOfDaysEachYearBS)) { + if (year_num == 2000) { + break; + } + dayCount += value + if (+key == year_num - 1) { + break; + } + } + for (let i = 0; i < month; i++) { + dayCount += numberOfDaysEachMonthBS[year][i] + } + dayCount += day_num - 1; + const final_time = Math.ceil((new Date(MIN_AD_YEAR, MIN_AD_MONTH, MIN_AD_DAY).getTime())) + (dayCount * MILLS_IN_DAY) + + return new Date(final_time).toLocaleDateString('en-ca'); +} + + +export function dateTodayBS():string { + const weekday_BS = weekDayBS[new Date().getDay()]; + const [year_AD, month_AD, day_AD] = new Date().toLocaleDateString('en-ca').split("-"); + const date_BS = ADTOBS(+year_AD, +month_AD - 1, +day_AD); + + const year_bs = convertToNepali(date_BS.split("-")[0]); + const month_bs = date_BS.split("-")[1]; + const day_bs = convertToNepali(date_BS.split("-")[2]); + return `${weekday_BS}, ${MONTH_NAME_BS[+month_bs - 1]} ${day_bs}, ${year_bs} बि.सं` +} + +export function dateTodayAD() { + return new Date().toLocaleString('en-ca', { + month: 'long', + day: 'numeric', + year: 'numeric', + weekday: 'long' + }) + " AD" } \ No newline at end of file diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..f20c1fb --- /dev/null +++ b/src/types.ts @@ -0,0 +1,7 @@ +export type DaysEachMonthBS = Readonly<{ + [key: string]: number[]; + }>; + +// export type datestring1 = `${number}${number}${number}${number}-${number}${number}-${number}${number}`; +// export type datestring2 = `${number}${number}-${number}${number}-${number}${number}${number}${number}`; +// type DateString = datestring1 | datestring2; diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..088b79f --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,10 @@ +import { NEPALI_NUMBER } from "./constant"; + +export function convertToNepali(num:string):string { + let nepali = ''; + + for (let i = 0; i < (num).length; i++) { + nepali += NEPALI_NUMBER[parseInt((num)[i])]; + } + return nepali; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7787320..9787ad2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,12 +2,12 @@ "compilerOptions": { /* Language and Environment */ "target": "ES5", - "module": "commonjs", + "module": "ES2015", "esModuleInterop": true, "declaration": true, "strict": true, "outDir": "./dist", - "skipLibCheck": true + "lib": ["es2017"] }, "include": ["src"], "exclude": ["node_modules", "**/__test__/"]