Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@finos/legend-application

Package Overview
Dependencies
Maintainers
4
Versions
262
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finos/legend-application - npm Package Compare versions

Comparing version 16.0.1 to 16.0.2

5

lib/application/LegendApplication.d.ts

@@ -70,3 +70,6 @@ /**

setupApplicationStore(store: GenericLegendApplicationStore): void;
fetchApplicationConfiguration(baseUrl: string): Promise<[LegendApplicationConfig, ExtensionsConfigurationData]>;
fetchApplicationConfiguration(): Promise<[
LegendApplicationConfig,
ExtensionsConfigurationData
]>;
loadDocumentationRegistryData(config: LegendApplicationConfig): Promise<void>;

@@ -73,0 +76,0 @@ protected abstract configureApplication(input: LegendApplicationConfigurationInput<LegendApplicationConfigurationData>): Promise<LegendApplicationConfig>;

10

lib/application/LegendApplication.js

@@ -93,3 +93,3 @@ /**

}
async fetchApplicationConfiguration(baseUrl) {
async fetchApplicationConfiguration() {
const client = new NetworkClient();

@@ -99,3 +99,3 @@ // app config

try {
configData = await client.get(`${window.location.origin}${baseUrl}config.json`);
configData = await client.get(`${window.location.origin}${this.baseAddress}config.json`);
}

@@ -110,3 +110,3 @@ catch (error) {

try {
versionData = await client.get(`${window.location.origin}${baseUrl}version.json`);
versionData = await client.get(`${window.location.origin}${this.baseAddress}version.json`);
}

@@ -122,3 +122,3 @@ catch (error) {

versionData,
baseAddress: baseUrl,
baseAddress: this.baseAddress,
}),

@@ -177,3 +177,3 @@ configData.extensions ?? {},

// fetch application config
const [config, extensionConfigData] = await this.fetchApplicationConfiguration(this.baseAddress);
const [config, extensionConfigData] = await this.fetchApplicationConfiguration();
this.config = config;

@@ -180,0 +180,0 @@ // setup plugins

@@ -16,14 +16,11 @@ /**

*/
import { createMemoryHistory, type History } from 'history';
import { BrowserPlatform } from '../../stores/platform/BrowserPlatform.js';
import { type GenericLegendApplicationStore } from '../../stores/ApplicationStore.js';
export { createMemoryHistory };
export declare const TEST__BrowserEnvironmentProvider: React.FC<{
children: React.ReactNode;
historyAPI?: History | undefined;
initialEntries: string[];
}>;
export declare const TEST__provideMockedBrowserPlatform: (applicationStore: GenericLegendApplicationStore, customization?: {
mock?: BrowserPlatform;
historyAPI?: History;
}) => BrowserPlatform;
//# sourceMappingURL=BrowserEnvironmentTestUtils.d.ts.map

@@ -17,5 +17,3 @@ import { jsx as _jsx } from "react/jsx-runtime";

*/
import { createMemoryHistory } from 'history';
import { useLocalObservable } from 'mobx-react-lite';
import { Router } from 'react-router';
import { BrowserPlatform } from '../../stores/platform/BrowserPlatform.js';

@@ -26,13 +24,28 @@ import { ApplicationPlatformContext } from '../ApplicationPlatformProvider.js';

