mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-04-20 12:49:33 +08:00
Refactored Loon resource parser
This commit is contained in:
parent
7ed08ef451
commit
e5c256803a
2
.gitignore
vendored
2
.gitignore
vendored
@ -87,7 +87,7 @@ out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
# dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
|
16
backend/dist/sub-store-parser.loon.min.js
vendored
Normal file
16
backend/dist/sub-store-parser.loon.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -7,8 +7,6 @@ import eslint from 'gulp-eslint-new';
|
||||
|
||||
import pkg from './package.json';
|
||||
|
||||
const DEST_FILE = 'sub-store.min.js';
|
||||
|
||||
export function lint() {
|
||||
return gulp
|
||||
.src('src/**/*.js')
|
||||
@ -32,23 +30,39 @@ export function styles() {
|
||||
.pipe(gulp.dest((file) => file.base));
|
||||
}
|
||||
|
||||
export function scripts() {
|
||||
return browserify('src/main.js')
|
||||
.transform('babelify', {
|
||||
presets: [ [ '@babel/preset-env' ] ]
|
||||
})
|
||||
.plugin('tinyify')
|
||||
.bundle()
|
||||
.pipe(fs.createWriteStream(DEST_FILE));
|
||||
function scripts(src, dest) {
|
||||
return () => {
|
||||
return browserify(src)
|
||||
.transform('babelify', {
|
||||
presets: [ [ '@babel/preset-env' ] ]
|
||||
})
|
||||
.plugin('tinyify')
|
||||
.bundle()
|
||||
.pipe(fs.createWriteStream(dest));
|
||||
};
|
||||
}
|
||||
|
||||
export function banner() {
|
||||
return gulp
|
||||
.src(DEST_FILE)
|
||||
.pipe(header(fs.readFileSync('./banner', 'utf-8'), { pkg, updated: new Date().toLocaleString() }))
|
||||
.pipe(gulp.dest((file) => file.base));
|
||||
function banner(dest) {
|
||||
return () => gulp
|
||||
.src(dest)
|
||||
.pipe(header(fs.readFileSync('./banner', 'utf-8'), { pkg, updated: new Date().toLocaleString() }))
|
||||
.pipe(gulp.dest((file) => file.base));
|
||||
}
|
||||
|
||||
const build = gulp.series(lint, styles, scripts, banner);
|
||||
const artifacts = [
|
||||
{ src: 'src/main.js', dest: 'sub-store.min.js' },
|
||||
{ src: 'src/products/resource-parser.loon.js', dest: 'dist/sub-store-parser.loon.min.js'}
|
||||
]
|
||||
|
||||
export default build;
|
||||
export const build = gulp.series(
|
||||
gulp.parallel(artifacts.map(artifact => scripts(artifact.src, artifact.dest))),
|
||||
gulp.parallel(artifacts.map(artifact => banner(artifact.dest)))
|
||||
);
|
||||
|
||||
const all = gulp.series(
|
||||
lint,
|
||||
styles,
|
||||
build
|
||||
)
|
||||
|
||||
export default all;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "1.5.1",
|
||||
"version": "1.6",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
20
backend/src/products/resource-parser.loon.js
Normal file
20
backend/src/products/resource-parser.loon.js
Normal file
@ -0,0 +1,20 @@
|
||||
/* eslint-disable no-undef */
|
||||
import { ProxyUtils } from '../core/proxy-utils';
|
||||
import { RuleUtils } from '../core/rule-utils';
|
||||
|
||||
const RESOURCE_TYPE = {
|
||||
PROXY: 1,
|
||||
RULE: 2,
|
||||
};
|
||||
|
||||
let result = $resource;
|
||||
|
||||
if ($resourceType === RESOURCE_TYPE.PROXY) {
|
||||
const proxies = ProxyUtils.parse($resource);
|
||||
result = ProxyUtils.produce(proxies, 'Loon');
|
||||
} else if ($resourceType === RESOURCE_TYPE.RULE) {
|
||||
const rules = RuleUtils.parse($resource);
|
||||
result = RuleUtils.produce(rules, 'Loon');
|
||||
}
|
||||
|
||||
$done(result);
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
@ -6,8 +6,8 @@
|
||||
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
|
||||
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
|
||||
* @updated: 2022/5/25 下午5:13:43
|
||||
* @version: 1.5.1
|
||||
* @updated: 2022/5/25 下午6:14:57
|
||||
* @version: 1.6
|
||||
* @author: Peng-YM
|
||||
* @github: https://github.com/Peng-YM/Sub-Store
|
||||
* @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46
|
||||
|
8
config/Loon-Resource-Parser.plugin
Normal file
8
config/Loon-Resource-Parser.plugin
Normal file
@ -0,0 +1,8 @@
|
||||
#!name=Sub-Store 资源解析器
|
||||
#!desc=Sub-Store 资源解析器 for Loon
|
||||
#!author=Peng-YM
|
||||
#!homepage=https://github.com/Peng-YM/Sub-Store
|
||||
#!icon=https://raw.githubusercontent.com/58xinian/icon/master/Sub-Store1.png
|
||||
|
||||
[General]
|
||||
resource-parser = https://raw.githubusercontent.com/Peng-YM/Sub-Store/master/backend/dist/sub-store-parser.loon.min.js
|
Loading…
x
Reference in New Issue
Block a user