Skip to content

Commit

Permalink
Merge pull request #689 from manuel-martos/2.x-support-wasm
Browse files Browse the repository at this point in the history
Support Kotlin/Wasm
  • Loading branch information
manuel-martos authored Apr 9, 2024
2 parents 339a43c + 8ff134a commit c4a43d5
Show file tree
Hide file tree
Showing 189 changed files with 7,939 additions and 91 deletions.
23 changes: 23 additions & 0 deletions appyx-components/experimental/cards/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
id("com.bumble.appyx.multiplatform")
id("org.jetbrains.compose")
Expand All @@ -24,6 +26,22 @@ kotlin {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "appyx-components-experimental-cards-commons"
browser()
binaries.executable()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "appyx-components-experimental-cards-commons-wa"
browser {
// Refer to this Slack thread for more details: https://kotlinlang.slack.com/archives/CDFP59223/p1702977410505449?thread_ts=1702668737.674499&cid=CDFP59223
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
binaries.executable()
}
iosX64()
iosArm64()
Expand Down Expand Up @@ -56,11 +74,16 @@ kotlin {
}
}

compose.experimental {
web.application {}
}

dependencies {
add("kspCommonMainMetadata", project(":ksp:appyx-processor"))
add("kspAndroid", project(":ksp:appyx-processor"))
add("kspDesktop", project(":ksp:appyx-processor"))
add("kspJs", project(":ksp:appyx-processor"))
add("kspWasmJs", project(":ksp:appyx-processor"))
add("kspIosArm64", project(":ksp:appyx-processor"))
add("kspIosX64", project(":ksp:appyx-processor"))
add("kspIosSimulatorArm64", project(":ksp:appyx-processor"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// see https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file
// This file provides karma.config.d configuration to run tests with k/wasm

const path = require("path");

config.browserConsoleLogOptions.level = "debug";

const basePath = config.basePath;
const projectPath = path.resolve(basePath, "..", "..", "..", "..");
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out")

const debug = message => console.log(`[karma-config] ${message}`);

debug(`karma basePath: ${basePath}`);
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`);

config.proxies["/"] = path.resolve(basePath, "kotlin");

config.files = [
{pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false},
].concat(config.files);

function KarmaWebpackOutputFramework(config) {
// This controller is instantiated and set during the preprocessor phase.
const controller = config.__karmaWebpackController;

// only if webpack has instantiated its controller
if (!controller) {
console.warn(
"Webpack has not instantiated controller yet.\n" +
"Check if you have enabled webpack preprocessor and framework before this framework"
)
return
}

config.files.push({
pattern: `${controller.outputPath}/**/*`,
included: false,
served: true,
watched: false
})
}

const KarmaWebpackOutputPlugin = {
'framework:webpack-output': ['factory', KarmaWebpackOutputFramework],
};

config.plugins.push(KarmaWebpackOutputPlugin);
config.frameworks.push("webpack-output");
23 changes: 23 additions & 0 deletions appyx-components/experimental/promoter/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
id("com.bumble.appyx.multiplatform")
id("org.jetbrains.compose")
Expand All @@ -24,6 +26,22 @@ kotlin {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "appyx-components-experimental-promoter-commons"
browser()
binaries.executable()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "appyx-components-experimental-promoter-commons-wa"
browser {
// Refer to this Slack thread for more details: https://kotlinlang.slack.com/archives/CDFP59223/p1702977410505449?thread_ts=1702668737.674499&cid=CDFP59223
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
binaries.executable()
}
iosX64()
iosArm64()
Expand Down Expand Up @@ -57,11 +75,16 @@ kotlin {
}
}

compose.experimental {
web.application {}
}

dependencies {
add("kspCommonMainMetadata", project(":ksp:appyx-processor"))
add("kspAndroid", project(":ksp:appyx-processor"))
add("kspDesktop", project(":ksp:appyx-processor"))
add("kspJs", project(":ksp:appyx-processor"))
add("kspWasmJs", project(":ksp:appyx-processor"))
add("kspIosArm64", project(":ksp:appyx-processor"))
add("kspIosX64", project(":ksp:appyx-processor"))
add("kspIosSimulatorArm64", project(":ksp:appyx-processor"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// see https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file
// This file provides karma.config.d configuration to run tests with k/wasm

const path = require("path");

config.browserConsoleLogOptions.level = "debug";

const basePath = config.basePath;
const projectPath = path.resolve(basePath, "..", "..", "..", "..");
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out")

const debug = message => console.log(`[karma-config] ${message}`);

debug(`karma basePath: ${basePath}`);
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`);

config.proxies["/"] = path.resolve(basePath, "kotlin");

config.files = [
{pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false},
].concat(config.files);

function KarmaWebpackOutputFramework(config) {
// This controller is instantiated and set during the preprocessor phase.
const controller = config.__karmaWebpackController;

// only if webpack has instantiated its controller
if (!controller) {
console.warn(
"Webpack has not instantiated controller yet.\n" +
"Check if you have enabled webpack preprocessor and framework before this framework"
)
return
}

config.files.push({
pattern: `${controller.outputPath}/**/*`,
included: false,
served: true,
watched: false
})
}

const KarmaWebpackOutputPlugin = {
'framework:webpack-output': ['factory', KarmaWebpackOutputFramework],
};

config.plugins.push(KarmaWebpackOutputPlugin);
config.frameworks.push("webpack-output");
23 changes: 23 additions & 0 deletions appyx-components/experimental/puzzle15/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
id("com.bumble.appyx.multiplatform")
id("org.jetbrains.compose")
Expand All @@ -24,6 +26,22 @@ kotlin {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "appyx-components-experimental-puzzle15-commons"
browser()
binaries.executable()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "appyx-components-experimental-puzzle15-commons-wa"
browser {
// Refer to this Slack thread for more details: https://kotlinlang.slack.com/archives/CDFP59223/p1702977410505449?thread_ts=1702668737.674499&cid=CDFP59223
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
binaries.executable()
}
sourceSets {
val commonMain by getting {
Expand All @@ -44,9 +62,14 @@ kotlin {
}
}

compose.experimental {
web.application {}
}

dependencies {
add("kspCommonMainMetadata", project(":ksp:appyx-processor"))
add("kspAndroid", project(":ksp:appyx-processor"))
add("kspDesktop", project(":ksp:appyx-processor"))
add("kspJs", project(":ksp:appyx-processor"))
add("kspWasmJs", project(":ksp:appyx-processor"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// see https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file
// This file provides karma.config.d configuration to run tests with k/wasm

const path = require("path");

config.browserConsoleLogOptions.level = "debug";

const basePath = config.basePath;
const projectPath = path.resolve(basePath, "..", "..", "..", "..");
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out")

const debug = message => console.log(`[karma-config] ${message}`);

debug(`karma basePath: ${basePath}`);
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`);

config.proxies["/"] = path.resolve(basePath, "kotlin");

config.files = [
{pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false},
].concat(config.files);

function KarmaWebpackOutputFramework(config) {
// This controller is instantiated and set during the preprocessor phase.
const controller = config.__karmaWebpackController;

// only if webpack has instantiated its controller
if (!controller) {
console.warn(
"Webpack has not instantiated controller yet.\n" +
"Check if you have enabled webpack preprocessor and framework before this framework"
)
return
}

config.files.push({
pattern: `${controller.outputPath}/**/*`,
included: false,
served: true,
watched: false
})
}

const KarmaWebpackOutputPlugin = {
'framework:webpack-output': ['factory', KarmaWebpackOutputFramework],
};

config.plugins.push(KarmaWebpackOutputPlugin);
config.frameworks.push("webpack-output");
16 changes: 16 additions & 0 deletions appyx-components/experimental/puzzle15/web/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
id("com.bumble.appyx.multiplatform")
id("org.jetbrains.compose")
Expand All @@ -9,6 +11,20 @@ kotlin {
browser()
binaries.executable()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "appyx-components-experimental-puzzle15-web-wa"
browser {
// Refer to this Slack thread for more details: https://kotlinlang.slack.com/archives/CDFP59223/p1702977410505449?thread_ts=1702668737.674499&cid=CDFP59223
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
binaries.executable()
}
sourceSets {
val commonMain by getting {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// see https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file
// This file provides karma.config.d configuration to run tests with k/wasm

const path = require("path");

config.browserConsoleLogOptions.level = "debug";

const basePath = config.basePath;
const projectPath = path.resolve(basePath, "..", "..", "..", "..");
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out")

const debug = message => console.log(`[karma-config] ${message}`);

debug(`karma basePath: ${basePath}`);
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`);

config.proxies["/"] = path.resolve(basePath, "kotlin");

config.files = [
{pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false},
].concat(config.files);

function KarmaWebpackOutputFramework(config) {
// This controller is instantiated and set during the preprocessor phase.
const controller = config.__karmaWebpackController;

// only if webpack has instantiated its controller
if (!controller) {
console.warn(
"Webpack has not instantiated controller yet.\n" +
"Check if you have enabled webpack preprocessor and framework before this framework"
)
return
}

config.files.push({
pattern: `${controller.outputPath}/**/*`,
included: false,
served: true,
watched: false
})
}

const KarmaWebpackOutputPlugin = {
'framework:webpack-output': ['factory', KarmaWebpackOutputFramework],
};

config.plugins.push(KarmaWebpackOutputPlugin);
config.frameworks.push("webpack-output");
Loading

0 comments on commit c4a43d5

Please sign in to comment.