Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RashadGasimli/MMRL
Browse files Browse the repository at this point in the history
  • Loading branch information
Rəşad Qasımlı committed Jul 7, 2024
2 parents 04e8a30 + 38eefb9 commit a485816
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 40 deletions.
34 changes: 17 additions & 17 deletions Android/app/default/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
"type": "UNIVERSAL",
"filters": [],
"attributes": [],
"versionCode": 22019,
"versionName": "2.20.19",
"outputFile": "app-default-universal-release-2.20.19-22019.apk"
"versionCode": 22020,
"versionName": "2.20.20",
"outputFile": "app-default-universal-release-2.20.20-22020.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "x86"
"value": "x86_64"
}
],
"attributes": [],
"versionCode": 22019,
"versionName": "2.20.19",
"outputFile": "app-default-x86-release-2.20.19-22019.apk"
"versionCode": 22020,
"versionName": "2.20.20",
"outputFile": "app-default-x86_64-release-2.20.20-22020.apk"
},
{
"type": "ONE_OF_MANY",
Expand All @@ -37,9 +37,9 @@
}
],
"attributes": [],
"versionCode": 22019,
"versionName": "2.20.19",
"outputFile": "app-default-arm64-v8a-release-2.20.19-22019.apk"
"versionCode": 22020,
"versionName": "2.20.20",
"outputFile": "app-default-arm64-v8a-release-2.20.20-22020.apk"
},
{
"type": "ONE_OF_MANY",
Expand All @@ -50,22 +50,22 @@
}
],
"attributes": [],
"versionCode": 22019,
"versionName": "2.20.19",
"outputFile": "app-default-armeabi-v7a-release-2.20.19-22019.apk"
"versionCode": 22020,
"versionName": "2.20.20",
"outputFile": "app-default-armeabi-v7a-release-2.20.20-22020.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "x86_64"
"value": "x86"
}
],
"attributes": [],
"versionCode": 22019,
"versionName": "2.20.19",
"outputFile": "app-default-x86_64-release-2.20.19-22019.apk"
"versionCode": 22020,
"versionName": "2.20.20",
"outputFile": "app-default-x86-release-2.20.20-22020.apk"
}
],
"elementType": "File"
Expand Down
2 changes: 1 addition & 1 deletion Website/src/activitys/fragments/DrawerFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const DrawerFragment = (props: Props) => {
hide();
}}
>
<ListItemText primary={"Changelog"} />
<ListItemText primary={strings("changelog")} />
</ListItemButton>
</List>

