Skip to content

Commit

Permalink
chore: bump package version
Browse files Browse the repository at this point in the history
Update pnpm-lock.yaml
Update package.json
  • Loading branch information
VirgilClyne committed Dec 6, 2024
1 parent 9b27a94 commit 3f74a23
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 329 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "src/utils"]
path = src/utils
url = https://github.com/NanoCat-Me/utils.git
14 changes: 1 addition & 13 deletions modkit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { pluginLoon } from "@iringo/modkit/plugins/loon";
import { pluginStash } from "@iringo/modkit/plugins/stash";
import { pluginSurge } from "@iringo/modkit/plugins/surge";
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";
import pkg from "./package.json";
import pkg from "./package.json" with { type: "json" };

export default defineConfig({
source: {
Expand Down Expand Up @@ -64,18 +64,6 @@ export default defineConfig({
},
},
arguments: [
{
key: "Switch",
name: "总功能开关",
defaultValue: true,
type: {
default: "boolean",
surge: "exclude",
loon: "exclude",
stash: "exclude",
},
description: "是否启用此APP修改。",
},
{
key: "CountryCode",
name: "国家或地区代码",
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "news",
"version": "3.1.5",
"name": "@nsringo/news",
"organizationName": " iRingo",
"displayName": " iRingo: 📰 News",
"description": "1.自定义解锁News的地区\n2.Coming Soon…",
Expand Down Expand Up @@ -38,11 +37,11 @@
"iOS >= 15"
],
"devDependencies": {
"@iringo/modkit": "^1.3.2",
"@iringo/modkit-plugin-egern": "^1.3.2",
"@iringo/modkit": "^1.3.3",
"@iringo/modkit-plugin-egern": "^1.3.3",
"@rsbuild/plugin-node-polyfill": "^1.2.0"
},
"dependencies": {
"@nsnanocat/util": "^1.4.8"
"@nsnanocat/util": "^1.7.5"
}
}
466 changes: 222 additions & 244 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/function/database.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
export default {
"News": {
"Settings": {
"Switch": true,
"CountryCode": "US",
"NewsPlusUser": true
}
},
"Default": {
"Settings": {
"Switch": true,
},
"Configs": {
"Storefront": {
Expand Down
14 changes: 7 additions & 7 deletions src/function/setENV.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import getStorage from '../utils/getStorage.mjs'
import { _, log } from "../utils/utils.mjs";
import { Console, getStorage, Lodash as _ } from "@nsnanocat/util";

/**
* Set Environment Variables
Expand All @@ -10,15 +9,16 @@ import { _, log } from "../utils/utils.mjs";
* @return {Object} { Settings, Caches, Configs }
*/
export default function setENV(name, platforms, database) {
log(`☑️ Set Environment Variables`, "");
let { Settings, Caches, Configs } = getStorage(name, platforms, database);
Console.log("☑️ Set Environment Variables");
const { Settings, Caches, Configs } = getStorage(name, platforms, database);
/***************** Settings *****************/
log(`✅ Set Environment Variables, Settings: ${typeof Settings}, Settings内容: ${JSON.stringify(Settings)}`, "");
Console.debug(`typeof Settings: ${typeof Settings}`, `Settings: ${JSON.stringify(Settings, null, 2)}`);
/***************** Caches *****************/
//log(`✅ Set Environment Variables, Caches: ${typeof Caches}, Caches内容: ${JSON.stringify(Caches)}`, "");
//Console.debug(`typeof Caches: ${typeof Caches}`, `Caches: ${JSON.stringify(Caches)}`);
/***************** Configs *****************/
//Configs.Storefront = new Map(Configs.Storefront);
if (Configs.Locale) Configs.Locale = new Map(Configs.Locale);
if (Configs.i18n) for (let type in Configs.i18n) Configs.i18n[type] = new Map(Configs.i18n[type]);
if (Configs.i18n) for (const type in Configs.i18n) Configs.i18n[type] = new Map(Configs.i18n[type]);
Console.log("✅ Set Environment Variables");
return { Settings, Caches, Configs };
};
63 changes: 31 additions & 32 deletions src/request.dev.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { $app, Lodash as _, Storage, fetch, notification, log, logError, wait, done } from "@nsnanocat/util";
import { $app, Console, done, Lodash as _ } from "@nsnanocat/util";
import database from "./function/database.mjs";
import setENV from "./function/setENV.mjs";
// 构造回复数据
// biome-ignore lint/style/useConst: <explanation>
let $response = undefined;
/***************** Processing *****************/
// 解构URL
const url = new URL($request.url);
log(`⚠ url: ${url.toJSON()}`, "");
Console.info(`url: ${url.toJSON()}`, "");
// 获取连接参数
const METHOD = $request.method,
HOST = url.hostname,
PATH = url.pathname;
log(`⚠ METHOD: ${METHOD}, HOST: ${HOST}, PATH: ${PATH}`, "");
const PATHs = url.pathname.split("/").filter(Boolean);
Console.info(`PATHs: ${PATHs}`);
// 解析格式
const FORMAT = ($request.headers?.["Content-Type"] ?? $request.headers?.["content-type"])?.split(";")?.[0];
log(`⚠ FORMAT: ${FORMAT}`, "");
Console.info(`FORMAT: ${FORMAT}`, "");
!(async () => {
/**
* @type {{Settings: import('./types').Settings}}
Expand All @@ -23,7 +22,7 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
// 创建空数据
let body = {};
// 方法判断
switch (METHOD) {
switch ($request.method) {
case "POST":
case "PUT":
case "PATCH":
Expand All @@ -42,7 +41,7 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
case "application/vnd.apple.mpegurl":
case "audio/mpegurl":
//body = M3U8.parse($request.body);
//log(`🚧 body: ${JSON.stringify(body)}`, "");
//Console.debug(`body: ${JSON.stringify(body)}`, "");
//$request.body = M3U8.stringify(body);
break;
case "text/xml":
Expand All @@ -52,25 +51,25 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
case "application/plist":
case "application/x-plist":
//body = XML.parse($request.body);
//log(`🚧 body: ${JSON.stringify(body)}`, "");
//Console.debug(`body: ${JSON.stringify(body)}`, "");
//$request.body = XML.stringify(body);
break;
case "text/vtt":
case "application/vtt":
//body = VTT.parse($request.body);
//log(`🚧 body: ${JSON.stringify(body)}`, "");
//Console.debug(`body: ${JSON.stringify(body)}`, "");
//$request.body = VTT.stringify(body);
break;
case "text/json":
case "application/json":
body = JSON.parse($request.body ?? "{}");
log(`🚧 body: ${JSON.stringify(body)}`, "");
Console.debug(`body: ${JSON.stringify(body)}`, "");
// 主机判断
switch (HOST) {
switch (url.hostname) {
case "news-edge.apple.com":
case "news-todayconfig-edge.apple.com":
// 路径判断
switch (PATH) {
switch (url.pathname) {
case "/v1/configs":
if (Settings.CountryCode !== "AUTO") body.storefrontId = Configs.Storefront[Settings.CountryCode];
if (body?.deviceInfo?.preferredLanguages) {
Expand All @@ -83,7 +82,7 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
break;
case "news-events.apple.com":
case "news-sports-events.apple.com":
switch (PATH) {
switch (url.pathname) {
case "/analyticseventsv2/async":
if (body?.data?.session?.mobileData) {
body.data.session.mobileData.countryCode = "310";
Expand All @@ -94,7 +93,7 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
}
break;
case "news-client-search.apple.com":
switch (PATH) {
switch (url.pathname) {
case "/v1/search":
break;
}
Expand All @@ -116,48 +115,49 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
case "OPTIONS":
default:
// 主机判断
switch (HOST) {
switch (url.hostname) {
case "news-edge.apple.com":
case "news-todayconfig-edge.apple.com":
// 路径判断
switch (PATH) {
switch (url.pathname) {
case "/v1/configs":
break;
}
break;
case "news-events.apple.com":
case "news-sports-events.apple.com":
switch (PATH) {
switch (url.pathname) {
case "/analyticseventsv2/async":
break;
}
break;
case "news-client-search.apple.com":
switch (PATH) {
case "/v1/search":
switch (url.pathname) {
case "/v1/search": {
const ParsecParameters = url.searchParams.get("parsecParameters"),
StorefrontID = url.searchParams.get("storefrontID"),
NewsPlusUser = url.searchParams.get("newsPlusUser");
log(`🚧 调试信息, ParsecParameters: ${ParsecParameters}, StorefrontID: ${StorefrontID}, NewsPlusUser: ${NewsPlusUser}`, "");
Console.debug(`调试信息, ParsecParameters: ${ParsecParameters}, StorefrontID: ${StorefrontID}, NewsPlusUser: ${NewsPlusUser}`, "");
if (ParsecParameters) {
let parsecParameters = decodeURIComponent(ParsecParameters);
log("🚧 调试信息", `decodeURIComponent(ParsecParameters): ${parsecParameters}`, "");
Console.debug(`decodeURIComponent(ParsecParameters): ${parsecParameters}`, "");
parsecParameters = JSON.parse(parsecParameters);
//log("🚧 调试信息", `JSON.parse(parsecParameters): ${parsecParameters}`, "");
//Console.debug(`JSON.parse(parsecParameters): ${parsecParameters}`, "");
if (parsecParameters.storeFront) {
if (Settings.CountryCode !== "AUTO") parsecParameters.storeFront = parsecParameters.storeFront.replace(/[\d]{6}/, Configs.Storefront[Settings.CountryCode]);
}
parsecParameters = JSON.stringify(parsecParameters);
//log("🚧 调试信息", `JSON.stringify(parsecParameters): ${parsecParameters}`, "");
//Console.debug(`JSON.stringify(parsecParameters): ${parsecParameters}`, "");
parsecParameters = encodeURIComponent(parsecParameters);
//log("🚧 调试信息", `encodeURIComponent(parsecParameters): ${parsecParameters}`, "");
//Console.debug(`encodeURIComponent(parsecParameters): ${parsecParameters}`, "");
url.searchParams.set("parsecParameters", parsecParameters);
}
if (StorefrontID) {
if (Settings.CountryCode !== "AUTO") url.searchParams.set("storefrontID", Configs.Storefront[Settings.CountryCode]);
}
if (NewsPlusUser) url.searchParams.set("newsPlusUser", Settings.NewsPlusUser || NewsPlusUser);
break;
}
}
break;
}
Expand All @@ -167,13 +167,13 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
break;
}
$request.url = url.toString();
log("🚧 调试信息", `$request.url: ${$request.url}`, "");
Console.debug(`$request.url: ${$request.url}`, "");
})()
.catch(e => logError(e))
.catch(e => Console.error(e))
.finally(() => {
switch (typeof $response) {
case "object": // 有构造回复数据,返回构造的回复数据
//log("🚧 finally", `echo $response: ${JSON.stringify($response, null, 2)}`, "");
//Console.debug("finally", `echo $response: ${JSON.stringify($response, null, 2)}`);
if ($response.headers?.["Content-Encoding"]) $response.headers["Content-Encoding"] = "identity";
if ($response.headers?.["content-encoding"]) $response.headers["content-encoding"] = "identity";
switch ($app) {
Expand All @@ -190,12 +190,11 @@ log(`⚠ FORMAT: ${FORMAT}`, "");
}
break;
case "undefined": // 无构造回复数据,发送修改的请求数据
//log("🚧 finally", `$request: ${JSON.stringify($request, null, 2)}`, "");
//Console.debug("finally", `$request: ${JSON.stringify($request, null, 2)}`);
done($request);
break;
default:
logError(`不合法的 $response 类型: ${typeof $response}`, "");
done();
Console.error(`不合法的 $response 类型: ${typeof $response}`);
break;
}
});
Loading

0 comments on commit 3f74a23

Please sign in to comment.