Skip to content

Commit

Permalink
Merge pull request #396 from TwoAbove/develop
Browse files Browse the repository at this point in the history
v2.33.4
  • Loading branch information
TwoAbove authored Oct 29, 2024
2 parents 0925f70 + 686f496 commit 01aef21
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 170 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ ssl

dataScripts/src/mapsToObj/gen
dataScripts/src/out
dataScripts/noita-data/data
dataScripts/noita-data/translations

cypress/screenshots/

Expand Down
36 changes: 36 additions & 0 deletions .repoignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public
cypress
.github
.husky
src/services/SeedInfo/data
src/services/SeedInfo/noita_random/src/wang


src/components/Icons/EntityIcons
src/services/SeedInfo/noita_random/src/spells.h


src/services/SeedInfo/infoHandler/InfoProviders/FungalShift/FungalShift-base.mjs
src/services/SeedInfo/infoHandler/InfoProviders/FungalShift/Fungal-base.mjs
src/services/SeedInfo/infoHandler/InfoProviders/FungalShift/Fungal.mjs
src/services/SeedInfo/infoHandler/InfoProviders/FungalShift/FungalShift.mjs

src/services/SeedInfo/infoHandler/InfoProviders/Alchemy/Alchemy.mjs
src/services/SeedInfo/infoHandler/InfoProviders/Alchemy/Alchemy-base.mjs
src/services/SeedInfo/infoHandler/InfoProviders/Alchemy/Alchemy.mjs

src/services/SeedInfo/noita_random/noita_random.mjs
src/services/SeedInfo/noita_random/noita_random-base.mjs
src/services/SeedInfo/noita_random/noita_random.wasm.map

src/components/SeedInfo/SeedInfoViews/Watercave.tsx

src/services/SeedInfo/infoHandler/InfoProviders/Map

src/services/imageActions

src/components/SeedInfo/SeedInfoViews

server

