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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@liferay/js-api

v1.0.0

Published

Public Liferay DXP API to be used from Client Extensions.

Readme

@liferay/js-api

Public Liferay DXP API to be used from Client Extensions.

This package exposes the stable, public TypeScript contracts that a Client Extension uses to integrate with Liferay DXP features.

Installation

npm install @liferay/js-api

Modules

@liferay/js-api/data-set

Public type contracts for the Frontend Data Set (FDS) widget. The module exposes only types; it contains no implementation. The contracts are split by functionality across sibling modules and re-exported from the module entry point, covering four groups:

  • FDS connection and remote state (./connection) — FDSConnection (and its companion FDSConnectionConstructor) let a Client Extension read and write FDS search state and take the data set's filtering over with FDSConnectionFilter expressions and one FDSConnectionCustomConfig the data set keeps in the page URL, while FDSConnectionInfo, FDSConnectionStatus, FDSConnectionOptions, FDSConnectionOwnership, FDSState, and FDSStateChangeCallback describe how a connection is opened and observed.
  • Custom cell renderers (./cell-renderer) — FDSTableCellHTMLElementBuilder and its args, the HTML element builder a renderer implements to draw a table cell.
  • Custom filters (./filter) — FDSFilter and the HTML element builders (rendering), OData query builders (server-side filtering), and description builders (human-readable filter summaries) it composes.
  • Custom visualization modes (./visualization-mode) — FDSVisualizationMode, the factory a Client Extension exports to show the items of a data set its own way, the FDSVisualizationModeInstance it returns, whose update() draws them, and the FDSVisualizationModeArgs the data set hands it, with its FDSVisualizationModeSchema field mapping and FDSVisualizationModeSelection.
import type {
	FDSTableCellHTMLElementBuilder,
	FDSFilter,
} from '@liferay/js-api/data-set';

Custom visualization modes

A visualization mode Client Extension draws the items of a data set next to the table, list and cards it ships with. The data set owns the data and the Client Extension owns the drawing: the data set searches, filters, sorts and paginates, then hands the current page of items to the visualization mode, which draws them into the container it is given with plain DOM. No framework crosses the boundary, so the Client Extension may use any or none.

The default export is a factory, called once per instance with an empty container. It sets the instance up, such as creating the elements the items go in, and returns the instance the data set drives:

  • update(args) draws. It runs right after the factory returns, and again whenever what the data set handed over changes while the visualization mode stays visible, such as the selection. It receives the full arguments, not what changed, so the same function draws the first page and every change after it.
  • destroy() runs before the data set takes the visualization mode away. Release whatever the instance holds outside its container; the data set empties the container itself.

Reloading data, which every search, filter, sort and page change does, destroys the instance and creates a new one, so nothing kept on it outlives a reload. A page may also show the same visualization mode in several data sets at once, so keep state on the instance rather than in the module.

Read item fields through schema rather than by fixed names: the data set decides which field fills each part the visualization mode draws, so the same visualization mode works across data sets whose items name their fields differently. selection is present only when the data set lets its items be selected; toggleItem() asks the data set to change the selection, which then calls update() with the new selectedValues.

import type {
	FDSVisualizationMode,
	FDSVisualizationModeArgs,
} from '@liferay/js-api/data-set';

const visualizationMode: FDSVisualizationMode = (container) => {
	const list = document.createElement('ul');

	container.append(list);

	const draw = ({items, schema}: FDSVisualizationModeArgs) => {
		list.replaceChildren(
			...items.map((item) => {
				const entry = document.createElement('li');

				entry.textContent = String(item[schema?.title ?? 'title']);

				return entry;
			})
		);
	};

	return {destroy: () => {}, update: draw};
};

export default visualizationMode;

@liferay/js-api/data-set/connection

The typed surface of the Frontend Data Set runtime client. Unlike the data-set entry point, which re-exports only types, this module also declares FDSConnection as a value (the constructor) alongside its type (the instance), so consumers can new FDSConnection(...) and annotate with FDSConnection exactly as they would a class.

At runtime the FDS connection is implemented and served by the portal as the @liferay/frontend-data-set-web/api ES module and resolved through the import map. A Client Extension redirects that import-map specifier to this module at build time (via a tsconfig paths entry) so it can construct a connection with full typing while the value is pulled from the import-map module at runtime.

import {FDSConnection} from '@liferay/js-api/data-set/connection';

const connection = new FDSConnection(
	fdsName,
	{
		search: (query) => {
			/* ... */
		},
	},
	(info) => {
		/* ... */
	},
	{timeout: 5000}
);

Taking over the filtering

A connection drives the search and nothing else by default. Declaring owns: ['filters'] takes the data set's filtering over as well: the filters it declares stop reaching the request, it drops its filters dropdown and its filter chips, and the Client Extension owns the whole expression through setFilters().

A data set has one filtering owner and the first connection to ask for it gets it, so asking is not getting. A refused connection settles at the refused status rather than ready and drives the search alone, which a Client Extension that enables its controls once ready handles without writing any code for the case.

Owning the filtering requires an appId: whatever the Client Extension asks the data set to remember is filed in the page URL under it, and handed back through the apply callback on the next visit or when the browser's back button lands on a different address.

Call disconnect() when the Client Extension goes, from the custom element's disconnectedCallback or its framework's equivalent. A connection that is never disconnected keeps the filtering of that data set claimed, and nothing on the page can filter it again until the next full page load.

const connection = new FDSConnection(
	fdsName,
	{
		apply: (customConfig) => {
			// Nothing has validated this: it comes from a URL anyone can edit.

			const selection = parseSelection(customConfig);

			drawFilterUI(selection);

			connection.setFilters(toODataFilters(selection), selection);
		},
		search: (query) => {
			/* ... */
		},
	},
	({status}) => {
		setControlsEnabled(status === 'ready');
	},
	{appId: 'mySampleFilterApp', owns: ['filters']}
);

@liferay/js-api/editor

Types for editor transformers. EditorTransformer and EditorConfigTransformer let a Client Extension transform an editor's configuration. For CKEditor 4, see the config API.

import type {EditorTransformer} from '@liferay/js-api/editor';

This module only describes DXP's editor contracts; it does not re-export any CKEditor 5 plugin. A Client Extension that needs one (for example @ckeditor/ckeditor5-word-count) should depend on that package directly, pinned to the version the portal ships, and mark it as external in its build so the portal's import map serves it at runtime:

import {WordCount} from '@ckeditor/ckeditor5-word-count';
import type {EditorTransformer} from '@liferay/js-api/editor';

const transformer: EditorTransformer<EditorConfig> = {
	editorConfigTransformer: (config) => ({
		...config,
		plugins: [...(config.plugins ?? []), WordCount],
	}),
};

Scripts

  • yarn build — compile the TypeScript sources with tsc.
  • yarn clean — remove generated .d.ts/.js output and build info.
  • yarn test — run the test suite.
  • yarn lint / yarn lint:fix — lint the sources.
  • yarn format / yarn format:check — format the sources.