Skip to content

Commit 8522315

Browse files
authored
Merge pull request #116 from ClayPulse/dev
Add Pulse App backend support
2 parents 1630ced + fca1568 commit 8522315

File tree

6 files changed

+59
-16
lines changed

6 files changed

+59
-16
lines changed

mobile/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ android {
77
applicationId "com.pulse_editor.app"
88
minSdkVersion rootProject.ext.minSdkVersion
99
targetSdkVersion rootProject.ext.targetSdkVersion
10-
versionCode 2
10+
versionCode 4
1111
versionName "v0.1.1-beta"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
aaptOptions {

web/app/(extension-layout)/extension/page.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function ExtensionPage({}) {
4343
setIsRegistered(true);
4444
}
4545

46+
// Load the remote module
4647
mfHost
4748
.loadRemote(`${moduleId}/main`)
4849
.then((module) => {
@@ -58,6 +59,46 @@ export default function ExtensionPage({}) {
5859
.catch((error) => {
5960
console.error("Error loading remote module:", error);
6061
});
62+
63+
// Patch fetch for Pulse App backend calling
64+
const originalFetch = window.fetch;
65+
66+
const patchedFetch = async (
67+
...args: Parameters<typeof fetch>
68+
): Promise<Response> => {
69+
const [resource, config] = args;
70+
const url =
71+
resource instanceof Request ? resource.url : resource.toString();
72+
73+
// Only patch relative URLs (not absolute http/https)
74+
if (/^https?:\/\//i.test(url)) {
75+
return originalFetch(resource, config);
76+
}
77+
78+
const newUrl = remoteOrigin.startsWith(
79+
process.env.NEXT_PUBLIC_CDN_URL ?? "https://cdn.pulse-editor.com",
80+
)
81+
? `${process.env.NEXT_PUBLIC_SERVER_FUNCTION_RUNNER_URL}/${moduleId}/${moduleVersion}/${url.replace("/server-function/", "")}`
82+
: remoteOrigin + url;
83+
84+
console.log(`[FETCH INTERCEPTED]: ${url}${newUrl}`);
85+
console.log(`[App Info] ID: ${moduleId}, Version: ${moduleVersion}`);
86+
87+
const response = await originalFetch(newUrl, config);
88+
89+
if (!response.ok) {
90+
console.warn(`Fetch Error (${response.status}) for ${url}`);
91+
}
92+
93+
return response;
94+
};
95+
96+
window.fetch = patchedFetch;
97+
98+
// // Cleanup on unmount or dependency change
99+
// return () => {
100+
// window.fetch = originalFetch;
101+
// };
61102
}, [remoteOrigin, moduleId, moduleVersion, isMounted]);
62103

63104
if (!isMounted) {

web/components/app-loaders/base-app-loader.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export default function BaseAppLoader({
3232
className="h-full w-full"
3333
src={src}
3434
sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
35+
role="application"
36+
title={moduleId}
37+
aria-label={moduleId}
3538
/>
3639
);
3740
}

web/components/marketplace/app/app-preview-card.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { ContextMenuState, ExtensionApp } from "@/lib/types";
1313
import { DraggableAttributes } from "@dnd-kit/core";
1414
import { SyntheticListenerMap } from "@dnd-kit/core/dist/hooks/utilities";
1515
import {
16-
addToast,
1716
Button,
1817
Chip,
1918
Skeleton,
@@ -91,7 +90,7 @@ export default function AppPreviewCard({
9190
undefined,
9291
);
9392

94-
const [showMFVersionInfo, setShowMFVersionInfo] = useState(false);
93+
const [isHover, setIsHover] = useState(false);
9594

9695
useEffect(() => {
9796
async function fetchVersions() {
@@ -170,13 +169,13 @@ export default function AppPreviewCard({
170169
className="relative h-full min-h-32 w-full"
171170
onMouseEnter={() => {
172171
if (getPlatform() !== PlatformEnum.Capacitor) {
173-
setIsShowInfo(true);
172+
setIsHover(true);
174173
}
175174
}}
176175
// Hide show info when user taps outside of the modal
177176
onMouseLeave={() => {
178177
if (getPlatform() !== PlatformEnum.Capacitor) {
179-
setIsShowInfo(false);
178+
setIsHover(false);
180179
}
181180
}}
182181
>
@@ -275,9 +274,6 @@ export default function AppPreviewCard({
275274
return;
276275
}
277276

278-
addToast({
279-
title: "App Preview Clicked",
280-
});
281277
if (onPress) {
282278
onPress(extension);
283279
} else {
@@ -323,7 +319,7 @@ export default function AppPreviewCard({
323319
<Skeleton className="h-full w-full" isLoaded={false}></Skeleton>
324320
)}
325321
</Button>
326-
{isShowInfo && (
322+
{(isShowInfo || isHover) && (
327323
<div className="absolute bottom-0.5 left-1/2 flex w-fit -translate-x-1/2 justify-center gap-x-0.5">
328324
{isShowUseButton && (
329325
<Button

web/components/marketplace/workflow/workflow-preview-card.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export default function WorkflowPreviewCard({
2929

3030
const [isShowInfo, setIsShowInfo] = useState(false);
3131

32+
const [isHover, setIsHover] = useState(false);
33+
3234
useEffect(() => {
3335
setIsLoaded(true);
3436
}, [workflow]);
@@ -54,18 +56,18 @@ export default function WorkflowPreviewCard({
5456
}
5557

5658
return (
57-
<div className="w-full h-full grid grid-rows-[auto_max-content_max-content] grid-cols-1">
59+
<div className="grid h-full w-full grid-cols-1 grid-rows-[auto_max-content_max-content]">
5860
<div
59-
className="relative h-full w-full min-h-32"
61+
className="relative h-full min-h-32 w-full"
6062
onMouseEnter={() => {
6163
if (getPlatform() !== PlatformEnum.Capacitor) {
62-
setIsShowInfo(true);
64+
setIsHover(true);
6365
}
6466
}}
6567
// Hide show info when user taps outside of the modal
6668
onMouseLeave={() => {
6769
if (getPlatform() !== PlatformEnum.Capacitor) {
68-
setIsShowInfo(false);
70+
setIsHover(false);
6971
}
7072
}}
7173
>
@@ -102,7 +104,7 @@ export default function WorkflowPreviewCard({
102104
<Skeleton className="h-full w-full" isLoaded={false}></Skeleton>
103105
)}
104106
</Button>
105-
{isShowInfo && (
107+
{(isShowInfo || isHover) && (
106108
<div className="absolute bottom-0.5 left-1/2 flex w-full -translate-x-1/2 justify-center gap-x-0.5">
107109
<Button
108110
color="primary"

web/components/views/canvas/nodes/app-node/node-handle.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ export default function NodeHandle({
1414
}) {
1515
return (
1616
<div
17-
className="relative h-fit w-fit bg-content2 text-content2-foreground z-40 pointer-events-none px-2 py-1 flex flex-col justify-center shadow-md data-[direction=left]:rounded-l-lg data-[direction=right]:rounded-r-lg"
17+
className="bg-content2 text-content2-foreground pointer-events-none relative z-40 flex h-fit w-fit flex-col justify-center px-2 py-1 shadow-md data-[direction=left]:rounded-l-lg data-[direction=right]:rounded-r-lg"
1818
data-direction={position}
19+
aria-label="Click on node handle to open node menu"
1920
>
20-
<div className="text-center text-sm ">
21+
<div className="text-center text-sm">
2122
<p>{id}</p>
2223
<p>({param?.type.toString()})</p>
2324
</div>

0 commit comments

Comments
 (0)