@wolfstar/shared-http-pieces 1.2.9 → 2.0.0-next-20260830180323

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 CHANGED
@@ -6,6 +6,10 @@ The shared commands used for Star Network's HTTP-only bots.
6
6
 
7
7
  - Define `locales/{{lng}}/commands/shared:infoEmbedDescription` as a string. This is the content displayed in `/info`'s embed description.
8
8
  - Define the information variables.
9
+ - Importing `@wolfstar/shared-http-pieces/register` registers a `preGenericsInitialization` hook
10
+ that adds this package's bundled locales to your `Client`'s i18n backend automatically — as long
11
+ as it's imported before `new Client(...)`, no manual wiring is required. The resolved path is
12
+ also exported as `localesPath`, if you need it directly.
9
13
 
10
14
  ## Usage
11
15
 
package/dist/index.d.ts CHANGED
@@ -1,37 +1,4 @@
1
1
  import * as Sentry from "@sentry/node";
2
- declare namespace Shared_d_exports {
3
- export { DonateDescription, DonateName, DonateResponse, InfoButtonDonate, InfoButtonGitHub, InfoButtonInvite, InfoButtonSupport, InfoDescription, InfoEmbedDescription, InfoFieldServerUsageTitle, InfoFieldServerUsageValue, InfoFieldUptimeTitle, InfoFieldUptimeValue, InfoName };
4
- }
5
- declare const DonateName: import("@wolfstar/http-framework-i18n").TypedT<string>;
6
- declare const DonateDescription: import("@wolfstar/http-framework-i18n").TypedT<string>;
7
- declare const DonateResponse: import("@wolfstar/http-framework-i18n").TypedFT<{
8
- urls: string;
9
- }, string>;
10
- declare const InfoName: import("@wolfstar/http-framework-i18n").TypedT<string>;
11
- declare const InfoDescription: import("@wolfstar/http-framework-i18n").TypedT<string>;
12
- declare const InfoEmbedDescription: import("@wolfstar/http-framework-i18n").TypedT<string>;
13
- declare const InfoFieldUptimeTitle: import("@wolfstar/http-framework-i18n").TypedT<string>;
14
- declare const InfoFieldUptimeValue: import("@wolfstar/http-framework-i18n").TypedFT<{
15
- host: string;
16
- client: string;
17
- }, string>;
18
- declare const InfoFieldServerUsageTitle: import("@wolfstar/http-framework-i18n").TypedT<string>;
19
- declare const InfoFieldServerUsageValue: import("@wolfstar/http-framework-i18n").TypedFT<{
20
- cpu: string;
21
- heapUsed: string;
22
- heapTotal: string;
23
- }, string>;
24
- declare const InfoButtonInvite: import("@wolfstar/http-framework-i18n").TypedT<string>;
25
- declare const InfoButtonSupport: import("@wolfstar/http-framework-i18n").TypedT<string>;
26
- declare const InfoButtonGitHub: import("@wolfstar/http-framework-i18n").TypedT<string>;
27
- declare const InfoButtonDonate: import("@wolfstar/http-framework-i18n").TypedT<string>;
28
- declare namespace All_d_exports$1 {
29
- export { Shared_d_exports as Shared };
30
- }
31
- declare namespace All_d_exports {
32
- export { All_d_exports$1 as Commands };
33
- }
34
- //#endregion
35
2
  //#region src/lib/information.d.ts
36
3
  declare function setRepository(url: string): void;
37
4
  declare function getRepository(): string;
@@ -53,5 +20,5 @@ declare module '@wolfstar/env-utilities' {
53
20
  }
54
21
  }
55
22
  //#endregion
56
- export { All_d_exports as LanguageKeys, Sentry, SentryOptions, getInvite, getRepository, initializeSentry, isSentryInitialized, registerCommands, setInvite, setRepository };
23
+ export { Sentry, SentryOptions, getInvite, getRepository, initializeSentry, isSentryInitialized, registerCommands, setInvite, setRepository };
57
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/i18n/LanguageKeys/Commands/Shared.ts","../src/lib/i18n/LanguageKeys/Commands/All.ts","../src/lib/i18n/LanguageKeys/All.ts","../src/lib/information.ts","../src/lib/sentry.ts","../src/lib/utilities/register-command.ts"],"mappings":";;;;cAEa,oDAAU;cACV,2DAAiB;cACjB,wDAAc;EAAc;;cAC5B,kDAAQ;cACR,yDAAe;cACf,8DAAoB;cACpB,8DAAoB;cACpB,8DAAoB;EAAc;EAAgB;;cAClD,mEAAyB;cACzB,mEAAyB;EAAa;EAAkB;EAAmB;;cAC3E,0DAAgB;cAChB,2DAAiB;cACjB,0DAAgB;cAChB,0DAAgB;;;;;;;;;iBGZb,cAAc;iBAId;iBAIA,UAAU,kBAAkB;iBAI5B;;;iBCTA;iBAIA,iBAAiB,UAAS;UAwCzB,sBAAsB,KAAK,OAAO;EAClD,OAAO;;;;iBChDc,oBAAgB;;YAS3B;IACT"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/information.ts","../src/lib/sentry.ts","../src/lib/utilities/register-command.ts"],"mappings":";;iBAGgB,cAAc;iBAId;iBAIA,UAAU,kBAAkB;iBAI5B;;;iBCTA;iBAIA,iBAAiB,UAAS;UAwCzB,sBAAsB,KAAK,OAAO;EAClD,OAAO;;;;iBChDc,oBAAgB;;YAS3B;IACT"}
package/dist/index.js CHANGED
@@ -1,115 +1,8 @@
1
- import { t as __exportAll } from "./rolldown-runtime-w6R9maHv.js";
1
+ import { a as setInvite, i as getRepository, n as isSentryInitialized, o as setRepository, r as getInvite, t as initializeSentry } from "./sentry-CKHik3nm.js";
2
2
  import * as Sentry from "@sentry/node";
3
- import { FT, T } from "@wolfstar/http-framework-i18n";
4
- import { readFileSync } from "node:fs";
5
- import { resolve } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
3
  import { envIsDefined, envParseString } from "@wolfstar/env-utilities";
8
4
  import { container } from "@wolfstar/http-framework";
9
5
 
