koishi-plugin-warframe 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.d.ts +26 -4
  2. package/lib/index.js +161 -138
  3. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export const dictToKeyDict: <T>(dict: {
18
18
  }, predict: (obj: T) => string[]) => {
19
19
  [key: string]: string;
20
20
  };
21
+ export const pascalToSpaced: (str: string) => string;
22
+ export const toPascalCase: (str: string) => string;
21
23
  export const toTimeStamp: (timeStr: string) => number;
22
24
  /**
23
25
  * 毫秒转「X小时X分钟X秒」格式(0单位不显示)
@@ -45,16 +47,37 @@ export const regionToShort: (region: IRegion, dict: any) => {
45
47
  maxLevel: number;
46
48
  minLevel: number;
47
49
  };
50
+ export const relicQualityToName: (quality: string) => RelicQuality;
51
+ /** transform relic quality to translation key, return original if not matched.
52
+ *
53
+ * eg. "VPQ_BRONZE" => "/Lotus/Language/Relics/VoidProjectionQuality_Bronze".
54
+ * @param quality directly provided from `IRelic.quality` expected to start with "VPQ_".
55
+ */
56
+ export const relicQualityToTransKey: (quality: string) => string;
57
+ /** transform relic era to translation key.
58
+ *
59
+ * eg. "Lith" => "/Lotus/Language/Relics/Era_LITH".
60
+ * @param era directly provided from `IRelic.era`.
61
+ */
62
+ export const relicEraToTransKey: (era: string) => string;
63
+ export const fixRelicRewardKey: (item: string) => string;
48
64
  export const getWFMItemList: () => Promise<WFMResponse<ItemShort[] | null>>;
49
65
  export const getWFMOrderList: (itemId: string) => Promise<WFMResponse<OrderWithUser[] | null>>;
50
66
  export const getWFMRivenItemList: () => Promise<WFMResponse<RivenItem[] | null>>;
51
- export const getWFMRivenOrderList: (itemId: string) => Promise<WFMResponseV1<RivenOrder> | null>;
67
+ export const getWFMRivenOrderList: (itemId: string) => Promise<WFMResponseV1<Auction<RivenOrder>> | null>;
52
68
  export const getWFMRivenAttributeList: () => Promise<WFMResponse<RivenAttribute[]> | null>;
69
+ export const getWFMDucatnator: () => Promise<WFMResponseV1<{
70
+ previous_day: Ducatnator[];
71
+ previous_hour: Ducatnator[];
72
+ }>>;
53
73
  export const getHtmlString: (body: string, title?: string) => string;
54
74
  export const getHtmlImageBase64: (puppe: Puppeteer, html: string, type?: "png" | "jpeg" | "webp") => Promise<string>;
55
75
  export const OutputImage: (imgBase64: string) => Element;
56
76
  export const ItemOrderOutput: (item: ItemShort, orders: OrderWithUser[]) => Element;
57
77
  export const RivenOrderOutput: (item: RivenItem, orders: RivenOrder[]) => Element;
78
+ export function createAsyncCache<T>(fetchFn: () => Promise<T>, ttlMs: number): {
79
+ get: () => Promise<T>;
80
+ };
58
81
  export let globalRivenAttributeDict: Record<string, RivenAttribute>;
59
82
  export const wmOnReady: () => Promise<void>;
60
83
  export const setGlobalItem: (data: ItemShort[]) => void;
@@ -70,7 +93,7 @@ export const getRivenOrders: (input: string) => Promise<{
70
93
  orders: RivenOrder[];
71
94
  }>;
72
95
  export const generateRivenOrderOutput: (puppe: Puppeteer, item: RivenItem, orders: RivenOrder[]) => Promise<import("koishi").Element>;
73
- export const loadRelicData: (relic: Relic) => OutputRelic;
96
+ export const loadRelicData: (relic: Relic) => Promise<OutputRelic>;
74
97
  export const inputToItem: (input: string) => ItemShort | undefined;