Expand Down
1 change: 0 additions & 1 deletion Website/src/components/Markdown/StyledMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export const StyledMarkdown = styled("article")(() => {
borderStyle: "none",
maxWidth: "100%",
boxSizing: "content-box",
backgroundColor: "#ffffff",
'&[align="right"]': { paddingLeft: "20px" },
'&[align="left"]': { paddingRight: "20px" },
},
Expand Down
3 changes: 2 additions & 1 deletion Website/src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export const Markup = (props: Props) => {
React.useEffect(() => {
if (ref.current) {
ref.current.querySelectorAll<HTMLElement>("pre code").forEach((block) => {
hljs.highlightBlock(block);
block.removeAttribute("data-highlighted");
hljs.highlightElement(block);
});
}

Expand Down
15 changes: 3 additions & 12 deletions Website/src/components/ModConfView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useLog } from "@Hooks/native/useLog";
import { ModFS, useModFS } from "@Hooks/useModFS";
import { useTheme } from "@Hooks/useTheme";
import { IsolatedEval } from "@Native/IsolatedEval";
import { os } from "@Native/Os";
import * as React from "react";
import { libraries } from "./libs";

export const ModConfView = React.forwardRef<any, { children: string; modid: string }>((props, ref) => {
const { theme } = useTheme();
export const ModConfView = (props: { children: string; modid: string }) => {
const { modFS } = useModFS();

const { modid, children } = props;
Expand All @@ -31,14 +29,7 @@ export const ModConfView = React.forwardRef<any, { children: string; modid: stri
__modpath: format("MODULECWD"),
window: {
fetch: internalFetch,
open(href: string) {
os.open(href, {
target: "_blank",
features: {
color: theme.palette.primary.main,
},
});
},
open: os.openURL,
},
fetch: internalFetch,

Expand Down Expand Up @@ -66,4 +57,4 @@ export const ModConfView = React.forwardRef<any, { children: string; modid: stri
}

return <></>;
});
};
9 changes: 2 additions & 7 deletions Website/src/components/dapi/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Anchor: React.FC<AnchorProps> = (props) => {
const { context } = useActivity();
const { settings } = useSettings();
const { strings } = useStrings();
const { href, children, noIcon, module, color = theme.palette.text.link, target = "_blank" } = props;
const { href, children, noIcon, module, color = theme.palette.text.link, target = os.WindowMMRLOwn } = props;

const { modules } = useRepos();
const findModule = React.useMemo(() => modules.find((m) => m.id === module), [module]);
Expand Down Expand Up @@ -116,12 +116,7 @@ const Anchor: React.FC<AnchorProps> = (props) => {
const __href = React.useMemo(() => (!(module && findModule) ? href : module), [href]);

const openLink = React.useCallback(() => {
os.open(__href, {
target: target,
features: {
color: theme.palette.background.default,
},
});
os.openURL(__href, target, `color=${theme.palette.background.default}`);
}, [__href]);

return (
Expand Down
65 changes: 64 additions & 1 deletion Website/src/native/Os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,77 @@ class OsClass extends Native {
super(window.__os__);
}

readonly WindowMMRLOwn = "_mmrlOwn";
readonly WindowBlank = "_blank";
readonly WindowSelf = "_self";
readonly WindowParent = "_parent";
readonly WindowTop = "_top";
readonly WindowUnfancedTop = "_unfencedTop";

/**
* @deprecated Use `os.openURL()` instead
*/
public open(url?: string | URL | undefined, options?: OpenOptions): Window | null {
if (this.isAndroid) {
return this.interface.open(url, options?.features?.color || "#fffddd");
return this.interface.open(url, options?.features?.color || "#101010");
} else {
return window.open(url, options?.target, options?.features?.window);
}
}

private _windowObjectReference: Window | null = null;
private _previousURL: string | URL | null | undefined = null;

/**
* Handle opening link on Android and browsers. Android supports additional `color=#101010` feature
* @param url
* @param target
* @param features
* @returns
*/
public openURL(url?: string | URL, target?: string, features?: string): void {
const openRequestedSingleTab = (url?: string | URL, features?: string) => {
if (this._windowObjectReference === null || this._windowObjectReference.closed) {
this._windowObjectReference = open(url, this.WindowMMRLOwn, features);
} else if (this._previousURL !== url) {
this._windowObjectReference = open(url, this.WindowMMRLOwn, features);
/* if the resource to load is different,
then we load it in the already opened secondary window and then
we bring such window back on top/in front of its parent window. */
this._windowObjectReference && this._windowObjectReference.focus();
} else {
this._windowObjectReference.focus();
}
this._previousURL = url;
/* explanation: we store the current url in order to compare url
in the event of another call of this function. */
};

function parseWindowFeatures(features?: string) {
if (!features) return {};
const featurePairs = features.split(",");
const featureObject = {};

featurePairs.forEach((pair) => {
const [key, value] = pair.split("=");
featureObject[key.trim()] = parseInt(value.trim()); // Parse value as integer
});

return featureObject;
}

if (this.isAndroid) {
const parseFetures: Record<string, number | string> = parseWindowFeatures(features);
this.interface.open(url, parseFetures.color || "#101010");
} else {
if (target === this.WindowMMRLOwn) {
openRequestedSingleTab(url, features);
} else {
window.open(url, target, features);
}
}
}

public hasStoragePermission(): boolean {
if (this.isAndroid) {
return this.interface.hasStoragePermission();
Expand Down
23 changes: 23 additions & 0 deletions docs/ModConf/functions/Window.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Window

Here is the window API documentated, restricted.

## `.open`

This is currently the only method avaiable here

```js
const windowFeatures = "left=100,top=100,width=320,height=320";
window.open(
"https://www.mozilla.org/",
"mozillaWindow",
windowFeatures
);
```

Android supports a additional feature `color`

```js
const windowFeatures = "color=#ffffff";
window.open("https://www.mozilla.org/", "mozillaWindow", windowFeatures);
```

0 comments on commit a485816

Please sign in to comment.