Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@coveops/turbo-core
Advanced tools
Readme
The Coveo Turbo Core library provides common utilities to facilitate turbo-charged JSUI component development.
Disclaimer: This library was built by the community at large and is not an official Coveo JSUI Component. Use this component at your own risk.
npm i @coveops/turbo-core
Coveo's component registration allows for two main strategies to load a component once the scripts and markup are present on the page: Eager and Lazy.
These decorators make it simple to choose the initialization structure without requiring boilerplate code. All of the strategies fallback to component
if the LazyInitialization
class isn't present by importing Coveo.Lazy.js
.
component
The component
decorator injects the Initialization
call. It is the equivalent of having the following code at the bottom of each component:
class CustomComponent extends Component {}
Initialization.registerAutoCreateComponent(CustomComponent);
To use:
Typescript:
import { component } from '@coveopos/turbo-core'
@component
export class CustomComponent extends Component {}
Vanilla Javascript:
const component = require('@coveopos/turbo-core').component;
const CustomComponent = (function(_super) {})(Component);
module.exports.CustomComponent = component(CustomComponent);
lazy
The lazy
decorator injects the LazyInitialization
call. It is the equivalent of having the following code at the bottom of each component:
class CustomComponent extends Component {}
LazyInitialization.registerLazyComponent(CustomComponent.ID, () => {
Initialization.registerAutoCreateComponent(CustomComponent);
return CustomComponent;
});
To use:
Typescript:
import { lazyComponent } from '@coveopos/turbo-core'
@lazyComponent
export class CustomComponent extends Component {}
Vanilla Javascript:
const lazyComponent = require('@coveopos/turbo-core').lazyComponent;
const CustomComponent = (function(_super) {})(Component);
module.exports.CustomComponent = lazyComponent(CustomComponent);
lazy-dependent
The lazy-dependent
decorator injects the LazyInitialization
call and ensures the dependent component is loaded first. It is the equivalent of having the following code at the bottom of each component:
class CustomComponent extends Component {}
LazyInitialization.registerLazyComponent(CustomComponent.ID, () => {
return load<IComponentDefinition>(dependentComponentId).then(() => {
Initialization.registerAutoCreateComponent(CustomComponent);
return CustomComponent;
});
});
The key difference in implementation, is the ID of the dependent component must be passed as an argument to the decorator.
To use:
Typescript:
import { lazyDependentComponent } from '@coveopos/turbo-core'
@lazyDependentComponent('ResultList')
export class CustomComponent extends Component {}
Vanilla Javascript:
const lazyDependentComponent = require('@coveopos/turbo-core').lazyDependentComponent;
const CustomComponent = (function(_super) {})(Component);
module.exports.CustomComponent = lazyDependentComponent('ResultList')(CustomComponent);
requires-fields
The requires-fields
decorator passes a list of fields declared in the platform to the search request:
class CustomComponent extends Component {}
Initialization.registerAutoCreateComponent(CustomComponent);
Initialization.registerComponentFields(CustomComponent.ID, ['field1', 'field2']);
To use:
Typescript:
import { requiresFields } from '@coveopos/turbo-core'
@component()
@requiresFields('field1', 'field2')
export class CustomComponent extends Component {}
Vanilla Javascript:
const component = require('@coveopos/turbo-core').component;
const requiresFields = require('@coveopos/turbo-core').requiresFields;
const CustomComponent = (function(_super) {})(Component);
module.exports.CustomComponent = requiresFields('field1', 'field2')(component(CustomComponent));
swapVar
Merges the Coveo namespace with the namespace of the component so that exported components can be instantiated from the Coveo
global object. Declare it after your exports at the root index
file.
To use:
Typescript:
import { swapVar } from '@coveopos/turbo-core'
swapVar(this)
Vanilla Javascript:
```javascript
const swapVar = require('@coveopos/turbo-core').swapVar;
swapVar(module.exports);
npm run build
npm pack
to get a local build.tgz
file to a test project, and install it.FAQs
A utility library for turbo-charged component development
The npm package @coveops/turbo-core receives a total of 48 weekly downloads. As such, @coveops/turbo-core popularity was classified as not popular.
We found that @coveops/turbo-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.