Bug Fixed for reording multiple processors

This commit is contained in:
Peng-YM
2020-09-04 15:05:25 +08:00
parent 2e758ec7c8
commit 3ed39271b1
4 changed files with 144 additions and 89 deletions

View File

@@ -22,9 +22,8 @@
<list default="true" id="8b97a098-48b2-4e64-a9ef-522fe2d30b52" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sub-store.js" beforeDir="false" afterPath="$PROJECT_DIR$/sub-store.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/RegexFilter.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/RegexFilter.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/ScriptFilter.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/ScriptFilter.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/ScriptOperator.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/ScriptOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/SubEditor.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/SubEditor.vue" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -52,6 +51,7 @@
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="restartRequiresConfirmation" value="false" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
<component name="RunManager">
@@ -104,6 +104,7 @@
<workItem from="1599108801252" duration="5007000" />
<workItem from="1599123166646" duration="2000" />
<workItem from="1599123176701" duration="51000" />
<workItem from="1599137069057" duration="3450000" />
</task>
<servers />
</component>
@@ -123,55 +124,55 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state width="1322" height="302" key="GridCell.Tab.0.bottom" timestamp="1599121249077">
<state width="1322" height="340" key="GridCell.Tab.0.bottom" timestamp="1599203090695">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
<state width="850" height="374" key="GridCell.Tab.0.bottom/51.23.1741.1097@51.23.1741.1097" timestamp="1598805773766" />
<state width="849" height="374" key="GridCell.Tab.0.bottom/53.23.1739.1097@53.23.1739.1097" timestamp="1598865052766" />
<state width="850" height="374" key="GridCell.Tab.0.bottom/55.23.1737.1097@55.23.1737.1097" timestamp="1598850298702" />
<state width="1322" height="340" key="GridCell.Tab.0.bottom/55.23.1737.1097@55.23.1737.1097" timestamp="1599197609082" />
<state width="849" height="374" key="GridCell.Tab.0.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.0.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="840" height="374" key="GridCell.Tab.0.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266532" />
<state width="1322" height="302" key="GridCell.Tab.0.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249077" />
<state width="1322" height="302" key="GridCell.Tab.0.center" timestamp="1599121249077">
<state width="1322" height="340" key="GridCell.Tab.0.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090695" />
<state width="1322" height="340" key="GridCell.Tab.0.center" timestamp="1599203090694">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
<state width="850" height="374" key="GridCell.Tab.0.center/51.23.1741.1097@51.23.1741.1097" timestamp="1598805773766" />
<state width="849" height="374" key="GridCell.Tab.0.center/53.23.1739.1097@53.23.1739.1097" timestamp="1598865052765" />
<state width="850" height="374" key="GridCell.Tab.0.center/55.23.1737.1097@55.23.1737.1097" timestamp="1598850298701" />
<state width="1322" height="340" key="GridCell.Tab.0.center/55.23.1737.1097@55.23.1737.1097" timestamp="1599197609081" />
<state width="849" height="374" key="GridCell.Tab.0.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847574" />
<state width="849" height="374" key="GridCell.Tab.0.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="840" height="374" key="GridCell.Tab.0.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266532" />
<state width="1322" height="302" key="GridCell.Tab.0.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249077" />
<state width="1322" height="302" key="GridCell.Tab.0.left" timestamp="1599121249077">
<state width="1322" height="340" key="GridCell.Tab.0.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090694" />
<state width="1322" height="340" key="GridCell.Tab.0.left" timestamp="1599203090694">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
<state width="850" height="374" key="GridCell.Tab.0.left/51.23.1741.1097@51.23.1741.1097" timestamp="1598805773765" />
<state width="849" height="374" key="GridCell.Tab.0.left/53.23.1739.1097@53.23.1739.1097" timestamp="1598865052763" />
<state width="850" height="374" key="GridCell.Tab.0.left/55.23.1737.1097@55.23.1737.1097" timestamp="1598850298699" />
<state width="1322" height="340" key="GridCell.Tab.0.left/55.23.1737.1097@55.23.1737.1097" timestamp="1599197609081" />
<state width="849" height="374" key="GridCell.Tab.0.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847574" />
<state width="849" height="374" key="GridCell.Tab.0.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992683" />
<state width="840" height="374" key="GridCell.Tab.0.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266531" />
<state width="1322" height="302" key="GridCell.Tab.0.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249077" />
<state width="1322" height="302" key="GridCell.Tab.0.right" timestamp="1599121249077">
<state width="1322" height="340" key="GridCell.Tab.0.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090694" />
<state width="1322" height="340" key="GridCell.Tab.0.right" timestamp="1599203090694">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
<state width="850" height="374" key="GridCell.Tab.0.right/51.23.1741.1097@51.23.1741.1097" timestamp="1598805773766" />
<state width="849" height="374" key="GridCell.Tab.0.right/53.23.1739.1097@53.23.1739.1097" timestamp="1598865052766" />
<state width="850" height="374" key="GridCell.Tab.0.right/55.23.1737.1097@55.23.1737.1097" timestamp="1598850298701" />
<state width="1322" height="340" key="GridCell.Tab.0.right/55.23.1737.1097@55.23.1737.1097" timestamp="1599197609082" />
<state width="849" height="374" key="GridCell.Tab.0.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.0.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="840" height="374" key="GridCell.Tab.0.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.0.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598946266532" />
<state width="1322" height="302" key="GridCell.Tab.0.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249077" />
<state width="1322" height="302" key="GridCell.Tab.1.bottom" timestamp="1599121249078">
<state width="1322" height="340" key="GridCell.Tab.0.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090694" />
<state width="1322" height="577" key="GridCell.Tab.1.bottom" timestamp="1599203090628">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -182,8 +183,8 @@
<state width="849" height="374" key="GridCell.Tab.1.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1322" height="302" key="GridCell.Tab.1.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249078" />
<state width="1322" height="302" key="GridCell.Tab.1.center" timestamp="1599121249078">
<state width="1322" height="577" key="GridCell.Tab.1.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090628" />
<state width="1322" height="577" key="GridCell.Tab.1.center" timestamp="1599203090628">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -194,8 +195,8 @@
<state width="849" height="374" key="GridCell.Tab.1.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.1.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1322" height="302" key="GridCell.Tab.1.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249078" />
<state width="1322" height="302" key="GridCell.Tab.1.left" timestamp="1599121249077">
<state width="1322" height="577" key="GridCell.Tab.1.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090628" />
<state width="1322" height="577" key="GridCell.Tab.1.left" timestamp="1599203090627">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -206,8 +207,8 @@
<state width="849" height="374" key="GridCell.Tab.1.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.1.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593852" />
<state width="1322" height="302" key="GridCell.Tab.1.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249077" />
<state width="1322" height="302" key="GridCell.Tab.1.right" timestamp="1599121249078">
<state width="1322" height="577" key="GridCell.Tab.1.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090627" />
<state width="1322" height="577" key="GridCell.Tab.1.right" timestamp="1599203090628">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@@ -218,8 +219,8 @@
<state width="849" height="374" key="GridCell.Tab.1.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.1.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305944" />
<state width="840" height="374" key="GridCell.Tab.1.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1322" height="302" key="GridCell.Tab.1.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249078" />
<state width="1322" height="302" key="GridCell.Tab.2.bottom" timestamp="1599121249079">
<state width="1322" height="577" key="GridCell.Tab.1.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090628" />
<state width="1322" height="577" key="GridCell.Tab.2.bottom" timestamp="1599203090629">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@@ -230,8 +231,8 @@
<state width="849" height="374" key="GridCell.Tab.2.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.2.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="302" key="GridCell.Tab.2.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249079" />
<state width="1322" height="302" key="GridCell.Tab.2.center" timestamp="1599121249079">
<state width="1322" height="577" key="GridCell.Tab.2.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090629" />
<state width="1322" height="577" key="GridCell.Tab.2.center" timestamp="1599203090629">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@@ -242,8 +243,8 @@
<state width="849" height="374" key="GridCell.Tab.2.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.2.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1322" height="302" key="GridCell.Tab.2.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249079" />
<state width="1322" height="302" key="GridCell.Tab.2.left" timestamp="1599121249078">
<state width="1322" height="577" key="GridCell.Tab.2.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090629" />
<state width="1322" height="577" key="GridCell.Tab.2.left" timestamp="1599203090628">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@@ -254,8 +255,8 @@
<state width="849" height="374" key="GridCell.Tab.2.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="840" height="374" key="GridCell.Tab.2.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1322" height="302" key="GridCell.Tab.2.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249078" />
<state width="1322" height="302" key="GridCell.Tab.2.right" timestamp="1599121249079">
<state width="1322" height="577" key="GridCell.Tab.2.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090628" />
<state width="1322" height="577" key="GridCell.Tab.2.right" timestamp="1599203090629">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@@ -266,8 +267,8 @@
<state width="849" height="374" key="GridCell.Tab.2.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.2.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.2.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1322" height="302" key="GridCell.Tab.2.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249079" />
<state width="1322" height="302" key="GridCell.Tab.3.bottom" timestamp="1599121249080">
<state width="1322" height="577" key="GridCell.Tab.2.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090629" />
<state width="1322" height="577" key="GridCell.Tab.3.bottom" timestamp="1599203090630">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
@@ -278,8 +279,8 @@
<state width="849" height="374" key="GridCell.Tab.3.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305946" />
<state width="1300" height="374" key="GridCell.Tab.3.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="302" key="GridCell.Tab.3.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249080" />
<state width="1322" height="302" key="GridCell.Tab.3.center" timestamp="1599121249080">
<state width="1322" height="577" key="GridCell.Tab.3.bottom/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090630" />
<state width="1322" height="577" key="GridCell.Tab.3.center" timestamp="1599203090630">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@@ -290,8 +291,8 @@
<state width="849" height="374" key="GridCell.Tab.3.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.3.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="302" key="GridCell.Tab.3.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249080" />
<state width="1322" height="302" key="GridCell.Tab.3.left" timestamp="1599121249079">
<state width="1322" height="577" key="GridCell.Tab.3.center/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090630" />
<state width="1322" height="577" key="GridCell.Tab.3.left" timestamp="1599203090629">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@@ -302,8 +303,8 @@
<state width="849" height="374" key="GridCell.Tab.3.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305945" />
<state width="1300" height="374" key="GridCell.Tab.3.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="302" key="GridCell.Tab.3.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249079" />
<state width="1322" height="302" key="GridCell.Tab.3.right" timestamp="1599121249080">
<state width="1322" height="577" key="GridCell.Tab.3.left/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090629" />
<state width="1322" height="577" key="GridCell.Tab.3.right" timestamp="1599203090630">
<screen x="70" y="23" width="2490" height="1417" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
@@ -314,7 +315,7 @@
<state width="849" height="374" key="GridCell.Tab.3.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="840" height="374" key="GridCell.Tab.3.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598947305946" />
<state width="1300" height="374" key="GridCell.Tab.3.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1322" height="302" key="GridCell.Tab.3.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599121249080" />
<state width="1322" height="577" key="GridCell.Tab.3.right/70.23.2490.1417@70.23.2490.1417" timestamp="1599203090630" />
<state x="161" y="268" width="670" height="676" key="search.everywhere.popup" timestamp="1598787117227">
<screen x="53" y="23" width="1739" height="1097" />
</state>

