Allow subpath imports, move extensions to separate module

This commit is contained in:
Rory&
2026-06-11 18:07:50 +02:00
parent 758389d1f5
commit fe1c390973
18 changed files with 54 additions and 23 deletions
+1
View File
@@ -126,6 +126,7 @@
"_moduleAliases": {
"@spacebar/api": "dist/api",
"@spacebar/cdn": "dist/cdn",
"@spacebar/extensions": "dist/extensions",
"@spacebar/gateway": "dist/gateway",
"@spacebar/util": "dist/util",
"@spacebar/webrtc": "dist/webrtc",
@@ -17,6 +17,7 @@
*/
import { route } from "@spacebar/api";
import { arrayRemove } from "@spacebar/extensions";
import {
Channel,
emitEvent,
@@ -29,7 +30,6 @@ import {
MessageReactionRemoveEmojiEvent,
MessageReactionRemoveEvent,
User,
arrayRemove,
ReactionType,
} from "@spacebar/util";
import { Request, Response, Router } from "express";
@@ -17,7 +17,8 @@
*/
import { Router, Request, Response } from "express";
import { DiscordApiErrors, Member, arrayPartition } from "@spacebar/util";
import { arrayPartition } from "@spacebar/extensions";
import { DiscordApiErrors, Member } from "@spacebar/util";
import { route } from "@spacebar/api";
const router = Router({ mergeParams: true });
+1 -3
View File
@@ -17,10 +17,9 @@
*/
import { fillMessageUrlEmbeds, randomString } from "@spacebar/api";
import { mathLogBase, arrayDistributeSequentially } from "@spacebar/extensions";
import {
Application,
arrayDistributeSequentially,
arrayPartition,
Attachment,
Channel,
CloudAttachment,
@@ -35,7 +34,6 @@ import {
Guild,
handleFile,
HERE_MENTION,
mathLogBase,
Member,
Message,
MessageCreateEvent,
+2 -1
View File
@@ -16,7 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { arrayDistinctBy, arrayGroupBy, Config, EmbedCache, emitEvent, Message, MessageUpdateEvent, normalizeUrl, OrmUtils, sleep } from "@spacebar/util";
import { sleep, arrayDistinctBy, arrayGroupBy } from "@spacebar/extensions";
import { Config, EmbedCache, emitEvent, Message, MessageUpdateEvent, normalizeUrl, OrmUtils } from "@spacebar/util";
import { Embed, EmbedImage, EmbedType } from "@spacebar/schemas";
import * as cheerio from "cheerio";
import crypto from "node:crypto";
+2 -2
View File
@@ -16,12 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { fileTypeFromBuffer } from "file-type";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache } from "../util/cache";
+1 -1
View File
@@ -17,9 +17,9 @@
*/
import { Capabilities, CLOSECODES, OPCODES, Payload, Send, setupListener, WebSocket } from "@spacebar/gateway";
import { arrayGroupBy } from "@spacebar/extensions";
import {
Application,
arrayGroupBy,
Channel,
checkToken,
Config,
+2 -1
View File
@@ -16,7 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { getDatabase, getPermission, listenEvent, Member, Role, Session, User, Presence, Channel, Permissions, arrayPartition, getMostRelevantSession } from "@spacebar/util";
import { arrayPartition } from "@spacebar/extensions";
import { getDatabase, getPermission, listenEvent, Member, Role, Session, User, Presence, Channel, Permissions, getMostRelevantSession } from "@spacebar/util";
import { WebSocket, Payload, handlePresenceUpdate, OPCODES, Send } from "@spacebar/gateway";
import murmur from "murmurhash-js/murmurhash3_gc";
import { check } from "./instanceOf";
+20 -1
View File
@@ -1,4 +1,23 @@
import { Event, Session, sleep, TimeSpan, VoiceState } from "@spacebar/util";
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2026 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { sleep } from "@spacebar/extensions";
import { Event, Session, TimeSpan, VoiceState } from "@spacebar/util";
import { WebSocket } from "./WebSocket";
import { OPCODES } from "./Constants";
import { Send } from "./Send";
+1 -1
View File
@@ -17,6 +17,7 @@
*/
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
import { arrayRemove } from "@spacebar/extensions";
import { Config, GuildWelcomeScreen, Snowflake, handleFile } from "..";
import { Ban } from "./Ban";
import { BaseClass } from "./BaseClass";
@@ -30,7 +31,6 @@ import { Template } from "./Template";
import { User } from "./User";
import { VoiceState } from "./VoiceState";
import { Webhook } from "./Webhook";
import { arrayRemove } from "@spacebar/util";
// TODO: application_command_count, application_command_counts: {1: 0, 2: 0, 3: 0}
// TODO: guild_scheduled_events
// TODO: stage_instances
-2
View File
@@ -17,7 +17,6 @@
*/
export * from "./ApiError";
export * from "./extensions/Array";
export * from "./BitField";
//export * from "./Categories";
export * from "./cdn";
@@ -52,7 +51,6 @@ export * from "./Gifs";
export * from "./Application";
export * from "./NameValidation";
export * from "../../schemas/HelperTypes";
export * from "./extensions";
export * from "./Random";
export * from "./Url";
export * from "./Version";
@@ -18,12 +18,13 @@
import EventEmitter from "node:events";
import { randomUUID } from "node:crypto";
import { BaseEventListener } from "./BaseEventListener";
import { arraySum, EVENT, Event, EventOpts, sleep } from "@spacebar/util";
import amqp, { Channel, ChannelModel } from "amqplib";
import { ProcessLifecycle } from "../../ProcessLifecycle";
import { Monitoring } from "../../../monitoring/Monitoring";
import { Gauge } from "prom-client";
import { sleep, arraySum } from "@spacebar/extensions";
import { EVENT, Event, EventOpts } from "@spacebar/util";
import { Monitoring } from "../../../monitoring/Monitoring";
import { ProcessLifecycle } from "../../ProcessLifecycle";
import { BaseEventListener } from "./BaseEventListener";
export class RabbitMqSingleListener extends BaseEventListener {
static openListenersMetric: Gauge;
@@ -19,10 +19,11 @@
import EventEmitter from "node:events";
import fs from "node:fs";
import net, { Server } from "node:net";
import { BaseEventListener } from "./BaseEventListener";
import { arraySum, EVENT, Event, EventOpts } from "@spacebar/util";
import { ProcessLifecycle } from "../../ProcessLifecycle";
import { Gauge } from "prom-client";
import { arraySum } from "@spacebar/extensions";
import { EVENT, Event, EventOpts } from "@spacebar/util";
import { BaseEventListener } from "./BaseEventListener";
import { ProcessLifecycle } from "../../ProcessLifecycle";
import { Monitoring } from "../../../monitoring/Monitoring";
export class UnixSocketListener extends BaseEventListener {
@@ -16,10 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { BaseEventWriter } from "./BaseEventWriter";
import amqp, { Channel, ChannelModel } from "amqplib";
import { Event, sleep } from "@spacebar/util";
import { sleep } from "@spacebar/extensions";
import { Event } from "@spacebar/util";
import { ProcessLifecycle } from "../../ProcessLifecycle";
import { BaseEventWriter } from "./BaseEventWriter";
export class RabbitMqSingleWriter extends BaseEventWriter {
private readonly host: string;
+9
View File
@@ -32,12 +32,21 @@
// "baseUrl": "./src/", //deprecated
"paths": {
//"*": ["./src/*"],
"@spacebar/api": ["./src/api"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/api*": ["./src/api*"],
"@spacebar/extensions": ["./src/extensions"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/extensions*": ["./src/extensions*"],
"@spacebar/gateway": ["./src/gateway"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/gateway*": ["./src/gateway*"],
"@spacebar/cdn": ["./src/cdn"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/cdn*": ["./src/cdn*"],
"@spacebar/util": ["./src/util"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/util*": ["./src/util*"],
"@spacebar/webrtc": ["./src/webrtc"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/webrtc*": ["./src/webrtc*"],
"@spacebar/schemas": ["./src/schemas"], // Required for stable tsc, typescript-go doesn't need this
"@spacebar/schemas*": ["./src/schemas*"],
"lambert-server": ["./src/util/util/lambert-server"], // Required for stable tsc, typescript-go doesn't need this
"lambert-server*": ["./src/util/util/lambert-server*"],
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
"rootDir": "./src", // Required as of TypeScript 7