commandkit 1.2.1 → 1.2.2
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/README.md +1 -1
- package/cache.cjs +2 -0
- package/cache.d.ts +1 -0
- package/dist/{ActionRow-Bt9qi0Mb.d.ts → ActionRow-DSh9roc5.d.ts} +2 -3
- package/dist/{Button-DxJLcZIU.d.ts → Button-BPsE5ju0.d.ts} +5 -6
- package/dist/{ButtonKit-BfcyvWfj.d.ts → ButtonKit-CNPmVg3h.d.ts} +2 -3
- package/dist/{ChannelSelectMenuKit-DYkudikb.d.ts → ChannelSelectMenuKit-CcOdaLQ6.d.ts} +3 -4
- package/dist/CommandTree-qu-8oAEV.d.ts +55 -0
- package/dist/CommandsRouter-Co225Ae5.d.ts +242 -0
- package/dist/{EventInterceptor-D9JKMcfi.d.ts → EventInterceptor-wg378vJp.d.ts} +1 -2
- package/dist/{EventsRouter-EuuSu6NH.d.ts → EventsRouter-Bt63ZuEF.d.ts} +21 -2
- package/dist/{MentionableSelectMenuKit-Mu4xqP6B.d.ts → MentionableSelectMenuKit-8_Nkgn_a.d.ts} +3 -4
- package/dist/{MessageCommandParser-DPCbHXCS.d.ts → MessageCommandParser-BYbxHOSK.d.ts} +7 -2
- package/dist/{Modal-v9rrcMl-.d.ts → Modal-DbWK6VmV.d.ts} +5 -6
- package/dist/{ModalKit-XJSM65SV.d.ts → ModalKit-CnmUVpw-.d.ts} +2 -3
- package/dist/{RoleSelectMenuKit-CCjcp3HY.d.ts → RoleSelectMenuKit-Bei7DHqD.d.ts} +3 -4
- package/dist/{SelectMenu-CY0vvoSu.d.ts → SelectMenu-Bce_PClo.d.ts} +8 -9
- package/dist/{StringSelectMenuKit-G5nBTicX.d.ts → StringSelectMenuKit-CBeB9HqT.d.ts} +3 -4
- package/dist/TreeArtifact-D6FZ5SVd.d.ts +27 -0
- package/dist/{UserSelectMenuKit-D3SO_fXA.d.ts → UserSelectMenuKit-DZmeZ_Tp.d.ts} +3 -4
- package/dist/analytics/analytics-engine.d.ts +1 -1
- package/dist/analytics/analytics-engine.js +1 -1
- package/dist/analytics/analytics-provider.d.ts +1 -1
- package/dist/analytics/constants.js +0 -1
- package/dist/analytics/constants.js.map +1 -1
- package/dist/analytics/utils.js +1 -1
- package/dist/{analytics-engine-DnRsHBId.d.ts → analytics-engine-Bz1p7ud3.d.ts} +178 -30
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.js +1 -1
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +1 -1
- package/dist/app/commands/MessageCommandParser.d.ts +1 -1
- package/dist/app/commands/MessageCommandParser.js +79 -71
- package/dist/app/commands/MessageCommandParser.js.map +1 -1
- package/dist/app/commands/helpers.d.ts +1 -1
- package/dist/app/commands/helpers.js +0 -1
- package/dist/app/commands/helpers.js.map +1 -1
- package/dist/app/events/EventWorkerContext.d.ts +3 -3
- package/dist/app/events/EventWorkerContext.js +0 -1
- package/dist/app/events/EventWorkerContext.js.map +1 -1
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppCommandHandler.js +1 -1
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +1 -1
- package/dist/app/index.d.ts +5 -5
- package/dist/app/index.js +1 -1
- package/dist/app/interrupt/signals.d.ts +1 -1
- package/dist/app/interrupt/signals.js.map +1 -1
- package/dist/app/middlewares/permissions.d.ts +1 -2
- package/dist/app/middlewares/permissions.js +1 -1
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +1 -1
- package/dist/app/router/CommandTree.d.ts +2 -0
- package/dist/app/router/CommandTree.js +1 -0
- package/dist/app/router/CommandsRouter.d.ts +2 -2
- package/dist/app/router/CommandsRouter.js +445 -24
- package/dist/app/router/CommandsRouter.js.map +1 -1
- package/dist/app/router/EventsRouter.d.ts +2 -2
- package/dist/app/router/EventsRouter.js +56 -3
- package/dist/app/router/EventsRouter.js.map +1 -1
- package/dist/app/router/TreeArtifact.d.ts +2 -0
- package/dist/app/router/TreeArtifact.js +87 -0
- package/dist/app/router/TreeArtifact.js.map +1 -0
- package/dist/app/router/index.d.ts +6 -3
- package/dist/app/router/index.js +8 -1
- package/dist/checkbox-DoR0Pcxm.d.ts +27 -0
- package/dist/cli/app-process.d.ts +2 -3
- package/dist/cli/app-process.js +15 -4
- package/dist/cli/app-process.js.map +1 -1
- package/dist/cli/build.d.ts +4 -9
- package/dist/cli/build.js +33 -5
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/common.d.ts +3 -6
- package/dist/cli/common.js +2 -2
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/development.d.ts +5 -6
- package/dist/cli/development.js +12 -12
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/generators.js +0 -1
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +5 -5
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +1 -3
- package/dist/cli/init.js +37 -12
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/production.d.ts +1 -3
- package/dist/cli/production.js +4 -4
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +0 -1
- package/dist/cli/type-checker.js.map +1 -1
- package/dist/cli/utils.d.ts +0 -1
- package/dist/cli/utils.js.map +1 -1
- package/dist/{commandkit-Bh7C1_c7.js → commandkit-DNbfLwyR.js} +786 -200
- package/dist/commandkit-DNbfLwyR.js.map +1 -0
- package/dist/commandkit.d.ts +1 -1
- package/dist/commandkit.js +1 -1
- package/dist/{common-CCvvgnxi.d.ts → common-CIbPzguv.d.ts} +2 -3
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/EventInterceptor.js +1 -0
- package/dist/components/common/EventInterceptor.js.map +1 -1
- package/dist/components/common/element.d.ts +1 -1
- package/dist/components/common/element.js +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/display/common.d.ts +0 -1
- package/dist/components/display/common.js +1 -1
- package/dist/components/display/container.d.ts +1 -1
- package/dist/components/display/container.js +1 -1
- package/dist/components/display/file.d.ts +1 -1
- package/dist/components/display/file.js +0 -1
- package/dist/components/display/file.js.map +1 -1
- package/dist/components/display/index.d.ts +9 -8
- package/dist/components/display/index.js +1 -1
- package/dist/components/display/label.d.ts +1 -1
- package/dist/components/display/label.js +1 -1
- package/dist/components/display/media-gallery.d.ts +1 -1
- package/dist/components/display/media-gallery.js +1 -1
- package/dist/components/display/poll.d.ts +1 -1
- package/dist/components/display/poll.js +4 -10
- package/dist/components/display/poll.js.map +1 -1
- package/dist/components/display/section.d.ts +1 -1
- package/dist/components/display/section.js +1 -1
- package/dist/components/display/separator.d.ts +1 -1
- package/dist/components/display/separator.js +0 -1
- package/dist/components/display/separator.js.map +1 -1
- package/dist/components/display/text-display.d.ts +1 -1
- package/dist/components/display/text-display.js +0 -1
- package/dist/components/display/text-display.js.map +1 -1
- package/dist/components/index.d.ts +26 -23
- package/dist/components/index.js +6 -1
- package/dist/components/interactive/action-row/ActionRow.d.ts +1 -1
- package/dist/components/interactive/action-row/ActionRow.js +0 -1
- package/dist/components/interactive/action-row/ActionRow.js.map +1 -1
- package/dist/components/interactive/button/Button.d.ts +1 -1
- package/dist/components/interactive/button/Button.js +1 -1
- package/dist/components/interactive/button/ButtonKit.d.ts +1 -1
- package/dist/components/interactive/button/ButtonKit.js +1 -1
- package/dist/components/interactive/checkbox/checkbox.d.ts +2 -0
- package/dist/components/interactive/checkbox/checkbox.js +6 -0
- package/dist/components/interactive/modal/Modal.d.ts +1 -1
- package/dist/components/interactive/modal/Modal.js +1 -1
- package/dist/components/interactive/modal/ModalKit.d.ts +1 -1
- package/dist/components/interactive/modal/ModalKit.js +1 -1
- package/dist/components/interactive/radio/radio.d.ts +2 -0
- package/dist/components/interactive/radio/radio.js +5 -0
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.js +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/common.d.ts +1 -1
- package/dist/config/config.d.ts +1 -2
- package/dist/config/config.js +1 -1
- package/dist/config/default.d.ts +1 -2
- package/dist/config/default.js +1 -1
- package/dist/config/loader.d.ts +1 -2
- package/dist/config/loader.js +1 -1
- package/dist/config/types.d.ts +2 -2
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js.map +1 -1
- package/dist/{constants-DqtJY0t-.d.ts → constants-B7AfnOFa.d.ts} +1 -1
- package/dist/{constants-DwxpkIeH.d.ts → constants-kWgE3L9F.d.ts} +15 -2
- package/dist/{container-CYojOA9d.d.ts → container-NVgblXmw.d.ts} +1 -2
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +1 -1
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +1 -1
- package/dist/{element-DeLvTMfZ.d.ts → element-BMZYAAQ-.d.ts} +3 -4
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/events/CommandKitEventsChannel.js +3 -2
- package/dist/events/CommandKitEventsChannel.js.map +1 -1
- package/dist/{file-DLO1zEcH.d.ts → file-DYAmr697.d.ts} +1 -2
- package/dist/flags/FlagProvider.d.ts +1 -1
- package/dist/flags/FlagProvider.js +1 -0
- package/dist/flags/FlagProvider.js.map +1 -1
- package/dist/flags/feature-flags.d.ts +1 -1
- package/dist/flags/feature-flags.js +1 -1
- package/dist/flags/store.d.ts +1 -1
- package/dist/flags/store.js +0 -1
- package/dist/flags/store.js.map +1 -1
- package/dist/{helpers-zmC44Mcu.d.ts → helpers-vlnRvNJv.d.ts} +1 -2
- package/dist/index-CAFaKBs_.d.ts +8 -0
- package/dist/index-COt7nfC9.d.ts +2 -0
- package/dist/index-DvqHpiuh.d.ts +16 -0
- package/dist/index.d.ts +37 -31
- package/dist/index.js +14 -2
- package/dist/kv/constants.d.ts +1 -1
- package/dist/kv/constants.js.map +1 -1
- package/dist/kv/dotprops.js.map +1 -1
- package/dist/kv/kv.d.ts +0 -1
- package/dist/kv/kv.js +1 -1
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.d.ts +1 -2
- package/dist/kv/serde.js +27 -27
- package/dist/kv/serde.js.map +1 -1
- package/dist/{label-DqGRqodo.d.ts → label-DClaYktn.d.ts} +1 -2
- package/dist/logger/DefaultLogger.d.ts +0 -1
- package/dist/logger/DefaultLogger.js +1 -1
- package/dist/logger/Logger.d.ts +0 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/NoopLogger.d.ts +0 -1
- package/dist/logger/NoopLogger.js.map +1 -1
- package/dist/{media-gallery-Ca8es-eB.d.ts → media-gallery-z2Snzz-u.d.ts} +1 -2
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/CompilerPlugin.js +2 -2
- package/dist/plugins/CompilerPlugin.js.map +1 -1
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/PluginCommon.js +1 -1
- package/dist/plugins/PluginCommon.js.map +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.js +2 -2
- package/dist/plugins/RuntimePlugin.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -2
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/{poll-DQ6DX_Tt.d.ts → poll-D2QDStsw.d.ts} +4 -14
- package/dist/radio-CJH_N4lq.d.ts +20 -0
- package/dist/{section-Q8nwx_-q.d.ts → section-DrFBT5b-.d.ts} +1 -2
- package/dist/{separator-B8P-kdIK.d.ts → separator-BVm3w6yd.d.ts} +1 -2
- package/dist/{signals-CBXwugBW.d.ts → signals-DRMDrCOn.d.ts} +1 -1
- package/dist/{text-display-CL9C2yMc.d.ts → text-display-BG0nNqy3.d.ts} +1 -2
- package/dist/{types-DZy7U-Ld.d.ts → types-ur7SvktF.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/colors.d.ts +1 -3
- package/dist/utils/colors.js +0 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +19 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +1 -1
- package/dist/utils/error-codes.js +15 -0
- package/dist/utils/error-codes.js.map +1 -1
- package/dist/utils/resolve-file-url.js +2 -2
- package/dist/utils/resolve-file-url.js.map +1 -1
- package/dist/utils/types-package.d.ts +6 -2
- package/dist/utils/types-package.js +31 -38
- package/dist/utils/types-package.js.map +1 -1
- package/dist/utils/useful-stuff/async-queue.js.map +1 -1
- package/dist/utils/useful-stuff/mutex.js.map +1 -1
- package/dist/utils/useful-stuff/ratelimiter.js +4 -1
- package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.js +1 -1
- package/dist/utils/warning.d.ts +1 -5
- package/dist/utils/warning.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +17 -17
- package/dist/CommandsRouter-DiNoF0dq.d.ts +0 -145
- package/dist/commandkit-Bh7C1_c7.js.map +0 -1
- package/dist/index-BIsCUWAs.d.ts +0 -1
- package/dist/index-CwHYpK-f.d.ts +0 -1
- package/dist/index-DHrsNvX1.d.ts +0 -1
- /package/dist/{chunk-BE-pF4vm.js → rolldown-runtime-C_NdSu1c.js} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../../chunk-BE-pF4vm.js');
|
|
3
2
|
let discord_js = require("discord.js");
|
|
4
3
|
let node_fs = require("node:fs");
|
|
5
4
|
let node_path = require("node:path");
|
|
@@ -11,6 +10,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
11
10
|
* Events are represented by directories, and handlers are files within those directories.
|
|
12
11
|
*/
|
|
13
12
|
var EventsRouter = class {
|
|
13
|
+
options;
|
|
14
14
|
/** Internal storage of parsed events */
|
|
15
15
|
events = new discord_js.Collection();
|
|
16
16
|
/**
|
|
@@ -29,7 +29,7 @@ var EventsRouter = class {
|
|
|
29
29
|
* @param entrypoints - Array of new entrypoint paths
|
|
30
30
|
*/
|
|
31
31
|
addEntrypoints(entrypoints) {
|
|
32
|
-
this.options.entrypoints = Array.from(new Set([...this.options.entrypoints, ...entrypoints]));
|
|
32
|
+
this.options.entrypoints = Array.from(/* @__PURE__ */ new Set([...this.options.entrypoints, ...entrypoints]));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Find a parsed event by its name
|
|
@@ -59,6 +59,13 @@ var EventsRouter = class {
|
|
|
59
59
|
this.events.clear();
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
+
* Populates router state from pre-resolved event metadata.
|
|
63
|
+
*/
|
|
64
|
+
populate(events) {
|
|
65
|
+
this.clear();
|
|
66
|
+
for (const [key, event] of Object.entries(events)) this.events.set(key, event);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
62
69
|
* Reload and re-scan the entrypoint directory for events
|
|
63
70
|
* @returns Promise resolving to the updated events tree
|
|
64
71
|
*/
|
|
@@ -71,6 +78,7 @@ var EventsRouter = class {
|
|
|
71
78
|
* @returns Promise resolving to the events tree
|
|
72
79
|
*/
|
|
73
80
|
async scan() {
|
|
81
|
+
this.clear();
|
|
74
82
|
for (const entrypoint of this.entrypoints) {
|
|
75
83
|
const dirs = await (0, node_fs_promises.readdir)(entrypoint, { withFileTypes: true });
|
|
76
84
|
for (const dir of dirs) if (dir.isDirectory()) {
|
|
@@ -81,6 +89,33 @@ var EventsRouter = class {
|
|
|
81
89
|
return Object.fromEntries(this.events);
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
92
|
+
* Incrementally rescans only the event subtree impacted by a changed path.
|
|
93
|
+
*/
|
|
94
|
+
async scanIncremental(changedPath, _changeType = "change") {
|
|
95
|
+
const resolvedChangedPath = (0, node_path.normalize)(changedPath);
|
|
96
|
+
const entrypoint = this.entrypoints.find((root) => this.isWithinPath(root, resolvedChangedPath));
|
|
97
|
+
if (!entrypoint) return this.toJSON();
|
|
98
|
+
const branch = this.resolveTopLevelBranch(entrypoint, resolvedChangedPath);
|
|
99
|
+
if (!branch) return this.scan();
|
|
100
|
+
const normalizedBranch = (0, node_path.normalize)(branch);
|
|
101
|
+
for (const [key, event] of this.events.entries()) {
|
|
102
|
+
const listeners = event.listeners.filter((listener) => !this.isWithinPath(normalizedBranch, listener));
|
|
103
|
+
if (!listeners.length && this.isWithinPath(normalizedBranch, event.path)) {
|
|
104
|
+
this.events.delete(key);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
this.events.set(key, {
|
|
108
|
+
...event,
|
|
109
|
+
listeners
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if ((0, node_fs.existsSync)(normalizedBranch)) {
|
|
113
|
+
const branchName = branch.slice(entrypoint.length).replace(/^[/\\]/, "").split(/[/\\]/).filter(Boolean)[0];
|
|
114
|
+
if (branchName) await this.scanEvent(branchName, normalizedBranch, null, [], true);
|
|
115
|
+
}
|
|
116
|
+
return this.toJSON();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
84
119
|
* Convert the internal events Collection to a plain object
|
|
85
120
|
* @returns Events tree as a plain object
|
|
86
121
|
*/
|
|
@@ -111,7 +146,7 @@ var EventsRouter = class {
|
|
|
111
146
|
if (!isNamespace) {
|
|
112
147
|
const existing = this.events.get(event);
|
|
113
148
|
if (existing) {
|
|
114
|
-
existing.listeners = Array.from(new Set([...existing.listeners, ...listeners]));
|
|
149
|
+
existing.listeners = Array.from(/* @__PURE__ */ new Set([...existing.listeners, ...listeners]));
|
|
115
150
|
return;
|
|
116
151
|
}
|
|
117
152
|
this.events.set(event, {
|
|
@@ -122,6 +157,24 @@ var EventsRouter = class {
|
|
|
122
157
|
});
|
|
123
158
|
}
|
|
124
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* @private
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
isWithinPath(basePath, targetPath) {
|
|
165
|
+
const rel = (0, node_path.relative)((0, node_path.normalize)(basePath), (0, node_path.normalize)(targetPath));
|
|
166
|
+
if (!rel) return true;
|
|
167
|
+
return !rel.startsWith("..") && !(0, node_path.isAbsolute)(rel);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @private
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
resolveTopLevelBranch(entrypoint, changedPath) {
|
|
174
|
+
const rel = (0, node_path.relative)(entrypoint, changedPath).split(/[/\\]/).filter(Boolean);
|
|
175
|
+
if (!rel.length) return null;
|
|
176
|
+
return (0, node_path.join)(entrypoint, rel[0]);
|
|
177
|
+
}
|
|
125
178
|
};
|
|
126
179
|
|
|
127
180
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventsRouter.js","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"EventsRouter.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as createRouterTreeArtifact, i as RouterTreeArtifact, n as ROUTER_TREE_ARTIFACT_FILE, o as hydrateRouterTreeArtifact, r as ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, s as validateRouterTreeArtifact, t as ROUTER_TREE_ARTIFACT_DIRECTORY } from "../../TreeArtifact-D6FZ5SVd.js";
|
|
2
|
+
export { ROUTER_TREE_ARTIFACT_DIRECTORY, ROUTER_TREE_ARTIFACT_FILE, ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, RouterTreeArtifact, createRouterTreeArtifact, hydrateRouterTreeArtifact, validateRouterTreeArtifact };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
|
|
4
|
+
//#region src/app/router/TreeArtifact.ts
|
|
5
|
+
const ROUTER_TREE_ARTIFACT_SCHEMA_VERSION = 1;
|
|
6
|
+
const ROUTER_TREE_ARTIFACT_FILE = "router-tree.json";
|
|
7
|
+
const ROUTER_TREE_ARTIFACT_DIRECTORY = ".commandkit";
|
|
8
|
+
function createRouterTreeArtifact(options) {
|
|
9
|
+
const { outputRoot, commandkitVersion } = options;
|
|
10
|
+
return {
|
|
11
|
+
schemaVersion: 1,
|
|
12
|
+
commandkitVersion,
|
|
13
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14
|
+
commands: mapCommandDataPaths(options.commands, outputRoot, toRelativePath),
|
|
15
|
+
events: mapEventsTreePaths(options.events, outputRoot, toRelativePath)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function validateRouterTreeArtifact(input, runtimeVersion) {
|
|
19
|
+
if (!input || typeof input !== "object") return false;
|
|
20
|
+
const artifact = input;
|
|
21
|
+
if (artifact.schemaVersion !== 1) return false;
|
|
22
|
+
if (!artifact.commandkitVersion || artifact.commandkitVersion !== runtimeVersion) return false;
|
|
23
|
+
if (!artifact.commands || typeof artifact.commands !== "object") return false;
|
|
24
|
+
if (!artifact.events || typeof artifact.events !== "object") return false;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function hydrateRouterTreeArtifact(artifact, outputRoot) {
|
|
28
|
+
return {
|
|
29
|
+
commands: mapCommandDataPaths(artifact.commands, outputRoot, toAbsolutePath),
|
|
30
|
+
events: mapEventsTreePaths(artifact.events, outputRoot, toAbsolutePath)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function mapCommandDataPaths(data, root, mapper) {
|
|
34
|
+
return {
|
|
35
|
+
commands: Object.fromEntries(Object.entries(data.commands ?? {}).map(([id, command]) => [id, {
|
|
36
|
+
...command,
|
|
37
|
+
path: mapper(root, command.path),
|
|
38
|
+
parentPath: mapper(root, command.parentPath)
|
|
39
|
+
}])),
|
|
40
|
+
middlewares: Object.fromEntries(Object.entries(data.middlewares ?? {}).map(([id, middleware]) => [id, {
|
|
41
|
+
...middleware,
|
|
42
|
+
path: mapper(root, middleware.path),
|
|
43
|
+
parentPath: mapper(root, middleware.parentPath)
|
|
44
|
+
}])),
|
|
45
|
+
treeNodes: Object.fromEntries(Object.entries(data.treeNodes ?? {}).map(([id, node]) => [id, {
|
|
46
|
+
...node,
|
|
47
|
+
directoryPath: mapper(root, node.directoryPath),
|
|
48
|
+
definitionPath: node.definitionPath === null ? null : mapper(root, node.definitionPath)
|
|
49
|
+
}])),
|
|
50
|
+
compiledRoutes: Object.fromEntries(Object.entries(data.compiledRoutes ?? {}).map(([id, route]) => [id, {
|
|
51
|
+
...route,
|
|
52
|
+
definitionPath: mapper(root, route.definitionPath)
|
|
53
|
+
}])),
|
|
54
|
+
diagnostics: (data.diagnostics ?? []).map((diagnostic) => ({
|
|
55
|
+
...diagnostic,
|
|
56
|
+
path: mapper(root, diagnostic.path)
|
|
57
|
+
}))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function mapEventsTreePaths(events, root, mapper) {
|
|
61
|
+
return Object.fromEntries(Object.entries(events ?? {}).map(([id, event]) => [id, {
|
|
62
|
+
...event,
|
|
63
|
+
path: mapper(root, event.path),
|
|
64
|
+
listeners: event.listeners.map((listener) => mapper(root, listener))
|
|
65
|
+
}]));
|
|
66
|
+
}
|
|
67
|
+
function toRelativePath(rootPath, path) {
|
|
68
|
+
if (!path) return path;
|
|
69
|
+
const normalizedPath = (0, node_path.normalize)(path);
|
|
70
|
+
if (!(0, node_path.isAbsolute)(normalizedPath)) return normalizedPath;
|
|
71
|
+
return (0, node_path.normalize)((0, node_path.relative)(rootPath, normalizedPath));
|
|
72
|
+
}
|
|
73
|
+
function toAbsolutePath(rootPath, path) {
|
|
74
|
+
if (!path) return path;
|
|
75
|
+
const normalizedPath = (0, node_path.normalize)(path);
|
|
76
|
+
if ((0, node_path.isAbsolute)(normalizedPath)) return normalizedPath;
|
|
77
|
+
return (0, node_path.normalize)((0, node_path.join)(rootPath, normalizedPath));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
exports.ROUTER_TREE_ARTIFACT_DIRECTORY = ROUTER_TREE_ARTIFACT_DIRECTORY;
|
|
82
|
+
exports.ROUTER_TREE_ARTIFACT_FILE = ROUTER_TREE_ARTIFACT_FILE;
|
|
83
|
+
exports.ROUTER_TREE_ARTIFACT_SCHEMA_VERSION = ROUTER_TREE_ARTIFACT_SCHEMA_VERSION;
|
|
84
|
+
exports.createRouterTreeArtifact = createRouterTreeArtifact;
|
|
85
|
+
exports.hydrateRouterTreeArtifact = hydrateRouterTreeArtifact;
|
|
86
|
+
exports.validateRouterTreeArtifact = validateRouterTreeArtifact;
|
|
87
|
+
//# sourceMappingURL=TreeArtifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeArtifact.js","names":[],"sources":[],"mappings":""}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { i as
|
|
3
|
-
|
|
1
|
+
import { a as CompiledCommandRoute, i as CommandTreeNodeSource, n as CommandTreeNode, r as CommandTreeNodeKind, t as CommandRouteDiagnostic } from "../../CommandTree-qu-8oAEV.js";
|
|
2
|
+
import { a as ParsedCommandData, i as Middleware, n as CommandsRouter, o as RouterFileChangeType, r as CommandsRouterOptions, t as Command } from "../../CommandsRouter-Co225Ae5.js";
|
|
3
|
+
import { a as ParsedEvent, i as EventsTree, n as EventsRouterFileChangeType, r as EventsRouterOptions, t as EventsRouter } from "../../EventsRouter-Bt63ZuEF.js";
|
|
4
|
+
import { a as createRouterTreeArtifact, i as RouterTreeArtifact, n as ROUTER_TREE_ARTIFACT_FILE, o as hydrateRouterTreeArtifact, r as ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, s as validateRouterTreeArtifact, t as ROUTER_TREE_ARTIFACT_DIRECTORY } from "../../TreeArtifact-D6FZ5SVd.js";
|
|
5
|
+
import "../../index-COt7nfC9.js";
|
|
6
|
+
export { Command, CommandRouteDiagnostic, CommandTreeNode, CommandTreeNodeKind, CommandTreeNodeSource, CommandsRouter, CommandsRouterOptions, CompiledCommandRoute, EventsRouter, EventsRouterFileChangeType, EventsRouterOptions, EventsTree, Middleware, ParsedCommandData, ParsedEvent, ROUTER_TREE_ARTIFACT_DIRECTORY, ROUTER_TREE_ARTIFACT_FILE, ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, RouterFileChangeType, RouterTreeArtifact, createRouterTreeArtifact, hydrateRouterTreeArtifact, validateRouterTreeArtifact };
|
package/dist/app/router/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_app_router_CommandsRouter = require('./CommandsRouter.js');
|
|
3
3
|
const require_app_router_EventsRouter = require('./EventsRouter.js');
|
|
4
|
+
const require_app_router_TreeArtifact = require('./TreeArtifact.js');
|
|
4
5
|
|
|
5
6
|
exports.CommandsRouter = require_app_router_CommandsRouter.CommandsRouter;
|
|
6
|
-
exports.EventsRouter = require_app_router_EventsRouter.EventsRouter;
|
|
7
|
+
exports.EventsRouter = require_app_router_EventsRouter.EventsRouter;
|
|
8
|
+
exports.ROUTER_TREE_ARTIFACT_DIRECTORY = require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_DIRECTORY;
|
|
9
|
+
exports.ROUTER_TREE_ARTIFACT_FILE = require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_FILE;
|
|
10
|
+
exports.ROUTER_TREE_ARTIFACT_SCHEMA_VERSION = require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_SCHEMA_VERSION;
|
|
11
|
+
exports.createRouterTreeArtifact = require_app_router_TreeArtifact.createRouterTreeArtifact;
|
|
12
|
+
exports.hydrateRouterTreeArtifact = require_app_router_TreeArtifact.hydrateRouterTreeArtifact;
|
|
13
|
+
exports.validateRouterTreeArtifact = require_app_router_TreeArtifact.validateRouterTreeArtifact;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { t as MaybeArray } from "./types-ur7SvktF.js";
|
|
2
|
+
import { CheckboxBuilder, CheckboxComponentData, CheckboxGroupBuilder, CheckboxGroupComponentData, CheckboxGroupOptionBuilder } from "discord.js";
|
|
3
|
+
//#region src/components/interactive/checkbox/checkbox.d.ts
|
|
4
|
+
interface CheckboxProps extends Omit<CheckboxComponentData, 'type' | 'required'> {
|
|
5
|
+
id?: number;
|
|
6
|
+
default?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function Checkbox(props: CheckboxProps): CheckboxBuilder;
|
|
9
|
+
interface CheckboxGroupOptionProps {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
default?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare function CheckboxGroupOption(props: CheckboxGroupOptionProps): CheckboxGroupOptionBuilder;
|
|
16
|
+
interface CheckboxGroupProps extends Omit<CheckboxGroupComponentData, 'type' | 'options'> {
|
|
17
|
+
id?: number;
|
|
18
|
+
customId: string;
|
|
19
|
+
children?: MaybeArray<CheckboxGroupOptionBuilder>;
|
|
20
|
+
minValues?: number;
|
|
21
|
+
maxValues?: number;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare function CheckboxGroup(props: CheckboxGroupProps): CheckboxGroupBuilder;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CheckboxGroupProps as a, CheckboxGroupOptionProps as i, CheckboxGroup as n, CheckboxProps as o, CheckboxGroupOption as r, Checkbox as t };
|
|
27
|
+
//# sourceMappingURL=checkbox-DoR0Pcxm.d.ts.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { m as ResolvedCommandKitConfig } from "../analytics-engine-Bz1p7ud3.js";
|
|
3
2
|
//#region src/cli/app-process.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* @private
|
|
6
5
|
* @internal
|
|
7
6
|
*/
|
|
8
|
-
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean):
|
|
7
|
+
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean, config: ResolvedCommandKitConfig): import("node:child_process").ChildProcess;
|
|
9
8
|
//#endregion
|
|
10
9
|
export { createAppProcess };
|
|
11
10
|
//# sourceMappingURL=app-process.d.ts.map
|
package/dist/cli/app-process.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
3
2
|
const require_cli_common = require('./common.js');
|
|
4
3
|
const require_cli_env = require('./env.js');
|
|
5
4
|
let node_fs = require("node:fs");
|
|
@@ -24,15 +23,27 @@ function getStdio(supportsCommands) {
|
|
|
24
23
|
"pipe"
|
|
25
24
|
];
|
|
26
25
|
}
|
|
26
|
+
const RuntimeLookup = [["bun", () => typeof Bun !== "undefined" && typeof Bun.version === "string"], ["deno", () => typeof Deno !== "undefined" && typeof Deno.version === "object" && typeof Deno.version.deno === "string"]];
|
|
27
|
+
function resolveRuntime(config) {
|
|
28
|
+
var _config$experimental;
|
|
29
|
+
const maybeRuntime = config === null || config === void 0 || (_config$experimental = config.experimental) === null || _config$experimental === void 0 ? void 0 : _config$experimental.devServerRuntime;
|
|
30
|
+
if (!maybeRuntime) return "node";
|
|
31
|
+
if (maybeRuntime === "auto") {
|
|
32
|
+
for (const [runtime, check] of RuntimeLookup) if (check()) return runtime;
|
|
33
|
+
return "node";
|
|
34
|
+
}
|
|
35
|
+
return maybeRuntime;
|
|
36
|
+
}
|
|
27
37
|
/**
|
|
28
38
|
* @private
|
|
29
39
|
* @internal
|
|
30
40
|
*/
|
|
31
|
-
function createAppProcess(fileName, cwd, isDev) {
|
|
41
|
+
function createAppProcess(fileName, cwd, isDev, config) {
|
|
32
42
|
var _ps$stdout, _ps$stderr;
|
|
33
43
|
if (!(0, node_fs.existsSync)((0, node_path.join)(cwd, fileName))) require_cli_common.panic(`Could not locate the entrypoint file: ${fileName}`);
|
|
34
44
|
const stdio = getStdio(isDev);
|
|
35
|
-
const
|
|
45
|
+
const targetRuntime = resolveRuntime(config);
|
|
46
|
+
const baseArgs = targetRuntime === "node" ? [`--title="CommandKit ${isDev ? "Development" : "Production"}"`, "--enable-source-maps"] : [];
|
|
36
47
|
const nodeOptions = process.env.CK_NODE_OPTIONS || process.env.NODE_OPTIONS;
|
|
37
48
|
let nodeArgs = [...baseArgs];
|
|
38
49
|
if (nodeOptions) {
|
|
@@ -45,7 +56,7 @@ function createAppProcess(fileName, cwd, isDev) {
|
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
nodeArgs.push(fileName);
|
|
48
|
-
const ps = (0, node_child_process.spawn)(
|
|
59
|
+
const ps = (0, node_child_process.spawn)(targetRuntime, nodeArgs, {
|
|
49
60
|
cwd,
|
|
50
61
|
windowsHide: true,
|
|
51
62
|
env: isDev ? require_cli_env.DevEnv() : require_cli_env.ProdEnv(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-process.js","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"app-process.js","names":[],"sources":[],"mappings":""}
|
package/dist/cli/build.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as MaybeArray } from "../types-
|
|
3
|
-
|
|
1
|
+
import { G as CompilerPlugin } from "../analytics-engine-Bz1p7ud3.js";
|
|
2
|
+
import { t as MaybeArray } from "../types-ur7SvktF.js";
|
|
3
|
+
import "../index-DvqHpiuh.js";
|
|
4
4
|
//#region src/cli/build.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* @private
|
|
@@ -16,12 +16,7 @@ interface ApplicationBuildOptions {
|
|
|
16
16
|
* @private
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
declare function buildApplication({
|
|
20
|
-
plugins,
|
|
21
|
-
rolldownPlugins,
|
|
22
|
-
isDev,
|
|
23
|
-
configPath
|
|
24
|
-
}: ApplicationBuildOptions): Promise<void>;
|
|
19
|
+
declare function buildApplication({ plugins, rolldownPlugins, isDev, configPath }: ApplicationBuildOptions): Promise<void>;
|
|
25
20
|
//#endregion
|
|
26
21
|
export { ApplicationBuildOptions, buildApplication };
|
|
27
22
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/cli/build.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_commandkit = require('../commandkit-Bh7C1_c7.js');
|
|
2
|
+
const require_commandkit = require('../commandkit-DNbfLwyR.js');
|
|
4
3
|
const require_utils_constants = require('../utils/constants.js');
|
|
5
4
|
const require_config_utils = require('../config/utils.js');
|
|
5
|
+
const require_app_router_CommandsRouter = require('../app/router/CommandsRouter.js');
|
|
6
|
+
const require_app_router_EventsRouter = require('../app/router/EventsRouter.js');
|
|
7
|
+
const require_app_router_TreeArtifact = require('../app/router/TreeArtifact.js');
|
|
8
|
+
require('../app/router/index.js');
|
|
9
|
+
const require_version = require('../version.js');
|
|
6
10
|
const require_cli_common = require('./common.js');
|
|
7
11
|
const require_cli_env = require('./env.js');
|
|
8
12
|
const require_cli_type_checker = require('./type-checker.js');
|
|
@@ -87,12 +91,12 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
|
|
|
87
91
|
},
|
|
88
92
|
plugins: rolldownPlugins,
|
|
89
93
|
platform: "node",
|
|
90
|
-
skipNodeModulesBundle: true,
|
|
94
|
+
deps: { skipNodeModulesBundle: true },
|
|
91
95
|
sourcemap: ((_config$sourceMap = config.sourceMap) === null || _config$sourceMap === void 0 ? void 0 : _config$sourceMap[isDev ? "development" : "production"]) ?? true,
|
|
92
96
|
target: "node16",
|
|
93
97
|
outDir: dest,
|
|
94
98
|
env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),
|
|
95
|
-
entry: Array.from(new Set([
|
|
99
|
+
entry: Array.from(/* @__PURE__ */ new Set([
|
|
96
100
|
"src/**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx}",
|
|
97
101
|
`!${config.distDir}`,
|
|
98
102
|
"!.commandkit",
|
|
@@ -105,6 +109,7 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
|
|
|
105
109
|
}, (_config$compilerOptio2 = config.compilerOptions) === null || _config$compilerOptio2 === void 0 ? void 0 : _config$compilerOptio2.tsdown));
|
|
106
110
|
await require_cli_common.copyLocaleFiles("src", dest);
|
|
107
111
|
await injectEntryFile(configPath || require_utils_constants.COMMANDKIT_CWD, !!isDev, !!(((_config$antiCrashScri = config.antiCrashScript) === null || _config$antiCrashScri === void 0 ? void 0 : _config$antiCrashScri[isDev ? "development" : "production"]) ?? (isDev ? true : false)), config.distDir);
|
|
112
|
+
if (config.experimental.pregenerateCommands) await emitPregeneratedRouterArtifact((0, node_path.join)(require_utils_constants.COMMANDKIT_CWD, dest));
|
|
108
113
|
} catch (error) {
|
|
109
114
|
console.error("Build failed:", error);
|
|
110
115
|
if (error instanceof Error) console.error("Error details:", error.stack);
|
|
@@ -113,6 +118,27 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
|
|
|
113
118
|
await pluginRuntime.destroy();
|
|
114
119
|
}
|
|
115
120
|
}
|
|
121
|
+
async function emitPregeneratedRouterArtifact(outputRoot) {
|
|
122
|
+
const commandEntrypoint = (0, node_path.join)(outputRoot, "app", "commands");
|
|
123
|
+
const eventsEntrypoint = (0, node_path.join)(outputRoot, "app", "events");
|
|
124
|
+
const commandsRouter = new require_app_router_CommandsRouter.CommandsRouter({ entrypoint: commandEntrypoint });
|
|
125
|
+
const eventsRouter = new require_app_router_EventsRouter.EventsRouter({ entrypoints: [eventsEntrypoint] });
|
|
126
|
+
const artifact = require_app_router_TreeArtifact.createRouterTreeArtifact({
|
|
127
|
+
outputRoot,
|
|
128
|
+
commandkitVersion: require_version.version,
|
|
129
|
+
commands: commandsRouter.isValidPath() ? await commandsRouter.scan() : {
|
|
130
|
+
commands: {},
|
|
131
|
+
middlewares: {},
|
|
132
|
+
treeNodes: {},
|
|
133
|
+
compiledRoutes: {},
|
|
134
|
+
diagnostics: []
|
|
135
|
+
},
|
|
136
|
+
events: eventsRouter.isValidPath() ? await eventsRouter.scan() : {}
|
|
137
|
+
});
|
|
138
|
+
const artifactDirectory = (0, node_path.join)(outputRoot, require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_DIRECTORY);
|
|
139
|
+
await (0, node_fs_promises.mkdir)(artifactDirectory, { recursive: true });
|
|
140
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(artifactDirectory, require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_FILE), JSON.stringify(artifact, null, 2), "utf8");
|
|
141
|
+
}
|
|
116
142
|
const envScript = (dev) => `// --- Environment Variables Loader ---
|
|
117
143
|
const $env = [${(dev ? require_cli_env.devEnvFileArgs : require_cli_env.prodEnvFileArgs).map((p) => `"${p}"`).join(", ")}];
|
|
118
144
|
for (const file of $env) {
|
|
@@ -161,7 +187,9 @@ async function bootstrap() {
|
|
|
161
187
|
}
|
|
162
188
|
|
|
163
189
|
await bootstrap().catch((e) => {
|
|
164
|
-
|
|
190
|
+
const error = new Error('Failed to bootstrap the application', { cause: e });
|
|
191
|
+
console.error(error);
|
|
192
|
+
console.error(\`Caused by \${e?.stack || e}\`);
|
|
165
193
|
})
|
|
166
194
|
`);
|
|
167
195
|
}
|
package/dist/cli/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":[],"sources":["../../src/cli/build.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { rimraf } from 'rimraf';\nimport type { InlineConfig } from 'tsdown';\n\nimport { MaybeArray } from '../components';\nimport { loadConfigFile } from '../config/loader';\nimport { mergeDeep } from '../config/utils';\nimport { CompilerPlugin, CompilerPluginRuntime } from '../plugins';\nimport { COMMANDKIT_CWD } from '../utils/constants';\nimport { copyLocaleFiles, loadTsdown } from './common';\nimport { devEnvFileArgs, prodEnvFileArgs } from './env';\nimport { performTypeCheck } from './type-checker';\n\n/**\n * @private\n * @internal\n */\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\n\n// emit public env variables and given env variables\n/**\n * @private\n * @internal\n */\nfunction mergeDefinitionsIfNeeded(env: Record<string, string>, isDev: boolean) {\n const values = Object.fromEntries(\n Object.entries(process.env).filter(\n ([k]) => !(k in env) && k.startsWith('COMMANDKIT_PUBLIC_'),\n ),\n );\n\n return {\n ...env,\n ...values,\n ...(isDev\n ? {\n NODE_ENV: 'development',\n COMMANDKIT_BOOTSTRAP_MODE: 'development',\n COMMANDKIT_IS_DEV: 'true',\n COMMANDKIT_IS_TEST: 'false',\n }\n : {\n NODE_ENV: 'production',\n COMMANDKIT_BOOTSTRAP_MODE: 'production',\n COMMANDKIT_IS_DEV: 'false',\n COMMANDKIT_IS_TEST: 'false',\n }),\n };\n}\n\n/**\n * @private\n * @internal\n */\nexport async function buildApplication({\n plugins,\n rolldownPlugins,\n isDev,\n configPath,\n}: ApplicationBuildOptions) {\n const { build } = await loadTsdown();\n const config = await loadConfigFile(configPath);\n\n if (!isDev && !config?.typescript?.ignoreBuildErrors) {\n await performTypeCheck(configPath || COMMANDKIT_CWD);\n }\n\n const pluginRuntime = new CompilerPluginRuntime(\n (plugins || []) as CompilerPlugin[],\n !!isDev,\n );\n\n rolldownPlugins ??= [];\n\n rolldownPlugins.push(pluginRuntime.toJSON());\n\n try {\n const dest = isDev ? '.commandkit' : config.distDir;\n\n // Clean the destination directory\n await rimraf(dest);\n\n await pluginRuntime.init();\n\n await build(\n mergeDeep(\n {\n watch: false,\n dts: false,\n clean: true,\n format: ['esm'],\n shims: true,\n minify: false,\n logLevel: !!isDev ? 'silent' : 'info',\n inputOptions: {\n transform: {\n jsx: {\n runtime: 'automatic',\n importSource: 'commandkit',\n },\n },\n checks: {\n circularDependency: true,\n },\n onwarn: (warning, defaultWarn) => {\n if (warning?.message?.includes('compilerOptions.jsx')) return;\n\n return defaultWarn(warning);\n },\n onLog: (level, log, defaultLog) => {\n if (isDev) return;\n\n return defaultLog(level, log);\n },\n moduleTypes: {\n '.json': 'json',\n '.node': 'binary',\n },\n },\n outExtensions: (context) => {\n return {\n dts: '.d.ts',\n js: context.format === 'cjs' ? '.cjs' : '.js',\n };\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n sourcemap:\n config.sourceMap?.[isDev ? 'development' : 'production'] ?? true,\n target: 'node16',\n outDir: dest,\n env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),\n entry: Array.from(\n new Set([\n 'src/**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx}',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ...(config.entrypoints ?? []),\n ]),\n ),\n outputOptions: {\n sanitizeFileName: (name) => name.replace(/\\0/g, ''),\n },\n unbundle: isDev\n ? true\n : (config.compilerOptions?.disableChunking ?? false),\n } satisfies InlineConfig,\n config.compilerOptions?.tsdown,\n ),\n );\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(\n configPath || COMMANDKIT_CWD,\n !!isDev,\n !!(\n config.antiCrashScript?.[isDev ? 'development' : 'production'] ??\n (isDev ? true : false)\n ),\n config.distDir,\n );\n } catch (error) {\n console.error('Build failed:', error);\n if (error instanceof Error) {\n console.error('Error details:', error.stack);\n }\n process.exit(1); // Force exit on error\n } finally {\n // Ensure plugins are cleaned up\n await pluginRuntime.destroy();\n }\n}\n\nconst envScript = (dev: boolean) => `// --- Environment Variables Loader ---\nconst $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `\"${p}\"`).join(', ')}];\nfor (const file of $env) {\n try {\n process.loadEnvFile(file);\n console.log('\\\\x1b[36m✔ Loaded \\\\x1b[0m\\\\x1b[33m%s\\\\x1b[0m', file);\n } catch {}\n}\n`;\n\nconst antiCrashScript = [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[31m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n].join('\\n');\n\nconst wrapInAsyncIIFE = (code: string[]) =>\n `;await (async () => {\\n${code.join('\\n\\n')}\\n})();`;\n\nasync function injectEntryFile(\n configPath: string,\n isDev: boolean,\n emitAntiCrashScript: boolean,\n distDir?: string,\n) {\n const dist = isDev ? '.commandkit' : distDir || 'dist';\n const entryFilePath = join(configPath, dist, 'index.js');\n\n // skip if the entry file already exists\n if (existsSync(entryFilePath)) return;\n\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), emitAntiCrashScript ? antiCrashScript : ''])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\n\nasync function bootstrap() {\n const { Client } = await import('discord.js');\n const { commandkit } = await import('commandkit');\n const app = await import('./app.js').then((m) => m.default ?? m);\n\n if (!app || !(app instanceof Client)) {\n throw new Error('The app file must default export the discord.js client instance');\n }\n\n commandkit.setClient(app);\n\n await commandkit.start();\n}\n\nawait bootstrap().catch((e) => {\n console.error('Failed to bootstrap CommandKit application:\\\\n', e.stack);\n})\n`;\n\n await writeFile(entryFilePath, code);\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"build.js","names":[],"sources":[],"mappings":""}
|
package/dist/cli/common.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { m as ResolvedCommandKitConfig } from "../analytics-engine-
|
|
2
|
-
import * as tsdown from "tsdown";
|
|
3
|
-
import * as typescript from "typescript";
|
|
4
|
-
|
|
1
|
+
import { m as ResolvedCommandKitConfig } from "../analytics-engine-Bz1p7ud3.js";
|
|
5
2
|
//#region src/cli/common.d.ts
|
|
6
3
|
/**
|
|
7
4
|
* @private
|
|
@@ -23,7 +20,7 @@ declare function panic(message: any): never;
|
|
|
23
20
|
* @private
|
|
24
21
|
* @internal
|
|
25
22
|
*/
|
|
26
|
-
declare function loadTypeScript(e?: string): Promise<typeof typescript>;
|
|
23
|
+
declare function loadTypeScript(e?: string): Promise<typeof import("typescript")>;
|
|
27
24
|
/**
|
|
28
25
|
* @private
|
|
29
26
|
* @internal
|
|
@@ -43,7 +40,7 @@ declare function copyLocaleFiles(_from: string, _to: string): Promise<void>;
|
|
|
43
40
|
* @private
|
|
44
41
|
* @internal
|
|
45
42
|
*/
|
|
46
|
-
declare function loadTsdown(): Promise<typeof tsdown>;
|
|
43
|
+
declare function loadTsdown(): Promise<typeof import('tsdown')>;
|
|
47
44
|
//#endregion
|
|
48
45
|
export { copyLocaleFiles, erase, findEntrypoint, loadConfigFileFromPath, loadTsdown, loadTypeScript, panic, write };
|
|
49
46
|
//# sourceMappingURL=common.d.ts.map
|
package/dist/cli/common.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_rolldown_runtime = require('../rolldown-runtime-C_NdSu1c.js');
|
|
3
3
|
const require_utils_colors = require('../utils/colors.js');
|
|
4
4
|
const require_utils_constants = require('../utils/constants.js');
|
|
5
5
|
const require_utils_types_package = require('../utils/types-package.js');
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
|
-
node_fs =
|
|
7
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
let rimraf = require("rimraf");
|
|
10
10
|
let node_child_process = require("node:child_process");
|
package/dist/cli/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":[],"mappings":""}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { o as HMREventType } from "../constants-
|
|
1
|
+
import { o as HMREventChangeType, s as HMREventType } from "../constants-kWgE3L9F.js";
|
|
2
|
+
import { watch } from "chokidar";
|
|
2
3
|
import { ChildProcess } from "node:child_process";
|
|
3
|
-
import * as chokidar from "chokidar";
|
|
4
|
-
|
|
5
4
|
//#region src/cli/development.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* @private
|
|
@@ -13,11 +12,11 @@ declare function buildAndStart(configPath: string, skipStart?: boolean): Promise
|
|
|
13
12
|
* @internal
|
|
14
13
|
*/
|
|
15
14
|
declare function bootstrapDevelopmentServer(configPath?: string): Promise<{
|
|
16
|
-
watcher:
|
|
15
|
+
watcher: ReturnType<typeof watch>;
|
|
17
16
|
isConfigUpdate: (path: string) => boolean;
|
|
18
17
|
performHMR: (path?: string) => Promise<boolean>;
|
|
19
|
-
hmrHandler: (path: string) => Promise<void>;
|
|
20
|
-
sendHmrEvent: (event: HMREventType, path?: string) => Promise<boolean>;
|
|
18
|
+
hmrHandler: (path: string, changeType?: HMREventChangeType) => Promise<void>;
|
|
19
|
+
sendHmrEvent: (event: HMREventType, path?: string, changeType?: HMREventChangeType) => Promise<boolean>;
|
|
21
20
|
getProcess: () => ChildProcess | null;
|
|
22
21
|
buildAndStart: typeof buildAndStart;
|
|
23
22
|
}>;
|