Skip to content

Commit 23ff252

Browse files
committed
fusion 3.0 support
1 parent ab981e4 commit 23ff252

File tree

7 files changed

+28
-23
lines changed

7 files changed

+28
-23
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@
4141
"@rbxts/sift": "^0.0.6",
4242
"@rbxts/signal": "^1.1.1",
4343
"@rbxts/t": "^3.1.1",
44-
"@rbxts/ui-labs": "2.2.0-test1"
44+
"@rbxts/ui-labs": "^2.2.0-ts.1"
4545
}
4646
}

src/UI/StoryPreview/PreviewController/Mounters/Functional.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function Functional(props: MounterProps<"Functional">) {
1010
.then((cleanup) => {
1111
unmounter.current = cleanup;
1212
})
13-
.catch((err) => warn("UI-Labs: Function story errored when mounting. The cleanup function will not be executed: ", err));
13+
.catch((err) => warn("UI Labs: Function story errored when mounting. The cleanup function will not be executed: ", err));
1414
return () => {
1515
if (unmounter.current) {
1616
const [success, err] = pcall(unmounter.current);
1717
if (!success) {
18-
warn("UI-Labs: The cleanup function errored when unmounting. This may cause a memory leak: ", err);
18+
warn("UI Labs: The cleanup function errored when unmounting. This may cause a memory leak: ", err);
1919
}
2020
} else {
21-
warn("UI-Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak.");
21+
warn("UI Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak.");
2222
}
2323
};
2424
}, []);

src/UI/StoryPreview/PreviewController/Mounters/FusionLib/index.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,29 @@ function FusionLib(props: MounterProps<"FusionLib">) {
3434
const fusionProps: InferFusionProps<ConvertedControls> = GetProps({
3535
controls: fusionValues,
3636
target: props.MountFrame,
37+
scope: Cast<Fusion3>(fusion),
3738
});
3839

3940
const [success, value] = pcall(() => result.story(fusionProps));
4041
if (!success) {
41-
warn("UI-Labs: Fusion story errored when mounting. The cleanup function will not be executed: ", value);
42+
warn("UI Labs: Fusion story errored when mounting. The cleanup function will not be executed: ", value);
4243
return () => {
43-
warn("UI-Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak.");
44+
warn("UI Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak.");
4445
};
4546
}
46-
return typeIs(value, "Instance") ? () => value.Destroy() : value;
47+
return value ? (typeIs(value, "Instance") ? () => value.Destroy() : value) : undefined;
4748
}, []);
4849

