Skip to content

Commit e572fd5

Browse files
committed
Dependency updates.
1 parent bde6ee4 commit e572fd5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+65
-61
lines changed

build.gradle.kts

+43-34
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
22

33
plugins {
4-
kotlin("js") version "1.8.22"
5-
kotlin("plugin.serialization") version "1.8.22"
4+
kotlin("multiplatform") version "1.9.10"
5+
kotlin("plugin.serialization") version "1.9.10"
66
}
77

88
group = "com.jeffpdavidson"
@@ -11,35 +11,46 @@ version = "1.3.10-SNAPSHOT"
1111
repositories {
1212
mavenCentral()
1313
// TODO: Remove ahead of public release.
14-
// maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
15-
}
16-
17-
dependencies {
18-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.6.4")
19-
implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.8.0")
20-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
21-
implementation("com.github.ajalt.colormath:colormath:3.2.1")
22-
23-
implementation("com.jeffpdavidson.kotwords:kotwords-js:1.3.9")
24-
25-
runtimeOnly(npm("webextension-polyfill", "0.10.0"))
26-
runtimeOnly(npm("jquery", "3.6.3"))
27-
runtimeOnly(npm("bootstrap", "4.6.2"))
28-
29-
testImplementation(kotlin("test-js"))
14+
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
3015
}
3116

3217
kotlin {
3318
js(IR) {
3419
browser {
35-
webpackTask {
20+
webpackTask(Action {
3621
// The default devtool uses eval(), which is forbidden in extensions. And we inline the map so we don't
3722
// need to configure the extension to load additional resources for the map.
3823
devtool = org.jetbrains.kotlin.gradle.targets.js.webpack.WebpackDevtool.INLINE_CHEAP_MODULE_SOURCE_MAP
39-
}
24+
})
4025
}
4126
binaries.executable()
4227
}
28+
29+
@Suppress("UNUSED_VARIABLE") // https://youtrack.jetbrains.com/issue/KT-38871
30+
sourceSets {
31+
val jsMain by getting {
32+
dependencies {
33+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.7.3")
34+
implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.9.1")
35+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json-js:1.6.0")
36+
implementation("com.github.ajalt.colormath:colormath-js:3.3.3")
37+
38+
implementation("com.jeffpdavidson.kotwords:kotwords-js:1.3.10-SNAPSHOT")
39+
40+
// TODO: Migrate to kotlinx-datetime if parsing/formatting support is added.
41+
implementation("com.soywiz.korlibs.klock:klock-js:4.0.10")
42+
43+
runtimeOnly(npm("webextension-polyfill", "0.10.0"))
44+
runtimeOnly(npm("bootstrap", "5.3.2"))
45+
}
46+
}
47+
48+
val jsTest by getting {
49+
dependencies {
50+
implementation(kotlin("test-js"))
51+
}
52+
}
53+
}
4354
}
4455

4556
// Define development{Browser}Extension and production{Browser}Extension tasks which build in development/production
@@ -59,29 +70,31 @@ tasks {
5970
}
6071
}
6172

