From 811d33869d4ed20c003885e55002115f346a58b5 Mon Sep 17 00:00:00 2001 From: Zach Parks Date: Sat, 8 Jul 2023 22:06:54 -0500 Subject: [PATCH] Fix imports... one final time. (#189) --- .npmignore | 2 +- package.json | 4 ++-- src/Client.ts | 4 ++-- src/index.ts | 14 -------------- src/packets/ConnectedPacket.ts | 4 ++-- src/types/ConnectionInformation.ts | 4 ++-- src/types/{UnknownSlotData.ts => SlotData.ts} | 5 ++++- src/types/index.ts | 14 ++++++++++++++ tsconfig.json | 2 +- webpack.config.js | 2 +- 10 files changed, 29 insertions(+), 26 deletions(-) rename src/types/{UnknownSlotData.ts => SlotData.ts} (60%) create mode 100644 src/types/index.ts diff --git a/.npmignore b/.npmignore index 7fa069b..522db36 100644 --- a/.npmignore +++ b/.npmignore @@ -3,4 +3,4 @@ # JavaScript and Type Definitions !dist/**/*.d.ts -!dist/archipelago.min.js +!dist/**/*.js diff --git a/package.json b/package.json index b8ccb21..f6b7839 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "archipelago.js", - "version": "1.0.1", + "version": "1.0.2", "description": "A general-purpose client library for communicating with Archipelago game servers, written for Node.js.", "license": "MIT", - "main": "archipelago.min.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "author": { "email": "zach@alliware.com", diff --git a/src/Client.ts b/src/Client.ts index af565c9..485b96e 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -27,13 +27,13 @@ import { SetReplyPacket } from "./packets/SetReplyPacket"; import { ConnectionInformation } from "./types/ConnectionInformation"; import { VALID_JSON_MESSAGE_TYPE } from "./types/JSONMessagePart"; import { NetworkVersion } from "./types/NetworkVersion"; -import { UnknownSlotData } from "./types/UnknownSlotData"; +import { SlotData } from "./types/SlotData"; /** * The client that connects to an Archipelago server and facilitates communication, listens for events, and manages * data. */ -export class Client { +export class Client { #socket?: WebSocket; #status: ConnectionStatus = CONNECTION_STATUS.DISCONNECTED; #emitter = new EventEmitter(); diff --git a/src/index.ts b/src/index.ts index 27633db..f8485d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,17 +42,3 @@ export * from "./packets/SetPacket"; export * from "./packets/SetReplyPacket"; export * from "./packets/StatusUpdatePacket"; export * from "./packets/SyncPacket"; -export * from "./types/ConnectionInformation"; -export * from "./types/DataPackage"; -export * from "./types/DataStorageOperations"; -export * from "./types/DeathLinkData"; -export * from "./types/GamePackage"; -export * from "./types/Hint"; -export * from "./types/JSONMessagePart"; -export * from "./types/JSONSerializableData"; -export * from "./types/NetworkItem"; -export * from "./types/NetworkPlayer"; -export * from "./types/NetworkSlot"; -export * from "./types/NetworkVersion"; -export * from "./types/Player"; -export * from "./types/UnknownSlotData"; diff --git a/src/packets/ConnectedPacket.ts b/src/packets/ConnectedPacket.ts index a975e9a..da88b58 100644 --- a/src/packets/ConnectedPacket.ts +++ b/src/packets/ConnectedPacket.ts @@ -1,6 +1,6 @@ import { NetworkPlayer } from "../types/NetworkPlayer"; import { NetworkSlot } from "../types/NetworkSlot"; -import { UnknownSlotData } from "../types/UnknownSlotData"; +import { SlotData } from "../types/SlotData"; import { BaseServerPacket } from "./BasePackets"; /** @@ -30,7 +30,7 @@ export interface ConnectedPacket extends BaseServerPacket { checked_locations: number[]; /** Contains a json object for slot related data, differs per game. Empty if not required. */ - slot_data: UnknownSlotData; + slot_data: SlotData; /** Object of each slot with their {@link NetworkSlot} information. */ slot_info: { [slot: number]: NetworkSlot }; diff --git a/src/types/ConnectionInformation.ts b/src/types/ConnectionInformation.ts index 220f5cf..3d86623 100644 --- a/src/types/ConnectionInformation.ts +++ b/src/types/ConnectionInformation.ts @@ -3,7 +3,7 @@ import { ItemsHandlingFlags } from "../consts/ItemsHandlingFlags"; /** * An object that holds credential information for a slot to connect. */ -export interface ConnectionInformation { +export type ConnectionInformation = { /** The hostname or ip address of the Archipelago server to connect to. */ hostname: string; @@ -46,4 +46,4 @@ export interface ConnectionInformation { * on individual flags. */ items_handling: number | ItemsHandlingFlags; -} +}; diff --git a/src/types/UnknownSlotData.ts b/src/types/SlotData.ts similarity index 60% rename from src/types/UnknownSlotData.ts rename to src/types/SlotData.ts index ec2b4bf..1ec52ac 100644 --- a/src/types/UnknownSlotData.ts +++ b/src/types/SlotData.ts @@ -3,6 +3,9 @@ import { JSONSerializableData } from "./JSONSerializableData"; /** * A stand in for unknown slot data. */ -export type UnknownSlotData = { +export type SlotData = { [arg: string]: JSONSerializableData; }; + +// For backwards compatibility. +export type UnknownSlotData = SlotData; diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 0000000..7e498a4 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,14 @@ +export * from "./ConnectionInformation"; +export * from "./DataPackage"; +export * from "./DataStorageOperations"; +export * from "./DeathLinkData"; +export * from "./GamePackage"; +export * from "./Hint"; +export * from "./JSONMessagePart"; +export * from "./JSONSerializableData"; +export * from "./NetworkItem"; +export * from "./NetworkPlayer"; +export * from "./NetworkSlot"; +export * from "./ObjectValues"; +export * from "./Player"; +export * from "./SlotData"; diff --git a/tsconfig.json b/tsconfig.json index ccd0d2c..f64c246 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,7 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "esnext", /* Specify what module code is generated. */ + "module": "commonjs", /* Specify what module code is generated. */ "rootDir": "./src", /* Specify the root folder within your source files. */ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ "baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */ diff --git a/webpack.config.js b/webpack.config.js index 0ed63be..0cfaecd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -26,7 +26,7 @@ module.exports = { minimizer: [new TerserPlugin()], }, output: { - path: path.resolve(__dirname), + path: path.resolve(__dirname, "dist"), filename: "archipelago.min.js", library: { type: "module",