@sapphire/plugin-hmr 0.1.0-next.4a18bb1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +24 -0
- package/README.md +178 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/register.d.ts +11 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +19 -0
- package/dist/register.js.map +1 -0
- package/dist/register.mjs +4 -0
- package/package.json +69 -0
- package/register.d.ts +1 -0
- package/register.js +4 -0
- package/register.mjs +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © `2020` `The Sapphire Community and its contributors`
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated documentation
|
|
7
|
+
files (the “Software”), to deal in the Software without
|
|
8
|
+
restriction, including without limitation the rights to use,
|
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the
|
|
11
|
+
Software is furnished to do so, subject to the following
|
|
12
|
+
conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
# @sapphire/plugin-hmr
|
|
6
|
+
|
|
7
|
+
**Plugin for <a href="https://github.com/sapphiredev/framework">@sapphire/framework</a> for super-speed HMR.**
|
|
8
|
+
|
|
9
|
+
[](https://github.com/sapphiredev/plugins/blob/main/LICENSE.md)
|
|
10
|
+
[](https://codecov.io/gh/sapphiredev/plugins)
|
|
11
|
+
[](https://bundlephobia.com/result?p=@sapphire/plugin-hmr)
|
|
12
|
+
[](https://www.npmjs.com/package/@sapphire/plugin-hmr)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
## Description
|
|
17
|
+
|
|
18
|
+
This plugin provides a HMR (Hot Module Replacement) feature for @sapphire/framework. This allows you to add, delete, and
|
|
19
|
+
update commands, listeners, and other pieces without having to restart your bot. This allows for rapid iteration and prototyping without your bot slowing you down.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Fully ready for TypeScript!
|
|
24
|
+
- Includes ESM ready entrypoint
|
|
25
|
+
- Easy to use
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
`@sapphire/plugin-hmr` depends on the following packages. Be sure to install these along with this package!
|
|
30
|
+
|
|
31
|
+
- [`@sapphire/framework`](https://www.npmjs.com/package/@sapphire/framework)
|
|
32
|
+
|
|
33
|
+
You can use the following command to install this package, or replace `npm install` with your package manager of choice.
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm install @sapphire/plugin-hmr @sapphire/framework
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### JavaScript
|
|
44
|
+
|
|
45
|
+
In your main or setup file, register the plugin:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
require('@sapphire/plugin-hmr/register');
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or if you want to make sure the plugin is only loaded in development, you can register it dynamically like so:
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
const { start } = require('@sapphire/hmr');
|
|
55
|
+
|
|
56
|
+
const client = new SapphireClient({
|
|
57
|
+
/* your bot options */
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
async function main() {
|
|
61
|
+
await client.login();
|
|
62
|
+
|
|
63
|
+
// this has to be called after you have logged into your bot
|
|
64
|
+
if (process.env.NODE_ENV === 'development') {
|
|
65
|
+
start();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void main();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### TypeScript
|
|
73
|
+
|
|
74
|
+
In your main or setup file, register the plugin:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import '@sapphire/plugin-hmr/register';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or if you want to make sure the plugin is only loaded in development, you can register it dynamically like so:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { start } from '@sapphire/plugin-hmr';
|
|
84
|
+
|
|
85
|
+
const client = new SapphireClient({
|
|
86
|
+
/* your bot options */
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
async function main() {
|
|
90
|
+
await client.login();
|
|
91
|
+
|
|
92
|
+
// this has to be called after you have logged into your bot
|
|
93
|
+
if (process.env.NODE_ENV === 'development') {
|
|
94
|
+
start();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void main();
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
In order for HMR to pick up your compiled JavaScript files, you will need to recompile your code. To that end, we will configure a `dev` script in `package.json` scripts that runs `build` in parallel with `start`:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
"scripts": {
|
|
105
|
+
"dev": "run-p watch start",
|
|
106
|
+
"build": "tsc",
|
|
107
|
+
"watch": "tsc --watch",
|
|
108
|
+
"start": "node dist/index.js"
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
_Note:_ This uses the `run-p` script which is part of [`npm-run-all`](https://github.com/mysticatea/npm-run-all)
|
|
113
|
+
|
|
114
|
+
_Note 2:_ Please do note that because the processes are started simultaneously you should run `build` at least once before running `dev`, otherwise the `start` process will fail because there are no files to run just yet.
|
|
115
|
+
|
|
116
|
+
then run your bot using the dev script. You can replace npm with your package manager of choice.
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
npm run start
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Buy us some doughnuts
|
|
123
|
+
|
|
124
|
+
Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!
|
|
125
|
+
|
|
126
|
+
We accept donations through Open Collective, Ko-fi, Paypal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
|
|
127
|
+
|
|
128
|
+
| Donate With | Address |
|
|
129
|
+
| :-------------: | :-------------------------------------------------: |
|
|
130
|
+
| Open Collective | [Click Here](https://sapphirejs.dev/opencollective) |
|
|
131
|
+
| Ko-fi | [Click Here](https://sapphirejs.dev/kofi) |
|
|
132
|
+
| Patreon | [Click Here](https://sapphirejs.dev/patreon) |
|
|
133
|
+
| PayPal | [Click Here](https://sapphirejs.dev/paypal) |
|
|
134
|
+
|
|
135
|
+
## Contributors ✨
|
|
136
|
+
|
|
137
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
138
|
+
|
|
139
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
140
|
+
<!-- prettier-ignore-start -->
|
|
141
|
+
<!-- markdownlint-disable -->
|
|
142
|
+
<table>
|
|
143
|
+
<tr>
|
|
144
|
+
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=favna" title="Code">💻</a> <a href="#infra-favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-favna" title="Project Management">📆</a></td>
|
|
145
|
+
<td align="center"><a href="https://Quantumlyy.com"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnic</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Quantumlyy" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Quantumlyy" title="Documentation">📖</a></td>
|
|
146
|
+
<td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio Román</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kyranet" title="Code">💻</a></td>
|
|
147
|
+
<td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">👀</a></td>
|
|
148
|
+
<td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
|
|
149
|
+
<td align="center"><a href="https://github.com/apps/dependabot"><img src="https://avatars0.githubusercontent.com/in/29110?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dependabot[bot]</b></sub></a><br /><a href="#maintenance-dependabot[bot]" title="Maintenance">🚧</a></td>
|
|
150
|
+
<td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=allcontributors[bot]" title="Documentation">📖</a></td>
|
|
151
|
+
</tr>
|
|
152
|
+
<tr>
|
|
153
|
+
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Documentation">📖</a></td>
|
|
154
|
+
<td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Stitch07" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/issues?q=author%3AStitch07" title="Bug reports">🐛</a></td>
|
|
155
|
+
<td align="center"><a href="https://github.com/PlatinBae"><img src="https://avatars.githubusercontent.com/u/50950966?v=4?s=100" width="100px;" alt=""/><br /><sub><b>PlatinBae</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=PlatinBae" title="Documentation">📖</a></td>
|
|
156
|
+
<td align="center"><a href="https://kaname.netlify.app"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Documentation">📖</a></td>
|
|
157
|
+
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=noftaly" title="Code">💻</a></td>
|
|
158
|
+
<td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Lioness100" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Lioness100" title="Documentation">📖</a></td>
|
|
159
|
+
<td align="center"><a href="https://github.com/UndiedGamer"><img src="https://avatars.githubusercontent.com/u/84702365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UndiedGamer</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=UndiedGamer" title="Code">💻</a></td>
|
|
160
|
+
</tr>
|
|
161
|
+
<tr>
|
|
162
|
+
<td align="center"><a href="https://github.com/feralheart"><img src="https://avatars.githubusercontent.com/u/3487559?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Feralheart</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=feralheart" title="Code">💻</a></td>
|
|
163
|
+
<td align="center"><a href="https://jurien.dev/"><img src="https://avatars.githubusercontent.com/u/5418114?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jurien Hamaker</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=jurienhamaker" title="Code">💻</a></td>
|
|
164
|
+
<td align="center"><a href="https://github.com/apps/renovate"><img src="https://avatars.githubusercontent.com/in/2740?v=4?s=100" width="100px;" alt=""/><br /><sub><b>renovate[bot]</b></sub></a><br /><a href="#maintenance-renovate[bot]" title="Maintenance">🚧</a></td>
|
|
165
|
+
<td align="center"><a href="https://renovate.whitesourcesoftware.com/"><img src="https://avatars.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">🚧</a></td>
|
|
166
|
+
<td align="center"><a href="https://c43721.github.io/"><img src="https://avatars.githubusercontent.com/u/55610086?v=4?s=100" width="100px;" alt=""/><br /><sub><b>c43721</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=c43721" title="Code">💻</a></td>
|
|
167
|
+
<td align="center"><a href="https://megatank58.me/"><img src="https://avatars.githubusercontent.com/u/51410502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>megatank58</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=megatank58" title="Code">💻</a></td>
|
|
168
|
+
<td align="center"><a href="https://fc5570.me/"><img src="https://avatars.githubusercontent.com/u/68158483?v=4?s=100" width="100px;" alt=""/><br /><sub><b>FC</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=FC5570" title="Code">💻</a></td>
|
|
169
|
+
</tr>
|
|
170
|
+
</table>
|
|
171
|
+
|
|
172
|
+
<!-- markdownlint-restore -->
|
|
173
|
+
<!-- prettier-ignore-end -->
|
|
174
|
+
|
|
175
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
176
|
+
|
|
177
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
|
|
178
|
+
Contributions of any kind welcome!
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,KAAK,SAWpB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.start = void 0;
|
|
4
|
+
const framework_1 = require("@sapphire/framework");
|
|
5
|
+
const chokidar_1 = require("chokidar");
|
|
6
|
+
const console_1 = require("console");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
/**
|
|
9
|
+
* Starts HMR for all registered {@link Store Stores} in {@link container.stores the main container}.
|
|
10
|
+
*/
|
|
11
|
+
function start() {
|
|
12
|
+
framework_1.container.logger.info('HMR-Plugin: Enabled.');
|
|
13
|
+
for (const store of framework_1.container.stores.values()) {
|
|
14
|
+
const deleteCb = handlePiecePathDelete.bind(null, store);
|
|
15
|
+
const updateCb = handlePiecePathUpdate.bind(null, store);
|
|
16
|
+
(0, chokidar_1.watch)([...store.paths])
|
|
17
|
+
.on('change', updateCb)
|
|
18
|
+
.on('unlink', deleteCb);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.start = start;
|
|
22
|
+
async function handlePiecePathDelete(store, path) {
|
|
23
|
+
if (!store.strategy.filter(path))
|
|
24
|
+
return;
|
|
25
|
+
const pieceToDelete = store.find((piece) => piece.location.full === path);
|
|
26
|
+
if (!pieceToDelete)
|
|
27
|
+
return;
|
|
28
|
+
const result = await (0, framework_1.fromAsync)(async () => {
|
|
29
|
+
await pieceToDelete.unload();
|
|
30
|
+
framework_1.container.logger.info(`HMR-Plugin: Unloaded ${pieceToDelete.name}.`);
|
|
31
|
+
});
|
|
32
|
+
if ((0, framework_1.isErr)(result)) {
|
|
33
|
+
framework_1.container.logger.error(`HMR-Plugin: Failed to unload ${pieceToDelete.name}.`, console_1.error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function handlePiecePathUpdate(store, path) {
|
|
37
|
+
if (!store.strategy.filter(path))
|
|
38
|
+
return;
|
|
39
|
+
const pieceToUpdate = store.find((piece) => piece.location.full === path);
|
|
40
|
+
const result = await (0, framework_1.fromAsync)(async () => {
|
|
41
|
+
if (pieceToUpdate) {
|
|
42
|
+
await pieceToUpdate.reload();
|
|
43
|
+
framework_1.container.logger.info(`HMR-Plugin: reloaded ${pieceToUpdate.name}.`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const rootPath = [...store.paths].find((storePath) => path.startsWith(storePath));
|
|
47
|
+
if (!rootPath)
|
|
48
|
+
throw new Error(`HMR-Plugin: Could not find root path for ${path}.`);
|
|
49
|
+
const commandsLoaded = await store.load(rootPath, (0, path_1.relative)(rootPath, path));
|
|
50
|
+
const commandsLoadedNames = commandsLoaded.map((piece) => piece.name);
|
|
51
|
+
framework_1.container.logger.info(`HMR-Plugin: Loaded ${commandsLoadedNames.join(', ')}.`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
if ((0, framework_1.isErr)(result)) {
|
|
55
|
+
framework_1.container.logger.error(`HMR-Plugin: Failed to load pieces from ${path}.`, result.error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin, postLogin, SapphireClient } from '@sapphire/framework';
|
|
2
|
+
/**
|
|
3
|
+
* @since 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
export declare class HmrPlugin extends Plugin {
|
|
6
|
+
/**
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
static [postLogin](this: SapphireClient): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGxE;;GAEG;AACH,qBAAa,SAAU,SAAQ,MAAM;IACpC;;OAEG;WACW,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;CAGrD"}
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HmrPlugin = void 0;
|
|
4
|
+
const framework_1 = require("@sapphire/framework");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
/**
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
class HmrPlugin extends framework_1.Plugin {
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
static [framework_1.postLogin]() {
|
|
14
|
+
(0, index_1.start)();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.HmrPlugin = HmrPlugin;
|
|
18
|
+
framework_1.SapphireClient.plugins.registerPostLoginHook(HmrPlugin[framework_1.postLogin], 'Hmr-PostLogin');
|
|
19
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,mDAAwE;AACxE,mCAAgC;AAEhC;;GAEG;AACH,MAAa,SAAU,SAAQ,kBAAM;IACpC;;OAEG;IACI,MAAM,CAAC,CAAC,qBAAS,CAAC;QACxB,IAAA,aAAK,GAAE,CAAC;IACT,CAAC;CACD;AAPD,8BAOC;AAED,0BAAc,CAAC,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,qBAAS,CAAC,EAAE,eAAe,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sapphire/plugin-hmr",
|
|
3
|
+
"version": "0.1.0-next.4a18bb1.0",
|
|
4
|
+
"description": "Plugin for @sapphire/framework for hot module reloading for pieces",
|
|
5
|
+
"author": "@sapphire",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"typedocMain": "src/index.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./register": {
|
|
17
|
+
"import": "./register.mjs",
|
|
18
|
+
"require": "./register.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./dist/register.js",
|
|
23
|
+
"./register.js",
|
|
24
|
+
"./register.mjs"
|
|
25
|
+
],
|
|
26
|
+
"homepage": "https://sapphirejs.dev",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"lint": "eslint src --ext ts --fix",
|
|
29
|
+
"build": "tsc -b src && yarn esm:register && yarn esm:default",
|
|
30
|
+
"esm:register": "gen-esm-wrapper dist/register.js dist/register.mjs",
|
|
31
|
+
"esm:default": "gen-esm-wrapper dist/index.js dist/index.mjs",
|
|
32
|
+
"prepublishOnly": "yarn build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"chokidar": "^3.5.2",
|
|
36
|
+
"tslib": "2.x"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/sapphiredev/plugins.git",
|
|
41
|
+
"directory": "packages/hmr"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"!dist/*.tsbuildinfo",
|
|
46
|
+
"register.*"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.6.0",
|
|
50
|
+
"npm": ">=7.0.0"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"sapphiredev",
|
|
54
|
+
"plugin",
|
|
55
|
+
"bot",
|
|
56
|
+
"typescript",
|
|
57
|
+
"ts",
|
|
58
|
+
"yarn",
|
|
59
|
+
"discord",
|
|
60
|
+
"sapphire"
|
|
61
|
+
],
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/sapphiredev/plugins/issues"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "4a18bb1377a8d506fddc5bb991430503902d393b"
|
|
69
|
+
}
|
package/register.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/register';
|
package/register.js
ADDED
package/register.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/register.mjs';
|