import { createMock } from '@finos/legend-shared/test';
export { createMemoryHistory };
export const TEST__BrowserEnvironmentProvider = ({ children, historyAPI }) => {
import { MemoryRouter } from 'react-router';
import { BrowserNavigator } from '../../browser.js';
const TEST__APPLICATION_BASE_URL = '/test';
class TEST__BrowserNavigator extends BrowserNavigator {
getCurrentLocation() {
return TEST__APPLICATION_BASE_URL;
}
}
class TEST__BrowserPlatorm extends BrowserPlatform {
getNavigator() {
return new TEST__BrowserNavigator(() => { }, TEST__APPLICATION_BASE_URL);
}
}
export const TEST__BrowserEnvironmentProvider = ({ children, initialEntries }) => {
const applicationStore = useApplicationStore();
const history = historyAPI ?? createMemoryHistory();
const platform = useLocalObservable(() => new BrowserPlatform(applicationStore, { historyAPI: history }));
return (_jsx(Router, { history: history, children: _jsx(ApplicationPlatformContext.Provider, { value: platform, children: children }) }));
const platform = useLocalObservable(() => new TEST__BrowserPlatorm(applicationStore, {
navigate: () => { },
baseUrl: TEST__APPLICATION_BASE_URL,
}));
return (_jsx(MemoryRouter, { initialEntries: initialEntries, children: _jsx(ApplicationPlatformContext.Provider, { value: platform, children: children }) }));
};
export const TEST__provideMockedBrowserPlatform = (applicationStore, customization) => {
const value = customization?.mock ??
new BrowserPlatform(applicationStore, {
historyAPI: customization?.historyAPI ?? createMemoryHistory(),
new TEST__BrowserPlatorm(applicationStore, {
navigate: () => { },
baseUrl: TEST__APPLICATION_BASE_URL,
});

@@ -39,0 +52,0 @@ const MOCK__BrowserPlatform = require('../ApplicationPlatformProvider.js'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports

@@ -17,5 +17,4 @@ import { jsx as _jsx } from "react/jsx-runtime";

*/
import {} from 'history';
import { useLocalObservable } from 'mobx-react-lite';
import { useHistory } from 'react-router';
import { useNavigate } from 'react-router';
import { BrowserRouter } from 'react-router-dom';

@@ -25,9 +24,13 @@ import { BrowserPlatform } from '../stores/platform/BrowserPlatform.js';

import { useApplicationStore } from './ApplicationStoreProvider.js';
const BrowserPlatformProvider = ({ children }) => {
import { stripTrailingSlash } from '../stores/navigation/BrowserNavigator.js';
const BrowserPlatformProvider = ({ children, baseUrl }) => {
const applicationStore = useApplicationStore();
const historyAPI = useHistory(); // TODO: this is a temporary hack until we upgrade react-router
const platform = useLocalObservable(() => new BrowserPlatform(applicationStore, { historyAPI }));
const navigate = useNavigate();
const platform = useLocalObservable(() => new BrowserPlatform(applicationStore, {
navigate,
baseUrl: stripTrailingSlash(baseUrl),
}));
return (_jsx(ApplicationPlatformContext.Provider, { value: platform, children: children }));
};
export const BrowserEnvironmentProvider = ({ children, baseUrl }) => (_jsx(BrowserRouter, { basename: baseUrl, children: _jsx(BrowserPlatformProvider, { children: children }) }));
export const BrowserEnvironmentProvider = ({ children, baseUrl }) => (_jsx(BrowserRouter, { basename: stripTrailingSlash(baseUrl), children: _jsx(BrowserPlatformProvider, { baseUrl: baseUrl, children: children }) }));
//# sourceMappingURL=BrowserEnvironmentProvider.js.map
{
"name": "@finos/legend-application",
"version": "16.0.1",
"version": "16.0.2",
"description": "Legend application core",

@@ -50,6 +50,5 @@ "keywords": [

"@finos/legend-shared": "workspace:*",
"@types/react": "18.3.9",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.0",
"@types/react-router-dom": "5.3.3",
"history": "5.3.0",
"mobx": "6.13.3",

@@ -61,4 +60,4 @@ "mobx-react-lite": "4.0.7",

"react-dom": "18.3.1",
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
"react-router": "6.26.2",
"react-router-dom": "6.26.2",
"serializr": "3.0.2",

@@ -76,8 +75,8 @@ "xterm": "5.3.0",

"cross-env": "7.0.3",
"eslint": "8.57.1",
"eslint": "9.12.0",
"jest": "29.7.0",
"npm-run-all": "4.1.5",
"rimraf": "6.0.1",
"sass": "1.79.3",
"typescript": "5.6.2"
"sass": "1.79.4",
"typescript": "5.6.3"
},

@@ -84,0 +83,0 @@ "peerDependencies": {

@@ -27,3 +27,3 @@ /**

addressPatterns: string[];
renderer: React.FC | React.ReactElement;
renderer: () => React.ReactNode;
};

@@ -30,0 +30,0 @@ export type VirtualAssistantViewConfiguration = {

@@ -16,15 +16,8 @@ /**

*/
import type { History } from 'history';
import { type NavigationAddress, type NavigationLocation, type ApplicationNavigator, type NavigationLocationParameterValue, type NavigationZone } from './NavigationService.js';
import { Route, Switch, Redirect, matchPath, generatePath, useParams } from 'react-router';
import { Route, Routes, matchRoutes, generatePath, useParams, type NavigateFunction } from 'react-router';
export { BrowserRouter } from 'react-router-dom';
export { Route, Switch, Redirect, useParams, matchPath, generatePath };
export { Route, Routes, useParams, matchRoutes, generatePath };
export declare const useNavigationZone: () => NavigationZone;
/**
* This clashes between react-router (older version) and React typings, so this is the workaround
* We will remove this when we move forward with our react-router upgrade
* See https://github.com/finos/legend-studio/issues/688
*/
export type TEMPORARY__ReactRouterComponentType = any;
/**
* Prefix URL patterns coming from extensions with `/extensions/`

@@ -34,4 +27,6 @@ * to avoid potential conflicts with main routes.

export declare const generateExtensionUrlPattern: (pattern: string) => string;
export declare function stripTrailingSlash(url: string): string;
export declare class BrowserNavigator implements ApplicationNavigator {
private readonly historyAPI;
private readonly navigate;
private readonly baseUrl;
private _isNavigationBlocked;

@@ -43,3 +38,3 @@ private _forceBypassNavigationBlocking;

onNativePlatformNavigationBlock?: (() => void) | undefined;
constructor(historyApiClient: History);
constructor(navigate: NavigateFunction, baseUrl: string);
private get window();

@@ -46,0 +41,0 @@ goToLocation(location: NavigationLocation, options?: {

@@ -19,7 +19,7 @@ /**

import { NAVIGATION_ZONE_PREFIX, } from './NavigationService.js';
import { Route, Switch, Redirect, matchPath, generatePath, useParams, useLocation, } from 'react-router';
import { Route, Routes, matchRoutes, generatePath, useParams, useLocation, } from 'react-router';
export { BrowserRouter } from 'react-router-dom';
export { Route, Switch, Redirect, useParams, matchPath, generatePath };
export { Route, Routes, useParams, matchRoutes, generatePath };
export const useNavigationZone = () => {
const location = useLocation(); // TODO: this is a temporary hack until we upgrade react-router
const location = useLocation();
return location.hash.substring(NAVIGATION_ZONE_PREFIX.length);

@@ -32,4 +32,12 @@ };

export const generateExtensionUrlPattern = (pattern) => `/extensions/${pattern}`.replace(/^\/extensions\/\//, '/extensions/');
export function stripTrailingSlash(url) {
let _url = url;
while (_url.endsWith('/')) {
_url = _url.slice(0, -1);
}
return _url;
}
export class BrowserNavigator {
historyAPI;
navigate;
baseUrl;
_isNavigationBlocked = false;

@@ -46,2 +54,3 @@ _forceBypassNavigationBlocking = false;

event.returnValue = '';
event.preventDefault();
}

@@ -51,3 +60,3 @@ };

onNativePlatformNavigationBlock;
constructor(historyApiClient) {
constructor(navigate, baseUrl) {
makeObservable(this, {

@@ -59,3 +68,4 @@ _isNavigationBlocked: observable,

});
this.historyAPI = historyApiClient;
this.navigate = navigate;
this.baseUrl = baseUrl;
}

@@ -117,7 +127,6 @@ get window() {

generateAddress(location) {
return (this.window.location.origin +
this.historyAPI.createHref({ pathname: location }));
return this.window.location.origin + this.baseUrl + location;
}
updateCurrentLocation(location) {
this.historyAPI.push(location);
this.navigate(location);
}

@@ -140,3 +149,3 @@ updateCurrentZone(zone) {

getCurrentLocation() {
return this.historyAPI.location.pathname;
return this.window.location.pathname.substring(this.baseUrl.length);
}

@@ -143,0 +152,0 @@ getCurrentLocationParameters() {

@@ -16,3 +16,2 @@ /**

*/
import type { History } from 'history';
import { BrowserNavigator } from '../navigation/BrowserNavigator.js';

@@ -22,6 +21,8 @@ import { ApplicationPlatform } from './ApplicationPlatform.js';

import type { GenericLegendApplicationStore } from '../ApplicationStore.js';
import type { NavigateFunction } from 'react-router';
export declare class BrowserPlatform extends ApplicationPlatform {
readonly navigator: BrowserNavigator;
constructor(applicationStore: GenericLegendApplicationStore, config: {
historyAPI: History;
navigate: NavigateFunction;
baseUrl: string;
});

@@ -28,0 +29,0 @@ getNavigator(): ApplicationNavigator;

@@ -23,3 +23,3 @@ /**

super(applicationStore);
this.navigator = new BrowserNavigator(config.historyAPI);
this.navigator = new BrowserNavigator(config.navigate, config.baseUrl);
}

@@ -26,0 +26,0 @@ getNavigator() {

{
"name": "@finos/legend-application",
"version": "16.0.1",
"version": "16.0.2",
"description": "Legend application core",

@@ -48,8 +48,7 @@ "keywords": [

"dependencies": {
"@finos/legend-art": "7.1.60",
"@finos/legend-shared": "10.0.56",
"@types/react": "18.3.9",
"@finos/legend-art": "7.1.61",
"@finos/legend-shared": "10.0.57",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.0",
"@types/react-router-dom": "5.3.3",
"history": "5.3.0",
"mobx": "6.13.3",

@@ -61,4 +60,4 @@ "mobx-react-lite": "4.0.7",

"react-dom": "18.3.1",
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
"react-router": "6.26.2",
"react-router-dom": "6.26.2",
"serializr": "3.0.2",

@@ -73,11 +72,11 @@ "xterm": "5.3.0",

"devDependencies": {
"@finos/legend-dev-utils": "2.1.23",
"@finos/legend-dev-utils": "2.1.24",
"@jest/globals": "29.7.0",
"cross-env": "7.0.3",
"eslint": "8.57.1",
"eslint": "9.12.0",
"jest": "29.7.0",
"npm-run-all": "4.1.5",
"rimraf": "6.0.1",
"sass": "1.79.3",
"typescript": "5.6.2"
"sass": "1.79.4",
"typescript": "5.6.3"
},

@@ -84,0 +83,0 @@ "peerDependencies": {

@@ -187,5 +187,5 @@ /**

async fetchApplicationConfiguration(
baseUrl: string,
): Promise<[LegendApplicationConfig, ExtensionsConfigurationData]> {
async fetchApplicationConfiguration(): Promise<
[LegendApplicationConfig, ExtensionsConfigurationData]
> {
const client = new NetworkClient();

@@ -197,3 +197,3 @@

configData = await client.get<LegendApplicationConfigurationData>(
`${window.location.origin}${baseUrl}config.json`,
`${window.location.origin}${this.baseAddress}config.json`,
);

@@ -216,3 +216,3 @@ } catch (error) {

versionData = await client.get<LegendApplicationVersionData>(
`${window.location.origin}${baseUrl}version.json`,
`${window.location.origin}${this.baseAddress}version.json`,
);

@@ -232,3 +232,3 @@ } catch (error) {

versionData,
baseAddress: baseUrl,
baseAddress: this.baseAddress,
}),

@@ -327,3 +327,3 @@ configData.extensions ?? {},

const [config, extensionConfigData] =
await this.fetchApplicationConfiguration(this.baseAddress);
await this.fetchApplicationConfiguration();
this.config = config;

@@ -330,0 +330,0 @@

@@ -42,3 +42,3 @@ /**

addressPatterns: string[];
renderer: React.FC | React.ReactElement;
renderer: () => React.ReactNode;
};

@@ -45,0 +45,0 @@

@@ -17,3 +17,2 @@ /**

import type { History } from 'history';
import {

@@ -38,23 +37,16 @@ addQueryParametersToUrl,

Route,
Switch,
Redirect,
matchPath,
Routes,
matchRoutes,
generatePath,
useParams,
useLocation,
type NavigateFunction,
} from 'react-router';
export { BrowserRouter } from 'react-router-dom';
export { Route, Switch, Redirect, useParams, matchPath, generatePath };
export { Route, Routes, useParams, matchRoutes, generatePath };
export const useNavigationZone = (): NavigationZone => {
const location = useLocation() as { hash: string }; // TODO: this is a temporary hack until we upgrade react-router
const location = useLocation();
return location.hash.substring(NAVIGATION_ZONE_PREFIX.length);
};
/**
* This clashes between react-router (older version) and React typings, so this is the workaround
* We will remove this when we move forward with our react-router upgrade
* See https://github.com/finos/legend-studio/issues/688
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type TEMPORARY__ReactRouterComponentType = any;

@@ -68,4 +60,13 @@ /**

export function stripTrailingSlash(url: string): string {
let _url = url;
while (_url.endsWith('/')) {
_url = _url.slice(0, -1);
}
return _url;
}
export class BrowserNavigator implements ApplicationNavigator {
private readonly historyAPI: History;
private readonly navigate: NavigateFunction;
private readonly baseUrl: string;
private _isNavigationBlocked = false;

@@ -82,2 +83,3 @@ private _forceBypassNavigationBlocking = false;

event.returnValue = '';
event.preventDefault();
}

@@ -89,3 +91,3 @@ };

constructor(historyApiClient: History) {
constructor(navigate: NavigateFunction, baseUrl: string) {
makeObservable<BrowserNavigator, '_isNavigationBlocked'>(this, {

@@ -98,3 +100,4 @@ _isNavigationBlocked: observable,

this.historyAPI = historyApiClient;
this.navigate = navigate;
this.baseUrl = baseUrl;
}

@@ -174,10 +177,7 @@

generateAddress(location: NavigationLocation): string {
return (
this.window.location.origin +
this.historyAPI.createHref({ pathname: location })
);
return this.window.location.origin + this.baseUrl + location;
}
updateCurrentLocation(location: NavigationLocation): void {
this.historyAPI.push(location);
this.navigate(location);
}

@@ -207,3 +207,3 @@

getCurrentLocation(): NavigationLocation {
return this.historyAPI.location.pathname;
return this.window.location.pathname.substring(this.baseUrl.length);
}

@@ -210,0 +210,0 @@

@@ -17,3 +17,2 @@ /**

import type { History } from 'history';
import { BrowserNavigator } from '../navigation/BrowserNavigator.js';

@@ -24,2 +23,3 @@ import { ApplicationPlatform } from './ApplicationPlatform.js';

import { LEGEND_APPLICATION_PARAM_TOKEN } from '../../__lib__/LegendApplicationNavigation.js';
import type { NavigateFunction } from 'react-router';

@@ -31,6 +31,6 @@ export class BrowserPlatform extends ApplicationPlatform {

applicationStore: GenericLegendApplicationStore,
config: { historyAPI: History },
config: { navigate: NavigateFunction; baseUrl: string },
) {
super(applicationStore);
this.navigator = new BrowserNavigator(config.historyAPI);
this.navigator = new BrowserNavigator(config.navigate, config.baseUrl);
}

@@ -37,0 +37,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc