Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/workflows/apple-devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ jobs:
- rust-target: "aarch64-apple-watchos-sim"
os: macos-14
apple-sim: "watchOS"
- rust-target: "x86_64-apple-watchos-sim"
os: macos-13
apple-sim: "watchOS"
- rust-target: "x86_64-apple-tvos"
os: macos-13
apple-sim: "tvOS"
- rust-target: "x86_64-apple-ios"
os: macos-13
apple-sim: "iOS"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"crates/core",
"crates/core", "crates/uniffi-bindgen",
]

[workspace.package]
Expand Down
104 changes: 22 additions & 82 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ args = [
"${CARGO_TARGET_DIR}/universal/tvos-sim/",
]

[tasks.build-macos]
[tasks.build-apple-std-targets]
workspace = false
category = "Build"
description = "Compiles for all targets needed to produce a universal library for macOS"
Expand All @@ -138,75 +138,51 @@ args = [
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"--target", "aarch64-apple-darwin",
"--target", "x86_64-apple-darwin",
"-p", "liveview-native-core"
]
dependencies = ["install-targets"]

[tasks.build-ios]
workspace = false
category = "Build"
description = "Compiles for all targets needed to produce a universal library for iOS"
command = "rustup"
args = [
"run", "${CARGO_MAKE_TOOLCHAIN}",
"cargo", "build",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"--target", "aarch64-apple-ios",
"--target", "aarch64-apple-ios-sim",
"--target", "x86_64-apple-ios", "-p",
"liveview-native-core"
"--target", "x86_64-apple-ios",
"-p", "liveview-native-core"
]
dependencies = ["install-targets"]

[tasks.build-watchos]

[tasks.build-apple-no-std-targets]
workspace = false
category = "Build"
description = "Compiles for all targets needed to produce a universal library for watchOS"
description = "Compiles for all targets needed to produce a universal library for watchOS and tvOS"
command = "rustup"
args = [
"run", "${CARGO_MAKE_TOOLCHAIN}",
"cargo", "build",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"-Z", "build-std",

"--target", "arm64_32-apple-watchos",
"--target", "aarch64-apple-watchos-sim",
"--target", "x86_64-apple-watchos-sim",
"-p", "liveview-native-core"
]
dependencies = ["install-targets"]

[tasks.build-tvos]
workspace = false
category = "Build"
description = "Compiles for all targets needed to produce a universal library for tvOS"
command = "rustup"
args = [
"run", "${CARGO_MAKE_TOOLCHAIN}",
"cargo", "build",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"-Z", "build-std",
"--target", "aarch64-apple-tvos",
"--target", "aarch64-apple-tvos-sim",
"--target", "x86_64-apple-tvos",
"-p", "liveview-native-core"
]
dependencies = ["install-targets"]

[tasks.lipo-macos]
dependencies = ["create-lipo-universal-directories", "build-macos"]
dependencies = ["create-lipo-universal-directories", "build-apple-std-targets"]
workspace = false
category = "Build"
description = "Combines macOS targets into a universal binary"
command = "xcrun"
args = [
"lipo", "-create",
"${CARGO_TARGET_DIR}/aarch64-apple-darwin/debug/libliveview_native_core.a",
"${CARGO_TARGET_DIR}/x86_64-apple-darwin/debug/libliveview_native_core.a",
"${CARGO_TARGET_DIR}/x86_64-apple-darwin/debug/libliveview_native_core.a",
"-output", "${CARGO_TARGET_DIR}/universal/macos/libliveview_native_core.a"
]

[tasks.lipo-ios-sim]
dependencies = ["create-lipo-universal-directories", "build-ios"]
dependencies = ["create-lipo-universal-directories", "build-apple-std-targets"]
workspace = false
category = "Build"
description = "Combines iOS simulator targets into a universal binary"
Expand All @@ -215,12 +191,12 @@ args = [
"lipo",
"-create",
"${CARGO_TARGET_DIR}/aarch64-apple-ios-sim/debug/libliveview_native_core.a",
"${CARGO_TARGET_DIR}/x86_64-apple-ios/debug/libliveview_native_core.a",
"${CARGO_TARGET_DIR}/x86_64-apple-ios/debug/libliveview_native_core.a",
"-output", "${CARGO_TARGET_DIR}/universal/ios-sim/libliveview_native_core.a"
]