10
- //#region src/lib/i18n/LanguageKeys/Commands/Shared.ts
11
- var Shared_exports = /* @__PURE__ */ __exportAll({
12
- DonateDescription: () => DonateDescription,
13
- DonateName: () => DonateName,
14
- DonateResponse: () => DonateResponse,
15
- InfoButtonDonate: () => InfoButtonDonate,
16
- InfoButtonGitHub: () => InfoButtonGitHub,
17
- InfoButtonInvite: () => InfoButtonInvite,
18
- InfoButtonSupport: () => InfoButtonSupport,
19
- InfoDescription: () => InfoDescription,
20
- InfoEmbedDescription: () => InfoEmbedDescription,
21
- InfoFieldServerUsageTitle: () => InfoFieldServerUsageTitle,
22
- InfoFieldServerUsageValue: () => InfoFieldServerUsageValue,
23
- InfoFieldUptimeTitle: () => InfoFieldUptimeTitle,
24
- InfoFieldUptimeValue: () => InfoFieldUptimeValue,
25
- InfoName: () => InfoName
26
- });
27
- const DonateName = T("commands/shared:donateName");
28
- const DonateDescription = T("commands/shared:donateDescription");
29
- const DonateResponse = FT("commands/shared:donateResponse");
30
- const InfoName = T("commands/shared:inviteName");
31
- const InfoDescription = T("commands/shared:inviteDescription");
32
- const InfoEmbedDescription = T("commands/shared:infoEmbedDescription");
33
- const InfoFieldUptimeTitle = T("commands/shared:infoFieldUptimeTitle");
34
- const InfoFieldUptimeValue = FT("commands/shared:infoFieldUptimeValue");
35
- const InfoFieldServerUsageTitle = T("commands/shared:infoFieldServerUsageTitle");
36
- const InfoFieldServerUsageValue = FT("commands/shared:infoFieldServerUsageValue");
37
- const InfoButtonInvite = T("commands/shared:infoButtonInvite");
38
- const InfoButtonSupport = T("commands/shared:infoButtonSupport");
39
- const InfoButtonGitHub = T("commands/shared:infoButtonGitHub");
40
- const InfoButtonDonate = T("commands/shared:infoButtonDonate");
41
-
42
- //#endregion
43
- //#region src/lib/i18n/LanguageKeys/Commands/All.ts
44
- var All_exports$1 = /* @__PURE__ */ __exportAll({ Shared: () => Shared_exports });
45
-
46
- //#endregion
47
- //#region src/lib/i18n/LanguageKeys/All.ts
48
- var All_exports = /* @__PURE__ */ __exportAll({ Commands: () => All_exports$1 });
49
-
50
- //#endregion
51
- //#region src/lib/information.ts
52
- let repository = process.env.CLIENT_REPOSITORY ?? "https://github.com/wolfstar-project";
53
- let invite = process.env.CLIENT_INVITE ?? null;
54
- function setRepository(url) {
55
- repository = url.startsWith("http") ? url : `https://github.com/wolfstar-project/${url}`;
56
- }
57
- function getRepository() {
58
- return repository;
59
- }
60
- function setInvite(clientId, permissions = "0") {
61
- invite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;
62
- }
63
- function getInvite() {
64
- return invite;
65
- }
66
-
67
- //#endregion
68
- //#region src/lib/sentry.ts
69
- let initialized = false;
70
- function isSentryInitialized() {
71
- return initialized;
72
- }
73
- function initializeSentry(options = {}) {
74
- if (!process.env.SENTRY_DSN) return;
75
- const extractedIntegrations = options.integrations ?? [];
76
- const root = options.root ? typeof options.root === "string" ? options.root : fileURLToPath(options.root) : process.cwd();
77
- Sentry.init({
78
- dsn: process.env.SENTRY_DSN,
79
- ...options,
80
- integrations: (integrations) => [
81
- Sentry.consoleIntegration(),
82
- Sentry.functionToStringIntegration(),
83
- Sentry.linkedErrorsIntegration(),
84
- Sentry.modulesIntegration(),
85
- Sentry.onUncaughtExceptionIntegration(),
86
- Sentry.onUnhandledRejectionIntegration(),
87
- Sentry.rewriteFramesIntegration({ root }),
88
- ...typeof extractedIntegrations === "function" ? extractedIntegrations(integrations) : extractedIntegrations
89
- ]
90
- });
91
- const context = getAppContext();
92
- if (context) Sentry.setContext("app", context);
93
- initialized = true;
94
- }
95
- function getAppContext() {
96
- if (process.env.npm_package_name && process.env.npm_package_version) return {
97
- app_name: process.env.npm_package_name,
98
- app_version: process.env.npm_package_version
99
- };
100
- try {
101
- const path = process.env.npm_package_json ?? resolve("package.json");
102
- const { name, version } = JSON.parse(readFileSync(path, "utf8"));
103
- return {
104
- app_name: name,
105
- app_version: version
106
- };
107
- } catch {
108
- return null;
109
- }
110
- }
111
-
112
- //#endregion
113
6
  //#region src/lib/utilities/register-command.ts
