added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+181
View File
@@ -0,0 +1,181 @@
# MMM DynamicWeather Control Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [2.14.1] - 2021-04-10
### Fixed
- Fixed issue #40 with weather animation not changing after API code is different
## [2.14.0] - 2021-03-22
### Added
- Removed zIndex option and added opacity as a substitue.
## [2.13.0] - 2021-03-22
### Added
- Added sunny effect with multiple images. (added to configuration)
## [2.12.2] - 2021-02-23
### Changed
- Applied more logging info and try/catch for error handling.
## [2.12.1] - 2021-02-19
### Fixed
- Fixed issue with false value for hideSnowman and hideFlower not working
## [2.12.0] - 2021-02-19
### Added
- Added a flower growing animation during rain and a snowman being built during snow
- Added hideSnowman and hideFlower option (added to configuration)
## [2.11.0] - 2021-02-19
### Added
- Winter mix weather effect to show snow and rain at sametime based on current weather
- Added realisticClouds option (added to configuration)
- Added particleCount for each effect (added to configuration)
## [2.10.0] - 2021-02-19
### Added
- Added lightning effect for weather conditions. Added to alwaysDisplay option and hideLightning option. (added to configuration)
## [2.9.0] - 2021-02-18
### Added
- Add min and max speed to effects
## [2.8.0] - 2021-02-18
### Added
- Adding effect-one option for sequential
## [2.7.2] - 2021-02-18
### Fixed
- Fixed issue with sequential taking twice as long and holiday not being removed the next day
## [2.7.1] - 2021-02-05
### Changes
- Cleaned up code, removed unncessary comments and logs, formats, renamed example files
- Updated module description
## [2.7.0] - 2021-02-05
### Added
- Added fog weather effect (added to configuration)
## [2.6.1] - 2021-02-05
### Fixed
- Issue with larger images getting cut off has been resovled by changing background to "contain", which will not keep ratio of image
## [2.6.0] - 2021-02-05
### Added
- Adding fade duration to slowing hide effects (added to configuration)
## [2.5.0] - 2021-02-05
### Added
- Adding recurrence option for effects (added to effect configuration)
## [2.4.1] - 2021-02-04
### Added
- Adding sequential option (added to configuration)
## [2.3.0] - 2021-02-04
### Added
- Adding min and max weatherCode for effects (added to effect configuration)
## [2.2.1] - 2021-02-04
### Added
- Adding Right-Left and Left-Right Directions (added to effect configuration)
## [2.1.3] - 2021-02-04
### Fixed
- Minor bugfix where effects don't show with no year and no holidays
## [2.1.0] - 2021-02-04
### Added
- Holidays to effects so that they display on a specific holiday date (added to effect configuration)
### Changed
- Forced weather and holiday requests to finish before display effects
### Fixed
- Issue with effectDelay not working
- Issue with weather API being called multiple times
- Failed requests from weather will no longer break module
## [2.0.2] - 2021-02-04
### Fixed
- Minor issue with effects not being displayed on their date
## [2.0.1] - 2021-02-03
### Fixed
- Minor issue with effects not having weather code causing them to always display despite having a date
## [2.0.0] - 2021-02-03
### Added
- Changelog
- Custom effects
- Configuration changes:
- `locationID` - to work with OpenWeatherMap city IDs
- `effectDuration` - to display effects for X time
- `effectDelay` - to wait X time for effects to restart
- `hideSnow`, `hideRain`, `hideClouds` - to never display certain weather effects
- Added TypeScript
### Changed
- Configuration changes:
- `interval` renamed to `weatherInterval`
- Weather API changed to use Open Weather Map
## [1.0.0] - 2021-02-02
### Initial release of the DynamicWeather module
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Scott Lewis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,564 @@
.MMM-DynamicWeather .flake-downwards {
position: absolute;
top: -50px;
animation-name: flake-downwards;
animation-iteration-count: infinite;
}
.MMM-DynamicWeather .flake-upwards {
position: absolute;
top: -50px;
animation-name: flake-upwards;
animation-iteration-count: infinite;
}
.MMM-DynamicWeather .flake-right-left {
position: absolute;
animation-name: flake-right-left;
animation-iteration-count: infinite;
}
.MMM-DynamicWeather .flake-left-right {
position: absolute;
animation-name: flake-left-right;
animation-iteration-count: infinite;
}
.MMM-DynamicWeather *[class|="flake"] div {
width: 20px;
height: 20px;
background-repeat: no-repeat;
background-size: contain;
animation-iteration-count: infinite;
}
/* Animate opacity */
@keyframes fade {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@keyframes flake-downwards {
from {
transform: translateY(0vh);
}
to {
transform: translateY(100vh);
}
}
@keyframes flake-upwards {
from {
transform: translateY(calc(100vh + 20px));
}
to {
transform: translateY(0vh);
}
}
@keyframes flake-left-right {
from {
transform: translateX(0vw);
}
to {
transform: translateX(calc(100vw + 60px));
}
}
@keyframes flake-right-left {
from {
transform: translateX(calc(100vw + 60px));
}
to {
transform: translateX(0vw);
}
}
@keyframes flake-jiggle {
0% {
transform: translateX(0vw);
}
20% {
transform: translateX(20vw);
}
30% {
transform: translateX(5vw);
}
50% {
transform: translateX(25vw);
}
70% {
transform: translateX(0vw);
}
85% {
transform: translateX(15vw);
}
100% {
transform: translateX(0vw);
}
}
@keyframes flake-jiggle-left-right {
0% {
transform: translateX(0vw);
}
100% {
transform: translateX(150vw);
}
}
@keyframes flake-jiggle-right-left {
0% {
transform: translateX(0vw);
}
100% {
transform: translateX(-150vw);
}
}
/********************
RAIN CSS
*********************/
.MMM-DynamicWeather .rain {
position: absolute;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
}
.MMM-DynamicWeather .rain.back-row {
display: none;
z-index: 1;
bottom: 60px;
opacity: 0.5;
}
.MMM-DynamicWeather div.back-row-toggle .rain.back-row {
display: block;
}
.MMM-DynamicWeather .drop {
position: absolute;
bottom: 100%;
width: 15px;
height: 120px;
pointer-events: none;
animation: drop 0.5s linear infinite;
}
@keyframes drop {
0% {
transform: translateY(0vh);
}
75% {
transform: translateY(90vh);
}
100% {
transform: translateY(90vh);
}
}
.MMM-DynamicWeather .stem {
width: 3px;
height: 60%;
margin-left: 7px;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.25));
animation: stem 0.5s linear infinite;
}
@keyframes stem {
0% {
opacity: 1;
}
65% {
opacity: 1;
}
75% {
opacity: 0;
}
100% {
opacity: 0;
}
}
/******************************
Clouds
https://codepen.io/Mark_Bowley/pen/xEbuI
******************************/
/* KEYFRAMES */
@-webkit-keyframes animateCloud {
0% {
margin-left: -1000px;
}
100% {
margin-left: 100%;
}
}
@-moz-keyframes animateCloud {
0% {
margin-left: -1000px;
}
100% {
margin-left: 100%;
}
}
@keyframes animateCloud {
0% {
margin-left: -1000px;
}
100% {
margin-left: 100%;
}
}
/* OBJECTS */
.MMM-DynamicWeather .cloud {
opacity: 0.5;
background: #fff;
background: -moz-linear-gradient(top, #fff 5%, #f1f1f1 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(5%, #fff), color-stop(100%, #f1f1f1));
background: -webkit-linear-gradient(top, #fff 5%, #f1f1f1 100%);
background: -o-linear-gradient(top, #fff 5%, #f1f1f1 100%);
background: -ms-linear-gradient(top, #fff 5%, #f1f1f1 100%);
background: linear-gradient(top, #fff 5%, #f1f1f1 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff', endColorstr='#f1f1f1',GradientType=0 );
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;
-webkit-box-shadow: 0 8px 5px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 8px 5px rgba(0, 0, 0, 0.1);
box-shadow: 0 8px 5px rgba(0, 0, 0, 0.1);
height: 120px;
position: relative;
width: 350px;
}
.MMM-DynamicWeather .cloud:after,
.cloud:before {
background: #fff;
content: "";
position: absolute;
z-index: -1;
}
.MMM-DynamicWeather .cloud:after {
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;
height: 100px;
left: 50px;
top: -50px;
width: 100px;
}
.MMM-DynamicWeather .cloud:before {
-webkit-border-radius: 200px;
-moz-border-radius: 200px;
border-radius: 200px;
width: 180px;
height: 180px;
right: 50px;
top: -90px;
}
/***************************
Fog
https://codepen.io/Ravyre/pen/gXawyY
***************************/
/* ---------- Fog ---------- */
.MMM-DynamicWeather .fogwrapper {
height: 150%;
position: absolute;
top: -150px;
width: 100%;
-webkit-filter: blur(1px) grayscale(0.2) saturate(1.2) sepia(0.2);
filter: blur(1px) grayscale(0.2) saturate(1.2) sepia(0.2);
}
.MMM-DynamicWeather #foglayer_01,
.MMM-DynamicWeather #foglayer_02,
.MMM-DynamicWeather #foglayer_03 {
height: 150%;
position: absolute;
width: 500%;
top: -150px;
}
.MMM-DynamicWeather #foglayer_01 .image01,
.MMM-DynamicWeather #foglayer_01 .image02,
.MMM-DynamicWeather #foglayer_02 .image01,
.MMM-DynamicWeather #foglayer_02 .image02,
.MMM-DynamicWeather #foglayer_03 .image01,
.MMM-DynamicWeather #foglayer_03 .image02 {
float: left;
height: 150%;
top: -150px;
width: 100%;
}
.MMM-DynamicWeather #foglayer_01,
.MMM-DynamicWeather #foglayer_02,
.MMM-DynamicWeather #foglayer_03 {
animation: foglayer_01_opacity 10s linear infinite, foglayer_moveme 10s linear infinite;
}
.MMM-DynamicWeather #foglayer_01 .image01,
.MMM-DynamicWeather #foglayer_01 .image02 {
background: url("images/fog1.png") center center/cover no-repeat transparent;
}
.MMM-DynamicWeather #foglayer_02 .image01,
.MMM-DynamicWeather #foglayer_02 .image02,
.MMM-DynamicWeather #foglayer_03 .image01,
.MMM-DynamicWeather #foglayer_03 .image02 {
background: url("images/fog2.png") center center/cover no-repeat transparent;
}
/* ---------- Keyframe Layer 1 ---------- */
@keyframes foglayer_01_opacity {
0% {
opacity: 0;
}
50% {
opacity: 0.7;
}
100% {
opacity: 0;
}
}
/* ---------- Keyframe moveMe ---------- */
@keyframes foglayer_moveme {
0% {
left: 0;
}
100% {
left: -100%;
}
}
/***************************
Lightning
***************************/
.MMM-DynamicWeather .lightningPlayer {
height: 100%;
position: absolute;
top: -10px;
left: 0px;
width: 100%;
display: block;
}
.MMM-DynamicWeather .lightning1 {
height: 100%;
position: absolute;
top: -10px;
left: 0px;
width: 100%;
background: url("images/lightning1.png") center center/cover no-repeat transparent;
animation: lightning1_opacity 14s linear;
animation-fill-mode: forwards;
animation-delay: 0s;
}
.MMM-DynamicWeather .lightning2 {
height: 100%;
position: absolute;
top: -10px;
left: 0px;
width: 100%;
background: url("images/lightning2.png") center center/cover no-repeat transparent;
animation: lightning2_opacity 14s linear;
animation-fill-mode: forwards;
animation-delay: 0s;
}
@keyframes lightningPlayer_opacity {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@keyframes lightning1_opacity {
0% {
opacity: 0;
}
49% {
opacity: 0;
}
50% {
opacity: 0.8;
}
55% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@keyframes lightning2_opacity {
0% {
opacity: 0;
}
19% {
opacity: 0;
}
20% {
opacity: 0.8;
}
25% {
opacity: 0;
}
59% {
opacity: 0;
}
60% {
opacity: 0.8;
}
65% {
opacity: 0;
}
100% {
opacity: 0;
}
}
/***************************
Sunny
***************************/
.MMM-DynamicWeather .sunnyPlayer {
height: 100%;
width: 100%;
position: absolute;
display: block;
opacity: .4;
}
.MMM-DynamicWeather .sun {
height: 100%;
width: 100%;
position: absolute;
opacity: .4;
}
/***************************
Snowman
***************************/
.MMM-DynamicWeather .snowman {
width: 350px !important;
bottom: 20px;
left: 25%;
position: absolute;
display: block;
height: 100px !important;
background: url("images/SNOWMAN_1.png") center center/cover no-repeat transparent;
animation: snowmanBg linear;
animation-fill-mode: forwards;
animation-duration: 60;
/* animation-delay: 10s; */
}
@keyframes snowmanBg {
0% {
background-image: url("images/SNOWMAN_1.png");
height: 100px;
}
10% {
background-image: url("images/SNOWMAN_1.png");
height: 100px;
}
20% {
background-image: url("images/SNOWMAN_2.png");
height: 200px;
}
30% {
background-image: url("images/SNOWMAN_3.png");
height: 300px;
}
40% {
background-image: url("images/SNOWMAN_4.png");
height: 375px;
}
50% {
background-image: url("images/SNOWMAN_5.png");
height: 450px;
}
60% {
background-image: url("images/SNOWMAN_6.png");
height: 600px;
}
70% {
background-image: url("images/SNOWMAN_7.png");
height: 625px;
}
80% {
background-image: url("images/SNOWMAN_8.png");
height: 625px;
}
90% {
background-image: url("images/SNOWMAN_9.png");
height: 650px;
}
100% {
background-image: url("images/SNOWMAN_9.png");
height: 650px;
}
}
/***************************
Flower
***************************/
.MMM-DynamicWeather .flower {
width: 400px !important;
bottom: 20px;
left: 25%;
position: absolute;
display: block;
height: 250px !important;
background: url("images/FLOWER_1.png") center center/cover no-repeat transparent;
animation: flowerBg linear;
animation-fill-mode: forwards;
animation-delay: 10s;
}
@keyframes flowerBg {
0%, 10% {
background-image: url("images/FLOWER_1.png");
height: 250px;
}
20% {
background-image: url("images/FLOWER_2.png");
height: 350px;
}
30% {
background-image: url("images/FLOWER_3.png");
height: 400px;
}
40% {
background-image: url("images/FLOWER_4.png");
height: 450px;
}
50% {
background-image: url("images/FLOWER_5.png");
height: 500px;
}
60% {
background-image: url("images/FLOWER_6.png");
height: 600px;
}
70% {
background-image: url("images/FLOWER_7.png");
height: 650px;
}
80%, 100% {
background-image: url("images/FLOWER_8.png");
height: 650px;
}
}
@@ -0,0 +1,759 @@
var Effect = /** @class */ (function () {
function Effect() {
this.year = 0;
this.doDisplay = false;
}
Effect.prototype.getYear = function () {
return this.year ? this.year : 0;
};
Effect.prototype.getMonth = function () {
return this.month ? this.month : 0;
};
Effect.prototype.getDay = function () {
return this.day ? this.day : 0;
};
Effect.prototype.getSize = function () {
return this.size ? this.size : 1;
};
Effect.prototype.getParticleCount = function () {
return this.particleCount ? this.particleCount : -1;
};
Effect.prototype.getSpeedMax = function () {
return this.speedMax ? this.speedMax : 100;
};
Effect.prototype.getSpeedMin = function () {
return this.speedMin ? this.speedMin : 50;
};
Effect.prototype.getWeatherCode = function () {
return this.weatherCode ? this.weatherCode : -99;
};
Effect.prototype.getMinWeatherCode = function () {
return this.weatherCodeMin ? this.weatherCodeMin : 99999;
};
Effect.prototype.getMaxWeatherCode = function () {
return this.weatherCodeMax ? this.weatherCodeMax : -99999;
};
Effect.prototype.hasWeatherCode = function () {
return (this.weatherCode && this.weatherCode > 0) || (this.weatherCodeMin && this.weatherCodeMin > 0) || (this.weatherCodeMax && this.weatherCodeMax > 0) ? true : false;
};
Effect.prototype.hasHoliday = function () {
return this.holiday && this.holiday.length > 0 ? true : false;
};
Effect.prototype.clone = function (other) {
this.id = other.id;
this.day = other.day;
this.month = other.month;
this.year = other.year;
this.images = other.images;
this.direction = other.direction;
this.size = other.size;
this.particleCount = other.particleCount;
this.speedMax = other.speedMax;
this.speedMin = other.speedMin;
this.weatherCode = other.weatherCode;
this.weatherCodeMin = other.weatherCodeMin;
this.weatherCodeMax = other.weatherCodeMax;
this.holiday = other.holiday;
this.recurrence = other.recurrence;
this.doDisplay = other.doDisplay;
};
return Effect;
}());
Module.register("MMM-DynamicWeather", {
defaults: {
particleCount: 100,
api_key: "",
locationID: 0,
lat: 0,
lon: 0,
weatherInterval: 600000,
alwaysDisplay: "",
zIndex: 99,
opacity: 1,
fadeDuration: 3000,
effectDuration: 120000,
effectDelay: 60000,
realisticClouds: false,
hideSun: false,
hideSnow: false,
hideSnowman: true,
hideRain: false,
hideFlower: true,
hideClouds: false,
hideFog: false,
hideLightning: false,
lightning1Count: 2,
lightning2Count: 3,
sequential: "",
sunImage: "sun_right",
effects: [],
},
start: function () {
var _this_1 = this;
Log.info("Starting MMM-DynamicWeather");
this.now = new Date();
this.initialized = false;
this.weatherLoaded = false;
this.holidayLoaded = false;
this.doShowEffects = true;
this.hasDateEffectsToDisplay = false;
this.hasHolidayEffectsToDisplay = false;
this.hasWeatherEffectsToDisplay = true;
this.effectDurationTimeout = null;
this.effectDelayTimeout = null;
this.weatherTimeout = null;
this.holidayTimeout = null;
this.allEffects = [];
this.url = "https://api.openweathermap.org/data/2.5/weather?appid=" + this.config.api_key;
if (this.config.lat && this.config.lon) {
this.url += "&lat=" + this.config.lat + "&lon=" + this.config.lon;
}
if (this.config.locationID) {
this.url += "&id=" + this.config.locationID;
}
this.snowEffect = new Effect();
this.snowEffect.images = ["snow1.png", "snow2.png", "snow3.png"];
this.snowEffect.size = 1;
this.snowEffect.direction = "down";
this.realisticCloudsEffect = new Effect();
this.realisticCloudsEffect.size = 15;
this.realisticCloudsEffect.direction = "left-right";
this.realisticCloudsEffect.images = ["cloud1.png", "cloud2.png"];
this.weatherCode = 0;
this.allHolidays = [];
var count = 0;
this.config.effects.forEach(function (configEffect) {
var effect = new Effect();
effect.clone(configEffect);
effect.id = count;
count++;
_this_1.allEffects.push(effect);
_this_1.allHolidays.push(effect.holiday);
});
this.lastSequentialId = -1;
if (this.config.sequential) {
if (this.config.sequential == "effect" || this.config.sequential == "effect-one") {
this.lastSequential = "weather";
}
else if (this.config.sequential == "weather") {
this.lastSequential = "effect";
}
else {
this.lastSequential = "";
}
}
else {
this.lastSequential = "";
}
this.checkDates();
if (this.allHolidays.length > 0) {
this.getHolidays(this);
}
else {
this.holidayLoaded = true;
}
if (!this.config.alwaysDisplay) {
this.getWeather(this);
}
else {
this.weatherLoaded = true;
}
Log.info("[MMM-DynamicWeather] Finished initialization");
},
getStyles: function () {
return ["MMM-DynamicWeather.css"];
},
checkDates: function () {
var _this_1 = this;
try {
this.allEffects.forEach(function (effect) {
var effectMonth = effect.month - 1;
if (!effect.hasWeatherCode() && !effect.hasHoliday()) {
//if there is weatherCode or holiday, dates are ignored
if (effect.getMonth() == 0 && effect.getDay() == 0 && effect.getYear() == 0) {
//if no weatherCode, no holiday and no dates, then always display it
if (effect.recurrence == "weekdays") {
//if its not Sunday (0) and not Saturday (6)
if (_this_1.now.getDay() !== 6 && _this_1.now.getDay() !== 0) {
_this_1.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
else if (effect.recurrence == "weekends") {
//if its Sunday (0) or Saturday (6)
if (_this_1.now.getDay() == 6 || _this_1.now.getDay() == 0) {
_this_1.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
else {
_this_1.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
else {
//if the month and date match or the month, date and year match
if (_this_1.now.getMonth() == effectMonth && _this_1.now.getDate() == effect.day) {
if (effect.getYear() == 0 || _this_1.now.getFullYear() == effect.getYear()) {
_this_1.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
else if (effect.recurrence == "monthly") {
//ignore everything but the day
if (_this_1.now.getDate() == effect.getDay()) {
_this_1.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
else if (effect.recurrence == "weekly") {
var effectDay = new Date(effect.getYear(), effectMonth, effect.getDay());
if (_this_1.now.getDay() == effectDay.getDay()) {
_this_1.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
}
}
});
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in checkDates: ", error);
}
},
getDom: function () {
var wrapper = document.createElement("div");
wrapper.style.zIndex = this.config.zIndex;
wrapper.style.opacity = this.config.opacity;
wrapper.className = "wrapper";
try {
//setup the fade-out animation
var fadeDuration = parseInt(this.config.fadeDuration);
var animationDelay = parseInt(this.config.effectDuration) - fadeDuration;
var fadeCSS = document.createElement("style");
fadeCSS.innerHTML = ".fade-out {animation-name: fade; animation-duration: " + fadeDuration + "ms; animation-delay: " + animationDelay + "ms;}";
wrapper.prepend(fadeCSS);
wrapper.onanimationend = function (e) {
//delay finished, elements faded out, now remove
var thisAnimation = e.animationName;
if (thisAnimation == "fade") {
wrapper.remove();
}
};
if (this.config.alwaysDisplay) {
switch (this.config.alwaysDisplay) {
case "snow": {
this.showCustomEffect(wrapper, this.snowEffect);
if (this.config.hideSnowman === false || this.config.hideSnowman === "false") {
this.buildSnowman(wrapper);
}
break;
}
case "sun": {
this.makeItSunny(wrapper);
break;
}
case "rain": {
this.makeItRain(wrapper);
if (this.config.hideFlower === false || this.config.hideFlower === "false") {
this.buildFlower(wrapper);
}
break;
}
case "lightning": {
this.makeItLightning(wrapper);
break;
}
case "rain-lightning": {
this.makeItRain(wrapper);
this.makeItLightning(wrapper);
break;
}
case "cloudy": {
if (this.config.realisticClouds) {
this.showCustomEffect(wrapper, this.realisticCloudsEffect);
}
else {
this.makeItCloudy(wrapper);
}
break;
}
case "fog": {
this.makeItFoggy(wrapper);
break;
}
default: {
console.error("[MMM-DynamicWeather] Invalid config option 'alwaysDisplay'");
}
}
return wrapper;
}
if (!this.weatherLoaded || !this.holidayLoaded)
return wrapper; //need to wait for the weather to first be loaded
if (!this.doShowEffects)
return wrapper;
wrapper.className = "wrapper fade-out";
var showEffects = false;
var showWeather = false;
//check to see what should be shown based on availability and sequential
if (this.hasDateEffectsToDisplay || this.hasHolidayEffectsToDisplay || this.hasWeatherEffectsToDisplay) {
if (this.lastSequential == "effect" && this.hasWeatherEffectsToDisplay) {
//if its weather's turn and there are weather to show
showWeather = true;
this.lastSequential = "weather";
}
else if (this.lastSequential == "weather" && (this.hasDateEffectsToDisplay || this.hasHolidayEffectsToDisplay)) {
//if its effect's turn and there are effects to show
showEffects = true;
this.lastSequential = "effect";
}
else {
showWeather = true;
showEffects = true;
}
}
if (showEffects) {
for (var _i = 0, _a = this.allEffects; _i < _a.length; _i++) {
var effect = _a[_i];
if (effect.doDisplay) {
//we can display this effect
if (this.config.sequential == "effect-one") {
//only show one effect at a time. if it wasn't the last one and its next in line, then do show it
if (this.lastSequentialId < effect.id) {
this.lastSequentialId = effect.id;
if (this.allEffects.length - 1 == this.lastSequentialId) {
//reached end of effects, reset
this.lastSequentialId = -1;
}
this.showCustomEffect(wrapper, effect);
break;
}
}
else {
this.showCustomEffect(wrapper, effect);
}
}
}
}
if (showWeather) {
//Codes from https://openweathermap.org/weather-conditions
if (this.weatherCode >= 600 && this.weatherCode <= 622 && !this.config.hideSnow) {
this.showCustomEffect(wrapper, this.snowEffect);
if (this.config.hideSnowman === false || this.config.hideSnowman === "false") {
this.buildSnowman(wrapper);
}
if (this.weatherCode >= 611 && this.weatherCode <= 622 && !this.config.hideRain) {
//snow/rain mix
this.makeItRain(wrapper);
}
}
else if (this.weatherCode >= 200 && this.weatherCode <= 531 && !this.config.hideRain) {
this.makeItRain(wrapper);
if (this.config.hideFlower === false || this.config.hideFlower === "false") {
this.buildFlower(wrapper);
}
if (this.weatherCode >= 200 && this.weatherCode <= 232 && !this.config.hideLightning) {
this.makeItLightning(wrapper);
}
}
else if (this.weatherCode >= 801 && this.weatherCode <= 804 && !this.config.hideClouds) {
if (this.config.realisticClouds) {
if (this.weatherCode == 801) {
this.realisticCloudsEffect.size = 8;
this.realisticCloudsEffect.particleCount = 30;
this.realisticCloudsEffect.images = ["cloud1.png"];
}
else if (this.weatherCode == 802) {
this.realisticCloudsEffect.size = 8;
this.realisticCloudsEffect.particleCount = 50;
this.realisticCloudsEffect.images = ["cloud1.png", "cloud2.png"];
}
else if (this.weatherCode == 803) {
this.realisticCloudsEffect.size = 15;
this.realisticCloudsEffect.particleCount = 30;
this.realisticCloudsEffect.images = ["cloud1.png", "cloud2.png"];
}
else if (this.weatherCode == 804) {
this.realisticCloudsEffect.size = 15;
this.realisticCloudsEffect.particleCount = 30;
this.realisticCloudsEffect.images = ["cloud3.png", "cloud2.png", "cloud1.png"];
}
this.showCustomEffect(wrapper, this.realisticCloudsEffect);
}
else {
this.makeItCloudy(wrapper);
}
}
else if (this.weatherCode >= 701 && this.weatherCode <= 781 && !this.config.hideFog) {
this.makeItFoggy(wrapper);
}
else if (this.weatherCode == 800 && !this.config.hideSun) {
this.makeItSunny(wrapper);
}
}
console.info("[MMM-DynamicWeather] Displaying effects for: ", this.config.effectDuration);
this.effectDurationTimeout = setTimeout(this.stopEffect, this.config.effectDuration, this);
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in getDom: ", error);
}
return wrapper;
},
showCustomEffect: function (wrapper, effect) {
this.doShowEffects = false;
var flake, jiggle, size;
var particleCount = effect.getParticleCount();
if (particleCount < 0) {
particleCount = this.config.particleCount;
}
for (var i = 0; i < particleCount; i++) {
size = effect.getSize(); // * (Math.random() * 0.75) + 0.25;
var flakeImage = document.createElement("div");
var maxNum = effect.images.length;
var picIndex = Math.floor(Math.random() * (maxNum - 0) + 0);
flakeImage.style.backgroundImage = "url('./modules/MMM-DynamicWeather/images/" + effect.images[picIndex] + "')";
flakeImage.style.transform = "scale(" + size + ", " + size + ")";
flakeImage.style.opacity = size;
flake = document.createElement("div");
var animationName;
switch (effect.direction) {
case "down": {
flake.className = "flake-downwards";
flake.style.left = Math.random() * 100 - 10 + "%";
animationName = "flake-jiggle";
break;
}
case "left-right": {
flake.className = "flake-left-right";
flake.style.left = -75 - size * 2 + "px";
flake.style.top = Math.random() * 100 - 10 + "%";
flake.style.animationName = "flake-jiggle-left-right";
break;
}
case "right-left": {
flake.className = "flake-right-left";
flake.style.right = 75 + size * 2 + "px";
flake.style.top = Math.random() * 100 - 10 + "%";
flake.style.animationName = "flake-jiggle-right-left";
break;
}
default: {
flake.className = "flake-upwards";
flake.style.left = Math.random() * 100 - 10 + "%";
animationName = "flake-jiggle";
break;
}
}
var max = effect.getSpeedMax();
var min = effect.getSpeedMin();
jiggle = document.createElement("div");
jiggle.style.animationDelay = Math.random() * max + "s";
jiggle.style.animationDuration = max - Math.random() * min * size + "s";
if (animationName) {
jiggle.style.animationName = animationName;
}
jiggle.appendChild(flakeImage);
size = Math.random() * 0.75 + 0.25;
jiggle.style.transform = "scale(" + size + ", " + size + ")";
jiggle.style.opacity = size;
if (animationName) {
jiggle.style.animationName = animationName;
}
flake.appendChild(jiggle);
flake.style.animationDelay = Math.random() * max + "s";
flake.style.animationDuration = max - Math.random() * min * size + "s";
wrapper.appendChild(flake);
}
},
buildSnowman: function (wrapper) {
this.doShowEffects = false;
var snowmanImage = document.createElement("div");
snowmanImage.classList.add("snowman");
snowmanImage.style.animationDuration = this.config.effectDuration - 10000 + "ms"; //subtract for 10s delay
wrapper.appendChild(snowmanImage);
},
makeItRain: function (wrapper) {
this.doShowEffects = false;
var increment = 0;
while (increment < this.config.particleCount) {
var randoHundo = Math.floor(Math.random() * (98 - 1 + 1) + 1); //random number between 98 and 1
var randoFiver = Math.floor(Math.random() * (5 - 2 + 1) + 2);
increment += randoFiver;
var frontDrop = document.createElement("div");
frontDrop.classList.add("drop");
frontDrop.style.left = increment + "%";
frontDrop.style.bottom = randoFiver + randoFiver - 1 + 100 + "%";
frontDrop.style.animationDelay = "1." + randoHundo + "s";
frontDrop.style.animationDuration = "1.5" + randoHundo + "s";
var frontStem = document.createElement("div");
frontStem.classList.add("stem");
frontStem.style.animationDelay = "1." + randoHundo + "s";
frontStem.style.animationDuration = "1.5" + randoHundo + "s";
frontDrop.appendChild(frontStem);
var backDrop = document.createElement("div");
backDrop.classList.add("drop");
backDrop.style.opacity = "0.5";
backDrop.style.right = increment + "%";
backDrop.style.bottom = randoFiver + randoFiver - 1 + 100 + "%";
backDrop.style.animationDelay = "1." + randoHundo + "s";
backDrop.style.animationDuration = "1.5" + randoHundo + "s";
var backStem = document.createElement("div");
backStem.classList.add("stem");
backStem.style.animationDelay = "1." + randoHundo + "s";
backStem.style.animationDuration = "1.5" + randoHundo + "s";
backDrop.appendChild(backStem);
wrapper.appendChild(backDrop);
wrapper.appendChild(frontDrop);
}
},
buildFlower: function (wrapper) {
this.doShowEffects = false;
var flowerImage = document.createElement("div");
flowerImage.classList.add("flower");
flowerImage.style.animationDuration = this.config.effectDuration - 10000 + "ms"; //subtract for 10s delay
wrapper.appendChild(flowerImage);
},
makeItLightning: function (wrapper) {
this.doShowEffects = false;
var lightningImage1 = document.createElement("div");
lightningImage1.classList.add("lightning1");
lightningImage1.style.animationIterationCount = this.config.lightning1Count;
var lightningImage2 = document.createElement("div");
lightningImage2.classList.add("lightning2");
lightningImage2.style.animationIterationCount = this.config.lightning2Count;
var lightningPlayer = document.createElement("div");
lightningPlayer.classList.add("lightningPlayer");
lightningPlayer.appendChild(lightningImage1);
lightningPlayer.appendChild(lightningImage2);
wrapper.appendChild(lightningPlayer);
},
makeItSunny: function (wrapper) {
this.doShowEffects = false;
var sunImage = document.createElement("div");
sunImage.classList.add("sun");
sunImage.style.background = "url('./modules/MMM-DynamicWeather/images/" + this.config.sunImage + ".png') center center/cover no-repeat transparent";
var sunPlayer = document.createElement("div");
sunPlayer.classList.add("sunPlayer");
sunPlayer.appendChild(sunImage);
wrapper.appendChild(sunPlayer);
},
makeItCloudy: function (wrapper) {
this.doShowEffects = false;
var increment = 0;
while (increment < this.config.particleCount) {
var randNum = Math.floor(Math.random() * (25 - 5 + 1) + 5); //random number between 25 and 5
var speed = Math.floor(Math.random() * (35 - 15 + 1) + 15);
var size = Math.floor(Math.random() * (60 - 3 + 1) + 3);
increment += randNum;
var cloudBase = document.createElement("div");
cloudBase.style.animation = "animateCloud " + speed + "s linear infinite";
cloudBase.style.transform = "scale(0." + size + ")";
var cloud = document.createElement("div");
cloud.classList.add("cloud");
cloudBase.appendChild(cloud);
wrapper.appendChild(cloudBase);
}
},
makeItFoggy: function (wrapper) {
this.doShowEffects = false;
var fogImage1 = document.createElement("div");
fogImage1.classList.add("image01");
var fogImage2 = document.createElement("div");
fogImage2.classList.add("image02");
var fogPlayer1 = document.createElement("div");
fogPlayer1.id = "foglayer_01";
fogPlayer1.classList.add("fog");
fogPlayer1.appendChild(fogImage1);
fogPlayer1.appendChild(fogImage2);
wrapper.appendChild(fogPlayer1);
fogImage1 = document.createElement("div");
fogImage1.classList.add("image01");
fogImage2 = document.createElement("div");
fogImage2.classList.add("image02");
var fogPlayer2 = document.createElement("div");
fogPlayer2.id = "foglayer_02";
fogPlayer2.classList.add("fog");
fogPlayer2.appendChild(fogImage1);
fogPlayer2.appendChild(fogImage2);
wrapper.appendChild(fogPlayer2);
fogImage1 = document.createElement("div");
fogImage1.classList.add("image01");
fogImage2 = document.createElement("div");
fogImage2.classList.add("image02");
var fogPlayer3 = document.createElement("div");
fogPlayer3.id = "foglayer_03";
fogPlayer3.classList.add("fog");
fogPlayer3.appendChild(fogImage1);
fogPlayer3.appendChild(fogImage2);
wrapper.appendChild(fogPlayer3);
},
stopEffect: function (_this) {
try {
//wait for delay and reset
_this.updateDom();
var delay = _this.config.effectDelay;
_this.effectDelayTimeout = setTimeout(function (_that, _effect) {
_that.doShowEffects = true;
_that.updateDom();
}, delay, _this);
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in stopping effects: ", error);
}
},
getWeather: function (_this) {
_this.sendSocketNotification("API-Fetch", _this.url);
_this.weatherTimeout = setTimeout(_this.getWeather, _this.config.weatherInterval, _this);
},
getHolidays: function (_this) {
try {
_this.sendSocketNotification("Holiday-Fetch", {});
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
tomorrow.setHours(0, 0, 0, 0);
var msTillMidnight = tomorrow.getTime() - today.getTime();
console.info("[MMM-DynamicWeather] Holidays have been fetched, waiting till midnight (" + msTillMidnight + " ms) to reset.");
_this.holidayTimeout = setTimeout(_this.resetHolidays, msTillMidnight, _this);
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in getHolidays: ", error);
}
},
resetHolidays: function (_this) {
try {
console.info("[MMM-DynamicWeather] Resetting holidays...");
//Reset all effects with a holiday to not show, we will trigger another getHolidays to see if the next day has another holiday to display next
_this.allEffects.forEach(function (effect) {
if (effect.holiday) {
effect.doDisplay = false;
}
});
_this.hasHolidayEffectsToDisplay = false;
_this.updateDom();
console.info("[MMM-DynamicWeather] Holidays reset.");
_this.getHolidays(_this);
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in resetting holidays: ", error);
}
},
parseHolidays: function (body) {
var today = new Date();
var todayHolidays = [];
todayHolidays.push("test");
try {
var parser = new DOMParser();
var doc = parser.parseFromString(body, "text/html");
var children = doc.getElementById("holidays-table").children[1].children;
for (var i = 0; i < children.length; i++) {
var child1 = children[i];
if (child1.hasAttribute("data-date")) {
var holidayDateStr = child1.getAttribute("data-date");
var child2 = child1.children;
for (var j = 0; j < child2.length; j++) {
var child3 = child2[j];
if (child3.hasChildNodes()) {
for (var k = 0; k < child3.children.length; k++) {
var child4 = child3.children[k];
for (var l = 0; l < this.allHolidays.length; l++) {
var effectHoliday = this.allHolidays[l];
if (child4.textContent == effectHoliday) {
var holidayDate = new Date(parseInt(holidayDateStr));
if (holidayDate.getUTCDate() == today.getDate() && holidayDate.getUTCMonth() == today.getMonth()) {
todayHolidays.push(effectHoliday);
}
}
}
}
}
}
}
}
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in parsing holidays: ", error);
}
return todayHolidays;
},
socketNotificationReceived: function (notification, payload) {
var _this_1 = this;
try {
if (notification === "API-Received" && payload.url === this.url) {
this.weatherLoaded = true;
if (!payload.success) {
console.error("[MMM-DynamicWeather] API-Receieved failure status");
return;
}
var newCode_1 = payload.result.weather[0].id;
var doUpdate_1 = false;
//check to see if the newCode is different than already displayed, and if so, is it going to show anything
if (newCode_1 != this.weatherCode) {
this.weatherCode = newCode_1;
if (newCode_1 >= 600 && newCode_1 <= 622 && !this.config.hideSnow) {
doUpdate_1 = true;
}
if ((newCode_1 >= 200 && newCode_1 <= 531) || (newCode_1 >= 611 && newCode_1 <= 622 && !this.config.hideRain)) {
doUpdate_1 = true;
}
if (newCode_1 >= 200 && newCode_1 <= 232 && !this.config.hideLightning) {
doUpdate_1 = true;
}
if (newCode_1 >= 801 && newCode_1 <= 804 && !this.config.hideClouds) {
doUpdate_1 = true;
}
if (newCode_1 >= 701 && newCode_1 <= 781 && !this.config.hideFog) {
doUpdate_1 = true;
}
if (newCode_1 == 800 && !this.config.hideSun) {
doUpdate_1 = true;
}
this.allEffects.forEach(function (effect) {
if (effect.getWeatherCode() == newCode_1 || (effect.getMinWeatherCode() <= newCode_1 && effect.getMaxWeatherCode() >= newCode_1)) {
doUpdate_1 = true;
effect.doDisplay = true;
_this_1.hasWeatherEffectsToDisplay = true;
}
});
}
//only update the dom if the weather is different (unless holiday or date effects exist and holiday has finished loading)
if (doUpdate_1 || (this.holidayLoaded && (this.hasDateEffectsToDisplay || this.hasHolidayEffectsToDisplay))) {
this.doShowEffects = true;
clearTimeout(this.effectDurationTimeout);
clearTimeout(this.effectDelayTimeout);
this.updateDom();
}
}
if (notification === "Holiday-Received") {
this.holidayLoaded = true;
if (!payload.success) {
console.error("[MMM-DynamicWeather] Holiday-Receieved failure status");
return;
}
var doUpdate_2 = false;
var todayHolidays_1 = [];
todayHolidays_1 = this.parseHolidays(payload.result.holidayBody);
//returned a list of holidays for today, check to see if any effects have the same holiday name, if so display them and update dom
this.allEffects.forEach(function (effect) {
todayHolidays_1.forEach(function (holidayName) {
if (effect.holiday == holidayName) {
doUpdate_2 = true;
effect.doDisplay = true;
_this_1.hasHolidayEffectsToDisplay = true;
}
});
});
//only update the dom if the effects have a holiday to show today (unless weather and date effects exist and weather has finished loading)
if (doUpdate_2 || (this.weatherLoaded && (this.hasDateEffectsToDisplay || this.hasWeatherEffectsToDisplay))) {
this.doShowEffects = true;
clearTimeout(this.effectDurationTimeout);
clearTimeout(this.effectDelayTimeout);
this.updateDom();
}
}
}
catch (error) {
console.error("[MMM-DynamicWeather] Error occured in notification received: ", error);
}
},
});
@@ -0,0 +1,841 @@
/* Magic Mirror
* Module: MMM-DynamicWeather
*
* By Scott Lewis - https://github.com/scottcl88/MMM-DynamicWeather
* MIT Licensed.
*
* A heavily configurable MagicMirror Module to display different animations based on current weather and show customized event effects.
*/
declare var Log: Console;
declare var Module: any;
class Effect {
constructor() {}
id: number; //an id made up to use for sequential logic
month: number;
day: number;
year: number = 0;
images: string[];
direction: string;
size: number;
particleCount: number;
speedMax: number;
speedMin: number;
weatherCode: number;
weatherCodeMin: number;
weatherCodeMax: number;
holiday: string;
recurrence: string; //monthly, weekly, weekdays, weekends
doDisplay: boolean = false;
public getYear(): number {
return this.year ? this.year : 0;
}
public getMonth(): number {
return this.month ? this.month : 0;
}
public getDay(): number {
return this.day ? this.day : 0;
}
public getSize(): number {
return this.size ? this.size : 1;
}
public getParticleCount(): number {
return this.particleCount ? this.particleCount : -1;
}
public getSpeedMax(): number {
return this.speedMax ? this.speedMax : 100;
}
public getSpeedMin(): number {
return this.speedMin ? this.speedMin : 50;
}
public getWeatherCode(): number {
return this.weatherCode ? this.weatherCode : -99;
}
public getMinWeatherCode(): number {
return this.weatherCodeMin ? this.weatherCodeMin : 99999;
}
public getMaxWeatherCode(): number {
return this.weatherCodeMax ? this.weatherCodeMax : -99999;
}
public hasWeatherCode(): boolean {
return (this.weatherCode && this.weatherCode > 0) || (this.weatherCodeMin && this.weatherCodeMin > 0) || (this.weatherCodeMax && this.weatherCodeMax > 0) ? true : false;
}
public hasHoliday(): boolean {
return this.holiday && this.holiday.length > 0 ? true : false;
}
public clone(other: Effect) {
this.id = other.id;
this.day = other.day;
this.month = other.month;
this.year = other.year;
this.images = other.images;
this.direction = other.direction;
this.size = other.size;
this.particleCount = other.particleCount;
this.speedMax = other.speedMax;
this.speedMin = other.speedMin;
this.weatherCode = other.weatherCode;
this.weatherCodeMin = other.weatherCodeMin;
this.weatherCodeMax = other.weatherCodeMax;
this.holiday = other.holiday;
this.recurrence = other.recurrence;
this.doDisplay = other.doDisplay;
}
}
Module.register("MMM-DynamicWeather", {
defaults: {
particleCount: 100,
api_key: "",
locationID: 0,
lat: 0,
lon: 0,
weatherInterval: 600000, // Every 10 minutes,
alwaysDisplay: "",
zIndex: 99,
opacity: 1,
fadeDuration: 3000,
effectDuration: 120000,
effectDelay: 60000,
realisticClouds: false,
hideSun: false,
hideSnow: false,
hideSnowman: true,
hideRain: false,
hideFlower: true,
hideClouds: false,
hideFog: false,
hideLightning: false,
lightning1Count: 2,
lightning2Count: 3,
sequential: "",
sunImage: "sun_right",
effects: [] as Effect[],
},
start: function () {
Log.info("Starting MMM-DynamicWeather");
this.now = new Date();
this.initialized = false;
this.weatherLoaded = false;
this.holidayLoaded = false;
this.doShowEffects = true;
this.hasDateEffectsToDisplay = false;
this.hasHolidayEffectsToDisplay = false;
this.hasWeatherEffectsToDisplay = true;
this.effectDurationTimeout = null;
this.effectDelayTimeout = null;
this.weatherTimeout = null;
this.holidayTimeout = null;
this.allEffects = [] as Effect[];
this.url = "https://api.openweathermap.org/data/2.5/weather?appid=" + this.config.api_key;
if (this.config.lat && this.config.lon) {
this.url += "&lat=" + this.config.lat + "&lon=" + this.config.lon;
}
if (this.config.locationID) {
this.url += "&id=" + this.config.locationID;
}
this.snowEffect = new Effect();
this.snowEffect.images = ["snow1.png", "snow2.png", "snow3.png"];
this.snowEffect.size = 1;
this.snowEffect.direction = "down";
(this.realisticCloudsEffect as Effect) = new Effect();
(this.realisticCloudsEffect as Effect).size = 15;
(this.realisticCloudsEffect as Effect).direction = "left-right";
(this.realisticCloudsEffect as Effect).images = ["cloud1.png", "cloud2.png"];
this.weatherCode = 0;
this.allHolidays = [] as string[];
let count = 0;
this.config.effects.forEach((configEffect) => {
var effect = new Effect();
effect.clone(configEffect);
effect.id = count;
count++;
this.allEffects.push(effect);
this.allHolidays.push(effect.holiday);
});
this.lastSequentialId = -1;
if (this.config.sequential) {
if (this.config.sequential == "effect" || this.config.sequential == "effect-one") {
this.lastSequential = "weather";
} else if (this.config.sequential == "weather") {
this.lastSequential = "effect";
} else {
this.lastSequential = "";
}
} else {
this.lastSequential = "";
}
this.checkDates();
if (this.allHolidays.length > 0) {
this.getHolidays(this);
} else {
this.holidayLoaded = true;
}
if (!this.config.alwaysDisplay) {
this.getWeather(this);
} else {
this.weatherLoaded = true;
}
Log.info("[MMM-DynamicWeather] Finished initialization");
},
getStyles: function () {
return ["MMM-DynamicWeather.css"];
},
checkDates: function () {
try {
(this.allEffects as Effect[]).forEach((effect) => {
var effectMonth = effect.month - 1;
if (!effect.hasWeatherCode() && !effect.hasHoliday()) {
//if there is weatherCode or holiday, dates are ignored
if (effect.getMonth() == 0 && effect.getDay() == 0 && effect.getYear() == 0) {
//if no weatherCode, no holiday and no dates, then always display it
if (effect.recurrence == "weekdays") {
//if its not Sunday (0) and not Saturday (6)
if (this.now.getDay() !== 6 && this.now.getDay() !== 0) {
this.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
} else if (effect.recurrence == "weekends") {
//if its Sunday (0) or Saturday (6)
if (this.now.getDay() == 6 || this.now.getDay() == 0) {
this.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
} else {
this.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
} else {
//if the month and date match or the month, date and year match
if (this.now.getMonth() == effectMonth && this.now.getDate() == effect.day) {
if (effect.getYear() == 0 || this.now.getFullYear() == effect.getYear()) {
this.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
} else if (effect.recurrence == "monthly") {
//ignore everything but the day
if (this.now.getDate() == effect.getDay()) {
this.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
} else if (effect.recurrence == "weekly") {
var effectDay = new Date(effect.getYear(), effectMonth, effect.getDay());
if (this.now.getDay() == effectDay.getDay()) {
this.hasDateEffectsToDisplay = true;
effect.doDisplay = true;
}
}
}
}
});
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in checkDates: ", error);
}
},
getDom: function () {
var wrapper = document.createElement("div");
wrapper.style.zIndex = this.config.zIndex;
wrapper.style.opacity = this.config.opacity;
wrapper.className = "wrapper";
try {
//setup the fade-out animation
var fadeDuration = parseInt(this.config.fadeDuration);
var animationDelay = parseInt(this.config.effectDuration) - fadeDuration;
var fadeCSS = document.createElement("style");
fadeCSS.innerHTML = ".fade-out {animation-name: fade; animation-duration: " + fadeDuration + "ms; animation-delay: " + animationDelay + "ms;}";
wrapper.prepend(fadeCSS);
wrapper.onanimationend = (e) => {
//delay finished, elements faded out, now remove
var thisAnimation = e.animationName;
if (thisAnimation == "fade") {
wrapper.remove();
}
};
if (this.config.alwaysDisplay) {
switch (this.config.alwaysDisplay) {
case "snow": {
this.showCustomEffect(wrapper, this.snowEffect);
if (this.config.hideSnowman === false || this.config.hideSnowman === "false") {
this.buildSnowman(wrapper);
}
break;
}
case "sun": {
this.makeItSunny(wrapper);
break;
}
case "rain": {
this.makeItRain(wrapper);
if (this.config.hideFlower === false || this.config.hideFlower === "false") {
this.buildFlower(wrapper);
}
break;
}
case "lightning": {
this.makeItLightning(wrapper);
break;
}
case "rain-lightning": {
this.makeItRain(wrapper);
this.makeItLightning(wrapper);
break;
}
case "cloudy": {
if (this.config.realisticClouds) {
this.showCustomEffect(wrapper, this.realisticCloudsEffect);
} else {
this.makeItCloudy(wrapper);
}
break;
}
case "fog": {
this.makeItFoggy(wrapper);
break;
}
default: {
console.error("[MMM-DynamicWeather] Invalid config option 'alwaysDisplay'");
}
}
return wrapper;
}
if (!this.weatherLoaded || !this.holidayLoaded) return wrapper; //need to wait for the weather to first be loaded
if (!this.doShowEffects) return wrapper;
wrapper.className = "wrapper fade-out";
let showEffects = false;
let showWeather = false;
//check to see what should be shown based on availability and sequential
if (this.hasDateEffectsToDisplay || this.hasHolidayEffectsToDisplay || this.hasWeatherEffectsToDisplay) {
if (this.lastSequential == "effect" && this.hasWeatherEffectsToDisplay) {
//if its weather's turn and there are weather to show
showWeather = true;
this.lastSequential = "weather";
} else if (this.lastSequential == "weather" && (this.hasDateEffectsToDisplay || this.hasHolidayEffectsToDisplay)) {
//if its effect's turn and there are effects to show
showEffects = true;
this.lastSequential = "effect";
} else {
showWeather = true;
showEffects = true;
}
}
if (showEffects) {
for (let effect of this.allEffects as Effect[]) {
if (effect.doDisplay) {
//we can display this effect
if (this.config.sequential == "effect-one") {
//only show one effect at a time. if it wasn't the last one and its next in line, then do show it
if (this.lastSequentialId < effect.id) {
this.lastSequentialId = effect.id;
if (this.allEffects.length - 1 == this.lastSequentialId) {
//reached end of effects, reset
this.lastSequentialId = -1;
}
this.showCustomEffect(wrapper, effect);
break;
}
} else {
this.showCustomEffect(wrapper, effect);
}
}
}
}
if (showWeather) {
//Codes from https://openweathermap.org/weather-conditions
if (this.weatherCode >= 600 && this.weatherCode <= 622 && !this.config.hideSnow) {
this.showCustomEffect(wrapper, this.snowEffect);
if (this.config.hideSnowman === false || this.config.hideSnowman === "false") {
this.buildSnowman(wrapper);
}
if (this.weatherCode >= 611 && this.weatherCode <= 622 && !this.config.hideRain) {
//snow/rain mix
this.makeItRain(wrapper);
}
} else if (this.weatherCode >= 200 && this.weatherCode <= 531 && !this.config.hideRain) {
this.makeItRain(wrapper);
if (this.config.hideFlower === false || this.config.hideFlower === "false") {
this.buildFlower(wrapper);
}
if (this.weatherCode >= 200 && this.weatherCode <= 232 && !this.config.hideLightning) {
this.makeItLightning(wrapper);
}
} else if (this.weatherCode >= 801 && this.weatherCode <= 804 && !this.config.hideClouds) {
if (this.config.realisticClouds) {
if (this.weatherCode == 801) {
(this.realisticCloudsEffect as Effect).size = 8;
(this.realisticCloudsEffect as Effect).particleCount = 30;
(this.realisticCloudsEffect as Effect).images = ["cloud1.png"];
} else if (this.weatherCode == 802) {
(this.realisticCloudsEffect as Effect).size = 8;
(this.realisticCloudsEffect as Effect).particleCount = 50;
(this.realisticCloudsEffect as Effect).images = ["cloud1.png", "cloud2.png"];
} else if (this.weatherCode == 803) {
(this.realisticCloudsEffect as Effect).size = 15;
(this.realisticCloudsEffect as Effect).particleCount = 30;
(this.realisticCloudsEffect as Effect).images = ["cloud1.png", "cloud2.png"];
} else if (this.weatherCode == 804) {
(this.realisticCloudsEffect as Effect).size = 15;
(this.realisticCloudsEffect as Effect).particleCount = 30;
(this.realisticCloudsEffect as Effect).images = ["cloud3.png", "cloud2.png", "cloud1.png"];
}
this.showCustomEffect(wrapper, this.realisticCloudsEffect);
} else {
this.makeItCloudy(wrapper);
}
} else if (this.weatherCode >= 701 && this.weatherCode <= 781 && !this.config.hideFog) {
this.makeItFoggy(wrapper);
}else if (this.weatherCode == 800 && !this.config.hideSun) {
this.makeItSunny(wrapper);
}
}
console.info("[MMM-DynamicWeather] Displaying effects for: ", this.config.effectDuration);
this.effectDurationTimeout = setTimeout(this.stopEffect, this.config.effectDuration, this);
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in getDom: ", error);
}
return wrapper;
},
showCustomEffect: function (wrapper: HTMLDivElement, effect: Effect) {
this.doShowEffects = false;
var flake, jiggle, size;
var particleCount = effect.getParticleCount();
if (particleCount < 0) {
particleCount = this.config.particleCount;
}
for (var i = 0; i < particleCount; i++) {
size = effect.getSize(); // * (Math.random() * 0.75) + 0.25;
let flakeImage = document.createElement("div");
let maxNum = effect.images.length;
var picIndex = Math.floor(Math.random() * (maxNum - 0) + 0);
flakeImage.style.backgroundImage = "url('./modules/MMM-DynamicWeather/images/" + effect.images[picIndex] + "')";
flakeImage.style.transform = "scale(" + size + ", " + size + ")";
flakeImage.style.opacity = size;
flake = document.createElement("div");
var animationName;
switch (effect.direction) {
case "down": {
flake.className = "flake-downwards";
flake.style.left = Math.random() * 100 - 10 + "%";
animationName = "flake-jiggle";
break;
}
case "left-right": {
flake.className = "flake-left-right";
flake.style.left = -75 - size * 2 + "px";
flake.style.top = Math.random() * 100 - 10 + "%";
flake.style.animationName = "flake-jiggle-left-right";
break;
}
case "right-left": {
flake.className = "flake-right-left";
flake.style.right = 75 + size * 2 + "px";
flake.style.top = Math.random() * 100 - 10 + "%";
flake.style.animationName = "flake-jiggle-right-left";
break;
}
default: {
flake.className = "flake-upwards";
flake.style.left = Math.random() * 100 - 10 + "%";
animationName = "flake-jiggle";
break;
}
}
let max = effect.getSpeedMax();
let min = effect.getSpeedMin();
jiggle = document.createElement("div");
jiggle.style.animationDelay = Math.random() * max + "s";
jiggle.style.animationDuration = max - Math.random() * min * size + "s";
if (animationName) {
jiggle.style.animationName = animationName;
}
jiggle.appendChild(flakeImage);
size = Math.random() * 0.75 + 0.25;
jiggle.style.transform = "scale(" + size + ", " + size + ")";
jiggle.style.opacity = size;
if (animationName) {
jiggle.style.animationName = animationName;
}
flake.appendChild(jiggle);
flake.style.animationDelay = Math.random() * max + "s";
flake.style.animationDuration = max - Math.random() * min * size + "s";
wrapper.appendChild(flake);
}
},
buildSnowman: function (wrapper) {
this.doShowEffects = false;
var snowmanImage = document.createElement("div");
snowmanImage.classList.add("snowman");
snowmanImage.style.animationDuration = this.config.effectDuration - 10000 + "ms"; //subtract for 10s delay
wrapper.appendChild(snowmanImage);
},
makeItRain: function (wrapper) {
this.doShowEffects = false;
var increment = 0;
while (increment < this.config.particleCount) {
var randoHundo = Math.floor(Math.random() * (98 - 1 + 1) + 1); //random number between 98 and 1
var randoFiver = Math.floor(Math.random() * (5 - 2 + 1) + 2);
increment += randoFiver;
let frontDrop = document.createElement("div");
frontDrop.classList.add("drop");
frontDrop.style.left = increment + "%";
frontDrop.style.bottom = randoFiver + randoFiver - 1 + 100 + "%";
frontDrop.style.animationDelay = "1." + randoHundo + "s";
frontDrop.style.animationDuration = "1.5" + randoHundo + "s";
let frontStem = document.createElement("div");
frontStem.classList.add("stem");
frontStem.style.animationDelay = "1." + randoHundo + "s";
frontStem.style.animationDuration = "1.5" + randoHundo + "s";
frontDrop.appendChild(frontStem);
let backDrop = document.createElement("div");
backDrop.classList.add("drop");
backDrop.style.opacity = "0.5";
backDrop.style.right = increment + "%";
backDrop.style.bottom = randoFiver + randoFiver - 1 + 100 + "%";
backDrop.style.animationDelay = "1." + randoHundo + "s";
backDrop.style.animationDuration = "1.5" + randoHundo + "s";
let backStem = document.createElement("div");
backStem.classList.add("stem");
backStem.style.animationDelay = "1." + randoHundo + "s";
backStem.style.animationDuration = "1.5" + randoHundo + "s";
backDrop.appendChild(backStem);
wrapper.appendChild(backDrop);
wrapper.appendChild(frontDrop);
}
},
buildFlower: function (wrapper) {
this.doShowEffects = false;
var flowerImage = document.createElement("div");
flowerImage.classList.add("flower");
flowerImage.style.animationDuration = this.config.effectDuration - 10000 + "ms"; //subtract for 10s delay
wrapper.appendChild(flowerImage);
},
makeItLightning: function (wrapper) {
this.doShowEffects = false;
var lightningImage1 = document.createElement("div");
lightningImage1.classList.add("lightning1");
lightningImage1.style.animationIterationCount = this.config.lightning1Count;
var lightningImage2 = document.createElement("div");
lightningImage2.classList.add("lightning2");
lightningImage2.style.animationIterationCount = this.config.lightning2Count;
let lightningPlayer = document.createElement("div");
lightningPlayer.classList.add("lightningPlayer");
lightningPlayer.appendChild(lightningImage1);
lightningPlayer.appendChild(lightningImage2);
wrapper.appendChild(lightningPlayer);
},
makeItSunny: function (wrapper) {
this.doShowEffects = false;
var sunImage = document.createElement("div");
sunImage.classList.add("sun");
sunImage.style.background = "url('./modules/MMM-DynamicWeather/images/" + this.config.sunImage + ".png') center center/cover no-repeat transparent";
let sunPlayer = document.createElement("div");
sunPlayer.classList.add("sunPlayer");
sunPlayer.appendChild(sunImage);
wrapper.appendChild(sunPlayer);
},
makeItCloudy: function (wrapper) {
this.doShowEffects = false;
var increment = 0;
while (increment < this.config.particleCount) {
var randNum = Math.floor(Math.random() * (25 - 5 + 1) + 5); //random number between 25 and 5
var speed = Math.floor(Math.random() * (35 - 15 + 1) + 15);
var size = Math.floor(Math.random() * (60 - 3 + 1) + 3);
increment += randNum;
let cloudBase = document.createElement("div");
cloudBase.style.animation = "animateCloud " + speed + "s linear infinite";
cloudBase.style.transform = "scale(0." + size + ")";
let cloud = document.createElement("div");
cloud.classList.add("cloud");
cloudBase.appendChild(cloud);
wrapper.appendChild(cloudBase);
}
},
makeItFoggy: function (wrapper) {
this.doShowEffects = false;
var fogImage1 = document.createElement("div");
fogImage1.classList.add("image01");
var fogImage2 = document.createElement("div");
fogImage2.classList.add("image02");
let fogPlayer1 = document.createElement("div");
fogPlayer1.id = "foglayer_01";
fogPlayer1.classList.add("fog");
fogPlayer1.appendChild(fogImage1);
fogPlayer1.appendChild(fogImage2);
wrapper.appendChild(fogPlayer1);
fogImage1 = document.createElement("div");
fogImage1.classList.add("image01");
fogImage2 = document.createElement("div");
fogImage2.classList.add("image02");
let fogPlayer2 = document.createElement("div");
fogPlayer2.id = "foglayer_02";
fogPlayer2.classList.add("fog");
fogPlayer2.appendChild(fogImage1);
fogPlayer2.appendChild(fogImage2);
wrapper.appendChild(fogPlayer2);
fogImage1 = document.createElement("div");
fogImage1.classList.add("image01");
fogImage2 = document.createElement("div");
fogImage2.classList.add("image02");
let fogPlayer3 = document.createElement("div");
fogPlayer3.id = "foglayer_03";
fogPlayer3.classList.add("fog");
fogPlayer3.appendChild(fogImage1);
fogPlayer3.appendChild(fogImage2);
wrapper.appendChild(fogPlayer3);
},
stopEffect: function (_this) {
try {
//wait for delay and reset
_this.updateDom();
let delay = _this.config.effectDelay;
_this.effectDelayTimeout = setTimeout(
(_that, _effect) => {
_that.doShowEffects = true;
_that.updateDom();
},
delay,
_this
);
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in stopping effects: ", error);
}
},
getWeather: function (_this) {
_this.sendSocketNotification("API-Fetch", _this.url);
_this.weatherTimeout = setTimeout(_this.getWeather, _this.config.weatherInterval, _this);
},
getHolidays: function (_this) {
try {
_this.sendSocketNotification("Holiday-Fetch", {});
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
tomorrow.setHours(0, 0, 0, 0);
var msTillMidnight = tomorrow.getTime() - today.getTime();
console.info("[MMM-DynamicWeather] Holidays have been fetched, waiting till midnight (" + msTillMidnight + " ms) to reset.");
_this.holidayTimeout = setTimeout(_this.resetHolidays, msTillMidnight, _this);
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in getHolidays: ", error);
}
},
resetHolidays: function (_this) {
try {
console.info("[MMM-DynamicWeather] Resetting holidays...");
//Reset all effects with a holiday to not show, we will trigger another getHolidays to see if the next day has another holiday to display next
(_this.allEffects as Effect[]).forEach((effect) => {
if (effect.holiday) {
effect.doDisplay = false;
}
});
_this.hasHolidayEffectsToDisplay = false;
_this.updateDom();
console.info("[MMM-DynamicWeather] Holidays reset.");
_this.getHolidays(_this);
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in resetting holidays: ", error);
}
},
parseHolidays: function (body: string) {
let today = new Date();
let todayHolidays = [];
todayHolidays.push("test");
try {
var parser = new DOMParser();
var doc = parser.parseFromString(body, "text/html");
var children = doc.getElementById("holidays-table").children[1].children;
for (var i = 0; i < children.length; i++) {
var child1 = children[i];
if (child1.hasAttribute("data-date")) {
var holidayDateStr = child1.getAttribute("data-date");
var child2 = child1.children;
for (var j = 0; j < child2.length; j++) {
var child3 = child2[j];
if (child3.hasChildNodes()) {
for (var k = 0; k < child3.children.length; k++) {
var child4 = child3.children[k];
for (var l = 0; l < this.allHolidays.length; l++) {
var effectHoliday = this.allHolidays[l];
if (child4.textContent == effectHoliday) {
var holidayDate = new Date(parseInt(holidayDateStr));
if (holidayDate.getUTCDate() == today.getDate() && holidayDate.getUTCMonth() == today.getMonth()) {
todayHolidays.push(effectHoliday);
}
}
}
}
}
}
}
}
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in parsing holidays: ", error);
}
return todayHolidays;
},
socketNotificationReceived: function (notification, payload) {
try {
if (notification === "API-Received" && payload.url === this.url) {
this.weatherLoaded = true;
if (!payload.success) {
console.error("[MMM-DynamicWeather] API-Receieved failure status");
return;
}
let newCode = payload.result.weather[0].id;
let doUpdate = false;
//check to see if the newCode is different than already displayed, and if so, is it going to show anything
if (newCode != this.weatherCode) {
this.weatherCode = newCode;
if (newCode >= 600 && newCode <= 622 && !this.config.hideSnow) {
doUpdate = true;
}
if ((newCode >= 200 && newCode <= 531) || (newCode >= 611 && newCode <= 622 && !this.config.hideRain)) {
doUpdate = true;
}
if (newCode >= 200 && newCode <= 232 && !this.config.hideLightning) {
doUpdate = true;
}
if (newCode >= 801 && newCode <= 804 && !this.config.hideClouds) {
doUpdate = true;
}
if (newCode >= 701 && newCode <= 781 && !this.config.hideFog) {
doUpdate = true;
}
if (newCode == 800 && !this.config.hideSun) {
doUpdate = true;
}
(this.allEffects as Effect[]).forEach((effect) => {
if (effect.getWeatherCode() == newCode || (effect.getMinWeatherCode() <= newCode && effect.getMaxWeatherCode() >= newCode)) {
doUpdate = true;
effect.doDisplay = true;
this.hasWeatherEffectsToDisplay = true;
}
});
}
//only update the dom if the weather is different (unless holiday or date effects exist and holiday has finished loading)
if (doUpdate || (this.holidayLoaded && (this.hasDateEffectsToDisplay || this.hasHolidayEffectsToDisplay))) {
this.doShowEffects = true;
clearTimeout(this.effectDurationTimeout);
clearTimeout(this.effectDelayTimeout);
this.updateDom();
}
}
if (notification === "Holiday-Received") {
this.holidayLoaded = true;
if (!payload.success) {
console.error("[MMM-DynamicWeather] Holiday-Receieved failure status");
return;
}
let doUpdate = false;
let todayHolidays = [] as string[];
todayHolidays = this.parseHolidays(payload.result.holidayBody);
//returned a list of holidays for today, check to see if any effects have the same holiday name, if so display them and update dom
(this.allEffects as Effect[]).forEach((effect) => {
todayHolidays.forEach((holidayName) => {
if (effect.holiday == holidayName) {
doUpdate = true;
effect.doDisplay = true;
this.hasHolidayEffectsToDisplay = true;
}
});
});
//only update the dom if the effects have a holiday to show today (unless weather and date effects exist and weather has finished loading)
if (doUpdate || (this.weatherLoaded && (this.hasDateEffectsToDisplay || this.hasWeatherEffectsToDisplay))) {
this.doShowEffects = true;
clearTimeout(this.effectDurationTimeout);
clearTimeout(this.effectDelayTimeout);
this.updateDom();
}
}
} catch (error) {
console.error("[MMM-DynamicWeather] Error occured in notification received: ", error);
}
},
});
+123
View File
@@ -0,0 +1,123 @@
# Module: MMM-DynamicWeather
A heavily configurable MagicMirror Module to display different animations based on current weather and show customized event effects.
<br>
<br>
Inspired by [MichMich's Snow Plugin](https://github.com/MichMich/MMM-Snow)
**Rain**
![](rain_example.png)
**Cloudy**
![](cloudy_example.png)
## Installation
In your terminal, go to your MagicMirror's Module folder:
````
cd ~/MagicMirror/modules
````
Clone this repository:
````
git clone https://github.com/scottcl88/MMM-DynamicWeather.git
````
Configure the module in your `config.js` file.
**Note:** After starting the Mirror, it may take a few seconds to startup.
## Updating
Go to the DynamicWeather module
````
cd ~/MagicMirror/modules/MMM-DynamicWeather
````
Pull latest
````
git pull origin master --allow-unrelated-histories
````
<br><br>
You can also use the NPM package: <https://www.npmjs.com/package/mmm-dynamicweather>
## Using the module
To use this module, add it to the modules array in the `config/config.js` file:
````javascript
{
module: 'MMM-DynamicWeather',
position: 'fullscreen_above',
config: { // See https://github.com/scottcl88/MMM-DynamicWeather for more information.
api_key: "your_key",
locationID: "4140963",
effects: [
{
month: "2",
day: "14",
year: "2021",
images: ["heart1.png", "heart2.png"],
direction: "up"
}
],
}
},
````
## Configuration options
The following properties can be configured:
|Option|Description|
|---|---|
|`alwaysDisplay`|Set this to always display the specified default effect, regardless of weather. Does not work for custom effects; to always display custom effects leave out weatherCode, month, day and year.<br><br>**Options:** `cloudy`, `fog`, `lightning`, `rain-lightning`, `rain`, `sun`, `snow` <br>**Type:** `string`<br>**Default value:** `null`|
|`api_key`|**Required** This is the API key you need to use to request weather data from the OpenWeatherMap site. Details on how to request an API key can be found [here](https://home.openweathermap.org/users/sign_up)<br><br>**Type:** `string`<br>**Default value:** `null`|
|`effectDuration`|The length, in milliseconds, to display the effect. <br><br>**Type:** `number`<br>**Default value:** `120000`|
|`effectDelay`|The length, in milliseconds, to wait to restart the effect. <br><br>**Type:** `number`<br>**Default value:** `60000`|
|`fadeDuration`|The length, in milliseconds, to fade out all effects. <br><br>**Type:** `number`<br>**Default value:** `3000`|
|`hideSnow`|If true, will never display the "snow" effect. <br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`hideSnowman`|If false, will display an animation at the bottom of a snowman being built if the current weather is snow and `hideSnow` is false. The animation lasts for the effectDuration with a 10 second delay.<br><br>**Type:** `boolean`<br>**Default value:** `true`|
|`hideRain`|If true, will never display the "rain" effect. <br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`hideFlower`|If false, will display an animation at the bottom of a flower growing if the current weather is rain and `hideRain` is false. The animation lasts for the effectDuration with a 10 second delay. <br><br>**Type:** `boolean`<br>**Default value:** `true`|
|`hideClouds`|If true, will never display the "cloudy" effect. <br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`hideFog`|If true, will never display the "fog" effect. <br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`hideLightning`|If true, will never display the "lightning" effect. <br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`hideSun`|If true, will never display the "sun" effect. <br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`lightning1Count`|Sets how many times the lightning1.png image will be displayed during the effect duration if current weather is thunderstorm.<br><br>**Type:** `number`<br>**Default value:** `2`|
|`lightning2Count`|Sets how many times the lightning2.png image will be displayed during the effect duration if current weather is thunderstorm.<br><br>**Type:** `number`<br>**Default value:** `3`|
|`locationID`|**Required (or use lat/lon)** The locationID from OpenWeatherMap for your city to get current weather. [Follow steps here to find city ID](https://www.dmopress.com/openweathermap-howto/) <br><br>**Type:** `integer`<br>**Default value:** `0`|
|`lat`|**Required with lon (or use locationID)** This is the latitude of the location you want to get the weather for.<br><br>**Type:** `number`<br>**Default value:** `0.0`|
|`lon`|**Required with lat (or use locationID)** This is the longitude of the location you want to get the weather for.<br><br>**Type:** `number`<br>**Default value:** `0.0`|
|`particleCount`|The number of particles to show for each effect. Higher counts may cause performance issues. This can be overriden in each effect. <br><br>**Type:** `integer`<br>**Default value:** `100`|
|`realisticClouds`|If true, shows more realistic cloud effect. Uses the cloud pictures with varying size and amount based on current weather cloud density.<br><br>**Type:** `boolean`<br>**Default value:** `false`|
|`sequential`|If set, will not display weather and a custom effect at the same time. It will run for effectDuration, wait for effectDelay, and then show the next. Repeats until either the weather changes and/or the effect date/holiday is no longer today. If not set, both weather and effect can be seen together. <br><br>`weather` to see weather first <br> `effect` to see effect first <br> `effect-one` to see effect first but only 1 effect at a time, going in order of the array. <br><br><br>**Options:**`weather`,`effect`,`effect-one`<br>**Type:** `string`<br>**Default value:** `null`|
|`sunImage`|Determines which image to display when sunny.<br><br>**Options:**`sun_center`,`sun_large`,`sun_left`,`sun_right`<br>**Type:** `string`<br>**Default value:** `sun_right`|
|`weatherInterval`|How often the weather is updated.<br><br>**Type:** `integer`<br>**Default value:** `600000 // 10 minutes`|
|`opacity`|Sets the opacity of the module's wrapper. Use a value between `0.1` and `1`. <br><br>**Type:** `number`<br>**Default value:** `1`|
### Effect options
|Option|Description|
|---|---|
|`direction`|How the effect moves across the screen.<br><br>**Options:** `up`, `down`, `right-left`, `left-right`<br>**Type:** `string`<br>**Default value:** `up`|
|`month`|The month (1-12) of the date to display this effect on. Must not set weatherCode or holiday.<br><br>**Type:** `number`<br>**Default value:** `0`|
|`day`|The day of the month (1-31) of the date to display this effect on. Must not set weatherCode or holiday.<br><br>**Type:** `number`<br>**Default value:** `0`|
|`year`|The year (4 digits) of the date to display this effect on. You can leave it out or set to zero to ignore the year and it will just check month and date. If you want to use dates, then you must not set weatherCode or holiday.<br><br>**Type:** `number`<br>**Default value:** `0`|
|`holiday`|Will display the effect on the holiday found at [https://www.timeanddate.com/holidays/us/?hol=43122559](https://www.timeanddate.com/holidays/us/?hol=43122559). Simply copy the "Name" value from that table. <br><br>**Type:** `string`<br>**Default value:** `null`|
|`images`|An array of image files to display at random for this effect. All files need to be in the "images" folder of the MMM-DynamicWeather module folder.<br><br>**Type:** `string[]`<br>**Default value:** `null`|
|`particleCount`|The number of particles to show for the effect. Higher counts may cause performance issues. If this is not set, it will use the `particleCount` from the general configuration. <br><br>**Type:** `integer`<br>**Default value:** `null`|
|`maxSpeed`|The maximum speed, in seconds, for the effect's image to cross the screen. Closer to zero is faster. Each effect particle is randomized between maxSpeed and minSpeed. <br><br>**Type:** `number`<br>**Default value:** `100`|
|`minSpeed`|The minimum speed, in seconds, for the effect's image to cross the screen. Closer to zero is faster. Each effect particle is randomized between maxSpeed and minSpeed. <br><br>**Type:** `number`<br>**Default value:** `50`|
|`recurrence`|Display the effect repeatedly.<br>Yearly - Not a recurrence option, just leave year unset or zero.<br><br>**Options:**`monthly`,`weekly`,`weekdays`,`weekends`<br>**Type:** `string`<br>**Default value:** `null`|
|`size`|The size factor to display the image; larger the number the larger the picture.<br><br>**Type:** `number`<br>**Default value:** `1`|
|`weatherCode`|The effect will be displayed whenever the current weather matches this code. You can find all valid codes [here](https://openweathermap.org/weather-conditions)<br>This does not change the default weather effects, those will still be shown unless the specific weather condition is turned off. <br><br>**Type:** `number`<br>**Default value:** `0`|
|`weatherCodeMin`|Similar to `weatherCode` but will show the effect if the current weather code is greater or equal to this value. <br><br>**Type:** `number`<br>**Default value:** `0`|
|`weatherCodeMax`|Similar to `weatherCode` but will show the effect if the current weather code is less than or equal to this value. <br><br>**Type:** `number`<br>**Default value:** `0`|
+5
View File
@@ -0,0 +1,5 @@
# Security Policy
## Reporting a Vulnerability
Please email scottcl88code@gmail.com when you found a security issue, even when you are not 100% certain that it is actually a security issue. I will try to respond within 48 hours.
Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

+65
View File
@@ -0,0 +1,65 @@
/* Magic Mirror
* Module: MMM-DynamicWeather
*
* By Scott Lewis - https://github.com/scottcl88/MMM-DynamicWeather
* MIT Licensed.
*
* Extension helper module to call external resources
*/
var NodeHelper = require("node_helper");
var request = require("request");
module.exports = NodeHelper.create({
start: function () {},
callApi: function (payload) {
var that = this;
this.url = payload;
var success = false;
console.info("[MMM-DynamicWeather] Getting Weather API data");
request({ url: this.url, method: "GET" }, function (error, response, body) {
var result = JSON.parse(body);
if (error || response.statusCode !== 200) {
console.error("[MMM-DynamicWeather] Failed getting api: ", error, response);
} else {
console.info("[MMM-DynamicWeather] Received successful Weather API data");
success = true;
}
that.sendSocketNotification("API-Received", {
url: that.url,
result: result,
success: success,
});
});
},
callHoliday: function () {
var that = this;
var success = false;
console.info("[MMM-DynamicWeather] Getting Holiday data");
request({ url: "https://www.timeanddate.com/holidays/us/?hol=43122559", method: "GET" }, function (error, response, body) {
if (error || response.statusCode !== 200) {
console.error("[MMM-DynamicWeather] Failed getting holidays: ", error, response);
} else {
console.info("[MMM-DynamicWeather] Received successful Holiday data");
success = true;
}
var result = { holidayBody: body };
that.sendSocketNotification("Holiday-Received", {
url: that.url,
result: result,
success: success,
});
});
},
socketNotificationReceived: function (notification, payload) {
if (notification === "API-Fetch") {
this.callApi(payload);
}
if (notification === "Holiday-Fetch") {
this.callHoliday();
}
},
});
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
ret=$?
else
node "$basedir/../typescript/bin/tsc" "$@"
ret=$?
fi
exit $ret
+17
View File
@@ -0,0 +1,17 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\typescript\bin\tsc" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../typescript/bin/tsc" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../typescript/bin/tsc" $args
$ret=$LASTEXITCODE
}
exit $ret
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
ret=$?
else
node "$basedir/../typescript/bin/tsserver" "$@"
ret=$?
fi
exit $ret
+17
View File
@@ -0,0 +1,17 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\typescript\bin\tsserver" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../typescript/bin/tsserver" $args
$ret=$LASTEXITCODE
}
exit $ret
+480
View File
@@ -0,0 +1,480 @@
TypeScript is authored by:
- 0verk1ll
- Abubaker Bashir
- Adam Freidin
- Adam Postma
- Adi Dahiya
- Aditya Daflapurkar
- Adnan Chowdhury
- Adrian Leonhard
- Adrien Gibrat
- Ahmad Farid
- Ajay Poshak
- Alan Agius
- Alan Pierce
- Alessandro Vergani
- Alex Chugaev
- Alex Eagle
- Alex Khomchenko
- Alex Ryan
- Alexander
- Alexander Kuvaev
- Alexander Rusakov
- Alexander Tarasyuk
- Ali Sabzevari
- Aluan Haddad
- amaksimovich2
- Anatoly Ressin
- Anders Hejlsberg
- Anders Kaseorg
- Andre Sutherland
- Andreas Martin
- Andrej Baran
- Andrew
- Andrew Branch
- Andrew Casey
- Andrew Faulkner
- Andrew Ochsner
- Andrew Stegmaier
- Andrew Z Allen
- Andrey Roenko
- Andrii Dieiev
- András Parditka
- Andy Hanson
- Anil Anar
- Anix
- Anton Khlynovskiy
- Anton Tolmachev
- Anubha Mathur
- AnyhowStep
- Armando Aguirre
- Arnaud Tournier
- Arnav Singh
- Arpad Borsos
- Artem Tyurin
- Arthur Ozga
- Asad Saeeduddin
- Austin Cummings
- Avery Morin
- Aziz Khambati
- Basarat Ali Syed
- @begincalendar
- Ben Duffield
- Ben Lichtman
- Ben Mosher
- Benedikt Meurer
- Benjamin Bock
- Benjamin Lichtman
- Benny Neugebauer
- BigAru
- Bill Ticehurst
- Blaine Bublitz
- Blake Embrey
- @bluelovers
- @bootstraponline
- Bowden Kelly
- Bowden Kenny
- Brad Zacher
- Brandon Banks
- Brandon Bloom
- Brandon Slade
- Brendan Kenny
- Brett Mayen
- Brian Terlson
- Bryan Forbes
- Caitlin Potter
- Caleb Sander
- Cameron Taggart
- @cedvdb
- Charles
- Charles Pierce
- Charly POLY
- Chris Bubernak
- Chris Patterson
- christian
- Christophe Vidal
- Chuck Jazdzewski
- Clay Miller
- Colby Russell
- Colin Snover
- Collins Abitekaniza
- Connor Clark
- Cotton Hou
- csigs
- Cyrus Najmabadi
- Dafrok Zhang
- Dahan Gong
- Daiki Nishikawa
- Dan Corder
- Dan Freeman
- Dan Quirk
- Dan Rollo
- Daniel Gooss
- Daniel Imms
- Daniel Krom
- Daniel Król
- Daniel Lehenbauer
- Daniel Rosenwasser
- David Li
- David Sheldrick
- David Sherret
- David Souther
- David Staheli
- Denis Nedelyaev
- Derek P Sifford
- Dhruv Rajvanshi
- Dick van den Brink
- Diogo Franco (Kovensky)
- Dirk Bäumer
- Dirk Holtwick
- Dmitrijs Minajevs
- Dom Chen
- Donald Pipowitch
- Doug Ilijev
- dreamran43@gmail.com
- @e-cloud
- Ecole Keine
- Eddie Jaoude
- Edward Thomson
- EECOLOR
- Eli Barzilay
- Elizabeth Dinella
- Ely Alamillo
- Eric Grube
- Eric Tsang
- Erik Edrosa
- Erik McClenney
- Esakki Raj
- Ethan Resnick
- Ethan Rubio
- Eugene Timokhov
- Evan Cahill
- Evan Martin
- Evan Sebastian
- ExE Boss
- Eyas Sharaiha
- Fabian Cook
- @falsandtru
- Filipe Silva
- @flowmemo
- Forbes Lindesay
- Francois Hendriks
- Francois Wouts
- Frank Wallis
- František Žiacik
- Frederico Bittencourt
- fullheightcoding
- Gabe Moothart
- Gabriel Isenberg
- Gabriela Araujo Britto
- Gabriela Britto
- gb714us
- Gilad Peleg
- Godfrey Chan
- Gorka Hernández Estomba
- Graeme Wicksted
- Guillaume Salles
- Guy Bedford
- hafiz
- Halasi Tamás
- Hendrik Liebau
- Henry Mercer
- Herrington Darkholme
- Hoang Pham
- Holger Jeromin
- Homa Wong
- Hye Sung Jung
- Iain Monro
- @IdeaHunter
- Igor Novozhilov
- Igor Oleinikov
- Ika
- iliashkolyar
- IllusionMH
- Ingvar Stepanyan
- Ingvar Stepanyan
- Isiah Meadows
- ispedals
- Ivan Enderlin
- Ivo Gabe de Wolff
- Iwata Hidetaka
- Jack Bates
- Jack Williams
- Jake Boone
- Jakub Korzeniowski
- Jakub Młokosiewicz
- James Henry
- James Keane
- James Whitney
- Jan Melcher
- Jason Freeman
- Jason Jarrett
- Jason Killian
- Jason Ramsay
- JBerger
- Jean Pierre
- Jed Mao
- Jeff Wilcox
- Jeffrey Morlan
- Jesse Schalken
- Jesse Trinity
- Jing Ma
- Jiri Tobisek
- Joe Calzaretta
- Joe Chung
- Joel Day
- Joey Watts
- Johannes Rieken
- John Doe
- John Vilk
- Jonathan Bond-Caron
- Jonathan Park
- Jonathan Toland
- Jordan Harband
- Jordi Oliveras Rovira
- Joscha Feth
- Joseph Wunderlich
- Josh Abernathy
- Josh Goldberg
- Josh Kalderimis
- Josh Soref
- Juan Luis Boya García
- Julian Williams
- Justin Bay
- Justin Johansson
- jwbay
- K. Preißer
- Kagami Sascha Rosylight
- Kanchalai Tanglertsampan
- karthikkp
- Kate Miháliková
- Keen Yee Liau
- Keith Mashinter
- Ken Howard
- Kenji Imamula
- Kerem Kat
- Kevin Donnelly
- Kevin Gibbons
- Kevin Lang
- Khải
- Kitson Kelly
- Klaus Meinhardt
- Kris Zyp
- Kyle Kelley
- Kārlis Gaņģis
- laoxiong
- Leon Aves
- Limon Monte
- Lorant Pinter
- Lucien Greathouse
- Luka Hartwig
- Lukas Elmer
- M.Yoshimura
- Maarten Sijm
- Magnus Hiie
- Magnus Kulke
- Manish Bansal
- Manish Giri
- Marcus Noble
- Marin Marinov
- Marius Schulz
- Markus Johnsson
- Markus Wolf
- Martin
- Martin Hiller
- Martin Johns
- Martin Probst
- Martin Vseticka
- Martyn Janes
- Masahiro Wakame
- Mateusz Burzyński
- Matt Bierner
- Matt McCutchen
- Matt Mitchell
- Matthew Aynalem
- Matthew Miller
- Mattias Buelens
- Max Heiber
- Maxwell Paul Brickner
- @meyer
- Micah Zoltu
- @micbou
- Michael
- Michael Crane
- Michael Henderson
- Michael Tamm
- Michael Tang
- Michal Przybys
- Mike Busyrev
- Mike Morearty
- Milosz Piechocki
- Mine Starks
- Minh Nguyen
- Mohamed Hegazy
- Mohsen Azimi
- Mukesh Prasad
- Myles Megyesi
- Nathan Day
- Nathan Fenner
- Nathan Shively-Sanders
- Nathan Yee
- ncoley
- Nicholas Yang
- Nicu Micleușanu
- @nieltg
- Nima Zahedi
- Noah Chen
- Noel Varanda
- Noel Yoo
- Noj Vek
- nrcoley
- Nuno Arruda
- Oleg Mihailik
- Oleksandr Chekhovskyi
- Omer Sheikh
- Orta Therox
- Orta Therox
- Oskar Grunning
- Oskar Segersva¨rd
- Oussama Ben Brahim
- Ozair Patel
- Patrick McCartney
- Patrick Zhong
- Paul Koerbitz
- Paul van Brenk
- @pcbro
- Pedro Maltez
- Pete Bacon Darwin
- Peter Burns
- Peter Šándor
- Philip Pesca
- Philippe Voinov
- Pi Lanningham
- Piero Cangianiello
- Pierre-Antoine Mills
- @piloopin
- Pranav Senthilnathan
- Prateek Goel
- Prateek Nayak
- Prayag Verma
- Priyantha Lankapura
- @progre
- Punya Biswal
- r7kamura
- Rado Kirov
- Raj Dosanjh
- rChaser53
- Reiner Dolp
- Remo H. Jansen
- @rflorian
- Rhys van der Waerden
- @rhysd
- Ricardo N Feliciano
- Richard Karmazín
- Richard Knoll
- Roger Spratley
- Ron Buckton
- Rostislav Galimsky
- Rowan Wyborn
- rpgeeganage
- Ruwan Pradeep Geeganage
- Ryan Cavanaugh
- Ryan Clarke
- Ryohei Ikegami
- Salisbury, Tom
- Sam Bostock
- Sam Drugan
- Sam El-Husseini
- Sam Lanning
- Sangmin Lee
- Sanket Mishra
- Sarangan Rajamanickam
- Sasha Joseph
- Sean Barag
- Sergey Rubanov
- Sergey Shandar
- Sergey Tychinin
- Sergii Bezliudnyi
- Sergio Baidon
- Sharon Rolel
- Sheetal Nandi
- Shengping Zhong
- Sheon Han
- Shyyko Serhiy
- Siddharth Singh
- sisisin
- Slawomir Sadziak
- Solal Pirelli
- Soo Jae Hwang
- Stan Thomas
- Stanislav Iliev
- Stanislav Sysoev
- Stas Vilchik
- Stephan Ginthör
- Steve Lucco
- @styfle
- Sudheesh Singanamalla
- Suhas
- Suhas Deshpande
- superkd37
- Sébastien Arod
- @T18970237136
- @t_
- Tan Li Hau
- Tapan Prakash
- Taras Mankovski
- Tarik Ozket
- Tetsuharu Ohzeki
- The Gitter Badger
- Thomas den Hollander
- Thorsten Ball
- Tien Hoanhtien
- Tim Lancina
- Tim Perry
- Tim Schaub
- Tim Suchanek
- Tim Viiding-Spader
- Tingan Ho
- Titian Cernicova-Dragomir
- tkondo
- Todd Thomson
- togru
- Tom J
- Torben Fitschen
- Toxyxer
- @TravCav
- Troy Tae
- TruongSinh Tran-Nguyen
- Tycho Grouwstra
- uhyo
- Vadi Taslim
- Vakhurin Sergey
- Valera Rozuvan
- Vilic Vane
- Vimal Raghubir
- Vladimir Kurchatkin
- Vladimir Matveev
- Vyacheslav Pukhanov
- Wenlu Wang
- Wes Souza
- Wesley Wigham
- William Orr
- Wilson Hobbs
- xiaofa
- xl1
- Yacine Hmito
- Yang Cao
- York Yao
- @yortus
- Yoshiki Shibukawa
- Yuichi Nukiyama
- Yuval Greenfield
- Yuya Tanaka
- Z
- Zeeshan Ahmed
- Zev Spitz
- Zhengbo Li
- Zixiang Li
- @Zzzen
- 阿卡琳
@@ -0,0 +1 @@
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
+15
View File
@@ -0,0 +1,15 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
+55
View File
@@ -0,0 +1,55 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
+104
View File
@@ -0,0 +1,104 @@
# TypeScript
[![Build Status](https://travis-ci.org/microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/microsoft/TypeScript)
[![Devops Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://dev.azure.com/typescript/TypeScript/_build?definitionId=7)
[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
[![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript)
[TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescript).
Find others who are using TypeScript at [our community page](https://www.typescriptlang.org/community/).
## Installing
For the latest stable version:
```bash
npm install -g typescript
```
For our nightly builds:
```bash
npm install -g typescript@next
```
## Contribute
There are many ways to [contribute](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
* [Submit bugs](https://github.com/microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
* Review the [source code changes](https://github.com/microsoft/TypeScript/pulls).
* Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript).
* Help each other in the [TypeScript Community Discord](https://discord.gg/typescript).
* Join the [#typescript](https://twitter.com/search?q=%23TypeScript) discussion on Twitter.
* [Contribute bug fixes](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md).
* Read the archived language specification ([docx](https://github.com/microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification%20-%20ARCHIVED.docx?raw=true),
[pdf](https://github.com/microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification%20-%20ARCHIVED.pdf?raw=true), [md](https://github.com/microsoft/TypeScript/blob/master/doc/spec-archived.md)).
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see
the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com)
with any additional questions or comments.
## Documentation
* [TypeScript in 5 minutes](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html)
* [Programming handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html)
* [Homepage](https://www.typescriptlang.org/)
## Building
In order to build the TypeScript compiler, ensure that you have [Git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/) installed.
Clone a copy of the repo:
```bash
git clone https://github.com/microsoft/TypeScript.git
```
Change to the TypeScript directory:
```bash
cd TypeScript
```
Install [Gulp](https://gulpjs.com/) tools and dev dependencies:
```bash
npm install -g gulp
npm ci
```
Use one of the following to build and test:
```
gulp local # Build the compiler into built/local.
gulp clean # Delete the built compiler.
gulp LKG # Replace the last known good with the built one.
# Bootstrapping step to be executed when the built compiler reaches a stable state.
gulp tests # Build the test infrastructure using the built compiler.
gulp runtests # Run tests using the built compiler and test infrastructure.
# You can override the specific suite runner used or specify a test for this command.
# Use --tests=<testPath> for a specific test and/or --runner=<runnerName> for a specific suite.
# Valid runners include conformance, compiler, fourslash, project, user, and docker
# The user and docker runners are extended test suite runners - the user runner
# works on disk in the tests/cases/user directory, while the docker runner works in containers.
# You'll need to have the docker executable in your system path for the docker runner to work.
gulp runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system
# core count by default. Use --workers=<number> to adjust this.
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
gulp lint # Runs eslint on the TypeScript source.
gulp help # List the above commands.
```
## Usage
```bash
node built/local/tsc.js hello.ts
```
## Roadmap
For details on our planned features and future direction please refer to our [roadmap](https://github.com/microsoft/TypeScript/wiki/Roadmap).
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../lib/tsc.js')
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../lib/tsserver.js')
+5
View File
@@ -0,0 +1,5 @@
# Read This!
**These files are not meant to be edited by hand.**
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
Running `gulp LKG` will then appropriately update the files in this directory.
@@ -0,0 +1,67 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
"use strict";
var fs = require("fs");
function pipeExists(name) {
return fs.existsSync(name);
}
function createCancellationToken(args) {
var cancellationPipeName;
for (var i = 0; i < args.length - 1; i++) {
if (args[i] === "--cancellationPipeName") {
cancellationPipeName = args[i + 1];
break;
}
}
if (!cancellationPipeName) {
return {
isCancellationRequested: function () { return false; },
setRequest: function (_requestId) { return void 0; },
resetRequest: function (_requestId) { return void 0; }
};
}
if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") {
var namePrefix_1 = cancellationPipeName.slice(0, -1);
if (namePrefix_1.length === 0 || namePrefix_1.indexOf("*") >= 0) {
throw new Error("Invalid name for template cancellation pipe: it should have length greater than 2 characters and contain only one '*'.");
}
var perRequestPipeName_1;
var currentRequestId_1;
return {
isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); },
setRequest: function (requestId) {
currentRequestId_1 = requestId;
perRequestPipeName_1 = namePrefix_1 + requestId;
},
resetRequest: function (requestId) {
if (currentRequestId_1 !== requestId) {
throw new Error("Mismatched request id, expected " + currentRequestId_1 + ", actual " + requestId);
}
perRequestPipeName_1 = undefined;
}
};
}
else {
return {
isCancellationRequested: function () { return pipeExists(cancellationPipeName); },
setRequest: function (_requestId) { return void 0; },
resetRequest: function (_requestId) { return void 0; }
};
}
}
module.exports = createCancellationToken;
//# sourceMappingURL=cancellationToken.js.map
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es5" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,351 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// DOM Iterable APIs
/////////////////////////////
interface AudioParam {
setValueCurveAtTime(values: Iterable<number>, startTime: number, duration: number): AudioParam;
}
interface AudioParamMap extends ReadonlyMap<string, AudioParam> {
}
interface BaseAudioContext {
createIIRFilter(feedforward: Iterable<number>, feedback: Iterable<number>): IIRFilterNode;
createPeriodicWave(real: Iterable<number>, imag: Iterable<number>, constraints?: PeriodicWaveConstraints): PeriodicWave;
}
interface CSSRuleList {
[Symbol.iterator](): IterableIterator<CSSRule>;
}
interface CSSStyleDeclaration {
[Symbol.iterator](): IterableIterator<string>;
}
interface Cache {
addAll(requests: Iterable<RequestInfo>): Promise<void>;
}
interface CanvasPathDrawingStyles {
setLineDash(segments: Iterable<number>): void;
}
interface ClientRectList {
[Symbol.iterator](): IterableIterator<ClientRect>;
}
interface DOMRectList {
[Symbol.iterator](): IterableIterator<DOMRect>;
}
interface DOMStringList {
[Symbol.iterator](): IterableIterator<string>;
}
interface DOMTokenList {
[Symbol.iterator](): IterableIterator<string>;
entries(): IterableIterator<[number, string]>;
keys(): IterableIterator<number>;
values(): IterableIterator<string>;
}
interface DataTransferItemList {
[Symbol.iterator](): IterableIterator<DataTransferItem>;
}
interface FileList {
[Symbol.iterator](): IterableIterator<File>;
}
interface FormData {
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
/**
* Returns an array of key, value pairs for every entry in the list.
*/
entries(): IterableIterator<[string, FormDataEntryValue]>;
/**
* Returns a list of keys in the list.
*/
keys(): IterableIterator<string>;
/**
* Returns a list of values in the list.
*/
values(): IterableIterator<FormDataEntryValue>;
}
interface HTMLAllCollection {
[Symbol.iterator](): IterableIterator<Element>;
}
interface HTMLCollectionBase {
[Symbol.iterator](): IterableIterator<Element>;
}
interface HTMLCollectionOf<T extends Element> {
[Symbol.iterator](): IterableIterator<T>;
}
interface HTMLFormElement {
[Symbol.iterator](): IterableIterator<Element>;
}
interface HTMLSelectElement {
[Symbol.iterator](): IterableIterator<Element>;
}
interface Headers {
[Symbol.iterator](): IterableIterator<[string, string]>;
/**
* Returns an iterator allowing to go through all key/value pairs contained in this object.
*/
entries(): IterableIterator<[string, string]>;
/**
* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.
*/
keys(): IterableIterator<string>;
/**
* Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
*/
values(): IterableIterator<string>;
}
interface IDBDatabase {
/**
* Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names.
*/
transaction(storeNames: string | Iterable<string>, mode?: IDBTransactionMode): IDBTransaction;
}
interface IDBObjectStore {
/**
* Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.
*
* Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
*/
createIndex(name: string, keyPath: string | Iterable<string>, options?: IDBIndexParameters): IDBIndex;
}
interface MediaKeyStatusMap {
[Symbol.iterator](): IterableIterator<[BufferSource, MediaKeyStatus]>;
entries(): IterableIterator<[BufferSource, MediaKeyStatus]>;
keys(): IterableIterator<BufferSource>;
values(): IterableIterator<MediaKeyStatus>;
}
interface MediaList {
[Symbol.iterator](): IterableIterator<string>;
}
interface MimeTypeArray {
[Symbol.iterator](): IterableIterator<MimeType>;
}
interface NamedNodeMap {
[Symbol.iterator](): IterableIterator<Attr>;
}
interface Navigator {
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: Iterable<MediaKeySystemConfiguration>): Promise<MediaKeySystemAccess>;
}
interface NodeList {
[Symbol.iterator](): IterableIterator<Node>;
/**
* Returns an array of key, value pairs for every entry in the list.
*/
entries(): IterableIterator<[number, Node]>;
/**
* Returns an list of keys in the list.
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the list.
*/
values(): IterableIterator<Node>;
}
interface NodeListOf<TNode extends Node> {
[Symbol.iterator](): IterableIterator<TNode>;
/**
* Returns an array of key, value pairs for every entry in the list.
*/
entries(): IterableIterator<[number, TNode]>;
/**
* Returns an list of keys in the list.
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the list.
*/
values(): IterableIterator<TNode>;
}
interface Plugin {
[Symbol.iterator](): IterableIterator<MimeType>;
}
interface PluginArray {
[Symbol.iterator](): IterableIterator<Plugin>;
}
interface RTCRtpTransceiver {
setCodecPreferences(codecs: Iterable<RTCRtpCodecCapability>): void;
}
interface RTCStatsReport extends ReadonlyMap<string, any> {
}
interface SVGLengthList {
[Symbol.iterator](): IterableIterator<SVGLength>;
}
interface SVGNumberList {
[Symbol.iterator](): IterableIterator<SVGNumber>;
}
interface SVGPointList {
[Symbol.iterator](): IterableIterator<DOMPoint>;
}
interface SVGStringList {
[Symbol.iterator](): IterableIterator<string>;
}
interface SourceBufferList {
[Symbol.iterator](): IterableIterator<SourceBuffer>;
}
interface SpeechGrammarList {
[Symbol.iterator](): IterableIterator<SpeechGrammar>;
}
interface SpeechRecognitionResult {
[Symbol.iterator](): IterableIterator<SpeechRecognitionAlternative>;
}
interface SpeechRecognitionResultList {
[Symbol.iterator](): IterableIterator<SpeechRecognitionResult>;
}
interface StyleSheetList {
[Symbol.iterator](): IterableIterator<CSSStyleSheet>;
}
interface TextTrackCueList {
[Symbol.iterator](): IterableIterator<TextTrackCue>;
}
interface TextTrackList {
[Symbol.iterator](): IterableIterator<TextTrack>;
}
interface TouchList {
[Symbol.iterator](): IterableIterator<Touch>;
}
interface URLSearchParams {
[Symbol.iterator](): IterableIterator<[string, string]>;
/**
* Returns an array of key, value pairs for every entry in the search params.
*/
entries(): IterableIterator<[string, string]>;
/**
* Returns a list of keys in the search params.
*/
keys(): IterableIterator<string>;
/**
* Returns a list of values in the search params.
*/
values(): IterableIterator<string>;
}
interface VRDisplay {
requestPresent(layers: Iterable<VRLayer>): Promise<void>;
}
interface WEBGL_draw_buffers {
drawBuffersWEBGL(buffers: Iterable<GLenum>): void;
}
interface WebAuthentication {
makeCredential(accountInformation: Account, cryptoParameters: Iterable<ScopedCredentialParameters>, attestationChallenge: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | null, options?: ScopedCredentialOptions): Promise<ScopedCredentialInfo>;
}
interface WebGL2RenderingContextBase {
clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLfloat>, srcOffset?: GLuint): void;
clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLint>, srcOffset?: GLuint): void;
clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLuint>, srcOffset?: GLuint): void;
drawBuffers(buffers: Iterable<GLenum>): void;
getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable<GLuint>, pname: GLenum): any;
getUniformIndices(program: WebGLProgram, uniformNames: Iterable<string>): Iterable<GLuint> | null;
invalidateFramebuffer(target: GLenum, attachments: Iterable<GLenum>): void;
invalidateSubFramebuffer(target: GLenum, attachments: Iterable<GLenum>, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void;
transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable<string>, bufferMode: GLenum): void;
uniform1uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform2uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform3uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform4uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix2x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix2x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix3x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
vertexAttribI4iv(index: GLuint, values: Iterable<GLint>): void;
vertexAttribI4uiv(index: GLuint, values: Iterable<GLuint>): void;
}
interface WebGL2RenderingContextOverloads {
uniform1fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform1iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform2fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform2iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform3fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform3iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform4fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniform4iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: GLuint, srcLength?: GLuint): void;
}
interface WebGLRenderingContextBase {
vertexAttrib1fv(index: GLuint, values: Iterable<GLfloat>): void;
vertexAttrib2fv(index: GLuint, values: Iterable<GLfloat>): void;
vertexAttrib3fv(index: GLuint, values: Iterable<GLfloat>): void;
vertexAttrib4fv(index: GLuint, values: Iterable<GLfloat>): void;
}
interface WebGLRenderingContextOverloads {
uniform1fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
uniform1iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
uniform2fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
uniform2iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
uniform3fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
uniform3iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
uniform4fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
uniform4iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
}
@@ -0,0 +1,89 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value: V): this;
readonly size: number;
}
interface MapConstructor {
new(): Map<any, any>;
new<K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
readonly prototype: Map<any, any>;
}
declare var Map: MapConstructor;
interface ReadonlyMap<K, V> {
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
get(key: K): V | undefined;
has(key: K): boolean;
readonly size: number;
}
interface WeakMap<K extends object, V> {
delete(key: K): boolean;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value: V): this;
}
interface WeakMapConstructor {
new <K extends object = object, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
readonly prototype: WeakMap<object, any>;
}
declare var WeakMap: WeakMapConstructor;
interface Set<T> {
add(value: T): this;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
readonly size: number;
}
interface SetConstructor {
new <T = any>(values?: readonly T[] | null): Set<T>;
readonly prototype: Set<any>;
}
declare var Set: SetConstructor;
interface ReadonlySet<T> {
forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
has(value: T): boolean;
readonly size: number;
}
interface WeakSet<T extends object> {
add(value: T): this;
delete(value: T): boolean;
has(value: T): boolean;
}
interface WeakSetConstructor {
new <T extends object = object>(values?: readonly T[] | null): WeakSet<T>;
readonly prototype: WeakSet<object>;
}
declare var WeakSet: WeakSetConstructor;
@@ -0,0 +1,517 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Array<T> {
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: T, start?: number, end?: number): this;
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): this;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): T[];
/**
* Creates an array from an iterable object.
* @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of<T>(...items: T[]): T[];
}
interface DateConstructor {
new (value: number | string | Date): Date;
}
interface Function {
/**
* Returns the name of the function. Function names are read-only and can not be changed.
*/
readonly name: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
* @param x A numeric expression.
*/
clz32(x: number): number;
/**
* Returns the result of 32-bit multiplication of two numbers.
* @param x First number
* @param y Second number
*/
imul(x: number, y: number): number;
/**
* Returns the sign of the x, indicating whether x is positive, negative or zero.
* @param x The numeric expression to test
*/
sign(x: number): number;
/**
* Returns the base 10 logarithm of a number.
* @param x A numeric expression.
*/
log10(x: number): number;
/**
* Returns the base 2 logarithm of a number.
* @param x A numeric expression.
*/
log2(x: number): number;
/**
* Returns the natural logarithm of 1 + x.
* @param x A numeric expression.
*/
log1p(x: number): number;
/**
* Returns the result of (e^x - 1), which is an implementation-dependent approximation to
* subtracting 1 from the exponential function of x (e raised to the power of x, where e
* is the base of the natural logarithms).
* @param x A numeric expression.
*/
expm1(x: number): number;
/**
* Returns the hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cosh(x: number): number;
/**
* Returns the hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sinh(x: number): number;
/**
* Returns the hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tanh(x: number): number;
/**
* Returns the inverse hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
acosh(x: number): number;
/**
* Returns the inverse hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
asinh(x: number): number;
/**
* Returns the inverse hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
atanh(x: number): number;
/**
* Returns the square root of the sum of squares of its arguments.
* @param values Values to compute the square root for.
* If no arguments are passed, the result is +0.
* If there is only one argument, the result is the absolute value.
* If any argument is +Infinity or -Infinity, the result is +Infinity.
* If any argument is NaN, the result is NaN.
* If all arguments are either +0 or −0, the result is +0.
*/
hypot(...values: number[]): number;
/**
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
* If x is already an integer, the result is x.
* @param x A numeric expression.
*/
trunc(x: number): number;
/**
* Returns the nearest single precision float representation of a number.
* @param x A numeric expression.
*/
fround(x: number): number;
/**
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number;
}
interface NumberConstructor {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
* 2.2204460492503130808472633361816 x 10‍−‍16.
*/
readonly EPSILON: number;
/**
* Returns true if passed value is finite.
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(number: unknown): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(number: unknown): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(number: unknown): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(number: unknown): boolean;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
*/
readonly MAX_SAFE_INTEGER: number;
/**
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
*/
readonly MIN_SAFE_INTEGER: number;
/**
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
parseFloat(string: string): number;
/**
* Converts A string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
parseInt(string: string, radix?: number): number;
}
interface ObjectConstructor {
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source The source object from which to copy properties.
*/
assign<T, U>(target: T, source: U): T & U;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
*/
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
* @param source3 The third source object from which to copy properties.
*/
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
assign(target: object, ...sources: any[]): any;
/**
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns the names of the enumerable string properties and methods of an object.
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
keys(o: {}): string[];
/**
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
is(value1: any, value2: any): boolean;
/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
*/
setPrototypeOf(o: any, proto: object | null): any;
}
interface ReadonlyArray<T> {
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find<S extends T>(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
}
interface RegExp {
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
readonly flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
*/
readonly sticky: boolean;
/**
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
* expression. Default is false. Read-only.
*/
readonly unicode: boolean;
}
interface RegExpConstructor {
new (pattern: RegExp | string, flags?: string): RegExp;
(pattern: RegExp | string, flags?: string): RegExp;
}
interface String {
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
* value of the UTF-16 encoded code point starting at the string element at position pos in
* the String resulting from converting this object to a String.
* If there is no element at that position, the result is undefined.
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
*/
codePointAt(pos: number): number | undefined;
/**
* Returns true if searchString appears as a substring of the result of converting this
* object to a String, at one or more positions that are
* greater than or equal to position; otherwise, returns false.
* @param searchString search string
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
*/
includes(searchString: string, position?: number): boolean;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* endPosition – length(this). Otherwise returns false.
*/
endsWith(searchString: string, endPosition?: number): boolean;
/**
* Returns the String value result of normalizing the string into the normalization form
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
* is "NFC"
*/
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
/**
* Returns the String value result of normalizing the string into the normalization form
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
* is "NFC"
*/
normalize(form?: string): string;
/**
* Returns a String value that is made from count copies appended together. If count is 0,
* the empty string is returned.
* @param count number of copies to append
*/
repeat(count: number): string;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* position. Otherwise returns false.
*/
startsWith(searchString: string, position?: number): boolean;
/**
* Returns an `<a>` HTML anchor element and sets the name attribute to the text value
* @param name
*/
anchor(name: string): string;
/** Returns a `<big>` HTML element */
big(): string;
/** Returns a `<blink>` HTML element */
blink(): string;
/** Returns a `<b>` HTML element */
bold(): string;
/** Returns a `<tt>` HTML element */
fixed(): string;
/** Returns a `<font>` HTML element and sets the color attribute value */
fontcolor(color: string): string;
/** Returns a `<font>` HTML element and sets the size attribute value */
fontsize(size: number): string;
/** Returns a `<font>` HTML element and sets the size attribute value */
fontsize(size: string): string;
/** Returns an `<i>` HTML element */
italics(): string;
/** Returns an `<a>` HTML element and sets the href attribute value */
link(url: string): string;
/** Returns a `<small>` HTML element */
small(): string;
/** Returns a `<strike>` HTML element */
strike(): string;
/** Returns a `<sub>` HTML element */
sub(): string;
/** Returns a `<sup>` HTML element */
sup(): string;
}
interface StringConstructor {
/**
* Return the String value whose elements are, in order, the elements in the List elements.
* If length is 0, the empty string is returned.
*/
fromCodePoint(...codePoints: number[]): string;
/**
* String.raw is intended for use as a tag function of a Tagged Template String. When called
* as such the first argument will be a well formed template call site object and the rest
* parameter will contain the substitution values.
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
+30
View File
@@ -0,0 +1,30 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es5" />
/// <reference lib="es2015.core" />
/// <reference lib="es2015.collection" />
/// <reference lib="es2015.iterable" />
/// <reference lib="es2015.generator" />
/// <reference lib="es2015.promise" />
/// <reference lib="es2015.proxy" />
/// <reference lib="es2015.reflect" />
/// <reference lib="es2015.symbol" />
/// <reference lib="es2015.symbol.wellknown" />
@@ -0,0 +1,79 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.iterable" />
interface Generator<T = unknown, TReturn = any, TNext = unknown> extends Iterator<T, TReturn, TNext> {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
return(value: TReturn): IteratorResult<T, TReturn>;
throw(e: any): IteratorResult<T, TReturn>;
[Symbol.iterator](): Generator<T, TReturn, TNext>;
}
interface GeneratorFunction {
/**
* Creates a new Generator object.
* @param args A list of arguments the function accepts.
*/
new (...args: any[]): Generator;
/**
* Creates a new Generator object.
* @param args A list of arguments the function accepts.
*/
(...args: any[]): Generator;
/**
* The length of the arguments.
*/
readonly length: number;
/**
* Returns the name of the function.
*/
readonly name: string;
/**
* A reference to the prototype.
*/
readonly prototype: Generator;
}
interface GeneratorFunctionConstructor {
/**
* Creates a new Generator function.
* @param args A list of arguments the function accepts.
*/
new (...args: string[]): GeneratorFunction;
/**
* Creates a new Generator function.
* @param args A list of arguments the function accepts.
*/
(...args: string[]): GeneratorFunction;
/**
* The length of the arguments.
*/
readonly length: number;
/**
* Returns the name of the function.
*/
readonly name: string;
/**
* A reference to the prototype.
*/
readonly prototype: GeneratorFunction;
}
@@ -0,0 +1,505 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.symbol" />
interface SymbolConstructor {
/**
* A method that returns the default iterator for an object. Called by the semantics of the
* for-of statement.
*/
readonly iterator: symbol;
}
interface IteratorYieldResult<TYield> {
done?: false;
value: TYield;
}
interface IteratorReturnResult<TReturn> {
done: true;
value: TReturn;
}
type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
interface Iterator<T, TReturn = any, TNext = undefined> {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
return?(value?: TReturn): IteratorResult<T, TReturn>;
throw?(e?: any): IteratorResult<T, TReturn>;
}
interface Iterable<T> {
[Symbol.iterator](): Iterator<T>;
}
interface IterableIterator<T> extends Iterator<T> {
[Symbol.iterator](): IterableIterator<T>;
}
interface Array<T> {
/** Iterator */
[Symbol.iterator](): IterableIterator<T>;
/**
* Returns an iterable of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, T]>;
/**
* Returns an iterable of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an iterable of values in the array
*/
values(): IterableIterator<T>;
}
interface ArrayConstructor {
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
}
interface ReadonlyArray<T> {
/** Iterator of values in the array. */
[Symbol.iterator](): IterableIterator<T>;
/**
* Returns an iterable of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, T]>;
/**
* Returns an iterable of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an iterable of values in the array
*/
values(): IterableIterator<T>;
}
interface IArguments {
/** Iterator */
[Symbol.iterator](): IterableIterator<any>;
}
interface Map<K, V> {
/** Returns an iterable of entries in the map. */
[Symbol.iterator](): IterableIterator<[K, V]>;
/**
* Returns an iterable of key, value pairs for every entry in the map.
*/
entries(): IterableIterator<[K, V]>;
/**
* Returns an iterable of keys in the map
*/
keys(): IterableIterator<K>;
/**
* Returns an iterable of values in the map
*/
values(): IterableIterator<V>;
}
interface ReadonlyMap<K, V> {
/** Returns an iterable of entries in the map. */
[Symbol.iterator](): IterableIterator<[K, V]>;
/**
* Returns an iterable of key, value pairs for every entry in the map.
*/
entries(): IterableIterator<[K, V]>;
/**
* Returns an iterable of keys in the map
*/
keys(): IterableIterator<K>;
/**
* Returns an iterable of values in the map
*/
values(): IterableIterator<V>;
}
interface MapConstructor {
new <K, V>(iterable: Iterable<readonly [K, V]>): Map<K, V>;
}
interface WeakMap<K extends object, V> { }
interface WeakMapConstructor {
new <K extends object, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
}
interface Set<T> {
/** Iterates over values in the set. */
[Symbol.iterator](): IterableIterator<T>;
/**
* Returns an iterable of [v,v] pairs for every value `v` in the set.
*/
entries(): IterableIterator<[T, T]>;
/**
* Despite its name, returns an iterable of the values in the set.
*/
keys(): IterableIterator<T>;
/**
* Returns an iterable of values in the set.
*/
values(): IterableIterator<T>;
}
interface ReadonlySet<T> {
/** Iterates over values in the set. */
[Symbol.iterator](): IterableIterator<T>;
/**
* Returns an iterable of [v,v] pairs for every value `v` in the set.
*/
entries(): IterableIterator<[T, T]>;
/**
* Despite its name, returns an iterable of the values in the set.
*/
keys(): IterableIterator<T>;
/**
* Returns an iterable of values in the set.
*/
values(): IterableIterator<T>;
}
interface SetConstructor {
new <T>(iterable?: Iterable<T> | null): Set<T>;
}
interface WeakSet<T extends object> { }
interface WeakSetConstructor {
new <T extends object = object>(iterable: Iterable<T>): WeakSet<T>;
}
interface Promise<T> { }
interface PromiseConstructor {
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An iterable of Promises.
* @returns A new Promise.
*/
all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An iterable of Promises.
* @returns A new Promise.
*/
race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An iterable of Promises.
* @returns A new Promise.
*/
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>;
}
interface String {
/** Iterator */
[Symbol.iterator](): IterableIterator<string>;
}
interface Int8Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Int8ArrayConstructor {
new (elements: Iterable<number>): Int8Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
}
interface Uint8Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Uint8ArrayConstructor {
new (elements: Iterable<number>): Uint8Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
}
interface Uint8ClampedArray {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Uint8ClampedArrayConstructor {
new (elements: Iterable<number>): Uint8ClampedArray;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
}
interface Int16Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Int16ArrayConstructor {
new (elements: Iterable<number>): Int16Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
}
interface Uint16Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Uint16ArrayConstructor {
new (elements: Iterable<number>): Uint16Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
}
interface Int32Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Int32ArrayConstructor {
new (elements: Iterable<number>): Int32Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
}
interface Uint32Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Uint32ArrayConstructor {
new (elements: Iterable<number>): Uint32Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
}
interface Float32Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Float32ArrayConstructor {
new (elements: Iterable<number>): Float32Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
}
interface Float64Array {
[Symbol.iterator](): IterableIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
}
interface Float64ArrayConstructor {
new (elements: Iterable<number>): Float64Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
}
@@ -0,0 +1,150 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface PromiseConstructor {
/**
* A reference to the prototype.
*/
readonly prototype: Promise<any>;
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used to resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4, T5, T6, T7>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4, T5, T6>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4, T5>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
// see: lib.es2015.iterable.d.ts
// all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: readonly T[]): Promise<T extends PromiseLike<infer U> ? U : T>;
// see: lib.es2015.iterable.d.ts
// race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T = never>(reason?: any): Promise<T>;
/**
* Creates a new resolved promise.
* @returns A resolved promise.
*/
resolve(): Promise<void>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
}
declare var Promise: PromiseConstructor;
@@ -0,0 +1,41 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface ProxyHandler<T extends object> {
getPrototypeOf? (target: T): object | null;
setPrototypeOf? (target: T, v: any): boolean;
isExtensible? (target: T): boolean;
preventExtensions? (target: T): boolean;
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined;
has? (target: T, p: PropertyKey): boolean;
get? (target: T, p: PropertyKey, receiver: any): any;
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
deleteProperty? (target: T, p: PropertyKey): boolean;
defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean;
ownKeys? (target: T): PropertyKey[];
apply? (target: T, thisArg: any, argArray?: any): any;
construct? (target: T, argArray: any, newTarget?: any): object;
}
interface ProxyConstructor {
revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T extends object>(target: T, handler: ProxyHandler<T>): T;
}
declare var Proxy: ProxyConstructor;
@@ -0,0 +1,35 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare namespace Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
function get(target: object, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined;
function getPrototypeOf(target: object): object;
function has(target: object, propertyKey: PropertyKey): boolean;
function isExtensible(target: object): boolean;
function ownKeys(target: object): PropertyKey[];
function preventExtensions(target: object): boolean;
function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
function setPrototypeOf(target: object, proto: any): boolean;
}
@@ -0,0 +1,48 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface SymbolConstructor {
/**
* A reference to the prototype.
*/
readonly prototype: Symbol;
/**
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string | number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: symbol): string | undefined;
}
declare var Symbol: SymbolConstructor;
@@ -0,0 +1,324 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.symbol" />
interface SymbolConstructor {
/**
* A method that determines if a constructor object recognizes an object as one of the
* constructor’s instances. Called by the semantics of the instanceof operator.
*/
readonly hasInstance: symbol;
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
readonly isConcatSpreadable: symbol;
/**
* A regular expression method that matches the regular expression against a string. Called
* by the String.prototype.match method.
*/
readonly match: symbol;
/**
* A regular expression method that replaces matched substrings of a string. Called by the
* String.prototype.replace method.
*/
readonly replace: symbol;
/**
* A regular expression method that returns the index within a string that matches the
* regular expression. Called by the String.prototype.search method.
*/
readonly search: symbol;
/**
* A function valued property that is the constructor function that is used to create
* derived objects.
*/
readonly species: symbol;
/**
* A regular expression method that splits a string at the indices that match the regular
* expression. Called by the String.prototype.split method.
*/
readonly split: symbol;
/**
* A method that converts an object to a corresponding primitive value.
* Called by the ToPrimitive abstract operation.
*/
readonly toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
readonly toStringTag: symbol;
/**
* An Object whose own property names are property names that are excluded from the 'with'
* environment bindings of the associated objects.
*/
readonly unscopables: symbol;
}
interface Symbol {
/**
* Converts a Symbol object to a symbol.
*/
[Symbol.toPrimitive](hint: string): symbol;
readonly [Symbol.toStringTag]: string;
}
interface Array<T> {
/**
* Returns an object whose properties have the value 'true'
* when they will be absent when used in a 'with' statement.
*/
[Symbol.unscopables](): {
copyWithin: boolean;
entries: boolean;
fill: boolean;
find: boolean;
findIndex: boolean;
keys: boolean;
values: boolean;
};
}
interface Date {
/**
* Converts a Date object to a string.
*/
[Symbol.toPrimitive](hint: "default"): string;
/**
* Converts a Date object to a string.
*/
[Symbol.toPrimitive](hint: "string"): string;
/**
* Converts a Date object to a number.
*/
[Symbol.toPrimitive](hint: "number"): number;
/**
* Converts a Date object to a string or number.
*
* @param hint The strings "number", "string", or "default" to specify what primitive to return.
*
* @throws {TypeError} If 'hint' was given something other than "number", "string", or "default".
* @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default".
*/
[Symbol.toPrimitive](hint: string): string | number;
}
interface Map<K, V> {
readonly [Symbol.toStringTag]: string;
}
interface WeakMap<K extends object, V> {
readonly [Symbol.toStringTag]: string;
}
interface Set<T> {
readonly [Symbol.toStringTag]: string;
}
interface WeakSet<T extends object> {
readonly [Symbol.toStringTag]: string;
}
interface JSON {
readonly [Symbol.toStringTag]: string;
}
interface Function {
/**
* Determines whether the given value inherits from this function if this function was used
* as a constructor function.
*
* A constructor function can control which objects are recognized as its instances by
* 'instanceof' by overriding this method.
*/
[Symbol.hasInstance](value: any): boolean;
}
interface GeneratorFunction {
readonly [Symbol.toStringTag]: string;
}
interface Math {
readonly [Symbol.toStringTag]: string;
}
interface Promise<T> {
readonly [Symbol.toStringTag]: string;
}
interface PromiseConstructor {
readonly [Symbol.species]: PromiseConstructor;
}
interface RegExp {
/**
* Matches a string with this regular expression, and returns an array containing the results of
* that search.
* @param string A string to search within.
*/
[Symbol.match](string: string): RegExpMatchArray | null;
/**
* Replaces text in a string, using this regular expression.
* @param string A String object or string literal whose contents matching against
* this regular expression will be replaced
* @param replaceValue A String object or string literal containing the text to replace for every
* successful match of this regular expression.
*/
[Symbol.replace](string: string, replaceValue: string): string;
/**
* Replaces text in a string, using this regular expression.
* @param string A String object or string literal whose contents matching against
* this regular expression will be replaced
* @param replacer A function that returns the replacement text.
*/
[Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
/**
* Finds the position beginning first substring match in a regular expression search
* using this regular expression.
*
* @param string The string to search within.
*/
[Symbol.search](string: string): number;
/**
* Returns an array of substrings that were delimited by strings in the original input that
* match against this regular expression.
*
* If the regular expression contains capturing parentheses, then each time this
* regular expression matches, the results (including any undefined results) of the
* capturing parentheses are spliced.
*
* @param string string value to split
* @param limit if not undefined, the output array is truncated so that it contains no more
* than 'limit' elements.
*/
[Symbol.split](string: string, limit?: number): string[];
}
interface RegExpConstructor {
readonly [Symbol.species]: RegExpConstructor;
}
interface String {
/**
* Matches a string or an object that supports being matched against, and returns an array
* containing the results of that search, or null if no matches are found.
* @param matcher An object that supports being matched against.
*/
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
/**
* Replaces text in a string, using an object that supports replacement within a string.
* @param searchValue A object can search for and replace matches within a string.
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
*/
replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
/**
* Replaces text in a string, using an object that supports replacement within a string.
* @param searchValue A object can search for and replace matches within a string.
* @param replacer A function that returns the replacement text.
*/
replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
/**
* Finds the first substring match in a regular expression search.
* @param searcher An object which supports searching within a string.
*/
search(searcher: { [Symbol.search](string: string): number; }): number;
/**
* Split a string into substrings using the specified separator and return them as an array.
* @param splitter An object that can split a string.
* @param limit A value used to limit the number of elements returned in the array.
*/
split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
}
interface ArrayBuffer {
readonly [Symbol.toStringTag]: string;
}
interface DataView {
readonly [Symbol.toStringTag]: string;
}
interface Int8Array {
readonly [Symbol.toStringTag]: "Int8Array";
}
interface Uint8Array {
readonly [Symbol.toStringTag]: "Uint8Array";
}
interface Uint8ClampedArray {
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
}
interface Int16Array {
readonly [Symbol.toStringTag]: "Int16Array";
}
interface Uint16Array {
readonly [Symbol.toStringTag]: "Uint16Array";
}
interface Int32Array {
readonly [Symbol.toStringTag]: "Int32Array";
}
interface Uint32Array {
readonly [Symbol.toStringTag]: "Uint32Array";
}
interface Float32Array {
readonly [Symbol.toStringTag]: "Float32Array";
}
interface Float64Array {
readonly [Symbol.toStringTag]: "Float64Array";
}
interface ArrayConstructor {
readonly [Symbol.species]: ArrayConstructor;
}
interface MapConstructor {
readonly [Symbol.species]: MapConstructor;
}
interface SetConstructor {
readonly [Symbol.species]: SetConstructor;
}
interface ArrayBufferConstructor {
readonly [Symbol.species]: ArrayBufferConstructor;
}
@@ -0,0 +1,118 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Array<T> {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: T, fromIndex?: number): boolean;
}
interface ReadonlyArray<T> {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: T, fromIndex?: number): boolean;
}
interface Int8Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint8Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint8ClampedArray {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Int16Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint16Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Int32Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint32Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Float32Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Float64Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
+22
View File
@@ -0,0 +1,22 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015" />
/// <reference lib="es2016.array.include" />
@@ -0,0 +1,25 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2016" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
+26
View File
@@ -0,0 +1,26 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2016" />
/// <reference lib="es2017.object" />
/// <reference lib="es2017.sharedmemory" />
/// <reference lib="es2017.string" />
/// <reference lib="es2017.intl" />
/// <reference lib="es2017.typedarrays" />
@@ -0,0 +1,25 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2017" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
@@ -0,0 +1,32 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare namespace Intl {
type DateTimeFormatPartTypes = "day" | "dayPeriod" | "era" | "hour" | "literal" | "minute" | "month" | "second" | "timeZoneName" | "weekday" | "year";
interface DateTimeFormatPart {
type: DateTimeFormatPartTypes;
value: string;
}
interface DateTimeFormat {
formatToParts(date?: Date | number): DateTimeFormatPart[];
}
}
@@ -0,0 +1,51 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface ObjectConstructor {
/**
* Returns an array of values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
values<T>(o: { [s: string]: T } | ArrayLike<T>): T[];
/**
* Returns an array of values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
values(o: {}): any[];
/**
* Returns an array of key/values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
entries<T>(o: { [s: string]: T } | ArrayLike<T>): [string, T][];
/**
* Returns an array of key/values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
entries(o: {}): [string, any][];
/**
* Returns an object containing all own property descriptors of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
getOwnPropertyDescriptors<T>(o: T): {[P in keyof T]: TypedPropertyDescriptor<T[P]>} & { [x: string]: PropertyDescriptor };
}
@@ -0,0 +1,137 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.symbol" />
/// <reference lib="es2015.symbol.wellknown" />
interface SharedArrayBuffer {
/**
* Read-only. The length of the ArrayBuffer (in bytes).
*/
readonly byteLength: number;
/**
* Returns a section of an SharedArrayBuffer.
*/
slice(begin: number, end?: number): SharedArrayBuffer;
readonly [Symbol.species]: SharedArrayBuffer;
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
}
interface SharedArrayBufferConstructor {
readonly prototype: SharedArrayBuffer;
new (byteLength: number): SharedArrayBuffer;
}
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
interface ArrayBufferTypes {
SharedArrayBuffer: SharedArrayBuffer;
}
interface Atomics {
/**
* Adds a value to the value at the given position in the array, returning the original value.
* Until this atomic operation completes, any other read or write operation against the array
* will block.
*/
add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
/**
* Stores the bitwise AND of a value with the value at the given position in the array,
* returning the original value. Until this atomic operation completes, any other read or
* write operation against the array will block.
*/
and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
/**
* Replaces the value at the given position in the array if the original value equals the given
* expected value, returning the original value. Until this atomic operation completes, any
* other read or write operation against the array will block.
*/
compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
/**
* Replaces the value at the given position in the array, returning the original value. Until
* this atomic operation completes, any other read or write operation against the array will
* block.
*/
exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
/**
* Returns a value indicating whether high-performance algorithms can use atomic operations
* (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
* array.
*/
isLockFree(size: number): boolean;
/**
* Returns the value at the given position in the array. Until this atomic operation completes,
* any other read or write operation against the array will block.
*/
load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number;
/**
* Stores the bitwise OR of a value with the value at the given position in the array,
* returning the original value. Until this atomic operation completes, any other read or write
* operation against the array will block.
*/
or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
/**
* Stores a value at the given position in the array, returning the new value. Until this
* atomic operation completes, any other read or write operation against the array will block.
*/
store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
/**
* Subtracts a value from the value at the given position in the array, returning the original
* value. Until this atomic operation completes, any other read or write operation against the
* array will block.
*/
sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
/**
* If the value at the given position in the array is equal to the provided value, the current
* agent is put to sleep causing execution to suspend until the timeout expires (returning
* `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
* `"not-equal"`.
*/
wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
/**
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
* number of agents that were awoken.
* @param typedArray A shared Int32Array.
* @param index The position in the typedArray to wake up on.
* @param count The number of sleeping agents to notify. Defaults to +Infinity.
*/
notify(typedArray: Int32Array, index: number, count?: number): number;
/**
* Stores the bitwise XOR of a value with the value at the given position in the array,
* returning the original value. Until this atomic operation completes, any other read or write
* operation against the array will block.
*/
xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
readonly [Symbol.toStringTag]: "Atomics";
}
declare var Atomics: Atomics;
@@ -0,0 +1,47 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface String {
/**
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
* The padding is applied from the start (left) of the current string.
*
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
*
* @param fillString The string to pad the current string with.
* If this string is too long, it will be truncated and the left-most part will be applied.
* The default value for this parameter is " " (U+0020).
*/
padStart(maxLength: number, fillString?: string): string;
/**
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
* The padding is applied from the end (right) of the current string.
*
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
*
* @param fillString The string to pad the current string with.
* If this string is too long, it will be truncated and the left-most part will be applied.
* The default value for this parameter is " " (U+0020).
*/
padEnd(maxLength: number, fillString?: string): string;
}
@@ -0,0 +1,55 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Int8ArrayConstructor {
new (): Int8Array;
}
interface Uint8ArrayConstructor {
new (): Uint8Array;
}
interface Uint8ClampedArrayConstructor {
new (): Uint8ClampedArray;
}
interface Int16ArrayConstructor {
new (): Int16Array;
}
interface Uint16ArrayConstructor {
new (): Uint16Array;
}
interface Int32ArrayConstructor {
new (): Int32Array;
}
interface Uint32ArrayConstructor {
new (): Uint32Array;
}
interface Float32ArrayConstructor {
new (): Float32Array;
}
interface Float64ArrayConstructor {
new (): Float64Array;
}
@@ -0,0 +1,79 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2018.asynciterable" />
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
throw(e: any): Promise<IteratorResult<T, TReturn>>;
[Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
}
interface AsyncGeneratorFunction {
/**
* Creates a new AsyncGenerator object.
* @param args A list of arguments the function accepts.
*/
new (...args: any[]): AsyncGenerator;
/**
* Creates a new AsyncGenerator object.
* @param args A list of arguments the function accepts.
*/
(...args: any[]): AsyncGenerator;
/**
* The length of the arguments.
*/
readonly length: number;
/**
* Returns the name of the function.
*/
readonly name: string;
/**
* A reference to the prototype.
*/
readonly prototype: AsyncGenerator;
}
interface AsyncGeneratorFunctionConstructor {
/**
* Creates a new AsyncGenerator function.
* @param args A list of arguments the function accepts.
*/
new (...args: string[]): AsyncGeneratorFunction;
/**
* Creates a new AsyncGenerator function.
* @param args A list of arguments the function accepts.
*/
(...args: string[]): AsyncGeneratorFunction;
/**
* The length of the arguments.
*/
readonly length: number;
/**
* Returns the name of the function.
*/
readonly name: string;
/**
* A reference to the prototype.
*/
readonly prototype: AsyncGeneratorFunction;
}
@@ -0,0 +1,45 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.symbol" />
/// <reference lib="es2015.iterable" />
interface SymbolConstructor {
/**
* A method that returns the default async iterator for an object. Called by the semantics of
* the for-await-of statement.
*/
readonly asyncIterator: symbol;
}
interface AsyncIterator<T, TReturn = any, TNext = undefined> {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
}
interface AsyncIterable<T> {
[Symbol.asyncIterator](): AsyncIterator<T>;
}
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
}
+26
View File
@@ -0,0 +1,26 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2017" />
/// <reference lib="es2018.asynciterable" />
/// <reference lib="es2018.asyncgenerator" />
/// <reference lib="es2018.promise" />
/// <reference lib="es2018.regexp" />
/// <reference lib="es2018.intl" />
@@ -0,0 +1,25 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2018" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
@@ -0,0 +1,61 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare namespace Intl {
// http://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories
type LDMLPluralRule = "zero" | "one" | "two" | "few" | "many" | "other";
type PluralRuleType = "cardinal" | "ordinal";
interface PluralRulesOptions {
localeMatcher?: "lookup" | "best fit";
type?: PluralRuleType;
minimumIntegerDigits?: number;
minimumFractionDigits?: number;
maximumFractionDigits?: number;
minimumSignificantDigits?: number;
maximumSignificantDigits?: number;
}
interface ResolvedPluralRulesOptions {
locale: string;
pluralCategories: LDMLPluralRule[];
type: PluralRuleType;
minimumIntegerDigits: number;
minimumFractionDigits: number;
maximumFractionDigits: number;
minimumSignificantDigits?: number;
maximumSignificantDigits?: number;
}
interface PluralRules {
resolvedOptions(): ResolvedPluralRulesOptions;
select(n: number): LDMLPluralRule;
}
const PluralRules: {
new (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
(locales?: string | string[], options?: PluralRulesOptions): PluralRules;
supportedLocalesOf(
locales: string | string[],
options?: PluralRulesOptions,
): string[];
};
}
@@ -0,0 +1,32 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> {
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
* resolved value cannot be modified from the callback.
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
* @returns A Promise for the completion of the callback.
*/
finally(onfinally?: (() => void) | undefined | null): Promise<T>
}
@@ -0,0 +1,39 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface RegExpMatchArray {
groups?: {
[key: string]: string
}
}
interface RegExpExecArray {
groups?: {
[key: string]: string
}
}
interface RegExp {
/**
* Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression.
* Default is false. Read-only.
*/
readonly dotAll: boolean;
}
@@ -0,0 +1,85 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
type FlatArray<Arr, Depth extends number> = {
"done": Arr,
"recur": Arr extends ReadonlyArray<infer InnerArr>
? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
: Arr
}[Depth extends -1 ? "done" : "recur"];
interface ReadonlyArray<T> {
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callback A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U, This = undefined> (
callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>,
thisArg?: This
): U[]
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<A, D extends number = 1>(
this: A,
depth?: D
): FlatArray<A, D>[]
}
interface Array<T> {
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callback A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U, This = undefined> (
callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>,
thisArg?: This
): U[]
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<A, D extends number = 1>(
this: A,
depth?: D
): FlatArray<A, D>[]
}
+25
View File
@@ -0,0 +1,25 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2018" />
/// <reference lib="es2019.array" />
/// <reference lib="es2019.object" />
/// <reference lib="es2019.string" />
/// <reference lib="es2019.symbol" />
@@ -0,0 +1,25 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2019" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
@@ -0,0 +1,35 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.iterable" />
interface ObjectConstructor {
/**
* Returns an object created by key-value entries for properties and methods
* @param entries An iterable object that contains key-value entries for properties and methods.
*/
fromEntries<T = any>(entries: Iterable<readonly [PropertyKey, T]>): { [k: string]: T };
/**
* Returns an object created by key-value entries for properties and methods
* @param entries An iterable object that contains key-value entries for properties and methods.
*/
fromEntries(entries: Iterable<readonly any[]>): any;
}
@@ -0,0 +1,33 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface String {
/** Removes the trailing white space and line terminator characters from a string. */
trimEnd(): string;
/** Removes the leading white space and line terminator characters from a string. */
trimStart(): string;
/** Removes the leading white space and line terminator characters from a string. */
trimLeft(): string;
/** Removes the trailing white space and line terminator characters from a string. */
trimRight(): string;
}

Some files were not shown because too many files have changed in this diff Show More