feat: 🚀 Update dependencies to support ESM

This commit is contained in:
viarotel 2024-05-08 11:02:00 +08:00
parent 8460945bd6
commit 9f1696f289
16 changed files with 394 additions and 95 deletions

View File

@ -1,7 +0,0 @@
.github
.gitignore
.vscode
node_modules
dist
dist-electron
dist-release

View File

@ -0,0 +1,84 @@
{
"globals": {
"Component": true,
"ComponentPublicInstance": true,
"ComputedRef": true,
"EffectScope": true,
"ExtractDefaultPropTypes": true,
"ExtractPropTypes": true,
"ExtractPublicPropTypes": true,
"InjectionKey": true,
"PropType": true,
"Ref": true,
"VNode": true,
"WritableComputedRef": true,
"acceptHMRUpdate": true,
"computed": true,
"createApp": true,
"createPinia": true,
"customRef": true,
"defineAsyncComponent": true,
"defineComponent": true,
"defineStore": true,
"effectScope": true,
"getActivePinia": true,
"getCurrentInstance": true,
"getCurrentScope": true,
"h": true,
"inject": true,
"isProxy": true,
"isReactive": true,
"isReadonly": true,
"isRef": true,
"mapActions": true,
"mapGetters": true,
"mapState": true,
"mapStores": true,
"mapWritableState": true,
"markRaw": true,
"nextTick": true,
"onActivated": true,
"onBeforeMount": true,
"onBeforeRouteLeave": true,
"onBeforeRouteUpdate": true,
"onBeforeUnmount": true,
"onBeforeUpdate": true,
"onDeactivated": true,
"onErrorCaptured": true,
"onMounted": true,
"onRenderTracked": true,
"onRenderTriggered": true,
"onScopeDispose": true,
"onServerPrefetch": true,
"onUnmounted": true,
"onUpdated": true,
"provide": true,
"reactive": true,
"readonly": true,
"ref": true,
"resolveComponent": true,
"setActivePinia": true,
"setMapStoreSuffix": true,
"shallowReactive": true,
"shallowReadonly": true,
"shallowRef": true,
"storeToRefs": true,
"toRaw": true,
"toRef": true,
"toRefs": true,
"toValue": true,
"triggerRef": true,
"unref": true,
"useAttrs": true,
"useCssModule": true,
"useCssVars": true,
"useLink": true,
"useRoute": true,
"useRouter": true,
"useSlots": true,
"watch": true,
"watchEffect": true,
"watchPostEffect": true,
"watchSyncEffect": true
}
}

View File

@ -1,27 +0,0 @@
module.exports = {
extends: ['@antfu'],
rules: {
'antfu/top-level-function': 'off',
'no-unused-vars': 'off',
'eqeqeq': 'off',
'prefer-promise-reject-errors': 'off',
'no-new-func': 'off',
'curly': 'off',
'no-console': 'off',
'unused-imports/no-unused-vars': 'off',
'import/default': 'off',
'vue/no-mutating-props': 'off',
'vue/no-use-v-if-with-v-for': 'off',
'vue/html-self-closing': 'off',
'vue/block-order': 'off',
'vue/no-unused-refs': 'off',
'vue/component-tags-order': 'off',
'n/prefer-global/process': 'off',
'@typescript-eslint/no-invalid-this': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
}

83
auto-imports.d.ts vendored Normal file
View File

@ -0,0 +1,83 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const createPinia: typeof import('pinia')['createPinia']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const defineStore: typeof import('pinia')['defineStore']
const effectScope: typeof import('vue')['effectScope']
const getActivePinia: typeof import('pinia')['getActivePinia']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const mapActions: typeof import('pinia')['mapActions']
const mapGetters: typeof import('pinia')['mapGetters']
const mapState: typeof import('pinia')['mapState']
const mapStores: typeof import('pinia')['mapStores']
const mapWritableState: typeof import('pinia')['mapWritableState']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onMounted: typeof import('vue')['onMounted']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const setActivePinia: typeof import('pinia')['setActivePinia']
const setMapStoreSuffix: typeof import('pinia')['setMapStoreSuffix']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const storeToRefs: typeof import('pinia')['storeToRefs']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useLink: typeof import('vue-router')['useLink']
const useRoute: typeof import('vue-router')['useRoute']
const useRouter: typeof import('vue-router')['useRouter']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
}
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}

78
components.d.ts vendored Normal file
View File