114
7
  async function registerCommands() {
115
8
  if (envIsDefined("REGISTRY_GUILD_ID")) await container.applicationCommandRegistry.pushAllCommandsInGuild(envParseString("REGISTRY_GUILD_ID"));
@@ -117,5 +10,5 @@ async function registerCommands() {
117
10
  }
118
11
 
119
12
  //#endregion
120
- export { All_exports as LanguageKeys, Sentry, getInvite, getRepository, initializeSentry, isSentryInitialized, registerCommands, setInvite, setRepository };
13
+ export { Sentry, getInvite, getRepository, initializeSentry, isSentryInitialized, registerCommands, setInvite, setRepository };
121
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/lib/i18n/LanguageKeys/Commands/Shared.ts","../src/lib/i18n/LanguageKeys/Commands/All.ts","../src/lib/i18n/LanguageKeys/All.ts","../src/lib/information.ts","../src/lib/sentry.ts","../src/lib/utilities/register-command.ts"],"sourcesContent":["import { FT, T } from '@wolfstar/http-framework-i18n';\n\nexport const DonateName = T('commands/shared:donateName');\nexport const DonateDescription = T('commands/shared:donateDescription');\nexport const DonateResponse = FT<{ urls: string }>('commands/shared:donateResponse');\nexport const InfoName = T('commands/shared:inviteName');\nexport const InfoDescription = T('commands/shared:inviteDescription');\nexport const InfoEmbedDescription = T('commands/shared:infoEmbedDescription');\nexport const InfoFieldUptimeTitle = T('commands/shared:infoFieldUptimeTitle');\nexport const InfoFieldUptimeValue = FT<{ host: string; client: string }>('commands/shared:infoFieldUptimeValue');\nexport const InfoFieldServerUsageTitle = T('commands/shared:infoFieldServerUsageTitle');\nexport const InfoFieldServerUsageValue = FT<{ cpu: string; heapUsed: string; heapTotal: string }>('commands/shared:infoFieldServerUsageValue');\nexport const InfoButtonInvite = T('commands/shared:infoButtonInvite');\nexport const InfoButtonSupport = T('commands/shared:infoButtonSupport');\nexport const InfoButtonGitHub = T('commands/shared:infoButtonGitHub');\nexport const InfoButtonDonate = T('commands/shared:infoButtonDonate');\n","export * as Shared from './Shared.js';\n","export * as Commands from './Commands/All.js';\n","let repository = process.env.CLIENT_REPOSITORY ?? 'https://github.com/wolfstar-project';\nlet invite = process.env.CLIENT_INVITE ?? null;\n\nexport function setRepository(url: string) {\n\trepository = url.startsWith('http') ? url : `https://github.com/wolfstar-project/${url}`;\n}\n\nexport function getRepository() {\n\treturn repository;\n}\n\nexport function setInvite(clientId: string, permissions = '0') {\n\tinvite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;\n}\n\nexport function getInvite() {\n\treturn invite;\n}\n","import * as Sentry from '@sentry/node';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nlet initialized = false;\nexport function isSentryInitialized() {\n\treturn initialized;\n}\n\nexport function initializeSentry(options: SentryOptions = {}) {\n\tif (!process.env.SENTRY_DSN) return;\n\n\tconst extractedIntegrations = options.integrations ?? [];\n\tconst root = options.root ? (typeof options.root === 'string' ? options.root : fileURLToPath(options.root)) : process.cwd();\n\tSentry.init({\n\t\tdsn: process.env.SENTRY_DSN,\n\t\t...options,\n\t\tintegrations: (integrations) => [\n\t\t\tSentry.consoleIntegration(),\n\t\t\tSentry.functionToStringIntegration(),\n\t\t\tSentry.linkedErrorsIntegration(),\n\t\t\tSentry.modulesIntegration(),\n\t\t\tSentry.onUncaughtExceptionIntegration(),\n\t\t\tSentry.onUnhandledRejectionIntegration(),\n\t\t\tSentry.rewriteFramesIntegration({ root }),\n\t\t\t...(typeof extractedIntegrations === 'function' ? extractedIntegrations(integrations) : extractedIntegrations)\n\t\t]\n\t});\n\n\tconst context = getAppContext();\n\tif (context) Sentry.setContext('app', context);\n\n\tinitialized = true;\n}\n\nfunction getAppContext() {\n\tif (process.env.npm_package_name && process.env.npm_package_version) {\n\t\treturn { app_name: process.env.npm_package_name, app_version: process.env.npm_package_version };\n\t}\n\n\ttry {\n\t\tconst path = process.env.npm_package_json ?? resolve('package.json');\n\t\tconst { name, version } = JSON.parse(readFileSync(path, 'utf8')) as { name: string; version: string };\n\t\treturn { app_name: name, app_version: version };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport interface SentryOptions extends Omit<Sentry.NodeOptions, 'dsn'> {\n\troot?: URL | string;\n}\n","import { envIsDefined, envParseString } from '@wolfstar/env-utilities';\nimport { container } from '@wolfstar/http-framework';\n\nexport async function registerCommands() {\n\tif (envIsDefined('REGISTRY_GUILD_ID')) {\n\t\tawait container.applicationCommandRegistry.pushAllCommandsInGuild(envParseString('REGISTRY_GUILD_ID'));\n\t} else {\n\t\tawait container.applicationCommandRegistry.pushGlobalCommands();\n\t}\n}\n\ndeclare module '@wolfstar/env-utilities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AAK;EACX,KAAK,QAAQ,IAAI;EACjB,GAAG;EACH,eAAe,iBAAiB;GAC/B,OAAO,mBAAmB;GAC1B,OAAO,4BAA4B;GACnC,OAAO,wBAAwB;GAC/B,OAAO,mBAAmB;GAC1B,OAAO,+BAA+B;GACtC,OAAO,gCAAgC;GACvC,OAAO,yBAAyB,EAAE,KAAK,CAAC;GACxC,GAAI,OAAO,0BAA0B,aAAa,sBAAsB,YAAY,IAAI;EACzF;CACD,CAAC;CAED,MAAM,UAAU,cAAc;CAC9B,IAAI,SAAS,OAAO,WAAW,OAAO,OAAO;CAE7C,cAAc;AACf;AAEA,SAAS,gBAAgB;CACxB,IAAI,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,qBAC/C,OAAO;EAAE,UAAU,QAAQ,IAAI;EAAkB,aAAa,QAAQ,IAAI;CAAoB;CAG/F,IAAI;EACH,MAAM,OAAO,QAAQ,IAAI,oBAAoB,QAAQ,cAAc;EACnE,MAAM,EAAE,MAAM,YAAY,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EAC/D,OAAO;GAAE,UAAU;GAAM,aAAa;EAAQ;CAC/C,QAAQ;EACP,OAAO;CACR;AACD;;;;AC7CA,eAAsB,mBAAmB;CACxC,IAAI,aAAa,mBAAmB,GACnC,MAAM,UAAU,2BAA2B,uBAAuB,eAAe,mBAAmB,CAAC;MAErG,MAAM,UAAU,2BAA2B,mBAAmB;AAEhE"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lib/utilities/register-command.ts"],"sourcesContent":["import { envIsDefined, envParseString } from '@wolfstar/env-utilities';\nimport { container } from '@wolfstar/http-framework';\n\nexport async function registerCommands() {\n\tif (envIsDefined('REGISTRY_GUILD_ID')) {\n\t\tawait container.applicationCommandRegistry.pushAllCommandsInGuild(envParseString('REGISTRY_GUILD_ID'));\n\t} else {\n\t\tawait container.applicationCommandRegistry.pushGlobalCommands();\n\t}\n}\n\ndeclare module '@wolfstar/env-utilities' {\n\tinterface Env {\n\t\tREGISTRY_GUILD_ID: string;\n\t}\n}\n"],"mappings":";;;;;;AAGA,eAAsB,mBAAmB;CACxC,IAAI,aAAa,mBAAmB,GACnC,MAAM,UAAU,2BAA2B,uBAAuB,eAAe,mBAAmB,CAAC;MAErG,MAAM,UAAU,2BAA2B,mBAAmB;AAEhE"}
@@ -1 +1,10 @@
1
- import "@wolfstar/http-framework";
1
+ import { Command, Listener } from "@wolfstar/http-framework";
2
+ //#region src/register.d.ts
3
+ /**
4
+ * Path pattern for this package's bundled locales, in the format
5
+ * `@wolfstar/plugin-i18next` expects for `i18n.backend.paths`.
6
+ */
7
+ declare const localesPath: string;
8
+ //#endregion
9
+ export { localesPath };
10
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","names":[],"sources":["../src/register.ts"],"mappings":";;;;;;cAUa"}
package/dist/register.js CHANGED
@@ -1,8 +1,229 @@
1
- import { load } from "@wolfstar/http-framework-i18n";
1
+ import { i as getRepository, n as isSentryInitialized, r as getInvite } from "./sentry-CKHik3nm.js";
2
+ import { captureException } from "@sentry/node";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { Client, Command, Listener, RegisterCommand, container } from "@wolfstar/http-framework";
6
+ import { EmbedBuilder, TimestampStyles, time } from "@discordjs/builders";
7
+ import { applyLocalizedBuilder, getSupportedUserLanguageName, getSupportedUserLanguageT } from "@wolfstar/plugin-i18next";
8
+ import { ButtonStyle, ComponentType, MessageFlags } from "discord-api-types/v10";
9
+ import { cpus, uptime } from "node:os";
2
10
 
11
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/decorate.js
12
+ function __decorate(decorators, target, key, desc) {
13
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
15
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ }
18
+
19
+ //#endregion
20
+ //#region src/commands/info.ts
21
+ var _SharedCommand;
22
+ let SharedCommand = _SharedCommand = class SharedCommand extends Command {
23
+ chatInputRun(interaction) {
24
+ const t = getSupportedUserLanguageT(interaction);
25
+ const lng = getSupportedUserLanguageName(interaction);
26
+ const embed = new EmbedBuilder().setDescription(t("commands/shared:infoEmbedDescription")).addFields(this.getUptimeStatistics(t), this.getServerUsageStatistics(t, lng));
27
+ const components = this.getComponents(t);
28
+ return interaction.reply({
29
+ embeds: [embed.toJSON()],
30
+ components,
31
+ flags: MessageFlags.Ephemeral
32
+ });
33
+ }
34
+ getUptimeStatistics(t) {
35
+ const nowSeconds = Math.round(Date.now() / 1e3);
36
+ return {
37
+ name: t("commands/shared:infoFieldUptimeTitle"),
38
+ value: t("commands/shared:infoFieldUptimeValue", {
39
+ host: time(Math.round(nowSeconds - uptime()), TimestampStyles.RelativeTime),
40
+ client: time(Math.round(nowSeconds - process.uptime()), TimestampStyles.RelativeTime)
41
+ })
42
+ };
43
+ }
44
+ getServerUsageStatistics(t, lng) {
45
+ const usage = process.memoryUsage();
46
+ return {
47
+ name: t("commands/shared:infoFieldServerUsageTitle"),
48
+ value: t("commands/shared:infoFieldServerUsageValue", {
49
+ cpu: cpus().map(_SharedCommand.formatCpuInfo.bind(null)).join(" | "),
50
+ heapUsed: (usage.heapUsed / 1048576).toLocaleString(lng, { maximumFractionDigits: 2 }),
51
+ heapTotal: (usage.heapTotal / 1048576).toLocaleString(lng, { maximumFractionDigits: 2 })
52
+ })
53
+ };
54
+ }
55
+ getComponents(t) {
56
+ const url = getInvite();
57
+ const support = this.getSupportComponent(t);
58
+ const github = this.getGitHubComponent(t);
59
+ const donate = this.getDonateComponent(t);
60
+ return url ? [this.getActionRow(support, this.getInviteComponent(t, url)), this.getActionRow(github, donate)] : [this.getActionRow(support, github, donate)];
61
+ }
62
+ getActionRow(...components) {
63
+ return {
64
+ type: ComponentType.ActionRow,
65
+ components
66
+ };
67
+ }
68
+ getSupportComponent(t) {
69
+ return {
70
+ type: ComponentType.Button,
71
+ style: ButtonStyle.Link,
72
+ label: t("commands/shared:infoButtonSupport"),
73
+ emoji: { name: "🆘" },
74
+ url: "https://discord.gg/6gakFR2"
75
+ };
76
+ }
77
+ getInviteComponent(t, url) {
78
+ return {
79
+ type: ComponentType.Button,
80
+ style: ButtonStyle.Link,
81
+ label: t("commands/shared:infoButtonInvite"),
82
+ emoji: { name: "🎉" },
83
+ url
84
+ };
85
+ }
86
+ getGitHubComponent(t) {
87
+ return {
88
+ type: ComponentType.Button,
89
+ style: ButtonStyle.Link,
90
+ label: t("commands/shared:infoButtonGitHub"),
91
+ emoji: {
92
+ id: "950888087188283422",
93
+ name: "github2"
94
+ },
95
+ url: getRepository()
96
+ };
97
+ }
98
+ getDonateComponent(t) {
99
+ return {
100
+ type: ComponentType.Button,
101
+ style: ButtonStyle.Link,
102
+ label: t("commands/shared:infoButtonDonate"),
103
+ emoji: { name: "🧡" },
104
+ url: "https://donate.wolfstar.rocks"
105
+ };
106
+ }
107
+ static formatCpuInfo({ times }) {
108
+ return `${Math.round((times.user + times.nice + times.sys + times.irq) / times.idle * 1e4) / 100}%`;
109
+ }
110
+ };
111
+ SharedCommand = _SharedCommand = __decorate([RegisterCommand((builder) => applyLocalizedBuilder(builder, "commands/shared:info"))], SharedCommand);
112
+ container.stores.loadPiece({
113
+ name: "info",
114
+ piece: SharedCommand,
115
+ store: "commands"
116
+ });
117
+
118
+ //#endregion
119
+ //#region src/listeners/SharedAutocompleteError.ts
120
+ var SharedListener$3 = class extends Listener {
121
+ constructor(context, options) {
122
+ super(context, {
123
+ ...options,
124
+ event: "autocompleteError",
125
+ enabled: isSentryInitialized()
126
+ });
127
+ }
128
+ run(error, context) {
129
+ captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name).setExtra("command", context.command.name));
130
+ }
131
+ };
132
+ container.stores.loadPiece({
133
+ name: "SharedAutocompleteError",
134
+ piece: SharedListener$3,
135
+ store: "listeners"
136
+ });
137
+
138
+ //#endregion
139
+ //#region src/listeners/SharedCommandError.ts
140
+ var SharedListener$2 = class extends Listener {
141
+ constructor(context, options) {
142
+ super(context, {
143
+ ...options,
144
+ event: "commandError",
145
+ enabled: isSentryInitialized()
146
+ });
147
+ }
148
+ run(error, context) {
149
+ captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name).setExtra("command", context.command.name));
150
+ }
151
+ };
152
+ container.stores.loadPiece({
153
+ name: "SharedCommandError",
154
+ piece: SharedListener$2,
155
+ store: "listeners"
156
+ });
157
+
158
+ //#endregion
159
+ //#region src/listeners/SharedError.ts
160
+ var SharedListener$1 = class extends Listener {
161
+ constructor(context, options) {
162
+ super(context, {
163
+ ...options,
164
+ event: "error",
165
+ enabled: isSentryInitialized()
166
+ });
167
+ }
168
+ run(error) {
169
+ captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name));
170
+ }
171
+ };
172
+ container.stores.loadPiece({
173
+ name: "SharedError",
174
+ piece: SharedListener$1,
175
+ store: "listeners"
176
+ });
177
+
178
+ //#endregion
179
+ //#region src/listeners/SharedInteractionHandlerError.ts
180
+ var SharedListener = class extends Listener {
181
+ constructor(context, options) {
182
+ super(context, {
183
+ ...options,
184
+ event: "interactionHandlerError",
185
+ enabled: isSentryInitialized()
186
+ });
187
+ }
188
+ run(error, context) {
189
+ captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name).setExtra("handler", context.handler.name));
190
+ }
191
+ };
192
+ container.stores.loadPiece({
193
+ name: "SharedInteractionHandlerError",
194
+ piece: SharedListener,
195
+ store: "listeners"
196
+ });
197
+
198
+ //#endregion
3
199
  //#region src/register.ts
