diff --git a/api/README.md b/api/README.md index fe5aef6..ddf7c4a 100644 --- a/api/README.md +++ b/api/README.md @@ -76,12 +76,14 @@ Gets a (paginated) list of all C/C++(-like) types used by the intrinsics. The ty Searches the database using the given filters. The filters are passed as query parameters, and can be combined. All filters are optional. The following filters are available: - `name=[string]`: searches based on the name of the intrinsic; employs fuzzy-search (using `LIKE %it%`) - `return=[string]`: searches based on the return type of the intrinsic; exact search only -- `cpuid=[string]`: searches based on the CPUID of the intrinsic; exact search only -- `tech=[string]`: searches based on the technology of the intrinsic; exact search only -- `category=[string]`: searches based on the category of the intrinsic; exact search only +- `cpuid=[*]`: searches based on the CPUID of the intrinsic; exact search only +- `tech=[*]`: searches based on the technology of the intrinsic; exact search only +- `category=[*]`: searches based on the category of the intrinsic; exact search only - `desc=[string]`: searches based on the description of the intrinsic; employs fuzzy-search (using `LIKE %it%`) - `page=[int]`: specifies the page number to return (default is 0) +Parameters marked by `[*]` are JSON-lists (so you should pass them as `cpuid=["PREFETCHI", "SSE2"]`). They are considered to be OR-ed together (i.e. the results will contain a mix of all intrinsics matching either of the CPUIDs (from the example)). + Passing no filters is equivalent to using `GET /all`, and data is returned in the same format: ```json { diff --git a/api/src/main/kotlin/data/Loader.kt b/api/src/main/kotlin/data/Loader.kt index 872b259..7f3cc4a 100644 --- a/api/src/main/kotlin/data/Loader.kt +++ b/api/src/main/kotlin/data/Loader.kt @@ -1,6 +1,7 @@ package com.jaytux.simd.data import com.fleeksoft.ksoup.Ksoup +import com.fleeksoft.ksoup.parser.Parser import com.jaytux.simd.data.IntrinsicInstructions.xed import kotlinx.coroutines.coroutineScope import kotlinx.datetime.* @@ -84,6 +85,7 @@ object Loader { suspend fun loadXml(xmlFile: String): XmlData = coroutineScope { val xml = Ksoup.parseXml(File(xmlFile).readText(Charsets.UTF_8)) + Parser.xmlParser() val cppTypes = mutableSetOf() val techs = mutableSetOf() @@ -158,13 +160,13 @@ object Loader { args += argName to type } - val desc = it.getElementsByTag("description").firstOrNull()?.text() + val desc = it.getElementsByTag("description").firstOrNull()?.wholeText()?.trim() if(desc == null) { errors += "Missing description element for intrinsic $name" return@forEachIndexed } - val op = it.getElementsByTag("operation").firstOrNull()?.text() + val op = it.getElementsByTag("operation").firstOrNull()?.wholeText()?.trim() val insn = mutableListOf>() it.getElementsByTag("instruction").forEachIndexed { i, ins -> diff --git a/api/src/main/kotlin/server/Endpoints.kt b/api/src/main/kotlin/server/Endpoints.kt index e2a65b8..15dcd66 100644 --- a/api/src/main/kotlin/server/Endpoints.kt +++ b/api/src/main/kotlin/server/Endpoints.kt @@ -4,13 +4,17 @@ import com.jaytux.simd.data.* import com.jaytux.simd.server.RouteCache.register import io.ktor.http.* import io.ktor.http.content.* +import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* import kotlinx.datetime.LocalDate import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import org.jetbrains.exposed.dao.UUIDEntity +import org.jetbrains.exposed.dao.id.EntityID +import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.like -import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import java.util.* @@ -60,32 +64,46 @@ fun Routing.installGetAll() { fun Routing.installSearch() { getPagedRequest("/search", "Search for intrinsics matching certain filters", { 100 }, { IntrinsicSummary(it[Intrinsics.id].value, it[Intrinsics.mnemonic]) }) { + fun resolveAny(key: String, finder: (String) -> SizedIterable): List>? { + return call.request.queryParameters[key]?.let { + try { + val list = Json.decodeFromString>(it) + list.map { + finder(it).firstOrNull()?.id + ?: throw HttpError("Unknown $key: ${list.joinToString(", ")}") + } + } + catch(e: HttpError) { + throw e + } + catch(e: Exception) { + throw HttpError("Malformed $key parameter: $it") + } + } + } + val name = call.request.queryParameters["name"] val returnType = call.request.queryParameters["return"]?.let { CppType.find { CppTypes.name eq it }.firstOrNull() ?: throw HttpError("Unknown return type: $it") } - val cpuid = call.request.queryParameters["cpuid"]?.let { - CPUID.find { CPUIDs.name eq it }.firstOrNull() - ?: throw HttpError("Unknown CPUID: $it") - } - val tech = call.request.queryParameters["tech"]?.let { - Tech.find { Techs.name eq it }.firstOrNull() - ?: throw HttpError("Unknown tech: $it") - } - val category = call.request.queryParameters["category"]?.let { - Category.find { Categories.name eq it }.firstOrNull() - ?: throw HttpError("Unknown category: $it") - } + val anyCpuid = resolveAny("cpuid") { CPUID.find { CPUIDs.name eq it } } + val anyTech = resolveAny("tech") { Tech.find { Techs.name eq it } } + val anyCat = resolveAny("category") { Category.find { Categories.name eq it } } val desc = call.request.queryParameters["desc"] - var results = Intrinsics.selectAll() - name?.let { results = results.where { Intrinsics.mnemonic like "%$it%" } } - returnType?.let { results = results.where { Intrinsics.returnType eq it.id } } - cpuid?.let { results = results.where { Intrinsics.cpuid eq it.id } } - tech?.let { results = results.where { Intrinsics.tech eq it.id } } - category?.let { results = results.where { Intrinsics.category eq it.id } } - desc?.let { results = results.where { Intrinsics.description like "%$it%" } } + var results = Intrinsics.selectAll().where { + val build = listOf( + name?.let { Intrinsics.mnemonic like "%$it%" }, + returnType?.let { Intrinsics.returnType eq it.id }, + anyCpuid?.let { Intrinsics.cpuid inList it }, + anyTech?.let { Intrinsics.tech inList it }, + anyCat?.let { Intrinsics.category inList it }, + desc?.let { Intrinsics.description like "%$it%" } + ).filterNotNull() + + build.fold(Op.TRUE as Op, { acc, op -> op and acc }) + } results.orderAsc(Intrinsics.mnemonic) } diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/Alegreya-Italic-VariableFont_wght.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/Alegreya-Italic-VariableFont_wght.ttf deleted file mode 100644 index 6acf196..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/Alegreya-Italic-VariableFont_wght.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/Alegreya-VariableFont_wght.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/Alegreya-VariableFont_wght.ttf deleted file mode 100644 index 8c07df8..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/Alegreya-VariableFont_wght.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/OFL.txt b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/OFL.txt deleted file mode 100644 index 0042c66..0000000 --- a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/OFL.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2011 The Alegreya Project Authors (https://github.com/huertatipografica/Alegreya) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -https://openfontlicense.org - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/README.txt b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/README.txt deleted file mode 100644 index 6c8e9b0..0000000 --- a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/README.txt +++ /dev/null @@ -1,75 +0,0 @@ -Alegreya Variable Font -====================== - -This download contains Alegreya as both variable fonts and static fonts. - -Alegreya is a variable font with this axis: - wght - -This means all the styles are contained in these files: - Alegreya/Alegreya-VariableFont_wght.ttf - Alegreya/Alegreya-Italic-VariableFont_wght.ttf - -If your app fully supports variable fonts, you can now pick intermediate styles -that aren’t available as static fonts. Not all apps support variable fonts, and -in those cases you can use the static font files for Alegreya: - Alegreya/static/Alegreya-Regular.ttf - Alegreya/static/Alegreya-Medium.ttf - Alegreya/static/Alegreya-SemiBold.ttf - Alegreya/static/Alegreya-Bold.ttf - Alegreya/static/Alegreya-ExtraBold.ttf - Alegreya/static/Alegreya-Black.ttf - Alegreya/static/Alegreya-Italic.ttf - Alegreya/static/Alegreya-MediumItalic.ttf - Alegreya/static/Alegreya-SemiBoldItalic.ttf - Alegreya/static/Alegreya-BoldItalic.ttf - Alegreya/static/Alegreya-ExtraBoldItalic.ttf - Alegreya/static/Alegreya-BlackItalic.ttf - -Get started ------------ - -1. Install the font files you want to use - -2. Use your app's font picker to view the font family and all the -available styles - -Learn more about variable fonts -------------------------------- - - https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts - https://variablefonts.typenetwork.com - https://medium.com/variable-fonts - -In desktop apps - - https://theblog.adobe.com/can-variable-fonts-illustrator-cc - https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts - -Online - - https://developers.google.com/fonts/docs/getting_started - https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide - https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts - -Installing fonts - - MacOS: https://support.apple.com/en-us/HT201749 - Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux - Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows - -Android Apps - - https://developers.google.com/fonts/docs/android - https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts - -License -------- -Please read the full license text (OFL.txt) to understand the permissions, -restrictions and requirements for usage, redistribution, and modification. - -You can use them in your products & projects – print or digital, -commercial or otherwise. - -This isn't legal advice, please consider consulting a lawyer and see the full -license for all details. diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Black.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Black.ttf deleted file mode 100644 index 846ec96..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Black.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-BlackItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-BlackItalic.ttf deleted file mode 100644 index ea26069..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-BlackItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-BoldItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-BoldItalic.ttf deleted file mode 100644 index 1876276..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-BoldItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-ExtraBold.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-ExtraBold.ttf deleted file mode 100644 index 8efdcd0..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-ExtraBold.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-ExtraBoldItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-ExtraBoldItalic.ttf deleted file mode 100644 index 7c9d661..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-ExtraBoldItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-MediumItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-MediumItalic.ttf deleted file mode 100644 index 1425d18..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-MediumItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Regular.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Regular.ttf deleted file mode 100644 index 3270a9f..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Regular.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-SemiBold.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-SemiBold.ttf deleted file mode 100644 index b941c35..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-SemiBold.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-SemiBoldItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-SemiBoldItalic.ttf deleted file mode 100644 index cc93f0c..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-SemiBoldItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Bold.ttf b/frontend/composeApp/src/commonMain/composeResources/font/AlegreyaBold.ttf similarity index 100% rename from frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Bold.ttf rename to frontend/composeApp/src/commonMain/composeResources/font/AlegreyaBold.ttf diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Italic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/AlegreyaItalic.ttf similarity index 100% rename from frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Italic.ttf rename to frontend/composeApp/src/commonMain/composeResources/font/AlegreyaItalic.ttf diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Medium.ttf b/frontend/composeApp/src/commonMain/composeResources/font/AlegreyaMedium.ttf similarity index 100% rename from frontend/composeApp/src/commonMain/composeResources/font/Alegreya/static/Alegreya-Medium.ttf rename to frontend/composeApp/src/commonMain/composeResources/font/AlegreyaMedium.ttf diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Bold.ttf b/frontend/composeApp/src/commonMain/composeResources/font/RobotoMonoBold.ttf similarity index 100% rename from frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Bold.ttf rename to frontend/composeApp/src/commonMain/composeResources/font/RobotoMonoBold.ttf diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Italic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/RobotoMonoItalic.ttf similarity index 100% rename from frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Italic.ttf rename to frontend/composeApp/src/commonMain/composeResources/font/RobotoMonoItalic.ttf diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Medium.ttf b/frontend/composeApp/src/commonMain/composeResources/font/RobotoMonoMedium.ttf similarity index 100% rename from frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Medium.ttf rename to frontend/composeApp/src/commonMain/composeResources/font/RobotoMonoMedium.ttf diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/LICENSE.txt b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/LICENSE.txt deleted file mode 100644 index 75b5248..0000000 --- a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/README.txt b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/README.txt deleted file mode 100644 index ebe9bf2..0000000 --- a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/README.txt +++ /dev/null @@ -1,77 +0,0 @@ -Roboto Mono Variable Font -========================= - -This download contains Roboto Mono as both variable fonts and static fonts. - -Roboto Mono is a variable font with this axis: - wght - -This means all the styles are contained in these files: - Roboto_Mono/RobotoMono-VariableFont_wght.ttf - Roboto_Mono/RobotoMono-Italic-VariableFont_wght.ttf - -If your app fully supports variable fonts, you can now pick intermediate styles -that aren’t available as static fonts. Not all apps support variable fonts, and -in those cases you can use the static font files for Roboto Mono: - Roboto_Mono/static/RobotoMono-Thin.ttf - Roboto_Mono/static/RobotoMono-ExtraLight.ttf - Roboto_Mono/static/RobotoMono-Light.ttf - Roboto_Mono/static/RobotoMono-Regular.ttf - Roboto_Mono/static/RobotoMono-Medium.ttf - Roboto_Mono/static/RobotoMono-SemiBold.ttf - Roboto_Mono/static/RobotoMono-Bold.ttf - Roboto_Mono/static/RobotoMono-ThinItalic.ttf - Roboto_Mono/static/RobotoMono-ExtraLightItalic.ttf - Roboto_Mono/static/RobotoMono-LightItalic.ttf - Roboto_Mono/static/RobotoMono-Italic.ttf - Roboto_Mono/static/RobotoMono-MediumItalic.ttf - Roboto_Mono/static/RobotoMono-SemiBoldItalic.ttf - Roboto_Mono/static/RobotoMono-BoldItalic.ttf - -Get started ------------ - -1. Install the font files you want to use - -2. Use your app's font picker to view the font family and all the -available styles - -Learn more about variable fonts -------------------------------- - - https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts - https://variablefonts.typenetwork.com - https://medium.com/variable-fonts - -In desktop apps - - https://theblog.adobe.com/can-variable-fonts-illustrator-cc - https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts - -Online - - https://developers.google.com/fonts/docs/getting_started - https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide - https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts - -Installing fonts - - MacOS: https://support.apple.com/en-us/HT201749 - Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux - Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows - -Android Apps - - https://developers.google.com/fonts/docs/android - https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts - -License -------- -Please read the full license text (LICENSE.txt) to understand the permissions, -restrictions and requirements for usage, redistribution, and modification. - -You can use them in your products & projects – print or digital, -commercial or otherwise. - -This isn't legal advice, please consider consulting a lawyer and see the full -license for all details. diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/RobotoMono-Italic-VariableFont_wght.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/RobotoMono-Italic-VariableFont_wght.ttf deleted file mode 100644 index 1a4d694..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/RobotoMono-Italic-VariableFont_wght.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/RobotoMono-VariableFont_wght.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/RobotoMono-VariableFont_wght.ttf deleted file mode 100644 index fc02de4..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/RobotoMono-VariableFont_wght.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-BoldItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-BoldItalic.ttf deleted file mode 100644 index e9c4802..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-BoldItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ExtraLight.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ExtraLight.ttf deleted file mode 100644 index 9ff7ac6..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ExtraLight.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ExtraLightItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ExtraLightItalic.ttf deleted file mode 100644 index 9e962d4..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ExtraLightItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Light.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Light.ttf deleted file mode 100644 index 4893662..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Light.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-LightItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-LightItalic.ttf deleted file mode 100644 index 39b7250..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-LightItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-MediumItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-MediumItalic.ttf deleted file mode 100644 index 70a1a75..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-MediumItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Regular.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Regular.ttf deleted file mode 100644 index 6df2b25..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Regular.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-SemiBold.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-SemiBold.ttf deleted file mode 100644 index 82ddc82..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-SemiBold.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-SemiBoldItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-SemiBoldItalic.ttf deleted file mode 100644 index 15b0846..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-SemiBoldItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Thin.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Thin.ttf deleted file mode 100644 index aeb997b..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-Thin.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ThinItalic.ttf b/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ThinItalic.ttf deleted file mode 100644 index ab99e08..0000000 Binary files a/frontend/composeApp/src/commonMain/composeResources/font/Roboto_Mono/static/RobotoMono-ThinItalic.ttf and /dev/null differ diff --git a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/client/Client.kt b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/client/Client.kt index 125d8f8..bc42c61 100644 --- a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/client/Client.kt +++ b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/client/Client.kt @@ -25,7 +25,7 @@ import kotlin.uuid.Uuid @OptIn(ExperimentalUuidApi::class) object Client { val httpClient: HttpClient by lazy { getKtorClient{ install(ContentNegotiation) { json() } } } - val baseUrl = "https://simd.jaytux.com/api" + val baseUrl = "http://localhost:42024" // ""https://simd.jaytux.com/api" object UUIDSerializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING) @@ -132,7 +132,7 @@ object Client { private suspend inline fun getPaginatedQuery(url: String, crossinline addParams: URLBuilder.() -> Unit = {}): OrError> { val loader: suspend (Long?) -> OrError> = { page: Long? -> - makeBasicRequest>(url + (if (page != null) "/$page" else "")) { + makeBasicRequest>(url) { addParams() if(page != null) parameters.append("page", "$page") } diff --git a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/theme/Type.kt b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/theme/Type.kt index 4821b3e..5755020 100644 --- a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/theme/Type.kt +++ b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/theme/Type.kt @@ -5,23 +5,30 @@ import androidx.compose.material3.Typography import androidx.compose.runtime.Composable import androidx.compose.ui.text.font.FontFamily import com.jaytux.simd.frontend.App -import frontend.composeapp.generated.resources.Alegreya +import frontend.composeapp.generated.resources.* import frontend.composeapp.generated.resources.Res -import frontend.composeapp.generated.resources.Roboto_Mono -import frontend.composeapp.generated.resources.allFontResources import org.jetbrains.compose.resources.Font @Composable -fun Roboto() = FontFamily(Font(Res.font.Roboto_Mono)) +fun Roboto() = FontFamily( + Font(Res.font.RobotoMonoMedium), + Font(Res.font.RobotoMonoItalic), + Font(Res.font.RobotoMonoBold), +) @Composable -fun Alegreya() = FontFamily(Font(Res.font.Alegreya)) +fun Alegreya() = FontFamily( + Font(Res.font.AlegreyaMedium), + Font(Res.font.AlegreyaItalic), + Font(Res.font.AlegreyaBold), +) @Composable fun buildTypography(): Typography { val baseline = MaterialTheme.typography val displayFontFamily = Alegreya() val bodyFontFamily = Roboto() + val AppTypography = Typography( displayLarge = baseline.displayLarge.copy(fontFamily = displayFontFamily), displayMedium = baseline.displayMedium.copy(fontFamily = displayFontFamily), diff --git a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/DataState.kt b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/DataState.kt index 4b9c32c..dcb24c7 100644 --- a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/DataState.kt +++ b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/DataState.kt @@ -74,6 +74,8 @@ class DataState( private var _filterJob: Job? = null private val _filterData = mutableStateOf(listOf()) val filterData = _filterData.immutable() + val filterName = mutableStateOf("") + val filterDesc = mutableStateOf("") init { _filterJob = scope.loadAll( @@ -121,16 +123,22 @@ class DataState( fun toggleTech(idx: Int) { if (idx in _selectedTechs.value) _selectedTechs.value -= idx else _selectedTechs.value += idx + + doFilter() } fun toggleCategory(idx: Int) { if (idx in _selectedCats.value) _selectedCats.value -= idx else _selectedCats.value += idx + + doFilter() } fun toggleCpuid(idx: Int) { if (idx in _selectedCpuids.value) _selectedCpuids.value -= idx else _selectedCpuids.value += idx + + doFilter() } fun setReturn(type: String) { @@ -152,17 +160,17 @@ class DataState( } } - fun doFilter(name: String, desc: String) { + fun doFilter() { _filterJob?.cancel() _filterJob = scope.loadAll( client = { Client.getSearch( - name = name.ifBlank { null }, + name = filterName.value.ifBlank { null }, returnT = filterByType, cpuid = _selectedCpuids.value.map { cpuid.value[it] }, tech = _selectedTechs.value.map { techs.value[it] }, category = _selectedCats.value.map { categories.value[it] }, - desc = desc.ifBlank { null } + desc = filterDesc.value.ifBlank { null } ) }, onError = addSnackBar, diff --git a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/Widgets.kt b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/Widgets.kt index a648121..e80e9da 100644 --- a/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/Widgets.kt +++ b/frontend/composeApp/src/commonMain/kotlin/com/jaytux/simd/frontend/ui/Widgets.kt @@ -23,6 +23,7 @@ import com.composables.icons.lucide.* import com.jaytux.simd.frontend.OrError import com.jaytux.simd.frontend.client.Client import com.jaytux.simd.frontend.client.Loader +import com.jaytux.simd.frontend.theme.buildTypography import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import kotlin.uuid.ExperimentalUuidApi @@ -74,8 +75,8 @@ fun Checkable(checked: Boolean, onClick: () -> Unit, content: @Composable () -> } @Composable -fun Indented(content: @Composable ColumnScope.() -> Unit) { - Row(Modifier.padding(start = 20.dp)) { +fun Indented(steps: Int = 1, content: @Composable ColumnScope.() -> Unit) { + Row(Modifier.padding(start = (steps * 20).dp)) { Column { content() } @@ -189,6 +190,8 @@ fun IntrinsicCard( shadowElevation = 2.dp, shape = MaterialTheme.shapes.medium ) { + val style = MaterialTheme.typography.labelMedium + Column(Modifier.padding(10.dp)) { Text(summary.name, style = MaterialTheme.typography.headlineSmall) if(expanded) { @@ -198,19 +201,23 @@ fun IntrinsicCard( }) { Text("Synopsis") Indented { - Text("${it.returnType} ${it.name}(${it.params.joinToString(", ") { p -> "${p.type} ${p.name}" }}) [${it.category}]") - it.cpuid?.let { cpuid -> Text("CPUID: $cpuid") } + Row { + Text("${it.returnType} ${it.name}(${it.params.joinToString(", ") { p -> "${p.type} ${p.name}" }})") + Text(" [${it.category}]", color = LocalContentColor.current.copy(alpha = 0.4f)) + } + it.cpuid?.let { cpuid -> Text("CPUID: $cpuid", style = style) } } Spacer(Modifier.height(5.dp)) Text("Description") Indented { - Text(it.description) + Text(it.description, style = style) it.instructions?.let { insn -> + Spacer(Modifier.height(2.dp)) Text("Instruction(s):") Indented { insn.forEach { ins -> - Text("${ins.mnemonic} ${ins.form ?: ""}") + Text("${ins.mnemonic} ${ins.form ?: ""}", style = style) } } } @@ -221,7 +228,13 @@ fun IntrinsicCard( Text("Operations") Indented { Surface(Modifier.fillMaxWidth(), color = MaterialTheme.colorScheme.surfaceDim) { - Text(ops) + Column { + ops.split("\n").forEach { op -> + val depth = op.takeWhile { it == '\t' }.length + val text = op.drop(depth) + Indented(depth) { Text(text, style = style) } + } + } } } } @@ -234,26 +247,27 @@ fun IntrinsicCard( Row { Column { Text("Architecture") - perf.forEach { p -> Text(p.platform) } + perf.forEach { p -> Text(p.platform, style = style) } } Spacer(Modifier.width(20.dp)) Column { Text("Latency (cycles)") - perf.forEach { p -> Text(p.latency?.toString() ?: "-") } + perf.forEach { p -> Text(p.latency?.toString() ?: "-", style = style) } } Spacer(Modifier.width(20.dp)) Column { Text("Throughput (CPI)") - perf.forEach { p -> Text(p.throughput?.toString() ?: "-") } + perf.forEach { p -> Text(p.throughput?.toString() ?: "-", style = style) } } } } } - } ?: Text("Loading details...", style = MaterialTheme.typography.bodySmall) + } + if(details == null) Text("Loading details...", style = MaterialTheme.typography.bodySmall) } } } @@ -263,8 +277,8 @@ fun IntrinsicCard( @OptIn(ExperimentalUuidApi::class) @Composable fun ColumnScope.IntrinsicColumn(data: DataState) { - var nameFilter by remember { mutableStateOf("") } - var descFilter by remember { mutableStateOf("") } + var nameFilter by data.filterName + var descFilter by data.filterDesc var retFilter by remember { mutableStateOf("") } val intrinsicState by data.summaryState val intrinsicList by data.filterData @@ -274,7 +288,7 @@ fun ColumnScope.IntrinsicColumn(data: DataState) { var expandFilter by remember { mutableStateOf(false) } OutlinedTextField( - nameFilter, { nameFilter = it; data.doFilter(nameFilter, descFilter) }, + nameFilter, { nameFilter = it; data.doFilter() }, Modifier.fillMaxWidth(), leadingIcon = { Icon(Lucide.SearchCode, "Search") }, label = { Text("Filter by intrinsic name...") } @@ -324,7 +338,7 @@ fun ColumnScope.IntrinsicColumn(data: DataState) { OutlinedTextField( descFilter, - { descFilter = it; data.doFilter(nameFilter, descFilter) }, + { descFilter = it; data.doFilter() }, Modifier.fillMaxWidth(), label = { Text("Filter by description...") }) } @@ -332,8 +346,15 @@ fun ColumnScope.IntrinsicColumn(data: DataState) { if(intrinsicList.isEmpty()) { Box(Modifier.fillMaxSize()) { Column(Modifier.align(Alignment.Center)) { - Text("Loading intrinsics...") - Spinner(intrinsicState) + when(intrinsicState) { + Loader.progressFinished -> Text("No results for your query") + Loader.progressFailed -> { + Text("An error occurred while processing your query") + } + else -> { + Spinner(intrinsicState) + } + } } } } diff --git a/frontend/composeApp/src/wasmJsMain/kotlin/com/jaytux/simd/frontend/MainView.wasmJs.kt b/frontend/composeApp/src/wasmJsMain/kotlin/com/jaytux/simd/frontend/MainView.wasmJs.kt index 104417a..25ce870 100644 --- a/frontend/composeApp/src/wasmJsMain/kotlin/com/jaytux/simd/frontend/MainView.wasmJs.kt +++ b/frontend/composeApp/src/wasmJsMain/kotlin/com/jaytux/simd/frontend/MainView.wasmJs.kt @@ -2,13 +2,34 @@ package com.jaytux.simd.frontend import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.CornerSize +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp import com.jaytux.simd.frontend.ui.DataState +import com.jaytux.simd.frontend.ui.FilterColumn +import com.jaytux.simd.frontend.ui.IntrinsicColumn import com.jaytux.simd.frontend.ui.topBar @Composable actual fun mainView(data: DataState) = Row { - Column { } - Column { } + Surface( + Modifier.weight(0.25f).fillMaxSize(), + tonalElevation = 3.dp, + shadowElevation = 3.dp, + color = MaterialTheme.colorScheme.primary, + shape = MaterialTheme.shapes.medium.copy(topStart = CornerSize(0.dp), topEnd = CornerSize(0.dp)) + ) { + Column(Modifier.padding(5.dp)) { + FilterColumn(data) + } + } + Column(Modifier.weight(0.66f).padding(15.dp)) { + IntrinsicColumn(data) + } } \ No newline at end of file