npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ditrit/leto-modelizer-plugin-core

v0.28.0

Published

Library that contains all models for modelling tools in Leto's projects.

Downloads

122

Readme

leto-modelizer-plugin-core

Quality Gate Status Reliability Rating Maintainability Rating Security Rating

Code Smells Bugs Vulnerabilities Technical Debt

Lines of Code Coverage Duplicated Lines (%)

Library that contains all models for modeling tools in Leto's projects.

This library is used to create your own plugin for the Leto Modelizer tool.

Get started

Requirements

Install

npm install --save @ditrit/leto-modelizer-plugin-core

Run demo

git clone [email protected]:ditrit/leto-modelizer-plugin-core.git
cd leto-modelizer-plugin-core
npm install
npm run demo

:warning: If you have this error when trying to run demo:

npm warn reify The "linked" install strategy is EXPERIMENTAL and may contain bugs.
npm error Cannot read properties of undefined (reading 'path')

You have to configure npm with:

npm config set install-strategy hoisted

Then

rm -rf node_modules
npm install
npm run demo

Usage

Here are all imports you can use in your plugin:

import {
  Component,
  ComponentDefinition,
  ComponentAttributeDefinition,
  ComponentDrawOption,
  ComponentAttribute,
  ComponentLink,
  ComponentLinkDefinition,
  DefaultDrawer,
  DefaultMetadata,
  DefaultParser,
  DefaultRender,
  ParserLog,
  FileInformation,
  FileInput,
  DefaultData,
  DefaultPlugin,
  DefaultConfiguration,
  Tag,
  Variable,
} from "leto-modelizer-plugin-core";

For more information about all imports please refer to technical documentation and project template.

You can use it in that way:

import { DefaultParser } from 'leto-modelizer-plugin-core';

class FruitParser extends DefaultParser {
  parse(inputs) {
    // Write your own parser here
    return {
      components: [/* ... */], // Generated components from parser
      links: [/* ... */]       // Generated component links from parser
    }
  }
}

export default FruitParser;

To see a complete example, please refer to iactor.

How to create your plugin

You can use this template repository to create your own plugin.

The project template leto-modelizer-plugin-template provides you the default structure of a plugin and all useful scripts to generate resources and other.

It is strongly recommended to use it and the following documentation will make references to it.

Furthermore, in this template there are code comments to explain how to override methods/classes and usages.

How to create your own models

You can read the template documentation to see how to create your own models.

Default Plugin structure

For your plugin to be used by Leto Modelizer, it needs to have this structure:

// src/index.js
export default new DefaultPlugin({
  pluginData: MyPluginData,         // MyPluginData has to extend DefaultData
  pluginDrawer: MyPluginDrawer,     // MyPluginDrawer has to extend DefaultDrawer
  pluginMetadata: MyPluginMetadata, // MyPluginMetadata has to extend DefaultMetadata
  pluginParser: MyPluginParser,     // MyPluginParser has to extend DefaultParser
  pluginRenderer: MyPluginRenderer, // MyPluginRenderer has to extend DefaultRender
});

How it works

| Plugin lifecycle | | :--: | | |

This is the default lifecycle of plugin usage in Leto Modelizer.

Plugin creation

Create you plugin project from leto-modelizer-plugin-template and follow the readme section of the template project.

Plugin configuration

The configuration.md explains how you can configure your plugin.

Events

By default, the plugin sends events if you provide a next() function in DefaultData, like:

new DefaultPlugin({
  event: {
    next: () => {},
  }
})

If you do not, events are still stored in the DefaultData.eventLogs.

When you create your plugin, you can send events to Leto-modelizer to see the progression of your parsing or rendering action.

See EventLog in technical documentation for more information.

Technical documentation

Technical documentation can be found here.