Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@luigi-project/client-support-angular
Advanced tools
This library provides several features which make it easier to run your Angular application inside the Luigi micro frontend framework. If you want to know more about Luigi, please have a look at the [Luigi homepage](https://luigi-project.io/).
This library provides several features which make it easier to run your Angular application inside the Luigi micro frontend framework. If you want to know more about Luigi, please have a look at the Luigi homepage.
package.json
:npm install @luigi-project/client-support-angular -s
LuigiAngularSupportModule
:imports: [
........
,LuigiAngularSupportModule
],
These are the features provided by the library:
You can inject this service inside your Angular items in order to:
Observable<Context>
where through subscribing, you can get any context changeLuigiContextService is an abstract class. Its implementation is in the LuigiContextServiceImpl class. If you need to change or extend the implementation, you can easily create a new class extending LuigiContextServiceImpl:
In this class, we added the possibility to "reuse" a component and not initialize it every time you load it (as it could be useful to keep component state.)
export class YourContextService extends LuigiContextServiceImpl {
....
}
Inside your module, redefine the provider:
providers: [
{
provide: LuigiContextService,
useClass: YourContextService
}
]
This service cannot be used directly, but it provides useful features on how to synchronize your Angular application with Luigi navigation.
For example, when the user navigates through different pages within a micro frontend, you can use this feature to update Luigi accordingly. (You can also find more information about this process in the micro frontend routing document.)
In your Angular route configuration, you can add in any of the following preload components:
{path: 'luigi-client-support-preload',component: Sample1Component,data: { fromVirtualTreeRoot: true }}
{path: 'luigi-client-support-preload',component: Sample1Component,data: { fromVirtualTreeRoot: : {"truncate": "*/projects"} }}
{path: 'luigi-client-support-preload',component: Sample1Component,data: { fromVirtualTreeRoot: : {"truncate": "/projects"} }}
{path: 'luigi-client-support-preload',component: Sample2Component,data: { luigiRoute: '/home/sample2' }}
{path: 'luigi-client-support-preload',component: Sample2Component,data: { luigiRoute: '/home/sample2', fromContext: true}}
{path: 'luigi-client-support-preload',component: Sample2Component,data: { luigiRoute: '/home/sample2', fromContext: 'localContext'}}
Under the hood, these components make use of Luigi's linkManager in the following way:
For data: { fromVirtualTreeRoot: true }
, once we load Sample1Component, this Luigi Client API method is called:
luigiClient.linkManager().fromVirtualTreeRoot().withoutSync().navigate({route url});
For data: { fromVirtualTreeRoot: : {"truncate": "*/projects"} }}
or {"truncate": "/projects"} }}
, this Luigi Client API method is called:
luigiClient.linkManager().fromVirtualTreeRoot().withoutSync().navigate({truncated url});
In the above case, the specified string (e.g. projects
) will be cut off from the beginning of the current micro frontend route before being sent to Luigi Core. This can be useful when the micro frontend is not served under the webroot, but under a subfolder. If the truncate string starts with *
, the route will be truncated after the first occurrence of the string following *
.
For data: { luigiRoute: '/home/sample2' }
, this Luigi Client API method is called:
luigiClient.linkManager().withoutSync().navigate(data.luigiRoute);
For data: { luigiRoute: '/home/sample2', fromContext: true }
, this Luigi Client API method is called:
luigiClient.linkManager().fromClosestContext().withoutSync().navigate(data.luigiRoute);
For data: { luigiRoute: '/home/sample2', fromContext: 'localContext' }
, this Luigi Client API method is called:
luigiClient.linkManager().fromContext('localContext').withoutSync().navigate(data.luigiRoute);
To use LuigiAutoRoutingService, this library defines a new RouteReuseStrategy named LuigiRouteStrategy. If you need to define your own RouteReuseStrategy, you can extend LuigiRouteStrategy by overriding it in this way:
export class YourRouteStrategy extends LuigiRouteStrategy {
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
super.retrieve(route);
// Your code
}
}
and define the provider:
{
provide: RouteReuseStrategy,
useClass: YourRouteStrategy
}
Similarly to other components, modals which have a modalPathParam can trigger a change in the URL when navigation occurs. In the Angular router of your Luigi app, you can enable auto-routing for modals using these parameters:
updateModalDataPath
- if set to true
, the URL will be updated automatically every time the user navigates within a modal.addHistoryEntry
- if set to true
, changes in the modal will also add a history element in the history of the tab.For example:
{
path: 'luigi-client-support-preload',
component: LuigiPreloadComponent,
data: { updateModalDataPath: true, addHistoryEntry: true }
}
In the normal Luigi workflow, messages coming from Luigi Client to Luigi Core are processed on the Core and a proper response is sent back. However, in many systems where testing of micro frontends standalone is a necessity, the absence of Luigi Core to send back needed responses to Client micro frontends becomes a case of high coupling. To remove this coupling, we introduce LuigiMockModule for Angular applications. This module is attached to the start of your application where it intercepts all the Client calls and sends a mocked Core response back. This enables users to test their micro frontends standalone without depending on the Core. To use LuigiMockModule, simply add it to the list of imports of your applications entry point. A good practice is to include it in the main testing module of your application as given in the example below:
import {LuigiMockModule} from '@luigi-project/client-support-angular';
/**
* This module is used to run the application for e2e tests.
*/
@NgModule({
imports: [
AppModule,
LuigiMockModule,
],
bootstrap: [AppComponent]
})
export class AppTestingModule {}
To make mocking of Luigi Core easier, you can use a range of utility functions and assertions. Our lightweight Luigi Testing Utilities library provides the necessary basic utility functions needed for your application.
FAQs
This library provides several features which make it easier to run your Angular application inside the Luigi micro frontend framework. If you want to know more about Luigi, please have a look at the [Luigi homepage](https://luigi-project.io/).
We found that @luigi-project/client-support-angular demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.