4950
useStoryUnmount(result, () => {
50-
const [success, err] = pcall(cleanup);
51-
if (!success) {
52-
warn("UI-Labs: The cleanup function errored when unmounting. This may cause a memory leak: ", err);
51+
if (cleanup) {
52+
const [success, err] = pcall(cleanup);
53+
if (!success) {
54+
warn("UI Labs: The cleanup function errored when unmounting. This may cause a memory leak: ", err);
55+
}
56+
} else {
57+
if (version === "Fusion2") {
58+
warn("UI Labs: No cleanup function was returned for Fusion 2.0, there's no way to cleanup the story.");
59+
}
5360
}
5461
if (version === "Fusion3") {
5562
Cast<Fusion3>(fusion).doCleanup(fusion);

src/UI/StoryPreview/PreviewController/Mounters/Generic/index.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function Generic(props: MounterProps<"Generic">) {
3838
for (const listener of listeners.current) {
3939
const [success, err] = pcall(() => listener(controlValues as InferControls<ReturnControls>, controlInfos));
4040
if (!success) {
41-
warn("UI-Labs: Generic Story listener errored when updating.", err);
41+
warn("UI Labs: Generic Story listener errored when updating.", err);
4242
}
4343
}
4444
},
@@ -54,9 +54,9 @@ function Generic(props: MounterProps<"Generic">) {
5454
});
5555
const [success, err] = pcall(() => result.render(storyProps));
5656
if (!success) {
57-
warn("UI-Labs: Generic story errored when mounting. The cleanup function will not be executed: ", err);
57+
warn("UI Labs: Generic story errored when mounting. The cleanup function will not be executed: ", err);
5858
return () => {
59-
warn("UI-Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak.");
59+
warn("UI Labs: The cleanup function was not found. This might be due to the story erroring. This may cause a memory leak.");
6060
};
6161
}
6262
return err;
@@ -71,7 +71,7 @@ function Generic(props: MounterProps<"Generic">) {
7171
listeners.current = [];
7272
const [success, err] = pcall(cleanup);
7373
if (!success) {
74-
warn("UI-Labs: The cleanup function errored when unmounting. This may cause a memory leak: ", err);
74+
warn("UI Labs: The cleanup function errored when unmounting. This may cause a memory leak: ", err);
7575
}
7676
});
7777

src/UI/StoryPreview/PreviewController/Utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function useStoryUnmount(story: StoryBase, unmounter: () => void) {
88
if (story.cleanup) {
99
const [success, err] = pcall(story.cleanup);
1010
if (!success) {
11-
warn("UI-Labs: Error while running cleanup function: ", err);
11+
warn("UI Labs: Error while running cleanup function: ", err);
1212
}
1313
}
1414
});

src/UI/StoryPreview/PreviewController/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useState } from "@rbxts/react";
1+
import React, { useEffect, useState } from "@rbxts/react";
22
import { useProducer } from "@rbxts/react-reflex";
33
import { useStoryRequire } from "UI/StoryPreview/PreviewController/StoryRequire";
44
import { usePlugin } from "Hooks/Reflex/Use/Plugin";
@@ -48,7 +48,7 @@ function PreviewController(props: PreviewControllerProps) {
4848
//Mounting story
4949
if (result === undefined) return;
5050
const check = CheckStory(result);
51-
if (!check.Sucess) return warn("UI-Labs: " + check.Error);
51+
if (!check.Sucess) return warn("UI Labs: " + check.Error);
5252
mountFrame.Name = RemoveExtension(props.PreviewEntry.Module.Name, Configs.Extensions.Story);
5353
const gotRenderer = MountStory(check.Type, props.PreviewEntry, check.Result, mountFrame);
5454
setRenderer({ Key: tostring(newproxy()), MountType: check.Type, Renderer: gotRenderer });

yarn.lock

+4-6
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,10 @@
197197
resolved "https://registry.yarnpkg.com/@rbxts/types/-/types-1.0.791.tgz#8e8dbabc5044ec19b9c063ccf0bb487dcb9cfbc9"
198198
integrity sha512-kKivHGm9n12L7AlKUH7KfBI7dJTZaWs21rqTpzhcknn7mqjpkZxcn6RDaIIFl3x7mMnvUsJ5amVL25zd7xkTug==
199199

200-
"@rbxts/ui-labs@2.2.0-test1":
201-
version "2.2.0-test1"
202-
resolved "https://registry.yarnpkg.com/@rbxts/ui-labs/-/ui-labs-2.2.0-test1.tgz#b1b275521c3cfe868c02ee4096110414e07d3bcf"
203-
integrity sha512-N+38bvrMDZ39/uHcEObHkIpcejrYBKJGNUMZdS5m9V9xxS3HnzNr1axgnCzcdHra5S92bfFolP6rvG3rEUv8Hg==
204-
dependencies:
205-
"@rbxts/fusion" "^0.2.0"
200+
"@rbxts/ui-labs@^2.2.0-ts.1":
201+
version "2.2.0-ts.1"
202+
resolved "https://registry.yarnpkg.com/@rbxts/ui-labs/-/ui-labs-2.2.0-ts.1.tgz#e1a44de5fa69d3700813d7cb307b5592a44c1403"
203+
integrity sha512-pRGI2bqakTdnmwA1+a7JaVZ9DLoBTCKg3Aw+BLzeVT9nd8ofKEzsOXBsLDJYmeECVRt3q8T0Is25wgd0tLxA/A==
206204

207205
"@roblox-ts/luau-ast@=2.0.0":
208206
version "2.0.0"

0 commit comments

Comments
 (0)