From b5335f7d10b82c00b8ba0d335cee2a796474a401 Mon Sep 17 00:00:00 2001 From: Luca Raddatz Date: Fri, 28 Feb 2025 23:20:17 +0100 Subject: [PATCH] [bgw-docs] Added bgw-net api endpoints to reference --- .gitignore | 1 + bgw-docs/parser/.gitignore | 1 + bgw-docs/parser/app.js | 14 +- bgw-docs/parser/build.gradle.kts | 25 +- bgw-docs/website/src/lib/utils.ts | 68 ++++++ bgw-docs/website/src/pages/BGWDocsLayout.tsx | 225 ++++++++++++------ bgw-docs/website/src/pages/docs/Packages.tsx | 130 +++++++--- .../tools/aqua/bgw/visual/ColorVisual.kt | 40 ++-- 8 files changed, 385 insertions(+), 119 deletions(-) diff --git a/.gitignore b/.gitignore index ad44a20f4..abc58aa1c 100644 --- a/.gitignore +++ b/.gitignore @@ -234,3 +234,4 @@ bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/application/Config.kt bgw-docs/website/public/bgw/bgw-gui.js bgw-docs/website/public/bgw/bgwSamples.json bgw-docs/website/public/bgw/cleanedStructure.json +bgw-docs/build/ diff --git a/bgw-docs/parser/.gitignore b/bgw-docs/parser/.gitignore index 67f4f277f..bb5e76b8e 100644 --- a/bgw-docs/parser/.gitignore +++ b/bgw-docs/parser/.gitignore @@ -1,4 +1,5 @@ /node_modules/ /example/ /output/ +/build/ package-lock.json \ No newline at end of file diff --git a/bgw-docs/parser/app.js b/bgw-docs/parser/app.js index 7b724d76f..2d6d99df9 100644 --- a/bgw-docs/parser/app.js +++ b/bgw-docs/parser/app.js @@ -11,9 +11,9 @@ const { let rootDir = "./example/htmlPartial"; -function loadPackageList() { +function loadPackageList(filename) { const packageList = fs.readFileSync( - "./example/htmlPartial/package-list", + "./example/htmlPartial/" + filename, "utf8" ); @@ -23,7 +23,15 @@ function loadPackageList() { return lines; } -let validPackages = loadPackageList(); +function loadAllPackages() { + const bgwGui = loadPackageList("package-list"); + const bgwClient = loadPackageList("package-list-client"); + const bgwCommon = loadPackageList("package-list-common"); + + return [...bgwGui, ...bgwClient, ...bgwCommon]; +} + +let validPackages = loadAllPackages(); function getDirectoryStructure(dir) { let results = {}; diff --git a/bgw-docs/parser/build.gradle.kts b/bgw-docs/parser/build.gradle.kts index 34e2ce902..81d2dca9b 100644 --- a/bgw-docs/parser/build.gradle.kts +++ b/bgw-docs/parser/build.gradle.kts @@ -76,7 +76,10 @@ tasks.register("buildAndCopySamples") { } tasks.register("buildAndCopyDokkaHtml") { - dependsOn(":bgw-gui:dokkaHtmlPartial") + dependsOn( + rootProject.project(":bgw-gui").tasks.named("dokkaHtmlPartial"), + rootProject.project(":bgw-net:bgw-net-client").tasks.named("dokkaHtmlPartial"), + rootProject.project(":bgw-net:bgw-net-common").tasks.named("dokkaHtmlPartial")) this.group = "build" doLast { val sourceDir = project(":bgw-gui").buildDir.resolve("dokka/htmlPartial") @@ -86,6 +89,26 @@ tasks.register("buildAndCopyDokkaHtml") { from(sourceDir) into(destinationDir) } + + val sourceDir2 = + rootProject.project(":bgw-net:bgw-net-client").buildDir.resolve("dokka/htmlPartial") + val destinationDir2 = projectDir.resolve("example/htmlPartial") + println("Copying files from $sourceDir2 to $destinationDir2") + copy { + from(sourceDir2) + into(destinationDir2) + rename("package-list", "package-list-client") + } + + val sourceDir3 = + rootProject.project(":bgw-net:bgw-net-common").buildDir.resolve("dokka/htmlPartial") + val destinationDir3 = projectDir.resolve("example/htmlPartial") + println("Copying files from $sourceDir3 to $destinationDir3") + copy { + from(sourceDir3) + into(destinationDir3) + rename("package-list", "package-list-common") + } } } diff --git a/bgw-docs/website/src/lib/utils.ts b/bgw-docs/website/src/lib/utils.ts index c0475ef9f..e865b35b0 100644 --- a/bgw-docs/website/src/lib/utils.ts +++ b/bgw-docs/website/src/lib/utils.ts @@ -334,12 +334,14 @@ export const layoutMap = { description: "Animations are a powerful tool to bring your app to life.", icon: "motion_play", package: "tools.aqua.bgw.animation", + module: "bgw-gui", }, components: { title: "Components", description: "Components are the building blocks of your BGW app.", icon: "shapes", package: "tools.aqua.bgw.components", + module: "bgw-gui", }, container: { title: "Container", @@ -347,54 +349,63 @@ export const layoutMap = { "Containers are used to layout and align your game components.", icon: "stacks", package: "tools.aqua.bgw.components.container", + module: "bgw-gui", }, gamecomponentviews: { title: "GameComponentViews", description: "GameComponentViews are used to display your game components.", icon: "playing_cards", package: "tools.aqua.bgw.components.gamecomponentviews", + module: "bgw-gui", }, layoutviews: { title: "LayoutViews", description: "LayoutViews are used to layout and align your ui components.", icon: "view_carousel", package: "tools.aqua.bgw.components.layoutviews", + module: "bgw-gui", }, uicomponents: { title: "UIComponents", description: "UIComponents are used to build your UI.", icon: "buttons_alt", package: "tools.aqua.bgw.components.uicomponents", + module: "bgw-gui", }, core: { title: "Core", description: "Includes core classes, functions and constants.", icon: "token", package: "tools.aqua.bgw.core", + module: "bgw-gui", }, dialog: { title: "Dialog", description: "Dialogs are popups that can be used to display information.", icon: "wysiwyg", package: "tools.aqua.bgw.dialog", + module: "bgw-gui", }, event: { title: "Event", description: "Events are used to handle user interactions.", icon: "web_traffic", package: "tools.aqua.bgw.event", + module: "bgw-gui", }, io: { title: "IO", description: "IO classes are used to read and write files.", icon: "save", package: "tools.aqua.bgw.io", + module: "bgw-gui", }, observable: { title: "Observable", description: "Observables are used to listen for changes in your data.", icon: "visibility", package: "tools.aqua.bgw.observable", + module: "bgw-gui", }, lists: { title: "Lists", @@ -402,30 +413,87 @@ export const layoutMap = { "Observable lists are used to store data as a list and observe changes.", icon: "format_list_numbered", package: "tools.aqua.bgw.observable.lists", + module: "bgw-gui", }, properties: { title: "Properties", description: "Properties are used to store data and observe changes.", icon: "123", package: "tools.aqua.bgw.observable.properties", + module: "bgw-gui", }, style: { title: "Style", description: "Style classes are used to style your components.", icon: "style", package: "tools.aqua.bgw.style", + module: "bgw-gui", }, util: { title: "Util", description: "Util classes are used to perform common tasks.", icon: "function", package: "tools.aqua.bgw.util", + module: "bgw-gui", }, visual: { title: "Visual", description: "Visual classes are used to give your components color.", icon: "colors", package: "tools.aqua.bgw.visual", + module: "bgw-gui", + }, + annotations: { + title: "Annotations", + description: + "Network annotations are used to annotate network message receivers.", + icon: "alternate_email", + package: "tools.aqua.bgw.net.common.annotations", + module: "bgw-net", + }, + client: { + title: "Client", + description: "The client is used to communicate with the BGW-Net server.", + icon: "cast", + package: "tools.aqua.bgw.net.client", + module: "bgw-net", + }, + common: { + title: "Common", + description: "Common classes are used to define network messages.", + icon: "device_hub", + package: "tools.aqua.bgw.net.common", + module: "bgw-net", + }, + message: { + title: "Message", + description: + "Messages are used to send custom game messages between clients.", + icon: "message", + package: "tools.aqua.bgw.net.common.message", + module: "bgw-net", + }, + notification: { + title: "Notification", + description: "Notifications are used to send alerts between clients.", + icon: "mark_chat_unread", + package: "tools.aqua.bgw.net.common.notification", + module: "bgw-net", + }, + request: { + title: "Request", + description: + "Requests are used to send predefined framework messages to clients.", + icon: "keyboard_double_arrow_right", + package: "tools.aqua.bgw.net.common.request", + module: "bgw-net", + }, + response: { + title: "Response", + description: "Responses are used to receive data from clients.", + icon: "keyboard_double_arrow_left", + package: "tools.aqua.bgw.net.common.response", + module: "bgw-net", }, }; diff --git a/bgw-docs/website/src/pages/BGWDocsLayout.tsx b/bgw-docs/website/src/pages/BGWDocsLayout.tsx index 3e37588ad..1ffac80a0 100644 --- a/bgw-docs/website/src/pages/BGWDocsLayout.tsx +++ b/bgw-docs/website/src/pages/BGWDocsLayout.tsx @@ -324,76 +324,167 @@ function BGWDocsLayout() { {buildTopSidebar(loc)} - Packages + Packages (GUI) - {navMain.map((item) => ( - { - setOpenedSections( - isOpen - ? [...openedSections, item.title] - : openedSections.filter( - (section) => section !== item.title - ) - ); - }} - className="group/collapsible" - > - - - - {item.icon && ( - - {layoutMap[item.title].icon} - - )} - - {layoutMap[item.title].title} - - - - - - - {item.items?.map((subItem) => ( - - - - {subItem.type && ( - - )} - - {subItem.title} - - - - - ))} - - - - - ))} + {navMain + .filter((i) => { + return ( + layoutMap[i.title] !== undefined && + layoutMap[i.title].module === "bgw-gui" + ); + }) + .map((item) => ( + { + setOpenedSections( + isOpen + ? [...openedSections, item.title] + : openedSections.filter( + (section) => section !== item.title + ) + ); + }} + className="group/collapsible" + > + + + + {item.icon && ( + + {layoutMap[item.title].icon} + + )} + + {layoutMap[item.title].title} + + + + + + + {item.items?.map((subItem) => ( + + + + {subItem.type && ( + + )} + + {subItem.title} + + + + + ))} + + + + + ))} + + + + Packages (Network) + + + + {navMain + .filter((i) => { + return ( + layoutMap[i.title] !== undefined && + layoutMap[i.title].module === "bgw-net" + ); + }) + .map((item) => ( + { + setOpenedSections( + isOpen + ? [...openedSections, item.title] + : openedSections.filter( + (section) => section !== item.title + ) + ); + }} + className="group/collapsible" + > + + + + {item.icon && ( + + {layoutMap[item.title].icon} + + )} + + {layoutMap[item.title].title} + + + + + + + {item.items?.map((subItem) => ( + + + + {subItem.type && ( + + )} + + {subItem.title} + + + + + ))} + + + + + ))} diff --git a/bgw-docs/website/src/pages/docs/Packages.tsx b/bgw-docs/website/src/pages/docs/Packages.tsx index 725785ea5..d2343ff69 100644 --- a/bgw-docs/website/src/pages/docs/Packages.tsx +++ b/bgw-docs/website/src/pages/docs/Packages.tsx @@ -8,6 +8,7 @@ import { import { useDocsStore } from "@/stores/docsStore"; import { Link, useLocation } from "react-router-dom"; import { useEffect } from "react"; +import { Badge } from "@/components/ui/badge"; function Packages({ packages }: { packages: any }) { const { setSecondarySidebar } = useDocsStore(); @@ -17,18 +18,39 @@ function Packages({ packages }: { packages: any }) { useEffect(() => { const sidebarItems = [ { - title: "Packages", + title: "Packages (GUI)", url: location.pathname, - items: Object.keys(packages).map((key: any) => { - let elem = packages[key]; - return { - title: elem.title, - url: `/docs/${elem.package}`, - }; - }), + items: Object.keys(packages) + .map((e) => { + return packages[e]; + }) + .filter((elem: any) => elem.module === "bgw-gui") + .map((elem: any) => { + return { + title: elem.title, + url: `/docs/${elem.package}`, + }; + }), + }, + { + title: "Packages (Network)", + url: location.pathname, + items: Object.keys(packages) + .map((e) => { + return packages[e]; + }) + .filter((elem: any) => elem.module === "bgw-net") + .map((elem: any) => { + return { + title: elem.title, + url: `/docs/${elem.package}`, + }; + }), }, ]; + console.log(sidebarItems); + setSecondarySidebar(sidebarItems); }, [location.pathname]); @@ -42,32 +64,72 @@ function Packages({ packages }: { packages: any }) { -
- {Object.keys(packages).map((key) => { - let elem = packages[key]; - return ( - -
-
- - {elem.icon} - -
-
-

- {elem.title} -

-

- {elem.description} -

-
- - chevron_right - -
- - ); - })} +
+
+ {Object.keys(packages) + .map((e) => { + return packages[e]; + }) + .filter((elem: any) => elem.module === "bgw-gui") + .map((elem: any) => { + return ( + +
+
+ + {elem.icon} + +
+
+

+ {elem.title} +

+

+ {elem.description} +

+
+ + chevron_right + +
+ + ); + })} +
+
+ {Object.keys(packages) + .map((e) => { + return packages[e]; + }) + .filter((elem: any) => elem.module === "bgw-net") + .map((elem: any) => { + return ( + +
+
+ + {elem.icon} + +
+
+

+ {elem.title} +

+

+ {elem.description} +

+
+ + chevron_right + +
+ + ); + })} +
diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ColorVisual.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ColorVisual.kt index 41ba0400f..c85eac9a8 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ColorVisual.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ColorVisual.kt @@ -112,60 +112,72 @@ open class ColorVisual(color: Color) : SingleLayerVisual() { } companion object { - /** [ColorVisual] filled [WHITE] but completely opaque. */ + /** [ColorVisual] filled with [Color.WHITE] but completely opaque. */ val TRANSPARENT: ColorVisual get() = ColorVisual(Color.WHITE).apply { transparency = 0.0 } - /** [ColorVisual] filled [WHITE]. */ + /** [ColorVisual] filled with [Color.WHITE]. */ val WHITE: ColorVisual get() = ColorVisual(Color.WHITE) - /** [ColorVisual] filled [LIGHT_GRAY]. */ + /** [ColorVisual] filled with [Color.LIGHT_GRAY]. */ val LIGHT_GRAY: ColorVisual get() = ColorVisual(Color.LIGHT_GRAY) - /** [ColorVisual] filled [GRAY]. */ + /** [ColorVisual] filled with [Color.GRAY]. */ val GRAY: ColorVisual get() = ColorVisual(Color.GRAY) - /** [ColorVisual] filled [DARK_GRAY]. */ + /** [ColorVisual] filled with [Color.DARK_GRAY]. */ val DARK_GRAY: ColorVisual get() = ColorVisual(Color.DARK_GRAY) - /** [ColorVisual] filled [BLACK]. */ + /** [ColorVisual] filled with [Color.BLACK]. */ val BLACK: ColorVisual get() = ColorVisual(Color.BLACK) - /** [ColorVisual] filled [RED]. */ + /** [ColorVisual] filled with [Color.RED]. */ val RED: ColorVisual get() = ColorVisual(Color.RED) - /** [ColorVisual] filled [PINK]. */ + /** [ColorVisual] filled with [Color.PINK]. */ val PINK: ColorVisual get() = ColorVisual(Color.PINK) - /** [ColorVisual] filled [ORANGE]. */ + /** [ColorVisual] filled with [Color.ORANGE]. */ val ORANGE: ColorVisual get() = ColorVisual(Color.ORANGE) - /** [ColorVisual] filled [YELLOW]. */ + /** [ColorVisual] filled with [Color.YELLOW]. */ val YELLOW: ColorVisual get() = ColorVisual(Color.YELLOW) - /** [ColorVisual] filled [GREEN]. */ + /** [ColorVisual] filled with [Color.GREEN]. */ val GREEN: ColorVisual get() = ColorVisual(Color.GREEN) - /** [ColorVisual] filled [MAGENTA]. */ + /** [ColorVisual] filled with [Color.LIME]. */ + val LIME: ColorVisual + get() = ColorVisual(Color.LIME) + + /** [ColorVisual] filled with [Color.MAGENTA]. */ val MAGENTA: ColorVisual get() = ColorVisual(Color.MAGENTA) - /** [ColorVisual] filled [CYAN]. */ + /** [ColorVisual] filled with [Color.CYAN]. */ val CYAN: ColorVisual get() = ColorVisual(Color.CYAN) - /** [ColorVisual] filled [BLUE]. */ + /** [ColorVisual] filled with [Color.BLUE]. */ val BLUE: ColorVisual get() = ColorVisual(Color.BLUE) + + /** [ColorVisual] filled with [Color.PURPLE]. */ + val PURPLE: ColorVisual + get() = ColorVisual(Color.PURPLE) + + /** [ColorVisual] filled with [Color.BROWN]. */ + val BROWN: ColorVisual + get() = ColorVisual(Color.BROWN) } }