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

custom-elements-manifest-deprecator

v1.1.2

Published

A tool for marking Custom Elements Manifest data as 'deprecated'

Downloads

121

Readme

Custom Elements Manifest Deprecator

This package is designed to provide a mechanism to deprecate items in your the Custom Elements Manifest.

The standard approach is to use the @deprecated tag in the JSDoc descriptions.

/**
 * @deprecated This deprecates the class
 *
 */
class MyElement extends HTMLElement {
  /** @deprecated This deprecates the property */
  deprecatedProperty = "some value";
}

The problem is that you can't add it to other elements with JSDoc tags.

/**
 * @attr {boolean} disabled - disables the element
 *
 * @csspart bar - Styles the color of bar
 *
 * @slot - This is a default/unnamed slot
 * @slot container - You can put some elements here
 *
 * @cssprop --text-color - Controls the color of foo
 *
 * @prop {boolean} prop1 - some description
 *
 * @fires custom-event - some description for custom-event
 * @event {MyEventDetail} typed-custom-event - some description for typed-custom-event
 */
class MyElement extends HTMLElement {}

This plugin allows you to deprecate these JSDoc elements using the (@deprecated) string (or one of your choosing). Without wrapping it in the parenthesis, it will deprecate the class instead of the JSDoc element.

/**
 * @attr {boolean} disabled - (@deprecated) disables the element
 *
 * @csspart bar - (@deprecated) Styles the color of bar
 *
 * @slot - (@deprecated) This is a default/unnamed slot
 * @slot container - (@deprecated) You can put some elements here
 *
 * @cssprop --text-color - (@deprecated) Controls the color of foo
 *
 * @prop {boolean} prop1 - (@deprecated) some description
 *
 * @fires custom-event - (@deprecated) some description for custom-event
 * @event {MyEventDetail} typed-custom-event - (@deprecated) some description for typed-custom-event
 */
class MyElement extends HTMLElement {}

Feel free to test it out in this demo environment.

Usage

This package includes two ways to generate an updated Custom Elements Manifest:

  1. calling a function in your build pipeline
  2. as a plugin for the Custom Element Manifest Analyzer.

Install

npm i -D custom-elements-manifest-deprecator

Build Pipeline

import { updateCemDeprecations } from "custom-elements-manifest-deprecator";
import manifest from "./path/to/custom-elements.json";

const options = {...};

updateCemDeprecations(manifest, options);

CEM Analyzer

Set-up

Ensure the following steps have been taken in your component library prior to using this plugin:

Import

// custom-elements-manifest.config.js

import { cemDeprecatorPlugin } from "custom-elements-manifest-deprecator";

const options = {
  /* add options here */
};

export default {
  plugins: [cemDeprecatorPlugin(options)],
};

Configuration

There are a number of configurations you can apply to customize the output for your components.

interface Options {
  /** The value used to indicate an element is deprecated - default is "(@deprecated)" */
  indicator?: string;
  /** When `true` the indicator will be included in the final description - default is `false` */
  preserveIndicator?: boolean;
  /** Name of the updated CEM file - default is "custom-elements.json" */
  fileName?: string;
  /** Path to output directory */
  outdir?: string;
  /** Class names of any components you would like to exclude from inheritance */
  exclude?: string[];
  /** Hides logs produced by the plugin */
  hideLogs?: boolean;
  /** Prevents plugin from executing */
  skip?: boolean;
}

Indicator

This value is used to indicate whether the tag element is deprecated. The default value is "(@deprecated)", but you can set this to whatever value you would like - "retired", '@legacy', etc.

Preserve Indicator

When the indicator is found in a description, it will remove the value from the string (similar to the default @deprecated tag behavior). If you would like to keep the indicator in the description, you can se the preserveIndicator property to true.

fileName and outdir

If you would like to add your updated Custom Elements Manifest to a specific location in your project, you can use the fileName and outdir setting for that. Otherwise, the updated manifest will be default location - ./custom-elements.json.

NOTE: If you are using the CEM Analyzer, you do not need to set these options. It will allow the analyzer to handle it based on your configuration.

exclude

If there are any classes you would like to exclude from inheritance, you can specify the class names here in a string array.