73+
fun String.capitalizeAscii() = replaceFirstChar(Char::titlecase)
74+
6275
val tasks = variants.associateWith { (env, browser) ->
63-
val variantName = "$env${browser.capitalize()}"
76+
val variantName = "$env${browser.capitalizeAscii()}"
6477
val extensionFolder = "build/extension/$variantName"
6578

66-
val browserWebpackTask = getByName("browser${env.capitalize()}Webpack", KotlinWebpack::class)
79+
val browserWebpackTask = getByName("jsBrowser${env.capitalizeAscii()}Webpack", KotlinWebpack::class)
6780

68-
val copyBundleFile = register<Copy>("copy${variantName.capitalize()}BundleFile") {
81+
val copyBundleFile = register<Copy>("copy${variantName.capitalizeAscii()}BundleFile") {
6982
dependsOn(browserWebpackTask)
70-
from(browserWebpackTask.destinationDirectory) {
83+
from(browserWebpackTask.outputDirectory) {
7184
include("*.js")
7285
}
7386
into("$extensionFolder/js")
7487
}
7588

76-
val copyResources = register<Copy>("copy${variantName.capitalize()}Resources") {
77-
from("src/main/resources")
89+
val copyResources = register<Copy>("copy${variantName.capitalizeAscii()}Resources") {
90+
from("src/jsMain/resources")
7891
exclude("manifest.json")
7992
exclude("browser-js/")
8093
into(extensionFolder)
8194
}
8295

83-
val copyManifest = register<Copy>("copy${variantName.capitalize()}Manifest") {
84-
from("src/main/resources/manifest.json")
96+
val copyManifest = register<Copy>("copy${variantName.capitalizeAscii()}Manifest") {
97+
from("src/jsMain/resources/manifest.json")
8598
into(extensionFolder)
8699
// Replace placeholders in manifest.json based on the browser.
87100
when (browser) {
@@ -108,11 +121,7 @@ tasks {
108121
}
109122
}
110123

111-
val copyJsDeps = register<Copy>("copy${variantName.capitalize()}JsDeps") {
112-
from("build/js/node_modules/jquery/dist") {
113-
include("jquery.slim.min.js")
114-
into("js")
115-
}
124+
val copyJsDeps = register<Copy>("copy${variantName.capitalizeAscii()}JsDeps") {
116125
from("build/js/node_modules/bootstrap/dist") {
117126
include("css/bootstrap.min.css")
118127
include("js/bootstrap.bundle.min.js")
@@ -121,7 +130,7 @@ tasks {
121130
include("browser-polyfill.min.js")
122131
into("js")
123132
}
124-
from("src/main/resources/browser-js") {
133+
from("src/jsMain/resources/browser-js") {
125134
include("$browser.js")
126135
rename { "browser.js" }
127136
into("js")
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/kotlin/com/jeffpdavidson/crosswordscraper/CrosswordScraper.kt src/jsMain/kotlin/com/jeffpdavidson/crosswordscraper/CrosswordScraper.kt

+4-6
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ object CrosswordScraper {
201201
debugLog.appendLine("Browser: ${window.navigator.userAgent}")
202202

203203
val (tabId, frames) = Scraping.getAllFrames()
204-
debugLog.appendLine("URL: ${frames.first { it.parentFrameId == -1 }.url}")
204+
debugLog.appendLine("URL: ${frames.firstOrNull { it.parentFrameId == -1 }?.url ?: "<unknown>"}")
205205

206206
val puzzles = mutableSetOf<ProcessedScrapeResult>()
207207
val processedGrids = mutableListOf<List<List<Puzzle.Cell>>>()
@@ -385,7 +385,6 @@ object CrosswordScraper {
385385

386386
private fun HtmlBlockTag.renderScrapeError(scrapedPuzzle: ProcessedScrapeResult.Error) {
387387
classes = classes + "disabled"
388-
style = "pointer-events: auto;"
389388
div(classes = "mb-1") {
390389
+scrapedPuzzle.source
391390
}
@@ -439,7 +438,7 @@ object CrosswordScraper {
439438
}
440439
div("modal-footer") {
441440
button(type = ButtonType.button, classes = "btn btn-secondary") {
442-
attributes["data-dismiss"] = "modal"
441+
attributes["data-bs-dismiss"] = "modal"
443442
+"Close"
444443
}
445444
}
@@ -451,14 +450,13 @@ object CrosswordScraper {
451450
val errorMessageElement = document.getElementById("error-message") as HTMLParagraphElement
452451
errorMessageElement.innerText = message
453452
}
454-
val modal = js("$('#error-dialog')")
455-
modal.modal("show")
453+
js("new bootstrap.Modal('#error-dialog').show()")
456454
}
457455

458456
/** Initiate a user download of the given data. */
459457
private suspend fun startDownload(fileName: String, data: ByteArray) {
460458
val reader = FileReader()
461-
suspendCoroutine<Unit> { cont ->
459+
suspendCoroutine { cont ->
462460
reader.onload = { event ->
463461
val link = document.createElement("a") as HTMLAnchorElement
464462
link.download = fileName

src/main/kotlin/com/jeffpdavidson/crosswordscraper/Settings.kt src/jsMain/kotlin/com/jeffpdavidson/crosswordscraper/Settings.kt

+10-10
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object Settings {
6262
h4 {
6363
+"Automatic Download"
6464
}
65-
div("form-group") {
65+
div("mb-3") {
6666
div("form-check") {
6767
input(type = InputType.checkBox, classes = "form-check-input") {
6868
id = ID_AUTO_DOWNLOAD
@@ -80,12 +80,12 @@ object Settings {
8080
"download that puzzle and close the scraper dialog.")
8181
}
8282
}
83-
div("form-group") {
83+
div("mb-3") {
8484
label {
8585
htmlFor = ID_AUTO_DOWNLOAD_FORMAT
8686
+"Format"
8787
}
88-
select("form-control") {
88+
select("form-select") {
8989
id = ID_AUTO_DOWNLOAD_FORMAT
9090
style = "max-width: 100px;"
9191
FileFormat.values().forEach { format ->
@@ -106,7 +106,7 @@ object Settings {
106106
h4 {
107107
+"PUZ"
108108
}
109-
div("form-group") {
109+
div("mb-3") {
110110
div("form-check") {
111111
input(type = InputType.checkBox, classes = "form-check-input") {
112112
id = ID_PUZ_UNICODE_SUPPORT
@@ -127,13 +127,13 @@ object Settings {
127127
h4 {
128128
+"PDF"
129129
}
130-
div("form-group") {
130+
div("mb-3") {
131131
label {
132132
htmlFor = ID_PDF_INK_SAVER_PERCENTAGE
133133
+"Ink Saver percentage"
134134
}
135135
div("d-flex align-items-center") {
136-
input(type = InputType.range, classes = "custom-range") {
136+
input(type = InputType.range, classes = "form-range") {
137137
id = ID_PDF_INK_SAVER_PERCENTAGE
138138
style = "max-width: 300px;"
139139
onInputFunction = {
@@ -143,24 +143,24 @@ object Settings {
143143
setPdfInkSaverPercentage(pdfInkSaverPercentageInput.value.toInt())
144144
}
145145
}
146-
div("ml-2 border d-block") {
146+
div("ms-2 border d-block") {
147147
id = ID_PDF_INK_SAVER_PERCENTAGE_SQUARE
148148
style = "width: 1.5em; height: 1.5em; border-color: black !important;"
149149
}
150-
span("ml-2") {
150+
span("ms-2") {
151151
id = ID_PDF_INK_SAVER_PERCENTAGE_TEXT
152152
}
153153
}
154154
small("form-text text-muted") {
155155
+"Percentage to lighten black squares. 0% is pure black; 100% is pure white."
156156
}
157157
}
158-
div("form-group") {
158+
div("mb-3") {
159159
label {
160160
htmlFor = ID_PDF_FONT
161161
+"Font"
162162
}
163-
select("form-control") {
163+
select("form-select") {
164164
id = ID_PDF_FONT
165165
style = "max-width: 300px;"
166166
option {

src/main/kotlin/com/jeffpdavidson/crosswordscraper/sources/PuzzleSocietySource.kt src/jsMain/kotlin/com/jeffpdavidson/crosswordscraper/sources/PuzzleSocietySource.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import com.jeffpdavidson.crosswordscraper.Scraping
55
import com.jeffpdavidson.crosswordscraper.sources.Source.Companion.hostIsDomainOrSubdomainOf
66
import com.jeffpdavidson.kotwords.formats.UclickJpz
77
import com.jeffpdavidson.kotwords.formats.UclickXml
8-
import com.soywiz.klock.DateFormat
9-
import com.soywiz.klock.DateTime
10-
import com.soywiz.klock.parseDate
8+
import korlibs.time.DateFormat
9+
import korlibs.time.DateTime
10+
import korlibs.time.parseDate
1111
import kotlinx.serialization.Serializable
12-
import kotlinx.serialization.decodeFromString
1312
import kotlinx.serialization.json.Json
1413
import org.w3c.dom.parsing.DOMParser
1514
import org.w3c.dom.url.URL

src/main/kotlin/com/jeffpdavidson/crosswordscraper/sources/PzzlSource.kt src/jsMain/kotlin/com/jeffpdavidson/crosswordscraper/sources/PzzlSource.kt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.w3c.dom.url.URL
88
object PzzlSource : FixedHostSource() {
99

1010
private data class PzzlSourceInfo(val hostPermission: String, val baseUrl: String)
11+
1112
private val NYT_SOURCE = PzzlSourceInfo(
1213
hostPermission = "https://*.pzzl.com/*",
1314
baseUrl = "https://nytsyn.pzzl.com/nytsyn-crossword-mh/nytsyncrossword",
File renamed without changes.
File renamed without changes.

src/main/resources/amuse-labs.html src/jsMain/resources/amuse-labs.html

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ <h2>Crossword Scraper - Note About Amuse Labs</h2>
3737
point, support for Amuse Labs puzzles may have to be removed altogether.
3838
</p>
3939
</div>
40-
<script src="js/jquery.slim.min.js"></script>
4140
<script src="js/bootstrap.bundle.min.js"></script>
4241
</body>
4342
</html>
File renamed without changes.
File renamed without changes.

src/main/resources/options.html src/jsMain/resources/options.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ <h2>Crossword Scraper - Options</h2>
1616
<hr/>
1717
<div id="loading-container">
1818
<div class="spinner-border align-middle" id="loading-spinner" role="status"></div>
19-
<strong class="ml-1">Loading&hellip;</strong>
19+
<strong class="ms-1">Loading&hellip;</strong>
2020
</div>
2121
<div class="d-none" id="options-container"></div>
2222
</div>
23-
<script src="js/jquery.slim.min.js"></script>
2423
<script src="js/bootstrap.bundle.min.js"></script>
25-
<script src="js/browser-scripting-workaround.js"></script>
24+
<script src="js/browser.js"></script>
2625
<script src="js/CrosswordScraper.js"></script>
2726
</body>
2827
</html>

src/main/resources/popup.html src/jsMain/resources/popup.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ <h2>Crossword Scraper</h2>
2121
<hr/>
2222
<div id="loading-container">
2323
<div class="spinner-border align-middle" id="loading-spinner" role="status"></div>
24-
<strong class="ml-1">Loading&hellip;</strong>
24+
<strong class="ms-1">Loading&hellip;</strong>
2525
</div>
2626
<div class="d-none" id="puzzle-container"></div>
2727
</div>
28-
<script src="js/jquery.slim.min.js"></script>
2928
<script src="js/bootstrap.bundle.min.js"></script>
3029
<script src="js/browser.js"></script>
3130
<script src="js/CrosswordScraper.js"></script>

0 commit comments

Comments
 (0)