4
- await load(new URL("../src/locales", import.meta.url));
200
+ /**
201
+ * Path pattern for this package's bundled locales, in the format
202
+ * `@wolfstar/plugin-i18next` expects for `i18n.backend.paths`.
203
+ */
204
+ const localesPath = join(fileURLToPath(new URL("../src/locales", import.meta.url)), "{{lng}}", "{{ns}}.json");
205
+ /**
206
+ * `@wolfstar/plugin-i18next` reads `Client`'s `i18n` option exactly once, in its own
207
+ * `preGenericsInitialization` hook, and has no API to register extra locale directories
208
+ * afterwards. Hooks run in registration order, so registering this one *before* importing
209
+ * the plugin's `register` entrypoint below guarantees it runs first and can splice this
210
+ * package's locales into `options.i18n.backend.paths` before the plugin builds its
211
+ * `InternationalizationHandler` — consumers that only import this module keep working
212
+ * without having to list `localesPath` in their own `Client` config.
213
+ */
214
+ Client.plugins.registerPreGenericsInitializationHook((options) => {
215
+ const { i18n } = options;
216
+ if (!i18n) return;
217
+ options.i18n = {
218
+ ...i18n,
219
+ backend: {
220
+ ...i18n.backend,
221
+ paths: [...i18n.backend?.paths ?? [], localesPath]
222
+ }
223
+ };
224
+ }, "@wolfstar/shared-http-pieces");
225
+ await import("@wolfstar/plugin-i18next/register");
5
226
 
