
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@mdi/element
Advanced tools
Simple TypeScript wrapper for creating a Web Component.
npm install @mdi/element
Example Usage: Element-Hello-World
To make things easier setup the project assuming the custom element <hello-world message="Hello World!"></hello-world>
.
📂 src/
📂 hello/
📂 world/
📃 world.ts
📃 world.html
📃 world.css
📃 rollup.config.js
📃 tsconfig.json
📃 package.json
world.ts
)import { Component, Prop, Part } from '@mdi/element';
import template from "./world.html";
import style from './world.css';
@Component({
selector: 'hello-world',
style,
template
})
export default class HelloWorld extends HTMLElement {
@Prop() message = 'Hello World';
@Part() $message: HTMLDivElement;
render(changes) {
if (changes.message) {
this.$message.innerText = this.message;
}
}
}
world.html
)<div part="message">Default!</div>
world.css
):host {
display: block;
}
[part~=message] {
/* Style Part */
}
Starting with a simple component can allow one to extend it with more features later on. This can be done by extending components.
📂 src/
📂 hello/
📂 world/
📃 world.ts
📃 world.html
📃 world.css
📂 worldButton/
📃 worldButton.ts
📃 worldButton.html
📃 worldButton.css
worldButton.ts
)import { Component, Prop, Part } from '@mdi/element';
import HelloWorld from '../world/world';
import style from './worldButton.css';
import template from './worldButton.html';
@Component({
selector: 'hello-world-button',
style,
template
})
export default class HelloWorldButton extends HelloWorld {
@Part() $button: HTMLButtonElement;
renderCallback() {
this.$button.addEventListener('click', () => {
alert(this.message);
});
}
}
worldButton.html
)<button part="button">
<parent/> <!-- <div>Default!</div> -->
</button>
worldButton.css
)[part~=button] {
border-radius: 0.25rem;
border: #ddd;
color: #222;
}
@Local(initialValue[, key])
To access localStorage values bind them to variable.
// Default to 42
@Local('42') foo;
// Default to 42 and share a global key
@Local('42', 'sharedKeyName') foo;
# Build
npm run build
# View files in dist/
# Then link for use locally
npm link
# Within a local project directory
npm link @mdi/element
Some other notes about unique use cases that are handled.
Component()
ConfigUtility base classes can be defined without a config. These are rarely used, but are supported.
import { Component } from '@mdi/element';
@Component()
export default class HelloOverlay extends HtmlElement {
static open() {
}
close() {
}
}
FAQs
Web Component Element for TypeScript
The npm package @mdi/element receives a total of 0 weekly downloads. As such, @mdi/element popularity was classified as not popular.
We found that @mdi/element demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.