Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "luna",
"version": "1.16.4-beta",
"version": "1.16.5-beta",
"description": "A client mod for the Tidal music app for plugins",
"author": {
"name": "Inrixia",
Expand Down
4 changes: 4 additions & 0 deletions render/src/exposeTidalInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ for (const script of scripts) {
plugins: [
{
transform({ code }) {
// Tidal react-dom/client
const createRootExport = /([\w$]+)\.createRoot\s*=(?!=)/;
code = code.replace(createRootExport, "$1.createRoot=globalThis.__lunaCreateRoot=");

const actionData = findCreateActionFunction(code);

if (actionData) {
Expand Down
20 changes: 17 additions & 3 deletions render/src/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,22 @@ const jsxRT = resolveCjsModule(/\/jsx-runtime-[^/]+\.js$/, (r) => typeof r.jsx =
if (jsxRT) { jsxRT.default ??= jsxRT; modules["react/jsx-runtime"] = jsxRT; }
else { coreTrace.warn("modules", "Failed to resolve react/jsx-runtime module"); }

const reactDom = resolveCjsModule(/\/react-dom-[^/]+\.js$/, (r) => typeof r.createRoot === "function" && typeof r.hydrateRoot === "function");
if (reactDom) { reactDom.default ??= reactDom; modules["react-dom/client"] = reactDom; }
else { coreTrace.warn("modules", "Failed to resolve react-dom/client module"); }
// Tidal tree shakes hydrateRoot
const reactDomPath = /\/react-dom(-client)?-[^/]+\.js$/;
const reactDom = resolveCjsModule(reactDomPath, (r) => typeof r.createRoot === "function");

// Fallback for react-dom/client
const taggedCreateRoot = (<any>globalThis).__lunaCreateRoot;

if (reactDom) {
reactDom.default ??= reactDom;
modules["react-dom/client"] = reactDom;
} else if (typeof taggedCreateRoot === "function") {
const client: any = { createRoot: taggedCreateRoot };
client.default = client;
modules["react-dom/client"] = client;
} else {
coreTrace.warn("modules", "Failed to resolve react-dom/client module");
}

modules["oby"] = await import("oby");
Loading