├── .eslintrc.yml ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── docma.json ├── docs ├── content │ └── readme.html ├── css │ ├── docma.css │ └── styles.css ├── img │ ├── tree-deep.png │ ├── tree-first.png │ ├── tree-folded.png │ ├── tree-last.png │ ├── tree-node.png │ ├── tree-parent.png │ └── tree-space.png ├── index.html └── js │ ├── app.min.js │ ├── docma-web.js │ ├── highlight.pack.js │ └── tippy.all.min.js ├── index.d.ts ├── index.js ├── package-lock.json ├── package.json ├── src ├── Azuma.js ├── Constants.js ├── Structures.js ├── client │ ├── LICENSE │ ├── RequestHandler.js │ ├── RequestManager.js │ ├── Router.js │ └── structures │ │ ├── DiscordError.js │ │ ├── DiscordRequest.js │ │ └── RequestError.js └── ratelimits │ ├── AzumaIPC.js │ ├── AzumaManager.js │ └── AzumaRatelimit.js └── typings ├── Azuma.d.ts ├── Constants.d.ts ├── Structures.d.ts ├── client ├── RequestHandler.d.ts └── RequestManager.d.ts └── ratelimits ├── AzumaIPC.d.ts ├── AzumaManager.d.ts └── AzumaRatelimit.d.ts /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es2020: true 3 | node: true 4 | extends: 'eslint:recommended' 5 | globals: 6 | Atomics: readonly 7 | SharedArrayBuffer: readonly 8 | load: readonly 9 | BigInt: readonly 10 | parserOptions: 11 | ecmaVersion: 2020 12 | sourceType: 'module' 13 | rules: 14 | indent: 15 | - error 16 | - 4 17 | - SwitchCase: 1 18 | linebreak-style: 19 | - error 20 | - unix 21 | quotes: 22 | - error 23 | - single 24 | semi: 25 | - error 26 | no-extra-parens: 27 | - warn 28 | - all 29 | array-callback-return: 30 | - warn 31 | prefer-spread: 32 | - warn 33 | no-useless-constructor: 34 | - warn 35 | no-console: 36 | - off 37 | arrow-parens: 38 | - error 39 | - as-needed 40 | no-multi-spaces: 41 | - error 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | docs 3 | assets 4 | .gitattributes 5 | .idea 6 | .gitignore 7 | .eslintrc.yml 8 | .eslintignore 9 | docma.json 10 | README.md -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Saya 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azuma 2 | A package that actually syncs your ratelimits across all your clusters on Discord.JS 3 | 4 | > The Shipgirl Project; [Azuma](https://azurlane.koumakan.jp/Azuma) 5 | 6 |

7 | 8 |

9 | 10 | ## EOL 11 | > Discord.JS started developing their "proxy" module, marking the end of EOL of this package. Use that instead 12 | 13 | > Link: https://github.com/discordjs/discord.js/tree/main/packages/proxy 14 | 15 | ## Features 16 | 17 | ✅ An easy drop in solution for those who wants globally synced ratelimits 18 | 19 | ✅ Follows the original Discord.JS rest manager, so no breaking changes needed 20 | 21 | ✅ Supports Discord.JS v13 22 | 23 | 24 | ## NOTE 25 | 26 | > This library is now in "Maintenance" phase. I'm not gonna add new features on it. I'll just fix issues if there is but that's as far as I'll go. 27 | 28 | > You need to use [Kurasuta](https://github.com/DevYukine/Kurasuta) to make this work as this package depends on it 29 | 30 | > This is planned to use `@discordjs/sharder` once it's ready. That's the last update and marks the v4 release 31 | 32 | > v1.x.x initial release (Latest in 1x branch is version: 1.1.0) 33 | 34 | > v2.x.x drops support for Discord.JS v12 (Latest in 2x branch is version: 2.1.2) 35 | 36 | > v3.x.x makes the package ESM only (Current) 37 | 38 | ## Installation 39 | 40 | > npm i --save azuma 41 | 42 | ## Documentation 43 | 44 | > https://deivu.github.io/Azuma/?api 45 | 46 | ## Support 47 | > https://discord.gg/FVqbtGu `#development` channel 48 | 49 | ## Example 50 | > Running Azuma is the same with [Kurasuta](https://github.com/DevYukine/Kurasuta#example), except on you need to change your index.js based on example below 51 | 52 | ## Example of index.js 53 | ```js 54 | import { Azuma } from 'azuma'; 55 | import { Client } = from 'discord.js'; 56 | 57 | const KurasutaOptions = { 58 | client: YourBotClient, 59 | timeout: 90000, 60 | token: 'idk' 61 | }; 62 | const AzumaOptions = { 63 | inactiveTimeout: 300000, 64 | requestOffset: 500 65 | }; 66 | // Initialize Azuma 67 | const azuma = new Azuma(new URL('BaseCluster.js', import.meta.url), KurasutaOptions, AzumaOptions); 68 | // If you need to access the Kurasuta Sharding Manager, example, you want to listen to shard ready event 69 | azuma.manager.on('shardReady', id => console.log(`Shard ${id} is now ready`)); 70 | // Call spawn from azuma, not from kurasuta 71 | azuma.spawn(); 72 | ``` 73 | 74 | ## Pro Tip 75 | > Azuma also exposes when a request was made, when a response from a request is received, and if you hit an actual 429 via an event emitter, which you can use to make metrics on 76 | ```js 77 | import { Client } = from 'discord.js'; 78 | 79 | class Example extends Client { 80 | login() { 81 | this.rest.on('onRequest', ({ request }) => /* do some parses on your thing for metrics or log it idk */); 82 | this.rest.on('onResponse', ({ request, response }) => /* do some parses on your thing for metrics or log it idk */); 83 | this.rest.on('onTooManyRequest', ({ request, response }) => /* do some probably, warning logs here? since this is an actual 429 and can get you banned for an hour */); 84 | return super.login('token'); 85 | } 86 | } 87 | ``` 88 | > WARNING: DO NOT CHANGE OR RUN ANY FUNCTION FROM THE PARAMETERS. It's designed to be used as read-only values 89 | 90 | > Based from my old handling from `@Kashima`, Made with ❤ by @Sāya#0113 91 | -------------------------------------------------------------------------------- /docma.json: -------------------------------------------------------------------------------- 1 | { 2 | "src":[ 3 | "./index.js", 4 | "./src/*.js", 5 | "./src/**/*.js", 6 | "./README.md" 7 | ], 8 | "dest":"./docs", 9 | "jsdoc":{ 10 | "hierarchy":true, 11 | "sort":"kind", 12 | "plugins":[ 13 | "plugins/markdown" 14 | ] 15 | }, 16 | "markdown":{ 17 | "sanitize":false 18 | }, 19 | "app":{ 20 | "title":"Azuma | Synced ratelimits for Discord.JS", 21 | "routing":"query", 22 | "entrance":"content:readme", 23 | "base":"/Azuma" 24 | }, 25 | "template":{ 26 | "options":{ 27 | "title":{ 28 | "label":"Azuma", 29 | "href":"." 30 | }, 31 | "sidebar":{ 32 | "enabled":true, 33 | "outline":"tree", 34 | "collapsed":false, 35 | "toolbar":true, 36 | "itemsFolded":false, 37 | "itemsOverflow":"crop", 38 | "badges":true, 39 | "search":true, 40 | "animations":true 41 | }, 42 | "symbols":{ 43 | "autoLink":true, 44 | "params":"list", 45 | "enums":"list", 46 | "props":"list", 47 | "meta":false 48 | }, 49 | "navbar":{ 50 | "enabled":true, 51 | "dark":false, 52 | "animations":true, 53 | "menu":[ 54 | { 55 | "label":"Readme", 56 | "href":"." 57 | }, 58 | { 59 | "label":"Documentation", 60 | "href":"?api" 61 | }, 62 | { 63 | "label":"GitHub", 64 | "href":"https://github.com/Deivu/Azuma" 65 | } 66 | ] 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /docs/content/readme.html: -------------------------------------------------------------------------------- 1 | 2 |

Azuma

3 |
4 |

A package that actually syncs your ratelimits across all your clusters on Discord.JS

5 |
6 |

The Shipgirl Project; Azuma

7 |
8 |

9 | 10 |

11 | 12 |

Features

13 |
14 |

✅ An easy drop in solution for those who wants globally synced ratelimits

15 |

✅ Follows the original Discord.JS rest manager, so no breaking changes needed

16 |

✅ Supports Discord.JS v13

17 |

NOTE

18 |
19 |
20 |

This library is now in "Maintenance" phase. I'm not gonna add new features on it. I'll just fix issues if there is but that's as far as I'll go.

21 |
22 |
23 |

You need to use Kurasuta to make this work as this package depends on it

24 |
25 |
26 |

This is planned to use @discordjs/sharder once it's ready. That's the last update and marks the v4 release

27 |
28 |
29 |

v1.x.x initial release (Latest in 1x branch is version: 1.1.0)

30 |
31 |
32 |

v2.x.x drops support for Discord.JS v12 (Latest in 2x branch is version: 2.1.2)

33 |
34 |
35 |

v3.x.x makes the package ESM only (Current)

36 |
37 |

Installation

38 |
39 |
40 |

npm i --save azuma

41 |
42 |

Documentation

43 |
44 |
45 |

https://deivu.github.io/Azuma/?api

46 |
47 |

Support

48 |
49 |
50 |

https://discord.gg/FVqbtGu #development channel

51 |
52 |

Example

53 |
54 |
55 |

Running Azuma is the same with Kurasuta, except on you need to change your index.js based on example below

56 |
57 |

Example of index.js

58 |
59 |
import { Azuma } from 'azuma';
60 | import { Client } = from 'discord.js';
61 | 
62 | const KurasutaOptions = {
63 |     client: YourBotClient,
64 |     timeout: 90000,
65 |     token: 'idk'
66 | };
67 | const AzumaOptions = {
68 |     inactiveTimeout: 300000,
69 |     requestOffset: 500
70 | };
71 | // Initialize Azuma
72 | const azuma = new Azuma(new URL('BaseCluster.js', import.meta.url), KurasutaOptions, AzumaOptions);
73 | // If you need to access the Kurasuta Sharding Manager, example, you want to listen to shard ready event
74 | azuma.manager.on('shardReady', id => console.log(`Shard ${id} is now ready`));
75 | // Call spawn from azuma, not from kurasuta
76 | azuma.spawn();
77 |

Pro Tip

78 |
79 |
80 |

Azuma also exposes when a request was made, when a response from a request is received, and if you hit an actual 429 via an event emitter, which you can use to make metrics on

81 |
import { Client } = from 'discord.js';
82 |
83 |

class Example extends Client { 84 | login() { 85 | this.rest.on('onRequest', ({ request }) => /* do some parses on your thing for metrics or log it idk /); 86 | this.rest.on('onResponse', ({ request, response }) => / do some parses on your thing for metrics or log it idk /); 87 | this.rest.on('onTooManyRequest', ({ request, response }) => / do some probably, warning logs here? since this is an actual 429 and can get you banned for an hour */); 88 | return super.login('token'); 89 | } 90 | }

91 |
> WARNING: DO NOT CHANGE OR RUN ANY FUNCTION FROM THE PARAMETERS. It's designed to be used as read-only values
92 | 
93 | ## Example Bot
94 | https://github.com/Deivu/Kongou
95 | 
96 | > Based from my Handling from `@Kashima`, Made with ❤ by @Sāya#0113
-------------------------------------------------------------------------------- /docs/css/docma.css: -------------------------------------------------------------------------------- 1 | img.docma{display:inline-block;border:0 none}img.docma.emoji,img.docma.emoji-sm,img.docma.emoji-1x{height:1em;width:1em;margin:0 .05em 0 .1em;vertical-align:-0.1em}img.docma.emoji-md{height:1.33em;width:1.33em;margin:0 .0665em 0 .133em;vertical-align:-0.133em}img.docma.emoji-lg{height:1.66em;width:1.66em;margin:0 .083em 0 .166em;vertical-align:-0.166em}img.docma .emoji-2x{height:2em;width:2em;margin:0 .1em 0 .2em;vertical-align:-0.2em}img.docma .emoji-3x{height:3em;width:3em;margin:0 .15em 0 .3em;vertical-align:-0.3em}img.docma .emoji-4x{height:4em;width:4em;margin:0 .2em 0 .4em;vertical-align:-0.4em}img.docma .emoji-5x{height:5em;width:5em;margin:0 .25em 0 .5em;vertical-align:-0.5em}ul.docma.task-list{list-style:none;padding-left:0;margin-left:0}ul.docma.task-list>li.docma.task-item{padding-left:0;margin-left:0}.docma-hide,.docma-ignore{position:absolute !important;display:none !important;visibility:hidden !important;opacity:0 !important;margin-right:2000px} -------------------------------------------------------------------------------- /docs/css/styles.css: -------------------------------------------------------------------------------- 1 | caption,th{text-align:left}.table,legend{max-width:100%}.clearfix::after,.row:after,.row:before{content:""}.row,.row:after{clear:both}.span-3,.table{width:100%}.no-pointer-events,img.item-tree-line{pointer-events:none}.underline-skip,a:focus,a:hover{-webkit-text-decoration-line:underline;text-decoration-line:underline;text-decoration-skip:ink;-webkit-text-decoration-skip:ink;text-decoration-skip-ink:auto}@font-face{font-family:'Fira Sans';font-style:italic;font-weight:400;src:local('Fira Sans Italic'),local('FiraSans-Italic'),url(https://fonts.gstatic.com/s/firasans/v8/va9C4kDNxMZdWfMOD5VvkrjJYTc.ttf) format('truetype')}@font-face{font-family:'Fira Sans';font-style:normal;font-weight:400;src:local('Fira Sans Regular'),local('FiraSans-Regular'),url(https://fonts.gstatic.com/s/firasans/v8/va9E4kDNxMZdWfMOD5Vvl4jO.ttf) format('truetype')}@font-face{font-family:'Fira Sans';font-style:normal;font-weight:500;src:local('Fira Sans Medium'),local('FiraSans-Medium'),url(https://fonts.gstatic.com/s/firasans/v8/va9B4kDNxMZdWfMOD5VnZKveRhf_.ttf) format('truetype')}@font-face{font-family:'Fira Sans';font-style:normal;font-weight:700;src:local('Fira Sans Bold'),local('FiraSans-Bold'),url(https://fonts.gstatic.com/s/firasans/v8/va9B4kDNxMZdWfMOD5VnLK3eRhf_.ttf) format('truetype')}@font-face{font-family:'Overpass Mono';font-style:normal;font-weight:400;src:local('Overpass Mono Regular'),local('OverpassMono-Regular'),url(https://fonts.gstatic.com/s/overpassmono/v4/_Xmq-H86tzKDdAPa-KPQZ-AC1i-0sw.ttf) format('truetype')}@font-face{font-family:'Overpass Mono';font-style:normal;font-weight:600;src:local('Overpass Mono SemiBold'),local('OverpassMono-SemiBold'),url(https://fonts.gstatic.com/s/overpassmono/v4/_Xm3-H86tzKDdAPa-KPQZ-AC3vCQo_CXAw.ttf) format('truetype')}@font-face{font-family:'Overpass Mono';font-style:normal;font-weight:700;src:local('Overpass Mono Bold'),local('OverpassMono-Bold'),url(https://fonts.gstatic.com/s/overpassmono/v4/_Xm3-H86tzKDdAPa-KPQZ-AC3pSRo_CXAw.ttf) format('truetype')}.background-clip-padding{-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.trans-all-ease-fast{-webkit-transition:all .15s ease;transition:all .15s ease}.trans-all-ease-slow{-webkit-transition:all .5s ease;transition:all .5s ease}.trans-all-ease{-webkit-transition:all .3s ease;transition:all .3s ease}.trans-height-ease{-webkit-transition:opacity .15s ease,height .15s ease;transition:opacity .15s ease,height .15s ease}.trans-delay-1{transition-delay:.1s}.no-trans{-webkit-transition-property:none;transition-property:none}.no-trans-force{-webkit-transition-property:none!important;transition-property:none!important}.no-margin,.no-space{margin:0!important}.no-space-top{margin-top:0!important}.no-space-right{margin-right:0!important}.no-space-bottom{margin-bottom:0!important}.no-space-left{margin-left:0!important}.space-xs{margin-left:7px!important}.space-sm{margin-left:15px!important}.space,.space-md{margin-left:25px!important}.space-lg{margin-left:40px!important}.space-top-xs{margin-top:7px!important}.space-top-sm{margin-top:15px!important}.space-top,.space-top-md{margin-top:25px!important}.space-top-lg{margin-top:40px!important}.space-right-xs{margin-right:7px!important}.space-right-sm{margin-right:15px!important}.space-right,.space-right-md{margin-right:25px!important}.space-right-lg{margin-right:40px!important}.space-bottom-xs{margin-bottom:7px!important}.space-bottom-sm{margin-bottom:15px!important}.space-bottom,.space-bottom-md{margin-bottom:25px!important}.space-bottom-lg{margin-bottom:40px!important}.space-left-xs{margin-left:7px!important}.space-left-sm{margin-left:15px!important}.space-left,.space-left-md{margin-left:25px!important}.space-left-lg{margin-left:40px!important}.no-pad,.no-padding{padding:0!important}.no-pad-top{padding-top:0!important}.no-pad-right{padding-right:0!important}.no-pad-bottom{padding-bottom:0!important}.no-pad-left{padding-left:0!important}.pad-xs{padding:7px!important}.pad-sm{padding:15px!important}.pad,.pad-lg,.pad-md{padding:7px!important}.pad-top-xs{padding-top:7px!important}.pad-top-sm{padding-top:15px!important}.pad-top,.pad-top-md{padding-top:25px!important}.pad-top-lg{padding-top:40px!important}.pad-right-xs{padding-right:7px!important}.pad-right-sm{padding-right:15px!important}.pad-right,.pad-right-md{padding-right:25px!important}.pad-right-lg{padding-right:40px!important}.pad-bottom-xs{padding-bottom:7px!important}.pad-bottom-sm{padding-bottom:15px!important}.pad-bottom,.pad-bottom-md{padding-bottom:25px!important}.pad-bottom-lg{padding-bottom:40px!important}.pad-left-xs{padding-left:7px!important}.pad-left-sm{padding-left:15px!important}.pad-left,.pad-left-md{padding-left:25px!important}.pad-left-lg{padding-left:40px!important}legend,td,th{padding:0}.fw-bold{font-weight:700!important}.fw-medium{font-weight:500!important}.fw-normal{font-weight:400!important}.pointer{cursor:pointer!important}.vertical-middle{vertical-align:middle}progress,sub,sup{vertical-align:baseline}.inline-block{display:inline-block}.absolute{position:absolute}.no-scroll{overflow:hidden!important}.no-wrap,.nowrap{white-space:nowrap!important}.snap-left{display:block;float:left}.snap-right{display:block;float:right}.clearfix::after{clear:both;display:table}audio,canvas,progress,video{display:inline-block}article,aside,details,figcaption,figure,footer,header,main,menu,nav,pre,section{display:block}.ellipsis{text-overflow:ellipsis;overflow-x:hidden}button,hr,input{overflow:visible}.no-ellipsis{text-overflow:clip;overflow-x:visible}.color-white{color:#fff!important}.color-black{color:#000!important}.color-blue{color:#5ca1eb!important}.color-accent{color:#3875ee!important}.color-cyan{color:#5bc0de!important}.color-green,.color-success{color:#52af52!important}.color-yellow{color:#f0b563!important}.color-red{color:#e07470!important}.color-purple{color:#996599!important}.color-orange{color:#dc881f!important}.color-light{color:#aaafbd!important}.color-pink{color:#ff6fbc!important}.color-brown{color:#8a4c42!important}.color-gray-base{color:#17191e!important}.color-gray-darkest{color:#292c35!important}.color-gray-darker{color:#383d49!important}.color-gray-dark{color:#596175!important}.color-gray{color:#7e879c!important}.color-gray-light{color:#aaafbd!important}.color-gray-lighter{color:#e3e5ea!important}code,legend,pre code{color:inherit}.bg-blue{background-color:#5ca1eb!important}.bg-accent{background-color:#3875ee!important}.bg-cyan{background-color:#5bc0de!important}.bg-green{background-color:#52af52!important}.bg-green-pale{background-color:#34793c!important}.bg-yellow{background-color:#f0b563!important}.bg-red{background-color:#e07470!important}.bg-purple{background-color:#996599!important}.bg-purple-dark{background-color:#6736a0!important}.bg-pink{background-color:#ff6fbc!important}.bg-orange{background-color:#dc881f!important}.bg-ice{background-color:#9cbed3!important}.bg-ice-mid{background-color:#9aaec3!important}.bg-ice-dark{background-color:#788EA3!important}.bg-ice-blue{background-color:#465c84!important}.bg-gray{background-color:#7e879c!important}.bg-gray-light{background-color:#aaafbd!important}.bg-gray-dark{background-color:#596175!important}.bg-gray-darker{background-color:#383d49!important}.bg-brown{background-color:#8a4c42!important}a,table{background-color:transparent}.svg-fill-blue svg{fill:#5ca1eb!important}.svg-fill-blue-pale svg{fill:#4f5e84!important}.svg-fill-accent svg{fill:#3875ee!important}.svg-fill-cyan svg{fill:#5bc0de!important}.svg-fill-green svg{fill:#52af52!important}.svg-fill-green-pale svg{fill:#34793c!important}.svg-fill-yellow svg{fill:#f0b563!important}.svg-fill-red svg{fill:#e07470!important}.svg-fill-purple svg{fill:#996599!important}.svg-fill-purple-pale svg{fill:#7f58ab!important}.svg-fill-purple-dark svg{fill:#6736a0!important}.svg-fill-pink svg{fill:#ff6fbc!important}.svg-fill-orange svg{fill:#dc881f!important}.svg-fill-gray svg{fill:#7e879c!important}.svg-fill-gray-dark svg{fill:#596175!important}.svg-fill-ice-blue svg{fill:#465c84!important}.svg-fill-brown svg{fill:#8a4c42!important}.svg-fill-black svg{fill:#000!important}.opacity-full{opacity:1}.opacity-xl{opacity:.8}.opacity-lg{opacity:.65}.opacity-md{opacity:.5}.opacity-sm{opacity:.3}.opacity-xs{opacity:.1}/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */h1{margin:.67em 0}figure{margin:1em 40px}hr{box-sizing:content-box}.container,.container-boxed,legend{box-sizing:border-box}a{-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}audio:not([controls]){display:none;height:0}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{display:table;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.docma-info,.hljs-emphasis,.param-info,.symbol-meta,blockquote{font-style:italic}summary{display:list-item}[hidden],template{display:none}table{border-collapse:collapse;border-spacing:0}caption{padding-top:8px;padding-bottom:8px;color:#aaafbd}.table{margin-bottom:24px}.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th{padding:8px;line-height:1.5;vertical-align:top;border-top:1px solid #e1e7ea}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #e1e7ea;font-size:15.5px}.table>caption+thead>tr:first-child>td,.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>td,.table>thead:first-child>tr:first-child>th{border-top:0}.table>tbody+tbody{border-top:2px solid #e1e7ea}.table .table{background-color:#fff}.table-condensed>tbody>tr>td,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>td,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>thead>tr>th{padding:5px}.table-bordered{border:1px solid #e1e7ea}.table-bordered>tbody>td,.table-bordered>tbody>th,.table-bordered>thead>td,.table-bordered>thead>th,.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border-bottom-width:2px}.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.table-hover>tbody>tr:hover{background-color:#e1e7ea}pre,pre code{background-color:transparent}table col[class*=col-]{position:static;float:none;display:table-column}table td[class*=col-],table th[class*=col-]{position:static;float:none;display:table-cell}.container,.container-boxed,.nav-spacer,body.static-navbar .navbar{position:relative}.table-responsive{overflow-x:auto;min-height:.01%}@media screen and (max-width:768px){.table-responsive{width:100%;margin-bottom:18px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #e1e7ea}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>td,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>thead>tr>th{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}}code,kbd,pre,samp{font-family:"Overpass Mono",Menlo,Monaco,Consolas,monospace,"Courier New";font-size:15.5px}.navbar-brand .navbar-title,.navbar-list>li,.sidebar-header>.sidebar-brand span.sidebar-title{font-family:"Fira Sans","Helvetica Neue",Helvetica,Arial,sans-serif}code{padding:2px 5px 3px;font-size:90%;background-color:rgba(238,240,244,.74);border-radius:3px}pre{padding:0;margin:0 0 15px;font-size:15.5px;line-height:1.5;word-break:keep-all;word-wrap:inherit;color:#596175;border:0;border-radius:4px;overflow:auto;overflow-x:scroll}pre code{padding:15px 25px!important;font-size:85.4%;white-space:unset;border-radius:0}pre code.options{padding:15px 25px 0!important}.code-delim{color:#cfd3de}.pre-scrollable{max-height:340px;overflow-y:scroll}kbd{padding:2px 4px;font-size:90%;color:#fff;background-color:#333;border-radius:2px;box-shadow:inset 0 -1px 0 rgba(0,0,0,.25)}kbd kbd{padding:0;font-size:100%;font-weight:700;box-shadow:none}.container{padding:0 55px;margin:0 auto}.container-boxed{max-width:960px!important;padding:0}@media screen and (max-width:1050px){.container-boxed{padding:0 55px}}.row{padding:0;margin:0}.row:after,.row:before{display:table}.col{display:block;float:left;margin:1% 0 1% 4%}.col:first-child{margin-left:0}.span-2{width:64%}.span-1{width:31.5%}.span-half{width:47.5%}@media only screen and (max-width:768px){.col{margin:1% 0}.span-1,.span-2,.span-3,.span-half{width:100%}}body.static-navbar{padding-top:0!important}.nav-spacer{display:block;height:50px;visibility:hidden}.nav-overlay,.navbar{position:fixed;width:100%;display:block;top:0;left:0}.nav-arrow{margin-left:6px}.nav-overlay{bottom:0;right:0;height:100%;overflow:scroll;background-color:rgba(23,25,30,.5);z-index:-1;opacity:0;-webkit-transition:opacity .2s,z-index 0s;transition:opacity .2s,z-index 0s}.nav-overlay.toggled{z-index:999997;opacity:1}.navbar{background-color:#fff;z-index:999998;user-select:none;box-shadow:0 1px 30px 10px rgba(0,0,0,.02);border-bottom:2px solid rgba(0,0,0,.05);height:52px}.navbar>.navbar-inner{display:block;position:relative;white-space:nowrap}.navbar a,.navbar a:focus,.navbar a:hover{text-decoration:none!important}.navbar-brand{display:inline-table;position:absolute;float:left;margin:0 24px 0 0;z-index:9;height:100%!important}.navbar-brand .navbar-logo{display:table-cell;position:relative;height:38px;padding:0;margin:6px 9px 0 0;width:auto}.navbar-brand .navbar-title{display:table-cell;position:relative;margin:auto 0 0;height:50px;line-height:1em;vertical-align:middle;font-weight:700;font-size:18px;letter-spacing:.03em}.navbar-brand .navbar-title a{display:inline-block;white-space:normal!important;max-width:180px;padding-top:4px;text-decoration:none;color:#4e5566}.navbar-brand .navbar-title a:hover{color:#17191e}.navbar-menu{display:inline-table;position:relative;float:right;height:50px;overflow-y:visible;max-width:100%;z-index:8}.navbar-list{display:block;position:relative;margin:0!important;padding:0!important;list-style:none;white-space:nowrap}.navbar-list>li{display:inline-table;position:relative;height:50px;background-color:#fff}.navbar-list>li:hover>a{background-color:#f5f5f7;color:#010101}.navbar-list>li.dropdown>ul>li>a,.navbar-list>li>a{color:#4e5566;cursor:pointer;white-space:nowrap;text-decoration:none}.navbar-list>li>a{display:table-cell;position:relative;padding:4px 21px 0;height:50px;border-right:1px dashed rgba(40,44,53,.1);vertical-align:middle;font-weight:500;z-index:3}.navbar-list>li>a span.nav-label{margin-left:6px}.navbar-list>li:last-child>a{border-right:0 none!important}.navbar-list>li.dropdown{margin:0;padding:0;list-style:none;height:50px}.navbar-list>li.dropdown:hover{overflow:visible}.navbar-list>li.dropdown:hover>ul{display:block;margin-top:50px;opacity:1;height:auto;-webkit-transition:margin-top .2s ease-out,opacity .2s ease-out;transition:margin-top .2s ease-out,opacity .2s ease-out}.navbar-list>li.dropdown:hover>ul>li{height:30px;opacity:1}.navbar-list>li.dropdown:hover>ul>li.divider{height:1px;margin:11px 0!important;opacity:1}.navbar-list>li.dropdown>ul{z-index:1;display:block;position:absolute;width:auto;top:0;left:0;list-style:none;line-height:1.6em;padding:12px;margin:1px 0 0;background-color:#fff;box-shadow:0 6px 12px rgba(0,0,0,.175);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;border-bottom-left-radius:4px;border-bottom-right-radius:4px;border:1px solid rgba(33,37,44,.1);opacity:0;-webkit-transition:opacity .15s ease-out,top .2 ease-in;transition:opacity .15s ease-out,top .2 ease-in}.navbar-list>li.dropdown>ul>li{border-radius:3px;height:0;opacity:0;-webkit-transition:height .1s ease-out;transition:height .1s ease-out}.navbar-list>li.dropdown>ul>li>a{display:inline-block;width:100%;padding:3px 12px}.navbar-list>li.dropdown>ul>li:hover{background-color:#f5f5f7}.navbar-list>li.dropdown>ul>li:hover>a{color:#010101}.navbar-list>li.dropdown>ul>li.divider{height:0;margin:0!important;border-radius:0!important;background-color:rgba(36,39,47,.1)!important;cursor:default!important}li.dropdown>ul>li>a>code{background-color:#f5f5f7!important}.navbar-menu-btn{display:none;position:absolute;top:6px;right:55px;height:38px;width:38px;border-radius:38px;cursor:pointer;-webkit-transition:all .2s ease;transition:all .2s ease}.navbar-menu-btn:hover{background-color:#f5f5f7}.navbar-menu-btn:active,.navbar-menu-btn:focus{outline:0}.navbar-menu-btn svg.fa-bars{display:block;position:absolute;color:#17191e;margin:8px 0 0 9px;opacity:1}.navbar-menu-btn svg.fa-times{display:block;position:absolute;color:#fff;margin:11px 0 0 13px;opacity:0}.navbar-menu-btn.toggled{background-color:#17191e!important}.navbar-menu-btn.toggled svg.fa-bars{color:#fff;opacity:0}.navbar-menu-btn.toggled svg.fa-times{opacity:1}.navbar-menu.toggled{height:300px!important;opacity:1!important;overflow-y:scroll!important}.hide-navbar-menu,.navbar-menu.break{height:0;opacity:0;overflow-y:hidden}.navbar-menu.toggled .navbar-list{margin-top:0!important}.hide-navbar-menu .navbar-list,.navbar-menu.break .navbar-list{margin-top:-350px}.navbar-menu-btn.break{display:block}.navbar-menu.break{display:block;position:absolute;left:55px;right:55px;top:50px;margin-right:0!important;max-width:100%;box-shadow:0 6px 12px rgba(0,0,0,.175);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;background-color:#fff;-webkit-transition:all .2s ease-out;transition:all .2s ease-out;border-bottom-left-radius:6px;border-bottom-right-radius:6px}ul.navbar-list.break{display:block;position:relative;margin-bottom:0!important;-webkit-transition:all .2s ease-out;transition:all .2s ease-out}ul.navbar-list.break>li{display:table;float:none;width:100%;border-bottom:1px solid rgba(47,51,62,.1);height:auto!important}ul.navbar-list.break>li>a{display:table-cell;border-right:none;padding:0 30px;background-color:#f9f9f9}ul.navbar-list.break>li.dropdown{margin:0;padding:0;list-style:none;height:auto!important}ul.navbar-list.break>li.dropdown:hover>ul>li,ul.navbar-list.break>li.dropdown>ul>li{height:auto;opacity:1}ul.navbar-list.break>li.dropdown>a{display:block;line-height:50px;border-bottom:1px solid rgba(47,51,62,.1)}ul.navbar-list.break>li.dropdown:hover{overflow:visible}ul.navbar-list.break>li.dropdown:hover>ul{display:block;margin-top:0;opacity:1;height:auto}ul.navbar-list.break>li.dropdown>ul{display:block;position:relative;width:auto;margin:0 0 0 30px!important;box-shadow:0 0 0;border-radius:0;border:0;border-left:1px dashed rgba(40,44,53,.1);opacity:1;-webkit-transition:none;transition:none}ul.navbar-list.break>li.dropdown>ul>li.divider{height:1px;margin:11px 0!important;opacity:1}.navbar.dark{box-shadow:0 1px 1px 0 rgba(0,0,0,.2);border-bottom:0 none;height:50px;background-color:#282c35;color:#8890a2}.navbar.dark .navbar-title a{color:#D6DBE7}.navbar.dark .navbar-title a:hover{color:#fff}.navbar.dark .navbar-list>li{background-color:#282c35;color:#8890a2}.navbar.dark .navbar-list>li>a{color:#8890a2;border-right:1px dashed rgba(104,110,123,.1)}.navbar.dark .navbar-list>li:hover,.navbar.dark .navbar-list>li:hover>a{background-color:#3e4452;color:#fff}.navbar.dark .navbar-list>li.dropdown>ul{color:#4e5566}.navbar.dark .navbar-menu-btn:hover{background-color:#3e4452}.navbar.dark .navbar-menu-btn:hover svg.fa-bars{color:#fff}.navbar.dark .navbar-menu-btn svg.fa-bars{color:#8890a2}.navbar.dark .navbar-menu-btn svg.fa-times,.navbar.dark .navbar-menu-btn.toggled svg.fa-bars{color:#fff}.navbar.dark .navbar-menu-btn.toggled{background-color:#17191e!important}.navbar.dark .navbar-menu.break,.navbar.dark ul.navbar-list.break>li{background-color:#fff}.navbar.dark ul.navbar-list.break>li:hover>a{background-color:#f5f5f7;color:#010101}.navbar.dark ul.navbar-list.break>li>a{background-color:#f9f9f9}.symbol{font-size:20px}.symbol a{position:relative;text-decoration:none}.symbol a:hover{text-decoration:none}.symbol a:hover svg{opacity:.6}.symbol a svg{display:inline-block;position:absolute;font-size:1em;line-height:1em;margin-left:-1.3em;margin-top:.25em;opacity:.15}code.symbol-name{font-size:85.4%;font-weight:700;color:#050607}code.symbol-name .def-val,span.symbol-sep{color:#aaafbd;font-weight:400}span.symbol-sep{background-color:transparent;font-size:20px;padding-left:5px}code.symbol-type{color:#7e879c;font-size:16px;font-weight:400;background-color:transparent}code.symbol-type a:focus,code.symbol-type a:hover{text-decoration:underline}.symbol-meta{font-size:13px!important;text-align:right;padding-bottom:0;margin-bottom:0;color:#7e879c}.symbol-container{padding-top:50px;margin-top:-50px;font-size:16px}.symbol-container .symbol-heading .symbol{padding:10px 0}.symbol-container .symbol-definition{padding:5px 0}.symbol-container .symbol-definition .symbol-info>p{margin:0}.symbol-container .symbol-definition .symbol-info>p:last-of-type{margin-bottom:10px}.symbol-container .symbol-definition>p{margin:0 0 15px}.symbol-container .symbol-definition p+table{margin-top:20px}.symbol-container .symbol-definition .table td:first-child{white-space:nowrap}.symbol-container .symbol-definition .table td:last-child{width:auto}.symbol-container .symbol-definition .caption{display:inline-block!important;min-width:80px}.boxed,.symbol-badge{display:inline-block}.boxed{font-size:12px;letter-spacing:.04em;color:#fff;padding:2px 6px 0;border-radius:2px;margin:-2px 3px 0 0;vertical-align:middle;background-color:#d5d8df}ul.param-list{margin-bottom:25px!important}ul.param-list>li{padding-top:5px;margin-bottom:15px}ul.param-list>li .param-meta>span>code:first-child{font-size:97%}ul.param-list>li .param-meta>span>code:last-child{padding:3px 5px}ul.param-list>li .param-meta .param-info-box{float:right}ul.param-list>li .param-desc{margin-top:10px;margin-left:-20px;padding:10px 20px 7px;border-top:1px solid #eef0f5!important;background:#fbfbfb;border-bottom-left-radius:3px;border-bottom-right-radius:3px}ul.param-list>li .param-desc p:last-of-type{margin:0!important}.param-info{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.param-info.required{background:#e07470;margin-right:7px}.param-info.optional{background:#aaafbd;margin-right:7px}.param-info.default,.param-info.value{background:0 0!important;color:#7e879c!important;font-size:15px}.param-info.default+code,.param-info.value+code{margin:0 12px 0 3px}.symbol-def-val code{padding:2px 7px 3px;color:#17191e!important;font-weight:700}.symbol-badge{position:relative;width:25px;height:25px;opacity:.65;margin-left:-2px}.symbol-badge>span{position:absolute;display:block;font-family:Arial,sans-serif;font-size:9.5px;color:#fff;width:100%;line-height:25px;text-indent:0!important;text-align:center;left:0;top:0;z-index:2}.symbol-badge>svg{position:absolute;display:block;width:25px!important;height:25px!important;left:0;top:0;z-index:1;fill:#000}.symbol-badge>svg.svg-inline--fa{width:21.01px!important;height:21.01px!important;margin:1px 0 0 2px;padding:0}.symbol-badge>div.badge-scope-circle{position:absolute;top:-2px;left:-1px;width:10px;height:10px;border-radius:10px;border:2px solid #1e2128!important;background-color:#e07470;z-index:2}.symbol-badge.badge-str>span{font-weight:700;font-size:18px!important;line-height:25px!important}.badge-scope-btn{position:absolute;width:11px;height:11px;border-radius:11px;border:1px solid #1e2128!important;background-color:#e07470;z-index:2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;opacity:.3}.symbol-badge.badge-btn,.symbol-badge.badge-btn>span,.symbol-badge.badge-btn>svg{width:22px!important;height:22px!important}.symbol-badge.badge-btn,img.item-tree-line{-moz-user-select:none;-ms-user-select:none}.badge-scope-btn.active,.badge-scope-btn:hover{opacity:1}.symbol-badge.badge-btn{display:inline-block;position:relative;margin-right:3px;white-space:nowrap;-webkit-user-select:none;user-select:none;cursor:pointer;opacity:.3}.symbol-badge.badge-btn>span{font-size:9px!important;line-height:22px!important;margin-left:-.5px}.symbol-badge.badge-btn.active,.symbol-badge.badge-btn:hover{opacity:1}img.item-tree-line{-webkit-user-select:none;user-select:none;vertical-align:top;margin-left:-2.2px}.sidebar-header,.sidebar-item{-moz-user-select:none;-ms-user-select:none}input[type=search]:-moz-placeholder{color:#8b93a6}input[type=search]::-webkit-input-placeholder{color:#8b93a6}.symbol-memberof{display:inline-block;width:auto;max-width:300px;overflow-x:hidden;vertical-align:middle}.symbol-memberof.no-width{max-width:0}#sidebar-toggle{display:block;position:fixed;z-index:9999999;top:0;left:0;width:50px;text-align:center;line-height:50px;font-size:20px;cursor:pointer}#sidebar-toggle svg.fa-bars{display:inline-block;margin-top:13px;color:#636982;opacity:.4}#sidebar-toggle:hover svg.fa-bars{opacity:1}#sidebar-toggle.toggled svg.fa-bars{color:#636982}#sidebar-toggle.toggled:hover svg.fa-bars{color:#fff;opacity:.85}.sidebar-item{opacity:1;-webkit-user-select:none;user-select:none}.sidebar-item.hidden{height:0;opacity:0;overflow:hidden}.sidebar-item .item-inner{height:36px}.sidebar-item .item-inner .item-label{display:inline-block;text-indent:0!important}.sidebar-item .item-inner .item-label.crop-to-fit{width:210px!important;overflow-x:hidden}.sidebar-item .item-inner .item-label.crop-to-fit div.inner{display:block;white-space:nowrap;overflow-x:hidden;width:auto;-webkit-transition:margin-left .2s ease;transition:margin-left .2s ease}.sidebar-item .item-inner .item-label .edge-shadow{position:absolute;background:0 0;top:0;right:0;width:50px;height:36px;box-shadow:inset -50px 0 40px -7px #1e2128;z-index:9;-webkit-transition:all .15s ease;transition:all .15s ease}.sidebar-item .item-inner .item-label div.inner{display:inline}.sidebar-item .item-inner .item-label div.inner span{display:inline-block;position:relative;height:36px!important;line-height:36px!important;vertical-align:middle;font-size:inherit;overflow:hidden}.sidebar-item .symbol-badge{position:absolute;top:6px;margin-left:-2px}.sidebar-item:hover .symbol-badge{opacity:1}.sidebar-item:hover .item-label.crop-to-fit div.inner{text-overflow:clip;overflow-x:visible}.sidebar-header{display:block;position:absolute;top:0;left:0;width:300px;height:130px;background-color:#1e2128;border-bottom:2px solid rgba(28,31,37,.7)!important;-webkit-user-select:none;user-select:none}.sidebar-header>.sidebar-brand{display:table;position:relative;height:49px;background-color:#1b1f25;border-bottom:1px solid rgba(0,0,0,.04)!important;padding-left:55px;width:100%}.sidebar-header>.sidebar-brand .sidebar-logo{display:table-cell;position:relative;height:38px;width:auto;margin:6px 9px 0 0}.sidebar-header>.sidebar-brand span.sidebar-title{position:relative;display:table-cell;width:100%;margin:auto 0 0 50px;font-size:18px;font-weight:700;letter-spacing:.03em;height:50px;line-height:1em;vertical-align:middle;color:#D6DBE7}.sidebar-header>.sidebar-brand span.sidebar-title>a{display:inline-block;margin-top:4px;text-decoration:none;color:#D6DBE7;width:180px}.sidebar-header>.sidebar-brand span.sidebar-title>a:hover{color:#fff}.sidebar-header>.sidebar-toolbar{display:block;position:relative;text-align:center;height:30px;overflow:hidden;margin-top:6px}.toolbar-buttons,.toolbar-kind-filters,.toolbar-scope-filters{display:inline-block;padding:0;position:relative;white-space:nowrap}.toolbar-kind-filters{margin:0 6px 0 0;text-align:center;vertical-align:middle}.toolbar-scope-filters{width:32px;height:32px;vertical-align:top}.toolbar-buttons{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;top:-1px}.toolbar-buttons span{color:#fff;opacity:.5;cursor:pointer}.toolbar-buttons span:hover{opacity:1}.sidebar-search{margin:0 20px;padding:20px 0 10px;position:relative}.sidebar-search #txt-search{outline:0!important;font-size:14px;width:100%;height:38px;margin-bottom:0;padding:2px 25px 0 30px;border-radius:36px;text-indent:0!important;background-color:#2b2e38;color:#8b93a6;border:1px solid #2b2e39;-webkit-box-shadow:inset 12px 2px 5px rgba(0,0,0,.1);box-shadow:inset 12px 2px 5px rgba(0,0,0,.1);transition-delay:.1s}.sidebar-search #txt-search:focus{background-color:#fff;color:#596175;-webkit-box-shadow:inset 1px 0 2px rgba(0,0,0,.5);box-shadow:inset 1px 0 2px rgba(0,0,0,.5)}.sidebar-search .sidebar-search-icon{position:absolute;top:22px;left:10px;line-height:36px;color:#8b93a6;z-index:999}.sidebar-search .sidebar-search-clean{position:absolute;top:21px;right:6px;line-height:36px;color:#8b93a6;z-index:999;cursor:pointer;text-indent:0!important}.sidebar-search .sidebar-search-clean:hover svg{color:#191c20}.search-query:focus+button{z-index:3}.sidebar-nav-container{display:block;position:absolute;overflow-y:auto;top:130px;bottom:0;left:0;right:0}ul.sidebar-nav,ul.sidebar-nav ul{display:block;position:relative;overflow:visible;list-style:none;padding:0}ul.sidebar-nav{padding-bottom:15px}ul.sidebar-nav ul{margin:0!important;height:auto;max-height:10000px;overflow:hidden;-webkit-transition:all .3s ease;transition:all .3s ease}ul.sidebar-nav ul.no-height{max-height:0}.sidebar-nav>.sidebar-brand{height:50px;font-size:18px;line-height:50px;background-color:#2b2e39}.sidebar-nav>.sidebar-brand a{color:#8b93a6}.sidebar-nav>.sidebar-brand a:hover{color:#fff;background:0 0}.sidebar-nav li{text-indent:20px;line-height:36px!important;white-space:nowrap}.sidebar-nav li>a{display:block;text-decoration:none;color:#aaafbd;height:36px}.sidebar-nav li>a:hover{text-decoration:none;color:#fff;background:#131519}.sidebar-nav li>a:hover .badge-scope-circle{border-color:#131519!important}button.btn,hr{border:0}.sidebar-nav li>a:hover .edge-shadow{box-shadow:inset 0 0 0 0 transparent!important}.sidebar-nav li>a:active,.sidebar-nav li>a:focus{text-decoration:none;outline:0}.hljs-link,a:focus,a:hover{text-decoration:underline}*,button,select{outline:0!important}.sidebar-nav li div.chevron{position:absolute;display:block;right:0;height:36px;width:36px;line-height:36px;color:rgba(255,255,255,.35);cursor:pointer;z-index:9}.sidebar-nav li div.chevron svg{margin-left:-12px;-webkit-transition:all .3s ease;transition:all .3s ease;-webkit-transform-origin:center center;-moz-transform-origin:center center;-ms-transform-origin:center center;transform-origin:center center;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.sidebar-nav li div.chevron.members-folded svg{-webkit-transform-origin:center center;-moz-transform-origin:center center;-ms-transform-origin:center center;transform-origin:center center;-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0)}.sidebar-nav li div.chevron:hover svg{color:#fff}.sidebar-nav li div.chevron:hover~a{background-color:rgba(0,0,0,.35)}.sidebar-nav li div.chevron:hover~a .edge-shadow{background-color:rgba(0,0,0,0);box-shadow:inset 0 0 0 0 transparent!important}.sidebar-nav li div.chevron:hover~ul{background-color:rgba(0,0,0,.2)}.sidebar-nav li div.chevron:hover~ul .edge-shadow{background-color:rgba(24,27,32,.35);box-shadow:inset -50px 0 40px -7px rgba(24,27,32,.2)!important}#wrapper{display:block;position:relative;margin-left:0}#wrapper.toggled{margin-left:300px}#wrapper.toggled #sidebar-wrapper{display:block;width:300px}#wrapper.toggled #page-content-wrapper{position:absolute;margin-right:-300px}#sidebar-wrapper{position:fixed;display:block;width:0;top:0;bottom:0;left:0;overflow-y:hidden;background-color:#1e2128;font-family:"Overpass Mono",Menlo,Monaco,Consolas,monospace,"Courier New";font-size:13px;z-index:999999}#page-content-wrapper{width:100%;position:relative;background:#fff;margin-right:0}@media print,(max-width:768px){#sidebar-wrapper,#wrapper.toggled #sidebar-wrapper{width:0}#sidebar-toggle{display:none}#wrapper,#wrapper.toggled{margin-left:0}#wrapper.toggled #page-content-wrapper{position:relative;margin-right:0}#page-content-wrapper{position:absolute}}.zebra-bookmark,a,p{position:relative}.tippy-tooltip.zebra-theme{background-color:#2b2e39;color:#8b93a6;box-shadow:0 1px 3px rgba(0,0,0,.25)}.hljs{display:block;overflow-x:auto;padding:.5em;color:#cacfd8;background:#282c34}.hljs-comment,.hljs-quote{color:#737a88;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-attribute,.hljs-regexp{color:#7987c3}.hljs-addition,.hljs-meta-string,.hljs-string{color:#98c379}.hljs-built_in,.hljs-class .hljs-title{color:#e6c07b}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-strong{font-weight:500}html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;-webkit-font-smoothing:subpixel-antialiased}body,html{font-family:"Fira Sans","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;line-height:1.5;background-color:#fff!important;color:#292c35;padding:0;margin:0;height:100%;min-height:100%}*,:after,:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}button{font-size:16px!important}button::-moz-focus-inner{border:0!important}button.btn-block{letter-spacing:.03em;font-size:18px!important}div,img{border:0!important}select{-webkit-appearance:menulist-button;background:#fff!important}a{color:#2f87e5;text-decoration:none}a:focus,a:hover{color:#196dc8;text-decoration-color:#13559b!important}.zebra-bookmark,.zebra-bookmark:hover{text-decoration:none}a:focus{outline:dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}hr{height:0;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(255,255,255,.3);margin:10px 0 20px}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{font-family:inherit;font-weight:500;line-height:1.1;color:inherit;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;z-index:0}a,ol,p,table,ul{z-index:1}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small,h4 .small,h4 small,h5 .small,h5 small,h6 .small,h6 small{font-size:70%;font-weight:400;line-height:1;color:#aaafbd}.h1,h1{font-size:36px;margin-top:36px;margin-bottom:13.33px}.h2,h2{font-size:32px;margin-top:32px;margin-bottom:11.85px}.h3,h3{font-size:26px;margin-top:26px;margin-bottom:9.63px}.h4,h4{font-size:21px;margin-top:21px;margin-bottom:7.78px}.h5,h5{font-size:16px;margin-top:16px;margin-bottom:5.93px}.h6,h6{font-size:13px;margin-top:13px;margin-bottom:4.81px}p{margin:0 0 15px}ol>li>p,ul{margin:5px 0}td>p{margin:0}img{vertical-align:middle}.well,details .details-content{background-color:#f9f9f9;border-radius:3px}blockquote{padding:10px 12px;margin:0 0 17px;font-size:1em;border-left:5px solid #f0b563;color:#576075;background-color:#f9f9f9;border-top-right-radius:3px;border-bottom-right-radius:3px}.well>p:last-of-type,blockquote>p:last-of-type{margin-bottom:0}.well{padding:20px}details{padding-top:60px;margin-top:-60px}details>summary{cursor:pointer;user-select:none;margin-bottom:10px}details .details-content{padding:12px 20px;border-top:3px solid #dadce2!important;margin-bottom:20px}details .details-content p:last-of-type{margin:0}details .details-content pre,details .details-content table{margin-top:10px}details .details-content :not(pre)>code{background-color:#e8ebee}details .details-content thead{background-color:#fff}details .details-content blockquote{background-color:#f4f4f4}.zebra-bookmark:hover svg{opacity:.6}.zebra-bookmark svg{display:inline-block;position:absolute;font-size:.7em;line-height:.7em;margin-left:-1.3em;margin-top:.175em;opacity:.15}.zebra-bookmark:before{content:" ";display:block;visibility:hidden;height:50px;margin-top:-50px}.docma-info{display:inline-block;font-size:12px;letter-spacing:.04em;margin-bottom:25px;z-index:2}#docma-content{margin-top:17px} -------------------------------------------------------------------------------- /docs/img/tree-deep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-deep.png -------------------------------------------------------------------------------- /docs/img/tree-first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-first.png -------------------------------------------------------------------------------- /docs/img/tree-folded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-folded.png -------------------------------------------------------------------------------- /docs/img/tree-last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-last.png -------------------------------------------------------------------------------- /docs/img/tree-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-node.png -------------------------------------------------------------------------------- /docs/img/tree-parent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-parent.png -------------------------------------------------------------------------------- /docs/img/tree-space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shipgirlproject/Azuma/68432c420c8b9a6e50e4287346aece62e0420165/docs/img/tree-space.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Azuma | Synced ratelimits for Discord.JS 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/js/app.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Zebra Template for Docma - app.js 4 | * Copyright © 2019, Onur Yıldırım 5 | * SVG shapes: CC-BY 4.0 6 | */ 7 | var app=window.app||{};(function(){"use strict";app.svg={}; 8 | /** 9 | * @license 10 | * CC-BY 4.0, © Onur Yıldırım 11 | */var shapes={square:'',circle:'',diamond:'',pentagonUp:'',pentagonDown:'',octagon:'',hexagonH:'',hexagonV:''};shapes.pentagon=shapes.pentagonUp;shapes.hexagon=shapes.hexagonV;app.svg.shape=function(options){var opts=options||{};var shape=opts.shape||"square";var svg=shapes[shape];var cls="badge-"+shape;cls+=" svg-fill-"+(opts.color||"black");if(opts.addClass)cls+=" "+opts.addClass;svg=''+svg+"";var scopeCircle=opts.circleColor?'
':"";var dataKind=!opts.circleColor?' data-kind="'+opts.kind+'"':"";var title=(opts.title||"").toLowerCase();return'
"+scopeCircle+""+(opts.char||"-")+""+svg+"
"};function getFaHtml(title,color){return'
'+''+"
"}app.svg.warn=function(title){title=title||"Warning: Check your JSDoc comments.";return getFaHtml(title,"yellow")};app.svg.error=function(title){title=title||"Error: Check your JSDoc comments.";return getFaHtml(title,"red")}})(); 12 | /** 13 | * @license 14 | * Zebra Template for Docma - app.js 15 | * Copyright © 2019, Onur Yıldırım 16 | */ 17 | var app=window.app||{};(function(){"use strict";app.NODE_MIN_FONT_SIZE=9;app.NODE_MAX_FONT_SIZE=13;app.NODE_LABEL_MAX_WIDTH=210;app.RE_EXAMPLE_CAPTION=/^\s*(.*?)<\/caption>\s*/gi;app.NAVBAR_HEIGHT=50;app.SIDEBAR_WIDTH=300;app.SIDEBAR_NODE_HEIGHT=36;app.TOOLBAR_HEIGHT=30;app.TREE_NODE_WIDTH=25;var helper={};var templateOpts=docma.template.options;helper.toggleBodyScroll=function(enable){var overflow=enable?"auto":"hidden";$("body").css({overflow:overflow})};helper.capitalize=function(str){return str.split(/[ \t]+/g).map(function(word){return word.charAt(0).toUpperCase()+word.slice(1)}).join(" ")};helper.removeFromArray=function(arr,value){var index=arr.indexOf(value);if(index!==-1)arr.splice(index,1)};helper.addToArray=function(arr,value){var index=arr.indexOf(value);if(index===-1)arr.push(value)};helper.debounce=function(func,wait,immediate){var timeout;return function(){var context=this;var args=arguments;var later=function(){timeout=null;if(!immediate)func.apply(context,args)};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow)func.apply(context,args)}};helper.getCssNumVal=function($elem,styleName){return parseInt($elem.css(styleName),10)||0};helper.getScrollWidth=function($elem){return $elem.get(0).scrollWidth||$elem.outerWidth()||0};helper.fitSidebarNavItems=function($el,outline){outline=outline||templateOpts.sidebar.outline;var cropToFit=templateOpts.sidebar.itemsOverflow==="crop";if(cropToFit){var dMarginLeft="data-margin-"+outline;var $inner=$el.find(".inner");var savedMargin=$inner.attr(dMarginLeft);if(!savedMargin){var marginLeft=Math.round(app.NODE_LABEL_MAX_WIDTH-helper.getScrollWidth($inner));if(marginLeft>=0)marginLeft=0;$inner.attr(dMarginLeft,marginLeft+"px")}return}var dFontSize="data-font-"+outline;var savedSize=$el.attr(dFontSize);if(savedSize){$el.css("font-size",savedSize);return}var delay=templateOpts.sidebar.animations?210:0;setTimeout(function(){var spans=$el.find("span").addClass("no-trans");var f=app.NODE_MAX_FONT_SIZE;while($el.width()>app.NODE_LABEL_MAX_WIDTH&&f>=app.NODE_MIN_FONT_SIZE){$el.css("font-size",f+"px");f-=.2}$el.attr(dFontSize,f+"px");spans.removeClass("no-trans")},delay)};helper.colorOperators=function(str){return str.replace(/[.#~]/g,'$&').replace(/:/g,'$&')};helper.hasChildren=function(symbol){return symbol.$members&&!symbol.isEnum};helper.getScopeInfo=function(scope){var o={};var top=0;var left=0;var m=12;switch(scope){case"global":o.color="purple";break;case"static":o.color="accent";top=m;break;case"instance":o.color="green";left=m;break;case"inner":o.color="gray-light";top=m;left=m;break;default:o.color=null}var margin=top+"px 0 0 "+left+"px";o.title=scope||"";o.badge='
';return o};helper.getSymbolInfo=function(kind,scope,asButton){var title=scope||"";title+=" "+String(kind||"").replace("typedef","type");title=DocmaWeb.Utils.trimLeft(helper.capitalize(title));var svgOpts={title:title,addClass:asButton?"badge-btn":"",circleColor:helper.getScopeInfo(scope).color,kind:kind,scope:scope};switch(kind){case"class":svgOpts.char="C";svgOpts.color="green";svgOpts.shape="diamond";break;case"constructor":svgOpts.char="c";svgOpts.color="green-pale";svgOpts.shape="circle";break;case"namespace":svgOpts.char="N";svgOpts.color="pink";svgOpts.shape="pentagonDown";break;case"module":svgOpts.char="M";svgOpts.color="red";svgOpts.shape="hexagonH";break;case"constant":svgOpts.char="c";svgOpts.color="brown";svgOpts.shape="hexagonV";break;case"typedef":svgOpts.char="T";svgOpts.color="purple-dark";svgOpts.shape="hexagonV";break;case"global":svgOpts.char="G";svgOpts.color="purple-dark";svgOpts.shape="hexagonV";break;case"global-object":svgOpts.char="G";svgOpts.color="purple-dark";svgOpts.shape="hexagonV";break;case"global-function":svgOpts.char="F";svgOpts.color="accent";svgOpts.shape="circle";break;case"function":svgOpts.char="F";svgOpts.color="accent";svgOpts.shape="circle";break;case"method":svgOpts.char="M";svgOpts.color="cyan";svgOpts.shape="circle";break;case"property":svgOpts.char="P";svgOpts.color="yellow";svgOpts.shape="square";break;case"enum":svgOpts.char="e";svgOpts.color="orange";svgOpts.shape="pentagonUp";break;case"event":svgOpts.char="E";svgOpts.color="blue-pale";svgOpts.shape="octagon";break;case"member":svgOpts.char="m";svgOpts.color="ice-blue";svgOpts.shape="square";break;default:svgOpts.title="";svgOpts.char="•";svgOpts.color="black";svgOpts.shape="square"}return{kind:kind,scope:scope||"",char:svgOpts.char,badge:app.svg.shape(svgOpts)}};function getSymbolData(symbol){if(!symbol){return{kind:"Unknown",char:"",badge:app.svg.error()}}if(DocmaWeb.Utils.isClass(symbol))return helper.getSymbolInfo("class",symbol.scope);if(DocmaWeb.Utils.isConstant(symbol))return helper.getSymbolInfo("constant",symbol.scope);if(DocmaWeb.Utils.isTypeDef(symbol))return helper.getSymbolInfo("typedef",symbol.scope);if(DocmaWeb.Utils.isConstructor(symbol))return helper.getSymbolInfo("constructor",symbol.scope);if(DocmaWeb.Utils.isNamespace(symbol))return helper.getSymbolInfo("namespace",symbol.scope);if(DocmaWeb.Utils.isModule(symbol))return helper.getSymbolInfo("module",symbol.scope);if(DocmaWeb.Utils.isEnum(symbol))return helper.getSymbolInfo("enum",symbol.scope);if(DocmaWeb.Utils.isEvent(symbol))return helper.getSymbolInfo("event",symbol.scope);if(DocmaWeb.Utils.isProperty(symbol))return helper.getSymbolInfo("property",symbol.scope);if(DocmaWeb.Utils.isMethod(symbol))return helper.getSymbolInfo("method",symbol.scope);if(symbol.kind==="member")return helper.getSymbolInfo("member",symbol.scope);return helper.getSymbolInfo()}function getTreeLine(treeNode,addClass){var cls="item-tree-line";if(addClass)cls+=" "+addClass;if(treeNode==="parent")cls+=" item-tree-parent";return''}function getTreeLineImgs(levels,treeNode,hasChildren,lastNodeLevels){var imgs=[];if(hasChildren)imgs=[getTreeLine("parent","absolute")];if(treeNode==="first"){if(levels>1)return getTreeLineImgs(levels,"node",hasChildren)}else{imgs.unshift(getTreeLine(treeNode))}var deeps=[];if(levels>2){var i;for(i=2;i";labelMargin=25}else{labelMargin=31}var labelStyle=' style="margin-left: '+labelMargin+'px !important; "';var itemTitle=errMessage?' title="'+errMessage+'"':"";return'
'+treeImages+badge+'
"+'
'+'
'+name+"
"+"
"+"
"}function getSidebarNavItem(symbol,parentSymbol,isLast,lastNodeLevels){var treeNode=parentSymbol?isLast?"last":"node":"first";var id=dust.filters.$id(symbol);var keywords=DocmaWeb.Utils.getKeywords(symbol);var symbolData=getSymbolData(symbol);var badge=templateOpts.sidebar.badges===true?symbolData.badge||"":typeof templateOpts.sidebar.badges==="string"?templateOpts.sidebar.badges:" • ";var hasChildren=helper.hasChildren(symbol);var innerHTML=getSidebarNavItemInner(badge,symbol.$longname,treeNode,hasChildren,lastNodeLevels);var chevron="";if(hasChildren){chevron='
'}return chevron+''+innerHTML+""}helper.buildSidebarNodes=function(symbolNames,symbols,parentSymbol,lastNodeLevels){lastNodeLevels=lastNodeLevels||0;symbols=symbols||docma.documentation;var items=[];symbols.forEach(function(symbol,index){if(symbolNames.indexOf(symbol.$longname)===-1)return;if(DocmaWeb.Utils.isConstructor(symbol)&&symbol.hideconstructor===true){return}var isLast=index===symbols.length-1;var navItem=getSidebarNavItem(symbol,parentSymbol,isLast,lastNodeLevels);var currentLastLevel=isLast?DocmaWeb.Utils.getLevels(symbol):lastNodeLevels;var members="";if(helper.hasChildren(symbol)){members='
    '+helper.buildSidebarNodes(symbolNames,symbol.$members,symbol,currentLastLevel).join("")+"
"}items.push("
  • "+navItem+members+"
  • ")});return items};var RE_KIND=/(?:\bkind:\s*)([^, ]+(?:\s*,\s*[^, ]+)*)?/gi;var RE_SCOPE=/(?:\bscope:\s*)([^, ]+(?:\s*,\s*[^, ]+)*)?/gi;function SidebarSearch(){this.reset()}SidebarSearch.prototype.reset=function(){this.scope=[];this.kind=[];this.keywords=[]};SidebarSearch.prototype.parseKeywords=function(string){var kw=(string||"").replace(RE_KIND,"").replace(RE_SCOPE,"").trim().replace(/\s+/," ");this.keywords=kw?kw.split(" "):[];return this};SidebarSearch.prototype.parse=function(string){if(!string){this.kind=[];this.scope=[];this.keywords=[];return this}var m=RE_KIND.exec(string);if(!m||m.length<2||!m[1]||m.indexOf("*")>=0){this.kind=[]}else{this.kind=m[1].split(",").map(function(k){return k.toLocaleLowerCase().trim()})}m=RE_SCOPE.exec(string);if(!m||m.length<2||!m[1]||m.indexOf("*")>=0){this.scope=[]}else{this.scope=m[1].split(",").map(function(s){return s.toLocaleLowerCase().trim()})}RE_KIND.lastIndex=0;RE_SCOPE.lastIndex=0;this.parseKeywords(string);return this};SidebarSearch.prototype.hasScope=function(scope){return this.scope.indexOf(scope)>=0};SidebarSearch.prototype.removeScope=function(scope){helper.removeFromArray(this.scope,scope)};SidebarSearch.prototype.addScope=function(scope){helper.addToArray(this.scope,scope)};SidebarSearch.prototype.hasKind=function(kind){return this.kind.indexOf(kind)>=0};SidebarSearch.prototype.removeKind=function(kind){helper.removeFromArray(this.kind,kind)};SidebarSearch.prototype.addKind=function(kind){helper.addToArray(this.kind,kind)};SidebarSearch.prototype.matchesAnyKeyword=function(keywords){return this.keywords.some(function(kw){return keywords.indexOf(kw.toLocaleLowerCase())>=0})};SidebarSearch.prototype.toObject=function(){return{scope:this.scope,kind:this.kind,keywords:this.keywords}};SidebarSearch.prototype.toString=function(){var s="";if(Array.isArray(this.keywords)&&this.keywords.length>0){s=this.keywords.join(" ")+" "}if(Array.isArray(this.scope)&&this.scope.length>0){s+="scope:"+this.scope.join(",")+" "}if(Array.isArray(this.kind)&&this.kind.length>0){s+="kind:"+this.kind.join(",")}return s.trim()};app.SidebarSearch=SidebarSearch;app.helper=helper})();(function(){"use strict";var templateOpts=docma.template.options;function dotProp(name,forSidebar){var re=/(.*)([.#~][\w:]+)/g,match=re.exec(name);if(!match)return''+name+"";if(forSidebar){var cls=templateOpts.sidebar.animations?" trans-all-ease-fast":"";return''+app.helper.colorOperators(match[1])+""+app.helper.colorOperators(match[2])+""}return''+app.helper.colorOperators(match[1])+''+app.helper.colorOperators(match[2])+""}docma.addFilter("$color_ops",function(name){return app.helper.colorOperators(name)}).addFilter("$dot_prop_sb",function(name){return dotProp(name,true)}).addFilter("$dot_prop",function(name){return dotProp(name,false)}).addFilter("$author",function(symbol){var authors=Array.isArray(symbol)?symbol:symbol.author||[];return authors.join(", ")}).addFilter("$type",function(symbol){if(DocmaWeb.Utils.isConstructor(symbol))return"";var opts={links:templateOpts.symbols.autoLink};if(symbol.kind==="function"){var returnTypes=DocmaWeb.Utils.getReturnTypes(docma.apis,symbol,opts);return returnTypes?returnTypes:""}var types=DocmaWeb.Utils.getTypes(docma.apis,symbol,opts);return types?types:""}).addFilter("$type_sep",function(symbol){if(DocmaWeb.Utils.isConstructor(symbol))return"";if(symbol.kind==="function")return"⇒";if(symbol.kind==="event"&&symbol.type)return"⇢";if(symbol.kind==="class")return":";if(!symbol.type&&!symbol.returns)return"";return":"}).addFilter("$param_desc",function(param){return DocmaWeb.Utils.parse(param.description||"")}).addFilter("$longname",function(symbol){if(typeof symbol==="string")return symbol;var nw=DocmaWeb.Utils.isConstructor(symbol)?"new ":"";return nw+symbol.$longname}).addFilter("$longname_params",function(symbol){var isCon=DocmaWeb.Utils.isConstructor(symbol),longName=app.helper.colorOperators(symbol.$longname);if(symbol.kind==="function"||isCon){var defVal,defValHtml="",nw=isCon?"new ":"",name=nw+longName+"(";if(Array.isArray(symbol.params)){var params=symbol.params.reduce(function(memo,param){if(param&¶m.name.indexOf(".")===-1){defVal=param.hasOwnProperty("defaultvalue")?String(param.defaultvalue):"undefined";defValHtml=param.optional?'='+defVal+"":"";var rest=param.variable?"...":"";memo.push(rest+param.name+defValHtml)}return memo},[]).join(", ");name+=params}return name+")"}return longName}).addFilter("$extends",function(symbol){var ext=Array.isArray(symbol)?symbol:symbol.augments;return DocmaWeb.Utils.getCodeTags(docma.apis,ext,{delimeter:", ",links:templateOpts.symbols.autoLink})}).addFilter("$returns",function(symbol){var returns=Array.isArray(symbol)?symbol:symbol.returns;return DocmaWeb.Utils.getFormattedTypeList(docma.apis,returns,{delimeter:"|",descriptions:true,links:templateOpts.symbols.autoLink})}).addFilter("$yields",function(symbol){var yields=Array.isArray(symbol)?symbol:symbol.yields;return DocmaWeb.Utils.getFormattedTypeList(docma.apis,yields,{delimeter:"|",descriptions:true,links:templateOpts.symbols.autoLink})}).addFilter("$emits",function(symbol){var emits=Array.isArray(symbol)?symbol:symbol.fires;return DocmaWeb.Utils.getEmittedEvents(docma.apis,emits,{delimeter:", ",links:templateOpts.symbols.autoLink})}).addFilter("$exceptions",function(symbol){var exceptions=Array.isArray(symbol)?symbol:symbol.exceptions;return DocmaWeb.Utils.getFormattedTypeList(docma.apis,exceptions,{delimeter:"|",descriptions:true,links:templateOpts.symbols.autoLink})}).addFilter("$tags",function(symbol){var openIce='',openIceDark='',openBlue='',openGreenPale='',openYellow='',openPurple='',openRed='',openPink='',openBrown='',close="",tagBoxes=[];if(DocmaWeb.Utils.isDeprecated(symbol)){tagBoxes.push(openYellow+"deprecated"+close)}if(DocmaWeb.Utils.isGlobal(symbol)&&!DocmaWeb.Utils.isConstructor(symbol)){tagBoxes.push(openPurple+"global"+close)}if(DocmaWeb.Utils.isStatic(symbol)){tagBoxes.push(openBlue+"static"+close)}if(DocmaWeb.Utils.isInner(symbol)){tagBoxes.push(openIceDark+"inner"+close)}if(DocmaWeb.Utils.isModule(symbol)){tagBoxes.push(openRed+"module"+close)}if(DocmaWeb.Utils.isConstructor(symbol)){tagBoxes.push(openGreenPale+"constructor"+close)}if(DocmaWeb.Utils.isNamespace(symbol)){tagBoxes.push(openPink+"namespace"+close)}if(DocmaWeb.Utils.isGenerator(symbol)){tagBoxes.push(openBlue+"generator"+close)}if(DocmaWeb.Utils.isPublic(symbol)===false){tagBoxes.push(openIceDark+symbol.access+close)}if(DocmaWeb.Utils.isReadOnly(symbol)){tagBoxes.push(openIceDark+"readonly"+close)}if(DocmaWeb.Utils.isConstant(symbol)){tagBoxes.push(openBrown+"constant"+close)}var tags=Array.isArray(symbol)?symbol:symbol.tags||[];var tagTitles=tags.map(function(tag){return openIce+tag.originalTitle+close});tagBoxes=tagBoxes.concat(tagTitles);if(tagBoxes.length)return"  "+tagBoxes.join(" ");return""}).addFilter("$navnodes",function(symbolNames){return app.helper.buildSidebarNodes(symbolNames).join("")}).addFilter("$get_caption",function(example){var m=app.RE_EXAMPLE_CAPTION.exec(example||"");return m&&m[1]?" — "+DocmaWeb.Utils.parseTicks(m[1])+"":""}).addFilter("$remove_caption",function(example){return(example||"").replace(app.RE_EXAMPLE_CAPTION,"")})})();var app=window.app||{};(function(){"use strict";var helper=app.helper;var templateOpts=docma.template.options;var $sidebarNodes,$btnClean,$txtSearch;var $wrapper,$sidebarWrapper,$sidebarToggle;var $nbmBtn,$navOverlay,$navbarMenu,$navbarBrand,$navbarInner,$navbarList;var $btnSwitchFold,$btnSwitchOutline;var $scopeFilters,$scopeFilterBtns,$kindFilters,$kindFilterBtns;var navbarMenuActuallWidth;var isFilterActive=false;var isItemsFolded=templateOpts.sidebar.itemsFolded;var isApiRoute=false;var SidebarSearch=app.SidebarSearch;var sbSearch=new SidebarSearch;function setTitleSize(){var sb=templateOpts.sidebar.enabled;var nb=templateOpts.navbar.enabled;if(!sb&&!nb)return;var $a=sb?$(".sidebar-title a"):$(".navbar-title a");if($a.height()>18){var css={"font-size":"16px"};$a.parent().css(css);if(nb){$(".navbar-title").css(css)}}}function getCurrentOutline(){return isFilterActive?"flat":templateOpts.sidebar.outline}function setSidebarNodesOutline(outline){outline=outline||templateOpts.sidebar.outline;var isTree=outline==="tree";var $labels=$sidebarNodes.find(".item-label");if(isTree){$sidebarNodes.find(".item-tree-line").show();$labels.find(".symbol-memberof").addClass("no-width")}else{$sidebarNodes.find(".item-tree-line").hide();$labels.find(".symbol-memberof").removeClass("no-width")}$labels.removeClass("crop-to-fit");var delay=templateOpts.sidebar.animations?templateOpts.sidebar.itemsOverflow==="shrink"?0:240:0;setTimeout(function(){$labels.each(function(){helper.fitSidebarNavItems($(this),outline)})},delay);if(templateOpts.sidebar.itemsOverflow==="crop"){$labels.addClass("crop-to-fit");var $inners=$labels.find(".inner");$inners.css("text-overflow","clip")}}function cleanFilter(){sbSearch.reset();if(!templateOpts.sidebar.enabled||!$sidebarNodes)return;setFilterBtnStates();if($txtSearch)$txtSearch.val("");$sidebarNodes.removeClass("hidden");if($btnClean)$btnClean.hide();$(".toolbar-buttons > span").css("color","#fff");$(".chevron").show();setTimeout(function(){setSidebarNodesOutline(templateOpts.sidebar.outline);if($txtSearch)$txtSearch.focus()},100);isFilterActive=false}function setFilterBtnStates(){if(!$scopeFilterBtns||!$kindFilterBtns)return;$scopeFilterBtns.removeClass("active");sbSearch.scope.forEach(function(s){$scopeFilters.find('[data-scope="'+s+'"]').addClass("active")});$kindFilterBtns.removeClass("active");sbSearch.kind.forEach(function(s){$kindFilters.find('[data-kind="'+s+'"]').addClass("active")})}function applySearch(strSearch){sbSearch.parse(strSearch);setFilterBtnStates();$sidebarNodes.each(function(){var node=$(this);var show=true;if(sbSearch.scope.length>0){show=sbSearch.hasScope(node.attr("data-scope"))}if(show&&sbSearch.kind.length>0){show=sbSearch.hasKind(node.attr("data-kind"))}if(show&&sbSearch.keywords.length>0){show=sbSearch.matchesAnyKeyword(node.attr("data-keywords"))}if(show){node.removeClass("hidden")}else{node.addClass("hidden")}})}var debounceApplySearch=helper.debounce(applySearch,100,false);function filterSidebarNodes(strSearch){if(!templateOpts.sidebar.enabled)return;strSearch=(strSearch||"").trim().toLowerCase();if(!strSearch){cleanFilter();return}if($btnClean)$btnClean.show();toggleAllSubTrees(false);$(".chevron").hide();setFoldState(false);isFilterActive=true;setSidebarNodesOutline("flat");debounceApplySearch(strSearch);$(".toolbar-buttons > span").css("color","#3f4450")}function toggleSubTree(elem,fold){fold=typeof fold!=="boolean"?!elem.hasClass("members-folded"):fold;var parent;if(fold){parent=elem.addClass("members-folded").parent();parent.find(".item-members:first").addClass("no-height");parent.find(".item-inner > img.item-tree-parent").attr("src","img/tree-folded.png");setFoldState(true)}else{parent=elem.removeClass("members-folded").parent();parent.find(".item-members:first").removeClass("no-height");parent.find(".item-inner > img.item-tree-parent").attr("src","img/tree-parent.png")}}function toggleAllSubTrees(fold){$(".chevron").each(function(){toggleSubTree($(this),fold)})}function setFoldState(folded){var $btni=$btnSwitchFold.find("[data-fa-i2svg]").removeClass("fa-caret-square-right fa-caret-square-down");var newCls=!folded?"fa-caret-square-down":"fa-caret-square-right";isItemsFolded=folded;$btni.addClass(newCls)}function toggleHamMenu(show){if(!$nbmBtn)return;var fn=show?"addClass":"removeClass";$nbmBtn[fn]("toggled");$navOverlay[fn]("toggled");$navbarMenu[fn]("toggled");helper.toggleBodyScroll(!show);if(show){$navbarMenu.scrollTop(0);if($sidebarWrapper&&$sidebarWrapper.length){$wrapper.removeClass("toggled");$sidebarToggle.removeClass("toggled");$sidebarToggle.css("opacity",0)}}else{$sidebarToggle.css("opacity",1)}}function breakNavbarMenu(){if(!navbarMenuActuallWidth){navbarMenuActuallWidth=$navbarMenu.width()||500}var diff=$sidebarWrapper&&$sidebarWrapper.length?app.SIDEBAR_WIDTH:$navbarBrand.width();var breakMenu=($navbarInner.width()||0)-diff<=navbarMenuActuallWidth+50;if(breakMenu){if($nbmBtn.hasClass("break"))return;$nbmBtn.addClass("break");$navbarMenu.addClass("break");$navbarList.addClass("break")}else{toggleHamMenu(false);if(!$nbmBtn.hasClass("break"))return;$nbmBtn.removeClass("break");$navbarMenu.removeClass("break");$navbarList.removeClass("break")}}function checkOpenDetails(){if(docma.location.hash){var elem=$("details#"+$.escapeSelector(docma.location.hash));if(elem&&elem[0])elem.attr("open","")}}hljs.configure({tabReplace:" ",useBR:false});if(!templateOpts.title){templateOpts.title=docma.app.title||"Documentation"}docma.once("ready",function(){setTitleSize()});docma.on("render",function(currentRoute){isApiRoute=currentRoute&¤tRoute.type==="api";$("table").each(function(){$(this).html($.trim($(this).html()))});$("table:empty").remove();$wrapper=$("#wrapper");$sidebarWrapper=$("#sidebar-wrapper");$sidebarToggle=$("#sidebar-toggle");if(templateOpts.sidebar.animations){$wrapper.addClass("trans-all-ease");$sidebarWrapper.addClass("trans-all-ease")}else{$wrapper.removeClass("trans-all-ease");$sidebarWrapper.removeClass("trans-all-ease")}if(!templateOpts.navbar.enabled){$("body, html").css("padding-top",0);$sidebarWrapper.css("margin-top",0);$(".symbol-container").css({"padding-top":0,"margin-top":0})}else{$navbarInner=$(".navbar-inner");$navbarList=$(".navbar-list");$navbarBrand=$(".navbar-brand");$nbmBtn=$(".navbar-menu-btn");$navOverlay=$(".nav-overlay");$navbarMenu=$(".navbar-menu");if(!templateOpts.navbar.animations){$navOverlay.addClass("no-trans-force");$navbarMenu.addClass("no-trans-force");$navbarList.addClass("no-trans-force").find("ul").addClass("no-trans-force")}var navMargin=isApiRoute?55:0;$(".navbar-brand").css({"margin-left":navMargin+"px"});$(".navbar-menu").css({"margin-right":navMargin+"px"});$nbmBtn.on("click",function(){toggleHamMenu(!$navbarMenu.hasClass("toggled"))});var deBreakNavbarMenu=helper.debounce(breakNavbarMenu,50,false);setTimeout(function(){breakNavbarMenu();$(window).on("resize",deBreakNavbarMenu)},300);$navbarList.find('a[href="#"]').on("click",function(event){event.preventDefault()})}var examples=$("#docma-main pre > code");examples.each(function(i,block){hljs.highlightBlock(block)});checkOpenDetails();if(isApiRoute===false){$("table").addClass("table table-striped table-bordered");if(templateOpts.contentView.bookmarks){var bmSelector=typeof templateOpts.contentView.bookmarks==="string"?templateOpts.contentView.bookmarks:":header";$(bmSelector).each(function(){var bmHeading=$(this);var bmId=bmHeading.attr("id");if(bmId){bmHeading.addClass("zebra-bookmark").prepend('')}})}return}function searchHandler(){if(!$txtSearch)return;filterSidebarNodes($txtSearch.val())}var debounceSearchHandler=helper.debounce(searchHandler,200);function getFilterClickHandler(filter){var isKind=filter==="kind";var has=isKind?sbSearch.hasKind:sbSearch.hasScope;var add=isKind?sbSearch.addKind:sbSearch.addScope;var remove=isKind?sbSearch.removeKind:sbSearch.removeScope;return function(event){var btn=$(this);var value=(btn.attr("data-"+filter)||"*").toLowerCase();if(has.call(sbSearch,value)){remove.call(sbSearch,value)}else if(event.shiftKey){add.call(sbSearch,value)}else{sbSearch[filter]=[value]}var strSearch;if($txtSearch){sbSearch.parseKeywords($txtSearch.val());strSearch=sbSearch.toString();$txtSearch.val(strSearch).focus();if($btnClean)$btnClean.show()}else{sbSearch.keywords=[];strSearch=sbSearch.toString()}filterSidebarNodes(strSearch)}}if(templateOpts.sidebar.enabled){var sidebarHeaderHeight;if(templateOpts.sidebar.search){sidebarHeaderHeight=130;if(templateOpts.sidebar.toolbar)sidebarHeaderHeight+=app.TOOLBAR_HEIGHT}else{sidebarHeaderHeight=app.NAVBAR_HEIGHT;if(templateOpts.sidebar.toolbar)sidebarHeaderHeight+=app.TOOLBAR_HEIGHT+10}$(".sidebar-nav-container").css("top",sidebarHeaderHeight);$(".sidebar-header").css("height",sidebarHeaderHeight);if(templateOpts.sidebar.search){$btnClean=$(".sidebar-search-clean");$txtSearch=$("#txt-search");if($btnClean){$btnClean.hide();$btnClean.on("mousedown",cleanFilter)}if($txtSearch){$txtSearch.on("keyup",debounceSearchHandler);$txtSearch.on("change",searchHandler);$(".sidebar-search-icon").on("click",function(){$txtSearch.focus()});if(templateOpts.sidebar.animations){$txtSearch.addClass("trans-all-ease")}}}else{$(".sidebar-nav").css("top","0px")}$sidebarNodes=$("ul.sidebar-nav .sidebar-item");if(templateOpts.sidebar.animations){$sidebarNodes.addClass("trans-height-ease")}setSidebarNodesOutline();$btnSwitchOutline=$(".toolbar-buttons .btn-switch-outline");$btnSwitchFold=$(".toolbar-buttons .btn-switch-fold");toggleAllSubTrees(isItemsFolded);if(!templateOpts.sidebar.collapsed){$wrapper.addClass("toggled");$sidebarToggle.addClass("toggled")}$sidebarToggle.on("click",function(event){event.preventDefault();$wrapper.toggleClass("toggled");$sidebarToggle.toggleClass("toggled")});$(".chevron").on("click",function(){toggleSubTree($(this))});if(templateOpts.sidebar.toolbar){var kindButtons=helper.getSymbolInfo("namespace",null,true).badge+helper.getSymbolInfo("module",null,true).badge+helper.getSymbolInfo("typedef",null,true).badge+helper.getSymbolInfo("class",null,true).badge+helper.getSymbolInfo("method",null,true).badge+helper.getSymbolInfo("property",null,true).badge+helper.getSymbolInfo("enum",null,true).badge+helper.getSymbolInfo("event",null,true).badge;$kindFilters=$(".toolbar-kind-filters").html(kindButtons);$kindFilterBtns=$kindFilters.find(".badge-btn").on("click",getFilterClickHandler("kind"));var scopeButtons=helper.getScopeInfo("global").badge+helper.getScopeInfo("static").badge+helper.getScopeInfo("instance").badge+helper.getScopeInfo("inner").badge;$scopeFilters=$(".toolbar-scope-filters").html(scopeButtons);$scopeFilterBtns=$scopeFilters.find(".badge-scope-btn").on("click",getFilterClickHandler("scope"));$btnSwitchFold.on("click",function(){if(isFilterActive)return;setFoldState(!isItemsFolded);toggleAllSubTrees(isItemsFolded)});$btnSwitchOutline.on("click",function(){if(isFilterActive)return;var $btn=$(this);var $btni=$btn.find("[data-fa-i2svg]").removeClass("fa-outdent fa-indent");var newOutline,newCls;if(templateOpts.sidebar.outline==="flat"){newOutline="tree";newCls="fa-indent"}else{newOutline="flat";newCls="fa-outdent"}templateOpts.sidebar.outline=newOutline;$btni.addClass(newCls);setSidebarNodesOutline(newOutline)})}if(templateOpts.sidebar.itemsOverflow==="crop"){$sidebarNodes.hover(function(){setInnerMarginLeft($(this))},function(){setInnerMarginLeft($(this),true)})}}else{$wrapper.removeClass("toggled");$sidebarToggle.removeClass("toggled")}tippy("[title]",{placement:"bottom",animation:"scale",duration:200,arrow:true,appendTo:document.body,zIndex:9999999,theme:"zebra"})});function setInnerMarginLeft($elem,reset){var $inner=$elem.find(".crop-to-fit > .inner");var dMarginLeft="data-margin-"+getCurrentOutline();var m=parseInt($inner.attr(dMarginLeft),0)||0;$inner.css("margin-left",reset?0:m)}})(); -------------------------------------------------------------------------------- /docs/js/highlight.pack.js: -------------------------------------------------------------------------------- 1 | /*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ 2 | !function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
    ":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
    ",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}});hljs.registerLanguage("http",function(e){var t="HTTP/[0-9\\.]+";return{aliases:["https"],i:"\\S",c:[{b:"^"+t,e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{b:"^[A-Z]+ (.*?) "+t+"$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0},{b:t},{cN:"keyword",b:"[A-Z]+"}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{e:"$",r:0}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/\b-?[a-z\._]+\b/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,s,a,t]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("less",function(e){var r="[\\w-]+",t="("+r+"|@{"+r+"})",a=[],c=[],s=function(e){return{cN:"string",b:"~?"+e+".*?"+e}},b=function(e,r,t){return{cN:e,b:r,r:t}},n={b:"\\(",e:"\\)",c:c,r:0};c.push(e.CLCM,e.CBCM,s("'"),s('"'),e.CSSNM,{b:"(url|data-uri)\\(",starts:{cN:"string",e:"[\\)\\n]",eE:!0}},b("number","#[0-9A-Fa-f]+\\b"),n,b("variable","@@?"+r,10),b("variable","@{"+r+"}"),b("built_in","~?`[^`]*?`"),{cN:"attribute",b:r+"\\s*:",e:":",rB:!0,eE:!0},{cN:"meta",b:"!important"});var i=c.concat({b:"{",e:"}",c:a}),o={bK:"when",eW:!0,c:[{bK:"and not"}].concat(c)},u={b:t+"\\s*:",rB:!0,e:"[;}]",r:0,c:[{cN:"attribute",b:t,e:":",eE:!0,starts:{eW:!0,i:"[<=$]",r:0,c:c}}]},l={cN:"keyword",b:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{e:"[;{}]",rE:!0,c:c,r:0}},C={cN:"variable",v:[{b:"@"+r+"\\s*:",r:15},{b:"@"+r}],starts:{e:"[;}]",rE:!0,c:i}},p={v:[{b:"[\\.#:&\\[>]",e:"[;{}]"},{b:t,e:"{"}],rB:!0,rE:!0,i:"[<='$\"]",r:0,c:[e.CLCM,e.CBCM,o,b("keyword","all\\b"),b("variable","@{"+r+"}"),b("selector-tag",t+"%?",0),b("selector-id","#"+t),b("selector-class","\\."+t,0),b("selector-tag","&",0),{cN:"selector-attr",b:"\\[",e:"\\]"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"\\(",e:"\\)",c:i},{b:"!important"}]};return a.push(e.CLCM,e.CBCM,l,C,u,p),{cI:!0,i:"[=>'/<($\"]",c:a}});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[t],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[t],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}});hljs.registerLanguage("scss",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",i={cN:"variable",b:"(\\$"+t+")\\b"},r={cN:"number",b:"#[0-9A-Fa-f]+"};({cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{eW:!0,eE:!0,c:[r,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"meta",b:"!important"}]}});return{cI:!0,i:"[=/|']",c:[e.CLCM,e.CBCM,{cN:"selector-id",b:"\\#[A-Za-z0-9_-]+",r:0},{cN:"selector-class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"selector-attr",b:"\\[",e:"\\]",i:"$"},{cN:"selector-tag",b:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",r:0},{b:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{b:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},i,{cN:"attribute",b:"\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",i:"[^\\s]"},{b:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{b:":",e:";",c:[i,r,e.CSSNM,e.QSM,e.ASM,{cN:"meta",b:"!important"}]},{b:"@",e:"[{;]",k:"mixin include extend for if else each while charset import debug media page content font-face namespace warn",c:[i,e.QSM,e.ASM,r,e.CSSNM,{b:"\\s[A-Za-z0-9_.-]+",r:0}]}]}});hljs.registerLanguage("dust",function(e){var t="if eq ne lt lte gt gte select default math sep";return{aliases:["dst"],cI:!0,sL:"xml",c:[{cN:"template-tag",b:/\{[#\/]/,e:/\}/,i:/;/,c:[{cN:"name",b:/[a-zA-Z\.-]+/,starts:{eW:!0,r:0,c:[e.QSM]}}]},{cN:"template-variable",b:/\{/,e:/\}/,i:/;/,k:t}]}});hljs.registerLanguage("shell",function(s){return{aliases:["console"],c:[{cN:"meta",b:"^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]",starts:{e:"$",sL:"bash"}}]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:c,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}});hljs.registerLanguage("typescript",function(e){var r={keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class public private protected get set super static implements enum export import declare type namespace abstract as from extends async await",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document any number boolean string void Promise"};return{aliases:["ts"],k:r,c:[{cN:"meta",b:/^\s*['"]use strict['"]/},e.ASM,e.QSM,{cN:"string",b:"`",e:"`",c:[e.BE,{cN:"subst",b:"\\$\\{",e:"\\}"}]},e.CLCM,e.CBCM,{cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+e.IR+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:e.IR},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:["self",e.CLCM,e.CBCM]}]}]}],r:0},{cN:"function",b:"function",e:/[\{;]/,eE:!0,k:r,c:["self",e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:[e.CLCM,e.CBCM],i:/["'\(]/}],i:/%/,r:0},{bK:"constructor",e:/\{/,eE:!0,c:["self",{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:[e.CLCM,e.CBCM],i:/["'\(]/}]},{b:/module\./,k:{built_in:"module"},r:0},{bK:"module",e:/\{/,eE:!0},{bK:"interface",e:/\{/,eE:!0,k:"interface extends"},{b:/\$[(.]/},{b:"\\."+e.IR,r:0},{cN:"meta",b:"@[A-Za-z]+"}]}}); -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import { RequestHandler } from './typings/client/RequestHandler'; 2 | import { RequestManager, Request, EmittedInfo } from './typings/client/RequestManager'; 3 | import { AzumaIPC } from './typings/ratelimits/AzumaIPC'; 4 | import { AzumaManager } from './typings/ratelimits/AzumaManager'; 5 | import { AzumaRatelimit, ParsedHeaders } from './typings/ratelimits/AzumaRatelimit'; 6 | import { Azuma, RatelimitOptions } from './typings/Azuma'; 7 | import { Structures } from './typings/Structures'; 8 | import * as Constants from './typings/Constants'; 9 | 10 | export { 11 | RequestHandler, 12 | RequestManager, 13 | Request, 14 | EmittedInfo, 15 | AzumaIPC, 16 | AzumaManager, 17 | AzumaRatelimit, 18 | ParsedHeaders, 19 | Azuma, 20 | RatelimitOptions, 21 | Structures, 22 | Constants 23 | }; 24 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import RequestHandler from './src/client/RequestHandler.js'; 2 | import RequestManager from './src/client/RequestManager.js'; 3 | import AzumaIPC from './src/ratelimits/AzumaIPC.js'; 4 | import AzumaManager from './src/ratelimits/AzumaManager.js'; 5 | import AzumaRatelimit from './src/ratelimits/AzumaRatelimit.js'; 6 | import Azuma from './src/Azuma.js'; 7 | import Structures from './src/Structures.js'; 8 | import Constants from './src/Constants.js'; 9 | 10 | export { 11 | RequestHandler, 12 | RequestManager, 13 | AzumaIPC, 14 | AzumaManager, 15 | AzumaRatelimit, 16 | Azuma, 17 | Structures, 18 | Constants 19 | }; -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azuma", 3 | "version": "3.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "azuma", 9 | "version": "3.0.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@sapphire/async-queue": "^1.1.7", 13 | "cheshire": "github:Deivu/Cheshire#2.0.2", 14 | "discord.js": ">=13.0.0", 15 | "kurasuta": "^3.0.1" 16 | } 17 | }, 18 | "node_modules/@discordjs/builders": { 19 | "version": "0.6.0", 20 | "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.6.0.tgz", 21 | "integrity": "sha512-mH3Gx61LKk2CD05laCI9K5wp+a3NyASHDUGx83DGJFkqJlRlSV5WMJNY6RS37A5SjqDtGMF4wVR9jzFaqShe6Q==", 22 | "dependencies": { 23 | "@sindresorhus/is": "^4.0.1", 24 | "discord-api-types": "^0.22.0", 25 | "ow": "^0.27.0", 26 | "ts-mixer": "^6.0.0", 27 | "tslib": "^2.3.1" 28 | }, 29 | "engines": { 30 | "node": ">=14.0.0", 31 | "npm": ">=7.0.0" 32 | } 33 | }, 34 | "node_modules/@discordjs/builders/node_modules/discord-api-types": { 35 | "version": "0.22.0", 36 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz", 37 | "integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==", 38 | "engines": { 39 | "node": ">=12" 40 | } 41 | }, 42 | "node_modules/@discordjs/collection": { 43 | "version": "0.2.1", 44 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.2.1.tgz", 45 | "integrity": "sha512-vhxqzzM8gkomw0TYRF3tgx7SwElzUlXT/Aa41O7mOcyN6wIJfj5JmDWaO5XGKsGSsNx7F3i5oIlrucCCWV1Nog==", 46 | "engines": { 47 | "node": ">=14.0.0" 48 | } 49 | }, 50 | "node_modules/@discordjs/form-data": { 51 | "version": "3.0.1", 52 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", 53 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", 54 | "dependencies": { 55 | "asynckit": "^0.4.0", 56 | "combined-stream": "^1.0.8", 57 | "mime-types": "^2.1.12" 58 | }, 59 | "engines": { 60 | "node": ">= 6" 61 | } 62 | }, 63 | "node_modules/@sapphire/async-queue": { 64 | "version": "1.1.7", 65 | "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.7.tgz", 66 | "integrity": "sha512-EBRERa9NqK/EV6DIPBVtjjdHBsu/DSdMuYAydmoIyIPONzp0UAxf2G6JGJ52WkiONtPRx6KNuqB5Q8dm14fwyw==", 67 | "engines": { 68 | "node": ">=v14.0.0", 69 | "npm": ">=7.0.0" 70 | } 71 | }, 72 | "node_modules/@sindresorhus/is": { 73 | "version": "4.2.0", 74 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", 75 | "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==", 76 | "engines": { 77 | "node": ">=10" 78 | }, 79 | "funding": { 80 | "url": "https://github.com/sindresorhus/is?sponsor=1" 81 | } 82 | }, 83 | "node_modules/@types/node": { 84 | "version": "16.10.3", 85 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.3.tgz", 86 | "integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==" 87 | }, 88 | "node_modules/@types/ws": { 89 | "version": "8.2.0", 90 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.0.tgz", 91 | "integrity": "sha512-cyeefcUCgJlEk+hk2h3N+MqKKsPViQgF5boi9TTHSK+PoR9KWBb/C5ccPcDyAqgsbAYHTwulch725DV84+pSpg==", 92 | "dependencies": { 93 | "@types/node": "*" 94 | } 95 | }, 96 | "node_modules/asynckit": { 97 | "version": "0.4.0", 98 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 99 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 100 | }, 101 | "node_modules/binarytf": { 102 | "version": "2.0.0", 103 | "resolved": "https://registry.npmjs.org/binarytf/-/binarytf-2.0.0.tgz", 104 | "integrity": "sha512-CS0MvijAFAHBBw4LgIHBP7wzdW3KWEB0KeMjblK0rHOyyhnkoMu3puW7uhJXlnS5WDn5M2XQFaQBtw00FwRfcA==" 105 | }, 106 | "node_modules/callsites": { 107 | "version": "3.1.0", 108 | "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", 109 | "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", 110 | "engines": { 111 | "node": ">=6" 112 | } 113 | }, 114 | "node_modules/cheshire": { 115 | "version": "2.0.2", 116 | "resolved": "git+ssh://git@github.com/Deivu/Cheshire.git#a664eb2928b556bc1317649afb43c3948dbd0de3", 117 | "license": "MIT", 118 | "dependencies": { 119 | "@discordjs/collection": "^0.2.1", 120 | "fun-dispatcher": "^1.2.6" 121 | }, 122 | "engines": { 123 | "node": ">=14.0.0" 124 | } 125 | }, 126 | "node_modules/combined-stream": { 127 | "version": "1.0.8", 128 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 129 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 130 | "dependencies": { 131 | "delayed-stream": "~1.0.0" 132 | }, 133 | "engines": { 134 | "node": ">= 0.8" 135 | } 136 | }, 137 | "node_modules/delayed-stream": { 138 | "version": "1.0.0", 139 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 140 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 141 | "engines": { 142 | "node": ">=0.4.0" 143 | } 144 | }, 145 | "node_modules/discord-api-types": { 146 | "version": "0.23.1", 147 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.23.1.tgz", 148 | "integrity": "sha512-igWmn+45mzXRWNEPU25I/pr8MwxHb767wAr51oy3VRLRcTlp5ADBbrBR0lq3SA1Rfw3MtM4TQu1xo3kxscfVdQ==", 149 | "engines": { 150 | "node": ">=12" 151 | } 152 | }, 153 | "node_modules/discord.js": { 154 | "version": "13.2.0", 155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.2.0.tgz", 156 | "integrity": "sha512-nyxUvL8wuQG38zx13wUMkpcA8koFszyiXdkSLwwM9opKW2LC2H5gD0cTZxImeJ6GtEnKPWT8xBiE8lLBmbNIhw==", 157 | "dependencies": { 158 | "@discordjs/builders": "^0.6.0", 159 | "@discordjs/collection": "^0.2.1", 160 | "@discordjs/form-data": "^3.0.1", 161 | "@sapphire/async-queue": "^1.1.5", 162 | "@types/ws": "^8.2.0", 163 | "discord-api-types": "^0.23.1", 164 | "node-fetch": "^2.6.1", 165 | "ws": "^8.2.3" 166 | }, 167 | "engines": { 168 | "node": ">=16.6.0", 169 | "npm": ">=7.0.0" 170 | } 171 | }, 172 | "node_modules/dot-prop": { 173 | "version": "6.0.1", 174 | "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", 175 | "integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==", 176 | "dependencies": { 177 | "is-obj": "^2.0.0" 178 | }, 179 | "engines": { 180 | "node": ">=10" 181 | }, 182 | "funding": { 183 | "url": "https://github.com/sponsors/sindresorhus" 184 | } 185 | }, 186 | "node_modules/fun-dispatcher": { 187 | "version": "1.2.6", 188 | "resolved": "https://registry.npmjs.org/fun-dispatcher/-/fun-dispatcher-1.2.6.tgz", 189 | "integrity": "sha512-lw6LoVrReV6qlaADvy0ua9a1f3W9qGLd8BBfLnzIV0YCfZd3jo5caZsgBBGOw/tO50P783iFEK8aTSwtQ67KDQ==", 190 | "engines": { 191 | "node": ">=12.1" 192 | } 193 | }, 194 | "node_modules/is-obj": { 195 | "version": "2.0.0", 196 | "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", 197 | "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", 198 | "engines": { 199 | "node": ">=8" 200 | } 201 | }, 202 | "node_modules/kurasuta": { 203 | "version": "3.0.1", 204 | "resolved": "https://registry.npmjs.org/kurasuta/-/kurasuta-3.0.1.tgz", 205 | "integrity": "sha512-RW5tAdwgAcfMsY8uJpVe6Wk/UlF2HHLzZcPFJQQRDjBdSVUVSlYmqnxQeHwwuyykkpGlftd+gv0Cp5p4WMjW+A==", 206 | "dependencies": { 207 | "discord.js": "^13.1.0", 208 | "node-fetch": "^2.6.2", 209 | "veza": "^1.1.0" 210 | } 211 | }, 212 | "node_modules/lodash.isequal": { 213 | "version": "4.5.0", 214 | "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", 215 | "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" 216 | }, 217 | "node_modules/mime-db": { 218 | "version": "1.50.0", 219 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz", 220 | "integrity": "sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A==", 221 | "engines": { 222 | "node": ">= 0.6" 223 | } 224 | }, 225 | "node_modules/mime-types": { 226 | "version": "2.1.33", 227 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz", 228 | "integrity": "sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g==", 229 | "dependencies": { 230 | "mime-db": "1.50.0" 231 | }, 232 | "engines": { 233 | "node": ">= 0.6" 234 | } 235 | }, 236 | "node_modules/node-fetch": { 237 | "version": "2.6.5", 238 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz", 239 | "integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==", 240 | "dependencies": { 241 | "whatwg-url": "^5.0.0" 242 | }, 243 | "engines": { 244 | "node": "4.x || >=6.0.0" 245 | } 246 | }, 247 | "node_modules/ow": { 248 | "version": "0.27.0", 249 | "resolved": "https://registry.npmjs.org/ow/-/ow-0.27.0.tgz", 250 | "integrity": "sha512-SGnrGUbhn4VaUGdU0EJLMwZWSupPmF46hnTRII7aCLCrqixTAC5eKo8kI4/XXf1eaaI8YEVT+3FeGNJI9himAQ==", 251 | "dependencies": { 252 | "@sindresorhus/is": "^4.0.1", 253 | "callsites": "^3.1.0", 254 | "dot-prop": "^6.0.1", 255 | "lodash.isequal": "^4.5.0", 256 | "type-fest": "^1.2.1", 257 | "vali-date": "^1.0.0" 258 | }, 259 | "engines": { 260 | "node": ">=12" 261 | }, 262 | "funding": { 263 | "url": "https://github.com/sponsors/sindresorhus" 264 | } 265 | }, 266 | "node_modules/tr46": { 267 | "version": "0.0.3", 268 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 269 | "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" 270 | }, 271 | "node_modules/ts-mixer": { 272 | "version": "6.0.0", 273 | "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz", 274 | "integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ==" 275 | }, 276 | "node_modules/tslib": { 277 | "version": "2.3.1", 278 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", 279 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" 280 | }, 281 | "node_modules/type-fest": { 282 | "version": "1.4.0", 283 | "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.4.0.tgz", 284 | "integrity": "sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==", 285 | "engines": { 286 | "node": ">=10" 287 | }, 288 | "funding": { 289 | "url": "https://github.com/sponsors/sindresorhus" 290 | } 291 | }, 292 | "node_modules/vali-date": { 293 | "version": "1.0.0", 294 | "resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz", 295 | "integrity": "sha1-G5BKWWCfsyjvB4E4Qgk09rhnCaY=", 296 | "engines": { 297 | "node": ">=0.10.0" 298 | } 299 | }, 300 | "node_modules/veza": { 301 | "version": "1.1.0", 302 | "resolved": "https://registry.npmjs.org/veza/-/veza-1.1.0.tgz", 303 | "integrity": "sha512-JxDVZZXwFJ+FxsX+kPdsjRK9XZdwayEYzPsPLxpZjzzgncWphjvMlzn8ioVAgeonZ/Aa7vEZOb4Hp13ergwybA==", 304 | "dependencies": { 305 | "binarytf": "^2.0.0" 306 | } 307 | }, 308 | "node_modules/webidl-conversions": { 309 | "version": "3.0.1", 310 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 311 | "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" 312 | }, 313 | "node_modules/whatwg-url": { 314 | "version": "5.0.0", 315 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 316 | "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", 317 | "dependencies": { 318 | "tr46": "~0.0.3", 319 | "webidl-conversions": "^3.0.0" 320 | } 321 | }, 322 | "node_modules/ws": { 323 | "version": "8.2.3", 324 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", 325 | "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", 326 | "engines": { 327 | "node": ">=10.0.0" 328 | }, 329 | "peerDependencies": { 330 | "bufferutil": "^4.0.1", 331 | "utf-8-validate": "^5.0.2" 332 | }, 333 | "peerDependenciesMeta": { 334 | "bufferutil": { 335 | "optional": true 336 | }, 337 | "utf-8-validate": { 338 | "optional": true 339 | } 340 | } 341 | } 342 | }, 343 | "dependencies": { 344 | "@discordjs/builders": { 345 | "version": "0.6.0", 346 | "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.6.0.tgz", 347 | "integrity": "sha512-mH3Gx61LKk2CD05laCI9K5wp+a3NyASHDUGx83DGJFkqJlRlSV5WMJNY6RS37A5SjqDtGMF4wVR9jzFaqShe6Q==", 348 | "requires": { 349 | "@sindresorhus/is": "^4.0.1", 350 | "discord-api-types": "^0.22.0", 351 | "ow": "^0.27.0", 352 | "ts-mixer": "^6.0.0", 353 | "tslib": "^2.3.1" 354 | }, 355 | "dependencies": { 356 | "discord-api-types": { 357 | "version": "0.22.0", 358 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz", 359 | "integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==" 360 | } 361 | } 362 | }, 363 | "@discordjs/collection": { 364 | "version": "0.2.1", 365 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.2.1.tgz", 366 | "integrity": "sha512-vhxqzzM8gkomw0TYRF3tgx7SwElzUlXT/Aa41O7mOcyN6wIJfj5JmDWaO5XGKsGSsNx7F3i5oIlrucCCWV1Nog==" 367 | }, 368 | "@discordjs/form-data": { 369 | "version": "3.0.1", 370 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", 371 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", 372 | "requires": { 373 | "asynckit": "^0.4.0", 374 | "combined-stream": "^1.0.8", 375 | "mime-types": "^2.1.12" 376 | } 377 | }, 378 | "@sapphire/async-queue": { 379 | "version": "1.1.7", 380 | "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.7.tgz", 381 | "integrity": "sha512-EBRERa9NqK/EV6DIPBVtjjdHBsu/DSdMuYAydmoIyIPONzp0UAxf2G6JGJ52WkiONtPRx6KNuqB5Q8dm14fwyw==" 382 | }, 383 | "@sindresorhus/is": { 384 | "version": "4.2.0", 385 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", 386 | "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==" 387 | }, 388 | "@types/node": { 389 | "version": "16.10.3", 390 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.3.tgz", 391 | "integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==" 392 | }, 393 | "@types/ws": { 394 | "version": "8.2.0", 395 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.0.tgz", 396 | "integrity": "sha512-cyeefcUCgJlEk+hk2h3N+MqKKsPViQgF5boi9TTHSK+PoR9KWBb/C5ccPcDyAqgsbAYHTwulch725DV84+pSpg==", 397 | "requires": { 398 | "@types/node": "*" 399 | } 400 | }, 401 | "asynckit": { 402 | "version": "0.4.0", 403 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 404 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 405 | }, 406 | "binarytf": { 407 | "version": "2.0.0", 408 | "resolved": "https://registry.npmjs.org/binarytf/-/binarytf-2.0.0.tgz", 409 | "integrity": "sha512-CS0MvijAFAHBBw4LgIHBP7wzdW3KWEB0KeMjblK0rHOyyhnkoMu3puW7uhJXlnS5WDn5M2XQFaQBtw00FwRfcA==" 410 | }, 411 | "callsites": { 412 | "version": "3.1.0", 413 | "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", 414 | "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" 415 | }, 416 | "cheshire": { 417 | "version": "git+ssh://git@github.com/Deivu/Cheshire.git#a664eb2928b556bc1317649afb43c3948dbd0de3", 418 | "from": "cheshire@github:Deivu/Cheshire#2.0.2", 419 | "requires": { 420 | "@discordjs/collection": "^0.2.1", 421 | "fun-dispatcher": "^1.2.6" 422 | } 423 | }, 424 | "combined-stream": { 425 | "version": "1.0.8", 426 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 427 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 428 | "requires": { 429 | "delayed-stream": "~1.0.0" 430 | } 431 | }, 432 | "delayed-stream": { 433 | "version": "1.0.0", 434 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 435 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 436 | }, 437 | "discord-api-types": { 438 | "version": "0.23.1", 439 | "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.23.1.tgz", 440 | "integrity": "sha512-igWmn+45mzXRWNEPU25I/pr8MwxHb767wAr51oy3VRLRcTlp5ADBbrBR0lq3SA1Rfw3MtM4TQu1xo3kxscfVdQ==" 441 | }, 442 | "discord.js": { 443 | "version": "13.2.0", 444 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.2.0.tgz", 445 | "integrity": "sha512-nyxUvL8wuQG38zx13wUMkpcA8koFszyiXdkSLwwM9opKW2LC2H5gD0cTZxImeJ6GtEnKPWT8xBiE8lLBmbNIhw==", 446 | "requires": { 447 | "@discordjs/builders": "^0.6.0", 448 | "@discordjs/collection": "^0.2.1", 449 | "@discordjs/form-data": "^3.0.1", 450 | "@sapphire/async-queue": "^1.1.5", 451 | "@types/ws": "^8.2.0", 452 | "discord-api-types": "^0.23.1", 453 | "node-fetch": "^2.6.1", 454 | "ws": "^8.2.3" 455 | } 456 | }, 457 | "dot-prop": { 458 | "version": "6.0.1", 459 | "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", 460 | "integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==", 461 | "requires": { 462 | "is-obj": "^2.0.0" 463 | } 464 | }, 465 | "fun-dispatcher": { 466 | "version": "1.2.6", 467 | "resolved": "https://registry.npmjs.org/fun-dispatcher/-/fun-dispatcher-1.2.6.tgz", 468 | "integrity": "sha512-lw6LoVrReV6qlaADvy0ua9a1f3W9qGLd8BBfLnzIV0YCfZd3jo5caZsgBBGOw/tO50P783iFEK8aTSwtQ67KDQ==" 469 | }, 470 | "is-obj": { 471 | "version": "2.0.0", 472 | "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", 473 | "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==" 474 | }, 475 | "kurasuta": { 476 | "version": "3.0.1", 477 | "resolved": "https://registry.npmjs.org/kurasuta/-/kurasuta-3.0.1.tgz", 478 | "integrity": "sha512-RW5tAdwgAcfMsY8uJpVe6Wk/UlF2HHLzZcPFJQQRDjBdSVUVSlYmqnxQeHwwuyykkpGlftd+gv0Cp5p4WMjW+A==", 479 | "requires": { 480 | "discord.js": "^13.1.0", 481 | "node-fetch": "^2.6.2", 482 | "veza": "^1.1.0" 483 | } 484 | }, 485 | "lodash.isequal": { 486 | "version": "4.5.0", 487 | "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", 488 | "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" 489 | }, 490 | "mime-db": { 491 | "version": "1.50.0", 492 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz", 493 | "integrity": "sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A==" 494 | }, 495 | "mime-types": { 496 | "version": "2.1.33", 497 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz", 498 | "integrity": "sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g==", 499 | "requires": { 500 | "mime-db": "1.50.0" 501 | } 502 | }, 503 | "node-fetch": { 504 | "version": "2.6.5", 505 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz", 506 | "integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==", 507 | "requires": { 508 | "whatwg-url": "^5.0.0" 509 | } 510 | }, 511 | "ow": { 512 | "version": "0.27.0", 513 | "resolved": "https://registry.npmjs.org/ow/-/ow-0.27.0.tgz", 514 | "integrity": "sha512-SGnrGUbhn4VaUGdU0EJLMwZWSupPmF46hnTRII7aCLCrqixTAC5eKo8kI4/XXf1eaaI8YEVT+3FeGNJI9himAQ==", 515 | "requires": { 516 | "@sindresorhus/is": "^4.0.1", 517 | "callsites": "^3.1.0", 518 | "dot-prop": "^6.0.1", 519 | "lodash.isequal": "^4.5.0", 520 | "type-fest": "^1.2.1", 521 | "vali-date": "^1.0.0" 522 | } 523 | }, 524 | "tr46": { 525 | "version": "0.0.3", 526 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 527 | "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" 528 | }, 529 | "ts-mixer": { 530 | "version": "6.0.0", 531 | "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz", 532 | "integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ==" 533 | }, 534 | "tslib": { 535 | "version": "2.3.1", 536 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", 537 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" 538 | }, 539 | "type-fest": { 540 | "version": "1.4.0", 541 | "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.4.0.tgz", 542 | "integrity": "sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==" 543 | }, 544 | "vali-date": { 545 | "version": "1.0.0", 546 | "resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz", 547 | "integrity": "sha1-G5BKWWCfsyjvB4E4Qgk09rhnCaY=" 548 | }, 549 | "veza": { 550 | "version": "1.1.0", 551 | "resolved": "https://registry.npmjs.org/veza/-/veza-1.1.0.tgz", 552 | "integrity": "sha512-JxDVZZXwFJ+FxsX+kPdsjRK9XZdwayEYzPsPLxpZjzzgncWphjvMlzn8ioVAgeonZ/Aa7vEZOb4Hp13ergwybA==", 553 | "requires": { 554 | "binarytf": "^2.0.0" 555 | } 556 | }, 557 | "webidl-conversions": { 558 | "version": "3.0.1", 559 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 560 | "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" 561 | }, 562 | "whatwg-url": { 563 | "version": "5.0.0", 564 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 565 | "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", 566 | "requires": { 567 | "tr46": "~0.0.3", 568 | "webidl-conversions": "^3.0.0" 569 | } 570 | }, 571 | "ws": { 572 | "version": "8.2.3", 573 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", 574 | "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", 575 | "requires": {} 576 | } 577 | } 578 | } 579 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azuma", 3 | "version": "3.0.7", 4 | "description": "A package that actually syncs your ratelimits across all your clusters on Discord.JS", 5 | "type":"module", 6 | "main": "index.js", 7 | "types": "index.d.ts", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/Deivu/Azuma.git" 11 | }, 12 | "author": "Deivu", 13 | "license": "MIT", 14 | "bugs": { 15 | "url": "https://github.com/Deivu/Azuma/issues" 16 | }, 17 | "homepage": "https://github.com/Deivu/Azuma/blob/master/README.md", 18 | "keywords": [ 19 | "discord", 20 | "discord.js", 21 | "discordjs", 22 | "discord-bot", 23 | "discord-ratelimits", 24 | "sharding", 25 | "api", 26 | "ratelimits", 27 | "node" 28 | ], 29 | "dependencies": { 30 | "@sapphire/async-queue": "^1.2.0", 31 | "cheshire": "github:Deivu/Cheshire#2.0.2", 32 | "discord.js": ">=13.0.0", 33 | "kurasuta": ">=3.0.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Azuma.js: -------------------------------------------------------------------------------- 1 | import { isPrimary } from 'cluster'; 2 | import { Util } from 'discord.js'; 3 | import Structures from './Structures.js'; 4 | import Constants from './Constants.js'; 5 | import EventEmitter from 'events'; 6 | import AzumaIPC from './ratelimits/AzumaIPC.js'; 7 | import AzumaManager from './ratelimits/AzumaManager.js'; 8 | import RequestManager from './client/RequestManager.js'; 9 | 10 | /** 11 | * Discord.JS Client 12 | * @external DiscordClient 13 | * @see {@link https://discord.js.org/#/docs/main/stable/class/Client} 14 | */ 15 | /** 16 | * Kurasuta Options 17 | * @external KurasutaOptions 18 | * @see {@link https://github.com/DevYukine/Kurasuta#shardingmanager} 19 | */ 20 | /** 21 | * Kurasuta ShardingManager 22 | * @external KurasutaShardingManager 23 | * @see {@link https://github.com/DevYukine/Kurasuta#shardingmanager} 24 | */ 25 | /** 26 | * Node.JS Timeout 27 | * @external Timeout 28 | * @see {@link https://nodejs.org/api/timers.html#timers_class_timeout} 29 | */ 30 | /** 31 | * Request object in EmittedInfo 32 | * @external Request 33 | * @see {@link https://github.com/Deivu/Azuma/blob/8ed42d73c4604c09aba0df117982123b0592c796/typings/client/RequestManager.d.ts#L11} 34 | */ 35 | /** 36 | * Response object in EmittedInfo 37 | * @external Response 38 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response} 39 | */ 40 | 41 | /** 42 | * Initalizes the sharding manager, and ratelimit manager class 43 | * @class Azuma 44 | * @extends {EventEmitter} 45 | */ 46 | class Azuma extends EventEmitter { 47 | /** 48 | * @param {string} path The path of your extended Kurasuta "BaseCluster.js" 49 | * @param {KurasutaOptions} [managerOptions={}] Options to initialize Kurasuta with 50 | * @param {Object} [ratelimitOptions={}] Options to initialize Azuma with 51 | * @param {number} [ratelimitOptions.inactiveTimeout=240000] TTL for cached hashes, data and handlers. in ms 52 | * @param {number} [ratelimitOptions.requestOffset=500] Extra time in ms to wait before continuing to make REST requests 53 | */ 54 | constructor(path, managerOptions = {}, ratelimitOptions = {}) { 55 | super(); 56 | /** 57 | * Emitted when a debug message was sent 58 | * @event Azuma#debug 59 | * @param {string} message 60 | * @memberOf Azuma 61 | */ 62 | if (!path) throw new Error('Commander, please provide a path for your BaseCluster.js'); 63 | /** 64 | * Your Kurasuta sharding manager class 65 | * @type {KurasutaShardingManager} 66 | */ 67 | this.manager = new (Structures.get('ShardingManager'))(path, managerOptions); 68 | /** 69 | * Options for Azuma 70 | * @type {Object} 71 | */ 72 | this.options = Util.mergeDefault(Constants.DefaultOptions, ratelimitOptions); 73 | /** 74 | * Ratelimit cache for all your clusters, null on non primary process 75 | * @type {AzumaManager|null} 76 | */ 77 | this.ratelimits = null; 78 | } 79 | /** 80 | * Initializes Azuma and Kurasuta 81 | * @memberOf Azuma 82 | * @returns {Promise} 83 | */ 84 | async spawn() { 85 | if (isPrimary) { 86 | while(this.manager.ipc.server.status !== 0) await sleep(1); 87 | await this.manager.ipc.server.close(); 88 | this.manager.ipc.server.removeAllListeners(); 89 | this.manager.ipc = new AzumaIPC(this.manager); 90 | while(this.manager.ipc.server.status !== 0) await sleep(1); 91 | this.ratelimits = new AzumaManager(this); 92 | const tasks = Structures.getBeforeSpawn(); 93 | if (tasks.length) await Promise.all(tasks.map(task => task(this.manager))); 94 | await this.manager.spawn(); 95 | return; 96 | } 97 | const manager = await import(this.manager.path); 98 | const cluster = new manager.default(this.manager); 99 | cluster.client.rest = new RequestManager(cluster.client); 100 | await cluster.init(); 101 | } 102 | } 103 | 104 | function sleep(delay) { 105 | return new Promise(resolve => setTimeout(resolve, delay*1000)); 106 | } 107 | 108 | export default Azuma; -------------------------------------------------------------------------------- /src/Constants.js: -------------------------------------------------------------------------------- 1 | const OP = 'AZUMA'; 2 | 3 | export default { 4 | OP, 5 | DefaultOptions: { 6 | inactiveTimeout: 240000, 7 | requestOffset: 500 8 | }, 9 | Events: { 10 | ON_REQUEST: 'onRequest', 11 | ON_RESPONSE: 'onResponse', 12 | ON_TOO_MANY_REQUEST: 'onTooManyRequest' 13 | }, 14 | createHandler: (manager, handler) => { 15 | const global = manager.timeout !== 0; 16 | const timeout = global ? manager.globalTimeout : handler.timeout; 17 | return { 18 | limit: handler.limit, 19 | remaining: handler.remaining, 20 | limited: handler.limited, 21 | timeout, 22 | global 23 | }; 24 | }, 25 | createFetchHandlerMessage: (id, hash, route) => { 26 | return { 27 | op: OP, 28 | type: 'handler', 29 | hash, 30 | id, 31 | route 32 | }; 33 | }, 34 | createUpdateHandlerMessage: (id, hash, method, route, data) => { 35 | return { 36 | op: OP, 37 | type: 'bucket', 38 | hash, 39 | id, 40 | method, 41 | route, 42 | data 43 | }; 44 | }, 45 | createFetchHashMessage: id => { 46 | return { 47 | op: OP, 48 | type: 'hash', 49 | id 50 | }; 51 | } 52 | }; -------------------------------------------------------------------------------- /src/Structures.js: -------------------------------------------------------------------------------- 1 | import { ShardingManager } from 'kurasuta'; 2 | 3 | const Struct = { 4 | ShardingManager: ShardingManager 5 | }; 6 | const beforeSpawn = []; 7 | 8 | class Structures { 9 | static extend(name, structure) { 10 | if (Struct[name]) Struct[name] = structure; 11 | } 12 | 13 | static get(name) { 14 | return Struct[name]; 15 | } 16 | 17 | static setBeforeSpawn(fn) { 18 | beforeSpawn.push(fn); 19 | } 20 | 21 | static getBeforeSpawn() { 22 | const clone = [...beforeSpawn]; 23 | beforeSpawn.length = 0; 24 | return clone; 25 | } 26 | } 27 | 28 | export default Structures; -------------------------------------------------------------------------------- /src/client/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2021 Noel Buechler 179 | Copyright 2021 Antonio Román 180 | Copyright 2021 Vlad Frangu 181 | 182 | Licensed under the Apache License, Version 2.0 (the "License"); 183 | you may not use this file except in compliance with the License. 184 | You may obtain a copy of the License at 185 | 186 | http://www.apache.org/licenses/LICENSE-2.0 187 | 188 | Unless required by applicable law or agreed to in writing, software 189 | distributed under the License is distributed on an "AS IS" BASIS, 190 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 191 | See the License for the specific language governing permissions and 192 | limitations under the License. -------------------------------------------------------------------------------- /src/client/RequestHandler.js: -------------------------------------------------------------------------------- 1 | import { AsyncQueue } from '@sapphire/async-queue'; 2 | import { Util, Constants as DiscordConstants } from 'discord.js'; 3 | 4 | import AzumaConstants from '../Constants.js'; 5 | import RequestError from './structures/RequestError.js'; 6 | import DiscordError from './structures/DiscordError.js'; 7 | import AzumaRatelimit from '../ratelimits/AzumaRatelimit.js'; 8 | 9 | /** 10 | * The handler for the non-master process that executes the rest requests 11 | * @class RequestHandler 12 | */ 13 | class RequestHandler { 14 | /** 15 | * @param {RequestManager} manager The manager for this request handler 16 | * @param {string} hash The hash for this request handler 17 | * @param {Object} options The options for the API request from the router 18 | */ 19 | constructor(manager, hash, { major }) { 20 | /** 21 | * The manager of this request handler 22 | * @type {RequestManager} 23 | */ 24 | this.manager = manager; 25 | /** 26 | * The ratelimit hash of this request handler 27 | * @type {string} 28 | */ 29 | this.hash = hash; 30 | /** 31 | * The ID of this request handler 32 | * @type {string} 33 | */ 34 | this.id = `${hash}:${major}`; 35 | /** 36 | * The current queued requests for this handler 37 | * @type {AsyncQueue} 38 | */ 39 | this.queue = new AsyncQueue(); 40 | } 41 | /** 42 | * Parses an api response 43 | * @static 44 | * @param {Response} res 45 | * @returns {Promise} 46 | */ 47 | static async parseResponse(res) { 48 | if (res.headers.get('content-type').startsWith('application/json')) return await res.json(); 49 | const arrayBuffer = await res.arrayBuffer(); 50 | return Buffer.from(arrayBuffer); 51 | } 52 | /** 53 | * If this handler is inactive 54 | * @type {boolean} 55 | * @readonly 56 | */ 57 | get inactive() { 58 | return this.queue.remaining === 0; 59 | } 60 | /** 61 | * Queues a request in this handler 62 | * @param {Request} request 63 | * @returns {Promise} 64 | */ 65 | async push(request) { 66 | await this.queue.wait(); 67 | let res; 68 | try { 69 | res = await this.execute(request); 70 | } finally { 71 | this.queue.shift(); 72 | } 73 | return res; 74 | } 75 | /** 76 | * Executes a request in this handler 77 | * @param {Request} request 78 | * @private 79 | * @returns {Promise} 80 | */ 81 | async execute(request) { 82 | // Get ratelimit data 83 | const { limited, limit, global, timeout } = await this.manager.fetchInfo(this.id, this.hash, request.route); 84 | if (global || limited) { 85 | if (this.manager.client.listenerCount(DiscordConstants.Events.RATE_LIMIT)) 86 | this.manager.client.emit(DiscordConstants.Events.RATE_LIMIT, { 87 | method: request.method, 88 | path: request.path, 89 | route: request.route, 90 | hash: this.hash, 91 | timeout, 92 | limit, 93 | global 94 | }); 95 | await Util.delayFor(timeout); 96 | } 97 | // Perform the request 98 | let res; 99 | try { 100 | if (this.manager.listenerCount(AzumaConstants.Events.ON_REQUEST)) 101 | this.manager.emit(AzumaConstants.Events.ON_REQUEST, { request }); 102 | res = await request.make(); 103 | } catch (error) { 104 | // Retry the specified number of times for request abortions 105 | if (request.retries === this.manager.client.options.retryLimit) { 106 | throw new RequestError(error.message, error.constructor.name, error.status, request); 107 | } 108 | request.retries++; 109 | return this.execute(request); 110 | } 111 | if (this.manager.listenerCount(AzumaConstants.Events.ON_RESPONSE)) 112 | this.manager.emit(AzumaConstants.Events.ON_RESPONSE, { request, response: res }); 113 | let after; 114 | if (res.headers) { 115 | // Build ratelimit data for master process 116 | const data = AzumaRatelimit.constructData(request, res.headers); 117 | // Just incase I messed my ratelimit handling up, so you can avoid getting banned 118 | after = !isNaN(data.after) ? Number(data.after) * 1000 : -1; 119 | // Send ratelimit data, and wait for possible global ratelimit manager halt 120 | await this.manager.updateInfo(this.id, this.hash, request.method, request.route, data); 121 | } 122 | // Handle 2xx and 3xx responses 123 | if (res.ok) 124 | // Nothing wrong with the request, proceed with the next one 125 | return RequestHandler.parseResponse(res); 126 | 127 | // Handle 4xx responses 128 | if (res.status >= 400 && res.status < 500) { 129 | // Handle ratelimited requests 130 | if (res.status === 429) { 131 | if (this.manager.listenerCount(AzumaConstants.Events.ON_TOO_MANY_REQUEST)) 132 | this.manager.emit(AzumaConstants.Events.ON_TOO_MANY_REQUEST, { request, response: res }); 133 | // A ratelimit was hit, You did something stupid @saya 134 | this.manager.client.emit('debug', 135 | 'Encountered unexpected 429 ratelimit\n' + 136 | ` Route : ${request.route}\n` + 137 | ` Request : ${request.method}\n` + 138 | ` Hash:Major : ${this.id}\n` + 139 | ` Request Route : ${request.route}\n` + 140 | ` Retry After : ${after}ms` 141 | ); 142 | // Retry after, but add 500ms on the top of original retry after 143 | await Util.delayFor(after + 500); 144 | return this.execute(request); 145 | } 146 | // Handle possible malformed requests 147 | let data; 148 | try { 149 | data = await RequestHandler.parseResponse(res); 150 | } catch (err) { 151 | throw new RequestError(err.message, err.constructor.name, err.status, request); 152 | } 153 | throw new DiscordError(data, res.status, request); 154 | } 155 | // Handle 5xx responses 156 | if (res.status >= 500 && res.status < 600) { 157 | // Retry the specified number of times for possible serverside issues 158 | if (request.retries === this.manager.client.options.retryLimit) 159 | throw new RequestError(res.statusText, res.constructor.name, res.status, request); 160 | request.retries++; 161 | return this.execute(request); 162 | } 163 | // Fallback in the rare case a status code outside the range 200..=599 is returned 164 | return null; 165 | } 166 | } 167 | 168 | export default RequestHandler; -------------------------------------------------------------------------------- /src/client/RequestManager.js: -------------------------------------------------------------------------------- 1 | import EventEmitter from 'events'; 2 | import Https from 'https'; 3 | 4 | import { LimitedCollection, Constants as DiscordConstants } from 'discord.js'; 5 | 6 | import AzumaConstants from '../Constants.js'; 7 | import DiscordRequest from './structures/DiscordRequest.js'; 8 | import RequestHandler from './RequestHandler.js'; 9 | import Router from './Router.js'; 10 | 11 | /** 12 | * The parameter emitted in onRequest, onResponse, onTooManyRequest events 13 | * @typedef {Object} EmittedInfo 14 | * @property {Request} request Info about the request made 15 | * @property {Response} [response] Response for the request made, will be null in onRequest event 16 | */ 17 | 18 | /** 19 | * The request manager of the non-master process that communicates with the master process 20 | * @class RequestManager 21 | */ 22 | class RequestManager extends EventEmitter { 23 | /** 24 | * @param {DiscordClient} client The client for this request manager 25 | * @param {number} lifetime The TTL for ratelimit handlers 26 | */ 27 | constructor(client) { 28 | super(); 29 | /** 30 | * Emitted when a request was made 31 | * @event RequestManager#onRequest 32 | * @param {EmittedInfo} data 33 | * @memberOf RequestManager 34 | */ 35 | /** 36 | * Emitted when a request was fulfilled 37 | * @event RequestManager#onResponse 38 | * @param {EmittedInfo} data 39 | * @memberOf RequestManager 40 | */ 41 | /** 42 | * Emitted when an actual 429 was hit 43 | * @event RequestManager#onTooManyRequest 44 | * @param {EmittedInfo} data 45 | * @memberOf RequestManager 46 | */ 47 | /** 48 | * The client for this request manager 49 | * @type {DiscordClient} 50 | */ 51 | this.client = client; 52 | /** 53 | * If this request manager is versioned 54 | * @type {boolean} 55 | */ 56 | this.versioned = true; 57 | /** 58 | * The request handlers that this request manager handles 59 | * @type {LimitedCollection} 60 | */ 61 | this.handlers = new LimitedCollection({ sweepInterval: 60, sweepFilter: () => handler => handler.inactive }); 62 | /** 63 | * The agent used for this manager 64 | * @type {Agent} 65 | */ 66 | this.agent = new Https.Agent({ ...client.options.http.agent, keepAlive: true }); 67 | } 68 | /** 69 | * The client for the IPC 70 | * @type {*} 71 | * @readonly 72 | */ 73 | get server() { 74 | return this.client.shard.ipc.server; 75 | } 76 | /** 77 | * A proxy api router 78 | * @type {*} 79 | * @readonly 80 | */ 81 | get api() { 82 | return Router(this); 83 | } 84 | /** 85 | * CDN endpoints 86 | * @type {Object} 87 | * @readonly 88 | */ 89 | get cdn() { 90 | return DiscordConstants.Endpoints.CDN(this.client.options.http.cdn); 91 | } 92 | /** 93 | * Sets the endpoint for http api 94 | * @type {string} 95 | */ 96 | get endpoint() { 97 | return this.client.options.http.api; 98 | } 99 | set endpoint(endpoint) { 100 | this.client.options.http.api = endpoint; 101 | } 102 | /** 103 | * Gets the auth for this manager 104 | * @returns {string} 105 | */ 106 | getAuth() { 107 | const token = this.client.token || this.client.accessToken; 108 | if (token) return `Bot ${token}`; 109 | throw new Error('TOKEN_MISSING'); 110 | } 111 | /** 112 | * Gets a cached hash in central cache 113 | * @param {string} id 114 | * @returns {Promise} 115 | */ 116 | fetchHash(id) { 117 | return this.server.send(AzumaConstants.createFetchHashMessage(id), { receptive: true }); 118 | } 119 | /** 120 | * Gets a cached ratelimit info in central cache 121 | * @param {Object} data 122 | * @returns {Promise<*>} 123 | */ 124 | fetchInfo(...args) { 125 | return this.server.send(AzumaConstants.createFetchHandlerMessage(...args), { receptive: true }); 126 | } 127 | /** 128 | * Updates a cached ratelimit info in central cache 129 | * @param {Object} data 130 | * @returns {Promise} 131 | */ 132 | updateInfo(...args) { 133 | return this.server.send(AzumaConstants.createUpdateHandlerMessage(...args), { receptive: true }); 134 | } 135 | /** 136 | * Executes a request 137 | * @param {string} method 138 | * @param {route} route 139 | * @param {Object} data 140 | * @returns {Promise} 141 | */ 142 | async request(method, route, options = {}) { 143 | const hash = await this.fetchHash(`${method}:${options.route}`) ?? `Global(${method}:${options.route})`; 144 | if (hash.startsWith('Global')) options.major = 'id'; 145 | let handler = this.handlers.get(`${hash}:${options.major}`); 146 | if (!handler) { 147 | handler = new RequestHandler(this, hash, options); 148 | this.handlers.set(handler.id, handler); 149 | } 150 | return handler.push(new DiscordRequest(this, method, route, options)); 151 | } 152 | } 153 | 154 | export default RequestManager; -------------------------------------------------------------------------------- /src/client/Router.js: -------------------------------------------------------------------------------- 1 | import { SnowflakeUtil } from 'discord.js'; 2 | 3 | const noop = () => {}; // eslint-disable-line no-empty-function 4 | const methods = ['get', 'post', 'delete', 'patch', 'put']; 5 | const reflectors = [ 6 | 'toString', 7 | 'valueOf', 8 | 'inspect', 9 | 'constructor', 10 | Symbol.toPrimitive, 11 | Symbol.for('nodejs.util.inspect.custom'), 12 | ]; 13 | 14 | function buildRoute(manager) { 15 | const route = ['']; 16 | const handler = { 17 | get(target, name) { 18 | if (reflectors.includes(name)) return () => route.join('/'); 19 | if (methods.includes(name)) { 20 | const endpoint = route.join('/'); 21 | const major = /^\/(?:channels|guilds|webhooks)\/(\d{16,19})/.exec(endpoint)?.[1] ?? 'global'; 22 | const bucket = endpoint.replace(/\d{16,19}/g, ':id').replace(/\/reactions\/(.*)/, '/reactions/:reaction'); 23 | // Hard-Code Old Message Deletion Exception (2 week+ old messages are a different bucket) 24 | // https://github.com/discord/discord-api-docs/issues/1295 25 | let exceptions = ''; 26 | if (name === 'delete' && bucket === '/channels/:id/messages/:id') { 27 | const id = /\d{16,19}$/.exec(endpoint)[0]; 28 | const { timestamp } = SnowflakeUtil.deconstruct(id); 29 | if (Date.now() - Number(timestamp) > 1000 * 60 * 60 * 24 * 14) exceptions += '/Delete Old Message'; 30 | } 31 | return options => 32 | manager.request( 33 | name, 34 | endpoint, 35 | Object.assign({ versioned: manager.versioned, route: bucket + exceptions, major }, options) 36 | ); 37 | } 38 | route.push(name); 39 | return new Proxy(noop, handler); 40 | }, 41 | apply(target, _, args) { 42 | route.push(...args.filter(x => x != null)); // eslint-disable-line eqeqeq 43 | return new Proxy(noop, handler); 44 | }, 45 | }; 46 | return new Proxy(noop, handler); 47 | } 48 | 49 | export default buildRoute; -------------------------------------------------------------------------------- /src/client/structures/DiscordError.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an error from the Discord API. 3 | * @extends Error 4 | */ 5 | class DiscordError extends Error { 6 | constructor(error, status, request) { 7 | super(); 8 | const flattened = this.constructor.flattenErrors(error.errors ?? error).join('\n'); 9 | this.name = 'DiscordAPIError'; 10 | this.message = error.message && flattened ? `${error.message}\n${flattened}` : error.message ?? flattened; 11 | 12 | /** 13 | * The HTTP method used for the request 14 | * @type {string} 15 | */ 16 | this.method = request.method; 17 | 18 | /** 19 | * The path of the request relative to the HTTP endpoint 20 | * @type {string} 21 | */ 22 | this.path = request.path; 23 | 24 | /** 25 | * HTTP error code returned by Discord 26 | * @type {number} 27 | */ 28 | this.code = error.code; 29 | 30 | /** 31 | * The HTTP status code 32 | * @type {number} 33 | */ 34 | this.httpStatus = status; 35 | 36 | /** 37 | * The data associated with the request that caused this error 38 | * @type {HTTPErrorData} 39 | */ 40 | this.requestData = { 41 | json: request.options.data, 42 | files: request.options.files ?? [], 43 | }; 44 | } 45 | /** 46 | * Flattens an errors object returned from the API into an array. 47 | * @param {APIError} obj Discord errors object 48 | * @param {string} [key] Used internally to determine key names of nested fields 49 | * @returns {string[]} 50 | * @private 51 | */ 52 | static flattenErrors(obj, key = '') { 53 | let messages = []; 54 | for (const [k, v] of Object.entries(obj)) { 55 | if (k === 'message') continue; 56 | const newKey = key ? isNaN(k) ? `${key}.${k}` : `${key}[${k}]` : k; 57 | if (v._errors) { 58 | messages.push(`${newKey}: ${v._errors.map(e => e.message).join(' ')}`); 59 | } else if (v.code ?? v.message) { 60 | messages.push(`${v.code ? `${v.code}: ` : ''}${v.message}`.trim()); 61 | } else if (typeof v === 'string') { 62 | messages.push(v); 63 | } else { 64 | messages = messages.concat(this.flattenErrors(v, newKey)); 65 | } 66 | } 67 | return messages; 68 | } 69 | } 70 | 71 | /** 72 | * @external DiscordError 73 | * @see {@link https://discord.com/developers/docs/reference#error-messages} 74 | */ 75 | 76 | export default DiscordError; 77 | -------------------------------------------------------------------------------- /src/client/structures/DiscordRequest.js: -------------------------------------------------------------------------------- 1 | import { Constants } from 'discord.js'; 2 | import FormData from '@discordjs/form-data'; 3 | import Fetch from 'node-fetch'; 4 | 5 | class DiscordRequest { 6 | constructor(rest, method, path, options) { 7 | this.rest = rest; 8 | this.client = rest.client; 9 | this.method = method; 10 | this.route = options.route; 11 | this.options = options; 12 | this.retries = 0; 13 | const { userAgentSuffix } = this.client.options; 14 | this.fullUserAgent = `${Constants.UserAgent}${userAgentSuffix.length ? `, ${userAgentSuffix.join(', ')}` : ''}`; 15 | let queryString = ''; 16 | if (options.query) { 17 | const query = Object.entries(options.query) 18 | .filter(([, value]) => value !== null && typeof value !== 'undefined') 19 | .flatMap(([key, value]) => Array.isArray(value) ? value.map(v => [key, v]) : [[key, value]]); 20 | queryString = new URLSearchParams(query).toString(); 21 | } 22 | this.path = `${path}${queryString && `?${queryString}`}`; 23 | } 24 | 25 | make() { 26 | const API = this.options.versioned === false 27 | ? this.client.options.http.api 28 | : `${this.client.options.http.api}/v${this.client.options.http.version}`; 29 | const url = API + this.path; 30 | let headers = { 31 | ...this.client.options.http.headers, 32 | 'User-Agent': this.fullUserAgent, 33 | }; 34 | if (this.options.auth !== false) headers.Authorization = this.rest.getAuth(); 35 | if (this.options.reason) headers['X-Audit-Log-Reason'] = encodeURIComponent(this.options.reason); 36 | if (this.options.headers) headers = Object.assign(headers, this.options.headers); 37 | let body; 38 | if (this.options.files?.length) { 39 | body = new FormData(); 40 | for (const file of this.options.files) { 41 | if (file?.file) body.append(file.key ?? file.name, file.file, file.name); 42 | } 43 | if (typeof this.options.data !== 'undefined') { 44 | if (this.options.dontUsePayloadJSON) { 45 | for (const [key, value] of Object.entries(this.options.data)) body.append(key, value); 46 | } else { 47 | body.append('payload_json', JSON.stringify(this.options.data)); 48 | } 49 | } 50 | headers = Object.assign(headers, body.getHeaders()); 51 | // eslint-disable-next-line eqeqeq 52 | } else if (this.options.data != null) { 53 | body = JSON.stringify(this.options.data); 54 | headers['Content-Type'] = 'application/json'; 55 | } 56 | const controller = new AbortController(); 57 | const timeout = setTimeout(() => controller.abort(), this.client.options.restRequestTimeout).unref(); 58 | return Fetch(url, { 59 | method: this.method, 60 | agent: this.rest.agent, 61 | signal: controller.signal, 62 | headers, 63 | body 64 | }).finally(() => clearTimeout(timeout)); 65 | } 66 | } 67 | 68 | export default DiscordRequest; -------------------------------------------------------------------------------- /src/client/structures/RequestError.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an HTTP error from a request. 3 | * @extends Error 4 | */ 5 | class RequestError extends Error { 6 | constructor(message, name, code, request) { 7 | super(message); 8 | /** 9 | * The name of the error 10 | * @type {string} 11 | */ 12 | this.name = name; 13 | /** 14 | * HTTP error code returned from the request 15 | * @type {number} 16 | */ 17 | this.code = code ?? 500; 18 | /** 19 | * The HTTP method used for the request 20 | * @type {string} 21 | */ 22 | this.method = request.method; 23 | /** 24 | * The path of the request relative to the HTTP endpoint 25 | * @type {string} 26 | */ 27 | this.path = request.path; 28 | /** 29 | * The HTTP data that was sent to Discord 30 | * @typedef {Object} HTTPErrorData 31 | * @property {*} json The JSON data that was sent 32 | * @property {HTTPAttachmentData[]} files The files that were sent with this request, if any 33 | */ 34 | /** 35 | * The attachment data that is sent to Discord 36 | * @typedef {Object} HTTPAttachmentData 37 | * @property {string|Buffer|Stream} attachment The source of this attachment data 38 | * @property {string} name The file name 39 | * @property {Buffer|Stream} file The file buffer 40 | */ 41 | /** 42 | * The data associated with the request that caused this error 43 | * @type {HTTPErrorData} 44 | */ 45 | this.requestData = { 46 | json: request.options.data, 47 | files: request.options.files ?? [], 48 | }; 49 | } 50 | } 51 | 52 | export default RequestError; -------------------------------------------------------------------------------- /src/ratelimits/AzumaIPC.js: -------------------------------------------------------------------------------- 1 | import { MasterIPC, IPCEvents } from 'kurasuta'; 2 | 3 | class AzumaIPC extends MasterIPC { 4 | _incommingMessage(message) { 5 | const event = IPCEvents[message.data.op]?.toLowerCase(); 6 | if (!event) return; 7 | this[`_${event}`](message); 8 | } 9 | } 10 | 11 | export default AzumaIPC; -------------------------------------------------------------------------------- /src/ratelimits/AzumaManager.js: -------------------------------------------------------------------------------- 1 | import { Cheshire } from 'cheshire'; 2 | import Constants from '../Constants.js'; 3 | import AzumaRatelimit from './AzumaRatelimit.js'; 4 | 5 | /** 6 | * Governs all the ratelimits across all your clusters / process 7 | * @class AzumaManager 8 | */ 9 | class AzumaManager { 10 | /** 11 | * @param {Azuma} azuma The class that initalized the sharding manager, and ratelimit manager class 12 | */ 13 | constructor(azuma) { 14 | /** 15 | * Contains the sharding manager, and ratelimit manager class 16 | * @type {Azuma} 17 | */ 18 | this.azuma = azuma; 19 | /** 20 | * Currently cached ratelimit hashes 21 | * @type {Cheshire} 22 | */ 23 | this.hashes = new Cheshire({ lru: true, lifetime: this.azuma.options.inactiveTimeout }); 24 | /** 25 | * Currently cached ratelimit info 26 | * @type {Cheshire} 27 | */ 28 | this.handlers = new Cheshire({ lru: true, lifetime: this.azuma.options.inactiveTimeout }); 29 | /** 30 | * Global ratelimit timeout 31 | * @type {number} 32 | */ 33 | this.timeout = 0; 34 | // listener 35 | this.server.on('message', message => { 36 | if (!message) return; 37 | const data = message.data; 38 | // This OP should be "ALWAYS RECEPTIVE" 39 | if (Constants.OP !== data?.op) return; 40 | switch(data.type) { 41 | case 'handler': 42 | message.reply(this.get(data)); 43 | break; 44 | case 'bucket': 45 | message.reply(this.update(data)); 46 | break; 47 | case 'hash': 48 | message.reply(this.hashes.get(data.id)); 49 | } 50 | }); 51 | } 52 | /** 53 | * The server for the IPC 54 | * @type {*} 55 | * @readonly 56 | */ 57 | get server() { 58 | return this.azuma.manager.ipc.server; 59 | } 60 | /** 61 | * Global timeout if there's any. Will only be accurate if this.timeout is not zero 62 | * @type {number} 63 | * @readonly 64 | */ 65 | get globalTimeout() { 66 | if (this.timeout === 0) return 0; 67 | const timeout = this.timeout - Date.now() + this.azuma.options.requestOffset; 68 | if (Math.sign(timeout) === -1) return 0; 69 | return timeout; 70 | } 71 | /** 72 | * Gets a specific handler from cache 73 | * @param {Object} data 74 | * @returns {*} 75 | */ 76 | get({ id, hash, route }) { 77 | let limiter = this.handlers.get(id); 78 | if (!limiter) { 79 | limiter = new AzumaRatelimit(this, id, hash, route); 80 | this.handlers.set(id, limiter); 81 | } 82 | return Constants.createHandler(this, limiter); 83 | } 84 | /** 85 | * Updates a specific handler from cache 86 | * @param {Object} data 87 | * @returns {void} 88 | */ 89 | update({ id, hash, method, route, data }) { 90 | let limiter = this.handlers.get(id); 91 | if (!limiter) { 92 | limiter = new AzumaRatelimit(this, id, hash, route); 93 | this.handlers.set(id, limiter); 94 | } 95 | return limiter.update(method, route, data); 96 | } 97 | } 98 | 99 | export default AzumaManager; -------------------------------------------------------------------------------- /src/ratelimits/AzumaRatelimit.js: -------------------------------------------------------------------------------- 1 | import { Util } from 'discord.js'; 2 | 3 | /** 4 | * Represents a ratelimit cache data for an endpoint 5 | * @class AzumaRatelimit 6 | */ 7 | class AzumaRatelimit { 8 | /** 9 | * @param {AzumaManager} manager The manager for this ratelimit queue 10 | * @param {string} id The ID of this ratelimit queue 11 | * @param {string} hash The ratelimit hash for this ratelimit queue 12 | * @param {string} route The route for this ratelimit queue 13 | */ 14 | constructor(manager, id, hash, route) { 15 | /** 16 | * The manager for this ratelimit queue 17 | * @type {AzumaManager} 18 | */ 19 | this.manager = manager; 20 | /** 21 | * The ID of this ratelimit queue 22 | * @type {string} 23 | */ 24 | this.id = id; 25 | /** 26 | * The ratelimit hash for this ratelimit queue 27 | * @type {string} 28 | */ 29 | this.hash = hash; 30 | /** 31 | * The route for this ratelimit queue 32 | * @type {string} 33 | */ 34 | this.route = route; 35 | /** 36 | * The max number of request you can do in this ratelimit queue cycle 37 | * @type {number} 38 | */ 39 | this.limit = -1; 40 | /** 41 | * The remaining requests you can do in this ratelimit queue cycle 42 | * @type {number} 43 | */ 44 | this.remaining = -1; 45 | /** 46 | * When this ratelimit queue remaining requests will reset 47 | * @type {number} 48 | */ 49 | this.reset = -1; 50 | /** 51 | * Retry-After header for this requests, 0 if nothing out of ordinary happened 52 | * @type {number} 53 | */ 54 | this.after = -1; 55 | } 56 | /** 57 | * Generates an update object for this class to parse 58 | * @static 59 | * @param {*} request 60 | * @param {*} headers 61 | * @returns {Object} 62 | */ 63 | static constructData(request, headers) { 64 | if (!request || !headers) throw new Error('Request and Headers can\'t be null'); 65 | return { 66 | date: headers.get('date'), 67 | limit: headers.get('x-ratelimit-limit'), 68 | remaining: headers.get('x-ratelimit-remaining'), 69 | reset: headers.get('x-ratelimit-reset'), 70 | hash: headers.get('X-RateLimit-Bucket'), 71 | after: headers.get('retry-after'), 72 | global: !!headers.get('x-ratelimit-global'), 73 | reactions: request.route.includes('reactions') 74 | }; 75 | } 76 | /** 77 | * Gets the offset from api and this system 78 | * @static 79 | * @param {string} date 80 | * @returns {number} 81 | */ 82 | static getAPIOffset(date) { 83 | return new Date(date).getTime() - Date.now(); 84 | } 85 | /** 86 | * Calculates the reset for ratelimit 87 | * @static 88 | * @param {string} reset 89 | * @param {string} date 90 | * @returns {number} 91 | */ 92 | static calculateReset(reset, date) { 93 | return new Date(Number(reset) * 1000).getTime() - AzumaRatelimit.getAPIOffset(date); 94 | } 95 | /** 96 | * If this ratelimit cache is considered as ratelimit hit to stop requests from occuring 97 | * @type {boolean} 98 | * @readonly 99 | */ 100 | get limited() { 101 | return !!this.manager.timeout || this.remaining <= 0 && Date.now() < this.reset; 102 | } 103 | /** 104 | * Timeout before the ratelimit clears, takes account the offset as well 105 | * @type {number} 106 | * @readonly 107 | */ 108 | get timeout() { 109 | return this.reset + this.manager.azuma.options.requestOffset - Date.now(); 110 | } 111 | /** 112 | * Updates the data in this cached ratelimit info 113 | * @param {string} method 114 | * @param {string} route 115 | * @param {Object} data 116 | * @returns {void} 117 | */ 118 | update(method, route, { date, limit, remaining, reset, hash, after, global, reactions } = {}) { 119 | // Set or Update this queue ratelimit data 120 | this.limit = !isNaN(limit) ? Number(limit) : Infinity; 121 | this.remaining = !isNaN(remaining) ? Number(remaining) : -1; 122 | this.reset = !isNaN(reset) ? AzumaRatelimit.calculateReset(reset, date) : Date.now(); 123 | this.after = !isNaN(after) ? Number(after) * 1000 : -1; 124 | // Handle buckets via the hash header retroactively 125 | if (hash && hash !== this.hash) { 126 | this.manager.azuma.emit('debug', 127 | 'Received a bucket hash update\n' + 128 | ` Route : ${route}\n` + 129 | ` Old Hash : ${this.hash}\n` + 130 | ` New Hash : ${hash}` 131 | ); 132 | this.manager.hashes.set(`${method}:${route}`, hash); 133 | } 134 | // https://github.com/discordapp/discord-api-docs/issues/182 135 | if (reactions) 136 | this.reset = new Date(date).getTime() - AzumaRatelimit.getAPIOffset(date) + this.manager.azuma.sweepInterval; 137 | // Global ratelimit, will halt all the requests if this is true 138 | if (global) { 139 | this.manager.azuma.emit('debug', `Globally Ratelimited, all request will stop for ${this.after}`); 140 | this.manager.timeout = Date.now() + this.after; 141 | Util.delayFor(this.after) 142 | .then(() => this.manager.timeout = 0); 143 | } 144 | } 145 | } 146 | 147 | export default AzumaRatelimit; -------------------------------------------------------------------------------- /typings/Azuma.d.ts: -------------------------------------------------------------------------------- 1 | import { EventEmitter } from 'events'; 2 | import { SharderOptions, ShardingManager } from 'kurasuta'; 3 | import { AzumaManager } from './ratelimits/AzumaManager'; 4 | 5 | export interface RatelimitOptions { 6 | handlerSweepInterval?: number; 7 | inactiveTimeout?: number; 8 | requestOffset?: number; 9 | } 10 | 11 | export class Azuma extends EventEmitter { 12 | constructor(path: string, managerOptions: SharderOptions, ratelimitOptions?: RatelimitOptions); 13 | public manager: ShardingManager; 14 | public options: RatelimitOptions; 15 | public ratelimits: AzumaManager; 16 | public spawn(): Promise; 17 | } 18 | 19 | export interface Azuma { 20 | on(event: 'debug', listener: (message: string) => void): this; 21 | once(event: 'debug', listener: (message: string) => void): this; 22 | off(event: 'debug', listener: (message: string) => void): this; 23 | } -------------------------------------------------------------------------------- /typings/Constants.d.ts: -------------------------------------------------------------------------------- 1 | import { AzumaManager } from './ratelimits/AzumaManager'; 2 | import { AzumaRatelimit } from './ratelimits/AzumaRatelimit'; 3 | 4 | export interface DefaultOptions { 5 | handlerSweepInterval?: number; 6 | inactiveTimeout?: number; 7 | requestOffset?: number; 8 | } 9 | 10 | export interface Events { 11 | ON_REQUEST: string; 12 | ON_RESPONSE: string; 13 | ON_TOO_MANY_REQUEST: string; 14 | } 15 | 16 | export interface Handler { 17 | limit: number; 18 | remaining: number; 19 | limited: boolean; 20 | timeout: number; 21 | global: boolean; 22 | } 23 | 24 | export interface FetchHandlerMessage { 25 | op: string; 26 | type: string; 27 | hash: string; 28 | id: string; 29 | route: string; 30 | } 31 | 32 | export interface UpdateHandlerMessage { 33 | op: string; 34 | type: string; 35 | hash: string; 36 | id: string; 37 | method: string; 38 | route: string; 39 | data: Object; 40 | } 41 | 42 | export interface FetchHashMessage { 43 | op: string; 44 | type: string; 45 | id: string; 46 | } 47 | 48 | export interface Constants { 49 | OP: string; 50 | DefaultOptions: DefaultOptions; 51 | Events: Events; 52 | createHandler(manager: AzumaManager, handler: AzumaRatelimit): Handler; 53 | createFetchHandlerMessage(id: string, hash: string, route: string): FetchHandlerMessage; 54 | createUpdateHandlerMessage(id: string, hash: string, method: string, route: string, data: Object): UpdateHandlerMessage; 55 | createFetchHashMessage(id: string): FetchHashMessage; 56 | } -------------------------------------------------------------------------------- /typings/Structures.d.ts: -------------------------------------------------------------------------------- 1 | export class Structures { 2 | public static extend(name: string, structure: any): any; 3 | public static get(name: string): any; 4 | public static setBeforeSpawn(fn: any): void; 5 | public static getBeforeSpawn(): any[]; 6 | } -------------------------------------------------------------------------------- /typings/client/RequestHandler.d.ts: -------------------------------------------------------------------------------- 1 | import { AsyncQueue } from '@sapphire/async-queue'; 2 | import { Request, RequestManager } from './RequestManager'; 3 | 4 | export class RequestHandler { 5 | constructor(manager: RequestManager, hash: string, options: Object); 6 | public manager: RequestManager; 7 | public hash: string; 8 | public id: string; 9 | public queue: AsyncQueue; 10 | public readonly inactive: boolean; 11 | public static parseResponse(res: Response): Promise; 12 | public push(request: Request): Promise; 13 | private execute(request: Request): Promise; 14 | } -------------------------------------------------------------------------------- /typings/client/RequestManager.d.ts: -------------------------------------------------------------------------------- 1 | import { LimitedCollection } from 'discord.js'; 2 | import { EventEmitter } from 'events'; 3 | import { ParsedHeaders } from '../ratelimits/AzumaRatelimit'; 4 | import { RequestHandler } from './RequestHandler'; 5 | 6 | export interface EmittedInfo { 7 | request: Request; 8 | response?: Response; 9 | } 10 | 11 | export class Request { 12 | public rest: RequestManager; 13 | public client: any; 14 | public method: string; 15 | public route: string; 16 | public options: Object; 17 | public retries: number; 18 | public fullUserAgent: string; 19 | public path: string; 20 | protected make(): Promise; 21 | } 22 | 23 | export class RequestManager extends EventEmitter { 24 | constructor(client: any, interval: number); 25 | public client: any; 26 | public versioned: boolean; 27 | public handlers: LimitedCollection; 28 | public endpoint: string; 29 | public readonly server: any; 30 | public readonly api: any; 31 | public readonly cdn: Object; 32 | public getAuth(): string; 33 | public fetchHash(id: string): Promise; 34 | public fetchInfo(id: string, hash: string, route: string): Promise; 35 | public updateInfo(id: string, hash: string, method: string, route: string, data: ParsedHeaders): Promise; 36 | public request(method: string, route: string, options?: Object): Promise; 37 | } 38 | 39 | export interface RequestManager { 40 | on(event: 'onRequest', listener: (info: EmittedInfo) => void): this; 41 | on(event: 'onResponse', listener: (info: EmittedInfo) => void): this; 42 | on(event: 'onTooManyRequest', listener: (info: EmittedInfo) => void): this; 43 | once(event: 'onRequest', listener: (info: EmittedInfo) => void): this; 44 | once(event: 'onResponse', listener: (info: EmittedInfo) => void): this; 45 | once(event: 'onTooManyRequest', listener: (info: EmittedInfo) => void): this; 46 | off(event: 'onRequest', listener: (info: EmittedInfo) => void): this; 47 | off(event: 'onResponse', listener: (info: EmittedInfo) => void): this; 48 | off(event: 'onTooManyRequest', listener: (info: EmittedInfo) => void): this; 49 | } -------------------------------------------------------------------------------- /typings/ratelimits/AzumaIPC.d.ts: -------------------------------------------------------------------------------- 1 | import { MasterIPC } from "kurasuta"; 2 | 3 | export class AzumaIPC extends MasterIPC {} -------------------------------------------------------------------------------- /typings/ratelimits/AzumaManager.d.ts: -------------------------------------------------------------------------------- 1 | import { Cheshire } from 'Cheshire'; 2 | import { Azuma } from '../Azuma'; 3 | import { AzumaRatelimit } from './AzumaRatelimit'; 4 | 5 | export class AzumaManager { 6 | constructor(azuma: Azuma); 7 | public azuma: Azuma; 8 | public hashes: Cheshire; 9 | public handlers: Cheshire; 10 | public timeout: number; 11 | public readonly server: any; 12 | public readonly globalTimeout: number; 13 | public get(data: Object): Object; 14 | public update(data: Object): void; 15 | } -------------------------------------------------------------------------------- /typings/ratelimits/AzumaRatelimit.d.ts: -------------------------------------------------------------------------------- 1 | import { AzumaManager } from './AzumaManager'; 2 | 3 | export interface ParsedHeaders { 4 | date: string; 5 | limit: string|number; 6 | remaining: string|number; 7 | reset: string|number; 8 | hash: string; 9 | after: string|number; 10 | global: boolean; 11 | reactions: boolean; 12 | } 13 | 14 | export class AzumaRatelimit { 15 | constructor(manager: AzumaManager, id: string, hash: string, route: string); 16 | public manager: AzumaManager; 17 | public id: string; 18 | public hash: string; 19 | public route: string; 20 | public limit: number; 21 | public remaining: number; 22 | public reset: number; 23 | public after: number; 24 | protected static constructData(request: Object, headers: ParsedHeaders): Object; 25 | protected static getAPIOffset(date: string): number; 26 | protected static calculateReset(reset: number, date: string): number; 27 | public readonly limited: boolean; 28 | public readonly timeout: number; 29 | public update(method: string, route: string, data: ParsedHeaders): void; 30 | } --------------------------------------------------------------------------------