@hotbunny/hackhub-content-sdk 0.2.0 → 0.4.0

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.
Files changed (2) hide show
  1. package/index.d.ts +160 -12
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -68,6 +68,10 @@ export interface CommandDefinition {
68
68
  packageName?: string;
69
69
  autocomplete?: CommandAutoComplete[];
70
70
  }
71
+ export interface ParsedFlags {
72
+ flags: Record<string, string | boolean>;
73
+ positional: string[];
74
+ }
71
75
  export interface CommandTools {
72
76
  println(text: string): void;
73
77
  printError(text: string): void;
@@ -80,11 +84,29 @@ export interface CommandTools {
80
84
  isLocked(): boolean;
81
85
  lock(): void;
82
86
  unlock(): void;
87
+ /** Print a formatted ASCII table. */
88
+ printTable(headers: string[], rows: string[][]): void;
89
+ /** Print a success message (green). */
90
+ printSuccess(text: string): void;
91
+ /** Print a warning message (yellow). */
92
+ printWarning(text: string): void;
93
+ /** Print an info message (cyan). */
94
+ printInfo(text: string): void;
95
+ /** Parse args into flags and positional arguments. */
96
+ parseFlags(): ParsedFlags;
83
97
  }
84
98
  export interface AppSize {
85
99
  width: number;
86
100
  height: number;
87
101
  }
102
+ /** App Store listing definition for mod apps. */
103
+ export interface AppStoreDefinition {
104
+ title: string;
105
+ ratings: number;
106
+ description: string;
107
+ /** Price in dollars. Omit for free apps. */
108
+ price?: number;
109
+ }
88
110
  export interface AppDefinition {
89
111
  name: string;
90
112
  title: string;
@@ -96,12 +118,67 @@ export interface AppDefinition {
96
118
  maxOpen?: number;
97
119
  disableMaximize?: boolean;
98
120
  disableMinimize?: boolean;
99
- store?: {
100
- title: string;
101
- ratings: number;
102
- description: string;
103
- price?: number;
104
- };
121
+ store?: AppStoreDefinition;
122
+ }
123
+ /** Twotter account that gets registered with the game for quest use. */
124
+ export interface TwotterAccountDefinition {
125
+ id: string;
126
+ username: string;
127
+ displayName: string;
128
+ avatar: string;
129
+ bio?: string;
130
+ followers?: number;
131
+ following?: number;
132
+ verified?: boolean;
133
+ }
134
+ /** A tweet posted by a Twotter account during a quest. */
135
+ export interface TweetDefinition {
136
+ /** Must match a TwotterAccountDefinition.id from TwotterAccounts. */
137
+ accountId: string;
138
+ content: string;
139
+ image?: string;
140
+ likes?: number;
141
+ comments?: number;
142
+ shares?: number;
143
+ views?: number;
144
+ /** How long ago the tweet was posted, e.g. "2 days", "1 month". */
145
+ postedAgo?: string;
146
+ }
147
+ /** A Kisscord conversation chain attached to a quest. */
148
+ export interface KisscordChatDefinition {
149
+ /** The Kisscord user ID to chat with (NPC). */
150
+ contactId: string;
151
+ /** Ordered list of messages. The chain follows array order automatically. */
152
+ messages: KisscordMessageDefinition[];
153
+ }
154
+ /** A single Kisscord message in a chat chain. */
155
+ export interface KisscordMessageDefinition {
156
+ content: string;
157
+ /** True if the player sends this message. Defaults to false (NPC). */
158
+ isMine?: boolean;
159
+ /** Delay in ms before this NPC message appears. */
160
+ delayMs?: number;
161
+ /** Callback fired after this message is sent/received. */
162
+ onSent?: () => void | Promise<void>;
163
+ }
164
+ /** A WeeChat (IRC) conversation chain attached to a quest. */
165
+ export interface WeeChatChatDefinition {
166
+ /** The IRC server host. */
167
+ host: string;
168
+ /** Ordered list of messages. */
169
+ messages: WeeChatMessageDefinition[];
170
+ }
171
+ /** A single WeeChat message in a chain. */
172
+ export interface WeeChatMessageDefinition {
173
+ content: string;
174
+ /** Username for NPC messages. Player username auto-filled if isMine. */
175
+ username?: string;
176
+ /** True if the player sends this message. */
177
+ isMine?: boolean;
178
+ /** Delay in ms before this NPC message appears. */
179
+ delayMs?: number;
180
+ /** Callback fired after this message is sent. */
181
+ onSent?: () => void | Promise<void>;
105
182
  }
106
183
  /**
107
184
  * Game events that mods can listen to.
@@ -809,6 +886,14 @@ export declare abstract class Quest {
809
886
  MaxClaimPerDay?: number;
810
887
  Abandonable?: boolean;
811
888
  HasCompleteButton?: boolean;
889
+ /** Twotter accounts to register when this quest loads. */
890
+ TwotterAccounts?: TwotterAccountDefinition[];
891
+ /** Tweets to post when the quest starts. */
892
+ Tweets?: TweetDefinition[];
893
+ /** Kisscord chat chains for this quest. */
894
+ KisscordChats?: KisscordChatDefinition[];
895
+ /** WeeChat (IRC) chat chains for this quest. */
896
+ WeeChatChats?: WeeChatChatDefinition[];
812
897
  /**
813
898
  * Called when the quest is first claimed/started.
814
899
  * Use this to set up event listeners for objective completion.
@@ -846,8 +931,25 @@ export declare abstract class Quest {
846
931
  * { path: "/", title: "Home", html: homePage },
847
932
  * { path: "/about", title: "About", html: aboutPage },
848
933
  * ];
934
+ * Exports = {
935
+ * formatPost: (text: string) => text.toUpperCase(),
936
+ * };
849
937
  * }
850
938
  * ```
939
+ *
940
+ * In your HTML, access exported functions via `window.ModExports`:
941
+ * ```html
942
+ * <script>
943
+ * const formatted = window.ModExports.formatPost("hello");
944
+ * </script>
945
+ * ```
946
+ *
947
+ * SDK APIs are available via `window.HackhubSDK`:
948
+ * ```html
949
+ * <script>
950
+ * window.HackhubSDK.Mail.send({ to: "user@mail.com", subject: "Hi" });
951
+ * </script>
952
+ * ```
851
953
  */
852
954
  export declare abstract class Website {
853
955
  abstract SiteName: string;
@@ -855,6 +957,11 @@ export declare abstract class Website {
855
957
  abstract Icon: string;
856
958
  abstract Pages: WebsitePageDefinition[];
857
959
  Popular?: boolean;
960
+ /**
961
+ * Functions/values exposed to all pages' HTML via `window.ModExports`.
962
+ * Use this to bridge your TypeScript logic with the iframe UI.
963
+ */
964
+ Exports?: Record<string, any>;
858
965
  }
859
966
  /**
860
967
  * Base class for mod terminal commands. Mod authors extend this to
@@ -917,8 +1024,26 @@ export declare abstract class Command {
917
1024
  * ratings: 4.5,
918
1025
  * description: "Generate secure passwords",
919
1026
  * };
1027
+ * Exports = {
1028
+ * generate: (length: number) => "x".repeat(length),
1029
+ * };
920
1030
  * }
921
1031
  * ```
1032
+ *
1033
+ * In your HTML, access exported functions via `window.ModExports`:
1034
+ * ```html
1035
+ * <script>
1036
+ * const pw = window.ModExports.generate(16);
1037
+ * document.getElementById("result").textContent = pw;
1038
+ * </script>
1039
+ * ```
1040
+ *
1041
+ * SDK APIs are available via `window.HackhubSDK`:
1042
+ * ```html
1043
+ * <script>
1044
+ * window.HackhubSDK.Events.emit("PasswordGenerated");
1045
+ * </script>
1046
+ * ```
922
1047
  */
923
1048
  export declare abstract class App {
924
1049
  abstract AppName: string;
@@ -931,12 +1056,15 @@ export declare abstract class App {
931
1056
  MaxOpen?: number;
932
1057
  DisableMaximize?: boolean;
933
1058
  DisableMinimize?: boolean;
934
- Store?: {
935
- title: string;
936
- ratings: number;
937
- description: string;
938
- price?: number;
939
- };
1059
+ /** App Store listing. If provided, the app appears in the AppStore. */
1060
+ Store?: AppStoreDefinition;
1061
+ /** If true, the app is unlocked in the AppStore by default (no quest required). */
1062
+ Unlocked?: boolean;
1063
+ /**
1064
+ * Functions/values exposed to the app's HTML via `window.ModExports`.
1065
+ * Use this to bridge your TypeScript logic with the iframe UI.
1066
+ */
1067
+ Exports?: Record<string, any>;
940
1068
  }
941
1069
  /**
942
1070
  * Game events API. Allows mods to listen to in-game events
@@ -1314,6 +1442,26 @@ export declare namespace Shell {
1314
1442
  export function getInstalledPackages(): string[];
1315
1443
  /** Check if a specific package is installed. */
1316
1444
  export function isPackageInstalled(pkg: string): boolean;
1445
+ /**
1446
+ * Add response data for a built-in terminal command.
1447
+ * When a player runs `command input`, the game returns this data.
1448
+ *
1449
+ * @example
1450
+ * ```ts
1451
+ * Shell.addCommandData("nmap", "10.0.0.1", [
1452
+ * { port: 22, service: "ssh", status: "OPEN", version: "OpenSSH 8.9" }
1453
+ * ]);
1454
+ * Shell.addCommandData("whois", "example.com", { registrant: "John Doe" });
1455
+ * ```
1456
+ */
1457
+ export function addCommandData(command: string, input: any, data: any): void;
1458
+ /**
1459
+ * Remove previously added command data.
1460
+ * Should be called when a quest completes to clean up.
1461
+ */
1462
+ export function removeCommandData(command: string, input: any): void;
1463
+ /** Get existing command data for a command+input pair. */
1464
+ export function getCommandData(command: string, input: any): any;
1317
1465
  export {};
1318
1466
  }
1319
1467
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotbunny/hackhub-content-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Type definitions and API reference for HackHub mod development",
5
5
  "types": "index.d.ts",
6
6
  "files": [