From 164ae9a7a8940b3ca4687448540c604d2124edad Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 13 Jan 2024 13:40:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=AB=E6=8D=B7=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20await;=20=E8=84=9A=E6=9C=AC=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=94=AF=E6=8C=81=20produceArtifact?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../src/core/proxy-utils/processors/index.js | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend/package.json b/backend/package.json index cbd2979..2bf9d2e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.148", + "version": "2.14.149", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/processors/index.js b/backend/src/core/proxy-utils/processors/index.js index a96f909..ee04aac 100644 --- a/backend/src/core/proxy-utils/processors/index.js +++ b/backend/src/core/proxy-utils/processors/index.js @@ -7,6 +7,8 @@ import lodash from 'lodash'; import $ from '@/core/app'; import { hex_md5 } from '@/vendor/md5'; import { ProxyUtils } from '@/core/proxy-utils'; +import { produceArtifact } from '@/restful/sync'; + import env from '@/utils/env'; import { getFlowHeaders, parseFlowHeaders, flowTransfer } from '@/utils/flow'; @@ -319,11 +321,12 @@ function ScriptOperator(script, targetPlatform, $arguments, source) { `async function operator(input = []) { let proxies if (Array.isArray(input)) { - proxies = input - return proxies.map(($server = {}) => { + let list = [] + for await (let $server of input) { ${script} - return $server - }) + list.push($server) + } + return list } else { let { $content, $files } = input ${script} @@ -783,6 +786,7 @@ function createDynamicFunction(name, script, $arguments) { 'ProxyUtils', 'scriptResourceCache', 'flowUtils', + 'produceArtifact', `${script}\n return ${name}`, )( $arguments, @@ -797,6 +801,7 @@ function createDynamicFunction(name, script, $arguments) { ProxyUtils, scriptResourceCache, flowUtils, + produceArtifact, ); } else { return new Function( @@ -806,8 +811,17 @@ function createDynamicFunction(name, script, $arguments) { 'ProxyUtils', 'scriptResourceCache', 'flowUtils', + 'produceArtifact', `${script}\n return ${name}`, - )($arguments, $, lodash, ProxyUtils, scriptResourceCache, flowUtils); + )( + $arguments, + $, + lodash, + ProxyUtils, + scriptResourceCache, + flowUtils, + produceArtifact, + ); } }