**/*.spec.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "noitool",
"version": "2.33.3",
"version": "2.33.4",
"private": true,
"type": "module",
"homepage": "https://www.noitool.com/",
Expand Down
4 changes: 3 additions & 1 deletion server/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "dotenv-flow/config";

if (process.env.DISCORD_TOKEN && process.env.DISCORD_CLIENT_ID) {
import("./discord.mjs");
import("./discord.mjs").catch(e => {
console.error(e);
});
}

import "./server.mjs";
58 changes: 48 additions & 10 deletions server/patreon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ let patronCache = {};
let tierCache = {};

const updatePatrons = async () => {
const { tierMembers, tiers } = await getPatreonPatronsData();
patronCache = tierMembers;
tierCache = tiers;
try {
const { tierMembers, tiers } = await getPatreonPatronsData();
patronCache = tierMembers;
tierCache = tiers;
} catch (e) {
console.error(e);
}
};

updatePatrons();
Expand Down Expand Up @@ -361,14 +365,48 @@ const loadUser = async (req, res, next) => {
};

const loadPatreonClient = async (req, res, next) => {
const patreonUser = await getIdentity(req.user.patreonData.access_token);
if (patreonUser.errors) {
res.status(401).send(null);
return;
}
try {
const response = await fetch(
`https://www.patreon.com/api/oauth2/v2/identity?${new URLSearchParams({
"fields[user]": ["full_name", "url", "image_url"],
})}`,
{
headers: {
Authorization: `Bearer ${req.user.patreonData.access_token}`,
"Content-Type": "application/json",
},
},
);

req.patreonUser = patreonUser.data;
next();
if (!response.ok) {
console.error(`Patreon API error: ${response.status} ${response.statusText}`);
if (response.status === 503) {
return res.status(503).json({ error: "Patreon service temporarily unavailable" });
}
return res.status(response.status).json({ error: "Error fetching Patreon data" });
}

const contentType = response.headers.get("content-type");
if (
!contentType ||
!(contentType.includes("application/json") || contentType.includes("application/vnd.api+json"))
) {
console.error("Unexpected content type from Patreon API:", contentType);
return res.status(500).json({ error: "Unexpected response from Patreon" });
}

const patreonUser = await response.json();
if (patreonUser.errors) {
console.error("Patreon API returned errors:", patreonUser.errors);
return res.status(401).json({ error: "Unauthorized" });
}

req.patreonUser = patreonUser.data;
next();
} catch (error) {
console.error("Error in loadPatreonClient:", error);
res.status(500).json({ error: "Internal server error" });
}
};

const gatherMeData = (user, patreonUser) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TestBench from "./TestBench";
import { Compute, ComputeConsole } from "./Compute";
import { ProfileContext } from "./Profile/ProfileContext";

import { isDev, isLocal } from "./utils";
import { isDev, isFullPath, isLocal } from "./utils";

const Body = () => {
const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -46,7 +46,7 @@ const Body = () => {

const isLoggedIn = !!patreonData;

const showTestBench = isDev() && isLocal();
const showTestBench = (isDev() && isLocal()) || isFullPath("/test");
const showClusterCompute = isLoggedIn; // || isDev();
const showClusterComputeConsole = false; // isLocal();

Expand Down
86 changes: 74 additions & 12 deletions src/components/SearchSeeds/SearchViews/Shop.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useReducer, useState, useEffect } from "react";
import { Row, Col, Container, Stack, Button } from "react-bootstrap";
import { Row, Col, Container, Stack, Button, Form } from "react-bootstrap";

import WandIcon from "../../Icons/Wand";
import Clickable from "../../Icons/Clickable";
Expand All @@ -12,16 +12,64 @@ import { Square } from "../../helpers";
import SpellSelect from "../../SpellSelect";
import WandSelect from "../../WandSelect";
import cloneDeep from "lodash/cloneDeep.js";
import { ConfigRow } from "../../Settings/helpers";

interface WandAdditionalSettingsProps {
handleClickModal: () => void;
}

const WandAdditionalSettings = (props: WandAdditionalSettingsProps) => {
const { handleClickModal } = props;

return (
<Button onClick={handleClickModal} className="m-1">
Advanced Wand Filter
</Button>
);
};

interface SpellAdditionalSettingsProps {
strict: boolean;
handleClickModal: () => void;
handleAllSomeToggle: (val: boolean) => void;
}

const SpellAdditionalSettingsProps = (props: SpellAdditionalSettingsProps) => {
const { handleClickModal, handleAllSomeToggle, strict } = props;
return (
<>
<Button onClick={handleClickModal} className="m-1">
Advanced Spell Filter
</Button>
<div>
<ConfigRow
left={<>{strict ? "All" : "Some"}</>}
right={
<Form.Switch
checked={strict}
onChange={e => {
handleAllSomeToggle(e.target.checked);
}}
label=""
/>
}
/>
</div>
</>
);
};

interface IShopLevelProps {
handleClicked: (string) => void;
handleClickModal: () => void;
handleAllSomeToggle: (val: boolean) => void;
shop: any;
level: number;
strict: boolean;
}

const ShopLevel = (props: IShopLevelProps) => {
const { handleClicked, handleClickModal, shop, level } = props;
const { handleClicked, handleClickModal, handleAllSomeToggle, shop, level } = props;
return (
<Row>
<Col>
Expand All @@ -41,20 +89,23 @@ const ShopLevel = (props: IShopLevelProps) => {
<LightBulletIcon />
</Clickable>
</Stack>
{!!shop.type && (
<Button onClick={handleClickModal} className="m-1">
Advanced Filter
</Button>
{shop.type === IShopType.wand && <WandAdditionalSettings handleClickModal={handleClickModal} />}
{shop.type === IShopType.item && (
<SpellAdditionalSettingsProps
handleClickModal={handleClickModal}
handleAllSomeToggle={handleAllSomeToggle}
strict={shop.strict}
/>
)}
</div>
</Col>
</Row>
);
};

type IConfig = Array<{ type: string; items: any[] }>;
type IConfig = Array<{ type: string; items: any[]; strict: boolean }>;
interface IAction {
action: string;
action: "type" | "spell-add" | "spell-remove" | "strict";
level: number;
data?: any;
}
Expand All @@ -65,7 +116,7 @@ const shopReducer = (state: IConfig, a: IAction): IConfig => {
switch (action) {
case "type": {
if (!newState[level]) {
newState[level] = { type: data, items: [] };
newState[level] = { type: data, items: [], strict: true };
} else {
newState[level].type = data;
}
Expand All @@ -85,6 +136,10 @@ const shopReducer = (state: IConfig, a: IAction): IConfig => {
newState[level].items.splice(newState[level].items.indexOf(data), 1);
return newState;
}
case "strict": {
newState[level].strict = data;
return newState;
}
}
return state;
};
Expand All @@ -99,14 +154,15 @@ const Shop = (props: IShopProps) => {
const [d, setModal] = useState<[number, number]>([-1, IShopType.item]);
const level = d[0];
const shopType = d[1];
const [shops, dispatch] = useReducer(shopReducer, config.val);
const [shops, dispatch] = useReducer(shopReducer, config.val, () => {
return config.val.map(shop => shop || { type: "", items: [], strict: true });
});

useEffect(() => {
onUpdateConfig({
type: "shop",
path: "",
params: [],
strict: true,
val: shops,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -120,7 +176,11 @@ const Shop = (props: IShopProps) => {
};

const handleTypeClicked = (l, type) => {
dispatch({ data: type, level: l, action: "type" });
dispatch({ action: "type", data: type, level: l });
};

const handleStrictSet = (l, val) => {
dispatch({ action: "strict", data: val, level: l });
};

const handleOpenAdvancedModal = (i, type) => {
Expand All @@ -142,7 +202,9 @@ const Shop = (props: IShopProps) => {
<ShopLevel
handleClicked={type => handleTypeClicked(i, type)}
handleClickModal={() => handleOpenAdvancedModal(i, shop.type)}
handleAllSomeToggle={val => handleStrictSet(i, val)}
level={i}
strict={shop.strict}
shop={shop || {}}
key={i}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IConfigRowProps {
export const ConfigRow = (props: IConfigRowProps) => {
// Maybe make this work with children and not left/right props?
return (
<Row className="align-items-center">
<Row className="align-items-baseline justify-content-between">
<Col>{props.left}</Col>
<Col className="col-auto">{props.right}</Col>
</Row>
Expand Down
5 changes: 5 additions & 0 deletions src/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ export const isLocal = () => {
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
);
};

// Used for matching urls like /test
export const isFullPath = (target: string) => {
return window.location.pathname === target;
};

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ export interface VectorFungalTransformation {
}

interface EmbindModule {
VectorString: {new(): VectorString};
VectorFungalTransformation: {new(): VectorFungalTransformation};
VectorString: {
new(): VectorString;
};
VectorFungalTransformation: {
new(): VectorFungalTransformation;
};
PickForSeed(_0: number, _1: number): VectorFungalTransformation;
}

Expand Down

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ export interface VectorFungalTransformation {
}

interface EmbindModule {
VectorString: {new(): VectorString};
VectorFungalTransformation: {new(): VectorFungalTransformation};
VectorString: {
new(): VectorString;
};
VectorFungalTransformation: {
new(): VectorFungalTransformation;
};
PickForSeed(_0: number, _1: number): VectorFungalTransformation;
}

Expand Down

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion src/services/SeedInfo/infoHandler/InfoProviders/Shop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ export class ShopInfoProvider extends InfoProvider {
];

test(rule: IRule): boolean {
const check = rule.strict ? includesAll : includesSome;
for (let j = 0; j <= this.temples.length; j++) {
const shop = rule.val[j];
if (!shop) {
continue;
}
try {
const check = shop.strict ? includesAll : includesSome;
if (shop.type) {
const info = this.provideLevel(j);
if (shop.type !== info.type) {
Expand Down
Loading

0 comments on commit 01aef21

Please sign in to comment.