@sapphire/plugin-hmr 3.0.2-next.fe95a62.0 → 3.0.3-next.dd4b95f
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/CHANGELOG.md +10 -0
- package/README.md +0 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/lib/hmr.cjs +9 -17
- package/dist/cjs/lib/hmr.cjs.map +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/cjs/register.cjs.map +1 -1
- package/dist/esm/{chunk-G5GHKT7C.mjs → chunk-PAWJFY3S.mjs} +2 -2
- package/dist/esm/chunk-PAWJFY3S.mjs.map +1 -0
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/hmr.mjs +10 -18
- package/dist/esm/lib/hmr.mjs.map +1 -1
- package/dist/esm/register.mjs +2 -2
- package/dist/esm/register.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/esm/chunk-G5GHKT7C.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@sapphire/plugin-hmr@3.0.2](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-hmr@3.0.1...@sapphire/plugin-hmr@3.0.2) - (2024-11-02)
|
|
6
|
+
|
|
7
|
+
## 🐛 Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **deps:** Update dependency chokidar to v4 ([e6fdc84](https://github.com/sapphiredev/plugins/commit/e6fdc8494268eec4aba7f06f54e48454b2fabbc0)) ([#626](https://github.com/sapphiredev/plugins/pull/626) by @renovate[bot])
|
|
10
|
+
- **deps:** Update all non-major dependencies ([43df709](https://github.com/sapphiredev/plugins/commit/43df70954d837f7b14d62ea9123aca4b1da9ae36)) ([#574](https://github.com/sapphiredev/plugins/pull/574) by @renovate[bot])
|
|
11
|
+
- **deps:** Update all non-major dependencies ([7909d16](https://github.com/sapphiredev/plugins/commit/7909d16fcec9a8e5e9a3f8816c90a26fbc7d1284)) ([#573](https://github.com/sapphiredev/plugins/pull/573) by @renovate[bot])
|
|
12
|
+
- **deps:** Update all non-major dependencies ([ee64834](https://github.com/sapphiredev/plugins/commit/ee64834c799a5ac28b1ae172cb19f77a1887f3d4)) ([#546](https://github.com/sapphiredev/plugins/pull/546) by @renovate[bot])
|
|
13
|
+
- **hmr:** Update transitive dependencies ([7579d59](https://github.com/sapphiredev/plugins/commit/7579d599e5422cd1f6480567ed78abd1c06bd3b6))
|
|
14
|
+
|
|
5
15
|
# [@sapphire/plugin-hmr@3.0.1](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-hmr@3.0.1...@sapphire/plugin-hmr@3.0.1) - (2024-01-19)
|
|
6
16
|
|
|
7
17
|
## 🐛 Bug Fixes
|
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
**Plugin for <a href="https://github.com/sapphiredev/framework">@sapphire/framework</a> for super-speed HMR.**
|
|
8
8
|
|
|
9
9
|
[](https://github.com/sapphiredev/plugins/blob/main/LICENSE.md)
|
|
10
|
-
[](https://codecov.io/gh/sapphiredev/plugins)
|
|
11
10
|
[](https://bundlephobia.com/result?p=@sapphire/plugin-hmr)
|
|
12
11
|
[](https://www.npmjs.com/package/@sapphire/plugin-hmr)
|
|
13
12
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var hmr_cjs = require('./lib/hmr.cjs');
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
|
-
var version = "3.0.
|
|
6
|
+
var version = "3.0.3-next.dd4b95f";
|
|
7
7
|
|
|
8
8
|
exports.version = version;
|
|
9
9
|
Object.keys(hmr_cjs).forEach(function (k) {
|
|
@@ -12,5 +12,5 @@ Object.keys(hmr_cjs).forEach(function (k) {
|
|
|
12
12
|
get: function () { return hmr_cjs[k]; }
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=index.cjs.map
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAiBO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["export * from './lib/hmr';\n\nimport type { HMROptions } from './lib/hmr';\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\thmr?: HMROptions;\n\t}\n}\n\n/**\n * The [@sapphire/plugin-hmr](https://github.com/sapphiredev/plugins/blob/main/packages/hmr) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '3.0.3-next.dd4b95f';\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
package/dist/cjs/lib/hmr.cjs
CHANGED
|
@@ -7,25 +7,20 @@ var path = require('path');
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
9
|
function start({ enabled = true, silent = false, ...options } = { enabled: true }) {
|
|
10
|
-
if (!enabled)
|
|
11
|
-
|
|
12
|
-
if (!silent)
|
|
13
|
-
framework.container.logger.info("[HMR-Plugin]: Enabled. Watching for piece changes.");
|
|
10
|
+
if (!enabled) return;
|
|
11
|
+
if (!silent) framework.container.logger.info("[HMR-Plugin]: Enabled. Watching for piece changes.");
|
|
14
12
|
for (const store of framework.container.stores.values()) {
|
|
15
13
|
chokidar.watch([...store.paths], options).on("change", (path) => handlePiecePathUpdate(store, path, silent)).on("unlink", (path) => handlePiecePathDelete(store, path, silent));
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
16
|
__name(start, "start");
|
|
19
17
|
async function handlePiecePathDelete(store, path, silent) {
|
|
20
|
-
if (!store.strategy.filter(path))
|
|
21
|
-
return;
|
|
18
|
+
if (!store.strategy.filter(path)) return;
|
|
22
19
|
const pieceToDelete = store.find((piece) => piece.location.full === path);
|
|
23
|
-
if (!pieceToDelete)
|
|
24
|
-
return;
|
|
20
|
+
if (!pieceToDelete) return;
|
|
25
21
|
const result = await framework.Result.fromAsync(async () => {
|
|
26
22
|
await pieceToDelete.unload();
|
|
27
|
-
if (!silent)
|
|
28
|
-
framework.container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`);
|
|
23
|
+
if (!silent) framework.container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`);
|
|
29
24
|
});
|
|
30
25
|
result.inspectErr(
|
|
31
26
|
(error) => framework.container.logger.error(`[HMR-Plugin]: Failed to unload ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`, error)
|
|
@@ -33,18 +28,15 @@ async function handlePiecePathDelete(store, path, silent) {
|
|
|
33
28
|
}
|
|
34
29
|
__name(handlePiecePathDelete, "handlePiecePathDelete");
|
|
35
30
|
async function handlePiecePathUpdate(store, path$1, silent) {
|
|
36
|
-
if (!store.strategy.filter(path$1))
|
|
37
|
-
return;
|
|
31
|
+
if (!store.strategy.filter(path$1)) return;
|
|
38
32
|
const pieceToUpdate = store.find((piece) => piece.location.full === path$1);
|
|
39
33
|
const result = await framework.Result.fromAsync(async () => {
|
|
40
34
|
if (pieceToUpdate) {
|
|
41
35
|
await pieceToUpdate.reload();
|
|
42
|
-
if (!silent)
|
|
43
|
-
framework.container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`);
|
|
36
|
+
if (!silent) framework.container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`);
|
|
44
37
|
} else {
|
|
45
38
|
const rootPath = [...store.paths].find((storePath) => path$1.startsWith(storePath));
|
|
46
|
-
if (!rootPath)
|
|
47
|
-
throw new Error(`[HMR-Plugin]: Could not find root path for ${path$1}.`);
|
|
39
|
+
if (!rootPath) throw new Error(`[HMR-Plugin]: Could not find root path for ${path$1}.`);
|
|
48
40
|
const piecesLoaded = await store.load(rootPath, path.relative(rootPath, path$1));
|
|
49
41
|
const piecesLoadedNames = piecesLoaded.map((piece) => piece.name);
|
|
50
42
|
const piecesLoadedStoreNames = piecesLoaded.map((piece) => piece.store.name);
|
|
@@ -59,5 +51,5 @@ async function handlePiecePathUpdate(store, path$1, silent) {
|
|
|
59
51
|
__name(handlePiecePathUpdate, "handlePiecePathUpdate");
|
|
60
52
|
|
|
61
53
|
exports.start = start;
|
|
62
|
-
//# sourceMappingURL=
|
|
54
|
+
//# sourceMappingURL=hmr.cjs.map
|
|
63
55
|
//# sourceMappingURL=hmr.cjs.map
|
package/dist/cjs/lib/hmr.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/hmr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/hmr.ts"],"names":["container","watch","Result","path","relative"],"mappings":";;;;;;;;AAmBO,SAAS,KAAM,CAAA,EAAE,OAAU,GAAA,IAAA,EAAM,MAAS,GAAA,KAAA,EAAO,GAAG,OAAA,EAAwB,GAAA,EAAE,OAAS,EAAA,IAAA,EAAQ,EAAA;AAErG,EAAA,IAAI,CAAC,OAAS,EAAA;AAEd,EAAA,IAAI,CAAC,MAAA,EAAkBA,mBAAA,CAAA,MAAA,CAAO,KAAK,oDAAoD,CAAA;AAEvF,EAAA,KAAA,MAAW,KAAS,IAAAA,mBAAA,CAAU,MAAO,CAAA,MAAA,EAAU,EAAA;A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CAAA,IAAI,CAAC,CAAkB,eAAA,EAAA,CAAC,GAAG,IAAI,IAAI,sBAAsB,CAAC,CAAE,CAAA,IAAA,CAAK,IAAI,CAAC,CAAA,UAAA;AAAA,SACtH;AAAA;AACF,GACA,CAAA;AAED,EAAO,MAAA,CAAA,UAAA,CAAW,CAAC,KAAA,KAAUA,mBAAU,CAAA,MAAA,CAAO,MAAM,CAA4C,yCAAA,EAAAG,MAAI,CAAK,CAAA,CAAA,EAAA,KAAK,CAAC,CAAA;AAChH;AAxBe,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA","file":"hmr.cjs","sourcesContent":["import { Piece, Result, Store, container } from '@sapphire/framework';\nimport { watch, type ChokidarOptions } from 'chokidar';\nimport { relative } from 'node:path';\n\nexport interface HMROptions extends ChokidarOptions {\n\tenabled?: boolean;\n\tsilent?: boolean;\n}\n\n/**\n * Starts HMR for all registered {@link Store Stores} in {@link container.stores the main container}.\n *\n * @param __namedParameter The {@link HMROptions}.\n * This includes [all options from chokidar](https://github.com/paulmillr/chokidar#persistence),\n * as well as whether the HMR should be enabled.\n * The default options are `{ enabled: true }`,\n * and if not provided in the object then `enabled` is also set to true.\n *\n */\nexport function start({ enabled = true, silent = false, ...options }: HMROptions = { enabled: true }) {\n\t// Do not enable plugin when enabled is false\n\tif (!enabled) return;\n\n\tif (!silent) container.logger.info('[HMR-Plugin]: Enabled. Watching for piece changes.');\n\n\tfor (const store of container.stores.values()) {\n\t\twatch([...store.paths], options)\n\t\t\t.on('change', (path) => handlePiecePathUpdate(store, path, silent))\n\t\t\t.on('unlink', (path) => handlePiecePathDelete(store, path, silent));\n\t}\n}\n\nasync function handlePiecePathDelete(store: Store<Piece>, path: string, silent: boolean) {\n\tif (!store.strategy.filter(path)) return;\n\n\tconst pieceToDelete = store.find((piece) => piece.location.full === path);\n\tif (!pieceToDelete) return;\n\n\tconst result = await Result.fromAsync(async () => {\n\t\tawait pieceToDelete.unload();\n\t\tif (!silent) container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`);\n\t});\n\n\tresult.inspectErr((error) =>\n\t\tcontainer.logger.error(`[HMR-Plugin]: Failed to unload ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`, error)\n\t);\n}\n\nasync function handlePiecePathUpdate(store: Store<Piece>, path: string, silent: boolean) {\n\tif (!store.strategy.filter(path)) return;\n\n\tconst pieceToUpdate = store.find((piece) => piece.location.full === path);\n\n\tconst result = await Result.fromAsync(async () => {\n\t\tif (pieceToUpdate) {\n\t\t\tawait pieceToUpdate.reload();\n\t\t\tif (!silent) container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`);\n\t\t} else {\n\t\t\tconst rootPath = [...store.paths].find((storePath) => path.startsWith(storePath));\n\t\t\tif (!rootPath) throw new Error(`[HMR-Plugin]: Could not find root path for ${path}.`);\n\n\t\t\tconst piecesLoaded = await store.load(rootPath, relative(rootPath, path));\n\t\t\tconst piecesLoadedNames = piecesLoaded.map((piece) => piece.name);\n\t\t\tconst piecesLoadedStoreNames = piecesLoaded.map((piece) => piece.store.name);\n\t\t\tif (!silent)\n\t\t\t\tcontainer.logger.info(\n\t\t\t\t\t`[HMR-Plugin]: Loaded ${piecesLoadedNames.join(', ')} piece(s) from ${[...new Set(piecesLoadedStoreNames)].join(', ')} store(s).`\n\t\t\t\t);\n\t\t}\n\t});\n\n\tresult.inspectErr((error) => container.logger.error(`[HMR-Plugin]: Failed to load pieces from ${path}.`, error));\n}\n"]}
|
package/dist/cjs/register.cjs
CHANGED
|
@@ -18,5 +18,5 @@ var HmrPlugin = _HmrPlugin;
|
|
|
18
18
|
framework.SapphireClient.plugins.registerPostLoginHook(HmrPlugin[framework.postLogin], "Hmr-PostLogin");
|
|
19
19
|
|
|
20
20
|
exports.HmrPlugin = HmrPlugin;
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=register.cjs.map
|
|
22
22
|
//# sourceMappingURL=register.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/register.ts"],"names":["Plugin","postLogin","start","SapphireClient"],"mappings":";;;;;;;AAQO,IAAM,UAAA,GAAN,MAAM,UAAA,SAAkBA,gBAAO,CAAA;AAAA;AAAA;AAAA;AAAA,EAIrC,QAAeC,mBAAS,CAA8B,GAAA;AACrD,IAAMC,eAAA,CAAA,IAAA,CAAK,QAAQ,GAAG,CAAA;AAAA;AAExB,CAAA;AAPsC,MAAA,CAAA,UAAA,EAAA,WAAA,CAAA;AAA/B,IAAM,SAAN,GAAA;AASPC,wBAAA,CAAe,OAAQ,CAAA,qBAAA,CAAsB,SAAU,CAAAF,mBAAS,GAAG,eAAe,CAAA","file":"register.cjs","sourcesContent":["import './index';\n\nimport { Plugin, postLogin, SapphireClient } from '@sapphire/framework';\nimport { start } from './index';\n\n/**\n * @since 1.0.0\n */\nexport class HmrPlugin extends Plugin {\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static [postLogin](this: SapphireClient): void {\n\t\tstart(this.options.hmr);\n\t}\n}\n\nSapphireClient.plugins.registerPostLoginHook(HmrPlugin[postLogin], 'Hmr-PostLogin');\n"]}
|
|
@@ -2,5 +2,5 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
export { __name };
|
|
5
|
-
//# sourceMappingURL=
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-PAWJFY3S.mjs.map
|
|
6
|
+
//# sourceMappingURL=chunk-PAWJFY3S.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-PAWJFY3S.mjs"}
|
package/dist/esm/index.d.mts
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-PAWJFY3S.mjs';
|
|
2
2
|
export * from './lib/hmr.mjs';
|
|
3
3
|
|
|
4
|
-
var version = "3.0.
|
|
4
|
+
var version = "3.0.3-next.dd4b95f";
|
|
5
5
|
|
|
6
6
|
export { version };
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=index.mjs.map
|
|
8
8
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;AAiBO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["export * from './lib/hmr';\n\nimport type { HMROptions } from './lib/hmr';\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\thmr?: HMROptions;\n\t}\n}\n\n/**\n * The [@sapphire/plugin-hmr](https://github.com/sapphiredev/plugins/blob/main/packages/hmr) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '3.0.3-next.dd4b95f';\n"]}
|
package/dist/esm/lib/hmr.mjs
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { container, Result } from '@sapphire/framework';
|
|
3
3
|
import { watch } from 'chokidar';
|
|
4
4
|
import { relative } from 'node:path';
|
|
5
5
|
|
|
6
6
|
function start({ enabled = true, silent = false, ...options } = { enabled: true }) {
|
|
7
|
-
if (!enabled)
|
|
8
|
-
|
|
9
|
-
if (!silent)
|
|
10
|
-
container.logger.info("[HMR-Plugin]: Enabled. Watching for piece changes.");
|
|
7
|
+
if (!enabled) return;
|
|
8
|
+
if (!silent) container.logger.info("[HMR-Plugin]: Enabled. Watching for piece changes.");
|
|
11
9
|
for (const store of container.stores.values()) {
|
|
12
10
|
watch([...store.paths], options).on("change", (path) => handlePiecePathUpdate(store, path, silent)).on("unlink", (path) => handlePiecePathDelete(store, path, silent));
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
13
|
__name(start, "start");
|
|
16
14
|
async function handlePiecePathDelete(store, path, silent) {
|
|
17
|
-
if (!store.strategy.filter(path))
|
|
18
|
-
return;
|
|
15
|
+
if (!store.strategy.filter(path)) return;
|
|
19
16
|
const pieceToDelete = store.find((piece) => piece.location.full === path);
|
|
20
|
-
if (!pieceToDelete)
|
|
21
|
-
return;
|
|
17
|
+
if (!pieceToDelete) return;
|
|
22
18
|
const result = await Result.fromAsync(async () => {
|
|
23
19
|
await pieceToDelete.unload();
|
|
24
|
-
if (!silent)
|
|
25
|
-
container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`);
|
|
20
|
+
if (!silent) container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`);
|
|
26
21
|
});
|
|
27
22
|
result.inspectErr(
|
|
28
23
|
(error) => container.logger.error(`[HMR-Plugin]: Failed to unload ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`, error)
|
|
@@ -30,18 +25,15 @@ async function handlePiecePathDelete(store, path, silent) {
|
|
|
30
25
|
}
|
|
31
26
|
__name(handlePiecePathDelete, "handlePiecePathDelete");
|
|
32
27
|
async function handlePiecePathUpdate(store, path, silent) {
|
|
33
|
-
if (!store.strategy.filter(path))
|
|
34
|
-
return;
|
|
28
|
+
if (!store.strategy.filter(path)) return;
|
|
35
29
|
const pieceToUpdate = store.find((piece) => piece.location.full === path);
|
|
36
30
|
const result = await Result.fromAsync(async () => {
|
|
37
31
|
if (pieceToUpdate) {
|
|
38
32
|
await pieceToUpdate.reload();
|
|
39
|
-
if (!silent)
|
|
40
|
-
container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`);
|
|
33
|
+
if (!silent) container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`);
|
|
41
34
|
} else {
|
|
42
35
|
const rootPath = [...store.paths].find((storePath) => path.startsWith(storePath));
|
|
43
|
-
if (!rootPath)
|
|
44
|
-
throw new Error(`[HMR-Plugin]: Could not find root path for ${path}.`);
|
|
36
|
+
if (!rootPath) throw new Error(`[HMR-Plugin]: Could not find root path for ${path}.`);
|
|
45
37
|
const piecesLoaded = await store.load(rootPath, relative(rootPath, path));
|
|
46
38
|
const piecesLoadedNames = piecesLoaded.map((piece) => piece.name);
|
|
47
39
|
const piecesLoadedStoreNames = piecesLoaded.map((piece) => piece.store.name);
|
|
@@ -56,5 +48,5 @@ async function handlePiecePathUpdate(store, path, silent) {
|
|
|
56
48
|
__name(handlePiecePathUpdate, "handlePiecePathUpdate");
|
|
57
49
|
|
|
58
50
|
export { start };
|
|
59
|
-
//# sourceMappingURL=
|
|
51
|
+
//# sourceMappingURL=hmr.mjs.map
|
|
60
52
|
//# sourceMappingURL=hmr.mjs.map
|
package/dist/esm/lib/hmr.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/hmr.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/hmr.ts"],"names":[],"mappings":";;;;;AAmBO,SAAS,KAAM,CAAA,EAAE,OAAU,GAAA,IAAA,EAAM,MAAS,GAAA,KAAA,EAAO,GAAG,OAAA,EAAwB,GAAA,EAAE,OAAS,EAAA,IAAA,EAAQ,EAAA;AAErG,EAAA,IAAI,CAAC,OAAS,EAAA;AAEd,EAAA,IAAI,CAAC,MAAA,EAAkB,SAAA,CAAA,MAAA,CAAO,KAAK,oDAAoD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CAAA,IAAA;AAAA,UAChB,CAAwB,qBAAA,EAAA,iBAAA,CAAkB,IAAK,CAAA,IAAI,CAAC,CAAkB,eAAA,EAAA,CAAC,GAAG,IAAI,IAAI,sBAAsB,CAAC,CAAE,CAAA,IAAA,CAAK,IAAI,CAAC,CAAA,UAAA;AAAA,SACtH;AAAA;AACF,GACA,CAAA;AAED,EAAO,MAAA,CAAA,UAAA,CAAW,CAAC,KAAA,KAAU,SAAU,CAAA,MAAA,CAAO,MAAM,CAA4C,yCAAA,EAAA,IAAI,CAAK,CAAA,CAAA,EAAA,KAAK,CAAC,CAAA;AAChH;AAxBe,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA","file":"hmr.mjs","sourcesContent":["import { Piece, Result, Store, container } from '@sapphire/framework';\nimport { watch, type ChokidarOptions } from 'chokidar';\nimport { relative } from 'node:path';\n\nexport interface HMROptions extends ChokidarOptions {\n\tenabled?: boolean;\n\tsilent?: boolean;\n}\n\n/**\n * Starts HMR for all registered {@link Store Stores} in {@link container.stores the main container}.\n *\n * @param __namedParameter The {@link HMROptions}.\n * This includes [all options from chokidar](https://github.com/paulmillr/chokidar#persistence),\n * as well as whether the HMR should be enabled.\n * The default options are `{ enabled: true }`,\n * and if not provided in the object then `enabled` is also set to true.\n *\n */\nexport function start({ enabled = true, silent = false, ...options }: HMROptions = { enabled: true }) {\n\t// Do not enable plugin when enabled is false\n\tif (!enabled) return;\n\n\tif (!silent) container.logger.info('[HMR-Plugin]: Enabled. Watching for piece changes.');\n\n\tfor (const store of container.stores.values()) {\n\t\twatch([...store.paths], options)\n\t\t\t.on('change', (path) => handlePiecePathUpdate(store, path, silent))\n\t\t\t.on('unlink', (path) => handlePiecePathDelete(store, path, silent));\n\t}\n}\n\nasync function handlePiecePathDelete(store: Store<Piece>, path: string, silent: boolean) {\n\tif (!store.strategy.filter(path)) return;\n\n\tconst pieceToDelete = store.find((piece) => piece.location.full === path);\n\tif (!pieceToDelete) return;\n\n\tconst result = await Result.fromAsync(async () => {\n\t\tawait pieceToDelete.unload();\n\t\tif (!silent) container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`);\n\t});\n\n\tresult.inspectErr((error) =>\n\t\tcontainer.logger.error(`[HMR-Plugin]: Failed to unload ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`, error)\n\t);\n}\n\nasync function handlePiecePathUpdate(store: Store<Piece>, path: string, silent: boolean) {\n\tif (!store.strategy.filter(path)) return;\n\n\tconst pieceToUpdate = store.find((piece) => piece.location.full === path);\n\n\tconst result = await Result.fromAsync(async () => {\n\t\tif (pieceToUpdate) {\n\t\t\tawait pieceToUpdate.reload();\n\t\t\tif (!silent) container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`);\n\t\t} else {\n\t\t\tconst rootPath = [...store.paths].find((storePath) => path.startsWith(storePath));\n\t\t\tif (!rootPath) throw new Error(`[HMR-Plugin]: Could not find root path for ${path}.`);\n\n\t\t\tconst piecesLoaded = await store.load(rootPath, relative(rootPath, path));\n\t\t\tconst piecesLoadedNames = piecesLoaded.map((piece) => piece.name);\n\t\t\tconst piecesLoadedStoreNames = piecesLoaded.map((piece) => piece.store.name);\n\t\t\tif (!silent)\n\t\t\t\tcontainer.logger.info(\n\t\t\t\t\t`[HMR-Plugin]: Loaded ${piecesLoadedNames.join(', ')} piece(s) from ${[...new Set(piecesLoadedStoreNames)].join(', ')} store(s).`\n\t\t\t\t);\n\t\t}\n\t});\n\n\tresult.inspectErr((error) => container.logger.error(`[HMR-Plugin]: Failed to load pieces from ${path}.`, error));\n}\n"]}
|
package/dist/esm/register.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from './chunk-
|
|
1
|
+
import { __name } from './chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { start } from './index.mjs';
|
|
3
3
|
import { SapphireClient, postLogin, Plugin } from '@sapphire/framework';
|
|
4
4
|
|
|
@@ -15,5 +15,5 @@ var HmrPlugin = _HmrPlugin;
|
|
|
15
15
|
SapphireClient.plugins.registerPostLoginHook(HmrPlugin[postLogin], "Hmr-PostLogin");
|
|
16
16
|
|
|
17
17
|
export { HmrPlugin };
|
|
18
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=register.mjs.map
|
|
19
19
|
//# sourceMappingURL=register.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AAQO,IAAM,UAAA,GAAN,MAAM,UAAA,SAAkB,MAAO,CAAA;AAAA;AAAA;AAAA;AAAA,EAIrC,QAAe,SAAS,CAA8B,GAAA;AACrD,IAAM,KAAA,CAAA,IAAA,CAAK,QAAQ,GAAG,CAAA;AAAA;AAExB,CAAA;AAPsC,MAAA,CAAA,UAAA,EAAA,WAAA,CAAA;AAA/B,IAAM,SAAN,GAAA;AASP,cAAA,CAAe,OAAQ,CAAA,qBAAA,CAAsB,SAAU,CAAA,SAAS,GAAG,eAAe,CAAA","file":"register.mjs","sourcesContent":["import './index';\n\nimport { Plugin, postLogin, SapphireClient } from '@sapphire/framework';\nimport { start } from './index';\n\n/**\n * @since 1.0.0\n */\nexport class HmrPlugin extends Plugin {\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static [postLogin](this: SapphireClient): void {\n\t\tstart(this.options.hmr);\n\t}\n}\n\nSapphireClient.plugins.registerPostLoginHook(HmrPlugin[postLogin], 'Hmr-PostLogin');\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-hmr",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3-next.dd4b95f",
|
|
4
4
|
"description": "Plugin for @sapphire/framework for hot module reloading for pieces",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"check-update": "cliff-jumper --dry-run"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"chokidar": "^
|
|
52
|
+
"chokidar": "^4.0.1"
|
|
53
53
|
},
|
|
54
54
|
"repository": {
|
|
55
55
|
"type": "git",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@favware/cliff-jumper": "^
|
|
83
|
+
"@favware/cliff-jumper": "^5.0.0",
|
|
84
84
|
"@favware/rollup-type-bundler": "^3.3.0",
|
|
85
|
-
"concurrently": "^
|
|
86
|
-
"tsup": "^8.
|
|
87
|
-
"tsx": "^4.
|
|
88
|
-
"typedoc": "^0.
|
|
89
|
-
"typedoc-json-parser": "^
|
|
90
|
-
"typescript": "
|
|
85
|
+
"concurrently": "^9.0.1",
|
|
86
|
+
"tsup": "^8.3.5",
|
|
87
|
+
"tsx": "^4.19.2",
|
|
88
|
+
"typedoc": "^0.26.11",
|
|
89
|
+
"typedoc-json-parser": "^10.2.0",
|
|
90
|
+
"typescript": "~5.4.5"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|