Skip to content

Commit

Permalink
⬆️ 升级依赖、处理babel
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jan 24, 2022
1 parent 4df67fa commit ab7bc9b
Show file tree
Hide file tree
Showing 26 changed files with 2,006 additions and 1,416 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/build
/node_modules
.eslintrc.js
webpack.*
/scripts
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ module.exports = {
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unsafe-assignment": ["off"],
"@typescript-eslint/no-implied-eval": ["off"],

"@typescript-eslint/no-this-alias": [
"error",
{
"allowDestructuring": false, // Disallow `const { props, state } = this`; true by default
"allowedNames": ["self"] // Allow `const self = this`; `[]` by default
}
]
// '@typescript-eslint/no-unsafe-return': ['off'],
// '@typescript-eslint/no-unsafe-call': ['off'],
// '@typescript-eslint/no-empty-function': ['off'],
Expand Down
11 changes: 10 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"presets": [
"@vue/babel-preset-jsx",
"@babel/preset-env",
[
"@babel/preset-env",
{
"targets": {
"chrome": "67"
},
"useBuiltIns": "usage",
"corejs": "3.18"
}
],
"@babel/preset-typescript"
],
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion build/scriptcat/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ScriptCat",
"version": "0.8.2",
"version": "0.9.0",
"description": "脚本猫,一个用户脚本的框架,可编写脚本每天帮你自动处理事务.",
"background": {
"page": "background.html"
Expand Down
3,137 changes: 1,850 additions & 1,287 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,35 @@
"dependencies": {
"adm-zip": "^0.5.3",
"axios": "^0.21.1",
"buffer": "^4.9.2",
"core-js": "^3.20.3",
"cron": "^1.8.2",
"crypto-js": "^4.0.0",
"dayjs": "^1.10.4",
"dexie": "^3.0.3",
"dexie": "^3.2.0",
"file-saver": "^2.0.5",
"jszip": "^3.7.1",
"monaco-editor": "^0.22.3",
"monaco-editor": "^0.31.1",
"reflect-metadata": "^0.1.13",
"sortablejs": "^1.14.0",
"uuid": "^8.3.2",
"vue": "^2.6.12",
"vue-i18n": "^8.24.1",
"vue-router": "^3.5.1",
"vuetify": "^2.4.5",
"vuetify": "^2.6.2",
"vuetify-dialog-promise": "^2.4.2",
"vuex": "^3.6.2",
"vuex-module-decorators": "^1.0.1",
"yaml": "^1.10.2"
},
"devDependencies": {
"@babel/core": "^7.13.10",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@babel/preset-typescript": "^7.13.0",
"@babel/register": "^7.13.8",
"@babel/core": "^7.16.12",
"@babel/plugin-transform-runtime": "^7.16.10",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@babel/register": "^7.16.8",
"@mdi/js": "^5.9.55",
"@types/adm-zip": "^0.4.34",
"@types/chrome": "0.0.127",
"@types/chrome": "0.0.176",
"@types/cron": "^1.7.2",
"@types/crypto-js": "^4.0.1",
"@types/file-saver": "^2.0.3",
Expand Down Expand Up @@ -84,7 +84,7 @@
"style-loader": "^2.0.0",
"ts-jest": "^27.0.7",
"ts-loader": "^8.3.0",
"typescript": "^4.1.3",
"typescript": "^4.5.5",
"vue-class-component": "^7.2.6",
"vue-loader": "^15.9.8",
"vue-property-decorator": "^9.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/apps/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ExtVersion = '0.8.2';
export const ExtVersion = '0.9.0';

export const Server = process.env.NODE_ENV == 'production' ? 'https://sc.icodef.com/' : 'http://localhost:8080/';

Expand Down
10 changes: 5 additions & 5 deletions src/apps/grant/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export class BackgroundGrant {
const item = list.pop();
if (item) {
void App.Cache.set('confirm:info:' + item.uuid, [item, list.length]);
chrome.tabs.create({ url: chrome.runtime.getURL('confirm.html?uuid=' + item.uuid) });
void chrome.tabs.create({ url: chrome.runtime.getURL('confirm.html?uuid=' + item.uuid) });
} else {
void App.Cache.del('confirm:window:' + confirm.permission + ':list:' + script.id.toString());
}
Expand Down Expand Up @@ -484,7 +484,7 @@ export class BackgroundGrant {
if (xhr.response instanceof ArrayBuffer) {
respond.response = URL.createObjectURL(new Blob([xhr.response]));
} else {
respond.response = URL.createObjectURL(xhr.response);
respond.response = URL.createObjectURL(<Blob>xhr.response);
}
setTimeout(() => {
URL.revokeObjectURL(<string>respond.response);
Expand Down Expand Up @@ -832,7 +832,7 @@ export class BackgroundGrant {
@BackgroundGrant.GMFunction({ default: true })
protected GM_closeInTab(grant: Grant): Promise<any> {
return new Promise(resolve => {
chrome.tabs.remove(<number>grant.params[0]);
void chrome.tabs.remove(<number>grant.params[0]);
resolve(undefined);
})
}
Expand Down Expand Up @@ -889,9 +889,9 @@ export class BackgroundGrant {
return reject('param is null');
}
const details: GM_Types.NotificationDetails = params[0];
const options: chrome.notifications.NotificationOptions = {
const options: chrome.notifications.NotificationOptions<true> = {
title: details.title || 'ScriptCat',
message: details.text,
message: details.text || '无消息内容',
iconUrl: details.image || getIcon(script) || chrome.runtime.getURL('assets/logo.png'),
type: (isFirefox() || details.progress === undefined) ? 'basic' : 'progress',
};
Expand Down
25 changes: 25 additions & 0 deletions src/apps/logger/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { LOGGER_LEVEL, LOGGER_LEVEL_DEBUG, LOGGER_LEVEL_ERROR, LOGGER_LEVEL_INFO, LOGGER_LEVEL_WARN } from '@App/model/do/logger';
import { Logger } from './logger';

export class ConsoleLogger implements Logger {
public Logger(level: LOGGER_LEVEL, origin: string, msg: string, title = ''): Logger {
console.log({ level: level, origin: origin, msg: msg, title: title });
return this;
}

public Debug(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_DEBUG, origin, msg, title);
}

public Info(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_INFO, origin, msg, title);
}

public Warn(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_WARN, origin, msg, title);
}

public Error(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_ERROR, origin, msg, title);
}
}
41 changes: 41 additions & 0 deletions src/apps/logger/dblogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Log, LOGGER_LEVEL, LOGGER_LEVEL_ERROR, LOGGER_LEVEL_INFO, LOGGER_LEVEL_WARN } from '@App/model/do/logger';
import { LoggerModel } from '@App/model/logger';
import { Logger } from './logger';

export class DBLogger implements Logger {
public logger = new LoggerModel();

public Logger(level: LOGGER_LEVEL, origin: string, msg: string, title = '', scriptId?: number): Logger {
const log: Log = {
id: 0,
level: level,
message: msg,
origin: origin,
title: title,
createtime: new Date().getTime(),
};
if (scriptId) {
log.scriptId = scriptId;
}
void this.logger.save(log);
return this;
}

public Debug(origin: string, msg: string, title = '', scriptId?: number): Logger {
console.log(origin + '-' + title + ': ' + msg, scriptId);
return this;
// return this.Logger(LOGGER_LEVEL_DEBUG, origin, msg, title);
}

public Info(origin: string, msg: string, title = '', scriptId?: number): Logger {
return this.Logger(LOGGER_LEVEL_INFO, origin, msg, title, scriptId);
}

public Warn(origin: string, msg: string, title = '', scriptId?: number): Logger {
return this.Logger(LOGGER_LEVEL_WARN, origin, msg, title, scriptId);
}

public Error(origin: string, msg: string, title = '', scriptId?: number): Logger {
return this.Logger(LOGGER_LEVEL_ERROR, origin, msg, title, scriptId);
}
}
63 changes: 1 addition & 62 deletions src/apps/logger/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LOGGER_LEVEL, Log, LOGGER_LEVEL_INFO, LOGGER_LEVEL_WARN, LOGGER_LEVEL_ERROR, LOGGER_LEVEL_DEBUG } from '@App/model/do/logger';
import { LoggerModel } from '@App/model/logger';
import { LOGGER_LEVEL } from '@App/model/do/logger';

export interface Logger {
// todo 可以改造为可调用实例
Expand All @@ -19,63 +18,3 @@ export interface Logger {
message?: string;
createtime?: Date;
}
export class DBLogger implements Logger {
public logger = new LoggerModel();

public Logger(level: LOGGER_LEVEL, origin: string, msg: string, title = '', scriptId?: number): Logger {
const log: Log = {
id: 0,
level: level,
message: msg,
origin: origin,
title: title,
createtime: new Date().getTime(),
};
if (scriptId) {
log.scriptId = scriptId;
}
this.logger.save(log);
return this;
}

public Debug(origin: string, msg: string, title = '', scriptId?: number): Logger {
console.log(origin + '-' + title + ': ' + msg, scriptId);
return this;
// return this.Logger(LOGGER_LEVEL_DEBUG, origin, msg, title);
}

public Info(origin: string, msg: string, title = '', scriptId?: number): Logger {
return this.Logger(LOGGER_LEVEL_INFO, origin, msg, title, scriptId);
}

public Warn(origin: string, msg: string, title = '', scriptId?: number): Logger {
return this.Logger(LOGGER_LEVEL_WARN, origin, msg, title, scriptId);
}

public Error(origin: string, msg: string, title = '', scriptId?: number): Logger {
return this.Logger(LOGGER_LEVEL_ERROR, origin, msg, title, scriptId);
}
}

export class ConsoleLogger implements Logger {
public Logger(level: LOGGER_LEVEL, origin: string, msg: string, title = ''): Logger {
console.log({ level: level, origin: origin, msg: msg, title: title });
return this;
}

public Debug(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_DEBUG, origin, msg, title);
}

public Info(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_INFO, origin, msg, title);
}

public Warn(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_WARN, origin, msg, title);
}

public Error(origin: string, msg: string, title = ''): Logger {
return this.Logger(LOGGER_LEVEL_ERROR, origin, msg, title);
}
}
1 change: 1 addition & 0 deletions src/apps/script/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { ResourceManager } from '../resource';
import { compileScriptCode } from '@App/pkg/sandbox/compile';
import { SubscribeModel } from '@App/model/subscribe';
import { Subscribe, SUBSCRIBE_STATUS_DISABLE, SUBSCRIBE_STATUS_ENABLE } from '@App/model/do/subscribe';
import Dexie from 'dexie';

// 脚本控制器,发送或者接收来自管理器的消息,并不对脚本数据做实际的处理
export class ScriptController {
Expand Down
1 change: 1 addition & 0 deletions src/apps/script/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { SyncAction, SyncData } from '@App/model/do/sync';
import { v4 as uuidv4 } from 'uuid';
import { Manager } from '@App/pkg/apps/manager';
import { SystemConfig } from '@App/pkg/config';
import Dexie from 'dexie';

// 脚本管理器,收到控制器消息进行实际的操作
export class ScriptManager extends Manager {
Expand Down
3 changes: 2 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { MultiGrantListener } from '@App/apps/grant/utils';
import { Logger } from './apps/msg-center/event';
import { SystemConfig } from './pkg/config';
import { App, ENV_BACKGROUND, InitApp } from './apps/app';
import { DBLogger } from './apps/logger/logger';
import { migrate } from './model/migrate';
import { SCRIPT_STATUS_ENABLE, Script, SCRIPT_STATUS_DISABLE } from './model/do/script';
import { MapCache } from './pkg/storage/cache/cache';
Expand All @@ -14,6 +13,8 @@ import { Server } from './apps/config';
import { Subscribe, SUBSCRIBE_STATUS_ENABLE } from './model/do/subscribe';
import { UserManager } from './apps/user/manager';
import { ToolsManager } from './apps/tools/manager';
import Dexie from 'dexie';
import { DBLogger } from './apps/logger/dblogger';

migrate();

Expand Down
3 changes: 1 addition & 2 deletions src/confirm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'reflect-metadata';
import Vue from 'vue';
import Vuetify from 'vuetify';

Expand All @@ -7,8 +6,8 @@ import 'vuetify/dist/vuetify.min.css';
import Confirm from '@App/views/pages/Confirm/index.vue';
import { ENV_FRONTEND, InitApp } from './apps/app';
import { SystemCache } from './pkg/storage/cache/system-cache';
import { DBLogger } from './apps/logger/logger';
import { migrate } from './model/migrate';
import { DBLogger } from './apps/logger/dblogger';

migrate();

Expand Down
3 changes: 1 addition & 2 deletions src/import.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'reflect-metadata';
import 'vuetify/dist/vuetify.min.css';
import Vue from 'vue';
import { i18n, vuetify } from '../i18n/i18n';
import App from '@App/views/pages/Import/index.vue';
import { migrate } from './model/migrate';

import { ENV_FRONTEND, InitApp } from './apps/app';
import { DBLogger } from './apps/logger/logger';
import { SystemCache } from './pkg/storage/cache/system-cache';
import { DBLogger } from './apps/logger/dblogger';

migrate();

Expand Down
3 changes: 1 addition & 2 deletions src/install.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'reflect-metadata';
import 'vuetify/dist/vuetify.min.css';
import Vue from 'vue';
import Vuetify from 'vuetify';
Expand All @@ -7,9 +6,9 @@ import App from '@App/views/pages/Install/index.vue';
import { migrate } from './model/migrate';

import { ENV_FRONTEND, InitApp } from './apps/app';
import { DBLogger } from './apps/logger/logger';
import { SystemCache } from './pkg/storage/cache/system-cache';
import { registerEditorPrompt } from './pkg/utils/editor';
import { DBLogger } from './apps/logger/dblogger';

migrate();

Expand Down
3 changes: 1 addition & 2 deletions src/options.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'reflect-metadata';
import 'vuetify/dist/vuetify.min.css';

import Vue from 'vue';
Expand All @@ -10,11 +9,11 @@ import VuetifyDialogPromise from 'vuetify-dialog-promise';
import { i18n, vuetify } from '../i18n/i18n';
import { migrate } from './model/migrate';
import store from '@Option/store';
import { DBLogger } from './apps/logger/logger';
import { MapCache } from './pkg/storage/cache/cache';
import { ENV_FRONTEND, InitApp } from './apps/app';
import { SystemConfig } from './pkg/config';
import { registerEditorPrompt } from './pkg/utils/editor';
import { DBLogger } from './apps/logger/dblogger';

migrate();

Expand Down
2 changes: 1 addition & 1 deletion src/pkg/storage/cache/system-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class SystemCache extends MapCache implements ICache {
try {
MsgCenter.connect(SystemCacheEvent, { msg: [event, key, data, oldData] });
} catch (e) {
console.log(e.message);
console.log(e);
}
}
}
Expand Down
Loading

0 comments on commit ab7bc9b

Please sign in to comment.