Skip to content

Commit

Permalink
Initial project (#2)
Browse files Browse the repository at this point in the history
* Initial project

* Update readme
  • Loading branch information
jisungbin committed Oct 13, 2023
1 parent 2f45bbc commit 5f49f1e
Show file tree
Hide file tree
Showing 19 changed files with 572 additions and 67 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
max_line_length = 150
insert_final_newline = true
trim_trailing_whitespace = true
ktlint_standard_filename = disabled
ktlint_standard_import-ordering = disabled
ktlint_standard_annotation = disabled
ktlint_standard_wrapping = disabled
ktlint_standard_argument-list-wrapping = disabled
ktlint_standard_multiline-if-else = disabled

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @jisungbin
79 changes: 79 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [email protected]. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Issue

- Resolve #ISSUE_NUMBER

## Overview (Required)

-

## Screenshot

| Before | After |
|:--------------------------:|:--------------------------:|
| <img src="" width="300" /> | <img src="" width="300" /> |
39 changes: 39 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
":timezone(Asia/Seoul)",
"config:base",
"schedule:daily",
],
"packageRules": [
{
"groupName": "Kotlin and Compose Compiler",
"groupSlug": "kotlin",
"matchPackagePrefixes": [
"androidx.compose.compiler",
],
"matchPackagePatterns": [
"org.jetbrains.kotlin.*",
],
},
{
"groupName": "AGP unstable updates",
"groupSlug": "android-gradle-plugin",
"ignoreUnstable": false,
"matchPackagePrefixes": [
"com.android.tools.build",
],
},
{
"description": "Automatically merge minor and patch-level updates",
"matchUpdateTypes": [
"minor",
"patch",
"digest",
],
"automerge": true,
"automergeStrategy": "rebase",
"platformAutomerge": true,
},
],
}
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

env:
GRADLE_OPTS: '-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false'
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true

on:
pull_request:
paths-ignore: [ '**/**.md' ]

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
ci-build:
runs-on: macos-latest

if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}

steps:
- uses: actions/checkout@v3

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

- name: Code style checks
run: ./gradlew ktlintCheck detekt

- name: Run test
run: ./gradlew test --stacktrace

- name: Run build
run: ./gradlew build --stacktrace

- name: Upload reports
if: always()
uses: actions/upload-artifact@v3
with:
name: build-reports
retention-days: 7
path: |
**/build/reports/*
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
retention-days: 7
path: |
**/build/test-results/*
15 changes: 15 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Gradle Wrapper Validation

on:
pull_request:
paths: [ 'gradlew', 'gradlew.bat', 'gradle/wrapper/' ]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
53 changes: 12 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
**/.idea/*
!/.idea/icon.png
!/.idea/vcs.xml
!/.idea/copyright
!/.idea/codeStyleSettings.xml
!/.idea/codeStyles
!/.idea/dictionaries
!/.idea/inspectionProfiles
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
.gradle
build
release
local.properties
7 changes: 7 additions & 0 deletions .idea/copyright/MIT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/dictionaries

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## ComposeInvalidator

Composable's forced invalidation[^1] request and invalidation tree building tools.

[^1]: Commonly known as "recomposition".

This tool was started for personal learning and is not proven to be necessary in production, but it can do the following things:

- **Request to force invalidate a Composable:** Forces the Composable to be invalidated without handling `State`.
- **Request to force dispose a Composable:** Disposing of a Composable will initialize any items cached by `key`, such as `remember`, `LaunchedEffect`, and `DisposableEffect`. That is, it initializes the Composable and requests an initial-composition.
- **Record "real" re-composed Composable:** Simply adding logs to a Composable function and seeing them printed doesn't mean that recomposition has occurred; this feature only logs when it's actually recomposed. ("fake" and "real" recompositions will be discussed in more detail later.)

- **When the root Composable is recomposed, record the child Composables that are recomposed with it:** Help easily identify tangled Composables.

The first and second features can be useful for people who want to control the Composable lifecycle without being tied to a `State` or Compose Runtime.

---

### Usage

```kotlin
@[Composable Invalidable(tag = [String?, default = null], disposable = [Boolean, default = true]) RecompositionRecord(child = [Boolean, default = true])]
fun HelloWorld() = Unit

// without Invalidable.tag

ComposeInvalidator.invalidHelloWorld() // auto-generated function
ComposeInvalidator.disposeHelloWorld() // auto-generated function

// with Invalidable.tag

ComposeInvalidator.invalidHelloWorld{Tag}() // auto-generated function
ComposeInvalidator.disposeHelloWorld{Tag}() // auto-generated function

// with @RecompositionRecord, each time a Composable is recomposed, its name is printed.
```

### Under the hood

The core principle behind this tool is the Kotlin Compiler Plugin (K2).

The tool works in two steps.

1. IR modulation of the Composable function. However, this step is performed before the Compose Compiler.
2. Re-modulating the IR that the Compose Compiler has modulated. It intercepts the IRs that Compose Compiler changes and re-morphs them for this tool.

... TBD

#### "fake" and "real" recompositions

TBD

---

### Download

This tool is currently in the early stages of development and **is not yet released**.

```kotlin
plugins {
id("land.sungbin.composeinvalidator") version "0.1.0-SNAPSHOT"
}
```
Loading

0 comments on commit 5f49f1e

Please sign in to comment.