[tasks.lipo-tvos-sim]
dependencies = ["create-lipo-universal-directories", "build-tvos"]
dependencies = ["create-lipo-universal-directories", "build-apple-no-std-targets"]
workspace = false
category = "Build"
description = "Combines iOS simulator targets into a universal binary"
Expand All @@ -234,7 +210,7 @@ args = [
]

[tasks.lipo-watchos-sim]
dependencies = ["create-lipo-universal-directories", "build-watchos"]
dependencies = ["create-lipo-universal-directories", "build-apple-no-std-targets"]
workspace = false
category = "Build"
description = "Combines watchOS simulator targets into a universal binary"
Expand Down Expand Up @@ -295,30 +271,14 @@ description = "Run cargo-bloat"
command = "cargo"
args = ["bloat", "${@}"]

[tasks.uniffi-swift-generate-from-udl]
workspace = false
category = "Packaging"
description = ""
command = "cargo"
args = [
"run",
"--bin",
"uniffi-bindgen",
"--",
"generate",
"${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/crates/core/src/uniffi.udl",
"--language=swift",
"--out-dir=${CARGO_TARGET_DIR}/uniffi/swift/generated",
]

[tasks.uniffi-swift-generate]
workspace = false
category = "Packaging"
description = ""
command = "cargo"
args = [
"run",
"--bin",
"-p",
"uniffi-bindgen",
"--",
"generate",
Expand All @@ -327,29 +287,11 @@ args = [
"--language=swift",
"--out-dir=${CARGO_TARGET_DIR}/uniffi/swift/generated",
]
dependencies = ["build-macos"]

[tasks.uniffi-kotlin-generate]
workspace = false
category = "Packaging"
description = ""
command = "cargo"
args = [
"run",
"--bin",
"uniffi-bindgen",
"--",
"generate",
"--library",
"${CARGO_TARGET_DIR}/aarch64-apple-darwin/debug/libliveview_native_core.dylib",
"--language=kotlin",
"--out-dir=${CARGO_TARGET_DIR}/uniffi/kotlin/generated",
]
dependencies = ["build-macos"]
dependencies = ["build-apple-std-targets"]

[tasks.uniffi-swift-modulemap]
workspace = false
category = "Packaging"
category = "Packaging the module maps for FFIs"
description = ""
script_runner = "@shell"
script = '''
Expand All @@ -363,13 +305,13 @@ dependencies = ["uniffi-swift-generate"]
[tasks.uniffi-swift-package]
workspace = false
category = "Packaging"
description = "Generates the LiveViewNativeCore.xcframework package"
description = "Generates the swift package from the liveview native core and phoenix-channels-clients bindings"
dependencies = ["uniffi-swift-modulemap", "uniffi-swift-package-lvn", "uniffi-swift-package-phx"]

[tasks.uniffi-swift-package-lvn]
workspace = false
category = "Packaging"
description = "Generates the LiveViewNativeCore.xcframework package"
description = "Copy the generated swift bindings for LiveViewNativeCore to the correct location."
command = "cp"
args = [
"${CARGO_TARGET_DIR}/uniffi/swift/generated/LiveViewNativeCore.swift",
Expand All @@ -378,7 +320,7 @@ args = [
[tasks.uniffi-swift-package-phx]
workspace = false
category = "Packaging"
description = "Generates the LiveViewNativeCore.xcframework package"
description = "Copy the swift bindings for PhoenixChannelsClient to the right location."
command = "cp"
args = [
"${CARGO_TARGET_DIR}/uniffi/swift/generated/PhoenixChannelsClient.swift",
Expand Down Expand Up @@ -419,16 +361,14 @@ args = [
"-headers", "${CARGO_TARGET_DIR}/uniffi/swift/generated",
]
dependencies = [
"build-macos",
"build-apple-std-targets",
"lipo-macos",
"build-ios",
"lipo-ios-sim",
"build-watchos",
"build-apple-no-std-targets",
"lipo-watchos-sim",
"build-tvos",
"lipo-tvos-sim",
"remove-existing-uniffi-xcframework",
"uniffi-swift-package"
"uniffi-swift-generate",
]

[tasks.remove-existing-uniffi-xcframework]
Expand Down
13 changes: 6 additions & 7 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ name = "liveview_native_core"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cranelift-entity = { version = "0.104" }
cranelift-entity = { version = "0.106" }
fixedbitset = { version = "0.4" }
fxhash = { version = "0.2" }
html5gum = { git = "https://github.com/liveviewnative/html5gum", branch = "lvn" }
Expand All @@ -39,25 +39,24 @@ serde_json = { version = "1.0" }
smallstr = { version = "0.3", features = ["union"] }
smallvec = { version = "1.10", features = ["union", "const_generics", "specialization"] }
thiserror = "1.0"
uniffi = { version = "0.26", features = ["cli", "tokio"] }
uniffi = { version = "0.27", features = ["tokio"] }
async-compat = "0.2.3"
futures = "0.3.29"
log = "0.4"
reqwest = { version = "0.11.23", features = ["native-tls-vendored"] }
tokio = { version = "1.35", features = ["full"] }
reqwest = { version = "0.12.2", features = ["native-tls-vendored"] }

[build-dependencies]
Inflector = "0.11"
uniffi = { version = "0.26", features = [ "build" ] }
uniffi = { version = "0.27", features = [ "build" ] }

[dev-dependencies]
paste = { version = "1.0" }
pretty_assertions = { version = "1.4.0" }
text-diff = { version = "0.4.0" }
uniffi = { version = "0.26", features = ["bindgen-tests", "tokio", "cli"]}
uniffi = { version = "0.27", features = ["bindgen-tests", "tokio"]}
tokio = { version = "1.35", features = ["full"] }
env_logger = "0.11.1"

# For image generation for tests
image = "0.24.8"
image = "0.25.1"
tempfile = "3.9.0"
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ android {
commandLine(
"cargo",
"run",
"--bin",
"-p",
"uniffi-bindgen",
"--",
"generate",
Expand Down Expand Up @@ -115,6 +115,7 @@ cargo {
tasks.configureEach {
if ((name == "javaPreCompileDebug" || name == "javaPreCompileRelease")) {
dependsOn("cargoBuild")
dependsOn("generateDebugUniFFIBindings")
}
if (name == "cargoBuild") {
dependsOn("generateDebugUniFFIBindings")
Expand Down Expand Up @@ -146,7 +147,7 @@ publishing {
register<MavenPublication>("release") {
groupId = "org.phoenixframework"
artifactId = "liveview-native-core-jetpack"
version = "0.1.0-pre-alpha-08"
version = "0.2.0-pre-alpha-01"

afterEvaluate {
from(components["release"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SimpleChangeHandler: DocumentChangeHandler {
}

override fun `handle`(
`context`: String,
`context`: Document,
`changeType`: ChangeType,
`nodeRef`: NodeRef,
`optionNodeRef`: NodeRef?,
Expand Down Expand Up @@ -68,6 +68,47 @@ class DocumentTest {
var rendered = doc.render();
assertEquals(input, rendered)
}
@Test
fun json_merging_from_empty() {
var doc = Document.empty();
var input = """
{
"0":"0",
"1":"0",
"2":"",
"s":[
"<Column>\n <Button phx-click=\"inc\">\n <Text>Increment</Text>\n </Button>\n <Button phx-click=\"dec\">\n <Text>Decrement</Text>\n </Button>\n <Text>Static Text </Text>\n <Text>Counter 1: ",
" </Text>\n <Text>Counter 2: ",
" </Text>\n",
"\n</Column>"
]
}
"""
doc.mergeFragmentJson(input)
var expected = """<Column>
<Button phx-click="inc">
<Text>
Increment
</Text>
</Button>
<Button phx-click="dec">
<Text>
Decrement
</Text>
</Button>
<Text>
Static Text
</Text>
<Text>
Counter 1: 0
</Text>
<Text>
Counter 2: 0
</Text>
</Column>"""
var rendered = doc.render();
assertEquals(expected, rendered)
}

@Test
fun json_merging() {
Expand Down Expand Up @@ -141,8 +182,9 @@ class DocumentTest {
}
}
"""
var simple = SimpleChangeHandler()
doc.mergeFragmentJson(first_increment, simple);
var simple = SimpleChangeHandler();
doc.setEventHandler(simple);
doc.mergeFragmentJson(first_increment);
rendered = doc.render();
expected = """<Column>
<Button phx-click="inc">
Expand Down
Loading