Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
},
"formatter": {
"indentStyle": "space",
"lineWidth": 120
"lineWidth": 120,
"lineEnding": "auto"
},
"javascript": {
"jsxRuntime": "reactClassic",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
"check:ci": "biome ci",
"check:write": "biome check --write",
"check:types": "pnpm run -r check:types",
"build:proto": "node scripts/build-proto.mjs",
"prepare": "husky install"
},
"devDependencies": {
"@biomejs/biome": "catalog:lint",
"husky": "catalog:lint"
"husky": "catalog:lint",
"@protobuf-ts/plugin": "^2.9.0",
"@protobuf-ts/protoc": "^2.9.0"
}
}
3 changes: 3 additions & 0 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ window._moonlightBrowserInit = async () => {
// @ts-expect-error Set by esbuild
branch: MOONLIGHT_BRANCH as MoonlightBranch,

getFullConfig() {
return config;
},
getConfig(ext) {
return getConfig(ext, config);
},
Expand Down
1 change: 1 addition & 0 deletions packages/core-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"@moonlight-mod/core": "workspace:*",
"@moonlight-mod/types": "workspace:*",
"@protobuf-ts/runtime": "catalog:",
"microdiff": "catalog:",
"nanotar": "catalog:"
},
Expand Down
28 changes: 28 additions & 0 deletions packages/core-extensions/src/cloudSync/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { ExtensionWebExports } from "@moonlight-mod/types";

export const webpackModules: ExtensionWebExports["webpackModules"] = {
proto: {},

sync: {
dependencies: [
{ id: "discord/packages/flux" },
{ id: "discord/Dispatcher" },
{ id: "discord/utils/HTTPUtils" },
{ id: "react" },
{ ext: "notices", id: "notices" },
{ ext: "spacepack", id: "spacepack" },
{ ext: "cloudSync", id: "proto" }
],
entrypoint: true
}
};

export const patches: ExtensionWebExports["patches"] = [
{
find: "UserSettingsProto must not be a string",
replace: {
match: /\["USER_SETTINGS_PROTO_UPDATE"\],(\i)=>\{/,
replacement: `$&require("cloudSync_sync").default.onUserSettingsProtoUpdate($1);`
}
}
];
13 changes: 13 additions & 0 deletions packages/core-extensions/src/cloudSync/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://moonlight-mod.github.io/manifest.schema.json",
"id": "cloudSync",
"apiLevel": 2,
"meta": {
"name": "Cloud Sync",
"tagline": "Sync your moonlight settings to Discord",
"authors": ["moonlight"],
"tags": ["qol"]
},
"dependencies": ["spacepack", "notices"],
"cors": []
}
9 changes: 9 additions & 0 deletions packages/core-extensions/src/cloudSync/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { deflateSync, inflateSync } from "node:zlib";

export function toBinary(buf: string): Uint8Array {
return new Uint8Array(deflateSync(new TextEncoder().encode(buf)));
}

export function fromBinary(buf: Uint8Array): string {
return new TextDecoder().decode(inflateSync(buf));
}
26 changes: 26 additions & 0 deletions packages/core-extensions/src/cloudSync/proto/settings.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";

message CustomUserSettings {
message Versions {
uint32 client_version = 1;
uint32 server_version = 2;
uint32 data_version = 3;
}

message SettingsEntry {
bytes data = 1;
}

message MoonlightSettingsEntry {
uint32 version = 1;
bytes data = 2;
}

message ClientSettings {
SettingsEntry shared = 1;
MoonlightSettingsEntry moonlight = 14045442;
}

optional Versions versions = 1;
optional ClientSettings settings = 2;
}
Loading