@seedcord/http 0.0.1 → 0.1.0-next.1
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/RouteManifest-BHdAeyLG.d.mts +60 -0
- package/dist/edge.index-BAgNb6TV.mjs +1046 -0
- package/dist/edge.index-BAgNb6TV.mjs.map +1 -0
- package/dist/edge.index-CTOyjsO4.d.mts +501 -0
- package/dist/edge.index-D-60VfMn.cjs +1175 -0
- package/dist/edge.index-D-60VfMn.cjs.map +1 -0
- package/dist/edge.index.cjs +22 -0
- package/dist/edge.index.d.cts +1 -0
- package/dist/edge.index.d.mts +4 -0
- package/dist/edge.index.mjs +5 -0
- package/dist/index.cjs +413 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +63 -4
- package/dist/index.mjs +397 -3
- package/dist/index.mjs.map +1 -1
- package/dist/manifest.index.cjs +16 -0
- package/dist/manifest.index.cjs.map +1 -0
- package/dist/manifest.index.d.cts +1 -0
- package/dist/manifest.index.d.mts +11 -0
- package/dist/manifest.index.mjs +15 -0
- package/dist/manifest.index.mjs.map +1 -0
- package/dist/rolldown-runtime-BUUfjzRC.mjs +36 -0
- package/package.json +95 -58
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,401 @@
|
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BUUfjzRC.mjs";
|
|
2
|
+
import { a as ButtonHandler, c as SlashHandler, d as buildRouteMaps, f as InteractionHandler, i as SelectMenuHandler, l as createSeedcord, m as RepliableHandler, n as Gated, o as ComponentHandler, p as AutocompleteHandler, r as ModalHandler, s as ContextMenuHandler, t as version, u as buildEngine } from "./edge.index-BAgNb6TV.mjs";
|
|
3
|
+
import { SeedcordError, validateDiscordToken } from "@seedcord/errors/internal";
|
|
4
|
+
import { Envapter } from "envapt";
|
|
5
|
+
import { REST } from "@discordjs/rest";
|
|
6
|
+
import { HmrManager, InteractionMetadataKey, InteractionRoutes, interactionRoutesOf, setBotColor } from "@seedcord/core/internal";
|
|
7
|
+
import { Logger, LoggerChannelRegistry, paint } from "@seedcord/logger";
|
|
8
|
+
import { MemoryRateLimiter } from "@seedcord/rate-limiter";
|
|
9
|
+
import { Routes } from "discord-api-types/v10";
|
|
10
|
+
import { SeedcordErrorCode } from "@seedcord/errors";
|
|
11
|
+
import { once } from "node:events";
|
|
12
|
+
import { createServer } from "node:http";
|
|
13
|
+
import { CoordinatedShutdown, CoordinatedStartup, HealthCheck, Pluggable, ShutdownPhase, StartupPhase } from "@seedcord/core/node/internal";
|
|
14
|
+
import { installNodeDefaults } from "@seedcord/logger/node";
|
|
15
|
+
import { SeedcordBrand } from "@seedcord/types/internal";
|
|
16
|
+
import { HmrModuleHandler } from "@seedcord/core/hmr";
|
|
17
|
+
import { formatFilePath } from "@seedcord/utils";
|
|
18
|
+
import { traverseDirectory } from "@seedcord/utils/node";
|
|
19
|
+
|
|
20
|
+
export * from "@seedcord/core"
|
|
21
|
+
|
|
22
|
+
//#region src/manifest/RouteManifest.ts
|
|
23
|
+
/** @internal */
|
|
24
|
+
const EMPTY_MANIFEST = {
|
|
25
|
+
commands: [],
|
|
26
|
+
components: [],
|
|
27
|
+
autocomplete: [],
|
|
28
|
+
subscribers: []
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/node/InteractionDispatcher.ts
|
|
33
|
+
/**
|
|
34
|
+
* Discovers interaction handlers from the filesystem into the engine's live route maps.
|
|
35
|
+
*
|
|
36
|
+
* The node host runs it at startup and dev HMR swaps map entries in place. The engine's `resolve`
|
|
37
|
+
* reads `maps` per request. The edge path builds its maps from the generated manifest.
|
|
38
|
+
*/
|
|
39
|
+
var InteractionDispatcher = class {
|
|
40
|
+
handlersDir;
|
|
41
|
+
maps;
|
|
42
|
+
targets;
|
|
43
|
+
/** @internal */
|
|
44
|
+
logger = new Logger("Interactions");
|
|
45
|
+
isInitialized = false;
|
|
46
|
+
hmrHandler;
|
|
47
|
+
rowOwners = /* @__PURE__ */ new Map();
|
|
48
|
+
loading = false;
|
|
49
|
+
loadedHandlers = [];
|
|
50
|
+
constructor(handlersDir) {
|
|
51
|
+
this.handlersDir = handlersDir;
|
|
52
|
+
this.maps = buildRouteMaps(EMPTY_MANIFEST);
|
|
53
|
+
this.targets = this.buildTargets();
|
|
54
|
+
if (!Envapter.isDevelopment && !Envapter.isTest) return;
|
|
55
|
+
this.hmrHandler = new HmrModuleHandler({
|
|
56
|
+
handlersDir,
|
|
57
|
+
isHandler: this.isHandler.bind(this),
|
|
58
|
+
registerHandler: this.registerHandler.bind(this),
|
|
59
|
+
unregisterHandler: this.unregisterHandler.bind(this),
|
|
60
|
+
getArtifacts: this.getArtifacts.bind(this),
|
|
61
|
+
logger: this.logger
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** @internal */
|
|
65
|
+
async init() {
|
|
66
|
+
if (this.isInitialized) return;
|
|
67
|
+
this.isInitialized = true;
|
|
68
|
+
this.loading = true;
|
|
69
|
+
this.loadedHandlers.length = 0;
|
|
70
|
+
try {
|
|
71
|
+
await traverseDirectory(this.handlersDir, (fullPath, relativePath, imported) => {
|
|
72
|
+
for (const value of Object.values(imported)) {
|
|
73
|
+
if (!this.isHandler(value)) continue;
|
|
74
|
+
this.registerHandler(value, relativePath);
|
|
75
|
+
this.hmrHandler?.trackHandler(fullPath, value);
|
|
76
|
+
}
|
|
77
|
+
}, this.logger);
|
|
78
|
+
} finally {
|
|
79
|
+
this.loading = false;
|
|
80
|
+
}
|
|
81
|
+
this.logger.utils.block("Loaded handlers", [...this.logger.utils.entries(this.loadedHandlers), ...this.logger.utils.counts({ routes: this.rowOwners.size })]);
|
|
82
|
+
}
|
|
83
|
+
/** @internal */
|
|
84
|
+
async onHmr(event) {
|
|
85
|
+
await this.hmrHandler?.handle(event);
|
|
86
|
+
}
|
|
87
|
+
isHandler(value) {
|
|
88
|
+
if (typeof value !== "function") return false;
|
|
89
|
+
return (value.prototype instanceof InteractionHandler || value.prototype instanceof AutocompleteHandler) && Reflect.hasMetadata(InteractionMetadataKey, value);
|
|
90
|
+
}
|
|
91
|
+
getArtifacts(ctor) {
|
|
92
|
+
const routeIds = [];
|
|
93
|
+
for (const [routeId, owner] of this.rowOwners) if (owner.ctor === ctor) routeIds.push(routeId);
|
|
94
|
+
return routeIds;
|
|
95
|
+
}
|
|
96
|
+
targetFor(route) {
|
|
97
|
+
return this.targets[route];
|
|
98
|
+
}
|
|
99
|
+
buildTargets() {
|
|
100
|
+
return {
|
|
101
|
+
[InteractionRoutes.Slash]: {
|
|
102
|
+
map: this.maps.slash,
|
|
103
|
+
kind: "slash"
|
|
104
|
+
},
|
|
105
|
+
[InteractionRoutes.UserContextMenu]: {
|
|
106
|
+
map: this.maps.userContextMenu,
|
|
107
|
+
kind: "userContextMenu"
|
|
108
|
+
},
|
|
109
|
+
[InteractionRoutes.MessageContextMenu]: {
|
|
110
|
+
map: this.maps.messageContextMenu,
|
|
111
|
+
kind: "messageContextMenu"
|
|
112
|
+
},
|
|
113
|
+
[InteractionRoutes.Autocomplete]: {
|
|
114
|
+
map: this.maps.autocomplete,
|
|
115
|
+
kind: "autocomplete"
|
|
116
|
+
},
|
|
117
|
+
[InteractionRoutes.Button]: {
|
|
118
|
+
map: this.maps.components.button,
|
|
119
|
+
kind: "button"
|
|
120
|
+
},
|
|
121
|
+
[InteractionRoutes.StringMenu]: {
|
|
122
|
+
map: this.maps.components.stringSelect,
|
|
123
|
+
kind: "stringMenu"
|
|
124
|
+
},
|
|
125
|
+
[InteractionRoutes.UserMenu]: {
|
|
126
|
+
map: this.maps.components.userSelect,
|
|
127
|
+
kind: "userMenu"
|
|
128
|
+
},
|
|
129
|
+
[InteractionRoutes.RoleMenu]: {
|
|
130
|
+
map: this.maps.components.roleSelect,
|
|
131
|
+
kind: "roleMenu"
|
|
132
|
+
},
|
|
133
|
+
[InteractionRoutes.ChannelMenu]: {
|
|
134
|
+
map: this.maps.components.channelSelect,
|
|
135
|
+
kind: "channelMenu"
|
|
136
|
+
},
|
|
137
|
+
[InteractionRoutes.MentionableMenu]: {
|
|
138
|
+
map: this.maps.components.mentionableSelect,
|
|
139
|
+
kind: "mentionableMenu"
|
|
140
|
+
},
|
|
141
|
+
[InteractionRoutes.Modal]: {
|
|
142
|
+
map: this.maps.components.modal,
|
|
143
|
+
kind: "modal"
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
registerHandler(ctor, relativePath) {
|
|
148
|
+
const writes = [];
|
|
149
|
+
for (const [route, keys] of interactionRoutesOf(ctor)) {
|
|
150
|
+
const target = this.targetFor(route);
|
|
151
|
+
for (const key of keys) {
|
|
152
|
+
const existing = this.rowOwners.get(`${target.kind}:${key}`);
|
|
153
|
+
if (existing && existing.ctor !== ctor) throw new SeedcordError(SeedcordErrorCode.InteractionDuplicateRoute, [
|
|
154
|
+
key,
|
|
155
|
+
existing.ctor.name,
|
|
156
|
+
ctor.name
|
|
157
|
+
]);
|
|
158
|
+
writes.push([target, key]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (writes.length === 0) return;
|
|
162
|
+
for (const [target, key] of writes) {
|
|
163
|
+
const routeId = `${target.kind}:${key}`;
|
|
164
|
+
target.map.set(key, {
|
|
165
|
+
kind: target.kind,
|
|
166
|
+
routeId,
|
|
167
|
+
load: () => Promise.resolve({ [ctor.name]: ctor })
|
|
168
|
+
});
|
|
169
|
+
this.rowOwners.set(routeId, {
|
|
170
|
+
ctor,
|
|
171
|
+
target,
|
|
172
|
+
key
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const from = formatFilePath(relativePath);
|
|
176
|
+
if (this.loading) this.loadedHandlers.push({
|
|
177
|
+
name: ctor.name,
|
|
178
|
+
from
|
|
179
|
+
});
|
|
180
|
+
else this.logger.utils.registration(ctor.name, from);
|
|
181
|
+
}
|
|
182
|
+
unregisterHandler(ctor, artifacts) {
|
|
183
|
+
const routeIds = artifacts ?? this.getArtifacts(ctor);
|
|
184
|
+
for (const routeId of routeIds) {
|
|
185
|
+
const owner = this.rowOwners.get(routeId);
|
|
186
|
+
if (owner?.ctor !== ctor) continue;
|
|
187
|
+
this.rowOwners.delete(routeId);
|
|
188
|
+
owner.target.map.delete(owner.key);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/node/webBridge.ts
|
|
195
|
+
function toHeaders(raw) {
|
|
196
|
+
const headers = new Headers();
|
|
197
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
198
|
+
if (value === void 0) continue;
|
|
199
|
+
if (Array.isArray(value)) for (const item of value) headers.append(name, item);
|
|
200
|
+
else headers.set(name, value);
|
|
201
|
+
}
|
|
202
|
+
return headers;
|
|
203
|
+
}
|
|
204
|
+
async function toWebRequest(request) {
|
|
205
|
+
const chunks = [];
|
|
206
|
+
for await (const chunk of request) chunks.push(chunk);
|
|
207
|
+
const method = request.method ?? "GET";
|
|
208
|
+
const body = method === "GET" || method === "HEAD" ? void 0 : new Uint8Array(Buffer.concat(chunks));
|
|
209
|
+
return new Request(`http://${request.headers.host ?? "localhost"}${request.url ?? "/"}`, {
|
|
210
|
+
method,
|
|
211
|
+
headers: toHeaders(request.headers),
|
|
212
|
+
...body !== void 0 && { body }
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
async function writeWebResponse(response, out) {
|
|
216
|
+
const headers = Object.fromEntries(response.headers);
|
|
217
|
+
const cookies = response.headers.getSetCookie();
|
|
218
|
+
if (cookies.length > 0) headers["set-cookie"] = cookies;
|
|
219
|
+
out.writeHead(response.status, headers);
|
|
220
|
+
out.end(response.body === null ? void 0 : Buffer.from(await response.arrayBuffer()));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/node/Seedcord.ts
|
|
225
|
+
const DEFAULT_PORT = 3e3;
|
|
226
|
+
const SERVER_SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
227
|
+
const DRAIN_TIMEOUT_MS = 1e4;
|
|
228
|
+
/**
|
|
229
|
+
* The HTTP-interactions bot host, a long-running node server around the engine.
|
|
230
|
+
*
|
|
231
|
+
* Discovers handlers from `config.bot.interactions.path`, verifies and dispatches interactions on
|
|
232
|
+
* `start(port)`, and runs coordinated shutdown with an in-flight drain. The edge deploy path calls
|
|
233
|
+
* `createSeedcord` from a generated entry.
|
|
234
|
+
*/
|
|
235
|
+
var Seedcord = class Seedcord extends Pluggable {
|
|
236
|
+
config;
|
|
237
|
+
/** @internal */
|
|
238
|
+
[SeedcordBrand] = true;
|
|
239
|
+
/** @internal */
|
|
240
|
+
augmentTarget = "@seedcord/http";
|
|
241
|
+
/** @internal */
|
|
242
|
+
version = version;
|
|
243
|
+
/** Workerd-compatible Discord REST client. `start()` sets the token. */
|
|
244
|
+
rest = new REST();
|
|
245
|
+
/** @see {@link IRateLimiter} */
|
|
246
|
+
rateLimiter;
|
|
247
|
+
/** @see {@link CoordinatedShutdown} */
|
|
248
|
+
shutdown;
|
|
249
|
+
/** @see {@link CoordinatedStartup} */
|
|
250
|
+
startup;
|
|
251
|
+
interactions;
|
|
252
|
+
healthCheck;
|
|
253
|
+
hmrManager;
|
|
254
|
+
logger = new Logger("Server");
|
|
255
|
+
server;
|
|
256
|
+
boundPort;
|
|
257
|
+
requestedPort = DEFAULT_PORT;
|
|
258
|
+
fetchedUsername;
|
|
259
|
+
constructor(config) {
|
|
260
|
+
const shutdown = new CoordinatedShutdown();
|
|
261
|
+
const startup = new CoordinatedStartup();
|
|
262
|
+
super(shutdown, startup);
|
|
263
|
+
this.config = config;
|
|
264
|
+
installNodeDefaults(config.logger);
|
|
265
|
+
setBotColor(config.botColor);
|
|
266
|
+
this.shutdown = shutdown;
|
|
267
|
+
this.startup = startup;
|
|
268
|
+
this.hmrManager = new HmrManager();
|
|
269
|
+
this.hmrManager.init();
|
|
270
|
+
if (this.config.bot.interactions.path) this.interactions = new InteractionDispatcher(this.config.bot.interactions.path);
|
|
271
|
+
this.rateLimiter = config.store ?? new MemoryRateLimiter();
|
|
272
|
+
this.healthCheck = config.runtime === "edge" ? void 0 : HealthCheck.fromOption(this.shutdown, config.healthCheck);
|
|
273
|
+
this.registerStartupTasks();
|
|
274
|
+
}
|
|
275
|
+
/** The bot's discord username, populated by the ready fetch. */
|
|
276
|
+
get username() {
|
|
277
|
+
return this.fetchedUsername;
|
|
278
|
+
}
|
|
279
|
+
/** The bound server port, populated once `start()` is listening. */
|
|
280
|
+
get port() {
|
|
281
|
+
return this.boundPort;
|
|
282
|
+
}
|
|
283
|
+
pluginCapabilities() {
|
|
284
|
+
const token = Envapter.get("DISCORD_BOT_TOKEN");
|
|
285
|
+
return {
|
|
286
|
+
rest: this.rest,
|
|
287
|
+
...token !== void 0 && { token }
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Starts the host and runs the startup tasks.
|
|
292
|
+
*
|
|
293
|
+
* @param port - The port the interaction server binds. {@default `3000`}
|
|
294
|
+
*/
|
|
295
|
+
async start(port = DEFAULT_PORT) {
|
|
296
|
+
this.requestedPort = port;
|
|
297
|
+
try {
|
|
298
|
+
await super.init();
|
|
299
|
+
} catch (caught) {
|
|
300
|
+
await this.shutdown.run(1, false);
|
|
301
|
+
Seedcord.reset();
|
|
302
|
+
throw caught;
|
|
303
|
+
}
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
static reset() {
|
|
307
|
+
super.reset();
|
|
308
|
+
LoggerChannelRegistry.instance.reset();
|
|
309
|
+
}
|
|
310
|
+
registerStartupTasks() {
|
|
311
|
+
if (Envapter.isDevelopment || Envapter.isTest) this.registerHmrAwareModules();
|
|
312
|
+
const { interactions } = this;
|
|
313
|
+
if (interactions) this.startup.addTask(StartupPhase.Configuration, "Interactions Initialization", async () => {
|
|
314
|
+
interactions.logger.utils.initialization("Interactions", "start");
|
|
315
|
+
await interactions.init();
|
|
316
|
+
interactions.logger.utils.initialization("Interactions", "end");
|
|
317
|
+
});
|
|
318
|
+
this.startup.addTask(StartupPhase.Ready, "Http Server", () => this.listen());
|
|
319
|
+
if (!Envapter.isTest) this.startup.addTask(StartupPhase.Ready, "Identity", () => this.fetchUsername());
|
|
320
|
+
const { healthCheck } = this;
|
|
321
|
+
if (healthCheck) this.startup.addTask(StartupPhase.Ready, "Health Check", async () => {
|
|
322
|
+
healthCheck.logger.utils.initialization("HealthCheck", "start");
|
|
323
|
+
await healthCheck.init();
|
|
324
|
+
healthCheck.logger.utils.initialization("HealthCheck", "end");
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
registerHmrAwareModules() {
|
|
328
|
+
this.startup.addTask(StartupPhase.Configuration, "HMR Registration", async () => {
|
|
329
|
+
if (this.interactions) this.hmrManager.register(this.interactions);
|
|
330
|
+
for (const plugin of this.plugins) this.hmrManager.register(plugin);
|
|
331
|
+
await Promise.resolve();
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
async listen() {
|
|
335
|
+
const token = validateDiscordToken(Envapter.get("DISCORD_BOT_TOKEN"));
|
|
336
|
+
this.rest.setToken(token);
|
|
337
|
+
const maps = this.interactions?.maps ?? buildRouteMaps(EMPTY_MANIFEST);
|
|
338
|
+
const { handle, inFlight } = buildEngine(this, maps);
|
|
339
|
+
const server = createServer((incoming, outgoing) => {
|
|
340
|
+
(async () => {
|
|
341
|
+
await writeWebResponse(await handle(await toWebRequest(incoming)), outgoing);
|
|
342
|
+
})().catch((error) => {
|
|
343
|
+
outgoing.destroy(Error.isError(error) ? error : new Error(String(error)));
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
this.server = server;
|
|
347
|
+
server.listen(this.requestedPort);
|
|
348
|
+
await once(server, "listening");
|
|
349
|
+
this.boundPort = server.address().port;
|
|
350
|
+
this.logger.info(`Interactions server listening on port ${paint.sky.bold(String(this.boundPort))}`);
|
|
351
|
+
this.shutdown.addTask(ShutdownPhase.Unbind, "stop-http-server", () => this.stopServer(), SERVER_SHUTDOWN_TIMEOUT_MS);
|
|
352
|
+
this.shutdown.addTask(ShutdownPhase.Drain, "drain-inflight", async () => {
|
|
353
|
+
await Promise.allSettled(inFlight);
|
|
354
|
+
}, DRAIN_TIMEOUT_MS);
|
|
355
|
+
}
|
|
356
|
+
async fetchUsername() {
|
|
357
|
+
try {
|
|
358
|
+
const me = await this.rest.get(Routes.user("@me"));
|
|
359
|
+
this.fetchedUsername = me.username;
|
|
360
|
+
} catch (caught) {
|
|
361
|
+
this.logger.warn("could not fetch the bot identity", caught);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
stopServer() {
|
|
365
|
+
const server = this.server;
|
|
366
|
+
if (!server?.listening) return Promise.resolve();
|
|
367
|
+
return new Promise((resolveClose, rejectClose) => {
|
|
368
|
+
server.close((err) => {
|
|
369
|
+
if (err) {
|
|
370
|
+
rejectClose(err);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
this.logger.info(paint.coral.bold("Interactions server stopped"));
|
|
374
|
+
resolveClose();
|
|
375
|
+
});
|
|
376
|
+
server.closeIdleConnections();
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
1
382
|
//#region src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
383
|
+
var src_exports = /* @__PURE__ */ __exportAll({
|
|
384
|
+
AutocompleteHandler: () => AutocompleteHandler,
|
|
385
|
+
ButtonHandler: () => ButtonHandler,
|
|
386
|
+
ComponentHandler: () => ComponentHandler,
|
|
387
|
+
ContextMenuHandler: () => ContextMenuHandler,
|
|
388
|
+
Gated: () => Gated,
|
|
389
|
+
InteractionHandler: () => InteractionHandler,
|
|
390
|
+
ModalHandler: () => ModalHandler,
|
|
391
|
+
RepliableHandler: () => RepliableHandler,
|
|
392
|
+
Seedcord: () => Seedcord,
|
|
393
|
+
SelectMenuHandler: () => SelectMenuHandler,
|
|
394
|
+
SlashHandler: () => SlashHandler,
|
|
395
|
+
createSeedcord: () => createSeedcord,
|
|
396
|
+
version: () => version
|
|
397
|
+
});
|
|
4
398
|
|
|
5
399
|
//#endregion
|
|
6
|
-
export { version };
|
|
400
|
+
export { AutocompleteHandler, ButtonHandler, ComponentHandler, ContextMenuHandler, Gated, InteractionHandler, ModalHandler, RepliableHandler, Seedcord, SelectMenuHandler, SlashHandler, createSeedcord, version };
|
|
7
401
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/** Package version */\nexport const version = process.env.PACKAGE_VERSION ?? '0.0.0';\n"],"mappings":";;AACA,MAAa"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["packageVersion"],"sources":["../src/manifest/RouteManifest.ts","../src/node/InteractionDispatcher.ts","../src/node/webBridge.ts","../src/node/Seedcord.ts","../src/index.ts"],"sourcesContent":["import type { SelectMenuKind } from '@seedcord/core';\nimport type { ApplicationCommandType } from 'discord-api-types/v10';\n\n/** The command kinds a manifest row registers, the wire enum's other members have no handler base. */\ntype RegistrableCommandType =\n | ApplicationCommandType.ChatInput\n | ApplicationCommandType.User\n | ApplicationCommandType.Message;\n\n/**\n * A slash or context-menu command row. `type` picks the per-kind map, `name` is the lookup key. For a\n * chat-input command with subcommands, `name` is the full route path (`'config/set'`), the same key\n * `@SlashRoute` registers.\n */\ninterface CommandRoute {\n readonly name: string;\n readonly type: RegistrableCommandType;\n /** Lazy import of the handler module, evaluated on first hit. */\n readonly load: () => Promise<unknown>;\n}\n\n/**\n * A button, select, or modal row. `kind` picks the per-kind map, `prefix` is the stable customId prefix\n * the receiver routes by (the routeKey minus its layout hash).\n */\nexport interface ComponentRoute {\n readonly kind: 'button' | `${SelectMenuKind}Select` | 'modal';\n readonly prefix: string;\n /** Lazy import of the handler module, evaluated on first hit. */\n readonly load: () => Promise<unknown>;\n}\n\n/**\n * An autocomplete row, its own route keyed by the command's route path, separate from the slash row.\n */\ninterface AutocompleteRoute {\n readonly name: string;\n /** Lazy import of the handler module, evaluated on first hit. */\n readonly load: () => Promise<unknown>;\n}\n\n/**\n * A bus subscriber row. The Bus routes off it without importing the subscriber module. The HTTP engine\n * ignores these rows until the Bus ships on this transport.\n */\ninterface SubscriberRoute {\n /** The subscription keys this subscriber registers for. */\n readonly keys: readonly string[];\n /** Mirrors the `@Subscribe` frequency metadata. */\n readonly frequency: 'on' | 'once';\n /** Lazy import of the subscriber module. */\n readonly load: () => Promise<unknown>;\n}\n\n/**\n * The static route table the HTTP engine dispatches through, replacing the filesystem handler scan that\n * cannot run in a bundled isolate. `seedcord build` emits it, the mount path authors it by hand.\n */\nexport interface RouteManifest {\n readonly commands: readonly CommandRoute[];\n readonly components: readonly ComponentRoute[];\n readonly autocomplete: readonly AutocompleteRoute[];\n readonly subscribers: readonly SubscriberRoute[];\n}\n\n/** @internal */\nexport const EMPTY_MANIFEST: RouteManifest = { commands: [], components: [], autocomplete: [], subscribers: [] };\n","import { HmrModuleHandler } from '@seedcord/core/hmr';\nimport { interactionRoutesOf, InteractionMetadataKey, InteractionRoutes } from '@seedcord/core/internal';\nimport { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\nimport { Logger } from '@seedcord/logger';\nimport { formatFilePath } from '@seedcord/utils';\nimport { traverseDirectory } from '@seedcord/utils/node';\nimport { Envapter } from 'envapt';\n\nimport { AutocompleteHandler } from '@handlers/interaction/AutocompleteHandler';\nimport { InteractionHandler } from '@handlers/interaction/InteractionHandler';\nimport { buildRouteMaps } from '@src/dispatch/resolve';\nimport { EMPTY_MANIFEST } from '@src/manifest/RouteManifest';\n\nimport type { HandlerConstructor } from '@handlers/constructors';\nimport type { Initializeable } from '@seedcord/core';\nimport type { HmrAware, HmrUpdateEvent } from '@seedcord/types';\nimport type { ResolvedRoute, RouteMap, RouteMaps } from '@src/dispatch/resolve';\n\ninterface RouteTarget {\n readonly map: RouteMap;\n readonly kind: ResolvedRoute['kind'];\n}\n\n/**\n * Discovers interaction handlers from the filesystem into the engine's live route maps.\n *\n * The node host runs it at startup and dev HMR swaps map entries in place. The engine's `resolve`\n * reads `maps` per request. The edge path builds its maps from the generated manifest.\n */\nexport class InteractionDispatcher implements Initializeable, HmrAware {\n public readonly maps: RouteMaps;\n private readonly targets: Record<InteractionRoutes, RouteTarget>;\n\n /** @internal */\n public readonly logger = new Logger('Interactions');\n\n private isInitialized = false;\n private readonly hmrHandler?: HmrModuleHandler<HandlerConstructor, void, string[]>;\n // routeId -> owner row, the duplicate guard and the hmr unregister index\n private readonly rowOwners = new Map<string, { ctor: HandlerConstructor; target: RouteTarget; key: string }>();\n\n private loading = false;\n private readonly loadedHandlers: { name: string; from: string }[] = [];\n\n constructor(private readonly handlersDir: string) {\n this.maps = buildRouteMaps(EMPTY_MANIFEST);\n this.targets = this.buildTargets();\n\n if (!Envapter.isDevelopment && !Envapter.isTest) return;\n this.hmrHandler = new HmrModuleHandler({\n handlersDir,\n isHandler: this.isHandler.bind(this),\n registerHandler: this.registerHandler.bind(this),\n unregisterHandler: this.unregisterHandler.bind(this),\n getArtifacts: this.getArtifacts.bind(this),\n logger: this.logger\n });\n }\n\n /** @internal */\n public async init(): Promise<void> {\n if (this.isInitialized) return;\n this.isInitialized = true;\n\n this.loading = true;\n this.loadedHandlers.length = 0;\n try {\n await traverseDirectory(\n this.handlersDir,\n (fullPath, relativePath, imported) => {\n for (const value of Object.values(imported)) {\n if (!this.isHandler(value)) continue;\n this.registerHandler(value, relativePath);\n this.hmrHandler?.trackHandler(fullPath, value);\n }\n },\n this.logger\n );\n } finally {\n this.loading = false;\n }\n\n this.logger.utils.block('Loaded handlers', [\n ...this.logger.utils.entries(this.loadedHandlers),\n ...this.logger.utils.counts({ routes: this.rowOwners.size })\n ]);\n }\n\n /** @internal */\n public async onHmr(event: HmrUpdateEvent): Promise<void> {\n await this.hmrHandler?.handle(event);\n }\n\n private isHandler(value: unknown): value is HandlerConstructor {\n if (typeof value !== 'function') return false;\n // this package's own family bases. A gateway handler in the same dir stays unregistered\n return (\n (value.prototype instanceof InteractionHandler || value.prototype instanceof AutocompleteHandler) &&\n Reflect.hasMetadata(InteractionMetadataKey, value)\n );\n }\n\n private getArtifacts(ctor: HandlerConstructor): string[] {\n const routeIds: string[] = [];\n for (const [routeId, owner] of this.rowOwners) {\n if (owner.ctor === ctor) routeIds.push(routeId);\n }\n return routeIds;\n }\n\n private targetFor(route: InteractionRoutes): RouteTarget {\n return this.targets[route];\n }\n\n private buildTargets(): Record<InteractionRoutes, RouteTarget> {\n return {\n [InteractionRoutes.Slash]: { map: this.maps.slash, kind: 'slash' },\n [InteractionRoutes.UserContextMenu]: { map: this.maps.userContextMenu, kind: 'userContextMenu' },\n [InteractionRoutes.MessageContextMenu]: { map: this.maps.messageContextMenu, kind: 'messageContextMenu' },\n [InteractionRoutes.Autocomplete]: { map: this.maps.autocomplete, kind: 'autocomplete' },\n [InteractionRoutes.Button]: { map: this.maps.components.button, kind: 'button' },\n [InteractionRoutes.StringMenu]: { map: this.maps.components.stringSelect, kind: 'stringMenu' },\n [InteractionRoutes.UserMenu]: { map: this.maps.components.userSelect, kind: 'userMenu' },\n [InteractionRoutes.RoleMenu]: { map: this.maps.components.roleSelect, kind: 'roleMenu' },\n [InteractionRoutes.ChannelMenu]: { map: this.maps.components.channelSelect, kind: 'channelMenu' },\n [InteractionRoutes.MentionableMenu]: {\n map: this.maps.components.mentionableSelect,\n kind: 'mentionableMenu'\n },\n [InteractionRoutes.Modal]: { map: this.maps.components.modal, kind: 'modal' }\n };\n }\n\n private registerHandler(ctor: HandlerConstructor, relativePath: string): void {\n // a partial registration would orphan routes and break hmr rollback\n const writes: [RouteTarget, string][] = [];\n\n for (const [route, keys] of interactionRoutesOf(ctor)) {\n const target = this.targetFor(route);\n for (const key of keys) {\n const existing = this.rowOwners.get(`${target.kind}:${key}`);\n // a different class on the same route would silently shadow (last write wins), so this throws\n if (existing && existing.ctor !== ctor) {\n throw new SeedcordError(SeedcordErrorCode.InteractionDuplicateRoute, [\n key,\n existing.ctor.name,\n ctor.name\n ]);\n }\n writes.push([target, key]);\n }\n }\n\n if (writes.length === 0) return;\n for (const [target, key] of writes) {\n const routeId = `${target.kind}:${key}`;\n // a one-export module, the dispatch first-handler scan resolves exactly this row's class\n target.map.set(key, { kind: target.kind, routeId, load: () => Promise.resolve({ [ctor.name]: ctor }) });\n this.rowOwners.set(routeId, { ctor, target, key });\n }\n\n const from = formatFilePath(relativePath);\n if (this.loading) this.loadedHandlers.push({ name: ctor.name, from });\n else this.logger.utils.registration(ctor.name, from);\n }\n\n private unregisterHandler(ctor: HandlerConstructor, artifacts?: string[]): void {\n const routeIds = artifacts ?? this.getArtifacts(ctor);\n for (const routeId of routeIds) {\n const owner = this.rowOwners.get(routeId);\n if (owner?.ctor !== ctor) continue;\n this.rowOwners.delete(routeId);\n owner.target.map.delete(owner.key);\n }\n }\n}\n","import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';\n\nfunction toHeaders(raw: IncomingHttpHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of Object.entries(raw)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n for (const item of value) headers.append(name, item);\n } else {\n headers.set(name, value);\n }\n }\n return headers;\n}\n\n// buffers the raw body before any parse so ed25519 verifies the exact signed bytes\nexport async function toWebRequest(request: IncomingMessage): Promise<Request> {\n const chunks: Buffer[] = [];\n // justified: the async iterator is typed any and IncomingMessage yields Buffer chunks\n for await (const chunk of request) chunks.push(chunk as Buffer);\n\n const method = request.method ?? 'GET';\n const body = method === 'GET' || method === 'HEAD' ? undefined : new Uint8Array(Buffer.concat(chunks));\n\n return new Request(`http://${request.headers.host ?? 'localhost'}${request.url ?? '/'}`, {\n method,\n headers: toHeaders(request.headers),\n ...(body !== undefined && { body })\n });\n}\n\nexport async function writeWebResponse(response: Response, out: ServerResponse): Promise<void> {\n const headers: Record<string, string | string[]> = Object.fromEntries(response.headers);\n // iterating Headers comma-joins same-name values, which corrupts Set-Cookie (a per-cookie header)\n const cookies = response.headers.getSetCookie();\n if (cookies.length > 0) headers['set-cookie'] = cookies;\n\n out.writeHead(response.status, headers);\n out.end(response.body === null ? undefined : Buffer.from(await response.arrayBuffer()));\n}\n","import { once } from 'node:events';\nimport { createServer } from 'node:http';\n\nimport { REST } from '@discordjs/rest';\nimport { HmrManager, setBotColor } from '@seedcord/core/internal';\nimport {\n CoordinatedShutdown,\n CoordinatedStartup,\n HealthCheck,\n Pluggable,\n ShutdownPhase,\n StartupPhase\n} from '@seedcord/core/node/internal';\nimport { validateDiscordToken } from '@seedcord/errors/internal';\nimport { Logger, LoggerChannelRegistry, paint } from '@seedcord/logger';\nimport { installNodeDefaults } from '@seedcord/logger/node';\nimport { MemoryRateLimiter } from '@seedcord/rate-limiter';\nimport { SeedcordBrand } from '@seedcord/types/internal';\nimport { Routes } from 'discord-api-types/v10';\nimport { Envapter } from 'envapt';\n\nimport { buildRouteMaps } from '@src/dispatch/resolve';\nimport { buildEngine } from '@src/engine';\nimport { EMPTY_MANIFEST } from '@src/manifest/RouteManifest';\n\nimport { InteractionDispatcher } from './InteractionDispatcher';\nimport { toWebRequest, writeWebResponse } from './webBridge';\nimport { version as packageVersion } from '../version';\n\nimport type { HttpConfig } from '@interfaces/Config';\nimport type { Core } from '@interfaces/Core';\nimport type { PluginCapabilities } from '@seedcord/core/node/internal';\nimport type { IRateLimiter } from '@seedcord/types';\nimport type { Server } from 'node:http';\nimport type { AddressInfo } from 'node:net';\n\nconst DEFAULT_PORT = 3000;\nconst SERVER_SHUTDOWN_TIMEOUT_MS = 5000;\nconst DRAIN_TIMEOUT_MS = 10_000;\n\n/**\n * The HTTP-interactions bot host, a long-running node server around the engine.\n *\n * Discovers handlers from `config.bot.interactions.path`, verifies and dispatches interactions on\n * `start(port)`, and runs coordinated shutdown with an in-flight drain. The edge deploy path calls\n * `createSeedcord` from a generated entry.\n */\nexport class Seedcord extends Pluggable implements Core {\n // the CLI reads these to detect and augment the instance\n /** @internal */\n public readonly [SeedcordBrand] = true;\n /** @internal */\n public readonly augmentTarget = '@seedcord/http';\n /** @internal */\n public readonly version: string = packageVersion;\n\n /** Workerd-compatible Discord REST client. `start()` sets the token. */\n public readonly rest = new REST();\n\n /** @see {@link IRateLimiter} */\n public readonly rateLimiter: IRateLimiter;\n\n /** @see {@link CoordinatedShutdown} */\n public override readonly shutdown: CoordinatedShutdown;\n\n /** @see {@link CoordinatedStartup} */\n public override readonly startup: CoordinatedStartup;\n\n private readonly interactions?: InteractionDispatcher;\n private readonly healthCheck?: HealthCheck | undefined;\n private readonly hmrManager: HmrManager;\n private readonly logger = new Logger('Server');\n\n private server?: Server;\n private boundPort?: number;\n private requestedPort = DEFAULT_PORT;\n private fetchedUsername?: string | undefined;\n\n constructor(public readonly config: HttpConfig) {\n const shutdown = new CoordinatedShutdown();\n const startup = new CoordinatedStartup();\n\n super(shutdown, startup);\n\n installNodeDefaults(config.logger);\n setBotColor(config.botColor);\n\n this.shutdown = shutdown;\n this.startup = startup;\n\n this.hmrManager = new HmrManager();\n this.hmrManager.init();\n\n if (this.config.bot.interactions.path) {\n this.interactions = new InteractionDispatcher(this.config.bot.interactions.path);\n }\n\n this.rateLimiter = config.store ?? new MemoryRateLimiter();\n // the edge arm types healthCheck never, and a dev run of an edge config needs no health server\n this.healthCheck =\n config.runtime === 'edge' ? undefined : HealthCheck.fromOption(this.shutdown, config.healthCheck);\n\n this.registerStartupTasks();\n }\n\n /** The bot's discord username, populated by the ready fetch. */\n public get username(): string | undefined {\n return this.fetchedUsername;\n }\n\n /** The bound server port, populated once `start()` is listening. */\n public get port(): number | undefined {\n return this.boundPort;\n }\n\n protected override pluginCapabilities(): PluginCapabilities {\n const token = Envapter.get('DISCORD_BOT_TOKEN');\n return { rest: this.rest, ...(token !== undefined && { token }) };\n }\n\n /**\n * Starts the host and runs the startup tasks.\n *\n * @param port - The port the interaction server binds. {@default `3000`}\n */\n public async start(port = DEFAULT_PORT): Promise<this> {\n this.requestedPort = port;\n try {\n await super.init();\n } catch (caught) {\n // shutdown releases any resource opened before the failure, then rethrow\n await this.shutdown.run(1, false);\n Seedcord.reset();\n throw caught;\n }\n return this;\n }\n\n protected static override reset(): void {\n super.reset();\n LoggerChannelRegistry.instance.reset();\n }\n\n private registerStartupTasks(): void {\n if (Envapter.isDevelopment || Envapter.isTest) this.registerHmrAwareModules();\n\n const { interactions } = this;\n if (interactions) {\n this.startup.addTask(StartupPhase.Configuration, 'Interactions Initialization', async () => {\n interactions.logger.utils.initialization('Interactions', 'start');\n await interactions.init();\n interactions.logger.utils.initialization('Interactions', 'end');\n });\n }\n\n this.startup.addTask(StartupPhase.Ready, 'Http Server', () => this.listen());\n\n if (!Envapter.isTest) {\n this.startup.addTask(StartupPhase.Ready, 'Identity', () => this.fetchUsername());\n }\n\n const { healthCheck } = this;\n if (healthCheck) {\n this.startup.addTask(StartupPhase.Ready, 'Health Check', async () => {\n healthCheck.logger.utils.initialization('HealthCheck', 'start');\n await healthCheck.init();\n healthCheck.logger.utils.initialization('HealthCheck', 'end');\n });\n }\n }\n\n private registerHmrAwareModules(): void {\n this.startup.addTask(StartupPhase.Configuration, 'HMR Registration', async () => {\n if (this.interactions) this.hmrManager.register(this.interactions);\n for (const plugin of this.plugins) {\n this.hmrManager.register(plugin);\n }\n await Promise.resolve();\n });\n }\n\n private async listen(): Promise<void> {\n const token = validateDiscordToken(Envapter.get('DISCORD_BOT_TOKEN'));\n this.rest.setToken(token);\n\n const maps = this.interactions?.maps ?? buildRouteMaps(EMPTY_MANIFEST);\n const { handle, inFlight } = buildEngine(this, maps);\n\n const server = createServer((incoming, outgoing) => {\n void (async () => {\n const response = await handle(await toWebRequest(incoming));\n await writeWebResponse(response, outgoing);\n })().catch((error: unknown) => {\n // a swallowed throw would hang the client request with no cause\n outgoing.destroy(Error.isError(error) ? error : new Error(String(error)));\n });\n });\n this.server = server;\n\n server.listen(this.requestedPort);\n await once(server, 'listening');\n // justified: address() is AddressInfo once a TCP server is listening\n this.boundPort = (server.address() as AddressInfo).port;\n this.logger.info(`Interactions server listening on port ${paint.sky.bold(String(this.boundPort))}`);\n\n this.shutdown.addTask(\n ShutdownPhase.Unbind,\n 'stop-http-server',\n () => this.stopServer(),\n SERVER_SHUTDOWN_TIMEOUT_MS\n );\n // Unbind already ran, so every accepted request is in the in-flight set here\n this.shutdown.addTask(\n ShutdownPhase.Drain,\n 'drain-inflight',\n async () => {\n await Promise.allSettled(inFlight);\n },\n DRAIN_TIMEOUT_MS\n );\n }\n\n private async fetchUsername(): Promise<void> {\n try {\n // justified: the @me payload carries username per the discord api contract\n const me = (await this.rest.get(Routes.user('@me'))) as { username?: string };\n this.fetchedUsername = me.username;\n } catch (caught) {\n // a bad token errors on the first real send. The identity fetch stays non-fatal\n this.logger.warn('could not fetch the bot identity', caught);\n }\n }\n\n private stopServer(): Promise<void> {\n const server = this.server;\n if (!server?.listening) return Promise.resolve();\n\n return new Promise((resolveClose, rejectClose) => {\n server.close((err) => {\n if (err) {\n rejectClose(err);\n return;\n }\n this.logger.info(paint.coral.bold('Interactions server stopped'));\n resolveClose();\n });\n // idle keep-alive sockets would stall close() past the task timeout. Active responses\n // still flush, and the task timeout bounds a hung one\n server.closeIdleConnections();\n });\n }\n}\n","export * from './edge.index';\nexport { Seedcord } from '@src/node/Seedcord';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,iBAAgC;CAAE,UAAU,CAAC;CAAG,YAAY,CAAC;CAAG,cAAc,CAAC;CAAG,aAAa,CAAC;AAAE;;;;;;;;;;ACpC/G,IAAa,wBAAb,MAAuE;CAetC;CAd7B,AAAgB;CAChB,AAAiB;;CAGjB,AAAgB,SAAS,IAAI,OAAO,cAAc;CAElD,AAAQ,gBAAgB;CACxB,AAAiB;CAEjB,AAAiB,4BAAY,IAAI,IAA4E;CAE7G,AAAQ,UAAU;CAClB,AAAiB,iBAAmD,CAAC;CAEr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,KAAK,WAAW,GACtB,0BACJ;EAEA,KAAK,SAAS,QACV,cAAc,OACd,kBACA,YAAY;GACR,MAAM,QAAQ,WAAW,QAAQ;EACrC,GACA,gBACJ;CACJ;CAEA,MAAc,gBAA+B;EACzC,IAAI;GAEA,MAAM,KAAM,MAAM,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,CAAC;GAClD,KAAK,kBAAkB,GAAG;EAC9B,SAAS,QAAQ;GAEb,KAAK,OAAO,KAAK,oCAAoC,MAAM;EAC/D;CACJ;CAEA,AAAQ,aAA4B;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ,WAAW,OAAO,QAAQ,QAAQ;EAE/C,OAAO,IAAI,SAAS,cAAc,gBAAgB;GAC9C,OAAO,OAAO,QAAQ;IAClB,IAAI,KAAK;KACL,YAAY,GAAG;KACf;IACJ;IACA,KAAK,OAAO,KAAK,MAAM,MAAM,KAAK,6BAA6B,CAAC;IAChE,aAAa;GACjB,CAAC;GAGD,OAAO,qBAAqB;EAChC,CAAC;CACL;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _seedcord_errors_internal = require("@seedcord/errors/internal");
|
|
3
|
+
let _seedcord_errors = require("@seedcord/errors");
|
|
4
|
+
|
|
5
|
+
//#region src/manifest.index.ts
|
|
6
|
+
/**
|
|
7
|
+
* The generated route table. `seedcord build` aliases this module to the emitted file. An un-built
|
|
8
|
+
* import throws.
|
|
9
|
+
*/
|
|
10
|
+
const manifest = (() => {
|
|
11
|
+
throw new _seedcord_errors_internal.SeedcordError(_seedcord_errors.SeedcordErrorCode.ConfigManifestNotGenerated);
|
|
12
|
+
})();
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.manifest = manifest;
|
|
16
|
+
//# sourceMappingURL=manifest.index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.index.cjs","names":["SeedcordError","SeedcordErrorCode"],"sources":["../src/manifest.index.ts"],"sourcesContent":["import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport type { RouteManifest } from '@src/manifest/RouteManifest';\n\nexport type { RouteManifest } from '@src/manifest/RouteManifest';\n\n/**\n * The generated route table. `seedcord build` aliases this module to the emitted file. An un-built\n * import throws.\n */\nexport const manifest: RouteManifest = (() => {\n throw new SeedcordError(SeedcordErrorCode.ConfigManifestNotGenerated);\n})();\n"],"mappings":";;;;;;;;;AAWA,MAAa,kBAAiC;CAC1C,MAAM,IAAIA,wCAAcC,mCAAkB,0BAA0B;AACxE,EAAC,CAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './manifest.index.d.mts'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as RouteManifest } from "./RouteManifest-BHdAeyLG.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/manifest.index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The generated route table. `seedcord build` aliases this module to the emitted file. An un-built
|
|
6
|
+
* import throws.
|
|
7
|
+
*/
|
|
8
|
+
declare const manifest: RouteManifest;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type RouteManifest, manifest };
|
|
11
|
+
//# sourceMappingURL=manifest.index.d.mts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SeedcordError } from "@seedcord/errors/internal";
|
|
2
|
+
import { SeedcordErrorCode } from "@seedcord/errors";
|
|
3
|
+
|
|
4
|
+
//#region src/manifest.index.ts
|
|
5
|
+
/**
|
|
6
|
+
* The generated route table. `seedcord build` aliases this module to the emitted file. An un-built
|
|
7
|
+
* import throws.
|
|
8
|
+
*/
|
|
9
|
+
const manifest = (() => {
|
|
10
|
+
throw new SeedcordError(SeedcordErrorCode.ConfigManifestNotGenerated);
|
|
11
|
+
})();
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { manifest };
|
|
15
|
+
//# sourceMappingURL=manifest.index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.index.mjs","names":[],"sources":["../src/manifest.index.ts"],"sourcesContent":["import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport type { RouteManifest } from '@src/manifest/RouteManifest';\n\nexport type { RouteManifest } from '@src/manifest/RouteManifest';\n\n/**\n * The generated route table. `seedcord build` aliases this module to the emitted file. An un-built\n * import throws.\n */\nexport const manifest: RouteManifest = (() => {\n throw new SeedcordError(SeedcordErrorCode.ConfigManifestNotGenerated);\n})();\n"],"mappings":";;;;;;;;AAWA,MAAa,kBAAiC;CAC1C,MAAM,IAAI,cAAc,kBAAkB,0BAA0B;AACxE,EAAC,CAAE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __exportAll = (all, no_symbols) => {
|
|
7
|
+
let target = {};
|
|
8
|
+
for (var name in all) {
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (!no_symbols) {
|
|
15
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: ((k) => from[k]).bind(null, key),
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { __reExport as n, __exportAll as t };
|