Skip to content

Commit 79f8f03

Browse files
send appId in registry/package endpoints
1 parent 5c37d58 commit 79f8f03

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

client/packages/lowcoder/src/comps/comps/remoteComp/loaders.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import {
88
} from "types/remoteComp";
99

1010
async function npmLoader(
11-
remoteInfo: RemoteCompInfo
11+
{
12+
appId,
13+
...remoteInfo
14+
}: RemoteCompInfo & {appId?: string}
1215
): Promise<CompConstructor | null> {
1316

1417
// Falk: removed "packageVersion = "latest" as default value fir packageVersion - to ensure no automatic version jumping.
1518
const localPackageVersion = remoteInfo.packageVersion || "latest";
1619
const { packageName, packageVersion, compName } = remoteInfo;
17-
const entry = `${NPM_PLUGIN_ASSETS_BASE_URL}/${packageName}@${localPackageVersion}/index.js`;
20+
const entry = `${NPM_PLUGIN_ASSETS_BASE_URL}/${appId}/${packageName}@${localPackageVersion}/index.js`;
1821

1922
try {
2023
const module = await import(
@@ -51,7 +54,7 @@ async function bundleLoader(
5154
return comp;
5255
}
5356

54-
export const loaders: Record<RemoteCompSource, RemoteCompLoader> = {
57+
export const loaders: Record<RemoteCompSource, RemoteCompLoader<RemoteCompInfo & {appId?: string}>> = {
5558
npm: npmLoader,
5659
bundle: bundleLoader,
5760
};

client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { CompContext } from "@lowcoder-ee/comps/utils/compContext";
1616
import React from "react";
1717
import type { AppState } from "@lowcoder-ee/redux/reducers";
1818
import { useSelector } from "react-redux";
19+
import { useApplicationId } from "@lowcoder-ee/util/hooks";
1920

2021
const ViewError = styled.div`
2122
display: flex;
@@ -51,7 +52,7 @@ interface RemoteCompReadyAction {
5152

5253
interface RemoteCompViewProps {
5354
isLowcoderComp?: boolean;
54-
loadComp: (packageVersion?: string) => Promise<void>;
55+
loadComp: (packageVersion?: string, appId?: string) => Promise<void>;
5556
loadingElement?: () => React.ReactNode;
5657
errorElement?: (error: any) => React.ReactNode;
5758
source?: RemoteCompSource;
@@ -62,6 +63,7 @@ const RemoteCompView = React.memo((props: React.PropsWithChildren<RemoteCompView
6263
const [error, setError] = useState<any>("");
6364
const editorState = useContext(EditorContext);
6465
const compState = useContext(CompContext);
66+
const appId = useApplicationId();
6567
const lowcoderCompPackageVersion = editorState?.getAppSettings().lowcoderCompVersion || 'latest';
6668
const latestLowcoderCompsVersion = useSelector((state: AppState) => state.npmPlugin.packageVersion['lowcoder-comps']);
6769

@@ -79,7 +81,7 @@ const RemoteCompView = React.memo((props: React.PropsWithChildren<RemoteCompView
7981

8082
useMount(() => {
8183
setError("");
82-
loadComp(packageVersion).catch((e) => {
84+
loadComp(packageVersion, appId).catch((e) => {
8385
setError(String(e));
8486
});
8587
});
@@ -117,7 +119,7 @@ export function remoteComp<T extends RemoteCompInfo = RemoteCompInfo>(
117119
this.compValue = params.value;
118120
}
119121

120-
private async load(packageVersion = 'latest') {
122+
private async load(packageVersion = 'latest', appId = 'none') {
121123
if (!remoteInfo) {
122124
return;
123125
}
@@ -129,7 +131,7 @@ export function remoteComp<T extends RemoteCompInfo = RemoteCompInfo>(
129131
log.error("loader not found, remote info:", remoteInfo);
130132
return;
131133
}
132-
const RemoteExportedComp = await finalLoader({...remoteInfo, packageVersion});
134+
const RemoteExportedComp = await finalLoader({...remoteInfo, packageVersion, appId});
133135
if (!RemoteExportedComp) {
134136
return;
135137
}
@@ -159,7 +161,7 @@ export function remoteComp<T extends RemoteCompInfo = RemoteCompInfo>(
159161
<RemoteCompView
160162
key={key}
161163
isLowcoderComp={remoteInfo?.packageName === 'lowcoder-comps'}
162-
loadComp={(packageVersion?: string) => this.load(packageVersion)}
164+
loadComp={(packageVersion?: string, appId?: string) => this.load(packageVersion, appId)}
163165
loadingElement={loadingElement}
164166
source={remoteInfo?.source}
165167
/>

client/packages/lowcoder/src/comps/utils/remote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function parseCompType(compType: string) {
3939
}
4040

4141
export async function getNpmPackageMeta(packageName: string) {
42-
const res = await axios.get<NpmPackageMeta>(`${NPM_REGISTRY_URL}/${packageName}`);
42+
const res = await axios.get<NpmPackageMeta>(`${NPM_REGISTRY_URL}/none/${packageName}`);
4343
if (res.status >= 400) {
4444
return null;
4545
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy