Skip to content

Commit

Permalink
fix lowcoder-comps base url in embedded apps
Browse files Browse the repository at this point in the history
  • Loading branch information
raheeliftikhar5 committed Nov 7, 2024
1 parent fcf6596 commit fb3aecf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/packages/lowcoder-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lowcoder-sdk",
"version": "2.4.15",
"version": "2.4.16",
"type": "module",
"files": [
"src",
Expand Down
8 changes: 4 additions & 4 deletions client/packages/lowcoder/src/appView/AppViewInstance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ export class AppViewInstance<I = any, O = any> {
});

await DatasourceApi.fetchJsDatasourceByApp(this.appId).then((res) => {
res.data.data.forEach((i) => {
res.data?.data?.forEach((i) => {
registryDataSourcePlugin(i.type, i.id, i.pluginDefinition);
});
});

setGlobalSettings({
orgCommonSettings: data.data.orgCommonSettings,
orgCommonSettings: data?.data?.orgCommonSettings,
});

finalAppDsl = data.data.applicationDSL;
finalModuleDslMap = data.data.moduleDSL;
finalAppDsl = data?.data?.applicationDSL || {};
finalModuleDslMap = data?.data?.moduleDSL || {};
}

if (this.options.moduleInputs && this.isModuleDSL(finalAppDsl)) {
Expand Down
10 changes: 8 additions & 2 deletions client/packages/lowcoder/src/comps/comps/remoteComp/loaders.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NPM_PLUGIN_ASSETS_BASE_URL } from "constants/npmPlugins";
import { sdkConfig } from "@lowcoder-ee/constants/sdkConfig";
import { ASSETS_BASE_URL, NPM_PLUGIN_ASSETS_BASE_URL } from "constants/npmPlugins";
import { trans } from "i18n";
import { CompConstructor } from "lowcoder-core";
import {
Expand All @@ -17,7 +18,12 @@ async function npmLoader(
// Falk: removed "packageVersion = "latest" as default value fir packageVersion - to ensure no automatic version jumping.
const localPackageVersion = remoteInfo.packageVersion || "latest";
const { packageName, packageVersion, compName } = remoteInfo;
const entry = `${NPM_PLUGIN_ASSETS_BASE_URL}/${appId}/${packageName}@${localPackageVersion}/index.js`;

const pluginBaseUrl = REACT_APP_BUNDLE_TYPE === 'sdk' && sdkConfig.baseURL
? `${sdkConfig.baseURL}/${ASSETS_BASE_URL}`
: NPM_PLUGIN_ASSETS_BASE_URL;

const entry = `${pluginBaseUrl}/${appId}/${packageName}@${localPackageVersion}/index.js`;

try {
const module = await import(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { CompContext } from "@lowcoder-ee/comps/utils/compContext";
import React from "react";
import type { AppState } from "@lowcoder-ee/redux/reducers";
import { useSelector } from "react-redux";
import { useApplicationId } from "@lowcoder-ee/util/hooks";
import { ExternalEditorContext } from "@lowcoder-ee/util/context/ExternalEditorContext";

const ViewError = styled.div`
display: flex;
Expand Down Expand Up @@ -63,7 +63,8 @@ const RemoteCompView = React.memo((props: React.PropsWithChildren<RemoteCompView
const [error, setError] = useState<any>("");
const editorState = useContext(EditorContext);
const compState = useContext(CompContext);
const appId = useApplicationId();
const externalEditorState = useContext(ExternalEditorContext);
const appId = externalEditorState.applicationId;
const lowcoderCompPackageVersion = editorState?.getAppSettings().lowcoderCompVersion || 'latest';
const latestLowcoderCompsVersion = useSelector((state: AppState) => state.npmPlugin.packageVersion['lowcoder-comps']);

Expand Down
2 changes: 1 addition & 1 deletion client/packages/lowcoder/src/constants/npmPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// export const SERVER_HOST = `${REACT_APP_NODE_SERVICE_URL ?? ""}`;
// export const NPM_REGISTRY_URL = `${SERVER_HOST}/node-service/api/npm/registry`;
// export const NPM_PLUGIN_ASSETS_BASE_URL = `${SERVER_HOST}/node-service/api/npm/package`;

export const ASSETS_BASE_URL = `api/npm/package`;
export const SERVER_HOST = `${REACT_APP_API_SERVICE_URL ?? ""}`;
export const NPM_REGISTRY_URL = `${SERVER_HOST}/api/npm/registry`;
export const NPM_PLUGIN_ASSETS_BASE_URL = `${SERVER_HOST}/api/npm/package`;

0 comments on commit fb3aecf

Please sign in to comment.