seedcord 0.21.3 → 0.21.4
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/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as SEEDCORD_CONFIG_FILENAMES, t as version } from "./src-
|
|
2
|
-
import { createRequire
|
|
1
|
+
import { n as SEEDCORD_CONFIG_FILENAMES, t as version } from "./src-BfciUrzr.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
3
|
import { Command } from "@commander-js/extra-typings";
|
|
4
4
|
import { LEVEL_COLOR, Logger, LoggerChannelRegistry } from "@seedcord/logger";
|
|
5
5
|
import { formatBody, installNodeDefaults } from "@seedcord/logger/node";
|
|
@@ -31,7 +31,6 @@ import process$1 from "node:process";
|
|
|
31
31
|
import { assertNever } from "@seedcord/utils";
|
|
32
32
|
import { settleWithin } from "@seedcord/core/node/internal";
|
|
33
33
|
import { createServer, createServerModuleRunner, defineConfig, mergeConfig } from "vite";
|
|
34
|
-
import { EvaluatedModules } from "vite/module-runner";
|
|
35
34
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
36
35
|
import { minimatch } from "minimatch";
|
|
37
36
|
import { createServer as createServer$1 } from "node:net";
|
|
@@ -967,17 +966,17 @@ var CleanRunner = class CleanRunner {
|
|
|
967
966
|
async fetchBotGuilds(rest) {
|
|
968
967
|
const guilds = [];
|
|
969
968
|
let after;
|
|
970
|
-
|
|
969
|
+
let page;
|
|
970
|
+
do {
|
|
971
971
|
const query = new URLSearchParams({ limit: String(GUILD_PAGE) });
|
|
972
972
|
if (after) query.set("after", after);
|
|
973
|
-
|
|
973
|
+
page = await rest.get(Routes.userGuilds(), { query });
|
|
974
974
|
for (const guild of page) guilds.push({
|
|
975
975
|
id: guild.id,
|
|
976
976
|
name: guild.name
|
|
977
977
|
});
|
|
978
978
|
after = page.at(-1)?.id;
|
|
979
|
-
|
|
980
|
-
}
|
|
979
|
+
} while (page.length === GUILD_PAGE && after);
|
|
981
980
|
return guilds;
|
|
982
981
|
}
|
|
983
982
|
async fetchGlobalNames(rest, appId) {
|
|
@@ -2887,7 +2886,6 @@ var DevStore = class extends TypedEventEmitter {
|
|
|
2887
2886
|
case "module-loading":
|
|
2888
2887
|
case "module-loaded":
|
|
2889
2888
|
case "module-error":
|
|
2890
|
-
case "file-change":
|
|
2891
2889
|
case "ready": break;
|
|
2892
2890
|
default: assertNever(event);
|
|
2893
2891
|
}
|
|
@@ -3080,11 +3078,17 @@ var DevSession = class {
|
|
|
3080
3078
|
//#endregion
|
|
3081
3079
|
//#region src/commands/dev/runtime/HmrPlugin.ts
|
|
3082
3080
|
const DEBOUNCE_MS = 250;
|
|
3081
|
+
const TYPE_COLOR = {
|
|
3082
|
+
create: paint.mint,
|
|
3083
|
+
createDir: paint.mint,
|
|
3084
|
+
update: paint.sky,
|
|
3085
|
+
delete: paint.coral,
|
|
3086
|
+
deleteDir: paint.coral
|
|
3087
|
+
};
|
|
3083
3088
|
var HmrPlugin = class extends TypedEventEmitter {
|
|
3084
3089
|
config;
|
|
3085
3090
|
logger;
|
|
3086
3091
|
lastUpdate = /* @__PURE__ */ new Map();
|
|
3087
|
-
awaitingCreateEcho = /* @__PURE__ */ new Set();
|
|
3088
3092
|
server = null;
|
|
3089
3093
|
dynamicRestartPatterns = /* @__PURE__ */ new Set();
|
|
3090
3094
|
get hot() {
|
|
@@ -3099,10 +3103,13 @@ var HmrPlugin = class extends TypedEventEmitter {
|
|
|
3099
3103
|
this.logger = new Logger("HMR", { channel: "hmr" });
|
|
3100
3104
|
}
|
|
3101
3105
|
get plugin() {
|
|
3106
|
+
const onHotUpdate = this.hotUpdate.bind(this);
|
|
3102
3107
|
return {
|
|
3103
3108
|
name: "seedcord:hmr",
|
|
3104
3109
|
configureServer: this.configureServer.bind(this),
|
|
3105
|
-
hotUpdate
|
|
3110
|
+
hotUpdate(ctx) {
|
|
3111
|
+
return onHotUpdate(this.environment, ctx);
|
|
3112
|
+
}
|
|
3106
3113
|
};
|
|
3107
3114
|
}
|
|
3108
3115
|
sendRefreshCommands(shouldRefresh) {
|
|
@@ -3110,10 +3117,8 @@ var HmrPlugin = class extends TypedEventEmitter {
|
|
|
3110
3117
|
}
|
|
3111
3118
|
configureServer(server) {
|
|
3112
3119
|
this.server = server;
|
|
3113
|
-
server.watcher.on("
|
|
3114
|
-
server.watcher.on("
|
|
3115
|
-
server.watcher.on("addDir", (file) => this.handleFileEvent(file, "createDir"));
|
|
3116
|
-
server.watcher.on("unlinkDir", (file) => this.handleFileEvent(file, "deleteDir"));
|
|
3120
|
+
server.watcher.on("addDir", (dir) => this.handleDirEvent(dir, "createDir"));
|
|
3121
|
+
server.watcher.on("unlinkDir", (dir) => this.handleDirEvent(dir, "deleteDir"));
|
|
3117
3122
|
server.watcher.add(this.config.configFile);
|
|
3118
3123
|
server.watcher.on("change", (file) => this.handleChange(file));
|
|
3119
3124
|
this.dev?.on("seedcord:commands-update-prompt", (data) => {
|
|
@@ -3134,14 +3139,12 @@ var HmrPlugin = class extends TypedEventEmitter {
|
|
|
3134
3139
|
});
|
|
3135
3140
|
}
|
|
3136
3141
|
isDebounced(file, type) {
|
|
3137
|
-
|
|
3138
|
-
this.lastUpdate.
|
|
3142
|
+
const key = `${file}::${type}`;
|
|
3143
|
+
const last = this.lastUpdate.get(key);
|
|
3144
|
+
if (last !== void 0 && Date.now() - last < DEBOUNCE_MS) return true;
|
|
3145
|
+
this.lastUpdate.set(key, Date.now());
|
|
3139
3146
|
return false;
|
|
3140
3147
|
}
|
|
3141
|
-
justSaw(file, type) {
|
|
3142
|
-
const last = this.lastUpdate.get(`${file}::${type}`);
|
|
3143
|
-
return last !== void 0 && Date.now() - last < DEBOUNCE_MS;
|
|
3144
|
-
}
|
|
3145
3148
|
handleChange(file) {
|
|
3146
3149
|
if (!this.isCriticalFile(file) || this.isDebounced(file, "update")) return;
|
|
3147
3150
|
this.reportRestartRequired(file);
|
|
@@ -3151,78 +3154,56 @@ var HmrPlugin = class extends TypedEventEmitter {
|
|
|
3151
3154
|
this.logger.warn(`${paint.coral("Critical file changed:")} ${paint.sky.bold(relPath)}. Restart required.`);
|
|
3152
3155
|
this.emit("event", { type: "restart-required" });
|
|
3153
3156
|
}
|
|
3154
|
-
|
|
3155
|
-
if (this.isDebounced(
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3157
|
+
handleDirEvent(dir, type) {
|
|
3158
|
+
if (this.isDebounced(dir, type)) return;
|
|
3159
|
+
this.send({
|
|
3160
|
+
file: dir,
|
|
3161
|
+
type
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3164
|
+
send(event) {
|
|
3165
|
+
const relPath = relative(process.cwd(), event.file);
|
|
3166
|
+
this.logger.trace(`${TYPE_COLOR[event.type](event.type.toUpperCase())} ${paint.mute(relPath)}`);
|
|
3167
|
+
this.dev?.send("seedcord:hmr", {
|
|
3168
|
+
...event,
|
|
3163
3169
|
rollback: this.config.hmr?.rollback ?? true
|
|
3164
|
-
};
|
|
3165
|
-
this.dev?.send("seedcord:hmr", payload);
|
|
3170
|
+
});
|
|
3166
3171
|
}
|
|
3167
|
-
hotUpdate(ctx) {
|
|
3168
|
-
const { file, modules
|
|
3169
|
-
|
|
3170
|
-
if (this.awaitingCreateEcho.delete(file) && this.justSaw(file, "create") || this.isDebounced(file, type)) return [];
|
|
3171
|
-
const relPath = relative(process.cwd(), file);
|
|
3172
|
-
this.logger.trace(`${paint.sky(type.toUpperCase())} ${paint.mute(relPath)}`);
|
|
3172
|
+
hotUpdate(environment, ctx) {
|
|
3173
|
+
const { type, file, modules } = ctx;
|
|
3174
|
+
if (environment.name !== "ssr" || this.isDebounced(file, type)) return [];
|
|
3173
3175
|
if (this.isCriticalFile(file)) {
|
|
3174
3176
|
this.reportRestartRequired(file);
|
|
3175
3177
|
return [];
|
|
3176
3178
|
}
|
|
3177
|
-
const moduleGraph =
|
|
3178
|
-
const
|
|
3179
|
-
const
|
|
3180
|
-
|
|
3181
|
-
const affectedModules = this.getAffectedModules([...combinedModules]);
|
|
3182
|
-
const filesToInvalidate = /* @__PURE__ */ new Set([file, ...affectedModules]);
|
|
3183
|
-
for (const fileToInvalidate of filesToInvalidate) {
|
|
3184
|
-
const mods = moduleGraph.getModulesByFile(fileToInvalidate);
|
|
3185
|
-
if (mods) for (const mod of mods) moduleGraph.invalidateModule(mod);
|
|
3186
|
-
}
|
|
3187
|
-
this.emit("event", {
|
|
3188
|
-
type: "file-change",
|
|
3189
|
-
path: file
|
|
3190
|
-
});
|
|
3191
|
-
const payload = {
|
|
3179
|
+
const { moduleGraph } = environment;
|
|
3180
|
+
const affectedModules = affectedFiles(file, modules);
|
|
3181
|
+
for (const target of affectedModules) for (const mod of moduleGraph.getModulesByFile(target) ?? []) moduleGraph.invalidateModule(mod);
|
|
3182
|
+
this.send({
|
|
3192
3183
|
file,
|
|
3193
3184
|
type,
|
|
3194
|
-
affectedModules
|
|
3195
|
-
|
|
3196
|
-
};
|
|
3197
|
-
this.dev?.send("seedcord:hmr", payload);
|
|
3185
|
+
affectedModules
|
|
3186
|
+
});
|
|
3198
3187
|
return [];
|
|
3199
3188
|
}
|
|
3200
3189
|
isCriticalFile(file) {
|
|
3201
|
-
const root = this.config
|
|
3190
|
+
const { root, configFile, entry, instance } = this.config;
|
|
3202
3191
|
const relPath = relative(root, file);
|
|
3203
|
-
|
|
3204
|
-
for (const pattern of this.config.hmr.restart) if (minimatch(relPath, pattern)) return true;
|
|
3205
|
-
}
|
|
3206
|
-
for (const pattern of this.dynamicRestartPatterns) if (minimatch(relPath, pattern)) return true;
|
|
3207
|
-
if (file === this.config.configFile || file.endsWith("package.json") || file.endsWith("tsconfig.json") || file.endsWith(".env")) return true;
|
|
3208
|
-
const entryPath = resolve(root, this.config.entry);
|
|
3209
|
-
const instancePath = resolve(root, this.config.instance);
|
|
3210
|
-
if (file === entryPath || file === instancePath) return true;
|
|
3211
|
-
return false;
|
|
3212
|
-
}
|
|
3213
|
-
getAffectedModules(modules) {
|
|
3214
|
-
const affected = /* @__PURE__ */ new Set();
|
|
3215
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3216
|
-
const traverse = (mod) => {
|
|
3217
|
-
if (!mod.file || seen.has(mod.file)) return;
|
|
3218
|
-
seen.add(mod.file);
|
|
3219
|
-
affected.add(mod.file);
|
|
3220
|
-
mod.importers.forEach(traverse);
|
|
3221
|
-
};
|
|
3222
|
-
modules.forEach(traverse);
|
|
3223
|
-
return [...affected];
|
|
3192
|
+
return [...this.config.hmr?.restart ?? [], ...this.dynamicRestartPatterns].some((pattern) => minimatch(relPath, pattern)) || file === configFile || file.endsWith("package.json") || file.endsWith("tsconfig.json") || file.endsWith(".env") || file === resolve(root, entry) || file === resolve(root, instance);
|
|
3224
3193
|
}
|
|
3225
3194
|
};
|
|
3195
|
+
function affectedFiles(file, modules) {
|
|
3196
|
+
const files = /* @__PURE__ */ new Set([file]);
|
|
3197
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3198
|
+
const visit = (mod) => {
|
|
3199
|
+
if (visited.has(mod)) return;
|
|
3200
|
+
visited.add(mod);
|
|
3201
|
+
if (mod.file) files.add(mod.file);
|
|
3202
|
+
mod.importers.forEach(visit);
|
|
3203
|
+
};
|
|
3204
|
+
modules.forEach(visit);
|
|
3205
|
+
return [...files];
|
|
3206
|
+
}
|
|
3226
3207
|
|
|
3227
3208
|
//#endregion
|
|
3228
3209
|
//#region src/commands/dev/runtime/seedcordDependents.ts
|
|
@@ -3241,12 +3222,14 @@ function dependencyNames(manifestPath, fields) {
|
|
|
3241
3222
|
});
|
|
3242
3223
|
}
|
|
3243
3224
|
function installedManifest(name, fromManifest) {
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3225
|
+
let dir = dirname(fromManifest);
|
|
3226
|
+
let checked;
|
|
3227
|
+
do {
|
|
3228
|
+
const candidate = join(dir, "node_modules", name, "package.json");
|
|
3229
|
+
if (existsSync(candidate)) return realpathSync(candidate);
|
|
3230
|
+
checked = dir;
|
|
3231
|
+
dir = dirname(dir);
|
|
3232
|
+
} while (dir !== checked);
|
|
3250
3233
|
}
|
|
3251
3234
|
function isSeedcordPackage(name) {
|
|
3252
3235
|
return name.startsWith("@seedcord/");
|
|
@@ -3353,7 +3336,6 @@ var ViteDevRuntime = class {
|
|
|
3353
3336
|
viteServer = null;
|
|
3354
3337
|
moduleRunner = null;
|
|
3355
3338
|
eventHandler = null;
|
|
3356
|
-
evaluatedModules = null;
|
|
3357
3339
|
hmrPlugin = null;
|
|
3358
3340
|
async start(context) {
|
|
3359
3341
|
this.context = context;
|
|
@@ -3375,26 +3357,14 @@ var ViteDevRuntime = class {
|
|
|
3375
3357
|
plugins: [tsconfigPaths({ root: projectDir }), hmrPlugin.plugin]
|
|
3376
3358
|
});
|
|
3377
3359
|
this.viteServer = await createServer(config);
|
|
3378
|
-
this.
|
|
3379
|
-
|
|
3380
|
-
hmrPlugin.on("event", this.handleHmrEvent.bind(this));
|
|
3360
|
+
this.moduleRunner = createServerModuleRunner(this.viteServer.environments.ssr);
|
|
3361
|
+
hmrPlugin.on("event", this.emit.bind(this));
|
|
3381
3362
|
this.emit({
|
|
3382
3363
|
type: "module-loaded",
|
|
3383
3364
|
path: projectRoot
|
|
3384
3365
|
});
|
|
3385
3366
|
this.emit({ type: "ready" });
|
|
3386
3367
|
}
|
|
3387
|
-
handleHmrEvent(event) {
|
|
3388
|
-
if (event.type === "file-change") this.invalidateModule(event.path);
|
|
3389
|
-
this.emit(event);
|
|
3390
|
-
}
|
|
3391
|
-
invalidateModule(file) {
|
|
3392
|
-
const projectRoot = this.context?.config.root;
|
|
3393
|
-
if (!projectRoot || !this.evaluatedModules) return;
|
|
3394
|
-
const moduleId = toModuleId(projectRoot, file);
|
|
3395
|
-
const moduleNode = this.evaluatedModules.getModuleById(moduleId);
|
|
3396
|
-
if (moduleNode) this.evaluatedModules.invalidateModule(moduleNode);
|
|
3397
|
-
}
|
|
3398
3368
|
refreshCommands(shouldRefresh) {
|
|
3399
3369
|
this.hmrPlugin?.sendRefreshCommands(shouldRefresh);
|
|
3400
3370
|
}
|
|
@@ -3430,7 +3400,6 @@ var ViteDevRuntime = class {
|
|
|
3430
3400
|
this.viteServer = null;
|
|
3431
3401
|
}
|
|
3432
3402
|
this.moduleRunner = null;
|
|
3433
|
-
this.evaluatedModules = null;
|
|
3434
3403
|
this.hmrPlugin = null;
|
|
3435
3404
|
this.context = null;
|
|
3436
3405
|
this.eventHandler = null;
|