View File

@@ -8,7 +8,7 @@
* 2. 节点过滤,重命名,排序等。
* 3. 订阅拆分,组合。
*/
const $ = API("sub-store", true);
const $ = API("sub-store");
const $app = express();
$.http = HTTP({
@@ -45,7 +45,7 @@ if (!$.read(SUBS_KEY)) $.write({}, SUBS_KEY);
if (!$.read(COLLECTIONS_KEY)) $.write({}, COLLECTIONS_KEY);
// BACKEND API
$.log("Initializing Express...");
$.info("Initializing Express...");
// download
$app.get("/download/collection/:name", downloadCollection);
@@ -76,7 +76,7 @@ $app.all("/", async (req, res) => {
res.send("Hello from Sub-Store! Made with ❤️ by Peng-YM.");
});
$.log("Express initialized");
$.info("Express initialized");
$app.start();
/**************************** API -- Subscriptions ***************************************/
@@ -151,13 +151,13 @@ async function parseSub(sub, platform) {
$.write(raw, `#${sub.url}`);
}
$.log(
$.info(
"======================================================================="
);
$.log(
$.info(
`Processing subscription: ${sub.name}, target platform ==> ${platform}.`
);
$.log(`Initializing parsers...`);
$.info(`Initializing parsers...`);
const $parser = ProxyParser(platform);
// Parsers
$parser.addParsers([
@@ -186,7 +186,7 @@ async function parseSub(sub, platform) {
Surge_Http,
]);
$.log(`Parsers initialized.`);
$.info(`Parsers initialized.`);
let proxies = $parser.parse(raw);
// filters
@@ -195,12 +195,13 @@ async function parseSub(sub, platform) {
const $operator = ProxyOperator();
for (const item of sub.process || []) {
let script;
// process script
if (item.type.indexOf("Script") !== -1) {
const {mode, content} = item.args;
if (mode === "link") {
// if this is remote script, download it
item.args = await $.http
script = await $.http
.get(content)
.then((resp) => resp.body)
.catch((err) => {
@@ -209,30 +210,49 @@ async function parseSub(sub, platform) {
);
});
} else {
item.args = content;
script = content;
}
}
if (item.type.indexOf("Filter") !== -1) {
const filter = AVAILABLE_FILTERS[item.type];
if (filter) {
$filter.setFilter(filter(item.args));
proxies = $filter.process(proxies);
$.log(
$.info(
`Applying filter "${item.type}" with arguments:\n >>> ${
JSON.stringify(item.args) || "None"
}`
);
if (item.type.indexOf("Script") !== -1) {
$filter.setFilter(filter(script));
} else {
$filter.setFilter(filter(item.args));
}
try {
proxies = $filter.process(proxies);
} catch (err) {
$.error(
`Failed to apply filter "${item.type}"!\n REASON: ${err}`
);
}
}
} else if (item.type.indexOf("Operator") !== -1) {
const operator = AVAILABLE_OPERATORS[item.type];
if (operator) {
$operator.setOperator(operator(item.args));
proxies = $operator.process(proxies);
$.log(
$.info(
`Applying operator "${item.type}" with arguments: \n >>> ${
item.args || "None"
JSON.stringify(item.args) || "None"
}`
);
if (item.type.indexOf("Script") !== -1) {
$operator.setOperator(operator(script));
} else {
$operator.setOperator(operator(item.args));
}
try {
proxies = $operator.process(proxies);
} catch (err) {
`Failed to apply operator "${item.type}"!\n REASON: ${err}`
}
}
}
}
@@ -330,7 +350,7 @@ async function newSub(req, res) {
async function updateSub(req, res) {
const {name} = req.params;
$.log(`Updating subscription: ${name}`);
$.info(`Updating subscription: ${name}`);
let sub = req.body;
const allSubs = $.read(SUBS_KEY);
if (allSubs[name]) {
@@ -528,7 +548,7 @@ function ProxyParser(targetPlatform) {
function addParsers(args) {
args.forEach((a) => parsers.push(a()));
$.log(`${args.length} parser added.`);
$.info(`${args.length} parser added.`);
}
function addProducers(args) {
@@ -2557,7 +2577,7 @@ function express(port = 3000) {
// adapter
app.start = () => {
app.listen(port, () => {
$.log(`Express started on port: ${port}`);
$.info(`Express started on port: ${port}`);
});
};
return app;
@@ -2581,8 +2601,6 @@ function express(port = 3000) {
// dispatch url to route
const dispatch = (request, start = 0) => {
let {method, url, headers, body} = request;
console.log("DISPATCHING: " + method + ": " + url);
if (/json/i.test(headers["Content-Type"])) {
body = JSON.parse(body);
}
@@ -2657,7 +2675,6 @@ function express(port = 3000) {
// start service
app.start = () => {
console.log(`STARTING TO ROUTE: ${JSON.stringify($request)}`);
dispatch($request);
};