tangled
alpha
login
or
join now
notnite.com
/
moonlight
3
fork
atom
this repo has no description
3
fork
atom
overview
issues
pulls
pipelines
extension styles
redstonekasi
2 years ago
93006e1d
4b93f9c2
+30
-3
6 changed files
expand all
collapse all
unified
split
packages
core
src
extension
loader.ts
styles.ts
core-extensions
src
moonbase
index.tsx
ui
extensions
settings.tsx
types
src
extension.ts
web-preload
src
index.ts
+4
packages/core-extensions/src/moonbase/index.tsx
···
61
61
}
62
62
}
63
63
};
64
64
+
65
65
+
export const styles = [
66
66
+
".moonbase-settings > :first-child { margin-top: 0px; }"
67
67
+
];
-3
packages/core-extensions/src/moonbase/ui/extensions/settings.tsx
···
357
357
const { Flex } = CommonComponents;
358
358
return (
359
359
<Flex className="moonbase-settings" direction={Flex.Direction.VERTICAL}>
360
360
-
<style>
361
361
-
{".moonbase-settings > :nth-child(2) { margin-top: 0px; }"}
362
362
-
</style>
363
360
{Object.entries(ext.manifest.settings!).map(([name, setting]) => (
364
361
<Setting ext={ext} key={name} name={name} setting={setting} />
365
362
))}
+7
packages/core/src/extension/loader.ts
···
9
9
import { registerPatch, registerWebpackModule } from "../patch";
10
10
import calculateDependencies from "../util/dependency";
11
11
import { createEventEmitter } from "../util/event";
12
12
+
import { registerStyles } from "../styles";
12
13
13
14
const logger = new Logger("core/extension/loader");
14
15
···
67
68
registerWebpackModule({ ...wp, ext: ext.id, id: name });
68
69
}
69
70
}
71
71
+
}
72
72
+
73
73
+
if (exports.styles != null) {
74
74
+
registerStyles(
75
75
+
exports.styles.map((style, i) => `/* ${ext.id}#${i} */ ${style}`)
76
76
+
);
70
77
}
71
78
}
72
79
}
+13
packages/core/src/styles.ts
···
1
1
+
const styles: string[] = [];
2
2
+
3
3
+
export function registerStyles(style: string[]) {
4
4
+
styles.push(...style);
5
5
+
}
6
6
+
7
7
+
export function installStyles() {
8
8
+
for (const style of styles) {
9
9
+
const el = document.createElement("style");
10
10
+
el.textContent = style;
11
11
+
document.documentElement.appendChild(el);
12
12
+
}
13
13
+
}
+1
packages/types/src/extension.ts
···
115
115
export type ExtensionWebExports = {
116
116
patches?: Patch[];
117
117
webpackModules?: Record<string, ExtensionWebpackModule>;
118
118
+
styles?: string[];
118
119
};
119
120
120
121
export type IdentifiedPatch = Patch & {
+5
packages/web-preload/src/index.ts
···
1
1
import { loadProcessedExtensions } from "@moonlight-mod/core/extension/loader";
2
2
import { installWebpackPatcher } from "@moonlight-mod/core/patch";
3
3
+
import { installStyles } from "@moonlight-mod/core/styles";
3
4
import Logger from "@moonlight-mod/core/util/logger";
4
5
5
6
(async () => {
···
23
24
} catch (e) {
24
25
logger.error("Error setting up web-preload", e);
25
26
}
27
27
+
28
28
+
window.addEventListener("DOMContentLoaded", () => {
29
29
+
installStyles();
30
30
+
});
26
31
})();