-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from moonlight-mod/webpack-modules
Newly structured Webpack modules
- Loading branch information
Showing
36 changed files
with
754 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/// <reference types="./packages/types/src/index.d.ts" /> | ||
/// <reference types="./packages/types/src/index" /> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
import { ExtensionWebExports } from "@moonlight-mod/types"; | ||
|
||
import { react } from "./react"; | ||
import { flux } from "./flux"; | ||
import { stores } from "./stores"; | ||
import { http } from "./http"; | ||
import { components } from "./components"; | ||
import { fluxDispatcher } from "./fluxDispatcher"; | ||
|
||
export const webpackModules: ExtensionWebExports["webpackModules"] = { | ||
react, | ||
flux, | ||
stores, | ||
http, | ||
components, | ||
fluxDispatcher | ||
components: { | ||
dependencies: [ | ||
{ ext: "spacepack", id: "spacepack" }, | ||
"MasonryList:", | ||
".flexGutterSmall," | ||
] | ||
}, | ||
|
||
flux: { | ||
dependencies: [ | ||
{ ext: "spacepack", id: "spacepack" }, | ||
"useStateFromStores:function" | ||
] | ||
}, | ||
|
||
fluxDispatcher: { | ||
dependencies: [ | ||
{ ext: "spacepack", id: "spacepack" }, | ||
"isDispatching", | ||
"dispatch" | ||
] | ||
}, | ||
|
||
react: { | ||
dependencies: [ | ||
{ ext: "spacepack", id: "spacepack" }, | ||
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", | ||
/\.?version(?:=|:)/, | ||
/\.?createElement(?:=|:)/ | ||
] | ||
}, | ||
|
||
stores: { | ||
dependencies: [{ ext: "common", id: "flux" }] | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
packages/core-extensions/src/common/webpackModules/components.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; | ||
|
||
const Components = spacepack.findByCode("MasonryList:function")[0].exports; | ||
const MarkdownParser = spacepack.findByCode( | ||
"parseAutoModerationSystemMessage:" | ||
)[0].exports.default; | ||
const LegacyText = spacepack.findByCode(".selectable", ".colorStandard")[0] | ||
.exports.default; | ||
const Flex = spacepack.findByCode(".flex" + "GutterSmall,")[0].exports.default; | ||
const CardClasses = spacepack.findByCode("card", "cardHeader", "inModal")[0] | ||
.exports; | ||
const ControlClasses = spacepack.findByCode( | ||
"title", | ||
"titleDefault", | ||
"dividerDefault" | ||
)[0].exports; | ||
|
||
// We use CJS export here because merging the exports from Components is annoying as shit | ||
module.exports = { | ||
...Components, | ||
MarkdownParser, | ||
LegacyText, | ||
Flex, | ||
CardClasses, | ||
ControlClasses | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; | ||
|
||
module.exports = spacepack.findByCode( | ||
["useStateFromStores", ":function"].join("") | ||
)[0].exports; |
6 changes: 6 additions & 0 deletions
6
packages/core-extensions/src/common/webpackModules/fluxDispatcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; | ||
|
||
module.exports = spacepack.findByExports( | ||
"isDispatching", | ||
"dispatch" | ||
)[0].exports.default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; | ||
|
||
module.exports = spacepack.findByCode( | ||
"__SECRET_INTERNALS_DO_NOT_USE" + "_OR_YOU_WILL_BE_FIRED", | ||
/\.?version(?:=|:)/, | ||
/\.?createElement(?:=|:)/ | ||
)[0].exports; |
23 changes: 23 additions & 0 deletions
23
packages/core-extensions/src/common/webpackModules/stores.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Flux from "@moonlight-mod/wp/common_flux"; | ||
|
||
module.exports = new Proxy( | ||
{}, | ||
{ | ||
get: function (target, key, receiver) { | ||
const allStores = Flux.Store.getAll(); | ||
|
||
let targetStore; | ||
for (const store of allStores) { | ||
const name = store.getName(); | ||
if (name.length === 1) continue; // filter out unnamed stores | ||
|
||
if (name === key) { | ||
targetStore = store; | ||
break; | ||
} | ||
} | ||
|
||
return targetStore; | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.