6
227
  //#endregion
7
- export { };
228
+ export { localesPath };
8
229
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","names":[],"sources":["../src/register.ts"],"sourcesContent":["import { load } from '@wolfstar/http-framework-i18n';\nimport './commands/_load.js';\nimport './listeners/_load.js';\n\nawait load(new URL('../src/locales', import.meta.url));\n"],"mappings":";;;AAIA,MAAM,KAAK,IAAI,IAAI,kBAAkB,YAAY,GAAG,CAAC"}
1
+ {"version":3,"file":"register.js","names":["SharedListener","SharedListener","SharedListener"],"sources":["../src/commands/info.ts","../src/listeners/SharedAutocompleteError.ts","../src/listeners/SharedCommandError.ts","../src/listeners/SharedError.ts","../src/listeners/SharedInteractionHandlerError.ts","../src/register.ts"],"sourcesContent":["import { EmbedBuilder, time, TimestampStyles } from '@discordjs/builders';\nimport { Command, container, RegisterCommand } from '@wolfstar/http-framework';\nimport { applyLocalizedBuilder, getSupportedUserLanguageName, getSupportedUserLanguageT, type TFunction } from '@wolfstar/plugin-i18next';\nimport {\n\tButtonStyle,\n\tComponentType,\n\tMessageFlags,\n\ttype APIActionRowComponent,\n\ttype APIComponentInMessageActionRow,\n\ttype APIEmbedField\n} from 'discord-api-types/v10';\nimport { cpus, uptime, type CpuInfo } from 'node:os';\nimport { getInvite, getRepository } from '../lib/information.js';\n\ntype TranslateFn = TFunction;\n\n@RegisterCommand((builder) => applyLocalizedBuilder(builder, 'commands/shared:info'))\nexport class SharedCommand extends Command {\n\tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n\t\tconst t = getSupportedUserLanguageT(interaction) as TranslateFn;\n\t\tconst lng = getSupportedUserLanguageName(interaction);\n\t\tconst embed = new EmbedBuilder()\n\t\t\t.setDescription(t('commands/shared:infoEmbedDescription'))\n\t\t\t.addFields(this.getUptimeStatistics(t), this.getServerUsageStatistics(t, lng));\n\t\tconst components = this.getComponents(t);\n\n\t\treturn interaction.reply({ embeds: [embed.toJSON()], components, flags: MessageFlags.Ephemeral });\n\t}\n\n\tprivate getUptimeStatistics(t: TranslateFn): APIEmbedField {\n\t\tconst now = Date.now();\n\t\tconst nowSeconds = Math.round(now / 1000);\n\n\t\treturn {\n\t\t\tname: t('commands/shared:infoFieldUptimeTitle'),\n\t\t\tvalue: t('commands/shared:infoFieldUptimeValue', {\n\t\t\t\thost: time(Math.round(nowSeconds - uptime()), TimestampStyles.RelativeTime),\n\t\t\t\tclient: time(Math.round(nowSeconds - process.uptime()), TimestampStyles.RelativeTime)\n\t\t\t})\n\t\t};\n\t}\n\n\tprivate getServerUsageStatistics(t: TranslateFn, lng: string): APIEmbedField {\n\t\tconst usage = process.memoryUsage();\n\n\t\treturn {\n\t\t\tname: t('commands/shared:infoFieldServerUsageTitle'),\n\t\t\tvalue: t('commands/shared:infoFieldServerUsageValue', {\n\t\t\t\tcpu: cpus().map(SharedCommand.formatCpuInfo.bind(null)).join(' | '),\n\t\t\t\theapUsed: (usage.heapUsed / 1048576).toLocaleString(lng, { maximumFractionDigits: 2 }),\n\t\t\t\theapTotal: (usage.heapTotal / 1048576).toLocaleString(lng, { maximumFractionDigits: 2 })\n\t\t\t})\n\t\t};\n\t}\n\n\tprivate getComponents(t: TranslateFn) {\n\t\tconst url = getInvite();\n\t\tconst support = this.getSupportComponent(t);\n\t\tconst github = this.getGitHubComponent(t);\n\t\tconst donate = this.getDonateComponent(t);\n\t\tconst data = url\n\t\t\t? [this.getActionRow(support, this.getInviteComponent(t, url)), this.getActionRow(github, donate)]\n\t\t\t: [this.getActionRow(support, github, donate)];\n\n\t\treturn data;\n\t}\n\n\tprivate getActionRow(...components: APIComponentInMessageActionRow[]): APIActionRowComponent<APIComponentInMessageActionRow> {\n\t\treturn { type: ComponentType.ActionRow, components };\n\t}\n\n\tprivate getSupportComponent(t: TranslateFn): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t('commands/shared:infoButtonSupport'),\n\t\t\temoji: { name: '🆘' },\n\t\t\turl: 'https://discord.gg/6gakFR2'\n\t\t};\n\t}\n\n\tprivate getInviteComponent(t: TranslateFn, url: string): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t('commands/shared:infoButtonInvite'),\n\t\t\temoji: { name: '🎉' },\n\t\t\turl\n\t\t};\n\t}\n\n\tprivate getGitHubComponent(t: TranslateFn): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t('commands/shared:infoButtonGitHub'),\n\t\t\temoji: { id: '950888087188283422', name: 'github2' },\n\t\t\turl: getRepository()\n\t\t};\n\t}\n\n\tprivate getDonateComponent(t: TranslateFn): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t('commands/shared:infoButtonDonate'),\n\t\t\temoji: { name: '🧡' },\n\t\t\turl: 'https://donate.wolfstar.rocks'\n\t\t};\n\t}\n\n\tprivate static formatCpuInfo({ times }: CpuInfo) {\n\t\treturn `${Math.round(((times.user + times.nice + times.sys + times.irq) / times.idle) * 10000) / 100}%`;\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'info', piece: SharedCommand as any, store: 'commands' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEventAutocompleteContext, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'autocompleteError' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown, context: ClientEventAutocompleteContext) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name).setExtra('command', context.command.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedAutocompleteError', piece: SharedListener as any, store: 'listeners' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEventCommandContext, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'commandError' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown, context: ClientEventCommandContext) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name).setExtra('command', context.command.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedCommandError', piece: SharedListener as any, store: 'listeners' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'error' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedError', piece: SharedListener as any, store: 'listeners' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEventInteractionHandlerContext, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'interactionHandlerError' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown, context: ClientEventInteractionHandlerContext) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name).setExtra('handler', context.handler.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedInteractionHandlerError', piece: SharedListener as any, store: 'listeners' });\n","import { Client } from '@wolfstar/http-framework';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport './commands/_load.js';\nimport './listeners/_load.js';\n\n/**\n * Path pattern for this package's bundled locales, in the format\n * `@wolfstar/plugin-i18next` expects for `i18n.backend.paths`.\n */\nexport const localesPath = join(fileURLToPath(new URL('../src/locales', import.meta.url)), '{{lng}}', '{{ns}}.json');\n\n/**\n * `@wolfstar/plugin-i18next` reads `Client`'s `i18n` option exactly once, in its own\n * `preGenericsInitialization` hook, and has no API to register extra locale directories\n * afterwards. Hooks run in registration order, so registering this one *before* importing\n * the plugin's `register` entrypoint below guarantees it runs first and can splice this\n * package's locales into `options.i18n.backend.paths` before the plugin builds its\n * `InternationalizationHandler` — consumers that only import this module keep working\n * without having to list `localesPath` in their own `Client` config.\n */\nClient.plugins.registerPreGenericsInitializationHook((options) => {\n\tconst { i18n } = options;\n\tif (!i18n) return;\n\toptions.i18n = { ...i18n, backend: { ...i18n.backend, paths: [...(i18n.backend?.paths ?? []), localesPath] } };\n}, '@wolfstar/shared-http-pieces');\n\n// A dynamic import, not a static one: static imports are hoisted above the hook\n// registration above, which would let the plugin's own hook register — and run — first.\nawait import('@wolfstar/plugin-i18next/register');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBO,IAAM,iCAAN,MAAM,sBAAsB,QAAQ;CAC1C,AAAgB,aAAa,aAA2C;EACvE,MAAM,IAAI,0BAA0B,WAAW;EAC/C,MAAM,MAAM,6BAA6B,WAAW;EACpD,MAAM,QAAQ,IAAI,aAAa,CAAC,CAC9B,eAAe,EAAE,sCAAsC,CAAC,CAAC,CACzD,UAAU,KAAK,oBAAoB,CAAC,GAAG,KAAK,yBAAyB,GAAG,GAAG,CAAC;EAC9E,MAAM,aAAa,KAAK,cAAc,CAAC;EAEvC,OAAO,YAAY,MAAM;GAAE,QAAQ,CAAC,MAAM,OAAO,CAAC;GAAG;GAAY,OAAO,aAAa;EAAU,CAAC;CACjG;CAEA,AAAQ,oBAAoB,GAA+B;EAE1D,MAAM,aAAa,KAAK,MADZ,KAAK,IACe,IAAI,GAAI;EAExC,OAAO;GACN,MAAM,EAAE,sCAAsC;GAC9C,OAAO,EAAE,wCAAwC;IAChD,MAAM,KAAK,KAAK,MAAM,aAAa,OAAO,CAAC,GAAG,gBAAgB,YAAY;IAC1E,QAAQ,KAAK,KAAK,MAAM,aAAa,QAAQ,OAAO,CAAC,GAAG,gBAAgB,YAAY;GACrF,CAAC;EACF;CACD;CAEA,AAAQ,yBAAyB,GAAgB,KAA4B;EAC5E,MAAM,QAAQ,QAAQ,YAAY;EAElC,OAAO;GACN,MAAM,EAAE,2CAA2C;GACnD,OAAO,EAAE,6CAA6C;IACrD,KAAK,KAAK,CAAC,CAAC,mBAAkB,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK;IAClE,WAAW,MAAM,WAAW,QAAO,CAAE,eAAe,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACrF,Y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M,SAAS,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK,IAAI,CAAC;CACtF;AACD;AAEK,UAAU,OAAO,UAAU;CAAE,MAAM;CAAe,OAAOA;CAAuB,OAAO;AAAY,CAAC;;;;ACVzG,IAAa,iBAAb,cAAoC,SAAS;CAC5C,AAAO,YAAY,SAAiC,SAA2B;EAC9E,MAAM,SAAS;GAAE,GAAG;GAAS,OAAO;GAAwD,SAAS,oBAAoB;EAAE,CAAC;CAC7H;CAEA,AAAO,IAAI,OAAgB,SAA+C;EACzE,iBAAiB,QAAQ,UAAU,MAAM,SAAS,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,SAAS,WAAW,QAAQ,QAAQ,IAAI,CAAC;CAChI;AACD;AAEK,UAAU,OAAO,UAAU;CAAE,MAAM;CAAiC,OAAO;CAAuB,OAAO;AAAY,CAAC;;;;;;;;ACJ3H,MAAa,cAAc,KAAK,cAAc,IAAI,IAAI,kBAAkB,YAAY,GAAG,CAAC,GAAG,WAAW,aAAa;;;;;;;;;;AAWnH,OAAO,QAAQ,uCAAuC,YAAY;CACjE,MAAM,EAAE,SAAS;CACjB,IAAI,CAAC,MAAM;CACX,QAAQ,OAAO;EAAE,GAAG;EAAM,SAAS;GAAE,GAAG,KAAK;GAAS,OAAO,CAAC,GAAI,KAAK,SAAS,SAAS,CAAC,GAAI,WAAW;EAAE;CAAE;AAC9G,GAAG,8BAA8B;AAIjC,MAAM,OAAO"}
@@ -0,0 +1,69 @@
1
+ import * as Sentry from "@sentry/node";
2
+ import { readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ //#region src/lib/information.ts
7
+ let repository = process.env.CLIENT_REPOSITORY ?? "https://github.com/wolfstar-project";
8
+ let invite = process.env.CLIENT_INVITE ?? null;
9
+ function setRepository(url) {
10
+ repository = url.startsWith("http") ? url : `https://github.com/wolfstar-project/${url}`;
11
+ }
12
+ function getRepository() {
13
+ return repository;
14
+ }
15
+ function setInvite(clientId, permissions = "0") {
16
+ invite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;
17
+ }
18
+ function getInvite() {
19
+ return invite;
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/lib/sentry.ts
24
+ let initialized = false;
25
+ function isSentryInitialized() {
26
+ return initialized;
27
+ }
28
+ function initializeSentry(options = {}) {
29
+ if (!process.env.SENTRY_DSN) return;
30
+ const extractedIntegrations = options.integrations ?? [];
31
+ const root = options.root ? typeof options.root === "string" ? options.root : fileURLToPath(options.root) : process.cwd();
32
+ Sentry.init({
33
+ dsn: process.env.SENTRY_DSN,
34
+ ...options,
35
+ integrations: (integrations) => [
36
+ Sentry.consoleIntegration(),
37
+ Sentry.functionToStringIntegration(),
38
+ Sentry.linkedErrorsIntegration(),
39
+ Sentry.modulesIntegration(),
40
+ Sentry.onUncaughtExceptionIntegration(),
41
+ Sentry.onUnhandledRejectionIntegration(),
42
+ Sentry.rewriteFramesIntegration({ root }),
43
+ ...typeof extractedIntegrations === "function" ? extractedIntegrations(integrations) : extractedIntegrations
44
+ ]
45
+ });
46
+ const context = getAppContext();
47
+ if (context) Sentry.setContext("app", context);
48
+ initialized = true;
49
+ }
50
+ function getAppContext() {
51
+ if (process.env.npm_package_name && process.env.npm_package_version) return {
52
+ app_name: process.env.npm_package_name,
53
+ app_version: process.env.npm_package_version
54
+ };
55
+ try {
56
+ const path = process.env.npm_package_json ?? resolve("package.json");
57
+ const { name, version } = JSON.parse(readFileSync(path, "utf8"));
58
+ return {
59
+ app_name: name,
60
+ app_version: version
61
+ };
62
+ } catch {
63
+ return null;
64
+ }
65
+ }
66
+
67
+ //#endregion
68
+ export { setInvite as a, getRepository as i, isSentryInitialized as n, setRepository as o, getInvite as r, initializeSentry as t };
69
+ //# sourceMappingURL=sentry-CKHik3nm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry-CKHik3nm.js","names":[],"sources":["../src/lib/information.ts","../src/lib/sentry.ts"],"sourcesContent":["let repository = process.env.CLIENT_REPOSITORY ?? 'https://github.com/wolfstar-project';\nlet invite = process.env.CLIENT_INVITE ?? null;\n\nexport function setRepository(url: string) {\n\trepository = url.startsWith('http') ? url : `https://github.com/wolfstar-project/${url}`;\n}\n\nexport function getRepository() {\n\treturn repository;\n}\n\nexport function setInvite(clientId: string, permissions = '0') {\n\tinvite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;\n}\n\nexport function getInvite() {\n\treturn invite;\n}\n","import * as Sentry from '@sentry/node';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nlet initialized = false;\nexport function isSentryInitialized() {\n\treturn initialized;\n}\n\nexport function initializeSentry(options: SentryOptions = {}) {\n\tif (!process.env.SENTRY_DSN) return;\n\n\tconst extractedIntegrations = options.integrations ?? [];\n\tconst root = options.root ? (typeof options.root === 'string' ? options.root : fileURLToPath(options.root)) : process.cwd();\n\tSentry.init({\n\t\tdsn: process.env.SENTRY_DSN,\n\t\t...options,\n\t\tintegrations: (integrations) => [\n\t\t\tSentry.consoleIntegration(),\n\t\t\tSentry.functionToStringIntegration(),\n\t\t\tSentry.linkedErrorsIntegration(),\n\t\t\tSentry.modulesIntegration(),\n\t\t\tSentry.onUncaughtExceptionIntegration(),\n\t\t\tSentry.onUnhandledRejectionIntegration(),\n\t\t\tSentry.rewriteFramesIntegration({ root }),\n\t\t\t...(typeof extractedIntegrations === 'function' ? extractedIntegrations(integrations) : extractedIntegrations)\n\t\t]\n\t});\n\n\tconst context = getAppContext();\n\tif (context) Sentry.setContext('app', context);\n\n\tinitialized = true;\n}\n\nfunction getAppContext() {\n\tif (process.env.npm_package_name && process.env.npm_package_version) {\n\t\treturn { app_name: process.env.npm_package_name, app_version: process.env.npm_package_version };\n\t}\n\n\ttry {\n\t\tconst path = process.env.npm_package_json ?? resolve('package.json');\n\t\tconst { name, version } = JSON.parse(readFileSync(path, 'utf8')) as { name: string; version: string };\n\t\treturn { app_name: name, app_version: version };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport interface SentryOptions extends Omit<Sentry.NodeOptions, 'dsn'> {\n\troot?: URL | string;\n}\n"],"mappings":";;;;;;AAAA,IAAI,aAAa,QAAQ,IAAI,qBAAqB;AAClD,IAAI,SAAS,QAAQ,IAAI,iBAAiB;AAE1C,SAAgB,cAAc,KAAa;CAC1C,aAAa,IAAI,WAAW,MAAM,IAAI,MAAM,uCAAuC;AACpF;AAEA,SAAgB,gBAAgB;CAC/B,OAAO;AACR;AAEA,SAAgB,UAAU,UAAkB,cAAc,KAAK;CAC9D,SAAS,kDAAkD,SAAS,eAAe,YAAY;AAChG;AAEA,SAAgB,YAAY;CAC3B,OAAO;AACR;;;;ACZA,IAAI,cAAc;AAClB,SAAgB,sBAAsB;CACrC,OAAO;AACR;AAEA,SAAgB,iBAAiB,UAAyB,CAAC,GAAG;CAC7D,IAAI,CAAC,QAAQ,IAAI,YAAY;CAE7B,MAAM,wBAAwB,QAAQ,gBAAgB,CAAC;CACvD,MAAM,OAAO,QAAQ,OAAQ,OAAO,QAAQ,SAAS,WAAW,QAAQ,OAAO,cAAc,QAAQ,IAAI,IAAK,QAAQ,IAAI;CAC1H,OAAO,KAAK;EACX,KAAK,QAAQ,IAAI;EACjB,GAAG;EACH,eAAe,iBAAiB;GAC/B,OAAO,mBAAmB;GAC1B,OAAO,4BAA4B;GACnC,OAAO,wBAAwB;GAC/B,OAAO,mBAAmB;GAC1B,OAAO,+BAA+B;GACtC,OAAO,gCAAgC;GACvC,OAAO,yBAAyB,EAAE,KAAK,CAAC;GACxC,GAAI,OAAO,0BAA0B,aAAa,sBAAsB,YAAY,IAAI;EACzF;CACD,CAAC;CAED,MAAM,UAAU,cAAc;CAC9B,IAAI,SAAS,OAAO,WAAW,OAAO,OAAO;CAE7C,cAAc;AACf;AAEA,SAAS,gBAAgB;CACxB,IAAI,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,qBAC/C,OAAO;EAAE,UAAU,QAAQ,IAAI;EAAkB,aAAa,QAAQ,IAAI;CAAoB;CAG/F,IAAI;EACH,MAAM,OAAO,QAAQ,IAAI,oBAAoB,QAAQ,cAAc;EACnE,MAAM,EAAE,MAAM,YAAY,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EAC/D,OAAO;GAAE,UAAU;GAAM,aAAa;EAAQ;CAC/C,QAAQ;EACP,OAAO;CACR;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/shared-http-pieces",
3
- "version": "1.2.9",
3
+ "version": "2.0.0-next-20260830180323",
4
4
  "description": "The common pieces for Star Network's HTTP-only bots",
5
5
  "keywords": [
6
6
  "api",
@@ -50,14 +50,16 @@
50
50
  "@discordjs/builders": "^1.14.1",
51
51
  "@discordjs/collection": "^2.1.1",
52
52
  "@sentry/node": "^10.69.0",
53
+ "@wolfstar/plugin-i18next": "1.0.1-next-20260830111821",
53
54
  "discord-api-types": "^0.38.8",
55
+ "i18next": "^25.10.10",
54
56
  "tslib": "^2.8.1",
55
- "@wolfstar/http-framework-i18n": "^1.2.5",
56
- "@wolfstar/env-utilities": "^2.0.7",
57
- "@wolfstar/http-framework": "^3.1.4"
57
+ "@wolfstar/http-framework": "^3.2.0",
58
+ "@wolfstar/env-utilities": "^2.0.7"
58
59
  },
59
60
  "devDependencies": {
60
- "typescript": "~5.8.3"
61
+ "typescript": "~5.8.3",
62
+ "@wolfstar/i18next-type-generator": "^3.1.0-next-20260830180323"
61
63
  },
62
64
  "engines": {
63
65
  "node": ">=20"
@@ -66,6 +68,7 @@
66
68
  "build": "tsdown --config-loader unrun",
67
69
  "watch": "tsdown --config-loader unrun --watch",
68
70
  "typecheck": "tsc -p ../../tsconfig.json",
69
- "lint": "oxlint src --fix"
71
+ "lint": "oxlint src --fix",
72
+ "generate:i18n": "i18next-type-generator ./src/locales/en-US/ ./src/@types/i18next.d.ts"
70
73
  }
71
74
  }
@@ -1,18 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
4
- let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (!no_symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
14
- return target;
15
- };
16
-
17
- //#endregion
18
- export { __exportAll as t };