diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/icon.png b/.idea/icon.png deleted file mode 100644 index deda69c..0000000 Binary files a/.idea/icon.png and /dev/null differ diff --git a/.idea/icon.svg b/.idea/icon.svg new file mode 100644 index 0000000..df15380 --- /dev/null +++ b/.idea/icon.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 6d0ee1c..5815a4a 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README-zh-CN.md b/README-zh-CN.md index 76e6164..d511454 100644 --- a/README-zh-CN.md +++ b/README-zh-CN.md @@ -5,7 +5,7 @@ [](https://t.me/HighCapable_Dev) [](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf) - + 一个 Android 响应式 UI 构建工具。 @@ -18,199 +18,30 @@ ## 这是什么 -这是一个 Android 响应式 UI 构建工具,它的设计聚焦于 **实时代码构建 UI**。 +`Hikage` (发音 /ˈhɪkɑːɡeɪ/),这是一个 Android 响应式 UI 构建工具,它的设计聚焦于 **实时代码构建 UI**。 -名称取自 「BanG Dream It's MyGO!!!!!」 中的原创歌曲《春日影》(Haru**hikage**)。 +项目图标由 [MaiTungTM](https://github.com/Lagrio) 设计,名称取自 「BanG Dream It's MyGO!!!!!」 中的原创歌曲《春日影》(Haru**hikage**)。 为什么要... - + - **なんで春日影レイアウト使いの?** +**なんで春日影レイアウト使いの?** 不同于 Jetpack Compose 的声明式 UI,Hikage 专注于 Android 原生平台,它的设计目标是为了让开发者能够快速构建 UI 并可直接支持 Android 原生组件。 -Hikage 只是一个 UI 构建工具,自身并不提供任何 UI 组件。 +**Hikage 只是一个 UI 构建工具,自身并不提供任何 UI 组件**。 拒绝重复造轮子,我们的方案始终是兼容与高效,现在你可以抛弃 ViewBinding 和 XML 甚至是 `findViewById`,直接来尝试使用代码布局吧。 -Android View 中的属性将配合 Gradle 插件实现自动生成,你可以像在 XML 一样去使用它, -而不需要考虑在代码中如何完成复杂的属性设置,特别是一些第三方库并未对它们的自定义 View 提供代码中的属性动态修改。 +`Hikage` 配合我们的另一个项目 [BetterAndroid](https://github.com/BetterAndroid/BetterAndroid) 使用效果更佳,同时 `Hikage` 自身将自动引用 +`BetterAndroid` 相关依赖作为核心内容。 -## 效果展示 +## 开始使用 -> 原始布局 - -```xml - - - - - - -``` - -> 使用 Hikage - -```kotlin -// 使用 Hikage 构建布局,需要有一个 UI Context -val context: Context -// 确保 Context 为 UI Context -if (!context.isUiContext) return -// 开始构建布局,请注意确保 context 参数已初始化 -// 根据 Android 原生组件特性,布局构建后属性 (`attrs`) 将固定,无法动态修改 -val hikage = Hikageable( - context = context, - // 你还可以自定义每个 View 被创建后的操作 - onViewCreated = { name, view -> - // ... - } -) { - LinearLayout( - attrs = { - android.layout_width = MATCH_PARENT - android.layout_height = MATCH_PARENT - android.orientation = VERTICAL - android.padding = 16.dp - }, - // 你可以手动指定布局参数 - lpparams = { - gravity = Gravity.CENTER - } - ) { - TextView( - // 使用字符串形式设置 ID,可以使用大驼峰、小驼峰或下划线形式,在生成时将被转换为小驼峰形式 - id = "text_view", - // 你可以直接使用 attrs 来设置属性,无需考虑它们属于谁 - attrs = { - android.layout_width = WRAP_CONTENT - android.layout_height = WRAP_CONTENT - android.text = "Hello, World!" - android.textSize = 16.sp - android.textColor = Color.BLACK - android.layout_marginTop = 16.dp - android.layout_marginStart = 16.dp - android.layout_marginEnd = 16.dp - android.layout_marginBottom = 16.dp - android.gravity = Gravity.CENTER - // 或者使用字符串形式设置属性 (注意没有拼写检查) - namespace("android") { - set("id", R.id.text_view) - set("layout_margin", 16.dp) - set("layout_gravity", Gravity.CENTER) - // ... - } - }, - // 你也可以手动指定布局参数 - lpparams = { - gravity = Gravity.CENTER - }, - // 执行初始化后的操作 - // 你也可以手动设置属性 - initialize = { - text = "Hello, World!" - textSize = 16f - setTextColor(Color.BLACK) - // 或者更多操作 - doOnLayout { - // ... - } - } - ) - // 使用第三方 View - View( - id = "button", - attrs = { - android.layout_width = WRAP_CONTENT - android.layout_height = WRAP_CONTENT - android.text = "Click Me!" - android.textSize = 16.sp - android.textColor = Color.WHITE - android.backgroundTint = Color.RED - android.layout_marginTop = 16.dp - android.layout_marginStart = 16.dp - android.layout_marginEnd = 16.dp - android.layout_marginBottom = 16.dp - android.gravity = Gravity.CENTER - } - ) - } -} -// 获取根布局 -val root = hikage.root -// 你还可以将其转换为第一个布局的类型,等价于 hikage.root as LinearLayout -// 得益于 Kotlin 的特性,直接使用 Hikageable(...) { ... }.rootAsType() 可以不需要填写泛型 -val root = hikage.rootAsType() -// 设置到 Activity 上 -setContentView(root) -// 获取构建的布局内部组件 (第一种方案) -val textView = hikage.textView -val button = hikage.button -// 获取构建的布局内部组件 (第二种方案) -val textView = hikage.get("text_view") -val button = hikage.get("button") -``` - -## 使用 Android Studio 预览 - -不同于 XML,Hikage 不支持实时预览,但你可以继承于 Hikage 提供的 `HikagePreview` 在其中传入你的布局,然后在 Android Studio 右侧窗格中查看预览。 - -你还可以在代码中使用 `isInEditMode` 来避免在预览模式中展示无法显示的实际逻辑代码。 - -```kotlin -class MyPreview(context: Context, attrs: AttributeSet?) : HikagePreview(context, attrs) { - - override fun onPreview(): Hikage { - // 返回你的布局 - return Hikageable { - Button( - attrs = { - android.layout_width = WRAP_CONTENT - android.layout_height = WRAP_CONTENT - android.text = "Click Me!" - } - ) - } - } -} -``` - -注意 `HikagePreview` 仅用于预览,不应该在实际代码中使用,否则会抛出异常。 - -Hikage 可能会有计划支持 Java,但依然推荐使用 Kotlin。 - -## WIP - -该项目仍在开发中,如果您有任何建议或反馈,请随时开启 `issue` 或 PR。 +[点击这里](https://betterandroid.github.io/Hikage/zh-cn) 前往文档页面查看更多详细教程和内容。 ## 项目推广 @@ -227,6 +58,10 @@ Hikage 可能会有计划支持 Java,但依然推荐使用 Kotlin。  +## 第三方开源使用声明 + +- [AndroidHiddenApiBypass](https://github.com/LSPosed/AndroidHiddenApiBypass) + ## 许可证 - [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) diff --git a/README.md b/README.md index f04e66f..bbc26a3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [](https://t.me/HighCapable_Dev) [](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf) - + An Android responsive UI building tool. @@ -18,206 +18,33 @@ This project belongs to the above-mentioned organization, **click the link above ## What's this -This is an Android responsive UI build tool designed to focus on **Real-time code building UI**. +`Hikage` (Pronunciation /ˈhɪkɑːɡeɪ/), this is an Android responsive UI build tool designed to focus on **Real-time code building UI**. -The name is taken from the original song "Haru**hikage**" in "BanG Dream It's MyGO!!!!!". +The project icon was designed by [MaiTungTM](https://github.com/Lagrio), +the name is taken from the original song "Haru**hikage**" in "BanG Dream It's MyGO!!!!!". Why... - + - **なんで春日影レイアウト使いの?** +**なんで春日影レイアウト使いの?** Unlike Jetpack Compose's declarative UI, Hikage focuses on Android native platforms, and its design goal is to enable developers to quickly build UIs and directly support Android native components. -Hikage is just a UI build tool and does not provide any UI components themselves. +**Hikage is just a UI build tool and does not provide any UI components themselves**. Rejecting duplicate wheels, our solution is always compatible and efficient. Now you can abandon ViewBinding and XML and even `findViewById` and try to use the code layout directly. -The properties in Android view will be automatically generated with the Gradle plugin, and you can use it like in XML. +`Hikage` works better with another project [BetterAndroid](https://github.com/BetterAndroid/BetterAndroid) and +`Hikage` itself will automatically reference the `BetterAndroid` related dependencies as the core content. -It does not need to consider how to complete complex attribute settings in the code, especially some third-party libraries do not provide dynamic -modifications to their custom views. +## Get Started -## Effects - -> Original layout - -```xml - - - - - - -``` - -> Using Hikage - -```kotlin -// Using Hikage to build a layout requires a UI Context. -val context: Context -// Make sure the Context is UI Context. -if (!context.isUiContext) return -// Start building the layout, be careful to make sure the context parameter is initialized. -// According to the Android native component features, -// the attributes (`attrs`) after layout construction will be fixed and cannot be modified dynamically. -val hikage = Hikageable( - context = context, - // You can also customize the actions after each view is created. - onViewCreated = { name, view -> - // ... - } -) { - LinearLayout( - attrs = { - android.layout_width = MATCH_PARENT - android.layout_height = MATCH_PARENT - android.orientation = VERTICAL - android.padding = 16.dp - }, - // You can manually specify layout parameters. - lpparams = { - gravity = Gravity.CENTER - } - ) { - TextView( - // Set the ID using string form, you can use large camel, small camel, - // or underscore form, which will be converted to small camel form when generated. - id = "text_view", - // You can set properties directly using attrs without considering who they belong to. - attrs = { - android.layout_width = WRAP_CONTENT - android.layout_height = WRAP_CONTENT - android.text = "Hello, World!" - android.textSize = 16.sp - android.textColor = Color.BLACK - android.layout_marginTop = 16.dp - android.layout_marginStart = 16.dp - android.layout_marginEnd = 16.dp - android.layout_marginBottom = 16.dp - android.gravity = Gravity.CENTER - // Or use string form to set properties (note that there is no spelling check). - namespace("android") { - set("id", R.id.text_view) - set("layout_margin", 16.dp) - set("layout_gravity", Gravity.CENTER) - // ... - } - }, - // You can also manually specify layout parameters. - lpparams = { - gravity = Gravity.CENTER - }, - // Perform initialization operations. - // You can also manually set properties. - initialize = { - text = "Hello, World!" - textSize = 16f - setTextColor(Color.BLACK) - // Or more operations. - doOnLayout { - // ... - } - } - ) - // Use third-party views. - View( - id = "button", - attrs = { - android.layout_width = WRAP_CONTENT - android.layout_height = WRAP_CONTENT - android.text = "Click Me!" - android.textSize = 16.sp - android.textColor = Color.WHITE - android.backgroundTint = Color.RED - android.layout_marginTop = 16.dp - android.layout_marginStart = 16.dp - android.layout_marginEnd = 16.dp - android.layout_marginBottom = 16.dp - android.gravity = Gravity.CENTER - } - ) - } -} -// Get the root layout. -val root = hikage.root -// You can also convert it to the type of the first layout, equivalent to hikage.root as LinearLayout. -// Thanks to Kotlin's features, using Hikageable(...) { ... }.rootAsType() directly does not require filling in generics. -val root = hikage.rootAsType() -// Set to Activity. -setContentView(root) -// Get the built layout internal components (first solution). -val textView = hikage.textView -val button = hikage.button -// Get the built layout internal components (second solution). -val textView = hikage.get("text_view") -val button = hikage.get("button") -``` - -## Preview with Android Studio - -Unlike XML, Hikage does not support live previews, but you can inherit the `HikagePreview` provided by Hikage, -and pass in your layout, and then view the preview in the pane on the right of Android Studio. - -You can also use `isInEditMode` in your code to avoid displaying actual logical code that cannot be displayed in preview mode. - -```kotlin -class MyPreview(context: Context, attrs: AttributeSet?) : HikagePreview(context, attrs) { - - override fun onPreview(): Hikage { - // Return to your layout. - return Hikageable { - Button( - attrs = { - android.layout_width = WRAP_CONTENT - android.layout_height = WRAP_CONTENT - android.text = "Click Me!" - } - ) - } - } -} -``` - -Note `HikagePreview` is for preview only and should not be used in actual code, otherwise an exception will be thrown. - -Hikage may have plans to support Java, but Kotlin is still recommended. - -## WIP - -This project is still a work in progress. If you have any suggestions or feedback, feel free to open an issue or a pull request. +[Click here](https://betterandroid.github.io/Hikage/en) go to the documentation page for more detailed tutorials and content. ## Promotion @@ -234,6 +61,10 @@ This project is still a work in progress. If you have any suggestions or feedbac  +## Third-Party Open Source Usage Statement + +- [AndroidHiddenApiBypass](https://github.com/LSPosed/AndroidHiddenApiBypass) + ## License - [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index e42c27e..0000000 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 1bed29f..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp deleted file mode 100644 index 78e77cb..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp deleted file mode 100644 index 0376402..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp deleted file mode 100644 index 46c9772..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp deleted file mode 100644 index 7084430..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp deleted file mode 100644 index 2538bc9..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp deleted file mode 100644 index 4213927..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp deleted file mode 100644 index 9ddd2b5..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp deleted file mode 100644 index 0fad296..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp deleted file mode 100644 index 4927263..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp deleted file mode 100644 index 44dfd4d..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml deleted file mode 100644 index 2556f87..0000000 --- a/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml deleted file mode 100644 index 1949563..0000000 --- a/app/src/main/res/values/ic_launcher_background.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #FF639F70 - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index cdcaf69..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Hikage Demo - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml deleted file mode 100644 index d4a63ca..0000000 --- a/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 008ba31..077330e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,78 @@ +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import org.jetbrains.dokka.gradle.DokkaTask + plugins { autowire(libs.plugins.android.application) apply false autowire(libs.plugins.android.library) apply false autowire(libs.plugins.kotlin.android) apply false + autowire(libs.plugins.kotlin.jvm) apply false + autowire(libs.plugins.kotlin.ksp) apply false + autowire(libs.plugins.compose.compiler) apply false + autowire(libs.plugins.kotlin.dokka) apply false + autowire(libs.plugins.maven.publish) apply false +} + +libraryProjects { + afterEvaluate { + configure { + repositories { + val repositoryDir = gradle.gradleUserHomeDir + .resolve("highcapable-maven-repository") + .resolve("repository") + maven { + name = "HighCapableMavenReleases" + url = repositoryDir.resolve("releases").toURI() + } + maven { + name = "HighCapableMavenSnapShots" + url = repositoryDir.resolve("snapshots").toURI() + } + } + } + configure { + if (name != Libraries.HIKAGE_COMPILER) + configure(AndroidSingleVariantLibrary(publishJavadocJar = false)) + } + } + tasks.withType().configureEach { + val configuration = """{ "footerMessage": "Hikage | Apache-2.0 License | Copyright (C) 2019 HighCapable" }""" + pluginsMapConfiguration.set(mapOf("org.jetbrains.dokka.base.DokkaBase" to configuration)) + } + tasks.register("publishKDoc") { + group = "documentation" + dependsOn("dokkaHtml") + doLast { + val docsDir = rootProject.projectDir + .resolve("docs-source") + .resolve("dist") + .resolve("KDoc") + .resolve(project.name) + if (docsDir.exists()) docsDir.deleteRecursively() else docsDir.mkdirs() + layout.buildDirectory.dir("dokka/html").get().asFile.copyRecursively(docsDir) + } + } +} + +fun libraryProjects(action: Action) { + val libraries = listOf( + Libraries.HIKAGE_CORE, + Libraries.HIKAGE_EXTENSION, + Libraries.HIKAGE_EXTENSION_COMPOSE, + Libraries.HIKAGE_EXTENSION_BETTERANDROID, + Libraries.HIKAGE_COMPILER, + Libraries.HIKAGE_WIDGET_ANDROIDX, + Libraries.HIKAGE_WIDGET_MATERIAL + ) + allprojects { if (libraries.contains(name)) action.execute(this) } +} + +object Libraries { + const val HIKAGE_CORE = "hikage-core" + const val HIKAGE_EXTENSION = "hikage-extension" + const val HIKAGE_EXTENSION_COMPOSE = "hikage-extension-compose" + const val HIKAGE_EXTENSION_BETTERANDROID = "hikage-extension-betterandroid" + const val HIKAGE_COMPILER = "hikage-compiler" + const val HIKAGE_WIDGET_ANDROIDX = "hikage-widget-androidx" + const val HIKAGE_WIDGET_MATERIAL = "hikage-widget-material" } \ No newline at end of file diff --git a/docs-source/.gitignore b/docs-source/.gitignore new file mode 100644 index 0000000..8de9280 --- /dev/null +++ b/docs-source/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/src/.vuepress/.cache +/src/.vuepress/.temp +/dist \ No newline at end of file diff --git a/docs-source/.vscode/settings.json b/docs-source/.vscode/settings.json new file mode 100644 index 0000000..3b66410 --- /dev/null +++ b/docs-source/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/docs-source/build-dokka.sh b/docs-source/build-dokka.sh new file mode 100644 index 0000000..1809bdb --- /dev/null +++ b/docs-source/build-dokka.sh @@ -0,0 +1,2 @@ +cd .. +./gradlew :hikage-core:publishKDoc :hikage-extension:publishKDoc :hikage-extension-betterandroid:publishKDoc :hikage-extension-compose:publishKDoc \ No newline at end of file diff --git a/docs-source/package.json b/docs-source/package.json new file mode 100644 index 0000000..221d1f3 --- /dev/null +++ b/docs-source/package.json @@ -0,0 +1,17 @@ +{ + "name": "hikage_docs", + "license": "Apache-2.0", + "devDependencies": { + "@mr-hope/vuepress-plugin-copy-code": "^1.30.0", + "@vuepress/plugin-prismjs": "2.0.0-rc.0", + "@vuepress/plugin-search": "2.0.0-rc.0", + "@vuepress/plugin-shiki": "2.0.0-rc.0", + "vuepress": "2.0.0-rc.0" + }, + "scripts": { + "docs:dev": "vuepress dev src", + "docs:build": "vuepress build src", + "docs:build-gh-pages": "vuepress build src && touch dist/.nojekyll && sh build-dokka.sh" + }, + "dependencies": {} +} \ No newline at end of file diff --git a/docs-source/src/.vuepress/config.ts b/docs-source/src/.vuepress/config.ts new file mode 100644 index 0000000..5ae6bc7 --- /dev/null +++ b/docs-source/src/.vuepress/config.ts @@ -0,0 +1,64 @@ +import { defaultTheme } from 'vuepress'; +import { shikiPlugin } from '@vuepress/plugin-shiki'; +import { searchPlugin } from '@vuepress/plugin-search'; +import { navBarItems, sideBarItems, configs, pageLinkRefs } from './configs/template'; +import { env, markdown } from './configs/utils'; + +export default { + dest: configs.dev.dest, + port: configs.dev.port, + base: configs.website.base, + head: [['link', { rel: 'icon', href: configs.website.icon }]], + title: configs.website.title, + description: configs.website.locales['/en/'].description, + locales: configs.website.locales, + theme: defaultTheme({ + logo: configs.website.logo, + repo: configs.github.repo, + docsRepo: configs.github.repo, + docsBranch: configs.github.branch, + docsDir: configs.github.dir, + editLinkPattern: ':repo/edit/:branch/:path', + sidebar: sideBarItems, + sidebarDepth: 2, + locales: { + '/en/': { + navbar: navBarItems['/en/'], + selectLanguageText: 'English (US)', + selectLanguageName: 'English', + editLinkText: 'Edit this page on GitHub', + tip: 'Tips', + warning: 'Notice', + danger: 'Pay Attention', + }, + '/zh-cn/': { + navbar: navBarItems['/zh-cn/'], + selectLanguageText: '简体中文 (CN)', + selectLanguageName: '简体中文', + editLinkText: '在 GitHub 上编辑此页', + notFound: ['这里什么都没有', '我们怎么到这来了?', '这是一个 404 页面', '看起来我们进入了错误的链接'], + backToHome: '回到首页', + contributorsText: '贡献者', + lastUpdatedText: '上次更新', + tip: '小提示', + warning: '注意', + danger: '特别注意', + openInNewWindow: '在新窗口中打开', + toggleColorMode: '切换颜色模式' + } + }, + }), + extendsMarkdown: (md: markdownit) => { + markdown.injectLinks(md, env.dev ? pageLinkRefs.dev : pageLinkRefs.prod); + }, + plugins: [ + shikiPlugin({ theme: 'github-dark-dimmed' }), + searchPlugin({ + isSearchable: (page) => page.path !== '/', + locales: { + '/en/': { placeholder: 'Search' }, + '/zh-cn/': { placeholder: '搜索' } + } + }) + ] +}; \ No newline at end of file diff --git a/docs-source/src/.vuepress/configs/template.ts b/docs-source/src/.vuepress/configs/template.ts new file mode 100644 index 0000000..c2ddee7 --- /dev/null +++ b/docs-source/src/.vuepress/configs/template.ts @@ -0,0 +1,151 @@ +import { i18n } from './utils'; + +interface PageLinkRefs { + dev: Record[]; + prod: Record[]; +} + +const navigationLinks = { + start: [ + '/guide/home', + '/guide/quick-start' + ], + library: [ + '/library/hikage-core', + '/library/hikage-compiler', + '/library/hikage-extension', + '/library/hikage-extension-betterandroid', + '/library/hikage-extension-compose', + '/library/hikage-widget-androidx', + '/library/hikage-widget-material' + ], + config: [ + '/config/r8-proguard' + ], + about: [ + '/about/changelog', + '/about/future', + '/about/contacts', + '/about/about' + ] +}; + +export const configs = { + dev: { + dest: 'dist', + port: 9000 + }, + website: { + base: '/Hikage/', + icon: '/Hikage/images/logo.svg', + logo: '/images/logo.svg', + title: 'Hikage', + locales: { + '/en/': { + lang: 'en-US', + description: 'An Android responsive UI building tool' + }, + '/zh-cn/': { + lang: 'zh-CN', + description: '一个 Android 响应式 UI 构建工具' + } + } + }, + github: { + repo: 'https://github.com/BetterAndroid/Hikage', + page: 'https://betterandroid.github.io/Hikage', + branch: 'main', + dir: 'docs-source/src' + } +}; + +export const pageLinkRefs: PageLinkRefs = { + dev: [ + { 'repo://': `${configs.github.repo}/` }, + // KDoc URL for local debugging, non-fixed value, adjust according to your own needs. + // You can run ./build-dokka.sh and start the local server in dist/KDoc. + { 'kdoc://': 'http://localhost:9001/' } + ], + prod: [ + { 'repo://': `${configs.github.repo}/` }, + { 'kdoc://': `${configs.github.page}/KDoc/` } + ] +}; + +export const navBarItems = { + '/en/': [{ + text: 'Navigation', + children: [{ + text: 'Get Started', + children: i18n.array(navigationLinks.start, 'en') + }, { + text: 'Libraries', + children: i18n.array(navigationLinks.library, 'en') + }, { + text: 'Configs', + children: i18n.array(navigationLinks.config, 'en') + }, { + text: 'About', + children: i18n.array(navigationLinks.about, 'en') + }] + }, { + text: 'Contact Us', + link: i18n.string(navigationLinks.about[2], 'en') + }], + '/zh-cn/': [{ + text: '导航', + children: [{ + text: '入门', + children: i18n.array(navigationLinks.start, 'zh-cn') + }, { + text: '依赖', + children: i18n.array(navigationLinks.library, 'zh-cn') + }, { + text: '配置', + children: i18n.array(navigationLinks.config, 'zh-cn') + }, { + text: '关于', + children: i18n.array(navigationLinks.about, 'zh-cn') + }] + }, { + text: '联系我们', + link: i18n.string(navigationLinks.about[2], 'zh-cn') + }] +}; + +export const sideBarItems = { + '/en/': [{ + text: 'Get Started', + collapsible: true, + children: i18n.array(navigationLinks.start, 'en') + }, { + text: 'Libraries', + collapsible: true, + children: i18n.array(navigationLinks.library, 'en') + }, { + text: 'Configs', + collapsible: true, + children: i18n.array(navigationLinks.config, 'en') + }, { + text: 'About', + collapsible: true, + children: i18n.array(navigationLinks.about, 'en') + }], + '/zh-cn/': [{ + text: '入门', + collapsible: true, + children: i18n.array(navigationLinks.start, 'zh-cn') + }, { + text: '依赖', + collapsible: true, + children: i18n.array(navigationLinks.library, 'zh-cn') + }, { + text: '配置', + collapsible: true, + children: i18n.array(navigationLinks.config, 'zh-cn') + }, { + text: '关于', + collapsible: true, + children: i18n.array(navigationLinks.about, 'zh-cn') + }] +}; \ No newline at end of file diff --git a/docs-source/src/.vuepress/configs/utils.ts b/docs-source/src/.vuepress/configs/utils.ts new file mode 100644 index 0000000..dbd8f13 --- /dev/null +++ b/docs-source/src/.vuepress/configs/utils.ts @@ -0,0 +1,39 @@ +export const env = { + dev: process.env.NODE_ENV === 'development' +}; + +export const i18n = { + space: ' ', + string: (content: string, locale: string) => { + return '/' + locale + content; + }, + array: (contents: string[], locale: string) => { + const newContents: string[] = []; + contents.forEach((content) => { + newContents.push(i18n.string(content, locale)); + }); + return newContents; + } +}; + +export const markdown = { + injectLinks: (md: markdownit, maps: Record[]) => { + const defaultRender = md.renderer.rules.link_open || function (tokens, idx, options, _env, self) { + return self.renderToken(tokens, idx, options); + }; + md.renderer.rules.link_open = function (tokens, idx, options, env, self) { + const hrefIndex = tokens[idx].attrIndex('href'); + let current = tokens[idx].attrs!![hrefIndex][1]; + for (const map of maps) { + for (const [search, replace] of Object.entries(map)) { + if (current.startsWith(search)) { + current = current.replace(search, replace); + tokens[idx].attrs!![hrefIndex][1] = current; + break; + } + } + } + return defaultRender(tokens, idx, options, env, self); + }; + } +}; \ No newline at end of file diff --git a/docs-source/src/.vuepress/public/images/logo.svg b/docs-source/src/.vuepress/public/images/logo.svg new file mode 100644 index 0000000..df15380 --- /dev/null +++ b/docs-source/src/.vuepress/public/images/logo.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/docs-source/src/.vuepress/public/images/nagasaki_soyo.png b/docs-source/src/.vuepress/public/images/nagasaki_soyo.png new file mode 100644 index 0000000..03a75ac Binary files /dev/null and b/docs-source/src/.vuepress/public/images/nagasaki_soyo.png differ diff --git a/docs-source/src/.vuepress/styles/index.scss b/docs-source/src/.vuepress/styles/index.scss new file mode 100644 index 0000000..834f34b --- /dev/null +++ b/docs-source/src/.vuepress/styles/index.scss @@ -0,0 +1,179 @@ +$primary-color: rgb(99, 159, 112); +$accent-color: rgb(130, 180, 140); +$content-width: 965px; +$scroll-bar-width: 8px; +$scroll-bar-height: 6.5px; +$scroll-bar-border-radius: 50px; +$scroll-bar-track-color-code: rgb(86, 96, 110); +$scroll-bar-thumb-hover-color-code: rgb(121, 135, 155); + +:root { + --c-brand: #{$primary-color}; + --c-brand-light: #{$accent-color}; + --content-width: #{$content-width}; +} + +code { + padding: 3px 5px 3px 5px; + border-radius: 5px; +} + +.badge { + margin-bottom: 5px; +} + +.custom-container { + border-radius: 5px; +} + +.sidebar-item { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.language-text { + ::-webkit-scrollbar-track { + background: #{$scroll-bar-track-color-code}; + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: #{$scroll-bar-thumb-hover-color-code}; + } +} + +.language-kotlin { + ::-webkit-scrollbar-track { + background: #{$scroll-bar-track-color-code}; + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: #{$scroll-bar-thumb-hover-color-code}; + } +} + +.language-java { + ::-webkit-scrollbar-track { + background: #{$scroll-bar-track-color-code}; + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: #{$scroll-bar-thumb-hover-color-code}; + } +} + +.language-groovy { + ::-webkit-scrollbar-track { + background: #{$scroll-bar-track-color-code}; + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: #{$scroll-bar-thumb-hover-color-code}; + } +} + +.language-xml { + ::-webkit-scrollbar-track { + background: #{$scroll-bar-track-color-code}; + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: #{$scroll-bar-thumb-hover-color-code}; + } +} + +.hidden-anchor-page { + h6 { + color: transparent; + margin-bottom: -35px; + padding-top: 50px; + } +} + +.code-page { + h1 { + font-size: 24pt; + } + + h2 { + font-size: 18pt; + } + + h3 { + font-size: 15pt; + } + + h4 { + font-size: 12pt; + } + + h5 { + font-size: 9.6pt; + } + + h6 { + font-size: 8.4pt; + } + + .symbol { + color: rgb(142, 155, 168); + } + + .deprecated { + color: rgb(142, 155, 168); + text-decoration: line-through; + } +} + +html { + scroll-behavior: smooth; + + ::-webkit-scrollbar { + width: #{$scroll-bar-width}; + height: #{$scroll-bar-height}; + } + + ::-webkit-scrollbar-track { + background: rgb(234, 236, 239); + } + + ::-webkit-scrollbar-thumb { + background: rgb(189, 189, 189); + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: rgb(133, 133, 133); + border-radius: #{$scroll-bar-border-radius}; + } +} + +html.dark { + --c-brand: #{$primary-color}; + --c-brand-light: #{$accent-color}; + --content-width: #{$content-width}; + + ::-webkit-scrollbar { + width: #{$scroll-bar-width}; + height: #{$scroll-bar-height}; + } + + ::-webkit-scrollbar-track { + background: rgb(41, 46, 53); + } + + ::-webkit-scrollbar-thumb { + background: rgb(65, 72, 83); + border-radius: #{$scroll-bar-border-radius}; + } + + ::-webkit-scrollbar-thumb:hover { + background: rgb(56, 62, 72); + border-radius: #{$scroll-bar-border-radius}; + } +} \ No newline at end of file diff --git a/docs-source/src/en/about/about.md b/docs-source/src/en/about/about.md new file mode 100644 index 0000000..80b01a6 --- /dev/null +++ b/docs-source/src/en/about/about.md @@ -0,0 +1,27 @@ +# About This Document + +> This document is powered by [VuePress](https://v2.vuepress.vuejs.org/en). + +## License + +[Apache-2.0](https://github.com/BetterAndroid/Hikage/blob/main/LICENSE) + +```:no-line-numbers +Apache License Version 2.0 + +Copyright (C) 2019 HighCapable + +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 + + https://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. +``` + +Copyright © 2019 HighCapable \ No newline at end of file diff --git a/docs-source/src/en/about/changelog.md b/docs-source/src/en/about/changelog.md new file mode 100644 index 0000000..a4ac12b --- /dev/null +++ b/docs-source/src/en/about/changelog.md @@ -0,0 +1,59 @@ +# Changelog + +> The version update history of `Hikage` is recorded here. + +::: danger + +We will only maintain the latest API version, if you are using an outdate API version, you voluntarily renounce any possibility of maintenance. + +::: + +::: warning + +To avoid translation time consumption, Changelog will use **Google Translation** from **Chinese** to **English**, please refer to the original text for actual reference. + +Time zone of version release date: **UTC+8** + +::: + +## hikage-core + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven + +## hikage-compiler + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven + +## hikage-extension + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven + +## hikage-extension-betterandroid + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven + +## hikage-extension-compose + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven + +## hikage-widget-androidx + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven + +## hikage-widget-material + +### 1.0.0 | 2025.04.20 + +- The first version is submitted to Maven \ No newline at end of file diff --git a/docs-source/src/en/about/contacts.md b/docs-source/src/en/about/contacts.md new file mode 100644 index 0000000..f07866a --- /dev/null +++ b/docs-source/src/en/about/contacts.md @@ -0,0 +1,16 @@ +# Contact Us + +> If you have any questions in use, or have any constructive suggestions, you can contact us. + +Join our developers group. + +- [Click to join Telegram group](https://t.me/BetterAndroid) +- [Click to join Telegram group (Developer)](https://t.me/HighCapable_Dev) + +Find me on **Twitter** [@fankesyooni](https://twitter.com/fankesyooni). + +## Help with Maintenance + +Thank you for choosing and using `Hikage`. + +If you have code-related suggestions and requests, you can submit a Pull Request on GitHub. \ No newline at end of file diff --git a/docs-source/src/en/about/future.md b/docs-source/src/en/about/future.md new file mode 100644 index 0000000..184a121 --- /dev/null +++ b/docs-source/src/en/about/future.md @@ -0,0 +1,75 @@ +# Looking for Future + +> The future is bright and uncertain, let us look forward to the future development space of `Hikage`. + +## Future Plans + +> Features that `Hikage` may add later are included here. + +### Process AttrtibuteSet + +`Hikage` will support processing `AttributeSet` in the future to dock with the original XML properties to implement the takeover +of some third-party components that are not open to customization of layout properties in the code. + +`Hikage` currently supports automated creation of `XmlBlock`, but does not support the direct processing +of customized `AttributeSet`. Because of its historical problems and high processing difficulty, it may compromise whether to continue to improve this function in the later stage. + +> The following example + +```kotlin +TextView( + id = "text_view", + // Attributes passed through AttributeSet. + attrs = { + namespace("android") { + set("text", "Hello, World!") + set("textSize", "16sp") + set("gravity", "center") + } + } +) { + // Attributes passed through code. + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER +} +``` + +### Generate Components ID + +`Hikage` may support the direct call function to generate component IDs customized with strings as required in the future. + +> The following example + +```kotlin +object MyLayout : HikageBuilder { + + override fun build() = Hikageable(context) { + LinearLayout( + id = "lin_layout", + lparams = LayoutParams(matchParent = true), + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView(id = "text_view") { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } +} + +val context: Context +// Create TypedHikage. +val myLayout = MyLayout.asTyped().build().create(context) +// Or, use lazy init. +val myLayout by context.lazyTypedHikage(MyLayout) +// Directly call the ID generated from the string. +val linLayout = myLayout.linLayout +val textView = myLayout.textView +// Get the root layout, i.e. LinearLayout. +val root = myLayout.root +``` \ No newline at end of file diff --git a/docs-source/src/en/config/r8-proguard.md b/docs-source/src/en/config/r8-proguard.md new file mode 100644 index 0000000..1e07c72 --- /dev/null +++ b/docs-source/src/en/config/r8-proguard.md @@ -0,0 +1,18 @@ +# R8 & Proguard Obfuscate + +> In most scenarios, the app packages can be compressed through obfuscation, +> here is an introduction to how to configure obfuscation rules. + +`Hikage` does not require additional configuration of obfuscation rules, since `View` loaded by Hikage does not need to be defined in XML, they can be equally obfuscated. + +You can force them to be confused with your custom `View`, such as `com.yourpackage.YourView`, using the following rules. + +``` +-allowobfuscation class com.yourpackage.YourView +``` + +If you must prevent `Hikage` from being confused or something that occurs after being confused, you can use the following rules to prevent `Hikage` from being confused. + +``` +-keep class com.highcapable.hikage** +``` \ No newline at end of file diff --git a/docs-source/src/en/guide/home.md b/docs-source/src/en/guide/home.md new file mode 100644 index 0000000..1741955 --- /dev/null +++ b/docs-source/src/en/guide/home.md @@ -0,0 +1,120 @@ +# Introduce + +> `Hikage` (Pronunciation /ˈhɪkɑːɡeɪ/) is an Android responsive UI building tool. + +## Background + +This is an Android responsive UI build tool designed to focus on **Real-time code building UI**. + +The project icon was designed by [MaiTungTM](https://github.com/Lagrio), +the name is taken from the original song "Haru**hikage**" in "BanG Dream It's MyGO!!!!!". + +Why... + + + + **なんで春日影レイアウト使いの?** + + + +Unlike Jetpack Compose's declarative UI, Hikage focuses on Android native platforms, +and its design goal is to enable developers to quickly build UIs and directly support Android native components. + +**Hikage is just a UI build tool and does not provide any UI components themselves**. + +Rejecting duplicate wheels, our solution is always compatible and efficient. Now you can abandon ViewBinding and XML and even `findViewById` and try +to use the code layout directly. + +`Hikage` works better with another project [BetterAndroid](https://github.com/BetterAndroid/BetterAndroid) and +`Hikage` itself will automatically reference the `BetterAndroid` related dependencies as the core content. + +## Usage + +Hikage is mainly suitable for developers focusing on native Android platform development. +Since Kotlin became the primary development language, there hasn't been a perfect tool to implement dynamic code layouts using DSL. +Therefore, projects that do not use Jetpack Compose still need to use the original XML. Although ViewBinding provides support, it is still not very user-friendly. + +Hikage inherits the design schemes of [Anko](https://github.com/Kotlin/anko) and [Splitties](https://github.com/LouisCAD/Splitties), +and draws on the DSL function naming scheme of Jetpack Compose. On this basis, it has made many improvements, +making it closer to native in terms of usage cost and closer to Jetpack Compose in terms of writing style. + +> Comparison of various DSL layout schemes + +:::: code-group +::: code-group-item Hikage + +```kotlin +LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` + +::: +::: code-group-item Anko、Splitties + +```kotlin +verticalLayout { + gravity = Gravity.CENTER + textView("Hello, World!") { + textSize = 16f + gravity = Gravity.CENTER + } +}.lparams( + width = matchParent, + height = matchParent +) { + topMargin = dip(16) +} +``` + +::: +::: code-group-item Jetpack Compose + +```kotlin +Column( + modifier = Modifier.padding(top = 16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally +) { + Text( + text = "Hello, World!", + fontSize = 16.sp, + textAlign = TextAlign.Center + ) +} +``` + +::: +:::: + +The basic part of Hikage **does not require any external or additional compilation plugins**. +It can be **plug-and-play** and **create a View object anywhere** that can be set to the parent layout and `Window`. + +Hikage **fully supports** hybrid layouts. You can embed XML (using the `R.layout` scheme to load layouts), ViewBinding, and even Jetpack Compose within Hikage. + +## Language Requirement + +It is recommended to use Kotlin as the preferred development language. This project is entirely written in Kotlin, and there are no plans to support Java compatibility. + +All demo examples in the documentation will be described using Kotlin. If you are not familiar with Kotlin, you may encounter difficulties in using this project effectively. + +## Contribution + +The maintenance of this project is inseparable from the support and contributions of all developers. + +This project is currently in its early stages, and there may still be some problems or lack of functions you need. + +If possible, feel free to submit a PR to contribute features you think are needed to this project or goto [GitHub Issues](repo://issues) +to make suggestions to us. \ No newline at end of file diff --git a/docs-source/src/en/guide/quick-start.md b/docs-source/src/en/guide/quick-start.md new file mode 100644 index 0000000..2bfb557 --- /dev/null +++ b/docs-source/src/en/guide/quick-start.md @@ -0,0 +1,89 @@ +# Quick Start + +> Integrate `Hikage` into your project. + +## Project Requirements + +The project needs to be created using `Android Studio` or `IntelliJ IDEA` and be of type Android or Kotlin Multiplatform +project and have integrated Kotlin environment dependencies. + +- Android Studio (It is recommended to get the latest version [from here](https://developer.android.com/studio)) + +- IntelliJ IDEA (It is recommended to get the latest version [from here](https://www.jetbrains.com/idea)) + +- Kotlin 1.9.0+, Gradle 8+, Java 17+, Android Gradle Plugin 8+ + +### Configure Repositories + +The dependencies of `Hikage` are published in **Maven Central** and our public repository, +you can use the following method to configure repositories. + +We recommend using Kotlin DSL as the Gradle build script language and [SweetDependency](https://github.com/HighCapable/SweetDependency) +to manage dependencies. + +#### SweetDependency (Recommended) + +Configure repositories in your project's `SweetDependency` configuration file. + +```yaml +repositories: + google: + maven-central: + # (Optional) You can add this URL to use our public repository + # When Sonatype-OSS fails and cannot publish dependencies, this repository is added as a backup + # For details, please visit: https://github.com/HighCapable/maven-repository + highcapable-maven-releases: + url: https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases +``` + +#### Traditional Method + +Configure repositories in your project `build.gradle.kts`. + +```kotlin +repositories { + google() + mavenCentral() + // (Optional) You can add this URL to use our public repository + // When Sonatype-OSS fails and cannot publish dependencies, this repository is added as a backup + // For details, please visit: https://github.com/HighCapable/maven-repository + maven("https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases") +} +``` + +### Configure Java Version + +Modify the Java version of Kotlin in your project `build.gradle.kts` to 17 or above. + +> Kotlin DSL + +```kt +android { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } +} +``` + +## Functional Overview + +The project is divided into multiple modules. You can choose the module you wish to include as a dependency in your project, but be sure to include the **hikage-core** module. + +Click the corresponding module below to view detailed feature descriptions. + +- [hikage-core](../library/hikage-core.md) +- [hikage-compiler](../library/hikage-compiler.md) +- [hikage-extension](../library/hikage-extension.md) +- [hikage-extension-betterandroid](../library/hikage-extension-betterandroid.md) +- [hikage-extension-compose](../library/hikage-extension-compose.md) +- [hikage-widget-androidx](../library/hikage-widget-androidx.md) +- [hikage-widget-material](../library/hikage-widget-material.md) + +## Demo + +You can find some samples [here](repo://tree/main/samples) view the corresponding demo project to better understand how these functions work and quickly +select the functions you need. \ No newline at end of file diff --git a/docs-source/src/en/index.md b/docs-source/src/en/index.md new file mode 100644 index 0000000..d1c7d8a --- /dev/null +++ b/docs-source/src/en/index.md @@ -0,0 +1,65 @@ +--- +home: true +title: Home +heroImage: /images/logo.svg +actions: + - text: Get Started + link: /en/guide/home + type: primary + - text: Changelog + link: /en/about/changelog + type: secondary +features: + - title: Native Control + details: Using View as the foundation and Kotlin as the development language, 100% dynamic code layout, no additional configuration required, supports custom Views. + - title: Fully Compatible + details: Supports embedding and mixing XML, ViewBinding, and Jetpack Compose, and provides support for Material components and Jetpack. + - title: Quickly Started + details: Simple and easy to use it now! Do not need complex configuration and full development experience, Integrate dependencies and enjoy yourself. +footer: Apache-2.0 License | Copyright (C) 2019 HighCapable +--- + +### Layout, it's that flexible. + +:::: code-group +::: code-group-item Hikage (Kotlin DSL) + +```kotlin +LinearLayout( + lparams = LayoutParams(matchParent = true), + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + TextView(id = "text_view") { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` + +::: +::: code-group-item XML + +```xml + + + + + +``` + +::: +:::: \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-compiler.md b/docs-source/src/en/library/hikage-compiler.md new file mode 100644 index 0000000..d61dcfd --- /dev/null +++ b/docs-source/src/en/library/hikage-compiler.md @@ -0,0 +1,171 @@ +# hikage-compiler + + + + + + + +This is a Hikage automatic compilation module. + +## Configure Dependency + +You can add this module to your project using the following method. + +::: warning + +You need to integrate the [Google KSP](https://github.com/google/ksp/releases) plugin in your project that is suitable for the current Kotlin version of your project. + +::: + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +plugins: + com.google.devtools.ksp: + version: + + +libraries: + com.highcapable.hikage: + hikage-compiler: + version: + +``` + +Configure dependency in your root project `build.gradle.kts`. + +```kotlin +plugins { + // ... + autowire(libs.plugins.com.google.devtools.ksp) apply false +} +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +plugins { + // ... + autowire(libs.plugins.com.google.devtools.ksp) +} + +dependencies { + // ... + ksp(com.highcapable.hikage.hikage.compiler) +} +``` + +### Traditional Method + +Configure dependency in your root project `build.gradle.kts`. + +```kotlin +plugins { + // ... + id("com.google.devtools.ksp") version "" apply false +} +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +plugins { + // ... + id("com.google.devtools.ksp") +} + +dependencies { + // ... + ksp("com.highcapable.hikage:hikage-compiler:") +} +``` + +Please change `` to the version displayed at the top of this document, +and change `` to the KSP version corresponding to the Kotlin version currently used by your project. + +## Function Introduction + +Hikage's compilation module will automatically generate code at runtime. +After update, please re-run the `assembleDebug` or `assembleRelease` task to generate the latest code. + +### Generate Layout Components + +Hikage can automatically generate the `Hikageable` function corresponding to the layout component for the specified layout component at compile time. + +#### Custom View + +You can add the `HikageView` annotation on your custom `View` to mark it as a Hikage layout component. + +| Parameter Name | Description | +| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `lparams` | LayoutParams `Class` object, if your custom `View` is a subclass of `ViewGroup`, you can declare or leave it blank to use the default value | +| `alias` | The alias of the layout component, that is, the function name to be generated, gets the name of the current Class by default | +| `requireInit` | Whether to fill in the initialization method block of the layout, the default is the omitted parameters | +| `requirePerformer` | Whether to fill in the `performer` method block of the layout, the default is an omitted parameter, which only takes effect when your custom `View` is a subclass of `ViewGroup` | + +> The following example + +```kotlin +@HikageView(lparams = LinearLayout.LayoutParams::class) +class MyLayout(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) { + // ... +} +``` + +Once compiled, you can use `MyLayout` as the layout component in the Hikage layout. + +> The following example + +```kotlin +Hikageable { + MyLayout { + TextView( + lparams = LayoutParams { + topMargin = 16.dp + } + ) { + text = "Hello, World!" + } + } +} +``` + +#### Third-party Components + +Hikage can also automatically generate layout component functions for the `View` component provided by third parties, and you can use the `HikageViewDeclaration` annotation to complete it. + +| Parameter Name | Description | +| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `view` | Class object of layout component that needs to be declared | +| `lparams` | LayoutParams `Class` object, if your custom `View` is a subclass of `ViewGroup`, you can declare or leave it blank to use the default value | +| `alias` | The alias of the layout component, that is, the name of the function to be generated, obtains the name of the `view` Class by default | +| `requireInit` | Whether to fill in the initialization method block of the layout, the default is the omitted parameters | +| `requirePerformer` | Whether to fill in the `performer` method block of the layout, the default is an omitted parameter, which only takes effect when your custom `View` is a subclass of `ViewGroup` | + +> The following example + +```kotlin +@HikageViewDeclaration(ThirdPartyView::class) +object ThirdPartyViewDeclaration +``` + +This annotation can be declared on any `object` class and is only used as a class that needs to be automatically included by the annotation scanner. You can set visibility to `private`, but make sure that the annotated class must be modified with `object`. + +Similarly, after compilation, you can use `ThirdPartyView` as the layout component in the Hikage layout. + +> The following example + +```kotlin +Hikageable { + ThirdPartyView { + // ... + } +} +``` + +::: tip + +Hikage The function package name path for generating layout components is `com.highcapable.hikage.widget` + the full package name of your `View` or third-party `View` component. + +::: \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-core.md b/docs-source/src/en/library/hikage-core.md new file mode 100644 index 0000000..f5520e8 --- /dev/null +++ b/docs-source/src/en/library/hikage-core.md @@ -0,0 +1,524 @@ +# hikage-core + + + + + + + +This is the core dependency of Hikage, and you need to introduce this module to use the basic features of Hikage. + +## Configure Dependency + +You can add this module to your project using the following method. + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +libraries: + com.highcapable.hikage: + hikage-core: + version: + +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation(com.highcapable.hikage.hikage.core) +``` + +### Traditional Method + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation("com.highcapable.hikage:hikage-core:") +``` + +Please change `` to the version displayed at the top of this document. + +## Function Introduction + +You can view the KDoc [click here](kdoc://hikage-core). + +### Basic Usage + +Use the code below to create your first Hikage layout. + +First, use `Hikageable` to create a `Hikage.Delegate` object. + +> The following example + +```kotlin +val myLayout = Hikageable { + LinearLayout { + TextView { + text = "Hello, World!" + } + } +} +``` + +Then, set it to the parent or root layout you want to display. + +> The following example + +```kotlin +// Assume that's your Activity. +val activity: Activity +// Instantiate the Hikage object. +val hikage = myLayout.create(activity) +// Get the root layout. +val root = hikage.root +// Content view set to Activity. +activity.setContentView(root) +``` + +In this way, we complete a simple layout creation and setting. + +### Layout Agreement + +The basic layout elements of Hikage are based on the Android native `View` component. + +All layout elements can be created directly using the Android native `View` component. + +The creation process of all layouts will be limited to the specified scope `Hikage.Performer`, +which is called the "player" of the layout, that is, the role object that plays the layout. + +This object can be created and maintained in the following ways. + +#### Hikageable + +As shown in [Basic Usage](#basic-usage), `Hikageable` can directly create a `Hikage.Delegate` or `Hikage` object. + +In DSL, you can get the `Hikage.Performer` object to create the layout content. + +The first solution is created anywhere. + +> The following example + +```kotlin +// myLayout is a Hikage.Delegate object. +val myLayout = Hikageable { + // ... +} +// Assume that's your Context. +val context: Context +// Instantiate the Hikage object where the Context is needed. +val hikage = myLayout.create(context) +``` + +The second solution is created directly where `Context` exists. + +> The following example + +```kotlin +// Assume that's your Context. +val context: Context +// Create a layout, myLayout is a Hikage object. +val myLayout = Hikageable(context) { + // ... +} +``` + +#### HikageBuilder + +In addition to the above methods, you can also maintain a `HikageBuilder` object to pre-create the layout. + +First, we need to create a `HikageBuilder` object and define it as a singleton. + +> The following example + +```kotlin +object MyLayout : HikageBuilder { + + override fun build() = Hikageable { + // ... + } +} +``` + +Then, use it where needed, there are two options as follows. + +The first solution is to create a `Hikage.Delegate` object directly using `build`. + +> The following example + +```kotlin +// myLayout is a Hikage.Delegate object. +val myLayout = MyLayout.build() +// Assume that's your Context. +val context: Context +// Instantiate the Hikage object where the Context is needed. +val hikage = myLayout.create(context) +``` + +The second solution is to create the `Hikage` delegate object using `Context.lazyHikage`. + +For example, we can use it like `ViewBinding` in `Activity`. + +> The following example + +```kotlin +class MyActivity: AppCompatActivity() { + + private val myLayout by lazyHikage(MyLayout) + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + // Get the root layout. + val root = myLayout.root + // Content view set to Activity. + setContentView(root) + } +} +``` + +### Basic Layout Components + +Hikage uses a functional component creation scheme consistent with Jetpack Compose. + +Its layout is done using two basic components, the `View` and `ViewGroup` functions. +They correspond to Android native components based on `View` and `ViewGroup`, respectively. + +#### View + +The basic parameters of the `View` function are the following three, and the `View` object type created using generic definitions. + +If the generic type is not declared, the default is to use `android.view.View` as the object type created. + +| Parameter Name | Description | +| -------------- | ----------------------------------------------------------------------------- | +| `lparams` | Layout parameter, i.e. `ViewGroup.LayoutParams`, created using `LayoutParams` | +| `id` | Used to find the ID of the created object, defined using a string | +| `init` | The initialization method body of `View`, passed as the last DSL parameter | + +> The following example + +```kotlin +View( + lparams = LayoutParams(), + id = "my_text_view" +) { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER +} +``` + +#### ViewGroup + +The basic parameters of the `ViewGroup` function are four, and compared with the `View` function, there is one more `performer` parameter. + +It must declare a generic type because `ViewGroup` is an abstract class and requires a concrete implementation class. + +`ViewGroup` provides an additional generic parameter based on `ViewGroup.LayoutParams` to provide layout parameters for sub-layouts. + +`ViewGroup.LayoutParams` is used by default when not declared. + +| Parameter Name | Description | +| -------------- | ----------------------------------------------------------------------------- | +| `lparams` | Layout parameter, i.e. `ViewGroup.LayoutParams`, created using `LayoutParams` | +| `id` | Used to find the ID of the created object, defined using a string | +| `init` | The initialization method body of `ViewGroup`, passed in as DSL parameter | +| `performer` | `Hikage.Performer` object, passed as the last DSL parameter | + +The function of the `performer` parameter is to pass a new `Hikage.Performer` object downward as the creator of the sub-layout. + +> The following example + +```kotlin +ViewGroup( + lparams = LayoutParams(), + id = "my_linear_layout", + // Initialization method body will be reflected here using `init`. + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + // You can continue to create sub-layouts here. + View() +} +``` + +#### LayoutParams + +Layouts in Hikage can be set using the `LayoutParams` function, you can create it using the following parameters. + +| Parameter Name | Description | +| ------------------- | --------------------------------------------------------------------------------------------- | +| `width` | Manually specify layout width | +| `height` | Manually specify layout height | +| `matchParent` | Whether to use `MATCH_PARENT` as layout width and height | +| `wrapContent` | Whether to use `WRAP_CONTENT` as layout width and height | +| `widthMatchParent` | Set width to `MATCH_PARENT` only | +| `heightMatchParent` | Set the height to `MATCH_PARENT` only | +| `body` | The initialization method body of the layout parameter, passed into as the last DSL parameter | + +When you do not set the `LayoutParams` object or specify `width` and `height`, Hikage will automatically use `WRAP_CONTENT` as layout parameters. + +The type of the `body` method body comes from the second generic parameter provided by the upper layer [ViewGroup](#viewgroup). + +> The following example + +```kotlin +View( + // Assume that the layout parameter type provided by the upper layer is LinearLayout.LayoutParams. + lparams = LayoutParams(width = 100.dp) { + topMargin = 20.dp + } +) +``` + +If you only need a horizontally filled layout, you can use `widthMatchParent = true` directly. + +> The following example + +```kotlin +View( + lparams = LayoutParams(widthMatchParent = true) +) +``` + +#### Layout + +Hikage supports references to third-party layouts, you can pass in XML layout resource IDs, other Hikage objects, and `View` objects, and even `ViewBinding`. + +> The following example + +```kotlin +ViewGroup<...> { + // Quote XML layout resource ID. + Layout(R.layout.my_layout) + // Quote ViewBinding. + Layout() + // Reference another Hikage or Hikage.Delegate object. + Layout(myLayout) +} +``` + +### Positioning Layout Components + +Hikage supports locating components using `id`. In the example above, we used the `id` parameter to set the component's ID. + +After setting the ID, you can use the `Hikage.get` method to get them. + +> The following example + +```kotlin +val myLayout = Hikageable { + View(id = "my_text_view") { + text = "Hello, World!" + } +} +// Assume that's your Context. +val context: Context +// Instantiate the Hikage object where the Context is needed. +val hikage = myLayout.create(context) +// Get the specified component and return the View type. +val textView = hikage["my_text_view"] +// Get the specified component and declare the component type. +val textView = hikage.get("my_text_view") +// If you are not sure whether the ID exists, you can use the `getOrNull` method. +val textView = hikage.getOrNull("my_text_view") +``` + +### Custom Layout Components + +Hikage provides functions corresponding to component class names for Android basic layout components. + +You can directly use these functions to create components without using generics to declare them. If you need components provided by Jetpack or Material, +the [hikage-widget-androidx](../library/hikage-widget-androidx.md) or [hikage-widget-material](../library/hikage-widget-material.md) modules can be introduced. + +> The following example + +```kotlin +LinearLayout( + lparams = LayoutParams(), + id = "my_linear_layout", + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + TextView( + lparams = LayoutParams(), + id = "my_text_view" + ) { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` + +The initialized `View` or `ViewGroup` objects return instances of their own object type, which you can use in the following layout. + +> The following example + +```kotlin +val textView = TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER +} +Button { + text = "Click Me!" + setOnClickListener { + // Use the textView object directly. + textView.text = "Clicked!" + } +} +``` + +If the provided components do not meet your needs, you can create your own components manually. + +> The following example + +```kotlin +// Suppose you have defined your custom components. +class MyCustomView(context: Context, attrs: AttributeSet? = null) : View(context, attrs) { + // ... +} + +// Below, create the function corresponding to the component. +// Custom components must declare this annotation. +// Declaring the annotation of the component is contagious, +// and this annotation is required in every scope used to build the layout. +@Hikageable +// The naming of functions can be done at will, but it is recommended to use a big camel name. +// The signature part of the function needs to be fixedly +// declared as `inline fun Hikage.Performer`. +inline fun Hikage.Performer.MyCustomView( + lparams: Hikage.LayoutParams? = null, + id: String? = null, + init: HikageView = {}, + // If this component is a container, you can declare a `performer` parameter. + // performer: HikagePerformer = {} +) = View(lparams, id, init) +``` + +It would seem tedious to implement such complex functions manually every time. +If you want to be able to automatically generate component functions, you can introduce and refer to the [hikage-compiler](../library/hikage-compiler.md) module. + +### Custom Layout Factory + +Hikage supports custom layout factories and is compatible with `LayoutInflater.Factory2`. +You can customize events and listening during the Hikage layout inflating process in the following ways. + +> The following example + +```kotlin +val factory = HikageFactory { parent, base, context, params -> + // You can customize the behavior of the layout factory here. + // For example, create a new View object in your own way. + // `parent` is the ViewGroup object to which the current component is to be added, + // and if not, it is `null`. + // `base` is the View object created for the previous HikageFactory, if not, it is `null`. + // `params` object contains the component ID, AttributeSet and Class objects of View. + val view = MyLayoutFactory.createView(context, params) + // You can also initialize and set the created View object here. + view.setBackgroundColor(Color.RED) + // Return the created View object. + // Return `null` will use the default component inflating method. + view +} +``` + +You can also pass in the `LayoutInflater` object directly to automatically inflate and use the `LayoutInflater.Factory2` in it. + +> The following example + +```kotlin +// Assume that this is your LayoutInflater object. +val layoutInflater: LayoutInflater +// Create HikageFactory object through LayoutInflater. +val factory = HikageFactory(layoutInflater) +``` + +Then set it to the Hikage layout you need to inflate. + +> The following example + +```kotlin +// Assume that's your Context. +val context: Context +// Create Hikage object. +val hikage = Hikageable( + context = context, + factory = { + // Add a custom HikageFactory object. + add(factory) + // Add directly. + add { parent, base, context, params -> + // ... + null + } + // Add multiple consecutively. + addAll(factories) + } +) { + LinearLayout { + TextView { + text = "Hello, World!" + } + } +} +``` + +::: tip + +Hikage will inflate the layout according to the `LayoutInflater.Factory2` of the `Context` object, if you are using `AppCompatActivity`, +Components in the layout will be automatically replaced with the corresponding Compat component or Material component, +which is consistent with the characteristics of the XML layout. + +If you do not need this feature to be effective by default, you can turn it off globally using the following method. + +> The following example + +```kotlin +Hikage.isAutoProcessWithFactory2 = false +``` + +::: + +### Preview Layout + +Hikage supports previewing layouts in Android Studio. + +With the help of the custom `View` preview plugin that comes with Android Studio, you can preview the layout using the following methods. + +You just need to define a custom `View` for the preview layout and inherit from `HikagePreview`. + +> The following example + +```kotlin +class MyLayoutPreview(context: Context, attrs: AttributeSet?) : HikagePreview(context, attrs) { + + override fun build() = Hikageable { + LinearLayout { + TextView { + text = "Hello, World!" + } + } + } +} +``` + +Then the preview pane should appear on the right side of your current window. +After opening, click "Build & Refresh". The preview will be automatically displayed after the compilation is completed. + +:::tip + +`HikagePreview` implements the `HikageBuilder` interface, you can return any Hikage layout in the `build` method for preview. + +::: + +::: danger + +`HikagePreview` supports previewing layouts in Android Studio only, do not use it at runtime or add it to any XML layout. + +::: \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-extension-betterandroid.md b/docs-source/src/en/library/hikage-extension-betterandroid.md new file mode 100644 index 0000000..4c6b343 --- /dev/null +++ b/docs-source/src/en/library/hikage-extension-betterandroid.md @@ -0,0 +1,74 @@ +# hikage-extension-betterandroid + + + + + + + +This is a Hikage extension dependency for [BetterAndroid](https://github.com/BetterAndroid/BetterAndroid) UI component-related features. + +## Configure Dependency + +You can add this module to your project using the following method. + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +libraries: + com.highcapable.hikage: + hikage-extension-betterandroid: + version: + +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation(com.highcapable.hikage.hikage.extension.betterandroid) +``` + +### Traditional Method + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation("com.highcapable.hikage:hikage-extension-betterandroid:") +``` + +Please change `` to the version displayed at the top of this document. + +## Function Introduction + +You can view the KDoc [click here](kdoc://hikage-extension-betterandroid). + +### Adapter Extension + +Hikage provides layout extension function for BetterAndroid's [Adapter](https://betterandroid.github.io/BetterAndroid/en/library/ui-component#adapter), +you can use the Hikage layout directly on the original extension method of the adapter. + +It uses the `ViewHolderDelegate` provided by BetterAndroid to create extension methods. + +Here is a simple example based on `RecyclerView`. + +> The following example + +```kotlin +// Assume this is the dataset you need to bind to. +val listData = ArrayList() +// Create and bind to a custom RecyclerView.Adapter. +val adapter = recyclerView.bindAdapter { + onBindData { listData } + onBindItemView( + Hikageable = { + TextView(id = "text_view") { + text = "Hello, World!" + textSize = 16f + } + } + ) { hikage, bean, position -> + hikage.get("text_view").text = bean.name + } +} +``` \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-extension-compose.md b/docs-source/src/en/library/hikage-extension-compose.md new file mode 100644 index 0000000..36fdf97 --- /dev/null +++ b/docs-source/src/en/library/hikage-extension-compose.md @@ -0,0 +1,89 @@ +# hikage-extension-compose + + + + + + + +This is a Hikage extension dependency for Jetpack Compose component-related features. + +## Configure Dependency + +You can add this module to your project using the following method. + +::: warning + +This module relies on the Jetpack Compose compiler plugin. +Please make sure that your project has integrated Jetpack Compose-related dependencies. +Please refer to [here](https://developer.android.com/develop/ui/compose/compiler) for details. + +::: + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +libraries: + com.highcapable.hikage: + hikage-extension-compose: + version: + +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation(com.highcapable.hikage.hikage.extension.compose) +``` + +### Traditional Method + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation("com.highcapable.hikage:hikage-extension-compose:") +``` + +Please change `` to the version displayed at the top of this document. + +## Function Introduction + +You can view the KDoc [click here](kdoc://hikage-extension-compose). + +### Use Jetpack Compose in Hikage + +You can use the following methods to embed Jetpack Compose components in a Hikage layout. + +> The following example + +```kotlin +Hikageable { + ComposeView( + lparams = LayoutParams(matchParent = true) + ) { + Text("Hello, World!") + } +} +``` + +### Use Hikage in Jetpack Compose + +You can use the following methods to embed Hikage components in a Jetpack Compose layout. + +> The following example + +```kotlin +Column( + modifier = Modifier.fillMaxSize() +) { + HikageView { + TextView( + lparams = LayoutParams(matchParent = true) + ) { + text = "Hello, World!" + textSize = 20f + } + } +} +``` \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-extension.md b/docs-source/src/en/library/hikage-extension.md new file mode 100644 index 0000000..19c805f --- /dev/null +++ b/docs-source/src/en/library/hikage-extension.md @@ -0,0 +1,210 @@ +# hikage-extension + + + + + + + +This is a Hikage extension dependency for UI component-related features. + +## Configure Dependency + +You can add this module to your project using the following method. + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +libraries: + com.highcapable.hikage: + hikage-extension: + version: + +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation(com.highcapable.hikage.hikage.extension) +``` + +### Traditional Method + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation("com.highcapable.hikage:hikage-extension:") +``` + +Please change `` to the version displayed at the top of this document. + +## Function Introduction + +You can view the KDoc [click here](kdoc://hikage-extension). + +### Activity + +Hikage provides better extensions for `Activity`, and creating a Hikage in `Activity` will be easier. + +> The following example + +```kotlin +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView { + LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } + } +} +``` + +With the `setContentView` extension method of `Hikage`, you can set the layout using the `setContent` method like Jetpack Compose. + +### Window + +Using Hikage to create a layout in Window is consistent with [Activity](#activity), you just need to use the `setContentView` method to pass in a `Hikage` layout. + +### Dialog + +If you want to create a layout using Hikage directly in `AlertDialog`, you can now do it more simply using the following scheme. + +> The following example + +```kotlin +// Assume this is your Context. +val context: Context +// Create a dialog box and display it. +AlertDialog.Builder(context) + .setTitle("Hello, World!") + .setView { + TextView { + text = "Hello, World!" + textSize = 16f + } + } + .show() +``` + +To create a layout using Hikage in `AlertDialog`, you just need to use the `setView` method to pass in a `Hikage` layout. + +If you inherited from `Dialog` for customization, you can use the `setContentView` method as in [Activity](#activity). + +> The following example + +```kotlin +class CustomDialog(context: Context) : Dialog(context) { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView { + LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } + } +} +``` + +### PopupWindow + +You can inherit from `PopupWindow` for customization and then use Hikage to create the layout, +and you can use the `setContentView` method like in [Activity](#activity). + +> The following example + +```kotlin +class CustomPopupWindow(context: Context) : PopupWindow(context) { + + init { + setContentView(context) { + LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } + } +} +``` + +::: danger + +To create a `PopupWindow` for Hikage layout, you need to use the `Context` constructor method to initialize it. +If the `Context` cannot be obtained immediately, please pass the `Context` instance to the `setContentView` method. + +::: + +### ViewGroup + +Hikage extends the `addView` method of `ViewGroup`, and you can use the Hikage layout directly to quickly add new layouts to the current `ViewGroup`. + +> The following example + +```kotlin +// Assume this is your ViewGroup. +val root: FrameLayout +// Add Hikage layout. +root.addView { + TextView { + text = "Hello, World!" + textSize = 16f + } +} +``` + +Or, use in a custom `View`. + +> The following example + +```kotlin +class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { + + init { + addView { + TextView { + text = "Hello, World!" + textSize = 16f + } + } + } +} +``` \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-widget-androidx.md b/docs-source/src/en/library/hikage-widget-androidx.md new file mode 100644 index 0000000..7ab8770 --- /dev/null +++ b/docs-source/src/en/library/hikage-widget-androidx.md @@ -0,0 +1,64 @@ +# hikage-widget-androidx + + + + + + + +This is a Hikage extension dependency for Jetpack Compact component-related features. + +## Configure Dependency + +You can add this module to your project using the following method. + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +libraries: + com.highcapable.hikage: + hikage-widget-androidx: + version: + +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation(com.highcapable.hikage.hikage.widget.androidx) +``` + +### Traditional Method + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation("com.highcapable.hikage:hikage-widget-androidx:") +``` + +Please change `` to the version displayed at the top of this document. + +## Function Introduction + +This dependency inherits the available components from Jetpack Compact, which you can directly reference to use in Hikage. + +> The following example + +```kotlin +LinearLayoutCompact( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayoutCompat.VERTICAL + gravity = Gravity.CENTER + } +) { + AppCompatTextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` \ No newline at end of file diff --git a/docs-source/src/en/library/hikage-widget-material.md b/docs-source/src/en/library/hikage-widget-material.md new file mode 100644 index 0000000..5c2a9cd --- /dev/null +++ b/docs-source/src/en/library/hikage-widget-material.md @@ -0,0 +1,80 @@ +# hikage-widget-material + + + + + + + +This is a Hikage extension dependency for Google Material (MDC) component-related features. + +## Configure Dependency + +You can add this module to your project using the following method. + +### SweetDependency (Recommended) + +Add dependency in your project's `SweetDependency` configuration file. + +```yaml +libraries: + com.highcapable.hikage: + hikage-widget-material: + version: + +``` + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation(com.highcapable.hikage.hikage.widget.material) +``` + +### Traditional Method + +Configure dependency in your project `build.gradle.kts`. + +```kotlin +implementation("com.highcapable.hikage:hikage-widget-material:") +``` + +Please change `` to the version displayed at the top of this document. + +## Function Introduction + +This dependency inherits the available components from Google Material (MDC), which you can directly reference to use in Hikage. + +> The following example + +```kotlin +LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + MaterialTextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + MaterialButton { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + TextInputLayout( + lparams = LayoutParams { + topMargin = 16.dp + }, + init = { + minWidth = 200.dp + hint = "Enter your text" + } + ) { + TextInputEditText() + } +} +``` \ No newline at end of file diff --git a/docs-source/src/index.md b/docs-source/src/index.md new file mode 100644 index 0000000..e45ef78 --- /dev/null +++ b/docs-source/src/index.md @@ -0,0 +1,17 @@ +--- +home: true +navbar: false +sidebar: false +title: null +heroAlt: null +heroText: null +tagline: Select a language +actions: + - text: English + link: /en/ + type: secondary + - text: 简体中文 + link: /zh-cn/ + type: secondary +footer: Apache-2.0 License | Copyright (C) 2019 HighCapable +--- \ No newline at end of file diff --git a/docs-source/src/zh-cn/about/about.md b/docs-source/src/zh-cn/about/about.md new file mode 100644 index 0000000..7052974 --- /dev/null +++ b/docs-source/src/zh-cn/about/about.md @@ -0,0 +1,27 @@ +# 关于此文档 + +> 此文档由 [VuePress](https://v2.vuepress.vuejs.org/zh) 强力驱动。 + +## 许可证 + +[Apache-2.0](https://github.com/BetterAndroid/Hikage/blob/main/LICENSE) + +```:no-line-numbers +Apache License Version 2.0 + +Copyright (C) 2019 HighCapable + +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 + + https://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. +``` + +版权所有 © 2019 HighCapable \ No newline at end of file diff --git a/docs-source/src/zh-cn/about/changelog.md b/docs-source/src/zh-cn/about/changelog.md new file mode 100644 index 0000000..63cee33 --- /dev/null +++ b/docs-source/src/zh-cn/about/changelog.md @@ -0,0 +1,51 @@ +# 更新日志 + +> 这里记录了 `Hikage` 的版本更新历史。 + +::: danger + +我们只会对最新的 API 版本进行维护,若你正在使用过时的 API 版本则代表你自愿放弃一切维护的可能性。 + +::: + +## hikage-core + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven + +## hikage-compiler + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven + +## hikage-extension + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven + +## hikage-extension-betterandroid + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven + +## hikage-extension-compose + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven + +## hikage-widget-androidx + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven + +## hikage-widget-material + +### 1.0.0 | 2025.04.20 + +- 首个版本提交至 Maven \ No newline at end of file diff --git a/docs-source/src/zh-cn/about/contacts.md b/docs-source/src/zh-cn/about/contacts.md new file mode 100644 index 0000000..d63a20e --- /dev/null +++ b/docs-source/src/zh-cn/about/contacts.md @@ -0,0 +1,15 @@ +# 联系我们 + +> 如在使用中有任何问题,或有任何建设性的建议,都可以联系我们。 + +加入我们的开发者群组。 + +- [点击加入 Telegram 群组](https://t.me/BetterAndroid) +- [点击加入 Telegram 群组 (开发者)](https://t.me/HighCapable_Dev) +- [点击加入 QQ 群 (开发者)](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf) + +在 **酷安** 找到我 [@星夜不荟](http://www.coolapk.com/u/876977)。 + +## 助力维护 + +感谢您选择并使用 `Hikage`,如有代码相关的建议和请求,可在 GitHub 提交 Pull Request。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/about/future.md b/docs-source/src/zh-cn/about/future.md new file mode 100644 index 0000000..0eadadc --- /dev/null +++ b/docs-source/src/zh-cn/about/future.md @@ -0,0 +1,73 @@ +# 展望未来 + +> 未来是美好的,也是不确定的,让我们共同期待 `Hikage` 在未来的发展空间。 + +## 未来的计划 + +> 这里收录了 `Hikage` 可能会在后期添加的功能。 + +### 处理 AttrtibuteSet + +`Hikage` 未来将会支持处理 `AttributeSet` 来对接 XML 原始的属性以实现接管一些并未在代码中对布局属性开放自定义的第三方组件。 + +`Hikage` 目前已经支持自动化创建 `XmlBlock`,但尚未支持直接处理自定义的 `AttributeSet`,因为其历史遗留问题和处理难度较高,可能会折中考虑后期是否要继续完善此功能。 + +> 示例如下 + +```kotlin +TextView( + id = "text_view", + // 通过 AttributeSet 传入的属性 + attrs = { + namespace("android") { + set("text", "Hello, World!") + set("textSize", "16sp") + set("gravity", "center") + } + } +) { + // 通过代码传入的属性 + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER +} +``` + +### 生成组件 ID + +`Hikage` 未来可能会根据需求支持生成使用字符串自定义的组件 ID 的直接调用功能。 + +> 示例如下 + +```kotlin +object MyLayout : HikageBuilder { + + override fun build() = Hikageable(context) { + LinearLayout( + id = "lin_layout", + lparams = LayoutParams(matchParent = true), + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView(id = "text_view") { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } +} + +val context: Context +// 创建 TypedHikage +val myLayout = MyLayout.asTyped().build().create(context) +// 或者,使用懒加载 +val myLayout by context.lazyTypedHikage(MyLayout) +// 直接调用根据字符串生成的 ID +val linLayout = myLayout.linLayout +val textView = myLayout.textView +// 获取根布局,即 LinearLayout +val root = myLayout.root +``` \ No newline at end of file diff --git a/docs-source/src/zh-cn/config/r8-proguard.md b/docs-source/src/zh-cn/config/r8-proguard.md new file mode 100644 index 0000000..455273f --- /dev/null +++ b/docs-source/src/zh-cn/config/r8-proguard.md @@ -0,0 +1,17 @@ +# R8 与 Proguard 混淆 + +> 大部分场景下应用程序安装包可通过混淆压缩体积,这里介绍了混淆规则的配置方法。 + +`Hikage` 不需要额外配置混淆规则,由于 Hikage 装载的 `View` 不需要在 XML 中被定义,它们也可以同样被混淆。 + +你可以将你的自定义 `View`,例如 `com.yourpackage.YourView` 使用以下规则强制让它们被混淆。 + +``` +-allowobfuscation class com.yourpackage.YourView +``` + +如果你一定要防止 `Hikage` 被混淆或者混淆后发生了问题,那么你可以使用以下规则来防止 `Hikage` 被混淆。 + +``` +-keep class com.highcapable.hikage** +``` \ No newline at end of file diff --git a/docs-source/src/zh-cn/guide/home.md b/docs-source/src/zh-cn/guide/home.md new file mode 100644 index 0000000..e17ba0d --- /dev/null +++ b/docs-source/src/zh-cn/guide/home.md @@ -0,0 +1,109 @@ +# 介绍 + +> `Hikage` (发音 /ˈhɪkɑːɡeɪ/) 是一个 Android 响应式 UI 构建工具。 + +## 背景 + +这是一个 Android 响应式 UI 构建工具,它的设计聚焦于 **实时代码构建 UI**。 + +项目图标由 [MaiTungTM](https://github.com/Lagrio) 设计,名称取自 「BanG Dream It's MyGO!!!!!」 中的原创歌曲《春日影》(Haru**hikage**)。 + +为什么要... + + + + **なんで春日影レイアウト使いの?** + + + +不同于 Jetpack Compose 的声明式 UI,Hikage 专注于 Android 原生平台,它的设计目标是为了让开发者能够快速构建 UI 并可直接支持 Android 原生组件。 + +**Hikage 只是一个 UI 构建工具,自身并不提供任何 UI 组件**。 + +拒绝重复造轮子,我们的方案始终是兼容与高效,现在你可以抛弃 ViewBinding 和 XML 甚至是 `findViewById`,直接来尝试使用代码布局吧。 + +`Hikage` 配合我们的另一个项目 [BetterAndroid](https://github.com/BetterAndroid/BetterAndroid) 使用效果更佳,同时 `Hikage` 自身将自动引用 `BetterAndroid` 相关依赖作为核心内容。 + +## 用途 + +Hikage 主要适用于专注原生 Android 平台开发的开发者,自从 Kotlin 作为主要开发语言后,依然没有一套比较完美的工具能够使用 DSL 实现动态代码布局, +所以没有使用 Jetpack Compose 的项目依然需要使用原始的 XML,虽然有着 ViewBinding 的支持,但是依然不是很友好。 + +Hikage 继承了 [Anko](https://github.com/Kotlin/anko)、[Splitties](https://github.com/LouisCAD/Splitties) 的设计方案以及借鉴了 Jetpack Compose 的 DSL 函数命名方案, +并且在此基础上进行了大量改进,使得它在使用成本上更贴近原生,写法上更贴近 Jetpack Compose。 + +> 各种 DSL 布局方案对比 + +:::: code-group +::: code-group-item Hikage + +```kotlin +LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` + +::: +::: code-group-item Anko、Splitties + +```kotlin +verticalLayout { + gravity = Gravity.CENTER + textView("Hello, World!") { + textSize = 16f + gravity = Gravity.CENTER + } +}.lparams( + width = matchParent, + height = matchParent +) { + topMargin = dip(16) +} +``` + +::: +::: code-group-item Jetpack Compose + +```kotlin +Column( + modifier = Modifier.padding(top = 16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally +) { + Text( + text = "Hello, World!", + fontSize = 16.sp, + textAlign = TextAlign.Center + ) +} +``` + +::: +:::: + +Hikage 的基础部分**完全不需要借助外部及额外的编译插件**,它能**即插即用**并在**任何地方创建**一个可被设置到父布局以及 `Window` 上的 `View` 对象。 + +Hikage **全面兼容**混合式布局,你可以在 Hikage 中嵌入 XML (使用 `R.layout` 方案装载布局)、ViewBinding 甚至是 Jetpack Compose。 + +## 语言要求 + +推荐使用 Kotlin 作为首选开发语言,本项目完全使用 Kotlin 编写,且不再有计划兼容 Java。 + +文档全部的 Demo 示例代码都将使用 Kotlin 进行描述,如果你完全不会使用 Kotlin,那么你将有可能无法正常使用本项目。 + +## 功能贡献 + +本项目的维护离不开各位开发者的支持和贡献,目前这个项目处于初期阶段,可能依然存在一些问题或者缺少你需要的功能, +如果可能,欢迎提交 PR 为此项目贡献你认为需要的功能或前往 [GitHub Issues](repo://issues) 向我们提出建议。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/guide/quick-start.md b/docs-source/src/zh-cn/guide/quick-start.md new file mode 100644 index 0000000..63e16af --- /dev/null +++ b/docs-source/src/zh-cn/guide/quick-start.md @@ -0,0 +1,85 @@ +# 快速开始 + +> 集成 `Hikage` 到你的项目中。 + +## 项目要求 + +项目需要使用 `Android Studio` 或 `IntelliJ IDEA` 创建且类型为 Android 或 Kotlin Multiplatform 项目并已集成 Kotlin 环境依赖。 + +- Android Studio (建议 [从这里](https://developer.android.com/studio) 获取最新版本) + +- IntelliJ IDEA (建议 [从这里](https://www.jetbrains.com/idea) 获取最新版本) + +- Kotlin 1.9.0+、Gradle 8+、Java 17+、Android Gradle Plugin 8+ + +### 配置存储库 + +`Hikage` 的依赖发布在 **Maven Central** 和我们的公共存储库中,你可以使用如下方式配置存储库。 + +我们推荐使用 Kotlin DSL 作为 Gradle 构建脚本语言并推荐使用 [SweetDependency](https://github.com/HighCapable/SweetDependency) 来管理依赖。 + +#### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中配置存储库。 + +```yaml +repositories: + google: + maven-central: + # (可选) 你可以添加此 URL 以使用我们的公共存储库 + # 当 Sonatype-OSS 发生故障无法发布依赖时,此存储库作为备选进行添加 + # 详情请前往:https://github.com/HighCapable/maven-repository + highcapable-maven-releases: + # 中国大陆用户请将下方的 "raw.githubusercontent.com" 修改为 "raw.gitmirror.com" + url: https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases +``` + +#### 传统方式 + +在你的项目 `build.gradle.kts` 中配置存储库。 + +```kotlin +repositories { + google() + mavenCentral() + // (可选) 你可以添加此 URL 以使用我们的公共存储库 + // 当 Sonatype-OSS 发生故障无法发布依赖时,此存储库作为备选进行添加 + // 详情请前往:https://github.com/HighCapable/maven-repository + // 中国大陆用户请将下方的 "raw.githubusercontent.com" 修改为 "raw.gitmirror.com" + maven("https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases") +} +``` + +### 配置 Java 版本 + +在你的项目 `build.gradle.kts` 中修改 Kotlin 的 Java 版本为 17 及以上。 + +```kt +android { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } +} +``` + +## 功能一览 + +整个项目分为多个模块,你可以选择你希望引入的模块作为依赖应用到你的项目中,但一定要包含 **hikage-core** 模块。 + +你可以点击下方对应的模块前往查看详细的功能介绍。 + +- [hikage-core](../library/hikage-core.md) +- [hikage-compiler](../library/hikage-compiler.md) +- [hikage-extension](../library/hikage-extension.md) +- [hikage-extension-betterandroid](../library/hikage-extension-betterandroid.md) +- [hikage-extension-compose](../library/hikage-extension-compose.md) +- [hikage-widget-androidx](../library/hikage-widget-androidx.md) +- [hikage-widget-material](../library/hikage-widget-material.md) + +## Demo + +你可以在 [这里](repo://tree/main/samples) 找到一些示例,查看对应的演示项目来更好地了解这些功能的运作方式,快速地挑选出你需要的功能。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/index.md b/docs-source/src/zh-cn/index.md new file mode 100644 index 0000000..795c34b --- /dev/null +++ b/docs-source/src/zh-cn/index.md @@ -0,0 +1,65 @@ +--- +home: true +title: 首页 +heroImage: /images/logo.svg +actions: + - text: 快速上手 + link: /zh-cn/guide/home + type: primary + - text: 更新日志 + link: /zh-cn/about/changelog + type: secondary +features: + - title: 原生可控 + details: 使用 View 作为基础,Kotlin 作为开发语言,100% 动态代码布局,无需任何额外配置,支持自定义 View。 + - title: 全面兼容 + details: 支持 XML、ViewBinding 以及 Jetpack Compose 嵌入混合使用,并对 Material 组件及 Jetpack 提供支持。 + - title: 快速上手 + details: 简单易用,不需要繁琐的配置,不需要十足的开发经验,搭建环境集成依赖即可立即开始使用。 +footer: Apache-2.0 License | Copyright (C) 2019 HighCapable +--- + +### 布局,就是这么灵活。 + +:::: code-group +::: code-group-item Hikage (Kotlin DSL) + +```kotlin +LinearLayout( + lparams = LayoutParams(matchParent = true), + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + TextView(id = "text_view") { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` + +::: +::: code-group-item XML + +```xml + + + + + +``` + +::: +:::: \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-compiler.md b/docs-source/src/zh-cn/library/hikage-compiler.md new file mode 100644 index 0000000..eb4c7d5 --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-compiler.md @@ -0,0 +1,169 @@ +# hikage-compiler + + + + + + + +这是 Hikage 的自动化编译模块。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +::: warning + +你需要在你的项目中集成适合于你项目当前 Kotlin 版本的 [Google KSP](https://github.com/google/ksp/releases) 插件。 + +::: + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +plugins: + com.google.devtools.ksp: + version: + + +libraries: + com.highcapable.hikage: + hikage-compiler: + version: + +``` + +在你的根项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +plugins { + // ... + autowire(libs.plugins.com.google.devtools.ksp) apply false +} +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +plugins { + // ... + autowire(libs.plugins.com.google.devtools.ksp) +} + +dependencies { + // ... + ksp(com.highcapable.hikage.hikage.compiler) +} +``` + +### 传统方式 + +在你的根项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +plugins { + // ... + id("com.google.devtools.ksp") version "" apply false +} +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +plugins { + // ... + id("com.google.devtools.ksp") +} + +dependencies { + // ... + ksp("com.highcapable.hikage:hikage-compiler:") +} +``` + +请将 `` 修改为此文档顶部显示的版本,并将 `` 修改为你项目当前使用的 Kotlin 版本对应的 KSP 版本。 + +## 功能介绍 + +Hikage 的编译模块将在运行时自动生成代码,在更新后,请重新运行 `assembleDebug` 或 `assembleRelease` Task 以生成最新的代码。 + +### 生成布局组件 + +Hikage 可以在编译时为指定的布局组件自动生成布局组件对应的 `Hikageable` 函数。 + +#### 自定义 View + +你可以在你的自定义 `View` 上加入 `HikageView` 注解,以标记它生成为 Hikage 布局组件。 + +| 参数名称 | 描述 | +| ------------------ | --------------------------------------------------------------------------------------------------------------------- | +| `lparams` | 布局参数 `ViewGroup.LayoutParams` Class 对象,如果你的自定义 `View` 是 `ViewGroup` 的子类,则可以声明或留空使用默认值 | +| `alias` | 布局组件的别名,即要生成的函数名称,默认获取当前 Class 的名称 | +| `requireInit` | 是否要求填写布局的初始化方法块,默认为可省略的参数 | +| `requirePerformer` | 是否要求填写布局的 `performer` 方法块,默认为可省略的参数,仅在你的自定义 `View` 是 `ViewGroup` 的子类时生效 | + +> 示例如下 + +```kotlin +@HikageView(lparams = LinearLayout.LayoutParams::class) +class MyLayout(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) { + // ... +} +``` + +编译后,你就可以在 Hikage 布局中使用 `MyLayout` 作为布局组件了。 + +> 示例如下 + +```kotlin +Hikageable { + MyLayout { + TextView( + lparams = LayoutParams { + topMargin = 16.dp + } + ) { + text = "Hello, World!" + } + } +} +``` + +#### 第三方组件 + +Hikage 同样可以为第三方提供的 `View` 组件自动生成布局组件函数,你可以使用 `HikageViewDeclaration` 注解来完成。 + +| 参数名称 | 描述 | +| ------------------ | --------------------------------------------------------------------------------------------------------------------- | +| `view` | 需要声明的布局组件的 Class 对象 | +| `lparams` | 布局参数 `ViewGroup.LayoutParams` Class 对象,如果你的自定义 `View` 是 `ViewGroup` 的子类,则可以声明或留空使用默认值 | +| `alias` | 布局组件的别名,即要生成的函数名称,默认获取 `view` Class 的名称 | +| `requireInit` | 是否要求填写布局的初始化方法块,默认为可省略的参数 | +| `requirePerformer` | 是否要求填写布局的 `performer` 方法块,默认为可省略的参数,仅在你的自定义 `View` 是 `ViewGroup` 的子类时生效 | + +> 示例如下 + +```kotlin +@HikageViewDeclaration(ThirdPartyView::class) +object ThirdPartyViewDeclaration +``` + +这个注解可以声明到任意一个 `object` 类上,仅作为注解扫描器需要自动纳入的类来使用,你可以将可见性设为 `private`,但要确保被注解的类一定是使用 `object` 修饰的。 + +同样地,编译后,你就可以在 Hikage 布局中使用 `ThirdPartyView` 作为布局组件了。 + +> 示例如下 + +```kotlin +Hikageable { + ThirdPartyView { + // ... + } +} +``` + +::: tip + +Hikage 生成布局组件的函数包名路径为 `com.highcapable.hikage.widget` + 你的 `View` 或第三方 `View` 组件的完整包名。 + +::: \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-core.md b/docs-source/src/zh-cn/library/hikage-core.md new file mode 100644 index 0000000..4906134 --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-core.md @@ -0,0 +1,502 @@ +# hikage-core + + + + + + + +这是 Hikage 的核心依赖,你需要引入此模块才能使用 Hikage 的基本功能。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +libraries: + com.highcapable.hikage: + hikage-core: + version: + +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation(com.highcapable.hikage.hikage.core) +``` + +### 传统方式 + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation("com.highcapable.hikage:hikage-core:") +``` + +请将 `` 修改为此文档顶部显示的版本。 + +## 功能介绍 + +你可以 [点击这里](kdoc://hikage-core) 查看 KDoc。 + +### 基本用法 + +使用下方的代码创建你的第一个 Hikage 布局。 + +首先,使用 `Hikageable` 创建一个 `Hikage.Delegate` 对象。 + +> 示例如下 + +```kotlin +val myLayout = Hikageable { + LinearLayout { + TextView { + text = "Hello, World!" + } + } +} +``` + +然后,将其设置到你想要显示的父布局或根布局上。 + +> 示例如下 + +```kotlin +// 假设这就是你的 Activity +val activity: Activity +// 实例化 Hikage 对象 +val hikage = myLayout.create(activity) +// 得到根布局 +val root = hikage.root +// 设置为 Activity 的内容视图 +activity.setContentView(root) +``` + +这样我们就完成了一个简单的布局创建与设置。 + +### 布局约定 + +Hikage 的布局基本元素基于 Android 原生的 `View` 组件,所有的布局元素都可以直接使用 Android 原生的 `View` 组件进行创建。 + +所有布局的创建过程都会被限定在指定的作用域 `Hikage.Performer` 中,它被称为布局的 “演奏者”,即饰演布局的角色对象,这个对象可以通过以下几种方式创建并维护。 + +#### Hikageable + +正如 [基本用法](#基本用法) 所示,`Hikageable` 可以直接创建一个 `Hikage.Delegate` 或 `Hikage` 对象,在 DSL 中,你可以得到 `Hikage.Performer` 对象对布局内容进行创建。 + +第一种方案,在任意地方创建。 + +> 示例如下 + +```kotlin +// myLayout 是 Hikage.Delegate 对象 +val myLayout = Hikageable { + // ... +} +// 假设这就是你的 Context +val context: Context +// 在需要 Context 的地方实例化 Hikage 对象 +val hikage = myLayout.create(context) +``` + +第二种方案,在存在 `Context` 的地方直接创建。 + +> 示例如下 + +```kotlin +// 假设这就是你的 Context +val context: Context +// 创建布局,myLayout 是 Hikage 对象 +val myLayout = Hikageable(context) { + // ... +} +``` + +#### HikageBuilder + +除了上述的方式以外,你还可以维护一个 `HikageBuilder` 对象来预创建布局。 + +首先,我们需要创建一个 `HikageBuilder` 对象并定义为单例。 + +> 示例如下 + +```kotlin +object MyLayout : HikageBuilder { + + override fun build() = Hikageable { + // ... + } +} +``` + +然后,在需要的地方使用它,可以有如下两种方案。 + +第一种方案,直接使用 `build` 创建 `Hikage.Delegate` 对象。 + +> 示例如下 + +```kotlin +// myLayout 是 Hikage.Delegate 对象 +val myLayout = MyLayout.build() +// 假设这就是你的 Context +val context: Context +// 在需要 Context 的地方实例化 Hikage 对象 +val hikage = myLayout.create(context) +``` + +第二种方案,使用 `Context.lazyHikage` 创建 `Hikage` 委托对象。 + +例如,我们可以在 `Activity` 中像 `ViewBinding` 一样使用它。 + +> 示例如下 + +```kotlin +class MyActivity : AppCompatActivity() { + + private val myLayout by lazyHikage(MyLayout) + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + // 得到根布局 + val root = myLayout.root + // 设置为 Activity 的内容视图 + setContentView(root) + } +} +``` + +### 基本布局组件 + +Hikage 采用与 Jetpack Compose 一致的函数式创建组件方案,它的布局使用两种基础组件完成,`View` 和 `ViewGroup` 函数, +它们分别对应于 Android 原生基于 `View` 和 `ViewGroup` 的组件。 + +#### View + +`View` 函数的基础参数为以下三个,使用泛型定义创建的 `View` 对象类型。 + +如果不声明泛型类型,默认使用 `android.view.View` 作为创建的对象类型。 + +| 参数名称 | 描述 | +| --------- | ------------------------------------------------------------------- | +| `lparams` | 布局参数,即 `ViewGroup.LayoutParams`,使用 `LayoutParams` 进行创建 | +| `id` | 用于查找已创建对象的 ID,使用字符串定义 | +| `init` | `View` 的初始化方法体,作为最后一位 DSL 参数传入 | + +> 示例如下 + +```kotlin +View( + lparams = LayoutParams(), + id = "my_text_view" +) { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER +} +``` + +#### ViewGroup + +`ViewGroup` 函数的基础参数为四个,比较于 `View` 函数多了一个 `performer` 参数。 + +它必须声明一个泛型类型,因为 `ViewGroup` 是抽象类,需要一个具体的实现类。 + +`ViewGroup` 额外提供一个基于 `ViewGroup.LayoutParams` 的泛型参数,用于为子布局提供布局参数,不声明时默认使用 `ViewGroup.LayoutParams`。 + +| 参数名称 | 描述 | +| ----------- | ------------------------------------------------------------------- | +| `lparams` | 布局参数,即 `ViewGroup.LayoutParams`,使用 `LayoutParams` 进行创建 | +| `id` | 用于查找已创建对象的 ID,使用字符串定义 | +| `init` | `ViewGroup` 的初始化方法体,作为 DSL 参数传入 | +| `performer` | `Hikage.Performer` 对象,作为最后一位 DSL 参数传入 | + +`performer` 参数的作用是向下传递新的 `Hikage.Performer` 对象,作为子布局的创建者。 + +> 示例如下 + +```kotlin +ViewGroup( + lparams = LayoutParams(), + id = "my_linear_layout", + // 初始化方法体将在这里使用 `init` 体现 + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + // 可在这里继续创建子布局 + View() +} +``` + +#### LayoutParams + +Hikage 中的布局均可使用 `LayoutParams` 函数设置布局参数,你可以使用以下参数创建它。 + +| 参数名称 | 描述 | +| ------------------- | ------------------------------------------------- | +| `width` | 手动指定布局宽度 | +| `height` | 手动指定布局高度 | +| `matchParent` | 是否使用 `MATCH_PARENT` 作为布局宽度和高度 | +| `wrapContent` | 是否使用 `WRAP_CONTENT` 作为布局宽度和高度 | +| `widthMatchParent` | 仅设置宽度为 `MATCH_PARENT` | +| `heightMatchParent` | 仅设置高度为 `MATCH_PARENT` | +| `body` | 布局参数的初始化方法体,作为最后一位 DSL 参数传入 | + +在你不设置 `LayoutParams` 对象或不指定 `width` 和 `height` 时,Hikage 会自动使用 `WRAP_CONTENT` 作为布局参数。 + +`body` 方法体的类型来源于上层 [ViewGroup](#viewgroup) 提供的第二位泛型参数。 + +> 示例如下 + +```kotlin +View( + // 假设上层提供的布局参数类型为 LinearLayout.LayoutParams + lparams = LayoutParams(width = 100.dp) { + topMargin = 20.dp + } +) +``` + +如果你只需要一个横向填充的布局,可以直接使用 `widthMatchParent = true`。 + +> 示例如下 + +```kotlin +View( + lparams = LayoutParams(widthMatchParent = true) +) +``` + +#### Layout + +Hikage 支持引用第三方布局,你可以传入 XML 布局资源 ID、其它 Hikage 对象以及 `View` 对象,甚至是 `ViewBinding`。 + +> 示例如下 + +```kotlin +ViewGroup<...> { + // 引用 XML 布局资源 ID + Layout(R.layout.my_layout) + // 引用 ViewBinding + Layout() + // 引用另一个 Hikage 或 Hikage.Delegate 对象 + Layout(myLayout) +} +``` + +### 定位布局组件 + +Hikage 支持使用 `id` 定位组件,在上面的示例中,我们使用了 `id` 参数设置了组件的 ID。 + +在设置 ID 后,你可以使用 `Hikage.get` 方法获取它们。 + +> 示例如下 + +```kotlin +val myLayout = Hikageable { + View(id = "my_text_view") { + text = "Hello, World!" + } +} +// 假设这就是你的 Context +val context: Context +// 在需要 Context 的地方实例化 Hikage 对象 +val hikage = myLayout.create(context) +// 获取指定的组件,返回 View 类型 +val textView = hikage["my_text_view"] +// 获取指定的组件并声明组件类型 +val textView = hikage.get("my_text_view") +// 如果不确定 ID 是否存在,可以使用 `getOrNull` 方法 +val textView = hikage.getOrNull("my_text_view") +``` + +### 自定义布局组件 + +Hikage 为 Android 基础的布局组件提供了组件类名对应的函数,你可以直接使用这些函数创建组件,而无需再使用泛型声明它们,如果你需要 Jetpack 或者 Material 提供的组件, +可以引入 [hikage-widget-androidx](../library/hikage-widget-androidx.md) 或 [hikage-widget-material](../library/hikage-widget-material.md) 模块。 + +> 示例如下 + +```kotlin +LinearLayout( + lparams = LayoutParams(), + id = "my_linear_layout", + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + TextView( + lparams = LayoutParams(), + id = "my_text_view" + ) { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` + +初始化后的 `View` 或 `ViewGroup` 对象会返回其自身对象类型的实例,你可以在接下来的布局中使用它们。 + +> 示例如下 + +```kotlin +val textView = TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER +} +Button { + text = "Click Me!" + setOnClickListener { + // 直接使用 textView 对象 + textView.text = "Clicked!" + } +} +``` + +如果提供的组件不满足你的需求,你可以手动创建自己的组件。 + +> 示例如下 + +```kotlin +// 假设你已经定义好了你的自定义组件 +class MyCustomView(context: Context, attrs: AttributeSet? = null) : View(context, attrs) { + // ... +} + +// 下面,创建组件对应的函数 +// 自定义组件必须声明此注解 +// 声明组件的注解具有传染性,在每个用于构建布局的作用域中,都需要存在此注解 +@Hikageable +// 函数的命名可以随意,但是建议使用大驼峰命名 +// 函数的签名部分需要固定声明为 `inline fun Hikage.Performer` +inline fun Hikage.Performer.MyCustomView( + lparams: Hikage.LayoutParams? = null, + id: String? = null, + init: HikageView = {}, + // 如果此组件是容器,可以声明一个 `performer` 参数 + // performer: HikagePerformer = {} +) = View(lparams, id, init) +``` + +每次都手动实现这样复杂的函数看起来会很繁琐,如果你希望能够自动生成组件函数,可以引入并参考 [hikage-compiler](../library/hikage-compiler.md) 模块。 + +### 自定义布局装载器 + +Hikage 支持自定义布局装载器并同时兼容 `LayoutInflater.Factory2`,你可以通过以下方式自定义在 Hikage 布局装载过程中的事件和监听。 + +> 示例如下 + +```kotlin +val factory = HikageFactory { parent, base, context, params -> + // 你可以在这里自定义布局装载器的行为 + // 例如,使用你自己的方式创建一个新的 View 对象 + // `parent` 为当前组件要添加到的 ViewGroup 对象,如果没有则为 `null` + // `base` 为上一个 HikageFactory 创建的 View 对象,如果没有则为 `null` + // `params` 对象中包含了组件 ID、AttributeSet 以及 View 的 Class 对象 + val view = MyLayoutFactory.createView(context, params) + // 你还可以在这里对创建的 View 对象进行初始化和设置 + view.setBackgroundColor(Color.RED) + // 返回创建的 View 对象 + // 返回 `null` 将会使用默认的组件装载方式 + view +} +``` + +你还可以直接传入 `LayoutInflater` 对象以自动装载并使用其中的 `LayoutInflater.Factory2`。 + +> 示例如下 + +```kotlin +// 假设这就是你的 LayoutInflater 对象 +val layoutInflater: LayoutInflater +// 通过 LayoutInflater 创建 HikageFactory 对象 +val factory = HikageFactory(layoutInflater) +``` + +然后使用以下方式将其设置到你需要装载的 Hikage 布局上。 + +> 示例如下 + +```kotlin +// 假设这就是你的 Context +val context: Context +// 创建 Hikage 对象 +val hikage = Hikageable( + context = context, + factory = { + // 添加自定义的 HikageFactory 对象 + add(factory) + // 直接添加 + add { parent, base, context, params -> + // ... + null + } + // 连续添加多个 + addAll(factories) + } +) { + LinearLayout { + TextView { + text = "Hello, World!" + } + } +} +``` + +::: tip + +Hikage 在默认装载时将会根据传入 `Context` 对象的 `LayoutInflater.Factory2` 对布局进行装载,如果你正在使用 `AppCompatActivity`, +布局中的组件将会自动被替换为对应的 Compat 组件或 Material 组件,与 XML 布局的特性保持一致。 + +如果你不需要默认生效此特性,可以使用以下方式全局关闭。 + +> 示例如下 + +```kotlin +Hikage.isAutoProcessWithFactory2 = false +``` + +::: + +### 预览布局 + +Hikage 支持在 Android Studio 中预览布局,借助于 Android Studio 自带的自定义 `View` 预览插件,你可以使用以下方式预览布局。 + +你只需要定义一个预览布局的自定义 `View` 并继承于 `HikagePreview`。 + +> 示例如下 + +```kotlin +class MyLayoutPreview(context: Context, attrs: AttributeSet?) : HikagePreview(context, attrs) { + + override fun build() = Hikageable { + LinearLayout { + TextView { + text = "Hello, World!" + } + } + } +} +``` + +然后在你当前的窗口右侧应该会出现预览窗格,打开后点击 “Build & Refresh”,等待编译完成后将会自动显示预览。 + +::: tip + +`HikagePreview` 实现了 `HikageBuilder` 接口,你可以在 `build` 方法中返回任意的 Hikage 布局以进行预览。 + +::: + +::: danger + +`HikagePreview` 仅支持在 Android Studio 中预览布局,请勿在运行时使用它或将其添加到任何 XML 布局中。 + +::: \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-extension-betterandroid.md b/docs-source/src/zh-cn/library/hikage-extension-betterandroid.md new file mode 100644 index 0000000..6e5c167 --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-extension-betterandroid.md @@ -0,0 +1,74 @@ +# hikage-extension-betterandroid + + + + + + + +这是 Hikage 针对 [BetterAndroid](https://github.com/BetterAndroid/BetterAndroid) UI 组件相关功能的扩展依赖。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +libraries: + com.highcapable.hikage: + hikage-extension-betterandroid: + version: + +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation(com.highcapable.hikage.hikage.extension.betterandroid) +``` + +### 传统方式 + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation("com.highcapable.hikage:hikage-extension-betterandroid:") +``` + +请将 `` 修改为此文档顶部显示的版本。 + +## 功能介绍 + +你可以 [点击这里](kdoc://hikage-extension-betterandroid) 查看 KDoc。 + +### 适配器 (Adapter) 扩展 + +Hikage 为 BetterAndroid 提供的 [适配器](https://betterandroid.github.io/BetterAndroid/zh-cn/library/ui-component#%E9%80%82%E9%85%8D%E5%99%A8-adapter) +提供了布局扩展功能,你可以直接在适配器的原始扩展方法上使用 Hikage 布局。 + +它使用了 BetterAndroid 提供的 `ViewHolderDelegate` 来创建扩展方法。 + +下面提供了一个基于 `RecyclerView` 的简单示例。 + +> 示例如下 + +```kotlin +// 假设这就是你需要绑定的数据集 +val listData = ArrayList() +// 创建并绑定到自定义的 RecyclerView.Adapter +val adapter = recyclerView.bindAdapter { + onBindData { listData } + onBindItemView( + Hikageable = { + TextView(id = "text_view") { + text = "Hello, World!" + textSize = 16f + } + } + ) { hikage, bean, position -> + hikage.get("text_view").text = bean.name + } +} +``` \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-extension-compose.md b/docs-source/src/zh-cn/library/hikage-extension-compose.md new file mode 100644 index 0000000..fb05de9 --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-extension-compose.md @@ -0,0 +1,87 @@ +# hikage-extension-compose + + + + + + + +这是 Hikage 针对 Jetpack Compose 组件相关功能的扩展依赖。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +::: warning + +此模块依赖于 Jetpack Compose 编译插件,请确保你的项目中已经集成了 Jetpack Compose 相关依赖,详情请参考 [这里](https://developer.android.com/develop/ui/compose/compiler)。 + +::: + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +libraries: + com.highcapable.hikage: + hikage-extension-compose: + version: + +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation(com.highcapable.hikage.hikage.extension.compose) +``` + +### 传统方式 + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation("com.highcapable.hikage:hikage-extension-compose:") +``` + +请将 `` 修改为此文档顶部显示的版本。 + +## 功能介绍 + +你可以 [点击这里](kdoc://hikage-extension-compose) 查看 KDoc。 + +### 在 Hikage 中使用 Jetpack Compose + +你可以使用以下方式在一个 Hikage 布局中嵌入 Jetpack Compose 组件。 + +> 示例如下 + +```kotlin +Hikageable { + ComposeView( + lparams = LayoutParams(matchParent = true) + ) { + Text("Hello, World!") + } +} +``` + +### 在 Jetpack Compose 中使用 Hikage + +你可以使用以下方式在一个 Jetpack Compose 布局中嵌入 Hikage 组件。 + +> 示例如下 + +```kotlin +Column( + modifier = Modifier.fillMaxSize() +) { + HikageView { + TextView( + lparams = LayoutParams(matchParent = true) + ) { + text = "Hello, World!" + textSize = 20f + } + } +} +``` \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-extension.md b/docs-source/src/zh-cn/library/hikage-extension.md new file mode 100644 index 0000000..d85e6b7 --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-extension.md @@ -0,0 +1,208 @@ +# hikage-extension + + + + + + + +这是 Hikage 针对 UI 组件相关功能的扩展依赖。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +libraries: + com.highcapable.hikage: + hikage-extension: + version: + +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation(com.highcapable.hikage.hikage.extension) +``` + +### 传统方式 + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation("com.highcapable.hikage:hikage-extension:") +``` + +请将 `` 修改为此文档顶部显示的版本。 + +## 功能介绍 + +你可以 [点击这里](kdoc://hikage-extension) 查看 KDoc。 + +### Activity + +Hikage 为 `Activity` 提供了更好用的扩展,在 `Activity` 中创建 Hikage 将会变得更加简单。 + +> 示例如下 + +```kotlin +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView { + LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } + } +} +``` + +借助 `Hikage` 的 `setContentView` 扩展方法,你可以像 Jetpack Compose 一样使用 `setContent` 方法来设置布局。 + +### Window + +在 `Window` 中使用 Hikage 创建布局与 [Activity](#activity) 保持一致,你只需要使用 `setContentView` 方法传入一个 `Hikage` 布局即可。 + +### Dialog + +如果你想直接在 `AlertDialog` 中使用 Hikage 创建布局,现在你可以使用以下方案更加简单地进行。 + +> 示例如下 + +```kotlin +// 假设这就是你的 Context +val context: Context +// 创建对话框并显示 +AlertDialog.Builder(context) + .setTitle("Hello, World!") + .setView { + TextView { + text = "Hello, World!" + textSize = 16f + } + } + .show() +``` + +在 `AlertDialog` 中使用 Hikage 创建布局,你只需要使用 `setView` 方法传入一个 `Hikage` 布局即可。 + +如果你是继承于 `Dialog` 进行自定义,那么你可以和像在 [Activity](#activity) 一样使用 `setContentView` 方法。 + +> 示例如下 + +```kotlin +class CustomDialog(context: Context) : Dialog(context) { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView { + LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } + } +} +``` + +### PopupWindow + +你可以继承于 `PopupWindow` 进行自定义,然后使用 Hikage 创建布局,你可以和像在 [Activity](#activity) 一样使用 `setContentView` 方法。 + +> 示例如下 + +```kotlin +class CustomPopupWindow(context: Context) : PopupWindow(context) { + + init { + setContentView(context) { + LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } + ) { + TextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + } + } + } +} +``` + +::: danger + +创建 Hikage 布局的 `PopupWindow` 需要使用 `Context` 构造方法进行初始化,如果当前无法立即获取到 `Context`,请对 `setContentView` 方法传入 `Context` 实例。 + +::: + +### ViewGroup + +Hikage 对 `ViewGroup` 的 `addView` 方法进行了扩展,你可以直接使用 Hikage 布局来为当前 `ViewGroup` 快速添加新的布局。 + +> 示例如下 + +```kotlin +// 假设这就是你的 ViewGroup +val root: FrameLayout +// 添加 Hikage 布局 +root.addView { + TextView { + text = "Hello, World!" + textSize = 16f + } +} +``` + +或者,在自定义 `View` 中使用。 + +> 示例如下 + +```kotlin +class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { + + init { + addView { + TextView { + text = "Hello, World!" + textSize = 16f + } + } + } +} +``` \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-widget-androidx.md b/docs-source/src/zh-cn/library/hikage-widget-androidx.md new file mode 100644 index 0000000..a963804 --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-widget-androidx.md @@ -0,0 +1,64 @@ +# hikage-widget-androidx + + + + + + + +这是 Hikage 针对 Jetpack Compact 组件相关功能的扩展依赖。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +libraries: + com.highcapable.hikage: + hikage-widget-androidx: + version: + +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation(com.highcapable.hikage.hikage.widget.androidx) +``` + +### 传统方式 + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation("com.highcapable.hikage:hikage-widget-androidx:") +``` + +请将 `` 修改为此文档顶部显示的版本。 + +## 功能介绍 + +这个依赖中继承了来自 Jetpack Compact 中的可用组件,你可以直接引用它们到 Hikage 中使用。 + +> 示例如下 + +```kotlin +LinearLayoutCompact( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayoutCompat.VERTICAL + gravity = Gravity.CENTER + } +) { + AppCompatTextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } +} +``` \ No newline at end of file diff --git a/docs-source/src/zh-cn/library/hikage-widget-material.md b/docs-source/src/zh-cn/library/hikage-widget-material.md new file mode 100644 index 0000000..5ac1bcc --- /dev/null +++ b/docs-source/src/zh-cn/library/hikage-widget-material.md @@ -0,0 +1,80 @@ +# hikage-widget-material + + + + + + + +这是 Hikage 针对 Google Material (MDC) 组件相关功能的扩展依赖。 + +## 配置依赖 + +你可以使用如下方式将此模块添加到你的项目中。 + +### SweetDependency (推荐) + +在你的项目 `SweetDependency` 配置文件中添加依赖。 + +```yaml +libraries: + com.highcapable.hikage: + hikage-widget-material: + version: + +``` + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation(com.highcapable.hikage.hikage.widget.material) +``` + +### 传统方式 + +在你的项目 `build.gradle.kts` 中配置依赖。 + +```kotlin +implementation("com.highcapable.hikage:hikage-widget-material:") +``` + +请将 `` 修改为此文档顶部显示的版本。 + +## 功能介绍 + +这个依赖中继承了来自 Google Material (MDC) 中的可用组件,你可以直接引用它们到 Hikage 中使用。 + +> 示例如下 + +```kotlin +LinearLayout( + lparams = LayoutParams(matchParent = true) { + topMargin = 16.dp + }, + init = { + orientation = LinearLayout.VERTICAL + gravity = Gravity.CENTER + } +) { + MaterialTextView { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + MaterialButton { + text = "Hello, World!" + textSize = 16f + gravity = Gravity.CENTER + } + TextInputLayout( + lparams = LayoutParams { + topMargin = 16.dp + }, + init = { + minWidth = 200.dp + hint = "Enter your text" + } + ) { + TextInputEditText() + } +} +``` \ No newline at end of file diff --git a/docs-source/yarn.lock b/docs-source/yarn.lock new file mode 100644 index 0000000..4f88786 --- /dev/null +++ b/docs-source/yarn.lock @@ -0,0 +1,2004 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/parser@^7.18.4": + version "7.18.13" + resolved "https://repo.huaweicloud.com/repository/npm/@babel/parser/-/parser-7.18.13.tgz#5b2dd21cae4a2c5145f1fbd8ca103f9313d3b7e4" + integrity sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg== + +"@babel/parser@^7.23.5": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.6.tgz#ba1c9e512bda72a47e285ae42aff9d2a635a9e3b" + integrity sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ== + +"@esbuild/android-arm64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.9.tgz#683794bdc3d27222d3eced7b74cad15979548031" + integrity sha512-q4cR+6ZD0938R19MyEW3jEsMzbb/1rulLXiNAJQADD/XYp7pT+rOS5JGxvpRW8dFDEfjW4wLgC/3FXIw4zYglQ== + +"@esbuild/android-arm@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.19.9.tgz#21a4de41f07b2af47401c601d64dfdefd056c595" + integrity sha512-jkYjjq7SdsWuNI6b5quymW0oC83NN5FdRPuCbs9HZ02mfVdAP8B8eeqLSYU3gb6OJEaY5CQabtTFbqBf26H3GA== + +"@esbuild/android-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.19.9.tgz#e2d7674bc025ddc8699f0cc76cb97823bb63c252" + integrity sha512-KOqoPntWAH6ZxDwx1D6mRntIgZh9KodzgNOy5Ebt9ghzffOk9X2c1sPwtM9P+0eXbefnDhqYfkh5PLP5ULtWFA== + +"@esbuild/darwin-arm64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.9.tgz#ae7a582289cc5c0bac15d4b9020a90cb7288f1e9" + integrity sha512-KBJ9S0AFyLVx2E5D8W0vExqRW01WqRtczUZ8NRu+Pi+87opZn5tL4Y0xT0mA4FtHctd0ZgwNoN639fUUGlNIWw== + +"@esbuild/darwin-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.19.9.tgz#8a216c66dcf51addeeb843d8cfaeff712821d12b" + integrity sha512-vE0VotmNTQaTdX0Q9dOHmMTao6ObjyPm58CHZr1UK7qpNleQyxlFlNCaHsHx6Uqv86VgPmR4o2wdNq3dP1qyDQ== + +"@esbuild/freebsd-arm64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.9.tgz#63d4f603e421252c3cd836b18d01545be7c6c440" + integrity sha512-uFQyd/o1IjiEk3rUHSwUKkqZwqdvuD8GevWF065eqgYfexcVkxh+IJgwTaGZVu59XczZGcN/YMh9uF1fWD8j1g== + +"@esbuild/freebsd-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.9.tgz#a3db52595be65360eae4de1d1fa3c1afd942e1e4" + integrity sha512-WMLgWAtkdTbTu1AWacY7uoj/YtHthgqrqhf1OaEWnZb7PQgpt8eaA/F3LkV0E6K/Lc0cUr/uaVP/49iE4M4asA== + +"@esbuild/linux-arm64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.19.9.tgz#4ae5811ce9f8d7df5eb9edd9765ea9401a534f13" + integrity sha512-PiPblfe1BjK7WDAKR1Cr9O7VVPqVNpwFcPWgfn4xu0eMemzRp442hXyzF/fSwgrufI66FpHOEJk0yYdPInsmyQ== + +"@esbuild/linux-arm@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.19.9.tgz#9807e92cfd335f46326394805ad488e646e506f2" + integrity sha512-C/ChPohUYoyUaqn1h17m/6yt6OB14hbXvT8EgM1ZWaiiTYz7nWZR0SYmMnB5BzQA4GXl3BgBO1l8MYqL/He3qw== + +"@esbuild/linux-ia32@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.19.9.tgz#18892c10f3106652b16f9da88a0362dc95ed46c7" + integrity sha512-f37i/0zE0MjDxijkPSQw1CO/7C27Eojqb+r3BbHVxMLkj8GCa78TrBZzvPyA/FNLUMzP3eyHCVkAopkKVja+6Q== + +"@esbuild/linux-loong64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.19.9.tgz#dc2ebf9a125db0a1bba18c2bbfd4fbdcbcaf61c2" + integrity sha512-t6mN147pUIf3t6wUt3FeumoOTPfmv9Cc6DQlsVBpB7eCpLOqQDyWBP1ymXn1lDw4fNUSb/gBcKAmvTP49oIkaA== + +"@esbuild/linux-mips64el@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.9.tgz#4c2f7c5d901015e3faf1563c4a89a50776cb07fd" + integrity sha512-jg9fujJTNTQBuDXdmAg1eeJUL4Jds7BklOTkkH80ZgQIoCTdQrDaHYgbFZyeTq8zbY+axgptncko3v9p5hLZtw== + +"@esbuild/linux-ppc64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.9.tgz#8385332713b4e7812869622163784a5633f76fc4" + integrity sha512-tkV0xUX0pUUgY4ha7z5BbDS85uI7ABw3V1d0RNTii7E9lbmV8Z37Pup2tsLV46SQWzjOeyDi1Q7Wx2+QM8WaCQ== + +"@esbuild/linux-riscv64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.9.tgz#23f1db24fa761be311874f32036c06249aa20cba" + integrity sha512-DfLp8dj91cufgPZDXr9p3FoR++m3ZJ6uIXsXrIvJdOjXVREtXuQCjfMfvmc3LScAVmLjcfloyVtpn43D56JFHg== + +"@esbuild/linux-s390x@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.19.9.tgz#2dffe497726b897c9f0109e774006e25b33b4fd0" + integrity sha512-zHbglfEdC88KMgCWpOl/zc6dDYJvWGLiUtmPRsr1OgCViu3z5GncvNVdf+6/56O2Ca8jUU+t1BW261V6kp8qdw== + +"@esbuild/linux-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.19.9.tgz#ceb1d62cd830724ff5b218e5d3172a8bad59420e" + integrity sha512-JUjpystGFFmNrEHQnIVG8hKwvA2DN5o7RqiO1CVX8EN/F/gkCjkUMgVn6hzScpwnJtl2mPR6I9XV1oW8k9O+0A== + +"@esbuild/netbsd-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.9.tgz#0cbca65e9ef4d3fc41502d3e055e6f49479a8f18" + integrity sha512-GThgZPAwOBOsheA2RUlW5UeroRfESwMq/guy8uEe3wJlAOjpOXuSevLRd70NZ37ZrpO6RHGHgEHvPg1h3S1Jug== + +"@esbuild/openbsd-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.9.tgz#1f57adfbee09c743292c6758a3642e875bcad1cf" + integrity sha512-Ki6PlzppaFVbLnD8PtlVQfsYw4S9n3eQl87cqgeIw+O3sRr9IghpfSKY62mggdt1yCSZ8QWvTZ9jo9fjDSg9uw== + +"@esbuild/sunos-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.19.9.tgz#116be6adbd2c7479edeeb5f6ea0441002ab4cb9c" + integrity sha512-MLHj7k9hWh4y1ddkBpvRj2b9NCBhfgBt3VpWbHQnXRedVun/hC7sIyTGDGTfsGuXo4ebik2+3ShjcPbhtFwWDw== + +"@esbuild/win32-arm64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.19.9.tgz#2be22131ab18af4693fd737b161d1ef34de8ca9d" + integrity sha512-GQoa6OrQ8G08guMFgeXPH7yE/8Dt0IfOGWJSfSH4uafwdC7rWwrfE6P9N8AtPGIjUzdo2+7bN8Xo3qC578olhg== + +"@esbuild/win32-ia32@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.19.9.tgz#e10ead5a55789b167b4225d2469324538768af7c" + integrity sha512-UOozV7Ntykvr5tSOlGCrqU3NBr3d8JqPes0QWN2WOXfvkWVGRajC+Ym0/Wj88fUgecUCLDdJPDF0Nna2UK3Qtg== + +"@esbuild/win32-x64@0.19.9": + version "0.19.9" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.9.tgz#b2da6219b603e3fa371a78f53f5361260d0c5585" + integrity sha512-oxoQgglOP7RH6iasDrhY+R/3cHrfwIDvRlT4CGChflq6twk8iENeVvMJjmvBb94Ik1Z+93iGO27err7w6l54GQ== + +"@jridgewell/sourcemap-codec@^1.4.15": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@mdit-vue/plugin-component@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/plugin-component/-/plugin-component-1.0.0.tgz#fdc41e58ef8b2207c94864657b27bb52f891bea9" + integrity sha512-ZXsJwxkG5yyTHARIYbR74cT4AZ0SfMokFFjiHYCbypHIeYWgJhso4+CZ8+3V9EWFG3EHlGoKNGqKp9chHnqntQ== + dependencies: + "@types/markdown-it" "^13.0.1" + markdown-it "^13.0.1" + +"@mdit-vue/plugin-frontmatter@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/plugin-frontmatter/-/plugin-frontmatter-1.0.0.tgz#c968335a96c0c65e623ba3e4cc6fb89a8e5a012b" + integrity sha512-MMA7Ny+YPZA7eDOY1t4E+rKuEWO39mzDdP/M68fKdXJU6VfcGkPr7gnpnJfW2QBJ5qIvMrK/3lDAA2JBy5TfpA== + dependencies: + "@mdit-vue/types" "1.0.0" + "@types/markdown-it" "^13.0.1" + gray-matter "^4.0.3" + markdown-it "^13.0.1" + +"@mdit-vue/plugin-headers@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/plugin-headers/-/plugin-headers-1.0.0.tgz#4e3d9f13d69ec2de325a5502ba08da09f62f2cd6" + integrity sha512-0rK/iKy6x13d/Pp5XxdLBshTD0+YjZvtHIaIV+JO+/H2WnOv7oaRgs48G5d44z3XJVUE2u6fNnTlI169fef0/A== + dependencies: + "@mdit-vue/shared" "1.0.0" + "@mdit-vue/types" "1.0.0" + "@types/markdown-it" "^13.0.1" + markdown-it "^13.0.1" + +"@mdit-vue/plugin-sfc@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/plugin-sfc/-/plugin-sfc-1.0.0.tgz#ecebfe3483db009a03bca9b9cebf549c0b31591c" + integrity sha512-agMUe0fY4YHxsZivSvplBwRwrFvsIf/JNUJCAYq1+2Sg9+2hviTBZwjZDxYqHDHOVLtiNr+wuo68tE24mAx3AQ== + dependencies: + "@mdit-vue/types" "1.0.0" + "@types/markdown-it" "^13.0.1" + markdown-it "^13.0.1" + +"@mdit-vue/plugin-title@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/plugin-title/-/plugin-title-1.0.0.tgz#6010990870d24bc86577b88890c92fcf3344e566" + integrity sha512-8yC60fCZ95xcJ/cvJH4Lv43Rs4k+33UGyKrRWj5J8TNyMwUyGcwur0XyPM+ffJH4/Bzq4myZLsj/TTFSkXRxvw== + dependencies: + "@mdit-vue/shared" "1.0.0" + "@mdit-vue/types" "1.0.0" + "@types/markdown-it" "^13.0.1" + markdown-it "^13.0.1" + +"@mdit-vue/plugin-toc@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/plugin-toc/-/plugin-toc-1.0.0.tgz#d961b537643b3dc1c9a17f2739f1361b9839f031" + integrity sha512-WN8blfX0X/5Nolic0ClDWP7eVo9IB+U4g0jbycX3lolIZX5Bai1UpsD3QYZr5VVsPbQJMKMGvTrCEtCNTGvyWQ== + dependencies: + "@mdit-vue/shared" "1.0.0" + "@mdit-vue/types" "1.0.0" + "@types/markdown-it" "^13.0.1" + markdown-it "^13.0.1" + +"@mdit-vue/shared@1.0.0", "@mdit-vue/shared@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/shared/-/shared-1.0.0.tgz#d8456da39c08c20ccadef7ba7321ecff4b05d330" + integrity sha512-nbYBfmEi+pR2Lm0Z6TMVX2/iBjfr/kGEsHW8CC0rQw+3+sG5dY6VG094HuFAkiAmmvZx9DZZb+7ZMWp9vkwCRw== + dependencies: + "@mdit-vue/types" "1.0.0" + "@types/markdown-it" "^13.0.1" + markdown-it "^13.0.1" + +"@mdit-vue/types@1.0.0", "@mdit-vue/types@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@mdit-vue/types/-/types-1.0.0.tgz#4950ae987a7c0d8377122bd3b09a53536911ca38" + integrity sha512-xeF5+sHLzRNF7plbksywKCph4qli20l72of2fMlZQQ7RECvXYrRkE9+bjRFQCyULC7B8ydUYbpbkux5xJlVWyw== + +"@mr-hope/vuepress-plugin-copy-code@^1.30.0": + version "1.30.0" + resolved "https://repo.huaweicloud.com/repository/npm/@mr-hope/vuepress-plugin-copy-code/-/vuepress-plugin-copy-code-1.30.0.tgz#ab2ad1fb418948c1513ab5d7daeb343547f07b69" + integrity sha512-odDox9FKRjfW9RHNo30TlmAe74VVMmn4vjqfJ/nfzBkgghZArz7CdzIfg8zSfJ4PaQoNxEc57uAQ7w/jeM2Efg== + dependencies: + "@mr-hope/vuepress-shared" "1.30.0" + "@mr-hope/vuepress-types" "1.30.0" + balloon-css "^1.2.0" + +"@mr-hope/vuepress-shared@1.30.0": + version "1.30.0" + resolved "https://repo.huaweicloud.com/repository/npm/@mr-hope/vuepress-shared/-/vuepress-shared-1.30.0.tgz#c93949160b86cb03fb57c0a6e91a8d75bf48081d" + integrity sha512-yJS0IaWJ8eCJXKCpY0TjFU5xhgrIg11SoFQjq0KuR8C7VMYsC9JPPv/tV5g0d9SAdshooUinibO3rOZcwHbMHA== + dependencies: + "@mr-hope/vuepress-types" "1.30.0" + +"@mr-hope/vuepress-types@1.30.0": + version "1.30.0" + resolved "https://repo.huaweicloud.com/repository/npm/@mr-hope/vuepress-types/-/vuepress-types-1.30.0.tgz#938d45213ba7099e817ef6df46abf2d5ce437b2d" + integrity sha512-XsPxmevdUxrKKx5l/1JS/wkzzRWMcd1wGrQaahETUbeZ9HuxUCNrLnUc9aH8ngss91LZ01qPiAx69zxIBQUcOw== + dependencies: + "@types/express" "^4.17.13" + "@types/markdown-it" "^10.0.3" + "@types/markdown-it-anchor" "^7.0.0" + "@types/webpack-dev-server" "^3.11.6" + cac "^6.7.12" + vue "^2.6.14" + webpack-chain "^6.5.1" + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://repo.huaweicloud.com/repository/npm/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://repo.huaweicloud.com/repository/npm/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://repo.huaweicloud.com/repository/npm/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@rollup/rollup-android-arm-eabi@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.1.tgz#beaf518ee45a196448e294ad3f823d2d4576cf35" + integrity sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig== + +"@rollup/rollup-android-arm64@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.1.tgz#6f76cfa759c2d0fdb92122ffe28217181a1664eb" + integrity sha512-Jto9Fl3YQ9OLsTDWtLFPtaIMSL2kwGyGoVCmPC8Gxvym9TCZm4Sie+cVeblPO66YZsYH8MhBKDMGZ2NDxuk/XQ== + +"@rollup/rollup-darwin-arm64@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.1.tgz#9aaefe33a5481d66322d1c62f368171c03eabe2b" + integrity sha512-LtYcLNM+bhsaKAIGwVkh5IOWhaZhjTfNOkGzGqdHvhiCUVuJDalvDxEdSnhFzAn+g23wgsycmZk1vbnaibZwwA== + +"@rollup/rollup-darwin-x64@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.1.tgz#707dcaadcdc6bd3fd6c69f55d9456cd4446306a3" + integrity sha512-KyP/byeXu9V+etKO6Lw3E4tW4QdcnzDG/ake031mg42lob5tN+5qfr+lkcT/SGZaH2PdW4Z1NX9GHEkZ8xV7og== + +"@rollup/rollup-linux-arm-gnueabihf@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.1.tgz#7a4dbbd1dd98731d88a55aefcef0ec4c578fa9c7" + integrity sha512-Yqz/Doumf3QTKplwGNrCHe/B2p9xqDghBZSlAY0/hU6ikuDVQuOUIpDP/YcmoT+447tsZTmirmjgG3znvSCR0Q== + +"@rollup/rollup-linux-arm64-gnu@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.1.tgz#967ba8e6f68a5f21bd00cd97773dcdd6107e94ed" + integrity sha512-u3XkZVvxcvlAOlQJ3UsD1rFvLWqu4Ef/Ggl40WAVCuogf4S1nJPHh5RTgqYFpCOvuGJ7H5yGHabjFKEZGExk5Q== + +"@rollup/rollup-linux-arm64-musl@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.1.tgz#d3a4e1c9f21eef3b9f4e4989f334a519a1341462" + integrity sha512-0XSYN/rfWShW+i+qjZ0phc6vZ7UWI8XWNz4E/l+6edFt+FxoEghrJHjX1EY/kcUGCnZzYYRCl31SNdfOi450Aw== + +"@rollup/rollup-linux-riscv64-gnu@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.1.tgz#415c0533bb752164effd05f5613858e8f6779bc9" + integrity sha512-LmYIO65oZVfFt9t6cpYkbC4d5lKHLYv5B4CSHRpnANq0VZUQXGcCPXHzbCXCz4RQnx7jvlYB1ISVNCE/omz5cw== + +"@rollup/rollup-linux-x64-gnu@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.1.tgz#0983385dd753a2e0ecaddea7a81dd37fea5114f5" + integrity sha512-kr8rEPQ6ns/Lmr/hiw8sEVj9aa07gh1/tQF2Y5HrNCCEPiCBGnBUt9tVusrcBBiJfIt1yNaXN6r1CCmpbFEDpg== + +"@rollup/rollup-linux-x64-musl@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.1.tgz#eb7494ebc5199cbd2e5c38c2b8acbe2603f35e03" + integrity sha512-t4QSR7gN+OEZLG0MiCgPqMWZGwmeHhsM4AkegJ0Kiy6TnJ9vZ8dEIwHw1LcZKhbHxTY32hp9eVCMdR3/I8MGRw== + +"@rollup/rollup-win32-arm64-msvc@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.1.tgz#5bebc66e3a7f82d4b9aa9ff448e7fc13a69656e9" + integrity sha512-7XI4ZCBN34cb+BH557FJPmh0kmNz2c25SCQeT9OiFWEgf8+dL6ZwJ8f9RnUIit+j01u07Yvrsuu1rZGxJCc51g== + +"@rollup/rollup-win32-ia32-msvc@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.1.tgz#34156ebf8b4de3b20e6497260fe519a30263f8cf" + integrity sha512-yE5c2j1lSWOH5jp+Q0qNL3Mdhr8WuqCNVjc6BxbVfS5cAS6zRmdiw7ktb8GNpDCEUJphILY6KACoFoRtKoqNQg== + +"@rollup/rollup-win32-x64-msvc@4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.1.tgz#d146db7a5949e10837b323ce933ed882ac878262" + integrity sha512-PyJsSsafjmIhVgaI1Zdj7m8BB8mMckFah/xbpplObyHfiXzKcI5UOUXRyOdHW7nz4DpMCuzLnF7v5IWHenCwYA== + +"@sindresorhus/merge-streams@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/merge-streams/-/merge-streams-1.0.0.tgz#9cd84cc15bc865a5ca35fcaae198eb899f7b5c90" + integrity sha512-rUV5WyJrJLoloD4NDN1V1+LDMDWOa4OTsT4yYJwQNpTU6FWxkxHpL7eu4w+DmiH8x/EAM1otkPE1+LaspIbplw== + +"@types/body-parser@*": + version "1.19.2" + resolved "https://repo.huaweicloud.com/repository/npm/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" + integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/connect-history-api-fallback@*": + version "1.3.5" + resolved "https://repo.huaweicloud.com/repository/npm/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae" + integrity sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw== + dependencies: + "@types/express-serve-static-core" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.35" + resolved "https://repo.huaweicloud.com/repository/npm/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" + integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== + dependencies: + "@types/node" "*" + +"@types/debug@^4.1.12": + version "4.1.12" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917" + integrity sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ== + dependencies: + "@types/ms" "*" + +"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.18": + version "4.17.30" + resolved "https://repo.huaweicloud.com/repository/npm/@types/express-serve-static-core/-/express-serve-static-core-4.17.30.tgz#0f2f99617fa8f9696170c46152ccf7500b34ac04" + integrity sha512-gstzbTWro2/nFed1WXtf+TtrpwxH7Ggs4RLYTLbeVgIkUQOI3WG/JKjgeOU1zXDvezllupjrf8OPIdvTbIaVOQ== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + +"@types/express@*", "@types/express@^4.17.13": + version "4.17.13" + resolved "https://repo.huaweicloud.com/repository/npm/@types/express/-/express-4.17.13.tgz#a76e2995728999bab51a33fabce1d705a3709034" + integrity sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "^4.17.18" + "@types/qs" "*" + "@types/serve-static" "*" + +"@types/fs-extra@^11.0.4": + version "11.0.4" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.4.tgz#e16a863bb8843fba8c5004362b5a73e17becca45" + integrity sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ== + dependencies: + "@types/jsonfile" "*" + "@types/node" "*" + +"@types/hash-sum@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@types/hash-sum/-/hash-sum-1.0.2.tgz#32e6e4343ee25914b2a3822f27e8e641ca534f63" + integrity sha512-UP28RddqY8xcU0SCEp9YKutQICXpaAq9N8U2klqF5hegGha7KzTOL8EdhIIV3bOSGBzjEpN9bU/d+nNZBdJYVw== + +"@types/highlight.js@^9.7.0": + version "9.12.4" + resolved "https://repo.huaweicloud.com/repository/npm/@types/highlight.js/-/highlight.js-9.12.4.tgz#8c3496bd1b50cc04aeefd691140aa571d4dbfa34" + integrity sha512-t2szdkwmg2JJyuCM20e8kR2X59WCE5Zkl4bzm1u1Oukjm79zpbiAv+QjnwLnuuV0WHEcX2NgUItu0pAMKuOPww== + +"@types/http-proxy@^1.17.5": + version "1.17.9" + resolved "https://repo.huaweicloud.com/repository/npm/@types/http-proxy/-/http-proxy-1.17.9.tgz#7f0e7931343761efde1e2bf48c40f02f3f75705a" + integrity sha512-QsbSjA/fSk7xB+UXlCT3wHBy5ai9wOcNDWwZAtud+jXhwOM3l+EYZh8Lng4+/6n8uar0J7xILzqftJdJ/Wdfkw== + dependencies: + "@types/node" "*" + +"@types/jsonfile@*": + version "6.1.2" + resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.2.tgz#d3b8a3536c5bb272ebee0f784180e456b7691c8f" + integrity sha512-8t92P+oeW4d/CRQfJaSqEwXujrhH4OEeHRjGU3v1Q8mUS8GPF3yiX26sw4svv6faL2HfBtGTe2xWIoVgN3dy9w== + dependencies: + "@types/node" "*" + +"@types/linkify-it@*": + version "3.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/@types/linkify-it/-/linkify-it-3.0.2.tgz#fd2cd2edbaa7eaac7e7f3c1748b52a19143846c9" + integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA== + +"@types/markdown-it-anchor@^7.0.0": + version "7.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/@types/markdown-it-anchor/-/markdown-it-anchor-7.0.0.tgz#4de1bea40ebf7643990ef35c51908e037bfa48a8" + integrity sha512-kFehISVfgSePSp6JWGWrcgKIPoPpAsZAqTLUt0Wq9+MNiGdnWdXQy8UerwhmD2afmjux1TWf8XCmlpL2/6ax/A== + dependencies: + markdown-it-anchor "*" + +"@types/markdown-it-emoji@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/markdown-it-emoji/-/markdown-it-emoji-2.0.4.tgz#5bb4293eb8699962710b3b67f10fa211730c28c3" + integrity sha512-H6ulk/ZmbDxOayPwI/leJzrmoW1YKX1Z+MVSCHXuYhvqckV4I/c+hPTf6UiqJyn2avWugfj30XroheEb6/Ekqg== + dependencies: + "@types/markdown-it" "*" + +"@types/markdown-it@*": + version "12.2.3" + resolved "https://repo.huaweicloud.com/repository/npm/@types/markdown-it/-/markdown-it-12.2.3.tgz#0d6f6e5e413f8daaa26522904597be3d6cd93b51" + integrity sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ== + dependencies: + "@types/linkify-it" "*" + "@types/mdurl" "*" + +"@types/markdown-it@^10.0.3": + version "10.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/@types/markdown-it/-/markdown-it-10.0.3.tgz#a9800d14b112c17f1de76ec33eff864a4815eec7" + integrity sha512-daHJk22isOUvNssVGF2zDnnSyxHhFYhtjeX4oQaKD6QzL3ZR1QSgiD1g+Q6/WSWYVogNXYDXODtbgW/WiFCtyw== + dependencies: + "@types/highlight.js" "^9.7.0" + "@types/linkify-it" "*" + "@types/mdurl" "*" + highlight.js "^9.7.0" + +"@types/markdown-it@^13.0.1": + version "13.0.1" + resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-13.0.1.tgz#2f45bd54315f5db2d9bd909ec7fd4d994cf75df4" + integrity sha512-SUEb8Frsxs3D5Gg9xek6i6EG6XQ5s+O+ZdQzIPESZVZw3Pv3CPQfjCJBI+RgqZd1IBeu18S0Rn600qpPnEK37w== + dependencies: + "@types/linkify-it" "*" + "@types/mdurl" "*" + +"@types/markdown-it@^13.0.6": + version "13.0.7" + resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-13.0.7.tgz#4a495115f470075bd4434a0438ac477a49c2e152" + integrity sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA== + dependencies: + "@types/linkify-it" "*" + "@types/mdurl" "*" + +"@types/mdurl@*": + version "1.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/@types/mdurl/-/mdurl-1.0.2.tgz#e2ce9d83a613bacf284c7be7d491945e39e1f8e9" + integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA== + +"@types/mime@*": + version "3.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" + integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA== + +"@types/ms@*": + version "0.7.31" + resolved "https://repo.huaweicloud.com/repository/npm/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197" + integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== + +"@types/node@*": + version "18.7.13" + resolved "https://repo.huaweicloud.com/repository/npm/@types/node/-/node-18.7.13.tgz#23e6c5168333480d454243378b69e861ab5c011a" + integrity sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw== + +"@types/qs@*": + version "6.9.7" + resolved "https://repo.huaweicloud.com/repository/npm/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" + integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== + +"@types/range-parser@*": + version "1.2.4" + resolved "https://repo.huaweicloud.com/repository/npm/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" + integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== + +"@types/serve-static@*": + version "1.15.0" + resolved "https://repo.huaweicloud.com/repository/npm/@types/serve-static/-/serve-static-1.15.0.tgz#c7930ff61afb334e121a9da780aac0d9b8f34155" + integrity sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg== + dependencies: + "@types/mime" "*" + "@types/node" "*" + +"@types/source-list-map@*": + version "0.1.2" + resolved "https://repo.huaweicloud.com/repository/npm/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" + integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA== + +"@types/tapable@^1": + version "1.0.8" + resolved "https://repo.huaweicloud.com/repository/npm/@types/tapable/-/tapable-1.0.8.tgz#b94a4391c85666c7b73299fd3ad79d4faa435310" + integrity sha512-ipixuVrh2OdNmauvtT51o3d8z12p6LtFW9in7U79der/kwejjdNchQC5UMn5u/KxNoM7VHHOs/l8KS8uHxhODQ== + +"@types/uglify-js@*": + version "3.17.0" + resolved "https://repo.huaweicloud.com/repository/npm/@types/uglify-js/-/uglify-js-3.17.0.tgz#95271e7abe0bf7094c60284f76ee43232aef43b9" + integrity sha512-3HO6rm0y+/cqvOyA8xcYLweF0TKXlAxmQASjbOi49Co51A1N4nR4bEwBgRoD9kNM+rqFGArjKr654SLp2CoGmQ== + dependencies: + source-map "^0.6.1" + +"@types/web-bluetooth@^0.0.20": + version "0.0.20" + resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597" + integrity sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow== + +"@types/webpack-dev-server@^3.11.6": + version "3.11.6" + resolved "https://repo.huaweicloud.com/repository/npm/@types/webpack-dev-server/-/webpack-dev-server-3.11.6.tgz#d8888cfd2f0630203e13d3ed7833a4d11b8a34dc" + integrity sha512-XCph0RiiqFGetukCTC3KVnY1jwLcZ84illFRMbyFzCcWl90B/76ew0tSqF46oBhnLC4obNDG7dMO0JfTN0MgMQ== + dependencies: + "@types/connect-history-api-fallback" "*" + "@types/express" "*" + "@types/serve-static" "*" + "@types/webpack" "^4" + http-proxy-middleware "^1.0.0" + +"@types/webpack-sources@*": + version "3.2.0" + resolved "https://repo.huaweicloud.com/repository/npm/@types/webpack-sources/-/webpack-sources-3.2.0.tgz#16d759ba096c289034b26553d2df1bf45248d38b" + integrity sha512-Ft7YH3lEVRQ6ls8k4Ff1oB4jN6oy/XmU6tQISKdhfh+1mR+viZFphS6WL0IrtDOzvefmJg5a0s7ZQoRXwqTEFg== + dependencies: + "@types/node" "*" + "@types/source-list-map" "*" + source-map "^0.7.3" + +"@types/webpack@^4": + version "4.41.32" + resolved "https://repo.huaweicloud.com/repository/npm/@types/webpack/-/webpack-4.41.32.tgz#a7bab03b72904070162b2f169415492209e94212" + integrity sha512-cb+0ioil/7oz5//7tZUSwbrSAN/NWHrQylz5cW8G0dWTcF/g+/dSdMlKVZspBYuMAN1+WnwHrkxiRrLcwd0Heg== + dependencies: + "@types/node" "*" + "@types/tapable" "^1" + "@types/uglify-js" "*" + "@types/webpack-sources" "*" + anymatch "^3.0.0" + source-map "^0.6.0" + +"@vitejs/plugin-vue@^4.5.0": + version "4.5.2" + resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-4.5.2.tgz#1212d81bc83680e14448fefe55abd9fe1ed49ed1" + integrity sha512-UGR3DlzLi/SaVBPX0cnSyE37vqxU3O6chn8l0HJNzQzDia6/Au2A4xKv+iIJW8w2daf80G7TYHhi1pAUjdZ0bQ== + +"@vue/compiler-core@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.3.12.tgz#3346c0f55ce0d59e17c21d9eef9154b70c19931b" + integrity sha512-qAtjyG3GBLG0chzp5xGCyRLLe6wFCHmjI82aGzwuGKyznNP+GJJMxjc0wOYWDB2YKfho7niJFdoFpo0CZZQg9w== + dependencies: + "@babel/parser" "^7.23.5" + "@vue/shared" "3.3.12" + estree-walker "^2.0.2" + source-map-js "^1.0.2" + +"@vue/compiler-dom@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.3.12.tgz#267c54b388d58f30fc120ea496ebf27d4ea8368b" + integrity sha512-RdJU9oEYaoPKUdGXCy0l+i4clesdDeLmbvRlszoc9iagsnBnMmQtYfCPVQ5BHB6o7K4SCucDdJM2Dh3oXB0D6g== + dependencies: + "@vue/compiler-core" "3.3.12" + "@vue/shared" "3.3.12" + +"@vue/compiler-sfc@2.7.10": + version "2.7.10" + resolved "https://repo.huaweicloud.com/repository/npm/@vue/compiler-sfc/-/compiler-sfc-2.7.10.tgz#3fe08e780053a3bbf41328c65ae5dfdee0385206" + integrity sha512-55Shns6WPxlYsz4WX7q9ZJBL77sKE1ZAYNYStLs6GbhIOMrNtjMvzcob6gu3cGlfpCR4bT7NXgyJ3tly2+Hx8Q== + dependencies: + "@babel/parser" "^7.18.4" + postcss "^8.4.14" + source-map "^0.6.1" + +"@vue/compiler-sfc@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.3.12.tgz#6ec2c19858f264671457699c1f3a0a6fedf429fe" + integrity sha512-yy5b9e7b79dsGbMmglCe/YnhCQgBkHO7Uf6JfjWPSf2/5XH+MKn18LhzhHyxbHdJgnA4lZCqtXzLaJz8Pd8lMw== + dependencies: + "@babel/parser" "^7.23.5" + "@vue/compiler-core" "3.3.12" + "@vue/compiler-dom" "3.3.12" + "@vue/compiler-ssr" "3.3.12" + "@vue/reactivity-transform" "3.3.12" + "@vue/shared" "3.3.12" + estree-walker "^2.0.2" + magic-string "^0.30.5" + postcss "^8.4.32" + source-map-js "^1.0.2" + +"@vue/compiler-ssr@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.3.12.tgz#e62499c6003ccd09acb7190167d08845e3a0eaa5" + integrity sha512-adCiMJPznfWcQyk/9HSuXGja859IaMV+b8UNSVzDatqv7h0PvT9BEeS22+gjkWofDiSg5d78/ZLls3sLA+cn3A== + dependencies: + "@vue/compiler-dom" "3.3.12" + "@vue/shared" "3.3.12" + +"@vue/devtools-api@^6.5.0": + version "6.5.0" + resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07" + integrity sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q== + +"@vue/devtools-api@^6.5.1": + version "6.5.1" + resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.5.1.tgz#7f71f31e40973eeee65b9a64382b13593fdbd697" + integrity sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA== + +"@vue/reactivity-transform@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/reactivity-transform/-/reactivity-transform-3.3.12.tgz#4cb871b597eb8b321577b4d7f1e93eaebca16128" + integrity sha512-g5TijmML7FyKkLt6QnpqNmA4KD7K/T5SbXa88Bhq+hydNQEkzA8veVXWAQuNqg9rjaFYD0rPf0a9NofKA0ENgg== + dependencies: + "@babel/parser" "^7.23.5" + "@vue/compiler-core" "3.3.12" + "@vue/shared" "3.3.12" + estree-walker "^2.0.2" + magic-string "^0.30.5" + +"@vue/reactivity@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.3.12.tgz#b4a62a7678ab20c1ef32f991342ddbb8532417da" + integrity sha512-vOJORzO8DlIx88cgTnMLIf2GlLYpoXAKsuoQsK6SGdaqODjxO129pVPTd2s/N/Mb6KKZEFIHIEwWGmtN4YPs+g== + dependencies: + "@vue/shared" "3.3.12" + +"@vue/runtime-core@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.3.12.tgz#67ee6cfc2e85d656946975239ea635ec42dde5f6" + integrity sha512-5iL4w7MZrSGKEZU2wFAYhDZdZmgn+s//73EfgDXW1M+ZUOl36md7tlWp1QFK/ladiq4FvQ82shVjo0KiPDPr0A== + dependencies: + "@vue/reactivity" "3.3.12" + "@vue/shared" "3.3.12" + +"@vue/runtime-dom@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.3.12.tgz#28a239496e589037774cba7c1b27057242eedb11" + integrity sha512-8mMzqiIdl+IYa/OXwKwk6/4ebLq7cYV1pUcwCSwBK2KerUa6cwGosen5xrCL9f8o2DJ9TfPFwbPEvH7OXzUpoA== + dependencies: + "@vue/runtime-core" "3.3.12" + "@vue/shared" "3.3.12" + csstype "^3.1.3" + +"@vue/server-renderer@3.3.12": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.3.12.tgz#f0246aba5d5d6fdfa840ac9e4f32d76f03b20665" + integrity sha512-OZ0IEK5TU5GXb5J8/wSplyxvGGdIcwEmS8EIO302Vz8K6fGSgSJTU54X0Sb6PaefzZdiN3vHsLXO8XIeF8crQQ== + dependencies: + "@vue/compiler-ssr" "3.3.12" + "@vue/shared" "3.3.12" + +"@vue/shared@3.3.12", "@vue/shared@^3.3.8": + version "3.3.12" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.3.12.tgz#7c030c4e2f1db8beb638b159cbb86d0ff78c3198" + integrity sha512-6p0Yin0pclvnER7BLNOQuod9Z+cxSYh8pSh7CzHnWNjAIP6zrTlCdHRvSCb1aYEx6i3Q3kvfuWU7nG16CgG1ag== + +"@vuepress/bundler-vite@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/bundler-vite/-/bundler-vite-2.0.0-rc.0.tgz#22551deb85c5fefe434c02685ef3c037e06d513f" + integrity sha512-rX8S8IYpqqlJfNPstS/joorpxXx/4WuE7+gDM31i2HUrxOKGZVzq8ZsRRRU2UdoTwHZSd3LpUS4sMtxE5xLK1A== + dependencies: + "@vitejs/plugin-vue" "^4.5.0" + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + autoprefixer "^10.4.16" + connect-history-api-fallback "^2.0.0" + postcss "^8.4.31" + postcss-load-config "^4.0.1" + rollup "^4.4.1" + vite "~5.0.0" + vue "^3.3.8" + vue-router "^4.2.5" + +"@vuepress/cli@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/cli/-/cli-2.0.0-rc.0.tgz#387b423121560247192dcdf27a391fa425adbbaf" + integrity sha512-XWSIFO9iOR7N4O2lXIwS5vZuLjU9WU/aGAtmhMWEMxrdMx7TQaJbgrfpTUEbHMf+cPI1DXBbUbtmkqIvtfOV0w== + dependencies: + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + cac "^6.7.14" + chokidar "^3.5.3" + envinfo "^7.11.0" + esbuild "~0.19.5" + +"@vuepress/client@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/client/-/client-2.0.0-rc.0.tgz#851677f81d90ad4fb5d5fd4c5693c499b3dd0ad2" + integrity sha512-TwQx8hJgYONYxX+QltZ2aw9O5Ym6SKelfiUduuIRb555B1gece/jSVap3H/ZwyBhpgJMtG4+/Mrmf8nlDSHjvw== + dependencies: + "@vue/devtools-api" "^6.5.1" + "@vuepress/shared" "2.0.0-rc.0" + "@vueuse/core" "^10.6.1" + vue "^3.3.8" + vue-router "^4.2.5" + +"@vuepress/core@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/core/-/core-2.0.0-rc.0.tgz#b4a8f68a58e755ecc23d330c7d7769270ce792e4" + integrity sha512-uoOaZP1MdxZYJIAJcRcmYKKeCIVnxZeOuLMOOB9CPuAKSalT1RvJ1lztw6RX3q9SPnlqtSZPQXDncPAZivw4pA== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/markdown" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + vue "^3.3.8" + +"@vuepress/markdown@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/markdown/-/markdown-2.0.0-rc.0.tgz#513de09b470306e3a647ce2901995d0e63efbc0e" + integrity sha512-USmqdKKMT6ZFHYRztTjKUlO8qgGfnEygMAAq4AzC/uYXiEfrbMBLAWJhteyGS56P3rGLj0OPAhksE681bX/wOg== + dependencies: + "@mdit-vue/plugin-component" "^1.0.0" + "@mdit-vue/plugin-frontmatter" "^1.0.0" + "@mdit-vue/plugin-headers" "^1.0.0" + "@mdit-vue/plugin-sfc" "^1.0.0" + "@mdit-vue/plugin-title" "^1.0.0" + "@mdit-vue/plugin-toc" "^1.0.0" + "@mdit-vue/shared" "^1.0.0" + "@mdit-vue/types" "^1.0.0" + "@types/markdown-it" "^13.0.6" + "@types/markdown-it-emoji" "^2.0.4" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + markdown-it "^13.0.2" + markdown-it-anchor "^8.6.7" + markdown-it-emoji "^2.0.2" + mdurl "^1.0.1" + +"@vuepress/plugin-active-header-links@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-active-header-links/-/plugin-active-header-links-2.0.0-rc.0.tgz#bd542ba9964de36c8650b29f7fd238d28cedfb64" + integrity sha512-UJdXLYNGL5Wjy5YGY8M2QgqT75bZ95EHebbqGi8twBdIJE9O+bM+dPJyYtAk2PIVqFORiw3Hj+PchsNSxdn9+g== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + ts-debounce "^4.0.0" + vue "^3.3.8" + vue-router "^4.2.5" + +"@vuepress/plugin-back-to-top@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-back-to-top/-/plugin-back-to-top-2.0.0-rc.0.tgz#686b00890ed5feae28800cdb417edce9a9070181" + integrity sha512-6GPfuzV5lkAnR00BxRUhqMXwMWt741alkq2R6bln4N8BneSOwEpX/7vi19MGf232aKdS/Va4pF5p0/nJ8Sed/g== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + ts-debounce "^4.0.0" + vue "^3.3.8" + +"@vuepress/plugin-container@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-container/-/plugin-container-2.0.0-rc.0.tgz#27153a5c3b0cd8818337aa85a1a5c98bde49f63e" + integrity sha512-b7vrLN11YE7qiUDPfA3N9P7Z8fupe9Wbcr9KAE/bmfZ9VT4d6kzpVyoU7XHi99XngitsmnkaXP4aBvBF1c2AnA== + dependencies: + "@types/markdown-it" "^13.0.6" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/markdown" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + markdown-it "^13.0.2" + markdown-it-container "^3.0.0" + +"@vuepress/plugin-external-link-icon@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-external-link-icon/-/plugin-external-link-icon-2.0.0-rc.0.tgz#d1bb78cedb99370ea4dad7522f7b234e50243eb8" + integrity sha512-o8bk0oIlj/BkKc02mq91XLDloq1VOz/8iNcRwKAeqBE6svXzdYiyoTGet0J/4iPuAetsCn75S57W6RioDJHMnQ== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/markdown" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + vue "^3.3.8" + +"@vuepress/plugin-git@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-git/-/plugin-git-2.0.0-rc.0.tgz#fb62cfbaf13d5f06310ae50026cd43f10a32f5b1" + integrity sha512-r7UF77vZxaYeJQLygzodKv+15z3/dTLuGp4VcYO21W6BlJZvd4u9zqgiV7A//bZQvK4+3Hprylr0G3KgXqMewA== + dependencies: + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + execa "^8.0.1" + +"@vuepress/plugin-medium-zoom@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-medium-zoom/-/plugin-medium-zoom-2.0.0-rc.0.tgz#9e9006986aaf4d343a6fdfe8941b3182f8931b85" + integrity sha512-peU1lYKsmKikIe/0pkJuHzD/k6xW2TuqdvKVhV4I//aOE1WxsREKJ4ACcldmoIsnysoDydAUqKT6xDPGyDsH2g== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + medium-zoom "^1.1.0" + vue "^3.3.8" + +"@vuepress/plugin-nprogress@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-nprogress/-/plugin-nprogress-2.0.0-rc.0.tgz#ba5b932db095c9a58a6b1b64c73f21332bd173b6" + integrity sha512-rI+eK0Pg1KiZE+7hGmDUeSbgdWCid8Vnw0hFKNmjinDzGVmx4m03M6qfvclsI0SryH+lR7itZGLaR4gbTlrz/w== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + vue "^3.3.8" + vue-router "^4.2.5" + +"@vuepress/plugin-palette@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-palette/-/plugin-palette-2.0.0-rc.0.tgz#57445772fda0556ca236fcde9c1e325b0ab17772" + integrity sha512-wW70SCp3/K7s1lln5YQsBGTog2WXaQv5piva5zhXcQ47YGf4aAJpThDa5C/ot4HhkPOKn8Iz5s0ckxXZzW8DIg== + dependencies: + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + chokidar "^3.5.3" + +"@vuepress/plugin-prismjs@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-prismjs/-/plugin-prismjs-2.0.0-rc.0.tgz#c2eb8b9aaf2dd955965ab6684dd2fb638619c114" + integrity sha512-c5WRI7+FhVjdbymOKQ8F2KY/Bnv7aQtWScVk8vCMUimNi7v7Wff/A/i3KSFNz/tge3LxiAeH/Dc2WS/OnQXwCg== + dependencies: + "@vuepress/core" "2.0.0-rc.0" + prismjs "^1.29.0" + +"@vuepress/plugin-search@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-search/-/plugin-search-2.0.0-rc.0.tgz#7ebedf697290779f51e421633fd0faf89736f298" + integrity sha512-1ikJUgIN+7QrcAftxpWUKTrNVHEN2+k/az0Sjz7Ok7EthMHcG6qQsIb+AoK4WIQMsJkwVPLxwym/M1FbBTZDWQ== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + chokidar "^3.5.3" + vue "^3.3.8" + vue-router "^4.2.5" + +"@vuepress/plugin-shiki@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-shiki/-/plugin-shiki-2.0.0-rc.0.tgz#523f2673730948e262c5744d29c2d2458274ae56" + integrity sha512-K06icizhp0zVUtWa6rqL/SKWzzSP+XgYizRoqwdMsGlYNThLXAf4cIseRjF+I4VOFS5aj5hZs8MnxymKmRrwIQ== + dependencies: + "@vuepress/core" "2.0.0-rc.0" + shiki "^0.14.5" + +"@vuepress/plugin-theme-data@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-theme-data/-/plugin-theme-data-2.0.0-rc.0.tgz#ec5f7416fd79cb523277ff41e96408246ee5c004" + integrity sha512-FXY3/Ml+rM6gNKvwdBF6vKAcwnSvtXCzKgQwJAw3ppQTKUkLcbOxqM+h4d8bzHWAAvdnEvQFug5uEZgWllBQbA== + dependencies: + "@vue/devtools-api" "^6.5.1" + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + vue "^3.3.8" + +"@vuepress/shared@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/shared/-/shared-2.0.0-rc.0.tgz#0d6ef42940dd030d575c877160fb0583791a9d6c" + integrity sha512-ikdSfjRv5LGM1iv4HHwF9P6gqTjaFCXKPK+hzlkHFHNZO1GLqk7/BPc4F51tAG1s8TcLhUZc+54LrfgS7PkXXA== + dependencies: + "@mdit-vue/types" "^1.0.0" + "@vue/shared" "^3.3.8" + +"@vuepress/theme-default@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/theme-default/-/theme-default-2.0.0-rc.0.tgz#27c1bf7e9d7166e67e5a602616784e4f7e2ad1f5" + integrity sha512-I8Y08evDmMuD1jh3NftPpFFSlCWOizQDJLjN7EQwcg7jiAP4A7c2REo6nBN2EmP24Mi7UrRM+RnytHR5V+pElA== + dependencies: + "@vuepress/client" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/plugin-active-header-links" "2.0.0-rc.0" + "@vuepress/plugin-back-to-top" "2.0.0-rc.0" + "@vuepress/plugin-container" "2.0.0-rc.0" + "@vuepress/plugin-external-link-icon" "2.0.0-rc.0" + "@vuepress/plugin-git" "2.0.0-rc.0" + "@vuepress/plugin-medium-zoom" "2.0.0-rc.0" + "@vuepress/plugin-nprogress" "2.0.0-rc.0" + "@vuepress/plugin-palette" "2.0.0-rc.0" + "@vuepress/plugin-prismjs" "2.0.0-rc.0" + "@vuepress/plugin-theme-data" "2.0.0-rc.0" + "@vuepress/shared" "2.0.0-rc.0" + "@vuepress/utils" "2.0.0-rc.0" + "@vueuse/core" "^10.6.1" + sass "^1.69.5" + vue "^3.3.8" + vue-router "^4.2.5" + +"@vuepress/utils@2.0.0-rc.0": + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/@vuepress/utils/-/utils-2.0.0-rc.0.tgz#34331cea9d4f843cc0c5641aaa395ab49ee66041" + integrity sha512-Q1ay/woClDHcW0Qe91KsnHoupdNN0tp/vhjvVLuAYxlv/1Obii7hz9WFcajyyGEhmsYxdvG2sGmcxFA02tuKkw== + dependencies: + "@types/debug" "^4.1.12" + "@types/fs-extra" "^11.0.4" + "@types/hash-sum" "^1.0.2" + "@vuepress/shared" "2.0.0-rc.0" + debug "^4.3.4" + fs-extra "^11.1.1" + globby "^14.0.0" + hash-sum "^2.0.0" + ora "^7.0.1" + picocolors "^1.0.0" + upath "^2.0.1" + +"@vueuse/core@^10.6.1": + version "10.7.0" + resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-10.7.0.tgz#34f2f02f179dc0dcffc2be70d6b1233e011404b9" + integrity sha512-4EUDESCHtwu44ZWK3Gc/hZUVhVo/ysvdtwocB5vcauSV4B7NiGY5972WnsojB3vRNdxvAt7kzJWE2h9h7C9d5w== + dependencies: + "@types/web-bluetooth" "^0.0.20" + "@vueuse/metadata" "10.7.0" + "@vueuse/shared" "10.7.0" + vue-demi ">=0.14.6" + +"@vueuse/metadata@10.7.0": + version "10.7.0" + resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-10.7.0.tgz#7b05e6cfd376aa9bb339a81e16a89c12f3e88c03" + integrity sha512-GlaH7tKP2iBCZ3bHNZ6b0cl9g0CJK8lttkBNUX156gWvNYhTKEtbweWLm9rxCPIiwzYcr/5xML6T8ZUEt+DkvA== + +"@vueuse/shared@10.7.0": + version "10.7.0" + resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-10.7.0.tgz#21e425cc5ede421e0cda38ac59a0beee6da86b1b" + integrity sha512-kc00uV6CiaTdc3i1CDC4a3lBxzaBE9AgYNtFN87B5OOscqeWElj/uza8qVDmk7/U8JbqoONLbtqiLJ5LGRuqlw== + dependencies: + vue-demi ">=0.14.6" + +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + +ansi-sequence-parser@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz#e0aa1cdcbc8f8bb0b5bca625aac41f5f056973cf" + integrity sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg== + +anymatch@^3.0.0, anymatch@~3.1.2: + version "3.1.2" + resolved "https://repo.huaweicloud.com/repository/npm/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" + integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://repo.huaweicloud.com/repository/npm/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +autoprefixer@^10.4.16: + version "10.4.16" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.16.tgz#fad1411024d8670880bdece3970aa72e3572feb8" + integrity sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ== + dependencies: + browserslist "^4.21.10" + caniuse-lite "^1.0.30001538" + fraction.js "^4.3.6" + normalize-range "^0.1.2" + picocolors "^1.0.0" + postcss-value-parser "^4.2.0" + +balloon-css@^1.2.0: + version "1.2.0" + resolved "https://repo.huaweicloud.com/repository/npm/balloon-css/-/balloon-css-1.2.0.tgz#53d3fb4051264a278a58713bed6865845dbcaf4b" + integrity sha512-urXwkHgwp6GsXVF+it01485Z2Cj4pnW02ICnM0TemOlkKmCNnDLmyy+ZZiRXBpwldUXO+aRNr7Hdia4CBvXJ5A== + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://repo.huaweicloud.com/repository/npm/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://repo.huaweicloud.com/repository/npm/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +bl@^5.0.0: + version "5.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/bl/-/bl-5.0.0.tgz#6928804a41e9da9034868e1c50ca88f21f57aea2" + integrity sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ== + dependencies: + buffer "^6.0.3" + inherits "^2.0.4" + readable-stream "^3.4.0" + +braces@^3.0.2, braces@~3.0.2: + version "3.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browserslist@^4.21.10: + version "4.21.11" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.11.tgz#35f74a3e51adc4d193dcd76ea13858de7b8fecb8" + integrity sha512-xn1UXOKUz7DjdGlg9RrUr0GGiWzI97UQJnugHtH0OLDfJB7jMgoIkYvRIEO1l9EeEERVqeqLYOcFBW9ldjypbQ== + dependencies: + caniuse-lite "^1.0.30001538" + electron-to-chromium "^1.4.526" + node-releases "^2.0.13" + update-browserslist-db "^1.0.13" + +buffer@^6.0.3: + version "6.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +cac@^6.7.12, cac@^6.7.14: + version "6.7.14" + resolved "https://repo.huaweicloud.com/repository/npm/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" + integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== + +caniuse-lite@^1.0.30001538: + version "1.0.30001538" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz#9dbc6b9af1ff06b5eb12350c2012b3af56744f3f" + integrity sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw== + +chalk@^5.0.0: + version "5.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" + integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== + +chalk@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385" + integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w== + +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.3: + version "3.5.3" + resolved "https://repo.huaweicloud.com/repository/npm/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +cli-cursor@^4.0.0: + version "4.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/cli-cursor/-/cli-cursor-4.0.0.tgz#3cecfe3734bf4fe02a8361cbdc0f6fe28c6a57ea" + integrity sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg== + dependencies: + restore-cursor "^4.0.0" + +cli-spinners@^2.9.0: + version "2.9.1" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.1.tgz#9c0b9dad69a6d47cbb4333c14319b060ed395a35" + integrity sha512-jHgecW0pxkonBJdrKsqxgRX9AcG+u/5k0Q7WPDfi8AogLAdwxEkyYYNWwZ5GvVFoFx2uiY1eNcSK00fh+1+FyQ== + +connect-history-api-fallback@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz#647264845251a0daf25b97ce87834cace0f5f1c8" + integrity sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA== + +cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +csstype@^3.1.0: + version "3.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2" + integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA== + +csstype@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" + integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== + +debug@^4.3.4: + version "4.3.4" + resolved "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +deepmerge@^1.5.2: + version "1.5.2" + resolved "https://repo.huaweicloud.com/repository/npm/deepmerge/-/deepmerge-1.5.2.tgz#10499d868844cdad4fee0842df8c7f6f0c95a753" + integrity sha512-95k0GDqvBjZavkuvzx/YqVLv/6YYa17fz6ILMSf7neqQITCPbnfEnQvEgMPNjH4kgobe7+WIL0yJEHku+H3qtQ== + +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + +electron-to-chromium@^1.4.526: + version "1.4.528" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.528.tgz#7c900fd73d9d2e8bb0dab0e301f25f0f4776ef2c" + integrity sha512-UdREXMXzLkREF4jA8t89FQjA8WHI6ssP38PMY4/4KhXFQbtImnghh4GkCgrtiZwLKUKVD2iTVXvDVQjfomEQuA== + +emoji-regex@^10.2.1: + version "10.2.1" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-10.2.1.tgz#a41c330d957191efd3d9dfe6e1e8e1e9ab048b3f" + integrity sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA== + +entities@~3.0.1: + version "3.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" + integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== + +envinfo@^7.11.0: + version "7.11.0" + resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.11.0.tgz#c3793f44284a55ff8c82faf1ffd91bc6478ea01f" + integrity sha512-G9/6xF1FPbIw0TtalAMaVPpiq2aDEuKLXM314jPVAO9r2fo2a4BLqMNkmRS7O/xPPZ+COAhGIz3ETvHEV3eUcg== + +esbuild@^0.19.3, esbuild@~0.19.5: + version "0.19.9" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.9.tgz#423a8f35153beb22c0b695da1cd1e6c0c8cdd490" + integrity sha512-U9CHtKSy+EpPsEBa+/A2gMs/h3ylBC0H0KSqIg7tpztHerLi6nrrcoUJAkNCEPumx8yJ+Byic4BVwHgRbN0TBg== + optionalDependencies: + "@esbuild/android-arm" "0.19.9" + "@esbuild/android-arm64" "0.19.9" + "@esbuild/android-x64" "0.19.9" + "@esbuild/darwin-arm64" "0.19.9" + "@esbuild/darwin-x64" "0.19.9" + "@esbuild/freebsd-arm64" "0.19.9" + "@esbuild/freebsd-x64" "0.19.9" + "@esbuild/linux-arm" "0.19.9" + "@esbuild/linux-arm64" "0.19.9" + "@esbuild/linux-ia32" "0.19.9" + "@esbuild/linux-loong64" "0.19.9" + "@esbuild/linux-mips64el" "0.19.9" + "@esbuild/linux-ppc64" "0.19.9" + "@esbuild/linux-riscv64" "0.19.9" + "@esbuild/linux-s390x" "0.19.9" + "@esbuild/linux-x64" "0.19.9" + "@esbuild/netbsd-x64" "0.19.9" + "@esbuild/openbsd-x64" "0.19.9" + "@esbuild/sunos-x64" "0.19.9" + "@esbuild/win32-arm64" "0.19.9" + "@esbuild/win32-ia32" "0.19.9" + "@esbuild/win32-x64" "0.19.9" + +escalade@^3.1.1: + version "3.1.1" + resolved "https://repo.huaweicloud.com/repository/npm/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +esprima@^4.0.0: + version "4.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +estree-walker@^2.0.2: + version "2.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" + integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== + +eventemitter3@^4.0.0: + version "4.0.7" + resolved "https://repo.huaweicloud.com/repository/npm/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +execa@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-8.0.1.tgz#51f6a5943b580f963c3ca9c6321796db8cc39b8c" + integrity sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg== + dependencies: + cross-spawn "^7.0.3" + get-stream "^8.0.1" + human-signals "^5.0.0" + is-stream "^3.0.0" + merge-stream "^2.0.0" + npm-run-path "^5.1.0" + onetime "^6.0.0" + signal-exit "^4.1.0" + strip-final-newline "^3.0.0" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug== + dependencies: + is-extendable "^0.1.0" + +fast-glob@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" + integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fastq@^1.6.0: + version "1.13.0" + resolved "https://repo.huaweicloud.com/repository/npm/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" + integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + dependencies: + reusify "^1.0.4" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +follow-redirects@^1.0.0: + version "1.15.1" + resolved "https://repo.huaweicloud.com/repository/npm/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5" + integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== + +fraction.js@^4.3.6: + version "4.3.6" + resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.6.tgz#e9e3acec6c9a28cf7bc36cbe35eea4ceb2c5c92d" + integrity sha512-n2aZ9tNfYDwaHhvFTkhFErqOMIb8uyzSQ+vGJBjZyanAKZVbGUQ1sngfk9FdkBw7G26O7AgNjLcecLffD1c7eg== + +fs-extra@^11.1.1: + version "11.1.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d" + integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + +fsevents@~2.3.2: + version "2.3.2" + resolved "https://repo.huaweicloud.com/repository/npm/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +fsevents@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +get-stream@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-8.0.1.tgz#def9dfd71742cd7754a7761ed43749a27d02eca2" + integrity sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA== + +glob-parent@^5.1.2, glob-parent@~5.1.2: + version "5.1.2" + resolved "https://repo.huaweicloud.com/repository/npm/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +globby@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-14.0.0.tgz#ea9c062a3614e33f516804e778590fcf055256b9" + integrity sha512-/1WM/LNHRAOH9lZta77uGbq0dAEQM+XjNesWwhlERDVenqothRbnzTrL3/LrIoEPPjeUHC3vrS6TwoyxeHs7MQ== + dependencies: + "@sindresorhus/merge-streams" "^1.0.0" + fast-glob "^3.3.2" + ignore "^5.2.4" + path-type "^5.0.0" + slash "^5.1.0" + unicorn-magic "^0.1.0" + +graceful-fs@^4.1.6, graceful-fs@^4.2.0: + version "4.2.10" + resolved "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== + +gray-matter@^4.0.3: + version "4.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/gray-matter/-/gray-matter-4.0.3.tgz#e893c064825de73ea1f5f7d88c7a9f7274288798" + integrity sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q== + dependencies: + js-yaml "^3.13.1" + kind-of "^6.0.2" + section-matter "^1.0.0" + strip-bom-string "^1.0.0" + +hash-sum@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/hash-sum/-/hash-sum-2.0.0.tgz#81d01bb5de8ea4a214ad5d6ead1b523460b0b45a" + integrity sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg== + +highlight.js@^9.7.0: + version "9.18.5" + resolved "https://repo.huaweicloud.com/repository/npm/highlight.js/-/highlight.js-9.18.5.tgz#d18a359867f378c138d6819edfc2a8acd5f29825" + integrity sha512-a5bFyofd/BHCX52/8i8uJkjr9DYwXIPnM/plwI6W7ezItLGqzt7X2G2nXuYSfsIJdkwwj/g9DG1LkcGJI/dDoA== + +http-proxy-middleware@^1.0.0: + version "1.3.1" + resolved "https://repo.huaweicloud.com/repository/npm/http-proxy-middleware/-/http-proxy-middleware-1.3.1.tgz#43700d6d9eecb7419bf086a128d0f7205d9eb665" + integrity sha512-13eVVDYS4z79w7f1+NPllJtOQFx/FdUW4btIvVRMaRlUY9VGstAbo5MOhLEuUgZFRHn3x50ufn25zkj/boZnEg== + dependencies: + "@types/http-proxy" "^1.17.5" + http-proxy "^1.18.1" + is-glob "^4.0.1" + is-plain-obj "^3.0.0" + micromatch "^4.0.2" + +http-proxy@^1.18.1: + version "1.18.1" + resolved "https://repo.huaweicloud.com/repository/npm/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" + integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== + dependencies: + eventemitter3 "^4.0.0" + follow-redirects "^1.0.0" + requires-port "^1.0.0" + +human-signals@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28" + integrity sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ== + +ieee754@^1.2.1: + version "1.2.1" + resolved "https://repo.huaweicloud.com/repository/npm/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +ignore@^5.2.4: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== + +immutable@^4.0.0: + version "4.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/immutable/-/immutable-4.1.0.tgz#f795787f0db780183307b9eb2091fcac1f6fafef" + integrity sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ== + +inherits@^2.0.3, inherits@^2.0.4: + version "2.0.4" + resolved "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extendable@^0.1.0: + version "0.1.1" + resolved "https://repo.huaweicloud.com/repository/npm/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-interactive@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/is-interactive/-/is-interactive-2.0.0.tgz#40c57614593826da1100ade6059778d597f16e90" + integrity sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ== + +is-number@^7.0.0: + version "7.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + +is-stream@^3.0.0: + version "3.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-3.0.0.tgz#e6bfd7aa6bef69f4f472ce9bb681e3e57b4319ac" + integrity sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA== + +is-unicode-supported@^1.1.0: + version "1.2.0" + resolved "https://repo.huaweicloud.com/repository/npm/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz#f4f54f34d8ebc84a46b93559a036763b6d3e1014" + integrity sha512-wH+U77omcRzevfIG8dDhTS0V9zZyweakfD01FULl97+0EHiJTTZtJqxPSkIIo/SDPv/i07k/C9jAPY+jwLLeUQ== + +is-unicode-supported@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz#d824984b616c292a2e198207d4a609983842f714" + integrity sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +javascript-stringify@^2.0.1: + version "2.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/javascript-stringify/-/javascript-stringify-2.1.0.tgz#27c76539be14d8bd128219a2d731b09337904e79" + integrity sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg== + +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://repo.huaweicloud.com/repository/npm/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsonc-parser@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76" + integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w== + +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +lilconfig@^2.0.5: + version "2.1.0" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" + integrity sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ== + +linkify-it@^4.0.1: + version "4.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/linkify-it/-/linkify-it-4.0.1.tgz#01f1d5e508190d06669982ba31a7d9f56a5751ec" + integrity sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw== + dependencies: + uc.micro "^1.0.1" + +log-symbols@^5.1.0: + version "5.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/log-symbols/-/log-symbols-5.1.0.tgz#a20e3b9a5f53fac6aeb8e2bb22c07cf2c8f16d93" + integrity sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA== + dependencies: + chalk "^5.0.0" + is-unicode-supported "^1.1.0" + +magic-string@^0.30.5: + version "0.30.5" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.5.tgz#1994d980bd1c8835dc6e78db7cbd4ae4f24746f9" + integrity sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA== + dependencies: + "@jridgewell/sourcemap-codec" "^1.4.15" + +markdown-it-anchor@*: + version "8.6.4" + resolved "https://repo.huaweicloud.com/repository/npm/markdown-it-anchor/-/markdown-it-anchor-8.6.4.tgz#affb8aa0910a504c114e9fcad53ac3a5b907b0e6" + integrity sha512-Ul4YVYZNxMJYALpKtu+ZRdrryYt/GlQ5CK+4l1bp/gWXOG2QWElt6AqF3Mih/wfUKdZbNAZVXGR73/n6U/8img== + +markdown-it-anchor@^8.6.7: + version "8.6.7" + resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz#ee6926daf3ad1ed5e4e3968b1740eef1c6399634" + integrity sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA== + +markdown-it-container@^3.0.0: + version "3.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/markdown-it-container/-/markdown-it-container-3.0.0.tgz#1d19b06040a020f9a827577bb7dbf67aa5de9a5b" + integrity sha512-y6oKTq4BB9OQuY/KLfk/O3ysFhB3IMYoIWhGJEidXt1NQFocFK2sA2t0NYZAMyMShAGL6x5OPIbrmXPIqaN9rw== + +markdown-it-emoji@^2.0.2: + version "2.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/markdown-it-emoji/-/markdown-it-emoji-2.0.2.tgz#cd42421c2fda1537d9cc12b9923f5c8aeb9029c8" + integrity sha512-zLftSaNrKuYl0kR5zm4gxXjHaOI3FAOEaloKmRA5hijmJZvSjmxcokOLlzycb/HXlUFWzXqpIEoyEMCE4i9MvQ== + +markdown-it@^13.0.1: + version "13.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/markdown-it/-/markdown-it-13.0.1.tgz#c6ecc431cacf1a5da531423fc6a42807814af430" + integrity sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q== + dependencies: + argparse "^2.0.1" + entities "~3.0.1" + linkify-it "^4.0.1" + mdurl "^1.0.1" + uc.micro "^1.0.5" + +markdown-it@^13.0.2: + version "13.0.2" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-13.0.2.tgz#1bc22e23379a6952e5d56217fbed881e0c94d536" + integrity sha512-FtwnEuuK+2yVU7goGn/MJ0WBZMM9ZPgU9spqlFs7/A/pDIUNSOQZhUgOqYCficIuR2QaFnrt8LHqBWsbTAoI5w== + dependencies: + argparse "^2.0.1" + entities "~3.0.1" + linkify-it "^4.0.1" + mdurl "^1.0.1" + uc.micro "^1.0.5" + +mdurl@^1.0.1: + version "1.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" + integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== + +medium-zoom@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/medium-zoom/-/medium-zoom-1.1.0.tgz#6efb6bbda861a02064ee71a2617a8dc4381ecc71" + integrity sha512-ewyDsp7k4InCUp3jRmwHBRFGyjBimKps/AJLjRSox+2q/2H4p/PNpQf+pwONWlJiOudkBXtbdmVbFjqyybfTmQ== + +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + +merge2@^1.3.0: + version "1.4.1" + resolved "https://repo.huaweicloud.com/repository/npm/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.2, micromatch@^4.0.4: + version "4.0.5" + resolved "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +mimic-fn@^4.0.0: + version "4.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" + integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== + +ms@2.1.2: + version "2.1.2" + resolved "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +nanoid@^3.3.4: + version "3.3.4" + resolved "https://repo.huaweicloud.com/repository/npm/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + +nanoid@^3.3.7: + version "3.3.7" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" + integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== + +node-releases@^2.0.13: + version "2.0.13" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.13.tgz#d5ed1627c23e3461e819b02e57b75e4899b1c81d" + integrity sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +normalize-range@^0.1.2: + version "0.1.2" + resolved "https://repo.huaweicloud.com/repository/npm/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" + integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA== + +npm-run-path@^5.1.0: + version "5.1.0" + resolved "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-5.1.0.tgz#bc62f7f3f6952d9894bd08944ba011a6ee7b7e00" + integrity sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q== + dependencies: + path-key "^4.0.0" + +onetime@^5.1.0: + version "5.1.2" + resolved "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +onetime@^6.0.0: + version "6.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-6.0.0.tgz#7c24c18ed1fd2e9bca4bd26806a33613c77d34b4" + integrity sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ== + dependencies: + mimic-fn "^4.0.0" + +ora@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/ora/-/ora-7.0.1.tgz#cdd530ecd865fe39e451a0e7697865669cb11930" + integrity sha512-0TUxTiFJWv+JnjWm4o9yvuskpEJLXTcng8MJuKd+SzAzp2o+OP3HWqNhB4OdJRt1Vsd9/mR0oyaEYlOnL7XIRw== + dependencies: + chalk "^5.3.0" + cli-cursor "^4.0.0" + cli-spinners "^2.9.0" + is-interactive "^2.0.0" + is-unicode-supported "^1.3.0" + log-symbols "^5.1.0" + stdin-discarder "^0.1.0" + string-width "^6.1.0" + strip-ansi "^7.1.0" + +path-key@^3.1.0: + version "3.1.1" + resolved "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-key@^4.0.0: + version "4.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-4.0.0.tgz#295588dc3aee64154f877adb9d780b81c554bf18" + integrity sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ== + +path-type@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-5.0.0.tgz#14b01ed7aea7ddf9c7c3f46181d4d04f9c785bb8" + integrity sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg== + +picocolors@^1.0.0: + version "1.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: + version "2.3.1" + resolved "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +postcss-load-config@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-4.0.1.tgz#152383f481c2758274404e4962743191d73875bd" + integrity sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA== + dependencies: + lilconfig "^2.0.5" + yaml "^2.1.1" + +postcss-value-parser@^4.2.0: + version "4.2.0" + resolved "https://repo.huaweicloud.com/repository/npm/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" + integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== + +postcss@^8.4.14: + version "8.4.16" + resolved "https://repo.huaweicloud.com/repository/npm/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c" + integrity sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ== + dependencies: + nanoid "^3.3.4" + picocolors "^1.0.0" + source-map-js "^1.0.2" + +postcss@^8.4.31, postcss@^8.4.32: + version "8.4.32" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.32.tgz#1dac6ac51ab19adb21b8b34fd2d93a86440ef6c9" + integrity sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw== + dependencies: + nanoid "^3.3.7" + picocolors "^1.0.0" + source-map-js "^1.0.2" + +prismjs@^1.29.0: + version "1.29.0" + resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12" + integrity sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q== + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://repo.huaweicloud.com/repository/npm/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +readable-stream@^3.4.0: + version "3.6.0" + resolved "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://repo.huaweicloud.com/repository/npm/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== + +restore-cursor@^4.0.0: + version "4.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/restore-cursor/-/restore-cursor-4.0.0.tgz#519560a4318975096def6e609d44100edaa4ccb9" + integrity sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + +reusify@^1.0.4: + version "1.0.4" + resolved "https://repo.huaweicloud.com/repository/npm/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +rollup@^4.2.0, rollup@^4.4.1: + version "4.9.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.9.1.tgz#351d6c03e4e6bcd7a0339df3618d2aeeb108b507" + integrity sha512-pgPO9DWzLoW/vIhlSoDByCzcpX92bKEorbgXuZrqxByte3JFk2xSW2JEeAcyLc9Ru9pqcNNW+Ob7ntsk2oT/Xw== + optionalDependencies: + "@rollup/rollup-android-arm-eabi" "4.9.1" + "@rollup/rollup-android-arm64" "4.9.1" + "@rollup/rollup-darwin-arm64" "4.9.1" + "@rollup/rollup-darwin-x64" "4.9.1" + "@rollup/rollup-linux-arm-gnueabihf" "4.9.1" + "@rollup/rollup-linux-arm64-gnu" "4.9.1" + "@rollup/rollup-linux-arm64-musl" "4.9.1" + "@rollup/rollup-linux-riscv64-gnu" "4.9.1" + "@rollup/rollup-linux-x64-gnu" "4.9.1" + "@rollup/rollup-linux-x64-musl" "4.9.1" + "@rollup/rollup-win32-arm64-msvc" "4.9.1" + "@rollup/rollup-win32-ia32-msvc" "4.9.1" + "@rollup/rollup-win32-x64-msvc" "4.9.1" + fsevents "~2.3.2" + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://repo.huaweicloud.com/repository/npm/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://repo.huaweicloud.com/repository/npm/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +sass@^1.69.5: + version "1.69.5" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.69.5.tgz#23e18d1c757a35f2e52cc81871060b9ad653dfde" + integrity sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ== + dependencies: + chokidar ">=3.0.0 <4.0.0" + immutable "^4.0.0" + source-map-js ">=0.6.2 <2.0.0" + +section-matter@^1.0.0: + version "1.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/section-matter/-/section-matter-1.0.0.tgz#e9041953506780ec01d59f292a19c7b850b84167" + integrity sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA== + dependencies: + extend-shallow "^2.0.1" + kind-of "^6.0.0" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +shiki@^0.14.5: + version "0.14.7" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.7.tgz#c3c9e1853e9737845f1d2ef81b31bcfb07056d4e" + integrity sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg== + dependencies: + ansi-sequence-parser "^1.1.0" + jsonc-parser "^3.2.0" + vscode-oniguruma "^1.7.0" + vscode-textmate "^8.0.0" + +signal-exit@^3.0.2: + version "3.0.7" + resolved "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +signal-exit@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + +slash@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-5.1.0.tgz#be3adddcdf09ac38eebe8dcdc7b1a57a75b095ce" + integrity sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg== + +"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2: + version "1.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" + integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== + +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://repo.huaweicloud.com/repository/npm/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +source-map@^0.7.3: + version "0.7.4" + resolved "https://repo.huaweicloud.com/repository/npm/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656" + integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://repo.huaweicloud.com/repository/npm/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +stdin-discarder@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/stdin-discarder/-/stdin-discarder-0.1.0.tgz#22b3e400393a8e28ebf53f9958f3880622efde21" + integrity sha512-xhV7w8S+bUwlPTb4bAOUQhv8/cSS5offJuX8GQGq32ONF0ZtDWKfkdomM3HMRA+LhX6um/FZ0COqlwsjD53LeQ== + dependencies: + bl "^5.0.0" + +string-width@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-6.1.0.tgz#96488d6ed23f9ad5d82d13522af9e4c4c3fd7518" + integrity sha512-k01swCJAgQmuADB0YIc+7TuatfNvTBVOoaUWJjTB9R4VJzR5vNWzf5t42ESVZFPS8xTySF7CAdV4t/aaIm3UnQ== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^10.2.1" + strip-ansi "^7.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://repo.huaweicloud.com/repository/npm/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +strip-ansi@^7.0.1: + version "7.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" + integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== + dependencies: + ansi-regex "^6.0.1" + +strip-ansi@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + +strip-bom-string@^1.0.0: + version "1.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/strip-bom-string/-/strip-bom-string-1.0.0.tgz#e5211e9224369fbb81d633a2f00044dc8cedad92" + integrity sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g== + +strip-final-newline@^3.0.0: + version "3.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-3.0.0.tgz#52894c313fbff318835280aed60ff71ebf12b8fd" + integrity sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-debounce@^4.0.0: + version "4.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/ts-debounce/-/ts-debounce-4.0.0.tgz#33440ef64fab53793c3d546a8ca6ae539ec15841" + integrity sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg== + +uc.micro@^1.0.1, uc.micro@^1.0.5: + version "1.0.6" + resolved "https://repo.huaweicloud.com/repository/npm/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== + +unicorn-magic@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4" + integrity sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ== + +universalify@^2.0.0: + version "2.0.0" + resolved "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== + +upath@^2.0.1: + version "2.0.1" + resolved "https://repo.huaweicloud.com/repository/npm/upath/-/upath-2.0.1.tgz#50c73dea68d6f6b990f51d279ce6081665d61a8b" + integrity sha512-1uEe95xksV1O0CYKXo8vQvN1JEbtJp7lb7C5U9HMsIp6IVwntkH/oNUzyVNQSd4S1sYk2FpSSW44FqMc8qee5w== + +update-browserslist-db@^1.0.13: + version "1.0.13" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4" + integrity sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" + +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +vite@~5.0.0: + version "5.0.10" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.0.10.tgz#1e13ef5c3cf5aa4eed81f5df6d107b3c3f1f6356" + integrity sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw== + dependencies: + esbuild "^0.19.3" + postcss "^8.4.32" + rollup "^4.2.0" + optionalDependencies: + fsevents "~2.3.3" + +vscode-oniguruma@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz#439bfad8fe71abd7798338d1cd3dc53a8beea94b" + integrity sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA== + +vscode-textmate@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-8.0.0.tgz#2c7a3b1163ef0441097e0b5d6389cd5504b59e5d" + integrity sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg== + +vue-demi@>=0.14.6: + version "0.14.6" + resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.6.tgz#dc706582851dc1cdc17a0054f4fec2eb6df74c92" + integrity sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w== + +vue-router@^4.2.5: + version "4.2.5" + resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.2.5.tgz#b9e3e08f1bd9ea363fdd173032620bc50cf0e98a" + integrity sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw== + dependencies: + "@vue/devtools-api" "^6.5.0" + +vue@^2.6.14: + version "2.7.10" + resolved "https://repo.huaweicloud.com/repository/npm/vue/-/vue-2.7.10.tgz#ae516cc6c88e1c424754468844218fdd5e280f40" + integrity sha512-HmFC70qarSHPXcKtW8U8fgIkF6JGvjEmDiVInTkKZP0gIlEPhlVlcJJLkdGIDiNkIeA2zJPQTWJUI4iWe+AVfg== + dependencies: + "@vue/compiler-sfc" "2.7.10" + csstype "^3.1.0" + +vue@^3.3.8: + version "3.3.12" + resolved "https://registry.yarnpkg.com/vue/-/vue-3.3.12.tgz#4a3a39e79d22e9826ae7c058863316333c838b63" + integrity sha512-jYNv2QmET2OTHsFzfWHMnqgCfqL4zfo97QwofdET+GBRCHhSCHuMTTvNIgeSn0/xF3JRT5OGah6MDwUFN7MPlg== + dependencies: + "@vue/compiler-dom" "3.3.12" + "@vue/compiler-sfc" "3.3.12" + "@vue/runtime-dom" "3.3.12" + "@vue/server-renderer" "3.3.12" + "@vue/shared" "3.3.12" + +vuepress-vite@2.0.0-rc.0: + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/vuepress-vite/-/vuepress-vite-2.0.0-rc.0.tgz#edcb902881368143c24199e66c2300f4bcd2b61f" + integrity sha512-+2XBejeiskPyr2raBeA2o4uDFDsjtadpUVmtio3qqFtQpOhidz/ORuiTLr2UfLtFn1ASIHP6Vy2YjQ0e/TeUVw== + dependencies: + "@vuepress/bundler-vite" "2.0.0-rc.0" + "@vuepress/cli" "2.0.0-rc.0" + "@vuepress/core" "2.0.0-rc.0" + "@vuepress/theme-default" "2.0.0-rc.0" + vue "^3.3.8" + +vuepress@2.0.0-rc.0: + version "2.0.0-rc.0" + resolved "https://registry.yarnpkg.com/vuepress/-/vuepress-2.0.0-rc.0.tgz#680f15968afd8ba0e27c4af52d15109eb11bb1b4" + integrity sha512-sydt/B7+pIw926G5PntYmptLkC5o2buXKh+WR1+P2KnsvkXU+UGnQrJJ0FBvu/4RNuY99tkUZd59nyPhEmRrCg== + dependencies: + vuepress-vite "2.0.0-rc.0" + +webpack-chain@^6.5.1: + version "6.5.1" + resolved "https://repo.huaweicloud.com/repository/npm/webpack-chain/-/webpack-chain-6.5.1.tgz#4f27284cbbb637e3c8fbdef43eef588d4d861206" + integrity sha512-7doO/SRtLu8q5WM0s7vPKPWX580qhi0/yBHkOxNkv50f6qB76Zy9o2wRTrrPULqYTvQlVHuvbA8v+G5ayuUDsA== + dependencies: + deepmerge "^1.5.2" + javascript-stringify "^2.0.1" + +which@^2.0.1: + version "2.0.2" + resolved "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +yaml@^2.1.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.2.tgz#f522db4313c671a0ca963a75670f1c12ea909144" + integrity sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg== diff --git a/gradle.properties b/gradle.properties index 5a1fbdb..b5a2cdf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,9 +6,46 @@ kotlin.code.style=official kotlin.incremental.useClasspathSnapshot=true # Project Configuration project.name=Hikage +project.url=https://github.com/BetterAndroid/Hikage +project.groupName=com.highcapable.hikage project.android.compileSdk=35 project.android.minSdk=21 project.android.targetSdk=35 -project.app.packageName=com.highcapable.hikage.demo -project.app.versionName=1.0.0 -project.app.versionCode=1 \ No newline at end of file +project.samples-app.packageName=com.highcapable.hikage.demo +project.samples-app.versionName=universal +project.samples-app.versionCode=1 +project.hikage-core.namespace=${project.groupName}.core +project.hikage-core.version="1.0.0" +project.hikage-core-lint.namespace=${project.groupName}.core.lint +project.hikage-core-lint.identifier=${project.groupName}:hikage-core:${project.hikage-core.version} +project.hikage-core-lint.min-api=9 +project.hikage-core-lint.registry-v2-class="${project.hikage-core-lint.namespace}.HikageIssueRegistry" +project.hikage-extension.namespace=${project.groupName}.extension +project.hikage-extension.version="1.0.0" +project.hikage-extension-betterandroid.namespace=${project.groupName}.extension.betterandroid +project.hikage-extension-betterandroid.version="1.0.0" +project.hikage-extension-compose.namespace=${project.groupName}.extension.androidx.compose +project.hikage-extension-compose.version="1.0.0" +project.hikage-compiler.namespace="${project.groupName}.compiler" +project.hikage-compiler.version="1.0.0" +project.hikage-widget-androidx.namespace=${project.groupName}.widget.androidx +project.hikage-widget-androidx.version="1.0.0" +project.hikage-widget-material.namespace=${project.groupName}.widget.google.material +project.hikage-widget-material.version="1.0.0" +# Maven Publish Configuration +SONATYPE_HOST=CENTRAL_PORTAL +RELEASE_SIGNING_ENABLED=true +# Maven POM Configuration +POM_NAME=Hikage +POM_DESCRIPTION=An Android responsive UI building tool. +POM_URL=https://github.com/BetterAndroid/Hikage +POM_LICENSE_NAME=Apache License 2.0 +POM_LICENSE_URL=https://github.com/BetterAndroid/Hikage/blob/main/LICENSE +POM_LICENSE_DIST=repo +POM_SCM_URL=https://github.com/BetterAndroid/Hikage +POM_SCM_CONNECTION=scm:git:git://github.com/BetterAndroid/Hikage.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/BetterAndroid/Hikage.git +POM_DEVELOPER_ID=0 +POM_DEVELOPER_NAME=fankes +POM_DEVELOPER_EMAIL=qzmmcn@163.com +POM_DEVELOPER_URL=https://github.com/fankes \ No newline at end of file diff --git a/gradle/sweet-dependency/sweet-dependency-config.yaml b/gradle/sweet-dependency/sweet-dependency-config.yaml index f7d7026..75b4c8f 100644 --- a/gradle/sweet-dependency/sweet-dependency-config.yaml +++ b/gradle/sweet-dependency/sweet-dependency-config.yaml @@ -7,26 +7,72 @@ repositories: scope: PLUGINS google: maven-central: + highcapable-maven-releases: + url: https://raw.githubusercontent.com/HighCapable/maven-repository/main/repository/releases plugins: - com.android.application: - alias: android-application - version: 8.5.2 - com.android.library: - alias: android-library - version-ref: com.android.application + org.jetbrains.kotlin.jvm: + alias: kotlin-jvm + version: 2.0.10 + auto-update: false org.jetbrains.kotlin.android: alias: kotlin-android - version: 2.0.0 + version-ref: kotlin-jvm + com.google.devtools.ksp: + alias: kotlin-ksp + version: 2.0.10-1.0.24 + auto-update: false + com.android.application: + alias: android-application + version: 8.9.0 + com.android.library: + alias: android-library + version-ref: android-application + org.jetbrains.kotlin.plugin.compose: + alias: compose-compiler + version-ref: kotlin-jvm + org.jetbrains.dokka: + alias: kotlin-dokka + version: 1.9.20 + auto-update: false + com.vanniktech.maven.publish: + alias: maven-publish + version: 0.31.0 libraries: + org.jetbrains.kotlin: + kotlin-stdlib: + version-ref: ::kotlin-jvm + com.google.devtools.ksp: + symbol-processing-api: + version-ref: ::kotlin-ksp + com.google.auto.service: + auto-service-annotations: + version: 1.1.1 + dev.zacsweers.autoservice: + auto-service-ksp: + version: 1.2.0 + com.squareup: + kotlinpoet: + version: 2.1.0 + kotlinpoet-ksp: + version-ref: ::kotlinpoet com.highcapable.betterandroid: ui-component: - version: 1.0.6 + version: 1.0.7 ui-extension: - version: 1.0.5 + version: 1.0.6 system-extension: version: 1.0.2 + org.lsposed.hiddenapibypass: + hiddenapibypass: + version: 6.1 + com.highcapable.yukireflection: + api: + version: 1.0.3 + com.highcapable.pangutext: + pangutext-android: + version: 1.0.2 androidx.core: core: version: 1.15.0 @@ -37,10 +83,39 @@ libraries: version: 1.7.0 com.google.android.material: material: - version: 1.12.0 + auto-update: false + # Workaround for a bug in version 1.12.0 + version: 1.11.0 androidx.constraintlayout: constraintlayout: - version: 2.2.0 + version: 2.2.1 + androidx.coordinatorlayout: + coordinatorlayout: + version: 1.3.0 + androidx.swiperefreshlayout: + swiperefreshlayout: + version: 1.1.0 + androidx.slidingpanelayout: + slidingpanelayout: + version: 1.2.0 + androidx.drawerlayout: + drawerlayout: + version: 1.2.0 + androidx.cardview: + cardview: + version: 1.0.0 + androidx.viewpager: + viewpager: + version: 1.1.0 + androidx.viewpager2: + viewpager2: + version: 1.1.0 + androidx.recyclerview: + recyclerview: + version: 1.4.0 + androidx.compose.ui: + ui: + version: 1.7.8 junit: junit: version: 4.13.2 @@ -49,4 +124,13 @@ libraries: version: 1.2.1 androidx.test.espresso: espresso-core: - version: 3.6.1 \ No newline at end of file + version: 3.6.1 + com.android.tools.lint: + lint: + version: 31.9.0 + lint-api: + version-ref: ::lint + lint-checks: + version-ref: ::lint + lint-tests: + version-ref: ::lint \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e69de29..9bbc975 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a1ee240..37f853b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 4f906e0..faf9300 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,69 +15,103 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/hikage-compiler/build.gradle.kts b/hikage-compiler/build.gradle.kts new file mode 100644 index 0000000..b1da4e6 --- /dev/null +++ b/hikage-compiler/build.gradle.kts @@ -0,0 +1,32 @@ +plugins { + autowire(libs.plugins.kotlin.jvm) + autowire(libs.plugins.kotlin.ksp) + autowire(libs.plugins.maven.publish) +} + +group = property.project.groupName +version = property.project.hikage.compiler.version + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +kotlin { + jvmToolchain(17) + compilerOptions { + freeCompilerArgs = listOf( + "-Xno-param-assertions", + "-Xno-call-assertions", + "-Xno-receiver-assertions" + ) + } +} + +dependencies { + compileOnly(com.google.devtools.ksp.symbol.processing.api) + ksp(dev.zacsweers.autoservice.auto.service.ksp) + implementation(com.google.auto.service.auto.service.annotations) + implementation(com.squareup.kotlinpoet) + implementation(com.squareup.kotlinpoet.ksp) +} \ No newline at end of file diff --git a/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/DeclaredSymbol.kt b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/DeclaredSymbol.kt new file mode 100644 index 0000000..875711c --- /dev/null +++ b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/DeclaredSymbol.kt @@ -0,0 +1,64 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/23. + */ +@file:Suppress("unused", "MemberVisibilityCanBePrivate") + +package com.highcapable.hikage.compiler + +object DeclaredSymbol { + + const val ANNOTATION_PACKAGE_NAME = "com.highcapable.hikage.annotation" + + const val HIKAGEABLE_ANNOTATION_CLASS_NAME = "Hikageable" + const val HIKAGEABLE_ANNOTATION_CLASS = "$ANNOTATION_PACKAGE_NAME.$HIKAGEABLE_ANNOTATION_CLASS_NAME" + const val HIKAGE_VIEW_ANNOTATION_CLASS_NAME = "HikageView" + const val HIKAGE_VIEW_ANNOTATION_CLASS = "$ANNOTATION_PACKAGE_NAME.$HIKAGE_VIEW_ANNOTATION_CLASS_NAME" + const val HIKAGE_HIKAGE_VIEW_DECLARATION_ANNOTATION_CLASS_NAME = "HikageViewDeclaration" + const val HIKAGE_HIKAGE_VIEW_DECLARATION_ANNOTATION_CLASS = "$ANNOTATION_PACKAGE_NAME.$HIKAGE_HIKAGE_VIEW_DECLARATION_ANNOTATION_CLASS_NAME" + + const val ANDROID_VIEW_PACKAGE_NAME = "android.view" + + const val ANDROID_VIEW_CLASS = "$ANDROID_VIEW_PACKAGE_NAME.View" + const val ANDROID_VIEW_GROUP_CLASS_NAME = "ViewGroup" + const val ANDROID_VIEW_GROUP_CLASS = "$ANDROID_VIEW_PACKAGE_NAME.$ANDROID_VIEW_GROUP_CLASS_NAME" + + const val ANDROID_LAYOUT_PARAMS_CLASS_NAME = "ViewGroup.LayoutParams" + const val ANDROID_LAYOUT_PARAMS_CLASS = "$ANDROID_VIEW_PACKAGE_NAME.$ANDROID_LAYOUT_PARAMS_CLASS_NAME" + + const val HIKAGE_CORE_PACKAGE_NAME = "com.highcapable.hikage.core" + + const val HIKAGE_CLASS_NAME = "Hikage" + const val HIKAGE_CLASS = "$HIKAGE_CORE_PACKAGE_NAME.$HIKAGE_CLASS_NAME" + + const val HIKAGE_PERFORMER_CLASS_NAME = "Hikage.Performer" + const val HIKAGE_PERFORMER_CLASS = "$HIKAGE_CORE_PACKAGE_NAME.$HIKAGE_PERFORMER_CLASS_NAME" + + const val HIKAGE_LAYOUT_PARAMS_CLASS_NAME = "Hikage.LayoutParams" + const val HIKAGE_LAYOUT_PARAMS_CLASS = "$HIKAGE_CORE_PACKAGE_NAME.$HIKAGE_LAYOUT_PARAMS_CLASS_NAME" + + const val HIKAGE_BASE_PACKAGE_NAME = "com.highcapable.hikage.core.base" + + const val HIKAGE_VIEW_LAMBDA_CLASS_NAME = "HikageView" + const val HIKAGE_VIEW_LAMBDA_CLASS = "$HIKAGE_BASE_PACKAGE_NAME.$HIKAGE_VIEW_LAMBDA_CLASS_NAME" + + const val HIKAGE_PERFORMER_LAMBDA_CLASS_NAME = "HikagePerformer" + const val HIKAGE_PERFORMER_LAMBDA_CLASS = "$HIKAGE_BASE_PACKAGE_NAME.$HIKAGE_PERFORMER_LAMBDA_CLASS_NAME" +} \ No newline at end of file diff --git a/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/HikageProcessor.kt b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/HikageProcessor.kt new file mode 100644 index 0000000..4604cb5 --- /dev/null +++ b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/HikageProcessor.kt @@ -0,0 +1,51 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/23. + */ +@file:Suppress("unused") + +package com.highcapable.hikage.compiler + +import com.google.auto.service.AutoService +import com.google.devtools.ksp.processing.Resolver +import com.google.devtools.ksp.processing.SymbolProcessor +import com.google.devtools.ksp.processing.SymbolProcessorEnvironment +import com.google.devtools.ksp.processing.SymbolProcessorProvider +import com.google.devtools.ksp.symbol.KSAnnotated +import com.highcapable.hikage.compiler.subprocessor.HikageViewGenerator + +@AutoService(SymbolProcessorProvider::class) +class HikageProcessor : SymbolProcessorProvider { + + override fun create(environment: SymbolProcessorEnvironment) = object : SymbolProcessor { + + private val subProcessor = listOf( + HikageViewGenerator(environment) + ) + + override fun process(resolver: Resolver) = emptyList().let { startProcess(resolver); it } + + private fun startProcess(resolver: Resolver) { + subProcessor.forEach { + it.startProcess(resolver) + } + } + } +} \ No newline at end of file diff --git a/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/extension/HikageProcessor.kt b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/extension/HikageProcessor.kt new file mode 100644 index 0000000..6a50811 --- /dev/null +++ b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/extension/HikageProcessor.kt @@ -0,0 +1,74 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/30. + */ +package com.highcapable.hikage.compiler.extension + +import com.google.devtools.ksp.processing.Resolver +import com.google.devtools.ksp.symbol.KSClassDeclaration +import com.google.devtools.ksp.symbol.KSDeclaration +import com.google.devtools.ksp.symbol.KSType +import com.google.devtools.ksp.symbol.KSValueArgument +import com.squareup.kotlinpoet.ClassName + +fun KSDeclaration.getClassDeclaration(resolver: Resolver) = + if (this is KSClassDeclaration) this else qualifiedName?.let { resolver.getClassDeclarationByName(it) } + +fun KSDeclaration.getSimpleNameString(): String { + val packageName = packageName.asString() + return qualifiedName?.asString()?.replace("$packageName.", "") ?: simpleName.asString() +} + +fun KSClassDeclaration.isSubclassOf(superType: KSType?): Boolean { + if (superType == null) return false + if (this == superType.declaration) return true + superTypes.forEach { parent -> + val resolvedParent = parent.resolve() + // Direct match. + if (resolvedParent == superType) return true + val parentDeclaration = resolvedParent.declaration as? KSClassDeclaration + ?: return@forEach + // Recursively check the parent class. + if (parentDeclaration.isSubclassOf(superType)) return true + }; return false +} + +fun KSClassDeclaration.asType() = asType(emptyList()) + +inline fun List.getOrNull(name: String) = + firstOrNull { it.name?.asString() == name }?.value as? T? + +fun ClassName.getTypedSimpleName() = simpleName.replace(".", "_") + +object ClassDetector { + + private val javaKeywords = setOf( + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", + "const", "continue", "default", "do", "double", "else", "enum", "extends", "final", + "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", + "interface", "long", "native", "new", "package", "private", "protected", "public", + "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", + "throw", "throws", "transient", "try", "void", "volatile", "while" + ) + + private val invalidPattern = "^(\\d.*|.*[^A-Za-z0-9_\$].*)$".toRegex() + + fun verify(name: String) = name !in javaKeywords && !invalidPattern.matches(name) +} \ No newline at end of file diff --git a/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/subprocessor/HikageViewGenerator.kt b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/subprocessor/HikageViewGenerator.kt new file mode 100644 index 0000000..69af3f2 --- /dev/null +++ b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/subprocessor/HikageViewGenerator.kt @@ -0,0 +1,393 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/23. + */ +@file:Suppress("LocalVariableName") + +package com.highcapable.hikage.compiler.subprocessor + +import com.google.devtools.ksp.getClassDeclarationByName +import com.google.devtools.ksp.processing.Dependencies +import com.google.devtools.ksp.processing.KSPLogger +import com.google.devtools.ksp.processing.Resolver +import com.google.devtools.ksp.processing.SymbolProcessorEnvironment +import com.google.devtools.ksp.symbol.ClassKind +import com.google.devtools.ksp.symbol.KSAnnotation +import com.google.devtools.ksp.symbol.KSClassDeclaration +import com.google.devtools.ksp.symbol.KSType +import com.highcapable.hikage.compiler.DeclaredSymbol +import com.highcapable.hikage.compiler.extension.ClassDetector +import com.highcapable.hikage.compiler.extension.asType +import com.highcapable.hikage.compiler.extension.getClassDeclaration +import com.highcapable.hikage.compiler.extension.getOrNull +import com.highcapable.hikage.compiler.extension.getSimpleNameString +import com.highcapable.hikage.compiler.extension.getTypedSimpleName +import com.highcapable.hikage.compiler.extension.isSubclassOf +import com.highcapable.hikage.compiler.subprocessor.base.BaseSymbolProcessor +import com.highcapable.hikage.generated.HikageCompilerProperties +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.TypeVariableName +import com.squareup.kotlinpoet.asTypeName +import com.squareup.kotlinpoet.ksp.writeTo + +class HikageViewGenerator(override val environment: SymbolProcessorEnvironment) : BaseSymbolProcessor(environment) { + + private companion object { + + private const val PACKAGE_NAME_PREFIX = "com.highcapable.hikage.widget" + + val HikageableClass = ClassName(DeclaredSymbol.ANNOTATION_PACKAGE_NAME, DeclaredSymbol.HIKAGEABLE_ANNOTATION_CLASS_NAME) + val HikageLparamClass = ClassName(DeclaredSymbol.HIKAGE_CORE_PACKAGE_NAME, DeclaredSymbol.HIKAGE_LAYOUT_PARAMS_CLASS_NAME) + val ViewGroupLpClass = ClassName(DeclaredSymbol.ANDROID_VIEW_PACKAGE_NAME, DeclaredSymbol.ANDROID_LAYOUT_PARAMS_CLASS_NAME) + val PerformerClass = ClassName(DeclaredSymbol.HIKAGE_CORE_PACKAGE_NAME, DeclaredSymbol.HIKAGE_PERFORMER_CLASS_NAME) + val ViewLambdaClass = ClassName(DeclaredSymbol.HIKAGE_BASE_PACKAGE_NAME, DeclaredSymbol.HIKAGE_VIEW_LAMBDA_CLASS_NAME) + val PerformerLambdaClass = ClassName(DeclaredSymbol.HIKAGE_BASE_PACKAGE_NAME, DeclaredSymbol.HIKAGE_PERFORMER_LAMBDA_CLASS_NAME) + } + + private val performers = mutableListOf() + + override fun startProcess(resolver: Resolver) { + Processor.init(logger, resolver) + val dependencies = Dependencies(aggregating = true, *resolver.getAllFiles().toList().toTypedArray()) + resolver.getSymbolsWithAnnotation(HikageViewSpec.CLASS) + .filterIsInstance() + .distinctBy { it.qualifiedName } + .forEach { ksClass -> + ksClass.annotations.forEach { + // Get annotation parameters. + val (annotation, declaration) = HikageViewSpec.create(resolver, it, ksClass) + performers += Performer(annotation, declaration) + } + } + resolver.getSymbolsWithAnnotation(HikageViewDeclarationSpec.CLASS) + .filterIsInstance() + .distinctBy { it.qualifiedName } + .forEach { ksClass -> + ksClass.annotations.forEach { + // Get annotation parameters. + val (annotation, declaration) = HikageViewDeclarationSpec.create(resolver, it, ksClass) + performers += Performer(annotation, declaration) + } + } + processPerformer(dependencies) + } + + private fun processPerformer(dependencies: Dependencies) { + val duplicatedItems = performers.groupBy { it.declaration.key }.filter { it.value.size > 1 }.flatMap { it.value } + require(duplicatedItems.isEmpty()) { + "Discover duplicate @HikageView or @HikageViewDeclaration's class name or alias definitions, " + + "you can re-specify the class name using the `alias` parameter.\n" + + "Duplicated Items:\n" + + duplicatedItems.joinToString("\n") { "${it.declaration}\n${it.declaration.locateDesc}" } + } + performers.forEach { generateCodeFile(dependencies, it) } + } + + private fun generateCodeFile(dependencies: Dependencies, performer: Performer) { + val classNameSet = performer.declaration.alias ?: performer.declaration.className + val fileName = "_$classNameSet" + val viewClass = performer.declaration.toClassName().let { + val packageName = it.packageName + val simpleName = it.simpleName + val topClassName = if (simpleName.contains(".")) simpleName.split(".")[0] else null + // com.example.MyViewScope + // com.example.MyViewScope.MyView + topClassName?.let { name -> ClassName(packageName, name) } to it + } + val lparamsClass = performer.annotation.lparams?.let { + val packageName = it.packageName.asString() + val subClassName = it.getSimpleNameString() + val simpleName = it.simpleName.asString() + val topClassName = subClassName.replace(".$simpleName", "") + // android.view.ViewGroup + // android.view.ViewGroup.LayoutParams + (if (topClassName != subClassName) + ClassName(packageName, topClassName) + else null) to ClassName(packageName, subClassName) + } + val packageName = "$PACKAGE_NAME_PREFIX.${performer.declaration.packageName}" + val fileSpec = FileSpec.builder(packageName, fileName).apply { + addFileComment( + """ + Hikage - ${HikageCompilerProperties.POM_DESCRIPTION} + Copyright (C) 2019 HighCapable + ${HikageCompilerProperties.PROJECT_URL} + + This file is auto generated by Hikage. + **DO NOT EDIT THIS FILE MANUALLY** + """.trimIndent() + ) + addAnnotation( + AnnotationSpec.builder(Suppress::class) + .addMember("%S, %S, %S", "unused", "FunctionName", "DEPRECATION") + .build() + ) + addAnnotation( + AnnotationSpec.builder(JvmName::class) + .addMember("%S", "${classNameSet}Performer") + .build() + ) + addImport(DeclaredSymbol.ANDROID_VIEW_PACKAGE_NAME, DeclaredSymbol.ANDROID_VIEW_GROUP_CLASS_NAME) + addImport(DeclaredSymbol.HIKAGE_CORE_PACKAGE_NAME, DeclaredSymbol.HIKAGE_CLASS_NAME) + // Kotlin's import rule is to introduce the parent class that also needs to be introduced at the same time. + // If a child class exists, it needs to import the parent class, + // and kotlinpoet will not perform this operation automatically. + viewClass.first?.let { addImport(it.packageName, it.simpleName) } + lparamsClass?.first?.let { addImport(it.packageName, it.simpleName) } + // May conflict with other [LayoutParams]. + lparamsClass?.second?.let { addAliasedImport(it, it.getTypedSimpleName()) } + addAliasedImport(ViewGroupLpClass, ViewGroupLpClass.getTypedSimpleName()) + addAliasedImport(HikageLparamClass, HikageLparamClass.getTypedSimpleName()) + addFunction(FunSpec.builder(classNameSet).apply { + addKdoc( + """ + Resolve the [${performer.declaration.className}]. + @see ${performer.declaration.className} + @see Hikage.Performer.${if (lparamsClass == null) "View" else "ViewGroup"} + @return [${performer.declaration.className}] + """.trimIndent() + ) + addAnnotation(HikageableClass) + addModifiers(KModifier.INLINE) + addTypeVariable(TypeVariableName(name = "LP", ViewGroupLpClass).copy(reified = true)) + receiver(PerformerClass.parameterizedBy(TypeVariableName("LP"))) + addParameter( + ParameterSpec.builder(name = "lparams", HikageLparamClass.copy(nullable = true)) + .defaultValue("null") + .build() + ) + addParameter( + ParameterSpec.builder(name = "id", String::class.asTypeName().copy(nullable = true)) + .defaultValue("null") + .build() + ) + addParameter( + ParameterSpec.builder( + name = "init", + ViewLambdaClass.parameterizedBy(viewClass.second) + ).apply { + if (!performer.annotation.requireInit) defaultValue("{}") + }.build() + ) + lparamsClass?.second?.let { + addParameter( + ParameterSpec.builder( + name = "performer", + PerformerLambdaClass.parameterizedBy(it) + ).apply { + if (!performer.annotation.requirePerformer) defaultValue("{}") + }.build() + ) + addStatement("return ViewGroup<${performer.declaration.className}, ${it.simpleName}>(lparams, id, init, performer)") + } ?: addStatement("return View<${performer.declaration.className}>(lparams, id, init)") + returns(viewClass.second) + }.build()) + }.build() + // May already exists, no need to generate. + runCatching { + fileSpec.writeTo(codeGenerator, dependencies) + }.onFailure { + if (it !is FileAlreadyExistsException) throw it + } + } + + private object Processor { + + private lateinit var logger: KSPLogger + + private lateinit var viewDeclaration: KSClassDeclaration + private lateinit var viewGroupDeclaration: KSClassDeclaration + private lateinit var lparamsDeclaration: KSClassDeclaration + + fun init(logger: KSPLogger, resolver: Resolver) { + this.logger = logger + viewDeclaration = resolver.getClassDeclarationByName(DeclaredSymbol.ANDROID_VIEW_CLASS)!! + viewGroupDeclaration = resolver.getClassDeclarationByName(DeclaredSymbol.ANDROID_VIEW_GROUP_CLASS)!! + lparamsDeclaration = resolver.getClassDeclarationByName(DeclaredSymbol.ANDROID_LAYOUT_PARAMS_CLASS)!! + } + + fun resolvedLparamsDeclaration( + tagName: String, + resolver: Resolver, + declaration: ViewDeclaration, + lparams: KSType? + ): KSClassDeclaration? { + val lparamsType = lparams?.takeIf { ksType -> + ksType.declaration.qualifiedName?.asString() != Any::class.qualifiedName + } + var resolvedLparams = lparamsType?.declaration?.getClassDeclaration(resolver) + when { + // If the current view is not a view group but the lparams parameter is declared, + // remove the lparams parameter. + !declaration.isViewGroup && resolvedLparams != null -> { + logger.warn( + "Declares @$tagName's lparams \"${resolvedLparams.qualifiedName?.asString()}\" is invalid, " + + "because the current view is not a view group.\n${declaration.locateDesc}" + ) + resolvedLparams = null + } + // If the current view is a view group but the lparams parameter is not declared, + // set the default type parameter for it. + declaration.isViewGroup && resolvedLparams == null -> resolvedLparams = lparamsDeclaration + } + // Verify layout parameter class. + if (resolvedLparams != null) require(resolvedLparams.isSubclassOf(lparamsDeclaration.asType())) { + val resolvedLparamsName = resolvedLparams.qualifiedName?.asString() + "Declares @$tagName's lparams \"$resolvedLparamsName\" must be subclass of " + + "\"${DeclaredSymbol.ANDROID_LAYOUT_PARAMS_CLASS}\".\n${declaration.locateDesc}" + } + return resolvedLparams + } + + fun createViewDeclaration( + tagName: String, + alias: String?, + ksClass: KSClassDeclaration, + baseType: KSClassDeclaration = ksClass + ): ViewDeclaration { + val packageName = ksClass.packageName.asString() + val className = ksClass.getSimpleNameString() + val isViewGroup = ksClass.isSubclassOf(viewGroupDeclaration.asType()) + var _alias = alias + // If no alias name is set, if the class name contains a subclass, + // replace it with an underscore and use it as an alias name. + if (_alias.isNullOrBlank() && className.contains(".")) + _alias = className.replace(".", "_") + _alias = _alias?.takeIf { it.isNotBlank() } + val declaration = ViewDeclaration(packageName, className, _alias, isViewGroup, baseType) + // Verify the legality of the class name. + if (!_alias.isNullOrBlank()) require(ClassDetector.verify(_alias)) { + "Declares @$tagName's alias \"$_alias\" is illegal.\n${declaration.locateDesc}" + } + // [ViewGroup] cannot be new instance. + require(ksClass != viewGroupDeclaration) { + "Declares @$tagName's class must not be a directly \"${DeclaredSymbol.ANDROID_VIEW_GROUP_CLASS}\".\n${declaration.locateDesc}" + } + // Annotations can only be modified on android view. + require(ksClass.isSubclassOf(viewDeclaration.asType())) { + "Declares @$tagName's class must be subclass of \"${DeclaredSymbol.ANDROID_VIEW_CLASS}\".\n${declaration.locateDesc}" + } + return declaration + } + } + + private data class ViewDeclaration( + val packageName: String, + val className: String, + val alias: String?, + val isViewGroup: Boolean, + val baseType: KSClassDeclaration + ) { + + val key get() = "$packageName${alias ?: className}$isViewGroup" + + val locateDesc by lazy { "Located: ${baseType.qualifiedName?.asString()}" } + + fun toClassName() = ClassName(packageName, className) + + override fun toString() = "{ package: $packageName, class: $className, alias: ${alias ?: ""} }" + } + + private data class HikageViewSpec( + override val lparams: KSClassDeclaration?, + override val alias: String?, + override val requireInit: Boolean, + override val requirePerformer: Boolean + ) : HikageAnnotationSpec { + + companion object { + + const val CLASS = DeclaredSymbol.HIKAGE_VIEW_ANNOTATION_CLASS + const val NAME = DeclaredSymbol.HIKAGE_VIEW_ANNOTATION_CLASS_NAME + + fun create( + resolver: Resolver, + annotation: KSAnnotation, + ksClass: KSClassDeclaration + ): Pair { + val lparams = annotation.arguments.getOrNull("lparams") + val alias = annotation.arguments.getOrNull("alias") + val requireInit = annotation.arguments.getOrNull("requireInit") ?: false + val requirePerformer = annotation.arguments.getOrNull("requirePerformer") ?: false + // Solve the actual content of the annotation parameters. + val declaration = Processor.createViewDeclaration(NAME, alias, ksClass) + val resolvedLparams = Processor.resolvedLparamsDeclaration(NAME, resolver, declaration, lparams) + return HikageViewSpec(resolvedLparams, alias, requireInit, requirePerformer) to declaration + } + } + } + + private data class HikageViewDeclarationSpec( + val view: KSClassDeclaration?, + override val lparams: KSClassDeclaration?, + override val alias: String?, + override val requireInit: Boolean, + override val requirePerformer: Boolean + ) : HikageAnnotationSpec { + + companion object { + + const val CLASS = DeclaredSymbol.HIKAGE_HIKAGE_VIEW_DECLARATION_ANNOTATION_CLASS + const val NAME = DeclaredSymbol.HIKAGE_HIKAGE_VIEW_DECLARATION_ANNOTATION_CLASS_NAME + + fun create( + resolver: Resolver, + annotation: KSAnnotation, + ksClass: KSClassDeclaration + ): Pair { + val view = annotation.arguments.getOrNull("view") + val lparams = annotation.arguments.getOrNull("lparams") + val alias = annotation.arguments.getOrNull("alias") + val requireInit = annotation.arguments.getOrNull("requireInit") ?: false + val requirePerformer = annotation.arguments.getOrNull("requirePerformer") ?: false + // Solve the actual content of the annotation parameters. + val resolvedView = view?.declaration?.getClassDeclaration(resolver) ?: error("Internal error.") + val declaration = Processor.createViewDeclaration(NAME, alias, resolvedView, ksClass) + // Only object classes can be used as view declarations. + require(ksClass.classKind == ClassKind.OBJECT) { + "Declares @$NAME's class must be an object.\n${declaration.locateDesc}" + } + require(!ksClass.isCompanionObject) { + "Declares @$NAME's class must not be a companion object.\n${declaration.locateDesc}" + } + val resolvedLparams = Processor.resolvedLparamsDeclaration(NAME, resolver, declaration, lparams) + return HikageViewDeclarationSpec(resolvedView, resolvedLparams, alias, requireInit, requirePerformer) to declaration + } + } + } + + private interface HikageAnnotationSpec { + val lparams: KSClassDeclaration? + val alias: String? + val requireInit: Boolean + val requirePerformer: Boolean + } + + private data class Performer( + val annotation: HikageAnnotationSpec, + val declaration: ViewDeclaration + ) +} \ No newline at end of file diff --git a/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/subprocessor/base/BaseSymbolProcessor.kt b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/subprocessor/base/BaseSymbolProcessor.kt new file mode 100644 index 0000000..b213bec --- /dev/null +++ b/hikage-compiler/src/main/java/com/highcapable/hikage/compiler/subprocessor/base/BaseSymbolProcessor.kt @@ -0,0 +1,33 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/23. + */ +package com.highcapable.hikage.compiler.subprocessor.base + +import com.google.devtools.ksp.processing.Resolver +import com.google.devtools.ksp.processing.SymbolProcessorEnvironment + +abstract class BaseSymbolProcessor(protected open val environment: SymbolProcessorEnvironment) { + + protected val logger by lazy { environment.logger } + protected val codeGenerator by lazy { environment.codeGenerator } + + abstract fun startProcess(resolver: Resolver) +} \ No newline at end of file diff --git a/hikage-core-lint/build.gradle.kts b/hikage-core-lint/build.gradle.kts new file mode 100644 index 0000000..e4c2c0c --- /dev/null +++ b/hikage-core-lint/build.gradle.kts @@ -0,0 +1,46 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + autowire(libs.plugins.kotlin.jvm) +} + +group = property.project.groupName + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +kotlin { + jvmToolchain(17) + compilerOptions { + freeCompilerArgs = listOf( + "-Xno-param-assertions", + "-Xno-call-assertions", + "-Xno-receiver-assertions" + ) + } +} + +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + +tasks.named("jar") { + manifest { + attributes( + "Lint-Registry-V2" to property.project.hikage.core.lint.registry.v2.clazz + ) + } +} + +dependencies { + compileOnly(org.jetbrains.kotlin.kotlin.stdlib) + compileOnly(com.android.tools.lint.lint.api) + compileOnly(com.android.tools.lint.lint.checks) + testImplementation(com.android.tools.lint.lint) + testImplementation(com.android.tools.lint.lint.tests) +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/DeclaredSymbol.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/DeclaredSymbol.kt new file mode 100644 index 0000000..1eda30e --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/DeclaredSymbol.kt @@ -0,0 +1,31 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/17. + */ +package com.highcapable.hikage.core.lint + +object DeclaredSymbol { + + const val HIKAGEABLE_ANNOTATION_CLASS = "com.highcapable.hikage.annotation.Hikageable" + const val HIKAGE_CLASS = "com.highcapable.hikage.core.Hikage" + const val HIKAGE_PERFORMER_CLASS = "com.highcapable.hikage.core.Hikage.Performer" + + val HIKAGE_VIEW_REGEX = "kotlin.jvm.functions.Function1<\\?\\s*super\\s+[^,]+,kotlin.Unit>".toRegex() +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/HikageIssueRegistry.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/HikageIssueRegistry.kt new file mode 100644 index 0000000..c5e0177 --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/HikageIssueRegistry.kt @@ -0,0 +1,52 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/14. + */ +@file:Suppress("unused") + +package com.highcapable.hikage.core.lint + +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +import com.android.tools.lint.detector.api.CURRENT_API +import com.highcapable.hikage.core.lint.detector.HikageSafeTypeCastDetector +import com.highcapable.hikage.core.lint.detector.HikageableBeyondScopeDetector +import com.highcapable.hikage.core.lint.detector.HikageableFunctionsDetector +import com.highcapable.hikage.core.lint.detector.WidgetsUsageDetector +import com.highcapable.hikage.generated.HikageCoreLintProperties + +class HikageIssueRegistry : IssueRegistry() { + + override val issues get() = listOf( + HikageableBeyondScopeDetector.ISSUE, + HikageableFunctionsDetector.ISSUE, + HikageSafeTypeCastDetector.ISSUE, + WidgetsUsageDetector.ISSUE + ) + + override val minApi = HikageCoreLintProperties.PROJECT_HIKAGE_CORE_LINT_MIN_API + override val api = CURRENT_API + override val vendor = Vendor( + vendorName = HikageCoreLintProperties.PROJECT_NAME, + identifier = HikageCoreLintProperties.PROJECT_HIKAGE_CORE_LINT_IDENTIFIER, + feedbackUrl = "${HikageCoreLintProperties.PROJECT_URL}/issues", + contact = HikageCoreLintProperties.PROJECT_URL + ) +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageSafeTypeCastDetector.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageSafeTypeCastDetector.kt new file mode 100644 index 0000000..ce94214 --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageSafeTypeCastDetector.kt @@ -0,0 +1,111 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/4/2. + */ +package com.highcapable.hikage.core.lint.detector + +import com.android.tools.lint.client.api.UElementHandler +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.LintFix +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import com.highcapable.hikage.core.lint.DeclaredSymbol +import org.jetbrains.uast.UArrayAccessExpression +import org.jetbrains.uast.UBinaryExpressionWithType +import org.jetbrains.uast.UParenthesizedExpression +import org.jetbrains.uast.UQualifiedReferenceExpression + +class HikageSafeTypeCastDetector : Detector(), Detector.UastScanner { + + companion object { + + val ISSUE = Issue.create( + id = "UseHikageSafeTypeCast", + briefDescription = "Hikage safe type cast usage.", + explanation = "Recommended to use `hikage.get(\"your_id\")` instead of `hikage[\"your_id\"] as YourView`.", + category = Category.COMPLIANCE, + priority = 5, + severity = Severity.WARNING, + implementation = Implementation( + HikageSafeTypeCastDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + ) + } + + override fun getApplicableUastTypes() = listOf(UQualifiedReferenceExpression::class.java, UBinaryExpressionWithType::class.java) + + override fun createUastHandler(context: JavaContext) = object : UElementHandler() { + + override fun visitQualifiedReferenceExpression(node: UQualifiedReferenceExpression) { + if (node.selector !is UBinaryExpressionWithType) return + val castExpr = node.selector as UBinaryExpressionWithType + visitAndLint(context, castExpr, node) + } + + override fun visitBinaryExpressionWithType(node: UBinaryExpressionWithType) { + visitAndLint(context, node) + } + + private fun visitAndLint( + context: JavaContext, + node: UBinaryExpressionWithType, + parent: UQualifiedReferenceExpression? = null + ) { + // Get the parent node, if it is wrapped with brackets will also be included. + val locationNode = node.uastParent as? UParenthesizedExpression ?: node + val receiver = parent?.receiver ?: node.operand + val receiverType = (node.operand as? UArrayAccessExpression)?.receiver?.getExpressionType() ?: return + val receiverClass = receiverType.canonicalText + // Filter retains results that meet the conditions. + if (receiverClass != DeclaredSymbol.HIKAGE_CLASS) return + // Like `hikage["your_id"] as YourView`. + val exprText = node.sourcePsi?.text ?: return + // Like `hikage["your_id"]`. + val receiverText = receiver.sourcePsi?.text ?: return + // Like `hikage`. + val receiverNameText = receiverText.split("[")[0] + // Like `"your_id"`. + val receiverContent = runCatching { receiverText.split("[")[1].split("]")[0] }.getOrNull() ?: return + val isSafeCast = exprText.contains("as?") || exprText.endsWith("?") + // Like `YourView`. + val castTypeContent = node.typeReference?.sourcePsi?.text?.removeSuffix("?") ?: return + val replacement = "$receiverNameText.${if (isSafeCast) "getOrNull" else "get"}<$castTypeContent>($receiverContent)" + val replaceSuggestion = if (isSafeCast) "Hikage.getOrNull<$castTypeContent>" else "Hikage.get<$castTypeContent>" + val location = context.getLocation(locationNode) + val lintFix = LintFix.create() + .name("Replace with '$replacement'") + .replace() + .range(location) + .with(replacement) + .reformat(true) + .build() + context.report( + ISSUE, locationNode, location, + message = "Can be replaced with safe type cast `$replaceSuggestion`.", + quickfixData = lintFix + ) + } + } +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageableBeyondScopeDetector.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageableBeyondScopeDetector.kt new file mode 100644 index 0000000..7f356f0 --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageableBeyondScopeDetector.kt @@ -0,0 +1,133 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/17. + */ +package com.highcapable.hikage.core.lint.detector + +import com.android.tools.lint.client.api.UElementHandler +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.LintFix +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import com.highcapable.hikage.core.lint.DeclaredSymbol +import com.highcapable.hikage.core.lint.detector.entity.ReportDetail +import com.highcapable.hikage.core.lint.detector.extension.hasHikageable +import com.intellij.psi.PsiMethod +import org.jetbrains.kotlin.psi.KtCallExpression +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtLambdaArgument +import org.jetbrains.kotlin.psi.KtLambdaExpression +import org.jetbrains.kotlin.psi.KtValueArgument +import org.jetbrains.uast.UCallExpression +import org.jetbrains.uast.toUElementOfType + +class HikageableBeyondScopeDetector : Detector(), Detector.UastScanner { + + companion object { + + val ISSUE = Issue.create( + id = "HikageableBeyondScope", + briefDescription = "Hikageable beyond scope.", + explanation = "Functions marked with `@Hikageable` can only be passed in `Hikage.Performer`.", + category = Category.COMPLIANCE, + priority = 10, + severity = Severity.ERROR, + implementation = Implementation( + HikageableBeyondScopeDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + ) + } + + override fun getApplicableUastTypes() = listOf(UCallExpression::class.java) + + override fun createUastHandler(context: JavaContext) = object : UElementHandler() { + + private val reportedNodes = mutableSetOf() + private val reports = mutableListOf() + + override fun visitCallExpression(node: UCallExpression) { + val callExpr = node.sourcePsi as? KtCallExpression ?: return + val method = node.resolve() ?: return + startLint(callExpr, method) + organizeAndReport() + } + + private fun startLint(callExpr: KtCallExpression, method: PsiMethod) { + val className = method.containingClass?.qualifiedName ?: "" + val hasHikageable = method.hasHikageable() + val hasLayoutParams = className == DeclaredSymbol.HIKAGE_PERFORMER_CLASS && method.name == "LayoutParams" + if (hasHikageable || hasLayoutParams) visitAndLint(callExpr, method) + } + + private fun organizeAndReport() { + reports.forEach { + // Check if the call has been reported before reporting. + if (reportedNodes.contains(it.callExpr)) return@forEach + val location = context.getLocation(it.callExpr) + val lintFix = LintFix.create() + .name("Delete Call Expression") + .replace() + .range(location) + // Delete the call expression. + .with("") + .build() + context.report(ISSUE, it.callExpr, location, it.message, lintFix) + reportedNodes.add(it.callExpr) + } + } + + private fun visitAndLint(callExpr: KtCallExpression, method: PsiMethod) { + val bodyBlocks = mutableMapOf() + val parameters = method.parameterList.parameters + val valueArguments = callExpr.valueArgumentList?.arguments ?: emptyList() + fun visitValueArg(arg: KtValueArgument) { + val name = arg.getArgumentName()?.asName?.identifier ?: "" + val expr = arg.getArgumentExpression() + val parameter = parameters.firstOrNull { it.name == name } + // If the last bit is a lambda expression, then `parameter` must have a lambda parameter defined by the last bit. + ?: if (arg is KtLambdaArgument) parameters.lastOrNull() else null + val isMatched = parameter?.type?.canonicalText?.matches(DeclaredSymbol.HIKAGE_VIEW_REGEX) == true && + !parameter.type.canonicalText.contains(DeclaredSymbol.HIKAGE_PERFORMER_CLASS) + if (expr is KtLambdaExpression && isMatched) + expr.bodyExpression?.let { bodyBlocks[name] = it } + } + // Get the last lambda expression. + val lastLambda = callExpr.lambdaArguments.lastOrNull() + if (lastLambda != null) visitValueArg(lastLambda) + valueArguments.forEach { arg -> visitValueArg(arg) } + bodyBlocks.toList().flatMap { (_, value) -> value.children.filterIsInstance() }.forEach { + val expression = it.toUElementOfType() ?: return@forEach + val sCallExpr = expression.sourcePsi as? KtCallExpression ?: return@forEach + val sMethod = expression.resolve() ?: return@forEach + if (sMethod.hasHikageable()) { + val message = "Performers are not allowed to appear in `${method.name}` DSL creation process." + reports.add(ReportDetail(message, expression)) + // Recursively to visit next level. + visitAndLint(sCallExpr, sMethod) + } + } + } + } +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageableFunctionsDetector.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageableFunctionsDetector.kt new file mode 100644 index 0000000..a046abf --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/HikageableFunctionsDetector.kt @@ -0,0 +1,99 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/17. + */ +package com.highcapable.hikage.core.lint.detector + +import com.android.tools.lint.client.api.UElementHandler +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.LintFix +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import com.highcapable.hikage.core.lint.DeclaredSymbol +import com.highcapable.hikage.core.lint.detector.extension.hasHikageable +import com.intellij.psi.PsiMethod +import org.jetbrains.uast.UBlockExpression +import org.jetbrains.uast.UCallExpression +import org.jetbrains.uast.UMethod +import org.jetbrains.uast.UReturnExpression +import org.jetbrains.uast.tryResolve + +class HikageableFunctionsDetector : Detector(), Detector.UastScanner { + + companion object { + + val ISSUE = Issue.create( + id = "HikageableFunctions", + briefDescription = "Hikageable functions.", + explanation = "Functions which invoke `@Hikageable` functions must be marked with the `@Hikageable` annotation.", + category = Category.COMPLIANCE, + priority = 10, + severity = Severity.ERROR, + implementation = Implementation( + HikageableFunctionsDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + ) + + private val functionRegex = "(\\s?.+)?fun\\s?".toRegex() + } + + override fun getApplicableUastTypes() = listOf(UMethod::class.java) + + override fun createUastHandler(context: JavaContext) = object : UElementHandler() { + + override fun visitMethod(node: UMethod) { + val uastBody = node.uastBody as? UBlockExpression ?: return + val bodyHasHikageable = uastBody.expressions.any { + when (it) { + is UCallExpression -> it.resolve()?.hasHikageable() ?: false + is UReturnExpression -> + (it.returnExpression?.tryResolve() as? PsiMethod?)?.hasHikageable() ?: false + else -> false + } + } + if (!node.hasHikageable() && bodyHasHikageable) { + val location = context.getLocation(node) + val nameLocation = context.getNameLocation(node) + val message = "Function `${node.name}` must be marked with the `@Hikageable` annotation." + val functionText = node.asSourceString() + val hasDoubleSlash = functionText.startsWith("//") + val replacement = functionRegex.replace(functionText) { result -> + val functionBody = result.groupValues.getOrNull(0) ?: functionText + val prefix = if (hasDoubleSlash) "\n" else "" + "$prefix@Hikageable $functionBody" + } + val lintFix = LintFix.create() + .name("Add '@Hikageable' to '${node.name}'") + .replace() + .range(location) + .with(replacement) + .imports(DeclaredSymbol.HIKAGEABLE_ANNOTATION_CLASS) + .reformat(true) + .build() + context.report(ISSUE, node, nameLocation, message, lintFix) + } + } + } +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/WidgetsUsageDetector.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/WidgetsUsageDetector.kt new file mode 100644 index 0000000..c60dff4 --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/WidgetsUsageDetector.kt @@ -0,0 +1,207 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/17. + */ +package com.highcapable.hikage.core.lint.detector + +import com.android.tools.lint.client.api.UElementHandler +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.LintFix +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import com.highcapable.hikage.core.lint.detector.extension.hasHikageable +import com.intellij.psi.PsiMethod +import org.jetbrains.kotlin.psi.KtCallExpression +import org.jetbrains.uast.UCallExpression +import org.jetbrains.uast.UElement +import org.jetbrains.uast.UImportStatement +import org.jetbrains.uast.toUElement + +class WidgetsUsageDetector : Detector(), Detector.UastScanner { + + companion object { + + val ISSUE = Issue.create( + id = "ReplaceWithHikageWidgets", + briefDescription = "Hikage built-in widget usability.", + explanation = "Use the built-in widget function component provided by Hikage like `TextView(...)` " + + "without using a form like `View(...)` to use the component.", + category = Category.USABILITY, + priority = 5, + severity = Severity.WARNING, + implementation = Implementation( + WidgetsUsageDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + ) + + private const val BUILT_IN_WIDGETS_PACKAGE_PREFIX = "android.widget" + private const val WIDGET_FUNCTION_PREFIX = "com.highcapable.hikage.widget.$BUILT_IN_WIDGETS_PACKAGE_PREFIX" + private const val VIEW_CLASS_NAME = "android.view.View" + private const val VIEW_GROUP_CLASS_NAME = "android.view.ViewGroup" + + private val viewExpressionRegex = "(?:View|ViewGroup)<.*?>".toRegex() + + private val builtInWidgets = listOf( + "SeekBar", + "LinearLayout", + "ScrollView", + "TextView", + "EditText", + "AutoCompleteTextView", + "ExpandableListView", + "ListView", + "RatingBar", + "ViewSwitcher", + "ActionMenuView", + "ImageView", + "ViewAnimator", + "HorizontalScrollView", + "MediaController", + "RelativeLayout", + "TextClock", + "CalendarView", + "ToggleButton", + "RadioGroup", + "VideoView", + "GridView", + "QuickContactBadge", + "TableLayout", + "NumberPicker", + "Toolbar", + "ViewFlipper", + "Chronometer", + "ImageSwitcher", + "Button", + "CheckBox", + "TabWidget", + "TabHost", + "SearchView", + "Spinner", + "TimePicker", + "ImageButton", + "TextSwitcher", + "DatePicker", + "RadioButton", + "CheckedTextView", + "FrameLayout", + "Space", + "GridLayout", + "Switch", + "ProgressBar", + "TableRow" + ) + } + + data class ImportReference(val packagePrefix: String, val name: String, val alias: String? = null) + + override fun getApplicableUastTypes(): List> = listOf(UImportStatement::class.java, UCallExpression::class.java) + + override fun createUastHandler(context: JavaContext) = object : UElementHandler() { + + private val importReferences = mutableSetOf() + + override fun visitImportStatement(node: UImportStatement) { + val imported = node.asSourceString().replace("import", "").let { + when { + it.contains("//") -> it.split("//")[0] + it.contains("/*") -> it.split("/*")[0] + else -> it + } + }.trim() + val importRefs = imported.split(" as ") + val alias = if (importRefs.size > 1) + importRefs.getOrNull(1)?.trim() + else null + val importPrefix = importRefs[0] + val hasPrefix = importPrefix.contains(".") + val name = if (hasPrefix) + importPrefix.split(".").last() + else importPrefix + val packagePrefix = importPrefix.replace(if (hasPrefix) ".$name" else name, "") + val reference = ImportReference(packagePrefix, name, alias) + importReferences.add(reference) + } + + override fun visitCallExpression(node: UCallExpression) { + val callExpr = node.sourcePsi as? KtCallExpression ?: return + val method = node.resolve() ?: return + startLint(callExpr, method) + } + + private fun startLint(callExpr: KtCallExpression, method: PsiMethod) { + val hasHikageable = method.hasHikageable() + if (hasHikageable) visitAndReport(callExpr, method) + } + + private fun visitAndReport(callExpr: KtCallExpression, method: PsiMethod) { + val typeParameters = method.typeParameterList?.typeParameters ?: emptyArray() + val typeArguments = callExpr.typeArgumentList?.arguments ?: emptyList() + val typeArgumentsText = typeArguments.mapNotNull { it.text } + val typedViewFunctionIndex = typeParameters.indexOfFirst { + it.extendsListTypes.any { type -> + type.canonicalText == VIEW_CLASS_NAME || + type.canonicalText == VIEW_GROUP_CLASS_NAME + } + } + val isTypedViewFunction = typedViewFunctionIndex >= 0 + val imports = typeArgumentsText.mapNotNull { typeName -> + when { + // Like `TextView`. + !typeName.contains(".") -> importReferences.firstOrNull { + it.packagePrefix == BUILT_IN_WIDGETS_PACKAGE_PREFIX && + (it.alias == typeName || it.name == typeName) + } + // Like `android.widget.TextView`. + typeName.startsWith(BUILT_IN_WIDGETS_PACKAGE_PREFIX) -> + ImportReference(BUILT_IN_WIDGETS_PACKAGE_PREFIX, typeName.replace("$BUILT_IN_WIDGETS_PACKAGE_PREFIX.", "")) + else -> null + } + } + val matchedIndex = builtInWidgets.indexOfFirst { imports.any { e -> e.alias == it || e.name == it } } + val isBuiltInWidget = matchedIndex >= 0 + if (isTypedViewFunction && isBuiltInWidget) { + val widgetName = builtInWidgets[matchedIndex] + val sourceLocation = context.getLocation(callExpr) + val sourceText = callExpr.toUElement()?.asSourceString() ?: return + val callExprElement = callExpr.toUElement() ?: return + // Matchs '>' and like `View")[0].trim().length + 1 + val nameLocation = context.getRangeLocation(callExprElement, fromDelta = 0, callExprLength) + // Only replace the first one, because there may be multiple sub-functions in DSL. + val replacement = sourceText.replaceFirst(viewExpressionRegex, widgetName) + val lintFix = LintFix.create() + .name("Replace with '$widgetName'") + .replace() + .range(sourceLocation) + .with(replacement) + .imports("$WIDGET_FUNCTION_PREFIX.$widgetName") + .reformat(true) + .build() + val message = "Can be simplified to `$widgetName`." + context.report(ISSUE, callExpr, nameLocation, message, lintFix) + } + } + } +} \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/entity/ReportDetail.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/entity/ReportDetail.kt new file mode 100644 index 0000000..6a069a9 --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/entity/ReportDetail.kt @@ -0,0 +1,29 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/17. + */ +package com.highcapable.hikage.core.lint.detector.entity + +import org.jetbrains.uast.UCallExpression + +data class ReportDetail( + val message: String, + val callExpr: UCallExpression +) \ No newline at end of file diff --git a/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/extension/Detector.kt b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/extension/Detector.kt new file mode 100644 index 0000000..17169f9 --- /dev/null +++ b/hikage-core-lint/src/main/java/com/highcapable/hikage/core/lint/detector/extension/Detector.kt @@ -0,0 +1,27 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/30. + */ +package com.highcapable.hikage.core.lint.detector.extension + +import com.highcapable.hikage.core.lint.DeclaredSymbol +import com.intellij.psi.PsiMethod + +fun PsiMethod.hasHikageable() = hasAnnotation(DeclaredSymbol.HIKAGEABLE_ANNOTATION_CLASS) \ No newline at end of file diff --git a/hikage-core/build.gradle.kts b/hikage-core/build.gradle.kts new file mode 100644 index 0000000..18fa54a --- /dev/null +++ b/hikage-core/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + autowire(libs.plugins.android.library) + autowire(libs.plugins.kotlin.android) + autowire(libs.plugins.kotlin.dokka) + autowire(libs.plugins.maven.publish) + autowire(libs.plugins.kotlin.ksp) +} + +group = property.project.groupName +version = property.project.hikage.core.version + +android { + namespace = property.project.hikage.core.namespace + compileSdk = property.project.android.compileSdk + + defaultConfig { + minSdk = property.project.android.minSdk + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + freeCompilerArgs = listOf( + "-opt-in=kotlin.ExperimentalStdlibApi", + "-Xno-param-assertions", + "-Xno-call-assertions", + "-Xno-receiver-assertions" + ) + } +} + +dependencies { + lintPublish(projects.hikageCoreLint) + ksp(projects.hikageCompiler) + implementation(org.lsposed.hiddenapibypass.hiddenapibypass) + implementation(com.highcapable.yukireflection.api) + api(com.highcapable.betterandroid.ui.extension) + implementation(com.highcapable.betterandroid.system.extension) + implementation(androidx.core.core.ktx) + implementation(androidx.appcompat.appcompat) + testImplementation(junit.junit) + androidTestImplementation(androidx.test.ext.junit) + androidTestImplementation(androidx.test.espresso.espresso.core) +} \ No newline at end of file diff --git a/hikage-core/consumer-rules.pro b/hikage-core/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/hikage-core/proguard-rules.pro b/hikage-core/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/hikage-core/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/hikage-core/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt b/hikage-core/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..31723ed --- /dev/null +++ b/hikage-core/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt @@ -0,0 +1,25 @@ +package com.highcapable.hikage + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.highcapable.hikage.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/hikage-core/src/main/AndroidManifest.xml b/hikage-core/src/main/AndroidManifest.xml new file mode 100644 index 0000000..568741e --- /dev/null +++ b/hikage-core/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/annotation/HikageView.kt b/hikage-core/src/main/java/com/highcapable/hikage/annotation/HikageView.kt new file mode 100644 index 0000000..29c277b --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/annotation/HikageView.kt @@ -0,0 +1,57 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/23. + */ +package com.highcapable.hikage.annotation + +import android.view.View +import android.view.ViewGroup +import com.highcapable.hikage.core.Hikage +import kotlin.reflect.KClass + +/** + * Declare annotations to generate the [Hikage.Performer] function for the specified [View] at compile time. + * + * Usage: + * + * ```kotlin + * @HikageView(lparams = FrameLayout.LayoutParams::class, alias = "MyView") + * class MyView(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) { + * // ... + * } + * ``` + * @param lparams the layout params class, only [ViewGroup] can be specified, + * after specifying, the `performer` parameter will be generated for the function. + * The parameters must be a class inherited from [ViewGroup.LayoutParams], + * if the current [View] does not inherit from [ViewGroup], this parameter will be ignored and warned. + * @param alias the view's class name alias will naming the function, default is the class name. + * @param requireInit whether to force the `init` parameter to be called, default is false. + * @param requirePerformer whether to force the `performer` parameter to be called, default is false, + * this parameter will be ignored when no `performer` parameter is needed here. + */ +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.CLASS) +@MustBeDocumented +annotation class HikageView( + val lparams: KClass<*> = Any::class, + val alias: String = "", + val requireInit: Boolean = false, + val requirePerformer: Boolean = false +) \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/annotation/HikageViewDeclaration.kt b/hikage-core/src/main/java/com/highcapable/hikage/annotation/HikageViewDeclaration.kt new file mode 100644 index 0000000..4f0f6bc --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/annotation/HikageViewDeclaration.kt @@ -0,0 +1,61 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/31. + */ +package com.highcapable.hikage.annotation + +import android.view.View +import android.view.ViewGroup +import com.highcapable.hikage.core.Hikage +import kotlin.reflect.KClass + +/** + * Declare annotations to generate the [Hikage.Performer] function for the specified [view] at compile time. + * + * You can declare a class for [View] that does not belong to your own [View] or third-party library. + * + * The class name you define can be as good as you like, and notice it must to use the `object` keyword to modify it. + * + * Usage: + * + * ```kotlin + * @HikageViewDeclaration(ThirdPartyView::class, FrameLayout.LayoutParams::class, alias = "ThirdPartyView") + * object ThirdPartyViewDeclaration + * ``` + * @param view the view class, only [View] can be specified. + * @param lparams the layout params class, only [ViewGroup] can be specified, + * after specifying, the `performer` parameter will be generated for the function. + * The parameters must be a class inherited from [ViewGroup.LayoutParams], + * if the current [View] does not inherit from [ViewGroup], this parameter will be ignored and warned. + * @param alias the view's class name alias will naming the function, default is the [view] class name. + * @param requireInit whether to force the `init` parameter to be called, default is false. + * @param requirePerformer whether to force the `performer` parameter to be called, default is false, + * this parameter will be ignored when no `performer` parameter is needed here. + */ +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.CLASS) +@MustBeDocumented +annotation class HikageViewDeclaration( + val view: KClass<*>, + val lparams: KClass<*> = Any::class, + val alias: String = "", + val requireInit: Boolean = false, + val requirePerformer: Boolean = false +) \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/annotation/Hikageable.kt b/hikage-core/src/main/java/com/highcapable/hikage/annotation/Hikageable.kt new file mode 100644 index 0000000..8cabc83 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/annotation/Hikageable.kt @@ -0,0 +1,45 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/23. + */ +package com.highcapable.hikage.annotation + +import com.highcapable.hikage.core.Hikage + +/** + * Declare an implementation of the [Hikage.Performer] function that + * will be used for infectious creation of sub-layouts. + * + * Usage: + * + * ```kotlin + * @Hikageable + * inline fun Hikage.Performer.MyView( + * lparams: Hikage.LayoutParams? = null, + * id: String? = null, + * init: HikageView = {} + * ) = View(id, init, lparams) + * ``` + * @see Hikage.Performer + */ +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.FUNCTION) +@MustBeDocumented +annotation class Hikageable \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/bypass/HikageAttrsView.kt b/hikage-core/src/main/java/com/highcapable/hikage/bypass/HikageAttrsView.kt new file mode 100644 index 0000000..428fa2b --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/bypass/HikageAttrsView.kt @@ -0,0 +1,35 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/28. + */ +package com.highcapable.hikage.bypass + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import androidx.annotation.Keep + +/** + * Just a view for obtaining [AttributeSet]. + * + * **DONT USE THIS VIEW IN YOUR LAYOUT.** + */ +@Keep +class HikageAttrsView internal constructor(context: Context, internal val attrs: AttributeSet?) : View(context, attrs) \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/bypass/XmlBlockBypass.kt b/hikage-core/src/main/java/com/highcapable/hikage/bypass/XmlBlockBypass.kt new file mode 100644 index 0000000..008adc3 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/bypass/XmlBlockBypass.kt @@ -0,0 +1,178 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/5. + */ +@file:Suppress("unused", "MemberVisibilityCanBePrivate") + +package com.highcapable.hikage.bypass + +import android.content.Context +import android.content.pm.ApplicationInfo +import android.content.res.XmlResourceParser +import android.content.res.loader.AssetsProvider +import android.content.res.loader.ResourcesProvider +import android.util.AttributeSet +import androidx.annotation.StyleRes +import com.highcapable.betterandroid.system.extension.tool.SystemVersion +import com.highcapable.betterandroid.ui.extension.view.inflateOrNull +import com.highcapable.betterandroid.ui.extension.view.layoutInflater +import com.highcapable.hikage.core.R +import com.highcapable.yukireflection.factory.classOf +import com.highcapable.yukireflection.factory.lazyClass +import com.highcapable.yukireflection.type.android.AssetManagerClass +import com.highcapable.yukireflection.type.java.BooleanType +import com.highcapable.yukireflection.type.java.IntType +import com.highcapable.yukireflection.type.java.LongType +import com.highcapable.yukireflection.type.java.StringClass +import org.lsposed.hiddenapibypass.HiddenApiBypass +import android.R as Android_R + +/** + * Create a new XmlBlock with system api bypass reflection magic. + */ +internal object XmlBlockBypass { + + /** The path used to load the apk assets represents an APK file. */ + private const val FORMAT_APK = 0 + + /** The path used to load the apk assets represents an idmap file. */ + private const val FORMAT_IDMAP = 1 + + /** The path used to load the apk assets represents an resources.arsc file. */ + private const val FORMAT_ARSC = 2 + + /** The path used to load the apk assets represents a directory. */ + private const val FORMAT_DIR = 3 + + /** + * The apk assets contains framework resource values specified by the system. + * This allows some functions to filter out this package when computing what + * configurations/resources are available. + */ + private const val PROPERTY_SYSTEM = 1 shl 0 + + /** + * The apk assets is a shared library or was loaded as a shared library by force. + * The package ids of dynamic apk assets are assigned at runtime instead of compile time. + */ + private const val PROPERTY_DYNAMIC = 1 shl 1 + + /** + * The apk assets has been loaded dynamically using a [ResourcesProvider]. + * Loader apk assets overlay resources like RROs except they are not backed by an idmap. + */ + private const val PROPERTY_LOADER = 1 shl 2 + + /** + * The apk assets is a RRO. + * An RRO overlays resource values of its target package. + */ + private const val PROPERTY_OVERLAY = 1 shl 3 + + /** + * The apk assets is owned by the application running in this process and incremental crash + * protections for this APK must be disabled. + */ + private const val PROPERTY_DISABLE_INCREMENTAL_HARDENING = 1 shl 4 + + /** + * The apk assets only contain the overlayable declarations information. + */ + private const val PROPERTY_ONLY_OVERLAYABLES = 1 shl 5 + + /** The apk assets class. */ + private val ApkAssetsClass by lazyClass("android.content.res.ApkAssets") + + /** The xml block class. */ + private val XmlBlockClass by lazyClass("android.content.res.XmlBlock") + + /** Global pointer references object. */ + private var xmlBlock: Long? = null + + /** Global pointer references object. */ + private var blockParser: AutoCloseable? = null + + /** Whether the initialization is done once. */ + private var isInitOnce = false + + /** + * Initialize. + * @param context the context. + */ + fun init(context: Context) { + // Context may be loaded from the preview and other non-Android platforms, ignoring this. + if (context.javaClass.name.endsWith("BridgeContext")) return + init(context.applicationContext.applicationInfo) + } + + /** + * Initialize. + * @param info the application info. + */ + private fun init(info: ApplicationInfo) { + if (SystemVersion.isLowOrEqualsTo(SystemVersion.P)) return + if (isInitOnce) return + val sourceDir = info.sourceDir + xmlBlock = when { + SystemVersion.isHighOrEqualsTo(SystemVersion.R) -> + // private static native long nativeLoad(@FormatType int format, @NonNull String path, + // @PropertyFlags int flags, @Nullable AssetsProvider asset) throws IOException; + HiddenApiBypass.getDeclaredMethod( + ApkAssetsClass, "nativeLoad", + IntType, StringClass, IntType, classOf() + ).apply { isAccessible = true }.invoke(null, FORMAT_APK, sourceDir, PROPERTY_SYSTEM, null) + SystemVersion.isHighOrEqualsTo(SystemVersion.P) -> + // private static native long nativeLoad( + // @NonNull String path, boolean system, boolean forceSharedLib, boolean overlay) + // throws IOException; + HiddenApiBypass.getDeclaredMethod( + ApkAssetsClass, "nativeLoad", + StringClass, BooleanType, BooleanType, BooleanType + ).apply { isAccessible = true }.invoke(null, sourceDir, false, false, false) + else -> error("Unsupported Android version.") + } as? Long? ?: error("Failed to create ApkAssets.") + blockParser = HiddenApiBypass.getDeclaredConstructor(XmlBlockClass, AssetManagerClass, LongType) + .apply { isAccessible = true } + .newInstance(null, xmlBlock) as? AutoCloseable? ?: error("Failed to create XmlBlock\$Parser.") + isInitOnce = true + } + + /** + * Create a new parser. + * @param context the context. + * @param resId the style resource id, default is [Android_R.style.Widget]. + * @return [XmlResourceParser] + */ + fun newParser(context: Context, @StyleRes resId: Int = Android_R.style.Widget): XmlResourceParser { + /** + * Create a view [AttributeSet]. + * @return [XmlResourceParser] + */ + fun createViewAttrs() = context.layoutInflater.inflateOrNull(R.layout.layout_hikage_attrs_view)?.attrs + as? XmlResourceParser? ?: error("Failed to create AttributeSet.") + return if (SystemVersion.isHighOrEqualsTo(SystemVersion.P)) { + if (!isInitOnce) return createViewAttrs() + require(blockParser != null) { "Hikage initialization failed." } + HiddenApiBypass.getDeclaredMethod(XmlBlockClass, "newParser", IntType) + .apply { isAccessible = true } + .invoke(blockParser, resId) as? XmlResourceParser? ?: error("Failed to create parser.") + } else createViewAttrs() + } +} \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/Hikage.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/Hikage.kt new file mode 100644 index 0000000..0ce9d4f --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/Hikage.kt @@ -0,0 +1,953 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/25. + */ +@file:Suppress( + "unused", "FunctionName", "PropertyName", "ConstPropertyName", "UNCHECKED_CAST", + "MemberVisibilityCanBePrivate", "TOPLEVEL_TYPEALIASES_ONLY", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE" +) + +package com.highcapable.hikage.core + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.ColorRes +import androidx.annotation.DimenRes +import androidx.annotation.DrawableRes +import androidx.annotation.FontRes +import androidx.annotation.LayoutRes +import androidx.annotation.StringRes +import androidx.core.graphics.drawable.toBitmap +import androidx.viewbinding.ViewBinding +import com.highcapable.betterandroid.ui.extension.binding.ViewBinding +import com.highcapable.betterandroid.ui.extension.component.base.DisplayDensity +import com.highcapable.betterandroid.ui.extension.component.base.getColorCompat +import com.highcapable.betterandroid.ui.extension.component.base.getColorStateListCompat +import com.highcapable.betterandroid.ui.extension.component.base.getDrawableCompat +import com.highcapable.betterandroid.ui.extension.component.base.getFontCompat +import com.highcapable.betterandroid.ui.extension.component.base.toDp +import com.highcapable.betterandroid.ui.extension.component.base.toPx +import com.highcapable.betterandroid.ui.extension.view.LayoutParamsWrapContent +import com.highcapable.betterandroid.ui.extension.view.ViewLayoutParams +import com.highcapable.betterandroid.ui.extension.view.inflate +import com.highcapable.betterandroid.ui.extension.view.layoutInflater +import com.highcapable.hikage.annotation.Hikageable +import com.highcapable.hikage.bypass.XmlBlockBypass +import com.highcapable.hikage.core.Hikage.LayoutParamsBody +import com.highcapable.hikage.core.base.HikageFactory +import com.highcapable.hikage.core.base.HikageFactoryBuilder +import com.highcapable.hikage.core.base.HikagePerformer +import com.highcapable.hikage.core.base.HikageView +import com.highcapable.hikage.core.base.PerformerException +import com.highcapable.hikage.core.base.ProvideException +import com.highcapable.hikage.core.extension.ResourcesScope +import com.highcapable.yukireflection.factory.buildOf +import com.highcapable.yukireflection.factory.classOf +import com.highcapable.yukireflection.factory.constructor +import com.highcapable.yukireflection.factory.current +import com.highcapable.yukireflection.factory.notExtends +import com.highcapable.yukireflection.type.android.AttributeSetClass +import com.highcapable.yukireflection.type.android.ContextClass +import com.highcapable.yukireflection.type.android.ViewGroup_LayoutParamsClass +import com.highcapable.yukireflection.type.java.IntType +import java.io.Serializable +import java.lang.reflect.Constructor +import java.util.concurrent.atomic.AtomicInteger + +/** + * The Hikage core layout builder. + * + * A [Hikage] can have multiple levels of [Hikage.Performer]. + * @param factories the factories to customize the custom view in the initialization. + */ +class Hikage private constructor(private val factories: List) { + + companion object { + + /** The Android widget class prefix. */ + internal const val ANDROID_WIDGET_CLASS_PREFIX = "android.widget." + + /** The unspecified layout params value. */ + private const val LayoutParamsUnspecified = LayoutParamsWrapContent - 1 + + /** The view constructors map. */ + private val viewConstructors = mutableMapOf() + + /** The view atomic id. */ + private val viewAtomicId = AtomicInteger(0x7F00000) + + /** Returns nothing. */ + private fun noGetter(): Nothing = error("No getter available.") + + /** + * Automatically add [HikageFactory] to handle [LayoutInflater.Factory2]. + * + * This [LayoutInflater] will be retrieved from the [Context] you passed in. + * + * This option is enabled by default and will add this feature when creating any [Hikage]. + * It can support the [View] autoboxing feature that supports libraries such as `androidx.appcompat`, + * which can be disabled if you don't need it. + */ + var isAutoProcessWithFactory2 = true + + /** + * Create a new [Hikage]. + * @param context the context to create the layout. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage] + */ + @JvmName("createTyped") + inline fun create( + context: Context, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer + ) = create(classOf(), context, parent, attachToParent, factory, performer) + + /** + * Create a new [Hikage]. + * @param context the context to create the layout. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage] + */ + inline fun create( + context: Context, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer + ) = create(ViewGroup_LayoutParamsClass, context, parent, attachToParent, factory, performer) + + /** + * Create a new [Hikage]. + * @param lpClass the layout params type. + * @param context the context to create the layout. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage] + */ + inline fun create( + lpClass: Class, + context: Context, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer + ) = Hikage(HikageFactoryBuilder.create { + if (isAutoProcessWithFactory2) add(HikageFactory(context.layoutInflater)) + factory() + }.build()).apply { + // If the parent view is specified and mark as attach to parent, + // add it directly to the first position. + if (parent != null && attachToParent) { + val parentId = generateRandomViewId() + provideView(parent, parentId) + }; newPerformer(lpClass, parent, attachToParent, context).apply(performer) + } + + /** + * Create a new [Hikage.Delegate]. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage.Delegate]<[LP]> + */ + @JvmName("buildTyped") + inline fun build( + noinline factory: HikageFactoryBuilder.() -> Unit = {}, + noinline performer: HikagePerformer + ) = build(classOf(), factory, performer) + + /** + * Create a new [Hikage.Delegate]. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage.Delegate]<[ViewGroup.LayoutParams]> + */ + fun build( + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer + ) = build(ViewGroup_LayoutParamsClass, factory, performer) + + /** + * Create a new [Hikage.Delegate]. + * @param lpClass the layout params type. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage.Delegate]<[LP]> + */ + fun build( + lpClass: Class, + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer + ) = Delegate(lpClass, factory, performer) + } + + /** The [Hikage] layout params body type. */ + private typealias LayoutParamsBody = LP.() -> Unit + + /** + * The [Hikage.Performer] scope interface. + */ + private interface PerformerScope : DisplayDensity, ResourcesScope { + + /** + * Get the actual view id by [id]. + * @param id the view id. + * @return [Int] or -1. + */ + fun actualViewId(id: String): Int + } + + /** + * The view constructor class. + * @param instance the constructor instance. + * @param parameterCount the parameter count. + */ + private inner class ViewConstructor( + private val instance: Constructor<*>, + private val parameterCount: Int + ) { + + /** + * Build the view. + * @param context the context. + * @param attrs the attribute set. + * @return [V] or null. + */ + fun build(context: Context, attrs: AttributeSet) = when (parameterCount) { + 2 -> instance.newInstance(context, attrs) + 1 -> instance.newInstance(context) + else -> null + } as? V? + } + + /** The performer set. */ + private val performers = linkedSetOf>() + + /** The view map. */ + private val views = linkedMapOf() + + /** The view id map. */ + private val viewIds = mutableMapOf() + + /** + * Get the root view. + * @return [View] + */ + val root get() = views.values.firstOrNull() + ?: throw PerformerException("No root view found, are you sure you have provided any view?") + + /** + * Get the root view [V]. + * @return [V] + */ + inline fun root() = root as? V? + ?: throw PerformerException("Root view is not a type of ${classOf().name}.") + + /** + * Get the view by [id]. + * @param id the view id. + * @return [View] + */ + operator fun get(id: String) = views[id] + ?: throw PerformerException("View with id \"$id\" not found.") + + /** + * Get the view by [id]. + * @param id the view id. + * @return [View] or null. + */ + fun getOrNull(id: String) = views[id] + + /** + * Get the view by [id] via [V]. + * @param id the view id. + * @return [V] + */ + @JvmName("getTyped") + inline fun get(id: String) = get(id) as? V + ?: throw PerformerException("View with id \"$id\" is not a ${classOf().name}.") + + /** + * Get the view by [id] via [V]. + * @param id the view id. + * @return [V] or null. + */ + @JvmName("getOrNullTyped") + inline fun getOrNull(id: String) = getOrNull(id) as? V? + + /** + * Get the actual view id by [id]. + * @param id the view id. + * @return [Int] or -1. + */ + fun getActualViewId(id: String) = viewIds[id] ?: -1 + + /** + * Create a new [View] via [V]. + * @param viewClass the view class. + * @param id the view id, generated by default. + * @param context the context. + * @return [V] + */ + private fun createView(viewClass: Class, id: String?, context: Context): V { + val attrs = createAttributeSet(context) + val view = createViewFromFactory(viewClass, id, context, attrs) ?: getViewConstructor(viewClass)?.build(context, attrs) + if (view == null) throw PerformerException( + "Create view of type ${viewClass.name} failed. " + + "Please make sure the view class has a constructor with a single parameter of type Context." + ) + provideView(view, id) + return view + } + + /** + * Get the view constructor. + * @param viewClass the view class. + * @return [ViewConstructor] or null. + */ + private fun getViewConstructor(viewClass: Class) = + viewConstructors[viewClass.name] ?: run { + var parameterCount = 0 + val twoParams = viewClass.constructor { + param(ContextClass, AttributeSetClass) + }.ignored().give() + val onceParam = viewClass.constructor { + param(ContextClass) + }.ignored().give() + val constructor = onceParam?.apply { parameterCount = 1 } + ?: twoParams?.apply { parameterCount = 2 } + val viewConstructor = constructor?.let { ViewConstructor(it, parameterCount) } + if (viewConstructor != null) viewConstructors[viewClass.name] = viewConstructor + viewConstructor + } + + /** + * Create a new [View] from [HikageFactory]. + * @param viewClass the view class. + * @param id the view id. + * @param context the context. + * @param attrs the attribute set. + * @return [V] or null. + */ + private fun createViewFromFactory(viewClass: Class, id: String?, context: Context, attrs: AttributeSet): V? { + val parent = performers.firstOrNull()?.parent + var processed: V? = null + factories.forEach { factory -> + val params = PerformerParams(id, attrs, viewClass as Class) + val view = factory(parent, processed, context, params) + if (view != null && view.javaClass notExtends viewClass) throw PerformerException( + "HikageFactory cannot cast the created view type \"${view.javaClass}\" to \"${viewClass.name}\", " + + "please confirm that the view type you created is correct." + ) + if (view != null) processed = view as? V? + }; return processed + } + + /** + * Provide an exists [View]. + * @param view the view instance. + * @param id the view id. + * @return [String] + */ + private fun provideView(view: View, id: String?): String { + val (requireId, viewId) = generateViewId(id) + view.id = viewId + views[requireId] = view + return requireId + } + + /** + * Generate view id from [id]. + * @param id the view id. + * @return [Pair]<[String], [Int]> + */ + private fun generateViewId(id: String?): Pair { + /** + * Generate a new view id. + * @param id the view id. + * @return [Int] + */ + fun doGenerate(id: String): Int { + val generateId = View.generateViewId() + if (viewIds.contains(id)) throw PerformerException("View with id \"$id\" already exists.") + viewIds[id] = generateId + return generateId + } + val requireId = id ?: generateRandomViewId() + val viewId = doGenerate(requireId) + return requireId to viewId + } + + /** + * Generate random view id. + * @return [String] + */ + private fun generateRandomViewId() = "anonymous@${viewAtomicId.getAndIncrement().toHexString()}" + + /** + * We just need a [AttributeSet] instance. + * @param context the context. + * @return [AttributeSet] + */ + private fun createAttributeSet(context: Context): AttributeSet = XmlBlockBypass.newParser(context) + + /** + * Start a new performer [LP]. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param context the context, priority is given to [parent]'s context. + * @return [Performer] + */ + private inline fun newPerformer( + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + context: Context? = null + ) = newPerformer(classOf(), parent, attachToParent, context) + + /** + * Start a new performer [LP]. + * @param lpClass the layout params type. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param context the context, priority is given to [parent]'s context. + * @return [Performer] + */ + private fun newPerformer( + lpClass: Class, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + context: Context? = null + ) = Performer(lpClass, parent, attachToParent, context).apply { + // Init [XmlBlockBypass] if the context is not null. + context?.let { XmlBlockBypass.init(it) } + performers.add(this) + } + + /** + * Require no [Performer]. + * @param name the process name. + * @param block the block. + */ + internal inline fun requireNoPerformers(name: String, block: () -> Unit) { + val viewCount = views.size + block() + if (views.size != viewCount) throw PerformerException( + "Performers are not allowed to appear in $name DSL creation process." + ) + } + + /** + * Include a delegate. + * @param delegate the delegate. + * @param context the context. + * @param embedded the embedded flag. + * @return [Hikage] + */ + private fun include(delegate: Delegate<*>, context: Context, embedded: Boolean): Hikage { + val hikage = delegate.create(context) + if (!embedded) return hikage + val duplicateId = hikage.viewIds.toList().firstOrNull { (k, _) -> viewIds.containsKey(k) }?.first + if (duplicateId != null) throw PerformerException( + "Embedded layout view IDs conflict, the view id \"$duplicateId\" is already exists." + ) + viewIds.putAll(hikage.viewIds) + views.putAll(hikage.views) + performers.addAll(hikage.performers) + return hikage + } + + /** + * The core performer entity of layout build [LP]. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent. + * @param lpClass the layout params type. + * @param baseContext the context to create the layout, priority is given to [parent]'s context. + * if [parent] is null, it must be set manually. + */ + inner class Performer internal constructor( + private val lpClass: Class, + internal val parent: ViewGroup?, + private val attachToParent: Boolean, + private val baseContext: Context? = null + ) : PerformerScope { + + /** The current [Hikage]. */ + private val current get() = this@Hikage + + /** + * The context to create the layout. + * @return [Context] + */ + private val context get() = parent?.context + ?: baseContext + ?: throw PerformerException("Parent layout is null or broken, Hikage.Performer need a Context to create the layout.") + + override fun actualViewId(id: String) = getActualViewId(id) + + override fun stringResource(@StringRes resId: Int, vararg formatArgs: Any) = + if (formatArgs.isNotEmpty()) + context.getString(resId, *formatArgs) + else context.getString(resId) + override fun colorResource(@ColorRes resId: Int) = context.getColorCompat(resId) + override fun stateColorResource(@ColorRes resId: Int) = context.getColorStateListCompat(resId) + override fun drawableResource(@DrawableRes resId: Int) = context.getDrawableCompat(resId) + override fun bitmapResource(@DrawableRes resId: Int) = context.getDrawableCompat(resId).toBitmap() + override fun dimenResource(@DimenRes resId: Int) = context.resources.getDimension(resId) + override fun fontResource(@FontRes resId: Int) = context.getFontCompat(resId) + + override fun N.toPx() = toPx(context) + override fun N.toDp() = toDp(context) + + /** The count of providing views. */ + private var provideCount = 0 + + /** + * Provide a new [View] instance [V]. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @param init the view initialization body. + * @return [V] + */ + @Hikageable + @JvmName("ViewTyped") + inline fun View( + lparams: LayoutParams? = null, + id: String? = null, + init: HikageView = {} + ): V { + val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams) + val view = createView(classOf(), id, context) + view.layoutParams = lpDelegate.create() + requireNoPerformers(classOf().name) { view.init() } + startProvide(id) + addToParentIfRequired(view) + return view + } + + /** + * Provide a new [View] instance. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @param init the view initialization body. + * @return [View] + */ + @Hikageable + inline fun View( + lparams: LayoutParams? = null, + id: String? = null, + init: HikageView = {} + ) = View(lparams, id, init) + + /** + * Provide a new [ViewGroup] instance [VG]. + * + * Provide the new type of [ViewGroup.LayoutParams] down via [LP]. + * + * - Note: The [VG] must be inherited from [ViewGroup]. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @param init the view initialization body. + * @param performer the performer body. + * @return [VG] + */ + @Hikageable + @JvmName("ViewGroupLP") + inline fun ViewGroup( + lparams: LayoutParams? = null, + id: String? = null, + init: HikageView = {}, + performer: HikagePerformer = {} + ): VG { + val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams) + val view = createView(classOf(), id, context) + view.layoutParams = lpDelegate.create() + requireNoPerformers(classOf().name) { view.init() } + startProvide(id) + addToParentIfRequired(view) + newPerformer(view).apply(performer) + return view + } + + /** + * Provide a new [ViewGroup] instance [VG]. + * + * - Note: The [VG] must be inherited from [ViewGroup]. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @param init the view initialization body. + * @param performer the performer body. + * @return [VG] + */ + @Hikageable + inline fun ViewGroup( + lparams: LayoutParams? = null, + id: String? = null, + init: HikageView = {}, + performer: HikagePerformer = {} + ) = ViewGroup(lparams, id, init, performer) + + /** + * Provide layout from [resId]. + * @param resId the layout resource id. + * @param lparams the view layout params. + * @param id the view id, generated by default. + */ + @Hikageable + fun Layout( + @LayoutRes resId: Int, + lparams: LayoutParams? = null, + id: String? = null + ): View { + val view = context.layoutInflater.inflate(resId, parent, attachToRoot = false) + startProvide(id, view) + lparams?.create()?.let { view.layoutParams = it } + provideView(view, id) + addToParentIfRequired(view) + return view + } + + /** + * Provide layout from [ViewBinding]. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @return [VB] + */ + @Hikageable + inline fun Layout( + lparams: LayoutParams? = null, + id: String? = null + ): VB { + val viewBinding = ViewBinding().inflate(context.layoutInflater, parent, attachToParent = false) + val view = viewBinding.root + startProvide(id, view) + if (view.parent != null) throw ProvideException( + "The ViewBinding($view) already has a parent, " + + "it may have been created using layout root node or , cannot be provided." + ) + lparams?.create()?.let { view.layoutParams = it } + provideView(view, id) + addToParentIfRequired(view) + return viewBinding + } + + /** + * Provide layout from exists [View]. + * @param view the view instance. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @return [View] + */ + @Hikageable + fun Layout( + view: View, + lparams: LayoutParams? = null, + id: String? = null + ): View { + if (view.parent != null) throw ProvideException("The view $view already has a parent, cannot be provided.") + startProvide(id, view) + val lpDelegate = LayoutParams.from(current = this@Hikage, lpClass, parent, lparams, view.layoutParams) + view.layoutParams = lpDelegate.create() + provideView(view, id) + addToParentIfRequired(view) + return view + } + + /** + * Provide layout from another [Hikage]. + * + * - Note: [Hikage] view IDs will not copied to this layout + * when provides a complete [Hikage] instead of [Delegate]. + * + * ```kotlin + * val first: Hikage = Hikageable(context) { + * TextView(id = "textView") + * } + * val second: Hikage = Hikageable(context) { + * TextView(id = "textView") + * // The view ID "textView" will not copied to this layout, + * // so there will be no problem of ID overlap. + * Layout(first) + * } + * ``` + * @param hikage the hikage instance. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @return [Hikage] + */ + @Hikageable + fun Layout( + hikage: Hikage, + lparams: LayoutParams? = null, + id: String? = null + ): Hikage { + val view = hikage.root + startProvide(id, view) + val lpDelegate = LayoutParams.from(current = this@Hikage, lpClass, parent, lparams, view.layoutParams) + if (view.parent != null) throw ProvideException( + "The Hikage layout root view $view already has a parent, cannot be provided." + ) + view.layoutParams = lpDelegate.create() + provideView(view, id) + addToParentIfRequired(view) + return hikage + } + + /** + * Provide layout from another [Delegate]. + * + * - Note: If you use [embedded], you must make sure that the introduced view IDs + * do not overlap with the view IDs in the current layout. + * @param delegate the delegate instance. + * @param lparams the view layout params. + * @param id the view id, generated by default. + * @param embedded whether to embed this layout (All view IDs and performers will be copied), + * default is true. + * @return [Hikage] + */ + @Hikageable + fun Layout( + delegate: Delegate<*>, + lparams: LayoutParams? = null, + id: String? = null, + embedded: Boolean = true + ): Hikage { + val hikage = include(delegate, context, embedded) + return Layout(hikage, lparams, id) + } + + /** + * Create a new layout params. + * + * Usage: + * + * ```kotlin + * View( + * lparams = LayoutParams { + * // You code here. + * } + * ) + * ``` + * @see ViewLayoutParams + * @param body the layout params body. + * @return [LayoutParams] + */ + fun LayoutParams( + width: Int = LayoutParamsUnspecified, + height: Int = LayoutParamsUnspecified, + matchParent: Boolean = false, + widthMatchParent: Boolean = false, + heightMatchParent: Boolean = false, + body: LayoutParamsBody = {} + ) = LayoutParams.from( + current, lpClass, parent, + width, height, matchParent, widthMatchParent, heightMatchParent, + body = body + ) + + /** If required, add the [view] to the [parent]. */ + private fun addToParentIfRequired(view: View) { + if (attachToParent) parent?.addView(view) + } + + /** + * Call to start providing a new view. + * @param id the view id. + * @param view the view instance. + */ + private inline fun startProvide(id: String?, view: V? = null) { + provideCount++ + if (provideCount > 1 && (parent == null || !attachToParent)) throw ProvideException( + "Provide view ${view?.javaClass ?: classOf()}(${id?.let { "\"$it\""} ?: ""}) failed. ${ + if (parent == null) "No parent view group found" + else "Parent view group declares attachToParent = false" + }, you can only provide one view for the root view." + ) + } + } + + /** + * The parameters of the [Performer]. + * @param id the view ID. + * @param attrs the attributes set. + * @param viewClass the view class. + */ + data class PerformerParams internal constructor( + val id: String?, + val attrs: AttributeSet, + val viewClass: Class + ) : Serializable + + /** + * The [Hikage] layout params. + * @see ViewLayoutParams + * @param current the current [Hikage]. + * @param lpClass the layout params type. + * @param parent the parent view group. + */ + class LayoutParams private constructor( + private val current: Hikage, + private val lpClass: Class, + private val parent: ViewGroup? + ) { + + /** + * Builder params of body. + */ + private class BodyBuilder( + val width: Int, + val height: Int, + val matchParent: Boolean, + val widthMatchParent: Boolean, + val heightMatchParent: Boolean, + val body: LayoutParamsBody + ) + + /** + * Builder params of wrapper. + */ + private class WrapperBuilder( + val delegate: LayoutParams?, + val lparams: ViewGroup.LayoutParams? + ) + + /** The layout params body. */ + private var bodyBuilder: BodyBuilder? = null + + /** The layout params wrapper. */ + private var wrapperBuilder: WrapperBuilder? = null + + internal companion object { + + /** + * Create a new [LayoutParams] + * @see ViewLayoutParams + * @param current the current [Hikage]. + * @param parent the parent view group. + * @return [LayoutParams] + */ + fun from( + current: Hikage, + lpClass: Class, + parent: ViewGroup?, + width: Int, + height: Int, + matchParent: Boolean, + widthMatchParent: Boolean, + heightMatchParent: Boolean, + body: LayoutParamsBody + ) = LayoutParams(current, lpClass as Class, parent).apply { + bodyBuilder = BodyBuilder( + width, height, matchParent, widthMatchParent, heightMatchParent, + body as LayoutParamsBody + ) + } + + /** + * Create a new [LayoutParams]. + * @param current the current [Hikage]. + * @param parent the parent view group. + * @param delegate the delegate. + * @param lparams the another layout params. + * @return [LayoutParams] + */ + fun from( + current: Hikage, + lpClass: Class, + parent: ViewGroup?, + delegate: LayoutParams?, + lparams: ViewGroup.LayoutParams? = null + ) = LayoutParams(current, lpClass as Class, parent).apply { + wrapperBuilder = WrapperBuilder(delegate, lparams) + } + } + + /** + * Create a default layout params. + * @return [ViewGroup.LayoutParams] + */ + private fun createDefaultLayoutParams(lparams: ViewGroup.LayoutParams? = null): ViewGroup.LayoutParams { + val wrapped = lparams?.let { + parent?.current(ignored = true)?.method { + name = "generateLayoutParams" + param(ViewGroup_LayoutParamsClass) + superClass() + }?.invoke(it) + } ?: lparams + return wrapped + // Build a default. + ?: lpClass.buildOf(LayoutParamsWrapContent, LayoutParamsWrapContent) { + param(IntType, IntType) + } ?: throw PerformerException("Create default layout params failed.") + } + + /** + * Create the layout params. + * @return [ViewGroup.LayoutParams] + */ + fun create(): ViewGroup.LayoutParams { + if (bodyBuilder == null && wrapperBuilder == null) throw PerformerException("No layout params builder found.") + return bodyBuilder?.let { + val lparams = ViewLayoutParams(lpClass, it.width, it.height, it.matchParent, it.widthMatchParent, it.heightMatchParent) + current.requireNoPerformers(lparams.javaClass.name) { it.body(lparams) } + lparams + } ?: wrapperBuilder?.let { + val lparams = it.delegate?.create() ?: it.lparams + createDefaultLayoutParams(lparams) + } ?: throw PerformerException("Internal error of build layout params.") + } + } + + /** + * The delegate for [Hikage]. + * @param lpClass the layout params type. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + */ + class Delegate internal constructor( + private val lpClass: Class, + private val factory: HikageFactoryBuilder.() -> Unit = {}, + private val performer: HikagePerformer + ) { + + /** + * Create a new [Hikage]. + * @param context the context to create the layout. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @return [Hikage] + */ + + fun create(context: Context, parent: ViewGroup? = null, attachToParent: Boolean = parent != null) = + create(lpClass, context, parent, attachToParent, factory, performer) + } +} \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/base/Exceptions.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/base/Exceptions.kt new file mode 100644 index 0000000..f45290c --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/base/Exceptions.kt @@ -0,0 +1,36 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/26. + */ +@file:JvmName("ExceptionsUtils") + +package com.highcapable.hikage.core.base + +/** + * The exception of performing view. + * @param message the exception message. + */ +internal class PerformerException(message: String) : Exception(message) + +/** + * The exception of providing view. + * @param message the exception message. + */ +internal class ProvideException(message: String) : Exception(message) \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/base/HikageFactory.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/base/HikageFactory.kt new file mode 100644 index 0000000..48464f6 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/base/HikageFactory.kt @@ -0,0 +1,106 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/4. + */ +@file:Suppress("unused", "FunctionName") +@file:JvmName("HikageFactory") + +package com.highcapable.hikage.core.base + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.highcapable.hikage.core.Hikage + +/** + * The [Hikage] factory type. + * + * - `parent` the parent view group. + * - `base` the base view (from previous [HikageFactory] processed, if not will null). + * - `context` the view context. + * - `params` the parameters. + */ +typealias HikageFactory = (parent: ViewGroup?, base: View?, context: Context, params: Hikage.PerformerParams) -> View? + +/** + * Create a [Hikage] factory. + * @param createView the view creator. + * @return [HikageFactory] + */ +@JvmSynthetic +fun HikageFactory(createView: HikageFactory) = createView + +/** + * Create a [Hikage] factory from [LayoutInflater]. + * + * This will proxy the function of [LayoutInflater.Factory2] to [Hikage]. + * @param inflater the layout inflater. + * @return [HikageFactory] + */ +@JvmSynthetic +fun HikageFactory(inflater: LayoutInflater) = HikageFactory { parent, base, context, params -> + base ?: inflater.factory2?.onCreateView(parent, params.viewClass.name.let { + if (it.startsWith(Hikage.ANDROID_WIDGET_CLASS_PREFIX)) + it.replace(Hikage.ANDROID_WIDGET_CLASS_PREFIX, "") + else it + }, context, params.attrs) +} + +/** + * The [HikageFactory] builder. + */ +class HikageFactoryBuilder private constructor() { + + internal companion object { + + /** + * Create a [HikageFactoryBuilder]. + * @param builder the builder. + * @return [HikageFactoryBuilder] + */ + inline fun create(builder: HikageFactoryBuilder.() -> Unit) = HikageFactoryBuilder().apply(builder) + } + + /** Caches factories. */ + private val factories = mutableListOf() + + /** + * Add a factory. + * @param factory the factory. + */ + fun add(factory: HikageFactory) { + factories.add(factory) + } + + /** + * Add factories. + * @param factories the factories. + */ + fun addAll(factories: List) { + this.factories.addAll(factories) + } + + /** + * Build the factory. + * @return <[List]>[HikageFactory] + */ + internal fun build() = factories.toList() +} \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/base/Hikageable.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/base/Hikageable.kt new file mode 100644 index 0000000..bc57b67 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/base/Hikageable.kt @@ -0,0 +1,101 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/25. + */ +@file:Suppress("unused", "FunctionName", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") +@file:JvmName("HikageableUtils") + +package com.highcapable.hikage.core.base + +import android.content.Context +import android.view.ViewGroup +import com.highcapable.hikage.core.Hikage + +/** + * The [Hikage.Performer] type. + */ +typealias HikagePerformer = Hikage.Performer.() -> Unit + +/** + * The [Hikage] view scope type. + */ +typealias HikageView = V.() -> Unit + +/** + * Start performing a [Hikage] layout [LP]. + * @param context the context to create the layout. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage] + */ +@JvmSynthetic +@JvmName("HikageableTyped") +inline fun Hikageable( + context: Context, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer +) = Hikage.create(context, parent, attachToParent, factory, performer) + +/** + * Start performing a [Hikage] layout. + * @param context the context to create the layout. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage] + */ +@JvmSynthetic +inline fun Hikageable( + context: Context, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null, + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer +) = Hikage.create(context, parent, attachToParent, factory, performer) + +/** + * Start performing a [Hikage] layout [LP]. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage.Delegate]<[LP]> + */ +@JvmSynthetic +@JvmName("HikageableTyped") +inline fun Hikageable( + noinline factory: HikageFactoryBuilder.() -> Unit = {}, + noinline performer: HikagePerformer +) = Hikage.build(factory, performer) + +/** + * Start performing a [Hikage] layout. + * @param factory the [HikageFactory] builder. + * @param performer the performer body. + * @return [Hikage.Delegate]<[ViewGroup.LayoutParams]> + */ +@JvmSynthetic +fun Hikageable( + factory: HikageFactoryBuilder.() -> Unit = {}, + performer: HikagePerformer +) = Hikage.build(factory, performer) \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/builder/HikageBuilder.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/builder/HikageBuilder.kt new file mode 100644 index 0000000..e74eb40 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/builder/HikageBuilder.kt @@ -0,0 +1,106 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/6. + */ +@file:Suppress("unused") +@file:JvmName("HikageBuilderUtils") + +package com.highcapable.hikage.core.builder + +import android.content.Context +import android.view.ViewGroup +import com.highcapable.hikage.core.Hikage + +/** + * Lazy initialize a [Hikage] layout. + * + * Usage: + * + * ```kotlin + * object MainLayout : HikageBuilder { + * + * override fun build() = Hikageable { + * LinearLayout( + * lparams = LayoutParams(matchParent = true), + * init = { + * orientation = LinearLayout.VERTICAL + * gravity = Gravity.CENTER + * } + * ) { + * TextView { + * text = "Hello, Hikage!" + * textSize = 20f + * } + * } + * } + * } + * + * class MainActivity : AppCompatActivity() { + * + * private val hikage by lazyHikage(MainLayout) + * + * override fun onCreate(savedInstanceState: Bundle?) { + * super.onCreate(savedInstanceState) + * setContentView(hikage) + * } + * } + * ``` + * @receiver the context to create the layout. + * @param builder the [HikageBuilder] instance. + * @param parent the parent view group. + * @param attachToParent whether to attach the layout to the parent when the [parent] is filled. + * @return [Lazy]<[Hikage]> + */ +@JvmSynthetic +fun Context.lazyHikage( + builder: HikageBuilder, + parent: ViewGroup? = null, + attachToParent: Boolean = parent != null +) = lazy { builder.build().create(context = this, parent, attachToParent) } + +/** + * A layout builder interface for [Hikage]. + * + * Checking [build] for usage. + */ +interface HikageBuilder { + + /** + * Provide a [Hikage] for builder. + * + * Usage: + * + * ```kotlin + * override fun build() = Hikageable { + * TextView( + * lparams = LayoutParams( + * width = 100.dp, + * height = 100.dp + * ) + * ) { + * text = "Hello, Hikage!" + * textSize = 20f + * } + * } + * ``` + * @return [Hikage.Delegate] + */ + fun build(): Hikage.Delegate<*> +} \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/extension/ResourcesScope.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/extension/ResourcesScope.kt new file mode 100644 index 0000000..f840546 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/extension/ResourcesScope.kt @@ -0,0 +1,89 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/12. + */ +package com.highcapable.hikage.core.extension + +import android.content.res.ColorStateList +import android.graphics.Bitmap +import android.graphics.Typeface +import android.graphics.drawable.Drawable +import androidx.annotation.ColorRes +import androidx.annotation.DimenRes +import androidx.annotation.DrawableRes +import androidx.annotation.FontRes +import androidx.annotation.StringRes +import com.highcapable.hikage.core.Hikage + +/** + * An extension for [Hikage] view scope to provide resources. + */ +interface ResourcesScope { + + /** + * Get the string from [resId]. + * @param resId the resource id. + * @param formatArgs the format arguments. + * @return [String] + */ + fun stringResource(@StringRes resId: Int, vararg formatArgs: Any): String + + /** + * Get the color from [resId]. + * @param resId the resource id. + * @return [Int] + */ + fun colorResource(@ColorRes resId: Int): Int + + /** + * Get the [ColorStateList] from [resId]. + * @param resId the resource id. + * @return [Int] + */ + fun stateColorResource(@ColorRes resId: Int): ColorStateList + + /** + * Get the [Drawable] from [resId]. + * @param resId the resource id. + * @return [Drawable] + */ + fun drawableResource(@DrawableRes resId: Int): Drawable + + /** + * Get the [Bitmap] from [resId]. + * @param resId the resource id. + * @return [Bitmap] + */ + fun bitmapResource(@DrawableRes resId: Int): Bitmap + + /** + * Get the dimension from [resId]. + * @param resId the resource id. + * @return [Float] + */ + fun dimenResource(@DimenRes resId: Int): Float + + /** + * Get the font from [resId]. + * @param resId the resource id. + * @return [Typeface] or null. + */ + fun fontResource(@FontRes resId: Int): Typeface? +} \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/core/preview/HikagePreview.kt b/hikage-core/src/main/java/com/highcapable/hikage/core/preview/HikagePreview.kt new file mode 100644 index 0000000..9a89bd1 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/core/preview/HikagePreview.kt @@ -0,0 +1,53 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/27. + */ +@file:Suppress("unused", "FunctionName") + +package com.highcapable.hikage.core.preview + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.widget.FrameLayout +import androidx.annotation.CallSuper +import com.highcapable.hikage.core.Hikage +import com.highcapable.hikage.core.builder.HikageBuilder + +/** + * A preview layout for [Hikage]. + * + * - Note: This class should only be used in the layout preview mode by [View.isInEditMode]. + */ +abstract class HikagePreview(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs), HikageBuilder { + + init { + require(isInEditMode) { + "HikagePreview should only be used in the layout preview mode." + } + } + + @CallSuper + override fun onAttachedToWindow() { + super.onAttachedToWindow() + removeAllViews() + build().create(context, parent = this) + } +} \ No newline at end of file diff --git a/hikage-core/src/main/java/com/highcapable/hikage/widget/android/Widgets.kt b/hikage-core/src/main/java/com/highcapable/hikage/widget/android/Widgets.kt new file mode 100644 index 0000000..0a40dc7 --- /dev/null +++ b/hikage-core/src/main/java/com/highcapable/hikage/widget/android/Widgets.kt @@ -0,0 +1,216 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/26. + */ +@file:Suppress("unused", "DEPRECATION") +@file:JvmName("WidgetsDeclaration") + +package com.highcapable.hikage.widget.android + +import android.widget.AbsListView +import android.widget.ActionMenuView +import android.widget.AutoCompleteTextView +import android.widget.Button +import android.widget.CalendarView +import android.widget.CheckBox +import android.widget.CheckedTextView +import android.widget.Chronometer +import android.widget.DatePicker +import android.widget.EditText +import android.widget.ExpandableListView +import android.widget.FrameLayout +import android.widget.GridLayout +import android.widget.GridView +import android.widget.HorizontalScrollView +import android.widget.ImageButton +import android.widget.ImageSwitcher +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.ListView +import android.widget.MediaController +import android.widget.NumberPicker +import android.widget.ProgressBar +import android.widget.QuickContactBadge +import android.widget.RadioButton +import android.widget.RadioGroup +import android.widget.RatingBar +import android.widget.RelativeLayout +import android.widget.ScrollView +import android.widget.SearchView +import android.widget.SeekBar +import android.widget.Space +import android.widget.Spinner +import android.widget.Switch +import android.widget.TabHost +import android.widget.TabWidget +import android.widget.TableLayout +import android.widget.TableRow +import android.widget.TextClock +import android.widget.TextSwitcher +import android.widget.TextView +import android.widget.TimePicker +import android.widget.ToggleButton +import android.widget.Toolbar +import android.widget.VideoView +import android.widget.ViewAnimator +import android.widget.ViewFlipper +import android.widget.ViewSwitcher +import com.highcapable.hikage.annotation.HikageViewDeclaration + +@HikageViewDeclaration(SeekBar::class) +private object SeekBarDeclaration + +@HikageViewDeclaration(LinearLayout::class, LinearLayout.LayoutParams::class) +private object LinearLayoutDeclaration + +@HikageViewDeclaration(RelativeLayout::class, RelativeLayout.LayoutParams::class) +private object RelativeLayoutDeclaration + +@HikageViewDeclaration(FrameLayout::class, FrameLayout.LayoutParams::class) +private object FrameLayoutDeclaration + +@HikageViewDeclaration(ScrollView::class, FrameLayout.LayoutParams::class) +private object ScrollViewDeclaration + +@HikageViewDeclaration(ProgressBar::class) +private object ProgressBarDeclaration + +@HikageViewDeclaration(Chronometer::class) +private object ChronometerDeclaration + +@HikageViewDeclaration(Space::class) +private object SpaceDeclaration + +@HikageViewDeclaration(CheckedTextView::class) +private object CheckedTextViewDeclaration + +@HikageViewDeclaration(ExpandableListView::class, AbsListView.LayoutParams::class) +private object ExpandableListViewDeclaration + +@HikageViewDeclaration(Spinner::class) +private object SpinnerDeclaration + +@HikageViewDeclaration(RadioGroup::class, RadioGroup.LayoutParams::class) +private object RadioGroupDeclaration + +@HikageViewDeclaration(RadioButton::class) +private object RadioButtonDeclaration + +@HikageViewDeclaration(ToggleButton::class) +private object ToggleButtonDeclaration + +@HikageViewDeclaration(CheckBox::class) +private object CheckBoxDeclaration + +@HikageViewDeclaration(EditText::class) +private object EditTextDeclaration + +@HikageViewDeclaration(AutoCompleteTextView::class) +private object AutoCompleteTextViewDeclaration + +@HikageViewDeclaration(Button::class) +private object ButtonDeclaration + +@HikageViewDeclaration(ImageButton::class) +private object ImageButtonDeclaration + +@HikageViewDeclaration(TextView::class) +private object TextViewDeclaration + +@HikageViewDeclaration(TextClock::class) +private object TextClockDeclaration + +@HikageViewDeclaration(TextSwitcher::class, FrameLayout.LayoutParams::class) +private object TextSwitcherDeclaration + +@HikageViewDeclaration(ActionMenuView::class, ActionMenuView.LayoutParams::class) +private object ActionMenuViewDeclaration + +@HikageViewDeclaration(CalendarView::class, FrameLayout.LayoutParams::class) +private object CalendarViewDeclaration + +@HikageViewDeclaration(DatePicker::class, FrameLayout.LayoutParams::class) +private object DatePickerDeclaration + +@HikageViewDeclaration(TimePicker::class, FrameLayout.LayoutParams::class) +private object TimePickerDeclaration + +@HikageViewDeclaration(RatingBar::class) +private object RatingBarDeclaration + +@HikageViewDeclaration(HorizontalScrollView::class, FrameLayout.LayoutParams::class) +private object HorizontalScrollViewDeclaration + +@HikageViewDeclaration(QuickContactBadge::class) +private object QuickContactBadgeDeclaration + +@HikageViewDeclaration(ImageSwitcher::class, FrameLayout.LayoutParams::class) +private object ImageSwitcherDeclaration + +@HikageViewDeclaration(ViewSwitcher::class, FrameLayout.LayoutParams::class) +private object ViewSwitcherDeclaration + +@HikageViewDeclaration(ViewFlipper::class, FrameLayout.LayoutParams::class) +private object ViewFlipperDeclaration + +@HikageViewDeclaration(ViewAnimator::class, FrameLayout.LayoutParams::class) +private object ViewAnimatorDeclaration + +@HikageViewDeclaration(VideoView::class) +private object VideoViewDeclaration + +@HikageViewDeclaration(Toolbar::class, Toolbar.LayoutParams::class) +private object ToolbarDeclaration + +@HikageViewDeclaration(GridLayout::class, GridLayout.LayoutParams::class) +private object GridLayoutDeclaration + +@HikageViewDeclaration(GridView::class, AbsListView.LayoutParams::class) +private object GridViewDeclaration + +@HikageViewDeclaration(ListView::class, AbsListView.LayoutParams::class) +private object ListViewDeclaration + +@HikageViewDeclaration(ImageView::class) +private object ImageViewDeclaration + +@HikageViewDeclaration(MediaController::class, FrameLayout.LayoutParams::class) +private object MediaControllerDeclaration + +@HikageViewDeclaration(TableLayout::class, TableLayout.LayoutParams::class) +private object TableLayoutDeclaration + +@HikageViewDeclaration(TableRow::class, TableRow.LayoutParams::class) +private object TableRowDeclaration + +@HikageViewDeclaration(NumberPicker::class, LinearLayout.LayoutParams::class) +private object NumberPickerDeclaration + +@HikageViewDeclaration(SearchView::class, FrameLayout.LayoutParams::class) +private object SearchViewDeclaration + +@HikageViewDeclaration(Switch::class) +private object SwitchDeclaration + +@HikageViewDeclaration(TabHost::class, FrameLayout.LayoutParams::class) +private object TabHostDeclaration + +@HikageViewDeclaration(TabWidget::class, LinearLayout.LayoutParams::class) +private object TabWidgetDeclaration \ No newline at end of file diff --git a/hikage-core/src/main/res/layout/layout_hikage_attrs_view.xml b/hikage-core/src/main/res/layout/layout_hikage_attrs_view.xml new file mode 100644 index 0000000..75a1b66 --- /dev/null +++ b/hikage-core/src/main/res/layout/layout_hikage_attrs_view.xml @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/hikage-core/src/test/java/com/highcapable/hikage/ExampleUnitTest.kt b/hikage-core/src/test/java/com/highcapable/hikage/ExampleUnitTest.kt new file mode 100644 index 0000000..b55f02e --- /dev/null +++ b/hikage-core/src/test/java/com/highcapable/hikage/ExampleUnitTest.kt @@ -0,0 +1,18 @@ +package com.highcapable.hikage + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/app/build.gradle.kts b/hikage-extension-betterandroid/build.gradle.kts similarity index 70% rename from app/build.gradle.kts rename to hikage-extension-betterandroid/build.gradle.kts index d13afb5..4023487 100644 --- a/app/build.gradle.kts +++ b/hikage-extension-betterandroid/build.gradle.kts @@ -1,19 +1,21 @@ plugins { - autowire(libs.plugins.android.application) + autowire(libs.plugins.android.library) autowire(libs.plugins.kotlin.android) + autowire(libs.plugins.kotlin.dokka) + autowire(libs.plugins.maven.publish) } +group = property.project.groupName +version = property.project.hikage.extension.version + android { - namespace = property.project.app.packageName + namespace = property.project.hikage.extension.betterandroid.namespace compileSdk = property.project.android.compileSdk defaultConfig { - applicationId = property.project.app.packageName minSdk = property.project.android.minSdk - targetSdk = property.project.android.targetSdk - versionName = property.project.app.versionName - versionCode = property.project.app.versionCode testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildTypes { release { @@ -33,20 +35,16 @@ android { "-Xno-receiver-assertions" ) } - buildFeatures { - buildConfig = true - viewBinding = true - } } dependencies { + implementation(projects.hikageCore) + implementation(com.highcapable.yukireflection.api) implementation(com.highcapable.betterandroid.ui.component) implementation(com.highcapable.betterandroid.ui.extension) implementation(com.highcapable.betterandroid.system.extension) implementation(androidx.core.core.ktx) implementation(androidx.appcompat.appcompat) - implementation(com.google.android.material.material) - implementation(androidx.constraintlayout.constraintlayout) testImplementation(junit.junit) androidTestImplementation(androidx.test.ext.junit) androidTestImplementation(androidx.test.espresso.espresso.core) diff --git a/hikage-extension-betterandroid/consumer-rules.pro b/hikage-extension-betterandroid/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/hikage-extension-betterandroid/proguard-rules.pro b/hikage-extension-betterandroid/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/hikage-extension-betterandroid/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt b/hikage-extension-betterandroid/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..31723ed --- /dev/null +++ b/hikage-extension-betterandroid/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt @@ -0,0 +1,25 @@ +package com.highcapable.hikage + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.highcapable.hikage.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/main/AndroidManifest.xml b/hikage-extension-betterandroid/src/main/AndroidManifest.xml new file mode 100644 index 0000000..568741e --- /dev/null +++ b/hikage-extension-betterandroid/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/CommonAdapterBuilder.kt b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/CommonAdapterBuilder.kt new file mode 100644 index 0000000..41855c7 --- /dev/null +++ b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/CommonAdapterBuilder.kt @@ -0,0 +1,76 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/10. + */ +@file:Suppress("LocalVariableName") +@file:JvmName("CommonAdapterBuilderUtils") + +package com.highcapable.hikage.extension.betterandroid.ui.component.adapter + +import android.view.ViewGroup +import com.highcapable.betterandroid.ui.component.adapter.CommonAdapterBuilder +import com.highcapable.hikage.core.Hikage +import com.highcapable.hikage.core.base.HikagePerformer +import com.highcapable.hikage.core.base.Hikageable +import com.highcapable.hikage.extension.betterandroid.ui.component.adapter.viewholder.HikageHolderDelegate + +/** + * Create and add view holder from [Hikage.Delegate]. + * + * Usage: + * + * ```kotlin + * onBindItemView( + * Hikageable = { + * TextView( + * id = "text", + * lparams = LayoutParams(widthMatchParent = true) + * ) { + * text = "Item" + * textSize = 20f + * } + * } + * ) { hikage, entity, position -> + * hikage.get("text").text = "Item ${entity.name} of ${position + 1}" + * } + * ``` + * @see CommonAdapterBuilder.onBindItemView + * @receiver [CommonAdapterBuilder]<[E]> + * @param Hikageable the performer body. + * @return [CommonAdapterBuilder]<[E]> + */ +@JvmOverloads +fun CommonAdapterBuilder.onBindItemView( + Hikageable: HikagePerformer, + viewHolder: (hikage: Hikage, entity: E, position: Int) -> Unit = { _, _, _ -> } +) = onBindItemView(Hikageable(performer = Hikageable), viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate]. + * @see CommonAdapterBuilder.onBindItemView + * @receiver [CommonAdapterBuilder]<[E]> + * @param delegate the delegate. + * @return [CommonAdapterBuilder]<[E]> + */ +@JvmOverloads +fun CommonAdapterBuilder.onBindItemView( + delegate: Hikage.Delegate<*>, + viewHolder: (hikage: Hikage, entity: E, position: Int) -> Unit = { _, _, _ -> } +) = onBindItemView(HikageHolderDelegate(delegate), viewHolder) \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/PagerAdapterBuilder.kt b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/PagerAdapterBuilder.kt new file mode 100644 index 0000000..34d7ef7 --- /dev/null +++ b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/PagerAdapterBuilder.kt @@ -0,0 +1,87 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/10. + */ +@file:Suppress("LocalVariableName") +@file:JvmName("PagerAdapterBuilderUtils") + +package com.highcapable.hikage.extension.betterandroid.ui.component.adapter + +import android.view.ViewGroup +import com.highcapable.betterandroid.ui.component.adapter.PagerAdapterBuilder +import com.highcapable.hikage.core.Hikage +import com.highcapable.hikage.core.base.HikagePerformer +import com.highcapable.hikage.core.base.Hikageable +import com.highcapable.hikage.extension.betterandroid.ui.component.adapter.viewholder.HikageHolderDelegate + +/** + * Create and add view holder from [Hikage.Delegate]. + * + * Usage: + * + * ```kotlin + * onBindPageView( + * Hikageable = { + * LinearLayout( + * id = "container", + * lparams = LayoutParams(matchParent = true), + * init = { + * orientation = LinearLayout.VERTICAL + * gravity = Gravity.CENTER + * } + * ) { + * TextView( + * id = "text", + * lparams = LayoutParams { + * gravity = Gravity.CENTER + * } + * ) { + * text = "Page" + * textSize = 20f + * } + * } + * } + * ) { hikage, entity, position -> + * hikage.get("text").text = "Page ${entity.name} of ${position + 1}" + * } + * ``` + * @see PagerAdapterBuilder.onBindPageView + * @receiver [PagerAdapterBuilder]<[E]> + * @param Hikageable the performer body. + * @return [PagerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun PagerAdapterBuilder.onBindPageView( + Hikageable: HikagePerformer, + viewHolder: (hikage: Hikage, entity: E, position: Int) -> Unit = { _, _, _ -> } +) = onBindPageView(Hikageable(performer = Hikageable), viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate]. + * @see PagerAdapterBuilder.onBindPageView + * @receiver [PagerAdapterBuilder]<[E]> + * @param delegate the delegate. + * @return [PagerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun PagerAdapterBuilder.onBindPageView( + delegate: Hikage.Delegate<*>, + viewHolder: (hikage: Hikage, entity: E, position: Int) -> Unit = { _, _, _ -> } +) = onBindPageView(HikageHolderDelegate(delegate), viewHolder) \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/RecyclerAdapterBuilder.kt b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/RecyclerAdapterBuilder.kt new file mode 100644 index 0000000..f300c23 --- /dev/null +++ b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/RecyclerAdapterBuilder.kt @@ -0,0 +1,163 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/10. + */ +@file:Suppress("LocalVariableName") +@file:JvmName("RecyclerAdapterBuilderUtils") + +package com.highcapable.hikage.extension.betterandroid.ui.component.adapter + +import android.view.ViewGroup +import com.highcapable.betterandroid.ui.component.adapter.RecyclerAdapterBuilder +import com.highcapable.betterandroid.ui.component.adapter.entity.AdapterPosition +import com.highcapable.hikage.core.Hikage +import com.highcapable.hikage.core.base.HikagePerformer +import com.highcapable.hikage.core.base.Hikageable +import com.highcapable.hikage.extension.betterandroid.ui.component.adapter.viewholder.HikageHolderDelegate + +/** + * Create and add view holder from [Hikage.Delegate] for a header view. + * + * Usage: + * + * ```kotlin + * onBindHeaderView( + * Hikageable = { + * TextView( + * id = "text", + * lparams = LayoutParams(widthMatchParent = true) + * ) { + * text = "Header" + * textSize = 20f + * } + * } + * ) { hikage -> + * hikage.get("text").text = "Header with redefined text" + * } + * ``` + * @see RecyclerAdapterBuilder.onBindHeaderView + * @param Hikageable the performer body. + * @return [RecyclerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun RecyclerAdapterBuilder.onBindHeaderView( + Hikageable: HikagePerformer, + viewHolder: (hikage: Hikage) -> Unit = {} +) = onBindHeaderView(Hikageable(performer = Hikageable), viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate] for a header view. + * @see RecyclerAdapterBuilder.onBindHeaderView + * @param delegate the delegate. + * @return [RecyclerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun RecyclerAdapterBuilder.onBindHeaderView( + delegate: Hikage.Delegate<*>, + viewHolder: (hikage: Hikage) -> Unit = {} +) = onBindHeaderView(HikageHolderDelegate(delegate), viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate] for a footer view. + * + * Usage: + * + * ```kotlin + * onBindFooterView( + * Hikageable = { + * TextView( + * id = "text", + * lparams = LayoutParams(widthMatchParent = true) + * ) { + * text = "Footer" + * textSize = 20f + * } + * } + * ) { hikage -> + * hikage.get("text").text = "Footer with redefined text" + * } + * ``` + * @see RecyclerAdapterBuilder.onBindFooterView + * @param Hikageable the performer body. + * @return [RecyclerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun RecyclerAdapterBuilder.onBindFooterView( + Hikageable: HikagePerformer, + viewHolder: (hikage: Hikage) -> Unit = {} +) = onBindFooterView(Hikageable(performer = Hikageable), viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate] for a footer view. + * @see RecyclerAdapterBuilder.onBindFooterView + * @param delegate the delegate. + * @return [RecyclerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun RecyclerAdapterBuilder.onBindFooterView( + delegate: Hikage.Delegate<*>, + viewHolder: (hikage: Hikage) -> Unit = {} +) = onBindFooterView(HikageHolderDelegate(delegate), viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate]. + * + * Usage: + * + * ```kotlin + * onBindItemView( + * Hikageable = { + * TextView( + * id = "text", + * lparams = LayoutParams(widthMatchParent = true) + * ) { + * text = "Item" + * textSize = 20f + * } + * } + * ) { hikage, entity, position -> + * hikage.get("text").text = "Item ${entity.name} of ${position.value + 1}" + * } + * ``` + * @see RecyclerAdapterBuilder.onBindItemView + * @receiver [RecyclerAdapterBuilder]<[E]> + * @param Hikageable the performer body. + * @return [RecyclerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun RecyclerAdapterBuilder.onBindItemView( + Hikageable: HikagePerformer, + viewType: Int = RecyclerAdapterBuilder.DEFAULT_VIEW_TYPE, + viewHolder: (hikage: Hikage, entity: E, position: AdapterPosition) -> Unit = { _, _, _ -> } +) = onBindItemView(Hikageable(performer = Hikageable), viewType, viewHolder) + +/** + * Create and add view holder from [Hikage.Delegate]. + * @see RecyclerAdapterBuilder.onBindItemView + * @receiver [RecyclerAdapterBuilder]<[E]> + * @param delegate the delegate. + * @return [RecyclerAdapterBuilder]<[E]> + */ +@JvmOverloads +fun RecyclerAdapterBuilder.onBindItemView( + delegate: Hikage.Delegate<*>, + viewType: Int = RecyclerAdapterBuilder.DEFAULT_VIEW_TYPE, + viewHolder: (hikage: Hikage, entity: E, position: AdapterPosition) -> Unit = { _, _, _ -> } +) = onBindItemView(HikageHolderDelegate(delegate), viewType, viewHolder) \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/viewholder/HikageHolderDelegate.kt b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/viewholder/HikageHolderDelegate.kt new file mode 100644 index 0000000..4a0a0d1 --- /dev/null +++ b/hikage-extension-betterandroid/src/main/java/com/highcapable/hikage/extension/betterandroid/ui/component/adapter/viewholder/HikageHolderDelegate.kt @@ -0,0 +1,37 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/3/10. + */ +package com.highcapable.hikage.extension.betterandroid.ui.component.adapter.viewholder + +import android.content.Context +import android.view.ViewGroup +import com.highcapable.betterandroid.ui.component.adapter.viewholder.delegate.base.ViewHolderDelegate +import com.highcapable.hikage.core.Hikage + +/** + * [Hikage.Delegate] type view holder delegate. + * @param delegate the [Hikage.Delegate] instance. + */ +class HikageHolderDelegate internal constructor(private val delegate: Hikage.Delegate<*>) : ViewHolderDelegate() { + + override fun create(context: Context, parent: ViewGroup?) = delegate.create(context, parent, attachToParent = false) + override fun getView(instance: Hikage) = instance.root +} \ No newline at end of file diff --git a/hikage-extension-betterandroid/src/test/java/com/highcapable/hikage/ExampleUnitTest.kt b/hikage-extension-betterandroid/src/test/java/com/highcapable/hikage/ExampleUnitTest.kt new file mode 100644 index 0000000..b55f02e --- /dev/null +++ b/hikage-extension-betterandroid/src/test/java/com/highcapable/hikage/ExampleUnitTest.kt @@ -0,0 +1,18 @@ +package com.highcapable.hikage + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/hikage-extension-compose/build.gradle.kts b/hikage-extension-compose/build.gradle.kts new file mode 100644 index 0000000..7d4f2a8 --- /dev/null +++ b/hikage-extension-compose/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + autowire(libs.plugins.android.library) + autowire(libs.plugins.kotlin.android) + autowire(libs.plugins.compose.compiler) + autowire(libs.plugins.kotlin.dokka) + autowire(libs.plugins.maven.publish) +} + +group = property.project.groupName +version = property.project.hikage.extension.compose.version + +android { + namespace = property.project.hikage.extension.compose.namespace + compileSdk = property.project.android.compileSdk + + defaultConfig { + minSdk = property.project.android.minSdk + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + freeCompilerArgs = listOf( + "-Xno-param-assertions", + "-Xno-call-assertions", + "-Xno-receiver-assertions" + ) + } +} + +dependencies { + implementation(projects.hikageCore) + implementation(com.highcapable.yukireflection.api) + implementation(com.highcapable.betterandroid.ui.extension) + implementation(com.highcapable.betterandroid.system.extension) + implementation(androidx.core.core.ktx) + implementation(androidx.appcompat.appcompat) + implementation(androidx.compose.ui.ui) + testImplementation(junit.junit) + androidTestImplementation(androidx.test.ext.junit) + androidTestImplementation(androidx.test.espresso.espresso.core) +} \ No newline at end of file diff --git a/hikage-extension-compose/consumer-rules.pro b/hikage-extension-compose/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/hikage-extension-compose/proguard-rules.pro b/hikage-extension-compose/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/hikage-extension-compose/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/hikage-extension-compose/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt b/hikage-extension-compose/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..31723ed --- /dev/null +++ b/hikage-extension-compose/src/androidTest/java/com/highcapable/hikage/ExampleInstrumentedTest.kt @@ -0,0 +1,25 @@ +package com.highcapable.hikage + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.highcapable.hikage.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/hikage-extension-compose/src/main/AndroidManifest.xml b/hikage-extension-compose/src/main/AndroidManifest.xml new file mode 100644 index 0000000..568741e --- /dev/null +++ b/hikage-extension-compose/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/hikage-extension-compose/src/main/java/com/highcapable/hikage/extension/androidx/compose/ComposeView.kt b/hikage-extension-compose/src/main/java/com/highcapable/hikage/extension/androidx/compose/ComposeView.kt new file mode 100644 index 0000000..6568414 --- /dev/null +++ b/hikage-extension-compose/src/main/java/com/highcapable/hikage/extension/androidx/compose/ComposeView.kt @@ -0,0 +1,62 @@ +/* + * Hikage - An Android responsive UI building tool. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/Hikage + * + * Apache License Version 2.0 + * + * 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 + * + * https://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. + * + * This file is created by fankes on 2025/2/28. + */ +@file:Suppress("unused", "FunctionName") +@file:JvmName("ComposeViewPerformer") + +package com.highcapable.hikage.extension.androidx.compose + +import android.view.ViewGroup +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.ComposeView +import com.highcapable.hikage.annotation.Hikageable +import com.highcapable.hikage.core.Hikage +import com.highcapable.hikage.core.base.HikageView + +/** + * Composable in [Hikage]. + * + * Usage: + * + * ```kotlin + * Hikageable { + * ComposeView( + * lparams = LayoutParams(matchParent = true) + * ) { + * Text("Hello, Compose in Hikage!") + * } + * } + * ``` + * @see ComposeView + * @see Hikage.Performer.View + */ +@Hikageable +inline fun Hikage.Performer.ComposeView( + lparams: Hikage.LayoutParams? = null, + id: String? = null, + init: HikageView