@ -0,0 +1,78 @@
/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
About: typeof import('./src/components/About/index.vue')['default']
AppInstall: typeof import('./src/components/Device/components/ControlBar/AppInstall/index.vue')['default']
AudioCodecSelect: typeof import('./src/components/Preference/components/AudioCodecSelect/index.vue')['default']
Camera: typeof import('./src/components/Device/components/MoreDropdown/components/Camera/index.vue')['default']
ControlBar: typeof import('./src/components/Device/components/ControlBar/index.vue')['default']
Device: typeof import('./src/components/Device/index.vue')['default']
DisplaySelect: typeof import('./src/components/Preference/components/DisplaySelect/index.vue')['default']
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
ElButton: typeof import('element-plus/es')['ElButton']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElIconCaretLeft: typeof import('@element-plus/icons-vue')['CaretLeft']
ElIconCaretRight: typeof import('@element-plus/icons-vue')['CaretRight']
ElIconClose: typeof import('@element-plus/icons-vue')['Close']
ElIconCloseBold: typeof import('@element-plus/icons-vue')['CloseBold']
ElIconEditPen: typeof import('@element-plus/icons-vue')['EditPen']
ElIconLoading: typeof import('@element-plus/icons-vue')['Loading']
ElIconOperation: typeof import('@element-plus/icons-vue')['Operation']
ElIconQuestionFilled: typeof import('@element-plus/icons-vue')['QuestionFilled']
ElIconWarningFilled: typeof import('@element-plus/icons-vue')['WarningFilled']
ElInput: typeof import('element-plus/es')['ElInput']
ElLink: typeof import('element-plus/es')['ElLink']
ElOption: typeof import('element-plus/es')['ElOption']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
FileManage: typeof import('./src/components/Device/components/ControlBar/FileManage/index.vue')['default']
Gnirehtet: typeof import('./src/components/Device/components/ControlBar/Gnirehtet/index.vue')['default']
KeyboardInjectSelect: typeof import('./src/components/Preference/components/KeyboardInjectSelect/index.vue')['default']
LanguageSelect: typeof import('./src/components/Preference/components/LanguageSelect/index.vue')['default']
LoadingIcon: typeof import('./src/components/Device/components/LoadingIcon/index.vue')['default']
MirrorAction: typeof import('./src/components/Device/components/MirrorAction/index.vue')['default']
MirrorGroup: typeof import('./src/components/Device/components/ControlBar/MirrorGroup/index.vue')['default']
MoreDropdown: typeof import('./src/components/Device/components/MoreDropdown/index.vue')['default']
Otg: typeof import('./src/components/Device/components/MoreDropdown/components/Otg/index.vue')['default']
PairDialog: typeof import('./src/components/Device/components/Wireless/PairDialog/index.vue')['default']
PathInput: typeof import('./src/components/Preference/components/PathInput/index.vue')['default']
Preference: typeof import('./src/components/Preference/index.vue')['default']
Record: typeof import('./src/components/Device/components/MoreDropdown/components/Record/index.vue')['default']
Remark: typeof import('./src/components/Device/components/Remark/index.vue')['default']
Rotation: typeof import('./src/components/Device/components/ControlBar/Rotation/index.vue')['default']
Screenshot: typeof import('./src/components/Device/components/ControlBar/Screenshot/index.vue')['default']
TerminalAction: typeof import('./src/components/Device/components/TerminalAction/index.vue')['default']
TerminalDialog: typeof import('./src/components/Device/components/TerminalAction/components/TerminalDialog/index.vue')['default']
VideoCodecSelect: typeof import('./src/components/Preference/components/VideoCodecSelect/index.vue')['default']
Volume: typeof import('./src/components/Device/components/ControlBar/Volume/index.vue')['default']
Wireless: typeof import('./src/components/Device/components/Wireless/index.vue')['default']
WirelessAction: typeof import('./src/components/Device/components/WirelessAction/index.vue')['default']
}
export interface ComponentCustomProperties {
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
}
}

View File

