mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 06:43:08 +00:00
Refactored Loon resource parser
This commit is contained in:
1 parent
7b4f75fddc
commit
bbfd139ec8
7 files changed
+79
-21
No files matched your search
+1
-1
@@ -87,7 +87,7 @@ out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
# dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* ███████╗██╗ ██╗██████╗ ███████╗████████╗ ██████╗ ██████╗ ███████╗
|
||||
* ██╔════╝██║ ██║██╔══██╗ ██╔════╝╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝
|
||||
* ███████╗██║ ██║██████╔╝█████╗███████╗ ██║ ██║ ██║██████╔╝█████╗
|
||||
* ╚════██║██║ ██║██╔══██╗╚════╝╚════██║ ██║ ██║ ██║██╔══██╗██╔══╝
|
||||
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
|
||||
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
|
||||
* @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
|
||||
*/
|
||||
|
||||
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return i(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|c(e,n),i=t(o),a=i.write(e,n);return a!==o&&(i=i.slice(0,a)),i}(e,n);if(ArrayBuffer.isView(e))return a(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(P(e,ArrayBuffer)||e&&P(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return r.from(i,n,o);var u=function(e){if(r.isBuffer(e)){var n=0|s(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||$(e.length)?t(0):a(e):"Buffer"===e.type&&Array.isArray(e.data)?a(e.data):void 0}(e);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function i(e){return o(e),t(e<0?0:0|s(e))}function a(e){for(var r=e.length<0?0:0|s(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function s(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function c(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return I(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(t).length;default:if(i)return o?-1:I(t).length;e=(""+e).toLowerCase(),i=!0}}function u(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function p(t,e,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),$(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:l(t,e,n,o,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):l(t,[e],n,o,i);throw new TypeError("val must be string, number or Buffer")}function l(t,e,r,n,o){var i,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var p=-1;for(i=r;i<s;i++)if(u(t,i)===u(e,-1===p?0:i-p)){if(-1===p&&(p=i),i-p+1===c)return p*a}else-1!==p&&(i-=i-p),p=-1}else for(r+c>s&&(r=s-c),i=r;i>=0;i--){for(var l=!0,f=0;f<c;f++)if(u(t,i+f)!==u(e,f)){l=!1;break}if(l)return i}return-1}function f(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if($(s))return a;t[r+a]=s}return a}function h(t,e,r,n){return N(I(e,t.length-r),t,r,n)}function d(t,e,r,n){return N(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return d(t,e,r,n)}function y(t,e,r,n){return N(k(e),t,r,n)}function m(t,e,r,n){return N(function(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)n=(r=t.charCodeAt(a))>>8Line truncated
|
||||
+31
-17
@@ -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": {
|
||||
|
||||
@@ -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);
|
||||
Vendored
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user