75
98
  declare const _default: {
76
99
  SolNode147: number;
@@ -91,9 +114,8 @@ export const FissureTable: (fissures: Fissure[], type: "fissure" | "sp-fissure"
91
114
  export const WeeklyTable: (archon: string, deepArchimedea: ArchiMedea, temporalArchimedea: ArchiMedea) => Promise<string>;
92
115
  export const RelicComponent: (relic: OutputRelic) => Element;
93
116
  export const getWorldState: () => Promise<WorldState>;
94
- export const getRelicsDropTable: (puppe: Puppeteer) => Promise<Record<string, Relic>>;
95
117
  export const wfOnReady: () => Promise<void>;
96
- export const getRelic: (puppe: Puppeteer, input: string) => Promise<Relic | string>;
118
+ export const getRelic: (input: string) => Promise<Relic | string>;
97
119
  export const generateRelicOutput: (puppe: Puppeteer, relic: OutputRelic) => Promise<import("koishi").Element>;
98
120
  export const getArbitrations: (day?: number) => Arbitration[] | string;
99
121
  export const generateArbitrationsOutput: (puppe: Puppeteer, arby: Arbitration[]) => Promise<import("koishi").Element>;
package/lib/index.js CHANGED
@@ -104,6 +104,9 @@ var dictToKeyDict = /* @__PURE__ */ __name((dict, predict) => {
104
104
  }
105
105
  return result;
106
106
  }, "dictToKeyDict");
107
+ var pascalToSpaced = /* @__PURE__ */ __name((str) => {
108
+ return str.replace(/([A-Z])/g, " $1").trim();
109
+ }, "pascalToSpaced");
107
110
 
108
111
  // src/utils/time.ts
109
112
  var toTimeStamp = /* @__PURE__ */ __name((timeStr) => {
@@ -170,6 +173,9 @@ var regionToShort = /* @__PURE__ */ __name((region, dict) => {
170
173
  minLevel: region.minEnemyLevel
171
174
  };
172
175
  }, "regionToShort");
176
+ var fixRelicRewardKey = /* @__PURE__ */ __name((item) => {
177
+ return item.replace("StoreItems/", "");
178
+ }, "fixRelicRewardKey");
173
179
 
174
180
  // src/api/wfm-api.ts
175
181
  var wfmApiV1Base = "https://api.warframe.market/v1/";
@@ -197,6 +203,9 @@ var getWFMRivenAttributeList = /* @__PURE__ */ __name(async () => {
197
203
  `${wfmApiV2Base}riven/attributes`
198
204
  );
199
205
  }, "getWFMRivenAttributeList");
206
+ var getWFMDucatnator = /* @__PURE__ */ __name(async () => {
207
+ return await fetchAsyncData(`${wfmApiV1Base}tools/ducats`);
208
+ }, "getWFMDucatnator");
200
209
 
201
210
  // src/components/wfm.tsx
202
211
  var import_jsx_runtime = require("@satorijs/element/jsx-runtime");
@@ -558,6 +567,39 @@ var RivenAttributeComponent = /* @__PURE__ */ __name((attr, index) => {
558
567
  );
559
568
  }, "RivenAttributeComponent");
560
569
 
570
+ // src/services/wfm-service.ts
571
+ var import_warframe_public_export_plus2 = require("warframe-public-export-plus");
572
+
573
+ // src/utils/cache.ts
574
+ function createAsyncCache(fetchFn, ttlMs) {
575
+ let cache = null;
576
+ let lastUpdated = 0;
577
+ let inFlight = null;
578
+ async function get() {
579
+ const now = Date.now();
580
+ if (cache && now - lastUpdated < ttlMs) {
581
+ return cache;
582
+ }
583
+ if (inFlight) {
584
+ return inFlight;
585
+ }
586
+ inFlight = (async () => {
587
+ try {
588
+ const result = await fetchFn();
589
+ cache = result;
590
+ lastUpdated = Date.now();
591
+ return cache;
592
+ } finally {
593
+ inFlight = null;
594
+ }
595
+ })();
596
+ return inFlight;
597
+ }
598
+ __name(get, "get");
599
+ return { get };
600
+ }
601
+ __name(createAsyncCache, "createAsyncCache");
602
+
561
603
  // src/services/wfm-service.ts
562
604
  var globalItemList = [];
563
605
  var globalRivenItemList = [];
@@ -565,7 +607,8 @@ var globalRivenAttributeList = [];
565
607
  var globalItemDict = {};
566
608
  var globalRivenItemDict = {};
567
609
  var globalRivenAttributeDict = {};