@ -1,8 +1,10 @@
import { app, ipcMain } from 'electron'
import { is } from '@electron-toolkit/utils'
import { autoUpdater } from 'electron-updater'
import electronUpdater from 'electron-updater'
import { devPublishPath } from '@electron/configs/index.js'
const { autoUpdater } = electronUpdater
export default (mainWindow) => {
if (is.dev) {
autoUpdater.updateConfigPath = devPublishPath

View File

@ -1,4 +1,4 @@
import log from 'electron-log/main'
import log from 'electron-log/main.js'
import { createProxy } from '@electron/helpers/index'
const levels = Object.keys(log.functions)

View File

@ -1,5 +1,5 @@
import { shell } from 'electron'
import log from 'electron-log/main'
import log from 'electron-log/main.js'
import { createProxy } from '@electron/helpers/index'
log.transports.console.level = false

View File

@ -1,4 +1,7 @@
import path from 'node:path'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import { BrowserWindow, app, shell } from 'electron'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import contextMenu from 'electron-context-menu'
@ -16,6 +19,9 @@ import events from './events/index.js'
// import copilot from './copilot/index.js'
const require = createRequire(import.meta.url)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
log.initialize({ preload: true })
const debug = !!appStore.get('common.debug')
@ -77,9 +83,8 @@ function createWindow() {
minHeight: 800,
autoHideMenuBar: true,
webPreferences: {
// nodeIntegration: true,
// contextIsolation: false,
preload: path.join(__dirname, './preload.js'),
preload: path.join(__dirname, 'preload.mjs'),
nodeIntegration: true,
sandbox: false,
spellcheck: false,
},

60
eslint.config.js Normal file
View File

@ -0,0 +1,60 @@
import { createRequire } from 'node:module'
import antfu from '@antfu/eslint-config'
const require = createRequire(import.meta.url)
const autoImport = require('./.eslintrc-auto-import.json')
export default antfu(
{
typescript: false,
markdown: false,
ignores: [
'.github',
'.vscode',
'node_modules',
'dist',
'dist-electron',
'dist-release',
],
},
{
languageOptions: {
globals: {
...autoImport.globals,
},
},
rules: {
'jsdoc/check-param-names': 'off',
'jsdoc/check-types': 'off',
'jsdoc/require-returns-description': 'off',
'antfu/consistent-list-newline': 'off',
'antfu/top-level-function': 'off',
'import/default': 'off',
'node/prefer-global/process': 'off',
'no-console': 'off',
'curly': 'off',
'eqeqeq': 'off',
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': 'off',
'no-debugger': 'off',
'no-restricted-syntax': 'off',
'no-new': 'off',
'prefer-promise-reject-errors': 'off',
'vue/html-self-closing': 'off',
'vue/block-order': 'off',
'vue/no-unused-refs': 'off',
'vue/no-mutating-props': 'off',
'vue/no-constant-condition': 'off',
'vue/eqeqeq': 'off',
'vue/custom-event-name-casing': 'off',
'vue/no-use-v-if-with-v-for': 'off',
'vue/component-tags-order': 'off',
},
},
)

View File

@ -1,5 +1,6 @@
{
"name": "escrcpy",
"type": "module",
"version": "1.18.4",
"private": true,
"description": "Scrcpy Powered by Electron",
@ -7,59 +8,60 @@
"homepage": "https://github.com/viarotel-org/escrcpy",
"main": "dist-electron/main.js",
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"dev": "vite",
"build": "vite build && electron-builder",
"build:win": "vite build && electron-builder --win",
"build:mac": "vite build && electron-builder --mac",
"build:linux": "vite build && electron-builder --linux",
"preview": "vite preview",
"lint": "eslint . --ignore-path .eslintignore",
"lint:fix": "eslint . --ignore-path .eslintignore --fix",
"svgo": "svgo --folder=src/icons/svgo --output=src/icons/svg --config=src/icons/svgo.config.js",
"postinstall": "electron-builder install-app-deps",
"prepare": "husky install"
},
"dependencies": {
"vue": "^3.3.6"
"vue": "^3.4.26"
},
"devDependencies": {
"@antfu/eslint-config": "^0.43.1",
"@devicefarmer/adbkit": "^3.2.5",
"@electron-toolkit/preload": "^2.0.0",
"@electron-toolkit/utils": "^2.0.1",
"@hono/node-server": "^1.2.3",
"@intlify/unplugin-vue-i18n": "^1.4.0",
"@unocss/reset": "^0.58.5",
"@unocss/transformer-directives": "^0.58.5",
"@antfu/eslint-config": "^2.16.1",
"@devicefarmer/adbkit": "^3.2.6",
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"@hono/node-server": "^1.11.1",
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@unocss/reset": "^0.59.4",
"@unocss/transformer-directives": "^0.59.4",
"@viarotel-org/unocss-preset-shades": "^0.8.2",
"@vitejs/plugin-vue": "^4.4.0",
"dayjs": "^1.11.10",
"electron": "^27.0.3",
"electron-builder": "^24.6.4",
"electron-context-menu": "^3.6.1",
"electron-log": "^5.0.0",
"electron-store": "^8.1.0",
"electron-updater": "^6.1.4",
"element-plus": "^2.4.2",
"@vitejs/plugin-vue": "^5.0.4",
"dayjs": "^1.11.11",
"electron": "^30.0.2",
"electron-builder": "^24.13.3",
"electron-context-menu": "^4.0.0",
"electron-log": "^5.1.2",
"electron-store": "^9.0.0",
"electron-updater": "^6.1.8",
"element-plus": "^2.7.2",
"eslint": "^9.2.0",
"fix-path": "^4.0.0",
"fs-extra": "^11.1.1",
"hono": "^3.10.1",
"husky": "^8.0.0",
"isomorphic-ws": "^5.0.0",
"fs-extra": "^11.2.0",
"hono": "^4.3.2",
"husky": "^9.0.11",
"lodash-es": "^4.17.21",
"pinia": "^2.1.7",
"postcss": "^8.4.31",
"postcss": "^8.4.38",
"postcss-nested": "^6.0.1",
"postcss-scss": "^4.0.9",
"typescript": "5.2.2",
"unocss": "^0.58.5",
"vite": "^4.5.0",
"vite-plugin-electron": "^0.14.1",
"unocss": "^0.59.4",
"unplugin-auto-import": "^0.17.5",
"unplugin-vue-components": "^0.27.0",
"vite": "^5.2.11",
"vite-plugin-electron": "^0.28.7",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-svg-loader": "^4.0.0",
"vite-svg-loader": "^5.1.0",
"vue-command": "^35.2.1",
"vue-i18n": "^9.5.0",
"vue-i18n": "^9.13.1",
"which": "^4.0.0",
"ws": "^8.14.2"
"ws": "^8.17.0"
}
}

21
src/plugins/auto.js Normal file
View File

@ -0,0 +1,21 @@
import useAutoImport from 'unplugin-auto-import/vite'
import useAutoComponents from 'unplugin-vue-components/vite'
import ElementPlus from './element-plus/auto.js'
const resolvers = [ElementPlus()]
export default () => {
return [
useAutoImport({
resolvers,
imports: ['vue', 'vue-router', 'pinia'],
eslintrc: {
enabled: true,
},
}),
useAutoComponents({
resolvers,
}),
]
}

View File

@ -0,0 +1,3 @@
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default ElementPlusResolver

View File

@ -1,15 +1,11 @@
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import './restyle.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import * as ElementPlusIcons from '@element-plus/icons-vue'
export default {
install(app) {
app.use(ElementPlus, { size: 'default' })
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
for (const [key, component] of Object.entries(ElementPlusIcons)) {
app.component(key, component)
}
},

View File

@ -1,6 +1,6 @@
import { resolve } from 'node:path'
import { defineConfig, mergeConfig } from 'vite'
import useElectron from 'vite-plugin-electron'
import useElectron from 'vite-plugin-electron/simple'
import useRenderer from 'vite-plugin-electron-renderer'
import { notBundle } from 'vite-plugin-electron/plugin'
@ -9,7 +9,9 @@ import useUnoCSS from 'unocss/vite'
import useSvg from 'vite-svg-loader'
import useI18n from '@intlify/unplugin-vue-i18n/vite'
import postcssConfig from './postcss.config.mjs'
import postcssConfig from './postcss.config.js'
import useAutoImports from './src/plugins/auto.js'
const merge = (config, { command = '' } = {}) =>
mergeConfig(
@ -26,15 +28,14 @@ const merge = (config, { command = '' } = {}) =>
config,
)
// https://vitejs.dev/config/
export default params =>
export default args =>
merge(
defineConfig({
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
copilot: resolve(__dirname, 'copilot/index.html'),
main: resolve('index.html'),
copilot: resolve('copilot/index.html'),
},
},
},
@ -50,22 +51,20 @@ export default params =>
useSvg(),
useVue(),
useI18n({
include: [resolve(__dirname, './src/locales/languages/**')],
include: [resolve('src/locales/languages/**')],
}),
useElectron([
{
useElectron({
main: {
entry: 'electron/main.js',
vite: merge({}, params),
vite: merge({}, args),
},
{
entry: 'electron/preload.js',
onstart(args) {
args.reload()
},
vite: merge({}, params),
preload: {
input: 'electron/preload.js',
vite: merge({}, args),
},
]),
}),
useRenderer(),
...useAutoImports(),
],
css: {
postcss: postcssConfig,