@seedcord/core 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/CustomId-BJF6mbJs.d.mts +317 -0
- package/dist/CustomId-CqiuEllp.cjs +759 -0
- package/dist/CustomId-CqiuEllp.cjs.map +1 -0
- package/dist/CustomId-XgZ2KDgT.mjs +712 -0
- package/dist/CustomId-XgZ2KDgT.mjs.map +1 -0
- package/dist/index.cjs +105 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +217 -1
- package/dist/index.mjs +100 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.cjs +30 -0
- package/dist/internal.index.cjs.map +1 -0
- package/dist/internal.index.d.mts +83 -1
- package/dist/internal.index.mjs +23 -1
- package/dist/internal.index.mjs.map +1 -0
- package/package.json +69 -61
|
@@ -1 +1,83 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as CustomIdField, i as prefixOf, n as CustomId, o as DecodedParams, r as decodeFor, s as BuilderComponent, t as AnyCustomId } from "./CustomId-BJF6mbJs.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/colors.d.ts
|
|
4
|
+
declare const Colors: {
|
|
5
|
+
readonly Aqua: 1752220;
|
|
6
|
+
readonly Blue: 3447003;
|
|
7
|
+
readonly Blurple: 5793266;
|
|
8
|
+
readonly DarkAqua: 1146986;
|
|
9
|
+
readonly DarkBlue: 2123412;
|
|
10
|
+
readonly DarkButNotBlack: 2895667;
|
|
11
|
+
readonly DarkerGrey: 8359053;
|
|
12
|
+
readonly DarkGold: 12745742;
|
|
13
|
+
readonly DarkGreen: 2067276;
|
|
14
|
+
readonly DarkGrey: 9936031;
|
|
15
|
+
readonly DarkNavy: 2899536;
|
|
16
|
+
readonly DarkOrange: 11027200;
|
|
17
|
+
readonly DarkPurple: 7419530;
|
|
18
|
+
readonly DarkRed: 10038562;
|
|
19
|
+
readonly DarkVividPink: 11342935;
|
|
20
|
+
readonly Default: 0;
|
|
21
|
+
readonly Fuchsia: 15418782;
|
|
22
|
+
readonly Gold: 15844367;
|
|
23
|
+
readonly Green: 5763719;
|
|
24
|
+
readonly Grey: 9807270;
|
|
25
|
+
readonly Greyple: 10070709;
|
|
26
|
+
readonly LightGrey: 12370112;
|
|
27
|
+
readonly LuminousVividPink: 15277667;
|
|
28
|
+
readonly Navy: 3426654;
|
|
29
|
+
readonly NotQuiteBlack: 2303786;
|
|
30
|
+
readonly Orange: 15105570;
|
|
31
|
+
readonly Purple: 10181046;
|
|
32
|
+
readonly Red: 15548997;
|
|
33
|
+
readonly White: 16777215;
|
|
34
|
+
readonly Yellow: 16705372;
|
|
35
|
+
};
|
|
36
|
+
/** A discord.js color name, or `'Random'`. */
|
|
37
|
+
type ColorName = keyof typeof Colors | 'Random';
|
|
38
|
+
/** Any color the bot color accepts: a name, a raw integer, a `#hex` string, or an rgb tuple. */
|
|
39
|
+
type BotColor = ColorName | number | `#${string}` | readonly [number, number, number];
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/components/botColorHolder.d.ts
|
|
42
|
+
/** @internal */
|
|
43
|
+
declare function setBotColor(color: BotColor | undefined): void;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/stops/NoticeCard.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Built fresh inside a {@link Notice}'s `render` to back its ComponentsV2 reply. The title renders as
|
|
48
|
+
* an h3 line with the description on the next line.
|
|
49
|
+
*/
|
|
50
|
+
declare class NoticeCard extends BuilderComponent<'container'> {
|
|
51
|
+
constructor(description: string, title?: string);
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/customId/routing.d.ts
|
|
55
|
+
/**
|
|
56
|
+
* The route decorators store a handler's customId definitions here so the component base can decode
|
|
57
|
+
* against them at runtime.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
declare const ComponentDefsKey: unique symbol;
|
|
62
|
+
/**
|
|
63
|
+
* The phantom a component handler base carries. A route decorator constrains its argument to this, so
|
|
64
|
+
* passing different definitions to the decorator and the handler's generic is a compile error. Never set at runtime.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
interface HasComponentDefs<Defs extends readonly AnyCustomId[]> {
|
|
69
|
+
readonly __componentDefs?: Defs;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/pagination/cursor.d.ts
|
|
73
|
+
declare const PAGE_MAX = 1000000;
|
|
74
|
+
/** Page cursor for a paginator. */
|
|
75
|
+
type PageCursor<Prefix extends string> = CustomId<Prefix, {
|
|
76
|
+
page: CustomIdField<number>;
|
|
77
|
+
slot: CustomIdField<number>;
|
|
78
|
+
}>;
|
|
79
|
+
/** Build the page cursor for a paginator. */
|
|
80
|
+
declare function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix>;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { type AnyCustomId, ComponentDefsKey, type DecodedParams, type HasComponentDefs, NoticeCard, PAGE_MAX, type PageCursor, decodeFor, pageCursor, prefixOf, setBotColor };
|
|
83
|
+
//# sourceMappingURL=internal.index.d.mts.map
|
package/dist/internal.index.mjs
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { c as setBotColor, i as NoticeCard, n as decodeFor, r as prefixOf, t as CustomId } from "./CustomId-XgZ2KDgT.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/customId/routing.ts
|
|
4
|
+
/**
|
|
5
|
+
* The route decorators store a handler's customId definitions here so the component base can decode
|
|
6
|
+
* against them at runtime.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const ComponentDefsKey = Symbol("seedcord:customId:componentDefs");
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/pagination/cursor.ts
|
|
14
|
+
const PAGE_MAX = 1e6;
|
|
15
|
+
const SLOT_MAX = 4;
|
|
16
|
+
/** Build the page cursor for a paginator. */
|
|
17
|
+
function pageCursor(prefix) {
|
|
18
|
+
return new CustomId(prefix).int("page", 0, PAGE_MAX).int("slot", 0, SLOT_MAX);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ComponentDefsKey, NoticeCard, PAGE_MAX, decodeFor, pageCursor, prefixOf, setBotColor };
|
|
23
|
+
//# sourceMappingURL=internal.index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.index.mjs","names":[],"sources":["../src/customId/routing.ts","../src/pagination/cursor.ts"],"sourcesContent":["import type { AnyCustomId } from './CustomId';\n\n/**\n * The route decorators store a handler's customId definitions here so the component base can decode\n * against them at runtime.\n *\n * @internal\n */\nexport const ComponentDefsKey = Symbol('seedcord:customId:componentDefs');\n\n/**\n * The phantom a component handler base carries. A route decorator constrains its argument to this, so\n * passing different definitions to the decorator and the handler's generic is a compile error. Never set at runtime.\n *\n * @internal\n */\nexport interface HasComponentDefs<Defs extends readonly AnyCustomId[]> {\n readonly __componentDefs?: Defs;\n}\n","import { CustomId } from '@customId/CustomId';\n\nimport type { CustomIdField } from '@customId/Field';\n\n// Included in the layout hash so it is fixed per prefix. Reducing it marks every active button as StaleCustomId.\n// @internal\nexport const PAGE_MAX = 1_000_000;\n\n// Discord rejects a message with duplicate custom_ids, and two controls can target the same page (first and\n// prev both hit 0), so each control uses a distinct slot.\n// @internal\nconst SLOT_MAX = 4;\n\n/** Page cursor for a paginator. */\nexport type PageCursor<Prefix extends string> = CustomId<\n Prefix,\n { page: CustomIdField<number>; slot: CustomIdField<number> }\n>;\n\n/** Build the page cursor for a paginator. */\nexport function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix> {\n return new CustomId(prefix).int('page', 0, PAGE_MAX).int('slot', 0, SLOT_MAX);\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,mBAAmB,OAAO,iCAAiC;;;;ACFxE,MAAa,WAAW;AAKxB,MAAM,WAAW;;AASjB,SAAgB,WAAkC,QAAoC;CAClF,OAAO,IAAI,SAAS,MAAM,CAAC,CAAC,IAAI,QAAQ,GAAG,QAAQ,CAAC,CAAC,IAAI,QAAQ,GAAG,QAAQ;AAChF"}
|
package/package.json
CHANGED
|
@@ -1,64 +1,72 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"name": "@seedcord/core",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0-next.1",
|
|
5
|
+
"description": "Transport-agnostic core for Seedcord bots",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/seedcord/seedcord.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"default": "./dist/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
10
22
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"default": "./dist/index.cjs"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"./internal": {
|
|
24
|
-
"import": {
|
|
25
|
-
"types": "./dist/internal.index.d.mts",
|
|
26
|
-
"default": "./dist/internal.index.mjs"
|
|
27
|
-
},
|
|
28
|
-
"require": {
|
|
29
|
-
"types": "./dist/internal.index.d.cts",
|
|
30
|
-
"default": "./dist/internal.index.cjs"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"files": [
|
|
35
|
-
"dist",
|
|
36
|
-
"package.json",
|
|
37
|
-
"README.md",
|
|
38
|
-
"LICENSE"
|
|
39
|
-
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsdown",
|
|
42
|
-
"clean": "rm -rf dist",
|
|
43
|
-
"lint": "eslint 'src/**/*.{ts,tsx}' 'tests/**/*.{ts,tsx}' --cache",
|
|
44
|
-
"lint:fix": "eslint 'src/**/*.{ts,tsx}' 'tests/**/*.{ts,tsx}' --fix --cache",
|
|
45
|
-
"fmt": "prettier --write 'src/**/*.{ts,tsx,json,md}' 'tests/**/*.{ts,tsx,json,md}' --cache",
|
|
46
|
-
"fmt:check": "prettier --check 'src/**/*.{ts,tsx,json,md}' 'tests/**/*.{ts,tsx,json,md}' --cache",
|
|
47
|
-
"tc": "tsc --noEmit",
|
|
48
|
-
"test": "vitest run",
|
|
49
|
-
"test:watch": "vitest dev",
|
|
50
|
-
"coverage": "vitest run --coverage"
|
|
51
|
-
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"typescript": "catalog:peer"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@seedcord/eslint-config": "workspace:*",
|
|
57
|
-
"@seedcord/tsconfig": "workspace:*",
|
|
58
|
-
"@seedcord/tsdown-config": "workspace:*"
|
|
59
|
-
},
|
|
60
|
-
"publishConfig": {
|
|
61
|
-
"access": "public",
|
|
62
|
-
"provenance": true
|
|
23
|
+
"./internal": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/internal.index.d.mts",
|
|
26
|
+
"default": "./dist/internal.index.mjs"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/internal.index.d.cts",
|
|
30
|
+
"default": "./dist/internal.index.cjs"
|
|
31
|
+
}
|
|
63
32
|
}
|
|
64
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"package.json",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"typescript": "^6.0.3"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@discordjs/builders": "^1.14.1",
|
|
45
|
+
"discord-api-types": "^0.38.49",
|
|
46
|
+
"@seedcord/errors": "0.3.0-next.2",
|
|
47
|
+
"@seedcord/types": "0.8.0-next.2"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"type-fest": "^5.7.0",
|
|
51
|
+
"@seedcord/eslint-config": "1.5.0-next.1",
|
|
52
|
+
"@seedcord/tsconfig": "2.0.1",
|
|
53
|
+
"@seedcord/tsdown-config": "2.0.1"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public",
|
|
57
|
+
"provenance": true
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsdown",
|
|
61
|
+
"clean": "rm -rf dist",
|
|
62
|
+
"lint": "eslint 'src/**/*.{ts,tsx}' 'tests/**/*.{ts,tsx}' --cache",
|
|
63
|
+
"lint:fix": "eslint 'src/**/*.{ts,tsx}' 'tests/**/*.{ts,tsx}' --fix --cache",
|
|
64
|
+
"fmt": "prettier --write 'src/**/*.{ts,tsx,json,md}' 'tests/**/*.{ts,tsx,json,md}' --cache",
|
|
65
|
+
"fmt:check": "prettier --check 'src/**/*.{ts,tsx,json,md}' 'tests/**/*.{ts,tsx,json,md}' --cache",
|
|
66
|
+
"tc": "tsgo --noEmit",
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest dev",
|
|
69
|
+
"coverage": "vitest run --coverage"
|
|
70
|
+
},
|
|
71
|
+
"readme": "<p align=\"center\">\n <picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.seedcord.org/assets/wordmark-dark.webp\" />\n <img src=\"https://cdn.seedcord.org/assets/wordmark-light.webp\" alt=\"seedcord\" width=\"440\" />\n </picture>\n</p>\n\n# @seedcord/core\n\nTransport-agnostic core for Seedcord bots\n\nPart of the [seedcord](https://github.com/seedcord/seedcord) framework. Until a major v1.0.0 release, expect breaking changes in minor versions.\n"
|
|
72
|
+
}
|