568
- var globalItemNameToIDDict = {};
610
+ var globalItemNameToSlugDict = {};
611
+ var globalItemGameRefDict = {};
569
612
  var wmOnReady = /* @__PURE__ */ __name(async () => {
570
613
  const data = await getWFMItemList();
571
614
  if (!data) {
@@ -588,7 +631,7 @@ var wmOnReady = /* @__PURE__ */ __name(async () => {
588
631
  var setGlobalItem = /* @__PURE__ */ __name((data) => {
589
632
  globalItemList = data;
590
633
  globalItemDict = listToDict(data, (i) => [i.slug]);
591
- globalItemNameToIDDict = ((list) => {
634
+ globalItemNameToSlugDict = ((list) => {
592
635
  const result = {};
593
636
  for (const item of list) {
594
637
  if (item.i18n["zh-hans"]?.name) {
@@ -600,6 +643,7 @@ var setGlobalItem = /* @__PURE__ */ __name((data) => {
600
643
  }
601
644
  return result;
602
645
  })(globalItemList);
646
+ globalItemGameRefDict = listToDict(data, (i) => [i.gameRef]);
603
647
  }, "setGlobalItem");
604
648
  var setGlobalRivenItem = /* @__PURE__ */ __name((data) => {
605
649
  globalRivenItemList = data;
@@ -666,33 +710,35 @@ var generateRivenOrderOutput = /* @__PURE__ */ __name(async (puppe, item, orders
666
710
  const imgBase64 = await getHtmlImageBase64(puppe, element.toString());
667
711
  return OutputImage(imgBase64);
668
712
  }, "generateRivenOrderOutput");
669
- var loadRelicData = /* @__PURE__ */ __name((relic) => {
670
- const relicTierMap = {
671
- Lith: "古纪",
672
- Meso: "前纪",
673
- Neo: "中纪",
674
- Axi: "后纪",
675
- Requiem: "安魂",
676
- Vanguard: "先锋"
677
- };
678
- relic.tier = relicTierMap[relic.tier] ?? relic.tier;
713
+ var loadRelicData = /* @__PURE__ */ __name(async (relic) => {
714
+ const tier = import_warframe_public_export_plus2.dict_zh[relic.tierKey] ?? relic.tier;
715
+ const wfmDict = await globalDucatnatorIDDict.get();
679
716
  const loadedItems = relic.items.map((element) => {
680
- const item = nameToItem(element.name);
717
+ const item = globalItemGameRefDict[element.name];
681
718
  if (!item) {
719
+ const nameArr = element.name.split("/");
720
+ const name2 = pascalToSpaced(nameArr[nameArr.length - 1]).replace(
721
+ "Blueprint",
722
+ "蓝图"
723
+ );
724
+ const quantityPrefix = element.quantity > 1 ? `${element.quantity} X ` : "";
682
725
  return {
683
- name: element.name.replace("Blueprint", "蓝图"),
684
- ducats: 0,
685
- rate: element.rate
726
+ ...element,
727
+ name: quantityPrefix + name2,
728
+ ducats: 0
686
729
  };
687
730
  }
731
+ const platinum = wfmDict ? wfmDict[item.id]?.wa_price : void 0;
688
732
  return {
733
+ ...element,
689
734
  name: item.i18n["zh-hans"].name,
690
735
  ducats: item.ducats,
691
- rate: element.rate
736
+ platinum
692
737
  };
693
738
  });
694
739
  return {
695
- ...relic,
740
+ tier,
741
+ num: relic.num,
696
742
  items: loadedItems
697
743
  };
698
744
  }, "loadRelicData");
@@ -822,35 +868,35 @@ var shortHandProcess = /* @__PURE__ */ __name((input) => {
822
868
  const { pure: inputNoSuffix, suffix } = removeNameSuffix(input);
823
869
  if (inputNoSuffix === input) {
824
870
  const fixSet = input + setSuffix;
825
- const fixSetRes = globalItemNameToIDDict[fixSet];
871
+ const fixSetRes = globalItemNameToSlugDict[fixSet];
826
872
  if (fixSetRes) return globalItemDict[fixSetRes];
827
873
  const fixPrime = input.endsWith(primeSuffix) ? input : input.endsWith("p") ? input.slice(0, input.length - 1) + primeSuffix : input + primeSuffix;
828
- const fixPrimeRes = globalItemNameToIDDict[fixPrime];
874
+ const fixPrimeRes = globalItemNameToSlugDict[fixPrime];
829
875
  if (fixPrimeRes) return globalItemDict[fixPrimeRes];
830
876
  const fixPrimeSet = fixPrime + setSuffix;
831
- const fixPrimeSetRes = globalItemNameToIDDict[fixPrimeSet];
877
+ const fixPrimeSetRes = globalItemNameToSlugDict[fixPrimeSet];
832
878
  if (fixPrimeSetRes) return globalItemDict[fixPrimeSetRes];
833
879
  const fixBP = input + bpSuffix;
834
- const fixBPRes = globalItemNameToIDDict[fixBP];
880
+ const fixBPRes = globalItemNameToSlugDict[fixBP];
835
881
  if (fixBPRes) return globalItemDict[fixBPRes];
836
882
  const fixPrimeBP = fixPrime + bpSuffix;
837
- const fixPrimeBPRes = globalItemNameToIDDict[fixPrimeBP];
883
+ const fixPrimeBPRes = globalItemNameToSlugDict[fixPrimeBP];
838
884
  if (fixPrimeBPRes) return globalItemDict[fixPrimeBPRes];
839
885
  } else {
840
886
  const fixBP = inputNoSuffix + suffix + bpSuffix;
841
- const fixBPRes = globalItemNameToIDDict[fixBP];
887
+ const fixBPRes = globalItemNameToSlugDict[fixBP];
842
888
  if (fixBPRes) return globalItemDict[fixBPRes];
843
889
  const fixPrime = inputNoSuffix.endsWith(primeSuffix) ? inputNoSuffix : inputNoSuffix.endsWith("p") ? inputNoSuffix.slice(0, inputNoSuffix.length - 1) + primeSuffix : inputNoSuffix + primeSuffix;
844
- const fixPrimeRes = globalItemNameToIDDict[fixPrime + suffix];
890
+ const fixPrimeRes = globalItemNameToSlugDict[fixPrime + suffix];
845
891
  if (fixPrimeRes) return globalItemDict[fixPrimeRes];
846
892
  const fixPrimeBP = fixPrime + suffix + bpSuffix;
847
- const fixPrimeBPRes = globalItemNameToIDDict[fixPrimeBP];
893
+ const fixPrimeBPRes = globalItemNameToSlugDict[fixPrimeBP];
848
894
  if (fixPrimeBPRes) return globalItemDict[fixPrimeBPRes];
849
895
  }
850
896
  }, "shortHandProcess");
851
897
  var inputToItem = /* @__PURE__ */ __name((input) => {
852
898
  input = normalizeOrderName(input);
853
- const slug = globalItemNameToIDDict[input];
899
+ const slug = globalItemNameToSlugDict[input];
854
900
  if (slug) return globalItemDict[slug];
855
901
  const normalShortHandRes = shortHandProcess(input);
856
902
  if (normalShortHandRes) return normalShortHandRes;
@@ -939,16 +985,17 @@ var normalizeOrderName = /* @__PURE__ */ __name((str) => {
939
985
  }, "normalize");
940
986
  return normalize(str);
941
987
  }, "normalizeOrderName");
942
- var nameToItem = /* @__PURE__ */ __name((name2) => {
943
- const id = globalItemNameToIDDict[normalizeOrderName(name2)];
944
- if (id) {
945
- return globalItemDict[id];
988
+ var updateDucatnator = /* @__PURE__ */ __name(async () => {
989
+ const data = await getWFMDucatnator();
990
+ if (!data || !data.payload) {
991
+ return void 0;
946
992
  }
947
- return null;
948
- }, "nameToItem");
993
+ return listToDict(data.payload.previous_hour, (d) => [d.item]);
994
+ }, "updateDucatnator");
995
+ var globalDucatnatorIDDict = createAsyncCache(updateDucatnator, 36e5);
949
996
 
950
997
  // src/services/wf-service.ts
951
- var import_warframe_public_export_plus2 = require("warframe-public-export-plus");
998
+ var import_warframe_public_export_plus3 = require("warframe-public-export-plus");
952
999
 
953
1000
  // src/assets/zh.json
954
1001
  var zh_default = {
@@ -45752,15 +45799,20 @@ ${deepRes}
45752
45799
  ${tempRes}`;
45753
45800
  }, "WeeklyTable");
45754
45801
  var RelicComponent = /* @__PURE__ */ __name((relic) => {
45755
- const gold = relic.items.filter((i) => i.rate.Intact === 2);
45756
- const silver = relic.items.filter((i) => i.rate.Intact === 11);
45757
- const bronze = relic.items.filter((i) => i.rate.Intact === 25.33);
45758
- const getRateColor = /* @__PURE__ */ __name((rate) => {
45759
- if (rate === 2) return "#ffd700";
45760
- if (rate === 11) return "#c0c0c0";
45761
- if (rate === 25.33) return "#cd7f32";
45802
+ const gold = relic.items.filter((i) => i.rarity === "RARE");
45803
+ const silver = relic.items.filter((i) => i.rarity === "UNCOMMON");
45804
+ const bronze = relic.items.filter((i) => i.rarity === "COMMON");
45805
+ const getRateColor = /* @__PURE__ */ __name((rarity) => {
45806
+ if (rarity === "RARE") return "#ffd700";
45807
+ if (rarity === "UNCOMMON") return "#c0c0c0";
45808
+ if (rarity === "COMMON") return "#cd7f32";
45762
45809
  return "#000000";
45763
45810
  }, "getRateColor");
45811
+ const relicRewardDropRate = {
45812
+ RARE: "2/4/6/10",
45813
+ UNCOMMON: "11/13/17/20",
45814
+ COMMON: "25/23/20/17"
45815
+ };
45764
45816
  const renderRewards = /* @__PURE__ */ __name((items) => {
45765
45817
  if (items.length === 0) return null;
45766
45818
  return items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -45770,7 +45822,7 @@ var RelicComponent = /* @__PURE__ */ __name((relic) => {
45770
45822
  margin: 4px 0;
45771
45823
  border-radius: 4px;
45772
45824
  background-color: rgba(255, 255, 255, 0.05);
45773
- border-left: 4px solid ${getRateColor(item.rate.Intact)};
45825
+ border-left: 4px solid ${getRateColor(item.rarity)};
45774
45826
  display: flex;
45775
45827
  justify-content: space-between;
45776
45828
  align-items: center;
@@ -45786,7 +45838,24 @@ var RelicComponent = /* @__PURE__ */ __name((relic) => {
45786
45838
  display:flex;
45787
45839
  gap:10px;`,
45788
45840
  children: [
45789
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: "color: #a0a000;display:flex;line-height:1;", children: [
45841
+ item.platinum ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
45842
+ "span",
45843
+ {
45844
+ style: "\n color: #0d93b8;\n display:flex;\n line-height:1;",
45845
+ children: [
45846
+ item.platinum,
45847
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
45848
+ "svg",
45849
+ {
45850
+ viewBox: "0 0 18 18",
45851
+ style: "\n color: rgb(64 64 64 / 75%);\n height: 1em;\n width: 1em;\n vertical-align: -.125em;\n fill: currentcolor;\n margin-left:2px;",
45852
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("use", { href: `#icon-platinum` })
45853
+ }
45854
+ )
45855
+ ]
45856
+ }
45857
+ ) : "",
45858
+ item.ducats ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: "color: #a0a000;display:flex;line-height:1;", children: [
45790
45859
  item.ducats,
45791
45860
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
45792
45861
  "svg",
@@ -45796,9 +45865,9 @@ var RelicComponent = /* @__PURE__ */ __name((relic) => {
45796
45865
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("use", { href: `#icon-ducats` })
45797
45866
  }
45798
45867
  )
45799
- ] }),
45868
+ ] }) : "",
45800
45869
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
45801
- item.rate.Intact,
45870
+ relicRewardDropRate[item.rarity],
45802
45871
  "%"
45803
45872
  ] })
45804
45873
  ]
@@ -45918,7 +45987,7 @@ var RelicComponent = /* @__PURE__ */ __name((relic) => {
45918
45987
  font-size: 10px;
45919
45988
  color: #888888;
45920
45989
  text-align: center;`,
45921
- children: "掉落率基于Intact遗物品质"
45990
+ children: "价格数据来源于 WFM Ducanator, 约有1小时延迟"
45922
45991
  }
45923
45992
  )
45924
45993
  ]
@@ -45934,75 +46003,6 @@ var getWorldState = /* @__PURE__ */ __name(async () => {
45934
46003
  const ws = await WorldStateParser.WorldState.build(response);
45935
46004
  return ws;
45936
46005
  }, "getWorldState");
45937
- var getRelicsDropTable = /* @__PURE__ */ __name(async (puppe) => {
45938
- const dropTableUrl = "https://www.warframe.com/droptables";
45939
- const response = await fetchAsyncText(dropTableUrl);
45940
- const relicList = await puppe.render(response, async (p) => {
45941
- const body = await p.waitForSelector("body");
45942
- const title = await body.waitForSelector("#relicRewards");
45943
- const result2 = await title.evaluate((el) => {
45944
- const table = el.nextElementSibling;
45945
- if (!table) {
45946
- return null;
45947
- }
45948
- const relicList2 = [];
45949
- let current = { items: [] };
45950
- for (const tr of table.children[0].children) {
45951
- if (tr.className.includes("blank-row")) {
45952
- relicList2.push(current);
45953
- current = { items: [] };
45954
- continue;
45955
- }
45956
- const first = tr.children[0];
45957
- if (first.tagName.toLocaleLowerCase() === "th") {
45958
- const splitRes = first.textContent.split("(");
45959
- const name2 = splitRes[0].replace(/Relic$/, "").trim();
45960
- const tier = name2.split(" ")[0];
45961
- const num = name2.split(" ")[1] ?? "";
45962
- const quality = splitRes[1].split(")")[0].trim();
45963
- current.tier = tier;
45964
- current.num = num;
45965
- current.quality = quality;
45966
- } else {
45967
- const rateStr = tr.children[1].textContent;
45968
- const rate = parseFloat(rateStr.split("(")[1].split("%")[0]);
45969
- current.items.push({ name: first.textContent, rate });
45970
- }
45971
- }
45972
- return relicList2;
45973
- });
45974
- return result2;
45975
- });
45976
- const result = {};
45977
- relicList.forEach((r) => {
45978
- const nameKey = r.tier + r.num;
45979
- if (!result[nameKey]) {
45980
- result[nameKey] = {
45981
- tier: r.tier,
45982
- num: r.num,
45983
- items: r.items.map((i) => {
45984
- return {
45985
- name: i.name,
45986
- rate: {
45987
- Intact: void 0,
45988
- Exceptional: void 0,
45989
- Flawless: void 0,
45990
- Radiant: void 0
45991
- }
45992
- };
45993
- })
45994
- };
45995
- }
45996
- const itemsMap = new Map(
45997
- result[nameKey].items.map((item) => [item.name, item])
45998
- );
45999
- for (const target of r.items) {
46000
- const item = itemsMap.get(target.name);
46001
- item.rate[r.quality] = target.rate;
46002
- }
46003
- });
46004
- return result;
46005
- }, "getRelicsDropTable");
46006
46006
 
46007
46007
  // src/services/wf-service.ts
46008
46008
  var arbitrationSchedule = arbys_default.split("\n").map((line) => line.split(",")).filter((arr) => arr.length == 2).map((arr) => {
@@ -46019,13 +46019,11 @@ var spFissures = [];
46019
46019
  var rjFissures = [];
46020
46020
  var relics = null;
46021
46021
  var wfOnReady = /* @__PURE__ */ __name(async () => {
46022
+ loadRelics();
46022
46023
  }, "wfOnReady");
46023
- var getRelic = /* @__PURE__ */ __name(async (puppe, input) => {
46024
- if (!relics || Object.entries(relics).length === 0) {
46025
- relics = await getRelicsDropTable(puppe);
46026
- if (!relics || Object.entries(relics).length === 0) {
46027
- return "获取遗物信息失败";
46028
- }
46024
+ var getRelic = /* @__PURE__ */ __name(async (input) => {
46025
+ if (!relics) {
46026
+ return "遗物数据未加载完成,请稍后再试";
46029
46027
  }
46030
46028
  input = removeSpace(input);
46031
46029
  const tierList = [
@@ -46044,11 +46042,11 @@ var getRelic = /* @__PURE__ */ __name(async (puppe, input) => {
46044
46042
  ];
46045
46043
  const tier = tierList.find((t) => input.startsWith(t));
46046
46044
  if (!tier) {
46047
- return "输入非法";
46045
+ return "请提供正确的遗物名称";
46048
46046
  }
46049
- let body = input.replace(new RegExp(`^${tier}`), "");
46050
- if (body.endsWith("遗物") || body.endsWith("Relic")) {
46051
- body = body.replace(/遗物$|Relic$/, "");
46047
+ let category = input.replace(new RegExp(`^${tier}`), "");
46048
+ if (category.endsWith("遗物") || category.endsWith("Relic")) {
46049
+ category = category.replace(/遗物$|Relic$/, "");
46052
46050
  }
46053
46051
  const tierMap = {
46054
46052
  古纪: "Lith",
@@ -46058,9 +46056,9 @@ var getRelic = /* @__PURE__ */ __name(async (puppe, input) => {
46058
46056
  安魂: "Requiem",
46059
46057
  先锋: "Vanguard"
46060
46058
  };
46061
- const mappedTier = tierMap[tier];
46062
- const key = mappedTier + body;
46063
- return relics[key];
46059
+ const mappedTier = tierMap[tier] ?? tier;
46060
+ const key = mappedTier + category;
46061
+ return relics[key] ?? "未找到对应遗物信息";
46064
46062
  }, "getRelic");
46065
46063
  var generateRelicOutput = /* @__PURE__ */ __name(async (puppe, relic) => {
46066
46064
  const element = RelicComponent(relic);
@@ -46082,7 +46080,7 @@ var getArbitrations = /* @__PURE__ */ __name((day = 3) => {
46082
46080
  currentHourIndex + 24 * day
46083
46081
  );
46084
46082
  return weekArbys.filter((a) => arbyRewards_default[a.node]).map((a) => {
46085
- const obj = regionToShort(import_warframe_public_export_plus2.ExportRegions[a.node], import_warframe_public_export_plus2.dict_zh);
46083
+ const obj = regionToShort(import_warframe_public_export_plus3.ExportRegions[a.node], import_warframe_public_export_plus3.dict_zh);
46086
46084
  return {
46087
46085
  ...obj,
46088
46086
  time: new Date(a.time * 1e3).toLocaleString("zh-cn", {
@@ -46110,7 +46108,7 @@ var getWeekly = /* @__PURE__ */ __name(async () => {
46110
46108
  if (!await updateWorldState()) {
46111
46109
  return "内部错误,获取最新信息失败";
46112
46110
  }
46113
- const archon = import_warframe_public_export_plus2.dict_zh["/Lotus/Language/Narmer/" + removeSpace(worldState.archonHunt.boss)];
46111
+ const archon = import_warframe_public_export_plus3.dict_zh["/Lotus/Language/Narmer/" + removeSpace(worldState.archonHunt.boss)];
46114
46112
  const stringToDebuff = /* @__PURE__ */ __name((key, name2, prefix) => {
46115
46113
  const keyToName = zh_default[`${prefix}${key}`];
46116
46114
  if (!keyToName) {
@@ -46133,7 +46131,7 @@ var getWeekly = /* @__PURE__ */ __name(async () => {
46133
46131
  const deepArchimMissions = await Promise.all(
46134
46132
  deepArchim.missions.map(async (m) => {
46135
46133
  const receivedType = await getMissionTypeKey(m.missionType);
46136
- const type = import_warframe_public_export_plus2.dict_zh[import_warframe_public_export_plus2.ExportMissionTypes[receivedType]?.name] ?? m.missionType;
46134
+ const type = import_warframe_public_export_plus3.dict_zh[import_warframe_public_export_plus3.ExportMissionTypes[receivedType]?.name] ?? m.missionType;
46137
46135
  const diviation = stringToDebuff(
46138
46136
  m.diviation.key,
46139
46137
  m.diviation.name,
@@ -46161,7 +46159,7 @@ var getWeekly = /* @__PURE__ */ __name(async () => {
46161
46159
  const temporalArchimMissions = await Promise.all(
46162
46160
  temporalArchim.missions.map(async (m) => {
46163
46161
  const receivedType = await getMissionTypeKey(m.missionType);
46164
- const type = import_warframe_public_export_plus2.dict_zh[import_warframe_public_export_plus2.ExportMissionTypes[receivedType]?.name] ?? receivedType;
46162
+ const type = import_warframe_public_export_plus3.dict_zh[import_warframe_public_export_plus3.ExportMissionTypes[receivedType]?.name] ?? receivedType;
46165
46163
  const diviation = stringToDebuff(
46166
46164
  m.diviation.key,
46167
46165
  m.diviation.name,
@@ -46227,10 +46225,10 @@ var getCircuitWeek = /* @__PURE__ */ __name(() => {
46227
46225
  const EPOCH = 1734307200 * 1e3;
46228
46226
  const week = Math.trunc((Date.now() - EPOCH) / 6048e5);
46229
46227
  const incarnons = incarnonRewards[week % incarnonRewards.length].map(
46230
- (i) => import_warframe_public_export_plus2.dict_zh[i]
46228
+ (i) => import_warframe_public_export_plus3.dict_zh[i]
46231
46229
  );
46232
46230
  const warframes = warframeRewards[week % warframeRewards.length].map(
46233
- (i) => import_warframe_public_export_plus2.dict_zh[i]
46231
+ (i) => import_warframe_public_export_plus3.dict_zh[i]
46234
46232
  );
46235
46233
  return {
46236
46234
  incarnons,
@@ -46283,8 +46281,8 @@ var updateWorldState = /* @__PURE__ */ __name(async () => {
46283
46281
  hard: fissure.isHard,
46284
46282
  activation: fissure.activation.getTime(),
46285
46283
  expiry: fissure.expiry.getTime(),
46286
- node: regionToShort(import_warframe_public_export_plus2.ExportRegions[nodeKey], import_warframe_public_export_plus2.dict_zh),
46287
- tier: import_warframe_public_export_plus2.dict_zh[fissureTierName[fissure.tierNum]],
46284
+ node: regionToShort(import_warframe_public_export_plus3.ExportRegions[nodeKey], import_warframe_public_export_plus3.dict_zh),
46285
+ tier: import_warframe_public_export_plus3.dict_zh[fissureTierName[fissure.tierNum]],
46288
46286
  tierNum: fissureTierNumToNumber(fissure.tierNum)
46289
46287
  };
46290
46288
  if (fissure.isStorm) {
@@ -46304,6 +46302,31 @@ var updateWorldState = /* @__PURE__ */ __name(async () => {
46304
46302
  return worldState && worldStateLastUpdatedAt && Date.now() - worldStateLastUpdatedAt.getTime() < 12e4;
46305
46303
  }
46306
46304
  }, "updateWorldState");
46305
+ var loadRelics = /* @__PURE__ */ __name(() => {
46306
+ const result = {};
46307
+ for (const key in import_warframe_public_export_plus3.ExportRelics) {
46308
+ const exportRelic = import_warframe_public_export_plus3.ExportRelics[key];
46309
+ const exportRewards = import_warframe_public_export_plus3.ExportRewards[exportRelic.rewardManifest];
46310
+ const era = "/Lotus/Language/Relics/Era_" + exportRelic.era.toUpperCase();
46311
+ const relicKey = exportRelic.era + exportRelic.category;
46312
+ const rewards = (exportRewards[0] ?? []).map((r) => {
46313
+ const item = fixRelicRewardKey(r.type);
46314
+ return {
46315
+ name: item,
46316
+ rarity: r.rarity,
46317
+ quantity: r.itemCount
46318
+ };
46319
+ });
46320
+ const relic = {
46321
+ tier: exportRelic.era,
46322
+ tierKey: era,
46323
+ num: exportRelic.category,
46324
+ items: rewards
46325
+ };
46326
+ result[relicKey] = relic;
46327
+ }
46328
+ relics = result;
46329
+ }, "loadRelics");
46307
46330
 
46308
46331
  // src/commands/wfm/wm.ts
46309
46332
  var wmCommand = /* @__PURE__ */ __name(async (action, input) => {
@@ -46419,11 +46442,11 @@ var weeklyCommand = /* @__PURE__ */ __name(async (action) => {
46419
46442
 
46420
46443
  // src/commands/wf/relic.ts
46421
46444
  var relicCommand = /* @__PURE__ */ __name(async (action, input) => {
46422
- const result = await getRelic(action.session.app.puppeteer, input);
46445
+ const result = await getRelic(input);
46423
46446
  if (typeof result === "string") {
46424
46447
  return result;
46425
46448
  }
46426
- const relic = loadRelicData(result);
46449
+ const relic = await loadRelicData(result);
46427
46450
  return await generateRelicOutput(action.session.app.puppeteer, relic);
46428
46451
  }, "relicCommand");
46429
46452
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-warframe",
3
3
  "description": "WFMToolkit",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "license": "GPL-3.0",
6
6
  "scripts": {
7
7
  "build": "yakumo build",