更新js库

pull/1814/head
kunfei 3 years ago
parent 95efc4f4ec
commit 7c251e1905
  1. 3
      app/build.gradle
  2. BIN
      app/lib/rhino-1.7.13-1.jar
  3. 13
      app/src/main/assets/updateLog.md
  4. 7
      app/src/main/java/io/legado/app/constant/AppConst.kt
  5. 2
      app/src/main/java/io/legado/app/data/entities/BaseSource.kt
  6. 3
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  7. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  8. 2
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
  9. 2
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  10. 2
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  11. 2
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  12. 9
      app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt
  13. 2
      app/src/main/java/io/legado/app/utils/JsUtils.kt

@ -211,7 +211,8 @@ dependencies {
implementation(project(path: ':epublib'))
//JS rhino
implementation('com.github.gedoor:rhino-android:1.8')
//implementation('com.github.gedoor:rhino-android:1.8')
implementation(fileTree(dir: 'lib', include: ['*.jar', '*.aar']))
//
implementation('com.squareup.okhttp3:okhttp:4.9.3')

Binary file not shown.

@ -14,6 +14,19 @@
**2022/04/21**
* 修复一些bug
* 更新js库
```
实现 ES6 Object.values Object.entries Object.fromEntries
实现 ES2017 Object.getOwnPropertyDescriptors
添加:支持“catch”中的可选变量绑定
添加:反单引号里`${}`语法支持(用于字符串连接)
添加:equals (==) 等号的支持
添加:NativeArray.subList()
添加:Object.hasOwn
修复:(for of)导出字符串 of前无空格导致语法错误问题
其他一些优化
```
**2022/04/17**

@ -3,12 +3,11 @@ package io.legado.app.constant
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.provider.Settings
import com.script.javascript.RhinoScriptEngine
import io.legado.app.BuildConfig
import io.legado.app.R
import splitties.init.appCtx
import java.text.SimpleDateFormat
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
@SuppressLint("SimpleDateFormat")
object AppConst {
@ -23,8 +22,8 @@ object AppConst {
const val MAX_THREAD = 9
val SCRIPT_ENGINE: ScriptEngine by lazy {
ScriptEngineManager().getEngineByName("rhino")
val SCRIPT_ENGINE: RhinoScriptEngine by lazy {
RhinoScriptEngine()
}
val timeFormat: SimpleDateFormat by lazy {

@ -1,6 +1,7 @@
package io.legado.app.data.entities
import android.util.Base64
import com.script.SimpleBindings
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppLog
import io.legado.app.data.entities.rule.RowUi
@ -9,7 +10,6 @@ import io.legado.app.help.JsExtensions
import io.legado.app.help.config.AppConfig
import io.legado.app.help.http.CookieStore
import io.legado.app.utils.*
import javax.script.SimpleBindings
/**
* 可在js里调用,source.xxx()

@ -2,6 +2,7 @@ package io.legado.app.model.analyzeRule
import android.text.TextUtils
import androidx.annotation.Keep
import com.script.SimpleBindings
import io.legado.app.constant.AppConst.SCRIPT_ENGINE
import io.legado.app.constant.AppPattern.JS_PATTERN
import io.legado.app.data.entities.*
@ -13,10 +14,8 @@ import io.legado.app.utils.*
import kotlinx.coroutines.runBlocking
import org.jsoup.nodes.Entities
import org.mozilla.javascript.NativeObject
import java.net.URL
import java.util.regex.Pattern
import javax.script.SimpleBindings
/**
* 解析规则获取结果

@ -5,6 +5,7 @@ import android.util.Base64
import androidx.annotation.Keep
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.LazyHeaders
import com.script.SimpleBindings
import io.legado.app.constant.AppConst.SCRIPT_ENGINE
import io.legado.app.constant.AppConst.UA_NAME
import io.legado.app.constant.AppPattern.JS_PATTERN
@ -24,7 +25,6 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import java.net.URLEncoder
import java.util.regex.Pattern
import javax.script.SimpleBindings
/**
* Created by GKF on 2018/1/24.

@ -2,6 +2,7 @@ package io.legado.app.model.localBook
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import com.script.SimpleBindings
import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.data.appDb
@ -17,7 +18,6 @@ import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.InputStream
import java.util.regex.Pattern
import javax.script.SimpleBindings
object LocalBook {

@ -2,6 +2,7 @@ package io.legado.app.service
import android.content.Intent
import androidx.core.app.NotificationCompat
import com.script.ScriptException
import io.legado.app.R
import io.legado.app.base.BaseService
import io.legado.app.constant.AppConst
@ -28,7 +29,6 @@ import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.launch
import org.mozilla.javascript.WrappedException
import java.util.concurrent.Executors
import javax.script.ScriptException
import kotlin.math.min
/**

@ -6,6 +6,7 @@ import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.PlaybackException
import com.google.android.exoplayer2.Player
import com.script.ScriptException
import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
@ -25,7 +26,6 @@ import java.io.File
import java.net.ConnectException
import java.net.SocketTimeoutException
import java.util.*
import javax.script.ScriptException
/**
* 在线朗读

@ -9,6 +9,7 @@ import androidx.lifecycle.MutableLiveData
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.script.SimpleBindings
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppConst
@ -33,7 +34,6 @@ import java.io.File
import java.io.FileOutputStream
import java.nio.charset.Charset
import java.util.concurrent.ConcurrentHashMap
import javax.script.SimpleBindings
class CacheViewModel(application: Application) : BaseViewModel(application) {

@ -69,7 +69,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
return super.onCompatOptionsItemSelected(item)
}
@SuppressLint("JavascriptInterface")
@SuppressLint("JavascriptInterface", "SetJavaScriptEnabled")
private fun initWebView(url: String, headerMap: HashMap<String, String>) {
binding.webView.webChromeClient = CustomWebChromeClient()
binding.webView.webViewClient = CustomWebViewClient()
@ -100,11 +100,11 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
}
return@setOnLongClickListener false
}
binding.webView.setDownloadListener { url, _, contentDisposition, _, _ ->
var fileName = URLUtil.guessFileName(url, contentDisposition, null)
binding.webView.setDownloadListener { downloadUrl, _, contentDisposition, _, _ ->
var fileName = URLUtil.guessFileName(downloadUrl, contentDisposition, null)
fileName = URLDecoder.decode(fileName, "UTF-8")
binding.llView.longSnackbar(fileName, getString(R.string.action_download)) {
Download.start(this, url, fileName)
Download.start(this, downloadUrl, fileName)
}
}
}
@ -206,6 +206,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
return true
}
@Deprecated("Deprecated in Java")
@Suppress("DEPRECATION")
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
url?.let {

@ -1,8 +1,8 @@
package io.legado.app.utils
import com.script.SimpleBindings
import io.legado.app.constant.AppConst.SCRIPT_ENGINE
import io.legado.app.constant.AppPattern.EXP_PATTERN
import javax.script.SimpleBindings
object JsUtils {

Loading…
Cancel
Save